@aevantec/litevue 0.5.16 → 0.5.17

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 (49) hide show
  1. package/README.md +1 -1
  2. package/dist/litevue-plugins.dev.iife.js +32 -29
  3. package/dist/litevue-plugins.dev.mjs +32 -29
  4. package/dist/litevue-plugins.iife.js +1 -1
  5. package/dist/litevue-plugins.mjs +1 -1
  6. package/dist/litevue-plugins.umd.js +1 -1
  7. package/dist/litevue.dev.iife.js +232 -213
  8. package/dist/litevue.dev.mjs +232 -213
  9. package/dist/litevue.iife.js +1 -1
  10. package/dist/litevue.mjs +1 -1
  11. package/dist/litevue.umd.js +1 -1
  12. package/dist/plugins/focus.iife.js +1 -1
  13. package/dist/plugins/focus.mjs +1 -1
  14. package/dist/plugins/focus.umd.js +1 -1
  15. package/dist/plugins/mask.iife.js +1 -1
  16. package/dist/plugins/mask.mjs +1 -1
  17. package/dist/plugins/mask.umd.js +1 -1
  18. package/dist/plugins/media.dev.iife.js +9 -7
  19. package/dist/plugins/media.dev.mjs +9 -7
  20. package/dist/plugins/media.iife.js +1 -1
  21. package/dist/plugins/media.mjs +1 -1
  22. package/dist/plugins/media.umd.js +1 -1
  23. package/dist/plugins/morph.dev.iife.js +7 -4
  24. package/dist/plugins/morph.dev.mjs +7 -4
  25. package/dist/plugins/morph.iife.js +1 -1
  26. package/dist/plugins/morph.mjs +1 -1
  27. package/dist/plugins/morph.umd.js +1 -1
  28. package/dist/plugins/navigate.dev.iife.js +36 -16
  29. package/dist/plugins/navigate.dev.mjs +36 -16
  30. package/dist/plugins/navigate.iife.js +1 -1
  31. package/dist/plugins/navigate.mjs +1 -1
  32. package/dist/plugins/navigate.umd.js +1 -1
  33. package/dist/plugins/persist.dev.iife.js +1 -2
  34. package/dist/plugins/persist.dev.mjs +1 -2
  35. package/dist/types/block.d.mts +1 -1
  36. package/dist/types/block.d.ts +1 -1
  37. package/dist/types/context.d.mts +7 -1
  38. package/dist/types/context.d.ts +7 -1
  39. package/dist/types/directives/on.d.mts +2 -0
  40. package/dist/types/directives/on.d.ts +2 -0
  41. package/dist/types/directives/show.d.mts +4 -1
  42. package/dist/types/directives/show.d.ts +4 -1
  43. package/dist/types/ownership.d.mts +2 -0
  44. package/dist/types/ownership.d.ts +2 -0
  45. package/dist/types/scheduler.d.mts +9 -1
  46. package/dist/types/scheduler.d.ts +9 -1
  47. package/dist/types/walk.d.mts +1 -0
  48. package/dist/types/walk.d.ts +1 -0
  49. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  var LiteVue = (function(exports) {
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- //#region node_modules/.pnpm/@vue+shared@3.4.38/node_modules/@vue/shared/dist/shared.esm-bundler.js
3
+ // node_modules/.pnpm/@vue+shared@3.4.38/node_modules/@vue/shared/dist/shared.esm-bundler.js
4
4
  /**
5
5
  * @vue/shared v3.4.38
6
6
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
@@ -23,7 +23,6 @@ var LiteVue = (function(exports) {
23
23
  var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
24
24
  var hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
25
25
  var isArray = Array.isArray;
26
- var isMap = (val) => toTypeString(val) === "[object Map]";
27
26
  var isDate = (val) => toTypeString(val) === "[object Date]";
28
27
  var isFunction = (val) => typeof val === "function";
29
28
  var isString = (val) => typeof val === "string";
@@ -43,14 +42,14 @@ var LiteVue = (function(exports) {
43
42
  };
44
43
  };
45
44
  var camelizeRE = /-(\w)/g;
46
- var camelize = cacheStringFunction((str) => {
45
+ var camelize = /* @__PURE__ */ cacheStringFunction((str) => {
47
46
  return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
48
47
  });
49
48
  var hyphenateRE = /\B([A-Z])/g;
50
- var hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
49
+ var hyphenate = /* @__PURE__ */ cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
51
50
  var hasChanged = (value, oldValue) => !Object.is(value, oldValue);
52
- var toNumber = (val) => {
53
- const n = isString(val) ? Number(val) : NaN;
51
+ var looseToNumber = (val) => {
52
+ const n = parseFloat(val);
54
53
  return isNaN(n) ? val : n;
55
54
  };
56
55
  function normalizeStyle(value) {
@@ -122,8 +121,7 @@ var LiteVue = (function(exports) {
122
121
  function looseIndexOf(arr, val) {
123
122
  return arr.findIndex((item) => looseEqual(item, val));
124
123
  }
125
- //#endregion
126
- //#region node_modules/.pnpm/@vue+reactivity@3.4.38/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
124
+ // node_modules/.pnpm/@vue+reactivity@3.4.38/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
127
125
  /**
128
126
  * @vue/reactivity v3.4.38
129
127
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
@@ -308,7 +306,6 @@ var LiteVue = (function(exports) {
308
306
  };
309
307
  var targetMap = /* @__PURE__ */ new WeakMap();
310
308
  var ITERATE_KEY = Symbol("iterate");
311
- var MAP_KEY_ITERATE_KEY = Symbol("Map key iterate");
312
309
  function track(target, type, key) {
313
310
  if (shouldTrack && activeEffect) {
314
311
  let depsMap = targetMap.get(target);
@@ -326,8 +323,7 @@ var LiteVue = (function(exports) {
326
323
  const depsMap = targetMap.get(target);
327
324
  if (!depsMap) return;
328
325
  let deps = [];
329
- if (type === "clear") deps = [...depsMap.values()];
330
- else if (key === "length" && isArray(target)) {
326
+ if (key === "length" && isArray(target)) {
331
327
  const newLength = Number(newValue);
332
328
  depsMap.forEach((dep, key2) => {
333
329
  if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) deps.push(dep);
@@ -336,18 +332,10 @@ var LiteVue = (function(exports) {
336
332
  if (key !== void 0) deps.push(depsMap.get(key));
337
333
  switch (type) {
338
334
  case "add":
339
- if (!isArray(target)) {
340
- deps.push(depsMap.get(ITERATE_KEY));
341
- if (isMap(target)) deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
342
- } else if (isIntegerKey(key)) deps.push(depsMap.get("length"));
335
+ if (!isArray(target)) deps.push(depsMap.get(ITERATE_KEY));
336
+ else if (isIntegerKey(key)) deps.push(depsMap.get("length"));
343
337
  break;
344
- case "delete":
345
- if (!isArray(target)) {
346
- deps.push(depsMap.get(ITERATE_KEY));
347
- if (isMap(target)) deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
348
- }
349
- break;
350
- case "set": if (isMap(target)) deps.push(depsMap.get(ITERATE_KEY));
338
+ case "delete": if (!isArray(target)) deps.push(depsMap.get(ITERATE_KEY));
351
339
  }
352
340
  }
353
341
  pauseScheduling();
@@ -564,12 +552,6 @@ getter: `, this.getter);
564
552
  set value(newValue) {
565
553
  this._setter(newValue);
566
554
  }
567
- get _dirty() {
568
- return this.effect.dirty;
569
- }
570
- set _dirty(v) {
571
- this.effect.dirty = v;
572
- }
573
555
  };
574
556
  function computed(getterOrOptions, debugOptions, isSSR = false) {
575
557
  let getter;
@@ -616,8 +598,7 @@ getter: `, this.getter);
616
598
  function isRef(r) {
617
599
  return !!(r && r.__v_isRef === true);
618
600
  }
619
- //#endregion
620
- //#region src/devtools.ts
601
+ // src/devtools.ts
621
602
  var scopes = /* @__PURE__ */ new Map();
622
603
  var exps = /* @__PURE__ */ new Map();
623
604
  var names = /* @__PURE__ */ new Map();
@@ -636,9 +617,8 @@ getter: `, this.getter);
636
617
  var emit = (event, ...args) => {
637
618
  listeners[event].forEach((fn) => fn(...args));
638
619
  };
639
- var noop = () => {};
640
620
  var registerScope = (el, scope, exp, name) => {
641
- if (isDisabled()) return noop;
621
+ if (isDisabled()) return NOOP;
642
622
  scopes.set(el, scope);
643
623
  if (exp) exps.set(el, exp);
644
624
  if (name) names.set(el, name);
@@ -718,8 +698,7 @@ getter: `, this.getter);
718
698
  if (typeof window !== "undefined" && window.__LITE_VUE__ === devtools) delete window.__LITE_VUE__;
719
699
  };
720
700
  if (typeof window !== "undefined" && !isDisabled()) window.__LITE_VUE__ = devtools;
721
- //#endregion
722
- //#region src/errors.ts
701
+ // src/errors.ts
723
702
  /** Levenshtein, bounded — only used to rank candidate names in DEV. */
724
703
  var distance = (a, b) => {
725
704
  const m = a.length;
@@ -808,8 +787,7 @@ getter: `, this.getter);
808
787
  console.error(parts.join(""), "\n ", err);
809
788
  if (info.el) console.error(info.el);
810
789
  };
811
- //#endregion
812
- //#region src/scheduler.ts
790
+ // src/scheduler.ts
813
791
  /**
814
792
  * Effects this library has stopped.
815
793
  *
@@ -826,13 +804,19 @@ getter: `, this.getter);
826
804
  if (runner.effect) stop(runner);
827
805
  };
828
806
  var queued = false;
829
- var queue = [];
807
+ var uid$1 = 0;
808
+ var queue = /* @__PURE__ */ new Set();
830
809
  var p = Promise.resolve();
831
- var flushIndex = -1;
832
810
  var MAX_RUNS = 100;
833
811
  var nextTick = (fn) => p.then(fn);
812
+ /**
813
+ * Stamps a job with its creation order, which the flush runs in. An effect
814
+ * stamped as it is created sorts before the children its first run creates.
815
+ */
816
+ var stampJob = (job) => (job.i = uid$1++, job);
834
817
  var queueJob = (job) => {
835
- if (!queue.includes(job, flushIndex + 1)) queue.push(job);
818
+ job.i ?? stampJob(job);
819
+ queue.add(job);
836
820
  if (!queued) {
837
821
  queued = true;
838
822
  nextTick(flushJobs);
@@ -840,8 +824,8 @@ getter: `, this.getter);
840
824
  };
841
825
  var flushJobs = () => {
842
826
  const runs = /* @__PURE__ */ new Map();
843
- for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
844
- const job = queue[flushIndex];
827
+ while (queue.size) for (const job of [...queue].sort((a, b) => a.i - b.i)) {
828
+ queue.delete(job);
845
829
  if (stopped.has(job)) continue;
846
830
  const n = (runs.get(job) || 0) + 1;
847
831
  runs.set(job, n);
@@ -855,13 +839,10 @@ getter: `, this.getter);
855
839
  handleError(e, { phase: "effect" });
856
840
  }
857
841
  }
858
- queue.length = 0;
859
- flushIndex = -1;
860
842
  queued = false;
861
843
  emitFlush();
862
844
  };
863
- //#endregion
864
- //#region src/magics.ts
845
+ // src/magics.ts
865
846
  var uid = 0;
866
847
  /**
867
848
  * $id('name') — unique ids for accessibility attributes. Stable within a scope
@@ -884,7 +865,7 @@ getter: `, this.getter);
884
865
  const value = getter();
885
866
  const previous = oldValue;
886
867
  oldValue = value;
887
- if (init ? value !== previous : options?.immediate) {
868
+ if (init ? hasChanged(value, previous) : options?.immediate) {
888
869
  pauseTracking();
889
870
  try {
890
871
  cb(value, previous);
@@ -894,11 +875,14 @@ getter: `, this.getter);
894
875
  }
895
876
  init = true;
896
877
  });
897
- return () => stopEffect(runner);
878
+ return () => {
879
+ stopEffect(runner);
880
+ remove(ctx.effects, runner);
881
+ };
898
882
  };
899
- //#endregion
900
- //#region src/directives/bind.ts
901
- var forceAttrRE = /^(spellcheck|draggable|form|list|type)$/;
883
+ // src/directives/bind.ts
884
+ var forceAttrRE = /^(spellcheck|draggable|translate|form|list|type)$/;
885
+ var booleanAttrRE = /^(readonly|novalidate|formnovalidate|allowfullscreen|playsinline)$/;
902
886
  var bind = ({ el, get, effect, arg, modifiers }) => {
903
887
  let prevValue;
904
888
  if ((!arg || arg === "class") && !("_class" in el)) el._class = el.getAttribute("class");
@@ -909,7 +893,7 @@ getter: `, this.getter);
909
893
  setProp(el, arg, value, prevValue);
910
894
  } else {
911
895
  for (const key in value) setProp(el, key, value[key], prevValue && prevValue[key]);
912
- for (const key in prevValue) if (!value || !(key in value)) setProp(el, key, null);
896
+ for (const key in prevValue) if (!value || !(key in value)) setProp(el, key, null, prevValue[key]);
913
897
  }
914
898
  prevValue = isPlainObject(value) ? { ...value } : value;
915
899
  if (!arg) el.__bound = prevValue;
@@ -923,6 +907,10 @@ getter: `, this.getter);
923
907
  const prev = toStyle(prevValue);
924
908
  for (const key in next) setStyle(style, key, next[key]);
925
909
  for (const key in prev) if (next[key] == null) setStyle(style, key, "");
910
+ if ("_vod" in el) {
911
+ if ("display" in next || "display" in prev) el._vod = style.display;
912
+ if (el._vsh) style.display = "none";
913
+ }
926
914
  if (!style.cssText) el.removeAttribute("style");
927
915
  } else if (!(el instanceof SVGElement) && key in el && !forceAttrRE.test(key)) {
928
916
  el[key] = value == null && typeof el[key] == "string" ? "" : value;
@@ -930,8 +918,11 @@ getter: `, this.getter);
930
918
  if (key === "value") el._value = value;
931
919
  } else if (key === "true-value") el._trueValue = value;
932
920
  else if (key === "false-value") el._falseValue = value;
933
- else if (value != null) el.setAttribute(key, value);
934
- else el.removeAttribute(key);
921
+ else {
922
+ if (booleanAttrRE.test(key)) value = value || value === "" ? "" : null;
923
+ if (value != null) el.setAttribute(key, value);
924
+ else el.removeAttribute(key);
925
+ }
935
926
  };
936
927
  var toStyle = (value) => isString(value = normalizeStyle(value)) ? parseStringStyle(value) : value || {};
937
928
  var importantRE = /\s*!important$/;
@@ -941,8 +932,7 @@ getter: `, this.getter);
941
932
  else if (importantRE.test(val)) style.setProperty(hyphenate(name), val.replace(importantRE, ""), "important");
942
933
  else style[name] = val;
943
934
  };
944
- //#endregion
945
- //#region src/warn.ts
935
+ // src/warn.ts
946
936
  /**
947
937
  * Development warnings.
948
938
  *
@@ -964,16 +954,62 @@ getter: `, this.getter);
964
954
  seen.add(key);
965
955
  warn(msg);
966
956
  };
967
- //#endregion
968
- //#region src/directives/on.ts
957
+ var evalCache = Object.create(null);
958
+ var cached = 0;
959
+ var mkDispatch = (el) => (event, detail) => el.dispatchEvent(new CustomEvent(event, {
960
+ detail,
961
+ bubbles: true
962
+ }));
963
+ var unwrap = (exp) => exp.replace(/^return\(([^]*)\)$/, "$1");
964
+ var evaluate = (scope, exp, el, meta) => execute(scope, `return(${exp})`, el, meta);
965
+ var execute = (scope, exp, el, meta) => {
966
+ let fn = evalCache[exp];
967
+ if (!fn) {
968
+ if (++cached > 1e3) {
969
+ evalCache = Object.create(null);
970
+ cached = 1;
971
+ }
972
+ fn = evalCache[exp] = toFunction(exp, el, meta);
973
+ }
974
+ try {
975
+ return fn(scope, el, el && mkDispatch(el));
976
+ } catch (e) {
977
+ handleError(e, {
978
+ phase: "expression",
979
+ expression: meta?.expression ?? unwrap(exp),
980
+ source: meta?.source,
981
+ el: meta?.el ?? el,
982
+ scope
983
+ });
984
+ }
985
+ };
986
+ var toFunction = (exp, el, meta) => {
987
+ try {
988
+ return new Function(`$data`, `$el`, `$dispatch`, `with($data){${exp}}`);
989
+ } catch (e) {
990
+ handleError(e, {
991
+ phase: "compile",
992
+ expression: meta?.expression ?? unwrap(exp),
993
+ source: meta?.source,
994
+ el: meta?.el ?? el
995
+ });
996
+ return NOOP;
997
+ }
998
+ };
999
+ // src/directives/on.ts
969
1000
  /**
970
1001
  * Can `exp` stand as a single expression, or is it a statement list?
971
1002
  * Memoised: it compiles a throwaway function, which a `v-for` pays per row.
972
1003
  */
973
1004
  var expressionCache = Object.create(null);
1005
+ var cachedExpressions = 0;
974
1006
  var isExpression = (exp) => {
975
1007
  const hit = expressionCache[exp];
976
1008
  if (hit !== void 0) return hit;
1009
+ if (++cachedExpressions > 1e3) {
1010
+ expressionCache = Object.create(null);
1011
+ cachedExpressions = 1;
1012
+ }
977
1013
  try {
978
1014
  new Function(`return (${exp})`);
979
1015
  return expressionCache[exp] = true;
@@ -981,6 +1017,7 @@ getter: `, this.getter);
981
1017
  return expressionCache[exp] = false;
982
1018
  }
983
1019
  };
1020
+ var fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$]+)\s*=>|^\s*(async\s+)?function\b/;
984
1021
  var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
985
1022
  var systemModifiers = [
986
1023
  "ctrl",
@@ -1017,7 +1054,7 @@ getter: `, this.getter);
1017
1054
  return;
1018
1055
  }
1019
1056
  const a = /\bawait\b/.test(exp) ? "async " : "";
1020
- let handler = simplePathRE.test(exp) ? get(`(e => ${exp}(e))`) : isExpression(exp) ? get(`(${a}$event => (${exp}))`) : get(`(${a}$event => { ${exp} })`);
1057
+ let handler = simplePathRE.test(exp) || fnExpRE.test(exp) ? get(`(e => (${exp})(e))`) : isExpression(exp) ? get(`(${a}$event => (${exp}))`) : get(`(${a}$event => { ${exp} })`);
1021
1058
  if (arg === "vue:mounted" || arg === "vue:unmounted") console.warn(`@${arg} is deprecated in LiteVue - use @${arg.slice(4)} instead.`);
1022
1059
  if (arg === "mounted" || arg === "vue:mounted") {
1023
1060
  let live = true;
@@ -1078,42 +1115,43 @@ getter: `, this.getter);
1078
1115
  if (key.startsWith("prop-") && "propertyName" in e && e.propertyName !== key.slice(5)) return;
1079
1116
  if (key.startsWith("name-") && "animationName" in e && e.animationName !== key.slice(5)) return;
1080
1117
  }
1118
+ if (modifiers.once) target.removeEventListener(event, handler, modifiers);
1081
1119
  return invoke(e);
1082
1120
  };
1083
1121
  }
1084
1122
  const target = modifiers?.window ? window : modifiers?.document || modifiers?.outside ? document : el;
1085
1123
  const event = arg;
1086
- target.addEventListener(event, handler, modifiers);
1124
+ target.addEventListener(event, handler, {
1125
+ ...modifiers,
1126
+ once: false
1127
+ });
1087
1128
  return () => {
1088
1129
  clearTimeout(debounceTimer);
1089
1130
  target.removeEventListener(event, handler, modifiers);
1090
1131
  };
1091
1132
  };
1092
- //#endregion
1093
- //#region src/directives/show.ts
1133
+ // src/directives/show.ts
1094
1134
  var show = ({ el, get, effect }) => {
1095
- const initialDisplay = el.style.display == "none" ? "" : el.style.display;
1135
+ el._vod = el.style.display == "none" ? "" : el.style.display;
1096
1136
  effect(() => {
1097
- el.style.display = get() ? initialDisplay : "none";
1137
+ el._vsh = !get();
1138
+ el.style.display = el._vsh ? "none" : el._vod;
1098
1139
  });
1099
1140
  };
1100
- //#endregion
1101
- //#region src/directives/text.ts
1141
+ // src/directives/text.ts
1102
1142
  var text = ({ el, get, effect }) => {
1103
1143
  effect(() => {
1104
1144
  el.textContent = toDisplayString(get());
1105
1145
  });
1106
1146
  };
1107
1147
  var toDisplayString = (value) => value == null ? "" : isObject(value) ? JSON.stringify(value, null, 2) : String(value);
1108
- //#endregion
1109
- //#region src/directives/html.ts
1148
+ // src/directives/html.ts
1110
1149
  var html = ({ el, get, effect }) => {
1111
1150
  effect(() => {
1112
1151
  el.innerHTML = get() ?? "";
1113
1152
  });
1114
1153
  };
1115
- //#endregion
1116
- //#region src/utils.ts
1154
+ // src/utils.ts
1117
1155
  var checkAttr = (el, name) => {
1118
1156
  const val = el.getAttribute(name);
1119
1157
  if (val != null) el.removeAttribute(name);
@@ -1128,21 +1166,24 @@ getter: `, this.getter);
1128
1166
  el.addEventListener(event, handler, options);
1129
1167
  return () => el.removeEventListener(event, handler, options);
1130
1168
  };
1131
- //#endregion
1132
- //#region src/directives/model.ts
1169
+ // src/directives/model.ts
1133
1170
  var model = ({ el, exp, get, effect, modifiers }) => {
1134
1171
  const type = el.type;
1135
1172
  const assign = get(`(val) => { ${exp} = val }`);
1136
1173
  const { trim, number = type === "number", lazy, fill } = modifiers || {};
1174
+ const cast = (val) => number ? looseToNumber(val) : val;
1137
1175
  const off = [];
1138
1176
  const on = (event, handler) => off.push(listen(el, event, handler));
1177
+ let update;
1178
+ let render;
1179
+ let isText = false;
1139
1180
  if (el.tagName === "SELECT") {
1140
1181
  const sel = el;
1141
- on("change", () => {
1142
- const selectedVal = Array.prototype.filter.call(sel.options, (o) => o.selected).map((o) => number ? toNumber(getValue(o)) : getValue(o));
1182
+ on("change", update = () => {
1183
+ const selectedVal = Array.prototype.filter.call(sel.options, (o) => o.selected).map((o) => cast(getValue(o)));
1143
1184
  assign(sel.multiple ? selectedVal : selectedVal[0]);
1144
1185
  });
1145
- effect(() => {
1186
+ render = () => {
1146
1187
  const value = get();
1147
1188
  const isMultiple = sel.multiple;
1148
1189
  if (isMultiple && !isArray(value)) warnOnce(`select-multiple:${exp}`, `<select multiple v-model="${exp}"> needs an array, but got ${value === null ? "null" : typeof value}, so no option is selected. Initialise it as [] — a change writes an array either way.`);
@@ -1156,9 +1197,9 @@ getter: `, this.getter);
1156
1197
  }
1157
1198
  }
1158
1199
  if (!isMultiple && sel.selectedIndex !== -1) sel.selectedIndex = -1;
1159
- });
1200
+ };
1160
1201
  } else if (type === "checkbox") {
1161
- on("change", () => {
1202
+ on("change", update = () => {
1162
1203
  const modelValue = get();
1163
1204
  const checked = el.checked;
1164
1205
  if (isArray(modelValue)) {
@@ -1173,23 +1214,20 @@ getter: `, this.getter);
1173
1214
  }
1174
1215
  } else assign(getCheckboxValue(el, checked));
1175
1216
  });
1176
- effect(() => {
1217
+ render = () => {
1177
1218
  const value = get();
1178
1219
  if (isArray(value)) el.checked = looseIndexOf(value, getValue(el)) > -1;
1179
1220
  else el.checked = looseEqual(value, getCheckboxValue(el, true));
1180
- });
1221
+ };
1181
1222
  } else if (type === "radio") {
1182
- on("change", () => {
1183
- assign(getValue(el));
1184
- });
1185
- effect(() => {
1223
+ on("change", update = () => assign(getValue(el)));
1224
+ render = () => {
1186
1225
  el.checked = looseEqual(get(), getValue(el));
1187
- });
1188
- } else {
1189
- const resolveValue = (val) => {
1190
- if (trim) val = val.trim();
1191
- return number ? toNumber(val) : val;
1192
1226
  };
1227
+ } else {
1228
+ isText = true;
1229
+ const resolveValue = (val) => cast(trim ? val.trim() : val);
1230
+ update = () => assign(resolveValue(el.value));
1193
1231
  let write = assign;
1194
1232
  let debounceTimer;
1195
1233
  for (const key in modifiers || {}) {
@@ -1212,17 +1250,27 @@ getter: `, this.getter);
1212
1250
  if (trim) on("change", () => {
1213
1251
  el.value = el.value.trim();
1214
1252
  });
1215
- if (fill) {
1216
- const cur = get();
1217
- if ((cur == null || cur === "") && el.value) assign(resolveValue(el.value));
1218
- }
1219
- effect(() => {
1253
+ render = () => {
1220
1254
  if (el.composing) return;
1221
1255
  const curVal = el.value;
1222
1256
  const newVal = get() ?? "";
1223
1257
  if (document.activeElement === el && resolveValue(curVal) === newVal) return;
1224
1258
  if (curVal !== newVal) el.value = newVal;
1259
+ };
1260
+ }
1261
+ if (fill) {
1262
+ const cur = get();
1263
+ if ((cur == null || cur === "") && el.value && (type !== "radio" || el.checked)) update();
1264
+ }
1265
+ const sync = effect(render);
1266
+ if (!isText) {
1267
+ const observer = new MutationObserver(() => sync());
1268
+ observer.observe(el, {
1269
+ attributes: true,
1270
+ childList: true,
1271
+ subtree: true
1225
1272
  });
1273
+ off.push(() => observer.disconnect());
1226
1274
  }
1227
1275
  return () => off.forEach((remove) => remove());
1228
1276
  };
@@ -1247,50 +1295,7 @@ getter: `, this.getter);
1247
1295
  cancelable: true
1248
1296
  }));
1249
1297
  };
1250
- var evalCache = Object.create(null);
1251
- var cached = 0;
1252
- var mkDispatch = (el) => (event, detail) => el.dispatchEvent(new CustomEvent(event, {
1253
- detail,
1254
- bubbles: true
1255
- }));
1256
- var unwrap = (exp) => exp.replace(/^return\(([^]*)\)$/, "$1");
1257
- var evaluate = (scope, exp, el, meta) => execute(scope, `return(${exp})`, el, meta);
1258
- var execute = (scope, exp, el, meta) => {
1259
- let fn = evalCache[exp];
1260
- if (!fn) {
1261
- if (++cached > 1e3) {
1262
- evalCache = Object.create(null);
1263
- cached = 1;
1264
- }
1265
- fn = evalCache[exp] = toFunction(exp, el, meta);
1266
- }
1267
- try {
1268
- return fn(scope, el, el && mkDispatch(el));
1269
- } catch (e) {
1270
- handleError(e, {
1271
- phase: "expression",
1272
- expression: meta?.expression ?? unwrap(exp),
1273
- source: meta?.source,
1274
- el: meta?.el ?? el,
1275
- scope
1276
- });
1277
- }
1278
- };
1279
- var toFunction = (exp, el, meta) => {
1280
- try {
1281
- return new Function(`$data`, `$el`, `$dispatch`, `with($data){${exp}}`);
1282
- } catch (e) {
1283
- handleError(e, {
1284
- phase: "compile",
1285
- expression: meta?.expression ?? unwrap(exp),
1286
- source: meta?.source,
1287
- el: meta?.el ?? el
1288
- });
1289
- return () => {};
1290
- }
1291
- };
1292
- //#endregion
1293
- //#region src/ownership.ts
1298
+ // src/ownership.ts
1294
1299
  var owned = /* @__PURE__ */ new WeakMap();
1295
1300
  /**
1296
1301
  * The node currently being walked. A module-level cursor suffices because the
@@ -1315,6 +1320,8 @@ getter: `, this.getter);
1315
1320
  if (list) list.push(dispose);
1316
1321
  else owned.set(node, [dispose]);
1317
1322
  };
1323
+ /** Withdraws a disposer from `node`, for an owner that removes it itself. */
1324
+ var disown = (dispose, node) => remove(owned.get(node) || [], dispose);
1318
1325
  /**
1319
1326
  * Disposes `node` and its subtree. Safe on an unowned node, and idempotent —
1320
1327
  * the record is dropped as it runs.
@@ -1332,18 +1339,18 @@ getter: `, this.getter);
1332
1339
  child = next;
1333
1340
  }
1334
1341
  };
1335
- //#endregion
1336
- //#region src/directives/effect.ts
1342
+ // src/directives/effect.ts
1337
1343
  var effect = ({ el, ctx, exp, effect }) => {
1338
1344
  let live = true;
1345
+ const once = inOnce;
1339
1346
  nextTick(() => {
1340
1347
  if (!live) return;
1341
1348
  const previous = setOwner(el);
1342
1349
  try {
1343
- effect(() => execute(ctx.scope, exp, el, {
1350
+ withOnce(once, () => effect(() => execute(ctx.scope, exp, el, {
1344
1351
  source: "v-effect",
1345
1352
  el
1346
- }));
1353
+ })));
1347
1354
  } finally {
1348
1355
  setOwner(previous);
1349
1356
  }
@@ -1352,8 +1359,7 @@ getter: `, this.getter);
1352
1359
  live = false;
1353
1360
  };
1354
1361
  };
1355
- //#endregion
1356
- //#region src/directives/index.ts
1362
+ // src/directives/index.ts
1357
1363
  var builtInDirectives = {
1358
1364
  bind,
1359
1365
  on,
@@ -1363,8 +1369,7 @@ getter: `, this.getter);
1363
1369
  model,
1364
1370
  effect
1365
1371
  };
1366
- //#endregion
1367
- //#region src/directives/if.ts
1372
+ // src/directives/if.ts
1368
1373
  var _if = (el, exp, ctx) => {
1369
1374
  if (!exp.trim()) console.warn(`v-if expression cannot be empty.`);
1370
1375
  const anchor = new Comment("v-if");
@@ -1377,10 +1382,11 @@ getter: `, this.getter);
1377
1382
  let elseExp;
1378
1383
  while (elseEl = el.nextElementSibling) {
1379
1384
  elseExp = null;
1380
- if (checkAttr(elseEl, "v-else") === "" || (elseExp = checkAttr(elseEl, "v-else-if"))) {
1385
+ if (checkAttr(elseEl, "v-else") === "" || (elseExp = checkAttr(elseEl, "v-else-if")) != null) {
1386
+ if (elseExp?.trim() === "") console.warn(`v-else-if expression cannot be empty.`);
1381
1387
  elseEl.remove();
1382
1388
  branches.push({
1383
- exp: elseExp,
1389
+ exp: elseExp == null ? elseExp : elseExp.trim() || "0",
1384
1390
  el: elseEl
1385
1391
  });
1386
1392
  } else break;
@@ -1393,6 +1399,7 @@ getter: `, this.getter);
1393
1399
  const removeActiveBlock = () => {
1394
1400
  if (block) {
1395
1401
  if (!anchor.parentNode) block.el.before(anchor);
1402
+ disown(stopBranches, block.el);
1396
1403
  block.remove();
1397
1404
  block = void 0;
1398
1405
  }
@@ -1424,8 +1431,7 @@ getter: `, this.getter);
1424
1431
  own(stopBranches, anchor);
1425
1432
  return nextNode;
1426
1433
  };
1427
- //#endregion
1428
- //#region src/directives/for.ts
1434
+ // src/directives/for.ts
1429
1435
  var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
1430
1436
  var forIteratorRE = /,([^,}\]]*)(?:,([^,}\]]*))?$/;
1431
1437
  var stripParensRE = /^\(|\)$/g;
@@ -1480,7 +1486,7 @@ getter: `, this.getter);
1480
1486
  };
1481
1487
  const createRow = (map, value, index, objKey) => {
1482
1488
  const data = {};
1483
- if (destructureBindings) destructureBindings.forEach((b, i) => data[b] = value[isArrayDestructure ? i : b]);
1489
+ if (destructureBindings) destructureBindings.forEach((b, i) => data[b] = value?.[isArrayDestructure ? i : b]);
1484
1490
  else data[valueExp] = value;
1485
1491
  if (objKey) {
1486
1492
  indexExp && (data[indexExp] = objKey);
@@ -1518,7 +1524,7 @@ getter: `, this.getter);
1518
1524
  counts.set(row.key, n);
1519
1525
  if (n > 1 && dup === void 0) dup = row.key;
1520
1526
  }
1521
- warnOnce(`for-dup-key:${exp}`, `v-for="${exp}" produced a duplicate :key ${JSON.stringify(dup)}. Keys must be unique among siblings — with a repeat, one item's element and its scope state are silently dropped. Key by something stable and unique, such as a record id.`);
1527
+ warnOnce(`for-dup-key:${exp}`, `v-for="${exp}" produced a duplicate :key ${JSON.stringify(dup)}. Keys must be unique among siblings — with a repeat, the earlier item is rebuilt on every update, losing its element and scope state. Key by something stable and unique, such as a record id.`);
1522
1528
  }
1523
1529
  if (!keyExp && isArray(source)) {
1524
1530
  const items = [...source];
@@ -1534,25 +1540,24 @@ getter: `, this.getter);
1534
1540
  blocks = rows.map((row) => mountBlock(row, anchor));
1535
1541
  mounted = true;
1536
1542
  } else {
1537
- for (let i = 0; i < blocks.length; i++) if (!keyToIndexMap.has(blocks[i].key)) blocks[i].remove();
1543
+ for (let i = 0; i < blocks.length; i++) {
1544
+ const key = blocks[i].key;
1545
+ if (!keyToIndexMap.has(key) || prevKeyToIndexMap.get(key) !== i) blocks[i].remove();
1546
+ }
1538
1547
  const nextBlocks = [];
1539
1548
  let i = rows.length;
1540
1549
  let nextBlock;
1541
- let prevMovedBlock;
1542
1550
  while (i--) {
1543
1551
  const row = rows[i];
1544
1552
  const oldIndex = prevKeyToIndexMap.get(row.key);
1553
+ prevKeyToIndexMap.delete(row.key);
1554
+ const ref = nextBlock ? nextBlock.el : anchor;
1545
1555
  let block;
1546
- if (oldIndex == null) block = mountBlock(row, nextBlock ? nextBlock.el : anchor);
1556
+ if (oldIndex == null) block = mountBlock(row, ref);
1547
1557
  else {
1548
1558
  block = blocks[oldIndex];
1549
1559
  Object.assign(block.ctx.scope, row.data);
1550
- if (oldIndex !== i) {
1551
- if (blocks[oldIndex + 1] !== nextBlock || prevMovedBlock === nextBlock) {
1552
- prevMovedBlock = block;
1553
- block.insert(parent(), nextBlock ? nextBlock.el : anchor);
1554
- }
1555
- }
1560
+ if (oldIndex !== i && (block.end || block.el).nextSibling !== ref) block.insert(parent(), ref);
1556
1561
  }
1557
1562
  nextBlocks[i] = nextBlock = block;
1558
1563
  }
@@ -1561,8 +1566,7 @@ getter: `, this.getter);
1561
1566
  });
1562
1567
  return nextNode;
1563
1568
  };
1564
- //#endregion
1565
- //#region src/directives/ref.ts
1569
+ // src/directives/ref.ts
1566
1570
  var ref = ({ el, ctx: { scope: { $refs } }, get, effect }) => {
1567
1571
  let prevRef;
1568
1572
  effect(() => {
@@ -1579,8 +1583,7 @@ getter: `, this.getter);
1579
1583
  prevRef && delete $refs[prevRef];
1580
1584
  };
1581
1585
  };
1582
- //#endregion
1583
- //#region src/lazy.ts
1586
+ // src/lazy.ts
1584
1587
  var LAZY_MODES = [
1585
1588
  "visible",
1586
1589
  "idle",
@@ -1605,7 +1608,7 @@ getter: `, this.getter);
1605
1608
  stop();
1606
1609
  fire();
1607
1610
  };
1608
- let stop = () => {};
1611
+ let stop = NOOP;
1609
1612
  if (mode === "visible" && typeof IntersectionObserver == "function") {
1610
1613
  const io = new IntersectionObserver((entries) => {
1611
1614
  if (entries.some((e) => e.isIntersecting)) once();
@@ -1642,11 +1645,13 @@ getter: `, this.getter);
1642
1645
  walk(el, ctx, once);
1643
1646
  });
1644
1647
  ctx.cleanups.push(dispose);
1645
- own(dispose);
1648
+ own(() => {
1649
+ remove(ctx.cleanups, dispose);
1650
+ dispose();
1651
+ });
1646
1652
  return true;
1647
1653
  };
1648
- //#endregion
1649
- //#region src/walk.ts
1654
+ // src/walk.ts
1650
1655
  var dirRE = /^(?:v-|:|@)/;
1651
1656
  var modifierRE = /\.([\w-]+)/g;
1652
1657
  var inOnce = false;
@@ -1670,15 +1675,16 @@ getter: `, this.getter);
1670
1675
  }
1671
1676
  }, node);
1672
1677
  };
1673
- var walkDeferred = (node, ctx, once) => {
1678
+ var withOnce = (once, fn) => {
1674
1679
  const previous = inOnce;
1675
1680
  inOnce = once;
1676
1681
  try {
1677
- walk(node, ctx);
1682
+ fn();
1678
1683
  } finally {
1679
1684
  inOnce = previous;
1680
1685
  }
1681
1686
  };
1687
+ var walkDeferred = (node, ctx, once) => withOnce(once, () => walk(node, ctx));
1682
1688
  var walk = (node, ctx) => {
1683
1689
  const previousOwner = setOwner(node);
1684
1690
  try {
@@ -1691,6 +1697,7 @@ getter: `, this.getter);
1691
1697
  const type = node.nodeType;
1692
1698
  if (type === 1) {
1693
1699
  const el = node;
1700
+ if (!el.hasAttributes()) return walkChildren(el, ctx);
1694
1701
  if (el.hasAttribute("v-pre")) return;
1695
1702
  if (deferScope(el, ctx, walkDeferred, inOnce)) return;
1696
1703
  checkAttr(el, "v-cloak");
@@ -1719,7 +1726,11 @@ getter: `, this.getter);
1719
1726
  }) : {}) || {};
1720
1727
  ctx = createScopedContext(ctx, scope);
1721
1728
  el.__ctx = ctx;
1722
- addCleanup(ctx, registerScope(el, ctx.scope, exp || void 0, name || void 0));
1729
+ const deregister = registerScope(el, ctx.scope, exp || void 0, name || void 0);
1730
+ addCleanup(ctx, () => {
1731
+ deregister();
1732
+ delete el.__ctx;
1733
+ });
1723
1734
  if (scope.$template) resolveTemplate(el, scope.$template);
1724
1735
  }
1725
1736
  const wasOnce = inOnce;
@@ -1814,12 +1825,15 @@ getter: `, this.getter);
1814
1825
  const get = (code) => {
1815
1826
  const value = evaluate(ctx.scope, code ?? exp, el, meta);
1816
1827
  return code && typeof value == "function" ? (...args) => {
1828
+ const previous = setOwner(el);
1817
1829
  try {
1818
1830
  const result = value(...args);
1819
1831
  if (result instanceof Promise) result.catch(report);
1820
1832
  return result;
1821
1833
  } catch (err) {
1822
1834
  report(err);
1835
+ } finally {
1836
+ setOwner(previous);
1823
1837
  }
1824
1838
  } : value;
1825
1839
  };
@@ -1864,8 +1878,8 @@ getter: `, this.getter);
1864
1878
  var resolveTemplate = (el, template) => {
1865
1879
  if (template[0] === "#") {
1866
1880
  const templateEl = query(template, el, "v-scope");
1867
- if (!templateEl) {
1868
- if (templateEl === null) console.error(`template selector ${template} has no matching <template> element.`);
1881
+ if (!(templateEl instanceof HTMLTemplateElement)) {
1882
+ if (templateEl !== void 0) console.error(`template selector ${template} has no matching <template> element.`);
1869
1883
  return;
1870
1884
  }
1871
1885
  el.appendChild(templateEl.content.cloneNode(true));
@@ -1873,8 +1887,7 @@ getter: `, this.getter);
1873
1887
  }
1874
1888
  el.innerHTML = template;
1875
1889
  };
1876
- //#endregion
1877
- //#region src/context.ts
1890
+ // src/context.ts
1878
1891
  var createContext = (parent) => {
1879
1892
  const ctx = {
1880
1893
  delimiters: ["{{", "}}"],
@@ -1887,15 +1900,20 @@ getter: `, this.getter);
1887
1900
  cleanups: [],
1888
1901
  effect: (fn) => {
1889
1902
  if (inOnce) {
1890
- queueJob(fn);
1891
- return fn;
1903
+ const job = () => withOnce(true, fn);
1904
+ queueJob(job);
1905
+ return job;
1892
1906
  }
1893
- const e = effect$1(fn, { scheduler: () => queueJob(e) });
1907
+ const e = stampJob(effect$1(fn, {
1908
+ scheduler: () => queueJob(e),
1909
+ lazy: true
1910
+ }));
1894
1911
  ctx.effects.push(e);
1895
1912
  own(() => {
1896
1913
  stopEffect(e);
1897
1914
  remove(ctx.effects, e);
1898
1915
  });
1916
+ e();
1899
1917
  return e;
1900
1918
  }
1901
1919
  };
@@ -1926,26 +1944,17 @@ getter: `, this.getter);
1926
1944
  };
1927
1945
  hide(mergedScope, "$watch", createWatch(scopedCtx));
1928
1946
  hide(mergedScope, "$id", createId());
1929
- bindContextMethods(reactiveProxy);
1947
+ bindContextMethods(reactiveProxy, mergedScope);
1930
1948
  return scopedCtx;
1931
1949
  };
1932
- var bindContextMethods = (scope) => {
1933
- for (const key of Object.keys(scope)) {
1934
- const fn = Object.getOwnPropertyDescriptor(scope, key).value;
1950
+ var bindContextMethods = (scope, raw = scope) => {
1951
+ for (const key of Object.keys(raw)) {
1952
+ const fn = Object.getOwnPropertyDescriptor(raw, key).value;
1935
1953
  if (typeof fn === "function") scope[key] = fn.bind(scope);
1936
1954
  }
1937
1955
  };
1938
- //#endregion
1939
- //#region src/block.ts
1956
+ // src/block.ts
1940
1957
  var Block = class {
1941
- template;
1942
- ctx;
1943
- key;
1944
- parentCtx;
1945
- isFragment;
1946
- start;
1947
- end;
1948
- owned = false;
1949
1958
  get el() {
1950
1959
  return this.start || this.template.__marker || this.template;
1951
1960
  }
@@ -1997,10 +2006,14 @@ getter: `, this.getter);
1997
2006
  while (node) {
1998
2007
  next = node.nextSibling;
1999
2008
  parent.removeChild(node);
2009
+ disposeSubtree(node);
2000
2010
  if (node === this.end) break;
2001
2011
  node = next;
2002
2012
  }
2003
- } else parent.removeChild(this.template);
2013
+ } else {
2014
+ parent.removeChild(this.template);
2015
+ disposeSubtree(this.template);
2016
+ }
2004
2017
  }
2005
2018
  this.template.__marker?.remove();
2006
2019
  this.teardown();
@@ -2032,8 +2045,7 @@ getter: `, this.getter);
2032
2045
  this.ctx.cleanups.splice(0).forEach((fn) => fn());
2033
2046
  }
2034
2047
  };
2035
- //#endregion
2036
- //#region src/store.ts
2048
+ // src/store.ts
2037
2049
  /**
2038
2050
  * DEV: catch `$store.typo`, which otherwise reads as `undefined` and renders a
2039
2051
  * blank instead of raising.
@@ -2051,7 +2063,7 @@ getter: `, this.getter);
2051
2063
  var registry = Object.create(null);
2052
2064
  var target = registry;
2053
2065
  target = new Proxy(registry, { get(obj, key, receiver) {
2054
- if (typeof key === "string" && !key.startsWith("__") && !(key in obj)) setTimeout(() => {
2066
+ if (typeof key === "string" && !key.startsWith("__") && key !== "toJSON" && !(key in obj)) setTimeout(() => {
2055
2067
  if (key in obj) return;
2056
2068
  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.`);
2057
2069
  });
@@ -2071,9 +2083,8 @@ getter: `, this.getter);
2071
2083
  }
2072
2084
  return stores[name];
2073
2085
  };
2074
- //#endregion
2075
- //#region src/app.ts
2076
- var mountedRoots = /* @__PURE__ */ new WeakSet();
2086
+ // src/app.ts
2087
+ var mountedRoots = /* @__PURE__ */ new WeakMap();
2077
2088
  var escapeRegex = (str) => str.replace(/[-.*+?^${}()|[\]/\\]/g, "\\$&");
2078
2089
  var createApp = (initialData) => {
2079
2090
  const ctx = createContext();
@@ -2089,12 +2100,12 @@ getter: `, this.getter);
2089
2100
  ctx.delimitersRE = new RegExp(escapeRegex(open) + "([^]+?)" + escapeRegex(close), "g");
2090
2101
  }
2091
2102
  }
2092
- ctx.scope.$s = toDisplayString;
2093
- ctx.scope.$nextTick = nextTick;
2094
- ctx.scope.$refs = Object.create(null);
2095
- ctx.scope.$store = stores;
2096
- ctx.scope.$watch = createWatch(ctx);
2097
- ctx.scope.$id = createId();
2103
+ hide(ctx.scope, "$s", toDisplayString);
2104
+ hide(ctx.scope, "$nextTick", nextTick);
2105
+ hide(ctx.scope, "$refs", Object.create(null));
2106
+ hide(ctx.scope, "$store", stores);
2107
+ hide(ctx.scope, "$watch", createWatch(ctx));
2108
+ hide(ctx.scope, "$id", createId());
2098
2109
  Object.defineProperty(ctx.scope, "$root", {
2099
2110
  value: ctx.scope,
2100
2111
  enumerable: false
@@ -2172,13 +2183,15 @@ getter: `, this.getter);
2172
2183
  ctx.walk ??= walk;
2173
2184
  ctx.dispose ??= disposeSubtree;
2174
2185
  for (const el of roots) {
2175
- if (mountedRoots.has(el)) 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.");
2176
- mountedRoots.add(el);
2186
+ 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.");
2177
2187
  const name = el.getAttribute("v-name");
2178
2188
  const block = new Block(el, ctx, true);
2189
+ mountedRoots.set(el, el.firstChild);
2179
2190
  el.__ctx ??= block.ctx;
2180
2191
  if (!devtools.scopes.has(el) && !el.matches(SCOPE_SELECTOR)) block.ctx.cleanups.push(registerScope(el, block.ctx.scope, void 0, name || void 0));
2181
2192
  rootBlocks.push(block);
2193
+ own(() => remove(rootBlocks, block), el);
2194
+ block.ctx.cleanups.push(() => delete el.__ctx);
2182
2195
  }
2183
2196
  return this;
2184
2197
  },
@@ -2225,8 +2238,7 @@ getter: `, this.getter);
2225
2238
  };
2226
2239
  return app;
2227
2240
  };
2228
- //#endregion
2229
- //#region src/effect.ts
2241
+ // src/effect.ts
2230
2242
  /**
2231
2243
  * Runs `fn` now, then again when the reactive state it read changes. The
2232
2244
  * JS-side counterpart to `v-effect`, for work not tied to an element.
@@ -2238,15 +2250,22 @@ getter: `, this.getter);
2238
2250
  * Returns a stop function. Nothing stops it automatically.
2239
2251
  */
2240
2252
  var watchEffect = (fn) => {
2241
- let runner;
2242
- runner = effect$1(fn, { scheduler: () => queueJob(runner) });
2253
+ const runner = effect$1(fn, {
2254
+ scheduler: () => queueJob(runner),
2255
+ lazy: true
2256
+ });
2257
+ runner.i = Infinity;
2258
+ try {
2259
+ runner();
2260
+ } catch (e) {
2261
+ stopEffect(runner);
2262
+ throw e;
2263
+ }
2243
2264
  return () => stopEffect(runner);
2244
2265
  };
2245
- //#endregion
2246
- //#region src/index.ts
2266
+ // src/index.ts
2247
2267
  var s = document.currentScript;
2248
2268
  if (s && s.hasAttribute("init")) createApp().mount();
2249
- //#endregion
2250
2269
  exports.computed = computed;
2251
2270
  exports.createApp = createApp;
2252
2271
  exports.devtools = devtools;