aberdeen 1.7.0 → 1.7.2
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 +17 -11
- package/dist/aberdeen.js +52 -31
- package/dist/aberdeen.js.map +3 -3
- package/dist-min/aberdeen.js +8 -9
- package/dist-min/aberdeen.js.map +3 -3
- package/package.json +1 -1
- package/skill/aberdeen.md +49 -49
- package/skill/dispatcher.md +6 -6
- package/skill/prediction.md +3 -3
- package/skill/route.md +17 -17
- package/skill/transitions.md +3 -3
- package/src/aberdeen.ts +51 -32
package/skill/route.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**Aberdeen v1.7.
|
|
1
|
+
[**Aberdeen v1.7.2**](README.md)
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
### Route
|
|
12
12
|
|
|
13
|
-
Defined in: [route.ts:8](https://github.com/vanviegen/aberdeen/blob/
|
|
13
|
+
Defined in: [route.ts:8](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/route.ts#L8)
|
|
14
14
|
|
|
15
15
|
The class for the global `route` object.
|
|
16
16
|
|
|
@@ -20,7 +20,7 @@ The class for the global `route` object.
|
|
|
20
20
|
|
|
21
21
|
> **depth**: `number`
|
|
22
22
|
|
|
23
|
-
Defined in: [route.ts:20](https://github.com/vanviegen/aberdeen/blob/
|
|
23
|
+
Defined in: [route.ts:20](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/route.ts#L20)
|
|
24
24
|
|
|
25
25
|
The navigation depth of the current session. Starts at 1. Writing to this property has no effect.
|
|
26
26
|
|
|
@@ -28,7 +28,7 @@ The navigation depth of the current session. Starts at 1. Writing to this proper
|
|
|
28
28
|
|
|
29
29
|
> **hash**: `string`
|
|
30
30
|
|
|
31
|
-
Defined in: [route.ts:14](https://github.com/vanviegen/aberdeen/blob/
|
|
31
|
+
Defined in: [route.ts:14](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/route.ts#L14)
|
|
32
32
|
|
|
33
33
|
The hash fragment including the leading `#`, or an empty string. For instance `"#my_section"` or `""`.
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ The hash fragment including the leading `#`, or an empty string. For instance `"
|
|
|
36
36
|
|
|
37
37
|
> **nav**: `NavType`
|
|
38
38
|
|
|
39
|
-
Defined in: [route.ts:28](https://github.com/vanviegen/aberdeen/blob/
|
|
39
|
+
Defined in: [route.ts:28](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/route.ts#L28)
|
|
40
40
|
|
|
41
41
|
The navigation action that got us to this page. Writing to this property has no effect.
|
|
42
42
|
- `"load"`: An initial page load.
|
|
@@ -49,7 +49,7 @@ Mostly useful for page transition animations. Writing to this property has no ef
|
|
|
49
49
|
|
|
50
50
|
> **p**: `string`[]
|
|
51
51
|
|
|
52
|
-
Defined in: [route.ts:12](https://github.com/vanviegen/aberdeen/blob/
|
|
52
|
+
Defined in: [route.ts:12](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/route.ts#L12)
|
|
53
53
|
|
|
54
54
|
An convenience array containing path segments, mapping to `path`. For instance `[]` (for `"/"`) or `['users', '123', 'feed']` (for `"/users/123/feed"`).
|
|
55
55
|
|
|
@@ -57,7 +57,7 @@ An convenience array containing path segments, mapping to `path`. For instance `
|
|
|
57
57
|
|
|
58
58
|
> **path**: `string`
|
|
59
59
|
|
|
60
|
-
Defined in: [route.ts:10](https://github.com/vanviegen/aberdeen/blob/
|
|
60
|
+
Defined in: [route.ts:10](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/route.ts#L10)
|
|
61
61
|
|
|
62
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
63
|
|
|
@@ -65,7 +65,7 @@ The current path of the URL as a string. For instance `"/"` or `"/users/123/feed
|
|
|
65
65
|
|
|
66
66
|
> **search**: `Record`\<`string`, `string`\>
|
|
67
67
|
|
|
68
|
-
Defined in: [route.ts:16](https://github.com/vanviegen/aberdeen/blob/
|
|
68
|
+
Defined in: [route.ts:16](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/route.ts#L16)
|
|
69
69
|
|
|
70
70
|
The query string interpreted as search parameters. So `"a=x&b=y"` becomes `{a: "x", b: "y"}`.
|
|
71
71
|
|
|
@@ -73,7 +73,7 @@ The query string interpreted as search parameters. So `"a=x&b=y"` becomes `{a: "
|
|
|
73
73
|
|
|
74
74
|
> **state**: `Record`\<`string`, `any`\>
|
|
75
75
|
|
|
76
|
-
Defined in: [route.ts:18](https://github.com/vanviegen/aberdeen/blob/
|
|
76
|
+
Defined in: [route.ts:18](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/route.ts#L18)
|
|
77
77
|
|
|
78
78
|
An object to be used for any additional data you want to associate with the current page. Data should be JSON-compatible.
|
|
79
79
|
|
|
@@ -83,7 +83,7 @@ An object to be used for any additional data you want to associate with the curr
|
|
|
83
83
|
|
|
84
84
|
> `const` **current**: [`Route`](#route)
|
|
85
85
|
|
|
86
|
-
Defined in: [route.ts:332](https://github.com/vanviegen/aberdeen/blob/
|
|
86
|
+
Defined in: [route.ts:332](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/route.ts#L332)
|
|
87
87
|
|
|
88
88
|
The global [Route](#route) 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).
|
|
89
89
|
|
|
@@ -93,7 +93,7 @@ The global [Route](#route) object reflecting the current URL and browser history
|
|
|
93
93
|
|
|
94
94
|
> **back**(`target`): `void`
|
|
95
95
|
|
|
96
|
-
Defined in: [route.ts:190](https://github.com/vanviegen/aberdeen/blob/
|
|
96
|
+
Defined in: [route.ts:190](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/route.ts#L190)
|
|
97
97
|
|
|
98
98
|
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
99
|
|
|
@@ -117,7 +117,7 @@ The target route to go back to. May be a subset of [Route](#route), or a string
|
|
|
117
117
|
|
|
118
118
|
> **go**(`target`, `nav`): `void`
|
|
119
119
|
|
|
120
|
-
Defined in: [route.ts:156](https://github.com/vanviegen/aberdeen/blob/
|
|
120
|
+
Defined in: [route.ts:156](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/route.ts#L156)
|
|
121
121
|
|
|
122
122
|
Navigate to a new URL by pushing a new history entry.
|
|
123
123
|
|
|
@@ -158,7 +158,7 @@ route.go({p: ["users", 123], search: {tab: "feed"}, hash: "top"});
|
|
|
158
158
|
|
|
159
159
|
> **interceptLinks**(): `void`
|
|
160
160
|
|
|
161
|
-
Defined in: [route.ts:277](https://github.com/vanviegen/aberdeen/blob/
|
|
161
|
+
Defined in: [route.ts:277](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/route.ts#L277)
|
|
162
162
|
|
|
163
163
|
Intercept clicks and Enter key presses on links (`<a>` tags) and use Aberdeen routing
|
|
164
164
|
instead of browser navigation for local paths (paths without a protocol or host).
|
|
@@ -186,7 +186,7 @@ $('a text=About href=/corporate/about');
|
|
|
186
186
|
|
|
187
187
|
> **persistScroll**(`name`): `void`
|
|
188
188
|
|
|
189
|
-
Defined in: [route.ts:242](https://github.com/vanviegen/aberdeen/blob/
|
|
189
|
+
Defined in: [route.ts:242](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/route.ts#L242)
|
|
190
190
|
|
|
191
191
|
Restore and store the vertical and horizontal scroll position for
|
|
192
192
|
the parent element to the page state.
|
|
@@ -212,7 +212,7 @@ The scroll position will be persisted in `route.aux.scroll.<name>`.
|
|
|
212
212
|
|
|
213
213
|
> **push**(`target`): `void`
|
|
214
214
|
|
|
215
|
-
Defined in: [route.ts:177](https://github.com/vanviegen/aberdeen/blob/
|
|
215
|
+
Defined in: [route.ts:177](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/route.ts#L177)
|
|
216
216
|
|
|
217
217
|
Modify the current route by merging `target` into it (using [merge](aberdeen.md#merge)), pushing a new history entry.
|
|
218
218
|
|
|
@@ -236,7 +236,7 @@ Same as for [go](#go), but merged into the current route instead deleting all st
|
|
|
236
236
|
|
|
237
237
|
> **setLog**(`value`): `void`
|
|
238
238
|
|
|
239
|
-
Defined in: [route.ts:37](https://github.com/vanviegen/aberdeen/blob/
|
|
239
|
+
Defined in: [route.ts:37](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/route.ts#L37)
|
|
240
240
|
|
|
241
241
|
Configure logging on route changes.
|
|
242
242
|
|
|
@@ -258,7 +258,7 @@ Configure logging on route changes.
|
|
|
258
258
|
|
|
259
259
|
> **up**(`stripCount`): `void`
|
|
260
260
|
|
|
261
|
-
Defined in: [route.ts:215](https://github.com/vanviegen/aberdeen/blob/
|
|
261
|
+
Defined in: [route.ts:215](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/route.ts#L215)
|
|
262
262
|
|
|
263
263
|
Navigate up in the path hierarchy, by going back to the first history entry
|
|
264
264
|
that has a shorter path than the current one. If there's none, we just shorten
|
package/skill/transitions.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[**Aberdeen v1.7.
|
|
1
|
+
[**Aberdeen v1.7.2**](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:33](https://github.com/vanviegen/aberdeen/blob/
|
|
15
|
+
Defined in: [transitions.ts:33](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/transitions.ts#L33)
|
|
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:56](https://github.com/vanviegen/aberdeen/blob/
|
|
41
|
+
Defined in: [transitions.ts:56](https://github.com/vanviegen/aberdeen/blob/5343a0b73d29371c35d98f54f8a70608d83576dd/src/transitions.ts#L56)
|
|
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.
|
package/src/aberdeen.ts
CHANGED
|
@@ -1803,8 +1803,8 @@ export function setSpacingCssVars(base = 1, unit = 'rem'): void {
|
|
|
1803
1803
|
}
|
|
1804
1804
|
}
|
|
1805
1805
|
|
|
1806
|
-
// Matches: (1)
|
|
1807
|
-
const CSS_VAR_PATTERN = /(\([^)]*\))|("[^"]*")|(^| )\$(\w+)/g;
|
|
1806
|
+
// Matches: (1) url() content, (2) quoted content, (3) $varName at start or after space
|
|
1807
|
+
const CSS_VAR_PATTERN = /(\burl\([^)]*\))|("[^"]*")|(^| )\$(\w+)/g;
|
|
1808
1808
|
const DIGIT_FIRST = /^\d/;
|
|
1809
1809
|
|
|
1810
1810
|
/**
|
|
@@ -1822,28 +1822,6 @@ function cssVarRef(value: string): string {
|
|
|
1822
1822
|
});
|
|
1823
1823
|
}
|
|
1824
1824
|
|
|
1825
|
-
// Automatically mount cssVars style tag to document.head when cssVars is not empty
|
|
1826
|
-
if (typeof document !== "undefined") {
|
|
1827
|
-
leakScope(() => {
|
|
1828
|
-
$(() => {
|
|
1829
|
-
if (!isEmpty(cssVars)) {
|
|
1830
|
-
mount(document.head, () => {
|
|
1831
|
-
$('style', () => {
|
|
1832
|
-
let css = ":root {\n";
|
|
1833
|
-
for(const [key, value] of Object.entries(cssVars)) {
|
|
1834
|
-
const varName = DIGIT_FIRST.test(String(key)) ? `m${key}` : key;
|
|
1835
|
-
css += ` --${varName}: ${value};\n`;
|
|
1836
|
-
}
|
|
1837
|
-
css += "}";
|
|
1838
|
-
$(`#${css}`);
|
|
1839
|
-
});
|
|
1840
|
-
});
|
|
1841
|
-
}
|
|
1842
|
-
});
|
|
1843
|
-
});
|
|
1844
|
-
}
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
1825
|
let darkModeState: {value: boolean} | undefined;
|
|
1848
1826
|
|
|
1849
1827
|
/**
|
|
@@ -2349,9 +2327,25 @@ let cssCount = 0;
|
|
|
2349
2327
|
export function insertCss(style: string | object): string {
|
|
2350
2328
|
const prefix = `.AbdStl${++cssCount}`;
|
|
2351
2329
|
const css = typeof style === 'string' ? styleStringToCss(style, prefix) : objectToCss(style, prefix);
|
|
2352
|
-
if (css)
|
|
2330
|
+
if (css) {
|
|
2331
|
+
let cnt = cssSnippetCount++;
|
|
2332
|
+
cssSnippets[cnt] = css;
|
|
2333
|
+
clean(() => delete cssSnippets[cnt]);
|
|
2334
|
+
}
|
|
2353
2335
|
return prefix;
|
|
2354
2336
|
}
|
|
2337
|
+
let cssSnippets = proxy({} as Record<number, string>);
|
|
2338
|
+
let cssSnippetCount = 0;
|
|
2339
|
+
|
|
2340
|
+
function combinePrefixSelector(prefix: string, key: string): string {
|
|
2341
|
+
const sel = [];
|
|
2342
|
+
for(const p of prefix.split(',')) {
|
|
2343
|
+
for(const k of key.split(',')) {
|
|
2344
|
+
sel.push(k.includes("&") ? k.trim().replace(/&/g, p) : `${p} ${k.trim()}`.trim());
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
return sel.join(',');
|
|
2348
|
+
}
|
|
2355
2349
|
|
|
2356
2350
|
function objectToCss(style: object, prefix: string): string {
|
|
2357
2351
|
let css = "";
|
|
@@ -2364,10 +2358,7 @@ function objectToCss(style: object, prefix: string): string {
|
|
|
2364
2358
|
css += `${key}{\n${objectToCss(val, prefix)}}\n`;
|
|
2365
2359
|
} else {
|
|
2366
2360
|
// Regular nested selector
|
|
2367
|
-
|
|
2368
|
-
key.includes("&") ? key.replace(/&/g, prefix) :
|
|
2369
|
-
`${prefix} ${key}`.trim();
|
|
2370
|
-
css += objectToCss(val, sel);
|
|
2361
|
+
css += objectToCss(val, combinePrefixSelector(prefix, key));
|
|
2371
2362
|
}
|
|
2372
2363
|
} else if (typeof val === 'string') {
|
|
2373
2364
|
if (key.startsWith("@")) {
|
|
@@ -2375,8 +2366,7 @@ function objectToCss(style: object, prefix: string): string {
|
|
|
2375
2366
|
css += `${key}{\n${styleStringToCss(val, prefix)}}\n`;
|
|
2376
2367
|
} else {
|
|
2377
2368
|
// String value - parse as style string
|
|
2378
|
-
|
|
2379
|
-
css += styleStringToCss(val, sel);
|
|
2369
|
+
css += styleStringToCss(val, combinePrefixSelector(prefix, key));
|
|
2380
2370
|
}
|
|
2381
2371
|
}
|
|
2382
2372
|
}
|
|
@@ -2472,7 +2462,11 @@ function styleStringToCss(styleStr: string, selector: string): string {
|
|
|
2472
2462
|
*/
|
|
2473
2463
|
export function insertGlobalCss(style: object) {
|
|
2474
2464
|
const css = objectToCss(style, "");
|
|
2475
|
-
if (css)
|
|
2465
|
+
if (css) {
|
|
2466
|
+
let cnt = cssSnippetCount++;
|
|
2467
|
+
cssSnippets[cnt] = css;
|
|
2468
|
+
clean(() => delete cssSnippets[cnt]);
|
|
2469
|
+
}
|
|
2476
2470
|
}
|
|
2477
2471
|
|
|
2478
2472
|
const CSS_SHORT: Record<string, string | string[]> = {
|
|
@@ -3177,3 +3171,28 @@ export function withEmitHandler(
|
|
|
3177
3171
|
}
|
|
3178
3172
|
|
|
3179
3173
|
|
|
3174
|
+
// Automatically add cssVars and cssSnippets (from insertCss) into a <head> style tag
|
|
3175
|
+
if (typeof document !== "undefined") {
|
|
3176
|
+
leakScope(() => {
|
|
3177
|
+
$(() => {
|
|
3178
|
+
if (isEmpty(cssSnippets) && isEmpty(cssVars)) return;
|
|
3179
|
+
mount(document.head, () => {
|
|
3180
|
+
$('style.abd', () => {
|
|
3181
|
+
onEach(cssSnippets, (value) => {
|
|
3182
|
+
$('#', value);
|
|
3183
|
+
});
|
|
3184
|
+
$(() => {
|
|
3185
|
+
if (isEmpty(cssVars)) return;
|
|
3186
|
+
let css = ":root{";
|
|
3187
|
+
for(const [key, value] of Object.entries(cssVars)) {
|
|
3188
|
+
const varName = DIGIT_FIRST.test(String(key)) ? `m${key}` : key;
|
|
3189
|
+
css += `--${varName}:${value};`;
|
|
3190
|
+
}
|
|
3191
|
+
css += "}\n";
|
|
3192
|
+
$('#', css);
|
|
3193
|
+
})
|
|
3194
|
+
});
|
|
3195
|
+
});
|
|
3196
|
+
});
|
|
3197
|
+
});
|
|
3198
|
+
}
|