@nordcraft/ssr 1.0.77 → 1.0.78
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/rendering/html.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ export declare const getHtmlLanguage: ({ pageInfo, formulaContext, defaultLangua
|
|
|
4
4
|
language?: import("@nordcraft/core/dist/types").Nullable<{
|
|
5
5
|
formula: import("@nordcraft/core/dist/formula/formula").Formula;
|
|
6
6
|
}>;
|
|
7
|
+
theme?: import("@nordcraft/core/dist/types").Nullable<{
|
|
8
|
+
formula: import("@nordcraft/core/dist/formula/formula").Formula;
|
|
9
|
+
}>;
|
|
7
10
|
title?: import("@nordcraft/core/dist/types").Nullable<{
|
|
8
11
|
formula: import("@nordcraft/core/dist/formula/formula").Formula;
|
|
9
12
|
}>;
|
|
@@ -26,6 +29,9 @@ export declare const getCharset: ({ pageInfo, formulaContext, defaultCharset, }:
|
|
|
26
29
|
language?: import("@nordcraft/core/dist/types").Nullable<{
|
|
27
30
|
formula: import("@nordcraft/core/dist/formula/formula").Formula;
|
|
28
31
|
}>;
|
|
32
|
+
theme?: import("@nordcraft/core/dist/types").Nullable<{
|
|
33
|
+
formula: import("@nordcraft/core/dist/formula/formula").Formula;
|
|
34
|
+
}>;
|
|
29
35
|
title?: import("@nordcraft/core/dist/types").Nullable<{
|
|
30
36
|
formula: import("@nordcraft/core/dist/formula/formula").Formula;
|
|
31
37
|
}>;
|
|
@@ -43,3 +49,27 @@ export declare const getCharset: ({ pageInfo, formulaContext, defaultCharset, }:
|
|
|
43
49
|
formulaContext: FormulaContext;
|
|
44
50
|
defaultCharset?: string | undefined;
|
|
45
51
|
}) => string;
|
|
52
|
+
export declare const getTheme: ({ pageInfo, formulaContext, }: {
|
|
53
|
+
pageInfo?: import("@nordcraft/core/dist/types").Nullable<{
|
|
54
|
+
language?: import("@nordcraft/core/dist/types").Nullable<{
|
|
55
|
+
formula: import("@nordcraft/core/dist/formula/formula").Formula;
|
|
56
|
+
}>;
|
|
57
|
+
theme?: import("@nordcraft/core/dist/types").Nullable<{
|
|
58
|
+
formula: import("@nordcraft/core/dist/formula/formula").Formula;
|
|
59
|
+
}>;
|
|
60
|
+
title?: import("@nordcraft/core/dist/types").Nullable<{
|
|
61
|
+
formula: import("@nordcraft/core/dist/formula/formula").Formula;
|
|
62
|
+
}>;
|
|
63
|
+
description?: import("@nordcraft/core/dist/types").Nullable<{
|
|
64
|
+
formula: import("@nordcraft/core/dist/formula/formula").Formula;
|
|
65
|
+
}>;
|
|
66
|
+
icon?: import("@nordcraft/core/dist/types").Nullable<{
|
|
67
|
+
formula: import("@nordcraft/core/dist/formula/formula").Formula;
|
|
68
|
+
}>;
|
|
69
|
+
charset?: import("@nordcraft/core/dist/types").Nullable<{
|
|
70
|
+
formula: import("@nordcraft/core/dist/formula/formula").Formula;
|
|
71
|
+
}>;
|
|
72
|
+
meta?: import("@nordcraft/core/dist/types").Nullable<Record<string, import("@nordcraft/core/dist/component/component.types").MetaEntry>>;
|
|
73
|
+
}>;
|
|
74
|
+
formulaContext: FormulaContext;
|
|
75
|
+
}) => string | null;
|
package/dist/rendering/html.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { applyFormula } from '@nordcraft/core/dist/formula/formula';
|
|
2
|
+
import { THEME_COOKIE_NAME } from '@nordcraft/core/dist/styling/theme.const';
|
|
2
3
|
export const getHtmlLanguage = ({ pageInfo, formulaContext, defaultLanguage = 'en', }) => {
|
|
3
4
|
const language = pageInfo?.language
|
|
4
5
|
? applyFormula(pageInfo.language.formula, formulaContext)
|
|
@@ -11,4 +12,10 @@ export const getCharset = ({ pageInfo, formulaContext, defaultCharset = 'utf-8',
|
|
|
11
12
|
: defaultCharset;
|
|
12
13
|
return typeof charset === 'string' ? charset : defaultCharset;
|
|
13
14
|
};
|
|
15
|
+
export const getTheme = ({ pageInfo, formulaContext, }) => {
|
|
16
|
+
const theme = pageInfo?.theme?.formula
|
|
17
|
+
? applyFormula(pageInfo.theme.formula, formulaContext)
|
|
18
|
+
: formulaContext.env?.request?.cookies[THEME_COOKIE_NAME];
|
|
19
|
+
return typeof theme === 'string' ? theme : null;
|
|
20
|
+
};
|
|
14
21
|
//# sourceMappingURL=html.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/rendering/html.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/rendering/html.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAA;AAE5E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,QAAQ,EACR,cAAc,EACd,eAAe,GAAG,IAAI,GAKvB,EAAE,EAAE,CAAC;IACJ,MAAM,QAAQ,GAAG,QAAQ,EAAE,QAAQ;QACjC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;QACzD,CAAC,CAAC,eAAe,CAAA;IACnB,OAAO,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAA;AAAA,CACjE,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,QAAQ,EACR,cAAc,EACd,cAAc,GAAG,OAAO,GAKzB,EAAE,EAAE,CAAC;IACJ,MAAM,OAAO,GAAG,QAAQ,EAAE,OAAO;QAC/B,CAAC,CAAE,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,cAAc,CAAY;QACpE,CAAC,CAAC,cAAc,CAAA;IAClB,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAA;AAAA,CAC9D,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,QAAQ,EACR,cAAc,GAIf,EAAE,EAAE,CAAC;IACJ,MAAM,KAAK,GAAG,QAAQ,EAAE,KAAK,EAAE,OAAO;QACpC,CAAC,CAAE,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,cAAc,CAAY;QAClE,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAC3D,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;AAAA,CAChD,CAAA"}
|
package/package.json
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://github.com/nordcraftengine/nordcraft",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/nordcraftengine/nordcraft.git",
|
|
9
|
+
"directory": "packages/ssr"
|
|
10
|
+
},
|
|
6
11
|
"scripts": {
|
|
7
12
|
"build": "tsgo",
|
|
8
13
|
"npm-publish": "bun run build && bun publish --access public",
|
|
@@ -16,11 +21,11 @@
|
|
|
16
21
|
"main": "dist/index.js",
|
|
17
22
|
"types": "dist/index.d.ts",
|
|
18
23
|
"dependencies": {
|
|
19
|
-
"@nordcraft/core": "1.0.
|
|
20
|
-
"@nordcraft/std-lib": "1.0.
|
|
24
|
+
"@nordcraft/core": "1.0.78",
|
|
25
|
+
"@nordcraft/std-lib": "1.0.78",
|
|
21
26
|
"fast-deep-equal": "3.1.3",
|
|
22
27
|
"cookie": "1.0.2",
|
|
23
28
|
"xss": "1.0.15"
|
|
24
29
|
},
|
|
25
|
-
"version": "1.0.
|
|
30
|
+
"version": "1.0.78"
|
|
26
31
|
}
|
package/src/rendering/html.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PageRoute } from '@nordcraft/core/dist/component/component.types'
|
|
2
2
|
import type { FormulaContext } from '@nordcraft/core/dist/formula/formula'
|
|
3
3
|
import { applyFormula } from '@nordcraft/core/dist/formula/formula'
|
|
4
|
+
import { THEME_COOKIE_NAME } from '@nordcraft/core/dist/styling/theme.const'
|
|
4
5
|
|
|
5
6
|
export const getHtmlLanguage = ({
|
|
6
7
|
pageInfo,
|
|
@@ -31,3 +32,16 @@ export const getCharset = ({
|
|
|
31
32
|
: defaultCharset
|
|
32
33
|
return typeof charset === 'string' ? charset : defaultCharset
|
|
33
34
|
}
|
|
35
|
+
|
|
36
|
+
export const getTheme = ({
|
|
37
|
+
pageInfo,
|
|
38
|
+
formulaContext,
|
|
39
|
+
}: {
|
|
40
|
+
pageInfo?: PageRoute['info']
|
|
41
|
+
formulaContext: FormulaContext
|
|
42
|
+
}) => {
|
|
43
|
+
const theme = pageInfo?.theme?.formula
|
|
44
|
+
? (applyFormula(pageInfo.theme.formula, formulaContext) as string)
|
|
45
|
+
: formulaContext.env?.request?.cookies[THEME_COOKIE_NAME]
|
|
46
|
+
return typeof theme === 'string' ? theme : null
|
|
47
|
+
}
|