@21stware/rpui 0.4.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 +11 -0
- package/dist/gallery.d.ts +5 -1
- package/dist/gallery.js +176 -77
- package/dist/gallery.js.map +1 -1
- package/dist/rpui.d.ts +3 -1
- package/dist/rpui.js +63 -3
- package/dist/rpui.js.map +1 -1
- package/dist/serve.js +48 -8
- package/package.json +6 -4
package/dist/rpui.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { registerAll } from './registry';
|
|
2
2
|
import { parseToPage, rewriteTags } from 'rpml-parser';
|
|
3
|
-
|
|
3
|
+
import { liveRender, createDocRenderer } from './core/live-render';
|
|
4
|
+
export { registerAll, parseToPage, rewriteTags, liveRender, createDocRenderer };
|
|
5
|
+
export type { LiveRenderOpts, DocRenderer } from './core/live-render';
|
package/dist/rpui.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 {
|
|
@@ -99584,8 +99605,47 @@ function registerAll() {
|
|
|
99584
99605
|
define(toComponentTag(suffix), ctor);
|
|
99585
99606
|
}
|
|
99586
99607
|
}
|
|
99608
|
+
function createDocRenderer(host, opts = {}) {
|
|
99609
|
+
let initialized = false;
|
|
99610
|
+
return {
|
|
99611
|
+
render(source) {
|
|
99612
|
+
liveRender(host, source, { ...opts, preserve: initialized });
|
|
99613
|
+
initialized = true;
|
|
99614
|
+
},
|
|
99615
|
+
destroy() {
|
|
99616
|
+
host.replaceChildren();
|
|
99617
|
+
initialized = false;
|
|
99618
|
+
}
|
|
99619
|
+
};
|
|
99620
|
+
}
|
|
99621
|
+
function liveRender(host, source, opts = {}) {
|
|
99622
|
+
const { scroller, preserve = true, onError } = opts;
|
|
99623
|
+
const sc = scroller ?? document.scrollingElement ?? document.documentElement;
|
|
99624
|
+
const pane = preserve ? host.querySelector(".annotation-el-pane") : null;
|
|
99625
|
+
const pos = preserve ? { x: sc.scrollLeft, y: sc.scrollTop, px: (pane == null ? void 0 : pane.scrollLeft) ?? 0, py: (pane == null ? void 0 : pane.scrollTop) ?? 0 } : null;
|
|
99626
|
+
try {
|
|
99627
|
+
host.replaceChildren(parseToPage(source));
|
|
99628
|
+
onError == null ? void 0 : onError(null);
|
|
99629
|
+
} catch (e) {
|
|
99630
|
+
onError == null ? void 0 : onError(e.message ?? String(e));
|
|
99631
|
+
return;
|
|
99632
|
+
}
|
|
99633
|
+
if (pos) {
|
|
99634
|
+
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
99635
|
+
sc.scrollLeft = pos.x;
|
|
99636
|
+
sc.scrollTop = pos.y;
|
|
99637
|
+
const newPane = host.querySelector(".annotation-el-pane");
|
|
99638
|
+
if (newPane) {
|
|
99639
|
+
newPane.scrollLeft = pos.px;
|
|
99640
|
+
newPane.scrollTop = pos.py;
|
|
99641
|
+
}
|
|
99642
|
+
}));
|
|
99643
|
+
}
|
|
99644
|
+
}
|
|
99587
99645
|
registerAll();
|
|
99588
99646
|
export {
|
|
99647
|
+
createDocRenderer,
|
|
99648
|
+
liveRender,
|
|
99589
99649
|
parseToPage,
|
|
99590
99650
|
registerAll,
|
|
99591
99651
|
rewriteTags
|