pattern-dump 0.1.0-alpha.3 → 0.2.0-alpha.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.
- package/CHANGELOG.md +120 -0
- package/LICENSE +16 -3
- package/README.md +2 -2
- package/THIRD-PARTY-NOTICES.md +130 -0
- package/dist/chunks/chunk-ESMZAOP2.js +283 -0
- package/dist/dev-ui/main.js +215 -77
- package/dist/index.js +1 -1
- package/dist/pd.js +5887 -1003
- package/dist/types/config/index.d.ts +98 -5
- package/dist/types/config/validate.d.ts +12 -0
- package/dist/types/contracts/dev-protocol.d.ts +106 -4
- package/dist/types/contracts/iframe-fit.d.ts +33 -0
- package/dist/types/contracts/index.d.ts +36 -0
- package/package.json +10 -3
- package/templates/base/README.md +1 -0
- package/templates/base/_gitignore +1 -0
- package/templates/base/pattern-dump.config.ts +1 -0
- package/templates/base/src/styles/base/document.scss +5 -1
- package/templates/storefront/.github/workflows/pages.yml +53 -0
- package/templates/storefront/assets/icon.svg +2 -0
- package/templates/storefront/pages/about.md +15 -0
- package/templates/storefront/pages/index.md +24 -0
- package/templates/storefront/src/patterns/components/note/note.hbs +4 -0
- package/templates/storefront/src/patterns/components/note/note.json +4 -0
- package/templates/storefront/src/patterns/components/note/note.md +11 -0
- package/templates/storefront/src/patterns/components/note/note.schema.json +13 -0
- package/templates/storefront/src/patterns/components/note/note~warning.json +4 -0
- package/templates/storefront/src/patterns/layouts/page/page.hbs +8 -0
- package/templates/storefront/src/patterns/layouts/page/page.json +8 -0
- package/templates/storefront/src/patterns/layouts/page/page.md +6 -0
- package/templates/storefront/src/patterns/layouts/page/page.schema.json +19 -0
- package/templates/storefront/src/patterns/partials/base/base.hbs +17 -0
- package/templates/storefront/src/patterns/partials/base/base.json +4 -0
- package/templates/storefront/src/patterns/partials/base/base.md +6 -0
- package/templates/storefront/src/patterns/partials/base/base.schema.json +18 -0
- package/templates/storefront/src/patterns/partials/head/head.hbs +1 -0
- package/templates/storefront/src/patterns/partials/head/head.md +6 -0
- package/templates/storefront/src/styles/components/note.scss +8 -0
- package/templates/storefront/src/styles/layouts/page.scss +6 -0
- package/templates/storefront/src/styles/partials/base.scss +13 -0
- package/templates/storefront-fills/config.txt +14 -0
- package/templates/storefront-fills/gitignore.txt +2 -0
- package/templates/storefront-fills/readme.md +60 -0
- package/dist/chunks/chunk-3WZHFYHZ.js +0 -160
package/dist/dev-ui/main.js
CHANGED
|
@@ -87,6 +87,14 @@ var PD_ROUTES = {
|
|
|
87
87
|
version: "/api/version",
|
|
88
88
|
/** GET → ShellClientConfig */
|
|
89
89
|
config: "/api/config",
|
|
90
|
+
/** GET → StorefrontPagesResponse, on the storefront host. What `pd build` crawls for storefront pages. */
|
|
91
|
+
pages: "/api/pages",
|
|
92
|
+
/** GET → the storefront's sitemap (XML), on the storefront host; only when `storefront.url` is set. */
|
|
93
|
+
sitemap: "/sitemap.xml",
|
|
94
|
+
/** GET → robots.txt (text): the storefront's on the storefront host, the workbench's on every other host. */
|
|
95
|
+
robots: "/robots.txt",
|
|
96
|
+
/** GET → the storefront's 404 page (HTML, status 404), on the storefront host. `pd build` writes it as is. */
|
|
97
|
+
notFound: "/404.html",
|
|
90
98
|
/** The shell bundle, stylesheet and vendored assets. */
|
|
91
99
|
mainJs: "/_pd/main.js",
|
|
92
100
|
mainCss: "/_pd/main.css",
|
|
@@ -105,7 +113,8 @@ var PD_ROUTE_PREFIX = {
|
|
|
105
113
|
componentCss: "/_pd/components/",
|
|
106
114
|
themeCss: "/_pd/themes/",
|
|
107
115
|
script: "/_pd/scripts/",
|
|
108
|
-
assets: "/assets/"
|
|
116
|
+
assets: "/assets/",
|
|
117
|
+
images: "/_pd/images/"
|
|
109
118
|
};
|
|
110
119
|
function componentUrl(id, variant) {
|
|
111
120
|
const q = variant ? `?variant=${encodeURIComponent(variant)}` : "";
|
|
@@ -137,10 +146,62 @@ function staticPathFor(liveUrl) {
|
|
|
137
146
|
}
|
|
138
147
|
}
|
|
139
148
|
if (path.startsWith("/_pd/") || path.startsWith(PD_ROUTE_PREFIX.assets)) return path.slice(1);
|
|
149
|
+
if (path === PD_ROUTES.sitemap || path === PD_ROUTES.robots || path === PD_ROUTES.notFound) return path.slice(1);
|
|
140
150
|
const route = path.replace(/^\/+|\/+$/g, "");
|
|
141
151
|
return route ? `${route}/index.html` : "index.html";
|
|
142
152
|
}
|
|
143
153
|
var PD_PROTOCOL_VERSION = 1;
|
|
154
|
+
var PD_GENERATION_HEADER = "X-PD-Generation";
|
|
155
|
+
function generationBehind(a, b) {
|
|
156
|
+
if (!a || !b) return false;
|
|
157
|
+
const [bootA, countA] = a.split(".");
|
|
158
|
+
const [bootB, countB] = b.split(".");
|
|
159
|
+
return bootA !== bootB || Number(countA) < Number(countB);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// ../../packages/contracts/src/iframe-fit.ts
|
|
163
|
+
function createHeightFitter(adapter) {
|
|
164
|
+
const GROWTH_FACTOR = 1.5;
|
|
165
|
+
const GROWTH_RUN = 2;
|
|
166
|
+
const state = /* @__PURE__ */ new WeakMap();
|
|
167
|
+
const circular = /* @__PURE__ */ new WeakSet();
|
|
168
|
+
const isCircularGrowth2 = (previous, measured) => previous !== void 0 && measured > previous.last * GROWTH_FACTOR && previous.run + 1 >= GROWTH_RUN;
|
|
169
|
+
return {
|
|
170
|
+
isCircularGrowth: isCircularGrowth2,
|
|
171
|
+
accept(frame, height) {
|
|
172
|
+
if (adapter.fits && !adapter.fits(frame) || circular.has(frame)) return false;
|
|
173
|
+
const previous = state.get(frame);
|
|
174
|
+
if (previous !== void 0 && isCircularGrowth2(previous, height)) {
|
|
175
|
+
circular.add(frame);
|
|
176
|
+
state.delete(frame);
|
|
177
|
+
adapter.write(frame, previous.steady);
|
|
178
|
+
if (adapter.onCircular) adapter.onCircular(frame);
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
const grew = previous !== void 0 && height > previous.last * GROWTH_FACTOR;
|
|
182
|
+
state.set(frame, {
|
|
183
|
+
last: height,
|
|
184
|
+
steady: grew && previous ? previous.steady : height,
|
|
185
|
+
run: grew && previous ? previous.run + 1 : 0
|
|
186
|
+
});
|
|
187
|
+
adapter.write(frame, height);
|
|
188
|
+
return true;
|
|
189
|
+
},
|
|
190
|
+
reset(frame) {
|
|
191
|
+
state.delete(frame);
|
|
192
|
+
circular.delete(frame);
|
|
193
|
+
if (adapter.onReset) adapter.onReset(frame);
|
|
194
|
+
},
|
|
195
|
+
fromMessage(event, frames) {
|
|
196
|
+
const data = event.data;
|
|
197
|
+
if (!data || data.type !== "pd-height" || typeof data.height !== "number") return null;
|
|
198
|
+
for (const frame of frames) {
|
|
199
|
+
if (frame.contentWindow === event.source) return { frame, height: data.height };
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
144
205
|
|
|
145
206
|
// src/core/dom.ts
|
|
146
207
|
var dom = {};
|
|
@@ -380,9 +441,9 @@ function createStore() {
|
|
|
380
441
|
function notify() {
|
|
381
442
|
for (const fn of listeners) fn();
|
|
382
443
|
}
|
|
383
|
-
function persist(
|
|
444
|
+
function persist(state) {
|
|
384
445
|
try {
|
|
385
|
-
localStorage.setItem(STORAGE_KEY, toJSON(
|
|
446
|
+
localStorage.setItem(STORAGE_KEY, toJSON(state));
|
|
386
447
|
} catch {
|
|
387
448
|
}
|
|
388
449
|
}
|
|
@@ -1729,42 +1790,26 @@ function setVpProp(el2, prop, value) {
|
|
|
1729
1790
|
}
|
|
1730
1791
|
|
|
1731
1792
|
// src/stage/content-height.ts
|
|
1732
|
-
var GROWTH_FACTOR = 1.5;
|
|
1733
|
-
var GROWTH_RUN = 2;
|
|
1734
|
-
var state = /* @__PURE__ */ new WeakMap();
|
|
1735
|
-
var circular = /* @__PURE__ */ new WeakSet();
|
|
1736
1793
|
var report = null;
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
}
|
|
1744
|
-
function acceptContentHeight(frame, height) {
|
|
1745
|
-
if (!fitsHeight(frame) || circular.has(frame)) return false;
|
|
1746
|
-
const previous = state.get(frame);
|
|
1747
|
-
if (isCircularGrowth(previous, height)) {
|
|
1748
|
-
circular.add(frame);
|
|
1749
|
-
state.delete(frame);
|
|
1794
|
+
var fitter = createHeightFitter({
|
|
1795
|
+
write: (frame, height) => setVpProp(frame, "--vp-h", height),
|
|
1796
|
+
// A full-page preview fills the stage: its height is CSS, never measured (it is circular by
|
|
1797
|
+
// construction — the content derives its height from the frame we would derive from the content).
|
|
1798
|
+
fits: (frame) => frame.closest('[data-layout="full"]') === null,
|
|
1799
|
+
onCircular: (frame) => {
|
|
1750
1800
|
frame.dataset.pdHeight = "circular";
|
|
1751
|
-
setVpProp(frame, "--vp-h", previous.steady);
|
|
1752
1801
|
report?.(frame);
|
|
1753
|
-
|
|
1802
|
+
},
|
|
1803
|
+
onReset: (frame) => {
|
|
1804
|
+
delete frame.dataset.pdHeight;
|
|
1754
1805
|
}
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
run: grew ? previous.run + 1 : 0
|
|
1760
|
-
});
|
|
1761
|
-
setVpProp(frame, "--vp-h", height);
|
|
1762
|
-
return true;
|
|
1806
|
+
});
|
|
1807
|
+
function acceptContentHeightMessage(event, frames) {
|
|
1808
|
+
const match = fitter.fromMessage(event, frames);
|
|
1809
|
+
if (match) fitter.accept(match.frame, match.height);
|
|
1763
1810
|
}
|
|
1764
1811
|
function resetContentHeight(frame) {
|
|
1765
|
-
|
|
1766
|
-
circular.delete(frame);
|
|
1767
|
-
delete frame.dataset.pdHeight;
|
|
1812
|
+
fitter.reset(frame);
|
|
1768
1813
|
}
|
|
1769
1814
|
function initContentHeight(onCircular) {
|
|
1770
1815
|
report = onCircular;
|
|
@@ -1861,10 +1906,10 @@ function setWidthNow(frame, width) {
|
|
|
1861
1906
|
function acceptContentWidth(frame, width, at, scroll) {
|
|
1862
1907
|
const full = measuring.get(frame);
|
|
1863
1908
|
if (full === void 0) {
|
|
1864
|
-
const
|
|
1865
|
-
if (
|
|
1909
|
+
const state = fitted.get(frame);
|
|
1910
|
+
if (state === void 0 || scroll <= at + 1) return false;
|
|
1866
1911
|
const parentWidth = frame.parentElement?.clientWidth ?? Infinity;
|
|
1867
|
-
if (
|
|
1912
|
+
if (state === "measured" && scroll < parentWidth) {
|
|
1868
1913
|
fitted.set(frame, "widened");
|
|
1869
1914
|
setWidthNow(frame, scroll);
|
|
1870
1915
|
} else {
|
|
@@ -2291,6 +2336,42 @@ function initSplitters() {
|
|
|
2291
2336
|
});
|
|
2292
2337
|
}
|
|
2293
2338
|
|
|
2339
|
+
// src/core/generation.ts
|
|
2340
|
+
var newest;
|
|
2341
|
+
function heard(generation) {
|
|
2342
|
+
if (generation && (!newest || generationBehind(newest, generation))) newest = generation;
|
|
2343
|
+
}
|
|
2344
|
+
function generationOf(res) {
|
|
2345
|
+
return res.headers.get(PD_GENERATION_HEADER);
|
|
2346
|
+
}
|
|
2347
|
+
function behindHeard(generation) {
|
|
2348
|
+
return generationBehind(generation, newest);
|
|
2349
|
+
}
|
|
2350
|
+
var shown = /* @__PURE__ */ new Map();
|
|
2351
|
+
function claim(slot, key, generation) {
|
|
2352
|
+
const current = shown.get(slot);
|
|
2353
|
+
if (current && current.key === key && generationBehind(generation, current.generation)) return false;
|
|
2354
|
+
shown.set(slot, { key, generation });
|
|
2355
|
+
return true;
|
|
2356
|
+
}
|
|
2357
|
+
async function loadDocument(slot, key, url, apply, wanted) {
|
|
2358
|
+
for (; ; ) {
|
|
2359
|
+
const res = await fetch(url);
|
|
2360
|
+
const doc = await res.text();
|
|
2361
|
+
const generation = generationOf(res);
|
|
2362
|
+
if (!wanted() || !claim(slot, key, generation)) return;
|
|
2363
|
+
apply(doc);
|
|
2364
|
+
if (!behindHeard(generation)) return;
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
async function fetchDetail(componentId, variant) {
|
|
2368
|
+
const res = await fetch(componentUrl(componentId, variant));
|
|
2369
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
2370
|
+
const detail = await res.json();
|
|
2371
|
+
if (session.current?.id !== componentId || !claim("detail", componentId, generationOf(res))) return null;
|
|
2372
|
+
return detail;
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2294
2375
|
// src/core/pd-links.ts
|
|
2295
2376
|
function reconcilePdLinks(doc, orderedHrefs) {
|
|
2296
2377
|
if (!doc) return;
|
|
@@ -2431,7 +2512,7 @@ function swapWithTransition(fn) {
|
|
|
2431
2512
|
fn();
|
|
2432
2513
|
}
|
|
2433
2514
|
}
|
|
2434
|
-
async function applyComponent(detail, variant) {
|
|
2515
|
+
async function applyComponent(detail, variant, generation = null) {
|
|
2435
2516
|
session.current = detail;
|
|
2436
2517
|
session.currentVariant = variant ?? null;
|
|
2437
2518
|
session.renderedHtmlCache = null;
|
|
@@ -2460,11 +2541,46 @@ async function applyComponent(detail, variant) {
|
|
|
2460
2541
|
dom.hidePackagesCheck.checked = false;
|
|
2461
2542
|
dom.hidePackagesCheck.dispatchEvent(new Event("change"));
|
|
2462
2543
|
}
|
|
2463
|
-
|
|
2464
|
-
const
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2544
|
+
claim("detail", detail.id, generation);
|
|
2545
|
+
const key = `${detail.id}~${variant && isKnownVariant ? variant : ""}`;
|
|
2546
|
+
const wanted = () => session.current?.id === detail.id;
|
|
2547
|
+
if (variant && isKnownVariant) {
|
|
2548
|
+
await loadDocument(
|
|
2549
|
+
"preview",
|
|
2550
|
+
key,
|
|
2551
|
+
previewUrl(detail.id, variant, store.local.theme || void 0),
|
|
2552
|
+
(doc) => {
|
|
2553
|
+
swapWithTransition(() => {
|
|
2554
|
+
dom.iframe.srcdoc = doc;
|
|
2555
|
+
});
|
|
2556
|
+
},
|
|
2557
|
+
wanted
|
|
2558
|
+
);
|
|
2559
|
+
} else {
|
|
2560
|
+
claim("preview", key, generation);
|
|
2561
|
+
const _html = detail.document ?? "";
|
|
2562
|
+
swapWithTransition(() => {
|
|
2563
|
+
dom.iframe.srcdoc = _html;
|
|
2564
|
+
});
|
|
2565
|
+
if (behindHeard(generation)) {
|
|
2566
|
+
void loadDocument(
|
|
2567
|
+
"preview",
|
|
2568
|
+
key,
|
|
2569
|
+
previewUrl(detail.id, void 0, store.local.theme || void 0),
|
|
2570
|
+
(doc) => {
|
|
2571
|
+
dom.iframe.srcdoc = doc;
|
|
2572
|
+
},
|
|
2573
|
+
wanted
|
|
2574
|
+
);
|
|
2575
|
+
void fetchDetail(detail.id).then((d) => {
|
|
2576
|
+
if (d) {
|
|
2577
|
+
session.current = d;
|
|
2578
|
+
void renderPanel();
|
|
2579
|
+
}
|
|
2580
|
+
}).catch(() => {
|
|
2581
|
+
});
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2468
2584
|
dom.iframe.style.removeProperty("--vp-h");
|
|
2469
2585
|
if (isDiscoRunning()) stopDisco();
|
|
2470
2586
|
applyViewport();
|
|
@@ -2502,14 +2618,22 @@ async function swapVariant(componentId, variant) {
|
|
|
2502
2618
|
dom.htmlBody.innerHTML = "";
|
|
2503
2619
|
dom.dataBody.innerHTML = "";
|
|
2504
2620
|
dom.variantSelect.value = variant ?? "";
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2621
|
+
await loadDocument(
|
|
2622
|
+
"preview",
|
|
2623
|
+
`${componentId}~${variant ?? ""}`,
|
|
2624
|
+
previewUrl(componentId, variant ?? void 0, store.local.theme || void 0),
|
|
2625
|
+
(doc) => {
|
|
2626
|
+
swapWithTransition(() => {
|
|
2627
|
+
dom.iframe.srcdoc = doc;
|
|
2628
|
+
});
|
|
2629
|
+
},
|
|
2630
|
+
() => session.current?.id === componentId && session.currentVariant === variant
|
|
2631
|
+
);
|
|
2509
2632
|
const dock = store.local.dock;
|
|
2510
2633
|
if (dock.dockTab === "html") await fetchAndShowHtml();
|
|
2511
2634
|
if (dock.dockTab === "source" && dock.sourceFacet === "data") await fetchAndShowData();
|
|
2512
|
-
void
|
|
2635
|
+
void fetchDetail(componentId, variant ?? void 0).then((d) => {
|
|
2636
|
+
if (!d) return;
|
|
2513
2637
|
session.current = d;
|
|
2514
2638
|
session.renderedA11y = [];
|
|
2515
2639
|
session.scanPending = store.local.dock.dockTab === "diagnostics";
|
|
@@ -2525,7 +2649,7 @@ async function navigate(componentId, variant) {
|
|
|
2525
2649
|
const res = await fetch(componentUrl(componentId, variant));
|
|
2526
2650
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
2527
2651
|
const detail = await res.json();
|
|
2528
|
-
await applyComponent(detail, variant);
|
|
2652
|
+
await applyComponent(detail, variant, generationOf(res));
|
|
2529
2653
|
} catch (e) {
|
|
2530
2654
|
console.error("[pd] Navigate error:", e);
|
|
2531
2655
|
showStageMessage(`Could not load \u201C${componentId}\u201D: ${e instanceof Error ? e.message : String(e)}`);
|
|
@@ -2534,7 +2658,7 @@ async function navigate(componentId, variant) {
|
|
|
2534
2658
|
async function navigateUnknown(path, variant) {
|
|
2535
2659
|
const res = await fetch(componentUrl(path, variant)).catch(() => null);
|
|
2536
2660
|
if (res?.ok) {
|
|
2537
|
-
await applyComponent(await res.json(), variant);
|
|
2661
|
+
await applyComponent(await res.json(), variant, generationOf(res));
|
|
2538
2662
|
return;
|
|
2539
2663
|
}
|
|
2540
2664
|
showStageMessage(`No component or folder \u201C${path}\u201D.`, closestPaths(path));
|
|
@@ -2707,6 +2831,7 @@ function connectHmr() {
|
|
|
2707
2831
|
} catch {
|
|
2708
2832
|
return;
|
|
2709
2833
|
}
|
|
2834
|
+
if ("generation" in msg) heard(msg.generation);
|
|
2710
2835
|
if ((msg.type === "content-swap" || msg.type === "error") && store.local.panelTab === "audit") {
|
|
2711
2836
|
refreshAudit();
|
|
2712
2837
|
}
|
|
@@ -2723,20 +2848,23 @@ function connectHmr() {
|
|
|
2723
2848
|
const tiles = Array.from(
|
|
2724
2849
|
dom.variantsGalleryEl.querySelectorAll(".gallery-item iframe")
|
|
2725
2850
|
);
|
|
2726
|
-
await Promise.all(tiles.map(
|
|
2851
|
+
await Promise.all(tiles.map((f) => {
|
|
2727
2852
|
const vp = f.dataset.pdVariant || void 0;
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2853
|
+
return loadDocument(`tile:${vp ?? ""}`, `${componentId}~${vp ?? ""}`, previewUrl(componentId, vp, store.local.theme || void 0), (doc) => {
|
|
2854
|
+
f.srcdoc = doc;
|
|
2855
|
+
console.log(
|
|
2856
|
+
"%c[pd] srcdoc reloaded",
|
|
2857
|
+
"color:#7ed321;font-weight:bold",
|
|
2858
|
+
`\u2014 ${componentId} (${vp ?? "default"})`
|
|
2859
|
+
);
|
|
2860
|
+
}, () => f.isConnected && session.current?.id === componentId);
|
|
2735
2861
|
}));
|
|
2736
2862
|
} else {
|
|
2737
|
-
const
|
|
2738
|
-
|
|
2739
|
-
|
|
2863
|
+
const variant = session.currentVariant;
|
|
2864
|
+
await loadDocument("preview", `${componentId}~${variant ?? ""}`, previewUrl(componentId, variant ?? void 0, store.local.theme || void 0), (doc) => {
|
|
2865
|
+
dom.iframe.srcdoc = doc;
|
|
2866
|
+
console.log("%c[pd] srcdoc reloaded", "color:#7ed321;font-weight:bold", `\u2014 ${componentId}`);
|
|
2867
|
+
}, () => session.current?.id === componentId && session.currentVariant === variant);
|
|
2740
2868
|
}
|
|
2741
2869
|
{
|
|
2742
2870
|
const d = store.local.dock;
|
|
@@ -2748,7 +2876,8 @@ function connectHmr() {
|
|
|
2748
2876
|
void fetchAndShowData();
|
|
2749
2877
|
}
|
|
2750
2878
|
}
|
|
2751
|
-
void
|
|
2879
|
+
void fetchDetail(componentId, session.currentVariant ?? void 0).then((d) => {
|
|
2880
|
+
if (!d) return;
|
|
2752
2881
|
session.current = d;
|
|
2753
2882
|
session.renderedA11y = [];
|
|
2754
2883
|
session.scanPending = store.local.dock.dockTab === "diagnostics";
|
|
@@ -2785,12 +2914,20 @@ function connectHmr() {
|
|
|
2785
2914
|
if (f.id === "preview-frame") return;
|
|
2786
2915
|
if (f.closest("#variants-gallery")) return;
|
|
2787
2916
|
const link = f.contentDocument?.querySelector(`link[data-pd-comp="${componentId}"]`);
|
|
2788
|
-
if (link)
|
|
2917
|
+
if (link) {
|
|
2918
|
+
link.href = href;
|
|
2919
|
+
return;
|
|
2920
|
+
}
|
|
2921
|
+
if (msg.cssBecameNonEmpty && dom.categoryOverview.contains(f)) f.contentWindow?.location.reload();
|
|
2789
2922
|
});
|
|
2790
2923
|
} else {
|
|
2791
2924
|
document.querySelectorAll("iframe").forEach((f) => {
|
|
2792
2925
|
const link = f.contentDocument?.querySelector(`link[data-pd-comp="${componentId}"]`);
|
|
2793
|
-
if (link)
|
|
2926
|
+
if (link) {
|
|
2927
|
+
link.href = href;
|
|
2928
|
+
return;
|
|
2929
|
+
}
|
|
2930
|
+
if (msg.cssBecameNonEmpty && dom.categoryOverview.contains(f)) f.contentWindow?.location.reload();
|
|
2794
2931
|
});
|
|
2795
2932
|
}
|
|
2796
2933
|
void pdLinksLoaded().then(() => {
|
|
@@ -2798,9 +2935,11 @@ function connectHmr() {
|
|
|
2798
2935
|
remeasureAll();
|
|
2799
2936
|
});
|
|
2800
2937
|
if (store.local.panelTab === "relationships" && session.current) {
|
|
2801
|
-
void
|
|
2802
|
-
|
|
2803
|
-
|
|
2938
|
+
void fetchDetail(session.current.id).then((d) => {
|
|
2939
|
+
if (d) {
|
|
2940
|
+
session.current = d;
|
|
2941
|
+
return renderPanel();
|
|
2942
|
+
}
|
|
2804
2943
|
}).catch(() => {
|
|
2805
2944
|
});
|
|
2806
2945
|
}
|
|
@@ -2808,7 +2947,8 @@ function connectHmr() {
|
|
|
2808
2947
|
renderConsole(`${msg.scope === "build" ? "Build" : "Render"} error \u2014 ${msg.message}`, "error");
|
|
2809
2948
|
const errId = msg.componentId;
|
|
2810
2949
|
if (errId && errId === session.current?.id) {
|
|
2811
|
-
void
|
|
2950
|
+
void fetchDetail(errId).then((d) => {
|
|
2951
|
+
if (!d) return;
|
|
2812
2952
|
session.current = d;
|
|
2813
2953
|
session.renderedA11y = [];
|
|
2814
2954
|
session.scanPending = store.local.dock.dockTab === "diagnostics";
|
|
@@ -2850,9 +2990,11 @@ function connectHmr() {
|
|
|
2850
2990
|
if (folderPath) void navigateOverview(folderPath);
|
|
2851
2991
|
}
|
|
2852
2992
|
if (session.current?.id && session.componentRegistry.has(session.current.id) && store.local.panelTab === "relationships") {
|
|
2853
|
-
void
|
|
2854
|
-
|
|
2855
|
-
|
|
2993
|
+
void fetchDetail(session.current.id).then((d) => {
|
|
2994
|
+
if (d) {
|
|
2995
|
+
session.current = d;
|
|
2996
|
+
return renderPanel();
|
|
2997
|
+
}
|
|
2856
2998
|
}).catch(() => {
|
|
2857
2999
|
});
|
|
2858
3000
|
}
|
|
@@ -2863,6 +3005,7 @@ function connectHmr() {
|
|
|
2863
3005
|
`Handle collision \u2014 "${msg.handle}" is held by ${msg.incumbentPath}; ${msg.quarantinedPath} is quarantined until one is renamed`,
|
|
2864
3006
|
"error"
|
|
2865
3007
|
);
|
|
3008
|
+
} else if (msg.type === "page-changed") {
|
|
2866
3009
|
} else {
|
|
2867
3010
|
const unhandled = msg;
|
|
2868
3011
|
void unhandled;
|
|
@@ -2937,13 +3080,8 @@ function listenForPreviewMessages() {
|
|
|
2937
3080
|
window.addEventListener("message", (e) => {
|
|
2938
3081
|
const data = e.data;
|
|
2939
3082
|
if (!data) return;
|
|
2940
|
-
if (data.type === "pd-height"
|
|
2941
|
-
|
|
2942
|
-
document.querySelectorAll("iframe").forEach((f) => {
|
|
2943
|
-
const frame = f;
|
|
2944
|
-
if (frame.contentWindow !== e.source) return;
|
|
2945
|
-
acceptContentHeight(frame, height);
|
|
2946
|
-
});
|
|
3083
|
+
if (data.type === "pd-height") {
|
|
3084
|
+
acceptContentHeightMessage(e, document.querySelectorAll("iframe"));
|
|
2947
3085
|
} else if (data.type === "pd-width" && typeof data.width === "number" && typeof data.at === "number") {
|
|
2948
3086
|
const { width, at } = data;
|
|
2949
3087
|
const scroll = typeof data.scroll === "number" ? data.scroll : at;
|