@auv-js/cli 0.0.0-bootstrap.0 → 0.0.10

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # `@auv-js/cli`
2
+
3
+ Installs the AUV command-line executable that matches the current operating
4
+ system and CPU architecture. The executable is delivered by a platform-specific
5
+ optional npm dependency, so installation does not run a network-downloading
6
+ `postinstall` script.
7
+
8
+ ```sh
9
+ pnpm add @auv-js/cli
10
+ pnpm exec auv --help
11
+ ```
12
+
13
+ Node applications can resolve the installed executable explicitly:
14
+
15
+ ```ts
16
+ import { binaryPath } from '@auv-js/cli/binary'
17
+ import { startAuv } from '@auv-js/sdk/node'
18
+
19
+ const daemon = await startAuv({ binaryPath: binaryPath() })
20
+ ```
21
+
22
+ ## Electron packaging
23
+
24
+ Do not execute the binary from inside `app.asar`. During packaging, copy the
25
+ path returned by `binaryPath()` into an unpacked, app-owned location and resolve
26
+ that copied path at runtime.
27
+
28
+ - macOS: copy it to `YourApp.app/Contents/MacOS/auv`, and list it in
29
+ electron-builder's `mac.binaries` so it is signed as nested code.
30
+ - Windows and Linux: copy it to `resources/bin/auv.exe` or
31
+ `resources/bin/auv` through `extraResources`.
32
+
33
+ The Electron main process should own the child process and pass the resulting
34
+ absolute path to `startAuv()`. Importing `@auv-js/cli/binary` during staging
35
+ does not load the NAPI addon. If the application also imports the root NAPI
36
+ entrypoint at runtime, keep `*.node` files outside the ASAR with the packager's
37
+ native-module/`asarUnpack` support. Keep the SDK independent of packaging policy
38
+ so browser and remote-client consumers do not install a native executable.
39
+
40
+ Supported packages currently cover macOS arm64/x64, glibc Linux arm64/x64, and
41
+ Windows x64. Installing with optional dependencies disabled leaves no binary;
42
+ `binaryPath()` reports that case with an actionable error.
package/bin/auv.js ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+
3
+ import process from 'node:process'
4
+
5
+ import { spawnSync } from 'node:child_process'
6
+ import { constants } from 'node:os'
7
+
8
+ import { binaryPath } from '../dist/binary.js'
9
+
10
+ try {
11
+ const result = spawnSync(binaryPath(), process.argv.slice(2), {
12
+ stdio: 'inherit',
13
+ windowsHide: true,
14
+ })
15
+
16
+ if (result.error) {
17
+ throw result.error
18
+ }
19
+
20
+ if (result.signal) {
21
+ try {
22
+ process.kill(process.pid, result.signal)
23
+ }
24
+ catch {
25
+ const signalNumber = constants.signals[result.signal]
26
+ process.exitCode = signalNumber === undefined ? 1 : 128 + signalNumber
27
+ }
28
+ }
29
+ else {
30
+ process.exitCode = result.status ?? 1
31
+ }
32
+ }
33
+ catch (error) {
34
+ const message = error && typeof error === 'object' && 'message' in error
35
+ ? String(error.message)
36
+ : String(error)
37
+ console.error(`auv: ${message}`)
38
+ process.exitCode = 1
39
+ }
package/binding.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ /**
4
+ * Return the version embedded into the native binding.
5
+ *
6
+ * The JavaScript entrypoint compares this value with its package manifest so
7
+ * a partially published release fails before it starts an AUV sidecar.
8
+ */
9
+ export declare function nativePackageVersion(): string
package/binding.js ADDED
@@ -0,0 +1,707 @@
1
+ // prettier-ignore
2
+ /* eslint-disable */
3
+ // @ts-nocheck
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ import { createRequire } from 'module'
7
+ const require = createRequire(import.meta.url)
8
+ const __dirname = new URL('.', import.meta.url).pathname
9
+
10
+ const { readFileSync } = require('fs')
11
+ let nativeBinding = null
12
+ const loadErrors = []
13
+
14
+ const isMusl = () => {
15
+ let musl = false
16
+ if (process.platform === 'linux') {
17
+ musl = isMuslFromFilesystem()
18
+ if (musl === null) {
19
+ musl = isMuslFromReport()
20
+ }
21
+ if (musl === null) {
22
+ musl = isMuslFromChildProcess()
23
+ }
24
+ }
25
+ return musl
26
+ }
27
+
28
+ const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
29
+
30
+ const isMuslFromFilesystem = () => {
31
+ try {
32
+ return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
33
+ } catch {
34
+ return null
35
+ }
36
+ }
37
+
38
+ const isMuslFromReport = () => {
39
+ let report = null
40
+ if (process.report && typeof process.report.getReport === 'function') {
41
+ process.report.excludeNetwork = true
42
+ report = process.report.getReport()
43
+ }
44
+ if (!report) {
45
+ return null
46
+ }
47
+ if (report.header && report.header.glibcVersionRuntime) {
48
+ return false
49
+ }
50
+ if (Array.isArray(report.sharedObjects)) {
51
+ if (report.sharedObjects.some(isFileMusl)) {
52
+ return true
53
+ }
54
+ }
55
+ return false
56
+ }
57
+
58
+ const isMuslFromChildProcess = () => {
59
+ try {
60
+ return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
61
+ } catch (e) {
62
+ // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
63
+ return false
64
+ }
65
+ }
66
+
67
+ function requireNative() {
68
+ if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
69
+ try {
70
+ return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
71
+ } catch (err) {
72
+ loadErrors.push(err)
73
+ }
74
+ } else if (process.platform === 'android') {
75
+ if (process.arch === 'arm64') {
76
+ try {
77
+ return require('./auv-binding.android-arm64.node')
78
+ } catch (e) {
79
+ loadErrors.push(e)
80
+ }
81
+ try {
82
+ const binding = require('@auv-js/cli-android-arm64')
83
+ const bindingPackageVersion = require('@auv-js/cli-android-arm64/package.json').version
84
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
85
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
86
+ }
87
+ return binding
88
+ } catch (e) {
89
+ loadErrors.push(e)
90
+ }
91
+ } else if (process.arch === 'arm') {
92
+ try {
93
+ return require('./auv-binding.android-arm-eabi.node')
94
+ } catch (e) {
95
+ loadErrors.push(e)
96
+ }
97
+ try {
98
+ const binding = require('@auv-js/cli-android-arm-eabi')
99
+ const bindingPackageVersion = require('@auv-js/cli-android-arm-eabi/package.json').version
100
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
102
+ }
103
+ return binding
104
+ } catch (e) {
105
+ loadErrors.push(e)
106
+ }
107
+ } else {
108
+ loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
109
+ }
110
+ } else if (process.platform === 'win32') {
111
+ if (process.arch === 'x64') {
112
+ if ((process.config && process.config.variables && process.config.variables.shlib_suffix === 'dll.a') || (process.config && process.config.variables && process.config.variables.node_target_type === 'shared_library')) {
113
+ try {
114
+ return require('./auv-binding.win32-x64-gnu.node')
115
+ } catch (e) {
116
+ loadErrors.push(e)
117
+ }
118
+ try {
119
+ const binding = require('@auv-js/cli-win32-x64-gnu')
120
+ const bindingPackageVersion = require('@auv-js/cli-win32-x64-gnu/package.json').version
121
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
122
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
123
+ }
124
+ return binding
125
+ } catch (e) {
126
+ loadErrors.push(e)
127
+ }
128
+ } else {
129
+ try {
130
+ return require('./auv-binding.win32-x64-msvc.node')
131
+ } catch (e) {
132
+ loadErrors.push(e)
133
+ }
134
+ try {
135
+ const binding = require('@auv-js/cli-win32-x64-msvc')
136
+ const bindingPackageVersion = require('@auv-js/cli-win32-x64-msvc/package.json').version
137
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
138
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
139
+ }
140
+ return binding
141
+ } catch (e) {
142
+ loadErrors.push(e)
143
+ }
144
+ }
145
+ } else if (process.arch === 'ia32') {
146
+ try {
147
+ return require('./auv-binding.win32-ia32-msvc.node')
148
+ } catch (e) {
149
+ loadErrors.push(e)
150
+ }
151
+ try {
152
+ const binding = require('@auv-js/cli-win32-ia32-msvc')
153
+ const bindingPackageVersion = require('@auv-js/cli-win32-ia32-msvc/package.json').version
154
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
155
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
156
+ }
157
+ return binding
158
+ } catch (e) {
159
+ loadErrors.push(e)
160
+ }
161
+ } else if (process.arch === 'arm64') {
162
+ try {
163
+ return require('./auv-binding.win32-arm64-msvc.node')
164
+ } catch (e) {
165
+ loadErrors.push(e)
166
+ }
167
+ try {
168
+ const binding = require('@auv-js/cli-win32-arm64-msvc')
169
+ const bindingPackageVersion = require('@auv-js/cli-win32-arm64-msvc/package.json').version
170
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
172
+ }
173
+ return binding
174
+ } catch (e) {
175
+ loadErrors.push(e)
176
+ }
177
+ } else {
178
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
179
+ }
180
+ } else if (process.platform === 'darwin') {
181
+ try {
182
+ return require('./auv-binding.darwin-universal.node')
183
+ } catch (e) {
184
+ loadErrors.push(e)
185
+ }
186
+ try {
187
+ const binding = require('@auv-js/cli-darwin-universal')
188
+ const bindingPackageVersion = require('@auv-js/cli-darwin-universal/package.json').version
189
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
190
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
191
+ }
192
+ return binding
193
+ } catch (e) {
194
+ loadErrors.push(e)
195
+ }
196
+ if (process.arch === 'x64') {
197
+ try {
198
+ return require('./auv-binding.darwin-x64.node')
199
+ } catch (e) {
200
+ loadErrors.push(e)
201
+ }
202
+ try {
203
+ const binding = require('@auv-js/cli-darwin-x64')
204
+ const bindingPackageVersion = require('@auv-js/cli-darwin-x64/package.json').version
205
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
206
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
207
+ }
208
+ return binding
209
+ } catch (e) {
210
+ loadErrors.push(e)
211
+ }
212
+ } else if (process.arch === 'arm64') {
213
+ try {
214
+ return require('./auv-binding.darwin-arm64.node')
215
+ } catch (e) {
216
+ loadErrors.push(e)
217
+ }
218
+ try {
219
+ const binding = require('@auv-js/cli-darwin-arm64')
220
+ const bindingPackageVersion = require('@auv-js/cli-darwin-arm64/package.json').version
221
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
222
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
223
+ }
224
+ return binding
225
+ } catch (e) {
226
+ loadErrors.push(e)
227
+ }
228
+ } else {
229
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
230
+ }
231
+ } else if (process.platform === 'freebsd') {
232
+ if (process.arch === 'x64') {
233
+ try {
234
+ return require('./auv-binding.freebsd-x64.node')
235
+ } catch (e) {
236
+ loadErrors.push(e)
237
+ }
238
+ try {
239
+ const binding = require('@auv-js/cli-freebsd-x64')
240
+ const bindingPackageVersion = require('@auv-js/cli-freebsd-x64/package.json').version
241
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
242
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
243
+ }
244
+ return binding
245
+ } catch (e) {
246
+ loadErrors.push(e)
247
+ }
248
+ } else if (process.arch === 'arm64') {
249
+ try {
250
+ return require('./auv-binding.freebsd-arm64.node')
251
+ } catch (e) {
252
+ loadErrors.push(e)
253
+ }
254
+ try {
255
+ const binding = require('@auv-js/cli-freebsd-arm64')
256
+ const bindingPackageVersion = require('@auv-js/cli-freebsd-arm64/package.json').version
257
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
258
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
259
+ }
260
+ return binding
261
+ } catch (e) {
262
+ loadErrors.push(e)
263
+ }
264
+ } else {
265
+ loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
266
+ }
267
+ } else if (process.platform === 'linux') {
268
+ if (process.arch === 'x64') {
269
+ if (isMusl()) {
270
+ try {
271
+ return require('./auv-binding.linux-x64-musl.node')
272
+ } catch (e) {
273
+ loadErrors.push(e)
274
+ }
275
+ try {
276
+ const binding = require('@auv-js/cli-linux-x64-musl')
277
+ const bindingPackageVersion = require('@auv-js/cli-linux-x64-musl/package.json').version
278
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
279
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
280
+ }
281
+ return binding
282
+ } catch (e) {
283
+ loadErrors.push(e)
284
+ }
285
+ } else {
286
+ try {
287
+ return require('./auv-binding.linux-x64-gnu.node')
288
+ } catch (e) {
289
+ loadErrors.push(e)
290
+ }
291
+ try {
292
+ const binding = require('@auv-js/cli-linux-x64-gnu')
293
+ const bindingPackageVersion = require('@auv-js/cli-linux-x64-gnu/package.json').version
294
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
295
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
296
+ }
297
+ return binding
298
+ } catch (e) {
299
+ loadErrors.push(e)
300
+ }
301
+ }
302
+ } else if (process.arch === 'arm64') {
303
+ if (isMusl()) {
304
+ try {
305
+ return require('./auv-binding.linux-arm64-musl.node')
306
+ } catch (e) {
307
+ loadErrors.push(e)
308
+ }
309
+ try {
310
+ const binding = require('@auv-js/cli-linux-arm64-musl')
311
+ const bindingPackageVersion = require('@auv-js/cli-linux-arm64-musl/package.json').version
312
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
313
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
314
+ }
315
+ return binding
316
+ } catch (e) {
317
+ loadErrors.push(e)
318
+ }
319
+ } else {
320
+ try {
321
+ return require('./auv-binding.linux-arm64-gnu.node')
322
+ } catch (e) {
323
+ loadErrors.push(e)
324
+ }
325
+ try {
326
+ const binding = require('@auv-js/cli-linux-arm64-gnu')
327
+ const bindingPackageVersion = require('@auv-js/cli-linux-arm64-gnu/package.json').version
328
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
329
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
330
+ }
331
+ return binding
332
+ } catch (e) {
333
+ loadErrors.push(e)
334
+ }
335
+ }
336
+ } else if (process.arch === 'arm') {
337
+ if (isMusl()) {
338
+ try {
339
+ return require('./auv-binding.linux-arm-musleabihf.node')
340
+ } catch (e) {
341
+ loadErrors.push(e)
342
+ }
343
+ try {
344
+ const binding = require('@auv-js/cli-linux-arm-musleabihf')
345
+ const bindingPackageVersion = require('@auv-js/cli-linux-arm-musleabihf/package.json').version
346
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
347
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
348
+ }
349
+ return binding
350
+ } catch (e) {
351
+ loadErrors.push(e)
352
+ }
353
+ } else {
354
+ try {
355
+ return require('./auv-binding.linux-arm-gnueabihf.node')
356
+ } catch (e) {
357
+ loadErrors.push(e)
358
+ }
359
+ try {
360
+ const binding = require('@auv-js/cli-linux-arm-gnueabihf')
361
+ const bindingPackageVersion = require('@auv-js/cli-linux-arm-gnueabihf/package.json').version
362
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
363
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
364
+ }
365
+ return binding
366
+ } catch (e) {
367
+ loadErrors.push(e)
368
+ }
369
+ }
370
+ } else if (process.arch === 'loong64') {
371
+ if (isMusl()) {
372
+ try {
373
+ return require('./auv-binding.linux-loong64-musl.node')
374
+ } catch (e) {
375
+ loadErrors.push(e)
376
+ }
377
+ try {
378
+ const binding = require('@auv-js/cli-linux-loong64-musl')
379
+ const bindingPackageVersion = require('@auv-js/cli-linux-loong64-musl/package.json').version
380
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
381
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
382
+ }
383
+ return binding
384
+ } catch (e) {
385
+ loadErrors.push(e)
386
+ }
387
+ } else {
388
+ try {
389
+ return require('./auv-binding.linux-loong64-gnu.node')
390
+ } catch (e) {
391
+ loadErrors.push(e)
392
+ }
393
+ try {
394
+ const binding = require('@auv-js/cli-linux-loong64-gnu')
395
+ const bindingPackageVersion = require('@auv-js/cli-linux-loong64-gnu/package.json').version
396
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
397
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
398
+ }
399
+ return binding
400
+ } catch (e) {
401
+ loadErrors.push(e)
402
+ }
403
+ }
404
+ } else if (process.arch === 'riscv64') {
405
+ if (isMusl()) {
406
+ try {
407
+ return require('./auv-binding.linux-riscv64-musl.node')
408
+ } catch (e) {
409
+ loadErrors.push(e)
410
+ }
411
+ try {
412
+ const binding = require('@auv-js/cli-linux-riscv64-musl')
413
+ const bindingPackageVersion = require('@auv-js/cli-linux-riscv64-musl/package.json').version
414
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
415
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
416
+ }
417
+ return binding
418
+ } catch (e) {
419
+ loadErrors.push(e)
420
+ }
421
+ } else {
422
+ try {
423
+ return require('./auv-binding.linux-riscv64-gnu.node')
424
+ } catch (e) {
425
+ loadErrors.push(e)
426
+ }
427
+ try {
428
+ const binding = require('@auv-js/cli-linux-riscv64-gnu')
429
+ const bindingPackageVersion = require('@auv-js/cli-linux-riscv64-gnu/package.json').version
430
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
431
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
432
+ }
433
+ return binding
434
+ } catch (e) {
435
+ loadErrors.push(e)
436
+ }
437
+ }
438
+ } else if (process.arch === 'ppc64') {
439
+ try {
440
+ return require('./auv-binding.linux-ppc64-gnu.node')
441
+ } catch (e) {
442
+ loadErrors.push(e)
443
+ }
444
+ try {
445
+ const binding = require('@auv-js/cli-linux-ppc64-gnu')
446
+ const bindingPackageVersion = require('@auv-js/cli-linux-ppc64-gnu/package.json').version
447
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
448
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
449
+ }
450
+ return binding
451
+ } catch (e) {
452
+ loadErrors.push(e)
453
+ }
454
+ } else if (process.arch === 's390x') {
455
+ try {
456
+ return require('./auv-binding.linux-s390x-gnu.node')
457
+ } catch (e) {
458
+ loadErrors.push(e)
459
+ }
460
+ try {
461
+ const binding = require('@auv-js/cli-linux-s390x-gnu')
462
+ const bindingPackageVersion = require('@auv-js/cli-linux-s390x-gnu/package.json').version
463
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
464
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
465
+ }
466
+ return binding
467
+ } catch (e) {
468
+ loadErrors.push(e)
469
+ }
470
+ } else {
471
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
472
+ }
473
+ } else if (process.platform === 'openharmony') {
474
+ if (process.arch === 'arm64') {
475
+ try {
476
+ return require('./auv-binding.openharmony-arm64.node')
477
+ } catch (e) {
478
+ loadErrors.push(e)
479
+ }
480
+ try {
481
+ const binding = require('@auv-js/cli-openharmony-arm64')
482
+ const bindingPackageVersion = require('@auv-js/cli-openharmony-arm64/package.json').version
483
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
484
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
485
+ }
486
+ return binding
487
+ } catch (e) {
488
+ loadErrors.push(e)
489
+ }
490
+ } else if (process.arch === 'x64') {
491
+ try {
492
+ return require('./auv-binding.openharmony-x64.node')
493
+ } catch (e) {
494
+ loadErrors.push(e)
495
+ }
496
+ try {
497
+ const binding = require('@auv-js/cli-openharmony-x64')
498
+ const bindingPackageVersion = require('@auv-js/cli-openharmony-x64/package.json').version
499
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
500
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
501
+ }
502
+ return binding
503
+ } catch (e) {
504
+ loadErrors.push(e)
505
+ }
506
+ } else if (process.arch === 'arm') {
507
+ try {
508
+ return require('./auv-binding.openharmony-arm.node')
509
+ } catch (e) {
510
+ loadErrors.push(e)
511
+ }
512
+ try {
513
+ const binding = require('@auv-js/cli-openharmony-arm')
514
+ const bindingPackageVersion = require('@auv-js/cli-openharmony-arm/package.json').version
515
+ if (bindingPackageVersion !== '0.0.6' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
516
+ throw new Error(`Native binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
517
+ }
518
+ return binding
519
+ } catch (e) {
520
+ loadErrors.push(e)
521
+ }
522
+ } else {
523
+ loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
524
+ }
525
+ } else {
526
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
527
+ }
528
+ }
529
+
530
+ function createLoadErrorChain(errors) {
531
+ return errors.reduce((previous, current) => {
532
+ let message
533
+ try {
534
+ message =
535
+ current && typeof current.message === 'string'
536
+ ? current.message
537
+ : String(current)
538
+ } catch {
539
+ message = 'Unknown error'
540
+ }
541
+ const error = new Error(message)
542
+ error.cause = previous
543
+ return error
544
+ }, null)
545
+ }
546
+
547
+ // NAPI_RS_FORCE_WASI is a tri-state flag:
548
+ // unset / any other value → native binding preferred, WASI is only a fallback
549
+ // 'true' → prefer WASI, but retain native as a lazy fallback
550
+ // 'error' → require WASI without initializing a native fallback
551
+ // Treating any non-empty string as truthy (the historical behavior) meant
552
+ // NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
553
+ // the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
554
+ //
555
+ // NAPI_RS_WASI_FLAVOR selects one exact generated flavor and implies strict
556
+ // WASI loading. It never crosses into another flavor or falls back to native.
557
+ const __napiWasiFlavors = ["wasm32-wasi"]
558
+ const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR
559
+ const __napiWasiFlavorRequested =
560
+ typeof __napiWasiFlavor === 'string' && __napiWasiFlavor.length > 0
561
+ if (
562
+ __napiWasiFlavorRequested &&
563
+ __napiWasiFlavors.indexOf(__napiWasiFlavor) === -1
564
+ ) {
565
+ throw new Error(
566
+ 'Unsupported WASI flavor "' +
567
+ __napiWasiFlavor +
568
+ '". Available flavors: ' +
569
+ __napiWasiFlavors.join(', '),
570
+ )
571
+ }
572
+ const forceWasiError = process.env.NAPI_RS_FORCE_WASI === 'error'
573
+ const forceWasi =
574
+ process.env.NAPI_RS_FORCE_WASI === 'true' ||
575
+ forceWasiError ||
576
+ __napiWasiFlavorRequested
577
+
578
+ if (!forceWasi) {
579
+ nativeBinding = requireNative()
580
+ }
581
+
582
+ if (!nativeBinding || forceWasi) {
583
+ let wasiBinding = null
584
+ let wasiBindingLoaded = false
585
+ const wasiBindingErrors = []
586
+ const __napiWasiResolveCandidate = (specifier, isPackage, localArtifacts) => {
587
+ try {
588
+ require.resolve(specifier)
589
+ } catch (resolveError) {
590
+ if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
591
+ throw resolveError
592
+ }
593
+ if (isPackage) {
594
+ try {
595
+ require.resolve(specifier + '/package.json')
596
+ } catch (packageError) {
597
+ if (packageError && packageError.code === 'MODULE_NOT_FOUND') {
598
+ return resolveError
599
+ }
600
+ // An exports restriction proves the package exists even when its
601
+ // package.json is not public. Preserve the root resolution failure.
602
+ throw resolveError
603
+ }
604
+ // The package exists but its main/export target is broken.
605
+ throw resolveError
606
+ }
607
+ return resolveError
608
+ }
609
+ if (localArtifacts) {
610
+ let artifactError = null
611
+ for (let i = 0; i < localArtifacts.length; i++) {
612
+ try {
613
+ require.resolve(localArtifacts[i])
614
+ return null
615
+ } catch (resolveError) {
616
+ if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
617
+ throw resolveError
618
+ }
619
+ artifactError = resolveError
620
+ }
621
+ }
622
+ return artifactError
623
+ }
624
+ return null
625
+ }
626
+ if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
627
+ let candidateError = null
628
+ let candidateFailed = false
629
+ try {
630
+ candidateError = __napiWasiResolveCandidate('./auv-binding.wasi.cjs', false, ["./auv-binding.wasm32-wasi.debug.wasm","./auv-binding.wasm32-wasi.wasm"])
631
+ candidateFailed = candidateError !== null
632
+ if (!candidateFailed) {
633
+ wasiBinding = require('./auv-binding.wasi.cjs')
634
+ nativeBinding = wasiBinding
635
+ wasiBindingLoaded = true
636
+ }
637
+ } catch (err) {
638
+ candidateError = err
639
+ candidateFailed = true
640
+ }
641
+ if (candidateFailed) {
642
+ wasiBindingErrors.push(candidateError)
643
+ loadErrors.push(candidateError)
644
+ }
645
+ }
646
+ if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
647
+ let candidateError = null
648
+ let candidateFailed = false
649
+ try {
650
+ candidateError = __napiWasiResolveCandidate('@auv-js/cli-wasm32-wasi', true, undefined)
651
+ candidateFailed = candidateError !== null
652
+ if (!candidateFailed) {
653
+ if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
654
+ const bindingPackageVersion = require('@auv-js/cli-wasm32-wasi/package.json').version
655
+ if (bindingPackageVersion !== '0.0.6') {
656
+ throw new Error(`WASI binding package version mismatch, expected 0.0.6 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
657
+ }
658
+ }
659
+ wasiBinding = require('@auv-js/cli-wasm32-wasi')
660
+ nativeBinding = wasiBinding
661
+ wasiBindingLoaded = true
662
+ }
663
+ } catch (err) {
664
+ candidateError = err
665
+ candidateFailed = true
666
+ }
667
+ if (candidateFailed) {
668
+ wasiBindingErrors.push(candidateError)
669
+ loadErrors.push(candidateError)
670
+ }
671
+ }
672
+ if (
673
+ !wasiBindingLoaded &&
674
+ forceWasi &&
675
+ !forceWasiError &&
676
+ !__napiWasiFlavorRequested
677
+ ) {
678
+ nativeBinding = requireNative()
679
+ }
680
+ if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
681
+ const error = new Error(
682
+ __napiWasiFlavorRequested
683
+ ? 'WASI binding for flavor "' + __napiWasiFlavor + '" not found'
684
+ : 'WASI binding not found and NAPI_RS_FORCE_WASI is set to error',
685
+ )
686
+ error.cause = createLoadErrorChain(wasiBindingErrors)
687
+ throw error
688
+ }
689
+ }
690
+
691
+ if (!nativeBinding) {
692
+ if (loadErrors.length > 0) {
693
+ const error = new Error(
694
+ `Cannot find native binding. ` +
695
+ `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
696
+ 'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
697
+ )
698
+ // assign instead of the `new Error(message, { cause })` options form,
699
+ // which Node < 16.9 silently ignores
700
+ error.cause = createLoadErrorChain(loadErrors)
701
+ throw error
702
+ }
703
+ throw new Error(`Failed to load native binding`)
704
+ }
705
+
706
+ const { nativePackageVersion } = nativeBinding
707
+ export { nativePackageVersion }
@@ -0,0 +1,9 @@
1
+ //#region src-js/binary.d.ts
2
+ declare class AuvBinaryError extends Error {
3
+ constructor(message: string, options?: ErrorOptions);
4
+ }
5
+ /** Return the absolute path of the AUV executable installed for this host. */
6
+ declare function binaryPath(): string;
7
+ //#endregion
8
+ export { AuvBinaryError, binaryPath };
9
+ //# sourceMappingURL=binary.d.ts.map
package/dist/binary.js ADDED
@@ -0,0 +1,53 @@
1
+ import { createRequire } from "node:module";
2
+ import process from "node:process";
3
+ import { accessSync, constants, readFileSync } from "node:fs";
4
+ import { dirname, join } from "node:path";
5
+ //#region src-js/binary.ts
6
+ const require = createRequire(import.meta.url);
7
+ const PLATFORM_PACKAGES = /* @__PURE__ */ new Map([
8
+ ["darwin-arm64", ["@auv-js/cli-darwin-arm64", "bin/auv"]],
9
+ ["darwin-x64", ["@auv-js/cli-darwin-x64", "bin/auv"]],
10
+ ["linux-arm64", ["@auv-js/cli-linux-arm64-gnu", "bin/auv"]],
11
+ ["linux-x64", ["@auv-js/cli-linux-x64-gnu", "bin/auv"]],
12
+ ["win32-x64", ["@auv-js/cli-win32-x64-msvc", "bin/auv.exe"]]
13
+ ]);
14
+ var AuvBinaryError = class extends Error {
15
+ constructor(message, options) {
16
+ super(message, options);
17
+ this.name = "AuvBinaryError";
18
+ }
19
+ };
20
+ /** Return the absolute path of the AUV executable installed for this host. */
21
+ function binaryPath() {
22
+ const platformKey = `${process.platform}-${process.arch}`;
23
+ const platformPackage = PLATFORM_PACKAGES.get(platformKey);
24
+ if (!platformPackage) throw new AuvBinaryError(`AUV does not publish an executable for ${process.platform}/${process.arch}.`);
25
+ if (process.platform === "linux" && isMusl()) throw new AuvBinaryError("AUV currently publishes glibc Linux executables only; musl Linux is not supported.");
26
+ const [packageName, executable] = platformPackage;
27
+ let manifestPath;
28
+ try {
29
+ manifestPath = require.resolve(`${packageName}/package.json`);
30
+ } catch (cause) {
31
+ throw new AuvBinaryError(`The optional package ${packageName} is missing. Reinstall @auv-js/cli without omitting optional dependencies.`, { cause });
32
+ }
33
+ verifyPackageVersion(packageName, manifestPath);
34
+ const resolvedPath = join(dirname(manifestPath), executable);
35
+ try {
36
+ accessSync(resolvedPath, process.platform === "win32" ? constants.F_OK : constants.X_OK);
37
+ } catch (cause) {
38
+ throw new AuvBinaryError(`The ${packageName} package does not contain an executable AUV binary at ${resolvedPath}.`, { cause });
39
+ }
40
+ return resolvedPath;
41
+ }
42
+ function isMusl() {
43
+ return (process.report?.getReport?.())?.header?.glibcVersionRuntime === void 0;
44
+ }
45
+ function verifyPackageVersion(packageName, manifestPath) {
46
+ const rootManifest = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
47
+ const platformManifest = JSON.parse(readFileSync(manifestPath, "utf8"));
48
+ if (platformManifest.version !== rootManifest.version) throw new AuvBinaryError(`The installed ${packageName} version (${platformManifest.version}) does not match @auv-js/cli (${rootManifest.version}). Reinstall both packages together.`);
49
+ }
50
+ //#endregion
51
+ export { AuvBinaryError, binaryPath };
52
+
53
+ //# sourceMappingURL=binary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary.js","names":[],"sources":["../src-js/binary.ts"],"sourcesContent":["import process from 'node:process'\n\nimport { accessSync, constants, readFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { dirname, join } from 'node:path'\n\nconst require = createRequire(import.meta.url)\n\nconst PLATFORM_PACKAGES = new Map<string, readonly [string, string]>([\n ['darwin-arm64', ['@auv-js/cli-darwin-arm64', 'bin/auv']],\n ['darwin-x64', ['@auv-js/cli-darwin-x64', 'bin/auv']],\n ['linux-arm64', ['@auv-js/cli-linux-arm64-gnu', 'bin/auv']],\n ['linux-x64', ['@auv-js/cli-linux-x64-gnu', 'bin/auv']],\n ['win32-x64', ['@auv-js/cli-win32-x64-msvc', 'bin/auv.exe']],\n])\n\ninterface DiagnosticReport {\n header?: {\n glibcVersionRuntime?: string\n }\n}\n\ninterface PackageManifest {\n version: string\n}\n\nexport class AuvBinaryError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options)\n this.name = 'AuvBinaryError'\n }\n}\n\n/** Return the absolute path of the AUV executable installed for this host. */\nexport function binaryPath(): string {\n const platformKey = `${process.platform}-${process.arch}`\n const platformPackage = PLATFORM_PACKAGES.get(platformKey)\n\n if (!platformPackage) {\n throw new AuvBinaryError(\n `AUV does not publish an executable for ${process.platform}/${process.arch}.`,\n )\n }\n\n if (process.platform === 'linux' && isMusl()) {\n throw new AuvBinaryError(\n 'AUV currently publishes glibc Linux executables only; musl Linux is not supported.',\n )\n }\n\n const [packageName, executable] = platformPackage\n let manifestPath: string\n\n try {\n manifestPath = require.resolve(`${packageName}/package.json`)\n }\n catch (cause) {\n throw new AuvBinaryError(\n `The optional package ${packageName} is missing. Reinstall @auv-js/cli without omitting optional dependencies.`,\n { cause },\n )\n }\n\n verifyPackageVersion(packageName, manifestPath)\n\n const resolvedPath = join(dirname(manifestPath), executable)\n try {\n accessSync(\n resolvedPath,\n process.platform === 'win32' ? constants.F_OK : constants.X_OK,\n )\n }\n catch (cause) {\n throw new AuvBinaryError(\n `The ${packageName} package does not contain an executable AUV binary at ${resolvedPath}.`,\n { cause },\n )\n }\n\n return resolvedPath\n}\n\nfunction isMusl(): boolean {\n const report = process.report?.getReport?.() as DiagnosticReport | undefined\n return report?.header?.glibcVersionRuntime === undefined\n}\n\nfunction verifyPackageVersion(packageName: string, manifestPath: string): void {\n const rootManifest = JSON.parse(\n readFileSync(new URL('../package.json', import.meta.url), 'utf8'),\n ) as PackageManifest\n const platformManifest = JSON.parse(\n readFileSync(manifestPath, 'utf8'),\n ) as PackageManifest\n\n if (platformManifest.version !== rootManifest.version) {\n throw new AuvBinaryError(\n `The installed ${packageName} version (${platformManifest.version}) does not match @auv-js/cli (${rootManifest.version}). Reinstall both packages together.`,\n )\n }\n}\n"],"mappings":";;;;;AAMA,MAAM,UAAU,cAAc,OAAO,KAAK,GAAG;AAE7C,MAAM,oCAAoB,IAAI,IAAuC;CACnE,CAAC,gBAAgB,CAAC,4BAA4B,SAAS,CAAC;CACxD,CAAC,cAAc,CAAC,0BAA0B,SAAS,CAAC;CACpD,CAAC,eAAe,CAAC,+BAA+B,SAAS,CAAC;CAC1D,CAAC,aAAa,CAAC,6BAA6B,SAAS,CAAC;CACtD,CAAC,aAAa,CAAC,8BAA8B,aAAa,CAAC;AAC7D,CAAC;AAYD,IAAa,iBAAb,cAAoC,MAAM;CACxC,YAAY,SAAiB,SAAwB;EACnD,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CACd;AACF;;AAGA,SAAgB,aAAqB;CACnC,MAAM,cAAc,GAAG,QAAQ,SAAS,GAAG,QAAQ;CACnD,MAAM,kBAAkB,kBAAkB,IAAI,WAAW;CAEzD,IAAI,CAAC,iBACH,MAAM,IAAI,eACR,0CAA0C,QAAQ,SAAS,GAAG,QAAQ,KAAK,EAC7E;CAGF,IAAI,QAAQ,aAAa,WAAW,OAAO,GACzC,MAAM,IAAI,eACR,oFACF;CAGF,MAAM,CAAC,aAAa,cAAc;CAClC,IAAI;CAEJ,IAAI;EACF,eAAe,QAAQ,QAAQ,GAAG,YAAY,cAAc;CAC9D,SACO,OAAO;EACZ,MAAM,IAAI,eACR,wBAAwB,YAAY,6EACpC,EAAE,MAAM,CACV;CACF;CAEA,qBAAqB,aAAa,YAAY;CAE9C,MAAM,eAAe,KAAK,QAAQ,YAAY,GAAG,UAAU;CAC3D,IAAI;EACF,WACE,cACA,QAAQ,aAAa,UAAU,UAAU,OAAO,UAAU,IAC5D;CACF,SACO,OAAO;EACZ,MAAM,IAAI,eACR,OAAO,YAAY,wDAAwD,aAAa,IACxF,EAAE,MAAM,CACV;CACF;CAEA,OAAO;AACT;AAEA,SAAS,SAAkB;CAEzB,QADe,QAAQ,QAAQ,YAAY,EAAA,EAC5B,QAAQ,wBAAwB,KAAA;AACjD;AAEA,SAAS,qBAAqB,aAAqB,cAA4B;CAC7E,MAAM,eAAe,KAAK,MACxB,aAAa,IAAI,IAAI,mBAAmB,OAAO,KAAK,GAAG,GAAG,MAAM,CAClE;CACA,MAAM,mBAAmB,KAAK,MAC5B,aAAa,cAAc,MAAM,CACnC;CAEA,IAAI,iBAAiB,YAAY,aAAa,SAC5C,MAAM,IAAI,eACR,iBAAiB,YAAY,YAAY,iBAAiB,QAAQ,gCAAgC,aAAa,QAAQ,qCACzH;AAEJ"}
@@ -0,0 +1,3 @@
1
+ import { AuvBinaryError, binaryPath } from "./binary.js";
2
+ export * from "../binding.js";
3
+ export { AuvBinaryError, binaryPath };
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ import { AuvBinaryError, binaryPath } from "./binary.js";
2
+ import { readFileSync } from "node:fs";
3
+ import { nativePackageVersion } from "../binding.js";
4
+ export * from "../binding.js";
5
+ //#region src-js/index.ts
6
+ const packageVersion = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
7
+ const bindingVersion = nativePackageVersion();
8
+ if (bindingVersion !== packageVersion) console.warn(`The AUV native binding version (${bindingVersion}) does not match @auv-js/cli (${packageVersion}). This may cause unexpected behavior.`);
9
+ //#endregion
10
+ export { AuvBinaryError, binaryPath };
11
+
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src-js/index.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\n\nimport { nativePackageVersion } from '../binding.js'\n\nconst packageVersion = (JSON.parse(\n readFileSync(new URL('../package.json', import.meta.url), 'utf8'),\n) as { version: string }).version\n\nconst bindingVersion = nativePackageVersion()\nif (bindingVersion !== packageVersion) {\n console.warn(`The AUV native binding version (${bindingVersion}) does not match @auv-js/cli (${packageVersion}). This may cause unexpected behavior.`)\n}\n\nexport * from '../binding.js'\nexport * from './binary.js'\n"],"mappings":";;;;;AAIA,MAAM,iBAAkB,KAAK,MAC3B,aAAa,IAAI,IAAI,mBAAmB,OAAO,KAAK,GAAG,GAAG,MAAM,CAClE,CAAC,CAAyB;AAE1B,MAAM,iBAAiB,qBAAqB;AAC5C,IAAI,mBAAmB,gBACrB,QAAQ,KAAK,mCAAmC,eAAe,gCAAgC,eAAe,uCAAuC"}
package/package.json CHANGED
@@ -1,10 +1,90 @@
1
1
  {
2
2
  "name": "@auv-js/cli",
3
- "version": "0.0.0-bootstrap.0",
4
- "description": "Bootstrap release for configuring npm trusted publishing",
3
+ "type": "module",
4
+ "version": "0.0.10",
5
+ "description": "NAPI bindings and the platform-matched AUV command-line executable",
5
6
  "license": "Apache-2.0",
6
7
  "repository": {
7
8
  "type": "git",
8
- "url": "git+https://github.com/moeru-ai/auv.git"
9
+ "url": "git+https://github.com/moeru-ai/auv.git",
10
+ "directory": "js/packages/cli"
11
+ },
12
+ "keywords": [
13
+ "auv",
14
+ "automation",
15
+ "cli",
16
+ "electron",
17
+ "napi-rs"
18
+ ],
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js"
23
+ },
24
+ "./binary": {
25
+ "types": "./dist/binary.d.ts",
26
+ "import": "./dist/binary.js"
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "main": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "preferUnplugged": true,
33
+ "bin": {
34
+ "auv": "./bin/auv.js"
35
+ },
36
+ "files": [
37
+ "README.md",
38
+ "bin",
39
+ "binding.d.ts",
40
+ "binding.js",
41
+ "dist"
42
+ ],
43
+ "engines": {
44
+ "node": ">=20.19.0"
45
+ },
46
+ "napi": {
47
+ "binaryName": "auv-binding",
48
+ "packageName": "@auv-js/cli",
49
+ "rootPublisher": "pnpm",
50
+ "targets": [
51
+ "aarch64-apple-darwin",
52
+ "aarch64-unknown-linux-gnu",
53
+ "x86_64-apple-darwin",
54
+ "x86_64-pc-windows-msvc",
55
+ "x86_64-unknown-linux-gnu"
56
+ ]
57
+ },
58
+ "optionalDependencies": {
59
+ "@auv-js/cli-darwin-arm64": "0.0.10",
60
+ "@auv-js/cli-linux-arm64-gnu": "0.0.10",
61
+ "@auv-js/cli-darwin-x64": "0.0.10",
62
+ "@auv-js/cli-win32-x64-msvc": "0.0.10",
63
+ "@auv-js/cli-linux-x64-gnu": "0.0.10"
64
+ },
65
+ "devDependencies": {
66
+ "@emnapi/core": "^1.11.2",
67
+ "@emnapi/runtime": "^1.11.2",
68
+ "@napi-rs/cli": "^3.8.6",
69
+ "emnapi": "^1.11.3",
70
+ "tsdown": "^0.22.3",
71
+ "tsx": "^4.23.12",
72
+ "typescript": "^6.0.3",
73
+ "vitest": "^4.1.9"
74
+ },
75
+ "publishConfig": {
76
+ "access": "public",
77
+ "registry": "https://registry.npmjs.org/"
78
+ },
79
+ "scripts": {
80
+ "artifacts": "napi artifacts && tsx ./scripts/stage-platform-packages.ts ./artifacts",
81
+ "build": "pnpm run build:js && napi build --platform --release --esm --js binding.js --dts binding.d.ts",
82
+ "build:debug": "pnpm run build:js && napi build --platform --esm --js binding.js --dts binding.d.ts",
83
+ "build:js": "tsdown",
84
+ "create:npm-dirs": "napi create-npm-dirs",
85
+ "format:rs": "cargo fmt",
86
+ "lint:rs": "cargo clippy --all-targets --all-features -- -D warnings",
87
+ "test:run": "pnpm run build:debug && vitest run",
88
+ "typecheck": "tsc -p tsconfig.json --noEmit"
9
89
  }
10
- }
90
+ }