aberdeen 0.1.1 → 0.2.1

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.
Files changed (58) hide show
  1. package/.github/workflows/deploy.yml +43 -0
  2. package/.vscode/launch.json +23 -0
  3. package/README.md +11 -5
  4. package/{dist → dist-min}/aberdeen.d.ts +28 -153
  5. package/dist-min/aberdeen.js +2 -0
  6. package/dist-min/aberdeen.js.map +1 -0
  7. package/dist-min/prediction.d.ts +29 -0
  8. package/dist-min/prediction.js +2 -0
  9. package/dist-min/prediction.js.map +1 -0
  10. package/dist-min/route.d.ts +16 -0
  11. package/dist-min/route.js +2 -0
  12. package/dist-min/route.js.map +1 -0
  13. package/dist-min/transitions.d.ts +18 -0
  14. package/dist-min/transitions.js +2 -0
  15. package/dist-min/transitions.js.map +1 -0
  16. package/examples/input/index.html +8 -0
  17. package/examples/input/input.css +56 -0
  18. package/examples/input/input.js +66 -0
  19. package/examples/list/index.html +7 -0
  20. package/examples/list/list.js +47 -0
  21. package/examples/router/index.html +8 -0
  22. package/examples/router/page-home.js +12 -0
  23. package/examples/router/page-list.js +35 -0
  24. package/examples/router/page-settings.js +6 -0
  25. package/examples/router/router.js +76 -0
  26. package/examples/router/style.css +88 -0
  27. package/examples/tic-tac-toe/index.html +8 -0
  28. package/examples/tic-tac-toe/tic-tac-toe.css +50 -0
  29. package/examples/tic-tac-toe/tic-tac-toe.js +90 -0
  30. package/package.json +35 -27
  31. package/src/aberdeen.ts +2037 -0
  32. package/src/prediction.ts +117 -0
  33. package/src/route.ts +121 -0
  34. package/src/transitions.ts +73 -0
  35. package/tests/_fakedom.js +255 -0
  36. package/tests/_init.js +81 -0
  37. package/tests/array.js +109 -0
  38. package/tests/binding.js +106 -0
  39. package/tests/browsers.js +22 -0
  40. package/tests/clean.js +26 -0
  41. package/tests/count.js +105 -0
  42. package/tests/create.js +92 -0
  43. package/tests/destroy.js +270 -0
  44. package/tests/dom.js +219 -0
  45. package/tests/errors.js +114 -0
  46. package/tests/immediate.js +87 -0
  47. package/tests/map.js +76 -0
  48. package/tests/objmap.js +40 -0
  49. package/tests/onEach.js +392 -0
  50. package/tests/prediction.js +97 -0
  51. package/tests/props.js +49 -0
  52. package/tests/schedule.js +44 -0
  53. package/tests/scope.js +277 -0
  54. package/tests/sort.js +105 -0
  55. package/tests/store.js +254 -0
  56. package/tsconfig.json +67 -0
  57. package/dist/aberdeen.js +0 -1837
  58. package/dist/aberdeen.min.js +0 -1
@@ -0,0 +1,43 @@
1
+ name: Build, test and deploy
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ env:
9
+ NODE_VERSION: 20.x
10
+ ENTRY_FILE: 'src/aberdeen.ts'
11
+
12
+ permissions:
13
+ contents: read
14
+ pages: write
15
+ id-token: write
16
+
17
+ jobs:
18
+ deploy:
19
+ environment:
20
+ name: github-pages
21
+ url: ${{ steps.deployment.outputs.page_url }}
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v3
25
+ - name: Setup node.js
26
+ uses: actions/setup-node@v4
27
+ with:
28
+ node-version: '20.x'
29
+ registry-url: 'https://registry.npmjs.org'
30
+ - name: Install dependencies
31
+ run: npm ci
32
+ - name: Build docs
33
+ run: npm run build && cp -rav examples dist docs/
34
+ - name: Upload docs artifact
35
+ uses: actions/upload-pages-artifact@v3
36
+ with:
37
+ path: './docs'
38
+ - name: Deploy docs to GitHub Pages
39
+ uses: actions/deploy-pages@v4
40
+ - name: Test, build and deploy code to NPM
41
+ run: npm publish
42
+ env:
43
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,23 @@
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "type": "node",
9
+ "request": "launch",
10
+ "name": "Run Mocha Tests",
11
+ "skipFiles": [
12
+ "<node_internals>/**"
13
+ ],
14
+ "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
15
+ "args": [
16
+ "--file", "tests/_init.js", "tests/[^_]*.js"
17
+ ],
18
+ "outFiles": [
19
+ "${workspaceFolder}/**/*.js"
20
+ ]
21
+ }
22
+ ]
23
+ }
package/README.md CHANGED
@@ -8,13 +8,18 @@ The key insight is the use of many small anonymous functions, that will automati
8
8
  - It provides a flexible and simple to understand model for reactive user-interface building.
9
9
  - It allows you to express user-interfaces in plain JavaScript (or TypeScript) in an easy to read form, without (JSX-like) compilation steps.
10
10
  - It's fast, as it doesn't use a *virtual DOM* and only reruns small pieces of code in response to updated data. It also makes displaying and updating sorted lists very easy and very fast.
11
- - It's lightweight, at about 15kb minimized.
12
-
11
+ - It's lightweight, at about 14kb minimized and without any run-time dependencies.
12
+ - It comes with batteries included, providing modules for..
13
+ - Client-side routing.
14
+ - Optimistic user-interface updates (predictions) while awaiting a server response.
15
+ - Transitions.
13
16
 
14
17
  ## Examples
15
18
 
16
19
  - [Tic-tac-toe demo](https://vanviegen.github.io/aberdeen/examples/tic-tac-toe/) - [Source](https://github.com/vanviegen/aberdeen/tree/master/examples/tic-tac-toe)
17
20
  - [Input example demo](https://vanviegen.github.io/aberdeen/examples/input/) - [Source](https://github.com/vanviegen/aberdeen/tree/master/examples/input)
21
+ - [List example demo](https://vanviegen.github.io/aberdeen/examples/list/) - [Source](https://github.com/vanviegen/aberdeen/tree/master/examples/list)
22
+ - [Routing example demo](https://vanviegen.github.io/aberdeen/examples/router/) - [Source](https://github.com/vanviegen/aberdeen/tree/master/examples/router)
18
23
 
19
24
 
20
25
  To get a quick impression of what Aberdeen code looks like, this is all of the JavaScript for the above Tic-tac-toe demo:
@@ -122,9 +127,10 @@ https://vanviegen.github.io/aberdeen/modules.html
122
127
 
123
128
  - [x] Support for (dis)appear transitions.
124
129
  - [x] A better alternative for scheduleTask.
125
- - [ ] A simple router.
126
- - [ ] Architecture document.
130
+ - [x] A simple router.
127
131
  - [x] Optimistic client-side predictions.
128
- - [ ] SVG support.
132
+ - [ ] Support for (component local) CSS or possibly a tailwind-like abstraction.
129
133
  - [ ] More user friendly documentation generator.
134
+ - [ ] Architecture document.
135
+ - [ ] SVG support.
130
136
  - [ ] Performance profiling and tuning regarding lists.
@@ -1,8 +1,3 @@
1
- interface QueueRunner {
2
- queueOrder: number;
3
- queueRun(): void;
4
- }
5
- type Patch = Map<ObsCollection, Map<any, [any, any]>>;
6
1
  /**
7
2
  * Schedule a DOM read operation to be executed in Aberdeen's internal task queue.
8
3
  *
@@ -39,100 +34,6 @@ export declare function scheduleDomReader(func: () => void): void;
39
34
  * @param func The function to be executed as a DOM write operation.
40
35
  */
41
36
  export declare function scheduleDomWriter(func: () => void): void;
42
- type SortKeyType = number | string | Array<number | string>;
43
- interface Observer {
44
- onChange(index: any, newData: DatumType, oldData: DatumType): void;
45
- }
46
- declare abstract class Scope implements QueueRunner, Observer {
47
- parentElement: Element | undefined;
48
- queueOrder: number;
49
- precedingSibling: Node | Scope | undefined;
50
- lastChild: Node | Scope | undefined;
51
- cleaners: Array<{
52
- _clean: (scope: Scope) => void;
53
- }>;
54
- isDead: boolean;
55
- constructor(parentElement: Element | undefined, precedingSibling: Node | Scope | undefined, queueOrder: number);
56
- findPrecedingNode(stopAt?: Scope | Node | undefined): Node | undefined;
57
- findLastNode(): Node | undefined;
58
- addNode(node: Node): void;
59
- remove(): void;
60
- _clean(): void;
61
- onChange(index: any, newData: DatumType, oldData: DatumType): void;
62
- abstract queueRun(): void;
63
- }
64
- declare class OnEachScope extends Scope {
65
- /** The Node we are iterating */
66
- collection: ObsCollection;
67
- /** A function returning a number/string/array that defines the position of an item */
68
- makeSortKey: (value: Store) => SortKeyType;
69
- /** A function that renders an item */
70
- renderer: (itemStore: Store) => void;
71
- /** The ordered list of currently item scopes */
72
- byPosition: OnEachItemScope[];
73
- /** The item scopes in a Map by index */
74
- byIndex: Map<any, OnEachItemScope>;
75
- /** Indexes that have been created/removed and need to be handled in the next `queueRun` */
76
- newIndexes: Set<any>;
77
- removedIndexes: Set<any>;
78
- constructor(parentElement: Element | undefined, precedingSibling: Node | Scope | undefined, queueOrder: number, collection: ObsCollection, renderer: (itemStore: Store) => void, makeSortKey: (itemStore: Store) => SortKeyType);
79
- onChange(index: any, newData: DatumType, oldData: DatumType): void;
80
- queueRun(): void;
81
- _clean(): void;
82
- renderInitial(): void;
83
- addChild(itemIndex: any): void;
84
- removeChild(itemIndex: any): void;
85
- findPosition(sortStr: string): number;
86
- insertAtPosition(child: OnEachItemScope): void;
87
- removeFromPosition(child: OnEachItemScope): void;
88
- }
89
- declare class OnEachItemScope extends Scope {
90
- parent: OnEachScope;
91
- itemIndex: any;
92
- sortStr: string;
93
- constructor(parentElement: Element | undefined, precedingSibling: Node | Scope | undefined, queueOrder: number, parent: OnEachScope, itemIndex: any);
94
- queueRun(): void;
95
- update(): void;
96
- }
97
- type DatumType = string | number | Function | boolean | null | undefined | ObsMap | ObsArray;
98
- declare abstract class ObsCollection {
99
- observers: Map<any, Set<Observer>>;
100
- addObserver(index: any, observer: Observer): boolean;
101
- removeObserver(index: any, observer: Observer): void;
102
- emitChange(index: any, newData: DatumType, oldData: DatumType): void;
103
- _clean(observer: Observer): void;
104
- setIndex(index: any, newValue: any, deleteMissing: boolean): void;
105
- abstract rawGet(index: any): DatumType;
106
- abstract rawSet(index: any, data: DatumType): void;
107
- abstract merge(newValue: any, deleteMissing: boolean): void;
108
- abstract getType(): string;
109
- abstract getRecursive(depth: number): object | Set<any> | Array<any>;
110
- abstract iterateIndexes(scope: OnEachScope): void;
111
- abstract normalizeIndex(index: any): any;
112
- abstract getCount(): number;
113
- }
114
- declare class ObsArray extends ObsCollection {
115
- data: Array<DatumType>;
116
- getType(): string;
117
- getRecursive(depth: number): any[];
118
- rawGet(index: any): DatumType;
119
- rawSet(index: any, newData: DatumType): void;
120
- merge(newValue: any, deleteMissing: boolean): boolean;
121
- iterateIndexes(scope: OnEachScope): void;
122
- normalizeIndex(index: any): any;
123
- getCount(): number;
124
- }
125
- declare class ObsMap extends ObsCollection {
126
- data: Map<any, DatumType>;
127
- getType(): string;
128
- getRecursive(depth: number): Map<any, any>;
129
- rawGet(index: any): DatumType;
130
- rawSet(index: any, newData: DatumType): void;
131
- merge(newValue: any, deleteMissing: boolean): boolean;
132
- iterateIndexes(scope: OnEachScope): void;
133
- normalizeIndex(index: any): any;
134
- getCount(): number;
135
- }
136
37
  /**
137
38
  * A data store that automatically subscribes the current scope to updates
138
39
  * whenever data is read from it.
@@ -142,8 +43,6 @@ declare class ObsMap extends ObsCollection {
142
43
  * values, creating a tree of `Store`-objects.
143
44
  */
144
45
  export declare class Store {
145
- private collection;
146
- private idx;
147
46
  /**
148
47
  * Create a new store with the given `value` as its value. Defaults to `undefined` if no value is given.
149
48
  * When the value is a plain JavaScript object, an `Array` or a `Map`, it will be stored as a tree of
@@ -158,8 +57,6 @@ export declare class Store {
158
57
  */
159
58
  constructor();
160
59
  constructor(value: any);
161
- /** @internal */
162
- constructor(collection: ObsCollection, index: any);
163
60
  /**
164
61
  *
165
62
  * @returns The index for this Store within its parent collection. This will be a `number`
@@ -175,8 +72,6 @@ export declare class Store {
175
72
  * ```
176
73
  */
177
74
  index(): any;
178
- /** @internal */
179
- _clean(scope: Scope): void;
180
75
  /**
181
76
  * @returns Resolves `path` and then retrieves the value that is there, subscribing
182
77
  * to all read `Store` values. If `path` does not exist, `undefined` is returned.
@@ -412,8 +307,6 @@ export declare class Store {
412
307
  * ```
413
308
  */
414
309
  makeRef(...path: any[]): Store;
415
- /** @internal */
416
- _observe(): DatumType;
417
310
  /**
418
311
  * Iterate the specified collection (Array, Map or object), running the given code block for each item.
419
312
  * When items are added to the collection at some later point, the code block will be ran for them as well.
@@ -461,6 +354,10 @@ export declare class Store {
461
354
  * does not exist.
462
355
  */
463
356
  isDetached(): boolean;
357
+ /**
358
+ * Dump a live view of the `Store` tree as HTML text, `ul` and `li` nodes at
359
+ * the current mount position. Meant for debugging purposes.
360
+ */
464
361
  dump(): void;
465
362
  }
466
363
  /**
@@ -565,7 +462,7 @@ export declare function getParentElement(): Element;
565
462
  * disappears or redraws.
566
463
  * @param clean - The function to be executed.
567
464
  */
568
- export declare function clean(clean: (scope: Scope) => void): void;
465
+ export declare function clean(clean: () => void): void;
569
466
  /**
570
467
  * Reactively run a function, meaning the function will rerun when any `Store` that was read
571
468
  * during its execution is updated.
@@ -573,6 +470,7 @@ export declare function clean(clean: (scope: Scope) => void): void;
573
470
  * no cause the outer function to rerun.
574
471
  *
575
472
  * @param func - The function to be (repeatedly) executed.
473
+ * @returns The mount id (usable for `unmount`) if this is a top-level observe.
576
474
  * @example
577
475
  * ```
578
476
  * let number = new Store(0)
@@ -587,12 +485,23 @@ export declare function clean(clean: (scope: Scope) => void): void;
587
485
  * console.log(doubled.get())
588
486
  * })
589
487
  */
590
- export declare function observe(func: () => void): void;
488
+ export declare function observe(func: () => void): number | undefined;
489
+ /**
490
+ * Like `observe`, but instead of deferring running the observer function until
491
+ * a setTimeout 0, run it immediately and synchronously when a change to one of
492
+ * the observed `Store`s is made. Use this sparingly, as this prevents Aberdeen
493
+ * from doing the usual batching and smart ordering of observers, leading to
494
+ * performance problems and observing of 'weird' partial states.
495
+ * @param func The function to be (repeatedly) executed.
496
+ * @returns The mount id (usable for `unmount`) if this is a top-level observe.
497
+ */
498
+ export declare function immediateObserve(func: () => void): number | undefined;
591
499
  /**
592
500
  * Like {@link Store.observe}, but allow the function to create DOM elements using {@link Store.node}.
593
501
 
594
502
  * @param func - The function to be (repeatedly) executed, possibly adding DOM elements to `parentElement`.
595
503
  * @param parentElement - A DOM element that will be used as the parent element for calls to `node`.
504
+ * @returns The mount id (usable for `unmount`) if this is a top-level mount.
596
505
  *
597
506
  * @example
598
507
  * ```
@@ -628,7 +537,13 @@ export declare function observe(func: () => void): void;
628
537
  * })
629
538
  * ```
630
539
  */
631
- export declare function mount(parentElement: Element | undefined, func: () => void): void;
540
+ export declare function mount(parentElement: Element, func: () => void): number | undefined;
541
+ /**
542
+ * Unmount one specific or all top-level mounts or observes, meaning those that were created outside of the scope
543
+ * of any other mount or observe.
544
+ * @param id Optional mount number (as returned by `mount`, `observe` or `immediateObserve`). If `undefined`, unmount all.
545
+ */
546
+ export declare function unmount(id?: number): void;
632
547
  /** Runs the given function, while not subscribing the current scope when reading {@link Store.Store} values.
633
548
  *
634
549
  * @param func Function to be executed immediately.
@@ -651,48 +566,8 @@ export declare function mount(parentElement: Element | undefined, func: () => vo
651
566
  * for `count()` however.
652
567
  */
653
568
  export declare function peek<T>(func: () => T): T;
654
- /** Do a grow transition for the given element. This is meant to be used as a
655
- * handler for the `create` property.
656
- *
657
- * @param el The element to transition.
658
- *
659
- * The transition doesn't look great for table elements, and may have problems
660
- * for other specific cases as well.
661
- */
662
- export declare function grow(el: HTMLElement): void;
663
- /** Do a shrink transition for the given element, and remove it from the DOM
664
- * afterwards. This is meant to be used as a handler for the `destroy` property.
665
- *
666
- * @param el The element to transition and remove.
667
- *
668
- * The transition doesn't look great for table elements, and may have problems
669
- * for other specific cases as well.
670
- */
671
- export declare function shrink(el: HTMLElement): void;
672
- /**
673
- * Run the provided function, while treating all changes to Observables as predictions,
674
- * meaning they will be reverted when changes come back from the server (or some other
675
- * async source).
676
- * @param predictFunc The function to run. It will generally modify some Observables
677
- * to immediately reflect state (as closely as possible) that we expect the server
678
- * to communicate back to us later on.
679
- * @returns A `Patch` object. Don't modify it. This is only meant to be passed to `applyCanon`.
680
- */
681
- export declare function applyPrediction(predictFunc: () => void): Patch;
682
569
  /**
683
- * Temporarily revert all outstanding predictions, optionally run the provided function
684
- * (which will generally make authoritative changes to the data based on a server response),
685
- * and then attempt to reapply the predictions on top of the new canonical state, dropping
686
- * any predictions that can no longer be applied cleanly (the data has been modified) or
687
- * that were specified in `dropPredictions`.
688
- *
689
- * All of this is done such that redraws are only triggered if the overall effect is an
690
- * actual change to an `Observable`.
691
- * @param canonFunc The function to run without any predictions applied. This will typically
692
- * make authoritative changes to the data, based on a server response.
693
- * @param dropPredictions An optional list of predictions (as returned by `applyPrediction`)
694
- * to undo. Typically, when a server response for a certain request is being handled,
695
- * you'd want to drop the prediction that was done for that request.
570
+ * Run a function, while *not* causing reactive effects for any changes it makes to `Store`s.
571
+ * @param func The function to be executed once immediately.
696
572
  */
697
- export declare function applyCanon(canonFunc?: (() => void), dropPredictions?: Array<Patch>): void;
698
- export {};
573
+ export declare function inhibitEffects(func: () => void): void;
@@ -0,0 +1,2 @@
1
+ let t,e=[],i=new Set,n=!0,r=0;function o(t){if(!i.has(t)){if(r>42)throw new Error("Too many recursive updates from observes");e.length?t.t<e[e.length-1].t&&(n=!1):setTimeout(s,0),e.push(t),i.add(t)}}function s(){for(O=!0,t=0;t<e.length;){n||(e.splice(0,t),t=0,e.sort(((t,e)=>t.t-e.t)),n=!0);let o=e.length;for(;t<o&&n;t++){let n=e[t];i.delete(n),n.i()}r++}e.length=0,t=void 0,r=0,O=!1}export function scheduleDomReader(i){o({t:null!=t&&t<e.length&&e[t].t>=1e3?e[t].t+1&-2:1e3,i:i})}export function scheduleDomWriter(i){o({t:null!=t&&t<e.length&&e[t].t>=1e3?1|e[t].t:1001,i:i})}function h(t){if("string"==typeof t)return t+"";{let e=function(t,e){let i="";for(;t>0;)i+=String.fromCharCode(e?65535-t%65533:2+t%65533),t=Math.floor(t/65533);return i}(Math.abs(Math.round(t)),t<0);return String.fromCharCode(128+(t>0?e.length:-e.length))+e}}class l{constructor(t,e,i){this.o=[],this.h=!1,this.l=t,this.u=e,this.t=i}p(t=void 0){let e,i=this;for(;(e=i.u)&&e!==t;){if(e instanceof Node)return e;let t=e.v();if(t)return t;i=e}}v(){if(this.m)return this.m instanceof Node?this.m:this.m.v()||this.m.p(this.u)}_(t){if(!this.l)throw new k(!0);let e=this.v()||this.p();this.l.insertBefore(t,e?e.nextSibling:this.l.firstChild),this.m=t}O(){if(this.l){let t=this.v();if(t){let e=this.p();for(e=e?e.nextSibling:this.l.firstChild,this.m=void 0;;){if(!e)return I(1);const i=e;e=i.nextSibling||void 0;let n=S.get(i);if(n&&i instanceof Element?!0!==n&&("function"==typeof n?n(i):C(i,n),S.set(i,!0)):this.l.removeChild(i),i===t)break}}}this.S()}S(){this.h=!0;for(let t of this.o)t.S(this);this.o.length=0}C(t,e,i){o(this)}}class u extends l{constructor(t,e,i,n){super(t,e,i),this.N=n}i(){a&&I(2),this.h||(this.O(),this.h=!1,this.$())}$(){let t=a;a=this;try{this.N()}catch(t){R(t)}a=t}}let f=new Set;class c extends u{C(t,e,i){f.add(this)}}let a,d=!1;function p(){if(!d)for(let t=0;f.size;t++){if(t>42)throw f.clear(),new Error("Too many recursive updates from immediate-mode observes");d=!0;let e=f;f=new Set;let i=a;a=void 0;try{for(const t of e)t.i()}finally{a=i,d=!1}}}class w{constructor(t,e,i){this.scope=t,this.collection=e,this.triggerCount=i,this.count=e.j(),e.M(b,this),t.o.push(this)}C(t,e,i){void 0===e?!this.triggerCount&&--this.count||o(this.scope):void 0===i&&(!this.triggerCount&&this.count++||o(this.scope))}S(){this.collection.J(b,this)}}class v extends l{constructor(t,e,i,n,r,o){super(t,e,i),this.T=[],this.I=new Map,this.R=new Set,this.k=new Set,this.q=n,this.N=r,this.A=o}C(t,e,i){void 0===i?this.k.has(t)?this.k.delete(t):(this.R.add(t),o(this)):void 0===e&&(this.R.has(t)?this.R.delete(t):(this.k.add(t),o(this)))}i(){if(this.h)return;let t=this.k;this.k=new Set,t.forEach((t=>{this.P(t)})),t=this.R,this.R=new Set,t.forEach((t=>{this.D(t)}))}S(){super.S(),this.q.V.delete(this);for(const[t,e]of this.I)e.S();this.T.length=0,this.I.clear()}F(){if(!a)return I(3);let t=a;this.q.G(this),a=t}D(t){let e=new m(this.l,void 0,this.t+1,this,t);this.I.set(t,e),e.$()}P(t){let e=this.I.get(t);if(!e)return I(6);e.O(),this.I.delete(t),this.H(e)}W(t){let e=this.T,i=0,n=e.length;if(!n||t>e[n-1].B)return n;for(;i<n;){let r=i+n>>1;e[r].B<t?i=r+1:n=r}return i}L(t){let e=this.W(t.B);this.T.splice(e,0,t);let i=this.T[e+1];i?(t.u=i.u,i.u=t):(t.u=this.m||this.u,this.m=t)}H(t){if(""===t.B)return;let e=this.W(t.B);for(;;){if(this.T[e]===t){if(this.T.splice(e,1),e<this.T.length){let i=this.T[e];if(!i)return I(8);if(i.u!==t)return I(13);i.u=t.u}else{if(t!==this.m)return I(12);this.m=t.u===this.u?void 0:t.u}return}if(++e>=this.T.length||this.T[e].B!==t.B)return I(5)}}}class m extends l{constructor(t,e,i,n,r){super(t,e,i),this.B="",this.U=n,this.K=r}i(){a&&I(4),this.h||(this.O(),this.h=!1,this.$())}$(){let t=a;a=this;let e,i=new Store(this.U.q,this.K);try{e=this.U.A(i)}catch(t){R(t)}let n=this.B,r=null==e?"":(o=e)instanceof Array?o.map(h).join(""):h(o);var o;if(""!==n&&n!==r&&this.U.H(this),this.B=r,""!==r){r!==n&&this.U.L(this);try{this.U.N(i)}catch(t){R(t)}}a=t}}const b={};export class ObsCollection{constructor(){this.V=new Map}M(t,e){let i=this.V.get(t);if(i){if(i.has(e))return!1;i.add(e)}else this.V.set(t,new Set([e]));return!0}J(t,e){this.V.get(t).delete(e)}emitChange(t,e,i){let n=this.V.get(t);n&&n.forEach((n=>n.C(t,e,i))),n=this.V.get(b),n&&n.forEach((n=>n.C(t,e,i)))}S(t){this.J(b,t)}X(t,e,i){const n=this.rawGet(t);if(!(n instanceof ObsCollection)||e instanceof Store||!n.Y(e,i)){let i=J(e);i!==n&&(this.rawSet(t,i),this.emitChange(t,i,n))}}}class y extends ObsCollection{constructor(){super(...arguments),this.Z=[]}tt(){return"array"}et(t){a&&this.M(b,a)&&a.o.push(this);let e=[];for(let i=0;i<this.Z.length;i++){let n=this.Z[i];e.push(n instanceof ObsCollection?t?n.et(t-1):new Store(this,i):n)}return e}rawGet(t){return this.Z[t]}rawSet(t,e){if(t!==(0|t)||t<0||t>999999)throw new Error(`Invalid array index ${JSON.stringify(t)}`);for(this.Z[t]=e;this.Z.length>0&&void 0===this.Z[this.Z.length-1];)this.Z.pop()}Y(t,e){if(!(t instanceof Array))return!1;for(let i=0;i<t.length;i++)this.X(i,t[i],e);if(this.Z.length>t.length){for(let e=t.length;e<this.Z.length;e++){let t=this.Z[e];void 0!==t&&this.emitChange(e,void 0,t)}this.Z.length=t.length}return!0}G(t){for(let e=0;e<this.Z.length;e++)void 0!==this.Z[e]&&t.D(e)}it(t){if("number"==typeof t)return t;if("string"==typeof t){let e=0|t;if(t.length&&e==t)return t}throw new Error(`Invalid array index ${JSON.stringify(t)}`)}j(){return this.Z.length}}class _ extends ObsCollection{constructor(){super(...arguments),this.data=new Map}tt(){return"map"}et(t){a&&this.M(b,a)&&a.o.push(this);let e=new Map;return this.data.forEach(((i,n)=>{e.set(n,i instanceof ObsCollection?t?i.et(t-1):new Store(this,n):i)})),e}rawGet(t){return this.data.get(t)}rawSet(t,e){void 0===e?this.data.delete(t):this.data.set(t,e)}Y(t,e){return t instanceof Map&&(t.forEach(((t,i)=>{this.X(i,t,e)})),e&&this.data.forEach(((e,i)=>{t.has(i)||this.X(i,void 0,!1)})),!0)}G(t){this.data.forEach(((e,i)=>{t.D(i)}))}it(t){return t}j(){return this.data.size}}class g extends _{tt(){return"object"}et(t){a&&this.M(b,a)&&a.o.push(this);let e={};return this.data.forEach(((i,n)=>{e[n]=i instanceof ObsCollection?t?i.et(t-1):new Store(this,n):i})),e}Y(t,e){if(!t||t.constructor!==Object)return!1;for(let i in t)this.X(i,t[i],e);return e&&this.data.forEach(((e,i)=>{t.hasOwnProperty(i)||this.X(i,void 0,!1)})),!0}it(t){let e=typeof t;if("string"===e)return t;if("number"===e)return""+t;throw new Error(`Invalid object index ${JSON.stringify(t)}`)}j(){let t=0;for(let e of this.data)t++;return t}}export class Store{constructor(t=void 0,e=void 0){if(void 0===e)this.q=new y,this.nt=0,void 0!==t&&this.q.rawSet(0,J(t));else{if(!(t instanceof ObsCollection))throw new Error("1st parameter should be an ObsCollection if the 2nd is also given");this.q=t,this.nt=e}}index(){return this.nt}S(t){this.q.J(this.nt,t)}get(...t){return this.query({path:t})}peek(...t){return this.query({path:t,peek:!0})}getNumber(...t){return this.query({path:t,type:"number"})}getString(...t){return this.query({path:t,type:"string"})}getBoolean(...t){return this.query({path:t,type:"boolean"})}getFunction(...t){return this.query({path:t,type:"function"})}getArray(...t){return this.query({path:t,type:"array"})}getObject(...t){return this.query({path:t,type:"object"})}getMap(...t){return this.query({path:t,type:"map"})}getOr(t,...e){let i=typeof t;return"object"===i&&(t instanceof Map?i="map":t instanceof Array&&(i="array")),this.query({type:i,defaultValue:t,path:e})}query(t){if(t.peek&&a){let e=a;a=void 0;let i=this.query(t);return a=e,i}let e=(t.path&&t.path.length?this.ref(...t.path):this).rt();if(t.type&&(void 0!==e||void 0===t.defaultValue)){let i=e instanceof ObsCollection?e.tt():null===e?"null":typeof e;if(i!==t.type)throw new TypeError(`Expecting ${t.type} but got ${i}`)}return e instanceof ObsCollection?e.et(null==t.depth?-1:t.depth-1):void 0===e?t.defaultValue:e}isEmpty(...t){let e=this.ref(...t).rt();if(e instanceof ObsCollection){if(a){return!new w(a,e,!1).count}return!e.j()}if(void 0===e)return!0;throw new Error(`isEmpty() expects a collection or undefined, but got ${JSON.stringify(e)}`)}count(...t){let e=this.ref(...t).rt();if(e instanceof ObsCollection){if(a){return new w(a,e,!0).count}return e.j()}if(void 0===e)return 0;throw new Error(`count() expects a collection or undefined, but got ${JSON.stringify(e)}`)}getType(...t){let e=this.ref(...t).rt();return e instanceof ObsCollection?e.tt():null===e?"null":typeof e}set(...t){let e=t.pop(),i=this.makeRef(...t);i.q.X(i.nt,e,!0),p()}merge(...t){let e=t.pop(),i=this.makeRef(...t);i.q.X(i.nt,e,!1),p()}delete(...t){let e=this.makeRef(...t);e.q.X(e.nt,void 0,!0),p()}push(...t){let e=t.pop(),i=this.makeRef(...t),n=i.q.rawGet(i.nt);if(void 0===n)n=new y,i.q.X(i.nt,n,!0);else if(!(n instanceof y))throw new Error("push() is only allowed for an array or undefined (which would become an array)");let r=J(e),o=n.Z.length;return n.Z.push(r),n.emitChange(o,r,void 0),p(),o}modify(t){this.set(t(this.query({peek:!0})))}ref(...t){let e=this;for(let i=0;i<t.length;i++){let n=e.rt();if(!(n instanceof ObsCollection)){if(void 0!==n)throw new Error(`Value ${JSON.stringify(n)} is not a collection (nor undefined) in step ${i} of $(${JSON.stringify(t)})`);return new x}e=new Store(n,n.it(t[i]))}return e}makeRef(...t){let e=this;for(let i=0;i<t.length;i++){let n=e.q.rawGet(e.nt);if(!(n instanceof ObsCollection)){if(void 0!==n)throw new Error(`Value ${JSON.stringify(n)} is not a collection (nor undefined) in step ${i} of $(${JSON.stringify(t)})`);n=new g,e.q.rawSet(e.nt,n),e.q.emitChange(e.nt,n,void 0)}e=new Store(n,n.it(t[i]))}return p(),e}rt(){return a&&this.q.M(this.nt,a)&&a.o.push(this),this.q.rawGet(this.nt)}onEach(...t){let e=T,i=t.pop();if("function"!=typeof t[t.length-1]||"function"!=typeof i&&null!=i||(null!=i&&(e=i),i=t.pop()),"function"!=typeof i)throw new Error(`onEach() expects a render function as its last argument but got ${JSON.stringify(i)}`);if(!a)throw new k(!1);let n=this.ref(...t).rt();if(n instanceof ObsCollection){let t=new v(a.l,a.m||a.u,a.t+1,n,i,e);n.M(b,t),a.o.push(t),a.m=t,t.F()}else if(void 0!==n)throw new Error("onEach() attempted on a value that is neither a collection nor undefined")}map(t){let e=new Store(new Map);return this.onEach((i=>{let n=t(i);if(void 0!==n){let t=i.index();e.set(t,n),clean((()=>{e.delete(t)}))}})),e}multiMap(t){let e=new Store(new Map);return this.onEach((i=>{let n,r=t(i);if(r.constructor===Object){for(let t in r)e.set(t,r[t]);n=Object.keys(r)}else{if(!(r instanceof Map))return;r.forEach(((t,i)=>{e.set(i,t)})),n=[...r.keys()]}n.length&&clean((()=>{for(let t of n)e.delete(t)}))})),e}isDetached(){return!1}dump(){let t=this.getType();"array"===t||"object"===t||"map"===t?(text("<"+t+">"),node("ul",(()=>{this.onEach((t=>{node("li",(()=>{text(JSON.stringify(t.index())+": "),t.dump()}))}))}))):text(JSON.stringify(this.get()))}}class x extends Store{isDetached(){return!0}}let O=!1,S=new WeakMap;function C(t,e){t.classList.add(e),setTimeout((()=>t.remove()),2e3)}export function node(t="",...e){if(!a)throw new k(!0);let i;if(t instanceof Element)i=t;else{let e,n=t.indexOf(".");n>=0&&(e=t.substr(n+1),t=t.substr(0,n)),i=document.createElement(t||"div"),e&&(i.className=e.replaceAll("."," "))}a._(i);for(let t of e){let e=typeof t;if("function"===e){let e=new u(i,void 0,a.t+1,t);O?(O=!1,e.$(),O=!0):e.$(),a.o.push(e)}else if("string"===e||"number"===e)i.textContent=t;else if("object"===e&&t&&t.constructor===Object)for(let e in t)M(i,e,t[e]);else if(t instanceof Store)E(i,t);else if(null!=t)throw new Error(`Unexpected argument ${JSON.stringify(t)}`)}}export function html(t){if(!a||!a.l)throw new k(!0);let e=document.createElement(a.l.tagName);for(e.innerHTML=""+t;e.firstChild;)a._(e.firstChild)}function E(t,e){let i,n,r=t.getAttribute("type"),o=e.query({peek:!0});"checkbox"===r?(void 0===o&&e.set(t.checked),i=e=>t.checked=e,n=()=>e.set(t.checked)):"radio"===r?(void 0===o&&t.checked&&e.set(t.value),i=e=>t.checked=e===t.value,n=()=>{t.checked&&e.set(t.value)}):(n=()=>e.set("number"===r||"range"===r?""===t.value?null:+t.value:t.value),void 0===o&&n(),i=e=>{t.value!==e&&(t.value=e)}),observe((()=>{i(e.get())})),t.addEventListener("input",n),clean((()=>{t.removeEventListener("input",n)}))}export function text(t){if(!a)throw new k(!0);null!=t&&a._(document.createTextNode(t))}export function prop(t,e=void 0){if(!a||!a.l)throw new k(!0);if("object"==typeof t)for(let e in t)M(a.l,e,t[e]);else M(a.l,t,e)}export function getParentElement(){if(!a||!a.l)throw new k(!0);return a.l}export function clean(t){if(!a)throw new k(!1);a.o.push({S:t})}export function observe(t){return j(void 0,t,u)}export function immediateObserve(t){return j(void 0,t,c)}export function mount(t,e){return j(t,e,u)}let N=0;const $=new Map;function j(t,e,i){let n;if(t||!a?n=new i(t,void 0,0,e):(n=new i(a.l,a.m||a.u,a.t+1,e),a.m=n),n.$(),!a)return $.set(++N,n),N;a.o.push(n)}export function unmount(t){if(null==t){for(let t of $.values())t.O();$.clear()}else{let e=$.get(t);if(!e)throw new Error("No such mount "+t);e.O()}}export function peek(t){let e=a;a=void 0;try{return t()}finally{a=e}}function M(t,e,i){if("create"===e)O&&("function"==typeof i?i(t):(t.classList.add(i),setTimeout((function(){t.classList.remove(i)}),0)));else if("destroy"===e)S.set(t,i);else if("function"==typeof i)t.addEventListener(e,i),clean((()=>t.removeEventListener(e,i)));else if("value"===e||"className"===e||"selectedIndex"===e||!0===i||!1===i)t[e]=i;else if("text"===e)t.textContent=i;else if("class"!==e&&"className"!==e||"object"!=typeof i)"style"===e&&"object"==typeof i?Object.assign(t.style,i):t.setAttribute(e,i);else for(let e in i)i[e]?t.classList.add(e):t.classList.remove(e)}function J(t){if("object"==typeof t&&t){if(t instanceof Store)return t.rt();if(t instanceof Map){let e=new _;return t.forEach(((t,i)=>{let n=J(t);void 0!==n&&e.rawSet(i,n)})),e}if(t instanceof Array){let e=new y;for(let i=0;i<t.length;i++){let n=J(t[i]);void 0!==n&&e.rawSet(i,n)}return e}if(t.constructor===Object){let e=new g;for(let i in t){let n=J(t[i]);void 0!==n&&e.rawSet(i,n)}return e}return t}return t}function T(t){return t.index()}function I(t){let e=new Error("Aberdeen internal error "+t);setTimeout((()=>{throw e}),0)}function R(t){setTimeout((()=>{throw t}),0)}class k extends Error{constructor(t){super(`Operation not permitted outside of ${t?"a mount":"an observe"}() scope`)}}export function withEmitHandler(t,e){const i=ObsCollection.prototype.emitChange;ObsCollection.prototype.emitChange=t;try{e()}finally{ObsCollection.prototype.emitChange=i}}export function inhibitEffects(t){withEmitHandler((()=>{}),t)}String.prototype.replaceAll||(String.prototype.replaceAll=function(t,e){return this.split(t).join(e)});
2
+ //# sourceMappingURL=aberdeen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["queueIndex","queueArray","queueSet","Set","queueOrdered","runQueueDepth","queue","runner","has","Error","length","_queueOrder","setTimeout","runQueue","push","add","onCreateEnabled","splice","sort","a","b","batchEndIndex","delete","_queueRun","undefined","scheduleDomReader","func","scheduleDomWriter","partToStr","part","result","num","neg","String","fromCharCode","Math","floor","numToString","abs","round","Scope","constructor","parentElement","precedingSibling","queueOrder","this","_cleaners","_isDead","_parentElement","_precedingSibling","_findPrecedingNode","stopAt","pre","cur","Node","node","_findLastNode","_lastChild","_addNode","ScopeError","prevNode","insertBefore","nextSibling","firstChild","_remove","lastNode","nextNode","internalError","onDestroy","onDestroyMap","get","Element","destroyWithClass","set","removeChild","_clean","cleaner","_onChange","index","newData","oldData","SimpleScope","renderer","super","_renderer","currentScope","_update","savedScope","e","handleError","immediateQueue","ImmediateScope","immediateQueuerRunning","runImmediateQueue","count","size","clear","copy","scope","IsEmptyObserver","collection","triggerCount","_getCount","_addObserver","ANY_INDEX","_removeObserver","OnEachScope","makeSortKey","_byPosition","_byIndex","Map","_newIndexes","_removedIndexes","_collection","_makeSortKey","indexes","forEach","_removeChild","_addChild","_observers","_renderInitial","parentScope","_iterateIndexes","itemIndex","OnEachItemScope","_removeFromPosition","_findPosition","sortStr","items","min","max","_sortStr","mid","_insertAtPosition","child","pos","parent","_parent","_itemIndex","sortKey","itemStore","Store","oldSortStr","newSortStr","key","Array","map","join","ObsCollection","observer","obsSet","emitChange","_setIndex","newValue","deleteMissing","curData","rawGet","_merge","valueToData","rawSet","ObsArray","_data","_getType","_getRecursive","depth","i","v","JSON","stringify","pop","old","_normalizeIndex","ObsMap","data","k","_","ObsObject","Object","hasOwnProperty","type","cnt","value","_idx","path","query","peek","getNumber","getString","getBoolean","getFunction","getArray","getObject","getMap","getOr","defaultValue","opts","ref","_observe","TypeError","isEmpty","getType","pathAndValue","store","makeRef","merge","mergeValue","obsArray","modify","DetachedStore","onEach","pathAndFuncs","defaultMakeSortKey","val","onEachScope","out","item","clean","multiMap","keys","isDetached","dump","text","sub","WeakMap","element","cls","classList","remove","tag","rest","el","classes","indexOf","substr","document","createElement","className","replaceAll","textContent","applyProp","bindInput","html","tmpParent","tagName","innerHTML","onStoreChange","onInputChange","getAttribute","checked","observe","addEventListener","removeEventListener","createTextNode","prop","name","getParentElement","_mount","immediateObserve","mount","maxTopScopeId","topScopes","MountScope","unmount","id","values","assign","style","setAttribute","d","code","error","withEmitHandler","handler","oldEmitHandler","prototype","inhibitEffects","from","to","split"],"sources":["../src/aberdeen.ts"],"mappings":"AAaA,IAIIA,EAJAC,EAAiC,GACjCC,EAA6B,IAAIC,IACjCC,GAAe,EACfC,EAAgB,EAMpB,SAASC,EAAMC,GACd,IAAIL,EAASM,IAAID,GAAjB,CACA,GAAIF,EAAgB,GACnB,MAAM,IAAII,MAAM,4CAEZR,EAAWS,OAGPH,EAAOI,EAAcV,EAAWA,EAAWS,OAAO,GAAGC,IAC7DP,GAAe,GAHfQ,WAAWC,EAAU,GAKtBZ,EAAWa,KAAKP,GAChBL,EAASa,IAAIR,EAXa,CAY3B,CAEA,SAASM,IAER,IADAG,GAAkB,EACdhB,EAAa,EAAGA,EAAaC,EAAWS,QAAU,CAEhDN,IACJH,EAAWgB,OAAO,EAAGjB,GACrBA,EAAa,EAEbC,EAAWiB,MAAK,CAACC,EAAEC,IAAMD,EAAER,EAAcS,EAAET,IAC3CP,GAAe,GAIhB,IAAIiB,EAAgBpB,EAAWS,OAC/B,KAAMV,EAAaqB,GAAiBjB,EAAcJ,IAAc,CAC/D,IAAIO,EAASN,EAAWD,GACxBE,EAASoB,OAAOf,GAChBA,EAAOgB,G,CAKRlB,G,CAGDJ,EAAWS,OAAS,EACpBV,OAAawB,EACbnB,EAAgB,EAChBW,GAAkB,CACnB,QAoBM,SAAUS,kBAAkBC,GAEjCpB,EAAM,CAACK,EADkB,MAAZ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treating all changes to Observables as predictions,
5
+ * meaning they will be reverted when changes come back from the server (or some other
6
+ * async source).
7
+ * @param predictFunc The function to run. It will generally modify some Observables
8
+ * to immediately reflect state (as closely as possible) that we expect the server
9
+ * to communicate back to us later on.
10
+ * @returns A `Patch` object. Don't modify it. This is only meant to be passed to `applyCanon`.
11
+ */
12
+ export declare function applyPrediction(predictFunc: () => void): Patch;
13
+ /**
14
+ * Temporarily revert all outstanding predictions, optionally run the provided function
15
+ * (which will generally make authoritative changes to the data based on a server response),
16
+ * and then attempt to reapply the predictions on top of the new canonical state, dropping
17
+ * any predictions that can no longer be applied cleanly (the data has been modified) or
18
+ * that were specified in `dropPredictions`.
19
+ *
20
+ * All of this is done such that redraws are only triggered if the overall effect is an
21
+ * actual change to an `Observable`.
22
+ * @param canonFunc The function to run without any predictions applied. This will typically
23
+ * make authoritative changes to the data, based on a server response.
24
+ * @param dropPredictions An optional list of predictions (as returned by `applyPrediction`)
25
+ * to undo. Typically, when a server response for a certain request is being handled,
26
+ * you'd want to drop the prediction that was done for that request.
27
+ */
28
+ export declare function applyCanon(canonFunc?: (() => void), dropPredictions?: Array<Patch>): void;
29
+ export {};
@@ -0,0 +1,2 @@
1
+ import{withEmitHandler as t}from"aberdeen";function o(o){const n=new Map;return t((function(t,o,f){e(n,this,t,o,f)}),o),n}function e(t,o,e,n,f){let r=t.get(o);r||(r=new Map,t.set(o,r));let l=r.get(e);l&&(f=l[1]),n===f?r.delete(e):r.set(e,[n,f])}function n(t){for(let[o,e]of t)for(let[t,[n,f]]of e)o.emitChange(t,n,f)}function f(t,o,n=!1){for(let[f,r]of o)for(let[o,[l,i]]of r)e(t,f,o,n?i:l,n?l:i)}function r(t,o=!1){for(let[e,n]of t)for(let[t,[f,r]]of n){let n=e.rawGet(t);if(n!==r){if(!o)return!1;setTimeout((()=>{throw new Error(`Applying invalid patch: data ${n} is unequal to expected old data ${r} for index ${t}`)}),0)}}for(let[o,e]of t)for(let[t,[n,f]]of e)o.rawSet(t,n);return!0}const l=[];export function applyPrediction(t){let e=o(t);return l.push(e),n(e),e}export function applyCanon(t,e=[]){let i=new Map;for(let t of l)f(i,t,!0);r(i,!0);for(let t of e){let o=l.indexOf(t);o>=0&&l.splice(o,1)}t&&f(i,o(t));for(let t=0;t<l.length;t++)r(l[t])?f(i,l[t]):(l.splice(t,1),t--);n(i)}
2
+ //# sourceMappingURL=prediction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withEmitHandler","recordPatch","func","recordingPatch","Map","index","newData","oldData","addToPatch","this","patch","collection","collectionMap","get","set","prev","delete","emitPatch","emitChange","mergePatch","target","source","reverse","silentlyApplyPatch","force","actualData","rawGet","setTimeout","Error","rawSet","appliedPredictions","applyPrediction","predictFunc","push","applyCanon","canonFunc","dropPredictions","resultPatch","prediction","pos","indexOf","splice","idx","length"],"sources":["../src/prediction.ts"],"mappings":"0BAAQA,MAAsB,WAM9B,SAASC,EAAYC,GACpB,MAAMC,EAAiB,IAAIC,IAI3B,OAHAJ,GAAgB,SAASK,EAAOC,EAASC,GACxCC,EAAWL,EAAgBM,KAAMJ,EAAOC,EAASC,EAClD,GAAGL,GACIC,CACR,CAEA,SAASK,EAAWE,EAAcC,EAA2BN,EAAYC,EAAcC,GACtF,IAAIK,EAAgBF,EAAMG,IAAIF,GACzBC,IACJA,EAAgB,IAAIR,IACpBM,EAAMI,IAAIH,EAAYC,IAEvB,IAAIG,EAAOH,EAAcC,IAAIR,GACzBU,IAAMR,EAAUQ,EAAK,IACrBT,IAAYC,EAASK,EAAcI,OAAOX,GACzCO,EAAcE,IAAIT,EAAO,CAACC,EAASC,GACzC,CAEA,SAASU,EAAUP,GAClB,IAAI,IAAKC,EAAYC,KAAkBF,EACtC,IAAI,IAAKL,GAAQC,EAASC,MAAaK,EACtCD,EAAWO,WAAWb,EAAOC,EAASC,EAGzC,CAEA,SAASY,EAAWC,EAAeC,EAAeC,GAAmB,GACpE,IAAI,IAAKX,EAAYC,KAAkBS,EACtC,IAAI,IAA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- `path`: The current path of the URL split into components. For instance `/` or `/users/123/feed`. Updates will be reflected in the URL and will *push* a new entry to the browser history.
5
+ * - `p`: Array containing the path segments. For instance `[]` or `['users', 123, 'feed']`. Updates will be reflected in the URL and will *push* a new entry to the browser history. Also, the values of `p` and `path` will be synced.
6
+ * - `search`: An observable object containing search parameters (a split up query string). For instance `{order: "date", title: "something"}` or just `{}`. Updates will be reflected in the URL, modifying the current history state.
7
+ * - `hash`: The document hash part of the URL. For instance `"#section-title"`. It can also be an empty string. Updates will be reflected in the URL, modifying the current history state.
8
+ * - `state`: The browser history *state* object for the current page. Creating or removing top-level keys will cause *pushing* a new entry to the browser history.
9
+ *
10
+ * The following key may also be written to `route` but will be immediately and silently removed:
11
+ * - `mode`: As described above, this library takes a best guess about whether pushing an item to the browser history makes sense or not. When `mode` is...
12
+ * - `"push"`: Force creation of a new browser history entry.
13
+ * - `"replace"`: Update the current history entry, even when updates to other keys would normally cause a *push*.
14
+ * - `"back"`: Unwind the history (like repeatedly pressing the *back* button) until we find a page that matches the given `path`, `search` and top-level `state` keys, and then *replace* that state by the full given state.
15
+ */
16
+ export declare const route: Store;
@@ -0,0 +1,2 @@
1
+ import{Store as t,observe as e,immediateObserve as o,inhibitEffects as r}from"aberdeen";export const route=new t;let a=[];const s=history.length;let c;function u(t){const e={};for(let[t,o]of new URLSearchParams(location.search))e[t]=o;c=t&&t.state||{},a.length=Math.max(1,history.length-s+1),a[a.length-1]={url:location.pathname+location.search,state:c},route.set({path:location.pathname,p:location.pathname.slice(1).split("/"),search:e,hash:location.hash,state:c})}u(),window.addEventListener("popstate",u),o((()=>{let t=""+route.get("path");t.startsWith("/")||(t="/"+t),route.set("path",t),route.set("p",t.slice(1).split("/"))})),o((()=>{const t=route.get("p");t instanceof Array?0==t.length?route.set("p",[""]):route.set("path","/"+t.join("/")):(console.error(`aberdeen route: 'p' must be a non-empty array, not ${JSON.stringify(t)}`),route.set("p",[""]))})),o((()=>{"object"!==route.getType("search")&&route.set("search",{})})),o((()=>{"object"!==route.getType("state")&&route.set("state",{})})),o((()=>{let t=""+(route.get("hash")||"");t&&!t.startsWith("#")&&(t="#"+t),route.set("hash",t)})),e((()=>{const t=route.get("mode");t&&r((()=>route.delete("mode")));const e=route.get("state"),o=route.get("path"),s=new URLSearchParams(route.get("search")).toString(),u=(s?o+"?"+s:o)+route.get("hash");if("back"===t){let t=0;for(;a.length>1;){const o=a[a.length-1];if(o.url===u&&JSON.stringify(Object.keys(e||{}))===JSON.stringify(Object.keys(o.state||{})))break;t--,a.pop()}t&&history.go(t),setTimeout((()=>history.replaceState(e,"",u)),0),a[a.length-1]={url:u,state:e}}else"push"!==t&&(t||location.pathname===o&&JSON.stringify(Object.keys(e||{}))===JSON.stringify(Object.keys(c||{})))?(history.replaceState(e,"",u),a[a.length-1]={url:u,state:e}):(history.pushState(e,"",u),a.push({url:u,state:e}));c=e}));
2
+ //# sourceMappingURL=route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Store","observe","immediateObserve","inhibitEffects","route","stack","initialHistoryLength","history","length","prevHistoryState","handleLocationUpdate","event","search","k","v","URLSearchParams","location","state","Math","max","url","pathname","set","path","p","slice","split","hash","window","addEventListener","get","startsWith","Array","join","console","error","JSON","stringify","getType","mode","delete","toString","goDelta","item","Object","keys","pop","go","setTimeout","replaceState","pushState","push"],"sources":["../src/route.ts"],"mappings":"gBAAQA,aAAOC,sBAASC,oBAAkBC,MAAqB,kBAgBxD,MAAMC,MAAQ,IAAIJ,EAIzB,IAAIK,EAA6C,GAGjD,MAAMC,EAAuBC,QAAQC,OAIrC,IAAIC,EAGJ,SAASC,EAAqBC,GAC7B,MAAMC,EAAa,GACnB,IAAI,IAAKC,EAAGC,KAAM,IAAIC,gBAAgBC,SAASJ,QAC9CA,EAAOC,GAAKC,EAEbL,EAAmBE,GAASA,EAAMM,OAAe,GACjDZ,EAAMG,OAASU,KAAKC,IAAI,EAAGZ,QAAQC,OAASF,EAAuB,GACnED,EAAMA,EAAMG,OA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OR,EAASW,EAAK,IAAIX,EAASW,GAAQnB,MAAM0B,IAAI,QAG1D,GAAa,SAATS,EAAiB,CACpB,IAAIG,EAAU,EACd,KAAMrC,EAAMG,OAAS,GAAG,CACvB,MAAMmC,EAAOtC,EAAMA,EAAMG,OAAO,GAChC,GAAImC,EAAKvB,MAAQA,GAAOgB,KAAKC,UAAUO,OAAOC,KAAK5B,GAAO,OAASmB,KAAKC,UAAUO,OAAOC,KAAKF,EAAK1B,OAAO,KAAM,MAChHyB,IACArC,EAAMyC,K,CAEHJ,GAASnC,QAAQwC,GAAGL,GAExBM,YAAW,IAAMzC,QAAQ0C,aAAahC,EAAO,GAAIG,IAAM,GACvDf,EAAMA,EAAMG,OAAO,GAAK,CAACY,MAAIH,Q,KACV,SAATsB,IAAqBA,GAASvB,SAASK,WAAaE,GAAQa,KAAKC,UAAUO,OAAOC,KAAK5B,GAAO,OAASmB,KAAKC,UAAUO,OAAOC,KAAKpC,GAAkB,OAI9JF,QAAQ0C,aAAahC,EAAO,GAAIG,GAChCf,EAAMA,EAAMG,OAAO,GAAK,CAACY,MAAIH,WAJ7BV,QAAQ2C,UAAUjC,EAAO,GAAIG,GAC7Bf,EAAM8C,KAAK,CAAC/B,MAAIH,WAKjBR,EAAmBQ,CAAK","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ /** Do a grow transition for the given element. This is meant to be used as a
2
+ * handler for the `create` property.
3
+ *
4
+ * @param el The element to transition.
5
+ *
6
+ * The transition doesn't look great for table elements, and may have problems
7
+ * for other specific cases as well.
8
+ */
9
+ export declare function grow(el: HTMLElement): void;
10
+ /** Do a shrink transition for the given element, and remove it from the DOM
11
+ * afterwards. This is meant to be used as a handler for the `destroy` property.
12
+ *
13
+ * @param el The element to transition and remove.
14
+ *
15
+ * The transition doesn't look great for table elements, and may have problems
16
+ * for other specific cases as well.
17
+ */
18
+ export declare function shrink(el: HTMLElement): void;
@@ -0,0 +1,2 @@
1
+ import{scheduleDomReader as t,scheduleDomWriter as e}from"aberdeen";const o=400,r="margin 400ms ease-out, transform 400ms ease-out";function n(t){const e=t.parentElement?getComputedStyle(t.parentElement):{};return"flex"===e.display&&(e.flexDirection||"").startsWith("row")?{marginLeft:`-${t.offsetWidth/2}px`,marginRight:`-${t.offsetWidth/2}px`,transform:"scaleX(0)"}:{marginBottom:`-${t.offsetHeight/2}px`,marginTop:`-${t.offsetHeight/2}px`,transform:"scaleY(0)"}}export function grow(m){t((()=>{let s=n(m);e((()=>{Object.assign(m.style,s),t((()=>{m.offsetHeight,e((()=>{m.style.transition=r;for(let t in s)m.style[t]="";setTimeout((()=>{m.style.transition=""}),o)}))}))}))}))}export function shrink(m){t((()=>{const t=n(m);e((()=>{m.style.transition=r,Object.assign(m.style,t),setTimeout((()=>m.remove()),o)}))}))}
2
+ //# sourceMappingURL=transitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["scheduleDomReader","scheduleDomWriter","FADE_TIME","GROW_SHRINK_TRANSITION","getGrowShrinkProps","el","parentStyle","parentElement","getComputedStyle","display","flexDirection","startsWith","marginLeft","offsetWidth","marginRight","transform","marginBottom","offsetHeight","marginTop","grow","props","Object","assign","style","transition","prop","setTimeout","shrink","remove"],"sources":["../src/transitions.ts"],"mappings":"4BAAQA,uBAAmBC,MAAwB,WAEnD,MAAMC,EAAY,IACZC,EAAyB,kDAE/B,SAASC,EAAmBC,GAC3B,MAAMC,EAAmBD,EAAGE,cAAgBC,iBAAiBH,EAAGE,eAAiB,GAEjF,MAD6C,SAAxBD,EAAYG,UAAuBH,EAAYI,eAAe,IAAIC,WAAW,OAEjG,CAACC,WAAY,IAAIP,EAAGQ,YAAY,MAAOC,YAAa,IAAIT,EAAGQ,YAAY,MAAOE,UAAW,aACzF,CAACC,aAAc,IAAIX,EAAGY,aAAa,MAAOC,UAAW,IAAIb,EAAGY,aAAa,MAAOF,UAAW,YAE7F,QAUM,SAAUI,KAAKd,GAEpBL,GAAkB,KAGjB,IAAIoB,EAAQhB,EAAmBC,GAI/BJ,GAAkB,KACjBoB,OAAOC,OAAOjB,EAAGkB,MAAOH,GAGxBpB,GAAkB,KAEjBK,EAAGY,aACHhB,GAAkB,KAEjBI,EAAGkB,MAAMC,WAAarB,EACtB,IAAI,IAAIsB,KAAQL,EAAOf,EAAGkB,MAAME,GAAe,GAC/CC,YAAW,KAEVrB,EAAGkB,MAAMC,WAAa,EAAE,GACtBtB,EAAU,GACZ,GACD,GACD,GAEJ,QAUM,SAAUyB,OAAOtB,GACtBL,GAAkB,KACjB,MAAMoB,EAAQhB,EAAmBC,GAGjCJ,GAAkB,KACjBI,EAAGkB,MAAMC,WAAarB,EACtBkB,OAAOC,OAAOjB,EAAGkB,MAAOH,GAExBM,YAAW,IAAMrB,EAAGuB,UAAU1B,EAAU,GACvC,GAEJ","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ <!doctype html>
2
+ <head>
3
+ <meta charset="utf-8">
4
+ <link rel="stylesheet" href="input.css">
5
+ </head>
6
+ <body>
7
+ <script type="module" src="input.js"></script>
8
+ </body>