@publier/native 2.0.0 → 2.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/dist/index.d.mts +2 -3
- package/index.js +207 -83
- package/package.json +3 -3
- package/publier-native.linux-x64-gnu.node +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
//#region \0rolldown/runtime.js
|
|
3
2
|
//#endregion
|
|
4
3
|
//#region ts/core/analytics.d.ts
|
|
5
4
|
interface Ga4Config {
|
|
@@ -146,10 +145,10 @@ declare function clamp(value: string, max: number): string;
|
|
|
146
145
|
declare function generateOgImage(options: OgImageOptions): Promise<Uint8Array>;
|
|
147
146
|
//#endregion
|
|
148
147
|
//#region ts/core/publier-config.d.ts
|
|
149
|
-
declare const TOGGLEABLE_PAGES: readonly [
|
|
148
|
+
declare const TOGGLEABLE_PAGES: readonly ['docs', 'blog', 'landing', 'press', 'about', 'team', 'contact', 'careers', 'changelog', 'status', 'knowledge-base', '404'];
|
|
150
149
|
type ToggleablePage = (typeof TOGGLEABLE_PAGES)[number];
|
|
151
150
|
type PagesToggleMap = Partial<Record<ToggleablePage, boolean>>;
|
|
152
|
-
declare const APPEARANCE_DEFAULTS: readonly [
|
|
151
|
+
declare const APPEARANCE_DEFAULTS: readonly ['system', 'light', 'dark'];
|
|
153
152
|
type AppearanceDefault = (typeof APPEARANCE_DEFAULTS)[number];
|
|
154
153
|
interface AppearanceConfig {
|
|
155
154
|
default: AppearanceDefault;
|
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
|
|
5
|
-
const { readFileSync } = require('
|
|
5
|
+
const { readFileSync } = require('fs')
|
|
6
6
|
let nativeBinding = null
|
|
7
7
|
const loadErrors = []
|
|
8
8
|
|
|
@@ -32,7 +32,7 @@ const isMuslFromFilesystem = () => {
|
|
|
32
32
|
|
|
33
33
|
const isMuslFromReport = () => {
|
|
34
34
|
let report = null
|
|
35
|
-
if (typeof process.report
|
|
35
|
+
if (process.report && typeof process.report.getReport === 'function') {
|
|
36
36
|
process.report.excludeNetwork = true
|
|
37
37
|
report = process.report.getReport()
|
|
38
38
|
}
|
|
@@ -76,8 +76,8 @@ function requireNative() {
|
|
|
76
76
|
try {
|
|
77
77
|
const binding = require('@publier/native-android-arm64')
|
|
78
78
|
const bindingPackageVersion = require('@publier/native-android-arm64/package.json').version
|
|
79
|
-
if (bindingPackageVersion !== '2.
|
|
80
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
79
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
80
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
81
81
|
}
|
|
82
82
|
return binding
|
|
83
83
|
} catch (e) {
|
|
@@ -92,8 +92,8 @@ function requireNative() {
|
|
|
92
92
|
try {
|
|
93
93
|
const binding = require('@publier/native-android-arm-eabi')
|
|
94
94
|
const bindingPackageVersion = require('@publier/native-android-arm-eabi/package.json').version
|
|
95
|
-
if (bindingPackageVersion !== '2.
|
|
96
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
95
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
96
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
97
97
|
}
|
|
98
98
|
return binding
|
|
99
99
|
} catch (e) {
|
|
@@ -104,7 +104,7 @@ function requireNative() {
|
|
|
104
104
|
}
|
|
105
105
|
} else if (process.platform === 'win32') {
|
|
106
106
|
if (process.arch === 'x64') {
|
|
107
|
-
if (process.config
|
|
107
|
+
if ((process.config && process.config.variables && process.config.variables.shlib_suffix === 'dll.a') || (process.config && process.config.variables && process.config.variables.node_target_type === 'shared_library')) {
|
|
108
108
|
try {
|
|
109
109
|
return require('./publier-native.win32-x64-gnu.node')
|
|
110
110
|
} catch (e) {
|
|
@@ -113,8 +113,8 @@ function requireNative() {
|
|
|
113
113
|
try {
|
|
114
114
|
const binding = require('@publier/native-win32-x64-gnu')
|
|
115
115
|
const bindingPackageVersion = require('@publier/native-win32-x64-gnu/package.json').version
|
|
116
|
-
if (bindingPackageVersion !== '2.
|
|
117
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
116
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
117
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
118
118
|
}
|
|
119
119
|
return binding
|
|
120
120
|
} catch (e) {
|
|
@@ -129,8 +129,8 @@ function requireNative() {
|
|
|
129
129
|
try {
|
|
130
130
|
const binding = require('@publier/native-win32-x64-msvc')
|
|
131
131
|
const bindingPackageVersion = require('@publier/native-win32-x64-msvc/package.json').version
|
|
132
|
-
if (bindingPackageVersion !== '2.
|
|
133
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
132
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
133
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
134
134
|
}
|
|
135
135
|
return binding
|
|
136
136
|
} catch (e) {
|
|
@@ -146,8 +146,8 @@ function requireNative() {
|
|
|
146
146
|
try {
|
|
147
147
|
const binding = require('@publier/native-win32-ia32-msvc')
|
|
148
148
|
const bindingPackageVersion = require('@publier/native-win32-ia32-msvc/package.json').version
|
|
149
|
-
if (bindingPackageVersion !== '2.
|
|
150
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
149
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
150
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
151
151
|
}
|
|
152
152
|
return binding
|
|
153
153
|
} catch (e) {
|
|
@@ -162,8 +162,8 @@ function requireNative() {
|
|
|
162
162
|
try {
|
|
163
163
|
const binding = require('@publier/native-win32-arm64-msvc')
|
|
164
164
|
const bindingPackageVersion = require('@publier/native-win32-arm64-msvc/package.json').version
|
|
165
|
-
if (bindingPackageVersion !== '2.
|
|
166
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
165
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
166
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
167
167
|
}
|
|
168
168
|
return binding
|
|
169
169
|
} catch (e) {
|
|
@@ -181,8 +181,8 @@ function requireNative() {
|
|
|
181
181
|
try {
|
|
182
182
|
const binding = require('@publier/native-darwin-universal')
|
|
183
183
|
const bindingPackageVersion = require('@publier/native-darwin-universal/package.json').version
|
|
184
|
-
if (bindingPackageVersion !== '2.
|
|
185
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
184
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
185
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
186
186
|
}
|
|
187
187
|
return binding
|
|
188
188
|
} catch (e) {
|
|
@@ -197,8 +197,8 @@ function requireNative() {
|
|
|
197
197
|
try {
|
|
198
198
|
const binding = require('@publier/native-darwin-x64')
|
|
199
199
|
const bindingPackageVersion = require('@publier/native-darwin-x64/package.json').version
|
|
200
|
-
if (bindingPackageVersion !== '2.
|
|
201
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
200
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
201
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
202
202
|
}
|
|
203
203
|
return binding
|
|
204
204
|
} catch (e) {
|
|
@@ -213,8 +213,8 @@ function requireNative() {
|
|
|
213
213
|
try {
|
|
214
214
|
const binding = require('@publier/native-darwin-arm64')
|
|
215
215
|
const bindingPackageVersion = require('@publier/native-darwin-arm64/package.json').version
|
|
216
|
-
if (bindingPackageVersion !== '2.
|
|
217
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
216
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
217
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
218
218
|
}
|
|
219
219
|
return binding
|
|
220
220
|
} catch (e) {
|
|
@@ -233,8 +233,8 @@ function requireNative() {
|
|
|
233
233
|
try {
|
|
234
234
|
const binding = require('@publier/native-freebsd-x64')
|
|
235
235
|
const bindingPackageVersion = require('@publier/native-freebsd-x64/package.json').version
|
|
236
|
-
if (bindingPackageVersion !== '2.
|
|
237
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
236
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
237
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
238
238
|
}
|
|
239
239
|
return binding
|
|
240
240
|
} catch (e) {
|
|
@@ -249,8 +249,8 @@ function requireNative() {
|
|
|
249
249
|
try {
|
|
250
250
|
const binding = require('@publier/native-freebsd-arm64')
|
|
251
251
|
const bindingPackageVersion = require('@publier/native-freebsd-arm64/package.json').version
|
|
252
|
-
if (bindingPackageVersion !== '2.
|
|
253
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
252
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
253
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
254
254
|
}
|
|
255
255
|
return binding
|
|
256
256
|
} catch (e) {
|
|
@@ -270,8 +270,8 @@ function requireNative() {
|
|
|
270
270
|
try {
|
|
271
271
|
const binding = require('@publier/native-linux-x64-musl')
|
|
272
272
|
const bindingPackageVersion = require('@publier/native-linux-x64-musl/package.json').version
|
|
273
|
-
if (bindingPackageVersion !== '2.
|
|
274
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
273
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
274
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
275
275
|
}
|
|
276
276
|
return binding
|
|
277
277
|
} catch (e) {
|
|
@@ -286,8 +286,8 @@ function requireNative() {
|
|
|
286
286
|
try {
|
|
287
287
|
const binding = require('@publier/native-linux-x64-gnu')
|
|
288
288
|
const bindingPackageVersion = require('@publier/native-linux-x64-gnu/package.json').version
|
|
289
|
-
if (bindingPackageVersion !== '2.
|
|
290
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
289
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
290
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
291
291
|
}
|
|
292
292
|
return binding
|
|
293
293
|
} catch (e) {
|
|
@@ -304,8 +304,8 @@ function requireNative() {
|
|
|
304
304
|
try {
|
|
305
305
|
const binding = require('@publier/native-linux-arm64-musl')
|
|
306
306
|
const bindingPackageVersion = require('@publier/native-linux-arm64-musl/package.json').version
|
|
307
|
-
if (bindingPackageVersion !== '2.
|
|
308
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
307
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
308
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
309
309
|
}
|
|
310
310
|
return binding
|
|
311
311
|
} catch (e) {
|
|
@@ -320,8 +320,8 @@ function requireNative() {
|
|
|
320
320
|
try {
|
|
321
321
|
const binding = require('@publier/native-linux-arm64-gnu')
|
|
322
322
|
const bindingPackageVersion = require('@publier/native-linux-arm64-gnu/package.json').version
|
|
323
|
-
if (bindingPackageVersion !== '2.
|
|
324
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
323
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
324
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
325
325
|
}
|
|
326
326
|
return binding
|
|
327
327
|
} catch (e) {
|
|
@@ -338,8 +338,8 @@ function requireNative() {
|
|
|
338
338
|
try {
|
|
339
339
|
const binding = require('@publier/native-linux-arm-musleabihf')
|
|
340
340
|
const bindingPackageVersion = require('@publier/native-linux-arm-musleabihf/package.json').version
|
|
341
|
-
if (bindingPackageVersion !== '2.
|
|
342
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
341
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
342
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
343
343
|
}
|
|
344
344
|
return binding
|
|
345
345
|
} catch (e) {
|
|
@@ -354,8 +354,8 @@ function requireNative() {
|
|
|
354
354
|
try {
|
|
355
355
|
const binding = require('@publier/native-linux-arm-gnueabihf')
|
|
356
356
|
const bindingPackageVersion = require('@publier/native-linux-arm-gnueabihf/package.json').version
|
|
357
|
-
if (bindingPackageVersion !== '2.
|
|
358
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
357
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
358
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
359
359
|
}
|
|
360
360
|
return binding
|
|
361
361
|
} catch (e) {
|
|
@@ -372,8 +372,8 @@ function requireNative() {
|
|
|
372
372
|
try {
|
|
373
373
|
const binding = require('@publier/native-linux-loong64-musl')
|
|
374
374
|
const bindingPackageVersion = require('@publier/native-linux-loong64-musl/package.json').version
|
|
375
|
-
if (bindingPackageVersion !== '2.
|
|
376
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
375
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
376
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
377
377
|
}
|
|
378
378
|
return binding
|
|
379
379
|
} catch (e) {
|
|
@@ -388,8 +388,8 @@ function requireNative() {
|
|
|
388
388
|
try {
|
|
389
389
|
const binding = require('@publier/native-linux-loong64-gnu')
|
|
390
390
|
const bindingPackageVersion = require('@publier/native-linux-loong64-gnu/package.json').version
|
|
391
|
-
if (bindingPackageVersion !== '2.
|
|
392
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
391
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
392
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
393
393
|
}
|
|
394
394
|
return binding
|
|
395
395
|
} catch (e) {
|
|
@@ -406,8 +406,8 @@ function requireNative() {
|
|
|
406
406
|
try {
|
|
407
407
|
const binding = require('@publier/native-linux-riscv64-musl')
|
|
408
408
|
const bindingPackageVersion = require('@publier/native-linux-riscv64-musl/package.json').version
|
|
409
|
-
if (bindingPackageVersion !== '2.
|
|
410
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
409
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
410
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
411
411
|
}
|
|
412
412
|
return binding
|
|
413
413
|
} catch (e) {
|
|
@@ -422,8 +422,8 @@ function requireNative() {
|
|
|
422
422
|
try {
|
|
423
423
|
const binding = require('@publier/native-linux-riscv64-gnu')
|
|
424
424
|
const bindingPackageVersion = require('@publier/native-linux-riscv64-gnu/package.json').version
|
|
425
|
-
if (bindingPackageVersion !== '2.
|
|
426
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
425
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
426
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
427
427
|
}
|
|
428
428
|
return binding
|
|
429
429
|
} catch (e) {
|
|
@@ -439,8 +439,8 @@ function requireNative() {
|
|
|
439
439
|
try {
|
|
440
440
|
const binding = require('@publier/native-linux-ppc64-gnu')
|
|
441
441
|
const bindingPackageVersion = require('@publier/native-linux-ppc64-gnu/package.json').version
|
|
442
|
-
if (bindingPackageVersion !== '2.
|
|
443
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
442
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
443
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
444
444
|
}
|
|
445
445
|
return binding
|
|
446
446
|
} catch (e) {
|
|
@@ -455,8 +455,8 @@ function requireNative() {
|
|
|
455
455
|
try {
|
|
456
456
|
const binding = require('@publier/native-linux-s390x-gnu')
|
|
457
457
|
const bindingPackageVersion = require('@publier/native-linux-s390x-gnu/package.json').version
|
|
458
|
-
if (bindingPackageVersion !== '2.
|
|
459
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
458
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
459
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
460
460
|
}
|
|
461
461
|
return binding
|
|
462
462
|
} catch (e) {
|
|
@@ -475,8 +475,8 @@ function requireNative() {
|
|
|
475
475
|
try {
|
|
476
476
|
const binding = require('@publier/native-openharmony-arm64')
|
|
477
477
|
const bindingPackageVersion = require('@publier/native-openharmony-arm64/package.json').version
|
|
478
|
-
if (bindingPackageVersion !== '2.
|
|
479
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
478
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
479
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
480
480
|
}
|
|
481
481
|
return binding
|
|
482
482
|
} catch (e) {
|
|
@@ -491,8 +491,8 @@ function requireNative() {
|
|
|
491
491
|
try {
|
|
492
492
|
const binding = require('@publier/native-openharmony-x64')
|
|
493
493
|
const bindingPackageVersion = require('@publier/native-openharmony-x64/package.json').version
|
|
494
|
-
if (bindingPackageVersion !== '2.
|
|
495
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
494
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
495
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
496
496
|
}
|
|
497
497
|
return binding
|
|
498
498
|
} catch (e) {
|
|
@@ -507,8 +507,8 @@ function requireNative() {
|
|
|
507
507
|
try {
|
|
508
508
|
const binding = require('@publier/native-openharmony-arm')
|
|
509
509
|
const bindingPackageVersion = require('@publier/native-openharmony-arm/package.json').version
|
|
510
|
-
if (bindingPackageVersion !== '2.
|
|
511
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
510
|
+
if (bindingPackageVersion !== '2.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
511
|
+
throw new Error(`Native binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
512
512
|
}
|
|
513
513
|
return binding
|
|
514
514
|
} catch (e) {
|
|
@@ -522,54 +522,178 @@ function requireNative() {
|
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
-
|
|
525
|
+
function createLoadErrorChain(errors) {
|
|
526
|
+
return errors.reduce((previous, current) => {
|
|
527
|
+
let message
|
|
528
|
+
try {
|
|
529
|
+
message =
|
|
530
|
+
current && typeof current.message === 'string'
|
|
531
|
+
? current.message
|
|
532
|
+
: String(current)
|
|
533
|
+
} catch {
|
|
534
|
+
message = 'Unknown error'
|
|
535
|
+
}
|
|
536
|
+
const error = new Error(message)
|
|
537
|
+
error.cause = previous
|
|
538
|
+
return error
|
|
539
|
+
}, null)
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// NAPI_RS_FORCE_WASI is a tri-state flag:
|
|
543
|
+
// unset / any other value → native binding preferred, WASI is only a fallback
|
|
544
|
+
// 'true' → prefer WASI, but retain native as a lazy fallback
|
|
545
|
+
// 'error' → require WASI without initializing a native fallback
|
|
546
|
+
// Treating any non-empty string as truthy (the historical behavior) meant
|
|
547
|
+
// NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
|
|
548
|
+
// the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
|
|
549
|
+
//
|
|
550
|
+
// NAPI_RS_WASI_FLAVOR selects one exact generated flavor and implies strict
|
|
551
|
+
// WASI loading. It never crosses into another flavor or falls back to native.
|
|
552
|
+
const __napiWasiFlavors = ["wasm32-wasi"]
|
|
553
|
+
const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR
|
|
554
|
+
const __napiWasiFlavorRequested =
|
|
555
|
+
typeof __napiWasiFlavor === 'string' && __napiWasiFlavor.length > 0
|
|
556
|
+
if (
|
|
557
|
+
__napiWasiFlavorRequested &&
|
|
558
|
+
__napiWasiFlavors.indexOf(__napiWasiFlavor) === -1
|
|
559
|
+
) {
|
|
560
|
+
throw new Error(
|
|
561
|
+
'Unsupported WASI flavor "' +
|
|
562
|
+
__napiWasiFlavor +
|
|
563
|
+
'". Available flavors: ' +
|
|
564
|
+
__napiWasiFlavors.join(', '),
|
|
565
|
+
)
|
|
566
|
+
}
|
|
567
|
+
const forceWasiError = process.env.NAPI_RS_FORCE_WASI === 'error'
|
|
568
|
+
const forceWasi =
|
|
569
|
+
process.env.NAPI_RS_FORCE_WASI === 'true' ||
|
|
570
|
+
forceWasiError ||
|
|
571
|
+
__napiWasiFlavorRequested
|
|
572
|
+
|
|
573
|
+
if (!forceWasi) {
|
|
574
|
+
nativeBinding = requireNative()
|
|
575
|
+
}
|
|
526
576
|
|
|
527
|
-
if (!nativeBinding ||
|
|
577
|
+
if (!nativeBinding || forceWasi) {
|
|
528
578
|
let wasiBinding = null
|
|
529
|
-
let
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
579
|
+
let wasiBindingLoaded = false
|
|
580
|
+
const wasiBindingErrors = []
|
|
581
|
+
const __napiWasiResolveCandidate = (specifier, isPackage, localArtifacts) => {
|
|
582
|
+
try {
|
|
583
|
+
require.resolve(specifier)
|
|
584
|
+
} catch (resolveError) {
|
|
585
|
+
if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
|
|
586
|
+
throw resolveError
|
|
587
|
+
}
|
|
588
|
+
if (isPackage) {
|
|
589
|
+
try {
|
|
590
|
+
require.resolve(specifier + '/package.json')
|
|
591
|
+
} catch (packageError) {
|
|
592
|
+
if (packageError && packageError.code === 'MODULE_NOT_FOUND') {
|
|
593
|
+
return resolveError
|
|
594
|
+
}
|
|
595
|
+
// An exports restriction proves the package exists even when its
|
|
596
|
+
// package.json is not public. Preserve the root resolution failure.
|
|
597
|
+
throw resolveError
|
|
598
|
+
}
|
|
599
|
+
// The package exists but its main/export target is broken.
|
|
600
|
+
throw resolveError
|
|
601
|
+
}
|
|
602
|
+
return resolveError
|
|
536
603
|
}
|
|
604
|
+
if (localArtifacts) {
|
|
605
|
+
let artifactError = null
|
|
606
|
+
for (let i = 0; i < localArtifacts.length; i++) {
|
|
607
|
+
try {
|
|
608
|
+
require.resolve(localArtifacts[i])
|
|
609
|
+
return null
|
|
610
|
+
} catch (resolveError) {
|
|
611
|
+
if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
|
|
612
|
+
throw resolveError
|
|
613
|
+
}
|
|
614
|
+
artifactError = resolveError
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
return artifactError
|
|
618
|
+
}
|
|
619
|
+
return null
|
|
537
620
|
}
|
|
538
|
-
if (!
|
|
621
|
+
if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
|
|
622
|
+
let candidateError = null
|
|
623
|
+
let candidateFailed = false
|
|
539
624
|
try {
|
|
540
|
-
|
|
541
|
-
|
|
625
|
+
candidateError = __napiWasiResolveCandidate('./publier-native.wasi.cjs', false, ["./publier-native.wasm32-wasi.debug.wasm","./publier-native.wasm32-wasi.wasm"])
|
|
626
|
+
candidateFailed = candidateError !== null
|
|
627
|
+
if (!candidateFailed) {
|
|
628
|
+
wasiBinding = require('./publier-native.wasi.cjs')
|
|
629
|
+
nativeBinding = wasiBinding
|
|
630
|
+
wasiBindingLoaded = true
|
|
631
|
+
}
|
|
542
632
|
} catch (err) {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
633
|
+
candidateError = err
|
|
634
|
+
candidateFailed = true
|
|
635
|
+
}
|
|
636
|
+
if (candidateFailed) {
|
|
637
|
+
wasiBindingErrors.push(candidateError)
|
|
638
|
+
loadErrors.push(candidateError)
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
|
|
642
|
+
let candidateError = null
|
|
643
|
+
let candidateFailed = false
|
|
644
|
+
try {
|
|
645
|
+
candidateError = __napiWasiResolveCandidate('@publier/native-wasm32-wasi', true, undefined)
|
|
646
|
+
candidateFailed = candidateError !== null
|
|
647
|
+
if (!candidateFailed) {
|
|
648
|
+
if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
649
|
+
const bindingPackageVersion = require('@publier/native-wasm32-wasi/package.json').version
|
|
650
|
+
if (bindingPackageVersion !== '2.1.1') {
|
|
651
|
+
throw new Error(`WASI binding package version mismatch, expected 2.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
652
|
+
}
|
|
548
653
|
}
|
|
549
|
-
|
|
654
|
+
wasiBinding = require('@publier/native-wasm32-wasi')
|
|
655
|
+
nativeBinding = wasiBinding
|
|
656
|
+
wasiBindingLoaded = true
|
|
550
657
|
}
|
|
658
|
+
} catch (err) {
|
|
659
|
+
candidateError = err
|
|
660
|
+
candidateFailed = true
|
|
661
|
+
}
|
|
662
|
+
if (candidateFailed) {
|
|
663
|
+
wasiBindingErrors.push(candidateError)
|
|
664
|
+
loadErrors.push(candidateError)
|
|
551
665
|
}
|
|
552
666
|
}
|
|
553
|
-
if (
|
|
554
|
-
|
|
555
|
-
|
|
667
|
+
if (
|
|
668
|
+
!wasiBindingLoaded &&
|
|
669
|
+
forceWasi &&
|
|
670
|
+
!forceWasiError &&
|
|
671
|
+
!__napiWasiFlavorRequested
|
|
672
|
+
) {
|
|
673
|
+
nativeBinding = requireNative()
|
|
674
|
+
}
|
|
675
|
+
if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
|
|
676
|
+
const error = new Error(
|
|
677
|
+
__napiWasiFlavorRequested
|
|
678
|
+
? 'WASI binding for flavor "' + __napiWasiFlavor + '" not found'
|
|
679
|
+
: 'WASI binding not found and NAPI_RS_FORCE_WASI is set to error',
|
|
680
|
+
)
|
|
681
|
+
error.cause = createLoadErrorChain(wasiBindingErrors)
|
|
556
682
|
throw error
|
|
557
683
|
}
|
|
558
684
|
}
|
|
559
685
|
|
|
560
686
|
if (!nativeBinding) {
|
|
561
687
|
if (loadErrors.length > 0) {
|
|
562
|
-
|
|
688
|
+
const error = new Error(
|
|
563
689
|
`Cannot find native binding. ` +
|
|
564
690
|
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
565
691
|
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
566
|
-
{
|
|
567
|
-
cause: loadErrors.reduce((err, cur) => {
|
|
568
|
-
cur.cause = err
|
|
569
|
-
return cur
|
|
570
|
-
}),
|
|
571
|
-
},
|
|
572
692
|
)
|
|
693
|
+
// assign instead of the `new Error(message, { cause })` options form,
|
|
694
|
+
// which Node < 16.9 silently ignores
|
|
695
|
+
error.cause = createLoadErrorChain(loadErrors)
|
|
696
|
+
throw error
|
|
573
697
|
}
|
|
574
698
|
throw new Error(`Failed to load native binding`)
|
|
575
699
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@publier/native",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "Publier native bindings — build, content, and OpenAPI utilities.",
|
|
6
6
|
"_filesRationale": "explicit napi/binary list: index.js + index.d.ts + .node binary names are exact public contract",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@napi-rs/cli": "^3.6.2",
|
|
43
43
|
"@types/node": "^22",
|
|
44
|
-
"tsdown": "^0.22.
|
|
45
|
-
"typescript": "^
|
|
44
|
+
"tsdown": "^0.22.14",
|
|
45
|
+
"typescript": "^7.0.2"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
Binary file
|