@intentic/extension-ui 1.304.0 → 1.306.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/types/extension-ui/src/i18n.d.ts +11 -0
- package/dist/types/ui/src/components/overlays/ContextMenu.vue.d.ts +5 -1
- package/dist/types/ui/src/composables/useNow.d.ts +2 -2
- package/dist/types/ui/src/icons/iconSets.d.ts +1 -1
- package/dist/types/ui/src/lib/format.d.ts +2 -0
- package/package.json +1 -1
- package/src/i18n.ts +21 -0
package/README.md
CHANGED
|
@@ -29,9 +29,11 @@ authors is a marketplace-phase task.
|
|
|
29
29
|
|
|
30
30
|
- [src/index.ts](src/index.ts), the whole surface: which components and helpers an extension may render with.
|
|
31
31
|
- [src/format.ts](src/format.ts): the shared formatters, so two extensions render a duration the same way.
|
|
32
|
-
- [src/i18n.ts](src/i18n.ts): the extension's words. `
|
|
33
|
-
|
|
34
|
-
`
|
|
32
|
+
- [src/i18n.ts](src/i18n.ts): the extension's words. `extensionI18n(id, base, load)` is the one call every in-repo
|
|
33
|
+
extension's `src/i18n.ts` now makes, returning the catalog the host mounts and the translator its components read;
|
|
34
|
+
`extensionT(id)` is that translator alone, bound to its own slice of the host's one message tree, and
|
|
35
|
+
`registerExtensionMessages` mounts a catalog, which is what the host does before `activate` and what a test
|
|
36
|
+
calling `activate` itself has to do instead.
|
|
35
37
|
|
|
36
38
|
## The one control worth calling out
|
|
37
39
|
|
|
@@ -2,6 +2,17 @@ import { type Locale, type MessageTree } from "../../ui/src/i18n/index.js";
|
|
|
2
2
|
import type { Ref } from "vue";
|
|
3
3
|
export type ExtensionT = (key: string, values?: Record<string, unknown>, plural?: number) => string;
|
|
4
4
|
export declare const extensionT: (extensionId: string) => ExtensionT;
|
|
5
|
+
export declare const extensionI18n: (extensionId: string, base: MessageTree, load: (locale: string) => Promise<{
|
|
6
|
+
readonly default: MessageTree;
|
|
7
|
+
}>) => {
|
|
8
|
+
readonly messages: {
|
|
9
|
+
readonly base: MessageTree;
|
|
10
|
+
readonly load: (locale: string) => Promise<{
|
|
11
|
+
readonly default: MessageTree;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
readonly t: ExtensionT;
|
|
15
|
+
};
|
|
5
16
|
export declare const registerExtensionMessages: (extensionId: string, messages: {
|
|
6
17
|
readonly base: MessageTree;
|
|
7
18
|
readonly load: (locale: string) => Promise<{
|
|
@@ -7,6 +7,10 @@ type __VLS_Props = {
|
|
|
7
7
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
8
8
|
show: (event: Event) => void;
|
|
9
9
|
hide: () => void;
|
|
10
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
10
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
11
|
+
hide: () => any;
|
|
12
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
13
|
+
onHide?: (() => any) | undefined;
|
|
14
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
11
15
|
declare const _default: typeof __VLS_export;
|
|
12
16
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare function useNow(active?: MaybeRefOrGetter<boolean>):
|
|
1
|
+
import { type ComputedRef, type MaybeRefOrGetter } from "vue";
|
|
2
|
+
export declare function useNow(active?: MaybeRefOrGetter<boolean>): ComputedRef<number>;
|
|
@@ -557,4 +557,4 @@ export declare const ICONS: {
|
|
|
557
557
|
};
|
|
558
558
|
export type IconName = keyof typeof ICONS;
|
|
559
559
|
export declare const isIconName: (name: string) => name is IconName;
|
|
560
|
-
export declare const
|
|
560
|
+
export declare const sectionIcon: (section: string, fallback?: IconName) => IconName | undefined;
|
|
@@ -2,7 +2,9 @@ export declare const formatBytes: (bytes: number | undefined) => string;
|
|
|
2
2
|
export declare const formatDuration: (seconds: number) => string;
|
|
3
3
|
export declare const formatTokens: (tokens: number) => string;
|
|
4
4
|
export declare const initialsOf: (name: string) => string | undefined;
|
|
5
|
+
export declare const formatFixed: (value: number, digits: number) => string;
|
|
5
6
|
export declare const setFormatLocale: (tag: string) => void;
|
|
7
|
+
export declare const formatPercent: (percent: number) => string;
|
|
6
8
|
export declare const formatDate: (at: number) => string;
|
|
7
9
|
export declare const formatDateLong: (at: number | string) => string;
|
|
8
10
|
export declare const formatDayMonth: (at: number) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentic/extension-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.306.0",
|
|
4
4
|
"description": "The UI kit intentic extensions render with, host-provided at runtime (the app's own components via the import map), so extension UI is always native to the shell",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/i18n.ts
CHANGED
|
@@ -36,6 +36,27 @@ export type ExtensionT = (key: string, values?: Record<string, unknown>, plural?
|
|
|
36
36
|
*/
|
|
37
37
|
export const extensionT = (extensionId: string): ExtensionT => useT(`ext.${extensionId}`);
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* One extension's words in one call: the catalog the host mounts (`messages`) and the translator its components
|
|
41
|
+
* read (`t`), which were the same twenty lines in every in-repo extension. The loader stays at the CALL SITE
|
|
42
|
+
* because its specifier has to be a literal template — that is what emits one chunk per language rather than one
|
|
43
|
+
* request carrying all of them — and the id is passed in rather than derived, so this package's published types
|
|
44
|
+
* still reach no further than `vue` and the locale table.
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* // src/i18n.ts
|
|
48
|
+
* export const { messages, t } = extensionI18n(extensionIdOf(manifest), base, (locale) => import(`./locales/${locale}.json`));
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export const extensionI18n = (
|
|
52
|
+
extensionId: string,
|
|
53
|
+
base: MessageTree,
|
|
54
|
+
load: (locale: string) => Promise<{ readonly default: MessageTree }>,
|
|
55
|
+
): {
|
|
56
|
+
readonly messages: { readonly base: MessageTree; readonly load: (locale: string) => Promise<{ readonly default: MessageTree }> };
|
|
57
|
+
readonly t: ExtensionT;
|
|
58
|
+
} => ({ messages: { base, load }, t: extensionT(extensionId) });
|
|
59
|
+
|
|
39
60
|
/**
|
|
40
61
|
* Mounts an extension's own messages under its slice of the tree — what the HOST does before it calls `activate`, and
|
|
41
62
|
* what a test that calls `activate` itself has to do instead, or every label it asserts on reads as a dotted key.
|