aberdeen 0.2.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +1 -1
- package/README.md +140 -99
- package/dist/aberdeen.d.ts +649 -512
- package/dist/aberdeen.js +1147 -1704
- package/dist/aberdeen.js.map +11 -1
- package/dist/helpers/reverseSortedSet.d.ts +91 -0
- package/dist/prediction.d.ts +7 -3
- package/dist/prediction.js +77 -93
- package/dist/prediction.js.map +10 -1
- package/dist/route.d.ts +44 -13
- package/dist/route.js +138 -112
- package/dist/route.js.map +10 -1
- package/dist/transitions.d.ts +2 -2
- package/dist/transitions.js +30 -63
- package/dist/transitions.js.map +10 -1
- package/dist-min/aberdeen.js +7 -2
- package/dist-min/aberdeen.js.map +11 -1
- package/dist-min/prediction.js +4 -2
- package/dist-min/prediction.js.map +10 -1
- package/dist-min/route.js +4 -2
- package/dist-min/route.js.map +10 -1
- package/dist-min/transitions.js +4 -2
- package/dist-min/transitions.js.map +10 -1
- package/package.json +20 -23
- package/src/aberdeen.ts +1956 -1696
- package/src/helpers/reverseSortedSet.ts +188 -0
- package/src/prediction.ts +14 -9
- package/src/route.ts +149 -69
- package/src/transitions.ts +26 -43
- package/dist-min/aberdeen.d.ts +0 -573
- package/dist-min/prediction.d.ts +0 -29
- package/dist-min/route.d.ts +0 -16
- package/dist-min/transitions.d.ts +0 -18
package/dist/prediction.js
CHANGED
|
@@ -1,110 +1,94 @@
|
|
|
1
|
-
|
|
1
|
+
// src/prediction.ts
|
|
2
|
+
import { withEmitHandler, defaultEmitHandler } from "./aberdeen.js";
|
|
2
3
|
function recordPatch(func) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const recordingPatch = new Map;
|
|
5
|
+
withEmitHandler(function(target, index, newData, oldData) {
|
|
6
|
+
addToPatch(recordingPatch, target, index, newData, oldData);
|
|
7
|
+
}, func);
|
|
8
|
+
return recordingPatch;
|
|
8
9
|
}
|
|
9
10
|
function addToPatch(patch, collection, index, newData, oldData) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
let collectionMap = patch.get(collection);
|
|
12
|
+
if (!collectionMap) {
|
|
13
|
+
collectionMap = new Map;
|
|
14
|
+
patch.set(collection, collectionMap);
|
|
15
|
+
}
|
|
16
|
+
let prev = collectionMap.get(index);
|
|
17
|
+
if (prev)
|
|
18
|
+
oldData = prev[1];
|
|
19
|
+
if (newData === oldData)
|
|
20
|
+
collectionMap.delete(index);
|
|
21
|
+
else
|
|
22
|
+
collectionMap.set(index, [newData, oldData]);
|
|
22
23
|
}
|
|
23
24
|
function emitPatch(patch) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
25
|
+
for (let [collection, collectionMap] of patch) {
|
|
26
|
+
for (let [index, [newData, oldData]] of collectionMap) {
|
|
27
|
+
defaultEmitHandler(collection, index, newData, oldData);
|
|
28
28
|
}
|
|
29
|
+
}
|
|
29
30
|
}
|
|
30
31
|
function mergePatch(target, source, reverse = false) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
32
|
+
for (let [collection, collectionMap] of source) {
|
|
33
|
+
for (let [index, [newData, oldData]] of collectionMap) {
|
|
34
|
+
addToPatch(target, collection, index, reverse ? oldData : newData, reverse ? newData : oldData);
|
|
35
35
|
}
|
|
36
|
+
}
|
|
36
37
|
}
|
|
37
38
|
function silentlyApplyPatch(patch, force = false) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
for (let [collection, collectionMap] of patch) {
|
|
40
|
+
for (let [index, [newData, oldData]] of collectionMap) {
|
|
41
|
+
let actualData = collection[index];
|
|
42
|
+
if (actualData !== oldData) {
|
|
43
|
+
if (force)
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
throw new Error(`Applying invalid patch: data ${actualData} is unequal to expected old data ${oldData} for index ${index}`);
|
|
46
|
+
}, 0);
|
|
47
|
+
else
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
}
|
|
52
|
+
for (let [collection, collectionMap] of patch) {
|
|
53
|
+
for (let [index, [newData, oldData]] of collectionMap) {
|
|
54
|
+
collection[index] = newData;
|
|
53
55
|
}
|
|
54
|
-
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
55
58
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
* to immediately reflect state (as closely as possible) that we expect the server
|
|
63
|
-
* to communicate back to us later on.
|
|
64
|
-
* @returns A `Patch` object. Don't modify it. This is only meant to be passed to `applyCanon`.
|
|
65
|
-
*/
|
|
66
|
-
export function applyPrediction(predictFunc) {
|
|
67
|
-
let patch = recordPatch(predictFunc);
|
|
68
|
-
appliedPredictions.push(patch);
|
|
69
|
-
emitPatch(patch);
|
|
70
|
-
return patch;
|
|
59
|
+
var appliedPredictions = [];
|
|
60
|
+
function applyPrediction(predictFunc) {
|
|
61
|
+
let patch = recordPatch(predictFunc);
|
|
62
|
+
appliedPredictions.push(patch);
|
|
63
|
+
emitPatch(patch);
|
|
64
|
+
return patch;
|
|
71
65
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
mergePatch(resultPatch, prediction, true);
|
|
91
|
-
silentlyApplyPatch(resultPatch, true);
|
|
92
|
-
for (let prediction of dropPredictions) {
|
|
93
|
-
let pos = appliedPredictions.indexOf(prediction);
|
|
94
|
-
if (pos >= 0)
|
|
95
|
-
appliedPredictions.splice(pos, 1);
|
|
96
|
-
}
|
|
97
|
-
if (canonFunc)
|
|
98
|
-
mergePatch(resultPatch, recordPatch(canonFunc));
|
|
99
|
-
for (let idx = 0; idx < appliedPredictions.length; idx++) {
|
|
100
|
-
if (silentlyApplyPatch(appliedPredictions[idx])) {
|
|
101
|
-
mergePatch(resultPatch, appliedPredictions[idx]);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
appliedPredictions.splice(idx, 1);
|
|
105
|
-
idx--;
|
|
106
|
-
}
|
|
66
|
+
function applyCanon(canonFunc, dropPredictions = []) {
|
|
67
|
+
let resultPatch = new Map;
|
|
68
|
+
for (let prediction of appliedPredictions)
|
|
69
|
+
mergePatch(resultPatch, prediction, true);
|
|
70
|
+
silentlyApplyPatch(resultPatch, true);
|
|
71
|
+
for (let prediction of dropPredictions) {
|
|
72
|
+
let pos = appliedPredictions.indexOf(prediction);
|
|
73
|
+
if (pos >= 0)
|
|
74
|
+
appliedPredictions.splice(pos, 1);
|
|
75
|
+
}
|
|
76
|
+
if (canonFunc)
|
|
77
|
+
mergePatch(resultPatch, recordPatch(canonFunc));
|
|
78
|
+
for (let idx = 0;idx < appliedPredictions.length; idx++) {
|
|
79
|
+
if (silentlyApplyPatch(appliedPredictions[idx])) {
|
|
80
|
+
mergePatch(resultPatch, appliedPredictions[idx]);
|
|
81
|
+
} else {
|
|
82
|
+
appliedPredictions.splice(idx, 1);
|
|
83
|
+
idx--;
|
|
107
84
|
}
|
|
108
|
-
|
|
85
|
+
}
|
|
86
|
+
emitPatch(resultPatch);
|
|
109
87
|
}
|
|
110
|
-
|
|
88
|
+
export {
|
|
89
|
+
applyPrediction,
|
|
90
|
+
applyCanon
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
//# debugId=64BCD82AC2BC0BA664756E2164756E21
|
|
94
|
+
//# sourceMappingURL=prediction.js.map
|
package/dist/prediction.js.map
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/prediction.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import {withEmitHandler, defaultEmitHandler} from './aberdeen.js'\nimport type { DatumType, TargetType } from './aberdeen.js';\n\n/** \n * Represents a set of changes that can be applied to proxied objects.\n * This is an opaque type - its internal structure is not part of the public API.\n * @private\n */\nexport type Patch = Map<TargetType, Map<any, [DatumType, DatumType]>>;\n\n\nfunction recordPatch(func: () => void): Patch {\n\tconst recordingPatch = new Map()\n\twithEmitHandler(function(target, index, newData, oldData) {\n\t\taddToPatch(recordingPatch, target, index, newData, oldData)\n\t}, func)\n\treturn recordingPatch\n}\n\nfunction addToPatch(patch: Patch, collection: TargetType, index: any, newData: DatumType, oldData: DatumType) {\n\tlet collectionMap = patch.get(collection)\n\tif (!collectionMap) {\n\t\tcollectionMap = new Map()\n\t\tpatch.set(collection, collectionMap)\n\t}\n\tlet prev = collectionMap.get(index)\n\tif (prev) oldData = prev[1]\n\tif (newData === oldData) collectionMap.delete(index)\n\telse collectionMap.set(index, [newData, oldData])\n}\n\nfunction emitPatch(patch: Patch) {\n\tfor(let [collection, collectionMap] of patch) {\n\t\tfor(let [index, [newData, oldData]] of collectionMap) {\n\t\t\tdefaultEmitHandler(collection, index, newData, oldData);\n\t\t}\n\t}\n}\n\nfunction mergePatch(target: Patch, source: Patch, reverse: boolean = false) {\n\tfor(let [collection, collectionMap] of source) {\n\t\tfor(let [index, [newData, oldData]] of collectionMap) {\n\t\t\taddToPatch(target, collection, index, reverse ? oldData : newData, reverse ? newData : oldData)\n\t\t}\n\t}\n}\n\nfunction silentlyApplyPatch(patch: Patch, force: boolean = false): boolean {\n\tfor(let [collection, collectionMap] of patch) {\n\t\tfor(let [index, [newData, oldData]] of collectionMap) {\n\t\t\tlet actualData = (collection as any)[index]\n\t\t\tif (actualData !== oldData) {\n\t\t\t\tif (force) setTimeout(() => { throw new Error(`Applying invalid patch: data ${actualData} is unequal to expected old data ${oldData} for index ${index}`)}, 0)\n\t\t\t\telse return false\n\t\t\t}\n\t\t}\n\t}\n\tfor(let [collection, collectionMap] of patch) {\n\t\tfor(let [index, [newData, oldData]] of collectionMap) {\n\t\t\t(collection as any)[index] = newData\n\t\t}\n\t}\n\treturn true\n}\n\n\nconst appliedPredictions: Array<Patch> = []\n\n/**\n * Run the provided function, while treating all changes to Observables as predictions,\n * meaning they will be reverted when changes come back from the server (or some other\n * async source).\n * @param predictFunc The function to run. It will generally modify some Observables\n * \tto immediately reflect state (as closely as possible) that we expect the server\n * to communicate back to us later on.\n * @returns A `Patch` object. Don't modify it. This is only meant to be passed to `applyCanon`.\n */\nexport function applyPrediction(predictFunc: () => void): Patch {\n\tlet patch = recordPatch(predictFunc)\n\tappliedPredictions.push(patch)\n\temitPatch(patch)\n\treturn patch\n}\n\n/**\n * Temporarily revert all outstanding predictions, optionally run the provided function\n * (which will generally make authoritative changes to the data based on a server response),\n * and then attempt to reapply the predictions on top of the new canonical state, dropping \n * any predictions that can no longer be applied cleanly (the data has been modified) or\n * that were specified in `dropPredictions`.\n * \n * All of this is done such that redraws are only triggered if the overall effect is an\n * actual change to an `Observable`.\n * @param canonFunc The function to run without any predictions applied. This will typically\n * make authoritative changes to the data, based on a server response.\n * @param dropPredictions An optional list of predictions (as returned by `applyPrediction`)\n * to undo. Typically, when a server response for a certain request is being handled,\n * you'd want to drop the prediction that was done for that request.\n */\nexport function applyCanon(canonFunc?: (() => void), dropPredictions: Array<Patch> = []) {\n\t\n\tlet resultPatch = new Map()\n\tfor(let prediction of appliedPredictions) mergePatch(resultPatch, prediction, true)\n\tsilentlyApplyPatch(resultPatch, true)\n\n\tfor(let prediction of dropPredictions) {\n\t\tlet pos = appliedPredictions.indexOf(prediction)\n\t\tif (pos >= 0) appliedPredictions.splice(pos, 1)\n\t}\n\tif (canonFunc) mergePatch(resultPatch, recordPatch(canonFunc))\n\n\tfor(let idx=0; idx<appliedPredictions.length; idx++) {\n\t\tif (silentlyApplyPatch(appliedPredictions[idx])) {\n\t\t\tmergePatch(resultPatch, appliedPredictions[idx])\n\t\t} else {\n\t\t\tappliedPredictions.splice(idx, 1)\n\t\t\tidx--\n\t\t}\n\t}\n\n\temitPatch(resultPatch)\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AAAA;AAWA,SAAS,WAAW,CAAC,MAAyB;AAAA,EAC7C,MAAM,iBAAiB,IAAI;AAAA,EAC3B,gBAAgB,QAAQ,CAAC,QAAQ,OAAO,SAAS,SAAS;AAAA,IACzD,WAAW,gBAAgB,QAAQ,OAAO,SAAS,OAAO;AAAA,KACxD,IAAI;AAAA,EACP,OAAO;AAAA;AAGR,SAAS,UAAU,CAAC,OAAc,YAAwB,OAAY,SAAoB,SAAoB;AAAA,EAC7G,IAAI,gBAAgB,MAAM,IAAI,UAAU;AAAA,EACxC,KAAK,eAAe;AAAA,IACnB,gBAAgB,IAAI;AAAA,IACpB,MAAM,IAAI,YAAY,aAAa;AAAA,EACpC;AAAA,EACA,IAAI,OAAO,cAAc,IAAI,KAAK;AAAA,EAClC,IAAI;AAAA,IAAM,UAAU,KAAK;AAAA,EACzB,IAAI,YAAY;AAAA,IAAS,cAAc,OAAO,KAAK;AAAA,EAC9C;AAAA,kBAAc,IAAI,OAAO,CAAC,SAAS,OAAO,CAAC;AAAA;AAGjD,SAAS,SAAS,CAAC,OAAc;AAAA,EAChC,UAAS,YAAY,kBAAkB,OAAO;AAAA,IAC7C,UAAS,QAAQ,SAAS,aAAa,eAAe;AAAA,MACrD,mBAAmB,YAAY,OAAO,SAAS,OAAO;AAAA,IACvD;AAAA,EACD;AAAA;AAGD,SAAS,UAAU,CAAC,QAAe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CAAC;AAAA,EAC/C;AAAA,EACA,IAAI;AAAA,IAAW,WAAW,aAAa,YAAY,SAAS,CAAC;AAAA,EAE7D,SAAQ,MAAI,EAAG,MAAI,mBAAmB,QAAQ,OAAO;AAAA,IACpD,IAAI,mBAAmB,mBAAmB,IAAI,GAAG;AAAA,MAChD,WAAW,aAAa,mBAAmB,IAAI;AAAA,IAChD,EAAO;AAAA,MACN,mBAAmB,OAAO,KAAK,CAAC;AAAA,MAChC;AAAA;AAAA,EAEF;AAAA,EAEA,UAAU,WAAW;AAAA;",
|
|
8
|
+
"debugId": "64BCD82AC2BC0BA664756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/dist/route.d.ts
CHANGED
|
@@ -1,16 +1,47 @@
|
|
|
1
|
-
import { Store } from 'aberdeen';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
* - `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.
|
|
2
|
+
* The class for the singleton `route` object.
|
|
9
3
|
*
|
|
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
4
|
*/
|
|
16
|
-
export declare
|
|
5
|
+
export declare class Route {
|
|
6
|
+
/** 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. */
|
|
7
|
+
path: string;
|
|
8
|
+
/** 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. */
|
|
9
|
+
p: string[];
|
|
10
|
+
/** An observable object containing search parameters (a split up query string). For instance `{order: "date", title: "something"}` or just `{}`. By default, updates will be reflected in the URL, replacing the current history state. */
|
|
11
|
+
hash: string;
|
|
12
|
+
/** A part of the browser history *state* that is considered part of the page *identify*, meaning changes will (by default) cause a history push, and when going *back*, it must match. */
|
|
13
|
+
search: Record<string, string>;
|
|
14
|
+
/** The `hash` interpreted as search parameters. So `"a=x&b=y"` becomes `{a: "x", b: "y"}`. */
|
|
15
|
+
id: Record<string, any>;
|
|
16
|
+
/** The auxiliary part of the browser history *state*, not considered part of the page *identity*. Changes will be reflected in the browser history using a replace. */
|
|
17
|
+
aux: Record<string, any>;
|
|
18
|
+
/** The navigation depth of the current session. Starts at 1. Writing to this property has no effect. */
|
|
19
|
+
depth: number;
|
|
20
|
+
/** The navigation action that got us to this page. Writing to this property has no effect.
|
|
21
|
+
- `"load"`: An initial page load.
|
|
22
|
+
- `"back"` or `"forward"`: When we navigated backwards or forwards in the stack.
|
|
23
|
+
- `"push"`: When we added a new page on top of the stack.
|
|
24
|
+
*/
|
|
25
|
+
nav: 'load' | 'back' | 'forward' | 'push';
|
|
26
|
+
/** 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...
|
|
27
|
+
- `"push"`: Force creation of a new browser history entry.
|
|
28
|
+
- `"replace"`: Update the current history entry, even when updates to other keys would normally cause a *push*.
|
|
29
|
+
- `"back"`: Unwind the history (like repeatedly pressing the *back* button) until we find a page that matches the given `path` and `id` (or that is the first page in our stack), and then *replace* that state by the full given state.
|
|
30
|
+
The `mode` key can be written to `route` but will be immediately and silently removed.
|
|
31
|
+
*/
|
|
32
|
+
mode: 'push' | 'replace' | 'back' | undefined;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The singleton {@link Route} object reflecting the current URL and browser history state. You can make changes to it to affect the URL and browser history. See {@link Route} for details.
|
|
36
|
+
*/
|
|
37
|
+
export declare const route: Route;
|
|
38
|
+
/**
|
|
39
|
+
* Restore and store the vertical and horizontal scroll position for
|
|
40
|
+
* the parent element to the page state.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} name - A unique (within this page) name for this
|
|
43
|
+
* scrollable element. Defaults to 'main'.
|
|
44
|
+
*
|
|
45
|
+
* The scroll position will be persisted in `route.aux.scroll.<name>`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function persistScroll(name?: string): void;
|
package/dist/route.js
CHANGED
|
@@ -1,129 +1,155 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// Keep track of the initial history length, so we'll always know how long our `stack` should be.
|
|
21
|
-
const initialHistoryLength = history.length;
|
|
22
|
-
// Keep a copy of the last known history state, so we can tell if the user changed one of its
|
|
23
|
-
// top-level keys, so we can decide between push/replace when `mode` is not set.
|
|
24
|
-
let prevHistoryState;
|
|
25
|
-
// Reflect changes to the browser URL (back/forward navigation) in the `route` and `stack`.
|
|
1
|
+
// src/route.ts
|
|
2
|
+
import { getParentElement, runQueue, clean, proxy, observe, immediateObserve, unproxy, clone } from "./aberdeen.js";
|
|
3
|
+
|
|
4
|
+
class Route {
|
|
5
|
+
path;
|
|
6
|
+
p;
|
|
7
|
+
hash;
|
|
8
|
+
search;
|
|
9
|
+
id;
|
|
10
|
+
aux;
|
|
11
|
+
depth = 1;
|
|
12
|
+
nav = "load";
|
|
13
|
+
mode;
|
|
14
|
+
}
|
|
15
|
+
var route = proxy(new Route);
|
|
16
|
+
var stateRoute = {
|
|
17
|
+
nonce: -1,
|
|
18
|
+
depth: 0
|
|
19
|
+
};
|
|
26
20
|
function handleLocationUpdate(event) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
let state = event?.state || {};
|
|
22
|
+
let nav = "load";
|
|
23
|
+
if (state.route?.nonce == null) {
|
|
24
|
+
state.route = {
|
|
25
|
+
nonce: Math.floor(Math.random() * Number.MAX_SAFE_INTEGER),
|
|
26
|
+
depth: 1
|
|
27
|
+
};
|
|
28
|
+
history.replaceState(state, "");
|
|
29
|
+
} else if (stateRoute.nonce === state.route.nonce) {
|
|
30
|
+
nav = state.route.depth > stateRoute.depth ? "forward" : "back";
|
|
31
|
+
}
|
|
32
|
+
stateRoute = state.route;
|
|
33
|
+
if (unproxy(route).mode === "back") {
|
|
34
|
+
route.depth = stateRoute.depth;
|
|
35
|
+
updateHistory();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const search = {};
|
|
39
|
+
for (let [k, v] of new URLSearchParams(location.search)) {
|
|
40
|
+
search[k] = v;
|
|
41
|
+
}
|
|
42
|
+
route.path = location.pathname;
|
|
43
|
+
route.p = location.pathname.slice(1).split("/");
|
|
44
|
+
route.search = search;
|
|
45
|
+
route.hash = location.hash;
|
|
46
|
+
route.id = state.id;
|
|
47
|
+
route.aux = state.aux;
|
|
48
|
+
route.depth = stateRoute.depth;
|
|
49
|
+
route.nav = nav;
|
|
50
|
+
if (event)
|
|
51
|
+
runQueue();
|
|
41
52
|
}
|
|
42
53
|
handleLocationUpdate();
|
|
43
54
|
window.addEventListener("popstate", handleLocationUpdate);
|
|
44
|
-
// These immediate-mode observers will rewrite the data in `route` to its canonical form.
|
|
45
|
-
// We want to to this immediately, so that user-code running immediately after a user-code
|
|
46
|
-
// initiated `set` will see the canonical form (instead of doing a rerender shortly after,
|
|
47
|
-
// or crashing due to non-canonical data).
|
|
48
55
|
function updatePath() {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
let path = route.path;
|
|
57
|
+
if (path == null && unproxy(route).p) {
|
|
58
|
+
return updateP();
|
|
59
|
+
}
|
|
60
|
+
path = "" + (path || "/");
|
|
61
|
+
if (!path.startsWith("/"))
|
|
62
|
+
path = "/" + path;
|
|
63
|
+
route.path = path;
|
|
64
|
+
route.p = path.slice(1).split("/");
|
|
58
65
|
}
|
|
59
66
|
immediateObserve(updatePath);
|
|
60
67
|
function updateP() {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
else {
|
|
74
|
-
route.set('path', '/' + p.join('/'));
|
|
75
|
-
}
|
|
68
|
+
const p = route.p;
|
|
69
|
+
if (p == null && unproxy(route).path) {
|
|
70
|
+
return updatePath();
|
|
71
|
+
}
|
|
72
|
+
if (!(p instanceof Array)) {
|
|
73
|
+
console.error(`aberdeen route: 'p' must be a non-empty array, not ${JSON.stringify(p)}`);
|
|
74
|
+
route.p = [""];
|
|
75
|
+
} else if (p.length == 0) {
|
|
76
|
+
route.p = [""];
|
|
77
|
+
} else {
|
|
78
|
+
route.path = "/" + p.join("/");
|
|
79
|
+
}
|
|
76
80
|
}
|
|
77
81
|
immediateObserve(updateP);
|
|
78
82
|
immediateObserve(() => {
|
|
79
|
-
|
|
80
|
-
|
|
83
|
+
if (!route.search || typeof route.search !== "object")
|
|
84
|
+
route.search = {};
|
|
81
85
|
});
|
|
82
86
|
immediateObserve(() => {
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
if (!route.id || typeof route.id !== "object")
|
|
88
|
+
route.id = {};
|
|
85
89
|
});
|
|
86
90
|
immediateObserve(() => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
hash = '#' + hash;
|
|
90
|
-
route.set('hash', hash);
|
|
91
|
+
if (!route.aux || typeof route.aux !== "object")
|
|
92
|
+
route.aux = {};
|
|
91
93
|
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
inhibitEffects(() => route.delete('mode'));
|
|
98
|
-
const state = route.get('state');
|
|
99
|
-
// Construct the URL.
|
|
100
|
-
const path = route.get('path');
|
|
101
|
-
const search = new URLSearchParams(route.get('search')).toString();
|
|
102
|
-
const url = (search ? path + '?' + search : path) + route.get('hash');
|
|
103
|
-
// Change browser state, according to `mode`.
|
|
104
|
-
if (mode === 'back') {
|
|
105
|
-
let goDelta = 0;
|
|
106
|
-
while (stack.length > 1) {
|
|
107
|
-
const item = stack[stack.length - 1];
|
|
108
|
-
if (item.url === url && JSON.stringify(Object.keys(state || {})) === JSON.stringify(Object.keys(item.state || {})))
|
|
109
|
-
break; // Found it!
|
|
110
|
-
goDelta--;
|
|
111
|
-
stack.pop();
|
|
112
|
-
}
|
|
113
|
-
if (goDelta)
|
|
114
|
-
history.go(goDelta);
|
|
115
|
-
// We'll replace the state async, to give the history.go the time to take affect first.
|
|
116
|
-
setTimeout(() => history.replaceState(state, '', url), 0);
|
|
117
|
-
stack[stack.length - 1] = { url, state };
|
|
118
|
-
}
|
|
119
|
-
else if (mode === 'push' || (!mode && (location.pathname !== path || JSON.stringify(Object.keys(state || {})) !== JSON.stringify(Object.keys(prevHistoryState || {}))))) {
|
|
120
|
-
history.pushState(state, '', url);
|
|
121
|
-
stack.push({ url, state });
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
history.replaceState(state, '', url);
|
|
125
|
-
stack[stack.length - 1] = { url, state };
|
|
126
|
-
}
|
|
127
|
-
prevHistoryState = state;
|
|
94
|
+
immediateObserve(() => {
|
|
95
|
+
let hash = "" + (route.hash || "");
|
|
96
|
+
if (hash && !hash.startsWith("#"))
|
|
97
|
+
hash = "#" + hash;
|
|
98
|
+
route.hash = hash;
|
|
128
99
|
});
|
|
129
|
-
|
|
100
|
+
function isSamePage(path, state) {
|
|
101
|
+
return location.pathname === path && JSON.stringify(history.state.id) === JSON.stringify(state.id);
|
|
102
|
+
}
|
|
103
|
+
function updateHistory() {
|
|
104
|
+
let mode = route.mode;
|
|
105
|
+
const state = {
|
|
106
|
+
id: clone(route.id),
|
|
107
|
+
aux: clone(route.aux),
|
|
108
|
+
route: stateRoute
|
|
109
|
+
};
|
|
110
|
+
const path = route.path;
|
|
111
|
+
if (mode === "back") {
|
|
112
|
+
route.nav = "back";
|
|
113
|
+
if (!isSamePage(path, state) && (history.state.route?.depth || 0) > 1) {
|
|
114
|
+
history.back();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
mode = "replace";
|
|
118
|
+
}
|
|
119
|
+
if (mode)
|
|
120
|
+
route.mode = undefined;
|
|
121
|
+
const search = new URLSearchParams(route.search).toString();
|
|
122
|
+
const url = (search ? path + "?" + search : path) + route.hash;
|
|
123
|
+
if (mode === "push" || !mode && !isSamePage(path, state)) {
|
|
124
|
+
stateRoute.depth++;
|
|
125
|
+
history.pushState(state, "", url);
|
|
126
|
+
route.nav = "push";
|
|
127
|
+
route.depth = stateRoute.depth;
|
|
128
|
+
} else {
|
|
129
|
+
history.replaceState(state, "", url);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
observe(updateHistory);
|
|
133
|
+
function persistScroll(name = "main") {
|
|
134
|
+
const el = getParentElement();
|
|
135
|
+
el.addEventListener("scroll", onScroll);
|
|
136
|
+
clean(() => el.removeEventListener("scroll", onScroll));
|
|
137
|
+
let restore = unproxy(route).aux.scroll?.name;
|
|
138
|
+
if (restore) {
|
|
139
|
+
Object.assign(el, restore);
|
|
140
|
+
}
|
|
141
|
+
function onScroll() {
|
|
142
|
+
route.mode = "replace";
|
|
143
|
+
if (!route.aux.scroll)
|
|
144
|
+
route.aux.scroll = {};
|
|
145
|
+
route.aux.scroll[name] = { scrollTop: el.scrollTop, scrollLeft: el.scrollLeft };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
export {
|
|
149
|
+
route,
|
|
150
|
+
persistScroll,
|
|
151
|
+
Route
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
//# debugId=917712AC1764DFEF64756E2164756E21
|
|
155
|
+
//# sourceMappingURL=route.js.map
|
package/dist/route.js.map
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/route.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import {getParentElement, runQueue, clean, proxy, observe, immediateObserve, unproxy, clone} from './aberdeen.js'\n\n/**\n * The class for the singleton `route` object.\n * \n */\n\nexport class Route {\n\t/** 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. */\n\tpath!: string\n\t/** 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. */\n\tp!: string[]\n\t/** An observable object containing search parameters (a split up query string). For instance `{order: \"date\", title: \"something\"}` or just `{}`. By default, updates will be reflected in the URL, replacing the current history state. */\n\thash!: string\n\t/** A part of the browser history *state* that is considered part of the page *identify*, meaning changes will (by default) cause a history push, and when going *back*, it must match. */\n\tsearch!: Record<string, string>\n\t/** The `hash` interpreted as search parameters. So `\"a=x&b=y\"` becomes `{a: \"x\", b: \"y\"}`. */\n\tid!: Record<string, any>\n\t/** The auxiliary part of the browser history *state*, not considered part of the page *identity*. Changes will be reflected in the browser history using a replace. */\n\taux!: Record<string, any>\n\t/** The navigation depth of the current session. Starts at 1. Writing to this property has no effect. */\n\tdepth: number = 1\n\t/** The navigation action that got us to this page. Writing to this property has no effect.\n - `\"load\"`: An initial page load.\n - `\"back\"` or `\"forward\"`: When we navigated backwards or forwards in the stack.\n - `\"push\"`: When we added a new page on top of the stack. \n */\n nav: 'load' | 'back' | 'forward' | 'push' = 'load'\n /** 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... \n \t - `\"push\"`: Force creation of a new browser history entry. \n \t - `\"replace\"`: Update the current history entry, even when updates to other keys would normally cause a *push*.\n \t - `\"back\"`: Unwind the history (like repeatedly pressing the *back* button) until we find a page that matches the given `path` and `id` (or that is the first page in our stack), and then *replace* that state by the full given state.\n The `mode` key can be written to `route` but will be immediately and silently removed.\n */\n\tmode: 'push' | 'replace' | 'back' | undefined\n}\n\n/**\n * The singleton {@link Route} object reflecting the current URL and browser history state. You can make changes to it to affect the URL and browser history. See {@link Route} for details.\n */\nexport const route = proxy(new Route())\n\nlet stateRoute = {\n\tnonce: -1,\n\tdepth: 0,\n}\n\n// Reflect changes to the browser URL (back/forward navigation) in the `route` and `stack`.\nfunction handleLocationUpdate(event?: PopStateEvent) {\n\tlet state = event?.state || {}\n\tlet nav: 'load' | 'back' | 'forward' | 'push' = 'load'\n\tif (state.route?.nonce == null) {\n\t\tstate.route = {\n\t\t\tnonce: Math.floor(Math.random() * Number.MAX_SAFE_INTEGER),\n\t\t\tdepth: 1,\n\t\t} \n\t\thistory.replaceState(state, '')\n\t} else if (stateRoute.nonce === state.route.nonce) {\n\t\tnav = state.route.depth > stateRoute.depth ? 'forward' : 'back'\n\t}\n\tstateRoute = state.route\n\n\tif (unproxy(route).mode === 'back') {\n\t\troute.depth = stateRoute.depth\n\t\t// We are still in the process of searching for a page in our navigation history..\n\t\tupdateHistory()\n\t\treturn\n\t}\n\n\tconst search: any= {}\n\tfor(let [k, v] of new URLSearchParams(location.search)) {\n\t\tsearch[k] = v\n\t}\n\n\troute.path = location.pathname\n\troute.p = location.pathname.slice(1).split('/')\n\troute.search = search\n\troute.hash = location.hash\n\troute.id = state.id\n\troute.aux = state.aux\n\troute.depth = stateRoute.depth\n\troute.nav = nav\n\n\t// Forward or back event. Redraw synchronously, because we can!\n\tif (event) runQueue();\n}\nhandleLocationUpdate()\nwindow.addEventListener(\"popstate\", handleLocationUpdate);\n\n// These immediate-mode observers will rewrite the data in `route` to its canonical form.\n// We want to to this immediately, so that user-code running immediately after a user-code\n// initiated `set` will see the canonical form (instead of doing a rerender shortly after,\n// or crashing due to non-canonical data).\nfunction updatePath(): void {\n\tlet path = route.path\n\tif (path == null && unproxy(route).p) {\n\t\treturn updateP()\n\t} \n\tpath = ''+(path || '/')\n\tif (!path.startsWith('/')) path = '/'+path\n\troute.path = path\n\troute.p = path.slice(1).split('/')\n}\nimmediateObserve(updatePath)\n\nfunction updateP(): void {\n\tconst p = route.p\n\tif (p == null && unproxy(route).path) {\n\t\treturn updatePath()\n\t}\n\tif (!(p instanceof Array)) {\n\t\tconsole.error(`aberdeen route: 'p' must be a non-empty array, not ${JSON.stringify(p)}`)\n\t\troute.p = [''] // This will cause a recursive call this observer.\n\t} else if (p.length == 0) {\n\t\troute.p = [''] // This will cause a recursive call this observer.\n\t} else {\n\t\troute.path = '/' + p.join('/')\n\t}\n}\nimmediateObserve(updateP)\n\nimmediateObserve(() => {\n\tif (!route.search || typeof route.search !== 'object') route.search = {}\n})\n\nimmediateObserve(() => {\n\tif (!route.id || typeof route.id !== 'object') route.id = {}\n})\n\nimmediateObserve(() => {\n\tif (!route.aux || typeof route.aux !== 'object') route.aux = {}\n})\n\nimmediateObserve(() => {\n\tlet hash = ''+(route.hash || '')\n\tif (hash && !hash.startsWith('#')) hash = '#'+hash\n\troute.hash = hash\n})\n\nfunction isSamePage(path: string, state: any): boolean {\n\treturn location.pathname === path && JSON.stringify(history.state.id) === JSON.stringify(state.id)\n}\n\nfunction updateHistory() {\n\t// Get and delete mode without triggering anything.\n\tlet mode = route.mode\n\tconst state = {\n\t\tid: clone(route.id),\n\t\taux: clone(route.aux),\n\t\troute: stateRoute,\n\t}\n\t\n\t// Construct the URL.\n\tconst path = route.path\n\n\t// Change browser state, according to `mode`.\n\tif (mode === 'back') {\n\t\troute.nav = 'back'\n\t\tif (!isSamePage(path, state) && (history.state.route?.depth||0) > 1) {\n\t\t\thistory.back()\n\t\t\treturn\n\t\t}\n\t\tmode = 'replace'\n\t\t// We'll replace the state async, to give the history.go the time to take affect first.\n\t\t//setTimeout(() => history.replaceState(state, '', url), 0)\n\t}\n\n\tif (mode) route.mode = undefined\n\tconst search = new URLSearchParams(route.search).toString()\n\tconst url = (search ? path+'?'+search : path) + route.hash\n\t\t\n\tif (mode === 'push' || (!mode && !isSamePage(path, state))) {\n\t\tstateRoute.depth++ // stateRoute === state.route\n\t\thistory.pushState(state, '', url)\n\t\troute.nav = 'push'\n\t\troute.depth = stateRoute.depth\n\t} else {\n\t\t// Default to `push` when the URL changed or top-level state keys changed.\n\t\thistory.replaceState(state, '', url)\n\t}\n}\n\n// This deferred-mode observer will update the URL and history based on `route` changes.\nobserve(updateHistory)\n\n\n/**\n * Restore and store the vertical and horizontal scroll position for\n * the parent element to the page state.\n * \n * @param {string} name - A unique (within this page) name for this\n * scrollable element. Defaults to 'main'.\n * \n * The scroll position will be persisted in `route.aux.scroll.<name>`.\n */\nexport function persistScroll(name: string = 'main') {\n\tconst el = getParentElement()\n\tel.addEventListener('scroll', onScroll)\n\tclean(() => el.removeEventListener('scroll', onScroll))\n\n\tlet restore = unproxy(route).aux.scroll?.name\n\tif (restore) {\n\t\tObject.assign(el, restore)\n\t}\n\n\tfunction onScroll() {\n\t\troute.mode = 'replace'\n\t\tif (!route.aux.scroll) route.aux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AG;AAAA;AAAA;AAKrC,QAAQ,aAAa;AAYd,SAAS,aAAa,CAAC,OAAe,QAAQ;AAAA,EACpD,MAAM,KAAK,iBAAiB;AAAA,EAC5B,GAAG,iBAAiB,UAAU,QAAQ;AAAA,EACtC,MAAM,MAAM,GAAG,oBAAoB,UAAU,QAAQ,CAAC;AAAA,EAEtD,IAAI,UAAU,QAAQ,KAAK,EAAE,IAAI,QAAQ;AAAA,EACzC,IAAI,SAAS;AAAA,IACZ,OAAO,OAAO,IAAI,OAAO;AAAA,EAC1B;AAAA,EAEA,SAAS,QAAQ,GAAG;AAAA,IACnB,MAAM,OAAO;AAAA,IACb,KAAK,MAAM,IAAI;AAAA,MAAQ,MAAM,IAAI,SAAS,CAAC;AAAA,IAC3C,MAAM,IAAI,OAAO,QAAQ,EAAC,WAAW,GAAG,WAAW,YAAY,GAAG,WAAU;AAAA;AAAA;",
|
|
8
|
+
"debugId": "917712AC1764DFEF64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/dist/transitions.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* The transition doesn't look great for table elements, and may have problems
|
|
7
7
|
* for other specific cases as well.
|
|
8
8
|
*/
|
|
9
|
-
export declare function grow(el: HTMLElement): void
|
|
9
|
+
export declare function grow(el: HTMLElement): Promise<void>;
|
|
10
10
|
/** Do a shrink transition for the given element, and remove it from the DOM
|
|
11
11
|
* afterwards. This is meant to be used as a handler for the `destroy` property.
|
|
12
12
|
*
|
|
@@ -15,4 +15,4 @@ export declare function grow(el: HTMLElement): void;
|
|
|
15
15
|
* The transition doesn't look great for table elements, and may have problems
|
|
16
16
|
* for other specific cases as well.
|
|
17
17
|
*/
|
|
18
|
-
export declare function shrink(el: HTMLElement): void
|
|
18
|
+
export declare function shrink(el: HTMLElement): Promise<void>;
|