@fictjs/runtime 0.5.0 → 0.5.1
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 +9 -9
- package/dist/advanced.js +4 -4
- package/dist/{chunk-GHUV2FLD.cjs → chunk-4ZPZM5IG.cjs} +8 -8
- package/dist/{chunk-GHUV2FLD.cjs.map → chunk-4ZPZM5IG.cjs.map} +1 -1
- package/dist/{chunk-KKKYW54Z.js → chunk-5OYBRKE4.js} +3 -3
- package/dist/{chunk-6SOPF5LZ.cjs → chunk-6RCEIWZL.cjs} +36 -19
- package/dist/chunk-6RCEIWZL.cjs.map +1 -0
- package/dist/{chunk-FKDMDAUR.js → chunk-7BO6P2KP.js} +36 -19
- package/dist/chunk-7BO6P2KP.js.map +1 -0
- package/dist/{chunk-5AA7HP4S.js → chunk-AR6NSCZM.js} +3 -3
- package/dist/{chunk-KYLNC4CD.cjs → chunk-LFMXNQZC.cjs} +17 -17
- package/dist/{chunk-KYLNC4CD.cjs.map → chunk-LFMXNQZC.cjs.map} +1 -1
- package/dist/{chunk-BQG7VEBY.js → chunk-RY5CY4CI.js} +2 -2
- package/dist/{chunk-TKWN42TA.cjs → chunk-WJHXPF7M.cjs} +156 -156
- package/dist/{chunk-TKWN42TA.cjs.map → chunk-WJHXPF7M.cjs.map} +1 -1
- package/dist/index.cjs +39 -39
- package/dist/index.dev.js +33 -18
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/internal.cjs +54 -42
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +15 -3
- package/dist/internal.js.map +1 -1
- package/dist/loader.cjs +8 -8
- package/dist/loader.js +1 -1
- package/package.json +1 -1
- package/src/cycle-guard.ts +1 -1
- package/src/list-helpers.ts +19 -4
- package/src/signal.ts +47 -22
- package/dist/chunk-6SOPF5LZ.cjs.map +0 -1
- package/dist/chunk-FKDMDAUR.js.map +0 -1
- /package/dist/{chunk-KKKYW54Z.js.map → chunk-5OYBRKE4.js.map} +0 -0
- /package/dist/{chunk-5AA7HP4S.js.map → chunk-AR6NSCZM.js.map} +0 -0
- /package/dist/{chunk-BQG7VEBY.js.map → chunk-RY5CY4CI.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkLFMXNQZCcjs = require('./chunk-LFMXNQZC.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -19,7 +19,7 @@ var _chunkKYLNC4CDcjs = require('./chunk-KYLNC4CD.cjs');
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _chunkWJHXPF7Mcjs = require('./chunk-WJHXPF7M.cjs');
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
@@ -37,7 +37,7 @@ var _chunkTKWN42TAcjs = require('./chunk-TKWN42TA.cjs');
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
var
|
|
40
|
+
var _chunk6RCEIWZLcjs = require('./chunk-6RCEIWZL.cjs');
|
|
41
41
|
|
|
42
42
|
// src/ref.ts
|
|
43
43
|
function createRef() {
|
|
@@ -49,7 +49,7 @@ function ErrorBoundary(props) {
|
|
|
49
49
|
const fragment = document.createDocumentFragment();
|
|
50
50
|
const marker = document.createComment("fict:error-boundary");
|
|
51
51
|
fragment.appendChild(marker);
|
|
52
|
-
const hostRoot =
|
|
52
|
+
const hostRoot = _chunk6RCEIWZLcjs.getCurrentRoot.call(void 0, );
|
|
53
53
|
let cleanup;
|
|
54
54
|
let activeNodes = [];
|
|
55
55
|
let renderingFallback = false;
|
|
@@ -67,25 +67,25 @@ function ErrorBoundary(props) {
|
|
|
67
67
|
cleanup = void 0;
|
|
68
68
|
}
|
|
69
69
|
if (activeNodes.length) {
|
|
70
|
-
|
|
70
|
+
_chunkWJHXPF7Mcjs.removeNodes.call(void 0, activeNodes);
|
|
71
71
|
activeNodes = [];
|
|
72
72
|
}
|
|
73
73
|
if (value == null || value === false) {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
-
const root =
|
|
77
|
-
const prev =
|
|
76
|
+
const root = _chunk6RCEIWZLcjs.createRootContext.call(void 0, hostRoot);
|
|
77
|
+
const prev = _chunk6RCEIWZLcjs.pushRoot.call(void 0, root);
|
|
78
78
|
let nodes = [];
|
|
79
79
|
try {
|
|
80
|
-
const output =
|
|
81
|
-
nodes =
|
|
80
|
+
const output = _chunkWJHXPF7Mcjs.createElement.call(void 0, value);
|
|
81
|
+
nodes = _chunkWJHXPF7Mcjs.toNodeArray.call(void 0, output);
|
|
82
82
|
const parentNode = marker.parentNode;
|
|
83
83
|
if (parentNode) {
|
|
84
|
-
|
|
84
|
+
_chunkWJHXPF7Mcjs.insertNodesBefore.call(void 0, parentNode, nodes, marker);
|
|
85
85
|
}
|
|
86
86
|
} catch (err) {
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
_chunk6RCEIWZLcjs.popRoot.call(void 0, prev);
|
|
88
|
+
_chunk6RCEIWZLcjs.destroyRoot.call(void 0, root);
|
|
89
89
|
if (renderingFallback) {
|
|
90
90
|
throw err;
|
|
91
91
|
}
|
|
@@ -100,11 +100,11 @@ function ErrorBoundary(props) {
|
|
|
100
100
|
}
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
_chunk6RCEIWZLcjs.popRoot.call(void 0, prev);
|
|
104
|
+
_chunk6RCEIWZLcjs.flushOnMount.call(void 0, root);
|
|
105
105
|
cleanup = () => {
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
_chunk6RCEIWZLcjs.destroyRoot.call(void 0, root);
|
|
107
|
+
_chunkWJHXPF7Mcjs.removeNodes.call(void 0, nodes);
|
|
108
108
|
};
|
|
109
109
|
activeNodes = nodes;
|
|
110
110
|
};
|
|
@@ -113,7 +113,7 @@ function ErrorBoundary(props) {
|
|
|
113
113
|
renderValue(toView(null));
|
|
114
114
|
};
|
|
115
115
|
renderValue(_nullishCoalesce(props.children, () => ( null)));
|
|
116
|
-
|
|
116
|
+
_chunk6RCEIWZLcjs.registerErrorHandler.call(void 0, (err) => {
|
|
117
117
|
renderValue(toView(err));
|
|
118
118
|
_optionalChain([props, 'access', _5 => _5.onError, 'optionalCall', _6 => _6(err)]);
|
|
119
119
|
return true;
|
|
@@ -122,7 +122,7 @@ function ErrorBoundary(props) {
|
|
|
122
122
|
const isGetter = typeof props.resetKeys === "function" && props.resetKeys.length === 0;
|
|
123
123
|
const getter = isGetter ? props.resetKeys : void 0;
|
|
124
124
|
let prev = isGetter ? getter() : props.resetKeys;
|
|
125
|
-
|
|
125
|
+
_chunk6RCEIWZLcjs.createEffect.call(void 0, () => {
|
|
126
126
|
const next = getter ? getter() : props.resetKeys;
|
|
127
127
|
if (prev !== next) {
|
|
128
128
|
prev = next;
|
|
@@ -151,10 +151,10 @@ function createSuspenseToken() {
|
|
|
151
151
|
}
|
|
152
152
|
var isThenable = (value) => typeof value === "object" && value !== null && typeof value.then === "function";
|
|
153
153
|
function Suspense(props) {
|
|
154
|
-
const pending =
|
|
154
|
+
const pending = _chunk6RCEIWZLcjs.signal.call(void 0, 0);
|
|
155
155
|
let resolvedOnce = false;
|
|
156
156
|
let epoch = 0;
|
|
157
|
-
const hostRoot =
|
|
157
|
+
const hostRoot = _chunk6RCEIWZLcjs.getCurrentRoot.call(void 0, );
|
|
158
158
|
const toFallback = (err) => typeof props.fallback === "function" ? props.fallback(err) : props.fallback;
|
|
159
159
|
const renderView = (view) => {
|
|
160
160
|
if (cleanup) {
|
|
@@ -162,41 +162,41 @@ function Suspense(props) {
|
|
|
162
162
|
cleanup = void 0;
|
|
163
163
|
}
|
|
164
164
|
if (activeNodes.length) {
|
|
165
|
-
|
|
165
|
+
_chunkWJHXPF7Mcjs.removeNodes.call(void 0, activeNodes);
|
|
166
166
|
activeNodes = [];
|
|
167
167
|
}
|
|
168
168
|
if (view == null || view === false) {
|
|
169
169
|
return;
|
|
170
170
|
}
|
|
171
|
-
const root =
|
|
172
|
-
const prev =
|
|
171
|
+
const root = _chunk6RCEIWZLcjs.createRootContext.call(void 0, hostRoot);
|
|
172
|
+
const prev = _chunk6RCEIWZLcjs.pushRoot.call(void 0, root);
|
|
173
173
|
let nodes = [];
|
|
174
174
|
try {
|
|
175
|
-
const output =
|
|
176
|
-
nodes =
|
|
175
|
+
const output = _chunkWJHXPF7Mcjs.createElement.call(void 0, view);
|
|
176
|
+
nodes = _chunkWJHXPF7Mcjs.toNodeArray.call(void 0, output);
|
|
177
177
|
const suspendedAttempt = root.suspended || nodes.length > 0 && nodes.every((node) => node instanceof Comment && node.data === "fict:suspend");
|
|
178
178
|
if (suspendedAttempt) {
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
_chunk6RCEIWZLcjs.popRoot.call(void 0, prev);
|
|
180
|
+
_chunk6RCEIWZLcjs.destroyRoot.call(void 0, root);
|
|
181
181
|
return;
|
|
182
182
|
}
|
|
183
183
|
const parentNode = marker.parentNode;
|
|
184
184
|
if (parentNode) {
|
|
185
|
-
|
|
185
|
+
_chunkWJHXPF7Mcjs.insertNodesBefore.call(void 0, parentNode, nodes, marker);
|
|
186
186
|
}
|
|
187
187
|
} catch (err) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (!
|
|
188
|
+
_chunk6RCEIWZLcjs.popRoot.call(void 0, prev);
|
|
189
|
+
_chunk6RCEIWZLcjs.destroyRoot.call(void 0, root);
|
|
190
|
+
if (!_chunk6RCEIWZLcjs.handleError.call(void 0, err, { source: "render" }, hostRoot)) {
|
|
191
191
|
throw err;
|
|
192
192
|
}
|
|
193
193
|
return;
|
|
194
194
|
}
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
_chunk6RCEIWZLcjs.popRoot.call(void 0, prev);
|
|
196
|
+
_chunk6RCEIWZLcjs.flushOnMount.call(void 0, root);
|
|
197
197
|
cleanup = () => {
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
_chunk6RCEIWZLcjs.destroyRoot.call(void 0, root);
|
|
199
|
+
_chunkWJHXPF7Mcjs.removeNodes.call(void 0, nodes);
|
|
200
200
|
};
|
|
201
201
|
activeNodes = nodes;
|
|
202
202
|
};
|
|
@@ -211,7 +211,7 @@ function Suspense(props) {
|
|
|
211
211
|
_optionalChain([props, 'access', _7 => _7.onResolve, 'optionalCall', _8 => _8()]);
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
|
-
|
|
214
|
+
_chunk6RCEIWZLcjs.registerSuspenseHandler.call(void 0, (token) => {
|
|
215
215
|
const tokenEpoch = epoch;
|
|
216
216
|
pending(pending() + 1);
|
|
217
217
|
renderView(toFallback());
|
|
@@ -236,7 +236,7 @@ function Suspense(props) {
|
|
|
236
236
|
const newPending = Math.max(0, pending() - 1);
|
|
237
237
|
pending(newPending);
|
|
238
238
|
_optionalChain([props, 'access', _9 => _9.onReject, 'optionalCall', _10 => _10(err)]);
|
|
239
|
-
if (!
|
|
239
|
+
if (!_chunk6RCEIWZLcjs.handleError.call(void 0, err, { source: "render" }, hostRoot)) {
|
|
240
240
|
throw err;
|
|
241
241
|
}
|
|
242
242
|
}
|
|
@@ -250,7 +250,7 @@ function Suspense(props) {
|
|
|
250
250
|
const isGetter = typeof props.resetKeys === "function" && props.resetKeys.length === 0;
|
|
251
251
|
const getter = isGetter ? props.resetKeys : void 0;
|
|
252
252
|
let prev = isGetter ? getter() : props.resetKeys;
|
|
253
|
-
|
|
253
|
+
_chunk6RCEIWZLcjs.createEffect.call(void 0, () => {
|
|
254
254
|
const next = getter ? getter() : props.resetKeys;
|
|
255
255
|
if (prev !== next) {
|
|
256
256
|
prev = next;
|
|
@@ -288,5 +288,5 @@ function Suspense(props) {
|
|
|
288
288
|
|
|
289
289
|
|
|
290
290
|
|
|
291
|
-
exports.ErrorBoundary = ErrorBoundary; exports.Fragment =
|
|
291
|
+
exports.ErrorBoundary = ErrorBoundary; exports.Fragment = _chunkWJHXPF7Mcjs.Fragment; exports.Suspense = Suspense; exports.batch = _chunkWJHXPF7Mcjs.batch; exports.createContext = _chunkLFMXNQZCcjs.createContext; exports.createEffect = _chunk6RCEIWZLcjs.createEffect; exports.createElement = _chunkWJHXPF7Mcjs.createElement; exports.createMemo = _chunk6RCEIWZLcjs.createMemo; exports.createPortal = _chunkWJHXPF7Mcjs.createPortal; exports.createRef = createRef; exports.createRoot = _chunk6RCEIWZLcjs.createRoot; exports.createSuspenseToken = createSuspenseToken; exports.hasContext = _chunkLFMXNQZCcjs.hasContext; exports.keyed = _chunkWJHXPF7Mcjs.keyed; exports.mergeProps = _chunkWJHXPF7Mcjs.mergeProps; exports.onCleanup = _chunk6RCEIWZLcjs.onCleanup; exports.onDestroy = _chunk6RCEIWZLcjs.onDestroy; exports.onMount = _chunk6RCEIWZLcjs.onMount; exports.prop = _chunkWJHXPF7Mcjs.prop; exports.render = _chunkWJHXPF7Mcjs.render; exports.startTransition = _chunkWJHXPF7Mcjs.startTransition; exports.untrack = _chunkWJHXPF7Mcjs.untrack; exports.useContext = _chunkLFMXNQZCcjs.useContext; exports.useDeferredValue = _chunkWJHXPF7Mcjs.useDeferredValue; exports.useTransition = _chunkWJHXPF7Mcjs.useTransition;
|
|
292
292
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.dev.js
CHANGED
|
@@ -22,7 +22,7 @@ var enterRootGuard = () => true;
|
|
|
22
22
|
var exitRootGuard = () => {
|
|
23
23
|
};
|
|
24
24
|
var defaultOptions = {
|
|
25
|
-
enabled:
|
|
25
|
+
enabled: isDev,
|
|
26
26
|
maxFlushCyclesPerMicrotask: 1e4,
|
|
27
27
|
maxEffectRunsPerFlush: 2e4,
|
|
28
28
|
windowSize: 5,
|
|
@@ -526,6 +526,8 @@ var cycle = 0;
|
|
|
526
526
|
var batchDepth = 0;
|
|
527
527
|
var activeSub;
|
|
528
528
|
var flushScheduled = false;
|
|
529
|
+
var currentFlushId = 0;
|
|
530
|
+
var activeCleanupFlushId = 0;
|
|
529
531
|
var highPriorityQueue = [];
|
|
530
532
|
var lowPriorityQueue = [];
|
|
531
533
|
var isInTransition = false;
|
|
@@ -771,6 +773,8 @@ function updateSignal(s) {
|
|
|
771
773
|
const current = s.currentValue;
|
|
772
774
|
const pending = s.pendingValue;
|
|
773
775
|
if (valuesDiffer(s, current, pending)) {
|
|
776
|
+
s.prevValue = current;
|
|
777
|
+
s.prevFlushId = currentFlushId;
|
|
774
778
|
s.currentValue = pending;
|
|
775
779
|
return true;
|
|
776
780
|
}
|
|
@@ -789,6 +793,8 @@ function updateComputed(c) {
|
|
|
789
793
|
c.flags &= ~Running;
|
|
790
794
|
purgeDeps(c);
|
|
791
795
|
if (valuesDiffer(c, oldValue, newValue)) {
|
|
796
|
+
c.prevValue = oldValue;
|
|
797
|
+
c.prevFlushId = currentFlushId;
|
|
792
798
|
c.value = newValue;
|
|
793
799
|
if (isDev4) updateComputedDevtools(c, newValue);
|
|
794
800
|
return true;
|
|
@@ -802,15 +808,19 @@ function updateComputed(c) {
|
|
|
802
808
|
}
|
|
803
809
|
function runEffect(e) {
|
|
804
810
|
const flags = e.flags;
|
|
805
|
-
|
|
806
|
-
if (e.runCleanup)
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
811
|
+
const runCleanup = () => {
|
|
812
|
+
if (!e.runCleanup) return;
|
|
813
|
+
inCleanup = true;
|
|
814
|
+
activeCleanupFlushId = currentFlushId;
|
|
815
|
+
try {
|
|
816
|
+
e.runCleanup();
|
|
817
|
+
} finally {
|
|
818
|
+
activeCleanupFlushId = 0;
|
|
819
|
+
inCleanup = false;
|
|
813
820
|
}
|
|
821
|
+
};
|
|
822
|
+
if (flags & Dirty) {
|
|
823
|
+
runCleanup();
|
|
814
824
|
++cycle;
|
|
815
825
|
if (isDev4) effectRunDevtools(e);
|
|
816
826
|
e.depsTail = void 0;
|
|
@@ -828,14 +838,6 @@ function runEffect(e) {
|
|
|
828
838
|
throw err;
|
|
829
839
|
}
|
|
830
840
|
} else if (flags & Pending && e.deps) {
|
|
831
|
-
if (e.runCleanup) {
|
|
832
|
-
inCleanup = true;
|
|
833
|
-
try {
|
|
834
|
-
e.runCleanup();
|
|
835
|
-
} finally {
|
|
836
|
-
inCleanup = false;
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
841
|
let isDirty = false;
|
|
840
842
|
try {
|
|
841
843
|
isDirty = checkDirty(e.deps, e);
|
|
@@ -855,6 +857,7 @@ function runEffect(e) {
|
|
|
855
857
|
throw err;
|
|
856
858
|
}
|
|
857
859
|
if (isDirty) {
|
|
860
|
+
runCleanup();
|
|
858
861
|
++cycle;
|
|
859
862
|
if (isDev4) effectRunDevtools(e);
|
|
860
863
|
e.depsTail = void 0;
|
|
@@ -900,6 +903,7 @@ function flush() {
|
|
|
900
903
|
endFlushGuard();
|
|
901
904
|
return;
|
|
902
905
|
}
|
|
906
|
+
currentFlushId++;
|
|
903
907
|
flushScheduled = false;
|
|
904
908
|
let highIndex = 0;
|
|
905
909
|
while (highIndex < highPriorityQueue.length) {
|
|
@@ -1004,6 +1008,12 @@ function signalOper(value) {
|
|
|
1004
1008
|
if (subs !== void 0) shallowPropagate(subs);
|
|
1005
1009
|
}
|
|
1006
1010
|
}
|
|
1011
|
+
if (inCleanup) {
|
|
1012
|
+
if (this.prevFlushId === activeCleanupFlushId) {
|
|
1013
|
+
return this.prevValue;
|
|
1014
|
+
}
|
|
1015
|
+
return this.currentValue;
|
|
1016
|
+
}
|
|
1007
1017
|
let sub = activeSub;
|
|
1008
1018
|
while (sub !== void 0) {
|
|
1009
1019
|
if (sub.flags & 3) {
|
|
@@ -1037,7 +1047,12 @@ function computed(getter, options2) {
|
|
|
1037
1047
|
return bound;
|
|
1038
1048
|
}
|
|
1039
1049
|
function computedOper() {
|
|
1040
|
-
if (inCleanup)
|
|
1050
|
+
if (inCleanup) {
|
|
1051
|
+
if (this.prevFlushId === activeCleanupFlushId) {
|
|
1052
|
+
return this.prevValue;
|
|
1053
|
+
}
|
|
1054
|
+
return this.value;
|
|
1055
|
+
}
|
|
1041
1056
|
const flags = this.flags;
|
|
1042
1057
|
if (flags & Dirty) {
|
|
1043
1058
|
if (updateComputed(this)) {
|