@jami-studio/core 0.92.27 → 0.92.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +17 -0
- package/corpus/core/package.json +2 -1
- package/corpus/core/src/deploy/build.ts +56 -2
- package/corpus/core/src/event-bus/bus.ts +138 -140
- package/corpus/core/src/event-bus/registry.ts +81 -79
- package/corpus/core/src/file-upload/registry.ts +135 -125
- package/corpus/core/src/notifications/registry.ts +218 -216
- package/corpus/core/src/private-blob/registry.ts +246 -242
- package/corpus/core/src/secrets/register.ts +132 -129
- package/corpus/core/src/shared/global-scope.ts +75 -0
- package/corpus/core/src/sharing/registry.ts +193 -194
- package/corpus/core/src/tracking/providers.ts +425 -422
- package/corpus/core/src/tracking/registry.ts +102 -102
- package/dist/collab/routes.d.ts +1 -1
- package/dist/deploy/build.d.ts +23 -0
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +36 -2
- package/dist/deploy/build.js.map +1 -1
- package/dist/event-bus/bus.d.ts.map +1 -1
- package/dist/event-bus/bus.js +8 -6
- package/dist/event-bus/bus.js.map +1 -1
- package/dist/event-bus/registry.d.ts.map +1 -1
- package/dist/event-bus/registry.js +10 -6
- package/dist/event-bus/registry.js.map +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/file-upload/registry.d.ts.map +1 -1
- package/dist/file-upload/registry.js +28 -8
- package/dist/file-upload/registry.js.map +1 -1
- package/dist/notifications/registry.d.ts.map +1 -1
- package/dist/notifications/registry.js +6 -5
- package/dist/notifications/registry.js.map +1 -1
- package/dist/observability/routes.d.ts +5 -5
- package/dist/private-blob/registry.d.ts.map +1 -1
- package/dist/private-blob/registry.js +18 -13
- package/dist/private-blob/registry.js.map +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +2 -2
- package/dist/secrets/register.d.ts.map +1 -1
- package/dist/secrets/register.js +11 -7
- package/dist/secrets/register.js.map +1 -1
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/shared/global-scope.d.ts +55 -0
- package/dist/shared/global-scope.d.ts.map +1 -0
- package/dist/shared/global-scope.js +70 -0
- package/dist/shared/global-scope.js.map +1 -0
- package/dist/sharing/registry.d.ts.map +1 -1
- package/dist/sharing/registry.js +2 -16
- package/dist/sharing/registry.js.map +1 -1
- package/dist/tracking/providers.d.ts.map +1 -1
- package/dist/tracking/providers.js +11 -9
- package/dist/tracking/providers.js.map +1 -1
- package/dist/tracking/registry.d.ts.map +1 -1
- package/dist/tracking/registry.js +5 -5
- package/dist/tracking/registry.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function registerTrackingProvider(provider: TrackingProvider): void {
|
|
15
|
-
if (!provider?.name) {
|
|
16
|
-
throw new Error("registerTrackingProvider: provider.name is required");
|
|
17
|
-
}
|
|
18
|
-
if (typeof provider.track !== "function") {
|
|
19
|
-
throw new Error(
|
|
20
|
-
"registerTrackingProvider: provider.track must be a function",
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
getRegistry().set(provider.name, provider);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function unregisterTrackingProvider(name: string): boolean {
|
|
27
|
-
return getRegistry().delete(name);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function listTrackingProviders(): string[] {
|
|
31
|
-
return Array.from(getRegistry().keys());
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function track(
|
|
35
|
-
name: string,
|
|
36
|
-
properties?: Record<string, unknown>,
|
|
37
|
-
meta?: { userId?: string },
|
|
38
|
-
): void {
|
|
39
|
-
const event: TrackingEvent = {
|
|
40
|
-
name,
|
|
41
|
-
properties,
|
|
42
|
-
timestamp: new Date().toISOString(),
|
|
43
|
-
userId: meta?.userId,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
for (const provider of getRegistry().values()) {
|
|
47
|
-
try {
|
|
48
|
-
const result = provider.track(event);
|
|
49
|
-
if (result && typeof (result as Promise<void>).catch === "function") {
|
|
50
|
-
(result as Promise<void>).catch((err) => {
|
|
51
|
-
console.error(
|
|
52
|
-
`[tracking] Provider "${provider.name}" rejected:`,
|
|
53
|
-
err,
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
} catch (err) {
|
|
58
|
-
console.error(`[tracking] Provider "${provider.name}" threw:`, err);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function identify(
|
|
64
|
-
userId: string,
|
|
65
|
-
traits?: Record<string, unknown>,
|
|
66
|
-
): void {
|
|
67
|
-
for (const provider of getRegistry().values()) {
|
|
68
|
-
if (!provider.identify) continue;
|
|
69
|
-
try {
|
|
70
|
-
const result = provider.identify(userId, traits);
|
|
71
|
-
if (result && typeof (result as Promise<void>).catch === "function") {
|
|
72
|
-
(result as Promise<void>).catch(() => {});
|
|
73
|
-
}
|
|
74
|
-
} catch {
|
|
75
|
-
// best-effort
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function flushTracking(): Promise<void[]> {
|
|
81
|
-
const promises: Promise<void>[] = [];
|
|
82
|
-
for (const provider of getRegistry().values()) {
|
|
83
|
-
if (!provider.flush) continue;
|
|
84
|
-
try {
|
|
85
|
-
const result = provider.flush();
|
|
86
|
-
if (result) {
|
|
87
|
-
promises.push(
|
|
88
|
-
result.catch((err) => {
|
|
89
|
-
console.error(
|
|
90
|
-
`[tracking] Provider "${provider.name}" flush rejected:`,
|
|
91
|
-
err,
|
|
92
|
-
);
|
|
93
|
-
}),
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
} catch (err) {
|
|
97
|
-
console.error(`[tracking] Provider "${provider.name}" flush threw:`, err);
|
|
98
|
-
// best-effort
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return Promise.all(promises);
|
|
102
|
-
}
|
|
1
|
+
import { getScopedGlobal } from "../shared/global-scope.js";
|
|
2
|
+
import type { TrackingProvider, TrackingEvent } from "./types.js";
|
|
3
|
+
|
|
4
|
+
// globalThis-pinned so one app's ESM graphs share one provider registry, but
|
|
5
|
+
// scope-aware + lazily resolved so unified workspace deployments (all apps in
|
|
6
|
+
// one isolate) keep per-app tracking providers. See shared/global-scope.
|
|
7
|
+
function getRegistry(): Map<string, TrackingProvider> {
|
|
8
|
+
return getScopedGlobal(
|
|
9
|
+
"agent-native.tracking.registry",
|
|
10
|
+
() => new Map<string, TrackingProvider>(),
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function registerTrackingProvider(provider: TrackingProvider): void {
|
|
15
|
+
if (!provider?.name) {
|
|
16
|
+
throw new Error("registerTrackingProvider: provider.name is required");
|
|
17
|
+
}
|
|
18
|
+
if (typeof provider.track !== "function") {
|
|
19
|
+
throw new Error(
|
|
20
|
+
"registerTrackingProvider: provider.track must be a function",
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
getRegistry().set(provider.name, provider);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function unregisterTrackingProvider(name: string): boolean {
|
|
27
|
+
return getRegistry().delete(name);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function listTrackingProviders(): string[] {
|
|
31
|
+
return Array.from(getRegistry().keys());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function track(
|
|
35
|
+
name: string,
|
|
36
|
+
properties?: Record<string, unknown>,
|
|
37
|
+
meta?: { userId?: string },
|
|
38
|
+
): void {
|
|
39
|
+
const event: TrackingEvent = {
|
|
40
|
+
name,
|
|
41
|
+
properties,
|
|
42
|
+
timestamp: new Date().toISOString(),
|
|
43
|
+
userId: meta?.userId,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
for (const provider of getRegistry().values()) {
|
|
47
|
+
try {
|
|
48
|
+
const result = provider.track(event);
|
|
49
|
+
if (result && typeof (result as Promise<void>).catch === "function") {
|
|
50
|
+
(result as Promise<void>).catch((err) => {
|
|
51
|
+
console.error(
|
|
52
|
+
`[tracking] Provider "${provider.name}" rejected:`,
|
|
53
|
+
err,
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error(`[tracking] Provider "${provider.name}" threw:`, err);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function identify(
|
|
64
|
+
userId: string,
|
|
65
|
+
traits?: Record<string, unknown>,
|
|
66
|
+
): void {
|
|
67
|
+
for (const provider of getRegistry().values()) {
|
|
68
|
+
if (!provider.identify) continue;
|
|
69
|
+
try {
|
|
70
|
+
const result = provider.identify(userId, traits);
|
|
71
|
+
if (result && typeof (result as Promise<void>).catch === "function") {
|
|
72
|
+
(result as Promise<void>).catch(() => {});
|
|
73
|
+
}
|
|
74
|
+
} catch {
|
|
75
|
+
// best-effort
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function flushTracking(): Promise<void[]> {
|
|
81
|
+
const promises: Promise<void>[] = [];
|
|
82
|
+
for (const provider of getRegistry().values()) {
|
|
83
|
+
if (!provider.flush) continue;
|
|
84
|
+
try {
|
|
85
|
+
const result = provider.flush();
|
|
86
|
+
if (result) {
|
|
87
|
+
promises.push(
|
|
88
|
+
result.catch((err) => {
|
|
89
|
+
console.error(
|
|
90
|
+
`[tracking] Provider "${provider.name}" flush rejected:`,
|
|
91
|
+
err,
|
|
92
|
+
);
|
|
93
|
+
}),
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
} catch (err) {
|
|
97
|
+
console.error(`[tracking] Provider "${provider.name}" flush threw:`, err);
|
|
98
|
+
// best-effort
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return Promise.all(promises);
|
|
102
|
+
}
|
package/dist/collab/routes.d.ts
CHANGED
|
@@ -26,8 +26,8 @@ export declare const getCollabState: import("h3").EventHandlerWithFetch<import("
|
|
|
26
26
|
* Body: { update: string (base64), requestSource?: string }
|
|
27
27
|
*/
|
|
28
28
|
export declare const postCollabUpdate: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
29
|
-
error: string;
|
|
30
29
|
ok?: undefined;
|
|
30
|
+
error: string;
|
|
31
31
|
} | {
|
|
32
32
|
error?: undefined;
|
|
33
33
|
ok: boolean;
|
package/dist/deploy/build.d.ts
CHANGED
|
@@ -30,7 +30,30 @@ export declare function uninstalledOptionalAiSdkStubs(appDir: string): Record<st
|
|
|
30
30
|
export declare const CLOUDFLARE_WORKER_NODE_BUILTIN_STUB_MODULES: Record<string, string>;
|
|
31
31
|
export interface GenerateWorkerEntryOptions {
|
|
32
32
|
includeReactRouterSsr?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Per-app global-registry scope id for unified workspace deployments.
|
|
35
|
+
* When set, the generated entry's FIRST import is `./_scope-init.js`
|
|
36
|
+
* (written by the build via `generateScopeInitSource`), which calls
|
|
37
|
+
* core's `setGlobalScopeId(appId)` before any other module in the app
|
|
38
|
+
* bundle evaluates — so every globalThis-pinned registry in this app's
|
|
39
|
+
* module graph resolves per-app keys instead of colliding with sibling
|
|
40
|
+
* apps in the shared isolate (issue: /assets uploads served by clips'
|
|
41
|
+
* provider).
|
|
42
|
+
*/
|
|
43
|
+
appScopeId?: string | null;
|
|
33
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Source of the `_scope-init.js` module the worker entry imports first on
|
|
47
|
+
* unified workspace deployments. Must stay dependency-free beyond core's
|
|
48
|
+
* lean `global-scope` subpath so nothing registry-touching evaluates before
|
|
49
|
+
* the scope id is set (ESM evaluates imports depth-first in order).
|
|
50
|
+
*/
|
|
51
|
+
export declare function generateScopeInitSource(appScopeId: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Derive the workspace app id from a mounted app base path ("/assets" →
|
|
54
|
+
* "assets"). Returns null for unmounted (root) builds.
|
|
55
|
+
*/
|
|
56
|
+
export declare function workspaceAppScopeIdFromBasePath(basePath: string | undefined): string | null;
|
|
34
57
|
interface ReactRouterAssetManifest {
|
|
35
58
|
entry: ReactRouterAssetManifestEntry;
|
|
36
59
|
routes: Record<string, ReactRouterAssetManifestRoute>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/deploy/build.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG;AAmCH,OAAO,EAML,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,6BAA6B,UAiBzC,CAAC;AAEF,eAAO,MAAM,mCAAmC,UAiB/C,CAAC;AACF,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAuIjE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,UAUnC,CAAC;AAEF,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAaxB;AAoCD,eAAO,MAAM,2CAA2C,EAAE,MAAM,CAC9D,MAAM,EACN,MAAM,CAmSP,CAAC;AAEF,MAAM,WAAW,0BAA0B;IACzC,qBAAqB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/deploy/build.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG;AAmCH,OAAO,EAML,K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UAAU,EAAE,MAAM,GAAG,IAAI,CAY5E;AA6GD;;;;;;GAMG;AACH,wBAAgB,yCAAyC,CACvD,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,IAAI,CAqDN;AA6ID;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,gBAAgB,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,UAAU,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,EAAE,eAAe,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAkBD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iCAAiC,YAAI,KAAK,CAAU,CAAC;AAElE;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,MAAM,GACnB,IAAI,GAAG,SAAS,MAAM,EAAE,CAK1B"}
|
package/dist/deploy/build.js
CHANGED
|
@@ -517,6 +517,32 @@ export const CLOUDFLARE_WORKER_NODE_BUILTIN_STUB_MODULES = {
|
|
|
517
517
|
wasi: cloudflareNodeBuiltinStubSource("wasi", ["WASI"]),
|
|
518
518
|
worker_threads: cloudflareNodeBuiltinStubSource("worker_threads", ["MessageChannel", "MessagePort", "Worker", "isMainThread", "parentPort"], ["export const isMainThread = true;", "export const parentPort = null;"]),
|
|
519
519
|
};
|
|
520
|
+
/**
|
|
521
|
+
* Source of the `_scope-init.js` module the worker entry imports first on
|
|
522
|
+
* unified workspace deployments. Must stay dependency-free beyond core's
|
|
523
|
+
* lean `global-scope` subpath so nothing registry-touching evaluates before
|
|
524
|
+
* the scope id is set (ESM evaluates imports depth-first in order).
|
|
525
|
+
*/
|
|
526
|
+
export function generateScopeInitSource(appScopeId) {
|
|
527
|
+
return `// AUTO-GENERATED by @agent-native/core deploy build
|
|
528
|
+
// Scope globalThis-pinned framework registries to this app's module graph.
|
|
529
|
+
// Evaluated FIRST in the worker entry's import graph so the scope is set
|
|
530
|
+
// before any registry module initializes. See core shared/global-scope.
|
|
531
|
+
import { setGlobalScopeId } from "@agent-native/core/global-scope";
|
|
532
|
+
setGlobalScopeId(${JSON.stringify(appScopeId)});
|
|
533
|
+
`;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Derive the workspace app id from a mounted app base path ("/assets" →
|
|
537
|
+
* "assets"). Returns null for unmounted (root) builds.
|
|
538
|
+
*/
|
|
539
|
+
export function workspaceAppScopeIdFromBasePath(basePath) {
|
|
540
|
+
const normalized = normalizeAppBasePath(basePath ?? "");
|
|
541
|
+
if (!normalized)
|
|
542
|
+
return null;
|
|
543
|
+
const [first] = normalized.slice(1).split("/");
|
|
544
|
+
return first || null;
|
|
545
|
+
}
|
|
520
546
|
function normalizeConfiguredAppBasePath() {
|
|
521
547
|
return normalizeAppBasePath(process.env.VITE_APP_BASE_PATH || process.env.APP_BASE_PATH);
|
|
522
548
|
}
|
|
@@ -589,6 +615,7 @@ export function addImmutableAssetRouteRulesForClientBuild(routeRules, clientDir,
|
|
|
589
615
|
*/
|
|
590
616
|
export function generateWorkerEntry(routes, pluginPaths, defaultPluginStems = [], actions = [], workspaceCore = null, immutableAssetPaths = [], builtAppBasePath = normalizeConfiguredAppBasePath(), options = {}) {
|
|
591
617
|
const includeReactRouterSsr = options.includeReactRouterSsr ?? true;
|
|
618
|
+
const appScopeId = options.appScopeId ?? null;
|
|
592
619
|
const routeImports = [];
|
|
593
620
|
const routeRegistrations = [];
|
|
594
621
|
for (let i = 0; i < routes.length; i++) {
|
|
@@ -684,7 +711,7 @@ export function generateWorkerEntry(routes, pluginPaths, defaultPluginStems = []
|
|
|
684
711
|
}
|
|
685
712
|
return `
|
|
686
713
|
// Auto-generated worker entry point for ${preset}
|
|
687
|
-
import { H3, defineEventHandler, readBody, toResponse } from "h3";
|
|
714
|
+
${appScopeId ? 'import "./_scope-init.js";\n' : ""}import { H3, defineEventHandler, readBody, toResponse } from "h3";
|
|
688
715
|
${includeReactRouterSsr ? 'import { createRequestHandler } from "react-router";' : ""}
|
|
689
716
|
${includeReactRouterSsr ? 'import * as serverBuild from "./server-build.js";' : ""}
|
|
690
717
|
|
|
@@ -1400,7 +1427,11 @@ async function buildCloudflarePages() {
|
|
|
1400
1427
|
console.log(`[deploy] ${routes.length} API routes, ${actions.length} actions, ${plugins.length} plugins (${plugins.filter((p) => isNodeOnlyPlugin(p)).length} skipped as Node-only), ${missingDefaults.length} auto-mounted defaults${workspaceCore ? `, workspace-core ${workspaceCore.packageName} (${workspaceSlotCount} plugin slots)` : ""}`);
|
|
1401
1428
|
// Generate the worker entry
|
|
1402
1429
|
const immutableAssetPaths = collectImmutableAssetPaths(clientDir);
|
|
1403
|
-
|
|
1430
|
+
// Per-app global-registry scoping for unified workspace deploys: mounted
|
|
1431
|
+
// builds (APP_BASE_PATH=/<app>) get a scope-init module evaluated first so
|
|
1432
|
+
// globalThis-pinned registries stay per-app in the shared isolate.
|
|
1433
|
+
const appScopeId = workspaceAppScopeIdFromBasePath(normalizeConfiguredAppBasePath());
|
|
1434
|
+
const entrySource = generateWorkerEntry(routes, plugins, missingDefaults, actions, workspaceCore, immutableAssetPaths, normalizeConfiguredAppBasePath(), { includeReactRouterSsr, appScopeId });
|
|
1404
1435
|
// Create _worker.js output directory
|
|
1405
1436
|
const workerOutDir = path.join(distDir, "_worker.js");
|
|
1406
1437
|
fs.mkdirSync(workerOutDir, { recursive: true });
|
|
@@ -1419,6 +1450,9 @@ async function buildCloudflarePages() {
|
|
|
1419
1450
|
// matching the _worker.js/index.js entry point that Cloudflare Pages expects.
|
|
1420
1451
|
const tmpEntry = path.join(tmpDir, "index.js");
|
|
1421
1452
|
fs.writeFileSync(tmpEntry, adjustedEntry);
|
|
1453
|
+
if (appScopeId) {
|
|
1454
|
+
fs.writeFileSync(path.join(tmpDir, "_scope-init.js"), generateScopeInitSource(appScopeId));
|
|
1455
|
+
}
|
|
1422
1456
|
if (includeReactRouterSsr) {
|
|
1423
1457
|
copyDir(serverDir, path.join(tmpDir, "server"));
|
|
1424
1458
|
}
|