@component-compass/plugin-core 0.0.3 → 0.0.5

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.
@@ -28,18 +28,6 @@ export type Diagnostic = {
28
28
  filePath: string;
29
29
  tagName: string;
30
30
  conflictsWith: string;
31
- } | {
32
- code: "barrel-unsupported-form";
33
- severity: "info";
34
- filePath: string;
35
- form: string;
36
- line?: number;
37
- packageName?: string;
38
- } | {
39
- code: "untraceable-barrel";
40
- severity: "info";
41
- packageName: string;
42
- resolvedFile: string;
43
31
  } | {
44
32
  code: "cycle-detected";
45
33
  severity: "warning";
@@ -53,12 +41,6 @@ export type Diagnostic = {
53
41
  exportName: string;
54
42
  depth: number;
55
43
  packageName?: string;
56
- } | {
57
- code: "no-deps-match-scopes";
58
- severity: "info";
59
- packageScopes: readonly string[];
60
- packageManager: "yarn" | "npm" | "pnpm" | "unknown";
61
- workspacePackageCount: number;
62
44
  };
63
45
  export interface DiagnosticCollector {
64
46
  emit(d: Diagnostic): void;
@@ -16,14 +16,12 @@ function assertUnreachable(x) {
16
16
  * (e.g. file + line, or package + resolvedFile) — not the severity or
17
17
  * descriptive `detail`/`form` fields.
18
18
  *
19
- * Note on `packageName` omission: for `barrel-unsupported-form`,
20
- * `cycle-detected`, and `chain-too-deep`, the diagnostic describes a property
21
- * of the barrel/re-export (file, line, exportName), not the consumer package
22
- * that triggered resolution. Including `packageName` (which is the consumer's
23
- * package) would un-dedup based on consumer attribution and re-introduce the
24
- * noise pattern this collector exists to suppress (GH issue #12). For
25
- * `untraceable-barrel`, `packageName` IS included — it's the barrel's own
26
- * package name there, part of the observation identity.
19
+ * Note on `packageName` omission: for `cycle-detected` and `chain-too-deep`,
20
+ * the diagnostic describes a property of the barrel/re-export (file,
21
+ * exportName), not the consumer package that triggered resolution. Including
22
+ * `packageName` (which is the consumer's package) would un-dedup based on
23
+ * consumer attribution and re-introduce the noise pattern this collector
24
+ * exists to suppress (GH issue #12).
27
25
  */
28
26
  function dedupKey(d) {
29
27
  switch (d.code) {
@@ -33,16 +31,10 @@ function dedupKey(d) {
33
31
  return `${d.code}::${d.filePath}::${d.line ?? ""}::${d.column ?? ""}::${d.tagName}`;
34
32
  case "local-index-duplicate-tag":
35
33
  return `${d.code}::${d.filePath}::${d.tagName}`;
36
- case "barrel-unsupported-form":
37
- return `${d.code}::${d.filePath}::${d.line ?? ""}::${d.form}`;
38
- case "untraceable-barrel":
39
- return `${d.code}::${d.packageName}::${d.resolvedFile}`;
40
34
  case "cycle-detected":
41
35
  return `${d.code}::${d.filePath}::${d.exportName}`;
42
36
  case "chain-too-deep":
43
37
  return `${d.code}::${d.filePath}::${d.exportName}`;
44
- case "no-deps-match-scopes":
45
- return `${d.code}::${d.packageScopes.join(",")}::${d.packageManager}`;
46
38
  default:
47
39
  return assertUnreachable(d);
48
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostic.js","sourceRoot":"","sources":["../src/diagnostic.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA2EH,SAAS,iBAAiB,CAAC,CAAQ;IACjC,MAAM,IAAI,KAAK,CAAC,8BAA+B,CAAsB,CAAC,IAAI,EAAE,CAAC,CAAC;AAChF,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,QAAQ,CAAC,CAAa;IAC7B,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;QACf,KAAK,uBAAuB;YAC1B,OAAO,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,IAAI,IAAI,EAAE,KAAK,CAAC,CAAC,MAAM,IAAI,EAAE,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;QACvF,KAAK,wBAAwB;YAC3B,OAAO,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,IAAI,IAAI,EAAE,KAAK,CAAC,CAAC,MAAM,IAAI,EAAE,KAAK,CAAC,CAAC,OA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AAC,UAAU,EAAE,CAAC;QACrD;YACE,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAID,MAAM,UAAU,yBAAyB;IACvC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,OAAO;QACL,IAAI,CAAC,CAAC;YACJ,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YACxB,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,OAAO;YAC1B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACd,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,KAAK;YACH,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;YAC5B,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;YACnB,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,OAAO,GAAG,CAAC;QACb,CAAC;KACF,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -4,9 +4,10 @@ export { validateManifest } from "./validate.js";
4
4
  export type { ValidationResult } from "./validate.js";
5
5
  export { manifestJsonSchema } from "./schema.js";
6
6
  export { ManifestBuilder } from "./builder.js";
7
- export type { TagName, WrapperId, ImportRole, ImportEntry, IndexedComponent, Loc, WarningCode, Warning, ScanConfig, PropUsage, OccurrenceVia, Occurrence, WrapperDef, FileImport, ParseResult, ParseContext, ParserPlugin, ScanEnvelope, ScanOutput, ManifestRef, ScanStats, DetectorId, LocalDefinition, LocalDefinitionIndex, ResolveLazyManifest, LookupByTag, LazyResolverHit, } from "./scan-types.js";
7
+ export type { TagName, WrapperId, ImportRole, ImportEntry, IndexedComponent, Loc, WarningCode, Warning, ScanConfig, PropUsage, OccurrenceVia, Occurrence, WrapperDef, FileImport, ParseResult, ParseContext, ParserPlugin, ScanOutput, ManifestRef, ScanStats, DetectorId, LocalDefinition, LocalDefinitionIndex, ResolveLazyManifest, LookupByTag, LazyResolverHit, CemIndex, CemIndexEntry, } from "./scan-types.js";
8
8
  export { asTagName, asWrapperId, emptyLocalIndex } from "./scan-types.js";
9
9
  export type { Enrichment, AuthoredLeafPayload, DerivedLeafPayload } from "./enrichment.js";
10
+ export { normalizeOwnerPath } from "./owner-utils.js";
10
11
  export { computeOccurrenceId } from "./occurrence-id.js";
11
12
  export type { CompositionRollup } from "./output-types.js";
12
13
  export * from "./output-types.js";
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ export { validateManifest } from "./validate.js";
3
3
  export { manifestJsonSchema } from "./schema.js";
4
4
  export { ManifestBuilder } from "./builder.js";
5
5
  export { asTagName, asWrapperId, emptyLocalIndex } from "./scan-types.js";
6
+ export { normalizeOwnerPath } from "./owner-utils.js";
6
7
  export { computeOccurrenceId } from "./occurrence-id.js";
7
8
  export * from "./output-types.js";
8
9
  export { createDiagnosticCollector } from "./diagnostic.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC3G,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAc/C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAI1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGzD,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC3G,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAe/C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAI1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGzD,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import type { OccurrenceVia } from "./via-types.js";
7
7
  import type { Lifecycle } from "./types.js";
8
- export type ComponentScope = "ds" | "external" | "local";
8
+ export type ComponentScope = "external" | "local";
9
9
  export type ComponentKindOutput = "custom-element" | "react-component" | "vue-component";
10
10
  export type OutputIdentity = {
11
11
  scope: ComponentScope;
@@ -16,6 +16,15 @@ export type OutputIdentity = {
16
16
  * one. Absent for root-level local files (non-workspace single-package repos).
17
17
  */
18
18
  packageName?: string;
19
+ /**
20
+ * For resolver-driven external identities: the file Node's import resolution
21
+ * (and any further chain walking) landed on, relative to the leaf package
22
+ * root, POSIX-normalised. Disambiguates distinct components reached via
23
+ * different subpaths of the same package. Absent for byTag-driven external
24
+ * identities (which disambiguate via `tagName` alone) and for local identities
25
+ * (which use `filePath` instead).
26
+ */
27
+ modulePath?: string;
19
28
  /** For react-component / vue-component. */
20
29
  exportName?: string;
21
30
  /** For custom-element. */
@@ -106,7 +115,6 @@ export type CompositionRollup = {
106
115
  export type OutputComponent = {
107
116
  id: string;
108
117
  identity: OutputIdentity;
109
- derivedTags: string[];
110
118
  manifest: {
111
119
  source: "authored";
112
120
  data: AuthoredManifestData;
@@ -121,6 +129,14 @@ export type OutputComponent = {
121
129
  props: Record<string, PropDistribution>;
122
130
  /** Per-component composition rollup (owner-edge driven). Always emitted. */
123
131
  composition?: CompositionRollup;
132
+ /** Package version from package.json or CEM. Null for external packages not versioned at scan time. */
133
+ version: string | null;
134
+ /** Deprecation flag from CEM @deprecated declaration. False if the component's CEM declaration does not carry `@deprecated`; CEM declarations on external packages flow through to this field. */
135
+ deprecated: boolean;
136
+ /** Git-mtime: first commit of the declaring file. ISO 8601 string, or null for external packages. */
137
+ createdAt: string | null;
138
+ /** Git-mtime: last commit of the declaring file. ISO 8601 string, or null for external packages. */
139
+ updatedAt: string | null;
124
140
  };
125
141
  export type OutputOccurrence = {
126
142
  componentId: string;
@@ -143,3 +159,38 @@ export type OutputOccurrence = {
143
159
  */
144
160
  ownerComponentId?: string;
145
161
  };
162
+ /**
163
+ * Top-level metadata block in the scan artifact.
164
+ * Captures repo identity, git state, and scan timing for cross-scan joins and provenance.
165
+ */
166
+ export type ScanMeta = {
167
+ /** CC version that created this artifact. */
168
+ ccVersion: string;
169
+ /** ULID generated once per scan. Unique across scans; stable within a single run. */
170
+ scanId: string;
171
+ /** ISO 8601 timestamp of the scan. */
172
+ scannedAt: string;
173
+ /** Repository identification and git state. */
174
+ repo: {
175
+ /** Stable repo identifier: git remote basename, config override, or working-directory basename. */
176
+ id: string;
177
+ /** Git remote URL (or null if not configured). For provenance tracking. */
178
+ gitRemote: string | null;
179
+ /** Current HEAD commit SHA. */
180
+ commit: string;
181
+ /** First commit SHA in the repo history. Stable across force-pushes and rebases. Null on shallow clones where git rev-list --max-parents=0 is unavailable. */
182
+ initialCommit: string | null;
183
+ /** Current branch name, or null for detached HEAD / shallow clones where branch is unavailable. */
184
+ branch: string | null;
185
+ };
186
+ };
187
+ /**
188
+ * The complete scan artifact shape produced by the CLI.
189
+ * Two-grain structure: components (rolled-up identity + manifest + composition) +
190
+ * occurrences (per call-site, linked to components by id).
191
+ */
192
+ export type ScanArtifact = {
193
+ meta: ScanMeta;
194
+ components: OutputComponent[];
195
+ occurrences: OutputOccurrence[];
196
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Normalize a file path to the form used as keys in `LocalDefinitionIndex.byPath`.
3
+ *
4
+ * Parsers receive absolute paths from oxc; the local-index stores
5
+ * repo-root-relative POSIX paths. Shared helper to prevent path-normalisation
6
+ * drift in owner-resolution code paths across parsers.
7
+ *
8
+ * No-op for already-relative paths beyond backslash → forward-slash conversion.
9
+ */
10
+ export declare function normalizeOwnerPath(file: string, repoRoot?: string): string;
@@ -0,0 +1,16 @@
1
+ import { relative, isAbsolute } from "node:path";
2
+ /**
3
+ * Normalize a file path to the form used as keys in `LocalDefinitionIndex.byPath`.
4
+ *
5
+ * Parsers receive absolute paths from oxc; the local-index stores
6
+ * repo-root-relative POSIX paths. Shared helper to prevent path-normalisation
7
+ * drift in owner-resolution code paths across parsers.
8
+ *
9
+ * No-op for already-relative paths beyond backslash → forward-slash conversion.
10
+ */
11
+ export function normalizeOwnerPath(file, repoRoot) {
12
+ if (!repoRoot || !isAbsolute(file))
13
+ return file.replace(/\\/g, "/");
14
+ return relative(repoRoot, file).replace(/\\/g, "/");
15
+ }
16
+ //# sourceMappingURL=owner-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owner-utils.js","sourceRoot":"","sources":["../src/owner-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,QAAiB;IAChE,IAAI,CAAC,QAAQ,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACpE,OAAO,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACtD,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * depend on the CLI package (circular), so every type that crosses the
6
6
  * parser ↔ CLI boundary lives here in `plugin-core`.
7
7
  */
8
- import type { OutputComponent, OutputOccurrence } from "./output-types.js";
8
+ import type { OutputComponent, OutputOccurrence, ScanMeta } from "./output-types.js";
9
9
  import type { Diagnostic, DiagnosticCollector } from "./diagnostic.js";
10
10
  import type { ComponentId, ManifestComponent, ManifestSource } from "./types.js";
11
11
  import type { OccurrenceVia } from "./via-types.js";
@@ -18,6 +18,24 @@ export type WrapperId = Brand<string, "WrapperId">;
18
18
  /** Unsafe constructors — use only at the data-ingest boundary. */
19
19
  export declare const asTagName: (s: string) => TagName;
20
20
  export declare const asWrapperId: (s: string) => WrapperId;
21
+ export type CemIndexEntry = {
22
+ packageName: string;
23
+ manifest: unknown;
24
+ };
25
+ /**
26
+ * Structural interface for the global CEM index built by `buildCemIndex` in
27
+ * the CLI. Defined here as a structural type (not importing from CLI) so
28
+ * parsers can reference it without creating a circular dependency.
29
+ *
30
+ * The actual `CemIndex` implementation lives in
31
+ * `packages/cli/src/scan/cem-index.ts` and satisfies this interface.
32
+ */
33
+ export type CemIndex = {
34
+ byTag: Map<string, CemIndexEntry>;
35
+ byPackageName: Map<string, {
36
+ manifest: unknown;
37
+ }>;
38
+ };
21
39
  export type ImportRole = "native" | "react";
22
40
  export type ImportEntry = {
23
41
  specifier: string;
@@ -40,6 +58,8 @@ export type IndexedComponent = (Extract<ManifestComponent, {
40
58
  */
41
59
  export type LazyResolverHit = {
42
60
  leafPackage: string;
61
+ /** Terminal file's path relative to the leaf package root, POSIX-normalised. */
62
+ modulePath: string;
43
63
  matched: IndexedComponent | null;
44
64
  };
45
65
  export type ResolveLazyManifest = (fromFile: string, specifier: string, exportName: string) => LazyResolverHit | null;
@@ -98,7 +118,6 @@ export type Warning = (WarningBase & {
98
118
  * parsers decoupled from CLI-specific fields (configPath, output, etc.).
99
119
  */
100
120
  export type ScanConfig = {
101
- packageScopes: string[];
102
121
  captureValues: boolean;
103
122
  };
104
123
  export type PropUsage = {
@@ -138,10 +157,28 @@ export type Occurrence = {
138
157
  */
139
158
  depth?: number;
140
159
  /**
141
- * ComponentId of the enclosing component-definition. Resolved by parsers
142
- * via ancestor walk. The CLI projection layer hashes this into
143
- * `OutputOccurrence.ownerComponentId`. Undefined when no enclosing tracked
144
- * component was found.
160
+ * Identity of the Component definition that owns this Occurrence (i.e.
161
+ * lexically encloses it in source). Resolved by parsers via ancestor walk.
162
+ * The CLI projection layer (Assemble) hashes this into
163
+ * `OutputOccurrence.ownerComponentId` and drives the composition rollup.
164
+ *
165
+ * Convention for parsers that emit `ownerComponentId`:
166
+ * - Absent (undefined) ⇒ Occurrence is a "root" — no enclosing Component
167
+ * owns it. Composition rollup counts these in `isRootCount`.
168
+ * - Present ⇒ MUST be an Identity that matches a Local definition produced
169
+ * by the corresponding `detect-*.ts` for that file. Mismatch causes the
170
+ * composition rollup's id-equality check to drop the edge silently.
171
+ * - Parsers MUST NOT emit a sentinel value (e.g. "root", null-stringified)
172
+ * in this field. Absence is the signal.
173
+ *
174
+ * Per-language framing:
175
+ * - parser-vue: owner = enclosing SFC's vue-component Identity.
176
+ * - parser-react: owner = nearest enclosing function/class Component binding.
177
+ * - parser-lit (planned, #76): owner = enclosing @customElement class Identity.
178
+ * - parser-html: no owner; HTML files are not Component definitions.
179
+ *
180
+ * Path-based identity resolution must use `normalizeOwnerPath` (from
181
+ * `@component-compass/plugin-core`) to match local-index keys.
145
182
  */
146
183
  ownerComponentId?: ComponentId;
147
184
  };
@@ -175,24 +212,32 @@ export type ParseContext = {
175
212
  repoRoot: string;
176
213
  /** Shared diagnostic collector for the scan run. */
177
214
  collector?: DiagnosticCollector;
215
+ /**
216
+ * Pre-parsed AST for the file. Provided by scan.ts when the single-pass
217
+ * pipeline is active. The type is intentionally `unknown` here — concrete
218
+ * narrowing is plugin-specific. Plugin-core stays free of parser-library deps.
219
+ *
220
+ * For babel-family files (.tsx/.ts/.jsx/.js): oxc Program.
221
+ * For .vue: VueParseWrapper (descriptor + optional scriptProgram).
222
+ * For .html: parse5 Document.
223
+ */
224
+ ast?: unknown;
225
+ /**
226
+ * Global CEM index built once at scan startup. Maps hyphenated tag names
227
+ * and package names to their manifest entries, enabling parsers to resolve
228
+ * tags like `<pie-link>` unconditionally.
229
+ * Provided by scan.ts; parsers consume it.
230
+ */
231
+ cemIndex?: CemIndex;
178
232
  };
179
233
  export interface ParserPlugin {
180
234
  name: string;
181
235
  extensions: string[];
182
236
  parse(file: string, source: string, ctx: ParseContext): ParseResult;
183
237
  }
184
- export type ScanEnvelope = {
185
- scanId: string;
186
- repoId: string;
187
- commitSha: string | null;
188
- branch: string | null;
189
- timestamp: string;
190
- toolVersion: string;
191
- cwd: string;
192
- };
193
238
  export type ManifestRef = {
194
239
  source: ManifestSource;
195
- package: string;
240
+ packageName: string;
196
241
  path: string;
197
242
  version: string | null;
198
243
  };
@@ -204,7 +249,7 @@ export type ScanStats = {
204
249
  totalOccurrences: number;
205
250
  };
206
251
  export type ScanOutput = {
207
- envelope: ScanEnvelope;
252
+ meta: ScanMeta;
208
253
  manifests: ManifestRef[];
209
254
  stats: ScanStats;
210
255
  components: OutputComponent[];
@@ -1 +1 @@
1
- {"version":3,"file":"scan-types.js","sourceRoot":"","sources":["../src/scan-types.ts"],"names":[],"mappings":"AAsBA,kEAAkE;AAClE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAS,EAAW,EAAE,CAAC,CAAY,CAAC;AAC9D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAS,EAAa,EAAE,CAAC,CAAc,CAAC;AAsFpE,MAAM,CAAC,MAAM,eAAe,GAAyB;IACnD,MAAM,EAAE,IAAI,GAAG,EAAE;IACjB,KAAK,EAAE,IAAI,GAAG,EAAE;CACjB,CAAC"}
1
+ {"version":3,"file":"scan-types.js","sourceRoot":"","sources":["../src/scan-types.ts"],"names":[],"mappings":"AAsBA,kEAAkE;AAClE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAS,EAAW,EAAE,CAAC,CAAY,CAAC;AAC9D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAS,EAAa,EAAE,CAAC,CAAc,CAAC;AA2GpE,MAAM,CAAC,MAAM,eAAe,GAAyB;IACnD,MAAM,EAAE,IAAI,GAAG,EAAE;IACjB,KAAK,EAAE,IAAI,GAAG,EAAE;CACjB,CAAC"}
package/dist/schema.js CHANGED
@@ -1,4 +1,3 @@
1
- // biome-ignore lint/suspicious/noThenProperty: JSON Schema if/then for source⇄kind validation
2
1
  export const manifestJsonSchema = {
3
2
  $id: "https://component-compass.dev/manifest-2.0.0.json",
4
3
  type: "object",
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,GAAG,EAAE,mDAAmD;IACxD,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,eAAe,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,CAAC;IAC9D,oBAAoB,EAAE,IAAI;IAC1B,UAAU,EAAE;QACV,aAAa,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;QACjC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE;QACzC,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE;QACzC,UAAU,EAAE;YACV,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC;gBACrC,UAAU,EAAE;oBACV,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,CAAC,EAAE;oBACtE,MAAM,EAAE;wB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EAAE,EAAE;QAC3J,0FAA0F;QAC1F,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;KAC7J;CACO,CAAC"}
package/dist/types.d.ts CHANGED
@@ -2,6 +2,7 @@ export type ComponentKind = "custom-element" | "react-component" | "vue-componen
2
2
  export type ComponentSource = {
3
3
  type: "external";
4
4
  package: string;
5
+ modulePath?: string;
5
6
  } | {
6
7
  type: "local";
7
8
  filePath: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@component-compass/plugin-core",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",