@uniweb/core 0.7.23 → 0.7.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/core",
3
- "version": "0.7.23",
3
+ "version": "0.7.24",
4
4
  "description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
5
5
  "type": "module",
6
6
  "exports": {
@@ -31,8 +31,8 @@
31
31
  "vitest": "^4.1.7"
32
32
  },
33
33
  "dependencies": {
34
- "@uniweb/semantic-parser": "1.1.18",
35
- "@uniweb/theming": "0.1.9"
34
+ "@uniweb/theming": "0.1.10",
35
+ "@uniweb/semantic-parser": "1.1.18"
36
36
  },
37
37
  "scripts": {
38
38
  "test": "vitest run"
package/src/index.js CHANGED
@@ -12,7 +12,7 @@ export { Uniweb }
12
12
  export { default as Website } from './website.js'
13
13
  export { default as Page } from './page.js'
14
14
  export { default as Block } from './block.js'
15
- export { default as Theme } from './theme.js'
15
+ export { default as Theme, hasDarkScheme } from './theme.js'
16
16
  export { default as DataStore, deriveCacheKey } from './datastore.js'
17
17
  export { default as EntityStore } from './entity-store.js'
18
18
  export { default as FetcherDispatcher } from './fetcher-dispatcher.js'
package/src/theme.js CHANGED
@@ -404,3 +404,33 @@ export default class Theme {
404
404
  }
405
405
  }
406
406
  }
407
+
408
+ /**
409
+ * Does a site's appearance config make the dark scheme reachable at all?
410
+ *
411
+ * This is the behavioral "can this site ever show dark" predicate — distinct
412
+ * from Theme.supportsScheme(), which literally answers "is this scheme listed
413
+ * in `schemes:`". A site reaches dark if it offers a toggle, defaults to dark
414
+ * or system, or explicitly lists dark in `schemes`.
415
+ *
416
+ * CANONICAL SHARED PREDICATE. It MUST stay in lockstep with the dark-CSS
417
+ * emission guard in @uniweb/theming's css-generator.js (`generateThemeCSS`,
418
+ * "Dark scheme support" block): that guard decides whether the `.scheme-dark`
419
+ * rules physically exist, and this decides whether the runtime may boot into
420
+ * or switch to dark. If the two disagree, you get a scheme with no matching
421
+ * CSS (page claims dark, renders light) — the exact desync class this unifies
422
+ * away. @uniweb/theming cannot import @uniweb/core, so its copy is annotated to
423
+ * point here; everything that consumes the model (runtime boot, kit's
424
+ * useAppearance) imports THIS one.
425
+ *
426
+ * @param {Object} appearance - the resolved theme.yml `appearance:` block
427
+ * @returns {boolean}
428
+ */
429
+ export function hasDarkScheme(appearance = {}) {
430
+ return Boolean(
431
+ appearance.allowToggle ||
432
+ appearance.default === 'dark' ||
433
+ appearance.default === 'system' ||
434
+ appearance.schemes?.includes('dark')
435
+ )
436
+ }