sunpeak 0.9.6 → 0.9.10

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.
@@ -57,19 +57,38 @@ class OpenAiProvider {
57
57
  };
58
58
  }
59
59
  getAPI() {
60
- var _a2, _b2, _c, _d, _e, _f, _g;
61
60
  if (typeof window === "undefined" || !window.openai) {
62
61
  return null;
63
62
  }
64
- const api = window.openai;
65
63
  return {
66
- callTool: (_a2 = api.callTool) == null ? void 0 : _a2.bind(api),
67
- sendFollowUpMessage: (_b2 = api.sendFollowUpMessage) == null ? void 0 : _b2.bind(api),
68
- openExternal: (_c = api.openExternal) == null ? void 0 : _c.bind(api),
69
- requestDisplayMode: (_d = api.requestDisplayMode) == null ? void 0 : _d.bind(api),
70
- requestModal: (_e = api.requestModal) == null ? void 0 : _e.bind(api),
71
- notifyIntrinsicHeight: (_f = api.notifyIntrinsicHeight) == null ? void 0 : _f.bind(api),
72
- setWidgetState: (_g = api.setWidgetState) == null ? void 0 : _g.bind(api)
64
+ callTool: (...args) => {
65
+ var _a2, _b2;
66
+ return (_b2 = (_a2 = window.openai) == null ? void 0 : _a2.callTool) == null ? void 0 : _b2.call(_a2, ...args);
67
+ },
68
+ sendFollowUpMessage: (...args) => {
69
+ var _a2, _b2;
70
+ return (_b2 = (_a2 = window.openai) == null ? void 0 : _a2.sendFollowUpMessage) == null ? void 0 : _b2.call(_a2, ...args);
71
+ },
72
+ openExternal: (...args) => {
73
+ var _a2, _b2;
74
+ return (_b2 = (_a2 = window.openai) == null ? void 0 : _a2.openExternal) == null ? void 0 : _b2.call(_a2, ...args);
75
+ },
76
+ requestDisplayMode: (...args) => {
77
+ var _a2, _b2;
78
+ return (_b2 = (_a2 = window.openai) == null ? void 0 : _a2.requestDisplayMode) == null ? void 0 : _b2.call(_a2, ...args);
79
+ },
80
+ requestModal: (...args) => {
81
+ var _a2, _b2;
82
+ return (_b2 = (_a2 = window.openai) == null ? void 0 : _a2.requestModal) == null ? void 0 : _b2.call(_a2, ...args);
83
+ },
84
+ notifyIntrinsicHeight: (...args) => {
85
+ var _a2, _b2;
86
+ return (_b2 = (_a2 = window.openai) == null ? void 0 : _a2.notifyIntrinsicHeight) == null ? void 0 : _b2.call(_a2, ...args);
87
+ },
88
+ setWidgetState: (...args) => {
89
+ var _a2, _b2;
90
+ return (_b2 = (_a2 = window.openai) == null ? void 0 : _a2.setWidgetState) == null ? void 0 : _b2.call(_a2, ...args);
91
+ }
73
92
  };
74
93
  }
75
94
  }
@@ -172,8 +191,17 @@ function useWidgetState(defaultState) {
172
191
  }
173
192
  return typeof defaultState === "function" ? defaultState() : defaultState ?? null;
174
193
  });
194
+ const hasSentInitialState = React.useRef(false);
175
195
  React.useEffect(() => {
176
- _setWidgetState(widgetStateFromProvider);
196
+ if (!hasSentInitialState.current && widgetStateFromProvider == null && widgetState != null && (api == null ? void 0 : api.setWidgetState)) {
197
+ hasSentInitialState.current = true;
198
+ api.setWidgetState(widgetState);
199
+ }
200
+ }, [api, widgetState, widgetStateFromProvider]);
201
+ React.useEffect(() => {
202
+ if (widgetStateFromProvider != null) {
203
+ _setWidgetState(widgetStateFromProvider);
204
+ }
177
205
  }, [widgetStateFromProvider]);
178
206
  const setWidgetState = React.useCallback(
179
207
  (state) => {
@@ -5625,7 +5653,7 @@ const useEscCloseStack = (listening, cb) => {
5625
5653
  }, [id, listening, latestCallback]);
5626
5654
  };
5627
5655
  const __vite_import_meta_env__ = { "DEV": false, "MODE": "production" };
5628
- const META_ENV = typeof { url: typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("simulator-url-BStCoFTv.cjs", document.baseURI).href } !== "undefined" ? __vite_import_meta_env__ : void 0;
5656
+ const META_ENV = typeof { url: typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("simulator-url-oevkxbU4.cjs", document.baseURI).href } !== "undefined" ? __vite_import_meta_env__ : void 0;
5629
5657
  const NODE_ENV = typeof process !== "undefined" && ((_a = process.env) == null ? void 0 : _a.NODE_ENV) ? (_b = process.env) == null ? void 0 : _b.NODE_ENV : "production";
5630
5658
  const isDev = NODE_ENV === "development" || !!(META_ENV == null ? void 0 : META_ENV.DEV);
5631
5659
  const isJSDomLike = typeof navigator !== "undefined" && /(jsdom|happy-dom)/i.test(navigator.userAgent) || typeof globalThis.happyDOM === "object";
@@ -7369,9 +7397,34 @@ const Segment = ({ children, ...restProps }) => {
7369
7397
  return jsxRuntime.jsx(Item2, { className: s.SegmentedControlOption, ...restProps, onPointerEnter: handlePressableMouseEnter, children: jsxRuntime.jsx("span", { className: "relative", children }) });
7370
7398
  };
7371
7399
  SegmentedControl.Option = Segment;
7400
+ const DEFAULT_SIDEBAR_WIDTH = 224;
7372
7401
  function SimpleSidebar({ children, controls }) {
7373
7402
  const [isDrawerOpen, setIsDrawerOpen] = React__namespace.useState(false);
7403
+ const [sidebarWidth, setSidebarWidth] = React__namespace.useState(DEFAULT_SIDEBAR_WIDTH);
7404
+ const [isResizing, setIsResizing] = React__namespace.useState(false);
7405
+ const handleMouseDown = React__namespace.useCallback((e) => {
7406
+ e.preventDefault();
7407
+ setIsResizing(true);
7408
+ }, []);
7409
+ React__namespace.useEffect(() => {
7410
+ if (!isResizing) return;
7411
+ const handleMouseMove = (e) => {
7412
+ const maxWidth = Math.floor(window.innerWidth / 3);
7413
+ const newWidth = Math.min(maxWidth, Math.max(DEFAULT_SIDEBAR_WIDTH, e.clientX));
7414
+ setSidebarWidth(newWidth);
7415
+ };
7416
+ const handleMouseUp = () => {
7417
+ setIsResizing(false);
7418
+ };
7419
+ document.addEventListener("mousemove", handleMouseMove);
7420
+ document.addEventListener("mouseup", handleMouseUp);
7421
+ return () => {
7422
+ document.removeEventListener("mousemove", handleMouseMove);
7423
+ document.removeEventListener("mouseup", handleMouseUp);
7424
+ };
7425
+ }, [isResizing]);
7374
7426
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sunpeak-simulator-root flex h-screen w-full overflow-hidden relative", children: [
7427
+ isResizing && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed inset-0 z-50 cursor-col-resize" }),
7375
7428
  isDrawerOpen && /* @__PURE__ */ jsxRuntime.jsx(
7376
7429
  "div",
7377
7430
  {
@@ -7383,50 +7436,60 @@ function SimpleSidebar({ children, controls }) {
7383
7436
  }
7384
7437
  }
7385
7438
  ),
7386
- /* @__PURE__ */ jsxRuntime.jsx(
7439
+ /* @__PURE__ */ jsxRuntime.jsxs(
7387
7440
  "aside",
7388
7441
  {
7389
7442
  className: `
7390
- w-56 flex flex-col border-r border-subtle bg-sidebar
7391
- md:relative md:z-auto
7443
+ relative flex flex-col border-r border-subtle bg-sidebar
7444
+ md:z-auto
7392
7445
  max-md:fixed max-md:inset-y-0 max-md:left-0 max-md:z-[100]
7393
- max-md:transition-transform max-md:duration-300
7446
+ max-md:transition-transform max-md:duration-300 max-md:!w-2/3
7394
7447
  ${isDrawerOpen ? "max-md:translate-x-0" : "max-md:-translate-x-full"}
7395
7448
  `,
7396
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-y-auto min-h-0 px-3 pb-3 pt-0", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
7397
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between sticky top-0 bg-sidebar z-10 py-2", children: [
7398
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-xs font-semibold", children: "Controls" }),
7399
- /* @__PURE__ */ jsxRuntime.jsx(
7400
- "button",
7401
- {
7402
- onClick: () => setIsDrawerOpen(false),
7403
- className: "md:hidden text-secondary hover:text-primary transition-colors p-1",
7404
- type: "button",
7405
- "aria-label": "Close sidebar",
7406
- children: /* @__PURE__ */ jsxRuntime.jsx(
7407
- "svg",
7408
- {
7409
- width: "16",
7410
- height: "16",
7411
- viewBox: "0 0 16 16",
7412
- fill: "none",
7413
- xmlns: "http://www.w3.org/2000/svg",
7414
- children: /* @__PURE__ */ jsxRuntime.jsx(
7415
- "path",
7416
- {
7417
- d: "M12 4L4 12M4 4L12 12",
7418
- stroke: "currentColor",
7419
- strokeWidth: "2",
7420
- strokeLinecap: "round"
7421
- }
7422
- )
7423
- }
7424
- )
7425
- }
7426
- )
7427
- ] }),
7428
- controls
7429
- ] }) }) })
7449
+ style: { width: sidebarWidth },
7450
+ children: [
7451
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-y-auto min-h-0 px-3 pb-3 pt-0", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
7452
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between sticky top-0 bg-sidebar z-10 py-2", children: [
7453
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-xs font-semibold", children: "Controls" }),
7454
+ /* @__PURE__ */ jsxRuntime.jsx(
7455
+ "button",
7456
+ {
7457
+ onClick: () => setIsDrawerOpen(false),
7458
+ className: "md:hidden text-secondary hover:text-primary transition-colors p-1",
7459
+ type: "button",
7460
+ "aria-label": "Close sidebar",
7461
+ children: /* @__PURE__ */ jsxRuntime.jsx(
7462
+ "svg",
7463
+ {
7464
+ width: "16",
7465
+ height: "16",
7466
+ viewBox: "0 0 16 16",
7467
+ fill: "none",
7468
+ xmlns: "http://www.w3.org/2000/svg",
7469
+ children: /* @__PURE__ */ jsxRuntime.jsx(
7470
+ "path",
7471
+ {
7472
+ d: "M12 4L4 12M4 4L12 12",
7473
+ stroke: "currentColor",
7474
+ strokeWidth: "2",
7475
+ strokeLinecap: "round"
7476
+ }
7477
+ )
7478
+ }
7479
+ )
7480
+ }
7481
+ )
7482
+ ] }),
7483
+ controls
7484
+ ] }) }) }),
7485
+ /* @__PURE__ */ jsxRuntime.jsx(
7486
+ "div",
7487
+ {
7488
+ onMouseDown: handleMouseDown,
7489
+ 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"
7490
+ }
7491
+ )
7492
+ ]
7430
7493
  }
7431
7494
  ),
7432
7495
  /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "flex-1 overflow-auto relative", children: [
@@ -7520,9 +7583,11 @@ function SidebarTextarea({
7520
7583
  onFocus,
7521
7584
  onBlur,
7522
7585
  placeholder,
7523
- rows = 2,
7586
+ maxRows = 8,
7524
7587
  error
7525
7588
  }) {
7589
+ const contentRows = (value == null ? void 0 : value.split("\n").length) ?? 1;
7590
+ const rows = Math.min(contentRows, maxRows);
7526
7591
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5", children: [
7527
7592
  /* @__PURE__ */ jsxRuntime.jsx(
7528
7593
  Textarea,
@@ -7534,7 +7599,8 @@ function SidebarTextarea({
7534
7599
  placeholder,
7535
7600
  rows,
7536
7601
  size: "2xs",
7537
- className: "text-[10px] font-mono",
7602
+ className: "text-[10px] font-mono resize-y [&>textarea]:!h-full [&>textarea]:!max-h-none [&>textarea]:!min-h-0",
7603
+ style: { whiteSpace: "pre", overflowX: "auto", overflowWrap: "normal" },
7538
7604
  invalid: !!error
7539
7605
  }
7540
7606
  ),
@@ -8376,8 +8442,8 @@ class MockOpenAI {
8376
8442
  console.log("Mock notifyIntrinsicHeight:", height);
8377
8443
  }
8378
8444
  async setWidgetState(state) {
8379
- this.widgetState = state;
8380
- this.emitUpdate({ widgetState: state });
8445
+ this.widgetState = { ...this.widgetState, ...state };
8446
+ this.emitUpdate({ widgetState: this.widgetState });
8381
8447
  }
8382
8448
  setTheme(theme) {
8383
8449
  this.theme = theme;
@@ -8588,11 +8654,17 @@ function ChatGPTSimulator({
8588
8654
  // eslint-disable-next-line react-hooks/exhaustive-deps -- only initialize once
8589
8655
  []
8590
8656
  );
8657
+ if (typeof window !== "undefined") {
8658
+ window.openai = mock;
8659
+ resetProviderCache();
8660
+ }
8591
8661
  React.useEffect(() => {
8592
8662
  var _a2, _b2;
8593
8663
  if (selectedSim) {
8594
8664
  mock.toolInput = ((_a2 = selectedSim.callToolRequestParams) == null ? void 0 : _a2.arguments) ?? {};
8595
- mock.widgetState = selectedSim.widgetState ?? null;
8665
+ if (selectedSim.widgetState !== void 0) {
8666
+ mock.setWidgetStateExternal(selectedSim.widgetState);
8667
+ }
8596
8668
  mock.toolOutput = ((_b2 = selectedSim.callToolResult) == null ? void 0 : _b2.structuredContent) ?? null;
8597
8669
  }
8598
8670
  }, [selectedSimulationName, selectedSim, mock]);
@@ -8604,7 +8676,7 @@ function ChatGPTSimulator({
8604
8676
  const safeArea = useSafeArea();
8605
8677
  const view = useView();
8606
8678
  const toolInput = useToolInput();
8607
- const [widgetState] = useWidgetState();
8679
+ const widgetState = useWidgetGlobal("widgetState");
8608
8680
  const toolResponseMetadata = useToolResponseMetadata();
8609
8681
  const toolOutput = useWidgetProps();
8610
8682
  const [toolInputJson, setToolInputJson] = React.useState(
@@ -8628,12 +8700,6 @@ function ChatGPTSimulator({
8628
8700
  const [toolResponseMetadataError, setToolResponseMetadataError] = React.useState("");
8629
8701
  const [widgetStateError, setWidgetStateError] = React.useState("");
8630
8702
  const [viewParamsError, setViewParamsError] = React.useState("");
8631
- React.useLayoutEffect(() => {
8632
- if (mock && typeof window !== "undefined") {
8633
- window.openai = mock;
8634
- resetProviderCache();
8635
- }
8636
- }, [mock]);
8637
8703
  React.useEffect(() => {
8638
8704
  if (mock) {
8639
8705
  mock.emitUpdate({
@@ -8722,11 +8788,15 @@ function ChatGPTSimulator({
8722
8788
  SimpleSidebar,
8723
8789
  {
8724
8790
  controls: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
8725
- simulationNames.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "Simulation", children: /* @__PURE__ */ jsxRuntime.jsx(
8791
+ simulationNames.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "Simulation", children: /* @__PURE__ */ jsxRuntime.jsx(
8726
8792
  SidebarSelect,
8727
8793
  {
8728
8794
  value: selectedSimulationName,
8729
- onChange: (value) => setSelectedSimulationName(value),
8795
+ onChange: (value) => {
8796
+ const newSim = simulations[value];
8797
+ mock.setWidgetStateExternal((newSim == null ? void 0 : newSim.widgetState) ?? null);
8798
+ setSelectedSimulationName(value);
8799
+ },
8730
8800
  options: simulationNames.map((name) => {
8731
8801
  const sim = simulations[name];
8732
8802
  const resourceTitle = sim.resource.title || sim.resource.name;
@@ -8751,237 +8821,254 @@ function ChatGPTSimulator({
8751
8821
  ]
8752
8822
  }
8753
8823
  ) }),
8754
- /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "Theme", children: /* @__PURE__ */ jsxRuntime.jsx(
8755
- SidebarToggle,
8756
- {
8757
- value: theme,
8758
- onChange: (value) => mock.setTheme(value),
8759
- options: [
8760
- { value: "light", label: "Light" },
8761
- { value: "dark", label: "Dark" }
8762
- ]
8763
- }
8764
- ) }),
8765
- /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "Display Mode", children: /* @__PURE__ */ jsxRuntime.jsx(
8766
- SidebarToggle,
8767
- {
8768
- value: displayMode,
8769
- onChange: (value) => {
8770
- const newMode = value;
8771
- if (isMobileWidth(screenWidth) && newMode === "pip") {
8772
- mock.setDisplayMode("fullscreen");
8773
- } else {
8774
- mock.setDisplayMode(newMode);
8775
- }
8776
- },
8777
- options: [
8778
- { value: "inline", label: "Inline" },
8779
- { value: "pip", label: "PiP" },
8780
- { value: "fullscreen", label: "Full" }
8781
- ]
8782
- }
8783
- ) }),
8784
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
8785
- /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "Locale", children: /* @__PURE__ */ jsxRuntime.jsx(
8786
- SidebarInput,
8824
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarCollapsibleControl, { label: "Runtime Globals", defaultCollapsed: false, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
8825
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "Theme", children: /* @__PURE__ */ jsxRuntime.jsx(
8826
+ SidebarToggle,
8787
8827
  {
8788
- value: locale,
8789
- onChange: (value) => mock.setLocale(value),
8790
- placeholder: "e.g. en-US"
8828
+ value: theme,
8829
+ onChange: (value) => mock.setTheme(value),
8830
+ options: [
8831
+ { value: "light", label: "Light" },
8832
+ { value: "dark", label: "Dark" }
8833
+ ]
8791
8834
  }
8792
8835
  ) }),
8793
- /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "Max Height (PiP)", children: /* @__PURE__ */ jsxRuntime.jsx(
8794
- SidebarInput,
8836
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "Display Mode", children: /* @__PURE__ */ jsxRuntime.jsx(
8837
+ SidebarToggle,
8795
8838
  {
8796
- type: "number",
8797
- value: displayMode === "pip" && maxHeight !== void 0 ? String(maxHeight) : "",
8839
+ value: displayMode,
8798
8840
  onChange: (value) => {
8799
- if (displayMode === "pip") {
8800
- mock.setMaxHeight(value ? Number(value) : 480);
8841
+ const newMode = value;
8842
+ if (isMobileWidth(screenWidth) && newMode === "pip") {
8843
+ mock.setDisplayMode("fullscreen");
8844
+ } else {
8845
+ mock.setDisplayMode(newMode);
8801
8846
  }
8802
8847
  },
8803
- placeholder: displayMode === "pip" ? "480" : "-",
8804
- disabled: displayMode !== "pip"
8805
- }
8806
- ) })
8807
- ] }),
8808
- /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "User Agent - Device", children: /* @__PURE__ */ jsxRuntime.jsx(
8809
- SidebarSelect,
8810
- {
8811
- value: (userAgent == null ? void 0 : userAgent.device.type) ?? "desktop",
8812
- onChange: (value) => {
8813
- const deviceType = value;
8814
- let capabilities;
8815
- switch (deviceType) {
8816
- case "mobile":
8817
- capabilities = { hover: false, touch: true };
8818
- break;
8819
- case "tablet":
8820
- capabilities = { hover: false, touch: true };
8821
- break;
8822
- case "desktop":
8823
- capabilities = { hover: true, touch: false };
8824
- break;
8825
- case "unknown":
8826
- default:
8827
- capabilities = { hover: true, touch: false };
8828
- break;
8829
- }
8830
- mock.setUserAgent({
8831
- ...userAgent,
8832
- device: { type: deviceType },
8833
- capabilities
8834
- });
8835
- },
8836
- options: [
8837
- { value: "mobile", label: "Mobile" },
8838
- { value: "tablet", label: "Tablet" },
8839
- { value: "desktop", label: "Desktop" },
8840
- { value: "unknown", label: "Unknown" }
8841
- ]
8842
- }
8843
- ) }),
8844
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pl-4", children: /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "Capabilities", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
8845
- /* @__PURE__ */ jsxRuntime.jsx(
8846
- SidebarCheckbox,
8847
- {
8848
- checked: (userAgent == null ? void 0 : userAgent.capabilities.hover) ?? true,
8849
- onChange: (checked) => mock.setUserAgent({
8850
- ...userAgent,
8851
- device: (userAgent == null ? void 0 : userAgent.device) ?? { type: "desktop" },
8852
- capabilities: {
8853
- hover: checked,
8854
- touch: (userAgent == null ? void 0 : userAgent.capabilities.touch) ?? false
8855
- }
8856
- }),
8857
- label: "Hover"
8858
- }
8859
- ),
8860
- /* @__PURE__ */ jsxRuntime.jsx(
8861
- SidebarCheckbox,
8862
- {
8863
- checked: (userAgent == null ? void 0 : userAgent.capabilities.touch) ?? false,
8864
- onChange: (checked) => mock.setUserAgent({
8865
- ...userAgent,
8866
- device: (userAgent == null ? void 0 : userAgent.device) ?? { type: "desktop" },
8867
- capabilities: {
8868
- hover: (userAgent == null ? void 0 : userAgent.capabilities.hover) ?? true,
8869
- touch: checked
8870
- }
8871
- }),
8872
- label: "Touch"
8848
+ options: [
8849
+ { value: "inline", label: "Inline" },
8850
+ { value: "pip", label: "PiP" },
8851
+ { value: "fullscreen", label: "Full" }
8852
+ ]
8873
8853
  }
8874
- )
8875
- ] }) }) }),
8876
- /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "Safe Area Insets", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-1", children: [
8877
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5", children: [
8878
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-[9px] text-secondary", children: "Top" }),
8879
- /* @__PURE__ */ jsxRuntime.jsx(
8854
+ ) }),
8855
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
8856
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "Locale", children: /* @__PURE__ */ jsxRuntime.jsx(
8880
8857
  SidebarInput,
8881
8858
  {
8882
- type: "number",
8883
- value: String((safeArea == null ? void 0 : safeArea.insets.top) ?? 0),
8884
- onChange: (value) => mock.setSafeArea({
8885
- insets: {
8886
- ...safeArea == null ? void 0 : safeArea.insets,
8887
- top: Number(value),
8888
- bottom: (safeArea == null ? void 0 : safeArea.insets.bottom) ?? 0,
8889
- left: (safeArea == null ? void 0 : safeArea.insets.left) ?? 0,
8890
- right: (safeArea == null ? void 0 : safeArea.insets.right) ?? 0
8891
- }
8892
- })
8859
+ value: locale,
8860
+ onChange: (value) => mock.setLocale(value),
8861
+ placeholder: "e.g. en-US"
8893
8862
  }
8894
- )
8895
- ] }),
8896
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5", children: [
8897
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-[9px] text-secondary", children: "Bottom" }),
8898
- /* @__PURE__ */ jsxRuntime.jsx(
8863
+ ) }),
8864
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "Max Height (PiP)", children: /* @__PURE__ */ jsxRuntime.jsx(
8899
8865
  SidebarInput,
8900
8866
  {
8901
8867
  type: "number",
8902
- value: String((safeArea == null ? void 0 : safeArea.insets.bottom) ?? 0),
8903
- onChange: (value) => mock.setSafeArea({
8904
- insets: {
8905
- ...safeArea == null ? void 0 : safeArea.insets,
8906
- top: (safeArea == null ? void 0 : safeArea.insets.top) ?? 0,
8907
- bottom: Number(value),
8908
- left: (safeArea == null ? void 0 : safeArea.insets.left) ?? 0,
8909
- right: (safeArea == null ? void 0 : safeArea.insets.right) ?? 0
8868
+ value: displayMode === "pip" && maxHeight !== void 0 ? String(maxHeight) : "",
8869
+ onChange: (value) => {
8870
+ if (displayMode === "pip") {
8871
+ mock.setMaxHeight(value ? Number(value) : 480);
8910
8872
  }
8911
- })
8873
+ },
8874
+ placeholder: displayMode === "pip" ? "480" : "-",
8875
+ disabled: displayMode !== "pip"
8912
8876
  }
8913
- )
8877
+ ) })
8914
8878
  ] }),
8915
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5", children: [
8916
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-[9px] text-secondary", children: "Left" }),
8879
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "User Agent - Device", children: /* @__PURE__ */ jsxRuntime.jsx(
8880
+ SidebarSelect,
8881
+ {
8882
+ value: (userAgent == null ? void 0 : userAgent.device.type) ?? "desktop",
8883
+ onChange: (value) => {
8884
+ const deviceType = value;
8885
+ let capabilities;
8886
+ switch (deviceType) {
8887
+ case "mobile":
8888
+ capabilities = { hover: false, touch: true };
8889
+ break;
8890
+ case "tablet":
8891
+ capabilities = { hover: false, touch: true };
8892
+ break;
8893
+ case "desktop":
8894
+ capabilities = { hover: true, touch: false };
8895
+ break;
8896
+ case "unknown":
8897
+ default:
8898
+ capabilities = { hover: true, touch: false };
8899
+ break;
8900
+ }
8901
+ mock.setUserAgent({
8902
+ ...userAgent,
8903
+ device: { type: deviceType },
8904
+ capabilities
8905
+ });
8906
+ },
8907
+ options: [
8908
+ { value: "mobile", label: "Mobile" },
8909
+ { value: "tablet", label: "Tablet" },
8910
+ { value: "desktop", label: "Desktop" },
8911
+ { value: "unknown", label: "Unknown" }
8912
+ ]
8913
+ }
8914
+ ) }),
8915
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pl-4", children: /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "Capabilities", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
8917
8916
  /* @__PURE__ */ jsxRuntime.jsx(
8918
- SidebarInput,
8917
+ SidebarCheckbox,
8919
8918
  {
8920
- type: "number",
8921
- value: String((safeArea == null ? void 0 : safeArea.insets.left) ?? 0),
8922
- onChange: (value) => mock.setSafeArea({
8923
- insets: {
8924
- ...safeArea == null ? void 0 : safeArea.insets,
8925
- top: (safeArea == null ? void 0 : safeArea.insets.top) ?? 0,
8926
- bottom: (safeArea == null ? void 0 : safeArea.insets.bottom) ?? 0,
8927
- left: Number(value),
8928
- right: (safeArea == null ? void 0 : safeArea.insets.right) ?? 0
8919
+ checked: (userAgent == null ? void 0 : userAgent.capabilities.hover) ?? true,
8920
+ onChange: (checked) => mock.setUserAgent({
8921
+ ...userAgent,
8922
+ device: (userAgent == null ? void 0 : userAgent.device) ?? { type: "desktop" },
8923
+ capabilities: {
8924
+ hover: checked,
8925
+ touch: (userAgent == null ? void 0 : userAgent.capabilities.touch) ?? false
8929
8926
  }
8930
- })
8927
+ }),
8928
+ label: "Hover"
8931
8929
  }
8932
- )
8933
- ] }),
8934
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5", children: [
8935
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-[9px] text-secondary", children: "Right" }),
8930
+ ),
8936
8931
  /* @__PURE__ */ jsxRuntime.jsx(
8937
- SidebarInput,
8932
+ SidebarCheckbox,
8938
8933
  {
8939
- type: "number",
8940
- value: String((safeArea == null ? void 0 : safeArea.insets.right) ?? 0),
8941
- onChange: (value) => mock.setSafeArea({
8942
- insets: {
8943
- ...safeArea == null ? void 0 : safeArea.insets,
8944
- top: (safeArea == null ? void 0 : safeArea.insets.top) ?? 0,
8945
- bottom: (safeArea == null ? void 0 : safeArea.insets.bottom) ?? 0,
8946
- left: (safeArea == null ? void 0 : safeArea.insets.left) ?? 0,
8947
- right: Number(value)
8934
+ checked: (userAgent == null ? void 0 : userAgent.capabilities.touch) ?? false,
8935
+ onChange: (checked) => mock.setUserAgent({
8936
+ ...userAgent,
8937
+ device: (userAgent == null ? void 0 : userAgent.device) ?? { type: "desktop" },
8938
+ capabilities: {
8939
+ hover: (userAgent == null ? void 0 : userAgent.capabilities.hover) ?? true,
8940
+ touch: checked
8948
8941
  }
8949
- })
8942
+ }),
8943
+ label: "Touch"
8950
8944
  }
8951
8945
  )
8952
- ] })
8946
+ ] }) }) }),
8947
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "Safe Area Insets", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-4 gap-1", children: [
8948
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-0.5", children: [
8949
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-secondary", children: "↑" }),
8950
+ /* @__PURE__ */ jsxRuntime.jsx(
8951
+ SidebarInput,
8952
+ {
8953
+ type: "number",
8954
+ value: String((safeArea == null ? void 0 : safeArea.insets.top) ?? 0),
8955
+ onChange: (value) => mock.setSafeArea({
8956
+ insets: {
8957
+ ...safeArea == null ? void 0 : safeArea.insets,
8958
+ top: Number(value),
8959
+ bottom: (safeArea == null ? void 0 : safeArea.insets.bottom) ?? 0,
8960
+ left: (safeArea == null ? void 0 : safeArea.insets.left) ?? 0,
8961
+ right: (safeArea == null ? void 0 : safeArea.insets.right) ?? 0
8962
+ }
8963
+ })
8964
+ }
8965
+ )
8966
+ ] }),
8967
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-0.5", children: [
8968
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-secondary", children: "↓" }),
8969
+ /* @__PURE__ */ jsxRuntime.jsx(
8970
+ SidebarInput,
8971
+ {
8972
+ type: "number",
8973
+ value: String((safeArea == null ? void 0 : safeArea.insets.bottom) ?? 0),
8974
+ onChange: (value) => mock.setSafeArea({
8975
+ insets: {
8976
+ ...safeArea == null ? void 0 : safeArea.insets,
8977
+ top: (safeArea == null ? void 0 : safeArea.insets.top) ?? 0,
8978
+ bottom: Number(value),
8979
+ left: (safeArea == null ? void 0 : safeArea.insets.left) ?? 0,
8980
+ right: (safeArea == null ? void 0 : safeArea.insets.right) ?? 0
8981
+ }
8982
+ })
8983
+ }
8984
+ )
8985
+ ] }),
8986
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-0.5", children: [
8987
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-secondary", children: "←" }),
8988
+ /* @__PURE__ */ jsxRuntime.jsx(
8989
+ SidebarInput,
8990
+ {
8991
+ type: "number",
8992
+ value: String((safeArea == null ? void 0 : safeArea.insets.left) ?? 0),
8993
+ onChange: (value) => mock.setSafeArea({
8994
+ insets: {
8995
+ ...safeArea == null ? void 0 : safeArea.insets,
8996
+ top: (safeArea == null ? void 0 : safeArea.insets.top) ?? 0,
8997
+ bottom: (safeArea == null ? void 0 : safeArea.insets.bottom) ?? 0,
8998
+ left: Number(value),
8999
+ right: (safeArea == null ? void 0 : safeArea.insets.right) ?? 0
9000
+ }
9001
+ })
9002
+ }
9003
+ )
9004
+ ] }),
9005
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-0.5", children: [
9006
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-secondary", children: "→" }),
9007
+ /* @__PURE__ */ jsxRuntime.jsx(
9008
+ SidebarInput,
9009
+ {
9010
+ type: "number",
9011
+ value: String((safeArea == null ? void 0 : safeArea.insets.right) ?? 0),
9012
+ onChange: (value) => mock.setSafeArea({
9013
+ insets: {
9014
+ ...safeArea == null ? void 0 : safeArea.insets,
9015
+ top: (safeArea == null ? void 0 : safeArea.insets.top) ?? 0,
9016
+ bottom: (safeArea == null ? void 0 : safeArea.insets.bottom) ?? 0,
9017
+ left: (safeArea == null ? void 0 : safeArea.insets.left) ?? 0,
9018
+ right: Number(value)
9019
+ }
9020
+ })
9021
+ }
9022
+ )
9023
+ ] })
9024
+ ] }) }),
9025
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "View Mode", children: /* @__PURE__ */ jsxRuntime.jsx(
9026
+ SidebarSelect,
9027
+ {
9028
+ value: (view == null ? void 0 : view.mode) ?? "default",
9029
+ onChange: (value) => mock.setView(
9030
+ value === "default" ? null : {
9031
+ mode: value,
9032
+ params: view == null ? void 0 : view.params
9033
+ }
9034
+ ),
9035
+ options: [
9036
+ { value: "default", label: "Default (null)" },
9037
+ { value: "modal", label: "Modal" }
9038
+ ]
9039
+ }
9040
+ ) }),
9041
+ view && view.mode !== "default" && /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "View Params (JSON)", children: /* @__PURE__ */ jsxRuntime.jsx(
9042
+ SidebarTextarea,
9043
+ {
9044
+ value: viewParamsJson,
9045
+ onChange: (json) => validateJSON(json, setViewParamsJson, setViewParamsError),
9046
+ onFocus: () => setEditingField("viewParams"),
9047
+ onBlur: () => commitJSON(viewParamsJson, setViewParamsError, (parsed) => {
9048
+ if (view) {
9049
+ mock.setView({ ...view, params: parsed ?? void 0 });
9050
+ }
9051
+ }),
9052
+ error: viewParamsError,
9053
+ maxRows: 2
9054
+ }
9055
+ ) }),
9056
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarCollapsibleControl, { label: "Widget State (JSON)", defaultCollapsed: false, children: /* @__PURE__ */ jsxRuntime.jsx(
9057
+ SidebarTextarea,
9058
+ {
9059
+ value: widgetStateJson,
9060
+ onChange: (json) => validateJSON(json, setWidgetStateJson, setWidgetStateError),
9061
+ onFocus: () => setEditingField("widgetState"),
9062
+ onBlur: () => commitJSON(
9063
+ widgetStateJson,
9064
+ setWidgetStateError,
9065
+ (parsed) => mock.setWidgetStateExternal(parsed)
9066
+ ),
9067
+ error: widgetStateError,
9068
+ maxRows: 8
9069
+ }
9070
+ ) })
8953
9071
  ] }) }),
8954
- /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "View Mode", children: /* @__PURE__ */ jsxRuntime.jsx(
8955
- SidebarSelect,
8956
- {
8957
- value: (view == null ? void 0 : view.mode) ?? "default",
8958
- onChange: (value) => mock.setView(
8959
- value === "default" ? null : {
8960
- mode: value,
8961
- params: view == null ? void 0 : view.params
8962
- }
8963
- ),
8964
- options: [
8965
- { value: "default", label: "Default (null)" },
8966
- { value: "modal", label: "Modal" }
8967
- ]
8968
- }
8969
- ) }),
8970
- view && view.mode !== "default" && /* @__PURE__ */ jsxRuntime.jsx(SidebarControl, { label: "View Params (JSON)", children: /* @__PURE__ */ jsxRuntime.jsx(
8971
- SidebarTextarea,
8972
- {
8973
- value: viewParamsJson,
8974
- onChange: (json) => validateJSON(json, setViewParamsJson, setViewParamsError),
8975
- onFocus: () => setEditingField("viewParams"),
8976
- onBlur: () => commitJSON(viewParamsJson, setViewParamsError, (parsed) => {
8977
- if (view) {
8978
- mock.setView({ ...view, params: parsed ?? void 0 });
8979
- }
8980
- }),
8981
- error: viewParamsError,
8982
- rows: 2
8983
- }
8984
- ) }),
8985
9072
  /* @__PURE__ */ jsxRuntime.jsx(SidebarCollapsibleControl, { label: "Tool Input (JSON)", children: /* @__PURE__ */ jsxRuntime.jsx(
8986
9073
  SidebarTextarea,
8987
9074
  {
@@ -8994,7 +9081,7 @@ function ChatGPTSimulator({
8994
9081
  (parsed) => mock.setToolInput(parsed ?? {})
8995
9082
  ),
8996
9083
  error: toolInputError,
8997
- rows: 8
9084
+ maxRows: 8
8998
9085
  }
8999
9086
  ) }),
9000
9087
  /* @__PURE__ */ jsxRuntime.jsx(SidebarCollapsibleControl, { label: "Tool Output (JSON)", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -9009,7 +9096,7 @@ function ChatGPTSimulator({
9009
9096
  (parsed) => mock.setToolOutput(parsed)
9010
9097
  ),
9011
9098
  error: toolOutputError,
9012
- rows: 8
9099
+ maxRows: 8
9013
9100
  }
9014
9101
  ) }),
9015
9102
  /* @__PURE__ */ jsxRuntime.jsx(SidebarCollapsibleControl, { label: "Tool Response Metadata (JSON)", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -9024,22 +9111,7 @@ function ChatGPTSimulator({
9024
9111
  (parsed) => mock.setToolResponseMetadata(parsed)
9025
9112
  ),
9026
9113
  error: toolResponseMetadataError,
9027
- rows: 8
9028
- }
9029
- ) }),
9030
- /* @__PURE__ */ jsxRuntime.jsx(SidebarCollapsibleControl, { label: "Widget State (JSON)", children: /* @__PURE__ */ jsxRuntime.jsx(
9031
- SidebarTextarea,
9032
- {
9033
- value: widgetStateJson,
9034
- onChange: (json) => validateJSON(json, setWidgetStateJson, setWidgetStateError),
9035
- onFocus: () => setEditingField("widgetState"),
9036
- onBlur: () => commitJSON(
9037
- widgetStateJson,
9038
- setWidgetStateError,
9039
- (parsed) => mock.setWidgetStateExternal(parsed)
9040
- ),
9041
- error: widgetStateError,
9042
- rows: 8
9114
+ maxRows: 8
9043
9115
  }
9044
9116
  ) })
9045
9117
  ] }),
@@ -9130,4 +9202,4 @@ exports.useWidgetAPI = useWidgetAPI;
9130
9202
  exports.useWidgetGlobal = useWidgetGlobal;
9131
9203
  exports.useWidgetProps = useWidgetProps;
9132
9204
  exports.useWidgetState = useWidgetState;
9133
- //# sourceMappingURL=simulator-url-BStCoFTv.cjs.map
9205
+ //# sourceMappingURL=simulator-url-oevkxbU4.cjs.map