every-plugin 3.0.0-rc.14 → 3.0.0-rc.16
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/build/artifact-names.cjs +9 -6
- package/dist/build/artifact-names.cjs.map +1 -1
- package/dist/build/artifact-names.d.cts +7 -5
- package/dist/build/artifact-names.d.cts.map +1 -1
- package/dist/build/artifact-names.d.mts +7 -5
- package/dist/build/artifact-names.d.mts.map +1 -1
- package/dist/build/artifact-names.mjs +8 -5
- package/dist/build/artifact-names.mjs.map +1 -1
- package/dist/build/contract-types.cjs +1 -1
- package/dist/build/rspack/build-report-plugin.cjs +1 -1
- package/dist/build/rspack/chunk-completeness-plugin.cjs +1 -1
- package/dist/build/rspack/compose.cjs +3 -3
- package/dist/build/rspack/generated-config.cjs +2 -2
- package/dist/build/rspack/index.cjs +5 -5
- package/dist/build/rspack/module-federation.cjs +1 -1
- package/dist/build/rspack/plugin.cjs +8 -8
- package/dist/build/rspack/utils.cjs +2 -2
- package/dist/build/ui/factory.cjs +3 -3
- package/dist/build/ui/generated-config.cjs +2 -2
- package/dist/build/ui/hash-artifacts-plugin.cjs +2 -2
- package/dist/build/ui/index.cjs +9 -9
- package/dist/build/ui/manifest-plugin.cjs +1 -1
- package/dist/build/ui/rsbuild-config.cjs +10 -10
- package/dist/build/ui/stubs.cjs +2 -7
- package/dist/build/ui/stubs.cjs.map +1 -1
- package/dist/build/ui/stubs.d.cts.map +1 -1
- package/dist/build/ui/stubs.d.mts.map +1 -1
- package/dist/build/ui/stubs.mjs +2 -7
- package/dist/build/ui/stubs.mjs.map +1 -1
- package/dist/cli.cjs +3 -3
- package/dist/client.cjs +8 -4
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +8 -4
- package/dist/client.mjs.map +1 -1
- package/dist/dev/serve.cjs +9 -9
- package/dist/errors.cjs +12 -2
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +15 -1
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts +15 -1
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +11 -2
- package/dist/errors.mjs.map +1 -1
- package/dist/index.cjs +8 -7
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/plugin.cjs +1 -1
- package/dist/remote-entry.cjs +1 -1
- package/dist/runtime/index.cjs +3 -3
- package/dist/runtime/mf-config.cjs +2 -2
- package/dist/runtime/mf-config.mjs +1 -1
- package/dist/runtime/services/module-federation.service.cjs +5 -5
- package/dist/runtime/services/normalize.cjs +1 -1
- package/dist/runtime/services/plugin-loader.service.cjs +5 -5
- package/dist/runtime/services/plugin.service.cjs +4 -4
- package/dist/runtime/services/secrets.service.cjs +2 -2
- package/dist/runtime/services/shared-identity.cjs +1 -1
- package/dist/runtime/validation.cjs +1 -1
- package/dist/ui/manifest/construct.cjs +18 -43
- package/dist/ui/manifest/construct.cjs.map +1 -1
- package/dist/ui/manifest/construct.d.cts +4 -13
- package/dist/ui/manifest/construct.d.cts.map +1 -1
- package/dist/ui/manifest/construct.d.mts +4 -13
- package/dist/ui/manifest/construct.d.mts.map +1 -1
- package/dist/ui/manifest/construct.mjs +14 -39
- package/dist/ui/manifest/construct.mjs.map +1 -1
- package/dist/ui/manifest/contract.cjs +1 -1
- package/dist/ui/manifest/descriptor.cjs +2 -2
- package/dist/ui/manifest/descriptor.mjs +1 -1
- package/dist/ui/manifest/generator.cjs +6 -6
- package/dist/ui/manifest/index.cjs +7 -7
- package/dist/ui/manifest/index.d.cts +3 -3
- package/dist/ui/manifest/index.d.mts +3 -3
- package/dist/ui/manifest/manifest-schema.cjs +1 -1
- package/dist/ui/manifest/mount-registry.cjs +6 -13
- package/dist/ui/manifest/mount-registry.cjs.map +1 -1
- package/dist/ui/manifest/mount-registry.d.cts +29 -36
- package/dist/ui/manifest/mount-registry.d.cts.map +1 -1
- package/dist/ui/manifest/mount-registry.d.mts +29 -36
- package/dist/ui/manifest/mount-registry.d.mts.map +1 -1
- package/dist/ui/manifest/mount-registry.mjs +6 -13
- package/dist/ui/manifest/mount-registry.mjs.map +1 -1
- package/dist/version-manifest.cjs +25 -0
- package/dist/version-manifest.cjs.map +1 -1
- package/dist/version-manifest.d.cts +13 -1
- package/dist/version-manifest.d.cts.map +1 -1
- package/dist/version-manifest.d.mts +13 -1
- package/dist/version-manifest.d.mts.map +1 -1
- package/dist/version-manifest.mjs +24 -1
- package/dist/version-manifest.mjs.map +1 -1
- package/package.json +28 -28
- package/skills/plugin-client/SKILL.md +2 -2
- package/src/build/artifact-names.ts +8 -5
- package/src/build/ui/stubs.ts +2 -7
- package/src/client.ts +9 -3
- package/src/errors.ts +10 -0
- package/src/ui/manifest/construct.ts +20 -65
- package/src/ui/manifest/index.ts +0 -2
- package/src/ui/manifest/mount-registry.ts +20 -20
- package/src/version-manifest.ts +27 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
let zod = require("zod");
|
|
4
4
|
let node_crypto = require("node:crypto");
|
|
5
5
|
node_crypto = require_runtime.__toESM(node_crypto, 1);
|
|
@@ -34,13 +34,16 @@ function uiEntryFilename(input) {
|
|
|
34
34
|
}
|
|
35
35
|
const HASH_SEGMENT_PATTERN = /\.[a-f0-9]{8,}\./;
|
|
36
36
|
/**
|
|
37
|
-
* Serving classification for bundle objects: anything
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
37
|
+
* Serving classification for bundle objects: anything under a version
|
|
38
|
+
* directory (`versions/<dirId>/…`, #826) or a `versions/<id>.json` manifest
|
|
39
|
+
* is immutable by construction — the directory name is content-addressed and
|
|
40
|
+
* the upload service refuses conflicting writes under `versions/`; likewise
|
|
41
|
+
* any name carrying a content-hash segment (including hashed entrypoints
|
|
42
|
+
* like `remoteEntry.8f3a….js`). Fixed-name entrypoints and non-hashed files
|
|
43
|
+
* a redeploy replaces in place must revalidate.
|
|
42
44
|
*/
|
|
43
45
|
function isImmutableBundlePath(name) {
|
|
46
|
+
if (name === "versions" || name.startsWith("versions/")) return true;
|
|
44
47
|
const base = name.split("/").pop() ?? name;
|
|
45
48
|
return HASH_SEGMENT_PATTERN.test(base);
|
|
46
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact-names.cjs","names":["crypto","z"],"sources":["../../src/build/artifact-names.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport { z } from \"zod\";\n\n/** Dev-mode entry names: the in-memory dev server serves these exact names,\n * and dev consumers (the host's html shell, the compose client payload, the\n * readiness probe) append them — dev has no build report to discover hashed\n * names from. */\nexport const DEV_ENTRY_FILENAME = \"remoteEntry.js\";\nexport const DEV_SERVER_ENTRY_FILENAME = \"remoteEntry.server.js\";\n/** Fixed-name build outputs that get additive immutable hashed copies. */\nexport const MF_MANIFEST_FILENAME = \"mf-manifest.json\";\nexport const STYLE_FILENAME = \"style.css\";\nexport const HASHED_ENTRY_PATTERN = \"remoteEntry.[contenthash].js\";\nexport const HASHED_SERVER_ENTRY_PATTERN = \"remoteEntry.server.[contenthash].js\";\n\n/** The dev-stack signal: everything a dev server spawns (watch or no-watch\n * one-shot builds) serves the fixed dev entry names, because every dev\n * consumer appends them and no build report exists to discover hashed names\n * from. Every other invocation — local builds, host-test production builds,\n * regression container builds, deploys — is a build and emits content-hashed\n * entries + build reports. NODE_ENV cannot carry this decision (vitest runs\n * as \"test\", bundler CLIs default \"production\" even for dev watches), and\n * DEPLOY=true only marks deploy builds — so the dev server stamps its own\n * children. */\nexport function isBuildInvocation(): boolean {\n return process.env.BOS_DEV_SERVER !== \"1\";\n}\n\nexport function uiEntryFilename(input: { isBuild: boolean; server?: boolean }): string {\n if (!input.isBuild) return input.server ? DEV_SERVER_ENTRY_FILENAME : DEV_ENTRY_FILENAME;\n return input.server ? HASHED_SERVER_ENTRY_PATTERN : HASHED_ENTRY_PATTERN;\n}\n\nconst HASH_SEGMENT_PATTERN = /\\.[a-f0-9]{8,}\\./;\n\n/**\n * Serving classification for bundle objects: anything
|
|
1
|
+
{"version":3,"file":"artifact-names.cjs","names":["crypto","z"],"sources":["../../src/build/artifact-names.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport { z } from \"zod\";\n\n/** Dev-mode entry names: the in-memory dev server serves these exact names,\n * and dev consumers (the host's html shell, the compose client payload, the\n * readiness probe) append them — dev has no build report to discover hashed\n * names from. */\nexport const DEV_ENTRY_FILENAME = \"remoteEntry.js\";\nexport const DEV_SERVER_ENTRY_FILENAME = \"remoteEntry.server.js\";\n/** Fixed-name build outputs that get additive immutable hashed copies. */\nexport const MF_MANIFEST_FILENAME = \"mf-manifest.json\";\nexport const STYLE_FILENAME = \"style.css\";\nexport const HASHED_ENTRY_PATTERN = \"remoteEntry.[contenthash].js\";\nexport const HASHED_SERVER_ENTRY_PATTERN = \"remoteEntry.server.[contenthash].js\";\n\n/** The dev-stack signal: everything a dev server spawns (watch or no-watch\n * one-shot builds) serves the fixed dev entry names, because every dev\n * consumer appends them and no build report exists to discover hashed names\n * from. Every other invocation — local builds, host-test production builds,\n * regression container builds, deploys — is a build and emits content-hashed\n * entries + build reports. NODE_ENV cannot carry this decision (vitest runs\n * as \"test\", bundler CLIs default \"production\" even for dev watches), and\n * DEPLOY=true only marks deploy builds — so the dev server stamps its own\n * children. */\nexport function isBuildInvocation(): boolean {\n return process.env.BOS_DEV_SERVER !== \"1\";\n}\n\nexport function uiEntryFilename(input: { isBuild: boolean; server?: boolean }): string {\n if (!input.isBuild) return input.server ? DEV_SERVER_ENTRY_FILENAME : DEV_ENTRY_FILENAME;\n return input.server ? HASHED_SERVER_ENTRY_PATTERN : HASHED_ENTRY_PATTERN;\n}\n\nconst HASH_SEGMENT_PATTERN = /\\.[a-f0-9]{8,}\\./;\n\n/**\n * Serving classification for bundle objects: anything under a version\n * directory (`versions/<dirId>/…`, #826) or a `versions/<id>.json` manifest\n * is immutable by construction — the directory name is content-addressed and\n * the upload service refuses conflicting writes under `versions/`; likewise\n * any name carrying a content-hash segment (including hashed entrypoints\n * like `remoteEntry.8f3a….js`). Fixed-name entrypoints and non-hashed files\n * a redeploy replaces in place must revalidate.\n */\nexport function isImmutableBundlePath(name: string): boolean {\n if (name === \"versions\" || name.startsWith(\"versions/\")) return true;\n const base = name.split(\"/\").pop() ?? name;\n return HASH_SEGMENT_PATTERN.test(base);\n}\n\nexport function cacheControlOf(name: string): string {\n return isImmutableBundlePath(name)\n ? \"public, max-age=31536000, immutable\"\n : \"public, max-age=0, must-revalidate\";\n}\n\n/** Short content hash used to mint additive hashed copies of fixed-name artifacts. */\nexport function contentHashOf(content: string | Uint8Array): string {\n return crypto.createHash(\"sha256\").update(content).digest(\"hex\").slice(0, 16);\n}\n\nexport function hashedArtifactName(base: string, hash: string, ext: string): string {\n return `${base}.${hash}.${ext.replace(/^\\./, \"\")}`;\n}\n\n/** Find the content-hashed entry asset for a base name (\"remoteEntry\", \"remoteEntry.server\"). */\nexport function findHashedEntry(assetNames: string[], base: string): string | null {\n const hashed = assetNames.find((name) => {\n const rest = name.startsWith(`${base}.`) ? name.slice(base.length + 1) : null;\n if (rest === null) return false;\n const hash = rest.slice(0, -3);\n return name.endsWith(\".js\") && /^[a-f0-9]{8,}$/.test(hash);\n });\n return hashed ?? null;\n}\n\nexport const BuildEntryReportSchema = z.object({\n entry: z.string().min(1),\n browserManifest: z.string().min(1).optional(),\n css: z.string().min(1).optional(),\n /**\n * Shared-singleton `name → version` this build embedded — resolved from the\n * building workspace's node_modules at config time and stamped by both the\n * rspack and rsbuild build paths. The deploy leg records it into the\n * workspace's version manifest, so a slot's pin carries shared-dep\n * semantics and consumers can detect a build skew before loading (#546).\n */\n shared: z.record(z.string(), z.string()).optional(),\n});\nexport type BuildEntryReport = z.infer<typeof BuildEntryReportSchema>;\n\nexport interface ArtifactCopy {\n from: string;\n to: string;\n}\n\n/**\n * The additive-copy plan for one compiled dist root: each supplied fixed-name\n * artifact gets an immutable hashed copy. The hashed entry itself needs no\n * copy — the build report carries its name to the deploy leg. Returns null\n * when the build predates hashed entry names (only fixed names emitted).\n */\nexport function planArtifactCopies(input: {\n assetNames: string[];\n entryBase: string;\n contents?: Record<string, string | Uint8Array | undefined>;\n}): { copies: Array<ArtifactCopy>; report: BuildEntryReport } | null {\n const entry = findHashedEntry(input.assetNames, input.entryBase);\n if (!entry) return null;\n\n const copies: Array<ArtifactCopy> = [];\n const report: BuildEntryReport = { entry };\n\n const hashedCopy = (fixedName: string, reportField: \"browserManifest\" | \"css\") => {\n const content = input.contents?.[fixedName];\n if (content === undefined) return;\n const dot = fixedName.lastIndexOf(\".\");\n const base = fixedName.slice(0, dot);\n const ext = fixedName.slice(dot + 1);\n const hashed = hashedArtifactName(base, contentHashOf(content), ext);\n copies.push({ from: fixedName, to: hashed });\n report[reportField] = hashed;\n };\n hashedCopy(MF_MANIFEST_FILENAME, \"browserManifest\");\n hashedCopy(STYLE_FILENAME, \"css\");\n\n return { copies, report };\n}\n"],"mappings":";;;;;;;;;;;AAOA,MAAa,qBAAqB;AAClC,MAAa,4BAA4B;;AAEzC,MAAa,uBAAuB;AACpC,MAAa,iBAAiB;AAC9B,MAAa,uBAAuB;AACpC,MAAa,8BAA8B;;;;;;;;;;AAW3C,SAAgB,oBAA6B;CAC3C,OAAO,QAAQ,IAAI,mBAAmB;AACxC;AAEA,SAAgB,gBAAgB,OAAuD;CACrF,IAAI,CAAC,MAAM,SAAS,OAAO,MAAM,SAAS,4BAA4B;CACtE,OAAO,MAAM,SAAS,8BAA8B;AACtD;AAEA,MAAM,uBAAuB;;;;;;;;;;AAW7B,SAAgB,sBAAsB,MAAuB;CAC3D,IAAI,SAAS,cAAc,KAAK,WAAW,WAAW,GAAG,OAAO;CAChE,MAAM,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK;CACtC,OAAO,qBAAqB,KAAK,IAAI;AACvC;AAEA,SAAgB,eAAe,MAAsB;CACnD,OAAO,sBAAsB,IAAI,IAC7B,wCACA;AACN;;AAGA,SAAgB,cAAc,SAAsC;CAClE,OAAOA,oBAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,EAAE;AAC9E;AAEA,SAAgB,mBAAmB,MAAc,MAAc,KAAqB;CAClF,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,QAAQ,OAAO,EAAE;AACjD;;AAGA,SAAgB,gBAAgB,YAAsB,MAA6B;CAOjF,OANe,WAAW,MAAM,SAAS;EACvC,MAAM,OAAO,KAAK,WAAW,GAAG,KAAK,EAAE,IAAI,KAAK,MAAM,KAAK,SAAS,CAAC,IAAI;EACzE,IAAI,SAAS,MAAM,OAAO;EAC1B,MAAM,OAAO,KAAK,MAAM,GAAG,EAAE;EAC7B,OAAO,KAAK,SAAS,KAAK,KAAK,iBAAiB,KAAK,IAAI;CAC3D,CACY,KAAK;AACnB;AAEA,MAAa,yBAAyBC,MAAE,OAAO;CAC7C,OAAOA,MAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACvB,iBAAiBA,MAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;CAC5C,KAAKA,MAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;;;;;;;;CAQhC,QAAQA,MAAE,OAAOA,MAAE,OAAO,GAAGA,MAAE,OAAO,CAAC,CAAC,CAAC,SAAS;AACpD,CAAC;;;;;;;AAcD,SAAgB,mBAAmB,OAIkC;CACnE,MAAM,QAAQ,gBAAgB,MAAM,YAAY,MAAM,SAAS;CAC/D,IAAI,CAAC,OAAO,OAAO;CAEnB,MAAM,SAA8B,CAAC;CACrC,MAAM,SAA2B,EAAE,MAAM;CAEzC,MAAM,cAAc,WAAmB,gBAA2C;EAChF,MAAM,UAAU,MAAM,WAAW;EACjC,IAAI,YAAY,QAAW;EAC3B,MAAM,MAAM,UAAU,YAAY,GAAG;EACrC,MAAM,OAAO,UAAU,MAAM,GAAG,GAAG;EACnC,MAAM,MAAM,UAAU,MAAM,MAAM,CAAC;EACnC,MAAM,SAAS,mBAAmB,MAAM,cAAc,OAAO,GAAG,GAAG;EACnE,OAAO,KAAK;GAAE,MAAM;GAAW,IAAI;EAAO,CAAC;EAC3C,OAAO,eAAe;CACxB;CACA,WAAW,sBAAsB,iBAAiB;CAClD,WAAW,gBAAgB,KAAK;CAEhC,OAAO;EAAE;EAAQ;CAAO;AAC1B"}
|
|
@@ -26,11 +26,13 @@ declare function uiEntryFilename(input: {
|
|
|
26
26
|
server?: boolean;
|
|
27
27
|
}): string;
|
|
28
28
|
/**
|
|
29
|
-
* Serving classification for bundle objects: anything
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
29
|
+
* Serving classification for bundle objects: anything under a version
|
|
30
|
+
* directory (`versions/<dirId>/…`, #826) or a `versions/<id>.json` manifest
|
|
31
|
+
* is immutable by construction — the directory name is content-addressed and
|
|
32
|
+
* the upload service refuses conflicting writes under `versions/`; likewise
|
|
33
|
+
* any name carrying a content-hash segment (including hashed entrypoints
|
|
34
|
+
* like `remoteEntry.8f3a….js`). Fixed-name entrypoints and non-hashed files
|
|
35
|
+
* a redeploy replaces in place must revalidate.
|
|
34
36
|
*/
|
|
35
37
|
declare function isImmutableBundlePath(name: string): boolean;
|
|
36
38
|
declare function cacheControlOf(name: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact-names.d.cts","names":[],"sources":["../../src/build/artifact-names.ts"],"mappings":";;;;;;cAOa;cACA;;cAEA;cACA;cACA;cACA;;;;;;;;;;iBAWG;iBAIA,gBAAgB;EAAS;EAAkB
|
|
1
|
+
{"version":3,"file":"artifact-names.d.cts","names":[],"sources":["../../src/build/artifact-names.ts"],"mappings":";;;;;;cAOa;cACA;;cAEA;cACA;cACA;cACA;;;;;;;;;;iBAWG;iBAIA,gBAAgB;EAAS;EAAkB;;;;;;;;;;;iBAgB3C,sBAAsB;iBAMtB,eAAe;;iBAOf,cAAc,kBAAkB;iBAIhC,mBAAmB,cAAc,cAAc;;iBAK/C,gBAAgB,sBAAsB;cAUzC,wBAAsB,EAAA;;;;;GAYjC,EAAA,KAAA;KACU,mBAAmB,EAAE,aAAa;UAE7B;EACf;EACA;;;;;;;;iBASc,mBAAmB;EACjC;EACA;EACA,WAAW,wBAAwB;;EAC/B,QAAQ,MAAM;EAAe,QAAQ"}
|
|
@@ -26,11 +26,13 @@ declare function uiEntryFilename(input: {
|
|
|
26
26
|
server?: boolean;
|
|
27
27
|
}): string;
|
|
28
28
|
/**
|
|
29
|
-
* Serving classification for bundle objects: anything
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
29
|
+
* Serving classification for bundle objects: anything under a version
|
|
30
|
+
* directory (`versions/<dirId>/…`, #826) or a `versions/<id>.json` manifest
|
|
31
|
+
* is immutable by construction — the directory name is content-addressed and
|
|
32
|
+
* the upload service refuses conflicting writes under `versions/`; likewise
|
|
33
|
+
* any name carrying a content-hash segment (including hashed entrypoints
|
|
34
|
+
* like `remoteEntry.8f3a….js`). Fixed-name entrypoints and non-hashed files
|
|
35
|
+
* a redeploy replaces in place must revalidate.
|
|
34
36
|
*/
|
|
35
37
|
declare function isImmutableBundlePath(name: string): boolean;
|
|
36
38
|
declare function cacheControlOf(name: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact-names.d.mts","names":[],"sources":["../../src/build/artifact-names.ts"],"mappings":";;;;;;cAOa;cACA;;cAEA;cACA;cACA;cACA;;;;;;;;;;iBAWG;iBAIA,gBAAgB;EAAS;EAAkB
|
|
1
|
+
{"version":3,"file":"artifact-names.d.mts","names":[],"sources":["../../src/build/artifact-names.ts"],"mappings":";;;;;;cAOa;cACA;;cAEA;cACA;cACA;cACA;;;;;;;;;;iBAWG;iBAIA,gBAAgB;EAAS;EAAkB;;;;;;;;;;;iBAgB3C,sBAAsB;iBAMtB,eAAe;;iBAOf,cAAc,kBAAkB;iBAIhC,mBAAmB,cAAc,cAAc;;iBAK/C,gBAAgB,sBAAsB;cAUzC,wBAAsB,EAAA;;;;;GAYjC,EAAA,KAAA;KACU,mBAAmB,EAAE,aAAa;UAE7B;EACf;EACA;;;;;;;;iBASc,mBAAmB;EACjC;EACA;EACA,WAAW,wBAAwB;;EAC/B,QAAQ,MAAM;EAAe,QAAQ"}
|
|
@@ -31,13 +31,16 @@ function uiEntryFilename(input) {
|
|
|
31
31
|
}
|
|
32
32
|
const HASH_SEGMENT_PATTERN = /\.[a-f0-9]{8,}\./;
|
|
33
33
|
/**
|
|
34
|
-
* Serving classification for bundle objects: anything
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
34
|
+
* Serving classification for bundle objects: anything under a version
|
|
35
|
+
* directory (`versions/<dirId>/…`, #826) or a `versions/<id>.json` manifest
|
|
36
|
+
* is immutable by construction — the directory name is content-addressed and
|
|
37
|
+
* the upload service refuses conflicting writes under `versions/`; likewise
|
|
38
|
+
* any name carrying a content-hash segment (including hashed entrypoints
|
|
39
|
+
* like `remoteEntry.8f3a….js`). Fixed-name entrypoints and non-hashed files
|
|
40
|
+
* a redeploy replaces in place must revalidate.
|
|
39
41
|
*/
|
|
40
42
|
function isImmutableBundlePath(name) {
|
|
43
|
+
if (name === "versions" || name.startsWith("versions/")) return true;
|
|
41
44
|
const base = name.split("/").pop() ?? name;
|
|
42
45
|
return HASH_SEGMENT_PATTERN.test(base);
|
|
43
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact-names.mjs","names":[],"sources":["../../src/build/artifact-names.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport { z } from \"zod\";\n\n/** Dev-mode entry names: the in-memory dev server serves these exact names,\n * and dev consumers (the host's html shell, the compose client payload, the\n * readiness probe) append them — dev has no build report to discover hashed\n * names from. */\nexport const DEV_ENTRY_FILENAME = \"remoteEntry.js\";\nexport const DEV_SERVER_ENTRY_FILENAME = \"remoteEntry.server.js\";\n/** Fixed-name build outputs that get additive immutable hashed copies. */\nexport const MF_MANIFEST_FILENAME = \"mf-manifest.json\";\nexport const STYLE_FILENAME = \"style.css\";\nexport const HASHED_ENTRY_PATTERN = \"remoteEntry.[contenthash].js\";\nexport const HASHED_SERVER_ENTRY_PATTERN = \"remoteEntry.server.[contenthash].js\";\n\n/** The dev-stack signal: everything a dev server spawns (watch or no-watch\n * one-shot builds) serves the fixed dev entry names, because every dev\n * consumer appends them and no build report exists to discover hashed names\n * from. Every other invocation — local builds, host-test production builds,\n * regression container builds, deploys — is a build and emits content-hashed\n * entries + build reports. NODE_ENV cannot carry this decision (vitest runs\n * as \"test\", bundler CLIs default \"production\" even for dev watches), and\n * DEPLOY=true only marks deploy builds — so the dev server stamps its own\n * children. */\nexport function isBuildInvocation(): boolean {\n return process.env.BOS_DEV_SERVER !== \"1\";\n}\n\nexport function uiEntryFilename(input: { isBuild: boolean; server?: boolean }): string {\n if (!input.isBuild) return input.server ? DEV_SERVER_ENTRY_FILENAME : DEV_ENTRY_FILENAME;\n return input.server ? HASHED_SERVER_ENTRY_PATTERN : HASHED_ENTRY_PATTERN;\n}\n\nconst HASH_SEGMENT_PATTERN = /\\.[a-f0-9]{8,}\\./;\n\n/**\n * Serving classification for bundle objects: anything
|
|
1
|
+
{"version":3,"file":"artifact-names.mjs","names":[],"sources":["../../src/build/artifact-names.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport { z } from \"zod\";\n\n/** Dev-mode entry names: the in-memory dev server serves these exact names,\n * and dev consumers (the host's html shell, the compose client payload, the\n * readiness probe) append them — dev has no build report to discover hashed\n * names from. */\nexport const DEV_ENTRY_FILENAME = \"remoteEntry.js\";\nexport const DEV_SERVER_ENTRY_FILENAME = \"remoteEntry.server.js\";\n/** Fixed-name build outputs that get additive immutable hashed copies. */\nexport const MF_MANIFEST_FILENAME = \"mf-manifest.json\";\nexport const STYLE_FILENAME = \"style.css\";\nexport const HASHED_ENTRY_PATTERN = \"remoteEntry.[contenthash].js\";\nexport const HASHED_SERVER_ENTRY_PATTERN = \"remoteEntry.server.[contenthash].js\";\n\n/** The dev-stack signal: everything a dev server spawns (watch or no-watch\n * one-shot builds) serves the fixed dev entry names, because every dev\n * consumer appends them and no build report exists to discover hashed names\n * from. Every other invocation — local builds, host-test production builds,\n * regression container builds, deploys — is a build and emits content-hashed\n * entries + build reports. NODE_ENV cannot carry this decision (vitest runs\n * as \"test\", bundler CLIs default \"production\" even for dev watches), and\n * DEPLOY=true only marks deploy builds — so the dev server stamps its own\n * children. */\nexport function isBuildInvocation(): boolean {\n return process.env.BOS_DEV_SERVER !== \"1\";\n}\n\nexport function uiEntryFilename(input: { isBuild: boolean; server?: boolean }): string {\n if (!input.isBuild) return input.server ? DEV_SERVER_ENTRY_FILENAME : DEV_ENTRY_FILENAME;\n return input.server ? HASHED_SERVER_ENTRY_PATTERN : HASHED_ENTRY_PATTERN;\n}\n\nconst HASH_SEGMENT_PATTERN = /\\.[a-f0-9]{8,}\\./;\n\n/**\n * Serving classification for bundle objects: anything under a version\n * directory (`versions/<dirId>/…`, #826) or a `versions/<id>.json` manifest\n * is immutable by construction — the directory name is content-addressed and\n * the upload service refuses conflicting writes under `versions/`; likewise\n * any name carrying a content-hash segment (including hashed entrypoints\n * like `remoteEntry.8f3a….js`). Fixed-name entrypoints and non-hashed files\n * a redeploy replaces in place must revalidate.\n */\nexport function isImmutableBundlePath(name: string): boolean {\n if (name === \"versions\" || name.startsWith(\"versions/\")) return true;\n const base = name.split(\"/\").pop() ?? name;\n return HASH_SEGMENT_PATTERN.test(base);\n}\n\nexport function cacheControlOf(name: string): string {\n return isImmutableBundlePath(name)\n ? \"public, max-age=31536000, immutable\"\n : \"public, max-age=0, must-revalidate\";\n}\n\n/** Short content hash used to mint additive hashed copies of fixed-name artifacts. */\nexport function contentHashOf(content: string | Uint8Array): string {\n return crypto.createHash(\"sha256\").update(content).digest(\"hex\").slice(0, 16);\n}\n\nexport function hashedArtifactName(base: string, hash: string, ext: string): string {\n return `${base}.${hash}.${ext.replace(/^\\./, \"\")}`;\n}\n\n/** Find the content-hashed entry asset for a base name (\"remoteEntry\", \"remoteEntry.server\"). */\nexport function findHashedEntry(assetNames: string[], base: string): string | null {\n const hashed = assetNames.find((name) => {\n const rest = name.startsWith(`${base}.`) ? name.slice(base.length + 1) : null;\n if (rest === null) return false;\n const hash = rest.slice(0, -3);\n return name.endsWith(\".js\") && /^[a-f0-9]{8,}$/.test(hash);\n });\n return hashed ?? null;\n}\n\nexport const BuildEntryReportSchema = z.object({\n entry: z.string().min(1),\n browserManifest: z.string().min(1).optional(),\n css: z.string().min(1).optional(),\n /**\n * Shared-singleton `name → version` this build embedded — resolved from the\n * building workspace's node_modules at config time and stamped by both the\n * rspack and rsbuild build paths. The deploy leg records it into the\n * workspace's version manifest, so a slot's pin carries shared-dep\n * semantics and consumers can detect a build skew before loading (#546).\n */\n shared: z.record(z.string(), z.string()).optional(),\n});\nexport type BuildEntryReport = z.infer<typeof BuildEntryReportSchema>;\n\nexport interface ArtifactCopy {\n from: string;\n to: string;\n}\n\n/**\n * The additive-copy plan for one compiled dist root: each supplied fixed-name\n * artifact gets an immutable hashed copy. The hashed entry itself needs no\n * copy — the build report carries its name to the deploy leg. Returns null\n * when the build predates hashed entry names (only fixed names emitted).\n */\nexport function planArtifactCopies(input: {\n assetNames: string[];\n entryBase: string;\n contents?: Record<string, string | Uint8Array | undefined>;\n}): { copies: Array<ArtifactCopy>; report: BuildEntryReport } | null {\n const entry = findHashedEntry(input.assetNames, input.entryBase);\n if (!entry) return null;\n\n const copies: Array<ArtifactCopy> = [];\n const report: BuildEntryReport = { entry };\n\n const hashedCopy = (fixedName: string, reportField: \"browserManifest\" | \"css\") => {\n const content = input.contents?.[fixedName];\n if (content === undefined) return;\n const dot = fixedName.lastIndexOf(\".\");\n const base = fixedName.slice(0, dot);\n const ext = fixedName.slice(dot + 1);\n const hashed = hashedArtifactName(base, contentHashOf(content), ext);\n copies.push({ from: fixedName, to: hashed });\n report[reportField] = hashed;\n };\n hashedCopy(MF_MANIFEST_FILENAME, \"browserManifest\");\n hashedCopy(STYLE_FILENAME, \"css\");\n\n return { copies, report };\n}\n"],"mappings":";;;;;;;;AAOA,MAAa,qBAAqB;AAClC,MAAa,4BAA4B;;AAEzC,MAAa,uBAAuB;AACpC,MAAa,iBAAiB;AAC9B,MAAa,uBAAuB;AACpC,MAAa,8BAA8B;;;;;;;;;;AAW3C,SAAgB,oBAA6B;CAC3C,OAAO,QAAQ,IAAI,mBAAmB;AACxC;AAEA,SAAgB,gBAAgB,OAAuD;CACrF,IAAI,CAAC,MAAM,SAAS,OAAO,MAAM,SAAS,4BAA4B;CACtE,OAAO,MAAM,SAAS,8BAA8B;AACtD;AAEA,MAAM,uBAAuB;;;;;;;;;;AAW7B,SAAgB,sBAAsB,MAAuB;CAC3D,IAAI,SAAS,cAAc,KAAK,WAAW,WAAW,GAAG,OAAO;CAChE,MAAM,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK;CACtC,OAAO,qBAAqB,KAAK,IAAI;AACvC;AAEA,SAAgB,eAAe,MAAsB;CACnD,OAAO,sBAAsB,IAAI,IAC7B,wCACA;AACN;;AAGA,SAAgB,cAAc,SAAsC;CAClE,OAAO,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,EAAE;AAC9E;AAEA,SAAgB,mBAAmB,MAAc,MAAc,KAAqB;CAClF,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,QAAQ,OAAO,EAAE;AACjD;;AAGA,SAAgB,gBAAgB,YAAsB,MAA6B;CAOjF,OANe,WAAW,MAAM,SAAS;EACvC,MAAM,OAAO,KAAK,WAAW,GAAG,KAAK,EAAE,IAAI,KAAK,MAAM,KAAK,SAAS,CAAC,IAAI;EACzE,IAAI,SAAS,MAAM,OAAO;EAC1B,MAAM,OAAO,KAAK,MAAM,GAAG,EAAE;EAC7B,OAAO,KAAK,SAAS,KAAK,KAAK,iBAAiB,KAAK,IAAI;CAC3D,CACY,KAAK;AACnB;AAEA,MAAa,yBAAyB,EAAE,OAAO;CAC7C,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACvB,iBAAiB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;CAC5C,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;;;;;;;;CAQhC,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS;AACpD,CAAC;;;;;;;AAcD,SAAgB,mBAAmB,OAIkC;CACnE,MAAM,QAAQ,gBAAgB,MAAM,YAAY,MAAM,SAAS;CAC/D,IAAI,CAAC,OAAO,OAAO;CAEnB,MAAM,SAA8B,CAAC;CACrC,MAAM,SAA2B,EAAE,MAAM;CAEzC,MAAM,cAAc,WAAmB,gBAA2C;EAChF,MAAM,UAAU,MAAM,WAAW;EACjC,IAAI,YAAY,QAAW;EAC3B,MAAM,MAAM,UAAU,YAAY,GAAG;EACrC,MAAM,OAAO,UAAU,MAAM,GAAG,GAAG;EACnC,MAAM,MAAM,UAAU,MAAM,MAAM,CAAC;EACnC,MAAM,SAAS,mBAAmB,MAAM,cAAc,OAAO,GAAG,GAAG;EACnE,OAAO,KAAK;GAAE,MAAM;GAAW,IAAI;EAAO,CAAC;EAC3C,OAAO,eAAe;CACxB;CACA,WAAW,sBAAsB,iBAAiB;CAClD,WAAW,gBAAgB,KAAK;CAEhC,OAAO;EAAE;EAAQ;CAAO;AAC1B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_runtime = require(
|
|
2
|
-
const require_fix_mf_data_uri_plugin = require(
|
|
3
|
-
const require_plugin = require(
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_fix_mf_data_uri_plugin = require("./fix-mf-data-uri-plugin.cjs");
|
|
3
|
+
const require_plugin = require("./plugin.cjs");
|
|
4
4
|
let node_fs = require("node:fs");
|
|
5
5
|
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
6
6
|
let node_module = require("node:module");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_runtime = require(
|
|
2
|
-
const require_compose = require(
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_compose = require("./compose.cjs");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
5
5
|
let node_path = require("node:path");
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_shared_deps_spec = require(
|
|
3
|
-
const require_build_report_plugin = require(
|
|
4
|
-
const require_fix_mf_data_uri_plugin = require(
|
|
5
|
-
const require_plugin = require(
|
|
6
|
-
const require_compose = require(
|
|
2
|
+
const require_shared_deps_spec = require("../../shared-deps-spec.cjs");
|
|
3
|
+
const require_build_report_plugin = require("./build-report-plugin.cjs");
|
|
4
|
+
const require_fix_mf_data_uri_plugin = require("./fix-mf-data-uri-plugin.cjs");
|
|
5
|
+
const require_plugin = require("./plugin.cjs");
|
|
6
|
+
const require_compose = require("./compose.cjs");
|
|
7
7
|
|
|
8
8
|
exports.BuildReportPlugin = require_build_report_plugin.BuildReportPlugin;
|
|
9
9
|
exports.EmitPluginManifest = require_plugin.EmitPluginManifest;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const require_runtime = require(
|
|
2
|
-
const require_build_artifact_names = require(
|
|
3
|
-
const require_shared_deps_spec = require(
|
|
4
|
-
const require_build_report_plugin = require(
|
|
5
|
-
const require_contract_types = require(
|
|
6
|
-
const require_chunk_completeness_plugin = require(
|
|
7
|
-
const require_module_federation = require(
|
|
8
|
-
const require_utils = require(
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_build_artifact_names = require("../artifact-names.cjs");
|
|
3
|
+
const require_shared_deps_spec = require("../../shared-deps-spec.cjs");
|
|
4
|
+
const require_build_report_plugin = require("./build-report-plugin.cjs");
|
|
5
|
+
const require_contract_types = require("../contract-types.cjs");
|
|
6
|
+
const require_chunk_completeness_plugin = require("./chunk-completeness-plugin.cjs");
|
|
7
|
+
const require_module_federation = require("./module-federation.cjs");
|
|
8
|
+
const require_utils = require("./utils.cjs");
|
|
9
9
|
let node_crypto = require("node:crypto");
|
|
10
10
|
node_crypto = require_runtime.__toESM(node_crypto, 1);
|
|
11
11
|
let node_fs = require("node:fs");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_runtime = require(
|
|
2
|
-
const require_identity = require(
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_identity = require("../../identity.cjs");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
5
5
|
let node_module = require("node:module");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_runtime = require(
|
|
2
|
-
const require_ui_manifest_contract = require(
|
|
3
|
-
const require_rsbuild_config = require(
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_ui_manifest_contract = require("../../ui/manifest/contract.cjs");
|
|
3
|
+
const require_rsbuild_config = require("./rsbuild-config.cjs");
|
|
4
4
|
let node_fs = require("node:fs");
|
|
5
5
|
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
6
6
|
let node_path = require("node:path");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_runtime = require(
|
|
2
|
-
const require_compose = require(
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_compose = require("../rspack/compose.cjs");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
5
5
|
let node_path = require("node:path");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_runtime = require(
|
|
2
|
-
const require_build_artifact_names = require(
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_build_artifact_names = require("../artifact-names.cjs");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
5
5
|
let node_path = require("node:path");
|
package/dist/build/ui/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
3
|
-
const require_identity = require(
|
|
4
|
-
const require_ui_manifest_contract = require(
|
|
5
|
-
const require_manifest_plugin = require(
|
|
6
|
-
const require_hash_artifacts_plugin = require(
|
|
7
|
-
const require_rsbuild_config = require(
|
|
8
|
-
const require_factory = require(
|
|
9
|
-
const require_generated_config = require(
|
|
10
|
-
const require_stubs = require(
|
|
2
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_identity = require("../../identity.cjs");
|
|
4
|
+
const require_ui_manifest_contract = require("../../ui/manifest/contract.cjs");
|
|
5
|
+
const require_manifest_plugin = require("./manifest-plugin.cjs");
|
|
6
|
+
const require_hash_artifacts_plugin = require("./hash-artifacts-plugin.cjs");
|
|
7
|
+
const require_rsbuild_config = require("./rsbuild-config.cjs");
|
|
8
|
+
const require_factory = require("./factory.cjs");
|
|
9
|
+
const require_generated_config = require("./generated-config.cjs");
|
|
10
|
+
const require_stubs = require("./stubs.cjs");
|
|
11
11
|
let node_fs = require("node:fs");
|
|
12
12
|
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
13
13
|
let node_path = require("node:path");
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const require_runtime = require(
|
|
2
|
-
const require_build_artifact_names = require(
|
|
3
|
-
const require_shared_deps_spec = require(
|
|
4
|
-
const require_identity = require(
|
|
5
|
-
const require_fix_mf_data_uri_plugin = require(
|
|
6
|
-
require(
|
|
7
|
-
const require_ui_manifest_contract = require(
|
|
8
|
-
const require_manifest_plugin = require(
|
|
9
|
-
const require_hash_artifacts_plugin = require(
|
|
10
|
-
const require_build_ui_index = require(
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_build_artifact_names = require("../artifact-names.cjs");
|
|
3
|
+
const require_shared_deps_spec = require("../../shared-deps-spec.cjs");
|
|
4
|
+
const require_identity = require("../../identity.cjs");
|
|
5
|
+
const require_fix_mf_data_uri_plugin = require("../rspack/fix-mf-data-uri-plugin.cjs");
|
|
6
|
+
require("../rspack/index.cjs");
|
|
7
|
+
const require_ui_manifest_contract = require("../../ui/manifest/contract.cjs");
|
|
8
|
+
const require_manifest_plugin = require("./manifest-plugin.cjs");
|
|
9
|
+
const require_hash_artifacts_plugin = require("./hash-artifacts-plugin.cjs");
|
|
10
|
+
const require_build_ui_index = require("./index.cjs");
|
|
11
11
|
let node_path = require("node:path");
|
|
12
12
|
node_path = require_runtime.__toESM(node_path, 1);
|
|
13
13
|
let _module_federation_rsbuild_plugin = require("@module-federation/rsbuild-plugin");
|
package/dist/build/ui/stubs.cjs
CHANGED
|
@@ -65,19 +65,14 @@ export type {
|
|
|
65
65
|
ConstructedTree,
|
|
66
66
|
ConstructInput,
|
|
67
67
|
ConstructPluginRef,
|
|
68
|
-
GateUser,
|
|
69
|
-
HostContext,
|
|
70
68
|
NavManifest,
|
|
71
69
|
PluginManifest,
|
|
72
70
|
ResolvedPlugin,
|
|
73
71
|
RouteConfigModule,
|
|
74
72
|
RouteOptionsBundle,
|
|
75
73
|
} from "everything-dev/ui/manifest";
|
|
76
|
-
export {
|
|
77
|
-
|
|
78
|
-
ComposePayloadSchema,
|
|
79
|
-
constructTree,
|
|
80
|
-
} from "everything-dev/ui/manifest";
|
|
74
|
+
export { CORE_UI_PLUGIN_KEY, ComposePayloadSchema } from "everything-dev/ui/manifest";
|
|
75
|
+
export { constructTree } from "everything-dev/ui/compose";
|
|
81
76
|
`,
|
|
82
77
|
"src/globals.gen.ts": `// GENERATED FILE — do not edit. Regenerated from the installed framework version
|
|
83
78
|
// by \`bos dev\` / \`bos build\` / \`bos typecheck\` (gitignored).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stubs.cjs","names":["join","existsSync","readFileSync","dirname"],"sources":["../../../src/build/ui/stubs.ts"],"sourcesContent":["/**\n * The core ui's generated bootstrap stubs — the mechanical files an app must\n * never author or edit (ADR 0023): the web MF entry, the `./Hydrate`\n * bootstrap, the SSR router module, the `./compose` expose, and the ambient\n * globals. Emitted into the ui source root by the framework's code-artifact\n * generation pass, regenerated from the installed package version, and\n * gitignored (`*.gen.*`) — never synced, never hand-maintained.\n *\n * The generated hydrate/SSR stubs wire the app's AUTHORED seams into the\n * framework machinery: the router policy factory (`src/router.tsx`) and the\n * app override exports from `src/app.ts` (`apiConnectionError`, `appLocale`).\n * The seam files are scaffolded once by `bos init` and owned by the app; the\n * stubs themselves carry zero app-specific content.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\nexport const CORE_UI_STUBS: Record<string, string> = {\n \"src/entry.gen.ts\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\nimport \"./styles.css\";\nimport { runEntry } from \"everything-dev/ui/entry\";\n\nrunEntry(() => import(\"./hydrate.gen\"));\n`,\n \"src/hydrate.gen.tsx\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\nimport \"./styles.css\";\nimport { hydrate as coreHydrate } from \"everything-dev/ui/hydrate\";\nimport { apiConnectionError } from \"./app\";\nimport { createQueryClient, createRouter } from \"./router\";\n\nexport function hydrate() {\n return coreHydrate({\n routeConfig: () => import(\"./routeConfig.gen\"),\n manifest: () => import(\"./manifest.gen.json\"),\n createRouter,\n createQueryClient,\n apiConnectionError,\n });\n}\n\nexport default hydrate;\n`,\n \"src/router.server.gen.tsx\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\nimport { createServerRouterModule } from \"everything-dev/ui/router-server\";\nimport { appLocale } from \"./app\";\nimport { createQueryClient, createRouter } from \"./router\";\nimport { routeTree } from \"./routeTree.gen\";\n\nconst routerModule = createServerRouterModule({\n defaultRouteTree: routeTree,\n createRouter,\n createQueryClient,\n locale: appLocale,\n});\n\nexport default routerModule;\n`,\n \"src/compose.gen.ts\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\nexport type {\n ConstructedTree,\n ConstructInput,\n ConstructPluginRef,\n
|
|
1
|
+
{"version":3,"file":"stubs.cjs","names":["join","existsSync","readFileSync","dirname"],"sources":["../../../src/build/ui/stubs.ts"],"sourcesContent":["/**\n * The core ui's generated bootstrap stubs — the mechanical files an app must\n * never author or edit (ADR 0023): the web MF entry, the `./Hydrate`\n * bootstrap, the SSR router module, the `./compose` expose, and the ambient\n * globals. Emitted into the ui source root by the framework's code-artifact\n * generation pass, regenerated from the installed package version, and\n * gitignored (`*.gen.*`) — never synced, never hand-maintained.\n *\n * The generated hydrate/SSR stubs wire the app's AUTHORED seams into the\n * framework machinery: the router policy factory (`src/router.tsx`) and the\n * app override exports from `src/app.ts` (`apiConnectionError`, `appLocale`).\n * The seam files are scaffolded once by `bos init` and owned by the app; the\n * stubs themselves carry zero app-specific content.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\nexport const CORE_UI_STUBS: Record<string, string> = {\n \"src/entry.gen.ts\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\nimport \"./styles.css\";\nimport { runEntry } from \"everything-dev/ui/entry\";\n\nrunEntry(() => import(\"./hydrate.gen\"));\n`,\n \"src/hydrate.gen.tsx\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\nimport \"./styles.css\";\nimport { hydrate as coreHydrate } from \"everything-dev/ui/hydrate\";\nimport { apiConnectionError } from \"./app\";\nimport { createQueryClient, createRouter } from \"./router\";\n\nexport function hydrate() {\n return coreHydrate({\n routeConfig: () => import(\"./routeConfig.gen\"),\n manifest: () => import(\"./manifest.gen.json\"),\n createRouter,\n createQueryClient,\n apiConnectionError,\n });\n}\n\nexport default hydrate;\n`,\n \"src/router.server.gen.tsx\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\nimport { createServerRouterModule } from \"everything-dev/ui/router-server\";\nimport { appLocale } from \"./app\";\nimport { createQueryClient, createRouter } from \"./router\";\nimport { routeTree } from \"./routeTree.gen\";\n\nconst routerModule = createServerRouterModule({\n defaultRouteTree: routeTree,\n createRouter,\n createQueryClient,\n locale: appLocale,\n});\n\nexport default routerModule;\n`,\n \"src/compose.gen.ts\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\nexport type {\n ConstructedTree,\n ConstructInput,\n ConstructPluginRef,\n NavManifest,\n PluginManifest,\n ResolvedPlugin,\n RouteConfigModule,\n RouteOptionsBundle,\n} from \"everything-dev/ui/manifest\";\nexport { CORE_UI_PLUGIN_KEY, ComposePayloadSchema } from \"everything-dev/ui/manifest\";\nexport { constructTree } from \"everything-dev/ui/compose\";\n`,\n \"src/globals.gen.ts\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\n/// <reference types=\"@rsbuild/core/types\" />\n`,\n};\n\n/**\n * Emits the stub set into the ui source root. Returns the stub paths whose\n * content actually changed (empty when everything is already current) — the\n * same-content suppression keeps dev watchers from regen loops.\n */\nexport function emitCoreUiStubs(uiRoot: string): string[] {\n const written: string[] = [];\n for (const [relPath, content] of Object.entries(CORE_UI_STUBS)) {\n const fullPath = join(uiRoot, relPath);\n if (existsSync(fullPath) && readFileSync(fullPath, \"utf-8\") === content) continue;\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, content);\n written.push(relPath);\n }\n return written;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAa,gBAAwC;CACnD,oBAAoB;;;;;;;CAOpB,uBAAuB;;;;;;;;;;;;;;;;;;;CAmBvB,6BAA6B;;;;;;;;;;;;;;;;CAgB7B,sBAAsB;;;;;;;;;;;;;;;CAetB,sBAAsB;;;;AAIxB;;;;;;AAOA,SAAgB,gBAAgB,QAA0B;CACxD,MAAM,UAAoB,CAAC;CAC3B,KAAK,MAAM,CAAC,SAAS,YAAY,OAAO,QAAQ,aAAa,GAAG;EAC9D,MAAM,eAAWA,gBAAK,QAAQ,OAAO;EACrC,QAAIC,oBAAW,QAAQ,SAAKC,sBAAa,UAAU,OAAO,MAAM,SAAS;EACzE,2BAAUC,mBAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;EAChD,2BAAc,UAAU,OAAO;EAC/B,QAAQ,KAAK,OAAO;CACtB;CACA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stubs.d.cts","names":[],"sources":["../../../src/build/ui/stubs.ts"],"mappings":";;;;;;;;;;;;;;;cAkBa,eAAe;;;;;;
|
|
1
|
+
{"version":3,"file":"stubs.d.cts","names":[],"sources":["../../../src/build/ui/stubs.ts"],"mappings":";;;;;;;;;;;;;;;cAkBa,eAAe;;;;;;iBAqEZ,gBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stubs.d.mts","names":[],"sources":["../../../src/build/ui/stubs.ts"],"mappings":";;;;;;;;;;;;;;;cAkBa,eAAe;;;;;;
|
|
1
|
+
{"version":3,"file":"stubs.d.mts","names":[],"sources":["../../../src/build/ui/stubs.ts"],"mappings":";;;;;;;;;;;;;;;cAkBa,eAAe;;;;;;iBAqEZ,gBAAgB"}
|
package/dist/build/ui/stubs.mjs
CHANGED
|
@@ -65,19 +65,14 @@ export type {
|
|
|
65
65
|
ConstructedTree,
|
|
66
66
|
ConstructInput,
|
|
67
67
|
ConstructPluginRef,
|
|
68
|
-
GateUser,
|
|
69
|
-
HostContext,
|
|
70
68
|
NavManifest,
|
|
71
69
|
PluginManifest,
|
|
72
70
|
ResolvedPlugin,
|
|
73
71
|
RouteConfigModule,
|
|
74
72
|
RouteOptionsBundle,
|
|
75
73
|
} from "everything-dev/ui/manifest";
|
|
76
|
-
export {
|
|
77
|
-
|
|
78
|
-
ComposePayloadSchema,
|
|
79
|
-
constructTree,
|
|
80
|
-
} from "everything-dev/ui/manifest";
|
|
74
|
+
export { CORE_UI_PLUGIN_KEY, ComposePayloadSchema } from "everything-dev/ui/manifest";
|
|
75
|
+
export { constructTree } from "everything-dev/ui/compose";
|
|
81
76
|
`,
|
|
82
77
|
"src/globals.gen.ts": `// GENERATED FILE — do not edit. Regenerated from the installed framework version
|
|
83
78
|
// by \`bos dev\` / \`bos build\` / \`bos typecheck\` (gitignored).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stubs.mjs","names":[],"sources":["../../../src/build/ui/stubs.ts"],"sourcesContent":["/**\n * The core ui's generated bootstrap stubs — the mechanical files an app must\n * never author or edit (ADR 0023): the web MF entry, the `./Hydrate`\n * bootstrap, the SSR router module, the `./compose` expose, and the ambient\n * globals. Emitted into the ui source root by the framework's code-artifact\n * generation pass, regenerated from the installed package version, and\n * gitignored (`*.gen.*`) — never synced, never hand-maintained.\n *\n * The generated hydrate/SSR stubs wire the app's AUTHORED seams into the\n * framework machinery: the router policy factory (`src/router.tsx`) and the\n * app override exports from `src/app.ts` (`apiConnectionError`, `appLocale`).\n * The seam files are scaffolded once by `bos init` and owned by the app; the\n * stubs themselves carry zero app-specific content.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\nexport const CORE_UI_STUBS: Record<string, string> = {\n \"src/entry.gen.ts\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\nimport \"./styles.css\";\nimport { runEntry } from \"everything-dev/ui/entry\";\n\nrunEntry(() => import(\"./hydrate.gen\"));\n`,\n \"src/hydrate.gen.tsx\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\nimport \"./styles.css\";\nimport { hydrate as coreHydrate } from \"everything-dev/ui/hydrate\";\nimport { apiConnectionError } from \"./app\";\nimport { createQueryClient, createRouter } from \"./router\";\n\nexport function hydrate() {\n return coreHydrate({\n routeConfig: () => import(\"./routeConfig.gen\"),\n manifest: () => import(\"./manifest.gen.json\"),\n createRouter,\n createQueryClient,\n apiConnectionError,\n });\n}\n\nexport default hydrate;\n`,\n \"src/router.server.gen.tsx\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\nimport { createServerRouterModule } from \"everything-dev/ui/router-server\";\nimport { appLocale } from \"./app\";\nimport { createQueryClient, createRouter } from \"./router\";\nimport { routeTree } from \"./routeTree.gen\";\n\nconst routerModule = createServerRouterModule({\n defaultRouteTree: routeTree,\n createRouter,\n createQueryClient,\n locale: appLocale,\n});\n\nexport default routerModule;\n`,\n \"src/compose.gen.ts\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\nexport type {\n ConstructedTree,\n ConstructInput,\n ConstructPluginRef,\n
|
|
1
|
+
{"version":3,"file":"stubs.mjs","names":[],"sources":["../../../src/build/ui/stubs.ts"],"sourcesContent":["/**\n * The core ui's generated bootstrap stubs — the mechanical files an app must\n * never author or edit (ADR 0023): the web MF entry, the `./Hydrate`\n * bootstrap, the SSR router module, the `./compose` expose, and the ambient\n * globals. Emitted into the ui source root by the framework's code-artifact\n * generation pass, regenerated from the installed package version, and\n * gitignored (`*.gen.*`) — never synced, never hand-maintained.\n *\n * The generated hydrate/SSR stubs wire the app's AUTHORED seams into the\n * framework machinery: the router policy factory (`src/router.tsx`) and the\n * app override exports from `src/app.ts` (`apiConnectionError`, `appLocale`).\n * The seam files are scaffolded once by `bos init` and owned by the app; the\n * stubs themselves carry zero app-specific content.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\nexport const CORE_UI_STUBS: Record<string, string> = {\n \"src/entry.gen.ts\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\nimport \"./styles.css\";\nimport { runEntry } from \"everything-dev/ui/entry\";\n\nrunEntry(() => import(\"./hydrate.gen\"));\n`,\n \"src/hydrate.gen.tsx\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\nimport \"./styles.css\";\nimport { hydrate as coreHydrate } from \"everything-dev/ui/hydrate\";\nimport { apiConnectionError } from \"./app\";\nimport { createQueryClient, createRouter } from \"./router\";\n\nexport function hydrate() {\n return coreHydrate({\n routeConfig: () => import(\"./routeConfig.gen\"),\n manifest: () => import(\"./manifest.gen.json\"),\n createRouter,\n createQueryClient,\n apiConnectionError,\n });\n}\n\nexport default hydrate;\n`,\n \"src/router.server.gen.tsx\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\nimport { createServerRouterModule } from \"everything-dev/ui/router-server\";\nimport { appLocale } from \"./app\";\nimport { createQueryClient, createRouter } from \"./router\";\nimport { routeTree } from \"./routeTree.gen\";\n\nconst routerModule = createServerRouterModule({\n defaultRouteTree: routeTree,\n createRouter,\n createQueryClient,\n locale: appLocale,\n});\n\nexport default routerModule;\n`,\n \"src/compose.gen.ts\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\nexport type {\n ConstructedTree,\n ConstructInput,\n ConstructPluginRef,\n NavManifest,\n PluginManifest,\n ResolvedPlugin,\n RouteConfigModule,\n RouteOptionsBundle,\n} from \"everything-dev/ui/manifest\";\nexport { CORE_UI_PLUGIN_KEY, ComposePayloadSchema } from \"everything-dev/ui/manifest\";\nexport { constructTree } from \"everything-dev/ui/compose\";\n`,\n \"src/globals.gen.ts\": `// GENERATED FILE — do not edit. Regenerated from the installed framework version\n// by \\`bos dev\\` / \\`bos build\\` / \\`bos typecheck\\` (gitignored).\n/// <reference types=\"@rsbuild/core/types\" />\n`,\n};\n\n/**\n * Emits the stub set into the ui source root. Returns the stub paths whose\n * content actually changed (empty when everything is already current) — the\n * same-content suppression keeps dev watchers from regen loops.\n */\nexport function emitCoreUiStubs(uiRoot: string): string[] {\n const written: string[] = [];\n for (const [relPath, content] of Object.entries(CORE_UI_STUBS)) {\n const fullPath = join(uiRoot, relPath);\n if (existsSync(fullPath) && readFileSync(fullPath, \"utf-8\") === content) continue;\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, content);\n written.push(relPath);\n }\n return written;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAa,gBAAwC;CACnD,oBAAoB;;;;;;;CAOpB,uBAAuB;;;;;;;;;;;;;;;;;;;CAmBvB,6BAA6B;;;;;;;;;;;;;;;;CAgB7B,sBAAsB;;;;;;;;;;;;;;;CAetB,sBAAsB;;;;AAIxB;;;;;;AAOA,SAAgB,gBAAgB,QAA0B;CACxD,MAAM,UAAoB,CAAC;CAC3B,KAAK,MAAM,CAAC,SAAS,YAAY,OAAO,QAAQ,aAAa,GAAG;EAC9D,MAAM,WAAW,KAAK,QAAQ,OAAO;EACrC,IAAI,WAAW,QAAQ,KAAK,aAAa,UAAU,OAAO,MAAM,SAAS;EACzE,UAAU,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;EAChD,cAAc,UAAU,OAAO;EAC/B,QAAQ,KAAK,OAAO;CACtB;CACA,OAAO;AACT"}
|
package/dist/cli.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_contract_types = require(
|
|
3
|
-
const require_generated_config = require(
|
|
4
|
-
const require_generated_config$1 = require(
|
|
2
|
+
const require_contract_types = require("./build/contract-types.cjs");
|
|
3
|
+
const require_generated_config = require("./build/ui/generated-config.cjs");
|
|
4
|
+
const require_generated_config$1 = require("./build/rspack/generated-config.cjs");
|
|
5
5
|
let node_child_process = require("node:child_process");
|
|
6
6
|
|
|
7
7
|
//#region src/cli.ts
|
package/dist/client.cjs
CHANGED
|
@@ -16,6 +16,13 @@ async function fetchWithRateLimitRetry(fetchUrl, options) {
|
|
|
16
16
|
}
|
|
17
17
|
return response;
|
|
18
18
|
}
|
|
19
|
+
function mergeHeaders(base, overrides) {
|
|
20
|
+
const merged = new Headers(base);
|
|
21
|
+
new Headers(overrides).forEach((value, key) => {
|
|
22
|
+
merged.set(key, value);
|
|
23
|
+
});
|
|
24
|
+
return merged;
|
|
25
|
+
}
|
|
19
26
|
function createRpcLink(config, headers) {
|
|
20
27
|
return new _orpc_client_fetch.RPCLink({
|
|
21
28
|
origin: config.hostUrl,
|
|
@@ -40,10 +47,7 @@ function createRpcLink(config, headers) {
|
|
|
40
47
|
return fetchWithRateLimitRetry(fetchUrl, {
|
|
41
48
|
...options,
|
|
42
49
|
credentials: "include",
|
|
43
|
-
headers: headers ?
|
|
44
|
-
...Object.fromEntries(headers),
|
|
45
|
-
...options?.headers
|
|
46
|
-
} : options?.headers
|
|
50
|
+
headers: headers ? mergeHeaders(headers, options?.headers) : options?.headers
|
|
47
51
|
});
|
|
48
52
|
}
|
|
49
53
|
});
|
package/dist/client.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.cjs","names":["RPCLink","onError","createORPCClient"],"sources":["../src/client.ts"],"sourcesContent":["import { createORPCClient, onError } from \"@orpc/client\";\nimport { RPCLink } from \"@orpc/client/fetch\";\nimport type { ContractRouterClient, RouterContract } from \"@orpc/contract\";\n\nexport type RpcConnectionErrorCopy = () => { title: string; description: string };\n\nexport interface RpcClientConfig {\n hostUrl: string;\n path: `/${string}`;\n connectionError?: RpcConnectionErrorCopy;\n}\n\nconst RATE_LIMIT_MAX_RETRIES = 3;\nconst RATE_LIMIT_RETRY_CAP_MS = 2_000;\nconst browserClients = new Map<string, unknown>();\ntype FetchInput = Parameters<typeof fetch>[0];\n\nasync function fetchWithRateLimitRetry(\n fetchUrl: FetchInput,\n options?: RequestInit,\n): Promise<Response> {\n let response = await fetch(fetchUrl, options);\n for (let attempt = 1; attempt <= RATE_LIMIT_MAX_RETRIES && response.status === 429; attempt++) {\n const retryAfterSeconds = Number(response.headers.get(\"retry-after\"));\n const delay =\n Number.isFinite(retryAfterSeconds) && retryAfterSeconds > 0\n ? Math.min(retryAfterSeconds * 1000, RATE_LIMIT_RETRY_CAP_MS)\n : 100 * attempt;\n await new Promise((resolve) => setTimeout(resolve, delay));\n response = await fetch(fetchUrl, options);\n }\n\n return response;\n}\n\nfunction createRpcLink(config: RpcClientConfig, headers?: Headers) {\n return new RPCLink({\n origin: config.hostUrl,\n url: config.path,\n interceptors: [\n onError((error: unknown) => {\n const browserWindow = (globalThis as { window?: unknown }).window;\n if (typeof browserWindow === \"undefined\") {\n return;\n }\n\n if (error && typeof error === \"object\" && \"message\" in error) {\n const message = String(error.message).toLowerCase();\n if (\n message.includes(\"fetch\") ||\n message.includes(\"network\") ||\n message.includes(\"failed to fetch\")\n ) {\n void import(\"sonner\")\n .then(({ toast }) => {\n const message = config.connectionError?.() ?? {\n title: \"Unable to connect to API\",\n description: \"The API is currently unavailable. Please try again later.\",\n };\n toast.error(message.title, {\n id: \"api-connection-error\",\n description: message.description,\n });\n })\n .catch(() => {});\n }\n }\n }),\n ],\n fetch(fetchUrl: FetchInput, options?: RequestInit) {\n return fetchWithRateLimitRetry(fetchUrl, {\n ...options,\n credentials: \"include\",\n headers: headers
|
|
1
|
+
{"version":3,"file":"client.cjs","names":["RPCLink","onError","createORPCClient"],"sources":["../src/client.ts"],"sourcesContent":["import { createORPCClient, onError } from \"@orpc/client\";\nimport { RPCLink } from \"@orpc/client/fetch\";\nimport type { ContractRouterClient, RouterContract } from \"@orpc/contract\";\n\nexport type RpcConnectionErrorCopy = () => { title: string; description: string };\n\nexport interface RpcClientConfig {\n hostUrl: string;\n path: `/${string}`;\n connectionError?: RpcConnectionErrorCopy;\n}\n\nconst RATE_LIMIT_MAX_RETRIES = 3;\nconst RATE_LIMIT_RETRY_CAP_MS = 2_000;\nconst browserClients = new Map<string, unknown>();\ntype FetchInput = Parameters<typeof fetch>[0];\n\nasync function fetchWithRateLimitRetry(\n fetchUrl: FetchInput,\n options?: RequestInit,\n): Promise<Response> {\n let response = await fetch(fetchUrl, options);\n for (let attempt = 1; attempt <= RATE_LIMIT_MAX_RETRIES && response.status === 429; attempt++) {\n const retryAfterSeconds = Number(response.headers.get(\"retry-after\"));\n const delay =\n Number.isFinite(retryAfterSeconds) && retryAfterSeconds > 0\n ? Math.min(retryAfterSeconds * 1000, RATE_LIMIT_RETRY_CAP_MS)\n : 100 * attempt;\n await new Promise((resolve) => setTimeout(resolve, delay));\n response = await fetch(fetchUrl, options);\n }\n\n return response;\n}\n\nfunction mergeHeaders(base: Headers, overrides?: RequestInit[\"headers\"]): Headers {\n const merged = new Headers(base);\n new Headers(overrides).forEach((value, key) => {\n merged.set(key, value);\n });\n return merged;\n}\n\nfunction createRpcLink(config: RpcClientConfig, headers?: Headers) {\n return new RPCLink({\n origin: config.hostUrl,\n url: config.path,\n interceptors: [\n onError((error: unknown) => {\n const browserWindow = (globalThis as { window?: unknown }).window;\n if (typeof browserWindow === \"undefined\") {\n return;\n }\n\n if (error && typeof error === \"object\" && \"message\" in error) {\n const message = String(error.message).toLowerCase();\n if (\n message.includes(\"fetch\") ||\n message.includes(\"network\") ||\n message.includes(\"failed to fetch\")\n ) {\n void import(\"sonner\")\n .then(({ toast }) => {\n const message = config.connectionError?.() ?? {\n title: \"Unable to connect to API\",\n description: \"The API is currently unavailable. Please try again later.\",\n };\n toast.error(message.title, {\n id: \"api-connection-error\",\n description: message.description,\n });\n })\n .catch(() => {});\n }\n }\n }),\n ],\n fetch(fetchUrl: FetchInput, options?: RequestInit) {\n return fetchWithRateLimitRetry(fetchUrl, {\n ...options,\n credentials: \"include\",\n headers: headers ? mergeHeaders(headers, options?.headers) : options?.headers,\n });\n },\n });\n}\n\nfunction buildRpcClient<T extends RouterContract>(\n config: RpcClientConfig,\n headers?: Headers,\n): ContractRouterClient<T> {\n if (!config.hostUrl) {\n throw new Error(\"Missing runtime host URL\");\n }\n\n return createORPCClient(createRpcLink(config, headers)) as ContractRouterClient<T>;\n}\n\nexport function createRpcClient<T extends RouterContract = RouterContract>(\n config: RpcClientConfig,\n headers?: Headers,\n): ContractRouterClient<T> {\n const browserWindow = (globalThis as { window?: unknown }).window;\n if (typeof browserWindow !== \"undefined\" && !headers) {\n const key = `${config.hostUrl}${config.path}`;\n const memoized = browserClients.get(key);\n if (memoized) {\n return memoized as ContractRouterClient<T>;\n }\n\n const client = buildRpcClient<T>(config, headers);\n browserClients.set(key, client);\n return client;\n }\n\n return buildRpcClient<T>(config, headers);\n}\n"],"mappings":";;;;;AAYA,MAAM,yBAAyB;AAC/B,MAAM,0BAA0B;AAChC,MAAM,iCAAiB,IAAI,IAAqB;AAGhD,eAAe,wBACb,UACA,SACmB;CACnB,IAAI,WAAW,MAAM,MAAM,UAAU,OAAO;CAC5C,KAAK,IAAI,UAAU,GAAG,WAAW,0BAA0B,SAAS,WAAW,KAAK,WAAW;EAC7F,MAAM,oBAAoB,OAAO,SAAS,QAAQ,IAAI,aAAa,CAAC;EACpE,MAAM,QACJ,OAAO,SAAS,iBAAiB,KAAK,oBAAoB,IACtD,KAAK,IAAI,oBAAoB,KAAM,uBAAuB,IAC1D,MAAM;EACZ,MAAM,IAAI,SAAS,YAAY,WAAW,SAAS,KAAK,CAAC;EACzD,WAAW,MAAM,MAAM,UAAU,OAAO;CAC1C;CAEA,OAAO;AACT;AAEA,SAAS,aAAa,MAAe,WAA6C;CAChF,MAAM,SAAS,IAAI,QAAQ,IAAI;CAC/B,IAAI,QAAQ,SAAS,CAAC,CAAC,SAAS,OAAO,QAAQ;EAC7C,OAAO,IAAI,KAAK,KAAK;CACvB,CAAC;CACD,OAAO;AACT;AAEA,SAAS,cAAc,QAAyB,SAAmB;CACjE,OAAO,IAAIA,2BAAQ;EACjB,QAAQ,OAAO;EACf,KAAK,OAAO;EACZ,cAAc,KACZC,uBAAS,UAAmB;GAE1B,IAAI,OADmB,WAAoC,WAC9B,aAC3B;GAGF,IAAI,SAAS,OAAO,UAAU,YAAY,aAAa,OAAO;IAC5D,MAAM,UAAU,OAAO,MAAM,OAAO,CAAC,CAAC,YAAY;IAClD,IACE,QAAQ,SAAS,OAAO,KACxB,QAAQ,SAAS,SAAS,KAC1B,QAAQ,SAAS,iBAAiB,GAElC,AAAK,OAAO,SAAS,CAClB,MAAM,EAAE,YAAY;KACnB,MAAM,UAAU,OAAO,kBAAkB,KAAK;MAC5C,OAAO;MACP,aAAa;KACf;KACA,MAAM,MAAM,QAAQ,OAAO;MACzB,IAAI;MACJ,aAAa,QAAQ;KACvB,CAAC;IACH,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;GAErB;EACF,CAAC,CACH;EACA,MAAM,UAAsB,SAAuB;GACjD,OAAO,wBAAwB,UAAU;IACvC,GAAG;IACH,aAAa;IACb,SAAS,UAAU,aAAa,SAAS,SAAS,OAAO,IAAI,SAAS;GACxE,CAAC;EACH;CACF,CAAC;AACH;AAEA,SAAS,eACP,QACA,SACyB;CACzB,IAAI,CAAC,OAAO,SACV,MAAM,IAAI,MAAM,0BAA0B;CAG5C,WAAOC,+BAAiB,cAAc,QAAQ,OAAO,CAAC;AACxD;AAEA,SAAgB,gBACd,QACA,SACyB;CAEzB,IAAI,OADmB,WAAoC,WAC9B,eAAe,CAAC,SAAS;EACpD,MAAM,MAAM,GAAG,OAAO,UAAU,OAAO;EACvC,MAAM,WAAW,eAAe,IAAI,GAAG;EACvC,IAAI,UACF,OAAO;EAGT,MAAM,SAAS,eAAkB,QAAQ,OAAO;EAChD,eAAe,IAAI,KAAK,MAAM;EAC9B,OAAO;CACT;CAEA,OAAO,eAAkB,QAAQ,OAAO;AAC1C"}
|
package/dist/client.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.cts","names":[],"sources":["../src/client.ts"],"mappings":";;KAIY;EAAiC;EAAe;;UAE3C;EACf;EACA;EACA,kBAAkB;;
|
|
1
|
+
{"version":3,"file":"client.d.cts","names":[],"sources":["../src/client.ts"],"mappings":";;KAIY;EAAiC;EAAe;;UAE3C;EACf;EACA;EACA,kBAAkB;;iBAyFJ,gBAAgB,UAAU,iBAAiB,gBACzD,QAAQ,iBACR,UAAU,UACT,qBAAqB"}
|
package/dist/client.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.mts","names":[],"sources":["../src/client.ts"],"mappings":";;KAIY;EAAiC;EAAe;;UAE3C;EACf;EACA;EACA,kBAAkB;;
|
|
1
|
+
{"version":3,"file":"client.d.mts","names":[],"sources":["../src/client.ts"],"mappings":";;KAIY;EAAiC;EAAe;;UAE3C;EACf;EACA;EACA,kBAAkB;;iBAyFJ,gBAAgB,UAAU,iBAAiB,gBACzD,QAAQ,iBACR,UAAU,UACT,qBAAqB"}
|
package/dist/client.mjs
CHANGED
|
@@ -15,6 +15,13 @@ async function fetchWithRateLimitRetry(fetchUrl, options) {
|
|
|
15
15
|
}
|
|
16
16
|
return response;
|
|
17
17
|
}
|
|
18
|
+
function mergeHeaders(base, overrides) {
|
|
19
|
+
const merged = new Headers(base);
|
|
20
|
+
new Headers(overrides).forEach((value, key) => {
|
|
21
|
+
merged.set(key, value);
|
|
22
|
+
});
|
|
23
|
+
return merged;
|
|
24
|
+
}
|
|
18
25
|
function createRpcLink(config, headers) {
|
|
19
26
|
return new RPCLink({
|
|
20
27
|
origin: config.hostUrl,
|
|
@@ -39,10 +46,7 @@ function createRpcLink(config, headers) {
|
|
|
39
46
|
return fetchWithRateLimitRetry(fetchUrl, {
|
|
40
47
|
...options,
|
|
41
48
|
credentials: "include",
|
|
42
|
-
headers: headers ?
|
|
43
|
-
...Object.fromEntries(headers),
|
|
44
|
-
...options?.headers
|
|
45
|
-
} : options?.headers
|
|
49
|
+
headers: headers ? mergeHeaders(headers, options?.headers) : options?.headers
|
|
46
50
|
});
|
|
47
51
|
}
|
|
48
52
|
});
|