@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
@@ -1135,7 +1135,7 @@ function collectStyles(program, sourceName, options, tags = { html: /* @__PURE__
1135
1135
  const imported = literalsOf.imports.get(name);
1136
1136
  if (imported) {
1137
1137
  const nodes = options?.imported?.get(`${imported.source}#${imported.name}`);
1138
- if (nodes) return nodes.map(dropLoc);
1138
+ if (nodes) return nodes.map((n2) => keepLocIn(n2, options?.importedModules));
1139
1139
  plan.references.push({ name: imported.name, source: imported.source, ...at });
1140
1140
  plan.diagnostics.push({
1141
1141
  ...at,
@@ -1159,7 +1159,7 @@ function collectStyles(program, sourceName, options, tags = { html: /* @__PURE__
1159
1159
  const nodes = resolveLiteral(name, at, []);
1160
1160
  const id = hash(`${sourceName}:css:${name}`);
1161
1161
  plan.edits.push({ start: literal.start, end: literal.end, code: `({ $fxStyle: ${JSON.stringify(id)} })` });
1162
- if (nodes) plan.literals.push({ id, name, css: printStyle(nodes, options.minify) });
1162
+ if (nodes) plan.literals.push({ id, name, css: printStyle(nodes, options.minify), nodes });
1163
1163
  }
1164
1164
  const scopeOf = /* @__PURE__ */ new Map();
1165
1165
  const names = /* @__PURE__ */ new Map();
@@ -1234,7 +1234,7 @@ function collectStyles(program, sourceName, options, tags = { html: /* @__PURE__
1234
1234
  if (!plan.scopes.some((s) => s.value === id)) plan.scopes.push({ start: owner.start, end: owner.end, value: id });
1235
1235
  nodes = scopeNodes(nodes, id, (message) => plan.diagnostics.push({ ...at, message }));
1236
1236
  }
1237
- const printed = module ? printStyleWithMap(nodes, options.minify, sourceName, module) : { css: printStyle(nodes, options.minify) };
1237
+ const printed = module ? printStyleWithMap(nodes, options.minify, sourceName, module, options.importedModules) : { css: printStyle(nodes, options.minify) };
1238
1238
  plan.styles.push({ id, scoped: scoped && !shadow, component, ...printed, ...shadow ? { shadow: true } : {}, ...at });
1239
1239
  if (shadow) shadow.indexes.push(plan.styles.length - 1);
1240
1240
  };
@@ -1273,6 +1273,11 @@ function staticMember(cls, name) {
1273
1273
  (m) => m.type === "ClassProperty" && m.static && (m.key.type === "Identifier" && m.key.name === name || m.key.type === "StringLiteral" && m.key.value === name)
1274
1274
  );
1275
1275
  }
1276
+ var styleIds = {
1277
+ block: (owner, index) => `${owner}.fx-${index}.css`,
1278
+ inline: (owner, index) => `${owner}.fx-${index}.css?inline`,
1279
+ literal: (owner, name) => `${owner}.fx-literal-${name}.css?inline`
1280
+ };
1276
1281
  function finishShadowStyles(plan, code, moduleId) {
1277
1282
  const edits = [];
1278
1283
  const imports = [];
@@ -1284,7 +1289,7 @@ function finishShadowStyles(plan, code, moduleId) {
1284
1289
  return local;
1285
1290
  };
1286
1291
  for (const shadow of plan.shadowClasses.values()) {
1287
- const blocks = shadow.indexes.map((i) => importOf(`${moduleId}?fx-style&index=${i}&inline&lang.css`));
1292
+ const blocks = shadow.indexes.map((i) => importOf(styleIds.inline(moduleId, i)));
1288
1293
  let value;
1289
1294
  const prop = shadow.styles;
1290
1295
  if (prop?.value) {
@@ -1292,7 +1297,7 @@ function finishShadowStyles(plan, code, moduleId) {
1292
1297
  let text = code.slice(start, prop.value.end);
1293
1298
  const replacements = [];
1294
1299
  walkIdentifiers(prop.value, (id) => {
1295
- 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;
1300
+ 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;
1296
1301
  if (local) replacements.push({ at: id.start - start, length: id.name.length, with: local });
1297
1302
  });
1298
1303
  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);
@@ -1574,12 +1579,23 @@ function shiftLoc(node, source, start) {
1574
1579
  if (node.kind === "rule" || node.kind === "at-rule") return { ...node, loc, nodes: node.nodes.map((n2) => shiftLoc(n2, source, start)) };
1575
1580
  return { ...node, loc };
1576
1581
  }
1577
- function dropLoc(node) {
1578
- const { loc: _loc, ...rest } = node;
1579
- if (rest.kind === "rule" || rest.kind === "at-rule") return { ...rest, nodes: rest.nodes.map(dropLoc) };
1580
- return rest;
1581
- }
1582
- function printStyleWithMap(nodes, minify, sourceName, module) {
1582
+ function keepLocIn(node, modules) {
1583
+ const keep = node.loc !== void 0 && modules?.has(node.loc.source) === true;
1584
+ const { loc, ...rest } = node;
1585
+ const kept = keep ? { ...rest, loc } : rest;
1586
+ if (kept.kind === "rule" || kept.kind === "at-rule") return { ...kept, nodes: kept.nodes.map((n2) => keepLocIn(n2, modules)) };
1587
+ return kept;
1588
+ }
1589
+ function printStyleWithMap(nodes, minify, sourceName, module, others) {
1590
+ const sources = [module];
1591
+ const index = /* @__PURE__ */ new Map([[sourceName, 0]]);
1592
+ const sourceOf = (name) => {
1593
+ if (index.has(name)) return index.get(name);
1594
+ const other = others?.get(name);
1595
+ if (!other) return void 0;
1596
+ index.set(name, sources.push(other) - 1);
1597
+ return index.get(name);
1598
+ };
1583
1599
  const lines = [[]];
1584
1600
  let css = "";
1585
1601
  let column = 0;
@@ -1593,7 +1609,8 @@ function printStyleWithMap(nodes, minify, sourceName, module) {
1593
1609
  }
1594
1610
  };
1595
1611
  const mark = (loc) => {
1596
- if (loc && loc.source === sourceName) lines[lines.length - 1].push([column, 0, loc.line - 1, loc.column]);
1612
+ const at = loc ? sourceOf(loc.source) : void 0;
1613
+ if (loc && at !== void 0) lines[lines.length - 1].push([column, at, loc.line - 1, loc.column]);
1597
1614
  };
1598
1615
  const write = (node, depth) => {
1599
1616
  const pad = minify ? "" : " ".repeat(depth);
@@ -1612,7 +1629,7 @@ function printStyleWithMap(nodes, minify, sourceName, module) {
1612
1629
  }
1613
1630
  };
1614
1631
  for (const node of nodes) write(node, 0);
1615
- return { css, map: { version: 3, sources: [module.id], sourcesContent: [module.code], names: [], mappings: encode(lines) } };
1632
+ return { css, map: { version: 3, sources: sources.map((s) => s.id), sourcesContent: sources.map((s) => s.code), names: [], mappings: encode(lines) } };
1616
1633
  }
1617
1634
  function printStyle(nodes, minify = false) {
1618
1635
  const out = [];