@animatter/react 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +6 -2
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alanshown
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @animatter/react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Optional React lifecycle hooks for the shared Animatter runtime. Peer dependencies: React >=18 and animatter ^0.1.0. Version 0.1.0 is packed locally from the monorepo; no npm publication is claimed.
|
|
4
|
+
|
|
5
|
+
useAnimatter returns {ref,world}; useSurface registers a ref and cleans up on unmount. Keep surface option objects stable. World options are captured on mount; configure the world for live changes.
|
|
6
|
+
|
|
7
|
+
[Usage and tests](https://github.com/Alanshown/Animatter.js/blob/main/README.md#framework-integrations). MIT.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
import { type AnimatterWorld, type SurfaceOptions, type WorldOptions } from "animatter";
|
|
3
|
+
/** Options are captured on mount. Use world.configure/setMode for live changes. */
|
|
4
|
+
export declare function useAnimatter(options?: Omit<WorldOptions, "root">): {
|
|
5
|
+
ref: RefObject<HTMLDivElement | null>;
|
|
6
|
+
world: AnimatterWorld | null;
|
|
7
|
+
};
|
|
8
|
+
/** Cleans up on world/options identity change, unmount, and React StrictMode remount. */
|
|
9
|
+
export declare function useSurface<T extends HTMLElement>(world: AnimatterWorld | null, options?: SurfaceOptions): RefObject<T | null>;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,WAAW,CAAC;AACnB,mFAAmF;AACnF,wBAAgB,YAAY,CAAC,OAAO,GAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAM,GAAG;IACtE,GAAG,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACtC,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC;CAC9B,CAaA;AACD,yFAAyF;AACzF,wBAAgB,UAAU,CAAC,CAAC,SAAS,WAAW,EAC9C,KAAK,EAAE,cAAc,GAAG,IAAI,EAC5B,OAAO,GAAE,cAAmB,GAC3B,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,CAMrB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { createWorld, } from "animatter";
|
|
3
|
+
/** Options are captured on mount. Use world.configure/setMode for live changes. */
|
|
4
|
+
export function useAnimatter(options = {}) {
|
|
5
|
+
const ref = useRef(null), initial = useRef(options);
|
|
6
|
+
const [world, setWorld] = useState(null);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (!ref.current)
|
|
9
|
+
return;
|
|
10
|
+
const instance = createWorld({ ...initial.current, root: ref.current });
|
|
11
|
+
setWorld(instance);
|
|
12
|
+
return () => {
|
|
13
|
+
instance.destroy();
|
|
14
|
+
};
|
|
15
|
+
}, []);
|
|
16
|
+
return { ref, world };
|
|
17
|
+
}
|
|
18
|
+
/** Cleans up on world/options identity change, unmount, and React StrictMode remount. */
|
|
19
|
+
export function useSurface(world, options = {}) {
|
|
20
|
+
const ref = useRef(null);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (world && ref.current)
|
|
23
|
+
return world.register(ref.current, options);
|
|
24
|
+
}, [world, options]);
|
|
25
|
+
return ref;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACpE,OAAO,EACL,WAAW,GAIZ,MAAM,WAAW,CAAC;AACnB,mFAAmF;AACnF,MAAM,UAAU,YAAY,CAAC,UAAsC,EAAE;IAInE,MAAM,GAAG,GAAG,MAAM,CAA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
],
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"animatter": "^0.1.0",
|
|
21
|
+
"react": ">=18"
|
|
22
|
+
},
|
|
23
|
+
"description": "React lifecycle hooks for the shared Animatter.js physics interaction runtime",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/Alanshown/Animatter.js.git",
|
|
27
|
+
"directory": "packages/react"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/Alanshown/Animatter.js#readme",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/Alanshown/Animatter.js/issues"
|
|
32
|
+
},
|
|
33
|
+
"author": "Alanshown",
|
|
34
|
+
"keywords": [
|
|
35
|
+
"physics",
|
|
36
|
+
"interaction",
|
|
37
|
+
"animation",
|
|
38
|
+
"typescript",
|
|
39
|
+
"web",
|
|
40
|
+
"react"
|
|
41
|
+
],
|
|
42
|
+
"sideEffects": false,
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public",
|
|
45
|
+
"registry": "https://registry.npmjs.org/"
|
|
46
|
+
}
|
|
47
|
+
}
|