@pikacss/integration 0.0.41 → 0.0.43

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
@@ -62,10 +62,12 @@ function createEventHook() {
62
62
  //#endregion
63
63
  //#region src/tsCodegen.ts
64
64
  function formatUnionStringType(list) {
65
- return list.length > 0 ? list.map((i) => typeof i === "number" ? i : `'${i}'`).join(" | ") : "never";
65
+ return list.length > 0 ? list.map((i) => typeof i === "number" ? String(i) : JSON.stringify(i)).join(" | ") : "never";
66
66
  }
67
67
  function generateAutocomplete(ctx) {
68
68
  const autocomplete = ctx.engine.config.autocomplete;
69
+ const { layers } = ctx.engine.config;
70
+ const layerNames = (0, _pikacss_core.sortLayerNames)(layers);
69
71
  return [
70
72
  "export type Autocomplete = DefineAutocomplete<{",
71
73
  ` Selector: ${formatUnionStringType([...autocomplete.selectors])}`,
@@ -74,6 +76,7 @@ function generateAutocomplete(ctx) {
74
76
  ` ExtraCssProperty: ${formatUnionStringType([...autocomplete.extraCssProperties])}`,
75
77
  ` PropertiesValue: { ${Array.from(autocomplete.properties.entries(), ([k, v]) => `'${k}': ${v.join(" | ")}`).join(",")} }`,
76
78
  ` CssPropertiesValue: { ${Array.from(autocomplete.cssProperties.entries(), ([k, v]) => `'${k}': ${formatUnionStringType(v)}`).join(",")} }`,
79
+ ` Layer: ${formatUnionStringType(layerNames)}`,
77
80
  "}>",
78
81
  ""
79
82
  ];
@@ -518,11 +521,15 @@ function createCtx(options) {
518
521
  _pikacss_core.log.debug("Generating CSS code");
519
522
  const atomicStyleIds = [...new Set([...ctx.usages.values()].flatMap((i) => [...new Set(i.flatMap((i$1) => i$1.atomicStyleIds))]))];
520
523
  _pikacss_core.log.debug(`Collecting ${atomicStyleIds.length} atomic style IDs`);
524
+ const layerDecl = ctx.engine.renderLayerOrderDeclaration();
525
+ const preflightsCss = await ctx.engine.renderPreflights(true);
526
+ const atomicCss = await ctx.engine.renderAtomicStyles(true, { atomicStyleIds });
521
527
  return [
522
528
  `/* Auto-generated by ${ctx.currentPackageName} */`,
523
- await ctx.engine.renderPreflights(true),
524
- await ctx.engine.renderAtomicStyles(true, { atomicStyleIds })
525
- ].join("\n").trim();
529
+ layerDecl,
530
+ preflightsCss,
531
+ atomicCss
532
+ ].filter((s) => s.trim() !== "").join("\n").trim();
526
533
  },
527
534
  getTsCodegenContent: async () => {
528
535
  await ctx.setupPromise;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { statSync } from "node:fs";
2
2
  import { mkdir, readFile, writeFile } from "node:fs/promises";
3
- import { createEngine, defineEnginePlugin, log } from "@pikacss/core";
3
+ import { createEngine, defineEnginePlugin, log, sortLayerNames } from "@pikacss/core";
4
4
  import { computed, signal } from "alien-signals";
5
5
  import { globbyStream } from "globby";
6
6
  import { klona } from "klona";
@@ -36,10 +36,12 @@ function createEventHook() {
36
36
  //#endregion
37
37
  //#region src/tsCodegen.ts
38
38
  function formatUnionStringType(list) {
39
- return list.length > 0 ? list.map((i) => typeof i === "number" ? i : `'${i}'`).join(" | ") : "never";
39
+ return list.length > 0 ? list.map((i) => typeof i === "number" ? String(i) : JSON.stringify(i)).join(" | ") : "never";
40
40
  }
41
41
  function generateAutocomplete(ctx) {
42
42
  const autocomplete = ctx.engine.config.autocomplete;
43
+ const { layers } = ctx.engine.config;
44
+ const layerNames = sortLayerNames(layers);
43
45
  return [
44
46
  "export type Autocomplete = DefineAutocomplete<{",
45
47
  ` Selector: ${formatUnionStringType([...autocomplete.selectors])}`,
@@ -48,6 +50,7 @@ function generateAutocomplete(ctx) {
48
50
  ` ExtraCssProperty: ${formatUnionStringType([...autocomplete.extraCssProperties])}`,
49
51
  ` PropertiesValue: { ${Array.from(autocomplete.properties.entries(), ([k, v]) => `'${k}': ${v.join(" | ")}`).join(",")} }`,
50
52
  ` CssPropertiesValue: { ${Array.from(autocomplete.cssProperties.entries(), ([k, v]) => `'${k}': ${formatUnionStringType(v)}`).join(",")} }`,
53
+ ` Layer: ${formatUnionStringType(layerNames)}`,
51
54
  "}>",
52
55
  ""
53
56
  ];
@@ -492,11 +495,15 @@ function createCtx(options) {
492
495
  log.debug("Generating CSS code");
493
496
  const atomicStyleIds = [...new Set([...ctx.usages.values()].flatMap((i) => [...new Set(i.flatMap((i$1) => i$1.atomicStyleIds))]))];
494
497
  log.debug(`Collecting ${atomicStyleIds.length} atomic style IDs`);
498
+ const layerDecl = ctx.engine.renderLayerOrderDeclaration();
499
+ const preflightsCss = await ctx.engine.renderPreflights(true);
500
+ const atomicCss = await ctx.engine.renderAtomicStyles(true, { atomicStyleIds });
495
501
  return [
496
502
  `/* Auto-generated by ${ctx.currentPackageName} */`,
497
- await ctx.engine.renderPreflights(true),
498
- await ctx.engine.renderAtomicStyles(true, { atomicStyleIds })
499
- ].join("\n").trim();
503
+ layerDecl,
504
+ preflightsCss,
505
+ atomicCss
506
+ ].filter((s) => s.trim() !== "").join("\n").trim();
500
507
  },
501
508
  getTsCodegenContent: async () => {
502
509
  await ctx.setupPromise;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pikacss/integration",
3
3
  "type": "module",
4
- "version": "0.0.41",
4
+ "version": "0.0.43",
5
5
  "author": "DevilTea <ch19980814@gmail.com>",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -49,7 +49,7 @@
49
49
  "micromatch": "^4.0.8",
50
50
  "pathe": "^2.0.3",
51
51
  "perfect-debounce": "^2.0.0",
52
- "@pikacss/core": "0.0.41"
52
+ "@pikacss/core": "0.0.43"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/micromatch": "^4.0.10"