@insitue/capture-core 0.3.1 → 0.3.3
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 +13 -0
- package/dist/index.js +15 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -104,6 +104,19 @@ interface CaptureTarget {
|
|
|
104
104
|
}>;
|
|
105
105
|
/** Robust CSS path — always present, the last-resort locator. */
|
|
106
106
|
selector: string;
|
|
107
|
+
/** CMS attribution. Set when the picked element (or an ancestor)
|
|
108
|
+
* carries a `data-insitue-cms="<handle>"` attribute — host apps
|
|
109
|
+
* stamp this on CMS-rendered roots so tickets can tell reviewers
|
|
110
|
+
* "this content lives in the CMS, not the component". The
|
|
111
|
+
* `handle` is opaque to InSitue (host convention) — e.g.
|
|
112
|
+
* `briefings:<slug>:body`. Cloud tickets show this alongside
|
|
113
|
+
* the code source. Optional `adminUrl` (via the companion
|
|
114
|
+
* `data-insitue-cms-url` sibling attribute) deep-links to the
|
|
115
|
+
* CMS row in the host's admin UI. */
|
|
116
|
+
cmsSource?: {
|
|
117
|
+
handle: string;
|
|
118
|
+
adminUrl?: string;
|
|
119
|
+
};
|
|
107
120
|
}
|
|
108
121
|
interface CaptureBundle {
|
|
109
122
|
schemaVersion: typeof CAPTURE_SCHEMA_VERSION;
|
package/dist/index.js
CHANGED
|
@@ -138,7 +138,7 @@ function toLoc(workspaceCwdRelative) {
|
|
|
138
138
|
function fromAttribute(el) {
|
|
139
139
|
let cur = el;
|
|
140
140
|
for (let i = 0; cur && i < 8; i++, cur = cur.parentElement) {
|
|
141
|
-
const raw = cur.getAttribute("data-insitue-source")
|
|
141
|
+
const raw = cur.getAttribute("data-insitue-source");
|
|
142
142
|
if (raw) {
|
|
143
143
|
const m = /^(.*):(\d+):(\d+)$/.exec(raw);
|
|
144
144
|
if (m) return { file: m[1], line: Number(m[2]), column: Number(m[3]) };
|
|
@@ -146,6 +146,17 @@ function fromAttribute(el) {
|
|
|
146
146
|
}
|
|
147
147
|
return null;
|
|
148
148
|
}
|
|
149
|
+
function fromCmsAttribute(el) {
|
|
150
|
+
let cur = el;
|
|
151
|
+
for (let i = 0; cur && i < 16; i++, cur = cur.parentElement) {
|
|
152
|
+
const handle = cur.getAttribute("data-insitue-cms");
|
|
153
|
+
if (handle) {
|
|
154
|
+
const adminUrl = cur.getAttribute("data-insitue-cms-url") ?? void 0;
|
|
155
|
+
return adminUrl ? { handle, adminUrl } : { handle };
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return void 0;
|
|
159
|
+
}
|
|
149
160
|
function resolveTarget(el) {
|
|
150
161
|
const selector = buildSelector(el);
|
|
151
162
|
const fiber = getFiber(el);
|
|
@@ -183,7 +194,9 @@ function resolveTarget(el) {
|
|
|
183
194
|
}
|
|
184
195
|
}
|
|
185
196
|
}
|
|
186
|
-
|
|
197
|
+
const cmsSource = fromCmsAttribute(el);
|
|
198
|
+
const base = source === void 0 ? { confidence, componentStack, selector } : { source, confidence, componentStack, selector };
|
|
199
|
+
return cmsSource ? { ...base, cmsSource } : base;
|
|
187
200
|
}
|
|
188
201
|
|
|
189
202
|
// src/index.ts
|