@rivetkit/react 2.0.20 → 2.0.21
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/mod.js.map +1 -1
- package/package.json +3 -3
package/dist/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/nathan/rivetkit/packages/react/dist/mod.js","../src/mod.ts"],"names":["opts","actorState"],"mappings":"AAAA;ACAA;AAIC;AAAkB,yDACZ;AACP,mDAAyB;AACzB,8BAAkC;AAClC;AAEC;AAAA,yCAEM;AAEP;AAEO,SAAS,cAAA,CACf,WAAA,EACA,KAAA,EAAwC,CAAC,CAAA,EACxC;AACD,EAAA,OAAO,wBAAA;AAAA,IACN,kCAAA,WAAkC,CAAA;AAAA,IAClC;AAAA,EACD,CAAA;AACD;AAEO,SAAS,wBAAA,CACf,MAAA,EACA,KAAA,EAAwC,CAAC,CAAA,EACxC;AACD,EAAA,MAAM,EAAE,iBAAiB,EAAA,EAAI,2CAAA,MAI3B,EAAQ,IAAI,CAAA;AASd,EAAA,SAAS,QAAA,CAEPA,KAAAA,EAAyC;AAC1C,IAAA,MAAM,EAAE,KAAA,EAAO,QAAA,EAAU,MAAM,EAAA,EAAI,gBAAA,CAA4BA,KAAI,CAAA;AAEnE,IAAA,8BAAA,CAAU,EAAA,GAAM;AACf,MAAA,QAAA,CAAS,CAAC,IAAA,EAAA,GAAS;AAClB,QAAA,IAAA,CAAK,KAAA,EAAO;AAAA,UACX,GAAGA,KAAAA;AAAA,UACH,OAAA,mBAASA,KAAAA,CAAK,OAAA,UAAW;AAAA,QAC1B,CAAA;AACA,QAAA,OAAO,IAAA;AAAA,MACR,CAAC,CAAA;AAAA,IACF,CAAA,EAAG,CAACA,KAAAA,EAAM,QAAQ,CAAC,CAAA;AAEnB,IAAA,8BAAA,CAAU,EAAA,GAAM;AACf,MAAA,OAAO,KAAA,CAAM,CAAA;AAAA,IACd,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AAEV,IAAA,MAAM,WAAA,EAAa,kCAAA,KAAc,EAAA,GAAK,CAAC,CAAA;AAWvC,IAAA,SAAS,QAAA,CACR,SAAA,EAEA,OAAA,EACC;AACD,MAAA,MAAM,IAAA,EAAM,2BAAA,OAAc,CAAA;AAC1B,MAAA,MAAMC,YAAAA,EAAa,kCAAA,KAAc,EAAA,GAAK,CAAC,CAAA;AAEvC,MAAA,8BAAA,CAAU,EAAA,GAAM;AACf,QAAA,GAAA,CAAI,QAAA,EAAU,OAAA;AAAA,MACf,CAAA,EAAG,CAAC,OAAO,CAAC,CAAA;AAGZ,MAAA,8BAAA,CAAU,EAAA,GAAM;AACf,QAAA,GAAA,CAAI,CAAA,CAACA,YAAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAAA,WAAAA,CAAY,UAAA,CAAA,EAAY,MAAA;AAE7B,QAAA,SAAS,YAAA,CAAA,GAAgB,IAAA,EAAa;AACrC,UAAA,GAAA,CAAI,OAAA,CAAQ,GAAG,IAAI,CAAA;AAAA,QACpB;AACA,QAAA,OAAOA,WAAAA,CAAW,UAAA,CAAW,EAAA,CAAG,SAAA,EAAW,YAAY,CAAA;AAAA,MACxD,CAAA,EAAG;AAAA,QACFA,WAAAA,CAAW,UAAA;AAAA,QACXA,WAAAA,CAAW,WAAA;AAAA,QACXA,WAAAA,CAAW,IAAA;AAAA,QACX;AAAA,MACD,CAAC,CAAA;AAAA,IACF;AAEA,IAAA,OAAO;AAAA,MACN,GAAG,UAAA;AAAA,MACH;AAAA,IACD,CAAA;AAAA,EACD;AAEA,EAAA,OAAO;AAAA,IACN;AAAA,EACD,CAAA;AACD;ADjDA;AACE;AACA;AACA;AACF,kJAAC","file":"/Users/nathan/rivetkit/packages/react/dist/mod.js","sourcesContent":[null,"import {\n\ttype ActorOptions,\n\ttype AnyActorRegistry,\n\ttype CreateRivetKitOptions,\n\tcreateRivetKit as createVanillaRivetKit,\n} from \"@rivetkit/framework-base\";\nimport { useStore } from \"@tanstack/react-store\";\nimport { useEffect, useRef } from \"react\";\nimport {\n\ttype Client,\n\tcreateClient,\n\ttype ExtractActorsFromRegistry,\n} from \"rivetkit/client\";\n\nexport { createClient } from \"rivetkit/client\";\n\nexport function createRivetKit<Registry extends AnyActorRegistry>(\n\tclientInput: Parameters<typeof createClient>[0],\n\topts: CreateRivetKitOptions<Registry> = {},\n) {\n\treturn createRivetKitWithClient<Registry>(\n\t\tcreateClient<Registry>(clientInput),\n\t\topts,\n\t);\n}\n\nexport function createRivetKitWithClient<Registry extends AnyActorRegistry>(\n\tclient: Client<Registry>,\n\topts: CreateRivetKitOptions<Registry> = {},\n) {\n\tconst { getOrCreateActor } = createVanillaRivetKit<\n\t\tRegistry,\n\t\tExtractActorsFromRegistry<Registry>,\n\t\tkeyof ExtractActorsFromRegistry<Registry>\n\t>(client, opts);\n\n\t/**\n\t * Hook to connect to a actor and retrieve its state. Using this hook with the same options\n\t * will return the same actor instance. This simplifies passing around the actor state in your components.\n\t * It also provides a method to listen for events emitted by the actor.\n\t * @param opts - Options for the actor, including its name, key, and parameters.\n\t * @returns An object containing the actor's state and a method to listen for events.\n\t */\n\tfunction useActor<\n\t\tActorName extends keyof ExtractActorsFromRegistry<Registry>,\n\t>(opts: ActorOptions<Registry, ActorName>) {\n\t\tconst { mount, setState, state } = getOrCreateActor<ActorName>(opts);\n\n\t\tuseEffect(() => {\n\t\t\tsetState((prev) => {\n\t\t\t\tprev.opts = {\n\t\t\t\t\t...opts,\n\t\t\t\t\tenabled: opts.enabled ?? true,\n\t\t\t\t};\n\t\t\t\treturn prev;\n\t\t\t});\n\t\t}, [opts, setState]);\n\n\t\tuseEffect(() => {\n\t\t\treturn mount();\n\t\t}, [mount]);\n\n\t\tconst actorState = useStore(state) || {};\n\n\t\t/**\n\t\t * Hook to listen for events emitted by the actor.\n\t\t * This hook allows you to subscribe to specific events emitted by the actor and execute a handler function\n\t\t * when the event occurs.\n\t\t * It uses the `useEffect` hook to set up the event listener when the actor connection is established.\n\t\t * It cleans up the listener when the component unmounts or when the actor connection changes.\n\t\t * @param eventName The name of the event to listen for.\n\t\t * @param handler The function to call when the event is emitted.\n\t\t */\n\t\tfunction useEvent(\n\t\t\teventName: string,\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: strong typing of handler is not supported yet\n\t\t\thandler: (...args: any[]) => void,\n\t\t) {\n\t\t\tconst ref = useRef(handler);\n\t\t\tconst actorState = useStore(state) || {};\n\n\t\t\tuseEffect(() => {\n\t\t\t\tref.current = handler;\n\t\t\t}, [handler]);\n\n\t\t\t// biome-ignore lint/correctness/useExhaustiveDependencies: it's okay to not include all dependencies here\n\t\t\tuseEffect(() => {\n\t\t\t\tif (!actorState?.connection) return;\n\n\t\t\t\tfunction eventHandler(...args: any[]) {\n\t\t\t\t\tref.current(...args);\n\t\t\t\t}\n\t\t\t\treturn actorState.connection.on(eventName, eventHandler);\n\t\t\t}, [\n\t\t\t\tactorState.connection,\n\t\t\t\tactorState.isConnected,\n\t\t\t\tactorState.hash,\n\t\t\t\teventName,\n\t\t\t]);\n\t\t}\n\n\t\treturn {\n\t\t\t...actorState,\n\t\t\tuseEvent,\n\t\t};\n\t}\n\n\treturn {\n\t\tuseActor,\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/Users/nathan/rivet/rivetkit-typescript/packages/react/dist/mod.js","../src/mod.ts"],"names":["opts","actorState"],"mappings":"AAAA;ACAA;AAIC;AAAkB,yDACZ;AACP,mDAAyB;AACzB,8BAAkC;AAClC;AAEC;AAAA,yCAEM;AAEP;AAEO,SAAS,cAAA,CACf,WAAA,EACA,KAAA,EAAwC,CAAC,CAAA,EACxC;AACD,EAAA,OAAO,wBAAA;AAAA,IACN,kCAAA,WAAkC,CAAA;AAAA,IAClC;AAAA,EACD,CAAA;AACD;AAEO,SAAS,wBAAA,CACf,MAAA,EACA,KAAA,EAAwC,CAAC,CAAA,EACxC;AACD,EAAA,MAAM,EAAE,iBAAiB,EAAA,EAAI,2CAA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CAAA;AAAA,QACpB;AACA,QAAA,OAAOA,WAAAA,CAAW,UAAA,CAAW,EAAA,CAAG,SAAA,EAAW,YAAY,CAAA;AAAA,MACxD,CAAA,EAAG;AAAA,QACFA,WAAAA,CAAW,UAAA;AAAA,QACXA,WAAAA,CAAW,WAAA;AAAA,QACXA,WAAAA,CAAW,IAAA;AAAA,QACX;AAAA,MACD,CAAC,CAAA;AAAA,IACF;AAEA,IAAA,OAAO;AAAA,MACN,GAAG,UAAA;AAAA,MACH;AAAA,IACD,CAAA;AAAA,EACD;AAEA,EAAA,OAAO;AAAA,IACN;AAAA,EACD,CAAA;AACD;ADjDA;AACE;AACA;AACA;AACF,kJAAC","file":"/Users/nathan/rivet/rivetkit-typescript/packages/react/dist/mod.js","sourcesContent":[null,"import {\n\ttype ActorOptions,\n\ttype AnyActorRegistry,\n\ttype CreateRivetKitOptions,\n\tcreateRivetKit as createVanillaRivetKit,\n} from \"@rivetkit/framework-base\";\nimport { useStore } from \"@tanstack/react-store\";\nimport { useEffect, useRef } from \"react\";\nimport {\n\ttype Client,\n\tcreateClient,\n\ttype ExtractActorsFromRegistry,\n} from \"rivetkit/client\";\n\nexport { createClient } from \"rivetkit/client\";\n\nexport function createRivetKit<Registry extends AnyActorRegistry>(\n\tclientInput: Parameters<typeof createClient>[0],\n\topts: CreateRivetKitOptions<Registry> = {},\n) {\n\treturn createRivetKitWithClient<Registry>(\n\t\tcreateClient<Registry>(clientInput),\n\t\topts,\n\t);\n}\n\nexport function createRivetKitWithClient<Registry extends AnyActorRegistry>(\n\tclient: Client<Registry>,\n\topts: CreateRivetKitOptions<Registry> = {},\n) {\n\tconst { getOrCreateActor } = createVanillaRivetKit<\n\t\tRegistry,\n\t\tExtractActorsFromRegistry<Registry>,\n\t\tkeyof ExtractActorsFromRegistry<Registry>\n\t>(client, opts);\n\n\t/**\n\t * Hook to connect to a actor and retrieve its state. Using this hook with the same options\n\t * will return the same actor instance. This simplifies passing around the actor state in your components.\n\t * It also provides a method to listen for events emitted by the actor.\n\t * @param opts - Options for the actor, including its name, key, and parameters.\n\t * @returns An object containing the actor's state and a method to listen for events.\n\t */\n\tfunction useActor<\n\t\tActorName extends keyof ExtractActorsFromRegistry<Registry>,\n\t>(opts: ActorOptions<Registry, ActorName>) {\n\t\tconst { mount, setState, state } = getOrCreateActor<ActorName>(opts);\n\n\t\tuseEffect(() => {\n\t\t\tsetState((prev) => {\n\t\t\t\tprev.opts = {\n\t\t\t\t\t...opts,\n\t\t\t\t\tenabled: opts.enabled ?? true,\n\t\t\t\t};\n\t\t\t\treturn prev;\n\t\t\t});\n\t\t}, [opts, setState]);\n\n\t\tuseEffect(() => {\n\t\t\treturn mount();\n\t\t}, [mount]);\n\n\t\tconst actorState = useStore(state) || {};\n\n\t\t/**\n\t\t * Hook to listen for events emitted by the actor.\n\t\t * This hook allows you to subscribe to specific events emitted by the actor and execute a handler function\n\t\t * when the event occurs.\n\t\t * It uses the `useEffect` hook to set up the event listener when the actor connection is established.\n\t\t * It cleans up the listener when the component unmounts or when the actor connection changes.\n\t\t * @param eventName The name of the event to listen for.\n\t\t * @param handler The function to call when the event is emitted.\n\t\t */\n\t\tfunction useEvent(\n\t\t\teventName: string,\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: strong typing of handler is not supported yet\n\t\t\thandler: (...args: any[]) => void,\n\t\t) {\n\t\t\tconst ref = useRef(handler);\n\t\t\tconst actorState = useStore(state) || {};\n\n\t\t\tuseEffect(() => {\n\t\t\t\tref.current = handler;\n\t\t\t}, [handler]);\n\n\t\t\t// biome-ignore lint/correctness/useExhaustiveDependencies: it's okay to not include all dependencies here\n\t\t\tuseEffect(() => {\n\t\t\t\tif (!actorState?.connection) return;\n\n\t\t\t\tfunction eventHandler(...args: any[]) {\n\t\t\t\t\tref.current(...args);\n\t\t\t\t}\n\t\t\t\treturn actorState.connection.on(eventName, eventHandler);\n\t\t\t}, [\n\t\t\t\tactorState.connection,\n\t\t\t\tactorState.isConnected,\n\t\t\t\tactorState.hash,\n\t\t\t\teventName,\n\t\t\t]);\n\t\t}\n\n\t\treturn {\n\t\t\t...actorState,\n\t\t\tuseEvent,\n\t\t};\n\t}\n\n\treturn {\n\t\tuseActor,\n\t};\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivetkit/react",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.21",
|
|
4
4
|
"description": "React hooks and components for RivetKit client applications",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@tanstack/react-store": "^0.7.1",
|
|
36
|
-
"@rivetkit/framework-base": "2.0.
|
|
37
|
-
"rivetkit": "^2.0.
|
|
36
|
+
"@rivetkit/framework-base": "2.0.21",
|
|
37
|
+
"rivetkit": "^2.0.21"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": "^18 || ^19",
|