@component-compass/plugin-core 0.0.4 → 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.
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export { ManifestBuilder } from "./builder.js";
7
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;AAe/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"}
@@ -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"}
@@ -157,10 +157,28 @@ export type Occurrence = {
157
157
  */
158
158
  depth?: number;
159
159
  /**
160
- * ComponentId of the enclosing component-definition. Resolved by parsers
161
- * via ancestor walk. The CLI projection layer hashes this into
162
- * `OutputOccurrence.ownerComponentId`. Undefined when no enclosing tracked
163
- * 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.
164
182
  */
165
183
  ownerComponentId?: ComponentId;
166
184
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@component-compass/plugin-core",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",