@fulgurjs/federation 0.4.2 → 0.5.0
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/CHANGELOG.md +20 -7
- package/DESIGN.md +8 -8
- package/README.md +49 -49
- package/dist/cli.js +43 -43
- package/dist/config.cjs +13 -13
- package/dist/config.d.cts +20 -20
- package/dist/config.d.ts +20 -20
- package/dist/config.js +11 -11
- package/dist/index.cjs +139 -139
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +139 -139
- package/dist/pages.cjs +9 -9
- package/dist/pages.d.cts +7 -7
- package/dist/pages.d.ts +7 -7
- package/dist/pages.js +7 -7
- package/dist/runtime.js +2 -2
- package/docs/manual.html +23 -23
- package/docs/webpack-mf-/345/257/271/347/205/247/344/270/216/347/274/272/345/217/243.md +1 -1
- package/docs//346/262/231/347/256/261/350/276/271/347/225/214/345/256/241/350/256/241.md +1 -1
- package/docs//350/277/201/347/247/273/346/214/207/345/215/227.md +8 -8
- package/examples/fulgur.config.example.ts +4 -4
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -8,25 +8,25 @@ import fs from "fs";
|
|
|
8
8
|
import path from "path";
|
|
9
9
|
|
|
10
10
|
// src/version.ts
|
|
11
|
-
var RUNTIME_VERSION = "0.
|
|
11
|
+
var RUNTIME_VERSION = "0.5.0";
|
|
12
12
|
|
|
13
13
|
// src/options.ts
|
|
14
|
-
var DEFAULT_FILENAME = "
|
|
15
|
-
var RUNTIME_VIRTUAL_ID = "virtual:
|
|
16
|
-
var RUNTIME_PROXY_VIRTUAL_ID = "virtual:
|
|
17
|
-
var INIT_VIRTUAL_ID = "virtual:
|
|
18
|
-
var SHARED_FACADE_PREFIX = "virtual:
|
|
19
|
-
var SHARED_NS_FACADE_PREFIX = "virtual:
|
|
14
|
+
var DEFAULT_FILENAME = "fulgurjs-remoteEntry.js";
|
|
15
|
+
var RUNTIME_VIRTUAL_ID = "virtual:fulgurjs-runtime";
|
|
16
|
+
var RUNTIME_PROXY_VIRTUAL_ID = "virtual:fulgurjs-runtime-proxy";
|
|
17
|
+
var INIT_VIRTUAL_ID = "virtual:fulgurjs-init";
|
|
18
|
+
var SHARED_FACADE_PREFIX = "virtual:fulgurjs-shared:";
|
|
19
|
+
var SHARED_NS_FACADE_PREFIX = "virtual:fulgurjs-shared-ns:";
|
|
20
20
|
var RESOLVED = {
|
|
21
|
-
runtime: "virtual:
|
|
22
|
-
runtimeProxy: "virtual:
|
|
23
|
-
init: "virtual:
|
|
24
|
-
provides: "virtual:
|
|
25
|
-
remoteEntry: "virtual:
|
|
26
|
-
sharedFacade: (name) => `virtual:
|
|
27
|
-
sharedNsFacade: (name) => `virtual:
|
|
21
|
+
runtime: "virtual:fulgurjs-runtime",
|
|
22
|
+
runtimeProxy: "virtual:fulgurjs-runtime-proxy",
|
|
23
|
+
init: "virtual:fulgurjs-init",
|
|
24
|
+
provides: "virtual:fulgurjs-provides",
|
|
25
|
+
remoteEntry: "virtual:fulgurjs-remote-entry",
|
|
26
|
+
sharedFacade: (name) => `virtual:fulgurjs-shared:${name}`,
|
|
27
|
+
sharedNsFacade: (name) => `virtual:fulgurjs-shared-ns:${name}`,
|
|
28
28
|
/** CJS require(<shared>) 垫片:与 sharedNsFacade 同体,仅 id 形态不同(保持 require 调用语义) */
|
|
29
|
-
cjsNsFacade: (name) => `virtual:
|
|
29
|
+
cjsNsFacade: (name) => `virtual:fulgurjs-cjs-ns:${name}`
|
|
30
30
|
};
|
|
31
31
|
function joinUrl(base, file) {
|
|
32
32
|
const b = base.endsWith("/") ? base : `${base}/`;
|
|
@@ -64,7 +64,7 @@ function normalizeRemoteValue(key, value, filename, warnings) {
|
|
|
64
64
|
if (mode === "prod") return rawUrl;
|
|
65
65
|
return rawUrl;
|
|
66
66
|
}
|
|
67
|
-
return joinUrl(rawUrl, mode === "dev" ? "@
|
|
67
|
+
return joinUrl(rawUrl, mode === "dev" ? "@fulgurjs-entry.js" : filename);
|
|
68
68
|
};
|
|
69
69
|
const explicitDev = cfg.dev;
|
|
70
70
|
const explicitProd = cfg.prod;
|
|
@@ -195,7 +195,7 @@ function configError(what, got, expect, example) {
|
|
|
195
195
|
const gotText = typeof got === "string" ? `"${got}"` : JSON.stringify(got);
|
|
196
196
|
throw new Error(
|
|
197
197
|
[
|
|
198
|
-
`[
|
|
198
|
+
`[fulgurjs] Invalid federation() config \u2014 ${what}`,
|
|
199
199
|
` got: ${gotText}`,
|
|
200
200
|
` expected: ${expect}`,
|
|
201
201
|
` example: ${example}`
|
|
@@ -287,7 +287,7 @@ function validateOptions(options) {
|
|
|
287
287
|
function normalizeOptions(options, root, command) {
|
|
288
288
|
const warnings = [];
|
|
289
289
|
validateOptions(options);
|
|
290
|
-
if (!options.name) throw new Error("[
|
|
290
|
+
if (!options.name) throw new Error("[fulgurjs] option `name` is required.");
|
|
291
291
|
if (options.remoteType && options.remoteType !== "module") {
|
|
292
292
|
warnings.push(
|
|
293
293
|
`remoteType "${options.remoteType}" requires webpack-host interop (P3 milestone); falling back to "module".`
|
|
@@ -300,7 +300,7 @@ function normalizeOptions(options, root, command) {
|
|
|
300
300
|
}
|
|
301
301
|
if (options.automaticAsyncBoundary === false) {
|
|
302
302
|
warnings.push(
|
|
303
|
-
"automaticAsyncBoundary=false has no effect:
|
|
303
|
+
"automaticAsyncBoundary=false has no effect: fulgurjs uses TLA-based automatic async boundaries (better than webpack manual bootstrap)."
|
|
304
304
|
);
|
|
305
305
|
}
|
|
306
306
|
const exposes = [];
|
|
@@ -407,7 +407,7 @@ function serializeShareCallForFacade(item, fallbackUrl) {
|
|
|
407
407
|
const facadeUrl = fallbackUrl ?? SHARED_FACADE_PREFIX + item.shareKey;
|
|
408
408
|
opts.push(`fallback: () => import(${JSON.stringify(facadeUrl)})`);
|
|
409
409
|
}
|
|
410
|
-
return `
|
|
410
|
+
return `__fulgurjs_loadShare(${JSON.stringify(item.shareKey)}, { ${opts.join(", ")} })`;
|
|
411
411
|
}
|
|
412
412
|
function serializeShareCall(item, devUrls) {
|
|
413
413
|
const opts = [];
|
|
@@ -420,7 +420,7 @@ function serializeShareCall(item, devUrls) {
|
|
|
420
420
|
const facadeUrl = devUrls ? devUrls.namespaceFacade(item.shareKey) : SHARED_FACADE_PREFIX + item.shareKey;
|
|
421
421
|
opts.push(`fallback: () => import(${JSON.stringify(facadeUrl)})`);
|
|
422
422
|
}
|
|
423
|
-
return `
|
|
423
|
+
return `__fulgurjs_loadShare(${JSON.stringify(item.shareKey)}, { ${opts.join(", ")} })`;
|
|
424
424
|
}
|
|
425
425
|
function stripComments(s) {
|
|
426
426
|
return s.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\n]*/g, "");
|
|
@@ -511,7 +511,7 @@ async function transformModule(code, id, ctx) {
|
|
|
511
511
|
for (const [alias, item] of sharedByAlias) {
|
|
512
512
|
const re = new RegExp(`require\\((["'])${alias.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\1\\)`, "g");
|
|
513
513
|
if (!re.test(code)) continue;
|
|
514
|
-
code = code.replace(re, `require(${JSON.stringify(`virtual:
|
|
514
|
+
code = code.replace(re, `require(${JSON.stringify(`virtual:fulgurjs-cjs-ns:${item.shareKey}`)})`);
|
|
515
515
|
cjsEdited = true;
|
|
516
516
|
}
|
|
517
517
|
if (!cjsEdited) return null;
|
|
@@ -532,7 +532,7 @@ async function transformModule(code, id, ctx) {
|
|
|
532
532
|
let usesRuntimeHelpers = false;
|
|
533
533
|
const tlaLines = [];
|
|
534
534
|
let tempIdx = 0;
|
|
535
|
-
const genTemp = () => `
|
|
535
|
+
const genTemp = () => `__fulgurjs_m${tempIdx++}`;
|
|
536
536
|
const remap = (spec) => ctx.remapSpecifier?.(spec) ?? spec;
|
|
537
537
|
const remoteExposeName = (spec, remoteKey) => {
|
|
538
538
|
if (!spec.startsWith(`${remoteKey}/`)) return null;
|
|
@@ -546,7 +546,7 @@ async function transformModule(code, id, ctx) {
|
|
|
546
546
|
];
|
|
547
547
|
const genTlaOverwrite = (stmtStart, stmtEnd, shared, remoteName, exposeName, clauseRaw, clause) => {
|
|
548
548
|
usesRuntimeHelpers = true;
|
|
549
|
-
const call = shared ? serializeShareCall(shared, ctx?.devUrls) : `
|
|
549
|
+
const call = shared ? serializeShareCall(shared, ctx?.devUrls) : `__fulgurjs_loadRemote(${JSON.stringify(`${remoteName}/${exposeName}`)})`;
|
|
550
550
|
const nsAs = clauseRaw.match(/export\s+\*\s+as\s+(\w+)\s+from/);
|
|
551
551
|
if (nsAs) {
|
|
552
552
|
s.overwrite(stmtStart, stmtEnd, `const ${nsAs[1]} = await ${call};
|
|
@@ -560,14 +560,14 @@ export { ${nsAs[1]} };`);
|
|
|
560
560
|
const tmp = genTemp();
|
|
561
561
|
const parts = [`${tmp} = await ${call}`];
|
|
562
562
|
if (clause.ns) parts.push(`${clause.ns} = ${tmp}`);
|
|
563
|
-
if (clause.defaultLocal) parts.push(`${clause.defaultLocal} =
|
|
563
|
+
if (clause.defaultLocal) parts.push(`${clause.defaultLocal} = __fulgurjsU(${tmp})`);
|
|
564
564
|
const named = clause.bindings?.filter((b) => !b.isDefault) ?? [];
|
|
565
565
|
if (named.length) {
|
|
566
566
|
const destructure = named.map((b) => b.imported === b.local ? b.local : `${b.imported}: ${b.local}`);
|
|
567
567
|
parts.push(`{ ${destructure.join(", ")} } = ${tmp}`);
|
|
568
568
|
}
|
|
569
569
|
for (const b of clause.bindings?.filter((x) => x.isDefault) ?? []) {
|
|
570
|
-
parts.push(`${b.local} =
|
|
570
|
+
parts.push(`${b.local} = __fulgurjsU(${tmp})`);
|
|
571
571
|
}
|
|
572
572
|
s.overwrite(stmtStart, stmtEnd, `const ${parts.join(", ")}`);
|
|
573
573
|
};
|
|
@@ -599,7 +599,7 @@ export { ${nsAs[1]} };`);
|
|
|
599
599
|
const inner = clauseRaw.slice(clauseRaw.indexOf("{") + 1, clauseRaw.lastIndexOf("}"));
|
|
600
600
|
if (/export\s+\*/.test(clauseRaw) && !clauseRaw.includes("{")) {
|
|
601
601
|
throw new Error(
|
|
602
|
-
`[
|
|
602
|
+
`[fulgurjs] "export * from '${spec2}'" on a shared module is not supported (ESM cannot create dynamic export bindings). Use named re-exports: "export { a, b } from '${spec2}'".`
|
|
603
603
|
);
|
|
604
604
|
}
|
|
605
605
|
const bindings = parseBindings(inner).map((b) => b.imported === "default" ? "default" : b.imported);
|
|
@@ -630,15 +630,15 @@ export { ${nsAs[1]} };`);
|
|
|
630
630
|
s.overwrite(
|
|
631
631
|
callStart,
|
|
632
632
|
closeParen + 1,
|
|
633
|
-
`
|
|
633
|
+
`__fulgurjs_loadRemote(${JSON.stringify(`${remote.name}/${exposeName}`)})`
|
|
634
634
|
);
|
|
635
635
|
}
|
|
636
636
|
}
|
|
637
637
|
if (!edited) return null;
|
|
638
638
|
if (usesRuntimeHelpers) {
|
|
639
|
-
const runtimeSpec = JSON.stringify(ctx.devUrls?.runtime ?? "virtual:
|
|
639
|
+
const runtimeSpec = JSON.stringify(ctx.devUrls?.runtime ?? "virtual:fulgurjs-runtime");
|
|
640
640
|
s.prepend(
|
|
641
|
-
`import { loadShare as
|
|
641
|
+
`import { loadShare as __fulgurjs_loadShare, loadRemote as __fulgurjs_loadRemote, unwrapDefault as __fulgurjsU } from ${runtimeSpec};
|
|
642
642
|
`
|
|
643
643
|
);
|
|
644
644
|
}
|
|
@@ -655,39 +655,39 @@ function genSharedFacade(specifier, exportNames) {
|
|
|
655
655
|
);
|
|
656
656
|
if (names.length === 0) {
|
|
657
657
|
return [
|
|
658
|
-
`import * as
|
|
658
|
+
`import * as __fulgurjs_facade from ${JSON.stringify(specifier)};`,
|
|
659
659
|
`export * from ${JSON.stringify(specifier)};`,
|
|
660
|
-
`export default
|
|
660
|
+
`export default __fulgurjs_facade.default ?? __fulgurjs_facade;`,
|
|
661
661
|
""
|
|
662
662
|
].join("\n");
|
|
663
663
|
}
|
|
664
664
|
return [
|
|
665
|
-
`import * as
|
|
666
|
-
...names.map((n) => `export const ${n} =
|
|
667
|
-
`export default
|
|
665
|
+
`import * as __fulgurjs_facade from ${JSON.stringify(specifier)};`,
|
|
666
|
+
...names.map((n) => `export const ${n} = __fulgurjs_facade[${JSON.stringify(n)}];`),
|
|
667
|
+
`export default __fulgurjs_facade.default ?? __fulgurjs_facade;`,
|
|
668
668
|
""
|
|
669
669
|
].join("\n");
|
|
670
670
|
}
|
|
671
671
|
function genSharedNsFacade(item, loadShareCall, exportNames) {
|
|
672
672
|
const lines = [
|
|
673
|
-
`import { loadShare as
|
|
674
|
-
`const
|
|
675
|
-
`const
|
|
676
|
-
`export default
|
|
673
|
+
`import { loadShare as __fulgurjs_loadShare, unwrapDefault as __fulgurjsU } from "virtual:fulgurjs-runtime";`,
|
|
674
|
+
`const __fulgurjs_m = await ${loadShareCall};`,
|
|
675
|
+
`const __fulgurjs_d = __fulgurjsU(__fulgurjs_m);`,
|
|
676
|
+
`export default __fulgurjs_d;`
|
|
677
677
|
];
|
|
678
678
|
const seen = /* @__PURE__ */ new Set(["default"]);
|
|
679
679
|
for (const name of exportNames) {
|
|
680
680
|
if (seen.has(name) || !/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name)) continue;
|
|
681
681
|
seen.add(name);
|
|
682
|
-
lines.push(`export const ${name} =
|
|
682
|
+
lines.push(`export const ${name} = __fulgurjs_d[${JSON.stringify(name)}];`);
|
|
683
683
|
}
|
|
684
684
|
lines.push("");
|
|
685
685
|
return lines.join("\n");
|
|
686
686
|
}
|
|
687
687
|
function genBindingFacade(item, bindings, loadShareCall) {
|
|
688
688
|
const lines = [
|
|
689
|
-
`import { loadShare as
|
|
690
|
-
`const
|
|
689
|
+
`import { loadShare as __fulgurjs_loadShare, unwrapDefault as __fulgurjsU } from "virtual:fulgurjs-runtime";`,
|
|
690
|
+
`const __fulgurjs_m = await ${loadShareCall};`
|
|
691
691
|
];
|
|
692
692
|
const seen = /* @__PURE__ */ new Set();
|
|
693
693
|
for (const bRaw of bindings) {
|
|
@@ -696,16 +696,16 @@ function genBindingFacade(item, bindings, loadShareCall) {
|
|
|
696
696
|
const imported = (asMatch ? asMatch[1] : bRaw).trim();
|
|
697
697
|
if (seen.has(imported)) continue;
|
|
698
698
|
seen.add(imported);
|
|
699
|
-
lines.push(`export const ${imported} =
|
|
699
|
+
lines.push(`export const ${imported} = __fulgurjs_m.${imported};`);
|
|
700
700
|
}
|
|
701
|
-
lines.push(`export default
|
|
701
|
+
lines.push(`export default __fulgurjsU(__fulgurjs_m);`);
|
|
702
702
|
lines.push("");
|
|
703
703
|
return lines.join("\n");
|
|
704
704
|
}
|
|
705
705
|
function genRemoteBindingFacade(remoteSpec, bindings) {
|
|
706
706
|
const lines = [
|
|
707
|
-
`import { loadRemote as
|
|
708
|
-
`const
|
|
707
|
+
`import { loadRemote as __fulgurjs_loadRemote, unwrapDefault as __fulgurjsU } from "virtual:fulgurjs-runtime";`,
|
|
708
|
+
`const __fulgurjs_m = await __fulgurjs_loadRemote(${JSON.stringify(remoteSpec)});`
|
|
709
709
|
];
|
|
710
710
|
const seen = /* @__PURE__ */ new Set();
|
|
711
711
|
for (const bRaw of bindings) {
|
|
@@ -714,9 +714,9 @@ function genRemoteBindingFacade(remoteSpec, bindings) {
|
|
|
714
714
|
const imported = (asMatch ? asMatch[1] : bRaw).trim();
|
|
715
715
|
if (seen.has(imported)) continue;
|
|
716
716
|
seen.add(imported);
|
|
717
|
-
lines.push(`export const ${imported} =
|
|
717
|
+
lines.push(`export const ${imported} = __fulgurjs_m.${imported};`);
|
|
718
718
|
}
|
|
719
|
-
lines.push(`export default
|
|
719
|
+
lines.push(`export default __fulgurjsU(__fulgurjs_m);`);
|
|
720
720
|
lines.push("");
|
|
721
721
|
return lines.join("\n");
|
|
722
722
|
}
|
|
@@ -731,21 +731,21 @@ function providesRecords(options) {
|
|
|
731
731
|
}
|
|
732
732
|
function genInitModule(options, command) {
|
|
733
733
|
const lines = [];
|
|
734
|
-
lines.push(`import { initSharing, registerShare, registerRemotes, registerPlugins } from "virtual:
|
|
734
|
+
lines.push(`import { initSharing, registerShare, registerRemotes, registerPlugins } from "virtual:fulgurjs-runtime";`);
|
|
735
735
|
const provides = providesRecords(options);
|
|
736
736
|
const eagerShared = options.shared.filter((s) => s.eager && s.import !== false);
|
|
737
737
|
eagerShared.forEach((s, i) => {
|
|
738
|
-
lines.push(`import * as
|
|
738
|
+
lines.push(`import * as __fulgurjs_eager_${i} from "virtual:fulgurjs-shared:${s.shareKey}";`);
|
|
739
739
|
});
|
|
740
740
|
const isDevHost = command === "serve" && options.remotes.length > 0;
|
|
741
741
|
const loadedFlag = isDevHost ? "true" : "false";
|
|
742
742
|
lines.push(`initSharing(${JSON.stringify(options.shareScope)});`);
|
|
743
743
|
if (options.runtimePlugins.length > 0) {
|
|
744
744
|
options.runtimePlugins.forEach((p, i) => {
|
|
745
|
-
lines.push(`import * as
|
|
745
|
+
lines.push(`import * as __fulgurjs_rp_${i} from ${JSON.stringify(p)};`);
|
|
746
746
|
});
|
|
747
747
|
lines.push(
|
|
748
|
-
`registerPlugins([${options.runtimePlugins.map((_, i) => `(
|
|
748
|
+
`registerPlugins([${options.runtimePlugins.map((_, i) => `(__fulgurjs_rp_${i}.default ?? __fulgurjs_rp_${i})`).join(", ")}]);`
|
|
749
749
|
);
|
|
750
750
|
}
|
|
751
751
|
if (options.remotes.length > 0) {
|
|
@@ -755,11 +755,11 @@ function genInitModule(options, command) {
|
|
|
755
755
|
const eagerIdx = eagerShared.findIndex((s) => s.shareKey === p.name && s.shareScope === p.shareScope);
|
|
756
756
|
if (p.eager && eagerIdx !== -1) {
|
|
757
757
|
lines.push(
|
|
758
|
-
`registerShare(${JSON.stringify(p.shareScope)}, ${JSON.stringify(p.name)}, ${JSON.stringify(p.version)}, () => Promise.resolve(
|
|
758
|
+
`registerShare(${JSON.stringify(p.shareScope)}, ${JSON.stringify(p.name)}, ${JSON.stringify(p.version)}, () => Promise.resolve(__fulgurjs_eager_${eagerIdx}), { from: ${JSON.stringify(p.from)}, eager: true, loaded: ${loadedFlag} });`
|
|
759
759
|
);
|
|
760
760
|
} else {
|
|
761
761
|
lines.push(
|
|
762
|
-
`registerShare(${JSON.stringify(p.shareScope)}, ${JSON.stringify(p.name)}, ${JSON.stringify(p.version)}, () => import("virtual:
|
|
762
|
+
`registerShare(${JSON.stringify(p.shareScope)}, ${JSON.stringify(p.name)}, ${JSON.stringify(p.version)}, () => import("virtual:fulgurjs-shared:${p.name}"), { from: ${JSON.stringify(p.from)}, eager: false, loaded: ${loadedFlag} });`
|
|
763
763
|
);
|
|
764
764
|
}
|
|
765
765
|
});
|
|
@@ -771,10 +771,10 @@ function manifestUrlFor(r, command) {
|
|
|
771
771
|
if (!entry) return null;
|
|
772
772
|
try {
|
|
773
773
|
const u = new URL(entry);
|
|
774
|
-
if (u.pathname.includes("@
|
|
775
|
-
u.pathname = u.pathname.replace("@
|
|
774
|
+
if (u.pathname.includes("@fulgurjs-entry.js")) {
|
|
775
|
+
u.pathname = u.pathname.replace("@fulgurjs-entry.js", "@fulgurjs-manifest.json");
|
|
776
776
|
} else {
|
|
777
|
-
u.pathname = u.pathname.replace(/[^/]*$/, "") + "
|
|
777
|
+
u.pathname = u.pathname.replace(/[^/]*$/, "") + "fulgurjs-manifest.json";
|
|
778
778
|
}
|
|
779
779
|
return u.href;
|
|
780
780
|
} catch {
|
|
@@ -812,24 +812,24 @@ function genRuntimeProxyModule() {
|
|
|
812
812
|
"parseSpec"
|
|
813
813
|
];
|
|
814
814
|
const lines = [
|
|
815
|
-
`let
|
|
816
|
-
`const
|
|
817
|
-
`
|
|
818
|
-
` return await
|
|
815
|
+
`let __fulgurjs_mod_p;`,
|
|
816
|
+
`const __fulgurjs_rt = async () => {`,
|
|
817
|
+
` __fulgurjs_mod_p ??= import('virtual:fulgurjs-runtime');`,
|
|
818
|
+
` return await __fulgurjs_mod_p;`,
|
|
819
819
|
`};`,
|
|
820
|
-
...promiseApis.map((m) => `export const ${m} = (...a) =>
|
|
821
|
-
`export const getRuntime = () => (globalThis).
|
|
822
|
-
`export const
|
|
823
|
-
` (globalThis).
|
|
824
|
-
`export const
|
|
820
|
+
...promiseApis.map((m) => `export const ${m} = (...a) => __fulgurjs_rt().then((m2) => m2.${m}(...a));`),
|
|
821
|
+
`export const getRuntime = () => (globalThis).__FULGURJS_RUNTIME__;`,
|
|
822
|
+
`export const getFulgurjsAppConfig = () =>`,
|
|
823
|
+
` (globalThis).__FULGURJS_RUNTIME__?.getFulgurjsAppConfig?.() ?? (globalThis).__FULGURJS_APP_CONFIG__ ?? {};`,
|
|
824
|
+
`export const provideFulgurjsAppConfig = (c) => {`,
|
|
825
825
|
` const g = (globalThis);`,
|
|
826
|
-
` g.
|
|
827
|
-
` g.
|
|
826
|
+
` g.__FULGURJS_APP_CONFIG__ = { ...(g.__FULGURJS_APP_CONFIG__ ?? {}), ...c };`,
|
|
827
|
+
` g.__FULGURJS_RUNTIME__?.provideFulgurjsAppConfig?.(c);`,
|
|
828
828
|
`};`,
|
|
829
829
|
`export const unwrapDefault = (ns) =>`,
|
|
830
830
|
` ns && typeof ns === 'object' && 'default' in ns ? (ns.default !== undefined ? ns.default : ns) : ns;`,
|
|
831
|
-
`export const version = (globalThis).
|
|
832
|
-
`export default { get runtime() { return (globalThis).
|
|
831
|
+
`export const version = (globalThis).__FULGURJS_RUNTIME__?.version;`,
|
|
832
|
+
`export default { get runtime() { return (globalThis).__FULGURJS_RUNTIME__; } };`,
|
|
833
833
|
``
|
|
834
834
|
];
|
|
835
835
|
return lines.join("\n");
|
|
@@ -838,11 +838,11 @@ function genDevRemoteEntry(options, base) {
|
|
|
838
838
|
const b = base.endsWith("/") ? base : `${base}/`;
|
|
839
839
|
const remoteLines = registerRemotesLines(options, "serve");
|
|
840
840
|
return `import ${JSON.stringify(`${b}@vite/client`)};
|
|
841
|
-
import { name as
|
|
842
|
-
${remoteLines.length > 0 ? `import { registerRemotes } from ${JSON.stringify(`${b}@id/virtual:
|
|
841
|
+
import { name as _fulgurjs_name, exposes, provides } from ${JSON.stringify(`${b}@id/__x00__virtual:fulgurjs-provides`)};
|
|
842
|
+
${remoteLines.length > 0 ? `import { registerRemotes } from ${JSON.stringify(`${b}@id/virtual:fulgurjs-runtime`)};
|
|
843
843
|
${remoteLines.join("\n")}` : ""}
|
|
844
844
|
|
|
845
|
-
export const name =
|
|
845
|
+
export const name = _fulgurjs_name;
|
|
846
846
|
|
|
847
847
|
export async function init(shareScopeMap) {
|
|
848
848
|
for (const p of provides) {
|
|
@@ -873,7 +873,7 @@ function genDevProvides(options) {
|
|
|
873
873
|
);
|
|
874
874
|
}
|
|
875
875
|
const provides = providesRecords(options).map(
|
|
876
|
-
(p) => ` { shareScope: ${JSON.stringify(p.shareScope)}, name: ${JSON.stringify(p.name)}, version: ${JSON.stringify(p.version)}, eager: ${p.eager}, get: () => import("virtual:
|
|
876
|
+
(p) => ` { shareScope: ${JSON.stringify(p.shareScope)}, name: ${JSON.stringify(p.name)}, version: ${JSON.stringify(p.version)}, eager: ${p.eager}, get: () => import("virtual:fulgurjs-shared:${p.name}") },`
|
|
877
877
|
);
|
|
878
878
|
return [
|
|
879
879
|
`export const name = ${JSON.stringify(options.name)};`,
|
|
@@ -894,11 +894,11 @@ function genBuildRemoteEntry(options, exposeAbsPaths) {
|
|
|
894
894
|
exposes.push(` ${JSON.stringify(e.name)}: () => import(${JSON.stringify(abs)}),`);
|
|
895
895
|
}
|
|
896
896
|
const provides = providesRecords(options).map(
|
|
897
|
-
(p) => ` { shareScope: ${JSON.stringify(p.shareScope)}, name: ${JSON.stringify(p.name)}, version: ${JSON.stringify(p.version)}, eager: ${p.eager}, get: () => import("virtual:
|
|
897
|
+
(p) => ` { shareScope: ${JSON.stringify(p.shareScope)}, name: ${JSON.stringify(p.name)}, version: ${JSON.stringify(p.version)}, eager: ${p.eager}, get: () => import("virtual:fulgurjs-shared:${p.name}") },`
|
|
898
898
|
);
|
|
899
899
|
const remoteLines = registerRemotesLines(options, "build");
|
|
900
900
|
return [
|
|
901
|
-
...remoteLines.length > 0 ? [`import { registerRemotes } from "virtual:
|
|
901
|
+
...remoteLines.length > 0 ? [`import { registerRemotes } from "virtual:fulgurjs-runtime";`, ...remoteLines] : [],
|
|
902
902
|
`const exposes = {`,
|
|
903
903
|
...exposes,
|
|
904
904
|
`};`,
|
|
@@ -933,16 +933,16 @@ function genDevManifest(options, base) {
|
|
|
933
933
|
return {
|
|
934
934
|
id: options.name,
|
|
935
935
|
name: options.name,
|
|
936
|
-
version: options.pkgDependencies?.["
|
|
936
|
+
version: options.pkgDependencies?.["fulgurjs"] ?? "0.0.0",
|
|
937
937
|
devServer: true,
|
|
938
938
|
base: b,
|
|
939
|
-
entry: `${b}@
|
|
939
|
+
entry: `${b}@fulgurjs-entry.js`,
|
|
940
940
|
/** 本地联调时供宿主端 dts 类型直连(见 dts.ts);远程不在本机时宿主回退 any 桩 */
|
|
941
941
|
fsRoot: options.root,
|
|
942
942
|
exposes: options.exposes.map((e) => ({
|
|
943
943
|
name: e.name,
|
|
944
944
|
src: e.import,
|
|
945
|
-
file: `${b}@
|
|
945
|
+
file: `${b}@fulgurjs-src/${e.import.replace(/^\.?\//, "")}`
|
|
946
946
|
})),
|
|
947
947
|
shared: options.shared.map((s) => ({
|
|
948
948
|
name: s.shareKey,
|
|
@@ -969,7 +969,7 @@ function genProdManifest(options, exposeFiles, entryFile) {
|
|
|
969
969
|
eager: s.eager
|
|
970
970
|
})),
|
|
971
971
|
buildInfo: {
|
|
972
|
-
builtBy: "
|
|
972
|
+
builtBy: "fulgurjs-federation",
|
|
973
973
|
timestamp: Date.now()
|
|
974
974
|
}
|
|
975
975
|
};
|
|
@@ -982,7 +982,7 @@ async function fetchManifest(devEntry, attempts = 30, delayMs = 2e3) {
|
|
|
982
982
|
let manifestUrl;
|
|
983
983
|
try {
|
|
984
984
|
const u = new URL(devEntry);
|
|
985
|
-
u.pathname = u.pathname.replace("@
|
|
985
|
+
u.pathname = u.pathname.replace("@fulgurjs-entry.js", "@fulgurjs-manifest.json");
|
|
986
986
|
manifestUrl = u;
|
|
987
987
|
} catch {
|
|
988
988
|
return null;
|
|
@@ -1008,7 +1008,7 @@ function sourceHasDefaultExport(file) {
|
|
|
1008
1008
|
async function generateDevTypes(options, _server) {
|
|
1009
1009
|
const dtsOpt = options.dts === void 0 ? true : options.dts;
|
|
1010
1010
|
if (dtsOpt === false) return;
|
|
1011
|
-
const defaultDir = fs2.existsSync(path3.join(options.root, "src")) ? "src/
|
|
1011
|
+
const defaultDir = fs2.existsSync(path3.join(options.root, "src")) ? "src/fulgurjs-types" : "fulgurjs-types";
|
|
1012
1012
|
const dir = typeof dtsOpt === "object" ? dtsOpt.dir ?? defaultDir : defaultDir;
|
|
1013
1013
|
const outDir = path3.join(options.root, dir);
|
|
1014
1014
|
fs2.mkdirSync(outDir, { recursive: true });
|
|
@@ -1016,18 +1016,18 @@ async function generateDevTypes(options, _server) {
|
|
|
1016
1016
|
if (!remote.devEntry || remote.promise) continue;
|
|
1017
1017
|
const manifest = await fetchManifest(remote.devEntry);
|
|
1018
1018
|
if (!manifest || !manifest.exposes) {
|
|
1019
|
-
console.warn(`[
|
|
1019
|
+
console.warn(`[fulgurjs] dts: remote "${remote.key}" dev manifest unavailable; type mapping skipped.`);
|
|
1020
1020
|
continue;
|
|
1021
1021
|
}
|
|
1022
1022
|
const remoteRoot = manifest.fsRoot;
|
|
1023
1023
|
if (!remoteRoot || !fs2.existsSync(remoteRoot)) {
|
|
1024
1024
|
console.warn(
|
|
1025
|
-
`[
|
|
1025
|
+
`[fulgurjs] dts: remote "${remote.key}" is not on this machine; type mapping skipped (module types fall back to any).`
|
|
1026
1026
|
);
|
|
1027
1027
|
continue;
|
|
1028
1028
|
}
|
|
1029
1029
|
const lines = [
|
|
1030
|
-
`// \u81EA\u52A8\u751F\u6210\
|
|
1030
|
+
`// \u81EA\u52A8\u751F\u6210\uFF1Afulgurjs-federation dev \u7C7B\u578B\u76F4\u8FDE\uFF08remote: ${remote.name}\uFF09`,
|
|
1031
1031
|
`// \u91CD\u65B0\u751F\u6210\uFF1A\u91CD\u542F host dev server`
|
|
1032
1032
|
];
|
|
1033
1033
|
for (const expose of manifest.exposes ?? []) {
|
|
@@ -1054,16 +1054,16 @@ async function generateDevTypes(options, _server) {
|
|
|
1054
1054
|
fs2.writeFileSync(path3.join(outDir, `${remote.key}.d.ts`), `${lines.join("\n")}
|
|
1055
1055
|
`);
|
|
1056
1056
|
console.log(
|
|
1057
|
-
`[
|
|
1057
|
+
`[fulgurjs] dts: generated ${dir}/${remote.key}.d.ts (${manifest.exposes?.length ?? 0} exposes). \u786E\u4FDD tsconfig include \u5305\u542B "${dir}" \u4EE5\u83B7\u5F97\u6E90\u7801\u7EA7\u7C7B\u578B\u8865\u5168\u3002`
|
|
1058
1058
|
);
|
|
1059
1059
|
}
|
|
1060
1060
|
}
|
|
1061
1061
|
|
|
1062
1062
|
// src/diagnostics.ts
|
|
1063
|
-
function
|
|
1063
|
+
function formatFulgurjsDiagnostic(input) {
|
|
1064
1064
|
const ctx = input.details ? `
|
|
1065
1065
|
\u4E0A\u4E0B\u6587\uFF1A${JSON.stringify(input.details)}` : "";
|
|
1066
|
-
return `[
|
|
1066
|
+
return `[fulgurjs:${input.code}] ${input.symptom}
|
|
1067
1067
|
\u6839\u56E0\uFF1A${input.cause}
|
|
1068
1068
|
\u4FEE\u6CD5\uFF1A${input.fix}` + ctx;
|
|
1069
1069
|
}
|
|
@@ -1087,7 +1087,7 @@ async function isPortReachable(host, port, timeoutMs = 800) {
|
|
|
1087
1087
|
function manifestUrlOf(devEntry) {
|
|
1088
1088
|
try {
|
|
1089
1089
|
const u = new URL(devEntry);
|
|
1090
|
-
u.pathname = u.pathname.replace("@
|
|
1090
|
+
u.pathname = u.pathname.replace("@fulgurjs-entry.js", "@fulgurjs-manifest.json");
|
|
1091
1091
|
return u;
|
|
1092
1092
|
} catch {
|
|
1093
1093
|
return null;
|
|
@@ -1113,7 +1113,7 @@ async function probeRemotesAndBuildSchema(options) {
|
|
|
1113
1113
|
schema[remote.key] = { exposes, exists: true };
|
|
1114
1114
|
if (exposes.length === 0) {
|
|
1115
1115
|
console.warn(
|
|
1116
|
-
|
|
1116
|
+
formatFulgurjsDiagnostic({
|
|
1117
1117
|
code: "DEV-002",
|
|
1118
1118
|
symptom: `remote "${remote.key}" \u7684 dev manifest \u53EF\u8FBE\u4F46 exposes \u4E3A\u7A7A\uFF08${u.href}\uFF09`,
|
|
1119
1119
|
cause: "remote \u4FA7 federation({ exposes }) \u4E3A\u7A7A\uFF0C\u6216\u5176\u63D2\u4EF6\u7248\u672C\u8FC7\u65E7\u5BFC\u81F4 manifest \u7F3A\u5B57\u6BB5",
|
|
@@ -1125,7 +1125,7 @@ async function probeRemotesAndBuildSchema(options) {
|
|
|
1125
1125
|
const remoteVersion = manifest?.buildInfo?.version;
|
|
1126
1126
|
if (remoteVersion && remoteVersion !== options.pluginVersion) {
|
|
1127
1127
|
console.warn(
|
|
1128
|
-
|
|
1128
|
+
formatFulgurjsDiagnostic({
|
|
1129
1129
|
code: "DEV-006",
|
|
1130
1130
|
symptom: `\u5BBF\u4E3B\u4E0E remote "${remote.key}" \u7684 @fulgurjs/federation \u7248\u672C\u4E0D\u4E00\u81F4`,
|
|
1131
1131
|
cause: `\u5BBF\u4E3B ${options.pluginVersion} vs \u8FDC\u7A0B ${remoteVersion}\uFF08pnpm tarball \u65AD\u94FE/\u6F0F\u5347\u7EA7\u5E38\u89C1\uFF09`,
|
|
@@ -1139,7 +1139,7 @@ async function probeRemotesAndBuildSchema(options) {
|
|
|
1139
1139
|
const port = u.port ? Number(u.port) : u.protocol === "https:" ? 443 : 80;
|
|
1140
1140
|
const portOpen = await isPortReachable(u.hostname, port);
|
|
1141
1141
|
console.warn(
|
|
1142
|
-
|
|
1142
|
+
formatFulgurjsDiagnostic({
|
|
1143
1143
|
code: "DEV-001",
|
|
1144
1144
|
symptom: `remote "${remote.key}" \u7684 dev manifest \u4E0D\u53EF\u8FBE\uFF08${u.href}\uFF09\u2014\u2014\u8BE5 remote \u7684\u8DEF\u7531\u5B58\u5728\u6027\u6821\u9A8C\u5C06\u8DF3\u8FC7`,
|
|
1145
1145
|
cause: portOpen ? "\u7AEF\u53E3\u6709\u8FDB\u7A0B\u76D1\u542C\u4F46 manifest \u7AEF\u70B9\u5F02\u5E38\uFF1Aremote dev server \u53EF\u80FD\u4EE5\u975E\u8054\u90A6\u914D\u7F6E\u542F\u52A8\uFF0C\u6216 base/\u8DEF\u5F84\u4E0E remotes[].dev \u4E0D\u4E00\u81F4" : "\u7AEF\u53E3\u65E0\u8FDB\u7A0B\u76D1\u542C\uFF1Aremote dev server \u672A\u542F\u52A8\uFF0C\u6216 remotes[].dev \u7AEF\u53E3\u5199\u9519\uFF08server.origin \u9519\u4F4D\u540C\u6B3E\uFF09",
|
|
@@ -1152,7 +1152,7 @@ async function probeRemotesAndBuildSchema(options) {
|
|
|
1152
1152
|
return schema;
|
|
1153
1153
|
}
|
|
1154
1154
|
function genEmptyRemoteSchemaModule() {
|
|
1155
|
-
console.info("[
|
|
1155
|
+
console.info("[fulgurjs] build \u671F\u8DF3\u8FC7\u8DEF\u7531 spec \u5B58\u5728\u6027\u6821\u9A8C\uFF08\u8FDC\u7A0B manifest \u4E0D\u5728\u6784\u5EFA\u673A\u672C\u5730\uFF1Bdev \u4E0B\u81EA\u52A8\u542F\u7528\uFF09");
|
|
1156
1156
|
return "export default {}";
|
|
1157
1157
|
}
|
|
1158
1158
|
|
|
@@ -1161,27 +1161,27 @@ import fs3 from "fs";
|
|
|
1161
1161
|
import path4 from "path";
|
|
1162
1162
|
function syncViteCacheMarker(root, pluginVersion, log) {
|
|
1163
1163
|
const viteDir = path4.join(root, "node_modules", ".vite");
|
|
1164
|
-
const marker = path4.join(viteDir, "
|
|
1164
|
+
const marker = path4.join(viteDir, "fulgurjs-version.txt");
|
|
1165
1165
|
try {
|
|
1166
1166
|
if (fs3.existsSync(viteDir)) {
|
|
1167
1167
|
const prev = fs3.existsSync(marker) ? fs3.readFileSync(marker, "utf8").trim() : "";
|
|
1168
1168
|
if (prev === pluginVersion) return;
|
|
1169
1169
|
fs3.rmSync(viteDir, { recursive: true, force: true });
|
|
1170
1170
|
log(
|
|
1171
|
-
`[
|
|
1171
|
+
`[fulgurjs] \u63D2\u4EF6\u7248\u672C\u53D8\u5316\uFF08${prev || "\u65E0\u8BB0\u5F55"} \u2192 ${pluginVersion}\uFF09\uFF0C\u5DF2\u81EA\u52A8\u6E05\u9664 ${path4.relative(root, viteDir)} \u9884\u6784\u5EFA\u7F13\u5B58\uFF08\u907F\u514D\u65E7\u95E8\u9762\u7B7E\u540D 404 / DEV-009\uFF09\u3002\u672C\u6B21\u542F\u52A8\u5C06\u91CD\u65B0\u9884\u6784\u5EFA\uFF0C\u9996\u8F6E 30~60s \u5C5E\u6682\u6001\uFF08DEV-010\uFF09\u3002`
|
|
1172
1172
|
);
|
|
1173
1173
|
}
|
|
1174
1174
|
fs3.mkdirSync(viteDir, { recursive: true });
|
|
1175
1175
|
fs3.writeFileSync(marker, pluginVersion);
|
|
1176
1176
|
} catch (e) {
|
|
1177
1177
|
log(
|
|
1178
|
-
`[
|
|
1178
|
+
`[fulgurjs] \u81EA\u52A8\u6E05\u7406 .vite \u7F13\u5B58\u5931\u8D25\uFF08\u4E0D\u5F71\u54CD\u542F\u52A8\uFF1B\u5982\u9047\u8054\u90A6\u6A21\u5757 404 \u8BF7\u624B\u5DE5\u6267\u884C rm -rf ${viteDir}\uFF09\uFF1A${String(e.message ?? e)}`
|
|
1179
1179
|
);
|
|
1180
1180
|
}
|
|
1181
1181
|
}
|
|
1182
1182
|
|
|
1183
1183
|
// src/runtime-code.gen.ts
|
|
1184
|
-
var runtime_code_gen_default = 'var Q=/^v?(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?(?:-((?:[0-9A-Za-z-]+)(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z.-]+)?$/;function k(t){let n=Q.exec(String(t).trim());return n?{major:Number(n[1]),minor:Number(n[2]??0),patch:Number(n[3]??0),pre:n[4]?n[4].split("."):[]}:null}function ee(t,n){if(t.length===0&&n.length===0)return 0;if(t.length===0)return 1;if(n.length===0)return-1;let o=Math.max(t.length,n.length);for(let r=0;r<o;r++){let l=t[r],m=n[r];if(l===void 0)return-1;if(m===void 0)return 1;let y=/^\\d+$/.test(l),w=/^\\d+$/.test(m);if(y&&w){let M=Number(l)-Number(m);if(M!==0)return M}else{if(y!==w)return y?-1:1;if(l!==m)return l<m?-1:1}}return 0}function T(t,n){let o=k(t),r=k(n);return!o||!r?t<n?-1:t>n?1:0:o.major!==r.major?o.major-r.major:o.minor!==r.minor?o.minor-r.minor:o.patch!==r.patch?o.patch-r.patch:ee(o.pre,r.pre)}var re=/^[a-z]+[+:-]/i;function N(t,n){if(n===!1||n==null||n==="")return!0;let o=String(n).trim();return!o||o==="*"||o==="latest"||re.test(o)?!0:o.split("||").some(r=>te(t,r.trim()))}function te(t,n){if(!n||n==="*")return!k(t)?.pre.length;let o=n.split(/\\s+-\\s+/);if(o.length===2){let m=o[0].trim(),y=o[1].trim();return!(!N(t,`>=${m}`)||!N(t,`<=${y}`))}let r=k(t);if(!r)return!1;let l=ne(n);if(l===null)return!0;for(let m of l)if(!ue(r,t,m))return!1;return!(r.pre.length>0&&!l.some(m=>m.ver.pre.length>0)&&!l.some(y=>y.ver.major===r.major&&y.ver.minor===r.minor&&y.ver.patch===r.patch))}function ne(t){let n=[],o=t.trim().split(/\\s+/).filter(Boolean);if(o.length===0)return null;for(let r of o){let l=/^(>=|<=|>|<|=|\\^|~)?(.*)$/.exec(r);if(!l)return null;let m=l[1],y=l[2],w=oe(m,y);if(w===null)return null;n.push(...w)}return n}function oe(t,n){let o=ae(n);if(!o)return null;let{ver:r,partial:l}=o;switch(t){case"^":{let m=ie(r);return m?[{op:">=",ver:r},{op:"<",ver:m}]:null}case"~":{let m=l>=2?{major:r.major,minor:r.minor+1,patch:0,pre:[]}:{major:r.major+1,minor:0,patch:0,pre:[]};return[{op:">=",ver:r},{op:"<",ver:m}]}case">=":return[{op:">=",ver:r}];case">":return l===1?[{op:">=",ver:{major:r.major+1,minor:0,patch:0,pre:[]}}]:l===2?[{op:">=",ver:{major:r.major,minor:r.minor+1,patch:0,pre:[]}}]:[{op:">",ver:r}];case"<":return l===1?[{op:"<",ver:{major:r.major,minor:0,patch:0,pre:[]}}]:l===2?[{op:"<",ver:{major:r.major,minor:r.minor,patch:0,pre:[]}}]:[{op:"<",ver:r}];case"<=":return[{op:"<=",ver:r}];case"=":case void 0:return l===1?[{op:">=",ver:r},{op:"<",ver:{major:r.major+1,minor:0,patch:0,pre:[]}}]:l===2?[{op:">=",ver:r},{op:"<",ver:{major:r.major,minor:r.minor+1,patch:0,pre:[]}}]:[{op:"=",ver:r}];default:return null}}function ie(t){return t.major>0?{major:t.major+1,minor:0,patch:0,pre:[]}:t.minor>0?{major:0,minor:t.minor+1,patch:0,pre:[]}:{major:0,minor:0,patch:t.patch+1,pre:[]}}function ae(t){let n=t.replace(/^v/,"").trim();if(!n||n==="*"||n==="x"||n==="X")return{ver:{major:0,minor:0,patch:0,pre:[]},partial:0};let o=n.split("."),r=[],l=0;for(let w of o.slice(0,3))if(/^\\d+$/.test(w))r.push(Number(w)),l++;else{if(w==="x"||w==="X"||w==="*")break;break}let m=n.split("-"),y=m.length>1?m.slice(1).join("-").split("+")[0].split("."):[];return l===0&&y.length===0?{ver:{major:0,minor:0,patch:0,pre:[]},partial:0}:{ver:{major:r[0]??0,minor:r[1]??0,patch:r[2]??0,pre:y},partial:l}}function se(t,n){switch(n){case">=":return t>=0;case">":return t>0;case"<":return t<0;case"<=":return t<=0;case"=":return t===0}}function ue(t,n,o){let r=`${t.major}.${t.minor}.${t.patch}`+(t.pre.length?`-${t.pre.join(".")}`:"");if(o.upper)return!(!(T(r,`${o.ver.major}.${o.ver.minor}.${o.ver.patch}`+(o.ver.pre.length?`-${o.ver.pre.join(".")}`:""))>=0)||!(T(r,`${o.upper.major}.${o.upper.minor}.${o.upper.patch}`)<0));let l=T(r,`${o.ver.major}.${o.ver.minor}.${o.ver.patch}`+(o.ver.pre.length?`-${o.ver.pre.join(".")}`:"")),m=se(l,o.op);return o.ver.pre.length>0&&t.pre.length===0&&(o.op===">"||o.op==="<")?!1:m}var g=class extends Error{code;details;constructor(n,o,r){super(`[fulgur:${n}] ${o}`),this.name="FulgurError",this.code=n,this.details=r}},R={REMOTE_LOAD_FAILED:"MFU-001",REMOTE_NAME_MISMATCH:"MFU-002",SHARE_STRICT_VERSION:"MFU-003",SHARE_NOT_AVAILABLE:"MFU-004",CONTAINER_REINIT_CONFLICT:"MFU-005",MODULE_NOT_EXPOSED:"MFU-006",PRELOAD_FAILED:"MFU-007",REMOTE_UNKNOWN:"MFU-008",EMPTY_EXPORTS:"MFU-009",SINGLETON_SKEW:"MFU-010"};var F="0.4.2";var U=15e3,P=2,ce=5,le=3e4;function fe(){let t={},n=new Map,o=[],r=new Map,l=new WeakMap,m={};function y(e){m={...m,...e},typeof globalThis<"u"&&(globalThis.__FULGUR_APP_CONFIG__=m)}function w(){return m}let M={},D=()=>{for(let e of o)try{e.init?.(M)}catch(i){console.warn("[fulgur] runtimePlugin init failed:",e.name,i)}},I=e=>t[e]??={};function $(e){try{M.onRemoteError?.(e)}catch{}typeof window<"u"&&window.dispatchEvent(new CustomEvent("fulgur:error",{detail:e}))}function H(e="default"){return I(e),t}function K(e,i,a,u,E={}){let s=I(e||"default"),c=s[i]??={};c[a]||(c[a]={version:a,get:u,from:E.from??"unknown",eager:!!E.eager,loaded:!!E.loaded})}function x(e){for(let i of e){let a=n.get(i.name);n.set(i.name,{timeout:U,retries:P,...a,...i,state:a?.state??"idle",breakerState:a?.breakerState??{fails:0,openUntil:0},debug:a?.debug??{entry:i.entry,status:"idle"}})}}function q(e){x([e])}function G(e){o.push(...e),D()}async function z(e,i={}){let a=i.shareScope||"default",u=i.shareKey||e,s=I(a)[u]||{},c=Object.keys(s),d=i.requiredVersion,f=c.filter(p=>d===void 0||d===!1||N(p,d)),b;if(i.singleton&&c.length>0){let p=c.filter(h=>s[h].loaded);if(b=[...p.length?p:c].sort(T).pop(),c.length>1||!f.includes(b)){let h=s[b],O=`singleton skew "${u}": req "${d??"any"}" use ${b} from ${h.from}`;if(i.strictVersion){let v=new g(R.SHARE_STRICT_VERSION,O,{shareKey:u,requiredVersion:d});throw $({remote:h.from,error:v}),v}console.warn(`[fulgur:MFU-010] ${O}`)}}else if(b=[...f].sort(T).pop(),!b){if(i.strictVersion){let h=new g(R.SHARE_STRICT_VERSION,`no satisfying version for "${u}" (required "${d}") in share scope "${a}"`);throw $({remote:u,error:h}),h}if(i.fallback)return i.fallback();let p=new g(R.SHARE_NOT_AVAILABLE,`shared "${u}" (${d??"any"}) unavailable in scope "${a}" (no local fallback)`,{shareKey:u,requiredVersion:d});throw $({remote:u,error:p}),p}let _=s[b];if(M.resolveShare){let p=await M.resolveShare({shareKey:u,shareScope:a,requiredVersion:d,picked:_,available:Object.values(s)});p&&(_=p)}return _.loaded=!0,_.get()}function W(e,i,a){return new Promise((u,E)=>{let s=setTimeout(()=>E(new Error(`timeout after ${i}ms: ${a}`)),i);e.then(c=>{clearTimeout(s),u(c)},c=>{clearTimeout(s),E(c)})})}let B=e=>new Promise(i=>setTimeout(i,e));function j(e,i){if(!e||typeof e.get!="function")throw new Error(`remoteEntry of "${i.name}" does not export a container interface (get/init)`);if(e.name&&i.name&&e.name!==i.name){let a=`remoteEntry self-reported name "${e.name}" mismatches configured name "${i.name}"`;if(i.promise)console.warn(`[fulgur] ${a} (promise-based remote, continuing)`);else throw Object.assign(new Error(a),{code:R.REMOTE_NAME_MISMATCH})}}async function L(e,i){return W(import(e),i.timeout??U,`load remoteEntry ${e}`)}async function C(e,i){let a=e.shareScope||"default";if(e.container){let s=l.get(e.container);if(s&&s!==a)throw new g(R.CONTAINER_REINIT_CONFLICT,`container "${e.name}" already initialized with share scope "${s}", cannot re-init with "${a}"`);return e.container}if(e.containerPromise)return e.containerPromise;let u=e.breakerState;if(u.openUntil>Date.now()){let s=new g(R.REMOTE_LOAD_FAILED,`circuit breaker open for remote "${e.name}" until ${new Date(u.openUntil).toISOString()}`,{remote:e.name});throw $({remote:e.name,error:s}),s}e.state="loading",e.debug.status="loading";let E=(async()=>{let s=[];if(e.promise)s.push(async()=>{let p=await e.promise(),h=typeof p=="string"?await L(p,e):p;return j(h,e),h});else for(let p of[e.entry,...e.fallback??[]])s.push(async()=>{let h=await L(p,e);return j(h,e),h});let c,d,f=!1,b=i?.retries??e.retries??P;for(let p of s){for(let h=0;h<=b;h++){let O=performance.now();try{c=await p(),e.lastLoadMs=Math.round(performance.now()-O),e.debug.lastLoadMs=e.lastLoadMs,f=!0;break}catch(v){if(d=v,v?.code)throw v;h<b&&await B(200*2**h)}}if(f)break}if(!f||!c){let p=[];throw/^https?:\\/\\//.test(e.entry)&&typeof location<"u"?(p.push(`1. is the remote dev server running? try opening ${e.entry} in the browser \\u2014 it must return JS, not HTML/an error`),p.push("2. is the URL correct in federation({ remotes })? dev and prod entries can differ"),p.push("3. CORS: the remote dev server must allow cross-origin requests (fulgur-federation enables server.cors automatically; a custom server config may have disabled it)")):(p.push(`1. is the remote deployed and reachable? try opening ${e.entry} in the browser \\u2014 it must return JS`),p.push("2. NGINX/CDN routing: the entry path must serve the remoteEntry JS file (check try_files / fallback rules)")),new g(R.REMOTE_LOAD_FAILED,`failed to load remote "${e.name}" from ${e.entry}: ${String(d?.message??d)}\n`+p.join(`\n`),{remote:e.name})}j(c,e);let _=l.get(c);if(_&&_!==a)throw new g(R.CONTAINER_REINIT_CONFLICT,`container "${e.name}" already initialized with share scope "${_}", cannot re-init with "${a}"`);return typeof c.init=="function"&&await c.init(t),l.set(c,a),e.container=c,e.state="loaded",e.debug.status="loaded",u.fails=0,c})();e.containerPromise=E;try{return await E}catch(s){if(e.containerPromise=void 0,e.state="failed",e.debug.status="failed",e.debug.error=String(s?.message??s),u.fails+=1,u.fails>=ce&&(u.openUntil=Date.now()+le,u.fails=0),s instanceof g)throw $({remote:e.name,error:s}),s;if(s?.code)throw $({remote:e.name,error:s}),s;let c=new g(R.REMOTE_LOAD_FAILED,String(s?.message??s),{remote:e.name});throw $({remote:e.name,error:c}),c}}function A(e){let i=e.indexOf("/");return i===-1?{remote:e,module:""}:{remote:e.slice(0,i),module:X(e.slice(i+1))}}function X(e){return e?e.startsWith(".")?e:`./${e}`:""}async function J(e,i){let{remote:a,module:u}=A(e);M.beforeLoadRemote?.({remote:a,module:u});let E=n.get(a);if(!E)throw new g(R.REMOTE_UNKNOWN,`unknown remote "${a}". Register it via federation({ remotes }) or registerRemote().`,{remote:a});let s;try{s=await C(E,{retries:i?.retries})}catch(f){if(i?.fallbackModule)return console.error(`[fulgur] loadRemote("${e}") failed; returning fallbackModule (\\u663E\\u5F0F\\u964D\\u7EA7\\uFF0C\\u9519\\u8BEF\\u5DF2\\u900F\\u51FA)`,f),$({remote:a,error:f}),await i.fallbackModule();throw f}if(!u)return s;let c=`${a}@${E.shareScope||"default"}#${u}`;r.has(c)||r.set(c,s.get(u).catch(f=>{throw r.delete(c),f instanceof g||f?.code?f:new g(R.REMOTE_LOAD_FAILED,`failed to load module "${u}" from remote "${a}": ${String(f?.message??f)}`,{remote:a,module:u})}));let d;try{d=await r.get(c)}catch(f){if(i?.fallbackModule)return console.error(`[fulgur] loadRemote("${e}") failed; returning fallbackModule (\\u663E\\u5F0F\\u964D\\u7EA7\\uFF0C\\u9519\\u8BEF\\u5DF2\\u900F\\u51FA)`,f),$({remote:a,error:f}),await i.fallbackModule();throw f}if(M.afterLoadRemote?.({remote:a,module:u,module_ns:d}),d&&typeof d=="object"&&Object.keys(d).length===0){let f=new g(R.EMPTY_EXPORTS,`no exports: ${u} @ ${a}`,{remote:a,module:u});$({remote:a,error:f}),console.error(`[fulgur:MFU-009] ${f.message}`)}return d}function Y(e){let i=n.get(e);if(!i)throw new g(R.REMOTE_UNKNOWN,`unknown remote "${e}"`,{remote:e});return C(i)}async function Z(e,i={}){let{remote:a}=A(e),u=n.get(a);if(!u)throw new g(R.REMOTE_UNKNOWN,`unknown remote "${a}"`,{remote:a});let E=i.mode??"preload",s=(c,d)=>{if(typeof document>"u"||document.querySelector(`link[href="${c}"]`))return;let f=document.createElement("link");f.rel=d==="style"?"stylesheet":"modulepreload",f.href=c,E==="prefetch"&&(f.fetchPriority="low"),document.head.appendChild(f)};try{if(u.manifestUrl){let c=await fetch(u.manifestUrl,{cache:"no-cache"});if(c.ok){let d=await c.json();s(u.entry,"modulepreload");let f=d.exposes??{};for(let b of Object.keys(f)){let _=f[b];_?.file&&s(new URL(_.file,u.entry).href,"modulepreload");for(let p of _?.css??[])s(new URL(p,u.entry).href,"style")}return}}s(u.entry,"modulepreload")}catch(c){$({remote:a,error:new g(R.PRELOAD_FAILED,String(c?.message??c),{remote:a})})}}return typeof window>"u"||(window.__FULGUR_SCOPE__=t,window.__FULGUR_INFO__={get remotes(){let e={};for(let[i,a]of n)e[i]={...a.debug,entry:a.entry};return e},errors:[]}),{shareScopeMap:t,initSharing:H,registerShare:K,registerRemotes:x,registerRemote:q,registerPlugins:G,loadShare:z,loadRemote:J,getContainer:Y,preloadRemote:Z,parseSpec:A,provideFulgurAppConfig:y,getFulgurAppConfig:w}}var V=globalThis,S=V.__FULGUR_RUNTIME__??fe();V.__FULGUR_RUNTIME__=S;try{Object.freeze(S)}catch{}var Re=F;function Se(){return S}var we=S.initSharing,be=S.registerShare,_e=S.registerRemotes,$e=S.registerRemote,Me=S.registerPlugins,ve=S.loadShare,Te=S.loadRemote,Oe=S.getContainer,ke=S.preloadRemote,Ne=S.shareScopeMap,Ie=S.provideFulgurAppConfig,je=S.getFulgurAppConfig;function Ae(t){if(t&&typeof t=="object"&&"default"in t){let n=t.default;return n!==void 0?n:t}return t}var xe=S;export{xe as default,Oe as getContainer,je as getFulgurAppConfig,Se as getRuntime,we as initSharing,Te as loadRemote,ve as loadShare,ke as preloadRemote,Ie as provideFulgurAppConfig,Me as registerPlugins,$e as registerRemote,_e as registerRemotes,be as registerShare,S as runtime,Ne as shareScopeMap,Ae as unwrapDefault,Re as version};\n';
|
|
1184
|
+
var runtime_code_gen_default = 'var Q=/^v?(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?(?:-((?:[0-9A-Za-z-]+)(?:\\.[0-9A-Za-z-]+)*))?(?:\\+[0-9A-Za-z.-]+)?$/;function O(t){let n=Q.exec(String(t).trim());return n?{major:Number(n[1]),minor:Number(n[2]??0),patch:Number(n[3]??0),pre:n[4]?n[4].split("."):[]}:null}function ee(t,n){if(t.length===0&&n.length===0)return 0;if(t.length===0)return 1;if(n.length===0)return-1;let o=Math.max(t.length,n.length);for(let r=0;r<o;r++){let l=t[r],m=n[r];if(l===void 0)return-1;if(m===void 0)return 1;let y=/^\\d+$/.test(l),w=/^\\d+$/.test(m);if(y&&w){let $=Number(l)-Number(m);if($!==0)return $}else{if(y!==w)return y?-1:1;if(l!==m)return l<m?-1:1}}return 0}function v(t,n){let o=O(t),r=O(n);return!o||!r?t<n?-1:t>n?1:0:o.major!==r.major?o.major-r.major:o.minor!==r.minor?o.minor-r.minor:o.patch!==r.patch?o.patch-r.patch:ee(o.pre,r.pre)}var re=/^[a-z]+[+:-]/i;function k(t,n){if(n===!1||n==null||n==="")return!0;let o=String(n).trim();return!o||o==="*"||o==="latest"||re.test(o)?!0:o.split("||").some(r=>te(t,r.trim()))}function te(t,n){if(!n||n==="*")return!O(t)?.pre.length;let o=n.split(/\\s+-\\s+/);if(o.length===2){let m=o[0].trim(),y=o[1].trim();return!(!k(t,`>=${m}`)||!k(t,`<=${y}`))}let r=O(t);if(!r)return!1;let l=ne(n);if(l===null)return!0;for(let m of l)if(!ue(r,t,m))return!1;return!(r.pre.length>0&&!l.some(m=>m.ver.pre.length>0)&&!l.some(y=>y.ver.major===r.major&&y.ver.minor===r.minor&&y.ver.patch===r.patch))}function ne(t){let n=[],o=t.trim().split(/\\s+/).filter(Boolean);if(o.length===0)return null;for(let r of o){let l=/^(>=|<=|>|<|=|\\^|~)?(.*)$/.exec(r);if(!l)return null;let m=l[1],y=l[2],w=oe(m,y);if(w===null)return null;n.push(...w)}return n}function oe(t,n){let o=ae(n);if(!o)return null;let{ver:r,partial:l}=o;switch(t){case"^":{let m=ie(r);return m?[{op:">=",ver:r},{op:"<",ver:m}]:null}case"~":{let m=l>=2?{major:r.major,minor:r.minor+1,patch:0,pre:[]}:{major:r.major+1,minor:0,patch:0,pre:[]};return[{op:">=",ver:r},{op:"<",ver:m}]}case">=":return[{op:">=",ver:r}];case">":return l===1?[{op:">=",ver:{major:r.major+1,minor:0,patch:0,pre:[]}}]:l===2?[{op:">=",ver:{major:r.major,minor:r.minor+1,patch:0,pre:[]}}]:[{op:">",ver:r}];case"<":return l===1?[{op:"<",ver:{major:r.major,minor:0,patch:0,pre:[]}}]:l===2?[{op:"<",ver:{major:r.major,minor:r.minor,patch:0,pre:[]}}]:[{op:"<",ver:r}];case"<=":return[{op:"<=",ver:r}];case"=":case void 0:return l===1?[{op:">=",ver:r},{op:"<",ver:{major:r.major+1,minor:0,patch:0,pre:[]}}]:l===2?[{op:">=",ver:r},{op:"<",ver:{major:r.major,minor:r.minor+1,patch:0,pre:[]}}]:[{op:"=",ver:r}];default:return null}}function ie(t){return t.major>0?{major:t.major+1,minor:0,patch:0,pre:[]}:t.minor>0?{major:0,minor:t.minor+1,patch:0,pre:[]}:{major:0,minor:0,patch:t.patch+1,pre:[]}}function ae(t){let n=t.replace(/^v/,"").trim();if(!n||n==="*"||n==="x"||n==="X")return{ver:{major:0,minor:0,patch:0,pre:[]},partial:0};let o=n.split("."),r=[],l=0;for(let w of o.slice(0,3))if(/^\\d+$/.test(w))r.push(Number(w)),l++;else{if(w==="x"||w==="X"||w==="*")break;break}let m=n.split("-"),y=m.length>1?m.slice(1).join("-").split("+")[0].split("."):[];return l===0&&y.length===0?{ver:{major:0,minor:0,patch:0,pre:[]},partial:0}:{ver:{major:r[0]??0,minor:r[1]??0,patch:r[2]??0,pre:y},partial:l}}function se(t,n){switch(n){case">=":return t>=0;case">":return t>0;case"<":return t<0;case"<=":return t<=0;case"=":return t===0}}function ue(t,n,o){let r=`${t.major}.${t.minor}.${t.patch}`+(t.pre.length?`-${t.pre.join(".")}`:"");if(o.upper)return!(!(v(r,`${o.ver.major}.${o.ver.minor}.${o.ver.patch}`+(o.ver.pre.length?`-${o.ver.pre.join(".")}`:""))>=0)||!(v(r,`${o.upper.major}.${o.upper.minor}.${o.upper.patch}`)<0));let l=v(r,`${o.ver.major}.${o.ver.minor}.${o.ver.patch}`+(o.ver.pre.length?`-${o.ver.pre.join(".")}`:"")),m=se(l,o.op);return o.ver.pre.length>0&&t.pre.length===0&&(o.op===">"||o.op==="<")?!1:m}var g=class extends Error{code;details;constructor(n,o,r){super(`[fulgurjs:${n}] ${o}`),this.name="FulgurjsError",this.code=n,this.details=r}},R={REMOTE_LOAD_FAILED:"MFU-001",REMOTE_NAME_MISMATCH:"MFU-002",SHARE_STRICT_VERSION:"MFU-003",SHARE_NOT_AVAILABLE:"MFU-004",CONTAINER_REINIT_CONFLICT:"MFU-005",MODULE_NOT_EXPOSED:"MFU-006",PRELOAD_FAILED:"MFU-007",REMOTE_UNKNOWN:"MFU-008",EMPTY_EXPORTS:"MFU-009",SINGLETON_SKEW:"MFU-010"};var F="0.5.0";var U=15e3,P=2,ce=5,le=3e4;function fe(){let t={},n=new Map,o=[],r=new Map,l=new WeakMap,m={};function y(e){m={...m,...e},typeof globalThis<"u"&&(globalThis.__FULGURJS_APP_CONFIG__=m)}function w(){return m}let $={},D=()=>{for(let e of o)try{e.init?.($)}catch(i){console.warn("[fulgurjs] runtimePlugin init failed:",e.name,i)}},N=e=>t[e]??={};function j(e){try{$.onRemoteError?.(e)}catch{}typeof window<"u"&&window.dispatchEvent(new CustomEvent("fulgurjs:error",{detail:e}))}function H(e="default"){return N(e),t}function K(e,i,a,u,E={}){let s=N(e||"default"),c=s[i]??={};c[a]||(c[a]={version:a,get:u,from:E.from??"unknown",eager:!!E.eager,loaded:!!E.loaded})}function x(e){for(let i of e){let a=n.get(i.name);n.set(i.name,{timeout:U,retries:P,...a,...i,state:a?.state??"idle",breakerState:a?.breakerState??{fails:0,openUntil:0},debug:a?.debug??{entry:i.entry,status:"idle"}})}}function q(e){x([e])}function G(e){o.push(...e),D()}async function z(e,i={}){let a=i.shareScope||"default",u=i.shareKey||e,s=N(a)[u]||{},c=Object.keys(s),d=i.requiredVersion,f=c.filter(p=>d===void 0||d===!1||k(p,d)),b;if(i.singleton&&c.length>0){let p=c.filter(h=>s[h].loaded);if(b=[...p.length?p:c].sort(v).pop(),c.length>1||!f.includes(b)){let h=s[b],T=`singleton skew "${u}": req "${d??"any"}" use ${b} from ${h.from}`;if(i.strictVersion){let M=new g(R.SHARE_STRICT_VERSION,T,{shareKey:u,requiredVersion:d});throw j({remote:h.from,error:M}),M}console.warn(`[fulgurjs:MFU-010] ${T}`)}}else if(b=[...f].sort(v).pop(),!b){if(i.strictVersion){let h=new g(R.SHARE_STRICT_VERSION,`no satisfying version for "${u}" (required "${d}") in share scope "${a}"`);throw j({remote:u,error:h}),h}if(i.fallback)return i.fallback();let p=new g(R.SHARE_NOT_AVAILABLE,`shared "${u}" (${d??"any"}) unavailable in scope "${a}" (no local fallback)`,{shareKey:u,requiredVersion:d});throw j({remote:u,error:p}),p}let _=s[b];if($.resolveShare){let p=await $.resolveShare({shareKey:u,shareScope:a,requiredVersion:d,picked:_,available:Object.values(s)});p&&(_=p)}return _.loaded=!0,_.get()}function J(e,i,a){return new Promise((u,E)=>{let s=setTimeout(()=>E(new Error(`timeout after ${i}ms: ${a}`)),i);e.then(c=>{clearTimeout(s),u(c)},c=>{clearTimeout(s),E(c)})})}let W=e=>new Promise(i=>setTimeout(i,e));function I(e,i){if(!e||typeof e.get!="function")throw new Error(`remoteEntry of "${i.name}" does not export a container interface (get/init)`);if(e.name&&i.name&&e.name!==i.name){let a=`remoteEntry self-reported name "${e.name}" mismatches configured name "${i.name}"`;if(i.promise)console.warn(`[fulgurjs] ${a} (promise-based remote, continuing)`);else throw Object.assign(new Error(a),{code:R.REMOTE_NAME_MISMATCH})}}async function L(e,i){return J(import(e),i.timeout??U,`load remoteEntry ${e}`)}async function C(e,i){let a=e.shareScope||"default";if(e.container){let s=l.get(e.container);if(s&&s!==a)throw new g(R.CONTAINER_REINIT_CONFLICT,`container "${e.name}" already initialized with share scope "${s}", cannot re-init with "${a}"`);return e.container}if(e.containerPromise)return e.containerPromise;let u=e.breakerState;if(u.openUntil>Date.now()){let s=new g(R.REMOTE_LOAD_FAILED,`circuit breaker open for remote "${e.name}" until ${new Date(u.openUntil).toISOString()}`,{remote:e.name});throw j({remote:e.name,error:s}),s}e.state="loading",e.debug.status="loading";let E=(async()=>{let s=[];if(e.promise)s.push(async()=>{let p=await e.promise(),h=typeof p=="string"?await L(p,e):p;return I(h,e),h});else for(let p of[e.entry,...e.fallback??[]])s.push(async()=>{let h=await L(p,e);return I(h,e),h});let c,d,f=!1,b=i?.retries??e.retries??P;for(let p of s){for(let h=0;h<=b;h++){let T=performance.now();try{c=await p(),e.lastLoadMs=Math.round(performance.now()-T),e.debug.lastLoadMs=e.lastLoadMs,f=!0;break}catch(M){if(d=M,M?.code)throw M;h<b&&await W(200*2**h)}}if(f)break}if(!f||!c){let p=[];throw/^https?:\\/\\//.test(e.entry)&&typeof location<"u"?(p.push(`1. is the remote dev server running? try opening ${e.entry} in the browser \\u2014 it must return JS, not HTML/an error`),p.push("2. is the URL correct in federation({ remotes })? dev and prod entries can differ"),p.push("3. CORS: the remote dev server must allow cross-origin requests (fulgurjs-federation enables server.cors automatically; a custom server config may have disabled it)")):(p.push(`1. is the remote deployed and reachable? try opening ${e.entry} in the browser \\u2014 it must return JS`),p.push("2. NGINX/CDN routing: the entry path must serve the remoteEntry JS file (check try_files / fallback rules)")),new g(R.REMOTE_LOAD_FAILED,`failed to load remote "${e.name}" from ${e.entry}: ${String(d?.message??d)}\n`+p.join(`\n`),{remote:e.name})}I(c,e);let _=l.get(c);if(_&&_!==a)throw new g(R.CONTAINER_REINIT_CONFLICT,`container "${e.name}" already initialized with share scope "${_}", cannot re-init with "${a}"`);return typeof c.init=="function"&&await c.init(t),l.set(c,a),e.container=c,e.state="loaded",e.debug.status="loaded",u.fails=0,c})();e.containerPromise=E;try{return await E}catch(s){if(e.containerPromise=void 0,e.state="failed",e.debug.status="failed",e.debug.error=String(s?.message??s),u.fails+=1,u.fails>=ce&&(u.openUntil=Date.now()+le,u.fails=0),s instanceof g)throw j({remote:e.name,error:s}),s;if(s?.code)throw j({remote:e.name,error:s}),s;let c=new g(R.REMOTE_LOAD_FAILED,String(s?.message??s),{remote:e.name});throw j({remote:e.name,error:c}),c}}function A(e){let i=e.indexOf("/");return i===-1?{remote:e,module:""}:{remote:e.slice(0,i),module:B(e.slice(i+1))}}function B(e){return e?e.startsWith(".")?e:`./${e}`:""}async function X(e,i){let{remote:a,module:u}=A(e);$.beforeLoadRemote?.({remote:a,module:u});let E=n.get(a);if(!E)throw new g(R.REMOTE_UNKNOWN,`unknown remote "${a}". Register it via federation({ remotes }) or registerRemote().`,{remote:a});let s;try{s=await C(E,{retries:i?.retries})}catch(f){if(i?.fallbackModule)return console.error(`[fulgurjs] loadRemote("${e}") failed; returning fallbackModule (\\u663E\\u5F0F\\u964D\\u7EA7\\uFF0C\\u9519\\u8BEF\\u5DF2\\u900F\\u51FA)`,f),j({remote:a,error:f}),await i.fallbackModule();throw f}if(!u)return s;let c=`${a}@${E.shareScope||"default"}#${u}`;r.has(c)||r.set(c,s.get(u).catch(f=>{throw r.delete(c),f instanceof g||f?.code?f:new g(R.REMOTE_LOAD_FAILED,`failed to load module "${u}" from remote "${a}": ${String(f?.message??f)}`,{remote:a,module:u})}));let d;try{d=await r.get(c)}catch(f){if(i?.fallbackModule)return console.error(`[fulgurjs] loadRemote("${e}") failed; returning fallbackModule (\\u663E\\u5F0F\\u964D\\u7EA7\\uFF0C\\u9519\\u8BEF\\u5DF2\\u900F\\u51FA)`,f),j({remote:a,error:f}),await i.fallbackModule();throw f}if($.afterLoadRemote?.({remote:a,module:u,module_ns:d}),d&&typeof d=="object"&&Object.keys(d).length===0){let f=new g(R.EMPTY_EXPORTS,`no exports: ${u} @ ${a}`,{remote:a,module:u});j({remote:a,error:f}),console.error(`[fulgurjs:MFU-009] ${f.message}`)}return d}function Y(e){let i=n.get(e);if(!i)throw new g(R.REMOTE_UNKNOWN,`unknown remote "${e}"`,{remote:e});return C(i)}async function Z(e,i={}){let{remote:a}=A(e),u=n.get(a);if(!u)throw new g(R.REMOTE_UNKNOWN,`unknown remote "${a}"`,{remote:a});let E=i.mode??"preload",s=(c,d)=>{if(typeof document>"u"||document.querySelector(`link[href="${c}"]`))return;let f=document.createElement("link");f.rel=d==="style"?"stylesheet":"modulepreload",f.href=c,E==="prefetch"&&(f.fetchPriority="low"),document.head.appendChild(f)};try{if(u.manifestUrl){let c=await fetch(u.manifestUrl,{cache:"no-cache"});if(c.ok){let d=await c.json();s(u.entry,"modulepreload");let f=d.exposes??{};for(let b of Object.keys(f)){let _=f[b];_?.file&&s(new URL(_.file,u.entry).href,"modulepreload");for(let p of _?.css??[])s(new URL(p,u.entry).href,"style")}return}}s(u.entry,"modulepreload")}catch(c){j({remote:a,error:new g(R.PRELOAD_FAILED,String(c?.message??c),{remote:a})})}}return typeof window>"u"||(window.__FULGURJS_SCOPE__=t,window.__FULGURJS_INFO__={get remotes(){let e={};for(let[i,a]of n)e[i]={...a.debug,entry:a.entry};return e},errors:[]}),{shareScopeMap:t,initSharing:H,registerShare:K,registerRemotes:x,registerRemote:q,registerPlugins:G,loadShare:z,loadRemote:X,getContainer:Y,preloadRemote:Z,parseSpec:A,provideFulgurjsAppConfig:y,getFulgurjsAppConfig:w}}var V=globalThis,S=V.__FULGURJS_RUNTIME__??fe();V.__FULGURJS_RUNTIME__=S;try{Object.freeze(S)}catch{}var Re=F;function Se(){return S}var we=S.initSharing,be=S.registerShare,_e=S.registerRemotes,je=S.registerRemote,$e=S.registerPlugins,Me=S.loadShare,ve=S.loadRemote,Te=S.getContainer,Oe=S.preloadRemote,ke=S.shareScopeMap,Ne=S.provideFulgurjsAppConfig,Ie=S.getFulgurjsAppConfig;function Ae(t){if(t&&typeof t=="object"&&"default"in t){let n=t.default;return n!==void 0?n:t}return t}var xe=S;export{xe as default,Te as getContainer,Ie as getFulgurjsAppConfig,Se as getRuntime,we as initSharing,ve as loadRemote,Me as loadShare,Oe as preloadRemote,Ne as provideFulgurjsAppConfig,$e as registerPlugins,je as registerRemote,_e as registerRemotes,be as registerShare,S as runtime,ke as shareScopeMap,Ae as unwrapDefault,Re as version};\n';
|
|
1185
1185
|
|
|
1186
1186
|
// src/index.ts
|
|
1187
1187
|
function readRuntimeCode() {
|
|
@@ -1191,7 +1191,7 @@ function normalizeBase(base) {
|
|
|
1191
1191
|
if (!base || base === "/") return "/";
|
|
1192
1192
|
return base.endsWith("/") ? base : `${base}/`;
|
|
1193
1193
|
}
|
|
1194
|
-
var
|
|
1194
|
+
var FULGURJS_STUB_NAMESPACE = "fulgurjs-opt-stub";
|
|
1195
1195
|
var nsExportCache = /* @__PURE__ */ new Map();
|
|
1196
1196
|
function enumerateCjsExports(packageName, appRoot) {
|
|
1197
1197
|
const cached = nsExportCache.get(packageName);
|
|
@@ -1203,7 +1203,7 @@ function enumerateCjsExports(packageName, appRoot) {
|
|
|
1203
1203
|
names = Object.keys(mod);
|
|
1204
1204
|
} catch {
|
|
1205
1205
|
console.warn(
|
|
1206
|
-
`[
|
|
1206
|
+
`[fulgurjs] cannot enumerate CJS exports of shared package "${packageName}" for the optimize-deps facade; the facade will export default only. If consumers destructure named exports from it, add this package to optimizeDeps.exclude to serve it through the transform pipeline instead.`
|
|
1207
1207
|
);
|
|
1208
1208
|
}
|
|
1209
1209
|
nsExportCache.set(packageName, names);
|
|
@@ -1235,7 +1235,7 @@ function federation(options) {
|
|
|
1235
1235
|
entryInitInjected: /* @__PURE__ */ new Set()
|
|
1236
1236
|
};
|
|
1237
1237
|
const pre = {
|
|
1238
|
-
name: "
|
|
1238
|
+
name: "fulgurjs:core",
|
|
1239
1239
|
enforce: "pre",
|
|
1240
1240
|
async config(userConfig, env) {
|
|
1241
1241
|
state.command = env.command;
|
|
@@ -1254,19 +1254,19 @@ function federation(options) {
|
|
|
1254
1254
|
const filter = new RegExp(`^(${[...aliasToShare.keys()].map(escapeRe).join("|")})$`);
|
|
1255
1255
|
const devBase = normalizeBase(userConfig.base ?? "/");
|
|
1256
1256
|
const sharedExternal = {
|
|
1257
|
-
name: "
|
|
1257
|
+
name: "fulgurjs:optimize-shared-external",
|
|
1258
1258
|
setup(build) {
|
|
1259
|
-
const facadeUrlFor = (shareKey) => `${devBase}@id/__x00__virtual:
|
|
1259
|
+
const facadeUrlFor = (shareKey) => `${devBase}@id/__x00__virtual:fulgurjs-shared-ns:${shareKey}?import`;
|
|
1260
1260
|
const b = build;
|
|
1261
|
-
b.onResolve({ filter: /
|
|
1261
|
+
b.onResolve({ filter: /fulgurjs-shared-ns:/ }, (args) => ({ path: args.path, external: true }));
|
|
1262
1262
|
b.onResolve({ filter }, (args) => {
|
|
1263
1263
|
if (args.kind === "entry-point" || args.kind === "entry-point-render") return null;
|
|
1264
1264
|
const s = aliasToShare.get(args.path);
|
|
1265
1265
|
if (!s) return null;
|
|
1266
|
-
return { path: `
|
|
1266
|
+
return { path: `fulgurjs-stub:${s.shareKey}`, namespace: FULGURJS_STUB_NAMESPACE };
|
|
1267
1267
|
});
|
|
1268
|
-
b.onLoad({ filter: /^
|
|
1269
|
-
const shareKey = args.path.slice("
|
|
1268
|
+
b.onLoad({ filter: /^fulgurjs-stub:/, namespace: FULGURJS_STUB_NAMESPACE }, (args) => {
|
|
1269
|
+
const shareKey = args.path.slice("fulgurjs-stub:".length);
|
|
1270
1270
|
const url = facadeUrlFor(shareKey);
|
|
1271
1271
|
return {
|
|
1272
1272
|
contents: `export * from ${JSON.stringify(url)};
|
|
@@ -1293,7 +1293,7 @@ export { default } from ${JSON.stringify(url)};
|
|
|
1293
1293
|
if (userTarget) {
|
|
1294
1294
|
if (/es20(0\d|1\d|20|21)/.test(String(userTarget))) {
|
|
1295
1295
|
normalized.warnings.push(
|
|
1296
|
-
`build.target="${String(userTarget)}" does not support top-level await;
|
|
1296
|
+
`build.target="${String(userTarget)}" does not support top-level await; fulgurjs requires es2022 or higher.`
|
|
1297
1297
|
);
|
|
1298
1298
|
}
|
|
1299
1299
|
} else {
|
|
@@ -1301,13 +1301,13 @@ export { default } from ${JSON.stringify(url)};
|
|
|
1301
1301
|
extra.build = { target: "es2022" };
|
|
1302
1302
|
}
|
|
1303
1303
|
}
|
|
1304
|
-
for (const w of normalized.warnings) console.warn(`[
|
|
1304
|
+
for (const w of normalized.warnings) console.warn(`[fulgurjs] ${w}`);
|
|
1305
1305
|
return extra;
|
|
1306
1306
|
},
|
|
1307
1307
|
configResolved(resolved) {
|
|
1308
1308
|
state.base = normalizeBase(resolved.base);
|
|
1309
1309
|
if (resolved.build?.ssr) {
|
|
1310
|
-
console.warn("[
|
|
1310
|
+
console.warn("[fulgurjs] SSR builds are not supported in this version; plugin hooks disabled.");
|
|
1311
1311
|
}
|
|
1312
1312
|
const n0 = state.normalized;
|
|
1313
1313
|
const optimize = resolved.optimizeDeps;
|
|
@@ -1320,7 +1320,7 @@ export { default } from ${JSON.stringify(url)};
|
|
|
1320
1320
|
for (const pkg of KNOWN_UMD) {
|
|
1321
1321
|
if (n0.pkgDependencies[pkg] && !incl(pkg) && !excl(pkg)) {
|
|
1322
1322
|
console.warn(
|
|
1323
|
-
|
|
1323
|
+
formatFulgurjsDiagnostic({
|
|
1324
1324
|
code: "DEV-004",
|
|
1325
1325
|
symptom: `UMD-only \u4F9D\u8D56 "${pkg}" \u4E0D\u5728 optimizeDeps.include`,
|
|
1326
1326
|
cause: "UMD \u5305\u53EA\u80FD\u7ECF\u9884\u6784\u5EFA\u6D88\u8D39\uFF1B\u4E0D\u58F0\u660E\u4F1A\u88AB\u88F8 CJS \u670D\u52A1\u6216\u5185\u8054\u672C\u5730 vue\uFF08\u9875\u9762\u7A7A\u767D/\u53CC\u5B9E\u4F8B\uFF09",
|
|
@@ -1349,7 +1349,7 @@ export { default } from ${JSON.stringify(url)};
|
|
|
1349
1349
|
if (!known && !warnedUnknownPrefixes.has(prefix)) {
|
|
1350
1350
|
warnedUnknownPrefixes.add(prefix);
|
|
1351
1351
|
console.warn(
|
|
1352
|
-
`[
|
|
1352
|
+
`[fulgurjs] "${source}" uses prefix "${prefix}/", which is not in federation({ remotes }) or shared. If "${prefix}" is a federated remote, add it: remotes: { '${prefix}': '<url>' }. (Ignore this if it is a plain npm package.)`
|
|
1353
1353
|
);
|
|
1354
1354
|
}
|
|
1355
1355
|
}
|
|
@@ -1357,17 +1357,17 @@ export { default } from ${JSON.stringify(url)};
|
|
|
1357
1357
|
if (bareClean === RUNTIME_VIRTUAL_ID) return RESOLVED.runtime;
|
|
1358
1358
|
if (bareClean === RUNTIME_PROXY_VIRTUAL_ID) return RESOLVED.runtimeProxy;
|
|
1359
1359
|
if (bareClean === INIT_VIRTUAL_ID) return RESOLVED.init;
|
|
1360
|
-
if (bareClean === "virtual:
|
|
1361
|
-
if (bareClean === "virtual:
|
|
1362
|
-
if (bareClean === "virtual:
|
|
1360
|
+
if (bareClean === "virtual:fulgurjs-remote-schema") return bareClean;
|
|
1361
|
+
if (bareClean === "virtual:fulgurjs-provides") return RESOLVED.provides;
|
|
1362
|
+
if (bareClean === "virtual:fulgurjs-remote-entry") return RESOLVED.remoteEntry;
|
|
1363
1363
|
if (bareClean.startsWith(SHARED_NS_FACADE_PREFIX)) {
|
|
1364
1364
|
return RESOLVED.sharedNsFacade(bareClean.slice(SHARED_NS_FACADE_PREFIX.length)) + query;
|
|
1365
1365
|
}
|
|
1366
|
-
if (bareClean.startsWith("virtual:
|
|
1367
|
-
return RESOLVED.sharedNsFacade(bareClean.slice("virtual:
|
|
1366
|
+
if (bareClean.startsWith("virtual:fulgurjs-cjs-ns:")) {
|
|
1367
|
+
return RESOLVED.sharedNsFacade(bareClean.slice("virtual:fulgurjs-cjs-ns:".length)) + query;
|
|
1368
1368
|
}
|
|
1369
|
-
if (bareClean.startsWith("virtual:
|
|
1370
|
-
const body = bareClean.slice("virtual:
|
|
1369
|
+
if (bareClean.startsWith("virtual:fulgurjs-shared:")) {
|
|
1370
|
+
const body = bareClean.slice("virtual:fulgurjs-shared:".length);
|
|
1371
1371
|
return RESOLVED.sharedFacade(body) + query;
|
|
1372
1372
|
}
|
|
1373
1373
|
return null;
|
|
@@ -1376,22 +1376,22 @@ export { default } from ${JSON.stringify(url)};
|
|
|
1376
1376
|
const raw = id.startsWith("\0") ? id.slice(1) : id;
|
|
1377
1377
|
const q = raw.indexOf("?");
|
|
1378
1378
|
const clean = q === -1 ? raw : raw.slice(0, q);
|
|
1379
|
-
if (clean === "virtual:
|
|
1379
|
+
if (clean === "virtual:fulgurjs-runtime") return readRuntimeCode();
|
|
1380
1380
|
if (clean === RESOLVED.runtimeProxy || clean === RUNTIME_PROXY_VIRTUAL_ID) return genRuntimeProxyModule();
|
|
1381
|
-
if (clean === "virtual:
|
|
1381
|
+
if (clean === "virtual:fulgurjs-init" && state.normalized) {
|
|
1382
1382
|
return genInitModule(state.normalized, state.command);
|
|
1383
1383
|
}
|
|
1384
|
-
if (clean === "virtual:
|
|
1384
|
+
if (clean === "virtual:fulgurjs-provides" && state.normalized) {
|
|
1385
1385
|
return genDevProvides(state.normalized);
|
|
1386
1386
|
}
|
|
1387
|
-
if (clean === "virtual:
|
|
1387
|
+
if (clean === "virtual:fulgurjs-remote-schema" && state.normalized) {
|
|
1388
1388
|
if (state.command === "build") return genEmptyRemoteSchemaModule();
|
|
1389
1389
|
remoteSchemaPromise ??= probeRemotesAndBuildSchema(state.normalized).then(
|
|
1390
1390
|
(schema) => `export default ${JSON.stringify(schema)}`
|
|
1391
1391
|
);
|
|
1392
1392
|
return remoteSchemaPromise;
|
|
1393
1393
|
}
|
|
1394
|
-
if (clean === "virtual:
|
|
1394
|
+
if (clean === "virtual:fulgurjs-remote-entry" && state.normalized) {
|
|
1395
1395
|
return genBuildRemoteEntry(state.normalized, state.exposeAbsPaths);
|
|
1396
1396
|
}
|
|
1397
1397
|
if (clean.startsWith(SHARED_NS_FACADE_PREFIX) && state.normalized) {
|
|
@@ -1406,8 +1406,8 @@ export { default } from ${JSON.stringify(url)};
|
|
|
1406
1406
|
}
|
|
1407
1407
|
return genSharedNsFacade(item, serializeShareCallForFacade(item), names);
|
|
1408
1408
|
}
|
|
1409
|
-
if (clean.startsWith("virtual:
|
|
1410
|
-
const body = clean.slice("virtual:
|
|
1409
|
+
if (clean.startsWith("virtual:fulgurjs-shared:") && state.normalized) {
|
|
1410
|
+
const body = clean.slice("virtual:fulgurjs-shared:".length);
|
|
1411
1411
|
const f = raw.indexOf("?f=");
|
|
1412
1412
|
if (f === -1) {
|
|
1413
1413
|
const item2 = state.normalized.shared.find((x) => x.shareKey === body);
|
|
@@ -1432,7 +1432,7 @@ export { default } from ${JSON.stringify(url)};
|
|
|
1432
1432
|
...item.strictVersion ? ["strictVersion: true"] : [],
|
|
1433
1433
|
"fallback: () => import(" + JSON.stringify(item.import) + ")"
|
|
1434
1434
|
];
|
|
1435
|
-
const call = "
|
|
1435
|
+
const call = "__fulgurjs_loadShare(" + JSON.stringify(item.shareKey) + ", { " + opts.join(", ") + " })";
|
|
1436
1436
|
return genBindingFacade(item, entry.bindings, call);
|
|
1437
1437
|
}
|
|
1438
1438
|
return null;
|
|
@@ -1497,12 +1497,12 @@ ${code}`, map: null };
|
|
|
1497
1497
|
if (resolved) {
|
|
1498
1498
|
state.exposeAbsPaths[e.import] = resolved.id.split("?")[0];
|
|
1499
1499
|
} else {
|
|
1500
|
-
this.error(`[
|
|
1500
|
+
this.error(`[fulgurjs] expose "${e.import}" could not be resolved from ${n.root}`);
|
|
1501
1501
|
}
|
|
1502
1502
|
}
|
|
1503
1503
|
this.emitFile({
|
|
1504
1504
|
type: "chunk",
|
|
1505
|
-
id: "virtual:
|
|
1505
|
+
id: "virtual:fulgurjs-remote-entry",
|
|
1506
1506
|
fileName: n.filename.replace(/^\//, ""),
|
|
1507
1507
|
preserveSignature: "allow-extension"
|
|
1508
1508
|
});
|
|
@@ -1532,7 +1532,7 @@ ${code}`, map: null };
|
|
|
1532
1532
|
const manifest = genProdManifest(n, state.exposeFiles, entryChunkName ?? n.filename);
|
|
1533
1533
|
this.emitFile({
|
|
1534
1534
|
type: "asset",
|
|
1535
|
-
fileName: "
|
|
1535
|
+
fileName: "fulgurjs-manifest.json",
|
|
1536
1536
|
source: JSON.stringify(manifest, null, 2)
|
|
1537
1537
|
});
|
|
1538
1538
|
},
|
|
@@ -1542,10 +1542,10 @@ ${code}`, map: null };
|
|
|
1542
1542
|
warmResolvedSharedPaths(server);
|
|
1543
1543
|
if (n.exposes.length > 0 || n.remotes.length > 0) {
|
|
1544
1544
|
console.warn(
|
|
1545
|
-
|
|
1545
|
+
formatFulgurjsDiagnostic({
|
|
1546
1546
|
code: "DEV-010",
|
|
1547
1547
|
symptom: 'dev \u51B7\u542F\u52A8\u9884\u6784\u5EFA\u7A97\u53E3\uFF1A\u9996\u6B21\u542F\u52A8\u6216\u6E05 node_modules/.vite \u540E\u9996\u8F6E 30~60s \u5185\uFF0C\u8054\u90A6\u6A21\u5757\u8BF7\u6C42\u53EF\u80FD\u51FA\u73B0\u77AC\u65F6 504 / "ce" / Outdated Optimize Dep',
|
|
1548
|
-
cause: "vite \u4F9D\u8D56\u9884\u6784\u5EFA\uFF08\u542B
|
|
1548
|
+
cause: "vite \u4F9D\u8D56\u9884\u6784\u5EFA\uFF08\u542B fulgurjs \u5916\u90E8\u5316\u6869\uFF09\u5C1A\u672A\u5C31\u7EEA\uFF0C\u5C5E\u9884\u6784\u5EFA\u6682\u6001\u800C\u975E\u56DE\u5F52\uFF1B\u9996\u8F6E\u7ED3\u675F\u540E\u81EA\u884C\u6062\u590D",
|
|
1549
1549
|
fix: "\u5148\u771F\u5B9E\u6253\u5F00\u4E00\u6B21\u9875\u9762\u9884\u70ED\uFF08\u7B49\u5230\u7F51\u7EDC\u7A7A\u95F2\uFF09\uFF0C\u518D\u505A\u9A8C\u6536\u65AD\u8A00\u6216\u4EBA\u5DE5\u5224\u65AD\uFF1B\u91CD\u590D\u51FA\u73B0\u624D\u6309 DEV-009 \u6E05\u7F13\u5B58\u6392\u67E5"
|
|
1550
1550
|
})
|
|
1551
1551
|
);
|
|
@@ -1555,7 +1555,7 @@ ${code}`, map: null };
|
|
|
1555
1555
|
server.middlewares.use((req, res, next) => {
|
|
1556
1556
|
const raw = (req.url ?? "").split("?")[0];
|
|
1557
1557
|
const stripped = raw.startsWith(baseNorm) ? `/${raw.slice(baseNorm.length)}` : raw;
|
|
1558
|
-
if (stripped === "/@
|
|
1558
|
+
if (stripped === "/@fulgurjs-entry.js" || stripped === "/@fulgurjs-manifest.json") {
|
|
1559
1559
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
1560
1560
|
res.setHeader("Access-Control-Allow-Methods", "GET,OPTIONS");
|
|
1561
1561
|
res.setHeader("Access-Control-Allow-Headers", "*");
|
|
@@ -1564,7 +1564,7 @@ ${code}`, map: null };
|
|
|
1564
1564
|
res.end();
|
|
1565
1565
|
return;
|
|
1566
1566
|
}
|
|
1567
|
-
if (stripped === "/@
|
|
1567
|
+
if (stripped === "/@fulgurjs-entry.js") {
|
|
1568
1568
|
res.setHeader("Content-Type", "application/javascript; charset=utf-8");
|
|
1569
1569
|
res.setHeader("Cache-Control", "no-cache");
|
|
1570
1570
|
res.end(genDevRemoteEntry(n, baseNorm));
|
|
@@ -1594,10 +1594,10 @@ ${code}`, map: null };
|
|
|
1594
1594
|
return () => {
|
|
1595
1595
|
server.middlewares.use((req, res, next) => {
|
|
1596
1596
|
const url = req.url ?? "";
|
|
1597
|
-
if (req.method === "GET" && url.includes("
|
|
1597
|
+
if (req.method === "GET" && url.includes("fulgurjs")) {
|
|
1598
1598
|
res.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" });
|
|
1599
1599
|
res.end(
|
|
1600
|
-
|
|
1600
|
+
formatFulgurjsDiagnostic({
|
|
1601
1601
|
code: "DEV-009",
|
|
1602
1602
|
symptom: `\u8054\u90A6\u6A21\u5757\u8BF7\u6C42 404\uFF1A${url.slice(0, 120)}`,
|
|
1603
1603
|
cause: "node_modules/.vite \u9884\u6784\u5EFA\u7F13\u5B58\u4E0E\u5F53\u524D\u63D2\u4EF6\u4EA7\u7269\u4E0D\u4E00\u81F4\uFF08immutable \u7F13\u5B58\u6309 ?f= \u7B7E\u540D\u957F\u671F\u6301\u6709\uFF0C\u63D2\u4EF6 dist \u66F4\u65B0\u540E\u65E7\u7B7E\u540D\u5FC5 404\uFF09",
|
|
@@ -1612,15 +1612,15 @@ ${code}`, map: null };
|
|
|
1612
1612
|
}
|
|
1613
1613
|
};
|
|
1614
1614
|
const post = {
|
|
1615
|
-
name: "
|
|
1615
|
+
name: "fulgurjs:vue-post",
|
|
1616
1616
|
enforce: "post",
|
|
1617
1617
|
async transform(code, id) {
|
|
1618
1618
|
if (!state.normalized) return null;
|
|
1619
1619
|
const clean = id.split("?")[0];
|
|
1620
|
-
if (state.command === "serve" && code.includes("virtual:
|
|
1621
|
-
return { code: code.split("virtual:
|
|
1620
|
+
if (state.command === "serve" && code.includes("virtual:fulgurjs-runtime") && !code.includes("virtual:fulgurjs-runtime-proxy") && isExposeTargetFile(clean, state.normalized.root, state.normalized.exposes)) {
|
|
1621
|
+
return { code: code.split("virtual:fulgurjs-runtime").join("virtual:fulgurjs-runtime-proxy"), map: null };
|
|
1622
1622
|
}
|
|
1623
|
-
if (code.includes("virtual:
|
|
1623
|
+
if (code.includes("virtual:fulgurjs-runtime")) return null;
|
|
1624
1624
|
if (state.command === "build" && !/\.vue(\?|$)/.test(id)) return null;
|
|
1625
1625
|
if (/type=(style|template)/.test(id)) return null;
|
|
1626
1626
|
const isJsLike = /\.(m|c)?[jt]sx?$/.test(clean) || clean.endsWith(".vue");
|