design-embed 0.1.1 → 0.2.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.
package/dist/index.d.mts CHANGED
@@ -1,197 +1,75 @@
1
- //#region packages/config/src/index.d.ts
1
+ //#region packages/design-embed/src/core/nodes.d.ts
2
2
  /**
3
- * Minimal interface every source plugin instance must satisfy.
4
- * Keep this interface in the config package so plugin packages can implement
5
- * it without pulling in the heavier core package.
6
- */
7
- interface PluginDefinition {
8
- readonly name: string;
9
- }
10
- /**
11
- * External target adapter instance supplied by packages like
12
- * `@design-embed/target-react`.
13
- */
14
- interface TargetAdapterDefinition {
15
- readonly name?: string;
16
- emit(input: unknown): unknown;
17
- generateTests?(input: unknown): unknown;
18
- }
19
- /**
20
- * A diagnostic reported during configuration loading or validation.
21
- */
22
- interface ConfigDiagnostic {
23
- /** Unique error code. */
24
- code: string;
25
- /** Human-readable message. */
26
- message: string;
27
- /** Severity of the issue. */
28
- severity: "error" | "warning" | "info";
29
- }
30
- /**
31
- * The root configuration object for design-embed.
32
- */
33
- interface DesignEmbedConfig {
34
- /** Output settings for the generated code. */
35
- output?: {
36
- /** Directory where generated views will be written. */viewsDir?: string; /** Directory for page-level assemblies. */
37
- assembliesDir?: string; /** Target adapter instance. Omit to use built-in HTML output. */
38
- target?: "html" | TargetAdapterDefinition; /** Name of the generated component/view. */
39
- viewName?: string; /** How to handle styles: inline, Tailwind, or CSS Modules. */
40
- styleMode?: StyleMode;
41
- };
42
- /** Mappings from HTML selectors to project components. */
43
- components?: ComponentMapping[];
44
- /** Design token scales for style snapping. */
45
- tokens?: TokenConfig;
46
- /** Mappings for Tailwind utility classes. */
47
- styleMappings?: StyleMappings;
48
- /** Source plugin instances to run when fetching HTML with `design-embed --out`. */
49
- plugins?: PluginDefinition[];
50
- /** Visual and layout test generation settings. */
51
- tests?: TestGenerationConfig;
52
- }
53
- /**
54
- * Configuration for generated regression tests.
3
+ * Location in the source HTML file.
55
4
  */
56
- interface TestGenerationConfig {
57
- /** Directory where generated test files and reference fixtures are written. */
58
- outputDir?: string;
59
- /** Test runner emitted by the generator. */
60
- runner?: "playwright";
61
- /** Source artifact paths used as the visual/layout reference. */
62
- source?: {
63
- /** Path to the reference design HTML, relative to the config directory or cwd. */html?: string; /** Optional path to external reference CSS, relative to the config directory or cwd. */
64
- css?: string;
65
- };
66
- /** Viewports to verify. */
67
- viewports?: TestViewport[];
68
- /** Interaction states to verify for every viewport. */
69
- states?: TestState[];
70
- /** Assertion settings. */
71
- assertions?: TestAssertions;
72
- }
73
- interface TestViewport {
74
- /** Stable viewport name used in test titles. */
75
- name?: string;
76
- width: number;
77
- height: number;
78
- }
79
- interface TestState {
80
- /** Stable state name used in test titles. */
81
- name: string;
82
- /** Selector to hover before assertions. */
83
- hover?: string;
84
- /** Selector to focus before assertions. */
85
- focus?: string;
86
- /** Selector to click before assertions. */
87
- click?: string;
88
- /** Selector to wait for before assertions. */
89
- waitFor?: string;
90
- }
91
- interface TestAssertions {
92
- /** Whether to compare full-page screenshots. Defaults to true. */
93
- screenshot?: boolean;
94
- /** Whether to compare element bounding boxes. Defaults to true. */
95
- layout?: boolean;
96
- /** Maximum x/y/width/height drift in CSS pixels. Defaults to 0. */
97
- layoutTolerance?: number;
98
- /** Selectors to collect for layout comparison. Defaults to [":scope", ":scope *"]. */
99
- selectors?: string[];
5
+ interface SourceLocation {
6
+ /** Absolute offset in characters. */
7
+ offset: number;
8
+ /** 1-based line number. */
9
+ line: number;
10
+ /** 1-based column number. */
11
+ column: number;
100
12
  }
101
13
  /**
102
- * Available styling modes.
103
- */
104
- type StyleMode = "inline" | "css-modules" | "tailwind";
105
- /**
106
- * Defines how to map a design element to a project component.
14
+ * A normalized node in the design AST.
107
15
  */
108
- interface ComponentMapping {
109
- /** CSS selector to match the element in the design HTML. */
110
- selector: string;
111
- /** Import path of the project component. */
112
- component: string;
16
+ interface DesignNode {
17
+ /** The type of node. */
18
+ kind: "element" | "text" | "component";
19
+ /** HTML tag name (for element kind). */
20
+ tagName?: string;
21
+ /** HTML attributes (for element kind). */
22
+ attributes?: Record<string, string>;
23
+ /** Parsed inline styles (for element kind). */
24
+ styles?: Record<string, string>;
25
+ /** Utility classes to apply. */
26
+ generatedClassNames?: string[];
27
+ /** Child nodes. */
28
+ children?: DesignNode[];
29
+ /** Inner text content (for text kind). */
30
+ text?: string;
31
+ /** Original location in the source HTML. */
32
+ source?: SourceLocation;
33
+ /** Component name (for component kind). */
34
+ component?: string;
113
35
  /** Named export of the component. */
114
36
  importName?: string;
115
- /** Prop values to pass, supports $text, $children, and $attr expressions. */
116
- props?: Record<string, string>;
117
- }
118
- /**
119
- * Configuration for design tokens.
120
- */
121
- interface TokenConfig {
122
- /** Spacing scale (e.g. padding, margin, gap). */
123
- spacing?: {
124
- /** Unit to use in generated styles. */unit?: "px" | "rem"; /** Max distance for value snapping. */
125
- threshold?: number; /** The token scale mapping names to values. */
126
- values?: Record<string, number>;
127
- };
128
- /** Sizing scale (e.g. width, height). */
129
- sizing?: NumericTokenGroup;
130
- /** Typography scale (e.g. font-size, line-height). */
131
- typography?: NumericTokenGroup;
132
- /** Border radius scale. */
133
- radius?: Record<string, number>;
134
- /** Border width scale. */
135
- borderWidth?: Record<string, number>;
136
- /** Box shadow scale. */
137
- shadow?: Record<string, string>;
138
- /** Color palette. */
139
- colors?: Record<string, string>;
140
- /** Color matching threshold (CIE76). */
141
- colorThreshold?: number;
142
- }
143
- interface NumericTokenGroup {
144
- unit?: "px" | "rem";
145
- threshold?: number;
146
- values?: Record<string, number>;
147
- }
148
- type StyleMappings = Record<string, Record<string, string>>;
149
- /**
150
- * Result of loading a configuration file.
151
- */
152
- interface LoadConfigResult {
153
- /** The loaded and validated config, if successful. */
154
- config?: DesignEmbedConfig;
155
- /** Any errors or warnings encountered during loading. */
156
- diagnostics: ConfigDiagnostic[];
37
+ /** Mapped prop values for the component. */
38
+ props?: Record<string, PropValue>;
39
+ /** Import path of the component. */
40
+ importPath?: string;
41
+ /**
42
+ * The original element node a component was mapped from. Retained so
43
+ * targets can reconstruct the element's structure when emitting the
44
+ * component implementation.
45
+ */
46
+ sourceElement?: DesignNode;
157
47
  }
158
48
  /**
159
- * Helper to define configuration with type safety.
160
- *
161
- * @param config - The configuration object.
162
- * @returns The same configuration object.
163
- *
164
- * @example
165
- * export default defineConfig({
166
- * output: { target: reactTarget }
167
- * });
49
+ * A value passed to a component prop.
168
50
  */
169
- declare function defineConfig(config: DesignEmbedConfig): DesignEmbedConfig;
51
+ type PropValue = {
52
+ kind: "literal";
53
+ value: string | number | boolean; /** Source attribute name when the prop is bound to `$attr.*`. */
54
+ attribute?: string;
55
+ } | {
56
+ kind: "text";
57
+ value: string;
58
+ } | {
59
+ kind: "children";
60
+ value: DesignNode[];
61
+ };
62
+ //#endregion
63
+ //#region packages/design-embed/src/core/plugins/pluginApi.d.ts
170
64
  /**
171
- * Asynchronously loads a configuration file from disk.
172
- * Supports .ts, .js, and .mjs files via dynamic import.
173
- *
174
- * @param configPath - Path to the config file.
175
- * @param cwd - Current working directory.
176
- * @returns A promise resolving to the load result.
65
+ * Represents a file generated by the compiler.
177
66
  */
178
- declare function loadConfig(configPath: string, cwd?: string): Promise<LoadConfigResult>;
179
- declare function validateConfig(config: DesignEmbedConfig): ConfigDiagnostic[];
180
- //#endregion
181
- //#region packages/core/src/diagnostics/diagnostic.d.ts
182
- type DiagnosticSeverity = "error" | "warning" | "info";
183
- interface Diagnostic {
184
- code: string;
185
- message: string;
186
- severity: DiagnosticSeverity;
187
- file?: string;
188
- source?: SourceLocation;
189
- selector?: string;
190
- property?: string;
191
- details?: Record<string, unknown>;
67
+ interface GeneratedFile {
68
+ /** Relative path from the output directory. */
69
+ path: string;
70
+ /** File content. */
71
+ contents: string;
192
72
  }
193
- //#endregion
194
- //#region packages/core/src/plugins/pluginApi.d.ts
195
73
  interface GeneratedAsset {
196
74
  path: string;
197
75
  contents?: string | Uint8Array;
@@ -203,7 +81,6 @@ interface SourcePlugin {
203
81
  }
204
82
  interface SourcePluginInput {
205
83
  cwd: string;
206
- args: Record<string, string | boolean>;
207
84
  config?: unknown;
208
85
  }
209
86
  interface SourcePluginResult {
@@ -213,164 +90,129 @@ interface SourcePluginResult {
213
90
  files?: GeneratedFile[];
214
91
  diagnostics: Diagnostic[];
215
92
  }
93
+ interface TargetEmitResult {
94
+ files: GeneratedFile[];
95
+ }
96
+ interface TargetTestGenerateResult {
97
+ files: GeneratedFile[];
98
+ diagnostics: Diagnostic[];
99
+ }
100
+ //#endregion
101
+ //#region packages/design-embed/src/core/types.d.ts
216
102
  interface TargetEmitInput {
217
103
  nodes: DesignNode[];
218
104
  css?: string;
219
105
  config?: DesignEmbedConfig;
220
106
  diagnostics: Diagnostic[];
221
107
  }
222
- interface TargetEmitResult {
223
- files: GeneratedFile[];
224
- }
225
108
  interface TargetEmitter {
226
- name?: string;
227
109
  emit(input: TargetEmitInput): TargetEmitResult;
228
110
  }
229
111
  interface TargetTestGenerateInput {
230
112
  html: string;
231
113
  css?: string;
232
114
  config: DesignEmbedConfig;
233
- diagnostics: Diagnostic[];
234
- generatedFiles?: GeneratedFile[];
235
- }
236
- interface TargetTestGenerateResult {
237
- files: GeneratedFile[];
238
115
  }
239
116
  interface TargetTestGenerator {
240
117
  generateTests(input: TargetTestGenerateInput): TargetTestGenerateResult;
241
118
  }
242
- //#endregion
243
- //#region packages/core/src/diagnostics/jsonDiagnostic.d.ts
244
- interface JsonDiagnostic {
245
- code: string;
246
- severity: "error" | "warning" | "info";
247
- message: string;
248
- file?: string;
249
- line?: number;
250
- column?: number;
251
- details?: Record<string, unknown>;
119
+ type StyleMode = "inline" | "css-modules" | "tailwind";
120
+ interface ComponentMapping {
121
+ selector: string;
122
+ component: string;
123
+ props?: Record<string, string>;
252
124
  }
253
- declare function toJsonDiagnostic(diagnostic: Diagnostic): JsonDiagnostic;
254
- declare function toJsonDiagnostics(diagnostics: Diagnostic[]): JsonDiagnostic[];
255
- declare function formatDiagnosticText(diagnostic: Diagnostic): string;
256
- //#endregion
257
- //#region packages/core/src/pipeline/checkMode.d.ts
258
- interface CheckModeInput {
259
- files: GeneratedFile[];
260
- cwd: string;
261
- readFile(path: string): string | undefined;
125
+ interface TokenConfig {
126
+ spacing?: {
127
+ unit?: "px" | "rem";
128
+ threshold?: number;
129
+ values?: Record<string, number>;
130
+ };
131
+ sizing?: NumericTokenGroup;
132
+ typography?: NumericTokenGroup;
133
+ radius?: Record<string, number>;
134
+ borderWidth?: Record<string, number>;
135
+ shadow?: Record<string, string>;
136
+ colors?: Record<string, string>;
137
+ colorThreshold?: number;
262
138
  }
263
- interface CheckModeResult {
264
- ok: boolean;
265
- diagnostics: Diagnostic[];
139
+ interface NumericTokenGroup {
140
+ unit?: "px" | "rem";
141
+ threshold?: number;
142
+ values?: Record<string, number>;
266
143
  }
267
- declare function checkGeneratedFiles(input: CheckModeInput): CheckModeResult;
268
- //#endregion
269
- //#region packages/core/src/plugins/pluginRegistry.d.ts
270
- declare class PluginRegistry {
271
- #private;
272
- registerSource(plugin: SourcePlugin): void;
273
- getSource(name: string): SourcePlugin | undefined;
274
- listSources(): SourcePlugin[];
144
+ type StyleMappings = Record<string, Record<string, string>>;
145
+ interface TestGenerationConfig {
146
+ outputDir?: string;
147
+ runner?: "playwright";
148
+ viewports?: TestViewport[];
149
+ states?: TestState[];
150
+ assertions?: TestAssertions;
275
151
  }
276
- //#endregion
277
- //#region packages/core/src/index.d.ts
278
- /**
279
- * Represents a file generated by the compiler.
280
- */
281
- interface GeneratedFile {
282
- /** Relative path from the output directory. */
283
- path: string;
284
- /** File content. */
285
- contents: string;
152
+ interface TestViewport {
153
+ name?: string;
154
+ width: number;
155
+ height: number;
286
156
  }
287
- /**
288
- * Location in the source HTML file.
289
- */
290
- interface SourceLocation {
291
- /** Absolute offset in characters. */
292
- offset: number;
293
- /** 1-based line number. */
294
- line: number;
295
- /** 1-based column number. */
296
- column: number;
157
+ interface TestState {
158
+ name: string;
159
+ hover?: string;
160
+ focus?: string;
161
+ click?: string;
162
+ waitFor?: string;
297
163
  }
298
- /**
299
- * A normalized node in the design AST.
300
- */
301
- interface DesignNode {
302
- /** The type of node. */
303
- kind: "element" | "text" | "component";
304
- /** HTML tag name (for element kind). */
305
- tagName?: string;
306
- /** HTML attributes (for element kind). */
307
- attributes?: Record<string, string>;
308
- /** Parsed inline styles (for element kind). */
309
- styles?: Record<string, string>;
310
- /** Utility classes to apply. */
311
- generatedClassNames?: string[];
312
- /** Child nodes. */
313
- children?: DesignNode[];
314
- /** Inner text content (for text kind). */
315
- text?: string;
316
- /** Original location in the source HTML. */
317
- source?: SourceLocation;
318
- /** Component name (for component kind). */
319
- component?: string;
320
- /** Named export of the component. */
321
- importName?: string;
322
- /** Mapped prop values for the component. */
323
- props?: Record<string, PropValue>;
324
- /** Import path of the component. */
325
- importPath?: string;
164
+ interface TestAssertions {
165
+ screenshot?: boolean;
166
+ layout?: boolean;
167
+ layoutTolerance?: number;
168
+ selectors?: string[];
169
+ /**
170
+ * Per-pixel color sensitivity (0-1) for the screenshot comparison. Smaller
171
+ * is stricter. Defaults to 0.2.
172
+ */
173
+ screenshotThreshold?: number;
174
+ /**
175
+ * Maximum number of differing pixels tolerated in the screenshot
176
+ * comparison. Defaults to 0 (byte-exact).
177
+ */
178
+ screenshotMaxDiffPixels?: number;
326
179
  }
327
- /**
328
- * A value passed to a component prop.
329
- */
330
- type PropValue = {
331
- kind: "literal";
332
- value: string | number | boolean;
333
- } | {
334
- kind: "text";
335
- value: string;
336
- } | {
337
- kind: "children";
338
- value: DesignNode[];
339
- };
340
- /**
341
- * A parsed CSS selector.
342
- */
343
- interface ParsedSelector {
344
- /** Optional tag name. */
345
- tagName?: string;
346
- /** Optional ID selector. */
347
- id?: string;
348
- /** List of class names. */
349
- classes: string[];
350
- /** Attribute selectors. */
351
- attributes: Record<string, string>;
180
+ interface DesignEmbedConfig {
181
+ output?: {
182
+ viewsDir?: string | URL;
183
+ target?: "html" | TargetEmitter;
184
+ viewName?: string;
185
+ styleMode?: StyleMode;
186
+ };
187
+ components?: ComponentMapping[];
188
+ tokens?: TokenConfig;
189
+ styleMappings?: StyleMappings;
190
+ source?: SourcePlugin;
191
+ tests?: TestGenerationConfig;
352
192
  }
193
+ //#endregion
194
+ //#region packages/design-embed/src/core/index.d.ts
353
195
  /**
354
196
  * Input for the core embed function.
355
197
  */
356
198
  interface DesignEmbedInput {
357
- /** The source design HTML. */
358
- html: string;
359
- /** Optional external CSS. */
360
- css?: string;
361
- /** Optional path to the config file (for resolution). */
362
- configPath?: string;
363
199
  /** The compiler configuration. */
364
200
  config?: DesignEmbedConfig;
365
201
  /** Working directory. */
366
202
  cwd?: string;
367
- /** The target emitter to use. */
368
- targetEmitter: TargetEmitter;
203
+ /** When true, skips writing output files to disk. Defaults to false. */
204
+ dryRun?: boolean;
205
+ /** When true, generates test files alongside output files. Defaults to false. */
206
+ generateTests?: boolean;
369
207
  }
370
208
  /**
371
209
  * Result of the embedding process.
372
210
  */
373
211
  interface DesignEmbedResult {
212
+ /** Source HTML resolved from the config's source plugin. */
213
+ html: string;
214
+ /** Source CSS resolved from the config's source plugin. */
215
+ css?: string;
374
216
  /** Generated files. */
375
217
  files: GeneratedFile[];
376
218
  /** Diagnostics reported during compilation. */
@@ -383,18 +225,49 @@ interface DesignEmbedResult {
383
225
  * @param input - The compilation input.
384
226
  * @returns A promise resolving to the compilation result.
385
227
  *
386
- * @example
387
- * const result = await embed({
388
- * html: '<div class="btn">Click me</div>',
389
- * config: myConfig,
390
- * targetEmitter: reactEmitter
391
- * });
392
228
  */
393
229
  declare function embed(input: DesignEmbedInput): Promise<DesignEmbedResult>;
394
230
  declare function applyComponentMappings(nodes: DesignNode[], mappings: ComponentMapping[], diagnostics?: Diagnostic[]): DesignNode[];
395
- declare function parseSelector(selector: string): ParsedSelector | undefined;
396
- declare function matchesSelector(node: DesignNode, selector: ParsedSelector): boolean;
397
231
  declare function parseHtml(html: string): DesignNode[];
398
- declare function parseInlineStyle(style: string | undefined): Record<string, string>;
399
232
  //#endregion
400
- export { type CheckModeInput, type CheckModeResult, ComponentMapping, ConfigDiagnostic, DesignEmbedConfig, DesignEmbedInput, DesignEmbedResult, DesignNode, type Diagnostic, type DiagnosticSeverity, type GeneratedAsset, GeneratedFile, type JsonDiagnostic, LoadConfigResult, NumericTokenGroup, ParsedSelector, PluginDefinition, PluginRegistry, PropValue, SourceLocation, type SourcePlugin, type SourcePluginInput, type SourcePluginResult, StyleMappings, StyleMode, TargetAdapterDefinition, type TargetEmitInput, type TargetEmitResult, type TargetEmitter, type TargetTestGenerateInput, type TargetTestGenerateResult, type TargetTestGenerator, TestAssertions, TestGenerationConfig, TestState, TestViewport, TokenConfig, applyComponentMappings, checkGeneratedFiles, defineConfig, embed, formatDiagnosticText, loadConfig, matchesSelector, parseHtml, parseInlineStyle, parseSelector, toJsonDiagnostic, toJsonDiagnostics, validateConfig };
233
+ //#region packages/design-embed/src/core/diagnostics/diagnostic.d.ts
234
+ type DiagnosticSeverity = "error" | "warning" | "info";
235
+ interface Diagnostic {
236
+ code: string;
237
+ message: string;
238
+ severity: DiagnosticSeverity;
239
+ file?: string;
240
+ source?: SourceLocation;
241
+ selector?: string;
242
+ property?: string;
243
+ details?: Record<string, unknown>;
244
+ }
245
+ //#endregion
246
+ //#region packages/design-embed/src/config/index.d.ts
247
+ interface LoadConfigResult {
248
+ config?: DesignEmbedConfig;
249
+ configPath?: string;
250
+ diagnostics: Diagnostic[];
251
+ }
252
+ declare function defineConfig(config: DesignEmbedConfig): DesignEmbedConfig;
253
+ declare function fromFile(htmlPath: string | URL, cssPath?: string | URL): SourcePlugin;
254
+ declare function loadConfig(configPath: string, cwd?: string): Promise<LoadConfigResult>;
255
+ declare function validateConfig(config: DesignEmbedConfig): Diagnostic[];
256
+ //#endregion
257
+ //#region packages/design-embed/src/targets/html.d.ts
258
+ interface HtmlTargetOptions {
259
+ domModel?: "light" | "shadow";
260
+ }
261
+ declare class HtmlTarget implements TargetEmitter, TargetTestGenerator {
262
+ private readonly domModel;
263
+ constructor(options?: HtmlTargetOptions);
264
+ emit({
265
+ nodes,
266
+ css,
267
+ config
268
+ }: TargetEmitInput): TargetEmitResult;
269
+ generateTests(input: TargetTestGenerateInput): TargetTestGenerateResult;
270
+ }
271
+ declare const htmlTarget: TargetEmitter & TargetTestGenerator;
272
+ //#endregion
273
+ export { type ComponentMapping, type DesignEmbedConfig, type DesignEmbedInput, type DesignEmbedResult, type DesignNode, type Diagnostic, type DiagnosticSeverity, type GeneratedAsset, type GeneratedFile, HtmlTarget, type HtmlTargetOptions, type LoadConfigResult, type NumericTokenGroup, type PropValue, type SourceLocation, type SourcePlugin, type SourcePluginInput, type SourcePluginResult, type StyleMappings, type StyleMode, type TargetEmitInput, type TargetEmitResult, type TargetEmitter, type TargetTestGenerateInput, type TargetTestGenerateResult, type TargetTestGenerator, type TestAssertions, type TestGenerationConfig, type TestState, type TestViewport, type TokenConfig, applyComponentMappings, defineConfig, embed, fromFile, htmlTarget, loadConfig, parseHtml, validateConfig };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as parseInlineStyle, c as checkGeneratedFiles, d as toJsonDiagnostics, f as defineConfig, i as parseHtml, l as formatDiagnosticText, m as validateConfig, n as embed, o as parseSelector, p as loadConfig, r as matchesSelector, s as PluginRegistry, t as applyComponentMappings, u as toJsonDiagnostic } from "./src-D3fnqGCq.mjs";
2
- export { PluginRegistry, applyComponentMappings, checkGeneratedFiles, defineConfig, embed, formatDiagnosticText, loadConfig, matchesSelector, parseHtml, parseInlineStyle, parseSelector, toJsonDiagnostic, toJsonDiagnostics, validateConfig };
1
+ import { c as htmlTarget, d as loadConfig, f as validateConfig, l as defineConfig, n as embed, r as parseHtml, s as HtmlTarget, t as applyComponentMappings, u as fromFile } from "./core-DSlWqRBj.mjs";
2
+ export { HtmlTarget, applyComponentMappings, defineConfig, embed, fromFile, htmlTarget, loadConfig, parseHtml, validateConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "design-embed",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -23,15 +23,7 @@
23
23
  "bin": {
24
24
  "design-embed": "./dist/cli.mjs"
25
25
  },
26
- "devDependencies": {
27
- "@design-embed/config": "0.1.1",
28
- "@design-embed/core": "0.1.1"
29
- },
30
26
  "scripts": {
31
- "dev": "node src/cli.ts",
32
- "compile:react": "node src/cli.ts react",
33
- "compile:html": "node src/cli.ts html",
34
- "compile:vanjs": "node src/cli.ts vanjs",
35
- "get-raw": "node src/cli.ts raw"
27
+ "test": "node --conditions=development --test src/**/*.test.ts"
36
28
  }
37
29
  }
package/src/cli.ts CHANGED
@@ -4,48 +4,23 @@ import { runCheckCommand } from "./commands/check.ts";
4
4
  import { runCompileCommand } from "./commands/compile.ts";
5
5
  import { runGenerateTestsCommand } from "./commands/generateTests.ts";
6
6
  import { runInitCommand } from "./commands/init.ts";
7
- import { runPluginCommand } from "./commands/plugin.ts";
8
7
 
9
8
  async function main(): Promise<number> {
10
- const args = process.argv.slice(2);
11
- const parsed = parseArgs(args);
9
+ const { command, flags } = parseArgs(process.argv.slice(2));
12
10
 
13
- if (args[0] === "check") {
14
- return runCheckCommand(parsed.flags);
11
+ if (command === "check") {
12
+ return runCheckCommand(flags);
15
13
  }
16
-
17
- if (args[0] === "plugin") {
18
- return runPluginCommand(parsed.positionals[0], parsed.flags);
14
+ if (command === "generate-tests") {
15
+ return runGenerateTestsCommand(flags);
19
16
  }
20
-
21
- if (args[0] === "generate-tests") {
22
- return runGenerateTestsCommand(parsed.flags);
17
+ if (command === "init") {
18
+ return runInitCommand(flags);
23
19
  }
24
20
 
25
- if (args[0] === "init") {
26
- return runInitCommand(parsed.flags);
27
- }
28
-
29
- const flags =
30
- args[0] && !args[0].startsWith("--")
31
- ? { ...parsed.flags, "--": args[0] }
32
- : parsed.flags;
33
- if (getOutPath(flags) && !hasInput(flags)) {
34
- return runPluginCommand(undefined, flags);
35
- }
36
21
  return runCompileCommand(flags);
37
22
  }
38
23
 
39
- function getOutPath(flags: Record<string, string | boolean>): boolean {
40
- return typeof flags["--out"] === "string";
41
- }
42
-
43
- function hasInput(flags: Record<string, string | boolean>): boolean {
44
- return (
45
- typeof flags["--input"] === "string" || typeof flags["--"] === "string"
46
- );
47
- }
48
-
49
24
  main()
50
25
  .then((code) => {
51
26
  if (code !== 0) {