@shieldbattery/danimoth 0.0.0-stage → 0.1.1
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/.editorconfig +15 -0
- package/.gitattributes +25 -0
- package/.prettierignore +1 -0
- package/.prettierrc +10 -0
- package/AGENTS.md +25 -0
- package/LICENSE +21 -0
- package/README.md +102 -2
- package/index.d.ts +229 -0
- package/index.js +1 -0
- package/native/Cargo.lock +180 -0
- package/native/Cargo.toml +16 -0
- package/native/src/lib.rs +673 -0
- package/native/src/names.rs +103 -0
- package/native/src/sys.rs +364 -0
- package/package.json +35 -4
- package/prebuilds/x64.node +0 -0
- package/tag-prebuild.js +16 -0
package/.editorconfig
ADDED
package/.gitattributes
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Force unix style line endings for everything
|
|
2
|
+
* text eol=lf
|
|
3
|
+
|
|
4
|
+
*.ico binary
|
|
5
|
+
*.png binary
|
|
6
|
+
*.jpg binary
|
|
7
|
+
*.ai binary
|
|
8
|
+
*.scm binary
|
|
9
|
+
*.scx binary
|
|
10
|
+
*.msi binary
|
|
11
|
+
*.exe binary
|
|
12
|
+
*.diff binary
|
|
13
|
+
*.dll binary
|
|
14
|
+
*.opus binary
|
|
15
|
+
*.mp4 binary
|
|
16
|
+
*.afdesign binary
|
|
17
|
+
|
|
18
|
+
# Custom for Visual Studio
|
|
19
|
+
*.sln merge=union
|
|
20
|
+
*.csproj merge=union
|
|
21
|
+
*.vbproj merge=union
|
|
22
|
+
*.fsproj merge=union
|
|
23
|
+
*.dbproj merge=union
|
|
24
|
+
|
|
25
|
+
*.bat eol=crlf
|
package/.prettierignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pnpm-lock.yaml
|
package/.prettierrc
ADDED
package/AGENTS.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
Guidance for AI agents working in this repository.
|
|
4
|
+
|
|
5
|
+
- This is a Neon (Rust) Node.js native module, consumed by the ShieldBattery Electron app's main
|
|
6
|
+
process. The Rust crate lives in `native/`; `index.js` loads the built `prebuilds/x64.node`.
|
|
7
|
+
- Never commit or publish the Discord Social SDK (`discord_partner_sdk.dll`, `discordpp.h`, or any
|
|
8
|
+
other file from the SDK download). Keep a local copy under `sdk/`, which is gitignored and
|
|
9
|
+
excluded from the package.
|
|
10
|
+
- Never commit secrets: OAuth client secrets, access or refresh tokens, `.env` files. The repo is
|
|
11
|
+
public. Tests never need a token, and tokens for manual testing stay outside the checkout.
|
|
12
|
+
- Keep the module free of any one application's details. Application IDs, launch commands and
|
|
13
|
+
scheme names are passed in by the app using it, never hardcoded here.
|
|
14
|
+
- The SDK's C API is declared by hand in `native/src/sys.rs` and the DLL is loaded at runtime, so the
|
|
15
|
+
module builds without the SDK. Every declaration must match `cdiscord.h` from the local SDK copy
|
|
16
|
+
exactly; when moving to a new SDK version, check each one against the new header.
|
|
17
|
+
- SDK callbacks reach JS through a Neon `Channel`, never by calling JS directly, so it doesn't
|
|
18
|
+
matter which thread the SDK calls them on. A callback that hands over a `Discord_ClientResult*`
|
|
19
|
+
or a `Discord_String` gives ownership to the callee: drop the result and `Discord_Free` the
|
|
20
|
+
string (see `discordpp.h`, which shows the ownership rules for every function).
|
|
21
|
+
- Keep `version` in `native/Cargo.toml` equal to `version` in `package.json`.
|
|
22
|
+
- Run `pnpm test`, `pnpm run format:check`, `cargo fmt --all -- --check` and
|
|
23
|
+
`cargo clippy --all-targets -- -D warnings` (the last two in `native/`) before committing; CI runs
|
|
24
|
+
the same checks.
|
|
25
|
+
- Every export needs a matching declaration in `index.d.ts`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ShieldBattery
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,103 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @shieldbattery/danimoth
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Rust-based Node.js native module wrapping the Discord Social SDK.
|
|
4
|
+
|
|
5
|
+
## The Discord Social SDK is not included
|
|
6
|
+
|
|
7
|
+
Neither this repo nor the published package contains the Discord Social SDK
|
|
8
|
+
(`discord_partner_sdk.dll`, its headers, or anything else from the download). It comes from the
|
|
9
|
+
Downloads page of the Discord Developer Portal once the Social SDK is enabled for the application.
|
|
10
|
+
Keep a local copy under `sdk/`, which is gitignored and excluded from the package, by extracting
|
|
11
|
+
the download's `discord_social_sdk` folder there (so the DLL ends up at
|
|
12
|
+
`sdk/discord_social_sdk/bin/release/discord_partner_sdk.dll`).
|
|
13
|
+
|
|
14
|
+
The module builds without the SDK: it loads the DLL at runtime from a path the app passes to
|
|
15
|
+
`loadSdk`, so the app decides where the DLL lives and how it gets there. The C API declarations in
|
|
16
|
+
`native/src/sys.rs` are written by hand against SDK 1.10.
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const discord = require('@shieldbattery/danimoth')
|
|
22
|
+
|
|
23
|
+
discord.loadSdk('C:\\path\\to\\discord_partner_sdk.dll')
|
|
24
|
+
// Client callbacks and promise completions only happen while runCallbacks runs.
|
|
25
|
+
setInterval(() => discord.runCallbacks(), 100)
|
|
26
|
+
|
|
27
|
+
const client = discord.createClient({
|
|
28
|
+
onLog: (message, severity) => console.log(`[discord:${severity}] ${message}`),
|
|
29
|
+
onStatusChanged: status => {
|
|
30
|
+
if (status === 'ready') {
|
|
31
|
+
discord.updateRichPresence(client, {
|
|
32
|
+
details: 'Ranked 1v1',
|
|
33
|
+
state: 'Terran vs Zerg',
|
|
34
|
+
timestamps: { start: Date.now() },
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
onTokenExpiring: () => {
|
|
39
|
+
// Get a new access token and pass it to updateToken.
|
|
40
|
+
},
|
|
41
|
+
onActivityJoin: joinSecret => {
|
|
42
|
+
// Join whatever the secret identifies.
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
await discord.updateToken(client, accessToken)
|
|
46
|
+
discord.connect(client)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
See `index.d.ts` for the whole API.
|
|
50
|
+
|
|
51
|
+
## OS support
|
|
52
|
+
|
|
53
|
+
Currently we only build for x64 Windows.
|
|
54
|
+
|
|
55
|
+
## Local development
|
|
56
|
+
|
|
57
|
+
Build the module and copy it to where `index.js` loads it from:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
pnpm install
|
|
61
|
+
pnpm run build-debug
|
|
62
|
+
pnpm run tag-prebuild
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
To consume your local copy from the ShieldBattery app, point the dependency in
|
|
66
|
+
`ShieldBattery/app/package.json` at this directory with pnpm's `link:` protocol, then install. The
|
|
67
|
+
path is relative to the `app` directory; with the two checkouts side by side it is:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
"@shieldbattery/danimoth": "link:../../danimoth"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
cd path/to/ShieldBattery/app
|
|
75
|
+
pnpm install
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
After rebuilding here, run `build-debug` and `tag-prebuild` again, then rebuild the app. It picks up
|
|
79
|
+
the new `prebuilds/x64.node` through the link without reinstalling.
|
|
80
|
+
|
|
81
|
+
## Tests
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
pnpm test
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This runs the Rust tests, builds the module, and runs the Node tests in `test/` against the build.
|
|
88
|
+
The tests in `test/sdk.test.js` load the real SDK from the local copy under `sdk/` (or from the path
|
|
89
|
+
in `DANIMOTH_SDK_DLL`) and are skipped when it isn't there, as in CI. They don't connect to Discord.
|
|
90
|
+
|
|
91
|
+
## Releasing
|
|
92
|
+
|
|
93
|
+
Run the "Release package" workflow from the Actions tab with the new version number. It sets the
|
|
94
|
+
version in `package.json` and `native/Cargo.toml` (kept equal; the tests fail if they differ), runs
|
|
95
|
+
the tests, builds the release binary, publishes to npm, and pushes a "Version X" commit and a tag
|
|
96
|
+
with the bare version (`1.0.0`, not `v1.0.0`), matching the other ShieldBattery native modules.
|
|
97
|
+
|
|
98
|
+
The workflow publishes as an npm trusted publisher through GitHub's OIDC token, so no npm token is
|
|
99
|
+
stored in the repo or its secrets. The binary isn't code signed yet.
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
MIT
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// This implementation is based on type-fest's Opaque, just want to avoid needing the dep
|
|
2
|
+
declare const tag: unique symbol
|
|
3
|
+
declare type Tagged<Token> = {
|
|
4
|
+
readonly [tag]: Token
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/** A Discord Social SDK client created by `createClient`. */
|
|
8
|
+
export type DiscordClient = Tagged<'DiscordClient'>
|
|
9
|
+
|
|
10
|
+
/** Returns the version of this module, so a caller can tell which build of it was loaded. */
|
|
11
|
+
export function version(): string
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Loads the Discord Social SDK from the `discord_partner_sdk.dll` at `dllPath`. Every other
|
|
15
|
+
* function except `version` throws until this succeeds. Once the SDK is loaded, later calls do
|
|
16
|
+
* nothing; it stays loaded until the process exits.
|
|
17
|
+
*
|
|
18
|
+
* The module is written against SDK 1.10; check `sdkVersion` before relying on another version.
|
|
19
|
+
*/
|
|
20
|
+
export function loadSdk(dllPath: string): void
|
|
21
|
+
|
|
22
|
+
/** The version of the loaded SDK. */
|
|
23
|
+
export interface SdkVersion {
|
|
24
|
+
major: number
|
|
25
|
+
minor: number
|
|
26
|
+
patch: number
|
|
27
|
+
hash: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Returns the version of the loaded SDK. */
|
|
31
|
+
export function sdkVersion(): SdkVersion
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Runs the SDK's pending callbacks: client callbacks and the completion of pending calls happen
|
|
35
|
+
* only while this runs. Call it periodically (e.g. every 100ms) for as long as any client exists.
|
|
36
|
+
*/
|
|
37
|
+
export function runCallbacks(): void
|
|
38
|
+
|
|
39
|
+
export type ClientStatus =
|
|
40
|
+
| 'disconnected'
|
|
41
|
+
| 'connecting'
|
|
42
|
+
| 'connected'
|
|
43
|
+
| 'ready'
|
|
44
|
+
| 'reconnecting'
|
|
45
|
+
| 'disconnecting'
|
|
46
|
+
| 'httpWait'
|
|
47
|
+
/** A status this module doesn't know about, from a newer SDK. */
|
|
48
|
+
| 'unknown'
|
|
49
|
+
|
|
50
|
+
export type ClientError =
|
|
51
|
+
| 'none'
|
|
52
|
+
| 'connectionFailed'
|
|
53
|
+
| 'unexpectedClose'
|
|
54
|
+
| 'connectionCanceled'
|
|
55
|
+
/** An error this module doesn't know about, from a newer SDK. */
|
|
56
|
+
| 'unknown'
|
|
57
|
+
|
|
58
|
+
export type LogSeverity = 'verbose' | 'info' | 'warning' | 'error'
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Callbacks for a client's events. They're called asynchronously on the JS thread, after the
|
|
62
|
+
* `runCallbacks` call that received them.
|
|
63
|
+
*/
|
|
64
|
+
export interface ClientOptions {
|
|
65
|
+
/** Called with each message the SDK logs at `logSeverity` or above. */
|
|
66
|
+
onLog?: (message: string, severity: LogSeverity | 'unknown') => void
|
|
67
|
+
/** The lowest severity passed to `onLog`. Defaults to 'info'. */
|
|
68
|
+
logSeverity?: LogSeverity
|
|
69
|
+
/**
|
|
70
|
+
* Called when the client's connection status changes. `errorDetail` is a code that further
|
|
71
|
+
* describes `error`. The client is only usable once the status is 'ready'.
|
|
72
|
+
*/
|
|
73
|
+
onStatusChanged?: (status: ClientStatus, error: ClientError, errorDetail: number) => void
|
|
74
|
+
/**
|
|
75
|
+
* Called once when the token last passed to `updateToken` is about to expire or has expired.
|
|
76
|
+
* Get a new token and pass it to `updateToken`. Not called for a token that was expired or
|
|
77
|
+
* revoked when connecting; the client disconnects instead.
|
|
78
|
+
*/
|
|
79
|
+
onTokenExpiring?: () => void
|
|
80
|
+
/**
|
|
81
|
+
* Called when the user accepts an invite to, or asks to join, another user's activity in the
|
|
82
|
+
* Discord client, with the `joinSecret` of that activity. If the Discord client launched the
|
|
83
|
+
* app for this (see `registerLaunchCommand`), it's called once the app connects.
|
|
84
|
+
*/
|
|
85
|
+
onActivityJoin?: (joinSecret: string) => void
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Creates a client. It does nothing until it's given a token (`updateToken`) and connected
|
|
90
|
+
* (`connect`), or given an application ID (`setApplicationId`) to set rich presence through the
|
|
91
|
+
* Discord desktop client without connecting.
|
|
92
|
+
*
|
|
93
|
+
* The client keeps its callbacks until it's destroyed, and the callbacks often reference the
|
|
94
|
+
* client, so it isn't garbage collected on its own: call `destroyClient` when done with it.
|
|
95
|
+
*/
|
|
96
|
+
export function createClient(options: ClientOptions): DiscordClient
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Drops the client: it disconnects, stops calling its callbacks, and rejects its pending calls.
|
|
100
|
+
* Any later call with it throws.
|
|
101
|
+
*/
|
|
102
|
+
export function destroyClient(client: DiscordClient): void
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Sets the application to use when not connected, for setting rich presence through the Discord
|
|
106
|
+
* desktop client. Connecting sets it from the token instead.
|
|
107
|
+
*/
|
|
108
|
+
export function setApplicationId(client: DiscordClient, applicationId: string): void
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Sets the OAuth2 access token (a Bearer token) the client connects with. If the client is
|
|
112
|
+
* connected, it may reconnect with the new token. Resolves once the token is stored; wait for that
|
|
113
|
+
* before calling `connect`.
|
|
114
|
+
*/
|
|
115
|
+
export function updateToken(client: DiscordClient, token: string): Promise<void>
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Connects the client to Discord. Progress is reported to `onStatusChanged`; the client is ready
|
|
119
|
+
* to use once the status is 'ready'.
|
|
120
|
+
*/
|
|
121
|
+
export function connect(client: DiscordClient): void
|
|
122
|
+
|
|
123
|
+
/** Disconnects the client. Progress is reported to `onStatusChanged`. */
|
|
124
|
+
export function disconnect(client: DiscordClient): void
|
|
125
|
+
|
|
126
|
+
/** Returns the client's current connection status. */
|
|
127
|
+
export function getStatus(client: DiscordClient): ClientStatus
|
|
128
|
+
|
|
129
|
+
export type ActivityType = 'playing' | 'streaming' | 'listening' | 'watching' | 'competing'
|
|
130
|
+
|
|
131
|
+
export type ActivityGamePlatform =
|
|
132
|
+
'desktop' | 'xbox' | 'samsung' | 'ios' | 'android' | 'embedded' | 'ps4' | 'ps5'
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* A rich presence activity. The SDK validates the fields when it's set: strings noted as 2-128
|
|
136
|
+
* characters must be that long if given. The activity's name and application come from the
|
|
137
|
+
* Discord application and can't be set.
|
|
138
|
+
*/
|
|
139
|
+
export interface Activity {
|
|
140
|
+
/** Defaults to 'playing'. */
|
|
141
|
+
type?: ActivityType
|
|
142
|
+
/** Which field the user's status line in Discord shows. Defaults to the application's name. */
|
|
143
|
+
statusDisplayType?: 'name' | 'state' | 'details'
|
|
144
|
+
/** What the user is doing, e.g. the game mode. 2-128 characters. */
|
|
145
|
+
details?: string
|
|
146
|
+
/** The state of the user's party, e.g. "In a lobby". 2-128 characters. */
|
|
147
|
+
state?: string
|
|
148
|
+
/**
|
|
149
|
+
* In milliseconds since the Unix epoch. With `start`, Discord shows how long the activity has
|
|
150
|
+
* been going; with `end`, how long it has left.
|
|
151
|
+
*/
|
|
152
|
+
timestamps?: { start?: number; end?: number }
|
|
153
|
+
/**
|
|
154
|
+
* Images and their tooltips. An image is the key of an art asset uploaded to the Discord
|
|
155
|
+
* application, or a URL. Tooltips are 2-128 characters.
|
|
156
|
+
*/
|
|
157
|
+
assets?: {
|
|
158
|
+
largeImage?: string
|
|
159
|
+
largeText?: string
|
|
160
|
+
smallImage?: string
|
|
161
|
+
smallText?: string
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The group the user is in, shown as "(currentSize of maxSize)" after `state`. Everyone in the
|
|
165
|
+
* party should use the same `id` (2-128 characters). A `maxSize` of 0 shows no maximum.
|
|
166
|
+
* `privacy` defaults to 'private'.
|
|
167
|
+
*/
|
|
168
|
+
party?: {
|
|
169
|
+
id: string
|
|
170
|
+
currentSize: number
|
|
171
|
+
maxSize: number
|
|
172
|
+
privacy?: 'public' | 'private'
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Makes the activity joinable from Discord (with a `party` that has room) and is passed to
|
|
176
|
+
* `onActivityJoin` of whoever joins. 2-128 characters.
|
|
177
|
+
*/
|
|
178
|
+
joinSecret?: string
|
|
179
|
+
/** The platforms the activity can be joined from. */
|
|
180
|
+
supportedPlatforms?: ActivityGamePlatform[]
|
|
181
|
+
/** Up to 2 buttons that open a URL. They aren't shown to the user themselves. */
|
|
182
|
+
buttons?: Array<{ label: string; url: string }>
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export type ResultErrorType =
|
|
186
|
+
| 'none'
|
|
187
|
+
| 'networkError'
|
|
188
|
+
| 'httpError'
|
|
189
|
+
| 'clientNotReady'
|
|
190
|
+
| 'disabled'
|
|
191
|
+
| 'clientDestroyed'
|
|
192
|
+
| 'validationError'
|
|
193
|
+
| 'aborted'
|
|
194
|
+
| 'authorizationFailed'
|
|
195
|
+
| 'rpcError'
|
|
196
|
+
/** An error type this module doesn't know about, from a newer SDK. */
|
|
197
|
+
| 'unknown'
|
|
198
|
+
|
|
199
|
+
/** The error a call's promise rejects with when the SDK reports a failure. */
|
|
200
|
+
export interface DiscordCallError extends Error {
|
|
201
|
+
errorType: ResultErrorType
|
|
202
|
+
/** A code that further describes the error, e.g. Discord's error code for an HTTP error. */
|
|
203
|
+
errorCode: number
|
|
204
|
+
/** Whether the call may succeed if it's tried again. */
|
|
205
|
+
retryable: boolean
|
|
206
|
+
/** How long to wait before trying again, in seconds. */
|
|
207
|
+
retryAfter: number
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Sets the user's rich presence. Resolves once Discord accepted it, or rejects with a
|
|
212
|
+
* `DiscordCallError`.
|
|
213
|
+
*/
|
|
214
|
+
export function updateRichPresence(client: DiscordClient, activity: Activity): Promise<void>
|
|
215
|
+
|
|
216
|
+
/** Clears the user's rich presence. */
|
|
217
|
+
export function clearRichPresence(client: DiscordClient): void
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Registers the command the Discord client runs to launch the app when the user joins an activity
|
|
221
|
+
* from Discord while the app isn't running. Registration is per machine; do it on every start.
|
|
222
|
+
* `command` is an executable path plus any arguments, e.g. `"C:\path\app.exe" app-scheme://`; an
|
|
223
|
+
* empty string registers the running executable. Returns whether it was registered.
|
|
224
|
+
*/
|
|
225
|
+
export function registerLaunchCommand(
|
|
226
|
+
client: DiscordClient,
|
|
227
|
+
applicationId: string,
|
|
228
|
+
command: string,
|
|
229
|
+
): boolean
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./prebuilds/x64.node')
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "cfg-if"
|
|
7
|
+
version = "1.0.5"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "danimoth"
|
|
13
|
+
version = "0.1.1"
|
|
14
|
+
dependencies = [
|
|
15
|
+
"libloading",
|
|
16
|
+
"neon",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[[package]]
|
|
20
|
+
name = "either"
|
|
21
|
+
version = "1.19.0"
|
|
22
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
23
|
+
checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
|
|
24
|
+
|
|
25
|
+
[[package]]
|
|
26
|
+
name = "getrandom"
|
|
27
|
+
version = "0.2.17"
|
|
28
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
29
|
+
checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
|
|
30
|
+
dependencies = [
|
|
31
|
+
"cfg-if",
|
|
32
|
+
"libc",
|
|
33
|
+
"wasi",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[[package]]
|
|
37
|
+
name = "libc"
|
|
38
|
+
version = "0.2.191"
|
|
39
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
40
|
+
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
|
41
|
+
|
|
42
|
+
[[package]]
|
|
43
|
+
name = "libloading"
|
|
44
|
+
version = "0.8.9"
|
|
45
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
46
|
+
checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
|
|
47
|
+
dependencies = [
|
|
48
|
+
"cfg-if",
|
|
49
|
+
"windows-link",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[[package]]
|
|
53
|
+
name = "linkme"
|
|
54
|
+
version = "0.3.37"
|
|
55
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
56
|
+
checksum = "3045e122bd98aef8ec3ad58ce84f0791f64e70163d1a02710af4aa11a4d54cc5"
|
|
57
|
+
dependencies = [
|
|
58
|
+
"linkme-impl",
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
[[package]]
|
|
62
|
+
name = "linkme-impl"
|
|
63
|
+
version = "0.3.37"
|
|
64
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
65
|
+
checksum = "77060ebe535362c3da75682cd17b0431017b6e7c5661e714fc69a7ad017d1301"
|
|
66
|
+
dependencies = [
|
|
67
|
+
"proc-macro2",
|
|
68
|
+
"quote",
|
|
69
|
+
"syn 3.0.9",
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
[[package]]
|
|
73
|
+
name = "neon"
|
|
74
|
+
version = "1.1.2"
|
|
75
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
76
|
+
checksum = "70dbe899caa46aa63af21b88b4d345c7259c75c36d92e7d7531f658fb459becd"
|
|
77
|
+
dependencies = [
|
|
78
|
+
"either",
|
|
79
|
+
"getrandom",
|
|
80
|
+
"libloading",
|
|
81
|
+
"linkme",
|
|
82
|
+
"neon-macros",
|
|
83
|
+
"once_cell",
|
|
84
|
+
"semver",
|
|
85
|
+
"send_wrapper",
|
|
86
|
+
"smallvec",
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
[[package]]
|
|
90
|
+
name = "neon-macros"
|
|
91
|
+
version = "1.1.2"
|
|
92
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
93
|
+
checksum = "fdc6c9b9844577c69901eb0b690dc282e31172b934364536bbce1cc47639e1b7"
|
|
94
|
+
dependencies = [
|
|
95
|
+
"proc-macro2",
|
|
96
|
+
"quote",
|
|
97
|
+
"syn 2.0.119",
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
[[package]]
|
|
101
|
+
name = "once_cell"
|
|
102
|
+
version = "1.21.4"
|
|
103
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
104
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
105
|
+
|
|
106
|
+
[[package]]
|
|
107
|
+
name = "proc-macro2"
|
|
108
|
+
version = "1.0.107"
|
|
109
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
110
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
111
|
+
dependencies = [
|
|
112
|
+
"unicode-ident",
|
|
113
|
+
]
|
|
114
|
+
|
|
115
|
+
[[package]]
|
|
116
|
+
name = "quote"
|
|
117
|
+
version = "1.0.47"
|
|
118
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
119
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
120
|
+
dependencies = [
|
|
121
|
+
"proc-macro2",
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
[[package]]
|
|
125
|
+
name = "semver"
|
|
126
|
+
version = "1.0.28"
|
|
127
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
128
|
+
checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
|
|
129
|
+
|
|
130
|
+
[[package]]
|
|
131
|
+
name = "send_wrapper"
|
|
132
|
+
version = "0.6.0"
|
|
133
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
134
|
+
checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73"
|
|
135
|
+
|
|
136
|
+
[[package]]
|
|
137
|
+
name = "smallvec"
|
|
138
|
+
version = "1.16.3"
|
|
139
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
140
|
+
checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b"
|
|
141
|
+
|
|
142
|
+
[[package]]
|
|
143
|
+
name = "syn"
|
|
144
|
+
version = "2.0.119"
|
|
145
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
146
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
147
|
+
dependencies = [
|
|
148
|
+
"proc-macro2",
|
|
149
|
+
"quote",
|
|
150
|
+
"unicode-ident",
|
|
151
|
+
]
|
|
152
|
+
|
|
153
|
+
[[package]]
|
|
154
|
+
name = "syn"
|
|
155
|
+
version = "3.0.9"
|
|
156
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
157
|
+
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
|
|
158
|
+
dependencies = [
|
|
159
|
+
"proc-macro2",
|
|
160
|
+
"quote",
|
|
161
|
+
"unicode-ident",
|
|
162
|
+
]
|
|
163
|
+
|
|
164
|
+
[[package]]
|
|
165
|
+
name = "unicode-ident"
|
|
166
|
+
version = "1.0.27"
|
|
167
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
168
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
|
169
|
+
|
|
170
|
+
[[package]]
|
|
171
|
+
name = "wasi"
|
|
172
|
+
version = "0.11.1+wasi-snapshot-preview1"
|
|
173
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
174
|
+
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
|
175
|
+
|
|
176
|
+
[[package]]
|
|
177
|
+
name = "windows-link"
|
|
178
|
+
version = "0.2.1"
|
|
179
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
180
|
+
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "danimoth"
|
|
3
|
+
# Kept equal to the version in package.json: `version()` reports this one, and the tests check
|
|
4
|
+
# that the two match.
|
|
5
|
+
version = "0.1.1"
|
|
6
|
+
description = "Rust-based Node.js native module wrapping the Discord Social SDK"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
edition = "2024"
|
|
9
|
+
exclude = ["index.node"]
|
|
10
|
+
|
|
11
|
+
[lib]
|
|
12
|
+
crate-type = ["cdylib"]
|
|
13
|
+
|
|
14
|
+
[dependencies]
|
|
15
|
+
libloading = "0.8"
|
|
16
|
+
neon = "1.1"
|