Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/core-internal-entries-page-control.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astryxdesign/core': patch
---

[chore] Internal: `@astryxdesign/core/internal/touch` also re-exports an element's shared animator, the Reduce Motion cross-fade, and the coarse-pointer touch hit area's hook and layer, for Lab's PageControl. It is an internal entry reserved for Astryx's own packages, outside the public API.

@vjeux
22 changes: 22 additions & 0 deletions packages/core/src/internal/touch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,28 @@ describe('internal/touch', () => {
}
});

it("re-exports by name what Lab's PageControl also reads", async () => {
const entry: Record<string, unknown> = await import('./touch');
const animator = await import('../motion/animator');
const reduced = await import('../motion/reducedMotion');
const hitArea = await import('../utils/touchHitArea');
const hitAreaStyles = await import('../utils/touchHitArea.stylex');
expect(entry.animatorFor).toBe(animator.animatorFor);
expect(entry.reducedMotionFade).toBe(reduced.reducedMotionFade);
expect(entry.useTouchHitArea).toBe(hitArea.useTouchHitArea);
expect(entry.touchHitAreaStyles).toBe(hitAreaStyles.touchHitAreaStyles);
// An identity check passes when both sides are undefined, so each name
// must also be defined.
for (const name of [
'animatorFor',
'reducedMotionFade',
'useTouchHitArea',
]) {
expect(typeof entry[name], name).toBe('function');
}
expect(entry.touchHitAreaStyles).toBeDefined();
});

it('attaches no window or document listeners when it loads', async () => {
vi.resetModules();
const onWindow = vi.spyOn(window, 'addEventListener');
Expand Down
15 changes: 11 additions & 4 deletions packages/core/src/internal/touch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
/**
* @file touch.ts
* @input The gesture core: the arena, the recognizers, and their geometry;
* the pan, the motion engine and math, and the touch-presentation and
* direction helpers that Lab components read
* the pan, the motion engine and math, and the touch-presentation,
* direction and hit-area helpers that Lab components read
* @output `@astryxdesign/core/internal/touch`: the gesture core's primitives

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: @output still says "the gesture core's primitives", but the entry now also carries the motion engine, curve helpers, hit-area watcher and direction read, and the header is 20 lines (file headers stay near 12). Suggested: @input Core's gesture, motion, touch and direction modules and @output @astryxdesign/core/internal/touch: those modules for Lab, by name.

* and the motion, touch-presentation and direction modules for Lab
* components, re-exported by name
* and the motion, touch-presentation, direction and hit-area modules for
* Lab components, re-exported by name
* @position An internal entry reserved for Astryx's own packages:
* undocumented, outside the public API and its compatibility promise
* (spec:AST-017 FR21), versioned in lockstep with Core, and allowed only in
Expand Down Expand Up @@ -80,3 +80,10 @@ export {isRtlElement} from '../hooks/isRtlElement';
export {UIKIT_GESTURES} from '../motion/uikit/gestures';
export {useTouchPresentation} from '../utils/touchPresentation';
export {TOUCH_QUERY} from '../utils/touchQueries';

// Lab's PageControl also reads an element's shared animator, the Reduce
// Motion cross-fade, and the touch hit area's hook and layer.
Comment on lines +110 to +111

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking (INV29): this comment restates the four names below it in words. Keep only the reason:

// Lab's PageControl reads these.

export {animatorFor} from '../motion/animator';
export {reducedMotionFade} from '../motion/reducedMotion';
export {useTouchHitArea} from '../utils/touchHitArea';
export {touchHitAreaStyles} from '../utils/touchHitArea.stylex';
8 changes: 7 additions & 1 deletion scripts/touch-support-bundle.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ function exportsOf(entry) {
* refresh pull reads the pan, its hook, the motion engine, its motion math and
* companion curves, the scroll view's spring and the motion-role parsers.
* Other Lab components read the UIKit gesture table, the touch presentation
* and its query, and an element's direction.
* and its query, and an element's direction. PageControl also reads an
* element's shared animator, the Reduce Motion cross-fade, and the touch hit
* area's hook and layer.
*/
const LAB_ONLY_NAMES = [
'PanGestureRecognizer',
Expand All @@ -132,6 +134,10 @@ const LAB_ONLY_NAMES = [
'UIKIT_GESTURES',
'useTouchPresentation',
'TOUCH_QUERY',
'animatorFor',
'reducedMotionFade',
'useTouchHitArea',
'touchHitAreaStyles',
];

/** The inputs matching `pattern` that put bytes in `bytes`. */
Expand Down
Loading