aberdeen 1.18.2 → 1.19.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/README.md +9 -0
- package/dist/src/aberdeen.d.ts +27 -0
- package/{dist-docs/assets/aberdeen/aberdeen.js → dist/src/aberdeen.dev.js} +776 -15
- package/dist/src/aberdeen.dev.js.map +12 -0
- package/dist/src/aberdeen.js +59 -13
- package/dist/src/aberdeen.js.map +3 -3
- package/dist/src/devtools.d.ts +26 -0
- package/html-to-aberdeen +9 -5
- package/package.json +17 -10
- package/skill/A.md +127 -0
- package/skill/Dispatcher.md +51 -0
- package/skill/OPAQUE.md +15 -0
- package/skill/PromiseProxy.md +25 -0
- package/skill/Route.md +50 -0
- package/skill/SKILL.md +272 -156
- package/skill/applyCanon.md +20 -0
- package/skill/applyPrediction.md +15 -0
- package/skill/back.md +11 -0
- package/skill/clean.md +43 -0
- package/skill/clone.md +15 -0
- package/skill/copy.md +40 -0
- package/skill/count.md +32 -0
- package/skill/cssVars.md +15 -0
- package/skill/darkMode.md +26 -0
- package/skill/derive.md +56 -0
- package/skill/developer-tools.md +23 -0
- package/skill/disableCreateDestroy.md +11 -0
- package/skill/dump.md +37 -0
- package/skill/freeze.md +20 -0
- package/skill/full-example-multi-page-app.md +146 -0
- package/skill/go.md +25 -0
- package/skill/grow.md +13 -0
- package/skill/html-to-aberdeen.md +9 -0
- package/skill/insertCss.md +79 -0
- package/skill/insertGlobalCss.md +68 -0
- package/skill/interceptLinks.md +19 -0
- package/skill/invertString.md +32 -0
- package/skill/isEmpty.md +38 -0
- package/skill/map.md +16 -0
- package/skill/matchCurrent.md +27 -0
- package/skill/merge.md +27 -0
- package/skill/mount.md +48 -0
- package/skill/multiMap.md +15 -0
- package/skill/onEach.md +14 -0
- package/skill/partition.md +15 -0
- package/skill/peek.md +36 -0
- package/skill/persistScroll.md +13 -0
- package/skill/proxy.md +11 -0
- package/skill/push.md +13 -0
- package/skill/ref.md +39 -0
- package/skill/runQueue.md +34 -0
- package/skill/setErrorHandler.md +48 -0
- package/skill/setLog.md +9 -0
- package/skill/setSpacingCssVars.md +31 -0
- package/skill/shrink.md +13 -0
- package/skill/unmountAll.md +9 -0
- package/skill/unproxy.md +43 -0
- package/skill/up.md +13 -0
- package/src/aberdeen.ts +194 -73
- package/src/devtools.ts +685 -0
- package/dist-docs/.nojekyll +0 -1
- package/dist-docs/Tutorial/index.html +0 -305
- package/dist-docs/aberdeen/A/index.html +0 -116
- package/dist-docs/aberdeen/CUSTOM_DUMP/index.html +0 -7
- package/dist-docs/aberdeen/NO_COPY/index.html +0 -2
- package/dist-docs/aberdeen/OPAQUE/index.html +0 -12
- package/dist-docs/aberdeen/PromiseProxy/index.html +0 -8
- package/dist-docs/aberdeen/clean/index.html +0 -11
- package/dist-docs/aberdeen/clone/index.html +0 -5
- package/dist-docs/aberdeen/copy/index.html +0 -22
- package/dist-docs/aberdeen/count/index.html +0 -7
- package/dist-docs/aberdeen/cssVars/index.html +0 -11
- package/dist-docs/aberdeen/darkMode/index.html +0 -9
- package/dist-docs/aberdeen/default/index.html +0 -342
- package/dist-docs/aberdeen/derive/index.html +0 -18
- package/dist-docs/aberdeen/disableCreateDestroy/index.html +0 -6
- package/dist-docs/aberdeen/dump/index.html +0 -11
- package/dist-docs/aberdeen/index.html +0 -54
- package/dist-docs/aberdeen/insertCss/index.html +0 -30
- package/dist-docs/aberdeen/insertGlobalCss/index.html +0 -19
- package/dist-docs/aberdeen/invertString/index.html +0 -13
- package/dist-docs/aberdeen/isEmpty/index.html +0 -12
- package/dist-docs/aberdeen/map/index.html +0 -26
- package/dist-docs/aberdeen/merge/index.html +0 -11
- package/dist-docs/aberdeen/mount/index.html +0 -17
- package/dist-docs/aberdeen/multiMap/index.html +0 -28
- package/dist-docs/aberdeen/onEach/index.html +0 -19
- package/dist-docs/aberdeen/partition/index.html +0 -36
- package/dist-docs/aberdeen/peek/index.html +0 -40
- package/dist-docs/aberdeen/proxy/index.html +0 -35
- package/dist-docs/aberdeen/ref/index.html +0 -13
- package/dist-docs/aberdeen/runQueue/index.html +0 -13
- package/dist-docs/aberdeen/setErrorHandler/index.html +0 -16
- package/dist-docs/aberdeen/setSpacingCssVars/index.html +0 -8
- package/dist-docs/aberdeen/unmountAll/index.html +0 -5
- package/dist-docs/aberdeen/unproxy/index.html +0 -11
- package/dist-docs/assets/aberdeen/aberdeen.d.ts +0 -963
- package/dist-docs/assets/aberdeen/aberdeen.js.map +0 -11
- package/dist-docs/assets/aberdeen/dispatcher.d.ts +0 -57
- package/dist-docs/assets/aberdeen/dispatcher.js +0 -66
- package/dist-docs/assets/aberdeen/dispatcher.js.map +0 -10
- package/dist-docs/assets/aberdeen/helpers/reverseSortedSet.d.ts +0 -96
- package/dist-docs/assets/aberdeen/prediction.d.ts +0 -33
- package/dist-docs/assets/aberdeen/prediction.js +0 -112
- package/dist-docs/assets/aberdeen/prediction.js.map +0 -10
- package/dist-docs/assets/aberdeen/route.d.ts +0 -137
- package/dist-docs/assets/aberdeen/route.js +0 -287
- package/dist-docs/assets/aberdeen/route.js.map +0 -10
- package/dist-docs/assets/aberdeen/transitions.d.ts +0 -18
- package/dist-docs/assets/aberdeen/transitions.js +0 -47
- package/dist-docs/assets/aberdeen/transitions.js.map +0 -10
- package/dist-docs/assets/custom.js +0 -573
- package/dist-docs/assets/favicon.png +0 -0
- package/dist-docs/assets/hierarchy.js +0 -1
- package/dist-docs/assets/highlight.css +0 -134
- package/dist-docs/assets/icons.js +0 -18
- package/dist-docs/assets/icons.svg +0 -1
- package/dist-docs/assets/main.js +0 -60
- package/dist-docs/assets/navigation.js +0 -1
- package/dist-docs/assets/search.js +0 -1
- package/dist-docs/assets/style.css +0 -1640
- package/dist-docs/dispatcher/Dispatcher/index.html +0 -21
- package/dist-docs/dispatcher/MATCH_FAILED/index.html +0 -2
- package/dist-docs/dispatcher/MATCH_REST/index.html +0 -2
- package/dist-docs/dispatcher/index.html +0 -4
- package/dist-docs/hierarchy.html +0 -1
- package/dist-docs/index.html +0 -61
- package/dist-docs/media/CHANGELOG.md +0 -266
- package/dist-docs/modules.html +0 -1
- package/dist-docs/prediction/applyCanon/index.html +0 -13
- package/dist-docs/prediction/applyPrediction/index.html +0 -8
- package/dist-docs/prediction/index.html +0 -9
- package/dist-docs/route/Route/index.html +0 -23
- package/dist-docs/route/back/index.html +0 -4
- package/dist-docs/route/current/index.html +0 -2
- package/dist-docs/route/go/index.html +0 -14
- package/dist-docs/route/index.html +0 -15
- package/dist-docs/route/interceptLinks/index.html +0 -8
- package/dist-docs/route/matchCurrent/index.html +0 -10
- package/dist-docs/route/persistScroll/index.html +0 -6
- package/dist-docs/route/push/index.html +0 -6
- package/dist-docs/route/setLog/index.html +0 -3
- package/dist-docs/route/up/index.html +0 -5
- package/dist-docs/sitemap.xml +0 -239
- package/dist-docs/transitions/grow/index.html +0 -6
- package/dist-docs/transitions/index.html +0 -5
- package/dist-docs/transitions/shrink/index.html +0 -6
- package/skill/aberdeen.md +0 -4586
- package/skill/dispatcher.md +0 -129
- package/skill/prediction.md +0 -73
- package/skill/route.md +0 -322
- package/skill/transitions.md +0 -59
package/skill/merge.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
## merge · function
|
|
2
|
+
|
|
3
|
+
Like `copy`, but uses merge semantics. Properties in `dst` not present in `src` are kept.
|
|
4
|
+
`null`/`undefined` in `src` delete properties in `dst`.
|
|
5
|
+
|
|
6
|
+
**Signature:** `{ <T extends object>(dst: T, value: Partial<T>): boolean; <T extends object>(dst: T, dstKey: keyof T, value: Partial<T[keyof T]>): boolean; }`
|
|
7
|
+
|
|
8
|
+
**Type Parameters:**
|
|
9
|
+
|
|
10
|
+
- `T extends object`
|
|
11
|
+
|
|
12
|
+
**Parameters:**
|
|
13
|
+
|
|
14
|
+
- `dst: T`
|
|
15
|
+
- `value: Partial<T>`
|
|
16
|
+
|
|
17
|
+
**Examples:**
|
|
18
|
+
|
|
19
|
+
Basic merge
|
|
20
|
+
```typescript
|
|
21
|
+
const source = { b: { c: 99 }, d: undefined }; // d: undefined will delete
|
|
22
|
+
const $dest = A.proxy({ a: 1, b: { x: 5 }, d: 4 });
|
|
23
|
+
A.merge($dest, source);
|
|
24
|
+
A.merge($dest, 'b', { y: 6 }); // merge into $dest.b
|
|
25
|
+
A.merge($dest, 'c', { z: 7 }); // $dest.c doesn't exist yet, so it will just be assigned
|
|
26
|
+
console.log($dest); // proxy({ a: 1, b: { c: 99, x: 5, y: 6 }, c: { z: 7 } })
|
|
27
|
+
```
|
package/skill/mount.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
## mount · function
|
|
2
|
+
|
|
3
|
+
Attaches a reactive Aberdeen UI fragment to an existing DOM element. Without the use of
|
|
4
|
+
this function, | A will assume `document.body` as its root.
|
|
5
|
+
|
|
6
|
+
It creates a top-level reactive scope associated with the `parentElement`. The provided
|
|
7
|
+
function `func` is executed immediately within this scope. Any proxied data read by `func`
|
|
8
|
+
will cause it to re-execute when the data changes, updating the DOM elements created within it.
|
|
9
|
+
|
|
10
|
+
Calls to | A inside `func` will append nodes to `parentElement`.
|
|
11
|
+
You can nest `derive` or other | A scopes within `func`.
|
|
12
|
+
Use `unmountAll` to clean up all mounted scopes and their DOM nodes.
|
|
13
|
+
|
|
14
|
+
Mounting scopes happens reactively, meaning that if this function is called from within another
|
|
15
|
+
(`derive` or | A or `mount`) scope that gets cleaned up, so will the mount.
|
|
16
|
+
|
|
17
|
+
**Signature:** `(parentElement: Element, func: () => void) => void`
|
|
18
|
+
|
|
19
|
+
**Parameters:**
|
|
20
|
+
|
|
21
|
+
- `parentElement: Element` - - The native DOM `Element` to which the UI fragment will be appended.
|
|
22
|
+
- `func: () => void` - - The function that defines the UI fragment, typically containing calls to | A.
|
|
23
|
+
|
|
24
|
+
**Examples:**
|
|
25
|
+
|
|
26
|
+
Basic Mount
|
|
27
|
+
```javascript
|
|
28
|
+
// Create a pre-existing DOM structure (without Aberdeen)
|
|
29
|
+
document.body.innerHTML = `<h3>Static content <span id="title-extra"></span></h3><div class="box" id="app-root"></div>`;
|
|
30
|
+
|
|
31
|
+
import A from 'aberdeen';
|
|
32
|
+
|
|
33
|
+
const $runTime = A.proxy(0);
|
|
34
|
+
setInterval(() => $runTime.value++, 1000);
|
|
35
|
+
|
|
36
|
+
A.mount(document.getElementById('app-root'), () => {
|
|
37
|
+
A('h4#Aberdeen App');
|
|
38
|
+
A(`p#Run time: ${$runTime.value}s`);
|
|
39
|
+
// Conditionally render some content somewhere else in the static page
|
|
40
|
+
if ($runTime.value&1) {
|
|
41
|
+
A.mount(document.getElementById('title-extra'), () =>
|
|
42
|
+
A(`i#(${$runTime.value}s)`)
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Note how the inner mount behaves reactively as well, automatically unmounting when it's parent observer scope re-runs.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## multiMap · function
|
|
2
|
+
|
|
3
|
+
When using an array as `source`.
|
|
4
|
+
|
|
5
|
+
**Signature:** `{ <IN, OUT extends { [key: string | symbol]: any; }>(source: IN[], func: (value: IN, index: number) => OUT): OUT; <K extends string | number | symbol, IN, OUT extends { [key: string | symbol]: any; }>(source: Record<...>, func: (value: IN, index: KeyToString<...>) => OUT): OUT; <K, IN, OUT extends { [key: string | s...`
|
|
6
|
+
|
|
7
|
+
**Type Parameters:**
|
|
8
|
+
|
|
9
|
+
- `IN`
|
|
10
|
+
- `OUT extends { [key: string | symbol]: any }`
|
|
11
|
+
|
|
12
|
+
**Parameters:**
|
|
13
|
+
|
|
14
|
+
- `source: Array<IN>`
|
|
15
|
+
- `func: (value: IN, index: number) => OUT | undefined`
|
package/skill/onEach.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
## onEach · function
|
|
2
|
+
|
|
3
|
+
**Signature:** `{ <K, T>(target: Map<K, T>, render: (value: T, key: K) => void, makeKey?: (value: T, key: K) => SortKeyType): void; <T>(target: Set<T>, render: (value: T) => void, makeKey?: (value: T) => SortKeyType): void; <T>(target: readonly T[], render: (value: T, index: number) => void, makeKey?: (value: T, index: number) => S...`
|
|
4
|
+
|
|
5
|
+
**Type Parameters:**
|
|
6
|
+
|
|
7
|
+
- `K`
|
|
8
|
+
- `T`
|
|
9
|
+
|
|
10
|
+
**Parameters:**
|
|
11
|
+
|
|
12
|
+
- `target: Map<K, undefined | T>`
|
|
13
|
+
- `render: (value: T, key: K) => void`
|
|
14
|
+
- `makeKey?: (value: T, key: K) => SortKeyType`
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## partition · function
|
|
2
|
+
|
|
3
|
+
When using an object as `array`.
|
|
4
|
+
|
|
5
|
+
**Signature:** `{ <OUT_K extends string | number | symbol, IN_V>(source: IN_V[], func: (value: IN_V, key: number) => OUT_K | OUT_K[]): Record<OUT_K, Record<number, IN_V>>; <IN_K extends string | number | symbol, OUT_K extends string | number | symbol, IN_V>(source: Record<...>, func: (value: IN_V, key: IN_K) => OUT_K | OUT_K[]): Re...`
|
|
6
|
+
|
|
7
|
+
**Type Parameters:**
|
|
8
|
+
|
|
9
|
+
- `OUT_K extends string | number | symbol`
|
|
10
|
+
- `IN_V`
|
|
11
|
+
|
|
12
|
+
**Parameters:**
|
|
13
|
+
|
|
14
|
+
- `source: IN_V[]`
|
|
15
|
+
- `func: (value: IN_V, key: number) => undefined | OUT_K | OUT_K[]`
|
package/skill/peek.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
## peek · function
|
|
2
|
+
|
|
3
|
+
Executes a function or retrieves a value *without* creating subscriptions in the current reactive scope, and returns its result.
|
|
4
|
+
|
|
5
|
+
This is useful when you need to access reactive data inside a reactive scope (like | A)
|
|
6
|
+
but do not want changes to that specific data to trigger a re-execute of the scope.
|
|
7
|
+
|
|
8
|
+
Note: You may also use `unproxy` to get to the raw underlying data structure, which can be used to similar effect.
|
|
9
|
+
|
|
10
|
+
**Signature:** `{ <T extends object, K extends keyof T>(target: T, key: K): T[K]; <K, V>(target: Map<K, V>, key: K): V; <T>(target: T[], key: number): T; <T>(target: () => T): T; }`
|
|
11
|
+
|
|
12
|
+
**Type Parameters:**
|
|
13
|
+
|
|
14
|
+
- `T extends object`
|
|
15
|
+
- `K extends keyof T`
|
|
16
|
+
|
|
17
|
+
**Parameters:**
|
|
18
|
+
|
|
19
|
+
- `target: T` - - Either a function to execute, or an object (which may also be an Array or a Map) to index.
|
|
20
|
+
- `key: K` - - Optional key/index to use when `target` is an object.
|
|
21
|
+
|
|
22
|
+
**Returns:** The result of the function call, or the value at `target[key]` when `target` is an object or `target.get(key)` when it's a Map.
|
|
23
|
+
|
|
24
|
+
**Examples:**
|
|
25
|
+
|
|
26
|
+
Peeking within observer
|
|
27
|
+
```typescript
|
|
28
|
+
const $data = A.proxy({ a: 1, b: 2 });
|
|
29
|
+
A(() => {
|
|
30
|
+
// re-executes only when $data.a changes, because $data.b is peeked.
|
|
31
|
+
const b = A.peek(() => $data.b);
|
|
32
|
+
console.log(`A is ${$data.a}, B was ${b} when A changed.`);
|
|
33
|
+
});
|
|
34
|
+
$data.b = 3; // Does not trigger console.log
|
|
35
|
+
$data.a = 2; // Triggers console.log (logs "A is 2, B was 3 when A changed.")
|
|
36
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## persistScroll · function
|
|
2
|
+
|
|
3
|
+
Restore and store the vertical and horizontal scroll position for
|
|
4
|
+
the parent element to the page state.
|
|
5
|
+
|
|
6
|
+
**Signature:** `(name?: string) => void`
|
|
7
|
+
|
|
8
|
+
**Parameters:**
|
|
9
|
+
|
|
10
|
+
- `name: any` (optional) - - A unique (within this page) name for this
|
|
11
|
+
scrollable element. Defaults to 'main'.
|
|
12
|
+
|
|
13
|
+
The scroll position will be persisted in `route.aux.scroll.<name>`.
|
package/skill/proxy.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
## proxy · function
|
|
2
|
+
|
|
3
|
+
**Signature:** `{ <T extends unknown>(target: Promise<T>): PromiseProxy<T>; <T extends unknown>(target: T[]): (T extends number ? number : T extends string ? string : T extends boolean ? boolean : T)[]; <T extends object>(target: T): T; <T extends unknown>(target: T): ValueRef<...>; }`
|
|
4
|
+
|
|
5
|
+
**Type Parameters:**
|
|
6
|
+
|
|
7
|
+
- `T extends any`
|
|
8
|
+
|
|
9
|
+
**Parameters:**
|
|
10
|
+
|
|
11
|
+
- `target: Promise<T>`
|
package/skill/push.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## push · function
|
|
2
|
+
|
|
3
|
+
Modify the current route by merging `target` into it (using | A.merge), pushing a new history entry.
|
|
4
|
+
|
|
5
|
+
This is useful for things like opening modals or side panels, where you want a browser back action to return to the previous state.
|
|
6
|
+
|
|
7
|
+
**Signature:** `(target: RouteTarget, nav?: NavType) => void`
|
|
8
|
+
|
|
9
|
+
**Parameters:**
|
|
10
|
+
|
|
11
|
+
- `target: RouteTarget` - Same as for `go`, but merged into the current route instead deleting all state.
|
|
12
|
+
- `nav?: NavType` - The navigation type to use. Defaults to `undefined`, meaning the navigation type is unchanged from the current route,
|
|
13
|
+
preventing unwanted page transition animations.
|
package/skill/ref.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
## ref · function
|
|
2
|
+
|
|
3
|
+
Creates a reactive reference (`{ value: T }`-like object) to a specific value
|
|
4
|
+
within a proxied object or array.
|
|
5
|
+
|
|
6
|
+
This is primarily used for the `bind` property in | A to create two-way data bindings
|
|
7
|
+
with form elements, and for passing a reactive property to any of the | A key-value pairs.
|
|
8
|
+
|
|
9
|
+
Reading `ref.value` accesses the property from the underlying proxy (and subscribes the current scope).
|
|
10
|
+
Assigning to `ref.value` updates the property in the underlying proxy (triggering reactive updates).
|
|
11
|
+
|
|
12
|
+
**Signature:** `<T extends TargetType, K extends keyof T>(target: T, index: K) => ValueRef<T[K]>`
|
|
13
|
+
|
|
14
|
+
**Type Parameters:**
|
|
15
|
+
|
|
16
|
+
- `T extends TargetType`
|
|
17
|
+
- `K extends keyof T`
|
|
18
|
+
|
|
19
|
+
**Parameters:**
|
|
20
|
+
|
|
21
|
+
- `target: T` - - The reactive proxy (created by `proxy`) containing the target property.
|
|
22
|
+
- `index: K` - - The key (for objects) or index (for arrays) of the property to reference.
|
|
23
|
+
|
|
24
|
+
**Returns:** A reference object with a `value` property linked to the specified proxy property.
|
|
25
|
+
|
|
26
|
+
**Examples:**
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
const $formData = A.proxy({ color: 'orange', velocity: 42 });
|
|
30
|
+
|
|
31
|
+
// Usage with `bind`
|
|
32
|
+
A('input type=text bind=', A.ref($formData, 'color'));
|
|
33
|
+
|
|
34
|
+
// Usage as a dynamic property, causes a TextNode with just the name to be created and live-updated
|
|
35
|
+
A('p text="Selected color: " text=', A.ref($formData, 'color'), 'color:', A.ref($formData, 'color'));
|
|
36
|
+
|
|
37
|
+
// Changes are actually stored in $formData - this causes logs like `{color: "Blue", velocity 42}`
|
|
38
|
+
A(() => console.log($formData))
|
|
39
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
## runQueue · function
|
|
2
|
+
|
|
3
|
+
Forces the immediate and synchronous execution of all pending reactive updates.
|
|
4
|
+
|
|
5
|
+
Normally, changes to observed data sources (like proxied objects or arrays)
|
|
6
|
+
are processed asynchronously in a batch after a brief timeout (0ms). This function
|
|
7
|
+
allows you to bypass the timeout and process the update queue immediately.
|
|
8
|
+
|
|
9
|
+
This can be useful in specific scenarios where you need the DOM to be updated
|
|
10
|
+
synchronously.
|
|
11
|
+
|
|
12
|
+
This function is re-entrant, meaning it is safe to call `runQueue` from within
|
|
13
|
+
a function that is itself being executed as part of an update cycle triggered
|
|
14
|
+
by a previous (or the same) `runQueue` call.
|
|
15
|
+
|
|
16
|
+
**Signature:** `() => void`
|
|
17
|
+
|
|
18
|
+
**Examples:**
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
const $data = A.proxy("before");
|
|
22
|
+
|
|
23
|
+
A('#', $data);
|
|
24
|
+
console.log(1, document.body.innerHTML); // before
|
|
25
|
+
|
|
26
|
+
// Make an update that should cause the DOM to change.
|
|
27
|
+
$data.value = "after";
|
|
28
|
+
|
|
29
|
+
// Normally, the DOM update would happen after a timeout.
|
|
30
|
+
// But this causes an immediate update:
|
|
31
|
+
A.runQueue();
|
|
32
|
+
|
|
33
|
+
console.log(2, document.body.innerHTML); // after
|
|
34
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
## setErrorHandler · function
|
|
2
|
+
|
|
3
|
+
Sets a custom error handler function for errors that occur asynchronously
|
|
4
|
+
within reactive scopes (e.g., during updates triggered by proxy changes in
|
|
5
|
+
`derive` or | A render functions).
|
|
6
|
+
|
|
7
|
+
The default handler logs the error to `console.error` and adds a simple
|
|
8
|
+
'Error' message div to the DOM at the location where the error occurred (if possible).
|
|
9
|
+
|
|
10
|
+
Your handler can provide custom logging, UI feedback, or suppress the default
|
|
11
|
+
error message.
|
|
12
|
+
|
|
13
|
+
**Signature:** `(handler?: (error: Error) => boolean) => void`
|
|
14
|
+
|
|
15
|
+
**Parameters:**
|
|
16
|
+
|
|
17
|
+
- `handler?: (error: Error) => boolean | undefined` - - A function that accepts the `Error` object.
|
|
18
|
+
- Return `false` to prevent adding an error message to the DOM.
|
|
19
|
+
- Return `true` or `undefined` (or throw) to allow the error messages to be added to the DOM.
|
|
20
|
+
|
|
21
|
+
**Examples:**
|
|
22
|
+
|
|
23
|
+
Custom Logging and Suppressing Default Message
|
|
24
|
+
```typescript
|
|
25
|
+
A.setErrorHandler(error => {
|
|
26
|
+
console.warn('Aberdeen render error:', error.message);
|
|
27
|
+
// Log to error reporting service
|
|
28
|
+
// myErrorReporter.log(error);
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
// Attempt to show a custom message in the UI
|
|
32
|
+
A('div#Oops, something went wrong!', errorClass);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
// Ignore errors during error handling itself
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return false; // Suppress default console log and DOM error message
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Styling for our custom error message
|
|
41
|
+
const errorClass = A.insertCss('background-color:#e31f00 display:inline-block color:white r:3px padding: 2px 4px;');
|
|
42
|
+
|
|
43
|
+
// Cause an error within a render scope.
|
|
44
|
+
A('div.box', () => {
|
|
45
|
+
// Will cause our error handler to insert an error message within the box
|
|
46
|
+
noSuchFunction();
|
|
47
|
+
})
|
|
48
|
+
```
|
package/skill/setLog.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
## setLog · function
|
|
2
|
+
|
|
3
|
+
Configure logging on route changes.
|
|
4
|
+
|
|
5
|
+
**Signature:** `(value: boolean | ((...args: any[]) => void)) => void`
|
|
6
|
+
|
|
7
|
+
**Parameters:**
|
|
8
|
+
|
|
9
|
+
- `value: boolean | ((...args: any[]) => void)` - `true` to enable logging to console, `false` to disable logging, or a custom logging function. Defaults to `false`.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
## setSpacingCssVars · function
|
|
2
|
+
|
|
3
|
+
Initializes `cssVars[0]` through `cssVars[12]` with an exponential spacing scale.
|
|
4
|
+
|
|
5
|
+
The scale is calculated as `2^(n-3) * base`, providing values from `0.25 * base` to `512 * base`.
|
|
6
|
+
|
|
7
|
+
**Signature:** `(base?: number, unit?: string) => void`
|
|
8
|
+
|
|
9
|
+
**Parameters:**
|
|
10
|
+
|
|
11
|
+
- `base: any` (optional) - - The base size for the spacing scale that will apply to `cssVars[3]`. Every step up the scale will double this, while every step down will halve it. Defaults to 1.
|
|
12
|
+
- `unit: any` (optional) - - The CSS unit to use, like 'rem', 'em', or 'px'. Defaults to 'rem'.
|
|
13
|
+
|
|
14
|
+
**Examples:**
|
|
15
|
+
|
|
16
|
+
```javascript
|
|
17
|
+
import A from 'aberdeen';
|
|
18
|
+
// Use default scale (0.25rem to 512rem)
|
|
19
|
+
A.setSpacingCssVars();
|
|
20
|
+
|
|
21
|
+
// Use custom base size
|
|
22
|
+
A.setSpacingCssVars(16, 'px'); // 4px to 8192px
|
|
23
|
+
|
|
24
|
+
// Use em units
|
|
25
|
+
A.setSpacingCssVars(1, 'em'); // 0.25em to 512em
|
|
26
|
+
|
|
27
|
+
// Show the last generated spacing values
|
|
28
|
+
A.onEach(A.cssVars, (value, key) => {
|
|
29
|
+
A(`div #${key} → ${value}`)
|
|
30
|
+
}, (value, key) => parseInt(key)); // Numeric sort
|
|
31
|
+
```
|
package/skill/shrink.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## shrink · function
|
|
2
|
+
|
|
3
|
+
Do a shrink transition for the given element, and remove it from the DOM
|
|
4
|
+
afterwards. This is meant to be used as a handler for the `destroy` property.
|
|
5
|
+
|
|
6
|
+
**Signature:** `(el: HTMLElement) => Promise<void>`
|
|
7
|
+
|
|
8
|
+
**Parameters:**
|
|
9
|
+
|
|
10
|
+
- `el: HTMLElement` - The element to transition and remove.
|
|
11
|
+
|
|
12
|
+
The transition doesn't look great for table elements, and may have problems
|
|
13
|
+
for other specific cases as well.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
## unmountAll · function
|
|
2
|
+
|
|
3
|
+
Removes all Aberdeen-managed DOM nodes and stops all active reactive scopes
|
|
4
|
+
(created by `mount`, `derive`, | A with functions, etc.).
|
|
5
|
+
|
|
6
|
+
This effectively cleans up the entire Aberdeen application state. Aside from in
|
|
7
|
+
automated tests, there should probably be little reason to call this function.
|
|
8
|
+
|
|
9
|
+
**Signature:** `() => void`
|
package/skill/unproxy.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
## unproxy · function
|
|
2
|
+
|
|
3
|
+
Returns the original, underlying data target from a reactive proxy created by `proxy`.
|
|
4
|
+
If the input `target` is not a proxy, it is returned directly.
|
|
5
|
+
|
|
6
|
+
This is useful when you want to avoid triggering subscriptions during read operations or
|
|
7
|
+
re-executes during write operations. Using `peek` is an alternative way to achieve this.
|
|
8
|
+
|
|
9
|
+
**Signature:** `<T>(target: T) => T`
|
|
10
|
+
|
|
11
|
+
**Type Parameters:**
|
|
12
|
+
|
|
13
|
+
- `T` - The type of the target.
|
|
14
|
+
|
|
15
|
+
**Parameters:**
|
|
16
|
+
|
|
17
|
+
- `target: T` - - A proxied object, array, or any other value.
|
|
18
|
+
|
|
19
|
+
**Returns:** The underlying (unproxied) data, or the input value if it wasn't a proxy.
|
|
20
|
+
|
|
21
|
+
**Examples:**
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
const $user = A.proxy({ name: 'Frank' });
|
|
25
|
+
const rawUser = A.unproxy($user);
|
|
26
|
+
|
|
27
|
+
// Log reactively
|
|
28
|
+
A(() => console.log('proxied', $user.name));
|
|
29
|
+
// The following will only ever log once, as we're not subscribing to any observable
|
|
30
|
+
A(() => console.log('unproxied', rawUser.name));
|
|
31
|
+
|
|
32
|
+
// This cause the first log to run again:
|
|
33
|
+
setTimeout(() => $user.name += '!', 1000);
|
|
34
|
+
|
|
35
|
+
// This doesn't cause any new logs:
|
|
36
|
+
setTimeout(() => rawUser.name += '?', 2000);
|
|
37
|
+
|
|
38
|
+
// Both $user and rawUser end up as `{name: 'Frank!?'}`
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
console.log('final proxied', $user)
|
|
41
|
+
console.log('final unproxied', rawUser)
|
|
42
|
+
}, 3000);
|
|
43
|
+
```
|
package/skill/up.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## up · function
|
|
2
|
+
|
|
3
|
+
Navigate up in the path hierarchy, by going back to the first history entry
|
|
4
|
+
that has a shorter path than the current one. If there's none, we just shorten
|
|
5
|
+
the current path.
|
|
6
|
+
|
|
7
|
+
Note that going back in browser history happens asynchronously, so `route` will not be updated immediately.
|
|
8
|
+
|
|
9
|
+
**Signature:** `(stripCount?: number) => void`
|
|
10
|
+
|
|
11
|
+
**Parameters:**
|
|
12
|
+
|
|
13
|
+
- `stripCount: number` (optional)
|