@sampleapp.ai/sdk 1.0.29 → 1.0.31

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 (145) hide show
  1. package/dist/components/guardian/app-layout-no-sidebar.js +8 -0
  2. package/dist/components/guardian/ask-ai-view.js +249 -0
  3. package/dist/components/guardian/code-focus-section.d.ts +41 -0
  4. package/dist/components/guardian/code-focus-section.js +174 -0
  5. package/dist/components/guardian/context/guardian-context.js +94 -0
  6. package/dist/components/guardian/context/vm-context.js +28 -0
  7. package/dist/components/guardian/default-guide-view.js +34 -0
  8. package/dist/components/guardian/demo/guardian-demo.js +35 -0
  9. package/dist/components/guardian/demo/left-view/toggle.js +28 -0
  10. package/dist/components/guardian/demo/left-view.js +49 -0
  11. package/dist/components/guardian/guardian-component.js +79 -0
  12. package/dist/components/guardian/guardian-demo.js +35 -0
  13. package/dist/components/guardian/guardian-home.d.ts +4 -0
  14. package/dist/components/guardian/guardian-home.js +61 -0
  15. package/dist/components/guardian/guardian-playground.js +45 -0
  16. package/dist/components/guardian/guardian-style-wrapper.js +29 -0
  17. package/dist/components/guardian/guardian-upload-spec.d.ts +14 -0
  18. package/dist/components/guardian/guardian-upload-spec.js +160 -0
  19. package/dist/components/guardian/header/glassmorphic-combobox.d.ts +15 -0
  20. package/dist/components/guardian/header/glassmorphic-combobox.js +30 -0
  21. package/dist/components/guardian/header.js +61 -0
  22. package/dist/components/guardian/hooks/use-frame-messages.js +65 -0
  23. package/dist/components/guardian/hooks/use-frame-params.js +44 -0
  24. package/dist/components/guardian/hooks/use-sandbox-url-loader.js +101 -0
  25. package/dist/components/guardian/ide/browser.js +538 -0
  26. package/dist/components/guardian/index.js +8 -0
  27. package/dist/components/guardian/layout/app-layout-no-sidebar.js +8 -0
  28. package/dist/components/guardian/layout/header/glassmorphic-combobox.js +48 -0
  29. package/dist/components/guardian/layout/header.js +63 -0
  30. package/dist/components/guardian/right-view/code-view.js +56 -0
  31. package/dist/components/guardian/right-view/pill-file-selector.js +233 -0
  32. package/dist/components/guardian/right-view/preview-control-bar.js +25 -0
  33. package/dist/components/guardian/right-view/right-panel-view.js +38 -0
  34. package/dist/components/guardian/right-view/right-top-down-view.js +289 -0
  35. package/dist/components/guardian/right-view/right-view.js +28 -0
  36. package/dist/components/guardian/right-view/simplified-editor.js +234 -0
  37. package/dist/components/guardian/types/ide-types.js +162 -0
  38. package/dist/components/guardian/types.js +3 -0
  39. package/dist/components/guardian/ui/ai-loader.js +48 -0
  40. package/dist/components/guardian/ui/badge.js +24 -0
  41. package/dist/components/guardian/ui/button.js +45 -0
  42. package/dist/components/guardian/ui/command.js +63 -0
  43. package/dist/components/guardian/ui/console-with-app.js +17 -0
  44. package/dist/components/guardian/ui/dialog.js +57 -0
  45. package/dist/components/guardian/ui/dropdown-menu.js +82 -0
  46. package/dist/components/guardian/ui/markdown.js +57 -0
  47. package/dist/components/guardian/ui/popover.js +25 -0
  48. package/dist/components/guardian/ui/tooltip.js +25 -0
  49. package/dist/components/guardian/utils.js +88 -0
  50. package/dist/components/guardian/zip-to-codebase.js +246 -0
  51. package/dist/components/guardian/zip-to-filetree.js +284 -0
  52. package/dist/components/icons.js +22 -0
  53. package/dist/components/sandbox/Sandbox.js +88 -0
  54. package/dist/components/sandbox/SandboxHome.js +141 -0
  55. package/dist/components/sandbox/api.js +84 -0
  56. package/dist/components/sandbox/guardian/app-layout-no-sidebar.js +11 -0
  57. package/dist/components/sandbox/guardian/ask-ai-view.js +249 -0
  58. package/dist/components/sandbox/guardian/code-focus-section.js +174 -0
  59. package/dist/components/sandbox/guardian/context/guardian-context.js +94 -0
  60. package/dist/components/sandbox/guardian/context/vm-context.js +28 -0
  61. package/dist/components/sandbox/guardian/default-guide-view.js +34 -0
  62. package/dist/components/sandbox/guardian/demo/guardian-demo.js +35 -0
  63. package/dist/components/sandbox/guardian/demo/left-view/toggle.js +28 -0
  64. package/dist/components/sandbox/guardian/demo/left-view.js +70 -0
  65. package/dist/components/sandbox/guardian/guardian-component.js +99 -0
  66. package/dist/components/sandbox/guardian/guardian-demo.js +35 -0
  67. package/dist/components/sandbox/guardian/guardian-home.d.ts +4 -0
  68. package/dist/components/sandbox/guardian/guardian-home.js +61 -0
  69. package/dist/components/sandbox/guardian/guardian-playground.js +45 -0
  70. package/dist/components/sandbox/guardian/guardian-style-wrapper.js +47 -0
  71. package/dist/components/sandbox/guardian/guardian-upload-spec.d.ts +14 -0
  72. package/dist/components/sandbox/guardian/guardian-upload-spec.js +160 -0
  73. package/dist/components/sandbox/guardian/header/glassmorphic-combobox.js +30 -0
  74. package/dist/components/sandbox/guardian/header.js +61 -0
  75. package/dist/components/sandbox/guardian/hooks/use-frame-messages.js +65 -0
  76. package/dist/components/sandbox/guardian/hooks/use-frame-params.js +44 -0
  77. package/dist/components/sandbox/guardian/hooks/use-sandbox-url-loader.js +125 -0
  78. package/dist/components/sandbox/guardian/ide/browser.js +538 -0
  79. package/dist/components/sandbox/guardian/index.js +8 -0
  80. package/dist/components/sandbox/guardian/right-view/code-view.js +60 -0
  81. package/dist/components/sandbox/guardian/right-view/pill-file-selector.js +246 -0
  82. package/dist/components/sandbox/guardian/right-view/preview-control-bar.js +25 -0
  83. package/dist/components/sandbox/guardian/right-view/right-panel-view.js +51 -0
  84. package/dist/components/sandbox/guardian/right-view/right-top-down-view.js +281 -0
  85. package/dist/components/sandbox/guardian/right-view/right-view.js +28 -0
  86. package/dist/components/sandbox/guardian/right-view/simplified-editor.js +234 -0
  87. package/dist/components/sandbox/guardian/types/ide-types.js +162 -0
  88. package/dist/components/sandbox/guardian/types.js +3 -0
  89. package/dist/components/sandbox/guardian/ui/ai-loader.js +91 -0
  90. package/dist/components/sandbox/guardian/ui/badge.js +24 -0
  91. package/dist/components/sandbox/guardian/ui/button.js +45 -0
  92. package/dist/components/sandbox/guardian/ui/command.js +63 -0
  93. package/dist/components/sandbox/guardian/ui/console-with-app.js +17 -0
  94. package/dist/components/sandbox/guardian/ui/dialog.js +57 -0
  95. package/dist/components/sandbox/guardian/ui/download-and-open-buttons.js +117 -0
  96. package/dist/components/sandbox/guardian/ui/dropdown-menu.js +82 -0
  97. package/dist/components/sandbox/guardian/ui/markdown/accordion-group/accordion.js +62 -0
  98. package/dist/components/sandbox/guardian/ui/markdown/accordion-group.js +23 -0
  99. package/dist/components/sandbox/guardian/ui/markdown/callout/callout-check.js +4 -0
  100. package/dist/components/sandbox/guardian/ui/markdown/callout/callout-error.js +4 -0
  101. package/dist/components/sandbox/guardian/ui/markdown/callout/callout-info.js +4 -0
  102. package/dist/components/sandbox/guardian/ui/markdown/callout/callout-note.js +4 -0
  103. package/dist/components/sandbox/guardian/ui/markdown/callout/callout-tip.js +4 -0
  104. package/dist/components/sandbox/guardian/ui/markdown/callout/callout-warning.js +4 -0
  105. package/dist/components/sandbox/guardian/ui/markdown/callout/shared/callout.js +9 -0
  106. package/dist/components/sandbox/guardian/ui/markdown/callout/shared/types.js +1 -0
  107. package/dist/components/sandbox/guardian/ui/markdown/card-group/card.js +18 -0
  108. package/dist/components/sandbox/guardian/ui/markdown/card-group.js +25 -0
  109. package/dist/components/sandbox/guardian/ui/markdown/code-group/code-block.js +54 -0
  110. package/dist/components/sandbox/guardian/ui/markdown/code-group.js +101 -0
  111. package/dist/components/sandbox/guardian/ui/markdown/icon.js +31 -0
  112. package/dist/components/sandbox/guardian/ui/markdown.js +791 -0
  113. package/dist/components/sandbox/guardian/ui/popover.js +25 -0
  114. package/dist/components/sandbox/guardian/ui/tooltip.js +25 -0
  115. package/dist/components/sandbox/guardian/utils.js +89 -0
  116. package/dist/components/sandbox/guardian/zip-to-codebase.js +259 -0
  117. package/dist/components/sandbox/guardian/zip-to-filetree.js +284 -0
  118. package/dist/components/sandbox/index.js +4 -0
  119. package/dist/components/sandbox/sandbox-control-bar.js +91 -0
  120. package/dist/components/sandbox/sandbox-header.js +52 -0
  121. package/dist/components/sandbox/sandbox-home/SandboxCard.js +65 -0
  122. package/dist/components/sandbox/sandbox-home/SandboxHome.js +115 -0
  123. package/dist/components/sandbox/sandbox-home/SearchBar.js +12 -0
  124. package/dist/components/sandbox/sandbox-home/index.js +3 -0
  125. package/dist/components/sandbox/sandbox-left-panel.js +248 -0
  126. package/dist/components/sandbox/sandbox-loading.js +48 -0
  127. package/dist/components/sandbox/sandbox-right-panel.js +247 -0
  128. package/dist/components/sandbox/types.js +1 -0
  129. package/dist/components/sandbox.js +32 -0
  130. package/dist/components/tailwind-example.js +46 -0
  131. package/dist/components/ui/skeleton.js +18 -0
  132. package/dist/index.d.ts +32 -103
  133. package/dist/index.es.js +90529 -423
  134. package/dist/index.js +13 -2
  135. package/dist/index.standalone.js +61 -53
  136. package/dist/index.standalone.umd.js +17 -24
  137. package/dist/lib/api-client.example.js +60 -0
  138. package/dist/lib/api-client.js +140 -0
  139. package/dist/lib/generated-css.js +4 -0
  140. package/dist/lib/inject-styles.js +42 -0
  141. package/dist/lib/shadow-dom-wrapper.js +42 -0
  142. package/dist/lib/utils.js +5 -0
  143. package/dist/sdk.css +1 -1
  144. package/dist/tailwind.css +1 -0
  145. package/package.json +41 -9
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Example usage of the API client
3
+ *
4
+ * This file demonstrates how to use the API client to interact with
5
+ * the SampleApp backend API.
6
+ *
7
+ * The apiKey will be passed in from SandboxProps.apiKey (from types.ts)
8
+ */
9
+ import { createApiClient } from "./api-client";
10
+ // Example: How to use the API client with apiKey from SandboxProps
11
+ function createClientFromSandboxProps(props, baseUrl = "http://127.0.0.1:8000") {
12
+ return createApiClient({
13
+ baseUrl,
14
+ apiKey: props.apiKey, // apiKey comes from SandboxProps
15
+ });
16
+ }
17
+ // Initialize the API client (example)
18
+ const client = createApiClient({
19
+ baseUrl: "http://127.0.0.1:8000", // or your production URL
20
+ apiKey: "your-api-key-here", // This will come from SandboxProps.apiKey
21
+ });
22
+ // Example 1: Get public sandbox content
23
+ // Note: sandboxId from SandboxProps maps to sandbox_content_uid
24
+ async function getSandboxContentExample(apiKey, sandboxId, baseUrl = "http://127.0.0.1:8000") {
25
+ try {
26
+ const client = createApiClient({
27
+ baseUrl,
28
+ apiKey, // apiKey from SandboxProps.apiKey
29
+ });
30
+ // sandboxId from SandboxProps maps to sandbox_content_uid
31
+ const sandboxContent = await client.sandboxContent.getPublic(sandboxId);
32
+ console.log("Sandbox content:", sandboxContent);
33
+ return sandboxContent;
34
+ }
35
+ catch (error) {
36
+ console.error("Error fetching sandbox content:", error);
37
+ throw error;
38
+ }
39
+ }
40
+ // Example 2: Start a sandbox
41
+ async function startSandboxExample() {
42
+ try {
43
+ const response = await client.sdk.startSandbox({
44
+ env: {
45
+ API_KEY: "your-api-key",
46
+ ENVIRONMENT: "production",
47
+ },
48
+ apiKey: "your-sdk-api-key",
49
+ chatUid: "your-chat-uid",
50
+ });
51
+ console.log("Container URL:", response.container_url);
52
+ return response;
53
+ }
54
+ catch (error) {
55
+ console.error("Error starting sandbox:", error);
56
+ throw error;
57
+ }
58
+ }
59
+ // Export examples for use in other files
60
+ export { getSandboxContentExample, startSandboxExample, createClientFromSandboxProps, };
@@ -0,0 +1,140 @@
1
+ /**
2
+ * SDK API Client for interacting with the SampleApp backend API
3
+ */
4
+ /**
5
+ * Extract container ID from a browser URL
6
+ * @param browserUrl - URL like "https://nextjs-a3fcd2bb-2a15-4f9b-bd13-aeac52baebd2.sampleapp.love/?_ts=1767897000670"
7
+ * @returns Container ID like "nextjs-a3fcd2bb-2a15-4f9b-bd13-aeac52baebd2" or null if not found
8
+ */
9
+ export function extractContainerIdFromUrl(browserUrl) {
10
+ try {
11
+ const url = new URL(browserUrl);
12
+ // Hostname is like "nextjs-a3fcd2bb-2a15-4f9b-bd13-aeac52baebd2.sampleapp.love"
13
+ const hostname = url.hostname;
14
+ // Split by the first dot to get the container ID
15
+ const parts = hostname.split(".");
16
+ if (parts.length >= 2) {
17
+ return parts[0]; // e.g., "nextjs-a3fcd2bb-2a15-4f9b-bd13-aeac52baebd2"
18
+ }
19
+ return null;
20
+ }
21
+ catch (_a) {
22
+ return null;
23
+ }
24
+ }
25
+ const getBaseUrl = () => {
26
+ return process.env.BASE_API_URL || "https://api.sampleapp.ai";
27
+ };
28
+ /**
29
+ * Main API client class
30
+ */
31
+ class ApiClient {
32
+ constructor(config) {
33
+ /**
34
+ * Sandbox content endpoints
35
+ */
36
+ this.sandboxContent = {
37
+ /**
38
+ * Get public sandbox content by UID
39
+ * @param sandboxContentUid - The UID of the sandbox content
40
+ * @returns The sandbox content data
41
+ */
42
+ getPublic: async (sandboxContentUid) => {
43
+ return this.request([
44
+ "sandbox-content",
45
+ sandboxContentUid,
46
+ "public",
47
+ ]);
48
+ },
49
+ /**
50
+ * Get all sandbox contents for a specific playground (public access with truncated fields)
51
+ * @param playgroundUid - The UID of the playground
52
+ * @param skip - Number of records to skip (default: 0)
53
+ * @param limit - Maximum number of records to return (default: 100)
54
+ * @returns Array of sandbox content data with only uid and markdown fields
55
+ */
56
+ getByPlayground: async (playgroundUid, skip = 0, limit = 100) => {
57
+ return this.request(["sandbox-content", "playground", playgroundUid, "public"], {
58
+ method: "GET",
59
+ }, false, // Public endpoint, no API key required
60
+ { skip, limit });
61
+ },
62
+ };
63
+ /**
64
+ * SDK endpoints
65
+ */
66
+ this.sdk = {
67
+ /**
68
+ * Start a sandbox
69
+ * @param request - The start sandbox request
70
+ * @returns The sandbox response with container URL
71
+ */
72
+ startSandbox: async (request) => {
73
+ return this.request(["sdk", "start-sandbox"], {
74
+ method: "POST",
75
+ body: JSON.stringify(request),
76
+ });
77
+ },
78
+ /**
79
+ * Get the download URL for a container's code
80
+ * @param containerId - The container ID (extracted from browserUrl)
81
+ * @returns The full URL to download the code
82
+ */
83
+ getDownloadCodeUrl: (containerId) => {
84
+ return `${this.baseUrl}/api/v1/sdk/download-code?container_id=${encodeURIComponent(containerId)}`;
85
+ },
86
+ /**
87
+ * Download code from a container
88
+ * @param containerId - The container ID (extracted from browserUrl)
89
+ * @returns Triggers a file download
90
+ */
91
+ downloadCode: (containerId) => {
92
+ const url = this.sdk.getDownloadCodeUrl(containerId);
93
+ window.open(url, "_blank");
94
+ },
95
+ };
96
+ const defaultBaseUrl = getBaseUrl();
97
+ this.baseUrl = defaultBaseUrl.replace(/\/$/, ""); // Remove trailing slash
98
+ this.apiKey = config.apiKey;
99
+ }
100
+ /**
101
+ * Makes a request to the API
102
+ */
103
+ async request(endpoint, options = {}, useApiKeyHeader = false, queryParams) {
104
+ let url = `${this.baseUrl}/api/v1/${endpoint.join("/")}`;
105
+ if (queryParams) {
106
+ const params = new URLSearchParams();
107
+ Object.entries(queryParams).forEach(([key, value]) => {
108
+ params.append(key, value.toString());
109
+ });
110
+ url += `?${params.toString()}`;
111
+ }
112
+ const headers = Object.assign({ "Content-Type": "application/json" }, options.headers);
113
+ if (this.apiKey) {
114
+ if (useApiKeyHeader) {
115
+ headers["x-api-key"] = this.apiKey;
116
+ }
117
+ else {
118
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
119
+ }
120
+ }
121
+ const response = await fetch(url, Object.assign(Object.assign({}, options), { headers }));
122
+ if (!response.ok) {
123
+ const errorText = await response.text();
124
+ throw new Error(`API request failed: ${response.status} ${response.statusText}. ${errorText}`);
125
+ }
126
+ return response.json();
127
+ }
128
+ }
129
+ /**
130
+ * Create an API client instance
131
+ * @param config - Configuration for the API client
132
+ * @returns An API client instance
133
+ */
134
+ export function createApiClient(config) {
135
+ return new ApiClient(config);
136
+ }
137
+ /**
138
+ * Default export for convenience
139
+ */
140
+ export default ApiClient;