@typespec/playground 0.11.0-dev.1 → 0.11.0

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,7 +1,8 @@
1
- import require$$0, { createContext, useContext, useRef, useEffect, useMemo, memo, useCallback, useState, useId as useId$1 } from 'react';
1
+ import require$$0, { createContext, useContext, memo, useCallback, useRef, useEffect, useMemo, useState, useId as useId$1 } from 'react';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
- import { editor, Uri, MarkerSeverity, KeyMod, KeyCode } from 'monaco-editor';
4
3
  import { mergeClasses, Popover, PopoverTrigger, PopoverSurface, Title3, Table, TableHeader, TableRow, TableHeaderCell, TableBody, TableCell, Select, useId, Label, Checkbox, RadioGroup, Radio, Input, Switch, Divider, Dialog, DialogTrigger, ToolbarButton, DialogSurface, DialogBody, DialogTitle, DialogContent, Toolbar, Tooltip, Link, TabList, Tab, Button, useToastController, Toast, ToastTitle, ToastBody, Toaster, FluentProvider, webLightTheme } from '@fluentui/react-components';
4
+ import { getSourceLocation } from '@typespec/compiler';
5
+ import { editor, Uri, MarkerSeverity, KeyMod, KeyCode } from 'monaco-editor';
5
6
  import { $ } from '@typespec/compiler/typekit';
6
7
  import { Settings24Regular, Save16Regular, Broom16Filled, Bug16Regular, FolderListRegular, DataLineRegular, ErrorCircle16Filled, Warning16Filled, ChevronDown16Regular } from '@fluentui/react-icons';
7
8
  import debounce from 'debounce';
@@ -10,7 +11,6 @@ import { a as resolveVirtualPath, p as printDebugInfo, d as debugGlobals, g as g
10
11
  import { ErrorBoundary } from 'react-error-boundary';
11
12
  import { TypeGraph } from '@typespec/html-program-viewer/react';
12
13
  import '@typespec/html-program-viewer/style.css';
13
- import { getSourceLocation } from '@typespec/compiler';
14
14
  import { createRoot } from 'react-dom/client';
15
15
  import { createUrlStateStorage } from '../state-storage.js';
16
16
 
@@ -24,6 +24,71 @@ function usePlaygroundContext() {
24
24
  return context;
25
25
  }
26
26
 
27
+ const list = "_list_wrnwm_1";
28
+ const item$1 = "_item_wrnwm_4";
29
+ const style$a = {
30
+ list: list,
31
+ item: item$1,
32
+ "item--error": "_item--error_wrnwm_15",
33
+ "item--warning": "_item--warning_wrnwm_19",
34
+ "item-code": "_item-code_wrnwm_23",
35
+ "item-loc": "_item-loc_wrnwm_27"
36
+ };
37
+
38
+ const DiagnosticList = ({
39
+ diagnostics,
40
+ onDiagnosticSelected
41
+ }) => {
42
+ const handleItemSelected = useCallback(
43
+ (diagnostic) => {
44
+ onDiagnosticSelected?.(diagnostic);
45
+ },
46
+ [onDiagnosticSelected]
47
+ );
48
+ if (diagnostics.length === 0) {
49
+ return /* @__PURE__ */ jsx("div", { className: style$a["list"], children: "No errors" });
50
+ }
51
+ return /* @__PURE__ */ jsx("div", { className: style$a["list"], children: diagnostics.map((x, i) => {
52
+ return /* @__PURE__ */ jsx(DiagnosticItem, { diagnostic: x, onItemSelected: handleItemSelected }, i);
53
+ }) });
54
+ };
55
+ const DiagnosticItem = ({ diagnostic, onItemSelected }) => {
56
+ const handleClick = useCallback(() => {
57
+ onItemSelected(diagnostic);
58
+ }, [diagnostic, onItemSelected]);
59
+ return /* @__PURE__ */ jsxs("div", { tabIndex: 0, className: style$a["item"], onClick: handleClick, children: [
60
+ /* @__PURE__ */ jsx(
61
+ "div",
62
+ {
63
+ className: mergeClasses(
64
+ (style$a[diagnostic.severity === "error" ? "item--error" : "item--warning"])
65
+ ),
66
+ children: diagnostic.severity
67
+ }
68
+ ),
69
+ /* @__PURE__ */ jsx("div", { className: style$a["item-code"], children: diagnostic.code }),
70
+ /* @__PURE__ */ jsx("div", { className: style$a["item-message"], children: diagnostic.message }),
71
+ /* @__PURE__ */ jsx("div", { className: style$a["item-loc"], children: /* @__PURE__ */ jsx(DiagnosticTargetLink, { target: diagnostic.target }) })
72
+ ] });
73
+ };
74
+ const DiagnosticTargetLink = memo(({ target }) => {
75
+ if (target === void 0) {
76
+ return /* @__PURE__ */ jsx("span", { title: "Diagnostic didn't report a target. This is a bug on the emitter.", children: "No target" });
77
+ }
78
+ if (typeof target === "symbol") {
79
+ return /* @__PURE__ */ jsx("span", {});
80
+ }
81
+ const location = getSourceLocation(target);
82
+ const file = location.file.path === "/test/main.tsp" ? "" : `${location.file.path}:`;
83
+ const { line, character } = location.file.getLineAndCharacterOfPosition(location.pos);
84
+ return /* @__PURE__ */ jsxs("span", { children: [
85
+ file,
86
+ line + 1,
87
+ ":",
88
+ character + 1
89
+ ] });
90
+ });
91
+
27
92
  const Editor = ({ model, options, actions, onMount }) => {
28
93
  const editorContainerRef = useRef(null);
29
94
  const editorRef = useRef(null);
@@ -68,18 +133,18 @@ function useMonacoModel(uri, language) {
68
133
  }
69
134
 
70
135
  const footer = "_footer_e6dic_1";
71
- const style$a = {
136
+ const style$9 = {
72
137
  footer: footer,
73
138
  "footer-item": "_footer-item_e6dic_9"
74
139
  };
75
140
 
76
141
  const FooterItem = ({ children, link, className }) => {
77
- const resolvedClassName = mergeClasses(style$a["footer-item"], className);
142
+ const resolvedClassName = mergeClasses(style$9["footer-item"], className);
78
143
  return link ? /* @__PURE__ */ jsx("a", { className: resolvedClassName, href: link, target: "_blank", rel: "noopener noreferrer", children }) : /* @__PURE__ */ jsx("div", { className: resolvedClassName, children });
79
144
  };
80
145
 
81
146
  const button = "_button_1c15n_4";
82
- const style$9 = {
147
+ const style$8 = {
83
148
  "version-item": "_version-item_1c15n_1",
84
149
  button: button
85
150
  };
@@ -88,8 +153,8 @@ const FooterVersionItem = memo(({ versionSelector }) => {
88
153
  const { host } = usePlaygroundContext();
89
154
  const latest = versionSelector?.latest;
90
155
  const selected = versionSelector?.selected ?? host.compiler.MANIFEST.version;
91
- return /* @__PURE__ */ jsx(FooterItem, { className: style$9["version-item"], children: /* @__PURE__ */ jsxs(Popover, { children: [
92
- /* @__PURE__ */ jsx(PopoverTrigger, { disableButtonEnhancement: true, children: /* @__PURE__ */ jsxs("div", { className: style$9["button"], children: [
156
+ return /* @__PURE__ */ jsx(FooterItem, { className: style$8["version-item"], children: /* @__PURE__ */ jsxs(Popover, { children: [
157
+ /* @__PURE__ */ jsx(PopoverTrigger, { disableButtonEnhancement: true, children: /* @__PURE__ */ jsxs("div", { className: style$8["button"], children: [
93
158
  /* @__PURE__ */ jsx("span", { children: "Version " }),
94
159
  /* @__PURE__ */ jsx("span", { children: selected }),
95
160
  /* @__PURE__ */ jsx("span", { children: latest ? latest === selected ? " (latest)" : " (old)" : "" })
@@ -135,7 +200,7 @@ const VersionSelector = memo(({ versions, selected, latest, onChange }) => {
135
200
  });
136
201
 
137
202
  const Footer = ({ className, children }) => {
138
- return /* @__PURE__ */ jsx("div", { className: mergeClasses(style$a.footer, className), children });
203
+ return /* @__PURE__ */ jsx("div", { className: mergeClasses(style$9.footer, className), children });
139
204
  };
140
205
 
141
206
  function useControllableValue(controlledValue, defaultUncontrolledValue, onChange) {
@@ -1896,10 +1961,10 @@ const SamplesDropdown = ({
1896
1961
  };
1897
1962
 
1898
1963
  const form = "_form_sqeas_1";
1899
- const item$1 = "_item_sqeas_7";
1900
- const style$8 = {
1964
+ const item = "_item_sqeas_7";
1965
+ const style$7 = {
1901
1966
  form: form,
1902
- item: item$1,
1967
+ item: item,
1903
1968
  "switch": "_switch_sqeas_13"
1904
1969
  };
1905
1970
 
@@ -1925,8 +1990,8 @@ const EmitterOptionsForm = ({
1925
1990
  return /* @__PURE__ */ jsx(Fragment, { children: '"No options"' });
1926
1991
  }
1927
1992
  const entries = Object.entries(emitterOptionsSchema);
1928
- return /* @__PURE__ */ jsx("div", { className: style$8["form"], children: entries.map(([key, value]) => {
1929
- return /* @__PURE__ */ jsx("div", { className: style$8["form-item"], children: value.type === "array" ? /* @__PURE__ */ jsx(
1993
+ return /* @__PURE__ */ jsx("div", { className: style$7["form"], children: entries.map(([key, value]) => {
1994
+ return /* @__PURE__ */ jsx("div", { className: style$7["form-item"], children: value.type === "array" ? /* @__PURE__ */ jsx(
1930
1995
  JsonSchemaArrayPropertyInput,
1931
1996
  {
1932
1997
  emitterOptions: options[library.name] ?? {},
@@ -1977,7 +2042,7 @@ const JsonSchemaArrayPropertyInput = ({
1977
2042
  return JsonSchemaPropertyInput({ emitterOptions, name, prop: itemsSchema, onChange });
1978
2043
  }
1979
2044
  const itemsEnum = itemsSchema.enum;
1980
- return /* @__PURE__ */ jsxs("div", { className: style$8["item"], children: [
2045
+ return /* @__PURE__ */ jsxs("div", { className: style$7["item"], children: [
1981
2046
  /* @__PURE__ */ jsx(Label, { htmlFor: inputId, title: name, children: prettyName }),
1982
2047
  itemsEnum.map((x) => /* @__PURE__ */ jsx(
1983
2048
  Checkbox,
@@ -2012,7 +2077,7 @@ const JsonSchemaPropertyInput = ({
2012
2077
  return /* @__PURE__ */ jsx(
2013
2078
  Switch,
2014
2079
  {
2015
- className: style$8["switch"],
2080
+ className: style$7["switch"],
2016
2081
  label: prettyName,
2017
2082
  labelPosition: "above",
2018
2083
  checked: value,
@@ -2021,7 +2086,7 @@ const JsonSchemaPropertyInput = ({
2021
2086
  );
2022
2087
  case "string":
2023
2088
  default:
2024
- return /* @__PURE__ */ jsxs("div", { className: style$8["item"], children: [
2089
+ return /* @__PURE__ */ jsxs("div", { className: style$7["item"], children: [
2025
2090
  /* @__PURE__ */ jsx(Label, { htmlFor: inputId, title: name, children: prettyName }),
2026
2091
  prop.enum ? /* @__PURE__ */ jsx(RadioGroup, { layout: "horizontal", id: inputId, value, onChange: handleChange, children: prop.enum.map((x) => /* @__PURE__ */ jsx(Radio, { value: x, label: x }, x)) }) : /* @__PURE__ */ jsx(Input, { id: inputId, value, onChange: handleChange })
2027
2092
  ] });
@@ -2149,7 +2214,7 @@ const CompilerSettingsDialogButton = ({
2149
2214
  const bar = "_bar_15c2c_1";
2150
2215
  const divider = "_divider_15c2c_5";
2151
2216
  const spacer = "_spacer_15c2c_9";
2152
- const style$7 = {
2217
+ const style$6 = {
2153
2218
  bar: bar,
2154
2219
  divider: divider,
2155
2220
  spacer: spacer
@@ -2176,7 +2241,7 @@ const EditorCommandBar = ({
2176
2241
  () => Object.values(host.libraries).filter((x) => x.isEmitter).map((x) => x.name),
2177
2242
  [host.libraries]
2178
2243
  );
2179
- return /* @__PURE__ */ jsx("div", { className: style$7["bar"], children: /* @__PURE__ */ jsxs(Toolbar, { children: [
2244
+ return /* @__PURE__ */ jsx("div", { className: style$6["bar"], children: /* @__PURE__ */ jsxs(Toolbar, { children: [
2180
2245
  /* @__PURE__ */ jsx(Tooltip, { content: "Save", relationship: "description", withArrow: true, children: /* @__PURE__ */ jsx(ToolbarButton, { "aria-label": "Save", icon: /* @__PURE__ */ jsx(Save16Regular, {}), onClick: saveCode }) }),
2181
2246
  /* @__PURE__ */ jsx(Tooltip, { content: "Format", relationship: "description", withArrow: true, children: /* @__PURE__ */ jsx(ToolbarButton, { "aria-label": "Format", icon: /* @__PURE__ */ jsx(Broom16Filled, {}), onClick: formatCode }) }),
2182
2247
  samples && /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -2188,7 +2253,7 @@ const EditorCommandBar = ({
2188
2253
  onSelectedSampleNameChange
2189
2254
  }
2190
2255
  ),
2191
- /* @__PURE__ */ jsx("div", { className: style$7["spacer"] })
2256
+ /* @__PURE__ */ jsx("div", { className: style$6["spacer"] })
2192
2257
  ] }),
2193
2258
  /* @__PURE__ */ jsx(
2194
2259
  EmitterDropdown,
@@ -2199,10 +2264,10 @@ const EditorCommandBar = ({
2199
2264
  }
2200
2265
  ),
2201
2266
  documentation && /* @__PURE__ */ jsxs(Fragment, { children: [
2202
- /* @__PURE__ */ jsx("div", { className: style$7["spacer"] }),
2267
+ /* @__PURE__ */ jsx("div", { className: style$6["spacer"] }),
2203
2268
  documentation
2204
2269
  ] }),
2205
- /* @__PURE__ */ jsx("div", { className: style$7["divider"] }),
2270
+ /* @__PURE__ */ jsx("div", { className: style$6["divider"] }),
2206
2271
  commandBarButtons,
2207
2272
  bugButton,
2208
2273
  /* @__PURE__ */ jsx(
@@ -2264,7 +2329,7 @@ const OutputEditor = ({ filename, value, editorOptions }) => {
2264
2329
  return /* @__PURE__ */ jsx(Editor, { model, options });
2265
2330
  };
2266
2331
 
2267
- const style$6 = {
2332
+ const style$5 = {
2268
2333
  "file-output": "_file-output_jzw6j_1",
2269
2334
  "viewer-selector": "_viewer-selector_jzw6j_5"
2270
2335
  };
@@ -2290,8 +2355,8 @@ const FileOutput = ({ filename, content, viewers }) => {
2290
2355
  } else if (keys.length === 1) {
2291
2356
  return resolvedViewers[keys[0]].render({ filename, content });
2292
2357
  }
2293
- return /* @__PURE__ */ jsxs("div", { className: style$6["file-output"], children: [
2294
- /* @__PURE__ */ jsx("div", { className: style$6["viewer-selector"], children: /* @__PURE__ */ jsx(Select, { value: selected, onChange: handleSelected, "aria-label": "Select viewer", children: Object.values(resolvedViewers).map(({ key, label }) => /* @__PURE__ */ jsx("option", { value: key, children: label }, key)) }) }),
2358
+ return /* @__PURE__ */ jsxs("div", { className: style$5["file-output"], children: [
2359
+ /* @__PURE__ */ jsx("div", { className: style$5["viewer-selector"], children: /* @__PURE__ */ jsx(Select, { value: selected, onChange: handleSelected, "aria-label": "Select viewer", children: Object.values(resolvedViewers).map(({ key, label }) => /* @__PURE__ */ jsx("option", { value: key, children: label }, key)) }) }),
2295
2360
  selectedRender && selectedRender({ filename, content })
2296
2361
  ] });
2297
2362
  };
@@ -2303,7 +2368,7 @@ const RawFileViewer = {
2303
2368
 
2304
2369
  const tabs = "_tabs_1x6x2_1";
2305
2370
  const tab = "_tab_1x6x2_1";
2306
- const style$5 = {
2371
+ const style$4 = {
2307
2372
  tabs: tabs,
2308
2373
  tab: tab,
2309
2374
  "tab--selected": "_tab--selected_1x6x2_18"
@@ -2320,12 +2385,12 @@ const OutputTabs = ({
2320
2385
  },
2321
2386
  [onSelect]
2322
2387
  );
2323
- return /* @__PURE__ */ jsx(TabList, { selectedValue: selected, onTabSelect, className: style$5["tabs"], children: filenames.map((filename) => {
2388
+ return /* @__PURE__ */ jsx(TabList, { selectedValue: selected, onTabSelect, className: style$4["tabs"], children: filenames.map((filename) => {
2324
2389
  return /* @__PURE__ */ jsx(
2325
2390
  Tab,
2326
2391
  {
2327
2392
  value: filename,
2328
- className: mergeClasses(style$5["tab"], filename === selected && style$5["tab--selected"]),
2393
+ className: mergeClasses(style$4["tab"], filename === selected && style$4["tab--selected"]),
2329
2394
  children: filename
2330
2395
  },
2331
2396
  filename
@@ -2333,7 +2398,7 @@ const OutputTabs = ({
2333
2398
  }) });
2334
2399
  };
2335
2400
 
2336
- const style$4 = {
2401
+ const style$3 = {
2337
2402
  "output-view": "_output-view_omce4_1",
2338
2403
  "file-viewer": "_file-viewer_omce4_6",
2339
2404
  "output-content": "_output-content_omce4_12",
@@ -2377,9 +2442,9 @@ const FileViewerComponent = ({
2377
2442
  if (outputFiles.length === 0) {
2378
2443
  return /* @__PURE__ */ jsx(Fragment, { children: "No files emitted." });
2379
2444
  }
2380
- return /* @__PURE__ */ jsxs("div", { className: style$4["file-viewer"], children: [
2445
+ return /* @__PURE__ */ jsxs("div", { className: style$3["file-viewer"], children: [
2381
2446
  /* @__PURE__ */ jsx(OutputTabs, { filenames: outputFiles, selected: filename, onSelect: handleTabSelection }),
2382
- /* @__PURE__ */ jsx("div", { className: style$4["file-viewer-content"], children: /* @__PURE__ */ jsx(FileOutput, { filename, content, viewers: fileViewers }) })
2447
+ /* @__PURE__ */ jsx("div", { className: style$3["file-viewer-content"], children: /* @__PURE__ */ jsx(FileOutput, { filename, content, viewers: fileViewers }) })
2383
2448
  ] });
2384
2449
  };
2385
2450
  function createFileViewer(fileViewers) {
@@ -2409,7 +2474,7 @@ const TypeGraphViewerComponent = ({
2409
2474
  },
2410
2475
  [viewerState, onViewerStateChange]
2411
2476
  );
2412
- return /* @__PURE__ */ jsx("div", { className: style$4["type-graph-viewer"], children: /* @__PURE__ */ jsx(
2477
+ return /* @__PURE__ */ jsx("div", { className: style$3["type-graph-viewer"], children: /* @__PURE__ */ jsx(
2413
2478
  TypeGraph,
2414
2479
  {
2415
2480
  program,
@@ -2491,8 +2556,8 @@ const OutputViewInternal = ({
2491
2556
  const viewer = useMemo(() => {
2492
2557
  return viewers.programViewers[selected];
2493
2558
  }, [viewers.programViewers, selected]);
2494
- return /* @__PURE__ */ jsxs("div", { className: style$4["output-view"], children: [
2495
- /* @__PURE__ */ jsx("div", { className: style$4["output-content"], children: /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender, children: /* @__PURE__ */ jsx(
2559
+ return /* @__PURE__ */ jsxs("div", { className: style$3["output-view"], children: [
2560
+ /* @__PURE__ */ jsx("div", { className: style$3["output-content"], children: /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender, children: /* @__PURE__ */ jsx(
2496
2561
  viewer.render,
2497
2562
  {
2498
2563
  program: compilationResult.program,
@@ -2501,23 +2566,23 @@ const OutputViewInternal = ({
2501
2566
  onViewerStateChange
2502
2567
  }
2503
2568
  ) }) }),
2504
- /* @__PURE__ */ jsx("div", { className: style$4["viewer-tabs-container"], children: /* @__PURE__ */ jsx(
2569
+ /* @__PURE__ */ jsx("div", { className: style$3["viewer-tabs-container"], children: /* @__PURE__ */ jsx(
2505
2570
  TabList,
2506
2571
  {
2507
2572
  vertical: true,
2508
2573
  size: "large",
2509
2574
  selectedValue: selected,
2510
2575
  onTabSelect,
2511
- className: style$4["viewer-tabs"],
2576
+ className: style$3["viewer-tabs"],
2512
2577
  children: viewerList.map((viewer2) => {
2513
- return /* @__PURE__ */ jsx(Tab, { value: viewer2.key, className: style$4["viewer-tab"], children: /* @__PURE__ */ jsx("span", { title: viewer2.label, children: viewer2.icon }) }, viewer2.key);
2578
+ return /* @__PURE__ */ jsx(Tab, { value: viewer2.key, className: style$3["viewer-tab"], children: /* @__PURE__ */ jsx("span", { title: viewer2.label, children: viewer2.icon }) }, viewer2.key);
2514
2579
  })
2515
2580
  }
2516
2581
  ) })
2517
2582
  ] });
2518
2583
  };
2519
2584
  function fallbackRender({ error, resetErrorBoundary }) {
2520
- return /* @__PURE__ */ jsxs("div", { role: "alert", className: style$4["viewer-error"], children: [
2585
+ return /* @__PURE__ */ jsxs("div", { role: "alert", className: style$3["viewer-error"], children: [
2521
2586
  /* @__PURE__ */ jsx("h2", { children: "Something went wrong:" }),
2522
2587
  /* @__PURE__ */ jsx("div", { style: { color: "red" }, children: error.toString() }),
2523
2588
  /* @__PURE__ */ jsx(Button, { onClick: resetErrorBoundary, children: "Try again" })
@@ -2525,76 +2590,11 @@ function fallbackRender({ error, resetErrorBoundary }) {
2525
2590
  }
2526
2591
 
2527
2592
  const layout = "_layout_l03ni_1";
2528
- const style$3 = {
2593
+ const style$2 = {
2529
2594
  layout: layout,
2530
2595
  "edit-pane": "_edit-pane_l03ni_9"
2531
2596
  };
2532
2597
 
2533
- const list = "_list_wrnwm_1";
2534
- const item = "_item_wrnwm_4";
2535
- const style$2 = {
2536
- list: list,
2537
- item: item,
2538
- "item--error": "_item--error_wrnwm_15",
2539
- "item--warning": "_item--warning_wrnwm_19",
2540
- "item-code": "_item-code_wrnwm_23",
2541
- "item-loc": "_item-loc_wrnwm_27"
2542
- };
2543
-
2544
- const DiagnosticList = ({
2545
- diagnostics,
2546
- onDiagnosticSelected
2547
- }) => {
2548
- const handleItemSelected = useCallback(
2549
- (diagnostic) => {
2550
- onDiagnosticSelected?.(diagnostic);
2551
- },
2552
- [onDiagnosticSelected]
2553
- );
2554
- if (diagnostics.length === 0) {
2555
- return /* @__PURE__ */ jsx("div", { className: style$2["list"], children: "No errors" });
2556
- }
2557
- return /* @__PURE__ */ jsx("div", { className: style$2["list"], children: diagnostics.map((x, i) => {
2558
- return /* @__PURE__ */ jsx(DiagnosticItem, { diagnostic: x, onItemSelected: handleItemSelected }, i);
2559
- }) });
2560
- };
2561
- const DiagnosticItem = ({ diagnostic, onItemSelected }) => {
2562
- const handleClick = useCallback(() => {
2563
- onItemSelected(diagnostic);
2564
- }, [diagnostic, onItemSelected]);
2565
- return /* @__PURE__ */ jsxs("div", { tabIndex: 0, className: style$2["item"], onClick: handleClick, children: [
2566
- /* @__PURE__ */ jsx(
2567
- "div",
2568
- {
2569
- className: mergeClasses(
2570
- (style$2[diagnostic.severity === "error" ? "item--error" : "item--warning"])
2571
- ),
2572
- children: diagnostic.severity
2573
- }
2574
- ),
2575
- /* @__PURE__ */ jsx("div", { className: style$2["item-code"], children: diagnostic.code }),
2576
- /* @__PURE__ */ jsx("div", { className: style$2["item-message"], children: diagnostic.message }),
2577
- /* @__PURE__ */ jsx("div", { className: style$2["item-loc"], children: /* @__PURE__ */ jsx(DiagnosticTargetLink, { target: diagnostic.target }) })
2578
- ] });
2579
- };
2580
- const DiagnosticTargetLink = memo(({ target }) => {
2581
- if (target === void 0) {
2582
- return /* @__PURE__ */ jsx("span", { title: "Diagnostic didn't report a target. This is a bug on the emitter.", children: "No target" });
2583
- }
2584
- if (typeof target === "symbol") {
2585
- return /* @__PURE__ */ jsx("span", {});
2586
- }
2587
- const location = getSourceLocation(target);
2588
- const file = location.file.path === "/test/main.tsp" ? "" : `${location.file.path}:`;
2589
- const { line, character } = location.file.getLineAndCharacterOfPosition(location.pos);
2590
- return /* @__PURE__ */ jsxs("span", { children: [
2591
- file,
2592
- line + 1,
2593
- ":",
2594
- character + 1
2595
- ] });
2596
- });
2597
-
2598
2598
  const header = "_header_1qhql_1";
2599
2599
  const style$1 = {
2600
2600
  header: header,
@@ -2961,10 +2961,10 @@ const Playground = (props) => {
2961
2961
  }
2962
2962
  };
2963
2963
  }, [host, typespecModel, onContentChange]);
2964
- return /* @__PURE__ */ jsx(PlaygroundContextProvider, { value: playgroundContext, children: /* @__PURE__ */ jsxs("div", { className: style$3["layout"], children: [
2964
+ return /* @__PURE__ */ jsx(PlaygroundContextProvider, { value: playgroundContext, children: /* @__PURE__ */ jsxs("div", { className: style$2["layout"], children: [
2965
2965
  /* @__PURE__ */ jsxs(SplitPane, { sizes: verticalPaneSizes, onChange: onVerticalPaneSizeChange, split: "horizontal", children: [
2966
2966
  /* @__PURE__ */ jsx(Pane, { children: /* @__PURE__ */ jsxs(SplitPane, { initialSizes: ["50%", "50%"], children: [
2967
- /* @__PURE__ */ jsxs(Pane, { className: style$3["edit-pane"], children: [
2967
+ /* @__PURE__ */ jsxs(Pane, { className: style$2["edit-pane"], children: [
2968
2968
  /* @__PURE__ */ jsx(
2969
2969
  EditorCommandBar,
2970
2970
  {
@@ -3209,4 +3209,4 @@ function createStandalonePlaygroundStateStorage() {
3209
3209
  };
3210
3210
  }
3211
3211
 
3212
- export { Editor, Footer, FooterItem, FooterVersionItem, Playground, StandalonePlayground, createReactPlayground, createStandalonePlaygroundStateStorage, renderReactPlayground, useMonacoModel, usePlaygroundContext, usePlaygroundState };
3212
+ export { DiagnosticList, Editor, Footer, FooterItem, FooterVersionItem, Playground, StandalonePlayground, createReactPlayground, createStandalonePlaygroundStateStorage, renderReactPlayground, useMonacoModel, usePlaygroundContext, usePlaygroundState };
@@ -1,4 +1,6 @@
1
1
  export { usePlaygroundContext } from './context/index.js';
2
+ export { DiagnosticList } from './diagnostic-list/diagnostic-list.js';
3
+ export type { DiagnosticListProps } from './diagnostic-list/diagnostic-list.js';
2
4
  export { Editor, useMonacoModel, type EditorProps } from './editor.js';
3
5
  export { Footer, FooterItem, FooterVersionItem, type FooterItemProps, type FooterProps, type FooterVersionItemProps, type VersionSelectorProps, type VersionSelectorVersion, } from './footer/index.js';
4
6
  export { Playground } from './playground.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EACL,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,GAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,sCAAsC,EACtC,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,mBAAmB,YAAY,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,YAAY,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EACL,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,GAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,sCAAsC,EACtC,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,mBAAmB,YAAY,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/style.css CHANGED
@@ -1,3 +1,32 @@
1
+ ._list_wrnwm_1 {
2
+ }
3
+
4
+ ._item_wrnwm_4 {
5
+ cursor: pointer;
6
+ display: flex;
7
+ gap: 10px;
8
+ padding: 0 10px;
9
+ }
10
+
11
+ ._item_wrnwm_4:hover {
12
+ background-color: var(--colorNeutralBackground3Hover);
13
+ }
14
+
15
+ ._item--error_wrnwm_15 {
16
+ color: var(--colorStatusDangerForeground1);
17
+ }
18
+
19
+ ._item--warning_wrnwm_19 {
20
+ color: var(--colorStatusWarningForeground1);
21
+ }
22
+
23
+ ._item-code_wrnwm_23 {
24
+ color: var(--colorBrandForeground2);
25
+ }
26
+
27
+ ._item-loc_wrnwm_27 {
28
+ color: var(--colorNeutralForeground3);
29
+ }
1
30
  ._footer_e6dic_1 {
2
31
  grid-area: footer;
3
32
  display: flex;
@@ -246,35 +275,6 @@
246
275
  display: flex;
247
276
  flex-direction: column;
248
277
  }
249
- ._list_wrnwm_1 {
250
- }
251
-
252
- ._item_wrnwm_4 {
253
- cursor: pointer;
254
- display: flex;
255
- gap: 10px;
256
- padding: 0 10px;
257
- }
258
-
259
- ._item_wrnwm_4:hover {
260
- background-color: var(--colorNeutralBackground3Hover);
261
- }
262
-
263
- ._item--error_wrnwm_15 {
264
- color: var(--colorStatusDangerForeground1);
265
- }
266
-
267
- ._item--warning_wrnwm_19 {
268
- color: var(--colorStatusWarningForeground1);
269
- }
270
-
271
- ._item-code_wrnwm_23 {
272
- color: var(--colorBrandForeground2);
273
- }
274
-
275
- ._item-loc_wrnwm_27 {
276
- color: var(--colorNeutralForeground3);
277
- }
278
278
  ._header_1qhql_1 {
279
279
  padding: 5px;
280
280
  cursor: pointer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/playground",
3
- "version": "0.11.0-dev.1",
3
+ "version": "0.11.0",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec playground UI components.",
6
6
  "homepage": "https://typespec.io",
@@ -61,15 +61,6 @@
61
61
  "dependencies": {
62
62
  "@fluentui/react-components": "~9.69.0",
63
63
  "@fluentui/react-icons": "^2.0.292",
64
- "@typespec/bundler": "^0.4.3 || >=0.5.0-dev <0.5.0",
65
- "@typespec/compiler": "^1.3.0",
66
- "@typespec/html-program-viewer": "^0.73.0 || >=0.74.0-dev <0.74.0",
67
- "@typespec/http": "^1.3.0",
68
- "@typespec/openapi": "^1.3.0",
69
- "@typespec/openapi3": "^1.3.0",
70
- "@typespec/protobuf": "^0.73.0 || >=0.74.0-dev <0.74.0",
71
- "@typespec/rest": "^0.73.0 || >=0.74.0-dev <0.74.0",
72
- "@typespec/versioning": "^0.73.0 || >=0.74.0-dev <0.74.0",
73
64
  "clsx": "^2.1.1",
74
65
  "debounce": "~2.2.0",
75
66
  "lzutf8": "0.6.3",
@@ -79,7 +70,16 @@
79
70
  "react-error-boundary": "^6.0.0",
80
71
  "swagger-ui-dist": "^5.20.1",
81
72
  "vscode-languageserver": "~9.0.1",
82
- "vscode-languageserver-textdocument": "~1.0.12"
73
+ "vscode-languageserver-textdocument": "~1.0.12",
74
+ "@typespec/bundler": "^0.4.4",
75
+ "@typespec/compiler": "^1.4.0",
76
+ "@typespec/html-program-viewer": "^0.74.0",
77
+ "@typespec/http": "^1.4.0",
78
+ "@typespec/openapi": "^1.4.0",
79
+ "@typespec/openapi3": "^1.4.0",
80
+ "@typespec/protobuf": "^0.74.0",
81
+ "@typespec/versioning": "^0.74.0",
82
+ "@typespec/rest": "^0.74.0"
83
83
  },
84
84
  "devDependencies": {
85
85
  "@babel/core": "^7.26.10",
@@ -91,7 +91,6 @@
91
91
  "@types/react": "~18.3.11",
92
92
  "@types/react-dom": "~18.3.0",
93
93
  "@types/swagger-ui-dist": "~3.30.5",
94
- "@typespec/bundler": "^0.4.3 || >=0.5.0-dev <0.5.0",
95
94
  "@vitejs/plugin-react": "~4.7.0",
96
95
  "c8": "^10.1.3",
97
96
  "cross-env": "~10.0.0",
@@ -102,9 +101,9 @@
102
101
  "vite": "^7.0.5",
103
102
  "vite-plugin-checker": "^0.10.1",
104
103
  "vite-plugin-dts": "4.5.4",
105
- "@typespec/react-components": "^0.57.0"
104
+ "@typespec/react-components": "^0.57.0",
105
+ "@typespec/bundler": "^0.4.4"
106
106
  },
107
- "peerDependencies": {},
108
107
  "scripts": {
109
108
  "clean": "rimraf ./dist ./dist-dev ./temp ./typespecContents.json",
110
109
  "build": "vite build",