@shgysk8zer0/importmap 1.8.20 → 1.9.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/CHANGELOG.md +11 -0
- package/cli.cjs +2 -3
- package/cli.js +2 -3
- package/consts.js +1 -2
- package/html.cjs +6 -7
- package/html.js +6 -7
- package/imap.js +195 -0
- package/importmap.cjs +2 -189
- package/importmap.js +2 -183
- package/index.cjs +45 -18
- package/index.js +42 -15
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var promises = require('node:fs/promises');
|
|
4
|
-
var node_path = require('node:path');
|
|
5
4
|
require('@shgysk8zer0/polyfills');
|
|
6
5
|
var yaml_js = require('@shgysk8zer0/npm-utils/yaml.js');
|
|
7
6
|
var json_js = require('@shgysk8zer0/npm-utils/json.js');
|
|
8
7
|
var path_js = require('@shgysk8zer0/npm-utils/path.js');
|
|
9
8
|
|
|
10
|
-
var json = JSON.parse('{\n "imports": {\n "@node/": "/node_modules/",\n "@shgysk8zer0/kazoo/": "https://unpkg.com/@shgysk8zer0/kazoo@1.0.11/",\n "@shgysk8zer0/konami": "https://unpkg.com/@shgysk8zer0/konami@1.1.2/konami.js",\n "@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.6.3/browser.min.js",\n "@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.6.3/",\n "@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.1.5/jwk-utils.min.js",\n "@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.1.5/",\n "@shgysk8zer0/jswaggersheets": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/swagger.js",\n "@shgysk8zer0/jswaggersheets/": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/",\n "@shgysk8zer0/jss/": "https://unpkg.com/@shgysk8zer0/jss@1.0.1/",\n "@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.8/",\n "@shgysk8zer0/http/": "https://unpkg.com/@shgysk8zer0/http@1.0.5/",\n "@shgysk8zer0/http-status": "https://unpkg.com/@shgysk8zer0/http-status@1.1.4/http-status.js",\n "@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.9/aes-gcm.min.js",\n "@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.9/",\n "@shgysk8zer0/squish": "https://unpkg.com/@shgysk8zer0/squish@1.0.2/squish.min.js",\n "@shgysk8zer0/squish/": "https://unpkg.com/@shgysk8zer0/squish@1.0.2/",\n "@shgysk8zer0/suid": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/suid.min.js",\n "@shgysk8zer0/suid/": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/",\n "@shgysk8zer0/geoutils": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/geoutils.min.js",\n "@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/",\n "@shgysk8zer0/core-css/": "https://unpkg.com/@shgysk8zer0/core-css@3.0.0/",\n "@shgysk8zer0/signals": "https://unpkg.com/@shgysk8zer0/signals@0.0.3/signals.min.js",\n "@shgysk8zer0/signals/": "https://unpkg.com/@shgysk8zer0/signals@0.0.3/",\n "@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",\n "@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",\n "@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.6/bundle.min.js",\n "@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.6/",\n "@aegisjsproject/sanitizer": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/sanitizer.js",\n "@aegisjsproject/sanitizer/": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/",\n "@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.34/core.js",\n "@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.34/",\n "@aegisjsproject/styles": "https://unpkg.com/@aegisjsproject/styles@0.3.2/styles.js",\n "@aegisjsproject/styles/": "https://unpkg.com/@aegisjsproject/styles@0.3.2/",\n "@aegisjsproject/component": "https://unpkg.com/@aegisjsproject/component@0.1.8/component.js",\n "@aegisjsproject/component/": "https://unpkg.com/@aegisjsproject/component@0.1.8/",\n "@aegisjsproject/markdown": "https://unpkg.com/@aegisjsproject/markdown@0.1.7/markdown.min.js",\n "@aegisjsproject/markdown/": "https://unpkg.com/@aegisjsproject/markdown@0.1.7/",\n "@aegisjsproject/aegis-md": "https://unpkg.com/@aegisjsproject/aegis-md@0.0.4/aegis-md.js",\n "@aegisjsproject/aegis-md/": "https://unpkg.com/@aegisjsproject/aegis-md@0.0.4/",\n "@aegisjsproject/url": "https://unpkg.com/@aegisjsproject/url@1.0.3/url.min.js",\n "@aegisjsproject/url/": "https://unpkg.com/@aegisjsproject/url@1.0.3/",\n "@aegisjsproject/idb/": "https://unpkg.com/@aegisjsproject/idb@1.0.6/",\n "@aegisjsproject/idb": "https://unpkg.com/@aegisjsproject/idb@1.0.6/idb.min.js",\n "@aegisjsproject/otp/": "https://unpkg.com/@aegisjsproject/otp@1.0.2/",\n "@aegisjsproject/otp": "https://unpkg.com/@aegisjsproject/otp@1.0.2/otp.min.js",\n "@aegisjsproject/md-editor": "https://unpkg.com/@aegisjsproject/md-editor@1.0.0/md-editor.js",\n "@aegisjsproject/md-editor/": "https://unpkg.com/@aegisjsproject/md-editor@1.0.0/",\n "@aegisjsproject/barcodescanner": "https://unpkg.com/@aegisjsproject/barcodescanner@1.2.3/scanner.min.js",\n "@aegisjsproject/barcodescanner/": "https://unpkg.com/@aegisjsproject/barcodescanner@1.2.3/",\n "@shgysk8zer0/components/": "https://unpkg.com/@shgysk8zer0/components@0.3.23/",\n "@aegisjsproject/state": "https://unpkg.com/@aegisjsproject/state@1.0.7/state.mjs",\n "@aegisjsproject/state/": "https://unpkg.com/@aegisjsproject/state@1.0.7/",\n "@aegisjsproject/router": "https://unpkg.com/@aegisjsproject/router@1.1.15/router.mjs",\n "@aegisjsproject/router/": "https://unpkg.com/@aegisjsproject/router@1.1.15/",\n "@aegisjsproject/callback-registry": "https://unpkg.com/@aegisjsproject/callback-registry@2.0.4/callbackRegistry.js",\n "@aegisjsproject/callback-registry/": "https://unpkg.com/@aegisjsproject/callback-registry@2.0.4/",\n "@aegisjsproject/attempt": "https://unpkg.com/@aegisjsproject/attempt@1.0.7/attempt.js",\n "@aegisjsproject/attempt/": "https://unpkg.com/@aegisjsproject/attempt@1.0.7/",\n "@aegisjsproject/secret-store": "https://unpkg.com/@aegisjsproject/secret-store@1.1.1/commands.min.js",\n "@aegisjsproject/commands/": "https://unpkg.com/@aegisjsproject/commands@1.0.2/",\n "@aegisjsproject/commands": "https://unpkg.com/@aegisjsproject/commands@1.0.2/commands.min.js",\n "@aegisjsproject/firebase-account-routes": "https://unpkg.com/@aegisjsproject/firebase-account-routes@0.0.6/main.js",\n "@aegisjsproject/firebase-account-routes/": "https://unpkg.com/@aegisjsproject/firebase-account-routes@0.0.6/",\n "@aegisjsproject/secret-store/": "https://unpkg.com/@aegisjsproject/secret-store@1.1.1/",\n "@aegisjsproject/qr-encoder": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/index.min.js",\n "@aegisjsproject/qr-encoder/": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/",\n "@aegisjsproject/escape": "https://unpkg.com/@aegisjsproject/escape@1.0.4/index.min.js",\n "@aegisjsproject/escape/": "https://unpkg.com/@aegisjsproject/escape@1.0.4/",\n "@aegisjsproject/disposable": "https://unpkg.com/@aegisjsproject/disposable@1.0.3/disposable.min.js",\n "@aegisjsproject/disposable/": "https://unpkg.com/@aegisjsproject/disposable@1.0.3/",\n "@aegisjsproject/iota": "https://unpkg.com/@aegisjsproject/iota@1.0.12/iota.min.js",\n "@aegisjsproject/iota/": "https://unpkg.com/@aegisjsproject/iota@1.0.12/",\n "@aegisjsproject/disposable-registry": "https://unpkg.com/@aegisjsproject/disposable-registry@1.0.2/registry.js",\n "@aegisjsproject/disposable-registry/": "https://unpkg.com/@aegisjsproject/disposable-registry@1.0.2/",\n "@aegisjsproject/hermes": "https://unpkg.com/@aegisjsproject/hermes@1.0.2/hermes.js",\n "@aegisjsproject/hermes/": "https://unpkg.com/@aegisjsproject/hermes@1.0.2/",\n "@kernvalley/components/": "https://unpkg.com/@kernvalley/components@2.0.10/",\n "@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",\n "leaflet": "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",\n "leaflet/": "https://unpkg.com/leaflet@1.9.4/dist/",\n "urlpattern-polyfill": "https://unpkg.com/urlpattern-polyfill@10.1.0/index.js",\n "highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/core.min.js",\n "highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/",\n "highlight.js/styles/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/",\n "@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/core.min.js",\n "@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/",\n "@highlightjs/cdn-assets/styles/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/",\n "marked": "https://unpkg.com/marked@18.0.0/lib/marked.esm.js",\n "marked-highlight": "https://unpkg.com/marked-highlight@2.2.4/src/index.js",\n "yaml": "https://unpkg.com/yaml@2.8.3/browser/dist/index.js",\n "yaml/": "https://unpkg.com/yaml@2.8.3/browser/dist/",\n "firebase/": "https://www.gstatic.com/firebasejs/10.12.1/",\n "firebase/app": "https://www.gstatic.com/firebasejs/10.12.1/firebase-app.js",\n "firebase/app-check": "https://www.gstatic.com/firebasejs/10.12.1/firebase-app-check.js",\n "firebase/auth": "https://www.gstatic.com/firebasejs/10.12.1/firebase-auth.js",\n "firebase/database": "https://www.gstatic.com/firebasejs/10.12.1/firebase-database.js",\n "firebase/firestore": "https://www.gstatic.com/firebasejs/10.12.1/firebase-firestore.js",\n "firebase/functions": "https://www.gstatic.com/firebasejs/10.12.1/firebase-functions.js",\n "firebase/messaging": "https://www.gstatic.com/firebasejs/10.12.1/firebase-messaging.js",\n "firebase/performance": "https://www.gstatic.com/firebasejs/10.12.1/firebase-performance.js",\n "firebase/remote-config": "https://www.gstatic.com/firebasejs/10.12.1/firebase-remote-config.js",\n "firebase/storage": "https://www.gstatic.com/firebasejs/10.12.1/firebase-storage.js",\n "firebase/analytics": "https://www.gstatic.com/firebasejs/10.12.1/firebase-analytics.js",\n "qr": "https://unpkg.com/qr@0.5.5/index.js",\n "qr/": "https://unpkg.com/qr@0.5.5/",\n "lit": "https://unpkg.com/lit@3.3.2/index.js",\n "lit/": "https://unpkg.com/lit@3.3.2/",\n "lit-html": "https://unpkg.com/lit-html@3.3.2/lit-html.js",\n "lit-html/": "https://unpkg.com/lit-html@3.3.2/",\n "lit-element": "https://unpkg.com/lit-element@4.2.2/lit-element.js",\n "lit-element/": "https://unpkg.com/lit-element@4.2.2/",\n "@lit/reactive-element": "https://unpkg.com/@lit/reactive-element@2.1.2/reactive-element.js",\n "@lit/reactive-element/": "https://unpkg.com/@lit/reactive-element@2.1.2/",\n "@awesome.me/webawesome/": "https://unpkg.com/@awesome.me/webawesome@3.5.0/",\n "normalize.css": "https://unpkg.com/normalize.css@8.0.1/normalize.css"\n },\n "scopes": {}\n}');
|
|
11
|
-
|
|
12
9
|
const SHA256 = 'SHA-256';
|
|
13
10
|
const SHA384 = 'SHA-384';
|
|
14
11
|
const SHA512 = 'SHA-512';
|
|
@@ -48,14 +45,12 @@ async function hash(data, { algo = DEFAULT_ALGO, output = BUFFER } = {}) {
|
|
|
48
45
|
|
|
49
46
|
const sri = async(data, { algo = SHA384 } = {}) => hash(data, { algo, output: SRI });
|
|
50
47
|
|
|
51
|
-
const { imports, scopes } = json;
|
|
52
|
-
|
|
53
48
|
class Importmap {
|
|
54
49
|
#imports = {};
|
|
55
50
|
#scopes = {};
|
|
56
|
-
#base;
|
|
51
|
+
#base = globalThis?.document?.baseURI ?? null;
|
|
57
52
|
|
|
58
|
-
constructor({ imports: i =
|
|
53
|
+
constructor({ imports: i = {}, scopes: s = {} } = {}) {
|
|
59
54
|
this.#imports = i;
|
|
60
55
|
this.#scopes = s;
|
|
61
56
|
}
|
|
@@ -103,12 +98,13 @@ class Importmap {
|
|
|
103
98
|
}
|
|
104
99
|
|
|
105
100
|
resolve(specifier, base = this.baseUrl) {
|
|
101
|
+
console.log({ specifier, base });
|
|
106
102
|
if (specifier instanceof URL) {
|
|
107
103
|
return specifier.href;
|
|
108
104
|
} else if (typeof specifier !== 'string') {
|
|
109
105
|
return null;
|
|
110
106
|
} else if (this.has(specifier)) {
|
|
111
|
-
return URL.parse(this.get(specifier),
|
|
107
|
+
return URL.parse(this.get(specifier), base)?.href ?? null;
|
|
112
108
|
} else if (URL.canParse(specifier)) {
|
|
113
109
|
return specifier;
|
|
114
110
|
} else if (! specifier.startsWith('.')) {
|
|
@@ -120,11 +116,12 @@ class Importmap {
|
|
|
120
116
|
if (matches.length === 0) {
|
|
121
117
|
return null;
|
|
122
118
|
} else {
|
|
119
|
+
const imports = this.#imports;
|
|
123
120
|
const match = matches[0];
|
|
124
121
|
const target = imports[match];
|
|
125
122
|
const subpath = specifier.slice(match.length);
|
|
126
123
|
// Resolve the mapping target against the map's base, then the subpath against that
|
|
127
|
-
const resolvedTarget = new URL(target,
|
|
124
|
+
const resolvedTarget = new URL(target, base);
|
|
128
125
|
return new URL(subpath, resolvedTarget).href;
|
|
129
126
|
}
|
|
130
127
|
} else if (typeof base === 'string') {
|
|
@@ -135,8 +132,13 @@ class Importmap {
|
|
|
135
132
|
}
|
|
136
133
|
|
|
137
134
|
async importLocalPackage(name = 'package.json', { signal } = {}) {
|
|
138
|
-
const
|
|
139
|
-
|
|
135
|
+
const [{ join }, { readFile }] = await Promise.all([
|
|
136
|
+
import('node:path'),
|
|
137
|
+
import('node:fs/promises'),
|
|
138
|
+
]);
|
|
139
|
+
|
|
140
|
+
const path = join(process.cwd(), name);
|
|
141
|
+
const pkg = await readFile(path, { encoding: 'utf8', signal });
|
|
140
142
|
|
|
141
143
|
return this.setLocalPackage(JSON.parse(pkg));
|
|
142
144
|
}
|
|
@@ -177,10 +179,12 @@ class Importmap {
|
|
|
177
179
|
}
|
|
178
180
|
}
|
|
179
181
|
|
|
180
|
-
async getScript({ algo = DEFAULT_ALGO, alphabet = BASE64, signal } = {}) {
|
|
182
|
+
async getScript({ algo = DEFAULT_ALGO, alphabet = BASE64, name, signal } = {}) {
|
|
181
183
|
const integrity = await this.getIntegrity({ algo, alphabet, signal });
|
|
182
184
|
|
|
183
|
-
return
|
|
185
|
+
return typeof name === 'string'
|
|
186
|
+
? `<script type="importmap" name="${name}" integrity="${integrity}">${JSON.stringify(this)}</script>`
|
|
187
|
+
: `<script type="importmap" integrity="${integrity}">${JSON.stringify(this)}</script>`;
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
async getIntegrity({ algo = DEFAULT_ALGO, alphabet = BASE64, signal } = {}) {
|
|
@@ -207,18 +211,37 @@ class Importmap {
|
|
|
207
211
|
return SHA512;
|
|
208
212
|
}
|
|
209
213
|
|
|
214
|
+
static importFromScript(script) {
|
|
215
|
+
if (! ('HTMLScriptElement' in globalThis)) {
|
|
216
|
+
throw new Error('Attempting to import from the wrong environment.');
|
|
217
|
+
} else if (typeof script === 'string') {
|
|
218
|
+
return this.importFromScript(globalThis.document.scripts.namedItem(script));
|
|
219
|
+
} else if (typeof script === 'number') {
|
|
220
|
+
return this.importFromScript(globalThis.document.scripts.item(script));
|
|
221
|
+
} else if (! (script instanceof globalThis.HTMLScriptElement)) {
|
|
222
|
+
throw new TypeError('Can only import from a <script>.');
|
|
223
|
+
} else if (script.type !== 'importmap') {
|
|
224
|
+
throw new TypeError(`Cannot import importmap from a <script type="${script.type ?? 'application/jacascript'}">.`);
|
|
225
|
+
} else {
|
|
226
|
+
return new this(JSON.parse(script.textContent));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
210
230
|
static async importFromFile(path = 'importmap.json', { signal } = {}) {
|
|
211
|
-
const
|
|
212
|
-
|
|
231
|
+
const [{ join }, { readFile }] = await Promise.all([
|
|
232
|
+
import('node:path'),
|
|
233
|
+
import('node:fs/promises'),
|
|
234
|
+
]);
|
|
235
|
+
const fullPath = join(process.cwd(), path);
|
|
236
|
+
const importmap = await readFile(fullPath, { encoding: 'utf8', signal });
|
|
213
237
|
|
|
214
238
|
return new Importmap(JSON.parse(importmap));
|
|
215
239
|
}
|
|
216
240
|
}
|
|
217
241
|
|
|
218
|
-
const importmap = new Importmap({ imports, scopes });
|
|
242
|
+
var data = JSON.parse('{\n "imports": {\n "@node/": "/node_modules/",\n "@shgysk8zer0/kazoo/": "https://unpkg.com/@shgysk8zer0/kazoo@1.0.11/",\n "@shgysk8zer0/konami": "https://unpkg.com/@shgysk8zer0/konami@1.1.2/konami.js",\n "@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.6.3/browser.min.js",\n "@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.6.3/",\n "@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.1.5/jwk-utils.min.js",\n "@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.1.5/",\n "@shgysk8zer0/jswaggersheets": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/swagger.js",\n "@shgysk8zer0/jswaggersheets/": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/",\n "@shgysk8zer0/jss/": "https://unpkg.com/@shgysk8zer0/jss@1.0.1/",\n "@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.8/",\n "@shgysk8zer0/http/": "https://unpkg.com/@shgysk8zer0/http@1.0.5/",\n "@shgysk8zer0/http-status": "https://unpkg.com/@shgysk8zer0/http-status@1.1.4/http-status.js",\n "@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.9/aes-gcm.min.js",\n "@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.9/",\n "@shgysk8zer0/squish": "https://unpkg.com/@shgysk8zer0/squish@1.0.2/squish.min.js",\n "@shgysk8zer0/squish/": "https://unpkg.com/@shgysk8zer0/squish@1.0.2/",\n "@shgysk8zer0/suid": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/suid.min.js",\n "@shgysk8zer0/suid/": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/",\n "@shgysk8zer0/geoutils": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/geoutils.min.js",\n "@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/",\n "@shgysk8zer0/core-css/": "https://unpkg.com/@shgysk8zer0/core-css@3.0.0/",\n "@shgysk8zer0/signals": "https://unpkg.com/@shgysk8zer0/signals@0.0.3/signals.min.js",\n "@shgysk8zer0/signals/": "https://unpkg.com/@shgysk8zer0/signals@0.0.3/",\n "@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",\n "@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",\n "@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.6/bundle.min.js",\n "@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.6/",\n "@aegisjsproject/sanitizer": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/sanitizer.js",\n "@aegisjsproject/sanitizer/": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/",\n "@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.34/core.js",\n "@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.34/",\n "@aegisjsproject/styles": "https://unpkg.com/@aegisjsproject/styles@0.3.2/styles.js",\n "@aegisjsproject/styles/": "https://unpkg.com/@aegisjsproject/styles@0.3.2/",\n "@aegisjsproject/component": "https://unpkg.com/@aegisjsproject/component@0.1.8/component.js",\n "@aegisjsproject/component/": "https://unpkg.com/@aegisjsproject/component@0.1.8/",\n "@aegisjsproject/markdown": "https://unpkg.com/@aegisjsproject/markdown@0.1.7/markdown.min.js",\n "@aegisjsproject/markdown/": "https://unpkg.com/@aegisjsproject/markdown@0.1.7/",\n "@aegisjsproject/aegis-md": "https://unpkg.com/@aegisjsproject/aegis-md@0.0.4/aegis-md.js",\n "@aegisjsproject/aegis-md/": "https://unpkg.com/@aegisjsproject/aegis-md@0.0.4/",\n "@aegisjsproject/url": "https://unpkg.com/@aegisjsproject/url@1.0.3/url.min.js",\n "@aegisjsproject/url/": "https://unpkg.com/@aegisjsproject/url@1.0.3/",\n "@aegisjsproject/idb/": "https://unpkg.com/@aegisjsproject/idb@1.0.6/",\n "@aegisjsproject/idb": "https://unpkg.com/@aegisjsproject/idb@1.0.6/idb.min.js",\n "@aegisjsproject/otp/": "https://unpkg.com/@aegisjsproject/otp@1.0.2/",\n "@aegisjsproject/otp": "https://unpkg.com/@aegisjsproject/otp@1.0.2/otp.min.js",\n "@aegisjsproject/md-editor": "https://unpkg.com/@aegisjsproject/md-editor@1.0.0/md-editor.js",\n "@aegisjsproject/md-editor/": "https://unpkg.com/@aegisjsproject/md-editor@1.0.0/",\n "@aegisjsproject/barcodescanner": "https://unpkg.com/@aegisjsproject/barcodescanner@1.2.3/scanner.min.js",\n "@aegisjsproject/barcodescanner/": "https://unpkg.com/@aegisjsproject/barcodescanner@1.2.3/",\n "@shgysk8zer0/components/": "https://unpkg.com/@shgysk8zer0/components@0.3.23/",\n "@aegisjsproject/state": "https://unpkg.com/@aegisjsproject/state@1.0.7/state.mjs",\n "@aegisjsproject/state/": "https://unpkg.com/@aegisjsproject/state@1.0.7/",\n "@aegisjsproject/router": "https://unpkg.com/@aegisjsproject/router@1.1.15/router.mjs",\n "@aegisjsproject/router/": "https://unpkg.com/@aegisjsproject/router@1.1.15/",\n "@aegisjsproject/callback-registry": "https://unpkg.com/@aegisjsproject/callback-registry@2.0.4/callbackRegistry.js",\n "@aegisjsproject/callback-registry/": "https://unpkg.com/@aegisjsproject/callback-registry@2.0.4/",\n "@aegisjsproject/attempt": "https://unpkg.com/@aegisjsproject/attempt@1.0.7/attempt.js",\n "@aegisjsproject/attempt/": "https://unpkg.com/@aegisjsproject/attempt@1.0.7/",\n "@aegisjsproject/secret-store": "https://unpkg.com/@aegisjsproject/secret-store@1.1.1/commands.min.js",\n "@aegisjsproject/commands/": "https://unpkg.com/@aegisjsproject/commands@1.0.2/",\n "@aegisjsproject/commands": "https://unpkg.com/@aegisjsproject/commands@1.0.2/commands.min.js",\n "@aegisjsproject/firebase-account-routes": "https://unpkg.com/@aegisjsproject/firebase-account-routes@0.0.6/main.js",\n "@aegisjsproject/firebase-account-routes/": "https://unpkg.com/@aegisjsproject/firebase-account-routes@0.0.6/",\n "@aegisjsproject/secret-store/": "https://unpkg.com/@aegisjsproject/secret-store@1.1.1/",\n "@aegisjsproject/qr-encoder": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/index.min.js",\n "@aegisjsproject/qr-encoder/": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/",\n "@aegisjsproject/escape": "https://unpkg.com/@aegisjsproject/escape@1.0.4/index.min.js",\n "@aegisjsproject/escape/": "https://unpkg.com/@aegisjsproject/escape@1.0.4/",\n "@aegisjsproject/disposable": "https://unpkg.com/@aegisjsproject/disposable@1.0.3/disposable.min.js",\n "@aegisjsproject/disposable/": "https://unpkg.com/@aegisjsproject/disposable@1.0.3/",\n "@aegisjsproject/iota": "https://unpkg.com/@aegisjsproject/iota@1.0.12/iota.min.js",\n "@aegisjsproject/iota/": "https://unpkg.com/@aegisjsproject/iota@1.0.12/",\n "@aegisjsproject/disposable-registry": "https://unpkg.com/@aegisjsproject/disposable-registry@1.0.2/registry.js",\n "@aegisjsproject/disposable-registry/": "https://unpkg.com/@aegisjsproject/disposable-registry@1.0.2/",\n "@aegisjsproject/hermes": "https://unpkg.com/@aegisjsproject/hermes@1.0.2/hermes.js",\n "@aegisjsproject/hermes/": "https://unpkg.com/@aegisjsproject/hermes@1.0.2/",\n "@kernvalley/components/": "https://unpkg.com/@kernvalley/components@2.0.10/",\n "@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",\n "leaflet": "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",\n "leaflet/": "https://unpkg.com/leaflet@1.9.4/dist/",\n "urlpattern-polyfill": "https://unpkg.com/urlpattern-polyfill@10.1.0/index.js",\n "highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/core.min.js",\n "highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/",\n "highlight.js/styles/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/",\n "@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/core.min.js",\n "@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/",\n "@highlightjs/cdn-assets/styles/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/",\n "marked": "https://unpkg.com/marked@18.0.0/lib/marked.esm.js",\n "marked-highlight": "https://unpkg.com/marked-highlight@2.2.4/src/index.js",\n "yaml": "https://unpkg.com/yaml@2.8.3/browser/dist/index.js",\n "yaml/": "https://unpkg.com/yaml@2.8.3/browser/dist/",\n "firebase/": "https://www.gstatic.com/firebasejs/10.12.1/",\n "firebase/app": "https://www.gstatic.com/firebasejs/10.12.1/firebase-app.js",\n "firebase/app-check": "https://www.gstatic.com/firebasejs/10.12.1/firebase-app-check.js",\n "firebase/auth": "https://www.gstatic.com/firebasejs/10.12.1/firebase-auth.js",\n "firebase/database": "https://www.gstatic.com/firebasejs/10.12.1/firebase-database.js",\n "firebase/firestore": "https://www.gstatic.com/firebasejs/10.12.1/firebase-firestore.js",\n "firebase/functions": "https://www.gstatic.com/firebasejs/10.12.1/firebase-functions.js",\n "firebase/messaging": "https://www.gstatic.com/firebasejs/10.12.1/firebase-messaging.js",\n "firebase/performance": "https://www.gstatic.com/firebasejs/10.12.1/firebase-performance.js",\n "firebase/remote-config": "https://www.gstatic.com/firebasejs/10.12.1/firebase-remote-config.js",\n "firebase/storage": "https://www.gstatic.com/firebasejs/10.12.1/firebase-storage.js",\n "firebase/analytics": "https://www.gstatic.com/firebasejs/10.12.1/firebase-analytics.js",\n "qr": "https://unpkg.com/qr@0.5.5/index.js",\n "qr/": "https://unpkg.com/qr@0.5.5/",\n "lit": "https://unpkg.com/lit@3.3.2/index.js",\n "lit/": "https://unpkg.com/lit@3.3.2/",\n "lit-html": "https://unpkg.com/lit-html@3.3.2/lit-html.js",\n "lit-html/": "https://unpkg.com/lit-html@3.3.2/",\n "lit-element": "https://unpkg.com/lit-element@4.2.2/lit-element.js",\n "lit-element/": "https://unpkg.com/lit-element@4.2.2/",\n "@lit/reactive-element": "https://unpkg.com/@lit/reactive-element@2.1.2/reactive-element.js",\n "@lit/reactive-element/": "https://unpkg.com/@lit/reactive-element@2.1.2/",\n "@awesome.me/webawesome/": "https://unpkg.com/@awesome.me/webawesome@3.5.0/",\n "normalize.css": "https://unpkg.com/normalize.css@8.0.1/normalize.css"\n },\n "scopes": {}\n}');
|
|
219
243
|
|
|
220
|
-
|
|
221
|
-
const IMPORTMAP_EXP = /<script\b(?=[^>]*\btype=["']importmap["'])(?:[^>]*?\bnonce=["'](?<nonce>[^"']*)["'])?[^>]*>(?<content>[\s\S]*?)<\/script>/i;
|
|
244
|
+
const IMPORTMAP_EXP = /<script\b(?=[^>]*\btype=["']importmap["'])(?=(?:[^>]*\bnonce=["'](?<nonce>[^"']*)["'])?)(?=(?:[^>]*\bname=["'](?<name>[^"']*)["'])?)[^>]*>(?<content>[\s\S]*?)<\/script>/i;
|
|
222
245
|
|
|
223
246
|
const UNPKG = 'https://unpkg.com/';
|
|
224
247
|
|
|
@@ -344,6 +367,10 @@ var unpkg = /*#__PURE__*/Object.freeze({
|
|
|
344
367
|
updateYAML: updateYAML
|
|
345
368
|
});
|
|
346
369
|
|
|
370
|
+
const imports = data.imports;
|
|
371
|
+
const scopes = data.scopes;
|
|
372
|
+
const importmap = new Importmap(data);
|
|
373
|
+
|
|
347
374
|
/**
|
|
348
375
|
* @typedef {Object<string, string>} ImportMapSpecifiers
|
|
349
376
|
*/
|
package/index.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { join } from 'node:path';
|
|
1
|
+
import { writeFile, readFile } from 'node:fs/promises';
|
|
3
2
|
import '@shgysk8zer0/polyfills';
|
|
4
3
|
import { readYAMLFile, writeYAMLFile } from '@shgysk8zer0/npm-utils/yaml.js';
|
|
5
4
|
import { readJSONFile, writeJSONFile } from '@shgysk8zer0/npm-utils/json.js';
|
|
6
5
|
import { getFileURL } from '@shgysk8zer0/npm-utils/path.js';
|
|
7
6
|
|
|
8
|
-
var json = JSON.parse('{\n "imports": {\n "@node/": "/node_modules/",\n "@shgysk8zer0/kazoo/": "https://unpkg.com/@shgysk8zer0/kazoo@1.0.11/",\n "@shgysk8zer0/konami": "https://unpkg.com/@shgysk8zer0/konami@1.1.2/konami.js",\n "@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.6.3/browser.min.js",\n "@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.6.3/",\n "@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.1.5/jwk-utils.min.js",\n "@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.1.5/",\n "@shgysk8zer0/jswaggersheets": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/swagger.js",\n "@shgysk8zer0/jswaggersheets/": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/",\n "@shgysk8zer0/jss/": "https://unpkg.com/@shgysk8zer0/jss@1.0.1/",\n "@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.8/",\n "@shgysk8zer0/http/": "https://unpkg.com/@shgysk8zer0/http@1.0.5/",\n "@shgysk8zer0/http-status": "https://unpkg.com/@shgysk8zer0/http-status@1.1.4/http-status.js",\n "@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.9/aes-gcm.min.js",\n "@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.9/",\n "@shgysk8zer0/squish": "https://unpkg.com/@shgysk8zer0/squish@1.0.2/squish.min.js",\n "@shgysk8zer0/squish/": "https://unpkg.com/@shgysk8zer0/squish@1.0.2/",\n "@shgysk8zer0/suid": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/suid.min.js",\n "@shgysk8zer0/suid/": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/",\n "@shgysk8zer0/geoutils": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/geoutils.min.js",\n "@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/",\n "@shgysk8zer0/core-css/": "https://unpkg.com/@shgysk8zer0/core-css@3.0.0/",\n "@shgysk8zer0/signals": "https://unpkg.com/@shgysk8zer0/signals@0.0.3/signals.min.js",\n "@shgysk8zer0/signals/": "https://unpkg.com/@shgysk8zer0/signals@0.0.3/",\n "@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",\n "@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",\n "@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.6/bundle.min.js",\n "@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.6/",\n "@aegisjsproject/sanitizer": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/sanitizer.js",\n "@aegisjsproject/sanitizer/": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/",\n "@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.34/core.js",\n "@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.34/",\n "@aegisjsproject/styles": "https://unpkg.com/@aegisjsproject/styles@0.3.2/styles.js",\n "@aegisjsproject/styles/": "https://unpkg.com/@aegisjsproject/styles@0.3.2/",\n "@aegisjsproject/component": "https://unpkg.com/@aegisjsproject/component@0.1.8/component.js",\n "@aegisjsproject/component/": "https://unpkg.com/@aegisjsproject/component@0.1.8/",\n "@aegisjsproject/markdown": "https://unpkg.com/@aegisjsproject/markdown@0.1.7/markdown.min.js",\n "@aegisjsproject/markdown/": "https://unpkg.com/@aegisjsproject/markdown@0.1.7/",\n "@aegisjsproject/aegis-md": "https://unpkg.com/@aegisjsproject/aegis-md@0.0.4/aegis-md.js",\n "@aegisjsproject/aegis-md/": "https://unpkg.com/@aegisjsproject/aegis-md@0.0.4/",\n "@aegisjsproject/url": "https://unpkg.com/@aegisjsproject/url@1.0.3/url.min.js",\n "@aegisjsproject/url/": "https://unpkg.com/@aegisjsproject/url@1.0.3/",\n "@aegisjsproject/idb/": "https://unpkg.com/@aegisjsproject/idb@1.0.6/",\n "@aegisjsproject/idb": "https://unpkg.com/@aegisjsproject/idb@1.0.6/idb.min.js",\n "@aegisjsproject/otp/": "https://unpkg.com/@aegisjsproject/otp@1.0.2/",\n "@aegisjsproject/otp": "https://unpkg.com/@aegisjsproject/otp@1.0.2/otp.min.js",\n "@aegisjsproject/md-editor": "https://unpkg.com/@aegisjsproject/md-editor@1.0.0/md-editor.js",\n "@aegisjsproject/md-editor/": "https://unpkg.com/@aegisjsproject/md-editor@1.0.0/",\n "@aegisjsproject/barcodescanner": "https://unpkg.com/@aegisjsproject/barcodescanner@1.2.3/scanner.min.js",\n "@aegisjsproject/barcodescanner/": "https://unpkg.com/@aegisjsproject/barcodescanner@1.2.3/",\n "@shgysk8zer0/components/": "https://unpkg.com/@shgysk8zer0/components@0.3.23/",\n "@aegisjsproject/state": "https://unpkg.com/@aegisjsproject/state@1.0.7/state.mjs",\n "@aegisjsproject/state/": "https://unpkg.com/@aegisjsproject/state@1.0.7/",\n "@aegisjsproject/router": "https://unpkg.com/@aegisjsproject/router@1.1.15/router.mjs",\n "@aegisjsproject/router/": "https://unpkg.com/@aegisjsproject/router@1.1.15/",\n "@aegisjsproject/callback-registry": "https://unpkg.com/@aegisjsproject/callback-registry@2.0.4/callbackRegistry.js",\n "@aegisjsproject/callback-registry/": "https://unpkg.com/@aegisjsproject/callback-registry@2.0.4/",\n "@aegisjsproject/attempt": "https://unpkg.com/@aegisjsproject/attempt@1.0.7/attempt.js",\n "@aegisjsproject/attempt/": "https://unpkg.com/@aegisjsproject/attempt@1.0.7/",\n "@aegisjsproject/secret-store": "https://unpkg.com/@aegisjsproject/secret-store@1.1.1/commands.min.js",\n "@aegisjsproject/commands/": "https://unpkg.com/@aegisjsproject/commands@1.0.2/",\n "@aegisjsproject/commands": "https://unpkg.com/@aegisjsproject/commands@1.0.2/commands.min.js",\n "@aegisjsproject/firebase-account-routes": "https://unpkg.com/@aegisjsproject/firebase-account-routes@0.0.6/main.js",\n "@aegisjsproject/firebase-account-routes/": "https://unpkg.com/@aegisjsproject/firebase-account-routes@0.0.6/",\n "@aegisjsproject/secret-store/": "https://unpkg.com/@aegisjsproject/secret-store@1.1.1/",\n "@aegisjsproject/qr-encoder": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/index.min.js",\n "@aegisjsproject/qr-encoder/": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/",\n "@aegisjsproject/escape": "https://unpkg.com/@aegisjsproject/escape@1.0.4/index.min.js",\n "@aegisjsproject/escape/": "https://unpkg.com/@aegisjsproject/escape@1.0.4/",\n "@aegisjsproject/disposable": "https://unpkg.com/@aegisjsproject/disposable@1.0.3/disposable.min.js",\n "@aegisjsproject/disposable/": "https://unpkg.com/@aegisjsproject/disposable@1.0.3/",\n "@aegisjsproject/iota": "https://unpkg.com/@aegisjsproject/iota@1.0.12/iota.min.js",\n "@aegisjsproject/iota/": "https://unpkg.com/@aegisjsproject/iota@1.0.12/",\n "@aegisjsproject/disposable-registry": "https://unpkg.com/@aegisjsproject/disposable-registry@1.0.2/registry.js",\n "@aegisjsproject/disposable-registry/": "https://unpkg.com/@aegisjsproject/disposable-registry@1.0.2/",\n "@aegisjsproject/hermes": "https://unpkg.com/@aegisjsproject/hermes@1.0.2/hermes.js",\n "@aegisjsproject/hermes/": "https://unpkg.com/@aegisjsproject/hermes@1.0.2/",\n "@kernvalley/components/": "https://unpkg.com/@kernvalley/components@2.0.10/",\n "@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",\n "leaflet": "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",\n "leaflet/": "https://unpkg.com/leaflet@1.9.4/dist/",\n "urlpattern-polyfill": "https://unpkg.com/urlpattern-polyfill@10.1.0/index.js",\n "highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/core.min.js",\n "highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/",\n "highlight.js/styles/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/",\n "@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/core.min.js",\n "@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/",\n "@highlightjs/cdn-assets/styles/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/",\n "marked": "https://unpkg.com/marked@18.0.0/lib/marked.esm.js",\n "marked-highlight": "https://unpkg.com/marked-highlight@2.2.4/src/index.js",\n "yaml": "https://unpkg.com/yaml@2.8.3/browser/dist/index.js",\n "yaml/": "https://unpkg.com/yaml@2.8.3/browser/dist/",\n "firebase/": "https://www.gstatic.com/firebasejs/10.12.1/",\n "firebase/app": "https://www.gstatic.com/firebasejs/10.12.1/firebase-app.js",\n "firebase/app-check": "https://www.gstatic.com/firebasejs/10.12.1/firebase-app-check.js",\n "firebase/auth": "https://www.gstatic.com/firebasejs/10.12.1/firebase-auth.js",\n "firebase/database": "https://www.gstatic.com/firebasejs/10.12.1/firebase-database.js",\n "firebase/firestore": "https://www.gstatic.com/firebasejs/10.12.1/firebase-firestore.js",\n "firebase/functions": "https://www.gstatic.com/firebasejs/10.12.1/firebase-functions.js",\n "firebase/messaging": "https://www.gstatic.com/firebasejs/10.12.1/firebase-messaging.js",\n "firebase/performance": "https://www.gstatic.com/firebasejs/10.12.1/firebase-performance.js",\n "firebase/remote-config": "https://www.gstatic.com/firebasejs/10.12.1/firebase-remote-config.js",\n "firebase/storage": "https://www.gstatic.com/firebasejs/10.12.1/firebase-storage.js",\n "firebase/analytics": "https://www.gstatic.com/firebasejs/10.12.1/firebase-analytics.js",\n "qr": "https://unpkg.com/qr@0.5.5/index.js",\n "qr/": "https://unpkg.com/qr@0.5.5/",\n "lit": "https://unpkg.com/lit@3.3.2/index.js",\n "lit/": "https://unpkg.com/lit@3.3.2/",\n "lit-html": "https://unpkg.com/lit-html@3.3.2/lit-html.js",\n "lit-html/": "https://unpkg.com/lit-html@3.3.2/",\n "lit-element": "https://unpkg.com/lit-element@4.2.2/lit-element.js",\n "lit-element/": "https://unpkg.com/lit-element@4.2.2/",\n "@lit/reactive-element": "https://unpkg.com/@lit/reactive-element@2.1.2/reactive-element.js",\n "@lit/reactive-element/": "https://unpkg.com/@lit/reactive-element@2.1.2/",\n "@awesome.me/webawesome/": "https://unpkg.com/@awesome.me/webawesome@3.5.0/",\n "normalize.css": "https://unpkg.com/normalize.css@8.0.1/normalize.css"\n },\n "scopes": {}\n}');
|
|
9
|
-
|
|
10
7
|
const SHA256 = 'SHA-256';
|
|
11
8
|
const SHA384 = 'SHA-384';
|
|
12
9
|
const SHA512 = 'SHA-512';
|
|
@@ -46,14 +43,12 @@ async function hash(data, { algo = DEFAULT_ALGO, output = BUFFER } = {}) {
|
|
|
46
43
|
|
|
47
44
|
const sri = async(data, { algo = SHA384 } = {}) => hash(data, { algo, output: SRI });
|
|
48
45
|
|
|
49
|
-
const { imports, scopes } = json;
|
|
50
|
-
|
|
51
46
|
class Importmap {
|
|
52
47
|
#imports = {};
|
|
53
48
|
#scopes = {};
|
|
54
|
-
#base;
|
|
49
|
+
#base = globalThis?.document?.baseURI ?? null;
|
|
55
50
|
|
|
56
|
-
constructor({ imports: i =
|
|
51
|
+
constructor({ imports: i = {}, scopes: s = {} } = {}) {
|
|
57
52
|
this.#imports = i;
|
|
58
53
|
this.#scopes = s;
|
|
59
54
|
}
|
|
@@ -101,12 +96,13 @@ class Importmap {
|
|
|
101
96
|
}
|
|
102
97
|
|
|
103
98
|
resolve(specifier, base = this.baseUrl) {
|
|
99
|
+
console.log({ specifier, base });
|
|
104
100
|
if (specifier instanceof URL) {
|
|
105
101
|
return specifier.href;
|
|
106
102
|
} else if (typeof specifier !== 'string') {
|
|
107
103
|
return null;
|
|
108
104
|
} else if (this.has(specifier)) {
|
|
109
|
-
return URL.parse(this.get(specifier),
|
|
105
|
+
return URL.parse(this.get(specifier), base)?.href ?? null;
|
|
110
106
|
} else if (URL.canParse(specifier)) {
|
|
111
107
|
return specifier;
|
|
112
108
|
} else if (! specifier.startsWith('.')) {
|
|
@@ -118,11 +114,12 @@ class Importmap {
|
|
|
118
114
|
if (matches.length === 0) {
|
|
119
115
|
return null;
|
|
120
116
|
} else {
|
|
117
|
+
const imports = this.#imports;
|
|
121
118
|
const match = matches[0];
|
|
122
119
|
const target = imports[match];
|
|
123
120
|
const subpath = specifier.slice(match.length);
|
|
124
121
|
// Resolve the mapping target against the map's base, then the subpath against that
|
|
125
|
-
const resolvedTarget = new URL(target,
|
|
122
|
+
const resolvedTarget = new URL(target, base);
|
|
126
123
|
return new URL(subpath, resolvedTarget).href;
|
|
127
124
|
}
|
|
128
125
|
} else if (typeof base === 'string') {
|
|
@@ -133,6 +130,11 @@ class Importmap {
|
|
|
133
130
|
}
|
|
134
131
|
|
|
135
132
|
async importLocalPackage(name = 'package.json', { signal } = {}) {
|
|
133
|
+
const [{ join }, { readFile }] = await Promise.all([
|
|
134
|
+
import('node:path'),
|
|
135
|
+
import('node:fs/promises'),
|
|
136
|
+
]);
|
|
137
|
+
|
|
136
138
|
const path = join(process.cwd(), name);
|
|
137
139
|
const pkg = await readFile(path, { encoding: 'utf8', signal });
|
|
138
140
|
|
|
@@ -175,10 +177,12 @@ class Importmap {
|
|
|
175
177
|
}
|
|
176
178
|
}
|
|
177
179
|
|
|
178
|
-
async getScript({ algo = DEFAULT_ALGO, alphabet = BASE64, signal } = {}) {
|
|
180
|
+
async getScript({ algo = DEFAULT_ALGO, alphabet = BASE64, name, signal } = {}) {
|
|
179
181
|
const integrity = await this.getIntegrity({ algo, alphabet, signal });
|
|
180
182
|
|
|
181
|
-
return
|
|
183
|
+
return typeof name === 'string'
|
|
184
|
+
? `<script type="importmap" name="${name}" integrity="${integrity}">${JSON.stringify(this)}</script>`
|
|
185
|
+
: `<script type="importmap" integrity="${integrity}">${JSON.stringify(this)}</script>`;
|
|
182
186
|
}
|
|
183
187
|
|
|
184
188
|
async getIntegrity({ algo = DEFAULT_ALGO, alphabet = BASE64, signal } = {}) {
|
|
@@ -205,7 +209,27 @@ class Importmap {
|
|
|
205
209
|
return SHA512;
|
|
206
210
|
}
|
|
207
211
|
|
|
212
|
+
static importFromScript(script) {
|
|
213
|
+
if (! ('HTMLScriptElement' in globalThis)) {
|
|
214
|
+
throw new Error('Attempting to import from the wrong environment.');
|
|
215
|
+
} else if (typeof script === 'string') {
|
|
216
|
+
return this.importFromScript(globalThis.document.scripts.namedItem(script));
|
|
217
|
+
} else if (typeof script === 'number') {
|
|
218
|
+
return this.importFromScript(globalThis.document.scripts.item(script));
|
|
219
|
+
} else if (! (script instanceof globalThis.HTMLScriptElement)) {
|
|
220
|
+
throw new TypeError('Can only import from a <script>.');
|
|
221
|
+
} else if (script.type !== 'importmap') {
|
|
222
|
+
throw new TypeError(`Cannot import importmap from a <script type="${script.type ?? 'application/jacascript'}">.`);
|
|
223
|
+
} else {
|
|
224
|
+
return new this(JSON.parse(script.textContent));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
208
228
|
static async importFromFile(path = 'importmap.json', { signal } = {}) {
|
|
229
|
+
const [{ join }, { readFile }] = await Promise.all([
|
|
230
|
+
import('node:path'),
|
|
231
|
+
import('node:fs/promises'),
|
|
232
|
+
]);
|
|
209
233
|
const fullPath = join(process.cwd(), path);
|
|
210
234
|
const importmap = await readFile(fullPath, { encoding: 'utf8', signal });
|
|
211
235
|
|
|
@@ -213,10 +237,9 @@ class Importmap {
|
|
|
213
237
|
}
|
|
214
238
|
}
|
|
215
239
|
|
|
216
|
-
const importmap = new Importmap({ imports, scopes });
|
|
240
|
+
var data = JSON.parse('{\n "imports": {\n "@node/": "/node_modules/",\n "@shgysk8zer0/kazoo/": "https://unpkg.com/@shgysk8zer0/kazoo@1.0.11/",\n "@shgysk8zer0/konami": "https://unpkg.com/@shgysk8zer0/konami@1.1.2/konami.js",\n "@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.6.3/browser.min.js",\n "@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.6.3/",\n "@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.1.5/jwk-utils.min.js",\n "@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.1.5/",\n "@shgysk8zer0/jswaggersheets": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/swagger.js",\n "@shgysk8zer0/jswaggersheets/": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/",\n "@shgysk8zer0/jss/": "https://unpkg.com/@shgysk8zer0/jss@1.0.1/",\n "@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.8/",\n "@shgysk8zer0/http/": "https://unpkg.com/@shgysk8zer0/http@1.0.5/",\n "@shgysk8zer0/http-status": "https://unpkg.com/@shgysk8zer0/http-status@1.1.4/http-status.js",\n "@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.9/aes-gcm.min.js",\n "@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.9/",\n "@shgysk8zer0/squish": "https://unpkg.com/@shgysk8zer0/squish@1.0.2/squish.min.js",\n "@shgysk8zer0/squish/": "https://unpkg.com/@shgysk8zer0/squish@1.0.2/",\n "@shgysk8zer0/suid": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/suid.min.js",\n "@shgysk8zer0/suid/": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/",\n "@shgysk8zer0/geoutils": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/geoutils.min.js",\n "@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/",\n "@shgysk8zer0/core-css/": "https://unpkg.com/@shgysk8zer0/core-css@3.0.0/",\n "@shgysk8zer0/signals": "https://unpkg.com/@shgysk8zer0/signals@0.0.3/signals.min.js",\n "@shgysk8zer0/signals/": "https://unpkg.com/@shgysk8zer0/signals@0.0.3/",\n "@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",\n "@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",\n "@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.6/bundle.min.js",\n "@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.6/",\n "@aegisjsproject/sanitizer": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/sanitizer.js",\n "@aegisjsproject/sanitizer/": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/",\n "@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.34/core.js",\n "@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.34/",\n "@aegisjsproject/styles": "https://unpkg.com/@aegisjsproject/styles@0.3.2/styles.js",\n "@aegisjsproject/styles/": "https://unpkg.com/@aegisjsproject/styles@0.3.2/",\n "@aegisjsproject/component": "https://unpkg.com/@aegisjsproject/component@0.1.8/component.js",\n "@aegisjsproject/component/": "https://unpkg.com/@aegisjsproject/component@0.1.8/",\n "@aegisjsproject/markdown": "https://unpkg.com/@aegisjsproject/markdown@0.1.7/markdown.min.js",\n "@aegisjsproject/markdown/": "https://unpkg.com/@aegisjsproject/markdown@0.1.7/",\n "@aegisjsproject/aegis-md": "https://unpkg.com/@aegisjsproject/aegis-md@0.0.4/aegis-md.js",\n "@aegisjsproject/aegis-md/": "https://unpkg.com/@aegisjsproject/aegis-md@0.0.4/",\n "@aegisjsproject/url": "https://unpkg.com/@aegisjsproject/url@1.0.3/url.min.js",\n "@aegisjsproject/url/": "https://unpkg.com/@aegisjsproject/url@1.0.3/",\n "@aegisjsproject/idb/": "https://unpkg.com/@aegisjsproject/idb@1.0.6/",\n "@aegisjsproject/idb": "https://unpkg.com/@aegisjsproject/idb@1.0.6/idb.min.js",\n "@aegisjsproject/otp/": "https://unpkg.com/@aegisjsproject/otp@1.0.2/",\n "@aegisjsproject/otp": "https://unpkg.com/@aegisjsproject/otp@1.0.2/otp.min.js",\n "@aegisjsproject/md-editor": "https://unpkg.com/@aegisjsproject/md-editor@1.0.0/md-editor.js",\n "@aegisjsproject/md-editor/": "https://unpkg.com/@aegisjsproject/md-editor@1.0.0/",\n "@aegisjsproject/barcodescanner": "https://unpkg.com/@aegisjsproject/barcodescanner@1.2.3/scanner.min.js",\n "@aegisjsproject/barcodescanner/": "https://unpkg.com/@aegisjsproject/barcodescanner@1.2.3/",\n "@shgysk8zer0/components/": "https://unpkg.com/@shgysk8zer0/components@0.3.23/",\n "@aegisjsproject/state": "https://unpkg.com/@aegisjsproject/state@1.0.7/state.mjs",\n "@aegisjsproject/state/": "https://unpkg.com/@aegisjsproject/state@1.0.7/",\n "@aegisjsproject/router": "https://unpkg.com/@aegisjsproject/router@1.1.15/router.mjs",\n "@aegisjsproject/router/": "https://unpkg.com/@aegisjsproject/router@1.1.15/",\n "@aegisjsproject/callback-registry": "https://unpkg.com/@aegisjsproject/callback-registry@2.0.4/callbackRegistry.js",\n "@aegisjsproject/callback-registry/": "https://unpkg.com/@aegisjsproject/callback-registry@2.0.4/",\n "@aegisjsproject/attempt": "https://unpkg.com/@aegisjsproject/attempt@1.0.7/attempt.js",\n "@aegisjsproject/attempt/": "https://unpkg.com/@aegisjsproject/attempt@1.0.7/",\n "@aegisjsproject/secret-store": "https://unpkg.com/@aegisjsproject/secret-store@1.1.1/commands.min.js",\n "@aegisjsproject/commands/": "https://unpkg.com/@aegisjsproject/commands@1.0.2/",\n "@aegisjsproject/commands": "https://unpkg.com/@aegisjsproject/commands@1.0.2/commands.min.js",\n "@aegisjsproject/firebase-account-routes": "https://unpkg.com/@aegisjsproject/firebase-account-routes@0.0.6/main.js",\n "@aegisjsproject/firebase-account-routes/": "https://unpkg.com/@aegisjsproject/firebase-account-routes@0.0.6/",\n "@aegisjsproject/secret-store/": "https://unpkg.com/@aegisjsproject/secret-store@1.1.1/",\n "@aegisjsproject/qr-encoder": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/index.min.js",\n "@aegisjsproject/qr-encoder/": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/",\n "@aegisjsproject/escape": "https://unpkg.com/@aegisjsproject/escape@1.0.4/index.min.js",\n "@aegisjsproject/escape/": "https://unpkg.com/@aegisjsproject/escape@1.0.4/",\n "@aegisjsproject/disposable": "https://unpkg.com/@aegisjsproject/disposable@1.0.3/disposable.min.js",\n "@aegisjsproject/disposable/": "https://unpkg.com/@aegisjsproject/disposable@1.0.3/",\n "@aegisjsproject/iota": "https://unpkg.com/@aegisjsproject/iota@1.0.12/iota.min.js",\n "@aegisjsproject/iota/": "https://unpkg.com/@aegisjsproject/iota@1.0.12/",\n "@aegisjsproject/disposable-registry": "https://unpkg.com/@aegisjsproject/disposable-registry@1.0.2/registry.js",\n "@aegisjsproject/disposable-registry/": "https://unpkg.com/@aegisjsproject/disposable-registry@1.0.2/",\n "@aegisjsproject/hermes": "https://unpkg.com/@aegisjsproject/hermes@1.0.2/hermes.js",\n "@aegisjsproject/hermes/": "https://unpkg.com/@aegisjsproject/hermes@1.0.2/",\n "@kernvalley/components/": "https://unpkg.com/@kernvalley/components@2.0.10/",\n "@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",\n "leaflet": "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",\n "leaflet/": "https://unpkg.com/leaflet@1.9.4/dist/",\n "urlpattern-polyfill": "https://unpkg.com/urlpattern-polyfill@10.1.0/index.js",\n "highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/core.min.js",\n "highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/",\n "highlight.js/styles/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/",\n "@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/core.min.js",\n "@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/",\n "@highlightjs/cdn-assets/styles/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/",\n "marked": "https://unpkg.com/marked@18.0.0/lib/marked.esm.js",\n "marked-highlight": "https://unpkg.com/marked-highlight@2.2.4/src/index.js",\n "yaml": "https://unpkg.com/yaml@2.8.3/browser/dist/index.js",\n "yaml/": "https://unpkg.com/yaml@2.8.3/browser/dist/",\n "firebase/": "https://www.gstatic.com/firebasejs/10.12.1/",\n "firebase/app": "https://www.gstatic.com/firebasejs/10.12.1/firebase-app.js",\n "firebase/app-check": "https://www.gstatic.com/firebasejs/10.12.1/firebase-app-check.js",\n "firebase/auth": "https://www.gstatic.com/firebasejs/10.12.1/firebase-auth.js",\n "firebase/database": "https://www.gstatic.com/firebasejs/10.12.1/firebase-database.js",\n "firebase/firestore": "https://www.gstatic.com/firebasejs/10.12.1/firebase-firestore.js",\n "firebase/functions": "https://www.gstatic.com/firebasejs/10.12.1/firebase-functions.js",\n "firebase/messaging": "https://www.gstatic.com/firebasejs/10.12.1/firebase-messaging.js",\n "firebase/performance": "https://www.gstatic.com/firebasejs/10.12.1/firebase-performance.js",\n "firebase/remote-config": "https://www.gstatic.com/firebasejs/10.12.1/firebase-remote-config.js",\n "firebase/storage": "https://www.gstatic.com/firebasejs/10.12.1/firebase-storage.js",\n "firebase/analytics": "https://www.gstatic.com/firebasejs/10.12.1/firebase-analytics.js",\n "qr": "https://unpkg.com/qr@0.5.5/index.js",\n "qr/": "https://unpkg.com/qr@0.5.5/",\n "lit": "https://unpkg.com/lit@3.3.2/index.js",\n "lit/": "https://unpkg.com/lit@3.3.2/",\n "lit-html": "https://unpkg.com/lit-html@3.3.2/lit-html.js",\n "lit-html/": "https://unpkg.com/lit-html@3.3.2/",\n "lit-element": "https://unpkg.com/lit-element@4.2.2/lit-element.js",\n "lit-element/": "https://unpkg.com/lit-element@4.2.2/",\n "@lit/reactive-element": "https://unpkg.com/@lit/reactive-element@2.1.2/reactive-element.js",\n "@lit/reactive-element/": "https://unpkg.com/@lit/reactive-element@2.1.2/",\n "@awesome.me/webawesome/": "https://unpkg.com/@awesome.me/webawesome@3.5.0/",\n "normalize.css": "https://unpkg.com/normalize.css@8.0.1/normalize.css"\n },\n "scopes": {}\n}');
|
|
217
241
|
|
|
218
|
-
|
|
219
|
-
const IMPORTMAP_EXP = /<script\b(?=[^>]*\btype=["']importmap["'])(?:[^>]*?\bnonce=["'](?<nonce>[^"']*)["'])?[^>]*>(?<content>[\s\S]*?)<\/script>/i;
|
|
242
|
+
const IMPORTMAP_EXP = /<script\b(?=[^>]*\btype=["']importmap["'])(?=(?:[^>]*\bnonce=["'](?<nonce>[^"']*)["'])?)(?=(?:[^>]*\bname=["'](?<name>[^"']*)["'])?)[^>]*>(?<content>[\s\S]*?)<\/script>/i;
|
|
220
243
|
|
|
221
244
|
const UNPKG = 'https://unpkg.com/';
|
|
222
245
|
|
|
@@ -342,6 +365,10 @@ var unpkg = /*#__PURE__*/Object.freeze({
|
|
|
342
365
|
updateYAML: updateYAML
|
|
343
366
|
});
|
|
344
367
|
|
|
368
|
+
const imports = data.imports;
|
|
369
|
+
const scopes = data.scopes;
|
|
370
|
+
const importmap = new Importmap(data);
|
|
371
|
+
|
|
345
372
|
/**
|
|
346
373
|
* @typedef {Object<string, string>} ImportMapSpecifiers
|
|
347
374
|
*/
|