@entelligentsia/forgecli 0.7.10 → 0.8.4

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.
Files changed (227) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/dist/CHANGELOG-forge-plugin.md +70 -0
  3. package/dist/CHANGELOG-pi.md +63 -0
  4. package/dist/bin/argv.d.ts +2 -2
  5. package/dist/bin/argv.js +10 -0
  6. package/dist/bin/argv.js.map +1 -1
  7. package/dist/bin/env-defaults.d.ts +1 -0
  8. package/dist/bin/env-defaults.js +13 -0
  9. package/dist/bin/env-defaults.js.map +1 -0
  10. package/dist/bin/forge.js +9 -0
  11. package/dist/bin/forge.js.map +1 -1
  12. package/dist/bin/update-cli.d.ts +9 -0
  13. package/dist/bin/update-cli.js +120 -0
  14. package/dist/bin/update-cli.js.map +1 -0
  15. package/dist/extensions/forgecli/index.js +3 -3
  16. package/dist/extensions/forgecli/index.js.map +1 -1
  17. package/dist/extensions/forgecli/update-check.js +1 -1
  18. package/dist/extensions/forgecli/update-check.js.map +1 -1
  19. package/dist/extensions/forgecli/whats-new-widget.d.ts +5 -5
  20. package/dist/extensions/forgecli/whats-new-widget.js +11 -11
  21. package/dist/extensions/forgecli/whats-new-widget.js.map +1 -1
  22. package/dist/extensions/forgecli/whats-new.js +6 -5
  23. package/dist/extensions/forgecli/whats-new.js.map +1 -1
  24. package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
  25. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +27 -98
  26. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
  27. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +62 -132
  28. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js.map +1 -1
  29. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
  30. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +25 -15
  31. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
  32. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
  33. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +1 -0
  34. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js.map +1 -1
  35. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
  36. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +17 -1
  37. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js.map +1 -1
  38. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
  39. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js +8 -2
  40. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js.map +1 -1
  41. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
  42. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js +17 -1
  43. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js.map +1 -1
  44. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
  45. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js +8 -1
  46. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js.map +1 -1
  47. package/node_modules/@earendil-works/pi-ai/package.json +2 -2
  48. package/node_modules/@earendil-works/pi-coding-agent/CHANGELOG.md +63 -0
  49. package/node_modules/@earendil-works/pi-coding-agent/README.md +1 -1
  50. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/config-selector.d.ts.map +1 -1
  51. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/config-selector.js +1 -1
  52. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/config-selector.js.map +1 -1
  53. package/node_modules/@earendil-works/pi-coding-agent/dist/cli.d.ts.map +1 -1
  54. package/node_modules/@earendil-works/pi-coding-agent/dist/cli.js +6 -10
  55. package/node_modules/@earendil-works/pi-coding-agent/dist/cli.js.map +1 -1
  56. package/node_modules/@earendil-works/pi-coding-agent/dist/config.d.ts.map +1 -1
  57. package/node_modules/@earendil-works/pi-coding-agent/dist/config.js +12 -3
  58. package/node_modules/@earendil-works/pi-coding-agent/dist/config.js.map +1 -1
  59. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts +1 -0
  60. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  61. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js +30 -15
  62. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  63. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.d.ts +3 -3
  64. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
  65. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js +23 -13
  66. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
  67. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.d.ts +4 -0
  68. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
  69. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js +58 -38
  70. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js.map +1 -1
  71. package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.d.ts.map +1 -1
  72. package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.js +0 -1
  73. package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.js.map +1 -1
  74. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
  75. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js +3 -2
  76. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
  77. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts +2 -2
  78. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  79. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.js +7 -4
  80. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.js.map +1 -1
  81. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  82. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js +6 -2
  83. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  84. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.d.ts.map +1 -1
  85. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js +3 -4
  86. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js.map +1 -1
  87. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/changelog.d.ts.map +1 -1
  88. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/changelog.js +2 -2
  89. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/changelog.js.map +1 -1
  90. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.d.ts +7 -1
  91. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.d.ts.map +1 -1
  92. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.js +60 -7
  93. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.js.map +1 -1
  94. package/node_modules/@earendil-works/pi-coding-agent/docs/packages.md +2 -2
  95. package/node_modules/@earendil-works/pi-coding-agent/docs/settings.md +1 -3
  96. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package.json +1 -1
  97. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  98. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package.json +1 -1
  99. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package.json +1 -1
  100. package/node_modules/@earendil-works/pi-coding-agent/package.json +6 -6
  101. package/node_modules/@earendil-works/pi-tui/package.json +2 -2
  102. package/node_modules/@protobufjs/fetch/CHANGELOG.md +8 -0
  103. package/node_modules/@protobufjs/fetch/index.d.ts +7 -7
  104. package/node_modules/@protobufjs/fetch/index.js +4 -7
  105. package/node_modules/@protobufjs/fetch/package.json +7 -5
  106. package/node_modules/@protobufjs/fetch/tests/data/file.txt +1 -0
  107. package/node_modules/@protobufjs/fetch/tests/index.js +150 -8
  108. package/node_modules/@protobufjs/fetch/util/fs.js +11 -0
  109. package/node_modules/@protobufjs/inquire/CHANGELOG.md +8 -0
  110. package/node_modules/@protobufjs/inquire/index.d.ts +1 -0
  111. package/node_modules/@protobufjs/inquire/index.js +1 -0
  112. package/node_modules/@protobufjs/inquire/package.json +1 -1
  113. package/node_modules/protobufjs/dist/light/protobuf.js +187 -153
  114. package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  115. package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
  116. package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  117. package/node_modules/protobufjs/dist/minimal/protobuf.js +14 -5
  118. package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
  119. package/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
  120. package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
  121. package/node_modules/protobufjs/dist/protobuf.js +207 -173
  122. package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  123. package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  124. package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  125. package/node_modules/protobufjs/package.json +6 -3
  126. package/node_modules/protobufjs/src/util/fs.js +11 -0
  127. package/node_modules/protobufjs/src/util/minimal.js +10 -2
  128. package/node_modules/protobufjs/src/util.js +1 -1
  129. package/node_modules/undici/README.md +14 -5
  130. package/node_modules/undici/docs/docs/api/Client.md +4 -2
  131. package/node_modules/undici/docs/docs/api/Dispatcher.md +62 -27
  132. package/node_modules/undici/docs/docs/api/GlobalInstallation.md +7 -5
  133. package/node_modules/undici/docs/docs/api/H2CClient.md +1 -1
  134. package/node_modules/undici/docs/docs/api/RedirectHandler.md +14 -9
  135. package/node_modules/undici/docs/docs/api/RetryAgent.md +0 -1
  136. package/node_modules/undici/docs/docs/api/RetryHandler.md +12 -14
  137. package/node_modules/undici/docs/docs/api/SnapshotAgent.md +23 -0
  138. package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +231 -0
  139. package/node_modules/undici/index.js +4 -2
  140. package/node_modules/undici/lib/api/api-connect.js +13 -11
  141. package/node_modules/undici/lib/api/api-pipeline.js +26 -13
  142. package/node_modules/undici/lib/api/api-request.js +45 -21
  143. package/node_modules/undici/lib/api/api-stream.js +81 -20
  144. package/node_modules/undici/lib/api/api-upgrade.js +21 -11
  145. package/node_modules/undici/lib/api/readable.js +3 -2
  146. package/node_modules/undici/lib/cache/memory-cache-store.js +1 -1
  147. package/node_modules/undici/lib/cache/sqlite-cache-store.js +6 -4
  148. package/node_modules/undici/lib/core/connect.js +17 -1
  149. package/node_modules/undici/lib/core/constants.js +1 -24
  150. package/node_modules/undici/lib/core/errors.js +2 -2
  151. package/node_modules/undici/lib/core/request.js +115 -18
  152. package/node_modules/undici/lib/core/socks5-client.js +24 -9
  153. package/node_modules/undici/lib/core/socks5-utils.js +32 -23
  154. package/node_modules/undici/lib/core/symbols.js +1 -0
  155. package/node_modules/undici/lib/core/util.js +70 -43
  156. package/node_modules/undici/lib/dispatcher/agent.js +47 -33
  157. package/node_modules/undici/lib/dispatcher/balanced-pool.js +21 -26
  158. package/node_modules/undici/lib/dispatcher/client-h1.js +98 -39
  159. package/node_modules/undici/lib/dispatcher/client-h2.js +603 -272
  160. package/node_modules/undici/lib/dispatcher/client.js +12 -5
  161. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +24 -5
  162. package/node_modules/undici/lib/dispatcher/dispatcher.js +0 -4
  163. package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +107 -0
  164. package/node_modules/undici/lib/dispatcher/h2c-client.js +5 -5
  165. package/node_modules/undici/lib/dispatcher/pool-base.js +28 -10
  166. package/node_modules/undici/lib/dispatcher/pool.js +31 -6
  167. package/node_modules/undici/lib/dispatcher/proxy-agent.js +38 -13
  168. package/node_modules/undici/lib/dispatcher/round-robin-pool.js +31 -9
  169. package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +95 -80
  170. package/node_modules/undici/lib/global.js +13 -1
  171. package/node_modules/undici/lib/handler/cache-handler.js +16 -8
  172. package/node_modules/undici/lib/handler/decorator-handler.js +1 -2
  173. package/node_modules/undici/lib/handler/redirect-handler.js +5 -51
  174. package/node_modules/undici/lib/handler/retry-handler.js +15 -2
  175. package/node_modules/undici/lib/interceptor/cache.js +30 -17
  176. package/node_modules/undici/lib/interceptor/decompress.js +28 -2
  177. package/node_modules/undici/lib/interceptor/dns.js +1 -1
  178. package/node_modules/undici/lib/interceptor/redirect.js +3 -3
  179. package/node_modules/undici/lib/llhttp/llhttp-wasm.js +1 -1
  180. package/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +1 -1
  181. package/node_modules/undici/lib/mock/mock-agent.js +8 -8
  182. package/node_modules/undici/lib/mock/mock-call-history.js +15 -15
  183. package/node_modules/undici/lib/mock/mock-utils.js +37 -22
  184. package/node_modules/undici/lib/mock/snapshot-agent.js +16 -6
  185. package/node_modules/undici/lib/mock/snapshot-recorder.js +38 -3
  186. package/node_modules/undici/lib/util/cache.js +8 -7
  187. package/node_modules/undici/lib/util/runtime-features.js +3 -34
  188. package/node_modules/undici/lib/web/cache/cache.js +6 -8
  189. package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +245 -150
  190. package/node_modules/undici/lib/web/fetch/body.js +3 -9
  191. package/node_modules/undici/lib/web/fetch/formdata-parser.js +17 -6
  192. package/node_modules/undici/lib/web/fetch/formdata.js +21 -2
  193. package/node_modules/undici/lib/web/fetch/index.js +214 -221
  194. package/node_modules/undici/lib/web/webidl/index.js +7 -9
  195. package/node_modules/undici/lib/web/websocket/frame.js +1 -7
  196. package/node_modules/undici/lib/web/websocket/permessage-deflate.js +13 -31
  197. package/node_modules/undici/lib/web/websocket/receiver.js +62 -22
  198. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +11 -17
  199. package/node_modules/undici/lib/web/websocket/websocket.js +6 -1
  200. package/node_modules/undici/package.json +9 -9
  201. package/node_modules/undici/types/agent.d.ts +0 -2
  202. package/node_modules/undici/types/client.d.ts +25 -19
  203. package/node_modules/undici/types/dispatcher.d.ts +7 -27
  204. package/node_modules/undici/types/dispatcher1-wrapper.d.ts +7 -0
  205. package/node_modules/undici/types/formdata.d.ts +0 -6
  206. package/node_modules/undici/types/h2c-client.d.ts +6 -6
  207. package/node_modules/undici/types/header.d.ts +5 -0
  208. package/node_modules/undici/types/index.d.ts +3 -1
  209. package/node_modules/undici/types/interceptors.d.ts +1 -1
  210. package/node_modules/undici/types/pool.d.ts +0 -2
  211. package/node_modules/undici/types/proxy-agent.d.ts +2 -2
  212. package/node_modules/undici/types/round-robin-pool.d.ts +0 -2
  213. package/node_modules/undici/types/snapshot-agent.d.ts +4 -0
  214. package/node_modules/undici/types/socks5-proxy-agent.d.ts +2 -2
  215. package/node_modules/undici/types/webidl.d.ts +0 -1
  216. package/package.json +7 -8
  217. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package-lock.json +0 -24
  218. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package-lock.json +0 -92
  219. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package-lock.json +0 -31
  220. package/node_modules/undici/lib/handler/unwrap-handler.js +0 -100
  221. package/node_modules/undici/lib/handler/wrap-handler.js +0 -105
  222. package/node_modules/undici/lib/llhttp/.gitkeep +0 -0
  223. package/node_modules/undici/lib/util/promise.js +0 -28
  224. package/skills/refresh-kb-links/SKILL.md +0 -217
  225. package/skills/store-custodian/SKILL.md +0 -163
  226. package/skills/store-query-grammar/SKILL.md +0 -145
  227. package/skills/store-query-nlp/SKILL.md +0 -110
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-tui",
3
- "version": "0.74.2",
3
+ "version": "0.75.1",
4
4
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -32,7 +32,7 @@
32
32
  "directory": "packages/tui"
33
33
  },
34
34
  "engines": {
35
- "node": ">=20.0.0"
35
+ "node": ">=22.19.0"
36
36
  },
37
37
  "types": "./dist/index.d.ts",
38
38
  "dependencies": {
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## [1.1.1](https://github.com/protobufjs/protobuf.js/compare/fetch-v1.1.0...fetch-v1.1.1) (2026-05-17)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * Backport bundler-safe optional module lookups ([#2254](https://github.com/protobufjs/protobuf.js/issues/2254)) ([0853a62](https://github.com/protobufjs/protobuf.js/commit/0853a625680f9247596b84ef48082b8f4e554797))
@@ -12,26 +12,26 @@ type FetchCallback = (error: Error, contents?: string) => void;
12
12
 
13
13
  /**
14
14
  * Options as used by {@link util.fetch}.
15
- * @typedef FetchOptions
15
+ * @typedef IFetchOptions
16
16
  * @type {Object}
17
17
  * @property {boolean} [binary=false] Whether expecting a binary response
18
18
  * @property {boolean} [xhr=false] If `true`, forces the use of XMLHttpRequest
19
19
  */
20
20
 
21
- interface FetchOptions {
21
+ interface IFetchOptions {
22
22
  binary?: boolean;
23
- xhr?: boolean
23
+ xhr?: boolean;
24
24
  }
25
25
 
26
26
  /**
27
27
  * Fetches the contents of a file.
28
28
  * @memberof util
29
29
  * @param {string} filename File path or url
30
- * @param {FetchOptions} options Fetch options
30
+ * @param {IFetchOptions} options Fetch options
31
31
  * @param {FetchCallback} callback Callback function
32
32
  * @returns {undefined}
33
33
  */
34
- declare function fetch(filename: string, options: FetchOptions, callback: FetchCallback): void;
34
+ declare function fetch(filename: string, options: IFetchOptions, callback: FetchCallback): void;
35
35
 
36
36
  /**
37
37
  * Fetches the contents of a file.
@@ -49,8 +49,8 @@ declare function fetch(path: string, callback: FetchCallback): void;
49
49
  * @name util.fetch
50
50
  * @function
51
51
  * @param {string} path File path or url
52
- * @param {FetchOptions} [options] Fetch options
52
+ * @param {IFetchOptions} [options] Fetch options
53
53
  * @returns {Promise<string|Uint8Array>} Promise
54
54
  * @variation 3
55
55
  */
56
- declare function fetch(path: string, options?: FetchOptions): Promise<(string|Uint8Array)>;
56
+ declare function fetch(path: string, options?: IFetchOptions): Promise<(string|Uint8Array)>;
@@ -2,9 +2,7 @@
2
2
  module.exports = fetch;
3
3
 
4
4
  var asPromise = require("@protobufjs/aspromise"),
5
- inquire = require("@protobufjs/inquire");
6
-
7
- var fs = inquire("fs");
5
+ fs = require("./util/fs");
8
6
 
9
7
  /**
10
8
  * Node-style callback as used by {@link util.fetch}.
@@ -17,8 +15,7 @@ var fs = inquire("fs");
17
15
 
18
16
  /**
19
17
  * Options as used by {@link util.fetch}.
20
- * @typedef FetchOptions
21
- * @type {Object}
18
+ * @interface IFetchOptions
22
19
  * @property {boolean} [binary=false] Whether expecting a binary response
23
20
  * @property {boolean} [xhr=false] If `true`, forces the use of XMLHttpRequest
24
21
  */
@@ -27,7 +24,7 @@ var fs = inquire("fs");
27
24
  * Fetches the contents of a file.
28
25
  * @memberof util
29
26
  * @param {string} filename File path or url
30
- * @param {FetchOptions} options Fetch options
27
+ * @param {IFetchOptions} options Fetch options
31
28
  * @param {FetchCallback} callback Callback function
32
29
  * @returns {undefined}
33
30
  */
@@ -70,7 +67,7 @@ function fetch(filename, options, callback) {
70
67
  * @name util.fetch
71
68
  * @function
72
69
  * @param {string} path File path or url
73
- * @param {FetchOptions} [options] Fetch options
70
+ * @param {IFetchOptions} [options] Fetch options
74
71
  * @returns {Promise<string|Uint8Array>} Promise
75
72
  * @variation 3
76
73
  */
@@ -1,25 +1,27 @@
1
1
  {
2
2
  "name": "@protobufjs/fetch",
3
3
  "description": "Fetches the contents of a file accross node and browsers.",
4
- "version": "1.1.0",
4
+ "version": "1.1.1",
5
5
  "author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/dcodeIO/protobuf.js.git"
9
9
  },
10
10
  "dependencies": {
11
- "@protobufjs/aspromise": "^1.1.1",
12
- "@protobufjs/inquire": "^1.1.0"
11
+ "@protobufjs/aspromise": "^1.1.1"
13
12
  },
14
13
  "license": "BSD-3-Clause",
15
14
  "main": "index.js",
16
15
  "types": "index.d.ts",
16
+ "browser": {
17
+ "fs": false
18
+ },
17
19
  "devDependencies": {
18
20
  "istanbul": "^0.4.5",
19
- "tape": "^4.6.3"
21
+ "tape": "^5.0.0"
20
22
  },
21
23
  "scripts": {
22
24
  "test": "tape tests/*.js",
23
25
  "coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js"
24
26
  }
25
- }
27
+ }
@@ -4,13 +4,155 @@ var fetch = require("..");
4
4
 
5
5
  tape.test("fetch", function(test) {
6
6
 
7
- if (typeof Promise !== "undefined") {
8
- var promise = fetch("NOTFOUND");
9
- promise.catch(function() {});
10
- test.ok(promise instanceof Promise, "should return a promise if callback has been omitted");
11
- }
7
+ if (typeof Promise !== "undefined")
8
+ test.test(test.name + " - promise", function(test) {
9
+ var promise = fetch("NOTFOUND");
10
+ test.plan(2);
11
+ test.ok(promise instanceof Promise, "should return a promise if callback has been omitted");
12
+ promise
13
+ .then(function() {
14
+ test.fail("should not resolve");
15
+ })
16
+ .catch(function(err) {
17
+ test.ok(err, "should reject with an error");
18
+ });
19
+ });
20
+
21
+ test.test(test.name + " - node fs", function(test) {
22
+
23
+ test.test(test.name + " - string", function(test) {
24
+ test.plan(2);
25
+ fetch(require.resolve("./data/file.txt"), function(err, contents) {
26
+ test.notOk(err, "should not return an error");
27
+ test.equal(contents, "file.txt", "should return contents as a string");
28
+ });
29
+ });
30
+
31
+ test.test(test.name + " - binary", function(test) {
32
+ test.plan(2);
33
+ fetch(require.resolve("./data/file.txt"), { binary: true }, function(err, contents) {
34
+ test.notOk(err, "should not return an error");
35
+ test.same(contents, new Buffer("file.txt", "utf8"), "should return contents as a Buffer");
36
+ });
37
+ });
38
+
39
+ test.test(test.name + " - fallback", function(test) {
40
+ test.plan(2);
41
+ global.XMLHttpRequest = fakeXHR(0);
42
+ fetch("file.txt", function(err, contents) {
43
+ delete global.XMLHttpRequest;
44
+ test.notOk(err, "should not return an error");
45
+ test.same(contents, "file.txt", "should return contents as a string");
46
+ });
47
+ });
48
+
49
+ test.end();
50
+ });
51
+
52
+ test.test(test.name + " - XMLHttpRequest", function(test) {
53
+
54
+ test.test(test.name + " - 404", function(test) {
55
+ global.XMLHttpRequest = fakeXHR(404);
56
+ fetch("file.txt", { xhr: true }, function(err) {
57
+ delete global.XMLHttpRequest;
58
+ test.ok(err, "should return an error");
59
+ test.end();
60
+ });
61
+ });
62
+
63
+ test.test(test.name + " - string", function(test) {
64
+ global.XMLHttpRequest = fakeXHR(0);
65
+ test.plan(2);
66
+ fetch("file.txt", { xhr: true }, function(err, contents) {
67
+ delete global.XMLHttpRequest;
68
+ test.notOk(err, "should not return an error");
69
+ test.equal(contents, "file.txt", "should return contents as a string");
70
+ });
71
+ });
72
+
73
+ test.test(test.name + " - binary", function(test) {
74
+ global.XMLHttpRequest = fakeXHR(200);
75
+ test.plan(2);
76
+ fetch("file.txt", { xhr: true, binary: true }, function(err, contents) {
77
+ delete global.XMLHttpRequest;
78
+ test.notOk(err, "should not return an error");
79
+ test.same(contents, new Uint8Array([0x66, 0x69, 0x6c, 0x65, 0x2e, 0x74, 0x78, 0x74]), "should return contents as an Uint8Array");
80
+ });
81
+ });
82
+
83
+ });
84
+
85
+ test.test(test.name + " - XMLHttpRequest (ancient)", function(test) {
86
+
87
+ test.test(test.name + " - string", function(test) {
88
+ global.XMLHttpRequest = fakeXHR(0, true);
89
+ test.plan(2);
90
+ fetch("file.txt", { xhr: true }, function(err, contents) {
91
+ delete global.XMLHttpRequest;
92
+ test.notOk(err, "should not return an error");
93
+ test.equal(contents, "file.txt", "should return contents as a string");
94
+ });
95
+ });
96
+
97
+ test.test(test.name + " - binary", function(test) {
98
+ global.XMLHttpRequest = fakeXHR(200, true);
99
+ var U8 = global.Uint8Array;
100
+ delete global.Uint8Array;
101
+ test.plan(2);
102
+ fetch("file.txt", { xhr: true, binary: true }, function(err, contents) {
103
+ delete global.XMLHttpRequest;
104
+ global.Uint8Array = U8;
105
+ test.notOk(err, "should not return an error");
106
+ test.same(contents, [0x66, 0x69, 0x6c, 0x65, 0x2e, 0x74, 0x78, 0x74], "should return contents as an Array");
107
+ });
108
+ });
109
+
110
+ });
12
111
 
13
- // TODO - some way to test this properly?
14
-
15
- test.end();
16
112
  });
113
+
114
+ function fakeXHR(status, ancient) {
115
+
116
+ var UNSENT = 0,
117
+ OPENED = 1,
118
+ HEADERS_RECEIVED = 2,
119
+ LOADING = 3,
120
+ DONE = 4;
121
+
122
+ function XMLHttpRequest() {
123
+ this.status = 0;
124
+ this.readyState = UNSENT;
125
+ }
126
+ if (!ancient)
127
+ XMLHttpRequest.prototype.overrideMimeType = function(mimeType) {
128
+ this._mimeType = mimeType;
129
+ };
130
+ XMLHttpRequest.prototype.open = function open(method, path) {
131
+ this._method = method;
132
+ this._path = path;
133
+ this.readyState = OPENED;
134
+ };
135
+ XMLHttpRequest.prototype.send = function send() {
136
+ var self = this;
137
+ setTimeout(function() {
138
+ self.onreadystatechange(); // opened
139
+ self.readyState = HEADERS_RECEIVED;
140
+ self.onreadystatechange();
141
+ self.readyState = LOADING;
142
+ self.onreadystatechange();
143
+ self.readyState = DONE;
144
+ self.status = status;
145
+ if (self.responseType === "arraybuffer" && !ancient) {
146
+ var buf = new Buffer(self._path, "utf8");
147
+ var abuf = new ArrayBuffer(buf.length);
148
+ var view = new Uint8Array(abuf);
149
+ for (var i = 0; i < buf.length; ++i)
150
+ view[i] = buf[i];
151
+ self.response = abuf;
152
+ } else
153
+ self.responseText = self._path;
154
+ self.onreadystatechange();
155
+ });
156
+ };
157
+ return XMLHttpRequest;
158
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ var fs = null;
4
+ try {
5
+ fs = require(/* webpackIgnore: true */ "fs");
6
+ if (!fs || !fs.readFile || !fs.readFileSync)
7
+ fs = null;
8
+ } catch (e) {
9
+ // `fs` is unavailable in browsers and browser-like bundles.
10
+ }
11
+ module.exports = fs;
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## [1.1.2](https://github.com/protobufjs/protobuf.js/compare/inquire-v1.1.1...inquire-v1.1.2) (2026-05-17)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * Backport bundler-safe optional module lookups ([#2254](https://github.com/protobufjs/protobuf.js/issues/2254)) ([0853a62](https://github.com/protobufjs/protobuf.js/commit/0853a625680f9247596b84ef48082b8f4e554797))
@@ -5,5 +5,6 @@ export = inquire;
5
5
  * @memberof util
6
6
  * @param {string} moduleName Module to require
7
7
  * @returns {?Object} Required module if available and not empty, otherwise `null`
8
+ * @deprecated Legacy optional require helper. Will be removed in a future release.
8
9
  */
9
10
  declare function inquire(moduleName: string): object;
@@ -6,6 +6,7 @@ module.exports = inquire;
6
6
  * @memberof util
7
7
  * @param {string} moduleName Module to require
8
8
  * @returns {?Object} Required module if available and not empty, otherwise `null`
9
+ * @deprecated Legacy optional require helper. Will be removed in a future release.
9
10
  */
10
11
  function inquire(moduleName) {
11
12
  try {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@protobufjs/inquire",
3
3
  "description": "Requires a module only if available and hides the require call from bundlers.",
4
- "version": "1.1.1",
4
+ "version": "1.1.2",
5
5
  "author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
6
6
  "repository": {
7
7
  "type": "git",