@21stware/rpui 0.4.4 → 0.5.4

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/rpui.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import { registerAll } from './registry';
2
2
  import { parseToPage, rewriteTags } from 'rpml-parser';
3
- export { registerAll, parseToPage, rewriteTags };
3
+ import { liveRender } from './core/live-render';
4
+ export { registerAll, parseToPage, rewriteTags, liveRender };
package/dist/rpui.js CHANGED
@@ -99584,8 +99584,33 @@ function registerAll() {
99584
99584
  define(toComponentTag(suffix), ctor);
99585
99585
  }
99586
99586
  }
99587
+ function liveRender(host, source, opts = {}) {
99588
+ const { scroller, preserve = true, onError } = opts;
99589
+ const sc = scroller ?? document.scrollingElement ?? document.documentElement;
99590
+ const pane = preserve ? host.querySelector(".annotation-el-pane") : null;
99591
+ 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;
99592
+ try {
99593
+ host.replaceChildren(parseToPage(source));
99594
+ onError == null ? void 0 : onError(null);
99595
+ } catch (e) {
99596
+ onError == null ? void 0 : onError(e.message ?? String(e));
99597
+ return;
99598
+ }
99599
+ if (pos) {
99600
+ requestAnimationFrame(() => requestAnimationFrame(() => {
99601
+ sc.scrollLeft = pos.x;
99602
+ sc.scrollTop = pos.y;
99603
+ const newPane = host.querySelector(".annotation-el-pane");
99604
+ if (newPane) {
99605
+ newPane.scrollLeft = pos.px;
99606
+ newPane.scrollTop = pos.py;
99607
+ }
99608
+ }));
99609
+ }
99610
+ }
99587
99611
  registerAll();
99588
99612
  export {
99613
+ liveRender,
99589
99614
  parseToPage,
99590
99615
  registerAll,
99591
99616
  rewriteTags