@constela/start 1.5.0 → 1.5.2

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-LCCIX5MB.js";
6
+ } from "./chunk-PG3Y4EJN.js";
7
7
 
8
8
  // src/router/file-router.ts
9
9
  import fg from "fast-glob";
@@ -1307,6 +1307,7 @@ async function resolvePageExport(pageDefault, params, expectedParams) {
1307
1307
 
1308
1308
  // src/edge/adapter.ts
1309
1309
  import { matchRoute } from "@constela/router";
1310
+ import { isCookieInitialExpr } from "@constela/core";
1310
1311
  async function defaultLoadModule(file) {
1311
1312
  return import(file);
1312
1313
  }
@@ -1395,7 +1396,15 @@ function createAdapter(options) {
1395
1396
  };
1396
1397
  const hydrationScript = generateHydrationScript(program, void 0, routeContext);
1397
1398
  const themeState = program.state?.["theme"];
1398
- const initialTheme = themeState?.initial;
1399
+ let initialTheme;
1400
+ if (themeState) {
1401
+ if (isCookieInitialExpr(themeState.initial)) {
1402
+ const cookieValue = cookies[themeState.initial.key];
1403
+ initialTheme = cookieValue ?? themeState.initial.default;
1404
+ } else if (typeof themeState.initial === "string") {
1405
+ initialTheme = themeState.initial;
1406
+ }
1407
+ }
1399
1408
  const html = wrapHtml(content, hydrationScript, void 0, initialTheme ? {
1400
1409
  theme: initialTheme,
1401
1410
  defaultTheme: initialTheme,
@@ -1609,6 +1618,7 @@ import { createServer } from "http";
1609
1618
  import { createReadStream } from "fs";
1610
1619
  import { join as join7, isAbsolute } from "path";
1611
1620
  import { createServer as createViteServer } from "vite";
1621
+ import { isCookieInitialExpr as isCookieInitialExpr2 } from "@constela/core";
1612
1622
 
1613
1623
  // src/json-page-loader.ts
1614
1624
  import { existsSync as existsSync6, readFileSync as readFileSync4 } from "fs";
@@ -2377,7 +2387,15 @@ async function createDevServer(options = {}) {
2377
2387
  const cssHead = css ? (Array.isArray(css) ? css : [css]).map((p) => `<link rel="stylesheet" href="/${p}">`).join("\n") : "";
2378
2388
  const head = [metaTags, cssHead].filter(Boolean).join("\n");
2379
2389
  const themeState = composedProgram.state?.["theme"];
2380
- const initialTheme = themeState?.initial;
2390
+ let initialTheme;
2391
+ if (themeState) {
2392
+ if (isCookieInitialExpr2(themeState.initial)) {
2393
+ const cookieValue = cookies[themeState.initial.key];
2394
+ initialTheme = cookieValue ?? themeState.initial.default;
2395
+ } else if (typeof themeState.initial === "string") {
2396
+ initialTheme = themeState.initial;
2397
+ }
2398
+ }
2381
2399
  const importMap = {
2382
2400
  "@constela/runtime": "/node_modules/@constela/runtime/dist/index.js",
2383
2401
  "@constela/core": "/node_modules/@constela/core/dist/index.js",
@@ -121,9 +121,23 @@ ${importMapJson}
121
121
  themeScript = `<script>
122
122
  (function() {
123
123
  try {
124
- var raw = localStorage.getItem('${options.themeStorageKey}');
125
- var theme = raw;
126
- try { theme = JSON.parse(raw); } catch (e) {}
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
@@ -4,8 +4,8 @@ import {
4
4
  hyperlink,
5
5
  loadConfig,
6
6
  resolveConfig
7
- } from "../chunk-NYYUZJG5.js";
8
- import "../chunk-LCCIX5MB.js";
7
+ } from "../chunk-2QR63VOH.js";
8
+ import "../chunk-PG3Y4EJN.js";
9
9
 
10
10
  // src/cli/index.ts
11
11
  import { Command } from "commander";
package/dist/index.js CHANGED
@@ -28,14 +28,14 @@ import {
28
28
  transformCsv,
29
29
  transformMdx,
30
30
  transformYaml
31
- } from "./chunk-NYYUZJG5.js";
31
+ } from "./chunk-2QR63VOH.js";
32
32
  import {
33
33
  evaluateMetaExpression,
34
34
  generateHydrationScript,
35
35
  generateMetaTags,
36
36
  renderPage,
37
37
  wrapHtml
38
- } from "./chunk-LCCIX5MB.js";
38
+ } from "./chunk-PG3Y4EJN.js";
39
39
 
40
40
  // src/build/ssg.ts
41
41
  import { mkdir, writeFile } from "fs/promises";
@@ -4,7 +4,7 @@ import {
4
4
  generateMetaTags,
5
5
  renderPage,
6
6
  wrapHtml
7
- } from "../chunk-LCCIX5MB.js";
7
+ } from "../chunk-PG3Y4EJN.js";
8
8
  export {
9
9
  evaluateMetaExpression,
10
10
  generateHydrationScript,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constela/start",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "Meta-framework for Constela applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -45,9 +45,9 @@
45
45
  "tailwindcss": "^4.0.0",
46
46
  "@constela/compiler": "0.11.1",
47
47
  "@constela/core": "0.12.0",
48
- "@constela/server": "8.0.0",
49
48
  "@constela/runtime": "0.15.0",
50
- "@constela/router": "13.0.0"
49
+ "@constela/router": "13.0.0",
50
+ "@constela/server": "8.0.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/mdast": "^4.0.4",