@callimacus/thamyr-react 4.3.4 → 4.4.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/CHANGELOG.core.md +32 -0
- package/CHANGELOG.md +48 -0
- package/MIGRATION.md +15 -15
- package/dist/esm/chunks/api-PeedNYnN.js +9 -0
- package/dist/esm/chunks/api-PeedNYnN.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/query.js +1 -1
- package/dist/types/index.d.ts +244 -5
- package/package.json +3 -3
- package/dist/esm/chunks/api-BeXO8dlg.js +0 -9
- package/dist/esm/chunks/api-BeXO8dlg.js.map +0 -1
- package/dist/esm/chunks/api-Bzz6EL4P.js +0 -9
- package/dist/esm/chunks/api-Bzz6EL4P.js.map +0 -1
package/CHANGELOG.core.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.4.0](https://github.com/callimacus/thamyr-sdk/compare/thamyr-core-v4.3.5...thamyr-core-v4.4.0) (2026-09-29)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **callimacus:** export additional action types from hooks for better type safety ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
12
|
+
* **ContentAPI:** implement getDocumentByGroupId method to retrieve documents based on language and group ID ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
13
|
+
* **hooks.ts:** enhance useProducts, useAnalytics, and useSitemap hooks with TypeScript interfaces and detailed documentation ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
14
|
+
* **react:** add eslint-config-xo-react for better React linting ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
15
|
+
* **react:** implement Callimacus store and hooks for state management ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
16
|
+
* **service.ts:** add polling transport option to socket connection for improved connectivity in restricted environments ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
17
|
+
* **service.ts:** add referrer to auth object for enhanced tracking and analytics ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
18
|
+
* **thamyr:** parity with the v2 wire, rounds without a message, acknowledged suggestions, receptors and block keys ([#784](https://github.com/callimacus/thamyr-sdk/issues/784)) ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* **AnalyticsAPI.ts, Thamyr.ts:** remove array type from content parameter in trackEvent method for consistency and simplification ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
24
|
+
* **core/package.json:** update @solomei-ai/intent to version 1.9.2 for latest features and fixes ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
25
|
+
* **package.json:** remove redundant comma in scripts section to ensure JSON validity ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
26
|
+
* **package.json:** update @types/react to version 19.2.10 for improved type definitions chore(package.json): bump react and react-dom to version 19.2.4 for latest features and fixes ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
27
|
+
* **react:** ensure consistent export style across components ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
28
|
+
* **react:** remove obsolete global type declarations ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
29
|
+
* remove legacy-peer-deps from .npmrc and update registry configuration for scoped package ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
30
|
+
|
|
31
|
+
## [4.3.5](https://github.com/callimacus/thamyr-sdk/compare/thamyr-core-v4.3.4...thamyr-core-v4.3.5) (2026-09-29)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Bug Fixes
|
|
35
|
+
|
|
36
|
+
* **npm:** publish the five packages as @callimacus/* ([#791](https://github.com/callimacus/thamyr-sdk/issues/791)) ([7beae9a](https://github.com/callimacus/thamyr-sdk/commit/7beae9a15f713602aa73d0ddb8ae82d045a725c0))
|
|
37
|
+
|
|
6
38
|
## [4.3.4](https://github.com/solomei-ai/thamyr-sdk/compare/thamyr-core-v4.3.3...thamyr-core-v4.3.4) (2026-09-27)
|
|
7
39
|
|
|
8
40
|
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,54 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.4.0](https://github.com/callimacus/thamyr-sdk/compare/thamyr-react-v4.3.5...thamyr-react-v4.4.0) (2026-09-29)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **callimacus:** export additional action types from hooks for better type safety ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
12
|
+
* **ContentAPI:** implement getDocumentByGroupId method to retrieve documents based on language and group ID ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
13
|
+
* **hooks.ts:** enhance useProducts, useAnalytics, and useSitemap hooks with TypeScript interfaces and detailed documentation ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
14
|
+
* **react:** add eslint-config-xo-react for better React linting ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
15
|
+
* **react:** implement Callimacus store and hooks for state management ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
16
|
+
* **service.ts:** add polling transport option to socket connection for improved connectivity in restricted environments ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
17
|
+
* **service.ts:** add referrer to auth object for enhanced tracking and analytics ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
18
|
+
* **thamyr:** parity with the v2 wire, rounds without a message, acknowledged suggestions, receptors and block keys ([#784](https://github.com/callimacus/thamyr-sdk/issues/784)) ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* **AnalyticsAPI.ts, Thamyr.ts:** remove array type from content parameter in trackEvent method for consistency and simplification ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
24
|
+
* **core/package.json:** update @solomei-ai/intent to version 1.9.2 for latest features and fixes ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
25
|
+
* **package.json:** remove redundant comma in scripts section to ensure JSON validity ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
26
|
+
* **package.json:** update @types/react to version 19.2.10 for improved type definitions chore(package.json): bump react and react-dom to version 19.2.4 for latest features and fixes ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
27
|
+
* **react:** ensure consistent export style across components ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
28
|
+
* **react:** remove obsolete global type declarations ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
29
|
+
* remove legacy-peer-deps from .npmrc and update registry configuration for scoped package ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Dependencies
|
|
33
|
+
|
|
34
|
+
* The following workspace dependencies were updated
|
|
35
|
+
* dependencies
|
|
36
|
+
* @callimacus/thamyr bumped from ^4.3.5 to ^4.4.0
|
|
37
|
+
* @callimacus/thamyr-core bumped from ^4.3.5 to ^4.4.0
|
|
38
|
+
|
|
39
|
+
## [4.3.5](https://github.com/callimacus/thamyr-sdk/compare/thamyr-react-v4.3.4...thamyr-react-v4.3.5) (2026-09-29)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Bug Fixes
|
|
43
|
+
|
|
44
|
+
* **npm:** publish the five packages as @callimacus/* ([#791](https://github.com/callimacus/thamyr-sdk/issues/791)) ([7beae9a](https://github.com/callimacus/thamyr-sdk/commit/7beae9a15f713602aa73d0ddb8ae82d045a725c0))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Dependencies
|
|
48
|
+
|
|
49
|
+
* The following workspace dependencies were updated
|
|
50
|
+
* dependencies
|
|
51
|
+
* @callimacus/thamyr bumped from ^4.3.4 to ^4.3.5
|
|
52
|
+
* @callimacus/thamyr-core bumped from ^4.3.4 to ^4.3.5
|
|
53
|
+
|
|
6
54
|
## [4.3.4](https://github.com/solomei-ai/thamyr-sdk/compare/thamyr-react-v4.3.3...thamyr-react-v4.3.4) (2026-09-27)
|
|
7
55
|
|
|
8
56
|
|
package/MIGRATION.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Thamyr SDK migration guide
|
|
2
2
|
|
|
3
|
-
This file ships inside every `@
|
|
3
|
+
This file ships inside every `@solomei-ai/thamyr*` package; the same guide is published at [docs.callimacus.ai/thamyr-sdk/8-migration](https://docs.callimacus.ai/thamyr-sdk/8-migration) (Callimacus account required). It covers every break since 1.x; release-by-release detail is in `CHANGELOG.md` (this package) and, in the framework packages, `CHANGELOG.core.md` (the contract and types — in `@solomei-ai/thamyr-core` that is `CHANGELOG.md` itself).
|
|
4
4
|
|
|
5
5
|
**The wire protocol has not changed since v1.** Any major talks to the same server, so upgrading is an exercise you can schedule: bump, run your type checker, work through the errors. Every signature change is compile-time; three things are not — error handling, retries, and since 4.0.2 the constructor rejecting an empty or relative `endpoint` — so read [Error handling](#error-handling) and [`endpoint` must be an absolute URL](#endpoint-must-be-an-absolute-url-402) before you start.
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ This file ships inside every `@callimacus/thamyr*` package; the same guide is pu
|
|
|
8
8
|
|
|
9
9
|
Sites still on 1.x (the last 1.x release is 1.8.2) cross three majors at once. Work through the errors in this order:
|
|
10
10
|
|
|
11
|
-
1. **`@
|
|
11
|
+
1. **`@solomei-ai/common` imports.** The package left the dependency tree in v2.0.0; every wire type and enum a client needs is exported by `@solomei-ai/thamyr`. One rewrite — see [`@solomei-ai/common` is no longer a dependency](#solomei-aicommon-is-no-longer-a-dependency). Imports from `@solomei-ai/thamyr-core` keep working (`@solomei-ai/thamyr` re-exports all of it), but declare the package or import from `@solomei-ai/thamyr` instead of relying on hoisting.
|
|
12
12
|
2. **`accessToken` → `clientId`** on the constructor / `useInitThamyr` — see [Initialization](#initialization-accesstoken--clientid).
|
|
13
13
|
3. **Contract methods take one parameters object and resolve `{data, error, response}`; none of them rejects on HTTP status** (only `sitemap.getSitemap()` still does). Read [Error handling](#error-handling) before touching code that caught or retried — a `catch` on `err.status` silently stops running, and a retry-on-500 handler can loop. Signature-by-signature mapping under [New method signatures](#new-method-signatures-on-the-api-namespaces).
|
|
14
14
|
4. **`language` is required** on `content.*` — v1 sent `'en'` when you omitted it. Pass `'en'` to keep behaviour identical, or your real locale to fix it.
|
|
@@ -16,10 +16,10 @@ Sites still on 1.x (the last 1.x release is 1.8.2) cross three majors at once. W
|
|
|
16
16
|
6. **Protocol enums are `as const` objects.** Runtime values are unchanged; `Enum.member` in a type position becomes `typeof Enum.member` — see [Protocol enums](#protocol-enums-are-as-const-objects).
|
|
17
17
|
7. **Salesforce `c_*` attributes and media extras are `unknown`** on `Basket`, on each `ProductItem` and on `Image.properties.cloudinary` — declare your shapes once, see [Custom attributes](#custom-attributes-are-unknown).
|
|
18
18
|
8. **v4:** `skesis.*` takes a parameters object and resolves the envelope; `products.*` is deprecated but stays; `endpoint` must be an absolute URL; `Basket.basketId` is required — see [Migrating to v4](#migrating-to-v4).
|
|
19
|
-
9. **Ride-along:** `@
|
|
19
|
+
9. **Ride-along:** `@solomei-ai/intent` moves to 2.1.2 or later — see [Intent SDK 2.1.2 rides along](#intent-sdk-212-rides-along).
|
|
20
20
|
10. **Deploy:** if your build copies `VITE_*` variables into `.env`, delete those lines — see [`endpoint` must be an absolute URL](#endpoint-must-be-an-absolute-url-402).
|
|
21
21
|
|
|
22
|
-
Dependencies your build scripts only had transitively through `@
|
|
22
|
+
Dependencies your build scripts only had transitively through `@solomei-ai/common` (a `zod` import in a script, for instance) disappear too — declare them yourself.
|
|
23
23
|
|
|
24
24
|
The call sites a storefront on 1.x most often has, v1 → v4 in one hop:
|
|
25
25
|
|
|
@@ -97,11 +97,11 @@ Reading code is unaffected by all of these; hand-written fixtures and mocks type
|
|
|
97
97
|
|
|
98
98
|
## Intent SDK 2.1.2 rides along
|
|
99
99
|
|
|
100
|
-
`@
|
|
100
|
+
`@solomei-ai/thamyr-core` 4 requires `@solomei-ai/intent` 2.1.2 or later, so npm upgrades a 2.0.x lock on the same install. If your site calls the Intent SDK directly, read its changelog entries for 2.1.0 (platform-free core, [#278](https://github.com/solomei-ai/intent-sdk/issues/278)) and 2.1.1 (hrefs that lead nowhere are dropped instead of forwarded, [#289](https://github.com/solomei-ai/intent-sdk/issues/289)), and verify the consent banner on staging: accepting sets the `intent_sid` cookie, revoking clears it. If your site declares its own `@solomei-ai/intent` dependency, bump its range to `^2.1.2` — or drop it and import `initIntent` / `setConsent` from `@solomei-ai/thamyr`, which re-exports the Intent SDK — and check that `npm ls @solomei-ai/intent` shows a single copy.
|
|
101
101
|
|
|
102
102
|
# Migrating to v3: cart becomes a contract namespace
|
|
103
103
|
|
|
104
|
-
v3.0.0 (2026-08-07, [#725](https://github.com/
|
|
104
|
+
v3.0.0 (2026-08-07, [#725](https://github.com/solomei-ai/thamyr-sdk/issues/725)). The `cart` namespace joined the generated contract surface: methods take a flat parameters object and resolve `{data, error, response}` like the other contract namespaces, and the `CartAPI` class export is gone (the `Basket`/`ProductItem` types remain, now generated from Salesforce's own published schema). `useCart()` keeps its method names and positional arguments, but resolves the envelope instead of the bare basket:
|
|
105
105
|
|
|
106
106
|
| v1 / v2 | v3+ |
|
|
107
107
|
| ---------------------------------------------- | ------------------------------------------------------------------ |
|
|
@@ -118,7 +118,7 @@ The `commerce-sdk-isomorphic` dependency left with `CartAPI`; non-SFCC consumers
|
|
|
118
118
|
Salesforce `c_*` attributes on `Basket` **and on each `ProductItem` in `Basket.productItems`**, and extra keys on `Image.properties.cloudinary` (beyond its typed `publicId`, `cloudName` and `secureDistribution`), are typed `[key: string]: unknown` (v1: `any`). Every former `any` access is now TS18046 `'basket.c_x' is of type 'unknown'` (or TS2322 where the value lands in a typed slot) — typically in templates and components far from the SDK call. Declare your project's shapes once and cast at the boundary:
|
|
119
119
|
|
|
120
120
|
```ts
|
|
121
|
-
import type {Basket, ProductItem} from '@
|
|
121
|
+
import type {Basket, ProductItem} from '@solomei-ai/thamyr';
|
|
122
122
|
|
|
123
123
|
type MyItem = ProductItem & {c_image?: string; c_analytics?: {color?: {code: string}}};
|
|
124
124
|
type MyBasket = Basket & {c_productsQuantity: number; productItems?: MyItem[]};
|
|
@@ -133,22 +133,22 @@ The product family is different: on `VariationGroup`, `MasterProduct`, `SetProdu
|
|
|
133
133
|
|
|
134
134
|
v2 aligns the SDK's types and methods exactly with what the platform serves, and every surface deprecated during v1 is gone. The wire protocol is unchanged — a v1 SDK and a v2 SDK speak to the same server identically; everything below is compile-time.
|
|
135
135
|
|
|
136
|
-
## `@
|
|
136
|
+
## `@solomei-ai/common` is no longer a dependency
|
|
137
137
|
|
|
138
|
-
v1 pulled `@
|
|
138
|
+
v1 pulled `@solomei-ai/common` — and its server-side dependency tree (langchain, openai, mysql2, zod, uuid, …) — into every browser bundle, and many sites imported wire types from it directly without declaring it. v2 drops it, so those imports fail with `Cannot find module '@solomei-ai/common'` after the bump. Every type and enum a site takes from it is exported by `@solomei-ai/thamyr` (through `@solomei-ai/thamyr-core`), so the migration is a rename:
|
|
139
139
|
|
|
140
140
|
```sh
|
|
141
141
|
# macOS
|
|
142
|
-
grep -rl '@
|
|
142
|
+
grep -rl '@solomei-ai/common' src | xargs sed -i '' 's#@solomei-ai/common#@solomei-ai/thamyr#g'
|
|
143
143
|
# GNU
|
|
144
|
-
grep -rl '@
|
|
144
|
+
grep -rl '@solomei-ai/common' src | xargs sed -i 's#@solomei-ai/common#@solomei-ai/thamyr#g'
|
|
145
145
|
```
|
|
146
146
|
|
|
147
147
|
Then merge any duplicated import statements and run your type checker: a name it still cannot find was a server-side helper with no client equivalent (`Chapter.fromSLChapter`, `Story.fromSLStory`, `story.getHistoryMessages()`).
|
|
148
148
|
|
|
149
|
-
Do **not** add `@
|
|
149
|
+
Do **not** add `@solomei-ai/common` back as a dependency: its current majors (12.x) are a server-side package (mysql2, winston, openai, langchain) that is not kept in step with the SDK's wire types.
|
|
150
150
|
|
|
151
|
-
The wire types and enums a v1 site imported from `@
|
|
151
|
+
The wire types and enums a v1 site imported from `@solomei-ai/common`, all exported by `@solomei-ai/thamyr` 4.x — types: `Basket`, `BCProduct`, `Block`, `Chapter`, `CustomBlock`, `ErrorMessage`, `Gallery`, `GenericProduct`, `HomePage`, `Image`, `LegacyBlock`, `LocalizedEPArtwork`, `LocalizedEPChapter`, `MasterProduct`, `MasterProductWithVariationGroup`, `OptionItem`, `ProductItem`, `ProductMatch`, `RecommendationsResponse`, `SetProduct`, `SkesisItem`, `SkesisRelatedResponse`, `SkesisSimilarResponse`, `SLDocument`, `SLDocumentSection`, `SLInputEvent`, `Story`, `ThamyrResponse`, `Topic`, `TopicContentsPage`, `TopicSummary`, `Variant`, `VariationAttribute`, `VariationGroup`, `Video`, `WhisperPayload`. Values: `ChapterStatus`, `ClientEvents`, `GalleryMode`, `isCustomBlock`, `isMasterProduct`, `isSetProduct`, `ServerEvents`, `SLInputEventType`, `ThamyrResponseType`.
|
|
152
152
|
|
|
153
153
|
## Initialization: `accessToken` → `clientId`
|
|
154
154
|
|
|
@@ -232,7 +232,7 @@ Two consequences for code written against v1:
|
|
|
232
232
|
- **Anything that keyed off `err.status` in a `catch` stops running** unless the call opts into throwing. Either read `error` and `response?.status` from the envelope, or keep the v1 contract with the option the generated client already has:
|
|
233
233
|
|
|
234
234
|
```ts
|
|
235
|
-
import {ThamyrHttpError} from '@
|
|
235
|
+
import {ThamyrHttpError} from '@solomei-ai/thamyr';
|
|
236
236
|
|
|
237
237
|
const {data: basket} = await thamyr.cart.getCart({throwOnError: true}); // Basket, or rejects
|
|
238
238
|
|
|
@@ -255,7 +255,7 @@ Two consequences for code written against v1:
|
|
|
255
255
|
- `ThamyrResponse` gains the `story-reset` variant, `chapter-deleted` carries the deprecated `roundId` alias, custom blocks carry `name` and `metaJson`, and `ErrorMessage` gains optional `reason`.
|
|
256
256
|
- Protocol enums (`SLInputEventType`, `ThamyrResponseType`, `ChapterStatus`, …) keep their members and values; comparisons and switches are unaffected — but they are `as const` objects now, not TypeScript `enum`s, which changes two idioms: see [below](#protocol-enums-are-as-const-objects).
|
|
257
257
|
- New exports: the `isCustomBlock` block guard, the `CallimacusApi` client class and `createContractClient` (thamyr-core), and the full product family (`BCProduct`, `SetProduct`, `VariationGroup`, …).
|
|
258
|
-
- `@
|
|
258
|
+
- `@solomei-ai/common` is no longer a dependency (nor `uuid`) — see [above](#solomei-aicommon-is-no-longer-a-dependency).
|
|
259
259
|
|
|
260
260
|
## Protocol enums are `as const` objects
|
|
261
261
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright © 2025–2026 Solomei AI SRL. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Proprietary software, licensed for use by Callimacus customers only.
|
|
5
|
+
* See LICENSE.md for the full terms.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import{Thamyr as e}from"@callimacus/thamyr";import{callimacusService as t,ThamyrResponseType as n,applyBlockPatch as r}from"@callimacus/thamyr-core";import o from"react";const s=e=>{let t;const n=new Set,r=(e,r)=>{const o="function"==typeof e?e(t):e;if(!Object.is(o,t)){const e=t;t=(null!=r?r:"object"!=typeof o||null===o)?o:Object.assign({},t,o),n.forEach(n=>n(t,e))}},o=()=>t,s={setState:r,getState:o,getInitialState:()=>i,subscribe:e=>(n.add(e),()=>n.delete(e))},i=t=e(r,o,s);return s},i=e=>e;const a=e=>{const t=(e=>e?s(e):s)(e),n=e=>function(e,t=i){const n=o.useSyncExternalStore(e.subscribe,o.useCallback(()=>t(e.getState()),[e,t]),o.useCallback(()=>t(e.getInitialState()),[e,t]));return o.useDebugValue(n),n}(t,e);return Object.assign(n,t),n};function c(e,t){for(const n of e)try{n(t)}catch(e){console.error("[Thamyr] Listener threw:",e)}}function u(e,t){let o=!1;const s=e.map(e=>{if(e.type!==n.CHAPTER_EVENT)return e;const s=r(e.chapter,t);return s===e.chapter?e:(o=!0,{...e,chapter:s})});return o?s:e}const d=(l?a(l):a)((r,o)=>{let s,i=0;const a=new Set,d=new Set,l=new Set;return{connectionStatus:"idle",messages:[],error:void 0,_initialized:!1,_thamyr:void 0,init(m){if(o()._initialized)return;if("undefined"==typeof window)return void console.debug("[Thamyr] init() skipped: no browser environment detected (SSR).");const{clientId:h}=m;if(!h){console.error("[Thamyr] clientId is required. Pass your Callimacus Client ID (`cal-pk-…`) to useInitThamyr().");const e={code:0,message:"clientId is required. Pass your Callimacus Client ID (`cal-pk-…`) to useInitThamyr()."};return r({connectionStatus:"error",error:e}),c(l,e),void c(d,"error")}void 0!==m.maxMessages&&m.maxMessages<0&&console.warn("[Thamyr] maxMessages must be >= 0. Received:",m.maxMessages,". Clamping to 1.");const f=0===m.maxMessages?1/0:Math.max(1,m.maxMessages??50);let y;r({connectionStatus:"connecting",error:void 0});try{y=new e({clientId:h,endpoint:m.endpoint,uiObserver:m.uiObserver})}catch(e){console.error("[Thamyr] Failed to create Thamyr instance:",e);const t={code:0,message:e instanceof Error?e.message:String(e)};return r({connectionStatus:"error",error:t}),c(l,t),void c(d,"error")}const w=++i;y.onResponse(e=>{i===w&&(e.type===n.BLOCK_PATCH?r(t=>({messages:u(t.messages,e.data)})):r(t=>{const n=[...t.messages,e];return{messages:n.length>f?n.slice(-f):n}}),c(a,e))}),y.onError(e=>{i===w&&(r({error:e,connectionStatus:"error"}),c(l,e),c(d,"error"))}),s=t.onConnectionStatus(e=>{if(i!==w)return;const t=e?"connected":"disconnected";r({connectionStatus:t}),c(d,t)}),function(e){r({_initialized:Boolean(e),_thamyr:e})}(y)},reset(){if(o()._initialized){i++;try{s?.()}catch(e){console.error("[Thamyr] Error unsubscribing connection status listener:",e)}try{t.disconnect()}catch(e){console.error("[Thamyr] Error disconnecting:",e)}s=void 0,r({_initialized:!1,_thamyr:void 0,connectionStatus:"idle",messages:[],error:void 0})}else"idle"!==o().connectionStatus&&r({connectionStatus:"idle",error:void 0})},sendEvent(e,t){const n=o()._thamyr;if(!n)throw new Error("[Thamyr] SDK is not initialized yet. Ensure useInitThamyr() has been called.");const{connectionStatus:s}=o();if("connected"!==s){const e={code:0,message:`Cannot send event: connection status is "${s}". Wait for connected status before sending.`};throw r({error:e}),c(l,e),new Error(e.message)}n.sendUserInteraction(e,t)},sendAudio(e,t){const n=o()._thamyr;if(!n)throw new Error("[Thamyr] SDK is not initialized yet. Ensure useInitThamyr() has been called.");const{connectionStatus:s}=o();if("connected"!==s){const e={code:0,message:`Cannot send audio: connection status is "${s}". Wait for connected status before sending.`};throw r({error:e}),c(l,e),new Error(e.message)}n.sendAudio(e,t)},addResponseListener:e=>(a.add(e),()=>{a.delete(e)}),addConnectionListener:e=>(d.add(e),()=>{d.delete(e)}),addErrorListener:e=>(l.add(e),()=>{l.delete(e)})}});var l;let m=!1,h=0;const f=new Set;function y(){m=!0}function w(){h++,m=!0}function g(){h--,queueMicrotask(()=>{if(h>0)return;m=!1;const e=[...f];f.clear();for(const t of e)t(new Error("[Thamyr] SDK was torn down: useInitThamyr() unmounted while this call was waiting for initialization."))})}function S(e){return new Error(`[Thamyr] SDK initialization failed: ${e?.message??"unknown error"}`)}async function p(){if("undefined"==typeof window)throw new Error("[Thamyr] The generated API is browser-only; this call ran without a browser environment (SSR).");const e=d.getState();if(e._thamyr)return e._thamyr;if(!m)throw new Error("[Thamyr] SDK is not initialized and no useInitThamyr() is mounted. Add useInitThamyr({clientId: 'cal-pk-…'}) to your root component.");if("error"===e.connectionStatus)throw S(e.error);return new Promise((e,t)=>{let n=!1;const r=e=>{n||(n=!0,s(),f.delete(o),e())},o=e=>{r(()=>{t(e)})};f.add(o);const s=d.subscribe(n=>{if(n._thamyr){const t=n._thamyr;r(()=>{e(t)})}else"error"===n.connectionStatus&&r(()=>{t(S(n.error))})})})}const b=new Set(["then","catch","finally","toJSON"]),T=new Set(Object.getOwnPropertyNames(Object.prototype));function E(e){return"string"!=typeof e||T.has(e)}const v=new Map,I=new Proxy({},{get(e,t){if(E(t))return Reflect.get(e,t);if(b.has(t))return;const n=t;let r=v.get(n);return void 0===r&&(r=function(e){const t=new Map;return new Proxy({},{get(n,r){if(E(r))return Reflect.get(n,r);if(b.has(r))return;const o=r;let s=t.get(o);return void 0===s&&(s=async(...t)=>{const n=(await p())[e],r=n?.[o];if("function"!=typeof r)throw new TypeError(`[Thamyr] ${e}.${o} is not part of the generated API surface.`);return Reflect.apply(r,n,t)},t.set(o,s)),s}})}(n),v.set(n,r)),r}});export{y as a,w as b,g as m,I as t,d as u,p as w};
|
|
9
|
+
//# sourceMappingURL=api-PeedNYnN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-PeedNYnN.js","sources":["../../../../../node_modules/zustand/esm/vanilla.mjs","../../../../../node_modules/zustand/esm/react.mjs","../../../../src/callimacus/store.ts","../../../../src/callimacus/api.ts"],"sourcesContent":["const createStoreImpl = (createState) => {\n let state;\n const listeners = /* @__PURE__ */ new Set();\n const setState = (partial, replace) => {\n const nextState = typeof partial === \"function\" ? partial(state) : partial;\n if (!Object.is(nextState, state)) {\n const previousState = state;\n state = (replace != null ? replace : typeof nextState !== \"object\" || nextState === null) ? nextState : Object.assign({}, state, nextState);\n listeners.forEach((listener) => listener(state, previousState));\n }\n };\n const getState = () => state;\n const getInitialState = () => initialState;\n const subscribe = (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n };\n const api = { setState, getState, getInitialState, subscribe };\n const initialState = state = createState(setState, getState, api);\n return api;\n};\nconst createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);\n\nexport { createStore };\n","import React from 'react';\nimport { createStore } from 'zustand/vanilla';\n\nconst identity = (arg) => arg;\nfunction useStore(api, selector = identity) {\n const slice = React.useSyncExternalStore(\n api.subscribe,\n React.useCallback(() => selector(api.getState()), [api, selector]),\n React.useCallback(() => selector(api.getInitialState()), [api, selector])\n );\n React.useDebugValue(slice);\n return slice;\n}\nconst createImpl = (createState) => {\n const api = createStore(createState);\n const useBoundStore = (selector) => useStore(api, selector);\n Object.assign(useBoundStore, api);\n return useBoundStore;\n};\nconst create = ((createState) => createState ? createImpl(createState) : createImpl);\n\nexport { create, useStore };\n",null,null],"names":["createStoreImpl","createState","state","listeners","Set","setState","partial","replace","nextState","Object","is","previousState","assign","forEach","listener","getState","api","getInitialState","initialState","subscribe","add","delete","identity","arg","createImpl","createStore","useBoundStore","selector","slice","React","useSyncExternalStore","useCallback","useDebugValue","useStore","notifyListeners","error","console","patchedHistory","messages","patch","isPatched","patched","map","message","type","ThamyrResponseType","CHAPTER_EVENT","chapter","applyBlockPatch","useCallimacusStore","set","get","unsubConnectionStatus","generation","responseListeners","connectionListeners","errorListeners","connectionStatus","undefined","_initialized","_thamyr","init","config","window","debug","clientId","errorMessage","code","maxMessages","warn","Infinity","Math","max","thamyr","Thamyr","endpoint","uiObserver","Error","String","currentGen","onResponse","response","BLOCK_PATCH","data","length","onError","callimacusService","onConnectionStatus","connected","status","Boolean","setInitState","reset","disconnect","sendEvent","payload","sendUserInteraction","sendAudio","audio","query","addResponseListener","cb","addConnectionListener","addErrorListener","wasInitRequested","mountedInitOwners","pendingRejecters","markInitRequested","markInitOwnerMounted","markInitOwnerUnmounted","queueMicrotask","rejecters","clear","rejectWaiter","initError","async","waitForInstance","Promise","resolve","reject","isSettled","settle","action","unsubscribe","rejecter","current","instance","blockedNames","objectPrototypeMembers","getOwnPropertyNames","prototype","isPassthroughProperty","property","has","namespaces","Map","thamyrApi","Proxy","target","Reflect","name","namespace","namespaceName","methods","method","args","fn","TypeError","apply","createNamespaceFacade"],"mappings":";;;;;;;0KAAA,MAAMA,EAAmBC,IACvB,IAAIC,EACJ,MAAMC,EAA4B,IAAIC,IAChCC,EAAW,CAACC,EAASC,KACzB,MAAMC,EAA+B,mBAAZF,EAAyBA,EAAQJ,GAASI,EACnE,IAAKG,OAAOC,GAAGF,EAAWN,GAAQ,CAChC,MAAMS,EAAgBT,EACtBA,GAAoB,MAAXK,EAAkBA,EAA+B,iBAAdC,GAAwC,OAAdA,GAAsBA,EAAYC,OAAOG,OAAO,CAAA,EAAIV,EAAOM,GACjIL,EAAUU,QAASC,GAA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F,+CAGlD,OAAOD,QAAQS,MAAMF,EAAIL,EAAWI,IAGrCF,EAAQ7F,IAAI0F,EAAMI,IAGZA,CACR,GAEF,CAmCeK,CAAsBT,GAClCN,EAAWpF,IAAI0F,EAAMC,IAGfA,CACR","x_google_ignoreList":[0,1]}
|
package/dist/esm/index.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* See LICENSE.md for the full terms.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
export{CallimacusEvent,ChapterStatus,ClientEvents,GalleryMode,SLInputEventType,ServerEvents,ThamyrHttpError,ThamyrResponseType,UserInteractionType,callimacusService,clearIntentSessionId,ensureIntentSessionId,extractTtsAudio,getIntentSessionId,initIntent,isSetProduct,logger,setConsent,setDebug,setDebugPanel,setGeo,setIntentSessionMaxAge,transformImageUrl}from"@callimacus/thamyr-core";import{t as
|
|
8
|
+
import{UserInteractionType as e,interactionRound as t,landingRound as n}from"@callimacus/thamyr-core";export{ADD_TO_CART_RESULT_BLOCK,CallimacusEvent,ChapterStatus,ClientEvents,GalleryMode,LANDING_VALUE_MAX_LENGTH,SLInputEventType,ServerEvents,ThamyrHttpError,ThamyrResponseType,UserInteractionType,addToCartResultOf,applyBlockPatch,blockKeyOf,callimacusService,clearIntentSessionId,ensureIntentSessionId,extractTtsAudio,getIntentSessionId,initIntent,interactionRound,isSetProduct,landingRound,logger,receptorsOf,setConsent,setDebug,setDebugPanel,setGeo,setIntentSessionMaxAge,transformImageUrl}from"@callimacus/thamyr-core";import{t as r,w as o,u as a,m as i,a as c,b as s}from"./chunks/api-PeedNYnN.js";import{useMemo as u,useEffect as d,useState as l,useRef as p,useCallback as m}from"react";import"@callimacus/thamyr";function v(e,t){const n=p(t);n.current=t,d(()=>e(e=>{n.current(e)}),[e])}function g(e){const t=a(e=>e.init),n=a(e=>e.reset);c(),d(()=>(s(),t(e),()=>{n(),i()}),[t,n,e.clientId,e.endpoint])}function y(){const r=a(e=>e.messages),o=a(e=>e.sendEvent),i=a(e=>e.sendAudio),c=u(()=>({openLanding(t,r={}){o(e.CREATE_ROUND,n(t,r))},sendInteraction(n,r={}){o(e.CREATE_ROUND,t(n,r))},refresh(n,r,a={}){o(e.CREATE_ROUND,t(r,{...a,block:n}))}}),[o]);return{history:r,sendEvent:o,sendAudio:i,...c}}const f={suggestions:[],loading:!1};function E(e,t={}){const{storyId:n,language:r,debounceMs:o=200}=t,i=a(e=>"connected"===e.connectionStatus),[c,s]=l(f),[u,p]=l(i);return u!==i&&(p(i),i||s(f)),d(()=>{if(!i)return;let t=!1;const c=setTimeout(()=>{s(e=>({...e,loading:!0}));(a.getState()._thamyr?.suggest(e,{storyId:n,language:r})??Promise.resolve(f)).then(({suggestions:e})=>{t||s({suggestions:e,loading:!1})}).catch(()=>{t||s(f)})},""===e?0:o);return()=>{t=!0,clearTimeout(c)}},[e,n,r,o,i]),i?c:f}function h(){return{status:a(e=>e.connectionStatus)}}function T(e){v(a(e=>e.addResponseListener),e)}function I(e){v(a(e=>e.addConnectionListener),e)}function L(e){v(a(e=>e.addErrorListener),e)}function w(){return u(()=>({getCart:async()=>(await o()).cart.getCart(),addItem:async e=>(await o()).cart.addItemToCart({productId:e}),removeItem:async e=>(await o()).cart.removeItemFromCart({productId:e}),updateQuantity:async(e,t)=>(await o()).cart.updateProductQuantity({productId:e,quantity:t})}),[])}function A(){return r}function C(){return u(()=>({similar:async(e,t)=>(await o()).skesis.similar({anchorId:e,...t}),related:async(e,t)=>(await o()).skesis.related({anchorId:e,...t})}),[])}function R(){return u(()=>({getSitemap:async()=>(await o()).sitemap.getSitemap()}),[])}const S=-45,D=1800,b=3e4;function M({silenceThreshold:e=S,silenceDuration:t=D,maxDuration:n=b,onRecordingComplete:r}){const[o,a]=l("idle"),[i,c]=l([]),[s,u]=l(void 0),v=p(void 0),g=p(void 0),y=p(void 0),f=p(void 0),E=p(0),h=p(0),T=p(void 0),I=p([]),L=p(!1),w=m(()=>{if(0!==E.current&&(cancelAnimationFrame(E.current),E.current=0),void 0!==T.current&&(clearTimeout(T.current),T.current=void 0),f.current){for(const e of f.current.getTracks())e.stop();f.current=void 0}"closed"!==g.current?.state&&g.current?.close(),g.current=void 0,y.current=void 0,v.current=void 0,L.current=!1},[]);d(()=>w,[w]);const A=m(()=>{L.current||(L.current=!0,"recording"===v.current?.state&&v.current.stop(),0!==E.current&&(cancelAnimationFrame(E.current),E.current=0),void 0!==T.current&&(clearTimeout(T.current),T.current=void 0))},[]),C=m(async()=>{u(void 0),I.current=[],L.current=!1;try{const o=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,sampleRate:16e3}});f.current=o;const i=new AudioContext({sampleRate:16e3});g.current=i;const s=i.createMediaStreamSource(o),u=i.createAnalyser();u.fftSize=256,u.smoothingTimeConstant=.7,s.connect(u),y.current=u;const d=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm",l=new MediaRecorder(o,{mimeType:d});v.current=l,l.addEventListener("dataavailable",e=>{e.data.size>0&&I.current.push(e.data)}),l.addEventListener("stop",()=>{a("processing");const e=new Blob(I.current,{type:d});w(),r(e)}),l.start(250),a("recording"),h.current=0,T.current=setTimeout(()=>{A()},n);const p=()=>{if(!y.current||L.current)return;const n=y.current.frequencyBinCount,r=new Uint8Array(n);y.current.getByteFrequencyData(r);const o=Math.floor(n/32),a=[];for(let e=0;e<32;e++){let t=0;for(let n=0;n<o;n++)t+=r[e*o+n];a.push(t/o/255)}c(a);let i=0;for(const e of r){const t=e/255;i+=t*t}const s=Math.sqrt(i/n);if((s>0?20*Math.log10(s):-100)<e){if(0===h.current)h.current=Date.now();else if(Date.now()-h.current>t)return void A()}else h.current=0;E.current=requestAnimationFrame(p)};p()}catch{u("Microphone access denied"),a("idle"),w()}},[e,t,n,r,A,w]),R=m(()=>{a("idle"),c([])},[]);return{state:o,audioLevels:i,startRecording:C,stopRecording:A,reset:R,error:s}}function U(e){const t=p(void 0),[n,r]=l("idle"),[o,a]=l(void 0);d(()=>{const n=e?.audioUrl;if("undefined"==typeof Audio||void 0===n||""===n)return t.current=void 0,void r("idle");const o=new Audio(n);o.preload="none",t.current=o,r("idle"),a(void 0);const i=()=>{r("playing")},c=()=>{r("loading")},s=()=>{r(e=>"ended"===e?e:"paused")},u=()=>{r("ended")},d=()=>{a("Audio playback failed"),r("error")};return o.addEventListener("playing",i),o.addEventListener("waiting",c),o.addEventListener("pause",s),o.addEventListener("ended",u),o.addEventListener("error",d),()=>{o.pause(),o.removeEventListener("playing",i),o.removeEventListener("waiting",c),o.removeEventListener("pause",s),o.removeEventListener("ended",u),o.removeEventListener("error",d),o.src="",t.current=void 0}},[e?.audioUrl]);const i=m(async()=>{const e=t.current;if(e)try{a(void 0),r("loading"),await e.play()}catch{a("Audio playback failed"),r("error")}},[]),c=m(()=>{t.current?.pause()},[]),s=m(()=>{const e=t.current;e&&(e.pause(),e.currentTime=0,r("idle"))},[]),u=m(()=>{const e=t.current;e&&(e.paused?i():e.pause())},[i]);return{state:n,isPlaying:"playing"===n||"loading"===n,error:o,play:i,pause:c,toggle:u,stop:s}}export{r as thamyrApi,A as useApi,a as useCallimacusStore,w as useCart,h as useConnection,g as useInitThamyr,I as useOnConnectionChange,L as useOnError,T as useOnResponse,R as useSitemap,C as useSkesis,E as useSuggestions,y as useThamyr,U as useTtsAudio,M as useVoiceRecorder};
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/callimacus/hooks.ts","../../../src/voice/use-voice-recorder.ts","../../../src/audio/use-tts-audio.ts"],"sourcesContent":[null,null,null],"names":["useEventListener","addListener","callback","callbackRef","useRef","current","useEffect","arg","useInitThamyr","config","init","useCallimacusStore","s","reset","markInitRequested","markInitOwnerMounted","markInitOwnerUnmounted","clientId","endpoint","useThamyr","history","messages","sendEvent","sendAudio","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/callimacus/hooks.ts","../../../src/voice/use-voice-recorder.ts","../../../src/audio/use-tts-audio.ts"],"sourcesContent":[null,null,null],"names":["useEventListener","addListener","callback","callbackRef","useRef","current","useEffect","arg","useInitThamyr","config","init","useCallimacusStore","s","reset","markInitRequested","markInitOwnerMounted","markInitOwnerUnmounted","clientId","endpoint","useThamyr","history","messages","sendEvent","sendAudio","rounds","useMemo","openLanding","value","options","UserInteractionType","CREATE_ROUND","landingRound","sendInteraction","id","interactionRound","refresh","block","interaction","NO_SUGGESTIONS","suggestions","loading","useSuggestions","prefix","storyId","language","debounceMs","isConnected","connectionStatus","state","setState","useState","wasConnected","setWasConnected","isStale","timer","setTimeout","getState","_thamyr","suggest","Promise","resolve","then","catch","clearTimeout","useConnection","status","useOnResponse","addResponseListener","useOnConnectionChange","addConnectionListener","useOnError","addErrorListener","useCart","async","waitForInstance","cart","getCart","productId","addItemToCart","removeItemFromCart","quantity","updateProductQuantity","useApi","thamyrApi","useSkesis","anchorId","skesis","similar","related","useSitemap","sitemap","getSitemap","defaultOptions","useVoiceRecorder","silenceThreshold","silenceDuration","maxDuration","onRecordingComplete","audioLevels","setAudioLevels","error","setError","undefined","mediaRecorderRef","audioContextRef","analyserRef","streamRef","animationFrameRef","silenceStartRef","maxDurationTimerRef","chunksRef","stoppingRef","cleanup","useCallback","cancelAnimationFrame","track","getTracks","stop","close","stopRecording","startRecording","stream","navigator","mediaDevices","getUserMedia","audio","echoCancellation","noiseSuppression","sampleRate","audioContext","AudioContext","source","createMediaStreamSource","analyser","createAnalyser","fftSize","smoothingTimeConstant","connect","mimeType","MediaRecorder","isTypeSupported","mediaRecorder","addEventListener","event","data","size","push","audioBlob","Blob","type","start","monitorAudio","bufferLength","frequencyBinCount","dataArray","Uint8Array","getByteFrequencyData","step","Math","floor","levels","i","sum","j","sumSquares","normalized","rms","sqrt","log10","Date","now","requestAnimationFrame","useTtsAudio","audioRef","audioUrl","Audio","element","preload","onPlaying","onWaiting","onPause","previous","on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
|
|
|
5
5
|
* See LICENSE.md for the full terms.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import{queryOptions as t}from"@tanstack/react-query";import{t as r}from"./chunks/api-
|
|
8
|
+
import{queryOptions as t}from"@tanstack/react-query";import{t as r}from"./chunks/api-PeedNYnN.js";import"@callimacus/thamyr";import"@callimacus/thamyr-core";import"react";async function a(t,a,n,o){const i=r[t][a],c={signal:o,throwOnError:!0};return(await(void 0===n?i(c):i(n,c))).data}function n(r,n,o){return t({queryKey:["thamyr",r,n,o],queryFn:async({signal:t})=>a(r,n,o,t)})}function o(t,r){return{mutationKey:["thamyr",t,r],mutationFn:async n=>a(t,r,n)}}export{o as thamyrMutationOptions,n as thamyrQueryOptions};
|
|
9
9
|
//# sourceMappingURL=query.js.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
import * as _callimacus_thamyr_core from '@callimacus/thamyr-core';
|
|
9
|
-
import { UiObserverConfig, CallimacusApi, ErrorMessage, ThamyrResponse, UserInteractionType, InteractionPayloadMap, TtsAudio } from '@callimacus/thamyr-core';
|
|
10
|
-
export { Block, BoundingBox, CallimacusEvent, Chapter, ChapterStatus, ClientEvents, ClientInfo, ConnectionStatusCallback, ErrorCallback, ErrorMessage, Gallery, GalleryMode, Image, ImageEdits, ImageFormatEdit, ImageResizeEdit, InteractionContext, InteractionPayloadMap, LocalizedEPArtwork, LocalizedEPChapter, LogLevel, LoggerConfig, ProductMatch, SLDocument, SLDocumentSection, SLInputEvent, SLInputEventType, ServerEvents, ServerResponseCallback, Story, ThamyrHttpError, ThamyrResponse, ThamyrResponseType, Topic, TtsAudio, UiElement, UiObserverConfig, UiSnapshot, UserInteraction, UserInteractionType, Video, WhisperPayload, callimacusService, clearIntentSessionId, ensureIntentSessionId, extractTtsAudio, getIntentSessionId, initIntent, isSetProduct, logger, setConsent, setDebug, setDebugPanel, setGeo, setIntentSessionMaxAge, transformImageUrl } from '@callimacus/thamyr-core';
|
|
9
|
+
import { UiObserverConfig, RoundOptions, CallimacusApi, ErrorMessage, ThamyrResponse, InteractionId, InteractionOptions, UserInteractionType, InteractionPayloadMap, TtsAudio } from '@callimacus/thamyr-core';
|
|
10
|
+
export { ADD_TO_CART_RESULT_BLOCK, AddToCartResult, Block, BlockPatch, BoundingBox, CallimacusEvent, Chapter, ChapterStatus, ClientEvents, ClientInfo, ConnectionStatusCallback, ErrorCallback, ErrorMessage, Gallery, GalleryMode, Image, ImageEdits, ImageFormatEdit, ImageResizeEdit, InteractionContext, InteractionId, InteractionOptions, InteractionPayload, InteractionPayloadMap, LANDING_VALUE_MAX_LENGTH, LocalizedEPArtwork, LocalizedEPChapter, LogLevel, LoggerConfig, ProductMatch, RiveManifest, RoundOptions, SLDocument, SLDocumentSection, SLInputEvent, SLInputEventType, ServerEvents, ServerResponseCallback, Story, SuggestPayload, Suggestions, ThamyrHttpError, ThamyrInteractionMap, ThamyrResponse, ThamyrResponseType, Topic, TtsAudio, UiElement, UiObserverConfig, UiSnapshot, UserInteraction, UserInteractionType, Video, WhisperPayload, addToCartResultOf, applyBlockPatch, blockKeyOf, callimacusService, clearIntentSessionId, ensureIntentSessionId, extractTtsAudio, getIntentSessionId, initIntent, interactionRound, isSetProduct, landingRound, logger, receptorsOf, setConsent, setDebug, setDebugPanel, setGeo, setIntentSessionMaxAge, transformImageUrl } from '@callimacus/thamyr-core';
|
|
11
11
|
import { Thamyr } from '@callimacus/thamyr';
|
|
12
12
|
import * as zustand from 'zustand';
|
|
13
13
|
|
|
@@ -82,14 +82,23 @@ function Chat() {
|
|
|
82
82
|
return <button onClick={handleSend} disabled={status !== 'connected'}>Send</button>;
|
|
83
83
|
}
|
|
84
84
|
```
|
|
85
|
+
|
|
86
|
+
Rounds without a message go through the same gate: `openLanding(value?)` opens
|
|
87
|
+
the landing page, `sendInteraction(id, options?)` sends a declared interaction
|
|
88
|
+
(typed once `ThamyrInteractionMap` is augmented), `refresh(block, interaction)`
|
|
89
|
+
re-runs the contents a block declares for its refresh interaction.
|
|
85
90
|
*/
|
|
86
91
|
declare function useThamyr(): {
|
|
92
|
+
openLanding(value?: string, options?: RoundOptions): void;
|
|
93
|
+
sendInteraction<I extends InteractionId>(id: I, options?: InteractionOptions<I>): void;
|
|
94
|
+
refresh(block: string, interaction: InteractionId, options?: RoundOptions): void;
|
|
87
95
|
history: ({
|
|
88
96
|
type: "chapter-event";
|
|
89
97
|
chapter: {
|
|
90
98
|
id: string;
|
|
91
99
|
deleted: boolean;
|
|
92
100
|
language?: string;
|
|
101
|
+
contentLanguage?: string;
|
|
93
102
|
receptors?: Array<string>;
|
|
94
103
|
intent?: Array<string>;
|
|
95
104
|
subCondition?: Array<string>;
|
|
@@ -221,6 +230,49 @@ declare function useThamyr(): {
|
|
|
221
230
|
[key: string]: unknown;
|
|
222
231
|
};
|
|
223
232
|
};
|
|
233
|
+
} | {
|
|
234
|
+
id: string;
|
|
235
|
+
document: string;
|
|
236
|
+
type: "rive";
|
|
237
|
+
content?: string;
|
|
238
|
+
url: string;
|
|
239
|
+
properties: {
|
|
240
|
+
artboards: Array<{
|
|
241
|
+
name: string;
|
|
242
|
+
animations: Array<string>;
|
|
243
|
+
stateMachines: Array<{
|
|
244
|
+
name: string;
|
|
245
|
+
inputs: Array<{
|
|
246
|
+
name: string;
|
|
247
|
+
type: "boolean" | "number" | "trigger";
|
|
248
|
+
}>;
|
|
249
|
+
}>;
|
|
250
|
+
viewModel?: string;
|
|
251
|
+
}>;
|
|
252
|
+
viewModels: Array<{
|
|
253
|
+
name: string;
|
|
254
|
+
instances: Array<string>;
|
|
255
|
+
properties: Array<{
|
|
256
|
+
name: string;
|
|
257
|
+
type: string;
|
|
258
|
+
values?: Array<string>;
|
|
259
|
+
}>;
|
|
260
|
+
}>;
|
|
261
|
+
textRuns: Array<{
|
|
262
|
+
artboard: string;
|
|
263
|
+
name: string;
|
|
264
|
+
text: string;
|
|
265
|
+
}>;
|
|
266
|
+
events: Array<{
|
|
267
|
+
artboard: string;
|
|
268
|
+
name: string;
|
|
269
|
+
url?: string;
|
|
270
|
+
properties: Array<{
|
|
271
|
+
name: string;
|
|
272
|
+
type: "number" | "boolean" | "string";
|
|
273
|
+
}>;
|
|
274
|
+
}>;
|
|
275
|
+
};
|
|
224
276
|
} | {
|
|
225
277
|
id: string;
|
|
226
278
|
document: string;
|
|
@@ -352,6 +404,49 @@ declare function useThamyr(): {
|
|
|
352
404
|
[key: string]: unknown;
|
|
353
405
|
};
|
|
354
406
|
};
|
|
407
|
+
} | {
|
|
408
|
+
id: string;
|
|
409
|
+
document: string;
|
|
410
|
+
type: "rive";
|
|
411
|
+
content?: string;
|
|
412
|
+
url: string;
|
|
413
|
+
properties: {
|
|
414
|
+
artboards: Array<{
|
|
415
|
+
name: string;
|
|
416
|
+
animations: Array<string>;
|
|
417
|
+
stateMachines: Array<{
|
|
418
|
+
name: string;
|
|
419
|
+
inputs: Array<{
|
|
420
|
+
name: string;
|
|
421
|
+
type: "boolean" | "number" | "trigger";
|
|
422
|
+
}>;
|
|
423
|
+
}>;
|
|
424
|
+
viewModel?: string;
|
|
425
|
+
}>;
|
|
426
|
+
viewModels: Array<{
|
|
427
|
+
name: string;
|
|
428
|
+
instances: Array<string>;
|
|
429
|
+
properties: Array<{
|
|
430
|
+
name: string;
|
|
431
|
+
type: string;
|
|
432
|
+
values?: Array<string>;
|
|
433
|
+
}>;
|
|
434
|
+
}>;
|
|
435
|
+
textRuns: Array<{
|
|
436
|
+
artboard: string;
|
|
437
|
+
name: string;
|
|
438
|
+
text: string;
|
|
439
|
+
}>;
|
|
440
|
+
events: Array<{
|
|
441
|
+
artboard: string;
|
|
442
|
+
name: string;
|
|
443
|
+
url?: string;
|
|
444
|
+
properties: Array<{
|
|
445
|
+
name: string;
|
|
446
|
+
type: "number" | "boolean" | "string";
|
|
447
|
+
}>;
|
|
448
|
+
}>;
|
|
449
|
+
};
|
|
355
450
|
} | {
|
|
356
451
|
id: string;
|
|
357
452
|
document: string;
|
|
@@ -843,6 +938,7 @@ declare function useThamyr(): {
|
|
|
843
938
|
priority?: number;
|
|
844
939
|
metaJson?: unknown;
|
|
845
940
|
type: `custom:${string}`;
|
|
941
|
+
key?: string;
|
|
846
942
|
name?: string;
|
|
847
943
|
data: unknown;
|
|
848
944
|
}>;
|
|
@@ -857,6 +953,7 @@ declare function useThamyr(): {
|
|
|
857
953
|
id: string;
|
|
858
954
|
deleted: boolean;
|
|
859
955
|
language?: string;
|
|
956
|
+
contentLanguage?: string;
|
|
860
957
|
receptors?: Array<string>;
|
|
861
958
|
intent?: Array<string>;
|
|
862
959
|
subCondition?: Array<string>;
|
|
@@ -988,6 +1085,49 @@ declare function useThamyr(): {
|
|
|
988
1085
|
[key: string]: unknown;
|
|
989
1086
|
};
|
|
990
1087
|
};
|
|
1088
|
+
} | {
|
|
1089
|
+
id: string;
|
|
1090
|
+
document: string;
|
|
1091
|
+
type: "rive";
|
|
1092
|
+
content?: string;
|
|
1093
|
+
url: string;
|
|
1094
|
+
properties: {
|
|
1095
|
+
artboards: Array<{
|
|
1096
|
+
name: string;
|
|
1097
|
+
animations: Array<string>;
|
|
1098
|
+
stateMachines: Array<{
|
|
1099
|
+
name: string;
|
|
1100
|
+
inputs: Array<{
|
|
1101
|
+
name: string;
|
|
1102
|
+
type: "boolean" | "number" | "trigger";
|
|
1103
|
+
}>;
|
|
1104
|
+
}>;
|
|
1105
|
+
viewModel?: string;
|
|
1106
|
+
}>;
|
|
1107
|
+
viewModels: Array<{
|
|
1108
|
+
name: string;
|
|
1109
|
+
instances: Array<string>;
|
|
1110
|
+
properties: Array<{
|
|
1111
|
+
name: string;
|
|
1112
|
+
type: string;
|
|
1113
|
+
values?: Array<string>;
|
|
1114
|
+
}>;
|
|
1115
|
+
}>;
|
|
1116
|
+
textRuns: Array<{
|
|
1117
|
+
artboard: string;
|
|
1118
|
+
name: string;
|
|
1119
|
+
text: string;
|
|
1120
|
+
}>;
|
|
1121
|
+
events: Array<{
|
|
1122
|
+
artboard: string;
|
|
1123
|
+
name: string;
|
|
1124
|
+
url?: string;
|
|
1125
|
+
properties: Array<{
|
|
1126
|
+
name: string;
|
|
1127
|
+
type: "number" | "boolean" | "string";
|
|
1128
|
+
}>;
|
|
1129
|
+
}>;
|
|
1130
|
+
};
|
|
991
1131
|
} | {
|
|
992
1132
|
id: string;
|
|
993
1133
|
document: string;
|
|
@@ -1119,6 +1259,49 @@ declare function useThamyr(): {
|
|
|
1119
1259
|
[key: string]: unknown;
|
|
1120
1260
|
};
|
|
1121
1261
|
};
|
|
1262
|
+
} | {
|
|
1263
|
+
id: string;
|
|
1264
|
+
document: string;
|
|
1265
|
+
type: "rive";
|
|
1266
|
+
content?: string;
|
|
1267
|
+
url: string;
|
|
1268
|
+
properties: {
|
|
1269
|
+
artboards: Array<{
|
|
1270
|
+
name: string;
|
|
1271
|
+
animations: Array<string>;
|
|
1272
|
+
stateMachines: Array<{
|
|
1273
|
+
name: string;
|
|
1274
|
+
inputs: Array<{
|
|
1275
|
+
name: string;
|
|
1276
|
+
type: "boolean" | "number" | "trigger";
|
|
1277
|
+
}>;
|
|
1278
|
+
}>;
|
|
1279
|
+
viewModel?: string;
|
|
1280
|
+
}>;
|
|
1281
|
+
viewModels: Array<{
|
|
1282
|
+
name: string;
|
|
1283
|
+
instances: Array<string>;
|
|
1284
|
+
properties: Array<{
|
|
1285
|
+
name: string;
|
|
1286
|
+
type: string;
|
|
1287
|
+
values?: Array<string>;
|
|
1288
|
+
}>;
|
|
1289
|
+
}>;
|
|
1290
|
+
textRuns: Array<{
|
|
1291
|
+
artboard: string;
|
|
1292
|
+
name: string;
|
|
1293
|
+
text: string;
|
|
1294
|
+
}>;
|
|
1295
|
+
events: Array<{
|
|
1296
|
+
artboard: string;
|
|
1297
|
+
name: string;
|
|
1298
|
+
url?: string;
|
|
1299
|
+
properties: Array<{
|
|
1300
|
+
name: string;
|
|
1301
|
+
type: "number" | "boolean" | "string";
|
|
1302
|
+
}>;
|
|
1303
|
+
}>;
|
|
1304
|
+
};
|
|
1122
1305
|
} | {
|
|
1123
1306
|
id: string;
|
|
1124
1307
|
document: string;
|
|
@@ -1610,6 +1793,7 @@ declare function useThamyr(): {
|
|
|
1610
1793
|
priority?: number;
|
|
1611
1794
|
metaJson?: unknown;
|
|
1612
1795
|
type: `custom:${string}`;
|
|
1796
|
+
key?: string;
|
|
1613
1797
|
name?: string;
|
|
1614
1798
|
data: unknown;
|
|
1615
1799
|
}>;
|
|
@@ -1636,11 +1820,66 @@ declare function useThamyr(): {
|
|
|
1636
1820
|
storyId: string;
|
|
1637
1821
|
success: boolean;
|
|
1638
1822
|
};
|
|
1823
|
+
} | {
|
|
1824
|
+
type: "block-patch";
|
|
1825
|
+
data: {
|
|
1826
|
+
storyId: string;
|
|
1827
|
+
chapterId: string;
|
|
1828
|
+
blockId: string;
|
|
1829
|
+
contentId: string;
|
|
1830
|
+
values: {
|
|
1831
|
+
[key: string]: string | number | boolean;
|
|
1832
|
+
};
|
|
1833
|
+
inputs: {
|
|
1834
|
+
[key: string]: number | boolean;
|
|
1835
|
+
};
|
|
1836
|
+
textRuns: {
|
|
1837
|
+
[key: string]: string;
|
|
1838
|
+
};
|
|
1839
|
+
fire: Array<string>;
|
|
1840
|
+
};
|
|
1639
1841
|
})[];
|
|
1640
|
-
sendEvent: <T extends
|
|
1842
|
+
sendEvent: <T extends UserInteractionType>(type: T, payload: _callimacus_thamyr_core.InteractionPayloadMap[T]) => void;
|
|
1641
1843
|
sendAudio: (audio: Blob, query?: string) => void;
|
|
1642
1844
|
};
|
|
1643
1845
|
/**
|
|
1846
|
+
What {@link useSuggestions} returns: the current list and whether a newer one is on its way.
|
|
1847
|
+
*/
|
|
1848
|
+
type SuggestionsState = {
|
|
1849
|
+
suggestions: string[];
|
|
1850
|
+
loading: boolean;
|
|
1851
|
+
};
|
|
1852
|
+
/**
|
|
1853
|
+
Options of {@link useSuggestions}.
|
|
1854
|
+
*/
|
|
1855
|
+
type SuggestionsOptions = RoundOptions & {
|
|
1856
|
+
/**
|
|
1857
|
+
How long to wait after the last keystroke before asking; the empty prefix asks at once. Default 200 ms.
|
|
1858
|
+
*/
|
|
1859
|
+
debounceMs?: number;
|
|
1860
|
+
};
|
|
1861
|
+
/**
|
|
1862
|
+
Prompt suggestions for an input box, following `prefix` as the visitor types:
|
|
1863
|
+
the tenant's starter questions while it is shorter than three characters,
|
|
1864
|
+
autocomplete from there. Debounced, and a late answer never overwrites a newer
|
|
1865
|
+
prefix. Empty until the SDK is connected; fail-open like the server, so an
|
|
1866
|
+
error or a timeout shows no suggestions rather than an error.
|
|
1867
|
+
@param prefix - What the visitor has typed so far.
|
|
1868
|
+
@param options - The story to suggest for, the language, the debounce.
|
|
1869
|
+
@example
|
|
1870
|
+
```tsx
|
|
1871
|
+
function Ask({ storyId }: Props) {
|
|
1872
|
+
const [text, setText] = useState('');
|
|
1873
|
+
const { suggestions } = useSuggestions(text, { storyId });
|
|
1874
|
+
return (<>
|
|
1875
|
+
<input value={text} onChange={e => setText(e.target.value)} />
|
|
1876
|
+
{suggestions.map(s => <button key={s} onClick={() => setText(s)}>{s}</button>)}
|
|
1877
|
+
</>);
|
|
1878
|
+
}
|
|
1879
|
+
```
|
|
1880
|
+
*/
|
|
1881
|
+
declare function useSuggestions(prefix: string, options?: SuggestionsOptions): SuggestionsState;
|
|
1882
|
+
/**
|
|
1644
1883
|
Returns the current connection status of the Thamyr SDK.
|
|
1645
1884
|
|
|
1646
1885
|
Starts at `idle`. Moves to `connecting` on init, then to `connected` — or straight
|
|
@@ -1944,5 +2183,5 @@ stream URL.
|
|
|
1944
2183
|
*/
|
|
1945
2184
|
declare function useTtsAudio(audio: TtsAudio | undefined): UseTtsAudioReturn;
|
|
1946
2185
|
|
|
1947
|
-
export { thamyrApi, useApi, useCallimacusStore, useCart, useConnection, useInitThamyr, useOnConnectionChange, useOnError, useOnResponse, useSitemap, useSkesis, useThamyr, useTtsAudio, useVoiceRecorder };
|
|
1948
|
-
export type { CallimacusInitConfig, CartActions, ConnectionStatus, SitemapActions, SkesisActions, TtsAudioState, UseTtsAudioReturn, UseVoiceRecorderOptions, UseVoiceRecorderReturn, VoiceRecorderState };
|
|
2186
|
+
export { thamyrApi, useApi, useCallimacusStore, useCart, useConnection, useInitThamyr, useOnConnectionChange, useOnError, useOnResponse, useSitemap, useSkesis, useSuggestions, useThamyr, useTtsAudio, useVoiceRecorder };
|
|
2187
|
+
export type { CallimacusInitConfig, CartActions, ConnectionStatus, SitemapActions, SkesisActions, SuggestionsOptions, SuggestionsState, TtsAudioState, UseTtsAudioReturn, UseVoiceRecorderOptions, UseVoiceRecorderReturn, VoiceRecorderState };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@callimacus/thamyr-react",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "React package for Thamyr",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"lint": "eslint src"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@callimacus/thamyr": "^4.
|
|
43
|
-
"@callimacus/thamyr-core": "^4.
|
|
42
|
+
"@callimacus/thamyr": "^4.4.0",
|
|
43
|
+
"@callimacus/thamyr-core": "^4.4.0",
|
|
44
44
|
"zustand": "^5.0.15"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright © 2025–2026 Solomei AI SRL. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* Proprietary software, licensed for use by Callimacus customers only.
|
|
5
|
-
* See LICENSE.md for the full terms.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
import{Thamyr as e}from"@solomei-ai/thamyr";import{callimacusService as t}from"@solomei-ai/thamyr-core";import n from"react";const r=e=>{let t;const n=new Set,r=(e,r)=>{const o="function"==typeof e?e(t):e;if(!Object.is(o,t)){const e=t;t=(null!=r?r:"object"!=typeof o||null===o)?o:Object.assign({},t,o),n.forEach(n=>n(t,e))}},o=()=>t,s={setState:r,getState:o,getInitialState:()=>i,subscribe:e=>(n.add(e),()=>n.delete(e))},i=t=e(r,o,s);return s},o=e=>e;const s=e=>{const t=(e=>e?r(e):r)(e),s=e=>function(e,t=o){const r=n.useSyncExternalStore(e.subscribe,n.useCallback(()=>t(e.getState()),[e,t]),n.useCallback(()=>t(e.getInitialState()),[e,t]));return n.useDebugValue(r),r}(t,e);return Object.assign(s,t),s};function i(e,t){for(const n of e)try{n(t)}catch(e){console.error("[Thamyr] Listener threw:",e)}}const a=(c?s(c):s)((n,r)=>{let o,s=0;const a=new Set,c=new Set,d=new Set;return{connectionStatus:"idle",messages:[],error:void 0,_initialized:!1,_thamyr:void 0,init(u){if(r()._initialized)return;if("undefined"==typeof window)return void console.debug("[Thamyr] init() skipped: no browser environment detected (SSR).");const{clientId:l}=u;if(!l){console.error("[Thamyr] clientId is required. Pass your Callimacus Client ID (`cal-pk-…`) to useInitThamyr().");const e={code:0,message:"clientId is required. Pass your Callimacus Client ID (`cal-pk-…`) to useInitThamyr()."};return n({connectionStatus:"error",error:e}),i(d,e),void i(c,"error")}void 0!==u.maxMessages&&u.maxMessages<0&&console.warn("[Thamyr] maxMessages must be >= 0. Received:",u.maxMessages,". Clamping to 1.");const m=0===u.maxMessages?1/0:Math.max(1,u.maxMessages??50);let f;n({connectionStatus:"connecting",error:void 0});try{f=new e({clientId:l,endpoint:u.endpoint,uiObserver:u.uiObserver})}catch(e){console.error("[Thamyr] Failed to create Thamyr instance:",e);const t={code:0,message:e instanceof Error?e.message:String(e)};return n({connectionStatus:"error",error:t}),i(d,t),void i(c,"error")}const h=++s;f.onResponse(e=>{s===h&&(n(t=>{const n=[...t.messages,e];return{messages:n.length>m?n.slice(-m):n}}),i(a,e))}),f.onError(e=>{s===h&&(n({error:e,connectionStatus:"error"}),i(d,e),i(c,"error"))}),o=t.onConnectionStatus(e=>{if(s!==h)return;const t=e?"connected":"disconnected";n({connectionStatus:t}),i(c,t)}),function(e){n({_initialized:Boolean(e),_thamyr:e})}(f)},reset(){if(r()._initialized){s++;try{o?.()}catch(e){console.error("[Thamyr] Error unsubscribing connection status listener:",e)}try{t.disconnect()}catch(e){console.error("[Thamyr] Error disconnecting:",e)}o=void 0,n({_initialized:!1,_thamyr:void 0,connectionStatus:"idle",messages:[],error:void 0})}else"idle"!==r().connectionStatus&&n({connectionStatus:"idle",error:void 0})},sendEvent(e,t){const o=r()._thamyr;if(!o)throw new Error("[Thamyr] SDK is not initialized yet. Ensure useInitThamyr() has been called.");const{connectionStatus:s}=r();if("connected"!==s){const e={code:0,message:`Cannot send event: connection status is "${s}". Wait for connected status before sending.`};throw n({error:e}),i(d,e),new Error(e.message)}o.sendUserInteraction(e,t)},sendAudio(e,t){const o=r()._thamyr;if(!o)throw new Error("[Thamyr] SDK is not initialized yet. Ensure useInitThamyr() has been called.");const{connectionStatus:s}=r();if("connected"!==s){const e={code:0,message:`Cannot send audio: connection status is "${s}". Wait for connected status before sending.`};throw n({error:e}),i(d,e),new Error(e.message)}o.sendAudio(e,t)},addResponseListener:e=>(a.add(e),()=>{a.delete(e)}),addConnectionListener:e=>(c.add(e),()=>{c.delete(e)}),addErrorListener:e=>(d.add(e),()=>{d.delete(e)})}});var c;let d=!1,u=0;const l=new Set;function m(){d=!0}function f(){u++,d=!0}function h(){u--,queueMicrotask(()=>{if(u>0)return;d=!1;const e=[...l];l.clear();for(const t of e)t(new Error("[Thamyr] SDK was torn down: useInitThamyr() unmounted while this call was waiting for initialization."))})}function y(e){return new Error(`[Thamyr] SDK initialization failed: ${e?.message??"unknown error"}`)}async function w(){if("undefined"==typeof window)throw new Error("[Thamyr] The generated API is browser-only; this call ran without a browser environment (SSR).");const e=a.getState();if(e._thamyr)return e._thamyr;if(!d)throw new Error("[Thamyr] SDK is not initialized and no useInitThamyr() is mounted. Add useInitThamyr({clientId: 'cal-pk-…'}) to your root component.");if("error"===e.connectionStatus)throw y(e.error);return new Promise((e,t)=>{let n=!1;const r=e=>{n||(n=!0,s(),l.delete(o),e())},o=e=>{r(()=>{t(e)})};l.add(o);const s=a.subscribe(n=>{if(n._thamyr){const t=n._thamyr;r(()=>{e(t)})}else"error"===n.connectionStatus&&r(()=>{t(y(n.error))})})})}const g=new Set(["then","catch","finally","toJSON"]),S=new Set(Object.getOwnPropertyNames(Object.prototype));function p(e){return"string"!=typeof e||S.has(e)}const b=new Map,T=new Proxy({},{get(e,t){if(p(t))return Reflect.get(e,t);if(g.has(t))return;const n=t;let r=b.get(n);return void 0===r&&(r=function(e){const t=new Map;return new Proxy({},{get(n,r){if(p(r))return Reflect.get(n,r);if(g.has(r))return;const o=r;let s=t.get(o);return void 0===s&&(s=async(...t)=>{const n=(await w())[e],r=n?.[o];if("function"!=typeof r)throw new TypeError(`[Thamyr] ${e}.${o} is not part of the generated API surface.`);return Reflect.apply(r,n,t)},t.set(o,s)),s}})}(n),b.set(n,r)),r}});export{m as a,f as b,h as m,T as t,a as u,w};
|
|
9
|
-
//# sourceMappingURL=api-BeXO8dlg.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-BeXO8dlg.js","sources":["../../../../../node_modules/zustand/esm/vanilla.mjs","../../../../../node_modules/zustand/esm/react.mjs","../../../../src/callimacus/store.ts","../../../../src/callimacus/api.ts"],"sourcesContent":["const createStoreImpl = (createState) => {\n let state;\n const listeners = /* @__PURE__ */ new Set();\n const setState = (partial, replace) => {\n const nextState = typeof partial === \"function\" ? partial(state) : partial;\n if (!Object.is(nextState, state)) {\n const previousState = state;\n state = (replace != null ? replace : typeof nextState !== \"object\" || nextState === null) ? nextState : Object.assign({}, state, nextState);\n listeners.forEach((listener) => listener(state, previousState));\n }\n };\n const getState = () => state;\n const getInitialState = () => initialState;\n const subscribe = (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n };\n const api = { setState, getState, getInitialState, subscribe };\n const initialState = state = createState(setState, getState, api);\n return api;\n};\nconst createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);\n\nexport { createStore };\n","import React from 'react';\nimport { createStore } from 'zustand/vanilla';\n\nconst identity = (arg) => arg;\nfunction useStore(api, selector = identity) {\n const slice = React.useSyncExternalStore(\n api.subscribe,\n React.useCallback(() => selector(api.getState()), [api, selector]),\n React.useCallback(() => selector(api.getInitialState()), [api, selector])\n );\n React.useDebugValue(slice);\n return slice;\n}\nconst createImpl = (createState) => {\n const api = createStore(createState);\n const useBoundStore = (selector) => useStore(api, selector);\n Object.assign(useBoundStore, api);\n return useBoundStore;\n};\nconst create = ((createState) => createState ? createImpl(createState) : createImpl);\n\nexport { create, useStore };\n",null,null],"names":["createStoreImpl","createState","state","listeners","Set","setState","partial","replace","nextState","Object","is","previousState","assign","forEach","listener","getState","api","getInitialState","initialState","subscribe","add","delete","identity","arg","createImpl","createStore","useBoundStore","selector","slice","React","useSyncExternalStore","useCallback","useDebugValue","useStore","notifyListeners","error","console","useCallimacusStore","set","get","unsubConnectionStatus","generation","responseListeners","connectionListeners","errorListeners","connectionStatus","messages","undefined","_initialized","_thamyr","init","config","window","debug","clientId","errorMessage","code","message","maxMessages","warn","Infinity","Math","max","thamyr","Thamyr","endpoint","uiObserver","Error","String","currentGen","onResponse","response","length","onError","callimacusService","onConnectionStatus","connected","status","Boolean","setInitState","reset","disconnect","sendEvent","type","payload","sendUserInteraction","sendAudio","audio","query","addResponseListener","cb","addConnectionListener","addErrorListener","wasInitRequested","mountedInitOwners","pendingRejecters","markInitRequested","markInitOwnerMounted","markInitOwnerUnmounted","queueMicrotask","rejecters","clear","rejectWaiter","initError","async","waitForInstance","Promise","resolve","reject","isSettled","settle","action","unsubscribe","rejecter","current","instance","blockedNames","objectPrototypeMembers","getOwnPropertyNames","prototype","isPassthroughProperty","property","has","namespaces","Map","thamyrApi","Proxy","target","Reflect","name","namespace","namespaceName","methods","method","args","fn","TypeError","apply","createNamespaceFacade"],"mappings":";;;;;;;6HAAA,MAAMA,EAAmBC,IACvB,IAAIC,EACJ,MAAMC,EAA4B,IAAIC,IAChCC,EAAW,CAACC,EAASC,KACzB,MAAMC,EAA+B,mBAAZF,EAAyBA,EAAQJ,GAASI,EACnE,IAAKG,OAAOC,GAAGF,EAAWN,GAAQ,CAChC,MAAMS,EAAgBT,EACtBA,GAAoB,MAAXK,EAAkBA,EAA+B,iBAAdC,GAAwC,OAAdA,GAAsBA,EAAYC,OAAOG,OAAO,CAAA,EAAIV,EAAOM,GACjIL,EAAUU,QAASC,GAAaA,EAASZ,EAAOS,GAClD,GAEII,EAAW,IAAMb,EAMjBc,EAAM,CAAEX,WAAUU,WAAUE,gBALV,IAAMC,EAKqBC,UAJhCL,IACjBX,EAAUiB,IAAIN,GACP,IAAMX,EAAUkB,OAAOP,KAG1BI,EAAehB,EAAQD,EAAYI,EAAUU,EAAUC,GAC7D,OAAOA,GChBHM,EAAYC,GAAQA,EAU1B,MAAMC,EAAcvB,IAClB,MAAMe,EDOS,CAAKf,GAAgBA,EAAcD,EAAgBC,GAAeD,ECPrEyB,CAAYxB,GAClByB,EAAiBC,GAXzB,SAAkBX,EAAKW,EAAWL,GAChC,MAAMM,EAAQC,EAAMC,qBAClBd,EAAIG,UACJU,EAAME,YAAY,IAAMJ,EAASX,EAAID,YAAa,CAACC,EAAKW,IACxDE,EAAME,YAAY,IAAMJ,EAASX,EAAIC,mBAAoB,CAACD,EAAKW,KAGjE,OADAE,EAAMG,cAAcJ,GACbA,CACT,CAGsCK,CAASjB,EAAKW,GAElD,OADAlB,OAAOG,OAAOc,EAAeV,GACtBU,GCiBT,SAASQ,EAAmB/B,EAAkCoB,GAC7D,IAAK,MAAMT,KAAYX,EACtB,IACCW,EAASS,EACV,CAAE,MAAOY,GACRC,QAAQD,MAAM,2BAA4BA,EAC3C,CAEF,CAQO,MAAME,GD/BoBpC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AYL,KAAiBF,+CAGlD,OAAOD,QAAQS,MAAMF,EAAIL,EAAWI,IAGrCF,EAAQ9F,IAAI2F,EAAMI,IAGZA,CACR,GAEF,CAmCeK,CAAsBT,GAClCN,EAAWrF,IAAI2F,EAAMC,IAGfA,CACR","x_google_ignoreList":[0,1]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright © 2025–2026 Solomei AI SRL. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* Proprietary software, licensed for use by Callimacus customers only.
|
|
5
|
-
* See LICENSE.md for the full terms.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
import{Thamyr as e}from"@callimacus/thamyr";import{callimacusService as t}from"@callimacus/thamyr-core";import n from"react";const r=e=>{let t;const n=new Set,r=(e,r)=>{const o="function"==typeof e?e(t):e;if(!Object.is(o,t)){const e=t;t=(null!=r?r:"object"!=typeof o||null===o)?o:Object.assign({},t,o),n.forEach(n=>n(t,e))}},o=()=>t,s={setState:r,getState:o,getInitialState:()=>i,subscribe:e=>(n.add(e),()=>n.delete(e))},i=t=e(r,o,s);return s},o=e=>e;const s=e=>{const t=(e=>e?r(e):r)(e),s=e=>function(e,t=o){const r=n.useSyncExternalStore(e.subscribe,n.useCallback(()=>t(e.getState()),[e,t]),n.useCallback(()=>t(e.getInitialState()),[e,t]));return n.useDebugValue(r),r}(t,e);return Object.assign(s,t),s};function i(e,t){for(const n of e)try{n(t)}catch(e){console.error("[Thamyr] Listener threw:",e)}}const a=(c?s(c):s)((n,r)=>{let o,s=0;const a=new Set,c=new Set,u=new Set;return{connectionStatus:"idle",messages:[],error:void 0,_initialized:!1,_thamyr:void 0,init(d){if(r()._initialized)return;if("undefined"==typeof window)return void console.debug("[Thamyr] init() skipped: no browser environment detected (SSR).");const{clientId:l}=d;if(!l){console.error("[Thamyr] clientId is required. Pass your Callimacus Client ID (`cal-pk-…`) to useInitThamyr().");const e={code:0,message:"clientId is required. Pass your Callimacus Client ID (`cal-pk-…`) to useInitThamyr()."};return n({connectionStatus:"error",error:e}),i(u,e),void i(c,"error")}void 0!==d.maxMessages&&d.maxMessages<0&&console.warn("[Thamyr] maxMessages must be >= 0. Received:",d.maxMessages,". Clamping to 1.");const m=0===d.maxMessages?1/0:Math.max(1,d.maxMessages??50);let f;n({connectionStatus:"connecting",error:void 0});try{f=new e({clientId:l,endpoint:d.endpoint,uiObserver:d.uiObserver})}catch(e){console.error("[Thamyr] Failed to create Thamyr instance:",e);const t={code:0,message:e instanceof Error?e.message:String(e)};return n({connectionStatus:"error",error:t}),i(u,t),void i(c,"error")}const h=++s;f.onResponse(e=>{s===h&&(n(t=>{const n=[...t.messages,e];return{messages:n.length>m?n.slice(-m):n}}),i(a,e))}),f.onError(e=>{s===h&&(n({error:e,connectionStatus:"error"}),i(u,e),i(c,"error"))}),o=t.onConnectionStatus(e=>{if(s!==h)return;const t=e?"connected":"disconnected";n({connectionStatus:t}),i(c,t)}),function(e){n({_initialized:Boolean(e),_thamyr:e})}(f)},reset(){if(r()._initialized){s++;try{o?.()}catch(e){console.error("[Thamyr] Error unsubscribing connection status listener:",e)}try{t.disconnect()}catch(e){console.error("[Thamyr] Error disconnecting:",e)}o=void 0,n({_initialized:!1,_thamyr:void 0,connectionStatus:"idle",messages:[],error:void 0})}else"idle"!==r().connectionStatus&&n({connectionStatus:"idle",error:void 0})},sendEvent(e,t){const o=r()._thamyr;if(!o)throw new Error("[Thamyr] SDK is not initialized yet. Ensure useInitThamyr() has been called.");const{connectionStatus:s}=r();if("connected"!==s){const e={code:0,message:`Cannot send event: connection status is "${s}". Wait for connected status before sending.`};throw n({error:e}),i(u,e),new Error(e.message)}o.sendUserInteraction(e,t)},sendAudio(e,t){const o=r()._thamyr;if(!o)throw new Error("[Thamyr] SDK is not initialized yet. Ensure useInitThamyr() has been called.");const{connectionStatus:s}=r();if("connected"!==s){const e={code:0,message:`Cannot send audio: connection status is "${s}". Wait for connected status before sending.`};throw n({error:e}),i(u,e),new Error(e.message)}o.sendAudio(e,t)},addResponseListener:e=>(a.add(e),()=>{a.delete(e)}),addConnectionListener:e=>(c.add(e),()=>{c.delete(e)}),addErrorListener:e=>(u.add(e),()=>{u.delete(e)})}});var c;let u=!1,d=0;const l=new Set;function m(){u=!0}function f(){d++,u=!0}function h(){d--,queueMicrotask(()=>{if(d>0)return;u=!1;const e=[...l];l.clear();for(const t of e)t(new Error("[Thamyr] SDK was torn down: useInitThamyr() unmounted while this call was waiting for initialization."))})}function y(e){return new Error(`[Thamyr] SDK initialization failed: ${e?.message??"unknown error"}`)}async function w(){if("undefined"==typeof window)throw new Error("[Thamyr] The generated API is browser-only; this call ran without a browser environment (SSR).");const e=a.getState();if(e._thamyr)return e._thamyr;if(!u)throw new Error("[Thamyr] SDK is not initialized and no useInitThamyr() is mounted. Add useInitThamyr({clientId: 'cal-pk-…'}) to your root component.");if("error"===e.connectionStatus)throw y(e.error);return new Promise((e,t)=>{let n=!1;const r=e=>{n||(n=!0,s(),l.delete(o),e())},o=e=>{r(()=>{t(e)})};l.add(o);const s=a.subscribe(n=>{if(n._thamyr){const t=n._thamyr;r(()=>{e(t)})}else"error"===n.connectionStatus&&r(()=>{t(y(n.error))})})})}const g=new Set(["then","catch","finally","toJSON"]),S=new Set(Object.getOwnPropertyNames(Object.prototype));function p(e){return"string"!=typeof e||S.has(e)}const b=new Map,T=new Proxy({},{get(e,t){if(p(t))return Reflect.get(e,t);if(g.has(t))return;const n=t;let r=b.get(n);return void 0===r&&(r=function(e){const t=new Map;return new Proxy({},{get(n,r){if(p(r))return Reflect.get(n,r);if(g.has(r))return;const o=r;let s=t.get(o);return void 0===s&&(s=async(...t)=>{const n=(await w())[e],r=n?.[o];if("function"!=typeof r)throw new TypeError(`[Thamyr] ${e}.${o} is not part of the generated API surface.`);return Reflect.apply(r,n,t)},t.set(o,s)),s}})}(n),b.set(n,r)),r}});export{m as a,f as b,h as m,T as t,a as u,w};
|
|
9
|
-
//# sourceMappingURL=api-Bzz6EL4P.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-Bzz6EL4P.js","sources":["../../../../../node_modules/zustand/esm/vanilla.mjs","../../../../../node_modules/zustand/esm/react.mjs","../../../../src/callimacus/store.ts","../../../../src/callimacus/api.ts"],"sourcesContent":["const createStoreImpl = (createState) => {\n let state;\n const listeners = /* @__PURE__ */ new Set();\n const setState = (partial, replace) => {\n const nextState = typeof partial === \"function\" ? partial(state) : partial;\n if (!Object.is(nextState, state)) {\n const previousState = state;\n state = (replace != null ? replace : typeof nextState !== \"object\" || nextState === null) ? nextState : Object.assign({}, state, nextState);\n listeners.forEach((listener) => listener(state, previousState));\n }\n };\n const getState = () => state;\n const getInitialState = () => initialState;\n const subscribe = (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n };\n const api = { setState, getState, getInitialState, subscribe };\n const initialState = state = createState(setState, getState, api);\n return api;\n};\nconst createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);\n\nexport { createStore };\n","import React from 'react';\nimport { createStore } from 'zustand/vanilla';\n\nconst identity = (arg) => arg;\nfunction useStore(api, selector = identity) {\n const slice = React.useSyncExternalStore(\n api.subscribe,\n React.useCallback(() => selector(api.getState()), [api, selector]),\n React.useCallback(() => selector(api.getInitialState()), [api, selector])\n );\n React.useDebugValue(slice);\n return slice;\n}\nconst createImpl = (createState) => {\n const api = createStore(createState);\n const useBoundStore = (selector) => useStore(api, selector);\n Object.assign(useBoundStore, api);\n return useBoundStore;\n};\nconst create = ((createState) => createState ? createImpl(createState) : createImpl);\n\nexport { create, useStore };\n",null,null],"names":["createStoreImpl","createState","state","listeners","Set","setState","partial","replace","nextState","Object","is","previousState","assign","forEach","listener","getState","api","getInitialState","initialState","subscribe","add","delete","identity","arg","createImpl","createStore","useBoundStore","selector","slice","React","useSyncExternalStore","useCallback","useDebugValue","useStore","notifyListeners","error","console","useCallimacusStore","set","get","unsubConnectionStatus","generation","responseListeners","connectionListeners","errorListeners","connectionStatus","messages","undefined","_initialized","_thamyr","init","config","window","debug","clientId","errorMessage","code","message","maxMessages","warn","Infinity","Math","max","thamyr","Thamyr","endpoint","uiObserver","Error","String","currentGen","onResponse","response","length","onError","callimacusService","onConnectionStatus","connected","status","Boolean","setInitState","reset","disconnect","sendEvent","type","payload","sendUserInteraction","sendAudio","audio","query","addResponseListener","cb","addConnectionListener","addErrorListener","wasInitRequested","mountedInitOwners","pendingRejecters","markInitRequested","markInitOwnerMounted","markInitOwnerUnmounted","queueMicrotask","rejecters","clear","rejectWaiter","initError","async","waitForInstance","Promise","resolve","reject","isSettled","settle","action","unsubscribe","rejecter","current","instance","blockedNames","objectPrototypeMembers","getOwnPropertyNames","prototype","isPassthroughProperty","property","has","namespaces","Map","thamyrApi","Proxy","target","Reflect","name","namespace","namespaceName","methods","method","args","fn","TypeError","apply","createNamespaceFacade"],"mappings":";;;;;;;6HAAA,MAAMA,EAAmBC,IACvB,IAAIC,EACJ,MAAMC,EAA4B,IAAIC,IAChCC,EAAW,CAACC,EAASC,KACzB,MAAMC,EAA+B,mBAAZF,EAAyBA,EAAQJ,GAASI,EACnE,IAAKG,OAAOC,GAAGF,EAAWN,GAAQ,CAChC,MAAMS,EAAgBT,EACtBA,GAAoB,MAAXK,EAAkBA,EAA+B,iBAAdC,GAAwC,OAAdA,GAAsBA,EAAYC,OAAOG,OAAO,CAAA,EAAIV,EAAOM,GACjIL,EAAUU,QAASC,GAAaA,EAASZ,EAAOS,GAClD,GAEII,EAAW,IAAMb,EAMjBc,EAAM,CAAEX,WAAUU,WAAUE,gBALV,IAAMC,EAKqBC,UAJhCL,IACjBX,EAAUiB,IAAIN,GACP,IAAMX,EAAUkB,OAAOP,KAG1BI,EAAehB,EAAQD,EAAYI,EAAUU,EAAUC,GAC7D,OAAOA,GChBHM,EAAYC,GAAQA,EAU1B,MAAMC,EAAcvB,IAClB,MAAMe,EDOS,CAAKf,GAAgBA,EAAcD,EAAgBC,GAAeD,ECPrEyB,CAAYxB,GAClBy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