@rivetkit/react 0.9.0 → 0.9.2
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 +1 -1
- package/dist/mod.js.map +1 -1
- package/dist/mod.mjs +1 -1
- package/dist/mod.mjs.map +1 -1
- package/package.json +5 -6
package/dist/mod.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/mod.tsx
|
|
2
|
-
var _reactstore = require('@tanstack/react-store');
|
|
3
2
|
|
|
4
3
|
|
|
5
4
|
var _frameworkbase = require('@rivetkit/framework-base');
|
|
5
|
+
var _reactstore = require('@tanstack/react-store');
|
|
6
6
|
var _react = require('react');
|
|
7
7
|
var _client = require('@rivetkit/core/client');
|
|
8
8
|
function createRivetKit(client, opts = {}) {
|
package/dist/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/nathan/rivetkit/packages/frameworks/react/dist/mod.js","../src/mod.tsx"],"names":["opts"],"mappings":"AAAA;
|
|
1
|
+
{"version":3,"sources":["/home/nathan/rivetkit/packages/frameworks/react/dist/mod.js","../src/mod.tsx"],"names":["opts"],"mappings":"AAAA;ACCA;AAIC;AAAkB,yDACZ;AACP,mDAAyB;AACzB,8BAA0B;AAE1B,+CAA6B;AAEtB,SAAS,cAAA,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,MAAM,SAAA,EAAW,CAChB,SAAA,EAEA,OAAA,EAAA,GACI;AAEJ,MAAA,8BAAA,CAAU,EAAA,GAAM;AACf,QAAA,GAAA,CAAI,CAAA,CAAC,WAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,UAAA,CAAY,UAAA,CAAA,EAAY,MAAA;AAE7B,QAAA,MAAM,WAAA,EAAa,UAAA,CAAW,UAAA;AAC9B,QAAA,OAAO,UAAA,CAAW,EAAA,CAAG,SAAA,EAAW,OAAO,CAAA;AAAA,MACxC,CAAA,EAAG,CAAC,UAAA,CAAW,UAAA,EAAY,UAAA,CAAW,WAAA,EAAa,SAAA,EAAW,OAAO,CAAC,CAAA;AAAA,IACvE,CAAA;AACA,IAAA,OAAO;AAAA,MACN,GAAG,UAAA;AAAA,MACH;AAAA,IACD,CAAA;AAAA,EACD;AAEA,EAAA,OAAO;AAAA,IACN;AAAA,EACD,CAAA;AACD;ADzCA;AACE;AACA;AACF,qFAAC","file":"/home/nathan/rivetkit/packages/frameworks/react/dist/mod.js","sourcesContent":[null,"import type { Client, ExtractActorsFromRegistry } from \"@rivetkit/core/client\";\nimport {\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 } from \"react\";\n\nexport { createClient } from \"@rivetkit/core/client\";\n\nexport function createRivetKit<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\tconst 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\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\tconst connection = actorState.connection;\n\t\t\t\treturn connection.on(eventName, handler);\n\t\t\t}, [actorState.connection, actorState.isConnected, eventName, handler]);\n\t\t};\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/dist/mod.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/mod.tsx
|
|
2
|
-
import { useStore } from "@tanstack/react-store";
|
|
3
2
|
import {
|
|
4
3
|
createRivetKit as createVanillaRivetKit
|
|
5
4
|
} from "@rivetkit/framework-base";
|
|
5
|
+
import { useStore } from "@tanstack/react-store";
|
|
6
6
|
import { useEffect } from "react";
|
|
7
7
|
import { createClient } from "@rivetkit/core/client";
|
|
8
8
|
function createRivetKit(client, opts = {}) {
|
package/dist/mod.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mod.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../src/mod.tsx"],"sourcesContent":["import type { Client, ExtractActorsFromRegistry } from \"@rivetkit/core/client\";\nimport {\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 } from \"react\";\n\nexport { createClient } from \"@rivetkit/core/client\";\n\nexport function createRivetKit<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\tconst 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\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\tconst connection = actorState.connection;\n\t\t\t\treturn connection.on(eventName, handler);\n\t\t\t}, [actorState.connection, actorState.isConnected, eventName, handler]);\n\t\t};\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"],"mappings":";AACA;AAAA,EAIC,kBAAkB;AAAA,OACZ;AACP,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAE1B,SAAS,oBAAoB;AAEtB,SAAS,eACf,QACA,OAAwC,CAAC,GACxC;AACD,QAAM,EAAE,iBAAiB,IAAI,sBAI3B,QAAQ,IAAI;AASd,WAAS,SAEPA,OAAyC;AAC1C,UAAM,EAAE,OAAO,UAAU,MAAM,IAAI,iBAA4BA,KAAI;AAEnE,cAAU,MAAM;AACf,eAAS,CAAC,SAAS;AAClB,aAAK,OAAO;AAAA,UACX,GAAGA;AAAA,UACH,SAASA,MAAK,WAAW;AAAA,QAC1B;AACA,eAAO;AAAA,MACR,CAAC;AAAA,IACF,GAAG,CAACA,OAAM,QAAQ,CAAC;AAEnB,cAAU,MAAM;AACf,aAAO,MAAM;AAAA,IACd,GAAG,CAAC,KAAK,CAAC;AAEV,UAAM,aAAa,SAAS,KAAK,KAAK,CAAC;AAWvC,UAAM,WAAW,CAChB,WAEA,YACI;AAEJ,gBAAU,MAAM;AACf,YAAI,EAAC,yCAAY,YAAY;AAE7B,cAAM,aAAa,WAAW;AAC9B,eAAO,WAAW,GAAG,WAAW,OAAO;AAAA,MACxC,GAAG,CAAC,WAAW,YAAY,WAAW,aAAa,WAAW,OAAO,CAAC;AAAA,IACvE;AACA,WAAO;AAAA,MACN,GAAG;AAAA,MACH;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AAAA,IACN;AAAA,EACD;AACD;","names":["opts"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivetkit/react",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rivetkit",
|
|
@@ -29,19 +29,18 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@tanstack/react-store": "^0.7.1",
|
|
32
|
-
"@rivetkit/framework-base": "0.9.
|
|
32
|
+
"@rivetkit/framework-base": "0.9.2",
|
|
33
|
+
"@rivetkit/core": "^0.9.2"
|
|
33
34
|
},
|
|
34
35
|
"peerDependencies": {
|
|
35
36
|
"react": "^18 || ^19",
|
|
36
|
-
"react-dom": "^18 || ^19"
|
|
37
|
-
"@rivetkit/core": "*"
|
|
37
|
+
"react-dom": "^18 || ^19"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/react": "^19.1.8",
|
|
41
41
|
"@types/react-dom": "^19.1.6",
|
|
42
42
|
"tsup": "^8.4.0",
|
|
43
|
-
"typescript": "^5.5.2"
|
|
44
|
-
"@rivetkit/core": "^0.9.0"
|
|
43
|
+
"typescript": "^5.5.2"
|
|
45
44
|
},
|
|
46
45
|
"stableVersion": "0.8.0",
|
|
47
46
|
"scripts": {
|