@aevantec/litevue 0.5.16 → 0.6.0
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-devtools.iife.js +1 -1
- package/dist/litevue-devtools.mjs +1 -1
- package/dist/litevue-devtools.umd.js +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 +246 -222
- package/dist/litevue.dev.mjs +246 -222
- 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/index.d.mts +2 -0
- package/dist/types/directives/index.d.ts +2 -0
- 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 +10 -2
- package/dist/types/scheduler.d.ts +10 -2
- package/dist/types/walk.d.mts +1 -0
- package/dist/types/walk.d.ts +1 -0
- package/package.json +9 -9
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,18 @@ var builtInDirectives = {
|
|
|
1361
1367
|
model,
|
|
1362
1368
|
effect
|
|
1363
1369
|
};
|
|
1364
|
-
|
|
1365
|
-
|
|
1370
|
+
var structuralDirectives = [
|
|
1371
|
+
"scope",
|
|
1372
|
+
"if",
|
|
1373
|
+
"for",
|
|
1374
|
+
"once",
|
|
1375
|
+
"pre",
|
|
1376
|
+
"cloak",
|
|
1377
|
+
"teleport",
|
|
1378
|
+
"name"
|
|
1379
|
+
];
|
|
1380
|
+
var isBuiltInDirective = (name) => hasOwn(builtInDirectives, name) || structuralDirectives.includes(name);
|
|
1381
|
+
// src/directives/if.ts
|
|
1366
1382
|
var _if = (el, exp, ctx) => {
|
|
1367
1383
|
if (!exp.trim()) console.warn(`v-if expression cannot be empty.`);
|
|
1368
1384
|
const anchor = new Comment("v-if");
|
|
@@ -1375,10 +1391,11 @@ var _if = (el, exp, ctx) => {
|
|
|
1375
1391
|
let elseExp;
|
|
1376
1392
|
while (elseEl = el.nextElementSibling) {
|
|
1377
1393
|
elseExp = null;
|
|
1378
|
-
if (checkAttr(elseEl, "v-else") === "" || (elseExp = checkAttr(elseEl, "v-else-if"))) {
|
|
1394
|
+
if (checkAttr(elseEl, "v-else") === "" || (elseExp = checkAttr(elseEl, "v-else-if")) != null) {
|
|
1395
|
+
if (elseExp?.trim() === "") console.warn(`v-else-if expression cannot be empty.`);
|
|
1379
1396
|
elseEl.remove();
|
|
1380
1397
|
branches.push({
|
|
1381
|
-
exp: elseExp,
|
|
1398
|
+
exp: elseExp == null ? elseExp : elseExp.trim() || "0",
|
|
1382
1399
|
el: elseEl
|
|
1383
1400
|
});
|
|
1384
1401
|
} else break;
|
|
@@ -1391,6 +1408,7 @@ var _if = (el, exp, ctx) => {
|
|
|
1391
1408
|
const removeActiveBlock = () => {
|
|
1392
1409
|
if (block) {
|
|
1393
1410
|
if (!anchor.parentNode) block.el.before(anchor);
|
|
1411
|
+
disown(stopBranches, block.el);
|
|
1394
1412
|
block.remove();
|
|
1395
1413
|
block = void 0;
|
|
1396
1414
|
}
|
|
@@ -1422,8 +1440,7 @@ var _if = (el, exp, ctx) => {
|
|
|
1422
1440
|
own(stopBranches, anchor);
|
|
1423
1441
|
return nextNode;
|
|
1424
1442
|
};
|
|
1425
|
-
|
|
1426
|
-
//#region src/directives/for.ts
|
|
1443
|
+
// src/directives/for.ts
|
|
1427
1444
|
var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
|
1428
1445
|
var forIteratorRE = /,([^,}\]]*)(?:,([^,}\]]*))?$/;
|
|
1429
1446
|
var stripParensRE = /^\(|\)$/g;
|
|
@@ -1478,7 +1495,7 @@ var _for = (el, exp, ctx) => {
|
|
|
1478
1495
|
};
|
|
1479
1496
|
const createRow = (map, value, index, objKey) => {
|
|
1480
1497
|
const data = {};
|
|
1481
|
-
if (destructureBindings) destructureBindings.forEach((b, i) => data[b] = value[isArrayDestructure ? i : b]);
|
|
1498
|
+
if (destructureBindings) destructureBindings.forEach((b, i) => data[b] = value?.[isArrayDestructure ? i : b]);
|
|
1482
1499
|
else data[valueExp] = value;
|
|
1483
1500
|
if (objKey) {
|
|
1484
1501
|
indexExp && (data[indexExp] = objKey);
|
|
@@ -1516,7 +1533,7 @@ var _for = (el, exp, ctx) => {
|
|
|
1516
1533
|
counts.set(row.key, n);
|
|
1517
1534
|
if (n > 1 && dup === void 0) dup = row.key;
|
|
1518
1535
|
}
|
|
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,
|
|
1536
|
+
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
1537
|
}
|
|
1521
1538
|
if (!keyExp && isArray(source)) {
|
|
1522
1539
|
const items = [...source];
|
|
@@ -1532,25 +1549,24 @@ var _for = (el, exp, ctx) => {
|
|
|
1532
1549
|
blocks = rows.map((row) => mountBlock(row, anchor));
|
|
1533
1550
|
mounted = true;
|
|
1534
1551
|
} else {
|
|
1535
|
-
for (let i = 0; i < blocks.length; i++)
|
|
1552
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
1553
|
+
const key = blocks[i].key;
|
|
1554
|
+
if (!keyToIndexMap.has(key) || prevKeyToIndexMap.get(key) !== i) blocks[i].remove();
|
|
1555
|
+
}
|
|
1536
1556
|
const nextBlocks = [];
|
|
1537
1557
|
let i = rows.length;
|
|
1538
1558
|
let nextBlock;
|
|
1539
|
-
let prevMovedBlock;
|
|
1540
1559
|
while (i--) {
|
|
1541
1560
|
const row = rows[i];
|
|
1542
1561
|
const oldIndex = prevKeyToIndexMap.get(row.key);
|
|
1562
|
+
prevKeyToIndexMap.delete(row.key);
|
|
1563
|
+
const ref = nextBlock ? nextBlock.el : anchor;
|
|
1543
1564
|
let block;
|
|
1544
|
-
if (oldIndex == null) block = mountBlock(row,
|
|
1565
|
+
if (oldIndex == null) block = mountBlock(row, ref);
|
|
1545
1566
|
else {
|
|
1546
1567
|
block = blocks[oldIndex];
|
|
1547
1568
|
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
|
-
}
|
|
1569
|
+
if (oldIndex !== i && (block.end || block.el).nextSibling !== ref) block.insert(parent(), ref);
|
|
1554
1570
|
}
|
|
1555
1571
|
nextBlocks[i] = nextBlock = block;
|
|
1556
1572
|
}
|
|
@@ -1559,8 +1575,7 @@ var _for = (el, exp, ctx) => {
|
|
|
1559
1575
|
});
|
|
1560
1576
|
return nextNode;
|
|
1561
1577
|
};
|
|
1562
|
-
|
|
1563
|
-
//#region src/directives/ref.ts
|
|
1578
|
+
// src/directives/ref.ts
|
|
1564
1579
|
var ref = ({ el, ctx: { scope: { $refs } }, get, effect }) => {
|
|
1565
1580
|
let prevRef;
|
|
1566
1581
|
effect(() => {
|
|
@@ -1577,8 +1592,7 @@ var ref = ({ el, ctx: { scope: { $refs } }, get, effect }) => {
|
|
|
1577
1592
|
prevRef && delete $refs[prevRef];
|
|
1578
1593
|
};
|
|
1579
1594
|
};
|
|
1580
|
-
|
|
1581
|
-
//#region src/lazy.ts
|
|
1595
|
+
// src/lazy.ts
|
|
1582
1596
|
var LAZY_MODES = [
|
|
1583
1597
|
"visible",
|
|
1584
1598
|
"idle",
|
|
@@ -1603,7 +1617,7 @@ var arm = (el, mode, fire) => {
|
|
|
1603
1617
|
stop();
|
|
1604
1618
|
fire();
|
|
1605
1619
|
};
|
|
1606
|
-
let stop =
|
|
1620
|
+
let stop = NOOP;
|
|
1607
1621
|
if (mode === "visible" && typeof IntersectionObserver == "function") {
|
|
1608
1622
|
const io = new IntersectionObserver((entries) => {
|
|
1609
1623
|
if (entries.some((e) => e.isIntersecting)) once();
|
|
@@ -1640,11 +1654,13 @@ var deferScope = (el, ctx, walk, once) => {
|
|
|
1640
1654
|
walk(el, ctx, once);
|
|
1641
1655
|
});
|
|
1642
1656
|
ctx.cleanups.push(dispose);
|
|
1643
|
-
own(
|
|
1657
|
+
own(() => {
|
|
1658
|
+
remove(ctx.cleanups, dispose);
|
|
1659
|
+
dispose();
|
|
1660
|
+
});
|
|
1644
1661
|
return true;
|
|
1645
1662
|
};
|
|
1646
|
-
|
|
1647
|
-
//#region src/walk.ts
|
|
1663
|
+
// src/walk.ts
|
|
1648
1664
|
var dirRE = /^(?:v-|:|@)/;
|
|
1649
1665
|
var modifierRE = /\.([\w-]+)/g;
|
|
1650
1666
|
var inOnce = false;
|
|
@@ -1668,15 +1684,16 @@ var addCleanup = (ctx, cleanup, node) => {
|
|
|
1668
1684
|
}
|
|
1669
1685
|
}, node);
|
|
1670
1686
|
};
|
|
1671
|
-
var
|
|
1687
|
+
var withOnce = (once, fn) => {
|
|
1672
1688
|
const previous = inOnce;
|
|
1673
1689
|
inOnce = once;
|
|
1674
1690
|
try {
|
|
1675
|
-
|
|
1691
|
+
fn();
|
|
1676
1692
|
} finally {
|
|
1677
1693
|
inOnce = previous;
|
|
1678
1694
|
}
|
|
1679
1695
|
};
|
|
1696
|
+
var walkDeferred = (node, ctx, once) => withOnce(once, () => walk(node, ctx));
|
|
1680
1697
|
var walk = (node, ctx) => {
|
|
1681
1698
|
const previousOwner = setOwner(node);
|
|
1682
1699
|
try {
|
|
@@ -1689,6 +1706,7 @@ var walkNode = (node, ctx) => {
|
|
|
1689
1706
|
const type = node.nodeType;
|
|
1690
1707
|
if (type === 1) {
|
|
1691
1708
|
const el = node;
|
|
1709
|
+
if (!el.hasAttributes()) return walkChildren(el, ctx);
|
|
1692
1710
|
if (el.hasAttribute("v-pre")) return;
|
|
1693
1711
|
if (deferScope(el, ctx, walkDeferred, inOnce)) return;
|
|
1694
1712
|
checkAttr(el, "v-cloak");
|
|
@@ -1717,7 +1735,11 @@ var walkNode = (node, ctx) => {
|
|
|
1717
1735
|
}) : {}) || {};
|
|
1718
1736
|
ctx = createScopedContext(ctx, scope);
|
|
1719
1737
|
el.__ctx = ctx;
|
|
1720
|
-
|
|
1738
|
+
const deregister = registerScope(el, ctx.scope, exp || void 0, name || void 0);
|
|
1739
|
+
addCleanup(ctx, () => {
|
|
1740
|
+
deregister();
|
|
1741
|
+
delete el.__ctx;
|
|
1742
|
+
});
|
|
1721
1743
|
if (scope.$template) resolveTemplate(el, scope.$template);
|
|
1722
1744
|
}
|
|
1723
1745
|
const wasOnce = inOnce;
|
|
@@ -1772,7 +1794,7 @@ var processDirective = (el, raw, exp, ctx) => {
|
|
|
1772
1794
|
} else {
|
|
1773
1795
|
const argIndex = raw.indexOf(":");
|
|
1774
1796
|
const dirName = argIndex > 0 ? raw.slice(2, argIndex) : raw.slice(2);
|
|
1775
|
-
dir = builtInDirectives[dirName]
|
|
1797
|
+
dir = hasOwn(builtInDirectives, dirName) ? builtInDirectives[dirName] : hasOwn(ctx.dirs, dirName) ? ctx.dirs[dirName] : void 0;
|
|
1776
1798
|
arg = argIndex > 0 ? raw.slice(argIndex + 1) : void 0;
|
|
1777
1799
|
}
|
|
1778
1800
|
if (dir) {
|
|
@@ -1781,14 +1803,7 @@ var processDirective = (el, raw, exp, ctx) => {
|
|
|
1781
1803
|
el.removeAttribute(source);
|
|
1782
1804
|
} else {
|
|
1783
1805
|
const known = [
|
|
1784
|
-
"v-
|
|
1785
|
-
"v-if",
|
|
1786
|
-
"v-for",
|
|
1787
|
-
"v-once",
|
|
1788
|
-
"v-pre",
|
|
1789
|
-
"v-cloak",
|
|
1790
|
-
"v-teleport",
|
|
1791
|
-
"v-name",
|
|
1806
|
+
...structuralDirectives.map((d) => "v-" + d),
|
|
1792
1807
|
"ref",
|
|
1793
1808
|
...Object.keys(builtInDirectives).map((d) => "v-" + d),
|
|
1794
1809
|
...Object.keys(ctx.dirs).map((d) => "v-" + d)
|
|
@@ -1812,12 +1827,15 @@ var applyDirective = (el, dir, exp, ctx, arg, modifiers, source, displayExp) =>
|
|
|
1812
1827
|
const get = (code) => {
|
|
1813
1828
|
const value = evaluate(ctx.scope, code ?? exp, el, meta);
|
|
1814
1829
|
return code && typeof value == "function" ? (...args) => {
|
|
1830
|
+
const previous = setOwner(el);
|
|
1815
1831
|
try {
|
|
1816
1832
|
const result = value(...args);
|
|
1817
1833
|
if (result instanceof Promise) result.catch(report);
|
|
1818
1834
|
return result;
|
|
1819
1835
|
} catch (err) {
|
|
1820
1836
|
report(err);
|
|
1837
|
+
} finally {
|
|
1838
|
+
setOwner(previous);
|
|
1821
1839
|
}
|
|
1822
1840
|
} : value;
|
|
1823
1841
|
};
|
|
@@ -1862,8 +1880,8 @@ var query = (sel, el, source) => {
|
|
|
1862
1880
|
var resolveTemplate = (el, template) => {
|
|
1863
1881
|
if (template[0] === "#") {
|
|
1864
1882
|
const templateEl = query(template, el, "v-scope");
|
|
1865
|
-
if (!templateEl) {
|
|
1866
|
-
if (templateEl
|
|
1883
|
+
if (!(templateEl instanceof HTMLTemplateElement)) {
|
|
1884
|
+
if (templateEl !== void 0) console.error(`template selector ${template} has no matching <template> element.`);
|
|
1867
1885
|
return;
|
|
1868
1886
|
}
|
|
1869
1887
|
el.appendChild(templateEl.content.cloneNode(true));
|
|
@@ -1871,8 +1889,7 @@ var resolveTemplate = (el, template) => {
|
|
|
1871
1889
|
}
|
|
1872
1890
|
el.innerHTML = template;
|
|
1873
1891
|
};
|
|
1874
|
-
|
|
1875
|
-
//#region src/context.ts
|
|
1892
|
+
// src/context.ts
|
|
1876
1893
|
var createContext = (parent) => {
|
|
1877
1894
|
const ctx = {
|
|
1878
1895
|
delimiters: ["{{", "}}"],
|
|
@@ -1885,15 +1902,20 @@ var createContext = (parent) => {
|
|
|
1885
1902
|
cleanups: [],
|
|
1886
1903
|
effect: (fn) => {
|
|
1887
1904
|
if (inOnce) {
|
|
1888
|
-
|
|
1889
|
-
|
|
1905
|
+
const job = () => withOnce(true, fn);
|
|
1906
|
+
queueJob(job);
|
|
1907
|
+
return job;
|
|
1890
1908
|
}
|
|
1891
|
-
const e = effect$1(fn, {
|
|
1909
|
+
const e = stampJob(effect$1(fn, {
|
|
1910
|
+
scheduler: () => queueJob(e),
|
|
1911
|
+
lazy: true
|
|
1912
|
+
}));
|
|
1892
1913
|
ctx.effects.push(e);
|
|
1893
1914
|
own(() => {
|
|
1894
1915
|
stopEffect(e);
|
|
1895
1916
|
remove(ctx.effects, e);
|
|
1896
1917
|
});
|
|
1918
|
+
e();
|
|
1897
1919
|
return e;
|
|
1898
1920
|
}
|
|
1899
1921
|
};
|
|
@@ -1924,26 +1946,17 @@ var createScopedContext = (ctx, data = {}) => {
|
|
|
1924
1946
|
};
|
|
1925
1947
|
hide(mergedScope, "$watch", createWatch(scopedCtx));
|
|
1926
1948
|
hide(mergedScope, "$id", createId());
|
|
1927
|
-
bindContextMethods(reactiveProxy);
|
|
1949
|
+
bindContextMethods(reactiveProxy, mergedScope);
|
|
1928
1950
|
return scopedCtx;
|
|
1929
1951
|
};
|
|
1930
|
-
var bindContextMethods = (scope) => {
|
|
1931
|
-
for (const key of Object.keys(
|
|
1932
|
-
const fn = Object.getOwnPropertyDescriptor(
|
|
1952
|
+
var bindContextMethods = (scope, raw = scope) => {
|
|
1953
|
+
for (const key of Object.keys(raw)) {
|
|
1954
|
+
const fn = Object.getOwnPropertyDescriptor(raw, key).value;
|
|
1933
1955
|
if (typeof fn === "function") scope[key] = fn.bind(scope);
|
|
1934
1956
|
}
|
|
1935
1957
|
};
|
|
1936
|
-
|
|
1937
|
-
//#region src/block.ts
|
|
1958
|
+
// src/block.ts
|
|
1938
1959
|
var Block = class {
|
|
1939
|
-
template;
|
|
1940
|
-
ctx;
|
|
1941
|
-
key;
|
|
1942
|
-
parentCtx;
|
|
1943
|
-
isFragment;
|
|
1944
|
-
start;
|
|
1945
|
-
end;
|
|
1946
|
-
owned = false;
|
|
1947
1960
|
get el() {
|
|
1948
1961
|
return this.start || this.template.__marker || this.template;
|
|
1949
1962
|
}
|
|
@@ -1995,10 +2008,14 @@ var Block = class {
|
|
|
1995
2008
|
while (node) {
|
|
1996
2009
|
next = node.nextSibling;
|
|
1997
2010
|
parent.removeChild(node);
|
|
2011
|
+
disposeSubtree(node);
|
|
1998
2012
|
if (node === this.end) break;
|
|
1999
2013
|
node = next;
|
|
2000
2014
|
}
|
|
2001
|
-
} else
|
|
2015
|
+
} else {
|
|
2016
|
+
parent.removeChild(this.template);
|
|
2017
|
+
disposeSubtree(this.template);
|
|
2018
|
+
}
|
|
2002
2019
|
}
|
|
2003
2020
|
this.template.__marker?.remove();
|
|
2004
2021
|
this.teardown();
|
|
@@ -2030,8 +2047,7 @@ var Block = class {
|
|
|
2030
2047
|
this.ctx.cleanups.splice(0).forEach((fn) => fn());
|
|
2031
2048
|
}
|
|
2032
2049
|
};
|
|
2033
|
-
|
|
2034
|
-
//#region src/store.ts
|
|
2050
|
+
// src/store.ts
|
|
2035
2051
|
/**
|
|
2036
2052
|
* DEV: catch `$store.typo`, which otherwise reads as `undefined` and renders a
|
|
2037
2053
|
* blank instead of raising.
|
|
@@ -2049,7 +2065,7 @@ var Block = class {
|
|
|
2049
2065
|
var registry = Object.create(null);
|
|
2050
2066
|
var target = registry;
|
|
2051
2067
|
target = new Proxy(registry, { get(obj, key, receiver) {
|
|
2052
|
-
if (typeof key === "string" && !key.startsWith("__") && !(key in obj)) setTimeout(() => {
|
|
2068
|
+
if (typeof key === "string" && !key.startsWith("__") && key !== "toJSON" && !(key in obj)) setTimeout(() => {
|
|
2053
2069
|
if (key in obj) return;
|
|
2054
2070
|
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
2071
|
});
|
|
@@ -2069,9 +2085,8 @@ var store = (name, value) => {
|
|
|
2069
2085
|
}
|
|
2070
2086
|
return stores[name];
|
|
2071
2087
|
};
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
var mountedRoots = /* @__PURE__ */ new WeakSet();
|
|
2088
|
+
// src/app.ts
|
|
2089
|
+
var mountedRoots = /* @__PURE__ */ new WeakMap();
|
|
2075
2090
|
var escapeRegex = (str) => str.replace(/[-.*+?^${}()|[\]/\\]/g, "\\$&");
|
|
2076
2091
|
var createApp = (initialData) => {
|
|
2077
2092
|
const ctx = createContext();
|
|
@@ -2087,12 +2102,12 @@ var createApp = (initialData) => {
|
|
|
2087
2102
|
ctx.delimitersRE = new RegExp(escapeRegex(open) + "([^]+?)" + escapeRegex(close), "g");
|
|
2088
2103
|
}
|
|
2089
2104
|
}
|
|
2090
|
-
ctx.scope
|
|
2091
|
-
ctx.scope
|
|
2092
|
-
ctx.scope
|
|
2093
|
-
ctx.scope
|
|
2094
|
-
ctx.scope
|
|
2095
|
-
ctx.scope
|
|
2105
|
+
hide(ctx.scope, "$s", toDisplayString);
|
|
2106
|
+
hide(ctx.scope, "$nextTick", nextTick);
|
|
2107
|
+
hide(ctx.scope, "$refs", Object.create(null));
|
|
2108
|
+
hide(ctx.scope, "$store", stores);
|
|
2109
|
+
hide(ctx.scope, "$watch", createWatch(ctx));
|
|
2110
|
+
hide(ctx.scope, "$id", createId());
|
|
2096
2111
|
Object.defineProperty(ctx.scope, "$root", {
|
|
2097
2112
|
value: ctx.scope,
|
|
2098
2113
|
enumerable: false
|
|
@@ -2109,6 +2124,7 @@ var createApp = (initialData) => {
|
|
|
2109
2124
|
},
|
|
2110
2125
|
directive(name, def) {
|
|
2111
2126
|
if (def) {
|
|
2127
|
+
if (isBuiltInDirective(name)) warn(`app.directive("${name}") registered a directive that never runs: v-${name} is built in, and LiteVue always uses its own ahead of a registered one. Register it under another name.`);
|
|
2112
2128
|
ctx.dirs[name] = def;
|
|
2113
2129
|
return this;
|
|
2114
2130
|
} else return ctx.dirs[name];
|
|
@@ -2170,13 +2186,15 @@ var createApp = (initialData) => {
|
|
|
2170
2186
|
ctx.walk ??= walk;
|
|
2171
2187
|
ctx.dispose ??= disposeSubtree;
|
|
2172
2188
|
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);
|
|
2189
|
+
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
2190
|
const name = el.getAttribute("v-name");
|
|
2176
2191
|
const block = new Block(el, ctx, true);
|
|
2192
|
+
mountedRoots.set(el, el.firstChild);
|
|
2177
2193
|
el.__ctx ??= block.ctx;
|
|
2178
2194
|
if (!devtools.scopes.has(el) && !el.matches(SCOPE_SELECTOR)) block.ctx.cleanups.push(registerScope(el, block.ctx.scope, void 0, name || void 0));
|
|
2179
2195
|
rootBlocks.push(block);
|
|
2196
|
+
own(() => remove(rootBlocks, block), el);
|
|
2197
|
+
block.ctx.cleanups.push(() => delete el.__ctx);
|
|
2180
2198
|
}
|
|
2181
2199
|
return this;
|
|
2182
2200
|
},
|
|
@@ -2223,8 +2241,7 @@ var createApp = (initialData) => {
|
|
|
2223
2241
|
};
|
|
2224
2242
|
return app;
|
|
2225
2243
|
};
|
|
2226
|
-
|
|
2227
|
-
//#region src/effect.ts
|
|
2244
|
+
// src/effect.ts
|
|
2228
2245
|
/**
|
|
2229
2246
|
* Runs `fn` now, then again when the reactive state it read changes. The
|
|
2230
2247
|
* JS-side counterpart to `v-effect`, for work not tied to an element.
|
|
@@ -2236,13 +2253,20 @@ var createApp = (initialData) => {
|
|
|
2236
2253
|
* Returns a stop function. Nothing stops it automatically.
|
|
2237
2254
|
*/
|
|
2238
2255
|
var watchEffect = (fn) => {
|
|
2239
|
-
|
|
2240
|
-
|
|
2256
|
+
const runner = effect$1(fn, {
|
|
2257
|
+
scheduler: () => queueJob(runner),
|
|
2258
|
+
lazy: true
|
|
2259
|
+
});
|
|
2260
|
+
runner.i = Infinity;
|
|
2261
|
+
try {
|
|
2262
|
+
runner();
|
|
2263
|
+
} catch (e) {
|
|
2264
|
+
stopEffect(runner);
|
|
2265
|
+
throw e;
|
|
2266
|
+
}
|
|
2241
2267
|
return () => stopEffect(runner);
|
|
2242
2268
|
};
|
|
2243
|
-
|
|
2244
|
-
//#region src/index.ts
|
|
2269
|
+
// src/index.ts
|
|
2245
2270
|
var s = document.currentScript;
|
|
2246
2271
|
if (s && s.hasAttribute("init")) createApp().mount();
|
|
2247
|
-
//#endregion
|
|
2248
2272
|
export { computed, createApp, devtools, disableDevtools, nextTick, reactive, store, watchEffect };
|