@duffcloudservices/cms 0.15.0 → 0.16.0

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.
@@ -6,5 +6,5 @@ var config = {
6
6
  };
7
7
 
8
8
  export { config };
9
- //# sourceMappingURL=chunk-ZGVP7AKD.js.map
10
- //# sourceMappingURL=chunk-ZGVP7AKD.js.map
9
+ //# sourceMappingURL=chunk-KD2HFSIZ.js.map
10
+ //# sourceMappingURL=chunk-KD2HFSIZ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../package.json"],"names":[],"mappings":";AAKE,IAAA,MAAA,GAAU;AAAA,EACR,eAAA,EAAmB,sCAAA;AAAA,EACnB,mBAAA,EAAuB,sCAAA;AAAA,EACvB,oBAAA,EAAwB;AAC1B","file":"chunk-ZGVP7AKD.js","sourcesContent":["{\n \"name\": \"@duffcloudservices/cms\",\n \"version\": \"0.15.0\",\n \"description\": \"Vue 3 composables and Vite plugins for DCS CMS integration\",\n \"type\": \"module\",\n \"config\": {\n \"agentApiBaseUrl\": \"https://portal.duffcloudservices.com\",\n \"previewPortalOrigin\": \"https://portal.duffcloudservices.com\",\n \"agentWidgetScriptUrl\": \"https://files.duffcloudservices.com/agent-widget/v1/dcs-agent-widget.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./plugins\": {\n \"types\": \"./dist/plugins/index.d.ts\",\n \"import\": \"./dist/plugins/index.js\"\n },\n \"./editor\": {\n \"types\": \"./dist/editor/editorBridge.d.ts\",\n \"import\": \"./dist/editor/editorBridge.js\"\n },\n \"./seo\": {\n \"types\": \"./dist/seo/index.d.ts\",\n \"import\": \"./dist/seo/index.js\"\n },\n \"./components\": {\n \"import\": \"./src/components/PreviewRibbon.vue\"\n },\n \"./responsive-image\": {\n \"import\": \"./src/components/ResponsiveImage.vue\"\n },\n \"./managed-image\": {\n \"import\": \"./src/components/ManagedImage.vue\"\n },\n \"./review-showcase\": {\n \"import\": \"./src/components/DcsReviewShowcase.vue\"\n },\n \"./call-button\": {\n \"import\": \"./src/components/DcsCallButton.vue\"\n },\n \"./lite-media-embed\": {\n \"import\": \"./src/components/LiteMediaEmbed.vue\"\n }\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"files\": [\n \"dist\",\n \"src/components\",\n \"src/composables\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"verify:honesty-rails\": \"node scripts/verify-honesty-rails.mjs\",\n \"probe:live-urls\": \"node scripts/probe-live-emitted-urls.mjs\",\n \"verify:served-honesty\": \"node scripts/probe-live-emitted-urls.mjs\",\n \"type-check\": \"tsc --noEmit\",\n \"lint\": \"eslint .\",\n \"lint:fix\": \"eslint . --fix\",\n \"prepublishOnly\": \"pnpm run build\"\n },\n \"peerDependencies\": {\n \"@unhead/vue\": \"^1.9.0\",\n \"playwright\": \"^1.40.0\",\n \"vue\": \"^3.4.0\"\n },\n \"peerDependenciesMeta\": {\n \"playwright\": {\n \"optional\": true\n }\n },\n \"dependencies\": {\n \"@duffcloudservices/cms-core\": \"workspace:*\",\n \"js-yaml\": \"^4.1.0\"\n },\n \"devDependencies\": {\n \"@dcs/eslint-rules\": \"workspace:*\",\n \"@dcs/test-utils\": \"workspace:*\",\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/markdown-it\": \"^14.1.0\",\n \"@types/node\": \"^20.11.0\",\n \"@unhead/vue\": \"^2.0.5\",\n \"@unhead/vue-v1\": \"npm:@unhead/vue@1.11.20\",\n \"@vitejs/plugin-vue\": \"^6.0.1\",\n \"@vitest/eslint-plugin\": \"^1.3.4\",\n \"@vue/eslint-config-typescript\": \"^14.6.0\",\n \"@vue/test-utils\": \"^2.4.0\",\n \"eslint\": \"^9.31.0\",\n \"eslint-plugin-vue\": \"~10.3.0\",\n \"jiti\": \"^2.4.2\",\n \"markdown-it\": \"^14.3.3\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"~5.6.3\",\n \"vite\": \"^6.3.5\",\n \"vitepress\": \"1.6.4\",\n \"vitest\": \"^3.2.3\",\n \"vue\": \"^3.5.44\",\n \"vue-router\": \"^4.5.1\"\n },\n \"keywords\": [\n \"vue\",\n \"vitepress\",\n \"cms\",\n \"dcs\",\n \"composables\",\n \"duff-cloud-services\"\n ],\n \"author\": \"Duff Cloud Services\",\n \"license\": \"MIT\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/NateDuff/dcs\"\n },\n \"homepage\": \"https://portal.duffcloudservices.com\",\n \"bugs\": {\n \"url\": \"https://github.com/NateDuff/dcs/issues\"\n },\n \"engines\": {\n \"node\": \">=18.0.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n"]}
1
+ {"version":3,"sources":["../package.json"],"names":[],"mappings":";AAKE,IAAA,MAAA,GAAU;AAAA,EACR,eAAA,EAAmB,sCAAA;AAAA,EACnB,mBAAA,EAAuB,sCAAA;AAAA,EACvB,oBAAA,EAAwB;AAC1B","file":"chunk-KD2HFSIZ.js","sourcesContent":["{\n \"name\": \"@duffcloudservices/cms\",\n \"version\": \"0.16.0\",\n \"description\": \"Vue 3 composables and Vite plugins for DCS CMS integration\",\n \"type\": \"module\",\n \"config\": {\n \"agentApiBaseUrl\": \"https://portal.duffcloudservices.com\",\n \"previewPortalOrigin\": \"https://portal.duffcloudservices.com\",\n \"agentWidgetScriptUrl\": \"https://files.duffcloudservices.com/agent-widget/v1/dcs-agent-widget.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./plugins\": {\n \"types\": \"./dist/plugins/index.d.ts\",\n \"import\": \"./dist/plugins/index.js\"\n },\n \"./editor\": {\n \"types\": \"./dist/editor/editorBridge.d.ts\",\n \"import\": \"./dist/editor/editorBridge.js\"\n },\n \"./seo\": {\n \"types\": \"./dist/seo/index.d.ts\",\n \"import\": \"./dist/seo/index.js\"\n },\n \"./components\": {\n \"import\": \"./src/components/PreviewRibbon.vue\"\n },\n \"./responsive-image\": {\n \"import\": \"./src/components/ResponsiveImage.vue\"\n },\n \"./managed-image\": {\n \"import\": \"./src/components/ManagedImage.vue\"\n },\n \"./review-showcase\": {\n \"import\": \"./src/components/DcsReviewShowcase.vue\"\n },\n \"./call-button\": {\n \"import\": \"./src/components/DcsCallButton.vue\"\n },\n \"./lite-media-embed\": {\n \"import\": \"./src/components/LiteMediaEmbed.vue\"\n }\n },\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"files\": [\n \"dist\",\n \"src/components\",\n \"src/composables\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"verify:honesty-rails\": \"node scripts/verify-honesty-rails.mjs\",\n \"probe:live-urls\": \"node scripts/probe-live-emitted-urls.mjs\",\n \"verify:served-honesty\": \"node scripts/probe-live-emitted-urls.mjs\",\n \"type-check\": \"tsc --noEmit\",\n \"lint\": \"eslint .\",\n \"lint:fix\": \"eslint . --fix\",\n \"prepublishOnly\": \"pnpm run build\"\n },\n \"peerDependencies\": {\n \"@unhead/vue\": \"^1.9.0\",\n \"playwright\": \"^1.40.0\",\n \"vue\": \"^3.4.0\"\n },\n \"peerDependenciesMeta\": {\n \"playwright\": {\n \"optional\": true\n }\n },\n \"dependencies\": {\n \"@duffcloudservices/cms-core\": \"workspace:*\",\n \"js-yaml\": \"^4.1.0\"\n },\n \"devDependencies\": {\n \"@dcs/eslint-rules\": \"workspace:*\",\n \"@dcs/test-utils\": \"workspace:*\",\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/markdown-it\": \"^14.1.0\",\n \"@types/node\": \"^20.11.0\",\n \"@unhead/vue\": \"^2.0.5\",\n \"@unhead/vue-v1\": \"npm:@unhead/vue@1.11.20\",\n \"@vitejs/plugin-vue\": \"^6.0.1\",\n \"@vitest/eslint-plugin\": \"^1.3.4\",\n \"@vue/eslint-config-typescript\": \"^14.6.0\",\n \"@vue/test-utils\": \"^2.4.0\",\n \"eslint\": \"^9.31.0\",\n \"eslint-plugin-vue\": \"~10.3.0\",\n \"jiti\": \"^2.4.2\",\n \"markdown-it\": \"^14.3.3\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"~5.6.3\",\n \"vite\": \"^6.4.6\",\n \"vitepress\": \"1.6.4\",\n \"vitest\": \"^3.2.3\",\n \"vue\": \"^3.5.44\",\n \"vue-router\": \"^4.5.1\"\n },\n \"keywords\": [\n \"vue\",\n \"vitepress\",\n \"cms\",\n \"dcs\",\n \"composables\",\n \"duff-cloud-services\"\n ],\n \"author\": \"Duff Cloud Services\",\n \"license\": \"MIT\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/NateDuff/dcs\"\n },\n \"homepage\": \"https://portal.duffcloudservices.com\",\n \"bugs\": {\n \"url\": \"https://github.com/NateDuff/dcs/issues\"\n },\n \"engines\": {\n \"node\": \">=18.0.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n"]}
@@ -1,3 +1,12 @@
1
+ interface ViewportPinReport {
2
+ /** The pinned viewport height in CSS px. */
3
+ height: number;
4
+ /** Declarations (or whole declaration blocks) rewritten since the bridge started. */
5
+ declarations: number;
6
+ /** Stylesheets the bridge could not read (cross-origin without CORS) at the last scan. */
7
+ unreadableSheets: number;
8
+ }
9
+
1
10
  /**
2
11
  * Editor Bridge — injected into customer site iframes by the DCS visual editor.
3
12
  *
@@ -20,6 +29,7 @@
20
29
  * This script runs inside the iframe (customer site). The parent portal
21
30
  * communicates via postMessage using the `dcs:*` message protocol.
22
31
  */
32
+
23
33
  interface SectionInfo {
24
34
  id: string;
25
35
  label: string | null;
@@ -55,6 +65,12 @@ interface EditorReadyPayload {
55
65
  hasReviews: boolean;
56
66
  /** Keys of all [data-dcs-reviews] elements found on the page */
57
67
  reviewKeys: string[];
68
+ /**
69
+ * C-2064 D4: the viewport-height pin (height, rewritten declarations,
70
+ * unreadable stylesheets). For judges, support and telemetry; the portal
71
+ * does not branch on it.
72
+ */
73
+ viewportPin?: ViewportPinReport | null;
58
74
  }
59
75
  /**
60
76
  * Swap the live `<img>`(s) carrying a managed image key to a new source.
@@ -1,4 +1,4 @@
1
- import { config } from '../chunk-ZGVP7AKD.js';
1
+ import { config } from '../chunk-KD2HFSIZ.js';
2
2
 
3
3
  // src/editor/bridgeTrust.ts
4
4
  var PREVIEW_SANDBOX_DOMAIN = "dcs-preview.dev";
@@ -95,7 +95,10 @@ var INBOUND_LIMITS = {
95
95
  html: 2e6,
96
96
  src: 2e6,
97
97
  alt: 1e4,
98
- reviews: 500
98
+ reviews: 500,
99
+ /** dcs:set-viewport height, CSS px (C-2064 D4): an integer in [1, 10000]. */
100
+ viewportHeightMin: 1,
101
+ viewportHeightMax: 1e4
99
102
  };
100
103
  function isRecord(v) {
101
104
  return typeof v === "object" && v !== null && !Array.isArray(v);
@@ -156,11 +159,169 @@ function parseInboundCommand(raw) {
156
159
  if (d.reviews === void 0 || d.reviews === null) return { type: raw.type, key: k, reviews: null };
157
160
  return Array.isArray(d.reviews) && d.reviews.length <= INBOUND_LIMITS.reviews ? { type: raw.type, key: k, reviews: d.reviews } : null;
158
161
  }
162
+ case "dcs:set-viewport": {
163
+ const h = d.height;
164
+ return typeof h === "number" && Number.isInteger(h) && h >= INBOUND_LIMITS.viewportHeightMin && h <= INBOUND_LIMITS.viewportHeightMax ? { type: raw.type, height: h } : null;
165
+ }
159
166
  default:
160
167
  return null;
161
168
  }
162
169
  }
163
170
 
171
+ // src/editor/viewportPin.ts
172
+ var VIEWPORT_PIN_STYLE_ID = "dcs-viewport-pin";
173
+ var VIEWPORT_PIN_PROPERTY = "--dcs-vh";
174
+ var UNIT_TOKEN = /(^|[^\w.#-])([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)([sld]?)(vh|vb|vmax|vmin)(?![\w-])/gi;
175
+ var PROTECTED = /url\((?:[^()"'\\]|\\.|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')*\)|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/gi;
176
+ var QUICK_CHECK = /\d[sld]?v(?:h|b|max|min)/i;
177
+ function rewriteSegment(text) {
178
+ return text.replace(UNIT_TOKEN, (_m, prefix, num, variant, unit) => {
179
+ const pinned = `calc(${num} * var(${VIEWPORT_PIN_PROPERTY}))`;
180
+ const u = unit.toLowerCase();
181
+ if (u === "vmax") return `${prefix}calc(${num} * max(1${variant}vw, var(${VIEWPORT_PIN_PROPERTY})))`;
182
+ if (u === "vmin") return `${prefix}calc(${num} * min(1${variant}vw, var(${VIEWPORT_PIN_PROPERTY})))`;
183
+ return `${prefix}${pinned}`;
184
+ });
185
+ }
186
+ function rewriteViewportUnits(value) {
187
+ if (!QUICK_CHECK.test(value)) return value;
188
+ let out = "";
189
+ let last = 0;
190
+ PROTECTED.lastIndex = 0;
191
+ for (let m = PROTECTED.exec(value); m; m = PROTECTED.exec(value)) {
192
+ out += rewriteSegment(value.slice(last, m.index)) + m[0];
193
+ last = m.index + m[0].length;
194
+ }
195
+ return out + rewriteSegment(value.slice(last));
196
+ }
197
+ var pinnedHeight = null;
198
+ var declarations = 0;
199
+ var unreadableSheets = 0;
200
+ var watching = false;
201
+ var scannedSheets = /* @__PURE__ */ new WeakMap();
202
+ function pinStyleElement() {
203
+ const el = document.getElementById(VIEWPORT_PIN_STYLE_ID);
204
+ return el instanceof HTMLStyleElement ? el : null;
205
+ }
206
+ function writePin(height) {
207
+ let el = pinStyleElement();
208
+ if (!el) {
209
+ el = document.createElement("style");
210
+ el.id = VIEWPORT_PIN_STYLE_ID;
211
+ (document.head ?? document.documentElement).appendChild(el);
212
+ }
213
+ const text = `:root{${VIEWPORT_PIN_PROPERTY}:${height / 100}px !important}`;
214
+ if (el.textContent !== text) el.textContent = text;
215
+ el.dataset.height = String(height);
216
+ }
217
+ function rewriteDeclarations(style) {
218
+ if (!QUICK_CHECK.test(style.cssText)) return 0;
219
+ let n = 0;
220
+ const props = [];
221
+ for (let i = 0; i < style.length; i++) props.push(style.item(i));
222
+ for (const prop of props) {
223
+ const value = style.getPropertyValue(prop);
224
+ const next2 = rewriteViewportUnits(value);
225
+ if (next2 !== value) {
226
+ style.setProperty(prop, next2, style.getPropertyPriority(prop));
227
+ n++;
228
+ }
229
+ }
230
+ const whole = style.cssText;
231
+ const next = rewriteViewportUnits(whole);
232
+ if (next !== whole) {
233
+ style.cssText = next;
234
+ n++;
235
+ }
236
+ return n;
237
+ }
238
+ function walkRules(rules, depth) {
239
+ let unreadable = 0;
240
+ for (let i = 0; i < rules.length; i++) {
241
+ const rule = rules[i];
242
+ if (rule.styleSheet) unreadable += scanSheet(rule.styleSheet, depth + 1, true);
243
+ if (rule.style) declarations += rewriteDeclarations(rule.style);
244
+ if (rule.cssRules) unreadable += walkRules(rule.cssRules, depth + 1);
245
+ }
246
+ return unreadable;
247
+ }
248
+ function scanSheet(sheet, depth, force = false) {
249
+ if (depth > 32) return 0;
250
+ const owner = sheet.ownerNode;
251
+ if (owner?.id === VIEWPORT_PIN_STYLE_ID) return 0;
252
+ let rules;
253
+ try {
254
+ rules = sheet.cssRules;
255
+ } catch {
256
+ return 1;
257
+ }
258
+ if (!rules) return 0;
259
+ const seen = scannedSheets.get(sheet);
260
+ if (!force && seen && seen.rules === rules.length) return seen.unreadable;
261
+ const unreadable = walkRules(rules, depth);
262
+ scannedSheets.set(sheet, { rules: rules.length, unreadable });
263
+ return unreadable;
264
+ }
265
+ function rescanViewportUnits(options = {}) {
266
+ if (pinnedHeight === null) return;
267
+ if (!pinStyleElement()) writePin(pinnedHeight);
268
+ let unreadable = 0;
269
+ const sheets = Array.from(document.styleSheets ?? []);
270
+ const adopted = document.adoptedStyleSheets;
271
+ if (adopted) sheets.push(...adopted);
272
+ for (const sheet of sheets) {
273
+ try {
274
+ void sheet.cssRules;
275
+ } catch {
276
+ unreadable++;
277
+ continue;
278
+ }
279
+ unreadable += scanSheet(sheet, 0);
280
+ }
281
+ unreadableSheets = unreadable;
282
+ if (options.inline) {
283
+ document.querySelectorAll("[style]").forEach((el) => {
284
+ if (el.style && QUICK_CHECK.test(el.getAttribute("style") ?? "")) declarations += rewriteDeclarations(el.style);
285
+ });
286
+ }
287
+ }
288
+ function startWatching() {
289
+ if (watching) return;
290
+ watching = true;
291
+ if (typeof MutationObserver !== "undefined") {
292
+ const observer = new MutationObserver((records) => {
293
+ const own = pinStyleElement();
294
+ if (records.every((r) => own && (r.target === own || r.target.parentNode === own))) return;
295
+ rescanViewportUnits();
296
+ });
297
+ observer.observe(document.head ?? document.documentElement, { childList: true, subtree: true, characterData: true });
298
+ }
299
+ document.addEventListener("load", (event) => {
300
+ const target = event.target;
301
+ if (target instanceof HTMLLinkElement || target instanceof HTMLStyleElement) rescanViewportUnits();
302
+ }, true);
303
+ }
304
+ function pinViewportUnits(height) {
305
+ const h = Math.round(height);
306
+ if (!Number.isFinite(h) || h < 0) return false;
307
+ const changed = pinnedHeight !== h;
308
+ const first = pinnedHeight === null;
309
+ pinnedHeight = h;
310
+ writePin(h);
311
+ if (first) {
312
+ rescanViewportUnits({ inline: true });
313
+ startWatching();
314
+ }
315
+ return changed;
316
+ }
317
+ function startViewportPin() {
318
+ const carried = Number(pinStyleElement()?.dataset.height);
319
+ pinViewportUnits(Number.isFinite(carried) && carried > 0 ? carried : globalThis.innerHeight);
320
+ }
321
+ function viewportPinReport() {
322
+ return pinnedHeight === null ? null : { height: pinnedHeight, declarations, unreadableSheets };
323
+ }
324
+
164
325
  // src/editor/editorBridge.ts
165
326
  function isInIframe() {
166
327
  try {
@@ -328,6 +489,7 @@ function setMode(mode) {
328
489
  }
329
490
  function rediscoverAndNotify() {
330
491
  activeEditElement = null;
492
+ rescanViewportUnits({ inline: true });
331
493
  const sections = discoverSections();
332
494
  const textKeys = discoverTextKeys();
333
495
  const reviewKeys = discoverReviewKeys();
@@ -356,7 +518,8 @@ function rediscoverAndNotify() {
356
518
  hasManagedForms: managedFormIds.length > 0,
357
519
  managedFormIds,
358
520
  hasReviews: reviewKeys.length > 0,
359
- reviewKeys
521
+ reviewKeys,
522
+ viewportPin: viewportPinReport()
360
523
  });
361
524
  applyPendingImageOverrides();
362
525
  if (editorActive) {
@@ -1360,9 +1523,13 @@ function handleMessage(event) {
1360
1523
  }));
1361
1524
  scheduleRediscovery();
1362
1525
  break;
1526
+ case "dcs:set-viewport":
1527
+ if (pinViewportUnits(cmd.height)) scheduleRediscovery();
1528
+ break;
1363
1529
  }
1364
1530
  }
1365
1531
  function injectEditorHeightFix() {
1532
+ startViewportPin();
1366
1533
  if (document.getElementById("dcs-editor-height-fix")) return;
1367
1534
  const style = document.createElement("style");
1368
1535
  style.id = "dcs-editor-height-fix";
@@ -1466,7 +1633,8 @@ function initEditorBridge(options) {
1466
1633
  hasManagedForms: managedFormIds.length > 0,
1467
1634
  managedFormIds,
1468
1635
  hasReviews: reviewKeys.length > 0,
1469
- reviewKeys
1636
+ reviewKeys,
1637
+ viewportPin: viewportPinReport()
1470
1638
  });
1471
1639
  observeSectionLayout();
1472
1640
  }