@esm.sh/import-map 0.1.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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/generator.mjs +24 -0
- package/dist/import-map.mjs +159 -0
- package/package.json +35 -0
- package/src/generator.ts +28 -0
- package/src/import-map.ts +171 -0
- package/types/generator.d.ts +4 -0
- package/types/import-map.d.ts +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 Je Xia <i@jex.me>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
let cdnOrigin = "https://esm.sh";
|
|
2
|
+
function setCDNOrigin(origin) {
|
|
3
|
+
const url = new URL(origin);
|
|
4
|
+
cdnOrigin = url.origin;
|
|
5
|
+
}
|
|
6
|
+
function add(importMap, specifier) {
|
|
7
|
+
throw new Error("Not implemented");
|
|
8
|
+
}
|
|
9
|
+
function update(importMap, specifier, version) {
|
|
10
|
+
throw new Error("Not implemented");
|
|
11
|
+
}
|
|
12
|
+
function remove(importMap) {
|
|
13
|
+
throw new Error("Not implemented");
|
|
14
|
+
}
|
|
15
|
+
function tidy(importMap) {
|
|
16
|
+
throw new Error("Not implemented");
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
add,
|
|
20
|
+
remove,
|
|
21
|
+
setCDNOrigin,
|
|
22
|
+
tidy,
|
|
23
|
+
update
|
|
24
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
function createBlankImportMap(baseURL) {
|
|
2
|
+
return {
|
|
3
|
+
$baseURL: new URL(baseURL ?? ".", "file:///").href,
|
|
4
|
+
imports: {},
|
|
5
|
+
scopes: {}
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
function importMapFrom(v, baseURL) {
|
|
9
|
+
const im = createBlankImportMap(baseURL);
|
|
10
|
+
if (isObject(v)) {
|
|
11
|
+
const { imports, scopes } = v;
|
|
12
|
+
if (isObject(imports)) {
|
|
13
|
+
validateImports(imports);
|
|
14
|
+
im.imports = imports;
|
|
15
|
+
}
|
|
16
|
+
if (isObject(scopes)) {
|
|
17
|
+
validateScopes(scopes);
|
|
18
|
+
im.scopes = scopes;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return im;
|
|
22
|
+
}
|
|
23
|
+
function parseImportMapFromJson(json, baseURL) {
|
|
24
|
+
const importMap = {
|
|
25
|
+
$baseURL: new URL(baseURL ?? ".", "file:///").href,
|
|
26
|
+
imports: {},
|
|
27
|
+
scopes: {}
|
|
28
|
+
};
|
|
29
|
+
const v = JSON.parse(json);
|
|
30
|
+
if (isObject(v)) {
|
|
31
|
+
const { imports, scopes } = v;
|
|
32
|
+
if (isObject(imports)) {
|
|
33
|
+
validateImports(imports);
|
|
34
|
+
importMap.imports = imports;
|
|
35
|
+
}
|
|
36
|
+
if (isObject(scopes)) {
|
|
37
|
+
validateScopes(scopes);
|
|
38
|
+
importMap.scopes = scopes;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return importMap;
|
|
42
|
+
}
|
|
43
|
+
function parseImportMapFromHtml(html, baseURL) {
|
|
44
|
+
const tplEl = document.createElement("template");
|
|
45
|
+
tplEl.innerHTML = html;
|
|
46
|
+
const scriptEl = tplEl.content.querySelector("script[type='importmap']");
|
|
47
|
+
if (scriptEl) {
|
|
48
|
+
return parseImportMapFromJson(scriptEl.textContent, baseURL);
|
|
49
|
+
}
|
|
50
|
+
return createBlankImportMap(baseURL);
|
|
51
|
+
}
|
|
52
|
+
function resolve(importMap, specifier, containingFile) {
|
|
53
|
+
const { $baseURL, imports, scopes } = importMap;
|
|
54
|
+
const { origin, pathname } = new URL(containingFile, $baseURL);
|
|
55
|
+
const sameOriginScopes = [];
|
|
56
|
+
for (const scopeName in scopes) {
|
|
57
|
+
const scopeUrl = new URL(scopeName, $baseURL);
|
|
58
|
+
if (scopeUrl.origin === origin) {
|
|
59
|
+
sameOriginScopes.push([scopeUrl.pathname, scopes[scopeName]]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
sameOriginScopes.sort(([a], [b]) => b.split("/").length - a.split("/").length);
|
|
63
|
+
if (sameOriginScopes.length > 0) {
|
|
64
|
+
for (const [scopePathname, scopeImports] of sameOriginScopes) {
|
|
65
|
+
if (pathname.startsWith(scopePathname)) {
|
|
66
|
+
const url = matchImport(specifier, scopeImports);
|
|
67
|
+
if (url) {
|
|
68
|
+
return [url, true];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (origin === new URL($baseURL).origin) {
|
|
74
|
+
const url = matchImport(specifier, imports);
|
|
75
|
+
if (url) {
|
|
76
|
+
return [url, true];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return [specifier, false];
|
|
80
|
+
}
|
|
81
|
+
function isSupportImportMap() {
|
|
82
|
+
return !globalThis.HTMLScriptElement?.supports?.("importmap");
|
|
83
|
+
}
|
|
84
|
+
function isBlankImportMap(importMap) {
|
|
85
|
+
const { imports, scopes } = importMap;
|
|
86
|
+
if (isObject(imports) && Object.keys(imports).length > 0 || isObject(scopes) && Object.keys(scopes).length > 0) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
function isSameImportMap(a, b) {
|
|
92
|
+
if (!isSameImports(a.imports, b.imports)) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
for (const k in a.scopes) {
|
|
96
|
+
if (!(k in b.scopes) || !isObject(b.scopes[k])) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
if (!isSameImports(a.scopes[k], b.scopes[k])) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
function matchImport(specifier, imports) {
|
|
106
|
+
if (specifier in imports) {
|
|
107
|
+
return imports[specifier];
|
|
108
|
+
}
|
|
109
|
+
for (const [k, v] of Object.entries(imports)) {
|
|
110
|
+
if (k.endsWith("/")) {
|
|
111
|
+
if (specifier.startsWith(k)) {
|
|
112
|
+
return v + specifier.slice(k.length);
|
|
113
|
+
}
|
|
114
|
+
} else if (specifier.startsWith(k + "/")) {
|
|
115
|
+
return v + specifier.slice(k.length);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
function validateImports(imports) {
|
|
121
|
+
for (const [k, v] of Object.entries(imports)) {
|
|
122
|
+
if (!v || typeof v !== "string") {
|
|
123
|
+
delete imports[k];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function validateScopes(imports) {
|
|
128
|
+
for (const [k, v] of Object.entries(imports)) {
|
|
129
|
+
if (isObject(v)) {
|
|
130
|
+
validateImports(v);
|
|
131
|
+
} else {
|
|
132
|
+
delete imports[k];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function isObject(v) {
|
|
137
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
138
|
+
}
|
|
139
|
+
function isSameImports(a, b) {
|
|
140
|
+
if (Object.keys(a).length !== Object.keys(b).length) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
for (const k in a) {
|
|
144
|
+
if (a[k] !== b[k]) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
export {
|
|
151
|
+
createBlankImportMap,
|
|
152
|
+
importMapFrom,
|
|
153
|
+
isBlankImportMap,
|
|
154
|
+
isSameImportMap,
|
|
155
|
+
isSupportImportMap,
|
|
156
|
+
parseImportMapFromHtml,
|
|
157
|
+
parseImportMapFromJson,
|
|
158
|
+
resolve
|
|
159
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@esm.sh/import-map",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A import map parser and resolver.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/import-map.mjs",
|
|
7
|
+
"module": "dist/import-map.mjs",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/import-map.mjs",
|
|
11
|
+
"types": "./types/import-map.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./generator": {
|
|
14
|
+
"import": "./dist/generator.mjs",
|
|
15
|
+
"types": "./types/generator.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"prepublishOnly": "npm run build",
|
|
20
|
+
"build": "esbuild --format=esm --outdir=dist --out-extension:.js=.mjs src/*.ts"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"esbuild": "^0.25.0"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/esm-dev/import-map.git"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/esm-dev/import-map/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/esm-dev/import-map#readme",
|
|
33
|
+
"author": "ije",
|
|
34
|
+
"license": "MIT"
|
|
35
|
+
}
|
package/src/generator.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ImportMap } from "../types/import-map.d.ts";
|
|
2
|
+
|
|
3
|
+
let cdnOrigin = "https://esm.sh";
|
|
4
|
+
|
|
5
|
+
export function setCDNOrigin(origin: string): void {
|
|
6
|
+
const url = new URL(origin);
|
|
7
|
+
cdnOrigin = url.origin;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Add a module to the import map. */
|
|
11
|
+
export function add(importMap: ImportMap, specifier: string): Promise<void> {
|
|
12
|
+
throw new Error("Not implemented");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Update a module in the import map. */
|
|
16
|
+
export function update(importMap: ImportMap, specifier: string, version: string): Promise<void> {
|
|
17
|
+
throw new Error("Not implemented");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Remove a module from the import map. */
|
|
21
|
+
export function remove(importMap: ImportMap): Promise<void> {
|
|
22
|
+
throw new Error("Not implemented");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Tidy the import map. */
|
|
26
|
+
export function tidy(importMap: ImportMap): Promise<void> {
|
|
27
|
+
throw new Error("Not implemented");
|
|
28
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { ImportMap } from "../types/import-map.d.ts";
|
|
2
|
+
|
|
3
|
+
/** Create a blank import map. */
|
|
4
|
+
export function createBlankImportMap(baseURL?: string): ImportMap {
|
|
5
|
+
return {
|
|
6
|
+
$baseURL: new URL(baseURL ?? ".", "file:///").href,
|
|
7
|
+
imports: {},
|
|
8
|
+
scopes: {},
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Create an import map from the given object. */
|
|
13
|
+
export function importMapFrom(v: any, baseURL?: string): ImportMap {
|
|
14
|
+
const im = createBlankImportMap(baseURL);
|
|
15
|
+
if (isObject(v)) {
|
|
16
|
+
const { imports, scopes } = v;
|
|
17
|
+
if (isObject(imports)) {
|
|
18
|
+
validateImports(imports);
|
|
19
|
+
im.imports = imports as ImportMap["imports"];
|
|
20
|
+
}
|
|
21
|
+
if (isObject(scopes)) {
|
|
22
|
+
validateScopes(scopes);
|
|
23
|
+
im.scopes = scopes as ImportMap["scopes"];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return im;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Parse the import map from JSON. */
|
|
30
|
+
export function parseImportMapFromJson(json: string, baseURL?: string): ImportMap {
|
|
31
|
+
const importMap: ImportMap = {
|
|
32
|
+
$baseURL: new URL(baseURL ?? ".", "file:///").href,
|
|
33
|
+
imports: {},
|
|
34
|
+
scopes: {},
|
|
35
|
+
};
|
|
36
|
+
const v = JSON.parse(json);
|
|
37
|
+
if (isObject(v)) {
|
|
38
|
+
const { imports, scopes } = v;
|
|
39
|
+
if (isObject(imports)) {
|
|
40
|
+
validateImports(imports);
|
|
41
|
+
importMap.imports = imports as ImportMap["imports"];
|
|
42
|
+
}
|
|
43
|
+
if (isObject(scopes)) {
|
|
44
|
+
validateScopes(scopes);
|
|
45
|
+
importMap.scopes = scopes as ImportMap["scopes"];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return importMap;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Parse the import map from the given HTML. (requires Browser environment) */
|
|
52
|
+
export function parseImportMapFromHtml(html: string, baseURL?: string): ImportMap {
|
|
53
|
+
const tplEl = document.createElement("template");
|
|
54
|
+
tplEl.innerHTML = html;
|
|
55
|
+
const scriptEl: HTMLScriptElement | null = tplEl.content.querySelector("script[type='importmap']");
|
|
56
|
+
if (scriptEl) {
|
|
57
|
+
return parseImportMapFromJson(scriptEl.textContent!, baseURL);
|
|
58
|
+
}
|
|
59
|
+
return createBlankImportMap(baseURL);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Resolve the specifier with the import map. */
|
|
63
|
+
export function resolve(importMap: ImportMap, specifier: string, containingFile: string): [string, boolean] {
|
|
64
|
+
const { $baseURL, imports, scopes } = importMap;
|
|
65
|
+
const { origin, pathname } = new URL(containingFile, $baseURL);
|
|
66
|
+
const sameOriginScopes: [string, ImportMap["imports"]][] = [];
|
|
67
|
+
for (const scopeName in scopes) {
|
|
68
|
+
const scopeUrl = new URL(scopeName, $baseURL);
|
|
69
|
+
if (scopeUrl.origin === origin) {
|
|
70
|
+
sameOriginScopes.push([scopeUrl.pathname, scopes[scopeName]]);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
sameOriginScopes.sort(([a], [b]) => b.split("/").length - a.split("/").length);
|
|
74
|
+
if (sameOriginScopes.length > 0) {
|
|
75
|
+
for (const [scopePathname, scopeImports] of sameOriginScopes) {
|
|
76
|
+
if (pathname.startsWith(scopePathname)) {
|
|
77
|
+
const url = matchImport(specifier, scopeImports);
|
|
78
|
+
if (url) {
|
|
79
|
+
return [url, true];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (origin === new URL($baseURL).origin) {
|
|
85
|
+
const url = matchImport(specifier, imports);
|
|
86
|
+
if (url) {
|
|
87
|
+
return [url, true];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return [specifier, false];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Check if current browser supports import maps. */
|
|
94
|
+
export function isSupportImportMap(): boolean {
|
|
95
|
+
return !(globalThis.HTMLScriptElement?.supports?.("importmap"));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Check if the import map is blank. */
|
|
99
|
+
export function isBlankImportMap(importMap: ImportMap) {
|
|
100
|
+
const { imports, scopes } = importMap;
|
|
101
|
+
if ((isObject(imports) && Object.keys(imports).length > 0) || (isObject(scopes) && Object.keys(scopes).length > 0)) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Check if the given two import maps are the same. */
|
|
108
|
+
export function isSameImportMap(a: ImportMap, b: ImportMap): boolean {
|
|
109
|
+
if (!isSameImports(a.imports, b.imports)) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
for (const k in a.scopes) {
|
|
113
|
+
if (!(k in b.scopes) || !isObject(b.scopes[k])) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (!isSameImports(a.scopes[k], b.scopes[k])) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function matchImport(specifier: string, imports: ImportMap["imports"]): string | null {
|
|
124
|
+
if (specifier in imports) {
|
|
125
|
+
return imports[specifier];
|
|
126
|
+
}
|
|
127
|
+
for (const [k, v] of Object.entries(imports)) {
|
|
128
|
+
if (k.endsWith("/")) {
|
|
129
|
+
if (specifier.startsWith(k)) {
|
|
130
|
+
return v + specifier.slice(k.length);
|
|
131
|
+
}
|
|
132
|
+
} else if (specifier.startsWith(k + "/")) {
|
|
133
|
+
return v + specifier.slice(k.length);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function validateImports(imports: Record<string, unknown>) {
|
|
140
|
+
for (const [k, v] of Object.entries(imports)) {
|
|
141
|
+
if (!v || typeof v !== "string") {
|
|
142
|
+
delete imports[k];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function validateScopes(imports: Record<string, unknown>) {
|
|
148
|
+
for (const [k, v] of Object.entries(imports)) {
|
|
149
|
+
if (isObject(v)) {
|
|
150
|
+
validateImports(v);
|
|
151
|
+
} else {
|
|
152
|
+
delete imports[k];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function isObject(v: unknown): v is Record<string, unknown> {
|
|
158
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function isSameImports(a: Record<string, string>, b: Record<string, string>): boolean {
|
|
162
|
+
if (Object.keys(a).length !== Object.keys(b).length) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
for (const k in a) {
|
|
166
|
+
if (a[k] !== b[k]) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** The import maps follow the spec at https://wicg.github.io/import-maps/. */
|
|
2
|
+
export interface ImportMap {
|
|
3
|
+
$src?: string;
|
|
4
|
+
$baseURL: string;
|
|
5
|
+
imports: Record<string, string>;
|
|
6
|
+
scopes: Record<string, Record<string, string>>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Create a blank import map. */
|
|
10
|
+
export function createBlankImportMap(): ImportMap;
|
|
11
|
+
|
|
12
|
+
/** Create an import map from the given object. */
|
|
13
|
+
export function importMapFrom(v: any, baseURL?: string): ImportMap;
|
|
14
|
+
|
|
15
|
+
/** Parse the import map from JSON. */
|
|
16
|
+
export function parseImportMapFromJson(json: string, baseURL?: string): ImportMap;
|
|
17
|
+
|
|
18
|
+
/** Parse the import map from the given HTML. (requires Browser environment) */
|
|
19
|
+
export function parseImportMapFromHtml(html: string, baseURL?: string): ImportMap;
|
|
20
|
+
|
|
21
|
+
/** Resolve the specifier with the import map. */
|
|
22
|
+
export function resolve(importMap: ImportMap, specifier: string, containingFile: string): string;
|
|
23
|
+
|
|
24
|
+
/** Check if current browser supports import maps. */
|
|
25
|
+
export function isSupportImportMap(): boolean;
|
|
26
|
+
|
|
27
|
+
/** Check if the import map is blank. */
|
|
28
|
+
export function isBlankImportMap(importMap: ImportMap): boolean;
|
|
29
|
+
|
|
30
|
+
/** Check if the given two import maps are the same. */
|
|
31
|
+
export function isSameImportMap(a: ImportMap, b: ImportMap): boolean;
|