@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.dev.js 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,30 @@ 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
+ ;
1589
+ result.call(context, event);
1590
+ } else {
1591
+ ;
1592
+ result.call(context, data, event);
1593
+ }
1594
+ } else if (result && typeof result.handleEvent === "function") {
1595
+ ;
1596
+ result.handleEvent.call(result, event);
1597
+ }
1598
+ } else if (fn && typeof fn.handleEvent === "function") {
1599
+ fn.handleEvent.call(fn, event);
1600
+ }
1601
+ };
1602
+ invoke(handler);
1603
+ }
1843
1604
  var PRIMITIVE_PROXY = Symbol("fict:primitive-proxy");
1844
1605
  var PRIMITIVE_PROXY_RAW_VALUE = Symbol("fict:primitive-proxy:raw-value");
1845
1606
  function unwrapPrimitive(value) {
@@ -2353,16 +2114,10 @@ function globalEventHandler(e) {
2353
2114
  const hasData = rawData !== void 0;
2354
2115
  const resolvedNodeData = hasData ? resolveData(rawData) : void 0;
2355
2116
  if (typeof handler === "function") {
2356
- if (hasData) {
2357
- ;
2358
- handler.call(node, resolvedNodeData, e);
2359
- } else {
2360
- ;
2361
- handler.call(node, e);
2362
- }
2117
+ callEventHandler(handler, e, node, hasData ? resolvedNodeData : void 0);
2363
2118
  } else if (Array.isArray(handler)) {
2364
2119
  const tupleData = resolveData(handler[1]);
2365
- handler[0].call(node, tupleData, e);
2120
+ callEventHandler(handler[0], e, node, tupleData);
2366
2121
  }
2367
2122
  if (e.cancelBubble) return false;
2368
2123
  }
@@ -2428,23 +2183,15 @@ function bindEvent(el, eventName, handler, options2) {
2428
2183
  if (DelegatedEvents.has(eventName) && !options2) {
2429
2184
  const key = `$$${eventName}`;
2430
2185
  delegateEvents([eventName]);
2431
- const createWrapped = (resolve) => {
2432
- const wrapped2 = function(...args) {
2433
- try {
2434
- const fn = resolve();
2435
- if (typeof fn === "function") {
2436
- return fn.apply(this, args);
2437
- } else if (fn && typeof fn.handleEvent === "function") {
2438
- return fn.handleEvent.apply(fn, args);
2439
- }
2440
- } catch (err) {
2441
- handleError(err, { source: "event", eventName }, rootRef);
2442
- }
2443
- };
2444
- return wrapped2;
2445
- };
2446
2186
  const resolveHandler = isReactive(handler) ? handler : () => handler;
2447
- el[key] = createWrapped(resolveHandler);
2187
+ el[key] = function(...args) {
2188
+ try {
2189
+ const fn = resolveHandler();
2190
+ callEventHandler(fn, args[0], el);
2191
+ } catch (err) {
2192
+ handleError(err, { source: "event", eventName }, rootRef);
2193
+ }
2194
+ };
2448
2195
  return () => {
2449
2196
  el[key] = void 0;
2450
2197
  };
@@ -2453,13 +2200,7 @@ function bindEvent(el, eventName, handler, options2) {
2453
2200
  const wrapped = (event) => {
2454
2201
  try {
2455
2202
  const resolved = getHandler();
2456
- if (typeof resolved === "function") {
2457
- ;
2458
- resolved(event);
2459
- } else if (resolved && typeof resolved.handleEvent === "function") {
2460
- ;
2461
- resolved.handleEvent(event);
2462
- }
2203
+ callEventHandler(resolved, event, el);
2463
2204
  } catch (err) {
2464
2205
  if (handleError(err, { source: "event", eventName }, rootRef)) {
2465
2206
  return;
@@ -2878,257 +2619,567 @@ function createPortal(container, render2, createElementFn) {
2878
2619
  currentRoot2 = null;
2879
2620
  }
2880
2621
  }
2881
- });
2882
- const portalDispose = () => {
2883
- dispose();
2884
- if (currentRoot2) {
2885
- destroyRoot(currentRoot2);
2622
+ });
2623
+ const portalDispose = () => {
2624
+ dispose();
2625
+ if (currentRoot2) {
2626
+ destroyRoot(currentRoot2);
2627
+ }
2628
+ if (currentNodes.length > 0) {
2629
+ removeNodes(currentNodes);
2630
+ }
2631
+ marker.parentNode?.removeChild(marker);
2632
+ };
2633
+ if (parentRoot) {
2634
+ parentRoot.destroyCallbacks.push(portalDispose);
2635
+ }
2636
+ return {
2637
+ marker,
2638
+ dispose: portalDispose
2639
+ };
2640
+ }
2641
+ function mountBlock(initialValue, initialIndex, renderItem, parent, anchor, createElementFn) {
2642
+ const start = document.createComment("fict:block:start");
2643
+ const end = document.createComment("fict:block:end");
2644
+ const valueSig = signal(initialValue);
2645
+ const indexSig = signal(initialIndex);
2646
+ const versionSig = signal(0);
2647
+ const valueProxy = createValueProxy(() => {
2648
+ versionSig();
2649
+ return valueSig();
2650
+ });
2651
+ const renderCurrent = () => renderItem(valueProxy, indexSig());
2652
+ const root = createRootContext();
2653
+ const prev = pushRoot(root);
2654
+ const nodes = [start];
2655
+ let handledError = false;
2656
+ try {
2657
+ const output = renderCurrent();
2658
+ if (output != null && output !== false) {
2659
+ const el = createElementFn(output);
2660
+ const rendered = toNodeArray(el);
2661
+ nodes.push(...rendered);
2662
+ }
2663
+ nodes.push(end);
2664
+ insertNodesBefore(parent, nodes, anchor);
2665
+ } catch (err) {
2666
+ if (handleSuspend(err, root)) {
2667
+ handledError = true;
2668
+ nodes.push(end);
2669
+ insertNodesBefore(parent, nodes, anchor);
2670
+ } else if (handleError(err, { source: "renderChild" }, root)) {
2671
+ handledError = true;
2672
+ nodes.push(end);
2673
+ insertNodesBefore(parent, nodes, anchor);
2674
+ } else {
2675
+ throw err;
2676
+ }
2677
+ } finally {
2678
+ popRoot(prev);
2679
+ if (!handledError) {
2680
+ flushOnMount(root);
2681
+ } else {
2682
+ destroyRoot(root);
2683
+ }
2684
+ }
2685
+ return {
2686
+ nodes,
2687
+ root,
2688
+ value: valueSig,
2689
+ index: indexSig,
2690
+ version: versionSig,
2691
+ start,
2692
+ end,
2693
+ valueProxy,
2694
+ renderCurrent
2695
+ };
2696
+ }
2697
+ function rerenderBlock(block, createElementFn) {
2698
+ const currentContent = block.nodes.slice(1, Math.max(1, block.nodes.length - 1));
2699
+ const currentNode = currentContent.length === 1 ? currentContent[0] : null;
2700
+ clearRoot(block.root);
2701
+ const prev = pushRoot(block.root);
2702
+ let nextOutput;
2703
+ let handledError = false;
2704
+ try {
2705
+ nextOutput = block.renderCurrent();
2706
+ } catch (err) {
2707
+ if (handleSuspend(err, block.root)) {
2708
+ handledError = true;
2709
+ popRoot(prev);
2710
+ destroyRoot(block.root);
2711
+ block.nodes = [block.start, block.end];
2712
+ return block;
2713
+ }
2714
+ if (handleError(err, { source: "renderChild" }, block.root)) {
2715
+ handledError = true;
2716
+ popRoot(prev);
2717
+ destroyRoot(block.root);
2718
+ block.nodes = [block.start, block.end];
2719
+ return block;
2720
+ }
2721
+ throw err;
2722
+ } finally {
2723
+ if (!handledError) {
2724
+ popRoot(prev);
2725
+ }
2726
+ }
2727
+ if (isFragmentVNode(nextOutput) && currentContent.length > 0) {
2728
+ const patched = patchFragmentChildren(currentContent, nextOutput.props?.children);
2729
+ if (patched) {
2730
+ block.nodes = [block.start, ...currentContent, block.end];
2731
+ return block;
2732
+ }
2733
+ }
2734
+ if (currentNode && patchNode(currentNode, nextOutput)) {
2735
+ block.nodes = [block.start, currentNode, block.end];
2736
+ return block;
2737
+ }
2738
+ clearContent(block);
2739
+ if (nextOutput != null && nextOutput !== false) {
2740
+ const newNodes = toNodeArray(
2741
+ nextOutput instanceof Node ? nextOutput : createElementFn(nextOutput)
2742
+ );
2743
+ insertNodesBefore(block.start.parentNode, newNodes, block.end);
2744
+ block.nodes = [block.start, ...newNodes, block.end];
2745
+ } else {
2746
+ block.nodes = [block.start, block.end];
2747
+ }
2748
+ return block;
2749
+ }
2750
+ function patchElement(el, output) {
2751
+ if (output === null || output === void 0 || output === false || typeof output === "string" || typeof output === "number") {
2752
+ el.textContent = output === null || output === void 0 || output === false ? "" : String(output);
2753
+ return true;
2754
+ }
2755
+ if (output instanceof Text) {
2756
+ el.textContent = output.data;
2757
+ return true;
2758
+ }
2759
+ if (output && typeof output === "object" && !(output instanceof Node)) {
2760
+ const vnode = output;
2761
+ if (typeof vnode.type === "string" && vnode.type.toLowerCase() === el.tagName.toLowerCase()) {
2762
+ const children = vnode.props?.children;
2763
+ const props = vnode.props ?? {};
2764
+ for (const [key, value] of Object.entries(props)) {
2765
+ if (key === "children" || key === "key") continue;
2766
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null || value === void 0) {
2767
+ if (key === "class" || key === "className") {
2768
+ el.setAttribute("class", value === false || value === null ? "" : String(value));
2769
+ } else if (key === "style" && typeof value === "string") {
2770
+ ;
2771
+ el.style.cssText = value;
2772
+ } else if (value === false || value === null || value === void 0) {
2773
+ el.removeAttribute(key);
2774
+ } else if (value === true) {
2775
+ el.setAttribute(key, "");
2776
+ } else {
2777
+ el.setAttribute(key, String(value));
2778
+ }
2779
+ }
2780
+ }
2781
+ if (typeof children === "string" || typeof children === "number" || children === null || children === void 0 || children === false) {
2782
+ el.textContent = children === null || children === void 0 || children === false ? "" : String(children);
2783
+ return true;
2784
+ }
2785
+ if (children && typeof children === "object" && !Array.isArray(children) && !(children instanceof Node)) {
2786
+ const childVNode = children;
2787
+ if (typeof childVNode.type === "string") {
2788
+ const childEl = el.querySelector(childVNode.type);
2789
+ if (childEl && patchElement(childEl, children)) {
2790
+ return true;
2791
+ }
2792
+ }
2793
+ }
2794
+ return false;
2795
+ }
2796
+ }
2797
+ if (output instanceof Node) {
2798
+ if (output.nodeType === Node.ELEMENT_NODE) {
2799
+ const nextEl = output;
2800
+ if (nextEl.tagName.toLowerCase() === el.tagName.toLowerCase()) {
2801
+ el.textContent = nextEl.textContent;
2802
+ return true;
2803
+ }
2804
+ } else if (output.nodeType === Node.TEXT_NODE) {
2805
+ el.textContent = output.data;
2806
+ return true;
2807
+ }
2808
+ }
2809
+ return false;
2810
+ }
2811
+ function patchNode(currentNode, nextOutput) {
2812
+ if (!currentNode) return false;
2813
+ if (currentNode instanceof Text && (nextOutput === null || nextOutput === void 0 || nextOutput === false || typeof nextOutput === "string" || typeof nextOutput === "number" || nextOutput instanceof Text)) {
2814
+ const nextText = nextOutput instanceof Text ? nextOutput.data : nextOutput === null || nextOutput === void 0 || nextOutput === false ? "" : String(nextOutput);
2815
+ currentNode.data = nextText;
2816
+ return true;
2817
+ }
2818
+ if (currentNode instanceof Element && patchElement(currentNode, nextOutput)) {
2819
+ return true;
2820
+ }
2821
+ if (nextOutput instanceof Node && currentNode === nextOutput) {
2822
+ return true;
2823
+ }
2824
+ return false;
2825
+ }
2826
+ function isFragmentVNode(value) {
2827
+ return value != null && typeof value === "object" && !(value instanceof Node) && value.type === Fragment;
2828
+ }
2829
+ function normalizeChildren(children, result = []) {
2830
+ if (children === void 0) {
2831
+ return result;
2832
+ }
2833
+ if (Array.isArray(children)) {
2834
+ for (const child of children) {
2835
+ normalizeChildren(child, result);
2836
+ }
2837
+ return result;
2838
+ }
2839
+ if (children === null || children === false) {
2840
+ return result;
2841
+ }
2842
+ result.push(children);
2843
+ return result;
2844
+ }
2845
+ function patchFragmentChildren(nodes, children) {
2846
+ const normalized = normalizeChildren(children);
2847
+ if (normalized.length !== nodes.length) {
2848
+ return false;
2849
+ }
2850
+ for (let i = 0; i < normalized.length; i++) {
2851
+ if (!patchNode(nodes[i], normalized[i])) {
2852
+ return false;
2886
2853
  }
2887
- if (currentNodes.length > 0) {
2888
- removeNodes(currentNodes);
2854
+ }
2855
+ return true;
2856
+ }
2857
+ function clearContent(block) {
2858
+ const nodes = block.nodes.slice(1, Math.max(1, block.nodes.length - 1));
2859
+ removeNodes(nodes);
2860
+ }
2861
+ function removeBlockNodes(block) {
2862
+ let cursor = block.start;
2863
+ const end = block.end;
2864
+ while (cursor) {
2865
+ const next = cursor.nextSibling;
2866
+ cursor.parentNode?.removeChild(cursor);
2867
+ if (cursor === end) break;
2868
+ cursor = next;
2869
+ }
2870
+ }
2871
+ function bumpBlockVersion(block) {
2872
+ block.version(block.version() + 1);
2873
+ }
2874
+
2875
+ // src/scope.ts
2876
+ function createScope() {
2877
+ let dispose = null;
2878
+ const stop = () => {
2879
+ if (dispose) {
2880
+ dispose();
2881
+ dispose = null;
2889
2882
  }
2890
- marker.parentNode?.removeChild(marker);
2891
2883
  };
2892
- if (parentRoot) {
2893
- parentRoot.destroyCallbacks.push(portalDispose);
2894
- }
2895
- return {
2896
- marker,
2897
- dispose: portalDispose
2884
+ const run = (fn) => {
2885
+ stop();
2886
+ const { dispose: rootDispose, value } = createRoot(fn);
2887
+ dispose = rootDispose;
2888
+ return value;
2898
2889
  };
2890
+ registerRootCleanup(stop);
2891
+ return { run, stop };
2899
2892
  }
2900
- function mountBlock(initialValue, initialIndex, renderItem, parent, anchor, createElementFn) {
2901
- const start = document.createComment("fict:block:start");
2902
- const end = document.createComment("fict:block:end");
2903
- const valueSig = signal(initialValue);
2904
- const indexSig = signal(initialIndex);
2905
- const versionSig = signal(0);
2906
- const valueProxy = createValueProxy(() => {
2907
- versionSig();
2908
- return valueSig();
2909
- });
2910
- const renderCurrent = () => renderItem(valueProxy, indexSig());
2911
- const root = createRootContext();
2912
- const prev = pushRoot(root);
2913
- const nodes = [start];
2914
- let handledError = false;
2915
- try {
2916
- const output = renderCurrent();
2917
- if (output != null && output !== false) {
2918
- const el = createElementFn(output);
2919
- const rendered = toNodeArray(el);
2920
- nodes.push(...rendered);
2921
- }
2922
- nodes.push(end);
2923
- insertNodesBefore(parent, nodes, anchor);
2924
- } catch (err) {
2925
- if (handleSuspend(err, root)) {
2926
- handledError = true;
2927
- nodes.push(end);
2928
- insertNodesBefore(parent, nodes, anchor);
2929
- } else if (handleError(err, { source: "renderChild" }, root)) {
2930
- handledError = true;
2931
- nodes.push(end);
2932
- insertNodesBefore(parent, nodes, anchor);
2893
+ function runInScope(flag, fn) {
2894
+ const scope = createScope();
2895
+ const evaluate = () => isReactive(flag) ? flag() : !!flag;
2896
+ createEffect(() => {
2897
+ const enabled = evaluate();
2898
+ if (enabled) {
2899
+ scope.run(fn);
2933
2900
  } else {
2934
- throw err;
2901
+ scope.stop();
2935
2902
  }
2903
+ });
2904
+ onCleanup(scope.stop);
2905
+ }
2906
+
2907
+ // src/hooks.ts
2908
+ var ctxStack = [];
2909
+ function __fictUseContext() {
2910
+ if (ctxStack.length === 0) {
2911
+ const ctx2 = { slots: [], cursor: 0 };
2912
+ ctxStack.push(ctx2);
2913
+ return ctx2;
2914
+ }
2915
+ const ctx = ctxStack[ctxStack.length - 1];
2916
+ ctx.cursor = 0;
2917
+ return ctx;
2918
+ }
2919
+ function __fictPushContext() {
2920
+ const ctx = { slots: [], cursor: 0 };
2921
+ ctxStack.push(ctx);
2922
+ return ctx;
2923
+ }
2924
+ function __fictPopContext() {
2925
+ ctxStack.pop();
2926
+ }
2927
+ function __fictResetContext() {
2928
+ ctxStack.length = 0;
2929
+ }
2930
+ function __fictUseSignal(ctx, initial, slot) {
2931
+ const index = slot ?? ctx.cursor++;
2932
+ if (!ctx.slots[index]) {
2933
+ ctx.slots[index] = signal(initial);
2934
+ }
2935
+ return ctx.slots[index];
2936
+ }
2937
+ function __fictUseMemo(ctx, fn, slot) {
2938
+ const index = slot ?? ctx.cursor++;
2939
+ if (!ctx.slots[index]) {
2940
+ ctx.slots[index] = createMemo(fn);
2941
+ }
2942
+ return ctx.slots[index];
2943
+ }
2944
+ function __fictUseEffect(ctx, fn, slot) {
2945
+ const index = slot ?? ctx.cursor++;
2946
+ if (!ctx.slots[index]) {
2947
+ ctx.slots[index] = createEffect(fn);
2948
+ }
2949
+ }
2950
+ function __fictRender(ctx, fn) {
2951
+ ctxStack.push(ctx);
2952
+ ctx.cursor = 0;
2953
+ try {
2954
+ return fn();
2936
2955
  } finally {
2937
- popRoot(prev);
2938
- if (!handledError) {
2939
- flushOnMount(root);
2940
- } else {
2941
- destroyRoot(root);
2942
- }
2956
+ ctxStack.pop();
2943
2957
  }
2958
+ }
2959
+
2960
+ // src/versioned-signal.ts
2961
+ function createVersionedSignal(initialValue, options2) {
2962
+ const equals = options2?.equals ?? Object.is;
2963
+ const value = signal(initialValue);
2964
+ const version = signal(0);
2965
+ const bumpVersion = () => {
2966
+ const next = version() + 1;
2967
+ version(next);
2968
+ };
2944
2969
  return {
2945
- nodes,
2946
- root,
2947
- value: valueSig,
2948
- index: indexSig,
2949
- version: versionSig,
2950
- start,
2951
- end,
2952
- valueProxy,
2953
- renderCurrent
2970
+ read: () => {
2971
+ version();
2972
+ return value();
2973
+ },
2974
+ write: (next) => {
2975
+ const prev = value();
2976
+ if (!equals(prev, next)) {
2977
+ value(next);
2978
+ return;
2979
+ }
2980
+ bumpVersion();
2981
+ },
2982
+ force: () => {
2983
+ bumpVersion();
2984
+ },
2985
+ peekVersion: () => version(),
2986
+ peekValue: () => value()
2954
2987
  };
2955
2988
  }
2956
- function rerenderBlock(block, createElementFn) {
2957
- const currentContent = block.nodes.slice(1, Math.max(1, block.nodes.length - 1));
2958
- const currentNode = currentContent.length === 1 ? currentContent[0] : null;
2959
- clearRoot(block.root);
2960
- const prev = pushRoot(block.root);
2961
- let nextOutput;
2962
- let handledError = false;
2963
- try {
2964
- nextOutput = block.renderCurrent();
2965
- } catch (err) {
2966
- if (handleSuspend(err, block.root)) {
2967
- handledError = true;
2968
- popRoot(prev);
2969
- destroyRoot(block.root);
2970
- block.nodes = [block.start, block.end];
2971
- return block;
2972
- }
2973
- if (handleError(err, { source: "renderChild" }, block.root)) {
2974
- handledError = true;
2975
- popRoot(prev);
2976
- destroyRoot(block.root);
2977
- block.nodes = [block.start, block.end];
2978
- return block;
2979
- }
2980
- throw err;
2981
- } finally {
2982
- if (!handledError) {
2983
- popRoot(prev);
2984
- }
2989
+
2990
+ // src/props.ts
2991
+ var propGetters = /* @__PURE__ */ new WeakSet();
2992
+ var rawToProxy = /* @__PURE__ */ new WeakMap();
2993
+ var proxyToRaw = /* @__PURE__ */ new WeakMap();
2994
+ function __fictProp(getter) {
2995
+ if (typeof getter === "function" && getter.length === 0) {
2996
+ propGetters.add(getter);
2985
2997
  }
2986
- if (isFragmentVNode(nextOutput) && currentContent.length > 0) {
2987
- const patched = patchFragmentChildren(currentContent, nextOutput.props?.children);
2988
- if (patched) {
2989
- block.nodes = [block.start, ...currentContent, block.end];
2990
- return block;
2998
+ return getter;
2999
+ }
3000
+ function isPropGetter(value) {
3001
+ return typeof value === "function" && propGetters.has(value);
3002
+ }
3003
+ function createPropsProxy(props) {
3004
+ if (!props || typeof props !== "object") {
3005
+ return props;
3006
+ }
3007
+ if (proxyToRaw.has(props)) {
3008
+ return props;
3009
+ }
3010
+ const cached = rawToProxy.get(props);
3011
+ if (cached) {
3012
+ return cached;
3013
+ }
3014
+ const proxy = new Proxy(props, {
3015
+ get(target, prop, receiver) {
3016
+ const value = Reflect.get(target, prop, receiver);
3017
+ if (isPropGetter(value)) {
3018
+ return value();
3019
+ }
3020
+ return value;
3021
+ },
3022
+ set(target, prop, value, receiver) {
3023
+ return Reflect.set(target, prop, value, receiver);
3024
+ },
3025
+ has(target, prop) {
3026
+ return prop in target;
3027
+ },
3028
+ ownKeys(target) {
3029
+ return Reflect.ownKeys(target);
3030
+ },
3031
+ getOwnPropertyDescriptor(target, prop) {
3032
+ return Object.getOwnPropertyDescriptor(target, prop);
2991
3033
  }
3034
+ });
3035
+ rawToProxy.set(props, proxy);
3036
+ proxyToRaw.set(proxy, props);
3037
+ return proxy;
3038
+ }
3039
+ function unwrapProps(props) {
3040
+ if (!props || typeof props !== "object") {
3041
+ return props;
2992
3042
  }
2993
- if (currentNode && patchNode(currentNode, nextOutput)) {
2994
- block.nodes = [block.start, currentNode, block.end];
2995
- return block;
2996
- }
2997
- clearContent(block);
2998
- if (nextOutput != null && nextOutput !== false) {
2999
- const newNodes = toNodeArray(
3000
- nextOutput instanceof Node ? nextOutput : createElementFn(nextOutput)
3001
- );
3002
- insertNodesBefore(block.start.parentNode, newNodes, block.end);
3003
- block.nodes = [block.start, ...newNodes, block.end];
3004
- } else {
3005
- block.nodes = [block.start, block.end];
3043
+ return proxyToRaw.get(props) ?? props;
3044
+ }
3045
+ function __fictPropsRest(props, exclude) {
3046
+ const raw = unwrapProps(props);
3047
+ const out = {};
3048
+ const excludeSet = new Set(exclude);
3049
+ for (const key of Reflect.ownKeys(raw)) {
3050
+ if (excludeSet.has(key)) continue;
3051
+ out[key] = raw[key];
3006
3052
  }
3007
- return block;
3053
+ return createPropsProxy(out);
3008
3054
  }
3009
- function patchElement(el, output) {
3010
- if (output === null || output === void 0 || output === false || typeof output === "string" || typeof output === "number") {
3011
- el.textContent = output === null || output === void 0 || output === false ? "" : String(output);
3012
- return true;
3055
+ function mergeProps(...sources) {
3056
+ const validSources = sources.filter(
3057
+ (s) => s != null && (typeof s === "object" || typeof s === "function")
3058
+ );
3059
+ if (validSources.length === 0) {
3060
+ return {};
3013
3061
  }
3014
- if (output instanceof Text) {
3015
- el.textContent = output.data;
3016
- return true;
3062
+ if (validSources.length === 1 && typeof validSources[0] === "object") {
3063
+ return validSources[0];
3017
3064
  }
3018
- if (output && typeof output === "object" && !(output instanceof Node)) {
3019
- const vnode = output;
3020
- if (typeof vnode.type === "string" && vnode.type.toLowerCase() === el.tagName.toLowerCase()) {
3021
- const children = vnode.props?.children;
3022
- const props = vnode.props ?? {};
3023
- for (const [key, value] of Object.entries(props)) {
3024
- if (key === "children" || key === "key") continue;
3025
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null || value === void 0) {
3026
- if (key === "class" || key === "className") {
3027
- el.setAttribute("class", value === false || value === null ? "" : String(value));
3028
- } else if (key === "style" && typeof value === "string") {
3029
- ;
3030
- el.style.cssText = value;
3031
- } else if (value === false || value === null || value === void 0) {
3032
- el.removeAttribute(key);
3033
- } else if (value === true) {
3034
- el.setAttribute(key, "");
3035
- } else {
3036
- el.setAttribute(key, String(value));
3037
- }
3065
+ const resolveSource = (src) => {
3066
+ const value = typeof src === "function" ? src() : src;
3067
+ if (!value || typeof value !== "object") return void 0;
3068
+ return unwrapProps(value);
3069
+ };
3070
+ return new Proxy({}, {
3071
+ get(_, prop) {
3072
+ if (typeof prop === "symbol") {
3073
+ return void 0;
3074
+ }
3075
+ for (let i = validSources.length - 1; i >= 0; i--) {
3076
+ const src = validSources[i];
3077
+ const raw = resolveSource(src);
3078
+ if (!raw || !(prop in raw)) continue;
3079
+ const value = raw[prop];
3080
+ if (typeof src === "function" && !isPropGetter(value)) {
3081
+ return __fictProp(() => {
3082
+ const latest = resolveSource(src);
3083
+ if (!latest || !(prop in latest)) return void 0;
3084
+ return latest[prop];
3085
+ });
3038
3086
  }
3087
+ return value;
3039
3088
  }
3040
- if (typeof children === "string" || typeof children === "number" || children === null || children === void 0 || children === false) {
3041
- el.textContent = children === null || children === void 0 || children === false ? "" : String(children);
3042
- return true;
3089
+ return void 0;
3090
+ },
3091
+ has(_, prop) {
3092
+ for (const src of validSources) {
3093
+ const raw = resolveSource(src);
3094
+ if (raw && prop in raw) {
3095
+ return true;
3096
+ }
3043
3097
  }
3044
- if (children && typeof children === "object" && !Array.isArray(children) && !(children instanceof Node)) {
3045
- const childVNode = children;
3046
- if (typeof childVNode.type === "string") {
3047
- const childEl = el.querySelector(childVNode.type);
3048
- if (childEl && patchElement(childEl, children)) {
3049
- return true;
3098
+ return false;
3099
+ },
3100
+ ownKeys() {
3101
+ const keys = /* @__PURE__ */ new Set();
3102
+ for (const src of validSources) {
3103
+ const raw = resolveSource(src);
3104
+ if (raw) {
3105
+ for (const key of Reflect.ownKeys(raw)) {
3106
+ keys.add(key);
3050
3107
  }
3051
3108
  }
3052
3109
  }
3053
- return false;
3054
- }
3055
- }
3056
- if (output instanceof Node) {
3057
- if (output.nodeType === Node.ELEMENT_NODE) {
3058
- const nextEl = output;
3059
- if (nextEl.tagName.toLowerCase() === el.tagName.toLowerCase()) {
3060
- el.textContent = nextEl.textContent;
3061
- return true;
3110
+ return Array.from(keys);
3111
+ },
3112
+ getOwnPropertyDescriptor(_, prop) {
3113
+ for (let i = validSources.length - 1; i >= 0; i--) {
3114
+ const raw = resolveSource(validSources[i]);
3115
+ if (raw && prop in raw) {
3116
+ return {
3117
+ enumerable: true,
3118
+ configurable: true,
3119
+ get: () => {
3120
+ const value = raw[prop];
3121
+ return value;
3122
+ }
3123
+ };
3124
+ }
3062
3125
  }
3063
- } else if (output.nodeType === Node.TEXT_NODE) {
3064
- el.textContent = output.data;
3065
- return true;
3126
+ return void 0;
3066
3127
  }
3067
- }
3068
- return false;
3128
+ });
3069
3129
  }
3070
- function patchNode(currentNode, nextOutput) {
3071
- if (!currentNode) return false;
3072
- if (currentNode instanceof Text && (nextOutput === null || nextOutput === void 0 || nextOutput === false || typeof nextOutput === "string" || typeof nextOutput === "number" || nextOutput instanceof Text)) {
3073
- const nextText = nextOutput instanceof Text ? nextOutput.data : nextOutput === null || nextOutput === void 0 || nextOutput === false ? "" : String(nextOutput);
3074
- currentNode.data = nextText;
3075
- return true;
3076
- }
3077
- if (currentNode instanceof Element && patchElement(currentNode, nextOutput)) {
3078
- return true;
3079
- }
3080
- if (nextOutput instanceof Node && currentNode === nextOutput) {
3081
- return true;
3082
- }
3083
- return false;
3130
+ function useProp(getter) {
3131
+ return __fictProp(createMemo(getter));
3084
3132
  }
3085
- function isFragmentVNode(value) {
3086
- return value != null && typeof value === "object" && !(value instanceof Node) && value.type === Fragment;
3133
+
3134
+ // src/ref.ts
3135
+ function createRef() {
3136
+ return { current: null };
3087
3137
  }
3088
- function normalizeChildren(children, result = []) {
3089
- if (children === void 0) {
3090
- return result;
3091
- }
3092
- if (Array.isArray(children)) {
3093
- for (const child of children) {
3094
- normalizeChildren(child, result);
3095
- }
3096
- return result;
3097
- }
3098
- if (children === null || children === false) {
3099
- return result;
3138
+
3139
+ // src/transition.ts
3140
+ function startTransition(fn) {
3141
+ const prev = setTransitionContext(true);
3142
+ try {
3143
+ fn();
3144
+ } finally {
3145
+ setTransitionContext(prev);
3146
+ scheduleFlush();
3100
3147
  }
3101
- result.push(children);
3102
- return result;
3103
3148
  }
3104
- function patchFragmentChildren(nodes, children) {
3105
- const normalized = normalizeChildren(children);
3106
- if (normalized.length !== nodes.length) {
3107
- return false;
3108
- }
3109
- for (let i = 0; i < normalized.length; i++) {
3110
- if (!patchNode(nodes[i], normalized[i])) {
3111
- return false;
3112
- }
3113
- }
3114
- return true;
3149
+ function useTransition() {
3150
+ const pending = signal(false);
3151
+ const start = (fn) => {
3152
+ pending(true);
3153
+ startTransition(() => {
3154
+ try {
3155
+ fn();
3156
+ } finally {
3157
+ pending(false);
3158
+ }
3159
+ });
3160
+ };
3161
+ return [() => pending(), start];
3115
3162
  }
3116
- function clearContent(block) {
3117
- const nodes = block.nodes.slice(1, Math.max(1, block.nodes.length - 1));
3118
- removeNodes(nodes);
3163
+ function useDeferredValue(getValue) {
3164
+ const deferredValue = signal(getValue());
3165
+ createEffect(() => {
3166
+ const newValue = getValue();
3167
+ const currentDeferred = untrack(() => deferredValue());
3168
+ if (currentDeferred !== newValue) {
3169
+ startTransition(() => {
3170
+ deferredValue(newValue);
3171
+ });
3172
+ }
3173
+ });
3174
+ return () => deferredValue();
3119
3175
  }
3120
- function removeBlockNodes(block) {
3121
- let cursor = block.start;
3122
- const end = block.end;
3123
- while (cursor) {
3124
- const next = cursor.nextSibling;
3125
- cursor.parentNode?.removeChild(cursor);
3126
- if (cursor === end) break;
3127
- cursor = next;
3128
- }
3176
+
3177
+ // src/scheduler.ts
3178
+ function batch2(fn) {
3179
+ return batch(fn);
3129
3180
  }
3130
- function bumpBlockVersion(block) {
3131
- block.version(block.version() + 1);
3181
+ function untrack2(fn) {
3182
+ return untrack(fn);
3132
3183
  }
3133
3184
 
3134
3185
  // src/dom.ts
@@ -4180,6 +4231,7 @@ export {
4180
4231
  bindRef,
4181
4232
  bindStyle,
4182
4233
  bindText,
4234
+ callEventHandler,
4183
4235
  classList,
4184
4236
  clearDelegatedEvents,
4185
4237
  createAttributeBinding,
@@ -4198,6 +4250,7 @@ export {
4198
4250
  createRef,
4199
4251
  createRenderEffect,
4200
4252
  createRoot,
4253
+ createScope,
4201
4254
  createSelector,
4202
4255
  createShow,
4203
4256
  signal as createSignal,
@@ -4208,6 +4261,7 @@ export {
4208
4261
  createVersionedSignal,
4209
4262
  delegateEvents,
4210
4263
  destroyMarkerBlock,
4264
+ effectScope,
4211
4265
  getDevtoolsHook,
4212
4266
  getFirstNodeAfter,
4213
4267
  getPropAlias,
@@ -4225,6 +4279,7 @@ export {
4225
4279
  reconcileArrays,
4226
4280
  removeNodes,
4227
4281
  render,
4282
+ runInScope,
4228
4283
  setCycleProtectionOptions,
4229
4284
  spread,
4230
4285
  startTransition,