vue-intlayer 9.5.6 → 9.5.8
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/dist/cjs/devtools/buildLocalesInspectorNode.cjs +1 -0
- package/dist/cjs/devtools/index.cjs +1 -1
- package/dist/esm/devtools/buildLocalesInspectorNode.mjs +20 -0
- package/dist/esm/devtools/index.mjs +73 -30
- package/dist/types/devtools/buildLocalesInspectorNode.d.ts +18 -0
- package/dist/types/devtools/index.d.ts +3 -2
- package/package.json +10 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@intlayer/config/built");var t=`intlayer-locales`,n=`locale:`,r=`:current`,{locales:i}=e.internationalization??{},a=e=>e.startsWith(n),o=e=>e.slice(7).replace(r,``),s=e=>{let a=i??[];return{id:t,label:`Locales`,children:(e&&a.includes(e)?[e,...a.filter(t=>t!==e)]:a).map(t=>({id:`${n}${t}${t===e?r:``}`,label:t,tags:t===e?[{label:`current`,textColor:16777215,backgroundColor:4372611}]:[]}))}};exports.CURRENT_LOCALE_NODE_ID_SUFFIX=r,exports.LOCALES_GROUP_NODE_ID=t,exports.LOCALE_NODE_ID_PREFIX=n,exports.buildLocalesInspectorNode=s,exports.getLocaleFromNodeId=o,exports.isLocaleNodeId=a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./formatDictionaryForInspector.cjs");let
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../client/installIntlayer.cjs"),t=require("../client/useLocaleStorage.cjs"),n=require("./buildLocalesInspectorNode.cjs"),r=require("./formatDictionaryForInspector.cjs");let i=require("@intlayer/config/built"),a=require("vue"),o=require("@intlayer/dictionaries-entry"),s=require("@vue/devtools-api");var c=`intlayer`,l=`intlayer-dictionaries-inspector`,{defaultLocale:u,locales:d}=i.internationalization??{},f=s.setupDevtoolsPlugin,p=i=>{f({id:c,label:`Intlayer`,packageName:`vue-intlayer`,homepage:`https://intlayer.org`,componentStateTypes:[c],app:i},i=>{i.addInspector({id:l,label:`Intlayer`,icon:`language`,treeFilterPlaceholder:`Search dictionaries`,nodeActions:[{icon:`check`,tooltip:`Set as current locale`,action:r=>{if(!n.isLocaleNodeId(r))return;let a=n.getLocaleFromNodeId(r);if(!d?.map(String).includes(a)){console.error(`Locale ${a} is not available`);return}let o=e.createIntlayerClient();o.setLocale(a),t.setLocaleInStorage(a,o.isCookieEnabled??!0),i.sendInspectorTree(l),i.sendInspectorState(l)}}]}),(0,a.watch)(()=>e.createIntlayerClient().locale.value,()=>{i.sendInspectorTree(l),i.sendInspectorState(l)}),i.on.getInspectorTree(t=>{if(t.inspectorId!==`intlayer-dictionaries-inspector`)return;let r=(0,o.getDictionaries)(),i=Object.keys(r),a=e.createIntlayerClient().locale.value??u;t.rootNodes=[...i.length===0?[{id:`intlayer-no-dictionaries`,label:`No dictionaries loaded. Add an Intlayer build plugin (e.g. vite-intlayer) to generate them.`}]:i.map(e=>({id:e,label:e})),n.buildLocalesInspectorNode(a)]}),i.on.getInspectorState(t=>{if(t.inspectorId!==`intlayer-dictionaries-inspector`)return;let i=e.createIntlayerClient().locale.value??u;if(t.nodeId===`intlayer-locales`){t.state={Locales:(d??[]).map(e=>({key:e,value:e===i?`current`:``,editable:!1}))};return}if(n.isLocaleNodeId(t.nodeId)){let e=n.getLocaleFromNodeId(t.nodeId);t.state={Locale:[{key:`locale`,value:e,editable:!1},{key:`current`,value:e===i,editable:!1}]};return}let a=(0,o.getDictionaries)()[t.nodeId];if(!a){t.state={};return}let s=r.formatDictionaryForInspector(a);t.state={Translations:Object.entries(s).map(([e,t])=>({key:e,value:t,editable:!1})),Metadata:[{key:`key`,value:a.key,editable:!1},{key:`title`,value:a.title??``,editable:!1},{key:`description`,value:a.description??``,editable:!1}]}})})};exports.INTLAYER_DEVTOOLS_PLUGIN_ID=c,exports.INTLAYER_DICTIONARIES_INSPECTOR_ID=l,exports.enableIntlayerDevtools=p;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { internationalization as e } from "@intlayer/config/built";
|
|
2
|
+
//#region src/devtools/buildLocalesInspectorNode.ts
|
|
3
|
+
var t = "intlayer-locales", n = "locale:", r = ":current", { locales: i } = e ?? {}, a = (e) => e.startsWith(n), o = (e) => e.slice(7).replace(r, ""), s = (e) => {
|
|
4
|
+
let a = i ?? [];
|
|
5
|
+
return {
|
|
6
|
+
id: t,
|
|
7
|
+
label: "Locales",
|
|
8
|
+
children: (e && a.includes(e) ? [e, ...a.filter((t) => t !== e)] : a).map((t) => ({
|
|
9
|
+
id: `${n}${t}${t === e ? r : ""}`,
|
|
10
|
+
label: t,
|
|
11
|
+
tags: t === e ? [{
|
|
12
|
+
label: "current",
|
|
13
|
+
textColor: 16777215,
|
|
14
|
+
backgroundColor: 4372611
|
|
15
|
+
}] : []
|
|
16
|
+
}))
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { r as CURRENT_LOCALE_NODE_ID_SUFFIX, t as LOCALES_GROUP_NODE_ID, n as LOCALE_NODE_ID_PREFIX, s as buildLocalesInspectorNode, o as getLocaleFromNodeId, a as isLocaleNodeId };
|
|
@@ -1,41 +1,84 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { createIntlayerClient as e } from "../client/installIntlayer.mjs";
|
|
2
|
+
import { setLocaleInStorage as t } from "../client/useLocaleStorage.mjs";
|
|
3
|
+
import { buildLocalesInspectorNode as n, getLocaleFromNodeId as r, isLocaleNodeId as i } from "./buildLocalesInspectorNode.mjs";
|
|
4
|
+
import { formatDictionaryForInspector as a } from "./formatDictionaryForInspector.mjs";
|
|
5
|
+
import { internationalization as o } from "@intlayer/config/built";
|
|
6
|
+
import { watch as s } from "vue";
|
|
7
|
+
import { getDictionaries as c } from "@intlayer/dictionaries-entry";
|
|
8
|
+
import { setupDevtoolsPlugin as l } from "@vue/devtools-api";
|
|
4
9
|
//#region src/devtools/index.ts
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
id:
|
|
10
|
+
var u = "intlayer", d = "intlayer-dictionaries-inspector", { defaultLocale: f, locales: p } = o ?? {}, m = l, h = (o) => {
|
|
11
|
+
m({
|
|
12
|
+
id: u,
|
|
8
13
|
label: "Intlayer",
|
|
9
14
|
packageName: "vue-intlayer",
|
|
10
15
|
homepage: "https://intlayer.org",
|
|
11
|
-
componentStateTypes: [
|
|
12
|
-
app:
|
|
13
|
-
}, (
|
|
14
|
-
|
|
15
|
-
id:
|
|
16
|
+
componentStateTypes: [u],
|
|
17
|
+
app: o
|
|
18
|
+
}, (o) => {
|
|
19
|
+
o.addInspector({
|
|
20
|
+
id: d,
|
|
16
21
|
label: "Intlayer",
|
|
17
22
|
icon: "language",
|
|
18
|
-
treeFilterPlaceholder: "Search dictionaries"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
treeFilterPlaceholder: "Search dictionaries",
|
|
24
|
+
nodeActions: [{
|
|
25
|
+
icon: "check",
|
|
26
|
+
tooltip: "Set as current locale",
|
|
27
|
+
action: (n) => {
|
|
28
|
+
if (!i(n)) return;
|
|
29
|
+
let a = r(n);
|
|
30
|
+
if (!p?.map(String).includes(a)) {
|
|
31
|
+
console.error(`Locale ${a} is not available`);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let s = e();
|
|
35
|
+
s.setLocale(a), t(a, s.isCookieEnabled ?? !0), o.sendInspectorTree(d), o.sendInspectorState(d);
|
|
36
|
+
}
|
|
37
|
+
}]
|
|
38
|
+
}), s(() => e().locale.value, () => {
|
|
39
|
+
o.sendInspectorTree(d), o.sendInspectorState(d);
|
|
40
|
+
}), o.on.getInspectorTree((t) => {
|
|
41
|
+
if (t.inspectorId !== "intlayer-dictionaries-inspector") return;
|
|
42
|
+
let r = c(), i = Object.keys(r), a = e().locale.value ?? f;
|
|
43
|
+
t.rootNodes = [...i.length === 0 ? [{
|
|
23
44
|
id: "intlayer-no-dictionaries",
|
|
24
45
|
label: "No dictionaries loaded. Add an Intlayer build plugin (e.g. vite-intlayer) to generate them."
|
|
25
|
-
}] :
|
|
46
|
+
}] : i.map((e) => ({
|
|
26
47
|
id: e,
|
|
27
48
|
label: e
|
|
28
|
-
}));
|
|
29
|
-
}),
|
|
30
|
-
if (
|
|
31
|
-
let
|
|
32
|
-
if (
|
|
33
|
-
|
|
49
|
+
})), n(a)];
|
|
50
|
+
}), o.on.getInspectorState((t) => {
|
|
51
|
+
if (t.inspectorId !== "intlayer-dictionaries-inspector") return;
|
|
52
|
+
let n = e().locale.value ?? f;
|
|
53
|
+
if (t.nodeId === "intlayer-locales") {
|
|
54
|
+
t.state = { Locales: (p ?? []).map((e) => ({
|
|
55
|
+
key: e,
|
|
56
|
+
value: e === n ? "current" : "",
|
|
57
|
+
editable: !1
|
|
58
|
+
})) };
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (i(t.nodeId)) {
|
|
62
|
+
let e = r(t.nodeId);
|
|
63
|
+
t.state = { Locale: [{
|
|
64
|
+
key: "locale",
|
|
65
|
+
value: e,
|
|
66
|
+
editable: !1
|
|
67
|
+
}, {
|
|
68
|
+
key: "current",
|
|
69
|
+
value: e === n,
|
|
70
|
+
editable: !1
|
|
71
|
+
}] };
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
let o = c()[t.nodeId];
|
|
75
|
+
if (!o) {
|
|
76
|
+
t.state = {};
|
|
34
77
|
return;
|
|
35
78
|
}
|
|
36
|
-
let
|
|
37
|
-
|
|
38
|
-
Translations: Object.entries(
|
|
79
|
+
let s = a(o);
|
|
80
|
+
t.state = {
|
|
81
|
+
Translations: Object.entries(s).map(([e, t]) => ({
|
|
39
82
|
key: e,
|
|
40
83
|
value: t,
|
|
41
84
|
editable: !1
|
|
@@ -43,17 +86,17 @@ var r = "intlayer", i = "intlayer-dictionaries-inspector", a = n, o = (n) => {
|
|
|
43
86
|
Metadata: [
|
|
44
87
|
{
|
|
45
88
|
key: "key",
|
|
46
|
-
value:
|
|
89
|
+
value: o.key,
|
|
47
90
|
editable: !1
|
|
48
91
|
},
|
|
49
92
|
{
|
|
50
93
|
key: "title",
|
|
51
|
-
value:
|
|
94
|
+
value: o.title ?? "",
|
|
52
95
|
editable: !1
|
|
53
96
|
},
|
|
54
97
|
{
|
|
55
98
|
key: "description",
|
|
56
|
-
value:
|
|
99
|
+
value: o.description ?? "",
|
|
57
100
|
editable: !1
|
|
58
101
|
}
|
|
59
102
|
]
|
|
@@ -62,4 +105,4 @@ var r = "intlayer", i = "intlayer-dictionaries-inspector", a = n, o = (n) => {
|
|
|
62
105
|
});
|
|
63
106
|
};
|
|
64
107
|
//#endregion
|
|
65
|
-
export {
|
|
108
|
+
export { u as INTLAYER_DEVTOOLS_PLUGIN_ID, d as INTLAYER_DICTIONARIES_INSPECTOR_ID, h as enableIntlayerDevtools };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Locale } from '@intlayer/types/allLocales';
|
|
2
|
+
import { CustomInspectorNode } from '@vue/devtools-api';
|
|
3
|
+
export declare const LOCALES_GROUP_NODE_ID = "intlayer-locales";
|
|
4
|
+
export declare const LOCALE_NODE_ID_PREFIX = "locale:";
|
|
5
|
+
export declare const CURRENT_LOCALE_NODE_ID_SUFFIX = ":current";
|
|
6
|
+
export declare const isLocaleNodeId: (nodeId: string) => boolean;
|
|
7
|
+
export declare const getLocaleFromNodeId: (nodeId: string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Build the "Locales" group node of the devtools inspector: one child node
|
|
10
|
+
* per available locale, the current one highlighted with a tag.
|
|
11
|
+
*
|
|
12
|
+
* The current locale is listed first AND its node id carries a `:current`
|
|
13
|
+
* suffix: devtools frontends cache the tree by node id, so changing the id
|
|
14
|
+
* forces the row that gains/loses the tag to be re-rendered even when the
|
|
15
|
+
* frontend would otherwise consider the tree unchanged and skip the refetch
|
|
16
|
+
* triggered by `sendInspectorTree`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const buildLocalesInspectorNode: (currentLocale?: Locale) => CustomInspectorNode;
|
|
@@ -2,8 +2,9 @@ import { App } from 'vue';
|
|
|
2
2
|
export declare const INTLAYER_DEVTOOLS_PLUGIN_ID = "intlayer";
|
|
3
3
|
export declare const INTLAYER_DICTIONARIES_INSPECTOR_ID = "intlayer-dictionaries-inspector";
|
|
4
4
|
/**
|
|
5
|
-
* Register the Intlayer plugin in Vue Devtools with
|
|
6
|
-
*
|
|
5
|
+
* Register the Intlayer plugin in Vue Devtools with an inspector listing
|
|
6
|
+
* the loaded dictionaries and their translations, plus a "Locales" group
|
|
7
|
+
* node allowing to switch the current locale of the app.
|
|
7
8
|
*
|
|
8
9
|
* Lazy-loaded by `installIntlayer`; safe to call only in a browser
|
|
9
10
|
* environment where the devtools hook may exist — `setupDevtoolsPlugin`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-intlayer",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Vue applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -103,12 +103,12 @@
|
|
|
103
103
|
"typecheck": "vue-tsc --noEmit --project tsconfig.types.json"
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
|
-
"@intlayer/api": "9.5.
|
|
107
|
-
"@intlayer/config": "9.5.
|
|
108
|
-
"@intlayer/core": "9.5.
|
|
109
|
-
"@intlayer/dictionaries-entry": "9.5.
|
|
110
|
-
"@intlayer/editor": "9.5.
|
|
111
|
-
"@intlayer/types": "9.5.
|
|
106
|
+
"@intlayer/api": "9.5.8",
|
|
107
|
+
"@intlayer/config": "9.5.8",
|
|
108
|
+
"@intlayer/core": "9.5.8",
|
|
109
|
+
"@intlayer/dictionaries-entry": "9.5.8",
|
|
110
|
+
"@intlayer/editor": "9.5.8",
|
|
111
|
+
"@intlayer/types": "9.5.8",
|
|
112
112
|
"@vue/devtools-api": "^6.6.4"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
@@ -123,12 +123,12 @@
|
|
|
123
123
|
"tsdown": "0.23.0",
|
|
124
124
|
"typescript": "7.0.2",
|
|
125
125
|
"vite": "8.3.0",
|
|
126
|
-
"vite-plugin-dts": "5.1.
|
|
126
|
+
"vite-plugin-dts": "5.1.1",
|
|
127
127
|
"vitest": "5.0.1",
|
|
128
128
|
"vue-tsc": "3.3.9"
|
|
129
129
|
},
|
|
130
130
|
"peerDependencies": {
|
|
131
|
-
"intlayer": "9.5.
|
|
131
|
+
"intlayer": "9.5.8",
|
|
132
132
|
"vue": ">=3.0.0"
|
|
133
133
|
},
|
|
134
134
|
"peerDependenciesMeta": {
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
}
|
|
138
138
|
},
|
|
139
139
|
"optionalDependencies": {
|
|
140
|
-
"@intlayer/analytics": "9.5.
|
|
140
|
+
"@intlayer/analytics": "9.5.8"
|
|
141
141
|
},
|
|
142
142
|
"engines": {
|
|
143
143
|
"node": ">=14.18"
|