poltrgeist-react 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/dist/index.cjs ADDED
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __objRest = (source, exclude) => {
24
+ var target = {};
25
+ for (var prop in source)
26
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
27
+ target[prop] = source[prop];
28
+ if (source != null && __getOwnPropSymbols)
29
+ for (var prop of __getOwnPropSymbols(source)) {
30
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
31
+ target[prop] = source[prop];
32
+ }
33
+ return target;
34
+ };
35
+ var __export = (target, all) => {
36
+ for (var name in all)
37
+ __defProp(target, name, { get: all[name], enumerable: true });
38
+ };
39
+ var __copyProps = (to, from, except, desc) => {
40
+ if (from && typeof from === "object" || typeof from === "function") {
41
+ for (let key of __getOwnPropNames(from))
42
+ if (!__hasOwnProp.call(to, key) && key !== except)
43
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
44
+ }
45
+ return to;
46
+ };
47
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
48
+
49
+ // src/index.ts
50
+ var index_exports = {};
51
+ __export(index_exports, {
52
+ Haunted: () => Haunted,
53
+ PoltrgeistProvider: () => PoltrgeistProvider,
54
+ usePoltrgeist: () => usePoltrgeist
55
+ });
56
+ module.exports = __toCommonJS(index_exports);
57
+
58
+ // src/PoltrgeistProvider.tsx
59
+ var import_react = require("react");
60
+ var import_poltrgeist = require("poltrgeist");
61
+ var import_jsx_runtime = require("react/jsx-runtime");
62
+ var PoltrgeistContext = (0, import_react.createContext)(null);
63
+ function PoltrgeistProvider({ children, options }) {
64
+ (0, import_react.useEffect)(() => {
65
+ import_poltrgeist.poltrgeist.haunt(options);
66
+ return () => import_poltrgeist.poltrgeist.release();
67
+ }, []);
68
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PoltrgeistContext.Provider, { value: import_poltrgeist.poltrgeist, children });
69
+ }
70
+
71
+ // src/usePoltrgeist.ts
72
+ var import_react2 = require("react");
73
+ var import_poltrgeist2 = require("poltrgeist");
74
+ function usePoltrgeist(effects) {
75
+ const cleanups = (0, import_react2.useRef)([]);
76
+ const ref = (0, import_react2.useCallback)(
77
+ (el) => {
78
+ cleanups.current.forEach((fn) => fn());
79
+ cleanups.current = [];
80
+ if (!el) return;
81
+ for (const effect of effects) {
82
+ import_poltrgeist2.poltrgeist.apply(el, effect);
83
+ }
84
+ },
85
+ [effects.join(",")]
86
+ );
87
+ return { ref };
88
+ }
89
+
90
+ // src/Haunted.tsx
91
+ var import_react3 = require("react");
92
+ var import_poltrgeist3 = require("poltrgeist");
93
+ var import_jsx_runtime2 = require("react/jsx-runtime");
94
+ function Haunted(_a) {
95
+ var _b = _a, {
96
+ as,
97
+ effects,
98
+ children
99
+ } = _b, rest = __objRest(_b, [
100
+ "as",
101
+ "effects",
102
+ "children"
103
+ ]);
104
+ const Tag = as != null ? as : "div";
105
+ const ref = (0, import_react3.useRef)(null);
106
+ (0, import_react3.useEffect)(() => {
107
+ if (!ref.current) return;
108
+ for (const effect of effects) {
109
+ import_poltrgeist3.poltrgeist.apply(ref.current, effect);
110
+ }
111
+ }, [effects.join(",")]);
112
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Tag, __spreadProps(__spreadValues({ ref }, rest), { children }));
113
+ }
114
+ // Annotate the CommonJS export names for ESM import in node:
115
+ 0 && (module.exports = {
116
+ Haunted,
117
+ PoltrgeistProvider,
118
+ usePoltrgeist
119
+ });
120
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/PoltrgeistProvider.tsx","../src/usePoltrgeist.ts","../src/Haunted.tsx"],"sourcesContent":["export { PoltrgeistProvider } from './PoltrgeistProvider'\nexport { usePoltrgeist } from './usePoltrgeist'\nexport { Haunted } from './Haunted'\n","import { useEffect, createContext, useContext } from 'react'\nimport type { ReactNode } from 'react'\nimport { poltrgeist } from 'poltrgeist'\nimport type { HauntOptions } from 'poltrgeist'\n\nconst PoltrgeistContext = createContext<typeof poltrgeist | null>(null)\n\nexport function usePoltrgeistContext(): typeof poltrgeist {\n const ctx = useContext(PoltrgeistContext)\n if (!ctx) throw new Error('usePoltrgeistContext must be used inside <PoltrgeistProvider>')\n return ctx\n}\n\ninterface Props {\n children: ReactNode\n options?: HauntOptions\n}\n\nexport function PoltrgeistProvider({ children, options }: Props) {\n useEffect(() => {\n poltrgeist.haunt(options)\n return () => poltrgeist.release()\n }, [])\n\n return (\n <PoltrgeistContext.Provider value={poltrgeist}>\n {children}\n </PoltrgeistContext.Provider>\n )\n}\n","import { useCallback, useRef } from 'react'\nimport { poltrgeist } from 'poltrgeist'\nimport type { EffectName } from 'poltrgeist'\n\nexport function usePoltrgeist(effects: EffectName[]) {\n const cleanups = useRef<(() => void)[]>([])\n\n const ref = useCallback(\n (el: HTMLElement | null) => {\n cleanups.current.forEach((fn) => fn())\n cleanups.current = []\n if (!el) return\n for (const effect of effects) {\n poltrgeist.apply(el, effect)\n }\n },\n [effects.join(',')],\n )\n\n return { ref }\n}\n","import { useEffect, useRef } from 'react'\nimport type { ReactNode, ElementType, ComponentPropsWithRef } from 'react'\nimport { poltrgeist } from 'poltrgeist'\nimport type { EffectName } from 'poltrgeist'\n\ntype HauntedProps<T extends ElementType> = {\n as?: T\n effects: EffectName[]\n children?: ReactNode\n} & Omit<ComponentPropsWithRef<T>, 'as' | 'effects'>\n\nexport function Haunted<T extends ElementType = 'div'>({\n as,\n effects,\n children,\n ...rest\n}: HauntedProps<T>) {\n const Tag = (as ?? 'div') as ElementType\n const ref = useRef<HTMLElement>(null)\n\n useEffect(() => {\n if (!ref.current) return\n for (const effect of effects) {\n poltrgeist.apply(ref.current, effect)\n }\n }, [effects.join(',')])\n\n return (\n <Tag ref={ref} {...rest}>\n {children}\n </Tag>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAqD;AAErD,wBAA2B;AAuBvB;AApBJ,IAAM,wBAAoB,4BAAwC,IAAI;AAa/D,SAAS,mBAAmB,EAAE,UAAU,QAAQ,GAAU;AAC/D,8BAAU,MAAM;AACd,iCAAW,MAAM,OAAO;AACxB,WAAO,MAAM,6BAAW,QAAQ;AAAA,EAClC,GAAG,CAAC,CAAC;AAEL,SACE,4CAAC,kBAAkB,UAAlB,EAA2B,OAAO,8BAChC,UACH;AAEJ;;;AC7BA,IAAAA,gBAAoC;AACpC,IAAAC,qBAA2B;AAGpB,SAAS,cAAc,SAAuB;AACnD,QAAM,eAAW,sBAAuB,CAAC,CAAC;AAE1C,QAAM,UAAM;AAAA,IACV,CAAC,OAA2B;AAC1B,eAAS,QAAQ,QAAQ,CAAC,OAAO,GAAG,CAAC;AACrC,eAAS,UAAU,CAAC;AACpB,UAAI,CAAC,GAAI;AACT,iBAAW,UAAU,SAAS;AAC5B,sCAAW,MAAM,IAAI,MAAM;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,CAAC,QAAQ,KAAK,GAAG,CAAC;AAAA,EACpB;AAEA,SAAO,EAAE,IAAI;AACf;;;ACpBA,IAAAC,gBAAkC;AAElC,IAAAC,qBAA2B;AA0BvB,IAAAC,sBAAA;AAjBG,SAAS,QAAuC,IAKnC;AALmC,eACrD;AAAA;AAAA,IACA;AAAA,IACA;AAAA,EAdF,IAWuD,IAIlD,iBAJkD,IAIlD;AAAA,IAHH;AAAA,IACA;AAAA,IACA;AAAA;AAGA,QAAM,MAAO,kBAAM;AACnB,QAAM,UAAM,sBAAoB,IAAI;AAEpC,+BAAU,MAAM;AACd,QAAI,CAAC,IAAI,QAAS;AAClB,eAAW,UAAU,SAAS;AAC5B,oCAAW,MAAM,IAAI,SAAS,MAAM;AAAA,IACtC;AAAA,EACF,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,CAAC;AAEtB,SACE,6CAAC,oCAAI,OAAc,OAAlB,EACE,WACH;AAEJ;","names":["import_react","import_poltrgeist","import_react","import_poltrgeist","import_jsx_runtime"]}
@@ -0,0 +1,22 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ElementType, ComponentPropsWithRef } from 'react';
3
+ import { HauntOptions, EffectName } from 'poltrgeist';
4
+
5
+ interface Props {
6
+ children: ReactNode;
7
+ options?: HauntOptions;
8
+ }
9
+ declare function PoltrgeistProvider({ children, options }: Props): react.JSX.Element;
10
+
11
+ declare function usePoltrgeist(effects: EffectName[]): {
12
+ ref: (el: HTMLElement | null) => void;
13
+ };
14
+
15
+ type HauntedProps<T extends ElementType> = {
16
+ as?: T;
17
+ effects: EffectName[];
18
+ children?: ReactNode;
19
+ } & Omit<ComponentPropsWithRef<T>, 'as' | 'effects'>;
20
+ declare function Haunted<T extends ElementType = 'div'>({ as, effects, children, ...rest }: HauntedProps<T>): react.JSX.Element;
21
+
22
+ export { Haunted, PoltrgeistProvider, usePoltrgeist };
@@ -0,0 +1,22 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ElementType, ComponentPropsWithRef } from 'react';
3
+ import { HauntOptions, EffectName } from 'poltrgeist';
4
+
5
+ interface Props {
6
+ children: ReactNode;
7
+ options?: HauntOptions;
8
+ }
9
+ declare function PoltrgeistProvider({ children, options }: Props): react.JSX.Element;
10
+
11
+ declare function usePoltrgeist(effects: EffectName[]): {
12
+ ref: (el: HTMLElement | null) => void;
13
+ };
14
+
15
+ type HauntedProps<T extends ElementType> = {
16
+ as?: T;
17
+ effects: EffectName[];
18
+ children?: ReactNode;
19
+ } & Omit<ComponentPropsWithRef<T>, 'as' | 'effects'>;
20
+ declare function Haunted<T extends ElementType = 'div'>({ as, effects, children, ...rest }: HauntedProps<T>): react.JSX.Element;
21
+
22
+ export { Haunted, PoltrgeistProvider, usePoltrgeist };
package/dist/index.js ADDED
@@ -0,0 +1,94 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+
33
+ // src/PoltrgeistProvider.tsx
34
+ import { useEffect, createContext, useContext } from "react";
35
+ import { poltrgeist } from "poltrgeist";
36
+ import { jsx } from "react/jsx-runtime";
37
+ var PoltrgeistContext = createContext(null);
38
+ function PoltrgeistProvider({ children, options }) {
39
+ useEffect(() => {
40
+ poltrgeist.haunt(options);
41
+ return () => poltrgeist.release();
42
+ }, []);
43
+ return /* @__PURE__ */ jsx(PoltrgeistContext.Provider, { value: poltrgeist, children });
44
+ }
45
+
46
+ // src/usePoltrgeist.ts
47
+ import { useCallback, useRef } from "react";
48
+ import { poltrgeist as poltrgeist2 } from "poltrgeist";
49
+ function usePoltrgeist(effects) {
50
+ const cleanups = useRef([]);
51
+ const ref = useCallback(
52
+ (el) => {
53
+ cleanups.current.forEach((fn) => fn());
54
+ cleanups.current = [];
55
+ if (!el) return;
56
+ for (const effect of effects) {
57
+ poltrgeist2.apply(el, effect);
58
+ }
59
+ },
60
+ [effects.join(",")]
61
+ );
62
+ return { ref };
63
+ }
64
+
65
+ // src/Haunted.tsx
66
+ import { useEffect as useEffect2, useRef as useRef2 } from "react";
67
+ import { poltrgeist as poltrgeist3 } from "poltrgeist";
68
+ import { jsx as jsx2 } from "react/jsx-runtime";
69
+ function Haunted(_a) {
70
+ var _b = _a, {
71
+ as,
72
+ effects,
73
+ children
74
+ } = _b, rest = __objRest(_b, [
75
+ "as",
76
+ "effects",
77
+ "children"
78
+ ]);
79
+ const Tag = as != null ? as : "div";
80
+ const ref = useRef2(null);
81
+ useEffect2(() => {
82
+ if (!ref.current) return;
83
+ for (const effect of effects) {
84
+ poltrgeist3.apply(ref.current, effect);
85
+ }
86
+ }, [effects.join(",")]);
87
+ return /* @__PURE__ */ jsx2(Tag, __spreadProps(__spreadValues({ ref }, rest), { children }));
88
+ }
89
+ export {
90
+ Haunted,
91
+ PoltrgeistProvider,
92
+ usePoltrgeist
93
+ };
94
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/PoltrgeistProvider.tsx","../src/usePoltrgeist.ts","../src/Haunted.tsx"],"sourcesContent":["import { useEffect, createContext, useContext } from 'react'\nimport type { ReactNode } from 'react'\nimport { poltrgeist } from 'poltrgeist'\nimport type { HauntOptions } from 'poltrgeist'\n\nconst PoltrgeistContext = createContext<typeof poltrgeist | null>(null)\n\nexport function usePoltrgeistContext(): typeof poltrgeist {\n const ctx = useContext(PoltrgeistContext)\n if (!ctx) throw new Error('usePoltrgeistContext must be used inside <PoltrgeistProvider>')\n return ctx\n}\n\ninterface Props {\n children: ReactNode\n options?: HauntOptions\n}\n\nexport function PoltrgeistProvider({ children, options }: Props) {\n useEffect(() => {\n poltrgeist.haunt(options)\n return () => poltrgeist.release()\n }, [])\n\n return (\n <PoltrgeistContext.Provider value={poltrgeist}>\n {children}\n </PoltrgeistContext.Provider>\n )\n}\n","import { useCallback, useRef } from 'react'\nimport { poltrgeist } from 'poltrgeist'\nimport type { EffectName } from 'poltrgeist'\n\nexport function usePoltrgeist(effects: EffectName[]) {\n const cleanups = useRef<(() => void)[]>([])\n\n const ref = useCallback(\n (el: HTMLElement | null) => {\n cleanups.current.forEach((fn) => fn())\n cleanups.current = []\n if (!el) return\n for (const effect of effects) {\n poltrgeist.apply(el, effect)\n }\n },\n [effects.join(',')],\n )\n\n return { ref }\n}\n","import { useEffect, useRef } from 'react'\nimport type { ReactNode, ElementType, ComponentPropsWithRef } from 'react'\nimport { poltrgeist } from 'poltrgeist'\nimport type { EffectName } from 'poltrgeist'\n\ntype HauntedProps<T extends ElementType> = {\n as?: T\n effects: EffectName[]\n children?: ReactNode\n} & Omit<ComponentPropsWithRef<T>, 'as' | 'effects'>\n\nexport function Haunted<T extends ElementType = 'div'>({\n as,\n effects,\n children,\n ...rest\n}: HauntedProps<T>) {\n const Tag = (as ?? 'div') as ElementType\n const ref = useRef<HTMLElement>(null)\n\n useEffect(() => {\n if (!ref.current) return\n for (const effect of effects) {\n poltrgeist.apply(ref.current, effect)\n }\n }, [effects.join(',')])\n\n return (\n <Tag ref={ref} {...rest}>\n {children}\n </Tag>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,WAAW,eAAe,kBAAkB;AAErD,SAAS,kBAAkB;AAuBvB;AApBJ,IAAM,oBAAoB,cAAwC,IAAI;AAa/D,SAAS,mBAAmB,EAAE,UAAU,QAAQ,GAAU;AAC/D,YAAU,MAAM;AACd,eAAW,MAAM,OAAO;AACxB,WAAO,MAAM,WAAW,QAAQ;AAAA,EAClC,GAAG,CAAC,CAAC;AAEL,SACE,oBAAC,kBAAkB,UAAlB,EAA2B,OAAO,YAChC,UACH;AAEJ;;;AC7BA,SAAS,aAAa,cAAc;AACpC,SAAS,cAAAA,mBAAkB;AAGpB,SAAS,cAAc,SAAuB;AACnD,QAAM,WAAW,OAAuB,CAAC,CAAC;AAE1C,QAAM,MAAM;AAAA,IACV,CAAC,OAA2B;AAC1B,eAAS,QAAQ,QAAQ,CAAC,OAAO,GAAG,CAAC;AACrC,eAAS,UAAU,CAAC;AACpB,UAAI,CAAC,GAAI;AACT,iBAAW,UAAU,SAAS;AAC5B,QAAAA,YAAW,MAAM,IAAI,MAAM;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,CAAC,QAAQ,KAAK,GAAG,CAAC;AAAA,EACpB;AAEA,SAAO,EAAE,IAAI;AACf;;;ACpBA,SAAS,aAAAC,YAAW,UAAAC,eAAc;AAElC,SAAS,cAAAC,mBAAkB;AA0BvB,gBAAAC,YAAA;AAjBG,SAAS,QAAuC,IAKnC;AALmC,eACrD;AAAA;AAAA,IACA;AAAA,IACA;AAAA,EAdF,IAWuD,IAIlD,iBAJkD,IAIlD;AAAA,IAHH;AAAA,IACA;AAAA,IACA;AAAA;AAGA,QAAM,MAAO,kBAAM;AACnB,QAAM,MAAMC,QAAoB,IAAI;AAEpC,EAAAC,WAAU,MAAM;AACd,QAAI,CAAC,IAAI,QAAS;AAClB,eAAW,UAAU,SAAS;AAC5B,MAAAC,YAAW,MAAM,IAAI,SAAS,MAAM;AAAA,IACtC;AAAA,EACF,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,CAAC;AAEtB,SACE,gBAAAH,KAAC,oCAAI,OAAc,OAAlB,EACE,WACH;AAEJ;","names":["poltrgeist","useEffect","useRef","poltrgeist","jsx","useRef","useEffect","poltrgeist"]}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "poltrgeist-react",
3
+ "version": "0.1.0",
4
+ "description": "React bindings for poltrgeist",
5
+ "keywords": [
6
+ "react",
7
+ "ui",
8
+ "effects",
9
+ "animation",
10
+ "fun"
11
+ ],
12
+ "license": "MIT",
13
+ "type": "module",
14
+ "main": "./dist/index.cjs",
15
+ "module": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js",
21
+ "require": "./dist/index.cjs"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "peerDependencies": {
28
+ "react": ">=17",
29
+ "react-dom": ">=17"
30
+ },
31
+ "dependencies": {
32
+ "poltrgeist": "0.1.0"
33
+ },
34
+ "devDependencies": {
35
+ "tsup": "^8.0.0",
36
+ "typescript": "^5.5.0",
37
+ "@types/react": "^18.0.0",
38
+ "@types/react-dom": "^18.0.0"
39
+ },
40
+ "scripts": {
41
+ "build": "tsup",
42
+ "typecheck": "tsc --noEmit"
43
+ }
44
+ }