@21stware/rpui 0.5.4 → 0.5.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/canvas/page.d.ts +3 -0
- package/dist/core/live-render.d.ts +5 -0
- package/dist/gallery.d.ts +1 -0
- package/dist/gallery.js +43 -11
- package/dist/gallery.js.map +1 -1
- package/dist/rpui.d.ts +3 -2
- package/dist/rpui.js +38 -3
- package/dist/rpui.js.map +1 -1
- package/package.json +5 -1
package/dist/canvas/page.d.ts
CHANGED
|
@@ -3,4 +3,9 @@ export interface LiveRenderOpts {
|
|
|
3
3
|
preserve?: boolean;
|
|
4
4
|
onError?: (msg: string | null) => void;
|
|
5
5
|
}
|
|
6
|
+
export interface DocRenderer {
|
|
7
|
+
render(source: string): void;
|
|
8
|
+
destroy(): void;
|
|
9
|
+
}
|
|
10
|
+
export declare function createDocRenderer(host: HTMLElement, opts?: Pick<LiveRenderOpts, 'scroller' | 'onError'>): DocRenderer;
|
|
6
11
|
export declare function liveRender(host: HTMLElement, source: string, opts?: LiveRenderOpts): void;
|
package/dist/gallery.d.ts
CHANGED
package/dist/gallery.js
CHANGED
|
@@ -1031,8 +1031,13 @@ function activateSection(path, pane) {
|
|
|
1031
1031
|
setTimeout(() => target.classList.remove("rp-section-focus"), 3e3);
|
|
1032
1032
|
}
|
|
1033
1033
|
class RpPage extends HTMLElement {
|
|
1034
|
+
constructor() {
|
|
1035
|
+
super(...arguments);
|
|
1036
|
+
__publicField(this, "_handlers");
|
|
1037
|
+
}
|
|
1034
1038
|
connectedCallback() {
|
|
1035
1039
|
injectStyle();
|
|
1040
|
+
this.wireRouting();
|
|
1036
1041
|
if (this.dataset.rpReady) return;
|
|
1037
1042
|
this.dataset.rpReady = "true";
|
|
1038
1043
|
const pageTitle = attr(this, "title", "Untitled");
|
|
@@ -1069,13 +1074,29 @@ class RpPage extends HTMLElement {
|
|
|
1069
1074
|
const mv = body.querySelector("main-view, main-view");
|
|
1070
1075
|
if (mv) header.style.maxWidth = `${mv.offsetWidth}px`;
|
|
1071
1076
|
});
|
|
1077
|
+
this.wireRouting();
|
|
1078
|
+
requestAnimationFrame(this._handlers[0]);
|
|
1079
|
+
}
|
|
1080
|
+
/** Section routing: handle URL and rp-section events. Re-queries the pane
|
|
1081
|
+
* lazily so listeners don't capture build-scope DOM (survives reconnect). */
|
|
1082
|
+
wireRouting() {
|
|
1083
|
+
if (this._handlers) return;
|
|
1084
|
+
const pane = () => this.querySelector(".annotation-el-pane");
|
|
1072
1085
|
const go = () => {
|
|
1073
1086
|
const sec = new URLSearchParams(location.search).get("section");
|
|
1074
|
-
if (sec) activateSection(sec, pane);
|
|
1087
|
+
if (sec) activateSection(sec, pane());
|
|
1075
1088
|
};
|
|
1089
|
+
const onSection = (e) => activateSection(e.detail, pane());
|
|
1090
|
+
this._handlers = [go, onSection];
|
|
1076
1091
|
window.addEventListener("popstate", go);
|
|
1077
|
-
window.addEventListener("rp-section",
|
|
1078
|
-
|
|
1092
|
+
window.addEventListener("rp-section", onSection);
|
|
1093
|
+
}
|
|
1094
|
+
disconnectedCallback() {
|
|
1095
|
+
if (this._handlers) {
|
|
1096
|
+
window.removeEventListener("popstate", this._handlers[0]);
|
|
1097
|
+
window.removeEventListener("rp-section", this._handlers[1]);
|
|
1098
|
+
this._handlers = void 0;
|
|
1099
|
+
}
|
|
1079
1100
|
}
|
|
1080
1101
|
}
|
|
1081
1102
|
class GenericElement extends HTMLElement {
|
|
@@ -99608,7 +99629,6 @@ function liveRender(host, source, opts = {}) {
|
|
|
99608
99629
|
}));
|
|
99609
99630
|
}
|
|
99610
99631
|
}
|
|
99611
|
-
registerAll();
|
|
99612
99632
|
const THEME_STYLE_ID = "rpml-theme-style";
|
|
99613
99633
|
const ATTR = "data-rpml-theme";
|
|
99614
99634
|
const THEME_CSS = `
|
|
@@ -99840,14 +99860,17 @@ function mountGallery(docs, host = document.body) {
|
|
|
99840
99860
|
const path = decodeURIComponent(location.hash.slice(1)) || pickDefault();
|
|
99841
99861
|
show(path);
|
|
99842
99862
|
}
|
|
99843
|
-
|
|
99863
|
+
const onAnchor = (e) => {
|
|
99844
99864
|
const { to, section } = e.detail;
|
|
99845
99865
|
const target = resolveAnchorTarget(to, currentPath, new Set(byPath.keys()));
|
|
99846
99866
|
if (!target) return;
|
|
99847
99867
|
e.preventDefault();
|
|
99848
99868
|
history.pushState(null, "", `#${target}`);
|
|
99849
99869
|
show(target, section);
|
|
99850
|
-
}
|
|
99870
|
+
};
|
|
99871
|
+
const onPopstate = () => route();
|
|
99872
|
+
window.addEventListener("rp-anchor", onAnchor);
|
|
99873
|
+
window.addEventListener("popstate", onPopstate);
|
|
99851
99874
|
nav.addEventListener("click", (e) => {
|
|
99852
99875
|
var _a2;
|
|
99853
99876
|
const el = e.target;
|
|
@@ -99873,7 +99896,6 @@ function mountGallery(docs, host = document.body) {
|
|
|
99873
99896
|
history.pushState(null, "", a.hash);
|
|
99874
99897
|
show(path);
|
|
99875
99898
|
});
|
|
99876
|
-
window.addEventListener("popstate", route);
|
|
99877
99899
|
route();
|
|
99878
99900
|
const controller = {
|
|
99879
99901
|
update(newDocs) {
|
|
@@ -99892,6 +99914,13 @@ function mountGallery(docs, host = document.body) {
|
|
|
99892
99914
|
history.replaceState(null, "", `#${def}`);
|
|
99893
99915
|
show(def);
|
|
99894
99916
|
}
|
|
99917
|
+
},
|
|
99918
|
+
destroy() {
|
|
99919
|
+
window.removeEventListener("rp-anchor", onAnchor);
|
|
99920
|
+
window.removeEventListener("popstate", onPopstate);
|
|
99921
|
+
host.innerHTML = "";
|
|
99922
|
+
const g = globalThis;
|
|
99923
|
+
if (g.__RPML_GALLERY__ === controller) delete g.__RPML_GALLERY__;
|
|
99895
99924
|
}
|
|
99896
99925
|
};
|
|
99897
99926
|
globalThis.__RPML_GALLERY__ = controller;
|
|
@@ -99900,17 +99929,20 @@ function mountGallery(docs, host = document.body) {
|
|
|
99900
99929
|
const inlined = globalThis.__RPML_DOCS__;
|
|
99901
99930
|
if (inlined && Array.isArray(inlined) && inlined.length) {
|
|
99902
99931
|
const mount = () => {
|
|
99903
|
-
mountGallery(inlined);
|
|
99932
|
+
const gallery = mountGallery(inlined);
|
|
99904
99933
|
if (globalThis.__RPML_LIVE__) {
|
|
99905
99934
|
const es = new EventSource("/~live");
|
|
99906
99935
|
es.onmessage = (ev) => {
|
|
99907
|
-
var _a2;
|
|
99908
99936
|
try {
|
|
99909
|
-
|
|
99910
|
-
(_a2 = globalThis.__RPML_GALLERY__) == null ? void 0 : _a2.update(docs);
|
|
99937
|
+
gallery.update(JSON.parse(ev.data));
|
|
99911
99938
|
} catch {
|
|
99912
99939
|
}
|
|
99913
99940
|
};
|
|
99941
|
+
const origDestroy = gallery.destroy.bind(gallery);
|
|
99942
|
+
gallery.destroy = () => {
|
|
99943
|
+
es.close();
|
|
99944
|
+
origDestroy();
|
|
99945
|
+
};
|
|
99914
99946
|
}
|
|
99915
99947
|
};
|
|
99916
99948
|
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", mount);
|