crelte 0.5.0-alpha.8 → 0.5.0-beta.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/blocks/Blocks.svelte +1 -1
- package/dist/blocks/Blocks.svelte.d.ts +1 -1
- package/dist/blocks/Blocks.svelte.d.ts.map +1 -1
- package/dist/cookies/ClientCookies.d.ts +2 -2
- package/dist/cookies/ClientCookies.d.ts.map +1 -1
- package/dist/cookies/ClientCookies.js +3 -3
- package/dist/cookies/ServerCookies.d.ts +2 -2
- package/dist/cookies/ServerCookies.d.ts.map +1 -1
- package/dist/cookies/ServerCookies.js +3 -3
- package/dist/cookies/index.d.ts +3 -2
- package/dist/cookies/index.d.ts.map +1 -1
- package/dist/crelte.d.ts +196 -0
- package/dist/crelte.d.ts.map +1 -0
- package/dist/crelte.js +52 -0
- package/dist/index.d.ts +11 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -28
- package/dist/init/InternalApp.d.ts +3 -4
- package/dist/init/InternalApp.d.ts.map +1 -1
- package/dist/init/InternalApp.js +3 -6
- package/dist/init/client.d.ts.map +1 -1
- package/dist/init/client.js +42 -37
- package/dist/init/server.d.ts +1 -0
- package/dist/init/server.d.ts.map +1 -1
- package/dist/init/server.js +31 -25
- package/dist/init/shared.d.ts +7 -6
- package/dist/init/shared.d.ts.map +1 -1
- package/dist/init/shared.js +73 -69
- package/dist/loadData/Globals.d.ts +2 -1
- package/dist/loadData/Globals.d.ts.map +1 -1
- package/dist/loadData/Globals.js +1 -1
- package/dist/loadData/entry.d.ts +25 -0
- package/dist/loadData/entry.d.ts.map +1 -0
- package/dist/loadData/entry.js +41 -0
- package/dist/loadData/index.d.ts +4 -93
- package/dist/loadData/index.d.ts.map +1 -1
- package/dist/loadData/index.js +3 -47
- package/dist/loadData/loadData.d.ts +93 -0
- package/dist/loadData/loadData.d.ts.map +1 -0
- package/dist/loadData/loadData.js +47 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +170 -0
- package/dist/node/utils.d.ts +8 -0
- package/dist/node/utils.d.ts.map +1 -0
- package/dist/node/utils.js +50 -0
- package/dist/plugins/Events.d.ts +17 -1
- package/dist/plugins/Events.d.ts.map +1 -1
- package/dist/plugins/Events.js +3 -10
- package/dist/plugins/Plugins.d.ts +2 -2
- package/dist/plugins/Plugins.d.ts.map +1 -1
- package/dist/queries/Queries.d.ts +84 -0
- package/dist/queries/Queries.d.ts.map +1 -0
- package/dist/queries/Queries.js +192 -0
- package/dist/queries/QueryError.d.ts +22 -0
- package/dist/queries/QueryError.d.ts.map +1 -0
- package/dist/queries/QueryError.js +27 -0
- package/dist/queries/gql.d.ts +13 -0
- package/dist/queries/gql.d.ts.map +1 -0
- package/dist/queries/gql.js +34 -0
- package/dist/queries/index.d.ts +6 -0
- package/dist/queries/index.d.ts.map +1 -0
- package/dist/queries/index.js +5 -0
- package/dist/queries/vars.d.ts +34 -0
- package/dist/queries/vars.d.ts.map +1 -0
- package/dist/queries/vars.js +81 -0
- package/dist/routing/History.d.ts +1 -1
- package/dist/routing/History.d.ts.map +1 -1
- package/dist/routing/index.d.ts +5 -4
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +5 -4
- package/dist/routing/{BaseRoute.d.ts → route/BaseRoute.d.ts} +1 -1
- package/dist/routing/route/BaseRoute.d.ts.map +1 -0
- package/dist/routing/{BaseRoute.js → route/BaseRoute.js} +2 -2
- package/dist/routing/{Request.d.ts → route/Request.d.ts} +3 -3
- package/dist/routing/route/Request.d.ts.map +1 -0
- package/dist/routing/{Request.js → route/Request.js} +2 -2
- package/dist/routing/{Route.d.ts → route/Route.d.ts} +2 -2
- package/dist/routing/route/Route.d.ts.map +1 -0
- package/dist/routing/{Route.js → route/Route.js} +1 -1
- package/dist/routing/{BaseRouter.d.ts → router/BaseRouter.d.ts} +8 -7
- package/dist/routing/router/BaseRouter.d.ts.map +1 -0
- package/dist/routing/{BaseRouter.js → router/BaseRouter.js} +7 -7
- package/dist/routing/{ClientRouter.d.ts → router/ClientRouter.d.ts} +4 -4
- package/dist/routing/router/ClientRouter.d.ts.map +1 -0
- package/dist/routing/{ClientRouter.js → router/ClientRouter.js} +4 -12
- package/dist/routing/{Router.d.ts → router/Router.d.ts} +6 -6
- package/dist/routing/router/Router.d.ts.map +1 -0
- package/dist/routing/{Router.js → router/Router.js} +3 -3
- package/dist/routing/{ServerRouter.d.ts → router/ServerRouter.d.ts} +3 -3
- package/dist/routing/router/ServerRouter.d.ts.map +1 -0
- package/dist/server/CrelteServer.d.ts +49 -0
- package/dist/server/CrelteServer.d.ts.map +1 -0
- package/dist/server/CrelteServer.js +65 -0
- package/dist/server/Request.d.ts +16 -0
- package/dist/server/Request.d.ts.map +1 -0
- package/dist/server/Request.js +20 -0
- package/dist/server/ServerRouter.d.ts +52 -0
- package/dist/server/ServerRouter.d.ts.map +1 -0
- package/dist/server/ServerRouter.js +91 -0
- package/dist/server/index.d.ts +6 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +5 -0
- package/dist/server/platform.d.ts +13 -0
- package/dist/server/platform.d.ts.map +1 -0
- package/dist/server/platform.js +1 -0
- package/dist/server/queries/QueriesCaching.d.ts +13 -0
- package/dist/server/queries/QueriesCaching.d.ts.map +1 -0
- package/dist/server/queries/QueriesCaching.js +68 -0
- package/dist/server/queries/index.d.ts +4 -0
- package/dist/server/queries/index.d.ts.map +1 -0
- package/dist/server/queries/index.js +2 -0
- package/dist/server/queries/queries.d.ts +4 -0
- package/dist/server/queries/queries.d.ts.map +1 -0
- package/dist/server/queries/queries.js +67 -0
- package/dist/server/queries/routes.d.ts +27 -0
- package/dist/server/queries/routes.d.ts.map +1 -0
- package/dist/server/queries/routes.js +169 -0
- package/dist/server/shared.d.ts +62 -0
- package/dist/server/shared.d.ts.map +1 -0
- package/dist/server/shared.js +151 -0
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/index.d.ts.map +1 -1
- package/dist/ssr/index.js +2 -2
- package/dist/static/index.d.ts +35 -0
- package/dist/static/index.d.ts.map +1 -0
- package/dist/static/index.js +40 -0
- package/dist/std/index.d.ts +20 -0
- package/dist/std/index.d.ts.map +1 -0
- package/dist/std/index.js +18 -0
- package/dist/std/stores/Readable.d.ts +24 -0
- package/dist/std/stores/Readable.d.ts.map +1 -0
- package/dist/std/stores/Readable.js +34 -0
- package/dist/std/stores/Readclone.d.ts +24 -0
- package/dist/std/stores/Readclone.d.ts.map +1 -0
- package/dist/std/stores/Readclone.js +28 -0
- package/dist/std/stores/Writable.d.ts +48 -0
- package/dist/std/stores/Writable.d.ts.map +1 -0
- package/dist/std/stores/Writable.js +65 -0
- package/dist/std/stores/index.d.ts +5 -0
- package/dist/std/stores/index.d.ts.map +1 -0
- package/dist/std/stores/index.js +4 -0
- package/dist/std/sync/Barrier.d.ts +30 -0
- package/dist/std/sync/Barrier.d.ts.map +1 -0
- package/dist/std/sync/Barrier.js +76 -0
- package/dist/std/sync/Listeners.d.ts +36 -0
- package/dist/std/sync/Listeners.d.ts.map +1 -0
- package/dist/std/sync/Listeners.js +51 -0
- package/dist/std/sync/index.d.ts +4 -0
- package/dist/std/sync/index.d.ts.map +1 -0
- package/dist/std/sync/index.js +3 -0
- package/dist/utils.d.ts +0 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +0 -2
- package/dist/vite/index.d.ts +7 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +308 -0
- package/package.json +44 -22
- package/src/blocks/Blocks.svelte +1 -2
- package/src/cookies/ClientCookies.ts +4 -4
- package/src/cookies/ServerCookies.ts +4 -4
- package/src/cookies/index.ts +4 -2
- package/src/crelte.ts +290 -0
- package/src/index.ts +45 -38
- package/src/init/InternalApp.ts +6 -13
- package/src/init/client.ts +45 -42
- package/src/init/server.ts +34 -24
- package/src/init/shared.ts +102 -86
- package/src/loadData/Globals.ts +2 -1
- package/src/loadData/entry.ts +68 -0
- package/src/loadData/index.ts +34 -162
- package/src/loadData/loadData.ts +160 -0
- package/src/node/index.ts +239 -0
- package/src/node/utils.ts +70 -0
- package/src/plugins/Events.ts +32 -24
- package/src/plugins/Plugins.ts +2 -2
- package/src/queries/Queries.ts +331 -0
- package/src/queries/QueryError.ts +37 -0
- package/src/queries/gql.ts +39 -0
- package/src/queries/index.ts +23 -0
- package/src/queries/vars.ts +107 -0
- package/src/routing/History.ts +1 -1
- package/src/routing/index.ts +8 -3
- package/src/routing/{BaseRoute.ts → route/BaseRoute.ts} +3 -3
- package/src/routing/{Request.ts → route/Request.ts} +4 -4
- package/src/routing/{Route.ts → route/Route.ts} +3 -3
- package/src/routing/{BaseRouter.ts → router/BaseRouter.ts} +10 -9
- package/src/routing/{ClientRouter.ts → router/ClientRouter.ts} +8 -16
- package/src/routing/{Router.ts → router/Router.ts} +7 -7
- package/src/routing/{ServerRouter.ts → router/ServerRouter.ts} +3 -3
- package/src/server/CrelteServer.ts +96 -0
- package/src/server/Request.ts +23 -0
- package/src/server/ServerRouter.ts +136 -0
- package/src/server/index.ts +14 -0
- package/src/server/platform.ts +12 -0
- package/src/server/queries/QueriesCaching.ts +83 -0
- package/src/server/queries/index.ts +5 -0
- package/src/server/queries/queries.ts +118 -0
- package/src/server/queries/routes.ts +199 -0
- package/src/server/shared.ts +280 -0
- package/src/ssr/index.ts +2 -2
- package/src/static/index.ts +81 -0
- package/src/std/index.ts +34 -0
- package/src/std/stores/Readable.ts +38 -0
- package/src/std/stores/Readclone.ts +34 -0
- package/src/std/stores/Writable.ts +77 -0
- package/src/std/stores/index.ts +5 -0
- package/src/std/sync/Barrier.ts +100 -0
- package/src/std/sync/Listeners.ts +56 -0
- package/src/std/sync/index.ts +4 -0
- package/src/utils.ts +0 -3
- package/src/vite/index.ts +403 -0
- package/types.d.ts +12 -0
- package/dist/Crelte.d.ts +0 -172
- package/dist/Crelte.d.ts.map +0 -1
- package/dist/Crelte.js +0 -172
- package/dist/CrelteRequest.d.ts +0 -70
- package/dist/CrelteRequest.d.ts.map +0 -1
- package/dist/CrelteRequest.js +0 -103
- package/dist/cookies/internal.d.ts +0 -3
- package/dist/cookies/internal.d.ts.map +0 -1
- package/dist/cookies/internal.js +0 -2
- package/dist/entry/EntryRouter.d.ts +0 -30
- package/dist/entry/EntryRouter.d.ts.map +0 -1
- package/dist/entry/EntryRouter.js +0 -45
- package/dist/entry/index.d.ts +0 -37
- package/dist/entry/index.d.ts.map +0 -1
- package/dist/entry/index.js +0 -31
- package/dist/graphql/GraphQl.d.ts +0 -106
- package/dist/graphql/GraphQl.d.ts.map +0 -1
- package/dist/graphql/GraphQl.js +0 -231
- package/dist/graphql/gql.test.d.ts +0 -2
- package/dist/graphql/gql.test.d.ts.map +0 -1
- package/dist/graphql/gql.test.js +0 -80
- package/dist/graphql/index.d.ts +0 -3
- package/dist/graphql/index.d.ts.map +0 -1
- package/dist/graphql/index.js +0 -2
- package/dist/routing/BaseRoute.d.ts.map +0 -1
- package/dist/routing/BaseRouter.d.ts.map +0 -1
- package/dist/routing/ClientRouter.d.ts.map +0 -1
- package/dist/routing/Request.d.ts.map +0 -1
- package/dist/routing/Route.d.ts.map +0 -1
- package/dist/routing/Router.d.ts.map +0 -1
- package/dist/routing/ServerRouter.d.ts.map +0 -1
- package/dist/routing/internal.d.ts +0 -3
- package/dist/routing/internal.d.ts.map +0 -1
- package/dist/routing/internal.js +0 -2
- package/src/Crelte.ts +0 -285
- package/src/CrelteRequest.ts +0 -135
- package/src/cookies/internal.ts +0 -3
- package/src/entry/EntryRouter.ts +0 -71
- package/src/entry/index.ts +0 -54
- package/src/graphql/GraphQl.ts +0 -356
- package/src/graphql/gql.test.ts +0 -123
- package/src/graphql/index.ts +0 -14
- package/src/routing/internal.ts +0 -3
- /package/dist/routing/{ServerRouter.js → router/ServerRouter.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Blocks.svelte.d.ts","sourceRoot":"","sources":["../../src/blocks/Blocks.svelte.ts"],"names":[],"mappings":"AAGC,OAAO,aAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"Blocks.svelte.d.ts","sourceRoot":"","sources":["../../src/blocks/Blocks.svelte.ts"],"names":[],"mappings":"AAGC,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAiBjD,OAAO,MAAM,EAAE,EACd,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,YAAY,EAEZ,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACpC,IAAI,GAAE,mBAAwB,GAC5B,YAAY,CAEd;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CACnC,EAAE,EAAE,aAAa,EACjB,MAAM,EAAE,GAAG,EAAE,EACb,OAAO,EAAE,YAAY,GACnB,OAAO,CAAC,MAAM,CAAC,CAMjB;AAuBF,QAAA,MAAM,MAAM,KAAsG,CAAC;AACjG,KAAK,MAAM,GAAG,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC;AAC5C,eAAe,MAAM,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Cookies, SetOptions } from './index.js';
|
|
1
|
+
import { Cookies, RemoveOptions, SetOptions } from './index.js';
|
|
2
2
|
export default class ClientCookies implements Cookies {
|
|
3
3
|
constructor();
|
|
4
4
|
get(name: string): string | null;
|
|
5
5
|
set(name: string, value: string, opts?: SetOptions): void;
|
|
6
|
-
remove(name: string): void;
|
|
6
|
+
remove(name: string, opts?: RemoveOptions): void;
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=ClientCookies.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientCookies.d.ts","sourceRoot":"","sources":["../../src/cookies/ClientCookies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"ClientCookies.d.ts","sourceRoot":"","sources":["../../src/cookies/ClientCookies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAMhE,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,OAAO;;IAGpD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAKhC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI;IAMzD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,IAAI;CAGhD"}
|
|
@@ -9,11 +9,11 @@ export default class ClientCookies {
|
|
|
9
9
|
return cookies.get(name) ?? null;
|
|
10
10
|
}
|
|
11
11
|
set(name, value, opts) {
|
|
12
|
-
const setCookie = { name, value, ...opts };
|
|
12
|
+
const setCookie = { name, value, path: '/', ...opts };
|
|
13
13
|
document.cookie = setCookieToString(setCookie);
|
|
14
14
|
}
|
|
15
|
-
remove(name) {
|
|
16
|
-
this.set(name, '', { maxAge: 0 });
|
|
15
|
+
remove(name, opts) {
|
|
16
|
+
this.set(name, '', { ...opts, maxAge: 0 });
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
function getCookies() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cookies, SetOptions } from './index.js';
|
|
1
|
+
import { Cookies, RemoveOptions, SetOptions } from './index.js';
|
|
2
2
|
import { type SetCookie } from './utils.js';
|
|
3
3
|
/**
|
|
4
4
|
* ## Warning
|
|
@@ -10,7 +10,7 @@ export default class ServerCookies implements Cookies {
|
|
|
10
10
|
constructor(cookies: string);
|
|
11
11
|
get(name: string): string | null;
|
|
12
12
|
set(name: string, value: string, opts?: SetOptions): void;
|
|
13
|
-
remove(name: string): void;
|
|
13
|
+
remove(name: string, opts?: RemoveOptions): void;
|
|
14
14
|
_getSetCookiesHeaders(): string[];
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=ServerCookies.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerCookies.d.ts","sourceRoot":"","sources":["../../src/cookies/ServerCookies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"ServerCookies.d.ts","sourceRoot":"","sources":["../../src/cookies/ServerCookies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAgB,KAAK,SAAS,EAAqB,MAAM,YAAY,CAAC;AAE7E;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,OAAO;IACpD,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;gBAEvB,OAAO,EAAE,MAAM;IAM3B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAUhC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI;IAIzD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,IAAI;IAIhD,qBAAqB,IAAI,MAAM,EAAE;CAKjC"}
|
|
@@ -20,10 +20,10 @@ export default class ServerCookies {
|
|
|
20
20
|
return this.requestCookies.get(name) ?? null;
|
|
21
21
|
}
|
|
22
22
|
set(name, value, opts) {
|
|
23
|
-
this.setCookies.set(name, { name, value, ...opts });
|
|
23
|
+
this.setCookies.set(name, { name, value, path: '/', ...opts });
|
|
24
24
|
}
|
|
25
|
-
remove(name) {
|
|
26
|
-
this.set(name, '', { maxAge: 0 });
|
|
25
|
+
remove(name, opts) {
|
|
26
|
+
this.set(name, '', { ...opts, maxAge: 0 });
|
|
27
27
|
}
|
|
28
28
|
_getSetCookiesHeaders() {
|
|
29
29
|
return Array.from(this.setCookies.values()).map(setCookie => setCookieToString(setCookie));
|
package/dist/cookies/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type SetOptions = {
|
|
|
5
5
|
secure?: boolean;
|
|
6
6
|
httpOnly?: boolean;
|
|
7
7
|
};
|
|
8
|
+
export type RemoveOptions = Omit<SetOptions, 'maxAge'>;
|
|
8
9
|
export interface Cookies {
|
|
9
10
|
/**
|
|
10
11
|
* returns the value of the cookie
|
|
@@ -14,12 +15,12 @@ export interface Cookies {
|
|
|
14
15
|
* sets the value of the cookie
|
|
15
16
|
*
|
|
16
17
|
* ## Note
|
|
17
|
-
*
|
|
18
|
+
* path defaults to '/'
|
|
18
19
|
*/
|
|
19
20
|
set(name: string, value: string, opts?: SetOptions): void;
|
|
20
21
|
/**
|
|
21
22
|
* removes the cookie
|
|
22
23
|
*/
|
|
23
|
-
remove(name: string): void;
|
|
24
|
+
remove(name: string, opts?: RemoveOptions): void;
|
|
24
25
|
}
|
|
25
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cookies/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,OAAO;IACvB;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAEjC;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAE1D;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cookies/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAEvD,MAAM,WAAW,OAAO;IACvB;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAEjC;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAE1D;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;CACjD"}
|
package/dist/crelte.d.ts
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { Cookies } from './cookies/index.js';
|
|
2
|
+
import Globals from './loadData/Globals.js';
|
|
3
|
+
import Events from './plugins/Events.js';
|
|
4
|
+
import Plugins, { Plugin } from './plugins/Plugins.js';
|
|
5
|
+
import { type Route, Request, Router } from './routing/index.js';
|
|
6
|
+
import SsrCache from './ssr/SsrCache.js';
|
|
7
|
+
import Site from './routing/Site.js';
|
|
8
|
+
import Queries, { Query, QueryOptions } from './queries/Queries.js';
|
|
9
|
+
import { Readable } from './std/stores/index.js';
|
|
10
|
+
import { Entry } from './loadData/index.js';
|
|
11
|
+
export type Config = {
|
|
12
|
+
/**
|
|
13
|
+
* Preload pages on mouse over
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
preloadOnMouseOver?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Use view transitions
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
viewTransition?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Play the intro animation
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
playIntro?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Enable X-Craft-Site Header
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
XCraftSiteHeader?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Enable graphql query debugging
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
debugQueries?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Enable request and render timing measurement
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
debugTiming?: boolean;
|
|
42
|
+
};
|
|
43
|
+
export declare function configWithDefaults(config?: Config): Required<Config>;
|
|
44
|
+
/**
|
|
45
|
+
* This is Crelte a container of useful features and functions.
|
|
46
|
+
*
|
|
47
|
+
* In svelte contexts for each of these functions and classes there
|
|
48
|
+
* should be a getter function like `getCrelte()` or `getRouter()`.
|
|
49
|
+
*
|
|
50
|
+
* ## Note
|
|
51
|
+
* Plugins and other instances could modify this type, so when extending cloning
|
|
52
|
+
* or similar use the spread operator instead of naming all "properties".
|
|
53
|
+
*/
|
|
54
|
+
export type Crelte = {
|
|
55
|
+
/**
|
|
56
|
+
* Config
|
|
57
|
+
*/
|
|
58
|
+
config: Required<Config>;
|
|
59
|
+
/**
|
|
60
|
+
* Get the SSR cache
|
|
61
|
+
*/
|
|
62
|
+
ssrCache: SsrCache;
|
|
63
|
+
/**
|
|
64
|
+
* Get the Queries instance
|
|
65
|
+
*/
|
|
66
|
+
queries: Queries;
|
|
67
|
+
/**
|
|
68
|
+
* Get the Router instance
|
|
69
|
+
*/
|
|
70
|
+
router: Router;
|
|
71
|
+
/**
|
|
72
|
+
* Get the Plugins instance
|
|
73
|
+
*/
|
|
74
|
+
plugins: Plugins;
|
|
75
|
+
/**
|
|
76
|
+
* Get the Events instance
|
|
77
|
+
*/
|
|
78
|
+
events: Events;
|
|
79
|
+
/**
|
|
80
|
+
* Get the Globals instance
|
|
81
|
+
*/
|
|
82
|
+
globals: Globals;
|
|
83
|
+
/**
|
|
84
|
+
* Get the Cookies instance
|
|
85
|
+
*/
|
|
86
|
+
cookies: Cookies;
|
|
87
|
+
/**
|
|
88
|
+
* Get a Plugin by name
|
|
89
|
+
*/
|
|
90
|
+
getPlugin(name: string): Plugin | null;
|
|
91
|
+
/**
|
|
92
|
+
* returns an env variable from the craft/.env file.
|
|
93
|
+
* All env variables need to start with VITE_
|
|
94
|
+
* except ENDPOINT_URL, CRAFT_WEB_URL and FRONTEND_URL
|
|
95
|
+
*/
|
|
96
|
+
getEnv(name: 'ENDPOINT_URL'): string;
|
|
97
|
+
getEnv(name: 'CRAFT_WEB_URL'): string;
|
|
98
|
+
getEnv(name: 'FRONTEND_URL'): string;
|
|
99
|
+
getEnv(name: string): string | null;
|
|
100
|
+
/**
|
|
101
|
+
* returns a store which contains a globalSet
|
|
102
|
+
*
|
|
103
|
+
* ## Note
|
|
104
|
+
* This only works in loadData, in loadGlobalData this will
|
|
105
|
+
* always return null. In that context you should use
|
|
106
|
+
* `CrelteRequest.getGlobalAsync`
|
|
107
|
+
*/
|
|
108
|
+
getGlobalStore<T = any>(name: string): Readable<T> | null;
|
|
109
|
+
/**
|
|
110
|
+
* returns a new CrelteRequest instance either with the current
|
|
111
|
+
* route or a provided one
|
|
112
|
+
*
|
|
113
|
+
* ## Note
|
|
114
|
+
* This is useful if you want to create a stateful crelte
|
|
115
|
+
* to use in loadData context
|
|
116
|
+
*/
|
|
117
|
+
toRequest(req?: Route | Request): CrelteRequest;
|
|
118
|
+
/**
|
|
119
|
+
* Run a GraphQl Query
|
|
120
|
+
*
|
|
121
|
+
* @param query the default export from a graphql file or the gql`query {}`
|
|
122
|
+
* function
|
|
123
|
+
* @param variables variables that should be passed to the
|
|
124
|
+
* graphql query
|
|
125
|
+
*/
|
|
126
|
+
query(query: Query, variables?: Record<string, unknown>, opts?: QueryOptions): Promise<unknown>;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* This is Crelte a container of useful features and functions.
|
|
130
|
+
*
|
|
131
|
+
* In svelte contexts for each of these functions and classes there
|
|
132
|
+
* should be a getter function like `getCrelte()` or `getRouter()`.
|
|
133
|
+
*
|
|
134
|
+
* ## Note
|
|
135
|
+
* Plugins and other instances could modify this type, so when extending cloning
|
|
136
|
+
* or similar use the spread operator instead of naming all "properties".
|
|
137
|
+
*/
|
|
138
|
+
export type CrelteWithRoute = Crelte & {
|
|
139
|
+
/** The route */
|
|
140
|
+
get route(): Readable<Route>;
|
|
141
|
+
get site(): Readable<Site>;
|
|
142
|
+
get entry(): Readable<Entry>;
|
|
143
|
+
/**
|
|
144
|
+
* returns a store which contains a globalSet
|
|
145
|
+
*
|
|
146
|
+
* ## Note
|
|
147
|
+
* This only works in loadData, in loadGlobalData this will
|
|
148
|
+
* always return null. In that context you should use
|
|
149
|
+
* `CrelteRequest.getGlobalAsync`
|
|
150
|
+
*/
|
|
151
|
+
getGlobal<T = any>(name: string): Readable<T> | null;
|
|
152
|
+
};
|
|
153
|
+
export type CrelteRequest = Crelte & {
|
|
154
|
+
/**
|
|
155
|
+
* The current request
|
|
156
|
+
*/
|
|
157
|
+
req: Request;
|
|
158
|
+
/**
|
|
159
|
+
* Easy access to this.req.site
|
|
160
|
+
*
|
|
161
|
+
* ## Note
|
|
162
|
+
* The site might not always match with the current route
|
|
163
|
+
* but be the site default site or one that matches the
|
|
164
|
+
* users language.
|
|
165
|
+
*/
|
|
166
|
+
get site(): Site;
|
|
167
|
+
/**
|
|
168
|
+
* returns a globalSet
|
|
169
|
+
*
|
|
170
|
+
* ## Note
|
|
171
|
+
* This only works in loadData, in loadGlobalData this will
|
|
172
|
+
* always return null. In that context you should use
|
|
173
|
+
* `.getGlobalAsync`
|
|
174
|
+
*/
|
|
175
|
+
getGlobal<T = any>(name: string): T | null;
|
|
176
|
+
/**
|
|
177
|
+
* Get a globalSet and wait until it is loaded
|
|
178
|
+
*
|
|
179
|
+
* ## Note
|
|
180
|
+
* This is only useful in loadGlobalData in all other cases
|
|
181
|
+
* you can use `.getGlobal` which does not return a Promise
|
|
182
|
+
*/
|
|
183
|
+
getGlobalAsync<T = any>(name: string): T | Promise<T | null> | null;
|
|
184
|
+
};
|
|
185
|
+
export declare function newCrelte({ config, ssrCache, plugins, events, globals, router, queries, cookies, }: {
|
|
186
|
+
config: Required<Config>;
|
|
187
|
+
ssrCache: SsrCache;
|
|
188
|
+
plugins: Plugins;
|
|
189
|
+
events: Events;
|
|
190
|
+
globals: Globals;
|
|
191
|
+
router: Router;
|
|
192
|
+
queries: Queries;
|
|
193
|
+
cookies: Cookies;
|
|
194
|
+
}): Crelte;
|
|
195
|
+
export declare function crelteToRequest(crelte: Crelte, req?: Route | Request): CrelteRequest;
|
|
196
|
+
//# sourceMappingURL=crelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crelte.d.ts","sourceRoot":"","sources":["../src/crelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,QAA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;;;;;OAMG;IACH,cAAc,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;CACpE,CAAC;AAEF,wBAAgB,SAAS,CAAC,EACzB,MAAM,EACN,QAAQ,EACR,OAAO,EACP,MAAM,EACN,OAAO,EACP,MAAM,EACN,OAAO,EACP,OAAO,GACP,EAAE;IACF,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CACjB,GAAG,MAAM,CAsBT;AAED,wBAAgB,eAAe,CAC9B,MAAM,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,KAAK,GAAG,OAAO,GACnB,aAAa,CAkBf"}
|
package/dist/crelte.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Request } from './routing/index.js';
|
|
2
|
+
export function configWithDefaults(config = {}) {
|
|
3
|
+
return {
|
|
4
|
+
preloadOnMouseOver: config.preloadOnMouseOver ?? false,
|
|
5
|
+
viewTransition: config.viewTransition ?? false,
|
|
6
|
+
playIntro: config.playIntro ?? false,
|
|
7
|
+
XCraftSiteHeader: config.XCraftSiteHeader ?? false,
|
|
8
|
+
debugQueries: config.debugQueries ?? false,
|
|
9
|
+
debugTiming: config.debugTiming ?? false,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function newCrelte({ config, ssrCache, plugins, events, globals, router, queries, cookies, }) {
|
|
13
|
+
return {
|
|
14
|
+
config,
|
|
15
|
+
ssrCache,
|
|
16
|
+
plugins,
|
|
17
|
+
events,
|
|
18
|
+
globals,
|
|
19
|
+
router,
|
|
20
|
+
queries,
|
|
21
|
+
cookies,
|
|
22
|
+
getPlugin: name => plugins.get(name),
|
|
23
|
+
getEnv: key => ssrCache.get(key),
|
|
24
|
+
getGlobalStore: name => globals.getStore(name),
|
|
25
|
+
toRequest(req) {
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
if (this === globalThis)
|
|
28
|
+
throw new Error('need to call toRequest with a this context');
|
|
29
|
+
return crelteToRequest(this, req);
|
|
30
|
+
},
|
|
31
|
+
query: (query, vars, opts) => queries.query(query, vars, opts),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function crelteToRequest(crelte, req) {
|
|
35
|
+
req = req ?? crelte.req;
|
|
36
|
+
if (!req) {
|
|
37
|
+
req = crelte.router.route.get() ?? undefined;
|
|
38
|
+
// this will only occur in the first loadData call
|
|
39
|
+
if (!req)
|
|
40
|
+
throw new Error('router does not contain a route');
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
...crelte,
|
|
44
|
+
req: req instanceof Request ? req : Request.fromRoute(req),
|
|
45
|
+
get site() {
|
|
46
|
+
return this.req.site;
|
|
47
|
+
},
|
|
48
|
+
getGlobal: name => crelte.globals.get(name),
|
|
49
|
+
getGlobalAsync: name => crelte.globals.getAsync(name),
|
|
50
|
+
query: (query, vars, opts) => crelte.queries.query(query, vars, opts),
|
|
51
|
+
};
|
|
52
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import type Route from './routing/
|
|
2
|
-
import type Router from './routing/Router.js';
|
|
1
|
+
import { type Route, type Router } from './routing/index.js';
|
|
3
2
|
import type SsrCache from './ssr/SsrCache.js';
|
|
4
3
|
import type Site from './routing/Site.js';
|
|
5
|
-
import type
|
|
6
|
-
import Crelte, { type QueryOptions, type Config } from './Crelte.js';
|
|
7
|
-
import CrelteRequest from './CrelteRequest.js';
|
|
4
|
+
import { type Crelte, type CrelteRequest, type CrelteWithRoute, type Config } from './crelte.js';
|
|
8
5
|
import type { Cookies } from './cookies/index.js';
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
export { Crelte,
|
|
6
|
+
import { Entry, LoadData, LoadDataArray, LoadDataFn, LoadDataObj } from './loadData/index.js';
|
|
7
|
+
import Queries from './queries/Queries.js';
|
|
8
|
+
import { Readable } from './std/stores/index.js';
|
|
9
|
+
export { type Crelte, type CrelteWithRoute, type CrelteRequest, type Config, type LoadData, type LoadDataFn, type LoadDataObj, type LoadDataArray, };
|
|
13
10
|
export type Init = (crelte: Crelte) => void;
|
|
14
11
|
/**
|
|
15
12
|
* Get Crelte from the current context
|
|
@@ -17,7 +14,7 @@ export type Init = (crelte: Crelte) => void;
|
|
|
17
14
|
* ## Note
|
|
18
15
|
* This only works during component initialisation.
|
|
19
16
|
*/
|
|
20
|
-
export declare function getCrelte():
|
|
17
|
+
export declare function getCrelte(): CrelteWithRoute;
|
|
21
18
|
/**
|
|
22
19
|
* Get the router from the current context
|
|
23
20
|
*
|
|
@@ -33,12 +30,12 @@ export declare function getRouter(): Router;
|
|
|
33
30
|
*/
|
|
34
31
|
export declare function getSsrCache(): SsrCache;
|
|
35
32
|
/**
|
|
36
|
-
* Get the
|
|
33
|
+
* Get the Queries from the current context
|
|
37
34
|
*
|
|
38
35
|
* ## Note
|
|
39
36
|
* This only works during component initialisation.
|
|
40
37
|
*/
|
|
41
|
-
export declare function
|
|
38
|
+
export declare function getQueries(): Queries;
|
|
42
39
|
/**
|
|
43
40
|
* Get a store with the current route
|
|
44
41
|
*
|
|
@@ -63,13 +60,14 @@ export declare function getEntry(): Readable<Entry>;
|
|
|
63
60
|
/**
|
|
64
61
|
* returns an env variable from the craft/.env file.
|
|
65
62
|
* All env variables need to start with VITE_
|
|
66
|
-
* except ENDPOINT_URL and
|
|
63
|
+
* except ENDPOINT_URL, CRAFT_WEB_URL and FRONTEND_URL
|
|
67
64
|
*
|
|
68
65
|
* ## Note
|
|
69
66
|
* This only works during component initialisation.
|
|
70
67
|
*/
|
|
71
68
|
export declare function getEnv(name: 'ENDPOINT_URL'): string;
|
|
72
69
|
export declare function getEnv(name: 'CRAFT_WEB_URL'): string;
|
|
70
|
+
export declare function getEnv(name: 'FRONTEND_URL'): string;
|
|
73
71
|
export declare function getEnv(name: string): string | null;
|
|
74
72
|
/**
|
|
75
73
|
* returns a store which indicates if the a page is loading
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EACN,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACN,KAAK,EACL,QAAQ,EACR,aAAa,EACb,UAAU,EACV,WAAW,EACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EACN,KAAK,MAAM,EACX,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,aAAa,GAClB,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AAM5C;;;;;GAKG;AACH,wBAAgB,SAA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HANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getContext, onDestroy } from 'svelte';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
function innerGetCrelte() {
|
|
3
|
+
return getContext('crelte');
|
|
4
|
+
}
|
|
5
5
|
/**
|
|
6
6
|
* Get Crelte from the current context
|
|
7
7
|
*
|
|
@@ -9,7 +9,17 @@ export { Crelte, CrelteRequest, };
|
|
|
9
9
|
* This only works during component initialisation.
|
|
10
10
|
*/
|
|
11
11
|
export function getCrelte() {
|
|
12
|
-
|
|
12
|
+
const crelte = innerGetCrelte();
|
|
13
|
+
// the route, site and entry will never be null because it is
|
|
14
|
+
// only null in the first loadData call and that happens
|
|
15
|
+
// before any component initialisation
|
|
16
|
+
return {
|
|
17
|
+
...crelte,
|
|
18
|
+
route: crelte.router.route,
|
|
19
|
+
site: crelte.router.site,
|
|
20
|
+
entry: crelte.router.entry,
|
|
21
|
+
getGlobal: name => crelte.getGlobalStore(name),
|
|
22
|
+
};
|
|
13
23
|
}
|
|
14
24
|
/**
|
|
15
25
|
* Get the router from the current context
|
|
@@ -18,7 +28,7 @@ export function getCrelte() {
|
|
|
18
28
|
* This only works during component initialisation.
|
|
19
29
|
*/
|
|
20
30
|
export function getRouter() {
|
|
21
|
-
return
|
|
31
|
+
return innerGetCrelte().router;
|
|
22
32
|
}
|
|
23
33
|
/**
|
|
24
34
|
* Get the SSR cache from the current context
|
|
@@ -27,16 +37,16 @@ export function getRouter() {
|
|
|
27
37
|
* This only works during component initialisation.
|
|
28
38
|
*/
|
|
29
39
|
export function getSsrCache() {
|
|
30
|
-
return
|
|
40
|
+
return innerGetCrelte().ssrCache;
|
|
31
41
|
}
|
|
32
42
|
/**
|
|
33
|
-
* Get the
|
|
43
|
+
* Get the Queries from the current context
|
|
34
44
|
*
|
|
35
45
|
* ## Note
|
|
36
46
|
* This only works during component initialisation.
|
|
37
47
|
*/
|
|
38
|
-
export function
|
|
39
|
-
return
|
|
48
|
+
export function getQueries() {
|
|
49
|
+
return innerGetCrelte().queries;
|
|
40
50
|
}
|
|
41
51
|
/**
|
|
42
52
|
* Get a store with the current route
|
|
@@ -45,10 +55,7 @@ export function getGraphQl() {
|
|
|
45
55
|
* This only works during component initialisation.
|
|
46
56
|
*/
|
|
47
57
|
export function getRoute() {
|
|
48
|
-
|
|
49
|
-
// first loadData call and that happens before any component
|
|
50
|
-
// initialisation
|
|
51
|
-
return getRouter().route;
|
|
58
|
+
return getCrelte().route;
|
|
52
59
|
}
|
|
53
60
|
/**
|
|
54
61
|
* Get a store with the current site
|
|
@@ -57,10 +64,7 @@ export function getRoute() {
|
|
|
57
64
|
* This only works during component initialisation.
|
|
58
65
|
*/
|
|
59
66
|
export function getSite() {
|
|
60
|
-
|
|
61
|
-
// first loadData call and that happens before any component
|
|
62
|
-
// initialisation
|
|
63
|
-
return getRouter().site;
|
|
67
|
+
return getCrelte().site;
|
|
64
68
|
}
|
|
65
69
|
/**
|
|
66
70
|
* Get a store with the current entry
|
|
@@ -69,13 +73,10 @@ export function getSite() {
|
|
|
69
73
|
* This only works during component initialisation.
|
|
70
74
|
*/
|
|
71
75
|
export function getEntry() {
|
|
72
|
-
|
|
73
|
-
// first loadData call and that happens before any component
|
|
74
|
-
// initialisation
|
|
75
|
-
return getRouter().entry;
|
|
76
|
+
return getCrelte().entry;
|
|
76
77
|
}
|
|
77
78
|
export function getEnv(name) {
|
|
78
|
-
return
|
|
79
|
+
return innerGetCrelte().getEnv(name);
|
|
79
80
|
}
|
|
80
81
|
/**
|
|
81
82
|
* returns a store which indicates if the a page is loading
|
|
@@ -102,7 +103,7 @@ export function getLoadingProgress() {
|
|
|
102
103
|
* This only works during component initialisation.
|
|
103
104
|
*/
|
|
104
105
|
export function getGlobal(name) {
|
|
105
|
-
return getCrelte().
|
|
106
|
+
return getCrelte().getGlobal(name);
|
|
106
107
|
}
|
|
107
108
|
/**
|
|
108
109
|
* returns the cookies instance
|
|
@@ -111,7 +112,7 @@ export function getGlobal(name) {
|
|
|
111
112
|
* This only works during component initialisation.
|
|
112
113
|
*/
|
|
113
114
|
export function getCookies() {
|
|
114
|
-
return
|
|
115
|
+
return innerGetCrelte().cookies;
|
|
115
116
|
}
|
|
116
117
|
/**
|
|
117
118
|
* Listen for route changes
|
|
@@ -120,8 +121,7 @@ export function getCookies() {
|
|
|
120
121
|
* This only works during component initialisation.
|
|
121
122
|
*/
|
|
122
123
|
export function onRoute(fn) {
|
|
123
|
-
const
|
|
124
|
-
const rmListener = crelte.router.onRoute(route => fn(route));
|
|
124
|
+
const rmListener = getRouter().onRoute(route => fn(route));
|
|
125
125
|
onDestroy(rmListener);
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
@@ -131,7 +131,6 @@ export function onRoute(fn) {
|
|
|
131
131
|
* This only works during component initialisation.
|
|
132
132
|
*/
|
|
133
133
|
export function onRequest(fn) {
|
|
134
|
-
const
|
|
135
|
-
const rmListener = crelte.router.onRequest(cr => fn(cr));
|
|
134
|
+
const rmListener = getRouter().onRequest(cr => fn(cr));
|
|
136
135
|
onDestroy(rmListener);
|
|
137
136
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { Entry } from '../entry/index.js';
|
|
2
1
|
import { Crelte } from '../index.js';
|
|
3
|
-
import { LoadData } from '../loadData/index.js';
|
|
2
|
+
import { Entry, LoadData } from '../loadData/index.js';
|
|
4
3
|
import { PluginCreator } from '../plugins/index.js';
|
|
5
4
|
export interface App {
|
|
6
5
|
plugins?: PluginCreator[];
|
|
7
6
|
templates?: Record<string, LazyTemplateModule>;
|
|
8
7
|
loadGlobalData?: LoadData<null>;
|
|
9
|
-
loadEntry
|
|
8
|
+
loadEntry?: LoadData<null>;
|
|
10
9
|
loadEntryData?: LoadData<Entry>;
|
|
11
10
|
init?: (crelte: Crelte) => void;
|
|
12
11
|
}
|
|
@@ -21,7 +20,7 @@ export default class InternalApp {
|
|
|
21
20
|
templateModules: TemplateModules;
|
|
22
21
|
constructor(inner: App);
|
|
23
22
|
get plugins(): PluginCreator[];
|
|
24
|
-
get loadGlobalData(): LoadData<null
|
|
23
|
+
get loadGlobalData(): LoadData<null>;
|
|
25
24
|
init(crelte: Crelte): void;
|
|
26
25
|
get loadEntry(): LoadData<null>;
|
|
27
26
|
loadTemplate(entry: Entry): Promise<TemplateModule>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalApp.d.ts","sourceRoot":"","sources":["../../src/init/InternalApp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"InternalApp.d.ts","sourceRoot":"","sources":["../../src/init/InternalApp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,WAAW,GAAG;IACnB,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAE1B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAE/C,cAAc,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEhC,SAAS,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAG3B,aAAa,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IAIhC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,cAAc;IAE9B,OAAO,EAAE,GAAG,CAAC;IAEb,QAAQ,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;CAC3B;AAED,MAAM,MAAM,kBAAkB,GAC3B,CAAC,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC,GAC/B,cAAc,CAAC;AAElB,MAAM,MAAM,eAAe,GAAG,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAE9D,MAAM,CAAC,OAAO,OAAO,WAAW;IAC/B,KAAK,EAAE,GAAG,CAAC;IACX,eAAe,EAAE,eAAe,CAAC;gBAErB,KAAK,EAAE,GAAG;IAatB,IAAI,OAAO,IAAI,aAAa,EAAE,CAE7B;IAED,IAAI,cAAc,IAAI,QAAQ,CAAC,IAAI,CAAC,CAEnC;IAED,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI1B,IAAI,SAAS,IAAI,QAAQ,CAAC,IAAI,CAAC,CAG9B;IAEK,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC;IA4BzD,IAAI,aAAa,IAAI,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAE1C;CACD"}
|
package/dist/init/InternalApp.js
CHANGED
|
@@ -9,22 +9,19 @@ export default class InternalApp {
|
|
|
9
9
|
throw new Error('loadData is ambigous, choose loadGlobalData or ' +
|
|
10
10
|
'loadEntryData depending on if you need access to the entry or not?');
|
|
11
11
|
}
|
|
12
|
-
if (!inner.loadEntry) {
|
|
13
|
-
throw new Error('loadEntry is required in the app. `export const loadEntry ' +
|
|
14
|
-
'= entryQuery;`');
|
|
15
|
-
}
|
|
16
12
|
}
|
|
17
13
|
get plugins() {
|
|
18
14
|
return this.inner.plugins ?? [];
|
|
19
15
|
}
|
|
20
16
|
get loadGlobalData() {
|
|
21
|
-
return this.inner.loadGlobalData;
|
|
17
|
+
return this.inner.loadGlobalData ?? { queryName: 'global' };
|
|
22
18
|
}
|
|
23
19
|
init(crelte) {
|
|
24
20
|
this.inner.init?.(crelte);
|
|
25
21
|
}
|
|
26
22
|
get loadEntry() {
|
|
27
|
-
|
|
23
|
+
// if no loadEntry property was defined we expect a graphql entry file
|
|
24
|
+
return this.inner.loadEntry ?? { queryName: 'entry' };
|
|
28
25
|
}
|
|
29
26
|
async loadTemplate(entry) {
|
|
30
27
|
const modules = this.templateModules;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/init/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/init/client.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB,4BAA4B;IAC5B,GAAG,EAAE,GAAG,CAAC;IACT,8BAA8B;IAC9B,SAAS,EAAE,GAAG,CAAC;CACf,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,IAAI,CAAC,IAAI,EAAE,QAAQ,iBA4JxC"}
|