@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.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;
|
|
@@ -789,7 +768,7 @@ getter: `, this.getter);
|
|
|
789
768
|
teardown: "tearing down"
|
|
790
769
|
};
|
|
791
770
|
var handleError = (err, info) => {
|
|
792
|
-
for (const fn of handlers) try {
|
|
771
|
+
for (const fn of [...handlers]) try {
|
|
793
772
|
fn(err, info);
|
|
794
773
|
} catch (inner) {
|
|
795
774
|
console.error("[litevue] an onError handler itself threw:", inner);
|
|
@@ -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,9 +893,10 @@ 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;
|
|
899
|
+
if (!arg) el.__bound = prevValue;
|
|
915
900
|
});
|
|
916
901
|
};
|
|
917
902
|
var setProp = (el, key, value, prevValue) => {
|
|
@@ -922,6 +907,10 @@ getter: `, this.getter);
|
|
|
922
907
|
const prev = toStyle(prevValue);
|
|
923
908
|
for (const key in next) setStyle(style, key, next[key]);
|
|
924
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
|
+
}
|
|
925
914
|
if (!style.cssText) el.removeAttribute("style");
|
|
926
915
|
} else if (!(el instanceof SVGElement) && key in el && !forceAttrRE.test(key)) {
|
|
927
916
|
el[key] = value == null && typeof el[key] == "string" ? "" : value;
|
|
@@ -929,8 +918,11 @@ getter: `, this.getter);
|
|
|
929
918
|
if (key === "value") el._value = value;
|
|
930
919
|
} else if (key === "true-value") el._trueValue = value;
|
|
931
920
|
else if (key === "false-value") el._falseValue = value;
|
|
932
|
-
else
|
|
933
|
-
|
|
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
|
+
}
|
|
934
926
|
};
|
|
935
927
|
var toStyle = (value) => isString(value = normalizeStyle(value)) ? parseStringStyle(value) : value || {};
|
|
936
928
|
var importantRE = /\s*!important$/;
|
|
@@ -940,8 +932,7 @@ getter: `, this.getter);
|
|
|
940
932
|
else if (importantRE.test(val)) style.setProperty(hyphenate(name), val.replace(importantRE, ""), "important");
|
|
941
933
|
else style[name] = val;
|
|
942
934
|
};
|
|
943
|
-
|
|
944
|
-
//#region src/warn.ts
|
|
935
|
+
// src/warn.ts
|
|
945
936
|
/**
|
|
946
937
|
* Development warnings.
|
|
947
938
|
*
|
|
@@ -963,16 +954,62 @@ getter: `, this.getter);
|
|
|
963
954
|
seen.add(key);
|
|
964
955
|
warn(msg);
|
|
965
956
|
};
|
|
966
|
-
|
|
967
|
-
|
|
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
|
|
968
1000
|
/**
|
|
969
1001
|
* Can `exp` stand as a single expression, or is it a statement list?
|
|
970
1002
|
* Memoised: it compiles a throwaway function, which a `v-for` pays per row.
|
|
971
1003
|
*/
|
|
972
1004
|
var expressionCache = Object.create(null);
|
|
1005
|
+
var cachedExpressions = 0;
|
|
973
1006
|
var isExpression = (exp) => {
|
|
974
1007
|
const hit = expressionCache[exp];
|
|
975
1008
|
if (hit !== void 0) return hit;
|
|
1009
|
+
if (++cachedExpressions > 1e3) {
|
|
1010
|
+
expressionCache = Object.create(null);
|
|
1011
|
+
cachedExpressions = 1;
|
|
1012
|
+
}
|
|
976
1013
|
try {
|
|
977
1014
|
new Function(`return (${exp})`);
|
|
978
1015
|
return expressionCache[exp] = true;
|
|
@@ -980,6 +1017,7 @@ getter: `, this.getter);
|
|
|
980
1017
|
return expressionCache[exp] = false;
|
|
981
1018
|
}
|
|
982
1019
|
};
|
|
1020
|
+
var fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$]+)\s*=>|^\s*(async\s+)?function\b/;
|
|
983
1021
|
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
|
|
984
1022
|
var systemModifiers = [
|
|
985
1023
|
"ctrl",
|
|
@@ -1010,31 +1048,13 @@ getter: `, this.getter);
|
|
|
1010
1048
|
delete: "backspace"
|
|
1011
1049
|
};
|
|
1012
1050
|
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-.+)$/;
|
|
1013
|
-
var on = ({ el, get,
|
|
1051
|
+
var on = ({ el, get, exp, arg, modifiers }) => {
|
|
1014
1052
|
if (!arg) {
|
|
1015
1053
|
console.error(`v-on="obj" syntax is not supported in LiteVue.`);
|
|
1016
1054
|
return;
|
|
1017
1055
|
}
|
|
1018
1056
|
const a = /\bawait\b/.test(exp) ? "async " : "";
|
|
1019
|
-
|
|
1020
|
-
let handler = (...args) => {
|
|
1021
|
-
try {
|
|
1022
|
-
const result = raw(...args);
|
|
1023
|
-
if (result instanceof Promise) result.catch(fail);
|
|
1024
|
-
return result;
|
|
1025
|
-
} catch (e) {
|
|
1026
|
-
fail(e);
|
|
1027
|
-
}
|
|
1028
|
-
};
|
|
1029
|
-
function fail(e) {
|
|
1030
|
-
handleError(e, {
|
|
1031
|
-
phase: "handler",
|
|
1032
|
-
source: `@${arg}`,
|
|
1033
|
-
expression: exp,
|
|
1034
|
-
el,
|
|
1035
|
-
scope: ctx.scope
|
|
1036
|
-
});
|
|
1037
|
-
}
|
|
1057
|
+
let handler = simplePathRE.test(exp) || fnExpRE.test(exp) ? get(`(e => (${exp})(e))`) : isExpression(exp) ? get(`(${a}$event => (${exp}))`) : get(`(${a}$event => { ${exp} })`);
|
|
1038
1058
|
if (arg === "vue:mounted" || arg === "vue:unmounted") console.warn(`@${arg} is deprecated in LiteVue - use @${arg.slice(4)} instead.`);
|
|
1039
1059
|
if (arg === "mounted" || arg === "vue:mounted") {
|
|
1040
1060
|
let live = true;
|
|
@@ -1095,42 +1115,43 @@ getter: `, this.getter);
|
|
|
1095
1115
|
if (key.startsWith("prop-") && "propertyName" in e && e.propertyName !== key.slice(5)) return;
|
|
1096
1116
|
if (key.startsWith("name-") && "animationName" in e && e.animationName !== key.slice(5)) return;
|
|
1097
1117
|
}
|
|
1118
|
+
if (modifiers.once) target.removeEventListener(event, handler, modifiers);
|
|
1098
1119
|
return invoke(e);
|
|
1099
1120
|
};
|
|
1100
1121
|
}
|
|
1101
1122
|
const target = modifiers?.window ? window : modifiers?.document || modifiers?.outside ? document : el;
|
|
1102
1123
|
const event = arg;
|
|
1103
|
-
target.addEventListener(event, handler,
|
|
1124
|
+
target.addEventListener(event, handler, {
|
|
1125
|
+
...modifiers,
|
|
1126
|
+
once: false
|
|
1127
|
+
});
|
|
1104
1128
|
return () => {
|
|
1105
1129
|
clearTimeout(debounceTimer);
|
|
1106
1130
|
target.removeEventListener(event, handler, modifiers);
|
|
1107
1131
|
};
|
|
1108
1132
|
};
|
|
1109
|
-
|
|
1110
|
-
//#region src/directives/show.ts
|
|
1133
|
+
// src/directives/show.ts
|
|
1111
1134
|
var show = ({ el, get, effect }) => {
|
|
1112
|
-
|
|
1135
|
+
el._vod = el.style.display == "none" ? "" : el.style.display;
|
|
1113
1136
|
effect(() => {
|
|
1114
|
-
el.
|
|
1137
|
+
el._vsh = !get();
|
|
1138
|
+
el.style.display = el._vsh ? "none" : el._vod;
|
|
1115
1139
|
});
|
|
1116
1140
|
};
|
|
1117
|
-
|
|
1118
|
-
//#region src/directives/text.ts
|
|
1141
|
+
// src/directives/text.ts
|
|
1119
1142
|
var text = ({ el, get, effect }) => {
|
|
1120
1143
|
effect(() => {
|
|
1121
1144
|
el.textContent = toDisplayString(get());
|
|
1122
1145
|
});
|
|
1123
1146
|
};
|
|
1124
1147
|
var toDisplayString = (value) => value == null ? "" : isObject(value) ? JSON.stringify(value, null, 2) : String(value);
|
|
1125
|
-
|
|
1126
|
-
//#region src/directives/html.ts
|
|
1148
|
+
// src/directives/html.ts
|
|
1127
1149
|
var html = ({ el, get, effect }) => {
|
|
1128
1150
|
effect(() => {
|
|
1129
1151
|
el.innerHTML = get() ?? "";
|
|
1130
1152
|
});
|
|
1131
1153
|
};
|
|
1132
|
-
|
|
1133
|
-
//#region src/utils.ts
|
|
1154
|
+
// src/utils.ts
|
|
1134
1155
|
var checkAttr = (el, name) => {
|
|
1135
1156
|
const val = el.getAttribute(name);
|
|
1136
1157
|
if (val != null) el.removeAttribute(name);
|
|
@@ -1145,21 +1166,24 @@ getter: `, this.getter);
|
|
|
1145
1166
|
el.addEventListener(event, handler, options);
|
|
1146
1167
|
return () => el.removeEventListener(event, handler, options);
|
|
1147
1168
|
};
|
|
1148
|
-
|
|
1149
|
-
//#region src/directives/model.ts
|
|
1169
|
+
// src/directives/model.ts
|
|
1150
1170
|
var model = ({ el, exp, get, effect, modifiers }) => {
|
|
1151
1171
|
const type = el.type;
|
|
1152
1172
|
const assign = get(`(val) => { ${exp} = val }`);
|
|
1153
1173
|
const { trim, number = type === "number", lazy, fill } = modifiers || {};
|
|
1174
|
+
const cast = (val) => number ? looseToNumber(val) : val;
|
|
1154
1175
|
const off = [];
|
|
1155
1176
|
const on = (event, handler) => off.push(listen(el, event, handler));
|
|
1177
|
+
let update;
|
|
1178
|
+
let render;
|
|
1179
|
+
let isText = false;
|
|
1156
1180
|
if (el.tagName === "SELECT") {
|
|
1157
1181
|
const sel = el;
|
|
1158
|
-
on("change", () => {
|
|
1159
|
-
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)));
|
|
1160
1184
|
assign(sel.multiple ? selectedVal : selectedVal[0]);
|
|
1161
1185
|
});
|
|
1162
|
-
|
|
1186
|
+
render = () => {
|
|
1163
1187
|
const value = get();
|
|
1164
1188
|
const isMultiple = sel.multiple;
|
|
1165
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.`);
|
|
@@ -1173,9 +1197,9 @@ getter: `, this.getter);
|
|
|
1173
1197
|
}
|
|
1174
1198
|
}
|
|
1175
1199
|
if (!isMultiple && sel.selectedIndex !== -1) sel.selectedIndex = -1;
|
|
1176
|
-
}
|
|
1200
|
+
};
|
|
1177
1201
|
} else if (type === "checkbox") {
|
|
1178
|
-
on("change", () => {
|
|
1202
|
+
on("change", update = () => {
|
|
1179
1203
|
const modelValue = get();
|
|
1180
1204
|
const checked = el.checked;
|
|
1181
1205
|
if (isArray(modelValue)) {
|
|
@@ -1190,23 +1214,20 @@ getter: `, this.getter);
|
|
|
1190
1214
|
}
|
|
1191
1215
|
} else assign(getCheckboxValue(el, checked));
|
|
1192
1216
|
});
|
|
1193
|
-
|
|
1217
|
+
render = () => {
|
|
1194
1218
|
const value = get();
|
|
1195
1219
|
if (isArray(value)) el.checked = looseIndexOf(value, getValue(el)) > -1;
|
|
1196
1220
|
else el.checked = looseEqual(value, getCheckboxValue(el, true));
|
|
1197
|
-
}
|
|
1221
|
+
};
|
|
1198
1222
|
} else if (type === "radio") {
|
|
1199
|
-
on("change", () =>
|
|
1200
|
-
|
|
1201
|
-
});
|
|
1202
|
-
effect(() => {
|
|
1223
|
+
on("change", update = () => assign(getValue(el)));
|
|
1224
|
+
render = () => {
|
|
1203
1225
|
el.checked = looseEqual(get(), getValue(el));
|
|
1204
|
-
});
|
|
1205
|
-
} else {
|
|
1206
|
-
const resolveValue = (val) => {
|
|
1207
|
-
if (trim) val = val.trim();
|
|
1208
|
-
return number ? toNumber(val) : val;
|
|
1209
1226
|
};
|
|
1227
|
+
} else {
|
|
1228
|
+
isText = true;
|
|
1229
|
+
const resolveValue = (val) => cast(trim ? val.trim() : val);
|
|
1230
|
+
update = () => assign(resolveValue(el.value));
|
|
1210
1231
|
let write = assign;
|
|
1211
1232
|
let debounceTimer;
|
|
1212
1233
|
for (const key in modifiers || {}) {
|
|
@@ -1229,17 +1250,27 @@ getter: `, this.getter);
|
|
|
1229
1250
|
if (trim) on("change", () => {
|
|
1230
1251
|
el.value = el.value.trim();
|
|
1231
1252
|
});
|
|
1232
|
-
|
|
1233
|
-
const cur = get();
|
|
1234
|
-
if ((cur == null || cur === "") && el.value) assign(resolveValue(el.value));
|
|
1235
|
-
}
|
|
1236
|
-
effect(() => {
|
|
1253
|
+
render = () => {
|
|
1237
1254
|
if (el.composing) return;
|
|
1238
1255
|
const curVal = el.value;
|
|
1239
1256
|
const newVal = get() ?? "";
|
|
1240
1257
|
if (document.activeElement === el && resolveValue(curVal) === newVal) return;
|
|
1241
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
|
|
1242
1272
|
});
|
|
1273
|
+
off.push(() => observer.disconnect());
|
|
1243
1274
|
}
|
|
1244
1275
|
return () => off.forEach((remove) => remove());
|
|
1245
1276
|
};
|
|
@@ -1264,50 +1295,7 @@ getter: `, this.getter);
|
|
|
1264
1295
|
cancelable: true
|
|
1265
1296
|
}));
|
|
1266
1297
|
};
|
|
1267
|
-
|
|
1268
|
-
var cached = 0;
|
|
1269
|
-
var mkDispatch = (el) => (event, detail) => el.dispatchEvent(new CustomEvent(event, {
|
|
1270
|
-
detail,
|
|
1271
|
-
bubbles: true
|
|
1272
|
-
}));
|
|
1273
|
-
var unwrap = (exp) => exp.replace(/^return\(([^]*)\)$/, "$1");
|
|
1274
|
-
var evaluate = (scope, exp, el, meta) => execute(scope, `return(${exp})`, el, meta);
|
|
1275
|
-
var execute = (scope, exp, el, meta) => {
|
|
1276
|
-
let fn = evalCache[exp];
|
|
1277
|
-
if (!fn) {
|
|
1278
|
-
if (++cached > 1e3) {
|
|
1279
|
-
evalCache = Object.create(null);
|
|
1280
|
-
cached = 1;
|
|
1281
|
-
}
|
|
1282
|
-
fn = evalCache[exp] = toFunction(exp, el, meta);
|
|
1283
|
-
}
|
|
1284
|
-
try {
|
|
1285
|
-
return fn(scope, el, el && mkDispatch(el));
|
|
1286
|
-
} catch (e) {
|
|
1287
|
-
handleError(e, {
|
|
1288
|
-
phase: "expression",
|
|
1289
|
-
expression: meta?.expression ?? unwrap(exp),
|
|
1290
|
-
source: meta?.source,
|
|
1291
|
-
el: meta?.el ?? el,
|
|
1292
|
-
scope
|
|
1293
|
-
});
|
|
1294
|
-
}
|
|
1295
|
-
};
|
|
1296
|
-
var toFunction = (exp, el, meta) => {
|
|
1297
|
-
try {
|
|
1298
|
-
return new Function(`$data`, `$el`, `$dispatch`, `with($data){${exp}}`);
|
|
1299
|
-
} catch (e) {
|
|
1300
|
-
handleError(e, {
|
|
1301
|
-
phase: "compile",
|
|
1302
|
-
expression: meta?.expression ?? unwrap(exp),
|
|
1303
|
-
source: meta?.source,
|
|
1304
|
-
el: meta?.el ?? el
|
|
1305
|
-
});
|
|
1306
|
-
return () => {};
|
|
1307
|
-
}
|
|
1308
|
-
};
|
|
1309
|
-
//#endregion
|
|
1310
|
-
//#region src/ownership.ts
|
|
1298
|
+
// src/ownership.ts
|
|
1311
1299
|
var owned = /* @__PURE__ */ new WeakMap();
|
|
1312
1300
|
/**
|
|
1313
1301
|
* The node currently being walked. A module-level cursor suffices because the
|
|
@@ -1332,6 +1320,8 @@ getter: `, this.getter);
|
|
|
1332
1320
|
if (list) list.push(dispose);
|
|
1333
1321
|
else owned.set(node, [dispose]);
|
|
1334
1322
|
};
|
|
1323
|
+
/** Withdraws a disposer from `node`, for an owner that removes it itself. */
|
|
1324
|
+
var disown = (dispose, node) => remove(owned.get(node) || [], dispose);
|
|
1335
1325
|
/**
|
|
1336
1326
|
* Disposes `node` and its subtree. Safe on an unowned node, and idempotent —
|
|
1337
1327
|
* the record is dropped as it runs.
|
|
@@ -1349,18 +1339,18 @@ getter: `, this.getter);
|
|
|
1349
1339
|
child = next;
|
|
1350
1340
|
}
|
|
1351
1341
|
};
|
|
1352
|
-
|
|
1353
|
-
//#region src/directives/effect.ts
|
|
1342
|
+
// src/directives/effect.ts
|
|
1354
1343
|
var effect = ({ el, ctx, exp, effect }) => {
|
|
1355
1344
|
let live = true;
|
|
1345
|
+
const once = inOnce;
|
|
1356
1346
|
nextTick(() => {
|
|
1357
1347
|
if (!live) return;
|
|
1358
1348
|
const previous = setOwner(el);
|
|
1359
1349
|
try {
|
|
1360
|
-
effect(() => execute(ctx.scope, exp, el, {
|
|
1350
|
+
withOnce(once, () => effect(() => execute(ctx.scope, exp, el, {
|
|
1361
1351
|
source: "v-effect",
|
|
1362
1352
|
el
|
|
1363
|
-
}));
|
|
1353
|
+
})));
|
|
1364
1354
|
} finally {
|
|
1365
1355
|
setOwner(previous);
|
|
1366
1356
|
}
|
|
@@ -1369,8 +1359,7 @@ getter: `, this.getter);
|
|
|
1369
1359
|
live = false;
|
|
1370
1360
|
};
|
|
1371
1361
|
};
|
|
1372
|
-
|
|
1373
|
-
//#region src/directives/index.ts
|
|
1362
|
+
// src/directives/index.ts
|
|
1374
1363
|
var builtInDirectives = {
|
|
1375
1364
|
bind,
|
|
1376
1365
|
on,
|
|
@@ -1380,8 +1369,7 @@ getter: `, this.getter);
|
|
|
1380
1369
|
model,
|
|
1381
1370
|
effect
|
|
1382
1371
|
};
|
|
1383
|
-
|
|
1384
|
-
//#region src/directives/if.ts
|
|
1372
|
+
// src/directives/if.ts
|
|
1385
1373
|
var _if = (el, exp, ctx) => {
|
|
1386
1374
|
if (!exp.trim()) console.warn(`v-if expression cannot be empty.`);
|
|
1387
1375
|
const anchor = new Comment("v-if");
|
|
@@ -1394,10 +1382,11 @@ getter: `, this.getter);
|
|
|
1394
1382
|
let elseExp;
|
|
1395
1383
|
while (elseEl = el.nextElementSibling) {
|
|
1396
1384
|
elseExp = null;
|
|
1397
|
-
if (checkAttr(elseEl, "v-else") === "" || (elseExp = checkAttr(elseEl, "v-else-if"))) {
|
|
1385
|
+
if (checkAttr(elseEl, "v-else") === "" || (elseExp = checkAttr(elseEl, "v-else-if")) != null) {
|
|
1386
|
+
if (elseExp?.trim() === "") console.warn(`v-else-if expression cannot be empty.`);
|
|
1398
1387
|
elseEl.remove();
|
|
1399
1388
|
branches.push({
|
|
1400
|
-
exp: elseExp,
|
|
1389
|
+
exp: elseExp == null ? elseExp : elseExp.trim() || "0",
|
|
1401
1390
|
el: elseEl
|
|
1402
1391
|
});
|
|
1403
1392
|
} else break;
|
|
@@ -1410,6 +1399,7 @@ getter: `, this.getter);
|
|
|
1410
1399
|
const removeActiveBlock = () => {
|
|
1411
1400
|
if (block) {
|
|
1412
1401
|
if (!anchor.parentNode) block.el.before(anchor);
|
|
1402
|
+
disown(stopBranches, block.el);
|
|
1413
1403
|
block.remove();
|
|
1414
1404
|
block = void 0;
|
|
1415
1405
|
}
|
|
@@ -1441,8 +1431,7 @@ getter: `, this.getter);
|
|
|
1441
1431
|
own(stopBranches, anchor);
|
|
1442
1432
|
return nextNode;
|
|
1443
1433
|
};
|
|
1444
|
-
|
|
1445
|
-
//#region src/directives/for.ts
|
|
1434
|
+
// src/directives/for.ts
|
|
1446
1435
|
var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
|
1447
1436
|
var forIteratorRE = /,([^,}\]]*)(?:,([^,}\]]*))?$/;
|
|
1448
1437
|
var stripParensRE = /^\(|\)$/g;
|
|
@@ -1497,7 +1486,7 @@ getter: `, this.getter);
|
|
|
1497
1486
|
};
|
|
1498
1487
|
const createRow = (map, value, index, objKey) => {
|
|
1499
1488
|
const data = {};
|
|
1500
|
-
if (destructureBindings) destructureBindings.forEach((b, i) => data[b] = value[isArrayDestructure ? i : b]);
|
|
1489
|
+
if (destructureBindings) destructureBindings.forEach((b, i) => data[b] = value?.[isArrayDestructure ? i : b]);
|
|
1501
1490
|
else data[valueExp] = value;
|
|
1502
1491
|
if (objKey) {
|
|
1503
1492
|
indexExp && (data[indexExp] = objKey);
|
|
@@ -1535,7 +1524,7 @@ getter: `, this.getter);
|
|
|
1535
1524
|
counts.set(row.key, n);
|
|
1536
1525
|
if (n > 1 && dup === void 0) dup = row.key;
|
|
1537
1526
|
}
|
|
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,
|
|
1527
|
+
warnOnce(`for-dup-key:${exp}`, `v-for="${exp}" produced a duplicate :key ${JSON.stringify(dup)}. Keys must be unique among siblings — with a repeat, the earlier item is rebuilt on every update, losing its element and scope state. Key by something stable and unique, such as a record id.`);
|
|
1539
1528
|
}
|
|
1540
1529
|
if (!keyExp && isArray(source)) {
|
|
1541
1530
|
const items = [...source];
|
|
@@ -1551,35 +1540,33 @@ getter: `, this.getter);
|
|
|
1551
1540
|
blocks = rows.map((row) => mountBlock(row, anchor));
|
|
1552
1541
|
mounted = true;
|
|
1553
1542
|
} else {
|
|
1554
|
-
for (let i = 0; i < blocks.length; i++)
|
|
1543
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
1544
|
+
const key = blocks[i].key;
|
|
1545
|
+
if (!keyToIndexMap.has(key) || prevKeyToIndexMap.get(key) !== i) blocks[i].remove();
|
|
1546
|
+
}
|
|
1555
1547
|
const nextBlocks = [];
|
|
1556
1548
|
let i = rows.length;
|
|
1557
1549
|
let nextBlock;
|
|
1558
|
-
let prevMovedBlock;
|
|
1559
1550
|
while (i--) {
|
|
1560
1551
|
const row = rows[i];
|
|
1561
1552
|
const oldIndex = prevKeyToIndexMap.get(row.key);
|
|
1553
|
+
prevKeyToIndexMap.delete(row.key);
|
|
1554
|
+
const ref = nextBlock ? nextBlock.el : anchor;
|
|
1562
1555
|
let block;
|
|
1563
|
-
if (oldIndex == null) block = mountBlock(row,
|
|
1556
|
+
if (oldIndex == null) block = mountBlock(row, ref);
|
|
1564
1557
|
else {
|
|
1565
1558
|
block = blocks[oldIndex];
|
|
1566
1559
|
Object.assign(block.ctx.scope, row.data);
|
|
1567
|
-
if (oldIndex !== i)
|
|
1568
|
-
if (blocks[oldIndex + 1] !== nextBlock || prevMovedBlock === nextBlock) {
|
|
1569
|
-
prevMovedBlock = block;
|
|
1570
|
-
block.insert(parent(), nextBlock ? nextBlock.el : anchor);
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1560
|
+
if (oldIndex !== i && (block.end || block.el).nextSibling !== ref) block.insert(parent(), ref);
|
|
1573
1561
|
}
|
|
1574
|
-
nextBlocks
|
|
1562
|
+
nextBlocks[i] = nextBlock = block;
|
|
1575
1563
|
}
|
|
1576
1564
|
blocks = nextBlocks;
|
|
1577
1565
|
}
|
|
1578
1566
|
});
|
|
1579
1567
|
return nextNode;
|
|
1580
1568
|
};
|
|
1581
|
-
|
|
1582
|
-
//#region src/directives/ref.ts
|
|
1569
|
+
// src/directives/ref.ts
|
|
1583
1570
|
var ref = ({ el, ctx: { scope: { $refs } }, get, effect }) => {
|
|
1584
1571
|
let prevRef;
|
|
1585
1572
|
effect(() => {
|
|
@@ -1596,8 +1583,7 @@ getter: `, this.getter);
|
|
|
1596
1583
|
prevRef && delete $refs[prevRef];
|
|
1597
1584
|
};
|
|
1598
1585
|
};
|
|
1599
|
-
|
|
1600
|
-
//#region src/lazy.ts
|
|
1586
|
+
// src/lazy.ts
|
|
1601
1587
|
var LAZY_MODES = [
|
|
1602
1588
|
"visible",
|
|
1603
1589
|
"idle",
|
|
@@ -1622,7 +1608,7 @@ getter: `, this.getter);
|
|
|
1622
1608
|
stop();
|
|
1623
1609
|
fire();
|
|
1624
1610
|
};
|
|
1625
|
-
let stop =
|
|
1611
|
+
let stop = NOOP;
|
|
1626
1612
|
if (mode === "visible" && typeof IntersectionObserver == "function") {
|
|
1627
1613
|
const io = new IntersectionObserver((entries) => {
|
|
1628
1614
|
if (entries.some((e) => e.isIntersecting)) once();
|
|
@@ -1659,11 +1645,13 @@ getter: `, this.getter);
|
|
|
1659
1645
|
walk(el, ctx, once);
|
|
1660
1646
|
});
|
|
1661
1647
|
ctx.cleanups.push(dispose);
|
|
1662
|
-
own(
|
|
1648
|
+
own(() => {
|
|
1649
|
+
remove(ctx.cleanups, dispose);
|
|
1650
|
+
dispose();
|
|
1651
|
+
});
|
|
1663
1652
|
return true;
|
|
1664
1653
|
};
|
|
1665
|
-
|
|
1666
|
-
//#region src/walk.ts
|
|
1654
|
+
// src/walk.ts
|
|
1667
1655
|
var dirRE = /^(?:v-|:|@)/;
|
|
1668
1656
|
var modifierRE = /\.([\w-]+)/g;
|
|
1669
1657
|
var inOnce = false;
|
|
@@ -1677,7 +1665,7 @@ getter: `, this.getter);
|
|
|
1677
1665
|
* and via the node — and a second run would remove a listener the next mount
|
|
1678
1666
|
* installed.
|
|
1679
1667
|
*/
|
|
1680
|
-
var addCleanup = (ctx, cleanup) => {
|
|
1668
|
+
var addCleanup = (ctx, cleanup, node) => {
|
|
1681
1669
|
ctx.cleanups.push(cleanup);
|
|
1682
1670
|
own(() => {
|
|
1683
1671
|
const i = ctx.cleanups.indexOf(cleanup);
|
|
@@ -1685,17 +1673,18 @@ getter: `, this.getter);
|
|
|
1685
1673
|
ctx.cleanups.splice(i, 1);
|
|
1686
1674
|
cleanup();
|
|
1687
1675
|
}
|
|
1688
|
-
});
|
|
1676
|
+
}, node);
|
|
1689
1677
|
};
|
|
1690
|
-
var
|
|
1678
|
+
var withOnce = (once, fn) => {
|
|
1691
1679
|
const previous = inOnce;
|
|
1692
1680
|
inOnce = once;
|
|
1693
1681
|
try {
|
|
1694
|
-
|
|
1682
|
+
fn();
|
|
1695
1683
|
} finally {
|
|
1696
1684
|
inOnce = previous;
|
|
1697
1685
|
}
|
|
1698
1686
|
};
|
|
1687
|
+
var walkDeferred = (node, ctx, once) => withOnce(once, () => walk(node, ctx));
|
|
1699
1688
|
var walk = (node, ctx) => {
|
|
1700
1689
|
const previousOwner = setOwner(node);
|
|
1701
1690
|
try {
|
|
@@ -1708,6 +1697,7 @@ getter: `, this.getter);
|
|
|
1708
1697
|
const type = node.nodeType;
|
|
1709
1698
|
if (type === 1) {
|
|
1710
1699
|
const el = node;
|
|
1700
|
+
if (!el.hasAttributes()) return walkChildren(el, ctx);
|
|
1711
1701
|
if (el.hasAttribute("v-pre")) return;
|
|
1712
1702
|
if (deferScope(el, ctx, walkDeferred, inOnce)) return;
|
|
1713
1703
|
checkAttr(el, "v-cloak");
|
|
@@ -1720,9 +1710,13 @@ getter: `, this.getter);
|
|
|
1720
1710
|
const target = query(exp, el, "v-teleport");
|
|
1721
1711
|
if (target) {
|
|
1722
1712
|
teleportNext = el.nextSibling;
|
|
1723
|
-
el.
|
|
1713
|
+
const marker = el.__marker = new Text("");
|
|
1714
|
+
el.before(marker);
|
|
1724
1715
|
target.appendChild(el);
|
|
1725
|
-
ctx
|
|
1716
|
+
addCleanup(ctx, () => {
|
|
1717
|
+
disposeSubtree(el);
|
|
1718
|
+
el.remove();
|
|
1719
|
+
}, marker);
|
|
1726
1720
|
} else if (target === null) console.error(`v-teleport target "${exp}" not found.`);
|
|
1727
1721
|
}
|
|
1728
1722
|
if ((exp = checkAttr(el, "v-scope")) || exp === "") {
|
|
@@ -1732,7 +1726,11 @@ getter: `, this.getter);
|
|
|
1732
1726
|
}) : {}) || {};
|
|
1733
1727
|
ctx = createScopedContext(ctx, scope);
|
|
1734
1728
|
el.__ctx = ctx;
|
|
1735
|
-
|
|
1729
|
+
const deregister = registerScope(el, ctx.scope, exp || void 0, name || void 0);
|
|
1730
|
+
addCleanup(ctx, () => {
|
|
1731
|
+
deregister();
|
|
1732
|
+
delete el.__ctx;
|
|
1733
|
+
});
|
|
1736
1734
|
if (scope.$template) resolveTemplate(el, scope.$template);
|
|
1737
1735
|
}
|
|
1738
1736
|
const wasOnce = inOnce;
|
|
@@ -1817,7 +1815,28 @@ getter: `, this.getter);
|
|
|
1817
1815
|
el,
|
|
1818
1816
|
expression: displayExp
|
|
1819
1817
|
};
|
|
1820
|
-
const
|
|
1818
|
+
const report = (err) => handleError(err, {
|
|
1819
|
+
phase: "handler",
|
|
1820
|
+
source,
|
|
1821
|
+
el,
|
|
1822
|
+
expression: exp,
|
|
1823
|
+
scope: ctx.scope
|
|
1824
|
+
});
|
|
1825
|
+
const get = (code) => {
|
|
1826
|
+
const value = evaluate(ctx.scope, code ?? exp, el, meta);
|
|
1827
|
+
return code && typeof value == "function" ? (...args) => {
|
|
1828
|
+
const previous = setOwner(el);
|
|
1829
|
+
try {
|
|
1830
|
+
const result = value(...args);
|
|
1831
|
+
if (result instanceof Promise) result.catch(report);
|
|
1832
|
+
return result;
|
|
1833
|
+
} catch (err) {
|
|
1834
|
+
report(err);
|
|
1835
|
+
} finally {
|
|
1836
|
+
setOwner(previous);
|
|
1837
|
+
}
|
|
1838
|
+
} : value;
|
|
1839
|
+
};
|
|
1821
1840
|
let cleanup;
|
|
1822
1841
|
try {
|
|
1823
1842
|
cleanup = dir({
|
|
@@ -1859,8 +1878,8 @@ getter: `, this.getter);
|
|
|
1859
1878
|
var resolveTemplate = (el, template) => {
|
|
1860
1879
|
if (template[0] === "#") {
|
|
1861
1880
|
const templateEl = query(template, el, "v-scope");
|
|
1862
|
-
if (!templateEl) {
|
|
1863
|
-
if (templateEl
|
|
1881
|
+
if (!(templateEl instanceof HTMLTemplateElement)) {
|
|
1882
|
+
if (templateEl !== void 0) console.error(`template selector ${template} has no matching <template> element.`);
|
|
1864
1883
|
return;
|
|
1865
1884
|
}
|
|
1866
1885
|
el.appendChild(templateEl.content.cloneNode(true));
|
|
@@ -1868,8 +1887,7 @@ getter: `, this.getter);
|
|
|
1868
1887
|
}
|
|
1869
1888
|
el.innerHTML = template;
|
|
1870
1889
|
};
|
|
1871
|
-
|
|
1872
|
-
//#region src/context.ts
|
|
1890
|
+
// src/context.ts
|
|
1873
1891
|
var createContext = (parent) => {
|
|
1874
1892
|
const ctx = {
|
|
1875
1893
|
delimiters: ["{{", "}}"],
|
|
@@ -1882,15 +1900,20 @@ getter: `, this.getter);
|
|
|
1882
1900
|
cleanups: [],
|
|
1883
1901
|
effect: (fn) => {
|
|
1884
1902
|
if (inOnce) {
|
|
1885
|
-
|
|
1886
|
-
|
|
1903
|
+
const job = () => withOnce(true, fn);
|
|
1904
|
+
queueJob(job);
|
|
1905
|
+
return job;
|
|
1887
1906
|
}
|
|
1888
|
-
const e = effect$1(fn, {
|
|
1907
|
+
const e = stampJob(effect$1(fn, {
|
|
1908
|
+
scheduler: () => queueJob(e),
|
|
1909
|
+
lazy: true
|
|
1910
|
+
}));
|
|
1889
1911
|
ctx.effects.push(e);
|
|
1890
1912
|
own(() => {
|
|
1891
1913
|
stopEffect(e);
|
|
1892
1914
|
remove(ctx.effects, e);
|
|
1893
1915
|
});
|
|
1916
|
+
e();
|
|
1894
1917
|
return e;
|
|
1895
1918
|
}
|
|
1896
1919
|
};
|
|
@@ -1921,28 +1944,19 @@ getter: `, this.getter);
|
|
|
1921
1944
|
};
|
|
1922
1945
|
hide(mergedScope, "$watch", createWatch(scopedCtx));
|
|
1923
1946
|
hide(mergedScope, "$id", createId());
|
|
1924
|
-
bindContextMethods(reactiveProxy);
|
|
1947
|
+
bindContextMethods(reactiveProxy, mergedScope);
|
|
1925
1948
|
return scopedCtx;
|
|
1926
1949
|
};
|
|
1927
|
-
var bindContextMethods = (scope) => {
|
|
1928
|
-
for (const key of Object.keys(
|
|
1929
|
-
const fn = Object.getOwnPropertyDescriptor(
|
|
1950
|
+
var bindContextMethods = (scope, raw = scope) => {
|
|
1951
|
+
for (const key of Object.keys(raw)) {
|
|
1952
|
+
const fn = Object.getOwnPropertyDescriptor(raw, key).value;
|
|
1930
1953
|
if (typeof fn === "function") scope[key] = fn.bind(scope);
|
|
1931
1954
|
}
|
|
1932
1955
|
};
|
|
1933
|
-
|
|
1934
|
-
//#region src/block.ts
|
|
1956
|
+
// src/block.ts
|
|
1935
1957
|
var Block = class {
|
|
1936
|
-
template;
|
|
1937
|
-
ctx;
|
|
1938
|
-
key;
|
|
1939
|
-
parentCtx;
|
|
1940
|
-
isFragment;
|
|
1941
|
-
start;
|
|
1942
|
-
end;
|
|
1943
|
-
owned = false;
|
|
1944
1958
|
get el() {
|
|
1945
|
-
return this.start || this.template;
|
|
1959
|
+
return this.start || this.template.__marker || this.template;
|
|
1946
1960
|
}
|
|
1947
1961
|
constructor(template, parentCtx, isRoot = false) {
|
|
1948
1962
|
this.isFragment = template instanceof HTMLTemplateElement;
|
|
@@ -1975,7 +1989,7 @@ getter: `, this.getter);
|
|
|
1975
1989
|
parent.insertBefore(this.start, this.end);
|
|
1976
1990
|
parent.insertBefore(this.template, this.end);
|
|
1977
1991
|
}
|
|
1978
|
-
} else
|
|
1992
|
+
} else parent.insertBefore(this.el, anchor);
|
|
1979
1993
|
if (!this.owned) {
|
|
1980
1994
|
this.owned = true;
|
|
1981
1995
|
own(() => this.discard(), this.el);
|
|
@@ -1992,11 +2006,16 @@ getter: `, this.getter);
|
|
|
1992
2006
|
while (node) {
|
|
1993
2007
|
next = node.nextSibling;
|
|
1994
2008
|
parent.removeChild(node);
|
|
2009
|
+
disposeSubtree(node);
|
|
1995
2010
|
if (node === this.end) break;
|
|
1996
2011
|
node = next;
|
|
1997
2012
|
}
|
|
1998
|
-
} else
|
|
2013
|
+
} else {
|
|
2014
|
+
parent.removeChild(this.template);
|
|
2015
|
+
disposeSubtree(this.template);
|
|
2016
|
+
}
|
|
1999
2017
|
}
|
|
2018
|
+
this.template.__marker?.remove();
|
|
2000
2019
|
this.teardown();
|
|
2001
2020
|
};
|
|
2002
2021
|
const leaves = [];
|
|
@@ -2026,8 +2045,7 @@ getter: `, this.getter);
|
|
|
2026
2045
|
this.ctx.cleanups.splice(0).forEach((fn) => fn());
|
|
2027
2046
|
}
|
|
2028
2047
|
};
|
|
2029
|
-
|
|
2030
|
-
//#region src/store.ts
|
|
2048
|
+
// src/store.ts
|
|
2031
2049
|
/**
|
|
2032
2050
|
* DEV: catch `$store.typo`, which otherwise reads as `undefined` and renders a
|
|
2033
2051
|
* blank instead of raising.
|
|
@@ -2045,7 +2063,7 @@ getter: `, this.getter);
|
|
|
2045
2063
|
var registry = Object.create(null);
|
|
2046
2064
|
var target = registry;
|
|
2047
2065
|
target = new Proxy(registry, { get(obj, key, receiver) {
|
|
2048
|
-
if (typeof key === "string" && !key.startsWith("__") && !(key in obj)) setTimeout(() => {
|
|
2066
|
+
if (typeof key === "string" && !key.startsWith("__") && key !== "toJSON" && !(key in obj)) setTimeout(() => {
|
|
2049
2067
|
if (key in obj) return;
|
|
2050
2068
|
warnOnce(`store-missing:${key}`, `$store.${key} is not registered, so it reads as undefined. Register it with store('${key}', { … }) before mounting, or check the spelling.`);
|
|
2051
2069
|
});
|
|
@@ -2065,9 +2083,8 @@ getter: `, this.getter);
|
|
|
2065
2083
|
}
|
|
2066
2084
|
return stores[name];
|
|
2067
2085
|
};
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
var mountedRoots = /* @__PURE__ */ new WeakSet();
|
|
2086
|
+
// src/app.ts
|
|
2087
|
+
var mountedRoots = /* @__PURE__ */ new WeakMap();
|
|
2071
2088
|
var escapeRegex = (str) => str.replace(/[-.*+?^${}()|[\]/\\]/g, "\\$&");
|
|
2072
2089
|
var createApp = (initialData) => {
|
|
2073
2090
|
const ctx = createContext();
|
|
@@ -2083,12 +2100,12 @@ getter: `, this.getter);
|
|
|
2083
2100
|
ctx.delimitersRE = new RegExp(escapeRegex(open) + "([^]+?)" + escapeRegex(close), "g");
|
|
2084
2101
|
}
|
|
2085
2102
|
}
|
|
2086
|
-
ctx.scope
|
|
2087
|
-
ctx.scope
|
|
2088
|
-
ctx.scope
|
|
2089
|
-
ctx.scope
|
|
2090
|
-
ctx.scope
|
|
2091
|
-
ctx.scope
|
|
2103
|
+
hide(ctx.scope, "$s", toDisplayString);
|
|
2104
|
+
hide(ctx.scope, "$nextTick", nextTick);
|
|
2105
|
+
hide(ctx.scope, "$refs", Object.create(null));
|
|
2106
|
+
hide(ctx.scope, "$store", stores);
|
|
2107
|
+
hide(ctx.scope, "$watch", createWatch(ctx));
|
|
2108
|
+
hide(ctx.scope, "$id", createId());
|
|
2092
2109
|
Object.defineProperty(ctx.scope, "$root", {
|
|
2093
2110
|
value: ctx.scope,
|
|
2094
2111
|
enumerable: false
|
|
@@ -2166,13 +2183,15 @@ getter: `, this.getter);
|
|
|
2166
2183
|
ctx.walk ??= walk;
|
|
2167
2184
|
ctx.dispose ??= disposeSubtree;
|
|
2168
2185
|
for (const el of roots) {
|
|
2169
|
-
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.");
|
|
2170
|
-
mountedRoots.add(el);
|
|
2186
|
+
if (mountedRoots.has(el) && mountedRoots.get(el) === el.firstChild) warn("mount() was called again on an element that has already been mounted, so its directives were consumed by the first walk and nothing was bound this time. To re-activate a region, insert fresh markup and mount that instead.");
|
|
2171
2187
|
const name = el.getAttribute("v-name");
|
|
2172
2188
|
const block = new Block(el, ctx, true);
|
|
2189
|
+
mountedRoots.set(el, el.firstChild);
|
|
2173
2190
|
el.__ctx ??= block.ctx;
|
|
2174
2191
|
if (!devtools.scopes.has(el) && !el.matches(SCOPE_SELECTOR)) block.ctx.cleanups.push(registerScope(el, block.ctx.scope, void 0, name || void 0));
|
|
2175
2192
|
rootBlocks.push(block);
|
|
2193
|
+
own(() => remove(rootBlocks, block), el);
|
|
2194
|
+
block.ctx.cleanups.push(() => delete el.__ctx);
|
|
2176
2195
|
}
|
|
2177
2196
|
return this;
|
|
2178
2197
|
},
|
|
@@ -2219,8 +2238,7 @@ getter: `, this.getter);
|
|
|
2219
2238
|
};
|
|
2220
2239
|
return app;
|
|
2221
2240
|
};
|
|
2222
|
-
|
|
2223
|
-
//#region src/effect.ts
|
|
2241
|
+
// src/effect.ts
|
|
2224
2242
|
/**
|
|
2225
2243
|
* Runs `fn` now, then again when the reactive state it read changes. The
|
|
2226
2244
|
* JS-side counterpart to `v-effect`, for work not tied to an element.
|
|
@@ -2232,15 +2250,22 @@ getter: `, this.getter);
|
|
|
2232
2250
|
* Returns a stop function. Nothing stops it automatically.
|
|
2233
2251
|
*/
|
|
2234
2252
|
var watchEffect = (fn) => {
|
|
2235
|
-
|
|
2236
|
-
|
|
2253
|
+
const runner = effect$1(fn, {
|
|
2254
|
+
scheduler: () => queueJob(runner),
|
|
2255
|
+
lazy: true
|
|
2256
|
+
});
|
|
2257
|
+
runner.i = Infinity;
|
|
2258
|
+
try {
|
|
2259
|
+
runner();
|
|
2260
|
+
} catch (e) {
|
|
2261
|
+
stopEffect(runner);
|
|
2262
|
+
throw e;
|
|
2263
|
+
}
|
|
2237
2264
|
return () => stopEffect(runner);
|
|
2238
2265
|
};
|
|
2239
|
-
|
|
2240
|
-
//#region src/index.ts
|
|
2266
|
+
// src/index.ts
|
|
2241
2267
|
var s = document.currentScript;
|
|
2242
2268
|
if (s && s.hasAttribute("init")) createApp().mount();
|
|
2243
|
-
//#endregion
|
|
2244
2269
|
exports.computed = computed;
|
|
2245
2270
|
exports.createApp = createApp;
|
|
2246
2271
|
exports.devtools = devtools;
|