@bleedingdev/modern-js-app-tools 3.5.0-ultramodern.30 → 3.5.0-ultramodern.32

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.
Files changed (116) hide show
  1. package/dist/cjs/plugins/backend-federation/codegen.js +208 -0
  2. package/dist/cjs/plugins/backend-federation/config.js +217 -0
  3. package/dist/cjs/plugins/backend-federation/emit.js +139 -0
  4. package/dist/cjs/plugins/backendFederationBuild.js +4 -298
  5. package/dist/cjs/plugins/deploy/platforms/cloudflare/artifacts.js +127 -0
  6. package/dist/cjs/plugins/deploy/platforms/cloudflare/constants.js +137 -0
  7. package/dist/cjs/plugins/deploy/platforms/cloudflare/delivery-unit.js +118 -0
  8. package/dist/cjs/plugins/deploy/platforms/cloudflare/i18n-worker.js +135 -0
  9. package/dist/cjs/plugins/deploy/platforms/cloudflare/index.js +126 -0
  10. package/dist/cjs/plugins/deploy/platforms/cloudflare/security-policies.js +223 -0
  11. package/dist/cjs/plugins/deploy/platforms/cloudflare/types.js +18 -0
  12. package/dist/cjs/plugins/deploy/platforms/cloudflare/utils.js +66 -0
  13. package/dist/cjs/plugins/deploy/platforms/cloudflare/worker-manifest.js +178 -0
  14. package/dist/cjs/plugins/deploy/platforms/cloudflare/wrangler-config.js +189 -0
  15. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/identity.js +83 -0
  16. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js +184 -0
  17. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/issues.js +54 -0
  18. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/manifest.js +83 -0
  19. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.js +158 -0
  20. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.js +137 -0
  21. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier.js +23 -363
  22. package/dist/cjs/plugins/deploy/platforms/cloudflare.js +2 -745
  23. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +22 -0
  24. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -0
  25. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -0
  26. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -0
  27. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -0
  28. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +32 -0
  29. package/dist/esm/plugins/backend-federation/codegen.mjs +157 -0
  30. package/dist/esm/plugins/backend-federation/config.mjs +141 -0
  31. package/dist/esm/plugins/backend-federation/emit.mjs +88 -0
  32. package/dist/esm/plugins/backendFederationBuild.mjs +1 -296
  33. package/dist/esm/plugins/deploy/platforms/cloudflare/artifacts.mjs +64 -0
  34. package/dist/esm/plugins/deploy/platforms/cloudflare/constants.mjs +33 -0
  35. package/dist/esm/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +67 -0
  36. package/dist/esm/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +97 -0
  37. package/dist/esm/plugins/deploy/platforms/cloudflare/index.mjs +78 -0
  38. package/dist/esm/plugins/deploy/platforms/cloudflare/security-policies.mjs +167 -0
  39. package/dist/esm/plugins/deploy/platforms/cloudflare/types.mjs +0 -0
  40. package/dist/esm/plugins/deploy/platforms/cloudflare/utils.mjs +12 -0
  41. package/dist/esm/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +118 -0
  42. package/dist/esm/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +135 -0
  43. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +45 -0
  44. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +129 -0
  45. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +10 -0
  46. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +45 -0
  47. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +97 -0
  48. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +68 -0
  49. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier.mjs +1 -347
  50. package/dist/esm/plugins/deploy/platforms/cloudflare.mjs +1 -735
  51. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +22 -0
  52. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -0
  53. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -0
  54. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -0
  55. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -0
  56. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +32 -0
  57. package/dist/esm-node/plugins/backend-federation/codegen.mjs +158 -0
  58. package/dist/esm-node/plugins/backend-federation/config.mjs +142 -0
  59. package/dist/esm-node/plugins/backend-federation/emit.mjs +89 -0
  60. package/dist/esm-node/plugins/backendFederationBuild.mjs +1 -296
  61. package/dist/esm-node/plugins/deploy/platforms/cloudflare/artifacts.mjs +65 -0
  62. package/dist/esm-node/plugins/deploy/platforms/cloudflare/constants.mjs +34 -0
  63. package/dist/esm-node/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +68 -0
  64. package/dist/esm-node/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +98 -0
  65. package/dist/esm-node/plugins/deploy/platforms/cloudflare/index.mjs +79 -0
  66. package/dist/esm-node/plugins/deploy/platforms/cloudflare/security-policies.mjs +168 -0
  67. package/dist/esm-node/plugins/deploy/platforms/cloudflare/types.mjs +1 -0
  68. package/dist/esm-node/plugins/deploy/platforms/cloudflare/utils.mjs +13 -0
  69. package/dist/esm-node/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +119 -0
  70. package/dist/esm-node/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +136 -0
  71. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +46 -0
  72. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +130 -0
  73. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +11 -0
  74. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +46 -0
  75. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +98 -0
  76. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +69 -0
  77. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier.mjs +1 -347
  78. package/dist/esm-node/plugins/deploy/platforms/cloudflare.mjs +1 -735
  79. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +22 -0
  80. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +0 -0
  81. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +0 -0
  82. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +0 -0
  83. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +0 -0
  84. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +32 -0
  85. package/dist/types/plugins/backend-federation/codegen.d.ts +82 -0
  86. package/dist/types/plugins/backend-federation/config.d.ts +103 -0
  87. package/dist/types/plugins/backend-federation/emit.d.ts +13 -0
  88. package/dist/types/plugins/backendFederationBuild.d.ts +2 -11
  89. package/dist/types/plugins/deploy/platforms/cloudflare/artifacts.d.ts +15 -0
  90. package/dist/types/plugins/deploy/platforms/cloudflare/constants.d.ts +23 -0
  91. package/dist/types/plugins/deploy/platforms/cloudflare/delivery-unit.d.ts +23 -0
  92. package/dist/types/plugins/deploy/platforms/cloudflare/i18n-worker.d.ts +21 -0
  93. package/dist/types/plugins/deploy/platforms/cloudflare/index.d.ts +2 -0
  94. package/dist/types/plugins/deploy/platforms/cloudflare/security-policies.d.ts +88 -0
  95. package/dist/types/plugins/deploy/platforms/cloudflare/types.d.ts +5 -0
  96. package/dist/types/plugins/deploy/platforms/cloudflare/utils.d.ts +6 -0
  97. package/dist/types/plugins/deploy/platforms/cloudflare/worker-manifest.d.ts +100 -0
  98. package/dist/types/plugins/deploy/platforms/cloudflare/wrangler-config.d.ts +39 -0
  99. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/identity.d.ts +4 -0
  100. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/index.d.ts +18 -0
  101. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/issues.d.ts +14 -0
  102. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/manifest.d.ts +2 -0
  103. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.d.ts +13 -0
  104. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.d.ts +16 -0
  105. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier.d.ts +1 -32
  106. package/dist/types/plugins/deploy/platforms/cloudflare.d.ts +1 -2
  107. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.d.mts +1 -0
  108. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.d.mts +1 -0
  109. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.d.mts +1 -0
  110. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.d.mts +1 -0
  111. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.d.mts +1 -0
  112. package/package.json +11 -11
  113. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -879
  114. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -879
  115. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -879
  116. /package/dist/types/plugins/deploy/platforms/templates/{cloudflare-entry.d.mts → cloudflare-entry.006-fetch-handler.d.mts} +0 -0
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, getters, values)=>{
14
+ var define = (defs, kind)=>{
15
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
+ enumerable: true,
17
+ [kind]: defs[key]
18
+ });
19
+ };
20
+ define(getters, "get");
21
+ define(values, "value");
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
+ })();
27
+ (()=>{
28
+ __webpack_require__.r = (exports1)=>{
29
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
+ value: 'Module'
31
+ });
32
+ Object.defineProperty(exports1, '__esModule', {
33
+ value: true
34
+ });
35
+ };
36
+ })();
37
+ var __webpack_exports__ = {};
38
+ __webpack_require__.r(__webpack_exports__);
39
+ __webpack_require__.d(__webpack_exports__, {
40
+ isJsonRecord: ()=>isJsonRecord,
41
+ isRecord: ()=>isRecord,
42
+ normalizeRelativePath: ()=>normalizeRelativePath
43
+ });
44
+ const external_node_path_namespaceObject = require("node:path");
45
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
46
+ const isRecord = (value)=>null !== value && 'object' == typeof value && !Array.isArray(value);
47
+ const normalizeRelativePath = (value, label, scope = 'app output', options = {})=>{
48
+ if ('string' != typeof value) throw new Error(`${label} must be a relative path inside the ${scope}.`);
49
+ const normalized = value.trim().replace(/\\/g, '/').replace(/^\.\/+/u, '').replace(/\/+$/u, '');
50
+ const segments = normalized.split('/');
51
+ const isRootDestination = '.' === normalized;
52
+ if (!normalized || external_node_path_default().isAbsolute(normalized) || !options.allowRoot && isRootDestination || segments.includes('..')) throw new Error(`${label} must be a relative path inside the ${scope}.`);
53
+ return normalized;
54
+ };
55
+ const isJsonRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
56
+ exports.isJsonRecord = __webpack_exports__.isJsonRecord;
57
+ exports.isRecord = __webpack_exports__.isRecord;
58
+ exports.normalizeRelativePath = __webpack_exports__.normalizeRelativePath;
59
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
60
+ "isJsonRecord",
61
+ "isRecord",
62
+ "normalizeRelativePath"
63
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
64
+ Object.defineProperty(exports, '__esModule', {
65
+ value: true
66
+ });
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, getters, values)=>{
14
+ var define = (defs, kind)=>{
15
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
+ enumerable: true,
17
+ [kind]: defs[key]
18
+ });
19
+ };
20
+ define(getters, "get");
21
+ define(values, "value");
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
+ })();
27
+ (()=>{
28
+ __webpack_require__.r = (exports1)=>{
29
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
+ value: 'Module'
31
+ });
32
+ Object.defineProperty(exports1, '__esModule', {
33
+ value: true
34
+ });
35
+ };
36
+ })();
37
+ var __webpack_exports__ = {};
38
+ __webpack_require__.r(__webpack_exports__);
39
+ __webpack_require__.d(__webpack_exports__, {
40
+ createWorkerManifest: ()=>createWorkerManifest,
41
+ createWorkerModuleLoaders: ()=>createWorkerModuleLoaders,
42
+ getPublicAssetExcludes: ()=>getPublicAssetExcludes,
43
+ shouldCopyToPublicAssets: ()=>shouldCopyToPublicAssets,
44
+ shouldCopyToWorkerBundle: ()=>shouldCopyToWorkerBundle
45
+ });
46
+ const external_node_path_namespaceObject = require("node:path");
47
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
48
+ const utils_namespaceObject = require("@modern-js/utils");
49
+ const external_artifacts_js_namespaceObject = require("./artifacts.js");
50
+ const external_constants_js_namespaceObject = require("./constants.js");
51
+ const external_i18n_worker_js_namespaceObject = require("./i18n-worker.js");
52
+ const external_security_policies_js_namespaceObject = require("./security-policies.js");
53
+ const external_utils_js_namespaceObject = require("./utils.js");
54
+ const external_wrangler_config_js_namespaceObject = require("./wrangler-config.js");
55
+ const createMissingEffectBffWorkerError = (outputDirectory, worker)=>new Error(`Cloudflare Effect API runtime is configured, but the BFF worker bundle is missing: ${external_node_path_default().join(outputDirectory, worker)}. ${external_constants_js_namespaceObject.EFFECT_BFF_CLOUDFLARE_IMPORT_GUIDANCE}`);
56
+ const createWorkerManifest = async (outputDirectory, modernConfig, appContext, deliveryUnitStamp)=>{
57
+ const routeSpec = await (0, external_artifacts_js_namespaceObject.readRouteSpec)(outputDirectory);
58
+ const routes = await Promise.all(routeSpec.routes.map(async (route)=>{
59
+ const worker = 'string' == typeof route.worker ? route.worker : void 0;
60
+ return {
61
+ urlPath: route.urlPath,
62
+ entryName: route.entryName,
63
+ entryPath: route.entryPath,
64
+ isSSR: Boolean(route.isSSR),
65
+ worker,
66
+ workerExists: worker ? await utils_namespaceObject.fs.pathExists(external_node_path_default().join(outputDirectory, worker)) : false
67
+ };
68
+ }));
69
+ const bffPrefix = modernConfig.bff?.prefix;
70
+ const primaryBffPrefix = Array.isArray(bffPrefix) ? bffPrefix[0] : bffPrefix;
71
+ const isEffectApi = Boolean(modernConfig.bff) && modernConfig.bff?.runtimeFramework !== 'hono';
72
+ const effectApiWorkerExists = await utils_namespaceObject.fs.pathExists(external_node_path_default().join(outputDirectory, external_constants_js_namespaceObject.BFF_EFFECT_WORKER_ENTRY));
73
+ const serviceBindings = (0, external_wrangler_config_js_namespaceObject.createWorkerManifestServiceBindings)((0, external_wrangler_config_js_namespaceObject.createWorkerServiceBindings)(modernConfig, void 0));
74
+ if (isEffectApi && primaryBffPrefix && !effectApiWorkerExists) throw createMissingEffectBffWorkerError(outputDirectory, external_constants_js_namespaceObject.BFF_EFFECT_WORKER_ENTRY);
75
+ return {
76
+ version: 1,
77
+ runtime: {
78
+ type: external_constants_js_namespaceObject.CLOUDFLARE_RUNTIME_TYPE,
79
+ entry: external_constants_js_namespaceObject.WORKER_ENTRY,
80
+ fetchExport: true,
81
+ nodeListen: false
82
+ },
83
+ assets: {
84
+ binding: external_constants_js_namespaceObject.ASSETS_BINDING,
85
+ directory: `./${external_constants_js_namespaceObject.PUBLIC_ASSETS_DIRECTORY}`,
86
+ runWorkerFirst: true
87
+ },
88
+ routeSpec: {
89
+ file: external_constants_js_namespaceObject.ROUTE_SPEC_OUTPUT,
90
+ routes
91
+ },
92
+ workerBundles: {
93
+ directory: external_constants_js_namespaceObject.WORKER_BUNDLE_DIRECTORY,
94
+ format: external_constants_js_namespaceObject.CLOUDFLARE_WORKER_BUNDLE_FORMAT,
95
+ importableFromModuleWorker: true,
96
+ requestHandlerExport: 'requestHandler'
97
+ },
98
+ resources: {
99
+ loadableStats: external_constants_js_namespaceObject.LOADABLE_STATS_FILE,
100
+ routeManifest: external_constants_js_namespaceObject.ROUTE_MANIFEST_FILE
101
+ },
102
+ security: (0, external_security_policies_js_namespaceObject.createCloudflareWorkerSecurityPolicy)(modernConfig),
103
+ ...deliveryUnitStamp ? {
104
+ deliveryUnit: deliveryUnitStamp
105
+ } : {},
106
+ i18n: (0, external_i18n_worker_js_namespaceObject.createI18nWorkerManifest)(routeSpec, appContext),
107
+ bff: isEffectApi && primaryBffPrefix && effectApiWorkerExists ? {
108
+ runtimeFramework: 'effect',
109
+ prefix: primaryBffPrefix,
110
+ worker: external_constants_js_namespaceObject.BFF_EFFECT_WORKER_ENTRY
111
+ } : void 0,
112
+ ...void 0 === serviceBindings ? {} : {
113
+ serviceBindings
114
+ }
115
+ };
116
+ };
117
+ const createWorkerModuleLoaders = (manifest)=>{
118
+ const imports = new Map();
119
+ for (const route of manifest.routeSpec.routes)if (route.worker && route.workerExists) {
120
+ const importPath = `../${String(route.worker).replace(/^\/+/u, '')}`;
121
+ imports.set(route.worker, `() => import(${JSON.stringify(importPath)})`);
122
+ }
123
+ if (manifest.bff?.worker) {
124
+ const importPath = `../${String(manifest.bff.worker).replace(/^\/+/u, '')}`;
125
+ imports.set(manifest.bff.worker, `() => import(${JSON.stringify(importPath)})`);
126
+ }
127
+ if (0 === imports.size) return '{}';
128
+ const loaders = [
129
+ ...imports.entries()
130
+ ].map(([worker, loader])=>`${JSON.stringify(worker)}: ${loader}`);
131
+ return `{\n${loaders.join(',\n')}\n}`;
132
+ };
133
+ const getPublicAssetExcludes = (appDirectory, modernConfig)=>[
134
+ ...external_constants_js_namespaceObject.DEFAULT_SERVER_ONLY_PUBLIC_ASSET_EXCLUDES.filter((directory)=>{
135
+ try {
136
+ return utils_namespaceObject.fs.statSync(external_node_path_default().join(appDirectory, directory)).isDirectory();
137
+ } catch {
138
+ return false;
139
+ }
140
+ }),
141
+ ...modernConfig.deploy?.worker?.publicAssetExcludes ?? []
142
+ ].map((entry)=>(0, external_utils_js_namespaceObject.normalizeRelativePath)(entry, 'deploy.worker.publicAssetExcludes'));
143
+ const shouldCopyToPublicAssets = (src, distDirectory, publicAssetExcludes)=>{
144
+ const relativePath = external_node_path_default().relative(distDirectory, src);
145
+ if (!relativePath) return true;
146
+ const normalizedRelativePath = relativePath.replace(/\\/g, '/');
147
+ const [topLevelDirectory] = normalizedRelativePath.split('/');
148
+ const basename = normalizedRelativePath.split('/').pop() ?? '';
149
+ return normalizedRelativePath !== external_constants_js_namespaceObject.ROUTE_SPEC_FILE && topLevelDirectory !== external_constants_js_namespaceObject.WORKER_BUNDLE_DIRECTORY && topLevelDirectory !== external_constants_js_namespaceObject.SERVER_BUNDLE_DIRECTORY && '.env' !== basename && !basename.startsWith('.env.') && !publicAssetExcludes.some((exclude)=>normalizedRelativePath === exclude || normalizedRelativePath.startsWith(`${exclude}/`));
150
+ };
151
+ const shouldCopyToWorkerBundle = (src, workerBundleDirectory)=>{
152
+ const relativePath = external_node_path_default().relative(workerBundleDirectory, src);
153
+ if (!relativePath) return true;
154
+ const normalizedRelativePath = relativePath.replace(/\\/g, '/');
155
+ const basename = external_node_path_default().basename(normalizedRelativePath);
156
+ if (basename.startsWith('.') || normalizedRelativePath.includes('/.')) return false;
157
+ if (utils_namespaceObject.fs.statSync(src).isDirectory()) return true;
158
+ return [
159
+ '.cjs',
160
+ '.js',
161
+ '.mjs'
162
+ ].includes(external_node_path_default().extname(normalizedRelativePath));
163
+ };
164
+ exports.createWorkerManifest = __webpack_exports__.createWorkerManifest;
165
+ exports.createWorkerModuleLoaders = __webpack_exports__.createWorkerModuleLoaders;
166
+ exports.getPublicAssetExcludes = __webpack_exports__.getPublicAssetExcludes;
167
+ exports.shouldCopyToPublicAssets = __webpack_exports__.shouldCopyToPublicAssets;
168
+ exports.shouldCopyToWorkerBundle = __webpack_exports__.shouldCopyToWorkerBundle;
169
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
170
+ "createWorkerManifest",
171
+ "createWorkerModuleLoaders",
172
+ "getPublicAssetExcludes",
173
+ "shouldCopyToPublicAssets",
174
+ "shouldCopyToWorkerBundle"
175
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
176
+ Object.defineProperty(exports, '__esModule', {
177
+ value: true
178
+ });
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, getters, values)=>{
14
+ var define = (defs, kind)=>{
15
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
+ enumerable: true,
17
+ [kind]: defs[key]
18
+ });
19
+ };
20
+ define(getters, "get");
21
+ define(values, "value");
22
+ };
23
+ })();
24
+ (()=>{
25
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
26
+ })();
27
+ (()=>{
28
+ __webpack_require__.r = (exports1)=>{
29
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
30
+ value: 'Module'
31
+ });
32
+ Object.defineProperty(exports1, '__esModule', {
33
+ value: true
34
+ });
35
+ };
36
+ })();
37
+ var __webpack_exports__ = {};
38
+ __webpack_require__.r(__webpack_exports__);
39
+ __webpack_require__.d(__webpack_exports__, {
40
+ createWorkerManifestServiceBindings: ()=>createWorkerManifestServiceBindings,
41
+ createWorkerServiceBindings: ()=>createWorkerServiceBindings,
42
+ createWranglerConfig: ()=>createWranglerConfig
43
+ });
44
+ const external_node_path_namespaceObject = require("node:path");
45
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
46
+ const external_constants_js_namespaceObject = require("./constants.js");
47
+ const external_utils_js_namespaceObject = require("./utils.js");
48
+ const getCompatibilityDate = (modernConfig)=>{
49
+ const configuredDate = modernConfig.deploy?.worker?.compatibilityDate?.trim();
50
+ const compatibilityDate = configuredDate || external_constants_js_namespaceObject.DEFAULT_COMPATIBILITY_DATE;
51
+ if (!external_constants_js_namespaceObject.COMPATIBILITY_DATE_PATTERN.test(compatibilityDate)) throw new Error(`deploy.worker.compatibilityDate must use YYYY-MM-DD, received ${JSON.stringify(compatibilityDate)}.`);
52
+ return compatibilityDate;
53
+ };
54
+ const getWorkerName = (appDirectory)=>{
55
+ const basename = external_node_path_default().basename(appDirectory);
56
+ return basename.replace(/[^a-zA-Z0-9-_]/g, '-') || 'modern-cloudflare-worker';
57
+ };
58
+ const getConfiguredWorkerName = (appDirectory, modernConfig)=>{
59
+ const configuredName = modernConfig.deploy?.worker?.name?.trim();
60
+ return configuredName || getWorkerName(appDirectory);
61
+ };
62
+ const getConfiguredWrangler = (modernConfig)=>{
63
+ const wrangler = modernConfig.deploy?.worker?.wrangler;
64
+ if (void 0 === wrangler) return {};
65
+ if (!(0, external_utils_js_namespaceObject.isJsonRecord)(wrangler)) throw new Error('deploy.worker.wrangler must be a JSON object.');
66
+ return wrangler;
67
+ };
68
+ const createWranglerCompatibilityFlags = (configuredFlags)=>{
69
+ if (void 0 === configuredFlags) return [
70
+ ...external_constants_js_namespaceObject.REQUIRED_COMPATIBILITY_FLAGS
71
+ ];
72
+ if (!Array.isArray(configuredFlags) || configuredFlags.some((flag)=>'string' != typeof flag)) throw new Error('deploy.worker.wrangler.compatibility_flags must be an array of strings.');
73
+ return [
74
+ ...new Set([
75
+ ...configuredFlags,
76
+ ...external_constants_js_namespaceObject.REQUIRED_COMPATIBILITY_FLAGS
77
+ ])
78
+ ];
79
+ };
80
+ const createWranglerAssetsConfig = (configuredAssets)=>{
81
+ if (void 0 !== configuredAssets && !(0, external_utils_js_namespaceObject.isJsonRecord)(configuredAssets)) throw new Error('deploy.worker.wrangler.assets must be an object.');
82
+ return {
83
+ ...(0, external_utils_js_namespaceObject.isJsonRecord)(configuredAssets) ? configuredAssets : {},
84
+ directory: `./${external_constants_js_namespaceObject.PUBLIC_ASSETS_DIRECTORY}`,
85
+ binding: external_constants_js_namespaceObject.ASSETS_BINDING,
86
+ run_worker_first: true
87
+ };
88
+ };
89
+ const assertNonEmptyString = (value, label)=>{
90
+ if ('string' != typeof value || 0 === value.trim().length) throw new Error(`${label} must be a non-empty string.`);
91
+ return value.trim();
92
+ };
93
+ const normalizeD1Database = (database, index)=>{
94
+ const binding = assertNonEmptyString(database.binding, `deploy.worker.d1Databases[${index}].binding`);
95
+ const databaseName = assertNonEmptyString(database.databaseName, `deploy.worker.d1Databases[${index}].databaseName`);
96
+ const databaseId = assertNonEmptyString(database.databaseId, `deploy.worker.d1Databases[${index}].databaseId`);
97
+ const migrationsDir = void 0 === database.migrationsDir ? void 0 : (0, external_utils_js_namespaceObject.normalizeRelativePath)(database.migrationsDir, `deploy.worker.d1Databases[${index}].migrationsDir`, 'app root');
98
+ const previewDatabaseId = void 0 === database.previewDatabaseId ? void 0 : assertNonEmptyString(database.previewDatabaseId, `deploy.worker.d1Databases[${index}].previewDatabaseId`);
99
+ return {
100
+ binding,
101
+ database_name: databaseName,
102
+ database_id: databaseId,
103
+ ...void 0 === migrationsDir ? {} : {
104
+ migrations_dir: migrationsDir
105
+ },
106
+ ...void 0 === previewDatabaseId ? {} : {
107
+ preview_database_id: previewDatabaseId
108
+ },
109
+ ...void 0 === database.remote ? {} : {
110
+ remote: database.remote
111
+ }
112
+ };
113
+ };
114
+ const createWranglerD1Databases = (modernConfig, configuredWranglerD1)=>{
115
+ const d1Databases = modernConfig.deploy?.worker?.d1Databases;
116
+ if (void 0 === d1Databases) return configuredWranglerD1;
117
+ if (void 0 !== configuredWranglerD1) throw new Error('Use deploy.worker.d1Databases or deploy.worker.wrangler.d1_databases, not both.');
118
+ if (!Array.isArray(d1Databases)) throw new Error('deploy.worker.d1Databases must be an array.');
119
+ return d1Databases.map(normalizeD1Database);
120
+ };
121
+ const normalizeServiceBinding = (service, index)=>{
122
+ const binding = assertNonEmptyString(service.binding, `deploy.worker.services[${index}].binding`);
123
+ const serviceName = assertNonEmptyString(service.service, `deploy.worker.services[${index}].service`);
124
+ const prefix = void 0 === service.prefix ? void 0 : assertNonEmptyString(service.prefix, `deploy.worker.services[${index}].prefix`);
125
+ return {
126
+ binding,
127
+ service: serviceName,
128
+ ...void 0 === prefix ? {} : {
129
+ prefix
130
+ }
131
+ };
132
+ };
133
+ const createWorkerServiceBindings = (modernConfig, configuredWranglerServices)=>{
134
+ const services = modernConfig.deploy?.worker?.services;
135
+ if (void 0 === services) return configuredWranglerServices;
136
+ if (void 0 !== configuredWranglerServices) throw new Error('Use deploy.worker.services or deploy.worker.wrangler.services, not both.');
137
+ if (!Array.isArray(services)) throw new Error('deploy.worker.services must be an array.');
138
+ return services.map(normalizeServiceBinding);
139
+ };
140
+ const createWranglerServices = (serviceBindings)=>{
141
+ if (!Array.isArray(serviceBindings)) return serviceBindings;
142
+ if (!serviceBindings.every(external_utils_js_namespaceObject.isJsonRecord)) return serviceBindings;
143
+ return serviceBindings.map((service)=>{
144
+ const { prefix, ...wranglerService } = service;
145
+ return wranglerService;
146
+ });
147
+ };
148
+ const createWorkerManifestServiceBindings = (serviceBindings)=>{
149
+ if (!Array.isArray(serviceBindings)) return;
150
+ const dispatchBindings = serviceBindings.filter((service)=>(0, external_utils_js_namespaceObject.isJsonRecord)(service) && 'string' == typeof service.binding && 'string' == typeof service.service && 'string' == typeof service.prefix).map((service)=>({
151
+ binding: service.binding,
152
+ service: service.service,
153
+ prefix: service.prefix,
154
+ interface: 'fetch'
155
+ }));
156
+ return dispatchBindings.length > 0 ? dispatchBindings : void 0;
157
+ };
158
+ const createWranglerConfig = (appDirectory, modernConfig)=>{
159
+ const wrangler = getConfiguredWrangler(modernConfig);
160
+ const d1Databases = createWranglerD1Databases(modernConfig, wrangler.d1_databases);
161
+ const serviceBindings = createWorkerServiceBindings(modernConfig, wrangler.services);
162
+ const wranglerServices = createWranglerServices(serviceBindings);
163
+ return {
164
+ $schema: 'node_modules/wrangler/config-schema.json',
165
+ name: getConfiguredWorkerName(appDirectory, modernConfig),
166
+ compatibility_date: getCompatibilityDate(modernConfig),
167
+ ...wrangler,
168
+ main: external_constants_js_namespaceObject.WORKER_ENTRY,
169
+ compatibility_flags: createWranglerCompatibilityFlags(wrangler.compatibility_flags),
170
+ assets: createWranglerAssetsConfig(wrangler.assets),
171
+ ...void 0 === d1Databases ? {} : {
172
+ d1_databases: d1Databases
173
+ },
174
+ ...void 0 === wranglerServices ? {} : {
175
+ services: wranglerServices
176
+ }
177
+ };
178
+ };
179
+ exports.createWorkerManifestServiceBindings = __webpack_exports__.createWorkerManifestServiceBindings;
180
+ exports.createWorkerServiceBindings = __webpack_exports__.createWorkerServiceBindings;
181
+ exports.createWranglerConfig = __webpack_exports__.createWranglerConfig;
182
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
183
+ "createWorkerManifestServiceBindings",
184
+ "createWorkerServiceBindings",
185
+ "createWranglerConfig"
186
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
187
+ Object.defineProperty(exports, '__esModule', {
188
+ value: true
189
+ });
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ verifyDeliveryUnitIdentity: ()=>verifyDeliveryUnitIdentity
32
+ });
33
+ const universal_namespaceObject = require("@modern-js/utils/universal");
34
+ const external_issues_js_namespaceObject = require("./issues.js");
35
+ const verifyDeliveryUnitIdentity = (issues, manifest, manifestPath, declared)=>{
36
+ const stamped = manifest?.deliveryUnit;
37
+ const hasStamp = Boolean(stamped) && 'object' == typeof stamped;
38
+ if (declared) {
39
+ if (!hasStamp) return void (0, external_issues_js_namespaceObject.addIssue)(issues, {
40
+ code: 'missing-delivery-unit',
41
+ message: `Cloudflare worker manifest is missing the delivery-unit identity declared by the workspace topology (expected unitId ${declared.unitId}, buildMarker ${declared.buildMarker}).`,
42
+ path: manifestPath
43
+ });
44
+ for (const field of universal_namespaceObject.DELIVERY_UNIT_IDENTITY_FIELDS){
45
+ const stampedValue = (0, universal_namespaceObject.deliveryUnitIdentityFieldValue)(stamped, field);
46
+ (0, external_issues_js_namespaceObject.assertEqual)(issues, stampedValue, declared[field], {
47
+ code: 'delivery-unit-drift',
48
+ message: `Cloudflare worker manifest deliveryUnit.${field} must match the topology delivery-unit record (expected ${declared[field]}, received ${stampedValue ?? 'undefined'}).`,
49
+ path: manifestPath
50
+ });
51
+ }
52
+ }
53
+ if (hasStamp && stamped.surfaces && 'object' == typeof stamped.surfaces) for (const surface of [
54
+ 'ui',
55
+ 'api'
56
+ ]){
57
+ const marker = stamped.surfaces[surface];
58
+ if (!marker || 'object' != typeof marker) {
59
+ (0, external_issues_js_namespaceObject.addIssue)(issues, {
60
+ code: 'missing-delivery-unit',
61
+ message: `Cloudflare worker manifest is missing the ${surface} delivery-unit surface marker.`,
62
+ path: manifestPath
63
+ });
64
+ continue;
65
+ }
66
+ for (const field of universal_namespaceObject.DELIVERY_UNIT_IDENTITY_FIELDS){
67
+ const markerValue = (0, universal_namespaceObject.deliveryUnitIdentityFieldValue)(marker, field);
68
+ const stampedValue = (0, universal_namespaceObject.deliveryUnitIdentityFieldValue)(stamped, field);
69
+ (0, external_issues_js_namespaceObject.assertEqual)(issues, markerValue, stampedValue, {
70
+ code: 'delivery-unit-drift',
71
+ message: `Cloudflare worker manifest ${surface} surface deliveryUnit.${field} must derive from one delivery-unit record (expected ${stampedValue ?? 'undefined'}, received ${markerValue ?? 'undefined'}).`,
72
+ path: manifestPath
73
+ });
74
+ }
75
+ }
76
+ };
77
+ exports.verifyDeliveryUnitIdentity = __webpack_exports__.verifyDeliveryUnitIdentity;
78
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
79
+ "verifyDeliveryUnitIdentity"
80
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
81
+ Object.defineProperty(exports, '__esModule', {
82
+ value: true
83
+ });