@molecule/app-svelte 4.0.1 → 4.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/stores/theme.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAE/D,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAI/D;;GAEG;AACH,UAAU,WAAW;IACnB,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAA;IACtB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IAC7B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,WAAW,EAAE,MAAM,IAAI,CAAA;CACxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;CAAE,CAgDvF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAExF;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,aAAa,GAAG,WAAW,CA+BlF"}
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/stores/theme.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,KAAK,QAAQ,EAAY,MAAM,cAAc,CAAA;AAE/D,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAI/D;;GAEG;AACH,UAAU,WAAW;IACnB,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAA;IACtB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IAC7B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,WAAW,EAAE,MAAM,IAAI,CAAA;CACxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;CAAE,CAGvF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAExF;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,aAAa,GAAG,WAAW,CA6BlF"}
@@ -25,43 +25,8 @@ import { getThemeProvider } from '../context.js';
25
25
  * ```
26
26
  */
27
27
  export function createThemeStores() {
28
- const provider = getThemeProvider();
29
- // Main theme store
30
- const theme = readable(provider.getTheme(), (set) => {
31
- return provider.subscribe(() => {
32
- set(provider.getTheme());
33
- });
34
- });
35
- // Theme name store
36
- const themeName = readable(provider.getTheme().name, (set) => {
37
- return provider.subscribe(() => {
38
- set(provider.getTheme().name);
39
- });
40
- });
41
- // Derived stores
42
- const mode = derived(theme, ($theme) => $theme.mode);
43
- const colors = derived(theme, ($theme) => $theme.colors);
44
- // Get available themes
45
- const themes = provider.getThemes?.() ?? [];
46
- // Actions
47
- const setTheme = (name) => {
48
- provider.setTheme(name);
49
- };
50
- const toggleTheme = () => {
51
- const currentName = provider.getTheme().name;
52
- const currentIndex = themes.findIndex((t) => t.name === currentName);
53
- const nextIndex = (currentIndex + 1) % themes.length;
54
- provider.setTheme(themes[nextIndex]);
55
- };
56
- return {
57
- theme,
58
- themeName,
59
- mode,
60
- colors,
61
- themes,
62
- setTheme,
63
- toggleTheme,
64
- };
28
+ const stores = createThemeStoresFromProvider(getThemeProvider());
29
+ return { ...stores, colors: createThemeColorsStore(stores.theme) };
65
30
  }
66
31
  /**
67
32
  * Create a derived store that returns just the theme colors.
@@ -92,15 +57,12 @@ export function createThemeColorsStore(theme) {
92
57
  */
93
58
  export function createThemeStoresFromProvider(provider) {
94
59
  const theme = readable(provider.getTheme(), (set) => {
95
- return provider.subscribe(() => {
96
- set(provider.getTheme());
97
- });
98
- });
99
- const themeName = readable(provider.getTheme().name, (set) => {
100
- return provider.subscribe(() => {
101
- set(provider.getTheme().name);
102
- });
60
+ const refresh = () => set(provider.getTheme());
61
+ const unsubscribe = provider.subscribe(refresh);
62
+ refresh();
63
+ return unsubscribe;
103
64
  });
65
+ const themeName = derived(theme, ($theme) => $theme.name);
104
66
  const mode = derived(theme, ($theme) => $theme.mode);
105
67
  const themes = provider.getThemes?.() ?? [];
106
68
  return {
@@ -110,6 +72,10 @@ export function createThemeStoresFromProvider(provider) {
110
72
  themes,
111
73
  setTheme: (name) => provider.setTheme(name),
112
74
  toggleTheme: () => {
75
+ if (themes.length === 0) {
76
+ provider.toggleMode();
77
+ return;
78
+ }
113
79
  const currentName = provider.getTheme().name;
114
80
  const idx = themes.findIndex((t) => t.name === currentName);
115
81
  provider.setTheme(themes[(idx + 1) % themes.length]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-svelte",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "Svelte framework bindings for molecule.dev",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -119,7 +119,7 @@
119
119
  "@molecule/app-ai-models": "1.4.4",
120
120
  "@molecule/app-framework-conformance": "0.0.0",
121
121
  "@molecule/app-push": "1.2.3",
122
- "@molecule/app-utilities": "1.1.0",
122
+ "@molecule/app-utilities": "1.1.1",
123
123
  "@sveltejs/package": "3.0.2",
124
124
  "@sveltejs/vite-plugin-svelte": "7.1.2",
125
125
  "@types/node": "26.6.5",