crelte 0.5.11 → 0.5.12
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/bodyClass/BodyClass.d.ts +39 -0
- package/dist/bodyClass/BodyClass.d.ts.map +1 -0
- package/dist/bodyClass/BodyClass.js +51 -0
- package/dist/bodyClass/ClientBodyClass.d.ts +12 -0
- package/dist/bodyClass/ClientBodyClass.d.ts.map +1 -0
- package/dist/bodyClass/ClientBodyClass.js +57 -0
- package/dist/bodyClass/ServerBodyClass.d.ts +12 -0
- package/dist/bodyClass/ServerBodyClass.d.ts.map +1 -0
- package/dist/bodyClass/ServerBodyClass.js +47 -0
- package/dist/bodyClass/index.d.ts +2 -0
- package/dist/bodyClass/index.d.ts.map +1 -0
- package/dist/bodyClass/index.js +1 -0
- package/dist/cookies/ClientCookies.d.ts +8 -3
- package/dist/cookies/ClientCookies.d.ts.map +1 -1
- package/dist/cookies/ClientCookies.js +31 -7
- package/dist/cookies/Cookies.d.ts +42 -0
- package/dist/cookies/Cookies.d.ts.map +1 -0
- package/dist/cookies/Cookies.js +44 -0
- package/dist/cookies/ServerCookies.d.ts +3 -2
- package/dist/cookies/ServerCookies.d.ts.map +1 -1
- package/dist/cookies/ServerCookies.js +6 -4
- package/dist/cookies/index.d.ts +1 -25
- package/dist/cookies/index.d.ts.map +1 -1
- package/dist/cookies/index.js +1 -1
- package/dist/crelte.d.ts +7 -1
- package/dist/crelte.d.ts.map +1 -1
- package/dist/crelte.js +2 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/init/client.d.ts.map +1 -1
- package/dist/init/client.js +23 -14
- package/dist/init/server.d.ts.map +1 -1
- package/dist/init/server.js +11 -3
- package/dist/init/shared.d.ts +1 -0
- package/dist/init/shared.d.ts.map +1 -1
- package/dist/init/shared.js +16 -5
- package/dist/loadData/Globals.d.ts.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/plugins/Events.d.ts +6 -1
- package/dist/plugins/Events.d.ts.map +1 -1
- package/dist/plugins/Plugins.d.ts +36 -1
- package/dist/plugins/Plugins.d.ts.map +1 -1
- package/dist/plugins/Plugins.js +32 -0
- package/dist/routing/route/Request.d.ts +1 -1
- package/dist/routing/route/Request.d.ts.map +1 -1
- package/dist/routing/route/Request.js +7 -3
- package/dist/routing/router/ClientRouter.d.ts.map +1 -1
- package/dist/routing/router/ClientRouter.js +18 -11
- package/dist/routing/router/Router.d.ts.map +1 -1
- package/dist/routing/router/Router.js +8 -12
- package/dist/server/CrelteServer.d.ts +1 -0
- package/dist/server/CrelteServer.d.ts.map +1 -1
- package/dist/server/CrelteServer.js +5 -2
- package/dist/std/stores/StagedWritable.d.ts +48 -0
- package/dist/std/stores/StagedWritable.d.ts.map +1 -0
- package/dist/std/stores/StagedWritable.js +84 -0
- package/dist/std/stores/index.d.ts +2 -1
- package/dist/std/stores/index.d.ts.map +1 -1
- package/dist/std/stores/index.js +2 -1
- package/dist/std/sync/Barrier.js +1 -1
- package/dist/utils.d.ts +9 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +11 -0
- package/package.json +5 -1
- package/src/bodyClass/BodyClass.ts +72 -0
- package/src/bodyClass/ClientBodyClass.ts +62 -0
- package/src/bodyClass/ServerBodyClass.ts +65 -0
- package/src/bodyClass/index.ts +1 -0
- package/src/cookies/ClientCookies.ts +41 -10
- package/src/cookies/Cookies.ts +70 -0
- package/src/cookies/ServerCookies.ts +9 -6
- package/src/cookies/index.ts +5 -29
- package/src/crelte.ts +9 -0
- package/src/index.ts +15 -1
- package/src/init/client.ts +26 -14
- package/src/init/server.ts +11 -3
- package/src/init/shared.ts +18 -6
- package/src/loadData/Globals.ts +1 -1
- package/src/node/index.ts +1 -1
- package/src/plugins/Events.ts +12 -1
- package/src/plugins/Plugins.ts +66 -1
- package/src/routing/route/Request.ts +11 -4
- package/src/routing/router/ClientRouter.ts +23 -14
- package/src/routing/router/Router.ts +8 -10
- package/src/server/CrelteServer.ts +4 -2
- package/src/std/stores/StagedWritable.ts +96 -0
- package/src/std/stores/index.ts +2 -1
- package/src/std/sync/Barrier.ts +1 -1
- package/src/utils.ts +15 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import StagedWritable from '../std/stores/StagedWritable.js';
|
|
2
|
+
export default class BodyClass {
|
|
3
|
+
private inner;
|
|
4
|
+
private store;
|
|
5
|
+
constructor(inner: PlatformBodyClass, store?: StagedWritable<void>);
|
|
6
|
+
subscribe(fn: (val: BodyClass) => void, invalidate?: () => void): () => void;
|
|
7
|
+
/**
|
|
8
|
+
* Checks if the body contains the given class
|
|
9
|
+
*/
|
|
10
|
+
contains(cls: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Adds the given classes to the body
|
|
13
|
+
*/
|
|
14
|
+
add(...classes: string[]): void;
|
|
15
|
+
/**
|
|
16
|
+
* Toggles the given class on the body
|
|
17
|
+
*
|
|
18
|
+
* ## Warning
|
|
19
|
+
* toggle without `force` should almost never be used
|
|
20
|
+
* on the server. If you call this for example in loadData
|
|
21
|
+
* the server will add the class and the client will the remove
|
|
22
|
+
* it.
|
|
23
|
+
*/
|
|
24
|
+
toggle(cls: string, force?: boolean): void;
|
|
25
|
+
remove(...classes: string[]): void;
|
|
26
|
+
/** @hidden */
|
|
27
|
+
z_toRequest(): BodyClass;
|
|
28
|
+
/** @hidden */
|
|
29
|
+
z_render(): void;
|
|
30
|
+
}
|
|
31
|
+
export interface PlatformBodyClass {
|
|
32
|
+
contains(cls: string): boolean;
|
|
33
|
+
add(...classes: string[]): void;
|
|
34
|
+
toggle(cls: string, force?: boolean): void;
|
|
35
|
+
remove(...classes: string[]): void;
|
|
36
|
+
toRequest(): PlatformBodyClass;
|
|
37
|
+
render?: () => void;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=BodyClass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BodyClass.d.ts","sourceRoot":"","sources":["../../src/bodyClass/BodyClass.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,iCAAiC,CAAC;AAE7D,MAAM,CAAC,OAAO,OAAO,SAAS;IAC7B,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,KAAK,CAAuB;gBAExB,KAAK,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,cAAc,CAAC,IAAI,CAAC;IAKlE,SAAS,CACR,EAAE,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,IAAI,EAC5B,UAAU,CAAC,EAAE,MAAM,IAAI,GACrB,MAAM,IAAI;IAIb;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI9B;;OAEG;IACH,GAAG,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAK/B;;;;;;;;OAQG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;IAK1C,MAAM,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAKlC,cAAc;IACd,WAAW,IAAI,SAAS;IAIxB,cAAc;IACd,QAAQ,IAAI,IAAI;CAIhB;AAED,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B,GAAG,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAChC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3C,MAAM,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACnC,SAAS,IAAI,iBAAiB,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACpB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import StagedWritable from '../std/stores/StagedWritable.js';
|
|
2
|
+
export default class BodyClass {
|
|
3
|
+
inner;
|
|
4
|
+
store;
|
|
5
|
+
constructor(inner, store) {
|
|
6
|
+
this.inner = inner;
|
|
7
|
+
this.store = store ?? new StagedWritable(void 0);
|
|
8
|
+
}
|
|
9
|
+
subscribe(fn, invalidate) {
|
|
10
|
+
return this.store.subscribe(() => fn(this), invalidate);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Checks if the body contains the given class
|
|
14
|
+
*/
|
|
15
|
+
contains(cls) {
|
|
16
|
+
return this.inner.contains(cls);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Adds the given classes to the body
|
|
20
|
+
*/
|
|
21
|
+
add(...classes) {
|
|
22
|
+
this.inner.add(...classes);
|
|
23
|
+
this.store.set();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Toggles the given class on the body
|
|
27
|
+
*
|
|
28
|
+
* ## Warning
|
|
29
|
+
* toggle without `force` should almost never be used
|
|
30
|
+
* on the server. If you call this for example in loadData
|
|
31
|
+
* the server will add the class and the client will the remove
|
|
32
|
+
* it.
|
|
33
|
+
*/
|
|
34
|
+
toggle(cls, force) {
|
|
35
|
+
this.inner.toggle(cls, force);
|
|
36
|
+
this.store.set();
|
|
37
|
+
}
|
|
38
|
+
remove(...classes) {
|
|
39
|
+
this.inner.remove(...classes);
|
|
40
|
+
this.store.set();
|
|
41
|
+
}
|
|
42
|
+
/** @hidden */
|
|
43
|
+
z_toRequest() {
|
|
44
|
+
return new BodyClass(this.inner.toRequest(), this.store.stage());
|
|
45
|
+
}
|
|
46
|
+
/** @hidden */
|
|
47
|
+
z_render() {
|
|
48
|
+
this.inner.render?.();
|
|
49
|
+
this.store.commit();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PlatformBodyClass } from './BodyClass.js';
|
|
2
|
+
export default class ClientBodyClass implements PlatformBodyClass {
|
|
3
|
+
private inner;
|
|
4
|
+
constructor(inner?: Set<string>);
|
|
5
|
+
contains(cls: string): boolean;
|
|
6
|
+
add(...classes: string[]): void;
|
|
7
|
+
toggle(cls: string, force?: boolean): void;
|
|
8
|
+
remove(...classes: string[]): void;
|
|
9
|
+
toRequest(): ClientBodyClass;
|
|
10
|
+
render(): void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ClientBodyClass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientBodyClass.d.ts","sourceRoot":"","sources":["../../src/bodyClass/ClientBodyClass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,eAAgB,YAAW,iBAAiB;IAChE,OAAO,CAAC,KAAK,CAAqB;gBAEtB,KAAK,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;IAI/B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAK9B,GAAG,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAK/B,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;IAY1C,MAAM,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAKlC,SAAS,IAAI,eAAe;IAK5B,MAAM,IAAI,IAAI;CAgBd"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export default class ClientBodyClass {
|
|
2
|
+
inner;
|
|
3
|
+
constructor(inner) {
|
|
4
|
+
this.inner = inner ?? null;
|
|
5
|
+
}
|
|
6
|
+
contains(cls) {
|
|
7
|
+
if (this.inner)
|
|
8
|
+
return this.inner.has(cls);
|
|
9
|
+
return cl().contains(cls);
|
|
10
|
+
}
|
|
11
|
+
add(...classes) {
|
|
12
|
+
if (this.inner)
|
|
13
|
+
classes.forEach(cls => this.inner.add(cls));
|
|
14
|
+
else
|
|
15
|
+
cl().add(...classes);
|
|
16
|
+
}
|
|
17
|
+
toggle(cls, force) {
|
|
18
|
+
if (this.inner) {
|
|
19
|
+
const add = typeof force === 'boolean' ? force : !this.inner.has(cls);
|
|
20
|
+
if (add)
|
|
21
|
+
this.inner.add(cls);
|
|
22
|
+
else
|
|
23
|
+
this.inner.delete(cls);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
cl().toggle(cls, force);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
remove(...classes) {
|
|
30
|
+
if (this.inner)
|
|
31
|
+
classes.forEach(cls => this.inner.delete(cls));
|
|
32
|
+
else
|
|
33
|
+
cl().remove(...classes);
|
|
34
|
+
}
|
|
35
|
+
toRequest() {
|
|
36
|
+
const inner = new Set(cl());
|
|
37
|
+
return new ClientBodyClass(inner);
|
|
38
|
+
}
|
|
39
|
+
render() {
|
|
40
|
+
if (!this.inner)
|
|
41
|
+
throw new Error('call toRequest first');
|
|
42
|
+
const current = new Set(cl());
|
|
43
|
+
for (const cls of this.inner) {
|
|
44
|
+
const existed = current.delete(cls);
|
|
45
|
+
if (!existed)
|
|
46
|
+
cl().add(cls);
|
|
47
|
+
}
|
|
48
|
+
// now lets remove all classes that still exist in current
|
|
49
|
+
for (const cls of current) {
|
|
50
|
+
cl().remove(cls);
|
|
51
|
+
}
|
|
52
|
+
this.inner = null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function cl() {
|
|
56
|
+
return document.body.classList;
|
|
57
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PlatformBodyClass } from './BodyClass.js';
|
|
2
|
+
export default class ServerBodyClass implements PlatformBodyClass {
|
|
3
|
+
private inner;
|
|
4
|
+
constructor();
|
|
5
|
+
contains(cls: string): boolean;
|
|
6
|
+
add(...classes: string[]): void;
|
|
7
|
+
toggle(cls: string, force?: boolean): void;
|
|
8
|
+
remove(...classes: string[]): void;
|
|
9
|
+
toRequest(): ServerBodyClass;
|
|
10
|
+
z_processHtmlTemplate(html: string): string;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ServerBodyClass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServerBodyClass.d.ts","sourceRoot":"","sources":["../../src/bodyClass/ServerBodyClass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,eAAgB,YAAW,iBAAiB;IAChE,OAAO,CAAC,KAAK,CAAc;;IAM3B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI9B,GAAG,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAK/B,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;IAiB1C,MAAM,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAKlC,SAAS,IAAI,eAAe;IAI5B,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAU3C"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export default class ServerBodyClass {
|
|
2
|
+
inner;
|
|
3
|
+
constructor() {
|
|
4
|
+
this.inner = new Set();
|
|
5
|
+
}
|
|
6
|
+
contains(cls) {
|
|
7
|
+
return this.inner.has(cls);
|
|
8
|
+
}
|
|
9
|
+
add(...classes) {
|
|
10
|
+
validate(classes);
|
|
11
|
+
classes.forEach(cls => this.inner.add(cls));
|
|
12
|
+
}
|
|
13
|
+
toggle(cls, force) {
|
|
14
|
+
validate([cls]);
|
|
15
|
+
if (import.meta.env.DEV && typeof force !== 'boolean') {
|
|
16
|
+
console.warn('Using toggle without force on the server can lead ' +
|
|
17
|
+
'to unexpected results. Because in a loadData the server will add it ' +
|
|
18
|
+
'and the client will afterwards remove it.');
|
|
19
|
+
}
|
|
20
|
+
const add = typeof force === 'boolean' ? force : !this.inner.has(cls);
|
|
21
|
+
if (add)
|
|
22
|
+
this.inner.add(cls);
|
|
23
|
+
else
|
|
24
|
+
this.inner.delete(cls);
|
|
25
|
+
}
|
|
26
|
+
remove(...classes) {
|
|
27
|
+
validate(classes);
|
|
28
|
+
classes.forEach(cls => this.inner.delete(cls));
|
|
29
|
+
}
|
|
30
|
+
toRequest() {
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
z_processHtmlTemplate(html) {
|
|
34
|
+
const SEARCH_STR = '<!--body-class-->';
|
|
35
|
+
if (this.inner.size && !html.includes(SEARCH_STR)) {
|
|
36
|
+
throw new Error('index.html needs to contain `class="<!--body-class-->"`');
|
|
37
|
+
}
|
|
38
|
+
return html.replace(SEARCH_STR, Array.from(this.inner).join(' '));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function validate(classes) {
|
|
42
|
+
for (const cls of classes) {
|
|
43
|
+
if (cls.includes(' ')) {
|
|
44
|
+
throw new Error(`Invalid class name "${cls}". Class names must not contain spaces.`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bodyClass/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BodyClass } from './BodyClass.js';
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { PlatformCookies, RemoveOptions, SetOptions } from './Cookies.js';
|
|
2
|
+
import { SetCookie } from './utils.js';
|
|
3
|
+
export default class ClientCookies implements PlatformCookies {
|
|
4
|
+
private inner;
|
|
5
|
+
private setCookies;
|
|
6
|
+
constructor(inner?: Map<string, string>, setCookies?: Map<string, SetCookie>);
|
|
4
7
|
get(name: string): string | null;
|
|
5
8
|
set(name: string, value: string, opts?: SetOptions): void;
|
|
6
9
|
remove(name: string, opts?: RemoveOptions): void;
|
|
10
|
+
toRequest(): ClientCookies;
|
|
11
|
+
render(): void;
|
|
7
12
|
}
|
|
8
13
|
//# 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,
|
|
1
|
+
{"version":3,"file":"ClientCookies.d.ts","sourceRoot":"","sources":["../../src/cookies/ClientCookies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAgB,SAAS,EAAqB,MAAM,YAAY,CAAC;AAExE,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,eAAe;IAC5D,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,UAAU,CAAgC;gBAGjD,KAAK,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC3B,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC;IAMpC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAchC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI;IAOzD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,IAAI;IAIhD,SAAS,IAAI,aAAa;IAI1B,MAAM,IAAI,IAAI;CAUd"}
|
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
import { parseCookies, setCookieToString } from './utils.js';
|
|
2
|
-
// the philosophy here is that document.cookie is the source of truth
|
|
3
|
-
// so we don't cache cookies here
|
|
4
|
-
// if this changes, modify init/client.ts
|
|
5
2
|
export default class ClientCookies {
|
|
6
|
-
|
|
3
|
+
inner;
|
|
4
|
+
setCookies;
|
|
5
|
+
constructor(inner, setCookies) {
|
|
6
|
+
this.inner = inner ?? null;
|
|
7
|
+
this.setCookies = setCookies ?? null;
|
|
8
|
+
}
|
|
7
9
|
get(name) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
if (!this.inner || !this.setCookies) {
|
|
11
|
+
const cookies = getCookies();
|
|
12
|
+
return cookies.get(name) ?? null;
|
|
13
|
+
}
|
|
14
|
+
const setCookie = this.setCookies.get(name);
|
|
15
|
+
if (setCookie) {
|
|
16
|
+
return (setCookie.maxAge ?? 1) > 0 ? setCookie.value : null;
|
|
17
|
+
}
|
|
18
|
+
return this.inner.get(name) ?? null;
|
|
10
19
|
}
|
|
11
20
|
set(name, value, opts) {
|
|
12
21
|
const setCookie = { name, value, path: '/', ...opts };
|
|
13
|
-
|
|
22
|
+
if (this.setCookies)
|
|
23
|
+
this.setCookies.set(name, setCookie);
|
|
24
|
+
else
|
|
25
|
+
document.cookie = setCookieToString(setCookie);
|
|
14
26
|
}
|
|
15
27
|
remove(name, opts) {
|
|
16
28
|
this.set(name, '', { ...opts, maxAge: 0 });
|
|
17
29
|
}
|
|
30
|
+
toRequest() {
|
|
31
|
+
return new ClientCookies(getCookies(), new Map());
|
|
32
|
+
}
|
|
33
|
+
render() {
|
|
34
|
+
if (!this.setCookies)
|
|
35
|
+
throw new Error('call toRequest first');
|
|
36
|
+
for (const setCookie of this.setCookies.values()) {
|
|
37
|
+
document.cookie = setCookieToString(setCookie);
|
|
38
|
+
}
|
|
39
|
+
this.inner = null;
|
|
40
|
+
this.setCookies = null;
|
|
41
|
+
}
|
|
18
42
|
}
|
|
19
43
|
function getCookies() {
|
|
20
44
|
return parseCookies(document.cookie);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import StagedWritable from '../std/stores/StagedWritable.js';
|
|
2
|
+
export type SetOptions = {
|
|
3
|
+
maxAge?: number;
|
|
4
|
+
path?: string;
|
|
5
|
+
domain?: string;
|
|
6
|
+
secure?: boolean;
|
|
7
|
+
httpOnly?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type RemoveOptions = Omit<SetOptions, 'maxAge'>;
|
|
10
|
+
export default class Cookies {
|
|
11
|
+
private inner;
|
|
12
|
+
private store;
|
|
13
|
+
constructor(inner: PlatformCookies, store?: StagedWritable<void>);
|
|
14
|
+
subscribe(fn: (val: Cookies) => void, invalidate?: () => void): () => void;
|
|
15
|
+
/**
|
|
16
|
+
* returns the value of the cookie
|
|
17
|
+
*/
|
|
18
|
+
get(name: string): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* sets the value of the cookie
|
|
21
|
+
*
|
|
22
|
+
* #### Note
|
|
23
|
+
* path defaults to '/'
|
|
24
|
+
*/
|
|
25
|
+
set(name: string, value: string, opts?: SetOptions): void;
|
|
26
|
+
/**
|
|
27
|
+
* removes the cookie
|
|
28
|
+
*/
|
|
29
|
+
remove(name: string, opts?: RemoveOptions): void;
|
|
30
|
+
/** @hidden */
|
|
31
|
+
z_toRequest(): Cookies;
|
|
32
|
+
/** @hidden */
|
|
33
|
+
z_render(): void;
|
|
34
|
+
}
|
|
35
|
+
export interface PlatformCookies {
|
|
36
|
+
get(name: string): string | null;
|
|
37
|
+
set(name: string, value: string, opts?: SetOptions): void;
|
|
38
|
+
remove(name: string, opts?: RemoveOptions): void;
|
|
39
|
+
toRequest(): PlatformCookies;
|
|
40
|
+
render?: () => void;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=Cookies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cookies.d.ts","sourceRoot":"","sources":["../../src/cookies/Cookies.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,iCAAiC,CAAC;AAE7D,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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.js';
|
|
2
|
+
export default class Cookies {
|
|
3
|
+
inner;
|
|
4
|
+
store;
|
|
5
|
+
constructor(inner, store) {
|
|
6
|
+
this.inner = inner;
|
|
7
|
+
this.store = store ?? new StagedWritable(void 0);
|
|
8
|
+
}
|
|
9
|
+
subscribe(fn, invalidate) {
|
|
10
|
+
return this.store.subscribe(() => fn(this), invalidate);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* returns the value of the cookie
|
|
14
|
+
*/
|
|
15
|
+
get(name) {
|
|
16
|
+
return this.inner.get(name);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* sets the value of the cookie
|
|
20
|
+
*
|
|
21
|
+
* #### Note
|
|
22
|
+
* path defaults to '/'
|
|
23
|
+
*/
|
|
24
|
+
set(name, value, opts) {
|
|
25
|
+
this.inner.set(name, value, opts);
|
|
26
|
+
this.store.set();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* removes the cookie
|
|
30
|
+
*/
|
|
31
|
+
remove(name, opts) {
|
|
32
|
+
this.inner.remove(name, opts);
|
|
33
|
+
this.store.set();
|
|
34
|
+
}
|
|
35
|
+
/** @hidden */
|
|
36
|
+
z_toRequest() {
|
|
37
|
+
return new Cookies(this.inner.toRequest(), this.store.stage());
|
|
38
|
+
}
|
|
39
|
+
/** @hidden */
|
|
40
|
+
z_render() {
|
|
41
|
+
this.inner.render?.();
|
|
42
|
+
this.store.commit();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlatformCookies, RemoveOptions, SetOptions } from './Cookies.js';
|
|
2
2
|
import { type SetCookie } from './utils.js';
|
|
3
3
|
/**
|
|
4
4
|
* #### Warning
|
|
5
5
|
* This is not stable and should only be used internally by crelte
|
|
6
6
|
*/
|
|
7
|
-
export default class ServerCookies implements
|
|
7
|
+
export default class ServerCookies implements PlatformCookies {
|
|
8
8
|
requestCookies: Map<string, string>;
|
|
9
9
|
setCookies: Map<string, SetCookie>;
|
|
10
10
|
constructor(headers: Headers);
|
|
11
11
|
get(name: string): string | null;
|
|
12
12
|
set(name: string, value: string, opts?: SetOptions): void;
|
|
13
13
|
remove(name: string, opts?: RemoveOptions): void;
|
|
14
|
+
toRequest(): ServerCookies;
|
|
14
15
|
_populateHeaders(headers: Headers): void;
|
|
15
16
|
}
|
|
16
17
|
//# 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,
|
|
1
|
+
{"version":3,"file":"ServerCookies.d.ts","sourceRoot":"","sources":["../../src/cookies/ServerCookies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAgB,KAAK,SAAS,EAAqB,MAAM,YAAY,CAAC;AAE7E;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,eAAe;IAC5D,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;gBAEvB,OAAO,EAAE,OAAO;IAM5B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAShC,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,SAAS,IAAI,aAAa;IAI1B,gBAAgB,CAAC,OAAO,EAAE,OAAO;CAKjC"}
|
|
@@ -10,12 +10,11 @@ export default class ServerCookies {
|
|
|
10
10
|
this.requestCookies = parseCookies(headers.get('Cookie') ?? '');
|
|
11
11
|
this.setCookies = new Map();
|
|
12
12
|
}
|
|
13
|
-
///
|
|
13
|
+
/// Returns the value of the cookie with the given name, or null if it doesn't exist.
|
|
14
14
|
get(name) {
|
|
15
15
|
const setCookie = this.setCookies.get(name);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return setCookie.value;
|
|
16
|
+
if (setCookie) {
|
|
17
|
+
return (setCookie.maxAge ?? 1) > 0 ? setCookie.value : null;
|
|
19
18
|
}
|
|
20
19
|
return this.requestCookies.get(name) ?? null;
|
|
21
20
|
}
|
|
@@ -25,6 +24,9 @@ export default class ServerCookies {
|
|
|
25
24
|
remove(name, opts) {
|
|
26
25
|
this.set(name, '', { ...opts, maxAge: 0 });
|
|
27
26
|
}
|
|
27
|
+
toRequest() {
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
28
30
|
_populateHeaders(headers) {
|
|
29
31
|
for (const setCookie of this.setCookies.values()) {
|
|
30
32
|
headers.append('Set-Cookie', setCookieToString(setCookie));
|
package/dist/cookies/index.d.ts
CHANGED
|
@@ -1,26 +1,2 @@
|
|
|
1
|
-
export type SetOptions
|
|
2
|
-
maxAge?: number;
|
|
3
|
-
path?: string;
|
|
4
|
-
domain?: string;
|
|
5
|
-
secure?: boolean;
|
|
6
|
-
httpOnly?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export type RemoveOptions = Omit<SetOptions, 'maxAge'>;
|
|
9
|
-
export interface Cookies {
|
|
10
|
-
/**
|
|
11
|
-
* returns the value of the cookie
|
|
12
|
-
*/
|
|
13
|
-
get(name: string): string | null;
|
|
14
|
-
/**
|
|
15
|
-
* sets the value of the cookie
|
|
16
|
-
*
|
|
17
|
-
* #### Note
|
|
18
|
-
* path defaults to '/'
|
|
19
|
-
*/
|
|
20
|
-
set(name: string, value: string, opts?: SetOptions): void;
|
|
21
|
-
/**
|
|
22
|
-
* removes the cookie
|
|
23
|
-
*/
|
|
24
|
-
remove(name: string, opts?: RemoveOptions): void;
|
|
25
|
-
}
|
|
1
|
+
export { default as Cookies, type SetOptions, type RemoveOptions, } from './Cookies.js';
|
|
26
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cookies/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cookies/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,OAAO,IAAI,OAAO,EAClB,KAAK,UAAU,EACf,KAAK,aAAa,GAClB,MAAM,cAAc,CAAC"}
|
package/dist/cookies/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { default as Cookies, } from './Cookies.js';
|
package/dist/crelte.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import Site from './routing/Site.js';
|
|
|
8
8
|
import Queries, { Query, QueryOptions } from './queries/Queries.js';
|
|
9
9
|
import { Readable } from './std/stores/index.js';
|
|
10
10
|
import { Entry } from './loadData/index.js';
|
|
11
|
+
import { BodyClass } from './bodyClass/index.js';
|
|
11
12
|
/** The type for the app.config object */
|
|
12
13
|
export type Config = {
|
|
13
14
|
/**
|
|
@@ -85,6 +86,10 @@ export type Crelte = {
|
|
|
85
86
|
* Get the Cookies instance
|
|
86
87
|
*/
|
|
87
88
|
cookies: Cookies;
|
|
89
|
+
/**
|
|
90
|
+
* Get the BodyClass instance
|
|
91
|
+
*/
|
|
92
|
+
bodyClass: BodyClass;
|
|
88
93
|
/**
|
|
89
94
|
* Get a Plugin by name
|
|
90
95
|
*/
|
|
@@ -209,7 +214,7 @@ export type CrelteRequest = Crelte & {
|
|
|
209
214
|
*/
|
|
210
215
|
getGlobalAsync<T = any>(name: string): T | Promise<T | null> | null;
|
|
211
216
|
};
|
|
212
|
-
export declare function newCrelte({ config, ssrCache, plugins, events, globals, router, queries, cookies, }: {
|
|
217
|
+
export declare function newCrelte({ config, ssrCache, plugins, events, globals, router, queries, cookies, bodyClass, }: {
|
|
213
218
|
config: Required<Config>;
|
|
214
219
|
ssrCache: SsrCache;
|
|
215
220
|
plugins: Plugins;
|
|
@@ -218,6 +223,7 @@ export declare function newCrelte({ config, ssrCache, plugins, events, globals,
|
|
|
218
223
|
router: Router;
|
|
219
224
|
queries: Queries;
|
|
220
225
|
cookies: Cookies;
|
|
226
|
+
bodyClass: BodyClass;
|
|
221
227
|
}): Crelte;
|
|
222
228
|
export declare function crelteToRequest(crelte: Crelte, req?: Route | Request): CrelteRequest;
|
|
223
229
|
//# sourceMappingURL=crelte.d.ts.map
|
package/dist/crelte.d.ts.map
CHANGED
|
@@ -1 +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,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,IAAI,MAAM,mBAAmB,CAAC;AACrC,OAAO,OAAO,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;
|
|
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,qB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
|
|
|
10
10
|
debugTiming: config.debugTiming ?? false,
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
export function newCrelte({ config, ssrCache, plugins, events, globals, router, queries, cookies, }) {
|
|
13
|
+
export function newCrelte({ config, ssrCache, plugins, events, globals, router, queries, cookies, bodyClass, }) {
|
|
14
14
|
return {
|
|
15
15
|
config,
|
|
16
16
|
ssrCache,
|
|
@@ -20,6 +20,7 @@ export function newCrelte({ config, ssrCache, plugins, events, globals, router,
|
|
|
20
20
|
router,
|
|
21
21
|
queries,
|
|
22
22
|
cookies,
|
|
23
|
+
bodyClass,
|
|
23
24
|
getPlugin: name => plugins.get(name),
|
|
24
25
|
getEnv: key => ssrCache.get(key),
|
|
25
26
|
frontendUrl: path => urlWithPath(ssrCache.get('FRONTEND_URL'), path),
|
package/dist/index.d.ts
CHANGED
|
@@ -5,10 +5,15 @@ import { type Crelte, type CrelteRequest, type CrelteWithRoute, type Config } fr
|
|
|
5
5
|
import type { Cookies } from './cookies/index.js';
|
|
6
6
|
import { Entry, LoadData, LoadDataArray, LoadDataFn, LoadDataObj } from './loadData/index.js';
|
|
7
7
|
import Queries from './queries/Queries.js';
|
|
8
|
-
import { Readable } from './std/stores/index.js';
|
|
8
|
+
import { Readable, Writable } from './std/stores/index.js';
|
|
9
|
+
import { BodyClass } from './bodyClass/index.js';
|
|
9
10
|
export { type Crelte, type CrelteWithRoute, type CrelteRequest, type Config, type LoadData, type LoadDataFn, type LoadDataObj, type LoadDataArray, };
|
|
10
11
|
/** The type for the app.init function */
|
|
11
12
|
export type Init = (crelte: Crelte) => void;
|
|
13
|
+
/** The Props that are passed to the app */
|
|
14
|
+
export type AppProps = {
|
|
15
|
+
route: Writable<Route>;
|
|
16
|
+
};
|
|
12
17
|
/**
|
|
13
18
|
* Get Crelte from the current context
|
|
14
19
|
*
|
|
@@ -98,6 +103,13 @@ export declare function getGlobal<T = any>(name: string): Readable<T> | null;
|
|
|
98
103
|
* This only works during component initialisation.
|
|
99
104
|
*/
|
|
100
105
|
export declare function getCookies(): Cookies;
|
|
106
|
+
/**
|
|
107
|
+
* returns the body class instance
|
|
108
|
+
*
|
|
109
|
+
* #### Note
|
|
110
|
+
* This only works during component initialisation.
|
|
111
|
+
*/
|
|
112
|
+
export declare function getBodyClass(): BodyClass;
|
|
101
113
|
/**
|
|
102
114
|
* Listen for route changes
|
|
103
115
|
*
|
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,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,yCAAyC;AACzC,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,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,IAAI,QAAQ,CAAC,IAAI,CAAC,CAExC;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,CAE1C;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAAC;AACrD,wBAAgB,MAAM,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAAC;AACtD,wBAAgB,MAAM,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAAC;AACrD,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAKpD;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,QAAQ,CAAC,OAAO,CAAC,CAE9C;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,QAAQ,CAAC,MAAM,CAAC,CAErD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAEnE;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAExC;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,QAIjD;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,aAAa,KAAK,IAAI,QAIxD"}
|
package/dist/index.js
CHANGED
|
@@ -114,6 +114,15 @@ export function getGlobal(name) {
|
|
|
114
114
|
export function getCookies() {
|
|
115
115
|
return innerGetCrelte().cookies;
|
|
116
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* returns the body class instance
|
|
119
|
+
*
|
|
120
|
+
* #### Note
|
|
121
|
+
* This only works during component initialisation.
|
|
122
|
+
*/
|
|
123
|
+
export function getBodyClass() {
|
|
124
|
+
return innerGetCrelte().bodyClass;
|
|
125
|
+
}
|
|
117
126
|
/**
|
|
118
127
|
* Listen for route changes
|
|
119
128
|
*
|
|
@@ -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":"AA0BA;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB,4BAA4B;IAC5B,GAAG,EAAE,GAAG,CAAC;IACT,8BAA8B;IAC9B,SAAS,EAAE,GAAG,CAAC;CACf,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAsB,IAAI,CAAC,IAAI,EAAE,QAAQ,iBAqKxC"}
|