@typestyles/vite 0.0.0-unstable.8efd44454207 → 0.0.0-unstable.8f15fd4fd56a

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 CHANGED
@@ -63,7 +63,7 @@ export default defineConfig({
63
63
  });
64
64
  ```
65
65
 
66
- **3. Link the CSS** in your HTML shell (optional — the plugin auto-injects this during dev and build when extraction is enabled):
66
+ **3. Link the CSS** in your HTML shell:
67
67
 
68
68
  ```html
69
69
  <link rel="stylesheet" href="/typestyles.css" />
package/dist/index.cjs CHANGED
@@ -23,9 +23,7 @@ __export(index_exports, {
23
23
  DEFAULT_EXTRACT_MODULE_CANDIDATES: () => import_build_runner2.DEFAULT_EXTRACT_MODULE_CANDIDATES,
24
24
  default: () => typestylesPlugin,
25
25
  discoverDefaultExtractModules: () => import_build_runner2.discoverDefaultExtractModules,
26
- extractNamespaces: () => import_build_runner.extractNamespaces,
27
- htmlLinksTypestylesCss: () => htmlLinksTypestylesCss,
28
- resolveTypestylesCssHref: () => resolveTypestylesCssHref
26
+ extractNamespaces: () => import_build_runner.extractNamespaces
29
27
  });
30
28
  module.exports = __toCommonJS(index_exports);
31
29
  var import_node_path = require("path");
@@ -34,28 +32,6 @@ var import_build_runner2 = require("@typestyles/build-runner");
34
32
  function resolveExtractModulesForVite(root, extract) {
35
33
  return (0, import_build_runner.resolveExtractModules)(root, extract);
36
34
  }
37
- function resolveTypestylesCssHref(base, fileName) {
38
- const normalizedFileName = fileName.replace(/^\//, "");
39
- const normalizedBase = base.replace(/\/$/, "") || "";
40
- if (normalizedBase === "" || normalizedBase === "/") {
41
- return `/${normalizedFileName}`;
42
- }
43
- return `${normalizedBase}/${normalizedFileName}`;
44
- }
45
- function htmlLinksTypestylesCss(html, cssHref, fileName) {
46
- const bareName = fileName.replace(/^\//, "");
47
- const linkPattern = /<link\b[^>]*\brel=["']stylesheet["'][^>]*>/gi;
48
- const hrefPattern = /\bhref=["']([^"']+)["']/i;
49
- for (const match of html.matchAll(linkPattern)) {
50
- const hrefMatch = match[0].match(hrefPattern);
51
- const href = hrefMatch?.[1];
52
- if (!href) continue;
53
- if (href === cssHref || href.endsWith(`/${bareName}`) || href === bareName || href === `./${bareName}`) {
54
- return true;
55
- }
56
- }
57
- return false;
58
- }
59
35
  function typestylesPlugin(options = {}) {
60
36
  const { warnDuplicates = true, extract } = options;
61
37
  let resolvedExtractModules = [];
@@ -173,29 +149,6 @@ if (import.meta.hot) {
173
149
  map: null
174
150
  };
175
151
  },
176
- transformIndexHtml: {
177
- order: "pre",
178
- handler(html) {
179
- if (resolvedExtractModules.length === 0) return;
180
- if (resolvedMode === "runtime") return;
181
- if (!resolvedConfig) return;
182
- const fileName = extract?.fileName ?? "typestyles.css";
183
- const href = resolveTypestylesCssHref(resolvedConfig.base, fileName);
184
- if (htmlLinksTypestylesCss(html, href, fileName)) {
185
- return;
186
- }
187
- return [
188
- {
189
- tag: "link",
190
- attrs: {
191
- rel: "stylesheet",
192
- href
193
- },
194
- injectTo: "head"
195
- }
196
- ];
197
- }
198
- },
199
152
  async generateBundle() {
200
153
  if (!isBuildCommand) return;
201
154
  if (resolvedMode === "runtime") return;
@@ -225,7 +178,5 @@ if (import.meta.hot) {
225
178
  0 && (module.exports = {
226
179
  DEFAULT_EXTRACT_MODULE_CANDIDATES,
227
180
  discoverDefaultExtractModules,
228
- extractNamespaces,
229
- htmlLinksTypestylesCss,
230
- resolveTypestylesCssHref
181
+ extractNamespaces
231
182
  });
package/dist/index.d.cts CHANGED
@@ -42,10 +42,6 @@ interface TypestylesPluginOptions {
42
42
  */
43
43
  extract?: TypestylesExtractOptions;
44
44
  }
45
- /** Public URL path for the extracted CSS asset (respects Vite `base`). */
46
- declare function resolveTypestylesCssHref(base: string, fileName: string): string;
47
- /** True when `html` already links the extracted stylesheet (avoids duplicate injection). */
48
- declare function htmlLinksTypestylesCss(html: string, cssHref: string, fileName: string): boolean;
49
45
 
50
46
  /**
51
47
  * Vite plugin for typestyles HMR support.
@@ -57,4 +53,4 @@ declare function htmlLinksTypestylesCss(html: string, cssHref: string, fileName:
57
53
  */
58
54
  declare function typestylesPlugin(options?: TypestylesPluginOptions): Plugin;
59
55
 
60
- export { type TypestylesPluginOptions, typestylesPlugin as default, htmlLinksTypestylesCss, resolveTypestylesCssHref };
56
+ export { type TypestylesPluginOptions, typestylesPlugin as default };
package/dist/index.d.ts CHANGED
@@ -42,10 +42,6 @@ interface TypestylesPluginOptions {
42
42
  */
43
43
  extract?: TypestylesExtractOptions;
44
44
  }
45
- /** Public URL path for the extracted CSS asset (respects Vite `base`). */
46
- declare function resolveTypestylesCssHref(base: string, fileName: string): string;
47
- /** True when `html` already links the extracted stylesheet (avoids duplicate injection). */
48
- declare function htmlLinksTypestylesCss(html: string, cssHref: string, fileName: string): boolean;
49
45
 
50
46
  /**
51
47
  * Vite plugin for typestyles HMR support.
@@ -57,4 +53,4 @@ declare function htmlLinksTypestylesCss(html: string, cssHref: string, fileName:
57
53
  */
58
54
  declare function typestylesPlugin(options?: TypestylesPluginOptions): Plugin;
59
55
 
60
- export { type TypestylesPluginOptions, typestylesPlugin as default, htmlLinksTypestylesCss, resolveTypestylesCssHref };
56
+ export { type TypestylesPluginOptions, typestylesPlugin as default };
package/dist/index.js CHANGED
@@ -14,28 +14,6 @@ import {
14
14
  function resolveExtractModulesForVite(root, extract) {
15
15
  return resolveExtractModules(root, extract);
16
16
  }
17
- function resolveTypestylesCssHref(base, fileName) {
18
- const normalizedFileName = fileName.replace(/^\//, "");
19
- const normalizedBase = base.replace(/\/$/, "") || "";
20
- if (normalizedBase === "" || normalizedBase === "/") {
21
- return `/${normalizedFileName}`;
22
- }
23
- return `${normalizedBase}/${normalizedFileName}`;
24
- }
25
- function htmlLinksTypestylesCss(html, cssHref, fileName) {
26
- const bareName = fileName.replace(/^\//, "");
27
- const linkPattern = /<link\b[^>]*\brel=["']stylesheet["'][^>]*>/gi;
28
- const hrefPattern = /\bhref=["']([^"']+)["']/i;
29
- for (const match of html.matchAll(linkPattern)) {
30
- const hrefMatch = match[0].match(hrefPattern);
31
- const href = hrefMatch?.[1];
32
- if (!href) continue;
33
- if (href === cssHref || href.endsWith(`/${bareName}`) || href === bareName || href === `./${bareName}`) {
34
- return true;
35
- }
36
- }
37
- return false;
38
- }
39
17
  function typestylesPlugin(options = {}) {
40
18
  const { warnDuplicates = true, extract } = options;
41
19
  let resolvedExtractModules = [];
@@ -153,29 +131,6 @@ if (import.meta.hot) {
153
131
  map: null
154
132
  };
155
133
  },
156
- transformIndexHtml: {
157
- order: "pre",
158
- handler(html) {
159
- if (resolvedExtractModules.length === 0) return;
160
- if (resolvedMode === "runtime") return;
161
- if (!resolvedConfig) return;
162
- const fileName = extract?.fileName ?? "typestyles.css";
163
- const href = resolveTypestylesCssHref(resolvedConfig.base, fileName);
164
- if (htmlLinksTypestylesCss(html, href, fileName)) {
165
- return;
166
- }
167
- return [
168
- {
169
- tag: "link",
170
- attrs: {
171
- rel: "stylesheet",
172
- href
173
- },
174
- injectTo: "head"
175
- }
176
- ];
177
- }
178
- },
179
134
  async generateBundle() {
180
135
  if (!isBuildCommand) return;
181
136
  if (resolvedMode === "runtime") return;
@@ -205,7 +160,5 @@ export {
205
160
  DEFAULT_EXTRACT_MODULE_CANDIDATES,
206
161
  typestylesPlugin as default,
207
162
  discoverDefaultExtractModules,
208
- extractNamespaces,
209
- htmlLinksTypestylesCss,
210
- resolveTypestylesCssHref
163
+ extractNamespaces
211
164
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typestyles/vite",
3
- "version": "0.0.0-unstable.8efd44454207",
3
+ "version": "0.0.0-unstable.8f15fd4fd56a",
4
4
  "description": "Vite plugin for typestyles HMR support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -41,12 +41,12 @@
41
41
  "eslint": "^9.39.2",
42
42
  "tsup": "^8.0.0",
43
43
  "typescript": "^5.4.0",
44
- "typestyles": "0.0.0-unstable.8efd44454207",
44
+ "typestyles": "0.0.0-unstable.8f15fd4fd56a",
45
45
  "vite": "^6.0.0",
46
46
  "vitest": "^3.0.0"
47
47
  },
48
48
  "dependencies": {
49
- "@typestyles/build-runner": "0.0.0-unstable.8efd44454207"
49
+ "@typestyles/build-runner": "0.0.0-unstable.8f15fd4fd56a"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "tsup src/index.ts --format esm,cjs --dts --clean --external typestyles,@typestyles/build-runner",