veryfront 0.1.779 → 0.1.781
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/esm/deno.js +1 -1
- package/esm/src/html/html-shell-generator.d.ts.map +1 -1
- package/esm/src/html/html-shell-generator.js +2 -0
- package/esm/src/html/utils.d.ts +3 -0
- package/esm/src/html/utils.d.ts.map +1 -1
- package/esm/src/html/utils.js +31 -4
- package/esm/src/integrations/_data.d.ts.map +1 -1
- package/esm/src/integrations/_data.js +9 -1
- package/esm/src/release-assets/build-executor.d.ts.map +1 -1
- package/esm/src/release-assets/build-executor.js +79 -29
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-shell-generator.d.ts","sourceRoot":"","sources":["../../../src/src/html/html-shell-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA0BxE,OAAO,EAGL,aAAa,EACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAqCxD,KAAK,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,GAAG,IAAI,CAAC;AA2EzE,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,qBAAqB,EAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAC1C,KAAK,CAAC,EAAE,cAAc,EACtB,kBAAkB,CAAC,EAAE,MAAM,EAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAC5C,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAmBzC;
|
|
1
|
+
{"version":3,"file":"html-shell-generator.d.ts","sourceRoot":"","sources":["../../../src/src/html/html-shell-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA0BxE,OAAO,EAGL,aAAa,EACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAqCxD,KAAK,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,GAAG,IAAI,CAAC;AA2EzE,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,qBAAqB,EAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAC1C,KAAK,CAAC,EAAE,cAAc,EACtB,kBAAkB,CAAC,EAAE,MAAM,EAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAC5C,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAmBzC;AA8QD,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,qBAAqB,EAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAC1C,KAAK,CAAC,EAAE,cAAc,EACtB,iBAAiB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAC5C,OAAO,CAAC,MAAM,CAAC,CAoBjB"}
|
|
@@ -134,11 +134,13 @@ async function generateHTMLShellPartsImpl(meta, options, params, props, contentF
|
|
|
134
134
|
// Enable dev scripts for local dev OR preview mode (for HMR support in Studio),
|
|
135
135
|
// unless a caller explicitly forces production client scripts for fair benchmarking.
|
|
136
136
|
const useDevScripts = !options.forceProductionScripts && (isLocalProject || isPreviewMode);
|
|
137
|
+
const releaseManifest = options.studioEmbed ? null : getReadyManifestForRender(options.releaseId);
|
|
137
138
|
const importMapPromise = buildImportMap({
|
|
138
139
|
projectDir: options.projectDir,
|
|
139
140
|
config: options.config,
|
|
140
141
|
customImports: options.importMap,
|
|
141
142
|
pretty: useDevScripts,
|
|
143
|
+
releaseAssetManifest: releaseManifest,
|
|
142
144
|
});
|
|
143
145
|
const hydrationDataJson = generateHydrationData(meta.slug || "", params ?? {}, props ?? {}, options, { pretty: useDevScripts });
|
|
144
146
|
const nonce = options.nonce ?? "";
|
package/esm/src/html/utils.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import type { VeryfrontConfig } from "../config/index.js";
|
|
2
|
+
import type { ReleaseAssetManifest } from "../release-assets/manifest-schema.js";
|
|
2
3
|
export declare function buildRootAttributes(slug: string, mode: string, noLayout: boolean, ssrHash?: string): string;
|
|
3
4
|
export interface BuiltImportMap {
|
|
4
5
|
imports: Record<string, string>;
|
|
5
6
|
json: string;
|
|
6
7
|
}
|
|
8
|
+
export declare const PLATFORM_UTILITIES: Record<string, string>;
|
|
7
9
|
interface BuildImportMapOptions {
|
|
8
10
|
projectDir?: string;
|
|
9
11
|
config?: VeryfrontConfig;
|
|
10
12
|
customImports?: Record<string, string>;
|
|
11
13
|
pretty?: boolean;
|
|
14
|
+
releaseAssetManifest?: ReleaseAssetManifest | null;
|
|
12
15
|
}
|
|
13
16
|
export declare function buildImportMap(options?: BuildImportMapOptions | Record<string, string>): Promise<BuiltImportMap>;
|
|
14
17
|
export declare function buildImportMapJson(options?: BuildImportMapOptions | Record<string, string>): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/src/html/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":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,7 @@ const AI_MODULE_UTILITIES = {
|
|
|
63
63
|
"veryfront/mdx": PLATFORM_UTILITY_PATHS.mdx,
|
|
64
64
|
"veryfront/workflow": PLATFORM_UTILITY_PATHS.workflow,
|
|
65
65
|
};
|
|
66
|
-
const PLATFORM_UTILITIES = {
|
|
66
|
+
export const PLATFORM_UTILITIES = {
|
|
67
67
|
...CORE_PLATFORM_UTILITIES,
|
|
68
68
|
...AI_MODULE_UTILITIES,
|
|
69
69
|
};
|
|
@@ -186,10 +186,34 @@ function stableMapKey(imports) {
|
|
|
186
186
|
? JSON.stringify(Object.entries(imports).sort(([a], [b]) => a.localeCompare(b)))
|
|
187
187
|
: "";
|
|
188
188
|
}
|
|
189
|
+
function stableManifestDependencyKey(manifest) {
|
|
190
|
+
return manifest
|
|
191
|
+
? JSON.stringify({
|
|
192
|
+
assetBasePath: manifest.assetBasePath,
|
|
193
|
+
dependencies: Object.entries(manifest.dependencies)
|
|
194
|
+
.map(([specifier, entry]) => [specifier, entry.contentHash])
|
|
195
|
+
.sort(([a], [b]) => String(a).localeCompare(String(b))),
|
|
196
|
+
})
|
|
197
|
+
: "";
|
|
198
|
+
}
|
|
199
|
+
function applyManifestDependencies(imports, manifest) {
|
|
200
|
+
if (!manifest)
|
|
201
|
+
return imports;
|
|
202
|
+
let rewritten = null;
|
|
203
|
+
for (const specifier of Object.keys(imports)) {
|
|
204
|
+
const entry = manifest.dependencies[specifier];
|
|
205
|
+
if (!entry || entry.contentType !== "text/javascript")
|
|
206
|
+
continue;
|
|
207
|
+
rewritten ??= { ...imports };
|
|
208
|
+
rewritten[specifier] = `${manifest.assetBasePath}/${entry.contentHash}.js`;
|
|
209
|
+
}
|
|
210
|
+
return rewritten ?? imports;
|
|
211
|
+
}
|
|
189
212
|
function isImportMapOnlyOptions(options) {
|
|
190
213
|
return !("projectDir" in options) &&
|
|
191
214
|
!("config" in options) &&
|
|
192
215
|
!("customImports" in options) &&
|
|
216
|
+
!("releaseAssetManifest" in options) &&
|
|
193
217
|
!("pretty" in options);
|
|
194
218
|
}
|
|
195
219
|
export async function buildImportMap(options) {
|
|
@@ -199,19 +223,20 @@ export async function buildImportMap(options) {
|
|
|
199
223
|
return { imports, json: stringifyImportMap(imports) };
|
|
200
224
|
}
|
|
201
225
|
}
|
|
202
|
-
const { projectDir, config, customImports, pretty = true } = (options ?? {});
|
|
226
|
+
const { projectDir, config, customImports, pretty = true, releaseAssetManifest } = (options ?? {});
|
|
203
227
|
const mode = config?.client?.moduleResolution ?? "cdn";
|
|
204
228
|
const versions = projectDir ? await resolveVersions(projectDir, config) : DEFAULT_VERSIONS;
|
|
205
229
|
if (mode === "bundled") {
|
|
206
230
|
const reactTemplates = CDN_URL_TEMPLATES["esm.sh"];
|
|
207
|
-
|
|
231
|
+
let imports = {
|
|
208
232
|
react: reactTemplates.react(versions.react),
|
|
209
233
|
"react-dom": reactTemplates.reactDom(versions.react),
|
|
210
234
|
"react-dom/client": reactTemplates.reactDomClient(versions.react),
|
|
211
235
|
"react/jsx-runtime": reactTemplates.jsxRuntime(versions.react),
|
|
212
236
|
"react/jsx-dev-runtime": reactTemplates.jsxDevRuntime(versions.react),
|
|
213
|
-
...customImports,
|
|
214
237
|
};
|
|
238
|
+
imports = applyManifestDependencies(imports, releaseAssetManifest);
|
|
239
|
+
imports = { ...imports, ...customImports };
|
|
215
240
|
return { imports, json: stringifyImportMap(imports, pretty) };
|
|
216
241
|
}
|
|
217
242
|
let imports;
|
|
@@ -222,6 +247,7 @@ export async function buildImportMap(options) {
|
|
|
222
247
|
imports = getCdnImportMap(versions, (config?.client?.cdn?.provider ?? "esm.sh"));
|
|
223
248
|
}
|
|
224
249
|
imports["@/"] = "/_vf_modules/";
|
|
250
|
+
imports = applyManifestDependencies(imports, releaseAssetManifest);
|
|
225
251
|
if (customImports) {
|
|
226
252
|
imports = { ...imports, ...customImports };
|
|
227
253
|
}
|
|
@@ -233,6 +259,7 @@ export async function buildImportMap(options) {
|
|
|
233
259
|
veryfront: versions.veryfront,
|
|
234
260
|
pretty,
|
|
235
261
|
customImports: stableMapKey(customImports),
|
|
262
|
+
manifestDependencies: stableManifestDependencyKey(releaseAssetManifest),
|
|
236
263
|
});
|
|
237
264
|
const cached = importMapJsonCache.get(cacheKey);
|
|
238
265
|
if (cached)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_data.d.ts","sourceRoot":"","sources":["../../../src/src/integrations/_data.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,eAAO,MAAM,UAAU,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"_data.d.ts","sourceRoot":"","sources":["../../../src/src/integrations/_data.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,eAAO,MAAM,UAAU,EAAE,iBAAiB,EAk61DzC,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAyZxC,CAAC"}
|
|
@@ -13005,7 +13005,14 @@ export const connectors = [
|
|
|
13005
13005
|
"body": {
|
|
13006
13006
|
"file": {
|
|
13007
13007
|
"type": "string",
|
|
13008
|
-
"description": "
|
|
13008
|
+
"description": "Base64-encoded content of the document (e.g. a PDF invoice), sent decoded as the binary multipart 'file' part",
|
|
13009
|
+
"required": true,
|
|
13010
|
+
"encoding": "base64",
|
|
13011
|
+
"partFilenameField": "file_name",
|
|
13012
|
+
},
|
|
13013
|
+
"file_name": {
|
|
13014
|
+
"type": "string",
|
|
13015
|
+
"description": "Filename for the uploaded document, e.g. invoice.pdf",
|
|
13009
13016
|
"required": true,
|
|
13010
13017
|
},
|
|
13011
13018
|
"metadata": {
|
|
@@ -13013,6 +13020,7 @@ export const connectors = [
|
|
|
13013
13020
|
"description": 'Optional JSON metadata part, e.g. { "document_type": "Rechnungseingang", "note": "..." }. Use List Document Types to find valid document types.',
|
|
13014
13021
|
},
|
|
13015
13022
|
},
|
|
13023
|
+
"bodyMode": "form-data",
|
|
13016
13024
|
"contentType": "multipart/form-data",
|
|
13017
13025
|
},
|
|
13018
13026
|
}],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-executor.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/build-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"build-executor.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/build-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAgCH,MAAM,WAAW,sBAAsB;IACrC,yDAAyD;IACzD,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,MAAM,EAAE,uBAAuB,CAAC;IAChC,sDAAsD;IAEtD,OAAO,EAAE,GAAG,CAAC;IACb;;;;OAIG;IACH,SAAS,CAAC,EAAE,qBAAqB,CAAC;CACnC;AAED,MAAM,MAAM,qBAAqB,GAAG,CAClC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAElB,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,KAC9E,OAAO,CAAC,MAAM,CAAC,CAAC;AAErB,oEAAoE;AACpE,MAAM,WAAW,uBAAuB;IACt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MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA6BD,2DAA2D;AAC3D,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM/D;AA8LD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,sBAAsB,EAC7B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,uBAAuB,CAAC,CA2ClC"}
|
|
@@ -18,7 +18,10 @@ import { serverLogger } from "../utils/index.js";
|
|
|
18
18
|
import { VERSION } from "../utils/version.js";
|
|
19
19
|
import { createFileSystem } from "../platform/compat/fs.js";
|
|
20
20
|
import { dirname, join } from "../platform/compat/path/index.js";
|
|
21
|
+
import { resolveFrameworkSourcePath } from "../platform/compat/framework-source-resolver.js";
|
|
21
22
|
import { transformToESM } from "../transforms/esm-transform.js";
|
|
23
|
+
import { PLATFORM_UTILITIES } from "../html/utils.js";
|
|
24
|
+
import { extractCandidatesFromFiles } from "../html/styles-builder/candidate-extractor.js";
|
|
22
25
|
import { sha256HexBytes } from "./hash.js";
|
|
23
26
|
import { RELEASE_ASSET_BASE_PATH, RELEASE_ASSET_CONTENT_TYPES, RELEASE_ASSET_MANIFEST_SCHEMA_VERSION, RELEASE_ASSET_MAX_SIZE_BYTES, RELEASE_ASSET_UPLOAD_CONCURRENCY, } from "./constants.js";
|
|
24
27
|
const logger = serverLogger.component("release-asset-build");
|
|
@@ -26,6 +29,14 @@ const logger = serverLogger.component("release-asset-build");
|
|
|
26
29
|
const BROWSER_MODULE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mdx"];
|
|
27
30
|
/** Directories whose modules are part of the browser closure. */
|
|
28
31
|
const BROWSER_MODULE_DIRS = ["pages/", "components/", "layouts/", "lib/", "src/"];
|
|
32
|
+
const FRAMEWORK_MODULE_URL_PREFIX = "/_vf_modules/_veryfront/";
|
|
33
|
+
function frameworkModuleUrlToSourceKey(moduleUrl) {
|
|
34
|
+
if (!moduleUrl.startsWith(FRAMEWORK_MODULE_URL_PREFIX))
|
|
35
|
+
return null;
|
|
36
|
+
return moduleUrl
|
|
37
|
+
.slice(FRAMEWORK_MODULE_URL_PREFIX.length)
|
|
38
|
+
.replace(/\.(mjs|cjs|js|jsx|ts|tsx)$/, "");
|
|
39
|
+
}
|
|
29
40
|
/** Sanitize an error for state reporting (no internal paths / stack traces). */
|
|
30
41
|
function sanitizeError(error) {
|
|
31
42
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -110,6 +121,64 @@ function resolveStaticImports(source, moduleLogicalPath, knownPaths) {
|
|
|
110
121
|
}
|
|
111
122
|
return results;
|
|
112
123
|
}
|
|
124
|
+
async function addPreparedJavaScriptAsset(logicalPath, code, uploadQueue, pendingBytes) {
|
|
125
|
+
const bytes = new TextEncoder().encode(code);
|
|
126
|
+
if (bytes.byteLength > RELEASE_ASSET_MAX_SIZE_BYTES)
|
|
127
|
+
return null;
|
|
128
|
+
const contentHash = await sha256HexBytes(bytes);
|
|
129
|
+
const entry = {
|
|
130
|
+
logicalPath,
|
|
131
|
+
contentHash,
|
|
132
|
+
size: bytes.byteLength,
|
|
133
|
+
contentType: RELEASE_ASSET_CONTENT_TYPES.js,
|
|
134
|
+
};
|
|
135
|
+
if (!pendingBytes.has(contentHash)) {
|
|
136
|
+
pendingBytes.set(contentHash, { bytes, contentType: RELEASE_ASSET_CONTENT_TYPES.js });
|
|
137
|
+
uploadQueue.push(entry);
|
|
138
|
+
}
|
|
139
|
+
return entry;
|
|
140
|
+
}
|
|
141
|
+
async function buildFrameworkDependencies(input, tempDir, transform, uploadQueue, pendingBytes, gaps) {
|
|
142
|
+
const fs = createFileSystem();
|
|
143
|
+
const dependencies = {};
|
|
144
|
+
for (const [specifier, moduleUrl] of Object.entries(PLATFORM_UTILITIES)) {
|
|
145
|
+
const sourceKey = frameworkModuleUrlToSourceKey(moduleUrl);
|
|
146
|
+
if (!sourceKey)
|
|
147
|
+
continue;
|
|
148
|
+
const frameworkSource = await resolveFrameworkSourcePath(sourceKey, {
|
|
149
|
+
extraLookupDirs: [join(tempDir, "src")],
|
|
150
|
+
});
|
|
151
|
+
if (!frameworkSource) {
|
|
152
|
+
gaps.push(`dependency-missing:${specifier}`);
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
let code;
|
|
156
|
+
try {
|
|
157
|
+
const source = await fs.readTextFile(frameworkSource.path);
|
|
158
|
+
code = await transform(source, frameworkSource.path, tempDir, input.adapter, {
|
|
159
|
+
projectId: input.projectId,
|
|
160
|
+
dev: false,
|
|
161
|
+
ssr: false,
|
|
162
|
+
reactVersion: input.reactVersion,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
gaps.push(`dependency-transform-failed:${specifier}`);
|
|
167
|
+
logger.warn("Framework dependency transform failed during release asset build", {
|
|
168
|
+
specifier,
|
|
169
|
+
error: sanitizeError(error),
|
|
170
|
+
});
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const entry = await addPreparedJavaScriptAsset(`__dependencies__/${specifier}`, code, uploadQueue, pendingBytes);
|
|
174
|
+
if (!entry) {
|
|
175
|
+
gaps.push(`dependency-oversized:${specifier}`);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
dependencies[specifier] = entry;
|
|
179
|
+
}
|
|
180
|
+
return dependencies;
|
|
181
|
+
}
|
|
113
182
|
/**
|
|
114
183
|
* Walk the static import graph from a set of entry points using BFS.
|
|
115
184
|
* Returns all reachable logical paths (entries included).
|
|
@@ -239,31 +308,19 @@ async function runBuildInner(input, tempDir, client, transform) {
|
|
|
239
308
|
error: sanitized,
|
|
240
309
|
};
|
|
241
310
|
}
|
|
242
|
-
|
|
243
|
-
const bytes = new TextEncoder().encode(code);
|
|
311
|
+
const entry = await addPreparedJavaScriptAsset(logicalPath, code, uploadQueue, pendingBytes);
|
|
244
312
|
// M2: enforce 10 MB client-side limit — skip oversized modules with a gap.
|
|
245
|
-
if (
|
|
313
|
+
if (!entry) {
|
|
246
314
|
gaps.push(`oversized:${logicalPath}`);
|
|
247
315
|
logger.warn("Module exceeds max size, skipping", {
|
|
248
316
|
path: logicalPath,
|
|
249
|
-
size: bytes.byteLength,
|
|
250
317
|
limit: RELEASE_ASSET_MAX_SIZE_BYTES,
|
|
251
318
|
});
|
|
252
319
|
continue;
|
|
253
320
|
}
|
|
254
|
-
const contentHash = await sha256HexBytes(bytes);
|
|
255
|
-
const entry = {
|
|
256
|
-
logicalPath,
|
|
257
|
-
contentHash,
|
|
258
|
-
size: bytes.byteLength,
|
|
259
|
-
contentType: RELEASE_ASSET_CONTENT_TYPES.js,
|
|
260
|
-
};
|
|
261
321
|
modules[logicalPath] = entry;
|
|
262
|
-
if (!pendingBytes.has(contentHash)) {
|
|
263
|
-
pendingBytes.set(contentHash, { bytes, contentType: RELEASE_ASSET_CONTENT_TYPES.js });
|
|
264
|
-
uploadQueue.push(entry);
|
|
265
|
-
}
|
|
266
322
|
}
|
|
323
|
+
const dependencies = await buildFrameworkDependencies(input, tempDir, transform, uploadQueue, pendingBytes, gaps);
|
|
267
324
|
// 5b. CSS: compile project CSS where reachable, else record css:[] and note.
|
|
268
325
|
const css = [];
|
|
269
326
|
const cssHashes = [];
|
|
@@ -365,7 +422,11 @@ async function runBuildInner(input, tempDir, client, transform) {
|
|
|
365
422
|
}])),
|
|
366
423
|
css,
|
|
367
424
|
routes,
|
|
368
|
-
dependencies: {
|
|
425
|
+
dependencies: Object.fromEntries(Object.entries(dependencies).map(([specifier, entry]) => [specifier, {
|
|
426
|
+
contentHash: entry.contentHash,
|
|
427
|
+
size: entry.size,
|
|
428
|
+
contentType: entry.contentType,
|
|
429
|
+
}])),
|
|
369
430
|
fallback: { mode: "jit", gaps },
|
|
370
431
|
};
|
|
371
432
|
const result = await client.putReleaseAssetManifest(input.releaseVersionRef, manifest);
|
|
@@ -402,20 +463,9 @@ function resolveProjectStylesheet(sourceByPath, stylesheetPath) {
|
|
|
402
463
|
}
|
|
403
464
|
return undefined;
|
|
404
465
|
}
|
|
405
|
-
/** Extract Tailwind class candidates from materialized source
|
|
466
|
+
/** Extract Tailwind class candidates from materialized source. */
|
|
406
467
|
function collectClassCandidates(sourceByPath) {
|
|
407
|
-
|
|
408
|
-
const re = /class(?:Name)?\s*=\s*["'`]([^"'`]+)["'`]/g;
|
|
409
|
-
for (const source of sourceByPath.values()) {
|
|
410
|
-
let m;
|
|
411
|
-
while ((m = re.exec(source)) !== null) {
|
|
412
|
-
for (const cls of m[1].split(/\s+/)) {
|
|
413
|
-
if (cls)
|
|
414
|
-
candidates.add(cls);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
return candidates;
|
|
468
|
+
return extractCandidatesFromFiles([...sourceByPath.entries()].map(([path, content]) => ({ path, content })));
|
|
419
469
|
}
|
|
420
470
|
/** Run an async task over items with a fixed concurrency limit. */
|
|
421
471
|
async function uploadWithConcurrency(items, concurrency, task) {
|