ngx-theme-stack 3.4.0 → 3.5.1
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/README.md +202 -129
- package/fesm2022/ngx-theme-stack.mjs +18 -9
- package/fesm2022/ngx-theme-stack.mjs.map +1 -1
- package/package.json +21 -2
- package/schematics/ng-add/app-config.js +26 -33
- package/schematics/ng-add/app-config.js.map +1 -1
- package/schematics/ng-add/index.d.ts +0 -3
- package/schematics/ng-add/index.js +74 -64
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/utils.js.map +1 -1
- package/schematics/sync/index.js +33 -46
- package/schematics/sync/index.js.map +1 -1
- package/types/ngx-theme-stack.d.ts +36 -9
package/schematics/sync/index.js
CHANGED
|
@@ -33,12 +33,18 @@ const OPTION_MODE_RE = /mode\s*:\s*['"]([^'"]+)['"]/;
|
|
|
33
33
|
const OPTION_KEY_RE = /storageKey\s*:\s*['"]([^'"]+)['"]/;
|
|
34
34
|
/** Extracts "defaultTheme" value from the captured options string. */
|
|
35
35
|
const OPTION_DEFAULT_THEME_RE = /defaultTheme\s*:\s*['"]([^'"]+)['"]/;
|
|
36
|
+
/** Extracts "strategy" value from the captured options string. */
|
|
36
37
|
const OPTION_STRATEGY_RE = /strategy\s*:\s*['"]([^'"]+)['"]/;
|
|
37
38
|
/**
|
|
38
39
|
* Extracts the themes array from the options string.
|
|
39
|
-
*
|
|
40
|
+
* Supports both single-line and multiline array declarations:
|
|
41
|
+
* themes: ['light', 'dark', 'sunset']
|
|
42
|
+
* themes: [
|
|
43
|
+
* 'light',
|
|
44
|
+
* 'dark',
|
|
45
|
+
* ] as const
|
|
40
46
|
*/
|
|
41
|
-
const OPTION_THEMES_RE = /themes\s*:\s*\[([
|
|
47
|
+
const OPTION_THEMES_RE = /themes\s*:\s*\[([\s\S]*?)\]/;
|
|
42
48
|
/** Matches the complete <script> anti-flash block (identified by its marker comment). */
|
|
43
49
|
const SCRIPT_BLOCK_RE = /<!--\s*ngx-theme-stack\s*anti-flash\s*-->\s*<script[^>]*>[\s\S]*?<\/script>/;
|
|
44
50
|
/** Marker injected by ng-add that delimits the Critters Trick zone in <body>. */
|
|
@@ -72,7 +78,6 @@ function extractConfig(tree, sourceRoot, context) {
|
|
|
72
78
|
const storageKey = (_d = (_c = OPTION_KEY_RE.exec(opts)) === null || _c === void 0 ? void 0 : _c[1]) !== null && _d !== void 0 ? _d : constants_1.DEFAULTS.storageKey;
|
|
73
79
|
const defaultTheme = (_f = (_e = OPTION_DEFAULT_THEME_RE.exec(opts)) === null || _e === void 0 ? void 0 : _e[1]) !== null && _f !== void 0 ? _f : constants_1.DEFAULTS.defaultTheme;
|
|
74
80
|
const strategy = (_h = (_g = OPTION_STRATEGY_RE.exec(opts)) === null || _g === void 0 ? void 0 : _g[1]) !== null && _h !== void 0 ? _h : undefined;
|
|
75
|
-
// Extract themes array: ['light', 'dark', 'sunset'] → ['light', 'dark', 'sunset']
|
|
76
81
|
const themesRaw = (_k = (_j = OPTION_THEMES_RE.exec(opts)) === null || _j === void 0 ? void 0 : _j[1]) !== null && _k !== void 0 ? _k : '';
|
|
77
82
|
const themes = themesRaw
|
|
78
83
|
? themesRaw
|
|
@@ -134,16 +139,14 @@ function buildCrittersDivs(themes, mode) {
|
|
|
134
139
|
return ` <div data-theme="${theme}"></div>`;
|
|
135
140
|
}
|
|
136
141
|
else {
|
|
137
|
-
// 'both'
|
|
138
142
|
return ` <div class="${theme}" data-theme="${theme}"></div>`;
|
|
139
143
|
}
|
|
140
144
|
})
|
|
141
145
|
.join('\n');
|
|
142
146
|
return (`<!-- ngx-theme-stack critters-trick -->\n` +
|
|
143
|
-
` <div id="ngx-theme-stack-critters-trick" hidden>\n${divs}\n </div>\n` +
|
|
147
|
+
` <div id="ngx-theme-stack-critters-trick" hidden aria-hidden="true" style="display: none; overflow: hidden; clip-path: inset(50%); position: absolute;">\n${divs}\n </div>\n` +
|
|
144
148
|
` <!-- /ngx-theme-stack critters-trick -->`);
|
|
145
149
|
}
|
|
146
|
-
// ── index.html patching ───────────────────────────────────────────────────────
|
|
147
150
|
// ── Schematic factory ─────────────────────────────────────────────────────────
|
|
148
151
|
/**
|
|
149
152
|
* `ng generate ngx-theme-stack:sync`
|
|
@@ -155,25 +158,14 @@ function buildCrittersDivs(themes, mode) {
|
|
|
155
158
|
* `defaultTheme`, and `mode` in sync with the Angular provider.
|
|
156
159
|
*
|
|
157
160
|
* 2. **The Critters Trick divs** (if `strategy: 'critters'`) — hidden `<div>`
|
|
158
|
-
* elements that trick Angular's built-in CSS inliner
|
|
159
|
-
*
|
|
160
|
-
* at build time. This achieves zero-flash without any extra network requests.
|
|
161
|
+
* elements that trick Angular's built-in CSS inliner into treating all theme
|
|
162
|
+
* token blocks as "critical CSS", inlining them in `<head>` at build time.
|
|
161
163
|
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* so it runs automatically before every build.
|
|
165
|
-
*
|
|
166
|
-
* @example
|
|
167
|
-
* // One-off sync
|
|
168
|
-
* ng generate ngx-theme-stack:sync
|
|
164
|
+
* Auto-detects the strategy from the existing `index.html` markers so the
|
|
165
|
+
* prebuild command runs with zero extra flags.
|
|
169
166
|
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* "prebuild": "ng generate ngx-theme-stack:sync"
|
|
173
|
-
*/
|
|
174
|
-
/**
|
|
175
|
-
* Auto-detects the strategy by checking if a Critters marker exists in index.html.
|
|
176
|
-
* This allows the prebuild command to run with zero extra flags.
|
|
167
|
+
* Run this whenever you change `mode`, `storageKey`, `defaultTheme`, or `themes`
|
|
168
|
+
* inside `provideThemeStack()`. Tip: add it as a `prebuild` script in package.json.
|
|
177
169
|
*/
|
|
178
170
|
function detectStrategy(tree, sourceRoot, explicitStrategy) {
|
|
179
171
|
if (explicitStrategy)
|
|
@@ -271,34 +263,29 @@ function sync(options) {
|
|
|
271
263
|
}
|
|
272
264
|
}
|
|
273
265
|
// ── 2. angular.json ──
|
|
274
|
-
const
|
|
275
|
-
if (
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
if (typeof prodConfig.optimization === 'object') {
|
|
283
|
-
prodConfig.optimization.styles = prodConfig.optimization.styles || {};
|
|
284
|
-
if (prodConfig.optimization.styles.inlineCritical !== false) {
|
|
285
|
-
prodConfig.optimization.styles.inlineCritical = false;
|
|
286
|
-
changed = true;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
prodConfig.optimization = { styles: { inlineCritical: false } };
|
|
266
|
+
const prodConfig = (_e = (_d = (_c = project.architect) === null || _c === void 0 ? void 0 : _c.build) === null || _d === void 0 ? void 0 : _d.configurations) === null || _e === void 0 ? void 0 : _e.production;
|
|
267
|
+
if (prodConfig) {
|
|
268
|
+
let changed = false;
|
|
269
|
+
if (strategy === 'blocking') {
|
|
270
|
+
if (typeof prodConfig.optimization === 'object') {
|
|
271
|
+
prodConfig.optimization.styles = prodConfig.optimization.styles || {};
|
|
272
|
+
if (prodConfig.optimization.styles.inlineCritical !== false) {
|
|
273
|
+
prodConfig.optimization.styles.inlineCritical = false;
|
|
291
274
|
changed = true;
|
|
292
275
|
}
|
|
293
276
|
}
|
|
294
|
-
else
|
|
295
|
-
prodConfig.optimization
|
|
277
|
+
else {
|
|
278
|
+
prodConfig.optimization = { styles: { inlineCritical: false } };
|
|
296
279
|
changed = true;
|
|
297
280
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
281
|
+
}
|
|
282
|
+
else if (typeof prodConfig.optimization === 'object' && ((_f = prodConfig.optimization.styles) === null || _f === void 0 ? void 0 : _f.inlineCritical) === false) {
|
|
283
|
+
prodConfig.optimization.styles.inlineCritical = true;
|
|
284
|
+
changed = true;
|
|
285
|
+
}
|
|
286
|
+
if (changed) {
|
|
287
|
+
tree.overwrite('/angular.json', JSON.stringify(workspace, null, 2));
|
|
288
|
+
changeset.push(' \u001b[33mM\u001b[0m angular.json (optimization synced)');
|
|
302
289
|
}
|
|
303
290
|
}
|
|
304
291
|
context.logger.info('\u001b[1mChangeset:\u001b[0m');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/ngx-theme-stack/schematics/sync/index.ts"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/ngx-theme-stack/schematics/sync/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAiOA,oBA8HC;AA9VD,qDAAsD;AACtD,2CAAmD;AACnD,mDAA+C;AAG/C,iFAAiF;AAEjF;;;;;;;;;;;GAWG;AACH,MAAM,eAAe,GAAG,oCAAoC,CAAC;AAE7D,8DAA8D;AAC9D,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAErD,oEAAoE;AACpE,MAAM,aAAa,GAAG,mCAAmC,CAAC;AAE1D,sEAAsE;AACtE,MAAM,uBAAuB,GAAG,qCAAqC,CAAC;AACtE,kEAAkE;AAClE,MAAM,kBAAkB,GAAG,iCAAiC,CAAC;AAE7D;;;;;;;;GAQG;AACH,MAAM,gBAAgB,GAAG,6BAA6B,CAAC;AAEvD,yFAAyF;AACzF,MAAM,eAAe,GAAG,6EAA6E,CAAC;AAEtG,iFAAiF;AACjF,MAAM,eAAe,GAAG,yCAAyC,CAAC;AAElE,0EAA0E;AAC1E,MAAM,iBAAiB,GACrB,0FAA0F,CAAC;AAY7F,iFAAiF;AAEjF;;;;;GAKG;AACH,SAAS,aAAa,CACpB,IAAU,EACV,UAAkB,EAClB,OAAyB;;IAEzB,MAAM,UAAU,GAAG;QACjB,GAAG,UAAU,oBAAoB;QACjC,GAAG,UAAU,UAAU;KACxB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,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YAAY,CAAC,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;gBACrD,OAAO,GAAG,IAAI,CAAC;YACjB,CAAC;YAED,IAAI,OAAO,EAAE,CAAC;gBACZ,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBACpE,SAAS,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;YAC7E,CAAC;QACH,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QACpD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACN,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACxB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;QAC5D,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC,CAAA,CAAC;AACJ,CAAC"}
|
|
@@ -59,7 +59,7 @@ type NgStrategy = 'blocking' | 'critters';
|
|
|
59
59
|
interface NgConfig<T extends string = string & {}> {
|
|
60
60
|
/** The theme to use on first visit or when no preference is saved. Default: 'system'. */
|
|
61
61
|
defaultTheme: NgTheme<T>;
|
|
62
|
-
/** Key used to persist theme preference in localStorage. Default: 'ngx-theme-stack
|
|
62
|
+
/** Key used to persist theme preference in localStorage. Default: 'ngx-theme-stack'. */
|
|
63
63
|
storageKey: string;
|
|
64
64
|
/**
|
|
65
65
|
* How the theme should be applied to the document (via class, attribute or both).
|
|
@@ -68,11 +68,26 @@ interface NgConfig<T extends string = string & {}> {
|
|
|
68
68
|
mode: NgMode;
|
|
69
69
|
/**
|
|
70
70
|
* Performance strategy for anti-flash.
|
|
71
|
-
* Use 'critters'
|
|
72
|
-
*
|
|
71
|
+
* Use 'critters' (default) to inline all theme CSS in <head> — works for CSR, SSR, and SSG.
|
|
72
|
+
* Use 'blocking' to load themes.css as a render-blocking stylesheet (HTTP-cacheable).
|
|
73
73
|
*/
|
|
74
74
|
strategy: NgStrategy;
|
|
75
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* The **resolved** list of supported theme identifiers, always including the
|
|
77
|
+
* built-in themes (`'light'`, `'dark'`, `'system'`).
|
|
78
|
+
*
|
|
79
|
+
* When you pass custom themes to {@link provideThemeStack}, they are **merged**
|
|
80
|
+
* with the built-in defaults — your custom values are appended after them.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* // Input to provideThemeStack:
|
|
84
|
+
* themes: ['sepia', 'ocean'] as const
|
|
85
|
+
*
|
|
86
|
+
* // Resolved value stored in NgConfig:
|
|
87
|
+
* // ['system', 'light', 'dark', 'sepia', 'ocean']
|
|
88
|
+
*
|
|
89
|
+
* Default (no custom themes): `['system', 'light', 'dark']`.
|
|
90
|
+
*/
|
|
76
91
|
themes: NgTheme<T>[];
|
|
77
92
|
}
|
|
78
93
|
|
|
@@ -90,9 +105,19 @@ declare class CoreThemeService {
|
|
|
90
105
|
readonly selectedTheme: _angular_core.Signal<NgTheme>;
|
|
91
106
|
/** Resolved theme applied to the DOM. Always `'dark'` or `'light'` (or custom) — never `'system'`. */
|
|
92
107
|
readonly resolvedTheme: _angular_core.Signal<(string & {}) | NgSystemTheme>;
|
|
93
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* Whether the currently applied theme is dark.
|
|
110
|
+
*
|
|
111
|
+
* Returns `false` when a custom theme (e.g. `'sunset'`) is active — use
|
|
112
|
+
* `resolvedTheme()` directly if you need to inspect the current custom theme.
|
|
113
|
+
*/
|
|
94
114
|
readonly isDark: _angular_core.Signal<boolean>;
|
|
95
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Whether the currently applied theme is light.
|
|
117
|
+
*
|
|
118
|
+
* Returns `false` when a custom theme (e.g. `'sepia'`) is active — use
|
|
119
|
+
* `resolvedTheme()` directly if you need to inspect the current custom theme.
|
|
120
|
+
*/
|
|
96
121
|
readonly isLight: _angular_core.Signal<boolean>;
|
|
97
122
|
/** Whether the currently applied theme is system. */
|
|
98
123
|
readonly isSystem: _angular_core.Signal<boolean>;
|
|
@@ -163,8 +188,10 @@ declare const NGX_THEME_STACK_CONFIG: InjectionToken<NgConfig<string>>;
|
|
|
163
188
|
/**
|
|
164
189
|
* Provides Theme Stack configuration to Angular's DI system.
|
|
165
190
|
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
191
|
+
* The `themes` option accepts **additional** theme identifiers beyond the
|
|
192
|
+
* built-in defaults. They are merged with `'light'`, `'dark'`, and `'system'`
|
|
193
|
+
* so that the resolved {@link NgConfig.themes} array always includes all of
|
|
194
|
+
* them — your custom values are appended after the built-ins.
|
|
168
195
|
*
|
|
169
196
|
* **Defaults:**
|
|
170
197
|
* - `themes`: `['light', 'dark', 'system']`
|
|
@@ -192,7 +219,7 @@ declare const NGX_THEME_STACK_CONFIG: InjectionToken<NgConfig<string>>;
|
|
|
192
219
|
* provideThemeStack()
|
|
193
220
|
*
|
|
194
221
|
* @example
|
|
195
|
-
* //
|
|
222
|
+
* // Critters strategy — inlines all theme CSS in <head> (works for CSR, SSR, and SSG)
|
|
196
223
|
* provideThemeStack({
|
|
197
224
|
* strategy: 'critters',
|
|
198
225
|
* mode: 'class',
|