@fictjs/runtime 0.0.13 → 0.0.14
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 +79 -0
- package/dist/advanced.cjs.map +1 -0
- package/dist/advanced.d.cts +50 -0
- package/dist/advanced.d.ts +50 -0
- package/dist/advanced.js +79 -0
- package/dist/advanced.js.map +1 -0
- package/dist/chunk-624QY53A.cjs +45 -0
- package/dist/chunk-624QY53A.cjs.map +1 -0
- package/dist/chunk-F3AIYQB7.js +45 -0
- package/dist/chunk-F3AIYQB7.js.map +1 -0
- package/dist/chunk-GJTYOFMO.cjs +109 -0
- package/dist/chunk-GJTYOFMO.cjs.map +1 -0
- package/dist/chunk-IUZXKAAY.js +109 -0
- package/dist/chunk-IUZXKAAY.js.map +1 -0
- package/dist/chunk-PMF6MWEV.cjs +3301 -0
- package/dist/chunk-PMF6MWEV.cjs.map +1 -0
- package/dist/chunk-RY4WDS6R.js +3301 -0
- package/dist/chunk-RY4WDS6R.js.map +1 -0
- package/dist/context-B7UYnfzM.d.ts +153 -0
- package/dist/context-UXySaqI_.d.cts +153 -0
- package/dist/effect-Auji1rz9.d.cts +350 -0
- package/dist/effect-Auji1rz9.d.ts +350 -0
- package/dist/index.cjs +98 -3558
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1358
- package/dist/index.d.ts +5 -1358
- package/dist/index.dev.js +240 -1698
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +63 -3435
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +901 -0
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +158 -0
- package/dist/internal.d.ts +158 -0
- package/dist/internal.js +901 -0
- package/dist/internal.js.map +1 -0
- package/dist/{jsx-dev-runtime.d.ts → props-CrOMYbLv.d.cts} +107 -18
- package/dist/{jsx-dev-runtime.d.cts → props-ES0Ag_Wd.d.ts} +107 -18
- package/dist/scope-DKYzWfTn.d.cts +55 -0
- package/dist/scope-S6eAzBJZ.d.ts +55 -0
- package/package.json +11 -1
- package/src/advanced.ts +101 -0
- package/src/constants.ts +3 -26
- package/src/context.ts +300 -0
- package/src/delegated-events.ts +24 -0
- package/src/index.ts +41 -112
- package/src/internal.ts +130 -0
- package/src/props.ts +48 -46
- package/src/store.ts +47 -7
- package/src/versioned-signal.ts +3 -3
- package/dist/jsx-runtime.d.cts +0 -671
- package/dist/jsx-runtime.d.ts +0 -671
package/dist/index.dev.js
CHANGED
|
@@ -573,16 +573,16 @@ function shallowPropagate(firstLink) {
|
|
|
573
573
|
function update(node) {
|
|
574
574
|
return "getter" in node && node.getter !== void 0 ? updateComputed(node) : updateSignal(node);
|
|
575
575
|
}
|
|
576
|
-
function notify(
|
|
577
|
-
|
|
576
|
+
function notify(effect) {
|
|
577
|
+
effect.flags &= ~Watching;
|
|
578
578
|
const effects = [];
|
|
579
579
|
for (; ; ) {
|
|
580
|
-
effects.push(
|
|
581
|
-
const nextLink =
|
|
580
|
+
effects.push(effect);
|
|
581
|
+
const nextLink = effect.subs;
|
|
582
582
|
if (nextLink === void 0) break;
|
|
583
|
-
|
|
584
|
-
if (
|
|
585
|
-
|
|
583
|
+
effect = nextLink.sub;
|
|
584
|
+
if (effect === void 0 || !(effect.flags & Watching)) break;
|
|
585
|
+
effect.flags &= ~Watching;
|
|
586
586
|
}
|
|
587
587
|
const targetQueue = isInTransition ? lowPriorityQueue : highPriorityQueue;
|
|
588
588
|
for (let i = effects.length - 1; i >= 0; i--) {
|
|
@@ -851,31 +851,6 @@ function computedOper() {
|
|
|
851
851
|
if (activeSub !== void 0) link(this, activeSub, cycle);
|
|
852
852
|
return this.value;
|
|
853
853
|
}
|
|
854
|
-
function effect(fn) {
|
|
855
|
-
const e = {
|
|
856
|
-
fn,
|
|
857
|
-
subs: void 0,
|
|
858
|
-
subsTail: void 0,
|
|
859
|
-
deps: void 0,
|
|
860
|
-
depsTail: void 0,
|
|
861
|
-
flags: WatchingRunning,
|
|
862
|
-
__id: void 0
|
|
863
|
-
};
|
|
864
|
-
registerEffectDevtools(e);
|
|
865
|
-
const prevSub = activeSub;
|
|
866
|
-
if (prevSub !== void 0) link(e, prevSub, 0);
|
|
867
|
-
activeSub = e;
|
|
868
|
-
try {
|
|
869
|
-
effectRunDevtools(e);
|
|
870
|
-
fn();
|
|
871
|
-
} finally {
|
|
872
|
-
activeSub = prevSub;
|
|
873
|
-
e.flags &= ~Running;
|
|
874
|
-
}
|
|
875
|
-
const disposer = effectOper.bind(e);
|
|
876
|
-
disposer[EFFECT_MARKER] = true;
|
|
877
|
-
return disposer;
|
|
878
|
-
}
|
|
879
854
|
function effectWithCleanup(fn, cleanupRunner) {
|
|
880
855
|
const e = {
|
|
881
856
|
fn,
|
|
@@ -905,23 +880,6 @@ function effectWithCleanup(fn, cleanupRunner) {
|
|
|
905
880
|
function effectOper() {
|
|
906
881
|
disposeNode(this);
|
|
907
882
|
}
|
|
908
|
-
function effectScope(fn) {
|
|
909
|
-
const e = { deps: void 0, depsTail: void 0, subs: void 0, subsTail: void 0, flags: 0 };
|
|
910
|
-
const prevSub = activeSub;
|
|
911
|
-
if (prevSub !== void 0) link(e, prevSub, 0);
|
|
912
|
-
activeSub = e;
|
|
913
|
-
try {
|
|
914
|
-
fn();
|
|
915
|
-
} finally {
|
|
916
|
-
activeSub = prevSub;
|
|
917
|
-
}
|
|
918
|
-
const disposer = effectScopeOper.bind(e);
|
|
919
|
-
disposer[EFFECT_SCOPE_MARKER] = true;
|
|
920
|
-
return disposer;
|
|
921
|
-
}
|
|
922
|
-
function effectScopeOper() {
|
|
923
|
-
disposeNode(this);
|
|
924
|
-
}
|
|
925
883
|
function batch(fn) {
|
|
926
884
|
++batchDepth;
|
|
927
885
|
let result;
|
|
@@ -966,7 +924,6 @@ function setTransitionContext(value) {
|
|
|
966
924
|
isInTransition = value;
|
|
967
925
|
return prev;
|
|
968
926
|
}
|
|
969
|
-
var $state = signal;
|
|
970
927
|
var registerSignalDevtools = () => void 0;
|
|
971
928
|
var updateSignalDevtools = () => {
|
|
972
929
|
};
|
|
@@ -1005,163 +962,11 @@ if (isDev3) {
|
|
|
1005
962
|
if (id) hook.effectRun(id);
|
|
1006
963
|
};
|
|
1007
964
|
}
|
|
1008
|
-
function createSelector(source, equalityFn = (a, b) => a === b) {
|
|
1009
|
-
let current = source();
|
|
1010
|
-
const observers = /* @__PURE__ */ new Map();
|
|
1011
|
-
const dispose = effect(() => {
|
|
1012
|
-
const next = source();
|
|
1013
|
-
if (equalityFn(current, next)) return;
|
|
1014
|
-
const prevSig = observers.get(current);
|
|
1015
|
-
if (prevSig) prevSig(false);
|
|
1016
|
-
const nextSig = observers.get(next);
|
|
1017
|
-
if (nextSig) nextSig(true);
|
|
1018
|
-
current = next;
|
|
1019
|
-
});
|
|
1020
|
-
registerRootCleanup(() => {
|
|
1021
|
-
dispose();
|
|
1022
|
-
observers.clear();
|
|
1023
|
-
});
|
|
1024
|
-
return (key) => {
|
|
1025
|
-
let sig = observers.get(key);
|
|
1026
|
-
if (!sig) {
|
|
1027
|
-
sig = signal(equalityFn(key, current));
|
|
1028
|
-
observers.set(key, sig);
|
|
1029
|
-
registerRootCleanup(() => observers.delete(key));
|
|
1030
|
-
}
|
|
1031
|
-
return sig();
|
|
1032
|
-
};
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
// src/store.ts
|
|
1036
|
-
var PROXY = Symbol("fict:store-proxy");
|
|
1037
|
-
var TARGET = Symbol("fict:store-target");
|
|
1038
|
-
var ITERATE_KEY = Symbol("fict:iterate");
|
|
1039
|
-
function createStore(initialValue) {
|
|
1040
|
-
const unwrapped = unwrap(initialValue);
|
|
1041
|
-
const wrapped = wrap(unwrapped);
|
|
1042
|
-
function setStore(fn) {
|
|
1043
|
-
batch(() => {
|
|
1044
|
-
const result = fn(wrapped);
|
|
1045
|
-
if (result !== void 0) {
|
|
1046
|
-
reconcile(wrapped, result);
|
|
1047
|
-
}
|
|
1048
|
-
});
|
|
1049
|
-
}
|
|
1050
|
-
return [wrapped, setStore];
|
|
1051
|
-
}
|
|
1052
|
-
var proxyCache = /* @__PURE__ */ new WeakMap();
|
|
1053
|
-
var signalCache = /* @__PURE__ */ new WeakMap();
|
|
1054
|
-
function wrap(value) {
|
|
1055
|
-
if (value === null || typeof value !== "object") return value;
|
|
1056
|
-
if (value[PROXY]) return value;
|
|
1057
|
-
if (proxyCache.has(value)) return proxyCache.get(value);
|
|
1058
|
-
const handler = {
|
|
1059
|
-
get(target, prop, receiver) {
|
|
1060
|
-
if (prop === PROXY) return true;
|
|
1061
|
-
if (prop === TARGET) return target;
|
|
1062
|
-
const value2 = Reflect.get(target, prop, receiver);
|
|
1063
|
-
track(target, prop);
|
|
1064
|
-
return wrap(value2);
|
|
1065
|
-
},
|
|
1066
|
-
has(target, prop) {
|
|
1067
|
-
const result = Reflect.has(target, prop);
|
|
1068
|
-
track(target, prop);
|
|
1069
|
-
return result;
|
|
1070
|
-
},
|
|
1071
|
-
ownKeys(target) {
|
|
1072
|
-
track(target, ITERATE_KEY);
|
|
1073
|
-
return Reflect.ownKeys(target);
|
|
1074
|
-
},
|
|
1075
|
-
getOwnPropertyDescriptor(target, prop) {
|
|
1076
|
-
track(target, prop);
|
|
1077
|
-
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
1078
|
-
},
|
|
1079
|
-
set(target, prop, value2, receiver) {
|
|
1080
|
-
if (prop === PROXY || prop === TARGET) return false;
|
|
1081
|
-
const hadKey = Object.prototype.hasOwnProperty.call(target, prop);
|
|
1082
|
-
const oldValue = Reflect.get(target, prop, receiver);
|
|
1083
|
-
if (oldValue === value2) return true;
|
|
1084
|
-
const result = Reflect.set(target, prop, value2, receiver);
|
|
1085
|
-
if (result) {
|
|
1086
|
-
trigger(target, prop);
|
|
1087
|
-
if (!hadKey) {
|
|
1088
|
-
trigger(target, ITERATE_KEY);
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
return result;
|
|
1092
|
-
},
|
|
1093
|
-
deleteProperty(target, prop) {
|
|
1094
|
-
const hadKey = Object.prototype.hasOwnProperty.call(target, prop);
|
|
1095
|
-
const result = Reflect.deleteProperty(target, prop);
|
|
1096
|
-
if (result) {
|
|
1097
|
-
trigger(target, prop);
|
|
1098
|
-
if (hadKey) {
|
|
1099
|
-
trigger(target, ITERATE_KEY);
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
return result;
|
|
1103
|
-
}
|
|
1104
|
-
};
|
|
1105
|
-
const proxy = new Proxy(value, handler);
|
|
1106
|
-
proxyCache.set(value, proxy);
|
|
1107
|
-
return proxy;
|
|
1108
|
-
}
|
|
1109
|
-
function unwrap(value) {
|
|
1110
|
-
if (value && typeof value === "object" && value[PROXY]) {
|
|
1111
|
-
return value[TARGET];
|
|
1112
|
-
}
|
|
1113
|
-
return value;
|
|
1114
|
-
}
|
|
1115
|
-
function track(target, prop) {
|
|
1116
|
-
let signals = signalCache.get(target);
|
|
1117
|
-
if (!signals) {
|
|
1118
|
-
signals = /* @__PURE__ */ new Map();
|
|
1119
|
-
signalCache.set(target, signals);
|
|
1120
|
-
}
|
|
1121
|
-
let s = signals.get(prop);
|
|
1122
|
-
if (!s) {
|
|
1123
|
-
const initial = prop === ITERATE_KEY ? Reflect.ownKeys(target).length : getLastValue(target, prop);
|
|
1124
|
-
s = signal(initial);
|
|
1125
|
-
signals.set(prop, s);
|
|
1126
|
-
}
|
|
1127
|
-
s();
|
|
1128
|
-
}
|
|
1129
|
-
function trigger(target, prop) {
|
|
1130
|
-
const signals = signalCache.get(target);
|
|
1131
|
-
if (signals) {
|
|
1132
|
-
const s = signals.get(prop);
|
|
1133
|
-
if (s) {
|
|
1134
|
-
if (prop === ITERATE_KEY) {
|
|
1135
|
-
s(Reflect.ownKeys(target).length);
|
|
1136
|
-
} else {
|
|
1137
|
-
s(getLastValue(target, prop));
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
function getLastValue(target, prop) {
|
|
1143
|
-
return target[prop];
|
|
1144
|
-
}
|
|
1145
|
-
function reconcile(target, value) {
|
|
1146
|
-
if (target === value) return;
|
|
1147
|
-
if (value === null || typeof value !== "object") return;
|
|
1148
|
-
const realTarget = unwrap(target);
|
|
1149
|
-
const realValue = unwrap(value);
|
|
1150
|
-
const keys = /* @__PURE__ */ new Set([...Object.keys(realTarget), ...Object.keys(realValue)]);
|
|
1151
|
-
for (const key of keys) {
|
|
1152
|
-
if (realValue[key] === void 0 && realTarget[key] !== void 0) {
|
|
1153
|
-
delete target[key];
|
|
1154
|
-
} else if (realTarget[key] !== realValue[key]) {
|
|
1155
|
-
target[key] = realValue[key];
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
965
|
|
|
1160
966
|
// src/memo.ts
|
|
1161
967
|
function createMemo(fn) {
|
|
1162
968
|
return computed(fn);
|
|
1163
969
|
}
|
|
1164
|
-
var $memo = createMemo;
|
|
1165
970
|
|
|
1166
971
|
// src/effect.ts
|
|
1167
972
|
function createEffect(fn) {
|
|
@@ -1196,7 +1001,6 @@ function createEffect(fn) {
|
|
|
1196
1001
|
registerRootCleanup(teardown);
|
|
1197
1002
|
return teardown;
|
|
1198
1003
|
}
|
|
1199
|
-
var $effect = createEffect;
|
|
1200
1004
|
function createRenderEffect(fn) {
|
|
1201
1005
|
let cleanup;
|
|
1202
1006
|
const rootForError = getCurrentRoot();
|
|
@@ -1232,6 +1036,86 @@ function createRenderEffect(fn) {
|
|
|
1232
1036
|
return teardown;
|
|
1233
1037
|
}
|
|
1234
1038
|
|
|
1039
|
+
// src/ref.ts
|
|
1040
|
+
function createRef() {
|
|
1041
|
+
return { current: null };
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
// src/transition.ts
|
|
1045
|
+
function startTransition(fn) {
|
|
1046
|
+
const prev = setTransitionContext(true);
|
|
1047
|
+
try {
|
|
1048
|
+
fn();
|
|
1049
|
+
} finally {
|
|
1050
|
+
setTransitionContext(prev);
|
|
1051
|
+
scheduleFlush();
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
function useTransition() {
|
|
1055
|
+
const pending = signal(false);
|
|
1056
|
+
const start = (fn) => {
|
|
1057
|
+
startTransition(() => {
|
|
1058
|
+
pending(true);
|
|
1059
|
+
try {
|
|
1060
|
+
fn();
|
|
1061
|
+
} finally {
|
|
1062
|
+
pending(false);
|
|
1063
|
+
}
|
|
1064
|
+
});
|
|
1065
|
+
};
|
|
1066
|
+
return [() => pending(), start];
|
|
1067
|
+
}
|
|
1068
|
+
function useDeferredValue(getValue) {
|
|
1069
|
+
const deferredValue = signal(getValue());
|
|
1070
|
+
createEffect(() => {
|
|
1071
|
+
const newValue = getValue();
|
|
1072
|
+
const currentDeferred = untrack(() => deferredValue());
|
|
1073
|
+
if (currentDeferred !== newValue) {
|
|
1074
|
+
startTransition(() => {
|
|
1075
|
+
deferredValue(newValue);
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
});
|
|
1079
|
+
return () => deferredValue();
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
// src/scheduler.ts
|
|
1083
|
+
function batch2(fn) {
|
|
1084
|
+
return batch(fn);
|
|
1085
|
+
}
|
|
1086
|
+
function untrack2(fn) {
|
|
1087
|
+
return untrack(fn);
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
// src/jsx.ts
|
|
1091
|
+
var Fragment = Symbol("Fragment");
|
|
1092
|
+
|
|
1093
|
+
// src/delegated-events.ts
|
|
1094
|
+
var DelegatedEventNames = [
|
|
1095
|
+
"beforeinput",
|
|
1096
|
+
"click",
|
|
1097
|
+
"dblclick",
|
|
1098
|
+
"contextmenu",
|
|
1099
|
+
"focusin",
|
|
1100
|
+
"focusout",
|
|
1101
|
+
"input",
|
|
1102
|
+
"keydown",
|
|
1103
|
+
"keyup",
|
|
1104
|
+
"mousedown",
|
|
1105
|
+
"mousemove",
|
|
1106
|
+
"mouseout",
|
|
1107
|
+
"mouseover",
|
|
1108
|
+
"mouseup",
|
|
1109
|
+
"pointerdown",
|
|
1110
|
+
"pointermove",
|
|
1111
|
+
"pointerout",
|
|
1112
|
+
"pointerover",
|
|
1113
|
+
"pointerup",
|
|
1114
|
+
"touchend",
|
|
1115
|
+
"touchmove",
|
|
1116
|
+
"touchstart"
|
|
1117
|
+
];
|
|
1118
|
+
|
|
1235
1119
|
// src/constants.ts
|
|
1236
1120
|
var isDev4 = true ? true : typeof process === "undefined" || process.env?.NODE_ENV !== "production";
|
|
1237
1121
|
var booleans = isDev4 ? [
|
|
@@ -1320,10 +1204,6 @@ var ChildProperties = /* @__PURE__ */ new Set([
|
|
|
1320
1204
|
"innerText",
|
|
1321
1205
|
"children"
|
|
1322
1206
|
]);
|
|
1323
|
-
var Aliases = {
|
|
1324
|
-
className: "class",
|
|
1325
|
-
htmlFor: "for"
|
|
1326
|
-
};
|
|
1327
1207
|
var PropAliases = isDev4 ? {
|
|
1328
1208
|
// Direct mapping
|
|
1329
1209
|
class: "className",
|
|
@@ -1412,39 +1292,16 @@ var PropAliases = isDev4 ? {
|
|
|
1412
1292
|
IMG: 1
|
|
1413
1293
|
}
|
|
1414
1294
|
} : {};
|
|
1415
|
-
function getPropAlias(
|
|
1295
|
+
function getPropAlias(prop2, tagName) {
|
|
1416
1296
|
if (!isDev4) return void 0;
|
|
1417
|
-
const a = PropAliases[
|
|
1297
|
+
const a = PropAliases[prop2];
|
|
1418
1298
|
if (typeof a === "object") {
|
|
1419
1299
|
return a[tagName] ? a["$"] : void 0;
|
|
1420
1300
|
}
|
|
1421
1301
|
return a;
|
|
1422
1302
|
}
|
|
1423
1303
|
var $$EVENTS = "_$FICT_DELEGATE";
|
|
1424
|
-
var delegatedEvents = isDev4 ? [
|
|
1425
|
-
"beforeinput",
|
|
1426
|
-
"click",
|
|
1427
|
-
"dblclick",
|
|
1428
|
-
"contextmenu",
|
|
1429
|
-
"focusin",
|
|
1430
|
-
"focusout",
|
|
1431
|
-
"input",
|
|
1432
|
-
"keydown",
|
|
1433
|
-
"keyup",
|
|
1434
|
-
"mousedown",
|
|
1435
|
-
"mousemove",
|
|
1436
|
-
"mouseout",
|
|
1437
|
-
"mouseover",
|
|
1438
|
-
"mouseup",
|
|
1439
|
-
"pointerdown",
|
|
1440
|
-
"pointermove",
|
|
1441
|
-
"pointerout",
|
|
1442
|
-
"pointerover",
|
|
1443
|
-
"pointerup",
|
|
1444
|
-
"touchend",
|
|
1445
|
-
"touchmove",
|
|
1446
|
-
"touchstart"
|
|
1447
|
-
] : [];
|
|
1304
|
+
var delegatedEvents = isDev4 ? DelegatedEventNames : [];
|
|
1448
1305
|
var DelegatedEvents = new Set(delegatedEvents);
|
|
1449
1306
|
var svgElements = isDev4 ? [
|
|
1450
1307
|
"altGlyph",
|
|
@@ -1609,9 +1466,6 @@ var unitlessList = isDev4 ? [
|
|
|
1609
1466
|
] : ["opacity", "zIndex"];
|
|
1610
1467
|
var UnitlessStyles = new Set(unitlessList);
|
|
1611
1468
|
|
|
1612
|
-
// src/jsx.ts
|
|
1613
|
-
var Fragment = Symbol("Fragment");
|
|
1614
|
-
|
|
1615
1469
|
// src/node-ops.ts
|
|
1616
1470
|
function toNodeArray(node) {
|
|
1617
1471
|
try {
|
|
@@ -1755,60 +1609,11 @@ function removeNodes(nodes) {
|
|
|
1755
1609
|
}
|
|
1756
1610
|
}
|
|
1757
1611
|
|
|
1758
|
-
// src/transition.ts
|
|
1759
|
-
function startTransition(fn) {
|
|
1760
|
-
const prev = setTransitionContext(true);
|
|
1761
|
-
try {
|
|
1762
|
-
fn();
|
|
1763
|
-
} finally {
|
|
1764
|
-
setTransitionContext(prev);
|
|
1765
|
-
scheduleFlush();
|
|
1766
|
-
}
|
|
1767
|
-
}
|
|
1768
|
-
function useTransition() {
|
|
1769
|
-
const pending = signal(false);
|
|
1770
|
-
const start = (fn) => {
|
|
1771
|
-
startTransition(() => {
|
|
1772
|
-
pending(true);
|
|
1773
|
-
try {
|
|
1774
|
-
fn();
|
|
1775
|
-
} finally {
|
|
1776
|
-
pending(false);
|
|
1777
|
-
}
|
|
1778
|
-
});
|
|
1779
|
-
};
|
|
1780
|
-
return [() => pending(), start];
|
|
1781
|
-
}
|
|
1782
|
-
function useDeferredValue(getValue) {
|
|
1783
|
-
const deferredValue = signal(getValue());
|
|
1784
|
-
createEffect(() => {
|
|
1785
|
-
const newValue = getValue();
|
|
1786
|
-
const currentDeferred = untrack(() => deferredValue());
|
|
1787
|
-
if (currentDeferred !== newValue) {
|
|
1788
|
-
startTransition(() => {
|
|
1789
|
-
deferredValue(newValue);
|
|
1790
|
-
});
|
|
1791
|
-
}
|
|
1792
|
-
});
|
|
1793
|
-
return () => deferredValue();
|
|
1794
|
-
}
|
|
1795
|
-
|
|
1796
|
-
// src/scheduler.ts
|
|
1797
|
-
function batch2(fn) {
|
|
1798
|
-
return batch(fn);
|
|
1799
|
-
}
|
|
1800
|
-
function untrack2(fn) {
|
|
1801
|
-
return untrack(fn);
|
|
1802
|
-
}
|
|
1803
|
-
|
|
1804
1612
|
// src/binding.ts
|
|
1805
1613
|
var isDev5 = true ? true : typeof process === "undefined" || process.env?.NODE_ENV !== "production";
|
|
1806
1614
|
function isReactive(value) {
|
|
1807
1615
|
return typeof value === "function" && value.length === 0;
|
|
1808
1616
|
}
|
|
1809
|
-
function unwrap2(value) {
|
|
1810
|
-
return isReactive(value) ? value() : value;
|
|
1811
|
-
}
|
|
1812
1617
|
function callEventHandler(handler, event, node, data) {
|
|
1813
1618
|
if (!handler) return;
|
|
1814
1619
|
const context = node ?? event.currentTarget ?? void 0;
|
|
@@ -1833,35 +1638,6 @@ function callEventHandler(handler, event, node, data) {
|
|
|
1833
1638
|
};
|
|
1834
1639
|
invoke(handler);
|
|
1835
1640
|
}
|
|
1836
|
-
function createTextBinding(value) {
|
|
1837
|
-
const text = document.createTextNode("");
|
|
1838
|
-
if (isReactive(value)) {
|
|
1839
|
-
createRenderEffect(() => {
|
|
1840
|
-
const v = value();
|
|
1841
|
-
const fmt = formatTextValue(v);
|
|
1842
|
-
if (text.data !== fmt) {
|
|
1843
|
-
text.data = fmt;
|
|
1844
|
-
}
|
|
1845
|
-
});
|
|
1846
|
-
} else {
|
|
1847
|
-
text.data = formatTextValue(value);
|
|
1848
|
-
}
|
|
1849
|
-
return text;
|
|
1850
|
-
}
|
|
1851
|
-
function bindText(textNode, getValue) {
|
|
1852
|
-
return createRenderEffect(() => {
|
|
1853
|
-
const value = formatTextValue(getValue());
|
|
1854
|
-
if (textNode.data !== value) {
|
|
1855
|
-
textNode.data = value;
|
|
1856
|
-
}
|
|
1857
|
-
});
|
|
1858
|
-
}
|
|
1859
|
-
function formatTextValue(value) {
|
|
1860
|
-
if (value == null || value === false) {
|
|
1861
|
-
return "";
|
|
1862
|
-
}
|
|
1863
|
-
return String(value);
|
|
1864
|
-
}
|
|
1865
1641
|
function createAttributeBinding(el, key, value, setter) {
|
|
1866
1642
|
if (isReactive(value)) {
|
|
1867
1643
|
createRenderEffect(() => {
|
|
@@ -1871,45 +1647,6 @@ function createAttributeBinding(el, key, value, setter) {
|
|
|
1871
1647
|
setter(el, key, value);
|
|
1872
1648
|
}
|
|
1873
1649
|
}
|
|
1874
|
-
function bindAttribute(el, key, getValue) {
|
|
1875
|
-
let prevValue = void 0;
|
|
1876
|
-
return createRenderEffect(() => {
|
|
1877
|
-
const value = getValue();
|
|
1878
|
-
if (value === prevValue) return;
|
|
1879
|
-
prevValue = value;
|
|
1880
|
-
if (value === void 0 || value === null || value === false) {
|
|
1881
|
-
el.removeAttribute(key);
|
|
1882
|
-
} else if (value === true) {
|
|
1883
|
-
el.setAttribute(key, "");
|
|
1884
|
-
} else {
|
|
1885
|
-
el.setAttribute(key, String(value));
|
|
1886
|
-
}
|
|
1887
|
-
});
|
|
1888
|
-
}
|
|
1889
|
-
function bindProperty(el, key, getValue) {
|
|
1890
|
-
const PROPERTY_BINDING_KEYS = /* @__PURE__ */ new Set([
|
|
1891
|
-
"value",
|
|
1892
|
-
"checked",
|
|
1893
|
-
"selected",
|
|
1894
|
-
"disabled",
|
|
1895
|
-
"readOnly",
|
|
1896
|
-
"multiple",
|
|
1897
|
-
"muted"
|
|
1898
|
-
]);
|
|
1899
|
-
let prevValue = void 0;
|
|
1900
|
-
return createRenderEffect(() => {
|
|
1901
|
-
const next = getValue();
|
|
1902
|
-
if (next === prevValue) return;
|
|
1903
|
-
prevValue = next;
|
|
1904
|
-
if (PROPERTY_BINDING_KEYS.has(key) && (next === void 0 || next === null)) {
|
|
1905
|
-
const fallback = key === "checked" || key === "selected" ? false : "";
|
|
1906
|
-
el[key] = fallback;
|
|
1907
|
-
return;
|
|
1908
|
-
}
|
|
1909
|
-
;
|
|
1910
|
-
el[key] = next;
|
|
1911
|
-
});
|
|
1912
|
-
}
|
|
1913
1650
|
function createStyleBinding(el, value) {
|
|
1914
1651
|
const target = el;
|
|
1915
1652
|
if (isReactive(value)) {
|
|
@@ -1923,15 +1660,6 @@ function createStyleBinding(el, value) {
|
|
|
1923
1660
|
applyStyle(target, value, void 0);
|
|
1924
1661
|
}
|
|
1925
1662
|
}
|
|
1926
|
-
function bindStyle(el, getValue) {
|
|
1927
|
-
const target = el;
|
|
1928
|
-
let prev;
|
|
1929
|
-
return createRenderEffect(() => {
|
|
1930
|
-
const next = getValue();
|
|
1931
|
-
applyStyle(target, next, prev);
|
|
1932
|
-
prev = next;
|
|
1933
|
-
});
|
|
1934
|
-
}
|
|
1935
1663
|
function applyStyle(el, value, prev) {
|
|
1936
1664
|
if (typeof value === "string") {
|
|
1937
1665
|
el.style.cssText = value;
|
|
@@ -1949,14 +1677,14 @@ function applyStyle(el, value, prev) {
|
|
|
1949
1677
|
}
|
|
1950
1678
|
}
|
|
1951
1679
|
}
|
|
1952
|
-
for (const [
|
|
1680
|
+
for (const [prop2, v] of Object.entries(styles)) {
|
|
1953
1681
|
if (v != null) {
|
|
1954
|
-
const cssProperty =
|
|
1955
|
-
const unitless = isUnitlessStyleProperty(
|
|
1682
|
+
const cssProperty = prop2.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
1683
|
+
const unitless = isUnitlessStyleProperty(prop2) || isUnitlessStyleProperty(cssProperty);
|
|
1956
1684
|
const valueStr = typeof v === "number" && !unitless ? `${v}px` : String(v);
|
|
1957
1685
|
el.style.setProperty(cssProperty, valueStr);
|
|
1958
1686
|
} else {
|
|
1959
|
-
const cssProperty =
|
|
1687
|
+
const cssProperty = prop2.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
1960
1688
|
el.style.removeProperty(cssProperty);
|
|
1961
1689
|
}
|
|
1962
1690
|
}
|
|
@@ -1972,7 +1700,7 @@ function applyStyle(el, value, prev) {
|
|
|
1972
1700
|
}
|
|
1973
1701
|
}
|
|
1974
1702
|
}
|
|
1975
|
-
var isUnitlessStyleProperty = isDev5 ? (
|
|
1703
|
+
var isUnitlessStyleProperty = isDev5 ? (prop2) => UnitlessStyles.has(prop2) : (prop2) => prop2 === "opacity" || prop2 === "zIndex";
|
|
1976
1704
|
function createClassBinding(el, value) {
|
|
1977
1705
|
if (isReactive(value)) {
|
|
1978
1706
|
let prev = {};
|
|
@@ -1984,22 +1712,6 @@ function createClassBinding(el, value) {
|
|
|
1984
1712
|
applyClass(el, value, {});
|
|
1985
1713
|
}
|
|
1986
1714
|
}
|
|
1987
|
-
function bindClass(el, getValue) {
|
|
1988
|
-
let prev = {};
|
|
1989
|
-
let prevString;
|
|
1990
|
-
return createRenderEffect(() => {
|
|
1991
|
-
const next = getValue();
|
|
1992
|
-
if (typeof next === "string") {
|
|
1993
|
-
if (next === prevString) return;
|
|
1994
|
-
prevString = next;
|
|
1995
|
-
el.className = next;
|
|
1996
|
-
prev = {};
|
|
1997
|
-
return;
|
|
1998
|
-
}
|
|
1999
|
-
prevString = void 0;
|
|
2000
|
-
prev = applyClass(el, next, prev);
|
|
2001
|
-
});
|
|
2002
|
-
}
|
|
2003
1715
|
function toggleClassKey(node, key, value) {
|
|
2004
1716
|
const classNames = key.trim().split(/\s+/);
|
|
2005
1717
|
for (let i = 0, len = classNames.length; i < len; i++) {
|
|
@@ -2041,119 +1753,6 @@ function applyClass(el, value, prev) {
|
|
|
2041
1753
|
}
|
|
2042
1754
|
return prevState;
|
|
2043
1755
|
}
|
|
2044
|
-
function classList(node, value, prev = {}) {
|
|
2045
|
-
return applyClass(node, value, prev);
|
|
2046
|
-
}
|
|
2047
|
-
function insert(parent, getValue, markerOrCreateElement, createElementFn) {
|
|
2048
|
-
const hostRoot = getCurrentRoot();
|
|
2049
|
-
let marker;
|
|
2050
|
-
let ownsMarker = false;
|
|
2051
|
-
let createFn = createElementFn;
|
|
2052
|
-
if (markerOrCreateElement instanceof Node) {
|
|
2053
|
-
marker = markerOrCreateElement;
|
|
2054
|
-
createFn = createElementFn;
|
|
2055
|
-
} else {
|
|
2056
|
-
marker = document.createComment("fict:insert");
|
|
2057
|
-
parent.appendChild(marker);
|
|
2058
|
-
createFn = markerOrCreateElement;
|
|
2059
|
-
ownsMarker = true;
|
|
2060
|
-
}
|
|
2061
|
-
let currentNodes = [];
|
|
2062
|
-
let currentText = null;
|
|
2063
|
-
let currentRoot2 = null;
|
|
2064
|
-
const clearCurrentNodes = () => {
|
|
2065
|
-
if (currentNodes.length > 0) {
|
|
2066
|
-
removeNodes(currentNodes);
|
|
2067
|
-
currentNodes = [];
|
|
2068
|
-
}
|
|
2069
|
-
};
|
|
2070
|
-
const setTextNode = (textValue, shouldInsert, parentNode) => {
|
|
2071
|
-
if (!currentText) {
|
|
2072
|
-
currentText = document.createTextNode(textValue);
|
|
2073
|
-
} else if (currentText.data !== textValue) {
|
|
2074
|
-
currentText.data = textValue;
|
|
2075
|
-
}
|
|
2076
|
-
if (!shouldInsert) {
|
|
2077
|
-
clearCurrentNodes();
|
|
2078
|
-
return;
|
|
2079
|
-
}
|
|
2080
|
-
if (currentNodes.length === 1 && currentNodes[0] === currentText) {
|
|
2081
|
-
return;
|
|
2082
|
-
}
|
|
2083
|
-
clearCurrentNodes();
|
|
2084
|
-
insertNodesBefore(parentNode, [currentText], marker);
|
|
2085
|
-
currentNodes = [currentText];
|
|
2086
|
-
};
|
|
2087
|
-
const dispose = createRenderEffect(() => {
|
|
2088
|
-
const value = getValue();
|
|
2089
|
-
const parentNode = marker.parentNode;
|
|
2090
|
-
const isPrimitive = value == null || value === false || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
2091
|
-
if (isPrimitive) {
|
|
2092
|
-
if (currentRoot2) {
|
|
2093
|
-
destroyRoot(currentRoot2);
|
|
2094
|
-
currentRoot2 = null;
|
|
2095
|
-
}
|
|
2096
|
-
if (!parentNode) {
|
|
2097
|
-
clearCurrentNodes();
|
|
2098
|
-
return;
|
|
2099
|
-
}
|
|
2100
|
-
const textValue = value == null || value === false ? "" : String(value);
|
|
2101
|
-
const shouldInsert = value != null && value !== false;
|
|
2102
|
-
setTextNode(textValue, shouldInsert, parentNode);
|
|
2103
|
-
return;
|
|
2104
|
-
}
|
|
2105
|
-
if (currentRoot2) {
|
|
2106
|
-
destroyRoot(currentRoot2);
|
|
2107
|
-
currentRoot2 = null;
|
|
2108
|
-
}
|
|
2109
|
-
clearCurrentNodes();
|
|
2110
|
-
const root = createRootContext(hostRoot);
|
|
2111
|
-
const prev = pushRoot(root);
|
|
2112
|
-
let nodes = [];
|
|
2113
|
-
try {
|
|
2114
|
-
let newNode;
|
|
2115
|
-
if (value instanceof Node) {
|
|
2116
|
-
newNode = value;
|
|
2117
|
-
} else if (Array.isArray(value)) {
|
|
2118
|
-
if (value.every((v) => v instanceof Node)) {
|
|
2119
|
-
newNode = value;
|
|
2120
|
-
} else {
|
|
2121
|
-
if (createFn) {
|
|
2122
|
-
const mapped = [];
|
|
2123
|
-
for (const item of value) {
|
|
2124
|
-
mapped.push(...toNodeArray(createFn(item)));
|
|
2125
|
-
}
|
|
2126
|
-
newNode = mapped;
|
|
2127
|
-
} else {
|
|
2128
|
-
newNode = document.createTextNode(String(value));
|
|
2129
|
-
}
|
|
2130
|
-
}
|
|
2131
|
-
} else {
|
|
2132
|
-
newNode = createFn ? createFn(value) : document.createTextNode(String(value));
|
|
2133
|
-
}
|
|
2134
|
-
nodes = toNodeArray(newNode);
|
|
2135
|
-
if (parentNode) {
|
|
2136
|
-
insertNodesBefore(parentNode, nodes, marker);
|
|
2137
|
-
}
|
|
2138
|
-
} finally {
|
|
2139
|
-
popRoot(prev);
|
|
2140
|
-
flushOnMount(root);
|
|
2141
|
-
}
|
|
2142
|
-
currentRoot2 = root;
|
|
2143
|
-
currentNodes = nodes;
|
|
2144
|
-
});
|
|
2145
|
-
return () => {
|
|
2146
|
-
dispose();
|
|
2147
|
-
if (currentRoot2) {
|
|
2148
|
-
destroyRoot(currentRoot2);
|
|
2149
|
-
currentRoot2 = null;
|
|
2150
|
-
}
|
|
2151
|
-
clearCurrentNodes();
|
|
2152
|
-
if (ownsMarker) {
|
|
2153
|
-
marker.parentNode?.removeChild(marker);
|
|
2154
|
-
}
|
|
2155
|
-
};
|
|
2156
|
-
}
|
|
2157
1756
|
function createChildBinding(parent, getValue, createElementFn) {
|
|
2158
1757
|
const marker = document.createComment("fict:child");
|
|
2159
1758
|
parent.appendChild(marker);
|
|
@@ -2215,15 +1814,6 @@ function delegateEvents(eventNames, doc = window.document) {
|
|
|
2215
1814
|
}
|
|
2216
1815
|
}
|
|
2217
1816
|
}
|
|
2218
|
-
function clearDelegatedEvents(doc = window.document) {
|
|
2219
|
-
const e = doc[$$EVENTS];
|
|
2220
|
-
if (e) {
|
|
2221
|
-
for (const name of e.keys()) {
|
|
2222
|
-
doc.removeEventListener(name, globalEventHandler);
|
|
2223
|
-
}
|
|
2224
|
-
delete doc[$$EVENTS];
|
|
2225
|
-
}
|
|
2226
|
-
}
|
|
2227
1817
|
function globalEventHandler(e) {
|
|
2228
1818
|
const asNode = (value) => value && typeof value.nodeType === "number" ? value : null;
|
|
2229
1819
|
const asElement = (value) => {
|
|
@@ -2313,24 +1903,6 @@ function globalEventHandler(e) {
|
|
|
2313
1903
|
}
|
|
2314
1904
|
retarget(oriTarget);
|
|
2315
1905
|
}
|
|
2316
|
-
function addEventListener(node, name, handler, delegate) {
|
|
2317
|
-
if (handler == null) return;
|
|
2318
|
-
if (delegate) {
|
|
2319
|
-
if (Array.isArray(handler)) {
|
|
2320
|
-
;
|
|
2321
|
-
node[`$$${name}`] = handler[0];
|
|
2322
|
-
node[`$$${name}Data`] = handler[1];
|
|
2323
|
-
} else {
|
|
2324
|
-
;
|
|
2325
|
-
node[`$$${name}`] = handler;
|
|
2326
|
-
}
|
|
2327
|
-
} else if (Array.isArray(handler)) {
|
|
2328
|
-
const handlerFn = handler[0];
|
|
2329
|
-
node.addEventListener(name, (e) => handlerFn.call(node, handler[1], e));
|
|
2330
|
-
} else {
|
|
2331
|
-
node.addEventListener(name, handler);
|
|
2332
|
-
}
|
|
2333
|
-
}
|
|
2334
1906
|
function bindEvent(el, eventName, handler, options) {
|
|
2335
1907
|
if (handler == null) return () => {
|
|
2336
1908
|
};
|
|
@@ -2358,290 +1930,17 @@ function bindEvent(el, eventName, handler, options) {
|
|
|
2358
1930
|
try {
|
|
2359
1931
|
const resolved = getHandler();
|
|
2360
1932
|
callEventHandler(resolved, event, el);
|
|
2361
|
-
} catch (err) {
|
|
2362
|
-
if (handleError(err, { source: "event", eventName }, rootRef)) {
|
|
2363
|
-
return;
|
|
2364
|
-
}
|
|
2365
|
-
throw err;
|
|
2366
|
-
}
|
|
2367
|
-
};
|
|
2368
|
-
el.addEventListener(eventName, wrapped, options);
|
|
2369
|
-
const cleanup = () => el.removeEventListener(eventName, wrapped, options);
|
|
2370
|
-
registerRootCleanup(cleanup);
|
|
2371
|
-
return cleanup;
|
|
2372
|
-
}
|
|
2373
|
-
function bindRef(el, ref) {
|
|
2374
|
-
if (ref == null) return () => {
|
|
2375
|
-
};
|
|
2376
|
-
const getRef = isReactive(ref) ? ref : () => ref;
|
|
2377
|
-
const applyRef2 = (refValue) => {
|
|
2378
|
-
if (refValue == null) return;
|
|
2379
|
-
if (typeof refValue === "function") {
|
|
2380
|
-
;
|
|
2381
|
-
refValue(el);
|
|
2382
|
-
} else if (typeof refValue === "object" && "current" in refValue) {
|
|
2383
|
-
;
|
|
2384
|
-
refValue.current = el;
|
|
2385
|
-
}
|
|
2386
|
-
};
|
|
2387
|
-
const initialRef = getRef();
|
|
2388
|
-
applyRef2(initialRef);
|
|
2389
|
-
if (isReactive(ref)) {
|
|
2390
|
-
const cleanup2 = createRenderEffect(() => {
|
|
2391
|
-
const currentRef = getRef();
|
|
2392
|
-
applyRef2(currentRef);
|
|
2393
|
-
});
|
|
2394
|
-
registerRootCleanup(cleanup2);
|
|
2395
|
-
const nullifyCleanup = () => {
|
|
2396
|
-
const currentRef = getRef();
|
|
2397
|
-
if (currentRef && typeof currentRef === "object" && "current" in currentRef) {
|
|
2398
|
-
;
|
|
2399
|
-
currentRef.current = null;
|
|
2400
|
-
}
|
|
2401
|
-
};
|
|
2402
|
-
registerRootCleanup(nullifyCleanup);
|
|
2403
|
-
return () => {
|
|
2404
|
-
cleanup2();
|
|
2405
|
-
nullifyCleanup();
|
|
2406
|
-
};
|
|
2407
|
-
}
|
|
2408
|
-
const cleanup = () => {
|
|
2409
|
-
const refValue = getRef();
|
|
2410
|
-
if (refValue && typeof refValue === "object" && "current" in refValue) {
|
|
2411
|
-
;
|
|
2412
|
-
refValue.current = null;
|
|
2413
|
-
}
|
|
2414
|
-
};
|
|
2415
|
-
registerRootCleanup(cleanup);
|
|
2416
|
-
return cleanup;
|
|
2417
|
-
}
|
|
2418
|
-
function spread(node, props = {}, isSVG = false, skipChildren = false) {
|
|
2419
|
-
const prevProps = {};
|
|
2420
|
-
if (!skipChildren && "children" in props) {
|
|
2421
|
-
createRenderEffect(() => {
|
|
2422
|
-
prevProps.children = props.children;
|
|
2423
|
-
});
|
|
2424
|
-
}
|
|
2425
|
-
createRenderEffect(() => {
|
|
2426
|
-
if (typeof props.ref === "function") {
|
|
2427
|
-
;
|
|
2428
|
-
props.ref(node);
|
|
2429
|
-
}
|
|
2430
|
-
});
|
|
2431
|
-
createRenderEffect(() => {
|
|
2432
|
-
assign(node, props, isSVG, true, prevProps, true);
|
|
2433
|
-
});
|
|
2434
|
-
return prevProps;
|
|
2435
|
-
}
|
|
2436
|
-
function assign(node, props, isSVG = false, skipChildren = false, prevProps = {}, skipRef = false) {
|
|
2437
|
-
props = props || {};
|
|
2438
|
-
for (const prop in prevProps) {
|
|
2439
|
-
if (!(prop in props)) {
|
|
2440
|
-
if (prop === "children") continue;
|
|
2441
|
-
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef, props);
|
|
2442
|
-
}
|
|
2443
|
-
}
|
|
2444
|
-
for (const prop in props) {
|
|
2445
|
-
if (prop === "children") {
|
|
2446
|
-
if (!skipChildren) {
|
|
2447
|
-
prevProps.children = props.children;
|
|
2448
|
-
}
|
|
2449
|
-
continue;
|
|
2450
|
-
}
|
|
2451
|
-
const value = props[prop];
|
|
2452
|
-
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef, props);
|
|
2453
|
-
}
|
|
2454
|
-
}
|
|
2455
|
-
function assignProp(node, prop, value, prev, isSVG, skipRef, props) {
|
|
2456
|
-
if (prop === "style") {
|
|
2457
|
-
applyStyle(node, value, prev);
|
|
2458
|
-
return value;
|
|
2459
|
-
}
|
|
2460
|
-
if (prop === "classList") {
|
|
2461
|
-
return applyClass(node, value, prev);
|
|
2462
|
-
}
|
|
2463
|
-
if (value === prev) return prev;
|
|
2464
|
-
if (prop === "ref") {
|
|
2465
|
-
if (!skipRef && typeof value === "function") {
|
|
2466
|
-
;
|
|
2467
|
-
value(node);
|
|
2468
|
-
}
|
|
2469
|
-
return value;
|
|
2470
|
-
}
|
|
2471
|
-
if (prop.slice(0, 3) === "on:") {
|
|
2472
|
-
const eventName = prop.slice(3);
|
|
2473
|
-
if (prev) node.removeEventListener(eventName, prev);
|
|
2474
|
-
if (value) node.addEventListener(eventName, value);
|
|
2475
|
-
return value;
|
|
2476
|
-
}
|
|
2477
|
-
if (prop.slice(0, 10) === "oncapture:") {
|
|
2478
|
-
const eventName = prop.slice(10);
|
|
2479
|
-
if (prev) node.removeEventListener(eventName, prev, true);
|
|
2480
|
-
if (value) node.addEventListener(eventName, value, true);
|
|
2481
|
-
return value;
|
|
2482
|
-
}
|
|
2483
|
-
if (prop.slice(0, 2) === "on") {
|
|
2484
|
-
const eventName = prop.slice(2).toLowerCase();
|
|
2485
|
-
const shouldDelegate = isDev5 && DelegatedEvents.has(eventName);
|
|
2486
|
-
if (!shouldDelegate && prev) {
|
|
2487
|
-
const handler = Array.isArray(prev) ? prev[0] : prev;
|
|
2488
|
-
node.removeEventListener(eventName, handler);
|
|
2489
|
-
}
|
|
2490
|
-
if (shouldDelegate || value) {
|
|
2491
|
-
addEventListener(node, eventName, value, shouldDelegate);
|
|
2492
|
-
if (shouldDelegate) delegateEvents([eventName]);
|
|
2493
|
-
}
|
|
2494
|
-
return value;
|
|
2495
|
-
}
|
|
2496
|
-
if (prop.slice(0, 5) === "attr:") {
|
|
2497
|
-
if (value == null) node.removeAttribute(prop.slice(5));
|
|
2498
|
-
else node.setAttribute(prop.slice(5), String(value));
|
|
2499
|
-
return value;
|
|
2500
|
-
}
|
|
2501
|
-
if (prop.slice(0, 5) === "bool:") {
|
|
2502
|
-
if (value) node.setAttribute(prop.slice(5), "");
|
|
2503
|
-
else node.removeAttribute(prop.slice(5));
|
|
2504
|
-
return value;
|
|
2505
|
-
}
|
|
2506
|
-
if (prop.slice(0, 5) === "prop:") {
|
|
2507
|
-
;
|
|
2508
|
-
node[prop.slice(5)] = value;
|
|
2509
|
-
return value;
|
|
2510
|
-
}
|
|
2511
|
-
if (prop === "class" || prop === "className") {
|
|
2512
|
-
if (value == null) node.removeAttribute("class");
|
|
2513
|
-
else node.className = String(value);
|
|
2514
|
-
return value;
|
|
2515
|
-
}
|
|
2516
|
-
const isCE = node.nodeName.includes("-") || "is" in props;
|
|
2517
|
-
if (!isSVG) {
|
|
2518
|
-
const propAlias = isDev5 ? getPropAlias(prop, node.tagName) : void 0;
|
|
2519
|
-
const isProperty = isDev5 ? Properties.has(prop) : prop in node;
|
|
2520
|
-
const isChildProp = isDev5 ? ChildProperties.has(prop) : prop === "innerHTML" || prop === "textContent" || prop === "innerText" || prop === "children";
|
|
2521
|
-
if (propAlias || isProperty || isChildProp || isCE) {
|
|
2522
|
-
const propName = propAlias || prop;
|
|
2523
|
-
if (isCE && !isProperty && !isChildProp && !propAlias) {
|
|
2524
|
-
;
|
|
2525
|
-
node[toPropertyName(propName)] = value;
|
|
2526
|
-
} else {
|
|
2527
|
-
;
|
|
2528
|
-
node[propName] = value;
|
|
2529
|
-
}
|
|
2530
|
-
return value;
|
|
2531
|
-
}
|
|
2532
|
-
}
|
|
2533
|
-
if (isSVG && prop.indexOf(":") > -1) {
|
|
2534
|
-
const [prefix, name] = prop.split(":");
|
|
2535
|
-
const ns = SVGNamespace[prefix];
|
|
2536
|
-
if (ns) {
|
|
2537
|
-
if (value == null) node.removeAttributeNS(ns, name);
|
|
2538
|
-
else node.setAttributeNS(ns, name, String(value));
|
|
2539
|
-
return value;
|
|
2540
|
-
}
|
|
2541
|
-
}
|
|
2542
|
-
const attrName = prop === "htmlFor" ? "for" : prop;
|
|
2543
|
-
if (value == null) node.removeAttribute(attrName);
|
|
2544
|
-
else node.setAttribute(attrName, String(value));
|
|
2545
|
-
return value;
|
|
2546
|
-
}
|
|
2547
|
-
function toPropertyName(name) {
|
|
2548
|
-
return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
|
|
2549
|
-
}
|
|
2550
|
-
function createConditional(condition, renderTrue, createElementFn, renderFalse) {
|
|
2551
|
-
const startMarker = document.createComment("fict:cond:start");
|
|
2552
|
-
const endMarker = document.createComment("fict:cond:end");
|
|
2553
|
-
const fragment = document.createDocumentFragment();
|
|
2554
|
-
fragment.append(startMarker, endMarker);
|
|
2555
|
-
const hostRoot = getCurrentRoot();
|
|
2556
|
-
let currentNodes = [];
|
|
2557
|
-
let currentRoot2 = null;
|
|
2558
|
-
let lastCondition = void 0;
|
|
2559
|
-
let pendingRender = false;
|
|
2560
|
-
const conditionMemo = computed(condition);
|
|
2561
|
-
const runConditional = () => {
|
|
2562
|
-
const cond = conditionMemo();
|
|
2563
|
-
const parent = startMarker.parentNode;
|
|
2564
|
-
if (!parent) {
|
|
2565
|
-
pendingRender = true;
|
|
2566
|
-
return;
|
|
2567
|
-
}
|
|
2568
|
-
pendingRender = false;
|
|
2569
|
-
if (lastCondition === cond && currentNodes.length > 0) {
|
|
2570
|
-
return;
|
|
2571
|
-
}
|
|
2572
|
-
if (lastCondition === cond && lastCondition === false && renderFalse === void 0) {
|
|
2573
|
-
return;
|
|
2574
|
-
}
|
|
2575
|
-
lastCondition = cond;
|
|
2576
|
-
if (currentRoot2) {
|
|
2577
|
-
destroyRoot(currentRoot2);
|
|
2578
|
-
currentRoot2 = null;
|
|
2579
|
-
}
|
|
2580
|
-
removeNodes(currentNodes);
|
|
2581
|
-
currentNodes = [];
|
|
2582
|
-
const render2 = cond ? renderTrue : renderFalse;
|
|
2583
|
-
if (!render2) {
|
|
2584
|
-
return;
|
|
2585
|
-
}
|
|
2586
|
-
const root = createRootContext(hostRoot);
|
|
2587
|
-
const prev = pushRoot(root);
|
|
2588
|
-
let handledError = false;
|
|
2589
|
-
try {
|
|
2590
|
-
const output = untrack(render2);
|
|
2591
|
-
if (output == null || output === false) {
|
|
2592
|
-
return;
|
|
2593
|
-
}
|
|
2594
|
-
const el = createElementFn(output);
|
|
2595
|
-
const nodes = toNodeArray(el);
|
|
2596
|
-
insertNodesBefore(parent, nodes, endMarker);
|
|
2597
|
-
currentNodes = nodes;
|
|
2598
|
-
} catch (err) {
|
|
2599
|
-
if (handleSuspend(err, root)) {
|
|
2600
|
-
handledError = true;
|
|
2601
|
-
destroyRoot(root);
|
|
2602
|
-
return;
|
|
2603
|
-
}
|
|
2604
|
-
if (handleError(err, { source: "renderChild" }, root)) {
|
|
2605
|
-
handledError = true;
|
|
2606
|
-
destroyRoot(root);
|
|
1933
|
+
} catch (err) {
|
|
1934
|
+
if (handleError(err, { source: "event", eventName }, rootRef)) {
|
|
2607
1935
|
return;
|
|
2608
1936
|
}
|
|
2609
1937
|
throw err;
|
|
2610
|
-
} finally {
|
|
2611
|
-
popRoot(prev);
|
|
2612
|
-
if (!handledError) {
|
|
2613
|
-
flushOnMount(root);
|
|
2614
|
-
currentRoot2 = root;
|
|
2615
|
-
} else {
|
|
2616
|
-
currentRoot2 = null;
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
|
-
};
|
|
2620
|
-
const dispose = createRenderEffect(runConditional);
|
|
2621
|
-
return {
|
|
2622
|
-
marker: fragment,
|
|
2623
|
-
flush: () => {
|
|
2624
|
-
if (pendingRender) {
|
|
2625
|
-
runConditional();
|
|
2626
|
-
}
|
|
2627
|
-
},
|
|
2628
|
-
dispose: () => {
|
|
2629
|
-
dispose();
|
|
2630
|
-
if (currentRoot2) {
|
|
2631
|
-
destroyRoot(currentRoot2);
|
|
2632
|
-
}
|
|
2633
|
-
removeNodes(currentNodes);
|
|
2634
|
-
currentNodes = [];
|
|
2635
|
-
startMarker.parentNode?.removeChild(startMarker);
|
|
2636
|
-
endMarker.parentNode?.removeChild(endMarker);
|
|
2637
1938
|
}
|
|
2638
1939
|
};
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
el.style.display = condition() ? originalDisplay : "none";
|
|
2644
|
-
});
|
|
1940
|
+
el.addEventListener(eventName, wrapped, options);
|
|
1941
|
+
const cleanup = () => el.removeEventListener(eventName, wrapped, options);
|
|
1942
|
+
registerRootCleanup(cleanup);
|
|
1943
|
+
return cleanup;
|
|
2645
1944
|
}
|
|
2646
1945
|
function createPortal(container, render2, createElementFn) {
|
|
2647
1946
|
const parentRoot = getCurrentRoot();
|
|
@@ -2714,58 +2013,9 @@ function createPortal(container, render2, createElementFn) {
|
|
|
2714
2013
|
};
|
|
2715
2014
|
}
|
|
2716
2015
|
|
|
2717
|
-
// src/scope.ts
|
|
2718
|
-
function createScope() {
|
|
2719
|
-
let dispose = null;
|
|
2720
|
-
const stop = () => {
|
|
2721
|
-
if (dispose) {
|
|
2722
|
-
dispose();
|
|
2723
|
-
dispose = null;
|
|
2724
|
-
}
|
|
2725
|
-
};
|
|
2726
|
-
const run = (fn) => {
|
|
2727
|
-
stop();
|
|
2728
|
-
const { dispose: rootDispose, value } = createRoot(fn);
|
|
2729
|
-
dispose = rootDispose;
|
|
2730
|
-
return value;
|
|
2731
|
-
};
|
|
2732
|
-
registerRootCleanup(stop);
|
|
2733
|
-
return { run, stop };
|
|
2734
|
-
}
|
|
2735
|
-
function runInScope(flag, fn) {
|
|
2736
|
-
const scope = createScope();
|
|
2737
|
-
const evaluate = () => isReactive(flag) ? flag() : !!flag;
|
|
2738
|
-
createEffect(() => {
|
|
2739
|
-
const enabled = evaluate();
|
|
2740
|
-
if (enabled) {
|
|
2741
|
-
scope.run(fn);
|
|
2742
|
-
} else {
|
|
2743
|
-
scope.stop();
|
|
2744
|
-
}
|
|
2745
|
-
});
|
|
2746
|
-
onCleanup(scope.stop);
|
|
2747
|
-
}
|
|
2748
|
-
|
|
2749
2016
|
// src/hooks.ts
|
|
2750
2017
|
var isDev6 = true ? true : typeof process === "undefined" || process.env?.NODE_ENV !== "production";
|
|
2751
2018
|
var ctxStack = [];
|
|
2752
|
-
function assertRenderContext(ctx, hookName) {
|
|
2753
|
-
if (!ctx.rendering) {
|
|
2754
|
-
const message = isDev6 ? `${hookName} can only be used during render execution` : "FICT:E_HOOK_RENDER";
|
|
2755
|
-
throw new Error(message);
|
|
2756
|
-
}
|
|
2757
|
-
}
|
|
2758
|
-
function __fictUseContext() {
|
|
2759
|
-
if (ctxStack.length === 0) {
|
|
2760
|
-
const ctx2 = { slots: [], cursor: 0, rendering: true };
|
|
2761
|
-
ctxStack.push(ctx2);
|
|
2762
|
-
return ctx2;
|
|
2763
|
-
}
|
|
2764
|
-
const ctx = ctxStack[ctxStack.length - 1];
|
|
2765
|
-
ctx.cursor = 0;
|
|
2766
|
-
ctx.rendering = true;
|
|
2767
|
-
return ctx;
|
|
2768
|
-
}
|
|
2769
2019
|
function __fictPushContext() {
|
|
2770
2020
|
const ctx = { slots: [], cursor: 0 };
|
|
2771
2021
|
ctxStack.push(ctx);
|
|
@@ -2774,73 +2024,6 @@ function __fictPushContext() {
|
|
|
2774
2024
|
function __fictPopContext() {
|
|
2775
2025
|
ctxStack.pop();
|
|
2776
2026
|
}
|
|
2777
|
-
function __fictResetContext() {
|
|
2778
|
-
ctxStack.length = 0;
|
|
2779
|
-
}
|
|
2780
|
-
function __fictUseSignal(ctx, initial, slot) {
|
|
2781
|
-
assertRenderContext(ctx, "__fictUseSignal");
|
|
2782
|
-
const index = slot ?? ctx.cursor++;
|
|
2783
|
-
if (!ctx.slots[index]) {
|
|
2784
|
-
ctx.slots[index] = signal(initial);
|
|
2785
|
-
}
|
|
2786
|
-
return ctx.slots[index];
|
|
2787
|
-
}
|
|
2788
|
-
function __fictUseMemo(ctx, fn, slot) {
|
|
2789
|
-
assertRenderContext(ctx, "__fictUseMemo");
|
|
2790
|
-
const index = slot ?? ctx.cursor++;
|
|
2791
|
-
if (!ctx.slots[index]) {
|
|
2792
|
-
ctx.slots[index] = createMemo(fn);
|
|
2793
|
-
}
|
|
2794
|
-
return ctx.slots[index];
|
|
2795
|
-
}
|
|
2796
|
-
function __fictUseEffect(ctx, fn, slot) {
|
|
2797
|
-
assertRenderContext(ctx, "__fictUseEffect");
|
|
2798
|
-
const index = slot ?? ctx.cursor++;
|
|
2799
|
-
if (!ctx.slots[index]) {
|
|
2800
|
-
ctx.slots[index] = createEffect(fn);
|
|
2801
|
-
}
|
|
2802
|
-
}
|
|
2803
|
-
function __fictRender(ctx, fn) {
|
|
2804
|
-
ctxStack.push(ctx);
|
|
2805
|
-
ctx.cursor = 0;
|
|
2806
|
-
ctx.rendering = true;
|
|
2807
|
-
try {
|
|
2808
|
-
return fn();
|
|
2809
|
-
} finally {
|
|
2810
|
-
ctx.rendering = false;
|
|
2811
|
-
ctxStack.pop();
|
|
2812
|
-
}
|
|
2813
|
-
}
|
|
2814
|
-
|
|
2815
|
-
// src/versioned-signal.ts
|
|
2816
|
-
function createVersionedSignal(initialValue, options) {
|
|
2817
|
-
const equals = options?.equals ?? Object.is;
|
|
2818
|
-
const value = signal(initialValue);
|
|
2819
|
-
const version = signal(0);
|
|
2820
|
-
const bumpVersion = () => {
|
|
2821
|
-
const next = version() + 1;
|
|
2822
|
-
version(next);
|
|
2823
|
-
};
|
|
2824
|
-
return {
|
|
2825
|
-
read: () => {
|
|
2826
|
-
version();
|
|
2827
|
-
return value();
|
|
2828
|
-
},
|
|
2829
|
-
write: (next) => {
|
|
2830
|
-
const prev = value();
|
|
2831
|
-
if (!equals(prev, next)) {
|
|
2832
|
-
value(next);
|
|
2833
|
-
return;
|
|
2834
|
-
}
|
|
2835
|
-
bumpVersion();
|
|
2836
|
-
},
|
|
2837
|
-
force: () => {
|
|
2838
|
-
bumpVersion();
|
|
2839
|
-
},
|
|
2840
|
-
peekVersion: () => version(),
|
|
2841
|
-
peekValue: () => value()
|
|
2842
|
-
};
|
|
2843
|
-
}
|
|
2844
2027
|
|
|
2845
2028
|
// src/props.ts
|
|
2846
2029
|
var propGetters = /* @__PURE__ */ new WeakSet();
|
|
@@ -2867,24 +2050,24 @@ function createPropsProxy(props) {
|
|
|
2867
2050
|
return cached;
|
|
2868
2051
|
}
|
|
2869
2052
|
const proxy = new Proxy(props, {
|
|
2870
|
-
get(target,
|
|
2871
|
-
const value = Reflect.get(target,
|
|
2053
|
+
get(target, prop2, receiver) {
|
|
2054
|
+
const value = Reflect.get(target, prop2, receiver);
|
|
2872
2055
|
if (isPropGetter(value)) {
|
|
2873
2056
|
return value();
|
|
2874
2057
|
}
|
|
2875
2058
|
return value;
|
|
2876
2059
|
},
|
|
2877
|
-
set(target,
|
|
2878
|
-
return Reflect.set(target,
|
|
2060
|
+
set(target, prop2, value, receiver) {
|
|
2061
|
+
return Reflect.set(target, prop2, value, receiver);
|
|
2879
2062
|
},
|
|
2880
|
-
has(target,
|
|
2881
|
-
return
|
|
2063
|
+
has(target, prop2) {
|
|
2064
|
+
return prop2 in target;
|
|
2882
2065
|
},
|
|
2883
2066
|
ownKeys(target) {
|
|
2884
2067
|
return Reflect.ownKeys(target);
|
|
2885
2068
|
},
|
|
2886
|
-
getOwnPropertyDescriptor(target,
|
|
2887
|
-
return Object.getOwnPropertyDescriptor(target,
|
|
2069
|
+
getOwnPropertyDescriptor(target, prop2) {
|
|
2070
|
+
return Object.getOwnPropertyDescriptor(target, prop2);
|
|
2888
2071
|
}
|
|
2889
2072
|
});
|
|
2890
2073
|
rawToProxy.set(props, proxy);
|
|
@@ -2897,16 +2080,6 @@ function unwrapProps(props) {
|
|
|
2897
2080
|
}
|
|
2898
2081
|
return proxyToRaw.get(props) ?? props;
|
|
2899
2082
|
}
|
|
2900
|
-
function __fictPropsRest(props, exclude) {
|
|
2901
|
-
const raw = unwrapProps(props);
|
|
2902
|
-
const out = {};
|
|
2903
|
-
const excludeSet = new Set(exclude);
|
|
2904
|
-
for (const key of Reflect.ownKeys(raw)) {
|
|
2905
|
-
if (excludeSet.has(key)) continue;
|
|
2906
|
-
out[key] = raw[key];
|
|
2907
|
-
}
|
|
2908
|
-
return createPropsProxy(out);
|
|
2909
|
-
}
|
|
2910
2083
|
function mergeProps(...sources) {
|
|
2911
2084
|
const validSources = sources.filter(
|
|
2912
2085
|
(s) => s != null && (typeof s === "object" || typeof s === "function")
|
|
@@ -2922,32 +2095,38 @@ function mergeProps(...sources) {
|
|
|
2922
2095
|
if (!value || typeof value !== "object") return void 0;
|
|
2923
2096
|
return unwrapProps(value);
|
|
2924
2097
|
};
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
if (!raw || !(prop in raw)) continue;
|
|
2931
|
-
const value = raw[prop];
|
|
2932
|
-
if (typeof src === "function" && !isPropGetter(value)) {
|
|
2933
|
-
return __fictProp(() => {
|
|
2934
|
-
const latest = resolveSource(src);
|
|
2935
|
-
if (!latest || !(prop in latest)) return void 0;
|
|
2936
|
-
return latest[prop];
|
|
2937
|
-
});
|
|
2938
|
-
}
|
|
2939
|
-
return value;
|
|
2098
|
+
const hasProp = (prop2) => {
|
|
2099
|
+
for (const src of validSources) {
|
|
2100
|
+
const raw = resolveSource(src);
|
|
2101
|
+
if (raw && prop2 in raw) {
|
|
2102
|
+
return true;
|
|
2940
2103
|
}
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2104
|
+
}
|
|
2105
|
+
return false;
|
|
2106
|
+
};
|
|
2107
|
+
const readProp = (prop2) => {
|
|
2108
|
+
for (let i = validSources.length - 1; i >= 0; i--) {
|
|
2109
|
+
const src = validSources[i];
|
|
2110
|
+
const raw = resolveSource(src);
|
|
2111
|
+
if (!raw || !(prop2 in raw)) continue;
|
|
2112
|
+
const value = raw[prop2];
|
|
2113
|
+
if (typeof src === "function" && !isPropGetter(value)) {
|
|
2114
|
+
return __fictProp(() => {
|
|
2115
|
+
const latest = resolveSource(src);
|
|
2116
|
+
if (!latest || !(prop2 in latest)) return void 0;
|
|
2117
|
+
return latest[prop2];
|
|
2118
|
+
});
|
|
2949
2119
|
}
|
|
2950
|
-
return
|
|
2120
|
+
return value;
|
|
2121
|
+
}
|
|
2122
|
+
return void 0;
|
|
2123
|
+
};
|
|
2124
|
+
return new Proxy({}, {
|
|
2125
|
+
get(_, prop2) {
|
|
2126
|
+
return readProp(prop2);
|
|
2127
|
+
},
|
|
2128
|
+
has(_, prop2) {
|
|
2129
|
+
return hasProp(prop2);
|
|
2951
2130
|
},
|
|
2952
2131
|
ownKeys() {
|
|
2953
2132
|
const keys = /* @__PURE__ */ new Set();
|
|
@@ -2961,33 +2140,23 @@ function mergeProps(...sources) {
|
|
|
2961
2140
|
}
|
|
2962
2141
|
return Array.from(keys);
|
|
2963
2142
|
},
|
|
2964
|
-
getOwnPropertyDescriptor(_,
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
get: () => {
|
|
2972
|
-
const value = raw[prop];
|
|
2973
|
-
return value;
|
|
2974
|
-
}
|
|
2975
|
-
};
|
|
2976
|
-
}
|
|
2977
|
-
}
|
|
2978
|
-
return void 0;
|
|
2143
|
+
getOwnPropertyDescriptor(_, prop2) {
|
|
2144
|
+
if (!hasProp(prop2)) return void 0;
|
|
2145
|
+
return {
|
|
2146
|
+
enumerable: true,
|
|
2147
|
+
configurable: true,
|
|
2148
|
+
get: () => readProp(prop2)
|
|
2149
|
+
};
|
|
2979
2150
|
}
|
|
2980
2151
|
});
|
|
2981
2152
|
}
|
|
2982
|
-
function
|
|
2153
|
+
function prop(getter) {
|
|
2154
|
+
if (isPropGetter(getter)) {
|
|
2155
|
+
return getter;
|
|
2156
|
+
}
|
|
2983
2157
|
return __fictProp(createMemo(getter));
|
|
2984
2158
|
}
|
|
2985
2159
|
|
|
2986
|
-
// src/ref.ts
|
|
2987
|
-
function createRef() {
|
|
2988
|
-
return { current: null };
|
|
2989
|
-
}
|
|
2990
|
-
|
|
2991
2160
|
// src/dom.ts
|
|
2992
2161
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
2993
2162
|
var MATHML_NS = "http://www.w3.org/1998/Math/MathML";
|
|
@@ -3063,24 +2232,24 @@ function createElementWithContext(node, namespace) {
|
|
|
3063
2232
|
if (typeof vnode.type === "function") {
|
|
3064
2233
|
const rawProps = unwrapProps(vnode.props ?? {});
|
|
3065
2234
|
const baseProps = vnode.key === void 0 ? rawProps : new Proxy(rawProps, {
|
|
3066
|
-
get(target,
|
|
3067
|
-
if (
|
|
3068
|
-
return Reflect.get(target,
|
|
2235
|
+
get(target, prop2, receiver) {
|
|
2236
|
+
if (prop2 === "key") return vnode.key;
|
|
2237
|
+
return Reflect.get(target, prop2, receiver);
|
|
3069
2238
|
},
|
|
3070
|
-
has(target,
|
|
3071
|
-
if (
|
|
3072
|
-
return
|
|
2239
|
+
has(target, prop2) {
|
|
2240
|
+
if (prop2 === "key") return true;
|
|
2241
|
+
return prop2 in target;
|
|
3073
2242
|
},
|
|
3074
2243
|
ownKeys(target) {
|
|
3075
2244
|
const keys = new Set(Reflect.ownKeys(target));
|
|
3076
2245
|
keys.add("key");
|
|
3077
2246
|
return Array.from(keys);
|
|
3078
2247
|
},
|
|
3079
|
-
getOwnPropertyDescriptor(target,
|
|
3080
|
-
if (
|
|
2248
|
+
getOwnPropertyDescriptor(target, prop2) {
|
|
2249
|
+
if (prop2 === "key") {
|
|
3081
2250
|
return { enumerable: true, configurable: true, value: vnode.key };
|
|
3082
2251
|
}
|
|
3083
|
-
return Object.getOwnPropertyDescriptor(target,
|
|
2252
|
+
return Object.getOwnPropertyDescriptor(target, prop2);
|
|
3084
2253
|
}
|
|
3085
2254
|
});
|
|
3086
2255
|
const props = createPropsProxy(baseProps);
|
|
@@ -3115,23 +2284,6 @@ function createElementWithContext(node, namespace) {
|
|
|
3115
2284
|
);
|
|
3116
2285
|
return el;
|
|
3117
2286
|
}
|
|
3118
|
-
function template(html, isImportNode, isSVG, isMathML) {
|
|
3119
|
-
let node = null;
|
|
3120
|
-
const create = () => {
|
|
3121
|
-
const t = isMathML ? document.createElementNS(MATHML_NS, "template") : document.createElement("template");
|
|
3122
|
-
t.innerHTML = html;
|
|
3123
|
-
if (isSVG) {
|
|
3124
|
-
return t.content.firstChild.firstChild;
|
|
3125
|
-
}
|
|
3126
|
-
if (isMathML) {
|
|
3127
|
-
return t.firstChild;
|
|
3128
|
-
}
|
|
3129
|
-
return t.content.firstChild;
|
|
3130
|
-
};
|
|
3131
|
-
const fn = isImportNode ? () => untrack2(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
|
|
3132
|
-
fn.cloneNode = fn;
|
|
3133
|
-
return fn;
|
|
3134
|
-
}
|
|
3135
2287
|
function isBindingHandle(node) {
|
|
3136
2288
|
return node !== null && typeof node === "object" && "marker" in node && "dispose" in node && typeof node.dispose === "function";
|
|
3137
2289
|
}
|
|
@@ -3308,7 +2460,7 @@ function applyProps(el, props, isSVG = false) {
|
|
|
3308
2460
|
if (isCE && !isProperty && !propAlias) {
|
|
3309
2461
|
createAttributeBinding(
|
|
3310
2462
|
el,
|
|
3311
|
-
|
|
2463
|
+
toPropertyName(propName),
|
|
3312
2464
|
value,
|
|
3313
2465
|
setProperty
|
|
3314
2466
|
);
|
|
@@ -3334,7 +2486,7 @@ function applyProps(el, props, isSVG = false) {
|
|
|
3334
2486
|
createAttributeBinding(el, attrName, value, setAttribute);
|
|
3335
2487
|
}
|
|
3336
2488
|
}
|
|
3337
|
-
function
|
|
2489
|
+
function toPropertyName(name) {
|
|
3338
2490
|
return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
|
|
3339
2491
|
}
|
|
3340
2492
|
var setAttribute = (el, key, value) => {
|
|
@@ -3628,728 +2780,118 @@ function Suspense(props) {
|
|
|
3628
2780
|
return fragment;
|
|
3629
2781
|
}
|
|
3630
2782
|
|
|
3631
|
-
// src/
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
let
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
if (!map || !map.has(nodeToRemove)) {
|
|
3670
|
-
nodeToRemove.parentNode?.removeChild(nodeToRemove);
|
|
3671
|
-
}
|
|
3672
|
-
aStart++;
|
|
3673
|
-
}
|
|
3674
|
-
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
3675
|
-
const node = a[--aEnd].nextSibling;
|
|
3676
|
-
parentNode.insertBefore(b[bStart++], a[aStart++].nextSibling);
|
|
3677
|
-
parentNode.insertBefore(b[--bEnd], node);
|
|
3678
|
-
a[aEnd] = b[bEnd];
|
|
3679
|
-
} else {
|
|
3680
|
-
if (!map) {
|
|
3681
|
-
map = /* @__PURE__ */ new Map();
|
|
3682
|
-
let i = bStart;
|
|
3683
|
-
while (i < bEnd) {
|
|
3684
|
-
map.set(b[i], i++);
|
|
3685
|
-
}
|
|
3686
|
-
}
|
|
3687
|
-
const index = map.get(a[aStart]);
|
|
3688
|
-
if (index != null) {
|
|
3689
|
-
if (bStart < index && index < bEnd) {
|
|
3690
|
-
let i = aStart;
|
|
3691
|
-
let sequence = 1;
|
|
3692
|
-
let t;
|
|
3693
|
-
while (++i < aEnd && i < bEnd) {
|
|
3694
|
-
t = map.get(a[i]);
|
|
3695
|
-
if (t == null || t !== index + sequence) break;
|
|
3696
|
-
sequence++;
|
|
3697
|
-
}
|
|
3698
|
-
if (sequence > index - bStart) {
|
|
3699
|
-
const node = a[aStart];
|
|
3700
|
-
while (bStart < index) {
|
|
3701
|
-
parentNode.insertBefore(b[bStart++], node);
|
|
3702
|
-
}
|
|
3703
|
-
} else {
|
|
3704
|
-
parentNode.replaceChild(b[bStart++], a[aStart++]);
|
|
3705
|
-
}
|
|
3706
|
-
} else {
|
|
3707
|
-
aStart++;
|
|
3708
|
-
}
|
|
3709
|
-
} else {
|
|
3710
|
-
const nodeToRemove = a[aStart++];
|
|
3711
|
-
nodeToRemove.parentNode?.removeChild(nodeToRemove);
|
|
3712
|
-
}
|
|
3713
|
-
}
|
|
3714
|
-
}
|
|
3715
|
-
}
|
|
3716
|
-
|
|
3717
|
-
// src/list-helpers.ts
|
|
3718
|
-
var isDev8 = true ? true : typeof process === "undefined" || process.env?.NODE_ENV !== "production";
|
|
3719
|
-
function moveNodesBefore(parent, nodes, anchor) {
|
|
3720
|
-
for (let i = nodes.length - 1; i >= 0; i--) {
|
|
3721
|
-
const node = nodes[i];
|
|
3722
|
-
if (!node || !(node instanceof Node)) {
|
|
3723
|
-
const message = isDev8 ? "Invalid node in moveNodesBefore" : "FICT:E_NODE";
|
|
3724
|
-
throw new Error(message);
|
|
3725
|
-
}
|
|
3726
|
-
if (node.nextSibling !== anchor) {
|
|
3727
|
-
if (node.ownerDocument !== parent.ownerDocument && parent.ownerDocument) {
|
|
3728
|
-
parent.ownerDocument.adoptNode(node);
|
|
2783
|
+
// src/context.ts
|
|
2784
|
+
var contextStorage = /* @__PURE__ */ new WeakMap();
|
|
2785
|
+
function getContextMap(root) {
|
|
2786
|
+
let map = contextStorage.get(root);
|
|
2787
|
+
if (!map) {
|
|
2788
|
+
map = /* @__PURE__ */ new Map();
|
|
2789
|
+
contextStorage.set(root, map);
|
|
2790
|
+
}
|
|
2791
|
+
return map;
|
|
2792
|
+
}
|
|
2793
|
+
function createContext(defaultValue) {
|
|
2794
|
+
const id = Symbol("fict.context");
|
|
2795
|
+
const context = {
|
|
2796
|
+
id,
|
|
2797
|
+
defaultValue,
|
|
2798
|
+
Provider: null
|
|
2799
|
+
};
|
|
2800
|
+
context.Provider = function Provider(props) {
|
|
2801
|
+
const hostRoot = getCurrentRoot();
|
|
2802
|
+
const providerRoot = createRootContext(hostRoot);
|
|
2803
|
+
const contextMap = getContextMap(providerRoot);
|
|
2804
|
+
contextMap.set(id, props.value);
|
|
2805
|
+
const fragment = document.createDocumentFragment();
|
|
2806
|
+
const marker = document.createComment("fict:ctx");
|
|
2807
|
+
fragment.appendChild(marker);
|
|
2808
|
+
let cleanup;
|
|
2809
|
+
let activeNodes = [];
|
|
2810
|
+
const renderChildren = (children) => {
|
|
2811
|
+
if (cleanup) {
|
|
2812
|
+
cleanup();
|
|
2813
|
+
cleanup = void 0;
|
|
2814
|
+
}
|
|
2815
|
+
if (activeNodes.length) {
|
|
2816
|
+
removeNodes(activeNodes);
|
|
2817
|
+
activeNodes = [];
|
|
2818
|
+
}
|
|
2819
|
+
if (children == null || children === false) {
|
|
2820
|
+
return;
|
|
3729
2821
|
}
|
|
2822
|
+
const prev = pushRoot(providerRoot);
|
|
2823
|
+
let nodes = [];
|
|
3730
2824
|
try {
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
parent.insertBefore(clone, anchor);
|
|
3737
|
-
continue;
|
|
3738
|
-
} catch {
|
|
3739
|
-
}
|
|
2825
|
+
const output = createElement(children);
|
|
2826
|
+
nodes = toNodeArray(output);
|
|
2827
|
+
const parentNode = marker.parentNode;
|
|
2828
|
+
if (parentNode) {
|
|
2829
|
+
insertNodesBefore(parentNode, nodes, marker);
|
|
3740
2830
|
}
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
anchor = node;
|
|
3745
|
-
}
|
|
3746
|
-
}
|
|
3747
|
-
var MAX_SAFE_VERSION = 9007199254740991;
|
|
3748
|
-
function createVersionedSignalAccessor(initialValue) {
|
|
3749
|
-
let current = initialValue;
|
|
3750
|
-
let version = 0;
|
|
3751
|
-
const track2 = signal(version);
|
|
3752
|
-
function accessor(value) {
|
|
3753
|
-
if (arguments.length === 0) {
|
|
3754
|
-
track2();
|
|
3755
|
-
return current;
|
|
3756
|
-
}
|
|
3757
|
-
current = value;
|
|
3758
|
-
version = version >= MAX_SAFE_VERSION ? 1 : version + 1;
|
|
3759
|
-
track2(version);
|
|
3760
|
-
}
|
|
3761
|
-
return accessor;
|
|
3762
|
-
}
|
|
3763
|
-
function createKeyedListContainer() {
|
|
3764
|
-
const startMarker = document.createComment("fict:list:start");
|
|
3765
|
-
const endMarker = document.createComment("fict:list:end");
|
|
3766
|
-
const dispose = () => {
|
|
3767
|
-
for (const block of container.blocks.values()) {
|
|
3768
|
-
destroyRoot(block.root);
|
|
3769
|
-
}
|
|
3770
|
-
container.blocks.clear();
|
|
3771
|
-
container.nextBlocks.clear();
|
|
3772
|
-
if (!startMarker.parentNode || !endMarker.parentNode) {
|
|
3773
|
-
container.currentNodes = [];
|
|
3774
|
-
container.nextNodes = [];
|
|
3775
|
-
container.orderedBlocks.length = 0;
|
|
3776
|
-
container.nextOrderedBlocks.length = 0;
|
|
3777
|
-
container.orderedIndexByKey.clear();
|
|
3778
|
-
return;
|
|
3779
|
-
}
|
|
3780
|
-
const range = document.createRange();
|
|
3781
|
-
range.setStartBefore(startMarker);
|
|
3782
|
-
range.setEndAfter(endMarker);
|
|
3783
|
-
range.deleteContents();
|
|
3784
|
-
container.currentNodes = [];
|
|
3785
|
-
container.nextNodes = [];
|
|
3786
|
-
container.nextBlocks.clear();
|
|
3787
|
-
container.orderedBlocks.length = 0;
|
|
3788
|
-
container.nextOrderedBlocks.length = 0;
|
|
3789
|
-
container.orderedIndexByKey.clear();
|
|
3790
|
-
};
|
|
3791
|
-
const container = {
|
|
3792
|
-
startMarker,
|
|
3793
|
-
endMarker,
|
|
3794
|
-
blocks: /* @__PURE__ */ new Map(),
|
|
3795
|
-
nextBlocks: /* @__PURE__ */ new Map(),
|
|
3796
|
-
currentNodes: [startMarker, endMarker],
|
|
3797
|
-
nextNodes: [],
|
|
3798
|
-
orderedBlocks: [],
|
|
3799
|
-
nextOrderedBlocks: [],
|
|
3800
|
-
orderedIndexByKey: /* @__PURE__ */ new Map(),
|
|
3801
|
-
dispose
|
|
3802
|
-
};
|
|
3803
|
-
return container;
|
|
3804
|
-
}
|
|
3805
|
-
function createKeyedBlock(key, item, index, render2, needsIndex = true, hostRoot) {
|
|
3806
|
-
const itemSig = createVersionedSignalAccessor(item);
|
|
3807
|
-
const indexSig = needsIndex ? signal(index) : ((next) => {
|
|
3808
|
-
if (arguments.length === 0) return index;
|
|
3809
|
-
index = next;
|
|
3810
|
-
return index;
|
|
3811
|
-
});
|
|
3812
|
-
const root = createRootContext(hostRoot);
|
|
3813
|
-
const prevRoot = pushRoot(root);
|
|
3814
|
-
let nodes = [];
|
|
3815
|
-
let scopeDispose;
|
|
3816
|
-
const prevSub = setActiveSub(void 0);
|
|
3817
|
-
try {
|
|
3818
|
-
scopeDispose = effectScope(() => {
|
|
3819
|
-
const rendered = render2(itemSig, indexSig, key);
|
|
3820
|
-
if (rendered instanceof Node || Array.isArray(rendered) && rendered.every((n) => n instanceof Node)) {
|
|
3821
|
-
nodes = toNodeArray(rendered);
|
|
3822
|
-
} else {
|
|
3823
|
-
const element = createElement(rendered);
|
|
3824
|
-
nodes = toNodeArray(element);
|
|
2831
|
+
} finally {
|
|
2832
|
+
popRoot(prev);
|
|
2833
|
+
flushOnMount(providerRoot);
|
|
3825
2834
|
}
|
|
2835
|
+
cleanup = () => {
|
|
2836
|
+
destroyRoot(providerRoot);
|
|
2837
|
+
removeNodes(nodes);
|
|
2838
|
+
};
|
|
2839
|
+
activeNodes = nodes;
|
|
2840
|
+
};
|
|
2841
|
+
createRenderEffect(() => {
|
|
2842
|
+
contextMap.set(id, props.value);
|
|
2843
|
+
renderChildren(props.children);
|
|
3826
2844
|
});
|
|
3827
|
-
|
|
3828
|
-
root.cleanups.push(scopeDispose);
|
|
3829
|
-
}
|
|
3830
|
-
} finally {
|
|
3831
|
-
setActiveSub(prevSub);
|
|
3832
|
-
popRoot(prevRoot);
|
|
3833
|
-
}
|
|
3834
|
-
return {
|
|
3835
|
-
key,
|
|
3836
|
-
nodes,
|
|
3837
|
-
root,
|
|
3838
|
-
item: itemSig,
|
|
3839
|
-
index: indexSig,
|
|
3840
|
-
rawItem: item,
|
|
3841
|
-
rawIndex: index
|
|
2845
|
+
return fragment;
|
|
3842
2846
|
};
|
|
2847
|
+
return context;
|
|
3843
2848
|
}
|
|
3844
|
-
function
|
|
3845
|
-
let
|
|
3846
|
-
while (
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
return false;
|
|
3851
|
-
}
|
|
3852
|
-
function reorderBySwap(parent, first, second) {
|
|
3853
|
-
if (first === second) return false;
|
|
3854
|
-
const firstNodes = first.nodes;
|
|
3855
|
-
const secondNodes = second.nodes;
|
|
3856
|
-
if (firstNodes.length === 0 || secondNodes.length === 0) return false;
|
|
3857
|
-
const lastFirst = firstNodes[firstNodes.length - 1];
|
|
3858
|
-
const lastSecond = secondNodes[secondNodes.length - 1];
|
|
3859
|
-
const afterFirst = lastFirst.nextSibling;
|
|
3860
|
-
const afterSecond = lastSecond.nextSibling;
|
|
3861
|
-
moveNodesBefore(parent, firstNodes, afterSecond);
|
|
3862
|
-
moveNodesBefore(parent, secondNodes, afterFirst);
|
|
3863
|
-
return true;
|
|
3864
|
-
}
|
|
3865
|
-
function getLISIndices(sequence) {
|
|
3866
|
-
const predecessors = new Array(sequence.length);
|
|
3867
|
-
const result = [];
|
|
3868
|
-
for (let i = 0; i < sequence.length; i++) {
|
|
3869
|
-
const value = sequence[i];
|
|
3870
|
-
if (value < 0) {
|
|
3871
|
-
predecessors[i] = -1;
|
|
3872
|
-
continue;
|
|
3873
|
-
}
|
|
3874
|
-
let low = 0;
|
|
3875
|
-
let high = result.length;
|
|
3876
|
-
while (low < high) {
|
|
3877
|
-
const mid = low + high >> 1;
|
|
3878
|
-
if (sequence[result[mid]] < value) {
|
|
3879
|
-
low = mid + 1;
|
|
3880
|
-
} else {
|
|
3881
|
-
high = mid;
|
|
3882
|
-
}
|
|
3883
|
-
}
|
|
3884
|
-
predecessors[i] = low > 0 ? result[low - 1] : -1;
|
|
3885
|
-
if (low === result.length) {
|
|
3886
|
-
result.push(i);
|
|
3887
|
-
} else {
|
|
3888
|
-
result[low] = i;
|
|
2849
|
+
function useContext(context) {
|
|
2850
|
+
let root = getCurrentRoot();
|
|
2851
|
+
while (root) {
|
|
2852
|
+
const contextMap = contextStorage.get(root);
|
|
2853
|
+
if (contextMap && contextMap.has(context.id)) {
|
|
2854
|
+
return contextMap.get(context.id);
|
|
3889
2855
|
}
|
|
2856
|
+
root = root.parent;
|
|
3890
2857
|
}
|
|
3891
|
-
|
|
3892
|
-
let k = result.length > 0 ? result[result.length - 1] : -1;
|
|
3893
|
-
for (let i = result.length - 1; i >= 0; i--) {
|
|
3894
|
-
lis[i] = k;
|
|
3895
|
-
k = predecessors[k];
|
|
3896
|
-
}
|
|
3897
|
-
return lis;
|
|
2858
|
+
return context.defaultValue;
|
|
3898
2859
|
}
|
|
3899
|
-
function
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
for (let i = 0; i < next.length; i++) {
|
|
3906
|
-
const position = positions.get(next[i]);
|
|
3907
|
-
if (position === void 0) return false;
|
|
3908
|
-
sequence[i] = position;
|
|
3909
|
-
}
|
|
3910
|
-
const lisIndices = getLISIndices(sequence);
|
|
3911
|
-
if (lisIndices.length === sequence.length) return true;
|
|
3912
|
-
const inLIS = new Array(sequence.length).fill(false);
|
|
3913
|
-
for (let i = 0; i < lisIndices.length; i++) {
|
|
3914
|
-
inLIS[lisIndices[i]] = true;
|
|
3915
|
-
}
|
|
3916
|
-
let anchor = endMarker;
|
|
3917
|
-
let moved = false;
|
|
3918
|
-
for (let i = next.length - 1; i >= 0; i--) {
|
|
3919
|
-
const block = next[i];
|
|
3920
|
-
const nodes = block.nodes;
|
|
3921
|
-
if (nodes.length === 0) continue;
|
|
3922
|
-
if (inLIS[i]) {
|
|
3923
|
-
anchor = nodes[0];
|
|
3924
|
-
continue;
|
|
2860
|
+
function hasContext(context) {
|
|
2861
|
+
let root = getCurrentRoot();
|
|
2862
|
+
while (root) {
|
|
2863
|
+
const contextMap = contextStorage.get(root);
|
|
2864
|
+
if (contextMap && contextMap.has(context.id)) {
|
|
2865
|
+
return true;
|
|
3925
2866
|
}
|
|
3926
|
-
|
|
3927
|
-
anchor = nodes[0];
|
|
3928
|
-
moved = true;
|
|
2867
|
+
root = root.parent;
|
|
3929
2868
|
}
|
|
3930
|
-
return
|
|
3931
|
-
}
|
|
3932
|
-
function createKeyedList(getItems, keyFn, renderItem, needsIndex) {
|
|
3933
|
-
const resolvedNeedsIndex = arguments.length >= 4 ? !!needsIndex : renderItem.length > 1;
|
|
3934
|
-
return createFineGrainedKeyedList(getItems, keyFn, renderItem, resolvedNeedsIndex);
|
|
3935
|
-
}
|
|
3936
|
-
function createFineGrainedKeyedList(getItems, keyFn, renderItem, needsIndex) {
|
|
3937
|
-
const container = createKeyedListContainer();
|
|
3938
|
-
const hostRoot = getCurrentRoot();
|
|
3939
|
-
const fragment = document.createDocumentFragment();
|
|
3940
|
-
fragment.append(container.startMarker, container.endMarker);
|
|
3941
|
-
let disposed = false;
|
|
3942
|
-
let effectDispose;
|
|
3943
|
-
let connectObserver = null;
|
|
3944
|
-
let effectStarted = false;
|
|
3945
|
-
let startScheduled = false;
|
|
3946
|
-
const getConnectedParent = () => {
|
|
3947
|
-
const endParent = container.endMarker.parentNode;
|
|
3948
|
-
const startParent = container.startMarker.parentNode;
|
|
3949
|
-
if (endParent && startParent && endParent === startParent && endParent.nodeType !== 11) {
|
|
3950
|
-
return endParent;
|
|
3951
|
-
}
|
|
3952
|
-
return null;
|
|
3953
|
-
};
|
|
3954
|
-
const performDiff = () => {
|
|
3955
|
-
if (disposed) return;
|
|
3956
|
-
const parent = getConnectedParent();
|
|
3957
|
-
if (!parent) return;
|
|
3958
|
-
batch2(() => {
|
|
3959
|
-
const oldBlocks = container.blocks;
|
|
3960
|
-
const newBlocks = container.nextBlocks;
|
|
3961
|
-
const prevOrderedBlocks = container.orderedBlocks;
|
|
3962
|
-
const nextOrderedBlocks = container.nextOrderedBlocks;
|
|
3963
|
-
const orderedIndexByKey = container.orderedIndexByKey;
|
|
3964
|
-
const newItems = getItems();
|
|
3965
|
-
if (newItems.length === 0) {
|
|
3966
|
-
if (oldBlocks.size > 0) {
|
|
3967
|
-
for (const block of oldBlocks.values()) {
|
|
3968
|
-
destroyRoot(block.root);
|
|
3969
|
-
}
|
|
3970
|
-
const range = document.createRange();
|
|
3971
|
-
range.setStartAfter(container.startMarker);
|
|
3972
|
-
range.setEndBefore(container.endMarker);
|
|
3973
|
-
range.deleteContents();
|
|
3974
|
-
}
|
|
3975
|
-
oldBlocks.clear();
|
|
3976
|
-
newBlocks.clear();
|
|
3977
|
-
prevOrderedBlocks.length = 0;
|
|
3978
|
-
nextOrderedBlocks.length = 0;
|
|
3979
|
-
orderedIndexByKey.clear();
|
|
3980
|
-
container.currentNodes.length = 0;
|
|
3981
|
-
container.currentNodes.push(container.startMarker, container.endMarker);
|
|
3982
|
-
container.nextNodes.length = 0;
|
|
3983
|
-
return;
|
|
3984
|
-
}
|
|
3985
|
-
const prevCount = prevOrderedBlocks.length;
|
|
3986
|
-
if (prevCount > 0 && newItems.length === prevCount && orderedIndexByKey.size === prevCount) {
|
|
3987
|
-
let stableOrder = true;
|
|
3988
|
-
const seen = /* @__PURE__ */ new Set();
|
|
3989
|
-
for (let i = 0; i < prevCount; i++) {
|
|
3990
|
-
const item = newItems[i];
|
|
3991
|
-
const key = keyFn(item, i);
|
|
3992
|
-
if (seen.has(key) || prevOrderedBlocks[i].key !== key) {
|
|
3993
|
-
stableOrder = false;
|
|
3994
|
-
break;
|
|
3995
|
-
}
|
|
3996
|
-
seen.add(key);
|
|
3997
|
-
}
|
|
3998
|
-
if (stableOrder) {
|
|
3999
|
-
for (let i = 0; i < prevCount; i++) {
|
|
4000
|
-
const item = newItems[i];
|
|
4001
|
-
const block = prevOrderedBlocks[i];
|
|
4002
|
-
if (block.rawItem !== item) {
|
|
4003
|
-
block.rawItem = item;
|
|
4004
|
-
block.item(item);
|
|
4005
|
-
}
|
|
4006
|
-
if (needsIndex && block.rawIndex !== i) {
|
|
4007
|
-
block.rawIndex = i;
|
|
4008
|
-
block.index(i);
|
|
4009
|
-
}
|
|
4010
|
-
}
|
|
4011
|
-
return;
|
|
4012
|
-
}
|
|
4013
|
-
}
|
|
4014
|
-
newBlocks.clear();
|
|
4015
|
-
nextOrderedBlocks.length = 0;
|
|
4016
|
-
orderedIndexByKey.clear();
|
|
4017
|
-
const createdBlocks = [];
|
|
4018
|
-
let appendCandidate = prevCount > 0 && newItems.length >= prevCount;
|
|
4019
|
-
const appendedBlocks = [];
|
|
4020
|
-
let mismatchCount = 0;
|
|
4021
|
-
let mismatchFirst = -1;
|
|
4022
|
-
let mismatchSecond = -1;
|
|
4023
|
-
let hasDuplicateKey = false;
|
|
4024
|
-
newItems.forEach((item, index) => {
|
|
4025
|
-
const key = keyFn(item, index);
|
|
4026
|
-
let block = oldBlocks.get(key);
|
|
4027
|
-
const existed = block !== void 0;
|
|
4028
|
-
if (block) {
|
|
4029
|
-
if (block.rawItem !== item) {
|
|
4030
|
-
block.rawItem = item;
|
|
4031
|
-
block.item(item);
|
|
4032
|
-
}
|
|
4033
|
-
if (needsIndex && block.rawIndex !== index) {
|
|
4034
|
-
block.rawIndex = index;
|
|
4035
|
-
block.index(index);
|
|
4036
|
-
}
|
|
4037
|
-
}
|
|
4038
|
-
if (block) {
|
|
4039
|
-
newBlocks.set(key, block);
|
|
4040
|
-
oldBlocks.delete(key);
|
|
4041
|
-
} else {
|
|
4042
|
-
const existingBlock = newBlocks.get(key);
|
|
4043
|
-
if (existingBlock) {
|
|
4044
|
-
if (isDev8) {
|
|
4045
|
-
console.warn(
|
|
4046
|
-
`[fict] Duplicate key "${String(key)}" detected in list rendering. Each item should have a unique key. The previous item with this key will be replaced.`
|
|
4047
|
-
);
|
|
4048
|
-
}
|
|
4049
|
-
destroyRoot(existingBlock.root);
|
|
4050
|
-
removeNodes(existingBlock.nodes);
|
|
4051
|
-
}
|
|
4052
|
-
block = createKeyedBlock(key, item, index, renderItem, needsIndex, hostRoot);
|
|
4053
|
-
createdBlocks.push(block);
|
|
4054
|
-
}
|
|
4055
|
-
const resolvedBlock = block;
|
|
4056
|
-
newBlocks.set(key, resolvedBlock);
|
|
4057
|
-
const position = orderedIndexByKey.get(key);
|
|
4058
|
-
if (position !== void 0) {
|
|
4059
|
-
appendCandidate = false;
|
|
4060
|
-
hasDuplicateKey = true;
|
|
4061
|
-
const prior = nextOrderedBlocks[position];
|
|
4062
|
-
if (prior && prior !== resolvedBlock) {
|
|
4063
|
-
destroyRoot(prior.root);
|
|
4064
|
-
removeNodes(prior.nodes);
|
|
4065
|
-
}
|
|
4066
|
-
nextOrderedBlocks[position] = resolvedBlock;
|
|
4067
|
-
} else {
|
|
4068
|
-
if (appendCandidate) {
|
|
4069
|
-
if (index < prevCount) {
|
|
4070
|
-
if (!prevOrderedBlocks[index] || prevOrderedBlocks[index].key !== key) {
|
|
4071
|
-
appendCandidate = false;
|
|
4072
|
-
}
|
|
4073
|
-
} else if (existed) {
|
|
4074
|
-
appendCandidate = false;
|
|
4075
|
-
}
|
|
4076
|
-
}
|
|
4077
|
-
const nextIndex = nextOrderedBlocks.length;
|
|
4078
|
-
orderedIndexByKey.set(key, nextIndex);
|
|
4079
|
-
nextOrderedBlocks.push(resolvedBlock);
|
|
4080
|
-
if (mismatchCount < 3 && (nextIndex >= prevCount || prevOrderedBlocks[nextIndex] !== resolvedBlock)) {
|
|
4081
|
-
if (mismatchCount === 0) {
|
|
4082
|
-
mismatchFirst = nextIndex;
|
|
4083
|
-
} else if (mismatchCount === 1) {
|
|
4084
|
-
mismatchSecond = nextIndex;
|
|
4085
|
-
}
|
|
4086
|
-
mismatchCount++;
|
|
4087
|
-
}
|
|
4088
|
-
}
|
|
4089
|
-
if (appendCandidate && index >= prevCount) {
|
|
4090
|
-
appendedBlocks.push(resolvedBlock);
|
|
4091
|
-
}
|
|
4092
|
-
});
|
|
4093
|
-
const canAppend = appendCandidate && prevCount > 0 && newItems.length > prevCount && oldBlocks.size === 0 && appendedBlocks.length > 0;
|
|
4094
|
-
if (canAppend) {
|
|
4095
|
-
const appendedNodes = [];
|
|
4096
|
-
for (const block of appendedBlocks) {
|
|
4097
|
-
for (let i = 0; i < block.nodes.length; i++) {
|
|
4098
|
-
appendedNodes.push(block.nodes[i]);
|
|
4099
|
-
}
|
|
4100
|
-
}
|
|
4101
|
-
if (appendedNodes.length > 0) {
|
|
4102
|
-
insertNodesBefore(parent, appendedNodes, container.endMarker);
|
|
4103
|
-
const currentNodes = container.currentNodes;
|
|
4104
|
-
currentNodes.pop();
|
|
4105
|
-
for (let i = 0; i < appendedNodes.length; i++) {
|
|
4106
|
-
currentNodes.push(appendedNodes[i]);
|
|
4107
|
-
}
|
|
4108
|
-
currentNodes.push(container.endMarker);
|
|
4109
|
-
}
|
|
4110
|
-
container.blocks = newBlocks;
|
|
4111
|
-
container.nextBlocks = oldBlocks;
|
|
4112
|
-
container.orderedBlocks = nextOrderedBlocks;
|
|
4113
|
-
container.nextOrderedBlocks = prevOrderedBlocks;
|
|
4114
|
-
for (const block of createdBlocks) {
|
|
4115
|
-
if (newBlocks.get(block.key) === block) {
|
|
4116
|
-
flushOnMount(block.root);
|
|
4117
|
-
}
|
|
4118
|
-
}
|
|
4119
|
-
return;
|
|
4120
|
-
}
|
|
4121
|
-
if (oldBlocks.size > 0) {
|
|
4122
|
-
for (const block of oldBlocks.values()) {
|
|
4123
|
-
destroyRoot(block.root);
|
|
4124
|
-
removeNodes(block.nodes);
|
|
4125
|
-
}
|
|
4126
|
-
oldBlocks.clear();
|
|
4127
|
-
}
|
|
4128
|
-
const canReorderInPlace = createdBlocks.length === 0 && oldBlocks.size === 0 && nextOrderedBlocks.length === prevOrderedBlocks.length;
|
|
4129
|
-
let skipReconcile = false;
|
|
4130
|
-
let updateNodeBuffer = true;
|
|
4131
|
-
if (canReorderInPlace && nextOrderedBlocks.length > 0 && !hasDuplicateKey) {
|
|
4132
|
-
if (mismatchCount === 0) {
|
|
4133
|
-
skipReconcile = true;
|
|
4134
|
-
updateNodeBuffer = false;
|
|
4135
|
-
} else if (mismatchCount === 2 && prevOrderedBlocks[mismatchFirst] === nextOrderedBlocks[mismatchSecond] && prevOrderedBlocks[mismatchSecond] === nextOrderedBlocks[mismatchFirst]) {
|
|
4136
|
-
if (reorderBySwap(
|
|
4137
|
-
parent,
|
|
4138
|
-
prevOrderedBlocks[mismatchFirst],
|
|
4139
|
-
prevOrderedBlocks[mismatchSecond]
|
|
4140
|
-
)) {
|
|
4141
|
-
skipReconcile = true;
|
|
4142
|
-
}
|
|
4143
|
-
} else if (reorderByLIS(parent, container.endMarker, prevOrderedBlocks, nextOrderedBlocks)) {
|
|
4144
|
-
skipReconcile = true;
|
|
4145
|
-
}
|
|
4146
|
-
}
|
|
4147
|
-
if (!skipReconcile && (newBlocks.size > 0 || container.currentNodes.length > 0)) {
|
|
4148
|
-
const prevNodes = container.currentNodes;
|
|
4149
|
-
const nextNodes = container.nextNodes;
|
|
4150
|
-
nextNodes.length = 0;
|
|
4151
|
-
nextNodes.push(container.startMarker);
|
|
4152
|
-
for (let i = 0; i < nextOrderedBlocks.length; i++) {
|
|
4153
|
-
const nodes = nextOrderedBlocks[i].nodes;
|
|
4154
|
-
for (let j = 0; j < nodes.length; j++) {
|
|
4155
|
-
nextNodes.push(nodes[j]);
|
|
4156
|
-
}
|
|
4157
|
-
}
|
|
4158
|
-
nextNodes.push(container.endMarker);
|
|
4159
|
-
reconcileArrays(parent, prevNodes, nextNodes);
|
|
4160
|
-
container.currentNodes = nextNodes;
|
|
4161
|
-
container.nextNodes = prevNodes;
|
|
4162
|
-
} else if (skipReconcile && updateNodeBuffer) {
|
|
4163
|
-
const prevNodes = container.currentNodes;
|
|
4164
|
-
const nextNodes = container.nextNodes;
|
|
4165
|
-
nextNodes.length = 0;
|
|
4166
|
-
nextNodes.push(container.startMarker);
|
|
4167
|
-
for (let i = 0; i < nextOrderedBlocks.length; i++) {
|
|
4168
|
-
const nodes = nextOrderedBlocks[i].nodes;
|
|
4169
|
-
for (let j = 0; j < nodes.length; j++) {
|
|
4170
|
-
nextNodes.push(nodes[j]);
|
|
4171
|
-
}
|
|
4172
|
-
}
|
|
4173
|
-
nextNodes.push(container.endMarker);
|
|
4174
|
-
container.currentNodes = nextNodes;
|
|
4175
|
-
container.nextNodes = prevNodes;
|
|
4176
|
-
}
|
|
4177
|
-
container.blocks = newBlocks;
|
|
4178
|
-
container.nextBlocks = oldBlocks;
|
|
4179
|
-
container.orderedBlocks = nextOrderedBlocks;
|
|
4180
|
-
container.nextOrderedBlocks = prevOrderedBlocks;
|
|
4181
|
-
for (const block of createdBlocks) {
|
|
4182
|
-
if (newBlocks.get(block.key) === block) {
|
|
4183
|
-
flushOnMount(block.root);
|
|
4184
|
-
}
|
|
4185
|
-
}
|
|
4186
|
-
});
|
|
4187
|
-
};
|
|
4188
|
-
const disconnectObserver = () => {
|
|
4189
|
-
connectObserver?.disconnect();
|
|
4190
|
-
connectObserver = null;
|
|
4191
|
-
};
|
|
4192
|
-
const ensureEffectStarted = () => {
|
|
4193
|
-
if (disposed || effectStarted) return effectStarted;
|
|
4194
|
-
const parent = getConnectedParent();
|
|
4195
|
-
if (!parent) return false;
|
|
4196
|
-
const start = () => {
|
|
4197
|
-
effectDispose = createRenderEffect(performDiff);
|
|
4198
|
-
effectStarted = true;
|
|
4199
|
-
};
|
|
4200
|
-
if (hostRoot) {
|
|
4201
|
-
const prev = pushRoot(hostRoot);
|
|
4202
|
-
try {
|
|
4203
|
-
start();
|
|
4204
|
-
} finally {
|
|
4205
|
-
popRoot(prev);
|
|
4206
|
-
}
|
|
4207
|
-
} else {
|
|
4208
|
-
start();
|
|
4209
|
-
}
|
|
4210
|
-
return true;
|
|
4211
|
-
};
|
|
4212
|
-
const waitForConnection = () => {
|
|
4213
|
-
if (connectObserver || typeof MutationObserver === "undefined") return;
|
|
4214
|
-
connectObserver = new MutationObserver(() => {
|
|
4215
|
-
if (disposed) return;
|
|
4216
|
-
if (getConnectedParent()) {
|
|
4217
|
-
disconnectObserver();
|
|
4218
|
-
if (ensureEffectStarted()) {
|
|
4219
|
-
flush();
|
|
4220
|
-
}
|
|
4221
|
-
}
|
|
4222
|
-
});
|
|
4223
|
-
connectObserver.observe(document, { childList: true, subtree: true });
|
|
4224
|
-
};
|
|
4225
|
-
const scheduleStart = () => {
|
|
4226
|
-
if (startScheduled || disposed || effectStarted) return;
|
|
4227
|
-
startScheduled = true;
|
|
4228
|
-
const run = () => {
|
|
4229
|
-
startScheduled = false;
|
|
4230
|
-
if (!ensureEffectStarted()) {
|
|
4231
|
-
waitForConnection();
|
|
4232
|
-
}
|
|
4233
|
-
};
|
|
4234
|
-
if (typeof queueMicrotask === "function") {
|
|
4235
|
-
queueMicrotask(run);
|
|
4236
|
-
} else {
|
|
4237
|
-
Promise.resolve().then(run).catch(() => void 0);
|
|
4238
|
-
}
|
|
4239
|
-
};
|
|
4240
|
-
scheduleStart();
|
|
4241
|
-
return {
|
|
4242
|
-
get marker() {
|
|
4243
|
-
scheduleStart();
|
|
4244
|
-
return fragment;
|
|
4245
|
-
},
|
|
4246
|
-
startMarker: container.startMarker,
|
|
4247
|
-
endMarker: container.endMarker,
|
|
4248
|
-
// Flush pending items - call after markers are inserted into DOM
|
|
4249
|
-
flush: () => {
|
|
4250
|
-
if (disposed) return;
|
|
4251
|
-
scheduleStart();
|
|
4252
|
-
if (ensureEffectStarted()) {
|
|
4253
|
-
flush();
|
|
4254
|
-
} else {
|
|
4255
|
-
waitForConnection();
|
|
4256
|
-
}
|
|
4257
|
-
},
|
|
4258
|
-
dispose: () => {
|
|
4259
|
-
disposed = true;
|
|
4260
|
-
effectDispose?.();
|
|
4261
|
-
disconnectObserver();
|
|
4262
|
-
container.dispose();
|
|
4263
|
-
}
|
|
4264
|
-
};
|
|
2869
|
+
return false;
|
|
4265
2870
|
}
|
|
4266
2871
|
export {
|
|
4267
|
-
$effect,
|
|
4268
|
-
$memo,
|
|
4269
|
-
$state,
|
|
4270
|
-
Aliases,
|
|
4271
|
-
BooleanAttributes,
|
|
4272
|
-
ChildProperties,
|
|
4273
|
-
DelegatedEvents,
|
|
4274
2872
|
ErrorBoundary,
|
|
4275
2873
|
Fragment,
|
|
4276
|
-
Properties,
|
|
4277
|
-
SVGElements,
|
|
4278
|
-
SVGNamespace,
|
|
4279
2874
|
Suspense,
|
|
4280
|
-
UnitlessStyles,
|
|
4281
|
-
__fictPopContext,
|
|
4282
|
-
__fictProp,
|
|
4283
|
-
__fictPropsRest,
|
|
4284
|
-
__fictPushContext,
|
|
4285
|
-
__fictRender,
|
|
4286
|
-
__fictResetContext,
|
|
4287
|
-
__fictUseContext,
|
|
4288
|
-
__fictUseEffect,
|
|
4289
|
-
__fictUseMemo,
|
|
4290
|
-
__fictUseSignal,
|
|
4291
|
-
addEventListener,
|
|
4292
|
-
assign,
|
|
4293
2875
|
batch2 as batch,
|
|
4294
|
-
|
|
4295
|
-
bindClass,
|
|
4296
|
-
bindEvent,
|
|
4297
|
-
bindProperty,
|
|
4298
|
-
bindRef,
|
|
4299
|
-
bindStyle,
|
|
4300
|
-
bindText,
|
|
4301
|
-
callEventHandler,
|
|
4302
|
-
classList,
|
|
4303
|
-
clearDelegatedEvents,
|
|
4304
|
-
createAttributeBinding,
|
|
4305
|
-
createChildBinding,
|
|
4306
|
-
createClassBinding,
|
|
4307
|
-
createConditional,
|
|
2876
|
+
createContext,
|
|
4308
2877
|
createEffect,
|
|
4309
2878
|
createElement,
|
|
4310
|
-
createKeyedList,
|
|
4311
2879
|
createMemo,
|
|
4312
2880
|
createPortal,
|
|
4313
|
-
createPropsProxy,
|
|
4314
2881
|
createRef,
|
|
4315
|
-
createRenderEffect,
|
|
4316
2882
|
createRoot,
|
|
4317
|
-
createScope,
|
|
4318
|
-
createSelector,
|
|
4319
|
-
createShow,
|
|
4320
|
-
signal as createSignal,
|
|
4321
|
-
createStore,
|
|
4322
|
-
createStyleBinding,
|
|
4323
2883
|
createSuspenseToken,
|
|
4324
|
-
|
|
4325
|
-
createVersionedSignal,
|
|
4326
|
-
delegateEvents,
|
|
4327
|
-
effectScope,
|
|
4328
|
-
getDevtoolsHook,
|
|
4329
|
-
getPropAlias,
|
|
4330
|
-
insert,
|
|
4331
|
-
insertNodesBefore,
|
|
4332
|
-
isNodeBetweenMarkers,
|
|
4333
|
-
isReactive,
|
|
2884
|
+
hasContext,
|
|
4334
2885
|
mergeProps,
|
|
4335
|
-
moveNodesBefore,
|
|
4336
2886
|
onCleanup,
|
|
4337
2887
|
onDestroy,
|
|
4338
2888
|
onMount,
|
|
4339
|
-
|
|
4340
|
-
reconcileArrays,
|
|
4341
|
-
removeNodes,
|
|
2889
|
+
prop,
|
|
4342
2890
|
render,
|
|
4343
|
-
runInScope,
|
|
4344
|
-
setCycleProtectionOptions,
|
|
4345
|
-
spread,
|
|
4346
2891
|
startTransition,
|
|
4347
|
-
template,
|
|
4348
|
-
toNodeArray,
|
|
4349
2892
|
untrack2 as untrack,
|
|
4350
|
-
|
|
2893
|
+
useContext,
|
|
4351
2894
|
useDeferredValue,
|
|
4352
|
-
useProp,
|
|
4353
2895
|
useTransition
|
|
4354
2896
|
};
|
|
4355
2897
|
//# sourceMappingURL=index.dev.js.map
|