@vmz/vmz 0.1.24 → 0.1.25

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.
@@ -7,6 +7,7 @@
7
7
  * so barrels resolve at dist root.
8
8
  */
9
9
  export declare const CONTENT_ADDRESSED_ASSETS_SCHEMA = "vmz.content_addressed_assets.v0";
10
+ export declare const ASSET_PLAN_SCHEMA = "vmz.asset.plan.v0";
10
11
  interface ContentAddressedAssetObject {
11
12
  logicalPath: string;
12
13
  assetPath: string;
@@ -13,6 +13,7 @@ import { requireNativeAddon } from './native-addon.js';
13
13
  import { canonicalJson, sha256Hex } from './release-pack.js';
14
14
  import { writePrettyJsonFile } from './pretty-json.js';
15
15
  export const CONTENT_ADDRESSED_ASSETS_SCHEMA = 'vmz.content_addressed_assets.v0';
16
+ export const ASSET_PLAN_SCHEMA = 'vmz.asset.plan.v0';
16
17
  /** Immutable delivery candidates (client-facing bytes). */
17
18
  const DEFAULT_CANDIDATES = [
18
19
  'entry-client.js',
@@ -92,6 +93,14 @@ export function emitContentAddressedAssets(distDir, opts = {}) {
92
93
  const objects = [];
93
94
  const rewrites = {};
94
95
  const ordered = orderCandidates(candidates);
96
+ const vmzMetaDir = path.join(abs, '_vmz');
97
+ fs.mkdirSync(vmzMetaDir, { recursive: true });
98
+ writePrettyJsonFile(path.join(vmzMetaDir, 'asset-plan.json'), {
99
+ schema: ASSET_PLAN_SCHEMA,
100
+ layout: 'assets/<sha256>.<ext>',
101
+ immutable: true,
102
+ candidates: ordered,
103
+ });
95
104
  for (const rel of ordered) {
96
105
  // Aggregators are replaced in later passes; leaf JS must rewrite ./ → ../ so a
97
106
  // hashed barrel under assets/ never 404s on second-hop relative re-exports.
@@ -132,7 +132,7 @@ export declare function parseLocaleFromPath(pathname: string, supportedLocales:
132
132
  };
133
133
  export type { 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 } from '@vmz/core/localize-body-links';
135
+ export { localizeBodyLinks, localizeSameAppHref, buildLocaleLinkPlan, applyLocaleLinkPlan } 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 } from '@vmz/core/localize-body-links';
232
+ export { localizeBodyLinks, localizeSameAppHref, buildLocaleLinkPlan, applyLocaleLinkPlan } 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 = {
@@ -3,6 +3,7 @@
3
3
  * Reuses the same Direct SSR path as serve-host (no second SSG runtime).
4
4
  */
5
5
  export declare const STATIC_DELIVERY_MANIFEST_SCHEMA = "vmz.static.delivery_manifest.v0";
6
+ export declare const STATIC_EMIT_PLAN_SCHEMA = "vmz.static.emit_plan.v0";
6
7
  export type EmitWebStaticOpts = {
7
8
  origin?: string;
8
9
  applicationId?: string;
@@ -11,13 +11,14 @@ import { resolveRouteLayoutChain } from '@vmz/core/route-layout-chain';
11
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, localizeBodyLinks } from './locale-router.js';
14
+ import { absoluteUrl, buildLocalePageMeta, buildLocaleLinkPlan, applyLocaleLinkPlan } 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';
18
18
  import { listPublicPageUnits, parsePathPattern, unitBrowserPathPattern } from './route-path.js';
19
19
  import { emitSiteFavicon, readSiteFaviconHeadHtml } from './site-favicon.js';
20
20
  export const STATIC_DELIVERY_MANIFEST_SCHEMA = 'vmz.static.delivery_manifest.v0';
21
+ export const STATIC_EMIT_PLAN_SCHEMA = 'vmz.static.emit_plan.v0';
21
22
  export async function emitWebStatic(distDir, opts = {}) {
22
23
  const origin = String(opts.origin || process.env.VMZ_SITE_ORIGIN || 'https://example.test').replace(/\/$/, '');
23
24
  const applicationId = opts.applicationId || path.basename(path.dirname(distDir));
@@ -40,6 +41,8 @@ export async function emitWebStatic(distDir, opts = {}) {
40
41
  const cssLogical = readCssEntry(distDir);
41
42
  const cssEntry = hashedAssetHref(assets.rewrites, cssLogical) || hashedAssetHref(assets.rewrites, 'vmz.css');
42
43
  const moduleScriptSrc = hashedAssetHref(assets.rewrites, 'entry-client.js') || '/entry-client.js';
44
+ const localeArt = loadLocaleArtifact(distDir);
45
+ const localeLinkPlan = buildLocaleLinkPlan(localeArt);
43
46
  for (const page of pageCatalog) {
44
47
  const pattern = page.pathPattern || patternFromSegs(page.segs);
45
48
  const routeId = guessRouteId(distDir, page.chunkId);
@@ -104,8 +107,6 @@ export async function emitWebStatic(distDir, opts = {}) {
104
107
  continue;
105
108
  bodyHtml = await renderToString(Layout, {}, { slotHtml: bodyHtml });
106
109
  }
107
- const localeArt = loadLocaleArtifact(distDir);
108
- // Locale artifact routeId is chunkId (`pages/about`), not the page class name.
109
110
  const localeWrites = expandLocaleStaticGenerations({
110
111
  localeArt,
111
112
  routeId: page.chunkId,
@@ -118,7 +119,7 @@ export async function emitWebStatic(distDir, opts = {}) {
118
119
  const absHtml = path.join(distDir, gen.htmlPath);
119
120
  fs.mkdirSync(path.dirname(absHtml), { recursive: true });
120
121
  // Each LocaleId HTML must retain locale on same-app Links (realization authority).
121
- const localizedBody = gen.localeId && localeArt ? localizeBodyLinks(bodyHtml, gen.localeId, localeArt) : bodyHtml;
122
+ const localizedBody = gen.localeId && localeLinkPlan.rows.length ? applyLocaleLinkPlan(bodyHtml, gen.localeId, localeLinkPlan) : bodyHtml;
122
123
  const html = wrapDocument({
123
124
  bodyHtml: localizedBody,
124
125
  chunkId: page.chunkId,
@@ -227,6 +228,22 @@ export async function emitWebStatic(distDir, opts = {}) {
227
228
  const digest = sha256Hex(canonicalJson(manifest));
228
229
  manifest.manifestDigest = digest;
229
230
  writePrettyJsonFile(path.join(vmzDir, 'static-delivery-manifest.json'), manifest);
231
+ writePrettyJsonFile(path.join(vmzDir, 'static-emit-plan.json'), {
232
+ schema: STATIC_EMIT_PLAN_SCHEMA,
233
+ applicationId,
234
+ deliveryProfile: 'static',
235
+ origin,
236
+ localeLinks: localeLinkPlan,
237
+ assetPlanPath: '_vmz/asset-plan.json',
238
+ routes: generations.map((g) => ({
239
+ routeId: g.routeId,
240
+ path: g.path,
241
+ chunkId: g.chunkId,
242
+ htmlPath: g.htmlPath,
243
+ classification: g.classification,
244
+ localeId: g.localeId || null,
245
+ })),
246
+ });
230
247
  const cdn = emitCdnPolicy(distDir, manifest);
231
248
  return {
232
249
  manifest,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vmz/vmz",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
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.24",
52
- "@vmz/core": "0.1.24",
53
- "@vmz/diagnostic": "0.1.24",
54
- "@vmz/plugin": "0.1.24",
55
- "@vmz/protocol": "0.1.24",
51
+ "@vmz/commander": "0.1.25",
52
+ "@vmz/core": "0.1.25",
53
+ "@vmz/diagnostic": "0.1.25",
54
+ "@vmz/plugin": "0.1.25",
55
+ "@vmz/protocol": "0.1.25",
56
56
  "jiti": "^2.6.1"
57
57
  },
58
58
  "peerDependencies": {
59
- "@vmz/plugin-markdown-it": "0.1.24",
60
- "@vmz/test": "0.1.24",
59
+ "@vmz/plugin-markdown-it": "0.1.25",
60
+ "@vmz/test": "0.1.25",
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.24",
96
- "@vmz/vmz-win32-arm64": "0.1.24",
97
- "@vmz/vmz-darwin-x64": "0.1.24",
98
- "@vmz/vmz-darwin-arm64": "0.1.24",
99
- "@vmz/vmz-linux-x64": "0.1.24",
100
- "@vmz/vmz-linux-arm64": "0.1.24"
95
+ "@vmz/vmz-win32-x64": "0.1.25",
96
+ "@vmz/vmz-win32-arm64": "0.1.25",
97
+ "@vmz/vmz-darwin-x64": "0.1.25",
98
+ "@vmz/vmz-darwin-arm64": "0.1.25",
99
+ "@vmz/vmz-linux-x64": "0.1.25",
100
+ "@vmz/vmz-linux-arm64": "0.1.25"
101
101
  },
102
102
  "publishConfig": {
103
103
  "access": "public"