@simfinity/constellation-ui 1.0.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,9 @@
1
+ # @simfinity/constellation-client
2
+
3
+ ## Installation
4
+
5
+ ```bash
6
+ npm install @simfinity/constellation-client
7
+ # or
8
+ yarn add @simfinity/constellation-client
9
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,95 @@
1
+ "use strict";
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 __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ ConstellationProvider: () => ConstellationProvider,
34
+ useConstellationClient: () => useConstellationClient,
35
+ useConstellationSession: () => useConstellationSession
36
+ });
37
+ module.exports = __toCommonJS(index_exports);
38
+
39
+ // src/ConstellationContext.tsx
40
+ var import_react = __toESM(require("react"), 1);
41
+ var import_jsx_runtime = require("react/jsx-runtime");
42
+ var ConstellationContext = import_react.default.createContext(null);
43
+ function ConstellationProvider({ client, children }) {
44
+ const [sessionId, setSessionId] = (0, import_react.useState)(null);
45
+ const [connected, setConnected] = (0, import_react.useState)(false);
46
+ const [audioEnabled, setAudioEnabled] = (0, import_react.useState)(false);
47
+ const value = {
48
+ client,
49
+ sessionId,
50
+ connected,
51
+ audioEnabled,
52
+ setSessionId,
53
+ setConnected,
54
+ setAudioEnabled
55
+ };
56
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConstellationContext.Provider, { value, children });
57
+ }
58
+ function useConstellationClient() {
59
+ const ctx = (0, import_react.useContext)(ConstellationContext);
60
+ if (!ctx) throw new Error("Must be used inside ConstellationProvider");
61
+ return {
62
+ startSession: async (audio, voice) => {
63
+ await ctx.client.startSession(audio, voice);
64
+ ctx.setAudioEnabled(audio);
65
+ },
66
+ endSession: async () => {
67
+ await ctx.client.endSession();
68
+ ctx.setConnected(false);
69
+ ctx.setSessionId(null);
70
+ },
71
+ joinSession: async (audio, handlers) => {
72
+ await ctx.client.joinSession(audio, handlers);
73
+ ctx.setConnected(true);
74
+ },
75
+ configureSession: (settings) => ctx.client.configureSession(settings),
76
+ sendText: (text) => ctx.client.sendText(text),
77
+ sendAudioChunk: (chunk) => ctx.client.sendAudioChunk(chunk),
78
+ commitAudio: () => ctx.client.commitAudioChunksSent()
79
+ };
80
+ }
81
+ function useConstellationSession() {
82
+ const ctx = (0, import_react.useContext)(ConstellationContext);
83
+ if (!ctx) throw new Error("Must be used inside ConstellationProvider");
84
+ return {
85
+ sessionId: ctx.sessionId,
86
+ connected: ctx.connected,
87
+ audioEnabled: ctx.audioEnabled
88
+ };
89
+ }
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
92
+ ConstellationProvider,
93
+ useConstellationClient,
94
+ useConstellationSession
95
+ });
@@ -0,0 +1,24 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React from 'react';
3
+ import { WebClient, EventHandlers, SessionConfig } from '@simfinity/constellation-client';
4
+
5
+ declare function ConstellationProvider({ client, children, }: {
6
+ client: WebClient;
7
+ children: React.ReactNode;
8
+ }): react_jsx_runtime.JSX.Element;
9
+ declare function useConstellationClient(): {
10
+ startSession: (audio: boolean, voice?: string) => Promise<void>;
11
+ endSession: () => Promise<void>;
12
+ joinSession: (audio: boolean, handlers: EventHandlers) => Promise<void>;
13
+ configureSession: (settings: SessionConfig) => void;
14
+ sendText: (text: string) => void;
15
+ sendAudioChunk: (chunk: string) => void;
16
+ commitAudio: () => void;
17
+ };
18
+ declare function useConstellationSession(): {
19
+ sessionId: string | null;
20
+ connected: boolean;
21
+ audioEnabled: boolean;
22
+ };
23
+
24
+ export { ConstellationProvider, useConstellationClient, useConstellationSession };
@@ -0,0 +1,24 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React from 'react';
3
+ import { WebClient, EventHandlers, SessionConfig } from '@simfinity/constellation-client';
4
+
5
+ declare function ConstellationProvider({ client, children, }: {
6
+ client: WebClient;
7
+ children: React.ReactNode;
8
+ }): react_jsx_runtime.JSX.Element;
9
+ declare function useConstellationClient(): {
10
+ startSession: (audio: boolean, voice?: string) => Promise<void>;
11
+ endSession: () => Promise<void>;
12
+ joinSession: (audio: boolean, handlers: EventHandlers) => Promise<void>;
13
+ configureSession: (settings: SessionConfig) => void;
14
+ sendText: (text: string) => void;
15
+ sendAudioChunk: (chunk: string) => void;
16
+ commitAudio: () => void;
17
+ };
18
+ declare function useConstellationSession(): {
19
+ sessionId: string | null;
20
+ connected: boolean;
21
+ audioEnabled: boolean;
22
+ };
23
+
24
+ export { ConstellationProvider, useConstellationClient, useConstellationSession };
package/dist/index.js ADDED
@@ -0,0 +1,56 @@
1
+ // src/ConstellationContext.tsx
2
+ import React, { useContext, useState } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ var ConstellationContext = React.createContext(null);
5
+ function ConstellationProvider({ client, children }) {
6
+ const [sessionId, setSessionId] = useState(null);
7
+ const [connected, setConnected] = useState(false);
8
+ const [audioEnabled, setAudioEnabled] = useState(false);
9
+ const value = {
10
+ client,
11
+ sessionId,
12
+ connected,
13
+ audioEnabled,
14
+ setSessionId,
15
+ setConnected,
16
+ setAudioEnabled
17
+ };
18
+ return /* @__PURE__ */ jsx(ConstellationContext.Provider, { value, children });
19
+ }
20
+ function useConstellationClient() {
21
+ const ctx = useContext(ConstellationContext);
22
+ if (!ctx) throw new Error("Must be used inside ConstellationProvider");
23
+ return {
24
+ startSession: async (audio, voice) => {
25
+ await ctx.client.startSession(audio, voice);
26
+ ctx.setAudioEnabled(audio);
27
+ },
28
+ endSession: async () => {
29
+ await ctx.client.endSession();
30
+ ctx.setConnected(false);
31
+ ctx.setSessionId(null);
32
+ },
33
+ joinSession: async (audio, handlers) => {
34
+ await ctx.client.joinSession(audio, handlers);
35
+ ctx.setConnected(true);
36
+ },
37
+ configureSession: (settings) => ctx.client.configureSession(settings),
38
+ sendText: (text) => ctx.client.sendText(text),
39
+ sendAudioChunk: (chunk) => ctx.client.sendAudioChunk(chunk),
40
+ commitAudio: () => ctx.client.commitAudioChunksSent()
41
+ };
42
+ }
43
+ function useConstellationSession() {
44
+ const ctx = useContext(ConstellationContext);
45
+ if (!ctx) throw new Error("Must be used inside ConstellationProvider");
46
+ return {
47
+ sessionId: ctx.sessionId,
48
+ connected: ctx.connected,
49
+ audioEnabled: ctx.audioEnabled
50
+ };
51
+ }
52
+ export {
53
+ ConstellationProvider,
54
+ useConstellationClient,
55
+ useConstellationSession
56
+ };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@simfinity/constellation-ui",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "import": "./dist/index.mjs",
8
+ "require": "./dist/index.cjs"
9
+ }
10
+ },
11
+ "main": "./dist/index.cjs",
12
+ "module": "./dist/index.mjs",
13
+ "types": "./dist/index.d.ts",
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsup src/index.ts --format cjs,esm --dts"
19
+ },
20
+ "peerDependencies": {
21
+ "react": "^18.0.0 || ^19.0.0",
22
+ "react-dom": "^18.0.0 || ^19.0.0"
23
+ },
24
+ "author": "Simfinity",
25
+ "license": "MIT",
26
+ "dependencies": {
27
+ "@simfinity/constellation-client": "^1.0.8"
28
+ },
29
+ "devDependencies": {
30
+ "@types/react": "^19.2.11",
31
+ "@types/react-dom": "^19.2.3",
32
+ "tsup": "^8.5.1",
33
+ "typescript": "^5.9.3"
34
+ }
35
+ }