@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.
- package/bin/migration-scripts/0.14.68.js +1 -1
- package/bundle/bundle.umd.js +27 -97
- package/bundle/bundle.umd.min.js +1 -1
- package/dist/components/BonusBenefitsBlock/renderBonusBenefit.js +1 -1
- package/dist/components/BonusBenefitsBlock/renderBonusBenefit.js.map +1 -1
- package/dist/components/ContentPage/ContentPage.js +0 -2
- package/dist/components/ContentPage/ContentPage.js.map +1 -1
- package/dist/ui-kit/BlockWrapper.js +1 -3
- package/dist/ui-kit/BlockWrapper.js.map +1 -1
- package/lib/components/BonusBenefitsBlock/renderBonusBenefit.js +1 -1
- package/lib/components/BonusBenefitsBlock/renderBonusBenefit.js.map +1 -1
- package/lib/components/ContentPage/ContentPage.js +0 -2
- package/lib/components/ContentPage/ContentPage.js.map +1 -1
- package/lib/ui-kit/BlockWrapper.js +1 -3
- package/lib/ui-kit/BlockWrapper.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +27 -97
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/dist/components/BonusBenefitsBlock/renderBonusBenefit.js +1 -1
- package/mobile/dist/components/BonusBenefitsBlock/renderBonusBenefit.js.map +1 -1
- package/mobile/dist/components/ContentPage/ContentPage.js +0 -2
- package/mobile/dist/components/ContentPage/ContentPage.js.map +1 -1
- package/mobile/dist/ui-kit/BlockWrapper.js +1 -3
- package/mobile/dist/ui-kit/BlockWrapper.js.map +1 -1
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/components/BonusBenefitsBlock/renderBonusBenefit.js +1 -1
- package/mobile/lib/components/BonusBenefitsBlock/renderBonusBenefit.js.map +1 -1
- package/mobile/lib/components/ContentPage/ContentPage.js +0 -2
- package/mobile/lib/components/ContentPage/ContentPage.js.map +1 -1
- package/mobile/lib/ui-kit/BlockWrapper.js +1 -3
- package/mobile/lib/ui-kit/BlockWrapper.js.map +1 -1
- package/mobile/src/components/BonusBenefitsBlock/renderBonusBenefit.tsx +1 -1
- package/mobile/src/components/ContentPage/ContentPage.tsx +0 -3
- package/mobile/src/ui-kit/BlockWrapper.tsx +2 -4
- package/package.json +1 -1
- package/src/components/BenefitsBlock/BenefitsBlock.fixture.tsx +3 -3
- package/src/components/BonusBenefitsBlock/renderBonusBenefit.tsx +1 -1
- package/src/components/ContentPage/ContentPage.tsx +0 -3
- package/src/ui-kit/BlockWrapper.tsx +2 -4
- package/bundle/services/BlockRouter/BlockIntersection.d.ts +0 -2
- package/bundle/services/BlockRouter/BlockRouter.d.ts +0 -2
- package/bundle/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
- package/bundle/services/BlockRouter/findActiveBlock.d.ts +0 -3
- package/bundle/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
- package/bundle/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
- package/dist/services/BlockRouter/BlockIntersection.d.ts +0 -2
- package/dist/services/BlockRouter/BlockIntersection.js +0 -2
- package/dist/services/BlockRouter/BlockIntersection.js.map +0 -1
- package/dist/services/BlockRouter/BlockRouter.d.ts +0 -2
- package/dist/services/BlockRouter/BlockRouter.js +0 -11
- package/dist/services/BlockRouter/BlockRouter.js.map +0 -1
- package/dist/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
- package/dist/services/BlockRouter/blockRouterEventBus.js +0 -5
- package/dist/services/BlockRouter/blockRouterEventBus.js.map +0 -1
- package/dist/services/BlockRouter/findActiveBlock.d.ts +0 -3
- package/dist/services/BlockRouter/findActiveBlock.js +0 -15
- package/dist/services/BlockRouter/findActiveBlock.js.map +0 -1
- package/dist/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
- package/dist/services/BlockRouter/useBlockIntersectionObserver.js +0 -17
- package/dist/services/BlockRouter/useBlockIntersectionObserver.js.map +0 -1
- package/dist/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
- package/dist/services/BlockRouter/useBlockRouterProvider.js +0 -28
- package/dist/services/BlockRouter/useBlockRouterProvider.js.map +0 -1
- package/lib/services/BlockRouter/BlockIntersection.d.ts +0 -2
- package/lib/services/BlockRouter/BlockIntersection.js +0 -2
- package/lib/services/BlockRouter/BlockIntersection.js.map +0 -1
- package/lib/services/BlockRouter/BlockRouter.d.ts +0 -2
- package/lib/services/BlockRouter/BlockRouter.js +0 -8
- package/lib/services/BlockRouter/BlockRouter.js.map +0 -1
- package/lib/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
- package/lib/services/BlockRouter/blockRouterEventBus.js +0 -3
- package/lib/services/BlockRouter/blockRouterEventBus.js.map +0 -1
- package/lib/services/BlockRouter/findActiveBlock.d.ts +0 -3
- package/lib/services/BlockRouter/findActiveBlock.js +0 -12
- package/lib/services/BlockRouter/findActiveBlock.js.map +0 -1
- package/lib/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
- package/lib/services/BlockRouter/useBlockIntersectionObserver.js +0 -14
- package/lib/services/BlockRouter/useBlockIntersectionObserver.js.map +0 -1
- package/lib/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
- package/lib/services/BlockRouter/useBlockRouterProvider.js +0 -25
- package/lib/services/BlockRouter/useBlockRouterProvider.js.map +0 -1
- package/mobile/bundle/services/BlockRouter/BlockIntersection.d.ts +0 -2
- package/mobile/bundle/services/BlockRouter/BlockRouter.d.ts +0 -2
- package/mobile/bundle/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
- package/mobile/bundle/services/BlockRouter/findActiveBlock.d.ts +0 -3
- package/mobile/bundle/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
- package/mobile/bundle/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
- package/mobile/dist/services/BlockRouter/BlockIntersection.d.ts +0 -2
- package/mobile/dist/services/BlockRouter/BlockIntersection.js +0 -2
- package/mobile/dist/services/BlockRouter/BlockIntersection.js.map +0 -1
- package/mobile/dist/services/BlockRouter/BlockRouter.d.ts +0 -2
- package/mobile/dist/services/BlockRouter/BlockRouter.js +0 -11
- package/mobile/dist/services/BlockRouter/BlockRouter.js.map +0 -1
- package/mobile/dist/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
- package/mobile/dist/services/BlockRouter/blockRouterEventBus.js +0 -5
- package/mobile/dist/services/BlockRouter/blockRouterEventBus.js.map +0 -1
- package/mobile/dist/services/BlockRouter/findActiveBlock.d.ts +0 -3
- package/mobile/dist/services/BlockRouter/findActiveBlock.js +0 -15
- package/mobile/dist/services/BlockRouter/findActiveBlock.js.map +0 -1
- package/mobile/dist/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
- package/mobile/dist/services/BlockRouter/useBlockIntersectionObserver.js +0 -17
- package/mobile/dist/services/BlockRouter/useBlockIntersectionObserver.js.map +0 -1
- package/mobile/dist/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
- package/mobile/dist/services/BlockRouter/useBlockRouterProvider.js +0 -28
- package/mobile/dist/services/BlockRouter/useBlockRouterProvider.js.map +0 -1
- package/mobile/lib/services/BlockRouter/BlockIntersection.d.ts +0 -2
- package/mobile/lib/services/BlockRouter/BlockIntersection.js +0 -2
- package/mobile/lib/services/BlockRouter/BlockIntersection.js.map +0 -1
- package/mobile/lib/services/BlockRouter/BlockRouter.d.ts +0 -2
- package/mobile/lib/services/BlockRouter/BlockRouter.js +0 -8
- package/mobile/lib/services/BlockRouter/BlockRouter.js.map +0 -1
- package/mobile/lib/services/BlockRouter/blockRouterEventBus.d.ts +0 -11
- package/mobile/lib/services/BlockRouter/blockRouterEventBus.js +0 -3
- package/mobile/lib/services/BlockRouter/blockRouterEventBus.js.map +0 -1
- package/mobile/lib/services/BlockRouter/findActiveBlock.d.ts +0 -3
- package/mobile/lib/services/BlockRouter/findActiveBlock.js +0 -12
- package/mobile/lib/services/BlockRouter/findActiveBlock.js.map +0 -1
- package/mobile/lib/services/BlockRouter/useBlockIntersectionObserver.d.ts +0 -4
- package/mobile/lib/services/BlockRouter/useBlockIntersectionObserver.js +0 -14
- package/mobile/lib/services/BlockRouter/useBlockIntersectionObserver.js.map +0 -1
- package/mobile/lib/services/BlockRouter/useBlockRouterProvider.d.ts +0 -1
- package/mobile/lib/services/BlockRouter/useBlockRouterProvider.js +0 -25
- package/mobile/lib/services/BlockRouter/useBlockRouterProvider.js.map +0 -1
- package/mobile/src/services/BlockRouter/BlockIntersection.ts +0 -3
- package/mobile/src/services/BlockRouter/BlockRouter.ts +0 -11
- package/mobile/src/services/BlockRouter/blockRouterEventBus.ts +0 -13
- package/mobile/src/services/BlockRouter/findActiveBlock.ts +0 -20
- package/mobile/src/services/BlockRouter/useBlockIntersectionObserver.ts +0 -20
- package/mobile/src/services/BlockRouter/useBlockRouterProvider.ts +0 -37
- package/src/services/BlockRouter/BlockIntersection.ts +0 -3
- package/src/services/BlockRouter/BlockRouter.ts +0 -11
- package/src/services/BlockRouter/blockRouterEventBus.ts +0 -13
- package/src/services/BlockRouter/findActiveBlock.ts +0 -20
- package/src/services/BlockRouter/useBlockIntersectionObserver.ts +0 -20
- 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 +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,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,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BlockIntersection.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/BlockIntersection.ts"],"names":[],"mappings":""}
|
|
@@ -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 +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,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,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,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 +0,0 @@
|
|
|
1
|
-
export declare function useBlockRouterProvider(scrollTarget?: EventTarget): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BlockIntersection.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/BlockIntersection.ts"],"names":[],"mappings":""}
|
|
@@ -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 +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,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,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BlockIntersection.js","sourceRoot":"","sources":["../../../src/services/BlockRouter/BlockIntersection.ts"],"names":[],"mappings":""}
|
|
@@ -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 +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,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,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"}
|