@eik/node-client 2.0.6 → 2.0.8

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
@@ -1,3 +1,17 @@
1
+ ## [2.0.8](https://github.com/eik-lib/node-client/compare/v2.0.7...v2.0.8) (2025-05-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update eik/common to use the shared fetch ([#231](https://github.com/eik-lib/node-client/issues/231)) ([8ff38e8](https://github.com/eik-lib/node-client/commit/8ff38e844bdc971f5a6bc2b81dd1f062cef92ece))
7
+
8
+ ## [2.0.7](https://github.com/eik-lib/node-client/compare/v2.0.6...v2.0.7) (2025-05-08)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * redirections bug with Node 24 ([#230](https://github.com/eik-lib/node-client/issues/230)) ([9111ad0](https://github.com/eik-lib/node-client/commit/9111ad0c0fbc90dd89368507b6675740cb99cd5f))
14
+
1
15
  ## [2.0.6](https://github.com/eik-lib/node-client/compare/v2.0.5...v2.0.6) (2025-04-28)
2
16
 
3
17
 
package/dist/index.cjs CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var common = require('@eik/common');
4
- var undici = require('undici');
5
4
  var path = require('path');
6
5
 
7
6
  /**
@@ -60,30 +59,6 @@ const trimSlash = (value = "") => {
60
59
  return value;
61
60
  };
62
61
 
63
- const fetchImportMaps = async (urls = []) => {
64
- try {
65
- const maps = urls.map(async (map) => {
66
- const { statusCode, body } = await undici.request(map, {
67
- maxRedirections: 2,
68
- });
69
-
70
- if (statusCode === 404) {
71
- throw new Error("Import map could not be found on server");
72
- } else if (statusCode >= 400 && statusCode < 500) {
73
- throw new Error("Server rejected client request");
74
- } else if (statusCode >= 500) {
75
- throw new Error("Server error");
76
- }
77
- return body.json();
78
- });
79
- return await Promise.all(maps);
80
- } catch (err) {
81
- throw new Error(
82
- `Unable to load import map file from server: ${err.message}`,
83
- );
84
- }
85
- };
86
-
87
62
  /**
88
63
  * @typedef {object} Options
89
64
  * @property {string} [base=null]
@@ -189,9 +164,9 @@ class Eik {
189
164
  * use in {@link maps}.
190
165
  */
191
166
  async load() {
192
- this.#config = await common.helpers.getDefaults(this.#path);
167
+ this.#config = common.helpers.getDefaults(this.#path);
193
168
  if (this.#loadMaps) {
194
- this.#maps = await fetchImportMaps(this.#config.map);
169
+ this.#maps = await common.helpers.fetchImportMaps(this.#config.map);
195
170
  }
196
171
  }
197
172
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eik/node-client",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "Utilities for working with assets and import maps on an Eik server",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -43,16 +43,15 @@
43
43
  },
44
44
  "homepage": "https://github.com/eik-lib/node-client#readme",
45
45
  "dependencies": {
46
- "@eik/common": "5.0.4",
47
- "abslog": "2.4.4",
48
- "undici": "6.21.2"
46
+ "@eik/common": "5.1.0",
47
+ "abslog": "2.4.4"
49
48
  },
50
49
  "devDependencies": {
51
- "@eik/eslint-config": "1.0.12",
50
+ "@eik/eslint-config": "1.0.13",
52
51
  "@eik/prettier-config": "1.0.1",
53
52
  "@eik/semantic-release-config": "1.0.2",
54
53
  "@eik/typescript-config": "1.0.0",
55
- "eslint": "9.16.0",
54
+ "eslint": "9.25.1",
56
55
  "npm-run-all2": "7.0.2",
57
56
  "prettier": "3.4.1",
58
57
  "rimraf": "6.0.1",
package/src/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { helpers } from "@eik/common";
2
- import { request } from "undici";
3
2
  import { join } from "path";
4
3
  import { Asset } from "./asset.js";
5
4
 
@@ -8,30 +7,6 @@ const trimSlash = (value = "") => {
8
7
  return value;
9
8
  };
10
9
 
11
- const fetchImportMaps = async (urls = []) => {
12
- try {
13
- const maps = urls.map(async (map) => {
14
- const { statusCode, body } = await request(map, {
15
- maxRedirections: 2,
16
- });
17
-
18
- if (statusCode === 404) {
19
- throw new Error("Import map could not be found on server");
20
- } else if (statusCode >= 400 && statusCode < 500) {
21
- throw new Error("Server rejected client request");
22
- } else if (statusCode >= 500) {
23
- throw new Error("Server error");
24
- }
25
- return body.json();
26
- });
27
- return await Promise.all(maps);
28
- } catch (err) {
29
- throw new Error(
30
- `Unable to load import map file from server: ${err.message}`,
31
- );
32
- }
33
- };
34
-
35
10
  /**
36
11
  * @typedef {object} Options
37
12
  * @property {string} [base=null]
@@ -137,9 +112,9 @@ export default class Eik {
137
112
  * use in {@link maps}.
138
113
  */
139
114
  async load() {
140
- this.#config = await helpers.getDefaults(this.#path);
115
+ this.#config = helpers.getDefaults(this.#path);
141
116
  if (this.#loadMaps) {
142
- this.#maps = await fetchImportMaps(this.#config.map);
117
+ this.#maps = await helpers.fetchImportMaps(this.#config.map);
143
118
  }
144
119
  }
145
120