@typestyles/build-runner 0.0.0-unstable.e3b4bf19e2a2 → 0.0.0-unstable.e4f0ac414ce4

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/dist/index.cjs CHANGED
@@ -31,6 +31,7 @@ __export(index_exports, {
31
31
  extractNamespaces: () => extractNamespaces,
32
32
  getRouteCss: () => getRouteCss,
33
33
  isManifestV2: () => isManifestV2,
34
+ moduleNeedsOverrideHmr: () => moduleNeedsOverrideHmr,
34
35
  normalizeRoutePath: () => normalizeRoutePath,
35
36
  pageRelPathToRoutePath: () => pageRelPathToRoutePath,
36
37
  readCssFile: () => readCssFile,
@@ -80,7 +81,50 @@ var CREATE_THEME_RE = /(?:tokens\.)?createTheme\(\s*['"]([^'"]+)['"]/g;
80
81
  var KEYFRAMES_CREATE_RE = /keyframes\.create\(\s*['"]([^'"]+)['"]/g;
81
82
  var GLOBAL_STYLE_RE = /global\.style\(\s*['"]([^'"]+)['"]/g;
82
83
  var GLOBAL_FONT_FACE_RE = /global\.fontFace\(\s*['"]([^'"]+)['"]/g;
84
+ var OVERRIDE_HMR_EXPORT_NAMES = /* @__PURE__ */ new Set(["createDesignTheme", "overrideComponent"]);
83
85
  var TYPESTYLES_IMPORT_RE = /(?:from\s+|import\s+|require\s*\(\s*)['"]typestyles['"]/;
86
+ function stripCommentsForHmrScan(code) {
87
+ return code.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1");
88
+ }
89
+ function collectOverrideHmrCallTargets(code) {
90
+ const locals = new Set(OVERRIDE_HMR_EXPORT_NAMES);
91
+ const namespaces = /* @__PURE__ */ new Set();
92
+ for (const match of code.matchAll(/import\s*{([^}]+)}\s*from\s*['"][^'"]+['"]/g)) {
93
+ for (const rawPart of match[1].split(",")) {
94
+ const part = rawPart.trim();
95
+ if (!part || part.startsWith("type ")) continue;
96
+ const asMatch = part.match(/^(\w+)\s+as\s+(\w+)$/);
97
+ if (asMatch) {
98
+ if (OVERRIDE_HMR_EXPORT_NAMES.has(asMatch[1])) {
99
+ locals.add(asMatch[2]);
100
+ }
101
+ continue;
102
+ }
103
+ const name = part.match(/^(\w+)$/)?.[1];
104
+ if (name && OVERRIDE_HMR_EXPORT_NAMES.has(name)) {
105
+ locals.add(name);
106
+ }
107
+ }
108
+ }
109
+ for (const match of code.matchAll(/import\s*\*\s*as\s+(\w+)\s*from\s*['"][^'"]+['"]/g)) {
110
+ namespaces.add(match[1]);
111
+ }
112
+ return { locals, namespaces };
113
+ }
114
+ function moduleNeedsOverrideHmr(code) {
115
+ const scan = stripCommentsForHmrScan(code);
116
+ if (/\bstyles\.override\s*\(/.test(scan)) return true;
117
+ const { locals, namespaces } = collectOverrideHmrCallTargets(scan);
118
+ for (const name of locals) {
119
+ if (new RegExp(`\\b${name}\\s*\\(`).test(scan)) return true;
120
+ }
121
+ for (const ns of namespaces) {
122
+ if (new RegExp(`\\b${ns}\\.(?:createDesignTheme|overrideComponent)\\s*\\(`).test(scan)) {
123
+ return true;
124
+ }
125
+ }
126
+ return false;
127
+ }
84
128
  function extractNamespaces(code) {
85
129
  const keys = [];
86
130
  const prefixes = [];
@@ -613,6 +657,7 @@ ${result.stderr || result.stdout || "unknown error"}`
613
657
  extractNamespaces,
614
658
  getRouteCss,
615
659
  isManifestV2,
660
+ moduleNeedsOverrideHmr,
616
661
  normalizeRoutePath,
617
662
  pageRelPathToRoutePath,
618
663
  readCssFile,
package/dist/index.d.cts CHANGED
@@ -10,6 +10,15 @@ declare const DEFAULT_EXTRACT_MODULE_CANDIDATES: readonly string[];
10
10
  declare function discoverDefaultExtractModules(root: string): string[];
11
11
 
12
12
  declare const TYPESTYLES_IMPORT_RE: RegExp;
13
+ /**
14
+ * True when this module may register `styles.override` rules and needs Vite HMR
15
+ * dispose tracking — including Var UI sugar (`createDesignTheme` / `overrideComponent`)
16
+ * that never spells `styles.override` in source.
17
+ *
18
+ * Detects renamed imports (`createDesignTheme as cdt`) and namespace imports
19
+ * (`Core.createDesignTheme(`), not only the canonical identifier spelling.
20
+ */
21
+ declare function moduleNeedsOverrideHmr(code: string): boolean;
13
22
  /**
14
23
  * Extract namespace information from source code for invalidation and duplicate checks.
15
24
  */
@@ -194,4 +203,4 @@ interface RunTypestylesBuildOptions {
194
203
  */
195
204
  declare function runTypestylesBuild({ root, modules, }: RunTypestylesBuildOptions): Promise<string>;
196
205
 
197
- export { type CollectRouteCssOptions, type CollectRouteCssResult, DEFAULT_EXTRACT_MODULE_CANDIDATES, type DuplicateNamespaceReporter, type GetRouteCssOptions, type NextAppRoute, type RunTypestylesBuildOptions, TYPESTYLES_IMPORT_RE, type TypestylesExtractManifest, type TypestylesExtractManifestV1, type TypestylesExtractManifestV2, type TypestylesExtractOptions, type TypestylesIntegrationMode, type TypestylesRouteCssEntry, VerifyTypestylesBuildError, type VerifyTypestylesBuildOptions, type VerifyTypestylesBuildResult, buildManifestV2, collectAndWriteRouteCss, createModuleLoader, discoverDefaultExtractModules, discoverNextAppRoutes, extractNamespaces, getRouteCss, isManifestV2, normalizeRoutePath, pageRelPathToRoutePath, readCssFile, readTypestylesManifest, reportDuplicateNamespaces, resolveExtractMode, resolveExtractModules, runTypestylesBuild, traceTypestylesModules, verifyTypestylesBuild };
206
+ export { type CollectRouteCssOptions, type CollectRouteCssResult, DEFAULT_EXTRACT_MODULE_CANDIDATES, type DuplicateNamespaceReporter, type GetRouteCssOptions, type NextAppRoute, type RunTypestylesBuildOptions, TYPESTYLES_IMPORT_RE, type TypestylesExtractManifest, type TypestylesExtractManifestV1, type TypestylesExtractManifestV2, type TypestylesExtractOptions, type TypestylesIntegrationMode, type TypestylesRouteCssEntry, VerifyTypestylesBuildError, type VerifyTypestylesBuildOptions, type VerifyTypestylesBuildResult, buildManifestV2, collectAndWriteRouteCss, createModuleLoader, discoverDefaultExtractModules, discoverNextAppRoutes, extractNamespaces, getRouteCss, isManifestV2, moduleNeedsOverrideHmr, normalizeRoutePath, pageRelPathToRoutePath, readCssFile, readTypestylesManifest, reportDuplicateNamespaces, resolveExtractMode, resolveExtractModules, runTypestylesBuild, traceTypestylesModules, verifyTypestylesBuild };
package/dist/index.d.ts CHANGED
@@ -10,6 +10,15 @@ declare const DEFAULT_EXTRACT_MODULE_CANDIDATES: readonly string[];
10
10
  declare function discoverDefaultExtractModules(root: string): string[];
11
11
 
12
12
  declare const TYPESTYLES_IMPORT_RE: RegExp;
13
+ /**
14
+ * True when this module may register `styles.override` rules and needs Vite HMR
15
+ * dispose tracking — including Var UI sugar (`createDesignTheme` / `overrideComponent`)
16
+ * that never spells `styles.override` in source.
17
+ *
18
+ * Detects renamed imports (`createDesignTheme as cdt`) and namespace imports
19
+ * (`Core.createDesignTheme(`), not only the canonical identifier spelling.
20
+ */
21
+ declare function moduleNeedsOverrideHmr(code: string): boolean;
13
22
  /**
14
23
  * Extract namespace information from source code for invalidation and duplicate checks.
15
24
  */
@@ -194,4 +203,4 @@ interface RunTypestylesBuildOptions {
194
203
  */
195
204
  declare function runTypestylesBuild({ root, modules, }: RunTypestylesBuildOptions): Promise<string>;
196
205
 
197
- export { type CollectRouteCssOptions, type CollectRouteCssResult, DEFAULT_EXTRACT_MODULE_CANDIDATES, type DuplicateNamespaceReporter, type GetRouteCssOptions, type NextAppRoute, type RunTypestylesBuildOptions, TYPESTYLES_IMPORT_RE, type TypestylesExtractManifest, type TypestylesExtractManifestV1, type TypestylesExtractManifestV2, type TypestylesExtractOptions, type TypestylesIntegrationMode, type TypestylesRouteCssEntry, VerifyTypestylesBuildError, type VerifyTypestylesBuildOptions, type VerifyTypestylesBuildResult, buildManifestV2, collectAndWriteRouteCss, createModuleLoader, discoverDefaultExtractModules, discoverNextAppRoutes, extractNamespaces, getRouteCss, isManifestV2, normalizeRoutePath, pageRelPathToRoutePath, readCssFile, readTypestylesManifest, reportDuplicateNamespaces, resolveExtractMode, resolveExtractModules, runTypestylesBuild, traceTypestylesModules, verifyTypestylesBuild };
206
+ export { type CollectRouteCssOptions, type CollectRouteCssResult, DEFAULT_EXTRACT_MODULE_CANDIDATES, type DuplicateNamespaceReporter, type GetRouteCssOptions, type NextAppRoute, type RunTypestylesBuildOptions, TYPESTYLES_IMPORT_RE, type TypestylesExtractManifest, type TypestylesExtractManifestV1, type TypestylesExtractManifestV2, type TypestylesExtractOptions, type TypestylesIntegrationMode, type TypestylesRouteCssEntry, VerifyTypestylesBuildError, type VerifyTypestylesBuildOptions, type VerifyTypestylesBuildResult, buildManifestV2, collectAndWriteRouteCss, createModuleLoader, discoverDefaultExtractModules, discoverNextAppRoutes, extractNamespaces, getRouteCss, isManifestV2, moduleNeedsOverrideHmr, normalizeRoutePath, pageRelPathToRoutePath, readCssFile, readTypestylesManifest, reportDuplicateNamespaces, resolveExtractMode, resolveExtractModules, runTypestylesBuild, traceTypestylesModules, verifyTypestylesBuild };
package/dist/index.js CHANGED
@@ -34,7 +34,50 @@ var CREATE_THEME_RE = /(?:tokens\.)?createTheme\(\s*['"]([^'"]+)['"]/g;
34
34
  var KEYFRAMES_CREATE_RE = /keyframes\.create\(\s*['"]([^'"]+)['"]/g;
35
35
  var GLOBAL_STYLE_RE = /global\.style\(\s*['"]([^'"]+)['"]/g;
36
36
  var GLOBAL_FONT_FACE_RE = /global\.fontFace\(\s*['"]([^'"]+)['"]/g;
37
+ var OVERRIDE_HMR_EXPORT_NAMES = /* @__PURE__ */ new Set(["createDesignTheme", "overrideComponent"]);
37
38
  var TYPESTYLES_IMPORT_RE = /(?:from\s+|import\s+|require\s*\(\s*)['"]typestyles['"]/;
39
+ function stripCommentsForHmrScan(code) {
40
+ return code.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1");
41
+ }
42
+ function collectOverrideHmrCallTargets(code) {
43
+ const locals = new Set(OVERRIDE_HMR_EXPORT_NAMES);
44
+ const namespaces = /* @__PURE__ */ new Set();
45
+ for (const match of code.matchAll(/import\s*{([^}]+)}\s*from\s*['"][^'"]+['"]/g)) {
46
+ for (const rawPart of match[1].split(",")) {
47
+ const part = rawPart.trim();
48
+ if (!part || part.startsWith("type ")) continue;
49
+ const asMatch = part.match(/^(\w+)\s+as\s+(\w+)$/);
50
+ if (asMatch) {
51
+ if (OVERRIDE_HMR_EXPORT_NAMES.has(asMatch[1])) {
52
+ locals.add(asMatch[2]);
53
+ }
54
+ continue;
55
+ }
56
+ const name = part.match(/^(\w+)$/)?.[1];
57
+ if (name && OVERRIDE_HMR_EXPORT_NAMES.has(name)) {
58
+ locals.add(name);
59
+ }
60
+ }
61
+ }
62
+ for (const match of code.matchAll(/import\s*\*\s*as\s+(\w+)\s*from\s*['"][^'"]+['"]/g)) {
63
+ namespaces.add(match[1]);
64
+ }
65
+ return { locals, namespaces };
66
+ }
67
+ function moduleNeedsOverrideHmr(code) {
68
+ const scan = stripCommentsForHmrScan(code);
69
+ if (/\bstyles\.override\s*\(/.test(scan)) return true;
70
+ const { locals, namespaces } = collectOverrideHmrCallTargets(scan);
71
+ for (const name of locals) {
72
+ if (new RegExp(`\\b${name}\\s*\\(`).test(scan)) return true;
73
+ }
74
+ for (const ns of namespaces) {
75
+ if (new RegExp(`\\b${ns}\\.(?:createDesignTheme|overrideComponent)\\s*\\(`).test(scan)) {
76
+ return true;
77
+ }
78
+ }
79
+ return false;
80
+ }
38
81
  function extractNamespaces(code) {
39
82
  const keys = [];
40
83
  const prefixes = [];
@@ -566,6 +609,7 @@ export {
566
609
  extractNamespaces,
567
610
  getRouteCss,
568
611
  isManifestV2,
612
+ moduleNeedsOverrideHmr,
569
613
  normalizeRoutePath,
570
614
  pageRelPathToRoutePath,
571
615
  readCssFile,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typestyles/build-runner",
3
- "version": "0.0.0-unstable.e3b4bf19e2a2",
3
+ "version": "0.0.0-unstable.e4f0ac414ce4",
4
4
  "description": "Shared module execution utilities for typestyles build integrations",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -29,7 +29,7 @@
29
29
  "eslint": "^9.39.2",
30
30
  "tsup": "^8.0.0",
31
31
  "typescript": "^5.4.0",
32
- "typestyles": "0.0.0-unstable.e3b4bf19e2a2",
32
+ "typestyles": "0.0.0-unstable.e4f0ac414ce4",
33
33
  "vitest": "^3.0.0"
34
34
  },
35
35
  "license": "Apache-2.0",