ngx-theme-stack 1.0.1 → 2.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-theme-stack",
3
- "version": "1.0.1",
3
+ "version": "2.0.0",
4
4
  "description": "A stack of themes for Angular applications.",
5
5
  "schematics": "./schematics/collection.json",
6
6
  "ng-add": {
@@ -2,9 +2,14 @@
2
2
  "$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
3
  "schematics": {
4
4
  "ng-add": {
5
- "description": "Add my library to the project.",
5
+ "description": "Add and configure ngx-theme-stack in an Angular project.",
6
6
  "factory": "./ng-add/index#ngAdd",
7
7
  "schema": "./ng-add/schema.json"
8
+ },
9
+ "sync": {
10
+ "description": "Re-sync the anti-flash script in index.html with the current provideThemeStack() configuration.",
11
+ "factory": "./sync/index#sync",
12
+ "schema": "./sync/schema.json"
8
13
  }
9
14
  }
10
15
  }
@@ -0,0 +1,24 @@
1
+ import { SchematicContext, Tree } from '@angular-devkit/schematics';
2
+ /**
3
+ * Finds `index.html` and injects the anti-flash blocking script as the very
4
+ * first child of `<head>`. This is intentional: the script must run before
5
+ * any stylesheets or Angular bundles to eliminate the flash of incorrect theme.
6
+ *
7
+ * Skips the patch gracefully if:
8
+ * - `index.html` does not exist at the expected path.
9
+ * - The script tag is already present (idempotent).
10
+ *
11
+ * Detection strategy (in order):
12
+ * 1. `${sourceRoot}/index.html` — standard project layout.
13
+ * 2. `public/index.html` — project-level public folder (e.g. Vite-based).
14
+ *
15
+ * @param tree The virtual file tree of the Angular project.
16
+ * @param context The schematic's execution context for logging.
17
+ * @param sourceRoot The source root for the project.
18
+ * @param options The configuration options collected from the prompt.
19
+ */
20
+ export declare function patchIndexHtml(tree: Tree, context: SchematicContext, sourceRoot: string, options: {
21
+ storageKey: string;
22
+ defaultTheme: string;
23
+ mode: string;
24
+ }): void;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.patchIndexHtml = patchIndexHtml;
4
+ /**
5
+ * Generates a minimal blocking inline script that applies the stored theme
6
+ * to `<html>` before the browser paints.
7
+ *
8
+ * This is the single source of truth for the anti-flash script logic.
9
+ * Schematics compile to CommonJS (Node.js) and cannot import from the
10
+ * library's ESM build, so this logic lives here — close to its only consumer.
11
+ *
12
+ * The generated script:
13
+ * 1. Reads `localStorage` for the stored theme key.
14
+ * 2. Validates the value using a Regex to prevent injections.
15
+ * 3. Falls back to `defaultTheme`; resolves `'system'` via `matchMedia`.
16
+ * 4. Applies the theme according to the configured `mode` (class, attribute, or both).
17
+ * 5. Sets the `color-scheme` CSS property for native browser adaptation.
18
+ */
19
+ function buildAntiFlashScript(options) {
20
+ const { storageKey, defaultTheme, mode } = options;
21
+ return (`(function(){try{` +
22
+ `var k=${JSON.stringify(storageKey)},` +
23
+ `d=${JSON.stringify(defaultTheme)},` +
24
+ `m=${JSON.stringify(mode)},` +
25
+ `t=localStorage.getItem(k)||d,` +
26
+ `e=document.documentElement;` +
27
+ `if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(t))t=d;` +
28
+ `if(t==='system')t=window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light';` +
29
+ `if(m==='class'||m==='both')e.classList.add(t);` +
30
+ `if(m==='attribute'||m==='both')e.setAttribute('data-theme',t);` +
31
+ `if(t==='dark'||t==='light')e.style.setProperty('color-scheme',t);` +
32
+ `}catch(x){}})();`);
33
+ }
34
+ /**
35
+ * Finds `index.html` and injects the anti-flash blocking script as the very
36
+ * first child of `<head>`. This is intentional: the script must run before
37
+ * any stylesheets or Angular bundles to eliminate the flash of incorrect theme.
38
+ *
39
+ * Skips the patch gracefully if:
40
+ * - `index.html` does not exist at the expected path.
41
+ * - The script tag is already present (idempotent).
42
+ *
43
+ * Detection strategy (in order):
44
+ * 1. `${sourceRoot}/index.html` — standard project layout.
45
+ * 2. `public/index.html` — project-level public folder (e.g. Vite-based).
46
+ *
47
+ * @param tree The virtual file tree of the Angular project.
48
+ * @param context The schematic's execution context for logging.
49
+ * @param sourceRoot The source root for the project.
50
+ * @param options The configuration options collected from the prompt.
51
+ */
52
+ function patchIndexHtml(tree, context, sourceRoot, options) {
53
+ const candidates = [`${sourceRoot}/index.html`, 'public/index.html'].map((p) => p.startsWith('/') ? p.slice(1) : p);
54
+ for (const path of candidates) {
55
+ if (!tree.exists(path))
56
+ continue;
57
+ const content = tree.readText(path);
58
+ // Guard: idempotent — skip if script is already present
59
+ if (content.includes('ngx-theme-stack-theme') ||
60
+ content.includes('ngx-theme-stack anti-flash')) {
61
+ context.logger.info(`✔ Anti-flash script already present in ${path} — skipping.`);
62
+ return;
63
+ }
64
+ const script = buildAntiFlashScript({
65
+ storageKey: options.storageKey,
66
+ defaultTheme: options.defaultTheme,
67
+ mode: options.mode,
68
+ });
69
+ // ── CSP Detection ────────────────────────────────────────────────────────
70
+ // If the project uses a Content-Security-Policy meta tag, inline scripts
71
+ // are blocked by default unless 'unsafe-inline' or a nonce is allowed.
72
+ // We warn here; the user must add a nonce manually or adjust their CSP.
73
+ const hasCspMeta = content.includes('Content-Security-Policy') || content.includes('content-security-policy');
74
+ if (hasCspMeta) {
75
+ context.logger.warn(`⚠ A Content-Security-Policy meta tag was detected in ${path}.\n` +
76
+ ` Inline scripts may be blocked by your CSP.\n` +
77
+ ` Options:\n` +
78
+ ` 1. Add a nonce to the injected <script> tag and allow it in your CSP.\n` +
79
+ ` 2. Add the script hash to your CSP: script-src 'sha256-<HASH>'.\n` +
80
+ ` 3. Allow 'unsafe-inline' (not recommended for production).\n` +
81
+ ` See: https://angular.dev/guide/security#content-security-policy`);
82
+ }
83
+ // Inject immediately after <head> so it blocks rendering before any CSS.
84
+ // If your project uses CSP nonces, add nonce="<%= CSP_NONCE %>" to the tag.
85
+ const scriptTag = `\n <!-- ngx-theme-stack anti-flash -->\n <script>${script}</script>`;
86
+ const updated = content.replace('<head>', `<head>${scriptTag}`);
87
+ tree.overwrite(path, updated);
88
+ context.logger.info(`✔ Anti-flash script injected into ${path}`);
89
+ if (hasCspMeta) {
90
+ context.logger.warn(` → Remember to allow the inline script in your CSP before deploying.`);
91
+ }
92
+ return;
93
+ }
94
+ context.logger.warn(`⚠ Could not find index.html (tried: ${candidates.join(', ')}).\n` +
95
+ ` Add the anti-flash script manually to the <head> of your index.html.\n` +
96
+ ` See: https://github.com/your-org/ngx-theme-stack#anti-flash`);
97
+ }
98
+ //# sourceMappingURL=anti-flash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anti-flash.js","sourceRoot":"","sources":["../../../../projects/ngx-theme-stack/schematics/ng-add/anti-flash.ts"],"names":[],"mappings":";;AA0DA,wCAmEC;AA3HD;;;;;;;;;;;;;;GAcG;AACH,SAAS,oBAAoB,CAAC,OAI7B;IACC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAEnD,OAAO,CACL,kBAAkB;QAClB,SAAS,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG;QACtC,KAAK,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG;QACpC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG;QAC5B,+BAA+B;QAC/B,6BAA6B;QAC7B,6CAA6C;QAC7C,6FAA6F;QAC7F,gDAAgD;QAChD,gEAAgE;QAChE,mEAAmE;QACnE,kBAAkB,CACnB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,cAAc,CAC5B,IAAU,EACV,OAAyB,EACzB,UAAkB,EAClB,OAAmE;IAEnE,MAAM,UAAU,GAAG,CAAC,GAAG,UAAU,aAAa,EAAE,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC7E,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,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E,OAAO,CAAC,CAAC;QAC9B,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,qCAAqC,IAAI,EAAE,CAAC,CAAC;QACjE,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,uEAAuE,CAAC,CAAC;QAC/F,CAAC;QACD,OAAO;IACT,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,IAAI,CACjB,uCAAuC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM;QAChE,0EAA0E;QAC1E,+DAA+D,CAClE,CAAC;AACJ,CAAC"}
@@ -1,11 +1,11 @@
1
1
  import { SchematicContext, Tree } from '@angular-devkit/schematics';
2
2
  /**
3
3
  * Attempts to automatically locate and update the application configuration files.
4
- * It searches for standard Angular file paths like 'app.config.ts', 'main.ts',
5
- * and 'app.module.ts', injecting the proper import and provider call.
4
+ * It searches for standard Angular file paths relative to the project's source root.
6
5
  *
7
6
  * @param tree The virtual file tree of the project.
8
7
  * @param context The schematic's execution context.
8
+ * @param sourceRoot The source root for the project (e.g. 'projects/demo-ngx-theme-stack/src').
9
9
  * @param provideCall The pre-formatted code string for provideThemeStack().
10
10
  */
11
- export declare function patchAppConfig(tree: Tree, context: SchematicContext, provideCall: string): void;
11
+ export declare function patchAppConfig(tree: Tree, context: SchematicContext, sourceRoot: string, provideCall: string): void;
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.patchAppConfig = patchAppConfig;
4
4
  /**
5
5
  * Attempts to automatically locate and update the application configuration files.
6
- * It searches for standard Angular file paths like 'app.config.ts', 'main.ts',
7
- * and 'app.module.ts', injecting the proper import and provider call.
6
+ * It searches for standard Angular file paths relative to the project's source root.
8
7
  *
9
8
  * @param tree The virtual file tree of the project.
10
9
  * @param context The schematic's execution context.
10
+ * @param sourceRoot The source root for the project (e.g. 'projects/demo-ngx-theme-stack/src').
11
11
  * @param provideCall The pre-formatted code string for provideThemeStack().
12
12
  */
13
- function patchAppConfig(tree, context, provideCall) {
14
- const candidates = ['src/app/app.config.ts', 'src/main.ts', 'src/app/app.module.ts'];
13
+ function patchAppConfig(tree, context, sourceRoot, provideCall) {
14
+ const candidates = [`${sourceRoot}/app/app.config.ts`, `${sourceRoot}/main.ts`, `${sourceRoot}/app/app.module.ts`].map(p => p.startsWith('/') ? p.slice(1) : p);
15
15
  for (const filePath of candidates) {
16
16
  if (!tree.exists(filePath))
17
17
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"app-config.js","sourceRoot":"","sources":["../../../../projects/ngx-theme-stack/schematics/ng-add/app-config.ts"],"names":[],"mappings":";;AAWA,wCAqDC;AA9DD;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAAC,IAAU,EAAE,OAAyB,EAAE,WAAmB;IACvF,MAAM,UAAU,GAAG,CAAC,uBAAuB,EAAE,aAAa,EAAE,uBAAuB,CAAC,CAAC;IAErF,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;QAClC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;YAAE,SAAS;QAErC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAExC,IAAI,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAC1C,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,2CAA2C,QAAQ,EAAE,CAAC,CAAC;YAC3E,OAAO;QACT,CAAC;QAED,IAAI,OAAO,GAAG,OAAO,CAAC;QAEtB,wBAAwB;QACxB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,CAAC;YAChD,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;YAClD,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YAC9C,OAAO;gBACL,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,G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AAC,EAAU,EAAE,KAAa,EAAE,EAAE;gBAC5B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;gBAChC,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;gBAChF,OAAO,eAAe,OAAO,GAAG,GAAG,GAAG,WAAW,OAAO,CAAC;YAC3D,CAAC,CACF,CAAC;QACJ,CAAC;aAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC;YACpD,OAAO,GAAG,OAAO,CAAC,OAAO,CACvB,2CAA2C,EAC3C,mDAAmD,WAAW,WAAW,CAC1E,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,WAAW,OAAO,QAAQ,EAAE,CAAC,CAAC;QAC7D,OAAO;IACT,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,IAAI,CACjB,6DAA6D;QAC3D,qBAAqB;QACrB,4DAA4D;QAC5D,kBAAkB,WAAW,IAAI,CACpC,CAAC;AACJ,CAAC"}
@@ -2,16 +2,15 @@
2
2
  * ⚠ ATTENTION: SHARED CONFIGURATION VALUES
3
3
  *
4
4
  * These values MUST match the library defaults in:
5
- * projects/ngx-theme-stack/src/lib/services/theme-stack.config.ts
5
+ * - projects/ngx-theme-stack/src/lib/types.ts → DEFAULT_THEMES
6
+ * - projects/ngx-theme-stack/src/lib/config/index.ts → DEFAULT_NG_CONFIG
6
7
  *
7
8
  * Schematics run in Node.js (CommonJS) and cannot import from the library (ESM),
8
- * so these defaults are intentionally duplicated here for:
9
- * 1. Proposing hints/defaults in interactive prompts.
10
- * 2. Deciding if a property can be omitted from the generated provideThemeStack() call.
9
+ * so the values are intentionally duplicated. Change all three at the same time.
11
10
  */
12
11
  export declare const DEFAULT_THEMES: readonly ["system", "light", "dark"];
13
12
  export declare const DEFAULTS: {
14
- readonly theme: "system";
13
+ readonly defaultTheme: "system";
15
14
  readonly storageKey: "ngx-theme-stack-theme";
16
15
  readonly mode: "class";
17
16
  readonly themes: readonly ["system", "light", "dark"];
@@ -5,16 +5,15 @@ exports.DEFAULTS = exports.DEFAULT_THEMES = void 0;
5
5
  * ⚠ ATTENTION: SHARED CONFIGURATION VALUES
6
6
  *
7
7
  * These values MUST match the library defaults in:
8
- * projects/ngx-theme-stack/src/lib/services/theme-stack.config.ts
8
+ * - projects/ngx-theme-stack/src/lib/types.ts → DEFAULT_THEMES
9
+ * - projects/ngx-theme-stack/src/lib/config/index.ts → DEFAULT_NG_CONFIG
9
10
  *
10
11
  * Schematics run in Node.js (CommonJS) and cannot import from the library (ESM),
11
- * so these defaults are intentionally duplicated here for:
12
- * 1. Proposing hints/defaults in interactive prompts.
13
- * 2. Deciding if a property can be omitted from the generated provideThemeStack() call.
12
+ * so the values are intentionally duplicated. Change all three at the same time.
14
13
  */
15
14
  exports.DEFAULT_THEMES = ['system', 'light', 'dark'];
16
15
  exports.DEFAULTS = {
17
- theme: 'system',
16
+ defaultTheme: 'system',
18
17
  storageKey: 'ngx-theme-stack-theme',
19
18
  mode: 'class',
20
19
  themes: [...exports.DEFAULT_THEMES],
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../projects/ngx-theme-stack/schematics/ng-add/constants.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACU,QAAA,cAAc,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAU,CAAC;AAEtD,QAAA,QAAQ,GAAG;IACtB,KAAK,EAAE,QAAQ;IACf,UAAU,EAAE,uBAAuB;IACnC,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,CAAC,GAAG,sBAAc,CAAC;CACnB,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../projects/ngx-theme-stack/schematics/ng-add/constants.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACU,QAAA,cAAc,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAU,CAAC;AAEtD,QAAA,QAAQ,GAAG;IACtB,YAAY,EAAE,QAAQ;IACtB,UAAU,EAAE,uBAAuB;IACnC,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,CAAC,GAAG,sBAAc,CAAC;CACnB,CAAC"}
@@ -11,9 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ngAdd = ngAdd;
13
13
  const schematics_1 = require("@angular-devkit/schematics");
14
+ const anti_flash_1 = require("./anti-flash");
15
+ const app_config_1 = require("./app-config");
14
16
  const constants_1 = require("./constants");
15
17
  const utils_1 = require("./utils");
16
- const app_config_1 = require("./app-config");
17
18
  /**
18
19
  * Interactively prompts the user for custom configuration options using readline.
19
20
  * It allows defining additional themes, selecting a default theme from the expanded list,
@@ -34,13 +35,13 @@ function collectCustomOptions() {
34
35
  .filter(Boolean)
35
36
  : [];
36
37
  const allThemes = [...constants_1.DEFAULT_THEMES, ...customThemes];
37
- const theme = yield (0, utils_1.askList)(rl, 'Default theme:', allThemes, 0);
38
+ const defaultTheme = yield (0, utils_1.askList)(rl, 'Default theme:', allThemes, 0);
38
39
  const rawKey = yield (0, utils_1.ask)(rl, ` localStorage key [${constants_1.DEFAULTS.storageKey}]: `);
39
40
  const storageKey = rawKey || constants_1.DEFAULTS.storageKey;
40
41
  const MODES = ['class', 'attribute', 'both'];
41
42
  const mode = yield (0, utils_1.askList)(rl, 'How to apply theme on <html>:', MODES, 0);
42
43
  process.stdout.write('\n');
43
- return { theme, storageKey, mode, themes: allThemes };
44
+ return { defaultTheme, storageKey, mode, themes: allThemes };
44
45
  }
45
46
  finally {
46
47
  rl.close();
@@ -56,29 +57,51 @@ function collectCustomOptions() {
56
57
  * @returns A rule that modifies the project's setup.
57
58
  */
58
59
  function ngAdd(options) {
59
- return (_tree, context) => __awaiter(this, void 0, void 0, function* () {
60
+ return (tree, context) => __awaiter(this, void 0, void 0, function* () {
61
+ // ── Workspace Resolution ──────────────────────────────────────────────────
62
+ // In a monorepo, we must find the project's actual root and sourceRoot.
63
+ const workspaceConfig = tree.read('/angular.json');
64
+ if (!workspaceConfig) {
65
+ throw new Error('Could not find angular.json. Are you in an Angular workspace?');
66
+ }
67
+ const workspace = JSON.parse(workspaceConfig.toString());
68
+ const projectName = options.project || workspace.defaultProject;
69
+ const project = workspace.projects[projectName];
70
+ if (!project) {
71
+ throw new Error(`Project "${projectName}" not found in angular.json.`);
72
+ }
73
+ const projectRoot = project.root || '';
74
+ const projectSourceRoot = project.sourceRoot || `${projectRoot}/src`;
60
75
  context.logger.info('');
61
- context.logger.info('🎨 ngx-theme-stack — setup');
76
+ context.logger.info(`🎨 ngx-theme-stack — setup [project: ${projectName}]`);
62
77
  context.logger.info('');
63
78
  let provideCall;
79
+ let scriptOptions;
64
80
  if (options.mode === 'quick') {
65
81
  provideCall = 'provideThemeStack()';
82
+ scriptOptions = {
83
+ storageKey: constants_1.DEFAULTS.storageKey,
84
+ defaultTheme: constants_1.DEFAULTS.defaultTheme,
85
+ mode: constants_1.DEFAULTS.mode,
86
+ };
66
87
  context.logger.info('⚡ Quick setup — defaults applied by the library (DEFAULT_NG_CONFIG).');
67
88
  }
68
89
  else {
69
90
  context.logger.info('🛠 Custom setup — answer the prompts below:');
70
91
  const opts = yield collectCustomOptions();
71
- const { theme, storageKey, mode, themes } = opts;
92
+ const { defaultTheme, storageKey, mode, themes } = opts;
72
93
  context.logger.info(' Applying your configuration:');
73
- context.logger.info(` theme : ${theme}`);
74
- context.logger.info(` themes : [${themes.join(', ')}]`);
75
- context.logger.info(` storageKey : ${storageKey}`);
76
- context.logger.info(` mode : ${mode}`);
77
- provideCall = (0, utils_1.buildProvideCall)(theme, storageKey, mode, themes);
94
+ context.logger.info(` defaultTheme : ${defaultTheme}`);
95
+ context.logger.info(` themes : [${themes.join(', ')}]`);
96
+ context.logger.info(` storageKey : ${storageKey}`);
97
+ context.logger.info(` mode : ${mode}`);
98
+ provideCall = (0, utils_1.buildProvideCall)(defaultTheme, storageKey, mode, themes);
99
+ scriptOptions = { storageKey, defaultTheme, mode };
78
100
  }
79
101
  return (0, schematics_1.chain)([
80
102
  (t, ctx) => {
81
- (0, app_config_1.patchAppConfig)(t, ctx, provideCall);
103
+ (0, app_config_1.patchAppConfig)(t, ctx, projectSourceRoot, provideCall);
104
+ (0, anti_flash_1.patchIndexHtml)(t, ctx, projectSourceRoot, scriptOptions);
82
105
  ctx.logger.info('');
83
106
  ctx.logger.info('✅ Done! Run `ng serve` to see ngx-theme-stack in action.');
84
107
  ctx.logger.info('');
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/ngx-theme-stack/schematics/ng-add/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAwDA,sBAkCC;AA1FD,2DAAiF;AAEjF,2CAAuD;AACvD,mCAAmE;AACnE,6CAA8C;AAE9C;;;;;;GAMG;AACH,SAAe,oBAAoB;;QAMjC,MAAM,EAAE,GAAG,IAAA,gBAAQ,GAAE,CAAC;QAEtB,IAAI,CAAC;YACH,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAE3B,MAAM,SAAS,GAAG,MAAM,IAAA,WAAG,EAAC,EAAE,EAAE,oDAAoD,CAAC,CAAC;YACtF,MAAM,YAAY,GAAG,SAAS;gBAC5B,CAAC,CAAC,SAAS;qBACN,KAAK,CAAC,GAAG,CAAC;qBACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;qBACpB,MAAM,CAAC,OAAO,CAAC;gBACpB,CAAC,CAAC,EAAE,CAAC;YACP,MAAM,SAAS,GAAG,C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AM,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC;gBAC7E,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACtB,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAA,CAAC;AACJ,CAAC"}
@@ -17,4 +17,4 @@ export declare function askList(rl: readline.Interface, label: string, items: re
17
17
  * It compares the selected values with library defaults to generate a
18
18
  * minimal call string (omitting properties that match defaults).
19
19
  */
20
- export declare function buildProvideCall(theme: string, storageKey: string, mode: string, themes: string[]): string;
20
+ export declare function buildProvideCall(defaultTheme: string, storageKey: string, mode: string, themes: string[]): string;
@@ -45,18 +45,18 @@ function askList(rl_1, label_1, items_1) {
45
45
  * It compares the selected values with library defaults to generate a
46
46
  * minimal call string (omitting properties that match defaults).
47
47
  */
48
- function buildProvideCall(theme, storageKey, mode, themes) {
49
- const defaultThemes = [...constants_1.DEFAULT_THEMES];
50
- const isDefaultThemes = themes.length === defaultThemes.length && themes.every((t, i) => t === defaultThemes[i]);
51
- const isAllDefault = theme === constants_1.DEFAULTS.theme &&
48
+ function buildProvideCall(defaultTheme, storageKey, mode, themes) {
49
+ const defaultThemesList = [...constants_1.DEFAULT_THEMES];
50
+ const isDefaultThemes = themes.length === defaultThemesList.length && themes.every((t, i) => t === defaultThemesList[i]);
51
+ const isAllDefault = defaultTheme === constants_1.DEFAULTS.defaultTheme &&
52
52
  storageKey === constants_1.DEFAULTS.storageKey &&
53
53
  mode === constants_1.DEFAULTS.mode &&
54
54
  isDefaultThemes;
55
55
  if (isAllDefault)
56
56
  return `provideThemeStack()`;
57
57
  const parts = [];
58
- if (theme !== constants_1.DEFAULTS.theme)
59
- parts.push(`theme: '${theme}'`);
58
+ if (defaultTheme !== constants_1.DEFAULTS.defaultTheme)
59
+ parts.push(`defaultTheme: '${defaultTheme}'`);
60
60
  if (storageKey !== constants_1.DEFAULTS.storageKey)
61
61
  parts.push(`storageKey: '${storageKey}'`);
62
62
  if (mode !== constants_1.DEFAUL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CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,KAAK,CAAC,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,uBAAuB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;AACtD,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ import { Schema } from './schema';
3
+ /**
4
+ * `ng generate ngx-theme-stack:sync`
5
+ *
6
+ * Reads the current `provideThemeStack()` configuration from `app.config.ts`
7
+ * and regenerates the anti-flash inline script in `index.html` to match.
8
+ *
9
+ * Run this whenever you change `mode`, `storageKey`, or `defaultTheme`
10
+ * inside `provideThemeStack()` to keep the anti-flash script in sync.
11
+ */
12
+ export declare function sync(options: Schema): Rule;
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sync = sync;
4
+ const constants_1 = require("../ng-add/constants");
5
+ // ── Regex patterns ────────────────────────────────────────────────────────────
6
+ /**
7
+ * Matches the provideThemeStack() call in app.config.ts.
8
+ * Captures the full options object string (may be empty).
9
+ *
10
+ * Examples matched:
11
+ * provideThemeStack()
12
+ * provideThemeStack({ mode: 'attribute', themes: ['dark', 'light'] })
13
+ */
14
+ const PROVIDE_CALL_RE = /provideThemeStack\s*\(([^)]*)\)/;
15
+ /**
16
+ * Extracts "mode" value from the captured options string.
17
+ * e.g. { mode: 'attribute', ... } → 'attribute'
18
+ */
19
+ const OPTION_MODE_RE = /mode\s*:\s*['"]([^'"]+)['"]/;
20
+ /**
21
+ * Extracts "storageKey" value from the captured options string.
22
+ */
23
+ const OPTION_KEY_RE = /storageKey\s*:\s*['"]([^'"]+)['"]/;
24
+ /**
25
+ * Extracts "defaultTheme" value from the captured options string.
26
+ */
27
+ const OPTION_DEFAULT_THEME_RE = /defaultTheme\s*:\s*['"]([^'"]+)['"]/;
28
+ /**
29
+ * Identifies the inline anti-flash script injected by ng-add.
30
+ * We look for the unique comment marker.
31
+ */
32
+ const SCRIPT_MARKER = 'ngx-theme-stack anti-flash';
33
+ /**
34
+ * Matches the complete <script> block that contains the anti-flash script.
35
+ * Captures everything between the comment marker and the closing </script>.
36
+ */
37
+ const SCRIPT_BLOCK_RE = /<!-- ngx-theme-stack anti-flash -->\s*<script>[\s\S]*?<\/script>/;
38
+ /**
39
+ * Reads `app.config.ts` (or `main.ts`) and extracts the current
40
+ * `provideThemeStack()` configuration using regex.
41
+ *
42
+ * Falls back to library defaults for any option that is not found.
43
+ */
44
+ function extractConfig(tree, sourceRoot, context) {
45
+ var _a, _b, _c, _d, _e, _f;
46
+ const candidates = [
47
+ `${sourceRoot}/app/app.config.ts`,
48
+ `${sourceRoot}/main.ts`,
49
+ ].map((p) => (p.startsWith('/') ? p.slice(1) : p));
50
+ for (const filePath of candidates) {
51
+ if (!tree.exists(filePath))
52
+ continue;
53
+ const content = tree.readText(filePath);
54
+ const provideMatch = PROVIDE_CALL_RE.exec(content);
55
+ if (!provideMatch) {
56
+ context.logger.warn(`⚠ provideThemeStack() not found in ${filePath}. Using library defaults.`);
57
+ break;
58
+ }
59
+ const opts = provideMatch[1]; // everything inside provideThemeStack(...)
60
+ const mode = (_b = (_a = OPTION_MODE_RE.exec(opts)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : constants_1.DEFAULTS.mode;
61
+ 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;
62
+ 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;
63
+ context.logger.info(` Detected mode : ${mode}`);
64
+ context.logger.info(` Detected storageKey : ${storageKey}`);
65
+ context.logger.info(` Detected defaultTheme : ${defaultTheme}`);
66
+ return { mode, storageKey, defaultTheme };
67
+ }
68
+ // Fallback to defaults if no config file found
69
+ return {
70
+ mode: constants_1.DEFAULTS.mode,
71
+ storageKey: constants_1.DEFAULTS.storageKey,
72
+ defaultTheme: constants_1.DEFAULTS.defaultTheme,
73
+ };
74
+ }
75
+ // ── Script generation ─────────────────────────────────────────────────────────
76
+ /**
77
+ * Builds the minimal blocking inline script — identical logic to anti-flash.ts
78
+ * but read-only (no themes list needed; generic regex validation).
79
+ */
80
+ function buildScript(config) {
81
+ const { storageKey, defaultTheme, mode } = config;
82
+ return (`(function(){try{` +
83
+ `var k=${JSON.stringify(storageKey)},` +
84
+ `d=${JSON.stringify(defaultTheme)},` +
85
+ `m=${JSON.stringify(mode)},` +
86
+ `t=localStorage.getItem(k)||d,` +
87
+ `e=document.documentElement;` +
88
+ `if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(t))t=d;` +
89
+ `if(t==='system')t=window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light';` +
90
+ `if(m==='class'||m==='both')e.classList.add(t);` +
91
+ `if(m==='attribute'||m==='both')e.setAttribute('data-theme',t);` +
92
+ `if(t==='dark'||t==='light')e.style.setProperty('color-scheme',t);` +
93
+ `}catch(x){}})();`);
94
+ }
95
+ // ── index.html patching ───────────────────────────────────────────────────────
96
+ function syncIndexHtml(tree, context, sourceRoot, config) {
97
+ const candidates = [`${sourceRoot}/index.html`, 'public/index.html'].map((p) => p.startsWith('/') ? p.slice(1) : p);
98
+ for (const path of candidates) {
99
+ if (!tree.exists(path))
100
+ continue;
101
+ const content = tree.readText(path);
102
+ if (!content.includes(SCRIPT_MARKER)) {
103
+ context.logger.warn(`⚠ Anti-flash script marker not found in ${path}.\n` +
104
+ ` Run 'ng add ngx-theme-stack' first, or add the script manually.`);
105
+ return;
106
+ }
107
+ const newScriptBlock = `<!-- ngx-theme-stack anti-flash -->\n <script>${buildScript(config)}</script>`;
108
+ const updated = content.replace(SCRIPT_BLOCK_RE, newScriptBlock);
109
+ if (updated === content) {
110
+ context.logger.warn(`⚠ Could not replace script block in ${path}. The format may have changed.`);
111
+ return;
112
+ }
113
+ tree.overwrite(path, updated);
114
+ context.logger.info(`✔ Anti-flash script synced in ${path}`);
115
+ return;
116
+ }
117
+ context.logger.warn(`⚠ Could not find index.html (tried: ${candidates.join(', ')}).`);
118
+ }
119
+ // ── Schematic factory ─────────────────────────────────────────────────────────
120
+ /**
121
+ * `ng generate ngx-theme-stack:sync`
122
+ *
123
+ * Reads the current `provideThemeStack()` configuration from `app.config.ts`
124
+ * and regenerates the anti-flash inline script in `index.html` to match.
125
+ *
126
+ * Run this whenever you change `mode`, `storageKey`, or `defaultTheme`
127
+ * inside `provideThemeStack()` to keep the anti-flash script in sync.
128
+ */
129
+ function sync(options) {
130
+ return (tree, context) => {
131
+ var _a, _b;
132
+ const workspaceConfig = tree.read('/angular.json');
133
+ if (!workspaceConfig) {
134
+ throw new Error('Could not find angular.json. Are you in an Angular workspace?');
135
+ }
136
+ const workspace = JSON.parse(workspaceConfig.toString());
137
+ const projectName = (_a = options.project) !== null && _a !== void 0 ? _a : workspace.defaultProject;
138
+ const project = workspace.projects[projectName];
139
+ if (!project) {
140
+ throw new Error(`Project "${projectName}" not found in angular.json.`);
141
+ }
142
+ const sourceRoot = project.sourceRoot || `${(_b = project.root) !== null && _b !== void 0 ? _b : ''}/src`;
143
+ context.logger.info('');
144
+ context.logger.info(`🔄 ngx-theme-stack sync [project: ${projectName}]`);
145
+ context.logger.info('');
146
+ const config = extractConfig(tree, sourceRoot, context);
147
+ syncIndexHtml(tree, context, sourceRoot, config);
148
+ context.logger.info('');
149
+ context.logger.info('✅ Done! The anti-flash script is now in sync with your provider config.');
150
+ context.logger.info('');
151
+ };
152
+ }
153
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/ngx-theme-stack/schematics/sync/index.ts"],"names":[],"mappings":";;AA0LA,oBA4BC;AAr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AC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ export interface Schema {
2
+ /** Name of the Angular project to sync. */
3
+ project: string;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../projects/ngx-theme-stack/schematics/sync/schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "NgxThemeStackSync",
4
+ "title": "ngx-theme-stack sync",
5
+ "type": "object",
6
+ "properties": {
7
+ "project": {
8
+ "type": "string",
9
+ "description": "The name of the Angular project to sync.",
10
+ "$default": {
11
+ "$source": "projectName"
12
+ }
13
+ }
14
+ },
15
+ "required": ["project"]
16
+ }