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