@base-framework/base 3.9.22 → 3.9.24

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,3 +1,10 @@
1
+ /**
2
+ * The attribute set on the roots of a keep-alive page that is hidden
3
+ * in place. Routes inside it are dormant (see Route.isDormant).
4
+ *
5
+ * @type {string}
6
+ */
7
+ export const DORMANT_ATTR: string;
1
8
  /**
2
9
  * ComponentHelper
3
10
  *
@@ -41,6 +48,38 @@ export class ComponentHelper {
41
48
  * @type {boolean|null} keepAlive
42
49
  */
43
50
  keepAlive: boolean | null;
51
+ /**
52
+ * The route keep-alive mode: 'detach' removes the page from the
53
+ * document, 'hide' leaves it in place hidden. Null uses the
54
+ * component `keepAliveMode` or the router default.
55
+ *
56
+ * @type {string|null} keepAliveMode
57
+ */
58
+ keepAliveMode: string | null;
59
+ /**
60
+ * True while the cached page is hidden in place instead of
61
+ * detached.
62
+ *
63
+ * @type {boolean} hiddenInPlace
64
+ */
65
+ hiddenInPlace: boolean;
66
+ /**
67
+ * The inline values each root had before it was hidden.
68
+ *
69
+ * @type {WeakMap<object, Array<Array<string>>>|null} hiddenStyles
70
+ */
71
+ hiddenStyles: WeakMap<object, Array<Array<string>>> | null;
72
+ /**
73
+ * The element scroll offsets read at the start of a navigation,
74
+ * before any page was added or removed. Reading them later, once
75
+ * the incoming page is in the document, forces the browser to
76
+ * style and lay out that whole page in the click.
77
+ *
78
+ * @type {{ value: object|null }|null} capturedScroll
79
+ */
80
+ capturedScroll: {
81
+ value: object | null;
82
+ } | null;
44
83
  /**
45
84
  * The router page cache that tracks detached keep-alive
46
85
  * pages and element scroll memory.
@@ -97,12 +136,45 @@ export class ComponentHelper {
97
136
  * @returns {boolean}
98
137
  */
99
138
  isKeepAlive(component?: object | null): boolean;
139
+ /**
140
+ * This will get the keep-alive mode. The route setting wins, then
141
+ * the component `keepAliveMode` property, then the router default.
142
+ *
143
+ * @param {object|null} [component]
144
+ * @returns {string} 'detach' or 'hide'
145
+ */
146
+ getKeepAliveMode(component?: object | null): string;
100
147
  /**
101
148
  * This will check if the page is detached and cached.
102
149
  *
103
150
  * @returns {boolean}
104
151
  */
105
152
  isDetached(): boolean;
153
+ /**
154
+ * This will read the element scroll of the page now, while the
155
+ * document still only holds the current pages. The router calls it
156
+ * at the start of a navigation. The page uses it if it is removed
157
+ * during that navigation.
158
+ *
159
+ * @returns {void}
160
+ */
161
+ captureScroll(): void;
162
+ /**
163
+ * This will drop a captured element scroll that was not used.
164
+ *
165
+ * @returns {void}
166
+ */
167
+ releaseCapturedScroll(): void;
168
+ /**
169
+ * This will get the element scroll to save when the page is
170
+ * removed: the captured offsets when the router captured them,
171
+ * else the offsets read now.
172
+ *
173
+ * @protected
174
+ * @param {object} component
175
+ * @returns {object|null}
176
+ */
177
+ protected takeScroll(component: object): object | null;
106
178
  /**
107
179
  * This will create the component.
108
180
  *
@@ -209,8 +281,12 @@ export class ComponentHelper {
209
281
  protected restoreHistoryScroll(): void;
210
282
  /**
211
283
  * This will restore the element scroll of a re-inserted page.
212
- * The page keeps its content, so this is done synchronously
213
- * before the next paint.
284
+ *
285
+ * Setting scrollTop makes the browser lay out the document, and
286
+ * the navigation is still changing it (the outgoing page has not
287
+ * been removed yet), so writing it in the click would pay for a
288
+ * layout that is thrown away. It is written in the next animation
289
+ * frame instead, which still runs before that frame is painted.
214
290
  *
215
291
  * @protected
216
292
  * @returns {void}
@@ -225,6 +301,35 @@ export class ComponentHelper {
225
301
  * @returns {boolean} false when the page can not be detached.
226
302
  */
227
303
  protected detach(component: object): boolean;
304
+ /**
305
+ * This will remove the page roots from the document. They are
306
+ * removed directly so the data tracker cleanup does not run, and
307
+ * their parents are kept so they go back where they were.
308
+ *
309
+ * @protected
310
+ * @param {Array<object>} nodes
311
+ * @returns {void}
312
+ */
313
+ protected removeNodes(nodes: Array<object>): void;
314
+ /**
315
+ * This will hide the page roots where they are. Element roots are
316
+ * hidden; comment and text roots render nothing on their own.
317
+ *
318
+ * @protected
319
+ * @param {Array<object>} nodes
320
+ * @returns {void}
321
+ */
322
+ protected hideInPlace(nodes: Array<object>): void;
323
+ /**
324
+ * This will show the roots of a page hidden in place. A root that
325
+ * left the document while hidden goes into the route container.
326
+ *
327
+ * @protected
328
+ * @param {Array<object>} nodes
329
+ * @param {object} container
330
+ * @returns {void}
331
+ */
332
+ protected showInPlace(nodes: Array<object>, container: object): void;
228
333
  /**
229
334
  * This will re-insert a detached keep-alive page.
230
335
  *
@@ -54,6 +54,12 @@ export class PageCache {
54
54
  * @returns {boolean}
55
55
  */
56
56
  isEnabled(): boolean;
57
+ /**
58
+ * This will get the router default keep-alive mode.
59
+ *
60
+ * @returns {string} 'detach' or 'hide'
61
+ */
62
+ getMode(): string;
57
63
  /**
58
64
  * This will get the max detached pages.
59
65
  *
@@ -38,6 +38,7 @@ export class Route extends BasicData {
38
38
  title: any;
39
39
  preventScroll: any;
40
40
  scrollTo: any;
41
+ importSrc: any;
41
42
  /**
42
43
  * This will setup the route settings.
43
44
  *
@@ -62,6 +63,19 @@ export class Route extends BasicData {
62
63
  * @returns {void}
63
64
  */
64
65
  deactivate(destroy?: boolean): void;
66
+ /**
67
+ * This will read the page element scroll before a navigation
68
+ * changes the document (see ComponentHelper.captureScroll).
69
+ *
70
+ * @returns {void}
71
+ */
72
+ captureScroll(): void;
73
+ /**
74
+ * This will drop an unused captured page scroll.
75
+ *
76
+ * @returns {void}
77
+ */
78
+ releaseCapturedScroll(): void;
65
79
  /**
66
80
  * This will check if the route page is detached from the
67
81
  * document because it is kept alive, or because the route
@@ -120,6 +134,21 @@ export class Route extends BasicData {
120
134
  * @returns {object|boolean}
121
135
  */
122
136
  match(path: string): object | boolean;
137
+ /**
138
+ * This will check if the route matches the path without changing
139
+ * the route params, so it is safe to call on an active route.
140
+ *
141
+ * @param {string} path
142
+ * @returns {boolean}
143
+ */
144
+ matches(path: string): boolean;
145
+ /**
146
+ * This will start loading the route's imported page so it opens
147
+ * without waiting when the user navigates to it.
148
+ *
149
+ * @returns {Promise<unknown>|null}
150
+ */
151
+ prefetch(): Promise<unknown> | null;
123
152
  /**
124
153
  * Checks query/hash route conditions.
125
154
  *
package/package.json CHANGED
@@ -1,89 +1,89 @@
1
- {
2
- "name": "@base-framework/base",
3
- "version": "3.9.22",
4
- "description": "This is a javascript framework.",
5
- "main": "./dist/base.js",
6
- "module": "./dist/base.js",
7
- "type": "module",
8
- "sideEffects": [
9
- "**/default-directives.js",
10
- "./dist/base.js",
11
- "./dist/modules/*.js",
12
- "./dist/chunks/*.js"
13
- ],
14
- "scripts": {
15
- "build": "node ./esbuild.js && tsc",
16
- "prepublishOnly": "node ./esbuild.js",
17
- "test": "vitest",
18
- "test:run": "vitest run",
19
- "size": "node ./scripts/size-report.js",
20
- "size:check": "node ./scripts/size-report.js --check",
21
- "bench": "node --expose-gc ./scripts/bench.js"
22
- },
23
- "keywords": [
24
- "JavaScript",
25
- "Framework",
26
- "Base",
27
- "ES6"
28
- ],
29
- "author": "Chris Durfee",
30
- "license": "ISC",
31
- "repository": {
32
- "type": "git",
33
- "url": "git+https://github.com/chrisdurfee/base.git"
34
- },
35
- "bugs": {
36
- "url": "https://github.com/chrisdurfee/base/issues"
37
- },
38
- "devDependencies": {
39
- "esbuild": "^0.25.0",
40
- "jsdom": "^29.1.1",
41
- "typescript": "^5.7.3",
42
- "vitest": "^4.1.11"
43
- },
44
- "types": "dist/types/base.d.ts",
45
- "files": [
46
- "package.json",
47
- "readme.md",
48
- "dist",
49
- "copilot.md",
50
- "!dist/**/*.map"
51
- ],
52
- "exports": {
53
- "./package.json": "./package.json",
54
- ".": {
55
- "types": "./dist/types/base.d.ts",
56
- "import": "./dist/base.js",
57
- "require": "./dist/base.js"
58
- },
59
- "./component": {
60
- "types": "./dist/types/entries/component.d.ts",
61
- "import": "./dist/modules/component.js"
62
- },
63
- "./data": {
64
- "types": "./dist/types/entries/data.d.ts",
65
- "import": "./dist/modules/data.js"
66
- },
67
- "./router": {
68
- "types": "./dist/types/entries/router.d.ts",
69
- "import": "./dist/modules/router.js"
70
- },
71
- "./state": {
72
- "types": "./dist/types/entries/state.d.ts",
73
- "import": "./dist/modules/state.js"
74
- },
75
- "./ajax": {
76
- "types": "./dist/types/entries/ajax.d.ts",
77
- "import": "./dist/modules/ajax.js"
78
- },
79
- "./html": {
80
- "types": "./dist/types/entries/html.d.ts",
81
- "import": "./dist/modules/html.js"
82
- },
83
- "./date": {
84
- "types": "./dist/types/entries/date.d.ts",
85
- "import": "./dist/modules/date.js"
86
- }
87
- },
88
- "homepage": "https://github.com/chrisdurfee/base#readme"
89
- }
1
+ {
2
+ "name": "@base-framework/base",
3
+ "version": "3.9.24",
4
+ "description": "This is a javascript framework.",
5
+ "main": "./dist/base.js",
6
+ "module": "./dist/base.js",
7
+ "type": "module",
8
+ "sideEffects": [
9
+ "**/default-directives.js",
10
+ "./dist/base.js",
11
+ "./dist/modules/*.js",
12
+ "./dist/chunks/*.js"
13
+ ],
14
+ "scripts": {
15
+ "build": "node ./esbuild.js && tsc",
16
+ "prepublishOnly": "node ./esbuild.js",
17
+ "test": "vitest",
18
+ "test:run": "vitest run",
19
+ "size": "node ./scripts/size-report.js",
20
+ "size:check": "node ./scripts/size-report.js --check",
21
+ "bench": "node --expose-gc ./scripts/bench.js"
22
+ },
23
+ "keywords": [
24
+ "JavaScript",
25
+ "Framework",
26
+ "Base",
27
+ "ES6"
28
+ ],
29
+ "author": "Chris Durfee",
30
+ "license": "ISC",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/chrisdurfee/base.git"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/chrisdurfee/base/issues"
37
+ },
38
+ "devDependencies": {
39
+ "esbuild": "^0.25.0",
40
+ "jsdom": "^29.1.1",
41
+ "typescript": "^5.7.3",
42
+ "vitest": "^4.1.11"
43
+ },
44
+ "types": "dist/types/base.d.ts",
45
+ "files": [
46
+ "package.json",
47
+ "readme.md",
48
+ "dist",
49
+ "copilot.md",
50
+ "!dist/**/*.map"
51
+ ],
52
+ "exports": {
53
+ "./package.json": "./package.json",
54
+ ".": {
55
+ "types": "./dist/types/base.d.ts",
56
+ "import": "./dist/base.js",
57
+ "require": "./dist/base.js"
58
+ },
59
+ "./component": {
60
+ "types": "./dist/types/entries/component.d.ts",
61
+ "import": "./dist/modules/component.js"
62
+ },
63
+ "./data": {
64
+ "types": "./dist/types/entries/data.d.ts",
65
+ "import": "./dist/modules/data.js"
66
+ },
67
+ "./router": {
68
+ "types": "./dist/types/entries/router.d.ts",
69
+ "import": "./dist/modules/router.js"
70
+ },
71
+ "./state": {
72
+ "types": "./dist/types/entries/state.d.ts",
73
+ "import": "./dist/modules/state.js"
74
+ },
75
+ "./ajax": {
76
+ "types": "./dist/types/entries/ajax.d.ts",
77
+ "import": "./dist/modules/ajax.js"
78
+ },
79
+ "./html": {
80
+ "types": "./dist/types/entries/html.d.ts",
81
+ "import": "./dist/modules/html.js"
82
+ },
83
+ "./date": {
84
+ "types": "./dist/types/entries/date.d.ts",
85
+ "import": "./dist/modules/date.js"
86
+ }
87
+ },
88
+ "homepage": "https://github.com/chrisdurfee/base#readme"
89
+ }