@fluixi/compiler 1.0.0-alpha.94 → 1.0.0-alpha.95

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.
Files changed (44) hide show
  1. package/LICENSE +1 -1
  2. package/dist/analyze/static-graph.cjs +1 -1
  3. package/dist/analyze/static-graph.mjs +1 -1
  4. package/dist/{babel-RJFQVFJW.mjs → babel-V33QLJBF.mjs} +4 -4
  5. package/dist/{chunk-DP2QDWWH.mjs → chunk-62F2LLBM.mjs} +1 -1
  6. package/dist/{chunk-E2RWTIYE.mjs → chunk-7GNSGUHK.mjs} +4 -89
  7. package/dist/{chunk-ZR2QHTEX.mjs → chunk-B64LVPTU.mjs} +2 -2
  8. package/dist/{chunk-HCCBEJEZ.mjs → chunk-C3AK5PBV.mjs} +1 -1
  9. package/dist/{chunk-HIZU7WI2.mjs → chunk-GLFUPZ27.mjs} +1 -1
  10. package/dist/chunk-HUABRVWB.mjs +92 -0
  11. package/dist/chunk-XCWP7WJG.mjs +584 -0
  12. package/dist/frontend/babel/index.cjs +1 -1
  13. package/dist/frontend/babel/index.mjs +1 -1
  14. package/dist/index.cjs +1 -1
  15. package/dist/index.mjs +1 -1
  16. package/dist/integrations.cjs +3328 -3269
  17. package/dist/integrations.d.ts.map +1 -1
  18. package/dist/integrations.js +19 -8
  19. package/dist/integrations.mjs +85 -40
  20. package/dist/lower/compile-template.cjs +1 -1
  21. package/dist/lower/compile-template.mjs +1 -1
  22. package/dist/resolve/builtins.cjs +1 -1
  23. package/dist/resolve/builtins.mjs +1 -1
  24. package/dist/{server-fns-JLSTKWPS.mjs → server-fns-N3SDJXA7.mjs} +5 -4
  25. package/dist/{server-functions-BGY3RD4R.mjs → server-functions-LVS66Q4R.mjs} +3 -3
  26. package/dist/transform/index.cjs +31 -14
  27. package/dist/transform/index.mjs +31 -14
  28. package/dist/transform/styles.cjs +31 -13
  29. package/dist/transform/styles.d.cts +27 -1
  30. package/dist/transform/styles.d.ts +27 -1
  31. package/dist/transform/styles.d.ts.map +1 -1
  32. package/dist/transform/styles.js +45 -16
  33. package/dist/transform/styles.mjs +31 -13
  34. package/dist/transform/templates.cjs +30 -13
  35. package/dist/transform/templates.mjs +30 -13
  36. package/dist/{transform-GBP6Y4UI.mjs → transform-P4AETYV4.mjs} +12 -563
  37. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  38. package/dist/vite-styles.cjs +66 -23
  39. package/dist/vite-styles.d.cts +16 -7
  40. package/dist/vite-styles.d.ts +16 -7
  41. package/dist/vite-styles.d.ts.map +1 -1
  42. package/dist/vite-styles.js +68 -25
  43. package/dist/vite-styles.mjs +78 -23
  44. package/package.json +4 -4
@@ -28,7 +28,8 @@ __export(styles_exports, {
28
28
  printStyle: () => printStyle,
29
29
  printStyleWithMap: () => printStyleWithMap,
30
30
  scopeNodes: () => scopeNodes,
31
- scopeSelector: () => scopeSelector
31
+ scopeSelector: () => scopeSelector,
32
+ styleIds: () => styleIds
32
33
  });
33
34
  module.exports = __toCommonJS(styles_exports);
34
35
  var import_sourcemap_codec = require("@jridgewell/sourcemap-codec");
@@ -87,7 +88,7 @@ function collectStyles(program, sourceName, options, tags = { html: /* @__PURE__
87
88
  const imported = literalsOf.imports.get(name);
88
89
  if (imported) {
89
90
  const nodes = options?.imported?.get(`${imported.source}#${imported.name}`);
90
- if (nodes) return nodes.map(dropLoc);
91
+ if (nodes) return nodes.map((n) => keepLocIn(n, options?.importedModules));
91
92
  plan.references.push({ name: imported.name, source: imported.source, ...at });
92
93
  plan.diagnostics.push({
93
94
  ...at,
@@ -111,7 +112,7 @@ function collectStyles(program, sourceName, options, tags = { html: /* @__PURE__
111
112
  const nodes = resolveLiteral(name, at, []);
112
113
  const id = hash(`${sourceName}:css:${name}`);
113
114
  plan.edits.push({ start: literal.start, end: literal.end, code: `({ $fxStyle: ${JSON.stringify(id)} })` });
114
- if (nodes) plan.literals.push({ id, name, css: printStyle(nodes, options.minify) });
115
+ if (nodes) plan.literals.push({ id, name, css: printStyle(nodes, options.minify), nodes });
115
116
  }
116
117
  const scopeOf = /* @__PURE__ */ new Map();
117
118
  const names = /* @__PURE__ */ new Map();
@@ -186,7 +187,7 @@ function collectStyles(program, sourceName, options, tags = { html: /* @__PURE__
186
187
  if (!plan.scopes.some((s) => s.value === id)) plan.scopes.push({ start: owner.start, end: owner.end, value: id });
187
188
  nodes = scopeNodes(nodes, id, (message) => plan.diagnostics.push({ ...at, message }));
188
189
  }
189
- const printed = module2 ? printStyleWithMap(nodes, options.minify, sourceName, module2) : { css: printStyle(nodes, options.minify) };
190
+ const printed = module2 ? printStyleWithMap(nodes, options.minify, sourceName, module2, options.importedModules) : { css: printStyle(nodes, options.minify) };
190
191
  plan.styles.push({ id, scoped: scoped && !shadow, component, ...printed, ...shadow ? { shadow: true } : {}, ...at });
191
192
  if (shadow) shadow.indexes.push(plan.styles.length - 1);
192
193
  };
@@ -225,6 +226,11 @@ function staticMember(cls, name) {
225
226
  (m) => m.type === "ClassProperty" && m.static && (m.key.type === "Identifier" && m.key.name === name || m.key.type === "StringLiteral" && m.key.value === name)
226
227
  );
227
228
  }
229
+ var styleIds = {
230
+ block: (owner, index) => `${owner}.fx-${index}.css`,
231
+ inline: (owner, index) => `${owner}.fx-${index}.css?inline`,
232
+ literal: (owner, name) => `${owner}.fx-literal-${name}.css?inline`
233
+ };
228
234
  function finishShadowStyles(plan, code, moduleId) {
229
235
  const edits = [];
230
236
  const imports = [];
@@ -236,7 +242,7 @@ function finishShadowStyles(plan, code, moduleId) {
236
242
  return local;
237
243
  };
238
244
  for (const shadow of plan.shadowClasses.values()) {
239
- const blocks = shadow.indexes.map((i) => importOf(`${moduleId}?fx-style&index=${i}&inline&lang.css`));
245
+ const blocks = shadow.indexes.map((i) => importOf(styleIds.inline(moduleId, i)));
240
246
  let value;
241
247
  const prop = shadow.styles;
242
248
  if (prop?.value) {
@@ -244,7 +250,7 @@ function finishShadowStyles(plan, code, moduleId) {
244
250
  let text = code.slice(start, prop.value.end);
245
251
  const replacements = [];
246
252
  walkIdentifiers(prop.value, (id) => {
247
- const local = plan.names?.literals.has(id.name) ? importOf(`${moduleId}?fx-literal=${id.name}&inline&lang.css`) : plan.names?.imports.has(id.name) && !/\.css(\?|$)/.test(plan.names.imports.get(id.name).source) ? importOf(`${plan.names.imports.get(id.name).source}?fx-literal=${plan.names.imports.get(id.name).name}&inline&lang.css`) : void 0;
253
+ const local = plan.names?.literals.has(id.name) ? importOf(styleIds.literal(moduleId, id.name)) : plan.names?.imports.has(id.name) && !/\.css(\?|$)/.test(plan.names.imports.get(id.name).source) ? importOf(styleIds.literal(plan.names.imports.get(id.name).source, plan.names.imports.get(id.name).name)) : void 0;
248
254
  if (local) replacements.push({ at: id.start - start, length: id.name.length, with: local });
249
255
  });
250
256
  for (const r of replacements.sort((a, b) => b.at - a.at)) text = text.slice(0, r.at) + r.with + text.slice(r.at + r.length);
@@ -526,12 +532,23 @@ function shiftLoc(node, source, start) {
526
532
  if (node.kind === "rule" || node.kind === "at-rule") return { ...node, loc, nodes: node.nodes.map((n) => shiftLoc(n, source, start)) };
527
533
  return { ...node, loc };
528
534
  }
529
- function dropLoc(node) {
530
- const { loc: _loc, ...rest } = node;
531
- if (rest.kind === "rule" || rest.kind === "at-rule") return { ...rest, nodes: rest.nodes.map(dropLoc) };
532
- return rest;
535
+ function keepLocIn(node, modules) {
536
+ const keep = node.loc !== void 0 && modules?.has(node.loc.source) === true;
537
+ const { loc, ...rest } = node;
538
+ const kept = keep ? { ...rest, loc } : rest;
539
+ if (kept.kind === "rule" || kept.kind === "at-rule") return { ...kept, nodes: kept.nodes.map((n) => keepLocIn(n, modules)) };
540
+ return kept;
533
541
  }
534
- function printStyleWithMap(nodes, minify, sourceName, module2) {
542
+ function printStyleWithMap(nodes, minify, sourceName, module2, others) {
543
+ const sources = [module2];
544
+ const index = /* @__PURE__ */ new Map([[sourceName, 0]]);
545
+ const sourceOf = (name) => {
546
+ if (index.has(name)) return index.get(name);
547
+ const other = others?.get(name);
548
+ if (!other) return void 0;
549
+ index.set(name, sources.push(other) - 1);
550
+ return index.get(name);
551
+ };
535
552
  const lines = [[]];
536
553
  let css = "";
537
554
  let column = 0;
@@ -545,7 +562,8 @@ function printStyleWithMap(nodes, minify, sourceName, module2) {
545
562
  }
546
563
  };
547
564
  const mark = (loc) => {
548
- if (loc && loc.source === sourceName) lines[lines.length - 1].push([column, 0, loc.line - 1, loc.column]);
565
+ const at = loc ? sourceOf(loc.source) : void 0;
566
+ if (loc && at !== void 0) lines[lines.length - 1].push([column, at, loc.line - 1, loc.column]);
549
567
  };
550
568
  const write = (node, depth) => {
551
569
  const pad = minify ? "" : " ".repeat(depth);
@@ -564,7 +582,7 @@ function printStyleWithMap(nodes, minify, sourceName, module2) {
564
582
  }
565
583
  };
566
584
  for (const node of nodes) write(node, 0);
567
- return { css, map: { version: 3, sources: [module2.id], sourcesContent: [module2.code], names: [], mappings: (0, import_sourcemap_codec.encode)(lines) } };
585
+ return { css, map: { version: 3, sources: sources.map((s) => s.id), sourcesContent: sources.map((s) => s.code), names: [], mappings: (0, import_sourcemap_codec.encode)(lines) } };
568
586
  }
569
587
  function printStyle(nodes, minify = false) {
570
588
  const out = [];
@@ -59,6 +59,14 @@ export interface StyleOptions {
59
59
  * the import names them. A reference not in here is reported in `styleReferences`.
60
60
  */
61
61
  imported?: Map<string, StyleNode[]>;
62
+ /**
63
+ * The modules those values were written in, by the name their positions carry: with them, a
64
+ * composed value's rules map back to that module's lines. Without, they are left unmapped.
65
+ */
66
+ importedModules?: Map<string, {
67
+ id: string;
68
+ code: string;
69
+ }>;
62
70
  }
63
71
  /** A `css`` value: portable, unscoped, emitted only where something uses it. */
64
72
  export interface StyleLiteral {
@@ -66,6 +74,8 @@ export interface StyleLiteral {
66
74
  /** The variable it is bound to. */
67
75
  name: string;
68
76
  css: string;
77
+ /** Its rules, positions in this module kept, for a module that composes it. */
78
+ nodes: StyleNode[];
69
79
  }
70
80
  /** An interpolated style value from another module, for the build to resolve. */
71
81
  export interface StyleReference {
@@ -185,6 +195,17 @@ export declare function applyTemplateStyles(ir: IRLike, t: TemplateStyles): void
185
195
  * `css`` values named in its `static styles` become `?inline` imports of their processed CSS
186
196
  * (the text `static styles` takes), and the class's `static styles` lists them.
187
197
  */
198
+ /**
199
+ * Where a component's style blocks and css`` values are served: next to the component, a path
200
+ * ending in `.css`. Every CSS tool in the bundler then sees CSS, and none sees TSX: Vite 8
201
+ * matches its transforms on the path without the query, so `card.tsx?…` would read as a .tsx.
202
+ * `?inline` (Vite's own) asks for the CSS as a string, for a shadow root.
203
+ */
204
+ export declare const styleIds: {
205
+ block: (owner: string, index: number) => string;
206
+ inline: (owner: string, index: number) => string;
207
+ literal: (owner: string, name: string) => string;
208
+ };
188
209
  export declare function finishShadowStyles(plan: StylePlan, code: string, moduleId: string): {
189
210
  start: number;
190
211
  end: number;
@@ -203,7 +224,12 @@ export declare function scopeSelector(selector: string, id: string, warn?: (mess
203
224
  export declare function printStyleWithMap(nodes: StyleNode[], minify: boolean | undefined, sourceName: string, module: {
204
225
  id: string;
205
226
  code: string;
206
- }): {
227
+ },
228
+ /** Other modules rules came from (composed css`` values), by the name their positions carry. */
229
+ others?: ReadonlyMap<string, {
230
+ id: string;
231
+ code: string;
232
+ }>): {
207
233
  css: string;
208
234
  map: StyleMap;
209
235
  };
@@ -59,6 +59,14 @@ export interface StyleOptions {
59
59
  * the import names them. A reference not in here is reported in `styleReferences`.
60
60
  */
61
61
  imported?: Map<string, StyleNode[]>;
62
+ /**
63
+ * The modules those values were written in, by the name their positions carry: with them, a
64
+ * composed value's rules map back to that module's lines. Without, they are left unmapped.
65
+ */
66
+ importedModules?: Map<string, {
67
+ id: string;
68
+ code: string;
69
+ }>;
62
70
  }
63
71
  /** A `css`` value: portable, unscoped, emitted only where something uses it. */
64
72
  export interface StyleLiteral {
@@ -66,6 +74,8 @@ export interface StyleLiteral {
66
74
  /** The variable it is bound to. */
67
75
  name: string;
68
76
  css: string;
77
+ /** Its rules, positions in this module kept, for a module that composes it. */
78
+ nodes: StyleNode[];
69
79
  }
70
80
  /** An interpolated style value from another module, for the build to resolve. */
71
81
  export interface StyleReference {
@@ -185,6 +195,17 @@ export declare function applyTemplateStyles(ir: IRLike, t: TemplateStyles): void
185
195
  * `css`` values named in its `static styles` become `?inline` imports of their processed CSS
186
196
  * (the text `static styles` takes), and the class's `static styles` lists them.
187
197
  */
198
+ /**
199
+ * Where a component's style blocks and css`` values are served: next to the component, a path
200
+ * ending in `.css`. Every CSS tool in the bundler then sees CSS, and none sees TSX: Vite 8
201
+ * matches its transforms on the path without the query, so `card.tsx?…` would read as a .tsx.
202
+ * `?inline` (Vite's own) asks for the CSS as a string, for a shadow root.
203
+ */
204
+ export declare const styleIds: {
205
+ block: (owner: string, index: number) => string;
206
+ inline: (owner: string, index: number) => string;
207
+ literal: (owner: string, name: string) => string;
208
+ };
188
209
  export declare function finishShadowStyles(plan: StylePlan, code: string, moduleId: string): {
189
210
  start: number;
190
211
  end: number;
@@ -203,7 +224,12 @@ export declare function scopeSelector(selector: string, id: string, warn?: (mess
203
224
  export declare function printStyleWithMap(nodes: StyleNode[], minify: boolean | undefined, sourceName: string, module: {
204
225
  id: string;
205
226
  code: string;
206
- }): {
227
+ },
228
+ /** Other modules rules came from (composed css`` values), by the name their positions carry. */
229
+ others?: ReadonlyMap<string, {
230
+ id: string;
231
+ code: string;
232
+ }>): {
207
233
  css: string;
208
234
  map: StyleMap;
209
235
  };
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/transform/styles.ts"],"names":[],"mappings":"AAcA,uEAAuE;AACvE,UAAU,IAAI;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,GAAG,CAAC,EAAE;QAAE,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,E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,EAAE,MAAM,KAAK,IAAe,GAAG,SAAS,EAAE,CAMlH;AAED,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAe,GAAG,MAAM,CAI9G;AA4JD;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,SAAS,EAAE,EAClB,MAAM,EAAE,OAAO,GAAG,SAAS,EAC3B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AACpC,gGAAgG;AAChG,MAAM,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GACzD;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,QAAQ,CAAA;CAAE,CA4ChC;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,MAAM,UAAQ,GAAG,MAAM,CAmBrE"}
@@ -75,9 +75,9 @@ module) {
75
75
  const imported = literalsOf.imports.get(name);
76
76
  if (imported) {
77
77
  const nodes = options?.imported?.get(`${imported.source}#${imported.name}`);
78
- // Their positions count from printed CSS, not from any source file.
78
+ // Positions in a module the build named stay, for the map; any other is dropped.
79
79
  if (nodes)
80
- return nodes.map(dropLoc);
80
+ return nodes.map((n) => keepLocIn(n, options?.importedModules));
81
81
  plan.references.push({ name: imported.name, source: imported.source, ...at });
82
82
  // Without `imported` the host has not looked yet; with it, it looked and found nothing.
83
83
  plan.diagnostics.push({
@@ -106,7 +106,7 @@ module) {
106
106
  const id = hash(`${sourceName}:css:${name}`);
107
107
  plan.edits.push({ start: literal.start, end: literal.end, code: `({ $fxStyle: ${JSON.stringify(id)} })` });
108
108
  if (nodes)
109
- plan.literals.push({ id, name, css: printStyle(nodes, options.minify) });
109
+ plan.literals.push({ id, name, css: printStyle(nodes, options.minify), nodes });
110
110
  }
111
111
  const scopeOf = new Map();
112
112
  const names = new Map();
@@ -202,7 +202,9 @@ module) {
202
202
  plan.scopes.push({ start: owner.start, end: owner.end, value: id });
203
203
  nodes = scopeNodes(nodes, id, (message) => plan.diagnostics.push({ ...at, message }));
204
204
  }
205
- const printed = module ? printStyleWithMap(nodes, options.minify, sourceName, module) : { css: printStyle(nodes, options.minify) };
205
+ const printed = module
206
+ ? printStyleWithMap(nodes, options.minify, sourceName, module, options.importedModules)
207
+ : { css: printStyle(nodes, options.minify) };
206
208
  plan.styles.push({ id, scoped: scoped && !shadow, component, ...printed, ...(shadow ? { shadow: true } : {}), ...at });
207
209
  if (shadow)
208
210
  shadow.indexes.push(plan.styles.length - 1);
@@ -252,6 +254,17 @@ function staticMember(cls, name) {
252
254
  * `css`` values named in its `static styles` become `?inline` imports of their processed CSS
253
255
  * (the text `static styles` takes), and the class's `static styles` lists them.
254
256
  */
257
+ /**
258
+ * Where a component's style blocks and css`` values are served: next to the component, a path
259
+ * ending in `.css`. Every CSS tool in the bundler then sees CSS, and none sees TSX: Vite 8
260
+ * matches its transforms on the path without the query, so `card.tsx?…` would read as a .tsx.
261
+ * `?inline` (Vite's own) asks for the CSS as a string, for a shadow root.
262
+ */
263
+ export const styleIds = {
264
+ block: (owner, index) => `${owner}.fx-${index}.css`,
265
+ inline: (owner, index) => `${owner}.fx-${index}.css?inline`,
266
+ literal: (owner, name) => `${owner}.fx-literal-${name}.css?inline`,
267
+ };
255
268
  export function finishShadowStyles(plan, code, moduleId) {
256
269
  const edits = [];
257
270
  const imports = [];
@@ -262,7 +275,7 @@ export function finishShadowStyles(plan, code, moduleId) {
262
275
  return local;
263
276
  };
264
277
  for (const shadow of plan.shadowClasses.values()) {
265
- const blocks = shadow.indexes.map((i) => importOf(`${moduleId}?fx-style&index=${i}&inline&lang.css`));
278
+ const blocks = shadow.indexes.map((i) => importOf(styleIds.inline(moduleId, i)));
266
279
  let value;
267
280
  const prop = shadow.styles;
268
281
  if (prop?.value) {
@@ -272,9 +285,9 @@ export function finishShadowStyles(plan, code, moduleId) {
272
285
  const replacements = [];
273
286
  walkIdentifiers(prop.value, (id) => {
274
287
  const local = plan.names?.literals.has(id.name)
275
- ? importOf(`${moduleId}?fx-literal=${id.name}&inline&lang.css`)
288
+ ? importOf(styleIds.literal(moduleId, id.name))
276
289
  : plan.names?.imports.has(id.name) && !/\.css(\?|$)/.test(plan.names.imports.get(id.name).source)
277
- ? importOf(`${plan.names.imports.get(id.name).source}?fx-literal=${plan.names.imports.get(id.name).name}&inline&lang.css`)
290
+ ? importOf(styleIds.literal(plan.names.imports.get(id.name).source, plan.names.imports.get(id.name).name))
278
291
  : undefined;
279
292
  if (local)
280
293
  replacements.push({ at: id.start - start, length: id.name.length, with: local });
@@ -636,17 +649,32 @@ function shiftLoc(node, source, start) {
636
649
  return { ...node, loc, nodes: node.nodes.map((n) => shiftLoc(n, source, start)) };
637
650
  return { ...node, loc };
638
651
  }
639
- function dropLoc(node) {
640
- const { loc: _loc, ...rest } = node;
641
- if (rest.kind === 'rule' || rest.kind === 'at-rule')
642
- return { ...rest, nodes: rest.nodes.map(dropLoc) };
643
- return rest;
652
+ function keepLocIn(node, modules) {
653
+ const keep = node.loc !== undefined && modules?.has(node.loc.source) === true;
654
+ const { loc, ...rest } = node;
655
+ const kept = keep ? { ...rest, loc } : rest;
656
+ if (kept.kind === 'rule' || kept.kind === 'at-rule')
657
+ return { ...kept, nodes: kept.nodes.map((n) => keepLocIn(n, modules)) };
658
+ return kept;
644
659
  }
645
660
  /**
646
661
  * Prints like `printStyle`, with a map from each rule and declaration back to where it was
647
662
  * written in the module: the browser's devtools then show the `.tsx` line, not the generated CSS.
648
663
  */
649
- export function printStyleWithMap(nodes, minify, sourceName, module) {
664
+ export function printStyleWithMap(nodes, minify, sourceName, module,
665
+ /** Other modules rules came from (composed css`` values), by the name their positions carry. */
666
+ others) {
667
+ const sources = [module];
668
+ const index = new Map([[sourceName, 0]]);
669
+ const sourceOf = (name) => {
670
+ if (index.has(name))
671
+ return index.get(name);
672
+ const other = others?.get(name);
673
+ if (!other)
674
+ return undefined;
675
+ index.set(name, sources.push(other) - 1);
676
+ return index.get(name);
677
+ };
650
678
  const lines = [[]];
651
679
  let css = '';
652
680
  let column = 0;
@@ -662,8 +690,9 @@ export function printStyleWithMap(nodes, minify, sourceName, module) {
662
690
  }
663
691
  };
664
692
  const mark = (loc) => {
665
- if (loc && loc.source === sourceName)
666
- lines[lines.length - 1].push([column, 0, loc.line - 1, loc.column]);
693
+ const at = loc ? sourceOf(loc.source) : undefined;
694
+ if (loc && at !== undefined)
695
+ lines[lines.length - 1].push([column, at, loc.line - 1, loc.column]);
667
696
  };
668
697
  const write = (node, depth) => {
669
698
  const pad = minify ? '' : ' '.repeat(depth);
@@ -686,7 +715,7 @@ export function printStyleWithMap(nodes, minify, sourceName, module) {
686
715
  };
687
716
  for (const node of nodes)
688
717
  write(node, 0);
689
- return { css, map: { version: 3, sources: [module.id], sourcesContent: [module.code], names: [], mappings: encode(lines) } };
718
+ return { css, map: { version: 3, sources: sources.map((s) => s.id), sourcesContent: sources.map((s) => s.code), names: [], mappings: encode(lines) } };
690
719
  }
691
720
  export function printStyle(nodes, minify = false) {
692
721
  const out = [];
@@ -141,7 +141,7 @@ function collectStyles(program, sourceName, options, tags = { html: /* @__PURE__
141
141
  const imported = literalsOf.imports.get(name);
142
142
  if (imported) {
143
143
  const nodes = options?.imported?.get(`${imported.source}#${imported.name}`);
144
- if (nodes) return nodes.map(dropLoc);
144
+ if (nodes) return nodes.map((n) => keepLocIn(n, options?.importedModules));
145
145
  plan.references.push({ name: imported.name, source: imported.source, ...at });
146
146
  plan.diagnostics.push({
147
147
  ...at,
@@ -165,7 +165,7 @@ function collectStyles(program, sourceName, options, tags = { html: /* @__PURE__
165
165
  const nodes = resolveLiteral(name, at, []);
166
166
  const id = hash(`${sourceName}:css:${name}`);
167
167
  plan.edits.push({ start: literal.start, end: literal.end, code: `({ $fxStyle: ${JSON.stringify(id)} })` });
168
- if (nodes) plan.literals.push({ id, name, css: printStyle(nodes, options.minify) });
168
+ if (nodes) plan.literals.push({ id, name, css: printStyle(nodes, options.minify), nodes });
169
169
  }
170
170
  const scopeOf = /* @__PURE__ */ new Map();
171
171
  const names = /* @__PURE__ */ new Map();
@@ -240,7 +240,7 @@ function collectStyles(program, sourceName, options, tags = { html: /* @__PURE__
240
240
  if (!plan.scopes.some((s) => s.value === id)) plan.scopes.push({ start: owner.start, end: owner.end, value: id });
241
241
  nodes = scopeNodes(nodes, id, (message) => plan.diagnostics.push({ ...at, message }));
242
242
  }
243
- const printed = module ? printStyleWithMap(nodes, options.minify, sourceName, module) : { css: printStyle(nodes, options.minify) };
243
+ const printed = module ? printStyleWithMap(nodes, options.minify, sourceName, module, options.importedModules) : { css: printStyle(nodes, options.minify) };
244
244
  plan.styles.push({ id, scoped: scoped && !shadow, component, ...printed, ...shadow ? { shadow: true } : {}, ...at });
245
245
  if (shadow) shadow.indexes.push(plan.styles.length - 1);
246
246
  };
@@ -279,6 +279,11 @@ function staticMember(cls, name) {
279
279
  (m) => m.type === "ClassProperty" && m.static && (m.key.type === "Identifier" && m.key.name === name || m.key.type === "StringLiteral" && m.key.value === name)
280
280
  );
281
281
  }
282
+ var styleIds = {
283
+ block: (owner, index) => `${owner}.fx-${index}.css`,
284
+ inline: (owner, index) => `${owner}.fx-${index}.css?inline`,
285
+ literal: (owner, name) => `${owner}.fx-literal-${name}.css?inline`
286
+ };
282
287
  function finishShadowStyles(plan, code, moduleId) {
283
288
  const edits = [];
284
289
  const imports = [];
@@ -290,7 +295,7 @@ function finishShadowStyles(plan, code, moduleId) {
290
295
  return local;
291
296
  };
292
297
  for (const shadow of plan.shadowClasses.values()) {
293
- const blocks = shadow.indexes.map((i) => importOf(`${moduleId}?fx-style&index=${i}&inline&lang.css`));
298
+ const blocks = shadow.indexes.map((i) => importOf(styleIds.inline(moduleId, i)));
294
299
  let value;
295
300
  const prop = shadow.styles;
296
301
  if (prop?.value) {
@@ -298,7 +303,7 @@ function finishShadowStyles(plan, code, moduleId) {
298
303
  let text = code.slice(start, prop.value.end);
299
304
  const replacements = [];
300
305
  walkIdentifiers(prop.value, (id) => {
301
- const local = plan.names?.literals.has(id.name) ? importOf(`${moduleId}?fx-literal=${id.name}&inline&lang.css`) : plan.names?.imports.has(id.name) && !/\.css(\?|$)/.test(plan.names.imports.get(id.name).source) ? importOf(`${plan.names.imports.get(id.name).source}?fx-literal=${plan.names.imports.get(id.name).name}&inline&lang.css`) : void 0;
306
+ const local = plan.names?.literals.has(id.name) ? importOf(styleIds.literal(moduleId, id.name)) : plan.names?.imports.has(id.name) && !/\.css(\?|$)/.test(plan.names.imports.get(id.name).source) ? importOf(styleIds.literal(plan.names.imports.get(id.name).source, plan.names.imports.get(id.name).name)) : void 0;
302
307
  if (local) replacements.push({ at: id.start - start, length: id.name.length, with: local });
303
308
  });
304
309
  for (const r of replacements.sort((a, b) => b.at - a.at)) text = text.slice(0, r.at) + r.with + text.slice(r.at + r.length);
@@ -580,12 +585,23 @@ function shiftLoc(node, source, start) {
580
585
  if (node.kind === "rule" || node.kind === "at-rule") return { ...node, loc, nodes: node.nodes.map((n) => shiftLoc(n, source, start)) };
581
586
  return { ...node, loc };
582
587
  }
583
- function dropLoc(node) {
584
- const { loc: _loc, ...rest } = node;
585
- if (rest.kind === "rule" || rest.kind === "at-rule") return { ...rest, nodes: rest.nodes.map(dropLoc) };
586
- return rest;
588
+ function keepLocIn(node, modules) {
589
+ const keep = node.loc !== void 0 && modules?.has(node.loc.source) === true;
590
+ const { loc, ...rest } = node;
591
+ const kept = keep ? { ...rest, loc } : rest;
592
+ if (kept.kind === "rule" || kept.kind === "at-rule") return { ...kept, nodes: kept.nodes.map((n) => keepLocIn(n, modules)) };
593
+ return kept;
587
594
  }
588
- function printStyleWithMap(nodes, minify, sourceName, module) {
595
+ function printStyleWithMap(nodes, minify, sourceName, module, others) {
596
+ const sources = [module];
597
+ const index = /* @__PURE__ */ new Map([[sourceName, 0]]);
598
+ const sourceOf = (name) => {
599
+ if (index.has(name)) return index.get(name);
600
+ const other = others?.get(name);
601
+ if (!other) return void 0;
602
+ index.set(name, sources.push(other) - 1);
603
+ return index.get(name);
604
+ };
589
605
  const lines = [[]];
590
606
  let css = "";
591
607
  let column = 0;
@@ -599,7 +615,8 @@ function printStyleWithMap(nodes, minify, sourceName, module) {
599
615
  }
600
616
  };
601
617
  const mark = (loc) => {
602
- if (loc && loc.source === sourceName) lines[lines.length - 1].push([column, 0, loc.line - 1, loc.column]);
618
+ const at = loc ? sourceOf(loc.source) : void 0;
619
+ if (loc && at !== void 0) lines[lines.length - 1].push([column, at, loc.line - 1, loc.column]);
603
620
  };
604
621
  const write = (node, depth) => {
605
622
  const pad = minify ? "" : " ".repeat(depth);
@@ -618,7 +635,7 @@ function printStyleWithMap(nodes, minify, sourceName, module) {
618
635
  }
619
636
  };
620
637
  for (const node of nodes) write(node, 0);
621
- return { css, map: { version: 3, sources: [module.id], sourcesContent: [module.code], names: [], mappings: encode(lines) } };
638
+ return { css, map: { version: 3, sources: sources.map((s) => s.id), sourcesContent: sources.map((s) => s.code), names: [], mappings: encode(lines) } };
622
639
  }
623
640
  function printStyle(nodes, minify = false) {
624
641
  const out = [];
@@ -649,5 +666,6 @@ export {
649
666
  printStyle,
650
667
  printStyleWithMap,
651
668
  scopeNodes,
652
- scopeSelector
669
+ scopeSelector,
670
+ styleIds
653
671
  };
@@ -93,7 +93,7 @@ function collectStyles(program, sourceName, options, tags = { html: /* @__PURE__
93
93
  const imported = literalsOf.imports.get(name);
94
94
  if (imported) {
95
95
  const nodes = options?.imported?.get(`${imported.source}#${imported.name}`);
96
- if (nodes) return nodes.map(dropLoc);
96
+ if (nodes) return nodes.map((n) => keepLocIn(n, options?.importedModules));
97
97
  plan.references.push({ name: imported.name, source: imported.source, ...at });
98
98
  plan.diagnostics.push({
99
99
  ...at,
@@ -117,7 +117,7 @@ function collectStyles(program, sourceName, options, tags = { html: /* @__PURE__
117
117
  const nodes = resolveLiteral(name, at, []);
118
118
  const id = hash(`${sourceName}:css:${name}`);
119
119
  plan.edits.push({ start: literal.start, end: literal.end, code: `({ $fxStyle: ${JSON.stringify(id)} })` });
120
- if (nodes) plan.literals.push({ id, name, css: printStyle(nodes, options.minify) });
120
+ if (nodes) plan.literals.push({ id, name, css: printStyle(nodes, options.minify), nodes });
121
121
  }
122
122
  const scopeOf = /* @__PURE__ */ new Map();
123
123
  const names = /* @__PURE__ */ new Map();
@@ -192,7 +192,7 @@ function collectStyles(program, sourceName, options, tags = { html: /* @__PURE__
192
192
  if (!plan.scopes.some((s) => s.value === id)) plan.scopes.push({ start: owner.start, end: owner.end, value: id });
193
193
  nodes = scopeNodes(nodes, id, (message) => plan.diagnostics.push({ ...at, message }));
194
194
  }
195
- const printed = module2 ? printStyleWithMap(nodes, options.minify, sourceName, module2) : { css: printStyle(nodes, options.minify) };
195
+ const printed = module2 ? printStyleWithMap(nodes, options.minify, sourceName, module2, options.importedModules) : { css: printStyle(nodes, options.minify) };
196
196
  plan.styles.push({ id, scoped: scoped && !shadow, component, ...printed, ...shadow ? { shadow: true } : {}, ...at });
197
197
  if (shadow) shadow.indexes.push(plan.styles.length - 1);
198
198
  };
@@ -231,6 +231,11 @@ function staticMember(cls, name) {
231
231
  (m) => m.type === "ClassProperty" && m.static && (m.key.type === "Identifier" && m.key.name === name || m.key.type === "StringLiteral" && m.key.value === name)
232
232
  );
233
233
  }
234
+ var styleIds = {
235
+ block: (owner, index) => `${owner}.fx-${index}.css`,
236
+ inline: (owner, index) => `${owner}.fx-${index}.css?inline`,
237
+ literal: (owner, name) => `${owner}.fx-literal-${name}.css?inline`
238
+ };
234
239
  function finishShadowStyles(plan, code, moduleId) {
235
240
  const edits = [];
236
241
  const imports = [];
@@ -242,7 +247,7 @@ function finishShadowStyles(plan, code, moduleId) {
242
247
  return local;
243
248
  };
244
249
  for (const shadow of plan.shadowClasses.values()) {
245
- const blocks = shadow.indexes.map((i) => importOf(`${moduleId}?fx-style&index=${i}&inline&lang.css`));
250
+ const blocks = shadow.indexes.map((i) => importOf(styleIds.inline(moduleId, i)));
246
251
  let value;
247
252
  const prop = shadow.styles;
248
253
  if (prop?.value) {
@@ -250,7 +255,7 @@ function finishShadowStyles(plan, code, moduleId) {
250
255
  let text = code.slice(start, prop.value.end);
251
256
  const replacements = [];
252
257
  walkIdentifiers(prop.value, (id) => {
253
- const local = plan.names?.literals.has(id.name) ? importOf(`${moduleId}?fx-literal=${id.name}&inline&lang.css`) : plan.names?.imports.has(id.name) && !/\.css(\?|$)/.test(plan.names.imports.get(id.name).source) ? importOf(`${plan.names.imports.get(id.name).source}?fx-literal=${plan.names.imports.get(id.name).name}&inline&lang.css`) : void 0;
258
+ const local = plan.names?.literals.has(id.name) ? importOf(styleIds.literal(moduleId, id.name)) : plan.names?.imports.has(id.name) && !/\.css(\?|$)/.test(plan.names.imports.get(id.name).source) ? importOf(styleIds.literal(plan.names.imports.get(id.name).source, plan.names.imports.get(id.name).name)) : void 0;
254
259
  if (local) replacements.push({ at: id.start - start, length: id.name.length, with: local });
255
260
  });
256
261
  for (const r of replacements.sort((a, b) => b.at - a.at)) text = text.slice(0, r.at) + r.with + text.slice(r.at + r.length);
@@ -532,12 +537,23 @@ function shiftLoc(node, source, start) {
532
537
  if (node.kind === "rule" || node.kind === "at-rule") return { ...node, loc, nodes: node.nodes.map((n) => shiftLoc(n, source, start)) };
533
538
  return { ...node, loc };
534
539
  }
535
- function dropLoc(node) {
536
- const { loc: _loc, ...rest } = node;
537
- if (rest.kind === "rule" || rest.kind === "at-rule") return { ...rest, nodes: rest.nodes.map(dropLoc) };
538
- return rest;
539
- }
540
- function printStyleWithMap(nodes, minify, sourceName, module2) {
540
+ function keepLocIn(node, modules) {
541
+ const keep = node.loc !== void 0 && modules?.has(node.loc.source) === true;
542
+ const { loc, ...rest } = node;
543
+ const kept = keep ? { ...rest, loc } : rest;
544
+ if (kept.kind === "rule" || kept.kind === "at-rule") return { ...kept, nodes: kept.nodes.map((n) => keepLocIn(n, modules)) };
545
+ return kept;
546
+ }
547
+ function printStyleWithMap(nodes, minify, sourceName, module2, others) {
548
+ const sources = [module2];
549
+ const index = /* @__PURE__ */ new Map([[sourceName, 0]]);
550
+ const sourceOf = (name) => {
551
+ if (index.has(name)) return index.get(name);
552
+ const other = others?.get(name);
553
+ if (!other) return void 0;
554
+ index.set(name, sources.push(other) - 1);
555
+ return index.get(name);
556
+ };
541
557
  const lines = [[]];
542
558
  let css = "";
543
559
  let column = 0;
@@ -551,7 +567,8 @@ function printStyleWithMap(nodes, minify, sourceName, module2) {
551
567
  }
552
568
  };
553
569
  const mark = (loc) => {
554
- if (loc && loc.source === sourceName) lines[lines.length - 1].push([column, 0, loc.line - 1, loc.column]);
570
+ const at = loc ? sourceOf(loc.source) : void 0;
571
+ if (loc && at !== void 0) lines[lines.length - 1].push([column, at, loc.line - 1, loc.column]);
555
572
  };
556
573
  const write = (node, depth) => {
557
574
  const pad = minify ? "" : " ".repeat(depth);
@@ -570,7 +587,7 @@ function printStyleWithMap(nodes, minify, sourceName, module2) {
570
587
  }
571
588
  };
572
589
  for (const node of nodes) write(node, 0);
573
- return { css, map: { version: 3, sources: [module2.id], sourcesContent: [module2.code], names: [], mappings: (0, import_sourcemap_codec.encode)(lines) } };
590
+ return { css, map: { version: 3, sources: sources.map((s) => s.id), sourcesContent: sources.map((s) => s.code), names: [], mappings: (0, import_sourcemap_codec.encode)(lines) } };
574
591
  }
575
592
  function printStyle(nodes, minify = false) {
576
593
  const out = [];