@nordcraft/ssr 1.0.76 → 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/fonts.js
CHANGED
|
@@ -6,7 +6,7 @@ export const getFontCssUrl = ({ fonts, baseForAbsoluteUrls, basePath = '/.toddle
|
|
|
6
6
|
const searchParams = new URLSearchParams();
|
|
7
7
|
searchParams.set('display', 'swap');
|
|
8
8
|
for (const font of fonts) {
|
|
9
|
-
const sortedWeights = easySort(font.variants.filter((v) => !Number.isNaN(Number(v.weight))), (v) => Number(v.weight));
|
|
9
|
+
const sortedWeights = easySort((font.variants ?? []).filter((v) => !Number.isNaN(Number(v.weight))), (v) => Number(v.weight));
|
|
10
10
|
if (sortedWeights.length === 0) {
|
|
11
11
|
continue;
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fonts.js","sourceRoot":"","sources":["../../src/rendering/fonts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAA;AAEjE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,KAAK,EACL,mBAAmB,EACnB,QAAQ,GAAG,gCAAgC,GAK5C,EAAsC,EAAE,CAAC;IACxC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAM;IACR,CAAC;IACD,MAAM,YAAY,GAAG,IAAI,eAAe,EAAE,CAAA;IAC1C,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;IACnC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,aAAa,GAAG,QAAQ,CAC5B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":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,IAAI,CAAA;QACV,OAAO;YACL,6EAA6E;YAC7E,+FAA+F;YAC/F,IAAI,EAAE,GAAG;SACV,CAAA;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAClB,CAAC;AAAA,CACF,CAAA"}
|
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/fonts.ts
CHANGED
|
@@ -17,7 +17,7 @@ export const getFontCssUrl = ({
|
|
|
17
17
|
searchParams.set('display', 'swap')
|
|
18
18
|
for (const font of fonts) {
|
|
19
19
|
const sortedWeights = easySort(
|
|
20
|
-
font.variants.filter((v) => !Number.isNaN(Number(v.weight))),
|
|
20
|
+
(font.variants ?? []).filter((v) => !Number.isNaN(Number(v.weight))),
|
|
21
21
|
(v) => Number(v.weight),
|
|
22
22
|
)
|
|
23
23
|
if (sortedWeights.length === 0) {
|
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
|
+
}
|