use-scroll-animate 4.5.0 → 4.7.0
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/CHANGELOG.md +17 -0
- package/dist/components/angular.cjs +1 -0
- package/dist/components/angular.cjs.map +1 -1
- package/dist/components/angular.js +1 -0
- package/dist/components/angular.js.map +1 -1
- package/dist/components/bridge.cjs +154 -0
- package/dist/components/bridge.cjs.map +1 -0
- package/dist/components/bridge.d.cts +63 -0
- package/dist/components/bridge.d.ts +63 -0
- package/dist/components/bridge.js +147 -0
- package/dist/components/bridge.js.map +1 -0
- package/dist/components/lite.cjs +149 -0
- package/dist/components/lite.cjs.map +1 -1
- package/dist/components/lite.js +144 -1
- package/dist/components/lite.js.map +1 -1
- package/dist/components/solid.cjs +1 -0
- package/dist/components/solid.cjs.map +1 -1
- package/dist/components/solid.js +1 -0
- package/dist/components/solid.js.map +1 -1
- package/dist/components/svelte.cjs +1 -0
- package/dist/components/svelte.cjs.map +1 -1
- package/dist/components/svelte.js +1 -0
- package/dist/components/svelte.js.map +1 -1
- package/dist/components/vue.cjs +1 -0
- package/dist/components/vue.cjs.map +1 -1
- package/dist/components/vue.js +1 -0
- package/dist/components/vue.js.map +1 -1
- package/dist/components.cjs +7 -0
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +61 -2
- package/dist/components.d.ts +61 -2
- package/dist/components.js +1 -0
- package/dist/components.js.map +1 -1
- package/dist/components.umd.js +3 -2
- package/dist/components.umd.js.map +1 -1
- package/docs/ROADMAP.md +2 -2
- package/docs/hybrid-apps.md +15 -0
- package/package.json +11 -1
package/dist/components/lite.js
CHANGED
|
@@ -10091,6 +10091,149 @@ function auditMotionA11y(root) {
|
|
|
10091
10091
|
/** Every `<usa-*>` tag, for sweeping audits. */
|
|
10092
10092
|
const ALL_TAGS = Object.values(COMPONENT_CATEGORIES).flat();
|
|
10093
10093
|
|
|
10094
|
+
/**
|
|
10095
|
+
* use-scroll-animate/components/bridge — native shell bridges (4.7).
|
|
10096
|
+
*
|
|
10097
|
+
* Keeps the web UI in sync with the host app's system settings when it runs
|
|
10098
|
+
* inside **WinUI 3 / WPF (WebView2)**, **.NET MAUI** (WebView / HybridWebView)
|
|
10099
|
+
* or **Flutter** (webview_flutter / flutter_inappwebview): the native side
|
|
10100
|
+
* sends "reduce motion", light / dark / high-contrast theme and accent color;
|
|
10101
|
+
* the page applies them to every `<usa-*>` component.
|
|
10102
|
+
*
|
|
10103
|
+
* Protocol (JSON, both directions):
|
|
10104
|
+
* - native → web `{ "type": "usa:settings", "reducedMotion": true, "theme": "dark", "accent": "#0078d4", "sensitivity": "gentle" }`
|
|
10105
|
+
* - web → native `{ "type": "usa:ready", "version": 1 }` on connect, `{ "type": "usa:request-settings" }`
|
|
10106
|
+
*
|
|
10107
|
+
* Hosts that can only run script call `window.usaNative.apply({...})`.
|
|
10108
|
+
* Samples: examples/native/{winui3,maui,flutter}.
|
|
10109
|
+
*/
|
|
10110
|
+
const BRIDGE_PROTOCOL_VERSION = 1;
|
|
10111
|
+
const win = () => (typeof window === 'undefined' ? null : window);
|
|
10112
|
+
/** Which native shell (if any) hosts this page. */
|
|
10113
|
+
function detectNativeHost(channel = 'UsaBridge') {
|
|
10114
|
+
const w = win();
|
|
10115
|
+
if (!w)
|
|
10116
|
+
return 'browser';
|
|
10117
|
+
if (w.chrome?.webview?.postMessage)
|
|
10118
|
+
return 'webview2';
|
|
10119
|
+
if (w.HybridWebView?.SendRawMessage || w.HybridWebView?.SendRawMessageToDotNet || /\bMAUI\b/i.test(w.navigator?.userAgent || ''))
|
|
10120
|
+
return 'maui';
|
|
10121
|
+
if (w.flutter_inappwebview?.callHandler || w[channel]?.postMessage)
|
|
10122
|
+
return 'flutter';
|
|
10123
|
+
if (w.__TAURI__ || w.__TAURI_INTERNALS__)
|
|
10124
|
+
return 'tauri';
|
|
10125
|
+
if (w.process?.versions?.electron || /Electron\//.test(w.navigator?.userAgent || ''))
|
|
10126
|
+
return 'electron';
|
|
10127
|
+
return 'browser';
|
|
10128
|
+
}
|
|
10129
|
+
/** Send a JSON message to the native host (no-op in a plain browser). Returns whether it was sent. */
|
|
10130
|
+
function postToNative(message, channel = 'UsaBridge') {
|
|
10131
|
+
const w = win();
|
|
10132
|
+
if (!w)
|
|
10133
|
+
return false;
|
|
10134
|
+
const json = JSON.stringify(message);
|
|
10135
|
+
try {
|
|
10136
|
+
if (w.chrome?.webview?.postMessage)
|
|
10137
|
+
return w.chrome.webview.postMessage(message), true;
|
|
10138
|
+
if (w.HybridWebView?.SendRawMessage)
|
|
10139
|
+
return w.HybridWebView.SendRawMessage(json), true;
|
|
10140
|
+
if (w.HybridWebView?.SendRawMessageToDotNet)
|
|
10141
|
+
return w.HybridWebView.SendRawMessageToDotNet(json), true;
|
|
10142
|
+
if (w.flutter_inappwebview?.callHandler)
|
|
10143
|
+
return w.flutter_inappwebview.callHandler(channel, json), true;
|
|
10144
|
+
if (w[channel]?.postMessage)
|
|
10145
|
+
return w[channel].postMessage(json), true;
|
|
10146
|
+
}
|
|
10147
|
+
catch {
|
|
10148
|
+
/* host went away */
|
|
10149
|
+
}
|
|
10150
|
+
return false;
|
|
10151
|
+
}
|
|
10152
|
+
const THEMES = ['light', 'dark', 'high-contrast'];
|
|
10153
|
+
const COLOR = /^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%]+\)|hsla?\([\d\s.,%deg]+\))$/i;
|
|
10154
|
+
/** Validate an incoming message (string or object); unknown fields are dropped. */
|
|
10155
|
+
function parseNativeSettings(data) {
|
|
10156
|
+
let d = data;
|
|
10157
|
+
if (typeof d === 'string') {
|
|
10158
|
+
try {
|
|
10159
|
+
d = JSON.parse(d);
|
|
10160
|
+
}
|
|
10161
|
+
catch {
|
|
10162
|
+
return null;
|
|
10163
|
+
}
|
|
10164
|
+
}
|
|
10165
|
+
if (!d || typeof d !== 'object' || d.type !== 'usa:settings')
|
|
10166
|
+
return null;
|
|
10167
|
+
const out = {};
|
|
10168
|
+
if (typeof d.reducedMotion === 'boolean')
|
|
10169
|
+
out.reducedMotion = d.reducedMotion;
|
|
10170
|
+
if (THEMES.includes(d.theme))
|
|
10171
|
+
out.theme = d.theme;
|
|
10172
|
+
if (typeof d.accent === 'string' && COLOR.test(d.accent.trim()))
|
|
10173
|
+
out.accent = d.accent.trim();
|
|
10174
|
+
if (MOTION_SENSITIVITY_LEVELS.includes(d.sensitivity))
|
|
10175
|
+
out.sensitivity = d.sensitivity;
|
|
10176
|
+
return out;
|
|
10177
|
+
}
|
|
10178
|
+
/**
|
|
10179
|
+
* Apply native settings: reduce motion → `configureComponents({ reducedMotion: 'reduce' })`
|
|
10180
|
+
* (`false` → follow the media query again); theme → `data-theme`, `data-usa-contrast`
|
|
10181
|
+
* and `color-scheme`; accent → `--usa-accent`; sensitivity → `motionSensitivity`.
|
|
10182
|
+
*/
|
|
10183
|
+
function applyNativeSettings(s, root) {
|
|
10184
|
+
if (s.reducedMotion !== undefined)
|
|
10185
|
+
configureComponents({ reducedMotion: s.reducedMotion ? 'reduce' : 'user' });
|
|
10186
|
+
if (s.sensitivity)
|
|
10187
|
+
configureComponents({ motionSensitivity: s.sensitivity });
|
|
10188
|
+
const el = root || (typeof document !== 'undefined' ? document.documentElement : null);
|
|
10189
|
+
if (!el)
|
|
10190
|
+
return;
|
|
10191
|
+
if (s.theme) {
|
|
10192
|
+
el.setAttribute('data-theme', s.theme === 'high-contrast' ? 'dark' : s.theme);
|
|
10193
|
+
el.toggleAttribute('data-usa-contrast', s.theme === 'high-contrast');
|
|
10194
|
+
el.style.colorScheme = s.theme === 'light' ? 'light' : 'dark';
|
|
10195
|
+
}
|
|
10196
|
+
if (s.accent)
|
|
10197
|
+
el.style.setProperty('--usa-accent', s.accent);
|
|
10198
|
+
if (typeof document !== 'undefined')
|
|
10199
|
+
document.dispatchEvent(new CustomEvent('usa:native-settings', { detail: s }));
|
|
10200
|
+
}
|
|
10201
|
+
/**
|
|
10202
|
+
* Connect to the native shell: listens for `usa:settings` messages
|
|
10203
|
+
* (WebView2 `chrome.webview` messages, `window.postMessage`, or
|
|
10204
|
+
* `window.usaNative.apply()`), applies them, then announces `usa:ready` and
|
|
10205
|
+
* asks for the current settings. Returns `{ host, disconnect }`.
|
|
10206
|
+
*/
|
|
10207
|
+
function connectNativeShell(options = {}) {
|
|
10208
|
+
const w = win();
|
|
10209
|
+
const channel = options.channel || 'UsaBridge';
|
|
10210
|
+
const host = detectNativeHost(channel);
|
|
10211
|
+
if (!w)
|
|
10212
|
+
return { host, disconnect: () => undefined };
|
|
10213
|
+
const handle = (data) => {
|
|
10214
|
+
const s = parseNativeSettings(data);
|
|
10215
|
+
if (!s)
|
|
10216
|
+
return;
|
|
10217
|
+
applyNativeSettings(s, options.root);
|
|
10218
|
+
options.onSettings?.(s, host);
|
|
10219
|
+
};
|
|
10220
|
+
const onMessage = (e) => handle(e.data);
|
|
10221
|
+
w.chrome?.webview?.addEventListener?.('message', onMessage);
|
|
10222
|
+
w.addEventListener?.('message', onMessage);
|
|
10223
|
+
const prev = w.usaNative;
|
|
10224
|
+
w.usaNative = { apply: (s) => handle({ ...s, type: 'usa:settings' }), version: BRIDGE_PROTOCOL_VERSION, host };
|
|
10225
|
+
postToNative({ type: 'usa:ready', version: BRIDGE_PROTOCOL_VERSION }, channel);
|
|
10226
|
+
postToNative({ type: 'usa:request-settings' }, channel);
|
|
10227
|
+
return {
|
|
10228
|
+
host,
|
|
10229
|
+
disconnect: () => {
|
|
10230
|
+
w.chrome?.webview?.removeEventListener?.('message', onMessage);
|
|
10231
|
+
w.removeEventListener?.('message', onMessage);
|
|
10232
|
+
w.usaNative = prev;
|
|
10233
|
+
},
|
|
10234
|
+
};
|
|
10235
|
+
}
|
|
10236
|
+
|
|
10094
10237
|
/**
|
|
10095
10238
|
* use-scroll-animate/components
|
|
10096
10239
|
*
|
|
@@ -10157,5 +10300,5 @@ function defineComponents(categories) {
|
|
|
10157
10300
|
const STYLE_BASE = new URL('../', import.meta.url).href;
|
|
10158
10301
|
onDemandStyles(STYLE_BASE);
|
|
10159
10302
|
|
|
10160
|
-
export { ALL_TAGS, AMBIENT_EFFECTS, ANIM_ICONS, BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, CURSOR_MODES, JOINING_SCRIPT, LIVE_REGION_IDS, MASK_SHAPES, MORPH_ICONS, MOTION_SCALE, MOTION_SENSITIVITY, MOTION_SENSITIVITY_LEVELS, MOTION_TOKENS, PACKS, PACK_PRIMITIVES, PAGE_EFFECTS, REVEAL_EFFECTS, SENSITIVITY_CSS, SHADERS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, STATIC_ALTERNATIVES, STYLE_BASE, TIMELINE_PRESETS, VARIANTS, activeAnimations, adaptKeyframes, adoptVariants, animationBudget, announce, applyMotionTokens, applyPack, auditMotionA11y, autoAnimate, autoDegrade, burst, categoryOf, confetti, configureComponents, countUp, createSpring, defineAccordion, defineAcrylic, defineAmbient, defineAnimIcon, defineAurora, defineAutoAnimate, defineAutoSkeleton, defineAvatarStack, defineBackToTop, defineBackgroundComponents, defineBadge, defineBlobs, defineBottomSheet, defineButton, defineCard, defineCardComponents, defineCardStack, defineCarousel3d, defineCheck, defineCheckbox, defineClick, defineClickComponents, defineComponents, defineCounter, defineCube, defineCursor, defineDepth, defineDepthComponents, defineDialog, defineDistort, defineDotNetwork, defineDoubleTap, defineDraggable, defineDraw, defineDrawer, defineFab, defineFeedbackComponents, defineFullpage, defineGestureComponents, defineGlitch, defineGradientText, defineGrain, defineGridGlow, defineHandwriting, defineHold, defineIconMorph, defineInteractionComponents, defineLayoutComponents, defineLike, defineLiquid, defineLoadingBar, defineMagnetic, defineMarquee, defineMaskReveal, defineMasonry, defineMorph, defineMotionSwitch, defineNavbar, defineOverscroll, definePack, definePacksComponents, definePageComponents, defineParticles, definePhysicsComponents, definePinchZoom, definePopover, definePress, defineProgress, definePullRefresh, defineRating, defineReveal, defineRevealComponents, defineRipple, defineScramble, defineScrollHighlight, defineScrollProgress, defineScrolly, defineShader, defineShimmerText, defineSkeleton, defineSlider, defineSpinner, defineSplash, defineSplitText, defineSpotlight, defineSpring, defineStagger, defineStickyStack, defineSvgComponents, defineSwipeable, defineTabs, defineTextComponents, defineTextRotate, defineTilt, defineTimeline, defineTimelineComponents, defineToaster, defineToggle, defineTooltip, defineTransitionComponents, defineTypewriter, defineUiComponents, defineViewSwitch, defineWaterRipple, defineWaveText, defineWebglComponents, deviceTilt, drawLines, easeOutExpo, enableMpaTransitions, flip, flipFrames, fluentPreset, flyToCart, fragmentSource, gesture, getMotionIntensity, getMotionSensitivity, getMotionTokens, glQuad, graphemes, haptic, importMotionTokens, interpolatePath, linearEasing, liveRegion, loadCategoryStyles, loadedStyles, loadingBar, masonryLayout, mergeMotionTokens, morphPath, morphTo, motionAllowed, motionToken, motionTokensToCss, motionTokensToJSON, motionTokensToVars, motionVar, onDemandStyles, onFrame, orientationToTilt, pageTransition, parseDuration, parseEasing, pathsCompatible, pinchScale, prefersReducedMotion, projectInertia, readScrollProgress, requestOrientationPermission, resolveDurationToken, resolveEasingToken, resolvePosition, resolveSpring, restoreMotionIntensity, restoreMotionSensitivity, revealKeyframes, rubberBand, schedulerStats, scrambleFrame, scrollToTarget, setAnimationBudget, setMotionIntensity, setMotionSensitivity, setVariant, shake, sharedTransition, smoothScroll, snapTo, splitOrder, splitText, splitTimeline, words as splitWords, spring, springEasing, springEffectKeyframes, springSamples, staticAlternative, stepSpring, supportsLinearEasing, supportsNativeScrub, supportsOrientation, supportsViewTransitions, supportsWebGL, swipeDirection, themeTransition, timeline, toast, viewTransition };
|
|
10303
|
+
export { ALL_TAGS, AMBIENT_EFFECTS, ANIM_ICONS, BRIDGE_PROTOCOL_VERSION, BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, CURSOR_MODES, JOINING_SCRIPT, LIVE_REGION_IDS, MASK_SHAPES, MORPH_ICONS, MOTION_SCALE, MOTION_SENSITIVITY, MOTION_SENSITIVITY_LEVELS, MOTION_TOKENS, PACKS, PACK_PRIMITIVES, PAGE_EFFECTS, REVEAL_EFFECTS, SENSITIVITY_CSS, SHADERS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, STATIC_ALTERNATIVES, STYLE_BASE, TIMELINE_PRESETS, VARIANTS, activeAnimations, adaptKeyframes, adoptVariants, animationBudget, announce, applyMotionTokens, applyNativeSettings, applyPack, auditMotionA11y, autoAnimate, autoDegrade, burst, categoryOf, confetti, configureComponents, connectNativeShell, countUp, createSpring, defineAccordion, defineAcrylic, defineAmbient, defineAnimIcon, defineAurora, defineAutoAnimate, defineAutoSkeleton, defineAvatarStack, defineBackToTop, defineBackgroundComponents, defineBadge, defineBlobs, defineBottomSheet, defineButton, defineCard, defineCardComponents, defineCardStack, defineCarousel3d, defineCheck, defineCheckbox, defineClick, defineClickComponents, defineComponents, defineCounter, defineCube, defineCursor, defineDepth, defineDepthComponents, defineDialog, defineDistort, defineDotNetwork, defineDoubleTap, defineDraggable, defineDraw, defineDrawer, defineFab, defineFeedbackComponents, defineFullpage, defineGestureComponents, defineGlitch, defineGradientText, defineGrain, defineGridGlow, defineHandwriting, defineHold, defineIconMorph, defineInteractionComponents, defineLayoutComponents, defineLike, defineLiquid, defineLoadingBar, defineMagnetic, defineMarquee, defineMaskReveal, defineMasonry, defineMorph, defineMotionSwitch, defineNavbar, defineOverscroll, definePack, definePacksComponents, definePageComponents, defineParticles, definePhysicsComponents, definePinchZoom, definePopover, definePress, defineProgress, definePullRefresh, defineRating, defineReveal, defineRevealComponents, defineRipple, defineScramble, defineScrollHighlight, defineScrollProgress, defineScrolly, defineShader, defineShimmerText, defineSkeleton, defineSlider, defineSpinner, defineSplash, defineSplitText, defineSpotlight, defineSpring, defineStagger, defineStickyStack, defineSvgComponents, defineSwipeable, defineTabs, defineTextComponents, defineTextRotate, defineTilt, defineTimeline, defineTimelineComponents, defineToaster, defineToggle, defineTooltip, defineTransitionComponents, defineTypewriter, defineUiComponents, defineViewSwitch, defineWaterRipple, defineWaveText, defineWebglComponents, detectNativeHost, deviceTilt, drawLines, easeOutExpo, enableMpaTransitions, flip, flipFrames, fluentPreset, flyToCart, fragmentSource, gesture, getMotionIntensity, getMotionSensitivity, getMotionTokens, glQuad, graphemes, haptic, importMotionTokens, interpolatePath, linearEasing, liveRegion, loadCategoryStyles, loadedStyles, loadingBar, masonryLayout, mergeMotionTokens, morphPath, morphTo, motionAllowed, motionToken, motionTokensToCss, motionTokensToJSON, motionTokensToVars, motionVar, onDemandStyles, onFrame, orientationToTilt, pageTransition, parseDuration, parseEasing, parseNativeSettings, pathsCompatible, pinchScale, postToNative, prefersReducedMotion, projectInertia, readScrollProgress, requestOrientationPermission, resolveDurationToken, resolveEasingToken, resolvePosition, resolveSpring, restoreMotionIntensity, restoreMotionSensitivity, revealKeyframes, rubberBand, schedulerStats, scrambleFrame, scrollToTarget, setAnimationBudget, setMotionIntensity, setMotionSensitivity, setVariant, shake, sharedTransition, smoothScroll, snapTo, splitOrder, splitText, splitTimeline, words as splitWords, spring, springEasing, springEffectKeyframes, springSamples, staticAlternative, stepSpring, supportsLinearEasing, supportsNativeScrub, supportsOrientation, supportsViewTransitions, supportsWebGL, swipeDirection, themeTransition, timeline, toast, viewTransition };
|
|
10161
10304
|
//# sourceMappingURL=lite.js.map
|