veryfront 0.1.780 → 0.1.782
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
CHANGED
|
@@ -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;AAiCH,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,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ACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAkCD,2DAA2D;AAC3D,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM/D;AA8TD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,sBAAsB,EAC7B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,uBAAuB,CAAC,CA2ClC"}
|
|
@@ -21,8 +21,9 @@ import { dirname, join } from "../platform/compat/path/index.js";
|
|
|
21
21
|
import { resolveFrameworkSourcePath } from "../platform/compat/framework-source-resolver.js";
|
|
22
22
|
import { transformToESM } from "../transforms/esm-transform.js";
|
|
23
23
|
import { PLATFORM_UTILITIES } from "../html/utils.js";
|
|
24
|
+
import { extractCandidatesFromFiles } from "../html/styles-builder/candidate-extractor.js";
|
|
24
25
|
import { sha256HexBytes } from "./hash.js";
|
|
25
|
-
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";
|
|
26
|
+
import { RELEASE_ASSET_BASE_PATH, RELEASE_ASSET_CONTENT_TYPES, RELEASE_ASSET_MANIFEST_SCHEMA_VERSION, RELEASE_ASSET_MAX_SIZE_BYTES, RELEASE_ASSET_UPLOAD_CONCURRENCY, releaseAssetUrl, } from "./constants.js";
|
|
26
27
|
const logger = serverLogger.component("release-asset-build");
|
|
27
28
|
/** Browser module source extensions eligible for transform. */
|
|
28
29
|
const BROWSER_MODULE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mdx"];
|
|
@@ -120,6 +121,98 @@ function resolveStaticImports(source, moduleLogicalPath, knownPaths) {
|
|
|
120
121
|
}
|
|
121
122
|
return results;
|
|
122
123
|
}
|
|
124
|
+
function resolveKnownModulePath(path, knownPaths) {
|
|
125
|
+
const normalized = path
|
|
126
|
+
.replace(/^\/?_vf_modules\//, "")
|
|
127
|
+
.replace(/^\/+/, "")
|
|
128
|
+
.replace(/[?#].*$/, "");
|
|
129
|
+
if (normalized.startsWith("_veryfront/"))
|
|
130
|
+
return null;
|
|
131
|
+
if (knownPaths.has(normalized))
|
|
132
|
+
return normalized;
|
|
133
|
+
const withoutExt = normalized.replace(/\.(tsx|ts|jsx|mdx|js)$/, "");
|
|
134
|
+
for (const ext of BROWSER_MODULE_EXTENSIONS) {
|
|
135
|
+
const candidate = `${withoutExt}${ext}`;
|
|
136
|
+
if (knownPaths.has(candidate))
|
|
137
|
+
return candidate;
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
function collectVfModuleImports(code, knownPaths) {
|
|
142
|
+
const imports = new Map();
|
|
143
|
+
const re = /(["'])(\/_vf_modules\/[^"']+)\1/g;
|
|
144
|
+
let match;
|
|
145
|
+
while ((match = re.exec(code)) !== null) {
|
|
146
|
+
const specifier = match[2];
|
|
147
|
+
const logicalPath = resolveKnownModulePath(specifier, knownPaths);
|
|
148
|
+
if (logicalPath)
|
|
149
|
+
imports.set(specifier, logicalPath);
|
|
150
|
+
}
|
|
151
|
+
return imports;
|
|
152
|
+
}
|
|
153
|
+
function rewriteVfModuleImports(code, moduleAssets, knownPaths, dependencyUrls) {
|
|
154
|
+
return code.replace(/(["'])(\/_vf_modules\/[^"']+)\1/g, (full, quote, specifier) => {
|
|
155
|
+
const dependencyUrl = dependencyUrls.get(specifier.replace(/[?#].*$/, ""));
|
|
156
|
+
if (dependencyUrl)
|
|
157
|
+
return `${quote}${dependencyUrl}${quote}`;
|
|
158
|
+
const logicalPath = resolveKnownModulePath(specifier, knownPaths);
|
|
159
|
+
const asset = logicalPath ? moduleAssets.get(logicalPath) : undefined;
|
|
160
|
+
if (!asset)
|
|
161
|
+
return full;
|
|
162
|
+
return `${quote}${releaseAssetUrl(asset.contentHash, "js")}${quote}`;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function buildDependencyUrlMap(dependencies) {
|
|
166
|
+
const urls = new Map();
|
|
167
|
+
for (const [specifier, moduleUrl] of Object.entries(PLATFORM_UTILITIES)) {
|
|
168
|
+
const entry = dependencies[specifier];
|
|
169
|
+
if (!entry)
|
|
170
|
+
continue;
|
|
171
|
+
urls.set(moduleUrl, releaseAssetUrl(entry.contentHash, "js"));
|
|
172
|
+
}
|
|
173
|
+
return urls;
|
|
174
|
+
}
|
|
175
|
+
async function finalizeProjectModules(transformedModules, knownPaths, dependencyUrls, uploadQueue, pendingBytes, gaps) {
|
|
176
|
+
const finalized = new Map();
|
|
177
|
+
const unresolvedCycles = new Set();
|
|
178
|
+
async function finalize(logicalPath, stack) {
|
|
179
|
+
const existing = finalized.get(logicalPath);
|
|
180
|
+
if (existing)
|
|
181
|
+
return existing;
|
|
182
|
+
if (stack.includes(logicalPath)) {
|
|
183
|
+
const cycle = [...stack.slice(stack.indexOf(logicalPath)), logicalPath].join("->");
|
|
184
|
+
const gap = `cycle:${cycle}`;
|
|
185
|
+
if (!unresolvedCycles.has(gap)) {
|
|
186
|
+
unresolvedCycles.add(gap);
|
|
187
|
+
gaps.push(gap);
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
const transformed = transformedModules.get(logicalPath);
|
|
192
|
+
if (!transformed)
|
|
193
|
+
return null;
|
|
194
|
+
const nextStack = [...stack, logicalPath];
|
|
195
|
+
const imports = collectVfModuleImports(transformed.code, knownPaths);
|
|
196
|
+
for (const importedPath of imports.values()) {
|
|
197
|
+
await finalize(importedPath, nextStack);
|
|
198
|
+
}
|
|
199
|
+
const rewritten = rewriteVfModuleImports(transformed.code, finalized, knownPaths, dependencyUrls);
|
|
200
|
+
const entry = await addPreparedJavaScriptAsset(logicalPath, rewritten, uploadQueue, pendingBytes);
|
|
201
|
+
if (!entry)
|
|
202
|
+
return null;
|
|
203
|
+
finalized.set(logicalPath, entry);
|
|
204
|
+
return entry;
|
|
205
|
+
}
|
|
206
|
+
for (const logicalPath of transformedModules.keys()) {
|
|
207
|
+
const entry = await finalize(logicalPath, []);
|
|
208
|
+
if (!entry) {
|
|
209
|
+
const gap = `oversized:${logicalPath}`;
|
|
210
|
+
if (!gaps.includes(gap))
|
|
211
|
+
gaps.push(gap);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return Object.fromEntries(finalized);
|
|
215
|
+
}
|
|
123
216
|
async function addPreparedJavaScriptAsset(logicalPath, code, uploadQueue, pendingBytes) {
|
|
124
217
|
const bytes = new TextEncoder().encode(code);
|
|
125
218
|
if (bytes.byteLength > RELEASE_ASSET_MAX_SIZE_BYTES)
|
|
@@ -268,7 +361,7 @@ async function runBuildInner(input, tempDir, client, transform) {
|
|
|
268
361
|
}
|
|
269
362
|
// 3 + 4. Collect the browser module closure and transform each module
|
|
270
363
|
// through the SAME pipeline serveModule uses (browser, non-SSR).
|
|
271
|
-
const
|
|
364
|
+
const transformedModules = new Map();
|
|
272
365
|
const gaps = [];
|
|
273
366
|
const uploadQueue = [];
|
|
274
367
|
// Bytes are held per-hash only until uploaded, then dropped (M3).
|
|
@@ -307,19 +400,19 @@ async function runBuildInner(input, tempDir, client, transform) {
|
|
|
307
400
|
error: sanitized,
|
|
308
401
|
};
|
|
309
402
|
}
|
|
310
|
-
|
|
311
|
-
// M2: enforce 10 MB client-side limit — skip oversized modules with a gap.
|
|
312
|
-
if (!entry) {
|
|
313
|
-
gaps.push(`oversized:${logicalPath}`);
|
|
314
|
-
logger.warn("Module exceeds max size, skipping", {
|
|
315
|
-
path: logicalPath,
|
|
316
|
-
limit: RELEASE_ASSET_MAX_SIZE_BYTES,
|
|
317
|
-
});
|
|
318
|
-
continue;
|
|
319
|
-
}
|
|
320
|
-
modules[logicalPath] = entry;
|
|
403
|
+
transformedModules.set(logicalPath, { logicalPath, code });
|
|
321
404
|
}
|
|
322
405
|
const dependencies = await buildFrameworkDependencies(input, tempDir, transform, uploadQueue, pendingBytes, gaps);
|
|
406
|
+
const dependencyUrls = buildDependencyUrlMap(dependencies);
|
|
407
|
+
const modules = await finalizeProjectModules(transformedModules, knownPaths, dependencyUrls, uploadQueue, pendingBytes, gaps);
|
|
408
|
+
for (const logicalPath of transformedModules.keys()) {
|
|
409
|
+
if (modules[logicalPath])
|
|
410
|
+
continue;
|
|
411
|
+
logger.warn("Module exceeds max size, skipping", {
|
|
412
|
+
path: logicalPath,
|
|
413
|
+
limit: RELEASE_ASSET_MAX_SIZE_BYTES,
|
|
414
|
+
});
|
|
415
|
+
}
|
|
323
416
|
// 5b. CSS: compile project CSS where reachable, else record css:[] and note.
|
|
324
417
|
const css = [];
|
|
325
418
|
const cssHashes = [];
|
|
@@ -462,20 +555,9 @@ function resolveProjectStylesheet(sourceByPath, stylesheetPath) {
|
|
|
462
555
|
}
|
|
463
556
|
return undefined;
|
|
464
557
|
}
|
|
465
|
-
/** Extract Tailwind class candidates from materialized source
|
|
558
|
+
/** Extract Tailwind class candidates from materialized source. */
|
|
466
559
|
function collectClassCandidates(sourceByPath) {
|
|
467
|
-
|
|
468
|
-
const re = /class(?:Name)?\s*=\s*["'`]([^"'`]+)["'`]/g;
|
|
469
|
-
for (const source of sourceByPath.values()) {
|
|
470
|
-
let m;
|
|
471
|
-
while ((m = re.exec(source)) !== null) {
|
|
472
|
-
for (const cls of m[1].split(/\s+/)) {
|
|
473
|
-
if (cls)
|
|
474
|
-
candidates.add(cls);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
return candidates;
|
|
560
|
+
return extractCandidatesFromFiles([...sourceByPath.entries()].map(([path, content]) => ({ path, content })));
|
|
479
561
|
}
|
|
480
562
|
/** Run an async task over items with a fixed concurrency limit. */
|
|
481
563
|
async function uploadWithConcurrency(items, concurrency, task) {
|