pattern-dump 0.1.0-alpha.1 → 0.1.0-alpha.2
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 +6 -1
- package/README.md +1 -1
- package/dist/dev-ui/main.js +61 -11
- package/dist/pd.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.1.0-alpha.
|
|
3
|
+
## 0.1.0-alpha.2
|
|
4
4
|
|
|
5
5
|
Fixes found while moving a PatternLab styleguide to Pattern Dump, and the changes they needed.
|
|
6
6
|
|
|
@@ -39,6 +39,11 @@ These can change how an existing project loads or renders:
|
|
|
39
39
|
|
|
40
40
|
### Fixed
|
|
41
41
|
|
|
42
|
+
- A `centered` preview whose height comes from the viewport (`height: 200vh` in the base layer, a
|
|
43
|
+
percentage chain) no longer grows without bound. Content-fitting such a height is circular — the
|
|
44
|
+
frame's height feeds the content's — and the frame used to double every tick to the browser's
|
|
45
|
+
layout ceiling, showing a size like `785 × 33554428`. The run of growth is now detected, the frame
|
|
46
|
+
keeps its last steady height and the content scrolls inside it, and the Console says why.
|
|
42
47
|
- SCSS edits reach the preview live when `styles.entry` is set, and edits to base-layer styles
|
|
43
48
|
update live too.
|
|
44
49
|
- `@import`, `@charset`, `@layer a, b` and `@namespace` kept their `;`: the next rule was being
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A workbench for HTML and CSS design systems, and a successor to PatternLab. Writ
|
|
|
4
4
|
Handlebars templates with SCSS, data and Markdown docs; Pattern Dump shows them live, checks them, maps
|
|
5
5
|
how they relate, and publishes the result as a static site.
|
|
6
6
|
|
|
7
|
-
> **Alpha (0.1.0-alpha.
|
|
7
|
+
> **Alpha (0.1.0-alpha.2).** Published under the `alpha` tag. Options and file conventions can still change
|
|
8
8
|
> between releases.
|
|
9
9
|
|
|
10
10
|
## Requirements
|
package/dist/dev-ui/main.js
CHANGED
|
@@ -380,9 +380,9 @@ function createStore() {
|
|
|
380
380
|
function notify() {
|
|
381
381
|
for (const fn of listeners) fn();
|
|
382
382
|
}
|
|
383
|
-
function persist(
|
|
383
|
+
function persist(state2) {
|
|
384
384
|
try {
|
|
385
|
-
localStorage.setItem(STORAGE_KEY, toJSON(
|
|
385
|
+
localStorage.setItem(STORAGE_KEY, toJSON(state2));
|
|
386
386
|
} catch {
|
|
387
387
|
}
|
|
388
388
|
}
|
|
@@ -1728,6 +1728,48 @@ function setVpProp(el2, prop, value) {
|
|
|
1728
1728
|
}
|
|
1729
1729
|
}
|
|
1730
1730
|
|
|
1731
|
+
// 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
|
+
var report = null;
|
|
1737
|
+
function isCircularGrowth(previous, measured) {
|
|
1738
|
+
if (previous === void 0) return false;
|
|
1739
|
+
return measured > previous.last * GROWTH_FACTOR && previous.run + 1 >= GROWTH_RUN;
|
|
1740
|
+
}
|
|
1741
|
+
function fitsHeight(frame) {
|
|
1742
|
+
return frame.closest('[data-layout="full"]') === null;
|
|
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);
|
|
1750
|
+
frame.dataset.pdHeight = "circular";
|
|
1751
|
+
setVpProp(frame, "--vp-h", previous.steady);
|
|
1752
|
+
report?.(frame);
|
|
1753
|
+
return true;
|
|
1754
|
+
}
|
|
1755
|
+
const grew = previous !== void 0 && height > previous.last * GROWTH_FACTOR;
|
|
1756
|
+
state.set(frame, {
|
|
1757
|
+
last: height,
|
|
1758
|
+
steady: grew ? previous.steady : height,
|
|
1759
|
+
run: grew ? previous.run + 1 : 0
|
|
1760
|
+
});
|
|
1761
|
+
setVpProp(frame, "--vp-h", height);
|
|
1762
|
+
return true;
|
|
1763
|
+
}
|
|
1764
|
+
function resetContentHeight(frame) {
|
|
1765
|
+
state.delete(frame);
|
|
1766
|
+
circular.delete(frame);
|
|
1767
|
+
delete frame.dataset.pdHeight;
|
|
1768
|
+
}
|
|
1769
|
+
function initContentHeight(onCircular) {
|
|
1770
|
+
report = onCircular;
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1731
1773
|
// src/stage/content-width.ts
|
|
1732
1774
|
var measuring = /* @__PURE__ */ new WeakMap();
|
|
1733
1775
|
var fitted = /* @__PURE__ */ new WeakMap();
|
|
@@ -1819,10 +1861,10 @@ function setWidthNow(frame, width) {
|
|
|
1819
1861
|
function acceptContentWidth(frame, width, at, scroll) {
|
|
1820
1862
|
const full = measuring.get(frame);
|
|
1821
1863
|
if (full === void 0) {
|
|
1822
|
-
const
|
|
1823
|
-
if (
|
|
1864
|
+
const state2 = fitted.get(frame);
|
|
1865
|
+
if (state2 === void 0 || scroll <= at + 1) return false;
|
|
1824
1866
|
const parentWidth = frame.parentElement?.clientWidth ?? Infinity;
|
|
1825
|
-
if (
|
|
1867
|
+
if (state2 === "measured" && scroll < parentWidth) {
|
|
1826
1868
|
fitted.set(frame, "widened");
|
|
1827
1869
|
setWidthNow(frame, scroll);
|
|
1828
1870
|
} else {
|
|
@@ -2053,6 +2095,7 @@ function initViewport(onFullscreen) {
|
|
|
2053
2095
|
iframeObserver.observe(dom.iframe);
|
|
2054
2096
|
iframeObserver.observe(dom.stageView);
|
|
2055
2097
|
dom.iframe.addEventListener("load", () => {
|
|
2098
|
+
resetContentHeight(dom.iframe);
|
|
2056
2099
|
measureContentWidth(dom.iframe);
|
|
2057
2100
|
updateReadout();
|
|
2058
2101
|
syncFrameFocusListeners();
|
|
@@ -2326,6 +2369,7 @@ async function buildVariantsGallery() {
|
|
|
2326
2369
|
f.addEventListener("load", () => {
|
|
2327
2370
|
if (store.local.theme) applyThemeToIframe(f, store.local.theme);
|
|
2328
2371
|
const h = f.contentDocument?.documentElement?.scrollHeight;
|
|
2372
|
+
resetContentHeight(f);
|
|
2329
2373
|
if (typeof h === "number" && h > 0) f.style.setProperty("--vp-h", `${h}px`);
|
|
2330
2374
|
measureContentWidth(f);
|
|
2331
2375
|
});
|
|
@@ -2367,6 +2411,7 @@ function renderOverview(overview) {
|
|
|
2367
2411
|
f.addEventListener("load", () => {
|
|
2368
2412
|
if (store.local.theme) applyThemeToIframe(f, store.local.theme);
|
|
2369
2413
|
const h = f.contentDocument?.documentElement?.scrollHeight;
|
|
2414
|
+
resetContentHeight(f);
|
|
2370
2415
|
if (typeof h === "number" && h > 0) f.style.setProperty("--vp-h", `${h}px`);
|
|
2371
2416
|
measureContentWidth(f);
|
|
2372
2417
|
});
|
|
@@ -2748,7 +2793,10 @@ function connectHmr() {
|
|
|
2748
2793
|
if (link) link.href = href;
|
|
2749
2794
|
});
|
|
2750
2795
|
}
|
|
2751
|
-
void pdLinksLoaded().then(
|
|
2796
|
+
void pdLinksLoaded().then(() => {
|
|
2797
|
+
document.querySelectorAll("#preview-frame, .gallery-item iframe").forEach(resetContentHeight);
|
|
2798
|
+
remeasureAll();
|
|
2799
|
+
});
|
|
2752
2800
|
if (store.local.panelTab === "relationships" && session.current) {
|
|
2753
2801
|
void fetch(componentUrl(session.current.id)).then((r) => r.ok ? r.json() : Promise.reject(r.status)).then((d) => {
|
|
2754
2802
|
session.current = d;
|
|
@@ -2892,11 +2940,9 @@ function listenForPreviewMessages() {
|
|
|
2892
2940
|
if (data.type === "pd-height" && typeof data.height === "number") {
|
|
2893
2941
|
const height = data.height;
|
|
2894
2942
|
document.querySelectorAll("iframe").forEach((f) => {
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
setVpProp(el2, "--vp-h", height);
|
|
2899
|
-
}
|
|
2943
|
+
const frame = f;
|
|
2944
|
+
if (frame.contentWindow !== e.source) return;
|
|
2945
|
+
acceptContentHeight(frame, height);
|
|
2900
2946
|
});
|
|
2901
2947
|
} else if (data.type === "pd-width" && typeof data.width === "number" && typeof data.at === "number") {
|
|
2902
2948
|
const { width, at } = data;
|
|
@@ -2948,6 +2994,10 @@ function mount() {
|
|
|
2948
2994
|
initDom(app);
|
|
2949
2995
|
listenForPreviewMessages();
|
|
2950
2996
|
initContentWidth();
|
|
2997
|
+
initContentHeight((frame) => {
|
|
2998
|
+
const id = frame.contentDocument?.body?.dataset.componentId ?? session.current?.id ?? "preview";
|
|
2999
|
+
renderConsole(`${id}: height depends on the preview's own height (a viewport-relative rule such as height: 100vh), so the frame keeps its last steady height and the content scrolls inside it.`);
|
|
3000
|
+
});
|
|
2951
3001
|
dom.searchInput.addEventListener("input", () => {
|
|
2952
3002
|
session.searchQuery = dom.searchInput.value;
|
|
2953
3003
|
filterTree(session.searchQuery);
|
package/dist/pd.js
CHANGED
|
@@ -4616,7 +4616,7 @@ import { basename as basename6, dirname as dirname9, join as join23, relative as
|
|
|
4616
4616
|
// packages/cli/package.json
|
|
4617
4617
|
var package_default = {
|
|
4618
4618
|
name: "@pattern-dump/cli",
|
|
4619
|
-
version: "0.1.0-alpha.
|
|
4619
|
+
version: "0.1.0-alpha.2",
|
|
4620
4620
|
private: true,
|
|
4621
4621
|
description: "The pd command and the published pattern-dump package.",
|
|
4622
4622
|
type: "module",
|
package/package.json
CHANGED