crelte 0.1.1 → 0.1.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/dist/Crelte.d.ts +89 -25
- package/dist/Crelte.d.ts.map +1 -1
- package/dist/Crelte.js +79 -38
- package/dist/CrelteRequest.d.ts +63 -0
- package/dist/CrelteRequest.d.ts.map +1 -0
- package/dist/CrelteRequest.js +94 -0
- package/dist/blocks/Blocks.d.ts +27 -3
- package/dist/blocks/Blocks.d.ts.map +1 -1
- package/dist/blocks/Blocks.js +8 -0
- package/dist/blocks/Blocks.svelte +1 -1
- package/dist/blocks/Blocks.svelte.d.ts +36 -4
- package/dist/blocks/Blocks.svelte.d.ts.map +1 -1
- package/dist/blocks/index.d.ts +6 -3
- package/dist/blocks/index.d.ts.map +1 -1
- package/dist/blocks/index.js +3 -2
- package/dist/cookies/ServerCookies.d.ts +1 -1
- package/dist/cookies/ServerCookies.d.ts.map +1 -1
- package/dist/cookies/index.d.ts +7 -0
- package/dist/cookies/index.d.ts.map +1 -1
- package/dist/graphql/GraphQl.d.ts +53 -14
- package/dist/graphql/GraphQl.d.ts.map +1 -1
- package/dist/graphql/GraphQl.js +44 -23
- package/dist/graphql/index.d.ts +1 -1
- package/dist/graphql/index.d.ts.map +1 -1
- package/dist/graphql/index.js +2 -2
- package/dist/index.d.ts +55 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +50 -23
- package/dist/init/client.d.ts +43 -2
- package/dist/init/client.d.ts.map +1 -1
- package/dist/init/client.js +26 -6
- package/dist/init/server.d.ts +49 -2
- package/dist/init/server.d.ts.map +1 -1
- package/dist/init/server.js +56 -6
- package/dist/init/shared.d.ts +5 -4
- package/dist/init/shared.d.ts.map +1 -1
- package/dist/init/shared.js +3 -3
- package/dist/loadData/Globals.d.ts +41 -2
- package/dist/loadData/Globals.d.ts.map +1 -1
- package/dist/loadData/Globals.js +33 -5
- package/dist/loadData/index.d.ts +74 -11
- package/dist/loadData/index.d.ts.map +1 -1
- package/dist/loadData/index.js +5 -8
- package/dist/plugins/Events.d.ts +18 -5
- package/dist/plugins/Events.d.ts.map +1 -1
- package/dist/plugins/Events.js +3 -0
- package/dist/plugins/Plugins.d.ts +28 -2
- package/dist/plugins/Plugins.d.ts.map +1 -1
- package/dist/plugins/Plugins.js +8 -0
- package/dist/routing/History.d.ts +3 -0
- package/dist/routing/History.d.ts.map +1 -1
- package/dist/routing/History.js +6 -0
- package/dist/routing/InnerRouter.d.ts +10 -9
- package/dist/routing/InnerRouter.d.ts.map +1 -1
- package/dist/routing/InnerRouter.js +41 -33
- package/dist/routing/PageLoader.d.ts +5 -5
- package/dist/routing/PageLoader.d.ts.map +1 -1
- package/dist/routing/PageLoader.js +7 -7
- package/dist/routing/Request.d.ts +102 -0
- package/dist/routing/Request.d.ts.map +1 -0
- package/dist/routing/Request.js +128 -0
- package/dist/routing/Route.d.ts +73 -5
- package/dist/routing/Route.d.ts.map +1 -1
- package/dist/routing/Route.js +71 -6
- package/dist/routing/Router.d.ts +59 -52
- package/dist/routing/Router.d.ts.map +1 -1
- package/dist/routing/Router.js +92 -114
- package/dist/routing/Site.d.ts +1 -1
- package/dist/routing/Site.js +1 -1
- package/dist/routing/index.d.ts +4 -3
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +2 -1
- package/dist/ssr/SsrCache.d.ts +17 -0
- package/dist/ssr/SsrCache.d.ts.map +1 -1
- package/dist/ssr/SsrCache.js +17 -4
- package/dist/ssr/SsrComponents.d.ts +1 -0
- package/dist/ssr/SsrComponents.d.ts.map +1 -1
- package/dist/ssr/SsrComponents.js +1 -0
- package/package.json +6 -6
- package/src/Crelte.ts +124 -52
- package/src/CrelteRequest.ts +124 -0
- package/src/blocks/Blocks.svelte +35 -18
- package/src/blocks/Blocks.ts +38 -6
- package/src/blocks/index.ts +19 -10
- package/src/cookies/ServerCookies.ts +1 -1
- package/src/cookies/index.ts +7 -1
- package/src/graphql/GraphQl.ts +79 -27
- package/src/graphql/index.ts +7 -1
- package/src/index.ts +65 -29
- package/src/init/client.ts +55 -10
- package/src/init/server.ts +70 -10
- package/src/init/shared.ts +8 -7
- package/src/loadData/Globals.ts +43 -7
- package/src/loadData/index.ts +76 -13
- package/src/plugins/Events.ts +16 -5
- package/src/plugins/Plugins.ts +28 -2
- package/src/routing/History.ts +9 -0
- package/src/routing/InnerRouter.ts +47 -37
- package/src/routing/PageLoader.ts +10 -10
- package/src/routing/Request.ts +175 -0
- package/src/routing/Route.ts +73 -8
- package/src/routing/Router.ts +103 -159
- package/src/routing/Site.ts +1 -1
- package/src/routing/index.ts +12 -3
- package/src/ssr/SsrCache.ts +17 -4
- package/src/ssr/SsrComponents.ts +1 -0
- package/dist/CrelteBase.d.ts +0 -16
- package/dist/CrelteBase.d.ts.map +0 -1
- package/dist/CrelteBase.js +0 -1
- package/dist/CrelteRouted.d.ts +0 -50
- package/dist/CrelteRouted.d.ts.map +0 -1
- package/dist/CrelteRouted.js +0 -88
- package/src/CrelteBase.ts +0 -24
- package/src/CrelteRouted.ts +0 -128
|
@@ -1,11 +1,37 @@
|
|
|
1
|
-
import
|
|
1
|
+
import CrelteCore from '../Crelte.js';
|
|
2
|
+
/**
|
|
3
|
+
* A plugin
|
|
4
|
+
*/
|
|
2
5
|
export interface Plugin {
|
|
3
6
|
name: string;
|
|
4
7
|
}
|
|
5
|
-
|
|
8
|
+
/**
|
|
9
|
+
* A plugin create function
|
|
10
|
+
*
|
|
11
|
+
* Each plugin needs to export a createPluginname function which will be called
|
|
12
|
+
* by crelte to create the plugin. If youre plugin has options you can create
|
|
13
|
+
* a configurePluginname function which will be called by youre user and should
|
|
14
|
+
* return a createPlugin function.
|
|
15
|
+
*
|
|
16
|
+
* ## Example App.svelte in module="context"
|
|
17
|
+
* ```
|
|
18
|
+
* import { createPlugin, configurePlugin } from 'some-plugin';
|
|
19
|
+
*
|
|
20
|
+
* export plugins = [createPlugin, configurePlugin({ enableFeature: true })];
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export type PluginCreator = (crelte: CrelteCore) => Plugin;
|
|
24
|
+
/**
|
|
25
|
+
* A plugin manager
|
|
26
|
+
*/
|
|
6
27
|
export default class Plugins {
|
|
7
28
|
plugins: Map<string, Plugin>;
|
|
8
29
|
constructor();
|
|
30
|
+
/**
|
|
31
|
+
* @hidden
|
|
32
|
+
*
|
|
33
|
+
* Plugins should be added via App.svelte plugins export
|
|
34
|
+
*/
|
|
9
35
|
add(plugin: Plugin): void;
|
|
10
36
|
get(name: string): Plugin | null;
|
|
11
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugins.d.ts","sourceRoot":"","sources":["../../../../src/plugins/Plugins.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Plugins.d.ts","sourceRoot":"","sources":["../../../../src/plugins/Plugins.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,MAAM;IACtB,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,MAAM,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,OAAO;IAC3B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;;IAM7B;;;;OAIG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM;IAIlB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAGhC"}
|
package/dist/plugins/Plugins.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A plugin manager
|
|
3
|
+
*/
|
|
1
4
|
export default class Plugins {
|
|
2
5
|
plugins;
|
|
3
6
|
constructor() {
|
|
4
7
|
this.plugins = new Map();
|
|
5
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* @hidden
|
|
11
|
+
*
|
|
12
|
+
* Plugins should be added via App.svelte plugins export
|
|
13
|
+
*/
|
|
6
14
|
add(plugin) {
|
|
7
15
|
this.plugins.set(plugin.name, plugin);
|
|
8
16
|
}
|
|
@@ -3,12 +3,14 @@ export default interface History {
|
|
|
3
3
|
replaceState(data: any, url?: string): void;
|
|
4
4
|
pushState(data: any, url: string): void;
|
|
5
5
|
open(url: string): void;
|
|
6
|
+
back(): void;
|
|
6
7
|
}
|
|
7
8
|
export declare class ClientHistory implements History {
|
|
8
9
|
scrollY(): number | null;
|
|
9
10
|
replaceState(data: any, url?: string): void;
|
|
10
11
|
pushState(data: any, url: string): void;
|
|
11
12
|
open(url: string): void;
|
|
13
|
+
back(): void;
|
|
12
14
|
}
|
|
13
15
|
export declare class ServerHistory implements History {
|
|
14
16
|
state: any | null;
|
|
@@ -18,5 +20,6 @@ export declare class ServerHistory implements History {
|
|
|
18
20
|
replaceState(data: any, url?: string): void;
|
|
19
21
|
pushState(data: any, url: string): void;
|
|
20
22
|
open(url: string): void;
|
|
23
|
+
back(): void;
|
|
21
24
|
}
|
|
22
25
|
//# sourceMappingURL=History.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"History.d.ts","sourceRoot":"","sources":["../../../../src/routing/History.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,WAAW,OAAO;IAC/B,OAAO,IAAI,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"History.d.ts","sourceRoot":"","sources":["../../../../src/routing/History.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,WAAW,OAAO;IAC/B,OAAO,IAAI,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,IAAI,IAAI,CAAC;CACb;AAED,qBAAa,aAAc,YAAW,OAAO;IAC5C,OAAO,IAAI,MAAM,GAAG,IAAI;IAIxB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;IAI3C,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAIvC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIvB,IAAI,IAAI,IAAI;CAGZ;AAED,qBAAa,aAAc,YAAW,OAAO;IAC5C,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;IAClB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;;IAOnB,OAAO,IAAI,MAAM,GAAG,IAAI;IAIxB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;IAK3C,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAKvC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIvB,IAAI,IAAI,IAAI;CAGZ"}
|
package/dist/routing/History.js
CHANGED
|
@@ -11,6 +11,9 @@ export class ClientHistory {
|
|
|
11
11
|
open(url) {
|
|
12
12
|
window.location.href = url;
|
|
13
13
|
}
|
|
14
|
+
back() {
|
|
15
|
+
window.history.back();
|
|
16
|
+
}
|
|
14
17
|
}
|
|
15
18
|
export class ServerHistory {
|
|
16
19
|
state;
|
|
@@ -33,4 +36,7 @@ export class ServerHistory {
|
|
|
33
36
|
open(url) {
|
|
34
37
|
this.url = url;
|
|
35
38
|
}
|
|
39
|
+
back() {
|
|
40
|
+
throw new Error('Cannot go back on the server');
|
|
41
|
+
}
|
|
36
42
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import Route from './Route.js';
|
|
2
1
|
import Site, { SiteFromGraphQl } from './Site.js';
|
|
3
2
|
import History from './History.js';
|
|
3
|
+
import Request from './Request.js';
|
|
4
|
+
import Route from './Route.js';
|
|
4
5
|
export type InnerRouterOpts = {
|
|
5
6
|
preloadOnMouseOver: boolean;
|
|
6
7
|
};
|
|
@@ -17,8 +18,8 @@ export default class InnerRouter {
|
|
|
17
18
|
* @param changeHistory returns a function you need to call when you are ready to
|
|
18
19
|
update the window history (note do not call this after another onRoute call was made)
|
|
19
20
|
*/
|
|
20
|
-
onRoute: (route:
|
|
21
|
-
onPreload: (route:
|
|
21
|
+
onRoute: (route: Request, site: Site, changeHistory: () => void) => void;
|
|
22
|
+
onPreload: (route: Request, site: Site) => void;
|
|
22
23
|
private scrollDebounceTimeout;
|
|
23
24
|
/**
|
|
24
25
|
* Creates a new Router
|
|
@@ -56,7 +57,7 @@ export default class InnerRouter {
|
|
|
56
57
|
* @param target
|
|
57
58
|
* @return Returns null if the url does not match our host (the protocol get's ignored)
|
|
58
59
|
*/
|
|
59
|
-
|
|
60
|
+
targetToRequest(target: string | URL | Route | Request): Request;
|
|
60
61
|
/**
|
|
61
62
|
* Resolve a url and convert it to a Route
|
|
62
63
|
*
|
|
@@ -71,16 +72,16 @@ export default class InnerRouter {
|
|
|
71
72
|
* @param route a route object or an url or uri, never input the same route object again
|
|
72
73
|
* @param pushState if true pushed the state to the window.history
|
|
73
74
|
*/
|
|
74
|
-
open(target: string | URL | Route, pushState?: boolean): void;
|
|
75
|
+
open(target: string | URL | Route | Request, pushState?: boolean): void;
|
|
75
76
|
/**
|
|
76
77
|
* Sets a route
|
|
77
78
|
*
|
|
78
79
|
* Will trigger an onRoute event but will not store any scroll progress
|
|
79
80
|
* or modify the history
|
|
80
81
|
*
|
|
81
|
-
* @param
|
|
82
|
+
* @param req
|
|
82
83
|
*/
|
|
83
|
-
setRoute(
|
|
84
|
+
setRoute(req: Request): void;
|
|
84
85
|
/**
|
|
85
86
|
* This pushes the state of the route without triggering a currentRoute
|
|
86
87
|
* or currentSiteId change
|
|
@@ -105,7 +106,7 @@ export default class InnerRouter {
|
|
|
105
106
|
*
|
|
106
107
|
* @param url
|
|
107
108
|
*/
|
|
108
|
-
preload(target: string | URL | Route): void;
|
|
109
|
-
domReady(
|
|
109
|
+
preload(target: string | URL | Route | Request): void;
|
|
110
|
+
domReady(req: Request): void;
|
|
110
111
|
}
|
|
111
112
|
//# sourceMappingURL=InnerRouter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InnerRouter.d.ts","sourceRoot":"","sources":["../../../../src/routing/InnerRouter.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"InnerRouter.d.ts","sourceRoot":"","sources":["../../../../src/routing/InnerRouter.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,OAAsB,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,MAAM,YAAY,CAAC;AAE/B,MAAM,MAAM,eAAe,GAAG;IAC7B,kBAAkB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAW;IAC/B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IACzE,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAEhD,OAAO,CAAC,qBAAqB,CAAa;IAE1C;;;;;OAKG;gBACS,KAAK,EAAE,eAAe,EAAE,EAAE,IAAI,EAAE,eAAe;IAmB3D;;OAEG;IACH,UAAU;IAkBV;;OAEG;IACH,UAAU;IAEV;;;;;OAKG;IACH,gBAAgB,CAAC,UAAU,GAAE,MAAM,GAAG,IAAW,GAAG,IAAI;IAsCxD;;OAEG;IACH,WAAW,IAAI,IAAI;IAInB;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAIjC;;;;;OAKG;IACH,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO;IAqBhE;;;;;OAKG;IACH,YAAY,CAAC,OAAO,EAAE,GAAG,GAAG,KAAK;IA8BjC,MAAM;IA0FN;;;;;OAKG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,GAAG,KAAK,GAAG,OAAO,EAAE,SAAS,GAAE,OAAc;IAyCtE;;;;;;;OAOG;IACH,QAAQ,CAAC,GAAG,EAAE,OAAO;IAOrB;;;;;;;;OAQG;IACH,SAAS,CAAC,KAAK,EAAE,KAAK;IAYtB;;;;;OAKG;IACH,YAAY,CAAC,KAAK,EAAE,KAAK;IAYzB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,GAAG,KAAK,GAAG,OAAO;IAoB9C,QAAQ,CAAC,GAAG,EAAE,OAAO;CAkErB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import Route from './Route.js';
|
|
2
1
|
import Site from './Site.js';
|
|
3
2
|
import { ClientHistory, ServerHistory } from './History.js';
|
|
3
|
+
import Request, { isRequest } from './Request.js';
|
|
4
|
+
import Route from './Route.js';
|
|
4
5
|
/**
|
|
5
6
|
* Manages event listeners or functions.
|
|
6
7
|
*/
|
|
@@ -43,7 +44,7 @@ export default class InnerRouter {
|
|
|
43
44
|
initClient() {
|
|
44
45
|
this.listen();
|
|
45
46
|
// let's first try to load from the state
|
|
46
|
-
const route = this.
|
|
47
|
+
const route = this.targetToRequest(window.location.href);
|
|
47
48
|
route._fillFromState(window.history.state);
|
|
48
49
|
route.origin = 'init';
|
|
49
50
|
if (route.search.get('x-craft-live-preview')) {
|
|
@@ -115,7 +116,7 @@ export default class InnerRouter {
|
|
|
115
116
|
* @param target
|
|
116
117
|
* @return Returns null if the url does not match our host (the protocol get's ignored)
|
|
117
118
|
*/
|
|
118
|
-
|
|
119
|
+
targetToRequest(target) {
|
|
119
120
|
if (typeof target === 'string') {
|
|
120
121
|
if (target.startsWith('/')) {
|
|
121
122
|
const site = this.site;
|
|
@@ -126,7 +127,10 @@ export default class InnerRouter {
|
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
if (target instanceof URL) {
|
|
129
|
-
|
|
130
|
+
target = this.routeFromUrl(target);
|
|
131
|
+
}
|
|
132
|
+
if (!isRequest(target)) {
|
|
133
|
+
return Request.fromRoute(target);
|
|
130
134
|
}
|
|
131
135
|
return target;
|
|
132
136
|
}
|
|
@@ -228,7 +232,7 @@ export default class InnerRouter {
|
|
|
228
232
|
window.addEventListener('popstate', async (e) => {
|
|
229
233
|
if (!('route' in e.state))
|
|
230
234
|
return;
|
|
231
|
-
const route = this.
|
|
235
|
+
const route = this.targetToRequest(window.location.href);
|
|
232
236
|
route._fillFromState(e.state);
|
|
233
237
|
route.origin = 'pop';
|
|
234
238
|
// since the pop event replaced our state we can't replace the state
|
|
@@ -245,10 +249,10 @@ export default class InnerRouter {
|
|
|
245
249
|
* @param pushState if true pushed the state to the window.history
|
|
246
250
|
*/
|
|
247
251
|
open(target, pushState = true) {
|
|
248
|
-
const
|
|
252
|
+
const req = this.targetToRequest(target);
|
|
249
253
|
const current = this.route;
|
|
250
254
|
if (current) {
|
|
251
|
-
// if the scrollY
|
|
255
|
+
// if the scrollY would still be updated we clear the timeout
|
|
252
256
|
// since we should have the latest scrollY
|
|
253
257
|
if (this.scrollDebounceTimeout) {
|
|
254
258
|
clearTimeout(this.scrollDebounceTimeout);
|
|
@@ -263,19 +267,20 @@ export default class InnerRouter {
|
|
|
263
267
|
}
|
|
264
268
|
// if the domain of the current site is different than the domain of the
|
|
265
269
|
// new site we need to do a window.location.href call
|
|
266
|
-
if ((current && current.url.origin !==
|
|
270
|
+
if ((current && current.url.origin !== req.url.origin) ||
|
|
271
|
+
// @ts-ignore
|
|
267
272
|
import.meta.env.SSR) {
|
|
268
|
-
this.history.open(
|
|
273
|
+
this.history.open(req.url.href);
|
|
269
274
|
return;
|
|
270
275
|
}
|
|
271
276
|
if (pushState) {
|
|
272
|
-
|
|
273
|
-
this.onRoute(
|
|
274
|
-
this.pushState(
|
|
277
|
+
req.index = (current?.index ?? 0) + 1;
|
|
278
|
+
this.onRoute(req, req.site ?? this.site, () => {
|
|
279
|
+
this.pushState(req.toRoute());
|
|
275
280
|
});
|
|
276
281
|
}
|
|
277
282
|
else {
|
|
278
|
-
this.setRoute(
|
|
283
|
+
this.setRoute(req);
|
|
279
284
|
}
|
|
280
285
|
}
|
|
281
286
|
/**
|
|
@@ -284,13 +289,13 @@ export default class InnerRouter {
|
|
|
284
289
|
* Will trigger an onRoute event but will not store any scroll progress
|
|
285
290
|
* or modify the history
|
|
286
291
|
*
|
|
287
|
-
* @param
|
|
292
|
+
* @param req
|
|
288
293
|
*/
|
|
289
|
-
setRoute(
|
|
290
|
-
this.route =
|
|
291
|
-
if (
|
|
292
|
-
this.site =
|
|
293
|
-
this.onRoute(
|
|
294
|
+
setRoute(req) {
|
|
295
|
+
this.route = req.toRoute();
|
|
296
|
+
if (req.site)
|
|
297
|
+
this.site = req.site;
|
|
298
|
+
this.onRoute(req, this.site, () => { });
|
|
294
299
|
}
|
|
295
300
|
/**
|
|
296
301
|
* This pushes the state of the route without triggering a currentRoute
|
|
@@ -329,26 +334,29 @@ export default class InnerRouter {
|
|
|
329
334
|
* @param url
|
|
330
335
|
*/
|
|
331
336
|
preload(target) {
|
|
332
|
-
const
|
|
337
|
+
const req = this.targetToRequest(target);
|
|
338
|
+
// todo, don't think this makes any sense
|
|
333
339
|
// if the domain of the current site is different than the domain of the
|
|
334
340
|
// new site id does not make sense to preload
|
|
335
|
-
if (this.site.url.origin !==
|
|
341
|
+
if (this.site.url.origin !== req.url.origin) {
|
|
336
342
|
return;
|
|
337
343
|
}
|
|
338
344
|
const current = this.route;
|
|
339
|
-
const site =
|
|
345
|
+
const site = req.site ?? this.site;
|
|
340
346
|
// if the origin matches, the route will be able to be load
|
|
341
347
|
// so let's preload it
|
|
342
|
-
if (current && current.url.origin ===
|
|
343
|
-
this.onPreload(
|
|
348
|
+
if (current && current.url.origin === req.url.origin) {
|
|
349
|
+
this.onPreload(req, site);
|
|
344
350
|
}
|
|
345
351
|
}
|
|
346
|
-
domReady(
|
|
352
|
+
domReady(req) {
|
|
353
|
+
if (req.disableScroll)
|
|
354
|
+
return;
|
|
347
355
|
// scroll to target
|
|
348
356
|
let scrollTo = null;
|
|
349
357
|
// if the route is a live preview init and we have a scrollY stored
|
|
350
358
|
// scroll to that
|
|
351
|
-
if (
|
|
359
|
+
if (req.origin === 'live-preview-init') {
|
|
352
360
|
const scrollY = sessionStorage.getItem('live-preview-scroll');
|
|
353
361
|
if (scrollY) {
|
|
354
362
|
scrollTo = {
|
|
@@ -358,10 +366,10 @@ export default class InnerRouter {
|
|
|
358
366
|
}
|
|
359
367
|
// if we have a hash and the route was not visited
|
|
360
368
|
}
|
|
361
|
-
else if (
|
|
362
|
-
((
|
|
363
|
-
|
|
364
|
-
const el = document.getElementById(
|
|
369
|
+
else if (req.hash &&
|
|
370
|
+
((req.origin === 'init' && typeof req.scrollY !== 'number') ||
|
|
371
|
+
req.origin === 'click')) {
|
|
372
|
+
const el = document.getElementById(req.hash.substring(1));
|
|
365
373
|
if (el) {
|
|
366
374
|
scrollTo = {
|
|
367
375
|
intoView: el,
|
|
@@ -371,10 +379,10 @@ export default class InnerRouter {
|
|
|
371
379
|
}
|
|
372
380
|
// restore scroll position
|
|
373
381
|
if (!scrollTo &&
|
|
374
|
-
|
|
375
|
-
typeof
|
|
382
|
+
req.origin !== 'click' &&
|
|
383
|
+
typeof req.scrollY === 'number') {
|
|
376
384
|
scrollTo = {
|
|
377
|
-
top:
|
|
385
|
+
top: req.scrollY,
|
|
378
386
|
behavior: 'instant',
|
|
379
387
|
};
|
|
380
388
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Request from './Request.js';
|
|
2
2
|
import Site from './Site.js';
|
|
3
3
|
export type PageLoaderOptions = {
|
|
4
4
|
debugTiming: boolean;
|
|
@@ -7,7 +7,7 @@ export type LoadResponse = {
|
|
|
7
7
|
success: boolean;
|
|
8
8
|
data: any;
|
|
9
9
|
};
|
|
10
|
-
export type LoadFn = (
|
|
10
|
+
export type LoadFn = (req: Request, site: Site, opts: LoadOptions) => Promise<any> | any;
|
|
11
11
|
export type LoadOptions = {
|
|
12
12
|
setProgress: (num: number) => void;
|
|
13
13
|
};
|
|
@@ -18,7 +18,7 @@ export default class PageLoader<More> {
|
|
|
18
18
|
private debugTiming;
|
|
19
19
|
private preloadedUrls;
|
|
20
20
|
private loadingVersion;
|
|
21
|
-
onLoaded: (resp: LoadResponse,
|
|
21
|
+
onLoaded: (resp: LoadResponse, req: Request, site: Site, more: More) => void;
|
|
22
22
|
onProgress: (loading: boolean, progress?: number) => void;
|
|
23
23
|
loadFn: LoadFn;
|
|
24
24
|
/**
|
|
@@ -31,7 +31,7 @@ export default class PageLoader<More> {
|
|
|
31
31
|
* Discard the current page load if one is happening
|
|
32
32
|
*/
|
|
33
33
|
discard(): void;
|
|
34
|
-
load(
|
|
35
|
-
preload(
|
|
34
|
+
load(req: Request, site: Site, more: More): Promise<void>;
|
|
35
|
+
preload(req: Request, site: Site): Promise<void>;
|
|
36
36
|
}
|
|
37
37
|
//# sourceMappingURL=PageLoader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageLoader.d.ts","sourceRoot":"","sources":["../../../../src/routing/PageLoader.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"PageLoader.d.ts","sourceRoot":"","sources":["../../../../src/routing/PageLoader.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,MAAM,iBAAiB,GAAG;IAC/B,WAAW,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,GAAG,CAAC;CACV,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,CACpB,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,WAAW,KACb,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AAExB,MAAM,MAAM,WAAW,GAAG;IACzB,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU,CAAC,IAAI;IACnC,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,aAAa,CAAc;IAEnC,OAAO,CAAC,cAAc,CAAS;IAE/B,QAAQ,EAAE,CACT,IAAI,EAAE,YAAY,EAClB,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,KACN,IAAI,CAAC;IACV,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1D,MAAM,EAAE,MAAM,CAAC;IAEf;;;;OAIG;gBACS,OAAO,EAAE,iBAAiB;IAWtC;;OAEG;IACH,OAAO;IAKD,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAiCzC,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI;CActC"}
|
|
@@ -28,7 +28,7 @@ export default class PageLoader {
|
|
|
28
28
|
this.loadingVersion++;
|
|
29
29
|
this.onProgress(false);
|
|
30
30
|
}
|
|
31
|
-
async load(
|
|
31
|
+
async load(req, site, more) {
|
|
32
32
|
this.onProgress(true);
|
|
33
33
|
const version = ++this.loadingVersion;
|
|
34
34
|
const startTime = this.debugTiming ? Date.now() : null;
|
|
@@ -39,7 +39,7 @@ export default class PageLoader {
|
|
|
39
39
|
};
|
|
40
40
|
const resp = { success: false, data: null };
|
|
41
41
|
try {
|
|
42
|
-
resp.data = await this.loadFn(
|
|
42
|
+
resp.data = await this.loadFn(req, site, { setProgress });
|
|
43
43
|
resp.success = true;
|
|
44
44
|
}
|
|
45
45
|
catch (e) {
|
|
@@ -52,18 +52,18 @@ export default class PageLoader {
|
|
|
52
52
|
if (this.loadingVersion !== version)
|
|
53
53
|
return console.log('route changed quickly, ignoring response');
|
|
54
54
|
this.onProgress(false);
|
|
55
|
-
this.onLoaded(resp,
|
|
55
|
+
this.onLoaded(resp, req, site, more);
|
|
56
56
|
}
|
|
57
57
|
// you don't need to wait on this call
|
|
58
|
-
async preload(
|
|
59
|
-
const url =
|
|
58
|
+
async preload(req, site) {
|
|
59
|
+
const url = req.url.origin + req.url.pathname;
|
|
60
60
|
if (this.preloadedUrls.has(url))
|
|
61
61
|
return;
|
|
62
62
|
this.preloadedUrls.add(url);
|
|
63
63
|
try {
|
|
64
|
-
await this.loadFn(
|
|
64
|
+
await this.loadFn(req, site, { setProgress: () => null });
|
|
65
65
|
}
|
|
66
|
-
catch (
|
|
66
|
+
catch (_e) {
|
|
67
67
|
console.log('preload failed');
|
|
68
68
|
// retry at another time
|
|
69
69
|
this.preloadedUrls.delete(url);
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Barrier } from 'crelte-std/sync';
|
|
2
|
+
import Route, { RouteOrigin } from './Route.js';
|
|
3
|
+
import Site from './Site.js';
|
|
4
|
+
/**
|
|
5
|
+
* Options to create a Request
|
|
6
|
+
*/
|
|
7
|
+
export type RequestOptions = {
|
|
8
|
+
scrollY?: number;
|
|
9
|
+
index?: number;
|
|
10
|
+
origin?: RouteOrigin;
|
|
11
|
+
disableScroll?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A Request is a Route with some extra options
|
|
15
|
+
* you get a Request from the onRequest event or
|
|
16
|
+
* in a loadGlobal function.
|
|
17
|
+
*/
|
|
18
|
+
export default class Request extends Route {
|
|
19
|
+
/**
|
|
20
|
+
* Disable scrolling for this request
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
disableScroll: boolean;
|
|
24
|
+
/** @hidden */
|
|
25
|
+
_renderBarrier: RenderBarrier;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new Request
|
|
28
|
+
*/
|
|
29
|
+
constructor(url: string | URL, site: Site | null, opts?: RequestOptions);
|
|
30
|
+
/**
|
|
31
|
+
* Create a Request from a Route
|
|
32
|
+
*/
|
|
33
|
+
static fromRoute(route: Route): Request;
|
|
34
|
+
/**
|
|
35
|
+
* With delayRender you can make sure that the render waits
|
|
36
|
+
* until you are ready. This is useful for building page transitions.
|
|
37
|
+
*
|
|
38
|
+
* ## Important
|
|
39
|
+
* If you call delayRender you need to call `ready/remove` or the render
|
|
40
|
+
* will never happen
|
|
41
|
+
*
|
|
42
|
+
* ## Example
|
|
43
|
+
* ```
|
|
44
|
+
* import { onRequest } from 'crelte';
|
|
45
|
+
* import { animate } from 'motion';
|
|
46
|
+
*
|
|
47
|
+
* onRequest(async req => {
|
|
48
|
+
* if (req.origin !== 'click' && req.origin !== 'manual') return;
|
|
49
|
+
*
|
|
50
|
+
* const delay = req.delayRender();
|
|
51
|
+
*
|
|
52
|
+
* await animate(plane, { x: '0%' });
|
|
53
|
+
*
|
|
54
|
+
* // wait until the new page is ready to be rendered
|
|
55
|
+
* // if the render was cancelled we return
|
|
56
|
+
* if (await delay.ready()) return;
|
|
57
|
+
*
|
|
58
|
+
* await animate(plane, { x: '100%' });
|
|
59
|
+
* });
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
delayRender(): DelayRender;
|
|
63
|
+
/**
|
|
64
|
+
* Create a copy of the request
|
|
65
|
+
*/
|
|
66
|
+
clone(): Request;
|
|
67
|
+
/**
|
|
68
|
+
* Create a Route from the Request
|
|
69
|
+
*/
|
|
70
|
+
toRoute(): Route;
|
|
71
|
+
}
|
|
72
|
+
export declare function isRequest(req: any): req is Request;
|
|
73
|
+
declare class RenderBarrier {
|
|
74
|
+
inner: Barrier<unknown>;
|
|
75
|
+
cancelled: boolean;
|
|
76
|
+
root: DelayRender;
|
|
77
|
+
constructor();
|
|
78
|
+
isOpen(): boolean;
|
|
79
|
+
add(): DelayRender;
|
|
80
|
+
/** @hidden */
|
|
81
|
+
cancel(): void;
|
|
82
|
+
/** @hidden */
|
|
83
|
+
ready(): Promise<boolean>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* DelayRender is returned by `Request.delayRender`
|
|
87
|
+
*/
|
|
88
|
+
export type DelayRender = {
|
|
89
|
+
/**
|
|
90
|
+
* Call this when you're ready for the render to happen
|
|
91
|
+
* the promise will resolve when the render is done or was cancelled
|
|
92
|
+
*
|
|
93
|
+
* @returns if the render was cancelled
|
|
94
|
+
*/
|
|
95
|
+
ready: () => Promise<boolean>;
|
|
96
|
+
/**
|
|
97
|
+
* If youre not interested when the render happens anymore
|
|
98
|
+
*/
|
|
99
|
+
remove: () => void;
|
|
100
|
+
};
|
|
101
|
+
export {};
|
|
102
|
+
//# sourceMappingURL=Request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Request.d.ts","sourceRoot":"","sources":["../../../../src/routing/Request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,KAAK;IACzC;;;OAGG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB,cAAc;IACd,cAAc,EAAE,aAAa,CAAC;IAE9B;;OAEG;gBAEF,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,EAAE,IAAI,GAAG,IAAI,EACjB,IAAI,GAAE,cAAmB;IAQ1B;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK;IAQ7B;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,WAAW,IAAI,WAAW;IAI1B;;OAEG;IACH,KAAK;IASL;;OAEG;IACH,OAAO;CAOP;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,OAAO,CAElD;AAED,cAAM,aAAa;IAClB,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,WAAW,CAAC;;IAQlB,MAAM,IAAI,OAAO;IAIjB,GAAG,IAAI,WAAW;IAclB,cAAc;IACd,MAAM;IAQN,cAAc;IACd,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;CAGzB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACzB;;;;;OAKG;IACH,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAE9B;;OAEG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Barrier } from 'crelte-std/sync';
|
|
2
|
+
import Route from './Route.js';
|
|
3
|
+
/**
|
|
4
|
+
* A Request is a Route with some extra options
|
|
5
|
+
* you get a Request from the onRequest event or
|
|
6
|
+
* in a loadGlobal function.
|
|
7
|
+
*/
|
|
8
|
+
export default class Request extends Route {
|
|
9
|
+
/**
|
|
10
|
+
* Disable scrolling for this request
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
disableScroll;
|
|
14
|
+
/** @hidden */
|
|
15
|
+
_renderBarrier;
|
|
16
|
+
/**
|
|
17
|
+
* Create a new Request
|
|
18
|
+
*/
|
|
19
|
+
constructor(url, site, opts = {}) {
|
|
20
|
+
super(url, site, opts);
|
|
21
|
+
this.disableScroll = opts.disableScroll ?? false;
|
|
22
|
+
this._renderBarrier = new RenderBarrier();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create a Request from a Route
|
|
26
|
+
*/
|
|
27
|
+
static fromRoute(route) {
|
|
28
|
+
return new Request(route.url.href, route.site, {
|
|
29
|
+
scrollY: route.scrollY ?? undefined,
|
|
30
|
+
index: route.index,
|
|
31
|
+
origin: route.origin,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* With delayRender you can make sure that the render waits
|
|
36
|
+
* until you are ready. This is useful for building page transitions.
|
|
37
|
+
*
|
|
38
|
+
* ## Important
|
|
39
|
+
* If you call delayRender you need to call `ready/remove` or the render
|
|
40
|
+
* will never happen
|
|
41
|
+
*
|
|
42
|
+
* ## Example
|
|
43
|
+
* ```
|
|
44
|
+
* import { onRequest } from 'crelte';
|
|
45
|
+
* import { animate } from 'motion';
|
|
46
|
+
*
|
|
47
|
+
* onRequest(async req => {
|
|
48
|
+
* if (req.origin !== 'click' && req.origin !== 'manual') return;
|
|
49
|
+
*
|
|
50
|
+
* const delay = req.delayRender();
|
|
51
|
+
*
|
|
52
|
+
* await animate(plane, { x: '0%' });
|
|
53
|
+
*
|
|
54
|
+
* // wait until the new page is ready to be rendered
|
|
55
|
+
* // if the render was cancelled we return
|
|
56
|
+
* if (await delay.ready()) return;
|
|
57
|
+
*
|
|
58
|
+
* await animate(plane, { x: '100%' });
|
|
59
|
+
* });
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
delayRender() {
|
|
63
|
+
return this._renderBarrier.add();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create a copy of the request
|
|
67
|
+
*/
|
|
68
|
+
clone() {
|
|
69
|
+
return new Request(this.url.href, this.site, {
|
|
70
|
+
scrollY: this.scrollY ?? undefined,
|
|
71
|
+
index: this.index,
|
|
72
|
+
origin: this.origin,
|
|
73
|
+
disableScroll: this.disableScroll,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create a Route from the Request
|
|
78
|
+
*/
|
|
79
|
+
toRoute() {
|
|
80
|
+
return new Route(this.url.href, this.site, {
|
|
81
|
+
scrollY: this.scrollY ?? undefined,
|
|
82
|
+
index: this.index,
|
|
83
|
+
origin: this.origin,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export function isRequest(req) {
|
|
88
|
+
return typeof req === 'object' && req !== null && req instanceof Request;
|
|
89
|
+
}
|
|
90
|
+
class RenderBarrier {
|
|
91
|
+
inner;
|
|
92
|
+
cancelled;
|
|
93
|
+
root;
|
|
94
|
+
constructor() {
|
|
95
|
+
this.inner = new Barrier();
|
|
96
|
+
this.cancelled = false;
|
|
97
|
+
this.root = this.add();
|
|
98
|
+
}
|
|
99
|
+
isOpen() {
|
|
100
|
+
return this.inner.isOpen();
|
|
101
|
+
}
|
|
102
|
+
add() {
|
|
103
|
+
const action = this.inner.add();
|
|
104
|
+
return {
|
|
105
|
+
ready: async () => {
|
|
106
|
+
if (!this.inner.isOpen())
|
|
107
|
+
await action.ready(null);
|
|
108
|
+
return this.cancelled;
|
|
109
|
+
},
|
|
110
|
+
remove: () => {
|
|
111
|
+
if (!this.inner.isOpen())
|
|
112
|
+
action.remove();
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/** @hidden */
|
|
117
|
+
cancel() {
|
|
118
|
+
if (this.inner.isOpen())
|
|
119
|
+
return;
|
|
120
|
+
this.cancelled = true;
|
|
121
|
+
this.root.remove();
|
|
122
|
+
}
|
|
123
|
+
// returns if the render was cancelled
|
|
124
|
+
/** @hidden */
|
|
125
|
+
ready() {
|
|
126
|
+
return this.root.ready();
|
|
127
|
+
}
|
|
128
|
+
}
|