@blocksdiy/react-common 1.56.0 → 1.58.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.
@@ -1,5 +1,6 @@
1
- export type { ThemeMode, AppUpdate, PlatformApi, IframeApi, EditedElement, ElementData, ChatComponentPreview, } from "./types.js";
1
+ export type { ThemeMode, AppUpdate, PlatformApi, IframeApi, EditedElement, ElementData, ChatComponentPreview, IframeBootData, } from "./types.js";
2
2
  export { BridgeProvider, type BridgeState } from "./bridge-provider.js";
3
3
  export { IframeBridgeProvider, usePlatform } from "./iframe-bridge-provider.js";
4
4
  export { PlatformBridgeProvider, PlatformBridgeIframe, useIframe } from "./platform-bridge-provider.js";
5
+ export * from "./platform-app-link.js";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/iframe-communication/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,aAAa,EACb,WAAW,EACX,oBAAoB,GACrB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/iframe-communication/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,cAAc,GACf,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACrG,cAAc,qBAAqB,CAAC"}
@@ -3,3 +3,4 @@
3
3
  export { BridgeProvider } from "./bridge-provider.js";
4
4
  export { IframeBridgeProvider, usePlatform } from "./iframe-bridge-provider.js";
5
5
  export { PlatformBridgeProvider, PlatformBridgeIframe, useIframe } from "./platform-bridge-provider.js";
6
+ export * from "./platform-app-link.js";
@@ -0,0 +1,19 @@
1
+ /**
2
+ * A link from inside one app to another app on the platform — a solution's home page opening one
3
+ * of the solution's apps. Apps run on their own origins in the platform's iframe, so a plain link
4
+ * to another app can't leave the iframe; this one is a path in the app's OWN URL space,
5
+ * `/_platform/apps/<appId>/<route>`, that app-render catches before the app's router does and hands
6
+ * to the platform (`PlatformApi.onOpenApp`), which opens that app — at `<route>` when the app
7
+ * serves it, else where the app opens.
8
+ */
9
+ export declare const PLATFORM_APP_LINK_PREFIX = "/_platform/apps/";
10
+ export interface PlatformAppLink {
11
+ appId: string;
12
+ /** The route inside the app, `/`-led ("/board"); undefined for where the app opens. */
13
+ path?: string;
14
+ }
15
+ /** The link to another app: `platformAppLink("6ad2…", "/board")` → `/_platform/apps/6ad2…/board`. */
16
+ export declare const platformAppLink: (appId: string, path?: string) => string;
17
+ /** The app and route a platform app link names; null for any other path or a malformed id. */
18
+ export declare const parsePlatformAppLink: (pathname: string) => PlatformAppLink | null;
19
+ //# sourceMappingURL=platform-app-link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-app-link.d.ts","sourceRoot":"","sources":["../../src/iframe-communication/platform-app-link.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,qBAAqB,CAAC;AAI3D,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,uFAAuF;IACvF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qGAAqG;AACrG,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,KAAG,MACqC,CAAC;AAErG,8FAA8F;AAC9F,eAAO,MAAM,oBAAoB,GAAI,UAAU,MAAM,KAAG,eAAe,GAAG,IAUzE,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A link from inside one app to another app on the platform — a solution's home page opening one
3
+ * of the solution's apps. Apps run on their own origins in the platform's iframe, so a plain link
4
+ * to another app can't leave the iframe; this one is a path in the app's OWN URL space,
5
+ * `/_platform/apps/<appId>/<route>`, that app-render catches before the app's router does and hands
6
+ * to the platform (`PlatformApi.onOpenApp`), which opens that app — at `<route>` when the app
7
+ * serves it, else where the app opens.
8
+ */
9
+ export const PLATFORM_APP_LINK_PREFIX = "/_platform/apps/";
10
+ const APP_ID = /^[a-f0-9]{24}$/i;
11
+ /** The link to another app: `platformAppLink("6ad2…", "/board")` → `/_platform/apps/6ad2…/board`. */
12
+ export const platformAppLink = (appId, path) => `${PLATFORM_APP_LINK_PREFIX}${appId}${path && path !== "/" ? `/${path.replace(/^\/+/, "")}` : ""}`;
13
+ /** The app and route a platform app link names; null for any other path or a malformed id. */
14
+ export const parsePlatformAppLink = (pathname) => {
15
+ if (!pathname.startsWith(PLATFORM_APP_LINK_PREFIX)) {
16
+ return null;
17
+ }
18
+ const [appId, ...rest] = pathname.slice(PLATFORM_APP_LINK_PREFIX.length).split("/");
19
+ if (!appId || !APP_ID.test(appId)) {
20
+ return null;
21
+ }
22
+ const path = rest.filter(Boolean).join("/");
23
+ return path ? { appId, path: `/${path}` } : { appId };
24
+ };
@@ -25,12 +25,30 @@ export interface AppUpdate {
25
25
  darkVariables?: Record<string, string>;
26
26
  };
27
27
  }
28
+ /**
29
+ * What app-render needs to boot, fetched by the platform as the iframe mounts: the answers to the
30
+ * two lookups app-render makes for itself when it runs on its own — its app by the frame's host
31
+ * (`get-app-by-domain`, with the frame's `?version=`) and the current user on it
32
+ * (`safe-users/current`). From the platform's origin they are same-origin, one round trip each,
33
+ * and they run while the frame is still loading. The same endpoints, so the same JSON; null for
34
+ * one the platform could not get, which app-render then asks for itself.
35
+ */
36
+ export interface IframeBootData {
37
+ app: Record<string, unknown> | null;
38
+ user: Record<string, unknown> | null;
39
+ }
28
40
  /**
29
41
  * Methods the platform (Remix parent window) exposes to the iframe (app-render).
30
42
  * Called by code running inside the iframe to communicate back to the platform.
31
43
  */
32
44
  export interface PlatformApi extends Methods {
33
45
  getToken: () => Promise<string>;
46
+ /**
47
+ * The frame's boot data (`IframeBootData`), asked the moment the bridge connects. A platform from
48
+ * before it has no such method, so app-render calls it expecting a rejection there and then
49
+ * looks itself up.
50
+ */
51
+ getBootData: () => Promise<IframeBootData>;
34
52
  onLogout: () => void;
35
53
  onIframePageChange: (args: {
36
54
  changeToPageId: string;
@@ -51,6 +69,18 @@ export interface PlatformApi extends Methods {
51
69
  }) => Promise<void>;
52
70
  onLoad: () => Promise<void>;
53
71
  chooseElement: (data: ElementData) => Promise<void>;
72
+ /**
73
+ * Opens another app on the platform — a platform app link clicked in the app
74
+ * (`parsePlatformAppLink`): at `path` when that app serves it, else where it opens; `newTab`
75
+ * for a modifier-click. A platform from before it has no such method, so app-render calls it
76
+ * expecting a rejection there.
77
+ */
78
+ onOpenApp: (args: {
79
+ appId: string;
80
+ path?: string;
81
+ search?: string;
82
+ newTab?: boolean;
83
+ }) => Promise<void>;
54
84
  }
55
85
  /**
56
86
  * A chat component the builder previews inside the app, in place of its routes: the react-live
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/iframe-communication/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEpD,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CA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E,WAAW,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,mBAAmB,EAAE,CAAC,cAAc,EAAE,aAAa,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,gGAAgG;IAChG,sBAAsB,EAAE,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChF;;;;OAIG;IACH,wBAAwB,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D;;;;OAIG;IACH,iBAAiB,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAClE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocksdiy/react-common",
3
- "version": "1.56.0",
3
+ "version": "1.58.0",
4
4
  "type": "module",
5
5
  "description": "React common",
6
6
  "keywords": [],
@@ -37,9 +37,9 @@
37
37
  "@copilotkit/react-core": "1.70.2",
38
38
  "@radix-ui/react-slot": "^1.2.3",
39
39
  "@vapi-ai/web": "^2.5.2",
40
- "penpal": "^8.0.0",
40
+ "penpal": "^8.0.1",
41
41
  "react": "^19.2.8",
42
- "use-stick-to-bottom": "1.1.4"
42
+ "use-stick-to-bottom": "1.1.6"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@blockscom/eslint-config": "4.6.4",