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

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 (121) hide show
  1. package/bundle/bundle.umd.js +26 -96
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/dist/components/ContentPage/ContentPage.js +0 -2
  4. package/dist/components/ContentPage/ContentPage.js.map +1 -1
  5. package/dist/ui-kit/BlockWrapper.js +1 -3
  6. package/dist/ui-kit/BlockWrapper.js.map +1 -1
  7. package/lib/components/ContentPage/ContentPage.js +0 -2
  8. package/lib/components/ContentPage/ContentPage.js.map +1 -1
  9. package/lib/ui-kit/BlockWrapper.js +1 -3
  10. package/lib/ui-kit/BlockWrapper.js.map +1 -1
  11. package/mobile/bundle/bundle.umd.js +26 -96
  12. package/mobile/bundle/bundle.umd.min.js +1 -1
  13. package/mobile/dist/components/ContentPage/ContentPage.js +0 -2
  14. package/mobile/dist/components/ContentPage/ContentPage.js.map +1 -1
  15. package/mobile/dist/ui-kit/BlockWrapper.js +1 -3
  16. package/mobile/dist/ui-kit/BlockWrapper.js.map +1 -1
  17. package/mobile/lib/components/ContentPage/ContentPage.js +0 -2
  18. package/mobile/lib/components/ContentPage/ContentPage.js.map +1 -1
  19. package/mobile/lib/ui-kit/BlockWrapper.js +1 -3
  20. package/mobile/lib/ui-kit/BlockWrapper.js.map +1 -1
  21. package/mobile/src/components/ContentPage/ContentPage.tsx +0 -3
  22. package/mobile/src/ui-kit/BlockWrapper.tsx +2 -4
  23. package/package.json +1 -1
  24. package/src/components/ContentPage/ContentPage.tsx +0 -3
  25. package/src/ui-kit/BlockWrapper.tsx +2 -4
  26. package/bundle/services/BlockRouter/BlockIntersection.d.ts +0 -2
  27. package/bundle/services/BlockRouter/BlockRouter.d.ts +0 -2
  28. package/bundle/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
  29. package/bundle/services/BlockRouter/findActiveBlock.d.ts +0 -3
  30. package/bundle/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
  31. package/bundle/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
  32. package/dist/services/BlockRouter/BlockIntersection.d.ts +0 -2
  33. package/dist/services/BlockRouter/BlockIntersection.js +0 -2
  34. package/dist/services/BlockRouter/BlockIntersection.js.map +0 -1
  35. package/dist/services/BlockRouter/BlockRouter.d.ts +0 -2
  36. package/dist/services/BlockRouter/BlockRouter.js +0 -11
  37. package/dist/services/BlockRouter/BlockRouter.js.map +0 -1
  38. package/dist/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
  39. package/dist/services/BlockRouter/blockRouterEventBus.js +0 -5
  40. package/dist/services/BlockRouter/blockRouterEventBus.js.map +0 -1
  41. package/dist/services/BlockRouter/findActiveBlock.d.ts +0 -3
  42. package/dist/services/BlockRouter/findActiveBlock.js +0 -15
  43. package/dist/services/BlockRouter/findActiveBlock.js.map +0 -1
  44. package/dist/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
  45. package/dist/services/BlockRouter/useBlockIntersectionObserver.js +0 -17
  46. package/dist/services/BlockRouter/useBlockIntersectionObserver.js.map +0 -1
  47. package/dist/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
  48. package/dist/services/BlockRouter/useBlockRouterProvider.js +0 -28
  49. package/dist/services/BlockRouter/useBlockRouterProvider.js.map +0 -1
  50. package/lib/services/BlockRouter/BlockIntersection.d.ts +0 -2
  51. package/lib/services/BlockRouter/BlockIntersection.js +0 -2
  52. package/lib/services/BlockRouter/BlockIntersection.js.map +0 -1
  53. package/lib/services/BlockRouter/BlockRouter.d.ts +0 -2
  54. package/lib/services/BlockRouter/BlockRouter.js +0 -8
  55. package/lib/services/BlockRouter/BlockRouter.js.map +0 -1
  56. package/lib/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
  57. package/lib/services/BlockRouter/blockRouterEventBus.js +0 -3
  58. package/lib/services/BlockRouter/blockRouterEventBus.js.map +0 -1
  59. package/lib/services/BlockRouter/findActiveBlock.d.ts +0 -3
  60. package/lib/services/BlockRouter/findActiveBlock.js +0 -12
  61. package/lib/services/BlockRouter/findActiveBlock.js.map +0 -1
  62. package/lib/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
  63. package/lib/services/BlockRouter/useBlockIntersectionObserver.js +0 -14
  64. package/lib/services/BlockRouter/useBlockIntersectionObserver.js.map +0 -1
  65. package/lib/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
  66. package/lib/services/BlockRouter/useBlockRouterProvider.js +0 -25
  67. package/lib/services/BlockRouter/useBlockRouterProvider.js.map +0 -1
  68. package/mobile/bundle/services/BlockRouter/BlockIntersection.d.ts +0 -2
  69. package/mobile/bundle/services/BlockRouter/BlockRouter.d.ts +0 -2
  70. package/mobile/bundle/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
  71. package/mobile/bundle/services/BlockRouter/findActiveBlock.d.ts +0 -3
  72. package/mobile/bundle/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
  73. package/mobile/bundle/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
  74. package/mobile/dist/services/BlockRouter/BlockIntersection.d.ts +0 -2
  75. package/mobile/dist/services/BlockRouter/BlockIntersection.js +0 -2
  76. package/mobile/dist/services/BlockRouter/BlockIntersection.js.map +0 -1
  77. package/mobile/dist/services/BlockRouter/BlockRouter.d.ts +0 -2
  78. package/mobile/dist/services/BlockRouter/BlockRouter.js +0 -11
  79. package/mobile/dist/services/BlockRouter/BlockRouter.js.map +0 -1
  80. package/mobile/dist/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
  81. package/mobile/dist/services/BlockRouter/blockRouterEventBus.js +0 -5
  82. package/mobile/dist/services/BlockRouter/blockRouterEventBus.js.map +0 -1
  83. package/mobile/dist/services/BlockRouter/findActiveBlock.d.ts +0 -3
  84. package/mobile/dist/services/BlockRouter/findActiveBlock.js +0 -15
  85. package/mobile/dist/services/BlockRouter/findActiveBlock.js.map +0 -1
  86. package/mobile/dist/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
  87. package/mobile/dist/services/BlockRouter/useBlockIntersectionObserver.js +0 -17
  88. package/mobile/dist/services/BlockRouter/useBlockIntersectionObserver.js.map +0 -1
  89. package/mobile/dist/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
  90. package/mobile/dist/services/BlockRouter/useBlockRouterProvider.js +0 -28
  91. package/mobile/dist/services/BlockRouter/useBlockRouterProvider.js.map +0 -1
  92. package/mobile/lib/services/BlockRouter/BlockIntersection.d.ts +0 -2
  93. package/mobile/lib/services/BlockRouter/BlockIntersection.js +0 -2
  94. package/mobile/lib/services/BlockRouter/BlockIntersection.js.map +0 -1
  95. package/mobile/lib/services/BlockRouter/BlockRouter.d.ts +0 -2
  96. package/mobile/lib/services/BlockRouter/BlockRouter.js +0 -8
  97. package/mobile/lib/services/BlockRouter/BlockRouter.js.map +0 -1
  98. package/mobile/lib/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
  99. package/mobile/lib/services/BlockRouter/blockRouterEventBus.js +0 -3
  100. package/mobile/lib/services/BlockRouter/blockRouterEventBus.js.map +0 -1
  101. package/mobile/lib/services/BlockRouter/findActiveBlock.d.ts +0 -3
  102. package/mobile/lib/services/BlockRouter/findActiveBlock.js +0 -12
  103. package/mobile/lib/services/BlockRouter/findActiveBlock.js.map +0 -1
  104. package/mobile/lib/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
  105. package/mobile/lib/services/BlockRouter/useBlockIntersectionObserver.js +0 -14
  106. package/mobile/lib/services/BlockRouter/useBlockIntersectionObserver.js.map +0 -1
  107. package/mobile/lib/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
  108. package/mobile/lib/services/BlockRouter/useBlockRouterProvider.js +0 -25
  109. package/mobile/lib/services/BlockRouter/useBlockRouterProvider.js.map +0 -1
  110. package/mobile/src/services/BlockRouter/BlockIntersection.ts +0 -3
  111. package/mobile/src/services/BlockRouter/BlockRouter.ts +0 -11
  112. package/mobile/src/services/BlockRouter/blockRouterEventBus.ts +0 -13
  113. package/mobile/src/services/BlockRouter/findActiveBlock.ts +0 -20
  114. package/mobile/src/services/BlockRouter/useBlockIntersectionObserver.ts +0 -20
  115. package/mobile/src/services/BlockRouter/useBlockRouterProvider.ts +0 -37
  116. package/src/services/BlockRouter/BlockIntersection.ts +0 -3
  117. package/src/services/BlockRouter/BlockRouter.ts +0 -11
  118. package/src/services/BlockRouter/blockRouterEventBus.ts +0 -13
  119. package/src/services/BlockRouter/findActiveBlock.ts +0 -20
  120. package/src/services/BlockRouter/useBlockIntersectionObserver.ts +0 -20
  121. package/src/services/BlockRouter/useBlockRouterProvider.ts +0 -37
@@ -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];
@@ -1,11 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
-
3
- const normalizeAnchor = (anchor?: string) => anchor?.replace('#', '') || '';
4
-
5
- export function trackBlock(block?: BlockDef) {
6
- const hash = `#${normalizeAnchor(block?.anchor)}`;
7
-
8
- if (globalThis.location?.hash !== hash) {
9
- globalThis.history?.replaceState(globalThis.history?.state, '', hash);
10
- }
11
- }
@@ -1,13 +0,0 @@
1
- import { EventBus } from '../../EventBus/EventBus';
2
- import { type BlockDef } from '../../model/ContentPageDef';
3
-
4
- export interface BlockIntersectionEvent {
5
- block: BlockDef;
6
- intersection: IntersectionObserverEntry;
7
- }
8
-
9
- interface EventMap {
10
- intersection: BlockIntersectionEvent;
11
- }
12
-
13
- export const blockRouterEventBus = new EventBus<EventMap>();
@@ -1,20 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- import { minBy } from '../../utils/minBy';
3
- import { type BlockIntersection } from './BlockIntersection';
4
-
5
- const SPECIAL_BLOCK_TYPES = ['Header', 'Footer'];
6
- const EPS = 0.01;
7
-
8
- const topLineDelta = ([, { target }]: BlockIntersection) =>
9
- Math.abs(target.getBoundingClientRect().top);
10
-
11
- export function findActiveBlock(intersections: BlockIntersection[]): BlockDef | undefined {
12
- const visibleIntersections = intersections
13
- .filter(([block]) => !SPECIAL_BLOCK_TYPES.includes(block.type || ''))
14
- .filter(([, { intersectionRatio }]) => intersectionRatio > EPS);
15
-
16
- const [activeBlock] =
17
- visibleIntersections.length > 0 ? minBy(topLineDelta)(visibleIntersections) : [];
18
-
19
- return activeBlock;
20
- }
@@ -1,20 +0,0 @@
1
- import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
2
- import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';
3
- import { type BlockDef } from '../../model/ContentPageDef';
4
- import { blockRouterEventBus } from './blockRouterEventBus';
5
-
6
- export function useBlockIntersectionObserver(block?: BlockDef) {
7
- const observerCallback = useCallback(
8
- (entries: IntersectionObserverEntry[]) => {
9
- if (!block || !entries?.length) {
10
- return;
11
- }
12
-
13
- const intersection = entries[entries.length - 1];
14
- blockRouterEventBus.fire('intersection', { block, intersection });
15
- },
16
- [block],
17
- );
18
-
19
- return useIntersectionObserver(observerCallback, { sensitivity: 1 });
20
- }
@@ -1,37 +0,0 @@
1
- import { useEffect, useRef } from '@redneckz/uni-jsx/lib/hooks';
2
- import { type BlockDef } from '../../model/ContentPageDef';
3
- import { debounce } from '../../utils/debounce';
4
- import { trackBlock } from './BlockRouter';
5
- import { blockRouterEventBus } from './blockRouterEventBus';
6
- import { findActiveBlock } from './findActiveBlock';
7
-
8
- const isScrolledEnough = () => globalThis.scrollY > (globalThis.innerHeight * 3) / 4;
9
-
10
- export function useBlockRouterProvider(scrollTarget: EventTarget = globalThis) {
11
- const intersectionsMapRef = useRef<Map<BlockDef, IntersectionObserverEntry>>(new Map());
12
-
13
- useEffect(
14
- () =>
15
- blockRouterEventBus.subscribe('intersection', ({ block, intersection }) => {
16
- if (intersectionsMapRef.current) {
17
- intersectionsMapRef.current.set(block, intersection);
18
- }
19
- }),
20
- [],
21
- );
22
-
23
- useEffect(() => {
24
- const handleScroll = debounce(() => {
25
- trackBlock(
26
- isScrolledEnough() ? findActiveBlock([...(intersectionsMapRef.current || [])]) : undefined,
27
- );
28
- }, 100);
29
-
30
- scrollTarget.addEventListener('scroll', handleScroll);
31
-
32
- return () => {
33
- handleScroll.dispose();
34
- scrollTarget.removeEventListener('scroll', handleScroll);
35
- };
36
- }, [scrollTarget]);
37
- }
@@ -1,3 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
-
3
- export type BlockIntersection = [BlockDef, IntersectionObserverEntry];
@@ -1,11 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
-
3
- const normalizeAnchor = (anchor?: string) => anchor?.replace('#', '') || '';
4
-
5
- export function trackBlock(block?: BlockDef) {
6
- const hash = `#${normalizeAnchor(block?.anchor)}`;
7
-
8
- if (globalThis.location?.hash !== hash) {
9
- globalThis.history?.replaceState(globalThis.history?.state, '', hash);
10
- }
11
- }
@@ -1,13 +0,0 @@
1
- import { EventBus } from '../../EventBus/EventBus';
2
- import { type BlockDef } from '../../model/ContentPageDef';
3
-
4
- export interface BlockIntersectionEvent {
5
- block: BlockDef;
6
- intersection: IntersectionObserverEntry;
7
- }
8
-
9
- interface EventMap {
10
- intersection: BlockIntersectionEvent;
11
- }
12
-
13
- export const blockRouterEventBus = new EventBus<EventMap>();
@@ -1,20 +0,0 @@
1
- import { type BlockDef } from '../../model/ContentPageDef';
2
- import { minBy } from '../../utils/minBy';
3
- import { type BlockIntersection } from './BlockIntersection';
4
-
5
- const SPECIAL_BLOCK_TYPES = ['Header', 'Footer'];
6
- const EPS = 0.01;
7
-
8
- const topLineDelta = ([, { target }]: BlockIntersection) =>
9
- Math.abs(target.getBoundingClientRect().top);
10
-
11
- export function findActiveBlock(intersections: BlockIntersection[]): BlockDef | undefined {
12
- const visibleIntersections = intersections
13
- .filter(([block]) => !SPECIAL_BLOCK_TYPES.includes(block.type || ''))
14
- .filter(([, { intersectionRatio }]) => intersectionRatio > EPS);
15
-
16
- const [activeBlock] =
17
- visibleIntersections.length > 0 ? minBy(topLineDelta)(visibleIntersections) : [];
18
-
19
- return activeBlock;
20
- }
@@ -1,20 +0,0 @@
1
- import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
2
- import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';
3
- import { type BlockDef } from '../../model/ContentPageDef';
4
- import { blockRouterEventBus } from './blockRouterEventBus';
5
-
6
- export function useBlockIntersectionObserver(block?: BlockDef) {
7
- const observerCallback = useCallback(
8
- (entries: IntersectionObserverEntry[]) => {
9
- if (!block || !entries?.length) {
10
- return;
11
- }
12
-
13
- const intersection = entries[entries.length - 1];
14
- blockRouterEventBus.fire('intersection', { block, intersection });
15
- },
16
- [block],
17
- );
18
-
19
- return useIntersectionObserver(observerCallback, { sensitivity: 1 });
20
- }
@@ -1,37 +0,0 @@
1
- import { useEffect, useRef } from '@redneckz/uni-jsx/lib/hooks';
2
- import { type BlockDef } from '../../model/ContentPageDef';
3
- import { debounce } from '../../utils/debounce';
4
- import { trackBlock } from './BlockRouter';
5
- import { blockRouterEventBus } from './blockRouterEventBus';
6
- import { findActiveBlock } from './findActiveBlock';
7
-
8
- const isScrolledEnough = () => globalThis.scrollY > (globalThis.innerHeight * 3) / 4;
9
-
10
- export function useBlockRouterProvider(scrollTarget: EventTarget = globalThis) {
11
- const intersectionsMapRef = useRef<Map<BlockDef, IntersectionObserverEntry>>(new Map());
12
-
13
- useEffect(
14
- () =>
15
- blockRouterEventBus.subscribe('intersection', ({ block, intersection }) => {
16
- if (intersectionsMapRef.current) {
17
- intersectionsMapRef.current.set(block, intersection);
18
- }
19
- }),
20
- [],
21
- );
22
-
23
- useEffect(() => {
24
- const handleScroll = debounce(() => {
25
- trackBlock(
26
- isScrolledEnough() ? findActiveBlock([...(intersectionsMapRef.current || [])]) : undefined,
27
- );
28
- }, 100);
29
-
30
- scrollTarget.addEventListener('scroll', handleScroll);
31
-
32
- return () => {
33
- handleScroll.dispose();
34
- scrollTarget.removeEventListener('scroll', handleScroll);
35
- };
36
- }, [scrollTarget]);
37
- }