@aevantec/litevue 0.5.15 → 0.5.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/litevue-plugins.dev.iife.js +34 -30
- package/dist/litevue-plugins.dev.mjs +34 -30
- 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 +266 -241
- package/dist/litevue.dev.mjs +266 -241
- 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 +9 -5
- package/dist/plugins/morph.dev.mjs +9 -5
- 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 +2 -2
- package/dist/types/block.d.ts +2 -2
- package/dist/types/context.d.mts +7 -1
- package/dist/types/context.d.ts +7 -1
- package/dist/types/directives/bind.d.mts +1 -0
- package/dist/types/directives/bind.d.ts +1 -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/errors.d.mts +1 -1
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/ownership.d.mts +2 -0
- package/dist/types/ownership.d.ts +2 -0
- package/dist/types/scheduler.d.mts +9 -1
- package/dist/types/scheduler.d.ts +9 -1
- package/dist/types/walk.d.mts +1 -0
- package/dist/types/walk.d.ts +1 -0
- package/package.json +2 -2
package/dist/litevue.dev.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// node_modules/.pnpm/@vue+shared@3.4.38/node_modules/@vue/shared/dist/shared.esm-bundler.js
|
|
2
2
|
/**
|
|
3
3
|
* @vue/shared v3.4.38
|
|
4
4
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
@@ -21,7 +21,6 @@ var remove = (arr, el) => {
|
|
|
21
21
|
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
22
22
|
var hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
|
|
23
23
|
var isArray = Array.isArray;
|
|
24
|
-
var isMap = (val) => toTypeString(val) === "[object Map]";
|
|
25
24
|
var isDate = (val) => toTypeString(val) === "[object Date]";
|
|
26
25
|
var isFunction = (val) => typeof val === "function";
|
|
27
26
|
var isString = (val) => typeof val === "string";
|
|
@@ -41,14 +40,14 @@ var cacheStringFunction = (fn) => {
|
|
|
41
40
|
};
|
|
42
41
|
};
|
|
43
42
|
var camelizeRE = /-(\w)/g;
|
|
44
|
-
var camelize = cacheStringFunction((str) => {
|
|
43
|
+
var camelize = /* @__PURE__ */ cacheStringFunction((str) => {
|
|
45
44
|
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
|
46
45
|
});
|
|
47
46
|
var hyphenateRE = /\B([A-Z])/g;
|
|
48
|
-
var hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
|
|
47
|
+
var hyphenate = /* @__PURE__ */ cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
|
|
49
48
|
var hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
50
|
-
var
|
|
51
|
-
const n =
|
|
49
|
+
var looseToNumber = (val) => {
|
|
50
|
+
const n = parseFloat(val);
|
|
52
51
|
return isNaN(n) ? val : n;
|
|
53
52
|
};
|
|
54
53
|
function normalizeStyle(value) {
|
|
@@ -120,8 +119,7 @@ function looseEqual(a, b) {
|
|
|
120
119
|
function looseIndexOf(arr, val) {
|
|
121
120
|
return arr.findIndex((item) => looseEqual(item, val));
|
|
122
121
|
}
|
|
123
|
-
|
|
124
|
-
//#region node_modules/.pnpm/@vue+reactivity@3.4.38/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
|
|
122
|
+
// node_modules/.pnpm/@vue+reactivity@3.4.38/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
|
|
125
123
|
/**
|
|
126
124
|
* @vue/reactivity v3.4.38
|
|
127
125
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
@@ -306,7 +304,6 @@ var createDep = (cleanup, computed) => {
|
|
|
306
304
|
};
|
|
307
305
|
var targetMap = /* @__PURE__ */ new WeakMap();
|
|
308
306
|
var ITERATE_KEY = Symbol("iterate");
|
|
309
|
-
var MAP_KEY_ITERATE_KEY = Symbol("Map key iterate");
|
|
310
307
|
function track(target, type, key) {
|
|
311
308
|
if (shouldTrack && activeEffect) {
|
|
312
309
|
let depsMap = targetMap.get(target);
|
|
@@ -324,8 +321,7 @@ function trigger$1(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
324
321
|
const depsMap = targetMap.get(target);
|
|
325
322
|
if (!depsMap) return;
|
|
326
323
|
let deps = [];
|
|
327
|
-
if (
|
|
328
|
-
else if (key === "length" && isArray(target)) {
|
|
324
|
+
if (key === "length" && isArray(target)) {
|
|
329
325
|
const newLength = Number(newValue);
|
|
330
326
|
depsMap.forEach((dep, key2) => {
|
|
331
327
|
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) deps.push(dep);
|
|
@@ -334,18 +330,10 @@ function trigger$1(target, type, key, newValue, oldValue, oldTarget) {
|
|
|
334
330
|
if (key !== void 0) deps.push(depsMap.get(key));
|
|
335
331
|
switch (type) {
|
|
336
332
|
case "add":
|
|
337
|
-
if (!isArray(target))
|
|
338
|
-
|
|
339
|
-
if (isMap(target)) deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
340
|
-
} else if (isIntegerKey(key)) deps.push(depsMap.get("length"));
|
|
333
|
+
if (!isArray(target)) deps.push(depsMap.get(ITERATE_KEY));
|
|
334
|
+
else if (isIntegerKey(key)) deps.push(depsMap.get("length"));
|
|
341
335
|
break;
|
|
342
|
-
case "delete":
|
|
343
|
-
if (!isArray(target)) {
|
|
344
|
-
deps.push(depsMap.get(ITERATE_KEY));
|
|
345
|
-
if (isMap(target)) deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
346
|
-
}
|
|
347
|
-
break;
|
|
348
|
-
case "set": if (isMap(target)) deps.push(depsMap.get(ITERATE_KEY));
|
|
336
|
+
case "delete": if (!isArray(target)) deps.push(depsMap.get(ITERATE_KEY));
|
|
349
337
|
}
|
|
350
338
|
}
|
|
351
339
|
pauseScheduling();
|
|
@@ -562,12 +550,6 @@ getter: `, this.getter);
|
|
|
562
550
|
set value(newValue) {
|
|
563
551
|
this._setter(newValue);
|
|
564
552
|
}
|
|
565
|
-
get _dirty() {
|
|
566
|
-
return this.effect.dirty;
|
|
567
|
-
}
|
|
568
|
-
set _dirty(v) {
|
|
569
|
-
this.effect.dirty = v;
|
|
570
|
-
}
|
|
571
553
|
};
|
|
572
554
|
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
573
555
|
let getter;
|
|
@@ -614,8 +596,7 @@ function triggerRefValue(ref2, dirtyLevel = 4, newVal, oldVal) {
|
|
|
614
596
|
function isRef(r) {
|
|
615
597
|
return !!(r && r.__v_isRef === true);
|
|
616
598
|
}
|
|
617
|
-
|
|
618
|
-
//#region src/devtools.ts
|
|
599
|
+
// src/devtools.ts
|
|
619
600
|
var scopes = /* @__PURE__ */ new Map();
|
|
620
601
|
var exps = /* @__PURE__ */ new Map();
|
|
621
602
|
var names = /* @__PURE__ */ new Map();
|
|
@@ -634,9 +615,8 @@ var listeners = {
|
|
|
634
615
|
var emit = (event, ...args) => {
|
|
635
616
|
listeners[event].forEach((fn) => fn(...args));
|
|
636
617
|
};
|
|
637
|
-
var noop = () => {};
|
|
638
618
|
var registerScope = (el, scope, exp, name) => {
|
|
639
|
-
if (isDisabled()) return
|
|
619
|
+
if (isDisabled()) return NOOP;
|
|
640
620
|
scopes.set(el, scope);
|
|
641
621
|
if (exp) exps.set(el, exp);
|
|
642
622
|
if (name) names.set(el, name);
|
|
@@ -716,8 +696,7 @@ var disableDevtools = () => {
|
|
|
716
696
|
if (typeof window !== "undefined" && window.__LITE_VUE__ === devtools) delete window.__LITE_VUE__;
|
|
717
697
|
};
|
|
718
698
|
if (typeof window !== "undefined" && !isDisabled()) window.__LITE_VUE__ = devtools;
|
|
719
|
-
|
|
720
|
-
//#region src/errors.ts
|
|
699
|
+
// src/errors.ts
|
|
721
700
|
/** Levenshtein, bounded — only used to rank candidate names in DEV. */
|
|
722
701
|
var distance = (a, b) => {
|
|
723
702
|
const m = a.length;
|
|
@@ -787,7 +766,7 @@ var PHASES = {
|
|
|
787
766
|
teardown: "tearing down"
|
|
788
767
|
};
|
|
789
768
|
var handleError = (err, info) => {
|
|
790
|
-
for (const fn of handlers) try {
|
|
769
|
+
for (const fn of [...handlers]) try {
|
|
791
770
|
fn(err, info);
|
|
792
771
|
} catch (inner) {
|
|
793
772
|
console.error("[litevue] an onError handler itself threw:", inner);
|
|
@@ -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,9 +891,10 @@ 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;
|
|
897
|
+
if (!arg) el.__bound = prevValue;
|
|
913
898
|
});
|
|
914
899
|
};
|
|
915
900
|
var setProp = (el, key, value, prevValue) => {
|
|
@@ -920,6 +905,10 @@ var setProp = (el, key, value, prevValue) => {
|
|
|
920
905
|
const prev = toStyle(prevValue);
|
|
921
906
|
for (const key in next) setStyle(style, key, next[key]);
|
|
922
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
|
+
}
|
|
923
912
|
if (!style.cssText) el.removeAttribute("style");
|
|
924
913
|
} else if (!(el instanceof SVGElement) && key in el && !forceAttrRE.test(key)) {
|
|
925
914
|
el[key] = value == null && typeof el[key] == "string" ? "" : value;
|
|
@@ -927,8 +916,11 @@ var setProp = (el, key, value, prevValue) => {
|
|
|
927
916
|
if (key === "value") el._value = value;
|
|
928
917
|
} else if (key === "true-value") el._trueValue = value;
|
|
929
918
|
else if (key === "false-value") el._falseValue = value;
|
|
930
|
-
else
|
|
931
|
-
|
|
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
|
+
}
|
|
932
924
|
};
|
|
933
925
|
var toStyle = (value) => isString(value = normalizeStyle(value)) ? parseStringStyle(value) : value || {};
|
|
934
926
|
var importantRE = /\s*!important$/;
|
|
@@ -938,8 +930,7 @@ var setStyle = (style, name, val) => {
|
|
|
938
930
|
else if (importantRE.test(val)) style.setProperty(hyphenate(name), val.replace(importantRE, ""), "important");
|
|
939
931
|
else style[name] = val;
|
|
940
932
|
};
|
|
941
|
-
|
|
942
|
-
//#region src/warn.ts
|
|
933
|
+
// src/warn.ts
|
|
943
934
|
/**
|
|
944
935
|
* Development warnings.
|
|
945
936
|
*
|
|
@@ -961,16 +952,62 @@ var warnOnce = (key, msg) => {
|
|
|
961
952
|
seen.add(key);
|
|
962
953
|
warn(msg);
|
|
963
954
|
};
|
|
964
|
-
|
|
965
|
-
|
|
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
|
|
966
998
|
/**
|
|
967
999
|
* Can `exp` stand as a single expression, or is it a statement list?
|
|
968
1000
|
* Memoised: it compiles a throwaway function, which a `v-for` pays per row.
|
|
969
1001
|
*/
|
|
970
1002
|
var expressionCache = Object.create(null);
|
|
1003
|
+
var cachedExpressions = 0;
|
|
971
1004
|
var isExpression = (exp) => {
|
|
972
1005
|
const hit = expressionCache[exp];
|
|
973
1006
|
if (hit !== void 0) return hit;
|
|
1007
|
+
if (++cachedExpressions > 1e3) {
|
|
1008
|
+
expressionCache = Object.create(null);
|
|
1009
|
+
cachedExpressions = 1;
|
|
1010
|
+
}
|
|
974
1011
|
try {
|
|
975
1012
|
new Function(`return (${exp})`);
|
|
976
1013
|
return expressionCache[exp] = true;
|
|
@@ -978,6 +1015,7 @@ var isExpression = (exp) => {
|
|
|
978
1015
|
return expressionCache[exp] = false;
|
|
979
1016
|
}
|
|
980
1017
|
};
|
|
1018
|
+
var fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$]+)\s*=>|^\s*(async\s+)?function\b/;
|
|
981
1019
|
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
|
|
982
1020
|
var systemModifiers = [
|
|
983
1021
|
"ctrl",
|
|
@@ -1008,31 +1046,13 @@ var keyAliases = {
|
|
|
1008
1046
|
delete: "backspace"
|
|
1009
1047
|
};
|
|
1010
1048
|
var nonKeyModifierRE = /^(stop|prevent|self|ctrl|shift|alt|meta|left|middle|right|exact|once|capture|passive|window|document|outside|debounce(-\d+)?|throttle(-\d+)?|prop-.+|name-.+)$/;
|
|
1011
|
-
var on = ({ el, get,
|
|
1049
|
+
var on = ({ el, get, exp, arg, modifiers }) => {
|
|
1012
1050
|
if (!arg) {
|
|
1013
1051
|
console.error(`v-on="obj" syntax is not supported in LiteVue.`);
|
|
1014
1052
|
return;
|
|
1015
1053
|
}
|
|
1016
1054
|
const a = /\bawait\b/.test(exp) ? "async " : "";
|
|
1017
|
-
|
|
1018
|
-
let handler = (...args) => {
|
|
1019
|
-
try {
|
|
1020
|
-
const result = raw(...args);
|
|
1021
|
-
if (result instanceof Promise) result.catch(fail);
|
|
1022
|
-
return result;
|
|
1023
|
-
} catch (e) {
|
|
1024
|
-
fail(e);
|
|
1025
|
-
}
|
|
1026
|
-
};
|
|
1027
|
-
function fail(e) {
|
|
1028
|
-
handleError(e, {
|
|
1029
|
-
phase: "handler",
|
|
1030
|
-
source: `@${arg}`,
|
|
1031
|
-
expression: exp,
|
|
1032
|
-
el,
|
|
1033
|
-
scope: ctx.scope
|
|
1034
|
-
});
|
|
1035
|
-
}
|
|
1055
|
+
let handler = simplePathRE.test(exp) || fnExpRE.test(exp) ? get(`(e => (${exp})(e))`) : isExpression(exp) ? get(`(${a}$event => (${exp}))`) : get(`(${a}$event => { ${exp} })`);
|
|
1036
1056
|
if (arg === "vue:mounted" || arg === "vue:unmounted") console.warn(`@${arg} is deprecated in LiteVue - use @${arg.slice(4)} instead.`);
|
|
1037
1057
|
if (arg === "mounted" || arg === "vue:mounted") {
|
|
1038
1058
|
let live = true;
|
|
@@ -1093,42 +1113,43 @@ var on = ({ el, get, ctx, exp, arg, modifiers }) => {
|
|
|
1093
1113
|
if (key.startsWith("prop-") && "propertyName" in e && e.propertyName !== key.slice(5)) return;
|
|
1094
1114
|
if (key.startsWith("name-") && "animationName" in e && e.animationName !== key.slice(5)) return;
|
|
1095
1115
|
}
|
|
1116
|
+
if (modifiers.once) target.removeEventListener(event, handler, modifiers);
|
|
1096
1117
|
return invoke(e);
|
|
1097
1118
|
};
|
|
1098
1119
|
}
|
|
1099
1120
|
const target = modifiers?.window ? window : modifiers?.document || modifiers?.outside ? document : el;
|
|
1100
1121
|
const event = arg;
|
|
1101
|
-
target.addEventListener(event, handler,
|
|
1122
|
+
target.addEventListener(event, handler, {
|
|
1123
|
+
...modifiers,
|
|
1124
|
+
once: false
|
|
1125
|
+
});
|
|
1102
1126
|
return () => {
|
|
1103
1127
|
clearTimeout(debounceTimer);
|
|
1104
1128
|
target.removeEventListener(event, handler, modifiers);
|
|
1105
1129
|
};
|
|
1106
1130
|
};
|
|
1107
|
-
|
|
1108
|
-
//#region src/directives/show.ts
|
|
1131
|
+
// src/directives/show.ts
|
|
1109
1132
|
var show = ({ el, get, effect }) => {
|
|
1110
|
-
|
|
1133
|
+
el._vod = el.style.display == "none" ? "" : el.style.display;
|
|
1111
1134
|
effect(() => {
|
|
1112
|
-
el.
|
|
1135
|
+
el._vsh = !get();
|
|
1136
|
+
el.style.display = el._vsh ? "none" : el._vod;
|
|
1113
1137
|
});
|
|
1114
1138
|
};
|
|
1115
|
-
|
|
1116
|
-
//#region src/directives/text.ts
|
|
1139
|
+
// src/directives/text.ts
|
|
1117
1140
|
var text = ({ el, get, effect }) => {
|
|
1118
1141
|
effect(() => {
|
|
1119
1142
|
el.textContent = toDisplayString(get());
|
|
1120
1143
|
});
|
|
1121
1144
|
};
|
|
1122
1145
|
var toDisplayString = (value) => value == null ? "" : isObject(value) ? JSON.stringify(value, null, 2) : String(value);
|
|
1123
|
-
|
|
1124
|
-
//#region src/directives/html.ts
|
|
1146
|
+
// src/directives/html.ts
|
|
1125
1147
|
var html = ({ el, get, effect }) => {
|
|
1126
1148
|
effect(() => {
|
|
1127
1149
|
el.innerHTML = get() ?? "";
|
|
1128
1150
|
});
|
|
1129
1151
|
};
|
|
1130
|
-
|
|
1131
|
-
//#region src/utils.ts
|
|
1152
|
+
// src/utils.ts
|
|
1132
1153
|
var checkAttr = (el, name) => {
|
|
1133
1154
|
const val = el.getAttribute(name);
|
|
1134
1155
|
if (val != null) el.removeAttribute(name);
|
|
@@ -1143,21 +1164,24 @@ var listen = (el, event, handler, options) => {
|
|
|
1143
1164
|
el.addEventListener(event, handler, options);
|
|
1144
1165
|
return () => el.removeEventListener(event, handler, options);
|
|
1145
1166
|
};
|
|
1146
|
-
|
|
1147
|
-
//#region src/directives/model.ts
|
|
1167
|
+
// src/directives/model.ts
|
|
1148
1168
|
var model = ({ el, exp, get, effect, modifiers }) => {
|
|
1149
1169
|
const type = el.type;
|
|
1150
1170
|
const assign = get(`(val) => { ${exp} = val }`);
|
|
1151
1171
|
const { trim, number = type === "number", lazy, fill } = modifiers || {};
|
|
1172
|
+
const cast = (val) => number ? looseToNumber(val) : val;
|
|
1152
1173
|
const off = [];
|
|
1153
1174
|
const on = (event, handler) => off.push(listen(el, event, handler));
|
|
1175
|
+
let update;
|
|
1176
|
+
let render;
|
|
1177
|
+
let isText = false;
|
|
1154
1178
|
if (el.tagName === "SELECT") {
|
|
1155
1179
|
const sel = el;
|
|
1156
|
-
on("change", () => {
|
|
1157
|
-
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)));
|
|
1158
1182
|
assign(sel.multiple ? selectedVal : selectedVal[0]);
|
|
1159
1183
|
});
|
|
1160
|
-
|
|
1184
|
+
render = () => {
|
|
1161
1185
|
const value = get();
|
|
1162
1186
|
const isMultiple = sel.multiple;
|
|
1163
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.`);
|
|
@@ -1171,9 +1195,9 @@ var model = ({ el, exp, get, effect, modifiers }) => {
|
|
|
1171
1195
|
}
|
|
1172
1196
|
}
|
|
1173
1197
|
if (!isMultiple && sel.selectedIndex !== -1) sel.selectedIndex = -1;
|
|
1174
|
-
}
|
|
1198
|
+
};
|
|
1175
1199
|
} else if (type === "checkbox") {
|
|
1176
|
-
on("change", () => {
|
|
1200
|
+
on("change", update = () => {
|
|
1177
1201
|
const modelValue = get();
|
|
1178
1202
|
const checked = el.checked;
|
|
1179
1203
|
if (isArray(modelValue)) {
|
|
@@ -1188,23 +1212,20 @@ var model = ({ el, exp, get, effect, modifiers }) => {
|
|
|
1188
1212
|
}
|
|
1189
1213
|
} else assign(getCheckboxValue(el, checked));
|
|
1190
1214
|
});
|
|
1191
|
-
|
|
1215
|
+
render = () => {
|
|
1192
1216
|
const value = get();
|
|
1193
1217
|
if (isArray(value)) el.checked = looseIndexOf(value, getValue(el)) > -1;
|
|
1194
1218
|
else el.checked = looseEqual(value, getCheckboxValue(el, true));
|
|
1195
|
-
}
|
|
1219
|
+
};
|
|
1196
1220
|
} else if (type === "radio") {
|
|
1197
|
-
on("change", () =>
|
|
1198
|
-
|
|
1199
|
-
});
|
|
1200
|
-
effect(() => {
|
|
1221
|
+
on("change", update = () => assign(getValue(el)));
|
|
1222
|
+
render = () => {
|
|
1201
1223
|
el.checked = looseEqual(get(), getValue(el));
|
|
1202
|
-
});
|
|
1203
|
-
} else {
|
|
1204
|
-
const resolveValue = (val) => {
|
|
1205
|
-
if (trim) val = val.trim();
|
|
1206
|
-
return number ? toNumber(val) : val;
|
|
1207
1224
|
};
|
|
1225
|
+
} else {
|
|
1226
|
+
isText = true;
|
|
1227
|
+
const resolveValue = (val) => cast(trim ? val.trim() : val);
|
|
1228
|
+
update = () => assign(resolveValue(el.value));
|
|
1208
1229
|
let write = assign;
|
|
1209
1230
|
let debounceTimer;
|
|
1210
1231
|
for (const key in modifiers || {}) {
|
|
@@ -1227,17 +1248,27 @@ var model = ({ el, exp, get, effect, modifiers }) => {
|
|
|
1227
1248
|
if (trim) on("change", () => {
|
|
1228
1249
|
el.value = el.value.trim();
|
|
1229
1250
|
});
|
|
1230
|
-
|
|
1231
|
-
const cur = get();
|
|
1232
|
-
if ((cur == null || cur === "") && el.value) assign(resolveValue(el.value));
|
|
1233
|
-
}
|
|
1234
|
-
effect(() => {
|
|
1251
|
+
render = () => {
|
|
1235
1252
|
if (el.composing) return;
|
|
1236
1253
|
const curVal = el.value;
|
|
1237
1254
|
const newVal = get() ?? "";
|
|
1238
1255
|
if (document.activeElement === el && resolveValue(curVal) === newVal) return;
|
|
1239
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
|
|
1240
1270
|
});
|
|
1271
|
+
off.push(() => observer.disconnect());
|
|
1241
1272
|
}
|
|
1242
1273
|
return () => off.forEach((remove) => remove());
|
|
1243
1274
|
};
|
|
@@ -1262,50 +1293,7 @@ var trigger = (el, type) => {
|
|
|
1262
1293
|
cancelable: true
|
|
1263
1294
|
}));
|
|
1264
1295
|
};
|
|
1265
|
-
|
|
1266
|
-
var cached = 0;
|
|
1267
|
-
var mkDispatch = (el) => (event, detail) => el.dispatchEvent(new CustomEvent(event, {
|
|
1268
|
-
detail,
|
|
1269
|
-
bubbles: true
|
|
1270
|
-
}));
|
|
1271
|
-
var unwrap = (exp) => exp.replace(/^return\(([^]*)\)$/, "$1");
|
|
1272
|
-
var evaluate = (scope, exp, el, meta) => execute(scope, `return(${exp})`, el, meta);
|
|
1273
|
-
var execute = (scope, exp, el, meta) => {
|
|
1274
|
-
let fn = evalCache[exp];
|
|
1275
|
-
if (!fn) {
|
|
1276
|
-
if (++cached > 1e3) {
|
|
1277
|
-
evalCache = Object.create(null);
|
|
1278
|
-
cached = 1;
|
|
1279
|
-
}
|
|
1280
|
-
fn = evalCache[exp] = toFunction(exp, el, meta);
|
|
1281
|
-
}
|
|
1282
|
-
try {
|
|
1283
|
-
return fn(scope, el, el && mkDispatch(el));
|
|
1284
|
-
} catch (e) {
|
|
1285
|
-
handleError(e, {
|
|
1286
|
-
phase: "expression",
|
|
1287
|
-
expression: meta?.expression ?? unwrap(exp),
|
|
1288
|
-
source: meta?.source,
|
|
1289
|
-
el: meta?.el ?? el,
|
|
1290
|
-
scope
|
|
1291
|
-
});
|
|
1292
|
-
}
|
|
1293
|
-
};
|
|
1294
|
-
var toFunction = (exp, el, meta) => {
|
|
1295
|
-
try {
|
|
1296
|
-
return new Function(`$data`, `$el`, `$dispatch`, `with($data){${exp}}`);
|
|
1297
|
-
} catch (e) {
|
|
1298
|
-
handleError(e, {
|
|
1299
|
-
phase: "compile",
|
|
1300
|
-
expression: meta?.expression ?? unwrap(exp),
|
|
1301
|
-
source: meta?.source,
|
|
1302
|
-
el: meta?.el ?? el
|
|
1303
|
-
});
|
|
1304
|
-
return () => {};
|
|
1305
|
-
}
|
|
1306
|
-
};
|
|
1307
|
-
//#endregion
|
|
1308
|
-
//#region src/ownership.ts
|
|
1296
|
+
// src/ownership.ts
|
|
1309
1297
|
var owned = /* @__PURE__ */ new WeakMap();
|
|
1310
1298
|
/**
|
|
1311
1299
|
* The node currently being walked. A module-level cursor suffices because the
|
|
@@ -1330,6 +1318,8 @@ var own = (dispose, node = owner) => {
|
|
|
1330
1318
|
if (list) list.push(dispose);
|
|
1331
1319
|
else owned.set(node, [dispose]);
|
|
1332
1320
|
};
|
|
1321
|
+
/** Withdraws a disposer from `node`, for an owner that removes it itself. */
|
|
1322
|
+
var disown = (dispose, node) => remove(owned.get(node) || [], dispose);
|
|
1333
1323
|
/**
|
|
1334
1324
|
* Disposes `node` and its subtree. Safe on an unowned node, and idempotent —
|
|
1335
1325
|
* the record is dropped as it runs.
|
|
@@ -1347,18 +1337,18 @@ var disposeSubtree = (node) => {
|
|
|
1347
1337
|
child = next;
|
|
1348
1338
|
}
|
|
1349
1339
|
};
|
|
1350
|
-
|
|
1351
|
-
//#region src/directives/effect.ts
|
|
1340
|
+
// src/directives/effect.ts
|
|
1352
1341
|
var effect = ({ el, ctx, exp, effect }) => {
|
|
1353
1342
|
let live = true;
|
|
1343
|
+
const once = inOnce;
|
|
1354
1344
|
nextTick(() => {
|
|
1355
1345
|
if (!live) return;
|
|
1356
1346
|
const previous = setOwner(el);
|
|
1357
1347
|
try {
|
|
1358
|
-
effect(() => execute(ctx.scope, exp, el, {
|
|
1348
|
+
withOnce(once, () => effect(() => execute(ctx.scope, exp, el, {
|
|
1359
1349
|
source: "v-effect",
|
|
1360
1350
|
el
|
|
1361
|
-
}));
|
|
1351
|
+
})));
|
|
1362
1352
|
} finally {
|
|
1363
1353
|
setOwner(previous);
|
|
1364
1354
|
}
|
|
@@ -1367,8 +1357,7 @@ var effect = ({ el, ctx, exp, effect }) => {
|
|
|
1367
1357
|
live = false;
|
|
1368
1358
|
};
|
|
1369
1359
|
};
|
|
1370
|
-
|
|
1371
|
-
//#region src/directives/index.ts
|
|
1360
|
+
// src/directives/index.ts
|
|
1372
1361
|
var builtInDirectives = {
|
|
1373
1362
|
bind,
|
|
1374
1363
|
on,
|
|
@@ -1378,8 +1367,7 @@ var builtInDirectives = {
|
|
|
1378
1367
|
model,
|
|
1379
1368
|
effect
|
|
1380
1369
|
};
|
|
1381
|
-
|
|
1382
|
-
//#region src/directives/if.ts
|
|
1370
|
+
// src/directives/if.ts
|
|
1383
1371
|
var _if = (el, exp, ctx) => {
|
|
1384
1372
|
if (!exp.trim()) console.warn(`v-if expression cannot be empty.`);
|
|
1385
1373
|
const anchor = new Comment("v-if");
|
|
@@ -1392,10 +1380,11 @@ var _if = (el, exp, ctx) => {
|
|
|
1392
1380
|
let elseExp;
|
|
1393
1381
|
while (elseEl = el.nextElementSibling) {
|
|
1394
1382
|
elseExp = null;
|
|
1395
|
-
if (checkAttr(elseEl, "v-else") === "" || (elseExp = checkAttr(elseEl, "v-else-if"))) {
|
|
1383
|
+
if (checkAttr(elseEl, "v-else") === "" || (elseExp = checkAttr(elseEl, "v-else-if")) != null) {
|
|
1384
|
+
if (elseExp?.trim() === "") console.warn(`v-else-if expression cannot be empty.`);
|
|
1396
1385
|
elseEl.remove();
|
|
1397
1386
|
branches.push({
|
|
1398
|
-
exp: elseExp,
|
|
1387
|
+
exp: elseExp == null ? elseExp : elseExp.trim() || "0",
|
|
1399
1388
|
el: elseEl
|
|
1400
1389
|
});
|
|
1401
1390
|
} else break;
|
|
@@ -1408,6 +1397,7 @@ var _if = (el, exp, ctx) => {
|
|
|
1408
1397
|
const removeActiveBlock = () => {
|
|
1409
1398
|
if (block) {
|
|
1410
1399
|
if (!anchor.parentNode) block.el.before(anchor);
|
|
1400
|
+
disown(stopBranches, block.el);
|
|
1411
1401
|
block.remove();
|
|
1412
1402
|
block = void 0;
|
|
1413
1403
|
}
|
|
@@ -1439,8 +1429,7 @@ var _if = (el, exp, ctx) => {
|
|
|
1439
1429
|
own(stopBranches, anchor);
|
|
1440
1430
|
return nextNode;
|
|
1441
1431
|
};
|
|
1442
|
-
|
|
1443
|
-
//#region src/directives/for.ts
|
|
1432
|
+
// src/directives/for.ts
|
|
1444
1433
|
var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
|
1445
1434
|
var forIteratorRE = /,([^,}\]]*)(?:,([^,}\]]*))?$/;
|
|
1446
1435
|
var stripParensRE = /^\(|\)$/g;
|
|
@@ -1495,7 +1484,7 @@ var _for = (el, exp, ctx) => {
|
|
|
1495
1484
|
};
|
|
1496
1485
|
const createRow = (map, value, index, objKey) => {
|
|
1497
1486
|
const data = {};
|
|
1498
|
-
if (destructureBindings) destructureBindings.forEach((b, i) => data[b] = value[isArrayDestructure ? i : b]);
|
|
1487
|
+
if (destructureBindings) destructureBindings.forEach((b, i) => data[b] = value?.[isArrayDestructure ? i : b]);
|
|
1499
1488
|
else data[valueExp] = value;
|
|
1500
1489
|
if (objKey) {
|
|
1501
1490
|
indexExp && (data[indexExp] = objKey);
|
|
@@ -1533,7 +1522,7 @@ var _for = (el, exp, ctx) => {
|
|
|
1533
1522
|
counts.set(row.key, n);
|
|
1534
1523
|
if (n > 1 && dup === void 0) dup = row.key;
|
|
1535
1524
|
}
|
|
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,
|
|
1525
|
+
warnOnce(`for-dup-key:${exp}`, `v-for="${exp}" produced a duplicate :key ${JSON.stringify(dup)}. Keys must be unique among siblings — with a repeat, the earlier item is rebuilt on every update, losing its element and scope state. Key by something stable and unique, such as a record id.`);
|
|
1537
1526
|
}
|
|
1538
1527
|
if (!keyExp && isArray(source)) {
|
|
1539
1528
|
const items = [...source];
|
|
@@ -1549,35 +1538,33 @@ var _for = (el, exp, ctx) => {
|
|
|
1549
1538
|
blocks = rows.map((row) => mountBlock(row, anchor));
|
|
1550
1539
|
mounted = true;
|
|
1551
1540
|
} else {
|
|
1552
|
-
for (let i = 0; i < blocks.length; i++)
|
|
1541
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
1542
|
+
const key = blocks[i].key;
|
|
1543
|
+
if (!keyToIndexMap.has(key) || prevKeyToIndexMap.get(key) !== i) blocks[i].remove();
|
|
1544
|
+
}
|
|
1553
1545
|
const nextBlocks = [];
|
|
1554
1546
|
let i = rows.length;
|
|
1555
1547
|
let nextBlock;
|
|
1556
|
-
let prevMovedBlock;
|
|
1557
1548
|
while (i--) {
|
|
1558
1549
|
const row = rows[i];
|
|
1559
1550
|
const oldIndex = prevKeyToIndexMap.get(row.key);
|
|
1551
|
+
prevKeyToIndexMap.delete(row.key);
|
|
1552
|
+
const ref = nextBlock ? nextBlock.el : anchor;
|
|
1560
1553
|
let block;
|
|
1561
|
-
if (oldIndex == null) block = mountBlock(row,
|
|
1554
|
+
if (oldIndex == null) block = mountBlock(row, ref);
|
|
1562
1555
|
else {
|
|
1563
1556
|
block = blocks[oldIndex];
|
|
1564
1557
|
Object.assign(block.ctx.scope, row.data);
|
|
1565
|
-
if (oldIndex !== i)
|
|
1566
|
-
if (blocks[oldIndex + 1] !== nextBlock || prevMovedBlock === nextBlock) {
|
|
1567
|
-
prevMovedBlock = block;
|
|
1568
|
-
block.insert(parent(), nextBlock ? nextBlock.el : anchor);
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1558
|
+
if (oldIndex !== i && (block.end || block.el).nextSibling !== ref) block.insert(parent(), ref);
|
|
1571
1559
|
}
|
|
1572
|
-
nextBlocks
|
|
1560
|
+
nextBlocks[i] = nextBlock = block;
|
|
1573
1561
|
}
|
|
1574
1562
|
blocks = nextBlocks;
|
|
1575
1563
|
}
|
|
1576
1564
|
});
|
|
1577
1565
|
return nextNode;
|
|
1578
1566
|
};
|
|
1579
|
-
|
|
1580
|
-
//#region src/directives/ref.ts
|
|
1567
|
+
// src/directives/ref.ts
|
|
1581
1568
|
var ref = ({ el, ctx: { scope: { $refs } }, get, effect }) => {
|
|
1582
1569
|
let prevRef;
|
|
1583
1570
|
effect(() => {
|
|
@@ -1594,8 +1581,7 @@ var ref = ({ el, ctx: { scope: { $refs } }, get, effect }) => {
|
|
|
1594
1581
|
prevRef && delete $refs[prevRef];
|
|
1595
1582
|
};
|
|
1596
1583
|
};
|
|
1597
|
-
|
|
1598
|
-
//#region src/lazy.ts
|
|
1584
|
+
// src/lazy.ts
|
|
1599
1585
|
var LAZY_MODES = [
|
|
1600
1586
|
"visible",
|
|
1601
1587
|
"idle",
|
|
@@ -1620,7 +1606,7 @@ var arm = (el, mode, fire) => {
|
|
|
1620
1606
|
stop();
|
|
1621
1607
|
fire();
|
|
1622
1608
|
};
|
|
1623
|
-
let stop =
|
|
1609
|
+
let stop = NOOP;
|
|
1624
1610
|
if (mode === "visible" && typeof IntersectionObserver == "function") {
|
|
1625
1611
|
const io = new IntersectionObserver((entries) => {
|
|
1626
1612
|
if (entries.some((e) => e.isIntersecting)) once();
|
|
@@ -1657,11 +1643,13 @@ var deferScope = (el, ctx, walk, once) => {
|
|
|
1657
1643
|
walk(el, ctx, once);
|
|
1658
1644
|
});
|
|
1659
1645
|
ctx.cleanups.push(dispose);
|
|
1660
|
-
own(
|
|
1646
|
+
own(() => {
|
|
1647
|
+
remove(ctx.cleanups, dispose);
|
|
1648
|
+
dispose();
|
|
1649
|
+
});
|
|
1661
1650
|
return true;
|
|
1662
1651
|
};
|
|
1663
|
-
|
|
1664
|
-
//#region src/walk.ts
|
|
1652
|
+
// src/walk.ts
|
|
1665
1653
|
var dirRE = /^(?:v-|:|@)/;
|
|
1666
1654
|
var modifierRE = /\.([\w-]+)/g;
|
|
1667
1655
|
var inOnce = false;
|
|
@@ -1675,7 +1663,7 @@ var inOnce = false;
|
|
|
1675
1663
|
* and via the node — and a second run would remove a listener the next mount
|
|
1676
1664
|
* installed.
|
|
1677
1665
|
*/
|
|
1678
|
-
var addCleanup = (ctx, cleanup) => {
|
|
1666
|
+
var addCleanup = (ctx, cleanup, node) => {
|
|
1679
1667
|
ctx.cleanups.push(cleanup);
|
|
1680
1668
|
own(() => {
|
|
1681
1669
|
const i = ctx.cleanups.indexOf(cleanup);
|
|
@@ -1683,17 +1671,18 @@ var addCleanup = (ctx, cleanup) => {
|
|
|
1683
1671
|
ctx.cleanups.splice(i, 1);
|
|
1684
1672
|
cleanup();
|
|
1685
1673
|
}
|
|
1686
|
-
});
|
|
1674
|
+
}, node);
|
|
1687
1675
|
};
|
|
1688
|
-
var
|
|
1676
|
+
var withOnce = (once, fn) => {
|
|
1689
1677
|
const previous = inOnce;
|
|
1690
1678
|
inOnce = once;
|
|
1691
1679
|
try {
|
|
1692
|
-
|
|
1680
|
+
fn();
|
|
1693
1681
|
} finally {
|
|
1694
1682
|
inOnce = previous;
|
|
1695
1683
|
}
|
|
1696
1684
|
};
|
|
1685
|
+
var walkDeferred = (node, ctx, once) => withOnce(once, () => walk(node, ctx));
|
|
1697
1686
|
var walk = (node, ctx) => {
|
|
1698
1687
|
const previousOwner = setOwner(node);
|
|
1699
1688
|
try {
|
|
@@ -1706,6 +1695,7 @@ var walkNode = (node, ctx) => {
|
|
|
1706
1695
|
const type = node.nodeType;
|
|
1707
1696
|
if (type === 1) {
|
|
1708
1697
|
const el = node;
|
|
1698
|
+
if (!el.hasAttributes()) return walkChildren(el, ctx);
|
|
1709
1699
|
if (el.hasAttribute("v-pre")) return;
|
|
1710
1700
|
if (deferScope(el, ctx, walkDeferred, inOnce)) return;
|
|
1711
1701
|
checkAttr(el, "v-cloak");
|
|
@@ -1718,9 +1708,13 @@ var walkNode = (node, ctx) => {
|
|
|
1718
1708
|
const target = query(exp, el, "v-teleport");
|
|
1719
1709
|
if (target) {
|
|
1720
1710
|
teleportNext = el.nextSibling;
|
|
1721
|
-
el.
|
|
1711
|
+
const marker = el.__marker = new Text("");
|
|
1712
|
+
el.before(marker);
|
|
1722
1713
|
target.appendChild(el);
|
|
1723
|
-
ctx
|
|
1714
|
+
addCleanup(ctx, () => {
|
|
1715
|
+
disposeSubtree(el);
|
|
1716
|
+
el.remove();
|
|
1717
|
+
}, marker);
|
|
1724
1718
|
} else if (target === null) console.error(`v-teleport target "${exp}" not found.`);
|
|
1725
1719
|
}
|
|
1726
1720
|
if ((exp = checkAttr(el, "v-scope")) || exp === "") {
|
|
@@ -1730,7 +1724,11 @@ var walkNode = (node, ctx) => {
|
|
|
1730
1724
|
}) : {}) || {};
|
|
1731
1725
|
ctx = createScopedContext(ctx, scope);
|
|
1732
1726
|
el.__ctx = ctx;
|
|
1733
|
-
|
|
1727
|
+
const deregister = registerScope(el, ctx.scope, exp || void 0, name || void 0);
|
|
1728
|
+
addCleanup(ctx, () => {
|
|
1729
|
+
deregister();
|
|
1730
|
+
delete el.__ctx;
|
|
1731
|
+
});
|
|
1734
1732
|
if (scope.$template) resolveTemplate(el, scope.$template);
|
|
1735
1733
|
}
|
|
1736
1734
|
const wasOnce = inOnce;
|
|
@@ -1815,7 +1813,28 @@ var applyDirective = (el, dir, exp, ctx, arg, modifiers, source, displayExp) =>
|
|
|
1815
1813
|
el,
|
|
1816
1814
|
expression: displayExp
|
|
1817
1815
|
};
|
|
1818
|
-
const
|
|
1816
|
+
const report = (err) => handleError(err, {
|
|
1817
|
+
phase: "handler",
|
|
1818
|
+
source,
|
|
1819
|
+
el,
|
|
1820
|
+
expression: exp,
|
|
1821
|
+
scope: ctx.scope
|
|
1822
|
+
});
|
|
1823
|
+
const get = (code) => {
|
|
1824
|
+
const value = evaluate(ctx.scope, code ?? exp, el, meta);
|
|
1825
|
+
return code && typeof value == "function" ? (...args) => {
|
|
1826
|
+
const previous = setOwner(el);
|
|
1827
|
+
try {
|
|
1828
|
+
const result = value(...args);
|
|
1829
|
+
if (result instanceof Promise) result.catch(report);
|
|
1830
|
+
return result;
|
|
1831
|
+
} catch (err) {
|
|
1832
|
+
report(err);
|
|
1833
|
+
} finally {
|
|
1834
|
+
setOwner(previous);
|
|
1835
|
+
}
|
|
1836
|
+
} : value;
|
|
1837
|
+
};
|
|
1819
1838
|
let cleanup;
|
|
1820
1839
|
try {
|
|
1821
1840
|
cleanup = dir({
|
|
@@ -1857,8 +1876,8 @@ var query = (sel, el, source) => {
|
|
|
1857
1876
|
var resolveTemplate = (el, template) => {
|
|
1858
1877
|
if (template[0] === "#") {
|
|
1859
1878
|
const templateEl = query(template, el, "v-scope");
|
|
1860
|
-
if (!templateEl) {
|
|
1861
|
-
if (templateEl
|
|
1879
|
+
if (!(templateEl instanceof HTMLTemplateElement)) {
|
|
1880
|
+
if (templateEl !== void 0) console.error(`template selector ${template} has no matching <template> element.`);
|
|
1862
1881
|
return;
|
|
1863
1882
|
}
|
|
1864
1883
|
el.appendChild(templateEl.content.cloneNode(true));
|
|
@@ -1866,8 +1885,7 @@ var resolveTemplate = (el, template) => {
|
|
|
1866
1885
|
}
|
|
1867
1886
|
el.innerHTML = template;
|
|
1868
1887
|
};
|
|
1869
|
-
|
|
1870
|
-
//#region src/context.ts
|
|
1888
|
+
// src/context.ts
|
|
1871
1889
|
var createContext = (parent) => {
|
|
1872
1890
|
const ctx = {
|
|
1873
1891
|
delimiters: ["{{", "}}"],
|
|
@@ -1880,15 +1898,20 @@ var createContext = (parent) => {
|
|
|
1880
1898
|
cleanups: [],
|
|
1881
1899
|
effect: (fn) => {
|
|
1882
1900
|
if (inOnce) {
|
|
1883
|
-
|
|
1884
|
-
|
|
1901
|
+
const job = () => withOnce(true, fn);
|
|
1902
|
+
queueJob(job);
|
|
1903
|
+
return job;
|
|
1885
1904
|
}
|
|
1886
|
-
const e = effect$1(fn, {
|
|
1905
|
+
const e = stampJob(effect$1(fn, {
|
|
1906
|
+
scheduler: () => queueJob(e),
|
|
1907
|
+
lazy: true
|
|
1908
|
+
}));
|
|
1887
1909
|
ctx.effects.push(e);
|
|
1888
1910
|
own(() => {
|
|
1889
1911
|
stopEffect(e);
|
|
1890
1912
|
remove(ctx.effects, e);
|
|
1891
1913
|
});
|
|
1914
|
+
e();
|
|
1892
1915
|
return e;
|
|
1893
1916
|
}
|
|
1894
1917
|
};
|
|
@@ -1919,28 +1942,19 @@ var createScopedContext = (ctx, data = {}) => {
|
|
|
1919
1942
|
};
|
|
1920
1943
|
hide(mergedScope, "$watch", createWatch(scopedCtx));
|
|
1921
1944
|
hide(mergedScope, "$id", createId());
|
|
1922
|
-
bindContextMethods(reactiveProxy);
|
|
1945
|
+
bindContextMethods(reactiveProxy, mergedScope);
|
|
1923
1946
|
return scopedCtx;
|
|
1924
1947
|
};
|
|
1925
|
-
var bindContextMethods = (scope) => {
|
|
1926
|
-
for (const key of Object.keys(
|
|
1927
|
-
const fn = Object.getOwnPropertyDescriptor(
|
|
1948
|
+
var bindContextMethods = (scope, raw = scope) => {
|
|
1949
|
+
for (const key of Object.keys(raw)) {
|
|
1950
|
+
const fn = Object.getOwnPropertyDescriptor(raw, key).value;
|
|
1928
1951
|
if (typeof fn === "function") scope[key] = fn.bind(scope);
|
|
1929
1952
|
}
|
|
1930
1953
|
};
|
|
1931
|
-
|
|
1932
|
-
//#region src/block.ts
|
|
1954
|
+
// src/block.ts
|
|
1933
1955
|
var Block = class {
|
|
1934
|
-
template;
|
|
1935
|
-
ctx;
|
|
1936
|
-
key;
|
|
1937
|
-
parentCtx;
|
|
1938
|
-
isFragment;
|
|
1939
|
-
start;
|
|
1940
|
-
end;
|
|
1941
|
-
owned = false;
|
|
1942
1956
|
get el() {
|
|
1943
|
-
return this.start || this.template;
|
|
1957
|
+
return this.start || this.template.__marker || this.template;
|
|
1944
1958
|
}
|
|
1945
1959
|
constructor(template, parentCtx, isRoot = false) {
|
|
1946
1960
|
this.isFragment = template instanceof HTMLTemplateElement;
|
|
@@ -1973,7 +1987,7 @@ var Block = class {
|
|
|
1973
1987
|
parent.insertBefore(this.start, this.end);
|
|
1974
1988
|
parent.insertBefore(this.template, this.end);
|
|
1975
1989
|
}
|
|
1976
|
-
} else
|
|
1990
|
+
} else parent.insertBefore(this.el, anchor);
|
|
1977
1991
|
if (!this.owned) {
|
|
1978
1992
|
this.owned = true;
|
|
1979
1993
|
own(() => this.discard(), this.el);
|
|
@@ -1990,11 +2004,16 @@ var Block = class {
|
|
|
1990
2004
|
while (node) {
|
|
1991
2005
|
next = node.nextSibling;
|
|
1992
2006
|
parent.removeChild(node);
|
|
2007
|
+
disposeSubtree(node);
|
|
1993
2008
|
if (node === this.end) break;
|
|
1994
2009
|
node = next;
|
|
1995
2010
|
}
|
|
1996
|
-
} else
|
|
2011
|
+
} else {
|
|
2012
|
+
parent.removeChild(this.template);
|
|
2013
|
+
disposeSubtree(this.template);
|
|
2014
|
+
}
|
|
1997
2015
|
}
|
|
2016
|
+
this.template.__marker?.remove();
|
|
1998
2017
|
this.teardown();
|
|
1999
2018
|
};
|
|
2000
2019
|
const leaves = [];
|
|
@@ -2024,8 +2043,7 @@ var Block = class {
|
|
|
2024
2043
|
this.ctx.cleanups.splice(0).forEach((fn) => fn());
|
|
2025
2044
|
}
|
|
2026
2045
|
};
|
|
2027
|
-
|
|
2028
|
-
//#region src/store.ts
|
|
2046
|
+
// src/store.ts
|
|
2029
2047
|
/**
|
|
2030
2048
|
* DEV: catch `$store.typo`, which otherwise reads as `undefined` and renders a
|
|
2031
2049
|
* blank instead of raising.
|
|
@@ -2043,7 +2061,7 @@ var Block = class {
|
|
|
2043
2061
|
var registry = Object.create(null);
|
|
2044
2062
|
var target = registry;
|
|
2045
2063
|
target = new Proxy(registry, { get(obj, key, receiver) {
|
|
2046
|
-
if (typeof key === "string" && !key.startsWith("__") && !(key in obj)) setTimeout(() => {
|
|
2064
|
+
if (typeof key === "string" && !key.startsWith("__") && key !== "toJSON" && !(key in obj)) setTimeout(() => {
|
|
2047
2065
|
if (key in obj) return;
|
|
2048
2066
|
warnOnce(`store-missing:${key}`, `$store.${key} is not registered, so it reads as undefined. Register it with store('${key}', { … }) before mounting, or check the spelling.`);
|
|
2049
2067
|
});
|
|
@@ -2063,9 +2081,8 @@ var store = (name, value) => {
|
|
|
2063
2081
|
}
|
|
2064
2082
|
return stores[name];
|
|
2065
2083
|
};
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
var mountedRoots = /* @__PURE__ */ new WeakSet();
|
|
2084
|
+
// src/app.ts
|
|
2085
|
+
var mountedRoots = /* @__PURE__ */ new WeakMap();
|
|
2069
2086
|
var escapeRegex = (str) => str.replace(/[-.*+?^${}()|[\]/\\]/g, "\\$&");
|
|
2070
2087
|
var createApp = (initialData) => {
|
|
2071
2088
|
const ctx = createContext();
|
|
@@ -2081,12 +2098,12 @@ var createApp = (initialData) => {
|
|
|
2081
2098
|
ctx.delimitersRE = new RegExp(escapeRegex(open) + "([^]+?)" + escapeRegex(close), "g");
|
|
2082
2099
|
}
|
|
2083
2100
|
}
|
|
2084
|
-
ctx.scope
|
|
2085
|
-
ctx.scope
|
|
2086
|
-
ctx.scope
|
|
2087
|
-
ctx.scope
|
|
2088
|
-
ctx.scope
|
|
2089
|
-
ctx.scope
|
|
2101
|
+
hide(ctx.scope, "$s", toDisplayString);
|
|
2102
|
+
hide(ctx.scope, "$nextTick", nextTick);
|
|
2103
|
+
hide(ctx.scope, "$refs", Object.create(null));
|
|
2104
|
+
hide(ctx.scope, "$store", stores);
|
|
2105
|
+
hide(ctx.scope, "$watch", createWatch(ctx));
|
|
2106
|
+
hide(ctx.scope, "$id", createId());
|
|
2090
2107
|
Object.defineProperty(ctx.scope, "$root", {
|
|
2091
2108
|
value: ctx.scope,
|
|
2092
2109
|
enumerable: false
|
|
@@ -2164,13 +2181,15 @@ var createApp = (initialData) => {
|
|
|
2164
2181
|
ctx.walk ??= walk;
|
|
2165
2182
|
ctx.dispose ??= disposeSubtree;
|
|
2166
2183
|
for (const el of roots) {
|
|
2167
|
-
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.");
|
|
2168
|
-
mountedRoots.add(el);
|
|
2184
|
+
if (mountedRoots.has(el) && mountedRoots.get(el) === el.firstChild) warn("mount() was called again on an element that has already been mounted, so its directives were consumed by the first walk and nothing was bound this time. To re-activate a region, insert fresh markup and mount that instead.");
|
|
2169
2185
|
const name = el.getAttribute("v-name");
|
|
2170
2186
|
const block = new Block(el, ctx, true);
|
|
2187
|
+
mountedRoots.set(el, el.firstChild);
|
|
2171
2188
|
el.__ctx ??= block.ctx;
|
|
2172
2189
|
if (!devtools.scopes.has(el) && !el.matches(SCOPE_SELECTOR)) block.ctx.cleanups.push(registerScope(el, block.ctx.scope, void 0, name || void 0));
|
|
2173
2190
|
rootBlocks.push(block);
|
|
2191
|
+
own(() => remove(rootBlocks, block), el);
|
|
2192
|
+
block.ctx.cleanups.push(() => delete el.__ctx);
|
|
2174
2193
|
}
|
|
2175
2194
|
return this;
|
|
2176
2195
|
},
|
|
@@ -2217,8 +2236,7 @@ var createApp = (initialData) => {
|
|
|
2217
2236
|
};
|
|
2218
2237
|
return app;
|
|
2219
2238
|
};
|
|
2220
|
-
|
|
2221
|
-
//#region src/effect.ts
|
|
2239
|
+
// src/effect.ts
|
|
2222
2240
|
/**
|
|
2223
2241
|
* Runs `fn` now, then again when the reactive state it read changes. The
|
|
2224
2242
|
* JS-side counterpart to `v-effect`, for work not tied to an element.
|
|
@@ -2230,13 +2248,20 @@ var createApp = (initialData) => {
|
|
|
2230
2248
|
* Returns a stop function. Nothing stops it automatically.
|
|
2231
2249
|
*/
|
|
2232
2250
|
var watchEffect = (fn) => {
|
|
2233
|
-
|
|
2234
|
-
|
|
2251
|
+
const runner = effect$1(fn, {
|
|
2252
|
+
scheduler: () => queueJob(runner),
|
|
2253
|
+
lazy: true
|
|
2254
|
+
});
|
|
2255
|
+
runner.i = Infinity;
|
|
2256
|
+
try {
|
|
2257
|
+
runner();
|
|
2258
|
+
} catch (e) {
|
|
2259
|
+
stopEffect(runner);
|
|
2260
|
+
throw e;
|
|
2261
|
+
}
|
|
2235
2262
|
return () => stopEffect(runner);
|
|
2236
2263
|
};
|
|
2237
|
-
|
|
2238
|
-
//#region src/index.ts
|
|
2264
|
+
// src/index.ts
|
|
2239
2265
|
var s = document.currentScript;
|
|
2240
2266
|
if (s && s.hasAttribute("init")) createApp().mount();
|
|
2241
|
-
//#endregion
|
|
2242
2267
|
export { computed, createApp, devtools, disableDevtools, nextTick, reactive, store, watchEffect };
|