marko 6.3.23 → 6.3.25

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.
@@ -24,6 +24,7 @@ const BranchScopes$1 = "BranchScopes:";
24
24
  const ClosureScopes = "ClosureScopes:";
25
25
  const ClosureSignalIndex = "ClosureSignalIndex:";
26
26
  const ConditionalRenderer = "ConditionalRenderer:";
27
+ const ControlledObserver = "ControlledObserver:";
27
28
  const ControlledHandler = "ControlledHandler:";
28
29
  const ControlledType = "ControlledType:";
29
30
  const ControlledValue = "ControlledValue:";
@@ -685,7 +686,7 @@ const walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
685
686
  currentWalkIndex = walkInternal(currentWalkIndex, walkCodes, scope[getDebugKey(currentScopeIndex++, "#childScope")] = createScope(scope[Global], scope[ClosestBranch]));
686
687
  if (value === 48) scope[getDebugKey(currentScopeIndex++, "#scopeOffset")] = skipScope();
687
688
  } else if (value < 92) {
688
- value = 20 * currentMultiplier + value - 67;
689
+ value = 25 * currentMultiplier + value - 67;
689
690
  while (value--) walker.nextNode();
690
691
  } else if (value < 107) {
691
692
  value = 10 * currentMultiplier + value - 97;
@@ -1009,6 +1010,36 @@ function _attr_input_checked_default(scope, nodeAccessor, checked) {
1009
1010
  if (restoreValue !== normalizedChecked) el.checked = restoreValue;
1010
1011
  }
1011
1012
  }
1013
+ /** Filled by the latches a compiled page emits, so a page carries only the
1014
+ * control kinds its tags can be (`_attrs_script` resolves the kind at run time). */
1015
+ const controllableScripts = {};
1016
+ /** The render pass equivalent, for a tag whose name is only known at run time;
1017
+ * a statically named tag passes its claim to `_attrs` instead. */
1018
+ const controllableRenders = {};
1019
+ function _enable_controllable_input() {
1020
+ controllableScripts[0] = _attr_input_checked_script;
1021
+ controllableScripts[1] = _attr_input_checkedValue_script;
1022
+ controllableScripts[2] = _attr_input_value_script;
1023
+ }
1024
+ function _enable_controllable_textarea() {
1025
+ controllableScripts[2] = _attr_input_value_script;
1026
+ }
1027
+ function _enable_controllable_select() {
1028
+ controllableScripts[3] = _attr_select_value_script;
1029
+ }
1030
+ function _enable_controllable_open() {
1031
+ controllableScripts[4] = _attr_details_or_dialog_open_script;
1032
+ }
1033
+ /** A run-time tag name can be any controllable, so its page enables them all. */
1034
+ function _enable_controllable() {
1035
+ _enable_controllable_input();
1036
+ _enable_controllable_select();
1037
+ _enable_controllable_open();
1038
+ controllableRenders.INPUT = _controllable_input;
1039
+ controllableRenders.TEXTAREA = _controllable_textarea;
1040
+ controllableRenders.SELECT = _controllable_select;
1041
+ controllableRenders.DETAILS = controllableRenders.DIALOG = _controllable_open;
1042
+ }
1012
1043
  function _attr_input_checked(scope, nodeAccessor, checked, checkedChange) {
1013
1044
  const el = scope[nodeAccessor];
1014
1045
  const normalizedChecked = isNotVoid(checked);
@@ -1170,12 +1201,12 @@ function _attr_select_value_script(scope, nodeAccessor) {
1170
1201
  }
1171
1202
  }
1172
1203
  syncControllableFormInput(el, hasSelectChanged, onChange);
1173
- new MutationObserver(() => {
1174
- const value = scope[ControlledValue + nodeAccessor];
1175
- if (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((_, i) => !value.includes(el.selectedOptions[i].value)) : el.value !== value) onChange();
1176
- }).observe(el, {
1204
+ observeOnce(scope, nodeAccessor, {
1177
1205
  childList: true,
1178
1206
  subtree: true
1207
+ }, () => {
1208
+ const value = scope[ControlledValue + nodeAccessor];
1209
+ if (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((_, i) => !value.includes(el.selectedOptions[i].value)) : el.value !== value) onChange();
1179
1210
  });
1180
1211
  }
1181
1212
  function setSelectValue(el, value, multiple) {
@@ -1205,7 +1236,10 @@ function _attr_details_or_dialog_open(scope, nodeAccessor, open, openChange) {
1205
1236
  }
1206
1237
  function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
1207
1238
  const el = scope[nodeAccessor];
1208
- new MutationObserver(() => {
1239
+ observeOnce(scope, nodeAccessor, {
1240
+ attributes: true,
1241
+ attributeFilter: ["open"]
1242
+ }, () => {
1209
1243
  const openChange = scope[ControlledHandler + nodeAccessor];
1210
1244
  if (openChange && el.open === !scope["ControlledValue:" + nodeAccessor]) {
1211
1245
  const newValue = el.open;
@@ -1213,11 +1247,11 @@ function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
1213
1247
  openChange(newValue);
1214
1248
  run();
1215
1249
  }
1216
- }).observe(el, {
1217
- attributes: true,
1218
- attributeFilter: ["open"]
1219
1250
  });
1220
1251
  }
1252
+ function observeOnce(scope, nodeAccessor, init, callback) {
1253
+ (scope[ControlledObserver + nodeAccessor] ||= new MutationObserver(callback)).observe(scope[nodeAccessor], init);
1254
+ }
1221
1255
  function syncControllableFormInput(el, hasChanged, onChange) {
1222
1256
  el._ = onChange;
1223
1257
  delegate("input", handleChange);
@@ -1253,6 +1287,35 @@ function updateList(arr, val, push) {
1253
1287
  const index = arr.indexOf(val);
1254
1288
  return (push ? !~index && [...arr, val] : ~index && arr.slice(0, index).concat(arr.slice(index + 1))) || arr;
1255
1289
  }
1290
+ function _controllable_input(scope, nodeAccessor, nextAttrs) {
1291
+ if ("checked" in nextAttrs || "checkedChange" in nextAttrs) {
1292
+ _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
1293
+ return /^checked(?:Value)?(?:Change)?$/;
1294
+ }
1295
+ if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) {
1296
+ _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
1297
+ return /^(?:value|checked(?:Value)?)(?:Change)?$/;
1298
+ }
1299
+ return _controllable_textarea(scope, nodeAccessor, nextAttrs, _attr_input_value_dynamic_default);
1300
+ }
1301
+ function _controllable_textarea(scope, nodeAccessor, nextAttrs, dynamicDefault) {
1302
+ if ("value" in nextAttrs || "valueChange" in nextAttrs) {
1303
+ _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange, dynamicDefault);
1304
+ return /^value(?:Change)?$/;
1305
+ }
1306
+ }
1307
+ function _controllable_select(scope, nodeAccessor, nextAttrs) {
1308
+ if ("value" in nextAttrs || "valueChange" in nextAttrs) {
1309
+ _attr_select_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
1310
+ return /^value(?:Change)?$/;
1311
+ }
1312
+ }
1313
+ function _controllable_open(scope, nodeAccessor, nextAttrs) {
1314
+ if ("open" in nextAttrs || "openChange" in nextAttrs) {
1315
+ _attr_details_or_dialog_open(scope, nodeAccessor, nextAttrs.open, nextAttrs.openChange);
1316
+ return /^open(?:Change)?$/;
1317
+ }
1318
+ }
1256
1319
  //#endregion
1257
1320
  //#region src/dom/dom.ts
1258
1321
  function _to_text(value) {
@@ -1310,23 +1373,23 @@ function _text_content(node, value) {
1310
1373
  const normalizedValue = _to_text(value);
1311
1374
  if (node.textContent !== normalizedValue) node.textContent = normalizedValue;
1312
1375
  }
1313
- function _attrs(scope, nodeAccessor, nextAttrs) {
1376
+ function _attrs(scope, nodeAccessor, nextAttrs, controllable) {
1314
1377
  const el = scope[nodeAccessor];
1315
1378
  for (let i = el.attributes.length; i--;) {
1316
1379
  const { name } = el.attributes.item(i);
1317
1380
  if (!(nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)))) el.removeAttribute(name);
1318
1381
  }
1319
1382
  assertExclusiveAttrs(nextAttrs);
1320
- attrsInternal(scope, nodeAccessor, nextAttrs);
1383
+ attrsInternal(scope, nodeAccessor, nextAttrs, controllable);
1321
1384
  }
1322
- function _attrs_content(scope, nodeAccessor, nextAttrs) {
1323
- _attrs(scope, nodeAccessor, nextAttrs);
1385
+ function _attrs_content(scope, nodeAccessor, nextAttrs, controllable) {
1386
+ _attrs(scope, nodeAccessor, nextAttrs, controllable);
1324
1387
  _attr_content(scope, nodeAccessor, nextAttrs?.content);
1325
1388
  }
1326
1389
  function hasAttrAlias(element, attr, nextAttrs) {
1327
1390
  return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
1328
1391
  }
1329
- function _attrs_partial(scope, nodeAccessor, nextAttrs, skip) {
1392
+ function _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable) {
1330
1393
  const el = scope[nodeAccessor];
1331
1394
  const partial = {};
1332
1395
  for (let i = el.attributes.length; i--;) {
@@ -1341,52 +1404,19 @@ function _attrs_partial(scope, nodeAccessor, nextAttrs, skip) {
1341
1404
  ...nextAttrs,
1342
1405
  ...skip
1343
1406
  });
1344
- attrsInternal(scope, nodeAccessor, partial);
1407
+ attrsInternal(scope, nodeAccessor, partial, controllable);
1345
1408
  }
1346
- function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip) {
1347
- _attrs_partial(scope, nodeAccessor, nextAttrs, skip);
1409
+ function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip, controllable) {
1410
+ _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable);
1348
1411
  _attr_content(scope, nodeAccessor, nextAttrs?.content);
1349
1412
  }
1350
- function attrsInternal(scope, nodeAccessor, nextAttrs) {
1413
+ function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
1351
1414
  const el = scope[nodeAccessor];
1352
1415
  let events = scope[EventAttributes + nodeAccessor];
1353
- let skip;
1354
1416
  for (const name in events) events[name] = 0;
1355
1417
  scope[ControlledType + nodeAccessor] = 5;
1356
1418
  scope[ControlledHandler + nodeAccessor] = 0;
1357
- switch (nextAttrs && el.tagName) {
1358
- case "INPUT":
1359
- if ("checked" in nextAttrs || "checkedChange" in nextAttrs) {
1360
- _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
1361
- skip = /^checked(?:Value)?(?:Change)?$/;
1362
- } else if ("checkedValue" in nextAttrs || "checkedValueChange" in nextAttrs) {
1363
- _attr_input_checkedValue(scope, nodeAccessor, nextAttrs.checkedValue, nextAttrs.checkedValueChange, nextAttrs.value);
1364
- skip = /^(?:value|checked(?:Value)?)(?:Change)?$/;
1365
- } else if ("value" in nextAttrs || "valueChange" in nextAttrs) {
1366
- _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange, _attr_input_value_dynamic_default);
1367
- skip = /^value(?:Change)?$/;
1368
- }
1369
- break;
1370
- case "SELECT":
1371
- if ("value" in nextAttrs || "valueChange" in nextAttrs) {
1372
- _attr_select_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
1373
- skip = /^value(?:Change)?$/;
1374
- }
1375
- break;
1376
- case "TEXTAREA":
1377
- if ("value" in nextAttrs || "valueChange" in nextAttrs) {
1378
- _attr_input_value(scope, nodeAccessor, nextAttrs.value, nextAttrs.valueChange);
1379
- skip = /^value(?:Change)?$/;
1380
- }
1381
- break;
1382
- case "DETAILS":
1383
- case "DIALOG":
1384
- if ("open" in nextAttrs || "openChange" in nextAttrs) {
1385
- _attr_details_or_dialog_open(scope, nodeAccessor, nextAttrs.open, nextAttrs.openChange);
1386
- skip = /^open(?:Change)?$/;
1387
- }
1388
- break;
1389
- }
1419
+ const skip = nextAttrs && (controllable || controllableRenders[el.tagName])?.(scope, nodeAccessor, nextAttrs);
1390
1420
  for (const name in nextAttrs) {
1391
1421
  const value = nextAttrs[name];
1392
1422
  switch (name) {
@@ -1415,23 +1445,7 @@ function _attr_content(scope, nodeAccessor, value) {
1415
1445
  function _attrs_script(scope, nodeAccessor) {
1416
1446
  const el = scope[nodeAccessor];
1417
1447
  const events = scope[EventAttributes + nodeAccessor];
1418
- switch (scope[ControlledType + nodeAccessor]) {
1419
- case 0:
1420
- _attr_input_checked_script(scope, nodeAccessor);
1421
- break;
1422
- case 1:
1423
- _attr_input_checkedValue_script(scope, nodeAccessor);
1424
- break;
1425
- case 2:
1426
- _attr_input_value_script(scope, nodeAccessor);
1427
- break;
1428
- case 3:
1429
- _attr_select_value_script(scope, nodeAccessor);
1430
- break;
1431
- case 4:
1432
- _attr_details_or_dialog_open_script(scope, nodeAccessor);
1433
- break;
1434
- }
1448
+ controllableScripts[scope[ControlledType + nodeAccessor]]?.(scope, nodeAccessor);
1435
1449
  for (const name in events) _on(el, name, events[name]);
1436
1450
  }
1437
1451
  function _html(scope, value, accessor) {
@@ -1494,58 +1508,64 @@ function _await_promise(nodeAccessor, params) {
1494
1508
  const promiseAccessor = Promise$1 + nodeAccessor;
1495
1509
  const branchAccessor = BranchScopes$1 + nodeAccessor;
1496
1510
  _enable_catch();
1497
- return (scope, promise) => {
1498
- if (!isPromise(promise)) {
1499
- if (!scope[promiseAccessor]) {
1500
- const resolve = () => resolveAwait(scope, branchAccessor, nodeAccessor, scope[nodeAccessor], params, promise);
1501
- if (scope[branchAccessor]) resolve();
1502
- else scope[promiseAccessor] = resolve;
1503
- return;
1504
- }
1505
- promise = Promise.resolve(promise);
1511
+ const resolveAwait = (scope, referenceNode, value) => {
1512
+ const awaitBranch = scope[branchAccessor];
1513
+ if (awaitBranch["#DetachedAwait"]) {
1514
+ awaitBranch[PendingScopes] = awaitBranch[PendingScopes]?.forEach(syncGen);
1515
+ setupBranch(awaitBranch[DetachedAwait], awaitBranch);
1516
+ awaitBranch[DetachedAwait] = 0;
1517
+ insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]);
1518
+ referenceNode.remove();
1506
1519
  }
1520
+ params?.(awaitBranch, [value]);
1521
+ return awaitBranch;
1522
+ };
1523
+ const awaitPromise = (scope, promise) => {
1524
+ if (!isPromise(promise) && scope[promiseAccessor]) promise = Promise.resolve(promise);
1507
1525
  let awaitBranch = scope[branchAccessor];
1508
1526
  const tryPlaceholder = findBranchWithKey(scope, PlaceholderContent);
1509
1527
  const tryBranch = tryPlaceholder || awaitBranch;
1528
+ if (!(isPromise(promise) ? tryBranch : awaitBranch)) {
1529
+ scope[promiseAccessor] = () => awaitPromise(scope, promise);
1530
+ return;
1531
+ }
1532
+ if (!isPromise(promise)) {
1533
+ resolveAwait(scope, scope[nodeAccessor], promise);
1534
+ return;
1535
+ }
1510
1536
  let awaitCounter = tryBranch[AwaitCounter];
1511
1537
  placeholderShown.add(pendingEffects);
1512
- if (tryPlaceholder) {
1513
- if (!scope[promiseAccessor]) {
1514
- if (awaitBranch) awaitBranch[PendingRenders] ||= [];
1515
- awaitCounter = addAwaitCounter(scope, tryPlaceholder);
1516
- }
1517
- } else {
1518
- if (!awaitCounter?.i) awaitCounter = tryBranch[AwaitCounter] = {
1519
- i: 0,
1520
- c() {
1521
- if (--awaitCounter.i) return 1;
1522
- if (tryBranch === scope[branchAccessor]) {
1523
- const anchor = scope[nodeAccessor];
1524
- if (anchor.parentNode) {
1525
- const detachedParent = scope[branchAccessor][StartNode].parentNode;
1526
- if (detachedParent === anchor.parentNode) anchor.remove();
1527
- else anchor.replaceWith(detachedParent);
1528
- }
1529
- } else dismissPlaceholder(tryBranch);
1530
- queueEffect(tryBranch, runPendingEffects);
1538
+ if (!tryPlaceholder && !awaitCounter?.i) awaitCounter = createAwaitCounter(tryBranch, () => {
1539
+ if (tryBranch === scope[branchAccessor]) {
1540
+ const anchor = scope[nodeAccessor];
1541
+ if (anchor.parentNode) {
1542
+ const detachedParent = scope[branchAccessor][StartNode].parentNode;
1543
+ if (detachedParent === anchor.parentNode) anchor.remove();
1544
+ else anchor.replaceWith(detachedParent);
1531
1545
  }
1532
- };
1533
- if (!scope[promiseAccessor]) {
1534
- if (awaitBranch) awaitBranch[PendingRenders] ||= [];
1535
- if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
1536
- if (!awaitBranch["#DetachedAwait"]) {
1537
- awaitBranch["#StartNode"].parentNode.insertBefore(scope[nodeAccessor], awaitBranch["#StartNode"]);
1538
- tempDetachBranch(tryBranch);
1539
- }
1540
- }, -1))));
1541
- }
1546
+ } else dismissPlaceholder(tryBranch);
1547
+ });
1548
+ if (!scope[promiseAccessor]) {
1549
+ if (awaitBranch) awaitBranch[PendingRenders] ||= [];
1550
+ if (tryPlaceholder) awaitCounter = addAwaitCounter(scope, tryPlaceholder);
1551
+ else if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
1552
+ if (!awaitBranch["#DetachedAwait"]) {
1553
+ awaitBranch["#StartNode"].parentNode.insertBefore(scope[nodeAccessor], awaitBranch["#StartNode"]);
1554
+ tempDetachBranch(tryBranch);
1555
+ }
1556
+ }, -1))));
1542
1557
  }
1543
1558
  const thisPromise = scope[promiseAccessor] = promise.then((data) => {
1544
1559
  if (thisPromise === scope[promiseAccessor]) {
1545
1560
  const referenceNode = scope[nodeAccessor];
1546
1561
  scope[promiseAccessor] = 0;
1562
+ if (scope["#ClosestBranch"]?.["#Gen"] === 0) {
1563
+ awaitCounter.c();
1564
+ run();
1565
+ return;
1566
+ }
1547
1567
  queueAsyncRender(scope, () => {
1548
- awaitBranch = resolveAwait(scope, branchAccessor, nodeAccessor, referenceNode, params, data);
1568
+ awaitBranch = resolveAwait(scope, referenceNode, data);
1549
1569
  const pendingRenders = awaitBranch[PendingRenders];
1550
1570
  awaitBranch[PendingRenders] = 0;
1551
1571
  pendingRenders?.forEach(queuePendingRender);
@@ -1577,18 +1597,7 @@ function _await_promise(nodeAccessor, params) {
1577
1597
  }
1578
1598
  });
1579
1599
  };
1580
- }
1581
- function resolveAwait(scope, branchAccessor, nodeAccessor, referenceNode, params, value) {
1582
- const awaitBranch = scope[branchAccessor];
1583
- if (awaitBranch["#DetachedAwait"]) {
1584
- awaitBranch[PendingScopes] = awaitBranch[PendingScopes]?.forEach(syncGen);
1585
- setupBranch(awaitBranch[DetachedAwait], awaitBranch);
1586
- awaitBranch[DetachedAwait] = 0;
1587
- insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]);
1588
- referenceNode.remove();
1589
- }
1590
- params?.(awaitBranch, [value]);
1591
- return awaitBranch;
1600
+ return awaitPromise;
1592
1601
  }
1593
1602
  function _await_content(nodeAccessor, template, walks, setup) {
1594
1603
  const branchAccessor = BranchScopes$1 + nodeAccessor;
@@ -1607,19 +1616,23 @@ function _await_content(nodeAccessor, template, walks, setup) {
1607
1616
  function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, PlaceholderContent)) {
1608
1617
  if (!tryBranch) return;
1609
1618
  let awaitCounter = tryBranch[AwaitCounter];
1610
- if (!awaitCounter?.i) awaitCounter = tryBranch[AwaitCounter] = {
1619
+ if (!awaitCounter?.i) awaitCounter = createAwaitCounter(tryBranch, () => dismissPlaceholder(tryBranch));
1620
+ placeholderShown.add(pendingEffects);
1621
+ if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch, () => {
1622
+ insertBranchBefore(tryBranch["#PlaceholderBranch"] = createAndSetupBranch(tryBranch["$global"], tryBranch["#PlaceholderContent"], tryBranch["_"], tryBranch["#StartNode"].parentNode), tryBranch["#StartNode"].parentNode, tryBranch["#StartNode"]);
1623
+ tempDetachBranch(tryBranch);
1624
+ }, -1))));
1625
+ return awaitCounter;
1626
+ }
1627
+ function createAwaitCounter(tryBranch, done) {
1628
+ const awaitCounter = tryBranch[AwaitCounter] = {
1611
1629
  i: 0,
1612
1630
  c() {
1613
1631
  if (--awaitCounter.i) return 1;
1614
- dismissPlaceholder(tryBranch);
1632
+ done();
1615
1633
  queueEffect(tryBranch, runPendingEffects);
1616
1634
  }
1617
1635
  };
1618
- placeholderShown.add(pendingEffects);
1619
- if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch, () => {
1620
- insertBranchBefore(tryBranch["#PlaceholderBranch"] = createAndSetupBranch(tryBranch["$global"], tryBranch["#PlaceholderContent"], tryBranch["_"], tryBranch["#StartNode"].parentNode), tryBranch["#StartNode"].parentNode, tryBranch["#StartNode"]);
1621
- tempDetachBranch(tryBranch);
1622
- }, -1))));
1623
1636
  return awaitCounter;
1624
1637
  }
1625
1638
  function runPendingEffects(scope) {
@@ -2335,4 +2348,4 @@ function getSelectorOrResolve(selector, resolve) {
2335
2348
  return document.querySelector(selector) || (console.warn(`A lazy load trigger could not find an element matching "${selector}". The module was loaded immediately.`), resolve());
2336
2349
  }
2337
2350
  //#endregion
2338
- export { $signal, $signalReset, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_attribute_default, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_dynamic_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _dynamic_tag, _dynamic_tag_content, _el, _el_read, _enable_catch, _for_closure, _for_in, _for_of, _for_selector, _for_to, _for_until, _hoist, _hoist_resume, _html, _id, _if, _if_closure, _let, _let_change, _lifecycle, _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, _on, _or, _resume, _resume_dynamic_tag, _return, _return_change, _script, _show, _style_rule_item, _style_shell, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, ready, run };
2351
+ export { $signal, $signalReset, _assert_hoist, _assert_init, _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_checked_default, _attr_input_checked_script, _attr_input_value, _attr_input_value as _attr_textarea_value, _attr_input_value_attribute_default, _attr_input_value_default, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_dynamic_default, _attr_input_value_script, _attr_input_value_script as _attr_textarea_value_script, _attr_nonce, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _await_content, _await_promise, _call, _child_setup, _closure, _closure_get, _const, _content, _content_closures, _content_resume, _controllable_input, _controllable_open, _controllable_select, _controllable_textarea, _dynamic_tag, _dynamic_tag_content, _el, _el_read, _enable_catch, _enable_controllable, _enable_controllable_input, _enable_controllable_open, _enable_controllable_select, _enable_controllable_textarea, _for_closure, _for_in, _for_of, _for_selector, _for_to, _for_until, _hoist, _hoist_resume, _html, _id, _if, _if_closure, _let, _let_change, _lifecycle, _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, _on, _or, _resume, _resume_dynamic_tag, _return, _return_change, _script, _show, _style_rule_item, _style_shell, _template, _text, _text_content, _to_text, _try, _var, _var_change, _var_resume, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, init, initEmbedded, ready, run };
@@ -624,7 +624,7 @@ function writeScopesRoot(state, flushes) {
624
624
  const ref = state.refs.get(scope) || newScopeReference(state, scope, scopeId);
625
625
  const openIndex = buf.push("") - 1;
626
626
  if (writeObjectProps(state, flush[2], ref)) {
627
- buf[openIndex] = nextSlotId === -1 ? "[" + scopeId + ",{" : (scopeId > nextSlotId ? "," + (scopeId - nextSlotId) : "") + ",{";
627
+ buf[openIndex] = nextSlotId === -1 ? "[" + scopeId + ",{" : (scopeId !== nextSlotId ? "," + (scopeId - nextSlotId) : "") + ",{";
628
628
  if (fillIndex === -1) fillIndex = openIndex;
629
629
  nextSlotId = scopeId + 1;
630
630
  buf.push("}");
@@ -622,7 +622,7 @@ function writeScopesRoot(state, flushes) {
622
622
  const ref = state.refs.get(scope) || newScopeReference(state, scope, scopeId);
623
623
  const openIndex = buf.push("") - 1;
624
624
  if (writeObjectProps(state, flush[2], ref)) {
625
- buf[openIndex] = nextSlotId === -1 ? "[" + scopeId + ",{" : (scopeId > nextSlotId ? "," + (scopeId - nextSlotId) : "") + ",{";
625
+ buf[openIndex] = nextSlotId === -1 ? "[" + scopeId + ",{" : (scopeId !== nextSlotId ? "," + (scopeId - nextSlotId) : "") + ",{";
626
626
  if (fillIndex === -1) fillIndex = openIndex;
627
627
  nextSlotId = scopeId + 1;
628
628
  buf.push("}");
@@ -1,5 +1,22 @@
1
- import { type Accessor, type Scope } from "../common/types";
1
+ import { type Accessor, ControlledType, type Scope } from "../common/types";
2
2
  export declare function _attr_input_checked_default(scope: Scope, nodeAccessor: Accessor, checked: boolean): void;
3
+ /** Filled by the latches a compiled page emits, so a page carries only the
4
+ * control kinds its tags can be (`_attrs_script` resolves the kind at run time). */
5
+ export declare const controllableScripts: {
6
+ [T in ControlledType]?: (scope: Scope, nodeAccessor: Accessor) => void;
7
+ };
8
+ /** The render pass equivalent, for a tag whose name is only known at run time;
9
+ * a statically named tag passes its claim to `_attrs` instead. */
10
+ export declare const controllableRenders: {
11
+ [tagName: string]: ControllableAttrs;
12
+ };
13
+ export type ControllableAttrs = (scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>) => RegExp | void;
14
+ export declare function _enable_controllable_input(): void;
15
+ export declare function _enable_controllable_textarea(): void;
16
+ export declare function _enable_controllable_select(): void;
17
+ export declare function _enable_controllable_open(): void;
18
+ /** A run-time tag name can be any controllable, so its page enables them all. */
19
+ export declare function _enable_controllable(): void;
3
20
  export declare function _attr_input_checked(scope: Scope, nodeAccessor: Accessor, checked: unknown, checkedChange: unknown): void;
4
21
  export declare function _attr_input_checked_script(scope: Scope, nodeAccessor: Accessor): void;
5
22
  export declare function _attr_input_checkedValue_default(scope: Scope, nodeAccessor: Accessor, checkedValue: unknown, value: unknown): void;
@@ -16,3 +33,7 @@ export declare function _attr_select_value_script(scope: Scope, nodeAccessor: Ac
16
33
  export declare function _attr_details_or_dialog_open_default(scope: Scope, nodeAccessor: Accessor, open: unknown): void;
17
34
  export declare function _attr_details_or_dialog_open(scope: Scope, nodeAccessor: Accessor, open: unknown, openChange: unknown): void;
18
35
  export declare function _attr_details_or_dialog_open_script(scope: Scope, nodeAccessor: Accessor): void;
36
+ export declare function _controllable_input(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>): RegExp | undefined;
37
+ export declare function _controllable_textarea(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>, dynamicDefault?: typeof _attr_input_value_dynamic_default): RegExp | undefined;
38
+ export declare function _controllable_select(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>): RegExp | undefined;
39
+ export declare function _controllable_open(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>): RegExp | undefined;
package/dist/dom/dom.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { type Accessor, type Scope } from "../common/types";
2
+ import { type ControllableAttrs } from "./controllable";
2
3
  export declare function _to_text(value: unknown): string;
3
4
  export declare function _attr(element: Element, name: string, value: unknown): void;
4
5
  export declare function _attr_class(element: Element, value: unknown): void;
@@ -12,10 +13,10 @@ export declare function _style_rule_item(element: HTMLStyleElement, name: string
12
13
  export declare function _attr_nonce(scope: Scope, nodeAccessor: Accessor): void;
13
14
  export declare function _text(node: Text | Comment, value: unknown): void;
14
15
  export declare function _text_content(node: ParentNode, value: unknown): void;
15
- export declare function _attrs(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>): void;
16
- export declare function _attrs_content(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>): void;
17
- export declare function _attrs_partial(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>, skip: Record<string, 1>): void;
18
- export declare function _attrs_partial_content(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>, skip: Record<string, 1>): void;
16
+ export declare function _attrs(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>, controllable?: ControllableAttrs): void;
17
+ export declare function _attrs_content(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>, controllable?: ControllableAttrs): void;
18
+ export declare function _attrs_partial(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>, skip: Record<string, 1>, controllable?: ControllableAttrs): void;
19
+ export declare function _attrs_partial_content(scope: Scope, nodeAccessor: Accessor, nextAttrs: Record<string, unknown>, skip: Record<string, 1>, controllable?: ControllableAttrs): void;
19
20
  export declare function _attr_content(scope: Scope, nodeAccessor: Accessor, value: unknown): void;
20
21
  export declare function _attrs_script(scope: Scope, nodeAccessor: Accessor): void;
21
22
  export declare function _html(scope: Scope, value: unknown, accessor: Accessor): void;
package/dist/dom.d.ts CHANGED
@@ -5,7 +5,7 @@ export { _call } from "./common/helpers";
5
5
  export { $signal, $signalReset } from "./dom/abort-signal";
6
6
  export { compat } from "./dom/compat";
7
7
  export { _await_content, _await_promise, _dynamic_tag, _dynamic_tag_content, _for_in, _for_of, _for_to, _for_until, _if, _resume_dynamic_tag, _show, _try, } from "./dom/control-flow";
8
- export { _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checked_default, _attr_input_checked_script, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_value, _attr_input_value_attribute_default, _attr_input_value_default, _attr_input_value_dynamic_default, _attr_input_value_script, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_input_value as _attr_textarea_value, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_script as _attr_textarea_value_script, } from "./dom/controllable";
8
+ export { _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open_default as _attr_details_open_default, _attr_details_or_dialog_open_script as _attr_details_open_script, _attr_details_or_dialog_open as _attr_dialog_open, _attr_details_or_dialog_open_default as _attr_dialog_open_default, _attr_details_or_dialog_open_script as _attr_dialog_open_script, _attr_input_checked, _attr_input_checked_default, _attr_input_checked_script, _attr_input_checkedValue, _attr_input_checkedValue_default, _attr_input_checkedValue_script, _attr_input_value, _attr_input_value_attribute_default, _attr_input_value_default, _attr_input_value_dynamic_default, _attr_input_value_script, _attr_select_value, _attr_select_value_default, _attr_select_value_script, _attr_input_value as _attr_textarea_value, _attr_input_value_default as _attr_textarea_value_default, _attr_input_value_script as _attr_textarea_value_script, _controllable_input, _controllable_open, _controllable_select, _controllable_textarea, _enable_controllable, _enable_controllable_input, _enable_controllable_open, _enable_controllable_select, _enable_controllable_textarea, } from "./dom/controllable";
9
9
  export { _attr, _attr_class, _attr_class_item, _attr_class_items, _attr_content, _attr_nonce, _attr_style, _attr_style_item, _attr_style_items, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_script, _html, _lifecycle, _style_rule_item, _style_shell, _text, _text_content, _to_text, } from "./dom/dom";
10
10
  export { _on } from "./dom/event";
11
11
  export { _load_event_trigger, _load_idle_trigger, _load_media_trigger, _load_race_trigger, _load_setup, _load_signal, _load_template, _load_visible_trigger, } from "./dom/load";