@aevantec/litevue 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +73 -0
- package/dist/litevue-devtools.iife.js +1 -0
- package/dist/litevue-devtools.mjs +841 -0
- package/dist/litevue-devtools.umd.js +1 -0
- package/dist/litevue-plugins.iife.js +14 -0
- package/dist/litevue-plugins.mjs +1282 -0
- package/dist/litevue-plugins.umd.js +14 -0
- package/dist/litevue.iife.js +12 -0
- package/dist/litevue.mjs +1781 -0
- package/dist/litevue.umd.js +12 -0
- package/dist/types/app.d.mts +21 -0
- package/dist/types/app.d.ts +21 -0
- package/dist/types/block.d.mts +15 -0
- package/dist/types/block.d.ts +15 -0
- package/dist/types/context.d.mts +17 -0
- package/dist/types/context.d.ts +17 -0
- package/dist/types/devtools-panel.d.mts +1 -0
- package/dist/types/devtools-panel.d.ts +1 -0
- package/dist/types/devtools.d.mts +62 -0
- package/dist/types/devtools.d.ts +62 -0
- package/dist/types/directives/bind.d.mts +4 -0
- package/dist/types/directives/bind.d.ts +4 -0
- package/dist/types/directives/effect.d.mts +2 -0
- package/dist/types/directives/effect.d.ts +2 -0
- package/dist/types/directives/for.d.mts +2 -0
- package/dist/types/directives/for.d.ts +2 -0
- package/dist/types/directives/html.d.mts +2 -0
- package/dist/types/directives/html.d.ts +2 -0
- package/dist/types/directives/if.d.mts +2 -0
- package/dist/types/directives/if.d.ts +2 -0
- package/dist/types/directives/index.d.mts +15 -0
- package/dist/types/directives/index.d.ts +15 -0
- package/dist/types/directives/model.d.mts +2 -0
- package/dist/types/directives/model.d.ts +2 -0
- package/dist/types/directives/on.d.mts +2 -0
- package/dist/types/directives/on.d.ts +2 -0
- package/dist/types/directives/ref.d.mts +2 -0
- package/dist/types/directives/ref.d.ts +2 -0
- package/dist/types/directives/show.d.mts +2 -0
- package/dist/types/directives/show.d.ts +2 -0
- package/dist/types/directives/text.d.mts +3 -0
- package/dist/types/directives/text.d.ts +3 -0
- package/dist/types/effect.d.mts +15 -0
- package/dist/types/effect.d.ts +15 -0
- package/dist/types/eval.d.mts +2 -0
- package/dist/types/eval.d.ts +2 -0
- package/dist/types/index.d.mts +8 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/magics.d.mts +13 -0
- package/dist/types/magics.d.ts +13 -0
- package/dist/types/plugins/collapse.d.mts +10 -0
- package/dist/types/plugins/collapse.d.ts +10 -0
- package/dist/types/plugins/focus.d.mts +15 -0
- package/dist/types/plugins/focus.d.ts +15 -0
- package/dist/types/plugins/index.d.mts +7 -0
- package/dist/types/plugins/index.d.ts +7 -0
- package/dist/types/plugins/intersect.d.mts +11 -0
- package/dist/types/plugins/intersect.d.ts +11 -0
- package/dist/types/plugins/mask.d.mts +8 -0
- package/dist/types/plugins/mask.d.ts +8 -0
- package/dist/types/plugins/persist.d.mts +59 -0
- package/dist/types/plugins/persist.d.ts +59 -0
- package/dist/types/plugins/transition.d.mts +17 -0
- package/dist/types/plugins/transition.d.ts +17 -0
- package/dist/types/scheduler.d.mts +2 -0
- package/dist/types/scheduler.d.ts +2 -0
- package/dist/types/store.d.mts +10 -0
- package/dist/types/store.d.ts +10 -0
- package/dist/types/utils.d.mts +2 -0
- package/dist/types/utils.d.ts +2 -0
- package/dist/types/walk.d.mts +3 -0
- package/dist/types/walk.d.ts +3 -0
- package/package.json +124 -0
|
@@ -0,0 +1,1282 @@
|
|
|
1
|
+
const intersect = (app) => {
|
|
2
|
+
app.directive("intersect", ({ el, get, modifiers }) => {
|
|
3
|
+
const observer = new IntersectionObserver(
|
|
4
|
+
(entries) => {
|
|
5
|
+
for (const entry of entries) {
|
|
6
|
+
const hit = modifiers?.leave ? !entry.isIntersecting : entry.isIntersecting;
|
|
7
|
+
if (hit) {
|
|
8
|
+
get();
|
|
9
|
+
if (modifiers?.once) observer.disconnect();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
{ threshold: modifiers?.full ? 1 : 0 }
|
|
14
|
+
);
|
|
15
|
+
observer.observe(el);
|
|
16
|
+
return () => observer.disconnect();
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const tokens = {
|
|
21
|
+
"9": /\d/,
|
|
22
|
+
a: /[a-zA-Z]/,
|
|
23
|
+
"*": /[a-zA-Z0-9]/
|
|
24
|
+
};
|
|
25
|
+
const format = (value, mask2) => {
|
|
26
|
+
let out = "";
|
|
27
|
+
let literals = "";
|
|
28
|
+
let vi = 0;
|
|
29
|
+
for (let mi = 0; mi < mask2.length; mi++) {
|
|
30
|
+
const re = tokens[mask2[mi]];
|
|
31
|
+
if (re) {
|
|
32
|
+
while (vi < value.length && !re.test(value[vi])) vi++;
|
|
33
|
+
if (vi >= value.length) break;
|
|
34
|
+
out += literals + value[vi++];
|
|
35
|
+
literals = "";
|
|
36
|
+
} else {
|
|
37
|
+
literals += mask2[mi];
|
|
38
|
+
if (value[vi] === mask2[mi]) vi++;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
};
|
|
43
|
+
const mask = (app) => {
|
|
44
|
+
app.directive("mask", ({ el, exp }) => {
|
|
45
|
+
const input = el;
|
|
46
|
+
const apply = () => {
|
|
47
|
+
const masked = format(input.value, exp);
|
|
48
|
+
if (masked !== input.value) input.value = masked;
|
|
49
|
+
};
|
|
50
|
+
el.addEventListener("input", apply);
|
|
51
|
+
apply();
|
|
52
|
+
return () => el.removeEventListener("input", apply);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const toMs = (v) => (parseFloat(v) || 0) * (v.includes("ms") ? 1 : 1e3);
|
|
57
|
+
const maxOf = (durations, delays) => {
|
|
58
|
+
const ds = durations.split(",");
|
|
59
|
+
const dl = delays.split(",");
|
|
60
|
+
let max = 0;
|
|
61
|
+
for (let i = 0; i < ds.length; i++) {
|
|
62
|
+
max = Math.max(max, toMs(ds[i]) + toMs(dl[i % dl.length]));
|
|
63
|
+
}
|
|
64
|
+
return max;
|
|
65
|
+
};
|
|
66
|
+
const durationOf = (el) => {
|
|
67
|
+
const s = getComputedStyle(el);
|
|
68
|
+
return Math.max(
|
|
69
|
+
maxOf(s.transitionDuration, s.transitionDelay),
|
|
70
|
+
maxOf(s.animationDuration, s.animationDelay)
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
const transition = (app) => {
|
|
74
|
+
app.directive("transition", ({ el, get, effect, arg, modifiers, exp }) => {
|
|
75
|
+
const elem = el;
|
|
76
|
+
const name = arg || "v";
|
|
77
|
+
const cls = (phase) => `${name}-${phase}`;
|
|
78
|
+
let seq = 0;
|
|
79
|
+
let first = true;
|
|
80
|
+
const clear = () => {
|
|
81
|
+
elem.classList.remove(
|
|
82
|
+
cls("enter-from"),
|
|
83
|
+
cls("enter-active"),
|
|
84
|
+
cls("enter-to"),
|
|
85
|
+
cls("leave-from"),
|
|
86
|
+
cls("leave-active"),
|
|
87
|
+
cls("leave-to")
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
const run = (phase, done) => {
|
|
91
|
+
const id = ++seq;
|
|
92
|
+
clear();
|
|
93
|
+
elem.classList.add(cls(phase + "-from"), cls(phase + "-active"));
|
|
94
|
+
void elem.offsetWidth;
|
|
95
|
+
elem.classList.remove(cls(phase + "-from"));
|
|
96
|
+
elem.classList.add(cls(phase + "-to"));
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
if (id === seq) {
|
|
99
|
+
clear();
|
|
100
|
+
if (done) done();
|
|
101
|
+
}
|
|
102
|
+
}, durationOf(elem));
|
|
103
|
+
};
|
|
104
|
+
if (!exp) {
|
|
105
|
+
Promise.resolve().then(() => run("enter"));
|
|
106
|
+
elem.__leave = () => new Promise((resolve) => run("leave", resolve));
|
|
107
|
+
return () => {
|
|
108
|
+
delete elem.__leave;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
effect(() => {
|
|
112
|
+
const show = !!get();
|
|
113
|
+
if (first) {
|
|
114
|
+
first = false;
|
|
115
|
+
elem.style.display = show ? "" : "none";
|
|
116
|
+
if (show && modifiers?.appear) run("enter");
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (show) {
|
|
120
|
+
elem.style.display = "";
|
|
121
|
+
run("enter");
|
|
122
|
+
} else {
|
|
123
|
+
run("leave", () => {
|
|
124
|
+
elem.style.display = "none";
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @vue/shared v3.4.38
|
|
133
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
134
|
+
* @license MIT
|
|
135
|
+
**/
|
|
136
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
137
|
+
// @__NO_SIDE_EFFECTS__
|
|
138
|
+
function makeMap(str, expectsLowerCase) {
|
|
139
|
+
const set = new Set(str.split(","));
|
|
140
|
+
return (val) => set.has(val);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
!!(process.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
|
|
144
|
+
!!(process.env.NODE_ENV !== "production") ? Object.freeze([]) : [];
|
|
145
|
+
const NOOP = () => {
|
|
146
|
+
};
|
|
147
|
+
const extend = Object.assign;
|
|
148
|
+
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
149
|
+
const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
|
|
150
|
+
const isArray = Array.isArray;
|
|
151
|
+
const isMap = (val) => toTypeString(val) === "[object Map]";
|
|
152
|
+
const isString = (val) => typeof val === "string";
|
|
153
|
+
const isSymbol = (val) => typeof val === "symbol";
|
|
154
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
155
|
+
const objectToString = Object.prototype.toString;
|
|
156
|
+
const toTypeString = (value) => objectToString.call(value);
|
|
157
|
+
const toRawType = (value) => {
|
|
158
|
+
return toTypeString(value).slice(8, -1);
|
|
159
|
+
};
|
|
160
|
+
const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
161
|
+
const cacheStringFunction = (fn) => {
|
|
162
|
+
const cache = /* @__PURE__ */ Object.create(null);
|
|
163
|
+
return (str) => {
|
|
164
|
+
const hit = cache[str];
|
|
165
|
+
return hit || (cache[str] = fn(str));
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
const capitalize = cacheStringFunction((str) => {
|
|
169
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
170
|
+
});
|
|
171
|
+
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @vue/reactivity v3.4.38
|
|
175
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
176
|
+
* @license MIT
|
|
177
|
+
**/
|
|
178
|
+
|
|
179
|
+
function warn(msg, ...args) {
|
|
180
|
+
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
let activeEffectScope;
|
|
184
|
+
function recordEffectScope(effect, scope = activeEffectScope) {
|
|
185
|
+
if (scope && scope.active) {
|
|
186
|
+
scope.effects.push(effect);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
let activeEffect;
|
|
191
|
+
class ReactiveEffect {
|
|
192
|
+
constructor(fn, trigger, scheduler, scope) {
|
|
193
|
+
this.fn = fn;
|
|
194
|
+
this.trigger = trigger;
|
|
195
|
+
this.scheduler = scheduler;
|
|
196
|
+
this.active = true;
|
|
197
|
+
this.deps = [];
|
|
198
|
+
/**
|
|
199
|
+
* @internal
|
|
200
|
+
*/
|
|
201
|
+
this._dirtyLevel = 4;
|
|
202
|
+
/**
|
|
203
|
+
* @internal
|
|
204
|
+
*/
|
|
205
|
+
this._trackId = 0;
|
|
206
|
+
/**
|
|
207
|
+
* @internal
|
|
208
|
+
*/
|
|
209
|
+
this._runnings = 0;
|
|
210
|
+
/**
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
213
|
+
this._shouldSchedule = false;
|
|
214
|
+
/**
|
|
215
|
+
* @internal
|
|
216
|
+
*/
|
|
217
|
+
this._depsLength = 0;
|
|
218
|
+
recordEffectScope(this, scope);
|
|
219
|
+
}
|
|
220
|
+
get dirty() {
|
|
221
|
+
if (this._dirtyLevel === 2 || this._dirtyLevel === 3) {
|
|
222
|
+
this._dirtyLevel = 1;
|
|
223
|
+
pauseTracking();
|
|
224
|
+
for (let i = 0; i < this._depsLength; i++) {
|
|
225
|
+
const dep = this.deps[i];
|
|
226
|
+
if (dep.computed) {
|
|
227
|
+
triggerComputed(dep.computed);
|
|
228
|
+
if (this._dirtyLevel >= 4) {
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (this._dirtyLevel === 1) {
|
|
234
|
+
this._dirtyLevel = 0;
|
|
235
|
+
}
|
|
236
|
+
resetTracking();
|
|
237
|
+
}
|
|
238
|
+
return this._dirtyLevel >= 4;
|
|
239
|
+
}
|
|
240
|
+
set dirty(v) {
|
|
241
|
+
this._dirtyLevel = v ? 4 : 0;
|
|
242
|
+
}
|
|
243
|
+
run() {
|
|
244
|
+
this._dirtyLevel = 0;
|
|
245
|
+
if (!this.active) {
|
|
246
|
+
return this.fn();
|
|
247
|
+
}
|
|
248
|
+
let lastShouldTrack = shouldTrack;
|
|
249
|
+
let lastEffect = activeEffect;
|
|
250
|
+
try {
|
|
251
|
+
shouldTrack = true;
|
|
252
|
+
activeEffect = this;
|
|
253
|
+
this._runnings++;
|
|
254
|
+
preCleanupEffect(this);
|
|
255
|
+
return this.fn();
|
|
256
|
+
} finally {
|
|
257
|
+
postCleanupEffect(this);
|
|
258
|
+
this._runnings--;
|
|
259
|
+
activeEffect = lastEffect;
|
|
260
|
+
shouldTrack = lastShouldTrack;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
stop() {
|
|
264
|
+
if (this.active) {
|
|
265
|
+
preCleanupEffect(this);
|
|
266
|
+
postCleanupEffect(this);
|
|
267
|
+
this.onStop && this.onStop();
|
|
268
|
+
this.active = false;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function triggerComputed(computed) {
|
|
273
|
+
return computed.value;
|
|
274
|
+
}
|
|
275
|
+
function preCleanupEffect(effect2) {
|
|
276
|
+
effect2._trackId++;
|
|
277
|
+
effect2._depsLength = 0;
|
|
278
|
+
}
|
|
279
|
+
function postCleanupEffect(effect2) {
|
|
280
|
+
if (effect2.deps.length > effect2._depsLength) {
|
|
281
|
+
for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
|
|
282
|
+
cleanupDepEffect(effect2.deps[i], effect2);
|
|
283
|
+
}
|
|
284
|
+
effect2.deps.length = effect2._depsLength;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function cleanupDepEffect(dep, effect2) {
|
|
288
|
+
const trackId = dep.get(effect2);
|
|
289
|
+
if (trackId !== void 0 && effect2._trackId !== trackId) {
|
|
290
|
+
dep.delete(effect2);
|
|
291
|
+
if (dep.size === 0) {
|
|
292
|
+
dep.cleanup();
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
function effect(fn, options) {
|
|
297
|
+
if (fn.effect instanceof ReactiveEffect) {
|
|
298
|
+
fn = fn.effect.fn;
|
|
299
|
+
}
|
|
300
|
+
const _effect = new ReactiveEffect(fn, NOOP, () => {
|
|
301
|
+
if (_effect.dirty) {
|
|
302
|
+
_effect.run();
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
if (options) {
|
|
306
|
+
extend(_effect, options);
|
|
307
|
+
if (options.scope) recordEffectScope(_effect, options.scope);
|
|
308
|
+
}
|
|
309
|
+
if (!options || !options.lazy) {
|
|
310
|
+
_effect.run();
|
|
311
|
+
}
|
|
312
|
+
const runner = _effect.run.bind(_effect);
|
|
313
|
+
runner.effect = _effect;
|
|
314
|
+
return runner;
|
|
315
|
+
}
|
|
316
|
+
function stop(runner) {
|
|
317
|
+
runner.effect.stop();
|
|
318
|
+
}
|
|
319
|
+
let shouldTrack = true;
|
|
320
|
+
let pauseScheduleStack = 0;
|
|
321
|
+
const trackStack = [];
|
|
322
|
+
function pauseTracking() {
|
|
323
|
+
trackStack.push(shouldTrack);
|
|
324
|
+
shouldTrack = false;
|
|
325
|
+
}
|
|
326
|
+
function resetTracking() {
|
|
327
|
+
const last = trackStack.pop();
|
|
328
|
+
shouldTrack = last === void 0 ? true : last;
|
|
329
|
+
}
|
|
330
|
+
function pauseScheduling() {
|
|
331
|
+
pauseScheduleStack++;
|
|
332
|
+
}
|
|
333
|
+
function resetScheduling() {
|
|
334
|
+
pauseScheduleStack--;
|
|
335
|
+
while (!pauseScheduleStack && queueEffectSchedulers.length) {
|
|
336
|
+
queueEffectSchedulers.shift()();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
function trackEffect(effect2, dep, debuggerEventExtraInfo) {
|
|
340
|
+
var _a;
|
|
341
|
+
if (dep.get(effect2) !== effect2._trackId) {
|
|
342
|
+
dep.set(effect2, effect2._trackId);
|
|
343
|
+
const oldDep = effect2.deps[effect2._depsLength];
|
|
344
|
+
if (oldDep !== dep) {
|
|
345
|
+
if (oldDep) {
|
|
346
|
+
cleanupDepEffect(oldDep, effect2);
|
|
347
|
+
}
|
|
348
|
+
effect2.deps[effect2._depsLength++] = dep;
|
|
349
|
+
} else {
|
|
350
|
+
effect2._depsLength++;
|
|
351
|
+
}
|
|
352
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
353
|
+
(_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
const queueEffectSchedulers = [];
|
|
358
|
+
function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
|
|
359
|
+
var _a;
|
|
360
|
+
pauseScheduling();
|
|
361
|
+
for (const effect2 of dep.keys()) {
|
|
362
|
+
let tracking;
|
|
363
|
+
if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
|
364
|
+
effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0);
|
|
365
|
+
effect2._dirtyLevel = dirtyLevel;
|
|
366
|
+
}
|
|
367
|
+
if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) {
|
|
368
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
369
|
+
(_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
|
|
370
|
+
}
|
|
371
|
+
effect2.trigger();
|
|
372
|
+
if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) {
|
|
373
|
+
effect2._shouldSchedule = false;
|
|
374
|
+
if (effect2.scheduler) {
|
|
375
|
+
queueEffectSchedulers.push(effect2.scheduler);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
resetScheduling();
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
const createDep = (cleanup, computed) => {
|
|
384
|
+
const dep = /* @__PURE__ */ new Map();
|
|
385
|
+
dep.cleanup = cleanup;
|
|
386
|
+
dep.computed = computed;
|
|
387
|
+
return dep;
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
391
|
+
const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
|
|
392
|
+
const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map key iterate" : "");
|
|
393
|
+
function track(target, type, key) {
|
|
394
|
+
if (shouldTrack && activeEffect) {
|
|
395
|
+
let depsMap = targetMap.get(target);
|
|
396
|
+
if (!depsMap) {
|
|
397
|
+
targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
|
|
398
|
+
}
|
|
399
|
+
let dep = depsMap.get(key);
|
|
400
|
+
if (!dep) {
|
|
401
|
+
depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
|
|
402
|
+
}
|
|
403
|
+
trackEffect(
|
|
404
|
+
activeEffect,
|
|
405
|
+
dep,
|
|
406
|
+
!!(process.env.NODE_ENV !== "production") ? {
|
|
407
|
+
target,
|
|
408
|
+
type,
|
|
409
|
+
key
|
|
410
|
+
} : void 0
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
415
|
+
const depsMap = targetMap.get(target);
|
|
416
|
+
if (!depsMap) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
let deps = [];
|
|
420
|
+
if (type === "clear") {
|
|
421
|
+
deps = [...depsMap.values()];
|
|
422
|
+
} else if (key === "length" && isArray(target)) {
|
|
423
|
+
const newLength = Number(newValue);
|
|
424
|
+
depsMap.forEach((dep, key2) => {
|
|
425
|
+
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
|
|
426
|
+
deps.push(dep);
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
} else {
|
|
430
|
+
if (key !== void 0) {
|
|
431
|
+
deps.push(depsMap.get(key));
|
|
432
|
+
}
|
|
433
|
+
switch (type) {
|
|
434
|
+
case "add":
|
|
435
|
+
if (!isArray(target)) {
|
|
436
|
+
deps.push(depsMap.get(ITERATE_KEY));
|
|
437
|
+
if (isMap(target)) {
|
|
438
|
+
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
439
|
+
}
|
|
440
|
+
} else if (isIntegerKey(key)) {
|
|
441
|
+
deps.push(depsMap.get("length"));
|
|
442
|
+
}
|
|
443
|
+
break;
|
|
444
|
+
case "delete":
|
|
445
|
+
if (!isArray(target)) {
|
|
446
|
+
deps.push(depsMap.get(ITERATE_KEY));
|
|
447
|
+
if (isMap(target)) {
|
|
448
|
+
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
break;
|
|
452
|
+
case "set":
|
|
453
|
+
if (isMap(target)) {
|
|
454
|
+
deps.push(depsMap.get(ITERATE_KEY));
|
|
455
|
+
}
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
pauseScheduling();
|
|
460
|
+
for (const dep of deps) {
|
|
461
|
+
if (dep) {
|
|
462
|
+
triggerEffects(
|
|
463
|
+
dep,
|
|
464
|
+
4,
|
|
465
|
+
!!(process.env.NODE_ENV !== "production") ? {
|
|
466
|
+
target,
|
|
467
|
+
type,
|
|
468
|
+
key,
|
|
469
|
+
newValue,
|
|
470
|
+
oldValue,
|
|
471
|
+
oldTarget
|
|
472
|
+
} : void 0
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
resetScheduling();
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
480
|
+
const builtInSymbols = new Set(
|
|
481
|
+
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
|
|
482
|
+
);
|
|
483
|
+
const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
|
|
484
|
+
function createArrayInstrumentations() {
|
|
485
|
+
const instrumentations = {};
|
|
486
|
+
["includes", "indexOf", "lastIndexOf"].forEach((key) => {
|
|
487
|
+
instrumentations[key] = function(...args) {
|
|
488
|
+
const arr = toRaw(this);
|
|
489
|
+
for (let i = 0, l = this.length; i < l; i++) {
|
|
490
|
+
track(arr, "get", i + "");
|
|
491
|
+
}
|
|
492
|
+
const res = arr[key](...args);
|
|
493
|
+
if (res === -1 || res === false) {
|
|
494
|
+
return arr[key](...args.map(toRaw));
|
|
495
|
+
} else {
|
|
496
|
+
return res;
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
});
|
|
500
|
+
["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
|
|
501
|
+
instrumentations[key] = function(...args) {
|
|
502
|
+
pauseTracking();
|
|
503
|
+
pauseScheduling();
|
|
504
|
+
const res = toRaw(this)[key].apply(this, args);
|
|
505
|
+
resetScheduling();
|
|
506
|
+
resetTracking();
|
|
507
|
+
return res;
|
|
508
|
+
};
|
|
509
|
+
});
|
|
510
|
+
return instrumentations;
|
|
511
|
+
}
|
|
512
|
+
function hasOwnProperty(key) {
|
|
513
|
+
if (!isSymbol(key)) key = String(key);
|
|
514
|
+
const obj = toRaw(this);
|
|
515
|
+
track(obj, "has", key);
|
|
516
|
+
return obj.hasOwnProperty(key);
|
|
517
|
+
}
|
|
518
|
+
class BaseReactiveHandler {
|
|
519
|
+
constructor(_isReadonly = false, _isShallow = false) {
|
|
520
|
+
this._isReadonly = _isReadonly;
|
|
521
|
+
this._isShallow = _isShallow;
|
|
522
|
+
}
|
|
523
|
+
get(target, key, receiver) {
|
|
524
|
+
const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
|
|
525
|
+
if (key === "__v_isReactive") {
|
|
526
|
+
return !isReadonly2;
|
|
527
|
+
} else if (key === "__v_isReadonly") {
|
|
528
|
+
return isReadonly2;
|
|
529
|
+
} else if (key === "__v_isShallow") {
|
|
530
|
+
return isShallow2;
|
|
531
|
+
} else if (key === "__v_raw") {
|
|
532
|
+
if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
|
|
533
|
+
// this means the receiver is a user proxy of the reactive proxy
|
|
534
|
+
Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
|
|
535
|
+
return target;
|
|
536
|
+
}
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
const targetIsArray = isArray(target);
|
|
540
|
+
if (!isReadonly2) {
|
|
541
|
+
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
|
|
542
|
+
return Reflect.get(arrayInstrumentations, key, receiver);
|
|
543
|
+
}
|
|
544
|
+
if (key === "hasOwnProperty") {
|
|
545
|
+
return hasOwnProperty;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
const res = Reflect.get(target, key, receiver);
|
|
549
|
+
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
550
|
+
return res;
|
|
551
|
+
}
|
|
552
|
+
if (!isReadonly2) {
|
|
553
|
+
track(target, "get", key);
|
|
554
|
+
}
|
|
555
|
+
if (isShallow2) {
|
|
556
|
+
return res;
|
|
557
|
+
}
|
|
558
|
+
if (isRef(res)) {
|
|
559
|
+
return targetIsArray && isIntegerKey(key) ? res : res.value;
|
|
560
|
+
}
|
|
561
|
+
if (isObject(res)) {
|
|
562
|
+
return isReadonly2 ? readonly(res) : reactive(res);
|
|
563
|
+
}
|
|
564
|
+
return res;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
class MutableReactiveHandler extends BaseReactiveHandler {
|
|
568
|
+
constructor(isShallow2 = false) {
|
|
569
|
+
super(false, isShallow2);
|
|
570
|
+
}
|
|
571
|
+
set(target, key, value, receiver) {
|
|
572
|
+
let oldValue = target[key];
|
|
573
|
+
if (!this._isShallow) {
|
|
574
|
+
const isOldValueReadonly = isReadonly(oldValue);
|
|
575
|
+
if (!isShallow(value) && !isReadonly(value)) {
|
|
576
|
+
oldValue = toRaw(oldValue);
|
|
577
|
+
value = toRaw(value);
|
|
578
|
+
}
|
|
579
|
+
if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
|
|
580
|
+
if (isOldValueReadonly) {
|
|
581
|
+
return false;
|
|
582
|
+
} else {
|
|
583
|
+
oldValue.value = value;
|
|
584
|
+
return true;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
|
|
589
|
+
const result = Reflect.set(target, key, value, receiver);
|
|
590
|
+
if (target === toRaw(receiver)) {
|
|
591
|
+
if (!hadKey) {
|
|
592
|
+
trigger(target, "add", key, value);
|
|
593
|
+
} else if (hasChanged(value, oldValue)) {
|
|
594
|
+
trigger(target, "set", key, value, oldValue);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
return result;
|
|
598
|
+
}
|
|
599
|
+
deleteProperty(target, key) {
|
|
600
|
+
const hadKey = hasOwn(target, key);
|
|
601
|
+
const oldValue = target[key];
|
|
602
|
+
const result = Reflect.deleteProperty(target, key);
|
|
603
|
+
if (result && hadKey) {
|
|
604
|
+
trigger(target, "delete", key, void 0, oldValue);
|
|
605
|
+
}
|
|
606
|
+
return result;
|
|
607
|
+
}
|
|
608
|
+
has(target, key) {
|
|
609
|
+
const result = Reflect.has(target, key);
|
|
610
|
+
if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
|
611
|
+
track(target, "has", key);
|
|
612
|
+
}
|
|
613
|
+
return result;
|
|
614
|
+
}
|
|
615
|
+
ownKeys(target) {
|
|
616
|
+
track(
|
|
617
|
+
target,
|
|
618
|
+
"iterate",
|
|
619
|
+
isArray(target) ? "length" : ITERATE_KEY
|
|
620
|
+
);
|
|
621
|
+
return Reflect.ownKeys(target);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
class ReadonlyReactiveHandler extends BaseReactiveHandler {
|
|
625
|
+
constructor(isShallow2 = false) {
|
|
626
|
+
super(true, isShallow2);
|
|
627
|
+
}
|
|
628
|
+
set(target, key) {
|
|
629
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
630
|
+
warn(
|
|
631
|
+
`Set operation on key "${String(key)}" failed: target is readonly.`,
|
|
632
|
+
target
|
|
633
|
+
);
|
|
634
|
+
}
|
|
635
|
+
return true;
|
|
636
|
+
}
|
|
637
|
+
deleteProperty(target, key) {
|
|
638
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
639
|
+
warn(
|
|
640
|
+
`Delete operation on key "${String(key)}" failed: target is readonly.`,
|
|
641
|
+
target
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
return true;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
|
|
648
|
+
const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
|
|
649
|
+
|
|
650
|
+
const toShallow = (value) => value;
|
|
651
|
+
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
652
|
+
function get(target, key, isReadonly2 = false, isShallow2 = false) {
|
|
653
|
+
target = target["__v_raw"];
|
|
654
|
+
const rawTarget = toRaw(target);
|
|
655
|
+
const rawKey = toRaw(key);
|
|
656
|
+
if (!isReadonly2) {
|
|
657
|
+
if (hasChanged(key, rawKey)) {
|
|
658
|
+
track(rawTarget, "get", key);
|
|
659
|
+
}
|
|
660
|
+
track(rawTarget, "get", rawKey);
|
|
661
|
+
}
|
|
662
|
+
const { has: has2 } = getProto(rawTarget);
|
|
663
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
664
|
+
if (has2.call(rawTarget, key)) {
|
|
665
|
+
return wrap(target.get(key));
|
|
666
|
+
} else if (has2.call(rawTarget, rawKey)) {
|
|
667
|
+
return wrap(target.get(rawKey));
|
|
668
|
+
} else if (target !== rawTarget) {
|
|
669
|
+
target.get(key);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
function has(key, isReadonly2 = false) {
|
|
673
|
+
const target = this["__v_raw"];
|
|
674
|
+
const rawTarget = toRaw(target);
|
|
675
|
+
const rawKey = toRaw(key);
|
|
676
|
+
if (!isReadonly2) {
|
|
677
|
+
if (hasChanged(key, rawKey)) {
|
|
678
|
+
track(rawTarget, "has", key);
|
|
679
|
+
}
|
|
680
|
+
track(rawTarget, "has", rawKey);
|
|
681
|
+
}
|
|
682
|
+
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
683
|
+
}
|
|
684
|
+
function size(target, isReadonly2 = false) {
|
|
685
|
+
target = target["__v_raw"];
|
|
686
|
+
!isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
687
|
+
return Reflect.get(target, "size", target);
|
|
688
|
+
}
|
|
689
|
+
function add(value, _isShallow = false) {
|
|
690
|
+
if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
|
|
691
|
+
value = toRaw(value);
|
|
692
|
+
}
|
|
693
|
+
const target = toRaw(this);
|
|
694
|
+
const proto = getProto(target);
|
|
695
|
+
const hadKey = proto.has.call(target, value);
|
|
696
|
+
if (!hadKey) {
|
|
697
|
+
target.add(value);
|
|
698
|
+
trigger(target, "add", value, value);
|
|
699
|
+
}
|
|
700
|
+
return this;
|
|
701
|
+
}
|
|
702
|
+
function set(key, value, _isShallow = false) {
|
|
703
|
+
if (!_isShallow && !isShallow(value) && !isReadonly(value)) {
|
|
704
|
+
value = toRaw(value);
|
|
705
|
+
}
|
|
706
|
+
const target = toRaw(this);
|
|
707
|
+
const { has: has2, get: get2 } = getProto(target);
|
|
708
|
+
let hadKey = has2.call(target, key);
|
|
709
|
+
if (!hadKey) {
|
|
710
|
+
key = toRaw(key);
|
|
711
|
+
hadKey = has2.call(target, key);
|
|
712
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
713
|
+
checkIdentityKeys(target, has2, key);
|
|
714
|
+
}
|
|
715
|
+
const oldValue = get2.call(target, key);
|
|
716
|
+
target.set(key, value);
|
|
717
|
+
if (!hadKey) {
|
|
718
|
+
trigger(target, "add", key, value);
|
|
719
|
+
} else if (hasChanged(value, oldValue)) {
|
|
720
|
+
trigger(target, "set", key, value, oldValue);
|
|
721
|
+
}
|
|
722
|
+
return this;
|
|
723
|
+
}
|
|
724
|
+
function deleteEntry(key) {
|
|
725
|
+
const target = toRaw(this);
|
|
726
|
+
const { has: has2, get: get2 } = getProto(target);
|
|
727
|
+
let hadKey = has2.call(target, key);
|
|
728
|
+
if (!hadKey) {
|
|
729
|
+
key = toRaw(key);
|
|
730
|
+
hadKey = has2.call(target, key);
|
|
731
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
732
|
+
checkIdentityKeys(target, has2, key);
|
|
733
|
+
}
|
|
734
|
+
const oldValue = get2 ? get2.call(target, key) : void 0;
|
|
735
|
+
const result = target.delete(key);
|
|
736
|
+
if (hadKey) {
|
|
737
|
+
trigger(target, "delete", key, void 0, oldValue);
|
|
738
|
+
}
|
|
739
|
+
return result;
|
|
740
|
+
}
|
|
741
|
+
function clear() {
|
|
742
|
+
const target = toRaw(this);
|
|
743
|
+
const hadItems = target.size !== 0;
|
|
744
|
+
const oldTarget = !!(process.env.NODE_ENV !== "production") ? isMap(target) ? new Map(target) : new Set(target) : void 0;
|
|
745
|
+
const result = target.clear();
|
|
746
|
+
if (hadItems) {
|
|
747
|
+
trigger(target, "clear", void 0, void 0, oldTarget);
|
|
748
|
+
}
|
|
749
|
+
return result;
|
|
750
|
+
}
|
|
751
|
+
function createForEach(isReadonly2, isShallow2) {
|
|
752
|
+
return function forEach(callback, thisArg) {
|
|
753
|
+
const observed = this;
|
|
754
|
+
const target = observed["__v_raw"];
|
|
755
|
+
const rawTarget = toRaw(target);
|
|
756
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
757
|
+
!isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY);
|
|
758
|
+
return target.forEach((value, key) => {
|
|
759
|
+
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
760
|
+
});
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
764
|
+
return function(...args) {
|
|
765
|
+
const target = this["__v_raw"];
|
|
766
|
+
const rawTarget = toRaw(target);
|
|
767
|
+
const targetIsMap = isMap(rawTarget);
|
|
768
|
+
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
769
|
+
const isKeyOnly = method === "keys" && targetIsMap;
|
|
770
|
+
const innerIterator = target[method](...args);
|
|
771
|
+
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
772
|
+
!isReadonly2 && track(
|
|
773
|
+
rawTarget,
|
|
774
|
+
"iterate",
|
|
775
|
+
isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
|
776
|
+
);
|
|
777
|
+
return {
|
|
778
|
+
// iterator protocol
|
|
779
|
+
next() {
|
|
780
|
+
const { value, done } = innerIterator.next();
|
|
781
|
+
return done ? { value, done } : {
|
|
782
|
+
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
|
783
|
+
done
|
|
784
|
+
};
|
|
785
|
+
},
|
|
786
|
+
// iterable protocol
|
|
787
|
+
[Symbol.iterator]() {
|
|
788
|
+
return this;
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
function createReadonlyMethod(type) {
|
|
794
|
+
return function(...args) {
|
|
795
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
796
|
+
const key = args[0] ? `on key "${args[0]}" ` : ``;
|
|
797
|
+
warn(
|
|
798
|
+
`${capitalize(type)} operation ${key}failed: target is readonly.`,
|
|
799
|
+
toRaw(this)
|
|
800
|
+
);
|
|
801
|
+
}
|
|
802
|
+
return type === "delete" ? false : type === "clear" ? void 0 : this;
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
function createInstrumentations() {
|
|
806
|
+
const mutableInstrumentations2 = {
|
|
807
|
+
get(key) {
|
|
808
|
+
return get(this, key);
|
|
809
|
+
},
|
|
810
|
+
get size() {
|
|
811
|
+
return size(this);
|
|
812
|
+
},
|
|
813
|
+
has,
|
|
814
|
+
add,
|
|
815
|
+
set,
|
|
816
|
+
delete: deleteEntry,
|
|
817
|
+
clear,
|
|
818
|
+
forEach: createForEach(false, false)
|
|
819
|
+
};
|
|
820
|
+
const shallowInstrumentations2 = {
|
|
821
|
+
get(key) {
|
|
822
|
+
return get(this, key, false, true);
|
|
823
|
+
},
|
|
824
|
+
get size() {
|
|
825
|
+
return size(this);
|
|
826
|
+
},
|
|
827
|
+
has,
|
|
828
|
+
add(value) {
|
|
829
|
+
return add.call(this, value, true);
|
|
830
|
+
},
|
|
831
|
+
set(key, value) {
|
|
832
|
+
return set.call(this, key, value, true);
|
|
833
|
+
},
|
|
834
|
+
delete: deleteEntry,
|
|
835
|
+
clear,
|
|
836
|
+
forEach: createForEach(false, true)
|
|
837
|
+
};
|
|
838
|
+
const readonlyInstrumentations2 = {
|
|
839
|
+
get(key) {
|
|
840
|
+
return get(this, key, true);
|
|
841
|
+
},
|
|
842
|
+
get size() {
|
|
843
|
+
return size(this, true);
|
|
844
|
+
},
|
|
845
|
+
has(key) {
|
|
846
|
+
return has.call(this, key, true);
|
|
847
|
+
},
|
|
848
|
+
add: createReadonlyMethod("add"),
|
|
849
|
+
set: createReadonlyMethod("set"),
|
|
850
|
+
delete: createReadonlyMethod("delete"),
|
|
851
|
+
clear: createReadonlyMethod("clear"),
|
|
852
|
+
forEach: createForEach(true, false)
|
|
853
|
+
};
|
|
854
|
+
const shallowReadonlyInstrumentations2 = {
|
|
855
|
+
get(key) {
|
|
856
|
+
return get(this, key, true, true);
|
|
857
|
+
},
|
|
858
|
+
get size() {
|
|
859
|
+
return size(this, true);
|
|
860
|
+
},
|
|
861
|
+
has(key) {
|
|
862
|
+
return has.call(this, key, true);
|
|
863
|
+
},
|
|
864
|
+
add: createReadonlyMethod("add"),
|
|
865
|
+
set: createReadonlyMethod("set"),
|
|
866
|
+
delete: createReadonlyMethod("delete"),
|
|
867
|
+
clear: createReadonlyMethod("clear"),
|
|
868
|
+
forEach: createForEach(true, true)
|
|
869
|
+
};
|
|
870
|
+
const iteratorMethods = [
|
|
871
|
+
"keys",
|
|
872
|
+
"values",
|
|
873
|
+
"entries",
|
|
874
|
+
Symbol.iterator
|
|
875
|
+
];
|
|
876
|
+
iteratorMethods.forEach((method) => {
|
|
877
|
+
mutableInstrumentations2[method] = createIterableMethod(method, false, false);
|
|
878
|
+
readonlyInstrumentations2[method] = createIterableMethod(method, true, false);
|
|
879
|
+
shallowInstrumentations2[method] = createIterableMethod(method, false, true);
|
|
880
|
+
shallowReadonlyInstrumentations2[method] = createIterableMethod(
|
|
881
|
+
method,
|
|
882
|
+
true,
|
|
883
|
+
true
|
|
884
|
+
);
|
|
885
|
+
});
|
|
886
|
+
return [
|
|
887
|
+
mutableInstrumentations2,
|
|
888
|
+
readonlyInstrumentations2,
|
|
889
|
+
shallowInstrumentations2,
|
|
890
|
+
shallowReadonlyInstrumentations2
|
|
891
|
+
];
|
|
892
|
+
}
|
|
893
|
+
const [
|
|
894
|
+
mutableInstrumentations,
|
|
895
|
+
readonlyInstrumentations,
|
|
896
|
+
shallowInstrumentations,
|
|
897
|
+
shallowReadonlyInstrumentations
|
|
898
|
+
] = /* @__PURE__ */ createInstrumentations();
|
|
899
|
+
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
900
|
+
const instrumentations = shallow ? isReadonly2 ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly2 ? readonlyInstrumentations : mutableInstrumentations;
|
|
901
|
+
return (target, key, receiver) => {
|
|
902
|
+
if (key === "__v_isReactive") {
|
|
903
|
+
return !isReadonly2;
|
|
904
|
+
} else if (key === "__v_isReadonly") {
|
|
905
|
+
return isReadonly2;
|
|
906
|
+
} else if (key === "__v_raw") {
|
|
907
|
+
return target;
|
|
908
|
+
}
|
|
909
|
+
return Reflect.get(
|
|
910
|
+
hasOwn(instrumentations, key) && key in target ? instrumentations : target,
|
|
911
|
+
key,
|
|
912
|
+
receiver
|
|
913
|
+
);
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
const mutableCollectionHandlers = {
|
|
917
|
+
get: /* @__PURE__ */ createInstrumentationGetter(false, false)
|
|
918
|
+
};
|
|
919
|
+
const readonlyCollectionHandlers = {
|
|
920
|
+
get: /* @__PURE__ */ createInstrumentationGetter(true, false)
|
|
921
|
+
};
|
|
922
|
+
function checkIdentityKeys(target, has2, key) {
|
|
923
|
+
const rawKey = toRaw(key);
|
|
924
|
+
if (rawKey !== key && has2.call(target, rawKey)) {
|
|
925
|
+
const type = toRawType(target);
|
|
926
|
+
warn(
|
|
927
|
+
`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`
|
|
928
|
+
);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
933
|
+
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
934
|
+
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
935
|
+
const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
|
|
936
|
+
function targetTypeMap(rawType) {
|
|
937
|
+
switch (rawType) {
|
|
938
|
+
case "Object":
|
|
939
|
+
case "Array":
|
|
940
|
+
return 1 /* COMMON */;
|
|
941
|
+
case "Map":
|
|
942
|
+
case "Set":
|
|
943
|
+
case "WeakMap":
|
|
944
|
+
case "WeakSet":
|
|
945
|
+
return 2 /* COLLECTION */;
|
|
946
|
+
default:
|
|
947
|
+
return 0 /* INVALID */;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
function getTargetType(value) {
|
|
951
|
+
return value["__v_skip"] || !Object.isExtensible(value) ? 0 /* INVALID */ : targetTypeMap(toRawType(value));
|
|
952
|
+
}
|
|
953
|
+
function reactive(target) {
|
|
954
|
+
if (isReadonly(target)) {
|
|
955
|
+
return target;
|
|
956
|
+
}
|
|
957
|
+
return createReactiveObject(
|
|
958
|
+
target,
|
|
959
|
+
false,
|
|
960
|
+
mutableHandlers,
|
|
961
|
+
mutableCollectionHandlers,
|
|
962
|
+
reactiveMap
|
|
963
|
+
);
|
|
964
|
+
}
|
|
965
|
+
function readonly(target) {
|
|
966
|
+
return createReactiveObject(
|
|
967
|
+
target,
|
|
968
|
+
true,
|
|
969
|
+
readonlyHandlers,
|
|
970
|
+
readonlyCollectionHandlers,
|
|
971
|
+
readonlyMap
|
|
972
|
+
);
|
|
973
|
+
}
|
|
974
|
+
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
|
975
|
+
if (!isObject(target)) {
|
|
976
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
977
|
+
warn(
|
|
978
|
+
`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(
|
|
979
|
+
target
|
|
980
|
+
)}`
|
|
981
|
+
);
|
|
982
|
+
}
|
|
983
|
+
return target;
|
|
984
|
+
}
|
|
985
|
+
if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
|
|
986
|
+
return target;
|
|
987
|
+
}
|
|
988
|
+
const existingProxy = proxyMap.get(target);
|
|
989
|
+
if (existingProxy) {
|
|
990
|
+
return existingProxy;
|
|
991
|
+
}
|
|
992
|
+
const targetType = getTargetType(target);
|
|
993
|
+
if (targetType === 0 /* INVALID */) {
|
|
994
|
+
return target;
|
|
995
|
+
}
|
|
996
|
+
const proxy = new Proxy(
|
|
997
|
+
target,
|
|
998
|
+
targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers
|
|
999
|
+
);
|
|
1000
|
+
proxyMap.set(target, proxy);
|
|
1001
|
+
return proxy;
|
|
1002
|
+
}
|
|
1003
|
+
function isReadonly(value) {
|
|
1004
|
+
return !!(value && value["__v_isReadonly"]);
|
|
1005
|
+
}
|
|
1006
|
+
function isShallow(value) {
|
|
1007
|
+
return !!(value && value["__v_isShallow"]);
|
|
1008
|
+
}
|
|
1009
|
+
function toRaw(observed) {
|
|
1010
|
+
const raw = observed && observed["__v_raw"];
|
|
1011
|
+
return raw ? toRaw(raw) : observed;
|
|
1012
|
+
}
|
|
1013
|
+
const toReactive = (value) => isObject(value) ? reactive(value) : value;
|
|
1014
|
+
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
|
|
1015
|
+
function isRef(r) {
|
|
1016
|
+
return !!(r && r.__v_isRef === true);
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
const scopes = /* @__PURE__ */ new Map();
|
|
1020
|
+
const exps = /* @__PURE__ */ new Map();
|
|
1021
|
+
const names = /* @__PURE__ */ new Map();
|
|
1022
|
+
const storeMap = /* @__PURE__ */ new Map();
|
|
1023
|
+
const isDisabled = () => typeof window !== "undefined" && window.__LITE_VUE_DEVTOOLS__ === false;
|
|
1024
|
+
const listeners = {
|
|
1025
|
+
"scope:mount": /* @__PURE__ */ new Set(),
|
|
1026
|
+
"scope:unmount": /* @__PURE__ */ new Set(),
|
|
1027
|
+
"store:register": /* @__PURE__ */ new Set(),
|
|
1028
|
+
flush: /* @__PURE__ */ new Set()
|
|
1029
|
+
};
|
|
1030
|
+
const emit = (event, ...args) => {
|
|
1031
|
+
listeners[event].forEach((fn) => fn(...args));
|
|
1032
|
+
};
|
|
1033
|
+
const emitFlush = () => {
|
|
1034
|
+
if (listeners.flush.size) {
|
|
1035
|
+
emit("flush");
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
const devtools = {
|
|
1039
|
+
scopes,
|
|
1040
|
+
exps,
|
|
1041
|
+
names,
|
|
1042
|
+
stores: storeMap,
|
|
1043
|
+
getScopeByName(name) {
|
|
1044
|
+
for (const [el, n] of names) {
|
|
1045
|
+
if (n === name) return scopes.get(el);
|
|
1046
|
+
}
|
|
1047
|
+
},
|
|
1048
|
+
getScope(node) {
|
|
1049
|
+
let el = node.nodeType === 1 ? node : node.parentElement;
|
|
1050
|
+
while (el) {
|
|
1051
|
+
const scope = scopes.get(el);
|
|
1052
|
+
if (scope) return scope;
|
|
1053
|
+
el = el.parentElement;
|
|
1054
|
+
}
|
|
1055
|
+
},
|
|
1056
|
+
on(event, fn) {
|
|
1057
|
+
listeners[event].add(fn);
|
|
1058
|
+
return () => listeners[event].delete(fn);
|
|
1059
|
+
},
|
|
1060
|
+
off(event, fn) {
|
|
1061
|
+
listeners[event].delete(fn);
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
if (typeof window !== "undefined" && !isDisabled()) {
|
|
1065
|
+
window.__LITE_VUE__ = devtools;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
let queued = false;
|
|
1069
|
+
const queue = [];
|
|
1070
|
+
const p = Promise.resolve();
|
|
1071
|
+
const nextTick = (fn) => p.then(fn);
|
|
1072
|
+
const queueJob = (job) => {
|
|
1073
|
+
if (!queue.includes(job)) queue.push(job);
|
|
1074
|
+
if (!queued) {
|
|
1075
|
+
queued = true;
|
|
1076
|
+
nextTick(flushJobs);
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
const flushJobs = () => {
|
|
1080
|
+
for (const job of queue) {
|
|
1081
|
+
job();
|
|
1082
|
+
}
|
|
1083
|
+
queue.length = 0;
|
|
1084
|
+
queued = false;
|
|
1085
|
+
emitFlush();
|
|
1086
|
+
};
|
|
1087
|
+
|
|
1088
|
+
const watchEffect = (fn) => {
|
|
1089
|
+
let runner;
|
|
1090
|
+
runner = effect(fn, { scheduler: () => queueJob(runner) });
|
|
1091
|
+
return () => stop(runner);
|
|
1092
|
+
};
|
|
1093
|
+
|
|
1094
|
+
const stores = reactive(/* @__PURE__ */ Object.create(null));
|
|
1095
|
+
const store = (name, value) => {
|
|
1096
|
+
return stores[name];
|
|
1097
|
+
};
|
|
1098
|
+
|
|
1099
|
+
const PREFIX = "litevue:";
|
|
1100
|
+
const registry = /* @__PURE__ */ Object.create(null);
|
|
1101
|
+
let defaultStorage = "local";
|
|
1102
|
+
const builtin = (name) => {
|
|
1103
|
+
try {
|
|
1104
|
+
if (name === "local" || name === "localStorage") return localStorage;
|
|
1105
|
+
if (name === "session" || name === "sessionStorage") return sessionStorage;
|
|
1106
|
+
} catch {
|
|
1107
|
+
}
|
|
1108
|
+
};
|
|
1109
|
+
const resolve = (storage) => {
|
|
1110
|
+
const target = storage ?? defaultStorage;
|
|
1111
|
+
if (typeof target !== "string") return target;
|
|
1112
|
+
return registry[target] ?? builtin(target);
|
|
1113
|
+
};
|
|
1114
|
+
const registerStorage = (name, storage) => {
|
|
1115
|
+
registry[name] = storage;
|
|
1116
|
+
};
|
|
1117
|
+
const setDefaultStorage = (storage) => {
|
|
1118
|
+
defaultStorage = storage;
|
|
1119
|
+
};
|
|
1120
|
+
const persistable = (target, keys) => (keys ?? Object.keys(target)).filter((k) => {
|
|
1121
|
+
if (k[0] === "$") return false;
|
|
1122
|
+
const desc = Object.getOwnPropertyDescriptor(target, k);
|
|
1123
|
+
if (desc && desc.get && !desc.set) return false;
|
|
1124
|
+
return typeof target[k] !== "function";
|
|
1125
|
+
});
|
|
1126
|
+
const sync = (target, key, keys, storage, run) => {
|
|
1127
|
+
if (!storage) return run(() => {
|
|
1128
|
+
});
|
|
1129
|
+
const fields = persistable(target, keys);
|
|
1130
|
+
try {
|
|
1131
|
+
const saved = JSON.parse(storage.getItem(key) || "null");
|
|
1132
|
+
if (saved) {
|
|
1133
|
+
for (const k of fields) {
|
|
1134
|
+
if (k in saved) target[k] = saved[k];
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
} catch {
|
|
1138
|
+
}
|
|
1139
|
+
return run(() => {
|
|
1140
|
+
const snapshot = {};
|
|
1141
|
+
for (const k of fields) snapshot[k] = target[k];
|
|
1142
|
+
try {
|
|
1143
|
+
storage.setItem(key, JSON.stringify(snapshot));
|
|
1144
|
+
} catch {
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
1147
|
+
};
|
|
1148
|
+
const persist = (app) => {
|
|
1149
|
+
app.directive("persist", ({ ctx, el, exp, arg, modifiers, effect }) => {
|
|
1150
|
+
const key = PREFIX + (exp || el.id);
|
|
1151
|
+
let storage;
|
|
1152
|
+
for (const name in modifiers || {}) {
|
|
1153
|
+
if (resolve(name)) {
|
|
1154
|
+
storage = name;
|
|
1155
|
+
break;
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
const keys = arg ? arg.split(",").map((k) => k.trim()).filter(Boolean) : void 0;
|
|
1159
|
+
sync(ctx.scope, key, keys, resolve(storage), effect);
|
|
1160
|
+
});
|
|
1161
|
+
};
|
|
1162
|
+
const persistStore = (name, options = {}) => {
|
|
1163
|
+
const target = store(name);
|
|
1164
|
+
if (!target) {
|
|
1165
|
+
return () => {
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
const storage = resolve(options.storage);
|
|
1169
|
+
return sync(
|
|
1170
|
+
target,
|
|
1171
|
+
PREFIX + (options.key ?? name),
|
|
1172
|
+
options.keys,
|
|
1173
|
+
storage,
|
|
1174
|
+
watchEffect
|
|
1175
|
+
);
|
|
1176
|
+
};
|
|
1177
|
+
|
|
1178
|
+
const FOCUSABLE = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])';
|
|
1179
|
+
const focus = (app) => {
|
|
1180
|
+
app.directive("focus", ({ el, get, effect, modifiers }) => {
|
|
1181
|
+
effect(() => {
|
|
1182
|
+
const on = !!get();
|
|
1183
|
+
Promise.resolve().then(() => {
|
|
1184
|
+
if (on) {
|
|
1185
|
+
el.focus();
|
|
1186
|
+
if (modifiers?.select && el.select) {
|
|
1187
|
+
el.select();
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
});
|
|
1191
|
+
});
|
|
1192
|
+
});
|
|
1193
|
+
app.directive("trap", ({ el, get, effect }) => {
|
|
1194
|
+
let active = false;
|
|
1195
|
+
let prevFocus = null;
|
|
1196
|
+
const focusables = () => [...el.querySelectorAll(FOCUSABLE)].filter(
|
|
1197
|
+
(e) => !e.hasAttribute("disabled")
|
|
1198
|
+
);
|
|
1199
|
+
const onKeydown = (e) => {
|
|
1200
|
+
if (e.key !== "Tab") return;
|
|
1201
|
+
const els = focusables();
|
|
1202
|
+
if (!els.length) {
|
|
1203
|
+
e.preventDefault();
|
|
1204
|
+
return;
|
|
1205
|
+
}
|
|
1206
|
+
const first = els[0];
|
|
1207
|
+
const last = els[els.length - 1];
|
|
1208
|
+
const current = document.activeElement;
|
|
1209
|
+
if (!el.contains(current)) {
|
|
1210
|
+
e.preventDefault();
|
|
1211
|
+
first.focus();
|
|
1212
|
+
} else if (e.shiftKey && current === first) {
|
|
1213
|
+
e.preventDefault();
|
|
1214
|
+
last.focus();
|
|
1215
|
+
} else if (!e.shiftKey && current === last) {
|
|
1216
|
+
e.preventDefault();
|
|
1217
|
+
first.focus();
|
|
1218
|
+
}
|
|
1219
|
+
};
|
|
1220
|
+
const release = () => {
|
|
1221
|
+
active = false;
|
|
1222
|
+
document.removeEventListener("keydown", onKeydown, true);
|
|
1223
|
+
if (prevFocus && prevFocus.focus) {
|
|
1224
|
+
prevFocus.focus();
|
|
1225
|
+
}
|
|
1226
|
+
};
|
|
1227
|
+
effect(() => {
|
|
1228
|
+
const on = !!get();
|
|
1229
|
+
if (on && !active) {
|
|
1230
|
+
active = true;
|
|
1231
|
+
prevFocus = document.activeElement;
|
|
1232
|
+
document.addEventListener("keydown", onKeydown, true);
|
|
1233
|
+
Promise.resolve().then(() => {
|
|
1234
|
+
if (active) (focusables()[0] || el).focus();
|
|
1235
|
+
});
|
|
1236
|
+
} else if (!on && active) {
|
|
1237
|
+
release();
|
|
1238
|
+
}
|
|
1239
|
+
});
|
|
1240
|
+
return () => {
|
|
1241
|
+
if (active) release();
|
|
1242
|
+
};
|
|
1243
|
+
});
|
|
1244
|
+
};
|
|
1245
|
+
|
|
1246
|
+
const collapse = (app) => {
|
|
1247
|
+
app.directive("collapse", ({ el, get, effect, modifiers }) => {
|
|
1248
|
+
const elem = el;
|
|
1249
|
+
let duration = 250;
|
|
1250
|
+
for (const m in modifiers || {}) {
|
|
1251
|
+
const match = /^duration-(\d+)$/.exec(m);
|
|
1252
|
+
if (match) duration = +match[1];
|
|
1253
|
+
}
|
|
1254
|
+
elem.style.overflow = "hidden";
|
|
1255
|
+
let first = true;
|
|
1256
|
+
let seq = 0;
|
|
1257
|
+
effect(() => {
|
|
1258
|
+
const show = !!get();
|
|
1259
|
+
const id = ++seq;
|
|
1260
|
+
if (first) {
|
|
1261
|
+
first = false;
|
|
1262
|
+
if (!show) elem.style.height = "0px";
|
|
1263
|
+
setTimeout(() => {
|
|
1264
|
+
elem.style.transition = `height ${duration}ms ease`;
|
|
1265
|
+
});
|
|
1266
|
+
return;
|
|
1267
|
+
}
|
|
1268
|
+
if (show) {
|
|
1269
|
+
elem.style.height = elem.scrollHeight + "px";
|
|
1270
|
+
setTimeout(() => {
|
|
1271
|
+
if (id === seq) elem.style.height = "";
|
|
1272
|
+
}, duration);
|
|
1273
|
+
} else {
|
|
1274
|
+
elem.style.height = elem.scrollHeight + "px";
|
|
1275
|
+
void elem.offsetHeight;
|
|
1276
|
+
elem.style.height = "0px";
|
|
1277
|
+
}
|
|
1278
|
+
});
|
|
1279
|
+
});
|
|
1280
|
+
};
|
|
1281
|
+
|
|
1282
|
+
export { collapse, focus, intersect, mask, persist, persistStore, registerStorage, setDefaultStorage, transition };
|