@shgysk8zer0/importmap 1.7.5 → 1.7.6
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/CHANGELOG.md +8 -0
- package/cli.cjs +47 -7
- package/cli.js +47 -7
- package/importmap.cjs +47 -7
- package/importmap.js +47 -7
- package/importmap.json +4 -7
- package/index.cjs +47 -7
- package/index.js +47 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [v1.7.6] - 2026-01-09
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Add `Importmap.resolve()`
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- Update `@aegisjsproject/parsers` & `@aegisjsproject/core`
|
|
17
|
+
|
|
10
18
|
## [v1.7.5] - 2026-01-08
|
|
11
19
|
|
|
12
20
|
### Added
|
package/cli.cjs
CHANGED
|
@@ -33,12 +33,12 @@ const imports$1 = {
|
|
|
33
33
|
"@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/",
|
|
34
34
|
"@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",
|
|
35
35
|
"@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",
|
|
36
|
-
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.
|
|
37
|
-
"@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.
|
|
36
|
+
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/bundle.min.js",
|
|
37
|
+
"@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/",
|
|
38
38
|
"@aegisjsproject/sanitizer": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/sanitizer.js",
|
|
39
39
|
"@aegisjsproject/sanitizer/": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/",
|
|
40
|
-
"@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.
|
|
41
|
-
"@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.
|
|
40
|
+
"@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.32/core.js",
|
|
41
|
+
"@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.32/",
|
|
42
42
|
"@aegisjsproject/styles": "https://unpkg.com/@aegisjsproject/styles@0.2.7/styles.js",
|
|
43
43
|
"@aegisjsproject/styles/": "https://unpkg.com/@aegisjsproject/styles@0.2.7/",
|
|
44
44
|
"@aegisjsproject/component": "https://unpkg.com/@aegisjsproject/component@0.1.7/component.js",
|
|
@@ -76,9 +76,6 @@ const imports$1 = {
|
|
|
76
76
|
"@aegisjsproject/qr-encoder/": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/",
|
|
77
77
|
"@aegisjsproject/escape": "https://unpkg.com/@aegisjsproject/escape@1.0.4/index.min.js",
|
|
78
78
|
"@aegisjsproject/escape/": "https://unpkg.com/@aegisjsproject/escape@1.0.4/",
|
|
79
|
-
"@aegisjsproject/escape/html": "https://unpkg.com/@aegisjsproject/escape@1.0.4/html.min.js",
|
|
80
|
-
"@aegisjsproject/escape/trusted-html": "https://unpkg.com/@aegisjsproject/escape@1.0.4/trusted-html.min.js",
|
|
81
|
-
"@aegisjsproject/escape/css": "https://unpkg.com/@aegisjsproject/escape@1.0.4/css.min.js",
|
|
82
79
|
"@kernvalley/components/": "https://unpkg.com/@kernvalley/components@2.0.9/",
|
|
83
80
|
"@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",
|
|
84
81
|
leaflet: "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",
|
|
@@ -135,6 +132,7 @@ const { imports, scopes } = json;
|
|
|
135
132
|
class Importmap {
|
|
136
133
|
#imports = {};
|
|
137
134
|
#scopes = {};
|
|
135
|
+
#base;
|
|
138
136
|
|
|
139
137
|
constructor({ imports: i = imports, scopes: s = scopes } = {}) {
|
|
140
138
|
this.#imports = i;
|
|
@@ -173,6 +171,48 @@ class Importmap {
|
|
|
173
171
|
return JSON.stringify(this);
|
|
174
172
|
}
|
|
175
173
|
|
|
174
|
+
get baseUrl() {
|
|
175
|
+
return this.#base;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
set baseUrl(val) {
|
|
179
|
+
if (typeof val === 'string' && URL.canParse(val)) {
|
|
180
|
+
this.#base = val;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
resolve(specifier, base = this.baseUrl) {
|
|
185
|
+
if (specifier instanceof URL) {
|
|
186
|
+
return specifier.href;
|
|
187
|
+
} else if (typeof specifier !== 'string') {
|
|
188
|
+
return null;
|
|
189
|
+
} else if (this.has(specifier)) {
|
|
190
|
+
return URL.parse(this.get(specifier), this.baseUrl)?.href ?? null;
|
|
191
|
+
} else if (URL.canParse(specifier)) {
|
|
192
|
+
return specifier;
|
|
193
|
+
} else if (! specifier.startsWith('.')) {
|
|
194
|
+
// Find the longest match
|
|
195
|
+
const matches = Object.keys(this.imports)
|
|
196
|
+
.filter(key => key.endsWith('/') && specifier.startsWith(key))
|
|
197
|
+
.sort((a, b) => b.length - a.length);
|
|
198
|
+
|
|
199
|
+
if (matches.length === 0) {
|
|
200
|
+
return null;
|
|
201
|
+
} else {
|
|
202
|
+
const match = matches[0];
|
|
203
|
+
const target = imports[match];
|
|
204
|
+
const subpath = specifier.slice(match.length);
|
|
205
|
+
// Resolve the mapping target against the map's base, then the subpath against that
|
|
206
|
+
const resolvedTarget = new URL(target, this.baseUrl);
|
|
207
|
+
return new URL(subpath, resolvedTarget).href;
|
|
208
|
+
}
|
|
209
|
+
} else if (typeof base === 'string') {
|
|
210
|
+
return URL.parse(specifier, base)?.href ?? null;
|
|
211
|
+
} else {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
176
216
|
async importLocalPackage(name = 'package.json', { signal } = {}) {
|
|
177
217
|
const path = node_path.join(process.cwd(), name);
|
|
178
218
|
const pkg = await promises.readFile(path, { encoding: 'utf8', signal });
|
package/cli.js
CHANGED
|
@@ -30,12 +30,12 @@ const imports$1 = {
|
|
|
30
30
|
"@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/",
|
|
31
31
|
"@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",
|
|
32
32
|
"@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",
|
|
33
|
-
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.
|
|
34
|
-
"@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.
|
|
33
|
+
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/bundle.min.js",
|
|
34
|
+
"@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/",
|
|
35
35
|
"@aegisjsproject/sanitizer": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/sanitizer.js",
|
|
36
36
|
"@aegisjsproject/sanitizer/": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/",
|
|
37
|
-
"@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.
|
|
38
|
-
"@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.
|
|
37
|
+
"@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.32/core.js",
|
|
38
|
+
"@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.32/",
|
|
39
39
|
"@aegisjsproject/styles": "https://unpkg.com/@aegisjsproject/styles@0.2.7/styles.js",
|
|
40
40
|
"@aegisjsproject/styles/": "https://unpkg.com/@aegisjsproject/styles@0.2.7/",
|
|
41
41
|
"@aegisjsproject/component": "https://unpkg.com/@aegisjsproject/component@0.1.7/component.js",
|
|
@@ -73,9 +73,6 @@ const imports$1 = {
|
|
|
73
73
|
"@aegisjsproject/qr-encoder/": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/",
|
|
74
74
|
"@aegisjsproject/escape": "https://unpkg.com/@aegisjsproject/escape@1.0.4/index.min.js",
|
|
75
75
|
"@aegisjsproject/escape/": "https://unpkg.com/@aegisjsproject/escape@1.0.4/",
|
|
76
|
-
"@aegisjsproject/escape/html": "https://unpkg.com/@aegisjsproject/escape@1.0.4/html.min.js",
|
|
77
|
-
"@aegisjsproject/escape/trusted-html": "https://unpkg.com/@aegisjsproject/escape@1.0.4/trusted-html.min.js",
|
|
78
|
-
"@aegisjsproject/escape/css": "https://unpkg.com/@aegisjsproject/escape@1.0.4/css.min.js",
|
|
79
76
|
"@kernvalley/components/": "https://unpkg.com/@kernvalley/components@2.0.9/",
|
|
80
77
|
"@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",
|
|
81
78
|
leaflet: "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",
|
|
@@ -132,6 +129,7 @@ const { imports, scopes } = json;
|
|
|
132
129
|
class Importmap {
|
|
133
130
|
#imports = {};
|
|
134
131
|
#scopes = {};
|
|
132
|
+
#base;
|
|
135
133
|
|
|
136
134
|
constructor({ imports: i = imports, scopes: s = scopes } = {}) {
|
|
137
135
|
this.#imports = i;
|
|
@@ -170,6 +168,48 @@ class Importmap {
|
|
|
170
168
|
return JSON.stringify(this);
|
|
171
169
|
}
|
|
172
170
|
|
|
171
|
+
get baseUrl() {
|
|
172
|
+
return this.#base;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
set baseUrl(val) {
|
|
176
|
+
if (typeof val === 'string' && URL.canParse(val)) {
|
|
177
|
+
this.#base = val;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
resolve(specifier, base = this.baseUrl) {
|
|
182
|
+
if (specifier instanceof URL) {
|
|
183
|
+
return specifier.href;
|
|
184
|
+
} else if (typeof specifier !== 'string') {
|
|
185
|
+
return null;
|
|
186
|
+
} else if (this.has(specifier)) {
|
|
187
|
+
return URL.parse(this.get(specifier), this.baseUrl)?.href ?? null;
|
|
188
|
+
} else if (URL.canParse(specifier)) {
|
|
189
|
+
return specifier;
|
|
190
|
+
} else if (! specifier.startsWith('.')) {
|
|
191
|
+
// Find the longest match
|
|
192
|
+
const matches = Object.keys(this.imports)
|
|
193
|
+
.filter(key => key.endsWith('/') && specifier.startsWith(key))
|
|
194
|
+
.sort((a, b) => b.length - a.length);
|
|
195
|
+
|
|
196
|
+
if (matches.length === 0) {
|
|
197
|
+
return null;
|
|
198
|
+
} else {
|
|
199
|
+
const match = matches[0];
|
|
200
|
+
const target = imports[match];
|
|
201
|
+
const subpath = specifier.slice(match.length);
|
|
202
|
+
// Resolve the mapping target against the map's base, then the subpath against that
|
|
203
|
+
const resolvedTarget = new URL(target, this.baseUrl);
|
|
204
|
+
return new URL(subpath, resolvedTarget).href;
|
|
205
|
+
}
|
|
206
|
+
} else if (typeof base === 'string') {
|
|
207
|
+
return URL.parse(specifier, base)?.href ?? null;
|
|
208
|
+
} else {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
173
213
|
async importLocalPackage(name = 'package.json', { signal } = {}) {
|
|
174
214
|
const path = join(process.cwd(), name);
|
|
175
215
|
const pkg = await readFile(path, { encoding: 'utf8', signal });
|
package/importmap.cjs
CHANGED
|
@@ -30,12 +30,12 @@ const imports$1 = {
|
|
|
30
30
|
"@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/",
|
|
31
31
|
"@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",
|
|
32
32
|
"@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",
|
|
33
|
-
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.
|
|
34
|
-
"@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.
|
|
33
|
+
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/bundle.min.js",
|
|
34
|
+
"@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/",
|
|
35
35
|
"@aegisjsproject/sanitizer": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/sanitizer.js",
|
|
36
36
|
"@aegisjsproject/sanitizer/": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/",
|
|
37
|
-
"@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.
|
|
38
|
-
"@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.
|
|
37
|
+
"@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.32/core.js",
|
|
38
|
+
"@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.32/",
|
|
39
39
|
"@aegisjsproject/styles": "https://unpkg.com/@aegisjsproject/styles@0.2.7/styles.js",
|
|
40
40
|
"@aegisjsproject/styles/": "https://unpkg.com/@aegisjsproject/styles@0.2.7/",
|
|
41
41
|
"@aegisjsproject/component": "https://unpkg.com/@aegisjsproject/component@0.1.7/component.js",
|
|
@@ -73,9 +73,6 @@ const imports$1 = {
|
|
|
73
73
|
"@aegisjsproject/qr-encoder/": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/",
|
|
74
74
|
"@aegisjsproject/escape": "https://unpkg.com/@aegisjsproject/escape@1.0.4/index.min.js",
|
|
75
75
|
"@aegisjsproject/escape/": "https://unpkg.com/@aegisjsproject/escape@1.0.4/",
|
|
76
|
-
"@aegisjsproject/escape/html": "https://unpkg.com/@aegisjsproject/escape@1.0.4/html.min.js",
|
|
77
|
-
"@aegisjsproject/escape/trusted-html": "https://unpkg.com/@aegisjsproject/escape@1.0.4/trusted-html.min.js",
|
|
78
|
-
"@aegisjsproject/escape/css": "https://unpkg.com/@aegisjsproject/escape@1.0.4/css.min.js",
|
|
79
76
|
"@kernvalley/components/": "https://unpkg.com/@kernvalley/components@2.0.9/",
|
|
80
77
|
"@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",
|
|
81
78
|
leaflet: "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",
|
|
@@ -132,6 +129,7 @@ const { imports, scopes } = json;
|
|
|
132
129
|
class Importmap {
|
|
133
130
|
#imports = {};
|
|
134
131
|
#scopes = {};
|
|
132
|
+
#base;
|
|
135
133
|
|
|
136
134
|
constructor({ imports: i = imports, scopes: s = scopes } = {}) {
|
|
137
135
|
this.#imports = i;
|
|
@@ -170,6 +168,48 @@ class Importmap {
|
|
|
170
168
|
return JSON.stringify(this);
|
|
171
169
|
}
|
|
172
170
|
|
|
171
|
+
get baseUrl() {
|
|
172
|
+
return this.#base;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
set baseUrl(val) {
|
|
176
|
+
if (typeof val === 'string' && URL.canParse(val)) {
|
|
177
|
+
this.#base = val;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
resolve(specifier, base = this.baseUrl) {
|
|
182
|
+
if (specifier instanceof URL) {
|
|
183
|
+
return specifier.href;
|
|
184
|
+
} else if (typeof specifier !== 'string') {
|
|
185
|
+
return null;
|
|
186
|
+
} else if (this.has(specifier)) {
|
|
187
|
+
return URL.parse(this.get(specifier), this.baseUrl)?.href ?? null;
|
|
188
|
+
} else if (URL.canParse(specifier)) {
|
|
189
|
+
return specifier;
|
|
190
|
+
} else if (! specifier.startsWith('.')) {
|
|
191
|
+
// Find the longest match
|
|
192
|
+
const matches = Object.keys(this.imports)
|
|
193
|
+
.filter(key => key.endsWith('/') && specifier.startsWith(key))
|
|
194
|
+
.sort((a, b) => b.length - a.length);
|
|
195
|
+
|
|
196
|
+
if (matches.length === 0) {
|
|
197
|
+
return null;
|
|
198
|
+
} else {
|
|
199
|
+
const match = matches[0];
|
|
200
|
+
const target = imports[match];
|
|
201
|
+
const subpath = specifier.slice(match.length);
|
|
202
|
+
// Resolve the mapping target against the map's base, then the subpath against that
|
|
203
|
+
const resolvedTarget = new URL(target, this.baseUrl);
|
|
204
|
+
return new URL(subpath, resolvedTarget).href;
|
|
205
|
+
}
|
|
206
|
+
} else if (typeof base === 'string') {
|
|
207
|
+
return URL.parse(specifier, base)?.href ?? null;
|
|
208
|
+
} else {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
173
213
|
async importLocalPackage(name = 'package.json', { signal } = {}) {
|
|
174
214
|
const path = node_path.join(process.cwd(), name);
|
|
175
215
|
const pkg = await promises.readFile(path, { encoding: 'utf8', signal });
|
package/importmap.js
CHANGED
|
@@ -26,12 +26,12 @@ const imports$1 = {
|
|
|
26
26
|
"@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/",
|
|
27
27
|
"@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",
|
|
28
28
|
"@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",
|
|
29
|
-
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.
|
|
30
|
-
"@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.
|
|
29
|
+
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/bundle.min.js",
|
|
30
|
+
"@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/",
|
|
31
31
|
"@aegisjsproject/sanitizer": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/sanitizer.js",
|
|
32
32
|
"@aegisjsproject/sanitizer/": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/",
|
|
33
|
-
"@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.
|
|
34
|
-
"@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.
|
|
33
|
+
"@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.32/core.js",
|
|
34
|
+
"@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.32/",
|
|
35
35
|
"@aegisjsproject/styles": "https://unpkg.com/@aegisjsproject/styles@0.2.7/styles.js",
|
|
36
36
|
"@aegisjsproject/styles/": "https://unpkg.com/@aegisjsproject/styles@0.2.7/",
|
|
37
37
|
"@aegisjsproject/component": "https://unpkg.com/@aegisjsproject/component@0.1.7/component.js",
|
|
@@ -69,9 +69,6 @@ const imports$1 = {
|
|
|
69
69
|
"@aegisjsproject/qr-encoder/": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/",
|
|
70
70
|
"@aegisjsproject/escape": "https://unpkg.com/@aegisjsproject/escape@1.0.4/index.min.js",
|
|
71
71
|
"@aegisjsproject/escape/": "https://unpkg.com/@aegisjsproject/escape@1.0.4/",
|
|
72
|
-
"@aegisjsproject/escape/html": "https://unpkg.com/@aegisjsproject/escape@1.0.4/html.min.js",
|
|
73
|
-
"@aegisjsproject/escape/trusted-html": "https://unpkg.com/@aegisjsproject/escape@1.0.4/trusted-html.min.js",
|
|
74
|
-
"@aegisjsproject/escape/css": "https://unpkg.com/@aegisjsproject/escape@1.0.4/css.min.js",
|
|
75
72
|
"@kernvalley/components/": "https://unpkg.com/@kernvalley/components@2.0.9/",
|
|
76
73
|
"@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",
|
|
77
74
|
leaflet: "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",
|
|
@@ -128,6 +125,7 @@ const { imports, scopes } = json;
|
|
|
128
125
|
class Importmap {
|
|
129
126
|
#imports = {};
|
|
130
127
|
#scopes = {};
|
|
128
|
+
#base;
|
|
131
129
|
|
|
132
130
|
constructor({ imports: i = imports, scopes: s = scopes } = {}) {
|
|
133
131
|
this.#imports = i;
|
|
@@ -166,6 +164,48 @@ class Importmap {
|
|
|
166
164
|
return JSON.stringify(this);
|
|
167
165
|
}
|
|
168
166
|
|
|
167
|
+
get baseUrl() {
|
|
168
|
+
return this.#base;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
set baseUrl(val) {
|
|
172
|
+
if (typeof val === 'string' && URL.canParse(val)) {
|
|
173
|
+
this.#base = val;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
resolve(specifier, base = this.baseUrl) {
|
|
178
|
+
if (specifier instanceof URL) {
|
|
179
|
+
return specifier.href;
|
|
180
|
+
} else if (typeof specifier !== 'string') {
|
|
181
|
+
return null;
|
|
182
|
+
} else if (this.has(specifier)) {
|
|
183
|
+
return URL.parse(this.get(specifier), this.baseUrl)?.href ?? null;
|
|
184
|
+
} else if (URL.canParse(specifier)) {
|
|
185
|
+
return specifier;
|
|
186
|
+
} else if (! specifier.startsWith('.')) {
|
|
187
|
+
// Find the longest match
|
|
188
|
+
const matches = Object.keys(this.imports)
|
|
189
|
+
.filter(key => key.endsWith('/') && specifier.startsWith(key))
|
|
190
|
+
.sort((a, b) => b.length - a.length);
|
|
191
|
+
|
|
192
|
+
if (matches.length === 0) {
|
|
193
|
+
return null;
|
|
194
|
+
} else {
|
|
195
|
+
const match = matches[0];
|
|
196
|
+
const target = imports[match];
|
|
197
|
+
const subpath = specifier.slice(match.length);
|
|
198
|
+
// Resolve the mapping target against the map's base, then the subpath against that
|
|
199
|
+
const resolvedTarget = new URL(target, this.baseUrl);
|
|
200
|
+
return new URL(subpath, resolvedTarget).href;
|
|
201
|
+
}
|
|
202
|
+
} else if (typeof base === 'string') {
|
|
203
|
+
return URL.parse(specifier, base)?.href ?? null;
|
|
204
|
+
} else {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
169
209
|
async importLocalPackage(name = 'package.json', { signal } = {}) {
|
|
170
210
|
const path = join(process.cwd(), name);
|
|
171
211
|
const pkg = await readFile(path, { encoding: 'utf8', signal });
|
package/importmap.json
CHANGED
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/",
|
|
24
24
|
"@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",
|
|
25
25
|
"@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",
|
|
26
|
-
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.
|
|
27
|
-
"@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.
|
|
26
|
+
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/bundle.min.js",
|
|
27
|
+
"@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/",
|
|
28
28
|
"@aegisjsproject/sanitizer": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/sanitizer.js",
|
|
29
29
|
"@aegisjsproject/sanitizer/": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/",
|
|
30
|
-
"@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.
|
|
31
|
-
"@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.
|
|
30
|
+
"@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.32/core.js",
|
|
31
|
+
"@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.32/",
|
|
32
32
|
"@aegisjsproject/styles": "https://unpkg.com/@aegisjsproject/styles@0.2.7/styles.js",
|
|
33
33
|
"@aegisjsproject/styles/": "https://unpkg.com/@aegisjsproject/styles@0.2.7/",
|
|
34
34
|
"@aegisjsproject/component": "https://unpkg.com/@aegisjsproject/component@0.1.7/component.js",
|
|
@@ -66,9 +66,6 @@
|
|
|
66
66
|
"@aegisjsproject/qr-encoder/": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/",
|
|
67
67
|
"@aegisjsproject/escape": "https://unpkg.com/@aegisjsproject/escape@1.0.4/index.min.js",
|
|
68
68
|
"@aegisjsproject/escape/": "https://unpkg.com/@aegisjsproject/escape@1.0.4/",
|
|
69
|
-
"@aegisjsproject/escape/html": "https://unpkg.com/@aegisjsproject/escape@1.0.4/html.min.js",
|
|
70
|
-
"@aegisjsproject/escape/trusted-html": "https://unpkg.com/@aegisjsproject/escape@1.0.4/trusted-html.min.js",
|
|
71
|
-
"@aegisjsproject/escape/css": "https://unpkg.com/@aegisjsproject/escape@1.0.4/css.min.js",
|
|
72
69
|
"@kernvalley/components/": "https://unpkg.com/@kernvalley/components@2.0.9/",
|
|
73
70
|
"@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",
|
|
74
71
|
"leaflet": "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",
|
package/index.cjs
CHANGED
|
@@ -31,12 +31,12 @@ const imports$1 = {
|
|
|
31
31
|
"@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/",
|
|
32
32
|
"@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",
|
|
33
33
|
"@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",
|
|
34
|
-
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.
|
|
35
|
-
"@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.
|
|
34
|
+
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/bundle.min.js",
|
|
35
|
+
"@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/",
|
|
36
36
|
"@aegisjsproject/sanitizer": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/sanitizer.js",
|
|
37
37
|
"@aegisjsproject/sanitizer/": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/",
|
|
38
|
-
"@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.
|
|
39
|
-
"@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.
|
|
38
|
+
"@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.32/core.js",
|
|
39
|
+
"@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.32/",
|
|
40
40
|
"@aegisjsproject/styles": "https://unpkg.com/@aegisjsproject/styles@0.2.7/styles.js",
|
|
41
41
|
"@aegisjsproject/styles/": "https://unpkg.com/@aegisjsproject/styles@0.2.7/",
|
|
42
42
|
"@aegisjsproject/component": "https://unpkg.com/@aegisjsproject/component@0.1.7/component.js",
|
|
@@ -74,9 +74,6 @@ const imports$1 = {
|
|
|
74
74
|
"@aegisjsproject/qr-encoder/": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/",
|
|
75
75
|
"@aegisjsproject/escape": "https://unpkg.com/@aegisjsproject/escape@1.0.4/index.min.js",
|
|
76
76
|
"@aegisjsproject/escape/": "https://unpkg.com/@aegisjsproject/escape@1.0.4/",
|
|
77
|
-
"@aegisjsproject/escape/html": "https://unpkg.com/@aegisjsproject/escape@1.0.4/html.min.js",
|
|
78
|
-
"@aegisjsproject/escape/trusted-html": "https://unpkg.com/@aegisjsproject/escape@1.0.4/trusted-html.min.js",
|
|
79
|
-
"@aegisjsproject/escape/css": "https://unpkg.com/@aegisjsproject/escape@1.0.4/css.min.js",
|
|
80
77
|
"@kernvalley/components/": "https://unpkg.com/@kernvalley/components@2.0.9/",
|
|
81
78
|
"@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",
|
|
82
79
|
leaflet: "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",
|
|
@@ -165,6 +162,7 @@ const { imports, scopes } = json;
|
|
|
165
162
|
class Importmap {
|
|
166
163
|
#imports = {};
|
|
167
164
|
#scopes = {};
|
|
165
|
+
#base;
|
|
168
166
|
|
|
169
167
|
constructor({ imports: i = imports, scopes: s = scopes } = {}) {
|
|
170
168
|
this.#imports = i;
|
|
@@ -203,6 +201,48 @@ class Importmap {
|
|
|
203
201
|
return JSON.stringify(this);
|
|
204
202
|
}
|
|
205
203
|
|
|
204
|
+
get baseUrl() {
|
|
205
|
+
return this.#base;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
set baseUrl(val) {
|
|
209
|
+
if (typeof val === 'string' && URL.canParse(val)) {
|
|
210
|
+
this.#base = val;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
resolve(specifier, base = this.baseUrl) {
|
|
215
|
+
if (specifier instanceof URL) {
|
|
216
|
+
return specifier.href;
|
|
217
|
+
} else if (typeof specifier !== 'string') {
|
|
218
|
+
return null;
|
|
219
|
+
} else if (this.has(specifier)) {
|
|
220
|
+
return URL.parse(this.get(specifier), this.baseUrl)?.href ?? null;
|
|
221
|
+
} else if (URL.canParse(specifier)) {
|
|
222
|
+
return specifier;
|
|
223
|
+
} else if (! specifier.startsWith('.')) {
|
|
224
|
+
// Find the longest match
|
|
225
|
+
const matches = Object.keys(this.imports)
|
|
226
|
+
.filter(key => key.endsWith('/') && specifier.startsWith(key))
|
|
227
|
+
.sort((a, b) => b.length - a.length);
|
|
228
|
+
|
|
229
|
+
if (matches.length === 0) {
|
|
230
|
+
return null;
|
|
231
|
+
} else {
|
|
232
|
+
const match = matches[0];
|
|
233
|
+
const target = imports[match];
|
|
234
|
+
const subpath = specifier.slice(match.length);
|
|
235
|
+
// Resolve the mapping target against the map's base, then the subpath against that
|
|
236
|
+
const resolvedTarget = new URL(target, this.baseUrl);
|
|
237
|
+
return new URL(subpath, resolvedTarget).href;
|
|
238
|
+
}
|
|
239
|
+
} else if (typeof base === 'string') {
|
|
240
|
+
return URL.parse(specifier, base)?.href ?? null;
|
|
241
|
+
} else {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
206
246
|
async importLocalPackage(name = 'package.json', { signal } = {}) {
|
|
207
247
|
const path = node_path.join(process.cwd(), name);
|
|
208
248
|
const pkg = await promises.readFile(path, { encoding: 'utf8', signal });
|
package/index.js
CHANGED
|
@@ -29,12 +29,12 @@ const imports$1 = {
|
|
|
29
29
|
"@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/",
|
|
30
30
|
"@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",
|
|
31
31
|
"@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",
|
|
32
|
-
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.
|
|
33
|
-
"@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.
|
|
32
|
+
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/bundle.min.js",
|
|
33
|
+
"@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/",
|
|
34
34
|
"@aegisjsproject/sanitizer": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/sanitizer.js",
|
|
35
35
|
"@aegisjsproject/sanitizer/": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/",
|
|
36
|
-
"@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.
|
|
37
|
-
"@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.
|
|
36
|
+
"@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.32/core.js",
|
|
37
|
+
"@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.32/",
|
|
38
38
|
"@aegisjsproject/styles": "https://unpkg.com/@aegisjsproject/styles@0.2.7/styles.js",
|
|
39
39
|
"@aegisjsproject/styles/": "https://unpkg.com/@aegisjsproject/styles@0.2.7/",
|
|
40
40
|
"@aegisjsproject/component": "https://unpkg.com/@aegisjsproject/component@0.1.7/component.js",
|
|
@@ -72,9 +72,6 @@ const imports$1 = {
|
|
|
72
72
|
"@aegisjsproject/qr-encoder/": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/",
|
|
73
73
|
"@aegisjsproject/escape": "https://unpkg.com/@aegisjsproject/escape@1.0.4/index.min.js",
|
|
74
74
|
"@aegisjsproject/escape/": "https://unpkg.com/@aegisjsproject/escape@1.0.4/",
|
|
75
|
-
"@aegisjsproject/escape/html": "https://unpkg.com/@aegisjsproject/escape@1.0.4/html.min.js",
|
|
76
|
-
"@aegisjsproject/escape/trusted-html": "https://unpkg.com/@aegisjsproject/escape@1.0.4/trusted-html.min.js",
|
|
77
|
-
"@aegisjsproject/escape/css": "https://unpkg.com/@aegisjsproject/escape@1.0.4/css.min.js",
|
|
78
75
|
"@kernvalley/components/": "https://unpkg.com/@kernvalley/components@2.0.9/",
|
|
79
76
|
"@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",
|
|
80
77
|
leaflet: "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",
|
|
@@ -163,6 +160,7 @@ const { imports, scopes } = json;
|
|
|
163
160
|
class Importmap {
|
|
164
161
|
#imports = {};
|
|
165
162
|
#scopes = {};
|
|
163
|
+
#base;
|
|
166
164
|
|
|
167
165
|
constructor({ imports: i = imports, scopes: s = scopes } = {}) {
|
|
168
166
|
this.#imports = i;
|
|
@@ -201,6 +199,48 @@ class Importmap {
|
|
|
201
199
|
return JSON.stringify(this);
|
|
202
200
|
}
|
|
203
201
|
|
|
202
|
+
get baseUrl() {
|
|
203
|
+
return this.#base;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
set baseUrl(val) {
|
|
207
|
+
if (typeof val === 'string' && URL.canParse(val)) {
|
|
208
|
+
this.#base = val;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
resolve(specifier, base = this.baseUrl) {
|
|
213
|
+
if (specifier instanceof URL) {
|
|
214
|
+
return specifier.href;
|
|
215
|
+
} else if (typeof specifier !== 'string') {
|
|
216
|
+
return null;
|
|
217
|
+
} else if (this.has(specifier)) {
|
|
218
|
+
return URL.parse(this.get(specifier), this.baseUrl)?.href ?? null;
|
|
219
|
+
} else if (URL.canParse(specifier)) {
|
|
220
|
+
return specifier;
|
|
221
|
+
} else if (! specifier.startsWith('.')) {
|
|
222
|
+
// Find the longest match
|
|
223
|
+
const matches = Object.keys(this.imports)
|
|
224
|
+
.filter(key => key.endsWith('/') && specifier.startsWith(key))
|
|
225
|
+
.sort((a, b) => b.length - a.length);
|
|
226
|
+
|
|
227
|
+
if (matches.length === 0) {
|
|
228
|
+
return null;
|
|
229
|
+
} else {
|
|
230
|
+
const match = matches[0];
|
|
231
|
+
const target = imports[match];
|
|
232
|
+
const subpath = specifier.slice(match.length);
|
|
233
|
+
// Resolve the mapping target against the map's base, then the subpath against that
|
|
234
|
+
const resolvedTarget = new URL(target, this.baseUrl);
|
|
235
|
+
return new URL(subpath, resolvedTarget).href;
|
|
236
|
+
}
|
|
237
|
+
} else if (typeof base === 'string') {
|
|
238
|
+
return URL.parse(specifier, base)?.href ?? null;
|
|
239
|
+
} else {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
204
244
|
async importLocalPackage(name = 'package.json', { signal } = {}) {
|
|
205
245
|
const path = join(process.cwd(), name);
|
|
206
246
|
const pkg = await readFile(path, { encoding: 'utf8', signal });
|