@reboot-dev/reboot 0.25.1 → 0.25.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +147 -112
- package/index.d.ts +6 -6
- package/index.js +15 -8
- package/package.json +4 -3
- package/rbt.js +2 -5
- package/reboot_native.cc +20 -4
- package/reboot_native.cjs +11 -2
- package/utils/errors.d.ts +1 -1
- package/utils/errors.js +4 -6
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/binding.gyp
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
{
|
|
4
4
|
"python3":
|
|
5
5
|
"<!(echo $RBT_PYTHON3_USE)",
|
|
6
|
+
# Using `node` to get the OS and arch since it is platform independent.
|
|
6
7
|
"os_and_arch":
|
|
7
|
-
"<(OS) <!(
|
|
8
|
+
"<(OS) <!(node -p process.arch)",
|
|
8
9
|
# See https://gregoryszorc.com/docs/python-build-standalone/main/running.html.
|
|
9
10
|
# We use `gnu` (rather than `musl`) because we need a libc that we can install
|
|
10
11
|
# our native python extension on.
|
|
@@ -18,121 +19,155 @@
|
|
|
18
19
|
"conditions":
|
|
19
20
|
[
|
|
20
21
|
[
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
22
|
+
"OS != 'win'",
|
|
23
|
+
{
|
|
24
|
+
"conditions":
|
|
25
|
+
[
|
|
26
|
+
[
|
|
27
|
+
"os_and_arch=='mac arm64' and python3==''", {
|
|
28
|
+
"variables":
|
|
29
|
+
{
|
|
30
|
+
"python3":
|
|
31
|
+
"<!(curl -s -L <(pbs_base_url)-aarch64-apple-darwin-install_only.tar.gz | tar -xzf - && echo $(pwd)/python/bin/python3)"
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
[
|
|
36
|
+
"os_and_arch=='mac x64' and python3==''", {
|
|
37
|
+
"variables":
|
|
38
|
+
{
|
|
39
|
+
"python3":
|
|
40
|
+
"<!(curl -s -L <(pbs_base_url)-x86_64-apple-darwin-install_only.tar.gz | tar -xzf - && echo $(pwd)/python/bin/python3)"
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
"os_and_arch=='linux arm64' and python3==''", {
|
|
46
|
+
"variables":
|
|
47
|
+
{
|
|
48
|
+
"python3":
|
|
49
|
+
"<!(curl -s -L <(pbs_base_url)-aarch64-unknown-linux-gnu-install_only.tar.gz | tar -xzf - && echo $(pwd)/python/bin/python3)"
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
[
|
|
54
|
+
"os_and_arch=='linux x64' and python3==''", {
|
|
55
|
+
"variables":
|
|
56
|
+
{
|
|
57
|
+
"python3":
|
|
58
|
+
"<!(curl -s -L <(pbs_base_url)-x86_64-unknown-linux-gnu-install_only.tar.gz | tar -xzf - && echo $(pwd)/python/bin/python3)"
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
"OS=='mac' and python3==''",
|
|
64
|
+
{
|
|
65
|
+
"variables":
|
|
66
|
+
{
|
|
67
|
+
# NOTE: On macOS, the `rpath` is not respected, and the dependency name of the
|
|
68
|
+
# downloaded Python is based on what it self-reports. We adjust what it will
|
|
69
|
+
# self-report in order to ensure that it is located at runtime.
|
|
70
|
+
#
|
|
71
|
+
# In theory, `gyp` supports Actions and dependencies between Targets. But
|
|
72
|
+
# in practice, `node-gyp` makes (undocumented) adjustments to both Actions and
|
|
73
|
+
# Targets that make it very challenging to use it for either fetching or
|
|
74
|
+
# updating the interpreter. We use private/dummy variables here to trigger
|
|
75
|
+
# side-effects instead.
|
|
76
|
+
"_absolute_lib_path":
|
|
77
|
+
"<!(echo $(pwd)/python/lib/libpython3.10.dylib)",
|
|
78
|
+
"_dummy":
|
|
79
|
+
"<!(install_name_tool -id <(_absolute_lib_path) <(_absolute_lib_path))"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
],
|
|
84
|
+
"targets":
|
|
85
|
+
[
|
|
86
|
+
{
|
|
87
|
+
"target_name":
|
|
88
|
+
"reboot_native",
|
|
89
|
+
"sources": ["reboot_native.cc"],
|
|
90
|
+
"variables":
|
|
91
|
+
{
|
|
92
|
+
# We additionally determine the `lib`/`bin` dir using sysconfig, in order to
|
|
93
|
+
# resolve through any shims that might be masking the true location of the
|
|
94
|
+
# underlying binaries (`python3.10-config`, in particular).
|
|
95
|
+
"python_lib_dir":
|
|
96
|
+
"<!(dirname $(<(python3) -c \"import sysconfig; print(sysconfig.get_path('stdlib', scheme='posix_prefix'))\"))",
|
|
97
|
+
"python_bin_dir":
|
|
98
|
+
"<!(<(python3) -c \"import sysconfig; print(sysconfig.get_path('scripts', scheme='posix_prefix'))\")",
|
|
99
|
+
"python3_config":
|
|
100
|
+
"<(python_bin_dir)/python3.10-config"
|
|
101
|
+
},
|
|
102
|
+
"include_dirs":
|
|
103
|
+
[
|
|
104
|
+
"<!@(node -p \"require('node-addon-api').include\")",
|
|
105
|
+
"<!@(<(python3) -c \"import sysconfig; print(sysconfig.get_path('include'))\")",
|
|
106
|
+
"include"
|
|
107
|
+
],
|
|
108
|
+
"dependencies":
|
|
109
|
+
[
|
|
110
|
+
"<!@(node -p \"require('node-addon-api').gyp\")"
|
|
111
|
+
],
|
|
112
|
+
"libraries":
|
|
113
|
+
[
|
|
114
|
+
"-L<(python_lib_dir)",
|
|
115
|
+
"<!@(<(python3_config) --libs --embed)",
|
|
116
|
+
# Adding extra lib path for `npm install`, while using local Python.
|
|
117
|
+
"<!@(<(python3_config) --ldflags --embed)",
|
|
118
|
+
# Set the `python_lib_dir` as an rpath for our library, so that it will be
|
|
119
|
+
# used as the runtime source of `libpython3.10`.
|
|
120
|
+
# NOTE: Although this is applied on macOS it is not actually obeyed for some
|
|
121
|
+
# reason: see the NOTE in the `conditions` above.
|
|
122
|
+
"-Wl,-rpath,<(python_lib_dir)"
|
|
123
|
+
],
|
|
124
|
+
"cflags!": ["-fno-exceptions", "-fno-rtti"],
|
|
125
|
+
"cflags_cc!": ["-fno-exceptions", "-fno-rtti"],
|
|
126
|
+
"cflags_cc":
|
|
127
|
+
[
|
|
128
|
+
"<!@(<(python3_config) --cflags --embed)",
|
|
129
|
+
"-std=c++17"
|
|
130
|
+
],
|
|
131
|
+
# For no reason 'node gyp' doesn't respect 'cflags' and 'cflags_cc'.
|
|
132
|
+
# For more information: https://github.com/nodejs/node-gyp/issues/152
|
|
133
|
+
"xcode_settings":
|
|
134
|
+
{
|
|
135
|
+
"OTHER_CFLAGS":
|
|
136
|
+
[
|
|
137
|
+
"<!@(<(python3_config) --cflags --embed)",
|
|
138
|
+
"-std=c++17",
|
|
139
|
+
"-fexceptions",
|
|
140
|
+
"-frtti",
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
"ldflags":
|
|
144
|
+
[
|
|
145
|
+
"<!@(<(python3_config) --ldflags --embed)"
|
|
146
|
+
],
|
|
147
|
+
"defines":
|
|
148
|
+
[
|
|
149
|
+
"NAPI_CPP_EXCEPTIONS",
|
|
150
|
+
"RBT_PYTHON3_USE=\"<(python3)\""
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
]
|
|
54
154
|
}
|
|
55
155
|
],
|
|
56
156
|
[
|
|
57
|
-
|
|
157
|
+
# 'node-gyp' requires at least one target to be defined.
|
|
158
|
+
# This is a workaround to avoid building the 'reboot_native'
|
|
159
|
+
# target on Windows.
|
|
160
|
+
"OS == 'win'",
|
|
58
161
|
{
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
# Targets that make it very challenging to use it for either fetching or
|
|
68
|
-
# updating the interpreter. We use private/dummy variables here to trigger
|
|
69
|
-
# side-effects instead.
|
|
70
|
-
"_absolute_lib_path":
|
|
71
|
-
"<!(echo $(pwd)/python/lib/libpython3.10.dylib)",
|
|
72
|
-
"_dummy":
|
|
73
|
-
"<!(install_name_tool -id <(_absolute_lib_path) <(_absolute_lib_path))",
|
|
74
|
-
},
|
|
162
|
+
"targets":
|
|
163
|
+
[
|
|
164
|
+
{
|
|
165
|
+
"target_name": "empty",
|
|
166
|
+
"type": "none",
|
|
167
|
+
"sources": []
|
|
168
|
+
}
|
|
169
|
+
]
|
|
75
170
|
}
|
|
76
171
|
],
|
|
77
|
-
]
|
|
78
|
-
"targets":
|
|
79
|
-
[
|
|
80
|
-
{
|
|
81
|
-
"target_name":
|
|
82
|
-
"reboot_native",
|
|
83
|
-
"sources": ["reboot_native.cc"],
|
|
84
|
-
"variables":
|
|
85
|
-
{
|
|
86
|
-
# We additionally determine the `lib`/`bin` dir using sysconfig, in order to
|
|
87
|
-
# resolve through any shims that might be masking the true location of the
|
|
88
|
-
# underlying binaries (`python3.10-config`, in particular).
|
|
89
|
-
"python_lib_dir":
|
|
90
|
-
"<!(dirname $(<(python3) -c \"import sysconfig; print(sysconfig.get_path('stdlib', scheme='posix_prefix'))\"))",
|
|
91
|
-
"python_bin_dir":
|
|
92
|
-
"<!(<(python3) -c \"import sysconfig; print(sysconfig.get_path('scripts', scheme='posix_prefix'))\")",
|
|
93
|
-
"python3_config":
|
|
94
|
-
"<(python_bin_dir)/python3.10-config",
|
|
95
|
-
},
|
|
96
|
-
"include_dirs":
|
|
97
|
-
[
|
|
98
|
-
"<!@(node -p \"require('node-addon-api').include\")",
|
|
99
|
-
"<!@(<(python3) -c \"import sysconfig; print(sysconfig.get_path('include'))\")",
|
|
100
|
-
"include",
|
|
101
|
-
],
|
|
102
|
-
"dependencies":
|
|
103
|
-
["<!@(node -p \"require('node-addon-api').gyp\")"],
|
|
104
|
-
"libraries":
|
|
105
|
-
[
|
|
106
|
-
"-L<(python_lib_dir)",
|
|
107
|
-
"<!@(<(python3_config) --libs --embed)",
|
|
108
|
-
# Adding extra lib path for `npm install`, while using local Python.
|
|
109
|
-
"<!@(<(python3_config) --ldflags --embed)",
|
|
110
|
-
# Set the `python_lib_dir` as an rpath for our library, so that it will be
|
|
111
|
-
# used as the runtime source of `libpython3.10`.
|
|
112
|
-
# NOTE: Although this is applied on macOS it is not actually obeyed for some
|
|
113
|
-
# reason: see the NOTE in the `conditions` above.
|
|
114
|
-
"-Wl,-rpath,<(python_lib_dir)",
|
|
115
|
-
],
|
|
116
|
-
"cflags!": ["-fno-exceptions", "-fno-rtti"],
|
|
117
|
-
"cflags_cc!": ["-fno-exceptions", "-fno-rtti"],
|
|
118
|
-
"cflags_cc":
|
|
119
|
-
["<!@(<(python3_config) --cflags --embed)", "-std=c++17"],
|
|
120
|
-
# For no reason 'node gyp' doesn't respect 'cflags' and 'cflags_cc'.
|
|
121
|
-
# For more information: https://github.com/nodejs/node-gyp/issues/152
|
|
122
|
-
'xcode_settings':
|
|
123
|
-
{
|
|
124
|
-
'OTHER_CFLAGS':
|
|
125
|
-
[
|
|
126
|
-
"<!@(<(python3_config) --cflags --embed)",
|
|
127
|
-
"-std=c++17", "-fexceptions", "-frtti"
|
|
128
|
-
],
|
|
129
|
-
},
|
|
130
|
-
"ldflags": ["<!@(<(python3_config) --ldflags --embed)"],
|
|
131
|
-
"defines":
|
|
132
|
-
[
|
|
133
|
-
"NAPI_CPP_EXCEPTIONS",
|
|
134
|
-
'RBT_PYTHON3_USE="<(python3)"',
|
|
135
|
-
],
|
|
136
|
-
},
|
|
137
|
-
],
|
|
172
|
+
]
|
|
138
173
|
}
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { errors_pb, IdempotencyOptions, protobuf_es, ScheduleOptions } from "@reboot-dev/reboot-api";
|
|
2
|
-
import express from "express";
|
|
3
2
|
import * as reboot_native from "./reboot_native.cjs";
|
|
3
|
+
import { Application as ExpressApplication, NextFunction as ExpressNextFunction, Request as ExpressRequest, Response as ExpressResponse } from "express";
|
|
4
4
|
export { reboot_native };
|
|
5
5
|
export * from "./utils/index.js";
|
|
6
6
|
type ApplicationRevision = {
|
|
@@ -177,7 +177,7 @@ export declare function isAppInternal({ context, }: {
|
|
|
177
177
|
context: ReaderContext;
|
|
178
178
|
state?: protobuf_es.Message;
|
|
179
179
|
request?: protobuf_es.Message;
|
|
180
|
-
}): errors_pb.
|
|
180
|
+
}): errors_pb.PermissionDenied | errors_pb.Ok;
|
|
181
181
|
export declare class Application {
|
|
182
182
|
#private;
|
|
183
183
|
constructor({ servicers, initialize, initializeBearerToken, tokenVerifier, }: {
|
|
@@ -195,14 +195,14 @@ export declare class Application {
|
|
|
195
195
|
export declare namespace Application {
|
|
196
196
|
namespace Http {
|
|
197
197
|
type Path = string | RegExp | (string | RegExp)[];
|
|
198
|
-
type ReqResHandler = (context: ExternalContext, req:
|
|
199
|
-
type ReqResNextHandler = (context: ExternalContext, req:
|
|
200
|
-
type ErrReqResNextHandler = (context: ExternalContext, err: any, req:
|
|
198
|
+
type ReqResHandler = (context: ExternalContext, req: ExpressRequest, res: ExpressResponse) => any;
|
|
199
|
+
type ReqResNextHandler = (context: ExternalContext, req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction) => any;
|
|
200
|
+
type ErrReqResNextHandler = (context: ExternalContext, err: any, req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction) => any;
|
|
201
201
|
type Handler = ReqResHandler | ReqResNextHandler | ErrReqResNextHandler;
|
|
202
202
|
}
|
|
203
203
|
class Http {
|
|
204
204
|
#private;
|
|
205
|
-
constructor(express:
|
|
205
|
+
constructor(express: ExpressApplication, createExternalContext: (args: {
|
|
206
206
|
name: string;
|
|
207
207
|
bearerToken?: string;
|
|
208
208
|
}) => Promise<ExternalContext>);
|
package/index.js
CHANGED
|
@@ -12,12 +12,15 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
12
12
|
var _Reboot_external, _ExternalContext_external, _a, _Context_external, _Context_isInternalConstructing, _ReaderContext_kind, _WriterContext_kind, _TransactionContext_kind, _WorkflowContext_kind, _Application_servicers, _Application_tokenVerifier, _Application_express, _Application_http, _Application_servers, _Application_createExternalContext, _Application_external;
|
|
13
13
|
import { auth_pb, errors_pb, protobuf_es, } from "@reboot-dev/reboot-api";
|
|
14
14
|
import { strict as assert } from "assert";
|
|
15
|
-
import express from "express";
|
|
16
15
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
17
16
|
import { fork } from "node:child_process";
|
|
17
|
+
import { createRequire } from "node:module";
|
|
18
18
|
import { test } from "node:test";
|
|
19
19
|
import * as reboot_native from "./reboot_native.cjs";
|
|
20
|
+
import { ensureError } from "./utils/errors.js";
|
|
20
21
|
import { ensurePythonVenv } from "./venv.js";
|
|
22
|
+
const require = createRequire(import.meta.url);
|
|
23
|
+
const express = require("express");
|
|
21
24
|
export { reboot_native };
|
|
22
25
|
export * from "./utils/index.js";
|
|
23
26
|
const startedInstances = [];
|
|
@@ -431,7 +434,7 @@ export function isAppInternal({ context, }) {
|
|
|
431
434
|
if (context.appInternal) {
|
|
432
435
|
return new errors_pb.Ok();
|
|
433
436
|
}
|
|
434
|
-
return new errors_pb.
|
|
437
|
+
return new errors_pb.PermissionDenied();
|
|
435
438
|
}
|
|
436
439
|
export class Application {
|
|
437
440
|
constructor({ servicers, initialize, initializeBearerToken, tokenVerifier, }) {
|
|
@@ -500,12 +503,16 @@ export class Application {
|
|
|
500
503
|
await initialize(context);
|
|
501
504
|
}
|
|
502
505
|
catch (e) {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
506
|
+
// Ensure we have an `Error` and then `console.error()` it
|
|
507
|
+
// so that developers see a stack trace of what is going
|
|
508
|
+
// on.
|
|
509
|
+
const error = ensureError(e);
|
|
510
|
+
// Write an empy message which includes a newline to make
|
|
511
|
+
// it easier to identify the stack trace.
|
|
512
|
+
console.error("");
|
|
513
|
+
console.error(error);
|
|
514
|
+
console.error("");
|
|
515
|
+
throw error;
|
|
509
516
|
}
|
|
510
517
|
}
|
|
511
518
|
}, initializeBearerToken, tokenVerifier), "f");
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"@bufbuild/protobuf": "1.3.2",
|
|
4
4
|
"@bufbuild/protoplugin": "1.3.2",
|
|
5
5
|
"@bufbuild/protoc-gen-es": "1.3.2",
|
|
6
|
-
"@reboot-dev/reboot-api": "0.25.
|
|
6
|
+
"@reboot-dev/reboot-api": "0.25.2",
|
|
7
7
|
"chalk": "^4.1.2",
|
|
8
8
|
"node-addon-api": "^7.0.0",
|
|
9
9
|
"node-gyp": ">=10.2.0",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"name": "@reboot-dev/reboot",
|
|
18
|
-
"version": "0.25.
|
|
18
|
+
"version": "0.25.2",
|
|
19
19
|
"description": "npm package for Reboot",
|
|
20
20
|
"scripts": {
|
|
21
21
|
"postinstall": "rbt || exit 0",
|
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"typescript": ">=4.9.5",
|
|
27
|
+
"@types/express": "^5.0.1",
|
|
27
28
|
"@types/node": "20.11.5",
|
|
28
29
|
"@types/uuid": "^9.0.4",
|
|
29
|
-
"@types/express": "^5.0.
|
|
30
|
+
"@types/express-serve-static-core": "^5.0.6"
|
|
30
31
|
},
|
|
31
32
|
"bin": {
|
|
32
33
|
"rbt": "./rbt.js",
|
package/rbt.js
CHANGED
|
@@ -27,16 +27,13 @@ function addExtensionlessToNodeOptions() {
|
|
|
27
27
|
// If we have one of those two versions then we can pre import
|
|
28
28
|
// `extensionless/register` to use the `module.register()` function,
|
|
29
29
|
// otherwise we need to fall back to `--experimental-loader`.
|
|
30
|
-
if (major >= 21 ||
|
|
31
|
-
(major == 20 && minor >= 6) ||
|
|
32
|
-
(major == 18 && minor >= 19)) {
|
|
30
|
+
if (major >= 21 || (major == 20 && minor >= 6)) {
|
|
33
31
|
process.env.NODE_OPTIONS += "--import=extensionless/register";
|
|
34
32
|
}
|
|
35
33
|
else {
|
|
36
34
|
throw new Error(`The current version of Node.js is not supported.
|
|
37
35
|
Supported versions are:
|
|
38
|
-
* greater than or equal to 20.6
|
|
39
|
-
* greater than or equal to 18.19 but less than 19`);
|
|
36
|
+
* greater than or equal to 20.6`);
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
39
|
async function main() {
|
package/reboot_native.cc
CHANGED
|
@@ -1605,8 +1605,22 @@ Napi::Value Reboot_up(const Napi::CallbackInfo& info) {
|
|
|
1605
1605
|
});
|
|
1606
1606
|
}
|
|
1607
1607
|
|
|
1608
|
-
|
|
1609
|
-
|
|
1608
|
+
Napi::Value Reboot_down(const Napi::CallbackInfo& info) {
|
|
1609
|
+
auto js_external_reboot = NapiSafeReference(
|
|
1610
|
+
info[0].As<Napi::External<py::object>>());
|
|
1611
|
+
|
|
1612
|
+
// CHECK(js_external_reboot.CheckTypeTag(&reboot_aio_tests_Reboot));
|
|
1613
|
+
|
|
1614
|
+
py::object* py_reboot = js_external_reboot.Value(info.Env()).Data();
|
|
1615
|
+
|
|
1616
|
+
return NodePromiseFromPythonTask(
|
|
1617
|
+
info.Env(),
|
|
1618
|
+
"Reboot.down() in nodejs",
|
|
1619
|
+
{"asyncio", "create_task"},
|
|
1620
|
+
[js_external_reboot, // Ensures `py_reboot` remains valid.
|
|
1621
|
+
py_reboot]() {
|
|
1622
|
+
return py_reboot->attr("down")();
|
|
1623
|
+
});
|
|
1610
1624
|
}
|
|
1611
1625
|
|
|
1612
1626
|
Napi::Value Reboot_start(const Napi::CallbackInfo& info) {
|
|
@@ -1633,7 +1647,8 @@ Napi::Value Reboot_start(const Napi::CallbackInfo& info) {
|
|
|
1633
1647
|
info.Env(),
|
|
1634
1648
|
"Reboot.start() in nodejs",
|
|
1635
1649
|
{"asyncio", "create_task"},
|
|
1636
|
-
[py_reboot
|
|
1650
|
+
[js_external_reboot, // Ensures `py_reboot` remains valid.
|
|
1651
|
+
py_reboot]() {
|
|
1637
1652
|
return py_reboot->attr("start")();
|
|
1638
1653
|
});
|
|
1639
1654
|
}
|
|
@@ -1653,7 +1668,8 @@ Napi::Value Reboot_stop(const Napi::CallbackInfo& info) {
|
|
|
1653
1668
|
info.Env(),
|
|
1654
1669
|
"Reboot.stop() in nodejs",
|
|
1655
1670
|
{"asyncio", "create_task"},
|
|
1656
|
-
[py_reboot
|
|
1671
|
+
[js_external_reboot, // Ensures `py_reboot` remains valid.
|
|
1672
|
+
py_reboot]() {
|
|
1657
1673
|
return py_reboot->attr("stop")();
|
|
1658
1674
|
});
|
|
1659
1675
|
|
package/reboot_native.cjs
CHANGED
|
@@ -3,12 +3,21 @@ const process = require("node:process");
|
|
|
3
3
|
const os = require("node:os");
|
|
4
4
|
const path = require("node:path");
|
|
5
5
|
|
|
6
|
+
if (os.platform() === "win32") {
|
|
7
|
+
console.error(
|
|
8
|
+
chalk.stderr.bold.red(
|
|
9
|
+
`Reboot is not yet supported on Windows. Please use Linux or macOS.`
|
|
10
|
+
)
|
|
11
|
+
);
|
|
12
|
+
process.exit(-1);
|
|
13
|
+
}
|
|
14
|
+
|
|
6
15
|
const [major, minor, patch] = process.versions.node.split(".").map(Number);
|
|
7
16
|
|
|
8
|
-
if (major <
|
|
17
|
+
if (major < 20) {
|
|
9
18
|
console.error(
|
|
10
19
|
chalk.stderr.bold.red(
|
|
11
|
-
`Reboot requires nodejs version >=
|
|
20
|
+
`Reboot requires nodejs version >=20 (found ${major}.${minor}.${patch})`
|
|
12
21
|
)
|
|
13
22
|
);
|
|
14
23
|
process.exit(-1);
|
package/utils/errors.d.ts
CHANGED
package/utils/errors.js
CHANGED
|
@@ -4,13 +4,11 @@ export class UnknownError extends Error {
|
|
|
4
4
|
this.name = "UnknownError";
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
error = errorObject;
|
|
7
|
+
export const ensureError = (error) => {
|
|
8
|
+
if (error instanceof Error) {
|
|
9
|
+
return error;
|
|
11
10
|
}
|
|
12
11
|
else {
|
|
13
|
-
|
|
12
|
+
return new UnknownError(error);
|
|
14
13
|
}
|
|
15
|
-
return error;
|
|
16
14
|
};
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const REBOOT_VERSION = "0.25.
|
|
1
|
+
export declare const REBOOT_VERSION = "0.25.2";
|
package/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const REBOOT_VERSION = "0.25.
|
|
1
|
+
export const REBOOT_VERSION = "0.25.2";
|