aberdeen 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import type { DatumType, TargetType } from './aberdeen.js';
1
+ import type { DatumType, TargetType } from "./aberdeen.js";
2
2
  /**
3
3
  * Represents a set of changes that can be applied to proxied objects.
4
4
  * This is an opaque type - its internal structure is not part of the public API.
@@ -30,4 +30,4 @@ export declare function applyPrediction(predictFunc: () => void): Patch;
30
30
  * to undo. Typically, when a server response for a certain request is being handled,
31
31
  * you'd want to drop the prediction that was done for that request.
32
32
  */
33
- export declare function applyCanon(canonFunc?: (() => void), dropPredictions?: Array<Patch>): void;
33
+ export declare function applyCanon(canonFunc?: () => void, dropPredictions?: Array<Patch>): void;
@@ -1,8 +1,8 @@
1
1
  // src/prediction.ts
2
- import { withEmitHandler, defaultEmitHandler } from "./aberdeen.js";
2
+ import { defaultEmitHandler, withEmitHandler } from "./aberdeen.js";
3
3
  function recordPatch(func) {
4
4
  const recordingPatch = new Map;
5
- withEmitHandler(function(target, index, newData, oldData) {
5
+ withEmitHandler((target, index, newData, oldData) => {
6
6
  addToPatch(recordingPatch, target, index, newData, oldData);
7
7
  }, func);
8
8
  return recordingPatch;
@@ -13,32 +13,31 @@ function addToPatch(patch, collection, index, newData, oldData) {
13
13
  collectionMap = new Map;
14
14
  patch.set(collection, collectionMap);
15
15
  }
16
- let prev = collectionMap.get(index);
17
- if (prev)
18
- oldData = prev[1];
19
- if (newData === oldData)
16
+ const prev = collectionMap.get(index);
17
+ const oldData0 = prev ? prev[1] : oldData;
18
+ if (newData === oldData0)
20
19
  collectionMap.delete(index);
21
20
  else
22
- collectionMap.set(index, [newData, oldData]);
21
+ collectionMap.set(index, [newData, oldData0]);
23
22
  }
24
23
  function emitPatch(patch) {
25
- for (let [collection, collectionMap] of patch) {
26
- for (let [index, [newData, oldData]] of collectionMap) {
24
+ for (const [collection, collectionMap] of patch) {
25
+ for (const [index, [newData, oldData]] of collectionMap) {
27
26
  defaultEmitHandler(collection, index, newData, oldData);
28
27
  }
29
28
  }
30
29
  }
31
30
  function mergePatch(target, source, reverse = false) {
32
- for (let [collection, collectionMap] of source) {
33
- for (let [index, [newData, oldData]] of collectionMap) {
31
+ for (const [collection, collectionMap] of source) {
32
+ for (const [index, [newData, oldData]] of collectionMap) {
34
33
  addToPatch(target, collection, index, reverse ? oldData : newData, reverse ? newData : oldData);
35
34
  }
36
35
  }
37
36
  }
38
37
  function silentlyApplyPatch(patch, force = false) {
39
- for (let [collection, collectionMap] of patch) {
40
- for (let [index, [newData, oldData]] of collectionMap) {
41
- let actualData = collection[index];
38
+ for (const [collection, collectionMap] of patch) {
39
+ for (const [index, [newData, oldData]] of collectionMap) {
40
+ const actualData = collection[index];
42
41
  if (actualData !== oldData) {
43
42
  if (force)
44
43
  setTimeout(() => {
@@ -49,8 +48,8 @@ function silentlyApplyPatch(patch, force = false) {
49
48
  }
50
49
  }
51
50
  }
52
- for (let [collection, collectionMap] of patch) {
53
- for (let [index, [newData, oldData]] of collectionMap) {
51
+ for (const [collection, collectionMap] of patch) {
52
+ for (const [index, [newData, oldData]] of collectionMap) {
54
53
  collection[index] = newData;
55
54
  }
56
55
  }
@@ -58,18 +57,18 @@ function silentlyApplyPatch(patch, force = false) {
58
57
  }
59
58
  var appliedPredictions = [];
60
59
  function applyPrediction(predictFunc) {
61
- let patch = recordPatch(predictFunc);
60
+ const patch = recordPatch(predictFunc);
62
61
  appliedPredictions.push(patch);
63
62
  emitPatch(patch);
64
63
  return patch;
65
64
  }
66
65
  function applyCanon(canonFunc, dropPredictions = []) {
67
- let resultPatch = new Map;
68
- for (let prediction of appliedPredictions)
66
+ const resultPatch = new Map;
67
+ for (const prediction of appliedPredictions)
69
68
  mergePatch(resultPatch, prediction, true);
70
69
  silentlyApplyPatch(resultPatch, true);
71
- for (let prediction of dropPredictions) {
72
- let pos = appliedPredictions.indexOf(prediction);
70
+ for (const prediction of dropPredictions) {
71
+ const pos = appliedPredictions.indexOf(prediction);
73
72
  if (pos >= 0)
74
73
  appliedPredictions.splice(pos, 1);
75
74
  }
@@ -90,5 +89,5 @@ export {
90
89
  applyCanon
91
90
  };
92
91
 
93
- //# debugId=64BCD82AC2BC0BA664756E2164756E21
92
+ //# debugId=55BE44FF877D138F64756E2164756E21
94
93
  //# sourceMappingURL=prediction.js.map
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/prediction.ts"],
4
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"
5
+ "import { defaultEmitHandler, withEmitHandler } 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\nfunction recordPatch(func: () => void): Patch {\n\tconst recordingPatch = new Map();\n\twithEmitHandler((target, index, newData, oldData) => {\n\t\taddToPatch(recordingPatch, target, index, newData, oldData);\n\t}, func);\n\treturn recordingPatch;\n}\n\nfunction addToPatch(\n\tpatch: Patch,\n\tcollection: TargetType,\n\tindex: any,\n\tnewData: DatumType,\n\toldData: DatumType,\n) {\n\tlet collectionMap = patch.get(collection);\n\tif (!collectionMap) {\n\t\tcollectionMap = new Map();\n\t\tpatch.set(collection, collectionMap);\n\t}\n\tconst prev = collectionMap.get(index);\n\tconst oldData0 = prev ? prev[1] : oldData;\n\tif (newData === oldData0) collectionMap.delete(index);\n\telse collectionMap.set(index, [newData, oldData0]);\n}\n\nfunction emitPatch(patch: Patch) {\n\tfor (const [collection, collectionMap] of patch) {\n\t\tfor (const [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 = false) {\n\tfor (const [collection, collectionMap] of source) {\n\t\tfor (const [index, [newData, oldData]] of collectionMap) {\n\t\t\taddToPatch(\n\t\t\t\ttarget,\n\t\t\t\tcollection,\n\t\t\t\tindex,\n\t\t\t\treverse ? oldData : newData,\n\t\t\t\treverse ? newData : oldData,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction silentlyApplyPatch(patch: Patch, force = false): boolean {\n\tfor (const [collection, collectionMap] of patch) {\n\t\tfor (const [index, [newData, oldData]] of collectionMap) {\n\t\t\tconst actualData = (collection as any)[index];\n\t\t\tif (actualData !== oldData) {\n\t\t\t\tif (force)\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Applying invalid patch: data ${actualData} is unequal to expected old data ${oldData} for index ${index}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}, 0);\n\t\t\t\telse return false;\n\t\t\t}\n\t\t}\n\t}\n\tfor (const [collection, collectionMap] of patch) {\n\t\tfor (const [index, [newData, oldData]] of collectionMap) {\n\t\t\t(collection as any)[index] = newData;\n\t\t}\n\t}\n\treturn true;\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\tconst 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(\n\tcanonFunc?: () => void,\n\tdropPredictions: Array<Patch> = [],\n) {\n\tconst resultPatch = new Map();\n\tfor (const prediction of appliedPredictions)\n\t\tmergePatch(resultPatch, prediction, true);\n\tsilentlyApplyPatch(resultPatch, true);\n\n\tfor (const prediction of dropPredictions) {\n\t\tconst 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
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;A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AgC,CAAC,GAChC;AAAA,EACD,MAAM,cAAc,IAAI;AAAA,EACxB,WAAW,cAAc;AAAA,IACxB,WAAW,aAAa,YAAY,IAAI;AAAA,EACzC,mBAAmB,aAAa,IAAI;AAAA,EAEpC,WAAW,cAAc,iBAAiB;AAAA,IACzC,MAAM,MAAM,mBAAmB,QAAQ,UAAU;AAAA,IACjD,IAAI,OAAO;AAAA,MAAG,mBAAmB,OAAO,KAAK,CAAC;AAAA,EAC/C;AAAA,EACA,IAAI;AAAA,IAAW,WAAW,aAAa,YAAY,SAAS,CAAC;AAAA,EAE7D,SAAS,MAAM,EAAG,MAAM,mBAAmB,QAAQ,OAAO;AAAA,IACzD,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": "55BE44FF877D138F64756E2164756E21",
9
9
  "names": []
10
10
  }
package/dist/route.d.ts CHANGED
@@ -22,14 +22,14 @@ export declare class Route {
22
22
  - `"back"` or `"forward"`: When we navigated backwards or forwards in the stack.
23
23
  - `"push"`: When we added a new page on top of the stack.
24
24
  */
25
- nav: 'load' | 'back' | 'forward' | 'push';
25
+ nav: "load" | "back" | "forward" | "push";
26
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
27
  - `"push"`: Force creation of a new browser history entry.
28
28
  - `"replace"`: Update the current history entry, even when updates to other keys would normally cause a *push*.
29
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
30
  The `mode` key can be written to `route` but will be immediately and silently removed.
31
31
  */
32
- mode: 'push' | 'replace' | 'back' | undefined;
32
+ mode: "push" | "replace" | "back" | undefined;
33
33
  }
34
34
  /**
35
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.
package/dist/route.js CHANGED
@@ -1,5 +1,14 @@
1
1
  // src/route.ts
2
- import { getParentElement, runQueue, clean, proxy, observe, immediateObserve, unproxy, clone } from "./aberdeen.js";
2
+ import {
3
+ clean,
4
+ clone,
5
+ getParentElement,
6
+ immediateObserve,
7
+ observe,
8
+ proxy,
9
+ runQueue,
10
+ unproxy
11
+ } from "./aberdeen.js";
3
12
 
4
13
  class Route {
5
14
  path;
@@ -18,7 +27,7 @@ var stateRoute = {
18
27
  depth: 0
19
28
  };
20
29
  function handleLocationUpdate(event) {
21
- let state = event?.state || {};
30
+ const state = event?.state || {};
22
31
  let nav = "load";
23
32
  if (state.route?.nonce == null) {
24
33
  state.route = {
@@ -36,7 +45,7 @@ function handleLocationUpdate(event) {
36
45
  return;
37
46
  }
38
47
  const search = {};
39
- for (let [k, v] of new URLSearchParams(location.search)) {
48
+ for (const [k, v] of new URLSearchParams(location.search)) {
40
49
  search[k] = v;
41
50
  }
42
51
  route.path = location.pathname;
@@ -55,11 +64,12 @@ window.addEventListener("popstate", handleLocationUpdate);
55
64
  function updatePath() {
56
65
  let path = route.path;
57
66
  if (path == null && unproxy(route).p) {
58
- return updateP();
67
+ updateP();
68
+ return;
59
69
  }
60
- path = "" + (path || "/");
70
+ path = `${path || "/"}`;
61
71
  if (!path.startsWith("/"))
62
- path = "/" + path;
72
+ path = `/${path}`;
63
73
  route.path = path;
64
74
  route.p = path.slice(1).split("/");
65
75
  }
@@ -67,15 +77,16 @@ immediateObserve(updatePath);
67
77
  function updateP() {
68
78
  const p = route.p;
69
79
  if (p == null && unproxy(route).path) {
70
- return updatePath();
80
+ updatePath();
81
+ return;
71
82
  }
72
83
  if (!(p instanceof Array)) {
73
84
  console.error(`aberdeen route: 'p' must be a non-empty array, not ${JSON.stringify(p)}`);
74
85
  route.p = [""];
75
- } else if (p.length == 0) {
86
+ } else if (p.length === 0) {
76
87
  route.p = [""];
77
88
  } else {
78
- route.path = "/" + p.join("/");
89
+ route.path = `/${p.join("/")}`;
79
90
  }
80
91
  }
81
92
  immediateObserve(updateP);
@@ -92,9 +103,9 @@ immediateObserve(() => {
92
103
  route.aux = {};
93
104
  });
94
105
  immediateObserve(() => {
95
- let hash = "" + (route.hash || "");
106
+ let hash = `${route.hash || ""}`;
96
107
  if (hash && !hash.startsWith("#"))
97
- hash = "#" + hash;
108
+ hash = `#${hash}`;
98
109
  route.hash = hash;
99
110
  });
100
111
  function isSamePage(path, state) {
@@ -119,7 +130,7 @@ function updateHistory() {
119
130
  if (mode)
120
131
  route.mode = undefined;
121
132
  const search = new URLSearchParams(route.search).toString();
122
- const url = (search ? path + "?" + search : path) + route.hash;
133
+ const url = (search ? `${path}?${search}` : path) + route.hash;
123
134
  if (mode === "push" || !mode && !isSamePage(path, state)) {
124
135
  stateRoute.depth++;
125
136
  history.pushState(state, "", url);
@@ -134,7 +145,7 @@ function persistScroll(name = "main") {
134
145
  const el = getParentElement();
135
146
  el.addEventListener("scroll", onScroll);
136
147
  clean(() => el.removeEventListener("scroll", onScroll));
137
- let restore = unproxy(route).aux.scroll?.name;
148
+ const restore = unproxy(route).aux.scroll?.name;
138
149
  if (restore) {
139
150
  Object.assign(el, restore);
140
151
  }
@@ -142,7 +153,10 @@ function persistScroll(name = "main") {
142
153
  route.mode = "replace";
143
154
  if (!route.aux.scroll)
144
155
  route.aux.scroll = {};
145
- route.aux.scroll[name] = { scrollTop: el.scrollTop, scrollLeft: el.scrollLeft };
156
+ route.aux.scroll[name] = {
157
+ scrollTop: el.scrollTop,
158
+ scrollLeft: el.scrollLeft
159
+ };
146
160
  }
147
161
  }
148
162
  export {
@@ -151,5 +165,5 @@ export {
151
165
  Route
152
166
  };
153
167
 
154
- //# debugId=917712AC1764DFEF64756E2164756E21
168
+ //# debugId=D7FFE7D955D7855E64756E2164756E21
155
169
  //# sourceMappingURL=route.js.map
package/dist/route.js.map CHANGED
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/route.ts"],
4
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.scroll = {}\n\t\troute.aux.scroll[name] = {scrollTop: el.scrollTop, scrollLeft: el.scrollLeft}\n\t}\n}\n"
5
+ "import {\n\tclean,\n\tclone,\n\tgetParentElement,\n\timmediateObserve,\n\tobserve,\n\tproxy,\n\trunQueue,\n\tunproxy,\n} 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 = 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\tnav: \"load\" | \"back\" | \"forward\" | \"push\" = \"load\";\n\t/** 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\tconst 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 (const [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\tupdateP();\n\t\treturn;\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() {\n\tconst p = route.p;\n\tif (p == null && unproxy(route).path) {\n\t\tupdatePath();\n\t\treturn;\n\t}\n\tif (!(p instanceof Array)) {\n\t\tconsole.error(\n\t\t\t`aberdeen route: 'p' must be a non-empty array, not ${JSON.stringify(p)}`,\n\t\t);\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 (\n\t\tlocation.pathname === path &&\n\t\tJSON.stringify(history.state.id) === JSON.stringify(state.id)\n\t);\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\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\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 * 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 = \"main\") {\n\tconst el = getParentElement();\n\tel.addEventListener(\"scroll\", onScroll);\n\tclean(() => el.removeEventListener(\"scroll\", onScroll));\n\n\tconst 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.scroll = {};\n\t\troute.aux.scroll[name] = {\n\t\t\tscrollTop: el.scrollTop,\n\t\t\tscrollLeft: el.scrollLeft,\n\t\t};\n\t}\n}\n"
6
6
  ],
7
- "mappings": ";AAAA;AAAA;AAOO,MAAM,MAAM;AAAA,EAElB;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA,QAAgB;AAAA,EAMb,MAA4C;AAAA,EAO/C;AACD;AAKO,IAAM,QAAQ,MAAM,IAAI,KAAO;AAEtC,IAAI,aAAa;AAAA,EAChB,OAAO;AAAA,EACP,OAAO;AACR;AAGA,SAAS,oBAAoB,CAAC,OAAuB;AAAA,EACpD,IAAI,QAAQ,OAAO,SAAS,CAAC;AAAA,EAC7B,IAAI,MAA4C;AAAA,EAChD,IAAI,MAAM,OAAO,SAAS,MAAM;AAAA,IAC/B,MAAM,QAAQ;AAAA,MACb,OAAO,KAAK,MAAM,KAAK,OAAO,IAAI,OAAO,gBAAgB;AAAA,MACzD,OAAO;AAAA,IACR;AAAA,IACA,QAAQ,aAAa,OAAO,EAAE;AAAA,EAC/B,EAAO,SAAI,WAAW,UAAU,MAAM,MAAM,OAAO;AAAA,IAClD,MAAM,MAAM,MAAM,QAAQ,WAAW,QAAQ,YAAY;AAAA,EAC1D;AAAA,EACA,aAAa,MAAM;AAAA,EAEnB,IAAI,QAAQ,KAAK,EAAE,SAAS,QAAQ;AAAA,IACnC,MAAM,QAAQ,WAAW;AAAA,IAEzB,cAAc;AAAA,IACd;AAAA,EACD;AAAA,EAEA,MAAM,SAAa,CAAC;AAAA,EACpB,UAAS,GAAG,MAAM,IAAI,gBAAgB,SAAS,MAAM,GAAG;AAAA,IACvD,OAAO,KAAK;AAAA,EACb;AAAA,EAEA,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GAAG;AAAA,IAChB;AAAA;AAAA;",
8
+ "debugId": "D7FFE7D955D7855E64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,18 +1,18 @@
1
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
- */
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
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
- * 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
- */
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
18
  export declare function shrink(el: HTMLElement): Promise<void>;
@@ -2,16 +2,29 @@
2
2
  var FADE_TIME = 400;
3
3
  var GROW_SHRINK_TRANSITION = `margin ${FADE_TIME}ms ease-out, transform ${FADE_TIME}ms ease-out`;
4
4
  function getGrowShrinkProps(el) {
5
- const parentStyle = el.parentElement ? getComputedStyle(el.parentElement) : {};
6
- const isHorizontal = parentStyle.display === "flex" && (parentStyle.flexDirection || "").startsWith("row");
7
- return isHorizontal ? { marginLeft: `-${el.offsetWidth / 2}px`, marginRight: `-${el.offsetWidth / 2}px`, transform: "scaleX(0)" } : { marginBottom: `-${el.offsetHeight / 2}px`, marginTop: `-${el.offsetHeight / 2}px`, transform: "scaleY(0)" };
5
+ if (el.parentElement) {
6
+ const parentStyle = getComputedStyle(el.parentElement);
7
+ const isHorizontal = parentStyle.display === "flex" && (parentStyle.flexDirection || "").startsWith("row");
8
+ if (isHorizontal) {
9
+ return {
10
+ marginLeft: `-${el.offsetWidth / 2}px`,
11
+ marginRight: `-${el.offsetWidth / 2}px`,
12
+ transform: "scaleX(0)"
13
+ };
14
+ }
15
+ }
16
+ return {
17
+ marginBottom: `-${el.offsetHeight / 2}px`,
18
+ marginTop: `-${el.offsetHeight / 2}px`,
19
+ transform: "scaleY(0)"
20
+ };
8
21
  }
9
22
  async function grow(el) {
10
- let props = getGrowShrinkProps(el);
23
+ const props = getGrowShrinkProps(el);
11
24
  Object.assign(el.style, props);
12
25
  el.offsetHeight;
13
26
  el.style.transition = GROW_SHRINK_TRANSITION;
14
- for (let prop in props)
27
+ for (const prop in props)
15
28
  el.style[prop] = "";
16
29
  setTimeout(() => {
17
30
  el.style.transition = "";
@@ -30,5 +43,5 @@ export {
30
43
  grow
31
44
  };
32
45
 
33
- //# debugId=ADD871168A635CB264756E2164756E21
46
+ //# debugId=ACD770C0365651E664756E2164756E21
34
47
  //# sourceMappingURL=transitions.js.map
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/transitions.ts"],
4
4
  "sourcesContent": [
5
- "const FADE_TIME = 400\nconst GROW_SHRINK_TRANSITION = `margin ${FADE_TIME}ms ease-out, transform ${FADE_TIME}ms ease-out`\n\nfunction getGrowShrinkProps(el: HTMLElement) {\n\tconst parentStyle: any = el.parentElement ? getComputedStyle(el.parentElement) : {}\n\tconst isHorizontal = parentStyle.display === 'flex' && (parentStyle.flexDirection||'').startsWith('row')\n\treturn isHorizontal ?\n\t\t{marginLeft: `-${el.offsetWidth/2}px`, marginRight: `-${el.offsetWidth/2}px`, transform: \"scaleX(0)\"} :\n\t\t{marginBottom: `-${el.offsetHeight/2}px`, marginTop: `-${el.offsetHeight/2}px`, transform: \"scaleY(0)\"}\n\n}\n\n/** Do a grow transition for the given element. This is meant to be used as a\n* handler for the `create` property.\n*\n* @param el The element to transition.\n*\n* The transition doesn't look great for table elements, and may have problems\n* for other specific cases as well.\n*/\nexport async function grow(el: HTMLElement) {\n\tlet props = getGrowShrinkProps(el)\n\tObject.assign(el.style, props)\n\t\n\t// Make sure the layouting has been performed, to cause transitions to trigger\n\tel.offsetHeight\n\n\tel.style.transition = GROW_SHRINK_TRANSITION\n\tfor(let prop in props) el.style[prop as any] = ''\n\tsetTimeout(() => {\n\t\t// Disable transitions.\n\t\tel.style.transition = ''\n\t}, FADE_TIME)\n}\n\n/** Do a shrink transition for the given element, and remove it from the DOM\n* afterwards. This is meant to be used as a handler for the `destroy` property.\n*\n* @param el The element to transition and remove.\n*\n* The transition doesn't look great for table elements, and may have problems\n* for other specific cases as well.\n*/\nexport async function shrink(el: HTMLElement) {\n\t// Get original layout info\n\tconst props = getGrowShrinkProps(el)\n\n\t// Batch starting transitions in the write phase.\n\tel.style.transition = GROW_SHRINK_TRANSITION\n\tObject.assign(el.style, props)\n\t\n\t// Remove the element after the transition is done.\n\tsetTimeout(() => {\n\t\tel.remove()\n\t}, FADE_TIME)\n}\n"
5
+ "const FADE_TIME = 400;\nconst GROW_SHRINK_TRANSITION = `margin ${FADE_TIME}ms ease-out, transform ${FADE_TIME}ms ease-out`;\n\nfunction getGrowShrinkProps(el: HTMLElement): Partial<CSSStyleDeclaration> {\n\tif (el.parentElement) {\n\t\tconst parentStyle = getComputedStyle(el.parentElement);\n\t\tconst isHorizontal =\n\t\t\tparentStyle.display === \"flex\" &&\n\t\t\t(parentStyle.flexDirection || \"\").startsWith(\"row\");\n\t\tif (isHorizontal) {\n\t\t\treturn {\n\t\t\t\tmarginLeft: `-${el.offsetWidth / 2}px`,\n\t\t\t\tmarginRight: `-${el.offsetWidth / 2}px`,\n\t\t\t\ttransform: \"scaleX(0)\",\n\t\t\t};\n\t\t}\n\t}\n\treturn {\n\t\tmarginBottom: `-${el.offsetHeight / 2}px`,\n\t\tmarginTop: `-${el.offsetHeight / 2}px`,\n\t\ttransform: \"scaleY(0)\",\n\t};\n}\n\n/** Do a grow transition for the given element. This is meant to be used as a\n * handler for the `create` property.\n *\n * @param el The element to transition.\n *\n * The transition doesn't look great for table elements, and may have problems\n * for other specific cases as well.\n */\nexport async function grow(el: HTMLElement) {\n\tconst props = getGrowShrinkProps(el);\n\tObject.assign(el.style, props);\n\n\t// Make sure the layouting has been performed, to cause transitions to trigger\n\tel.offsetHeight;\n\n\tel.style.transition = GROW_SHRINK_TRANSITION;\n\tfor (const prop in props) el.style[prop] = \"\";\n\tsetTimeout(() => {\n\t\t// Disable transitions.\n\t\tel.style.transition = \"\";\n\t}, FADE_TIME);\n}\n\n/** Do a shrink transition for the given element, and remove it from the DOM\n * afterwards. This is meant to be used as a handler for the `destroy` property.\n *\n * @param el The element to transition and remove.\n *\n * The transition doesn't look great for table elements, and may have problems\n * for other specific cases as well.\n */\nexport async function shrink(el: HTMLElement) {\n\t// Get original layout info\n\tconst props = getGrowShrinkProps(el);\n\n\t// Batch starting transitions in the write phase.\n\tel.style.transition = GROW_SHRINK_TRANSITION;\n\tObject.assign(el.style, props);\n\n\t// Remove the element after the transition is done.\n\tsetTimeout(() => {\n\t\tel.remove();\n\t}, FADE_TIME);\n}\n"
6
6
  ],
7
- "mappings": ";AAAA,IAAM,YAAY;AAClB,IAAM,yBAAyB,UAAU,mCAAmC;AAE5E,SAAS,kBAAkB,CAAC,IAAiB;AAAA,EAC5C,MAAM,cAAmB,GAAG,gBAAgB,iBAAiB,GAAG,aAAa,IAAI,CAAC;AAAA,EAClF,MAAM,eAAe,YAAY,YAAY,WAAW,YAAY,iBAAe,IAAI,WAAW,KAAK;AAAA,EACvG,OAAO,eACN,EAAC,YAAY,IAAI,GAAG,cAAY,OAAO,aAAa,IAAI,GAAG,cAAY,OAAO,WAAW,YAAW,IACpG,EAAC,cAAc,IAAI,GAAG,eAAa,OAAO,WAAW,IAAI,GAAG,eAAa,OAAO,WAAW,YAAW;AAAA;AAYxG,eAAsB,IAAI,CAAC,IAAiB;AAAA,EAC3C,IAAI,QAAQ,mBAAmB,EAAE;AAAA,EACjC,OAAO,OAAO,GAAG,OAA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AM;AAAA,IAEhB,GAAG,MAAM,aAAa;AAAA,KACpB,SAAS;AAAA;AAWb,eAAsB,MAAM,CAAC,IAAiB;AAAA,EAE7C,MAAM,QAAQ,mBAAmB,EAAE;AAAA,EAGnC,GAAG,MAAM,aAAa;AAAA,EACtB,OAAO,OAAO,GAAG,OAAO,KAAK;AAAA,EAG7B,WAAW,MAAM;AAAA,IAChB,GAAG,OAAO;AAAA,KACR,SAAS;AAAA;",
8
+ "debugId": "ACD770C0365651E664756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,7 +1,7 @@
1
- class Y{keyProp;tail;symbols;constructor(z){this.keyProp=z;this.tail={},this.symbols=[Symbol(0)]}add(z){if(this.symbols[0]in z)return!1;let F=1+(Math.clz32(Math.random()*4294967295)>>2);for(let W=this.symbols.length;W<F;W++)this.symbols.push(Symbol(W));let J=this.keyProp,X=z[J],Z,U=this.tail;for(let W=this.symbols.length-1;W>=0;W--){let j=this.symbols[W];while((Z=U[j])&&Z[J]>X)U=Z;if(W<F)z[j]=U[j],U[j]=z}return!0}has(z){return this.symbols[0]in z}fetchLast(){let z=this.tail[this.symbols[0]];if(z)return this.remove(z),z}isEmpty(){return this.tail[this.symbols[0]]===void 0}get(z){let F=this.keyProp,J=this.tail,X;for(let Z=this.symbols.length-1;Z>=0;Z--){let U=this.symbols[Z];while((X=J[U])&&X[F]>z)J=X}return J[this.symbols[0]]?.[F]===z?J[this.symbols[0]]:void 0}*[Symbol.iterator](){let z=this.symbols[0],F=this.tail[z];while(F)yield F,F=F[z]}prev(z){return z[this.symbols[0]]}remove(z){if(!(this.symbols[0]in z))return!1;let F=this.keyProp,J=z[F],X,Z=this.tail;for(let U=this.symbols.length-1;U>=0;U--){let W=this.symbols[U];while((X=Z[W])&&X[F]>=J&&X!==z)Z=X;if(X===z)Z[W]=X[W],delete X[W]}return X===z}clear(){let z=this.symbols[0],F=this.tail;while(F){let J=F[z];for(let X of this.symbols){if(!(X in F))break;delete F[X]}F=J}this.tail={}}}var B,I=0,G;function E(z){if(!B)B=new Y("prio"),setTimeout(Kz,0);else if(!(I&1)){if(I++,I>98)throw new Error("Too many recursive updates from observes")}B.add(z)}function Kz(){let z=Date.now();while(B){let F=B.fetchLast();if(!F)break;if(I&1)I++;F.queueRun()}if(B=void 0,I=0,z=Date.now()-z,z>1)console.debug(`Aberdeen queue took ${z}ms`)}function l(z){if(typeof z==="string")return z+"\x01";let F="",J=Math.abs(Math.round(z)),X=z<0;while(J>0)F+=String.fromCharCode(X?65534-J%65533:2+J%65533),J=Math.floor(J/65533);return String.fromCharCode(128+(X?-F.length:F.length))+F}function Cz(z){let F="";for(let J=0;J<z.length;J++)F+=String.fromCodePoint(65535-z.charCodeAt(J));return F}var Gz=0;class d{prio=--Gz;remove(){let z=this.getLastNode();if(z)w(z,this.getPrecedingNode());this.delete()}}class P extends d{cleaners;constructor(z=[]){super();this.cleaners=z}lastChild;redraw(){}getLastNode(){return C(this.lastChild)}delete(){for(let z of this.cleaners)if(typeof z==="function")z();else z.delete(this);this.cleaners.length=0,B?.remove(this),this.lastChild=void 0}queueRun(){this.remove(),G=this,this.redraw(),G=void 0}getInsertAfterNode(){return this.getLastNode()||this.getPrecedingNode()}onChange(z,F,J){E(this)}getChildPrevSibling(){return this.lastChild}}class R extends P{parentElement;prevSibling;constructor(z,F=!1){super(F?q.cleaners:[]);this.parentElement=z;if(z===q.parentElement)this.prevSibling=q.getChildPrevSibling(),q.lastChild=this;if(!F)q.cleaners.push(this)}getPrecedingNode(){return C(this.prevSibling)}getChildPrevSibling(){return this.lastChild||this.prevSibling}}class x extends R{renderer;constructor(z,F){super(z);this.renderer=F;this.redraw()}redraw(){let z=q;q=this;try{this.renderer()}catch(F){c(F,!0)}q=z}}class r extends P{parentElement=document.body;getPrecedingNode(){return}}class t extends P{parentElement;renderer;constructor(z,F){super();this.parentElement=z;this.renderer=F;this.redraw(),q.cleaners.push(this)}redraw(){x.prototype.redraw.call(this)}getPrecedingNode(){return}delete(){w(this.getLastNode(),this.getPrecedingNode()),super.delete()}remove(){this.delete()}}function w(z,F){while(z&&z!==F){let J=z.previousSibling,X=S.get(z);if(X&&z instanceof Element){if(X!==!0){if(typeof X==="function")X(z);else Az(z,X);S.set(z,!0)}}else z.remove();z=J}}function C(z){if(!z||z instanceof Node)return z;return z.getLastNode()||z.getPrecedingNode()}class e extends R{renderer;result=A({value:void 0});constructor(z,F){super(z);this.renderer=F;this.redraw()}redraw(){let z=q;q=this;try{this.result.value=this.renderer()}catch(F){c(F,!0)}q=z}}class zz extends R{key;target;constructor(z,F,J){super(z);this.key=F;this.target=J;this.redraw()}redraw(){let z=q;q=this,jz(this.key,this.target.value),q=z}}var L=new Y("prio");class Fz extends x{onChange(z,F,J){L.add(this)}}var v=!1;function D(){for(let z=0;!L.isEmpty()&&!v;z++){if(z>42)throw L.clear(),new Error("Too many immediate-mode recursive updates");v=!0;let F=L;L=new Y("prio");try{for(let J of F)J.queueRun()}finally{v=!1}}}class Jz extends d{renderer;makeSortKey;parentElement=q.parentElement;prevSibling;target;byIndex=new Map;sortedSet=new Y("sortKey");changedIndexes=new Set;constructor(z,F,J){super();this.renderer=F;this.makeSortKey=J;let X=this.target=z[H]||z;if(V(X,Q,this),this.prevSibling=q.getChildPrevSibling(),q.lastChild=this,q.cleaners.push(this),X instanceof Array){for(let Z=0;Z<X.length;Z++)if(X[Z]!==void 0)new O(this,Z,!1)}else for(let Z in X)if(X[Z]!==void 0)new O(this,Z,!1)}getPrecedingNode(){return C(this.prevSibling)}onChange(z,F,J){if(!(this.target instanceof Array)||typeof z==="number")this.changedIndexes.add(z);E(this)}queueRun(){let z=this.changedIndexes;this.changedIndexes=new Set;for(let F of z){let J=this.byIndex.get(F);if(J)J.remove();if(this.target[F]===void 0)this.byIndex.delete(F);else new O(this,F,!0)}G=void 0}delete(){for(let z of this.byIndex.values())z.delete();this.byIndex.clear(),setTimeout(()=>{this.sortedSet.clear()},1)}getLastNode(){for(let z of this.sortedSet){let F=z.getActualLastNode();if(F)return F}}}class O extends P{parent;itemIndex;sortKey;parentElement;constructor(z,F,J){super();this.parent=z;this.itemIndex=F;if(this.parentElement=z.parentElement,this.parent.byIndex.set(this.itemIndex,this),this.lastChild=this,J)G=this;this.redraw()}getPrecedingNode(){this.parent.sortedSet.add(this);let z=this.parent.sortedSet.prev(this);if(z)return C(z.lastChild);return this.parent.getPrecedingNode()}getLastNode(){return this.getPrecedingNode()}getActualLastNode(){let z=this.lastChild;while(z&&z!==this){if(z instanceof Node)return z;let F=z.getLastNode();if(F)return F;z=z.getPrecedingNode()}}queueRun(){if(q!==h)a(4);if(this.sortKey!==void 0){let z=this.getActualLastNode();if(z)w(z,this.getPrecedingNode())}this.delete(),this.lastChild=this,G=this,this.redraw(),G=void 0}redraw(){let z=A(this.parent.target[this.itemIndex]),F=q;q=this;let J;try{if(this.parent.makeSortKey){let X=this.parent.makeSortKey(z,this.itemIndex);if(X!=null)J=X instanceof Array?X.map(l).join(""):X}else J=this.itemIndex;if(typeof J==="number")J=l(J);if(this.sortKey!==J)this.parent.sortedSet.remove(this),this.sortKey=J;if(J!=null)this.parent.renderer(z,this.itemIndex)}catch(X){c(X,J!=null)}q=F}getInsertAfterNode(){if(this.sortKey==null)a(1);return C(this.lastChild)}remove(){if(this.sortKey!==void 0){let z=this.getActualLastNode();if(z)w(z,this.getPrecedingNode());this.parent.sortedSet.remove(this),this.sortKey=void 0}this.delete()}}function T(z){let F=q.parentElement,J=q.getInsertAfterNode();F.insertBefore(z,J?J.nextSibling:F.firstChild),q.lastChild=z}var h=new r,q=h,Q=Symbol("any"),H=Symbol("target"),y=new WeakMap,k=0;function V(z,F,J=q){if(J===h||k)return;let X=y.get(z);if(!X)y.set(z,X=new Map);if(F!==Q&&X.get(Q)?.has(J))return;let Z=X.get(F);if(!Z)X.set(F,Z=new Set);if(Z.has(J))return;if(Z.add(J),J===q)q.cleaners.push(Z);else q.cleaners.push(function(){Z.delete(J)})}function m(z,F,J){if(!z||typeof z!=="object")throw new Error("onEach requires an object");z=z[H]||z,new Jz(z,F,J)}function Xz(z){for(let F in z)return!1;return!0}function Pz(z){let F=z[H]||z,J=q;if(F instanceof Array)return V(F,"length",function(X,Z,U){if(!Z!==!U)E(J)}),!F.length;else{let X=Xz(F);return V(F,Q,function(Z,U,W){if(X?W===void 0:U===void 0)E(J)}),X}}function Rz(z){if(z instanceof Array)return Wz(z,"length");let F=z[H]||z,J=0;for(let Z in F)if(F[Z]!==void 0)J++;let X=Zz(J);return V(F,Q,function(Z,U,W){if(W===U);else if(W===void 0)X.value=++J;else if(U===void 0)X.value=--J}),X}function Vz(z,F,J,X){if(J===X&&J!==void 0)return;let Z=y.get(z);if(Z===void 0)return;for(let U of[F,Q]){let W=Z.get(U);if(W)for(let j of W)if(typeof j==="function")j(F,J,X);else j.onChange(F,J,X)}}var $=Vz,Qz={get(z,F){if(F===H)return z;return V(z,F),A(z[F])},set(z,F,J){if(typeof J==="object"&&J)J=J[H]||J;let X=z[F];if(J!==X)z[F]=J,$(z,F,J,X),D();return!0},deleteProperty(z,F){let J=z[F];return delete z[F],$(z,F,void 0,J),D(),!0},has(z,F){let J=F in z;return V(z,F),J},ownKeys(z){return V(z,Q),Reflect.ownKeys(z)}};function u(z,F,J){if(typeof J==="object"&&J)J=J[H]||J;let X=z[F];if(J!==X){let Z=z.length;if(F==="length"){z.length=J;for(let U=J;U<Z;U++)$(z,U,void 0,z[U])}else{let U=parseInt(F);if(U.toString()===F)F=U;z[F]=J,$(z,F,J,X)}if(z.length!==Z)$(z,"length",z.length,Z);D()}return!0}var Bz={get(z,F){if(F===H)return z;let J=F;if(typeof F!=="symbol"){let X=parseInt(F);if(X.toString()===F)J=X}return V(z,J),A(z[F])},set:u,deleteProperty(z,F){return u(z,F,void 0)}},p=new WeakMap;function A(z){if(typeof z!=="object"||!z||z[H]!==void 0)return z;let F=p.get(z);if(F)return F;return F=new Proxy(z,z instanceof Array?Bz:Qz),p.set(z,F),F}function Zz(z){return A(typeof z==="object"&&z!==null?z:{value:z})}function Uz(z){return z?z[H]||z:z}var S=new WeakMap;function Az(z,F){let J=F.split(".").filter((X)=>X);z.classList.add(...J),setTimeout(()=>z.remove(),2000)}function hz(z,F,J=0){b(z,F,J),D()}var g=1,Nz=2,s=32,f=64;function Oz(z,F=0){let J=Object.create(Object.getPrototypeOf(z));return b(J,z,F),J}function b(z,F,J){let X=z[H];if(X)z=X,J|=f;if(X=F[H],X){if(F=X,q!==h&&!k)J|=s}if(J&s)V(F,Q);if(F instanceof Array){if(!(z instanceof Array))throw new Error("Cannot copy array into object");let Z=z.length,U=F.length;for(let W=0;W<U;W++)n(z,F,W,J);if(U!==Z)if(J&f){for(let W=U;W<Z;W++){let j=z[W];z[W]=void 0,$(z,W,void 0,j)}z.length=U,$(z,"length",U,Z)}else z.length=U}else{for(let Z in F)n(z,F,Z,J);if(!(J&g)){for(let Z in z)if(!(Z in F)){let U=z[Z];if(delete z[Z],J&f&&U!==void 0)$(z,Z,void 0,U)}}}}function n(z,F,J,X){let Z=z[J],U=F[J];if(U!==Z){if(U&&Z&&typeof U==="object"&&typeof Z==="object"&&(U.constructor===Z.constructor||X&g&&Z instanceof Array)){b(Z,U,X);return}if(!(X&Nz)&&U&&typeof U==="object"){let j=Object.create(Object.getPrototypeOf(U));b(j,U,0),U=j}let W=z[J];if(X&g&&U==null)delete z[J];else z[J]=U;if(X&f)$(z,J,U,W)}}var Yz={get(z,F){if(F===H)return Wz(Uz(z.proxy),z.index);if(F==="value")return z.proxy[z.index]},set(z,F,J){if(F==="value")return z.proxy[z.index]=J,!0;return!1}};function Wz(z,F){return new Proxy({proxy:z,index:F},Yz)}function _z(z,F){let J=z,X,Z,U=J.getAttribute("type"),W=Uz(F).value;if(U==="checkbox"){if(W===void 0)F.value=J.checked;X=()=>J.checked=F.value,Z=()=>F.value=J.checked}else if(U==="radio"){if(W===void 0&&J.checked)F.value=J.value;X=()=>J.checked=F.value===J.value,Z=()=>{if(J.checked)F.value=J.value}}else{if(Z=()=>F.value=U==="number"||U==="range"?J.value===""?null:+J.value:J.value,W===void 0)Z();X=()=>J.value=F.value}Iz(X),J.addEventListener("input",Z),M(()=>{J.removeEventListener("input",Z)})}var o={create:function(z){let F=q.parentElement;if(q!==G)return;if(typeof z==="function")z(F);else{let J=z.split(".").filter((X)=>X);F.classList.add(...J),async function(){F.offsetHeight,F.classList.remove(...J)}()}},destroy:function(z){let F=q.parentElement;S.set(F,z)},html:function(z){let F=document.createElement(q.parentElement.tagName);F.innerHTML=""+z;while(F.firstChild)T(F.firstChild)},text:function(z){T(document.createTextNode(z))},element:function(z){if(!(z instanceof Node))throw new Error(`Unexpected element-argument: ${JSON.parse(z)}`);T(z)}};function _(...z){let F,J,X;for(let Z of z){if(Z==null||Z===!1)continue;if(typeof Z==="string"){let U,W,j=Z.indexOf(":");if(j>=0)U=Z.substring(j+1),Z=Z.substring(0,j);let K=Z.indexOf(".");if(K>=0)W=Z.substring(K+1),Z=Z.substring(0,K);if(Z===""){if(U)T(document.createTextNode(U));if(W){let N=q.parentElement;if(N.classList.add(...W.split(".")),!F)M(()=>N.classList.remove(...W.split(".")))}}else if(Z.indexOf(" ")>=0){J=`Tag '${Z}' cannot contain space`;break}else{if(X=document.createElement(Z),W)X.className=W.replaceAll("."," ");if(U)X.textContent=U;if(T(X),!F)F=q;let N=new R(X,!0);if(N.lastChild=X.lastChild||void 0,G===q)G=N;q=N}}else if(typeof Z==="object"){if(Z.constructor!==Object){J=`Unexpected argument: ${Z}`;break}for(let U in Z){let W=Z[U];jz(U,W)}}else if(typeof Z==="function")new x(q.parentElement,Z);else{J=`Unexpected argument: ${Z}`;break}}if(F)q=F;if(J)throw new Error(J);return X}var qz=0;function fz(z,F=!1){let J=F?"":".AbdStl"+ ++qz,X=i(z,J);if(X)_("style:"+X);return J}function i(z,F){let J="",X="";for(let Z in z){let U=z[Z];for(let W of Z.split(/, ?/g))if(U&&typeof U==="object")if(W.startsWith("@"))X+=W+`{
2
- `+i(U,F)+`}
3
- `;else X+=i(U,W.includes("&")?W.replace(/&/g,F):F+" "+W);else J+=W.replace(/[A-Z]/g,(j)=>"-"+j.toLowerCase())+":"+U+";"}if(J)X=(F.trimStart()||"*")+"{"+J+`}
4
- `+X;return X}function jz(z,F){let J=q.parentElement;if(typeof F==="object"&&F!==null&&F[H])if(z==="bind")_z(J,F);else new zz(J,z,F);else if(z[0]==="."){let X=z.substring(1).split(".");if(F)J.classList.add(...X);else J.classList.remove(...X)}else if(z[0]==="$"){let X=z.substring(1);if(F==null||F===!1)J.style[X]="";else J.style[X]=""+F}else if(F==null);else if(z in o)o[z](F);else if(typeof F==="function")J.addEventListener(z,F),M(()=>J.removeEventListener(z,F));else if(F===!0||F===!1||z==="value"||z==="selectedIndex")J[z]=F;else J.setAttribute(z,F)}function Hz(z){return console.error("Error while in Aberdeen render:",z),!0}var $z=Hz;function Ez(z){$z=z||Hz}function wz(){return q.parentElement}function M(z){q.cleaners.push(z)}function Iz(z){return new e(q.parentElement,z).result}function Dz(z){new Fz(q.parentElement,z)}function kz(z,F){new t(z,F)}function bz(){h.remove(),qz=0}function xz(z){k++;try{return z()}finally{k--}}function mz(z,F){let J=A(z instanceof Array?[]:{});return m(z,(X,Z)=>{let U=F(X,Z);if(U!==void 0)J[Z]=U,M(()=>{delete J[Z]})}),J}function vz(z,F){let J=A({});return m(z,(X,Z)=>{let U=F(X,Z);if(U){for(let W in U)J[W]=U[W];M(()=>{for(let W in U)delete J[W]})}}),J}function yz(z,F){let J={},X=Zz(J);return m(z,(Z,U)=>{let W=F(Z,U);if(W!=null){let j=W instanceof Array?W:[W];if(j.length){for(let K of j)if(J[K])X[K][U]=Z;else X[K]={[U]:Z};M(()=>{for(let K of j)if(delete X[K][U],Xz(J[K]))delete X[K]})}}}),X}function Mz(z){if(z&&typeof z==="object")_({text:z instanceof Array?"<array>":"<object>"}),_("ul",()=>{m(z,(F,J)=>{_("li:"+JSON.stringify(J)+": ",()=>{Mz(F)})})});else _({text:JSON.stringify(z)});return z}function a(z){throw new Error("Aberdeen internal error "+z)}function c(z,F){try{if($z(z)===!1)F=!1}catch(J){console.error(J)}try{if(F)_("div.aberdeen-error:Error")}catch{}}function Sz(z,F){let J=$;$=z;try{F()}finally{$=J}}if(!String.prototype.replaceAll)String.prototype.replaceAll=function(z,F){return this.split(z).join(F)};export{Sz as withEmitHandler,Uz as unproxy,bz as unmountAll,Ez as setErrorHandler,Kz as runQueue,Wz as ref,Zz as proxy,xz as peek,yz as partition,m as onEach,Iz as observe,vz as multiMap,kz as mount,mz as map,Pz as isEmpty,Cz as invertString,fz as insertCss,Dz as immediateObserve,wz as getParentElement,Mz as dump,Vz as defaultEmitHandler,Rz as count,hz as copy,Oz as clone,M as clean,Nz as SHALLOW,g as MERGE,_ as $};
1
+ class _{keyProp;tail;symbols;constructor(z){this.keyProp=z;this.tail={},this.symbols=[Symbol(0)]}add(z){if(this.symbols[0]in z)return!1;let F=1+(Math.clz32(Math.random()*4294967295)>>2);for(let W=this.symbols.length;W<F;W++)this.symbols.push(Symbol(W));let J=this.keyProp,X=z[J],Z,U=this.tail;for(let W=this.symbols.length-1;W>=0;W--){let j=this.symbols[W];while((Z=U[j])&&Z[J]>X)U=Z;if(W<F)z[j]=U[j],U[j]=z}return!0}has(z){return this.symbols[0]in z}fetchLast(){let z=this.tail[this.symbols[0]];if(z)return this.remove(z),z}isEmpty(){return this.tail[this.symbols[0]]===void 0}get(z){let F=this.keyProp,J=this.tail,X;for(let Z=this.symbols.length-1;Z>=0;Z--){let U=this.symbols[Z];while((X=J[U])&&X[F]>z)J=X}return J[this.symbols[0]]?.[F]===z?J[this.symbols[0]]:void 0}*[Symbol.iterator](){let z=this.symbols[0],F=this.tail[z];while(F)yield F,F=F[z]}prev(z){return z[this.symbols[0]]}remove(z){if(!(this.symbols[0]in z))return!1;let F=this.keyProp,J=z[F],X,Z=this.tail;for(let U=this.symbols.length-1;U>=0;U--){let W=this.symbols[U];while((X=Z[W])&&X[F]>=J&&X!==z)Z=X;if(X===z)Z[W]=X[W],delete X[W]}return X===z}clear(){let z=this.symbols[0],F=this.tail;while(F){let J=F[z];for(let X of this.symbols){if(!(X in F))break;delete F[X]}F=J}this.tail={}}}var B,I=0,G;function E(z){if(!B)B=new _("prio"),setTimeout(Kz,0);else if(!(I&1)){if(I++,I>98)throw new Error("Too many recursive updates from observes")}B.add(z)}function Kz(){let z=Date.now();while(B){let F=B.fetchLast();if(!F)break;if(I&1)I++;F.queueRun()}if(B=void 0,I=0,z=Date.now()-z,z>1)console.debug(`Aberdeen queue took ${z}ms`)}function u(z){if(typeof z==="string")return`${z}\x01`;let F="",J=Math.abs(Math.round(z)),X=z<0;while(J>0)F+=String.fromCharCode(X?65534-J%65533:2+J%65533),J=Math.floor(J/65533);return String.fromCharCode(128+(X?-F.length:F.length))+F}function Cz(z){let F="";for(let J=0;J<z.length;J++)F+=String.fromCodePoint(65535-z.charCodeAt(J));return F}var Gz=0;class d{prio=--Gz;remove(){let z=this.getLastNode();if(z)w(z,this.getPrecedingNode());this.delete()}}class P extends d{cleaners;constructor(z=[]){super();this.cleaners=z}lastChild;redraw(){}getLastNode(){return C(this.lastChild)}delete(){for(let z of this.cleaners)if(typeof z==="function")z();else z.delete(this);this.cleaners.length=0,B?.remove(this),this.lastChild=void 0}queueRun(){this.remove(),G=this,this.redraw(),G=void 0}getInsertAfterNode(){return this.getLastNode()||this.getPrecedingNode()}onChange(z,F,J){E(this)}getChildPrevSibling(){return this.lastChild}}class R extends P{parentElement;prevSibling;constructor(z,F=!1){super(F?q.cleaners:[]);this.parentElement=z;if(z===q.parentElement)this.prevSibling=q.getChildPrevSibling(),q.lastChild=this;if(!F)q.cleaners.push(this)}getPrecedingNode(){return C(this.prevSibling)}getChildPrevSibling(){return this.lastChild||this.prevSibling}}class x extends R{renderer;constructor(z,F){super(z);this.renderer=F;this.redraw()}redraw(){let z=q;q=this;try{this.renderer()}catch(F){c(F,!0)}q=z}}class r extends P{parentElement=document.body;getPrecedingNode(){return}}class t extends P{parentElement;renderer;constructor(z,F){super();this.parentElement=z;this.renderer=F;this.redraw(),q.cleaners.push(this)}redraw(){x.prototype.redraw.call(this)}getPrecedingNode(){return}delete(){w(this.getLastNode(),this.getPrecedingNode()),super.delete()}remove(){this.delete()}}function w(z,F){while(z&&z!==F){let J=z.previousSibling,X=S.get(z);if(X&&z instanceof Element){if(X!==!0){if(typeof X==="function")X(z);else Az(z,X);S.set(z,!0)}}else z.remove();z=J}}function C(z){if(!z||z instanceof Node)return z;return z.getLastNode()||z.getPrecedingNode()}class e extends R{renderer;result=A({value:void 0});constructor(z,F){super(z);this.renderer=F;this.redraw()}redraw(){let z=q;q=this;try{this.result.value=this.renderer()}catch(F){c(F,!0)}q=z}}class zz extends R{key;target;constructor(z,F,J){super(z);this.key=F;this.target=J;this.redraw()}redraw(){let z=q;q=this,jz(this.key,this.target.value),q=z}}var L=new _("prio");class Fz extends x{onChange(z,F,J){L.add(this)}}var v=!1;function D(){for(let z=0;!L.isEmpty()&&!v;z++){if(z>42)throw L.clear(),new Error("Too many immediate-mode recursive updates");v=!0;let F=L;L=new _("prio");try{for(let J of F)J.queueRun()}finally{v=!1}}}class Jz extends d{renderer;makeSortKey;parentElement=q.parentElement;prevSibling;target;byIndex=new Map;sortedSet=new _("sortKey");changedIndexes=new Set;constructor(z,F,J){super();this.renderer=F;this.makeSortKey=J;let X=this.target=z[H]||z;if(V(X,Q,this),this.prevSibling=q.getChildPrevSibling(),q.lastChild=this,q.cleaners.push(this),X instanceof Array){for(let Z=0;Z<X.length;Z++)if(X[Z]!==void 0)new O(this,Z,!1)}else for(let Z in X)if(X[Z]!==void 0)new O(this,Z,!1)}getPrecedingNode(){return C(this.prevSibling)}onChange(z,F,J){if(!(this.target instanceof Array)||typeof z==="number")this.changedIndexes.add(z);E(this)}queueRun(){let z=this.changedIndexes;this.changedIndexes=new Set;for(let F of z){let J=this.byIndex.get(F);if(J)J.remove();if(this.target[F]===void 0)this.byIndex.delete(F);else new O(this,F,!0)}G=void 0}delete(){for(let z of this.byIndex.values())z.delete();this.byIndex.clear(),setTimeout(()=>{this.sortedSet.clear()},1)}getLastNode(){for(let z of this.sortedSet){let F=z.getActualLastNode();if(F)return F}}}class O extends P{parent;itemIndex;sortKey;parentElement;constructor(z,F,J){super();this.parent=z;this.itemIndex=F;if(this.parentElement=z.parentElement,this.parent.byIndex.set(this.itemIndex,this),this.lastChild=this,J)G=this;this.redraw()}getPrecedingNode(){this.parent.sortedSet.add(this);let z=this.parent.sortedSet.prev(this);if(z)return C(z.lastChild);return this.parent.getPrecedingNode()}getLastNode(){return this.getPrecedingNode()}getActualLastNode(){let z=this.lastChild;while(z&&z!==this){if(z instanceof Node)return z;let F=z.getLastNode();if(F)return F;z=z.getPrecedingNode()}}queueRun(){if(q!==h)a(4);if(this.sortKey!==void 0){let z=this.getActualLastNode();if(z)w(z,this.getPrecedingNode())}this.delete(),this.lastChild=this,G=this,this.redraw(),G=void 0}redraw(){let z=A(this.parent.target[this.itemIndex]),F=q;q=this;let J;try{if(this.parent.makeSortKey){let X=this.parent.makeSortKey(z,this.itemIndex);if(X!=null)J=X instanceof Array?X.map(u).join(""):X}else J=this.itemIndex;if(typeof J==="number")J=u(J);if(this.sortKey!==J)this.parent.sortedSet.remove(this),this.sortKey=J;if(J!=null)this.parent.renderer(z,this.itemIndex)}catch(X){c(X,J!=null)}q=F}getInsertAfterNode(){if(this.sortKey==null)a(1);return C(this.lastChild)}remove(){if(this.sortKey!==void 0){let z=this.getActualLastNode();if(z)w(z,this.getPrecedingNode());this.parent.sortedSet.remove(this),this.sortKey=void 0}this.delete()}}function T(z){let F=q.parentElement,J=q.getInsertAfterNode();F.insertBefore(z,J?J.nextSibling:F.firstChild),q.lastChild=z}var h=new r,q=h,Q=Symbol("any"),H=Symbol("target"),y=new WeakMap,k=0;function V(z,F,J=q){if(J===h||k)return;let X=y.get(z);if(!X)y.set(z,X=new Map);if(F!==Q&&X.get(Q)?.has(J))return;let Z=X.get(F);if(!Z)X.set(F,Z=new Set);if(Z.has(J))return;if(Z.add(J),J===q)q.cleaners.push(Z);else q.cleaners.push(()=>{Z.delete(J)})}function m(z,F,J){if(!z||typeof z!=="object")throw new Error("onEach requires an object");z=z[H]||z,new Jz(z,F,J)}function Xz(z){for(let F in z)return!1;return!0}function Pz(z){let F=z[H]||z,J=q;if(F instanceof Array)return V(F,"length",(Z,U,W)=>{if(!U!==!W)E(J)}),!F.length;let X=Xz(F);return V(F,Q,(Z,U,W)=>{if(X?W===void 0:U===void 0)E(J)}),X}function Rz(z){if(z instanceof Array)return Wz(z,"length");let F=z[H]||z,J=0;for(let Z in F)if(F[Z]!==void 0)J++;let X=Zz(J);return V(F,Q,(Z,U,W)=>{if(W===U);else if(W===void 0)X.value=++J;else if(U===void 0)X.value=--J}),X}function Vz(z,F,J,X){if(J===X&&J!==void 0)return;let Z=y.get(z);if(Z===void 0)return;for(let U of[F,Q]){let W=Z.get(U);if(W)for(let j of W)if(typeof j==="function")j(F,J,X);else j.onChange(F,J,X)}}var $=Vz,Qz={get(z,F){if(F===H)return z;return V(z,F),A(z[F])},set(z,F,J){if(typeof J==="object"&&J)J=J[H]||J;let X=z[F];if(J!==X)z[F]=J,$(z,F,J,X),D();return!0},deleteProperty(z,F){let J=z[F];return delete z[F],$(z,F,void 0,J),D(),!0},has(z,F){let J=F in z;return V(z,F),J},ownKeys(z){return V(z,Q),Reflect.ownKeys(z)}};function l(z,F,J){if(typeof J==="object"&&J)J=J[H]||J;let X=z[F];if(J!==X){let Z=z.length;if(F==="length"){z.length=J;for(let U=J;U<Z;U++)$(z,U,void 0,z[U])}else{let U=Number.parseInt(F);if(U.toString()===F)F=U;z[F]=J,$(z,F,J,X)}if(z.length!==Z)$(z,"length",z.length,Z);D()}return!0}var Bz={get(z,F){if(F===H)return z;let J=F;if(typeof F!=="symbol"){let X=Number.parseInt(F);if(X.toString()===F)J=X}return V(z,J),A(z[F])},set:l,deleteProperty(z,F){return l(z,F,void 0)}},p=new WeakMap;function A(z){if(typeof z!=="object"||!z||z[H]!==void 0)return z;let F=p.get(z);if(F)return F;return F=new Proxy(z,z instanceof Array?Bz:Qz),p.set(z,F),F}function Zz(z){return A(typeof z==="object"&&z!==null?z:{value:z})}function Uz(z){return z?z[H]||z:z}var S=new WeakMap;function Az(z,F){let J=F.split(".").filter((X)=>X);z.classList.add(...J),setTimeout(()=>z.remove(),2000)}function hz(z,F,J=0){b(z,F,J),D()}var g=1,Nz=2,s=32,f=64;function Oz(z,F=0){let J=Object.create(Object.getPrototypeOf(z));return b(J,z,F),J}function b(z,F,J){let X=z[H];if(X)z=X,J|=f;if(X=F[H],X){if(F=X,q!==h&&!k)J|=s}if(J&s)V(F,Q);if(F instanceof Array){if(!(z instanceof Array))throw new Error("Cannot copy array into object");let Z=z.length,U=F.length;for(let W=0;W<U;W++)n(z,F,W,J);if(U!==Z)if(J&f){for(let W=U;W<Z;W++){let j=z[W];z[W]=void 0,$(z,W,void 0,j)}z.length=U,$(z,"length",U,Z)}else z.length=U}else{for(let Z in F)n(z,F,Z,J);if(!(J&g)){for(let Z in z)if(!(Z in F)){let U=z[Z];if(delete z[Z],J&f&&U!==void 0)$(z,Z,void 0,U)}}}}function n(z,F,J,X){let Z=z[J],U=F[J];if(U!==Z){if(U&&Z&&typeof U==="object"&&typeof Z==="object"&&(U.constructor===Z.constructor||X&g&&Z instanceof Array)){b(Z,U,X);return}if(!(X&Nz)&&U&&typeof U==="object"){let j=Object.create(Object.getPrototypeOf(U));b(j,U,0),U=j}let W=z[J];if(X&g&&U==null)delete z[J];else z[J]=U;if(X&f)$(z,J,U,W)}}var _z={get(z,F){if(F===H)return Wz(Uz(z.proxy),z.index);if(F==="value")return z.proxy[z.index]},set(z,F,J){if(F==="value")return z.proxy[z.index]=J,!0;return!1}};function Wz(z,F){return new Proxy({proxy:z,index:F},_z)}function Yz(z,F){let J,X,Z=z.getAttribute("type"),U=Uz(F).value;if(Z==="checkbox"){if(U===void 0)F.value=z.checked;J=()=>{z.checked=F.value},X=()=>{F.value=z.checked}}else if(Z==="radio"){if(U===void 0&&z.checked)F.value=z.value;J=()=>{z.checked=F.value===z.value},X=()=>{if(z.checked)F.value=z.value}}else{if(X=()=>{F.value=Z==="number"||Z==="range"?z.value===""?null:+z.value:z.value},U===void 0)X();J=()=>{if(z.value=F.value,z.tagName==="SELECT"&&z.value!=F.value)throw new Error(`SELECT has no '${F.value}' OPTION (yet)`)}}Iz(J),z.addEventListener("input",X),M(()=>{z.removeEventListener("input",X)})}var o={create:(z)=>{let F=q.parentElement;if(q!==G)return;if(typeof z==="function")z(F);else{let J=z.split(".").filter((X)=>X);F.classList.add(...J),(async()=>{F.offsetHeight,F.classList.remove(...J)})()}},destroy:(z)=>{let F=q.parentElement;S.set(F,z)},html:(z)=>{let F=document.createElement(q.parentElement.tagName);F.innerHTML=`${z}`;while(F.firstChild)T(F.firstChild)},text:(z)=>{T(document.createTextNode(z))},element:(z)=>{if(!(z instanceof Node))throw new Error(`Unexpected element-argument: ${JSON.parse(z)}`);T(z)}};function Y(...z){let F,J,X;for(let Z of z){if(Z==null||Z===!1)continue;if(typeof Z==="string"){let U,W,j=Z.indexOf(":");if(j>=0)U=Z.substring(j+1),Z=Z.substring(0,j);let K=Z.indexOf(".");if(K>=0)W=Z.substring(K+1),Z=Z.substring(0,K);if(Z===""){if(U)T(document.createTextNode(U));if(W){let N=q.parentElement;if(N.classList.add(...W.split(".")),!F)M(()=>N.classList.remove(...W.split(".")))}}else if(Z.indexOf(" ")>=0){J=`Tag '${Z}' cannot contain space`;break}else{if(X=document.createElement(Z),W)X.className=W.replaceAll("."," ");if(U)X.textContent=U;if(T(X),!F)F=q;let N=new R(X,!0);if(N.lastChild=X.lastChild||void 0,G===q)G=N;q=N}}else if(typeof Z==="object"){if(Z.constructor!==Object){J=`Unexpected argument: ${Z}`;break}for(let U in Z){let W=Z[U];jz(U,W)}}else if(typeof Z==="function")new x(q.parentElement,Z);else{J=`Unexpected argument: ${Z}`;break}}if(F)q=F;if(J)throw new Error(J);return X}var qz=0;function fz(z,F=!1){let J=F?"":`.AbdStl${++qz}`,X=i(z,J);if(X)Y(`style:${X}`);return J}function i(z,F){let J="",X="";for(let Z in z){let U=z[Z];for(let W of Z.split(/, ?/g))if(U&&typeof U==="object")if(W.startsWith("@"))X+=`${W}{
2
+ ${i(U,F)}}
3
+ `;else X+=i(U,W.includes("&")?W.replace(/&/g,F):`${F} ${W}`);else J+=`${W.replace(/[A-Z]/g,(j)=>`-${j.toLowerCase()}`)}:${U};`}if(J)X=`${F.trimStart()||"*"}{${J}}
4
+ ${X}`;return X}function jz(z,F){let J=q.parentElement;if(typeof F==="object"&&F!==null&&F[H])if(z==="bind")Yz(J,F);else new zz(J,z,F);else if(z[0]==="."){let X=z.substring(1).split(".");if(F)J.classList.add(...X);else J.classList.remove(...X)}else if(z[0]==="$"){let X=z.substring(1);if(F==null||F===!1)J.style[X]="";else J.style[X]=`${F}`}else if(F==null);else if(z in o)o[z](F);else if(typeof F==="function")J.addEventListener(z,F),M(()=>J.removeEventListener(z,F));else if(F===!0||F===!1||z==="value"||z==="selectedIndex")J[z]=F;else J.setAttribute(z,F)}function Hz(z){return console.error("Error while in Aberdeen render:",z),!0}var $z=Hz;function Ez(z){$z=z||Hz}function wz(){return q.parentElement}function M(z){q.cleaners.push(z)}function Iz(z){return new e(q.parentElement,z).result}function Dz(z){new Fz(q.parentElement,z)}function kz(z,F){new t(z,F)}function bz(){h.remove(),qz=0}function xz(z){k++;try{return z()}finally{k--}}function mz(z,F){let J=A(z instanceof Array?[]:{});return m(z,(X,Z)=>{let U=F(X,Z);if(U!==void 0)J[Z]=U,M(()=>{delete J[Z]})}),J}function vz(z,F){let J=A({});return m(z,(X,Z)=>{let U=F(X,Z);if(U){for(let W in U)J[W]=U[W];M(()=>{for(let W in U)delete J[W]})}}),J}function yz(z,F){let J={},X=Zz(J);return m(z,(Z,U)=>{let W=F(Z,U);if(W!=null){let j=W instanceof Array?W:[W];if(j.length){for(let K of j)if(J[K])X[K][U]=Z;else X[K]={[U]:Z};M(()=>{for(let K of j)if(delete X[K][U],Xz(J[K]))delete X[K]})}}}),X}function Mz(z){if(z&&typeof z==="object")Y({text:z instanceof Array?"<array>":"<object>"}),Y("ul",()=>{m(z,(F,J)=>{Y(`li:${JSON.stringify(J)}: `,()=>{Mz(F)})})});else Y({text:JSON.stringify(z)});return z}function a(z){throw new Error(`Aberdeen internal error ${z}`)}function c(z,F){try{if($z(z)===!1)F=!1}catch(J){console.error(J)}try{if(F)Y("div.aberdeen-error:Error")}catch{}}function Sz(z,F){let J=$;$=z;try{F()}finally{$=J}}export{Sz as withEmitHandler,Uz as unproxy,bz as unmountAll,Ez as setErrorHandler,Kz as runQueue,Wz as ref,Zz as proxy,xz as peek,yz as partition,m as onEach,Iz as observe,vz as multiMap,kz as mount,mz as map,Pz as isEmpty,Cz as invertString,fz as insertCss,Dz as immediateObserve,wz as getParentElement,Mz as dump,Vz as defaultEmitHandler,Rz as count,hz as copy,Oz as clone,M as clean,Nz as SHALLOW,g as MERGE,Y as $};
5
5
 
6
- //# debugId=9D5CE14439C71C7164756E2164756E21
6
+ //# debugId=E870507FF45E52C064756E2164756E21
7
7
  //# sourceMappingURL=aberdeen.js.map