@typespec/playground 0.9.0 → 0.10.0-dev.1

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 CHANGED
@@ -1,4 +1,4 @@
1
- export { c as createBrowserHost, r as registerMonacoLanguage } from './services-BOARIFqT.js';
1
+ export { c as createBrowserHost, r as registerMonacoLanguage } from './services-C9EUyi1Z.js';
2
2
  export { createUrlStateStorage } from './state-storage.js';
3
3
 
4
4
  function registerMonacoDefaultWorkersForVite() {
@@ -2,10 +2,11 @@ import require$$0, { createContext, useContext, useRef, useEffect, useMemo, memo
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import { editor, Uri, MarkerSeverity, KeyMod, KeyCode } from 'monaco-editor';
4
4
  import { mergeClasses, Popover, PopoverTrigger, PopoverSurface, Title3, Table, TableHeader, TableRow, TableHeaderCell, TableBody, TableCell, Select, useId, Label, Checkbox, RadioGroup, Radio, Input, Switch, Divider, Dialog, DialogTrigger, ToolbarButton, DialogSurface, DialogBody, DialogTitle, DialogContent, Toolbar, Tooltip, Link, TabList, Tab, Button, useToastController, Toast, ToastTitle, ToastBody, Toaster, FluentProvider, webLightTheme } from '@fluentui/react-components';
5
+ import { $ } from '@typespec/compiler/typekit';
5
6
  import { Settings24Regular, Save16Regular, Broom16Filled, Bug16Regular, FolderListRegular, DataLineRegular, ErrorCircle16Filled, Warning16Filled, ChevronDown16Regular } from '@fluentui/react-icons';
6
7
  import debounce from 'debounce';
7
8
  import { CompletionItemTag } from 'vscode-languageserver';
8
- import { a as resolveVirtualPath, g as getMonacoRange, c as createBrowserHost, r as registerMonacoLanguage } from '../services-BOARIFqT.js';
9
+ import { a as resolveVirtualPath, p as printDebugInfo, d as debugGlobals, g as getMonacoRange, c as createBrowserHost, r as registerMonacoLanguage } from '../services-C9EUyi1Z.js';
9
10
  import { ErrorBoundary } from 'react-error-boundary';
10
11
  import { TypeGraph } from '@typespec/html-program-viewer/react';
11
12
  import '@typespec/html-program-viewer/style.css';
@@ -2814,6 +2815,10 @@ const Playground = (props) => {
2814
2815
  useEffect(() => {
2815
2816
  editor.setTheme(props.editorOptions?.theme ?? "typespec");
2816
2817
  }, [props.editorOptions?.theme]);
2818
+ useEffect(() => {
2819
+ printDebugInfo();
2820
+ debugGlobals().host = host;
2821
+ }, [host]);
2817
2822
  const typespecModel = useMonacoModel("inmemory://test/main.tsp", "typespec");
2818
2823
  const [compilationState, setCompilationState] = useState(void 0);
2819
2824
  const state = usePlaygroundState({
@@ -2869,6 +2874,8 @@ const Playground = (props) => {
2869
2874
  severity: diag.severity === "error" ? MarkerSeverity.Error : MarkerSeverity.Warning,
2870
2875
  tags: diag.code === "deprecated" ? [CompletionItemTag.Deprecated] : void 0
2871
2876
  }));
2877
+ debugGlobals().program = state2.program;
2878
+ debugGlobals().$$ = $(state2.program);
2872
2879
  editor.setModelMarkers(typespecModel, "owner", markers ?? []);
2873
2880
  } else {
2874
2881
  editor.setModelMarkers(typespecModel, "owner", []);
@@ -4,15 +4,37 @@ import * as lsp from 'vscode-languageserver';
4
4
  import { DiagnosticSeverity, FormattingOptions, DocumentHighlightKind } from 'vscode-languageserver';
5
5
  import { TextDocument } from 'vscode-languageserver-textdocument';
6
6
 
7
+ function printDebugInfo() {
8
+ console.info("TypeSpec Playground");
9
+ console.info(
10
+ "Some variables are bound to the `window` object in the browser console for debugging."
11
+ );
12
+ console.info(" - `program`: The current TypeSpec program.");
13
+ console.info(" - `host`: The current compiler host.");
14
+ console.info(" - `compiler`: The TypeSpec compiler API.");
15
+ console.info(" - `$$`: A Typekit instance bound to the current program.");
16
+ console.info(" - `libs`: A map of all loaded TypeSpec libraries.");
17
+ }
18
+ function debugGlobals() {
19
+ return window;
20
+ }
21
+ function debugLibs() {
22
+ return window.libs ??= {};
23
+ }
24
+
7
25
  async function importTypeSpecCompiler(config) {
8
- return await importLibrary("@typespec/compiler", config);
26
+ const compiler = await importLibrary("@typespec/compiler", config);
27
+ debugGlobals().compiler = compiler;
28
+ return compiler;
9
29
  }
10
30
  async function importLibrary(name, config) {
11
- return config.useShim ? importShim(name) : import(
31
+ const lib = await (config.useShim ? importShim(name) : import(
12
32
  /* @vite-ignore */
13
33
  /* webpackIgnore: true */
14
34
  name
15
- );
35
+ ));
36
+ debugLibs()[name] = lib;
37
+ return lib;
16
38
  }
17
39
  async function importShim(name) {
18
40
  return window.importShim(name);
@@ -574,4 +596,4 @@ function getMonacoRange(typespecCompiler, target) {
574
596
  };
575
597
  }
576
598
 
577
- export { resolveVirtualPath as a, createBrowserHost as c, getMonacoRange as g, registerMonacoLanguage as r };
599
+ export { resolveVirtualPath as a, createBrowserHost as c, debugGlobals as d, getMonacoRange as g, printDebugInfo as p, registerMonacoLanguage as r };
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,cAAc,oBAAoB,CAAC,CAAC,CAE9C;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,CAIhG"}
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,cAAc,oBAAoB,CAAC,CAAC,CAM9C;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,CAQhG"}
@@ -0,0 +1,38 @@
1
+ import { Program } from '@typespec/compiler';
2
+ import { Typekit } from '@typespec/compiler/typekit';
3
+ import { BrowserHost } from '../types.js';
4
+ export interface DebugGlobals {
5
+ /**
6
+ * The current TypeSpec program.
7
+ */
8
+ program: Program | undefined;
9
+ /**
10
+ * The compiler host.
11
+ */
12
+ host: BrowserHost | undefined;
13
+ /**
14
+ * The TypeSpec compiler API.
15
+ */
16
+ compiler: typeof import("@typespec/compiler") | undefined;
17
+ /**
18
+ * Global Typekit instance bound to the current program.
19
+ */
20
+ $$: Typekit | undefined;
21
+ /**
22
+ * A map of all loaded TypeSpec libraries.
23
+ */
24
+ libs: Record<string, unknown> | undefined;
25
+ }
26
+ /**
27
+ * Prints debug information to the console.
28
+ */
29
+ export declare function printDebugInfo(): void;
30
+ /**
31
+ * Get the global debug variables bound to the `window` object.
32
+ */
33
+ export declare function debugGlobals(): DebugGlobals;
34
+ /**
35
+ * Gets the global debug libraries
36
+ */
37
+ export declare function debugLibs(): Record<string, unknown>;
38
+ //# sourceMappingURL=debug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../src/react/debug.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAE7B;;OAEG;IACH,IAAI,EAAE,WAAW,GAAG,SAAS,CAAC;IAE9B;;OAEG;IACH,QAAQ,EAAE,cAAc,oBAAoB,CAAC,GAAG,SAAS,CAAC;IAE1D;;OAEG;IACH,EAAE,EAAE,OAAO,GAAG,SAAS,CAAC;IAExB;;OAEG;IACH,IAAI,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C3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CAiPzD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/playground",
3
- "version": "0.9.0",
3
+ "version": "0.10.0-dev.1",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec playground UI components.",
6
6
  "homepage": "https://typespec.io",
@@ -61,6 +61,15 @@
61
61
  "dependencies": {
62
62
  "@fluentui/react-components": "~9.66.1",
63
63
  "@fluentui/react-icons": "^2.0.292",
64
+ "@typespec/bundler": "^0.4.2 || >=0.5.0-dev <0.5.0",
65
+ "@typespec/compiler": "^1.2.1",
66
+ "@typespec/html-program-viewer": "^0.72.1 || >=0.73.0-dev <0.73.0",
67
+ "@typespec/http": "^1.2.1",
68
+ "@typespec/openapi": "^1.2.1",
69
+ "@typespec/openapi3": "^1.2.1",
70
+ "@typespec/protobuf": "^0.72.1 || >=0.73.0-dev <0.73.0",
71
+ "@typespec/rest": "^0.72.1 || >=0.73.0-dev <0.73.0",
72
+ "@typespec/versioning": "^0.72.1 || >=0.73.0-dev <0.73.0",
64
73
  "clsx": "^2.1.1",
65
74
  "debounce": "~2.2.0",
66
75
  "lzutf8": "0.6.3",
@@ -70,16 +79,7 @@
70
79
  "react-error-boundary": "^6.0.0",
71
80
  "swagger-ui-dist": "^5.20.1",
72
81
  "vscode-languageserver": "~9.0.1",
73
- "vscode-languageserver-textdocument": "~1.0.12",
74
- "@typespec/bundler": "^0.4.2",
75
- "@typespec/compiler": "^1.2.0",
76
- "@typespec/http": "^1.2.0",
77
- "@typespec/html-program-viewer": "^0.72.0",
78
- "@typespec/openapi": "^1.2.0",
79
- "@typespec/protobuf": "^0.72.0",
80
- "@typespec/rest": "^0.72.0",
81
- "@typespec/versioning": "^0.72.0",
82
- "@typespec/openapi3": "^1.2.0"
82
+ "vscode-languageserver-textdocument": "~1.0.12"
83
83
  },
84
84
  "devDependencies": {
85
85
  "@babel/core": "^7.26.10",
@@ -91,6 +91,7 @@
91
91
  "@types/react": "~18.3.11",
92
92
  "@types/react-dom": "~18.3.0",
93
93
  "@types/swagger-ui-dist": "~3.30.5",
94
+ "@typespec/bundler": "^0.4.2 || >=0.5.0-dev <0.5.0",
94
95
  "@vitejs/plugin-react": "~4.4.1",
95
96
  "c8": "^10.1.3",
96
97
  "cross-env": "~7.0.3",
@@ -101,9 +102,9 @@
101
102
  "vite": "^6.2.7",
102
103
  "vite-plugin-checker": "^0.9.1",
103
104
  "vite-plugin-dts": "4.5.4",
104
- "@typespec/bundler": "^0.4.2",
105
105
  "@typespec/react-components": "^0.57.0"
106
106
  },
107
+ "peerDependencies": {},
107
108
  "scripts": {
108
109
  "clean": "rimraf ./dist ./dist-dev ./temp ./typespecContents.json",
109
110
  "build": "vite build",