@typespec/playground 0.15.1-dev.4 → 0.15.1-dev.5
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.
- package/dist/react/index.js +262 -198
- package/dist/src/react/compilation/compile.d.ts +5 -0
- package/dist/src/react/compilation/compile.d.ts.map +1 -0
- package/dist/src/react/footer/footer-version-item.d.ts +1 -1
- package/dist/src/react/footer/footer-version-item.d.ts.map +1 -1
- package/dist/src/react/hooks/index.d.ts +5 -0
- package/dist/src/react/hooks/index.d.ts.map +1 -0
- package/dist/src/react/hooks/use-compilation.d.ts +18 -0
- package/dist/src/react/hooks/use-compilation.d.ts.map +1 -0
- package/dist/src/react/hooks/use-debounced-compile.d.ts +12 -0
- package/dist/src/react/hooks/use-debounced-compile.d.ts.map +1 -0
- package/dist/src/react/hooks/use-editor-actions.d.ts +30 -0
- package/dist/src/react/hooks/use-editor-actions.d.ts.map +1 -0
- package/dist/src/react/hooks/use-monaco-sync.d.ts +15 -0
- package/dist/src/react/hooks/use-monaco-sync.d.ts.map +1 -0
- package/dist/src/react/playground.d.ts +2 -6
- package/dist/src/react/playground.d.ts.map +1 -1
- package/dist/src/react/problem-pane/header.d.ts +1 -1
- package/dist/src/react/problem-pane/header.d.ts.map +1 -1
- package/dist/src/react/standalone.d.ts +1 -1
- package/dist/src/react/standalone.d.ts.map +1 -1
- package/dist/src/react/viewers/react-wrapper.d.ts +1 -1
- package/package.json +4 -4
package/dist/react/index.js
CHANGED
|
@@ -5,10 +5,10 @@ import { KeyCode, KeyMod, MarkerSeverity, MarkerTag, Range, Uri, editor } from "
|
|
|
5
5
|
import { Fragment, createContext, memo, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { Button, Card, Checkbox, DrawerBody, DrawerHeader, DrawerHeaderTitle, FluentProvider, Input, Label, Menu, MenuDivider, MenuItem, MenuList, MenuPopover, MenuTrigger, OverlayDrawer, Popover, PopoverSurface, PopoverTrigger, Radio, RadioGroup, SearchBox, Select, Spinner, Subtitle2, Switch, Tab, TabList, Table, TableBody, TableCell, TableHeader, TableHeaderCell, TableRow, Text, Title3, Toast, ToastBody, ToastTitle, Toaster, Toolbar, ToolbarButton, Tooltip, mergeClasses, tokens, useId as useId$1, useToastController, webLightTheme } from "@fluentui/react-components";
|
|
7
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import { $ } from "@typespec/compiler/typekit";
|
|
9
8
|
import { Broom16Filled, Bug16Regular, Checkmark16Regular, ChevronDown16Regular, ChevronDownRegular, ChevronRightRegular, DataLineRegular, Dismiss24Regular, DocumentBulletList24Regular, DocumentRegular, ErrorCircle16Filled, FolderListRegular, FolderRegular, MoreHorizontal24Filled, Save16Regular, SettingsRegular, Warning16Filled } from "@fluentui/react-icons";
|
|
10
9
|
import debounce from "debounce";
|
|
11
10
|
import { parse, stringify } from "yaml";
|
|
11
|
+
import { $ } from "@typespec/compiler/typekit";
|
|
12
12
|
import { ErrorBoundary } from "react-error-boundary";
|
|
13
13
|
import { TypeGraph } from "@typespec/html-program-viewer/react";
|
|
14
14
|
import "@typespec/html-program-viewer/style.css";
|
|
@@ -1779,6 +1779,244 @@ var EditorPanel = ({ host, model, actions, editorOptions, onMount, selectedEmitt
|
|
|
1779
1779
|
})]
|
|
1780
1780
|
});
|
|
1781
1781
|
};
|
|
1782
|
+
//#endregion
|
|
1783
|
+
//#region src/react/compilation/compile.ts
|
|
1784
|
+
var outputDir = resolveVirtualPath("tsp-output");
|
|
1785
|
+
async function compile(host, content, selectedEmitter, options) {
|
|
1786
|
+
await host.writeFile("main.tsp", content);
|
|
1787
|
+
await emptyOutputDir(host);
|
|
1788
|
+
try {
|
|
1789
|
+
return {
|
|
1790
|
+
program: await host.compiler.compile(host, resolveVirtualPath("main.tsp"), {
|
|
1791
|
+
...options,
|
|
1792
|
+
options: {
|
|
1793
|
+
...options.options,
|
|
1794
|
+
[selectedEmitter]: {
|
|
1795
|
+
...options.options?.[selectedEmitter],
|
|
1796
|
+
"emitter-output-dir": outputDir
|
|
1797
|
+
}
|
|
1798
|
+
},
|
|
1799
|
+
outputDir,
|
|
1800
|
+
emit: selectedEmitter ? [selectedEmitter] : []
|
|
1801
|
+
}),
|
|
1802
|
+
outputFiles: await findOutputFiles(host)
|
|
1803
|
+
};
|
|
1804
|
+
} catch (error) {
|
|
1805
|
+
console.error("Internal compiler error", error);
|
|
1806
|
+
return { internalCompilerError: error };
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
async function findOutputFiles(host) {
|
|
1810
|
+
const files = [];
|
|
1811
|
+
async function addFiles(dir) {
|
|
1812
|
+
const items = await host.readDir(outputDir + dir);
|
|
1813
|
+
for (const item of items) {
|
|
1814
|
+
const itemPath = `${dir}/${item}`;
|
|
1815
|
+
if ((await host.stat(outputDir + itemPath)).isDirectory()) await addFiles(itemPath);
|
|
1816
|
+
else files.push(dir === "" ? item : `${dir}/${item}`);
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
await addFiles("");
|
|
1820
|
+
return files;
|
|
1821
|
+
}
|
|
1822
|
+
async function emptyOutputDir(host) {
|
|
1823
|
+
const dirs = await host.readDir("./tsp-output");
|
|
1824
|
+
for (const file of dirs) {
|
|
1825
|
+
const path = "./tsp-output/" + file;
|
|
1826
|
+
const uri = Uri.parse(host.pathToFileURL(path));
|
|
1827
|
+
const model = editor.getModel(uri);
|
|
1828
|
+
if (model) model.dispose();
|
|
1829
|
+
await host.rm(path, { recursive: true });
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
//#endregion
|
|
1833
|
+
//#region src/react/hooks/use-compilation.ts
|
|
1834
|
+
function useCompilation({ host, selectedEmitter, compilerOptions, typespecModel }) {
|
|
1835
|
+
const [compilationState, setCompilationState] = useState(void 0);
|
|
1836
|
+
const [isCompiling, setIsCompiling] = useState(false);
|
|
1837
|
+
const [isOutputStale, setIsOutputStale] = useState(false);
|
|
1838
|
+
const lastSuccessfulOutputRef = useRef([]);
|
|
1839
|
+
useEffect(() => {
|
|
1840
|
+
lastSuccessfulOutputRef.current = [];
|
|
1841
|
+
setIsOutputStale(false);
|
|
1842
|
+
}, [selectedEmitter]);
|
|
1843
|
+
const compileIdRef = useRef(0);
|
|
1844
|
+
const isCompilingRef = useRef(false);
|
|
1845
|
+
const pendingRecompileRef = useRef(false);
|
|
1846
|
+
const doCompileRef = useRef(() => Promise.resolve());
|
|
1847
|
+
const doCompile = useCallback(async () => {
|
|
1848
|
+
if (isCompilingRef.current) {
|
|
1849
|
+
pendingRecompileRef.current = true;
|
|
1850
|
+
return;
|
|
1851
|
+
}
|
|
1852
|
+
const currentContent = typespecModel.getValue();
|
|
1853
|
+
const typespecCompiler = host.compiler;
|
|
1854
|
+
const compileId = ++compileIdRef.current;
|
|
1855
|
+
isCompilingRef.current = true;
|
|
1856
|
+
setIsCompiling(true);
|
|
1857
|
+
let state;
|
|
1858
|
+
try {
|
|
1859
|
+
state = await compile(host, currentContent, selectedEmitter, compilerOptions);
|
|
1860
|
+
} catch (error) {
|
|
1861
|
+
console.error("Compilation failed", error);
|
|
1862
|
+
isCompilingRef.current = false;
|
|
1863
|
+
setIsCompiling(false);
|
|
1864
|
+
if (pendingRecompileRef.current) {
|
|
1865
|
+
pendingRecompileRef.current = false;
|
|
1866
|
+
doCompileRef.current();
|
|
1867
|
+
}
|
|
1868
|
+
return;
|
|
1869
|
+
}
|
|
1870
|
+
isCompilingRef.current = false;
|
|
1871
|
+
setIsCompiling(false);
|
|
1872
|
+
if (compileId !== compileIdRef.current) return;
|
|
1873
|
+
if ("program" in state && state.program.hasError() && state.outputFiles.length === 0 && lastSuccessfulOutputRef.current.length > 0) {
|
|
1874
|
+
setIsOutputStale(true);
|
|
1875
|
+
setCompilationState({
|
|
1876
|
+
...state,
|
|
1877
|
+
outputFiles: lastSuccessfulOutputRef.current
|
|
1878
|
+
});
|
|
1879
|
+
} else {
|
|
1880
|
+
setIsOutputStale(false);
|
|
1881
|
+
if ("program" in state && state.outputFiles.length > 0) lastSuccessfulOutputRef.current = state.outputFiles;
|
|
1882
|
+
setCompilationState(state);
|
|
1883
|
+
}
|
|
1884
|
+
if ("program" in state) {
|
|
1885
|
+
const markers = state.program.diagnostics.map((diag) => ({
|
|
1886
|
+
...getMonacoRange(typespecCompiler, diag.target),
|
|
1887
|
+
message: diag.message,
|
|
1888
|
+
severity: diag.severity === "error" ? MarkerSeverity.Error : MarkerSeverity.Warning,
|
|
1889
|
+
tags: diag.code === "deprecated" ? [MarkerTag.Deprecated] : void 0
|
|
1890
|
+
}));
|
|
1891
|
+
updateDiagnosticsForCodeFixes(typespecCompiler, state.program.diagnostics);
|
|
1892
|
+
debugGlobals().program = state.program;
|
|
1893
|
+
debugGlobals().$$ = $(state.program);
|
|
1894
|
+
editor.setModelMarkers(typespecModel, "owner", markers ?? []);
|
|
1895
|
+
} else {
|
|
1896
|
+
updateDiagnosticsForCodeFixes(host.compiler, []);
|
|
1897
|
+
editor.setModelMarkers(typespecModel, "owner", []);
|
|
1898
|
+
}
|
|
1899
|
+
if (pendingRecompileRef.current) {
|
|
1900
|
+
pendingRecompileRef.current = false;
|
|
1901
|
+
doCompileRef.current();
|
|
1902
|
+
}
|
|
1903
|
+
}, [
|
|
1904
|
+
host,
|
|
1905
|
+
selectedEmitter,
|
|
1906
|
+
compilerOptions,
|
|
1907
|
+
typespecModel
|
|
1908
|
+
]);
|
|
1909
|
+
useEffect(() => {
|
|
1910
|
+
doCompileRef.current = doCompile;
|
|
1911
|
+
}, [doCompile]);
|
|
1912
|
+
useEffect(() => {
|
|
1913
|
+
doCompile();
|
|
1914
|
+
}, [doCompile]);
|
|
1915
|
+
return {
|
|
1916
|
+
compilationState,
|
|
1917
|
+
isCompiling,
|
|
1918
|
+
isOutputStale,
|
|
1919
|
+
doCompile
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
//#endregion
|
|
1923
|
+
//#region src/react/hooks/use-debounced-compile.ts
|
|
1924
|
+
/**
|
|
1925
|
+
* Subscribes to Monaco model content changes and triggers compilation
|
|
1926
|
+
* after a debounce delay.
|
|
1927
|
+
*/
|
|
1928
|
+
function useDebouncedCompile({ typespecModel, doCompile, debounceDelay = 200 }) {
|
|
1929
|
+
useEffect(() => {
|
|
1930
|
+
const debouncer = debounce(() => doCompile(), debounceDelay);
|
|
1931
|
+
const disposable = typespecModel.onDidChangeContent(debouncer);
|
|
1932
|
+
return () => {
|
|
1933
|
+
debouncer.clear();
|
|
1934
|
+
disposable.dispose();
|
|
1935
|
+
};
|
|
1936
|
+
}, [
|
|
1937
|
+
typespecModel,
|
|
1938
|
+
doCompile,
|
|
1939
|
+
debounceDelay
|
|
1940
|
+
]);
|
|
1941
|
+
}
|
|
1942
|
+
//#endregion
|
|
1943
|
+
//#region src/react/hooks/use-editor-actions.ts
|
|
1944
|
+
function useEditorActions({ typespecModel, editorRef, selectedEmitter, compilerOptions, selectedSampleName, isSampleUntouched, selectedViewer, viewerState, onSave, onFileBug }) {
|
|
1945
|
+
const saveCode = useCallback(() => {
|
|
1946
|
+
if (onSave) onSave({
|
|
1947
|
+
content: typespecModel.getValue(),
|
|
1948
|
+
emitter: selectedEmitter,
|
|
1949
|
+
compilerOptions,
|
|
1950
|
+
sampleName: isSampleUntouched ? selectedSampleName : void 0,
|
|
1951
|
+
selectedViewer,
|
|
1952
|
+
viewerState
|
|
1953
|
+
});
|
|
1954
|
+
}, [
|
|
1955
|
+
typespecModel,
|
|
1956
|
+
onSave,
|
|
1957
|
+
selectedEmitter,
|
|
1958
|
+
compilerOptions,
|
|
1959
|
+
selectedSampleName,
|
|
1960
|
+
isSampleUntouched,
|
|
1961
|
+
selectedViewer,
|
|
1962
|
+
viewerState
|
|
1963
|
+
]);
|
|
1964
|
+
return {
|
|
1965
|
+
saveCode,
|
|
1966
|
+
formatCode: useCallback(() => {
|
|
1967
|
+
editorRef.current?.getAction("editor.action.formatDocument")?.run();
|
|
1968
|
+
}, [editorRef]),
|
|
1969
|
+
fileBug: useCallback(async () => {
|
|
1970
|
+
if (onFileBug) {
|
|
1971
|
+
saveCode();
|
|
1972
|
+
onFileBug();
|
|
1973
|
+
}
|
|
1974
|
+
}, [onFileBug, saveCode]),
|
|
1975
|
+
editorActions: useMemo(() => [{
|
|
1976
|
+
id: "save",
|
|
1977
|
+
label: "Save",
|
|
1978
|
+
keybindings: [KeyMod.CtrlCmd | KeyCode.KeyS],
|
|
1979
|
+
run: saveCode
|
|
1980
|
+
}], [saveCode])
|
|
1981
|
+
};
|
|
1982
|
+
}
|
|
1983
|
+
//#endregion
|
|
1984
|
+
//#region src/react/hooks/use-monaco-sync.ts
|
|
1985
|
+
/**
|
|
1986
|
+
* Bidirectional sync between a Monaco editor model and React state.
|
|
1987
|
+
*
|
|
1988
|
+
* - When `content` changes externally (e.g. sample selection), the model is updated.
|
|
1989
|
+
* - When the user types in the editor, `onContentChange` is called.
|
|
1990
|
+
* - Uses a ref guard (`isModelDrivenChangeRef`) to prevent infinite loops.
|
|
1991
|
+
*/
|
|
1992
|
+
function useMonacoSync({ typespecModel, content, onContentChange }) {
|
|
1993
|
+
const isModelDrivenChangeRef = useRef(false);
|
|
1994
|
+
useEffect(() => {
|
|
1995
|
+
if (isModelDrivenChangeRef.current) {
|
|
1996
|
+
isModelDrivenChangeRef.current = false;
|
|
1997
|
+
return;
|
|
1998
|
+
}
|
|
1999
|
+
if (typespecModel.getValue() !== (content ?? "")) typespecModel.setValue(content ?? "");
|
|
2000
|
+
}, [content, typespecModel]);
|
|
2001
|
+
const contentRef = useRef(content);
|
|
2002
|
+
const onContentChangeRef = useRef(onContentChange);
|
|
2003
|
+
useEffect(() => {
|
|
2004
|
+
contentRef.current = content;
|
|
2005
|
+
}, [content]);
|
|
2006
|
+
useEffect(() => {
|
|
2007
|
+
onContentChangeRef.current = onContentChange;
|
|
2008
|
+
}, [onContentChange]);
|
|
2009
|
+
useEffect(() => {
|
|
2010
|
+
const disposable = typespecModel.onDidChangeContent(() => {
|
|
2011
|
+
const newContent = typespecModel.getValue();
|
|
2012
|
+
if (newContent !== contentRef.current) {
|
|
2013
|
+
isModelDrivenChangeRef.current = true;
|
|
2014
|
+
onContentChangeRef.current(newContent);
|
|
2015
|
+
}
|
|
2016
|
+
});
|
|
2017
|
+
return () => disposable.dispose();
|
|
2018
|
+
}, [typespecModel]);
|
|
2019
|
+
}
|
|
1782
2020
|
var file_breadcrumb_module_default = {
|
|
1783
2021
|
breadcrumb: "_breadcrumb_15sw5_1",
|
|
1784
2022
|
segment: "_segment_15sw5_15",
|
|
@@ -2547,10 +2785,6 @@ var Playground = (props) => {
|
|
|
2547
2785
|
debugGlobals().host = host;
|
|
2548
2786
|
}, [host]);
|
|
2549
2787
|
const typespecModel = useMonacoModel("inmemory://test/main.tsp", "typespec");
|
|
2550
|
-
const [compilationState, setCompilationState] = useState(void 0);
|
|
2551
|
-
const lastSuccessfulOutputRef = useRef([]);
|
|
2552
|
-
const [isCompiling, setIsCompiling] = useState(false);
|
|
2553
|
-
const [isOutputStale, setIsOutputStale] = useState(false);
|
|
2554
2788
|
const { selectedEmitter, compilerOptions, selectedSampleName, selectedViewer, viewerState, content, onSelectedEmitterChange, onCompilerOptionsChange, onSelectedSampleNameChange, onSelectedViewerChange, onViewerStateChange, onContentChange } = usePlaygroundState({
|
|
2555
2789
|
libraries: props.libraries,
|
|
2556
2790
|
samples: props.samples,
|
|
@@ -2560,162 +2794,40 @@ var Playground = (props) => {
|
|
|
2560
2794
|
defaultEmitter: props.defaultEmitter,
|
|
2561
2795
|
defaultContent: props.defaultContent
|
|
2562
2796
|
});
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
setIsOutputStale(false);
|
|
2566
|
-
}, [selectedEmitter]);
|
|
2567
|
-
const isModelDrivenChangeRef = useRef(false);
|
|
2568
|
-
useEffect(() => {
|
|
2569
|
-
if (isModelDrivenChangeRef.current) {
|
|
2570
|
-
isModelDrivenChangeRef.current = false;
|
|
2571
|
-
return;
|
|
2572
|
-
}
|
|
2573
|
-
if (typespecModel.getValue() !== (content ?? "")) typespecModel.setValue(content ?? "");
|
|
2574
|
-
}, [content, typespecModel]);
|
|
2575
|
-
const contentRef = useRef(content);
|
|
2576
|
-
const onContentChangeRef = useRef(onContentChange);
|
|
2577
|
-
useEffect(() => {
|
|
2578
|
-
contentRef.current = content;
|
|
2579
|
-
}, [content]);
|
|
2580
|
-
useEffect(() => {
|
|
2581
|
-
onContentChangeRef.current = onContentChange;
|
|
2582
|
-
}, [onContentChange]);
|
|
2583
|
-
useEffect(() => {
|
|
2584
|
-
const disposable = typespecModel.onDidChangeContent(() => {
|
|
2585
|
-
const newContent = typespecModel.getValue();
|
|
2586
|
-
if (newContent !== contentRef.current) {
|
|
2587
|
-
isModelDrivenChangeRef.current = true;
|
|
2588
|
-
onContentChangeRef.current(newContent);
|
|
2589
|
-
}
|
|
2590
|
-
});
|
|
2591
|
-
return () => disposable.dispose();
|
|
2592
|
-
}, [typespecModel]);
|
|
2593
|
-
const isSampleUntouched = useMemo(() => {
|
|
2594
|
-
return Boolean(selectedSampleName && content === props.samples?.[selectedSampleName]?.content);
|
|
2595
|
-
}, [
|
|
2797
|
+
useMonacoSync({
|
|
2798
|
+
typespecModel,
|
|
2596
2799
|
content,
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
const compileIdRef = useRef(0);
|
|
2601
|
-
const isCompilingRef = useRef(false);
|
|
2602
|
-
const pendingRecompileRef = useRef(false);
|
|
2603
|
-
const doCompileRef = useRef(() => Promise.resolve());
|
|
2604
|
-
const doCompile = useCallback(async () => {
|
|
2605
|
-
if (isCompilingRef.current) {
|
|
2606
|
-
pendingRecompileRef.current = true;
|
|
2607
|
-
return;
|
|
2608
|
-
}
|
|
2609
|
-
const currentContent = typespecModel.getValue();
|
|
2610
|
-
const typespecCompiler = host.compiler;
|
|
2611
|
-
const compileId = ++compileIdRef.current;
|
|
2612
|
-
isCompilingRef.current = true;
|
|
2613
|
-
setIsCompiling(true);
|
|
2614
|
-
let state;
|
|
2615
|
-
try {
|
|
2616
|
-
state = await compile(host, currentContent, selectedEmitter, compilerOptions);
|
|
2617
|
-
} catch (error) {
|
|
2618
|
-
console.error("Compilation failed", error);
|
|
2619
|
-
isCompilingRef.current = false;
|
|
2620
|
-
setIsCompiling(false);
|
|
2621
|
-
if (pendingRecompileRef.current) {
|
|
2622
|
-
pendingRecompileRef.current = false;
|
|
2623
|
-
doCompileRef.current();
|
|
2624
|
-
}
|
|
2625
|
-
return;
|
|
2626
|
-
}
|
|
2627
|
-
isCompilingRef.current = false;
|
|
2628
|
-
setIsCompiling(false);
|
|
2629
|
-
if (compileId !== compileIdRef.current) return;
|
|
2630
|
-
if ("program" in state && state.program.hasError() && state.outputFiles.length === 0 && lastSuccessfulOutputRef.current.length > 0) {
|
|
2631
|
-
setIsOutputStale(true);
|
|
2632
|
-
setCompilationState({
|
|
2633
|
-
...state,
|
|
2634
|
-
outputFiles: lastSuccessfulOutputRef.current
|
|
2635
|
-
});
|
|
2636
|
-
} else {
|
|
2637
|
-
setIsOutputStale(false);
|
|
2638
|
-
if ("program" in state && state.outputFiles.length > 0) lastSuccessfulOutputRef.current = state.outputFiles;
|
|
2639
|
-
setCompilationState(state);
|
|
2640
|
-
}
|
|
2641
|
-
if ("program" in state) {
|
|
2642
|
-
const markers = state.program.diagnostics.map((diag) => ({
|
|
2643
|
-
...getMonacoRange(typespecCompiler, diag.target),
|
|
2644
|
-
message: diag.message,
|
|
2645
|
-
severity: diag.severity === "error" ? MarkerSeverity.Error : MarkerSeverity.Warning,
|
|
2646
|
-
tags: diag.code === "deprecated" ? [MarkerTag.Deprecated] : void 0
|
|
2647
|
-
}));
|
|
2648
|
-
updateDiagnosticsForCodeFixes(typespecCompiler, state.program.diagnostics);
|
|
2649
|
-
debugGlobals().program = state.program;
|
|
2650
|
-
debugGlobals().$$ = $(state.program);
|
|
2651
|
-
editor.setModelMarkers(typespecModel, "owner", markers ?? []);
|
|
2652
|
-
} else {
|
|
2653
|
-
updateDiagnosticsForCodeFixes(typespecCompiler, []);
|
|
2654
|
-
editor.setModelMarkers(typespecModel, "owner", []);
|
|
2655
|
-
}
|
|
2656
|
-
if (pendingRecompileRef.current) {
|
|
2657
|
-
pendingRecompileRef.current = false;
|
|
2658
|
-
doCompileRef.current();
|
|
2659
|
-
}
|
|
2660
|
-
}, [
|
|
2800
|
+
onContentChange
|
|
2801
|
+
});
|
|
2802
|
+
const { compilationState, isCompiling, isOutputStale, doCompile } = useCompilation({
|
|
2661
2803
|
host,
|
|
2662
2804
|
selectedEmitter,
|
|
2663
2805
|
compilerOptions,
|
|
2664
2806
|
typespecModel
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
doCompileRef.current = doCompile;
|
|
2668
|
-
}, [doCompile]);
|
|
2669
|
-
const currentEmitterOptions = selectedEmitter ? props.emitterOptions?.[selectedEmitter] : void 0;
|
|
2670
|
-
useEffect(() => {
|
|
2671
|
-
const debouncer = debounce(() => doCompile(), currentEmitterOptions?.debounce ?? 200);
|
|
2672
|
-
const disposable = typespecModel.onDidChangeContent(debouncer);
|
|
2673
|
-
return () => {
|
|
2674
|
-
debouncer.clear();
|
|
2675
|
-
disposable.dispose();
|
|
2676
|
-
};
|
|
2677
|
-
}, [
|
|
2807
|
+
});
|
|
2808
|
+
useDebouncedCompile({
|
|
2678
2809
|
typespecModel,
|
|
2679
2810
|
doCompile,
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
doCompile();
|
|
2684
|
-
}, [doCompile]);
|
|
2685
|
-
const saveCode = useCallback(() => {
|
|
2686
|
-
if (onSave) onSave({
|
|
2687
|
-
content: typespecModel.getValue(),
|
|
2688
|
-
emitter: selectedEmitter,
|
|
2689
|
-
compilerOptions,
|
|
2690
|
-
sampleName: isSampleUntouched ? selectedSampleName : void 0,
|
|
2691
|
-
selectedViewer,
|
|
2692
|
-
viewerState
|
|
2693
|
-
});
|
|
2694
|
-
}, [
|
|
2811
|
+
debounceDelay: (selectedEmitter ? props.emitterOptions?.[selectedEmitter] : void 0)?.debounce
|
|
2812
|
+
});
|
|
2813
|
+
const { saveCode, formatCode, fileBug, editorActions } = useEditorActions({
|
|
2695
2814
|
typespecModel,
|
|
2696
|
-
|
|
2815
|
+
editorRef,
|
|
2697
2816
|
selectedEmitter,
|
|
2698
2817
|
compilerOptions,
|
|
2699
2818
|
selectedSampleName,
|
|
2700
|
-
isSampleUntouched
|
|
2819
|
+
isSampleUntouched: useMemo(() => {
|
|
2820
|
+
return Boolean(selectedSampleName && content === props.samples?.[selectedSampleName]?.content);
|
|
2821
|
+
}, [
|
|
2822
|
+
content,
|
|
2823
|
+
selectedSampleName,
|
|
2824
|
+
props.samples
|
|
2825
|
+
]),
|
|
2701
2826
|
selectedViewer,
|
|
2702
|
-
viewerState
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
}, []);
|
|
2707
|
-
const fileBug = useCallback(async () => {
|
|
2708
|
-
if (props.onFileBug) {
|
|
2709
|
-
saveCode();
|
|
2710
|
-
props.onFileBug();
|
|
2711
|
-
}
|
|
2712
|
-
}, [props, saveCode]);
|
|
2713
|
-
const typespecEditorActions = useMemo(() => [{
|
|
2714
|
-
id: "save",
|
|
2715
|
-
label: "Save",
|
|
2716
|
-
keybindings: [KeyMod.CtrlCmd | KeyCode.KeyS],
|
|
2717
|
-
run: saveCode
|
|
2718
|
-
}], [saveCode]);
|
|
2827
|
+
viewerState,
|
|
2828
|
+
onSave,
|
|
2829
|
+
onFileBug: props.onFileBug
|
|
2830
|
+
});
|
|
2719
2831
|
const onTypeSpecEditorMount = useCallback(({ editor }) => {
|
|
2720
2832
|
editorRef.current = editor;
|
|
2721
2833
|
}, []);
|
|
@@ -2765,7 +2877,7 @@ var Playground = (props) => {
|
|
|
2765
2877
|
const editorPanel = /* @__PURE__ */ jsx(EditorPanel, {
|
|
2766
2878
|
host,
|
|
2767
2879
|
model: typespecModel,
|
|
2768
|
-
actions:
|
|
2880
|
+
actions: editorActions,
|
|
2769
2881
|
editorOptions: props.editorOptions,
|
|
2770
2882
|
onMount: onTypeSpecEditorMount,
|
|
2771
2883
|
selectedEmitter,
|
|
@@ -2832,54 +2944,6 @@ var verticalPaneSizesConst = {
|
|
|
2832
2944
|
collapsed: [void 0, 30],
|
|
2833
2945
|
expanded: [void 0, 200]
|
|
2834
2946
|
};
|
|
2835
|
-
var outputDir = resolveVirtualPath("tsp-output");
|
|
2836
|
-
async function compile(host, content, selectedEmitter, options) {
|
|
2837
|
-
await host.writeFile("main.tsp", content);
|
|
2838
|
-
await emptyOutputDir(host);
|
|
2839
|
-
try {
|
|
2840
|
-
return {
|
|
2841
|
-
program: await host.compiler.compile(host, resolveVirtualPath("main.tsp"), {
|
|
2842
|
-
...options,
|
|
2843
|
-
options: {
|
|
2844
|
-
...options.options,
|
|
2845
|
-
[selectedEmitter]: {
|
|
2846
|
-
...options.options?.[selectedEmitter],
|
|
2847
|
-
"emitter-output-dir": outputDir
|
|
2848
|
-
}
|
|
2849
|
-
},
|
|
2850
|
-
outputDir,
|
|
2851
|
-
emit: selectedEmitter ? [selectedEmitter] : []
|
|
2852
|
-
}),
|
|
2853
|
-
outputFiles: await findOutputFiles(host)
|
|
2854
|
-
};
|
|
2855
|
-
} catch (error) {
|
|
2856
|
-
console.error("Internal compiler error", error);
|
|
2857
|
-
return { internalCompilerError: error };
|
|
2858
|
-
}
|
|
2859
|
-
}
|
|
2860
|
-
async function findOutputFiles(host) {
|
|
2861
|
-
const files = [];
|
|
2862
|
-
async function addFiles(dir) {
|
|
2863
|
-
const items = await host.readDir(outputDir + dir);
|
|
2864
|
-
for (const item of items) {
|
|
2865
|
-
const itemPath = `${dir}/${item}`;
|
|
2866
|
-
if ((await host.stat(outputDir + itemPath)).isDirectory()) await addFiles(itemPath);
|
|
2867
|
-
else files.push(dir === "" ? item : `${dir}/${item}`);
|
|
2868
|
-
}
|
|
2869
|
-
}
|
|
2870
|
-
await addFiles("");
|
|
2871
|
-
return files;
|
|
2872
|
-
}
|
|
2873
|
-
async function emptyOutputDir(host) {
|
|
2874
|
-
const dirs = await host.readDir("./tsp-output");
|
|
2875
|
-
for (const file of dirs) {
|
|
2876
|
-
const path = "./tsp-output/" + file;
|
|
2877
|
-
const uri = Uri.parse(host.pathToFileURL(path));
|
|
2878
|
-
const model = editor.getModel(uri);
|
|
2879
|
-
if (model) model.dispose();
|
|
2880
|
-
await host.rm(path, { recursive: true });
|
|
2881
|
-
}
|
|
2882
|
-
}
|
|
2883
2947
|
//#endregion
|
|
2884
2948
|
//#region src/react/standalone.tsx
|
|
2885
2949
|
function useStandalonePlaygroundContext(config) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CompilerOptions } from '@typespec/compiler';
|
|
2
|
+
import { BrowserHost } from '../../types.js';
|
|
3
|
+
import { CompilationState } from '../types.js';
|
|
4
|
+
export declare function compile(host: BrowserHost, content: string, selectedEmitter: string, options: CompilerOptions): Promise<CompilationState>;
|
|
5
|
+
//# sourceMappingURL=compile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../../src/react/compilation/compile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpD,wBAAsB,OAAO,CAC3B,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAwB3B"}
|
|
@@ -15,5 +15,5 @@ export interface FooterVersionItemProps {
|
|
|
15
15
|
/** Provide a way to change the version of packages in the playground */
|
|
16
16
|
versionSelector?: VersionSelectorProps;
|
|
17
17
|
}
|
|
18
|
-
export declare const FooterVersionItem: import('react').MemoExoticComponent<({ versionSelector }: FooterVersionItemProps) => import("react
|
|
18
|
+
export declare const FooterVersionItem: import('react').MemoExoticComponent<({ versionSelector }: FooterVersionItemProps) => import("react").JSX.Element>;
|
|
19
19
|
//# sourceMappingURL=footer-version-item.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer-version-item.d.ts","sourceRoot":"","sources":["../../../../src/react/footer/footer-version-item.tsx"],"names":[],"mappings":"AAmBA,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,sBAAsB,EAAE,CAAC;IAEnC,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;IAEjB,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,oDAAoD;IACpD,QAAQ,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,IAAI,CAAC;CACrD;AAED,MAAM,WAAW,sBAAsB;IACrC,wEAAwE;IACxE,eAAe,CAAC,EAAE,oBAAoB,CAAC;CACxC;AAED,eAAO,MAAM,iBAAiB,4DAA8B,sBAAsB,
|
|
1
|
+
{"version":3,"file":"footer-version-item.d.ts","sourceRoot":"","sources":["../../../../src/react/footer/footer-version-item.tsx"],"names":[],"mappings":"AAmBA,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,sBAAsB,EAAE,CAAC;IAEnC,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;IAEjB,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,oDAAoD;IACpD,QAAQ,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,IAAI,CAAC;CACrD;AAED,MAAM,WAAW,sBAAsB;IACrC,wEAAwE;IACxE,eAAe,CAAC,EAAE,oBAAoB,CAAC;CACxC;AAED,eAAO,MAAM,iBAAiB,4DAA8B,sBAAsB,iCAqBhF,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { useCompilation, type UseCompilationOptions, type UseCompilationResult, } from './use-compilation.js';
|
|
2
|
+
export { useDebouncedCompile, type UseDebouncedCompileOptions } from './use-debounced-compile.js';
|
|
3
|
+
export { useEditorActions, type PlaygroundSaveData, type UseEditorActionsOptions, type UseEditorActionsResult, } from './use-editor-actions.js';
|
|
4
|
+
export { useMonacoSync, type UseMonacoSyncOptions } from './use-monaco-sync.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,KAAK,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAClG,OAAO,EACL,gBAAgB,EAChB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,GAC5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CompilerOptions } from '@typespec/compiler';
|
|
2
|
+
import { editor } from 'monaco-editor';
|
|
3
|
+
import { BrowserHost } from '../../types.js';
|
|
4
|
+
import { CompilationState } from '../types.js';
|
|
5
|
+
export interface UseCompilationOptions {
|
|
6
|
+
host: BrowserHost;
|
|
7
|
+
selectedEmitter: string;
|
|
8
|
+
compilerOptions: CompilerOptions;
|
|
9
|
+
typespecModel: editor.ITextModel;
|
|
10
|
+
}
|
|
11
|
+
export interface UseCompilationResult {
|
|
12
|
+
compilationState: CompilationState | undefined;
|
|
13
|
+
isCompiling: boolean;
|
|
14
|
+
isOutputStale: boolean;
|
|
15
|
+
doCompile: () => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare function useCompilation({ host, selectedEmitter, compilerOptions, typespecModel, }: UseCompilationOptions): UseCompilationResult;
|
|
18
|
+
//# sourceMappingURL=use-compilation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-compilation.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/use-compilation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAA6B,MAAM,EAAE,MAAM,eAAe,CAAC;AAGlE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,WAAW,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,eAAe,CAAC;IACjC,aAAa,EAAE,MAAM,CAAC,UAAU,CAAC;CAClC;AAED,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAC/C,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,eAAe,EACf,eAAe,EACf,aAAa,GACd,EAAE,qBAAqB,GAAG,oBAAoB,CA0G9C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { editor } from 'monaco-editor';
|
|
2
|
+
export interface UseDebouncedCompileOptions {
|
|
3
|
+
typespecModel: editor.ITextModel;
|
|
4
|
+
doCompile: () => Promise<void>;
|
|
5
|
+
debounceDelay?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Subscribes to Monaco model content changes and triggers compilation
|
|
9
|
+
* after a debounce delay.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useDebouncedCompile({ typespecModel, doCompile, debounceDelay, }: UseDebouncedCompileOptions): void;
|
|
12
|
+
//# sourceMappingURL=use-debounced-compile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-debounced-compile.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/use-debounced-compile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,MAAM,WAAW,0BAA0B;IACzC,aAAa,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,aAAa,EACb,SAAS,EACT,aAAmB,GACpB,EAAE,0BAA0B,GAAG,IAAI,CASnC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CompilerOptions } from '@typespec/compiler';
|
|
2
|
+
import { editor } from 'monaco-editor';
|
|
3
|
+
import { RefObject } from 'react';
|
|
4
|
+
import { PlaygroundState } from '../use-playground-state.js';
|
|
5
|
+
export interface PlaygroundSaveData extends PlaygroundState {
|
|
6
|
+
/** Current content of the playground. */
|
|
7
|
+
content: string;
|
|
8
|
+
/** Emitter name. */
|
|
9
|
+
emitter: string;
|
|
10
|
+
}
|
|
11
|
+
export interface UseEditorActionsOptions {
|
|
12
|
+
typespecModel: editor.ITextModel;
|
|
13
|
+
editorRef: RefObject<editor.IStandaloneCodeEditor | undefined>;
|
|
14
|
+
selectedEmitter: string;
|
|
15
|
+
compilerOptions: CompilerOptions;
|
|
16
|
+
selectedSampleName: string;
|
|
17
|
+
isSampleUntouched: boolean;
|
|
18
|
+
selectedViewer?: string;
|
|
19
|
+
viewerState: Record<string, any>;
|
|
20
|
+
onSave?: (value: PlaygroundSaveData) => void;
|
|
21
|
+
onFileBug?: () => void;
|
|
22
|
+
}
|
|
23
|
+
export interface UseEditorActionsResult {
|
|
24
|
+
saveCode: () => void;
|
|
25
|
+
formatCode: () => void;
|
|
26
|
+
fileBug: () => Promise<void>;
|
|
27
|
+
editorActions: editor.IActionDescriptor[];
|
|
28
|
+
}
|
|
29
|
+
export declare function useEditorActions({ typespecModel, editorRef, selectedEmitter, compilerOptions, selectedSampleName, isSampleUntouched, selectedViewer, viewerState, onSave, onFileBug, }: UseEditorActionsOptions): UseEditorActionsResult;
|
|
30
|
+
//# sourceMappingURL=use-editor-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-editor-actions.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/use-editor-actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAmB,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,uBAAuB;IACtC,aAAa,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAAC;IAC/D,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,eAAe,CAAC;IACjC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC7C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC,iBAAiB,EAAE,CAAC;CAC3C;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,aAAa,EACb,SAAS,EACT,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,MAAM,EACN,SAAS,GACV,EAAE,uBAAuB,GAAG,sBAAsB,CA2ClD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { editor } from 'monaco-editor';
|
|
2
|
+
export interface UseMonacoSyncOptions {
|
|
3
|
+
typespecModel: editor.ITextModel;
|
|
4
|
+
content: string;
|
|
5
|
+
onContentChange: (content: string) => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Bidirectional sync between a Monaco editor model and React state.
|
|
9
|
+
*
|
|
10
|
+
* - When `content` changes externally (e.g. sample selection), the model is updated.
|
|
11
|
+
* - When the user types in the editor, `onContentChange` is called.
|
|
12
|
+
* - Uses a ref guard (`isModelDrivenChangeRef`) to prevent infinite loops.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useMonacoSync({ typespecModel, content, onContentChange, }: UseMonacoSyncOptions): void;
|
|
15
|
+
//# sourceMappingURL=use-monaco-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-monaco-sync.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/use-monaco-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,EAC5B,aAAa,EACb,OAAO,EACP,eAAe,GAChB,EAAE,oBAAoB,GAAG,IAAI,CAqC7B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FunctionComponent, ReactNode } from 'react';
|
|
2
2
|
import { BrowserHost, PlaygroundSample } from '../types.js';
|
|
3
|
+
import { PlaygroundSaveData } from './hooks/index.js';
|
|
3
4
|
import { CommandBarItem } from './responsive-command-bar/index.js';
|
|
4
5
|
import { FileOutputViewer, ProgramViewer } from './types.js';
|
|
5
6
|
import { PlaygroundState } from './use-playground-state.js';
|
|
@@ -48,12 +49,7 @@ export interface PlaygroundProps {
|
|
|
48
49
|
export interface PlaygroundEditorsOptions {
|
|
49
50
|
theme?: string;
|
|
50
51
|
}
|
|
51
|
-
export
|
|
52
|
-
/** Current content of the playground. */
|
|
53
|
-
content: string;
|
|
54
|
-
/** Emitter name. */
|
|
55
|
-
emitter: string;
|
|
56
|
-
}
|
|
52
|
+
export type { PlaygroundSaveData };
|
|
57
53
|
/**
|
|
58
54
|
* Playground component for TypeSpec with consolidated state management.
|
|
59
55
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../../src/react/playground.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../../src/react/playground.tsx"],"names":[],"mappings":"AAEA,OAAO,sCAAsC,CAAC;AAE9C,OAAO,EAML,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAMjE,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAElE,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAIrF,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC,MAAM,WAAW,wBAAwB;IACvC,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,CAAC;IAElB,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,kCAAkC;IAClC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAEtC,wBAAwB;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAE3C,oCAAoC;IACpC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,yDAAyD;IACzD,sBAAsB,CAAC,EAAE,eAAe,CAAC;IACzC,6CAA6C;IAC7C,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAE3D;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IAEvB,mDAAmD;IACnD,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IAEnC,kDAAkD;IAClD,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAE1B,4FAA4F;IAC5F,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAEpD;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IAE1D,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAE7C,aAAa,CAAC,EAAE,wBAAwB,CAAC;IAEzC;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAGD,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CAiNzD,CAAC"}
|
|
@@ -5,5 +5,5 @@ export interface ProblemPaneHeaderProps {
|
|
|
5
5
|
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
6
6
|
collaped: boolean;
|
|
7
7
|
}
|
|
8
|
-
export declare const ProblemPaneHeader: import('react').MemoExoticComponent<({ compilationState, ...props }: ProblemPaneHeaderProps) => import("react
|
|
8
|
+
export declare const ProblemPaneHeader: import('react').MemoExoticComponent<({ compilationState, ...props }: ProblemPaneHeaderProps) => import("react").JSX.Element>;
|
|
9
9
|
//# sourceMappingURL=header.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../../src/react/problem-pane/header.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAQ,KAAK,iBAAiB,EAAkB,MAAM,OAAO,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAC/C,OAAO,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAC5C,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,iBAAiB,uEAAyC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../../src/react/problem-pane/header.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAQ,KAAK,iBAAiB,EAAkB,MAAM,OAAO,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAC/C,OAAO,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAC5C,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,iBAAiB,uEAAyC,sBAAsB,iCAoC3F,CAAC"}
|
|
@@ -9,7 +9,7 @@ export interface ReactPlaygroundConfig extends Partial<PlaygroundProps> {
|
|
|
9
9
|
readonly fallback?: ReactNode;
|
|
10
10
|
}
|
|
11
11
|
export declare const StandalonePlayground: FunctionComponent<ReactPlaygroundConfig>;
|
|
12
|
-
export declare function createReactPlayground(config: ReactPlaygroundConfig): Promise<import("react
|
|
12
|
+
export declare function createReactPlayground(config: ReactPlaygroundConfig): Promise<import("react").JSX.Element>;
|
|
13
13
|
export declare function renderReactPlayground(config: ReactPlaygroundConfig): Promise<void>;
|
|
14
14
|
export declare function createStandalonePlaygroundStateStorage(): UrlStateStorage<PlaygroundSaveData>;
|
|
15
15
|
//# sourceMappingURL=standalone.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standalone.d.ts","sourceRoot":"","sources":["../../../src/react/standalone.tsx"],"names":[],"mappings":"AASA,OAAO,EAML,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EAExB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,qBAAsB,SAAQ,OAAO,CAAC,eAAe,CAAC;IACrE,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,YAAY,CAAC,EAAE,oBAAoB,CAAC;IAC7C,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;CAC/B;AAyBD,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,qBAAqB,CAuFzE,CAAC;AAEF,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"standalone.d.ts","sourceRoot":"","sources":["../../../src/react/standalone.tsx"],"names":[],"mappings":"AASA,OAAO,EAML,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EAExB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,qBAAsB,SAAQ,OAAO,CAAC,eAAe,CAAC;IACrE,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,YAAY,CAAC,EAAE,oBAAoB,CAAC;IAC7C,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;CAC/B;AAyBD,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,qBAAqB,CAuFzE,CAAC;AAEF,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,qBAAqB,wCAExE;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,qBAAqB,iBASxE;AAED,wBAAgB,sCAAsC,IAAI,eAAe,CAAC,kBAAkB,CAAC,CAkC5F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/playground",
|
|
3
|
-
"version": "0.15.1-dev.
|
|
3
|
+
"version": "0.15.1-dev.5",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec playground UI components.",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"debounce": "^3.0.0",
|
|
75
75
|
"lzutf8": "0.6.3",
|
|
76
76
|
"monaco-editor": "^0.55.1",
|
|
77
|
-
"react": "^19.2.
|
|
78
|
-
"react-dom": "^19.2.
|
|
77
|
+
"react": "^19.2.7",
|
|
78
|
+
"react-dom": "^19.2.7",
|
|
79
79
|
"react-error-boundary": "^6.1.1",
|
|
80
80
|
"swagger-ui-dist": "^5.32.2",
|
|
81
81
|
"vscode-languageserver": "^9.0.1",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@testing-library/react": "^16.3.2",
|
|
93
93
|
"@types/debounce": "^1.2.4",
|
|
94
94
|
"@types/node": "^25.5.2",
|
|
95
|
-
"@types/react": "^19.2.
|
|
95
|
+
"@types/react": "^19.2.16",
|
|
96
96
|
"@types/react-dom": "^19.2.3",
|
|
97
97
|
"@types/swagger-ui-dist": "^3.30.6",
|
|
98
98
|
"@typespec/bundler": "^0.6.0 || >= 0.6.1-dev.0",
|