@fictjs/runtime 0.0.3 → 0.0.5

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/index.js CHANGED
@@ -788,6 +788,21 @@ function effect(fn) {
788
788
  function effectOper() {
789
789
  disposeNode(this);
790
790
  }
791
+ function effectScope(fn) {
792
+ const e = { deps: void 0, depsTail: void 0, subs: void 0, subsTail: void 0, flags: 0 };
793
+ const prevSub = activeSub;
794
+ if (prevSub !== void 0) link(e, prevSub, 0);
795
+ activeSub = e;
796
+ try {
797
+ fn();
798
+ } finally {
799
+ activeSub = prevSub;
800
+ }
801
+ return effectScopeOper.bind(e);
802
+ }
803
+ function effectScopeOper() {
804
+ disposeNode(this);
805
+ }
791
806
  function batch(fn) {
792
807
  ++batchDepth;
793
808
  try {
@@ -1036,471 +1051,190 @@ function createRenderEffect(fn) {
1036
1051
  return teardown;
1037
1052
  }
1038
1053
 
1039
- // src/hooks.ts
1040
- var ctxStack = [];
1041
- function __fictUseContext() {
1042
- if (ctxStack.length === 0) {
1043
- const ctx2 = { slots: [], cursor: 0 };
1044
- ctxStack.push(ctx2);
1045
- return ctx2;
1046
- }
1047
- const ctx = ctxStack[ctxStack.length - 1];
1048
- ctx.cursor = 0;
1049
- return ctx;
1050
- }
1051
- function __fictPushContext() {
1052
- const ctx = { slots: [], cursor: 0 };
1053
- ctxStack.push(ctx);
1054
- return ctx;
1055
- }
1056
- function __fictPopContext() {
1057
- ctxStack.pop();
1058
- }
1059
- function __fictResetContext() {
1060
- ctxStack.length = 0;
1061
- }
1062
- function __fictUseSignal(ctx, initial, slot) {
1063
- const index = slot ?? ctx.cursor++;
1064
- if (!ctx.slots[index]) {
1065
- ctx.slots[index] = signal(initial);
1066
- }
1067
- return ctx.slots[index];
1068
- }
1069
- function __fictUseMemo(ctx, fn, slot) {
1070
- const index = slot ?? ctx.cursor++;
1071
- if (!ctx.slots[index]) {
1072
- ctx.slots[index] = createMemo(fn);
1073
- }
1074
- return ctx.slots[index];
1075
- }
1076
- function __fictUseEffect(ctx, fn, slot) {
1077
- const index = slot ?? ctx.cursor++;
1078
- if (!ctx.slots[index]) {
1079
- ctx.slots[index] = createEffect(fn);
1054
+ // src/constants.ts
1055
+ var booleans = [
1056
+ "allowfullscreen",
1057
+ "async",
1058
+ "alpha",
1059
+ // HTMLInputElement
1060
+ "autofocus",
1061
+ // HTMLElement prop
1062
+ "autoplay",
1063
+ "checked",
1064
+ "controls",
1065
+ "default",
1066
+ "disabled",
1067
+ "formnovalidate",
1068
+ "hidden",
1069
+ // HTMLElement prop
1070
+ "indeterminate",
1071
+ "inert",
1072
+ // HTMLElement prop
1073
+ "ismap",
1074
+ "loop",
1075
+ "multiple",
1076
+ "muted",
1077
+ "nomodule",
1078
+ "novalidate",
1079
+ "open",
1080
+ "playsinline",
1081
+ "readonly",
1082
+ "required",
1083
+ "reversed",
1084
+ "seamless",
1085
+ // HTMLIframeElement - non-standard
1086
+ "selected",
1087
+ // Experimental attributes
1088
+ "adauctionheaders",
1089
+ "browsingtopics",
1090
+ "credentialless",
1091
+ "defaultchecked",
1092
+ "defaultmuted",
1093
+ "defaultselected",
1094
+ "defer",
1095
+ "disablepictureinpicture",
1096
+ "disableremoteplayback",
1097
+ "preservespitch",
1098
+ "shadowrootclonable",
1099
+ "shadowrootcustomelementregistry",
1100
+ "shadowrootdelegatesfocus",
1101
+ "shadowrootserializable",
1102
+ "sharedstoragewritable"
1103
+ ];
1104
+ var BooleanAttributes = new Set(booleans);
1105
+ var Properties = /* @__PURE__ */ new Set([
1106
+ // Core properties
1107
+ "className",
1108
+ "value",
1109
+ // CamelCase booleans
1110
+ "readOnly",
1111
+ "noValidate",
1112
+ "formNoValidate",
1113
+ "isMap",
1114
+ "noModule",
1115
+ "playsInline",
1116
+ // Experimental (camelCase)
1117
+ "adAuctionHeaders",
1118
+ "allowFullscreen",
1119
+ "browsingTopics",
1120
+ "defaultChecked",
1121
+ "defaultMuted",
1122
+ "defaultSelected",
1123
+ "disablePictureInPicture",
1124
+ "disableRemotePlayback",
1125
+ "preservesPitch",
1126
+ "shadowRootClonable",
1127
+ "shadowRootCustomElementRegistry",
1128
+ "shadowRootDelegatesFocus",
1129
+ "shadowRootSerializable",
1130
+ "sharedStorageWritable",
1131
+ // All lowercase booleans
1132
+ ...booleans
1133
+ ]);
1134
+ var ChildProperties = /* @__PURE__ */ new Set([
1135
+ "innerHTML",
1136
+ "textContent",
1137
+ "innerText",
1138
+ "children"
1139
+ ]);
1140
+ var Aliases = {
1141
+ className: "class",
1142
+ htmlFor: "for"
1143
+ };
1144
+ var PropAliases = {
1145
+ // Direct mapping
1146
+ class: "className",
1147
+ // Element-specific mappings
1148
+ novalidate: {
1149
+ $: "noValidate",
1150
+ FORM: 1
1151
+ },
1152
+ formnovalidate: {
1153
+ $: "formNoValidate",
1154
+ BUTTON: 1,
1155
+ INPUT: 1
1156
+ },
1157
+ ismap: {
1158
+ $: "isMap",
1159
+ IMG: 1
1160
+ },
1161
+ nomodule: {
1162
+ $: "noModule",
1163
+ SCRIPT: 1
1164
+ },
1165
+ playsinline: {
1166
+ $: "playsInline",
1167
+ VIDEO: 1
1168
+ },
1169
+ readonly: {
1170
+ $: "readOnly",
1171
+ INPUT: 1,
1172
+ TEXTAREA: 1
1173
+ },
1174
+ // Experimental element-specific
1175
+ adauctionheaders: {
1176
+ $: "adAuctionHeaders",
1177
+ IFRAME: 1
1178
+ },
1179
+ allowfullscreen: {
1180
+ $: "allowFullscreen",
1181
+ IFRAME: 1
1182
+ },
1183
+ browsingtopics: {
1184
+ $: "browsingTopics",
1185
+ IMG: 1
1186
+ },
1187
+ defaultchecked: {
1188
+ $: "defaultChecked",
1189
+ INPUT: 1
1190
+ },
1191
+ defaultmuted: {
1192
+ $: "defaultMuted",
1193
+ AUDIO: 1,
1194
+ VIDEO: 1
1195
+ },
1196
+ defaultselected: {
1197
+ $: "defaultSelected",
1198
+ OPTION: 1
1199
+ },
1200
+ disablepictureinpicture: {
1201
+ $: "disablePictureInPicture",
1202
+ VIDEO: 1
1203
+ },
1204
+ disableremoteplayback: {
1205
+ $: "disableRemotePlayback",
1206
+ AUDIO: 1,
1207
+ VIDEO: 1
1208
+ },
1209
+ preservespitch: {
1210
+ $: "preservesPitch",
1211
+ AUDIO: 1,
1212
+ VIDEO: 1
1213
+ },
1214
+ shadowrootclonable: {
1215
+ $: "shadowRootClonable",
1216
+ TEMPLATE: 1
1217
+ },
1218
+ shadowrootdelegatesfocus: {
1219
+ $: "shadowRootDelegatesFocus",
1220
+ TEMPLATE: 1
1221
+ },
1222
+ shadowrootserializable: {
1223
+ $: "shadowRootSerializable",
1224
+ TEMPLATE: 1
1225
+ },
1226
+ sharedstoragewritable: {
1227
+ $: "sharedStorageWritable",
1228
+ IFRAME: 1,
1229
+ IMG: 1
1080
1230
  }
1081
- }
1082
- function __fictRender(ctx, fn) {
1083
- ctxStack.push(ctx);
1084
- ctx.cursor = 0;
1085
- try {
1086
- return fn();
1087
- } finally {
1088
- ctxStack.pop();
1231
+ };
1232
+ function getPropAlias(prop, tagName) {
1233
+ const a = PropAliases[prop];
1234
+ if (typeof a === "object") {
1235
+ return a[tagName] ? a["$"] : void 0;
1089
1236
  }
1090
- }
1091
-
1092
- // src/versioned-signal.ts
1093
- function createVersionedSignal(initialValue, options2) {
1094
- const equals = options2?.equals ?? Object.is;
1095
- const value = signal(initialValue);
1096
- const version = signal(0);
1097
- const bumpVersion = () => {
1098
- const next = version() + 1;
1099
- version(next);
1100
- };
1101
- return {
1102
- read: () => {
1103
- version();
1104
- return value();
1105
- },
1106
- write: (next) => {
1107
- const prev = value();
1108
- if (!equals(prev, next)) {
1109
- value(next);
1110
- return;
1111
- }
1112
- bumpVersion();
1113
- },
1114
- force: () => {
1115
- bumpVersion();
1116
- },
1117
- peekVersion: () => version(),
1118
- peekValue: () => value()
1119
- };
1120
- }
1121
-
1122
- // src/props.ts
1123
- var propGetters = /* @__PURE__ */ new WeakSet();
1124
- var rawToProxy = /* @__PURE__ */ new WeakMap();
1125
- var proxyToRaw = /* @__PURE__ */ new WeakMap();
1126
- function __fictProp(getter) {
1127
- if (typeof getter === "function" && getter.length === 0) {
1128
- propGetters.add(getter);
1129
- }
1130
- return getter;
1131
- }
1132
- function isPropGetter(value) {
1133
- return typeof value === "function" && propGetters.has(value);
1134
- }
1135
- function createPropsProxy(props) {
1136
- if (!props || typeof props !== "object") {
1137
- return props;
1138
- }
1139
- if (proxyToRaw.has(props)) {
1140
- return props;
1141
- }
1142
- const cached = rawToProxy.get(props);
1143
- if (cached) {
1144
- return cached;
1145
- }
1146
- const proxy = new Proxy(props, {
1147
- get(target, prop, receiver) {
1148
- const value = Reflect.get(target, prop, receiver);
1149
- if (isPropGetter(value)) {
1150
- return value();
1151
- }
1152
- return value;
1153
- },
1154
- set(target, prop, value, receiver) {
1155
- return Reflect.set(target, prop, value, receiver);
1156
- },
1157
- has(target, prop) {
1158
- return prop in target;
1159
- },
1160
- ownKeys(target) {
1161
- return Reflect.ownKeys(target);
1162
- },
1163
- getOwnPropertyDescriptor(target, prop) {
1164
- return Object.getOwnPropertyDescriptor(target, prop);
1165
- }
1166
- });
1167
- rawToProxy.set(props, proxy);
1168
- proxyToRaw.set(proxy, props);
1169
- return proxy;
1170
- }
1171
- function unwrapProps(props) {
1172
- if (!props || typeof props !== "object") {
1173
- return props;
1174
- }
1175
- return proxyToRaw.get(props) ?? props;
1176
- }
1177
- function __fictPropsRest(props, exclude) {
1178
- const raw = unwrapProps(props);
1179
- const out = {};
1180
- const excludeSet = new Set(exclude);
1181
- for (const key of Reflect.ownKeys(raw)) {
1182
- if (excludeSet.has(key)) continue;
1183
- out[key] = raw[key];
1184
- }
1185
- return createPropsProxy(out);
1186
- }
1187
- function mergeProps(...sources) {
1188
- const validSources = sources.filter(
1189
- (s) => s != null && (typeof s === "object" || typeof s === "function")
1190
- );
1191
- if (validSources.length === 0) {
1192
- return {};
1193
- }
1194
- if (validSources.length === 1 && typeof validSources[0] === "object") {
1195
- return validSources[0];
1196
- }
1197
- const resolveSource = (src) => {
1198
- const value = typeof src === "function" ? src() : src;
1199
- if (!value || typeof value !== "object") return void 0;
1200
- return unwrapProps(value);
1201
- };
1202
- return new Proxy({}, {
1203
- get(_, prop) {
1204
- if (typeof prop === "symbol") {
1205
- return void 0;
1206
- }
1207
- for (let i = validSources.length - 1; i >= 0; i--) {
1208
- const src = validSources[i];
1209
- const raw = resolveSource(src);
1210
- if (!raw || !(prop in raw)) continue;
1211
- const value = raw[prop];
1212
- if (typeof src === "function" && !isPropGetter(value)) {
1213
- return __fictProp(() => {
1214
- const latest = resolveSource(src);
1215
- if (!latest || !(prop in latest)) return void 0;
1216
- return latest[prop];
1217
- });
1218
- }
1219
- return value;
1220
- }
1221
- return void 0;
1222
- },
1223
- has(_, prop) {
1224
- for (const src of validSources) {
1225
- const raw = resolveSource(src);
1226
- if (raw && prop in raw) {
1227
- return true;
1228
- }
1229
- }
1230
- return false;
1231
- },
1232
- ownKeys() {
1233
- const keys = /* @__PURE__ */ new Set();
1234
- for (const src of validSources) {
1235
- const raw = resolveSource(src);
1236
- if (raw) {
1237
- for (const key of Reflect.ownKeys(raw)) {
1238
- keys.add(key);
1239
- }
1240
- }
1241
- }
1242
- return Array.from(keys);
1243
- },
1244
- getOwnPropertyDescriptor(_, prop) {
1245
- for (let i = validSources.length - 1; i >= 0; i--) {
1246
- const raw = resolveSource(validSources[i]);
1247
- if (raw && prop in raw) {
1248
- return {
1249
- enumerable: true,
1250
- configurable: true,
1251
- get: () => {
1252
- const value = raw[prop];
1253
- return value;
1254
- }
1255
- };
1256
- }
1257
- }
1258
- return void 0;
1259
- }
1260
- });
1261
- }
1262
- function useProp(getter) {
1263
- return __fictProp(createMemo(getter));
1264
- }
1265
-
1266
- // src/ref.ts
1267
- function createRef() {
1268
- return { current: null };
1269
- }
1270
-
1271
- // src/transition.ts
1272
- function startTransition(fn) {
1273
- const prev = setTransitionContext(true);
1274
- try {
1275
- fn();
1276
- } finally {
1277
- setTransitionContext(prev);
1278
- scheduleFlush();
1279
- }
1280
- }
1281
- function useTransition() {
1282
- const pending = signal(false);
1283
- const start = (fn) => {
1284
- pending(true);
1285
- startTransition(() => {
1286
- try {
1287
- fn();
1288
- } finally {
1289
- pending(false);
1290
- }
1291
- });
1292
- };
1293
- return [() => pending(), start];
1294
- }
1295
- function useDeferredValue(getValue) {
1296
- const deferredValue = signal(getValue());
1297
- createEffect(() => {
1298
- const newValue = getValue();
1299
- const currentDeferred = untrack(() => deferredValue());
1300
- if (currentDeferred !== newValue) {
1301
- startTransition(() => {
1302
- deferredValue(newValue);
1303
- });
1304
- }
1305
- });
1306
- return () => deferredValue();
1307
- }
1308
-
1309
- // src/scheduler.ts
1310
- function batch2(fn) {
1311
- return batch(fn);
1312
- }
1313
- function untrack2(fn) {
1314
- return untrack(fn);
1315
- }
1316
-
1317
- // src/jsx.ts
1318
- var Fragment = Symbol("Fragment");
1319
-
1320
- // src/constants.ts
1321
- var booleans = [
1322
- "allowfullscreen",
1323
- "async",
1324
- "alpha",
1325
- // HTMLInputElement
1326
- "autofocus",
1327
- // HTMLElement prop
1328
- "autoplay",
1329
- "checked",
1330
- "controls",
1331
- "default",
1332
- "disabled",
1333
- "formnovalidate",
1334
- "hidden",
1335
- // HTMLElement prop
1336
- "indeterminate",
1337
- "inert",
1338
- // HTMLElement prop
1339
- "ismap",
1340
- "loop",
1341
- "multiple",
1342
- "muted",
1343
- "nomodule",
1344
- "novalidate",
1345
- "open",
1346
- "playsinline",
1347
- "readonly",
1348
- "required",
1349
- "reversed",
1350
- "seamless",
1351
- // HTMLIframeElement - non-standard
1352
- "selected",
1353
- // Experimental attributes
1354
- "adauctionheaders",
1355
- "browsingtopics",
1356
- "credentialless",
1357
- "defaultchecked",
1358
- "defaultmuted",
1359
- "defaultselected",
1360
- "defer",
1361
- "disablepictureinpicture",
1362
- "disableremoteplayback",
1363
- "preservespitch",
1364
- "shadowrootclonable",
1365
- "shadowrootcustomelementregistry",
1366
- "shadowrootdelegatesfocus",
1367
- "shadowrootserializable",
1368
- "sharedstoragewritable"
1369
- ];
1370
- var BooleanAttributes = new Set(booleans);
1371
- var Properties = /* @__PURE__ */ new Set([
1372
- // Core properties
1373
- "className",
1374
- "value",
1375
- // CamelCase booleans
1376
- "readOnly",
1377
- "noValidate",
1378
- "formNoValidate",
1379
- "isMap",
1380
- "noModule",
1381
- "playsInline",
1382
- // Experimental (camelCase)
1383
- "adAuctionHeaders",
1384
- "allowFullscreen",
1385
- "browsingTopics",
1386
- "defaultChecked",
1387
- "defaultMuted",
1388
- "defaultSelected",
1389
- "disablePictureInPicture",
1390
- "disableRemotePlayback",
1391
- "preservesPitch",
1392
- "shadowRootClonable",
1393
- "shadowRootCustomElementRegistry",
1394
- "shadowRootDelegatesFocus",
1395
- "shadowRootSerializable",
1396
- "sharedStorageWritable",
1397
- // All lowercase booleans
1398
- ...booleans
1399
- ]);
1400
- var ChildProperties = /* @__PURE__ */ new Set([
1401
- "innerHTML",
1402
- "textContent",
1403
- "innerText",
1404
- "children"
1405
- ]);
1406
- var Aliases = {
1407
- className: "class",
1408
- htmlFor: "for"
1409
- };
1410
- var PropAliases = {
1411
- // Direct mapping
1412
- class: "className",
1413
- // Element-specific mappings
1414
- novalidate: {
1415
- $: "noValidate",
1416
- FORM: 1
1417
- },
1418
- formnovalidate: {
1419
- $: "formNoValidate",
1420
- BUTTON: 1,
1421
- INPUT: 1
1422
- },
1423
- ismap: {
1424
- $: "isMap",
1425
- IMG: 1
1426
- },
1427
- nomodule: {
1428
- $: "noModule",
1429
- SCRIPT: 1
1430
- },
1431
- playsinline: {
1432
- $: "playsInline",
1433
- VIDEO: 1
1434
- },
1435
- readonly: {
1436
- $: "readOnly",
1437
- INPUT: 1,
1438
- TEXTAREA: 1
1439
- },
1440
- // Experimental element-specific
1441
- adauctionheaders: {
1442
- $: "adAuctionHeaders",
1443
- IFRAME: 1
1444
- },
1445
- allowfullscreen: {
1446
- $: "allowFullscreen",
1447
- IFRAME: 1
1448
- },
1449
- browsingtopics: {
1450
- $: "browsingTopics",
1451
- IMG: 1
1452
- },
1453
- defaultchecked: {
1454
- $: "defaultChecked",
1455
- INPUT: 1
1456
- },
1457
- defaultmuted: {
1458
- $: "defaultMuted",
1459
- AUDIO: 1,
1460
- VIDEO: 1
1461
- },
1462
- defaultselected: {
1463
- $: "defaultSelected",
1464
- OPTION: 1
1465
- },
1466
- disablepictureinpicture: {
1467
- $: "disablePictureInPicture",
1468
- VIDEO: 1
1469
- },
1470
- disableremoteplayback: {
1471
- $: "disableRemotePlayback",
1472
- AUDIO: 1,
1473
- VIDEO: 1
1474
- },
1475
- preservespitch: {
1476
- $: "preservesPitch",
1477
- AUDIO: 1,
1478
- VIDEO: 1
1479
- },
1480
- shadowrootclonable: {
1481
- $: "shadowRootClonable",
1482
- TEMPLATE: 1
1483
- },
1484
- shadowrootdelegatesfocus: {
1485
- $: "shadowRootDelegatesFocus",
1486
- TEMPLATE: 1
1487
- },
1488
- shadowrootserializable: {
1489
- $: "shadowRootSerializable",
1490
- TEMPLATE: 1
1491
- },
1492
- sharedstoragewritable: {
1493
- $: "sharedStorageWritable",
1494
- IFRAME: 1,
1495
- IMG: 1
1496
- }
1497
- };
1498
- function getPropAlias(prop, tagName) {
1499
- const a = PropAliases[prop];
1500
- if (typeof a === "object") {
1501
- return a[tagName] ? a["$"] : void 0;
1502
- }
1503
- return a;
1237
+ return a;
1504
1238
  }
1505
1239
  var $$EVENTS = "_$FICT_DELEGATE";
1506
1240
  var DelegatedEvents = /* @__PURE__ */ new Set([
@@ -1688,6 +1422,9 @@ var UnitlessStyles = /* @__PURE__ */ new Set([
1688
1422
  "stroke-width"
1689
1423
  ]);
1690
1424
 
1425
+ // src/jsx.ts
1426
+ var Fragment = Symbol("Fragment");
1427
+
1691
1428
  // src/node-ops.ts
1692
1429
  function toNodeArray(node) {
1693
1430
  try {
@@ -1838,6 +1575,27 @@ function isReactive(value) {
1838
1575
  function unwrap2(value) {
1839
1576
  return isReactive(value) ? value() : value;
1840
1577
  }
1578
+ function callEventHandler(handler, event, node, data) {
1579
+ if (!handler) return;
1580
+ const context = node ?? event.currentTarget ?? void 0;
1581
+ const invoke = (fn) => {
1582
+ if (typeof fn === "function") {
1583
+ const result = data === void 0 ? fn.call(context, event) : fn.call(context, data, event);
1584
+ if (typeof result === "function" && result !== fn) {
1585
+ if (data === void 0) {
1586
+ result.call(context, event);
1587
+ } else {
1588
+ result.call(context, data, event);
1589
+ }
1590
+ } else if (result && typeof result.handleEvent === "function") {
1591
+ result.handleEvent.call(result, event);
1592
+ }
1593
+ } else if (fn && typeof fn.handleEvent === "function") {
1594
+ fn.handleEvent.call(fn, event);
1595
+ }
1596
+ };
1597
+ invoke(handler);
1598
+ }
1841
1599
  var PRIMITIVE_PROXY = Symbol("fict:primitive-proxy");
1842
1600
  var PRIMITIVE_PROXY_RAW_VALUE = Symbol("fict:primitive-proxy:raw-value");
1843
1601
  function unwrapPrimitive(value) {
@@ -2351,14 +2109,10 @@ function globalEventHandler(e) {
2351
2109
  const hasData = rawData !== void 0;
2352
2110
  const resolvedNodeData = hasData ? resolveData(rawData) : void 0;
2353
2111
  if (typeof handler === "function") {
2354
- if (hasData) {
2355
- handler.call(node, resolvedNodeData, e);
2356
- } else {
2357
- handler.call(node, e);
2358
- }
2112
+ callEventHandler(handler, e, node, hasData ? resolvedNodeData : void 0);
2359
2113
  } else if (Array.isArray(handler)) {
2360
2114
  const tupleData = resolveData(handler[1]);
2361
- handler[0].call(node, tupleData, e);
2115
+ callEventHandler(handler[0], e, node, tupleData);
2362
2116
  }
2363
2117
  if (e.cancelBubble) return false;
2364
2118
  }
@@ -2422,23 +2176,15 @@ function bindEvent(el, eventName, handler, options2) {
2422
2176
  if (DelegatedEvents.has(eventName) && !options2) {
2423
2177
  const key = `$$${eventName}`;
2424
2178
  delegateEvents([eventName]);
2425
- const createWrapped = (resolve) => {
2426
- const wrapped2 = function(...args) {
2427
- try {
2428
- const fn = resolve();
2429
- if (typeof fn === "function") {
2430
- return fn.apply(this, args);
2431
- } else if (fn && typeof fn.handleEvent === "function") {
2432
- return fn.handleEvent.apply(fn, args);
2433
- }
2434
- } catch (err) {
2435
- handleError(err, { source: "event", eventName }, rootRef);
2436
- }
2437
- };
2438
- return wrapped2;
2439
- };
2440
2179
  const resolveHandler = isReactive(handler) ? handler : () => handler;
2441
- el[key] = createWrapped(resolveHandler);
2180
+ el[key] = function(...args) {
2181
+ try {
2182
+ const fn = resolveHandler();
2183
+ callEventHandler(fn, args[0], el);
2184
+ } catch (err) {
2185
+ handleError(err, { source: "event", eventName }, rootRef);
2186
+ }
2187
+ };
2442
2188
  return () => {
2443
2189
  el[key] = void 0;
2444
2190
  };
@@ -2447,13 +2193,7 @@ function bindEvent(el, eventName, handler, options2) {
2447
2193
  const wrapped = (event) => {
2448
2194
  try {
2449
2195
  const resolved = getHandler();
2450
- if (typeof resolved === "function") {
2451
- ;
2452
- resolved(event);
2453
- } else if (resolved && typeof resolved.handleEvent === "function") {
2454
- ;
2455
- resolved.handleEvent(event);
2456
- }
2196
+ callEventHandler(resolved, event, el);
2457
2197
  } catch (err) {
2458
2198
  if (handleError(err, { source: "event", eventName }, rootRef)) {
2459
2199
  return;
@@ -2864,256 +2604,566 @@ function createPortal(container, render2, createElementFn) {
2864
2604
  currentRoot2 = null;
2865
2605
  }
2866
2606
  }
2867
- });
2868
- const portalDispose = () => {
2869
- dispose();
2870
- if (currentRoot2) {
2871
- destroyRoot(currentRoot2);
2607
+ });
2608
+ const portalDispose = () => {
2609
+ dispose();
2610
+ if (currentRoot2) {
2611
+ destroyRoot(currentRoot2);
2612
+ }
2613
+ if (currentNodes.length > 0) {
2614
+ removeNodes(currentNodes);
2615
+ }
2616
+ marker.parentNode?.removeChild(marker);
2617
+ };
2618
+ if (parentRoot) {
2619
+ parentRoot.destroyCallbacks.push(portalDispose);
2620
+ }
2621
+ return {
2622
+ marker,
2623
+ dispose: portalDispose
2624
+ };
2625
+ }
2626
+ function mountBlock(initialValue, initialIndex, renderItem, parent, anchor, createElementFn) {
2627
+ const start = document.createComment("fict:block:start");
2628
+ const end = document.createComment("fict:block:end");
2629
+ const valueSig = signal(initialValue);
2630
+ const indexSig = signal(initialIndex);
2631
+ const versionSig = signal(0);
2632
+ const valueProxy = createValueProxy(() => {
2633
+ versionSig();
2634
+ return valueSig();
2635
+ });
2636
+ const renderCurrent = () => renderItem(valueProxy, indexSig());
2637
+ const root = createRootContext();
2638
+ const prev = pushRoot(root);
2639
+ const nodes = [start];
2640
+ let handledError = false;
2641
+ try {
2642
+ const output = renderCurrent();
2643
+ if (output != null && output !== false) {
2644
+ const el = createElementFn(output);
2645
+ const rendered = toNodeArray(el);
2646
+ nodes.push(...rendered);
2647
+ }
2648
+ nodes.push(end);
2649
+ insertNodesBefore(parent, nodes, anchor);
2650
+ } catch (err) {
2651
+ if (handleSuspend(err, root)) {
2652
+ handledError = true;
2653
+ nodes.push(end);
2654
+ insertNodesBefore(parent, nodes, anchor);
2655
+ } else if (handleError(err, { source: "renderChild" }, root)) {
2656
+ handledError = true;
2657
+ nodes.push(end);
2658
+ insertNodesBefore(parent, nodes, anchor);
2659
+ } else {
2660
+ throw err;
2661
+ }
2662
+ } finally {
2663
+ popRoot(prev);
2664
+ if (!handledError) {
2665
+ flushOnMount(root);
2666
+ } else {
2667
+ destroyRoot(root);
2668
+ }
2669
+ }
2670
+ return {
2671
+ nodes,
2672
+ root,
2673
+ value: valueSig,
2674
+ index: indexSig,
2675
+ version: versionSig,
2676
+ start,
2677
+ end,
2678
+ valueProxy,
2679
+ renderCurrent
2680
+ };
2681
+ }
2682
+ function rerenderBlock(block, createElementFn) {
2683
+ const currentContent = block.nodes.slice(1, Math.max(1, block.nodes.length - 1));
2684
+ const currentNode = currentContent.length === 1 ? currentContent[0] : null;
2685
+ clearRoot(block.root);
2686
+ const prev = pushRoot(block.root);
2687
+ let nextOutput;
2688
+ let handledError = false;
2689
+ try {
2690
+ nextOutput = block.renderCurrent();
2691
+ } catch (err) {
2692
+ if (handleSuspend(err, block.root)) {
2693
+ handledError = true;
2694
+ popRoot(prev);
2695
+ destroyRoot(block.root);
2696
+ block.nodes = [block.start, block.end];
2697
+ return block;
2698
+ }
2699
+ if (handleError(err, { source: "renderChild" }, block.root)) {
2700
+ handledError = true;
2701
+ popRoot(prev);
2702
+ destroyRoot(block.root);
2703
+ block.nodes = [block.start, block.end];
2704
+ return block;
2705
+ }
2706
+ throw err;
2707
+ } finally {
2708
+ if (!handledError) {
2709
+ popRoot(prev);
2710
+ }
2711
+ }
2712
+ if (isFragmentVNode(nextOutput) && currentContent.length > 0) {
2713
+ const patched = patchFragmentChildren(currentContent, nextOutput.props?.children);
2714
+ if (patched) {
2715
+ block.nodes = [block.start, ...currentContent, block.end];
2716
+ return block;
2717
+ }
2718
+ }
2719
+ if (currentNode && patchNode(currentNode, nextOutput)) {
2720
+ block.nodes = [block.start, currentNode, block.end];
2721
+ return block;
2722
+ }
2723
+ clearContent(block);
2724
+ if (nextOutput != null && nextOutput !== false) {
2725
+ const newNodes = toNodeArray(
2726
+ nextOutput instanceof Node ? nextOutput : createElementFn(nextOutput)
2727
+ );
2728
+ insertNodesBefore(block.start.parentNode, newNodes, block.end);
2729
+ block.nodes = [block.start, ...newNodes, block.end];
2730
+ } else {
2731
+ block.nodes = [block.start, block.end];
2732
+ }
2733
+ return block;
2734
+ }
2735
+ function patchElement(el, output) {
2736
+ if (output === null || output === void 0 || output === false || typeof output === "string" || typeof output === "number") {
2737
+ el.textContent = output === null || output === void 0 || output === false ? "" : String(output);
2738
+ return true;
2739
+ }
2740
+ if (output instanceof Text) {
2741
+ el.textContent = output.data;
2742
+ return true;
2743
+ }
2744
+ if (output && typeof output === "object" && !(output instanceof Node)) {
2745
+ const vnode = output;
2746
+ if (typeof vnode.type === "string" && vnode.type.toLowerCase() === el.tagName.toLowerCase()) {
2747
+ const children = vnode.props?.children;
2748
+ const props = vnode.props ?? {};
2749
+ for (const [key, value] of Object.entries(props)) {
2750
+ if (key === "children" || key === "key") continue;
2751
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null || value === void 0) {
2752
+ if (key === "class" || key === "className") {
2753
+ el.setAttribute("class", value === false || value === null ? "" : String(value));
2754
+ } else if (key === "style" && typeof value === "string") {
2755
+ el.style.cssText = value;
2756
+ } else if (value === false || value === null || value === void 0) {
2757
+ el.removeAttribute(key);
2758
+ } else if (value === true) {
2759
+ el.setAttribute(key, "");
2760
+ } else {
2761
+ el.setAttribute(key, String(value));
2762
+ }
2763
+ }
2764
+ }
2765
+ if (typeof children === "string" || typeof children === "number" || children === null || children === void 0 || children === false) {
2766
+ el.textContent = children === null || children === void 0 || children === false ? "" : String(children);
2767
+ return true;
2768
+ }
2769
+ if (children && typeof children === "object" && !Array.isArray(children) && !(children instanceof Node)) {
2770
+ const childVNode = children;
2771
+ if (typeof childVNode.type === "string") {
2772
+ const childEl = el.querySelector(childVNode.type);
2773
+ if (childEl && patchElement(childEl, children)) {
2774
+ return true;
2775
+ }
2776
+ }
2777
+ }
2778
+ return false;
2779
+ }
2780
+ }
2781
+ if (output instanceof Node) {
2782
+ if (output.nodeType === Node.ELEMENT_NODE) {
2783
+ const nextEl = output;
2784
+ if (nextEl.tagName.toLowerCase() === el.tagName.toLowerCase()) {
2785
+ el.textContent = nextEl.textContent;
2786
+ return true;
2787
+ }
2788
+ } else if (output.nodeType === Node.TEXT_NODE) {
2789
+ el.textContent = output.data;
2790
+ return true;
2791
+ }
2792
+ }
2793
+ return false;
2794
+ }
2795
+ function patchNode(currentNode, nextOutput) {
2796
+ if (!currentNode) return false;
2797
+ if (currentNode instanceof Text && (nextOutput === null || nextOutput === void 0 || nextOutput === false || typeof nextOutput === "string" || typeof nextOutput === "number" || nextOutput instanceof Text)) {
2798
+ const nextText = nextOutput instanceof Text ? nextOutput.data : nextOutput === null || nextOutput === void 0 || nextOutput === false ? "" : String(nextOutput);
2799
+ currentNode.data = nextText;
2800
+ return true;
2801
+ }
2802
+ if (currentNode instanceof Element && patchElement(currentNode, nextOutput)) {
2803
+ return true;
2804
+ }
2805
+ if (nextOutput instanceof Node && currentNode === nextOutput) {
2806
+ return true;
2807
+ }
2808
+ return false;
2809
+ }
2810
+ function isFragmentVNode(value) {
2811
+ return value != null && typeof value === "object" && !(value instanceof Node) && value.type === Fragment;
2812
+ }
2813
+ function normalizeChildren(children, result = []) {
2814
+ if (children === void 0) {
2815
+ return result;
2816
+ }
2817
+ if (Array.isArray(children)) {
2818
+ for (const child of children) {
2819
+ normalizeChildren(child, result);
2820
+ }
2821
+ return result;
2822
+ }
2823
+ if (children === null || children === false) {
2824
+ return result;
2825
+ }
2826
+ result.push(children);
2827
+ return result;
2828
+ }
2829
+ function patchFragmentChildren(nodes, children) {
2830
+ const normalized = normalizeChildren(children);
2831
+ if (normalized.length !== nodes.length) {
2832
+ return false;
2833
+ }
2834
+ for (let i = 0; i < normalized.length; i++) {
2835
+ if (!patchNode(nodes[i], normalized[i])) {
2836
+ return false;
2872
2837
  }
2873
- if (currentNodes.length > 0) {
2874
- removeNodes(currentNodes);
2838
+ }
2839
+ return true;
2840
+ }
2841
+ function clearContent(block) {
2842
+ const nodes = block.nodes.slice(1, Math.max(1, block.nodes.length - 1));
2843
+ removeNodes(nodes);
2844
+ }
2845
+ function removeBlockNodes(block) {
2846
+ let cursor = block.start;
2847
+ const end = block.end;
2848
+ while (cursor) {
2849
+ const next = cursor.nextSibling;
2850
+ cursor.parentNode?.removeChild(cursor);
2851
+ if (cursor === end) break;
2852
+ cursor = next;
2853
+ }
2854
+ }
2855
+ function bumpBlockVersion(block) {
2856
+ block.version(block.version() + 1);
2857
+ }
2858
+
2859
+ // src/scope.ts
2860
+ function createScope() {
2861
+ let dispose = null;
2862
+ const stop = () => {
2863
+ if (dispose) {
2864
+ dispose();
2865
+ dispose = null;
2875
2866
  }
2876
- marker.parentNode?.removeChild(marker);
2877
2867
  };
2878
- if (parentRoot) {
2879
- parentRoot.destroyCallbacks.push(portalDispose);
2880
- }
2881
- return {
2882
- marker,
2883
- dispose: portalDispose
2868
+ const run = (fn) => {
2869
+ stop();
2870
+ const { dispose: rootDispose, value } = createRoot(fn);
2871
+ dispose = rootDispose;
2872
+ return value;
2884
2873
  };
2874
+ registerRootCleanup(stop);
2875
+ return { run, stop };
2885
2876
  }
2886
- function mountBlock(initialValue, initialIndex, renderItem, parent, anchor, createElementFn) {
2887
- const start = document.createComment("fict:block:start");
2888
- const end = document.createComment("fict:block:end");
2889
- const valueSig = signal(initialValue);
2890
- const indexSig = signal(initialIndex);
2891
- const versionSig = signal(0);
2892
- const valueProxy = createValueProxy(() => {
2893
- versionSig();
2894
- return valueSig();
2895
- });
2896
- const renderCurrent = () => renderItem(valueProxy, indexSig());
2897
- const root = createRootContext();
2898
- const prev = pushRoot(root);
2899
- const nodes = [start];
2900
- let handledError = false;
2901
- try {
2902
- const output = renderCurrent();
2903
- if (output != null && output !== false) {
2904
- const el = createElementFn(output);
2905
- const rendered = toNodeArray(el);
2906
- nodes.push(...rendered);
2907
- }
2908
- nodes.push(end);
2909
- insertNodesBefore(parent, nodes, anchor);
2910
- } catch (err) {
2911
- if (handleSuspend(err, root)) {
2912
- handledError = true;
2913
- nodes.push(end);
2914
- insertNodesBefore(parent, nodes, anchor);
2915
- } else if (handleError(err, { source: "renderChild" }, root)) {
2916
- handledError = true;
2917
- nodes.push(end);
2918
- insertNodesBefore(parent, nodes, anchor);
2877
+ function runInScope(flag, fn) {
2878
+ const scope = createScope();
2879
+ const evaluate = () => isReactive(flag) ? flag() : !!flag;
2880
+ createEffect(() => {
2881
+ const enabled = evaluate();
2882
+ if (enabled) {
2883
+ scope.run(fn);
2919
2884
  } else {
2920
- throw err;
2885
+ scope.stop();
2921
2886
  }
2887
+ });
2888
+ onCleanup(scope.stop);
2889
+ }
2890
+
2891
+ // src/hooks.ts
2892
+ var ctxStack = [];
2893
+ function __fictUseContext() {
2894
+ if (ctxStack.length === 0) {
2895
+ const ctx2 = { slots: [], cursor: 0 };
2896
+ ctxStack.push(ctx2);
2897
+ return ctx2;
2898
+ }
2899
+ const ctx = ctxStack[ctxStack.length - 1];
2900
+ ctx.cursor = 0;
2901
+ return ctx;
2902
+ }
2903
+ function __fictPushContext() {
2904
+ const ctx = { slots: [], cursor: 0 };
2905
+ ctxStack.push(ctx);
2906
+ return ctx;
2907
+ }
2908
+ function __fictPopContext() {
2909
+ ctxStack.pop();
2910
+ }
2911
+ function __fictResetContext() {
2912
+ ctxStack.length = 0;
2913
+ }
2914
+ function __fictUseSignal(ctx, initial, slot) {
2915
+ const index = slot ?? ctx.cursor++;
2916
+ if (!ctx.slots[index]) {
2917
+ ctx.slots[index] = signal(initial);
2918
+ }
2919
+ return ctx.slots[index];
2920
+ }
2921
+ function __fictUseMemo(ctx, fn, slot) {
2922
+ const index = slot ?? ctx.cursor++;
2923
+ if (!ctx.slots[index]) {
2924
+ ctx.slots[index] = createMemo(fn);
2925
+ }
2926
+ return ctx.slots[index];
2927
+ }
2928
+ function __fictUseEffect(ctx, fn, slot) {
2929
+ const index = slot ?? ctx.cursor++;
2930
+ if (!ctx.slots[index]) {
2931
+ ctx.slots[index] = createEffect(fn);
2932
+ }
2933
+ }
2934
+ function __fictRender(ctx, fn) {
2935
+ ctxStack.push(ctx);
2936
+ ctx.cursor = 0;
2937
+ try {
2938
+ return fn();
2922
2939
  } finally {
2923
- popRoot(prev);
2924
- if (!handledError) {
2925
- flushOnMount(root);
2926
- } else {
2927
- destroyRoot(root);
2928
- }
2940
+ ctxStack.pop();
2929
2941
  }
2942
+ }
2943
+
2944
+ // src/versioned-signal.ts
2945
+ function createVersionedSignal(initialValue, options2) {
2946
+ const equals = options2?.equals ?? Object.is;
2947
+ const value = signal(initialValue);
2948
+ const version = signal(0);
2949
+ const bumpVersion = () => {
2950
+ const next = version() + 1;
2951
+ version(next);
2952
+ };
2930
2953
  return {
2931
- nodes,
2932
- root,
2933
- value: valueSig,
2934
- index: indexSig,
2935
- version: versionSig,
2936
- start,
2937
- end,
2938
- valueProxy,
2939
- renderCurrent
2954
+ read: () => {
2955
+ version();
2956
+ return value();
2957
+ },
2958
+ write: (next) => {
2959
+ const prev = value();
2960
+ if (!equals(prev, next)) {
2961
+ value(next);
2962
+ return;
2963
+ }
2964
+ bumpVersion();
2965
+ },
2966
+ force: () => {
2967
+ bumpVersion();
2968
+ },
2969
+ peekVersion: () => version(),
2970
+ peekValue: () => value()
2940
2971
  };
2941
2972
  }
2942
- function rerenderBlock(block, createElementFn) {
2943
- const currentContent = block.nodes.slice(1, Math.max(1, block.nodes.length - 1));
2944
- const currentNode = currentContent.length === 1 ? currentContent[0] : null;
2945
- clearRoot(block.root);
2946
- const prev = pushRoot(block.root);
2947
- let nextOutput;
2948
- let handledError = false;
2949
- try {
2950
- nextOutput = block.renderCurrent();
2951
- } catch (err) {
2952
- if (handleSuspend(err, block.root)) {
2953
- handledError = true;
2954
- popRoot(prev);
2955
- destroyRoot(block.root);
2956
- block.nodes = [block.start, block.end];
2957
- return block;
2958
- }
2959
- if (handleError(err, { source: "renderChild" }, block.root)) {
2960
- handledError = true;
2961
- popRoot(prev);
2962
- destroyRoot(block.root);
2963
- block.nodes = [block.start, block.end];
2964
- return block;
2965
- }
2966
- throw err;
2967
- } finally {
2968
- if (!handledError) {
2969
- popRoot(prev);
2970
- }
2973
+
2974
+ // src/props.ts
2975
+ var propGetters = /* @__PURE__ */ new WeakSet();
2976
+ var rawToProxy = /* @__PURE__ */ new WeakMap();
2977
+ var proxyToRaw = /* @__PURE__ */ new WeakMap();
2978
+ function __fictProp(getter) {
2979
+ if (typeof getter === "function" && getter.length === 0) {
2980
+ propGetters.add(getter);
2971
2981
  }
2972
- if (isFragmentVNode(nextOutput) && currentContent.length > 0) {
2973
- const patched = patchFragmentChildren(currentContent, nextOutput.props?.children);
2974
- if (patched) {
2975
- block.nodes = [block.start, ...currentContent, block.end];
2976
- return block;
2982
+ return getter;
2983
+ }
2984
+ function isPropGetter(value) {
2985
+ return typeof value === "function" && propGetters.has(value);
2986
+ }
2987
+ function createPropsProxy(props) {
2988
+ if (!props || typeof props !== "object") {
2989
+ return props;
2990
+ }
2991
+ if (proxyToRaw.has(props)) {
2992
+ return props;
2993
+ }
2994
+ const cached = rawToProxy.get(props);
2995
+ if (cached) {
2996
+ return cached;
2997
+ }
2998
+ const proxy = new Proxy(props, {
2999
+ get(target, prop, receiver) {
3000
+ const value = Reflect.get(target, prop, receiver);
3001
+ if (isPropGetter(value)) {
3002
+ return value();
3003
+ }
3004
+ return value;
3005
+ },
3006
+ set(target, prop, value, receiver) {
3007
+ return Reflect.set(target, prop, value, receiver);
3008
+ },
3009
+ has(target, prop) {
3010
+ return prop in target;
3011
+ },
3012
+ ownKeys(target) {
3013
+ return Reflect.ownKeys(target);
3014
+ },
3015
+ getOwnPropertyDescriptor(target, prop) {
3016
+ return Object.getOwnPropertyDescriptor(target, prop);
2977
3017
  }
3018
+ });
3019
+ rawToProxy.set(props, proxy);
3020
+ proxyToRaw.set(proxy, props);
3021
+ return proxy;
3022
+ }
3023
+ function unwrapProps(props) {
3024
+ if (!props || typeof props !== "object") {
3025
+ return props;
2978
3026
  }
2979
- if (currentNode && patchNode(currentNode, nextOutput)) {
2980
- block.nodes = [block.start, currentNode, block.end];
2981
- return block;
2982
- }
2983
- clearContent(block);
2984
- if (nextOutput != null && nextOutput !== false) {
2985
- const newNodes = toNodeArray(
2986
- nextOutput instanceof Node ? nextOutput : createElementFn(nextOutput)
2987
- );
2988
- insertNodesBefore(block.start.parentNode, newNodes, block.end);
2989
- block.nodes = [block.start, ...newNodes, block.end];
2990
- } else {
2991
- block.nodes = [block.start, block.end];
3027
+ return proxyToRaw.get(props) ?? props;
3028
+ }
3029
+ function __fictPropsRest(props, exclude) {
3030
+ const raw = unwrapProps(props);
3031
+ const out = {};
3032
+ const excludeSet = new Set(exclude);
3033
+ for (const key of Reflect.ownKeys(raw)) {
3034
+ if (excludeSet.has(key)) continue;
3035
+ out[key] = raw[key];
2992
3036
  }
2993
- return block;
3037
+ return createPropsProxy(out);
2994
3038
  }
2995
- function patchElement(el, output) {
2996
- if (output === null || output === void 0 || output === false || typeof output === "string" || typeof output === "number") {
2997
- el.textContent = output === null || output === void 0 || output === false ? "" : String(output);
2998
- return true;
3039
+ function mergeProps(...sources) {
3040
+ const validSources = sources.filter(
3041
+ (s) => s != null && (typeof s === "object" || typeof s === "function")
3042
+ );
3043
+ if (validSources.length === 0) {
3044
+ return {};
2999
3045
  }
3000
- if (output instanceof Text) {
3001
- el.textContent = output.data;
3002
- return true;
3046
+ if (validSources.length === 1 && typeof validSources[0] === "object") {
3047
+ return validSources[0];
3003
3048
  }
3004
- if (output && typeof output === "object" && !(output instanceof Node)) {
3005
- const vnode = output;
3006
- if (typeof vnode.type === "string" && vnode.type.toLowerCase() === el.tagName.toLowerCase()) {
3007
- const children = vnode.props?.children;
3008
- const props = vnode.props ?? {};
3009
- for (const [key, value] of Object.entries(props)) {
3010
- if (key === "children" || key === "key") continue;
3011
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null || value === void 0) {
3012
- if (key === "class" || key === "className") {
3013
- el.setAttribute("class", value === false || value === null ? "" : String(value));
3014
- } else if (key === "style" && typeof value === "string") {
3015
- el.style.cssText = value;
3016
- } else if (value === false || value === null || value === void 0) {
3017
- el.removeAttribute(key);
3018
- } else if (value === true) {
3019
- el.setAttribute(key, "");
3020
- } else {
3021
- el.setAttribute(key, String(value));
3022
- }
3049
+ const resolveSource = (src) => {
3050
+ const value = typeof src === "function" ? src() : src;
3051
+ if (!value || typeof value !== "object") return void 0;
3052
+ return unwrapProps(value);
3053
+ };
3054
+ return new Proxy({}, {
3055
+ get(_, prop) {
3056
+ if (typeof prop === "symbol") {
3057
+ return void 0;
3058
+ }
3059
+ for (let i = validSources.length - 1; i >= 0; i--) {
3060
+ const src = validSources[i];
3061
+ const raw = resolveSource(src);
3062
+ if (!raw || !(prop in raw)) continue;
3063
+ const value = raw[prop];
3064
+ if (typeof src === "function" && !isPropGetter(value)) {
3065
+ return __fictProp(() => {
3066
+ const latest = resolveSource(src);
3067
+ if (!latest || !(prop in latest)) return void 0;
3068
+ return latest[prop];
3069
+ });
3023
3070
  }
3071
+ return value;
3024
3072
  }
3025
- if (typeof children === "string" || typeof children === "number" || children === null || children === void 0 || children === false) {
3026
- el.textContent = children === null || children === void 0 || children === false ? "" : String(children);
3027
- return true;
3073
+ return void 0;
3074
+ },
3075
+ has(_, prop) {
3076
+ for (const src of validSources) {
3077
+ const raw = resolveSource(src);
3078
+ if (raw && prop in raw) {
3079
+ return true;
3080
+ }
3028
3081
  }
3029
- if (children && typeof children === "object" && !Array.isArray(children) && !(children instanceof Node)) {
3030
- const childVNode = children;
3031
- if (typeof childVNode.type === "string") {
3032
- const childEl = el.querySelector(childVNode.type);
3033
- if (childEl && patchElement(childEl, children)) {
3034
- return true;
3082
+ return false;
3083
+ },
3084
+ ownKeys() {
3085
+ const keys = /* @__PURE__ */ new Set();
3086
+ for (const src of validSources) {
3087
+ const raw = resolveSource(src);
3088
+ if (raw) {
3089
+ for (const key of Reflect.ownKeys(raw)) {
3090
+ keys.add(key);
3035
3091
  }
3036
3092
  }
3037
3093
  }
3038
- return false;
3039
- }
3040
- }
3041
- if (output instanceof Node) {
3042
- if (output.nodeType === Node.ELEMENT_NODE) {
3043
- const nextEl = output;
3044
- if (nextEl.tagName.toLowerCase() === el.tagName.toLowerCase()) {
3045
- el.textContent = nextEl.textContent;
3046
- return true;
3094
+ return Array.from(keys);
3095
+ },
3096
+ getOwnPropertyDescriptor(_, prop) {
3097
+ for (let i = validSources.length - 1; i >= 0; i--) {
3098
+ const raw = resolveSource(validSources[i]);
3099
+ if (raw && prop in raw) {
3100
+ return {
3101
+ enumerable: true,
3102
+ configurable: true,
3103
+ get: () => {
3104
+ const value = raw[prop];
3105
+ return value;
3106
+ }
3107
+ };
3108
+ }
3047
3109
  }
3048
- } else if (output.nodeType === Node.TEXT_NODE) {
3049
- el.textContent = output.data;
3050
- return true;
3110
+ return void 0;
3051
3111
  }
3052
- }
3053
- return false;
3112
+ });
3054
3113
  }
3055
- function patchNode(currentNode, nextOutput) {
3056
- if (!currentNode) return false;
3057
- if (currentNode instanceof Text && (nextOutput === null || nextOutput === void 0 || nextOutput === false || typeof nextOutput === "string" || typeof nextOutput === "number" || nextOutput instanceof Text)) {
3058
- const nextText = nextOutput instanceof Text ? nextOutput.data : nextOutput === null || nextOutput === void 0 || nextOutput === false ? "" : String(nextOutput);
3059
- currentNode.data = nextText;
3060
- return true;
3061
- }
3062
- if (currentNode instanceof Element && patchElement(currentNode, nextOutput)) {
3063
- return true;
3064
- }
3065
- if (nextOutput instanceof Node && currentNode === nextOutput) {
3066
- return true;
3067
- }
3068
- return false;
3114
+ function useProp(getter) {
3115
+ return __fictProp(createMemo(getter));
3069
3116
  }
3070
- function isFragmentVNode(value) {
3071
- return value != null && typeof value === "object" && !(value instanceof Node) && value.type === Fragment;
3117
+
3118
+ // src/ref.ts
3119
+ function createRef() {
3120
+ return { current: null };
3072
3121
  }
3073
- function normalizeChildren(children, result = []) {
3074
- if (children === void 0) {
3075
- return result;
3076
- }
3077
- if (Array.isArray(children)) {
3078
- for (const child of children) {
3079
- normalizeChildren(child, result);
3080
- }
3081
- return result;
3082
- }
3083
- if (children === null || children === false) {
3084
- return result;
3122
+
3123
+ // src/transition.ts
3124
+ function startTransition(fn) {
3125
+ const prev = setTransitionContext(true);
3126
+ try {
3127
+ fn();
3128
+ } finally {
3129
+ setTransitionContext(prev);
3130
+ scheduleFlush();
3085
3131
  }
3086
- result.push(children);
3087
- return result;
3088
3132
  }
3089
- function patchFragmentChildren(nodes, children) {
3090
- const normalized = normalizeChildren(children);
3091
- if (normalized.length !== nodes.length) {
3092
- return false;
3093
- }
3094
- for (let i = 0; i < normalized.length; i++) {
3095
- if (!patchNode(nodes[i], normalized[i])) {
3096
- return false;
3097
- }
3098
- }
3099
- return true;
3133
+ function useTransition() {
3134
+ const pending = signal(false);
3135
+ const start = (fn) => {
3136
+ pending(true);
3137
+ startTransition(() => {
3138
+ try {
3139
+ fn();
3140
+ } finally {
3141
+ pending(false);
3142
+ }
3143
+ });
3144
+ };
3145
+ return [() => pending(), start];
3100
3146
  }
3101
- function clearContent(block) {
3102
- const nodes = block.nodes.slice(1, Math.max(1, block.nodes.length - 1));
3103
- removeNodes(nodes);
3147
+ function useDeferredValue(getValue) {
3148
+ const deferredValue = signal(getValue());
3149
+ createEffect(() => {
3150
+ const newValue = getValue();
3151
+ const currentDeferred = untrack(() => deferredValue());
3152
+ if (currentDeferred !== newValue) {
3153
+ startTransition(() => {
3154
+ deferredValue(newValue);
3155
+ });
3156
+ }
3157
+ });
3158
+ return () => deferredValue();
3104
3159
  }
3105
- function removeBlockNodes(block) {
3106
- let cursor = block.start;
3107
- const end = block.end;
3108
- while (cursor) {
3109
- const next = cursor.nextSibling;
3110
- cursor.parentNode?.removeChild(cursor);
3111
- if (cursor === end) break;
3112
- cursor = next;
3113
- }
3160
+
3161
+ // src/scheduler.ts
3162
+ function batch2(fn) {
3163
+ return batch(fn);
3114
3164
  }
3115
- function bumpBlockVersion(block) {
3116
- block.version(block.version() + 1);
3165
+ function untrack2(fn) {
3166
+ return untrack(fn);
3117
3167
  }
3118
3168
 
3119
3169
  // src/dom.ts
@@ -4128,6 +4178,6 @@ function createFineGrainedKeyedList(getItems, keyFn, renderItem, needsIndex) {
4128
4178
  };
4129
4179
  }
4130
4180
 
4131
- export { $effect, $memo, $state, Aliases, BooleanAttributes, ChildProperties, DelegatedEvents, ErrorBoundary, Fragment, Properties, SVGElements, SVGNamespace, Suspense, UnitlessStyles, __fictPopContext, __fictProp, __fictPropsRest, __fictPushContext, __fictRender, __fictResetContext, __fictUseContext, __fictUseEffect, __fictUseMemo, __fictUseSignal, addEventListener, assign, batch2 as batch, bindAttribute, bindClass, bindEvent, bindProperty, bindRef, bindStyle, bindText, classList, clearDelegatedEvents, createAttributeBinding, createChildBinding, createClassBinding, createConditional, createEffect, createElement, createKeyedBlock, createKeyedList, createKeyedListContainer, createList, createMemo, createPortal, createPropsProxy, createRef, createRenderEffect, createRoot, createSelector, createShow, signal as createSignal, createStore, createStyleBinding, createSuspenseToken, createTextBinding, createVersionedSignal, delegateEvents, destroyMarkerBlock, getDevtoolsHook, getFirstNodeAfter, getPropAlias, insert, insertNodesBefore, isNodeBetweenMarkers, isReactive, mergeProps, moveMarkerBlock, moveNodesBefore, onCleanup, onDestroy, onMount, __fictProp as prop, reconcileArrays, removeNodes, render, setCycleProtectionOptions, spread, startTransition, template, toNodeArray, untrack2 as untrack, unwrap2 as unwrap, unwrapPrimitive, useDeferredValue, useProp, useTransition };
4181
+ export { $effect, $memo, $state, Aliases, BooleanAttributes, ChildProperties, DelegatedEvents, ErrorBoundary, Fragment, Properties, SVGElements, SVGNamespace, Suspense, UnitlessStyles, __fictPopContext, __fictProp, __fictPropsRest, __fictPushContext, __fictRender, __fictResetContext, __fictUseContext, __fictUseEffect, __fictUseMemo, __fictUseSignal, addEventListener, assign, batch2 as batch, bindAttribute, bindClass, bindEvent, bindProperty, bindRef, bindStyle, bindText, callEventHandler, classList, clearDelegatedEvents, createAttributeBinding, createChildBinding, createClassBinding, createConditional, createEffect, createElement, createKeyedBlock, createKeyedList, createKeyedListContainer, createList, createMemo, createPortal, createPropsProxy, createRef, createRenderEffect, createRoot, createScope, createSelector, createShow, signal as createSignal, createStore, createStyleBinding, createSuspenseToken, createTextBinding, createVersionedSignal, delegateEvents, destroyMarkerBlock, effectScope, getDevtoolsHook, getFirstNodeAfter, getPropAlias, insert, insertNodesBefore, isNodeBetweenMarkers, isReactive, mergeProps, moveMarkerBlock, moveNodesBefore, onCleanup, onDestroy, onMount, __fictProp as prop, reconcileArrays, removeNodes, render, runInScope, setCycleProtectionOptions, spread, startTransition, template, toNodeArray, untrack2 as untrack, unwrap2 as unwrap, unwrapPrimitive, useDeferredValue, useProp, useTransition };
4132
4182
  //# sourceMappingURL=index.js.map
4133
4183
  //# sourceMappingURL=index.js.map