@shgysk8zer0/importmap 1.7.13 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [v1.8.1] -- 2026-03-04
11
+
12
+ ### Added
13
+ - Add function/CLI to update `<script type="importmap">` in HTML files
14
+ - Add support for parsing a `<script type="importmap">` from an HTML file
15
+ - Add JSDocs
16
+
17
+ ### Fixed
18
+ - Fix bad config for `bin` in `package.json`
19
+ - Ignore generated `index.js` file
20
+
21
+ ### Changed
22
+ - Use `@shgysk8zer0/rollup-import` instead of `@rollup/plugin-json`
23
+
24
+ ## [v1.8.0] - 2026-03-03
25
+
26
+ ### Added
27
+ - Add `normalize.css` for importing `with { type: 'css' }`
28
+
29
+ ### Changed
30
+ - Update `@aegisjsproject/attempt`
31
+ - Update dependencies
32
+
10
33
  ## [v1.7.13] - 2026-03-02
11
34
 
12
35
  ### Changed
package/README.md CHANGED
@@ -73,6 +73,9 @@ Which results in:
73
73
 
74
74
  ## CLI
75
75
 
76
+
77
+ ### `importmap-utils`
78
+
76
79
  Create / update local importmap JSON or YAML files.
77
80
 
78
81
  ```
@@ -89,6 +92,22 @@ Options:
89
92
  -h, --help display help for command
90
93
  ```
91
94
 
95
+ ### `importmap-html`
96
+
97
+ Updates the `<script type="importmap">` in an HTML file
98
+ ```
99
+ Usage: importmap-html [options] <html-file>
100
+
101
+ CLI utility for updating `<script type="importmap">` in HTML files
102
+
103
+ Options:
104
+ -V, --version output the version number
105
+ -a, --algo [algo] Hashing algorigthm to use for `integrity` (default: "SHA-384")
106
+ -s, --spaces [spaces] Spaces to indent with
107
+ -i, --importmap [importmap] Source importmap.json file.
108
+ -h, --help display help for command
109
+ ```
110
+
92
111
  ### CLI Example
93
112
 
94
113
  ```bash
@@ -97,4 +116,8 @@ importmap-utils -o importmap.json
97
116
  # Or...
98
117
 
99
118
  importmap-utils -i importmap.json -o importmap.yml -f yaml
119
+
120
+ importmap-html index.html
121
+
122
+ importmap index.html -i imports.json -a sha-512
100
123
  ```
package/cli.cjs CHANGED
@@ -2,308 +2,16 @@
2
2
 
3
3
  var json_js = require('@shgysk8zer0/npm-utils/json.js');
4
4
  var yaml_js = require('@shgysk8zer0/npm-utils/yaml.js');
5
+ var promises = require('node:fs/promises');
5
6
  var commander = require('commander');
6
7
  var node_path = require('node:path');
7
- var promises = require('node:fs/promises');
8
- require('@shgysk8zer0/polyfills');
9
- require('@shgysk8zer0/npm-utils/path.js');
10
-
11
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
12
- const imports$1 = {
13
- "@node/": "/node_modules/",
14
- "@shgysk8zer0/kazoo/": "https://unpkg.com/@shgysk8zer0/kazoo@1.0.11/",
15
- "@shgysk8zer0/konami": "https://unpkg.com/@shgysk8zer0/konami@1.1.2/konami.js",
16
- "@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.6.2/browser.min.js",
17
- "@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.6.2/",
18
- "@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.20/jwk-utils.min.js",
19
- "@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.20/",
20
- "@shgysk8zer0/jswaggersheets": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/swagger.js",
21
- "@shgysk8zer0/jswaggersheets/": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/",
22
- "@shgysk8zer0/jss/": "https://unpkg.com/@shgysk8zer0/jss@1.0.1/",
23
- "@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.8/",
24
- "@shgysk8zer0/http/": "https://unpkg.com/@shgysk8zer0/http@1.0.5/",
25
- "@shgysk8zer0/http-status": "https://unpkg.com/@shgysk8zer0/http-status@1.1.4/http-status.js",
26
- "@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.8/aes-gcm.min.js",
27
- "@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.8/",
28
- "@shgysk8zer0/squish": "https://unpkg.com/@shgysk8zer0/squish@1.0.2/squish.min.js",
29
- "@shgysk8zer0/squish/": "https://unpkg.com/@shgysk8zer0/squish@1.0.2/",
30
- "@shgysk8zer0/suid": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/suid.min.js",
31
- "@shgysk8zer0/suid/": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/",
32
- "@shgysk8zer0/geoutils": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/geoutils.min.js",
33
- "@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.6/",
34
- "@shgysk8zer0/core-css/": "https://unpkg.com/@shgysk8zer0/core-css@2.5.4/",
35
- "@shgysk8zer0/signals": "https://unpkg.com/@shgysk8zer0/signals@0.0.3/signals.min.js",
36
- "@shgysk8zer0/signals/": "https://unpkg.com/@shgysk8zer0/signals@0.0.3/",
37
- "@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",
38
- "@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",
39
- "@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/bundle.min.js",
40
- "@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/",
41
- "@aegisjsproject/sanitizer": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/sanitizer.js",
42
- "@aegisjsproject/sanitizer/": "https://unpkg.com/@aegisjsproject/sanitizer@0.2.4/",
43
- "@aegisjsproject/core": "https://unpkg.com/@aegisjsproject/core@0.2.33/core.js",
44
- "@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.33/",
45
- "@aegisjsproject/styles": "https://unpkg.com/@aegisjsproject/styles@0.2.7/styles.js",
46
- "@aegisjsproject/styles/": "https://unpkg.com/@aegisjsproject/styles@0.2.7/",
47
- "@aegisjsproject/component": "https://unpkg.com/@aegisjsproject/component@0.1.7/component.js",
48
- "@aegisjsproject/component/": "https://unpkg.com/@aegisjsproject/component@0.1.7/",
49
- "@aegisjsproject/markdown": "https://unpkg.com/@aegisjsproject/markdown@0.1.6/markdown.min.js",
50
- "@aegisjsproject/markdown/": "https://unpkg.com/@aegisjsproject/markdown@0.1.6/",
51
- "@aegisjsproject/aegis-md": "https://unpkg.com/@aegisjsproject/aegis-md@0.0.4/aegis-md.js",
52
- "@aegisjsproject/aegis-md/": "https://unpkg.com/@aegisjsproject/aegis-md@0.0.4/",
53
- "@aegisjsproject/url": "https://unpkg.com/@aegisjsproject/url@1.0.3/url.min.js",
54
- "@aegisjsproject/url/": "https://unpkg.com/@aegisjsproject/url@1.0.3/",
55
- "@aegisjsproject/idb/": "https://unpkg.com/@aegisjsproject/idb@1.0.6/",
56
- "@aegisjsproject/idb": "https://unpkg.com/@aegisjsproject/idb@1.0.6/idb.min.js",
57
- "@aegisjsproject/otp/": "https://unpkg.com/@aegisjsproject/otp@1.0.1/",
58
- "@aegisjsproject/otp": "https://unpkg.com/@aegisjsproject/otp@1.0.1/otp.min.js",
59
- "@aegisjsproject/md-editor": "https://unpkg.com/@aegisjsproject/md-editor@1.0.0/md-editor.js",
60
- "@aegisjsproject/md-editor/": "https://unpkg.com/@aegisjsproject/md-editor@1.0.0/",
61
- "@aegisjsproject/barcodescanner": "https://unpkg.com/@aegisjsproject/barcodescanner@1.2.3/scanner.min.js",
62
- "@aegisjsproject/barcodescanner/": "https://unpkg.com/@aegisjsproject/barcodescanner@1.2.3/",
63
- "@shgysk8zer0/components/": "https://unpkg.com/@shgysk8zer0/components@0.3.22/",
64
- "@aegisjsproject/state": "https://unpkg.com/@aegisjsproject/state@1.0.7/state.mjs",
65
- "@aegisjsproject/state/": "https://unpkg.com/@aegisjsproject/state@1.0.7/",
66
- "@aegisjsproject/router": "https://unpkg.com/@aegisjsproject/router@1.1.15/router.mjs",
67
- "@aegisjsproject/router/": "https://unpkg.com/@aegisjsproject/router@1.1.15/",
68
- "@aegisjsproject/callback-registry": "https://unpkg.com/@aegisjsproject/callback-registry@2.0.0/callbackRegistry.js",
69
- "@aegisjsproject/callback-registry/": "https://unpkg.com/@aegisjsproject/callback-registry@2.0.0/",
70
- "@aegisjsproject/attempt": "https://unpkg.com/@aegisjsproject/attempt@1.0.5/attempt.js",
71
- "@aegisjsproject/attempt/": "https://unpkg.com/@aegisjsproject/attempt@1.0.5/",
72
- "@aegisjsproject/secret-store": "https://unpkg.com/@aegisjsproject/secret-store@1.0.1/commands.min.js",
73
- "@aegisjsproject/commands/": "https://unpkg.com/@aegisjsproject/commands@1.0.1/",
74
- "@aegisjsproject/commands": "https://unpkg.com/@aegisjsproject/commands@1.0.1/commands.min.js",
75
- "@aegisjsproject/firebase-account-routes": "https://unpkg.com/@aegisjsproject/firebase-account-routes@0.0.5/main.js",
76
- "@aegisjsproject/firebase-account-routes/": "https://unpkg.com/@aegisjsproject/firebase-account-routes@0.0.5/",
77
- "@aegisjsproject/secret-store/": "https://unpkg.com/@aegisjsproject/secret-store@1.0.1/",
78
- "@aegisjsproject/qr-encoder": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/index.min.js",
79
- "@aegisjsproject/qr-encoder/": "https://unpkg.com/@aegisjsproject/qr-encoder@1.0.1/",
80
- "@aegisjsproject/escape": "https://unpkg.com/@aegisjsproject/escape@1.0.4/index.min.js",
81
- "@aegisjsproject/escape/": "https://unpkg.com/@aegisjsproject/escape@1.0.4/",
82
- "@aegisjsproject/disposable": "https://unpkg.com/@aegisjsproject/disposable@1.0.3/disposable.min.js",
83
- "@aegisjsproject/disposable/": "https://unpkg.com/@aegisjsproject/disposable@1.0.3/",
84
- "@kernvalley/components/": "https://unpkg.com/@kernvalley/components@2.0.9/",
85
- "@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",
86
- leaflet: "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",
87
- "leaflet/": "https://unpkg.com/leaflet@1.9.4/dist/",
88
- "urlpattern-polyfill": "https://unpkg.com/urlpattern-polyfill@10.1.0/index.js",
89
- "highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/core.min.js",
90
- "highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/",
91
- "highlight.js/styles/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/",
92
- "@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/core.min.js",
93
- "@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/es/",
94
- "@highlightjs/cdn-assets/styles/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.1/styles/",
95
- marked: "https://unpkg.com/marked@17.0.3/lib/marked.esm.js",
96
- "marked-highlight": "https://unpkg.com/marked-highlight@2.2.3/src/index.js",
97
- yaml: "https://unpkg.com/yaml@2.8.2/browser/dist/index.js",
98
- "yaml/": "https://unpkg.com/yaml@2.8.2/browser/dist/",
99
- "firebase/": "https://www.gstatic.com/firebasejs/10.12.1/",
100
- "firebase/app": "https://www.gstatic.com/firebasejs/10.12.1/firebase-app.js",
101
- "firebase/app-check": "https://www.gstatic.com/firebasejs/10.12.1/firebase-app-check.js",
102
- "firebase/auth": "https://www.gstatic.com/firebasejs/10.12.1/firebase-auth.js",
103
- "firebase/database": "https://www.gstatic.com/firebasejs/10.12.1/firebase-database.js",
104
- "firebase/firestore": "https://www.gstatic.com/firebasejs/10.12.1/firebase-firestore.js",
105
- "firebase/functions": "https://www.gstatic.com/firebasejs/10.12.1/firebase-functions.js",
106
- "firebase/messaging": "https://www.gstatic.com/firebasejs/10.12.1/firebase-messaging.js",
107
- "firebase/performance": "https://www.gstatic.com/firebasejs/10.12.1/firebase-performance.js",
108
- "firebase/remote-config": "https://www.gstatic.com/firebasejs/10.12.1/firebase-remote-config.js",
109
- "firebase/storage": "https://www.gstatic.com/firebasejs/10.12.1/firebase-storage.js",
110
- "firebase/analytics": "https://www.gstatic.com/firebasejs/10.12.1/firebase-analytics.js",
111
- qr: "https://unpkg.com/qr@0.5.4/index.js",
112
- "qr/": "https://unpkg.com/qr@0.5.4/",
113
- lit: "https://unpkg.com/lit@3.3.2/index.js",
114
- "lit/": "https://unpkg.com/lit@3.3.2/",
115
- "lit-html": "https://unpkg.com/lit-html@3.3.2/lit-html.js",
116
- "lit-html/": "https://unpkg.com/lit-html@3.3.2/",
117
- "lit-element": "https://unpkg.com/lit-element@4.2.2/lit-element.js",
118
- "lit-element/": "https://unpkg.com/lit-element@4.2.2/",
119
- "@lit/reactive-element": "https://unpkg.com/@lit/reactive-element@2.1.2/reactive-element.js",
120
- "@lit/reactive-element/": "https://unpkg.com/@lit/reactive-element@2.1.2/",
121
- "@awesome.me/webawesome/": "https://unpkg.com/@awesome.me/webawesome@3.2.1/"
122
- };
123
- const scopes$1 = {
124
- };
125
- var json = {
126
- imports: imports$1,
127
- scopes: scopes$1
128
- };
129
-
130
- const SHA256 = 'SHA-256';
131
- const SHA384 = 'SHA-384';
132
- const SHA512 = 'SHA-512';
133
- const DEFAULT_ALGO = SHA384;
134
-
135
- const BASE64 = 'base64';
136
-
137
- const { imports, scopes } = json;
138
-
139
- class Importmap {
140
- #imports = {};
141
- #scopes = {};
142
- #base;
143
-
144
- constructor({ imports: i = imports, scopes: s = scopes } = {}) {
145
- this.#imports = i;
146
- this.#scopes = s;
147
- }
148
-
149
- get imports() {
150
- return structuredClone(this.#imports);
151
- }
152
-
153
- get scopes() {
154
- return structuredClone(this.#scopes);
155
- }
156
-
157
- delete(key) {
158
- return Reflect.deleteProperty(this.#imports, key);
159
- }
160
-
161
- get(key) {
162
- return Reflect.get(this.#imports, key);
163
- }
164
-
165
- has(key) {
166
- return Reflect.has(this.#imports, key);
167
- }
168
-
169
- set(key, newValue) {
170
- return Reflect.set(this.#imports, key, newValue);
171
- }
172
-
173
- toJSON() {
174
- return { imports: this.#imports, scopes: this.#scopes };
175
- }
176
-
177
- toString() {
178
- return JSON.stringify(this);
179
- }
180
-
181
- get baseUrl() {
182
- return this.#base;
183
- }
184
-
185
- set baseUrl(val) {
186
- if (typeof val === 'string' && URL.canParse(val)) {
187
- this.#base = val;
188
- }
189
- }
190
-
191
- resolve(specifier, base = this.baseUrl) {
192
- if (specifier instanceof URL) {
193
- return specifier.href;
194
- } else if (typeof specifier !== 'string') {
195
- return null;
196
- } else if (this.has(specifier)) {
197
- return URL.parse(this.get(specifier), this.baseUrl)?.href ?? null;
198
- } else if (URL.canParse(specifier)) {
199
- return specifier;
200
- } else if (! specifier.startsWith('.')) {
201
- // Find the longest match
202
- const matches = Object.keys(this.imports)
203
- .filter(key => key.endsWith('/') && specifier.startsWith(key))
204
- .sort((a, b) => b.length - a.length);
205
8
 
206
- if (matches.length === 0) {
207
- return null;
208
- } else {
209
- const match = matches[0];
210
- const target = imports[match];
211
- const subpath = specifier.slice(match.length);
212
- // Resolve the mapping target against the map's base, then the subpath against that
213
- const resolvedTarget = new URL(target, this.baseUrl);
214
- return new URL(subpath, resolvedTarget).href;
215
- }
216
- } else if (typeof base === 'string') {
217
- return URL.parse(specifier, base)?.href ?? null;
218
- } else {
219
- return null;
220
- }
221
- }
222
-
223
- async importLocalPackage(name = 'package.json', { signal } = {}) {
224
- const path = node_path.join(process.cwd(), name);
225
- const pkg = await promises.readFile(path, { encoding: 'utf8', signal });
226
-
227
- return this.setLocalPackage(JSON.parse(pkg));
228
- }
229
-
230
- setLocalPackage({ name, module, exports = {} }) {
231
- if (typeof name !== 'string') {
232
- return false;
233
- } else if (typeof exports === 'string' ) {
234
- this.set(name, exports);
235
- return true;
236
- } else if (typeof exports === 'object') {
237
- Object.entries(exports).forEach(([key, value]) => {
238
- if (key.startsWith('.')) {
239
- const importKey = key === '.' ? name : `${name}${key.substring(1)}`;
240
- const resolved = typeof value === 'string' ? value : value.import ?? value.default;
241
-
242
- if (typeof resolved === 'string' && resolved.startsWith('./')) {
243
- if (importKey.includes('*') && resolved.includes('*')) {
244
- const [prefix, suffix] = importKey.split('*');
245
-
246
- if (resolved.endsWith('*' + suffix)) {
247
- this.set(prefix, resolved.substring(1).replace('*' + suffix, ''));
248
- }
249
- } else {
250
- this.set(importKey, resolved.substring(1));
251
- }
252
- }
253
- }
254
- });
255
-
256
- return true;
257
- } else if (typeof module === 'string') {
258
- this.set(name, module);
259
- return true;
260
- } else {
261
- this.set(name, '/');
262
- return true;
263
- }
264
- }
265
-
266
- async getScript({ algo = DEFAULT_ALGO, alphabet = BASE64, signal } = {}) {
267
- const integrity = await this.getIntegrity({ algo, alphabet, signal });
268
-
269
- return `<script type="importmap" integrity="${integrity}">${JSON.stringify(this)}</script>`;
270
- }
271
-
272
- async getIntegrity({ algo = DEFAULT_ALGO, alphabet = BASE64, signal } = {}) {
273
- if (signal instanceof AbortSignal && signal.aborted) {
274
- throw signal.reason;
275
- } else {
276
- const prefix = algo.toLowerCase().replace('-', '') + '-';
277
- const encoded = new TextEncoder().encode(this);
278
- const hash = await crypto.subtle.digest(algo, encoded);
279
-
280
- return prefix + new Uint8Array(hash).toBase64({ alphabet });
281
- }
282
- }
283
-
284
- static get SHA256() {
285
- return SHA256;
286
- }
287
-
288
- static get SHA384() {
289
- return SHA384;
290
- }
9
+ // export const IMPORTMAP_EXP = /<script\b(?=[^>]*\btype=["']importmap["'])(?:[^>]*?\bnonce=["'](?<nonce>[^"']*)["'])?[^>]*>[\s\S]*?<\/script>/i;
10
+ const IMPORTMAP_EXP = /<script\b(?=[^>]*\btype=["']importmap["'])(?:[^>]*?\bnonce=["'](?<nonce>[^"']*)["'])?[^>]*>(?<content>[\s\S]*?)<\/script>/i;
291
11
 
292
- static get SHA512() {
293
- return SHA512;
294
- }
12
+ var pkg = JSON.parse('{\n "name": "@shgysk8zer0/importmap",\n "version": "1.8.1",\n "engines": {\n "node": ">=20.10.0"\n },\n "description": "Front-End dependencies based on `<script type=\\"importmap\\">`",\n "type": "module",\n "module": "./index.js",\n "main": "./index.cjs",\n "unpkg": "./index.js",\n "exports": {\n ".": {\n "import": "./index.js",\n "require": "./index.cjs"\n },\n "./importmap": {\n "import": "./importmap.js"\n },\n "./*.json": {\n "import": "./*.json"\n },\n "./*.js": {\n "import": "./*.js",\n "require": "./*.cjs"\n },\n "./*.mjs": {\n "import": "./*.js"\n },\n "./*.cjs": {\n "require": "./*.cjs"\n },\n "./*": {\n "import": "./*.js",\n "require": "./*.cjs"\n }\n },\n "bin": {\n "importmap-utils": "cli.js",\n "importmap-html": "html.js"\n },\n "scripts": {\n "start": "npx @shgysk8zer0/http-server -c ./http.config.js",\n "test": "npm run lint:js && npm run run:tests && npm run test:imports",\n "preversion": "npm test && npm run build",\n "prepare": "npm test && npm run build",\n "update": "node ./update.js",\n "lint:js": "eslint . --ignore-pattern \'importmap.mjs\'",\n "fix:js": "eslint . --fix",\n "build": "npm run build:js",\n "build:js": "rollup -c",\n "test:imports": "rollup -c rollup.test.config.js",\n "run:tests": "node --test *.test.js",\n "create:lock": "npm i --package-lock-only --ignore-scripts --no-audit --no-fund",\n "version:bump": "npm run version:bump:patch",\n "version:bump:patch": "npm version --no-git-tag-version patch && npm run create:lock",\n "version:bump:minor": "npm version --no-git-tag-version minor && npm run create:lock",\n "version:bump:major": "npm version --no-git-tag-version major && npm run create:lock"\n },\n "repository": {\n "type": "git",\n "url": "git+https://github.com/shgysk8zer0/importmap.git"\n },\n "author": "Chris Zuber <admin@kernvalley.us>",\n "license": "MIT",\n "bugs": {\n "url": "https://github.com/shgysk8zer0/importmap/issues"\n },\n "homepage": "https://github.com/shgysk8zer0/importmap#readme",\n "devDependencies": {\n "@shgysk8zer0/eslint-config": "^1.0.7",\n "@shgysk8zer0/js-utils": "^1.0.3",\n "@shgysk8zer0/rollup-import": "^2.0.2",\n "eslint": "^10.0.2"\n },\n "dependencies": {\n "@shgysk8zer0/npm-utils": "^1.1.4",\n "@shgysk8zer0/polyfills": "^0.6.2",\n "commander": "^14.0.3"\n }\n}\n');
295
13
 
296
- static async importFromFile(path = 'importmap.json', { signal } = {}) {
297
- const fullPath = node_path.join(process.cwd(), path);
298
- const importmap = await promises.readFile(fullPath, { encoding: 'utf8', signal });
299
-
300
- return new Importmap(JSON.parse(importmap));
301
- }
302
- }
303
-
304
- const importmap = new Importmap({ imports, scopes });
305
-
306
- // import { updateImportMap } from './html.js';
14
+ var importmap = 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.2/browser.min.js",\n "@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.6.2/",\n "@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.20/jwk-utils.min.js",\n "@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.20/",\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.8/aes-gcm.min.js",\n "@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.8/",\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@2.5.4/",\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.5/bundle.min.js",\n "@aegisjsproject/parsers/": "https://unpkg.com/@aegisjsproject/parsers@0.1.5/",\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.33/core.js",\n "@aegisjsproject/core/": "https://unpkg.com/@aegisjsproject/core@0.2.33/",\n "@aegisjsproject/styles": "https://unpkg.com/@aegisjsproject/styles@0.2.7/styles.js",\n "@aegisjsproject/styles/": "https://unpkg.com/@aegisjsproject/styles@0.2.7/",\n "@aegisjsproject/component": "https://unpkg.com/@aegisjsproject/component@0.1.7/component.js",\n "@aegisjsproject/component/": "https://unpkg.com/@aegisjsproject/component@0.1.7/",\n "@aegisjsproject/markdown": "https://unpkg.com/@aegisjsproject/markdown@0.1.6/markdown.min.js",\n "@aegisjsproject/markdown/": "https://unpkg.com/@aegisjsproject/markdown@0.1.6/",\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.1/",\n "@aegisjsproject/otp": "https://unpkg.com/@aegisjsproject/otp@1.0.1/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.22/",\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.0/callbackRegistry.js",\n "@aegisjsproject/callback-registry/": "https://unpkg.com/@aegisjsproject/callback-registry@2.0.0/",\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.0.1/commands.min.js",\n "@aegisjsproject/commands/": "https://unpkg.com/@aegisjsproject/commands@1.0.1/",\n "@aegisjsproject/commands": "https://unpkg.com/@aegisjsproject/commands@1.0.1/commands.min.js",\n "@aegisjsproject/firebase-account-routes": "https://unpkg.com/@aegisjsproject/firebase-account-routes@0.0.5/main.js",\n "@aegisjsproject/firebase-account-routes/": "https://unpkg.com/@aegisjsproject/firebase-account-routes@0.0.5/",\n "@aegisjsproject/secret-store/": "https://unpkg.com/@aegisjsproject/secret-store@1.0.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 "@kernvalley/components/": "https://unpkg.com/@kernvalley/components@2.0.9/",\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@17.0.3/lib/marked.esm.js",\n "marked-highlight": "https://unpkg.com/marked-highlight@2.2.3/src/index.js",\n "yaml": "https://unpkg.com/yaml@2.8.2/browser/dist/index.js",\n "yaml/": "https://unpkg.com/yaml@2.8.2/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.4/index.js",\n "qr/": "https://unpkg.com/qr@0.5.4/",\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.2.1/",\n "normalize.css": "https://unpkg.com/normalize.css@8.0.1/normalize.css"\n },\n "scopes": {}\n}');
307
15
 
308
16
  function guessFileType(file) {
309
17
  const ext = node_path.extname(file).toLowerCase();
@@ -332,15 +40,19 @@ async function parse(file, { encoding, signal } = {}) {
332
40
  case 'json':
333
41
  return json_js.readJSONFile(file, { encoding, signal });
334
42
 
43
+ case 'html':
44
+ return promises.readFile(file, { encoding, signal }).then(html => {
45
+ const match = IMPORTMAP_EXP.exec(html);
46
+ return JSON.parse(match?.groups?.content ?? '{}');
47
+ });
48
+
335
49
  }
336
50
  }
337
51
 
338
52
  async function init() {
339
- const { version: VERSION } = await json_js.readJSONFile(new URL('./package.json', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href))));
340
-
341
53
  commander.program
342
- .name('importmap-utils')
343
- .version(VERSION)
54
+ .name(Object.keys(pkg.bin)[0])
55
+ .version(pkg.version)
344
56
  .description('CLI utility for updating importmap files')
345
57
  .option('-i, --input [input]', 'local JSON or YAML importmap file')
346
58
  .option('-e, --encoding [encoding]', 'encoding', 'utf8')
@@ -356,10 +68,10 @@ async function init() {
356
68
 
357
69
  init().then(async ({ opts: { input, encoding, format, output }}) => {
358
70
  const mod = typeof input === 'string'
359
- ? await parse(input, { encoding }).then(({ imports, scope = {}, ...rest }) => ({
71
+ ? await parse(input, { encoding }).then(({ imports, scopes = {}, ...rest }) => ({
360
72
  ...rest,
361
73
  imports: { ...imports, ...importmap.imports },
362
- scope: { ...scope, ...importmap.scope },
74
+ scopes: { ...scopes, ...importmap.scopes },
363
75
  }))
364
76
  : importmap;
365
77
 
@@ -371,9 +83,5 @@ init().then(async ({ opts: { input, encoding, format, output }}) => {
371
83
  case 'yaml':
372
84
  await yaml_js.writeYAMLFile(output, mod, { encoding });
373
85
  break;
374
-
375
- // case 'html':
376
- // await updateImportMap(output, { spaces: null });
377
- // break;
378
86
  }
379
87
  });