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