@fictjs/runtime 0.5.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/advanced.cjs +13 -9
- package/dist/advanced.cjs.map +1 -1
- package/dist/advanced.d.cts +4 -4
- package/dist/advanced.d.ts +4 -4
- package/dist/advanced.js +8 -4
- package/dist/advanced.js.map +1 -1
- package/dist/{chunk-D2IWOO4X.js → chunk-4LCHQ7U4.js} +250 -99
- package/dist/chunk-4LCHQ7U4.js.map +1 -0
- package/dist/{chunk-LRFMCJY3.js → chunk-7YQK3XKY.js} +120 -27
- package/dist/chunk-7YQK3XKY.js.map +1 -0
- package/dist/{chunk-QB2UD62G.cjs → chunk-CEV6TO5U.cjs} +8 -8
- package/dist/{chunk-QB2UD62G.cjs.map → chunk-CEV6TO5U.cjs.map} +1 -1
- package/dist/{chunk-ZR435MDC.cjs → chunk-FSCBL7RI.cjs} +120 -27
- package/dist/chunk-FSCBL7RI.cjs.map +1 -0
- package/dist/{chunk-KNGHYGK4.cjs → chunk-HHDHQGJY.cjs} +17 -17
- package/dist/{chunk-KNGHYGK4.cjs.map → chunk-HHDHQGJY.cjs.map} +1 -1
- package/dist/{chunk-Z6M3HKLG.cjs → chunk-PRF4QG73.cjs} +400 -249
- package/dist/chunk-PRF4QG73.cjs.map +1 -0
- package/dist/{chunk-4NUHM77Z.js → chunk-TLDT76RV.js} +3 -3
- package/dist/{chunk-SLFAEVKJ.js → chunk-WRU3IZOA.js} +3 -3
- package/dist/{context-CTBE00S_.d.cts → context-BFbHf9nC.d.cts} +1 -1
- package/dist/{context-lkLhbkFJ.d.ts → context-C4vBQbb4.d.ts} +1 -1
- package/dist/{effect-BpSNEJJz.d.cts → effect-DAzpH7Mm.d.cts} +33 -1
- package/dist/{effect-BpSNEJJz.d.ts → effect-DAzpH7Mm.d.ts} +33 -1
- package/dist/index.cjs +42 -42
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.dev.js +206 -46
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/internal.cjs +55 -41
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +3 -3
- package/dist/internal.d.ts +3 -3
- package/dist/internal.js +17 -3
- package/dist/internal.js.map +1 -1
- package/dist/loader.cjs +9 -9
- package/dist/loader.js +1 -1
- package/dist/{props-XTHYD19o.d.cts → props-84UJeWO8.d.cts} +1 -1
- package/dist/{props-x-HbI-jX.d.ts → props-BRhFK50f.d.ts} +1 -1
- package/dist/{scope-CdbGmsFf.d.ts → scope-D3DpsfoG.d.ts} +1 -1
- package/dist/{scope-DfcP9I-A.d.cts → scope-DlCBL1Ft.d.cts} +1 -1
- package/package.json +1 -1
- package/src/advanced.ts +1 -1
- package/src/binding.ts +229 -101
- package/src/constants.ts +1 -1
- package/src/cycle-guard.ts +4 -3
- package/src/dom.ts +15 -4
- package/src/hooks.ts +1 -1
- package/src/internal.ts +7 -0
- package/src/lifecycle.ts +1 -1
- package/src/props.ts +60 -1
- package/src/signal.ts +60 -10
- package/src/store.ts +131 -18
- package/src/transition.ts +46 -9
- package/dist/chunk-D2IWOO4X.js.map +0 -1
- package/dist/chunk-LRFMCJY3.js.map +0 -1
- package/dist/chunk-Z6M3HKLG.cjs.map +0 -1
- package/dist/chunk-ZR435MDC.cjs.map +0 -1
- package/dist/jsx-dev-runtime.d.cts +0 -671
- package/dist/jsx-dev-runtime.d.ts +0 -671
- /package/dist/{chunk-4NUHM77Z.js.map → chunk-TLDT76RV.js.map} +0 -0
- /package/dist/{chunk-SLFAEVKJ.js.map → chunk-WRU3IZOA.js.map} +0 -0
package/dist/index.dev.js
CHANGED
|
@@ -8,7 +8,7 @@ function getDevtoolsHook() {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
// src/cycle-guard.ts
|
|
11
|
-
var isDev = true ? true : typeof process
|
|
11
|
+
var isDev = true ? true : typeof process !== "undefined" && process.env?.NODE_ENV !== "production";
|
|
12
12
|
var setCycleProtectionOptions = () => {
|
|
13
13
|
};
|
|
14
14
|
var resetCycleProtectionStateForTests = () => {
|
|
@@ -22,7 +22,8 @@ var enterRootGuard = () => true;
|
|
|
22
22
|
var exitRootGuard = () => {
|
|
23
23
|
};
|
|
24
24
|
var defaultOptions = {
|
|
25
|
-
|
|
25
|
+
// Keep cycle guards on in production to avoid infinite flush loops.
|
|
26
|
+
enabled: true,
|
|
26
27
|
maxFlushCyclesPerMicrotask: 1e4,
|
|
27
28
|
maxEffectRunsPerFlush: 2e4,
|
|
28
29
|
windowSize: 5,
|
|
@@ -175,7 +176,7 @@ var reportCycle = (reason, detail = void 0) => {
|
|
|
175
176
|
};
|
|
176
177
|
|
|
177
178
|
// src/lifecycle.ts
|
|
178
|
-
var isDev2 = true ? true : typeof process
|
|
179
|
+
var isDev2 = true ? true : typeof process !== "undefined" && process.env?.NODE_ENV !== "production";
|
|
179
180
|
var currentRoot;
|
|
180
181
|
var currentEffectCleanups;
|
|
181
182
|
var globalErrorHandlers = /* @__PURE__ */ new WeakMap();
|
|
@@ -493,7 +494,7 @@ function createRenderEffect(fn) {
|
|
|
493
494
|
}
|
|
494
495
|
|
|
495
496
|
// src/hooks.ts
|
|
496
|
-
var isDev3 = true ? true : typeof process
|
|
497
|
+
var isDev3 = true ? true : typeof process !== "undefined" && process.env?.NODE_ENV !== "production";
|
|
497
498
|
var ctxStack = [];
|
|
498
499
|
var preparedContext = null;
|
|
499
500
|
function __fictPushContext() {
|
|
@@ -511,7 +512,7 @@ function __fictPopContext() {
|
|
|
511
512
|
}
|
|
512
513
|
|
|
513
514
|
// src/signal.ts
|
|
514
|
-
var isDev4 = true ? true : typeof process
|
|
515
|
+
var isDev4 = true ? true : typeof process !== "undefined" && process.env?.NODE_ENV !== "production";
|
|
515
516
|
var Mutable = 1;
|
|
516
517
|
var Watching = 2;
|
|
517
518
|
var Running = 4;
|
|
@@ -803,6 +804,7 @@ function updateComputed(c) {
|
|
|
803
804
|
} catch (e) {
|
|
804
805
|
activeSub = prevSub;
|
|
805
806
|
c.flags &= ~Running;
|
|
807
|
+
purgeDeps(c);
|
|
806
808
|
throw e;
|
|
807
809
|
}
|
|
808
810
|
}
|
|
@@ -835,6 +837,7 @@ function runEffect(e) {
|
|
|
835
837
|
} catch (err) {
|
|
836
838
|
activeSub = prevSub;
|
|
837
839
|
e.flags = Watching;
|
|
840
|
+
purgeDeps(e);
|
|
838
841
|
throw err;
|
|
839
842
|
}
|
|
840
843
|
} else if (flags & Pending && e.deps) {
|
|
@@ -872,6 +875,7 @@ function runEffect(e) {
|
|
|
872
875
|
} catch (err) {
|
|
873
876
|
activeSub = prevSub;
|
|
874
877
|
e.flags = Watching;
|
|
878
|
+
purgeDeps(e);
|
|
875
879
|
throw err;
|
|
876
880
|
}
|
|
877
881
|
} else {
|
|
@@ -975,11 +979,11 @@ function signal(initialValue, options2) {
|
|
|
975
979
|
subs: void 0,
|
|
976
980
|
subsTail: void 0,
|
|
977
981
|
flags: Mutable,
|
|
978
|
-
__id: void 0
|
|
979
|
-
...options2?.equals !== void 0 ? { equals: options2.equals } : {},
|
|
980
|
-
...options2?.name !== void 0 ? { name: options2.name } : {},
|
|
981
|
-
...options2?.devToolsSource !== void 0 ? { devToolsSource: options2.devToolsSource } : {}
|
|
982
|
+
__id: void 0
|
|
982
983
|
};
|
|
984
|
+
if (options2?.equals !== void 0) s.equals = options2.equals;
|
|
985
|
+
if (options2?.name !== void 0) s.name = options2.name;
|
|
986
|
+
if (options2?.devToolsSource !== void 0) s.devToolsSource = options2.devToolsSource;
|
|
983
987
|
if (isDev4) registerSignalDevtools(s);
|
|
984
988
|
const accessor = signalOper.bind(s);
|
|
985
989
|
accessor[SIGNAL_MARKER] = true;
|
|
@@ -1034,11 +1038,11 @@ function computed(getter, options2) {
|
|
|
1034
1038
|
depsTail: void 0,
|
|
1035
1039
|
flags: 0,
|
|
1036
1040
|
getter,
|
|
1037
|
-
__id: void 0
|
|
1038
|
-
...options2?.equals !== void 0 ? { equals: options2.equals } : {},
|
|
1039
|
-
...options2?.name !== void 0 ? { name: options2.name } : {},
|
|
1040
|
-
...options2?.devToolsSource !== void 0 ? { devToolsSource: options2.devToolsSource } : {}
|
|
1041
|
+
__id: void 0
|
|
1041
1042
|
};
|
|
1043
|
+
if (options2?.equals !== void 0) c.equals = options2.equals;
|
|
1044
|
+
if (options2?.name !== void 0) c.name = options2.name;
|
|
1045
|
+
if (options2?.devToolsSource !== void 0) c.devToolsSource = options2.devToolsSource;
|
|
1042
1046
|
if (isDev4) registerComputedDevtools(c);
|
|
1043
1047
|
const bound = computedOper.bind(
|
|
1044
1048
|
c
|
|
@@ -1069,14 +1073,21 @@ function computedOper() {
|
|
|
1069
1073
|
this.flags = flags & ~Pending;
|
|
1070
1074
|
}
|
|
1071
1075
|
} else if (!flags) {
|
|
1076
|
+
this.depsTail = void 0;
|
|
1072
1077
|
this.flags = MutableRunning;
|
|
1073
1078
|
const prevSub = setActiveSub(this);
|
|
1074
1079
|
try {
|
|
1075
1080
|
this.value = this.getter(void 0);
|
|
1076
1081
|
if (isDev4) updateComputedDevtools(this, this.value);
|
|
1082
|
+
} catch (err) {
|
|
1083
|
+
this.flags = 0;
|
|
1084
|
+
purgeDeps(this);
|
|
1085
|
+
throw err;
|
|
1077
1086
|
} finally {
|
|
1078
1087
|
setActiveSub(prevSub);
|
|
1079
|
-
this.flags
|
|
1088
|
+
if (this.flags & Running) {
|
|
1089
|
+
this.flags &= ~Running;
|
|
1090
|
+
}
|
|
1080
1091
|
}
|
|
1081
1092
|
}
|
|
1082
1093
|
if (activeSub !== void 0) link(this, activeSub, cycle);
|
|
@@ -1101,13 +1112,23 @@ function effectWithCleanup(fn, cleanupRunner, root) {
|
|
|
1101
1112
|
const prevSub = activeSub;
|
|
1102
1113
|
if (prevSub !== void 0) link(e, prevSub, 0);
|
|
1103
1114
|
activeSub = e;
|
|
1115
|
+
let didThrow = false;
|
|
1116
|
+
let thrown;
|
|
1104
1117
|
try {
|
|
1105
1118
|
if (isDev4) effectRunDevtools(e);
|
|
1106
1119
|
fn();
|
|
1120
|
+
} catch (err) {
|
|
1121
|
+
didThrow = true;
|
|
1122
|
+
thrown = err;
|
|
1107
1123
|
} finally {
|
|
1108
1124
|
activeSub = prevSub;
|
|
1109
|
-
|
|
1125
|
+
if (didThrow) {
|
|
1126
|
+
disposeNode(e);
|
|
1127
|
+
} else {
|
|
1128
|
+
e.flags &= ~Running;
|
|
1129
|
+
}
|
|
1110
1130
|
}
|
|
1131
|
+
if (didThrow) throw thrown;
|
|
1111
1132
|
const disposer = effectOper.bind(e);
|
|
1112
1133
|
disposer[EFFECT_MARKER] = true;
|
|
1113
1134
|
return disposer;
|
|
@@ -1278,15 +1299,48 @@ function startTransition(fn) {
|
|
|
1278
1299
|
}
|
|
1279
1300
|
function useTransition() {
|
|
1280
1301
|
const pending = signal(false);
|
|
1302
|
+
let pendingCount = 0;
|
|
1303
|
+
const beginPending = () => {
|
|
1304
|
+
pendingCount += 1;
|
|
1305
|
+
if (pendingCount === 1) {
|
|
1306
|
+
pending(true);
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
const endPending = () => {
|
|
1310
|
+
if (pendingCount === 0) return;
|
|
1311
|
+
pendingCount -= 1;
|
|
1312
|
+
if (pendingCount === 0) {
|
|
1313
|
+
pending(false);
|
|
1314
|
+
}
|
|
1315
|
+
};
|
|
1281
1316
|
const start = (fn) => {
|
|
1317
|
+
beginPending();
|
|
1318
|
+
let result;
|
|
1319
|
+
let thrown;
|
|
1320
|
+
let didThrow = false;
|
|
1282
1321
|
startTransition(() => {
|
|
1283
|
-
pending(true);
|
|
1284
1322
|
try {
|
|
1285
|
-
fn();
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1323
|
+
result = fn();
|
|
1324
|
+
} catch (err) {
|
|
1325
|
+
thrown = err;
|
|
1326
|
+
didThrow = true;
|
|
1288
1327
|
}
|
|
1289
1328
|
});
|
|
1329
|
+
if (didThrow) {
|
|
1330
|
+
endPending();
|
|
1331
|
+
throw thrown;
|
|
1332
|
+
}
|
|
1333
|
+
if (result && typeof result.then === "function") {
|
|
1334
|
+
Promise.resolve(result).finally(() => {
|
|
1335
|
+
endPending();
|
|
1336
|
+
});
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
if (typeof queueMicrotask === "function") {
|
|
1340
|
+
queueMicrotask(endPending);
|
|
1341
|
+
} else {
|
|
1342
|
+
Promise.resolve().then(endPending);
|
|
1343
|
+
}
|
|
1290
1344
|
};
|
|
1291
1345
|
return [() => pending(), start];
|
|
1292
1346
|
}
|
|
@@ -1342,7 +1396,7 @@ var DelegatedEventNames = [
|
|
|
1342
1396
|
];
|
|
1343
1397
|
|
|
1344
1398
|
// src/constants.ts
|
|
1345
|
-
var isDev5 = true ? true : typeof process
|
|
1399
|
+
var isDev5 = true ? true : typeof process !== "undefined" && process.env?.NODE_ENV !== "production";
|
|
1346
1400
|
var booleans = isDev5 ? [
|
|
1347
1401
|
"allowfullscreen",
|
|
1348
1402
|
"async",
|
|
@@ -1917,22 +1971,53 @@ function __fictRegisterScope(ctx, host, type, props) {
|
|
|
1917
1971
|
}
|
|
1918
1972
|
|
|
1919
1973
|
// src/binding.ts
|
|
1920
|
-
var isDev6 = true ? true : typeof process
|
|
1974
|
+
var isDev6 = true ? true : typeof process !== "undefined" && process.env?.NODE_ENV !== "production";
|
|
1975
|
+
var TEXT_CACHE = Symbol("fict:text");
|
|
1976
|
+
var ATTR_CACHE = Symbol("fict:attr");
|
|
1977
|
+
var PROP_CACHE = Symbol("fict:prop");
|
|
1978
|
+
var STYLE_CACHE = Symbol("fict:style");
|
|
1979
|
+
var CLASS_STATE_CACHE = Symbol("fict:class-state");
|
|
1980
|
+
var CLASS_VALUE_CACHE = Symbol("fict:class-value");
|
|
1981
|
+
var NON_REACTIVE_FN_MARKER = Symbol.for("fict:non-reactive-fn");
|
|
1982
|
+
var REACTIVE_FN_MARKER = Symbol.for("fict:reactive-fn");
|
|
1983
|
+
var NON_REACTIVE_FN_REGISTRY_KEY = Symbol.for("fict:non-reactive-fn-registry");
|
|
1984
|
+
var STYLE_PROP_CACHE = /* @__PURE__ */ new Map();
|
|
1985
|
+
var hasOwn = Object.prototype.hasOwnProperty;
|
|
1986
|
+
function getNonReactiveFnRegistry() {
|
|
1987
|
+
const host = globalThis;
|
|
1988
|
+
let registry = host[NON_REACTIVE_FN_REGISTRY_KEY];
|
|
1989
|
+
if (!registry) {
|
|
1990
|
+
registry = /* @__PURE__ */ new WeakSet();
|
|
1991
|
+
host[NON_REACTIVE_FN_REGISTRY_KEY] = registry;
|
|
1992
|
+
}
|
|
1993
|
+
return registry;
|
|
1994
|
+
}
|
|
1995
|
+
function isExplicitReactiveFn(value) {
|
|
1996
|
+
if (typeof value !== "function") return false;
|
|
1997
|
+
return value[REACTIVE_FN_MARKER] === true;
|
|
1998
|
+
}
|
|
1921
1999
|
function isReactive(value) {
|
|
1922
2000
|
if (typeof value !== "function") return false;
|
|
2001
|
+
if (isNonReactiveFn(value)) return false;
|
|
1923
2002
|
if (isSignal(value) || isComputed(value)) return true;
|
|
2003
|
+
if (isExplicitReactiveFn(value)) return true;
|
|
1924
2004
|
if (isEffect(value) || isEffectScope(value)) return false;
|
|
1925
2005
|
return value.length === 0;
|
|
1926
2006
|
}
|
|
1927
2007
|
function isStrictlyReactive(value) {
|
|
1928
2008
|
if (typeof value !== "function") return false;
|
|
1929
|
-
return isSignal(value) || isComputed(value) || isPropGetterFn(value);
|
|
2009
|
+
return isSignal(value) || isComputed(value) || isPropGetterFn(value) || isExplicitReactiveFn(value);
|
|
1930
2010
|
}
|
|
1931
2011
|
var PROP_GETTER_MARKER = Symbol.for("fict:prop-getter");
|
|
1932
2012
|
function isPropGetterFn(value) {
|
|
1933
2013
|
if (typeof value !== "function") return false;
|
|
1934
2014
|
return value[PROP_GETTER_MARKER] === true;
|
|
1935
2015
|
}
|
|
2016
|
+
function isNonReactiveFn(value) {
|
|
2017
|
+
if (typeof value !== "function") return false;
|
|
2018
|
+
if (getNonReactiveFnRegistry().has(value)) return true;
|
|
2019
|
+
return value[NON_REACTIVE_FN_MARKER] === true;
|
|
2020
|
+
}
|
|
1936
2021
|
function callEventHandler(handler, event, node, data) {
|
|
1937
2022
|
if (!handler) return;
|
|
1938
2023
|
const context = node ?? event.currentTarget ?? void 0;
|
|
@@ -1967,18 +2052,23 @@ function createAttributeBinding(el, key, value, setter) {
|
|
|
1967
2052
|
}
|
|
1968
2053
|
}
|
|
1969
2054
|
function createStyleBinding(el, value) {
|
|
1970
|
-
const target = el;
|
|
1971
2055
|
if (isReactive(value)) {
|
|
1972
|
-
let prev;
|
|
1973
2056
|
createRenderEffect(() => {
|
|
1974
|
-
|
|
1975
|
-
applyStyle(target, next, prev);
|
|
1976
|
-
prev = next;
|
|
2057
|
+
setStyle(el, value());
|
|
1977
2058
|
});
|
|
1978
2059
|
} else {
|
|
1979
|
-
|
|
2060
|
+
setStyle(el, value);
|
|
1980
2061
|
}
|
|
1981
2062
|
}
|
|
2063
|
+
function setStyle(el, value) {
|
|
2064
|
+
const target = el;
|
|
2065
|
+
const cache = target;
|
|
2066
|
+
const prev = cache[STYLE_CACHE];
|
|
2067
|
+
if (typeof value === "string" && prev === value) return;
|
|
2068
|
+
if ((value === null || value === void 0) && (prev === null || prev === void 0)) return;
|
|
2069
|
+
applyStyle(target, value, prev);
|
|
2070
|
+
cache[STYLE_CACHE] = value;
|
|
2071
|
+
}
|
|
1982
2072
|
function applyStyle(el, value, prev) {
|
|
1983
2073
|
if (typeof value === "string") {
|
|
1984
2074
|
el.style.cssText = value;
|
|
@@ -1989,29 +2079,33 @@ function applyStyle(el, value, prev) {
|
|
|
1989
2079
|
}
|
|
1990
2080
|
if (prev && typeof prev === "object") {
|
|
1991
2081
|
const prevStyles = prev;
|
|
1992
|
-
for (const key
|
|
1993
|
-
if (!(key
|
|
1994
|
-
|
|
2082
|
+
for (const key in prevStyles) {
|
|
2083
|
+
if (!hasOwn.call(prevStyles, key)) continue;
|
|
2084
|
+
if (!hasOwn.call(styles, key)) {
|
|
2085
|
+
const cssProperty = normalizeStyleProperty(key);
|
|
1995
2086
|
el.style.removeProperty(cssProperty);
|
|
1996
2087
|
}
|
|
1997
2088
|
}
|
|
1998
2089
|
}
|
|
1999
|
-
for (const
|
|
2090
|
+
for (const prop2 in styles) {
|
|
2091
|
+
if (!hasOwn.call(styles, prop2)) continue;
|
|
2092
|
+
const v = styles[prop2];
|
|
2000
2093
|
if (v != null) {
|
|
2001
|
-
const cssProperty = prop2
|
|
2094
|
+
const cssProperty = normalizeStyleProperty(prop2);
|
|
2002
2095
|
const unitless = isUnitlessStyleProperty(prop2) || isUnitlessStyleProperty(cssProperty);
|
|
2003
2096
|
const valueStr = typeof v === "number" && !unitless ? `${v}px` : String(v);
|
|
2004
2097
|
el.style.setProperty(cssProperty, valueStr);
|
|
2005
2098
|
} else {
|
|
2006
|
-
const cssProperty = prop2
|
|
2099
|
+
const cssProperty = normalizeStyleProperty(prop2);
|
|
2007
2100
|
el.style.removeProperty(cssProperty);
|
|
2008
2101
|
}
|
|
2009
2102
|
}
|
|
2010
2103
|
} else {
|
|
2011
2104
|
if (prev && typeof prev === "object") {
|
|
2012
2105
|
const prevStyles = prev;
|
|
2013
|
-
for (const key
|
|
2014
|
-
|
|
2106
|
+
for (const key in prevStyles) {
|
|
2107
|
+
if (!hasOwn.call(prevStyles, key)) continue;
|
|
2108
|
+
const cssProperty = normalizeStyleProperty(key);
|
|
2015
2109
|
el.style.removeProperty(cssProperty);
|
|
2016
2110
|
}
|
|
2017
2111
|
} else if (typeof prev === "string") {
|
|
@@ -2020,16 +2114,35 @@ function applyStyle(el, value, prev) {
|
|
|
2020
2114
|
}
|
|
2021
2115
|
}
|
|
2022
2116
|
var isUnitlessStyleProperty = isDev6 ? (prop2) => UnitlessStyles.has(prop2) : (prop2) => prop2 === "opacity" || prop2 === "zIndex";
|
|
2117
|
+
function normalizeStyleProperty(prop2) {
|
|
2118
|
+
const cached = STYLE_PROP_CACHE.get(prop2);
|
|
2119
|
+
if (cached) return cached;
|
|
2120
|
+
const normalized = prop2.includes("-") ? prop2 : prop2.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
2121
|
+
STYLE_PROP_CACHE.set(prop2, normalized);
|
|
2122
|
+
return normalized;
|
|
2123
|
+
}
|
|
2023
2124
|
function createClassBinding(el, value) {
|
|
2024
2125
|
if (isReactive(value)) {
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
prev = applyClass(el, next, prev);
|
|
2029
|
-
});
|
|
2126
|
+
createRenderEffect(
|
|
2127
|
+
() => setClass(el, value())
|
|
2128
|
+
);
|
|
2030
2129
|
} else {
|
|
2031
|
-
|
|
2130
|
+
setClass(el, value);
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
function setClass(el, value) {
|
|
2134
|
+
const cache = el;
|
|
2135
|
+
const prevValue = cache[CLASS_VALUE_CACHE];
|
|
2136
|
+
const prevState = cache[CLASS_STATE_CACHE] ?? {};
|
|
2137
|
+
if (typeof value === "string") {
|
|
2138
|
+
if (typeof prevValue === "string" && prevValue === value) return;
|
|
2139
|
+
el.className = value;
|
|
2140
|
+
cache[CLASS_STATE_CACHE] = {};
|
|
2141
|
+
cache[CLASS_VALUE_CACHE] = value;
|
|
2142
|
+
return;
|
|
2032
2143
|
}
|
|
2144
|
+
cache[CLASS_STATE_CACHE] = applyClass(el, value, prevState);
|
|
2145
|
+
cache[CLASS_VALUE_CACHE] = value;
|
|
2033
2146
|
}
|
|
2034
2147
|
function toggleClassKey(node, key, value) {
|
|
2035
2148
|
const classNames = key.trim().split(/\s+/);
|
|
@@ -2335,9 +2448,21 @@ function createPortal(container, render2, createElementFn) {
|
|
|
2335
2448
|
|
|
2336
2449
|
// src/props.ts
|
|
2337
2450
|
var PROP_GETTER_MARKER2 = Symbol.for("fict:prop-getter");
|
|
2451
|
+
var NON_REACTIVE_FN_MARKER2 = Symbol.for("fict:non-reactive-fn");
|
|
2452
|
+
var REACTIVE_FN_MARKER2 = Symbol.for("fict:reactive-fn");
|
|
2453
|
+
var NON_REACTIVE_FN_REGISTRY_KEY2 = Symbol.for("fict:non-reactive-fn-registry");
|
|
2338
2454
|
var propGetters = /* @__PURE__ */ new WeakSet();
|
|
2339
2455
|
var rawToProxy = /* @__PURE__ */ new WeakMap();
|
|
2340
2456
|
var proxyToRaw = /* @__PURE__ */ new WeakMap();
|
|
2457
|
+
function getNonReactiveFnRegistry2() {
|
|
2458
|
+
const host = globalThis;
|
|
2459
|
+
let registry = host[NON_REACTIVE_FN_REGISTRY_KEY2];
|
|
2460
|
+
if (!registry) {
|
|
2461
|
+
registry = /* @__PURE__ */ new WeakSet();
|
|
2462
|
+
host[NON_REACTIVE_FN_REGISTRY_KEY2] = registry;
|
|
2463
|
+
}
|
|
2464
|
+
return registry;
|
|
2465
|
+
}
|
|
2341
2466
|
function __fictProp(getter) {
|
|
2342
2467
|
if (typeof getter === "function" && getter.length === 0) {
|
|
2343
2468
|
propGetters.add(getter);
|
|
@@ -2356,6 +2481,35 @@ function isPropGetter(value) {
|
|
|
2356
2481
|
const fn = value;
|
|
2357
2482
|
return propGetters.has(fn) || fn[PROP_GETTER_MARKER2] === true;
|
|
2358
2483
|
}
|
|
2484
|
+
function isNonReactiveFn2(value) {
|
|
2485
|
+
if (typeof value !== "function") return false;
|
|
2486
|
+
if (getNonReactiveFnRegistry2().has(value)) return true;
|
|
2487
|
+
return value[NON_REACTIVE_FN_MARKER2] === true;
|
|
2488
|
+
}
|
|
2489
|
+
function markNonReactiveFn(fn) {
|
|
2490
|
+
getNonReactiveFnRegistry2().add(fn);
|
|
2491
|
+
if (Object.isExtensible(fn)) {
|
|
2492
|
+
try {
|
|
2493
|
+
;
|
|
2494
|
+
fn[NON_REACTIVE_FN_MARKER2] = true;
|
|
2495
|
+
} catch {
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
return fn;
|
|
2499
|
+
}
|
|
2500
|
+
function isExplicitReactiveFn2(value) {
|
|
2501
|
+
if (typeof value !== "function") return false;
|
|
2502
|
+
return value[REACTIVE_FN_MARKER2] === true;
|
|
2503
|
+
}
|
|
2504
|
+
function normalizePropsFunction(value) {
|
|
2505
|
+
if (typeof value !== "function") return value;
|
|
2506
|
+
if (value.length !== 0) return value;
|
|
2507
|
+
if (isPropGetter(value) || isSignal(value) || isComputed(value) || isExplicitReactiveFn2(value)) {
|
|
2508
|
+
return value;
|
|
2509
|
+
}
|
|
2510
|
+
if (isEffect(value) || isEffectScope(value) || isNonReactiveFn2(value)) return value;
|
|
2511
|
+
return markNonReactiveFn(value);
|
|
2512
|
+
}
|
|
2359
2513
|
function createPropsProxy(props) {
|
|
2360
2514
|
if (!props || typeof props !== "object") {
|
|
2361
2515
|
return props;
|
|
@@ -2373,7 +2527,7 @@ function createPropsProxy(props) {
|
|
|
2373
2527
|
if (isPropGetter(value)) {
|
|
2374
2528
|
return value();
|
|
2375
2529
|
}
|
|
2376
|
-
return value;
|
|
2530
|
+
return normalizePropsFunction(value);
|
|
2377
2531
|
},
|
|
2378
2532
|
set(target, prop2, value, receiver) {
|
|
2379
2533
|
return Reflect.set(target, prop2, value, receiver);
|
|
@@ -2495,7 +2649,7 @@ function prop(getter, options2) {
|
|
|
2495
2649
|
// src/dom.ts
|
|
2496
2650
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
2497
2651
|
var MATHML_NS = "http://www.w3.org/1998/Math/MathML";
|
|
2498
|
-
var isDev7 = true ? true : typeof process
|
|
2652
|
+
var isDev7 = true ? true : typeof process !== "undefined" && process.env?.NODE_ENV !== "production";
|
|
2499
2653
|
var nextComponentId = 1;
|
|
2500
2654
|
function render(view, container) {
|
|
2501
2655
|
const root = createRootContext();
|
|
@@ -2549,6 +2703,9 @@ function createElementWithContext(node, namespace) {
|
|
|
2549
2703
|
}
|
|
2550
2704
|
return createElementWithContext(resolved, namespace);
|
|
2551
2705
|
}
|
|
2706
|
+
if (typeof node === "function") {
|
|
2707
|
+
return document.createTextNode("");
|
|
2708
|
+
}
|
|
2552
2709
|
if (typeof node === "object" && node !== null && !(node instanceof Node)) {
|
|
2553
2710
|
if ("marker" in node) {
|
|
2554
2711
|
const handle = node;
|
|
@@ -2686,9 +2843,12 @@ function appendChildNode(parent, child, namespace) {
|
|
|
2686
2843
|
child.flush?.();
|
|
2687
2844
|
return;
|
|
2688
2845
|
}
|
|
2689
|
-
if (typeof child === "function"
|
|
2846
|
+
if (typeof child === "function") {
|
|
2690
2847
|
const childGetter = child;
|
|
2691
|
-
|
|
2848
|
+
if (isReactive(childGetter)) {
|
|
2849
|
+
createChildBinding(parent, childGetter, (node) => createElementWithContext(node, namespace));
|
|
2850
|
+
return;
|
|
2851
|
+
}
|
|
2692
2852
|
return;
|
|
2693
2853
|
}
|
|
2694
2854
|
if (Array.isArray(child)) {
|