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