@build-qube/takeoff-calculator 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/browser.js +1 -0
- package/index.d.ts +143 -0
- package/index.js +787 -0
- package/package.json +100 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 N-API for Rust
|
|
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/browser.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@build-qube/takeoff-calculator-wasm32-wasi";
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export declare class State {
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new state.
|
|
6
|
+
*
|
|
7
|
+
* # Arguments
|
|
8
|
+
*
|
|
9
|
+
* * `options` - The options for the state.
|
|
10
|
+
*
|
|
11
|
+
* # Returns
|
|
12
|
+
*
|
|
13
|
+
* * `State` - The new state.
|
|
14
|
+
*/
|
|
15
|
+
constructor(options: StateOptions)
|
|
16
|
+
/**
|
|
17
|
+
* Get the scale for a measurement.
|
|
18
|
+
*
|
|
19
|
+
* # Arguments
|
|
20
|
+
*
|
|
21
|
+
* * `measurement_id` - The id of the measurement.
|
|
22
|
+
*
|
|
23
|
+
* # Returns
|
|
24
|
+
*
|
|
25
|
+
* * `None` - If the measurement was not found.
|
|
26
|
+
* * `Some(scale)` - If the scale was found.
|
|
27
|
+
*/
|
|
28
|
+
getMeasurementScale(measurementId: string): Scale | null
|
|
29
|
+
/**
|
|
30
|
+
* Inserts or updates a page in the state.
|
|
31
|
+
*
|
|
32
|
+
* # Arguments
|
|
33
|
+
*
|
|
34
|
+
* * `page` - The page to insert or update.
|
|
35
|
+
*
|
|
36
|
+
* # Returns
|
|
37
|
+
*
|
|
38
|
+
* * `None` - If the page was not found.
|
|
39
|
+
* * `Some(page)` - If the page was found and updated.
|
|
40
|
+
*/
|
|
41
|
+
upsertPage(page: Page): Page | null
|
|
42
|
+
/**
|
|
43
|
+
* Inserts or updates a group in the state.
|
|
44
|
+
*
|
|
45
|
+
* # Arguments
|
|
46
|
+
*
|
|
47
|
+
* * `group` - The group to insert or update.
|
|
48
|
+
*
|
|
49
|
+
* # Returns
|
|
50
|
+
*
|
|
51
|
+
* * `None` - If the group was not found.
|
|
52
|
+
* * `Some(group)` - If the group was found and updated.
|
|
53
|
+
*/
|
|
54
|
+
upsertGroup(group: Group): Group | null
|
|
55
|
+
/**
|
|
56
|
+
* Inserts or updates a measurement in the state.
|
|
57
|
+
*
|
|
58
|
+
* # Arguments
|
|
59
|
+
*
|
|
60
|
+
* * `measurement` - The measurement to insert or update.
|
|
61
|
+
*
|
|
62
|
+
* # Returns
|
|
63
|
+
*
|
|
64
|
+
* * `None` - If the measurement was not found.
|
|
65
|
+
* * `Some(measurement)` - If the measurement was found and updated.
|
|
66
|
+
*/
|
|
67
|
+
upsertMeasurement(measurement: Measurement): Measurement | null
|
|
68
|
+
/**
|
|
69
|
+
* Inserts or updates a scale in the state.
|
|
70
|
+
*
|
|
71
|
+
* # Arguments
|
|
72
|
+
*
|
|
73
|
+
* * `scale` - The scale to insert or update.
|
|
74
|
+
*
|
|
75
|
+
* # Returns
|
|
76
|
+
*
|
|
77
|
+
* * `None` - If the scale was not found.
|
|
78
|
+
* * `Some(scale)` - If the scale was found and updated.
|
|
79
|
+
*/
|
|
80
|
+
upsertScale(scale: Scale): Scale | null
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export declare function plus100(input: number): number
|
|
84
|
+
export interface Group {
|
|
85
|
+
id: string
|
|
86
|
+
name?: string
|
|
87
|
+
measurementType: MeasurementType
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export type Measurement =
|
|
91
|
+
| { type: 'Count', id: string, pageId: string, groupId: string, points: [Point] }
|
|
92
|
+
| { type: 'Polygon', id: string, pageId: string, groupId: string, points: Array<Point> }
|
|
93
|
+
| { type: 'Polyline', id: string, pageId: string, groupId: string, points: Array<Point> }
|
|
94
|
+
| { type: 'Rectangle', id: string, pageId: string, groupId: string, points: [Point, Point] }
|
|
95
|
+
|
|
96
|
+
export type MeasurementType = 'Area'|
|
|
97
|
+
'Linear'|
|
|
98
|
+
'Count';
|
|
99
|
+
|
|
100
|
+
export interface Page {
|
|
101
|
+
id: string
|
|
102
|
+
name?: string
|
|
103
|
+
width?: number
|
|
104
|
+
height?: number
|
|
105
|
+
viewport?: PageViewport
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface PageViewport {
|
|
109
|
+
width: number
|
|
110
|
+
height: number
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Represents a 2D point with floating point coordinates */
|
|
114
|
+
export interface Point {
|
|
115
|
+
x: number
|
|
116
|
+
y: number
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type Scale =
|
|
120
|
+
| { type: 'Area', id: string, pageId: string, scale: ScaleDefinition, boundingBox: [Point, Point] }
|
|
121
|
+
| { type: 'Default', id: string, pageId: string, scale: ScaleDefinition }
|
|
122
|
+
|
|
123
|
+
export interface ScaleDefinition {
|
|
124
|
+
pixelDistance: number
|
|
125
|
+
realDistance: number
|
|
126
|
+
unit: Unit
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface StateOptions {
|
|
130
|
+
pages: Array<Page>
|
|
131
|
+
groups: Array<Group>
|
|
132
|
+
measurements: Array<Measurement>
|
|
133
|
+
scales: Array<Scale>
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Measurement units supported by the system */
|
|
137
|
+
export type Unit = /** Imperial units */
|
|
138
|
+
'Yards'|
|
|
139
|
+
'Feet'|
|
|
140
|
+
'Inches'|
|
|
141
|
+
/** Metric units */
|
|
142
|
+
'Meters'|
|
|
143
|
+
'Centimeters';
|
package/index.js
ADDED
|
@@ -0,0 +1,787 @@
|
|
|
1
|
+
// prettier-ignore
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
const { readFileSync } = require('node:fs')
|
|
7
|
+
let nativeBinding = null;
|
|
8
|
+
const loadErrors = [];
|
|
9
|
+
|
|
10
|
+
const isMusl = () => {
|
|
11
|
+
let musl = false;
|
|
12
|
+
if (process.platform === "linux") {
|
|
13
|
+
musl = isMuslFromFilesystem();
|
|
14
|
+
if (musl === null) {
|
|
15
|
+
musl = isMuslFromReport();
|
|
16
|
+
}
|
|
17
|
+
if (musl === null) {
|
|
18
|
+
musl = isMuslFromChildProcess();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return musl;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
|
|
25
|
+
|
|
26
|
+
const isMuslFromFilesystem = () => {
|
|
27
|
+
try {
|
|
28
|
+
return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
|
|
29
|
+
} catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const isMuslFromReport = () => {
|
|
35
|
+
let report = null;
|
|
36
|
+
if (typeof process.report?.getReport === "function") {
|
|
37
|
+
process.report.excludeNetwork = true;
|
|
38
|
+
report = process.report.getReport();
|
|
39
|
+
}
|
|
40
|
+
if (!report) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
47
|
+
if (report.sharedObjects.some(isFileMusl)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const isMuslFromChildProcess = () => {
|
|
55
|
+
try {
|
|
56
|
+
return require("child_process")
|
|
57
|
+
.execSync("ldd --version", { encoding: "utf8" })
|
|
58
|
+
.includes("musl");
|
|
59
|
+
} catch (e) {
|
|
60
|
+
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
function requireNative() {
|
|
66
|
+
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
67
|
+
try {
|
|
68
|
+
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
69
|
+
} catch (err) {
|
|
70
|
+
loadErrors.push(err);
|
|
71
|
+
}
|
|
72
|
+
} else if (process.platform === "android") {
|
|
73
|
+
if (process.arch === "arm64") {
|
|
74
|
+
try {
|
|
75
|
+
return require("./takeoff-calculator.android-arm64.node");
|
|
76
|
+
} catch (e) {
|
|
77
|
+
loadErrors.push(e);
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const binding = require("@build-qube/takeoff-calculator-android-arm64");
|
|
81
|
+
const bindingPackageVersion =
|
|
82
|
+
require("@build-qube/takeoff-calculator-android-arm64/package.json").version;
|
|
83
|
+
if (
|
|
84
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
85
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
86
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
87
|
+
) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
return binding;
|
|
93
|
+
} catch (e) {
|
|
94
|
+
loadErrors.push(e);
|
|
95
|
+
}
|
|
96
|
+
} else if (process.arch === "arm") {
|
|
97
|
+
try {
|
|
98
|
+
return require("./takeoff-calculator.android-arm-eabi.node");
|
|
99
|
+
} catch (e) {
|
|
100
|
+
loadErrors.push(e);
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
const binding = require("@build-qube/takeoff-calculator-android-arm-eabi");
|
|
104
|
+
const bindingPackageVersion =
|
|
105
|
+
require("@build-qube/takeoff-calculator-android-arm-eabi/package.json").version;
|
|
106
|
+
if (
|
|
107
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
108
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
109
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
110
|
+
) {
|
|
111
|
+
throw new Error(
|
|
112
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
return binding;
|
|
116
|
+
} catch (e) {
|
|
117
|
+
loadErrors.push(e);
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
loadErrors.push(
|
|
121
|
+
new Error(`Unsupported architecture on Android ${process.arch}`),
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
} else if (process.platform === "win32") {
|
|
125
|
+
if (process.arch === "x64") {
|
|
126
|
+
if (
|
|
127
|
+
process.config?.variables?.shlib_suffix === "dll.a" ||
|
|
128
|
+
process.config?.variables?.node_target_type === "shared_library"
|
|
129
|
+
) {
|
|
130
|
+
try {
|
|
131
|
+
return require("./takeoff-calculator.win32-x64-gnu.node");
|
|
132
|
+
} catch (e) {
|
|
133
|
+
loadErrors.push(e);
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
const binding = require("@build-qube/takeoff-calculator-win32-x64-gnu");
|
|
137
|
+
const bindingPackageVersion =
|
|
138
|
+
require("@build-qube/takeoff-calculator-win32-x64-gnu/package.json").version;
|
|
139
|
+
if (
|
|
140
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
141
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
142
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
143
|
+
) {
|
|
144
|
+
throw new Error(
|
|
145
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
return binding;
|
|
149
|
+
} catch (e) {
|
|
150
|
+
loadErrors.push(e);
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
try {
|
|
154
|
+
return require("./takeoff-calculator.win32-x64-msvc.node");
|
|
155
|
+
} catch (e) {
|
|
156
|
+
loadErrors.push(e);
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
const binding = require("@build-qube/takeoff-calculator-win32-x64-msvc");
|
|
160
|
+
const bindingPackageVersion =
|
|
161
|
+
require("@build-qube/takeoff-calculator-win32-x64-msvc/package.json").version;
|
|
162
|
+
if (
|
|
163
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
164
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
165
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
166
|
+
) {
|
|
167
|
+
throw new Error(
|
|
168
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
return binding;
|
|
172
|
+
} catch (e) {
|
|
173
|
+
loadErrors.push(e);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
} else if (process.arch === "ia32") {
|
|
177
|
+
try {
|
|
178
|
+
return require("./takeoff-calculator.win32-ia32-msvc.node");
|
|
179
|
+
} catch (e) {
|
|
180
|
+
loadErrors.push(e);
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
const binding = require("@build-qube/takeoff-calculator-win32-ia32-msvc");
|
|
184
|
+
const bindingPackageVersion =
|
|
185
|
+
require("@build-qube/takeoff-calculator-win32-ia32-msvc/package.json").version;
|
|
186
|
+
if (
|
|
187
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
188
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
189
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
190
|
+
) {
|
|
191
|
+
throw new Error(
|
|
192
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
return binding;
|
|
196
|
+
} catch (e) {
|
|
197
|
+
loadErrors.push(e);
|
|
198
|
+
}
|
|
199
|
+
} else if (process.arch === "arm64") {
|
|
200
|
+
try {
|
|
201
|
+
return require("./takeoff-calculator.win32-arm64-msvc.node");
|
|
202
|
+
} catch (e) {
|
|
203
|
+
loadErrors.push(e);
|
|
204
|
+
}
|
|
205
|
+
try {
|
|
206
|
+
const binding = require("@build-qube/takeoff-calculator-win32-arm64-msvc");
|
|
207
|
+
const bindingPackageVersion =
|
|
208
|
+
require("@build-qube/takeoff-calculator-win32-arm64-msvc/package.json").version;
|
|
209
|
+
if (
|
|
210
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
211
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
212
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
213
|
+
) {
|
|
214
|
+
throw new Error(
|
|
215
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
return binding;
|
|
219
|
+
} catch (e) {
|
|
220
|
+
loadErrors.push(e);
|
|
221
|
+
}
|
|
222
|
+
} else {
|
|
223
|
+
loadErrors.push(
|
|
224
|
+
new Error(`Unsupported architecture on Windows: ${process.arch}`),
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
} else if (process.platform === "darwin") {
|
|
228
|
+
try {
|
|
229
|
+
return require("./takeoff-calculator.darwin-universal.node");
|
|
230
|
+
} catch (e) {
|
|
231
|
+
loadErrors.push(e);
|
|
232
|
+
}
|
|
233
|
+
try {
|
|
234
|
+
const binding = require("@build-qube/takeoff-calculator-darwin-universal");
|
|
235
|
+
const bindingPackageVersion =
|
|
236
|
+
require("@build-qube/takeoff-calculator-darwin-universal/package.json").version;
|
|
237
|
+
if (
|
|
238
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
239
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
240
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
241
|
+
) {
|
|
242
|
+
throw new Error(
|
|
243
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
return binding;
|
|
247
|
+
} catch (e) {
|
|
248
|
+
loadErrors.push(e);
|
|
249
|
+
}
|
|
250
|
+
if (process.arch === "x64") {
|
|
251
|
+
try {
|
|
252
|
+
return require("./takeoff-calculator.darwin-x64.node");
|
|
253
|
+
} catch (e) {
|
|
254
|
+
loadErrors.push(e);
|
|
255
|
+
}
|
|
256
|
+
try {
|
|
257
|
+
const binding = require("@build-qube/takeoff-calculator-darwin-x64");
|
|
258
|
+
const bindingPackageVersion =
|
|
259
|
+
require("@build-qube/takeoff-calculator-darwin-x64/package.json").version;
|
|
260
|
+
if (
|
|
261
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
262
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
263
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
264
|
+
) {
|
|
265
|
+
throw new Error(
|
|
266
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
return binding;
|
|
270
|
+
} catch (e) {
|
|
271
|
+
loadErrors.push(e);
|
|
272
|
+
}
|
|
273
|
+
} else if (process.arch === "arm64") {
|
|
274
|
+
try {
|
|
275
|
+
return require("./takeoff-calculator.darwin-arm64.node");
|
|
276
|
+
} catch (e) {
|
|
277
|
+
loadErrors.push(e);
|
|
278
|
+
}
|
|
279
|
+
try {
|
|
280
|
+
const binding = require("@build-qube/takeoff-calculator-darwin-arm64");
|
|
281
|
+
const bindingPackageVersion =
|
|
282
|
+
require("@build-qube/takeoff-calculator-darwin-arm64/package.json").version;
|
|
283
|
+
if (
|
|
284
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
285
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
286
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
287
|
+
) {
|
|
288
|
+
throw new Error(
|
|
289
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
return binding;
|
|
293
|
+
} catch (e) {
|
|
294
|
+
loadErrors.push(e);
|
|
295
|
+
}
|
|
296
|
+
} else {
|
|
297
|
+
loadErrors.push(
|
|
298
|
+
new Error(`Unsupported architecture on macOS: ${process.arch}`),
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
} else if (process.platform === "freebsd") {
|
|
302
|
+
if (process.arch === "x64") {
|
|
303
|
+
try {
|
|
304
|
+
return require("./takeoff-calculator.freebsd-x64.node");
|
|
305
|
+
} catch (e) {
|
|
306
|
+
loadErrors.push(e);
|
|
307
|
+
}
|
|
308
|
+
try {
|
|
309
|
+
const binding = require("@build-qube/takeoff-calculator-freebsd-x64");
|
|
310
|
+
const bindingPackageVersion =
|
|
311
|
+
require("@build-qube/takeoff-calculator-freebsd-x64/package.json").version;
|
|
312
|
+
if (
|
|
313
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
314
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
315
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
316
|
+
) {
|
|
317
|
+
throw new Error(
|
|
318
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
return binding;
|
|
322
|
+
} catch (e) {
|
|
323
|
+
loadErrors.push(e);
|
|
324
|
+
}
|
|
325
|
+
} else if (process.arch === "arm64") {
|
|
326
|
+
try {
|
|
327
|
+
return require("./takeoff-calculator.freebsd-arm64.node");
|
|
328
|
+
} catch (e) {
|
|
329
|
+
loadErrors.push(e);
|
|
330
|
+
}
|
|
331
|
+
try {
|
|
332
|
+
const binding = require("@build-qube/takeoff-calculator-freebsd-arm64");
|
|
333
|
+
const bindingPackageVersion =
|
|
334
|
+
require("@build-qube/takeoff-calculator-freebsd-arm64/package.json").version;
|
|
335
|
+
if (
|
|
336
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
337
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
338
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
339
|
+
) {
|
|
340
|
+
throw new Error(
|
|
341
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
return binding;
|
|
345
|
+
} catch (e) {
|
|
346
|
+
loadErrors.push(e);
|
|
347
|
+
}
|
|
348
|
+
} else {
|
|
349
|
+
loadErrors.push(
|
|
350
|
+
new Error(`Unsupported architecture on FreeBSD: ${process.arch}`),
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
} else if (process.platform === "linux") {
|
|
354
|
+
if (process.arch === "x64") {
|
|
355
|
+
if (isMusl()) {
|
|
356
|
+
try {
|
|
357
|
+
return require("./takeoff-calculator.linux-x64-musl.node");
|
|
358
|
+
} catch (e) {
|
|
359
|
+
loadErrors.push(e);
|
|
360
|
+
}
|
|
361
|
+
try {
|
|
362
|
+
const binding = require("@build-qube/takeoff-calculator-linux-x64-musl");
|
|
363
|
+
const bindingPackageVersion =
|
|
364
|
+
require("@build-qube/takeoff-calculator-linux-x64-musl/package.json").version;
|
|
365
|
+
if (
|
|
366
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
367
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
368
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
369
|
+
) {
|
|
370
|
+
throw new Error(
|
|
371
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
return binding;
|
|
375
|
+
} catch (e) {
|
|
376
|
+
loadErrors.push(e);
|
|
377
|
+
}
|
|
378
|
+
} else {
|
|
379
|
+
try {
|
|
380
|
+
return require("./takeoff-calculator.linux-x64-gnu.node");
|
|
381
|
+
} catch (e) {
|
|
382
|
+
loadErrors.push(e);
|
|
383
|
+
}
|
|
384
|
+
try {
|
|
385
|
+
const binding = require("@build-qube/takeoff-calculator-linux-x64-gnu");
|
|
386
|
+
const bindingPackageVersion =
|
|
387
|
+
require("@build-qube/takeoff-calculator-linux-x64-gnu/package.json").version;
|
|
388
|
+
if (
|
|
389
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
390
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
391
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
392
|
+
) {
|
|
393
|
+
throw new Error(
|
|
394
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
return binding;
|
|
398
|
+
} catch (e) {
|
|
399
|
+
loadErrors.push(e);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
} else if (process.arch === "arm64") {
|
|
403
|
+
if (isMusl()) {
|
|
404
|
+
try {
|
|
405
|
+
return require("./takeoff-calculator.linux-arm64-musl.node");
|
|
406
|
+
} catch (e) {
|
|
407
|
+
loadErrors.push(e);
|
|
408
|
+
}
|
|
409
|
+
try {
|
|
410
|
+
const binding = require("@build-qube/takeoff-calculator-linux-arm64-musl");
|
|
411
|
+
const bindingPackageVersion =
|
|
412
|
+
require("@build-qube/takeoff-calculator-linux-arm64-musl/package.json").version;
|
|
413
|
+
if (
|
|
414
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
415
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
416
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
417
|
+
) {
|
|
418
|
+
throw new Error(
|
|
419
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
return binding;
|
|
423
|
+
} catch (e) {
|
|
424
|
+
loadErrors.push(e);
|
|
425
|
+
}
|
|
426
|
+
} else {
|
|
427
|
+
try {
|
|
428
|
+
return require("./takeoff-calculator.linux-arm64-gnu.node");
|
|
429
|
+
} catch (e) {
|
|
430
|
+
loadErrors.push(e);
|
|
431
|
+
}
|
|
432
|
+
try {
|
|
433
|
+
const binding = require("@build-qube/takeoff-calculator-linux-arm64-gnu");
|
|
434
|
+
const bindingPackageVersion =
|
|
435
|
+
require("@build-qube/takeoff-calculator-linux-arm64-gnu/package.json").version;
|
|
436
|
+
if (
|
|
437
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
438
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
439
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
440
|
+
) {
|
|
441
|
+
throw new Error(
|
|
442
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
return binding;
|
|
446
|
+
} catch (e) {
|
|
447
|
+
loadErrors.push(e);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
} else if (process.arch === "arm") {
|
|
451
|
+
if (isMusl()) {
|
|
452
|
+
try {
|
|
453
|
+
return require("./takeoff-calculator.linux-arm-musleabihf.node");
|
|
454
|
+
} catch (e) {
|
|
455
|
+
loadErrors.push(e);
|
|
456
|
+
}
|
|
457
|
+
try {
|
|
458
|
+
const binding = require("@build-qube/takeoff-calculator-linux-arm-musleabihf");
|
|
459
|
+
const bindingPackageVersion =
|
|
460
|
+
require("@build-qube/takeoff-calculator-linux-arm-musleabihf/package.json").version;
|
|
461
|
+
if (
|
|
462
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
463
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
464
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
465
|
+
) {
|
|
466
|
+
throw new Error(
|
|
467
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
return binding;
|
|
471
|
+
} catch (e) {
|
|
472
|
+
loadErrors.push(e);
|
|
473
|
+
}
|
|
474
|
+
} else {
|
|
475
|
+
try {
|
|
476
|
+
return require("./takeoff-calculator.linux-arm-gnueabihf.node");
|
|
477
|
+
} catch (e) {
|
|
478
|
+
loadErrors.push(e);
|
|
479
|
+
}
|
|
480
|
+
try {
|
|
481
|
+
const binding = require("@build-qube/takeoff-calculator-linux-arm-gnueabihf");
|
|
482
|
+
const bindingPackageVersion =
|
|
483
|
+
require("@build-qube/takeoff-calculator-linux-arm-gnueabihf/package.json").version;
|
|
484
|
+
if (
|
|
485
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
486
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
487
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
488
|
+
) {
|
|
489
|
+
throw new Error(
|
|
490
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
return binding;
|
|
494
|
+
} catch (e) {
|
|
495
|
+
loadErrors.push(e);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
} else if (process.arch === "loong64") {
|
|
499
|
+
if (isMusl()) {
|
|
500
|
+
try {
|
|
501
|
+
return require("./takeoff-calculator.linux-loong64-musl.node");
|
|
502
|
+
} catch (e) {
|
|
503
|
+
loadErrors.push(e);
|
|
504
|
+
}
|
|
505
|
+
try {
|
|
506
|
+
const binding = require("@build-qube/takeoff-calculator-linux-loong64-musl");
|
|
507
|
+
const bindingPackageVersion =
|
|
508
|
+
require("@build-qube/takeoff-calculator-linux-loong64-musl/package.json").version;
|
|
509
|
+
if (
|
|
510
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
511
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
512
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
513
|
+
) {
|
|
514
|
+
throw new Error(
|
|
515
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
return binding;
|
|
519
|
+
} catch (e) {
|
|
520
|
+
loadErrors.push(e);
|
|
521
|
+
}
|
|
522
|
+
} else {
|
|
523
|
+
try {
|
|
524
|
+
return require("./takeoff-calculator.linux-loong64-gnu.node");
|
|
525
|
+
} catch (e) {
|
|
526
|
+
loadErrors.push(e);
|
|
527
|
+
}
|
|
528
|
+
try {
|
|
529
|
+
const binding = require("@build-qube/takeoff-calculator-linux-loong64-gnu");
|
|
530
|
+
const bindingPackageVersion =
|
|
531
|
+
require("@build-qube/takeoff-calculator-linux-loong64-gnu/package.json").version;
|
|
532
|
+
if (
|
|
533
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
534
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
535
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
536
|
+
) {
|
|
537
|
+
throw new Error(
|
|
538
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
return binding;
|
|
542
|
+
} catch (e) {
|
|
543
|
+
loadErrors.push(e);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
} else if (process.arch === "riscv64") {
|
|
547
|
+
if (isMusl()) {
|
|
548
|
+
try {
|
|
549
|
+
return require("./takeoff-calculator.linux-riscv64-musl.node");
|
|
550
|
+
} catch (e) {
|
|
551
|
+
loadErrors.push(e);
|
|
552
|
+
}
|
|
553
|
+
try {
|
|
554
|
+
const binding = require("@build-qube/takeoff-calculator-linux-riscv64-musl");
|
|
555
|
+
const bindingPackageVersion =
|
|
556
|
+
require("@build-qube/takeoff-calculator-linux-riscv64-musl/package.json").version;
|
|
557
|
+
if (
|
|
558
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
559
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
560
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
561
|
+
) {
|
|
562
|
+
throw new Error(
|
|
563
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
return binding;
|
|
567
|
+
} catch (e) {
|
|
568
|
+
loadErrors.push(e);
|
|
569
|
+
}
|
|
570
|
+
} else {
|
|
571
|
+
try {
|
|
572
|
+
return require("./takeoff-calculator.linux-riscv64-gnu.node");
|
|
573
|
+
} catch (e) {
|
|
574
|
+
loadErrors.push(e);
|
|
575
|
+
}
|
|
576
|
+
try {
|
|
577
|
+
const binding = require("@build-qube/takeoff-calculator-linux-riscv64-gnu");
|
|
578
|
+
const bindingPackageVersion =
|
|
579
|
+
require("@build-qube/takeoff-calculator-linux-riscv64-gnu/package.json").version;
|
|
580
|
+
if (
|
|
581
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
582
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
583
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
584
|
+
) {
|
|
585
|
+
throw new Error(
|
|
586
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
return binding;
|
|
590
|
+
} catch (e) {
|
|
591
|
+
loadErrors.push(e);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
} else if (process.arch === "ppc64") {
|
|
595
|
+
try {
|
|
596
|
+
return require("./takeoff-calculator.linux-ppc64-gnu.node");
|
|
597
|
+
} catch (e) {
|
|
598
|
+
loadErrors.push(e);
|
|
599
|
+
}
|
|
600
|
+
try {
|
|
601
|
+
const binding = require("@build-qube/takeoff-calculator-linux-ppc64-gnu");
|
|
602
|
+
const bindingPackageVersion =
|
|
603
|
+
require("@build-qube/takeoff-calculator-linux-ppc64-gnu/package.json").version;
|
|
604
|
+
if (
|
|
605
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
606
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
607
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
608
|
+
) {
|
|
609
|
+
throw new Error(
|
|
610
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
return binding;
|
|
614
|
+
} catch (e) {
|
|
615
|
+
loadErrors.push(e);
|
|
616
|
+
}
|
|
617
|
+
} else if (process.arch === "s390x") {
|
|
618
|
+
try {
|
|
619
|
+
return require("./takeoff-calculator.linux-s390x-gnu.node");
|
|
620
|
+
} catch (e) {
|
|
621
|
+
loadErrors.push(e);
|
|
622
|
+
}
|
|
623
|
+
try {
|
|
624
|
+
const binding = require("@build-qube/takeoff-calculator-linux-s390x-gnu");
|
|
625
|
+
const bindingPackageVersion =
|
|
626
|
+
require("@build-qube/takeoff-calculator-linux-s390x-gnu/package.json").version;
|
|
627
|
+
if (
|
|
628
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
629
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
630
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
631
|
+
) {
|
|
632
|
+
throw new Error(
|
|
633
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
634
|
+
);
|
|
635
|
+
}
|
|
636
|
+
return binding;
|
|
637
|
+
} catch (e) {
|
|
638
|
+
loadErrors.push(e);
|
|
639
|
+
}
|
|
640
|
+
} else {
|
|
641
|
+
loadErrors.push(
|
|
642
|
+
new Error(`Unsupported architecture on Linux: ${process.arch}`),
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
} else if (process.platform === "openharmony") {
|
|
646
|
+
if (process.arch === "arm64") {
|
|
647
|
+
try {
|
|
648
|
+
return require("./takeoff-calculator.openharmony-arm64.node");
|
|
649
|
+
} catch (e) {
|
|
650
|
+
loadErrors.push(e);
|
|
651
|
+
}
|
|
652
|
+
try {
|
|
653
|
+
const binding = require("@build-qube/takeoff-calculator-openharmony-arm64");
|
|
654
|
+
const bindingPackageVersion =
|
|
655
|
+
require("@build-qube/takeoff-calculator-openharmony-arm64/package.json").version;
|
|
656
|
+
if (
|
|
657
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
658
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
659
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
660
|
+
) {
|
|
661
|
+
throw new Error(
|
|
662
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
return binding;
|
|
666
|
+
} catch (e) {
|
|
667
|
+
loadErrors.push(e);
|
|
668
|
+
}
|
|
669
|
+
} else if (process.arch === "x64") {
|
|
670
|
+
try {
|
|
671
|
+
return require("./takeoff-calculator.openharmony-x64.node");
|
|
672
|
+
} catch (e) {
|
|
673
|
+
loadErrors.push(e);
|
|
674
|
+
}
|
|
675
|
+
try {
|
|
676
|
+
const binding = require("@build-qube/takeoff-calculator-openharmony-x64");
|
|
677
|
+
const bindingPackageVersion =
|
|
678
|
+
require("@build-qube/takeoff-calculator-openharmony-x64/package.json").version;
|
|
679
|
+
if (
|
|
680
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
681
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
682
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
683
|
+
) {
|
|
684
|
+
throw new Error(
|
|
685
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
return binding;
|
|
689
|
+
} catch (e) {
|
|
690
|
+
loadErrors.push(e);
|
|
691
|
+
}
|
|
692
|
+
} else if (process.arch === "arm") {
|
|
693
|
+
try {
|
|
694
|
+
return require("./takeoff-calculator.openharmony-arm.node");
|
|
695
|
+
} catch (e) {
|
|
696
|
+
loadErrors.push(e);
|
|
697
|
+
}
|
|
698
|
+
try {
|
|
699
|
+
const binding = require("@build-qube/takeoff-calculator-openharmony-arm");
|
|
700
|
+
const bindingPackageVersion =
|
|
701
|
+
require("@build-qube/takeoff-calculator-openharmony-arm/package.json").version;
|
|
702
|
+
if (
|
|
703
|
+
bindingPackageVersion !== "1.2.2" &&
|
|
704
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
705
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
706
|
+
) {
|
|
707
|
+
throw new Error(
|
|
708
|
+
`Native binding package version mismatch, expected 1.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
return binding;
|
|
712
|
+
} catch (e) {
|
|
713
|
+
loadErrors.push(e);
|
|
714
|
+
}
|
|
715
|
+
} else {
|
|
716
|
+
loadErrors.push(
|
|
717
|
+
new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`),
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
} else {
|
|
721
|
+
loadErrors.push(
|
|
722
|
+
new Error(
|
|
723
|
+
`Unsupported OS: ${process.platform}, architecture: ${process.arch}`,
|
|
724
|
+
),
|
|
725
|
+
);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
nativeBinding = requireNative();
|
|
730
|
+
|
|
731
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
732
|
+
let wasiBinding = null;
|
|
733
|
+
let wasiBindingError = null;
|
|
734
|
+
try {
|
|
735
|
+
wasiBinding = require("./takeoff-calculator.wasi.cjs");
|
|
736
|
+
nativeBinding = wasiBinding;
|
|
737
|
+
} catch (err) {
|
|
738
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
739
|
+
wasiBindingError = err;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
743
|
+
try {
|
|
744
|
+
wasiBinding = require("@build-qube/takeoff-calculator-wasm32-wasi");
|
|
745
|
+
nativeBinding = wasiBinding;
|
|
746
|
+
} catch (err) {
|
|
747
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
748
|
+
if (!wasiBindingError) {
|
|
749
|
+
wasiBindingError = err;
|
|
750
|
+
} else {
|
|
751
|
+
wasiBindingError.cause = err;
|
|
752
|
+
}
|
|
753
|
+
loadErrors.push(err);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
|
|
758
|
+
const error = new Error(
|
|
759
|
+
"WASI binding not found and NAPI_RS_FORCE_WASI is set to error",
|
|
760
|
+
);
|
|
761
|
+
error.cause = wasiBindingError;
|
|
762
|
+
throw error;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
if (!nativeBinding) {
|
|
767
|
+
if (loadErrors.length > 0) {
|
|
768
|
+
throw new Error(
|
|
769
|
+
`Cannot find native binding. ` +
|
|
770
|
+
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
771
|
+
"Please try `npm i` again after removing both package-lock.json and node_modules directory.",
|
|
772
|
+
{
|
|
773
|
+
cause: loadErrors.reduce((err, cur) => {
|
|
774
|
+
cur.cause = err;
|
|
775
|
+
return cur;
|
|
776
|
+
}),
|
|
777
|
+
},
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
throw new Error(`Failed to load native binding`);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
module.exports = nativeBinding;
|
|
784
|
+
module.exports.State = nativeBinding.State;
|
|
785
|
+
module.exports.plus100 = nativeBinding.plus100;
|
|
786
|
+
module.exports.MeasurementType = nativeBinding.MeasurementType;
|
|
787
|
+
module.exports.Unit = nativeBinding.Unit;
|
package/package.json
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@build-qube/takeoff-calculator",
|
|
3
|
+
"version": "1.2.5",
|
|
4
|
+
"description": "Template project for writing node package with napi-rs",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"browser": "browser.js",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "git+ssh://git@github.com:BuildQube/takeoff-calculator.git",
|
|
10
|
+
"type": "git"
|
|
11
|
+
},
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"napi-rs",
|
|
15
|
+
"NAPI",
|
|
16
|
+
"N-API",
|
|
17
|
+
"Rust",
|
|
18
|
+
"node-addon",
|
|
19
|
+
"node-addon-api",
|
|
20
|
+
"takeoff",
|
|
21
|
+
"quick-maffs"
|
|
22
|
+
],
|
|
23
|
+
"files": [
|
|
24
|
+
"index.d.ts",
|
|
25
|
+
"index.js",
|
|
26
|
+
"browser.js"
|
|
27
|
+
],
|
|
28
|
+
"napi": {
|
|
29
|
+
"binaryName": "takeoff-calculator",
|
|
30
|
+
"constEnum": false,
|
|
31
|
+
"targets": [
|
|
32
|
+
"x86_64-apple-darwin",
|
|
33
|
+
"aarch64-apple-darwin",
|
|
34
|
+
"x86_64-unknown-linux-gnu",
|
|
35
|
+
"x86_64-pc-windows-msvc",
|
|
36
|
+
"x86_64-unknown-linux-musl",
|
|
37
|
+
"aarch64-unknown-linux-gnu",
|
|
38
|
+
"armv7-unknown-linux-gnueabihf",
|
|
39
|
+
"aarch64-unknown-linux-musl",
|
|
40
|
+
"aarch64-pc-windows-msvc",
|
|
41
|
+
"wasm32-wasip1-threads"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">= 10"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"registry": "https://registry.npmjs.org/",
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@emnapi/core": "^1.5.0",
|
|
53
|
+
"@emnapi/runtime": "^1.5.0",
|
|
54
|
+
"@napi-rs/cli": "^3.5.1",
|
|
55
|
+
"@napi-rs/wasm-runtime": "^1.1.0",
|
|
56
|
+
"@oxc-node/core": "^0.0.35",
|
|
57
|
+
"@taplo/cli": "^0.7.0",
|
|
58
|
+
"@tybys/wasm-util": "^0.10.0",
|
|
59
|
+
"ava": "^6.4.1",
|
|
60
|
+
"chalk": "^5.6.2",
|
|
61
|
+
"emnapi": "^1.5.0",
|
|
62
|
+
"npm-run-all2": "^8.0.4",
|
|
63
|
+
"oxlint": "^1.14.0",
|
|
64
|
+
"prettier": "^3.6.2",
|
|
65
|
+
"tinybench": "^6.0.0",
|
|
66
|
+
"typescript": "^5.9.2",
|
|
67
|
+
"vitest": "^4.0.15"
|
|
68
|
+
},
|
|
69
|
+
"ava": {
|
|
70
|
+
"extensions": {
|
|
71
|
+
"ts": "module"
|
|
72
|
+
},
|
|
73
|
+
"timeout": "2m",
|
|
74
|
+
"workerThreads": false,
|
|
75
|
+
"environmentVariables": {
|
|
76
|
+
"TS_NODE_PROJECT": "./tsconfig.json"
|
|
77
|
+
},
|
|
78
|
+
"nodeArguments": [
|
|
79
|
+
"--import",
|
|
80
|
+
"@oxc-node/core/register"
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
"scripts": {
|
|
84
|
+
"artifacts": "napi artifacts",
|
|
85
|
+
"create-npm-dirs": "napi create-npm-dirs",
|
|
86
|
+
"bench": "node --import @oxc-node/core/register benchmark/bench.ts",
|
|
87
|
+
"build": "napi build --platform --release",
|
|
88
|
+
"build:wasm": "napi build --platform --target wasm32-wasip1-threads --release",
|
|
89
|
+
"build:debug": "napi build --platform",
|
|
90
|
+
"format": "run-p format:prettier",
|
|
91
|
+
"format:fix": "oxlint --fix",
|
|
92
|
+
"format:prettier": "prettier . -w",
|
|
93
|
+
"format:toml": "taplo format",
|
|
94
|
+
"lint": "oxlint",
|
|
95
|
+
"test": "vitest run",
|
|
96
|
+
"test:local": "vitest run",
|
|
97
|
+
"test:watch": "vitest watch",
|
|
98
|
+
"version": "napi version"
|
|
99
|
+
}
|
|
100
|
+
}
|