@plucky-ai/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/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # @plucky-ai/react
2
+
3
+ A React hook for using the Plucky Chat SDK.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @plucky-ai/react
9
+ # or
10
+ yarn add @plucky-ai/react
11
+ # or
12
+ pnpm add @plucky-ai/react
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```typescript
18
+ import { useChat } from '@plucky-ai/react'
19
+
20
+ const { sendMessage } = useChat({
21
+ appId: '123',
22
+ })
23
+
24
+ sendMessage('Hello, world!')
25
+ ```
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -eux
4
+
5
+ # Build the project
6
+ npm run build:release
7
+
8
+ # Get the version from package.json before changing directory
9
+ VERSION="$(node -p "require('./package.json').version")"
10
+
11
+ # Extract the pre-release tag if it exists
12
+ if [[ "$VERSION" =~ -([a-zA-Z]+) ]]; then
13
+ # Extract the part before any dot in the pre-release identifier
14
+ TAG="${BASH_REMATCH[1]}"
15
+ else
16
+ TAG="latest"
17
+ fi
18
+
19
+ # Publish with the appropriate tag
20
+ npm publish --access public --tag "$TAG"
package/dist/index.cjs ADDED
@@ -0,0 +1,50 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ let __plucky_ai_chat_sdk = require("@plucky-ai/chat-sdk");
25
+ __plucky_ai_chat_sdk = __toESM(__plucky_ai_chat_sdk);
26
+ let react = require("react");
27
+ react = __toESM(react);
28
+
29
+ //#region src/hooks/useChat.ts
30
+ function useChat(params) {
31
+ const { tools,...rest } = params;
32
+ (0, react.useEffect)(() => {
33
+ (0, __plucky_ai_chat_sdk.init)({ ...rest });
34
+ }, [rest]);
35
+ (0, react.useEffect)(() => {
36
+ if (!tools || tools.length === 0) return;
37
+ const api = (0, __plucky_ai_chat_sdk.getAPI)();
38
+ api.registerManyTools(tools);
39
+ return () => {
40
+ tools.forEach((tool) => api.removeTool(tool.name));
41
+ };
42
+ }, [tools]);
43
+ return { sendMessage: (message) => {
44
+ (0, __plucky_ai_chat_sdk.getAPI)().sendMessage({ content: message });
45
+ } };
46
+ }
47
+
48
+ //#endregion
49
+ exports.useChat = useChat;
50
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/hooks/useChat.ts"],"sourcesContent":["import { getAPI, init } from '@plucky-ai/chat-sdk'\nimport { useEffect } from 'react'\n\nexport function useChat(params: Parameters<typeof init>[0]) {\n const { tools, ...rest } = params\n\n useEffect(() => {\n init({\n ...rest,\n })\n }, [rest])\n useEffect(() => {\n if (!tools || tools.length === 0) return\n const api = getAPI()\n api.registerManyTools(tools)\n return () => {\n tools.forEach((tool) => api.removeTool(tool.name))\n }\n }, [tools])\n return {\n sendMessage: (message: string) => {\n getAPI().sendMessage({\n content: message,\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAgB,QAAQ,QAAoC;CAC1D,MAAM,EAAE,MAAO,GAAG,SAAS;AAE3B,4BAAgB;AACd,iCAAK,EACH,GAAG,MACJ,CAAC;IACD,CAAC,KAAK,CAAC;AACV,4BAAgB;AACd,MAAI,CAAC,SAAS,MAAM,WAAW,EAAG;EAClC,MAAM,wCAAc;AACpB,MAAI,kBAAkB,MAAM;AAC5B,eAAa;AACX,SAAM,SAAS,SAAS,IAAI,WAAW,KAAK,KAAK,CAAC;;IAEnD,CAAC,MAAM,CAAC;AACX,QAAO,EACL,cAAc,YAAoB;AAChC,oCAAQ,CAAC,YAAY,EACnB,SAAS,SACV,CAAC;IAEL"}
@@ -0,0 +1,20 @@
1
+ import { ToolConfig, init } from "@plucky-ai/chat-sdk";
2
+
3
+ //#region src/hooks/useChat.d.ts
4
+ declare function useChat(params: Parameters<typeof init>[0]): {
5
+ sendMessage: (message: string) => void;
6
+ };
7
+ //#endregion
8
+ //#region src/types.d.ts
9
+ type UseChatParams = {
10
+ appId: string;
11
+ user?: {
12
+ id: string;
13
+ name?: string;
14
+ };
15
+ tools?: ToolConfig[];
16
+ tags?: string[];
17
+ };
18
+ //#endregion
19
+ export { UseChatParams, useChat };
20
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,20 @@
1
+ import { ToolConfig, init } from "@plucky-ai/chat-sdk";
2
+
3
+ //#region src/hooks/useChat.d.ts
4
+ declare function useChat(params: Parameters<typeof init>[0]): {
5
+ sendMessage: (message: string) => void;
6
+ };
7
+ //#endregion
8
+ //#region src/types.d.ts
9
+ type UseChatParams = {
10
+ appId: string;
11
+ user?: {
12
+ id: string;
13
+ name?: string;
14
+ };
15
+ tools?: ToolConfig[];
16
+ tags?: string[];
17
+ };
18
+ //#endregion
19
+ export { UseChatParams, useChat };
20
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ import { getAPI, init } from "@plucky-ai/chat-sdk";
2
+ import { useEffect } from "react";
3
+
4
+ //#region src/hooks/useChat.ts
5
+ function useChat(params) {
6
+ const { tools,...rest } = params;
7
+ useEffect(() => {
8
+ init({ ...rest });
9
+ }, [rest]);
10
+ useEffect(() => {
11
+ if (!tools || tools.length === 0) return;
12
+ const api = getAPI();
13
+ api.registerManyTools(tools);
14
+ return () => {
15
+ tools.forEach((tool) => api.removeTool(tool.name));
16
+ };
17
+ }, [tools]);
18
+ return { sendMessage: (message) => {
19
+ getAPI().sendMessage({ content: message });
20
+ } };
21
+ }
22
+
23
+ //#endregion
24
+ export { useChat };
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/hooks/useChat.ts"],"sourcesContent":["import { getAPI, init } from '@plucky-ai/chat-sdk'\nimport { useEffect } from 'react'\n\nexport function useChat(params: Parameters<typeof init>[0]) {\n const { tools, ...rest } = params\n\n useEffect(() => {\n init({\n ...rest,\n })\n }, [rest])\n useEffect(() => {\n if (!tools || tools.length === 0) return\n const api = getAPI()\n api.registerManyTools(tools)\n return () => {\n tools.forEach((tool) => api.removeTool(tool.name))\n }\n }, [tools])\n return {\n sendMessage: (message: string) => {\n getAPI().sendMessage({\n content: message,\n })\n },\n }\n}\n"],"mappings":";;;;AAGA,SAAgB,QAAQ,QAAoC;CAC1D,MAAM,EAAE,MAAO,GAAG,SAAS;AAE3B,iBAAgB;AACd,OAAK,EACH,GAAG,MACJ,CAAC;IACD,CAAC,KAAK,CAAC;AACV,iBAAgB;AACd,MAAI,CAAC,SAAS,MAAM,WAAW,EAAG;EAClC,MAAM,MAAM,QAAQ;AACpB,MAAI,kBAAkB,MAAM;AAC5B,eAAa;AACX,SAAM,SAAS,SAAS,IAAI,WAAW,KAAK,KAAK,CAAC;;IAEnD,CAAC,MAAM,CAAC;AACX,QAAO,EACL,cAAc,YAAoB;AAChC,UAAQ,CAAC,YAAY,EACnB,SAAS,SACV,CAAC;IAEL"}
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@plucky-ai/react",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "./index.cjs",
6
+ "module": "./index.js",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "*.js",
17
+ "*.mjs",
18
+ "*.cjs",
19
+ "*.d.ts",
20
+ "*.map"
21
+ ],
22
+ "sideEffects": false
23
+ }
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@plucky-ai/react",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ }
14
+ },
15
+ "dependencies": {
16
+ "react": "19.1.1",
17
+ "zod": "^4.1.11",
18
+ "@plucky-ai/chat-sdk": "^0.1.0"
19
+ },
20
+ "devDependencies": {
21
+ "@types/react": "19.1.13",
22
+ "tsdown": "^0.15.9",
23
+ "tsx": "^4.20.5",
24
+ "typescript": "^5.9.2"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public",
28
+ "registry": "https://registry.npmjs.org/"
29
+ },
30
+ "scripts": {
31
+ "build:watch": "pnpm exec tsdown --watch ./src",
32
+ "build": "pnpm exec tsdown --config tsdown.config.ts"
33
+ }
34
+ }