vue-intlayer 9.6.0 → 9.7.1
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/analytics/useAnalytics.cjs +1 -1
- package/dist/cjs/analytics/useConversion.cjs +1 -1
- package/dist/cjs/analytics/useExperiment.cjs +1 -1
- package/dist/cjs/client/useLocale.cjs +1 -1
- package/dist/cjs/devtools/editDictionaryContent.cjs +1 -0
- package/dist/cjs/devtools/editorServer.cjs +1 -0
- package/dist/cjs/devtools/formatDictionaryForInspector.cjs +1 -1
- package/dist/cjs/devtools/index.cjs +1 -1
- package/dist/cjs/editor/useEditor.cjs +1 -1
- package/dist/cjs/format/index.cjs +1 -1
- package/dist/cjs/format/useCompact.cjs +1 -1
- package/dist/cjs/format/useCurrency.cjs +1 -1
- package/dist/cjs/format/useDate.cjs +1 -1
- package/dist/cjs/format/useIntl.cjs +1 -1
- package/dist/cjs/format/useList.cjs +1 -1
- package/dist/cjs/format/useNumber.cjs +1 -1
- package/dist/cjs/format/usePercentage.cjs +1 -1
- package/dist/cjs/format/useRelativeTime.cjs +1 -1
- package/dist/cjs/format/useUnit.cjs +1 -1
- package/dist/cjs/html/index.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/plugins.cjs +1 -1
- package/dist/esm/UI/ContentSelector.mjs +1 -2
- package/dist/esm/analytics/exposureSink.mjs +1 -2
- package/dist/esm/analytics/useAnalytics.mjs +19 -20
- package/dist/esm/analytics/useConversion.mjs +3 -4
- package/dist/esm/analytics/useExperiment.mjs +4 -5
- package/dist/esm/client/installIntlayer.mjs +1 -2
- package/dist/esm/client/useDictionary.mjs +1 -2
- package/dist/esm/client/useDictionaryAsync.mjs +1 -2
- package/dist/esm/client/useDictionaryDynamic.mjs +1 -2
- package/dist/esm/client/useIntlayer.mjs +1 -2
- package/dist/esm/client/useLoadDynamic.mjs +1 -2
- package/dist/esm/client/useLocale.mjs +6 -11
- package/dist/esm/client/useLocaleStorage.mjs +1 -2
- package/dist/esm/client/usePathname.mjs +1 -2
- package/dist/esm/client/useRewriteURL.mjs +1 -2
- package/dist/esm/devtools/buildLocalesInspectorNode.mjs +1 -2
- package/dist/esm/devtools/editDictionaryContent.mjs +28 -0
- package/dist/esm/devtools/editorServer.mjs +20 -0
- package/dist/esm/devtools/formatDictionaryForInspector.mjs +38 -29
- package/dist/esm/devtools/index.mjs +155 -57
- package/dist/esm/editor/ContentSelector.mjs +1 -3
- package/dist/esm/editor/useEditor.mjs +28 -26
- package/dist/esm/format/index.mjs +10 -10
- package/dist/esm/format/useCompact.mjs +3 -4
- package/dist/esm/format/useCurrency.mjs +3 -4
- package/dist/esm/format/useDate.mjs +3 -4
- package/dist/esm/format/useIntl.mjs +3 -4
- package/dist/esm/format/useList.mjs +3 -4
- package/dist/esm/format/useNumber.mjs +3 -4
- package/dist/esm/format/usePercentage.mjs +3 -4
- package/dist/esm/format/useRelativeTime.mjs +3 -4
- package/dist/esm/format/useUnit.mjs +3 -4
- package/dist/esm/getDictionary.mjs +1 -2
- package/dist/esm/getIntlayer.mjs +1 -2
- package/dist/esm/html/HTMLRenderer.mjs +1 -2
- package/dist/esm/html/index.mjs +3 -3
- package/dist/esm/html/installIntlayerHTML.mjs +1 -2
- package/dist/esm/index.mjs +17 -17
- package/dist/esm/markdown/MarkdownRenderer.mjs +1 -2
- package/dist/esm/markdown/compiler.mjs +1 -2
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +1 -2
- package/dist/esm/markdown/runtime.mjs +1 -2
- package/dist/esm/plugins.mjs +63 -64
- package/dist/esm/renderIntlayerNode.mjs +1 -2
- package/dist/esm-BnFj8Txc.js +1 -0
- package/dist/{esm-CtrrRmRn.mjs → esm-hfQR-yiQ.mjs} +77 -82
- package/dist/{isEnabled-BbWU6Ox5.mjs → isEnabled-DVKEZ2He.mjs} +1 -2
- package/dist/rolldown-runtime-BocRIvOZ.js +1 -0
- package/dist/types/devtools/editDictionaryContent.d.ts +47 -0
- package/dist/types/devtools/editorServer.d.ts +26 -0
- package/dist/types/devtools/formatDictionaryForInspector.d.ts +20 -0
- package/dist/types/devtools/index.d.ts +7 -0
- package/package.json +14 -14
- package/dist/esm-CXlI80Tk.js +0 -1
|
@@ -1,31 +1,38 @@
|
|
|
1
|
-
import { r as e } from "./isEnabled-
|
|
1
|
+
import { r as e } from "./isEnabled-DVKEZ2He.mjs";
|
|
2
2
|
import { analytics as t, editor as n } from "@intlayer/config/built";
|
|
3
|
-
|
|
4
|
-
var r = (e) => {
|
|
3
|
+
// ../@intlayer/analytics/dist/esm/events/contentExposure.mjs
|
|
4
|
+
var r = (e) => e.map((e) => e.key === void 0 ? "*" : String(e.key)).join("."), i = (e) => ({
|
|
5
|
+
dictionaryKey: e.dictionaryKey,
|
|
6
|
+
keyPath: r(e.keyPath),
|
|
7
|
+
locale: e.locale,
|
|
8
|
+
nodeType: e.nodeType,
|
|
9
|
+
experimentKey: e.experimentKey,
|
|
10
|
+
variant: e.variant
|
|
11
|
+
}), a = (e) => {
|
|
5
12
|
let t = 2166136261;
|
|
6
13
|
for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
7
14
|
return t >>> 0;
|
|
8
|
-
},
|
|
15
|
+
}, o = (e, t, n, r) => {
|
|
9
16
|
if (n.length === 0) throw Error("assignVariant requires at least one variant");
|
|
10
17
|
if (n.length === 1) return n[0];
|
|
11
|
-
let
|
|
12
|
-
if (!
|
|
13
|
-
let e = Math.floor(
|
|
18
|
+
let i = a(`${e}:${t}`) / 4294967296;
|
|
19
|
+
if (!r || r.length !== n.length) {
|
|
20
|
+
let e = Math.floor(i * n.length);
|
|
14
21
|
return n[Math.min(e, n.length - 1)];
|
|
15
22
|
}
|
|
16
|
-
let o =
|
|
17
|
-
if (o <= 0) return n[Math.floor(
|
|
18
|
-
let s = 0, c =
|
|
19
|
-
for (let e = 0; e < n.length; e++) if (s +=
|
|
23
|
+
let o = r.reduce((e, t) => e + t, 0);
|
|
24
|
+
if (o <= 0) return n[Math.floor(i * n.length)];
|
|
25
|
+
let s = 0, c = i * o;
|
|
26
|
+
for (let e = 0; e < n.length; e++) if (s += r[e], c < s) return n[e];
|
|
20
27
|
return n[n.length - 1];
|
|
21
|
-
},
|
|
28
|
+
}, s = "", c = (e) => [
|
|
22
29
|
e.url,
|
|
23
30
|
e.dictionaryKey,
|
|
24
31
|
e.keyPath,
|
|
25
32
|
e.locale,
|
|
26
33
|
e.experimentKey ?? "",
|
|
27
34
|
e.variant ?? ""
|
|
28
|
-
].join(
|
|
35
|
+
].join(s), l = ({ max: e }) => {
|
|
29
36
|
let t = [], n = /* @__PURE__ */ new Map(), r = () => t.length + n.size, i = () => {
|
|
30
37
|
for (; r() > e && n.size > 0;) {
|
|
31
38
|
let e = n.keys().next().value;
|
|
@@ -36,7 +43,7 @@ var r = (e) => {
|
|
|
36
43
|
return {
|
|
37
44
|
push: (e) => {
|
|
38
45
|
if (e.type === "content_exposure") {
|
|
39
|
-
let t =
|
|
46
|
+
let t = c(e), r = n.get(t);
|
|
40
47
|
r ? (r.count = (r.count ?? 1) + (e.count ?? 1), r.t = e.t) : n.set(t, {
|
|
41
48
|
...e,
|
|
42
49
|
count: e.count ?? 1
|
|
@@ -50,20 +57,20 @@ var r = (e) => {
|
|
|
50
57
|
},
|
|
51
58
|
size: r
|
|
52
59
|
};
|
|
53
|
-
},
|
|
60
|
+
}, u = (e, t) => t >= 1 ? !0 : t <= 0 ? !1 : a(e) / 4294967295 < t, d = "__intlayer_analytics_sid__", f = () => {
|
|
54
61
|
let e = typeof globalThis < "u" ? globalThis.crypto : void 0;
|
|
55
62
|
return e?.randomUUID ? e.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
56
|
-
},
|
|
57
|
-
if (typeof window > "u" || !window.sessionStorage) return
|
|
63
|
+
}, p = () => {
|
|
64
|
+
if (typeof window > "u" || !window.sessionStorage) return f();
|
|
58
65
|
try {
|
|
59
|
-
let e = window.sessionStorage.getItem(
|
|
66
|
+
let e = window.sessionStorage.getItem(d);
|
|
60
67
|
if (e) return e;
|
|
61
|
-
let t =
|
|
62
|
-
return window.sessionStorage.setItem(
|
|
68
|
+
let t = f();
|
|
69
|
+
return window.sessionStorage.setItem(d, t), t;
|
|
63
70
|
} catch {
|
|
64
|
-
return
|
|
71
|
+
return f();
|
|
65
72
|
}
|
|
66
|
-
},
|
|
73
|
+
}, m = (e, t, { useBeacon: n = !1, token: r } = {}) => {
|
|
67
74
|
try {
|
|
68
75
|
let i = JSON.stringify(t);
|
|
69
76
|
return n && typeof navigator < "u" && typeof navigator.sendBeacon == "function" ? navigator.sendBeacon(e, i) : typeof fetch == "function" && (fetch(e, {
|
|
@@ -80,32 +87,28 @@ var r = (e) => {
|
|
|
80
87
|
} catch {
|
|
81
88
|
return !1;
|
|
82
89
|
}
|
|
83
|
-
},
|
|
90
|
+
}, h = (e) => {
|
|
84
91
|
if (typeof window > "u") return;
|
|
85
92
|
let t = window.requestIdleCallback;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
setTimeout(e, 1);
|
|
91
|
-
}, m = "__intlayer_public_token__", h = 6e4, g = () => {
|
|
93
|
+
typeof t == "function" ? t(() => e()) : setTimeout(e, 1);
|
|
94
|
+
}, g = "__intlayer_public_token__", _ = 6e4, v = () => {
|
|
92
95
|
try {
|
|
93
|
-
let e = window.sessionStorage?.getItem(
|
|
96
|
+
let e = window.sessionStorage?.getItem(g);
|
|
94
97
|
if (!e) return null;
|
|
95
98
|
let t = JSON.parse(e);
|
|
96
99
|
return typeof t?.token != "string" || typeof t?.expiresAt != "number" ? null : t;
|
|
97
100
|
} catch {
|
|
98
101
|
return null;
|
|
99
102
|
}
|
|
100
|
-
},
|
|
103
|
+
}, y = (e) => {
|
|
101
104
|
try {
|
|
102
|
-
window.sessionStorage?.setItem(
|
|
105
|
+
window.sessionStorage?.setItem(g, JSON.stringify(e));
|
|
103
106
|
} catch {}
|
|
104
|
-
},
|
|
105
|
-
let n = `${e.replace(/\/$/, "")}/api/public/token`, r = null, i = null, a = (e) => e !== null && e.expiresAt -
|
|
107
|
+
}, b = ({ backendURL: e, clientId: t }) => {
|
|
108
|
+
let n = `${e.replace(/\/$/, "")}/api/public/token`, r = null, i = null, a = (e) => e !== null && e.expiresAt - _ > Date.now(), o = () => {
|
|
106
109
|
if (a(r)) return r.token;
|
|
107
110
|
if (typeof window < "u") {
|
|
108
|
-
let e =
|
|
111
|
+
let e = v();
|
|
109
112
|
if (a(e)) return r = e, e.token;
|
|
110
113
|
}
|
|
111
114
|
}, s = async () => {
|
|
@@ -123,7 +126,7 @@ var r = (e) => {
|
|
|
123
126
|
r = {
|
|
124
127
|
token: a,
|
|
125
128
|
expiresAt: Date.now() + o * 1e3
|
|
126
|
-
}, typeof window < "u" &&
|
|
129
|
+
}, typeof window < "u" && y(r);
|
|
127
130
|
} catch {} finally {
|
|
128
131
|
i = null;
|
|
129
132
|
}
|
|
@@ -134,59 +137,59 @@ var r = (e) => {
|
|
|
134
137
|
t && typeof fetch == "function" && (o() || (i ||= s()));
|
|
135
138
|
}
|
|
136
139
|
};
|
|
137
|
-
},
|
|
140
|
+
}, x = "intlayer-analytics/1", S = () => typeof window > "u" || !window.location ? "" : window.location.pathname, C = () => {
|
|
138
141
|
if (typeof document < "u" && document.referrer) try {
|
|
139
142
|
return new URL(document.referrer).host;
|
|
140
143
|
} catch {
|
|
141
144
|
return;
|
|
142
145
|
}
|
|
143
|
-
},
|
|
144
|
-
let n =
|
|
146
|
+
}, w = (t) => {
|
|
147
|
+
let n = p(), r = e(), i = !r && u(n, t.sampleRate), a = l({ max: t.maxBufferSize }), s = `${t.backendURL.replace(/\/$/, "")}/api/analytics/events`, c = b({
|
|
145
148
|
backendURL: t.backendURL,
|
|
146
149
|
clientId: t.clientId
|
|
147
|
-
}),
|
|
148
|
-
let r =
|
|
149
|
-
for (let a = 0; a < r.length; a += 200)
|
|
150
|
+
}), d = "", f = null, g = !1, _ = null, v = null, y = /* @__PURE__ */ new Set(), w = (e = !1) => {
|
|
151
|
+
let r = a.drain(), i = c.getToken();
|
|
152
|
+
for (let a = 0; a < r.length; a += 200) m(s, {
|
|
150
153
|
token: i,
|
|
151
154
|
clientId: i ? void 0 : t.clientId,
|
|
152
155
|
sessionId: n,
|
|
153
|
-
sdkVersion:
|
|
156
|
+
sdkVersion: x,
|
|
154
157
|
events: r.slice(a, a + 200)
|
|
155
158
|
}, {
|
|
156
159
|
useBeacon: e,
|
|
157
160
|
token: i
|
|
158
161
|
});
|
|
159
162
|
}, T = (e) => {
|
|
160
|
-
|
|
163
|
+
a.push(e) >= t.maxBufferSize && w();
|
|
161
164
|
}, E = (e) => {
|
|
162
|
-
|
|
165
|
+
d = e;
|
|
163
166
|
}, D = (e = {}) => {
|
|
164
|
-
if (!
|
|
165
|
-
let t = e.url ??
|
|
166
|
-
(n !== "route_change" || t !==
|
|
167
|
+
if (!i) return;
|
|
168
|
+
let t = e.url ?? S(), n = e.reason ?? "initial";
|
|
169
|
+
(n !== "route_change" || t !== v) && (v = t, y = /* @__PURE__ */ new Set(), T({
|
|
167
170
|
type: "page_view",
|
|
168
171
|
t: Date.now(),
|
|
169
172
|
url: t,
|
|
170
|
-
locale: e.locale ??
|
|
171
|
-
ref: e.ref ??
|
|
173
|
+
locale: e.locale ?? d,
|
|
174
|
+
ref: e.ref ?? C(),
|
|
172
175
|
vw: e.vw ?? (typeof window < "u" ? window.innerWidth : void 0),
|
|
173
176
|
vh: e.vh ?? (typeof window < "u" ? window.innerHeight : void 0),
|
|
174
177
|
reason: n
|
|
175
178
|
}));
|
|
176
179
|
}, O = (e) => {
|
|
177
|
-
if (!
|
|
178
|
-
let t = e.locale ??
|
|
180
|
+
if (!i) return;
|
|
181
|
+
let t = e.locale ?? d, n = [
|
|
179
182
|
e.dictionaryKey,
|
|
180
183
|
e.keyPath,
|
|
181
184
|
t,
|
|
182
185
|
e.experimentKey ?? "",
|
|
183
186
|
e.variant ?? ""
|
|
184
187
|
].join("");
|
|
185
|
-
|
|
188
|
+
y.has(n) || (y.add(n), T({
|
|
186
189
|
...e,
|
|
187
190
|
type: "content_exposure",
|
|
188
191
|
t: Date.now(),
|
|
189
|
-
url:
|
|
192
|
+
url: S(),
|
|
190
193
|
locale: t
|
|
191
194
|
}));
|
|
192
195
|
}, k = (e) => {
|
|
@@ -194,10 +197,10 @@ var r = (e) => {
|
|
|
194
197
|
...e,
|
|
195
198
|
type: "conversion",
|
|
196
199
|
t: Date.now(),
|
|
197
|
-
url:
|
|
198
|
-
locale: e.locale ??
|
|
200
|
+
url: S(),
|
|
201
|
+
locale: e.locale ?? d
|
|
199
202
|
}), w());
|
|
200
|
-
}, A = (e, t, r) =>
|
|
203
|
+
}, A = (e, t, r) => o(n, e, t, r), j = () => {
|
|
201
204
|
if (typeof window > "u") return;
|
|
202
205
|
let e = () => {
|
|
203
206
|
document.visibilityState === "hidden" && w(!0);
|
|
@@ -219,43 +222,35 @@ var r = (e) => {
|
|
|
219
222
|
getVariant: A,
|
|
220
223
|
flush: w,
|
|
221
224
|
start: () => {
|
|
222
|
-
g || r || (g = !0,
|
|
225
|
+
g || r || (g = !0, c.prime(), f = setInterval(w, t.flushInterval), f?.unref?.(), h(j));
|
|
223
226
|
},
|
|
224
227
|
stop: () => {
|
|
225
|
-
g && (g = !1,
|
|
228
|
+
g && (g = !1, f &&= (clearInterval(f), null), _?.(), _ = null, w(!0));
|
|
226
229
|
}
|
|
227
230
|
};
|
|
228
|
-
},
|
|
229
|
-
typeof window < "u" && (window[
|
|
230
|
-
},
|
|
231
|
+
}, T = "__intlayer_analytics_client__", E = "__intlayer_analytics_ref_count__", D = () => typeof window > "u" ? null : window[T] ?? null, O = (e) => {
|
|
232
|
+
typeof window < "u" && (window[T] = e);
|
|
233
|
+
}, k = () => {
|
|
231
234
|
if (typeof window > "u") return 0;
|
|
232
235
|
let e = window;
|
|
233
|
-
return e[
|
|
234
|
-
},
|
|
236
|
+
return e[E] = (e[E] ?? 0) + 1, e[E];
|
|
237
|
+
}, A = () => {
|
|
235
238
|
if (typeof window > "u") return 0;
|
|
236
239
|
let e = window;
|
|
237
|
-
return e[
|
|
238
|
-
},
|
|
239
|
-
|
|
240
|
-
let e =
|
|
240
|
+
return e[E] = Math.max(0, (e[E] ?? 0) - 1), e[E];
|
|
241
|
+
}, j = () => {
|
|
242
|
+
k();
|
|
243
|
+
let e = D();
|
|
241
244
|
if (e) return e;
|
|
242
|
-
let r =
|
|
245
|
+
let r = w({
|
|
243
246
|
backendURL: n?.backendURL ?? "",
|
|
244
247
|
clientId: n?.clientId,
|
|
245
248
|
flushInterval: t?.flushInterval ?? 2e4,
|
|
246
249
|
maxBufferSize: 500,
|
|
247
250
|
sampleRate: t?.sampleRate ?? 1
|
|
248
251
|
});
|
|
249
|
-
return
|
|
250
|
-
},
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
keyPath: j(e.keyPath),
|
|
255
|
-
locale: e.locale,
|
|
256
|
-
nodeType: e.nodeType,
|
|
257
|
-
experimentKey: e.experimentKey,
|
|
258
|
-
variant: e.variant
|
|
259
|
-
});
|
|
260
|
-
//#endregion
|
|
261
|
-
export { M as buildContentExposure, T as getGlobalAnalyticsClient, k as initAnalyticsClient, A as stopAnalyticsClient };
|
|
252
|
+
return O(r), r.start(), r;
|
|
253
|
+
}, M = () => {
|
|
254
|
+
A() > 0 || (D()?.stop(), O(null));
|
|
255
|
+
};
|
|
256
|
+
export { i as buildContentExposure, D as getGlobalAnalyticsClient, j as initAnalyticsClient, M as stopAnalyticsClient };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { analytics as e, editor as t } from "@intlayer/config/built";
|
|
2
|
-
|
|
2
|
+
// ../@intlayer/analytics/dist/esm/utils/isBot.mjs
|
|
3
3
|
var n = /cubot/i, r = /bot\b|bot[/\-\s]|crawler|crawling|spider|scraper|slurp|archiver|feedfetcher|validator|curl\/|wget\/|python-requests|python-urllib|okhttp|axios\/|node-fetch|got \(|go-http-client|java\/|libwww|httpunit|http_request|apache-httpclient|headless|phantomjs|puppeteer|playwright|selenium|webdriver|cypress|lighthouse|pagespeed|gtmetrix|prerender|pingdom|uptime|statuscake|site24x7|bingpreview|yandex|baiduspider|sogou|exabot|semrush|ahrefs|mj12|dotbot|petalbot|applebot|amazonbot|bytespider|facebookexternalhit|meta-externalagent|embedly|outbrain|quora link preview|skypeuripreview|vkshare|w3c_validator|apis-google|mediapartners|adsbot|storebot-google|google-inspectiontool|google-read-aloud|google-extended|duplexweb-google|gptbot|oai-searchbot|chatgpt-user|perplexity|claudebot|claude-web|anthropic-ai|cohere-ai|ccbot|diffbot|imagesift|omgili|timpi|youbot/i, i = (e) => !e || !n.test(e) && r.test(e), a = [
|
|
4
4
|
"_phantom",
|
|
5
5
|
"__nightmare",
|
|
@@ -15,5 +15,4 @@ var n = /cubot/i, r = /bot\b|bot[/\-\s]|crawler|crawling|spider|scraper|slurp|ar
|
|
|
15
15
|
let e = globalThis;
|
|
16
16
|
return a.some((t) => t in e) ? !0 : navigator.userAgent ? i(navigator.userAgent) : !1;
|
|
17
17
|
}, s = process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && e?.enabled === !0 && !!t?.clientId && typeof window < "u" && window.self === window.top && !o();
|
|
18
|
-
//#endregion
|
|
19
18
|
export { i, r as n, o as r, s as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Dictionary } from '@intlayer/types/dictionary';
|
|
2
|
+
import { KeyPath } from '@intlayer/types/keyPath';
|
|
3
|
+
/**
|
|
4
|
+
* Edit coming from the devtools inspector: the label of the edited row, plus
|
|
5
|
+
* the locale when a single locale of a translation row was edited.
|
|
6
|
+
*/
|
|
7
|
+
export type InspectorEdit = {
|
|
8
|
+
label: string;
|
|
9
|
+
locale?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Editability of an inspector row: a translation node editable per locale,
|
|
13
|
+
* or a plain string leaf editable as a whole.
|
|
14
|
+
*/
|
|
15
|
+
export type Editability = 'translation' | 'plain-string';
|
|
16
|
+
/**
|
|
17
|
+
* Tell whether the node at `keyPath` can be edited from the devtools
|
|
18
|
+
* inspector: plain string leaves are editable as a whole, and translation
|
|
19
|
+
* nodes are editable per locale when every locale holds a plain string.
|
|
20
|
+
* Rich nodes (markdown, html, insertion…), numbers and nested structures stay
|
|
21
|
+
* read-only.
|
|
22
|
+
*/
|
|
23
|
+
export declare const getEditability: (dictionary: Dictionary, keyPath: KeyPath[]) => Editability | null;
|
|
24
|
+
/**
|
|
25
|
+
* Parse the `path` array of an `editInspectorState` payload.
|
|
26
|
+
*
|
|
27
|
+
* The devtools frontend builds the path from the edited state entry: the row
|
|
28
|
+
* label is always a single segment (even when it contains dots), optionally
|
|
29
|
+
* followed by the locale key. The leading section name is stripped
|
|
30
|
+
* defensively — some devtools frontends include it.
|
|
31
|
+
*
|
|
32
|
+
* Returns `null` for paths that do not address a single value.
|
|
33
|
+
*/
|
|
34
|
+
export declare const parseEditPath: (path: string[], sectionName?: string) => InspectorEdit | null;
|
|
35
|
+
/**
|
|
36
|
+
* Resolve an inspector edit to the `KeyPath` of the edited string: the row
|
|
37
|
+
* key path, extended with the locale for a translation edit. Returns `null`
|
|
38
|
+
* when no row of `dictionary` carries the edited label.
|
|
39
|
+
*/
|
|
40
|
+
export declare const getEditKeyPath: (dictionary: Dictionary, edit: InspectorEdit) => KeyPath[] | null;
|
|
41
|
+
/**
|
|
42
|
+
* Replace the string at `keyPath` and return the updated declaration, ready
|
|
43
|
+
* to be sent back to the editor server. The input dictionary is never
|
|
44
|
+
* mutated. Returns `null` when `keyPath` does not address an existing string
|
|
45
|
+
* (missing locale, rich node, number…), so an edit never creates a node.
|
|
46
|
+
*/
|
|
47
|
+
export declare const applyDictionaryEdit: (dictionary: Dictionary, keyPath: KeyPath[], newValue: string) => Dictionary | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Dictionary } from '@intlayer/types/dictionary';
|
|
2
|
+
/**
|
|
3
|
+
* Unmerged dictionaries as returned by the editor server: one array of
|
|
4
|
+
* declarations per dictionary key. Declared locally — rather than importing
|
|
5
|
+
* `GetEditorDictionariesResult` from `intlayer-editor` — to keep the
|
|
6
|
+
* published types of vue-intlayer free of a dependency on the editor package.
|
|
7
|
+
*/
|
|
8
|
+
export type UnmergedDictionaries = Record<string, Dictionary[]>;
|
|
9
|
+
export type EditorServerSession = {
|
|
10
|
+
/** Whether the last fetch reached the editor server. */
|
|
11
|
+
isOnline: () => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Fetch the unmerged dictionaries from the editor server, or `null` when
|
|
14
|
+
* the server is unreachable (`npx intlayer editor start` not running).
|
|
15
|
+
*/
|
|
16
|
+
fetchUnmergedDictionaries: () => Promise<UnmergedDictionaries | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Write a full declaration back to its source file through the editor
|
|
19
|
+
* server (`POST /api/dictionary`). The declaration must carry the `localId`
|
|
20
|
+
* (and `filePath`) it was fetched with, so the server can locate the source
|
|
21
|
+
* file. The server rebuilds the unmerged dictionaries before answering, so
|
|
22
|
+
* a fetch after the returned promise resolves reflects the write.
|
|
23
|
+
*/
|
|
24
|
+
writeDictionary: (dictionary: Dictionary) => Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
export declare const createEditorServerSession: () => EditorServerSession;
|
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
import { Dictionary } from '@intlayer/types/dictionary';
|
|
2
|
+
import { KeyPath } from '@intlayer/types/keyPath';
|
|
2
3
|
/**
|
|
3
4
|
* Flattened representation of a dictionary content for the devtools
|
|
4
5
|
* inspector: each leaf path maps to its per-locale translations, or to a
|
|
5
6
|
* stringified fallback for non-translation content.
|
|
6
7
|
*/
|
|
7
8
|
export type FlattenedDictionary = Record<string, Record<string, string> | string>;
|
|
9
|
+
/**
|
|
10
|
+
* One inspector row: the displayed label, the `KeyPath` addressing the node
|
|
11
|
+
* in the dictionary content, and the displayed value.
|
|
12
|
+
*/
|
|
13
|
+
export type InspectorEntry = {
|
|
14
|
+
label: string;
|
|
15
|
+
keyPath: KeyPath[];
|
|
16
|
+
value: Record<string, string> | string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Label used for a typed node sitting at the root of the dictionary content.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ROOT_PATH = "(root)";
|
|
22
|
+
/**
|
|
23
|
+
* Recursively list the inspector rows of a dictionary content, each one
|
|
24
|
+
* carrying the `KeyPath` of its node so edits can target it with the core
|
|
25
|
+
* `dictionaryManipulator` helpers.
|
|
26
|
+
*/
|
|
27
|
+
export declare const listInspectorEntries: (dictionary: Dictionary) => InspectorEntry[];
|
|
8
28
|
/**
|
|
9
29
|
* Recursively flatten a dictionary content into leaf-path entries.
|
|
10
30
|
* Translation nodes are exposed as their locale-to-string map; any other
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
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
|
+
export declare const EDITOR_OFFLINE_NODE_ID = "intlayer-editor-offline";
|
|
4
5
|
/**
|
|
5
6
|
* Register the Intlayer plugin in Vue Devtools with an inspector listing
|
|
6
7
|
* the loaded dictionaries and their translations, plus a "Locales" group
|
|
7
8
|
* node allowing to switch the current locale of the app.
|
|
8
9
|
*
|
|
10
|
+
* When the Intlayer editor server is running (`npx intlayer editor start`),
|
|
11
|
+
* the inspector lists the unmerged dictionary declarations fetched from it
|
|
12
|
+
* and plain-text values become editable: edits are written back to the source
|
|
13
|
+
* content files through the editor server. Without the server, the inspector
|
|
14
|
+
* falls back to a read-only view of the loaded (merged) dictionaries.
|
|
15
|
+
*
|
|
9
16
|
* Lazy-loaded by `installIntlayer`; safe to call only in a browser
|
|
10
17
|
* environment where the devtools hook may exist — `setupDevtoolsPlugin`
|
|
11
18
|
* no-ops when Vue Devtools is not installed.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-intlayer",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.7.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Vue applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -103,16 +103,16 @@
|
|
|
103
103
|
"typecheck": "vue-tsc --noEmit --project tsconfig.types.json"
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
|
-
"@intlayer/api": "9.
|
|
107
|
-
"@intlayer/config": "9.
|
|
108
|
-
"@intlayer/core": "9.
|
|
109
|
-
"@intlayer/dictionaries-entry": "9.
|
|
110
|
-
"@intlayer/editor": "9.
|
|
111
|
-
"@intlayer/types": "9.
|
|
106
|
+
"@intlayer/api": "9.7.1",
|
|
107
|
+
"@intlayer/config": "9.7.1",
|
|
108
|
+
"@intlayer/core": "9.7.1",
|
|
109
|
+
"@intlayer/dictionaries-entry": "9.7.1",
|
|
110
|
+
"@intlayer/editor": "9.7.1",
|
|
111
|
+
"@intlayer/types": "9.7.1",
|
|
112
112
|
"@vue/devtools-api": "^6.6.4"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
|
-
"@types/node": "^
|
|
115
|
+
"@types/node": "^26",
|
|
116
116
|
"@utils/ts-config": "1.0.4",
|
|
117
117
|
"@utils/ts-config-types": "1.0.4",
|
|
118
118
|
"@utils/tsdown-config": "1.0.4",
|
|
@@ -120,15 +120,15 @@
|
|
|
120
120
|
"ajv": "8.20.0",
|
|
121
121
|
"fast-glob": "3.3.3",
|
|
122
122
|
"rimraf": "6.1.3",
|
|
123
|
-
"tsdown": "0.23.
|
|
123
|
+
"tsdown": "0.23.4",
|
|
124
124
|
"typescript": "7.0.2",
|
|
125
|
-
"vite": "8.3.
|
|
126
|
-
"vite-plugin-dts": "5.1.
|
|
127
|
-
"vitest": "5.0
|
|
125
|
+
"vite": "8.3.5",
|
|
126
|
+
"vite-plugin-dts": "5.1.2",
|
|
127
|
+
"vitest": "5.1.0",
|
|
128
128
|
"vue-tsc": "3.3.9"
|
|
129
129
|
},
|
|
130
130
|
"peerDependencies": {
|
|
131
|
-
"intlayer": "9.
|
|
131
|
+
"intlayer": "9.7.1",
|
|
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.
|
|
140
|
+
"@intlayer/analytics": "9.7.1"
|
|
141
141
|
},
|
|
142
142
|
"engines": {
|
|
143
143
|
"node": ">=14.18"
|
package/dist/esm-CXlI80Tk.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./isEnabled-CuTKz0YA.js");let t=require("@intlayer/config/built");var n=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0},r=(e,t,r,i)=>{if(r.length===0)throw Error(`assignVariant requires at least one variant`);if(r.length===1)return r[0];let a=n(`${e}:${t}`)/4294967296;if(!i||i.length!==r.length){let e=Math.floor(a*r.length);return r[Math.min(e,r.length-1)]}let o=i.reduce((e,t)=>e+t,0);if(o<=0)return r[Math.floor(a*r.length)];let s=0,c=a*o;for(let e=0;e<r.length;e++)if(s+=i[e],c<s)return r[e];return r[r.length-1]},i=``,a=e=>[e.url,e.dictionaryKey,e.keyPath,e.locale,e.experimentKey??``,e.variant??``].join(i),o=({max:e})=>{let t=[],n=new Map,r=()=>t.length+n.size,i=()=>{for(;r()>e&&n.size>0;){let e=n.keys().next().value;n.delete(e)}r()>e&&(t=t.slice(r()-e))};return{push:e=>{if(e.type===`content_exposure`){let t=a(e),r=n.get(t);r?(r.count=(r.count??1)+(e.count??1),r.t=e.t):n.set(t,{...e,count:e.count??1})}else t.push(e);return i(),r()},drain:()=>{let e=[...t,...n.values()];return t=[],n.clear(),e},size:r}},s=(e,t)=>t>=1?!0:t<=0?!1:n(e)/4294967295<t,c=`__intlayer_analytics_sid__`,l=()=>{let e=typeof globalThis<`u`?globalThis.crypto:void 0;return e?.randomUUID?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`},u=()=>{if(typeof window>`u`||!window.sessionStorage)return l();try{let e=window.sessionStorage.getItem(c);if(e)return e;let t=l();return window.sessionStorage.setItem(c,t),t}catch{return l()}},d=(e,t,{useBeacon:n=!1,token:r}={})=>{try{let i=JSON.stringify(t);return n&&typeof navigator<`u`&&typeof navigator.sendBeacon==`function`?navigator.sendBeacon(e,i):typeof fetch==`function`&&(fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`,...r?{Authorization:`Bearer ${r}`}:{}},body:i,keepalive:!0,credentials:`omit`,mode:`cors`}).catch(()=>{}),!0)}catch{return!1}},f=e=>{if(typeof window>`u`)return;let t=window.requestIdleCallback;if(typeof t==`function`){t(()=>e());return}setTimeout(e,1)},p=`__intlayer_public_token__`,m=6e4,h=()=>{try{let e=window.sessionStorage?.getItem(p);if(!e)return null;let t=JSON.parse(e);return typeof t?.token!=`string`||typeof t?.expiresAt!=`number`?null:t}catch{return null}},g=e=>{try{window.sessionStorage?.setItem(p,JSON.stringify(e))}catch{}},_=({backendURL:e,clientId:t})=>{let n=`${e.replace(/\/$/,``)}/api/public/token`,r=null,i=null,a=e=>e!==null&&e.expiresAt-m>Date.now(),o=()=>{if(a(r))return r.token;if(typeof window<`u`){let e=h();if(a(e))return r=e,e.token}},s=async()=>{try{let e=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientId:t}),credentials:`omit`,mode:`cors`});if(!e.ok)return;let i=await e.json(),a=i?.data?.token,o=i?.data?.expiresIn??0;if(!a||o<=0)return;r={token:a,expiresAt:Date.now()+o*1e3},typeof window<`u`&&g(r)}catch{}finally{i=null}};return{getToken:o,prime:()=>{t&&typeof fetch==`function`&&(o()||(i||=s()))}}},v=`intlayer-analytics/1`,y=()=>typeof window>`u`||!window.location?``:window.location.pathname,b=()=>{if(typeof document<`u`&&document.referrer)try{return new URL(document.referrer).host}catch{return}},x=t=>{let n=u(),i=e.r(),a=!i&&s(n,t.sampleRate),c=o({max:t.maxBufferSize}),l=`${t.backendURL.replace(/\/$/,``)}/api/analytics/events`,p=_({backendURL:t.backendURL,clientId:t.clientId}),m=``,h=null,g=!1,x=null,S=null,C=new Set,w=(e=!1)=>{let r=c.drain(),i=p.getToken();for(let a=0;a<r.length;a+=200)d(l,{token:i,clientId:i?void 0:t.clientId,sessionId:n,sdkVersion:v,events:r.slice(a,a+200)},{useBeacon:e,token:i})},T=e=>{c.push(e)>=t.maxBufferSize&&w()},E=e=>{m=e},D=(e={})=>{if(!a)return;let t=e.url??y(),n=e.reason??`initial`;(n!==`route_change`||t!==S)&&(S=t,C=new Set,T({type:`page_view`,t:Date.now(),url:t,locale:e.locale??m,ref:e.ref??b(),vw:e.vw??(typeof window<`u`?window.innerWidth:void 0),vh:e.vh??(typeof window<`u`?window.innerHeight:void 0),reason:n}))},O=e=>{if(!a)return;let t=e.locale??m,n=[e.dictionaryKey,e.keyPath,t,e.experimentKey??``,e.variant??``].join(``);C.has(n)||(C.add(n),T({...e,type:`content_exposure`,t:Date.now(),url:y(),locale:t}))},k=e=>{i||(T({...e,type:`conversion`,t:Date.now(),url:y(),locale:e.locale??m}),w())},A=(e,t,i)=>r(n,e,t,i),j=()=>{if(typeof window>`u`)return;let e=()=>{document.visibilityState===`hidden`&&w(!0)},t=()=>w(!0),n=()=>D({reason:`route_change`});document.addEventListener(`visibilitychange`,e),window.addEventListener(`pagehide`,t,{capture:!0}),window.addEventListener(`popstate`,n);let r=window.history,i=r.pushState,a=function(...e){let t=i.apply(this,e);return D({reason:`route_change`}),t};r.pushState=a,x=()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`pagehide`,t,{capture:!0}),window.removeEventListener(`popstate`,n),r.pushState===a&&(r.pushState=i)}};return{setLocale:E,trackPageView:D,trackContentExposure:O,trackConversion:k,getVariant:A,flush:w,start:()=>{g||i||(g=!0,p.prime(),h=setInterval(w,t.flushInterval),h?.unref?.(),f(j))},stop:()=>{g&&(g=!1,h&&=(clearInterval(h),null),x?.(),x=null,w(!0))}}},S=`__intlayer_analytics_client__`,C=`__intlayer_analytics_ref_count__`,w=()=>typeof window>`u`?null:window[S]??null,T=e=>{typeof window<`u`&&(window[S]=e)},E=()=>{if(typeof window>`u`)return 0;let e=window;return e[C]=(e[C]??0)+1,e[C]},D=()=>{if(typeof window>`u`)return 0;let e=window;return e[C]=Math.max(0,(e[C]??0)-1),e[C]},O=()=>{E();let e=w();if(e)return e;let n=x({backendURL:t.editor?.backendURL??``,clientId:t.editor?.clientId,flushInterval:t.analytics?.flushInterval??2e4,maxBufferSize:500,sampleRate:t.analytics?.sampleRate??1});return T(n),n.start(),n},k=()=>{D()>0||(w()?.stop(),T(null))},A=e=>e.map(e=>e.key===void 0?`*`:String(e.key)).join(`.`),j=e=>({dictionaryKey:e.dictionaryKey,keyPath:A(e.keyPath),locale:e.locale,nodeType:e.nodeType,experimentKey:e.experimentKey,variant:e.variant});exports.buildContentExposure=j,exports.getGlobalAnalyticsClient=w,exports.initAnalyticsClient=O,exports.stopAnalyticsClient=k;
|