@fictjs/runtime 0.2.3 → 0.3.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/advanced.cjs +10 -8
- package/dist/advanced.cjs.map +1 -1
- package/dist/advanced.d.cts +8 -16
- package/dist/advanced.d.ts +8 -16
- package/dist/advanced.js +5 -3
- package/dist/advanced.js.map +1 -1
- package/dist/{chunk-2U6M3LKS.cjs → chunk-ID3WBWNO.cjs} +452 -219
- package/dist/chunk-ID3WBWNO.cjs.map +1 -0
- package/dist/{chunk-5YTFFAVU.cjs → chunk-L4DIV3RC.cjs} +7 -7
- package/dist/{chunk-5YTFFAVU.cjs.map → chunk-L4DIV3RC.cjs.map} +1 -1
- package/dist/{chunk-W525IQWC.cjs → chunk-M2TSXZ4C.cjs} +16 -16
- package/dist/{chunk-W525IQWC.cjs.map → chunk-M2TSXZ4C.cjs.map} +1 -1
- package/dist/{chunk-YVDWXY44.js → chunk-SO6X7G5S.js} +450 -217
- package/dist/chunk-SO6X7G5S.js.map +1 -0
- package/dist/{chunk-UHXUEGQH.js → chunk-TWELIZRY.js} +2 -2
- package/dist/{chunk-3WD7QD5G.js → chunk-XLIZJMMJ.js} +2 -2
- package/dist/{context-9gFXOdJl.d.cts → context-B25xyQrJ.d.cts} +36 -2
- package/dist/{context-4woHo7-L.d.ts → context-CGdP7_Jb.d.ts} +36 -2
- package/dist/{effect-ClARNUCc.d.cts → effect-D6kaLM2-.d.cts} +80 -1
- package/dist/{effect-ClARNUCc.d.ts → effect-D6kaLM2-.d.ts} +80 -1
- package/dist/index.cjs +40 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.dev.js +322 -145
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +39 -35
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +8 -6
- package/dist/internal.d.ts +8 -6
- package/dist/internal.js +7 -3
- package/dist/internal.js.map +1 -1
- package/dist/{props-DAyeRPwH.d.ts → props-BEgIVMRx.d.ts} +8 -15
- package/dist/{props-CBwuh35e.d.cts → props-BIfromL0.d.cts} +8 -15
- package/dist/scope-Cx_3CjIZ.d.cts +18 -0
- package/dist/scope-CzNkn587.d.ts +18 -0
- package/package.json +1 -1
- package/src/advanced.ts +1 -0
- package/src/binding.ts +30 -4
- package/src/constants.ts +5 -0
- package/src/cycle-guard.ts +59 -7
- package/src/devtools.ts +22 -2
- package/src/dom.ts +84 -10
- package/src/hooks.ts +60 -13
- package/src/index.ts +3 -1
- package/src/internal.ts +2 -2
- package/src/lifecycle.ts +13 -5
- package/src/memo.ts +3 -4
- package/src/props.ts +16 -0
- package/src/signal.ts +204 -36
- package/dist/chunk-2U6M3LKS.cjs.map +0 -1
- package/dist/chunk-YVDWXY44.js.map +0 -1
- package/dist/scope-DvgMquEy.d.ts +0 -55
- package/dist/scope-xmdo6lVU.d.cts +0 -55
- /package/dist/{chunk-UHXUEGQH.js.map → chunk-TWELIZRY.js.map} +0 -0
- /package/dist/{chunk-3WD7QD5G.js.map → chunk-XLIZJMMJ.js.map} +0 -0
|
@@ -25,7 +25,7 @@ var DelegatedEventNames = [
|
|
|
25
25
|
];
|
|
26
26
|
|
|
27
27
|
// src/constants.ts
|
|
28
|
-
var isDev =
|
|
28
|
+
var isDev = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process === "undefined" || _optionalChain([process, 'access', _2 => _2.env, 'optionalAccess', _3 => _3.NODE_ENV]) !== "production";
|
|
29
29
|
var booleans = isDev ? [
|
|
30
30
|
"allowfullscreen",
|
|
31
31
|
"async",
|
|
@@ -387,7 +387,7 @@ function getDevtoolsHook() {
|
|
|
387
387
|
}
|
|
388
388
|
|
|
389
389
|
// src/cycle-guard.ts
|
|
390
|
-
var isDev2 =
|
|
390
|
+
var isDev2 = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process === "undefined" || _optionalChain([process, 'access', _4 => _4.env, 'optionalAccess', _5 => _5.NODE_ENV]) !== "production";
|
|
391
391
|
var setCycleProtectionOptions = () => {
|
|
392
392
|
};
|
|
393
393
|
var resetCycleProtectionStateForTests = () => {
|
|
@@ -401,14 +401,17 @@ var enterRootGuard = () => true;
|
|
|
401
401
|
var exitRootGuard = () => {
|
|
402
402
|
};
|
|
403
403
|
var defaultOptions = {
|
|
404
|
-
enabled:
|
|
404
|
+
enabled: true,
|
|
405
405
|
maxFlushCyclesPerMicrotask: 1e4,
|
|
406
406
|
maxEffectRunsPerFlush: 2e4,
|
|
407
407
|
windowSize: 5,
|
|
408
408
|
highUsageRatio: 0.8,
|
|
409
409
|
maxRootReentrantDepth: 10,
|
|
410
410
|
enableWindowWarning: true,
|
|
411
|
-
devMode:
|
|
411
|
+
devMode: isDev2,
|
|
412
|
+
// Backoff warning options
|
|
413
|
+
enableBackoffWarning: isDev2,
|
|
414
|
+
backoffWarningRatio: 0.5
|
|
412
415
|
};
|
|
413
416
|
var enabled = defaultOptions.enabled;
|
|
414
417
|
var options = {
|
|
@@ -420,6 +423,8 @@ var rootDepth = /* @__PURE__ */ new WeakMap();
|
|
|
420
423
|
var flushWarned = false;
|
|
421
424
|
var rootWarned = false;
|
|
422
425
|
var windowWarned = false;
|
|
426
|
+
var backoffWarned50 = false;
|
|
427
|
+
var backoffWarned75 = false;
|
|
423
428
|
setCycleProtectionOptions = exports.setCycleProtectionOptions = (opts) => {
|
|
424
429
|
if (typeof opts.enabled === "boolean") {
|
|
425
430
|
enabled = opts.enabled;
|
|
@@ -435,24 +440,55 @@ resetCycleProtectionStateForTests = () => {
|
|
|
435
440
|
flushWarned = false;
|
|
436
441
|
rootWarned = false;
|
|
437
442
|
windowWarned = false;
|
|
443
|
+
backoffWarned50 = false;
|
|
444
|
+
backoffWarned75 = false;
|
|
438
445
|
};
|
|
439
446
|
beginFlushGuard = () => {
|
|
440
447
|
if (!enabled) return;
|
|
441
448
|
effectRunsThisFlush = 0;
|
|
442
449
|
flushWarned = false;
|
|
443
450
|
windowWarned = false;
|
|
451
|
+
backoffWarned50 = false;
|
|
452
|
+
backoffWarned75 = false;
|
|
444
453
|
};
|
|
445
454
|
beforeEffectRunGuard = () => {
|
|
446
455
|
if (!enabled) return true;
|
|
447
456
|
const next = ++effectRunsThisFlush;
|
|
448
|
-
|
|
457
|
+
const limit = Math.min(options.maxFlushCyclesPerMicrotask, options.maxEffectRunsPerFlush);
|
|
458
|
+
if (options.enableBackoffWarning && isDev2) {
|
|
459
|
+
const ratio = next / limit;
|
|
460
|
+
const backoffRatio = _nullishCoalesce(options.backoffWarningRatio, () => ( 0.5));
|
|
461
|
+
if (!backoffWarned50 && ratio >= backoffRatio && ratio < backoffRatio + 0.25) {
|
|
462
|
+
backoffWarned50 = true;
|
|
463
|
+
console.warn(
|
|
464
|
+
`[fict] cycle guard: approaching effect limit (${Math.round(ratio * 100)}% of budget used)
|
|
465
|
+
- Current: ${next} effects, Limit: ${limit}
|
|
466
|
+
- Tip: Check for effects that trigger other effects in a loop.
|
|
467
|
+
- Common causes: signal updates inside effects that read and write the same signal.`
|
|
468
|
+
);
|
|
469
|
+
} else if (!backoffWarned75 && ratio >= backoffRatio + 0.25 && ratio < 1) {
|
|
470
|
+
backoffWarned75 = true;
|
|
471
|
+
console.warn(
|
|
472
|
+
`[fict] cycle guard: nearing effect limit (${Math.round(ratio * 100)}% of budget used)
|
|
473
|
+
- Current: ${next} effects, Limit: ${limit}
|
|
474
|
+
- Warning: Consider breaking the reactive dependency cycle.
|
|
475
|
+
- Debug: Use browser devtools to identify the recursive effect chain.`
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (next > limit) {
|
|
449
480
|
const message = `[fict] cycle protection triggered: flush-budget-exceeded`;
|
|
450
481
|
if (options.devMode) {
|
|
451
|
-
throw new Error(
|
|
482
|
+
throw new Error(
|
|
483
|
+
message + `
|
|
484
|
+
- Effect runs: ${next}, Limit: ${limit}
|
|
485
|
+
- This indicates a reactive cycle where effects keep triggering each other.
|
|
486
|
+
- Check for patterns like: createEffect(() => { signal(); signal(newValue); })`
|
|
487
|
+
);
|
|
452
488
|
}
|
|
453
489
|
if (!flushWarned) {
|
|
454
490
|
flushWarned = true;
|
|
455
|
-
console.warn(message, { effectRuns: next });
|
|
491
|
+
console.warn(message, { effectRuns: next, limit });
|
|
456
492
|
}
|
|
457
493
|
return false;
|
|
458
494
|
}
|
|
@@ -469,11 +505,16 @@ enterRootGuard = (root) => {
|
|
|
469
505
|
if (depth > options.maxRootReentrantDepth) {
|
|
470
506
|
const message = `[fict] cycle protection triggered: root-reentry`;
|
|
471
507
|
if (options.devMode) {
|
|
472
|
-
throw new Error(
|
|
508
|
+
throw new Error(
|
|
509
|
+
message + `
|
|
510
|
+
- Re-entry depth: ${depth}, Max allowed: ${options.maxRootReentrantDepth}
|
|
511
|
+
- This indicates recursive render() or component initialization.
|
|
512
|
+
- Check for components that trigger re-renders during their own render phase.`
|
|
513
|
+
);
|
|
473
514
|
}
|
|
474
515
|
if (!rootWarned) {
|
|
475
516
|
rootWarned = true;
|
|
476
|
-
console.warn(message, { depth });
|
|
517
|
+
console.warn(message, { depth, maxAllowed: options.maxRootReentrantDepth });
|
|
477
518
|
}
|
|
478
519
|
return false;
|
|
479
520
|
}
|
|
@@ -513,7 +554,7 @@ var reportCycle = (reason, detail = void 0) => {
|
|
|
513
554
|
};
|
|
514
555
|
|
|
515
556
|
// src/lifecycle.ts
|
|
516
|
-
var isDev3 =
|
|
557
|
+
var isDev3 = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process === "undefined" || _optionalChain([process, 'access', _8 => _8.env, 'optionalAccess', _9 => _9.NODE_ENV]) !== "production";
|
|
517
558
|
var currentRoot;
|
|
518
559
|
var currentEffectCleanups;
|
|
519
560
|
var globalErrorHandlers = /* @__PURE__ */ new WeakMap();
|
|
@@ -559,13 +600,19 @@ function onCleanup(fn) {
|
|
|
559
600
|
function flushOnMount(root) {
|
|
560
601
|
const cbs = root.onMountCallbacks;
|
|
561
602
|
if (!cbs || cbs.length === 0) return;
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
603
|
+
const prevRoot = currentRoot;
|
|
604
|
+
currentRoot = root;
|
|
605
|
+
try {
|
|
606
|
+
for (let i = 0; i < cbs.length; i++) {
|
|
607
|
+
const cleanup = cbs[i]();
|
|
608
|
+
if (typeof cleanup === "function") {
|
|
609
|
+
root.cleanups.push(cleanup);
|
|
610
|
+
}
|
|
566
611
|
}
|
|
612
|
+
} finally {
|
|
613
|
+
currentRoot = prevRoot;
|
|
614
|
+
cbs.length = 0;
|
|
567
615
|
}
|
|
568
|
-
cbs.length = 0;
|
|
569
616
|
}
|
|
570
617
|
function registerRootCleanup(fn) {
|
|
571
618
|
if (currentRoot) {
|
|
@@ -750,8 +797,164 @@ function handleSuspend(token, startRoot) {
|
|
|
750
797
|
return false;
|
|
751
798
|
}
|
|
752
799
|
|
|
800
|
+
// src/effect.ts
|
|
801
|
+
function createEffect(fn) {
|
|
802
|
+
let cleanups = [];
|
|
803
|
+
const rootForError = getCurrentRoot();
|
|
804
|
+
const doCleanup = () => {
|
|
805
|
+
runCleanupList(cleanups);
|
|
806
|
+
cleanups = [];
|
|
807
|
+
};
|
|
808
|
+
const run = () => {
|
|
809
|
+
const bucket = [];
|
|
810
|
+
withEffectCleanups(bucket, () => {
|
|
811
|
+
try {
|
|
812
|
+
const maybeCleanup = fn();
|
|
813
|
+
if (typeof maybeCleanup === "function") {
|
|
814
|
+
bucket.push(maybeCleanup);
|
|
815
|
+
}
|
|
816
|
+
} catch (err) {
|
|
817
|
+
if (handleSuspend(err, rootForError)) {
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
if (handleError(err, { source: "effect" }, rootForError)) {
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
throw err;
|
|
824
|
+
}
|
|
825
|
+
});
|
|
826
|
+
cleanups = bucket;
|
|
827
|
+
};
|
|
828
|
+
const disposeEffect = effectWithCleanup(run, doCleanup, rootForError);
|
|
829
|
+
const teardown = () => {
|
|
830
|
+
runCleanupList(cleanups);
|
|
831
|
+
disposeEffect();
|
|
832
|
+
};
|
|
833
|
+
registerRootCleanup(teardown);
|
|
834
|
+
return teardown;
|
|
835
|
+
}
|
|
836
|
+
function createRenderEffect(fn) {
|
|
837
|
+
let cleanup;
|
|
838
|
+
const rootForError = getCurrentRoot();
|
|
839
|
+
const doCleanup = () => {
|
|
840
|
+
if (cleanup) {
|
|
841
|
+
cleanup();
|
|
842
|
+
cleanup = void 0;
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
const run = () => {
|
|
846
|
+
try {
|
|
847
|
+
const maybeCleanup = fn();
|
|
848
|
+
if (typeof maybeCleanup === "function") {
|
|
849
|
+
cleanup = maybeCleanup;
|
|
850
|
+
}
|
|
851
|
+
} catch (err) {
|
|
852
|
+
if (handleSuspend(err, rootForError)) {
|
|
853
|
+
return;
|
|
854
|
+
}
|
|
855
|
+
const handled = handleError(err, { source: "effect" }, rootForError);
|
|
856
|
+
if (handled) {
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
throw err;
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
const disposeEffect = effectWithCleanup(run, doCleanup, rootForError);
|
|
863
|
+
const teardown = () => {
|
|
864
|
+
if (cleanup) {
|
|
865
|
+
cleanup();
|
|
866
|
+
cleanup = void 0;
|
|
867
|
+
}
|
|
868
|
+
disposeEffect();
|
|
869
|
+
};
|
|
870
|
+
registerRootCleanup(teardown);
|
|
871
|
+
return teardown;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
// src/hooks.ts
|
|
875
|
+
var isDev4 = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process === "undefined" || _optionalChain([process, 'access', _11 => _11.env, 'optionalAccess', _12 => _12.NODE_ENV]) !== "production";
|
|
876
|
+
var ctxStack = [];
|
|
877
|
+
function assertRenderContext(ctx, hookName) {
|
|
878
|
+
if (!ctx.rendering) {
|
|
879
|
+
const message = isDev4 ? `${hookName} can only be used during render execution` : "FICT:E_HOOK_RENDER";
|
|
880
|
+
throw new Error(message);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
function __fictUseContext() {
|
|
884
|
+
if (ctxStack.length === 0) {
|
|
885
|
+
const message = isDev4 ? "Invalid hook call: hooks can only be used while rendering a component. Make sure you are not calling hooks in event handlers or outside of components." : "FICT:E_HOOK_OUTSIDE_RENDER";
|
|
886
|
+
throw new Error(message);
|
|
887
|
+
}
|
|
888
|
+
const ctx = ctxStack[ctxStack.length - 1];
|
|
889
|
+
if (!ctx.rendering) {
|
|
890
|
+
ctx.cursor = 0;
|
|
891
|
+
ctx.rendering = true;
|
|
892
|
+
}
|
|
893
|
+
return ctx;
|
|
894
|
+
}
|
|
895
|
+
function __fictPushContext() {
|
|
896
|
+
const ctx = { slots: [], cursor: 0 };
|
|
897
|
+
ctxStack.push(ctx);
|
|
898
|
+
return ctx;
|
|
899
|
+
}
|
|
900
|
+
function __fictGetCurrentComponentId() {
|
|
901
|
+
return _optionalChain([ctxStack, 'access', _13 => _13[ctxStack.length - 1], 'optionalAccess', _14 => _14.componentId]);
|
|
902
|
+
}
|
|
903
|
+
function __fictPopContext() {
|
|
904
|
+
const ctx = ctxStack.pop();
|
|
905
|
+
if (ctx) ctx.rendering = false;
|
|
906
|
+
}
|
|
907
|
+
function __fictResetContext() {
|
|
908
|
+
ctxStack.length = 0;
|
|
909
|
+
}
|
|
910
|
+
function __fictUseSignal(ctx, initial, optionsOrSlot, slot) {
|
|
911
|
+
assertRenderContext(ctx, "__fictUseSignal");
|
|
912
|
+
const options2 = typeof optionsOrSlot === "number" ? void 0 : optionsOrSlot;
|
|
913
|
+
const resolvedSlot = typeof optionsOrSlot === "number" ? optionsOrSlot : slot;
|
|
914
|
+
const index = _nullishCoalesce(resolvedSlot, () => ( ctx.cursor++));
|
|
915
|
+
if (!ctx.slots[index]) {
|
|
916
|
+
ctx.slots[index] = signal(initial, options2);
|
|
917
|
+
}
|
|
918
|
+
return ctx.slots[index];
|
|
919
|
+
}
|
|
920
|
+
function __fictUseMemo(ctx, fn, optionsOrSlot, slot) {
|
|
921
|
+
assertRenderContext(ctx, "__fictUseMemo");
|
|
922
|
+
const options2 = typeof optionsOrSlot === "number" ? void 0 : optionsOrSlot;
|
|
923
|
+
const resolvedSlot = typeof optionsOrSlot === "number" ? optionsOrSlot : slot;
|
|
924
|
+
const index = _nullishCoalesce(resolvedSlot, () => ( ctx.cursor++));
|
|
925
|
+
if (!ctx.slots[index]) {
|
|
926
|
+
ctx.slots[index] = createMemo(fn, options2);
|
|
927
|
+
}
|
|
928
|
+
return ctx.slots[index];
|
|
929
|
+
}
|
|
930
|
+
function __fictUseEffect(ctx, fn, slot) {
|
|
931
|
+
if (slot !== void 0) {
|
|
932
|
+
if (ctx.slots[slot]) {
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
ctx.slots[slot] = createEffect(fn);
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
assertRenderContext(ctx, "__fictUseEffect");
|
|
939
|
+
const index = ctx.cursor++;
|
|
940
|
+
if (!ctx.slots[index]) {
|
|
941
|
+
ctx.slots[index] = createEffect(fn);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
function __fictRender(ctx, fn) {
|
|
945
|
+
ctxStack.push(ctx);
|
|
946
|
+
ctx.cursor = 0;
|
|
947
|
+
ctx.rendering = true;
|
|
948
|
+
try {
|
|
949
|
+
return fn();
|
|
950
|
+
} finally {
|
|
951
|
+
ctx.rendering = false;
|
|
952
|
+
ctxStack.pop();
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
|
|
753
956
|
// src/signal.ts
|
|
754
|
-
var
|
|
957
|
+
var isDev5 = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process === "undefined" || _optionalChain([process, 'access', _15 => _15.env, 'optionalAccess', _16 => _16.NODE_ENV]) !== "production";
|
|
755
958
|
var Mutable = 1;
|
|
756
959
|
var Watching = 2;
|
|
757
960
|
var Running = 4;
|
|
@@ -796,6 +999,7 @@ function link(dep, sub, version) {
|
|
|
796
999
|
else sub.deps = newLink;
|
|
797
1000
|
if (prevSub !== void 0) prevSub.nextSub = newLink;
|
|
798
1001
|
else dep.subs = newLink;
|
|
1002
|
+
if (isDev5) trackDependencyDevtools(dep, sub);
|
|
799
1003
|
}
|
|
800
1004
|
function unlink(lnk, sub = lnk.sub) {
|
|
801
1005
|
const dep = lnk.dep;
|
|
@@ -811,6 +1015,7 @@ function unlink(lnk, sub = lnk.sub) {
|
|
|
811
1015
|
else dep.subsTail = prevSub;
|
|
812
1016
|
if (prevSub !== void 0) prevSub.nextSub = nextSub;
|
|
813
1017
|
else if ((dep.subs = nextSub) === void 0) unwatched(dep);
|
|
1018
|
+
if (isDev5) untrackDependencyDevtools(dep, sub);
|
|
814
1019
|
return nextDep;
|
|
815
1020
|
}
|
|
816
1021
|
function unwatched(dep) {
|
|
@@ -967,6 +1172,11 @@ function shallowPropagate(firstLink) {
|
|
|
967
1172
|
function update(node) {
|
|
968
1173
|
return "getter" in node && node.getter !== void 0 ? updateComputed(node) : updateSignal(node);
|
|
969
1174
|
}
|
|
1175
|
+
function valuesDiffer(node, prev, next) {
|
|
1176
|
+
if (node.equals === false) return true;
|
|
1177
|
+
if (typeof node.equals === "function") return !node.equals(prev, next);
|
|
1178
|
+
return prev !== next;
|
|
1179
|
+
}
|
|
970
1180
|
function notify(effect2) {
|
|
971
1181
|
effect2.flags &= ~Watching;
|
|
972
1182
|
const effects = [];
|
|
@@ -1003,7 +1213,7 @@ function updateSignal(s) {
|
|
|
1003
1213
|
s.flags = Mutable;
|
|
1004
1214
|
const current = s.currentValue;
|
|
1005
1215
|
const pending = s.pendingValue;
|
|
1006
|
-
if (current
|
|
1216
|
+
if (valuesDiffer(s, current, pending)) {
|
|
1007
1217
|
s.currentValue = pending;
|
|
1008
1218
|
return true;
|
|
1009
1219
|
}
|
|
@@ -1021,8 +1231,9 @@ function updateComputed(c) {
|
|
|
1021
1231
|
activeSub = prevSub;
|
|
1022
1232
|
c.flags &= ~Running;
|
|
1023
1233
|
purgeDeps(c);
|
|
1024
|
-
if (oldValue
|
|
1234
|
+
if (valuesDiffer(c, oldValue, newValue)) {
|
|
1025
1235
|
c.value = newValue;
|
|
1236
|
+
if (isDev5) updateComputedDevtools(c, newValue);
|
|
1026
1237
|
return true;
|
|
1027
1238
|
}
|
|
1028
1239
|
return false;
|
|
@@ -1044,7 +1255,7 @@ function runEffect(e) {
|
|
|
1044
1255
|
}
|
|
1045
1256
|
}
|
|
1046
1257
|
++cycle;
|
|
1047
|
-
effectRunDevtools(e);
|
|
1258
|
+
if (isDev5) effectRunDevtools(e);
|
|
1048
1259
|
e.depsTail = void 0;
|
|
1049
1260
|
e.flags = WatchingRunning;
|
|
1050
1261
|
const prevSub = activeSub;
|
|
@@ -1088,7 +1299,7 @@ function runEffect(e) {
|
|
|
1088
1299
|
}
|
|
1089
1300
|
if (isDirty) {
|
|
1090
1301
|
++cycle;
|
|
1091
|
-
effectRunDevtools(e);
|
|
1302
|
+
if (isDev5) effectRunDevtools(e);
|
|
1092
1303
|
e.depsTail = void 0;
|
|
1093
1304
|
e.flags = WatchingRunning;
|
|
1094
1305
|
const prevSub = activeSub;
|
|
@@ -1137,10 +1348,21 @@ function flush() {
|
|
|
1137
1348
|
while (highIndex < highPriorityQueue.length) {
|
|
1138
1349
|
const e = highPriorityQueue[highIndex];
|
|
1139
1350
|
if (!beforeEffectRunGuard()) {
|
|
1140
|
-
|
|
1141
|
-
highPriorityQueue
|
|
1142
|
-
|
|
1351
|
+
for (let i = 0; i < highPriorityQueue.length; i++) {
|
|
1352
|
+
const queued = highPriorityQueue[i];
|
|
1353
|
+
if (queued && queued.flags !== 0) {
|
|
1354
|
+
queued.flags = Watching;
|
|
1355
|
+
}
|
|
1143
1356
|
}
|
|
1357
|
+
for (let i = 0; i < lowPriorityQueue.length; i++) {
|
|
1358
|
+
const queued = lowPriorityQueue[i];
|
|
1359
|
+
if (queued && queued.flags !== 0) {
|
|
1360
|
+
queued.flags = Watching;
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
highPriorityQueue.length = 0;
|
|
1364
|
+
lowPriorityQueue.length = 0;
|
|
1365
|
+
flushScheduled = false;
|
|
1144
1366
|
endFlushGuard();
|
|
1145
1367
|
return;
|
|
1146
1368
|
}
|
|
@@ -1161,10 +1383,21 @@ function flush() {
|
|
|
1161
1383
|
}
|
|
1162
1384
|
const e = lowPriorityQueue[lowIndex];
|
|
1163
1385
|
if (!beforeEffectRunGuard()) {
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1386
|
+
for (let i = 0; i < highPriorityQueue.length; i++) {
|
|
1387
|
+
const queued = highPriorityQueue[i];
|
|
1388
|
+
if (queued && queued.flags !== 0) {
|
|
1389
|
+
queued.flags = Watching;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
for (let i = 0; i < lowPriorityQueue.length; i++) {
|
|
1393
|
+
const queued = lowPriorityQueue[i];
|
|
1394
|
+
if (queued && queued.flags !== 0) {
|
|
1395
|
+
queued.flags = Watching;
|
|
1396
|
+
}
|
|
1167
1397
|
}
|
|
1398
|
+
highPriorityQueue.length = 0;
|
|
1399
|
+
lowPriorityQueue.length = 0;
|
|
1400
|
+
flushScheduled = false;
|
|
1168
1401
|
endFlushGuard();
|
|
1169
1402
|
return;
|
|
1170
1403
|
}
|
|
@@ -1174,26 +1407,31 @@ function flush() {
|
|
|
1174
1407
|
lowPriorityQueue.length = 0;
|
|
1175
1408
|
endFlushGuard();
|
|
1176
1409
|
}
|
|
1177
|
-
function signal(initialValue) {
|
|
1410
|
+
function signal(initialValue, options2) {
|
|
1178
1411
|
const s = {
|
|
1179
1412
|
currentValue: initialValue,
|
|
1180
1413
|
pendingValue: initialValue,
|
|
1181
1414
|
subs: void 0,
|
|
1182
1415
|
subsTail: void 0,
|
|
1183
1416
|
flags: Mutable,
|
|
1184
|
-
__id: void 0
|
|
1417
|
+
__id: void 0,
|
|
1418
|
+
..._optionalChain([options2, 'optionalAccess', _17 => _17.equals]) !== void 0 ? { equals: options2.equals } : {},
|
|
1419
|
+
..._optionalChain([options2, 'optionalAccess', _18 => _18.name]) !== void 0 ? { name: options2.name } : {},
|
|
1420
|
+
..._optionalChain([options2, 'optionalAccess', _19 => _19.devToolsSource]) !== void 0 ? { devToolsSource: options2.devToolsSource } : {}
|
|
1185
1421
|
};
|
|
1186
|
-
registerSignalDevtools(
|
|
1422
|
+
if (isDev5) registerSignalDevtools(s);
|
|
1187
1423
|
const accessor = signalOper.bind(s);
|
|
1188
1424
|
accessor[SIGNAL_MARKER] = true;
|
|
1189
1425
|
return accessor;
|
|
1190
1426
|
}
|
|
1191
1427
|
function signalOper(value) {
|
|
1192
1428
|
if (arguments.length > 0) {
|
|
1193
|
-
|
|
1194
|
-
|
|
1429
|
+
const next = value;
|
|
1430
|
+
const prev = this.pendingValue;
|
|
1431
|
+
if (valuesDiffer(this, prev, next)) {
|
|
1432
|
+
this.pendingValue = next;
|
|
1195
1433
|
this.flags = MutableDirty;
|
|
1196
|
-
updateSignalDevtools(this,
|
|
1434
|
+
if (isDev5) updateSignalDevtools(this, next);
|
|
1197
1435
|
const subs = this.subs;
|
|
1198
1436
|
if (subs !== void 0) {
|
|
1199
1437
|
propagate(subs);
|
|
@@ -1220,7 +1458,7 @@ function signalOper(value) {
|
|
|
1220
1458
|
}
|
|
1221
1459
|
return this.currentValue;
|
|
1222
1460
|
}
|
|
1223
|
-
function computed(getter) {
|
|
1461
|
+
function computed(getter, options2) {
|
|
1224
1462
|
const c = {
|
|
1225
1463
|
value: void 0,
|
|
1226
1464
|
subs: void 0,
|
|
@@ -1228,13 +1466,21 @@ function computed(getter) {
|
|
|
1228
1466
|
deps: void 0,
|
|
1229
1467
|
depsTail: void 0,
|
|
1230
1468
|
flags: 0,
|
|
1231
|
-
getter
|
|
1469
|
+
getter,
|
|
1470
|
+
__id: void 0,
|
|
1471
|
+
..._optionalChain([options2, 'optionalAccess', _20 => _20.equals]) !== void 0 ? { equals: options2.equals } : {},
|
|
1472
|
+
..._optionalChain([options2, 'optionalAccess', _21 => _21.name]) !== void 0 ? { name: options2.name } : {},
|
|
1473
|
+
..._optionalChain([options2, 'optionalAccess', _22 => _22.devToolsSource]) !== void 0 ? { devToolsSource: options2.devToolsSource } : {}
|
|
1232
1474
|
};
|
|
1233
|
-
|
|
1475
|
+
if (isDev5) registerComputedDevtools(c);
|
|
1476
|
+
const bound = computedOper.bind(
|
|
1477
|
+
c
|
|
1478
|
+
);
|
|
1234
1479
|
bound[COMPUTED_MARKER] = true;
|
|
1235
1480
|
return bound;
|
|
1236
1481
|
}
|
|
1237
1482
|
function computedOper() {
|
|
1483
|
+
if (inCleanup) return this.value;
|
|
1238
1484
|
const flags = this.flags;
|
|
1239
1485
|
if (flags & Dirty) {
|
|
1240
1486
|
if (updateComputed(this)) {
|
|
@@ -1255,6 +1501,7 @@ function computedOper() {
|
|
|
1255
1501
|
const prevSub = setActiveSub(this);
|
|
1256
1502
|
try {
|
|
1257
1503
|
this.value = this.getter(void 0);
|
|
1504
|
+
if (isDev5) updateComputedDevtools(this, this.value);
|
|
1258
1505
|
} finally {
|
|
1259
1506
|
setActiveSub(prevSub);
|
|
1260
1507
|
this.flags &= ~Running;
|
|
@@ -1277,12 +1524,12 @@ function effect(fn) {
|
|
|
1277
1524
|
if (root) {
|
|
1278
1525
|
e.root = root;
|
|
1279
1526
|
}
|
|
1280
|
-
registerEffectDevtools(e);
|
|
1527
|
+
if (isDev5) registerEffectDevtools(e);
|
|
1281
1528
|
const prevSub = activeSub;
|
|
1282
1529
|
if (prevSub !== void 0) link(e, prevSub, 0);
|
|
1283
1530
|
activeSub = e;
|
|
1284
1531
|
try {
|
|
1285
|
-
effectRunDevtools(e);
|
|
1532
|
+
if (isDev5) effectRunDevtools(e);
|
|
1286
1533
|
fn();
|
|
1287
1534
|
} finally {
|
|
1288
1535
|
activeSub = prevSub;
|
|
@@ -1307,12 +1554,12 @@ function effectWithCleanup(fn, cleanupRunner, root) {
|
|
|
1307
1554
|
if (resolvedRoot) {
|
|
1308
1555
|
e.root = resolvedRoot;
|
|
1309
1556
|
}
|
|
1310
|
-
registerEffectDevtools(e);
|
|
1557
|
+
if (isDev5) registerEffectDevtools(e);
|
|
1311
1558
|
const prevSub = activeSub;
|
|
1312
1559
|
if (prevSub !== void 0) link(e, prevSub, 0);
|
|
1313
1560
|
activeSub = e;
|
|
1314
1561
|
try {
|
|
1315
|
-
effectRunDevtools(e);
|
|
1562
|
+
if (isDev5) effectRunDevtools(e);
|
|
1316
1563
|
fn();
|
|
1317
1564
|
} finally {
|
|
1318
1565
|
activeSub = prevSub;
|
|
@@ -1372,6 +1619,16 @@ function setActiveSub(sub) {
|
|
|
1372
1619
|
activeSub = sub;
|
|
1373
1620
|
return prev;
|
|
1374
1621
|
}
|
|
1622
|
+
function __resetReactiveState() {
|
|
1623
|
+
highPriorityQueue.length = 0;
|
|
1624
|
+
lowPriorityQueue.length = 0;
|
|
1625
|
+
batchDepth = 0;
|
|
1626
|
+
activeSub = void 0;
|
|
1627
|
+
flushScheduled = false;
|
|
1628
|
+
isInTransition = false;
|
|
1629
|
+
inCleanup = false;
|
|
1630
|
+
cycle = 0;
|
|
1631
|
+
}
|
|
1375
1632
|
function untrack(fn) {
|
|
1376
1633
|
const prev = activeSub;
|
|
1377
1634
|
activeSub = void 0;
|
|
@@ -1401,17 +1658,28 @@ function setTransitionContext(value) {
|
|
|
1401
1658
|
var registerSignalDevtools = () => void 0;
|
|
1402
1659
|
var updateSignalDevtools = () => {
|
|
1403
1660
|
};
|
|
1661
|
+
var registerComputedDevtools = () => void 0;
|
|
1662
|
+
var updateComputedDevtools = () => {
|
|
1663
|
+
};
|
|
1404
1664
|
var registerEffectDevtools = () => void 0;
|
|
1405
1665
|
var effectRunDevtools = () => {
|
|
1406
1666
|
};
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1667
|
+
var trackDependencyDevtools = () => {
|
|
1668
|
+
};
|
|
1669
|
+
var untrackDependencyDevtools = () => {
|
|
1670
|
+
};
|
|
1671
|
+
if (isDev5) {
|
|
1672
|
+
let nextDevtoolsId = 0;
|
|
1673
|
+
registerSignalDevtools = (node) => {
|
|
1411
1674
|
const hook = getDevtoolsHook();
|
|
1412
1675
|
if (!hook) return void 0;
|
|
1413
|
-
const id = ++
|
|
1414
|
-
|
|
1676
|
+
const id = ++nextDevtoolsId;
|
|
1677
|
+
const options2 = {};
|
|
1678
|
+
if (node.name !== void 0) options2.name = node.name;
|
|
1679
|
+
if (node.devToolsSource !== void 0) options2.source = node.devToolsSource;
|
|
1680
|
+
const ownerId = __fictGetCurrentComponentId();
|
|
1681
|
+
if (ownerId !== void 0) options2.ownerId = ownerId;
|
|
1682
|
+
hook.registerSignal(id, node.currentValue, options2);
|
|
1415
1683
|
node.__id = id;
|
|
1416
1684
|
return id;
|
|
1417
1685
|
};
|
|
@@ -1421,11 +1689,32 @@ if (isDev4) {
|
|
|
1421
1689
|
const id = node.__id;
|
|
1422
1690
|
if (id) hook.updateSignal(id, value);
|
|
1423
1691
|
};
|
|
1692
|
+
registerComputedDevtools = (node) => {
|
|
1693
|
+
const hook = getDevtoolsHook();
|
|
1694
|
+
if (!hook) return void 0;
|
|
1695
|
+
const id = ++nextDevtoolsId;
|
|
1696
|
+
const options2 = {};
|
|
1697
|
+
if (node.name !== void 0) options2.name = node.name;
|
|
1698
|
+
if (node.devToolsSource !== void 0) options2.source = node.devToolsSource;
|
|
1699
|
+
const ownerId = __fictGetCurrentComponentId();
|
|
1700
|
+
if (ownerId !== void 0) options2.ownerId = ownerId;
|
|
1701
|
+
options2.hasValue = false;
|
|
1702
|
+
hook.registerComputed(id, node.value, options2);
|
|
1703
|
+
node.__id = id;
|
|
1704
|
+
return id;
|
|
1705
|
+
};
|
|
1706
|
+
updateComputedDevtools = (node, value) => {
|
|
1707
|
+
const hook = getDevtoolsHook();
|
|
1708
|
+
if (!hook) return;
|
|
1709
|
+
const id = node.__id;
|
|
1710
|
+
if (id) hook.updateComputed(id, value);
|
|
1711
|
+
};
|
|
1424
1712
|
registerEffectDevtools = (node) => {
|
|
1425
1713
|
const hook = getDevtoolsHook();
|
|
1426
1714
|
if (!hook) return void 0;
|
|
1427
|
-
const id = ++
|
|
1428
|
-
|
|
1715
|
+
const id = ++nextDevtoolsId;
|
|
1716
|
+
const ownerId = __fictGetCurrentComponentId();
|
|
1717
|
+
hook.registerEffect(id, ownerId !== void 0 ? { ownerId } : void 0);
|
|
1429
1718
|
node.__id = id;
|
|
1430
1719
|
return id;
|
|
1431
1720
|
};
|
|
@@ -1435,6 +1724,20 @@ if (isDev4) {
|
|
|
1435
1724
|
const id = node.__id;
|
|
1436
1725
|
if (id) hook.effectRun(id);
|
|
1437
1726
|
};
|
|
1727
|
+
trackDependencyDevtools = (dep, sub) => {
|
|
1728
|
+
const hook = getDevtoolsHook();
|
|
1729
|
+
if (!_optionalChain([hook, 'optionalAccess', _23 => _23.trackDependency])) return;
|
|
1730
|
+
const depId = dep.__id;
|
|
1731
|
+
const subId = sub.__id;
|
|
1732
|
+
if (depId && subId) hook.trackDependency(subId, depId);
|
|
1733
|
+
};
|
|
1734
|
+
untrackDependencyDevtools = (dep, sub) => {
|
|
1735
|
+
const hook = getDevtoolsHook();
|
|
1736
|
+
if (!_optionalChain([hook, 'optionalAccess', _24 => _24.untrackDependency])) return;
|
|
1737
|
+
const depId = dep.__id;
|
|
1738
|
+
const subId = sub.__id;
|
|
1739
|
+
if (depId && subId) hook.untrackDependency(subId, depId);
|
|
1740
|
+
};
|
|
1438
1741
|
}
|
|
1439
1742
|
function createSelector(source, equalityFn = (a, b) => a === b) {
|
|
1440
1743
|
let current = source();
|
|
@@ -1463,78 +1766,9 @@ function createSelector(source, equalityFn = (a, b) => a === b) {
|
|
|
1463
1766
|
};
|
|
1464
1767
|
}
|
|
1465
1768
|
|
|
1466
|
-
// src/
|
|
1467
|
-
function
|
|
1468
|
-
|
|
1469
|
-
const rootForError = getCurrentRoot();
|
|
1470
|
-
const doCleanup = () => {
|
|
1471
|
-
runCleanupList(cleanups);
|
|
1472
|
-
cleanups = [];
|
|
1473
|
-
};
|
|
1474
|
-
const run = () => {
|
|
1475
|
-
const bucket = [];
|
|
1476
|
-
withEffectCleanups(bucket, () => {
|
|
1477
|
-
try {
|
|
1478
|
-
const maybeCleanup = fn();
|
|
1479
|
-
if (typeof maybeCleanup === "function") {
|
|
1480
|
-
bucket.push(maybeCleanup);
|
|
1481
|
-
}
|
|
1482
|
-
} catch (err) {
|
|
1483
|
-
if (handleSuspend(err, rootForError)) {
|
|
1484
|
-
return;
|
|
1485
|
-
}
|
|
1486
|
-
if (handleError(err, { source: "effect" }, rootForError)) {
|
|
1487
|
-
return;
|
|
1488
|
-
}
|
|
1489
|
-
throw err;
|
|
1490
|
-
}
|
|
1491
|
-
});
|
|
1492
|
-
cleanups = bucket;
|
|
1493
|
-
};
|
|
1494
|
-
const disposeEffect = effectWithCleanup(run, doCleanup, rootForError);
|
|
1495
|
-
const teardown = () => {
|
|
1496
|
-
runCleanupList(cleanups);
|
|
1497
|
-
disposeEffect();
|
|
1498
|
-
};
|
|
1499
|
-
registerRootCleanup(teardown);
|
|
1500
|
-
return teardown;
|
|
1501
|
-
}
|
|
1502
|
-
function createRenderEffect(fn) {
|
|
1503
|
-
let cleanup;
|
|
1504
|
-
const rootForError = getCurrentRoot();
|
|
1505
|
-
const doCleanup = () => {
|
|
1506
|
-
if (cleanup) {
|
|
1507
|
-
cleanup();
|
|
1508
|
-
cleanup = void 0;
|
|
1509
|
-
}
|
|
1510
|
-
};
|
|
1511
|
-
const run = () => {
|
|
1512
|
-
try {
|
|
1513
|
-
const maybeCleanup = fn();
|
|
1514
|
-
if (typeof maybeCleanup === "function") {
|
|
1515
|
-
cleanup = maybeCleanup;
|
|
1516
|
-
}
|
|
1517
|
-
} catch (err) {
|
|
1518
|
-
if (handleSuspend(err, rootForError)) {
|
|
1519
|
-
return;
|
|
1520
|
-
}
|
|
1521
|
-
const handled = handleError(err, { source: "effect" }, rootForError);
|
|
1522
|
-
if (handled) {
|
|
1523
|
-
return;
|
|
1524
|
-
}
|
|
1525
|
-
throw err;
|
|
1526
|
-
}
|
|
1527
|
-
};
|
|
1528
|
-
const disposeEffect = effectWithCleanup(run, doCleanup, rootForError);
|
|
1529
|
-
const teardown = () => {
|
|
1530
|
-
if (cleanup) {
|
|
1531
|
-
cleanup();
|
|
1532
|
-
cleanup = void 0;
|
|
1533
|
-
}
|
|
1534
|
-
disposeEffect();
|
|
1535
|
-
};
|
|
1536
|
-
registerRootCleanup(teardown);
|
|
1537
|
-
return teardown;
|
|
1769
|
+
// src/memo.ts
|
|
1770
|
+
function createMemo(fn, options2) {
|
|
1771
|
+
return computed(fn, options2);
|
|
1538
1772
|
}
|
|
1539
1773
|
|
|
1540
1774
|
// src/jsx.ts
|
|
@@ -1679,7 +1913,7 @@ function insertNodesBefore(parent, nodes, anchor) {
|
|
|
1679
1913
|
}
|
|
1680
1914
|
function removeNodes(nodes) {
|
|
1681
1915
|
for (const node of nodes) {
|
|
1682
|
-
_optionalChain([node, 'access',
|
|
1916
|
+
_optionalChain([node, 'access', _25 => _25.parentNode, 'optionalAccess', _26 => _26.removeChild, 'call', _27 => _27(node)]);
|
|
1683
1917
|
}
|
|
1684
1918
|
}
|
|
1685
1919
|
|
|
@@ -1730,13 +1964,22 @@ function untrack2(fn) {
|
|
|
1730
1964
|
}
|
|
1731
1965
|
|
|
1732
1966
|
// src/binding.ts
|
|
1733
|
-
var
|
|
1967
|
+
var isDev6 = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process === "undefined" || _optionalChain([process, 'access', _28 => _28.env, 'optionalAccess', _29 => _29.NODE_ENV]) !== "production";
|
|
1734
1968
|
function isReactive(value) {
|
|
1735
1969
|
if (typeof value !== "function") return false;
|
|
1736
1970
|
if (isSignal(value) || isComputed(value)) return true;
|
|
1737
1971
|
if (isEffect(value) || isEffectScope(value)) return false;
|
|
1738
1972
|
return value.length === 0;
|
|
1739
1973
|
}
|
|
1974
|
+
function isStrictlyReactive(value) {
|
|
1975
|
+
if (typeof value !== "function") return false;
|
|
1976
|
+
return isSignal(value) || isComputed(value) || isPropGetterFn(value);
|
|
1977
|
+
}
|
|
1978
|
+
var PROP_GETTER_MARKER = Symbol.for("fict:prop-getter");
|
|
1979
|
+
function isPropGetterFn(value) {
|
|
1980
|
+
if (typeof value !== "function") return false;
|
|
1981
|
+
return value[PROP_GETTER_MARKER] === true;
|
|
1982
|
+
}
|
|
1740
1983
|
function unwrap(value) {
|
|
1741
1984
|
return isReactive(value) ? value() : value;
|
|
1742
1985
|
}
|
|
@@ -1903,7 +2146,7 @@ function applyStyle(el, value, prev) {
|
|
|
1903
2146
|
}
|
|
1904
2147
|
}
|
|
1905
2148
|
}
|
|
1906
|
-
var isUnitlessStyleProperty =
|
|
2149
|
+
var isUnitlessStyleProperty = isDev6 ? (prop2) => UnitlessStyles.has(prop2) : (prop2) => prop2 === "opacity" || prop2 === "zIndex";
|
|
1907
2150
|
function createClassBinding(el, value) {
|
|
1908
2151
|
if (isReactive(value)) {
|
|
1909
2152
|
let prev = {};
|
|
@@ -2101,7 +2344,7 @@ function insert(parent, getValue, markerOrCreateElement, createElementFn) {
|
|
|
2101
2344
|
}
|
|
2102
2345
|
clearCurrentNodes();
|
|
2103
2346
|
if (ownsMarker) {
|
|
2104
|
-
_optionalChain([marker, 'access',
|
|
2347
|
+
_optionalChain([marker, 'access', _30 => _30.parentNode, 'optionalAccess', _31 => _31.removeChild, 'call', _32 => _32(marker)]);
|
|
2105
2348
|
}
|
|
2106
2349
|
};
|
|
2107
2350
|
}
|
|
@@ -2152,7 +2395,7 @@ function createChildBinding(parent, getValue, createElementFn) {
|
|
|
2152
2395
|
marker,
|
|
2153
2396
|
dispose: () => {
|
|
2154
2397
|
dispose();
|
|
2155
|
-
_optionalChain([marker, 'access',
|
|
2398
|
+
_optionalChain([marker, 'access', _33 => _33.parentNode, 'optionalAccess', _34 => _34.removeChild, 'call', _35 => _35(marker)]);
|
|
2156
2399
|
}
|
|
2157
2400
|
};
|
|
2158
2401
|
}
|
|
@@ -2290,7 +2533,7 @@ function bindEvent(el, eventName, handler, options2) {
|
|
|
2290
2533
|
if (shouldDelegate) {
|
|
2291
2534
|
const key = `$$${eventName}`;
|
|
2292
2535
|
delegateEvents([eventName]);
|
|
2293
|
-
const resolveHandler =
|
|
2536
|
+
const resolveHandler = isStrictlyReactive(handler) ? handler : () => handler;
|
|
2294
2537
|
el[key] = function(...args) {
|
|
2295
2538
|
try {
|
|
2296
2539
|
const fn = resolveHandler();
|
|
@@ -2305,7 +2548,7 @@ function bindEvent(el, eventName, handler, options2) {
|
|
|
2305
2548
|
el[key] = void 0;
|
|
2306
2549
|
};
|
|
2307
2550
|
}
|
|
2308
|
-
const getHandler =
|
|
2551
|
+
const getHandler = isStrictlyReactive(handler) ? handler : () => handler;
|
|
2309
2552
|
const wrapped = (event) => {
|
|
2310
2553
|
try {
|
|
2311
2554
|
const resolved = getHandler();
|
|
@@ -2467,9 +2710,9 @@ function assignProp(node, prop2, value, prev, isSVG, skipRef, props) {
|
|
|
2467
2710
|
}
|
|
2468
2711
|
const isCE = node.nodeName.includes("-") || "is" in props;
|
|
2469
2712
|
if (!isSVG) {
|
|
2470
|
-
const propAlias =
|
|
2471
|
-
const isProperty =
|
|
2472
|
-
const isChildProp =
|
|
2713
|
+
const propAlias = isDev6 ? getPropAlias(prop2, node.tagName) : void 0;
|
|
2714
|
+
const isProperty = isDev6 ? Properties.has(prop2) : prop2 in node;
|
|
2715
|
+
const isChildProp = isDev6 ? ChildProperties.has(prop2) : prop2 === "innerHTML" || prop2 === "textContent" || prop2 === "innerText" || prop2 === "children";
|
|
2473
2716
|
if (propAlias || isProperty || isChildProp || isCE) {
|
|
2474
2717
|
const propName = propAlias || prop2;
|
|
2475
2718
|
if (isCE && !isProperty && !isChildProp && !propAlias) {
|
|
@@ -2584,8 +2827,8 @@ function createConditional(condition, renderTrue, createElementFn, renderFalse)
|
|
|
2584
2827
|
}
|
|
2585
2828
|
removeNodes(currentNodes);
|
|
2586
2829
|
currentNodes = [];
|
|
2587
|
-
_optionalChain([startMarker, 'access',
|
|
2588
|
-
_optionalChain([endMarker, 'access',
|
|
2830
|
+
_optionalChain([startMarker, 'access', _36 => _36.parentNode, 'optionalAccess', _37 => _37.removeChild, 'call', _38 => _38(startMarker)]);
|
|
2831
|
+
_optionalChain([endMarker, 'access', _39 => _39.parentNode, 'optionalAccess', _40 => _40.removeChild, 'call', _41 => _41(endMarker)]);
|
|
2589
2832
|
}
|
|
2590
2833
|
};
|
|
2591
2834
|
}
|
|
@@ -2655,7 +2898,7 @@ function createPortal(container, render2, createElementFn) {
|
|
|
2655
2898
|
if (currentNodes.length > 0) {
|
|
2656
2899
|
removeNodes(currentNodes);
|
|
2657
2900
|
}
|
|
2658
|
-
_optionalChain([marker, 'access',
|
|
2901
|
+
_optionalChain([marker, 'access', _42 => _42.parentNode, 'optionalAccess', _43 => _43.removeChild, 'call', _44 => _44(marker)]);
|
|
2659
2902
|
};
|
|
2660
2903
|
if (parentRoot) {
|
|
2661
2904
|
parentRoot.destroyCallbacks.push(portalDispose);
|
|
@@ -2666,79 +2909,8 @@ function createPortal(container, render2, createElementFn) {
|
|
|
2666
2909
|
};
|
|
2667
2910
|
}
|
|
2668
2911
|
|
|
2669
|
-
// src/memo.ts
|
|
2670
|
-
function createMemo(fn) {
|
|
2671
|
-
return computed(fn);
|
|
2672
|
-
}
|
|
2673
|
-
|
|
2674
|
-
// src/hooks.ts
|
|
2675
|
-
var isDev6 = true ? false : typeof process === "undefined" || _optionalChain([process, 'access', _33 => _33.env, 'optionalAccess', _34 => _34.NODE_ENV]) !== "production";
|
|
2676
|
-
var ctxStack = [];
|
|
2677
|
-
function assertRenderContext(ctx, hookName) {
|
|
2678
|
-
if (!ctx.rendering) {
|
|
2679
|
-
const message = isDev6 ? `${hookName} can only be used during render execution` : "FICT:E_HOOK_RENDER";
|
|
2680
|
-
throw new Error(message);
|
|
2681
|
-
}
|
|
2682
|
-
}
|
|
2683
|
-
function __fictUseContext() {
|
|
2684
|
-
if (ctxStack.length === 0) {
|
|
2685
|
-
const ctx2 = { slots: [], cursor: 0, rendering: true };
|
|
2686
|
-
ctxStack.push(ctx2);
|
|
2687
|
-
return ctx2;
|
|
2688
|
-
}
|
|
2689
|
-
const ctx = ctxStack[ctxStack.length - 1];
|
|
2690
|
-
ctx.cursor = 0;
|
|
2691
|
-
ctx.rendering = true;
|
|
2692
|
-
return ctx;
|
|
2693
|
-
}
|
|
2694
|
-
function __fictPushContext() {
|
|
2695
|
-
const ctx = { slots: [], cursor: 0 };
|
|
2696
|
-
ctxStack.push(ctx);
|
|
2697
|
-
return ctx;
|
|
2698
|
-
}
|
|
2699
|
-
function __fictPopContext() {
|
|
2700
|
-
ctxStack.pop();
|
|
2701
|
-
}
|
|
2702
|
-
function __fictResetContext() {
|
|
2703
|
-
ctxStack.length = 0;
|
|
2704
|
-
}
|
|
2705
|
-
function __fictUseSignal(ctx, initial, slot) {
|
|
2706
|
-
assertRenderContext(ctx, "__fictUseSignal");
|
|
2707
|
-
const index = _nullishCoalesce(slot, () => ( ctx.cursor++));
|
|
2708
|
-
if (!ctx.slots[index]) {
|
|
2709
|
-
ctx.slots[index] = signal(initial);
|
|
2710
|
-
}
|
|
2711
|
-
return ctx.slots[index];
|
|
2712
|
-
}
|
|
2713
|
-
function __fictUseMemo(ctx, fn, slot) {
|
|
2714
|
-
assertRenderContext(ctx, "__fictUseMemo");
|
|
2715
|
-
const index = _nullishCoalesce(slot, () => ( ctx.cursor++));
|
|
2716
|
-
if (!ctx.slots[index]) {
|
|
2717
|
-
ctx.slots[index] = createMemo(fn);
|
|
2718
|
-
}
|
|
2719
|
-
return ctx.slots[index];
|
|
2720
|
-
}
|
|
2721
|
-
function __fictUseEffect(ctx, fn, slot) {
|
|
2722
|
-
assertRenderContext(ctx, "__fictUseEffect");
|
|
2723
|
-
const index = _nullishCoalesce(slot, () => ( ctx.cursor++));
|
|
2724
|
-
if (!ctx.slots[index]) {
|
|
2725
|
-
ctx.slots[index] = createEffect(fn);
|
|
2726
|
-
}
|
|
2727
|
-
}
|
|
2728
|
-
function __fictRender(ctx, fn) {
|
|
2729
|
-
ctxStack.push(ctx);
|
|
2730
|
-
ctx.cursor = 0;
|
|
2731
|
-
ctx.rendering = true;
|
|
2732
|
-
try {
|
|
2733
|
-
return fn();
|
|
2734
|
-
} finally {
|
|
2735
|
-
ctx.rendering = false;
|
|
2736
|
-
ctxStack.pop();
|
|
2737
|
-
}
|
|
2738
|
-
}
|
|
2739
|
-
|
|
2740
2912
|
// src/props.ts
|
|
2741
|
-
var
|
|
2913
|
+
var PROP_GETTER_MARKER2 = Symbol.for("fict:prop-getter");
|
|
2742
2914
|
var propGetters = /* @__PURE__ */ new WeakSet();
|
|
2743
2915
|
var rawToProxy = /* @__PURE__ */ new WeakMap();
|
|
2744
2916
|
var proxyToRaw = /* @__PURE__ */ new WeakMap();
|
|
@@ -2748,7 +2920,7 @@ function __fictProp(getter) {
|
|
|
2748
2920
|
if (Object.isExtensible(getter)) {
|
|
2749
2921
|
try {
|
|
2750
2922
|
;
|
|
2751
|
-
getter[
|
|
2923
|
+
getter[PROP_GETTER_MARKER2] = true;
|
|
2752
2924
|
} catch (e11) {
|
|
2753
2925
|
}
|
|
2754
2926
|
}
|
|
@@ -2758,7 +2930,7 @@ function __fictProp(getter) {
|
|
|
2758
2930
|
function isPropGetter(value) {
|
|
2759
2931
|
if (typeof value !== "function") return false;
|
|
2760
2932
|
const fn = value;
|
|
2761
|
-
return propGetters.has(fn) || fn[
|
|
2933
|
+
return propGetters.has(fn) || fn[PROP_GETTER_MARKER2] === true;
|
|
2762
2934
|
}
|
|
2763
2935
|
function createPropsProxy(props) {
|
|
2764
2936
|
if (!props || typeof props !== "object") {
|
|
@@ -2882,12 +3054,19 @@ function mergeProps(...sources) {
|
|
|
2882
3054
|
}
|
|
2883
3055
|
});
|
|
2884
3056
|
}
|
|
3057
|
+
function keyed(target, key, options2) {
|
|
3058
|
+
return prop(() => {
|
|
3059
|
+
const resolvedTarget = isPropGetter(target) ? target() : target;
|
|
3060
|
+
const resolvedKey = typeof key === "function" ? key() : key;
|
|
3061
|
+
return resolvedTarget[resolvedKey];
|
|
3062
|
+
}, options2);
|
|
3063
|
+
}
|
|
2885
3064
|
function prop(getter, options2) {
|
|
2886
3065
|
if (isPropGetter(getter)) {
|
|
2887
3066
|
return getter;
|
|
2888
3067
|
}
|
|
2889
3068
|
const fn = getter;
|
|
2890
|
-
const unwrap2 = _optionalChain([options2, 'optionalAccess',
|
|
3069
|
+
const unwrap2 = _optionalChain([options2, 'optionalAccess', _45 => _45.unwrap]) !== false;
|
|
2891
3070
|
return __fictProp(
|
|
2892
3071
|
createMemo(() => {
|
|
2893
3072
|
const value = fn();
|
|
@@ -2902,7 +3081,8 @@ function prop(getter, options2) {
|
|
|
2902
3081
|
// src/dom.ts
|
|
2903
3082
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
2904
3083
|
var MATHML_NS = "http://www.w3.org/1998/Math/MathML";
|
|
2905
|
-
var isDev7 =
|
|
3084
|
+
var isDev7 = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process === "undefined" || _optionalChain([process, 'access', _46 => _46.env, 'optionalAccess', _47 => _47.NODE_ENV]) !== "production";
|
|
3085
|
+
var nextComponentId = 1;
|
|
2906
3086
|
function render(view, container) {
|
|
2907
3087
|
const root = createRootContext();
|
|
2908
3088
|
const prev = pushRoot(root);
|
|
@@ -2995,9 +3175,27 @@ function createElementWithContext(node, namespace) {
|
|
|
2995
3175
|
}
|
|
2996
3176
|
});
|
|
2997
3177
|
const props = createPropsProxy(baseProps);
|
|
2998
|
-
|
|
3178
|
+
const hook = isDev7 ? getDevtoolsHook() : void 0;
|
|
3179
|
+
const parentId = hook ? __fictGetCurrentComponentId() : void 0;
|
|
3180
|
+
const componentId = hook ? nextComponentId++ : void 0;
|
|
3181
|
+
if (_optionalChain([hook, 'optionalAccess', _48 => _48.registerComponent]) && componentId !== void 0) {
|
|
3182
|
+
hook.registerComponent(componentId, vnode.type.name || "Anonymous", parentId);
|
|
3183
|
+
}
|
|
3184
|
+
const ctx = __fictPushContext();
|
|
3185
|
+
if (componentId !== void 0) {
|
|
3186
|
+
ctx.componentId = componentId;
|
|
3187
|
+
if (parentId !== void 0) {
|
|
3188
|
+
ctx.parentId = parentId;
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
2999
3191
|
try {
|
|
3000
3192
|
const rendered = vnode.type(props);
|
|
3193
|
+
if (hook && componentId !== void 0) {
|
|
3194
|
+
onMount(() => {
|
|
3195
|
+
_optionalChain([hook, 'access', _49 => _49.componentMount, 'optionalCall', _50 => _50(componentId)]);
|
|
3196
|
+
});
|
|
3197
|
+
onCleanup(() => _optionalChain([hook, 'access', _51 => _51.componentUnmount, 'optionalCall', _52 => _52(componentId)]));
|
|
3198
|
+
}
|
|
3001
3199
|
return createElementWithContext(rendered, namespace);
|
|
3002
3200
|
} catch (err) {
|
|
3003
3201
|
if (handleSuspend(err)) {
|
|
@@ -3011,7 +3209,7 @@ function createElementWithContext(node, namespace) {
|
|
|
3011
3209
|
}
|
|
3012
3210
|
if (vnode.type === Fragment) {
|
|
3013
3211
|
const frag = document.createDocumentFragment();
|
|
3014
|
-
const children = _optionalChain([vnode, 'access',
|
|
3212
|
+
const children = _optionalChain([vnode, 'access', _53 => _53.props, 'optionalAccess', _54 => _54.children]);
|
|
3015
3213
|
appendChildren(frag, children, namespace);
|
|
3016
3214
|
return frag;
|
|
3017
3215
|
}
|
|
@@ -3021,7 +3219,7 @@ function createElementWithContext(node, namespace) {
|
|
|
3021
3219
|
applyProps(el, _nullishCoalesce(vnode.props, () => ( {})), resolvedNamespace === "svg");
|
|
3022
3220
|
appendChildren(
|
|
3023
3221
|
el,
|
|
3024
|
-
_optionalChain([vnode, 'access',
|
|
3222
|
+
_optionalChain([vnode, 'access', _55 => _55.props, 'optionalAccess', _56 => _56.children]),
|
|
3025
3223
|
tagName === "foreignObject" ? null : resolvedNamespace
|
|
3026
3224
|
);
|
|
3027
3225
|
return el;
|
|
@@ -3029,15 +3227,48 @@ function createElementWithContext(node, namespace) {
|
|
|
3029
3227
|
function template(html, isImportNode, isSVG, isMathML) {
|
|
3030
3228
|
let node = null;
|
|
3031
3229
|
const create = () => {
|
|
3032
|
-
const t =
|
|
3033
|
-
t.innerHTML = html;
|
|
3230
|
+
const t = document.createElement("template");
|
|
3034
3231
|
if (isSVG) {
|
|
3035
|
-
|
|
3232
|
+
t.innerHTML = `<svg>${html}</svg>`;
|
|
3233
|
+
const wrapper = t.content.firstChild;
|
|
3234
|
+
if (isDev7 && wrapper.childNodes.length !== 1) {
|
|
3235
|
+
console.warn(
|
|
3236
|
+
`[fict] template() received multi-root SVG content (${wrapper.childNodes.length} nodes). Returning a DocumentFragment. This may indicate a compiler bug or invalid JSX structure.`
|
|
3237
|
+
);
|
|
3238
|
+
}
|
|
3239
|
+
if (wrapper.childNodes.length === 1) {
|
|
3240
|
+
return wrapper.firstChild;
|
|
3241
|
+
}
|
|
3242
|
+
const fragment = document.createDocumentFragment();
|
|
3243
|
+
fragment.append(...Array.from(wrapper.childNodes));
|
|
3244
|
+
return fragment;
|
|
3036
3245
|
}
|
|
3037
3246
|
if (isMathML) {
|
|
3038
|
-
|
|
3247
|
+
t.innerHTML = `<math>${html}</math>`;
|
|
3248
|
+
const wrapper = t.content.firstChild;
|
|
3249
|
+
if (isDev7 && wrapper.childNodes.length !== 1) {
|
|
3250
|
+
console.warn(
|
|
3251
|
+
`[fict] template() received multi-root MathML content (${wrapper.childNodes.length} nodes). Returning a DocumentFragment. This may indicate a compiler bug or invalid JSX structure.`
|
|
3252
|
+
);
|
|
3253
|
+
}
|
|
3254
|
+
if (wrapper.childNodes.length === 1) {
|
|
3255
|
+
return wrapper.firstChild;
|
|
3256
|
+
}
|
|
3257
|
+
const fragment = document.createDocumentFragment();
|
|
3258
|
+
fragment.append(...Array.from(wrapper.childNodes));
|
|
3259
|
+
return fragment;
|
|
3260
|
+
}
|
|
3261
|
+
t.innerHTML = html;
|
|
3262
|
+
const content = t.content;
|
|
3263
|
+
if (isDev7 && content.childNodes.length !== 1) {
|
|
3264
|
+
console.warn(
|
|
3265
|
+
`[fict] template() received multi-root content (${content.childNodes.length} nodes). Returning a DocumentFragment. This may indicate a compiler bug or invalid JSX structure.`
|
|
3266
|
+
);
|
|
3267
|
+
}
|
|
3268
|
+
if (content.childNodes.length === 1) {
|
|
3269
|
+
return content.firstChild;
|
|
3039
3270
|
}
|
|
3040
|
-
return
|
|
3271
|
+
return content;
|
|
3041
3272
|
};
|
|
3042
3273
|
const fn = isImportNode ? () => untrack2(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
|
|
3043
3274
|
fn.cloneNode = fn;
|
|
@@ -3052,7 +3283,7 @@ function appendChildNode(parent, child, namespace) {
|
|
|
3052
3283
|
}
|
|
3053
3284
|
if (isBindingHandle(child)) {
|
|
3054
3285
|
appendChildNode(parent, child.marker, namespace);
|
|
3055
|
-
_optionalChain([child, 'access',
|
|
3286
|
+
_optionalChain([child, 'access', _57 => _57.flush, 'optionalCall', _58 => _58()]);
|
|
3056
3287
|
return;
|
|
3057
3288
|
}
|
|
3058
3289
|
if (typeof child === "function" && child.length === 0) {
|
|
@@ -3401,5 +3632,7 @@ function eventNameFromProp(key) {
|
|
|
3401
3632
|
|
|
3402
3633
|
|
|
3403
3634
|
|
|
3404
|
-
|
|
3405
|
-
|
|
3635
|
+
|
|
3636
|
+
|
|
3637
|
+
exports.BooleanAttributes = BooleanAttributes; exports.Properties = Properties; exports.ChildProperties = ChildProperties; exports.Aliases = Aliases; exports.getPropAlias = getPropAlias; exports.DelegatedEvents = DelegatedEvents; exports.SVGElements = SVGElements; exports.SVGNamespace = SVGNamespace; exports.UnitlessStyles = UnitlessStyles; exports.getDevtoolsHook = getDevtoolsHook; exports.setCycleProtectionOptions = setCycleProtectionOptions; exports.createRootContext = createRootContext; exports.pushRoot = pushRoot; exports.getCurrentRoot = getCurrentRoot; exports.popRoot = popRoot; exports.onMount = onMount; exports.onDestroy = onDestroy; exports.onCleanup = onCleanup; exports.flushOnMount = flushOnMount; exports.registerRootCleanup = registerRootCleanup; exports.destroyRoot = destroyRoot; exports.createRoot = createRoot; exports.registerErrorHandler = registerErrorHandler; exports.registerSuspenseHandler = registerSuspenseHandler; exports.handleError = handleError; exports.createMemo = createMemo; exports.__fictUseContext = __fictUseContext; exports.__fictPushContext = __fictPushContext; exports.__fictPopContext = __fictPopContext; exports.__fictResetContext = __fictResetContext; exports.__fictUseSignal = __fictUseSignal; exports.__fictUseMemo = __fictUseMemo; exports.__fictUseEffect = __fictUseEffect; exports.__fictRender = __fictRender; exports.flush = flush; exports.signal = signal; exports.effectScope = effectScope; exports.batch = batch; exports.setActiveSub = setActiveSub; exports.__resetReactiveState = __resetReactiveState; exports.untrack = untrack; exports.createSelector = createSelector; exports.createEffect = createEffect; exports.createRenderEffect = createRenderEffect; exports.Fragment = Fragment; exports.toNodeArray = toNodeArray; exports.insertNodesBefore = insertNodesBefore; exports.removeNodes = removeNodes; exports.startTransition = startTransition; exports.useTransition = useTransition; exports.useDeferredValue = useDeferredValue; exports.batch2 = batch2; exports.untrack2 = untrack2; exports.isReactive = isReactive; exports.unwrap = unwrap; exports.callEventHandler = callEventHandler; exports.createTextBinding = createTextBinding; exports.bindText = bindText; exports.createAttributeBinding = createAttributeBinding; exports.bindAttribute = bindAttribute; exports.bindProperty = bindProperty; exports.createStyleBinding = createStyleBinding; exports.bindStyle = bindStyle; exports.createClassBinding = createClassBinding; exports.bindClass = bindClass; exports.classList = classList; exports.insert = insert; exports.createChildBinding = createChildBinding; exports.delegateEvents = delegateEvents; exports.clearDelegatedEvents = clearDelegatedEvents; exports.addEventListener = addEventListener; exports.bindEvent = bindEvent; exports.bindRef = bindRef; exports.spread = spread; exports.assign = assign; exports.createConditional = createConditional; exports.createShow = createShow; exports.createPortal = createPortal; exports.__fictProp = __fictProp; exports.createPropsProxy = createPropsProxy; exports.__fictPropsRest = __fictPropsRest; exports.mergeProps = mergeProps; exports.keyed = keyed; exports.prop = prop; exports.render = render; exports.createElement = createElement; exports.template = template;
|
|
3638
|
+
//# sourceMappingURL=chunk-ID3WBWNO.cjs.map
|