@markless/bundler 0.1.0 → 0.2.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/dist/dev-error.d.ts +57 -0
- package/dist/dev-error.js +174 -0
- package/dist/preload.d.ts +1 -1
- package/dist/preload.js +1 -1
- package/dist/{rolldown-Czh1duwk.js → rolldown-CpG_S-ZJ.js} +795 -43
- package/dist/rolldown.d.ts +1 -1
- package/dist/rolldown.js +2 -2
- package/dist/{source-module-CSRzW4Ny.js → source-module-C8W2THUI.js} +111 -42
- package/dist/{types-D6KerlYq.d.ts → types-CzXV_ABj.d.ts} +9 -0
- package/dist/vite.d.ts +2 -1
- package/dist/vite.js +261 -17
- package/package.json +18 -9
package/dist/rolldown.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as TransformTsrxModuleInput, a as MarklessBundle, c as MarklessEnvironment, d as MarklessRolldownPluginApi, f as MarklessTransformManifest, g as PreloadGraphEntriesAdder, h as PreloadGraphEntries, i as MarklessBuildMetadata, l as MarklessManifest, m as PreloadGraphContext, n as GlobalInjections, o as MarklessBundleGraph, p as MarklessVirtualModule, r as MarklessAsset, s as MarklessDevServer, t as BundleGraphAdder, u as MarklessRolldownOptions, v as TransformTsrxModuleResult } from "./types-
|
|
1
|
+
import { _ as TransformTsrxModuleInput, a as MarklessBundle, c as MarklessEnvironment, d as MarklessRolldownPluginApi, f as MarklessTransformManifest, g as PreloadGraphEntriesAdder, h as PreloadGraphEntries, i as MarklessBuildMetadata, l as MarklessManifest, m as PreloadGraphContext, n as GlobalInjections, o as MarklessBundleGraph, p as MarklessVirtualModule, r as MarklessAsset, s as MarklessDevServer, t as BundleGraphAdder, u as MarklessRolldownOptions, v as TransformTsrxModuleResult } from "./types-CzXV_ABj.js";
|
|
2
2
|
import { n as resumeVirtualModuleId, t as MARKLESS_VIRTUAL_PREFIX } from "./source-module-BRb5P7wL.js";
|
|
3
3
|
import { OutputOptions, Plugin } from "rolldown";
|
|
4
4
|
|
package/dist/rolldown.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { b as MARKLESS_BUNDLE_GRAPH, o as resumeVirtualModuleId, t as MARKLESS_VIRTUAL_PREFIX, x as outputDefaults, y as MARKLESS_BUILD_PREFIX } from "./source-module-C8W2THUI.js";
|
|
2
|
+
import { c as collectHeadLinkInjections, i as marklessServer, l as convertManifestToBundleGraph, n as marklessClient, o as transformTsrxModule, r as marklessLib, s as createBuildMetadata, t as createMarklessRolldownPlugin, u as createPreloadGraphAdder } from "./rolldown-CpG_S-ZJ.js";
|
|
3
3
|
export { MARKLESS_BUILD_PREFIX, MARKLESS_BUNDLE_GRAPH, MARKLESS_VIRTUAL_PREFIX, collectHeadLinkInjections, convertManifestToBundleGraph, createBuildMetadata, createMarklessRolldownPlugin, createPreloadGraphAdder, marklessClient, marklessLib, marklessServer, outputDefaults, resumeVirtualModuleId, transformTsrxModule };
|
|
@@ -323,84 +323,107 @@ function executionLogVirtualModuleSourceWithOwnSize(options, ownRawSize) {
|
|
|
323
323
|
estimated: true
|
|
324
324
|
}]), [MARKLESS_EXECUTION_LOG_MODULE_ID, {
|
|
325
325
|
raw: ownRawSize ?? 0,
|
|
326
|
-
estimated: true
|
|
326
|
+
estimated: true,
|
|
327
|
+
instrument: true
|
|
327
328
|
}]]) : null;
|
|
328
329
|
return `
|
|
329
330
|
globalThis.__mxLog?.add(${JSON.stringify(MARKLESS_EXECUTION_LOG_MODULE_ID)});
|
|
330
331
|
const marklessDefaultModuleSizes = ${JSON.stringify(moduleSizes)};
|
|
332
|
+
const marklessDefaultAttribution = ${JSON.stringify(options.attribution ?? null)};
|
|
331
333
|
const marklessSizesUrl = ${JSON.stringify(options.sizesUrl ?? null)};
|
|
332
334
|
let marklessSizesPromise;
|
|
335
|
+
let marklessAttribution;
|
|
336
|
+
let marklessInstallPromise;
|
|
333
337
|
function modules(log) { return log ? [...log] : []; }
|
|
334
338
|
function sizeRecord(input) { return !input ? undefined : typeof input === 'number' ? { raw: input, estimated: true } : input; }
|
|
335
|
-
function normalizeSizes(input) { if (!input) return undefined; const map = new Map(); for (const id of Object.keys(input)) map.set(id, sizeRecord(input[id])); return map; }
|
|
339
|
+
function normalizeSizes(input) { if (!input) return undefined; const map = new Map(); for (const id of Object.keys(input)) if (id !== 'attribution') map.set(id, sizeRecord(input[id])); return map; }
|
|
336
340
|
async function loadModuleSizes(input) {
|
|
337
341
|
if (input.moduleSizes) return normalizeSizes(input.moduleSizes);
|
|
338
|
-
if (marklessDefaultModuleSizes) return normalizeSizes(marklessDefaultModuleSizes);
|
|
342
|
+
if (marklessDefaultModuleSizes) { marklessAttribution = marklessDefaultAttribution; return normalizeSizes(marklessDefaultModuleSizes); }
|
|
339
343
|
if (!marklessSizesUrl) return undefined;
|
|
340
|
-
marklessSizesPromise ||= fetch(marklessSizesUrl).then((response) => response.ok ? response.json() : undefined).then(normalizeSizes).catch(() => undefined);
|
|
344
|
+
marklessSizesPromise ||= fetch(marklessSizesUrl).then((response) => response.ok ? response.json() : undefined).then((payload) => { marklessAttribution = payload && payload.attribution; return normalizeSizes(payload); }).catch(() => undefined);
|
|
341
345
|
return marklessSizesPromise;
|
|
342
346
|
}
|
|
343
347
|
function symbolParts(id) { const match = /^virtual:markless:symbol:([^:]+):([^:]+)$/.exec(id); if (!match) return null; try { return { source: decodeURIComponent(match[1]), symbolId: decodeURIComponent(match[2]) }; } catch { return null; } }
|
|
348
|
+
function baseSymbolId(id) { if (!id.startsWith('bound:')) return null; const separator = id.indexOf(':', 'bound:'.length); if (separator < 0) return null; try { return decodeURIComponent(id.slice('bound:'.length, separator)); } catch { return null; } }
|
|
349
|
+
function routeFile() { const text = document.querySelector?.('script[type="@markless/core/route"]')?.textContent; if (!text) return null; try { const value = JSON.parse(text).file; return typeof value === 'string' ? value : null; } catch { return null; } }
|
|
350
|
+
function qualifySymbolIds(ids, hostNodeId, sizes, tables) { const route = routeFile(); if (!route || route.includes('..') || route.includes('\\\\')) return ids; const canonical = route.replace(/^\\/+/, ''); const scopes = tables && Object.prototype.hasOwnProperty.call(tables, canonical) ? tables[canonical] : undefined; if (!scopes) return ids; const host = /^((?:c\\d+:)*)[^:]+$/.exec(hostNodeId); const hostScope = host && host[1]; return ids.map((id) => { const own = /^((?:c\\d+:)+)(.*)$/.exec(id); const scope = own ? own[1] : hostScope; if (scope === null || !Object.prototype.hasOwnProperty.call(scopes, scope)) return id; const local = own ? own[2] : id; const base = baseSymbolId(local); const sizeSymbolId = base || local; if (!sizeSymbolId.startsWith('symbol:')) return id; const matches = [...(sizes?.keys() || [])].filter((key) => { const match = /^virtual:markless:symbol:([^:]+):([^:]+)$/.exec(key); if (!match || match[1] !== scopes[scope]) return false; try { return decodeURIComponent(match[2]) === sizeSymbolId; } catch { return false; } }); if (matches.length !== 1) return id; if (!base) return matches[0]; const match = /^virtual:markless:symbol:([^:]+):/.exec(matches[0]); return match ? 'virtual:markless:symbol:' + match[1] + ':' + encodeURIComponent(local) : id; }); }
|
|
344
351
|
function canonicalId(id, sizes) {
|
|
345
352
|
if (!sizes || sizes.has(id)) return id;
|
|
346
|
-
const local = id.replace(/^(?:c\\d+:)+/, '');
|
|
347
|
-
if (!
|
|
348
|
-
const matches = [...sizes.keys()].filter((key) => { const parts = symbolParts(key); return !!parts && parts.symbolId ===
|
|
353
|
+
const qualified = symbolParts(id); const local = qualified ? qualified.symbolId : id.replace(/^(?:c\\d+:)+/, ''); const sizeSymbolId = baseSymbolId(local) || local;
|
|
354
|
+
if (!sizeSymbolId.startsWith('symbol:')) return id;
|
|
355
|
+
const matches = [...sizes.keys()].filter((key) => { const parts = symbolParts(key); return !!parts && parts.symbolId === sizeSymbolId && (!qualified || parts.source === qualified.source); });
|
|
349
356
|
return matches.length === 1 ? matches[0] : id;
|
|
350
357
|
}
|
|
351
358
|
function displayId(id) { const parts = symbolParts(id); return parts ? parts.symbolId + ' (' + (parts.source.split('/').pop() || parts.source) + ')' : id; }
|
|
352
|
-
function
|
|
353
|
-
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
+
function displayObservedId(id, sizes) { const parts = symbolParts(id); return displayId(baseSymbolId(parts ? parts.symbolId : id) ? id : canonicalId(id, sizes)); }
|
|
360
|
+
function accounting(items, sizes) {
|
|
361
|
+
const ids = [...new Set(items.map((id) => canonicalId(id, sizes)))];
|
|
362
|
+
if (!sizes) return { appBytes: ids.length ? null : 0, instrumentBytes: 0, appModules: ids.length, instrumentModules: 0, estimated: { app: false, instrument: false }, unmappedIds: [] };
|
|
363
|
+
let appBytes = 0, instrumentBytes = 0, appModules = 0, instrumentModules = 0, appEstimated = false, instrumentEstimated = false; const unmappedIds = [];
|
|
364
|
+
for (const id of ids) { const record = sizes.get(id); if (!record) { appModules++; unmappedIds.push(id); continue; } const bytes = record.estimated ? record.raw : (record.gzip ?? record.raw); if (record.instrument) { instrumentModules++; instrumentBytes += bytes; instrumentEstimated ||= !!record.estimated; } else { appModules++; appBytes += bytes; appEstimated ||= !!record.estimated; } }
|
|
365
|
+
return { appBytes: unmappedIds.length ? null : appBytes, instrumentBytes, appModules, instrumentModules, estimated: { app: appEstimated, instrument: instrumentEstimated }, unmappedIds };
|
|
366
|
+
}
|
|
367
|
+
function category(a, name) { const bytes = name === 'app' ? a.appBytes : a.instrumentBytes; const count = name === 'app' ? a.appModules : a.instrumentModules; if (bytes === null) return count + ' ' + name + ' module' + (count === 1 ? '' : 's') + (name === 'app' && a.unmappedIds.length ? ' (bytes unknown; ' + a.unmappedIds.length + ' unmapped)' : ''); return (bytes / 1024).toFixed(1) + ' KB' + (a.estimated[name] ? ' est. source' : '') + ' ' + name; }
|
|
368
|
+
function rowKb(items, sizes) { const a = accounting(items, sizes); if (a.unmappedIds.length) return 'bytes unknown'; const total = (a.appBytes || 0) + (a.instrumentBytes || 0); return (total / 1024).toFixed(1) + ' KB' + (a.estimated.app || a.estimated.instrument ? ' est. source' : ''); }
|
|
359
369
|
function warmIds(event) { return [...new Set([event.dispatchModuleId, ...((event.eventRecord && event.eventRecord.symbolIds) || [])].filter(Boolean))]; }
|
|
360
370
|
function causeRows(input) {
|
|
361
371
|
const before = input.before || new Set(); const after = input.after || new Set(); const woken = [...after].filter((id) => !before.has(id)); const record = input.eventRecord;
|
|
362
372
|
const cause = record ? input.eventName + ' matched event record ' + record.hostNodeId : input.eventName + ' matched runtime records';
|
|
363
|
-
const label = (id) =>
|
|
364
|
-
const rows = woken.map((id) => 'woke ' + label(id) + (input.moduleSizes ? ' (' +
|
|
365
|
-
if (record) for (const id of warmIds(input)) rows.push('ran warm ' + label(id) + (input.moduleSizes ? ' (' +
|
|
373
|
+
const label = (id) => displayObservedId(id, input.moduleSizes);
|
|
374
|
+
const rows = woken.map((id) => 'woke ' + label(id) + (input.moduleSizes ? ' (' + rowKb([id], input.moduleSizes) + (input.moduleSizes.get(canonicalId(id, input.moduleSizes))?.instrument ? ' instrument' : '') + ')' : '') + ' <- ' + cause);
|
|
375
|
+
if (record) for (const id of warmIds(input)) rows.push('ran warm ' + label(id) + (input.moduleSizes ? ' (' + rowKb([id], input.moduleSizes) + (input.moduleSizes.get(canonicalId(id, input.moduleSizes))?.instrument ? ' instrument' : '') + ')' : '') + ' <- ' + cause);
|
|
366
376
|
if (record && !(input.view?.behaviors || []).some((b) => b.hostNodeId === record.hostNodeId)) rows.push('skip behavior — no matching record touched');
|
|
367
377
|
return rows;
|
|
368
378
|
}
|
|
369
|
-
function mirror(text) {
|
|
379
|
+
function mirror(text, a) {
|
|
370
380
|
const root = document.documentElement; if (!root) return;
|
|
371
381
|
const count = Number(root.getAttribute('data-markless-log-interactions') || '0') + 1;
|
|
372
|
-
root.setAttribute('data-markless-log-interactions', String(count)); root.setAttribute('data-markless-log-last', text);
|
|
382
|
+
root.setAttribute('data-markless-log-interactions', String(count)); root.setAttribute('data-markless-log-last', text); mirrorBytes(root, a);
|
|
373
383
|
}
|
|
384
|
+
function mirrorBytes(root, a) { if (a.appBytes === null || a.instrumentBytes === null) { root.removeAttribute('data-markless-log-app-bytes'); root.removeAttribute('data-markless-log-instrument-bytes'); return; } root.setAttribute('data-markless-log-app-bytes', String(a.appBytes)); root.setAttribute('data-markless-log-instrument-bytes', String(a.instrumentBytes)); }
|
|
374
385
|
export async function installMarklessExecutionLog(input = {}) {
|
|
375
|
-
const log = globalThis.__mxLog; if (!log ||
|
|
376
|
-
|
|
386
|
+
const log = globalThis.__mxLog; if (!log || globalThis.__mxLogInteraction) return;
|
|
387
|
+
if (marklessInstallPromise) return marklessInstallPromise;
|
|
388
|
+
marklessInstallPromise = (async () => {
|
|
377
389
|
const moduleSizes = await loadModuleSizes(input); const preloaded = input.preloadedModuleCount || document.querySelectorAll('link[rel="modulepreload"]').length; const current = modules(log);
|
|
378
390
|
if (input.printResumeSummary !== false) {
|
|
379
|
-
const summary = 'markless: resumed — ' +
|
|
380
|
-
console.log(summary); document.documentElement
|
|
391
|
+
const a = accounting(current, moduleSizes); const summary = 'markless: resumed — ' + category(a, 'app') + ' executed, ' + preloaded + ' modules preloaded (' + a.appModules + ' app executed) · ' + category(a, 'instrument');
|
|
392
|
+
console.log(summary); const root = document.documentElement; if (root) { root.setAttribute('data-markless-log-summary', summary); mirrorBytes(root, a); }
|
|
381
393
|
}
|
|
382
394
|
globalThis.__mxLogInteraction = (event) => {
|
|
383
|
-
const
|
|
395
|
+
const capturedAfter = modules(event.after || log);
|
|
396
|
+
const symbolIds = qualifySymbolIds((event.eventRecord && event.eventRecord.symbolIds) || [], event.eventRecord && event.eventRecord.hostNodeId, moduleSizes, marklessAttribution);
|
|
397
|
+
if (event.eventRecord) event = { ...event, eventRecord: { ...event.eventRecord, symbolIds } };
|
|
398
|
+
const after = capturedAfter; const before = event.before || new Set(); if (log.has(${JSON.stringify(MARKLESS_EXECUTION_LOG_MODULE_ID)}) && !after.includes(${JSON.stringify(MARKLESS_EXECUTION_LOG_MODULE_ID)})) after.push(${JSON.stringify(MARKLESS_EXECUTION_LOG_MODULE_ID)}); const woken = after.filter((id) => !before.has(id)); const warm = warmIds(event);
|
|
384
399
|
if (event.noMatch) {
|
|
385
|
-
const line = 'markless: ' + event.eventName + ' [' + (event.selector || 'event target') + '] — no event record matched
|
|
386
|
-
console.info(line); mirror(line); return;
|
|
400
|
+
const a = accounting([], moduleSizes); const line = 'markless: ' + event.eventName + ' [' + (event.selector || 'event target') + '] — no event record matched · 0.0 KB app · 0.0 KB instrument';
|
|
401
|
+
console.info(line); mirror(line, a); return;
|
|
387
402
|
}
|
|
388
|
-
const header = 'markless: ' + event.eventName + ' [' + (event.selector || 'event target') + '] · woke ' + woken.length + ' modules · ran warm ' + warm.length + ' modules · ' +
|
|
403
|
+
const a = accounting([...woken, ...warm], moduleSizes); const header = 'markless: ' + event.eventName + ' [' + (event.selector || 'event target') + '] · woke ' + woken.length + ' modules · ran warm ' + warm.length + ' modules · ' + category(a, 'app') + ' · ' + category(a, 'instrument');
|
|
389
404
|
console.groupCollapsed(header);
|
|
390
405
|
for (const row of causeRows({ ...event, after: new Set(after), moduleSizes })) console.log(row);
|
|
391
|
-
console.groupEnd(); mirror(header);
|
|
406
|
+
console.groupEnd(); mirror(header, a);
|
|
392
407
|
};
|
|
408
|
+
log.__marklessInstalled = true;
|
|
409
|
+
})();
|
|
410
|
+
return marklessInstallPromise;
|
|
393
411
|
}
|
|
394
412
|
export async function logMarklessInteraction(event) { await installMarklessExecutionLog({ printResumeSummary: false }); globalThis.__mxLogInteraction?.(event); }
|
|
413
|
+
export async function logMarklessSpecializedInteraction(input, before) {
|
|
414
|
+
const target = input.element ?? input.event?.target;
|
|
415
|
+
const tag = typeof target?.tagName === 'string' ? target.tagName.toLowerCase() : 'element';
|
|
416
|
+
await logMarklessInteraction({ eventName: input.event?.type ?? 'event', eventRecord: input.eventRecord, before, selector: tag + (target?.id ? '#' + target.id : ''), after: new Set(globalThis.__mxLog) });
|
|
417
|
+
}
|
|
395
418
|
export async function logMarklessRenderSummary(input = {}) {
|
|
396
419
|
const log = globalThis.__mxLog; if (!log) return;
|
|
397
|
-
const moduleSizes = await loadModuleSizes(input); const current = modules(log);
|
|
398
|
-
const summary = 'markless: rendered — ' +
|
|
399
|
-
console.log(summary); document.documentElement
|
|
420
|
+
const moduleSizes = await loadModuleSizes(input); const current = modules(log); const a = accounting(current, moduleSizes);
|
|
421
|
+
const summary = 'markless: rendered — ' + a.appModules + ' app module' + (a.appModules === 1 ? '' : 's') + ' executed (' + category(a, 'app') + ') · ' + a.instrumentModules + ' instrument module' + (a.instrumentModules === 1 ? '' : 's') + ' executed (' + category(a, 'instrument').replace(/ instrument$/, '') + ')';
|
|
422
|
+
console.log(summary); const root = document.documentElement; if (root) { root.setAttribute('data-markless-log-summary', summary); mirrorBytes(root, a); }
|
|
400
423
|
}
|
|
401
424
|
`;
|
|
402
425
|
}
|
|
403
|
-
async function createExecutionSizesAsset(bundle, metadata, canonPath = (fileName) => fileName) {
|
|
426
|
+
async function createExecutionSizesAsset(bundle, metadata, canonPath = (fileName) => fileName, attribution) {
|
|
404
427
|
const entries = {};
|
|
405
428
|
const symbolLogIdsByChunk = /* @__PURE__ */ new Map();
|
|
406
429
|
for (const module of metadata.modules) for (const symbol of module.symbols) {
|
|
@@ -414,17 +437,27 @@ async function createExecutionSizesAsset(bundle, metadata, canonPath = (fileName
|
|
|
414
437
|
const chunk = canonPath(item.fileName);
|
|
415
438
|
const logIds = new Set([...item.moduleIds.flatMap((id) => chunkModuleLogId(id) ?? []), ...symbolLogIdsByChunk.get(chunk) ?? []]);
|
|
416
439
|
if (logIds.size === 0) continue;
|
|
440
|
+
if (logIds.has("virtual:markless:dev-log") && logIds.size > 1) {
|
|
441
|
+
const cohabitingIds = [...logIds].filter((id) => id !== MARKLESS_EXECUTION_LOG_MODULE_ID).sort();
|
|
442
|
+
throw new Error(`Markless execution sizes require an isolated dev-log chunk; chunk "${chunk}" also contains logged module ids: ${cohabitingIds.join(", ")}.`);
|
|
443
|
+
}
|
|
417
444
|
const size = {
|
|
418
445
|
raw: item.code.length,
|
|
419
446
|
gzip: await gzipByteLength(item.code),
|
|
420
447
|
chunk
|
|
421
448
|
};
|
|
422
|
-
for (const id of logIds) entries[id] =
|
|
449
|
+
for (const id of logIds) entries[id] = id === "virtual:markless:dev-log" ? {
|
|
450
|
+
...size,
|
|
451
|
+
instrument: true
|
|
452
|
+
} : size;
|
|
423
453
|
}
|
|
424
454
|
return {
|
|
425
455
|
type: "asset",
|
|
426
456
|
fileName: MARKLESS_EXECUTION_SIZES,
|
|
427
|
-
source: JSON.stringify(
|
|
457
|
+
source: JSON.stringify({
|
|
458
|
+
...sortRecord(entries),
|
|
459
|
+
...attribution && Object.keys(attribution).length > 0 ? { attribution: sortNestedRecord(attribution) } : {}
|
|
460
|
+
})
|
|
428
461
|
};
|
|
429
462
|
}
|
|
430
463
|
function executionLogActivationInjection(mode) {
|
|
@@ -463,6 +496,11 @@ function sortRecord(record) {
|
|
|
463
496
|
for (const key of Object.keys(record).sort()) next[key] = record[key];
|
|
464
497
|
return next;
|
|
465
498
|
}
|
|
499
|
+
function sortNestedRecord(record) {
|
|
500
|
+
const next = {};
|
|
501
|
+
for (const key of Object.keys(record).sort()) next[key] = sortRecord({ ...record[key] });
|
|
502
|
+
return next;
|
|
503
|
+
}
|
|
466
504
|
//#endregion
|
|
467
505
|
//#region src/source-module.ts
|
|
468
506
|
const MARKLESS_VIRTUAL_PREFIX = "virtual:markless:";
|
|
@@ -471,6 +509,9 @@ const SYMBOL_VIRTUAL_PREFIX = `${MARKLESS_VIRTUAL_PREFIX}symbol:`;
|
|
|
471
509
|
function symbolVirtualModuleId(filename, symbolId) {
|
|
472
510
|
return `${SYMBOL_VIRTUAL_PREFIX}${encodeURIComponent(filename)}:${encodeURIComponent(symbolId)}`;
|
|
473
511
|
}
|
|
512
|
+
function encodedSymbolSource(filename) {
|
|
513
|
+
return encodeURIComponent(filename);
|
|
514
|
+
}
|
|
474
515
|
function symbolVirtualModuleSourceFile(moduleId) {
|
|
475
516
|
const bare = moduleId.startsWith("\0") ? moduleId.slice(1) : moduleId;
|
|
476
517
|
if (!bare.startsWith(SYMBOL_VIRTUAL_PREFIX)) return null;
|
|
@@ -501,6 +542,20 @@ function payloadModule(payload) {
|
|
|
501
542
|
""
|
|
502
543
|
].join("\n");
|
|
503
544
|
}
|
|
545
|
+
function emitPublicRenderModule(source, input) {
|
|
546
|
+
if (!input.executionLogEnabled || !input.rootExportName) return source;
|
|
547
|
+
const declaration = `export function ${input.rootExportName}()`;
|
|
548
|
+
if (!source.includes(declaration)) return source;
|
|
549
|
+
const implementationName = `marklessRender${input.rootExportName}`;
|
|
550
|
+
return [
|
|
551
|
+
source.replace(declaration, `function ${implementationName}()`),
|
|
552
|
+
`export function ${input.rootExportName}() {`,
|
|
553
|
+
`\tconst output = ${implementationName}();`,
|
|
554
|
+
" globalThis.__mxLoadLog().then(log => log.logMarklessRenderSummary());",
|
|
555
|
+
" return output;",
|
|
556
|
+
"}"
|
|
557
|
+
].join("\n");
|
|
558
|
+
}
|
|
504
559
|
function emitSourceModule(input) {
|
|
505
560
|
const symbolsOnly = input.environment === "client" && input.clientOutput === "symbols-only";
|
|
506
561
|
const routeSymbols = input.environment === "client" && input.symbolRoutes.length > 0;
|
|
@@ -515,7 +570,10 @@ function emitSourceModule(input) {
|
|
|
515
570
|
symbolsOnly ? "" : "export { payloadRuntimeDemandMap };",
|
|
516
571
|
input.devResumeReexport && input.environment === "client" ? `export { resumeContainerEvent } from '${resumeVirtualModuleId(input.filename)}';` : "",
|
|
517
572
|
"",
|
|
518
|
-
input.environment === "server" || symbolsOnly ? "" : input.publicRenderModuleSource,
|
|
573
|
+
input.environment === "server" || symbolsOnly ? "" : emitPublicRenderModule(input.publicRenderModuleSource, {
|
|
574
|
+
executionLogEnabled: input.executionLog !== "never",
|
|
575
|
+
rootExportName: input.publicRenderRootExportName
|
|
576
|
+
}),
|
|
519
577
|
input.environment === "server" || symbolsOnly ? "" : input.publicCsrModuleSource,
|
|
520
578
|
input.environment === "client" ? "" : input.publicSsrModuleSource,
|
|
521
579
|
routeSymbols ? emitLazySymbolRouteFunction(input.symbolRoutes, "marklessSsrLoadSymbolRoute", "marklessLoadLocalSymbol") : "",
|
|
@@ -524,6 +582,8 @@ function emitSourceModule(input) {
|
|
|
524
582
|
environment: input.environment,
|
|
525
583
|
executionLog: input.executionLog,
|
|
526
584
|
headInjections: input.headInjections,
|
|
585
|
+
storageSeeds: input.storageSeeds,
|
|
586
|
+
inlineResumerSources: input.inlineResumerSources,
|
|
527
587
|
resumeModuleUrl: input.resumeModuleUrl,
|
|
528
588
|
rootExportName: input.publicRenderRootExportName,
|
|
529
589
|
csrExportName: input.publicRenderCsrExportName,
|
|
@@ -550,7 +610,7 @@ function emitResumeModule(input) {
|
|
|
550
610
|
routeSymbols ? "const marklessLoadLocalSymbol = loadSymbol;" : "",
|
|
551
611
|
routeSymbols ? emitLazySymbolRouteFunction(input.symbolRoutes, "marklessSsrLoadSymbolRoute", "marklessLoadLocalSymbol") : "",
|
|
552
612
|
routeSymbols ? "export { marklessSsrLoadSymbolRoute as loadSymbol };" : "",
|
|
553
|
-
emitResumeContainerEvent(resumeSymbolLoader, input.needsFullResume ?? false, input.symbolRoutes.length > 0 ? "none" : leanResumeMode(input.runtimeDemandMap), scalarSpecializations, input.runtimeDemandMap),
|
|
613
|
+
emitResumeContainerEvent(resumeSymbolLoader, input.needsFullResume ?? false, input.symbolRoutes.length > 0 ? "none" : leanResumeMode(input.runtimeDemandMap), scalarSpecializations, input.runtimeDemandMap, input.executionLog !== "never"),
|
|
554
614
|
""
|
|
555
615
|
].filter((line) => line !== null).join("\n");
|
|
556
616
|
}
|
|
@@ -578,11 +638,15 @@ function emitCompiledAppDefault(input) {
|
|
|
578
638
|
" },"
|
|
579
639
|
] : [];
|
|
580
640
|
const resumeModuleEntry = input.resumeModuleUrl && input.environment !== "client" ? [` resumeModuleUrl: ${JSON.stringify(input.resumeModuleUrl)},`] : [];
|
|
641
|
+
const inlineResumerEntry = input.inlineResumerSources && input.environment !== "client" ? [`\tinlineResumerSources: ${JSON.stringify(input.inlineResumerSources)},`] : [];
|
|
581
642
|
const headInjectionEntry = input.headInjections?.length && input.environment !== "client" ? [` headInjections: ${JSON.stringify(input.headInjections)},`] : [];
|
|
643
|
+
const storageSeedEntry = input.storageSeeds?.length && input.environment !== "client" ? [`\tstorageSeeds: ${JSON.stringify(input.storageSeeds)},`] : [];
|
|
582
644
|
const modulePreloadEntry = input.resumeModuleUrl && input.environment === "server" ? [` modulePreloads: [{ href: ${JSON.stringify(input.resumeModuleUrl)}, fetchPriority: "high" }],`] : [];
|
|
583
645
|
const metadataEntries = input.environment === "client" ? [] : [
|
|
584
646
|
...headInjectionEntry,
|
|
647
|
+
...storageSeedEntry,
|
|
585
648
|
...resumeModuleEntry,
|
|
649
|
+
...inlineResumerEntry,
|
|
586
650
|
...modulePreloadEntry,
|
|
587
651
|
input.executionLog && input.executionLog !== "never" ? ` executionLog: ${JSON.stringify(input.executionLog)},` : "",
|
|
588
652
|
" payloadView,"
|
|
@@ -596,7 +660,7 @@ function emitCompiledAppDefault(input) {
|
|
|
596
660
|
"export default marklessCompiledApp;"
|
|
597
661
|
].join("\n");
|
|
598
662
|
}
|
|
599
|
-
function emitResumeContainerEvent(loadSymbolName, needsFullResume, leanMode, scalarSpecializations, runtimeDemandMap) {
|
|
663
|
+
function emitResumeContainerEvent(loadSymbolName, needsFullResume, leanMode, scalarSpecializations, runtimeDemandMap, executionLogEnabled) {
|
|
600
664
|
const fullResumeHandoff = [
|
|
601
665
|
"async function marklessFullResumeHandoff(handoff) {",
|
|
602
666
|
" handoff.root.__asyncResumeRuntimeStarted = true;",
|
|
@@ -636,7 +700,9 @@ function emitResumeContainerEvent(loadSymbolName, needsFullResume, leanMode, sca
|
|
|
636
700
|
scalarOnlySpecialized ? "" : fullResumeHandoff,
|
|
637
701
|
scalarDispatcher,
|
|
638
702
|
"export async function resumeContainerEvent(input) {",
|
|
703
|
+
executionLogEnabled ? " const marklessLogBefore = globalThis.__mxLog && new Set(globalThis.__mxLog);" : "",
|
|
639
704
|
" await marklessResumeSpecializedScalarEvent(input);",
|
|
705
|
+
executionLogEnabled ? " if (marklessLogBefore) globalThis.__mxLoadLog().then(log => log.logMarklessSpecializedInteraction(input, marklessLogBefore));" : "",
|
|
640
706
|
"}"
|
|
641
707
|
].join("\n");
|
|
642
708
|
if (leanMode === "row") return [
|
|
@@ -758,7 +824,10 @@ function emitScalarAction(action, loadSymbolName) {
|
|
|
758
824
|
return [
|
|
759
825
|
`async function ${action.name}(input) {`,
|
|
760
826
|
" let syncPolicyAlreadyApplied = input.syncPolicyAlreadyApplied === true;",
|
|
761
|
-
|
|
827
|
+
" const values = input.root.__marklessEventOnlyGraph || new Map();",
|
|
828
|
+
" input.root.__marklessEventOnlyGraph = values;",
|
|
829
|
+
` if (!values.has(${JSON.stringify(action.cell)})) values.set(${JSON.stringify(action.cell)}, marklessDecodeScalarCell(marklessReadScalarCell(input.root, ${action.cellIndex}), ${JSON.stringify(action.cell)}, ${JSON.stringify(`markless/state cell[${action.cellIndex}]`)}));`,
|
|
830
|
+
` const state = { value: values.get(${JSON.stringify(action.cell)}), dirty: false };`,
|
|
762
831
|
" try {",
|
|
763
832
|
` const host = marklessFindElementAtDomOrderIndex(input.root, ${action.hostIndex});`,
|
|
764
833
|
` if (!host || (${JSON.stringify(action.hostTagName.toLowerCase())} !== "*" && host.tagName.toLowerCase() !== ${JSON.stringify(action.hostTagName.toLowerCase())})) return marklessScalarSpecializedHostMiss(input, "host");`,
|
|
@@ -767,8 +836,8 @@ function emitScalarAction(action, loadSymbolName) {
|
|
|
767
836
|
" const graph = {",
|
|
768
837
|
` hasCell(graphNodeId) { return graphNodeId === ${JSON.stringify(action.cell)}; },`,
|
|
769
838
|
` read(graphNodeId, path = []) { if (graphNodeId !== ${JSON.stringify(action.cell)} || path.length) return marklessScalarSpecializedError("MARKLESS_SCALAR_SPECIALIZED_ESCALATE", "read"); return state.value; },`,
|
|
770
|
-
` write(write) { if (write.graphNodeId !== ${JSON.stringify(action.cell)} || (write.path?.length ?? 0)) return marklessScalarSpecializedError("MARKLESS_SCALAR_SPECIALIZED_ESCALATE", "write"); if (!Object.is(state.value, write.value)) { state.value = write.value; state.dirty = true; } },`,
|
|
771
|
-
` update(update) { if (update.graphNodeId !== ${JSON.stringify(action.cell)} || (update.path?.length ?? 0)) return marklessScalarSpecializedError("MARKLESS_SCALAR_SPECIALIZED_ESCALATE", "update"); const previous = state.value; const next = update.update(previous); if (!Object.is(previous, next)) { state.value = next; state.dirty = true; } return update.returnValue === "previous" ? previous : update.returnValue === "next" ? next : undefined; },`,
|
|
839
|
+
` write(write) { if (write.graphNodeId !== ${JSON.stringify(action.cell)} || (write.path?.length ?? 0)) return marklessScalarSpecializedError("MARKLESS_SCALAR_SPECIALIZED_ESCALATE", "write"); if (!Object.is(state.value, write.value)) { state.value = write.value; values.set(${JSON.stringify(action.cell)}, state.value); state.dirty = true; } },`,
|
|
840
|
+
` update(update) { if (update.graphNodeId !== ${JSON.stringify(action.cell)} || (update.path?.length ?? 0)) return marklessScalarSpecializedError("MARKLESS_SCALAR_SPECIALIZED_ESCALATE", "update"); const previous = state.value; const next = update.update(previous); if (!Object.is(previous, next)) { state.value = next; values.set(${JSON.stringify(action.cell)}, state.value); state.dirty = true; } return update.returnValue === "previous" ? previous : update.returnValue === "next" ? next : undefined; },`,
|
|
772
841
|
" call() { return marklessScalarSpecializedError(\"MARKLESS_SCALAR_SPECIALIZED_ESCALATE\", \"call\"); },",
|
|
773
842
|
" async flush() {},",
|
|
774
843
|
" };",
|
|
@@ -839,7 +908,7 @@ function emitExecutionLogLoader() {
|
|
|
839
908
|
return `globalThis.__mxLoadLog ||= () => import(${JSON.stringify(MARKLESS_EXECUTION_LOG_MODULE_ID)});`;
|
|
840
909
|
}
|
|
841
910
|
function emitLoadSymbol(input) {
|
|
842
|
-
if (input.symbols.length > 0 && input.symbols.length <= SMALL_SYMBOL_DIRECT_LOAD_LIMIT) return emitDirectSourceSymbolLoader(input.symbols);
|
|
911
|
+
if (!input.hasBoundSymbols && input.symbols.length > 0 && input.symbols.length <= SMALL_SYMBOL_DIRECT_LOAD_LIMIT) return emitDirectSourceSymbolLoader(input.symbols);
|
|
843
912
|
return [
|
|
844
913
|
`const marklessSymbolResolverModule = () => import('${input.resolverId}');`,
|
|
845
914
|
"function loadSymbol(symbolId) {",
|
|
@@ -873,4 +942,4 @@ function stringHash(value) {
|
|
|
873
942
|
return (hash >>> 0).toString(36);
|
|
874
943
|
}
|
|
875
944
|
//#endregion
|
|
876
|
-
export { planModulePreloads as S,
|
|
945
|
+
export { planModulePreloads as C, planModulePreloadUrls as S, normalizeExecutionLogMode as _, payloadModule as a, MARKLESS_BUNDLE_GRAPH as b, scopedSymbolExportName as c, MARKLESS_EXECUTION_LOG_MODULE_ID as d, MARKLESS_EXECUTION_SIZES as f, injectExecutionLogModuleHook as g, executionLogVirtualModuleSource as h, encodedSymbolSource as i, symbolVirtualModuleId as l, executionLogActivationInjection as m, emitResumeModule as n, resumeVirtualModuleId as o, createExecutionSizesAsset as p, emitSourceModule as r, rewriteSymbolModuleExport as s, MARKLESS_VIRTUAL_PREFIX as t, symbolVirtualModuleSourceFile as u, requalifyExecutionLogModuleHook as v, outputDefaults as x, MARKLESS_BUILD_PREFIX as y };
|
|
@@ -28,14 +28,17 @@ interface MarklessVirtualModule {
|
|
|
28
28
|
interface TransformTsrxModuleInput {
|
|
29
29
|
filename: string;
|
|
30
30
|
source: string;
|
|
31
|
+
symbols?: _$_markless_compiler0.SymbolResolverModuleInput['symbols'];
|
|
31
32
|
devResumeReexport?: boolean;
|
|
32
33
|
buildId?: string;
|
|
33
34
|
environment?: MarklessEnvironment;
|
|
34
35
|
clientOutput?: MarklessClientOutput;
|
|
35
36
|
resumeModuleUrl?: string;
|
|
36
37
|
headInjections?: GlobalInjections[];
|
|
38
|
+
styleModuleUrl?: (virtualModuleId: string) => string;
|
|
37
39
|
executionLog?: MarklessExecutionLogMode;
|
|
38
40
|
executionLogModuleHooks?: boolean;
|
|
41
|
+
inlineResumerDebug?: boolean;
|
|
39
42
|
}
|
|
40
43
|
interface TransformTsrxModuleResult {
|
|
41
44
|
code: string;
|
|
@@ -45,6 +48,12 @@ interface TransformTsrxModuleResult {
|
|
|
45
48
|
}
|
|
46
49
|
interface MarklessTransformManifest {
|
|
47
50
|
source: string;
|
|
51
|
+
captureMetadata?: _$_markless_compiler0.CaptureAnalysisArtifact;
|
|
52
|
+
symbolRoutes?: ReadonlyArray<{
|
|
53
|
+
readonly prefix: string;
|
|
54
|
+
readonly importSource: string;
|
|
55
|
+
readonly componentEdgeId?: string;
|
|
56
|
+
}>;
|
|
48
57
|
payload: MarklessBuildModuleReference;
|
|
49
58
|
resolver: MarklessBuildModuleReference;
|
|
50
59
|
symbols: MarklessSymbolManifestEntry[];
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { c as MarklessEnvironment, g as PreloadGraphEntriesAdder, h as PreloadGraphEntries, i as MarklessBuildMetadata, l as MarklessManifest, m as PreloadGraphContext, n as GlobalInjections, t as BundleGraphAdder, u as MarklessRolldownOptions } from "./types-
|
|
1
|
+
import { c as MarklessEnvironment, g as PreloadGraphEntriesAdder, h as PreloadGraphEntries, i as MarklessBuildMetadata, l as MarklessManifest, m as PreloadGraphContext, n as GlobalInjections, t as BundleGraphAdder, u as MarklessRolldownOptions } from "./types-CzXV_ABj.js";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/vite/index.d.ts
|
|
5
5
|
interface MarklessViteOptions extends MarklessRolldownOptions {
|
|
6
6
|
clientEnvironment?: string;
|
|
7
|
+
debug?: boolean;
|
|
7
8
|
serverEnvironment?: string;
|
|
8
9
|
}
|
|
9
10
|
declare function markless(options?: MarklessViteOptions): Plugin[];
|