sandlot 0.1.4 → 0.2.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/browser/bundler.d.ts +68 -0
- package/dist/browser/bundler.d.ts.map +1 -0
- package/dist/browser/executor.d.ts +46 -0
- package/dist/browser/executor.d.ts.map +1 -0
- package/dist/browser/index.d.ts +9 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +2690 -0
- package/dist/browser/preset.d.ts +63 -0
- package/dist/browser/preset.d.ts.map +1 -0
- package/dist/commands/index.d.ts +20 -11
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/types.d.ts +37 -130
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/core/bundler-utils.d.ts +142 -0
- package/dist/core/bundler-utils.d.ts.map +1 -0
- package/dist/core/esm-types-resolver.d.ts +125 -0
- package/dist/core/esm-types-resolver.d.ts.map +1 -0
- package/dist/core/executor.d.ts +35 -0
- package/dist/core/executor.d.ts.map +1 -0
- package/dist/{fs.d.ts → core/fs.d.ts} +27 -29
- package/dist/core/fs.d.ts.map +1 -0
- package/dist/core/sandbox.d.ts +30 -0
- package/dist/core/sandbox.d.ts.map +1 -0
- package/dist/core/sandlot.d.ts +30 -0
- package/dist/core/sandlot.d.ts.map +1 -0
- package/dist/core/shared-module-registry.d.ts +46 -0
- package/dist/core/shared-module-registry.d.ts.map +1 -0
- package/dist/core/typechecker.d.ts +60 -0
- package/dist/core/typechecker.d.ts.map +1 -0
- package/dist/index.d.ts +11 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1398 -2010
- package/dist/node/bundler.d.ts +48 -0
- package/dist/node/bundler.d.ts.map +1 -0
- package/dist/node/executor.d.ts +48 -0
- package/dist/node/executor.d.ts.map +1 -0
- package/dist/node/index.d.ts +9 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +2644 -0
- package/dist/node/preset.d.ts +62 -0
- package/dist/node/preset.d.ts.map +1 -0
- package/dist/types.d.ts +528 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +16 -6
- package/src/browser/bundler.ts +294 -0
- package/src/browser/executor.ts +71 -0
- package/src/browser/index.ts +57 -0
- package/src/browser/preset.ts +179 -0
- package/src/commands/index.ts +498 -37
- package/src/commands/types.ts +117 -145
- package/src/core/bundler-utils.ts +630 -0
- package/src/core/esm-types-resolver.ts +432 -0
- package/src/core/executor.ts +161 -0
- package/src/{fs.ts → core/fs.ts} +59 -37
- package/src/core/sandbox.ts +624 -0
- package/src/core/sandlot.ts +77 -0
- package/src/core/shared-module-registry.ts +138 -0
- package/src/core/typechecker.ts +609 -0
- package/src/index.ts +106 -139
- package/src/node/bundler.ts +194 -0
- package/src/node/executor.ts +87 -0
- package/src/node/index.ts +39 -0
- package/src/node/preset.ts +178 -0
- package/src/types.ts +672 -0
- package/README.md +0 -243
- package/dist/build-emitter.d.ts +0 -47
- package/dist/build-emitter.d.ts.map +0 -1
- package/dist/builder.d.ts +0 -370
- package/dist/builder.d.ts.map +0 -1
- package/dist/bundler.d.ts +0 -152
- package/dist/bundler.d.ts.map +0 -1
- package/dist/commands/compile.d.ts +0 -13
- package/dist/commands/compile.d.ts.map +0 -1
- package/dist/commands/packages.d.ts +0 -17
- package/dist/commands/packages.d.ts.map +0 -1
- package/dist/commands/run.d.ts +0 -40
- package/dist/commands/run.d.ts.map +0 -1
- package/dist/commands.d.ts +0 -179
- package/dist/commands.d.ts.map +0 -1
- package/dist/fs.d.ts.map +0 -1
- package/dist/internal.d.ts +0 -79
- package/dist/internal.d.ts.map +0 -1
- package/dist/internal.js +0 -1942
- package/dist/loader.d.ts +0 -164
- package/dist/loader.d.ts.map +0 -1
- package/dist/packages.d.ts +0 -199
- package/dist/packages.d.ts.map +0 -1
- package/dist/runner.d.ts +0 -314
- package/dist/runner.d.ts.map +0 -1
- package/dist/sandbox-manager.d.ts +0 -261
- package/dist/sandbox-manager.d.ts.map +0 -1
- package/dist/sandbox.d.ts +0 -267
- package/dist/sandbox.d.ts.map +0 -1
- package/dist/shared-modules.d.ts +0 -148
- package/dist/shared-modules.d.ts.map +0 -1
- package/dist/shared-resources.d.ts +0 -102
- package/dist/shared-resources.d.ts.map +0 -1
- package/dist/ts-libs.d.ts +0 -85
- package/dist/ts-libs.d.ts.map +0 -1
- package/dist/typechecker.d.ts +0 -127
- package/dist/typechecker.d.ts.map +0 -1
- package/src/build-emitter.ts +0 -64
- package/src/builder.ts +0 -498
- package/src/bundler.ts +0 -575
- package/src/commands/compile.ts +0 -236
- package/src/commands/packages.ts +0 -154
- package/src/commands/run.ts +0 -245
- package/src/internal.ts +0 -119
- package/src/loader.ts +0 -229
- package/src/packages.ts +0 -936
- package/src/sandbox.ts +0 -398
- package/src/shared-modules.ts +0 -280
- package/src/shared-resources.ts +0 -166
- package/src/ts-libs.ts +0 -218
- package/src/typechecker.ts +0 -635
package/src/shared-resources.ts
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared resources for sandbox environments.
|
|
3
|
-
*
|
|
4
|
-
* Provides centralized management of expensive shared resources:
|
|
5
|
-
* - TypeScript lib files (~5MB) - loaded once, shared across all sandboxes
|
|
6
|
-
* - esbuild WASM (~10MB) - singleton bundler initialization
|
|
7
|
-
* - Types cache - avoids redundant network fetches when multiple sandboxes
|
|
8
|
-
* install the same packages
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { fetchAndCacheLibs, getDefaultBrowserLibs } from "./ts-libs";
|
|
12
|
-
import { initBundler } from "./bundler";
|
|
13
|
-
import { InMemoryTypesCache, type TypesCache } from "./packages";
|
|
14
|
-
|
|
15
|
-
// Re-export for consumers
|
|
16
|
-
export type { TypesCache } from "./packages";
|
|
17
|
-
export { InMemoryTypesCache } from "./packages";
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Shared resources that can be reused across multiple sandboxes
|
|
21
|
-
*/
|
|
22
|
-
export interface SharedResources {
|
|
23
|
-
/**
|
|
24
|
-
* Pre-loaded TypeScript lib files for type checking
|
|
25
|
-
*/
|
|
26
|
-
libFiles: Map<string, string>;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Promise that resolves when the bundler is ready
|
|
30
|
-
*/
|
|
31
|
-
bundlerReady: Promise<void>;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Cache for package type definitions.
|
|
35
|
-
* Avoids redundant network fetches when multiple sandboxes
|
|
36
|
-
* install the same packages.
|
|
37
|
-
*/
|
|
38
|
-
typesCache: TypesCache;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Options for creating shared resources
|
|
43
|
-
*/
|
|
44
|
-
export interface SharedResourcesOptions {
|
|
45
|
-
/**
|
|
46
|
-
* TypeScript libs to load. Defaults to browser libs (ES2020 + DOM).
|
|
47
|
-
*/
|
|
48
|
-
libs?: string[];
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* If true, skip fetching TypeScript libs.
|
|
52
|
-
* libFiles will be an empty Map.
|
|
53
|
-
* Default: false
|
|
54
|
-
*/
|
|
55
|
-
skipLibs?: boolean;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* If true, skip pre-initializing the bundler.
|
|
59
|
-
* bundlerReady will resolve immediately.
|
|
60
|
-
* Default: false
|
|
61
|
-
*/
|
|
62
|
-
skipBundler?: boolean;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Create a new SharedResources instance.
|
|
67
|
-
*
|
|
68
|
-
* Use this when you want to manage resource lifecycle explicitly,
|
|
69
|
-
* or when you need custom libs configuration.
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* ```ts
|
|
73
|
-
* // Create resources with custom libs
|
|
74
|
-
* const resources = await createSharedResources({
|
|
75
|
-
* libs: ['es2022', 'dom', 'webworker'],
|
|
76
|
-
* });
|
|
77
|
-
*
|
|
78
|
-
* // Pass to sandbox creation
|
|
79
|
-
* const sandbox = await createSandbox({
|
|
80
|
-
* resources,
|
|
81
|
-
* fsOptions: { ... },
|
|
82
|
-
* });
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
export async function createSharedResources(
|
|
86
|
-
options: SharedResourcesOptions = {}
|
|
87
|
-
): Promise<SharedResources> {
|
|
88
|
-
const { libs = getDefaultBrowserLibs(), skipLibs = false, skipBundler = false } = options;
|
|
89
|
-
|
|
90
|
-
// Start both in parallel
|
|
91
|
-
const libsPromise = skipLibs
|
|
92
|
-
? Promise.resolve(new Map<string, string>())
|
|
93
|
-
: fetchAndCacheLibs(libs);
|
|
94
|
-
|
|
95
|
-
const bundlerPromise = skipBundler ? Promise.resolve() : initBundler();
|
|
96
|
-
|
|
97
|
-
// Create types cache (synchronous, just an in-memory Map)
|
|
98
|
-
const typesCache = new InMemoryTypesCache();
|
|
99
|
-
|
|
100
|
-
// Wait for async initialization
|
|
101
|
-
const [libFiles] = await Promise.all([libsPromise, bundlerPromise]);
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
libFiles,
|
|
105
|
-
bundlerReady: Promise.resolve(), // Already initialized
|
|
106
|
-
typesCache,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// ============ Module-level Singleton ============
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Module-level singleton for default shared resources.
|
|
114
|
-
* Used by createSandbox() when no resources are provided.
|
|
115
|
-
*/
|
|
116
|
-
let defaultResourcesInstance: SharedResources | null = null;
|
|
117
|
-
let defaultResourcesPromise: Promise<SharedResources> | null = null;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Get the default shared resources singleton.
|
|
121
|
-
*
|
|
122
|
-
* Loads resources once and returns the same instance for all callers.
|
|
123
|
-
* This is the recommended way to get shared resources for most use cases.
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
* ```ts
|
|
127
|
-
* // Get default resources (creates on first call)
|
|
128
|
-
* const resources = await getDefaultResources();
|
|
129
|
-
*
|
|
130
|
-
* // Create multiple sandboxes sharing the same resources
|
|
131
|
-
* const sandbox1 = await createSandbox({ resources, ... });
|
|
132
|
-
* const sandbox2 = await createSandbox({ resources, ... });
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
export async function getDefaultResources(): Promise<SharedResources> {
|
|
136
|
-
if (defaultResourcesInstance) {
|
|
137
|
-
return defaultResourcesInstance;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (!defaultResourcesPromise) {
|
|
141
|
-
defaultResourcesPromise = createSharedResources().then((resources) => {
|
|
142
|
-
defaultResourcesInstance = resources;
|
|
143
|
-
return resources;
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return defaultResourcesPromise;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Clear the default resources singleton (for testing).
|
|
152
|
-
*
|
|
153
|
-
* Note: This doesn't unload the bundler WASM - that stays in memory
|
|
154
|
-
* until page reload. This only clears the cached lib files reference.
|
|
155
|
-
*/
|
|
156
|
-
export function clearDefaultResources(): void {
|
|
157
|
-
defaultResourcesInstance = null;
|
|
158
|
-
defaultResourcesPromise = null;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Check if the default resources have been initialized.
|
|
163
|
-
*/
|
|
164
|
-
export function hasDefaultResources(): boolean {
|
|
165
|
-
return defaultResourcesInstance !== null;
|
|
166
|
-
}
|
package/src/ts-libs.ts
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeScript standard library fetcher and cache.
|
|
3
|
-
*
|
|
4
|
-
* Fetches TypeScript's lib.*.d.ts files from jsDelivr CDN and caches
|
|
5
|
-
* them in memory. These files provide types for built-in JavaScript APIs
|
|
6
|
-
* (Array, Number, String) and browser APIs (console, window, document).
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* TypeScript version to fetch libs for.
|
|
11
|
-
* MUST match the version in package.json dependencies.
|
|
12
|
-
*/
|
|
13
|
-
const TS_VERSION = "5.9.3";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* CDN base URL for TypeScript lib files
|
|
17
|
-
*/
|
|
18
|
-
const CDN_BASE = `https://cdn.jsdelivr.net/npm/typescript@${TS_VERSION}/lib`;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Default libs for browser environment with ES2020 target.
|
|
22
|
-
* These provide types for console, DOM APIs, and modern JS features.
|
|
23
|
-
*/
|
|
24
|
-
export function getDefaultBrowserLibs(): string[] {
|
|
25
|
-
return ["es2020", "dom", "dom.iterable"];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Parse `/// <reference lib="..." />` directives from a lib file.
|
|
30
|
-
* These directives indicate dependencies on other lib files.
|
|
31
|
-
*
|
|
32
|
-
* @param content - The content of a lib.*.d.ts file
|
|
33
|
-
* @returns Array of lib names referenced (without "lib." prefix or ".d.ts" suffix)
|
|
34
|
-
*/
|
|
35
|
-
export function parseLibReferences(content: string): string[] {
|
|
36
|
-
const refs: string[] = [];
|
|
37
|
-
const regex = /\/\/\/\s*<reference\s+lib="([^"]+)"\s*\/>/g;
|
|
38
|
-
let match;
|
|
39
|
-
|
|
40
|
-
while ((match = regex.exec(content)) !== null) {
|
|
41
|
-
if (match[1]) {
|
|
42
|
-
refs.push(match[1]);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return refs;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Convert a lib name to its filename.
|
|
51
|
-
* e.g., "es2020" -> "lib.es2020.d.ts"
|
|
52
|
-
*/
|
|
53
|
-
export function libNameToFileName(name: string): string {
|
|
54
|
-
return `lib.${name}.d.ts`;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Extract lib name from a file path.
|
|
59
|
-
* e.g., "/node_modules/typescript/lib/lib.es2020.d.ts" -> "es2020"
|
|
60
|
-
* "lib.dom.d.ts" -> "dom"
|
|
61
|
-
*/
|
|
62
|
-
export function extractLibName(filePath: string): string | null {
|
|
63
|
-
const match = filePath.match(/lib\.([^/]+)\.d\.ts$/);
|
|
64
|
-
return match?.[1] ?? null;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Fetch a single lib file from the CDN.
|
|
69
|
-
*
|
|
70
|
-
* @param name - The lib name (e.g., "es2020", "dom")
|
|
71
|
-
* @returns The content of the lib file
|
|
72
|
-
* @throws Error if the fetch fails
|
|
73
|
-
*/
|
|
74
|
-
export async function fetchLibFile(name: string): Promise<string> {
|
|
75
|
-
const fileName = libNameToFileName(name);
|
|
76
|
-
const url = `${CDN_BASE}/${fileName}`;
|
|
77
|
-
|
|
78
|
-
const response = await fetch(url);
|
|
79
|
-
if (!response.ok) {
|
|
80
|
-
throw new Error(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return response.text();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Recursively fetch all lib files needed for the given libs.
|
|
88
|
-
* Parses `/// <reference lib="..." />` directives and fetches dependencies.
|
|
89
|
-
*
|
|
90
|
-
* @param libs - Initial lib names to fetch (e.g., ["es2020", "dom"])
|
|
91
|
-
* @returns Map of lib name to content
|
|
92
|
-
*/
|
|
93
|
-
export async function fetchAllLibs(libs: string[]): Promise<Map<string, string>> {
|
|
94
|
-
const result = new Map<string, string>();
|
|
95
|
-
const pending = new Set<string>(libs);
|
|
96
|
-
const fetched = new Set<string>();
|
|
97
|
-
|
|
98
|
-
while (pending.size > 0) {
|
|
99
|
-
// Get next batch of libs to fetch
|
|
100
|
-
const batch = Array.from(pending);
|
|
101
|
-
pending.clear();
|
|
102
|
-
|
|
103
|
-
// Fetch all in parallel
|
|
104
|
-
const results = await Promise.all(
|
|
105
|
-
batch.map(async (name) => {
|
|
106
|
-
if (fetched.has(name)) {
|
|
107
|
-
return { name, content: null };
|
|
108
|
-
}
|
|
109
|
-
fetched.add(name);
|
|
110
|
-
|
|
111
|
-
try {
|
|
112
|
-
const content = await fetchLibFile(name);
|
|
113
|
-
return { name, content };
|
|
114
|
-
} catch (err) {
|
|
115
|
-
console.warn(`Failed to fetch lib.${name}.d.ts:`, err);
|
|
116
|
-
return { name, content: null };
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
// Process results and find new dependencies
|
|
122
|
-
for (const { name, content } of results) {
|
|
123
|
-
if (content === null) continue;
|
|
124
|
-
|
|
125
|
-
result.set(name, content);
|
|
126
|
-
|
|
127
|
-
// Parse references and add unfetched ones to pending
|
|
128
|
-
const refs = parseLibReferences(content);
|
|
129
|
-
for (const ref of refs) {
|
|
130
|
-
if (!fetched.has(ref) && !pending.has(ref)) {
|
|
131
|
-
pending.add(ref);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return result;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* In-memory cache for TypeScript lib files.
|
|
142
|
-
* Shared across all LibCache instances.
|
|
143
|
-
*/
|
|
144
|
-
let memoryCache: Map<string, string> | null = null;
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* LibCache provides in-memory caching for TypeScript lib files.
|
|
148
|
-
*
|
|
149
|
-
* Usage:
|
|
150
|
-
* ```ts
|
|
151
|
-
* const cache = new LibCache();
|
|
152
|
-
* const libs = await cache.getOrFetch(getDefaultBrowserLibs());
|
|
153
|
-
* ```
|
|
154
|
-
*/
|
|
155
|
-
export class LibCache {
|
|
156
|
-
/**
|
|
157
|
-
* Get cached libs if available, otherwise fetch from CDN and cache.
|
|
158
|
-
*
|
|
159
|
-
* @param libs - Lib names to fetch (e.g., ["es2020", "dom"])
|
|
160
|
-
* @returns Map of lib name to content (includes all transitive dependencies)
|
|
161
|
-
*/
|
|
162
|
-
async getOrFetch(libs: string[]): Promise<Map<string, string>> {
|
|
163
|
-
// Try to get from cache first
|
|
164
|
-
if (memoryCache) {
|
|
165
|
-
// Verify all requested libs are in cache
|
|
166
|
-
const missing = libs.filter((lib) => !memoryCache!.has(lib));
|
|
167
|
-
if (missing.length === 0) {
|
|
168
|
-
return memoryCache;
|
|
169
|
-
}
|
|
170
|
-
// Some libs missing, fetch all and update cache
|
|
171
|
-
console.log(`Cache missing libs: ${missing.join(", ")}, fetching all...`);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Fetch from CDN
|
|
175
|
-
console.log(`Fetching TypeScript libs from CDN: ${libs.join(", ")}...`);
|
|
176
|
-
const fetched = await fetchAllLibs(libs);
|
|
177
|
-
console.log(`Fetched ${fetched.size} lib files`);
|
|
178
|
-
|
|
179
|
-
// Cache the results
|
|
180
|
-
memoryCache = fetched;
|
|
181
|
-
|
|
182
|
-
return fetched;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Get cached libs if available.
|
|
187
|
-
*/
|
|
188
|
-
get(): Map<string, string> | null {
|
|
189
|
-
return memoryCache;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Store libs in the cache.
|
|
194
|
-
*/
|
|
195
|
-
set(libs: Map<string, string>): void {
|
|
196
|
-
memoryCache = libs;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Clear all cached libs.
|
|
201
|
-
*/
|
|
202
|
-
clear(): void {
|
|
203
|
-
memoryCache = null;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Convenience function to fetch and cache libs in one call.
|
|
209
|
-
*
|
|
210
|
-
* @param libs - Lib names to fetch (defaults to getDefaultBrowserLibs())
|
|
211
|
-
* @returns Map of lib name to content
|
|
212
|
-
*/
|
|
213
|
-
export async function fetchAndCacheLibs(
|
|
214
|
-
libs: string[] = getDefaultBrowserLibs()
|
|
215
|
-
): Promise<Map<string, string>> {
|
|
216
|
-
const cache = new LibCache();
|
|
217
|
-
return cache.getOrFetch(libs);
|
|
218
|
-
}
|