aberdeen 1.17.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/aberdeen.d.ts +928 -944
- package/dist/src/aberdeen.js +1693 -1705
- package/dist/src/aberdeen.js.map +3 -3
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.js +11 -0
- package/dist/src/index.js.map +10 -0
- package/dist/src/prediction.d.ts +7 -4
- package/dist/src/prediction.js +18 -23
- package/dist/src/prediction.js.map +3 -3
- package/dist/src/route.d.ts +114 -101
- package/dist/src/route.js +246 -253
- package/dist/src/route.js.map +3 -3
- package/dist/src/server-dom.d.ts +158 -0
- package/dist/src/server-dom.js +458 -0
- package/dist/src/server-dom.js.map +10 -0
- package/dist/src/server.d.ts +55 -0
- package/dist/src/server.js +25 -0
- package/dist/src/server.js.map +10 -0
- package/dist/src/transitions.js +7 -4
- package/dist/src/transitions.js.map +3 -3
- package/dist/tests/environment.d.ts +24 -0
- package/dist/tests/{fakedom.js → environment.js} +239 -288
- package/dist/tests/environment.js.map +11 -0
- package/dist/tests/helpers.d.ts +15 -3
- package/dist/tests/helpers.js +277 -306
- package/dist/tests/helpers.js.map +6 -5
- package/dist-docs/Tutorial/index.html +30 -30
- package/dist-docs/aberdeen/Aberdeen/index.html +350 -0
- package/dist-docs/aberdeen/InitOptions/index.html +4 -0
- package/dist-docs/aberdeen/KeyToString/index.html +2 -0
- package/dist-docs/aberdeen/PromiseProxy/index.html +6 -6
- package/dist-docs/aberdeen/SortKeyType/index.html +2 -0
- package/dist-docs/aberdeen/TargetType/index.html +2 -0
- package/dist-docs/aberdeen/ValueRef/index.html +2 -0
- package/dist-docs/aberdeen/WindowLike/index.html +5 -0
- package/dist-docs/aberdeen/{clone → createA}/index.html +10 -5
- package/dist-docs/aberdeen/index.html +13 -54
- package/dist-docs/assets/aberdeen/aberdeen.d.ts +928 -944
- package/dist-docs/assets/aberdeen/aberdeen.js +1693 -1705
- package/dist-docs/assets/aberdeen/aberdeen.js.map +3 -3
- package/dist-docs/assets/aberdeen/index.d.ts +12 -0
- package/dist-docs/assets/aberdeen/index.js +11 -0
- package/dist-docs/assets/aberdeen/index.js.map +10 -0
- package/dist-docs/assets/aberdeen/prediction.d.ts +7 -4
- package/dist-docs/assets/aberdeen/prediction.js +18 -23
- package/dist-docs/assets/aberdeen/prediction.js.map +3 -3
- package/dist-docs/assets/aberdeen/route.d.ts +114 -101
- package/dist-docs/assets/aberdeen/route.js +246 -253
- package/dist-docs/assets/aberdeen/route.js.map +3 -3
- package/dist-docs/assets/aberdeen/server-dom.d.ts +158 -0
- package/dist-docs/assets/aberdeen/server-dom.js +458 -0
- package/dist-docs/assets/aberdeen/server-dom.js.map +10 -0
- package/dist-docs/assets/aberdeen/server.d.ts +55 -0
- package/dist-docs/assets/aberdeen/server.js +25 -0
- package/dist-docs/assets/aberdeen/server.js.map +10 -0
- package/dist-docs/assets/aberdeen/transitions.js +7 -4
- package/dist-docs/assets/aberdeen/transitions.js.map +3 -3
- package/dist-docs/assets/navigation.js +1 -1
- package/dist-docs/assets/search.js +1 -1
- package/dist-docs/dispatcher/Dispatcher/index.html +5 -6
- package/dist-docs/dispatcher/MATCH_FAILED/index.html +2 -2
- package/dist-docs/dispatcher/MATCH_REST/index.html +2 -2
- package/dist-docs/dispatcher/index.html +2 -2
- package/dist-docs/hierarchy.html +1 -1
- package/dist-docs/index-1/index.html +2 -0
- package/dist-docs/index.html +2 -2
- package/dist-docs/media/CHANGELOG.md +10 -1
- package/dist-docs/modules.html +1 -1
- package/dist-docs/prediction/applyCanon/index.html +4 -3
- package/dist-docs/prediction/applyPrediction/index.html +4 -3
- package/dist-docs/prediction/index.html +2 -2
- package/dist-docs/route/RouteApi/index.html +60 -0
- package/dist-docs/route/{Route → RouteState}/index.html +9 -9
- package/dist-docs/route/createRoute/index.html +5 -0
- package/dist-docs/route/index.html +6 -15
- package/dist-docs/server/RenderToStringOptions/index.html +6 -0
- package/dist-docs/server/RenderToStringResult/index.html +6 -0
- package/dist-docs/server/index.html +4 -0
- package/dist-docs/server/renderToString/index.html +6 -0
- package/dist-docs/sitemap.xml +52 -156
- package/dist-docs/transitions/grow/index.html +2 -2
- package/dist-docs/transitions/index.html +2 -2
- package/dist-docs/transitions/shrink/index.html +2 -2
- package/package.json +17 -7
- package/skill/SKILL.md +28 -28
- package/skill/aberdeen.md +471 -3448
- package/skill/dispatcher.md +6 -16
- package/skill/prediction.md +17 -5
- package/skill/route.md +155 -137
- package/skill/transitions.md +3 -3
- package/src/aberdeen.ts +1224 -741
- package/src/index.ts +13 -0
- package/src/prediction.ts +25 -24
- package/src/route.ts +419 -393
- package/src/server-dom.ts +508 -0
- package/src/server.ts +74 -0
- package/src/transitions.ts +9 -3
- package/dist/tests/fakedom.d.ts +0 -9
- package/dist/tests/fakedom.js.map +0 -10
- package/dist-docs/aberdeen/A/index.html +0 -115
- 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/clean/index.html +0 -11
- 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 -341
- 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/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/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/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/skill/dispatcher.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**Aberdeen
|
|
1
|
+
[**Aberdeen v2.0.1**](README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
### Dispatcher
|
|
12
12
|
|
|
13
|
-
Defined in: [dispatcher.ts:61](https://github.com/vanviegen/aberdeen/blob/
|
|
13
|
+
Defined in: [dispatcher.ts:61](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/dispatcher.ts#L61)
|
|
14
14
|
|
|
15
15
|
Simple route matcher and dispatcher.
|
|
16
16
|
|
|
@@ -37,23 +37,13 @@ dispatcher.dispatch(["search", "classical", "piano"]);
|
|
|
37
37
|
// Logs: Search terms: [ 'classical', 'piano' ]
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
#### Constructors
|
|
41
|
-
|
|
42
|
-
##### Constructor
|
|
43
|
-
|
|
44
|
-
> **new Dispatcher**(): [`Dispatcher`](#dispatcher)
|
|
45
|
-
|
|
46
|
-
###### Returns
|
|
47
|
-
|
|
48
|
-
[`Dispatcher`](#dispatcher)
|
|
49
|
-
|
|
50
40
|
#### Methods
|
|
51
41
|
|
|
52
42
|
##### addRoute()
|
|
53
43
|
|
|
54
44
|
> **addRoute**\<`T`, `H`\>(...`args`): `void`
|
|
55
45
|
|
|
56
|
-
Defined in: [dispatcher.ts:73](https://github.com/vanviegen/aberdeen/blob/
|
|
46
|
+
Defined in: [dispatcher.ts:73](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/dispatcher.ts#L73)
|
|
57
47
|
|
|
58
48
|
Add a route with matchers and a handler function.
|
|
59
49
|
|
|
@@ -90,7 +80,7 @@ An array of matchers followed by a handler function. Each matcher can be:
|
|
|
90
80
|
|
|
91
81
|
> **dispatch**(`segments`): `boolean`
|
|
92
82
|
|
|
93
|
-
Defined in: [dispatcher.ts:94](https://github.com/vanviegen/aberdeen/blob/
|
|
83
|
+
Defined in: [dispatcher.ts:94](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/dispatcher.ts#L94)
|
|
94
84
|
|
|
95
85
|
Dispatches the given segments to the first route handler that matches.
|
|
96
86
|
|
|
@@ -114,7 +104,7 @@ True if a matching route was found and handled, false otherwise.
|
|
|
114
104
|
|
|
115
105
|
> `const` **MATCH\_FAILED**: unique `symbol`
|
|
116
106
|
|
|
117
|
-
Defined in: [dispatcher.ts:4](https://github.com/vanviegen/aberdeen/blob/
|
|
107
|
+
Defined in: [dispatcher.ts:4](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/dispatcher.ts#L4)
|
|
118
108
|
|
|
119
109
|
Symbol to return when a custom [Dispatcher.addRoute](#addroute) matcher cannot match a segment.
|
|
120
110
|
|
|
@@ -124,6 +114,6 @@ Symbol to return when a custom [Dispatcher.addRoute](#addroute) matcher cannot m
|
|
|
124
114
|
|
|
125
115
|
> `const` **MATCH\_REST**: unique `symbol`
|
|
126
116
|
|
|
127
|
-
Defined in: [dispatcher.ts:9](https://github.com/vanviegen/aberdeen/blob/
|
|
117
|
+
Defined in: [dispatcher.ts:9](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/dispatcher.ts#L9)
|
|
128
118
|
|
|
129
119
|
Special [Dispatcher.addRoute](#addroute) matcher that matches the rest of the segments as an array of strings.
|
package/skill/prediction.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**Aberdeen
|
|
1
|
+
[**Aberdeen v2.0.1**](README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
### applyCanon()
|
|
12
12
|
|
|
13
|
-
> **applyCanon**(`canonFunc?`, `dropPredictions?`): `void`
|
|
13
|
+
> **applyCanon**(`A`, `canonFunc?`, `dropPredictions?`): `void`
|
|
14
14
|
|
|
15
|
-
Defined in: [prediction.ts:136](https://github.com/vanviegen/aberdeen/blob/
|
|
15
|
+
Defined in: [prediction.ts:136](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/prediction.ts#L136)
|
|
16
16
|
|
|
17
17
|
Temporarily revert all outstanding predictions, optionally run the provided function
|
|
18
18
|
(which will generally make authoritative changes to the data based on a server response),
|
|
@@ -25,6 +25,12 @@ actual change to an `Observable`.
|
|
|
25
25
|
|
|
26
26
|
#### Parameters
|
|
27
27
|
|
|
28
|
+
##### A
|
|
29
|
+
|
|
30
|
+
`any`
|
|
31
|
+
|
|
32
|
+
The Aberdeen instance (the default export of `aberdeen`, or one from `init`).
|
|
33
|
+
|
|
28
34
|
##### canonFunc?
|
|
29
35
|
|
|
30
36
|
() => `void`
|
|
@@ -48,9 +54,9 @@ An optional list of predictions (as returned by `applyPrediction`)
|
|
|
48
54
|
|
|
49
55
|
### applyPrediction()
|
|
50
56
|
|
|
51
|
-
> **applyPrediction**(`predictFunc`): `Patch`
|
|
57
|
+
> **applyPrediction**(`A`, `predictFunc`): `Patch`
|
|
52
58
|
|
|
53
|
-
Defined in: [prediction.ts:
|
|
59
|
+
Defined in: [prediction.ts:113](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/prediction.ts#L113)
|
|
54
60
|
|
|
55
61
|
Run the provided function, while treating all changes to Observables as predictions,
|
|
56
62
|
meaning they will be reverted when changes come back from the server (or some other
|
|
@@ -58,6 +64,12 @@ async source).
|
|
|
58
64
|
|
|
59
65
|
#### Parameters
|
|
60
66
|
|
|
67
|
+
##### A
|
|
68
|
+
|
|
69
|
+
`any`
|
|
70
|
+
|
|
71
|
+
The Aberdeen instance (the default export of `aberdeen`, or one from `init`).
|
|
72
|
+
|
|
61
73
|
##### predictFunc
|
|
62
74
|
|
|
63
75
|
() => `void`
|
package/skill/route.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**Aberdeen
|
|
1
|
+
[**Aberdeen v2.0.1**](README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -8,128 +8,63 @@
|
|
|
8
8
|
|
|
9
9
|
## Interfaces
|
|
10
10
|
|
|
11
|
-
###
|
|
11
|
+
### RouteApi
|
|
12
12
|
|
|
13
|
-
Defined in: [route.ts:
|
|
13
|
+
Defined in: [route.ts:39](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L39)
|
|
14
14
|
|
|
15
|
-
The
|
|
15
|
+
The router API returned by [createRoute](#createroute), bound to a specific Aberdeen instance's window.
|
|
16
16
|
|
|
17
17
|
#### Properties
|
|
18
18
|
|
|
19
|
-
#####
|
|
20
|
-
|
|
21
|
-
> **depth**: `number`
|
|
22
|
-
|
|
23
|
-
Defined in: [route.ts:20](https://github.com/vanviegen/aberdeen/blob/ceb94aef9d4eaf884e67232de79631a85f543e28/src/route.ts#L20)
|
|
24
|
-
|
|
25
|
-
The navigation depth of the current session. Starts at 1. Writing to this property has no effect.
|
|
26
|
-
|
|
27
|
-
##### hash
|
|
28
|
-
|
|
29
|
-
> **hash**: `string`
|
|
30
|
-
|
|
31
|
-
Defined in: [route.ts:14](https://github.com/vanviegen/aberdeen/blob/ceb94aef9d4eaf884e67232de79631a85f543e28/src/route.ts#L14)
|
|
32
|
-
|
|
33
|
-
The hash fragment including the leading `#`, or an empty string. For instance `"#my_section"` or `""`.
|
|
34
|
-
|
|
35
|
-
##### nav
|
|
36
|
-
|
|
37
|
-
> **nav**: `NavType`
|
|
38
|
-
|
|
39
|
-
Defined in: [route.ts:28](https://github.com/vanviegen/aberdeen/blob/ceb94aef9d4eaf884e67232de79631a85f543e28/src/route.ts#L28)
|
|
40
|
-
|
|
41
|
-
The navigation action that got us to this page. Writing to this property has no effect.
|
|
42
|
-
- `"load"`: An initial page load.
|
|
43
|
-
- `"back"` or `"forward"`: When we navigated backwards or forwards in the stack.
|
|
44
|
-
- `"go"`: When we added a new page on top of the stack.
|
|
45
|
-
- `"push"`: When we added a new page on top of the stack, merging with the current page.
|
|
46
|
-
Mostly useful for page transition animations. Writing to this property has no effect.
|
|
47
|
-
|
|
48
|
-
##### p
|
|
49
|
-
|
|
50
|
-
> **p**: `string`[]
|
|
51
|
-
|
|
52
|
-
Defined in: [route.ts:12](https://github.com/vanviegen/aberdeen/blob/ceb94aef9d4eaf884e67232de79631a85f543e28/src/route.ts#L12)
|
|
53
|
-
|
|
54
|
-
An convenience array containing path segments, mapping to `path`. For instance `[]` (for `"/"`) or `['users', '123', 'feed']` (for `"/users/123/feed"`).
|
|
55
|
-
|
|
56
|
-
##### path
|
|
57
|
-
|
|
58
|
-
> **path**: `string`
|
|
59
|
-
|
|
60
|
-
Defined in: [route.ts:10](https://github.com/vanviegen/aberdeen/blob/ceb94aef9d4eaf884e67232de79631a85f543e28/src/route.ts#L10)
|
|
61
|
-
|
|
62
|
-
The current path of the URL as a string. For instance `"/"` or `"/users/123/feed"`. Paths are normalized to always start with a `/` and never end with a `/` (unless it's the root path).
|
|
63
|
-
|
|
64
|
-
##### search
|
|
65
|
-
|
|
66
|
-
> **search**: `Record`\<`string`, `string`\>
|
|
19
|
+
##### current
|
|
67
20
|
|
|
68
|
-
|
|
21
|
+
> **current**: [`RouteState`](#routestate)
|
|
69
22
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
##### state
|
|
73
|
-
|
|
74
|
-
> **state**: `Record`\<`string`, `any`\>
|
|
75
|
-
|
|
76
|
-
Defined in: [route.ts:18](https://github.com/vanviegen/aberdeen/blob/ceb94aef9d4eaf884e67232de79631a85f543e28/src/route.ts#L18)
|
|
77
|
-
|
|
78
|
-
An object to be used for any additional data you want to associate with the current page. Data should be JSON-compatible.
|
|
23
|
+
Defined in: [route.ts:43](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L43)
|
|
79
24
|
|
|
80
|
-
|
|
25
|
+
The global [RouteState](#routestate) object reflecting the current URL and browser history state. Changes you make to this affect the current browser history item (modifying the URL if needed).
|
|
81
26
|
|
|
82
|
-
|
|
27
|
+
#### Methods
|
|
83
28
|
|
|
84
|
-
|
|
29
|
+
##### back()
|
|
85
30
|
|
|
86
|
-
|
|
31
|
+
> **back**(`target?`): `void`
|
|
87
32
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
## Functions
|
|
91
|
-
|
|
92
|
-
### back()
|
|
93
|
-
|
|
94
|
-
> **back**(`target`): `void`
|
|
95
|
-
|
|
96
|
-
Defined in: [route.ts:246](https://github.com/vanviegen/aberdeen/blob/ceb94aef9d4eaf884e67232de79631a85f543e28/src/route.ts#L246)
|
|
33
|
+
Defined in: [route.ts:108](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L108)
|
|
97
34
|
|
|
98
35
|
Try to go back in history to the first entry that matches the given target. If none is found, the given state will replace the current page. This is useful for "cancel" or "close" actions that should return to the previous page if possible, but create a new page if not (for instance when arriving at the current page through a direct link).
|
|
99
36
|
|
|
100
37
|
Consider using [up](#up) to go up in the path hierarchy.
|
|
101
38
|
|
|
102
|
-
|
|
39
|
+
###### Parameters
|
|
103
40
|
|
|
104
|
-
|
|
41
|
+
###### target?
|
|
105
42
|
|
|
106
|
-
`RouteTarget`
|
|
43
|
+
`RouteTarget`
|
|
107
44
|
|
|
108
|
-
The target route to go back to. May be a subset of [
|
|
45
|
+
The target route to go back to. May be a subset of [RouteState](#routestate), or a string (for `path`), or an array of strings (for `p`).
|
|
109
46
|
|
|
110
|
-
|
|
47
|
+
###### Returns
|
|
111
48
|
|
|
112
49
|
`void`
|
|
113
50
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
### go()
|
|
51
|
+
##### go()
|
|
117
52
|
|
|
118
|
-
> **go**(`target`, `nav
|
|
53
|
+
> **go**(`target`, `nav?`): `void`
|
|
119
54
|
|
|
120
|
-
Defined in: [route.ts:
|
|
55
|
+
Defined in: [route.ts:69](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L69)
|
|
121
56
|
|
|
122
57
|
Navigate to a new URL by pushing a new history entry.
|
|
123
58
|
|
|
124
59
|
Note that this happens synchronously, immediately updating `route` and processing any reactive updates based on that.
|
|
125
60
|
|
|
126
|
-
|
|
61
|
+
###### Parameters
|
|
127
62
|
|
|
128
|
-
|
|
63
|
+
###### target
|
|
129
64
|
|
|
130
65
|
`RouteTarget`
|
|
131
66
|
|
|
132
|
-
A subset of the [
|
|
67
|
+
A subset of the [RouteState](#routestate) properties to navigate to. If neither `p` nor `path` is given, the current path is used. For other properties, an empty/default value is assumed if not given. For convenience:
|
|
133
68
|
- You may pass a string instead of an object, which is interpreted as the `path`.
|
|
134
69
|
- You may pass an array instead of an object, which is interpreted as the `p` array.
|
|
135
70
|
- If you pass `p`, it may contain numbers, which will be converted to strings.
|
|
@@ -144,21 +79,19 @@ route.go("/users/123");
|
|
|
144
79
|
route.go({p: ["users", 123], search: {tab: "feed"}, hash: "top"});
|
|
145
80
|
```
|
|
146
81
|
|
|
147
|
-
|
|
82
|
+
###### nav?
|
|
148
83
|
|
|
149
|
-
`NavType`
|
|
84
|
+
`NavType`
|
|
150
85
|
|
|
151
|
-
|
|
86
|
+
###### Returns
|
|
152
87
|
|
|
153
88
|
`void`
|
|
154
89
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
### interceptLinks()
|
|
90
|
+
##### interceptLinks()
|
|
158
91
|
|
|
159
92
|
> **interceptLinks**(): `void`
|
|
160
93
|
|
|
161
|
-
Defined in: [route.ts:
|
|
94
|
+
Defined in: [route.ts:145](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L145)
|
|
162
95
|
|
|
163
96
|
Intercept clicks and Enter key presses on links (`<a>` tags) and use Aberdeen routing
|
|
164
97
|
instead of browser navigation for local paths (paths without a protocol or host).
|
|
@@ -166,11 +99,11 @@ instead of browser navigation for local paths (paths without a protocol or host)
|
|
|
166
99
|
This allows you to use regular HTML anchor tags for navigation without needing to
|
|
167
100
|
manually attach click handlers to each link.
|
|
168
101
|
|
|
169
|
-
|
|
102
|
+
###### Returns
|
|
170
103
|
|
|
171
104
|
`void`
|
|
172
105
|
|
|
173
|
-
|
|
106
|
+
###### Example
|
|
174
107
|
|
|
175
108
|
```js
|
|
176
109
|
// In your root component:
|
|
@@ -180,13 +113,11 @@ route.interceptLinks();
|
|
|
180
113
|
A('a text=About href=/corporate/about');
|
|
181
114
|
```
|
|
182
115
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
### matchCurrent()
|
|
116
|
+
##### matchCurrent()
|
|
186
117
|
|
|
187
118
|
> **matchCurrent**(`target`): `boolean`
|
|
188
119
|
|
|
189
|
-
Defined in: [route.ts:
|
|
120
|
+
Defined in: [route.ts:90](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L90)
|
|
190
121
|
|
|
191
122
|
Returns `true` if the current route matches `target`.
|
|
192
123
|
|
|
@@ -198,17 +129,17 @@ when target k/v search pairs are (un)set.
|
|
|
198
129
|
|
|
199
130
|
Primary usage: 'active' status for menu items.
|
|
200
131
|
|
|
201
|
-
|
|
132
|
+
###### Parameters
|
|
202
133
|
|
|
203
|
-
|
|
134
|
+
###### target
|
|
204
135
|
|
|
205
136
|
`RouteTarget`
|
|
206
137
|
|
|
207
|
-
|
|
138
|
+
###### Returns
|
|
208
139
|
|
|
209
140
|
`boolean`
|
|
210
141
|
|
|
211
|
-
|
|
142
|
+
###### Example
|
|
212
143
|
|
|
213
144
|
```js
|
|
214
145
|
// This example assumes interceptLinks() has been called
|
|
@@ -218,92 +149,84 @@ A('a.my-button text=Users href=/users .is-active=', route.matchCurrent('/users')
|
|
|
218
149
|
route.matchCurrent({path: '/users', search: {tab: 'profile'}});
|
|
219
150
|
```
|
|
220
151
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
### persistScroll()
|
|
152
|
+
##### persistScroll()
|
|
224
153
|
|
|
225
|
-
> **persistScroll**(`name
|
|
154
|
+
> **persistScroll**(`name?`): `void`
|
|
226
155
|
|
|
227
|
-
Defined in: [route.ts:
|
|
156
|
+
Defined in: [route.ts:128](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L128)
|
|
228
157
|
|
|
229
158
|
Restore and store the vertical and horizontal scroll position for
|
|
230
159
|
the parent element to the page state.
|
|
231
160
|
|
|
232
|
-
|
|
161
|
+
###### Parameters
|
|
233
162
|
|
|
234
|
-
|
|
163
|
+
###### name?
|
|
235
164
|
|
|
236
|
-
`string`
|
|
165
|
+
`string`
|
|
237
166
|
|
|
238
167
|
A unique (within this page) name for this
|
|
239
168
|
scrollable element. Defaults to 'main'.
|
|
240
169
|
|
|
241
170
|
The scroll position will be persisted in `route.aux.scroll.<name>`.
|
|
242
171
|
|
|
243
|
-
|
|
172
|
+
###### Returns
|
|
244
173
|
|
|
245
174
|
`void`
|
|
246
175
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
### push()
|
|
176
|
+
##### push()
|
|
250
177
|
|
|
251
178
|
> **push**(`target`, `nav?`): `void`
|
|
252
179
|
|
|
253
|
-
Defined in: [route.ts:
|
|
180
|
+
Defined in: [route.ts:100](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L100)
|
|
254
181
|
|
|
255
182
|
Modify the current route by merging `target` into it (using [A.merge](aberdeen.md#merge)), pushing a new history entry.
|
|
256
183
|
|
|
257
184
|
This is useful for things like opening modals or side panels, where you want a browser back action to return to the previous state.
|
|
258
185
|
|
|
259
|
-
|
|
186
|
+
###### Parameters
|
|
260
187
|
|
|
261
|
-
|
|
188
|
+
###### target
|
|
262
189
|
|
|
263
190
|
`RouteTarget`
|
|
264
191
|
|
|
265
192
|
Same as for [go](#go), but merged into the current route instead deleting all state.
|
|
266
193
|
|
|
267
|
-
|
|
194
|
+
###### nav?
|
|
268
195
|
|
|
269
196
|
`NavType`
|
|
270
197
|
|
|
271
198
|
The navigation type to use. Defaults to `undefined`, meaning the navigation type is unchanged from the current route,
|
|
272
199
|
preventing unwanted page transition animations.
|
|
273
200
|
|
|
274
|
-
|
|
201
|
+
###### Returns
|
|
275
202
|
|
|
276
203
|
`void`
|
|
277
204
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
### setLog()
|
|
205
|
+
##### setLog()
|
|
281
206
|
|
|
282
207
|
> **setLog**(`value`): `void`
|
|
283
208
|
|
|
284
|
-
Defined in: [route.ts:
|
|
209
|
+
Defined in: [route.ts:48](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L48)
|
|
285
210
|
|
|
286
211
|
Configure logging on route changes.
|
|
287
212
|
|
|
288
|
-
|
|
213
|
+
###### Parameters
|
|
289
214
|
|
|
290
|
-
|
|
215
|
+
###### value
|
|
291
216
|
|
|
292
217
|
`true` to enable logging to console, `false` to disable logging, or a custom logging function. Defaults to `false`.
|
|
293
218
|
|
|
294
219
|
`boolean` | (...`args`) => `void`
|
|
295
220
|
|
|
296
|
-
|
|
221
|
+
###### Returns
|
|
297
222
|
|
|
298
223
|
`void`
|
|
299
224
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
### up()
|
|
225
|
+
##### up()
|
|
303
226
|
|
|
304
|
-
> **up**(`stripCount
|
|
227
|
+
> **up**(`stripCount?`): `void`
|
|
305
228
|
|
|
306
|
-
Defined in: [route.ts:
|
|
229
|
+
Defined in: [route.ts:116](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L116)
|
|
307
230
|
|
|
308
231
|
Navigate up in the path hierarchy, by going back to the first history entry
|
|
309
232
|
that has a shorter path than the current one. If there's none, we just shorten
|
|
@@ -311,12 +234,107 @@ the current path.
|
|
|
311
234
|
|
|
312
235
|
Note that going back in browser history happens asynchronously, so `route` will not be updated immediately.
|
|
313
236
|
|
|
237
|
+
###### Parameters
|
|
238
|
+
|
|
239
|
+
###### stripCount?
|
|
240
|
+
|
|
241
|
+
`number`
|
|
242
|
+
|
|
243
|
+
###### Returns
|
|
244
|
+
|
|
245
|
+
`void`
|
|
246
|
+
|
|
247
|
+
***
|
|
248
|
+
|
|
249
|
+
### RouteState
|
|
250
|
+
|
|
251
|
+
Defined in: [route.ts:6](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L6)
|
|
252
|
+
|
|
253
|
+
The class for the global `route` object.
|
|
254
|
+
|
|
255
|
+
#### Properties
|
|
256
|
+
|
|
257
|
+
##### depth
|
|
258
|
+
|
|
259
|
+
> **depth**: `number`
|
|
260
|
+
|
|
261
|
+
Defined in: [route.ts:18](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L18)
|
|
262
|
+
|
|
263
|
+
The navigation depth of the current session. Starts at 1. Writing to this property has no effect.
|
|
264
|
+
|
|
265
|
+
##### hash
|
|
266
|
+
|
|
267
|
+
> **hash**: `string`
|
|
268
|
+
|
|
269
|
+
Defined in: [route.ts:12](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L12)
|
|
270
|
+
|
|
271
|
+
The hash fragment including the leading `#`, or an empty string. For instance `"#my_section"` or `""`.
|
|
272
|
+
|
|
273
|
+
##### nav
|
|
274
|
+
|
|
275
|
+
> **nav**: `NavType`
|
|
276
|
+
|
|
277
|
+
Defined in: [route.ts:26](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L26)
|
|
278
|
+
|
|
279
|
+
The navigation action that got us to this page. Writing to this property has no effect.
|
|
280
|
+
- `"load"`: An initial page load.
|
|
281
|
+
- `"back"` or `"forward"`: When we navigated backwards or forwards in the stack.
|
|
282
|
+
- `"go"`: When we added a new page on top of the stack.
|
|
283
|
+
- `"push"`: When we added a new page on top of the stack, merging with the current page.
|
|
284
|
+
Mostly useful for page transition animations. Writing to this property has no effect.
|
|
285
|
+
|
|
286
|
+
##### p
|
|
287
|
+
|
|
288
|
+
> **p**: `string`[]
|
|
289
|
+
|
|
290
|
+
Defined in: [route.ts:10](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L10)
|
|
291
|
+
|
|
292
|
+
An convenience array containing path segments, mapping to `path`. For instance `[]` (for `"/"`) or `['users', '123', 'feed']` (for `"/users/123/feed"`).
|
|
293
|
+
|
|
294
|
+
##### path
|
|
295
|
+
|
|
296
|
+
> **path**: `string`
|
|
297
|
+
|
|
298
|
+
Defined in: [route.ts:8](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L8)
|
|
299
|
+
|
|
300
|
+
The current path of the URL as a string. For instance `"/"` or `"/users/123/feed"`. Paths are normalized to always start with a `/` and never end with a `/` (unless it's the root path).
|
|
301
|
+
|
|
302
|
+
##### search
|
|
303
|
+
|
|
304
|
+
> **search**: `Record`\<`string`, `string`\>
|
|
305
|
+
|
|
306
|
+
Defined in: [route.ts:14](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L14)
|
|
307
|
+
|
|
308
|
+
The query string interpreted as search parameters. So `"a=x&b=y"` becomes `{a: "x", b: "y"}`.
|
|
309
|
+
|
|
310
|
+
##### state
|
|
311
|
+
|
|
312
|
+
> **state**: `Record`\<`string`, `any`\>
|
|
313
|
+
|
|
314
|
+
Defined in: [route.ts:16](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L16)
|
|
315
|
+
|
|
316
|
+
An object to be used for any additional data you want to associate with the current page. Data should be JSON-compatible.
|
|
317
|
+
|
|
318
|
+
## Functions
|
|
319
|
+
|
|
320
|
+
### createRoute()
|
|
321
|
+
|
|
322
|
+
> **createRoute**(`A`): [`RouteApi`](#routeapi)
|
|
323
|
+
|
|
324
|
+
Defined in: [route.ts:155](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/route.ts#L155)
|
|
325
|
+
|
|
326
|
+
Initialise routing for an Aberdeen instance and return the router API, bound to that
|
|
327
|
+
instance's window. In the browser, use the default instance: `init(A)`. For server-side
|
|
328
|
+
rendering, pass the instance provided by `aberdeen/server`'s render callback.
|
|
329
|
+
|
|
314
330
|
#### Parameters
|
|
315
331
|
|
|
316
|
-
#####
|
|
332
|
+
##### A
|
|
317
333
|
|
|
318
|
-
`
|
|
334
|
+
`any`
|
|
335
|
+
|
|
336
|
+
An Aberdeen instance (the default export of `aberdeen`, or one from `init`).
|
|
319
337
|
|
|
320
338
|
#### Returns
|
|
321
339
|
|
|
322
|
-
`
|
|
340
|
+
[`RouteApi`](#routeapi)
|
package/skill/transitions.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**Aberdeen
|
|
1
|
+
[**Aberdeen v2.0.1**](README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
> **grow**(`el`): `Promise`\<`void`\>
|
|
14
14
|
|
|
15
|
-
Defined in: [transitions.ts:
|
|
15
|
+
Defined in: [transitions.ts:39](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/transitions.ts#L39)
|
|
16
16
|
|
|
17
17
|
Do a grow transition for the given element. This is meant to be used as a
|
|
18
18
|
handler for the `create` property.
|
|
@@ -38,7 +38,7 @@ for other specific cases as well.
|
|
|
38
38
|
|
|
39
39
|
> **shrink**(`el`): `Promise`\<`void`\>
|
|
40
40
|
|
|
41
|
-
Defined in: [transitions.ts:
|
|
41
|
+
Defined in: [transitions.ts:62](https://github.com/vanviegen/aberdeen/blob/b53eddf1a1a2f6ec80ec8518a4cec30e65aa9b96/src/transitions.ts#L62)
|
|
42
42
|
|
|
43
43
|
Do a shrink transition for the given element, and remove it from the DOM
|
|
44
44
|
afterwards. This is meant to be used as a handler for the `destroy` property.
|