@vmz/vmz 0.1.16 → 0.1.18
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/application-cmd.d.ts +6 -16
- package/dist/application-cmd.js +34 -180
- package/dist/author-input.d.ts +40 -19
- package/dist/author-input.js +2 -16
- package/dist/build-assemble.d.ts +63 -41
- package/dist/build-assemble.js +42 -43
- package/dist/bundler-adapter.d.ts +46 -48
- package/dist/bundler-adapter.js +4 -43
- package/dist/cdn-policy.d.ts +77 -93
- package/dist/cdn-policy.js +10 -16
- package/dist/cli-localize.d.ts +34 -0
- package/dist/cli-localize.js +58 -0
- package/dist/cli.d.ts +8 -19
- package/dist/cli.js +69 -252
- package/dist/content-addressed-assets.d.ts +24 -10
- package/dist/content-addressed-assets.js +2 -7
- package/dist/delivery-profile.d.ts +54 -27
- package/dist/delivery-profile.js +15 -13
- package/dist/dev-session.d.ts +29 -23
- package/dist/dev-session.js +0 -21
- package/dist/dev-watch-roots.d.ts +34 -25
- package/dist/dev-watch-roots.js +0 -31
- package/dist/document-build.d.ts +22 -97
- package/dist/document-build.js +4 -19
- package/dist/document-check.d.ts +30 -53
- package/dist/document-check.js +14 -29
- package/dist/document-cmd.d.ts +3 -6
- package/dist/document-cmd.js +19 -79
- package/dist/document-designs.d.ts +5 -8
- package/dist/document-designs.js +2 -15
- package/dist/document-enrich.d.ts +52 -24
- package/dist/document-enrich.js +4 -32
- package/dist/document-evidence.d.ts +46 -43
- package/dist/document-evidence.js +6 -47
- package/dist/document-integrate.d.ts +13 -29
- package/dist/document-integrate.js +2 -13
- package/dist/document-interactive.d.ts +45 -67
- package/dist/document-interactive.js +9 -50
- package/dist/document-layout-render.d.ts +7 -16
- package/dist/document-layout-render.js +0 -17
- package/dist/document-locale.d.ts +12 -25
- package/dist/document-locale.js +3 -14
- package/dist/document-markdown.d.ts +9 -5
- package/dist/document-markdown.js +0 -4
- package/dist/document-routing-config.d.ts +7 -14
- package/dist/document-routing-config.js +0 -9
- package/dist/document-scan.d.ts +14 -18
- package/dist/document-scan.js +2 -23
- package/dist/document-schema.d.ts +154 -41
- package/dist/document-schema.js +0 -35
- package/dist/embedded-packaging.d.ts +20 -8
- package/dist/embedded-packaging.js +0 -1
- package/dist/explain-cmd.d.ts +4 -3
- package/dist/explain-cmd.js +16 -65
- package/dist/index.d.ts +70 -143
- package/dist/index.js +16 -136
- package/dist/invocation.d.ts +29 -50
- package/dist/invocation.js +11 -57
- package/dist/locale-check.d.ts +69 -70
- package/dist/locale-check.js +5 -66
- package/dist/locale-cmd.d.ts +2 -5
- package/dist/locale-cmd.js +62 -142
- package/dist/locale-delivery.d.ts +294 -191
- package/dist/locale-delivery.js +8 -94
- package/dist/locale-route-emit.d.ts +23 -9
- package/dist/locale-route-emit.js +0 -7
- package/dist/locale-router.d.ts +189 -162
- package/dist/locale-router.js +13 -122
- package/dist/locale-runtime.d.ts +292 -262
- package/dist/locale-runtime.js +8 -102
- package/dist/locale-schema.js +0 -1
- package/dist/locale-tooling.d.ts +100 -63
- package/dist/locale-tooling.js +7 -45
- package/dist/log.d.ts +22 -15
- package/dist/log.js +24 -21
- package/dist/native-addon.d.ts +10 -9
- package/dist/native-addon.js +1 -10
- package/dist/pack-client-packages.d.ts +5 -1
- package/dist/pack-client-packages.js +0 -6
- package/dist/pack.d.ts +17 -15
- package/dist/pack.js +0 -12
- package/dist/packages.d.ts +10 -23
- package/dist/packages.js +1 -37
- package/dist/plan-cmd.d.ts +6 -0
- package/dist/plan-cmd.js +35 -0
- package/dist/plugin-host.js +0 -1
- package/dist/port.d.ts +2 -10
- package/dist/port.js +2 -11
- package/dist/pretty-json.d.ts +9 -19
- package/dist/pretty-json.js +3 -17
- package/dist/production-observability.d.ts +37 -181
- package/dist/production-observability.js +1 -9
- package/dist/production-test-pack.d.ts +17 -3
- package/dist/production-test-pack.js +0 -2
- package/dist/public-static-assets.d.ts +6 -1
- package/dist/public-static-assets.js +0 -5
- package/dist/refactor-cmd.d.ts +3 -6
- package/dist/refactor-cmd.js +16 -69
- package/dist/release-cmd.d.ts +7 -6
- package/dist/release-cmd.js +17 -59
- package/dist/release-pack.d.ts +7 -3
- package/dist/release-pack.js +0 -6
- package/dist/resolve.d.ts +15 -19
- package/dist/resolve.js +1 -15
- package/dist/server-artifact.d.ts +30 -75
- package/dist/server-artifact.js +0 -10
- package/dist/server-language-backend.d.ts +22 -79
- package/dist/server-language-backend.js +0 -26
- package/dist/site-delivery.d.ts +46 -59
- package/dist/site-delivery.js +3 -8
- package/dist/site-favicon.d.ts +6 -1
- package/dist/site-favicon.js +0 -5
- package/dist/static-emit.d.ts +73 -103
- package/dist/static-emit.js +1 -26
- package/dist/test-cmd.d.ts +3 -5
- package/dist/test-cmd.js +15 -25
- package/dist/test-compile.js +0 -1
- package/dist/test-discover.js +0 -1
- package/dist/test-logic.js +0 -1
- package/dist/test-protocol.js +0 -1
- package/dist/toolchain-dx.d.ts +11 -0
- package/dist/toolchain-dx.js +10 -0
- package/dist/watch-diff.d.ts +4 -13
- package/dist/watch-diff.js +0 -17
- package/dist/wechat-packaging.d.ts +8 -7
- package/dist/wechat-packaging.js +0 -6
- package/locales/en-US/cli.json +105 -0
- package/locales/locales.json +4 -0
- package/package.json +15 -12
- package/dist/resolve-native-cli.d.ts +0 -14
- package/dist/resolve-native-cli.js +0 -84
package/dist/locale-delivery.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* Locale multi-host delivery: Web chunks · Mini packages · Native packs ·
|
|
4
3
|
* Server error envelope / formatter resources.
|
|
@@ -7,15 +6,9 @@
|
|
|
7
6
|
*/
|
|
8
7
|
import { createHash } from 'node:crypto';
|
|
9
8
|
import { DIAG_LOCALE_CHUNK_HASH_MISMATCH, DIAG_LOCALE_DELIVERY_FULL_BUNDLE, DIAG_LOCALE_HOST_MESSAGE_DIVERGENCE, DIAG_LOCALE_MINI_CROSS_PACKAGE_UNPROVEN, DIAG_LOCALE_NATIVE_PACK_APP_MISMATCH, DIAG_LOCALE_NATIVE_PACK_HAS_JS, DIAG_LOCALE_NATIVE_PACK_UNSIGNED, DIAG_LOCALE_SERVER_FORMAT_WITHOUT_CONTEXT, DIAG_LOCALE_SERVER_TRANSLATED_ERROR, FORMATTER_DATA_VERSION, LOCALE_CHUNK_MANIFEST_SCHEMA, LOCALE_DELIVERY_CHECK_SCHEMA, LOCALE_DELIVERY_RESOLUTION_SCHEMA, LOCALE_MINI_PACKAGE_PROOF_SCHEMA, LOCALE_NATIVE_PACK_SCHEMA, LOCALE_SERVER_ERROR_ENVELOPE_SCHEMA, } from './locale-schema.js';
|
|
10
|
-
/**
|
|
11
|
-
* @param {unknown} value
|
|
12
|
-
*/
|
|
13
9
|
function stableHash(value) {
|
|
14
10
|
return createHash('sha256').update(JSON.stringify(value)).digest('hex').slice(0, 32);
|
|
15
11
|
}
|
|
16
|
-
/**
|
|
17
|
-
* @param {Record<string, string[]>} [fallback]
|
|
18
|
-
*/
|
|
19
12
|
export function fallbackDigest(fallback = {}) {
|
|
20
13
|
const keys = Object.keys(fallback).sort();
|
|
21
14
|
const normalized = {};
|
|
@@ -23,15 +16,9 @@ export function fallbackDigest(fallback = {}) {
|
|
|
23
16
|
normalized[k] = [...(fallback[k] || [])];
|
|
24
17
|
return stableHash(normalized);
|
|
25
18
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Hash reachable message variants for one locale.
|
|
28
|
-
* @param {Array<{ messageId: string, variants: Record<string, { template: string }> }>} messages
|
|
29
|
-
* @param {string} localeId
|
|
30
|
-
* @param {string[]} [reachableIds]
|
|
31
|
-
*/
|
|
19
|
+
/** Hash reachable message variants for one locale. */
|
|
32
20
|
export function messageCatalogHash(messages, localeId, reachableIds) {
|
|
33
21
|
const allow = reachableIds ? new Set(reachableIds) : null;
|
|
34
|
-
/** @type {Record<string, string>} */
|
|
35
22
|
const slice = {};
|
|
36
23
|
for (const m of messages || []) {
|
|
37
24
|
if (allow && !allow.has(m.messageId))
|
|
@@ -45,25 +32,8 @@ export function messageCatalogHash(messages, localeId, reachableIds) {
|
|
|
45
32
|
.map((k) => [k, slice[k]]);
|
|
46
33
|
return stableHash(ordered);
|
|
47
34
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Build LocaleDeliveryResolution for one Host surface.
|
|
50
|
-
* @param {{
|
|
51
|
-
* host: 'web'|'mini'|'native'|'server',
|
|
52
|
-
* applicationId: string,
|
|
53
|
-
* deliveryId: string,
|
|
54
|
-
* planVersion?: string,
|
|
55
|
-
* supportedLocales: string[],
|
|
56
|
-
* defaultLocale: string,
|
|
57
|
-
* fallback?: Record<string, string[]>,
|
|
58
|
-
* routingRealization?: unknown,
|
|
59
|
-
* messages: Array<{ messageId: string, variants: Record<string, { template: string }> }>,
|
|
60
|
-
* reachableMessageIds?: string[],
|
|
61
|
-
* bundledLocales?: string[],
|
|
62
|
-
* allowFullClientBundle?: boolean,
|
|
63
|
-
* }} input
|
|
64
|
-
*/
|
|
35
|
+
/** Build LocaleDeliveryResolution for one Host surface. */
|
|
65
36
|
export function buildLocaleDeliveryResolution(input) {
|
|
66
|
-
/** @type {any[]} */
|
|
67
37
|
const diagnostics = [];
|
|
68
38
|
const supported = [...(input.supportedLocales || [])];
|
|
69
39
|
const defaultLocale = input.defaultLocale;
|
|
@@ -80,12 +50,10 @@ export function buildLocaleDeliveryResolution(input) {
|
|
|
80
50
|
message: `${input.host} delivery must not bundle all ${supported.length} locales by default`,
|
|
81
51
|
});
|
|
82
52
|
}
|
|
83
|
-
/** @type {Record<string, string>} */
|
|
84
53
|
const messageCatalogHashes = {};
|
|
85
54
|
for (const loc of supported) {
|
|
86
55
|
messageCatalogHashes[loc] = messageCatalogHash(input.messages, loc, reachable);
|
|
87
56
|
}
|
|
88
|
-
/** @type {any[]} */
|
|
89
57
|
const lazyLocaleChunks = [];
|
|
90
58
|
for (const loc of supported) {
|
|
91
59
|
if (bundled.includes(loc))
|
|
@@ -127,26 +95,8 @@ export function buildLocaleDeliveryResolution(input) {
|
|
|
127
95
|
diagnostics,
|
|
128
96
|
};
|
|
129
97
|
}
|
|
130
|
-
/**
|
|
131
|
-
* Validate a Native optional locale pack (signed, no JS, bound to app/plan/schema).
|
|
132
|
-
* @param {{
|
|
133
|
-
* pack: {
|
|
134
|
-
* schema?: string,
|
|
135
|
-
* applicationId: string,
|
|
136
|
-
* planVersion: string,
|
|
137
|
-
* localeId: string,
|
|
138
|
-
* signature?: string,
|
|
139
|
-
* catalog?: Record<string, string>,
|
|
140
|
-
* formatterDataVersion?: string,
|
|
141
|
-
* entries?: Array<{ path: string, kind?: string }>,
|
|
142
|
-
* executable?: boolean,
|
|
143
|
-
* },
|
|
144
|
-
* expectedApplicationId: string,
|
|
145
|
-
* expectedPlanVersion: string,
|
|
146
|
-
* }} input
|
|
147
|
-
*/
|
|
98
|
+
/** Validate a Native optional locale pack (signed, no JS, bound to app/plan/schema). */
|
|
148
99
|
export function validateNativeLocalePack(input) {
|
|
149
|
-
/** @type {any[]} */
|
|
150
100
|
const diagnostics = [];
|
|
151
101
|
const pack = input.pack || {};
|
|
152
102
|
if (!pack.signature) {
|
|
@@ -211,22 +161,13 @@ export function validateNativeLocalePack(input) {
|
|
|
211
161
|
},
|
|
212
162
|
};
|
|
213
163
|
}
|
|
214
|
-
/**
|
|
215
|
-
* Mini cross-subpackage message dependencies must be proven.
|
|
216
|
-
* @param {{
|
|
217
|
-
* packages: Array<{ id: string, messageIds: string[] }>,
|
|
218
|
-
* edges: Array<{ fromPackage: string, toPackage: string, messageId: string }>,
|
|
219
|
-
* }} input
|
|
220
|
-
*/
|
|
164
|
+
/** Mini cross-subpackage message dependencies must be proven. */
|
|
221
165
|
export function proveMiniPackageMessages(input) {
|
|
222
|
-
/** @type {any[]} */
|
|
223
166
|
const diagnostics = [];
|
|
224
|
-
/** @type {Map<string, Set<string>>} */
|
|
225
167
|
const owned = new Map();
|
|
226
168
|
for (const p of input.packages || []) {
|
|
227
169
|
owned.set(p.id, new Set(p.messageIds || []));
|
|
228
170
|
}
|
|
229
|
-
/** @type {any[]} */
|
|
230
171
|
const proven = [];
|
|
231
172
|
for (const edge of input.edges || []) {
|
|
232
173
|
const target = owned.get(edge.toPackage);
|
|
@@ -251,12 +192,8 @@ export function proveMiniPackageMessages(input) {
|
|
|
251
192
|
diagnostics,
|
|
252
193
|
};
|
|
253
194
|
}
|
|
254
|
-
/**
|
|
255
|
-
* Server/client boundary: ErrorCode + params only (no translated strings).
|
|
256
|
-
* @param {any} payload
|
|
257
|
-
*/
|
|
195
|
+
/** Server/client boundary: ErrorCode + params only (no translated strings). */
|
|
258
196
|
export function assertServerErrorEnvelope(payload) {
|
|
259
|
-
/** @type {any[]} */
|
|
260
197
|
const diagnostics = [];
|
|
261
198
|
if (payload == null || typeof payload !== 'object') {
|
|
262
199
|
diagnostics.push({
|
|
@@ -291,12 +228,8 @@ export function assertServerErrorEnvelope(payload) {
|
|
|
291
228
|
diagnostics,
|
|
292
229
|
};
|
|
293
230
|
}
|
|
294
|
-
/**
|
|
295
|
-
* Final-user server formatting (mail/export/push) requires explicit LocaleContext.
|
|
296
|
-
* @param {{ localeContext?: { localeId?: string, timeZone?: string }|null, purpose: string }} input
|
|
297
|
-
*/
|
|
231
|
+
/** Final-user server formatting (mail/export/push) requires explicit LocaleContext. */
|
|
298
232
|
export function assertServerFormatContext(input) {
|
|
299
|
-
/** @type {any[]} */
|
|
300
233
|
const diagnostics = [];
|
|
301
234
|
const ctx = input.localeContext;
|
|
302
235
|
if (!ctx?.localeId || !ctx?.timeZone) {
|
|
@@ -308,12 +241,8 @@ export function assertServerFormatContext(input) {
|
|
|
308
241
|
}
|
|
309
242
|
return { ok: diagnostics.length === 0, diagnostics };
|
|
310
243
|
}
|
|
311
|
-
/**
|
|
312
|
-
* Same MessageId / catalog hashes must agree across Host projections.
|
|
313
|
-
* @param {Array<ReturnType<typeof buildLocaleDeliveryResolution>>} resolutions
|
|
314
|
-
*/
|
|
244
|
+
/** Same MessageId / catalog hashes must agree across Host projections. */
|
|
315
245
|
export function assertHostMessageInvariant(resolutions) {
|
|
316
|
-
/** @type {any[]} */
|
|
317
246
|
const diagnostics = [];
|
|
318
247
|
if (!resolutions?.length)
|
|
319
248
|
return { ok: true, diagnostics };
|
|
@@ -345,23 +274,8 @@ export function assertHostMessageInvariant(resolutions) {
|
|
|
345
274
|
}
|
|
346
275
|
return { ok: diagnostics.length === 0, diagnostics };
|
|
347
276
|
}
|
|
348
|
-
/**
|
|
349
|
-
* Aggregate delivery proof for fixture / CLI.
|
|
350
|
-
* @param {{
|
|
351
|
-
* manifest: {
|
|
352
|
-
* defaultLocale: string,
|
|
353
|
-
* locales: Array<{ id: string }>,
|
|
354
|
-
* fallback?: Record<string, string[]>,
|
|
355
|
-
* routing?: unknown,
|
|
356
|
-
* },
|
|
357
|
-
* messages: Array<{ messageId: string, variants: Record<string, { template: string }> }>,
|
|
358
|
-
* applicationId?: string,
|
|
359
|
-
* planVersion?: string,
|
|
360
|
-
* reachableMessageIds?: string[],
|
|
361
|
-
* }} input
|
|
362
|
-
*/
|
|
277
|
+
/** Aggregate delivery proof for fixture / CLI. */
|
|
363
278
|
export function checkLocaleDelivery(input) {
|
|
364
|
-
/** @type {any[]} */
|
|
365
279
|
const diagnostics = [];
|
|
366
280
|
const supported = (input.manifest?.locales || []).map((l) => l.id);
|
|
367
281
|
const defaultLocale = input.manifest?.defaultLocale;
|
|
@@ -3,15 +3,13 @@
|
|
|
3
3
|
* Consumed by serve-host + static-emit; LocaleId stays out of stable RouteId.
|
|
4
4
|
*/
|
|
5
5
|
export declare const LOCALE_ROUTE_REALIZATION_ARTIFACT_SCHEMA = "vmz.locale.route_realization.v0";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
export declare function emitLocaleRouteRealization(projectRoot: any, distDir: any, opts?: {}): {
|
|
6
|
+
export interface EmitLocaleRouteRealizationOpts {
|
|
7
|
+
origin?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function emitLocaleRouteRealization(projectRoot: string, distDir: string, opts?: EmitLocaleRouteRealizationOpts): {
|
|
12
10
|
ok: boolean;
|
|
13
11
|
written: any[];
|
|
14
|
-
diagnostics:
|
|
12
|
+
diagnostics: import("./locale-check.js").LocaleDiagnostic[];
|
|
15
13
|
artifact: any;
|
|
16
14
|
} | {
|
|
17
15
|
ok: boolean;
|
|
@@ -30,8 +28,24 @@ export declare function emitLocaleRouteRealization(projectRoot: any, distDir: an
|
|
|
30
28
|
routeId: string;
|
|
31
29
|
path: string;
|
|
32
30
|
}[];
|
|
33
|
-
realizations:
|
|
34
|
-
pageMetas:
|
|
31
|
+
realizations: import("./locale-router.js").LocaleRealization[];
|
|
32
|
+
pageMetas: {
|
|
33
|
+
schema: string;
|
|
34
|
+
routeId: string;
|
|
35
|
+
locale: string;
|
|
36
|
+
htmlLang: string;
|
|
37
|
+
dir: string;
|
|
38
|
+
title: string;
|
|
39
|
+
description: string;
|
|
40
|
+
canonical: string;
|
|
41
|
+
alternates: {
|
|
42
|
+
localeId: string;
|
|
43
|
+
hreflang: string;
|
|
44
|
+
href: string;
|
|
45
|
+
}[];
|
|
46
|
+
diagnostics: import("./locale-router.js").LocaleDiagnostic[];
|
|
47
|
+
status: string;
|
|
48
|
+
}[];
|
|
35
49
|
};
|
|
36
50
|
diagnostics: any[];
|
|
37
51
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* Emit RouteId × LocaleId realization (+ PageMeta / hreflang seed) into dist/_vmz.
|
|
4
3
|
* Consumed by serve-host + static-emit; LocaleId stays out of stable RouteId.
|
|
@@ -10,11 +9,6 @@ import { buildLocalePageMeta, buildLocaleRouteRealizationTable } from './locale-
|
|
|
10
9
|
import { writePrettyJsonFile } from './pretty-json.js';
|
|
11
10
|
import { listPublicPageUnits, unitBrowserPathPattern } from './route-path.js';
|
|
12
11
|
export const LOCALE_ROUTE_REALIZATION_ARTIFACT_SCHEMA = 'vmz.locale.route_realization.v0';
|
|
13
|
-
/**
|
|
14
|
-
* @param {string} projectRoot
|
|
15
|
-
* @param {string} distDir
|
|
16
|
-
* @param {{ origin?: string }} [opts]
|
|
17
|
-
*/
|
|
18
12
|
export function emitLocaleRouteRealization(projectRoot, distDir, opts = {}) {
|
|
19
13
|
const report = checkLocales({ projectRoot, checkUnused: false });
|
|
20
14
|
if (localeHasErrors(report)) {
|
|
@@ -54,7 +48,6 @@ export function emitLocaleRouteRealization(projectRoot, distDir, opts = {}) {
|
|
|
54
48
|
return { ok: false, written: [], diagnostics: table.diagnostics || [], artifact: null };
|
|
55
49
|
}
|
|
56
50
|
const origin = String(opts.origin || process.env.VMZ_SITE_ORIGIN || 'https://example.test').replace(/\/$/, '');
|
|
57
|
-
/** @type {any[]} */
|
|
58
51
|
const pageMetas = [];
|
|
59
52
|
for (const route of routes) {
|
|
60
53
|
for (const loc of locales) {
|
package/dist/locale-router.d.ts
CHANGED
|
@@ -4,94 +4,112 @@
|
|
|
4
4
|
*
|
|
5
5
|
* LocaleId is a RouteNode realization dimension — not part of stable RouteId.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
export interface LocaleRoutingOpts {
|
|
8
|
+
strategy?: string;
|
|
9
|
+
defaultPrefix?: string;
|
|
10
|
+
defaultLocale?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface LocaleRouteEntry {
|
|
13
|
+
routeId: string;
|
|
14
|
+
path: string;
|
|
15
|
+
}
|
|
16
|
+
export interface LocaleRealization {
|
|
17
|
+
routeId: string;
|
|
18
|
+
localeId: string;
|
|
19
|
+
path: string;
|
|
20
|
+
pathPattern?: string;
|
|
21
|
+
prefixed?: boolean;
|
|
22
|
+
strategy?: string;
|
|
23
|
+
defaultPrefix?: string;
|
|
24
|
+
schema?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface LocaleDiagnostic {
|
|
27
|
+
code: string;
|
|
28
|
+
severity: string;
|
|
29
|
+
message: string;
|
|
30
|
+
}
|
|
31
|
+
/** Join locale prefix with a stable route path pattern. */
|
|
32
|
+
export declare function realizeRoutePath(localeId: string, pathPattern: string, routing?: LocaleRoutingOpts): {
|
|
14
33
|
schema: string;
|
|
15
|
-
localeId:
|
|
34
|
+
localeId: string;
|
|
16
35
|
path: string;
|
|
17
36
|
prefixed: boolean;
|
|
18
|
-
strategy:
|
|
37
|
+
strategy: string;
|
|
19
38
|
defaultPrefix?: undefined;
|
|
20
39
|
} | {
|
|
21
40
|
schema: string;
|
|
22
|
-
localeId:
|
|
41
|
+
localeId: string;
|
|
23
42
|
path: string;
|
|
24
43
|
prefixed: boolean;
|
|
25
44
|
strategy: string;
|
|
26
|
-
defaultPrefix:
|
|
45
|
+
defaultPrefix: string;
|
|
27
46
|
};
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
* }} input
|
|
36
|
-
*/
|
|
37
|
-
export declare function buildLocaleRouteRealizationTable(input: any): {
|
|
47
|
+
/** Build RouteId × LocaleId realization table. */
|
|
48
|
+
export declare function buildLocaleRouteRealizationTable(input: {
|
|
49
|
+
routes: LocaleRouteEntry[];
|
|
50
|
+
locales: string[];
|
|
51
|
+
defaultLocale: string;
|
|
52
|
+
routing?: LocaleRoutingOpts;
|
|
53
|
+
}): {
|
|
38
54
|
schema: string;
|
|
39
55
|
status: string;
|
|
40
56
|
routing: {
|
|
41
|
-
strategy:
|
|
42
|
-
defaultPrefix:
|
|
43
|
-
defaultLocale:
|
|
57
|
+
strategy: string;
|
|
58
|
+
defaultPrefix: string;
|
|
59
|
+
defaultLocale: string;
|
|
44
60
|
};
|
|
45
|
-
realizations:
|
|
46
|
-
diagnostics:
|
|
61
|
+
realizations: LocaleRealization[];
|
|
62
|
+
diagnostics: LocaleDiagnostic[];
|
|
47
63
|
};
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* }} input
|
|
67
|
-
*/
|
|
68
|
-
export declare function buildLocalePageMeta(input: any): {
|
|
64
|
+
/** Absolute URL helper. */
|
|
65
|
+
export declare function absoluteUrl(origin: string, path: string): string;
|
|
66
|
+
/** Locale-aware PageMeta for one RouteId × LocaleId. */
|
|
67
|
+
export declare function buildLocalePageMeta(input: {
|
|
68
|
+
routeId: string;
|
|
69
|
+
localeId: string;
|
|
70
|
+
direction?: string;
|
|
71
|
+
title: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
origin: string;
|
|
74
|
+
realizations: Array<{
|
|
75
|
+
routeId: string;
|
|
76
|
+
localeId: string;
|
|
77
|
+
path: string;
|
|
78
|
+
}>;
|
|
79
|
+
locales: string[];
|
|
80
|
+
defaultLocale: string;
|
|
81
|
+
}): {
|
|
69
82
|
schema: string;
|
|
70
|
-
routeId:
|
|
71
|
-
locale:
|
|
72
|
-
htmlLang:
|
|
73
|
-
dir:
|
|
74
|
-
title:
|
|
75
|
-
description:
|
|
83
|
+
routeId: string;
|
|
84
|
+
locale: string;
|
|
85
|
+
htmlLang: string;
|
|
86
|
+
dir: string;
|
|
87
|
+
title: string;
|
|
88
|
+
description: string;
|
|
76
89
|
canonical: string;
|
|
77
|
-
alternates:
|
|
78
|
-
|
|
90
|
+
alternates: {
|
|
91
|
+
localeId: string;
|
|
92
|
+
hreflang: string;
|
|
93
|
+
href: string;
|
|
94
|
+
}[];
|
|
95
|
+
diagnostics: LocaleDiagnostic[];
|
|
79
96
|
status: string;
|
|
80
97
|
};
|
|
81
|
-
/**
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
98
|
+
/** `<Link to="routeId">` retains current locale — never hand-written localized paths. */
|
|
99
|
+
export declare function resolveLinkHref(input: {
|
|
100
|
+
to: string;
|
|
101
|
+
currentLocale: string;
|
|
102
|
+
realizations: Array<{
|
|
103
|
+
routeId: string;
|
|
104
|
+
localeId: string;
|
|
105
|
+
path: string;
|
|
106
|
+
}>;
|
|
107
|
+
}): {
|
|
90
108
|
schema: string;
|
|
91
109
|
status: string;
|
|
92
|
-
to:
|
|
110
|
+
to: string;
|
|
93
111
|
href: any;
|
|
94
|
-
localeId:
|
|
112
|
+
localeId: string;
|
|
95
113
|
diagnostics: {
|
|
96
114
|
code: string;
|
|
97
115
|
severity: string;
|
|
@@ -101,126 +119,135 @@ export declare function resolveLinkHref(input: any): {
|
|
|
101
119
|
} | {
|
|
102
120
|
schema: string;
|
|
103
121
|
status: string;
|
|
104
|
-
to:
|
|
105
|
-
routeId:
|
|
106
|
-
localeId:
|
|
107
|
-
href:
|
|
122
|
+
to: string;
|
|
123
|
+
routeId: string;
|
|
124
|
+
localeId: string;
|
|
125
|
+
href: string;
|
|
108
126
|
diagnostics: any[];
|
|
109
127
|
};
|
|
110
|
-
/**
|
|
111
|
-
|
|
112
|
-
* @param {string} pathname
|
|
113
|
-
* @param {string[]} supportedLocales
|
|
114
|
-
*/
|
|
115
|
-
export declare function parseLocaleFromPath(pathname: any, supportedLocales: any): {
|
|
128
|
+
/** Parse locale prefix from a pathname under prefix strategy. */
|
|
129
|
+
export declare function parseLocaleFromPath(pathname: string, supportedLocales: string[]): {
|
|
116
130
|
localeId: string;
|
|
117
131
|
restPath: string;
|
|
118
132
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
* Plan redirect / negotiation for an incoming URL (omit-prefix aware).
|
|
141
|
-
* @param {{
|
|
142
|
-
* pathname: string,
|
|
143
|
-
* supportedLocales: string[],
|
|
144
|
-
* defaultLocale: string,
|
|
145
|
-
* routing?: { strategy?: string, defaultPrefix?: string },
|
|
146
|
-
* hostCandidates?: string[],
|
|
147
|
-
* preference?: string|null,
|
|
148
|
-
* userChoice?: string|null,
|
|
149
|
-
* }} input
|
|
150
|
-
*/
|
|
151
|
-
export declare function planLocalePathNavigation(input: any): {
|
|
133
|
+
export interface LocaleHrefArtifact {
|
|
134
|
+
locales?: Array<{
|
|
135
|
+
id: string;
|
|
136
|
+
} | string>;
|
|
137
|
+
defaultLocale?: string;
|
|
138
|
+
routing?: LocaleRoutingOpts;
|
|
139
|
+
}
|
|
140
|
+
/** Rewrite a same-app href to the given LocaleId via route realization. */
|
|
141
|
+
export declare function localizeSameAppHref(href: string, localeId: string, artifact: LocaleHrefArtifact): string;
|
|
142
|
+
/** Rewrite `<a data-vmz-route href>` in HTML body to retain `localeId`. */
|
|
143
|
+
export declare function localizeBodyLinks(html: string, localeId: string, artifact: LocaleHrefArtifact, escapeAttr?: (s: string) => string): string;
|
|
144
|
+
/** Plan redirect / negotiation for an incoming URL (omit-prefix aware). */
|
|
145
|
+
export declare function planLocalePathNavigation(input: {
|
|
146
|
+
pathname: string;
|
|
147
|
+
supportedLocales: string[];
|
|
148
|
+
defaultLocale: string;
|
|
149
|
+
routing?: LocaleRoutingOpts;
|
|
150
|
+
hostCandidates?: string[];
|
|
151
|
+
preference?: string | null;
|
|
152
|
+
userChoice?: string | null;
|
|
153
|
+
}): {
|
|
152
154
|
schema: string;
|
|
153
155
|
kind: string;
|
|
154
156
|
pathname: string;
|
|
155
157
|
routeLocale: string;
|
|
156
|
-
negotiatedLocale:
|
|
158
|
+
negotiatedLocale: string;
|
|
157
159
|
restPath: string;
|
|
158
|
-
redirectTo:
|
|
160
|
+
redirectTo: string;
|
|
159
161
|
realizedPath: string;
|
|
160
|
-
diagnostics:
|
|
161
|
-
contentLocale:
|
|
162
|
+
diagnostics: LocaleDiagnostic[];
|
|
163
|
+
contentLocale: string;
|
|
162
164
|
};
|
|
163
|
-
/**
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
165
|
+
/** Locale-aware cache key — must include LocaleId so Accept-Language cannot steal content. */
|
|
166
|
+
export declare function localeAwareCacheKey(input: {
|
|
167
|
+
routeId: string;
|
|
168
|
+
localeId: string;
|
|
169
|
+
path: string;
|
|
170
|
+
}): string;
|
|
171
|
+
/** Reject Vary: Accept-Language on a cache key that does not encode LocaleId. */
|
|
172
|
+
export declare function assertLocaleCacheKey(input: {
|
|
173
|
+
cacheKey: string;
|
|
174
|
+
varyAcceptLanguage?: boolean;
|
|
175
|
+
localeId?: string;
|
|
176
|
+
}): {
|
|
173
177
|
ok: boolean;
|
|
174
|
-
diagnostics:
|
|
178
|
+
diagnostics: LocaleDiagnostic[];
|
|
175
179
|
};
|
|
176
|
-
/**
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
180
|
+
/** LocaleTransition must commit Route realization + PageMeta together. */
|
|
181
|
+
export declare function commitLocaleRouteMetaTransition(input: {
|
|
182
|
+
fromLocale: string;
|
|
183
|
+
toLocale: string;
|
|
184
|
+
routeId: string;
|
|
185
|
+
realizations: Array<{
|
|
186
|
+
routeId: string;
|
|
187
|
+
localeId: string;
|
|
188
|
+
path: string;
|
|
189
|
+
}>;
|
|
190
|
+
pageMetaByLocale: Record<string, {
|
|
191
|
+
locale: string;
|
|
192
|
+
canonical: string;
|
|
193
|
+
}>;
|
|
194
|
+
}): {
|
|
187
195
|
schema: string;
|
|
188
196
|
kind: string;
|
|
189
197
|
status: string;
|
|
190
|
-
fromLocale:
|
|
191
|
-
toLocale:
|
|
192
|
-
fromPath:
|
|
193
|
-
toPath:
|
|
194
|
-
pageMeta:
|
|
195
|
-
|
|
198
|
+
fromLocale: string;
|
|
199
|
+
toLocale: string;
|
|
200
|
+
fromPath: string;
|
|
201
|
+
toPath: string;
|
|
202
|
+
pageMeta: {
|
|
203
|
+
locale: string;
|
|
204
|
+
canonical: string;
|
|
205
|
+
};
|
|
206
|
+
diagnostics: LocaleDiagnostic[];
|
|
196
207
|
};
|
|
197
|
-
/**
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
/** Aggregate router/meta proof. */
|
|
209
|
+
export declare function checkLocaleRouter(input: {
|
|
210
|
+
manifest: {
|
|
211
|
+
defaultLocale: string;
|
|
212
|
+
locales: Array<{
|
|
213
|
+
id: string;
|
|
214
|
+
direction?: string;
|
|
215
|
+
}>;
|
|
216
|
+
routing?: LocaleRoutingOpts;
|
|
217
|
+
};
|
|
218
|
+
routes: LocaleRouteEntry[];
|
|
219
|
+
titles?: Record<string, Record<string, string>>;
|
|
220
|
+
origin?: string;
|
|
221
|
+
}): {
|
|
211
222
|
schema: string;
|
|
212
223
|
status: string;
|
|
213
224
|
realizationTable: {
|
|
214
225
|
schema: string;
|
|
215
226
|
status: string;
|
|
216
227
|
routing: {
|
|
217
|
-
strategy:
|
|
218
|
-
defaultPrefix:
|
|
219
|
-
defaultLocale:
|
|
228
|
+
strategy: string;
|
|
229
|
+
defaultPrefix: string;
|
|
230
|
+
defaultLocale: string;
|
|
220
231
|
};
|
|
221
|
-
realizations:
|
|
222
|
-
diagnostics:
|
|
232
|
+
realizations: LocaleRealization[];
|
|
233
|
+
diagnostics: LocaleDiagnostic[];
|
|
223
234
|
};
|
|
224
|
-
pageMetas:
|
|
225
|
-
|
|
235
|
+
pageMetas: {
|
|
236
|
+
schema: string;
|
|
237
|
+
routeId: string;
|
|
238
|
+
locale: string;
|
|
239
|
+
htmlLang: string;
|
|
240
|
+
dir: string;
|
|
241
|
+
title: string;
|
|
242
|
+
description: string;
|
|
243
|
+
canonical: string;
|
|
244
|
+
alternates: {
|
|
245
|
+
localeId: string;
|
|
246
|
+
hreflang: string;
|
|
247
|
+
href: string;
|
|
248
|
+
}[];
|
|
249
|
+
diagnostics: LocaleDiagnostic[];
|
|
250
|
+
status: string;
|
|
251
|
+
}[];
|
|
252
|
+
diagnostics: LocaleDiagnostic[];
|
|
226
253
|
};
|