@lynx-js/motion 0.0.2 → 0.0.3
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 +6 -0
- package/dist/hooks/useMotionValueRef.d.ts +2 -1
- package/dist/hooks/useMotionValueRef.js +1 -16
- package/dist/hooks/useMotionValueRefCore.d.ts +2 -0
- package/dist/hooks/useMotionValueRefCore.js +17 -0
- package/dist/mini/index.d.ts +1 -1
- package/dist/mini/index.js +2 -2
- package/dist/mini/polyfill.d.ts +1 -0
- package/dist/mini/polyfill.js +14 -0
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { MotionValue } from 'motion-dom';
|
|
2
2
|
import type { MainThreadRef } from '@lynx-js/react';
|
|
3
|
-
|
|
3
|
+
import { useMotionValueRefCore } from './useMotionValueRefCore.js';
|
|
4
|
+
export { useMotionValueRefCore };
|
|
4
5
|
/**
|
|
5
6
|
* @experimental useMotionValue, but in MainThreadRef format, highly experimental, subject to change
|
|
6
7
|
*/
|
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { runWorkletCtx } from "@lynx-js/react/worklet-runtime/bindings";
|
|
1
|
+
import { useMotionValueRefCore } from "./useMotionValueRefCore.js";
|
|
3
2
|
import { motionValue } from "../animation/index.js";
|
|
4
|
-
function useMotionValueRefCore(value, make) {
|
|
5
|
-
const motionValueRef = useMainThreadRef();
|
|
6
|
-
useMemo(()=>{
|
|
7
|
-
function setMotionValue(value) {
|
|
8
|
-
'main thread';
|
|
9
|
-
if (!motionValueRef.current) motionValueRef.current = make(value);
|
|
10
|
-
}
|
|
11
|
-
if (__BACKGROUND__) runOnMainThread(setMotionValue)(value);
|
|
12
|
-
else runWorkletCtx(setMotionValue, [
|
|
13
|
-
value
|
|
14
|
-
]);
|
|
15
|
-
}, []);
|
|
16
|
-
return motionValueRef;
|
|
17
|
-
}
|
|
18
3
|
function useMotionValueRef(value) {
|
|
19
4
|
return useMotionValueRefCore(value, motionValue);
|
|
20
5
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { runOnMainThread, useMainThreadRef, useMemo } from "@lynx-js/react";
|
|
2
|
+
import { runWorkletCtx } from "@lynx-js/react/worklet-runtime/bindings";
|
|
3
|
+
function useMotionValueRefCore(value, make) {
|
|
4
|
+
const motionValueRef = useMainThreadRef();
|
|
5
|
+
useMemo(()=>{
|
|
6
|
+
function setMotionValue(value) {
|
|
7
|
+
'main thread';
|
|
8
|
+
if (!motionValueRef.current) motionValueRef.current = make(value);
|
|
9
|
+
}
|
|
10
|
+
if (__BACKGROUND__) runOnMainThread(setMotionValue)(value);
|
|
11
|
+
else runWorkletCtx(setMotionValue, [
|
|
12
|
+
value
|
|
13
|
+
]);
|
|
14
|
+
}, []);
|
|
15
|
+
return motionValueRef;
|
|
16
|
+
}
|
|
17
|
+
export { useMotionValueRefCore };
|
package/dist/mini/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MainThreadRef } from '@lynx-js/react';
|
|
2
|
-
import '
|
|
2
|
+
import './polyfill.js';
|
|
3
3
|
import type { MotionValue, MotionValueEventCallbacks } from './core/MotionValue.js';
|
|
4
4
|
export { animate, anticipate, backIn, backInOut, backOut, circIn, circInOut, circOut, easeIn, easeInOut, easeOut, linear, } from './core/animate.js';
|
|
5
5
|
export type { AnimationOptions, Easing } from './core/animate.js';
|
package/dist/mini/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "./polyfill.js";
|
|
2
2
|
import { useMotionValueRefEvent } from "../hooks/useMotionEvent.js";
|
|
3
|
-
import { useMotionValueRefCore } from "../hooks/
|
|
3
|
+
import { useMotionValueRefCore } from "../hooks/useMotionValueRefCore.js";
|
|
4
4
|
import { createMotionValue } from "./core/MotionValue.js";
|
|
5
5
|
import { animate, anticipate, backIn, backInOut, backOut, circIn, circInOut, circOut, easeIn, easeInOut, easeOut, linear } from "./core/animate.js";
|
|
6
6
|
import { spring } from "./core/spring.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function shimQueueMicroTask() {
|
|
2
|
+
if (!globalThis.queueMicrotask) if ("u" > typeof lynx && lynx.queueMicrotask) globalThis.queueMicrotask = lynx.queueMicrotask;
|
|
3
|
+
else {
|
|
4
|
+
const resolved = globalThis.Promise.resolve();
|
|
5
|
+
globalThis.queueMicrotask = (fn)=>{
|
|
6
|
+
resolved.then(fn).catch((err)=>{
|
|
7
|
+
setTimeout(()=>{
|
|
8
|
+
throw err;
|
|
9
|
+
}, 0);
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
shimQueueMicroTask();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/motion",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "This is a motion adapter for Lynx.js",
|
|
6
6
|
"keywords": [
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "Apache-2.0",
|
|
18
18
|
"sideEffects": [
|
|
19
|
-
"./dist/polyfill/shim.js"
|
|
19
|
+
"./dist/polyfill/shim.js",
|
|
20
|
+
"./dist/mini/polyfill.js"
|
|
20
21
|
],
|
|
21
22
|
"type": "module",
|
|
22
23
|
"exports": {
|
|
@@ -41,14 +42,14 @@
|
|
|
41
42
|
"CHANGELOG.md"
|
|
42
43
|
],
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"framer-motion": "12.
|
|
45
|
+
"framer-motion": "12.34.1",
|
|
45
46
|
"motion-dom": "12.23.12",
|
|
46
47
|
"motion-utils": "12.23.6"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@lynx-js/types": "3.
|
|
50
|
+
"@lynx-js/types": "3.7.0",
|
|
50
51
|
"rsbuild-plugin-publint": "0.3.4",
|
|
51
|
-
"@lynx-js/react": "0.116.
|
|
52
|
+
"@lynx-js/react": "0.116.3"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|
|
54
55
|
"@lynx-js/react": "*",
|