@typespec/playground 0.1.0-alpha.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.
- package/README.md +64 -0
- package/dist/src/browser-host.d.ts +11 -0
- package/dist/src/browser-host.d.ts.map +1 -0
- package/dist/src/browser-host.js +129 -0
- package/dist/src/browser-host.js.map +1 -0
- package/dist/src/core.d.ts +7 -0
- package/dist/src/core.d.ts.map +1 -0
- package/dist/src/core.js +17 -0
- package/dist/src/core.js.map +1 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/manifest.d.ts +3 -0
- package/dist/src/manifest.d.ts.map +1 -0
- package/dist/src/manifest.js +5 -0
- package/dist/src/manifest.js.map +1 -0
- package/dist/src/monaco-worker.d.ts +2 -0
- package/dist/src/monaco-worker.d.ts.map +1 -0
- package/dist/src/monaco-worker.js +18 -0
- package/dist/src/monaco-worker.js.map +1 -0
- package/dist/src/react/diagnostic-list.d.ts +11 -0
- package/dist/src/react/diagnostic-list.d.ts.map +1 -0
- package/dist/src/react/diagnostic-list.js +16 -0
- package/dist/src/react/diagnostic-list.js.map +1 -0
- package/dist/src/react/editor-command-bar.d.ts +19 -0
- package/dist/src/react/editor-command-bar.d.ts.map +1 -0
- package/dist/src/react/editor-command-bar.js +15 -0
- package/dist/src/react/editor-command-bar.js.map +1 -0
- package/dist/src/react/editor.d.ts +14 -0
- package/dist/src/react/editor.d.ts.map +1 -0
- package/dist/src/react/editor.js +37 -0
- package/dist/src/react/editor.js.map +1 -0
- package/dist/src/react/emitter-dropdown.d.ts +8 -0
- package/dist/src/react/emitter-dropdown.d.ts.map +1 -0
- package/dist/src/react/emitter-dropdown.js +13 -0
- package/dist/src/react/emitter-dropdown.js.map +1 -0
- package/dist/src/react/error-tab.d.ts +12 -0
- package/dist/src/react/error-tab.d.ts.map +1 -0
- package/dist/src/react/error-tab.js +20 -0
- package/dist/src/react/error-tab.js.map +1 -0
- package/dist/src/react/file-output.d.ts +12 -0
- package/dist/src/react/file-output.d.ts.map +1 -0
- package/dist/src/react/file-output.js +31 -0
- package/dist/src/react/file-output.js.map +1 -0
- package/dist/src/react/footer.d.ts +3 -0
- package/dist/src/react/footer.d.ts.map +1 -0
- package/dist/src/react/footer.js +29 -0
- package/dist/src/react/footer.js.map +1 -0
- package/dist/src/react/hooks.d.ts +15 -0
- package/dist/src/react/hooks.d.ts.map +1 -0
- package/dist/src/react/hooks.js +50 -0
- package/dist/src/react/hooks.js.map +1 -0
- package/dist/src/react/index.d.ts +4 -0
- package/dist/src/react/index.d.ts.map +1 -0
- package/dist/src/react/index.js +4 -0
- package/dist/src/react/index.js.map +1 -0
- package/dist/src/react/output-tabs.d.ts +19 -0
- package/dist/src/react/output-tabs.d.ts.map +1 -0
- package/dist/src/react/output-tabs.js +38 -0
- package/dist/src/react/output-tabs.js.map +1 -0
- package/dist/src/react/output-view.d.ts +9 -0
- package/dist/src/react/output-view.d.ts.map +1 -0
- package/dist/src/react/output-view.js +99 -0
- package/dist/src/react/output-view.js.map +1 -0
- package/dist/src/react/playground.d.ts +56 -0
- package/dist/src/react/playground.d.ts.map +1 -0
- package/dist/src/react/playground.js +186 -0
- package/dist/src/react/playground.js.map +1 -0
- package/dist/src/react/samples-dropdown.d.ts +9 -0
- package/dist/src/react/samples-dropdown.d.ts.map +1 -0
- package/dist/src/react/samples-dropdown.js +15 -0
- package/dist/src/react/samples-dropdown.js.map +1 -0
- package/dist/src/react/settings/compiler-settings.d.ts +11 -0
- package/dist/src/react/settings/compiler-settings.d.ts.map +1 -0
- package/dist/src/react/settings/compiler-settings.js +42 -0
- package/dist/src/react/settings/compiler-settings.js.map +1 -0
- package/dist/src/react/settings/emitter-options-form.d.ts +10 -0
- package/dist/src/react/settings/emitter-options-form.d.ts.map +1 -0
- package/dist/src/react/settings/emitter-options-form.js +39 -0
- package/dist/src/react/settings/emitter-options-form.js.map +1 -0
- package/dist/src/react/settings/linter-form.d.ts +10 -0
- package/dist/src/react/settings/linter-form.d.ts.map +1 -0
- package/dist/src/react/settings/linter-form.js +33 -0
- package/dist/src/react/settings/linter-form.js.map +1 -0
- package/dist/src/react/standalone.d.ts +9 -0
- package/dist/src/react/standalone.d.ts.map +1 -0
- package/dist/src/react/standalone.js +63 -0
- package/dist/src/react/standalone.js.map +1 -0
- package/dist/src/react/swagger-ui.d.ts +6 -0
- package/dist/src/react/swagger-ui.d.ts.map +1 -0
- package/dist/src/react/swagger-ui.js +19 -0
- package/dist/src/react/swagger-ui.js.map +1 -0
- package/dist/src/react/types.d.ts +26 -0
- package/dist/src/react/types.d.ts.map +1 -0
- package/dist/src/react/types.js +2 -0
- package/dist/src/react/types.js.map +1 -0
- package/dist/src/react/typespec-editor.d.ts +12 -0
- package/dist/src/react/typespec-editor.d.ts.map +1 -0
- package/dist/src/react/typespec-editor.js +30 -0
- package/dist/src/react/typespec-editor.js.map +1 -0
- package/dist/src/react/viewers.d.ts +3 -0
- package/dist/src/react/viewers.d.ts.map +1 -0
- package/dist/src/react/viewers.js +8 -0
- package/dist/src/react/viewers.js.map +1 -0
- package/dist/src/services.d.ts +6 -0
- package/dist/src/services.d.ts.map +1 -0
- package/dist/src/services.js +323 -0
- package/dist/src/services.js.map +1 -0
- package/dist/src/state-storage.d.ts +21 -0
- package/dist/src/state-storage.d.ts.map +1 -0
- package/dist/src/state-storage.js +81 -0
- package/dist/src/state-storage.js.map +1 -0
- package/dist/src/types.d.ts +11 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils.d.ts +8 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +14 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/src/vite/index.d.ts +4 -0
- package/dist/src/vite/index.d.ts.map +1 -0
- package/dist/src/vite/index.js +92 -0
- package/dist/src/vite/index.js.map +1 -0
- package/dist/src/vite/types.d.ts +15 -0
- package/dist/src/vite/types.d.ts.map +1 -0
- package/dist/src/vite/types.js +2 -0
- package/dist/src/vite/types.js.map +1 -0
- package/dist/vite.config.d.ts +3 -0
- package/dist/vite.config.d.ts.map +1 -0
- package/dist/vite.config.js +38 -0
- package/dist/vite.config.js.map +1 -0
- package/package.json +96 -0
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# TypeSpec Playground
|
|
2
|
+
|
|
3
|
+
Contains react components for the TypeSpec playground.
|
|
4
|
+
|
|
5
|
+
It can be used as a standalone custom playground with your own libraries or components can be used individually to customize the UI as you see fit.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
### Standalone
|
|
10
|
+
|
|
11
|
+
The stanalone playground provides some vite helpers to make it easy to get started.
|
|
12
|
+
|
|
13
|
+
In `vite.config.ts`:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { definePlaygroundViteConfig } from "@typespec/playground/vite";
|
|
17
|
+
|
|
18
|
+
const config = definePlaygroundViteConfig({
|
|
19
|
+
defaultEmitter: "@typespec/openapi3",
|
|
20
|
+
libraries: [
|
|
21
|
+
"@typespec/compiler",
|
|
22
|
+
"@typespec/http",
|
|
23
|
+
"@typespec/openapi3",
|
|
24
|
+
|
|
25
|
+
// Add any other libraries here. Make sure those libraries are also dependencies of that package.
|
|
26
|
+
],
|
|
27
|
+
samples: {
|
|
28
|
+
"My sample": {
|
|
29
|
+
filename: "samples/my.tsp",
|
|
30
|
+
preferredEmitter: "@typespec/openapi3",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
links: {
|
|
34
|
+
githubIssueUrl: `<link to your website>`,
|
|
35
|
+
documentationUrl: "<link to your website>",
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export default config;
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
In `src/main.tsx`:
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import { PlaygroundManifest } from "@typespec/playground/manifest";
|
|
46
|
+
import { renderReactPlayground } from "@typespec/playground/react";
|
|
47
|
+
import { SwaggerUIViewer } from "@typespec/playground/react/viewers";
|
|
48
|
+
import "./style.css";
|
|
49
|
+
|
|
50
|
+
await renderReactPlayground({
|
|
51
|
+
...PlaygroundManifest,
|
|
52
|
+
emitterViewers: {
|
|
53
|
+
"@typespec/openapi3": [SwaggerUIViewer],
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Individual components
|
|
59
|
+
|
|
60
|
+
Playground react components can be used individually. The things to watch out for is for the TypeSpec compiler to be working correctly it needs:
|
|
61
|
+
|
|
62
|
+
- The libraries to be loaded and registered
|
|
63
|
+
- The libraries **MUST** be importable by their name this means an import map must be setup. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap
|
|
64
|
+
- The libraries **MUST** have been bundled using `@typespec/bundler`
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CompilerHost } from "@typespec/compiler";
|
|
2
|
+
export interface BrowserHost extends CompilerHost {
|
|
3
|
+
}
|
|
4
|
+
export declare function resolveVirtualPath(path: string, ...paths: string[]): string;
|
|
5
|
+
/**
|
|
6
|
+
* Create the browser host from the list of libraries.
|
|
7
|
+
* @param libsToLoad List of libraries to load. Those must be set in the webpage importmap.
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function createBrowserHost(libsToLoad: string[]): Promise<BrowserHost>;
|
|
11
|
+
//# sourceMappingURL=browser-host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-host.d.ts","sourceRoot":"","sources":["../../src/browser-host.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAIb,MAAM,oBAAoB,CAAC;AAG5B,MAAM,WAAW,WAAY,SAAQ,YAAY;CAAG;AAEpD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,UAElE;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAoIlF"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { createSourceFile, getSourceFileKindFromExt, resolvePath, } from "@typespec/compiler";
|
|
2
|
+
import { importLibrary } from "./core.js";
|
|
3
|
+
export function resolveVirtualPath(path, ...paths) {
|
|
4
|
+
return resolvePath("/test", path, ...paths);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Create the browser host from the list of libraries.
|
|
8
|
+
* @param libsToLoad List of libraries to load. Those must be set in the webpage importmap.
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export async function createBrowserHost(libsToLoad) {
|
|
12
|
+
const virtualFs = new Map();
|
|
13
|
+
const jsImports = new Map();
|
|
14
|
+
for (const libName of libsToLoad) {
|
|
15
|
+
const { _TypeSpecLibrary_ } = (await importLibrary(libName));
|
|
16
|
+
for (const [key, value] of Object.entries(_TypeSpecLibrary_.typespecSourceFiles)) {
|
|
17
|
+
virtualFs.set(`/test/node_modules/${libName}/${key}`, value);
|
|
18
|
+
}
|
|
19
|
+
for (const [key, value] of Object.entries(_TypeSpecLibrary_.jsSourceFiles)) {
|
|
20
|
+
addJsImport(`/test/node_modules/${libName}/${key}`, value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function addJsImport(path, value) {
|
|
24
|
+
virtualFs.set(path, "");
|
|
25
|
+
jsImports.set(path, value);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
async readUrl(url) {
|
|
29
|
+
const contents = virtualFs.get(url);
|
|
30
|
+
if (contents === undefined) {
|
|
31
|
+
const e = new Error(`File ${url} not found.`);
|
|
32
|
+
e.code = "ENOENT";
|
|
33
|
+
throw e;
|
|
34
|
+
}
|
|
35
|
+
return createSourceFile(contents, url);
|
|
36
|
+
},
|
|
37
|
+
async readFile(path) {
|
|
38
|
+
path = resolveVirtualPath(path);
|
|
39
|
+
const contents = virtualFs.get(path);
|
|
40
|
+
if (contents === undefined) {
|
|
41
|
+
const e = new Error(`File ${path} not found.`);
|
|
42
|
+
e.code = "ENOENT";
|
|
43
|
+
throw e;
|
|
44
|
+
}
|
|
45
|
+
return createSourceFile(contents, path);
|
|
46
|
+
},
|
|
47
|
+
async writeFile(path, content) {
|
|
48
|
+
path = resolveVirtualPath(path);
|
|
49
|
+
virtualFs.set(path, content);
|
|
50
|
+
},
|
|
51
|
+
async readDir(path) {
|
|
52
|
+
path = resolveVirtualPath(path);
|
|
53
|
+
const fileFolder = [...virtualFs.keys()]
|
|
54
|
+
.filter((x) => x.startsWith(`${path}/`))
|
|
55
|
+
.map((x) => x.replace(`${path}/`, ""))
|
|
56
|
+
.map((x) => {
|
|
57
|
+
const index = x.indexOf("/");
|
|
58
|
+
return index !== -1 ? x.substring(0, index) : x;
|
|
59
|
+
});
|
|
60
|
+
return [...new Set(fileFolder)];
|
|
61
|
+
},
|
|
62
|
+
async rm(path) {
|
|
63
|
+
path = resolveVirtualPath(path);
|
|
64
|
+
for (const key of virtualFs.keys()) {
|
|
65
|
+
if (key === path || key.startsWith(`${path}/`)) {
|
|
66
|
+
virtualFs.delete(key);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
getLibDirs() {
|
|
71
|
+
return [resolveVirtualPath("/test/node_modules/@typespec/compiler/lib")];
|
|
72
|
+
},
|
|
73
|
+
getExecutionRoot() {
|
|
74
|
+
return resolveVirtualPath(".tsp");
|
|
75
|
+
},
|
|
76
|
+
async getJsImport(path) {
|
|
77
|
+
path = resolveVirtualPath(path);
|
|
78
|
+
const module = await jsImports.get(path);
|
|
79
|
+
if (module === undefined) {
|
|
80
|
+
const e = new Error(`Module ${path} not found`);
|
|
81
|
+
e.code = "MODULE_NOT_FOUND";
|
|
82
|
+
throw e;
|
|
83
|
+
}
|
|
84
|
+
return module;
|
|
85
|
+
},
|
|
86
|
+
async stat(path) {
|
|
87
|
+
path = resolveVirtualPath(path);
|
|
88
|
+
if (virtualFs.has(path)) {
|
|
89
|
+
return {
|
|
90
|
+
isDirectory() {
|
|
91
|
+
return false;
|
|
92
|
+
},
|
|
93
|
+
isFile() {
|
|
94
|
+
return true;
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
for (const fsPath of virtualFs.keys()) {
|
|
99
|
+
if (fsPath.startsWith(path) && fsPath !== path) {
|
|
100
|
+
return {
|
|
101
|
+
isDirectory() {
|
|
102
|
+
return true;
|
|
103
|
+
},
|
|
104
|
+
isFile() {
|
|
105
|
+
return false;
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const e = new Error(`File ${path} not found.`);
|
|
111
|
+
e.code = "ENOENT";
|
|
112
|
+
throw e;
|
|
113
|
+
},
|
|
114
|
+
// symlinks not supported in test-host
|
|
115
|
+
async realpath(path) {
|
|
116
|
+
return path;
|
|
117
|
+
},
|
|
118
|
+
getSourceFileKind: getSourceFileKindFromExt,
|
|
119
|
+
logSink: console,
|
|
120
|
+
mkdirp: async (path) => path,
|
|
121
|
+
fileURLToPath(path) {
|
|
122
|
+
return path.replace("inmemory:/", "");
|
|
123
|
+
},
|
|
124
|
+
pathToFileURL(path) {
|
|
125
|
+
return "inmemory:/" + resolveVirtualPath(path);
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=browser-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-host.js","sourceRoot":"","sources":["../../src/browser-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAI1C,MAAM,UAAU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AK,CAAC;oBACf,CAAC;oBACD,MAAM;wBACJ,OAAO,IAAI,CAAC;oBACd,CAAC;iBACF,CAAC;aACH;YAED,KAAK,MAAM,MAAM,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE;gBACrC,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,MAAM,KAAK,IAAI,EAAE;oBAC9C,OAAO;wBACL,WAAW;4BACT,OAAO,IAAI,CAAC;wBACd,CAAC;wBACD,MAAM;4BACJ,OAAO,KAAK,CAAC;wBACf,CAAC;qBACF,CAAC;iBACH;aACF;YACD,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,QAAQ,IAAI,aAAa,CAAC,CAAC;YAC9C,CAAS,CAAC,IAAI,GAAG,QAAQ,CAAC;YAC3B,MAAM,CAAC,CAAC;QACV,CAAC;QAED,sCAAsC;QACtC,KAAK,CAAC,QAAQ,CAAC,IAAI;YACjB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,iBAAiB,EAAE,wBAAwB;QAE3C,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,KAAK,EAAE,IAAY,EAAE,EAAE,CAAC,IAAI;QACpC,aAAa,CAAC,IAAI;YAChB,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QACxC,CAAC;QACD,aAAa,CAAC,IAAI;YAChB,OAAO,YAAY,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACjD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function importTypeSpecCompiler(): Promise<typeof import("@typespec/compiler")>;
|
|
2
|
+
/**
|
|
3
|
+
* @param name Import name.
|
|
4
|
+
* @returns Promise with the loaded module.
|
|
5
|
+
*/
|
|
6
|
+
export declare function importLibrary(name: string): Promise<unknown>;
|
|
7
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AACA,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,cAAc,oBAAoB,CAAC,CAAC,CAQ3F;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAElE"}
|
package/dist/src/core.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
let cachedCompiler;
|
|
2
|
+
export async function importTypeSpecCompiler() {
|
|
3
|
+
if (cachedCompiler === undefined) {
|
|
4
|
+
// We need to do this so the compiler loaded is the same as the one loaded by the bundled libraries.
|
|
5
|
+
const name = "@typespec/compiler";
|
|
6
|
+
cachedCompiler = (await importLibrary(name));
|
|
7
|
+
}
|
|
8
|
+
return cachedCompiler;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @param name Import name.
|
|
12
|
+
* @returns Promise with the loaded module.
|
|
13
|
+
*/
|
|
14
|
+
export async function importLibrary(name) {
|
|
15
|
+
return import(/* @vite-ignore */ name);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAAA,IAAI,cAAmB,CAAC;AACxB,MAAM,CAAC,KAAK,UAAU,sBAAsB;IAC1C,IAAI,cAAc,KAAK,SAAS,EAAE;QAChC,oGAAoG;QACpG,MAAM,IAAI,GAAG,oBAAoB,CAAC;QAClC,cAAc,GAAG,CAAC,MAAM,aAAa,CAAC,IAAI,CAAC,CAAQ,CAAC;KACrD;IAED,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAY;IAC9C,OAAO,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createBrowserHost } from "./browser-host.js";
|
|
2
|
+
export { registerMonacoDefaultWorkers } from "./monaco-worker.js";
|
|
3
|
+
export { registerMonacoLanguage } from "./services.js";
|
|
4
|
+
export { createUrlStateStorage } from "./state-storage.js";
|
|
5
|
+
export { PlaygroundSample } from "./types.js";
|
|
6
|
+
export { resolveLibraries as filterEmitters } from "./utils.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,gBAAgB,IAAI,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createBrowserHost } from "./browser-host.js";
|
|
2
|
+
export { registerMonacoDefaultWorkers } from "./monaco-worker.js";
|
|
3
|
+
export { registerMonacoLanguage } from "./services.js";
|
|
4
|
+
export { createUrlStateStorage } from "./state-storage.js";
|
|
5
|
+
export { resolveLibraries as filterEmitters } from "./utils.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,IAAI,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/manifest.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,eAAO,MAAM,kBAAkB,EAAE,gBAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/manifest.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,aAAa;AACb,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAG9C,MAAM,CAAC,MAAM,kBAAkB,GAAqB,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monaco-worker.d.ts","sourceRoot":"","sources":["../../src/monaco-worker.ts"],"names":[],"mappings":"AAOA,wBAAgB,4BAA4B,SAU3C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
import editorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker";
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import jsonWorker from "monaco-editor/esm/vs/language/json/json.worker?worker";
|
|
7
|
+
export function registerMonacoDefaultWorkers() {
|
|
8
|
+
self.MonacoEnvironment = {
|
|
9
|
+
createTrustedTypesPolicy: () => undefined,
|
|
10
|
+
getWorker(_, label) {
|
|
11
|
+
if (label === "json") {
|
|
12
|
+
return new jsonWorker();
|
|
13
|
+
}
|
|
14
|
+
return new editorWorker();
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=monaco-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monaco-worker.js","sourceRoot":"","sources":["../../src/monaco-worker.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,aAAa;AACb,OAAO,YAAY,MAAM,kDAAkD,CAAC;AAC5E,6DAA6D;AAC7D,aAAa;AACb,OAAO,UAAU,MAAM,uDAAuD,CAAC;AAE/E,MAAM,UAAU,4BAA4B;IAC1C,IAAI,CAAC,iBAAiB,GAAG;QACvB,wBAAwB,EAAE,GAAG,EAAE,CAAC,SAAS;QACzC,SAAS,CAAC,CAAM,EAAE,KAAa;YAC7B,IAAI,KAAK,KAAK,MAAM,EAAE;gBACpB,OAAO,IAAI,UAAU,EAAE,CAAC;aACzB;YACD,OAAO,IAAI,YAAY,EAAE,CAAC;QAC5B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Diagnostic } from "@typespec/compiler";
|
|
2
|
+
import { FunctionComponent } from "react";
|
|
3
|
+
export interface DiagnosticListProps {
|
|
4
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
5
|
+
}
|
|
6
|
+
export declare const DiagnosticList: FunctionComponent<DiagnosticListProps>;
|
|
7
|
+
export interface DiagnosticItemProps {
|
|
8
|
+
readonly diagnostic: Diagnostic;
|
|
9
|
+
}
|
|
10
|
+
export declare const DiagnosticItem: FunctionComponent<DiagnosticItemProps>;
|
|
11
|
+
//# sourceMappingURL=diagnostic-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic-list.d.ts","sourceRoot":"","sources":["../../../src/react/diagnostic-list.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED,eAAO,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,CAWjE,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;CACjC;AAED,eAAO,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,CAYjE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { css } from "@emotion/react";
|
|
3
|
+
export const DiagnosticList = ({ diagnostics }) => {
|
|
4
|
+
if (diagnostics.length === 0) {
|
|
5
|
+
return _jsx("div", { className: "center", children: "No errors" });
|
|
6
|
+
}
|
|
7
|
+
return (_jsx("div", { css: { height: "100%", overflow: "auto" }, children: diagnostics.map((x, i) => {
|
|
8
|
+
return _jsx(DiagnosticItem, { diagnostic: x }, i);
|
|
9
|
+
}) }));
|
|
10
|
+
};
|
|
11
|
+
export const DiagnosticItem = ({ diagnostic }) => {
|
|
12
|
+
return (_jsxs("div", { css: { display: "flex" }, children: [_jsx("div", { css: [{ padding: "0 5px" }, diagnostic.severity === "error" ? errorColor : warningColor], children: diagnostic.severity }), _jsx("div", { css: { padding: "0 5px", color: "#333333" }, children: diagnostic.code }), _jsx("div", { css: { padding: "0 5px" }, children: diagnostic.message })] }));
|
|
13
|
+
};
|
|
14
|
+
const errorColor = css({ color: "#cc2222" });
|
|
15
|
+
const warningColor = css({ color: "orange" });
|
|
16
|
+
//# sourceMappingURL=diagnostic-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic-list.js","sourceRoot":"","sources":["../../../src/react/diagnostic-list.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAQrC,MAAM,CAAC,MAAM,cAAc,GAA2C,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE;IACxF,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;QAC5B,OAAO,cAAK,SAAS,EAAC,QAAQ,0BAAgB,CAAC;KAChD;IACD,OAAO,CACL,cAAK,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAC3C,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACxB,OAAO,KAAC,cAAc,IAAS,UAAU,EAAE,CAAC,IAAhB,CAAC,CAAmB,CAAC;QACnD,CAAC,CAAC,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AAMF,MAAM,CAAC,MAAM,cAAc,GAA2C,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE;IACvF,OAAO,CACL,eAAK,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAC3B,cACE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,UAAU,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,YAEvF,UAAU,CAAC,QAAQ,GAChB,EACN,cAAK,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,YAAG,UAAU,CAAC,IAAI,GAAO,EACzE,cAAK,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,YAAG,UAAU,CAAC,OAAO,GAAO,IACtD,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;AAC7C,MAAM,YAAY,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CompilerOptions } from "@typespec/compiler";
|
|
2
|
+
import { FunctionComponent } from "react";
|
|
3
|
+
import { PlaygroundSample } from "../types.js";
|
|
4
|
+
import { PlaygroundTspLibrary } from "./types.js";
|
|
5
|
+
export interface EditorCommandBarProps {
|
|
6
|
+
documentationUrl?: string;
|
|
7
|
+
saveCode: () => Promise<void> | void;
|
|
8
|
+
newIssue?: () => Promise<void> | void;
|
|
9
|
+
libraries: PlaygroundTspLibrary[];
|
|
10
|
+
selectedEmitter: string;
|
|
11
|
+
onSelectedEmitterChange: (emitter: string) => void;
|
|
12
|
+
compilerOptions: CompilerOptions;
|
|
13
|
+
onCompilerOptionsChange: (options: CompilerOptions) => void;
|
|
14
|
+
samples?: Record<string, PlaygroundSample>;
|
|
15
|
+
selectedSampleName: string;
|
|
16
|
+
onSelectedSampleNameChange: (sampleName: string) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const EditorCommandBar: FunctionComponent<EditorCommandBarProps>;
|
|
19
|
+
//# sourceMappingURL=editor-command-bar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-command-bar.d.ts","sourceRoot":"","sources":["../../../src/react/editor-command-bar.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,WAAW,qBAAqB;IACpC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACtC,SAAS,EAAE,oBAAoB,EAAE,CAAC;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,uBAAuB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,eAAe,EAAE,eAAe,CAAC;IACjC,uBAAuB,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IAE5D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC3C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1D;AACD,eAAO,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,CAmErE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Button, Dialog, DialogBody, DialogSurface, DialogTrigger, Link, Toolbar, ToolbarButton, Tooltip, } from "@fluentui/react-components";
|
|
3
|
+
import { Bug16Regular, Save16Regular, Settings24Regular } from "@fluentui/react-icons";
|
|
4
|
+
import { EmitterDropdown } from "./emitter-dropdown.js";
|
|
5
|
+
import { SamplesDropdown } from "./samples-dropdown.js";
|
|
6
|
+
import { CompilerSettings } from "./settings/compiler-settings.js";
|
|
7
|
+
export const EditorCommandBar = ({ documentationUrl, saveCode, newIssue, libraries, selectedEmitter, onSelectedEmitterChange, compilerOptions: emitterOptions, onCompilerOptionsChange, samples, selectedSampleName, onSelectedSampleNameChange, }) => {
|
|
8
|
+
const documentation = documentationUrl ? (_jsx("label", { children: _jsx(Link, { href: documentationUrl, target: "_blank", children: "Docs" }) })) : undefined;
|
|
9
|
+
const bugButton = newIssue ? _jsx(FileBugButton, { onClick: newIssue }) : undefined;
|
|
10
|
+
return (_jsx("div", { css: { borderBottom: "1px solid #f5f5f5" }, children: _jsxs(Toolbar, { children: [_jsx(Tooltip, { content: "Save", relationship: "description", withArrow: true, children: _jsx(ToolbarButton, { appearance: "primary", "aria-label": "Save", icon: _jsx(Save16Regular, {}), onClick: saveCode }) }), samples && (_jsx(SamplesDropdown, { samples: samples, selectedSampleName: selectedSampleName, onSelectedSampleNameChange: onSelectedSampleNameChange })), _jsx(EmitterDropdown, { emitters: libraries.filter((x) => x.isEmitter).map((x) => x.name), onSelectedEmitterChange: onSelectedEmitterChange, selectedEmitter: selectedEmitter }), _jsxs(Dialog, { children: [_jsx(DialogTrigger, { children: _jsx(Button, { icon: _jsx(Settings24Regular, {}) }) }), _jsx(DialogSurface, { children: _jsx(DialogBody, { children: _jsx(CompilerSettings, { libraries: libraries, selectedEmitter: selectedEmitter, options: emitterOptions, onOptionsChanged: onCompilerOptionsChange }) }) })] }), documentation, _jsx("div", { css: { flex: "1" } }), bugButton] }) }));
|
|
11
|
+
};
|
|
12
|
+
const FileBugButton = ({ onClick }) => {
|
|
13
|
+
return (_jsx(Tooltip, { content: "File Bug Report", relationship: "description", withArrow: true, children: _jsx(ToolbarButton, { appearance: "subtle", "aria-label": "File Bug Report", icon: _jsx(Bug16Regular, {}), onClick: onClick, children: "File bug" }) }));
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=editor-command-bar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-command-bar.js","sourceRoot":"","sources":["../../../src/react/editor-command-bar.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,UAAU,EACV,aAAa,EACb,aAAa,EACb,IAAI,EACJ,OAAO,EACP,aAAa,EACb,OAAO,GACR,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAIvF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAiBnE,MAAM,CAAC,MAAM,gBAAgB,GAA6C,CAAC,EACzE,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,eAAe,EACf,uBAAuB,EACvB,eAAe,EAAE,cAAc,EAC/B,uB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,OAAO,EAAE,cAAc,EACvB,gBAAgB,EAAE,uBAAuB,GACzC,GACS,GACC,IACT,EACR,aAAa,EACd,cAAK,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,GAAQ,EAC9B,SAAS,IACF,GACN,CACP,CAAC;AACJ,CAAC,CAAC;AAKF,MAAM,aAAa,GAA0C,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;IAC3E,OAAO,CACL,KAAC,OAAO,IAAC,OAAO,EAAC,iBAAiB,EAAC,YAAY,EAAC,aAAa,EAAC,SAAS,kBACrE,KAAC,aAAa,IACZ,UAAU,EAAC,QAAQ,gBACR,iBAAiB,EAC5B,IAAI,EAAE,KAAC,YAAY,KAAG,EACtB,OAAO,EAAE,OAAc,yBAGT,GACR,CACX,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { editor } from "monaco-editor";
|
|
2
|
+
import { FunctionComponent } from "react";
|
|
3
|
+
export interface EditorProps {
|
|
4
|
+
model: editor.IModel;
|
|
5
|
+
actions?: editor.IActionDescriptor[];
|
|
6
|
+
options: editor.IStandaloneEditorConstructionOptions;
|
|
7
|
+
}
|
|
8
|
+
export interface EditorCommand {
|
|
9
|
+
binding: number;
|
|
10
|
+
handle: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const Editor: FunctionComponent<EditorProps>;
|
|
13
|
+
export declare function useMonacoModel(uri: string, language?: string): editor.IModel;
|
|
14
|
+
//# sourceMappingURL=editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../src/react/editor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAoB,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAA8B,MAAM,OAAO,CAAC;AAEtE,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,iBAAiB,EAAE,CAAC;IACrC,OAAO,EAAE,MAAM,CAAC,oCAAoC,CAAC;CACtD;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,eAAO,MAAM,MAAM,EAAE,iBAAiB,CAAC,WAAW,CAmCjD,CAAC;AAEF,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAK5E"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { editor, Uri } from "monaco-editor";
|
|
3
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
4
|
+
export const Editor = ({ model, options, actions }) => {
|
|
5
|
+
const editorContainerRef = useRef(null);
|
|
6
|
+
const editorRef = useRef(null);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
editorRef.current = editor.create(editorContainerRef.current, {
|
|
9
|
+
model,
|
|
10
|
+
automaticLayout: true,
|
|
11
|
+
...options,
|
|
12
|
+
});
|
|
13
|
+
}, []);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const disposables = [];
|
|
16
|
+
for (const command of actions !== null && actions !== void 0 ? actions : []) {
|
|
17
|
+
disposables.push(editorRef.current.addAction(command));
|
|
18
|
+
}
|
|
19
|
+
return () => {
|
|
20
|
+
disposables.forEach((x) => x.dispose());
|
|
21
|
+
};
|
|
22
|
+
}, [actions]);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (editorRef.current) {
|
|
25
|
+
editorRef.current.setModel(model);
|
|
26
|
+
}
|
|
27
|
+
}, [model]);
|
|
28
|
+
return (_jsx("div", { className: "monaco-editor-container", css: { width: "100%", height: "100%", overflow: "hidden" }, ref: editorContainerRef }));
|
|
29
|
+
};
|
|
30
|
+
export function useMonacoModel(uri, language) {
|
|
31
|
+
return useMemo(() => {
|
|
32
|
+
var _a;
|
|
33
|
+
const monacoUri = Uri.parse(uri);
|
|
34
|
+
return (_a = editor.getModel(monacoUri)) !== null && _a !== void 0 ? _a : editor.createModel("", language, monacoUri);
|
|
35
|
+
}, [uri, language]);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.js","sourceRoot":"","sources":["../../../src/react/editor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAe,GAAG,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAqB,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAatE,MAAM,CAAC,MAAM,MAAM,GAAmC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;IACpF,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,SAAS,GAAG,MAAM,CAAsC,IAAI,CAAC,CAAC;IAEpE,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,OAAQ,EAAE;YAC7D,KAAK;YACL,eAAe,EAAE,IAAI;YACrB,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,WAAW,GAAkB,EAAE,CAAC;QACtC,KAAK,MAAM,OAAO,IAAI,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,EAAE;YACnC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,OAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;SACzD;QACD,OAAO,GAAG,EAAE;YACV,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1C,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,CAAC,OAAO,EAAE;YACrB,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;SACnC;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CACL,cACE,SAAS,EAAC,yBAAyB,EACnC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAC1D,GAAG,EAAE,kBAAkB,GAClB,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,QAAiB;IAC3D,OAAO,OAAO,CAAC,GAAG,EAAE;;QAClB,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjC,OAAO,MAAA,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,mCAAI,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IACnF,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FunctionComponent } from "react";
|
|
2
|
+
export type EmitterDropdownProps = {
|
|
3
|
+
emitters: string[];
|
|
4
|
+
selectedEmitter: string;
|
|
5
|
+
onSelectedEmitterChange: (emitter: string) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const EmitterDropdown: FunctionComponent<EmitterDropdownProps>;
|
|
8
|
+
//# sourceMappingURL=emitter-dropdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitter-dropdown.d.ts","sourceRoot":"","sources":["../../../src/react/emitter-dropdown.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAe,MAAM,OAAO,CAAC;AAEvD,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,uBAAuB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAC,oBAAoB,CAuBnE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Select } from "@fluentui/react-components";
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
export const EmitterDropdown = ({ emitters, onSelectedEmitterChange, selectedEmitter, }) => {
|
|
5
|
+
const options = emitters.map((emitterName) => {
|
|
6
|
+
return _jsx("option", { children: emitterName }, emitterName);
|
|
7
|
+
});
|
|
8
|
+
const handleSelected = useCallback((evt) => {
|
|
9
|
+
onSelectedEmitterChange(evt.target.value);
|
|
10
|
+
}, [onSelectedEmitterChange]);
|
|
11
|
+
return (_jsxs(Select, { className: "sample-dropdown", onChange: handleSelected, value: selectedEmitter, children: [_jsx("option", { value: "", disabled: true, children: "Select emitter..." }), options] }));
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=emitter-dropdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitter-dropdown.js","sourceRoot":"","sources":["../../../src/react/emitter-dropdown.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAqB,WAAW,EAAE,MAAM,OAAO,CAAC;AAQvD,MAAM,CAAC,MAAM,eAAe,GAA4C,CAAC,EACvE,QAAQ,EACR,uBAAuB,EACvB,eAAe,GAChB,EAAE,EAAE;IACH,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE;QAC3C,OAAO,2BAA2B,WAAW,IAAzB,WAAW,CAAwB,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,GAAQ,EAAE,EAAE;QACX,uBAAuB,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC,EACD,CAAC,uBAAuB,CAAC,CAC1B,CAAC;IACF,OAAO,CACL,MAAC,MAAM,IAAC,SAAS,EAAC,iBAAiB,EAAC,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,eAAe,aAClF,iBAAQ,KAAK,EAAC,EAAE,EAAC,QAAQ,wCAEhB,EACR,OAAO,IACD,CACV,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Diagnostic } from "@typespec/compiler";
|
|
2
|
+
import { FunctionComponent } from "react";
|
|
3
|
+
export interface ErrorTabProps {
|
|
4
|
+
readonly internalCompilerError?: any;
|
|
5
|
+
readonly diagnostics?: readonly Diagnostic[];
|
|
6
|
+
}
|
|
7
|
+
export declare const ErrorTab: FunctionComponent<ErrorTabProps>;
|
|
8
|
+
export interface InternalCompilerErrorProps {
|
|
9
|
+
readonly error?: any;
|
|
10
|
+
}
|
|
11
|
+
export declare const InternalCompilerError: FunctionComponent<InternalCompilerErrorProps>;
|
|
12
|
+
//# sourceMappingURL=error-tab.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-tab.d.ts","sourceRoot":"","sources":["../../../src/react/error-tab.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG1C,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,qBAAqB,CAAC,EAAE,GAAG,CAAC;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;CAC9C;AAED,eAAO,MAAM,QAAQ,EAAE,iBAAiB,CAAC,aAAa,CAUrD,CAAC;AACF,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC;CACtB;AAED,eAAO,MAAM,qBAAqB,EAAE,iBAAiB,CAAC,0BAA0B,CAiB/E,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { css } from "@emotion/react";
|
|
3
|
+
import { DiagnosticList } from "./diagnostic-list.js";
|
|
4
|
+
export const ErrorTab = ({ internalCompilerError, diagnostics, }) => {
|
|
5
|
+
return (_jsxs(_Fragment, { children: [internalCompilerError && _jsx(InternalCompilerError, { error: internalCompilerError }), diagnostics && _jsx(DiagnosticList, { diagnostics: diagnostics })] }));
|
|
6
|
+
};
|
|
7
|
+
export const InternalCompilerError = ({ error }) => {
|
|
8
|
+
return (_jsx("div", { css: { CenterStyles }, children: _jsxs("div", { css: {
|
|
9
|
+
border: "1px solid #cc2222",
|
|
10
|
+
padding: "10px",
|
|
11
|
+
margin: "20px",
|
|
12
|
+
}, children: [_jsx("h3", { children: "Internal Compiler error" }), _jsx("div", { children: "File issue at https://github.com/microsoft/typespec" }), _jsx("hr", {}), _jsx("div", { children: error.stack })] }) }));
|
|
13
|
+
};
|
|
14
|
+
const CenterStyles = css({
|
|
15
|
+
display: "flex",
|
|
16
|
+
height: "100%",
|
|
17
|
+
alignItems: "center",
|
|
18
|
+
justifyContent: "center",
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=error-tab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-tab.js","sourceRoot":"","sources":["../../../src/react/error-tab.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAGrC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAOtD,MAAM,CAAC,MAAM,QAAQ,GAAqC,CAAC,EACzD,qBAAqB,EACrB,WAAW,GACZ,EAAE,EAAE;IACH,OAAO,CACL,8BACG,qBAAqB,IAAI,KAAC,qBAAqB,IAAC,KAAK,EAAE,qBAAqB,GAAI,EAChF,WAAW,IAAI,KAAC,cAAc,IAAC,WAAW,EAAE,WAAW,GAAI,IAC3D,CACJ,CAAC;AACJ,CAAC,CAAC;AAKF,MAAM,CAAC,MAAM,qBAAqB,GAAkD,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAChG,OAAO,CACL,cAAK,GAAG,EAAE,EAAE,YAAY,EAAE,YACxB,eACE,GAAG,EAAE;gBACH,MAAM,EAAE,mBAAmB;gBAC3B,OAAO,EAAE,MAAM;gBACf,MAAM,EAAE,MAAM;aACf,aAED,mDAAgC,EAChC,gFAA8D,EAC9D,cAAM,EACN,wBAAM,KAAK,CAAC,KAAK,GAAO,IACpB,GACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,GAAG,CAAC;IACvB,OAAO,EAAE,MAAM;IACf,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,QAAQ;IACpB,cAAc,EAAE,QAAQ;CACzB,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FunctionComponent } from "react";
|
|
2
|
+
import { FileOutputViewer } from "./types.js";
|
|
3
|
+
export interface FileOutputProps {
|
|
4
|
+
filename: string;
|
|
5
|
+
content: string;
|
|
6
|
+
viewers: FileOutputViewer[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Display a file output using different viewers.
|
|
10
|
+
*/
|
|
11
|
+
export declare const FileOutput: FunctionComponent<FileOutputProps>;
|
|
12
|
+
//# sourceMappingURL=file-output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-output.d.ts","sourceRoot":"","sources":["../../../src/react/file-output.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAkC,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CAgCzD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { css } from "@emotion/react";
|
|
3
|
+
import { Select } from "@fluentui/react-components";
|
|
4
|
+
import { useCallback, useMemo, useState } from "react";
|
|
5
|
+
/**
|
|
6
|
+
* Display a file output using different viewers.
|
|
7
|
+
*/
|
|
8
|
+
export const FileOutput = ({ filename, content, viewers }) => {
|
|
9
|
+
if (viewers.length === 0) {
|
|
10
|
+
return _jsx(_Fragment, { children: "No viewers" });
|
|
11
|
+
}
|
|
12
|
+
else if (viewers.length === 1) {
|
|
13
|
+
return viewers[0].render({ filename, content });
|
|
14
|
+
}
|
|
15
|
+
const [selected, setSelected] = useState(viewers[0].key);
|
|
16
|
+
const handleSelected = useCallback((_, data) => {
|
|
17
|
+
setSelected(data.value);
|
|
18
|
+
}, [selected]);
|
|
19
|
+
const selectedRender = useMemo(() => {
|
|
20
|
+
var _a;
|
|
21
|
+
return (_a = viewers.find((x) => x.key === selected)) === null || _a === void 0 ? void 0 : _a.render;
|
|
22
|
+
}, [selected, viewers]);
|
|
23
|
+
return (_jsxs("div", { css: { width: "100%", height: "100%", overflow: "hidden" }, children: [_jsx(Select, { value: selected, onChange: handleSelected, css: DropdownStyle, children: viewers.map(({ key, label }) => (_jsx("option", { value: key, children: label }, key))) }), selectedRender && selectedRender({ filename, content })] }));
|
|
24
|
+
};
|
|
25
|
+
const DropdownStyle = css({
|
|
26
|
+
margin: "0.5rem 1.5rem",
|
|
27
|
+
position: "absolute",
|
|
28
|
+
"z-index": 1,
|
|
29
|
+
right: 0,
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=file-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-output.js","sourceRoot":"","sources":["../../../src/react/file-output.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,MAAM,EAAsB,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAqB,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAS1E;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAuC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;IAC/F,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,OAAO,2CAAe,CAAC;KACxB;SAAM,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QAC/B,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;KACjD;IAED,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAS,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEjE,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,CAAU,EAAE,IAAwB,EAAE,EAAE;QACvC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,EAAE;;QAClC,OAAO,MAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,QAAQ,CA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