@shgysk8zer0/importmap 1.8.0 → 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,20 @@ 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
+
10
24
  ## [v1.8.0] - 2026-03-03
11
25
 
12
26
  ### Added
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,309 +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.7/attempt.js",
71
- "@aegisjsproject/attempt/": "https://unpkg.com/@aegisjsproject/attempt@1.0.7/",
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
- "normalize.css": "https://unpkg.com/normalize.css@8.0.1/normalize.css"
123
- };
124
- const scopes$1 = {
125
- };
126
- var json = {
127
- imports: imports$1,
128
- scopes: scopes$1
129
- };
130
-
131
- const SHA256 = 'SHA-256';
132
- const SHA384 = 'SHA-384';
133
- const SHA512 = 'SHA-512';
134
- const DEFAULT_ALGO = SHA384;
135
-
136
- const BASE64 = 'base64';
137
-
138
- const { imports, scopes } = json;
139
-
140
- class Importmap {
141
- #imports = {};
142
- #scopes = {};
143
- #base;
144
-
145
- constructor({ imports: i = imports, scopes: s = scopes } = {}) {
146
- this.#imports = i;
147
- this.#scopes = s;
148
- }
149
-
150
- get imports() {
151
- return structuredClone(this.#imports);
152
- }
153
-
154
- get scopes() {
155
- return structuredClone(this.#scopes);
156
- }
157
-
158
- delete(key) {
159
- return Reflect.deleteProperty(this.#imports, key);
160
- }
161
-
162
- get(key) {
163
- return Reflect.get(this.#imports, key);
164
- }
165
-
166
- has(key) {
167
- return Reflect.has(this.#imports, key);
168
- }
169
-
170
- set(key, newValue) {
171
- return Reflect.set(this.#imports, key, newValue);
172
- }
173
-
174
- toJSON() {
175
- return { imports: this.#imports, scopes: this.#scopes };
176
- }
177
-
178
- toString() {
179
- return JSON.stringify(this);
180
- }
181
-
182
- get baseUrl() {
183
- return this.#base;
184
- }
185
-
186
- set baseUrl(val) {
187
- if (typeof val === 'string' && URL.canParse(val)) {
188
- this.#base = val;
189
- }
190
- }
191
-
192
- resolve(specifier, base = this.baseUrl) {
193
- if (specifier instanceof URL) {
194
- return specifier.href;
195
- } else if (typeof specifier !== 'string') {
196
- return null;
197
- } else if (this.has(specifier)) {
198
- return URL.parse(this.get(specifier), this.baseUrl)?.href ?? null;
199
- } else if (URL.canParse(specifier)) {
200
- return specifier;
201
- } else if (! specifier.startsWith('.')) {
202
- // Find the longest match
203
- const matches = Object.keys(this.imports)
204
- .filter(key => key.endsWith('/') && specifier.startsWith(key))
205
- .sort((a, b) => b.length - a.length);
206
8
 
207
- if (matches.length === 0) {
208
- return null;
209
- } else {
210
- const match = matches[0];
211
- const target = imports[match];
212
- const subpath = specifier.slice(match.length);
213
- // Resolve the mapping target against the map's base, then the subpath against that
214
- const resolvedTarget = new URL(target, this.baseUrl);
215
- return new URL(subpath, resolvedTarget).href;
216
- }
217
- } else if (typeof base === 'string') {
218
- return URL.parse(specifier, base)?.href ?? null;
219
- } else {
220
- return null;
221
- }
222
- }
223
-
224
- async importLocalPackage(name = 'package.json', { signal } = {}) {
225
- const path = node_path.join(process.cwd(), name);
226
- const pkg = await promises.readFile(path, { encoding: 'utf8', signal });
227
-
228
- return this.setLocalPackage(JSON.parse(pkg));
229
- }
230
-
231
- setLocalPackage({ name, module, exports = {} }) {
232
- if (typeof name !== 'string') {
233
- return false;
234
- } else if (typeof exports === 'string' ) {
235
- this.set(name, exports);
236
- return true;
237
- } else if (typeof exports === 'object') {
238
- Object.entries(exports).forEach(([key, value]) => {
239
- if (key.startsWith('.')) {
240
- const importKey = key === '.' ? name : `${name}${key.substring(1)}`;
241
- const resolved = typeof value === 'string' ? value : value.import ?? value.default;
242
-
243
- if (typeof resolved === 'string' && resolved.startsWith('./')) {
244
- if (importKey.includes('*') && resolved.includes('*')) {
245
- const [prefix, suffix] = importKey.split('*');
246
-
247
- if (resolved.endsWith('*' + suffix)) {
248
- this.set(prefix, resolved.substring(1).replace('*' + suffix, ''));
249
- }
250
- } else {
251
- this.set(importKey, resolved.substring(1));
252
- }
253
- }
254
- }
255
- });
256
-
257
- return true;
258
- } else if (typeof module === 'string') {
259
- this.set(name, module);
260
- return true;
261
- } else {
262
- this.set(name, '/');
263
- return true;
264
- }
265
- }
266
-
267
- async getScript({ algo = DEFAULT_ALGO, alphabet = BASE64, signal } = {}) {
268
- const integrity = await this.getIntegrity({ algo, alphabet, signal });
269
-
270
- return `<script type="importmap" integrity="${integrity}">${JSON.stringify(this)}</script>`;
271
- }
272
-
273
- async getIntegrity({ algo = DEFAULT_ALGO, alphabet = BASE64, signal } = {}) {
274
- if (signal instanceof AbortSignal && signal.aborted) {
275
- throw signal.reason;
276
- } else {
277
- const prefix = algo.toLowerCase().replace('-', '') + '-';
278
- const encoded = new TextEncoder().encode(this);
279
- const hash = await crypto.subtle.digest(algo, encoded);
280
-
281
- return prefix + new Uint8Array(hash).toBase64({ alphabet });
282
- }
283
- }
284
-
285
- static get SHA256() {
286
- return SHA256;
287
- }
288
-
289
- static get SHA384() {
290
- return SHA384;
291
- }
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;
292
11
 
293
- static get SHA512() {
294
- return SHA512;
295
- }
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');
296
13
 
297
- static async importFromFile(path = 'importmap.json', { signal } = {}) {
298
- const fullPath = node_path.join(process.cwd(), path);
299
- const importmap = await promises.readFile(fullPath, { encoding: 'utf8', signal });
300
-
301
- return new Importmap(JSON.parse(importmap));
302
- }
303
- }
304
-
305
- const importmap = new Importmap({ imports, scopes });
306
-
307
- // 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}');
308
15
 
309
16
  function guessFileType(file) {
310
17
  const ext = node_path.extname(file).toLowerCase();
@@ -333,15 +40,19 @@ async function parse(file, { encoding, signal } = {}) {
333
40
  case 'json':
334
41
  return json_js.readJSONFile(file, { encoding, signal });
335
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
+
336
49
  }
337
50
  }
338
51
 
339
52
  async function init() {
340
- 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))));
341
-
342
53
  commander.program
343
- .name('importmap-utils')
344
- .version(VERSION)
54
+ .name(Object.keys(pkg.bin)[0])
55
+ .version(pkg.version)
345
56
  .description('CLI utility for updating importmap files')
346
57
  .option('-i, --input [input]', 'local JSON or YAML importmap file')
347
58
  .option('-e, --encoding [encoding]', 'encoding', 'utf8')
@@ -357,10 +68,10 @@ async function init() {
357
68
 
358
69
  init().then(async ({ opts: { input, encoding, format, output }}) => {
359
70
  const mod = typeof input === 'string'
360
- ? await parse(input, { encoding }).then(({ imports, scope = {}, ...rest }) => ({
71
+ ? await parse(input, { encoding }).then(({ imports, scopes = {}, ...rest }) => ({
361
72
  ...rest,
362
73
  imports: { ...imports, ...importmap.imports },
363
- scope: { ...scope, ...importmap.scope },
74
+ scopes: { ...scopes, ...importmap.scopes },
364
75
  }))
365
76
  : importmap;
366
77
 
@@ -372,9 +83,5 @@ init().then(async ({ opts: { input, encoding, format, output }}) => {
372
83
  case 'yaml':
373
84
  await yaml_js.writeYAMLFile(output, mod, { encoding });
374
85
  break;
375
-
376
- // case 'html':
377
- // await updateImportMap(output, { spaces: null });
378
- // break;
379
86
  }
380
87
  });