@typespec/playground 0.13.0-dev.3 → 0.13.0-dev.4
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-
|
|
1
|
+
export { c as createBrowserHost, r as registerMonacoLanguage } from './services-Z619RuQS.js';
|
|
2
2
|
export { createUrlStateStorage } from './state-storage.js';
|
|
3
3
|
|
|
4
4
|
function registerMonacoDefaultWorkersForVite() {
|
package/dist/react/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { $ } from '@typespec/compiler/typekit';
|
|
|
7
7
|
import { DocumentBulletList24Regular, Dismiss24Regular, Save16Regular, Broom16Filled, Bug16Regular, SettingsRegular, FolderListRegular, DataLineRegular, ErrorCircle16Filled, Warning16Filled, ChevronDown16Regular } from '@fluentui/react-icons';
|
|
8
8
|
import debounce from 'debounce';
|
|
9
9
|
import { CompletionItemTag } from 'vscode-languageserver';
|
|
10
|
-
import { a as resolveVirtualPath, p as printDebugInfo, d as debugGlobals, g as getMonacoRange, u as updateDiagnosticsForCodeFixes, c as createBrowserHost, r as registerMonacoLanguage } from '../services-
|
|
10
|
+
import { a as resolveVirtualPath, p as printDebugInfo, d as debugGlobals, g as getMonacoRange, u as updateDiagnosticsForCodeFixes, c as createBrowserHost, r as registerMonacoLanguage } from '../services-Z619RuQS.js';
|
|
11
11
|
import { stringify, parse } from 'yaml';
|
|
12
12
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
13
13
|
import { TypeGraph } from '@typespec/html-program-viewer/react';
|
|
@@ -47,24 +47,32 @@ function resolveVirtualPath(path, ...paths) {
|
|
|
47
47
|
function createBrowserHostInternal(options) {
|
|
48
48
|
const virtualFs = /* @__PURE__ */ new Map();
|
|
49
49
|
const jsImports = /* @__PURE__ */ new Map();
|
|
50
|
-
const libraries =
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
const libraries = {
|
|
51
|
+
...options.libraries
|
|
52
|
+
};
|
|
53
|
+
function registerLibraryFiles(libName, lib) {
|
|
54
|
+
for (const [key, value] of Object.entries(lib._TypeSpecLibrary_.typespecSourceFiles)) {
|
|
53
55
|
virtualFs.set(`/test/node_modules/${libName}/${key}`, value);
|
|
54
56
|
}
|
|
55
|
-
for (const [key, value] of Object.entries(_TypeSpecLibrary_.jsSourceFiles)) {
|
|
57
|
+
for (const [key, value] of Object.entries(lib._TypeSpecLibrary_.jsSourceFiles)) {
|
|
56
58
|
addJsImport(`/test/node_modules/${libName}/${key}`, value);
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Object.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
function updatePackageJson() {
|
|
62
|
+
virtualFs.set(
|
|
63
|
+
`/test/package.json`,
|
|
64
|
+
JSON.stringify({
|
|
65
|
+
name: "playground-pkg",
|
|
66
|
+
dependencies: Object.fromEntries(
|
|
67
|
+
Object.values(libraries).map((x) => [x.name, x.packageJson.version])
|
|
68
|
+
)
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
for (const [libName, lib] of Object.entries(libraries)) {
|
|
73
|
+
registerLibraryFiles(libName, lib);
|
|
74
|
+
}
|
|
75
|
+
updatePackageJson();
|
|
68
76
|
function addJsImport(path, value) {
|
|
69
77
|
virtualFs.set(path, "");
|
|
70
78
|
jsImports.set(path, value);
|
|
@@ -174,24 +182,33 @@ function createBrowserHostInternal(options) {
|
|
|
174
182
|
}
|
|
175
183
|
};
|
|
176
184
|
}
|
|
185
|
+
async function loadLibraries(libsToLoad, importOptions = {}) {
|
|
186
|
+
const entries = await Promise.all(
|
|
187
|
+
libsToLoad.map(async (libName) => {
|
|
188
|
+
const { _TypeSpecLibrary_, $lib, $linter } = await importLibrary(
|
|
189
|
+
libName,
|
|
190
|
+
importOptions
|
|
191
|
+
);
|
|
192
|
+
const lib = {
|
|
193
|
+
name: libName,
|
|
194
|
+
isEmitter: $lib?.emitter,
|
|
195
|
+
definition: $lib,
|
|
196
|
+
packageJson: JSON.parse(_TypeSpecLibrary_.typespecSourceFiles["package.json"]),
|
|
197
|
+
linter: $linter,
|
|
198
|
+
_TypeSpecLibrary_
|
|
199
|
+
};
|
|
200
|
+
return [libName, lib];
|
|
201
|
+
})
|
|
202
|
+
);
|
|
203
|
+
return Object.fromEntries(entries);
|
|
204
|
+
}
|
|
177
205
|
async function createBrowserHost(libsToLoad, importOptions = {}) {
|
|
178
|
-
const libraries =
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
importOptions
|
|
183
|
-
);
|
|
184
|
-
libraries[libName] = {
|
|
185
|
-
name: libName,
|
|
186
|
-
isEmitter: $lib?.emitter,
|
|
187
|
-
definition: $lib,
|
|
188
|
-
packageJson: JSON.parse(_TypeSpecLibrary_.typespecSourceFiles["package.json"]),
|
|
189
|
-
linter: $linter,
|
|
190
|
-
_TypeSpecLibrary_
|
|
191
|
-
};
|
|
192
|
-
}
|
|
206
|
+
const [libraries, compiler] = await Promise.all([
|
|
207
|
+
loadLibraries(libsToLoad, importOptions),
|
|
208
|
+
importTypeSpecCompiler(importOptions)
|
|
209
|
+
]);
|
|
193
210
|
return createBrowserHostInternal({
|
|
194
|
-
compiler
|
|
211
|
+
compiler,
|
|
195
212
|
libraries
|
|
196
213
|
});
|
|
197
214
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { LibraryImportOptions } from './core.js';
|
|
2
|
-
import { BrowserHost } from './types.js';
|
|
2
|
+
import { BrowserHost, PlaygroundTspLibrary } from './types.js';
|
|
3
3
|
export declare function resolveVirtualPath(path: string, ...paths: string[]): string;
|
|
4
|
+
/**
|
|
5
|
+
* Load libraries in parallel from the given list.
|
|
6
|
+
* @param libsToLoad List of library names. Must be available in the webpage importmap.
|
|
7
|
+
* @param importOptions Import configuration.
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadLibraries(libsToLoad: readonly string[], importOptions?: LibraryImportOptions): Promise<Record<string, PlaygroundTspLibrary & {
|
|
10
|
+
_TypeSpecLibrary_: any;
|
|
11
|
+
}>>;
|
|
4
12
|
/**
|
|
5
13
|
* Create the browser host from the list of libraries.
|
|
6
14
|
* @param libsToLoad List of libraries to load. Those must be set in the webpage importmap.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-host.d.ts","sourceRoot":"","sources":["../../src/browser-host.ts"],"names":[],"mappings":"AACA,OAAO,EAAyC,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC7F,OAAO,KAAK,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"browser-host.d.ts","sourceRoot":"","sources":["../../src/browser-host.ts"],"names":[],"mappings":"AACA,OAAO,EAAyC,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC7F,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEpE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,UAElE;AAmLD;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,aAAa,GAAE,oBAAyB,GACvC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG;IAAE,iBAAiB,EAAE,GAAG,CAAA;CAAE,CAAC,CAAC,CAmB5E;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,aAAa,GAAE,oBAAyB,GACvC,OAAO,CAAC,WAAW,CAAC,CAStB"}
|