@psnext/slingcli 2.4.20260525-4 → 2.4.20260527-2

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 (243) hide show
  1. package/bin/sling.js +4 -1
  2. package/node_modules/@aws-sdk/core/package.json +2 -2
  3. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  4. package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/fromHttp.js +12 -6
  5. package/node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/fromHttp.js +12 -6
  6. package/node_modules/@aws-sdk/credential-provider-http/package.json +3 -2
  7. package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
  8. package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
  9. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  10. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  11. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +3 -3
  12. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  13. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  14. package/node_modules/@aws-sdk/middleware-websocket/package.json +2 -2
  15. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  16. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  17. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  18. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  19. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  20. package/node_modules/@aws-sdk/nested-clients/package.json +3 -3
  21. package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +1 -2
  22. package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
  23. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +18 -24
  24. package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  25. package/node_modules/@earendil-works/pi-ai/dist/cli.js +14 -0
  26. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +78 -63
  27. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +2 -1
  28. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +8 -22
  29. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +1 -1
  30. package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.js +1 -1
  31. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js +60 -40
  32. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js +1 -1
  33. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js +1 -1
  34. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.js +55 -0
  35. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.js +45 -69
  36. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.js +1 -0
  37. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +5 -2
  38. package/node_modules/@earendil-works/pi-ai/package.json +4 -3
  39. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/file-processor.js +2 -3
  40. package/node_modules/@earendil-works/pi-coding-agent/dist/config.js +18 -12
  41. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-runtime.js +2 -1
  42. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-services.js +3 -2
  43. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js +8 -2
  44. package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.js +2 -1
  45. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js +18 -24
  46. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/index.js +8 -6
  47. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/template.js +6 -3
  48. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.js +12 -29
  49. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-registry.js +5 -1
  50. package/node_modules/@earendil-works/pi-coding-agent/dist/core/output-guard.js +52 -22
  51. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js +63 -36
  52. package/node_modules/@earendil-works/pi-coding-agent/dist/core/prompt-templates.js +6 -20
  53. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.js +38 -31
  54. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.js +9 -4
  55. package/node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.js +32 -24
  56. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.js +6 -13
  57. package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.js +8 -22
  58. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.js +54 -53
  59. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit-diff.js +8 -1
  60. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit.js +44 -81
  61. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/file-mutation-queue.js +27 -12
  62. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/find.js +2 -3
  63. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/grep.js +3 -3
  64. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/ls.js +5 -5
  65. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/output-accumulator.js +9 -3
  66. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/path-utils.js +39 -21
  67. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/read.js +9 -8
  68. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/truncate.js +12 -2
  69. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/write.js +20 -35
  70. package/node_modules/@earendil-works/pi-coding-agent/dist/main.js +5 -6
  71. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.js +1 -1
  72. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/footer.js +14 -5
  73. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +29 -4
  74. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/user-message.js +1 -1
  75. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js +4 -4
  76. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js +37 -28
  77. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-client.js +64 -7
  78. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-mode.js +15 -3
  79. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/clipboard-native.js +14 -8
  80. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-core.js +124 -0
  81. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-worker.js +31 -0
  82. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize.js +75 -115
  83. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/paths.js +33 -7
  84. package/node_modules/@earendil-works/pi-coding-agent/npm-shrinkwrap.json +13 -26
  85. package/node_modules/@earendil-works/pi-coding-agent/package.json +6 -6
  86. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +40 -55
  87. package/node_modules/@earendil-works/pi-tui/dist/components/input.js +2 -2
  88. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +12 -2
  89. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js +53 -0
  90. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +4 -1
  91. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +38 -16
  92. package/node_modules/@earendil-works/pi-tui/dist/utils.js +19 -12
  93. package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-arm64/darwin-modifiers.node +0 -0
  94. package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
  95. package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
  96. package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
  97. package/node_modules/@earendil-works/pi-tui/package.json +3 -5
  98. package/node_modules/@smithy/node-http-handler/package.json +2 -2
  99. package/node_modules/undici/lib/api/api-request.js +1 -1
  100. package/node_modules/undici/lib/cache/sqlite-cache-store.js +3 -3
  101. package/node_modules/undici/lib/core/connect.js +16 -0
  102. package/node_modules/undici/lib/core/request.js +17 -2
  103. package/node_modules/undici/lib/core/socks5-client.js +10 -5
  104. package/node_modules/undici/lib/core/socks5-utils.js +17 -22
  105. package/node_modules/undici/lib/dispatcher/client-h1.js +64 -20
  106. package/node_modules/undici/lib/dispatcher/client.js +6 -2
  107. package/node_modules/undici/lib/dispatcher/h2c-client.js +1 -1
  108. package/node_modules/undici/lib/mock/mock-call-history.js +15 -15
  109. package/node_modules/undici/lib/util/cache.js +8 -7
  110. package/node_modules/undici/lib/web/fetch/formdata-parser.js +17 -6
  111. package/node_modules/undici/lib/web/fetch/index.js +5 -2
  112. package/node_modules/undici/lib/web/webidl/index.js +5 -5
  113. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +1 -7
  114. package/node_modules/undici/package.json +1 -1
  115. package/package.json +6 -6
  116. package/slingshot/index.js +269 -266
  117. package/node_modules/koffi/CHANGELOG.md +0 -1093
  118. package/node_modules/koffi/LICENSE.txt +0 -22
  119. package/node_modules/koffi/README.md +0 -43
  120. package/node_modules/koffi/build/koffi/darwin_arm64/koffi.node +0 -0
  121. package/node_modules/koffi/build/koffi/darwin_x64/koffi.node +0 -0
  122. package/node_modules/koffi/build/koffi/freebsd_arm64/koffi.node +0 -0
  123. package/node_modules/koffi/build/koffi/freebsd_ia32/koffi.node +0 -0
  124. package/node_modules/koffi/build/koffi/freebsd_x64/koffi.node +0 -0
  125. package/node_modules/koffi/build/koffi/linux_arm64/koffi.node +0 -0
  126. package/node_modules/koffi/build/koffi/linux_armhf/koffi.node +0 -0
  127. package/node_modules/koffi/build/koffi/linux_ia32/koffi.node +0 -0
  128. package/node_modules/koffi/build/koffi/linux_loong64/koffi.node +0 -0
  129. package/node_modules/koffi/build/koffi/linux_riscv64d/koffi.node +0 -0
  130. package/node_modules/koffi/build/koffi/linux_x64/koffi.node +0 -0
  131. package/node_modules/koffi/build/koffi/musl_arm64/koffi.node +0 -0
  132. package/node_modules/koffi/build/koffi/musl_x64/koffi.node +0 -0
  133. package/node_modules/koffi/build/koffi/openbsd_ia32/koffi.node +0 -0
  134. package/node_modules/koffi/build/koffi/openbsd_x64/koffi.node +0 -0
  135. package/node_modules/koffi/build/koffi/win32_arm64/koffi.exp +0 -0
  136. package/node_modules/koffi/build/koffi/win32_arm64/koffi.lib +0 -0
  137. package/node_modules/koffi/build/koffi/win32_arm64/koffi.node +0 -0
  138. package/node_modules/koffi/build/koffi/win32_ia32/koffi.exp +0 -0
  139. package/node_modules/koffi/build/koffi/win32_ia32/koffi.lib +0 -0
  140. package/node_modules/koffi/build/koffi/win32_ia32/koffi.node +0 -0
  141. package/node_modules/koffi/build/koffi/win32_x64/koffi.exp +0 -0
  142. package/node_modules/koffi/build/koffi/win32_x64/koffi.lib +0 -0
  143. package/node_modules/koffi/build/koffi/win32_x64/koffi.node +0 -0
  144. package/node_modules/koffi/doc/benchmarks.md +0 -126
  145. package/node_modules/koffi/doc/callbacks.md +0 -210
  146. package/node_modules/koffi/doc/contribute.md +0 -148
  147. package/node_modules/koffi/doc/functions.md +0 -250
  148. package/node_modules/koffi/doc/index.md +0 -61
  149. package/node_modules/koffi/doc/input.md +0 -471
  150. package/node_modules/koffi/doc/migration.md +0 -159
  151. package/node_modules/koffi/doc/misc.md +0 -180
  152. package/node_modules/koffi/doc/output.md +0 -305
  153. package/node_modules/koffi/doc/packaging.md +0 -88
  154. package/node_modules/koffi/doc/platforms.md +0 -36
  155. package/node_modules/koffi/doc/pointers.md +0 -328
  156. package/node_modules/koffi/doc/start.md +0 -118
  157. package/node_modules/koffi/doc/unions.md +0 -186
  158. package/node_modules/koffi/doc/variables.md +0 -102
  159. package/node_modules/koffi/index.d.ts +0 -288
  160. package/node_modules/koffi/index.js +0 -634
  161. package/node_modules/koffi/indirect.js +0 -533
  162. package/node_modules/koffi/lib/native/base/base.cc +0 -11015
  163. package/node_modules/koffi/lib/native/base/base.hh +0 -6003
  164. package/node_modules/koffi/lib/native/base/crc.inc +0 -2214
  165. package/node_modules/koffi/lib/native/base/crc_gen.py +0 -72
  166. package/node_modules/koffi/lib/native/base/mimetypes.inc +0 -1248
  167. package/node_modules/koffi/lib/native/base/mimetypes_gen.py +0 -58
  168. package/node_modules/koffi/lib/native/base/tower.cc +0 -821
  169. package/node_modules/koffi/lib/native/base/tower.hh +0 -81
  170. package/node_modules/koffi/lib/native/base/unicode.inc +0 -408
  171. package/node_modules/koffi/lib/native/base/unicode_gen.py +0 -152
  172. package/node_modules/koffi/package.json +0 -38
  173. package/node_modules/koffi/src/cnoke/LICENSE.txt +0 -22
  174. package/node_modules/koffi/src/cnoke/README.md +0 -99
  175. package/node_modules/koffi/src/cnoke/assets/FindCNoke.cmake +0 -127
  176. package/node_modules/koffi/src/cnoke/assets/toolchains.json +0 -126
  177. package/node_modules/koffi/src/cnoke/assets/win_delay_hook.c +0 -36
  178. package/node_modules/koffi/src/cnoke/cnoke.js +0 -170
  179. package/node_modules/koffi/src/cnoke/package.json +0 -24
  180. package/node_modules/koffi/src/cnoke/src/builder.js +0 -511
  181. package/node_modules/koffi/src/cnoke/src/index.js +0 -10
  182. package/node_modules/koffi/src/cnoke/src/tools.js +0 -407
  183. package/node_modules/koffi/src/koffi/CMakeLists.txt +0 -182
  184. package/node_modules/koffi/src/koffi/src/abi_arm32.cc +0 -1018
  185. package/node_modules/koffi/src/koffi/src/abi_arm32_asm.S +0 -169
  186. package/node_modules/koffi/src/koffi/src/abi_arm64.cc +0 -1295
  187. package/node_modules/koffi/src/koffi/src/abi_arm64_asm.S +0 -195
  188. package/node_modules/koffi/src/koffi/src/abi_arm64_asm.asm +0 -174
  189. package/node_modules/koffi/src/koffi/src/abi_loong64.cc +0 -5
  190. package/node_modules/koffi/src/koffi/src/abi_loong64_asm.S +0 -204
  191. package/node_modules/koffi/src/koffi/src/abi_riscv64.cc +0 -915
  192. package/node_modules/koffi/src/koffi/src/abi_riscv64_asm.S +0 -203
  193. package/node_modules/koffi/src/koffi/src/abi_x64_sysv.cc +0 -939
  194. package/node_modules/koffi/src/koffi/src/abi_x64_sysv_asm.S +0 -231
  195. package/node_modules/koffi/src/koffi/src/abi_x64_win.cc +0 -715
  196. package/node_modules/koffi/src/koffi/src/abi_x64_win_asm.S +0 -166
  197. package/node_modules/koffi/src/koffi/src/abi_x64_win_asm.asm +0 -192
  198. package/node_modules/koffi/src/koffi/src/abi_x86.cc +0 -860
  199. package/node_modules/koffi/src/koffi/src/abi_x86_asm.S +0 -193
  200. package/node_modules/koffi/src/koffi/src/abi_x86_asm.asm +0 -177
  201. package/node_modules/koffi/src/koffi/src/call.cc +0 -1326
  202. package/node_modules/koffi/src/koffi/src/call.hh +0 -179
  203. package/node_modules/koffi/src/koffi/src/errno.inc +0 -462
  204. package/node_modules/koffi/src/koffi/src/ffi.cc +0 -2702
  205. package/node_modules/koffi/src/koffi/src/ffi.hh +0 -354
  206. package/node_modules/koffi/src/koffi/src/init.js +0 -105
  207. package/node_modules/koffi/src/koffi/src/parser.cc +0 -220
  208. package/node_modules/koffi/src/koffi/src/parser.hh +0 -54
  209. package/node_modules/koffi/src/koffi/src/util.cc +0 -1807
  210. package/node_modules/koffi/src/koffi/src/util.hh +0 -221
  211. package/node_modules/koffi/src/koffi/src/uv.cc +0 -193
  212. package/node_modules/koffi/src/koffi/src/uv.def +0 -10
  213. package/node_modules/koffi/src/koffi/src/uv.hh +0 -40
  214. package/node_modules/koffi/src/koffi/src/win32.cc +0 -198
  215. package/node_modules/koffi/src/koffi/src/win32.hh +0 -119
  216. package/node_modules/koffi/src/koffi/tools/write_trampolines.js +0 -77
  217. package/node_modules/koffi/vendor/node-addon-api/LICENSE.md +0 -9
  218. package/node_modules/koffi/vendor/node-addon-api/README.md +0 -95
  219. package/node_modules/koffi/vendor/node-addon-api/napi-inl.deprecated.h +0 -186
  220. package/node_modules/koffi/vendor/node-addon-api/napi-inl.h +0 -7033
  221. package/node_modules/koffi/vendor/node-addon-api/napi.h +0 -3309
  222. package/node_modules/koffi/vendor/node-api-headers/LICENSE +0 -21
  223. package/node_modules/koffi/vendor/node-api-headers/README.md +0 -95
  224. package/node_modules/koffi/vendor/node-api-headers/def/js_native_api.def +0 -125
  225. package/node_modules/koffi/vendor/node-api-headers/def/node_api.def +0 -157
  226. package/node_modules/koffi/vendor/node-api-headers/include/js_native_api.h +0 -591
  227. package/node_modules/koffi/vendor/node-api-headers/include/js_native_api_types.h +0 -210
  228. package/node_modules/koffi/vendor/node-api-headers/include/node_api.h +0 -265
  229. package/node_modules/koffi/vendor/node-api-headers/include/node_api_types.h +0 -58
  230. package/node_modules/koffi/vendor/node-api-headers/include/uv/aix.h +0 -32
  231. package/node_modules/koffi/vendor/node-api-headers/include/uv/bsd.h +0 -34
  232. package/node_modules/koffi/vendor/node-api-headers/include/uv/darwin.h +0 -61
  233. package/node_modules/koffi/vendor/node-api-headers/include/uv/errno.h +0 -483
  234. package/node_modules/koffi/vendor/node-api-headers/include/uv/linux.h +0 -34
  235. package/node_modules/koffi/vendor/node-api-headers/include/uv/os390.h +0 -33
  236. package/node_modules/koffi/vendor/node-api-headers/include/uv/posix.h +0 -31
  237. package/node_modules/koffi/vendor/node-api-headers/include/uv/sunos.h +0 -44
  238. package/node_modules/koffi/vendor/node-api-headers/include/uv/threadpool.h +0 -37
  239. package/node_modules/koffi/vendor/node-api-headers/include/uv/tree.h +0 -521
  240. package/node_modules/koffi/vendor/node-api-headers/include/uv/unix.h +0 -512
  241. package/node_modules/koffi/vendor/node-api-headers/include/uv/version.h +0 -43
  242. package/node_modules/koffi/vendor/node-api-headers/include/uv/win.h +0 -698
  243. package/node_modules/koffi/vendor/node-api-headers/include/uv.h +0 -1990
@@ -1,511 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
3
-
4
- 'use strict';
5
-
6
- const fs = require('fs');
7
- const os = require('os');
8
- const path = require('path');
9
- const { spawnSync } = require('child_process');
10
- const tools = require('./tools.js');
11
- const TOOLCHAINS = require('../assets/toolchains.json');
12
-
13
- const DefaultOptions = {
14
- mode: 'RelWithDebInfo'
15
- };
16
-
17
- function Builder(config = {}) {
18
- let self = this;
19
-
20
- let host = `${process.platform}_${tools.determine_arch()}`;
21
-
22
- let app_dir = config.app_dir;
23
- let project_dir = config.project_dir;
24
- let package_dir = config.package_dir;
25
-
26
- if (app_dir == null)
27
- app_dir = __dirname.replace(/\\/g, '/') + '/..';
28
- if (project_dir == null)
29
- project_dir = process.cwd();
30
- app_dir = app_dir.replace(/\\/g, '/');
31
- project_dir = project_dir.replace(/\\/g, '/');
32
- if (package_dir == null)
33
- package_dir = find_parent_directory(project_dir, 'package.json');
34
- if (package_dir != null)
35
- package_dir = package_dir.replace(/\\/g, '/');
36
-
37
- let runtime_version = config.runtime_version;
38
- let toolchain = config.toolchain || null;
39
- let prefer_clang = config.prefer_clang || false;
40
- let mode = config.mode || DefaultOptions.mode;
41
- let targets = config.targets || [];
42
- let verbose = config.verbose || false;
43
- let prebuild = config.prebuild || false;
44
-
45
- if (runtime_version == null)
46
- runtime_version = process.version;
47
- if (runtime_version.startsWith('v'))
48
- runtime_version = runtime_version.substr(1);
49
-
50
- if (toolchain != null && !Object.hasOwn(TOOLCHAINS, toolchain))
51
- throw new Error(`Unknown cross-compilation toolchain '${toolchain}'`);
52
-
53
- let options = null;
54
-
55
- let cache_dir = get_cache_directory();
56
- let build_dir = config.build_dir;
57
- let work_dir = null;
58
- let output_dir = null;
59
-
60
- if (build_dir == null) {
61
- let options = read_cnoke_options();
62
-
63
- if (options.output != null) {
64
- build_dir = expand_path(options.output, options.directory);
65
- } else {
66
- build_dir = project_dir + '/build';
67
- }
68
- }
69
- build_dir = build_dir.replace(/\\/g, '/');
70
- work_dir = build_dir + `/v${runtime_version}_${toolchain ?? 'native'}/${mode}`;
71
- output_dir = work_dir + '/Output';
72
-
73
- let cmake_bin = null;
74
-
75
- this.configure = async function(retry = true) {
76
- let options = read_cnoke_options();
77
-
78
- let args = [project_dir];
79
-
80
- check_cmake();
81
- check_compatibility();
82
-
83
- console.log(`>> Node: ${runtime_version}`);
84
- console.log(`>> Toolchain: ${toolchain ?? 'native'}`);
85
-
86
- // Prepare build directory
87
- fs.mkdirSync(build_dir, { recursive: true, mode: 0o755 });
88
- fs.mkdirSync(work_dir, { recursive: true, mode: 0o755 });
89
- fs.mkdirSync(output_dir, { recursive: true, mode: 0o755 });
90
-
91
- retry &= fs.existsSync(work_dir + '/CMakeCache.txt');
92
-
93
- args.push(`-DNODE_JS_EXECPATH=${process.execPath}`);
94
-
95
- // Download or use Node headers
96
- if (options.api == null) {
97
- let destname = `${cache_dir}/node-v${runtime_version}-headers.tar.gz`;
98
-
99
- if (!fs.existsSync(destname)) {
100
- fs.mkdirSync(cache_dir, { recursive: true, mode: 0o755 });
101
-
102
- let url = `https://nodejs.org/dist/v${runtime_version}/node-v${runtime_version}-headers.tar.gz`;
103
- await tools.download_http(url, destname);
104
- }
105
-
106
- await tools.extract_targz(destname, work_dir + '/headers', 1);
107
-
108
- args.push(`-DNODE_JS_INCLUDE_DIRS=${work_dir}/headers/include/node`);
109
- } else {
110
- console.log(`>> Using local node-api headers`);
111
-
112
- let api_dir = expand_path(options.api, project_dir);
113
- args.push(`-DNODE_JS_INCLUDE_DIRS=${api_dir}/include`);
114
- }
115
-
116
- args.push(`-DCMAKE_MODULE_PATH=${app_dir}/assets`);
117
-
118
- let win32 = (toolchain ?? host).startsWith('win32_');
119
- let mingw = (process.platform == 'win32' && process.env.MSYSTEM != null);
120
-
121
- // Handle Node import library on Windows
122
- if (win32) {
123
- if (mingw) {
124
- args.push(`-DNODE_JS_LINK_LIB=node.dll`);
125
- } else {
126
- let info = TOOLCHAINS[toolchain ?? host];
127
-
128
- if (options.api == null) {
129
- let destname = `${cache_dir}/node_v${runtime_version}_${toolchain ?? host}.lib`;
130
-
131
- if (!fs.existsSync(destname)) {
132
- fs.mkdirSync(cache_dir, { recursive: true, mode: 0o755 });
133
-
134
- let url = `https://nodejs.org/dist/v${runtime_version}/${info.lib}/node.lib`;
135
- await tools.download_http(url, destname);
136
- }
137
-
138
- fs.copyFileSync(destname, work_dir + '/node.lib');
139
- args.push(`-DNODE_JS_LINK_LIB=${work_dir}/node.lib`);
140
- } else {
141
- let api_dir = expand_path(options.api, project_dir);
142
- args.push(`-DNODE_JS_LINK_DEF=${api_dir}/def/node_api.def`);
143
- }
144
- }
145
-
146
- fs.copyFileSync(`${app_dir}/assets/win_delay_hook.c`, work_dir + '/win_delay_hook.c');
147
- args.push(`-DNODE_JS_SOURCES=${work_dir}/win_delay_hook.c`);
148
- }
149
-
150
- if (process.platform != 'win32' || mingw) {
151
- if (spawnSync('ninja', ['--version']).status === 0) {
152
- args.push('-G', 'Ninja');
153
- } else if (process.platform == 'win32') {
154
- args.push('-G', 'MinGW Makefiles');
155
- }
156
-
157
- // Use CCache if available
158
- if (spawnSync('ccache', ['--version']).status === 0) {
159
- args.push('-DCMAKE_C_COMPILER_LAUNCHER=ccache');
160
- args.push('-DCMAKE_CXX_COMPILER_LAUNCHER=ccache');
161
- }
162
- }
163
-
164
- // Handle toolchain flags and cross-compilation
165
- {
166
- let info = TOOLCHAINS[toolchain ?? host];
167
-
168
- if (info != null) {
169
- if (Object.hasOwn(info, process.platform))
170
- info = Object.assign({}, info, info[process.platform]);
171
-
172
- if (info.flags != null)
173
- args.push(...info.flags);
174
- }
175
-
176
- if (toolchain == null && process.arch == 'ia32') {
177
- let proc = spawnSync('uname', ['-m']);
178
- let machine = (proc.stdout ?? '').toString('utf-8').trim();
179
-
180
- if (machine == 'x86_64') {
181
- // Compiler probably does not default to 32-bit... just force it
182
- args.push('-DCMAKE_ASM_FLAGS=-m32', '-DCMAKE_C_FLAGS=-m32', '-DCMAKE_CXX_FLAGS=-m32');
183
- }
184
- }
185
-
186
- if (toolchain != null && info.triplet != null) {
187
- let values = [
188
- ['CMAKE_SYSTEM_NAME', info.system],
189
- ['CMAKE_SYSTEM_PROCESSOR', info.processor]
190
- ];
191
- let sysroot = null;
192
-
193
- // Switch to Clang automatically if the GCC cross-compiler does not exist
194
- if (process.platform != 'win32' && !prefer_clang) {
195
- let binary = info.triplet + '-gcc';
196
-
197
- if (spawnSync(binary, ['-v']).status !== 0)
198
- prefer_clang = true;
199
- }
200
-
201
- if (prefer_clang) {
202
- values.push(['CMAKE_ASM_COMPILER_TARGET', info.triplet]);
203
- values.push(['CMAKE_C_COMPILER_TARGET', info.triplet]);
204
- values.push(['CMAKE_CXX_COMPILER_TARGET', info.triplet]);
205
-
206
- values.push(['CMAKE_EXE_LINKER_FLAGS', '-fuse-ld=lld']);
207
- values.push(['CMAKE_SHARED_LINKER_FLAGS', '-fuse-ld=lld']);
208
- values.push(['CMAKE_STATIC_LINKER_FLAGS', '-fuse-ld=lld']);
209
- } else if (process.platform != 'win32') {
210
- values.push(['CMAKE_ASM_COMPILER', info.triplet + '-gcc']);
211
- values.push(['CMAKE_C_COMPILER', info.triplet + '-gcc']);
212
- values.push(['CMAKE_CXX_COMPILER', info.triplet + '-g++']);
213
- }
214
-
215
- if (info.sysroot != null) {
216
- sysroot = expand_path(info.sysroot, __dirname + '/..');
217
- if (!fs.existsSync(sysroot))
218
- throw new Error(`Cross-compilation sysroot '${sysroot}' does not exist`);
219
-
220
- values.push(['CMAKE_SYSROOT', sysroot]);
221
- }
222
-
223
- if (info.variables != null) {
224
- for (let key in info.variables) {
225
- let value = expand_string(info.variables[key], { sysroot: sysroot });
226
- values.push([key, value]);
227
- }
228
- }
229
-
230
- let filename = `${work_dir}/toolchain.cmake`;
231
- let text = values.map(pair => `set(${pair[0]} "${pair[1]}")`).join('\n');
232
-
233
- fs.writeFileSync(filename, text);
234
- args.push(`-DCMAKE_TOOLCHAIN_FILE=${filename}`);
235
- }
236
- }
237
-
238
- if (prefer_clang) {
239
- if (process.platform == 'win32' && !mingw) {
240
- args.push('-T', 'ClangCL');
241
- } else {
242
- args.push('-DCMAKE_C_COMPILER=clang');
243
- args.push('-DCMAKE_CXX_COMPILER=clang++');
244
- }
245
- }
246
-
247
- args.push(`-DCMAKE_BUILD_TYPE=${mode}`);
248
- for (let type of ['ARCHIVE', 'RUNTIME', 'LIBRARY']) {
249
- for (let suffix of ['', '_DEBUG', '_RELEASE', '_RELWITHDEBINFO'])
250
- args.push(`-DCMAKE_${type}_OUTPUT_DIRECTORY${suffix}=${output_dir}`);
251
- }
252
- args.push('--no-warn-unused-cli');
253
-
254
- console.log('>> Running configuration');
255
-
256
- let proc = spawnSync(cmake_bin, args, { cwd: work_dir, stdio: 'inherit' });
257
- if (proc.status !== 0) {
258
- tools.unlink_recursive(work_dir);
259
- if (retry)
260
- return self.configure(false);
261
-
262
- throw new Error('Failed to run configure step');
263
- }
264
- };
265
-
266
- this.build = async function() {
267
- check_compatibility();
268
-
269
- if (prebuild) {
270
- let valid = await check_prebuild();
271
- if (valid)
272
- return;
273
- }
274
-
275
- check_cmake();
276
-
277
- if (!fs.existsSync(work_dir + '/CMakeCache.txt'))
278
- await self.configure();
279
-
280
- // In case Make gets used
281
- // os.cpus() returns [] on Android (no /proc/cpuinfo access), so fall back to 1
282
- if (process.env.MAKEFLAGS == null)
283
- process.env.MAKEFLAGS = '-j' + (os.cpus().length || 1);
284
-
285
- let args = [
286
- '--build', work_dir,
287
- '--config', mode
288
- ];
289
-
290
- if (verbose)
291
- args.push('--verbose');
292
- for (let target of targets)
293
- args.push('--target', target);
294
-
295
- console.log('>> Running build');
296
-
297
- let proc = spawnSync(cmake_bin, args, { stdio: 'inherit' });
298
- if (proc.status !== 0)
299
- throw new Error('Failed to run build step');
300
-
301
- console.log('>> Copy target files');
302
-
303
- tools.sync_files(output_dir, build_dir);
304
- };
305
-
306
- async function check_prebuild() {
307
- let options = read_cnoke_options();
308
-
309
- if (options.prebuild != null) {
310
- fs.mkdirSync(build_dir, { recursive: true, mode: 0o755 });
311
-
312
- let archive_filename = expand_path(options.prebuild, options.directory);
313
-
314
- if (fs.existsSync(archive_filename)) {
315
- try {
316
- console.log('>> Extracting prebuilt binaries...');
317
- await tools.extract_targz(archive_filename, build_dir, 1);
318
- } catch (err) {
319
- console.error('Failed to find prebuilt binary for your platform, building manually');
320
- }
321
- } else {
322
- console.error('Cannot find local prebuilt archive');
323
- }
324
- }
325
-
326
- if (options.require != null) {
327
- let require_filename = expand_path(options.require, options.directory);
328
-
329
- if (fs.existsSync(require_filename)) {
330
- let proc = spawnSync(process.execPath, ['-e', 'require(process.argv[1])', require_filename]);
331
- if (proc.status === 0)
332
- return true;
333
- }
334
-
335
- console.error('Failed to load prebuilt binary, rebuilding from source');
336
- }
337
-
338
- return false;
339
- }
340
-
341
- this.clean = function() {
342
- tools.unlink_recursive(build_dir);
343
- };
344
-
345
- function find_parent_directory(dirname, basename) {
346
- if (process.platform == 'win32')
347
- dirname = dirname.replace(/\\/g, '/');
348
-
349
- do {
350
- if (fs.existsSync(dirname + '/' + basename))
351
- return dirname;
352
-
353
- dirname = path.dirname(dirname);
354
- } while (!dirname.endsWith('/'));
355
-
356
- return null;
357
- }
358
-
359
- function get_cache_directory() {
360
- if (process.platform == 'win32') {
361
- let cache_dir = process.env['LOCALAPPDATA'] || process.env['APPDATA'];
362
- if (cache_dir == null)
363
- throw new Error('Missing LOCALAPPDATA and APPDATA environment variable');
364
-
365
- cache_dir = path.join(cache_dir, 'cnoke');
366
- return cache_dir;
367
- } else {
368
- let cache_dir = process.env['XDG_CACHE_HOME'];
369
-
370
- if (cache_dir == null) {
371
- let home = process.env['HOME'];
372
- if (home == null)
373
- throw new Error('Missing HOME environment variable');
374
-
375
- cache_dir = path.join(home, '.cache');
376
- }
377
-
378
- cache_dir = path.join(cache_dir, 'cnoke');
379
- return cache_dir;
380
- }
381
- }
382
-
383
- function check_cmake() {
384
- if (cmake_bin != null)
385
- return;
386
-
387
- // Check for CMakeLists.txt
388
- if (!fs.existsSync(project_dir + '/CMakeLists.txt'))
389
- throw new Error('This directory does not appear to have a CMakeLists.txt file');
390
-
391
- // Check for CMake
392
- {
393
- let proc = spawnSync('cmake', ['--version']);
394
-
395
- if (proc.status === 0) {
396
- cmake_bin = 'cmake';
397
- } else {
398
- if (process.platform == 'win32') {
399
- // I really don't want to depend on anything in CNoke, and Node.js does not provide
400
- // anything to read from the registry. This is okay, REG.exe exists since Windows XP.
401
- let proc = spawnSync('reg', ['query', 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\CMake', '/v', 'InstallDir']);
402
-
403
- if (proc.status === 0) {
404
- let matches = proc.stdout.toString('utf-8').match(/InstallDir[ \t]+REG_[A-Z_]+[ \t]+(.*)+/);
405
-
406
- if (matches != null) {
407
- let bin = path.join(matches[1].trim(), 'bin\\cmake.exe');
408
-
409
- if (fs.existsSync(bin))
410
- cmake_bin = bin;
411
- }
412
- }
413
- }
414
-
415
- if (cmake_bin == null)
416
- throw new Error('CMake does not seem to be available');
417
- }
418
- }
419
-
420
- console.log(`>> Using CMake binary: ${cmake_bin}`);
421
- }
422
-
423
- function check_compatibility() {
424
- let options = read_cnoke_options();
425
-
426
- if (options.node != null && tools.cmp_version(runtime_version, options.node) < 0)
427
- throw new Error(`Project ${options.name} requires Node.js >= ${options.node}`);
428
-
429
- if (options.napi != null) {
430
- let major = parseInt(runtime_version, 10);
431
- let required = tools.get_napi_version(options.napi, major);
432
-
433
- if (required == null)
434
- throw new Error(`Project ${options.name} does not support the Node ${major}.x branch (old or missing N-API)`);
435
- if (tools.cmp_version(runtime_version, required) < 0)
436
- throw new Error(`Project ${options.name} requires Node >= ${required} in the Node ${major}.x branch (with N-API >= ${options.napi})`);
437
- }
438
- }
439
-
440
- function read_cnoke_options() {
441
- if (options != null)
442
- return options;
443
-
444
- let directory = project_dir;
445
- let pkg = null;
446
- let cnoke = null;
447
-
448
- if (package_dir != null) {
449
- try {
450
- let json = fs.readFileSync(package_dir + '/package.json', { encoding: 'utf-8' });
451
-
452
- pkg = JSON.parse(json);
453
- directory = package_dir;
454
- } catch (err) {
455
- if (err.code != 'ENOENT')
456
- throw err;
457
- }
458
- }
459
-
460
- if (cnoke == null)
461
- cnoke = pkg?.cnoke ?? {};
462
-
463
- options = {
464
- name: pkg?.name ?? path.basename(project_dir),
465
- version: pkg?.version ?? null,
466
-
467
- directory: directory,
468
- ...cnoke
469
- };
470
-
471
- return options;
472
- }
473
-
474
- function expand_string(str, values = {}) {
475
- let expanded = str.replace(/{{ *([a-zA-Z_][a-zA-Z_0-9]*) *}}/g, (match, p1) => {
476
- switch (p1) {
477
- case 'version': {
478
- let options = read_cnoke_options();
479
- return options.version || '';
480
- } break;
481
-
482
- case 'toolchain': return toolchain ?? host;
483
-
484
- default: {
485
- if (Object.hasOwn(values, p1)) {
486
- return values[p1];
487
- } else {
488
- return match;
489
- }
490
- } break;
491
- }
492
- });
493
-
494
- return expanded;
495
- }
496
-
497
- function expand_path(str, root) {
498
- let expanded = expand_string(str);
499
-
500
- if (!tools.path_is_absolute(expanded))
501
- expanded = path.join(root, expanded);
502
- expanded = path.normalize(expanded);
503
-
504
- return expanded;
505
- }
506
- }
507
-
508
- module.exports = {
509
- Builder,
510
- DefaultOptions
511
- };
@@ -1,10 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
3
-
4
- const builder = require('./builder.js');
5
- const tools = require('./tools.js');
6
-
7
- module.exports = {
8
- ...builder,
9
- ...tools
10
- };