@vmz/vmz 0.1.26 → 0.1.28

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.
@@ -130,9 +130,9 @@ export declare function parseLocaleFromPath(pathname: string, supportedLocales:
130
130
  localeId: string;
131
131
  restPath: string;
132
132
  };
133
- export type { LocaleHrefArtifact } from '@vmz/core/localize-body-links';
133
+ export type { LinkRouteAlias, LocaleHrefArtifact } from '@vmz/core/localize-body-links';
134
134
  /** Rewrite a same-app href — single implementation in `@vmz/core/localize-body-links`. */
135
- export { localizeBodyLinks, localizeSameAppHref, buildLocaleLinkPlan, applyLocaleLinkPlan } from '@vmz/core/localize-body-links';
135
+ export { applyLocaleLinkPlan, buildLocaleLinkPlan, linkRouteAliasesFromUnits, localizeBodyLinks, localizeSameAppHref, } from '@vmz/core/localize-body-links';
136
136
  /** Plan redirect / negotiation for an incoming URL (omit-prefix aware). */
137
137
  export declare function planLocalePathNavigation(input: {
138
138
  pathname: string;
@@ -229,7 +229,7 @@ export function parseLocaleFromPath(pathname, supportedLocales) {
229
229
  return { localeId: null, restPath: normalizePath(pathname) };
230
230
  }
231
231
  /** Rewrite a same-app href — single implementation in `@vmz/core/localize-body-links`. */
232
- export { localizeBodyLinks, localizeSameAppHref, buildLocaleLinkPlan, applyLocaleLinkPlan } from '@vmz/core/localize-body-links';
232
+ export { applyLocaleLinkPlan, buildLocaleLinkPlan, linkRouteAliasesFromUnits, localizeBodyLinks, localizeSameAppHref, } from '@vmz/core/localize-body-links';
233
233
  /** Plan redirect / negotiation for an incoming URL (omit-prefix aware). */
234
234
  export function planLocalePathNavigation(input) {
235
235
  const routing = {
@@ -6,12 +6,12 @@ import crypto from 'node:crypto';
6
6
  import fs from 'node:fs';
7
7
  import path from 'node:path';
8
8
  import { pathToFileURL } from 'node:url';
9
+ import { listClientComponentsSync } from '@vmz/core/component-registry';
9
10
  import { createRenderHost } from '@vmz/core/render-host';
10
11
  import { resolveRouteLayoutChain } from '@vmz/core/route-layout-chain';
11
- import { listClientComponentsSync } from '@vmz/core/component-registry';
12
12
  import { emitCdnPolicy } from './cdn-policy.js';
13
13
  import { emitContentAddressedAssets, hashedAssetHref } from './content-addressed-assets.js';
14
- import { absoluteUrl, buildLocalePageMeta, buildLocaleLinkPlan, applyLocaleLinkPlan } from './locale-router.js';
14
+ import { absoluteUrl, applyLocaleLinkPlan, buildLocaleLinkPlan, buildLocalePageMeta, linkRouteAliasesFromUnits } from './locale-router.js';
15
15
  import { requireNativeAddon } from './native-addon.js';
16
16
  import { writePrettyJsonFile } from './pretty-json.js';
17
17
  import { emitPublicStaticAssets } from './public-static-assets.js';
@@ -42,7 +42,7 @@ export async function emitWebStatic(distDir, opts = {}) {
42
42
  const cssEntry = hashedAssetHref(assets.rewrites, cssLogical) || hashedAssetHref(assets.rewrites, 'vmz.css');
43
43
  const moduleScriptSrc = hashedAssetHref(assets.rewrites, 'entry-client.js') || '/entry-client.js';
44
44
  const localeArt = loadLocaleArtifact(distDir);
45
- const localeLinkPlan = buildLocaleLinkPlan(localeArt);
45
+ const localeLinkPlan = buildLocaleLinkPlan(withLinkRouteAliases(localeArt, distDir, pageCatalog));
46
46
  for (const page of pageCatalog) {
47
47
  const pattern = page.pathPattern || patternFromSegs(page.segs);
48
48
  const routeId = guessRouteId(distDir, page.chunkId);
@@ -370,9 +370,6 @@ async function resolvePageMeta(Page, ctx) {
370
370
  const lang = String(raw.lang || 'en');
371
371
  return { title, description, canonical, robots, lang, alternates: [] };
372
372
  }
373
- /**
374
- * @param {string} distDir
375
- */
376
373
  function loadLocaleArtifact(distDir) {
377
374
  const p = path.join(distDir, '_vmz', 'locale-route-realization.json');
378
375
  if (!fs.existsSync(p))
@@ -384,6 +381,28 @@ function loadLocaleArtifact(distDir) {
384
381
  return null;
385
382
  }
386
383
  }
384
+ /** Bridge Link class RouteId ↔ realization chunk routeId for locale href rewrite. */
385
+ function withLinkRouteAliases(localeArt, distDir, pageCatalog) {
386
+ if (!localeArt)
387
+ return null;
388
+ try {
389
+ const dep = JSON.parse(fs.readFileSync(path.join(distDir, 'vmz-deployment.json'), 'utf8'));
390
+ const fromDep = linkRouteAliasesFromUnits(Array.isArray(dep.units) ? dep.units : []);
391
+ if (fromDep.length)
392
+ return { ...localeArt, linkRouteAliases: fromDep };
393
+ }
394
+ catch {
395
+ /* fall through to catalog guess */
396
+ }
397
+ const guessed = [];
398
+ for (const page of pageCatalog || []) {
399
+ const linkRouteId = guessRouteId(distDir, page.chunkId);
400
+ if (linkRouteId && linkRouteId !== page.chunkId) {
401
+ guessed.push({ linkRouteId, realizationRouteId: page.chunkId });
402
+ }
403
+ }
404
+ return guessed.length ? { ...localeArt, linkRouteAliases: guessed } : localeArt;
405
+ }
387
406
  /**
388
407
  * Expand one Static route across LocaleId realizations (hreflang seed + prefixed HTML).
389
408
  * @param {{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vmz/vmz",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "type": "module",
5
5
  "description": "VMZ Node toolchain — N-API workspace session + CLI (publish name @vmz/vmz)",
6
6
  "license": "MIT",
@@ -48,16 +48,16 @@
48
48
  }
49
49
  },
50
50
  "dependencies": {
51
- "@vmz/commander": "0.1.26",
52
- "@vmz/core": "0.1.26",
53
- "@vmz/diagnostic": "0.1.26",
54
- "@vmz/plugin": "0.1.26",
55
- "@vmz/protocol": "0.1.26",
51
+ "@vmz/commander": "0.1.28",
52
+ "@vmz/core": "0.1.28",
53
+ "@vmz/diagnostic": "0.1.28",
54
+ "@vmz/plugin": "0.1.28",
55
+ "@vmz/protocol": "0.1.28",
56
56
  "jiti": "^2.6.1"
57
57
  },
58
58
  "peerDependencies": {
59
- "@vmz/plugin-markdown-it": "0.1.26",
60
- "@vmz/test": "0.1.26",
59
+ "@vmz/plugin-markdown-it": "0.1.28",
60
+ "@vmz/test": "0.1.28",
61
61
  "typescript": "^5.8.3"
62
62
  },
63
63
  "peerDependenciesMeta": {
@@ -92,12 +92,12 @@
92
92
  "cli"
93
93
  ],
94
94
  "optionalDependencies": {
95
- "@vmz/vmz-win32-x64": "0.1.26",
96
- "@vmz/vmz-win32-arm64": "0.1.26",
97
- "@vmz/vmz-darwin-x64": "0.1.26",
98
- "@vmz/vmz-darwin-arm64": "0.1.26",
99
- "@vmz/vmz-linux-x64": "0.1.26",
100
- "@vmz/vmz-linux-arm64": "0.1.26"
95
+ "@vmz/vmz-win32-x64": "0.1.28",
96
+ "@vmz/vmz-win32-arm64": "0.1.28",
97
+ "@vmz/vmz-darwin-x64": "0.1.28",
98
+ "@vmz/vmz-darwin-arm64": "0.1.28",
99
+ "@vmz/vmz-linux-x64": "0.1.28",
100
+ "@vmz/vmz-linux-arm64": "0.1.28"
101
101
  },
102
102
  "publishConfig": {
103
103
  "access": "public"