@redneckz/wildless-cms-uni-blocks 0.14.76 → 0.14.78

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.
Files changed (134) hide show
  1. package/bin/migration-scripts/0.14.68.js +1 -1
  2. package/bundle/bundle.umd.js +27 -97
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/dist/components/BonusBenefitsBlock/renderBonusBenefit.js +1 -1
  5. package/dist/components/BonusBenefitsBlock/renderBonusBenefit.js.map +1 -1
  6. package/dist/components/ContentPage/ContentPage.js +0 -2
  7. package/dist/components/ContentPage/ContentPage.js.map +1 -1
  8. package/dist/ui-kit/BlockWrapper.js +1 -3
  9. package/dist/ui-kit/BlockWrapper.js.map +1 -1
  10. package/lib/components/BonusBenefitsBlock/renderBonusBenefit.js +1 -1
  11. package/lib/components/BonusBenefitsBlock/renderBonusBenefit.js.map +1 -1
  12. package/lib/components/ContentPage/ContentPage.js +0 -2
  13. package/lib/components/ContentPage/ContentPage.js.map +1 -1
  14. package/lib/ui-kit/BlockWrapper.js +1 -3
  15. package/lib/ui-kit/BlockWrapper.js.map +1 -1
  16. package/mobile/bundle/bundle.umd.js +27 -97
  17. package/mobile/bundle/bundle.umd.min.js +1 -1
  18. package/mobile/dist/components/BonusBenefitsBlock/renderBonusBenefit.js +1 -1
  19. package/mobile/dist/components/BonusBenefitsBlock/renderBonusBenefit.js.map +1 -1
  20. package/mobile/dist/components/ContentPage/ContentPage.js +0 -2
  21. package/mobile/dist/components/ContentPage/ContentPage.js.map +1 -1
  22. package/mobile/dist/ui-kit/BlockWrapper.js +1 -3
  23. package/mobile/dist/ui-kit/BlockWrapper.js.map +1 -1
  24. package/mobile/lib/common.css +1 -1
  25. package/mobile/lib/components/BonusBenefitsBlock/renderBonusBenefit.js +1 -1
  26. package/mobile/lib/components/BonusBenefitsBlock/renderBonusBenefit.js.map +1 -1
  27. package/mobile/lib/components/ContentPage/ContentPage.js +0 -2
  28. package/mobile/lib/components/ContentPage/ContentPage.js.map +1 -1
  29. package/mobile/lib/ui-kit/BlockWrapper.js +1 -3
  30. package/mobile/lib/ui-kit/BlockWrapper.js.map +1 -1
  31. package/mobile/src/components/BonusBenefitsBlock/renderBonusBenefit.tsx +1 -1
  32. package/mobile/src/components/ContentPage/ContentPage.tsx +0 -3
  33. package/mobile/src/ui-kit/BlockWrapper.tsx +2 -4
  34. package/package.json +1 -1
  35. package/src/components/BenefitsBlock/BenefitsBlock.fixture.tsx +3 -3
  36. package/src/components/BonusBenefitsBlock/renderBonusBenefit.tsx +1 -1
  37. package/src/components/ContentPage/ContentPage.tsx +0 -3
  38. package/src/ui-kit/BlockWrapper.tsx +2 -4
  39. package/bundle/services/BlockRouter/BlockIntersection.d.ts +0 -2
  40. package/bundle/services/BlockRouter/BlockRouter.d.ts +0 -2
  41. package/bundle/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
  42. package/bundle/services/BlockRouter/findActiveBlock.d.ts +0 -3
  43. package/bundle/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
  44. package/bundle/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
  45. package/dist/services/BlockRouter/BlockIntersection.d.ts +0 -2
  46. package/dist/services/BlockRouter/BlockIntersection.js +0 -2
  47. package/dist/services/BlockRouter/BlockIntersection.js.map +0 -1
  48. package/dist/services/BlockRouter/BlockRouter.d.ts +0 -2
  49. package/dist/services/BlockRouter/BlockRouter.js +0 -11
  50. package/dist/services/BlockRouter/BlockRouter.js.map +0 -1
  51. package/dist/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
  52. package/dist/services/BlockRouter/blockRouterEventBus.js +0 -5
  53. package/dist/services/BlockRouter/blockRouterEventBus.js.map +0 -1
  54. package/dist/services/BlockRouter/findActiveBlock.d.ts +0 -3
  55. package/dist/services/BlockRouter/findActiveBlock.js +0 -15
  56. package/dist/services/BlockRouter/findActiveBlock.js.map +0 -1
  57. package/dist/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
  58. package/dist/services/BlockRouter/useBlockIntersectionObserver.js +0 -17
  59. package/dist/services/BlockRouter/useBlockIntersectionObserver.js.map +0 -1
  60. package/dist/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
  61. package/dist/services/BlockRouter/useBlockRouterProvider.js +0 -28
  62. package/dist/services/BlockRouter/useBlockRouterProvider.js.map +0 -1
  63. package/lib/services/BlockRouter/BlockIntersection.d.ts +0 -2
  64. package/lib/services/BlockRouter/BlockIntersection.js +0 -2
  65. package/lib/services/BlockRouter/BlockIntersection.js.map +0 -1
  66. package/lib/services/BlockRouter/BlockRouter.d.ts +0 -2
  67. package/lib/services/BlockRouter/BlockRouter.js +0 -8
  68. package/lib/services/BlockRouter/BlockRouter.js.map +0 -1
  69. package/lib/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
  70. package/lib/services/BlockRouter/blockRouterEventBus.js +0 -3
  71. package/lib/services/BlockRouter/blockRouterEventBus.js.map +0 -1
  72. package/lib/services/BlockRouter/findActiveBlock.d.ts +0 -3
  73. package/lib/services/BlockRouter/findActiveBlock.js +0 -12
  74. package/lib/services/BlockRouter/findActiveBlock.js.map +0 -1
  75. package/lib/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
  76. package/lib/services/BlockRouter/useBlockIntersectionObserver.js +0 -14
  77. package/lib/services/BlockRouter/useBlockIntersectionObserver.js.map +0 -1
  78. package/lib/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
  79. package/lib/services/BlockRouter/useBlockRouterProvider.js +0 -25
  80. package/lib/services/BlockRouter/useBlockRouterProvider.js.map +0 -1
  81. package/mobile/bundle/services/BlockRouter/BlockIntersection.d.ts +0 -2
  82. package/mobile/bundle/services/BlockRouter/BlockRouter.d.ts +0 -2
  83. package/mobile/bundle/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
  84. package/mobile/bundle/services/BlockRouter/findActiveBlock.d.ts +0 -3
  85. package/mobile/bundle/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
  86. package/mobile/bundle/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
  87. package/mobile/dist/services/BlockRouter/BlockIntersection.d.ts +0 -2
  88. package/mobile/dist/services/BlockRouter/BlockIntersection.js +0 -2
  89. package/mobile/dist/services/BlockRouter/BlockIntersection.js.map +0 -1
  90. package/mobile/dist/services/BlockRouter/BlockRouter.d.ts +0 -2
  91. package/mobile/dist/services/BlockRouter/BlockRouter.js +0 -11
  92. package/mobile/dist/services/BlockRouter/BlockRouter.js.map +0 -1
  93. package/mobile/dist/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
  94. package/mobile/dist/services/BlockRouter/blockRouterEventBus.js +0 -5
  95. package/mobile/dist/services/BlockRouter/blockRouterEventBus.js.map +0 -1
  96. package/mobile/dist/services/BlockRouter/findActiveBlock.d.ts +0 -3
  97. package/mobile/dist/services/BlockRouter/findActiveBlock.js +0 -15
  98. package/mobile/dist/services/BlockRouter/findActiveBlock.js.map +0 -1
  99. package/mobile/dist/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
  100. package/mobile/dist/services/BlockRouter/useBlockIntersectionObserver.js +0 -17
  101. package/mobile/dist/services/BlockRouter/useBlockIntersectionObserver.js.map +0 -1
  102. package/mobile/dist/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
  103. package/mobile/dist/services/BlockRouter/useBlockRouterProvider.js +0 -28
  104. package/mobile/dist/services/BlockRouter/useBlockRouterProvider.js.map +0 -1
  105. package/mobile/lib/services/BlockRouter/BlockIntersection.d.ts +0 -2
  106. package/mobile/lib/services/BlockRouter/BlockIntersection.js +0 -2
  107. package/mobile/lib/services/BlockRouter/BlockIntersection.js.map +0 -1
  108. package/mobile/lib/services/BlockRouter/BlockRouter.d.ts +0 -2
  109. package/mobile/lib/services/BlockRouter/BlockRouter.js +0 -8
  110. package/mobile/lib/services/BlockRouter/BlockRouter.js.map +0 -1
  111. package/mobile/lib/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
  112. package/mobile/lib/services/BlockRouter/blockRouterEventBus.js +0 -3
  113. package/mobile/lib/services/BlockRouter/blockRouterEventBus.js.map +0 -1
  114. package/mobile/lib/services/BlockRouter/findActiveBlock.d.ts +0 -3
  115. package/mobile/lib/services/BlockRouter/findActiveBlock.js +0 -12
  116. package/mobile/lib/services/BlockRouter/findActiveBlock.js.map +0 -1
  117. package/mobile/lib/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
  118. package/mobile/lib/services/BlockRouter/useBlockIntersectionObserver.js +0 -14
  119. package/mobile/lib/services/BlockRouter/useBlockIntersectionObserver.js.map +0 -1
  120. package/mobile/lib/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
  121. package/mobile/lib/services/BlockRouter/useBlockRouterProvider.js +0 -25
  122. package/mobile/lib/services/BlockRouter/useBlockRouterProvider.js.map +0 -1
  123. package/mobile/src/services/BlockRouter/BlockIntersection.ts +0 -3
  124. package/mobile/src/services/BlockRouter/BlockRouter.ts +0 -11
  125. package/mobile/src/services/BlockRouter/blockRouterEventBus.ts +0 -13
  126. package/mobile/src/services/BlockRouter/findActiveBlock.ts +0 -20
  127. package/mobile/src/services/BlockRouter/useBlockIntersectionObserver.ts +0 -20
  128. package/mobile/src/services/BlockRouter/useBlockRouterProvider.ts +0 -37
  129. package/src/services/BlockRouter/BlockIntersection.ts +0 -3
  130. package/src/services/BlockRouter/BlockRouter.ts +0 -11
  131. package/src/services/BlockRouter/blockRouterEventBus.ts +0 -13
  132. package/src/services/BlockRouter/findActiveBlock.ts +0 -20
  133. package/src/services/BlockRouter/useBlockIntersectionObserver.ts +0 -20
  134. package/src/services/BlockRouter/useBlockRouterProvider.ts +0 -37
@@ -1,11 +0,0 @@
1
- import { EventBus } from '../../EventBus/EventBus';
2
- import { type BlockDef } from '../../model/ContentPageDef';
3
- export interface BlockIntersectionEvent {
4
- block: BlockDef;
5
- intersection: IntersectionObserverEntry;
6
- }
7
- interface EventMap {
8
- intersection: BlockIntersectionEvent;
9
- }
10
- export declare const blockRouterEventBus: EventBus<EventMap>;
11
- export {};
@@ -1,5 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.blockRouterEventBus = void 0;
3
- const EventBus_1 = require("../../EventBus/EventBus");
4
- exports.blockRouterEventBus = new EventBus_1.EventBus();
5
- //# sourceMappingURL=blockRouterEventBus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"blockRouterEventBus.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/blockRouterEventBus.ts"],"names":[],"mappings":";;AAAA,sDAAmD;AAYtC,QAAA,mBAAmB,GAAG,IAAI,mBAAQ,EAAY,CAAC"}
@@ -1,3 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- import { type BlockIntersection } from './BlockIntersection';
3
- export declare function findActiveBlock(intersections: BlockIntersection[]): BlockDef | undefined;
@@ -1,15 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.findActiveBlock = void 0;
3
- const minBy_1 = require("../../utils/minBy");
4
- const SPECIAL_BLOCK_TYPES = ['Header', 'Footer'];
5
- const EPS = 0.01;
6
- const topLineDelta = ([, { target }]) => Math.abs(target.getBoundingClientRect().top);
7
- function findActiveBlock(intersections) {
8
- const visibleIntersections = intersections
9
- .filter(([block]) => !SPECIAL_BLOCK_TYPES.includes(block.type || ''))
10
- .filter(([, { intersectionRatio }]) => intersectionRatio > EPS);
11
- const [activeBlock] = visibleIntersections.length > 0 ? (0, minBy_1.minBy)(topLineDelta)(visibleIntersections) : [];
12
- return activeBlock;
13
- }
14
- exports.findActiveBlock = findActiveBlock;
15
- //# sourceMappingURL=findActiveBlock.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findActiveBlock.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/findActiveBlock.ts"],"names":[],"mappings":";;AACA,6CAA0C;AAG1C,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACjD,MAAM,GAAG,GAAG,IAAI,CAAC;AAEjB,MAAM,YAAY,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,CAAoB,EAAE,EAAE,CACzD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC,GAAG,CAAC,CAAC;AAE/C,SAAgB,eAAe,CAAC,aAAkC;IAChE,MAAM,oBAAoB,GAAG,aAAa;SACvC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;SACpE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,iBAAiB,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,GAAG,GAAG,CAAC,CAAC;IAElE,MAAM,CAAC,WAAW,CAAC,GACjB,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,aAAK,EAAC,YAAY,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEnF,OAAO,WAAW,CAAC;AACrB,CAAC;AATD,0CASC"}
@@ -1,4 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- export declare function useBlockIntersectionObserver(block?: BlockDef): {
3
- current: Element | null;
4
- };
@@ -1,17 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.useBlockIntersectionObserver = void 0;
3
- const hooks_1 = require("@redneckz/uni-jsx/lib/hooks");
4
- const useIntersectionObserver_1 = require("../../hooks/useIntersectionObserver");
5
- const blockRouterEventBus_1 = require("./blockRouterEventBus");
6
- function useBlockIntersectionObserver(block) {
7
- const observerCallback = (0, hooks_1.useCallback)((entries) => {
8
- if (!block || !entries?.length) {
9
- return;
10
- }
11
- const intersection = entries[entries.length - 1];
12
- blockRouterEventBus_1.blockRouterEventBus.fire('intersection', { block, intersection });
13
- }, [block]);
14
- return (0, useIntersectionObserver_1.useIntersectionObserver)(observerCallback, { sensitivity: 1 });
15
- }
16
- exports.useBlockIntersectionObserver = useBlockIntersectionObserver;
17
- //# sourceMappingURL=useBlockIntersectionObserver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useBlockIntersectionObserver.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/useBlockIntersectionObserver.ts"],"names":[],"mappings":";;AAAA,uDAA0D;AAC1D,iFAA8E;AAE9E,+DAA4D;AAE5D,SAAgB,4BAA4B,CAAC,KAAgB;IAC3D,MAAM,gBAAgB,GAAG,IAAA,mBAAW,EAClC,CAAC,OAAoC,EAAE,EAAE;QACvC,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE;YAC9B,OAAO;SACR;QAED,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjD,yCAAmB,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;IACpE,CAAC,EACD,CAAC,KAAK,CAAC,CACR,CAAC;IAEF,OAAO,IAAA,iDAAuB,EAAC,gBAAgB,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC;AACvE,CAAC;AAdD,oEAcC"}
@@ -1 +0,0 @@
1
- export declare function useBlockRouterProvider(scrollTarget?: EventTarget): void;
@@ -1,28 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.useBlockRouterProvider = void 0;
3
- const hooks_1 = require("@redneckz/uni-jsx/lib/hooks");
4
- const debounce_1 = require("../../utils/debounce");
5
- const BlockRouter_1 = require("./BlockRouter");
6
- const blockRouterEventBus_1 = require("./blockRouterEventBus");
7
- const findActiveBlock_1 = require("./findActiveBlock");
8
- const isScrolledEnough = () => globalThis.scrollY > (globalThis.innerHeight * 3) / 4;
9
- function useBlockRouterProvider(scrollTarget = globalThis) {
10
- const intersectionsMapRef = (0, hooks_1.useRef)(new Map());
11
- (0, hooks_1.useEffect)(() => blockRouterEventBus_1.blockRouterEventBus.subscribe('intersection', ({ block, intersection }) => {
12
- if (intersectionsMapRef.current) {
13
- intersectionsMapRef.current.set(block, intersection);
14
- }
15
- }), []);
16
- (0, hooks_1.useEffect)(() => {
17
- const handleScroll = (0, debounce_1.debounce)(() => {
18
- (0, BlockRouter_1.trackBlock)(isScrolledEnough() ? (0, findActiveBlock_1.findActiveBlock)([...(intersectionsMapRef.current || [])]) : undefined);
19
- }, 100);
20
- scrollTarget.addEventListener('scroll', handleScroll);
21
- return () => {
22
- handleScroll.dispose();
23
- scrollTarget.removeEventListener('scroll', handleScroll);
24
- };
25
- }, [scrollTarget]);
26
- }
27
- exports.useBlockRouterProvider = useBlockRouterProvider;
28
- //# sourceMappingURL=useBlockRouterProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useBlockRouterProvider.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/useBlockRouterProvider.ts"],"names":[],"mappings":";;AAAA,uDAAgE;AAEhE,mDAAgD;AAChD,+CAA2C;AAC3C,+DAA4D;AAC5D,uDAAoD;AAEpD,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,UAAU,CAAC,WAAW,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAErF,SAAgB,sBAAsB,CAAC,eAA4B,UAAU;IAC3E,MAAM,mBAAmB,GAAG,IAAA,cAAM,EAA2C,IAAI,GAAG,EAAE,CAAC,CAAC;IAExF,IAAA,iBAAS,EACP,GAAG,EAAE,CACH,yCAAmB,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE;QACxE,IAAI,mBAAmB,CAAC,OAAO,EAAE;YAC/B,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;SACtD;IACH,CAAC,CAAC,EACJ,EAAE,CACH,CAAC;IAEF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,IAAA,mBAAQ,EAAC,GAAG,EAAE;YACjC,IAAA,wBAAU,EACR,gBAAgB,EAAE,CAAC,CAAC,CAAC,IAAA,iCAAe,EAAC,CAAC,GAAG,CAAC,mBAAmB,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAC3F,CAAC;QACJ,CAAC,EAAE,GAAG,CAAC,CAAC;QAER,YAAY,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAEtD,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,OAAO,EAAE,CAAC;YACvB,YAAY,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAC3D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;AACrB,CAAC;AA3BD,wDA2BC"}
@@ -1,2 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- export declare type BlockIntersection = [BlockDef, IntersectionObserverEntry];
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=BlockIntersection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BlockIntersection.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/BlockIntersection.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- export declare function trackBlock(block?: BlockDef): void;
@@ -1,8 +0,0 @@
1
- const normalizeAnchor = (anchor) => anchor?.replace('#', '') || '';
2
- export function trackBlock(block) {
3
- const hash = `#${normalizeAnchor(block?.anchor)}`;
4
- if (globalThis.location?.hash !== hash) {
5
- globalThis.history?.replaceState(globalThis.history?.state, '', hash);
6
- }
7
- }
8
- //# sourceMappingURL=BlockRouter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BlockRouter.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/BlockRouter.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAG,CAAC,MAAe,EAAE,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;AAE5E,MAAM,UAAU,UAAU,CAAC,KAAgB;IACzC,MAAM,IAAI,GAAG,IAAI,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC;IAElD,IAAI,UAAU,CAAC,QAAQ,EAAE,IAAI,KAAK,IAAI,EAAE;QACtC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;KACvE;AACH,CAAC"}
@@ -1,11 +0,0 @@
1
- import { EventBus } from '../../EventBus/EventBus';
2
- import { type BlockDef } from '../../model/ContentPageDef';
3
- export interface BlockIntersectionEvent {
4
- block: BlockDef;
5
- intersection: IntersectionObserverEntry;
6
- }
7
- interface EventMap {
8
- intersection: BlockIntersectionEvent;
9
- }
10
- export declare const blockRouterEventBus: EventBus<EventMap>;
11
- export {};
@@ -1,3 +0,0 @@
1
- import { EventBus } from '../../EventBus/EventBus.js';
2
- export const blockRouterEventBus = new EventBus();
3
- //# sourceMappingURL=blockRouterEventBus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"blockRouterEventBus.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/blockRouterEventBus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAYnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,QAAQ,EAAY,CAAC"}
@@ -1,3 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- import { type BlockIntersection } from './BlockIntersection';
3
- export declare function findActiveBlock(intersections: BlockIntersection[]): BlockDef | undefined;
@@ -1,12 +0,0 @@
1
- import { minBy } from '../../utils/minBy.js';
2
- const SPECIAL_BLOCK_TYPES = ['Header', 'Footer'];
3
- const EPS = 0.01;
4
- const topLineDelta = ([, { target }]) => Math.abs(target.getBoundingClientRect().top);
5
- export function findActiveBlock(intersections) {
6
- const visibleIntersections = intersections
7
- .filter(([block]) => !SPECIAL_BLOCK_TYPES.includes(block.type || ''))
8
- .filter(([, { intersectionRatio }]) => intersectionRatio > EPS);
9
- const [activeBlock] = visibleIntersections.length > 0 ? minBy(topLineDelta)(visibleIntersections) : [];
10
- return activeBlock;
11
- }
12
- //# sourceMappingURL=findActiveBlock.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findActiveBlock.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/findActiveBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG1C,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACjD,MAAM,GAAG,GAAG,IAAI,CAAC;AAEjB,MAAM,YAAY,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,CAAoB,EAAE,EAAE,CACzD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,UAAU,eAAe,CAAC,aAAkC;IAChE,MAAM,oBAAoB,GAAG,aAAa;SACvC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;SACpE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,iBAAiB,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,GAAG,GAAG,CAAC,CAAC;IAElE,MAAM,CAAC,WAAW,CAAC,GACjB,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEnF,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -1,4 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- export declare function useBlockIntersectionObserver(block?: BlockDef): {
3
- current: Element | null;
4
- };
@@ -1,14 +0,0 @@
1
- import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
2
- import { useIntersectionObserver } from '../../hooks/useIntersectionObserver.js';
3
- import { blockRouterEventBus } from './blockRouterEventBus.js';
4
- export function useBlockIntersectionObserver(block) {
5
- const observerCallback = useCallback((entries) => {
6
- if (!block || !entries?.length) {
7
- return;
8
- }
9
- const intersection = entries[entries.length - 1];
10
- blockRouterEventBus.fire('intersection', { block, intersection });
11
- }, [block]);
12
- return useIntersectionObserver(observerCallback, { sensitivity: 1 });
13
- }
14
- //# sourceMappingURL=useBlockIntersectionObserver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useBlockIntersectionObserver.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/useBlockIntersectionObserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,UAAU,4BAA4B,CAAC,KAAgB;IAC3D,MAAM,gBAAgB,GAAG,WAAW,CAClC,CAAC,OAAoC,EAAE,EAAE;QACvC,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE;YAC9B,OAAO;SACR;QAED,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjD,mBAAmB,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;IACpE,CAAC,EACD,CAAC,KAAK,CAAC,CACR,CAAC;IAEF,OAAO,uBAAuB,CAAC,gBAAgB,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC;AACvE,CAAC"}
@@ -1 +0,0 @@
1
- export declare function useBlockRouterProvider(scrollTarget?: EventTarget): void;
@@ -1,25 +0,0 @@
1
- import { useEffect, useRef } from '@redneckz/uni-jsx/lib/hooks';
2
- import { debounce } from '../../utils/debounce.js';
3
- import { trackBlock } from './BlockRouter.js';
4
- import { blockRouterEventBus } from './blockRouterEventBus.js';
5
- import { findActiveBlock } from './findActiveBlock.js';
6
- const isScrolledEnough = () => globalThis.scrollY > (globalThis.innerHeight * 3) / 4;
7
- export function useBlockRouterProvider(scrollTarget = globalThis) {
8
- const intersectionsMapRef = useRef(new Map());
9
- useEffect(() => blockRouterEventBus.subscribe('intersection', ({ block, intersection }) => {
10
- if (intersectionsMapRef.current) {
11
- intersectionsMapRef.current.set(block, intersection);
12
- }
13
- }), []);
14
- useEffect(() => {
15
- const handleScroll = debounce(() => {
16
- trackBlock(isScrolledEnough() ? findActiveBlock([...(intersectionsMapRef.current || [])]) : undefined);
17
- }, 100);
18
- scrollTarget.addEventListener('scroll', handleScroll);
19
- return () => {
20
- handleScroll.dispose();
21
- scrollTarget.removeEventListener('scroll', handleScroll);
22
- };
23
- }, [scrollTarget]);
24
- }
25
- //# sourceMappingURL=useBlockRouterProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useBlockRouterProvider.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/useBlockRouterProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,UAAU,CAAC,WAAW,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAErF,MAAM,UAAU,sBAAsB,CAAC,eAA4B,UAAU;IAC3E,MAAM,mBAAmB,GAAG,MAAM,CAA2C,IAAI,GAAG,EAAE,CAAC,CAAC;IAExF,SAAS,CACP,GAAG,EAAE,CACH,mBAAmB,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE;QACxE,IAAI,mBAAmB,CAAC,OAAO,EAAE;YAC/B,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;SACtD;IACH,CAAC,CAAC,EACJ,EAAE,CACH,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE;YACjC,UAAU,CACR,gBAAgB,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,mBAAmB,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAC3F,CAAC;QACJ,CAAC,EAAE,GAAG,CAAC,CAAC;QAER,YAAY,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAEtD,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,OAAO,EAAE,CAAC;YACvB,YAAY,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAC3D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;AACrB,CAAC"}
@@ -1,2 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- export declare type BlockIntersection = [BlockDef, IntersectionObserverEntry];
@@ -1,2 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- export declare function trackBlock(block?: BlockDef): void;
@@ -1,11 +0,0 @@
1
- import { EventBus } from '../../EventBus/EventBus';
2
- import { type BlockDef } from '../../model/ContentPageDef';
3
- export interface BlockIntersectionEvent {
4
- block: BlockDef;
5
- intersection: IntersectionObserverEntry;
6
- }
7
- interface EventMap {
8
- intersection: BlockIntersectionEvent;
9
- }
10
- export declare const blockRouterEventBus: EventBus<EventMap>;
11
- export {};
@@ -1,3 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- import { type BlockIntersection } from './BlockIntersection';
3
- export declare function findActiveBlock(intersections: BlockIntersection[]): BlockDef | undefined;
@@ -1,4 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- export declare function useBlockIntersectionObserver(block?: BlockDef): {
3
- current: Element | null;
4
- };
@@ -1 +0,0 @@
1
- export declare function useBlockRouterProvider(scrollTarget?: EventTarget): void;
@@ -1,2 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- export declare type BlockIntersection = [BlockDef, IntersectionObserverEntry];
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- //# sourceMappingURL=BlockIntersection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BlockIntersection.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/BlockIntersection.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- export declare function trackBlock(block?: BlockDef): void;
@@ -1,11 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.trackBlock = void 0;
3
- const normalizeAnchor = (anchor) => anchor?.replace('#', '') || '';
4
- function trackBlock(block) {
5
- const hash = `#${normalizeAnchor(block?.anchor)}`;
6
- if (globalThis.location?.hash !== hash) {
7
- globalThis.history?.replaceState(globalThis.history?.state, '', hash);
8
- }
9
- }
10
- exports.trackBlock = trackBlock;
11
- //# sourceMappingURL=BlockRouter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BlockRouter.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/BlockRouter.ts"],"names":[],"mappings":";;AAEA,MAAM,eAAe,GAAG,CAAC,MAAe,EAAE,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;AAE5E,SAAgB,UAAU,CAAC,KAAgB;IACzC,MAAM,IAAI,GAAG,IAAI,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC;IAElD,IAAI,UAAU,CAAC,QAAQ,EAAE,IAAI,KAAK,IAAI,EAAE;QACtC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;KACvE;AACH,CAAC;AAND,gCAMC"}
@@ -1,11 +0,0 @@
1
- import { EventBus } from '../../EventBus/EventBus';
2
- import { type BlockDef } from '../../model/ContentPageDef';
3
- export interface BlockIntersectionEvent {
4
- block: BlockDef;
5
- intersection: IntersectionObserverEntry;
6
- }
7
- interface EventMap {
8
- intersection: BlockIntersectionEvent;
9
- }
10
- export declare const blockRouterEventBus: EventBus<EventMap>;
11
- export {};
@@ -1,5 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.blockRouterEventBus = void 0;
3
- const EventBus_1 = require("../../EventBus/EventBus");
4
- exports.blockRouterEventBus = new EventBus_1.EventBus();
5
- //# sourceMappingURL=blockRouterEventBus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"blockRouterEventBus.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/blockRouterEventBus.ts"],"names":[],"mappings":";;AAAA,sDAAmD;AAYtC,QAAA,mBAAmB,GAAG,IAAI,mBAAQ,EAAY,CAAC"}
@@ -1,3 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- import { type BlockIntersection } from './BlockIntersection';
3
- export declare function findActiveBlock(intersections: BlockIntersection[]): BlockDef | undefined;
@@ -1,15 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.findActiveBlock = void 0;
3
- const minBy_1 = require("../../utils/minBy");
4
- const SPECIAL_BLOCK_TYPES = ['Header', 'Footer'];
5
- const EPS = 0.01;
6
- const topLineDelta = ([, { target }]) => Math.abs(target.getBoundingClientRect().top);
7
- function findActiveBlock(intersections) {
8
- const visibleIntersections = intersections
9
- .filter(([block]) => !SPECIAL_BLOCK_TYPES.includes(block.type || ''))
10
- .filter(([, { intersectionRatio }]) => intersectionRatio > EPS);
11
- const [activeBlock] = visibleIntersections.length > 0 ? (0, minBy_1.minBy)(topLineDelta)(visibleIntersections) : [];
12
- return activeBlock;
13
- }
14
- exports.findActiveBlock = findActiveBlock;
15
- //# sourceMappingURL=findActiveBlock.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findActiveBlock.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/findActiveBlock.ts"],"names":[],"mappings":";;AACA,6CAA0C;AAG1C,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACjD,MAAM,GAAG,GAAG,IAAI,CAAC;AAEjB,MAAM,YAAY,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,CAAoB,EAAE,EAAE,CACzD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC,GAAG,CAAC,CAAC;AAE/C,SAAgB,eAAe,CAAC,aAAkC;IAChE,MAAM,oBAAoB,GAAG,aAAa;SACvC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;SACpE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,iBAAiB,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,GAAG,GAAG,CAAC,CAAC;IAElE,MAAM,CAAC,WAAW,CAAC,GACjB,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,aAAK,EAAC,YAAY,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEnF,OAAO,WAAW,CAAC;AACrB,CAAC;AATD,0CASC"}
@@ -1,4 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- export declare function useBlockIntersectionObserver(block?: BlockDef): {
3
- current: Element | null;
4
- };
@@ -1,17 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.useBlockIntersectionObserver = void 0;
3
- const hooks_1 = require("@redneckz/uni-jsx/lib/hooks");
4
- const useIntersectionObserver_1 = require("../../hooks/useIntersectionObserver");
5
- const blockRouterEventBus_1 = require("./blockRouterEventBus");
6
- function useBlockIntersectionObserver(block) {
7
- const observerCallback = (0, hooks_1.useCallback)((entries) => {
8
- if (!block || !entries?.length) {
9
- return;
10
- }
11
- const intersection = entries[entries.length - 1];
12
- blockRouterEventBus_1.blockRouterEventBus.fire('intersection', { block, intersection });
13
- }, [block]);
14
- return (0, useIntersectionObserver_1.useIntersectionObserver)(observerCallback, { sensitivity: 1 });
15
- }
16
- exports.useBlockIntersectionObserver = useBlockIntersectionObserver;
17
- //# sourceMappingURL=useBlockIntersectionObserver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useBlockIntersectionObserver.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/useBlockIntersectionObserver.ts"],"names":[],"mappings":";;AAAA,uDAA0D;AAC1D,iFAA8E;AAE9E,+DAA4D;AAE5D,SAAgB,4BAA4B,CAAC,KAAgB;IAC3D,MAAM,gBAAgB,GAAG,IAAA,mBAAW,EAClC,CAAC,OAAoC,EAAE,EAAE;QACvC,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE;YAC9B,OAAO;SACR;QAED,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjD,yCAAmB,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;IACpE,CAAC,EACD,CAAC,KAAK,CAAC,CACR,CAAC;IAEF,OAAO,IAAA,iDAAuB,EAAC,gBAAgB,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC;AACvE,CAAC;AAdD,oEAcC"}
@@ -1 +0,0 @@
1
- export declare function useBlockRouterProvider(scrollTarget?: EventTarget): void;
@@ -1,28 +0,0 @@
1
- Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.useBlockRouterProvider = void 0;
3
- const hooks_1 = require("@redneckz/uni-jsx/lib/hooks");
4
- const debounce_1 = require("../../utils/debounce");
5
- const BlockRouter_1 = require("./BlockRouter");
6
- const blockRouterEventBus_1 = require("./blockRouterEventBus");
7
- const findActiveBlock_1 = require("./findActiveBlock");
8
- const isScrolledEnough = () => globalThis.scrollY > (globalThis.innerHeight * 3) / 4;
9
- function useBlockRouterProvider(scrollTarget = globalThis) {
10
- const intersectionsMapRef = (0, hooks_1.useRef)(new Map());
11
- (0, hooks_1.useEffect)(() => blockRouterEventBus_1.blockRouterEventBus.subscribe('intersection', ({ block, intersection }) => {
12
- if (intersectionsMapRef.current) {
13
- intersectionsMapRef.current.set(block, intersection);
14
- }
15
- }), []);
16
- (0, hooks_1.useEffect)(() => {
17
- const handleScroll = (0, debounce_1.debounce)(() => {
18
- (0, BlockRouter_1.trackBlock)(isScrolledEnough() ? (0, findActiveBlock_1.findActiveBlock)([...(intersectionsMapRef.current || [])]) : undefined);
19
- }, 100);
20
- scrollTarget.addEventListener('scroll', handleScroll);
21
- return () => {
22
- handleScroll.dispose();
23
- scrollTarget.removeEventListener('scroll', handleScroll);
24
- };
25
- }, [scrollTarget]);
26
- }
27
- exports.useBlockRouterProvider = useBlockRouterProvider;
28
- //# sourceMappingURL=useBlockRouterProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useBlockRouterProvider.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/useBlockRouterProvider.ts"],"names":[],"mappings":";;AAAA,uDAAgE;AAEhE,mDAAgD;AAChD,+CAA2C;AAC3C,+DAA4D;AAC5D,uDAAoD;AAEpD,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,UAAU,CAAC,WAAW,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAErF,SAAgB,sBAAsB,CAAC,eAA4B,UAAU;IAC3E,MAAM,mBAAmB,GAAG,IAAA,cAAM,EAA2C,IAAI,GAAG,EAAE,CAAC,CAAC;IAExF,IAAA,iBAAS,EACP,GAAG,EAAE,CACH,yCAAmB,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE;QACxE,IAAI,mBAAmB,CAAC,OAAO,EAAE;YAC/B,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;SACtD;IACH,CAAC,CAAC,EACJ,EAAE,CACH,CAAC;IAEF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,IAAA,mBAAQ,EAAC,GAAG,EAAE;YACjC,IAAA,wBAAU,EACR,gBAAgB,EAAE,CAAC,CAAC,CAAC,IAAA,iCAAe,EAAC,CAAC,GAAG,CAAC,mBAAmB,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAC3F,CAAC;QACJ,CAAC,EAAE,GAAG,CAAC,CAAC;QAER,YAAY,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAEtD,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,OAAO,EAAE,CAAC;YACvB,YAAY,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAC3D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;AACrB,CAAC;AA3BD,wDA2BC"}
@@ -1,2 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- export declare type BlockIntersection = [BlockDef, IntersectionObserverEntry];
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=BlockIntersection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BlockIntersection.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/BlockIntersection.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- export declare function trackBlock(block?: BlockDef): void;
@@ -1,8 +0,0 @@
1
- const normalizeAnchor = (anchor) => anchor?.replace('#', '') || '';
2
- export function trackBlock(block) {
3
- const hash = `#${normalizeAnchor(block?.anchor)}`;
4
- if (globalThis.location?.hash !== hash) {
5
- globalThis.history?.replaceState(globalThis.history?.state, '', hash);
6
- }
7
- }
8
- //# sourceMappingURL=BlockRouter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BlockRouter.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/BlockRouter.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAG,CAAC,MAAe,EAAE,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;AAE5E,MAAM,UAAU,UAAU,CAAC,KAAgB;IACzC,MAAM,IAAI,GAAG,IAAI,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC;IAElD,IAAI,UAAU,CAAC,QAAQ,EAAE,IAAI,KAAK,IAAI,EAAE;QACtC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;KACvE;AACH,CAAC"}
@@ -1,11 +0,0 @@
1
- import { EventBus } from '../../EventBus/EventBus';
2
- import { type BlockDef } from '../../model/ContentPageDef';
3
- export interface BlockIntersectionEvent {
4
- block: BlockDef;
5
- intersection: IntersectionObserverEntry;
6
- }
7
- interface EventMap {
8
- intersection: BlockIntersectionEvent;
9
- }
10
- export declare const blockRouterEventBus: EventBus<EventMap>;
11
- export {};
@@ -1,3 +0,0 @@
1
- import { EventBus } from '../../EventBus/EventBus.js';
2
- export const blockRouterEventBus = new EventBus();
3
- //# sourceMappingURL=blockRouterEventBus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"blockRouterEventBus.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/blockRouterEventBus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAYnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,QAAQ,EAAY,CAAC"}
@@ -1,3 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- import { type BlockIntersection } from './BlockIntersection';
3
- export declare function findActiveBlock(intersections: BlockIntersection[]): BlockDef | undefined;
@@ -1,12 +0,0 @@
1
- import { minBy } from '../../utils/minBy.js';
2
- const SPECIAL_BLOCK_TYPES = ['Header', 'Footer'];
3
- const EPS = 0.01;
4
- const topLineDelta = ([, { target }]) => Math.abs(target.getBoundingClientRect().top);
5
- export function findActiveBlock(intersections) {
6
- const visibleIntersections = intersections
7
- .filter(([block]) => !SPECIAL_BLOCK_TYPES.includes(block.type || ''))
8
- .filter(([, { intersectionRatio }]) => intersectionRatio > EPS);
9
- const [activeBlock] = visibleIntersections.length > 0 ? minBy(topLineDelta)(visibleIntersections) : [];
10
- return activeBlock;
11
- }
12
- //# sourceMappingURL=findActiveBlock.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findActiveBlock.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/findActiveBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG1C,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACjD,MAAM,GAAG,GAAG,IAAI,CAAC;AAEjB,MAAM,YAAY,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,CAAoB,EAAE,EAAE,CACzD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,UAAU,eAAe,CAAC,aAAkC;IAChE,MAAM,oBAAoB,GAAG,aAAa;SACvC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;SACpE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,iBAAiB,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,GAAG,GAAG,CAAC,CAAC;IAElE,MAAM,CAAC,WAAW,CAAC,GACjB,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEnF,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -1,4 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- export declare function useBlockIntersectionObserver(block?: BlockDef): {
3
- current: Element | null;
4
- };
@@ -1,14 +0,0 @@
1
- import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
2
- import { useIntersectionObserver } from '../../hooks/useIntersectionObserver.js';
3
- import { blockRouterEventBus } from './blockRouterEventBus.js';
4
- export function useBlockIntersectionObserver(block) {
5
- const observerCallback = useCallback((entries) => {
6
- if (!block || !entries?.length) {
7
- return;
8
- }
9
- const intersection = entries[entries.length - 1];
10
- blockRouterEventBus.fire('intersection', { block, intersection });
11
- }, [block]);
12
- return useIntersectionObserver(observerCallback, { sensitivity: 1 });
13
- }
14
- //# sourceMappingURL=useBlockIntersectionObserver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useBlockIntersectionObserver.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/useBlockIntersectionObserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,UAAU,4BAA4B,CAAC,KAAgB;IAC3D,MAAM,gBAAgB,GAAG,WAAW,CAClC,CAAC,OAAoC,EAAE,EAAE;QACvC,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE;YAC9B,OAAO;SACR;QAED,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjD,mBAAmB,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;IACpE,CAAC,EACD,CAAC,KAAK,CAAC,CACR,CAAC;IAEF,OAAO,uBAAuB,CAAC,gBAAgB,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC;AACvE,CAAC"}
@@ -1 +0,0 @@
1
- export declare function useBlockRouterProvider(scrollTarget?: EventTarget): void;
@@ -1,25 +0,0 @@
1
- import { useEffect, useRef } from '@redneckz/uni-jsx/lib/hooks';
2
- import { debounce } from '../../utils/debounce.js';
3
- import { trackBlock } from './BlockRouter.js';
4
- import { blockRouterEventBus } from './blockRouterEventBus.js';
5
- import { findActiveBlock } from './findActiveBlock.js';
6
- const isScrolledEnough = () => globalThis.scrollY > (globalThis.innerHeight * 3) / 4;
7
- export function useBlockRouterProvider(scrollTarget = globalThis) {
8
- const intersectionsMapRef = useRef(new Map());
9
- useEffect(() => blockRouterEventBus.subscribe('intersection', ({ block, intersection }) => {
10
- if (intersectionsMapRef.current) {
11
- intersectionsMapRef.current.set(block, intersection);
12
- }
13
- }), []);
14
- useEffect(() => {
15
- const handleScroll = debounce(() => {
16
- trackBlock(isScrolledEnough() ? findActiveBlock([...(intersectionsMapRef.current || [])]) : undefined);
17
- }, 100);
18
- scrollTarget.addEventListener('scroll', handleScroll);
19
- return () => {
20
- handleScroll.dispose();
21
- scrollTarget.removeEventListener('scroll', handleScroll);
22
- };
23
- }, [scrollTarget]);
24
- }
25
- //# sourceMappingURL=useBlockRouterProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useBlockRouterProvider.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/useBlockRouterProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,UAAU,CAAC,WAAW,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAErF,MAAM,UAAU,sBAAsB,CAAC,eAA4B,UAAU;IAC3E,MAAM,mBAAmB,GAAG,MAAM,CAA2C,IAAI,GAAG,EAAE,CAAC,CAAC;IAExF,SAAS,CACP,GAAG,EAAE,CACH,mBAAmB,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE;QACxE,IAAI,mBAAmB,CAAC,OAAO,EAAE;YAC/B,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;SACtD;IACH,CAAC,CAAC,EACJ,EAAE,CACH,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE;YACjC,UAAU,CACR,gBAAgB,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,mBAAmB,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAC3F,CAAC;QACJ,CAAC,EAAE,GAAG,CAAC,CAAC;QAER,YAAY,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAEtD,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,OAAO,EAAE,CAAC;YACvB,YAAY,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAC3D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;AACrB,CAAC"}
@@ -1,3 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
-
3
- export type BlockIntersection = [BlockDef, IntersectionObserverEntry];