@ronza.ai/react 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -60,10 +60,37 @@ mount loads the script once, starts the chat once and calls `getToken` once.
60
60
  ### `useRonza()`
61
61
 
62
62
  The typed client from `@ronza.ai/web` (`open`, `close`, `on`, `context`,
63
- `identify`, `reset` and the rest) once the chat is ready, and `null` before
63
+ `identify`, `reset`, `debug` and the rest) once the chat is ready, and `null` before
64
64
  that and on the server. It works in any component, inside or outside the
65
65
  widget's part of the tree.
66
66
 
67
+ ### When the chat does not appear
68
+
69
+ `useRonza()` stays `null` for a chat that never starts, so reach it with
70
+ `getRonza()`, the same client as soon as `<RonzaWidget />` has started
71
+ loading the chat:
72
+
73
+ ```tsx
74
+ import { getRonza } from '@ronza.ai/react';
75
+
76
+ getRonza()?.debug();
77
+ ```
78
+
79
+ `debug()` prints a checklist of the install to the browser's console: the
80
+ script's address, the agent's key, whether the chat's frame answered, and
81
+ the last error with a link to its section of the troubleshooting page,
82
+ https://ronza.ai/docs/install/troubleshooting. Adding `?ronza_debug=1` to
83
+ the page's address does the same without a code change. The output holds no
84
+ token, no message text and no page-context values, so you can paste it into
85
+ a message to Ronza's support.
86
+
87
+ When the chat could not start, the `error` event's `code` is `boot_failed`
88
+ and its `reason` is one of the install codes (`agent_not_found`,
89
+ `website_not_allowed`, `identity_token_refused`, `too_many_requests`,
90
+ `frame_blocked` or `start_failed`), each explained at
91
+ `https://ronza.ai/docs/install/troubleshooting#<reason>`. `getToken` is not
92
+ called again for any of them.
93
+
67
94
  ### Server rendering
68
95
 
69
96
  Safe in server-rendered apps (Next.js and others): nothing runs on the server
package/dist/index.cjs CHANGED
@@ -171,5 +171,9 @@ function RonzaWidget(props) {
171
171
  });
172
172
  return null;
173
173
  }
174
+ Object.defineProperty(exports, "getRonza", {
175
+ enumerable: true,
176
+ get: () => web.getRonza
177
+ });
174
178
  exports.RonzaWidget = RonzaWidget;
175
179
  exports.useRonza = useRonza;
package/dist/index.d.cts CHANGED
@@ -1,3 +1,10 @@
1
+ import { getRonza } from '@ronza.ai/web';
2
+ /**
3
+ * The page's client as soon as `<RonzaWidget />` has started loading the chat, before it is ready; `null` before
4
+ * that and on a server. `useRonza()` stays `null` for a chat that never starts, so this is how to reach one:
5
+ * `getRonza()?.debug()` prints the install checklist, and `getRonza()?.on('error', ...)` hears why it failed.
6
+ */
7
+ export { getRonza };
1
8
  import type { LoadRonzaOptions, PageContextFields, RonzaClient } from '@ronza.ai/web';
2
9
  export type { LoadRonzaOptions, PageContextFields, PageContextValue, RonzaChannel, RonzaClient, RonzaDisplay, RonzaEventDetails, RonzaEventListener, RonzaEventName, RonzaSettingsUpdate, RonzaTheme, } from '@ronza.ai/web';
3
10
  export interface RonzaWidgetProps {
package/dist/index.d.ts CHANGED
@@ -1,3 +1,10 @@
1
+ import { getRonza } from '@ronza.ai/web';
2
+ /**
3
+ * The page's client as soon as `<RonzaWidget />` has started loading the chat, before it is ready; `null` before
4
+ * that and on a server. `useRonza()` stays `null` for a chat that never starts, so this is how to reach one:
5
+ * `getRonza()?.debug()` prints the install checklist, and `getRonza()?.on('error', ...)` hears why it failed.
6
+ */
7
+ export { getRonza };
1
8
  import type { LoadRonzaOptions, PageContextFields, RonzaClient } from '@ronza.ai/web';
2
9
  export type { LoadRonzaOptions, PageContextFields, PageContextValue, RonzaChannel, RonzaClient, RonzaDisplay, RonzaEventDetails, RonzaEventListener, RonzaEventName, RonzaSettingsUpdate, RonzaTheme, } from '@ronza.ai/web';
3
10
  export interface RonzaWidgetProps {
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { useSyncExternalStore, useRef, useState, useEffect } from "react";
3
3
  import { getRonza, loadRonza } from "@ronza.ai/web";
4
+ import { getRonza as getRonza2 } from "@ronza.ai/web";
4
5
  const FRESH_TOKEN_ERROR_CODE = "identity_refused";
5
6
  const MIN_MILLISECONDS_BETWEEN_TOKEN_REFRESHES = 1e4;
6
7
  let readyClient = null;
@@ -171,5 +172,6 @@ function RonzaWidget(props) {
171
172
  }
172
173
  export {
173
174
  RonzaWidget,
175
+ getRonza2 as getRonza,
174
176
  useRonza
175
177
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ronza.ai/react",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "The Ronza chat agent in a React app: <RonzaWidget /> and useRonza(). Built on @ronza.ai/web.",
5
5
  "keywords": [
6
6
  "ronza",
@@ -10,7 +10,7 @@
10
10
  "react"
11
11
  ],
12
12
  "license": "MIT",
13
- "//": "Publish with pnpm (pnpm pack, then npm publish of that tarball, or pnpm publish): only pnpm turns workspace:^ into ^0.1.0; prepublishOnly (scripts/refuse-npm-publish.cjs) refuses a plain npm publish of this folder.",
13
+ "//": "Publish with pnpm (pnpm pack, then npm publish of that tarball, or pnpm publish): only pnpm turns workspace:^ into a caret range of the web package's version (^0.2.0); prepublishOnly (scripts/refuse-npm-publish.cjs) refuses a plain npm publish of this folder.",
14
14
  "repository": {
15
15
  "type": "git",
16
16
  "url": "git+https://github.com/ronzahq/ronza-js.git",
@@ -47,7 +47,7 @@
47
47
  "node": ">=18"
48
48
  },
49
49
  "dependencies": {
50
- "@ronza.ai/web": "^0.1.0"
50
+ "@ronza.ai/web": "^0.2.0"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "react": "^18.0.0 || ^19.0.0"