@aevantec/litevue 0.6.1 → 0.6.3

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.
Files changed (97) hide show
  1. package/dist/litevue-devtools.iife.js +1 -1
  2. package/dist/litevue-devtools.mjs +1 -1
  3. package/dist/litevue-devtools.umd.js +1 -1
  4. package/dist/litevue-plugins.dev.iife.js +67 -125
  5. package/dist/litevue-plugins.dev.mjs +67 -124
  6. package/dist/litevue-plugins.iife.js +1 -1
  7. package/dist/litevue-plugins.mjs +1 -1
  8. package/dist/litevue-plugins.umd.js +1 -1
  9. package/dist/litevue.dev.iife.js +122 -159
  10. package/dist/litevue.dev.mjs +122 -158
  11. package/dist/litevue.iife.js +1 -1
  12. package/dist/litevue.mjs +1 -1
  13. package/dist/litevue.umd.js +1 -1
  14. package/dist/plugins/collapse.iife.js +1 -1
  15. package/dist/plugins/collapse.mjs +1 -1
  16. package/dist/plugins/collapse.umd.js +1 -1
  17. package/dist/plugins/focus.iife.js +1 -1
  18. package/dist/plugins/focus.mjs +1 -1
  19. package/dist/plugins/focus.umd.js +1 -1
  20. package/dist/plugins/intersect.iife.js +1 -1
  21. package/dist/plugins/intersect.umd.js +1 -1
  22. package/dist/plugins/mask.iife.js +1 -1
  23. package/dist/plugins/mask.mjs +1 -1
  24. package/dist/plugins/mask.umd.js +1 -1
  25. package/dist/plugins/media.dev.iife.js +5 -39
  26. package/dist/plugins/media.dev.mjs +5 -38
  27. package/dist/plugins/media.iife.js +1 -1
  28. package/dist/plugins/media.mjs +1 -1
  29. package/dist/plugins/media.umd.js +1 -1
  30. package/dist/plugins/morph.dev.iife.js +41 -61
  31. package/dist/plugins/morph.dev.mjs +41 -60
  32. package/dist/plugins/morph.iife.js +1 -1
  33. package/dist/plugins/morph.mjs +1 -1
  34. package/dist/plugins/morph.umd.js +1 -1
  35. package/dist/plugins/navigate.dev.iife.js +24 -26
  36. package/dist/plugins/navigate.dev.mjs +24 -25
  37. package/dist/plugins/navigate.iife.js +1 -1
  38. package/dist/plugins/navigate.mjs +1 -1
  39. package/dist/plugins/navigate.umd.js +1 -1
  40. package/dist/plugins/persist.dev.iife.js +2 -10
  41. package/dist/plugins/persist.dev.mjs +2 -9
  42. package/dist/plugins/persist.iife.js +1 -1
  43. package/dist/plugins/persist.mjs +1 -1
  44. package/dist/plugins/persist.umd.js +1 -1
  45. package/dist/plugins/popover.iife.js +1 -1
  46. package/dist/plugins/popover.mjs +1 -1
  47. package/dist/plugins/popover.umd.js +1 -1
  48. package/dist/plugins/resize.iife.js +1 -1
  49. package/dist/plugins/resize.umd.js +1 -1
  50. package/dist/plugins/transition.iife.js +1 -1
  51. package/dist/plugins/transition.mjs +1 -1
  52. package/dist/plugins/transition.umd.js +1 -1
  53. package/dist/types/app.d.mts +5 -6
  54. package/dist/types/app.d.ts +5 -6
  55. package/dist/types/block.d.mts +0 -4
  56. package/dist/types/block.d.ts +0 -4
  57. package/dist/types/context.d.mts +1 -6
  58. package/dist/types/context.d.ts +1 -6
  59. package/dist/types/devtools-panel/chrome.d.mts +5 -7
  60. package/dist/types/devtools-panel/chrome.d.ts +5 -7
  61. package/dist/types/devtools-panel/menu.d.mts +10 -0
  62. package/dist/types/devtools-panel/menu.d.ts +10 -0
  63. package/dist/types/devtools-panel/plugins.d.mts +0 -4
  64. package/dist/types/devtools-panel/plugins.d.ts +0 -4
  65. package/dist/types/devtools-panel/styles.d.mts +3 -15
  66. package/dist/types/devtools-panel/styles.d.ts +3 -15
  67. package/dist/types/devtools-panel/values.d.mts +1 -20
  68. package/dist/types/devtools-panel/values.d.ts +1 -20
  69. package/dist/types/devtools.d.mts +0 -7
  70. package/dist/types/devtools.d.ts +0 -7
  71. package/dist/types/directives/on.d.mts +0 -1
  72. package/dist/types/directives/on.d.ts +0 -1
  73. package/dist/types/directives/show.d.mts +1 -0
  74. package/dist/types/directives/show.d.ts +1 -0
  75. package/dist/types/errors.d.mts +1 -8
  76. package/dist/types/errors.d.ts +1 -8
  77. package/dist/types/eval.d.mts +0 -3
  78. package/dist/types/eval.d.ts +0 -3
  79. package/dist/types/lazy.d.mts +0 -10
  80. package/dist/types/lazy.d.ts +0 -10
  81. package/dist/types/magics.d.mts +0 -9
  82. package/dist/types/magics.d.ts +0 -9
  83. package/dist/types/ownership.d.mts +0 -19
  84. package/dist/types/ownership.d.ts +0 -19
  85. package/dist/types/plugins/media/index.d.mts +0 -5
  86. package/dist/types/plugins/media/index.d.ts +0 -5
  87. package/dist/types/plugins/morph/index.d.mts +0 -8
  88. package/dist/types/plugins/morph/index.d.ts +0 -8
  89. package/dist/types/scheduler.d.mts +0 -5
  90. package/dist/types/scheduler.d.ts +0 -5
  91. package/dist/types/store.d.mts +5 -1
  92. package/dist/types/store.d.ts +5 -1
  93. package/dist/types/utils.d.mts +0 -5
  94. package/dist/types/utils.d.ts +0 -5
  95. package/dist/types/warn.d.mts +0 -12
  96. package/dist/types/warn.d.ts +0 -12
  97. package/package.json +3 -3
@@ -31,7 +31,6 @@ var toTypeString = (value) => objectToString.call(value);
31
31
  var toRawType = (value) => {
32
32
  return toTypeString(value).slice(8, -1);
33
33
  };
34
- var isPlainObject = (val) => toTypeString(val) === "[object Object]";
35
34
  var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
36
35
  var cacheStringFunction = (fn) => {
37
36
  const cache = /* @__PURE__ */ Object.create(null);
@@ -613,7 +612,13 @@ var listeners = {
613
612
  flush: /* @__PURE__ */ new Set()
614
613
  };
615
614
  var emit = (event, ...args) => {
616
- listeners[event].forEach((fn) => fn(...args));
615
+ listeners[event].forEach((fn) => {
616
+ try {
617
+ fn(...args);
618
+ } catch (e) {
619
+ console.error(`[litevue] a devtools "${event}" listener threw:`, e);
620
+ }
621
+ });
617
622
  };
618
623
  var registerScope = (el, scope, exp, name) => {
619
624
  if (isDisabled()) return NOOP;
@@ -637,7 +642,6 @@ var registerStore = (name, store) => {
637
642
  var registerComponent = (name) => {
638
643
  if (!isDisabled()) componentNames.add(name);
639
644
  };
640
- /** Registers a plugin and returns a deregister, as registerScope does. */
641
645
  var registerPlugin = (info) => {
642
646
  if (isDisabled()) return;
643
647
  pluginList.push(info);
@@ -647,7 +651,6 @@ var registerPlugin = (info) => {
647
651
  if (i > -1) pluginList.splice(i, 1);
648
652
  };
649
653
  };
650
- /** True when something is listening, so app.use() can skip the diff. */
651
654
  var pluginsWatched = () => !isDisabled();
652
655
  var emitFlush = () => {
653
656
  if (listeners.flush.size && !isDisabled()) emit("flush");
@@ -667,7 +670,7 @@ var devtools = {
667
670
  while (el) {
668
671
  const scope = scopes.get(el);
669
672
  if (scope) return scope;
670
- el = el.parentElement;
673
+ el = el.__marker?.parentElement || el.parentElement;
671
674
  }
672
675
  },
673
676
  on(event, fn) {
@@ -697,7 +700,6 @@ var disableDevtools = () => {
697
700
  };
698
701
  if (typeof window !== "undefined" && !isDisabled()) window.__LITE_VUE__ = devtools;
699
702
  // src/errors.ts
700
- /** Levenshtein, bounded — only used to rank candidate names in DEV. */
701
703
  var distance = (a, b) => {
702
704
  const m = a.length;
703
705
  const n = b.length;
@@ -711,7 +713,6 @@ var distance = (a, b) => {
711
713
  }
712
714
  return prev[n];
713
715
  };
714
- /** Every name in scope, up the prototype chain that nested `v-scope`s inherit. */
715
716
  var scopeNames = (scope) => {
716
717
  const names = /* @__PURE__ */ new Set();
717
718
  let cur = scope;
@@ -721,7 +722,6 @@ var scopeNames = (scope) => {
721
722
  }
722
723
  return [...names];
723
724
  };
724
- /** `count is not defined` → the closest name actually in scope. */
725
725
  var suggestName = (err, scope) => {
726
726
  if (!scope || !(err instanceof ReferenceError)) return;
727
727
  const missing = /^(\w+) is not defined$/.exec(err.message)?.[1];
@@ -742,14 +742,12 @@ var suggestName = (err, scope) => {
742
742
  suggestion: best
743
743
  } : { missing };
744
744
  };
745
- /** A short, recognisable rendering of the element — not its whole subtree. */
746
745
  var describeEl = (el) => {
747
746
  if (!el) return;
748
747
  if (!(el instanceof Element)) return el.nodeType === 3 ? `text node "${el.nodeValue?.trim().slice(0, 40)}"` : void 0;
749
748
  return `<${el.tagName.toLowerCase()}${el.id ? `#${el.id}` : ""}${el.classList.length ? `.${[...el.classList].join(".")}` : ""}>`;
750
749
  };
751
750
  var handlers = [];
752
- /** Registered by `app.onError()`. Shared across apps, like the store registry. */
753
751
  var addErrorHandler = (fn) => {
754
752
  handlers.push(fn);
755
753
  return () => {
@@ -786,17 +784,7 @@ var handleError = (err, info) => {
786
784
  if (info.el) console.error(info.el);
787
785
  };
788
786
  // src/scheduler.ts
789
- /**
790
- * Effects this library has stopped.
791
- *
792
- * The scheduler must know whether a queued runner is still live, and
793
- * @vue/reactivity offers no supported way to ask: 3.4's `ReactiveEffect.active`
794
- * became an undeclared `flags` bitfield in 3.5. Since every stop here goes
795
- * through `stopEffect`, tracking them ourselves is version-proof. Weak, so a
796
- * stopped effect stays collectable.
797
- */
798
787
  var stopped = /* @__PURE__ */ new WeakSet();
799
- /** Stops an effect and remembers that it is stopped. Use instead of `stop`. */
800
788
  var stopEffect = (runner) => {
801
789
  stopped.add(runner);
802
790
  if (runner.effect) stop(runner);
@@ -807,10 +795,6 @@ var queue = /* @__PURE__ */ new Set();
807
795
  var p = Promise.resolve();
808
796
  var MAX_RUNS = 100;
809
797
  var nextTick = (fn) => p.then(fn);
810
- /**
811
- * Stamps a job with its creation order, which the flush runs in. An effect
812
- * stamped as it is created sorts before the children its first run creates.
813
- */
814
798
  var stampJob = (job) => (job.i = uid$1++, job);
815
799
  var queueJob = (job) => {
816
800
  job.i ?? stampJob(job);
@@ -842,19 +826,10 @@ var flushJobs = () => {
842
826
  };
843
827
  // src/magics.ts
844
828
  var uid = 0;
845
- /**
846
- * $id('name') — unique ids for accessibility attributes. Stable within a scope
847
- * so label/input pairs match, unique across scopes.
848
- */
849
829
  var createId = () => {
850
830
  const memo = Object.create(null);
851
831
  return (name = "id") => memo[name] || (memo[name] = `${name}-${++uid}`);
852
832
  };
853
- /**
854
- * $watch(source, callback, { immediate }) — watches a dot-path string or getter
855
- * and calls back with (value, oldValue). Returns a stop function; it also stops
856
- * when the owning scope unmounts.
857
- */
858
833
  var createWatch = (ctx) => (source, cb, options) => {
859
834
  const getter = typeof source === "function" ? source : () => source.split(".").reduce((o, k) => o == null ? o : o[k], ctx.scope);
860
835
  let oldValue;
@@ -869,6 +844,7 @@ var createWatch = (ctx) => (source, cb, options) => {
869
844
  cb(value, previous);
870
845
  } finally {
871
846
  resetTracking();
847
+ oldValue = getter();
872
848
  }
873
849
  }
874
850
  init = true;
@@ -889,15 +865,21 @@ var bind = ({ el, get, effect, arg, modifiers }) => {
889
865
  let value = get();
890
866
  if (arg) {
891
867
  if (modifiers?.camel) arg = camelize(arg);
892
- if (value !== prevValue || isObject(value)) setProp(el, arg, value, prevValue);
868
+ patch(el, arg, value, prevValue);
893
869
  } else {
894
- for (const key in value) setProp(el, key, value[key], prevValue && prevValue[key]);
870
+ const prev = Object(prevValue);
871
+ for (const key in value) (key in prev ? patch : setProp)(el, key, value[key], prev[key]);
895
872
  for (const key in prevValue) if (!value || !(key in value)) setProp(el, key, null, prevValue[key]);
896
873
  }
897
- prevValue = isPlainObject(value) ? { ...value } : value;
874
+ prevValue = snapshot(value);
875
+ if (!arg && prevValue?.style) prevValue.style = snapshot(prevValue.style);
898
876
  if (!arg) el.__bound = prevValue;
899
877
  });
900
878
  };
879
+ var snapshot = (value) => isObject(value) ? { ...toStyle(value) } : value;
880
+ var patch = (el, key, value, prevValue) => {
881
+ if (value !== prevValue || isObject(value) || key === "value") setProp(el, key, value, prevValue);
882
+ };
901
883
  var setProp = (el, key, value, prevValue) => {
902
884
  if (key === "class") el.setAttribute("class", normalizeClass(el._class ? [el._class, value] : value) || "");
903
885
  else if (key === "style") {
@@ -912,7 +894,12 @@ var setProp = (el, key, value, prevValue) => {
912
894
  }
913
895
  if (!style.cssText) el.removeAttribute("style");
914
896
  } else if (!(el instanceof SVGElement) && key in el && !forceAttrRE.test(key) && !mediaSizeRE.test(el.localName + key)) {
915
- el[key] = value == null && typeof el[key] == "string" ? "" : value;
897
+ try {
898
+ const type = typeof el[key];
899
+ el[key] = value == null && type == "string" ? "" : value === "" && type == "boolean" || value;
900
+ } catch (e) {
901
+ if (value != null) throw e;
902
+ }
916
903
  if (value == null) el.removeAttribute(key);
917
904
  if (key === "value") el._value = value;
918
905
  } else if (key === "true-value") el._trueValue = value;
@@ -932,22 +919,10 @@ var setStyle = (style, name, val) => {
932
919
  else style[name] = val;
933
920
  };
934
921
  // src/warn.ts
935
- /**
936
- * Development warnings.
937
- *
938
- * Every call site is guarded by `import.meta.env.DEV`; the production build
939
- * replaces that constant and terser drops the branch, so neither these
940
- * functions nor their strings ship. Messages are therefore free to be wordy —
941
- * say what to do instead.
942
- */
943
922
  var seen = /* @__PURE__ */ new Set();
944
923
  var warn = (msg) => {
945
924
  console.warn(`[litevue] ${msg}`);
946
925
  };
947
- /**
948
- * Warns once per `key`. Most callers are effects, which re-run on every
949
- * relevant change — one mistake would otherwise print on every keystroke.
950
- */
951
926
  var warnOnce = (key, msg) => {
952
927
  if (seen.has(key)) return;
953
928
  seen.add(key);
@@ -996,10 +971,6 @@ var toFunction = (exp, el, meta) => {
996
971
  }
997
972
  };
998
973
  // src/directives/on.ts
999
- /**
1000
- * Can `exp` stand as a single expression, or is it a statement list?
1001
- * Memoised: it compiles a throwaway function, which a `v-for` pays per row.
1002
- */
1003
974
  var expressionCache = Object.create(null);
1004
975
  var cachedExpressions = 0;
1005
976
  var isExpression = (exp) => {
@@ -1053,7 +1024,9 @@ var on = ({ el, get, exp, arg, modifiers }) => {
1053
1024
  return;
1054
1025
  }
1055
1026
  const a = /\bawait\b/.test(exp) ? "async " : "";
1056
- let handler = simplePathRE.test(exp) || fnExpRE.test(exp) ? get(`(e => (${exp})(e))`) : isExpression(exp) ? get(`(${a}$event => (${exp}))`) : get(`(${a}$event => { ${exp} })`);
1027
+ const body = exp.replace(/;\s*$/, "");
1028
+ let handler = simplePathRE.test(exp) || fnExpRE.test(exp) ? get(`(e => (${body})(e))`) : isExpression(body) ? get(`(${a}$event => (${body}))`) : get(`(${a}$event => { ${exp} })`);
1029
+ if (!handler) return;
1057
1030
  if (arg === "vue:mounted" || arg === "vue:unmounted") console.warn(`@${arg} is deprecated in LiteVue - use @${arg.slice(4)} instead.`);
1058
1031
  if (arg === "mounted" || arg === "vue:mounted") {
1059
1032
  let live = true;
@@ -1103,7 +1076,7 @@ var on = ({ el, get, exp, arg, modifiers }) => {
1103
1076
  warnOnce(`modifier:${arg}.${k}`, `@${arg}.${k}: .${k} is not a modifier LiteVue knows, so it is ignored.` + (ms ? ` Timings are written with a dash — .debounce-${ms[1]} or .throttle-${ms[1]}.` : ` Key names only filter keyboard events.`));
1104
1077
  }
1105
1078
  handler = (e) => {
1106
- if (modifiers.outside && el.contains(e.target)) return;
1079
+ if (modifiers.outside && (e.composedPath().includes(el) || el._vsh || e.timeStamp < el._vts)) return;
1107
1080
  if (keyFilter.length && ("key" in e || e.type.startsWith("key"))) {
1108
1081
  const key = hyphenate(e.key || "");
1109
1082
  if (!keyFilter.some((k) => k === key || keyAliases[k] === key)) return;
@@ -1120,6 +1093,7 @@ var on = ({ el, get, exp, arg, modifiers }) => {
1120
1093
  }
1121
1094
  const target = modifiers?.window ? window : modifiers?.document || modifiers?.outside ? document : el;
1122
1095
  const event = arg;
1096
+ if (modifiers?.outside) el._vts = performance.now();
1123
1097
  target.addEventListener(event, handler, {
1124
1098
  ...modifiers,
1125
1099
  once: false
@@ -1133,12 +1107,15 @@ var on = ({ el, get, exp, arg, modifiers }) => {
1133
1107
  var show = ({ el, get, effect }) => {
1134
1108
  el._vod = el.style.display == "none" ? "" : el.style.display;
1135
1109
  effect(() => {
1136
- el._vsh = !get();
1137
- el.style.display = el._vsh ? "none" : el._vod;
1110
+ const hidden = !get();
1111
+ if (el._vsh && !hidden) el._vts = performance.now();
1112
+ el._vsh = hidden;
1113
+ el.style.display = hidden ? "none" : el._vod;
1138
1114
  });
1139
1115
  };
1140
1116
  // src/directives/text.ts
1141
1117
  var text = ({ el, get, effect }) => {
1118
+ el.__r = 1;
1142
1119
  effect(() => {
1143
1120
  el.textContent = toDisplayString(get());
1144
1121
  });
@@ -1146,6 +1123,7 @@ var text = ({ el, get, effect }) => {
1146
1123
  var toDisplayString = (value) => value == null ? "" : isArray(value) || isObject(value) && (value.toString === objectToString || !isFunction(value.toString)) ? JSON.stringify(value, null, 2) : String(value);
1147
1124
  // src/directives/html.ts
1148
1125
  var html = ({ el, get, effect }) => {
1126
+ el.__r = 1;
1149
1127
  effect(() => {
1150
1128
  el.innerHTML = get() ?? "";
1151
1129
  });
@@ -1156,11 +1134,6 @@ var checkAttr = (el, name) => {
1156
1134
  if (val != null) el.removeAttribute(name);
1157
1135
  return val;
1158
1136
  };
1159
- /**
1160
- * Adds a listener and returns a remover. Callers are expected to use it:
1161
- * `app.unmount(el)` leaves elements in the document, so a listener left behind
1162
- * would keep driving markup meant to be inert.
1163
- */
1164
1137
  var listen = (el, event, handler, options) => {
1165
1138
  el.addEventListener(event, handler, options);
1166
1139
  return () => el.removeEventListener(event, handler, options);
@@ -1296,35 +1269,19 @@ var trigger = (el, type) => {
1296
1269
  };
1297
1270
  // src/ownership.ts
1298
1271
  var owned = /* @__PURE__ */ new WeakMap();
1299
- /**
1300
- * The node currently being walked. A module-level cursor suffices because the
1301
- * walk is synchronous and depth-first, and it keeps `owner` out of every
1302
- * directive signature.
1303
- */
1304
1272
  var owner;
1305
1273
  var setOwner = (node) => {
1306
1274
  const previous = owner;
1307
1275
  owner = node;
1308
1276
  return previous;
1309
1277
  };
1310
- /**
1311
- * Registers a disposer against `node`, defaulting to the node being walked.
1312
- * Pass `node` explicitly for a directive that outlives its element: `v-if` and
1313
- * `v-for` detach the template and render from an anchor, so they must own to
1314
- * the anchor.
1315
- */
1316
1278
  var own = (dispose, node = owner) => {
1317
1279
  if (!node) return;
1318
1280
  const list = owned.get(node);
1319
1281
  if (list) list.push(dispose);
1320
1282
  else owned.set(node, [dispose]);
1321
1283
  };
1322
- /** Withdraws a disposer from `node`, for an owner that removes it itself. */
1323
1284
  var disown = (dispose, node) => remove(owned.get(node) || [], dispose);
1324
- /**
1325
- * Disposes `node` and its subtree. Safe on an unowned node, and idempotent —
1326
- * the record is dropped as it runs.
1327
- */
1328
1285
  var disposeSubtree = (node) => {
1329
1286
  const list = owned.get(node);
1330
1287
  if (list) {
@@ -1415,7 +1372,10 @@ var _if = (el, exp, ctx) => {
1415
1372
  }
1416
1373
  };
1417
1374
  let branchEffect;
1418
- const stopBranches = () => stopEffect(branchEffect);
1375
+ const stopBranches = () => {
1376
+ stopEffect(branchEffect);
1377
+ remove(ctx.effects, branchEffect);
1378
+ };
1419
1379
  branchEffect = ctx.effect(() => {
1420
1380
  for (let i = 0; i < branches.length; i++) {
1421
1381
  const { exp, el } = branches[i];
@@ -1486,11 +1446,21 @@ var _for = (el, exp, ctx) => {
1486
1446
  const createRows = (source) => {
1487
1447
  const map = /* @__PURE__ */ new Map();
1488
1448
  const rows = [];
1489
- if (isArray(source) || isString(source)) for (let i = 0; i < source.length; i++) rows.push(createRow(map, source[i], i));
1490
- else if (typeof source === "number") for (let i = 0; i < source; i++) rows.push(createRow(map, i + 1, i));
1491
- else if (isObject(source)) {
1492
- let i = 0;
1493
- for (const key in source) rows.push(createRow(map, source[key], i++, key));
1449
+ try {
1450
+ if (isArray(source) || isString(source)) for (let i = 0; i < source.length; i++) rows.push(createRow(map, source[i], i));
1451
+ else if (typeof source === "number") for (let i = 0; i < source; i++) rows.push(createRow(map, i + 1, i));
1452
+ else if (isObject(source)) {
1453
+ let i = 0;
1454
+ for (const key in source) rows.push(createRow(map, source[key], i++, key));
1455
+ }
1456
+ } catch (e) {
1457
+ handleError(e, {
1458
+ phase: "expression",
1459
+ source: "v-for",
1460
+ el,
1461
+ expression: sourceExp
1462
+ });
1463
+ return [[], /* @__PURE__ */ new Map()];
1494
1464
  }
1495
1465
  return [rows, map];
1496
1466
  };
@@ -1498,7 +1468,7 @@ var _for = (el, exp, ctx) => {
1498
1468
  const data = {};
1499
1469
  if (destructureBindings) destructureBindings.forEach((b, i) => data[b] = value?.[isArrayDestructure ? i : b]);
1500
1470
  else data[valueExp] = value;
1501
- if (objKey) {
1471
+ if (objKey != null) {
1502
1472
  indexExp && (data[indexExp] = objKey);
1503
1473
  objIndexExp && (data[objIndexExp] = index);
1504
1474
  } else indexExp && (data[indexExp] = index);
@@ -1513,7 +1483,10 @@ var _for = (el, exp, ctx) => {
1513
1483
  };
1514
1484
  };
1515
1485
  const mountBlock = (row, ref) => {
1516
- const block = new Block(el, createScopedContext(ctx, row.data));
1486
+ const block = new Block(el, createScopedContext(ctx, row.data, true));
1487
+ const t = block.template;
1488
+ t.__ctx ??= block.ctx;
1489
+ block.ctx.cleanups.push(() => delete t.__ctx);
1517
1490
  block.key = row.key;
1518
1491
  block.insert(parent(), ref);
1519
1492
  return block;
@@ -1567,7 +1540,9 @@ var _for = (el, exp, ctx) => {
1567
1540
  else {
1568
1541
  block = blocks[oldIndex];
1569
1542
  Object.assign(block.ctx.scope, row.data);
1570
- if (oldIndex !== i && (block.end || block.el).nextSibling !== ref) block.insert(parent(), ref);
1543
+ let next = (block.end || block.el).nextSibling;
1544
+ while (next?.__leaving) next = next.nextSibling;
1545
+ if (oldIndex !== i && next !== ref) block.insert(parent(), ref);
1571
1546
  }
1572
1547
  nextBlocks[i] = nextBlock = block;
1573
1548
  }
@@ -1584,7 +1559,7 @@ var ref = ({ el, ctx: { scope: { $refs } }, get, effect }) => {
1584
1559
  const ref = get();
1585
1560
  {
1586
1561
  const existing = hasOwn(refs, ref) && refs[ref];
1587
- if (existing && existing !== el && existing.isConnected) warnOnce(`ref-dup:${ref}`, `two elements claim ref="${ref}" in the same scope; $refs.${ref} points at the last one mounted and the earlier element is no longer reachable. Give each element its own name.`);
1562
+ if (existing && existing !== el && existing.isConnected && !existing.__leaving) warnOnce(`ref-dup:${ref}`, `two elements claim ref="${ref}" in the same scope; $refs.${ref} points at the last one mounted and the earlier element is no longer reachable. Give each element its own name.`);
1588
1563
  }
1589
1564
  $refs[ref] = el;
1590
1565
  if (prevRef && ref !== prevRef && refs[prevRef] === el) delete $refs[prevRef];
@@ -1600,17 +1575,12 @@ var LAZY_MODES = [
1600
1575
  "idle",
1601
1576
  "interaction"
1602
1577
  ];
1603
- /** Selector matching every scope root, deferred or not. */
1604
1578
  var SCOPE_SELECTOR = ["[v-scope]", ...LAZY_MODES.map((m) => `[v-scope\\.${m}]`)].join(",");
1605
1579
  var INTERACTIONS = [
1606
1580
  "pointerdown",
1607
1581
  "keydown",
1608
1582
  "focusin"
1609
1583
  ];
1610
- /**
1611
- * Arms `mode` and returns a disposer. Fires at most once; disposing first
1612
- * cancels it, since a region can be unmounted while still waiting.
1613
- */
1614
1584
  var arm = (el, mode, fire) => {
1615
1585
  let done = false;
1616
1586
  const once = () => {
@@ -1622,7 +1592,11 @@ var arm = (el, mode, fire) => {
1622
1592
  let stop = NOOP;
1623
1593
  if (mode === "visible" && typeof IntersectionObserver == "function") {
1624
1594
  const io = new IntersectionObserver((entries) => {
1625
- if (entries.some((e) => e.isIntersecting)) once();
1595
+ for (const e of entries) {
1596
+ if (e.isIntersecting) return once();
1597
+ const parent = e.target.parentElement;
1598
+ if (!e.boundingClientRect.width && parent) io.observe(parent);
1599
+ }
1626
1600
  });
1627
1601
  io.observe(el);
1628
1602
  stop = () => io.disconnect();
@@ -1641,10 +1615,6 @@ var arm = (el, mode, fire) => {
1641
1615
  stop();
1642
1616
  };
1643
1617
  };
1644
- /**
1645
- * Returns true if `el` was deferred. The walk must not descend into it:
1646
- * walking consumes directives, so it could not be walked again later.
1647
- */
1648
1618
  var deferScope = (el, ctx, walk, once) => {
1649
1619
  const mode = LAZY_MODES.find((m) => el.hasAttribute(`v-scope.${m}`));
1650
1620
  if (!mode) return false;
@@ -1666,16 +1636,6 @@ var deferScope = (el, ctx, walk, once) => {
1666
1636
  var dirRE = /^(?:v-|:|@)/;
1667
1637
  var modifierRE = /\.([\w-]+)/g;
1668
1638
  var inOnce = false;
1669
- /**
1670
- * Registers a cleanup on both owners: the context, for whole-region teardown,
1671
- * and the walked node, for a subtree detached on its own. Dropping the entry
1672
- * when the node goes keeps a re-mounted region from accumulating spent ones.
1673
- *
1674
- * The `indexOf` guard also makes this run-once. A subtree can reach the same
1675
- * cleanup twice — via the block root, whose teardown drains `ctx.cleanups`,
1676
- * and via the node — and a second run would remove a listener the next mount
1677
- * installed.
1678
- */
1679
1639
  var addCleanup = (ctx, cleanup, node) => {
1680
1640
  ctx.cleanups.push(cleanup);
1681
1641
  own(() => {
@@ -1705,16 +1665,17 @@ var walk = (node, ctx) => {
1705
1665
  }
1706
1666
  };
1707
1667
  var walkNode = (node, ctx) => {
1668
+ if (node.__r) return;
1708
1669
  const type = node.nodeType;
1709
1670
  if (type === 1) {
1710
1671
  const el = node;
1711
1672
  if (!el.hasAttributes()) return walkChildren(el, ctx);
1712
1673
  if (el.hasAttribute("v-pre")) return;
1713
- if (deferScope(el, ctx, walkDeferred, inOnce)) return;
1714
- checkAttr(el, "v-cloak");
1715
1674
  let exp;
1716
1675
  if ((exp = checkAttr(el, "v-if")) != null) return _if(el, exp, ctx);
1717
1676
  if (exp = checkAttr(el, "v-for")) return _for(el, exp, ctx);
1677
+ if (deferScope(el, ctx, walkDeferred, inOnce)) return;
1678
+ checkAttr(el, "v-cloak");
1718
1679
  const name = checkAttr(el, "v-name");
1719
1680
  let teleportNext;
1720
1681
  if (exp = checkAttr(el, "v-teleport")) {
@@ -1723,7 +1684,16 @@ var walkNode = (node, ctx) => {
1723
1684
  teleportNext = el.nextSibling;
1724
1685
  const marker = el.__marker = new Text("");
1725
1686
  el.before(marker);
1726
- target.appendChild(el);
1687
+ try {
1688
+ target.appendChild(el);
1689
+ } catch (e) {
1690
+ handleError(e, {
1691
+ phase: "directive",
1692
+ source: "v-teleport",
1693
+ el,
1694
+ expression: exp
1695
+ });
1696
+ }
1727
1697
  addCleanup(ctx, () => {
1728
1698
  disposeSubtree(el);
1729
1699
  el.remove();
@@ -1747,7 +1717,7 @@ var walkNode = (node, ctx) => {
1747
1717
  const wasOnce = inOnce;
1748
1718
  if (checkAttr(el, "v-once") != null) inOnce = true;
1749
1719
  if (exp = checkAttr(el, "ref")) applyDirective(el, ref, `"${exp}"`, ctx);
1750
- walkChildren(el, ctx);
1720
+ if (!el.hasAttribute("v-text") && !el.hasAttribute("v-html")) walkChildren(el, ctx);
1751
1721
  const deferred = [];
1752
1722
  for (const { name, value } of [...el.attributes]) if (dirRE.test(name) && name !== "v-cloak") {
1753
1723
  if (name === "v-model" || name.startsWith("v-model.")) deferred.unshift([name, value]);
@@ -1759,7 +1729,7 @@ var walkNode = (node, ctx) => {
1759
1729
  return teleportNext;
1760
1730
  } else if (type === 3) {
1761
1731
  const data = node.data;
1762
- if (data.includes(ctx.delimiters[0]) && !(node.parentNode instanceof HTMLScriptElement)) {
1732
+ if (data.includes(ctx.delimiters[0]) && node.parentNode?.localName != "script") {
1763
1733
  let segments = [];
1764
1734
  let lastIndex = 0;
1765
1735
  let match;
@@ -1817,7 +1787,7 @@ var applyDirective = (el, dir, exp, ctx, arg, modifiers, source, displayExp) =>
1817
1787
  const meta = {
1818
1788
  source,
1819
1789
  el,
1820
- expression: displayExp
1790
+ expression: displayExp || exp
1821
1791
  };
1822
1792
  const report = (err) => handleError(err, {
1823
1793
  phase: "handler",
@@ -1861,12 +1831,19 @@ var applyDirective = (el, dir, exp, ctx, arg, modifiers, source, displayExp) =>
1861
1831
  });
1862
1832
  return;
1863
1833
  }
1864
- if (cleanup) addCleanup(ctx, cleanup);
1834
+ if (cleanup) addCleanup(ctx, () => {
1835
+ try {
1836
+ cleanup();
1837
+ } catch (e) {
1838
+ handleError(e, {
1839
+ phase: "teardown",
1840
+ source,
1841
+ el,
1842
+ expression: exp
1843
+ });
1844
+ }
1845
+ });
1865
1846
  };
1866
- /**
1867
- * `querySelector` for a selector written in markup. One that does not parse is
1868
- * reported and yields undefined, rather than throwing out of `mount()`.
1869
- */
1870
1847
  var query = (sel, el, source) => {
1871
1848
  try {
1872
1849
  return document.querySelector(sel);
@@ -1886,7 +1863,7 @@ var resolveTemplate = (el, template) => {
1886
1863
  if (templateEl !== void 0) console.error(`template selector ${template} has no matching <template> element.`);
1887
1864
  return;
1888
1865
  }
1889
- el.appendChild(templateEl.content.cloneNode(true));
1866
+ el.appendChild(el.ownerDocument.importNode(templateEl.content, true));
1890
1867
  return;
1891
1868
  }
1892
1869
  el.innerHTML = template;
@@ -1923,17 +1900,12 @@ var createContext = (parent) => {
1923
1900
  };
1924
1901
  return ctx;
1925
1902
  };
1926
- /**
1927
- * Framework-provided, so non-enumerable: `Object.assign`-ing one scope onto
1928
- * another must copy the user's data and leave these alone. v-for does exactly
1929
- * that on every update, which reset each row's $id and wiped its $refs.
1930
- */
1931
1903
  var hide = (scope, key, value) => Object.defineProperty(scope, key, {
1932
1904
  value,
1933
1905
  writable: true,
1934
1906
  configurable: true
1935
1907
  });
1936
- var createScopedContext = (ctx, data = {}) => {
1908
+ var createScopedContext = (ctx, data = {}, isRow) => {
1937
1909
  const parentScope = ctx.scope;
1938
1910
  const mergedScope = Object.create(parentScope);
1939
1911
  Object.defineProperties(mergedScope, Object.getOwnPropertyDescriptors(data));
@@ -1948,16 +1920,20 @@ var createScopedContext = (ctx, data = {}) => {
1948
1920
  };
1949
1921
  hide(mergedScope, "$watch", createWatch(scopedCtx));
1950
1922
  hide(mergedScope, "$id", createId());
1951
- bindContextMethods(reactiveProxy, mergedScope);
1923
+ if (!isRow) bindContextMethods(reactiveProxy, mergedScope);
1952
1924
  return scopedCtx;
1953
1925
  };
1954
1926
  var bindContextMethods = (scope, raw = scope) => {
1955
1927
  for (const key of Object.keys(raw)) {
1956
- const fn = Object.getOwnPropertyDescriptor(raw, key).value;
1957
- if (typeof fn === "function") scope[key] = fn.bind(scope);
1928
+ const { value: fn, writable } = Object.getOwnPropertyDescriptor(raw, key);
1929
+ if (typeof fn === "function" && writable) scope[key] = Object.setPrototypeOf(fn.bind(scope), fn);
1958
1930
  }
1959
1931
  };
1960
1932
  // src/block.ts
1933
+ var stopEffects = (block) => {
1934
+ block.ctx.blocks.forEach(stopEffects);
1935
+ block.ctx.effects.splice(0).forEach(stopEffect);
1936
+ };
1961
1937
  var Block = class {
1962
1938
  get el() {
1963
1939
  return this.start || this.template.__marker || this.template;
@@ -1965,7 +1941,10 @@ var Block = class {
1965
1941
  constructor(template, parentCtx, isRoot = false) {
1966
1942
  this.isFragment = template instanceof HTMLTemplateElement;
1967
1943
  if (isRoot) this.template = template;
1968
- else if (this.isFragment) this.template = template.content.cloneNode(true);
1944
+ else if (template.hasAttribute("v-for")) {
1945
+ this.isFragment = true;
1946
+ (this.template = new DocumentFragment()).append(template.cloneNode(true));
1947
+ } else if (this.isFragment) this.template = template.ownerDocument.importNode(template.content, true);
1969
1948
  else this.template = template.cloneNode(true);
1970
1949
  if (isRoot) this.ctx = createContext(parentCtx);
1971
1950
  else {
@@ -2000,7 +1979,10 @@ var Block = class {
2000
1979
  }
2001
1980
  }
2002
1981
  remove() {
2003
- if (this.parentCtx) remove(this.parentCtx.blocks, this);
1982
+ if (this.parentCtx) {
1983
+ remove(this.parentCtx.blocks, this);
1984
+ this.parentCtx = void 0;
1985
+ }
2004
1986
  const removeNow = () => {
2005
1987
  const parent = this.start ? this.start.parentNode : this.template.parentNode;
2006
1988
  if (parent) {
@@ -2022,9 +2004,11 @@ var Block = class {
2022
2004
  this.template.__marker?.remove();
2023
2005
  this.teardown();
2024
2006
  };
2007
+ stopEffects(this);
2025
2008
  const leaves = [];
2026
2009
  let node = this.start || this.template;
2027
2010
  while (node) {
2011
+ node.__leaving = 1;
2028
2012
  const leave = node.__leave;
2029
2013
  if (leave) leaves.push(leave());
2030
2014
  if (!this.start || node === this.end) break;
@@ -2033,10 +2017,6 @@ var Block = class {
2033
2017
  if (leaves.length) Promise.all(leaves).then(removeNow);
2034
2018
  else removeNow();
2035
2019
  }
2036
- /**
2037
- * The bookkeeping half of `remove()`, for a block whose nodes are already
2038
- * gone — `remove()`'s `removeChild` calls would throw on them.
2039
- */
2040
2020
  discard() {
2041
2021
  if (this.parentCtx) remove(this.parentCtx.blocks, this);
2042
2022
  this.teardown();
@@ -2050,24 +2030,10 @@ var Block = class {
2050
2030
  }
2051
2031
  };
2052
2032
  // src/store.ts
2053
- /**
2054
- * DEV: catch `$store.typo`, which otherwise reads as `undefined` and renders a
2055
- * blank instead of raising.
2056
- *
2057
- * The trap sits *under* `reactive`, not over it: `reactive` probes its target
2058
- * for `__v_raw`, and a wrapper that forwards that probe is bypassed entirely.
2059
- * `__v_`-prefixed keys are ignored for the same reason — they are not reads a
2060
- * user wrote.
2061
- *
2062
- * Deferred to the end of the task, because reading a store before it is
2063
- * registered is legitimate — the registry is reactive so the expression
2064
- * re-runs. A microtask would warn on a store registered after an `await`. One
2065
- * registered later still warns; a check cannot wait forever.
2066
- */
2067
2033
  var registry = Object.create(null);
2068
2034
  var target = registry;
2069
2035
  target = new Proxy(registry, { get(obj, key, receiver) {
2070
- if (typeof key === "string" && !key.startsWith("__") && key !== "toJSON" && !(key in obj)) setTimeout(() => {
2036
+ if (typeof key === "string" && !key.startsWith("__") && key !== "toJSON" && !(key in obj) && !(key in Object.prototype)) setTimeout(() => {
2071
2037
  if (key in obj) return;
2072
2038
  warnOnce(`store-missing:${key}`, `$store.${key} is not registered, so it reads as undefined. Register it with store('${key}', { … }) before mounting, or check the spelling.`);
2073
2039
  });
@@ -2090,6 +2056,7 @@ var store = (name, value) => {
2090
2056
  // src/app.ts
2091
2057
  var mountedRoots = /* @__PURE__ */ new WeakMap();
2092
2058
  var escapeRegex = (str) => str.replace(/[-.*+?^${}()|[\]/\\]/g, "\\$&");
2059
+ var isInert = (el) => el && (el.__r || el.hasAttribute("v-pre") || isInert(el.parentElement));
2093
2060
  var createApp = (initialData) => {
2094
2061
  const ctx = createContext();
2095
2062
  if (typeof initialData === "function") {
@@ -2184,28 +2151,25 @@ var createApp = (initialData) => {
2184
2151
  if (el.matches(SCOPE_SELECTOR)) roots = [el];
2185
2152
  else roots = [...el.querySelectorAll(SCOPE_SELECTOR)].filter((root) => !root.matches(`:where(${SCOPE_SELECTOR}) *`));
2186
2153
  if (!roots.length) roots = [el];
2154
+ roots = roots.filter((root) => !isInert(root));
2187
2155
  if (roots.length === 1 && roots[0] === document.documentElement) console.warn("Mounting on documentElement - this is non-optimal as LiteVue will be forced to crawl the entire page's DOM. Consider explicitly marking elements controlled by LiteVue with `v-scope`.");
2188
2156
  ctx.walk ??= walk;
2189
2157
  ctx.dispose ??= disposeSubtree;
2190
2158
  for (const el of roots) {
2191
2159
  if (mountedRoots.has(el) && mountedRoots.get(el) === el.firstChild) warn("mount() was called again on an element that has already been mounted, so its directives were consumed by the first walk and nothing was bound this time. To re-activate a region, insert fresh markup and mount that instead.");
2192
2160
  const name = el.getAttribute("v-name");
2161
+ const host = el.parentNode;
2193
2162
  const block = new Block(el, ctx, true);
2163
+ block.host = host;
2194
2164
  mountedRoots.set(el, el.firstChild);
2195
2165
  el.__ctx ??= block.ctx;
2196
2166
  if (!devtools.scopes.has(el) && !el.matches(SCOPE_SELECTOR)) block.ctx.cleanups.push(registerScope(el, block.ctx.scope, void 0, name || void 0));
2197
2167
  rootBlocks.push(block);
2198
- own(() => remove(rootBlocks, block), el);
2168
+ own(() => (remove(rootBlocks, block), block.teardown()), el);
2199
2169
  block.ctx.cleanups.push(() => delete el.__ctx);
2200
2170
  }
2201
2171
  return this;
2202
2172
  },
2203
- /**
2204
- * Tear down mounted regions: every root, or only those at or inside `el`.
2205
- * Effects stop, cleanups run and scopes deregister; the rest of the app
2206
- * keeps running. Without it, replacing a region's markup leaves its
2207
- * effects writing to detached nodes.
2208
- */
2209
2173
  unmount(el) {
2210
2174
  if (el == null) {
2211
2175
  rootBlocks.forEach((block) => block.teardown());
@@ -2234,7 +2198,7 @@ var createApp = (initialData) => {
2234
2198
  const kept = [];
2235
2199
  for (const block of rootBlocks) {
2236
2200
  const root = block.template;
2237
- if (target.contains(root)) block.teardown();
2201
+ if (target.contains(root) || target.contains(block.host)) block.teardown();
2238
2202
  else kept.push(block);
2239
2203
  }
2240
2204
  if (kept.length === rootBlocks.length) console.warn("unmount: no mounted region found at or inside the given element. Pass the same element that was mounted, or one containing it.");