@genarou/blazir-icons 1.4.0 → 1.4.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.
@@ -29,8 +29,11 @@ export declare function blazirIconsPlugin(options?: BlazerIconsPluginOptions): {
29
29
  root?: string;
30
30
  }): void;
31
31
  buildStart(): void;
32
- resolveId(id: string, importer?: string): "\0virtual:blazir-icons/registry" | null | undefined;
33
- load(id: string): string | undefined;
32
+ resolveId(id: string, importer?: string): "\0virtual:blazir-icons/registry" | "\0blazir-icons-css" | null | undefined;
33
+ load(id: string): string | {
34
+ code: string;
35
+ moduleSideEffects: boolean;
36
+ } | undefined;
34
37
  handleHotUpdate({ file, read, server }: {
35
38
  file: string;
36
39
  read: () => Promise<string>;
@@ -12,7 +12,8 @@
12
12
  * plugins: [blazirIconsPlugin()]
13
13
  */
14
14
  import { readFileSync, readdirSync } from 'node:fs';
15
- import { join } from 'node:path';
15
+ import { dirname, join } from 'node:path';
16
+ import { fileURLToPath } from 'node:url';
16
17
  // ============================================================================
17
18
  // MAPA COMPLETO: clave del registry → nombre del archivo .svelte
18
19
  // (necesario porque no siempre coinciden, e.g. search → MagnifiyingGlass)
@@ -177,6 +178,7 @@ const DYNAMIC_RE = /\bname=\{(?!["'])/;
177
178
  // ID del módulo virtual que reemplaza al registry completo
178
179
  const VIRTUAL_ID = 'virtual:blazir-icons/registry';
179
180
  const RESOLVED_ID = '\0virtual:blazir-icons/registry';
181
+ const RESOLVED_CSS_ID = '\0blazir-icons-css';
180
182
  // ============================================================================
181
183
  // PLUGIN
182
184
  // ============================================================================
@@ -272,6 +274,8 @@ export function blazirIconsPlugin(options = {}) {
272
274
  },
273
275
  // Intercepta la importación del registry desde Icon.svelte
274
276
  resolveId(id, importer) {
277
+ if (id.includes('icon-animation.css'))
278
+ return RESOLVED_CSS_ID;
275
279
  if (id === VIRTUAL_ID)
276
280
  return RESOLVED_ID;
277
281
  // Solo interceptar cuando podemos optimizar:
@@ -290,6 +294,27 @@ export function blazirIconsPlugin(options = {}) {
290
294
  },
291
295
  // Genera el módulo virtual con solo los íconos detectados
292
296
  load(id) {
297
+ if (id === RESOLVED_CSS_ID) {
298
+ const cssPath = join(dirname(fileURLToPath(import.meta.url)), '../icon-animation.css');
299
+ const css = readFileSync(cssPath, 'utf-8');
300
+ const code = `
301
+ const css = ${JSON.stringify(css)};
302
+ if (typeof document !== 'undefined' && !document.getElementById('blazir-icons-css')) {
303
+ const el = document.createElement('style');
304
+ el.id = 'blazir-icons-css';
305
+ el.textContent = css;
306
+ const nonce =
307
+ document.querySelector('meta[property="csp-nonce"]')?.getAttribute('content') ??
308
+ document.currentScript?.nonce ??
309
+ '';
310
+ if (nonce) el.nonce = nonce;
311
+ document.head.appendChild(el);
312
+ }
313
+ `;
314
+ // moduleSideEffects: true evita que Rollup elimine este módulo por tree-shaking.
315
+ // El sideEffects["**/*.css"] del package.json no cubre módulos virtuales.
316
+ return { code, moduleSideEffects: true };
317
+ }
293
318
  if (id !== RESOLVED_ID)
294
319
  return;
295
320
  ensureScanned();
package/package.json CHANGED
@@ -65,6 +65,13 @@
65
65
  "type": "git",
66
66
  "url": "git+https://github.com/GenaroUG/blazir-icons.git"
67
67
  },
68
+ "sideEffects": [
69
+ "**/*.css"
70
+ ],
71
+ "svelte": "./dist/index.js",
72
+ "type": "module",
73
+ "types": "./dist/index.d.ts",
74
+ "version": "1.4.1",
68
75
  "scripts": {
69
76
  "build": "svelte-package",
70
77
  "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
@@ -73,15 +80,7 @@
73
80
  "dev": "vite",
74
81
  "postbuild": "node scripts/optimize-dist.mjs",
75
82
  "prebuild": "npm run clean",
76
- "prepublishOnly": "npm run build",
77
83
  "preview": "vite preview",
78
84
  "try": "npm run build && vite --config play/vite.config.js"
79
- },
80
- "sideEffects": [
81
- "**/*.css"
82
- ],
83
- "svelte": "./dist/index.js",
84
- "type": "module",
85
- "types": "./dist/index.d.ts",
86
- "version": "1.4.0"
85
+ }
87
86
  }