@opys/binding 0.0.0 → 0.3.0

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/README.md CHANGED
@@ -1,4 +1,11 @@
1
- # @opys/binding
1
+ # opys-napi
2
2
 
3
- Placeholder. The first real version is published by CI from
4
- https://github.com/harmoniya-net/opys.
3
+ Internal crate — the one napi-rs cdylib of opys, producing the `@opys/binding`
4
+ N-API addon. Every crate with a JS surface is a module here and a namespace
5
+ in the addon. Not consumed by Rust callers; ships via npm.
6
+
7
+ Rust consumers depend on the crate they need, such as
8
+ [`opys-core`](https://crates.io/crates/opys-core). JS/TS consumers depend on
9
+ the `@opys/*` package of the same name.
10
+
11
+ Part of the [opys](https://github.com/harmoniya-net/opys) toolkit.
package/index.d.ts ADDED
@@ -0,0 +1,450 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ export declare namespace authliberty {
7
+ /**
8
+ * Resolve AuthLiberty into `{ artifacts, jvmArgs, release }` — the agent jar
9
+ * and the JVM arguments that load it.
10
+ */
11
+ export function resolveAuthliberty(options: Json): Promise<Json>
12
+ /**
13
+ * Run the `authliberty` plugin: the same resolve, returned as the
14
+ * contribution to merge — `{ name, contribution }`.
15
+ */
16
+ export function buildAuthliberty(options: Json): Promise<Json>
17
+ /**
18
+ * Resolve a version, or `latest`, to `{ version, filename, url, size,
19
+ * sha256?, createdAt }` against the GitLab package registry.
20
+ */
21
+ export function resolveAuthLibertyVersion(version: string, options: Json): Promise<Json>
22
+ }
23
+ export declare namespace bifrost {
24
+ /** Mint a Bifrost token: `{ username, uuid, token }`. */
25
+ export function mintBifrost(options: Json): Json
26
+ /** How long a token lives when no lifetime is given, in seconds. */
27
+ export function defaultBifrostTtl(): number
28
+ }
29
+ export declare namespace bundle {
30
+ /** The id of the blob holding exactly `bytes`: the hex sha256 of them. */
31
+ export function blobId(bytes: Buffer): string
32
+ export interface HashedBlob {
33
+ id: string
34
+ /** A file size, which fits a JS number long before it fits nowhere. */
35
+ size: number
36
+ }
37
+ /** The id and size of the blob a file on disk would be. */
38
+ export function hashBlobFile(path: string): Promise<unknown>
39
+ /**
40
+ * Write `manifest` and the blobs it names to `path` as a bundle, under
41
+ * `head`.
42
+ */
43
+ export function writeBundle(path: string, head: Json, manifest: Json, blobs: Json): Promise<unknown>
44
+ /** The manifest of the bundle at `path`. */
45
+ export function readBundle(path: string): Json
46
+ /**
47
+ * The head of the bundle at `path`: what it says about itself. The manifest
48
+ * is left unread.
49
+ */
50
+ export function readBundleHead(path: string): Json
51
+ /** The bundle format this build reads and writes. */
52
+ export function bundleFormat(): number
53
+ }
54
+ export declare namespace cleanroom {
55
+ /**
56
+ * Resolve Cleanroom into `{ artifacts, vars, classpath, launch, jvmArgs,
57
+ * mainClass, gameArgs }` — the release's published version document, mapped
58
+ * the way a vanilla one is.
59
+ */
60
+ export function resolveCleanroom(options: Json): Promise<Json>
61
+ /**
62
+ * Run the `cleanroom` plugin: the same resolve, returned as the contribution
63
+ * to merge — `{ name, contribution }`.
64
+ */
65
+ export function buildCleanroom(options: Json): Promise<Json>
66
+ /**
67
+ * Resolve a Minecraft version, an alias or a release tag to `{ minecraft,
68
+ * cleanroom, documentUrl }`.
69
+ */
70
+ export function resolveCleanroomVersion(input: string, source: string): Promise<Json>
71
+ /** The canonical document index base URL. */
72
+ export function defaultCleanroomIndex(): string
73
+ }
74
+ export declare namespace core {
75
+ /**
76
+ * Decode a wire manifest (plain JS object) into the domain shape.
77
+ * Returns the domain object as plain JS.
78
+ */
79
+ export function decodeManifest(wire: Json): Json
80
+ /** Encode a domain manifest back to its wire form. */
81
+ export function encodeManifest(domain: Json): Json
82
+ /** Parse a JSON-string manifest and return the domain shape as JS. */
83
+ export function parseManifest(input: string): Json
84
+ export interface OsOptions {
85
+ name: string
86
+ version: string
87
+ arch: string
88
+ }
89
+ /** Resolve `${var}` references in a flat var map. Throws on circular refs. */
90
+ export function resolveVars(vars: Record<string, string>): Record<string, string>
91
+ /** Substitute resolved vars into a template string. */
92
+ export function interpolate(template: string, vars: Record<string, string>): string
93
+ /** Drop artifacts whose rules exclude the given platform / features. */
94
+ export function filterManifest(manifest: Json, platform: OsOptions, features: Array<string>): Json
95
+ /** Resolve a Launch's `args` rule-tagged values for the given platform. */
96
+ export function resolvedArgs(launch: Json, platform: OsOptions, features: Array<string>): Array<string>
97
+ /** Resolve a Launch's `envs` rule-tagged values for the given platform. */
98
+ export function resolvedEnvs(launch: Json, platform: OsOptions, features: Array<string>): Record<string, string>
99
+ /** Evaluate a ruleset against a platform + active features. */
100
+ export function satisfiesRuleset(rules: Json, platform: OsOptions, features: Array<string>): boolean
101
+ /** Compile a glob to its regex source. */
102
+ export function globToRegexSource(glob: string): string
103
+ /** The non-wildcard prefix of a glob, where a cleanup rule starts walking. */
104
+ export function globBase(glob: string): string
105
+ /** Single discriminated error shape (Q10 in design doc). */
106
+ export interface OpysErrorInfo {
107
+ code: string
108
+ message: string
109
+ }
110
+ }
111
+ export declare namespace curseforge {
112
+ /**
113
+ * Resolve file references — ids or `/files/<id>` URLs — to one file each, in
114
+ * the order given: `{ fileId, projectId, filename, size, url, sha1? }[]`.
115
+ */
116
+ export function resolveCurseforgeFiles(token: string, references: Json, apiBase: string): Promise<Json>
117
+ /**
118
+ * Look files up by id. The result is in the API's order and omits any id it
119
+ * does not know.
120
+ */
121
+ export function fetchCurseforgeFiles(token: string, fileIds: Json, apiBase: string): Promise<Json>
122
+ /**
123
+ * Resolve a modpack to `{ manifest, loader, files, overrides }` — everything
124
+ * but the loader itself.
125
+ */
126
+ export function resolveCurseforgeModpack(token: string, reference: Json, apiBase: string): Promise<Json>
127
+ /**
128
+ * Turn resolved files into artifacts, each at the path chosen for it. The
129
+ * paths come from the config author's callback, which only the host can run.
130
+ */
131
+ export function curseforgeFileArtifacts(files: Json, paths: Array<string>): Json
132
+ /** Map a modpack `manifest.json` to the loader it runs on. */
133
+ export function loaderSpecFromManifest(manifest: Json): Json
134
+ /** The id a file reference names — the number, or the one in its URL. */
135
+ export function parseFileRef(reference: Json): number
136
+ /** CurseForge's public API base. */
137
+ export function defaultCurseforgeApi(): string
138
+ }
139
+ export declare namespace dev {
140
+ /**
141
+ * Merge plugin contributions and the author's manifest config into a
142
+ * manifest. Returns `{ manifest, blobs, warnings }` — warnings are returned rather
143
+ * than logged so the engine stays pure and JS keeps its own log channel.
144
+ *
145
+ * A contribution's `launch` groups are ignored here even when present: the
146
+ * caller resolves them through the author's accessors before calling in, and
147
+ * hands the result over as `args` / `command`.
148
+ */
149
+ export function assemble(outputs: Json, config: Json): Json
150
+ /**
151
+ * Every regular file under `directory`, in path order:
152
+ * `{ rel, dir, filename, abs, size }[]`.
153
+ */
154
+ export function scanDirectory(directory: string): Promise<unknown>
155
+ /**
156
+ * Hash the placed files — `{ abs, path, url? }[]` — and return the
157
+ * contribution: a blob artifact for each file with no `url`, a pinned URL
158
+ * artifact for each with one.
159
+ *
160
+ * Placing is the caller's because it is the config author's: `path` and
161
+ * `url` may be functions, and a function does not cross into here.
162
+ */
163
+ export function scannedFiles(files: Json, hash?: string | undefined | null): Promise<unknown>
164
+ }
165
+ export declare namespace dgpuj {
166
+ /**
167
+ * Resolve dgpuj into `{ artifacts, vars, release }` — one archive per
168
+ * target, the vars that find the binary, and the release they came from.
169
+ */
170
+ export function resolveDgpuj(options: Json): Promise<Json>
171
+ /** Run the `dgpuj` plugin: `{ output: { name, contribution }, release }`. */
172
+ export function buildDgpuj(options: Json): Promise<Json>
173
+ /** dgpuj's published targets. */
174
+ export function defaultDgpujPlatforms(): Json
175
+ /** Where dgpuj's releases are published. */
176
+ export function defaultDgpujRepo(): string
177
+ }
178
+ export declare namespace fabric {
179
+ /**
180
+ * Resolve Fabric into `{ artifacts, vars, classpath, launch, jvmArgs,
181
+ * mainClass, gameArgs }` — the loader's libraries folded onto the vanilla
182
+ * version its launcher profile inherits from.
183
+ */
184
+ export function resolveFabric(options: Json): Promise<Json>
185
+ /**
186
+ * Run the `fabric` plugin: the same resolve, returned as the contribution to
187
+ * merge — `{ name, contribution }`.
188
+ */
189
+ export function buildFabric(options: Json): Promise<Json>
190
+ /**
191
+ * Resolve a game version (and optional loader) to `{ gameVersion,
192
+ * loaderVersion, profileUrl }`. A pinned loader needs no request.
193
+ */
194
+ export function resolveFabricVersion(game: string, meta: string, loader?: string | undefined | null): Promise<Json>
195
+ /** The canonical Fabric Meta base URL. */
196
+ export function defaultFabricMeta(): string
197
+ }
198
+ export declare namespace forge {
199
+ /**
200
+ * Resolve Forge into `{ artifacts, vars, classpath, launch, jvmArgs,
201
+ * mainClass, gameArgs }` — the build's published version document folded onto
202
+ * the vanilla version it inherits from.
203
+ */
204
+ export function resolveForge(options: Json): Promise<Json>
205
+ /**
206
+ * Run the `forge` plugin: the same resolve, returned as the contribution to
207
+ * merge — `{ name, contribution }`.
208
+ */
209
+ export function buildForge(options: Json): Promise<Json>
210
+ /**
211
+ * Resolve a Minecraft version, an alias or a full build id to `{ minecraft,
212
+ * forge, documentUrl }`.
213
+ */
214
+ export function resolveForgeVersion(input: string, source: string): Promise<Json>
215
+ /** The canonical document index base URL. */
216
+ export function defaultForgeIndex(): string
217
+ }
218
+ export declare namespace java {
219
+ /** The (OS, arch) pairs every vendor resolver targets by default. */
220
+ export function defaultPlatforms(): Json
221
+ /**
222
+ * Resolve a JDK and build the manifest fragment that installs it —
223
+ * `{ artifacts, vars, release }`.
224
+ */
225
+ export function resolveJava(options: Json): Promise<Json>
226
+ /**
227
+ * Run the `java` plugin: the same resolve, returned as the contribution to
228
+ * merge — `{ output, release }`.
229
+ */
230
+ export function buildJava(options: Json): Promise<Json>
231
+ /** Resolve an Eclipse Temurin release across the requested platforms. */
232
+ export function resolveTemurin(version: string, opts?: Json | undefined | null): Promise<Json>
233
+ /** Resolve an Azul Zulu release across the requested platforms. */
234
+ export function resolveZulu(version: string, opts?: Json | undefined | null): Promise<Json>
235
+ /** Resolve a GraalVM CE release across the requested platforms. */
236
+ export function resolveGraalvm(version: string, opts?: Json | undefined | null): Promise<Json>
237
+ }
238
+ export declare namespace links {
239
+ /**
240
+ * Resolve links to pinned files, in the order given —
241
+ * `{ link, provider, filename, url, size, integrity? }[]`.
242
+ */
243
+ export function resolveLinks(links: Array<string>, options: Json): Promise<Json>
244
+ /**
245
+ * Turn resolved files into artifacts, each at the path chosen for it. The
246
+ * paths come from the config author's callback, which only the host can run.
247
+ */
248
+ export function linkFileArtifacts(files: Json, paths: Array<string>): Json
249
+ }
250
+ export declare namespace lwjgl3ify {
251
+ /**
252
+ * Resolve lwjgl3ify into `{ artifacts, vars, classpath, launch, jvmArgs,
253
+ * mainClass, gameArgs }` — the release's published version document, mapped
254
+ * the way a vanilla one is, with the jars for `mods/` added to `artifacts`.
255
+ */
256
+ export function resolveLwjgl3ify(options: Json): Promise<Json>
257
+ /**
258
+ * Run the `lwjgl3ify` plugin: the same resolve, returned as the contribution
259
+ * to merge — `{ name, contribution }`.
260
+ */
261
+ export function buildLwjgl3ify(options: Json): Promise<Json>
262
+ /**
263
+ * Resolve a Minecraft version, an alias or a release tag to `{ minecraft,
264
+ * lwjgl3ify, documentUrl }`.
265
+ */
266
+ export function resolveLwjgl3ifyVersion(input: string, source: string): Promise<Json>
267
+ /** The canonical document index base URL. */
268
+ export function defaultLwjgl3ifyIndex(): string
269
+ }
270
+ export declare namespace minecraftServerlist {
271
+ /**
272
+ * Run the `serverlist` plugin: `{ name, contribution }`, the contribution
273
+ * holding one generated `servers.dat` per distinct ruleset and its blob.
274
+ */
275
+ export function buildServerlist(servers: Json, options: Json): Json
276
+ /** Where the list goes unless a config says otherwise. */
277
+ export function defaultServerlistPath(): string
278
+ }
279
+ export declare namespace minecraftVanilla {
280
+ /**
281
+ * Resolve vanilla Minecraft into `{ artifacts, vars, classpath, launch,
282
+ * jvmArgs, mainClass, gameArgs }`.
283
+ */
284
+ export function resolveMinecraft(opts?: Json | undefined | null): Promise<Json>
285
+ /**
286
+ * Run the `minecraft` plugin: the same resolve, returned as the contribution
287
+ * to merge — `{ name, contribution }`.
288
+ */
289
+ export function buildMinecraft(opts?: Json | undefined | null): Promise<Json>
290
+ /** Look a version up in the version manifest and fetch its version JSON. */
291
+ export function fetchClient(opts?: Json | undefined | null): Promise<Json>
292
+ /** Map an already-resolved version JSON, fetching only its asset manifest. */
293
+ export function clientToTemplate(client: Json): Promise<Json>
294
+ /** Fetch `version_manifest_v2.json`, or another URL serving that document. */
295
+ export function fetchVersionManifest(url?: string | undefined | null): Promise<Json>
296
+ /** Fetch and parse an asset manifest. */
297
+ export function fetchAssetManifest(url: string): Promise<Json>
298
+ /**
299
+ * Turn a version JSON and its asset manifest into a template. The pure half
300
+ * of `clientToTemplate`, for a caller that already holds both.
301
+ */
302
+ export function mapClientToTemplate(client: Json, assets: Json): Json
303
+ export function mapClientJar(client: Json): Json
304
+ export function libraryToArtifact(library: Json): Json
305
+ export function mapLibraries(libraries: Json): Json
306
+ export function mapAssetIndex(index: Json): Json
307
+ export function mapAssetObjects(manifest: Json, indexId: string): Json
308
+ /** The `${classpath}` arms — one per OS, each led by the client jar. */
309
+ export function buildClasspath(libs: Json, clientJarPath: string): Json
310
+ /**
311
+ * `{ launch, jvmArgs, mainClass, gameArgs }` from a main class and the two
312
+ * argument lists.
313
+ */
314
+ export function buildLaunch(mainClass: string, gameArgs: Json, jvmArgs: Json): Json
315
+ }
316
+ export declare namespace modrinth {
317
+ /**
318
+ * Resolve version references to one file each, in the order given —
319
+ * `{ filename, versionId, projectId, versionNumber, size, url, sha1? }[]`.
320
+ */
321
+ export function resolveModrinthFiles(references: Array<string>, apiBase: string): Promise<Json>
322
+ /**
323
+ * Resolve a modpack to `{ index, dependencies, loader, files, overrides }` —
324
+ * everything but the loader itself.
325
+ */
326
+ export function resolveModrinthModpack(reference: string, apiBase: string): Promise<Json>
327
+ /**
328
+ * Turn resolved files into artifacts, each at the path chosen for it. The
329
+ * paths come from the config author's callback, which only the host can run.
330
+ */
331
+ export function modrinthFileArtifacts(files: Json, paths: Array<string>): Json
332
+ /** Map a `.mrpack`'s `dependencies` to the loader it runs on. */
333
+ export function loaderSpec(dependencies: Json): Json
334
+ /** Modrinth's public API base. */
335
+ export function defaultModrinthApi(): string
336
+ }
337
+ export declare namespace mojang {
338
+ export interface OsOptions {
339
+ name: string
340
+ version: string
341
+ arch: string
342
+ }
343
+ /** Parse a version-JSON client document into the domain shape. */
344
+ export function parseClient(raw: Json): Json
345
+ /** Parse the `libraries` array of a version JSON. */
346
+ export function parseLibraries(raws: Json): Json
347
+ /** Parse `arguments` (modern object) or `minecraftArguments` (legacy string). */
348
+ export function parseArguments(raw: Json): Json
349
+ /** Merge a patch version's args onto a base version's (`inheritsFrom`). */
350
+ export function mergeArgs(base: Json, patch: Json): Json
351
+ /** Parse an asset manifest (`objects` map). */
352
+ export function parseAssetManifest(raw: Json): Json
353
+ /** Parse `version_manifest_v2.json`. */
354
+ export function parseVersionManifest(raw: Json): Json
355
+ /** Look up a version by id. Returns `null` when absent. */
356
+ export function findVersion(manifest: Json, id: string): Json
357
+ /** The manifest's current release version. Throws when it is missing. */
358
+ export function latestRelease(manifest: Json): Json
359
+ /** The canonical version-manifest URL. */
360
+ export function versionManifestUrl(): string
361
+ export function assetUrl(hash: string): string
362
+ export function assetPath(hash: string): string
363
+ export function parseMaven(value: string): Json
364
+ export function encodeMaven(coord: Json): string
365
+ export function isNativeMaven(coord: Json): boolean
366
+ export function mavenMatchesIgnoringVersion(a: Json, b: Json): boolean
367
+ /**
368
+ * Decode a ruleset in strict Mojang form. A shorthand string such as
369
+ * `"allow.os.linux"` is an error here — that spelling is opys's own, and
370
+ * belongs to `@opys/core`.
371
+ */
372
+ export function decodeRuleset(raw: Json): Json
373
+ export function encodeRuleset(ruleset: Json): Json
374
+ /** Evaluate a strict Mojang ruleset against a platform + active features. */
375
+ export function satisfiesRuleset(rules: Json, platform: OsOptions, features: Array<string>): boolean
376
+ export function satisfiesRule(rule: Json, platform: OsOptions, features: Array<string>): boolean
377
+ export function satisfiesOs(constraint: Json, platform: OsOptions): boolean
378
+ export function satisfiesFeatures(constraint: Json, features: Array<string>): boolean
379
+ }
380
+ export declare namespace neoforge {
381
+ /**
382
+ * Resolve NeoForge into `{ artifacts, vars, classpath, launch, jvmArgs,
383
+ * mainClass, gameArgs }` — the build's published version document folded onto
384
+ * the vanilla version it inherits from.
385
+ */
386
+ export function resolveNeoForge(options: Json): Promise<Json>
387
+ /**
388
+ * Run the `neoforge` plugin: the same resolve, returned as the contribution
389
+ * to merge — `{ name, contribution }`.
390
+ */
391
+ export function buildNeoForge(options: Json): Promise<Json>
392
+ /**
393
+ * Resolve a Minecraft version, an alias or a full build id to `{ minecraft,
394
+ * neoforge, documentUrl }`.
395
+ */
396
+ export function resolveNeoForgeVersion(input: string, source: string): Promise<Json>
397
+ /** The canonical document index base URL. */
398
+ export function defaultNeoForgeIndex(): string
399
+ }
400
+ export declare namespace runtime {
401
+ export interface OsOptions {
402
+ name: string
403
+ version: string
404
+ arch: string
405
+ }
406
+ export interface InstallOptionsJs {
407
+ platform?: OsOptions
408
+ vars?: Record<string, string>
409
+ concurrency?: number
410
+ verifyIntegrity?: boolean
411
+ features?: Array<string>
412
+ }
413
+ export interface ProgressEvent {
414
+ phase: string
415
+ fetched?: number
416
+ total?: number
417
+ skipped?: number
418
+ count?: number
419
+ removed?: number
420
+ directories?: number
421
+ path?: string
422
+ bytes?: number
423
+ totalBytes?: number
424
+ }
425
+ /**
426
+ * Install from `source`: `{ manifest }`, `{ bundle }` or `{ url }`.
427
+ * The source decodes itself — see `opys_runtime::ManifestSource`.
428
+ */
429
+ export function install(source: Json, options?: InstallOptionsJs | undefined | null, progress?: (...args: any[]) => any | undefined | null): Promise<unknown>
430
+ export interface LaunchSpec {
431
+ command: string
432
+ args: Array<string>
433
+ workdir: string
434
+ envs: Record<string, string>
435
+ }
436
+ export interface BuildLaunchOptions {
437
+ platform?: OsOptions
438
+ features?: Array<string>
439
+ vars?: Record<string, string>
440
+ cwd?: string
441
+ }
442
+ /** Pure spawn-spec — no install, no spawn. Q5 in design doc. */
443
+ export function buildLaunch(source: Json, options?: BuildLaunchOptions | undefined | null): Promise<LaunchSpec>
444
+ /**
445
+ * Install, then say what to spawn — from one reading of the source, so a
446
+ * bundle is opened, or downloaded, once for both.
447
+ */
448
+ export function prepare(source: Json, launch?: BuildLaunchOptions | undefined | null, install?: InstallOptionsJs | undefined | null, progress?: (...args: any[]) => any | undefined | null): Promise<unknown>
449
+ export function currentPlatform(): OsOptions
450
+ }
Binary file
Binary file
package/index.js ADDED
@@ -0,0 +1,333 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /* prettier-ignore */
4
+
5
+ /* auto-generated by NAPI-RS */
6
+
7
+ const { existsSync, readFileSync } = require('fs')
8
+ const { join } = require('path')
9
+
10
+ const { platform, arch } = process
11
+
12
+ let nativeBinding = null
13
+ let localFileExisted = false
14
+ let loadError = null
15
+
16
+ function isMusl() {
17
+ // For Node 10
18
+ if (!process.report || typeof process.report.getReport !== 'function') {
19
+ try {
20
+ const lddPath = require('child_process').execSync('which ldd').toString().trim()
21
+ return readFileSync(lddPath, 'utf8').includes('musl')
22
+ } catch (e) {
23
+ return true
24
+ }
25
+ } else {
26
+ const { glibcVersionRuntime } = process.report.getReport().header
27
+ return !glibcVersionRuntime
28
+ }
29
+ }
30
+
31
+ switch (platform) {
32
+ case 'android':
33
+ switch (arch) {
34
+ case 'arm64':
35
+ localFileExisted = existsSync(join(__dirname, 'index.android-arm64.node'))
36
+ try {
37
+ if (localFileExisted) {
38
+ nativeBinding = require('./index.android-arm64.node')
39
+ } else {
40
+ nativeBinding = require('@opys/binding-android-arm64')
41
+ }
42
+ } catch (e) {
43
+ loadError = e
44
+ }
45
+ break
46
+ case 'arm':
47
+ localFileExisted = existsSync(join(__dirname, 'index.android-arm-eabi.node'))
48
+ try {
49
+ if (localFileExisted) {
50
+ nativeBinding = require('./index.android-arm-eabi.node')
51
+ } else {
52
+ nativeBinding = require('@opys/binding-android-arm-eabi')
53
+ }
54
+ } catch (e) {
55
+ loadError = e
56
+ }
57
+ break
58
+ default:
59
+ throw new Error(`Unsupported architecture on Android ${arch}`)
60
+ }
61
+ break
62
+ case 'win32':
63
+ switch (arch) {
64
+ case 'x64':
65
+ localFileExisted = existsSync(
66
+ join(__dirname, 'index.win32-x64-msvc.node')
67
+ )
68
+ try {
69
+ if (localFileExisted) {
70
+ nativeBinding = require('./index.win32-x64-msvc.node')
71
+ } else {
72
+ nativeBinding = require('@opys/binding-win32-x64-msvc')
73
+ }
74
+ } catch (e) {
75
+ loadError = e
76
+ }
77
+ break
78
+ case 'ia32':
79
+ localFileExisted = existsSync(
80
+ join(__dirname, 'index.win32-ia32-msvc.node')
81
+ )
82
+ try {
83
+ if (localFileExisted) {
84
+ nativeBinding = require('./index.win32-ia32-msvc.node')
85
+ } else {
86
+ nativeBinding = require('@opys/binding-win32-ia32-msvc')
87
+ }
88
+ } catch (e) {
89
+ loadError = e
90
+ }
91
+ break
92
+ case 'arm64':
93
+ localFileExisted = existsSync(
94
+ join(__dirname, 'index.win32-arm64-msvc.node')
95
+ )
96
+ try {
97
+ if (localFileExisted) {
98
+ nativeBinding = require('./index.win32-arm64-msvc.node')
99
+ } else {
100
+ nativeBinding = require('@opys/binding-win32-arm64-msvc')
101
+ }
102
+ } catch (e) {
103
+ loadError = e
104
+ }
105
+ break
106
+ default:
107
+ throw new Error(`Unsupported architecture on Windows: ${arch}`)
108
+ }
109
+ break
110
+ case 'darwin':
111
+ localFileExisted = existsSync(join(__dirname, 'index.darwin-universal.node'))
112
+ try {
113
+ if (localFileExisted) {
114
+ nativeBinding = require('./index.darwin-universal.node')
115
+ } else {
116
+ nativeBinding = require('@opys/binding-darwin-universal')
117
+ }
118
+ break
119
+ } catch {}
120
+ switch (arch) {
121
+ case 'x64':
122
+ localFileExisted = existsSync(join(__dirname, 'index.darwin-x64.node'))
123
+ try {
124
+ if (localFileExisted) {
125
+ nativeBinding = require('./index.darwin-x64.node')
126
+ } else {
127
+ nativeBinding = require('@opys/binding-darwin-x64')
128
+ }
129
+ } catch (e) {
130
+ loadError = e
131
+ }
132
+ break
133
+ case 'arm64':
134
+ localFileExisted = existsSync(
135
+ join(__dirname, 'index.darwin-arm64.node')
136
+ )
137
+ try {
138
+ if (localFileExisted) {
139
+ nativeBinding = require('./index.darwin-arm64.node')
140
+ } else {
141
+ nativeBinding = require('@opys/binding-darwin-arm64')
142
+ }
143
+ } catch (e) {
144
+ loadError = e
145
+ }
146
+ break
147
+ default:
148
+ throw new Error(`Unsupported architecture on macOS: ${arch}`)
149
+ }
150
+ break
151
+ case 'freebsd':
152
+ if (arch !== 'x64') {
153
+ throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
154
+ }
155
+ localFileExisted = existsSync(join(__dirname, 'index.freebsd-x64.node'))
156
+ try {
157
+ if (localFileExisted) {
158
+ nativeBinding = require('./index.freebsd-x64.node')
159
+ } else {
160
+ nativeBinding = require('@opys/binding-freebsd-x64')
161
+ }
162
+ } catch (e) {
163
+ loadError = e
164
+ }
165
+ break
166
+ case 'linux':
167
+ switch (arch) {
168
+ case 'x64':
169
+ if (isMusl()) {
170
+ localFileExisted = existsSync(
171
+ join(__dirname, 'index.linux-x64-musl.node')
172
+ )
173
+ try {
174
+ if (localFileExisted) {
175
+ nativeBinding = require('./index.linux-x64-musl.node')
176
+ } else {
177
+ nativeBinding = require('@opys/binding-linux-x64-musl')
178
+ }
179
+ } catch (e) {
180
+ loadError = e
181
+ }
182
+ } else {
183
+ localFileExisted = existsSync(
184
+ join(__dirname, 'index.linux-x64-gnu.node')
185
+ )
186
+ try {
187
+ if (localFileExisted) {
188
+ nativeBinding = require('./index.linux-x64-gnu.node')
189
+ } else {
190
+ nativeBinding = require('@opys/binding-linux-x64-gnu')
191
+ }
192
+ } catch (e) {
193
+ loadError = e
194
+ }
195
+ }
196
+ break
197
+ case 'arm64':
198
+ if (isMusl()) {
199
+ localFileExisted = existsSync(
200
+ join(__dirname, 'index.linux-arm64-musl.node')
201
+ )
202
+ try {
203
+ if (localFileExisted) {
204
+ nativeBinding = require('./index.linux-arm64-musl.node')
205
+ } else {
206
+ nativeBinding = require('@opys/binding-linux-arm64-musl')
207
+ }
208
+ } catch (e) {
209
+ loadError = e
210
+ }
211
+ } else {
212
+ localFileExisted = existsSync(
213
+ join(__dirname, 'index.linux-arm64-gnu.node')
214
+ )
215
+ try {
216
+ if (localFileExisted) {
217
+ nativeBinding = require('./index.linux-arm64-gnu.node')
218
+ } else {
219
+ nativeBinding = require('@opys/binding-linux-arm64-gnu')
220
+ }
221
+ } catch (e) {
222
+ loadError = e
223
+ }
224
+ }
225
+ break
226
+ case 'arm':
227
+ if (isMusl()) {
228
+ localFileExisted = existsSync(
229
+ join(__dirname, 'index.linux-arm-musleabihf.node')
230
+ )
231
+ try {
232
+ if (localFileExisted) {
233
+ nativeBinding = require('./index.linux-arm-musleabihf.node')
234
+ } else {
235
+ nativeBinding = require('@opys/binding-linux-arm-musleabihf')
236
+ }
237
+ } catch (e) {
238
+ loadError = e
239
+ }
240
+ } else {
241
+ localFileExisted = existsSync(
242
+ join(__dirname, 'index.linux-arm-gnueabihf.node')
243
+ )
244
+ try {
245
+ if (localFileExisted) {
246
+ nativeBinding = require('./index.linux-arm-gnueabihf.node')
247
+ } else {
248
+ nativeBinding = require('@opys/binding-linux-arm-gnueabihf')
249
+ }
250
+ } catch (e) {
251
+ loadError = e
252
+ }
253
+ }
254
+ break
255
+ case 'riscv64':
256
+ if (isMusl()) {
257
+ localFileExisted = existsSync(
258
+ join(__dirname, 'index.linux-riscv64-musl.node')
259
+ )
260
+ try {
261
+ if (localFileExisted) {
262
+ nativeBinding = require('./index.linux-riscv64-musl.node')
263
+ } else {
264
+ nativeBinding = require('@opys/binding-linux-riscv64-musl')
265
+ }
266
+ } catch (e) {
267
+ loadError = e
268
+ }
269
+ } else {
270
+ localFileExisted = existsSync(
271
+ join(__dirname, 'index.linux-riscv64-gnu.node')
272
+ )
273
+ try {
274
+ if (localFileExisted) {
275
+ nativeBinding = require('./index.linux-riscv64-gnu.node')
276
+ } else {
277
+ nativeBinding = require('@opys/binding-linux-riscv64-gnu')
278
+ }
279
+ } catch (e) {
280
+ loadError = e
281
+ }
282
+ }
283
+ break
284
+ case 's390x':
285
+ localFileExisted = existsSync(
286
+ join(__dirname, 'index.linux-s390x-gnu.node')
287
+ )
288
+ try {
289
+ if (localFileExisted) {
290
+ nativeBinding = require('./index.linux-s390x-gnu.node')
291
+ } else {
292
+ nativeBinding = require('@opys/binding-linux-s390x-gnu')
293
+ }
294
+ } catch (e) {
295
+ loadError = e
296
+ }
297
+ break
298
+ default:
299
+ throw new Error(`Unsupported architecture on Linux: ${arch}`)
300
+ }
301
+ break
302
+ default:
303
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
304
+ }
305
+
306
+ if (!nativeBinding) {
307
+ if (loadError) {
308
+ throw loadError
309
+ }
310
+ throw new Error(`Failed to load native binding`)
311
+ }
312
+
313
+ const { authliberty, bifrost, bundle, cleanroom, core, curseforge, dev, dgpuj, fabric, forge, java, links, lwjgl3ify, minecraftServerlist, minecraftVanilla, modrinth, mojang, neoforge, runtime } = nativeBinding
314
+
315
+ module.exports.authliberty = authliberty
316
+ module.exports.bifrost = bifrost
317
+ module.exports.bundle = bundle
318
+ module.exports.cleanroom = cleanroom
319
+ module.exports.core = core
320
+ module.exports.curseforge = curseforge
321
+ module.exports.dev = dev
322
+ module.exports.dgpuj = dgpuj
323
+ module.exports.fabric = fabric
324
+ module.exports.forge = forge
325
+ module.exports.java = java
326
+ module.exports.links = links
327
+ module.exports.lwjgl3ify = lwjgl3ify
328
+ module.exports.minecraftServerlist = minecraftServerlist
329
+ module.exports.minecraftVanilla = minecraftVanilla
330
+ module.exports.modrinth = modrinth
331
+ module.exports.mojang = mojang
332
+ module.exports.neoforge = neoforge
333
+ module.exports.runtime = runtime
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,7 +1,33 @@
1
1
  {
2
2
  "name": "@opys/binding",
3
- "version": "0.0.0",
4
- "description": "Placeholder. The first real version is published by CI.",
3
+ "version": "0.3.0",
4
+ "description": "The napi-rs addon of opys: every native function, one namespace per package. Not consumed directly.",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "napi": {
8
+ "binaryName": "opys",
9
+ "triples": {
10
+ "defaults": true,
11
+ "additional": [
12
+ "aarch64-apple-darwin",
13
+ "aarch64-unknown-linux-gnu",
14
+ "x86_64-unknown-linux-musl",
15
+ "aarch64-unknown-linux-musl"
16
+ ]
17
+ }
18
+ },
19
+ "files": [
20
+ "index.js",
21
+ "index.d.ts",
22
+ "*.node"
23
+ ],
24
+ "scripts": {
25
+ "build": "napi build --platform --release",
26
+ "build:debug": "napi build --platform"
27
+ },
28
+ "engines": {
29
+ "node": ">=20"
30
+ },
5
31
  "repository": {
6
32
  "type": "git",
7
33
  "url": "git+https://github.com/harmoniya-net/opys.git",
@@ -9,5 +35,14 @@
9
35
  },
10
36
  "publishConfig": {
11
37
  "access": "public"
38
+ },
39
+ "optionalDependencies": {
40
+ "@opys/binding-darwin-arm64": "0.3.0",
41
+ "@opys/binding-darwin-x64": "0.3.0",
42
+ "@opys/binding-linux-arm64-gnu": "0.3.0",
43
+ "@opys/binding-linux-arm64-musl": "0.3.0",
44
+ "@opys/binding-linux-x64-gnu": "0.3.0",
45
+ "@opys/binding-linux-x64-musl": "0.3.0",
46
+ "@opys/binding-win32-x64-msvc": "0.3.0"
12
47
  }
13
48
  }