@constela/start 1.5.1 → 1.5.4
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.
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
generateMetaTags,
|
|
4
4
|
renderPage,
|
|
5
5
|
wrapHtml
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PG3Y4EJN.js";
|
|
7
7
|
|
|
8
8
|
// src/router/file-router.ts
|
|
9
9
|
import fg from "fast-glob";
|
|
@@ -2496,6 +2496,7 @@ h1 { color: #666; }
|
|
|
2496
2496
|
import { existsSync as existsSync8, readFileSync as readFileSync5 } from "fs";
|
|
2497
2497
|
import { mkdir as mkdir2, writeFile, cp, readdir } from "fs/promises";
|
|
2498
2498
|
import { join as join9, dirname as dirname5, relative as relative3, basename as basename4, isAbsolute as isAbsolute3, resolve as resolve4 } from "path";
|
|
2499
|
+
import { isCookieInitialExpr as isCookieInitialExpr3 } from "@constela/core";
|
|
2499
2500
|
|
|
2500
2501
|
// src/build/bundler.ts
|
|
2501
2502
|
import * as esbuild from "esbuild";
|
|
@@ -3092,9 +3093,17 @@ async function renderPageToHtml(program, params, runtimePath, cssPath, externalI
|
|
|
3092
3093
|
wrapOptions.importMap = externalImports;
|
|
3093
3094
|
}
|
|
3094
3095
|
const themeState = program.state?.["theme"];
|
|
3095
|
-
if (themeState
|
|
3096
|
-
|
|
3097
|
-
|
|
3096
|
+
if (themeState) {
|
|
3097
|
+
let defaultTheme;
|
|
3098
|
+
if (isCookieInitialExpr3(themeState.initial)) {
|
|
3099
|
+
defaultTheme = themeState.initial.default;
|
|
3100
|
+
} else if (typeof themeState.initial === "string") {
|
|
3101
|
+
defaultTheme = themeState.initial;
|
|
3102
|
+
}
|
|
3103
|
+
if (defaultTheme) {
|
|
3104
|
+
wrapOptions.defaultTheme = defaultTheme;
|
|
3105
|
+
wrapOptions.themeStorageKey = "theme";
|
|
3106
|
+
}
|
|
3098
3107
|
}
|
|
3099
3108
|
return wrapHtml(
|
|
3100
3109
|
content,
|
|
@@ -121,9 +121,23 @@ ${importMapJson}
|
|
|
121
121
|
themeScript = `<script>
|
|
122
122
|
(function() {
|
|
123
123
|
try {
|
|
124
|
-
var
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
var theme;
|
|
125
|
+
// Check cookie first (for SSR/SSG sync)
|
|
126
|
+
var cookies = document.cookie.split(';');
|
|
127
|
+
for (var i = 0; i < cookies.length; i++) {
|
|
128
|
+
var cookie = cookies[i].trim();
|
|
129
|
+
if (cookie.indexOf('${options.themeStorageKey}=') === 0) {
|
|
130
|
+
theme = decodeURIComponent(cookie.substring('${options.themeStorageKey}='.length));
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// Fallback to localStorage
|
|
135
|
+
if (!theme) {
|
|
136
|
+
var raw = localStorage.getItem('${options.themeStorageKey}');
|
|
137
|
+
theme = raw;
|
|
138
|
+
try { theme = JSON.parse(raw); } catch (e) {}
|
|
139
|
+
}
|
|
140
|
+
// Apply theme
|
|
127
141
|
if (theme === 'dark') {
|
|
128
142
|
document.documentElement.classList.add('dark');
|
|
129
143
|
} else if (theme === 'light') {
|
package/dist/cli/index.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -28,18 +28,19 @@ import {
|
|
|
28
28
|
transformCsv,
|
|
29
29
|
transformMdx,
|
|
30
30
|
transformYaml
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-FKQKP2UH.js";
|
|
32
32
|
import {
|
|
33
33
|
evaluateMetaExpression,
|
|
34
34
|
generateHydrationScript,
|
|
35
35
|
generateMetaTags,
|
|
36
36
|
renderPage,
|
|
37
37
|
wrapHtml
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-PG3Y4EJN.js";
|
|
39
39
|
|
|
40
40
|
// src/build/ssg.ts
|
|
41
41
|
import { mkdir, writeFile } from "fs/promises";
|
|
42
42
|
import { join, dirname } from "path";
|
|
43
|
+
import { isCookieInitialExpr } from "@constela/core";
|
|
43
44
|
var defaultProgram = {
|
|
44
45
|
version: "1.0",
|
|
45
46
|
state: {},
|
|
@@ -106,9 +107,17 @@ async function generateSinglePage(pattern, outDir, program, params = {}) {
|
|
|
106
107
|
});
|
|
107
108
|
const wrapOptions = {};
|
|
108
109
|
const themeState = program.state?.["theme"];
|
|
109
|
-
if (themeState
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
if (themeState) {
|
|
111
|
+
let defaultTheme;
|
|
112
|
+
if (isCookieInitialExpr(themeState.initial)) {
|
|
113
|
+
defaultTheme = themeState.initial.default;
|
|
114
|
+
} else if (typeof themeState.initial === "string") {
|
|
115
|
+
defaultTheme = themeState.initial;
|
|
116
|
+
}
|
|
117
|
+
if (defaultTheme) {
|
|
118
|
+
wrapOptions.defaultTheme = defaultTheme;
|
|
119
|
+
wrapOptions.themeStorageKey = "theme";
|
|
120
|
+
}
|
|
112
121
|
}
|
|
113
122
|
const html = wrapHtml(
|
|
114
123
|
content,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constela/start",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.4",
|
|
4
4
|
"description": "Meta-framework for Constela applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"postcss": "^8.5.0",
|
|
44
44
|
"@tailwindcss/postcss": "^4.0.0",
|
|
45
45
|
"tailwindcss": "^4.0.0",
|
|
46
|
-
"@constela/compiler": "0.11.1",
|
|
47
46
|
"@constela/core": "0.12.0",
|
|
48
|
-
"@constela/runtime": "0.15.
|
|
47
|
+
"@constela/runtime": "0.15.1",
|
|
48
|
+
"@constela/compiler": "0.11.1",
|
|
49
49
|
"@constela/server": "8.0.0",
|
|
50
50
|
"@constela/router": "13.0.0"
|
|
51
51
|
},
|