@typespec/playground 0.6.0-dev.1 → 0.6.0-dev.3
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/index.js +2 -1
- package/dist/react/index.js +5 -4
- package/dist/{state-storage-DqG2VXgn.js → services-VCejxTUV.js} +1 -82
- package/dist/src/react/editor.d.ts.map +1 -1
- package/dist/src/react/playground.d.ts.map +1 -1
- package/dist/src/services.d.ts.map +1 -1
- package/dist/state-storage.js +82 -0
- package/dist/vite.config.d.ts.map +1 -1
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { c as createBrowserHost,
|
|
1
|
+
export { c as createBrowserHost, r as registerMonacoLanguage } from './services-VCejxTUV.js';
|
|
2
|
+
export { createUrlStateStorage } from './state-storage.js';
|
|
2
3
|
|
|
3
4
|
function registerMonacoDefaultWorkersForVite() {
|
|
4
5
|
self.MonacoEnvironment = {
|
package/dist/react/index.js
CHANGED
|
@@ -5,12 +5,13 @@ import { mergeClasses, Popover, PopoverTrigger, PopoverSurface, Title3, Table, T
|
|
|
5
5
|
import { Settings24Regular, Save16Regular, Broom16Filled, Bug16Regular, FolderListRegular, DataLineRegular, ErrorCircle16Filled, Warning16Filled, ChevronDown16Regular } from '@fluentui/react-icons';
|
|
6
6
|
import debounce from 'debounce';
|
|
7
7
|
import { CompletionItemTag } from 'vscode-languageserver';
|
|
8
|
-
import {
|
|
8
|
+
import { a as resolveVirtualPath, g as getMonacoRange, c as createBrowserHost, r as registerMonacoLanguage } from '../services-VCejxTUV.js';
|
|
9
9
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
10
10
|
import { TypeGraph } from '@typespec/html-program-viewer/react';
|
|
11
11
|
import '@typespec/html-program-viewer/style.css';
|
|
12
12
|
import { getSourceLocation } from '@typespec/compiler';
|
|
13
13
|
import { createRoot } from 'react-dom/client';
|
|
14
|
+
import { createUrlStateStorage } from '../state-storage.js';
|
|
14
15
|
|
|
15
16
|
const PlaygroundContext = createContext(void 0);
|
|
16
17
|
const PlaygroundContextProvider = PlaygroundContext.Provider;
|
|
@@ -33,9 +34,6 @@ const Editor = ({ model, options, actions, onMount }) => {
|
|
|
33
34
|
});
|
|
34
35
|
onMount?.({ editor: editorRef.current });
|
|
35
36
|
}, []);
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
editor.setTheme(options.theme ?? "typespec");
|
|
38
|
-
}, [options.theme]);
|
|
39
37
|
useEffect(() => {
|
|
40
38
|
const disposables = [];
|
|
41
39
|
for (const command of actions ?? []) {
|
|
@@ -2599,6 +2597,9 @@ const ProblemPaneContent = ({
|
|
|
2599
2597
|
const Playground = (props) => {
|
|
2600
2598
|
const { host, onSave } = props;
|
|
2601
2599
|
const editorRef = useRef(void 0);
|
|
2600
|
+
useEffect(() => {
|
|
2601
|
+
editor.setTheme(props.editorOptions?.theme ?? "typespec");
|
|
2602
|
+
}, [props.editorOptions?.theme]);
|
|
2602
2603
|
const [selectedEmitter, onSelectedEmitterChange] = useControllableValue(
|
|
2603
2604
|
props.emitter,
|
|
2604
2605
|
props.defaultEmitter,
|
|
@@ -3,7 +3,6 @@ import * as monaco from 'monaco-editor';
|
|
|
3
3
|
import * as lsp from 'vscode-languageserver';
|
|
4
4
|
import { DiagnosticSeverity, FormattingOptions, DocumentHighlightKind } from 'vscode-languageserver';
|
|
5
5
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
6
|
-
import lzutf8 from 'lzutf8';
|
|
7
6
|
|
|
8
7
|
async function importTypeSpecCompiler(config) {
|
|
9
8
|
return await importLibrary("@typespec/compiler", config);
|
|
@@ -519,7 +518,6 @@ async function registerMonacoLanguage(host) {
|
|
|
519
518
|
{ token: "function", foreground: "#E06C75" }
|
|
520
519
|
]
|
|
521
520
|
});
|
|
522
|
-
monaco.editor.setTheme("typespec");
|
|
523
521
|
monaco.languages.registerDocumentSemanticTokensProvider("typespec", {
|
|
524
522
|
getLegend() {
|
|
525
523
|
const legend = lsConfig.capabilities.semanticTokensProvider.legend;
|
|
@@ -576,83 +574,4 @@ function getMonacoRange(typespecCompiler, target) {
|
|
|
576
574
|
};
|
|
577
575
|
}
|
|
578
576
|
|
|
579
|
-
|
|
580
|
-
return { load, save, resolveSearchParams };
|
|
581
|
-
function load() {
|
|
582
|
-
const result = {};
|
|
583
|
-
const parsed = new URLSearchParams(window.location.search);
|
|
584
|
-
for (const [key, item] of Object.entries(schema)) {
|
|
585
|
-
const value = parsed.get(item.queryParam);
|
|
586
|
-
const decompressed = value && decompress(item, value);
|
|
587
|
-
const deserialized = decompressed && deserialize(item, decompressed);
|
|
588
|
-
if (deserialized) {
|
|
589
|
-
result[key] = deserialized;
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
return result;
|
|
593
|
-
}
|
|
594
|
-
function decompress(item, value) {
|
|
595
|
-
if (item.compress) {
|
|
596
|
-
try {
|
|
597
|
-
return lzutf8.decompress(value, { inputEncoding: "Base64" });
|
|
598
|
-
} catch (e) {
|
|
599
|
-
console.error(
|
|
600
|
-
`Error decompressing query parameter ${item.queryParam} with content:`,
|
|
601
|
-
value
|
|
602
|
-
);
|
|
603
|
-
return void 0;
|
|
604
|
-
}
|
|
605
|
-
} else {
|
|
606
|
-
return value;
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
function deserialize(item, value) {
|
|
610
|
-
if (item.type === "object") {
|
|
611
|
-
try {
|
|
612
|
-
return JSON.parse(value);
|
|
613
|
-
} catch (e) {
|
|
614
|
-
console.error(
|
|
615
|
-
`Error decompressing query parameter ${item.queryParam} with content:`,
|
|
616
|
-
value
|
|
617
|
-
);
|
|
618
|
-
return void 0;
|
|
619
|
-
}
|
|
620
|
-
} else {
|
|
621
|
-
return value;
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
function save(data) {
|
|
625
|
-
const params = resolveSearchParams(data, true);
|
|
626
|
-
history.pushState(null, "", window.location.pathname + "?" + params.toString());
|
|
627
|
-
}
|
|
628
|
-
function resolveSearchParams(data, mergeWithExisting = false) {
|
|
629
|
-
const params = new URLSearchParams(mergeWithExisting ? location.search : void 0);
|
|
630
|
-
for (const [key, item] of Object.entries(schema)) {
|
|
631
|
-
const value = data[key];
|
|
632
|
-
if (value) {
|
|
633
|
-
const serialized = serialize(item, value);
|
|
634
|
-
const compressed = compress(item, serialized);
|
|
635
|
-
params.set(item.queryParam, compressed);
|
|
636
|
-
} else {
|
|
637
|
-
params.delete(item.queryParam);
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
return params;
|
|
641
|
-
}
|
|
642
|
-
function compress(item, value) {
|
|
643
|
-
if (item.compress) {
|
|
644
|
-
return lzutf8.compress(value, { outputEncoding: "Base64" });
|
|
645
|
-
} else {
|
|
646
|
-
return value;
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
function serialize(item, value) {
|
|
650
|
-
if (item.type === "object") {
|
|
651
|
-
return JSON.stringify(value);
|
|
652
|
-
} else {
|
|
653
|
-
return value;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
export { createUrlStateStorage as a, resolveVirtualPath as b, createBrowserHost as c, getMonacoRange as g, registerMonacoLanguage as r };
|
|
577
|
+
export { resolveVirtualPath as a, createBrowserHost as c, getMonacoRange as g, registerMonacoLanguage as r };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../src/react/editor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,MAAM,EAAoB,MAAM,eAAe,CAAC;AAC9D,OAAO,EAA8B,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE3E,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;IACrD,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC,qBAAqB,CAAC;CACtC;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,eAAO,MAAM,MAAM,EAAE,iBAAiB,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../src/react/editor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,MAAM,EAAoB,MAAM,eAAe,CAAC;AAC9D,OAAO,EAA8B,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE3E,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;IACrD,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC,qBAAqB,CAAC;CACtC;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,eAAO,MAAM,MAAM,EAAE,iBAAiB,CAAC,WAAW,CAuCjD,CAAC;AAEF,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAK5E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../../../src/react/playground.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,oBAAoB,CAAC;AAEtE,OAAO,sC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2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAC;IAEhB,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAEhB,uBAAuB;IACvB,OAAO,CAAC,EAAE,eAAe,CAAC;IAE1B,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,4BAA4B;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CAgOzD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/services.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EAEd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAKxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAmC9C,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/services.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EAEd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAKxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAmC9C,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,WAAW,iBAgU7D;AAED,wBAAgB,cAAc,CAC5B,gBAAgB,EAAE,cAAc,oBAAoB,CAAC,EACrD,MAAM,EAAE,gBAAgB,GAAG,OAAO,QAAQ,GACzC,MAAM,CAAC,MAAM,CAkBf"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import lzutf8 from 'lzutf8';
|
|
2
|
+
|
|
3
|
+
function createUrlStateStorage(schema) {
|
|
4
|
+
return { load, save, resolveSearchParams };
|
|
5
|
+
function load() {
|
|
6
|
+
const result = {};
|
|
7
|
+
const parsed = new URLSearchParams(window.location.search);
|
|
8
|
+
for (const [key, item] of Object.entries(schema)) {
|
|
9
|
+
const value = parsed.get(item.queryParam);
|
|
10
|
+
const decompressed = value && decompress(item, value);
|
|
11
|
+
const deserialized = decompressed && deserialize(item, decompressed);
|
|
12
|
+
if (deserialized) {
|
|
13
|
+
result[key] = deserialized;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
function decompress(item, value) {
|
|
19
|
+
if (item.compress) {
|
|
20
|
+
try {
|
|
21
|
+
return lzutf8.decompress(value, { inputEncoding: "Base64" });
|
|
22
|
+
} catch (e) {
|
|
23
|
+
console.error(
|
|
24
|
+
`Error decompressing query parameter ${item.queryParam} with content:`,
|
|
25
|
+
value
|
|
26
|
+
);
|
|
27
|
+
return void 0;
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function deserialize(item, value) {
|
|
34
|
+
if (item.type === "object") {
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(value);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.error(
|
|
39
|
+
`Error decompressing query parameter ${item.queryParam} with content:`,
|
|
40
|
+
value
|
|
41
|
+
);
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function save(data) {
|
|
49
|
+
const params = resolveSearchParams(data, true);
|
|
50
|
+
history.pushState(null, "", window.location.pathname + "?" + params.toString());
|
|
51
|
+
}
|
|
52
|
+
function resolveSearchParams(data, mergeWithExisting = false) {
|
|
53
|
+
const params = new URLSearchParams(mergeWithExisting ? location.search : void 0);
|
|
54
|
+
for (const [key, item] of Object.entries(schema)) {
|
|
55
|
+
const value = data[key];
|
|
56
|
+
if (value) {
|
|
57
|
+
const serialized = serialize(item, value);
|
|
58
|
+
const compressed = compress(item, serialized);
|
|
59
|
+
params.set(item.queryParam, compressed);
|
|
60
|
+
} else {
|
|
61
|
+
params.delete(item.queryParam);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return params;
|
|
65
|
+
}
|
|
66
|
+
function compress(item, value) {
|
|
67
|
+
if (item.compress) {
|
|
68
|
+
return lzutf8.compress(value, { outputEncoding: "Base64" });
|
|
69
|
+
} else {
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function serialize(item, value) {
|
|
74
|
+
if (item.type === "object") {
|
|
75
|
+
return JSON.stringify(value);
|
|
76
|
+
} else {
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { createUrlStateStorage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.config.d.ts","sourceRoot":"","sources":["../vite.config.ts"],"names":[],"mappings":";AAwBA,
|
|
1
|
+
{"version":3,"file":"vite.config.d.ts","sourceRoot":"","sources":["../vite.config.ts"],"names":[],"mappings":";AAwBA,wBAyCG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/playground",
|
|
3
|
-
"version": "0.6.0-dev.
|
|
3
|
+
"version": "0.6.0-dev.3",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec playground UI components.",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
"types": "./dist/src/index.d.ts",
|
|
24
24
|
"default": "./dist/index.js"
|
|
25
25
|
},
|
|
26
|
+
"./state-storage": {
|
|
27
|
+
"types": "./dist/src/state-storage.d.ts",
|
|
28
|
+
"default": "./dist/state-storage.js"
|
|
29
|
+
},
|
|
26
30
|
"./vite": {
|
|
27
31
|
"types": "./dist/src/vite/index.d.ts",
|
|
28
32
|
"default": "./dist/vite/index.js"
|
|
@@ -58,7 +62,7 @@
|
|
|
58
62
|
"@fluentui/react-components": "~9.55.0",
|
|
59
63
|
"@fluentui/react-icons": "^2.0.260",
|
|
60
64
|
"@typespec/bundler": "~0.1.8 || >=0.2.0-dev <0.2.0",
|
|
61
|
-
"@typespec/compiler": "~0.61.
|
|
65
|
+
"@typespec/compiler": "~0.61.2 || >=0.62.0-dev <0.62.0",
|
|
62
66
|
"@typespec/html-program-viewer": "~0.61.0 || >=0.62.0-dev <0.62.0",
|
|
63
67
|
"@typespec/http": "~0.61.0 || >=0.62.0-dev <0.62.0",
|
|
64
68
|
"@typespec/openapi": "~0.61.0 || >=0.62.0-dev <0.62.0",
|