@callimacus/thamyr-react-native 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 +46 -0
- package/MIGRATION.md +15 -15
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -2
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
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.4.0](https://github.com/callimacus/thamyr-sdk/compare/thamyr-react-native-v4.3.5...thamyr-react-native-v4.4.0) (2026-09-29)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **callimacus:** export additional action types from hooks for better type safety ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
9
|
+
* **ContentAPI:** implement getDocumentByGroupId method to retrieve documents based on language and group ID ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
10
|
+
* **hooks.ts:** enhance useProducts, useAnalytics, and useSitemap hooks with TypeScript interfaces and detailed documentation ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
11
|
+
* **react:** add eslint-config-xo-react for better React linting ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
12
|
+
* **react:** implement Callimacus store and hooks for state management ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
13
|
+
* **service.ts:** add polling transport option to socket connection for improved connectivity in restricted environments ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
14
|
+
* **service.ts:** add referrer to auth object for enhanced tracking and analytics ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
15
|
+
* **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))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **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))
|
|
21
|
+
* **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))
|
|
22
|
+
* **package.json:** remove redundant comma in scripts section to ensure JSON validity ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
23
|
+
* **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))
|
|
24
|
+
* **react:** ensure consistent export style across components ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
25
|
+
* **react:** remove obsolete global type declarations ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
26
|
+
* remove legacy-peer-deps from .npmrc and update registry configuration for scoped package ([fe22166](https://github.com/callimacus/thamyr-sdk/commit/fe221665c994723d546f972c9379cdf4b4eecbc8))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Dependencies
|
|
30
|
+
|
|
31
|
+
* The following workspace dependencies were updated
|
|
32
|
+
* dependencies
|
|
33
|
+
* @callimacus/thamyr-react bumped from ^4.3.5 to ^4.4.0
|
|
34
|
+
|
|
35
|
+
## [4.3.5](https://github.com/callimacus/thamyr-sdk/compare/thamyr-react-native-v4.3.4...thamyr-react-native-v4.3.5) (2026-09-29)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Bug Fixes
|
|
39
|
+
|
|
40
|
+
* **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))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Dependencies
|
|
44
|
+
|
|
45
|
+
* The following workspace dependencies were updated
|
|
46
|
+
* dependencies
|
|
47
|
+
* @callimacus/thamyr-react bumped from ^4.3.4 to ^4.3.5
|
|
48
|
+
|
|
3
49
|
## [4.3.4](https://github.com/solomei-ai/thamyr-sdk/compare/thamyr-react-native-v4.3.3...thamyr-react-native-v4.3.4) (2026-09-27)
|
|
4
50
|
|
|
5
51
|
|
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
|
|
package/dist/esm/index.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* See LICENSE.md for the full terms.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import{useInitThamyr as e}from"@callimacus/thamyr-react";export{CallimacusEvent,ChapterStatus,ClientEvents,GalleryMode,SLInputEventType,ServerEvents,ThamyrHttpError,ThamyrResponseType,UserInteractionType,callimacusService,extractTtsAudio,isSetProduct,logger,thamyrApi,transformImageUrl,useApi,useCallimacusStore,useCart,useConnection,useOnConnectionChange,useOnError,useOnResponse,useSitemap,useSkesis,useThamyr}from"@callimacus/thamyr-react";import{useState as r,useRef as t,useCallback as n,useEffect as o}from"react";function i(r){e(r)}async function s(e){return new Promise((r,t)=>{const n=new XMLHttpRequest;n.responseType="arraybuffer","arraybuffer"===n.responseType?(n.addEventListener("load",()=>{const o=n.response;o instanceof ArrayBuffer?0!==o.byteLength?r(new Uint8Array(o)):t(new Error(`The recording at ${e} is empty`)):t(new Error(`Reading the recording at ${e} produced ${typeof o}, expected an ArrayBuffer`))}),n.addEventListener("error",()=>{t(new Error(`Failed to read the recording at ${e}`))}),n.open("GET",e,!0),n.send(null)):t(new Error('This runtime does not support XMLHttpRequest responseType "arraybuffer", so the recording cannot be read. Pass a custom adapter that returns bytes.'))})}const a=-45,c=1800,u=3e4;function d(e){if(!Number.isFinite(e))return 0;const r=(e- -60)/60;return Math.min(1,Math.max(0,r))}function l({silenceThreshold:e=a,silenceDuration:i=c,maxDuration:l=u,onRecordingComplete:p,adapter:y}){const[
|
|
8
|
+
import{useInitThamyr as e}from"@callimacus/thamyr-react";export{ADD_TO_CART_RESULT_BLOCK,CallimacusEvent,ChapterStatus,ClientEvents,GalleryMode,LANDING_VALUE_MAX_LENGTH,SLInputEventType,ServerEvents,ThamyrHttpError,ThamyrResponseType,UserInteractionType,addToCartResultOf,applyBlockPatch,blockKeyOf,callimacusService,extractTtsAudio,interactionRound,isSetProduct,landingRound,logger,receptorsOf,thamyrApi,transformImageUrl,useApi,useCallimacusStore,useCart,useConnection,useOnConnectionChange,useOnError,useOnResponse,useSitemap,useSkesis,useSuggestions,useThamyr}from"@callimacus/thamyr-react";import{useState as r,useRef as t,useCallback as n,useEffect as o}from"react";function i(r){e(r)}async function s(e){return new Promise((r,t)=>{const n=new XMLHttpRequest;n.responseType="arraybuffer","arraybuffer"===n.responseType?(n.addEventListener("load",()=>{const o=n.response;o instanceof ArrayBuffer?0!==o.byteLength?r(new Uint8Array(o)):t(new Error(`The recording at ${e} is empty`)):t(new Error(`Reading the recording at ${e} produced ${typeof o}, expected an ArrayBuffer`))}),n.addEventListener("error",()=>{t(new Error(`Failed to read the recording at ${e}`))}),n.open("GET",e,!0),n.send(null)):t(new Error('This runtime does not support XMLHttpRequest responseType "arraybuffer", so the recording cannot be read. Pass a custom adapter that returns bytes.'))})}const a=-45,c=1800,u=3e4;function d(e){if(!Number.isFinite(e))return 0;const r=(e- -60)/60;return Math.min(1,Math.max(0,r))}function l({silenceThreshold:e=a,silenceDuration:i=c,maxDuration:l=u,onRecordingComplete:p,adapter:y}){const[f,g]=r("idle"),[m,h]=r([]),[w,v]=r(void 0),[T,E]=r(void 0),R=t(y);R.current=y;const A=t(void 0),M=t([]),L=t(0),S=t(void 0),C=t(!1),b=t(p);b.current=p;const I=n(()=>{void 0!==S.current&&(clearTimeout(S.current),S.current=void 0)},[]),O=n(()=>{M.current=[],L.current=0,h([])},[]),_=n(()=>{if(C.current)return;C.current=!0,I(),g("processing");(async()=>{const e=A.current;A.current=void 0;try{if(!e)throw new Error("No active recording to stop");const r=await e.stop();E(r.uri),b.current(await s(r.uri))}catch(e){v(e instanceof Error?e.message:"Failed to finish recording")}finally{C.current=!1,g("idle")}})()},[I]),D=n(r=>{if(C.current)return;const t=[...M.current,d(r)];t.length>32&&t.splice(0,t.length-32),M.current=t,h(t),r<e?0===L.current?L.current=Date.now():Date.now()-L.current>i&&_():L.current=0},[e,i,_]),U=n(async()=>{v(void 0),C.current=!1,O();const e=R.current;A.current=e;try{await e.start({onMetering:D}),g("recording"),S.current=setTimeout(()=>{_()},l)}catch(r){A.current=void 0,v(r instanceof Error?r.message:"Microphone access denied"),g("idle"),await e.cancel()}},[D,l,O,_]),x=n(()=>{g("idle"),v(void 0),O()},[O]);return o(()=>()=>{I();const e=A.current;A.current=void 0,e?.cancel()},[I]),{state:f,audioLevels:m,startRecording:U,stopRecording:_,reset:x,error:w,lastRecordingUri:T}}function p(e){let r,t;function n(){void 0!==t&&(clearInterval(t),t=void 0)}return{async start({onMetering:n}){if(!(await e.requestRecordingPermissionsAsync()).granted)throw new Error("Microphone permission denied");await e.setAudioModeAsync({allowsRecording:!0,playsInSilentMode:!0});const o=new e.AudioModule.AudioRecorder({...e.RecordingPresets.HIGH_QUALITY,isMeteringEnabled:!0});await o.prepareToRecordAsync(),o.record(),r=o,t=setInterval(()=>{const e=o.getStatus();"number"==typeof e.metering&&n?.(e.metering)},100)},async stop(){if(!r)throw new Error("No active recording to stop");n();const e=r;r=void 0,await e.stop();const{uri:t}=e;if(null===t||""===t)throw new Error("Recording finished without producing a file");return{uri:t,durationMillis:e.getStatus().durationMillis}},async cancel(){if(n(),!r)return;const e=r;r=void 0;try{await e.stop()}catch{}}}}export{p as createExpoAudioAdapter,s as readRecording,i as useInitThamyr,l 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/index.ts","../../../src/voice/read-recording.ts","../../../src/voice/use-voice-recorder.ts","../../../src/voice/adapters/expo-audio.ts"],"sourcesContent":[null,null,null,null],"names":["useInitThamyr","config","useInitThamyrWeb","async","readRecording","uri","Promise","resolve","reject","request","XMLHttpRequest","responseType","addEventListener","response","ArrayBuffer","byteLength","Uint8Array","Error","open","send","defaultOptions","normalizeMetering","db","Number","isFinite","level","Math","min","max","useVoiceRecorder","silenceThreshold","silenceDuration","maxDuration","onRecordingComplete","adapter","state","setState","useState","audioLevels","setAudioLevels","error","setError","undefined","lastRecordingUri","setLastRecordingUri","adapterRef","useRef","current","activeAdapterRef","levelsRef","silenceStartRef","maxDurationTimerRef","stoppingRef","onCompleteRef","clearMaxDurationTimer","useCallback","clearTimeout","resetWaveform","stopRecording","active","result","stop","error_","message","finish","handleMetering","next","length","splice","Date","now","startRecording","start","onMetering","setTimeout","cancel","reset","useEffect","createExpoAudioAdapter","expoAudio","recorder","meterTimer","stopMeterTimer","clearInterval","requestRecordingPermissionsAsync","granted","setAudioModeAsync","allowsRecording","playsInSilentMode","AudioModule","AudioRecorder","RecordingPresets","HIGH_QUALITY","isMeteringEnabled","prepareToRecordAsync","record","setInterval","status","getStatus","metering","durationMillis"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/callimacus/index.ts","../../../src/voice/read-recording.ts","../../../src/voice/use-voice-recorder.ts","../../../src/voice/adapters/expo-audio.ts"],"sourcesContent":[null,null,null,null],"names":["useInitThamyr","config","useInitThamyrWeb","async","readRecording","uri","Promise","resolve","reject","request","XMLHttpRequest","responseType","addEventListener","response","ArrayBuffer","byteLength","Uint8Array","Error","open","send","defaultOptions","normalizeMetering","db","Number","isFinite","level","Math","min","max","useVoiceRecorder","silenceThreshold","silenceDuration","maxDuration","onRecordingComplete","adapter","state","setState","useState","audioLevels","setAudioLevels","error","setError","undefined","lastRecordingUri","setLastRecordingUri","adapterRef","useRef","current","activeAdapterRef","levelsRef","silenceStartRef","maxDurationTimerRef","stoppingRef","onCompleteRef","clearMaxDurationTimer","useCallback","clearTimeout","resetWaveform","stopRecording","active","result","stop","error_","message","finish","handleMetering","next","length","splice","Date","now","startRecording","start","onMetering","setTimeout","cancel","reset","useEffect","createExpoAudioAdapter","expoAudio","recorder","meterTimer","stopMeterTimer","clearInterval","requestRecordingPermissionsAsync","granted","setAudioModeAsync","allowsRecording","playsInSilentMode","AudioModule","AudioRecorder","RecordingPresets","HIGH_QUALITY","isMeteringEnabled","prepareToRecordAsync","record","setInterval","status","getStatus","metering","durationMillis"],"mappings":";;;;;;;gqBAqBM,SAAUA,EAAcC,GAE7BC,EAAiBD,EAClB,CCCOE,eAAeC,EAA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.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* See LICENSE.md for the full terms.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
export { Block, BoundingBox, CallimacusEvent, CartActions, Chapter, ChapterStatus, ClientEvents, ClientInfo, ConnectionStatus, ConnectionStatusCallback, ErrorCallback, ErrorMessage, Gallery, GalleryMode, Image, ImageEdits, ImageFormatEdit, ImageResizeEdit, InteractionContext, InteractionPayloadMap, LocalizedEPArtwork, LocalizedEPChapter, LogLevel, LoggerConfig, ProductMatch, SLDocument, SLDocumentSection, SLInputEvent, SLInputEventType, ServerEvents, ServerResponseCallback, SitemapActions, SkesisActions, Story, ThamyrHttpError, ThamyrResponse, ThamyrResponseType, Topic, TtsAudio, UiElement, UiSnapshot, UserInteraction, UserInteractionType, Video, WhisperPayload, callimacusService, extractTtsAudio, isSetProduct, logger, thamyrApi, transformImageUrl, useApi, useCallimacusStore, useCart, useConnection, useOnConnectionChange, useOnError, useOnResponse, useSitemap, useSkesis, useThamyr } from '@callimacus/thamyr-react';
|
|
8
|
+
export { ADD_TO_CART_RESULT_BLOCK, AddToCartResult, Block, BlockPatch, BoundingBox, CallimacusEvent, CartActions, Chapter, ChapterStatus, ClientEvents, ClientInfo, ConnectionStatus, 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, SitemapActions, SkesisActions, Story, SuggestPayload, Suggestions, SuggestionsOptions, SuggestionsState, ThamyrHttpError, ThamyrInteractionMap, ThamyrResponse, ThamyrResponseType, Topic, TtsAudio, UiElement, UiSnapshot, UserInteraction, UserInteractionType, Video, WhisperPayload, addToCartResultOf, applyBlockPatch, blockKeyOf, callimacusService, extractTtsAudio, interactionRound, isSetProduct, landingRound, logger, receptorsOf, thamyrApi, transformImageUrl, useApi, useCallimacusStore, useCart, useConnection, useOnConnectionChange, useOnError, useOnResponse, useSitemap, useSkesis, useSuggestions, useThamyr } from '@callimacus/thamyr-react';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
Configuration for initializing the Thamyr SDK via `useInitThamyr` on React Native.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@callimacus/thamyr-react-native",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "React Native package for Thamyr",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"lint": "eslint src"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@callimacus/thamyr-react": "^4.
|
|
43
|
+
"@callimacus/thamyr-react": "^4.4.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": ">=18",
|