sunpeak 0.9.8 → 0.9.12

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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const simulatorUrl = require("../simulator-url-BpCa95pE.cjs");
3
+ const simulatorUrl = require("../simulator-url-D4tFBjeu.cjs");
4
4
  exports.ChatGPTSimulator = simulatorUrl.ChatGPTSimulator;
5
5
  exports.IframeResource = simulatorUrl.IframeResource;
6
6
  exports.ThemeProvider = simulatorUrl.ThemeProvider;
@@ -1,4 +1,4 @@
1
- import { C, I, T, c, i, u } from "../simulator-url-q5tHLc4-.js";
1
+ import { C, I, T, c, i, u } from "../simulator-url-BZBcq5tc.js";
2
2
  export {
3
3
  C as ChatGPTSimulator,
4
4
  I as IframeResource,
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const simulatorUrl = require("./simulator-url-BpCa95pE.cjs");
3
+ const simulatorUrl = require("./simulator-url-D4tFBjeu.cjs");
4
4
  const React = require("react");
5
5
  const discovery = require("./discovery-a4WId9PC.cjs");
6
6
  function _interopNamespaceDefault(e) {
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a as clsx } from "./simulator-url-q5tHLc4-.js";
2
- import { C, I, S, T, c, v, s, q, i, r, w, t, e, f, g, h, j, u, k, l, m, n, d, b, o, p } from "./simulator-url-q5tHLc4-.js";
1
+ import { a as clsx } from "./simulator-url-BZBcq5tc.js";
2
+ import { C, I, S, T, c, v, s, q, i, r, w, t, e, f, g, h, j, u, k, l, m, n, d, b, o, p } from "./simulator-url-BZBcq5tc.js";
3
3
  import * as React from "react";
4
4
  import { i as i2, d as d2, h as h2, c as c2, b as b2, e as e2, a, f as f2, g as g2, t as t2 } from "./discovery-ft3cd2dW.js";
5
5
  const MOBILE_BREAKPOINT = 768;
@@ -7379,9 +7379,34 @@ const Segment = ({ children, ...restProps }) => {
7379
7379
  return jsx(Item2, { className: s.SegmentedControlOption, ...restProps, onPointerEnter: handlePressableMouseEnter, children: jsx("span", { className: "relative", children }) });
7380
7380
  };
7381
7381
  SegmentedControl.Option = Segment;
7382
+ const DEFAULT_SIDEBAR_WIDTH = 224;
7382
7383
  function SimpleSidebar({ children, controls }) {
7383
7384
  const [isDrawerOpen, setIsDrawerOpen] = React.useState(false);
7385
+ const [sidebarWidth, setSidebarWidth] = React.useState(DEFAULT_SIDEBAR_WIDTH);
7386
+ const [isResizing, setIsResizing] = React.useState(false);
7387
+ const handleMouseDown = React.useCallback((e) => {
7388
+ e.preventDefault();
7389
+ setIsResizing(true);
7390
+ }, []);
7391
+ React.useEffect(() => {
7392
+ if (!isResizing) return;
7393
+ const handleMouseMove = (e) => {
7394
+ const maxWidth = Math.floor(window.innerWidth / 3);
7395
+ const newWidth = Math.min(maxWidth, Math.max(DEFAULT_SIDEBAR_WIDTH, e.clientX));
7396
+ setSidebarWidth(newWidth);
7397
+ };
7398
+ const handleMouseUp = () => {
7399
+ setIsResizing(false);
7400
+ };
7401
+ document.addEventListener("mousemove", handleMouseMove);
7402
+ document.addEventListener("mouseup", handleMouseUp);
7403
+ return () => {
7404
+ document.removeEventListener("mousemove", handleMouseMove);
7405
+ document.removeEventListener("mouseup", handleMouseUp);
7406
+ };
7407
+ }, [isResizing]);
7384
7408
  return /* @__PURE__ */ jsxs("div", { className: "sunpeak-simulator-root flex h-screen w-full overflow-hidden relative", children: [
7409
+ isResizing && /* @__PURE__ */ jsx("div", { className: "fixed inset-0 z-50 cursor-col-resize" }),
7385
7410
  isDrawerOpen && /* @__PURE__ */ jsx(
7386
7411
  "div",
7387
7412
  {
@@ -7393,50 +7418,60 @@ function SimpleSidebar({ children, controls }) {
7393
7418
  }
7394
7419
  }
7395
7420
  ),
7396
- /* @__PURE__ */ jsx(
7421
+ /* @__PURE__ */ jsxs(
7397
7422
  "aside",
7398
7423
  {
7399
7424
  className: `
7400
- w-56 flex flex-col border-r border-subtle bg-sidebar
7401
- md:relative md:z-auto
7425
+ relative flex flex-col border-r border-subtle bg-sidebar
7426
+ md:z-auto
7402
7427
  max-md:fixed max-md:inset-y-0 max-md:left-0 max-md:z-[100]
7403
- max-md:transition-transform max-md:duration-300
7428
+ max-md:transition-transform max-md:duration-300 max-md:!w-2/3
7404
7429
  ${isDrawerOpen ? "max-md:translate-x-0" : "max-md:-translate-x-full"}
7405
7430
  `,
7406
- children: /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto min-h-0 px-3 pb-3 pt-0", children: /* @__PURE__ */ jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsxs("div", { children: [
7407
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between sticky top-0 bg-sidebar z-10 py-2", children: [
7408
- /* @__PURE__ */ jsx("h2", { className: "text-xs font-semibold", children: "Controls" }),
7409
- /* @__PURE__ */ jsx(
7410
- "button",
7411
- {
7412
- onClick: () => setIsDrawerOpen(false),
7413
- className: "md:hidden text-secondary hover:text-primary transition-colors p-1",
7414
- type: "button",
7415
- "aria-label": "Close sidebar",
7416
- children: /* @__PURE__ */ jsx(
7417
- "svg",
7418
- {
7419
- width: "16",
7420
- height: "16",
7421
- viewBox: "0 0 16 16",
7422
- fill: "none",
7423
- xmlns: "http://www.w3.org/2000/svg",
7424
- children: /* @__PURE__ */ jsx(
7425
- "path",
7426
- {
7427
- d: "M12 4L4 12M4 4L12 12",
7428
- stroke: "currentColor",
7429
- strokeWidth: "2",
7430
- strokeLinecap: "round"
7431
- }
7432
- )
7433
- }
7434
- )
7435
- }
7436
- )
7437
- ] }),
7438
- controls
7439
- ] }) }) })
7431
+ style: { width: sidebarWidth },
7432
+ children: [
7433
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto min-h-0 px-3 pb-3 pt-0", children: /* @__PURE__ */ jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsxs("div", { children: [
7434
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between sticky top-0 bg-sidebar z-10 py-2", children: [
7435
+ /* @__PURE__ */ jsx("h2", { className: "text-xs font-semibold", children: "Controls" }),
7436
+ /* @__PURE__ */ jsx(
7437
+ "button",
7438
+ {
7439
+ onClick: () => setIsDrawerOpen(false),
7440
+ className: "md:hidden text-secondary hover:text-primary transition-colors p-1",
7441
+ type: "button",
7442
+ "aria-label": "Close sidebar",
7443
+ children: /* @__PURE__ */ jsx(
7444
+ "svg",
7445
+ {
7446
+ width: "16",
7447
+ height: "16",
7448
+ viewBox: "0 0 16 16",
7449
+ fill: "none",
7450
+ xmlns: "http://www.w3.org/2000/svg",
7451
+ children: /* @__PURE__ */ jsx(
7452
+ "path",
7453
+ {
7454
+ d: "M12 4L4 12M4 4L12 12",
7455
+ stroke: "currentColor",
7456
+ strokeWidth: "2",
7457
+ strokeLinecap: "round"
7458
+ }
7459
+ )
7460
+ }
7461
+ )
7462
+ }
7463
+ )
7464
+ ] }),
7465
+ controls
7466
+ ] }) }) }),
7467
+ /* @__PURE__ */ jsx(
7468
+ "div",
7469
+ {
7470
+ onMouseDown: handleMouseDown,
7471
+ className: "hidden md:block absolute top-0 right-0 w-1 h-full cursor-col-resize hover:bg-primary/20 active:bg-primary/30 transition-colors"
7472
+ }
7473
+ )
7474
+ ]
7440
7475
  }
7441
7476
  ),
7442
7477
  /* @__PURE__ */ jsxs("main", { className: "flex-1 overflow-auto relative", children: [
@@ -7546,7 +7581,7 @@ function SidebarTextarea({
7546
7581
  placeholder,
7547
7582
  rows,
7548
7583
  size: "2xs",
7549
- className: "text-[10px] font-mono resize-y",
7584
+ className: "text-[10px] font-mono resize-y [&>textarea]:!h-full [&>textarea]:!max-h-none [&>textarea]:!min-h-0",
7550
7585
  style: { whiteSpace: "pre", overflowX: "auto", overflowWrap: "normal" },
7551
7586
  invalid: !!error
7552
7587
  }
@@ -7574,14 +7609,14 @@ const SCREEN_WIDTHS = {
7574
7609
  full: 1024
7575
7610
  };
7576
7611
  const ALLOWED_SCRIPT_ORIGINS = [
7577
- "https://sandbox.sunpeakai.com",
7612
+ "https://sunpeak-prod-app-storage.s3.us-east-2.amazonaws.com",
7578
7613
  "http://localhost",
7579
7614
  "https://localhost",
7580
7615
  "http://127.0.0.1",
7581
7616
  "https://127.0.0.1"
7582
7617
  ];
7583
7618
  const ALLOWED_PARENT_ORIGINS = [
7584
- "https://app.sunpeak.ai",
7619
+ "https://sandbox.sunpeakai.com",
7585
7620
  "http://localhost",
7586
7621
  "https://localhost",
7587
7622
  "http://127.0.0.1",
@@ -8114,31 +8149,24 @@ function IframeResource({ scriptSrc, className, style, csp }) {
8114
8149
  sendUpdate("openai:update");
8115
8150
  }, [sendUpdate]);
8116
8151
  const isValidScriptSrc = useMemo(() => isAllowedScriptSrc(scriptSrc), [scriptSrc]);
8117
- const blobUrl = useMemo(() => {
8152
+ const htmlContent = useMemo(() => {
8118
8153
  if (!isValidScriptSrc) {
8119
8154
  console.error("[IframeResource] Script source not allowed:", scriptSrc);
8120
- const errorHtml = `<!DOCTYPE html><html><body><h1>Error</h1><p>Script source not allowed.</p></body></html>`;
8121
- const blob2 = new Blob([errorHtml], { type: "text/html" });
8122
- return URL.createObjectURL(blob2);
8155
+ return `<!DOCTYPE html><html><body><h1>Error</h1><p>Script source not allowed.</p></body></html>`;
8123
8156
  }
8124
8157
  const absoluteScriptSrc = scriptSrc.startsWith("/") ? `${window.location.origin}${scriptSrc}` : scriptSrc;
8125
8158
  const cspPolicy = generateCSP(csp, absoluteScriptSrc);
8126
8159
  const bridgeScript = generateBridgeScript(ALLOWED_PARENT_ORIGINS);
8127
- const html = injectBridgeScript(
8160
+ return injectBridgeScript(
8128
8161
  generateScriptHtml(absoluteScriptSrc, theme ?? "dark", cspPolicy),
8129
8162
  bridgeScript
8130
8163
  );
8131
- const blob = new Blob([html], { type: "text/html" });
8132
- return URL.createObjectURL(blob);
8133
8164
  }, [scriptSrc, theme, isValidScriptSrc, csp]);
8134
- useEffect(() => {
8135
- return () => URL.revokeObjectURL(blobUrl);
8136
- }, [blobUrl]);
8137
8165
  return /* @__PURE__ */ jsx(
8138
8166
  "iframe",
8139
8167
  {
8140
8168
  ref: iframeRef,
8141
- src: blobUrl,
8169
+ srcDoc: htmlContent,
8142
8170
  className,
8143
8171
  style: {
8144
8172
  border: "none",
@@ -8150,8 +8178,8 @@ function IframeResource({ scriptSrc, className, style, csp }) {
8150
8178
  ...style
8151
8179
  },
8152
8180
  title: "Resource Preview",
8153
- sandbox: "allow-scripts",
8154
- allow: "accelerometer 'none'; autoplay 'none'; camera 'none'; display-capture 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; payment 'none'; publickey-credentials-get 'none'; usb 'none'; xr-spatial-tracking 'none'"
8181
+ sandbox: "allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox",
8182
+ allow: "local-network-access *; microphone *; midi *; accelerometer 'none'; autoplay 'none'; camera 'none'; display-capture 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; payment 'none'; publickey-credentials-get 'none'; usb 'none'; xr-spatial-tracking 'none'"
8155
8183
  }
8156
8184
  );
8157
8185
  }
@@ -9151,4 +9179,4 @@ export {
9151
9179
  getAPI as v,
9152
9180
  resetProviderCache as w
9153
9181
  };
9154
- //# sourceMappingURL=simulator-url-q5tHLc4-.js.map
9182
+ //# sourceMappingURL=simulator-url-BZBcq5tc.js.map