@tailorkit/react 0.1.0-beta.45 → 0.1.0-beta.46

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.js CHANGED
@@ -187,6 +187,58 @@ var RemoteErrorBoundary = class extends Component {
187
187
  return this.props.children;
188
188
  }
189
189
  };
190
+ var RemoteElementViewComponent = ({
191
+ children,
192
+ ctx,
193
+ node
194
+ }) => {
195
+ const componentStore = useMemo2(
196
+ () => ctx.selectComponent(node.type),
197
+ [ctx, node.type]
198
+ );
199
+ const component = useStore(componentStore);
200
+ if (component === void 0) {
201
+ throw new Error(`TailorKit component "${node.type}" is not registered.`);
202
+ }
203
+ const props = createRemoteElementProps(node, ctx.dispatch.bind(ctx));
204
+ return createElement(
205
+ /* oxlint-disable typescript/no-unsafe-type-assertion -- The renderer was supplied through the typed component registry; React's createElement overload erases its heterogeneous props. */
206
+ component,
207
+ /* oxlint-enable typescript/no-unsafe-type-assertion */
208
+ props,
209
+ ...children
210
+ );
211
+ };
212
+ var RemoteElementView = memo(RemoteElementViewComponent);
213
+ var RemoteNode = {
214
+ View: ({
215
+ ctx,
216
+ nodeId
217
+ }) => {
218
+ const nodeStore = useMemo2(
219
+ () => ctx.nodes.selectNode(nodeId),
220
+ [ctx, nodeId]
221
+ );
222
+ const node = useStore(nodeStore);
223
+ if (node === null) {
224
+ return null;
225
+ }
226
+ if (node.kind === "text") {
227
+ return node.text;
228
+ }
229
+ const childElements = node.children.map((child) => /* @__PURE__ */ jsx2(RemoteNode.View, { ctx, nodeId: child.id }, child.id));
230
+ if (node.kind === "fragment") {
231
+ return createElement(Fragment2, { key: node.id }, ...childElements);
232
+ }
233
+ return /* @__PURE__ */ jsx2(RemoteElementView, { node, ctx, children: childElements });
234
+ }
235
+ };
236
+ RemoteNode.View = memo(RemoteNode.View);
237
+ var RemoteViewComponent = ({ nodeId }) => {
238
+ const ctx = useContext2(RemoteUIContext);
239
+ return ctx === null ? null : /* @__PURE__ */ jsx2(RemoteNode.View, { ctx, nodeId });
240
+ };
241
+ var RemoteView = memo(RemoteViewComponent);
190
242
  var RemoteRoot = ({ store }) => {
191
243
  const rootId = useStore(store.nodes.root);
192
244
  return rootId === null ? null : /* @__PURE__ */ jsx2(RemoteView, { nodeId: rootId });
@@ -229,58 +281,6 @@ var RemoteViewHost = ({
229
281
  }
230
282
  return /* @__PURE__ */ jsx2(RemoteUIContext.Provider, { value: store, children: /* @__PURE__ */ jsx2(RemoteErrorBoundary, { children: /* @__PURE__ */ jsx2(RemoteRoot, { store }) }, `${appKey}:${snapshot.generation}`) });
231
283
  };
232
- var RemoteElementViewComponent = ({
233
- ctx,
234
- node
235
- }) => {
236
- const componentStore = useMemo2(
237
- () => ctx.selectComponent(node.type),
238
- [ctx, node.type]
239
- );
240
- const component = useStore(componentStore);
241
- const children = node.children.map((child) => (
242
- // oxlint-disable-next-line no-use-before-define -- This deferred callback runs after initialization; the definitions are mutually dependent.
243
- /* @__PURE__ */ jsx2(RemoteView, { nodeId: child.id }, child.id)
244
- ));
245
- if (component === void 0) {
246
- throw new Error(`TailorKit component "${node.type}" is not registered.`);
247
- }
248
- const props = createRemoteElementProps(node, ctx.dispatch.bind(ctx));
249
- return createElement(
250
- /* oxlint-disable typescript/no-unsafe-type-assertion -- The renderer was supplied through the typed component registry; React's createElement overload erases its heterogeneous props. */
251
- component,
252
- /* oxlint-enable typescript/no-unsafe-type-assertion */
253
- props,
254
- ...children
255
- );
256
- };
257
- var RemoteElementView = memo(RemoteElementViewComponent);
258
- var RemoteNodeView = ({
259
- ctx,
260
- nodeId
261
- }) => {
262
- const nodeStore = useMemo2(() => ctx.nodes.selectNode(nodeId), [ctx, nodeId]);
263
- const node = useStore(nodeStore);
264
- if (node === null) {
265
- return null;
266
- }
267
- if (node.kind === "text") {
268
- return node.text;
269
- }
270
- const childElements = node.children.map((child) => (
271
- // oxlint-disable-next-line no-use-before-define -- This deferred callback runs after initialization; the definitions are mutually dependent.
272
- /* @__PURE__ */ jsx2(RemoteView, { nodeId: child.id }, child.id)
273
- ));
274
- if (node.kind === "fragment") {
275
- return createElement(Fragment2, { key: node.id }, ...childElements);
276
- }
277
- return /* @__PURE__ */ jsx2(RemoteElementView, { node, ctx });
278
- };
279
- var RemoteViewComponent = ({ nodeId }) => {
280
- const ctx = useContext2(RemoteUIContext);
281
- return ctx === null ? null : /* @__PURE__ */ jsx2(RemoteNodeView, { ctx, nodeId });
282
- };
283
- var RemoteView = memo(RemoteViewComponent);
284
284
 
285
285
  // src/components/context.ts
286
286
  import { createContext as createContext3, useContext as useContext3 } from "react";
@@ -11,10 +11,10 @@ interface RemoteViewHostProps {
11
11
  createIframe?: () => HTMLIFrameElement;
12
12
  props?: RemoteProps;
13
13
  }
14
- export declare const RemoteViewHost: ({ appUrl, toolBridge, getBackendSession, components, createIframe, props, }: RemoteViewHostProps) => ReactNode;
15
14
  interface RemoteViewProps {
16
15
  nodeId: string;
17
16
  }
18
17
  declare const RemoteViewComponent: ({ nodeId }: RemoteViewProps) => ReactNode;
19
18
  export declare const RemoteView: import("react").MemoExoticComponent<typeof RemoteViewComponent>;
19
+ export declare const RemoteViewHost: ({ appUrl, toolBridge, getBackendSession, components, createIframe, props, }: RemoteViewHostProps) => ReactNode;
20
20
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailorkit/react",
3
- "version": "0.1.0-beta.45",
3
+ "version": "0.1.0-beta.46",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -47,11 +47,11 @@
47
47
  "@floating-ui/react-dom": "^2.1.9",
48
48
  "@nanostores/react": "2.0.1",
49
49
  "@standard-schema/spec": "^1.1.0",
50
- "@tailorkit/app": "0.1.0-beta.45",
51
- "@tailorkit/client-core": "0.1.0-beta.45",
52
- "@tailorkit/client-platform": "0.1.0-beta.45",
53
- "@tailorkit/core": "0.1.0-beta.45",
54
- "@tailorkit/sandbox": "0.1.0-beta.45",
50
+ "@tailorkit/app": "0.1.0-beta.46",
51
+ "@tailorkit/client-core": "0.1.0-beta.46",
52
+ "@tailorkit/client-platform": "0.1.0-beta.46",
53
+ "@tailorkit/core": "0.1.0-beta.46",
54
+ "@tailorkit/sandbox": "0.1.0-beta.46",
55
55
  "nanostores": "1.5.5"
56
56
  },
57
57
  "devDependencies": {