@rivetkit/rivetkit-napi 0.0.0-pr.4654.0c7e751
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/index.d.ts +308 -0
- package/index.js +325 -0
- package/package.json +57 -0
- package/scripts/build.mjs +21 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
export interface JsActorKeySegment {
|
|
7
|
+
kind: string
|
|
8
|
+
stringValue?: string
|
|
9
|
+
numberValue?: number
|
|
10
|
+
}
|
|
11
|
+
export interface JsHttpRequest {
|
|
12
|
+
method: string
|
|
13
|
+
uri: string
|
|
14
|
+
headers?: Record<string, string>
|
|
15
|
+
body?: Buffer
|
|
16
|
+
}
|
|
17
|
+
export interface StateDeltaConnHibernationEntry {
|
|
18
|
+
connId: string
|
|
19
|
+
bytes: Buffer
|
|
20
|
+
}
|
|
21
|
+
export interface StateDeltaPayload {
|
|
22
|
+
state?: Buffer
|
|
23
|
+
connHibernation: Array<StateDeltaConnHibernationEntry>
|
|
24
|
+
connHibernationRemoved: Array<string>
|
|
25
|
+
}
|
|
26
|
+
export interface JsRequestSaveOpts {
|
|
27
|
+
immediate?: boolean
|
|
28
|
+
maxWaitMs?: number
|
|
29
|
+
}
|
|
30
|
+
export interface JsInspectorSnapshot {
|
|
31
|
+
stateRevision: number
|
|
32
|
+
connectionsRevision: number
|
|
33
|
+
queueRevision: number
|
|
34
|
+
activeConnections: number
|
|
35
|
+
queueSize: number
|
|
36
|
+
connectedClients: number
|
|
37
|
+
}
|
|
38
|
+
export interface JsHttpResponse {
|
|
39
|
+
status?: number
|
|
40
|
+
headers?: Record<string, string>
|
|
41
|
+
body?: Buffer
|
|
42
|
+
}
|
|
43
|
+
export interface JsQueueSendResult {
|
|
44
|
+
status: string
|
|
45
|
+
response?: Buffer
|
|
46
|
+
}
|
|
47
|
+
export interface JsActionDefinition {
|
|
48
|
+
name: string
|
|
49
|
+
}
|
|
50
|
+
export interface JsActorConfig {
|
|
51
|
+
name?: string
|
|
52
|
+
icon?: string
|
|
53
|
+
hasDatabase?: boolean
|
|
54
|
+
hasState?: boolean
|
|
55
|
+
canHibernateWebsocket?: boolean
|
|
56
|
+
stateSaveIntervalMs?: number
|
|
57
|
+
createStateTimeoutMs?: number
|
|
58
|
+
onCreateTimeoutMs?: number
|
|
59
|
+
createVarsTimeoutMs?: number
|
|
60
|
+
createConnStateTimeoutMs?: number
|
|
61
|
+
onBeforeConnectTimeoutMs?: number
|
|
62
|
+
onConnectTimeoutMs?: number
|
|
63
|
+
onMigrateTimeoutMs?: number
|
|
64
|
+
onWakeTimeoutMs?: number
|
|
65
|
+
onBeforeActorStartTimeoutMs?: number
|
|
66
|
+
actionTimeoutMs?: number
|
|
67
|
+
onRequestTimeoutMs?: number
|
|
68
|
+
sleepTimeoutMs?: number
|
|
69
|
+
noSleep?: boolean
|
|
70
|
+
sleepGracePeriodMs?: number
|
|
71
|
+
connectionLivenessTimeoutMs?: number
|
|
72
|
+
connectionLivenessIntervalMs?: number
|
|
73
|
+
maxQueueSize?: number
|
|
74
|
+
maxQueueMessageSize?: number
|
|
75
|
+
maxIncomingMessageSize?: number
|
|
76
|
+
maxOutgoingMessageSize?: number
|
|
77
|
+
preloadMaxWorkflowBytes?: number
|
|
78
|
+
preloadMaxConnectionsBytes?: number
|
|
79
|
+
actions?: Array<JsActionDefinition>
|
|
80
|
+
}
|
|
81
|
+
export interface JsBindParam {
|
|
82
|
+
kind: string
|
|
83
|
+
intValue?: number
|
|
84
|
+
floatValue?: number
|
|
85
|
+
textValue?: string
|
|
86
|
+
blobValue?: Buffer
|
|
87
|
+
}
|
|
88
|
+
export interface ExecuteResult {
|
|
89
|
+
changes: number
|
|
90
|
+
}
|
|
91
|
+
export interface QueryResult {
|
|
92
|
+
columns: Array<string>
|
|
93
|
+
rows: Array<Array<any>>
|
|
94
|
+
}
|
|
95
|
+
export interface JsSqliteVfsMetrics {
|
|
96
|
+
requestBuildNs: number
|
|
97
|
+
serializeNs: number
|
|
98
|
+
transportNs: number
|
|
99
|
+
stateUpdateNs: number
|
|
100
|
+
totalNs: number
|
|
101
|
+
commitCount: number
|
|
102
|
+
}
|
|
103
|
+
export interface JsQueueNextOptions {
|
|
104
|
+
names?: Array<string>
|
|
105
|
+
timeoutMs?: number
|
|
106
|
+
completable?: boolean
|
|
107
|
+
}
|
|
108
|
+
export interface JsQueueNextBatchOptions {
|
|
109
|
+
names?: Array<string>
|
|
110
|
+
count?: number
|
|
111
|
+
timeoutMs?: number
|
|
112
|
+
completable?: boolean
|
|
113
|
+
}
|
|
114
|
+
export interface JsQueueWaitOptions {
|
|
115
|
+
timeoutMs?: number
|
|
116
|
+
completable?: boolean
|
|
117
|
+
}
|
|
118
|
+
export interface JsQueueEnqueueAndWaitOptions {
|
|
119
|
+
timeoutMs?: number
|
|
120
|
+
}
|
|
121
|
+
export interface JsQueueTryNextOptions {
|
|
122
|
+
names?: Array<string>
|
|
123
|
+
completable?: boolean
|
|
124
|
+
}
|
|
125
|
+
export interface JsQueueTryNextBatchOptions {
|
|
126
|
+
names?: Array<string>
|
|
127
|
+
count?: number
|
|
128
|
+
completable?: boolean
|
|
129
|
+
}
|
|
130
|
+
export interface JsQueueInspectMessage {
|
|
131
|
+
/**
|
|
132
|
+
* Queue message id. Stored as the raw u64 reinterpreted as i64 so JS
|
|
133
|
+
* sees a plain number; ids are monotonic and fit comfortably in i64.
|
|
134
|
+
*/
|
|
135
|
+
id: number
|
|
136
|
+
name: string
|
|
137
|
+
createdAtMs: number
|
|
138
|
+
}
|
|
139
|
+
export interface JsServeConfig {
|
|
140
|
+
version: number
|
|
141
|
+
endpoint: string
|
|
142
|
+
token?: string
|
|
143
|
+
namespace: string
|
|
144
|
+
poolName: string
|
|
145
|
+
engineBinaryPath?: string
|
|
146
|
+
handleInspectorHttpInRuntime?: boolean
|
|
147
|
+
serverlessBasePath?: string
|
|
148
|
+
serverlessPackageVersion: string
|
|
149
|
+
serverlessClientEndpoint?: string
|
|
150
|
+
serverlessClientNamespace?: string
|
|
151
|
+
serverlessClientToken?: string
|
|
152
|
+
serverlessValidateEndpoint: boolean
|
|
153
|
+
serverlessMaxStartPayloadBytes: number
|
|
154
|
+
}
|
|
155
|
+
export interface JsServerlessRequest {
|
|
156
|
+
method: string
|
|
157
|
+
url: string
|
|
158
|
+
headers: Record<string, string>
|
|
159
|
+
body: Buffer
|
|
160
|
+
}
|
|
161
|
+
export interface JsServerlessResponseHead {
|
|
162
|
+
status: number
|
|
163
|
+
headers: Record<string, string>
|
|
164
|
+
}
|
|
165
|
+
export interface JsServerlessStreamError {
|
|
166
|
+
group: string
|
|
167
|
+
code: string
|
|
168
|
+
message: string
|
|
169
|
+
}
|
|
170
|
+
/** Options for KV list operations. */
|
|
171
|
+
export interface JsKvListOptions {
|
|
172
|
+
reverse?: boolean
|
|
173
|
+
limit?: number
|
|
174
|
+
}
|
|
175
|
+
/** A key-value entry returned from KV list operations. */
|
|
176
|
+
export interface JsKvEntry {
|
|
177
|
+
key: Buffer
|
|
178
|
+
value: Buffer
|
|
179
|
+
}
|
|
180
|
+
/** N-API wrapper around `rivetkit-core::ActorContext`. */
|
|
181
|
+
export declare class ActorContext {
|
|
182
|
+
constructor(actorId: string, name: string, region: string)
|
|
183
|
+
state(): Buffer
|
|
184
|
+
beginOnStateChange(): void
|
|
185
|
+
endOnStateChange(): void
|
|
186
|
+
kv(): Kv
|
|
187
|
+
sql(): JsNativeDatabase
|
|
188
|
+
schedule(): Schedule
|
|
189
|
+
queue(): Queue
|
|
190
|
+
setAlarm(timestampMs?: number | undefined | null): void
|
|
191
|
+
requestSave(opts?: JsRequestSaveOpts | undefined | null): void
|
|
192
|
+
requestSaveAndWait(opts?: JsRequestSaveOpts | undefined | null): Promise<void>
|
|
193
|
+
decodeInspectorRequest(bytes: Buffer, advertisedVersion: number): Buffer
|
|
194
|
+
encodeInspectorResponse(bytes: Buffer, targetVersion: number): Buffer
|
|
195
|
+
inspectorSnapshot(): JsInspectorSnapshot
|
|
196
|
+
verifyInspectorAuth(bearerToken?: string | undefined | null): Promise<void>
|
|
197
|
+
queueHibernationRemoval(connId: string): void
|
|
198
|
+
hasPendingHibernationChanges(): boolean
|
|
199
|
+
takePendingHibernationChanges(): Array<string>
|
|
200
|
+
dirtyHibernatableConns(): Array<ConnHandle>
|
|
201
|
+
saveState(payload: StateDeltaPayload): Promise<void>
|
|
202
|
+
actorId(): string
|
|
203
|
+
name(): string
|
|
204
|
+
key(): Array<JsActorKeySegment>
|
|
205
|
+
region(): string
|
|
206
|
+
sleep(): void
|
|
207
|
+
destroy(): void
|
|
208
|
+
destroyRequested(): boolean
|
|
209
|
+
waitForDestroyCompletion(): Promise<void>
|
|
210
|
+
setPreventSleep(preventSleep: boolean): void
|
|
211
|
+
preventSleep(): boolean
|
|
212
|
+
aborted(): boolean
|
|
213
|
+
runHandlerActive(): boolean
|
|
214
|
+
restartRunHandler(): void
|
|
215
|
+
beginWebsocketCallback(): number
|
|
216
|
+
endWebsocketCallback(regionId: number): void
|
|
217
|
+
abortSignal(): AbortSignal
|
|
218
|
+
conns(): Array<ConnHandle>
|
|
219
|
+
connectConn(params: Buffer, request?: JsHttpRequest | undefined | null): Promise<ConnHandle>
|
|
220
|
+
disconnectConn(id: string): Promise<void>
|
|
221
|
+
disconnectConns(predicate: (...args: any[]) => any): Promise<void>
|
|
222
|
+
broadcast(name: string, args: Buffer): void
|
|
223
|
+
waitUntil(promise: Promise<any>): void
|
|
224
|
+
keepAwake(promise: Promise<any>): Promise<any>
|
|
225
|
+
registerTask(promise: Promise<any>): void
|
|
226
|
+
runtimeState(): object
|
|
227
|
+
clearRuntimeState(): void
|
|
228
|
+
}
|
|
229
|
+
export declare class NapiActorFactory {
|
|
230
|
+
constructor(callbacks: object, config?: JsActorConfig | undefined | null)
|
|
231
|
+
}
|
|
232
|
+
export declare class CancellationToken {
|
|
233
|
+
constructor()
|
|
234
|
+
aborted(): boolean
|
|
235
|
+
cancel(): void
|
|
236
|
+
onCancelled(callback: (...args: any[]) => any): void
|
|
237
|
+
}
|
|
238
|
+
export declare class ConnHandle {
|
|
239
|
+
id(): string
|
|
240
|
+
params(): Buffer
|
|
241
|
+
state(): Buffer
|
|
242
|
+
setState(state: Buffer): void
|
|
243
|
+
isHibernatable(): boolean
|
|
244
|
+
send(name: string, args: Buffer): void
|
|
245
|
+
disconnect(reason?: string | undefined | null): Promise<void>
|
|
246
|
+
}
|
|
247
|
+
export declare class JsNativeDatabase {
|
|
248
|
+
takeLastKvError(): string | null
|
|
249
|
+
getSqliteVfsMetrics(): JsSqliteVfsMetrics | null
|
|
250
|
+
run(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<ExecuteResult>
|
|
251
|
+
query(sql: string, params?: Array<JsBindParam> | undefined | null): Promise<QueryResult>
|
|
252
|
+
exec(sql: string): Promise<QueryResult>
|
|
253
|
+
close(): Promise<void>
|
|
254
|
+
}
|
|
255
|
+
export declare class Kv {
|
|
256
|
+
get(key: Buffer): Promise<Buffer | null>
|
|
257
|
+
put(key: Buffer, value: Buffer): Promise<void>
|
|
258
|
+
delete(key: Buffer): Promise<void>
|
|
259
|
+
deleteRange(start: Buffer, end: Buffer): Promise<void>
|
|
260
|
+
listPrefix(prefix: Buffer, options?: JsKvListOptions | undefined | null): Promise<Array<JsKvEntry>>
|
|
261
|
+
listRange(start: Buffer, end: Buffer, options?: JsKvListOptions | undefined | null): Promise<Array<JsKvEntry>>
|
|
262
|
+
batchGet(keys: Array<Buffer>): Promise<Array<Buffer | undefined | null>>
|
|
263
|
+
batchPut(entries: Array<JsKvEntry>): Promise<void>
|
|
264
|
+
batchDelete(keys: Array<Buffer>): Promise<void>
|
|
265
|
+
}
|
|
266
|
+
export declare class Queue {
|
|
267
|
+
send(name: string, body: Buffer): Promise<QueueMessage>
|
|
268
|
+
next(options?: JsQueueNextOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<QueueMessage | null>
|
|
269
|
+
nextBatch(options?: JsQueueNextBatchOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<Array<QueueMessage>>
|
|
270
|
+
waitForNames(names: Array<string>, options?: JsQueueWaitOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<QueueMessage>
|
|
271
|
+
waitForNamesAvailable(names: Array<string>, options?: JsQueueWaitOptions | undefined | null): Promise<void>
|
|
272
|
+
enqueueAndWait(name: string, body: Buffer, options?: JsQueueEnqueueAndWaitOptions | undefined | null, signal?: CancellationToken | undefined | null): Promise<Buffer | null>
|
|
273
|
+
tryNext(options?: JsQueueTryNextOptions | undefined | null): QueueMessage | null
|
|
274
|
+
tryNextBatch(options?: JsQueueTryNextBatchOptions | undefined | null): Array<QueueMessage>
|
|
275
|
+
maxSize(): number
|
|
276
|
+
inspectMessages(): Promise<Array<JsQueueInspectMessage>>
|
|
277
|
+
}
|
|
278
|
+
export declare class QueueMessage {
|
|
279
|
+
id(): bigint
|
|
280
|
+
name(): string
|
|
281
|
+
body(): Buffer
|
|
282
|
+
createdAt(): number
|
|
283
|
+
isCompletable(): boolean
|
|
284
|
+
complete(response?: Buffer | undefined | null): Promise<void>
|
|
285
|
+
}
|
|
286
|
+
export declare class CoreRegistry {
|
|
287
|
+
constructor()
|
|
288
|
+
register(name: string, factory: NapiActorFactory): void
|
|
289
|
+
serve(config: JsServeConfig): Promise<void>
|
|
290
|
+
/**
|
|
291
|
+
* Trip the shutdown token and tear down any live serverless runtime.
|
|
292
|
+
*
|
|
293
|
+
* Idempotent. Safe to call when neither mode has been activated.
|
|
294
|
+
* Does not block on the `serve()` future; TS awaits that promise
|
|
295
|
+
* separately to avoid re-entrancy.
|
|
296
|
+
*/
|
|
297
|
+
shutdown(): Promise<void>
|
|
298
|
+
handleServerlessRequest(req: JsServerlessRequest, onStreamEvent: (...args: any[]) => any, cancelToken: CancellationToken, config: JsServeConfig): Promise<JsServerlessResponseHead>
|
|
299
|
+
}
|
|
300
|
+
export declare class Schedule {
|
|
301
|
+
after(durationMs: number, actionName: string, args: Buffer): void
|
|
302
|
+
at(timestampMs: number, actionName: string, args: Buffer): void
|
|
303
|
+
}
|
|
304
|
+
export declare class WebSocket {
|
|
305
|
+
send(data: Buffer, binary: boolean): void
|
|
306
|
+
close(code?: number | undefined | null, reason?: string | undefined | null): Promise<void>
|
|
307
|
+
setEventCallback(callback: (...args: any[]) => any): void
|
|
308
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
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, 'rivetkit-napi.android-arm64.node'))
|
|
36
|
+
try {
|
|
37
|
+
if (localFileExisted) {
|
|
38
|
+
nativeBinding = require('./rivetkit-napi.android-arm64.node')
|
|
39
|
+
} else {
|
|
40
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-android-arm64')
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
loadError = e
|
|
44
|
+
}
|
|
45
|
+
break
|
|
46
|
+
case 'arm':
|
|
47
|
+
localFileExisted = existsSync(join(__dirname, 'rivetkit-napi.android-arm-eabi.node'))
|
|
48
|
+
try {
|
|
49
|
+
if (localFileExisted) {
|
|
50
|
+
nativeBinding = require('./rivetkit-napi.android-arm-eabi.node')
|
|
51
|
+
} else {
|
|
52
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-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, 'rivetkit-napi.win32-x64-msvc.node')
|
|
67
|
+
)
|
|
68
|
+
try {
|
|
69
|
+
if (localFileExisted) {
|
|
70
|
+
nativeBinding = require('./rivetkit-napi.win32-x64-msvc.node')
|
|
71
|
+
} else {
|
|
72
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-win32-x64-msvc')
|
|
73
|
+
}
|
|
74
|
+
} catch (e) {
|
|
75
|
+
loadError = e
|
|
76
|
+
}
|
|
77
|
+
break
|
|
78
|
+
case 'ia32':
|
|
79
|
+
localFileExisted = existsSync(
|
|
80
|
+
join(__dirname, 'rivetkit-napi.win32-ia32-msvc.node')
|
|
81
|
+
)
|
|
82
|
+
try {
|
|
83
|
+
if (localFileExisted) {
|
|
84
|
+
nativeBinding = require('./rivetkit-napi.win32-ia32-msvc.node')
|
|
85
|
+
} else {
|
|
86
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-win32-ia32-msvc')
|
|
87
|
+
}
|
|
88
|
+
} catch (e) {
|
|
89
|
+
loadError = e
|
|
90
|
+
}
|
|
91
|
+
break
|
|
92
|
+
case 'arm64':
|
|
93
|
+
localFileExisted = existsSync(
|
|
94
|
+
join(__dirname, 'rivetkit-napi.win32-arm64-msvc.node')
|
|
95
|
+
)
|
|
96
|
+
try {
|
|
97
|
+
if (localFileExisted) {
|
|
98
|
+
nativeBinding = require('./rivetkit-napi.win32-arm64-msvc.node')
|
|
99
|
+
} else {
|
|
100
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-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, 'rivetkit-napi.darwin-universal.node'))
|
|
112
|
+
try {
|
|
113
|
+
if (localFileExisted) {
|
|
114
|
+
nativeBinding = require('./rivetkit-napi.darwin-universal.node')
|
|
115
|
+
} else {
|
|
116
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-darwin-universal')
|
|
117
|
+
}
|
|
118
|
+
break
|
|
119
|
+
} catch {}
|
|
120
|
+
switch (arch) {
|
|
121
|
+
case 'x64':
|
|
122
|
+
localFileExisted = existsSync(join(__dirname, 'rivetkit-napi.darwin-x64.node'))
|
|
123
|
+
try {
|
|
124
|
+
if (localFileExisted) {
|
|
125
|
+
nativeBinding = require('./rivetkit-napi.darwin-x64.node')
|
|
126
|
+
} else {
|
|
127
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-darwin-x64')
|
|
128
|
+
}
|
|
129
|
+
} catch (e) {
|
|
130
|
+
loadError = e
|
|
131
|
+
}
|
|
132
|
+
break
|
|
133
|
+
case 'arm64':
|
|
134
|
+
localFileExisted = existsSync(
|
|
135
|
+
join(__dirname, 'rivetkit-napi.darwin-arm64.node')
|
|
136
|
+
)
|
|
137
|
+
try {
|
|
138
|
+
if (localFileExisted) {
|
|
139
|
+
nativeBinding = require('./rivetkit-napi.darwin-arm64.node')
|
|
140
|
+
} else {
|
|
141
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-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, 'rivetkit-napi.freebsd-x64.node'))
|
|
156
|
+
try {
|
|
157
|
+
if (localFileExisted) {
|
|
158
|
+
nativeBinding = require('./rivetkit-napi.freebsd-x64.node')
|
|
159
|
+
} else {
|
|
160
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-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, 'rivetkit-napi.linux-x64-musl.node')
|
|
172
|
+
)
|
|
173
|
+
try {
|
|
174
|
+
if (localFileExisted) {
|
|
175
|
+
nativeBinding = require('./rivetkit-napi.linux-x64-musl.node')
|
|
176
|
+
} else {
|
|
177
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-linux-x64-musl')
|
|
178
|
+
}
|
|
179
|
+
} catch (e) {
|
|
180
|
+
loadError = e
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
localFileExisted = existsSync(
|
|
184
|
+
join(__dirname, 'rivetkit-napi.linux-x64-gnu.node')
|
|
185
|
+
)
|
|
186
|
+
try {
|
|
187
|
+
if (localFileExisted) {
|
|
188
|
+
nativeBinding = require('./rivetkit-napi.linux-x64-gnu.node')
|
|
189
|
+
} else {
|
|
190
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-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, 'rivetkit-napi.linux-arm64-musl.node')
|
|
201
|
+
)
|
|
202
|
+
try {
|
|
203
|
+
if (localFileExisted) {
|
|
204
|
+
nativeBinding = require('./rivetkit-napi.linux-arm64-musl.node')
|
|
205
|
+
} else {
|
|
206
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-linux-arm64-musl')
|
|
207
|
+
}
|
|
208
|
+
} catch (e) {
|
|
209
|
+
loadError = e
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
localFileExisted = existsSync(
|
|
213
|
+
join(__dirname, 'rivetkit-napi.linux-arm64-gnu.node')
|
|
214
|
+
)
|
|
215
|
+
try {
|
|
216
|
+
if (localFileExisted) {
|
|
217
|
+
nativeBinding = require('./rivetkit-napi.linux-arm64-gnu.node')
|
|
218
|
+
} else {
|
|
219
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-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, 'rivetkit-napi.linux-arm-musleabihf.node')
|
|
230
|
+
)
|
|
231
|
+
try {
|
|
232
|
+
if (localFileExisted) {
|
|
233
|
+
nativeBinding = require('./rivetkit-napi.linux-arm-musleabihf.node')
|
|
234
|
+
} else {
|
|
235
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-linux-arm-musleabihf')
|
|
236
|
+
}
|
|
237
|
+
} catch (e) {
|
|
238
|
+
loadError = e
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
localFileExisted = existsSync(
|
|
242
|
+
join(__dirname, 'rivetkit-napi.linux-arm-gnueabihf.node')
|
|
243
|
+
)
|
|
244
|
+
try {
|
|
245
|
+
if (localFileExisted) {
|
|
246
|
+
nativeBinding = require('./rivetkit-napi.linux-arm-gnueabihf.node')
|
|
247
|
+
} else {
|
|
248
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-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, 'rivetkit-napi.linux-riscv64-musl.node')
|
|
259
|
+
)
|
|
260
|
+
try {
|
|
261
|
+
if (localFileExisted) {
|
|
262
|
+
nativeBinding = require('./rivetkit-napi.linux-riscv64-musl.node')
|
|
263
|
+
} else {
|
|
264
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-linux-riscv64-musl')
|
|
265
|
+
}
|
|
266
|
+
} catch (e) {
|
|
267
|
+
loadError = e
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
localFileExisted = existsSync(
|
|
271
|
+
join(__dirname, 'rivetkit-napi.linux-riscv64-gnu.node')
|
|
272
|
+
)
|
|
273
|
+
try {
|
|
274
|
+
if (localFileExisted) {
|
|
275
|
+
nativeBinding = require('./rivetkit-napi.linux-riscv64-gnu.node')
|
|
276
|
+
} else {
|
|
277
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-linux-riscv64-gnu')
|
|
278
|
+
}
|
|
279
|
+
} catch (e) {
|
|
280
|
+
loadError = e
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
break
|
|
284
|
+
case 's390x':
|
|
285
|
+
localFileExisted = existsSync(
|
|
286
|
+
join(__dirname, 'rivetkit-napi.linux-s390x-gnu.node')
|
|
287
|
+
)
|
|
288
|
+
try {
|
|
289
|
+
if (localFileExisted) {
|
|
290
|
+
nativeBinding = require('./rivetkit-napi.linux-s390x-gnu.node')
|
|
291
|
+
} else {
|
|
292
|
+
nativeBinding = require('@rivetkit/rivetkit-napi-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 { ActorContext, NapiActorFactory, CancellationToken, ConnHandle, JsNativeDatabase, Kv, Queue, QueueMessage, CoreRegistry, Schedule, WebSocket } = nativeBinding
|
|
314
|
+
|
|
315
|
+
module.exports.ActorContext = ActorContext
|
|
316
|
+
module.exports.NapiActorFactory = NapiActorFactory
|
|
317
|
+
module.exports.CancellationToken = CancellationToken
|
|
318
|
+
module.exports.ConnHandle = ConnHandle
|
|
319
|
+
module.exports.JsNativeDatabase = JsNativeDatabase
|
|
320
|
+
module.exports.Kv = Kv
|
|
321
|
+
module.exports.Queue = Queue
|
|
322
|
+
module.exports.QueueMessage = QueueMessage
|
|
323
|
+
module.exports.CoreRegistry = CoreRegistry
|
|
324
|
+
module.exports.Schedule = Schedule
|
|
325
|
+
module.exports.WebSocket = WebSocket
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rivetkit/rivetkit-napi",
|
|
3
|
+
"version": "0.0.0-pr.4654.0c7e751",
|
|
4
|
+
"description": "Native N-API addon for RivetKit providing envoy client and SQLite access",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"types": "index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./index.d.ts",
|
|
11
|
+
"default": "./index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">= 20.0.0"
|
|
16
|
+
},
|
|
17
|
+
"napi": {
|
|
18
|
+
"name": "rivetkit-napi",
|
|
19
|
+
"triples": {
|
|
20
|
+
"defaults": false,
|
|
21
|
+
"additional": [
|
|
22
|
+
"x86_64-unknown-linux-gnu",
|
|
23
|
+
"aarch64-unknown-linux-gnu",
|
|
24
|
+
"x86_64-unknown-linux-musl",
|
|
25
|
+
"aarch64-unknown-linux-musl",
|
|
26
|
+
"x86_64-apple-darwin",
|
|
27
|
+
"aarch64-apple-darwin",
|
|
28
|
+
"x86_64-pc-windows-msvc"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"index.js",
|
|
34
|
+
"index.d.ts",
|
|
35
|
+
"package.json",
|
|
36
|
+
"scripts/build.mjs"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "node scripts/build.mjs",
|
|
40
|
+
"build:release": "node scripts/build.mjs --release",
|
|
41
|
+
"build:force": "node scripts/build.mjs --force",
|
|
42
|
+
"build:force:release": "node scripts/build.mjs --force --release"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@napi-rs/cli": "^2.18.4",
|
|
46
|
+
"@rivetkit/engine-envoy-protocol": "0.0.0-pr.4654.0c7e751"
|
|
47
|
+
},
|
|
48
|
+
"optionalDependencies": {
|
|
49
|
+
"@rivetkit/rivetkit-napi-darwin-arm64": "0.0.0-pr.4654.0c7e751",
|
|
50
|
+
"@rivetkit/rivetkit-napi-darwin-x64": "0.0.0-pr.4654.0c7e751",
|
|
51
|
+
"@rivetkit/rivetkit-napi-linux-arm64-gnu": "0.0.0-pr.4654.0c7e751",
|
|
52
|
+
"@rivetkit/rivetkit-napi-linux-arm64-musl": "0.0.0-pr.4654.0c7e751",
|
|
53
|
+
"@rivetkit/rivetkit-napi-linux-x64-gnu": "0.0.0-pr.4654.0c7e751",
|
|
54
|
+
"@rivetkit/rivetkit-napi-linux-x64-musl": "0.0.0-pr.4654.0c7e751",
|
|
55
|
+
"@rivetkit/rivetkit-napi-win32-x64-msvc": "0.0.0-pr.4654.0c7e751"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Build wrapper for rivetkit-napi.
|
|
4
|
+
*/
|
|
5
|
+
import { execFileSync } from "node:child_process";
|
|
6
|
+
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
const extraFlags = args.includes("--release") ? ["--release"] : [];
|
|
9
|
+
|
|
10
|
+
// Explicit skip for environments that don't need the native binary (e.g.
|
|
11
|
+
// Docker engine-frontend build which only consumes TypeScript types).
|
|
12
|
+
if (process.env.SKIP_NAPI_BUILD === "1") {
|
|
13
|
+
console.log(
|
|
14
|
+
"[rivetkit-napi/build] SKIP_NAPI_BUILD=1 — skipping napi build",
|
|
15
|
+
);
|
|
16
|
+
process.exit(0);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const cmd = ["build", "--platform", ...extraFlags];
|
|
20
|
+
console.log(`[rivetkit-napi/build] running: napi ${cmd.join(" ")}`);
|
|
21
|
+
execFileSync("napi", cmd, { stdio: "inherit" });
|