@dheme/next 1.3.0 → 1.4.0
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/server.js +9 -9
- package/dist/server.mjs +2 -2
- package/package.json +2 -2
package/dist/server.js
CHANGED
|
@@ -41,7 +41,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
41
41
|
// src/components/DhemeScript.tsx
|
|
42
42
|
var import_react = __toESM(require("react"));
|
|
43
43
|
var import_sdk = require("@dheme/sdk");
|
|
44
|
-
var
|
|
44
|
+
var import_utils = require("@dheme/react/utils");
|
|
45
45
|
|
|
46
46
|
// src/server/cache.ts
|
|
47
47
|
var ThemeCache = class {
|
|
@@ -84,7 +84,7 @@ async function DhemeScript({
|
|
|
84
84
|
nonce
|
|
85
85
|
}) {
|
|
86
86
|
const params = { theme, ...themeParams };
|
|
87
|
-
const cacheKey = (0,
|
|
87
|
+
const cacheKey = (0, import_utils.buildCacheKey)(params);
|
|
88
88
|
let themeData = themeCache.get(cacheKey);
|
|
89
89
|
if (!themeData) {
|
|
90
90
|
const client = new import_sdk.DhemeClient({ apiKey, baseUrl });
|
|
@@ -92,10 +92,10 @@ async function DhemeScript({
|
|
|
92
92
|
themeData = response.data;
|
|
93
93
|
themeCache.set(cacheKey, themeData);
|
|
94
94
|
}
|
|
95
|
-
const lightCSS = (0,
|
|
96
|
-
const darkCSS = (0,
|
|
95
|
+
const lightCSS = (0, import_utils.themeToCSS)(themeData, "light");
|
|
96
|
+
const darkCSS = (0, import_utils.themeToCSS)(themeData, "dark");
|
|
97
97
|
const styleContent = `:root{${lightCSS}}.dark{${darkCSS}}`;
|
|
98
|
-
const scriptContent = (0,
|
|
98
|
+
const scriptContent = (0, import_utils.getNextBlockingScriptPayload)(defaultMode);
|
|
99
99
|
return import_react.default.createElement(
|
|
100
100
|
import_react.default.Fragment,
|
|
101
101
|
null,
|
|
@@ -112,20 +112,20 @@ async function DhemeScript({
|
|
|
112
112
|
|
|
113
113
|
// src/server/generateThemeStyles.ts
|
|
114
114
|
var import_sdk2 = require("@dheme/sdk");
|
|
115
|
-
var
|
|
115
|
+
var import_utils2 = require("@dheme/react/utils");
|
|
116
116
|
async function generateThemeStyles(options) {
|
|
117
117
|
const { apiKey, theme, themeParams, mode = "light", baseUrl } = options;
|
|
118
118
|
const params = { theme, ...themeParams };
|
|
119
|
-
const cacheKey = (0,
|
|
119
|
+
const cacheKey = (0, import_utils2.buildCacheKey)(params);
|
|
120
120
|
const cached = themeCache.get(cacheKey);
|
|
121
121
|
if (cached) {
|
|
122
|
-
return (0,
|
|
122
|
+
return (0, import_utils2.themeToCSS)(cached, mode);
|
|
123
123
|
}
|
|
124
124
|
const client = new import_sdk2.DhemeClient({ apiKey, baseUrl });
|
|
125
125
|
const response = await client.generateTheme(params);
|
|
126
126
|
const data = response.data;
|
|
127
127
|
themeCache.set(cacheKey, data);
|
|
128
|
-
return (0,
|
|
128
|
+
return (0, import_utils2.themeToCSS)(data, mode);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
// src/server/cookies.ts
|
package/dist/server.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/components/DhemeScript.tsx
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { DhemeClient } from "@dheme/sdk";
|
|
4
|
-
import { themeToCSS, buildCacheKey, getNextBlockingScriptPayload } from "@dheme/react";
|
|
4
|
+
import { themeToCSS, buildCacheKey, getNextBlockingScriptPayload } from "@dheme/react/utils";
|
|
5
5
|
|
|
6
6
|
// src/server/cache.ts
|
|
7
7
|
var ThemeCache = class {
|
|
@@ -72,7 +72,7 @@ async function DhemeScript({
|
|
|
72
72
|
|
|
73
73
|
// src/server/generateThemeStyles.ts
|
|
74
74
|
import { DhemeClient as DhemeClient2 } from "@dheme/sdk";
|
|
75
|
-
import { themeToCSS as themeToCSS2, buildCacheKey as buildCacheKey2 } from "@dheme/react";
|
|
75
|
+
import { themeToCSS as themeToCSS2, buildCacheKey as buildCacheKey2 } from "@dheme/react/utils";
|
|
76
76
|
async function generateThemeStyles(options) {
|
|
77
77
|
const { apiKey, theme, themeParams, mode = "light", baseUrl } = options;
|
|
78
78
|
const params = { theme, ...themeParams };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dheme/next",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Next.js App Router bindings for Dheme SDK with server-side theme generation",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@dheme/sdk": "^1.1.0",
|
|
59
|
-
"@dheme/react": "^2.
|
|
59
|
+
"@dheme/react": "^2.4.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/react": "^18.2.0",
|