@12nil/theme-registry-package 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,179 @@
1
+ # theme-registry-package
2
+
3
+ A small TypeScript package for registering themes and using them in React applications.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install theme-registry-package
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ import React from 'react'
15
+ import { ThemeProvider, useTheme } from 'theme-registry-package'
16
+
17
+ function ThemeSwitcher() {
18
+ const { themes, currentTheme, currentMode, availableModes, setTheme, setMode } = useTheme()
19
+
20
+ return (
21
+ <div>
22
+ <p>
23
+ Current: {currentTheme} ({currentMode})
24
+ </p>
25
+
26
+ {themes.map((theme) => (
27
+ <button key={theme.name} onClick={() => setTheme(theme.name, availableModes[0])}>
28
+ {theme.name}
29
+ </button>
30
+ ))}
31
+
32
+ {availableModes.map((mode) => (
33
+ <button key={mode} onClick={() => setMode(mode)}>
34
+ {mode}
35
+ </button>
36
+ ))}
37
+ </div>
38
+ )
39
+ }
40
+
41
+ export default function App() {
42
+ return (
43
+ <ThemeProvider>
44
+ <ThemeSwitcher />
45
+ </ThemeProvider>
46
+ )
47
+ }
48
+ ```
49
+
50
+ ## Phase 2 Features
51
+
52
+ ```ts
53
+ import { themeRegistry } from 'theme-registry-package'
54
+
55
+ const unsubscribe = themeRegistry.onThemeChanged(({ themeName, modeName }) => {
56
+ console.log('theme changed', themeName, modeName)
57
+ })
58
+
59
+ themeRegistry.registerPlugin({
60
+ name: 'CRM',
61
+ version: '1.0.0',
62
+ minRegistryVersion: '0.2.0',
63
+ themes: [
64
+ {
65
+ name: 'crm',
66
+ metadata: {
67
+ version: '1.0.0',
68
+ compatibility: { minRegistryVersion: '0.2.0' },
69
+ },
70
+ modes: {
71
+ light: {
72
+ primary: '#1d4ed8',
73
+ secondary: '#2563eb',
74
+ background: '#ffffff',
75
+ text: '#0f172a',
76
+ accent: '#1d4ed8',
77
+ muted: '#64748b',
78
+ error: '#dc2626',
79
+ warning: '#f59e0b',
80
+ success: '#16a34a',
81
+ info: '#0ea5e9',
82
+ },
83
+ },
84
+ },
85
+ ],
86
+ })
87
+
88
+ unsubscribe()
89
+ ```
90
+
91
+ Contribution lookup:
92
+
93
+ ```ts
94
+ const crmContrib = themeRegistry.getPluginContributions('CRM')
95
+ const merged = themeRegistry.getMergedPluginContributions()
96
+
97
+ console.log(crmContrib?.icons)
98
+ console.log(merged.spacing)
99
+ ```
100
+
101
+ ## Phase 3 Features (In Progress)
102
+
103
+ ```ts
104
+ import { themeRegistry } from 'theme-registry-package'
105
+
106
+ themeRegistry.registerCompositionLayer({
107
+ type: 'brand',
108
+ name: 'fnp',
109
+ tokens: {
110
+ primary: '#031011',
111
+ secondary: '#153e46',
112
+ background: '#ffffff',
113
+ text: '#031011',
114
+ accent: '#378d93',
115
+ muted: '#667085',
116
+ error: '#DF1C41',
117
+ warning: '#F4C790',
118
+ success: '#27AE60',
119
+ info: '#378d93',
120
+ },
121
+ })
122
+
123
+ themeRegistry.registerCompositionLayer({
124
+ type: 'appearance',
125
+ name: 'dark',
126
+ tokens: {
127
+ background: '#031011',
128
+ text: '#c4e8ee',
129
+ secondary: '#378d93',
130
+ primary: '#c4e8ee',
131
+ accent: '#378d93',
132
+ muted: '#667085',
133
+ error: '#DF1C41',
134
+ warning: '#F4C790',
135
+ success: '#27AE60',
136
+ info: '#378d93',
137
+ },
138
+ })
139
+
140
+ const composed = themeRegistry.compose({ brand: 'fnp', appearance: 'dark' })
141
+
142
+ await themeRegistry.load('/api/themes', {
143
+ ifExists: 'merge',
144
+ cacheKey: 'customer-themes',
145
+ maxAgeMs: 5 * 60 * 1000,
146
+ })
147
+
148
+ // Force refresh if cache should be bypassed.
149
+ await themeRegistry.load('/api/themes', {
150
+ ifExists: 'merge',
151
+ cacheKey: 'customer-themes',
152
+ forceRefresh: true,
153
+ })
154
+
155
+ // SSR/hydration helpers.
156
+ const attrs = themeRegistry.getInitialThemeAttributes('fnp', 'dark')
157
+ const hydrated = themeRegistry.hydrateThemeOnDocument('fnp', 'dark')
158
+
159
+ // Optional cache management.
160
+ themeRegistry.clearLoadCache('customer-themes')
161
+ themeRegistry.clearLoadCache()
162
+ ```
163
+
164
+ ## Development
165
+
166
+ ```bash
167
+ npm.cmd install
168
+ npm.cmd run build
169
+ ```
170
+
171
+ ## Publish
172
+
173
+ 1. Update `name` and `version` in `package.json`.
174
+ 2. Log in: `npm.cmd login`.
175
+ 3. Publish: `npm.cmd publish --access public`.
176
+
177
+ ## Roadmap
178
+
179
+ See [ROADMAP.md](ROADMAP.md) for the phased feature plan from semantic tokens to plugin architecture, SSR support, CLI tooling, and v1 marketplace goals.
@@ -0,0 +1,7 @@
1
+ import {
2
+ themeRegistry
3
+ } from "./chunk-GUPUN2GN.js";
4
+ export {
5
+ themeRegistry
6
+ };
7
+ //# sourceMappingURL=app_theme-K3SQNO7I.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}