aberdeen 1.10.1 → 1.11.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/dist/src/aberdeen.d.ts +27 -26
- package/dist/src/aberdeen.js +130 -51
- package/dist/src/aberdeen.js.map +3 -3
- package/dist/src/aberdeen.min.js +8 -8
- package/dist/src/aberdeen.min.js.map +3 -3
- package/dist/src/route.js +24 -9
- package/dist/src/route.js.map +3 -3
- package/dist/src/route.min.js +2 -2
- package/dist/src/route.min.js.map +3 -3
- package/dist-docs/Tutorial/index.html +17 -13
- package/dist-docs/aberdeen/{_ → A}/index.html +2 -2
- package/dist-docs/aberdeen/NO_COPY/index.html +2 -2
- package/dist-docs/aberdeen/PromiseProxy/index.html +5 -5
- package/dist-docs/aberdeen/clean/index.html +3 -3
- package/dist-docs/aberdeen/clone/index.html +2 -2
- package/dist-docs/aberdeen/copy/index.html +3 -3
- package/dist-docs/aberdeen/count/index.html +4 -4
- package/dist-docs/aberdeen/cssVars/index.html +2 -2
- package/dist-docs/aberdeen/darkMode/index.html +3 -3
- package/dist-docs/aberdeen/default/index.html +24 -24
- package/dist-docs/aberdeen/derive/index.html +3 -3
- package/dist-docs/aberdeen/disableCreateDestroy/index.html +2 -2
- package/dist-docs/aberdeen/dump/index.html +3 -3
- package/dist-docs/aberdeen/index.html +10 -10
- package/dist-docs/aberdeen/insertCss/index.html +5 -5
- package/dist-docs/aberdeen/insertGlobalCss/index.html +2 -2
- package/dist-docs/aberdeen/invertString/index.html +2 -2
- package/dist-docs/aberdeen/isEmpty/index.html +4 -4
- package/dist-docs/aberdeen/map/index.html +4 -4
- package/dist-docs/aberdeen/merge/index.html +3 -3
- package/dist-docs/aberdeen/mount/index.html +7 -7
- package/dist-docs/aberdeen/multiMap/index.html +4 -4
- package/dist-docs/aberdeen/onEach/index.html +8 -5
- package/dist-docs/aberdeen/partition/index.html +4 -4
- package/dist-docs/aberdeen/peek/index.html +9 -9
- package/dist-docs/aberdeen/proxy/index.html +8 -5
- package/dist-docs/aberdeen/ref/index.html +4 -4
- package/dist-docs/aberdeen/runQueue/index.html +2 -2
- package/dist-docs/aberdeen/setErrorHandler/index.html +3 -3
- package/dist-docs/aberdeen/setSpacingCssVars/index.html +2 -2
- package/dist-docs/aberdeen/unmountAll/index.html +3 -3
- package/dist-docs/aberdeen/unproxy/index.html +2 -2
- package/dist-docs/assets/aberdeen/aberdeen.d.ts +27 -26
- package/dist-docs/assets/aberdeen/aberdeen.js +130 -51
- package/dist-docs/assets/aberdeen/aberdeen.js.map +3 -3
- package/dist-docs/assets/aberdeen/aberdeen.min.js +8 -8
- package/dist-docs/assets/aberdeen/aberdeen.min.js.map +3 -3
- package/dist-docs/assets/aberdeen/route.js +24 -9
- package/dist-docs/assets/aberdeen/route.js.map +3 -3
- package/dist-docs/assets/aberdeen/route.min.js +2 -2
- package/dist-docs/assets/aberdeen/route.min.js.map +3 -3
- package/dist-docs/assets/navigation.js +1 -1
- package/dist-docs/assets/search.js +1 -1
- package/dist-docs/dispatcher/Dispatcher/index.html +4 -4
- package/dist-docs/dispatcher/MATCH_FAILED/index.html +2 -2
- package/dist-docs/dispatcher/MATCH_REST/index.html +2 -2
- package/dist-docs/dispatcher/index.html +2 -2
- package/dist-docs/hierarchy.html +1 -1
- package/dist-docs/index.html +2 -2
- package/dist-docs/media/CHANGELOG.md +15 -0
- package/dist-docs/modules.html +1 -1
- package/dist-docs/prediction/applyCanon/index.html +2 -2
- package/dist-docs/prediction/applyPrediction/index.html +2 -2
- package/dist-docs/prediction/index.html +2 -2
- package/dist-docs/route/Route/index.html +9 -9
- package/dist-docs/route/back/index.html +2 -2
- package/dist-docs/route/current/index.html +2 -2
- package/dist-docs/route/go/index.html +2 -2
- package/dist-docs/route/index.html +2 -2
- package/dist-docs/route/interceptLinks/index.html +2 -2
- package/dist-docs/route/persistScroll/index.html +2 -2
- package/dist-docs/route/push/index.html +2 -2
- package/dist-docs/route/setLog/index.html +2 -2
- package/dist-docs/route/up/index.html +2 -2
- package/dist-docs/sitemap.xml +57 -57
- package/dist-docs/transitions/grow/index.html +2 -2
- package/dist-docs/transitions/index.html +2 -2
- package/dist-docs/transitions/shrink/index.html +2 -2
- package/package.json +7 -7
- package/skill/SKILL.md +32 -13
- package/skill/aberdeen.md +212 -136
- package/skill/dispatcher.md +6 -6
- package/skill/prediction.md +3 -3
- package/skill/route.md +17 -17
- package/skill/transitions.md +3 -3
- package/src/aberdeen.ts +198 -104
- package/src/route.ts +27 -8
package/dist/src/aberdeen.d.ts
CHANGED
|
@@ -59,12 +59,13 @@ export declare function runQueue(): void;
|
|
|
59
59
|
*/
|
|
60
60
|
export declare function invertString(input: string): string;
|
|
61
61
|
export declare function onEach<K, T>(target: Map<K, undefined | T>, render: (value: T, key: K) => void, makeKey?: (value: T, key: K) => SortKeyType): void;
|
|
62
|
+
export declare function onEach<T>(target: Set<T>, render: (value: T) => void, makeKey?: (value: T) => SortKeyType): void;
|
|
62
63
|
export declare function onEach<T>(target: ReadonlyArray<undefined | T>, render: (value: T, index: number) => void, makeKey?: (value: T, index: number) => SortKeyType): void;
|
|
63
64
|
export declare function onEach<K extends string | number | symbol, T>(target: Record<K, undefined | T>, render: (value: T, index: KeyToString<K>) => void, makeKey?: (value: T, index: KeyToString<K>) => SortKeyType): void;
|
|
64
65
|
/** @private */
|
|
65
66
|
export declare const EMPTY: unique symbol;
|
|
66
67
|
/**
|
|
67
|
-
* Reactively checks if an observable array or
|
|
68
|
+
* Reactively checks if an observable array, object, Map, or Set is empty.
|
|
68
69
|
*
|
|
69
70
|
* This function not only returns the current emptiness state but also establishes
|
|
70
71
|
* a reactive dependency. If the emptiness state of the `proxied` object or array
|
|
@@ -72,8 +73,8 @@ export declare const EMPTY: unique symbol;
|
|
|
72
73
|
* is deleted from an object), the scope that called `isEmpty` will be automatically
|
|
73
74
|
* scheduled for re-evaluation.
|
|
74
75
|
*
|
|
75
|
-
* @param proxied The observable array or
|
|
76
|
-
* @returns `true` if the array has length 0 or the object has no own enumerable properties, `false` otherwise.
|
|
76
|
+
* @param proxied The observable array, object, Map, or Set to check.
|
|
77
|
+
* @returns `true` if the array has length 0, the Map/Set has size 0, or the object has no own enumerable properties, `false` otherwise.
|
|
77
78
|
*
|
|
78
79
|
* @example
|
|
79
80
|
* ```typescript
|
|
@@ -101,10 +102,10 @@ export interface ValueRef<T> {
|
|
|
101
102
|
value: T;
|
|
102
103
|
}
|
|
103
104
|
/**
|
|
104
|
-
* Reactively counts the number of properties in an
|
|
105
|
+
* Reactively counts the number of properties in an object.
|
|
105
106
|
*
|
|
106
|
-
* @param proxied The observable object to count. In case an `array` is passed in, a {@link ref} to its `.length` will be returned.
|
|
107
|
-
* @returns an observable object for which the `value` property reflects the number of properties in `proxied` with a value other than `undefined
|
|
107
|
+
* @param proxied The observable object to count. In case an `array`, `Map`, or `Set` is passed in, a {@link ref} to its `.length` or `.size` will be returned.
|
|
108
|
+
* @returns an observable object for which the `value` property reflects the number of properties in `proxied` with a value other than `undefined`, or the collection size for arrays, Maps, and Sets.
|
|
108
109
|
*
|
|
109
110
|
* @example
|
|
110
111
|
* ```typescript
|
|
@@ -306,7 +307,7 @@ export declare function setSpacingCssVars(base?: number, unit?: string): void;
|
|
|
306
307
|
* This function is reactive - scopes that call it will re-execute when the
|
|
307
308
|
* browser's color scheme preference changes (via the `prefers-color-scheme` media query).
|
|
308
309
|
*
|
|
309
|
-
* Use this in combination with {@link
|
|
310
|
+
* Use this in combination with {@link A | A} and {@link cssVars} to implement theme switching:
|
|
310
311
|
*
|
|
311
312
|
* @returns `true` if the browser prefers dark mode, `false` if it prefers light mode.
|
|
312
313
|
*
|
|
@@ -336,8 +337,8 @@ export declare function clone<T extends object>(src: T): T;
|
|
|
336
337
|
* Creates a reactive reference (`{ value: T }`-like object) to a specific value
|
|
337
338
|
* within a proxied object or array.
|
|
338
339
|
*
|
|
339
|
-
* This is primarily used for the `bind` property in {@link
|
|
340
|
-
* with form elements, and for passing a reactive property to any of the {@link
|
|
340
|
+
* This is primarily used for the `bind` property in {@link A | A} to create two-way data bindings
|
|
341
|
+
* with form elements, and for passing a reactive property to any of the {@link A | A} key-value pairs.
|
|
341
342
|
*
|
|
342
343
|
* Reading `ref.value` accesses the property from the underlying proxy (and subscribes the current scope).
|
|
343
344
|
* Assigning to `ref.value` updates the property in the underlying proxy (triggering reactive updates).
|
|
@@ -490,7 +491,7 @@ export declare function disableCreateDestroy(): void;
|
|
|
490
491
|
* ```
|
|
491
492
|
* This is often used together with {@link ref}, in order to use properties other than `.value`.
|
|
492
493
|
*/
|
|
493
|
-
export declare function
|
|
494
|
+
export declare function A(...args: any[]): undefined | Element;
|
|
494
495
|
/**
|
|
495
496
|
* Inserts CSS rules into the document, scoping them with a unique class name.
|
|
496
497
|
*
|
|
@@ -502,7 +503,7 @@ export declare function $(...args: any[]): undefined | Element;
|
|
|
502
503
|
*
|
|
503
504
|
* ### Concise Style Strings
|
|
504
505
|
*
|
|
505
|
-
* Concise style strings use two syntaxes (same as inline CSS in {@link
|
|
506
|
+
* Concise style strings use two syntaxes (same as inline CSS in {@link A | A}):
|
|
506
507
|
* - **Short form** `key:value` (no space after colon): The value ends at the next whitespace.
|
|
507
508
|
* Example: `'m:$3 bg:red r:8px'`
|
|
508
509
|
* - **Long form** `key: value;` (space after colon): The value continues until a semicolon.
|
|
@@ -510,11 +511,11 @@ export declare function $(...args: any[]): undefined | Element;
|
|
|
510
511
|
*
|
|
511
512
|
* Both forms can be mixed: `'m:$3 box-shadow: 0 2px 4px rgba(0,0,0,0.2); bg:$cardBg'`
|
|
512
513
|
*
|
|
513
|
-
* Supports the same CSS shortcuts as {@link
|
|
514
|
+
* Supports the same CSS shortcuts as {@link A | A} and CSS variable references with `$` (e.g., `$primary`, `$3`).
|
|
514
515
|
*
|
|
515
516
|
* @param style - A concise style string or a style object.
|
|
516
517
|
* @returns The unique class name prefix used for scoping (e.g., `.AbdStl1`).
|
|
517
|
-
* Use this prefix with {@link
|
|
518
|
+
* Use this prefix with {@link A | A} to apply the styles.
|
|
518
519
|
*
|
|
519
520
|
* @example Basic Usage with Shortcuts and CSS Variables
|
|
520
521
|
* ```typescript
|
|
@@ -608,7 +609,7 @@ export declare function insertGlobalCss(style: object): void;
|
|
|
608
609
|
/**
|
|
609
610
|
* Sets a custom error handler function for errors that occur asynchronously
|
|
610
611
|
* within reactive scopes (e.g., during updates triggered by proxy changes in
|
|
611
|
-
* {@link derive} or {@link
|
|
612
|
+
* {@link derive} or {@link A | A} render functions).
|
|
612
613
|
*
|
|
613
614
|
* The default handler logs the error to `console.error` and adds a simple
|
|
614
615
|
* 'Error' message div to the DOM at the location where the error occurred (if possible).
|
|
@@ -655,7 +656,7 @@ export declare function setErrorHandler(handler?: (error: Error) => boolean | un
|
|
|
655
656
|
* This is useful for releasing resources, removing manual event listeners, or cleaning up
|
|
656
657
|
* side effects associated with the scope. Cleaners are run in reverse order of registration.
|
|
657
658
|
*
|
|
658
|
-
* Scopes are created by functions like {@link derive}, {@link mount}, {@link
|
|
659
|
+
* Scopes are created by functions like {@link derive}, {@link mount}, {@link A | A} (when given a render function),
|
|
659
660
|
* and internally by constructs like {@link onEach}.
|
|
660
661
|
*
|
|
661
662
|
* @param cleaner - The function to execute during cleanup.
|
|
@@ -696,7 +697,7 @@ export declare function clean(cleaner: () => void): void;
|
|
|
696
697
|
* Use {@link peek} or {@link unproxy} within the function to read proxied data without subscribing to it.
|
|
697
698
|
*
|
|
698
699
|
* @param func - The function to execute reactively. Any DOM manipulations should typically
|
|
699
|
-
* be done using {@link
|
|
700
|
+
* be done using {@link A | A} within this function. Its return value will be made available as an
|
|
700
701
|
* observable returned by the `derive()` function.
|
|
701
702
|
* @returns An observable object, with its `value` property containing whatever the last run of `func` returned.
|
|
702
703
|
*
|
|
@@ -737,21 +738,21 @@ export declare function clean(cleaner: () => void): void;
|
|
|
737
738
|
export declare function derive<T>(func: () => T): ValueRef<T>;
|
|
738
739
|
/**
|
|
739
740
|
* Attaches a reactive Aberdeen UI fragment to an existing DOM element. Without the use of
|
|
740
|
-
* this function, {@link
|
|
741
|
+
* this function, {@link A | A} will assume `document.body` as its root.
|
|
741
742
|
*
|
|
742
743
|
* It creates a top-level reactive scope associated with the `parentElement`. The provided
|
|
743
744
|
* function `func` is executed immediately within this scope. Any proxied data read by `func`
|
|
744
745
|
* will cause it to re-execute when the data changes, updating the DOM elements created within it.
|
|
745
746
|
*
|
|
746
|
-
* Calls to {@link
|
|
747
|
-
* You can nest {@link derive} or other {@link
|
|
747
|
+
* Calls to {@link A | A} inside `func` will append nodes to `parentElement`.
|
|
748
|
+
* You can nest {@link derive} or other {@link A | A} scopes within `func`.
|
|
748
749
|
* Use {@link unmountAll} to clean up all mounted scopes and their DOM nodes.
|
|
749
750
|
*
|
|
750
751
|
* Mounting scopes happens reactively, meaning that if this function is called from within another
|
|
751
|
-
* ({@link derive} or {@link
|
|
752
|
+
* ({@link derive} or {@link A | A} or {@link mount}) scope that gets cleaned up, so will the mount.
|
|
752
753
|
*
|
|
753
754
|
* @param parentElement - The native DOM `Element` to which the UI fragment will be appended.
|
|
754
|
-
* @param func - The function that defines the UI fragment, typically containing calls to {@link
|
|
755
|
+
* @param func - The function that defines the UI fragment, typically containing calls to {@link A | A}.
|
|
755
756
|
*
|
|
756
757
|
* @example Basic Mount
|
|
757
758
|
* ```javascript
|
|
@@ -780,7 +781,7 @@ export declare function derive<T>(func: () => T): ValueRef<T>;
|
|
|
780
781
|
export declare function mount(parentElement: Element, func: () => void): void;
|
|
781
782
|
/**
|
|
782
783
|
* Removes all Aberdeen-managed DOM nodes and stops all active reactive scopes
|
|
783
|
-
* (created by {@link mount}, {@link derive}, {@link
|
|
784
|
+
* (created by {@link mount}, {@link derive}, {@link A | A} with functions, etc.).
|
|
784
785
|
*
|
|
785
786
|
* This effectively cleans up the entire Aberdeen application state. Aside from in
|
|
786
787
|
* automated tests, there should probably be little reason to call this function.
|
|
@@ -789,7 +790,7 @@ export declare function unmountAll(): void;
|
|
|
789
790
|
/**
|
|
790
791
|
* Executes a function or retrieves a value *without* creating subscriptions in the current reactive scope, and returns its result.
|
|
791
792
|
*
|
|
792
|
-
* This is useful when you need to access reactive data inside a reactive scope (like {@link
|
|
793
|
+
* This is useful when you need to access reactive data inside a reactive scope (like {@link A | A})
|
|
793
794
|
* but do not want changes to that specific data to trigger a re-execute of the scope.
|
|
794
795
|
*
|
|
795
796
|
* Note: You may also use {@link unproxy} to get to the raw underlying data structure, which can be used to similar effect.
|
|
@@ -841,7 +842,7 @@ export declare function partition<IN_K extends string | number | symbol, OUT_K e
|
|
|
841
842
|
export declare function partition<IN_K extends string | number | symbol, OUT_K extends string | number | symbol, IN_V>(source: Map<IN_K, IN_V>, func: (value: IN_V, key: IN_K) => undefined | OUT_K | OUT_K[]): Record<OUT_K, Record<IN_K, IN_V>>;
|
|
842
843
|
/**
|
|
843
844
|
* Renders a live, recursive dump of a proxied data structure (or any value)
|
|
844
|
-
* into the DOM at the current {@link
|
|
845
|
+
* into the DOM at the current {@link A | A} insertion point.
|
|
845
846
|
*
|
|
846
847
|
* Uses `<ul>` and `<li>` elements to display object properties and array items.
|
|
847
848
|
* Updates reactively if the dumped data changes. Primarily intended for debugging purposes.
|
|
@@ -883,7 +884,7 @@ export declare function dump<T>(data: T): T;
|
|
|
883
884
|
* });
|
|
884
885
|
* ```
|
|
885
886
|
*/
|
|
886
|
-
declare const
|
|
887
|
+
declare const _default: typeof A & {
|
|
887
888
|
/** {@inheritDoc clean} */ clean: typeof clean;
|
|
888
889
|
/** {@inheritDoc clone} */ clone: typeof clone;
|
|
889
890
|
/** {@inheritDoc copy} */ copy: typeof copy;
|
|
@@ -913,4 +914,4 @@ declare const A: typeof $ & {
|
|
|
913
914
|
/** {@inheritDoc unmountAll} */ unmountAll: typeof unmountAll;
|
|
914
915
|
/** {@inheritDoc unproxy} */ unproxy: typeof unproxy;
|
|
915
916
|
};
|
|
916
|
-
export default
|
|
917
|
+
export default _default;
|
package/dist/src/aberdeen.js
CHANGED
|
@@ -130,18 +130,26 @@ function runQueue() {
|
|
|
130
130
|
if (time > 9)
|
|
131
131
|
console.debug(`Aberdeen queue took ${time}ms`);
|
|
132
132
|
}
|
|
133
|
-
function
|
|
134
|
-
if (typeof part === "string") {
|
|
135
|
-
return `${part}\x01`;
|
|
136
|
-
}
|
|
133
|
+
function arrayToStr(parts) {
|
|
137
134
|
let result = "";
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
135
|
+
for (const part of parts) {
|
|
136
|
+
if (typeof part === "string") {
|
|
137
|
+
result += `${part}\x01`;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (typeof part !== "number") {
|
|
141
|
+
throw new Error("onEach() sort key must be a string, number or an array of such");
|
|
142
|
+
}
|
|
143
|
+
let digits = "";
|
|
144
|
+
let num = Math.abs(Math.round(part));
|
|
145
|
+
const negative = part < 0;
|
|
146
|
+
while (num > 0) {
|
|
147
|
+
digits = String.fromCharCode(negative ? 65534 - num % 65533 : 2 + num % 65533) + digits;
|
|
148
|
+
num = Math.floor(num / 65533);
|
|
149
|
+
}
|
|
150
|
+
result += String.fromCharCode(128 + (negative ? -digits.length : digits.length)) + digits;
|
|
143
151
|
}
|
|
144
|
-
return
|
|
152
|
+
return result;
|
|
145
153
|
}
|
|
146
154
|
function invertString(input) {
|
|
147
155
|
let result = "";
|
|
@@ -403,7 +411,7 @@ class OnEachScope extends Scope {
|
|
|
403
411
|
new OnEachItemScope(this, i, false);
|
|
404
412
|
}
|
|
405
413
|
} else {
|
|
406
|
-
for (const key of target instanceof Map ? target.keys() : Object.keys(target)) {
|
|
414
|
+
for (const key of target instanceof Map ? target.keys() : target instanceof Set ? target.values() : Object.keys(target)) {
|
|
407
415
|
new OnEachItemScope(this, key, false);
|
|
408
416
|
}
|
|
409
417
|
}
|
|
@@ -430,7 +438,7 @@ class OnEachScope extends Scope {
|
|
|
430
438
|
const oldScope = this.byIndex.get(index);
|
|
431
439
|
if (oldScope)
|
|
432
440
|
oldScope.remove();
|
|
433
|
-
if (this.target instanceof Map ? this.target.has(index) : (index in this.target)) {
|
|
441
|
+
if (this.target instanceof Set || this.target instanceof Map ? this.target.has(index) : (index in this.target)) {
|
|
434
442
|
new OnEachItemScope(this, index, true);
|
|
435
443
|
} else {
|
|
436
444
|
this.byIndex.delete(index);
|
|
@@ -516,7 +524,9 @@ class OnEachItemScope extends ContentScope {
|
|
|
516
524
|
let value;
|
|
517
525
|
const target = this.parent.target;
|
|
518
526
|
let itemIndex = this.itemIndex;
|
|
519
|
-
if (target instanceof
|
|
527
|
+
if (target instanceof Set) {
|
|
528
|
+
value = itemIndex = optProxy(itemIndex);
|
|
529
|
+
} else if (target instanceof Map) {
|
|
520
530
|
value = optProxy(target.get(itemIndex));
|
|
521
531
|
itemIndex = optProxy(itemIndex);
|
|
522
532
|
} else {
|
|
@@ -527,14 +537,14 @@ class OnEachItemScope extends ContentScope {
|
|
|
527
537
|
let sortKey;
|
|
528
538
|
try {
|
|
529
539
|
if (this.parent.makeSortKey) {
|
|
530
|
-
|
|
531
|
-
if (rawSortKey != null)
|
|
532
|
-
sortKey = rawSortKey instanceof Array ? rawSortKey.map(partToStr).join("") : rawSortKey;
|
|
540
|
+
sortKey = this.parent.makeSortKey(value, itemIndex);
|
|
533
541
|
} else {
|
|
534
542
|
sortKey = itemIndex;
|
|
535
543
|
}
|
|
536
|
-
if (
|
|
537
|
-
sortKey =
|
|
544
|
+
if (sortKey instanceof Array)
|
|
545
|
+
sortKey = arrayToStr(sortKey);
|
|
546
|
+
else if (typeof sortKey !== "string" && sortKey != null)
|
|
547
|
+
sortKey = arrayToStr([sortKey]);
|
|
538
548
|
if (this.sortKey !== sortKey) {
|
|
539
549
|
this.parent.sortedSet.remove(this);
|
|
540
550
|
this.sortKey = sortKey;
|
|
@@ -632,7 +642,7 @@ function isEmpty(proxied) {
|
|
|
632
642
|
});
|
|
633
643
|
return !target.length;
|
|
634
644
|
}
|
|
635
|
-
if (target instanceof Map) {
|
|
645
|
+
if (target instanceof Map || target instanceof Set) {
|
|
636
646
|
subscribe(target, MAP_SIZE_SYMBOL, (index, newData, oldData) => {
|
|
637
647
|
if (!newData !== !oldData)
|
|
638
648
|
scope.onChange(target, EMPTY, !newData, !oldData);
|
|
@@ -652,7 +662,7 @@ function isEmpty(proxied) {
|
|
|
652
662
|
function count(proxied) {
|
|
653
663
|
if (proxied instanceof Array)
|
|
654
664
|
return ref(proxied, "length");
|
|
655
|
-
if (proxied instanceof Map)
|
|
665
|
+
if (proxied instanceof Map || proxied instanceof Set)
|
|
656
666
|
return ref(proxied, "size");
|
|
657
667
|
const target = proxied[TARGET_SYMBOL] || proxied;
|
|
658
668
|
let cnt = 0;
|
|
@@ -807,22 +817,20 @@ function wrapIteratorPair(iterator) {
|
|
|
807
817
|
}
|
|
808
818
|
};
|
|
809
819
|
}
|
|
820
|
+
function unproxyCollectionValue(value) {
|
|
821
|
+
return typeof value === "object" && value ? value[TARGET_SYMBOL] || value : value;
|
|
822
|
+
}
|
|
810
823
|
var mapMethodHandlers = {
|
|
811
824
|
get(key) {
|
|
812
825
|
const target = this[TARGET_SYMBOL];
|
|
813
|
-
|
|
814
|
-
key = key[TARGET_SYMBOL] || key;
|
|
826
|
+
key = unproxyCollectionValue(key);
|
|
815
827
|
subscribe(target, key);
|
|
816
828
|
return optProxy(target.get(key));
|
|
817
829
|
},
|
|
818
830
|
set(key, newData) {
|
|
819
831
|
const target = this[TARGET_SYMBOL];
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
}
|
|
823
|
-
if (typeof newData === "object" && newData) {
|
|
824
|
-
newData = newData[TARGET_SYMBOL] || newData;
|
|
825
|
-
}
|
|
832
|
+
key = unproxyCollectionValue(key);
|
|
833
|
+
newData = unproxyCollectionValue(newData);
|
|
826
834
|
let oldData = target.get(key);
|
|
827
835
|
if (oldData === undefined && !target.has(key))
|
|
828
836
|
oldData = EMPTY;
|
|
@@ -836,9 +844,7 @@ var mapMethodHandlers = {
|
|
|
836
844
|
},
|
|
837
845
|
delete(key) {
|
|
838
846
|
const target = this[TARGET_SYMBOL];
|
|
839
|
-
|
|
840
|
-
key = key[TARGET_SYMBOL] || key;
|
|
841
|
-
}
|
|
847
|
+
key = unproxyCollectionValue(key);
|
|
842
848
|
let oldData = target.get(key);
|
|
843
849
|
if (oldData === undefined && !target.has(key))
|
|
844
850
|
oldData = EMPTY;
|
|
@@ -860,9 +866,7 @@ var mapMethodHandlers = {
|
|
|
860
866
|
},
|
|
861
867
|
has(key) {
|
|
862
868
|
const target = this[TARGET_SYMBOL];
|
|
863
|
-
|
|
864
|
-
key = key[TARGET_SYMBOL] || key;
|
|
865
|
-
}
|
|
869
|
+
key = unproxyCollectionValue(key);
|
|
866
870
|
subscribe(target, key);
|
|
867
871
|
return target.has(key);
|
|
868
872
|
},
|
|
@@ -887,6 +891,66 @@ var mapMethodHandlers = {
|
|
|
887
891
|
return wrapIteratorPair(target[Symbol.iterator]());
|
|
888
892
|
}
|
|
889
893
|
};
|
|
894
|
+
var setMethodHandlers = {
|
|
895
|
+
add(value) {
|
|
896
|
+
const target = this[TARGET_SYMBOL];
|
|
897
|
+
value = unproxyCollectionValue(value);
|
|
898
|
+
if (!target.has(value)) {
|
|
899
|
+
const oldSize = target.size;
|
|
900
|
+
target.add(value);
|
|
901
|
+
emit(target, value, value, EMPTY);
|
|
902
|
+
emit(target, MAP_SIZE_SYMBOL, target.size, oldSize);
|
|
903
|
+
}
|
|
904
|
+
return this;
|
|
905
|
+
},
|
|
906
|
+
delete(value) {
|
|
907
|
+
const target = this[TARGET_SYMBOL];
|
|
908
|
+
value = unproxyCollectionValue(value);
|
|
909
|
+
if (!target.has(value))
|
|
910
|
+
return false;
|
|
911
|
+
const oldSize = target.size;
|
|
912
|
+
target.delete(value);
|
|
913
|
+
emit(target, value, EMPTY, value);
|
|
914
|
+
emit(target, MAP_SIZE_SYMBOL, target.size, oldSize);
|
|
915
|
+
return true;
|
|
916
|
+
},
|
|
917
|
+
clear() {
|
|
918
|
+
const target = this[TARGET_SYMBOL];
|
|
919
|
+
const oldSize = target.size;
|
|
920
|
+
if (!oldSize)
|
|
921
|
+
return;
|
|
922
|
+
for (const value of target.values())
|
|
923
|
+
emit(target, value, EMPTY, value);
|
|
924
|
+
target.clear();
|
|
925
|
+
emit(target, MAP_SIZE_SYMBOL, 0, oldSize);
|
|
926
|
+
},
|
|
927
|
+
has(value) {
|
|
928
|
+
const target = this[TARGET_SYMBOL];
|
|
929
|
+
value = unproxyCollectionValue(value);
|
|
930
|
+
subscribe(target, value);
|
|
931
|
+
return target.has(value);
|
|
932
|
+
},
|
|
933
|
+
keys() {
|
|
934
|
+
const target = this[TARGET_SYMBOL];
|
|
935
|
+
subscribe(target, ANY_SYMBOL);
|
|
936
|
+
return wrapIteratorSingle(target.keys());
|
|
937
|
+
},
|
|
938
|
+
values() {
|
|
939
|
+
const target = this[TARGET_SYMBOL];
|
|
940
|
+
subscribe(target, ANY_SYMBOL);
|
|
941
|
+
return wrapIteratorSingle(target.values());
|
|
942
|
+
},
|
|
943
|
+
entries() {
|
|
944
|
+
const target = this[TARGET_SYMBOL];
|
|
945
|
+
subscribe(target, ANY_SYMBOL);
|
|
946
|
+
return wrapIteratorPair(target.entries());
|
|
947
|
+
},
|
|
948
|
+
[Symbol.iterator]() {
|
|
949
|
+
const target = this[TARGET_SYMBOL];
|
|
950
|
+
subscribe(target, ANY_SYMBOL);
|
|
951
|
+
return wrapIteratorSingle(target[Symbol.iterator]());
|
|
952
|
+
}
|
|
953
|
+
};
|
|
890
954
|
var mapHandler = {
|
|
891
955
|
get(target, prop) {
|
|
892
956
|
if (prop === TARGET_SYMBOL)
|
|
@@ -901,6 +965,20 @@ var mapHandler = {
|
|
|
901
965
|
return target[prop];
|
|
902
966
|
}
|
|
903
967
|
};
|
|
968
|
+
var setHandler = {
|
|
969
|
+
get(target, prop) {
|
|
970
|
+
if (prop === TARGET_SYMBOL)
|
|
971
|
+
return target;
|
|
972
|
+
if (setMethodHandlers.hasOwnProperty(prop)) {
|
|
973
|
+
return setMethodHandlers[prop];
|
|
974
|
+
}
|
|
975
|
+
if (prop === "size") {
|
|
976
|
+
subscribe(target, MAP_SIZE_SYMBOL);
|
|
977
|
+
return target.size;
|
|
978
|
+
}
|
|
979
|
+
return target[prop];
|
|
980
|
+
}
|
|
981
|
+
};
|
|
904
982
|
var proxyMap = new WeakMap;
|
|
905
983
|
function optProxy(value) {
|
|
906
984
|
if (typeof value !== "object" || !value || value[TARGET_SYMBOL] !== undefined || NO_COPY in value) {
|
|
@@ -914,6 +992,8 @@ function optProxy(value) {
|
|
|
914
992
|
handler = arrayHandler;
|
|
915
993
|
} else if (value instanceof Map) {
|
|
916
994
|
handler = mapHandler;
|
|
995
|
+
} else if (value instanceof Set) {
|
|
996
|
+
handler = setHandler;
|
|
917
997
|
} else {
|
|
918
998
|
handler = objectHandler;
|
|
919
999
|
}
|
|
@@ -1295,7 +1375,7 @@ var SPECIAL_PROPS = {
|
|
|
1295
1375
|
function disableCreateDestroy() {
|
|
1296
1376
|
SPECIAL_PROPS.create = SPECIAL_PROPS.destroy = () => {};
|
|
1297
1377
|
}
|
|
1298
|
-
function
|
|
1378
|
+
function A(...args) {
|
|
1299
1379
|
let el = currentScope.el;
|
|
1300
1380
|
let svg = currentScope.svg;
|
|
1301
1381
|
const argCount = args.length;
|
|
@@ -1651,21 +1731,21 @@ function partition(source, func) {
|
|
|
1651
1731
|
function dump(data) {
|
|
1652
1732
|
if (data && typeof data === "object") {
|
|
1653
1733
|
const name = data.constructor.name.toLowerCase() || "unknown object";
|
|
1654
|
-
|
|
1734
|
+
A(`#<${name}>`);
|
|
1655
1735
|
if (NO_COPY in data) {
|
|
1656
|
-
|
|
1736
|
+
A("# [NO_COPY]");
|
|
1657
1737
|
} else {
|
|
1658
|
-
|
|
1738
|
+
A("ul", () => {
|
|
1659
1739
|
onEach(data, (value, key) => {
|
|
1660
|
-
|
|
1661
|
-
|
|
1740
|
+
A("li", () => {
|
|
1741
|
+
A(`#${JSON.stringify(key)}: `);
|
|
1662
1742
|
dump(value);
|
|
1663
1743
|
});
|
|
1664
1744
|
});
|
|
1665
1745
|
});
|
|
1666
1746
|
}
|
|
1667
1747
|
} else if (data !== undefined) {
|
|
1668
|
-
|
|
1748
|
+
A("#" + JSON.stringify(data));
|
|
1669
1749
|
}
|
|
1670
1750
|
return data;
|
|
1671
1751
|
}
|
|
@@ -1681,7 +1761,7 @@ function handleError(e, showMessage) {
|
|
|
1681
1761
|
}
|
|
1682
1762
|
try {
|
|
1683
1763
|
if (showMessage)
|
|
1684
|
-
|
|
1764
|
+
A("div.aberdeen-error#Error");
|
|
1685
1765
|
} catch {}
|
|
1686
1766
|
}
|
|
1687
1767
|
function withEmitHandler(handler, func) {
|
|
@@ -1695,15 +1775,15 @@ function withEmitHandler(handler, func) {
|
|
|
1695
1775
|
}
|
|
1696
1776
|
if (typeof document !== "undefined") {
|
|
1697
1777
|
leakScope(() => {
|
|
1698
|
-
|
|
1778
|
+
A(() => {
|
|
1699
1779
|
if (isEmpty(cssSnippets) && isEmpty(cssVars))
|
|
1700
1780
|
return;
|
|
1701
1781
|
mount(document.head, () => {
|
|
1702
|
-
|
|
1782
|
+
A("style.abd", () => {
|
|
1703
1783
|
onEach(cssSnippets, (value) => {
|
|
1704
|
-
|
|
1784
|
+
A("#", value);
|
|
1705
1785
|
});
|
|
1706
|
-
|
|
1786
|
+
A(() => {
|
|
1707
1787
|
if (isEmpty(cssVars))
|
|
1708
1788
|
return;
|
|
1709
1789
|
let css = ":root{";
|
|
@@ -1713,14 +1793,14 @@ if (typeof document !== "undefined") {
|
|
|
1713
1793
|
}
|
|
1714
1794
|
css += `}
|
|
1715
1795
|
`;
|
|
1716
|
-
|
|
1796
|
+
A("#", css);
|
|
1717
1797
|
});
|
|
1718
1798
|
});
|
|
1719
1799
|
});
|
|
1720
1800
|
});
|
|
1721
1801
|
});
|
|
1722
1802
|
}
|
|
1723
|
-
var
|
|
1803
|
+
var aberdeen_default = Object.assign(A, {
|
|
1724
1804
|
clean,
|
|
1725
1805
|
clone,
|
|
1726
1806
|
copy,
|
|
@@ -1750,7 +1830,6 @@ var A = Object.assign($, {
|
|
|
1750
1830
|
unmountAll,
|
|
1751
1831
|
unproxy
|
|
1752
1832
|
});
|
|
1753
|
-
var aberdeen_default = A;
|
|
1754
1833
|
export {
|
|
1755
1834
|
withEmitHandler,
|
|
1756
1835
|
unproxy,
|
|
@@ -1786,8 +1865,8 @@ export {
|
|
|
1786
1865
|
NO_COPY,
|
|
1787
1866
|
MAP_SIZE_SYMBOL,
|
|
1788
1867
|
EMPTY,
|
|
1789
|
-
|
|
1868
|
+
A
|
|
1790
1869
|
};
|
|
1791
1870
|
|
|
1792
|
-
//# debugId=
|
|
1871
|
+
//# debugId=3BD6C02AE5C4634B64756E2164756E21
|
|
1793
1872
|
//# sourceMappingURL=aberdeen.js.map
|