@markless/bundler 0.7.0 → 0.9.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.js +1 -2
- package/dist/{execution-log-BL-7a77M.d.ts → execution-log-6xkAwVG_.d.ts} +2 -2
- package/dist/preload.d.ts +2 -2
- package/dist/preload.js +1 -1
- package/dist/{rolldown-DpkfQO1h.js → rolldown-Bh_TCkt_.js} +367 -550
- package/dist/rolldown.d.ts +3 -3
- package/dist/rolldown.js +2 -2
- package/dist/{roster-resume-CpphsFl_.js → roster-resume-DXptD6DG.js} +2 -1
- package/dist/{route-pack-groups-BXc755qH.js → route-pack-groups-0vHmSVdv.js} +583 -18
- package/dist/{types-iOUoceJ-.d.ts → types-5srcMsXU.d.ts} +10 -0
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +149 -37
- package/package.json +8 -8
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { joinURL, parsePath, withQuery, withoutLeadingSlash } from "ufo";
|
|
2
|
+
import { INLINE_RESUMER_PAGE_TOKEN, PRERENDER_INLINE_EVENT_NAMES_TOKEN, createInlineResumerDebugRegistrationSource, createInlineResumerSelfWakeSource, createInlineResumerSource, createPrerenderInlineResumerSource, createPrerenderSettleInlineResumerSource } from "@markless/web/inline/resumer";
|
|
2
3
|
import { MARKLESS_COMPONENT_PART_BRAND } from "@markless/web/render-to-string";
|
|
3
4
|
import { ASYNC_PROTOCOL_VERSION, PROTOCOL_EVENT_ACTION_KIND, protocolEventActionKind } from "@markless/serializer";
|
|
4
5
|
import { isAbsolute, resolve } from "pathe";
|
|
@@ -415,6 +416,535 @@ function executionLogActivationInjection(mode) {
|
|
|
415
416
|
};
|
|
416
417
|
}
|
|
417
418
|
//#endregion
|
|
419
|
+
//#region ../web/src/debug-channel.ts
|
|
420
|
+
function installDebugChannelLayer(root, initialPhase, initiallyActive = true) {
|
|
421
|
+
const global = globalThis;
|
|
422
|
+
const previous = global.__MARKLESS_DEBUG__?.version === 1 ? global.__MARKLESS_DEBUG__ : void 0;
|
|
423
|
+
let priorRoot;
|
|
424
|
+
try {
|
|
425
|
+
priorRoot = previous?.explainInteraction(root, "__markless_debug_root__");
|
|
426
|
+
} catch {}
|
|
427
|
+
const priorContainer = priorRoot && "containerId" in priorRoot ? previous?.containers.find((entry) => entry.id === priorRoot.containerId) : void 0;
|
|
428
|
+
const seed = `${Date.now().toString(36)}:${Math.random().toString(36).slice(2)}`;
|
|
429
|
+
const id = priorContainer?.id ?? `container:${seed}`;
|
|
430
|
+
const rootKey = priorContainer?.root.key ?? `root:${seed}`;
|
|
431
|
+
const rootRef = new WeakRef(root);
|
|
432
|
+
const events = /* @__PURE__ */ new WeakMap();
|
|
433
|
+
const delegatedEvents = /* @__PURE__ */ new Set();
|
|
434
|
+
const keys = /* @__PURE__ */ new WeakMap();
|
|
435
|
+
const invalidated = /* @__PURE__ */ new WeakSet();
|
|
436
|
+
const routerSources = global[Symbol.for("markless.debug.channel.v1.router-sources")] ??= /* @__PURE__ */ new Set();
|
|
437
|
+
const ownViolations = [];
|
|
438
|
+
let phase = initialPhase;
|
|
439
|
+
let lifecycle = initiallyActive ? "active" : "registered";
|
|
440
|
+
let boundarySnapshots = Object.freeze([]);
|
|
441
|
+
let nextElement = 1;
|
|
442
|
+
let nextSequence = (previous?.violations.at(-1)?.sequence ?? 0) + 1;
|
|
443
|
+
let dropped = 0;
|
|
444
|
+
let pruned = false;
|
|
445
|
+
const freeze = (value) => Object.freeze(value);
|
|
446
|
+
const contains = (element) => {
|
|
447
|
+
const currentRoot = rootRef.deref();
|
|
448
|
+
return !!currentRoot && (currentRoot === element || currentRoot.contains?.(element) === true);
|
|
449
|
+
};
|
|
450
|
+
const keyFor = (element) => {
|
|
451
|
+
let key = keys.get(element);
|
|
452
|
+
if (!key) {
|
|
453
|
+
key = `${rootKey}:element:${nextElement++}`;
|
|
454
|
+
keys.set(element, key);
|
|
455
|
+
}
|
|
456
|
+
return key;
|
|
457
|
+
};
|
|
458
|
+
const eligibleAnchor = (element) => {
|
|
459
|
+
const anchor = element.closest?.("a[href]");
|
|
460
|
+
if (!anchor?.hasAttribute("data-markless-router-link") || anchor.hasAttribute("download")) return false;
|
|
461
|
+
const target = anchor.getAttribute("target");
|
|
462
|
+
if (target && target !== "_self" || anchor.relList?.contains("external")) return false;
|
|
463
|
+
try {
|
|
464
|
+
const base = global.location?.href ?? "http://localhost/";
|
|
465
|
+
return new URL(anchor.href ?? "", base).origin === new URL(base).origin;
|
|
466
|
+
} catch {
|
|
467
|
+
return false;
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
const none = (element, eventName, reason) => freeze({
|
|
471
|
+
kind: "none",
|
|
472
|
+
eventName,
|
|
473
|
+
reason,
|
|
474
|
+
containerId: id,
|
|
475
|
+
elementKey: keyFor(element)
|
|
476
|
+
});
|
|
477
|
+
const explain = (element, eventName) => {
|
|
478
|
+
if (lifecycle === "disposed" && (contains(element) || keys.has(element))) return none(element, eventName, "container-disposed");
|
|
479
|
+
if (!contains(element)) try {
|
|
480
|
+
return previous?.explainInteraction(element, eventName) ?? freeze({
|
|
481
|
+
kind: "none",
|
|
482
|
+
eventName,
|
|
483
|
+
reason: "outside-known-container"
|
|
484
|
+
});
|
|
485
|
+
} catch {
|
|
486
|
+
return freeze({
|
|
487
|
+
kind: "none",
|
|
488
|
+
eventName,
|
|
489
|
+
reason: "outside-known-container"
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
if (element.isConnected === false) return none(element, eventName, "element-disconnected");
|
|
493
|
+
if (eligibleAnchor(element)) {
|
|
494
|
+
const source = eventName === "navigate" && routerSources.has("navigation-event") ? "navigation-event" : eventName === "click" && routerSources.has("spa-click-listener") ? "spa-click-listener" : eventName === "click" && routerSources.has("ssr-link-bridge") ? "ssr-link-bridge" : void 0;
|
|
495
|
+
if (source) return freeze({
|
|
496
|
+
kind: "router-delegation",
|
|
497
|
+
source,
|
|
498
|
+
containerId: id,
|
|
499
|
+
elementKey: keyFor(element),
|
|
500
|
+
eventName
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
const interaction = events.get(element)?.get(eventName);
|
|
504
|
+
if (interaction) return freeze({ ...interaction });
|
|
505
|
+
if (delegatedEvents.has(eventName)) return freeze({
|
|
506
|
+
kind: "inline-resumer",
|
|
507
|
+
source: "ssr-inline",
|
|
508
|
+
containerId: id,
|
|
509
|
+
elementKey: keyFor(element),
|
|
510
|
+
eventName
|
|
511
|
+
});
|
|
512
|
+
if (invalidated.has(element)) return none(element, eventName, "not-registered");
|
|
513
|
+
try {
|
|
514
|
+
const prior = previous?.explainInteraction(element, eventName);
|
|
515
|
+
if (prior && prior.kind !== "none") return prior;
|
|
516
|
+
} catch {}
|
|
517
|
+
return none(element, eventName, "not-registered");
|
|
518
|
+
};
|
|
519
|
+
const cloneJson = (value, seen = /* @__PURE__ */ new Set()) => {
|
|
520
|
+
if (value === null) return null;
|
|
521
|
+
if (typeof value === "boolean" || typeof value === "string") return value;
|
|
522
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
|
|
523
|
+
if (!value || typeof value !== "object" || seen.has(value)) return void 0;
|
|
524
|
+
seen.add(value);
|
|
525
|
+
if (Array.isArray(value)) {
|
|
526
|
+
const copy = value.map((entry) => cloneJson(entry, seen));
|
|
527
|
+
return copy.some((entry) => entry === void 0) ? void 0 : freeze(copy);
|
|
528
|
+
}
|
|
529
|
+
if (Object.getPrototypeOf(value) !== Object.prototype) return void 0;
|
|
530
|
+
const copy = {};
|
|
531
|
+
for (const [name, entry] of Object.entries(value)) {
|
|
532
|
+
const cloned = cloneJson(entry, seen);
|
|
533
|
+
if (cloned === void 0) return void 0;
|
|
534
|
+
copy[name] = cloned;
|
|
535
|
+
}
|
|
536
|
+
return freeze(copy);
|
|
537
|
+
};
|
|
538
|
+
const pushViolation = (input) => {
|
|
539
|
+
const cloned = input.details === void 0 ? void 0 : cloneJson(input.details);
|
|
540
|
+
const details = cloned && !Array.isArray(cloned) && typeof cloned === "object" ? cloned : void 0;
|
|
541
|
+
const { details: _details, ...metadata } = input;
|
|
542
|
+
ownViolations.push(freeze({
|
|
543
|
+
...metadata,
|
|
544
|
+
...details ? { details } : {},
|
|
545
|
+
sequence: nextSequence++,
|
|
546
|
+
timestamp: Date.now()
|
|
547
|
+
}));
|
|
548
|
+
if (input.details !== void 0 && !details) ownViolations.push(freeze({
|
|
549
|
+
code: "MARKLESS_DEBUG_DETAILS_DROPPED",
|
|
550
|
+
message: "Debug violation details were not JSON-safe and were dropped.",
|
|
551
|
+
sequence: nextSequence++,
|
|
552
|
+
timestamp: Date.now()
|
|
553
|
+
}));
|
|
554
|
+
while (ownViolations.length > 100) {
|
|
555
|
+
ownViolations.shift();
|
|
556
|
+
dropped++;
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
const channel = freeze({
|
|
560
|
+
version: 1,
|
|
561
|
+
get containers() {
|
|
562
|
+
const inherited = previous?.containers.filter((entry) => entry.id !== id) ?? [];
|
|
563
|
+
if (pruned || lifecycle === "disposed") return freeze([...inherited]);
|
|
564
|
+
const currentRoot = rootRef.deref();
|
|
565
|
+
const connected = !!currentRoot && currentRoot.isConnected !== false;
|
|
566
|
+
const snapshot = freeze({
|
|
567
|
+
id,
|
|
568
|
+
phase,
|
|
569
|
+
lifecycle: connected ? lifecycle : "disposed",
|
|
570
|
+
root: freeze({
|
|
571
|
+
key: rootKey,
|
|
572
|
+
connected
|
|
573
|
+
}),
|
|
574
|
+
boundaries: freeze([...boundarySnapshots])
|
|
575
|
+
});
|
|
576
|
+
if (!connected) pruned = true;
|
|
577
|
+
return freeze([...inherited, snapshot]);
|
|
578
|
+
},
|
|
579
|
+
get violations() {
|
|
580
|
+
return freeze([...previous?.violations ?? [], ...ownViolations].slice(-100));
|
|
581
|
+
},
|
|
582
|
+
violationCapacity: 100,
|
|
583
|
+
get droppedViolationCount() {
|
|
584
|
+
return (previous?.droppedViolationCount ?? 0) + dropped;
|
|
585
|
+
},
|
|
586
|
+
explainInteraction: explain
|
|
587
|
+
});
|
|
588
|
+
Object.defineProperty(global, "__MARKLESS_DEBUG__", {
|
|
589
|
+
configurable: true,
|
|
590
|
+
enumerable: false,
|
|
591
|
+
value: channel,
|
|
592
|
+
writable: false
|
|
593
|
+
});
|
|
594
|
+
return {
|
|
595
|
+
start(nextPhase, active = true) {
|
|
596
|
+
phase = nextPhase === "ssr-resume" && phase === "csr" ? "csr" : nextPhase;
|
|
597
|
+
if (active) lifecycle = "active";
|
|
598
|
+
return id;
|
|
599
|
+
},
|
|
600
|
+
activate: () => void (lifecycle === "disposed" || (lifecycle = "active")),
|
|
601
|
+
dispose() {
|
|
602
|
+
lifecycle = "disposed";
|
|
603
|
+
boundarySnapshots = freeze([]);
|
|
604
|
+
},
|
|
605
|
+
invalidate(element) {
|
|
606
|
+
events.delete(element);
|
|
607
|
+
invalidated.add(element);
|
|
608
|
+
},
|
|
609
|
+
record(element, eventName, input) {
|
|
610
|
+
if (lifecycle === "disposed") return;
|
|
611
|
+
let byName = events.get(element);
|
|
612
|
+
if (!byName) events.set(element, byName = /* @__PURE__ */ new Map());
|
|
613
|
+
const symbolIds = "symbolIds" in input ? freeze([...input.symbolIds]) : void 0;
|
|
614
|
+
byName.set(eventName, freeze({
|
|
615
|
+
...input,
|
|
616
|
+
...symbolIds ? { symbolIds } : {},
|
|
617
|
+
containerId: id,
|
|
618
|
+
elementKey: keyFor(element),
|
|
619
|
+
eventName
|
|
620
|
+
}));
|
|
621
|
+
},
|
|
622
|
+
delegated(eventNames) {
|
|
623
|
+
if (lifecycle === "disposed") return;
|
|
624
|
+
for (const eventName of eventNames) delegatedEvents.add(eventName);
|
|
625
|
+
},
|
|
626
|
+
violation: pushViolation,
|
|
627
|
+
router: (source) => void routerSources.add(source),
|
|
628
|
+
boundaries(value) {
|
|
629
|
+
boundarySnapshots = freeze(value.map((entry) => freeze({ ...entry })));
|
|
630
|
+
},
|
|
631
|
+
disposed: () => lifecycle === "disposed"
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
function __marklessDebugBootstrapSource() {
|
|
635
|
+
return `((root,phase,active)=>{const controls=(${installDebugChannelLayer.toString()})(root,phase,active);return Object.freeze({record:(element,eventName,input)=>controls.record(element,eventName,input),delegated:(eventNames)=>controls.delegated(eventNames),router:(source)=>controls.router(source),activate:()=>controls.activate()})})`;
|
|
636
|
+
}
|
|
637
|
+
//#endregion
|
|
638
|
+
//#region ../serializer/src/protocol-event-names.ts
|
|
639
|
+
const PROTOCOL_VISIBLE_EVENT_NAME = "visible";
|
|
640
|
+
const PROTOCOL_IDLE_EVENT_NAME$1 = "idle";
|
|
641
|
+
//#endregion
|
|
642
|
+
//#region ../serializer/src/protocol-locator-paths.ts
|
|
643
|
+
/**
|
|
644
|
+
* The container attribute that lets resume find each located element by its
|
|
645
|
+
* position under its parent, so a node a third-party script adds or swaps
|
|
646
|
+
* elsewhere cannot shift it. Format: protocol-locator-paths-format.ts.
|
|
647
|
+
*/
|
|
648
|
+
const PROTOCOL_LOCATOR_PATHS_ATTRIBUTE = "data-markless-paths";
|
|
649
|
+
//#endregion
|
|
650
|
+
//#region ../serializer/src/protocol-event-host.ts
|
|
651
|
+
/**
|
|
652
|
+
* The attribute the server writes on each served element that hosts an event
|
|
653
|
+
* record. The inline boot reads it from the event target up, so it finds a
|
|
654
|
+
* press's handler and sync policy without parsing a payload or knowing the
|
|
655
|
+
* element's position. Grammar: entries joined by `;`, each
|
|
656
|
+
* `name[:ref][!policy]`, where `ref` is the record's index in its region's event
|
|
657
|
+
* list (or `-` for an event an external delegate owns) and `policy` is `p`, `s`,
|
|
658
|
+
* `ps` or an index into the container's sync-policy table.
|
|
659
|
+
*/
|
|
660
|
+
const PROTOCOL_EVENT_HOST_ATTRIBUTE = "m:on";
|
|
661
|
+
//#endregion
|
|
662
|
+
//#region ../serializer/src/protocol-page-markers.ts
|
|
663
|
+
const PROTOCOL_CONTAINER_START_COMMENT = "markless:page-start";
|
|
664
|
+
const PROTOCOL_CONTAINER_END_COMMENT = "markless:page-end";
|
|
665
|
+
//#endregion
|
|
666
|
+
//#region ../web/src/inline/defer.ts
|
|
667
|
+
const PROTOCOL_EVENT_HOST_SELECTOR = PROTOCOL_EVENT_HOST_ATTRIBUTE.replace(":", "\\:");
|
|
668
|
+
/**
|
|
669
|
+
* The one startup helper deferred triggers share. Serialized whole into a served
|
|
670
|
+
* page that has one; a client mount and the runtime call it directly. Hosts are
|
|
671
|
+
* the elements whose event host attribute (`hostSelector`, escaped for a CSS
|
|
672
|
+
* attribute selector) names the lane's event with a record;
|
|
673
|
+
* `ownsRoot` adds the container itself, which hands records the runtime owns
|
|
674
|
+
* (arms, rows) to the runtime.
|
|
675
|
+
*/
|
|
676
|
+
function createMarklessDefer(loadModule, pageStart, pageEnd, pathsAttribute, hostSelector) {
|
|
677
|
+
const scope = globalThis;
|
|
678
|
+
const clockOf = (root) => root.__mClock || {
|
|
679
|
+
frame: (run) => requestAnimationFrame(run),
|
|
680
|
+
idle: (run) => scope.scheduler?.postTask ? scope.scheduler.postTask(run, { priority: "background" }) : typeof requestIdleCallback === "function" ? requestIdleCallback(run, { timeout: 2e3 }) : setTimeout(run, 200)
|
|
681
|
+
};
|
|
682
|
+
const census = (root) => {
|
|
683
|
+
const live = [root];
|
|
684
|
+
const walker = document.createTreeWalker(root, 129);
|
|
685
|
+
for (let next = walker.nextNode(); next; next = walker.nextNode()) if (next.nodeType !== 8) live.push(next);
|
|
686
|
+
else if (next.data === pageStart) live.length = 1;
|
|
687
|
+
else if (next.data === pageEnd) break;
|
|
688
|
+
const paths = pathsAttribute && root.getAttribute?.(pathsAttribute);
|
|
689
|
+
const order = paths && paths.split("|")[3];
|
|
690
|
+
let signature = 0;
|
|
691
|
+
if (order) for (const element of live.slice(1)) {
|
|
692
|
+
const name = element.localName ?? element.tagName ?? "";
|
|
693
|
+
signature = signature * 31 + name.length * 32 + (name.charCodeAt(0) | 32) | 0;
|
|
694
|
+
}
|
|
695
|
+
if (paths && (parseInt(paths) !== live.length || order && order !== (signature >>> 0).toString(36))) root.__marklessShifted = 1;
|
|
696
|
+
return live;
|
|
697
|
+
};
|
|
698
|
+
const idle = (root, run) => {
|
|
699
|
+
const clock = clockOf(root);
|
|
700
|
+
const next = () => clock.idle(() => root.__marklessArmRegistering?.size ? next() : run());
|
|
701
|
+
const loaded = () => clock.frame(() => scope.__mArm?.idle ? scope.__mArm.idle(next) : next());
|
|
702
|
+
if (document.readyState === "complete") loaded();
|
|
703
|
+
else addEventListener("load", loaded, { once: true });
|
|
704
|
+
};
|
|
705
|
+
const trigger = (target, lane, ownsRoot, eventName) => {
|
|
706
|
+
const root = target;
|
|
707
|
+
const url = document.currentScript?.getAttribute("data-markless-resume-module");
|
|
708
|
+
if (!root || !url) return;
|
|
709
|
+
const fired = root.__mFired ||= /* @__PURE__ */ new WeakSet();
|
|
710
|
+
const claimed = /* @__PURE__ */ new WeakSet();
|
|
711
|
+
let pending = 0;
|
|
712
|
+
const claim = (host) => {
|
|
713
|
+
if (fired.has(host) || claimed.has(host)) return;
|
|
714
|
+
const input = {
|
|
715
|
+
root,
|
|
716
|
+
event: {
|
|
717
|
+
type: eventName,
|
|
718
|
+
target: host,
|
|
719
|
+
bubbles: false
|
|
720
|
+
},
|
|
721
|
+
element: host
|
|
722
|
+
};
|
|
723
|
+
const queue = root.__marklessDispatch;
|
|
724
|
+
if (!queue && root.__marklessDelegatedDispatch === true) return idle(root, () => claim(host));
|
|
725
|
+
claimed.add(host);
|
|
726
|
+
if (lane !== "visible") fired.add(host);
|
|
727
|
+
root.__marklessCensus ||= census(root);
|
|
728
|
+
root.__marklessDelegatedDispatch ||= eventName;
|
|
729
|
+
pending++;
|
|
730
|
+
(queue ? Promise.resolve(queue(input)) : (root.__mResume ||= loadModule(url)).then((module) => module.resumeContainerEvent(input))).then(() => {
|
|
731
|
+
if (root.__asyncResumeRuntimeStarted) return;
|
|
732
|
+
fired.add(host);
|
|
733
|
+
if (!--pending && root.__marklessDelegatedDispatch === eventName) root.__marklessDelegatedDispatch = void 0;
|
|
734
|
+
});
|
|
735
|
+
};
|
|
736
|
+
const hosts = ownsRoot ? [root] : [];
|
|
737
|
+
hosts.push(...root.querySelectorAll(`[${hostSelector}^="${eventName}:"],[${hostSelector}*=";${eventName}:"]`));
|
|
738
|
+
if (lane === "idle") return idle(root, () => hosts.forEach(claim));
|
|
739
|
+
const observer = new IntersectionObserver((entries) => {
|
|
740
|
+
for (const entry of entries) if (entry.isIntersecting) {
|
|
741
|
+
observer.unobserve(entry.target);
|
|
742
|
+
claim(entry.target);
|
|
743
|
+
}
|
|
744
|
+
});
|
|
745
|
+
for (const host of hosts) observer.observe(host);
|
|
746
|
+
};
|
|
747
|
+
return Object.assign(trigger, { idle });
|
|
748
|
+
}
|
|
749
|
+
const INLINE_DEFER_LOADER_SOURCE = "(url) => import(/* @vite-ignore */ url)";
|
|
750
|
+
/** An expression that installs the helper once per document and evaluates to it; a build passes the factory minified. */
|
|
751
|
+
function inlineDeferSource(factory = createMarklessDefer.toString()) {
|
|
752
|
+
return `(globalThis.__mDefer||=(${factory})(${INLINE_DEFER_LOADER_SOURCE},${JSON.stringify(PROTOCOL_CONTAINER_START_COMMENT)},${JSON.stringify(PROTOCOL_CONTAINER_END_COMMENT)},${JSON.stringify(PROTOCOL_LOCATOR_PATHS_ATTRIBUTE)},${JSON.stringify(PROTOCOL_EVENT_HOST_SELECTOR)}))`;
|
|
753
|
+
}
|
|
754
|
+
/** One lane's registration, appended only to a served page whose records name that lane's event. */
|
|
755
|
+
function createInlineDeferTriggerSource(lane, ownsRoot) {
|
|
756
|
+
const eventName = lane === "idle" ? PROTOCOL_IDLE_EVENT_NAME$1 : PROTOCOL_VISIBLE_EVENT_NAME;
|
|
757
|
+
return `;${inlineDeferSource()}(document.currentScript?.closest('[data-async-container]'),${JSON.stringify(lane)},${ownsRoot ? 1 : 0},${JSON.stringify(eventName)});`;
|
|
758
|
+
}
|
|
759
|
+
//#endregion
|
|
760
|
+
//#region src/inline-resumer.ts
|
|
761
|
+
let oxcToolsPromise;
|
|
762
|
+
const compiledSources = /* @__PURE__ */ new Map();
|
|
763
|
+
function loadOxcTools() {
|
|
764
|
+
oxcToolsPromise ??= import("rolldown/experimental").then(({ minifySync, transformSync }) => ({
|
|
765
|
+
minifySync,
|
|
766
|
+
transformSync
|
|
767
|
+
}));
|
|
768
|
+
return oxcToolsPromise;
|
|
769
|
+
}
|
|
770
|
+
function compileInlineResumerSources(options) {
|
|
771
|
+
const cacheKey = `${options.debug ? "debug" : "production"}:${options.executionLog}`;
|
|
772
|
+
let compiled = compiledSources.get(cacheKey);
|
|
773
|
+
if (!compiled) {
|
|
774
|
+
compiled = compileInlineResumerSourceVariants(options);
|
|
775
|
+
compiledSources.set(cacheKey, compiled);
|
|
776
|
+
}
|
|
777
|
+
return compiled;
|
|
778
|
+
}
|
|
779
|
+
async function compileInlineResumerSourceVariants(options) {
|
|
780
|
+
const shared = {
|
|
781
|
+
debug: options.debug,
|
|
782
|
+
executionLog: options.executionLog
|
|
783
|
+
};
|
|
784
|
+
const [event, syncPolicy, graphSyncPolicyOwner, graphSyncPolicyConsumer] = await Promise.all([
|
|
785
|
+
compileInlineResumerSource({
|
|
786
|
+
...shared,
|
|
787
|
+
graphSyncPolicy: false,
|
|
788
|
+
sharedGraphPolicy: false,
|
|
789
|
+
syncPolicy: false
|
|
790
|
+
}),
|
|
791
|
+
compileInlineResumerSource({
|
|
792
|
+
...shared,
|
|
793
|
+
graphSyncPolicy: false,
|
|
794
|
+
sharedGraphPolicy: false,
|
|
795
|
+
syncPolicy: true
|
|
796
|
+
}),
|
|
797
|
+
compileInlineResumerSource({
|
|
798
|
+
...shared,
|
|
799
|
+
graphSyncPolicy: true,
|
|
800
|
+
sharedGraphPolicy: true,
|
|
801
|
+
syncPolicy: true
|
|
802
|
+
}),
|
|
803
|
+
compileInlineResumerSource({
|
|
804
|
+
...shared,
|
|
805
|
+
graphSyncPolicy: true,
|
|
806
|
+
sharedGraphPolicy: false,
|
|
807
|
+
syncPolicy: true
|
|
808
|
+
})
|
|
809
|
+
]);
|
|
810
|
+
const defer = await compileDeferFactorySource();
|
|
811
|
+
return {
|
|
812
|
+
...shared,
|
|
813
|
+
event,
|
|
814
|
+
syncPolicy,
|
|
815
|
+
graphSyncPolicyOwner,
|
|
816
|
+
graphSyncPolicyConsumer,
|
|
817
|
+
defer
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
async function compileDeferFactorySource() {
|
|
821
|
+
const binding = "var __marklessDeferFactory=";
|
|
822
|
+
const { minifySync, transformSync } = await loadOxcTools();
|
|
823
|
+
const transformed = transformSync("markless-defer.js", `${binding}${createMarklessDefer.toString()};`, {
|
|
824
|
+
lang: "js",
|
|
825
|
+
sourceType: "script",
|
|
826
|
+
target: "es2020"
|
|
827
|
+
});
|
|
828
|
+
assertOxcResult("transform", transformed.errors);
|
|
829
|
+
const minified = minifySync("markless-defer.js", transformed.code, {
|
|
830
|
+
compress: true,
|
|
831
|
+
mangle: { toplevel: false },
|
|
832
|
+
module: false
|
|
833
|
+
});
|
|
834
|
+
assertOxcResult("minify", minified.errors);
|
|
835
|
+
const code = minified.code.trim().replace(/;$/, "");
|
|
836
|
+
if (!code.startsWith(binding)) throw new Error("MARKLESS_INLINE_DEFER_FACTORY_UNWRAPPABLE");
|
|
837
|
+
return code.slice(27);
|
|
838
|
+
}
|
|
839
|
+
async function compileInlineResumerSource(options) {
|
|
840
|
+
const source = createInlineResumerSource({
|
|
841
|
+
...options,
|
|
842
|
+
...options.debug ? {
|
|
843
|
+
debugBootstrapSource: __marklessDebugBootstrapSource(),
|
|
844
|
+
debugRegistrationSource: createInlineResumerDebugRegistrationSource()
|
|
845
|
+
} : {}
|
|
846
|
+
});
|
|
847
|
+
const { minifySync, transformSync } = await loadOxcTools();
|
|
848
|
+
const transformed = transformSync("markless-inline-resumer.js", source, {
|
|
849
|
+
lang: "js",
|
|
850
|
+
sourceType: "script",
|
|
851
|
+
target: "es2020"
|
|
852
|
+
});
|
|
853
|
+
assertOxcResult("transform", transformed.errors);
|
|
854
|
+
const minified = minifySync("markless-inline-resumer.js", transformed.code, {
|
|
855
|
+
compress: true,
|
|
856
|
+
mangle: { toplevel: true },
|
|
857
|
+
module: false
|
|
858
|
+
});
|
|
859
|
+
assertOxcResult("minify", minified.errors);
|
|
860
|
+
const code = minified.code.trim();
|
|
861
|
+
if (!code.includes(INLINE_RESUMER_PAGE_TOKEN)) throw new Error("MARKLESS_INLINE_RESUMER_PAGE_TOKEN_FOLDED");
|
|
862
|
+
return code;
|
|
863
|
+
}
|
|
864
|
+
function assertOxcResult(phase, errors) {
|
|
865
|
+
if (errors.length === 0) return;
|
|
866
|
+
throw new Error(`MARKLESS_INLINE_RESUMER_${phase.toUpperCase()}_FAILED:\n${errors.map((error) => error.message).join("\n")}`);
|
|
867
|
+
}
|
|
868
|
+
const compiledPrerenderSources = /* @__PURE__ */ new Map();
|
|
869
|
+
function compilePrerenderInlineResumerSources() {
|
|
870
|
+
let compiled = compiledPrerenderSources.get("production");
|
|
871
|
+
if (!compiled) {
|
|
872
|
+
compiled = compilePrerenderVariants();
|
|
873
|
+
compiledPrerenderSources.set("production", compiled);
|
|
874
|
+
}
|
|
875
|
+
return compiled;
|
|
876
|
+
}
|
|
877
|
+
async function compilePrerenderVariants() {
|
|
878
|
+
const [prerender, prerenderSelfWake, prerenderSettle] = await Promise.all([
|
|
879
|
+
compilePrerenderInlineResumerSource(false),
|
|
880
|
+
compilePrerenderInlineResumerSource(true),
|
|
881
|
+
compilePrerenderInlineResumerSource("settle")
|
|
882
|
+
]);
|
|
883
|
+
return {
|
|
884
|
+
prerender,
|
|
885
|
+
prerenderSelfWake,
|
|
886
|
+
prerenderSettle
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
async function compilePrerenderInlineResumerSource(selfWake) {
|
|
890
|
+
const source = parameterizedPrerenderInlineResumerSource(selfWake);
|
|
891
|
+
const { minifySync, transformSync } = await loadOxcTools();
|
|
892
|
+
const transformed = transformSync("markless-prerender-inline-resumer.js", source, {
|
|
893
|
+
lang: "js",
|
|
894
|
+
sourceType: "script",
|
|
895
|
+
target: "es2020"
|
|
896
|
+
});
|
|
897
|
+
assertOxcResult("transform", transformed.errors);
|
|
898
|
+
const minified = minifySync("markless-prerender-inline-resumer.js", transformed.code, {
|
|
899
|
+
compress: true,
|
|
900
|
+
mangle: { toplevel: true },
|
|
901
|
+
module: false
|
|
902
|
+
});
|
|
903
|
+
assertOxcResult("minify", minified.errors);
|
|
904
|
+
const code = minified.code.trim();
|
|
905
|
+
if (code.split(PRERENDER_INLINE_EVENT_NAMES_TOKEN).length !== 2) throw new Error("MARKLESS_PRERENDER_INLINE_RESUMER_EVENT_NAMES_TOKEN_LOST");
|
|
906
|
+
return code;
|
|
907
|
+
}
|
|
908
|
+
function parameterizedPrerenderInlineResumerSource(selfWake) {
|
|
909
|
+
const placeholder = [PRERENDER_INLINE_EVENT_NAMES_TOKEN];
|
|
910
|
+
const literal = JSON.stringify(placeholder);
|
|
911
|
+
const plain = selfWake === "settle" ? createPrerenderSettleInlineResumerSource(placeholder, void 0) : createPrerenderInlineResumerSource(placeholder, void 0);
|
|
912
|
+
if (plain.split(literal).length !== 2) throw new Error("MARKLESS_PRERENDER_INLINE_RESUMER_EVENT_NAMES_UNPLACEABLE");
|
|
913
|
+
return `${plain.replace(literal, PRERENDER_INLINE_EVENT_NAMES_TOKEN)}${selfWake === true ? createInlineResumerSelfWakeSource(void 0) : ""}`;
|
|
914
|
+
}
|
|
915
|
+
//#endregion
|
|
916
|
+
//#region src/shared-inline-sources.ts
|
|
917
|
+
const SHARED_INLINE_RESUMER_SOURCES = "inlineResumerSources";
|
|
918
|
+
const SHARED_PRERENDER_BOOT = "prerenderBoot";
|
|
919
|
+
const PREFIX = "virtual:markless:inline-sources-";
|
|
920
|
+
const EXECUTION_LOG_MODES = /* @__PURE__ */ new Set([
|
|
921
|
+
"auto",
|
|
922
|
+
"never",
|
|
923
|
+
"always"
|
|
924
|
+
]);
|
|
925
|
+
function sharedInlineSourcesModuleId(options) {
|
|
926
|
+
return `${PREFIX}${options.debug ? "debug" : "production"}-${options.executionLog}`;
|
|
927
|
+
}
|
|
928
|
+
function sharedInlineSourcesOptions(id) {
|
|
929
|
+
const bare = id.startsWith("\0") ? id.slice(1) : id;
|
|
930
|
+
if (!bare.startsWith(PREFIX)) return null;
|
|
931
|
+
const [flavour, executionLog] = bare.slice(32).split("-");
|
|
932
|
+
if (flavour !== "debug" && flavour !== "production" || !EXECUTION_LOG_MODES.has(executionLog)) return null;
|
|
933
|
+
return {
|
|
934
|
+
debug: flavour === "debug",
|
|
935
|
+
executionLog
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
function isSharedInlineSourcesModuleId(id) {
|
|
939
|
+
return sharedInlineSourcesOptions(id) !== null;
|
|
940
|
+
}
|
|
941
|
+
async function sharedInlineSourcesModuleSource(id) {
|
|
942
|
+
const options = sharedInlineSourcesOptions(id);
|
|
943
|
+
if (!options) return null;
|
|
944
|
+
const [sources, prerender] = await Promise.all([compileInlineResumerSources(options), compilePrerenderInlineResumerSources()]);
|
|
945
|
+
return [`export const ${SHARED_INLINE_RESUMER_SOURCES} = ${JSON.stringify(sources)};`, `export const ${SHARED_PRERENDER_BOOT} = ${JSON.stringify(prerender)};`].join("\n");
|
|
946
|
+
}
|
|
947
|
+
//#endregion
|
|
418
948
|
//#region src/scalar-plan-loader.ts
|
|
419
949
|
function emitScalarPlanLoader(actions, routes) {
|
|
420
950
|
const ordered = routes.filter((route) => route.prefix.length > 0).toSorted((left, right) => right.prefix.length - left.prefix.length);
|
|
@@ -625,8 +1155,9 @@ function emitSourceModule(input) {
|
|
|
625
1155
|
const emitsSsrBody = !!input.publicSsrModuleSource && !(input.environment === "client" && (symbolsOnly || !input.prerenderRecords && !input.dev));
|
|
626
1156
|
const csrRootName = input.environment !== "server" && !symbolsOnly && !input.prerenderRecords && input.publicRenderRootExportName ? csrRootLocalName(input.publicRenderRootExportName) : null;
|
|
627
1157
|
return [
|
|
628
|
-
!input.publicSsrModuleSource && !input.publicRenderModuleSource || symbolsOnly || !input.renderDataId || input.environment === "client" && !input.publicRenderModuleSource && !input.prerenderRecords && !input.dev && !canonicalRenderData ? "" : canonicalRenderData ? emitsSsrBody ? `import { marklessPrerenderData, marklessRenderData } from
|
|
629
|
-
symbolsOnly ? "" : `import { state as payloadState, view as payloadView, runtimeDemandMap as payloadRuntimeDemandMap } from
|
|
1158
|
+
!input.publicSsrModuleSource && !input.publicRenderModuleSource || symbolsOnly || !input.renderDataId || input.environment === "client" && !input.publicRenderModuleSource && !input.prerenderRecords && !input.dev && !canonicalRenderData ? "" : canonicalRenderData ? emitsSsrBody ? `import { marklessPrerenderData, marklessRenderData } from ${singleQuoted(input.renderDataId)};` : `import { marklessPrerenderData } from ${singleQuoted(input.renderDataId)};` : `import { marklessRenderData } from ${singleQuoted(input.renderDataId)};`,
|
|
1159
|
+
symbolsOnly ? "" : `import { state as payloadState, view as payloadView, runtimeDemandMap as payloadRuntimeDemandMap } from ${singleQuoted(input.payloadId)};`,
|
|
1160
|
+
sharedInlineSources(input) ? `import { ${SHARED_INLINE_RESUMER_SOURCES} as marklessInlineResumerSources, ${SHARED_PRERENDER_BOOT} as marklessPrerenderBoot } from ${singleQuoted(input.sharedInlineSourcesModuleId)};` : null,
|
|
630
1161
|
input.environment === "client" && input.directCsr === true && input.hasComputedState === true ? ["import { installMarklessDerivedReconcile } from '@markless/web/fns/reconcile-plane';", "installMarklessDerivedReconcile();"].join("\n") : null,
|
|
631
1162
|
input.environment === "client" && input.hasComputedState === true ? emitRosterResumeLoaderInstall() : null,
|
|
632
1163
|
input.environment === "client" && input.hasOverlayMarks === true ? emitOverlayLoaderInstall() : null,
|
|
@@ -645,7 +1176,7 @@ function emitSourceModule(input) {
|
|
|
645
1176
|
(symbolsOnly || input.publicRenderRootExportName === null) && !routeSymbols ? "export { loadSymbol };" : "",
|
|
646
1177
|
symbolsOnly ? "" : "export { payloadView };",
|
|
647
1178
|
symbolsOnly ? "" : "export { payloadRuntimeDemandMap };",
|
|
648
|
-
input.devResumeReexport && input.environment === "client" ? `export { resumeContainerEvent } from
|
|
1179
|
+
input.devResumeReexport && input.environment === "client" ? `export { resumeContainerEvent } from ${singleQuoted(resumeVirtualModuleId(input.filename))};` : "",
|
|
649
1180
|
"",
|
|
650
1181
|
input.environment === "server" || symbolsOnly || input.prerenderRecords ? "" : emitPublicRenderModule(input.publicRenderModuleSource, {
|
|
651
1182
|
executionLogEnabled: input.executionLog !== "never",
|
|
@@ -662,6 +1193,7 @@ function emitSourceModule(input) {
|
|
|
662
1193
|
storageSeeds: input.storageSeeds,
|
|
663
1194
|
inlineResumerSources: input.inlineResumerSources,
|
|
664
1195
|
prerenderBoot: input.prerenderBoot,
|
|
1196
|
+
sharedInlineSources: sharedInlineSources(input),
|
|
665
1197
|
resumeModuleUrl: input.resumeModuleUrl,
|
|
666
1198
|
prerenderWakeModuleUrl: input.prerenderWakeModuleUrl,
|
|
667
1199
|
rootExportName: input.publicRenderRootExportName,
|
|
@@ -843,9 +1375,9 @@ function emitResumeModule(input) {
|
|
|
843
1375
|
].filter((name) => resumeContainerEvent.includes(name));
|
|
844
1376
|
return [
|
|
845
1377
|
input.boundSymbolDescriptors ? `export const ${MARKLESS_BOUND_SYMBOLS_EXPORT} = ${emitBoundSymbolDescriptors(input.boundSymbolDescriptors)};` : null,
|
|
846
|
-
input.prerenderDataId && !stagedPrerender && resumeContainerEvent.includes("marklessPrerenderData") ? `import { marklessPrerenderData } from
|
|
847
|
-
stagedPrerender && input.prerenderDataId ? `async function marklessLoadPrerenderData() { const module = await import(
|
|
848
|
-
`import { runtimeDemandMap as payloadRuntimeDemandMap } from
|
|
1378
|
+
input.prerenderDataId && !stagedPrerender && resumeContainerEvent.includes("marklessPrerenderData") ? `import { marklessPrerenderData } from ${singleQuoted(input.prerenderDataId)};` : null,
|
|
1379
|
+
stagedPrerender && input.prerenderDataId ? `async function marklessLoadPrerenderData() { const module = await import(${singleQuoted(input.lazyRenderDataId ?? input.prerenderDataId)}); return module.marklessPrerenderData; }` : null,
|
|
1380
|
+
`import { runtimeDemandMap as payloadRuntimeDemandMap } from ${singleQuoted(input.payloadId)};`,
|
|
849
1381
|
payloadHasComputed(input.payloadState) ? [
|
|
850
1382
|
"import { installMarklessDerivedReconcile } from '@markless/web/fns/reconcile-plane';",
|
|
851
1383
|
"installMarklessDerivedReconcile();",
|
|
@@ -888,6 +1420,7 @@ function emitQueuedResumeContainerEvent(source, { censusRepair = true } = {}) {
|
|
|
888
1420
|
implementation,
|
|
889
1421
|
"export function resumeContainerEvent(input) {",
|
|
890
1422
|
" const root = input.root;",
|
|
1423
|
+
" if (input.eventIndex >= 0) input = { ...input, eventRecord: (root.__mE ||= JSON.parse(root.querySelector('script[type=\"markless/view\"]').textContent).events)[input.eventIndex] };",
|
|
891
1424
|
censusRepair ? " if (root.__marklessShifted) return import('@markless/web/fns/served-census-repair').then((census) => (census.marklessRepairCensus(root), resumeContainerEvent(input)));" : "",
|
|
892
1425
|
" if (!root.__marklessDispatch) {",
|
|
893
1426
|
" let handler = marklessResumeContainerEvent, tail = Promise.resolve(), done = tail, lastEvent = null, lastEventTime = undefined, seen = new WeakMap();",
|
|
@@ -968,6 +1501,14 @@ function symbolRouteImportSource$1(importSource, includeScalarActionPlans = fals
|
|
|
968
1501
|
if (includeScalarActionPlans) return scalarPlanSourceReference(importSource);
|
|
969
1502
|
return importSource.includes("?") ? `${importSource}&markless-symbols` : `${importSource}?markless-symbols`;
|
|
970
1503
|
}
|
|
1504
|
+
function sharedInlineSources(input) {
|
|
1505
|
+
return input.environment === "server" && !!input.sharedInlineSourcesModuleId && !!input.inlineResumerSources && !!input.prerenderBoot;
|
|
1506
|
+
}
|
|
1507
|
+
function sharedPrerenderBootSource(boot) {
|
|
1508
|
+
if (!boot.settle) return "marklessPrerenderBoot";
|
|
1509
|
+
const { boot: _boot, ...settle } = boot.settle;
|
|
1510
|
+
return `{ ...marklessPrerenderBoot, settle: { ...${JSON.stringify(settle)}, boot: marklessPrerenderBoot.prerenderSettle } }`;
|
|
1511
|
+
}
|
|
971
1512
|
function emitCompiledAppDefault(input) {
|
|
972
1513
|
const renderCsrEntry = input.csrRootName ? [` renderCsr: ${input.csrRootName},`] : [];
|
|
973
1514
|
const symbolLoaderEntry = input.environment !== "server" && input.rootExportName === null ? [`\tloadSymbol: ${input.symbolLoaderName},`] : input.prerenderRecords === true ? [`\tloadSymbol: ${input.symbolLoaderName},`] : [];
|
|
@@ -981,8 +1522,8 @@ function emitCompiledAppDefault(input) {
|
|
|
981
1522
|
const renderSsrComponentsEntry = servesSsr && input.ssrComponents.length > 0 ? [` renderSsrComponents: { ${input.ssrComponents.map((component) => `${JSON.stringify(component.exportName)}: { renderSsr: ${component.ssrFunctionName} }`).join(", ")} },`] : [];
|
|
982
1523
|
const resumeModuleEntry = input.resumeModuleUrl && input.environment !== "client" ? [` resumeModuleUrl: ${JSON.stringify(input.resumeModuleUrl)},`] : [];
|
|
983
1524
|
const prerenderWakeModuleEntry = input.prerenderWakeModuleUrl && input.environment !== "client" ? [`\tprerenderWakeModuleUrl: ${JSON.stringify(input.prerenderWakeModuleUrl)},`] : [];
|
|
984
|
-
const inlineResumerEntry = input.inlineResumerSources && input.environment !== "client" ? [`\tinlineResumerSources: ${JSON.stringify(input.inlineResumerSources)},`] : [];
|
|
985
|
-
const prerenderBootEntry = input.prerenderBoot && input.environment !== "client" ? [`\tprerenderBoot: ${JSON.stringify(input.prerenderBoot)},`] : [];
|
|
1525
|
+
const inlineResumerEntry = input.inlineResumerSources && input.environment !== "client" ? [input.sharedInlineSources ? " inlineResumerSources: marklessInlineResumerSources," : `\tinlineResumerSources: ${JSON.stringify(input.inlineResumerSources)},`] : [];
|
|
1526
|
+
const prerenderBootEntry = input.prerenderBoot && input.environment !== "client" ? [input.sharedInlineSources ? `\tprerenderBoot: ${sharedPrerenderBootSource(input.prerenderBoot)},` : `\tprerenderBoot: ${JSON.stringify(input.prerenderBoot)},`] : [];
|
|
986
1527
|
const headInjectionEntry = input.headInjections?.length && input.environment !== "client" ? [` headInjections: ${JSON.stringify(input.headInjections)},`] : [];
|
|
987
1528
|
const storageSeedEntry = input.storageSeeds?.length && input.environment !== "client" ? [`\tstorageSeeds: ${JSON.stringify(input.storageSeeds)},`] : [];
|
|
988
1529
|
const modulePreloadEntry = input.resumeModuleUrl && input.environment === "server" ? [` modulePreloads: [{ href: ${JSON.stringify(input.resumeModuleUrl)}, fetchPriority: "high" }],`] : [];
|
|
@@ -1122,12 +1663,12 @@ function emitResumeContainerEvent(loadSymbolName, needsFullResume, storageFreePa
|
|
|
1122
1663
|
"async function marklessFullResumeHandoff(handoff) {",
|
|
1123
1664
|
" handoff.root.__asyncResumeRuntimeStarted = true;",
|
|
1124
1665
|
...armsOpen(" "),
|
|
1125
|
-
` const { resumeFromPayloadDocument } = await import(
|
|
1666
|
+
` const { resumeFromPayloadDocument } = await import(${singleQuoted(resumeEntry)});`,
|
|
1126
1667
|
" const { runtime } = await resumeFromPayloadDocument({",
|
|
1127
1668
|
" document: handoff.document,",
|
|
1128
1669
|
" root: handoff.root,",
|
|
1129
1670
|
` loadSymbol: ${wakeLoadSymbol},`,
|
|
1130
|
-
...renderDataEntry(" ", `import(
|
|
1671
|
+
...renderDataEntry(" ", `import(${singleQuoted(componentRowRenderDataId)}).then((data) => data.marklessPrerenderData)`),
|
|
1131
1672
|
" });",
|
|
1132
1673
|
...armsStarted(" "),
|
|
1133
1674
|
" await runtime.dispatch(handoff.event, { syncPolicyAlreadyApplied: handoff.syncPolicyAlreadyApplied === true, ignoreUnmatched: true });",
|
|
@@ -1335,7 +1876,10 @@ function emitSpecializedScalarDispatcher(actions, loadSymbolName, fallback, reso
|
|
|
1335
1876
|
"function marklessScalarEventMatches(input, host, tagName, eventName, hostNodeId) {",
|
|
1336
1877
|
" const eventTypeMatches = input.event?.type === eventName;",
|
|
1337
1878
|
" if (!eventTypeMatches) return false;",
|
|
1338
|
-
" if (!host || (tagName !== \"*\" && host.tagName.toLowerCase() !== tagName))
|
|
1879
|
+
" if (!host || (tagName !== \"*\" && host.tagName.toLowerCase() !== tagName)) {",
|
|
1880
|
+
" if (typeof __MARKLESS_DEV_ENABLED__ === \"undefined\" || __MARKLESS_DEV_ENABLED__) void import(\"@markless/web/fns/locator-miss\").then((m) => m.marklessReportLocatorMiss(input.root, { hostNodeId, tagName }, host));",
|
|
1881
|
+
" return false;",
|
|
1882
|
+
" }",
|
|
1339
1883
|
" const eventTarget = input.event?.target;",
|
|
1340
1884
|
" return host === eventTarget || (!!eventTarget?.nodeType && typeof host.contains === \"function\" && host.contains(eventTarget));",
|
|
1341
1885
|
"}",
|
|
@@ -1488,10 +2032,10 @@ function emitLoadSymbol(input, sourceReaderName) {
|
|
|
1488
2032
|
if (input.symbols.length > 0 && input.symbols.length <= 8) {
|
|
1489
2033
|
const direct = emitDirectSourceSymbolLoader(input.symbols, sourceReaderName);
|
|
1490
2034
|
if (!input.hasBoundSymbols) return direct;
|
|
1491
|
-
return [`const marklessSymbolResolverModule = () => import(
|
|
2035
|
+
return [`const marklessSymbolResolverModule = () => import(${singleQuoted(input.resolverId)});`, direct.replace(" return Promise.reject(new Error(`Unknown async symbol ${symbolId}`));", " return marklessSymbolResolverModule().then((mod) => mod.loadSymbol(symbolId));")].join("\n");
|
|
1492
2036
|
}
|
|
1493
2037
|
return [
|
|
1494
|
-
`const marklessSymbolResolverModule = () => import(
|
|
2038
|
+
`const marklessSymbolResolverModule = () => import(${singleQuoted(input.resolverId)});`,
|
|
1495
2039
|
"function loadSymbol(symbolId) {",
|
|
1496
2040
|
" return marklessSymbolResolverModule().then((mod) => mod.loadSymbol(symbolId));",
|
|
1497
2041
|
"}"
|
|
@@ -1500,7 +2044,7 @@ function emitLoadSymbol(input, sourceReaderName) {
|
|
|
1500
2044
|
function emitDirectSourceSymbolLoader(symbols, readerName = "readMarklessSourceSymbol") {
|
|
1501
2045
|
return [
|
|
1502
2046
|
"function loadSymbol(symbolId) {",
|
|
1503
|
-
...symbols.flatMap((symbol) => [` if (symbolId === ${JSON.stringify(symbol.id)}) return import(
|
|
2047
|
+
...symbols.flatMap((symbol) => [` if (symbolId === ${JSON.stringify(symbol.id)}) return import(${singleQuoted(symbol.lazyChunk ?? symbol.chunk)})`, ` .then((mod) => ${readerName}(mod, ${JSON.stringify(symbol.exportName)}));`]),
|
|
1504
2048
|
" return Promise.reject(new Error(`Unknown async symbol ${symbolId}`));",
|
|
1505
2049
|
"}",
|
|
1506
2050
|
emitSourceSymbolExportReader(readerName)
|
|
@@ -1522,12 +2066,16 @@ function stringHash(value) {
|
|
|
1522
2066
|
}
|
|
1523
2067
|
return (hash >>> 0).toString(36);
|
|
1524
2068
|
}
|
|
2069
|
+
function singleQuoted(value) {
|
|
2070
|
+
return `'${String(value).replace(/[\\']/g, "\\$&").replace(/\n/g, "\\n").replace(/\r/g, "\\r")}'`;
|
|
2071
|
+
}
|
|
1525
2072
|
const MARKLESS_BUILD_PREFIX = `build/`;
|
|
1526
2073
|
const MARKLESS_BUNDLE_GRAPH = `${MARKLESS_BUILD_PREFIX}bundle-graph.json`;
|
|
1527
2074
|
const MARKLESS_EXECUTION_SIZES = `${MARKLESS_BUILD_PREFIX}execution-sizes.json`;
|
|
1528
2075
|
const MARKLESS_EXECUTION_DEMAND = `${MARKLESS_BUILD_PREFIX}execution-demand.json`;
|
|
1529
2076
|
const MARKLESS_INTERACTION_CLOSURES = `${MARKLESS_BUILD_PREFIX}interaction-closures.json`;
|
|
1530
2077
|
const MARKLESS_BYTE_ATTRIBUTION = `${MARKLESS_BUILD_PREFIX}byte-attribution.json`;
|
|
2078
|
+
const MARKLESS_SERVER_CHUNK_MAX_BYTES = 4194304;
|
|
1531
2079
|
const MARKLESS_BUILD_METADATA_FILES = [
|
|
1532
2080
|
MARKLESS_BUNDLE_GRAPH,
|
|
1533
2081
|
MARKLESS_EXECUTION_SIZES,
|
|
@@ -1681,6 +2229,13 @@ const MARKLESS_RUNTIME_GROUPS = [...WEB_RUNTIME_CAPABILITY_GROUPS, {
|
|
|
1681
2229
|
name: "markless-runtime",
|
|
1682
2230
|
test: /[/\\]@markless[/\\]runtime[/\\]/
|
|
1683
2231
|
}];
|
|
2232
|
+
const MARKLESS_SERVER_COMPILED_GROUP = {
|
|
2233
|
+
name: "markless-server",
|
|
2234
|
+
minShareCount: 2,
|
|
2235
|
+
test: /\.tsrx(?:[?#]|$)|^\0?virtual:markless:/,
|
|
2236
|
+
entriesAware: true,
|
|
2237
|
+
maxSize: MARKLESS_SERVER_CHUNK_MAX_BYTES
|
|
2238
|
+
};
|
|
1684
2239
|
function outputDefaults(output, environment) {
|
|
1685
2240
|
if (environment === "lib") return output;
|
|
1686
2241
|
const next = {
|
|
@@ -1690,7 +2245,11 @@ function outputDefaults(output, environment) {
|
|
|
1690
2245
|
if (environment === "server") {
|
|
1691
2246
|
next.entryFileNames ??= "[name].js";
|
|
1692
2247
|
next.chunkFileNames ??= "chunk-[hash].js";
|
|
1693
|
-
|
|
2248
|
+
const splitting = marklessCodeSplitting(next.codeSplitting);
|
|
2249
|
+
next.codeSplitting = {
|
|
2250
|
+
...splitting,
|
|
2251
|
+
groups: [...splitting.groups, MARKLESS_SERVER_COMPILED_GROUP]
|
|
2252
|
+
};
|
|
1694
2253
|
return next;
|
|
1695
2254
|
}
|
|
1696
2255
|
next.entryFileNames ??= `${MARKLESS_BUILD_PREFIX}chunk-[hash].js`;
|
|
@@ -2211,7 +2770,7 @@ const PRERENDER_WAKE_VIRTUAL_ID_RE = /^virtual:markless:prerender-wake:([^:]+)$/
|
|
|
2211
2770
|
const SETTLE_VIRTUAL_ID_RE = /^virtual:markless:settle:([^:]+)$/;
|
|
2212
2771
|
const SYMBOL_VIRTUAL_STRING_RE = /(["'`])((?:virtual:markless:symbol:)[^"'`]+)\1/g;
|
|
2213
2772
|
function stripBuildPrefix(fileName) {
|
|
2214
|
-
return fileName.startsWith(
|
|
2773
|
+
return fileName.startsWith("build/") ? fileName.slice(MARKLESS_BUILD_PREFIX.length) : fileName;
|
|
2215
2774
|
}
|
|
2216
2775
|
function virtualModuleSourceForLoad(module, options) {
|
|
2217
2776
|
if (!options.dev || module.type !== "resolver") return module.source;
|
|
@@ -2320,6 +2879,10 @@ function sourceForSettleVirtualImporter(importer) {
|
|
|
2320
2879
|
function isRelativeImport(source) {
|
|
2321
2880
|
return source.startsWith("./") || source.startsWith("../");
|
|
2322
2881
|
}
|
|
2882
|
+
function isCompilerStatefulModuleId(id) {
|
|
2883
|
+
const bare = id.startsWith("\0") ? id.slice(1) : id;
|
|
2884
|
+
return TSRX_SOURCE_FILE.test(bare) || bare.startsWith("virtual:markless:") || /[?&]markless-[a-z-]+(?:[=&#]|$)/.test(bare);
|
|
2885
|
+
}
|
|
2323
2886
|
function isMarklessRuntimeModule(id) {
|
|
2324
2887
|
const path = pathname(id);
|
|
2325
2888
|
return /[/\\](?:web|runtime|serializer)[/\\]src[/\\].+\.ts$/.test(path);
|
|
@@ -2666,11 +3229,13 @@ function splitStartupPacksByStaticReach(groups, roots, sources, owners, input) {
|
|
|
2666
3229
|
};
|
|
2667
3230
|
};
|
|
2668
3231
|
const staticReach = /* @__PURE__ */ new Set();
|
|
3232
|
+
const ownHandlers = /* @__PURE__ */ new Map();
|
|
3233
|
+
for (const [id, routes] of owners) if (routes.size === 1 && seed(id) && handler(id)) push(ownHandlers, [...routes][0], id);
|
|
2669
3234
|
for (const [route, ids] of input.routes) {
|
|
2670
3235
|
const visited = /* @__PURE__ */ new Set();
|
|
2671
3236
|
const first = closure(route, ids.filter((id) => seed(id) && !handler(id)), visited);
|
|
2672
3237
|
for (const id of first.reached) visited.add(id);
|
|
2673
|
-
const candidates = [...first.handlers, ...
|
|
3238
|
+
const candidates = [...first.handlers, ...ownHandlers.get(route) ?? []];
|
|
2674
3239
|
while (candidates.length) {
|
|
2675
3240
|
const id = candidates.pop();
|
|
2676
3241
|
if (visited.has(id)) continue;
|
|
@@ -2741,4 +3306,4 @@ function push(map, key, value) {
|
|
|
2741
3306
|
else map.set(key, [value]);
|
|
2742
3307
|
}
|
|
2743
3308
|
//#endregion
|
|
2744
|
-
export {
|
|
3309
|
+
export { MARKLESS_BUILD_PREFIX as $, isScalarPlanSourceRequest as A, compileInlineResumerSources as At, sourceForPrerenderWakeVirtualImporter as B, hasExecutionLogModuleHook as Bt, isCompilerStatefulModuleId as C, symbolEntryVirtualModuleId as Ct, isRenderDataSourceRequest as D, isSharedInlineSourcesModuleId as Dt, isRelativeImport as E, withoutFirstUse as Et, renderDataReachedFromQuery as F, EXECUTION_LOG_DISPATCH_MODULE_IDS as Ft, stripBuildPrefix as G, planModulePreloadUrls as Gt, sourceForSettleVirtualImporter as H, isExecutionLogChunk as Ht, resolveVirtualId as I, MARKLESS_EXECUTION_LOG_GLOBAL as It, emitPrerenderTriggerGroupModule as J, virtualModuleSourceForLoad as K, planModulePreloads as Kt, resolverVirtualModuleSourceFile as L, MARKLESS_EXECUTION_LOG_MODULE_ID as Lt, materializedReachedRenderDataSource as M, INLINE_DEFER_LOADER_SOURCE as Mt, normalizeVirtualId as N, createInlineDeferTriggerSource as Nt, isResumeSourceRequest as O, sharedInlineSourcesModuleId as Ot, pathname as P, inlineDeferSource as Pt, MARKLESS_BUILD_METADATA_FILES as Q, serverSharedSourceRequest as R, executionLogActivationInjection as Rt, isClientPrimarySourceRequest as S, settleVirtualModuleId as St, isPrerenderWakeSourceRequest as T, symbolVirtualModuleSourceFile as Tt, sourceForSymbolVirtualImporter as U, normalizeExecutionLogMode as Ut, sourceForResumeVirtualImporter as V, injectExecutionLogModuleHook as Vt, sourceForTriggerGroupVirtualImporter as W, requalifyExecutionLogModuleHook as Wt, triggerGroupVirtualModuleId as X, planPrerenderTriggerGroups as Y, adaptImportedCaptureResolver as Z, clientSymbolEntries as _, prerenderWakeVirtualModuleId as _t, isStartupPack as a, MARKLESS_PUBLIC_BUILD_METADATA_FILES as at, emittedBundleModuleIds as b, rewriteSymbolModuleExport as bt, planRoutePackGroups as c, RESUME_ENTRY_SPECIFIER as ct, warmPacksSuffix as d, emitOverlayLoaderInstall as dt, MARKLESS_BUNDLE_GRAPH as et, MARKLESS_INTERACTION_CLOSURES_ASSET as f, emitResumeModule as ft, clientRouteArtifactReference as g, payloadModule as gt, TSRX_SOURCE_FILE as h, encodedSymbolSource as ht, isMarklessNavigationPack as i, MARKLESS_INTERACTION_CLOSURES as it, isSymbolOnlySourceRequest as j, compilePrerenderInlineResumerSources as jt, isRouteNavigationSourceRequest as k, sharedInlineSourcesModuleSource as kt, startupPackOfLazy as l, STORAGE_FREE_RESUME_ENTRY_SPECIFIER as lt, MARKLESS_ROUTE_SOURCE_QUERY_RE as m, emitSourceModule as mt, MARKLESS_NAVIGATION_PACK_PREFIX as n, MARKLESS_EXECUTION_DEMAND as nt, lazyStartupPackName as o, outputDefaults as ot, plannedLandingFiles as p, emitSettleModule as pt, emitPrerenderBoundaryRendererModule as q, isMarklessDeferredPack as r, MARKLESS_EXECUTION_SIZES as rt, marklessDeferredChunkFileNames as s, MARKLESS_VIRTUAL_PREFIX as st, MARKLESS_DEFERRED_PACK as t, MARKLESS_BYTE_ATTRIBUTION as tt, warmEvaluatedImports as u, demandsOverlay as ut, devBrowserSourceModuleUrl as v, prerenderWakeVirtualModuleSourceFile as vt, isMarklessRuntimeModule as w, symbolVirtualModuleId as wt, executionLogRuntimeModuleId as x, scopedSymbolExportName as xt, devBrowserVirtualModuleUrl as y, resumeVirtualModuleId as yt, sharedReachedRenderDataRequest as z, executionLogVirtualModuleSource as zt };
|