@stackable-labs/sdk-extension-react 1.57.0 → 1.58.1

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/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
9
9
 
10
10
  interface CreateExtensionOptions {
11
11
  extensionId?: string;
12
+ onError?: (error: Error) => void;
12
13
  }
13
14
  /**
14
15
  * Bootstrap an extension. Call this as the entry point of your extension bundle.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import React2, { createContext, useContext, useCallback, useSyncExternalStore, useEffect, useState, useRef } from 'react';
1
+ import React2, { createContext, useContext, useCallback, useSyncExternalStore, useEffect, useState, useRef, Component } from 'react';
2
2
  import { createRoot } from 'react-dom/client';
3
3
  import { WebCrypto } from '@agnostack/verifyd/esm';
4
- import { jsxs, jsx } from 'react/jsx-runtime';
4
+ import { jsx, jsxs } from 'react/jsx-runtime';
5
5
 
6
6
  var __defProp = Object.defineProperty;
7
7
  var __export = (target, all) => {
@@ -128,6 +128,24 @@ var ReadySignal = ({ extensionId }) => {
128
128
  }, [extensionId]);
129
129
  return null;
130
130
  };
131
+ var ExtensionErrorBoundary = class extends Component {
132
+ state = { error: null };
133
+ static getDerivedStateFromError(error) {
134
+ return { error };
135
+ }
136
+ componentDidCatch(error) {
137
+ const { onError } = this.props;
138
+ onError?.(error);
139
+ }
140
+ render() {
141
+ const { error } = this.state;
142
+ if (error) {
143
+ return null;
144
+ }
145
+ const { children } = this.props;
146
+ return children;
147
+ }
148
+ };
131
149
  var createExtension = (factory, options) => {
132
150
  const injectedId = window.__STACKABLE_EXTENSION_ID__ ?? new URLSearchParams(window.location.search).get("__extensionId") ?? void 0;
133
151
  const extensionId = injectedId ?? options?.extensionId ?? "unknown";
@@ -139,10 +157,10 @@ var createExtension = (factory, options) => {
139
157
  const container = document.getElementById("extension-root") ?? document.body;
140
158
  const root = createRoot(container);
141
159
  root.render(
142
- /* @__PURE__ */ jsxs(ExtensionContext.Provider, { value: contextValue, children: [
160
+ /* @__PURE__ */ jsx(ExtensionErrorBoundary, { onError: options?.onError, children: /* @__PURE__ */ jsxs(ExtensionContext.Provider, { value: contextValue, children: [
143
161
  factory(),
144
162
  /* @__PURE__ */ jsx(ReadySignal, { extensionId })
145
- ] })
163
+ ] }) })
146
164
  );
147
165
  };
148
166
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackable-labs/sdk-extension-react",
3
- "version": "1.57.0",
3
+ "version": "1.58.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -15,7 +15,7 @@
15
15
  "@agnostack/verifyd": "alpha",
16
16
  "@remote-dom/core": "1.x",
17
17
  "@remote-dom/react": "1.x",
18
- "@stackable-labs/sdk-extension-contracts": "1.57.0"
18
+ "@stackable-labs/sdk-extension-contracts": "1.58.1"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "react": ">=18.0.0 <19.0.0",