Tracking de l'application VApp (IHM du jeu)

This commit is contained in:
2025-05-11 18:04:12 +02:00
commit 89e9db9b62
17763 changed files with 3718499 additions and 0 deletions

View File

@ -0,0 +1,29 @@
import { I18n, useI18n } from 'vue-i18n';
import { Ref } from 'vue';
interface LocaleMessages {
[key: string]: LocaleMessages | string;
}
interface LocaleOptions {
messages?: LocaleMessages;
locale?: string;
fallback?: string;
adapter?: LocaleInstance;
}
interface LocaleInstance {
name: string;
messages: Ref<LocaleMessages>;
current: Ref<string>;
fallback: Ref<string>;
t: (key: string, ...params: unknown[]) => string;
n: (value: number) => string;
provide: (props: LocaleOptions) => LocaleInstance;
}
type VueI18nAdapterParams = {
i18n: I18n<any, {}, {}, string, false>;
useI18n: typeof useI18n;
};
declare function createVueI18nAdapter({ i18n, useI18n }: VueI18nAdapterParams): LocaleInstance;
export { createVueI18nAdapter };

View File

@ -0,0 +1,83 @@
// Composables
import { useProxiedModel } from "../../composables/proxiedModel.mjs"; // Utilities
import { watch } from 'vue';
// Types
function useProvided(props, prop, provided) {
const internal = useProxiedModel(props, prop);
internal.value = props[prop] ?? provided.value;
watch(provided, v => {
if (props[prop] == null) {
internal.value = v;
}
});
return internal;
}
function createProvideFunction(data) {
return props => {
const current = useProvided(props, 'locale', data.current);
const fallback = useProvided(props, 'fallback', data.fallback);
const messages = useProvided(props, 'messages', data.messages);
const i18n = data.useI18n({
locale: current.value,
fallbackLocale: fallback.value,
messages: messages.value,
useScope: 'local',
legacy: false,
inheritLocale: false
});
watch(current, v => {
i18n.locale.value = v;
});
return {
name: 'vue-i18n',
current,
fallback,
messages,
t: function (key) {
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
params[_key - 1] = arguments[_key];
}
return i18n.t(key, params);
},
n: i18n.n,
provide: createProvideFunction({
current,
fallback,
messages,
useI18n: data.useI18n
})
};
};
}
export function createVueI18nAdapter(_ref) {
let {
i18n,
useI18n
} = _ref;
const current = i18n.global.locale;
const fallback = i18n.global.fallbackLocale;
const messages = i18n.global.messages;
return {
name: 'vue-i18n',
current,
fallback,
messages,
// @ts-expect-error Type instantiation is excessively deep and possibly infinite
t: function (key) {
for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
params[_key2 - 1] = arguments[_key2];
}
return i18n.global.t(key, params);
},
n: i18n.global.n,
provide: createProvideFunction({
current,
fallback,
messages,
useI18n
})
};
}
//# sourceMappingURL=vue-i18n.mjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,24 @@
import { Ref } from 'vue';
interface LocaleMessages {
[key: string]: LocaleMessages | string;
}
interface LocaleOptions {
messages?: LocaleMessages;
locale?: string;
fallback?: string;
adapter?: LocaleInstance;
}
interface LocaleInstance {
name: string;
messages: Ref<LocaleMessages>;
current: Ref<string>;
fallback: Ref<string>;
t: (key: string, ...params: unknown[]) => string;
n: (value: number) => string;
provide: (props: LocaleOptions) => LocaleInstance;
}
declare function createVuetifyAdapter(options?: LocaleOptions): LocaleInstance;
export { createVuetifyAdapter };

View File

@ -0,0 +1,98 @@
// Composables
import { useProxiedModel } from "../../composables/proxiedModel.mjs"; // Utilities
import { ref, shallowRef, watch } from 'vue';
import { consoleError, consoleWarn, getObjectValueByPath } from "../../util/index.mjs"; // Locales
import en from "../en.mjs"; // Types
const LANG_PREFIX = '$vuetify.';
const replace = (str, params) => {
return str.replace(/\{(\d+)\}/g, (match, index) => {
return String(params[+index]);
});
};
const createTranslateFunction = (current, fallback, messages) => {
return function (key) {
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
params[_key - 1] = arguments[_key];
}
if (!key.startsWith(LANG_PREFIX)) {
return replace(key, params);
}
const shortKey = key.replace(LANG_PREFIX, '');
const currentLocale = current.value && messages.value[current.value];
const fallbackLocale = fallback.value && messages.value[fallback.value];
let str = getObjectValueByPath(currentLocale, shortKey, null);
if (!str) {
consoleWarn(`Translation key "${key}" not found in "${current.value}", trying fallback locale`);
str = getObjectValueByPath(fallbackLocale, shortKey, null);
}
if (!str) {
consoleError(`Translation key "${key}" not found in fallback`);
str = key;
}
if (typeof str !== 'string') {
consoleError(`Translation key "${key}" has a non-string value`);
str = key;
}
return replace(str, params);
};
};
function createNumberFunction(current, fallback) {
return (value, options) => {
const numberFormat = new Intl.NumberFormat([current.value, fallback.value], options);
return numberFormat.format(value);
};
}
function useProvided(props, prop, provided) {
const internal = useProxiedModel(props, prop, props[prop] ?? provided.value);
// TODO: Remove when defaultValue works
internal.value = props[prop] ?? provided.value;
watch(provided, v => {
if (props[prop] == null) {
internal.value = provided.value;
}
});
return internal;
}
function createProvideFunction(state) {
return props => {
const current = useProvided(props, 'locale', state.current);
const fallback = useProvided(props, 'fallback', state.fallback);
const messages = useProvided(props, 'messages', state.messages);
return {
name: 'vuetify',
current,
fallback,
messages,
t: createTranslateFunction(current, fallback, messages),
n: createNumberFunction(current, fallback),
provide: createProvideFunction({
current,
fallback,
messages
})
};
};
}
export function createVuetifyAdapter(options) {
const current = shallowRef(options?.locale ?? 'en');
const fallback = shallowRef(options?.fallback ?? 'en');
const messages = ref({
en,
...options?.messages
});
return {
name: 'vuetify',
current,
fallback,
messages,
t: createTranslateFunction(current, fallback, messages),
n: createNumberFunction(current, fallback),
provide: createProvideFunction({
current,
fallback,
messages
})
};
}
//# sourceMappingURL=vuetify.mjs.map

File diff suppressed because one or more lines are too long