@rork-ai/toolkit-sdk 0.2.19 → 0.2.22

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.
Files changed (56) hide show
  1. package/lib/module/dev/error-boundary.js +133 -0
  2. package/lib/module/dev/error-boundary.js.map +1 -0
  3. package/lib/module/dev/patch-alert/patch-alert.js +4 -0
  4. package/lib/module/dev/patch-alert/patch-alert.js.map +1 -0
  5. package/lib/module/dev/patch-alert/patch-alert.web.js +7 -0
  6. package/lib/module/dev/patch-alert/patch-alert.web.js.map +1 -0
  7. package/lib/module/dev/safe-insets-content.js +13 -0
  8. package/lib/module/dev/safe-insets-content.js.map +1 -0
  9. package/lib/module/dev/safe-insets-content.web.js +61 -0
  10. package/lib/module/dev/safe-insets-content.web.js.map +1 -0
  11. package/lib/module/dev/sdk53/index.js +19 -0
  12. package/lib/module/dev/sdk53/index.js.map +1 -0
  13. package/lib/module/dev/sdk53/inspector.js +413 -0
  14. package/lib/module/dev/sdk53/inspector.js.map +1 -0
  15. package/lib/module/dev/sdk53/inspector.web.js +11 -0
  16. package/lib/module/dev/sdk53/inspector.web.js.map +1 -0
  17. package/lib/module/dev/sdk54/index.js +19 -0
  18. package/lib/module/dev/sdk54/index.js.map +1 -0
  19. package/lib/module/dev/sdk54/inspector.js +290 -0
  20. package/lib/module/dev/sdk54/inspector.js.map +1 -0
  21. package/lib/module/dev/sdk54/inspector.web.js +11 -0
  22. package/lib/module/dev/sdk54/inspector.web.js.map +1 -0
  23. package/lib/typescript/src/dev/error-boundary.d.ts +20 -0
  24. package/lib/typescript/src/dev/error-boundary.d.ts.map +1 -0
  25. package/lib/typescript/src/dev/patch-alert/patch-alert.d.ts +2 -0
  26. package/lib/typescript/src/dev/patch-alert/patch-alert.d.ts.map +1 -0
  27. package/lib/typescript/src/dev/patch-alert/patch-alert.web.d.ts +2 -0
  28. package/lib/typescript/src/dev/patch-alert/patch-alert.web.d.ts.map +1 -0
  29. package/lib/typescript/src/dev/safe-insets-content.d.ts +3 -0
  30. package/lib/typescript/src/dev/safe-insets-content.d.ts.map +1 -0
  31. package/lib/typescript/src/dev/safe-insets-content.web.d.ts +3 -0
  32. package/lib/typescript/src/dev/safe-insets-content.web.d.ts.map +1 -0
  33. package/lib/typescript/src/dev/sdk53/index.d.ts +5 -0
  34. package/lib/typescript/src/dev/sdk53/index.d.ts.map +1 -0
  35. package/lib/typescript/src/dev/sdk53/inspector.d.ts +23 -0
  36. package/lib/typescript/src/dev/sdk53/inspector.d.ts.map +1 -0
  37. package/lib/typescript/src/dev/sdk53/inspector.web.d.ts +4 -0
  38. package/lib/typescript/src/dev/sdk53/inspector.web.d.ts.map +1 -0
  39. package/lib/typescript/src/dev/sdk54/index.d.ts +5 -0
  40. package/lib/typescript/src/dev/sdk54/index.d.ts.map +1 -0
  41. package/lib/typescript/src/dev/sdk54/inspector.d.ts +23 -0
  42. package/lib/typescript/src/dev/sdk54/inspector.d.ts.map +1 -0
  43. package/lib/typescript/src/dev/sdk54/inspector.web.d.ts +4 -0
  44. package/lib/typescript/src/dev/sdk54/inspector.web.d.ts.map +1 -0
  45. package/package.json +25 -20
  46. package/src/dev/error-boundary.tsx +161 -0
  47. package/src/dev/patch-alert/patch-alert.tsx +1 -0
  48. package/src/dev/patch-alert/patch-alert.web.tsx +5 -0
  49. package/src/dev/safe-insets-content.tsx +7 -0
  50. package/src/dev/safe-insets-content.web.tsx +57 -0
  51. package/src/dev/sdk53/index.tsx +15 -0
  52. package/src/dev/sdk53/inspector.tsx +467 -0
  53. package/src/dev/sdk53/inspector.web.tsx +3 -0
  54. package/src/dev/sdk54/index.tsx +15 -0
  55. package/src/dev/sdk54/inspector.tsx +345 -0
  56. package/src/dev/sdk54/inspector.web.tsx +3 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rork-ai/toolkit-sdk",
3
- "version": "0.2.19",
3
+ "version": "0.2.22",
4
4
  "description": "toolkit-sdk",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -10,7 +10,19 @@
10
10
  "types": "./lib/typescript/src/index.d.ts",
11
11
  "default": "./lib/module/index.js"
12
12
  },
13
- "./package.json": "./package.json"
13
+ "exports": {
14
+ "./package.json": "./package.json",
15
+ "./v53": {
16
+ "source": "./src/dev/sdk53/index.tsx",
17
+ "types": "./lib/typescript/src/dev/sdk53/index.d.ts",
18
+ "default": "./lib/module/dev/sdk53/index.js"
19
+ },
20
+ "./v54": {
21
+ "source": "./src/dev/sdk54/index.tsx",
22
+ "types": "./lib/typescript/src/dev/sdk54/index.d.ts",
23
+ "default": "./lib/module/dev/sdk54/index.js"
24
+ }
25
+ }
14
26
  },
15
27
  "files": [
16
28
  "src",
@@ -57,7 +69,7 @@
57
69
  "@eslint/js": "^9.35.0",
58
70
  "@react-native/babel-preset": "0.81.1",
59
71
  "@react-native/eslint-config": "^0.81.1",
60
- "@tanstack/react-query": "5.56.2",
72
+ "@tanstack/react-query": "5.90.10",
61
73
  "@types/jest": "^29.5.14",
62
74
  "@types/react": "19.1.11",
63
75
  "@types/ungap__structured-clone": "^1.2.0",
@@ -73,12 +85,16 @@
73
85
  "react": "19.1.0",
74
86
  "react-native": "0.81.4",
75
87
  "react-native-builder-bob": "^0.40.13",
76
- "release-it": "^19.0.4",
77
- "release-it-pnpm": "^4.6.6",
78
88
  "typescript": "5.9.3",
79
- "zod": "4.1.12"
89
+ "zod": "4.1.12",
90
+ "expo-blur": "15.0.7",
91
+ "lucide-react-native": "0.544.0",
92
+ "react-native-safe-area-context": "~5.6.1"
80
93
  },
81
94
  "peerDependencies": {
95
+ "expo-blur": "*",
96
+ "lucide-react-native": "*",
97
+ "react-native-safe-area-context": "*",
82
98
  "@tanstack/react-query": "*",
83
99
  "expo": "*",
84
100
  "expo-modules-core": "*",
@@ -97,17 +113,6 @@
97
113
  "<rootDir>/lib/"
98
114
  ]
99
115
  },
100
- "release-it": {
101
- "npm": {
102
- "publish": true
103
- },
104
- "github": {
105
- "release": false
106
- },
107
- "plugins": {
108
- "release-it-pnpm": {}
109
- }
110
- },
111
116
  "prettier": {
112
117
  "quoteProps": "consistent",
113
118
  "singleQuote": true,
@@ -143,15 +148,15 @@
143
148
  "@stardazed/streams-text-encoding": "^1.0.2",
144
149
  "@ungap/structured-clone": "^1.3.0",
145
150
  "ai": "5.0.93",
146
- "posthog-react-native": "^4.10.8"
151
+ "posthog-react-native": "^4.10.8",
152
+ "@blazejkustra/react-native-alert": "^1.0.0"
147
153
  },
148
154
  "scripts": {
149
- "test": "jest",
150
155
  "typecheck": "tsc",
151
156
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
152
157
  "clean": "del-cli lib",
153
158
  "build": "bob build",
154
- "release": "pnpm build && release-it --only-version --no-git",
159
+ "release": "pnpm build && pnpm version patch && pnpm publish --no-git-checks",
155
160
  "start": "cd example && pnpm start"
156
161
  }
157
162
  }
@@ -0,0 +1,161 @@
1
+ import { requireOptionalNativeModule } from "expo-modules-core";
2
+ import React from "react";
3
+ import { Platform, StyleSheet, Text, View } from "react-native";
4
+
5
+ interface Props {
6
+ children: React.ReactNode;
7
+ onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
8
+ }
9
+
10
+ interface State {
11
+ hasError: boolean;
12
+ error: Error | null;
13
+ }
14
+
15
+ const IFRAME_ID = "rork-web-preview";
16
+
17
+ const webTargetOrigins = [
18
+ "http://localhost:3000",
19
+ "https://rorkai.com",
20
+ "https://rork.com",
21
+ ];
22
+
23
+ const BridgeModule = requireOptionalNativeModule("Bridge");
24
+
25
+ function sendErrorToIframeParent(error: any, errorInfo?: any) {
26
+ const errorData = {
27
+ message: error?.message || error?.toString() || "Unknown error",
28
+ stack: error?.stack,
29
+ componentStack: errorInfo?.componentStack,
30
+ timestamp: new Date().toISOString(),
31
+ };
32
+
33
+ if (Platform.OS === "web" && typeof window !== "undefined") {
34
+ console.debug("Sending error to parent via postMessage:", {
35
+ error,
36
+ errorInfo,
37
+ referrer: document.referrer,
38
+ });
39
+
40
+ const errorMessage = {
41
+ type: "ERROR",
42
+ error: errorData,
43
+ iframeId: IFRAME_ID,
44
+ };
45
+
46
+ try {
47
+ window.parent.postMessage(
48
+ errorMessage,
49
+ webTargetOrigins.includes(document.referrer) ? document.referrer : "*",
50
+ );
51
+ } catch (postMessageError) {
52
+ console.warn("Failed to send error to parent:", postMessageError);
53
+ }
54
+ } else if (Platform.OS !== "web" && BridgeModule) {
55
+ BridgeModule?.sendMessage({
56
+ type: "runtime-error",
57
+ data: JSON.stringify(errorData),
58
+ });
59
+ }
60
+ }
61
+
62
+ if (Platform.OS === "web" && typeof window !== "undefined") {
63
+ window.addEventListener(
64
+ "error",
65
+ (event) => {
66
+ event.preventDefault();
67
+ const errorDetails = event.error ?? {
68
+ message: event.message ?? "Unknown error",
69
+ filename: event.filename ?? "Unknown file",
70
+ lineno: event.lineno ?? "Unknown line",
71
+ colno: event.colno ?? "Unknown column",
72
+ };
73
+ sendErrorToIframeParent(errorDetails);
74
+ },
75
+ true,
76
+ );
77
+
78
+ window.addEventListener(
79
+ "unhandledrejection",
80
+ (event) => {
81
+ event.preventDefault();
82
+ sendErrorToIframeParent(event.reason);
83
+ },
84
+ true,
85
+ );
86
+ }
87
+
88
+ const originalConsoleError = console.error;
89
+ console.error = (...args) => {
90
+ sendErrorToIframeParent(args.join(" "));
91
+ originalConsoleError.apply(console, args);
92
+ };
93
+
94
+ export class RorkErrorBoundary extends React.Component<Props, State> {
95
+ constructor(props: Props) {
96
+ super(props);
97
+ this.state = { hasError: false, error: null };
98
+ }
99
+
100
+ static getDerivedStateFromError(error: Error) {
101
+ return { hasError: true, error };
102
+ }
103
+
104
+ componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
105
+ sendErrorToIframeParent(error, errorInfo);
106
+ if (this.props.onError) {
107
+ this.props.onError(error, errorInfo);
108
+ }
109
+ }
110
+
111
+ render() {
112
+ if (this.state.hasError) {
113
+ return (
114
+ <View style={styles.container}>
115
+ <View style={styles.content}>
116
+ <Text style={styles.title}>Something went wrong</Text>
117
+ <Text style={styles.subtitle}>{this.state.error?.message}</Text>
118
+ {Platform.OS !== "web" && (
119
+ <Text style={styles.description}>
120
+ Please check your device logs for more details.
121
+ </Text>
122
+ )}
123
+ </View>
124
+ </View>
125
+ );
126
+ }
127
+
128
+ return this.props.children;
129
+ }
130
+ }
131
+
132
+ const styles = StyleSheet.create({
133
+ container: {
134
+ flex: 1,
135
+ backgroundColor: "#fff",
136
+ },
137
+ content: {
138
+ flex: 1,
139
+ alignItems: "center",
140
+ justifyContent: "center",
141
+ padding: 20,
142
+ },
143
+ title: {
144
+ fontSize: 36,
145
+ textAlign: "center",
146
+ fontWeight: "bold",
147
+ marginBottom: 8,
148
+ },
149
+ subtitle: {
150
+ fontSize: 14,
151
+ color: "#666",
152
+ marginBottom: 12,
153
+ textAlign: "center",
154
+ },
155
+ description: {
156
+ fontSize: 14,
157
+ color: "#666",
158
+ textAlign: "center",
159
+ marginTop: 8,
160
+ },
161
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import AlertNew from "@blazejkustra/react-native-alert";
2
+ import { Alert } from "react-native";
3
+
4
+ Alert.alert = AlertNew.alert;
5
+ Alert.prompt = AlertNew.prompt;
@@ -0,0 +1,7 @@
1
+ import type { PropsWithChildren } from "react";
2
+
3
+ export function RorkSafeInsets({ children }: PropsWithChildren) {
4
+ // On native, use the default safe area context from react-native-safe-area-context
5
+ // which is already provided by expo-router
6
+ return <>{children}</>;
7
+ }
@@ -0,0 +1,57 @@
1
+ import { useEffect, useState, type PropsWithChildren } from "react";
2
+ import { Platform } from "react-native";
3
+ import {
4
+ SafeAreaInsetsContext,
5
+ type EdgeInsets,
6
+ } from "react-native-safe-area-context";
7
+
8
+ const DEFAULT_IOS_LIKE_WEB_INSETS: EdgeInsets = {
9
+ top: 44,
10
+ right: 0,
11
+ bottom: 34,
12
+ left: 0,
13
+ };
14
+
15
+ export function RorkSafeInsets({ children }: PropsWithChildren) {
16
+ if (Platform.OS !== "web") {
17
+ return <>{children}</>;
18
+ }
19
+
20
+ const [insets, setInsets] = useState<EdgeInsets>(DEFAULT_IOS_LIKE_WEB_INSETS);
21
+
22
+ useEffect(() => {
23
+ const handleMessage = (event: MessageEvent) => {
24
+ // Security check: validate the event origin if needed
25
+ // if (event.origin !== 'https://your-expected-origin.com') return;
26
+
27
+ if (event.data?.type === "update-safe-area-insets") {
28
+ const { top, right, bottom, left } = event.data.insets;
29
+
30
+ // Validate that all values are numbers
31
+ if (
32
+ typeof top === "number" &&
33
+ typeof right === "number" &&
34
+ typeof bottom === "number" &&
35
+ typeof left === "number"
36
+ ) {
37
+ setInsets({ top, right, bottom, left });
38
+ }
39
+ }
40
+ };
41
+
42
+ window.addEventListener("message", handleMessage);
43
+
44
+ // Notify parent that we're ready to receive insets
45
+ window.parent.postMessage({ type: "safe-insets-ready" }, "*");
46
+
47
+ return () => {
48
+ window.removeEventListener("message", handleMessage);
49
+ };
50
+ }, []);
51
+
52
+ return (
53
+ <SafeAreaInsetsContext.Provider value={insets}>
54
+ {children}
55
+ </SafeAreaInsetsContext.Provider>
56
+ );
57
+ }
@@ -0,0 +1,15 @@
1
+ import { RorkErrorBoundary } from "../error-boundary";
2
+ import { RorkSafeInsets } from "../safe-insets-content";
3
+ import { BundleInspector } from "./inspector";
4
+
5
+ import "../patch-alert";
6
+
7
+ export function RorkDevWrapper({ children }: { children: React.ReactNode }) {
8
+ return (
9
+ <RorkErrorBoundary>
10
+ <BundleInspector>
11
+ <RorkSafeInsets>{children}</RorkSafeInsets>
12
+ </BundleInspector>
13
+ </RorkErrorBoundary>
14
+ );
15
+ }