@pikacss/integration 0.0.13 → 0.0.15

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
@@ -41,23 +41,23 @@ function formatUnionStringType(list) {
41
41
  function generateAutocomplete(ctx) {
42
42
  const autocomplete = ctx.engine.config.autocomplete;
43
43
  return [
44
- "export interface Autocomplete extends _Autocomplete {",
44
+ "export type Autocomplete = DefineAutocomplete<{",
45
45
  ` Selector: ${formatUnionStringType([...autocomplete.selectors])}`,
46
46
  ` StyleItemString: ${formatUnionStringType([...autocomplete.styleItemStrings])}`,
47
47
  ` ExtraProperty: ${formatUnionStringType([...autocomplete.extraProperties])}`,
48
48
  ` ExtraCssProperty: ${formatUnionStringType([...autocomplete.extraCssProperties])}`,
49
49
  ` PropertiesValue: { ${Array.from(autocomplete.properties.entries(), ([k, v]) => `'${k}': ${v.join(" | ")}`).join(",")} }`,
50
50
  ` CssPropertiesValue: { ${Array.from(autocomplete.cssProperties.entries(), ([k, v]) => `'${k}': ${formatUnionStringType(v)}`).join(",")} }`,
51
- "}",
51
+ "}>",
52
52
  ""
53
53
  ];
54
54
  }
55
55
  function generateStyleFn(ctx) {
56
56
  const { transformedFormat } = ctx;
57
57
  const lines = [
58
- "type StyleFn_Array = (...params: StyleItem<Autocomplete>[]) => string[]",
59
- "type StyleFn_String = (...params: StyleItem<Autocomplete>[]) => string",
60
- "type StyleFn_Inline = (...params: StyleItem<Autocomplete>[]) => void"
58
+ "type StyleFn_Array = (...params: StyleItem[]) => string[]",
59
+ "type StyleFn_String = (...params: StyleItem[]) => string",
60
+ "type StyleFn_Inline = (...params: StyleItem[]) => void"
61
61
  ];
62
62
  if (transformedFormat === "array")
63
63
  lines.push("type StyleFn_Normal = StyleFn_Array");
@@ -118,7 +118,7 @@ function generateVueDeclaration(ctx) {
118
118
  ""
119
119
  ];
120
120
  }
121
- async function generateOverloadContent(ctx) {
121
+ function generateOverloadContent(ctx) {
122
122
  const paramsLines = [];
123
123
  const fnsLines = [];
124
124
  const usages = [...ctx.usages.values()].flat();
@@ -153,22 +153,28 @@ async function generateOverloadContent(ctx) {
153
153
  ...paramsLines
154
154
  ];
155
155
  }
156
- async function generateTsCodegenContent(ctx) {
156
+ function generateTsCodegenContent(ctx) {
157
157
  const lines = [
158
158
  `// Auto-generated by ${ctx.currentPackageName}`,
159
- `import type { Autocomplete as _Autocomplete, StyleItem } from '${ctx.currentPackageName}'`,
160
- `import { createDefineEngineConfigFn } from '${ctx.currentPackageName}'`,
159
+ `import type { CSSProperty, CSSSelectors, DefineAutocomplete, Properties, StyleDefinition, StyleItem } from '${ctx.currentPackageName}'`,
160
+ "",
161
+ `declare module '${ctx.currentPackageName}' {`,
162
+ " interface PikaAugment {",
163
+ " Autocomplete: Autocomplete",
164
+ " Selector: Autocomplete['Selector'] | CSSSelectors",
165
+ " CSSProperty: Autocomplete['ExtraCssProperty'] | CSSProperty",
166
+ " Properties: Properties",
167
+ " StyleDefinition: StyleDefinition",
168
+ " StyleItem: StyleItem",
169
+ " }",
170
+ "}",
161
171
  ""
162
172
  ];
163
173
  lines.push(...generateAutocomplete(ctx));
164
- lines.push(
165
- "export const defineEngineConfig: ReturnType<typeof createDefineEngineConfigFn<Autocomplete>> = createDefineEngineConfigFn<Autocomplete>()",
166
- ""
167
- );
168
174
  lines.push(...generateStyleFn(ctx));
169
175
  lines.push(...generateGlobalDeclaration(ctx));
170
176
  lines.push(...generateVueDeclaration(ctx));
171
- lines.push(...await generateOverloadContent(ctx));
177
+ lines.push(...generateOverloadContent(ctx));
172
178
  return lines.join("\n");
173
179
  }
174
180
 
@@ -273,9 +279,10 @@ async function createCtx(options) {
273
279
  resolvedConfigPath = configSources[0];
274
280
  await promises.mkdir(pathe.dirname(resolvedConfigPath), { recursive: true }).catch(() => {
275
281
  });
276
- const from = tsCodegenFilepath == null ? currentPackageName : `./${pathe.relative(pathe.dirname(resolvedConfigPath), tsCodegenFilepath)}`;
282
+ const relativeTsCodegenFilepath = tsCodegenFilepath == null ? null : `./${pathe.relative(pathe.dirname(resolvedConfigPath), tsCodegenFilepath)}`;
277
283
  await promises.writeFile(resolvedConfigPath, [
278
- `import { defineEngineConfig } from '${from}'`,
284
+ ...relativeTsCodegenFilepath == null ? [] : [`/// <reference path="${relativeTsCodegenFilepath}" />`],
285
+ `import { defineEngineConfig } from '${currentPackageName}'`,
279
286
  "",
280
287
  "export default defineEngineConfig({",
281
288
  " // Add your PikaCSS engine config here",
@@ -291,16 +298,6 @@ async function createCtx(options) {
291
298
  },
292
299
  init: async () => {
293
300
  ctx.isReady = false;
294
- await promises.mkdir(pathe.dirname(devCssFilepath), { recursive: true }).catch(() => {
295
- });
296
- const isDevCssFileExists = await promises.stat(devCssFilepath).then((stat2) => stat2.isFile()).catch(() => false);
297
- if (isDevCssFileExists === false)
298
- await promises.writeFile(devCssFilepath, "");
299
- if (tsCodegenFilepath != null) {
300
- await promises.mkdir(pathe.dirname(tsCodegenFilepath), { recursive: true }).catch(() => {
301
- });
302
- await promises.writeFile(tsCodegenFilepath, "export function defineEngineConfig(config: any) { return config }");
303
- }
304
301
  ctx.usages.clear();
305
302
  const { config, file } = await ctx.loadConfig().catch((error) => {
306
303
  core.warn(`Failed to load config file: ${error.message}`, error);
@@ -319,6 +316,20 @@ async function createCtx(options) {
319
316
  atomicStyleAdded: () => ctx.hooks.styleUpdated.trigger(),
320
317
  autocompleteConfigUpdated: () => ctx.hooks.tsCodegenUpdated.trigger()
321
318
  });
319
+ await promises.mkdir(pathe.dirname(devCssFilepath), { recursive: true }).catch(() => {
320
+ });
321
+ const isDevCssFileExists = await promises.stat(devCssFilepath).then((stat2) => stat2.isFile()).catch(() => false);
322
+ if (isDevCssFileExists === false)
323
+ await promises.writeFile(devCssFilepath, "");
324
+ if (tsCodegenFilepath != null) {
325
+ await promises.mkdir(pathe.dirname(tsCodegenFilepath), { recursive: true }).catch(() => {
326
+ });
327
+ const isGenTsFileExists = await promises.stat(tsCodegenFilepath).then((stat2) => stat2.isFile()).catch(() => false);
328
+ if (isGenTsFileExists === false) {
329
+ const content = await generateTsCodegenContent(ctx);
330
+ await promises.writeFile(tsCodegenFilepath, content);
331
+ }
332
+ }
322
333
  ctx.isReady = true;
323
334
  },
324
335
  isReady: false,
@@ -335,7 +346,6 @@ async function createCtx(options) {
335
346
  if (functionCalls.length === 0)
336
347
  return;
337
348
  const usages = [];
338
- ctx.usages.set(id, usages);
339
349
  const transformed = new MagicString__default(code);
340
350
  for (const fnCall of functionCalls) {
341
351
  const functionCallStr = fnCall.snippet;
@@ -347,7 +357,6 @@ async function createCtx(options) {
347
357
  params: args
348
358
  };
349
359
  usages.push(usage);
350
- ctx.hooks.tsCodegenUpdated.trigger();
351
360
  let transformedContent;
352
361
  if (ctx.fnUtils.isNormal(fnCall.fnName)) {
353
362
  transformedContent = ctx.transformedFormat === "array" ? `[${names.map((n) => `'${n}'`).join(", ")}]` : ctx.transformedFormat === "string" ? `'${names.join(" ")}'` : names.join(" ");
@@ -362,6 +371,9 @@ async function createCtx(options) {
362
371
  }
363
372
  transformed.update(fnCall.start, fnCall.end + 1, transformedContent);
364
373
  }
374
+ ctx.usages.set(id, usages);
375
+ ctx.hooks.styleUpdated.trigger();
376
+ ctx.hooks.tsCodegenUpdated.trigger();
365
377
  return {
366
378
  code: transformed.toString(),
367
379
  map: transformed.generateMap({ hires: true })
@@ -371,7 +383,7 @@ async function createCtx(options) {
371
383
  return void 0;
372
384
  }
373
385
  },
374
- writeDevCssFile: async () => {
386
+ writeDevCssFile: () => {
375
387
  if (ctx.isReady === false)
376
388
  return;
377
389
  const atomicStyleIds = [...new Set([...ctx.usages.values()].flatMap((i) => [...new Set(i.flatMap((i2) => i2.atomicStyleIds))]))];
@@ -380,13 +392,13 @@ async function createCtx(options) {
380
392
  ctx.engine.renderPreflights(true),
381
393
  ctx.engine.renderAtomicStyles(true, { atomicStyleIds })
382
394
  ].join("\n").trim();
383
- await promises.writeFile(ctx.devCssFilepath, css);
395
+ node_fs.writeFileSync(ctx.devCssFilepath, css);
384
396
  },
385
- writeTsCodegenFile: async () => {
397
+ writeTsCodegenFile: () => {
386
398
  if (ctx.isReady === false || ctx.tsCodegenFilepath == null)
387
399
  return;
388
- const content = await generateTsCodegenContent(ctx);
389
- await promises.writeFile(ctx.tsCodegenFilepath, content);
400
+ const content = generateTsCodegenContent(ctx);
401
+ node_fs.writeFileSync(ctx.tsCodegenFilepath, content);
390
402
  }
391
403
  };
392
404
  await ctx.init();
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { EngineConfig, Engine } from '@pikacss/core';
1
+ import { EngineConfig, Nullish, Engine } from '@pikacss/core';
2
2
  export * from '@pikacss/core';
3
3
  import { SourceMap } from 'magic-string';
4
4
 
@@ -30,7 +30,7 @@ interface IntegrationContext {
30
30
  fnUtils: FnUtils;
31
31
  transformedFormat: 'string' | 'array' | 'inline';
32
32
  devCssFilepath: string;
33
- tsCodegenFilepath: string | null;
33
+ tsCodegenFilepath: string | Nullish;
34
34
  hasVue: boolean;
35
35
  usages: Map<string, UsageRecord[]>;
36
36
  hooks: {
@@ -50,20 +50,20 @@ interface IntegrationContext {
50
50
  init: () => Promise<any>;
51
51
  isReady: boolean;
52
52
  configSources: string[];
53
- resolvedConfigPath: string | null;
53
+ resolvedConfigPath: string | Nullish;
54
54
  engine: Engine;
55
55
  transform: (code: string, id: string) => Promise<{
56
56
  code: string;
57
57
  map: SourceMap;
58
- } | undefined>;
59
- writeDevCssFile: () => Promise<void>;
60
- writeTsCodegenFile: () => Promise<void>;
58
+ } | Nullish>;
59
+ writeDevCssFile: () => void;
60
+ writeTsCodegenFile: () => void;
61
61
  }
62
62
  interface IntegrationContextOptions {
63
63
  cwd: string;
64
64
  currentPackageName: string;
65
65
  target: string[];
66
- configOrPath: EngineConfig | string | null | undefined;
66
+ configOrPath: EngineConfig | string | Nullish;
67
67
  fnName: string;
68
68
  transformedFormat: 'string' | 'array' | 'inline';
69
69
  tsCodegen: false | string;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { EngineConfig, Engine } from '@pikacss/core';
1
+ import { EngineConfig, Nullish, Engine } from '@pikacss/core';
2
2
  export * from '@pikacss/core';
3
3
  import { SourceMap } from 'magic-string';
4
4
 
@@ -30,7 +30,7 @@ interface IntegrationContext {
30
30
  fnUtils: FnUtils;
31
31
  transformedFormat: 'string' | 'array' | 'inline';
32
32
  devCssFilepath: string;
33
- tsCodegenFilepath: string | null;
33
+ tsCodegenFilepath: string | Nullish;
34
34
  hasVue: boolean;
35
35
  usages: Map<string, UsageRecord[]>;
36
36
  hooks: {
@@ -50,20 +50,20 @@ interface IntegrationContext {
50
50
  init: () => Promise<any>;
51
51
  isReady: boolean;
52
52
  configSources: string[];
53
- resolvedConfigPath: string | null;
53
+ resolvedConfigPath: string | Nullish;
54
54
  engine: Engine;
55
55
  transform: (code: string, id: string) => Promise<{
56
56
  code: string;
57
57
  map: SourceMap;
58
- } | undefined>;
59
- writeDevCssFile: () => Promise<void>;
60
- writeTsCodegenFile: () => Promise<void>;
58
+ } | Nullish>;
59
+ writeDevCssFile: () => void;
60
+ writeTsCodegenFile: () => void;
61
61
  }
62
62
  interface IntegrationContextOptions {
63
63
  cwd: string;
64
64
  currentPackageName: string;
65
65
  target: string[];
66
- configOrPath: EngineConfig | string | null | undefined;
66
+ configOrPath: EngineConfig | string | Nullish;
67
67
  fnName: string;
68
68
  transformedFormat: 'string' | 'array' | 'inline';
69
69
  tsCodegen: false | string;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { EngineConfig, Engine } from '@pikacss/core';
1
+ import { EngineConfig, Nullish, Engine } from '@pikacss/core';
2
2
  export * from '@pikacss/core';
3
3
  import { SourceMap } from 'magic-string';
4
4
 
@@ -30,7 +30,7 @@ interface IntegrationContext {
30
30
  fnUtils: FnUtils;
31
31
  transformedFormat: 'string' | 'array' | 'inline';
32
32
  devCssFilepath: string;
33
- tsCodegenFilepath: string | null;
33
+ tsCodegenFilepath: string | Nullish;
34
34
  hasVue: boolean;
35
35
  usages: Map<string, UsageRecord[]>;
36
36
  hooks: {
@@ -50,20 +50,20 @@ interface IntegrationContext {
50
50
  init: () => Promise<any>;
51
51
  isReady: boolean;
52
52
  configSources: string[];
53
- resolvedConfigPath: string | null;
53
+ resolvedConfigPath: string | Nullish;
54
54
  engine: Engine;
55
55
  transform: (code: string, id: string) => Promise<{
56
56
  code: string;
57
57
  map: SourceMap;
58
- } | undefined>;
59
- writeDevCssFile: () => Promise<void>;
60
- writeTsCodegenFile: () => Promise<void>;
58
+ } | Nullish>;
59
+ writeDevCssFile: () => void;
60
+ writeTsCodegenFile: () => void;
61
61
  }
62
62
  interface IntegrationContextOptions {
63
63
  cwd: string;
64
64
  currentPackageName: string;
65
65
  target: string[];
66
- configOrPath: EngineConfig | string | null | undefined;
66
+ configOrPath: EngineConfig | string | Nullish;
67
67
  fnName: string;
68
68
  transformedFormat: 'string' | 'array' | 'inline';
69
69
  tsCodegen: false | string;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { statSync } from 'node:fs';
2
- import { writeFile, mkdir, stat } from 'node:fs/promises';
1
+ import { writeFileSync, statSync } from 'node:fs';
2
+ import { mkdir, stat, writeFile } from 'node:fs/promises';
3
3
  import { setWarnFn, warn, createEngine } from '@pikacss/core';
4
4
  export * from '@pikacss/core';
5
5
  import { createJiti } from 'jiti';
@@ -35,23 +35,23 @@ function formatUnionStringType(list) {
35
35
  function generateAutocomplete(ctx) {
36
36
  const autocomplete = ctx.engine.config.autocomplete;
37
37
  return [
38
- "export interface Autocomplete extends _Autocomplete {",
38
+ "export type Autocomplete = DefineAutocomplete<{",
39
39
  ` Selector: ${formatUnionStringType([...autocomplete.selectors])}`,
40
40
  ` StyleItemString: ${formatUnionStringType([...autocomplete.styleItemStrings])}`,
41
41
  ` ExtraProperty: ${formatUnionStringType([...autocomplete.extraProperties])}`,
42
42
  ` ExtraCssProperty: ${formatUnionStringType([...autocomplete.extraCssProperties])}`,
43
43
  ` PropertiesValue: { ${Array.from(autocomplete.properties.entries(), ([k, v]) => `'${k}': ${v.join(" | ")}`).join(",")} }`,
44
44
  ` CssPropertiesValue: { ${Array.from(autocomplete.cssProperties.entries(), ([k, v]) => `'${k}': ${formatUnionStringType(v)}`).join(",")} }`,
45
- "}",
45
+ "}>",
46
46
  ""
47
47
  ];
48
48
  }
49
49
  function generateStyleFn(ctx) {
50
50
  const { transformedFormat } = ctx;
51
51
  const lines = [
52
- "type StyleFn_Array = (...params: StyleItem<Autocomplete>[]) => string[]",
53
- "type StyleFn_String = (...params: StyleItem<Autocomplete>[]) => string",
54
- "type StyleFn_Inline = (...params: StyleItem<Autocomplete>[]) => void"
52
+ "type StyleFn_Array = (...params: StyleItem[]) => string[]",
53
+ "type StyleFn_String = (...params: StyleItem[]) => string",
54
+ "type StyleFn_Inline = (...params: StyleItem[]) => void"
55
55
  ];
56
56
  if (transformedFormat === "array")
57
57
  lines.push("type StyleFn_Normal = StyleFn_Array");
@@ -112,7 +112,7 @@ function generateVueDeclaration(ctx) {
112
112
  ""
113
113
  ];
114
114
  }
115
- async function generateOverloadContent(ctx) {
115
+ function generateOverloadContent(ctx) {
116
116
  const paramsLines = [];
117
117
  const fnsLines = [];
118
118
  const usages = [...ctx.usages.values()].flat();
@@ -147,22 +147,28 @@ async function generateOverloadContent(ctx) {
147
147
  ...paramsLines
148
148
  ];
149
149
  }
150
- async function generateTsCodegenContent(ctx) {
150
+ function generateTsCodegenContent(ctx) {
151
151
  const lines = [
152
152
  `// Auto-generated by ${ctx.currentPackageName}`,
153
- `import type { Autocomplete as _Autocomplete, StyleItem } from '${ctx.currentPackageName}'`,
154
- `import { createDefineEngineConfigFn } from '${ctx.currentPackageName}'`,
153
+ `import type { CSSProperty, CSSSelectors, DefineAutocomplete, Properties, StyleDefinition, StyleItem } from '${ctx.currentPackageName}'`,
154
+ "",
155
+ `declare module '${ctx.currentPackageName}' {`,
156
+ " interface PikaAugment {",
157
+ " Autocomplete: Autocomplete",
158
+ " Selector: Autocomplete['Selector'] | CSSSelectors",
159
+ " CSSProperty: Autocomplete['ExtraCssProperty'] | CSSProperty",
160
+ " Properties: Properties",
161
+ " StyleDefinition: StyleDefinition",
162
+ " StyleItem: StyleItem",
163
+ " }",
164
+ "}",
155
165
  ""
156
166
  ];
157
167
  lines.push(...generateAutocomplete(ctx));
158
- lines.push(
159
- "export const defineEngineConfig: ReturnType<typeof createDefineEngineConfigFn<Autocomplete>> = createDefineEngineConfigFn<Autocomplete>()",
160
- ""
161
- );
162
168
  lines.push(...generateStyleFn(ctx));
163
169
  lines.push(...generateGlobalDeclaration(ctx));
164
170
  lines.push(...generateVueDeclaration(ctx));
165
- lines.push(...await generateOverloadContent(ctx));
171
+ lines.push(...generateOverloadContent(ctx));
166
172
  return lines.join("\n");
167
173
  }
168
174
 
@@ -267,9 +273,10 @@ async function createCtx(options) {
267
273
  resolvedConfigPath = configSources[0];
268
274
  await mkdir(dirname(resolvedConfigPath), { recursive: true }).catch(() => {
269
275
  });
270
- const from = tsCodegenFilepath == null ? currentPackageName : `./${relative(dirname(resolvedConfigPath), tsCodegenFilepath)}`;
276
+ const relativeTsCodegenFilepath = tsCodegenFilepath == null ? null : `./${relative(dirname(resolvedConfigPath), tsCodegenFilepath)}`;
271
277
  await writeFile(resolvedConfigPath, [
272
- `import { defineEngineConfig } from '${from}'`,
278
+ ...relativeTsCodegenFilepath == null ? [] : [`/// <reference path="${relativeTsCodegenFilepath}" />`],
279
+ `import { defineEngineConfig } from '${currentPackageName}'`,
273
280
  "",
274
281
  "export default defineEngineConfig({",
275
282
  " // Add your PikaCSS engine config here",
@@ -285,16 +292,6 @@ async function createCtx(options) {
285
292
  },
286
293
  init: async () => {
287
294
  ctx.isReady = false;
288
- await mkdir(dirname(devCssFilepath), { recursive: true }).catch(() => {
289
- });
290
- const isDevCssFileExists = await stat(devCssFilepath).then((stat2) => stat2.isFile()).catch(() => false);
291
- if (isDevCssFileExists === false)
292
- await writeFile(devCssFilepath, "");
293
- if (tsCodegenFilepath != null) {
294
- await mkdir(dirname(tsCodegenFilepath), { recursive: true }).catch(() => {
295
- });
296
- await writeFile(tsCodegenFilepath, "export function defineEngineConfig(config: any) { return config }");
297
- }
298
295
  ctx.usages.clear();
299
296
  const { config, file } = await ctx.loadConfig().catch((error) => {
300
297
  warn(`Failed to load config file: ${error.message}`, error);
@@ -313,6 +310,20 @@ async function createCtx(options) {
313
310
  atomicStyleAdded: () => ctx.hooks.styleUpdated.trigger(),
314
311
  autocompleteConfigUpdated: () => ctx.hooks.tsCodegenUpdated.trigger()
315
312
  });
313
+ await mkdir(dirname(devCssFilepath), { recursive: true }).catch(() => {
314
+ });
315
+ const isDevCssFileExists = await stat(devCssFilepath).then((stat2) => stat2.isFile()).catch(() => false);
316
+ if (isDevCssFileExists === false)
317
+ await writeFile(devCssFilepath, "");
318
+ if (tsCodegenFilepath != null) {
319
+ await mkdir(dirname(tsCodegenFilepath), { recursive: true }).catch(() => {
320
+ });
321
+ const isGenTsFileExists = await stat(tsCodegenFilepath).then((stat2) => stat2.isFile()).catch(() => false);
322
+ if (isGenTsFileExists === false) {
323
+ const content = await generateTsCodegenContent(ctx);
324
+ await writeFile(tsCodegenFilepath, content);
325
+ }
326
+ }
316
327
  ctx.isReady = true;
317
328
  },
318
329
  isReady: false,
@@ -329,7 +340,6 @@ async function createCtx(options) {
329
340
  if (functionCalls.length === 0)
330
341
  return;
331
342
  const usages = [];
332
- ctx.usages.set(id, usages);
333
343
  const transformed = new MagicString(code);
334
344
  for (const fnCall of functionCalls) {
335
345
  const functionCallStr = fnCall.snippet;
@@ -341,7 +351,6 @@ async function createCtx(options) {
341
351
  params: args
342
352
  };
343
353
  usages.push(usage);
344
- ctx.hooks.tsCodegenUpdated.trigger();
345
354
  let transformedContent;
346
355
  if (ctx.fnUtils.isNormal(fnCall.fnName)) {
347
356
  transformedContent = ctx.transformedFormat === "array" ? `[${names.map((n) => `'${n}'`).join(", ")}]` : ctx.transformedFormat === "string" ? `'${names.join(" ")}'` : names.join(" ");
@@ -356,6 +365,9 @@ async function createCtx(options) {
356
365
  }
357
366
  transformed.update(fnCall.start, fnCall.end + 1, transformedContent);
358
367
  }
368
+ ctx.usages.set(id, usages);
369
+ ctx.hooks.styleUpdated.trigger();
370
+ ctx.hooks.tsCodegenUpdated.trigger();
359
371
  return {
360
372
  code: transformed.toString(),
361
373
  map: transformed.generateMap({ hires: true })
@@ -365,7 +377,7 @@ async function createCtx(options) {
365
377
  return void 0;
366
378
  }
367
379
  },
368
- writeDevCssFile: async () => {
380
+ writeDevCssFile: () => {
369
381
  if (ctx.isReady === false)
370
382
  return;
371
383
  const atomicStyleIds = [...new Set([...ctx.usages.values()].flatMap((i) => [...new Set(i.flatMap((i2) => i2.atomicStyleIds))]))];
@@ -374,13 +386,13 @@ async function createCtx(options) {
374
386
  ctx.engine.renderPreflights(true),
375
387
  ctx.engine.renderAtomicStyles(true, { atomicStyleIds })
376
388
  ].join("\n").trim();
377
- await writeFile(ctx.devCssFilepath, css);
389
+ writeFileSync(ctx.devCssFilepath, css);
378
390
  },
379
- writeTsCodegenFile: async () => {
391
+ writeTsCodegenFile: () => {
380
392
  if (ctx.isReady === false || ctx.tsCodegenFilepath == null)
381
393
  return;
382
- const content = await generateTsCodegenContent(ctx);
383
- await writeFile(ctx.tsCodegenFilepath, content);
394
+ const content = generateTsCodegenContent(ctx);
395
+ writeFileSync(ctx.tsCodegenFilepath, content);
384
396
  }
385
397
  };
386
398
  await ctx.init();
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.0.13",
7
+ "version": "0.0.15",
8
8
  "author": "DevilTea <ch19980814@gmail.com>",
9
9
  "license": "MIT",
10
10
  "repository": {
@@ -40,7 +40,7 @@
40
40
  "magic-string": "^0.30.12",
41
41
  "micromatch": "^4.0.8",
42
42
  "pathe": "^2.0.3",
43
- "@pikacss/core": "0.0.13"
43
+ "@pikacss/core": "0.0.15"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/micromatch": "^4.0.9"