@sampleapp.ai/sdk 1.0.47 → 1.0.48

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,23 +1,26 @@
1
1
  "use client";
2
2
  import React, { useEffect, useState, useCallback, useRef } from "react";
3
- import { fetchSandboxConfigWithContent, buildConfigFromContent } from "./api";
3
+ import { fetchSandboxConfigWithContent, buildConfigFromContent, } from "./api";
4
4
  import GuardianPlayground from "./guardian/guardian-playground";
5
5
  import { GuardianProvider } from "./guardian/context/guardian-context";
6
6
  import { VmProvider } from "./guardian/context/vm-context";
7
7
  import { Skeleton } from "../ui/skeleton";
8
8
  import { useTreeSelector } from "../../hooks/use-tree-selector";
9
- import { SELECTABLE_NODE_TYPES } from "../../lib/types/tree-config";
10
- import { useFrameParams } from "./guardian/hooks/use-frame-params";
9
+ import { SELECTABLE_NODE_TYPES, } from "../../lib/types/tree-config";
10
+ import { useFrameParams, } from "./guardian/hooks/use-frame-params";
11
11
  /**
12
12
  * Inner component that uses the tree selector hook
13
13
  * Separated to ensure hooks are called after data is loaded
14
14
  */
15
- function SandboxInner({ configWithContent, apiKey, env, themeColor, theme, config }) {
15
+ function SandboxInner({ configWithContent, apiKey, env, themeColor, theme, config, }) {
16
16
  var _a;
17
17
  const [currentConfig, setCurrentConfig] = useState(configWithContent.legacyConfig);
18
18
  // Get frame params for syncing external selection changes
19
19
  const frameParams = useFrameParams();
20
20
  const isFrame = (config === null || config === void 0 ? void 0 : config.isFrame) || frameParams.isFrame;
21
+ const containerClass = isFrame
22
+ ? "h-full w-full bg-white dark:bg-black"
23
+ : "h-screen w-full bg-white dark:bg-black";
21
24
  // Track previous nodeTypes to detect changes
22
25
  const prevNodeTypesRef = useRef({});
23
26
  // Handle selection changes - update the config when user selects different options
@@ -37,7 +40,7 @@ function SandboxInner({ configWithContent, apiKey, env, themeColor, theme, confi
37
40
  config: configWithContent.techStackConfig,
38
41
  allContent: configWithContent.allContent,
39
42
  initialPath: configWithContent.initialSelectionPath,
40
- onSelectionChange: handleSelectionChange
43
+ onSelectionChange: handleSelectionChange,
41
44
  });
42
45
  // Sync frame params with tree selector when in frame mode
43
46
  // This effect listens for changes in URL params (via postMessage or direct URL changes)
@@ -73,12 +76,12 @@ function SandboxInner({ configWithContent, apiKey, env, themeColor, theme, confi
73
76
  const firstUseCase = currentConfig.useCases[0];
74
77
  const firstFramework = (_a = firstUseCase === null || firstUseCase === void 0 ? void 0 : firstUseCase.frameworks[0]) === null || _a === void 0 ? void 0 : _a.key;
75
78
  if (!firstUseCase || !firstFramework) {
76
- return (React.createElement("div", { className: "flex items-center justify-center h-screen bg-white dark:bg-black" },
79
+ return (React.createElement("div", { className: `flex items-center justify-center ${containerClass}` },
77
80
  React.createElement("div", { className: "text-red-500" }, "No use cases or frameworks found")));
78
81
  }
79
82
  return (React.createElement(GuardianProvider, null,
80
83
  React.createElement(VmProvider, null,
81
- React.createElement("div", { className: "h-screen w-screen bg-white dark:bg-black" },
84
+ React.createElement("div", { className: containerClass },
82
85
  React.createElement(GuardianPlayground, { sandboxConfig: currentConfig, sections: sections, onSelect: selectOption, useCase: firstUseCase.id, framework: firstFramework, isFrame: isFrame, apiKey: apiKey, env: env, chatUid: currentConfig.chatUid, theme: theme, hasNetworkView: config === null || config === void 0 ? void 0 : config.hasNetworkView })))));
83
86
  }
84
87
  /**
@@ -108,10 +111,14 @@ function SandboxInner({ configWithContent, apiKey, env, themeColor, theme, confi
108
111
  * />
109
112
  * ```
110
113
  */
111
- export default function Sandbox({ apiKey, sandboxId, env, themeColor, theme = "dark", config }) {
114
+ export default function Sandbox({ apiKey, sandboxId, env, themeColor, theme = "dark", config, }) {
112
115
  // Validate apiKey immediately
116
+ const isFrame = config === null || config === void 0 ? void 0 : config.isFrame;
117
+ const containerClass = isFrame
118
+ ? "h-full w-full bg-white dark:bg-black"
119
+ : "h-screen w-full bg-white dark:bg-black";
113
120
  if (!apiKey || apiKey.trim() === "") {
114
- return (React.createElement("div", { className: "flex items-center justify-center h-screen bg-white dark:bg-black" },
121
+ return (React.createElement("div", { className: `flex items-center justify-center ${containerClass}` },
115
122
  React.createElement("div", { className: "text-red-500" }, "Error: apiKey is required. Please provide a valid API key.")));
116
123
  }
117
124
  const [configWithContent, setConfigWithContent] = useState(null);
@@ -148,11 +155,11 @@ export default function Sandbox({ apiKey, sandboxId, env, themeColor, theme = "d
148
155
  };
149
156
  }, [apiKey, sandboxId, themeColor]);
150
157
  if (loading) {
151
- return (React.createElement("div", { className: "h-screen w-screen bg-white dark:bg-black" },
158
+ return (React.createElement("div", { className: containerClass },
152
159
  React.createElement(Skeleton, { className: "w-full h-full bg-zinc-100 dark:bg-zinc-900" })));
153
160
  }
154
161
  if (error) {
155
- return (React.createElement("div", { className: "flex items-center justify-center h-screen bg-white dark:bg-black" },
162
+ return (React.createElement("div", { className: `flex items-center justify-center ${containerClass}` },
156
163
  React.createElement("div", { className: "text-red-500" },
157
164
  "Error: ",
158
165
  error)));
package/dist/index.d.ts CHANGED
@@ -670,7 +670,7 @@ declare class SampleAppSDK {
670
670
  * />
671
671
  * ```
672
672
  */
673
- export declare function Sandbox({ apiKey, sandboxId, env, themeColor, theme, config }: SandboxProps): default_2.JSX.Element | null;
673
+ export declare function Sandbox({ apiKey, sandboxId, env, themeColor, theme, config, }: SandboxProps): default_2.JSX.Element | null;
674
674
 
675
675
  /**
676
676
  * Configuration fetched from the API for a sandbox