@aevantec/litevue 0.5.1 → 0.5.3

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.
@@ -1,3 +1,5 @@
1
+ import { store, watchEffect } from '@aevantec/litevue';
2
+
1
3
  const intersect = (app) => {
2
4
  app.directive("intersect", ({ el, get, modifiers }) => {
3
5
  const observer = new IntersectionObserver(
@@ -128,974 +130,6 @@ const transition = (app) => {
128
130
  });
129
131
  };
130
132
 
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
133
  const PREFIX = "litevue:";
1100
134
  const registry = /* @__PURE__ */ Object.create(null);
1101
135
  let defaultStorage = "local";
@@ -1121,6 +155,10 @@ const persistable = (target, keys) => (keys ?? Object.keys(target)).filter((k) =
1121
155
  if (k[0] === "$") return false;
1122
156
  const desc = Object.getOwnPropertyDescriptor(target, k);
1123
157
  if (desc && desc.get && !desc.set) return false;
158
+ const raw = desc && desc.value;
159
+ if (raw && raw.__v_isRef === true && raw.__v_isReadonly === true) {
160
+ return false;
161
+ }
1124
162
  return typeof target[k] !== "function";
1125
163
  });
1126
164
  const sync = (target, key, keys, storage, run) => {
@@ -1279,4 +317,177 @@ const collapse = (app) => {
1279
317
  });
1280
318
  };
1281
319
 
1282
- export { collapse, focus, intersect, mask, persist, persistStore, registerStorage, setDefaultStorage, transition };
320
+ const dirRE = /^(?:v-|:|@)/;
321
+ const bindRE = /^(?::|v-bind:)/;
322
+ const KEY_ATTRS = ["id", "data-key", "data-id"];
323
+ const defaultKey = (el) => {
324
+ for (const attr of KEY_ATTRS) {
325
+ const value = el.getAttribute(attr);
326
+ if (value != null) return attr + "=" + value;
327
+ }
328
+ return null;
329
+ };
330
+ const nearestCtx = (node) => {
331
+ for (let el = node; el; el = el.parentElement) {
332
+ if (el.__ctx) return el.__ctx;
333
+ }
334
+ };
335
+ const boundAttrs = (to) => {
336
+ const owned = /* @__PURE__ */ new Set();
337
+ for (const { name } of to.attributes) {
338
+ if (bindRE.test(name)) {
339
+ owned.add(name.replace(bindRE, "").split(".")[0]);
340
+ } else if (name === "v-model") {
341
+ owned.add("value");
342
+ owned.add("checked");
343
+ }
344
+ }
345
+ return owned;
346
+ };
347
+ const isBlockRoot = (el) => el.hasAttribute("v-for") || el.hasAttribute("v-if") || el.hasAttribute("v-else") || el.hasAttribute("v-else-if");
348
+ const ownsChildren = (to) => {
349
+ if (to.hasAttribute("v-text") || to.hasAttribute("v-html") || to.hasAttribute("v-pre") || to.hasAttribute("v-once") || isBlockRoot(to)) {
350
+ return true;
351
+ }
352
+ for (let c = to.firstElementChild; c; c = c.nextElementSibling) {
353
+ if (isBlockRoot(c)) return true;
354
+ }
355
+ return false;
356
+ };
357
+ const patchAttrs = (from, to) => {
358
+ const owned = boundAttrs(to);
359
+ for (const { name, value } of [...to.attributes]) {
360
+ if (dirRE.test(name) || owned.has(name)) continue;
361
+ if (from.getAttribute(name) !== value) from.setAttribute(name, value);
362
+ }
363
+ for (const { name } of [...from.attributes]) {
364
+ if (owned.has(name) || to.hasAttribute(name)) continue;
365
+ from.removeAttribute(name);
366
+ }
367
+ };
368
+ const isInterpolation = (data, ctx) => data.includes(ctx ? ctx.delimiters[0] : "{{");
369
+ const patchNode = (from, to, ctx, opts) => {
370
+ if (from.nodeType !== to.nodeType) return replaceNode(from, to, ctx);
371
+ if (from.nodeType === 3 || from.nodeType === 8) {
372
+ const data = to.data;
373
+ if (isInterpolation(data, ctx)) return;
374
+ if (from.data !== data) from.data = data;
375
+ return;
376
+ }
377
+ if (from.nodeType !== 1) return;
378
+ const a = from;
379
+ const b = to;
380
+ if (a.tagName !== b.tagName) return replaceNode(from, to, ctx);
381
+ if (opts.skip?.(a, b) || a.hasAttribute("data-morph-skip")) return;
382
+ patchAttrs(a, b);
383
+ if (!ownsChildren(b)) {
384
+ patchChildren(a, b, a.__ctx || ctx, opts);
385
+ }
386
+ };
387
+ const replaceNode = (from, to, ctx) => {
388
+ const fresh = to.cloneNode(true);
389
+ from.parentNode.replaceChild(fresh, from);
390
+ mountNew(fresh, ctx);
391
+ };
392
+ const mountNew = (node, ctx) => {
393
+ const target = ctx || nearestCtx(node.parentNode);
394
+ target?.walk?.(node, target);
395
+ };
396
+ const patchChildren = (from, to, ctx, opts) => {
397
+ const key = opts.key || defaultKey;
398
+ const keyed = /* @__PURE__ */ new Map();
399
+ for (let n = from.firstChild; n; n = n.nextSibling) {
400
+ if (n.nodeType === 1) {
401
+ const k = key(n);
402
+ if (k == null) continue;
403
+ keyed.set(k, n);
404
+ }
405
+ }
406
+ const keyOf = (n) => n && n.nodeType === 1 ? key(n) : null;
407
+ let oldChild = from.firstChild;
408
+ let newChild = to.firstChild;
409
+ const insert = (node) => {
410
+ const fresh = node.cloneNode(true);
411
+ from.insertBefore(fresh, oldChild);
412
+ mountNew(fresh, ctx);
413
+ };
414
+ while (newChild) {
415
+ const nextNew = newChild.nextSibling;
416
+ const wantKey = keyOf(newChild);
417
+ if (wantKey != null) {
418
+ const match = keyed.get(wantKey);
419
+ if (match) {
420
+ if (match === oldChild) {
421
+ oldChild = oldChild.nextSibling;
422
+ } else {
423
+ from.insertBefore(match, oldChild);
424
+ }
425
+ keyed.delete(wantKey);
426
+ patchNode(match, newChild, ctx, opts);
427
+ } else {
428
+ insert(newChild);
429
+ }
430
+ } else if (oldChild && keyOf(oldChild) == null) {
431
+ const nextOld = oldChild.nextSibling;
432
+ patchNode(oldChild, newChild, ctx, opts);
433
+ oldChild = nextOld;
434
+ } else {
435
+ insert(newChild);
436
+ }
437
+ newChild = nextNew;
438
+ }
439
+ while (oldChild) {
440
+ const next = oldChild.nextSibling;
441
+ from.removeChild(oldChild);
442
+ oldChild = next;
443
+ }
444
+ };
445
+ const morph = (from, to, opts = {}) => {
446
+ let target;
447
+ if (typeof to === "string") {
448
+ const holder = document.createElement("template");
449
+ holder.innerHTML = to.trim();
450
+ const content = holder.content;
451
+ target = content.childElementCount === 1 ? content.firstElementChild : (() => {
452
+ const wrapper = from.cloneNode(false);
453
+ wrapper.appendChild(content);
454
+ return wrapper;
455
+ })();
456
+ } else {
457
+ target = to;
458
+ }
459
+ if (target) {
460
+ const restore = captureFocus();
461
+ patchNode(from, target, nearestCtx(from), opts);
462
+ restore();
463
+ }
464
+ return from;
465
+ };
466
+ const captureFocus = () => {
467
+ const active = document.activeElement;
468
+ if (!active || active === document.body) return () => {
469
+ };
470
+ const field = active;
471
+ let start = null;
472
+ let end = null;
473
+ try {
474
+ start = field.selectionStart;
475
+ end = field.selectionEnd;
476
+ } catch {
477
+ }
478
+ return () => {
479
+ if (active === document.activeElement || !active.isConnected) return;
480
+ active.focus();
481
+ if (start !== null) {
482
+ try {
483
+ field.setSelectionRange(start, end);
484
+ } catch {
485
+ }
486
+ }
487
+ };
488
+ };
489
+ const morphPlugin = (app) => {
490
+ app.scope.$morph = morph;
491
+ };
492
+
493
+ export { collapse, focus, intersect, mask, morph, morphPlugin, persist, persistStore, registerStorage, setDefaultStorage, transition };