@vizejs/native 0.100.0 → 0.103.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,784 +1,140 @@
1
- // prettier-ignore
2
1
  /* eslint-disable */
3
2
  // @ts-nocheck
4
- /* auto-generated by NAPI-RS */
5
3
 
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;
4
+ const nativeBinding = require("./native-binding");
5
+ const tokenNativeBinding = {
6
+ buildDesignTokenMap: nativeBinding.buildDesignTokenMap,
7
+ findDependentDesignTokens: nativeBinding.findDependentDesignTokens,
8
+ flattenDesignTokenCategories: nativeBinding.flattenDesignTokenCategories,
9
+ generateDesignTokensMarkdown: nativeBinding.generateDesignTokensMarkdown,
10
+ parseDesignTokensFromJson: nativeBinding.parseDesignTokensFromJson,
11
+ parseDesignTokensFromPath: nativeBinding.parseDesignTokensFromPath,
12
+ resolveDesignTokenReferences: nativeBinding.resolveDesignTokenReferences,
13
+ validateDesignTokenReference: nativeBinding.validateDesignTokenReference,
22
14
  };
23
15
 
24
- const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
16
+ function parseJsonResult(value) {
17
+ return JSON.parse(value);
18
+ }
25
19
 
26
- const isMuslFromFilesystem = () => {
27
- try {
28
- return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
29
- } catch {
30
- return null;
31
- }
32
- };
20
+ function stringifyJsonArg(value) {
21
+ return JSON.stringify(value) ?? "null";
22
+ }
33
23
 
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
- };
24
+ function buildDesignTokenMap(categories) {
25
+ return parseJsonResult(tokenNativeBinding.buildDesignTokenMap(stringifyJsonArg(categories)));
26
+ }
53
27
 
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
- };
28
+ function findDependentDesignTokens(tokenMap, targetPath) {
29
+ return tokenNativeBinding.findDependentDesignTokens(stringifyJsonArg(tokenMap), targetPath);
30
+ }
31
+
32
+ function flattenDesignTokenCategories(categories) {
33
+ return parseJsonResult(
34
+ tokenNativeBinding.flattenDesignTokenCategories(stringifyJsonArg(categories)),
35
+ );
36
+ }
64
37
 
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("./vize-vitrine.android-arm64.node");
76
- } catch (e) {
77
- loadErrors.push(e);
78
- }
79
- try {
80
- const binding = require("@vizejs/native-android-arm64");
81
- const bindingPackageVersion = require("@vizejs/native-android-arm64/package.json").version;
82
- if (
83
- bindingPackageVersion !== "0.78.0" &&
84
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
85
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
86
- ) {
87
- throw new Error(
88
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
89
- );
90
- }
91
- return binding;
92
- } catch (e) {
93
- loadErrors.push(e);
94
- }
95
- } else if (process.arch === "arm") {
96
- try {
97
- return require("./vize-vitrine.android-arm-eabi.node");
98
- } catch (e) {
99
- loadErrors.push(e);
100
- }
101
- try {
102
- const binding = require("@vizejs/native-android-arm-eabi");
103
- const bindingPackageVersion =
104
- require("@vizejs/native-android-arm-eabi/package.json").version;
105
- if (
106
- bindingPackageVersion !== "0.78.0" &&
107
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
108
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
109
- ) {
110
- throw new Error(
111
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
112
- );
113
- }
114
- return binding;
115
- } catch (e) {
116
- loadErrors.push(e);
117
- }
118
- } else {
119
- loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`));
120
- }
121
- } else if (process.platform === "win32") {
122
- if (process.arch === "x64") {
123
- if (
124
- process.config?.variables?.shlib_suffix === "dll.a" ||
125
- process.config?.variables?.node_target_type === "shared_library"
126
- ) {
127
- try {
128
- return require("./vize-vitrine.win32-x64-gnu.node");
129
- } catch (e) {
130
- loadErrors.push(e);
131
- }
132
- try {
133
- const binding = require("@vizejs/native-win32-x64-gnu");
134
- const bindingPackageVersion =
135
- require("@vizejs/native-win32-x64-gnu/package.json").version;
136
- if (
137
- bindingPackageVersion !== "0.78.0" &&
138
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
139
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
140
- ) {
141
- throw new Error(
142
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
143
- );
144
- }
145
- return binding;
146
- } catch (e) {
147
- loadErrors.push(e);
148
- }
149
- } else {
150
- try {
151
- return require("./vize-vitrine.win32-x64-msvc.node");
152
- } catch (e) {
153
- loadErrors.push(e);
154
- }
155
- try {
156
- const binding = require("@vizejs/native-win32-x64-msvc");
157
- const bindingPackageVersion =
158
- require("@vizejs/native-win32-x64-msvc/package.json").version;
159
- if (
160
- bindingPackageVersion !== "0.78.0" &&
161
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
162
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
163
- ) {
164
- throw new Error(
165
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
166
- );
167
- }
168
- return binding;
169
- } catch (e) {
170
- loadErrors.push(e);
171
- }
172
- }
173
- } else if (process.arch === "ia32") {
174
- try {
175
- return require("./vize-vitrine.win32-ia32-msvc.node");
176
- } catch (e) {
177
- loadErrors.push(e);
178
- }
179
- try {
180
- const binding = require("@vizejs/native-win32-ia32-msvc");
181
- const bindingPackageVersion =
182
- require("@vizejs/native-win32-ia32-msvc/package.json").version;
183
- if (
184
- bindingPackageVersion !== "0.78.0" &&
185
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
186
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
187
- ) {
188
- throw new Error(
189
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
190
- );
191
- }
192
- return binding;
193
- } catch (e) {
194
- loadErrors.push(e);
195
- }
196
- } else if (process.arch === "arm64") {
197
- try {
198
- return require("./vize-vitrine.win32-arm64-msvc.node");
199
- } catch (e) {
200
- loadErrors.push(e);
201
- }
202
- try {
203
- const binding = require("@vizejs/native-win32-arm64-msvc");
204
- const bindingPackageVersion =
205
- require("@vizejs/native-win32-arm64-msvc/package.json").version;
206
- if (
207
- bindingPackageVersion !== "0.78.0" &&
208
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
209
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
210
- ) {
211
- throw new Error(
212
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
213
- );
214
- }
215
- return binding;
216
- } catch (e) {
217
- loadErrors.push(e);
218
- }
219
- } else {
220
- loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`));
221
- }
222
- } else if (process.platform === "darwin") {
223
- try {
224
- return require("./vize-vitrine.darwin-universal.node");
225
- } catch (e) {
226
- loadErrors.push(e);
227
- }
228
- try {
229
- const binding = require("@vizejs/native-darwin-universal");
230
- const bindingPackageVersion = require("@vizejs/native-darwin-universal/package.json").version;
231
- if (
232
- bindingPackageVersion !== "0.78.0" &&
233
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
234
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
235
- ) {
236
- throw new Error(
237
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
238
- );
239
- }
240
- return binding;
241
- } catch (e) {
242
- loadErrors.push(e);
243
- }
244
- if (process.arch === "x64") {
245
- try {
246
- return require("./vize-vitrine.darwin-x64.node");
247
- } catch (e) {
248
- loadErrors.push(e);
249
- }
250
- try {
251
- const binding = require("@vizejs/native-darwin-x64");
252
- const bindingPackageVersion = require("@vizejs/native-darwin-x64/package.json").version;
253
- if (
254
- bindingPackageVersion !== "0.78.0" &&
255
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
256
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
257
- ) {
258
- throw new Error(
259
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
260
- );
261
- }
262
- return binding;
263
- } catch (e) {
264
- loadErrors.push(e);
265
- }
266
- } else if (process.arch === "arm64") {
267
- try {
268
- return require("./vize-vitrine.darwin-arm64.node");
269
- } catch (e) {
270
- loadErrors.push(e);
271
- }
272
- try {
273
- const binding = require("@vizejs/native-darwin-arm64");
274
- const bindingPackageVersion = require("@vizejs/native-darwin-arm64/package.json").version;
275
- if (
276
- bindingPackageVersion !== "0.78.0" &&
277
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
278
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
279
- ) {
280
- throw new Error(
281
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
282
- );
283
- }
284
- return binding;
285
- } catch (e) {
286
- loadErrors.push(e);
287
- }
288
- } else {
289
- loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`));
290
- }
291
- } else if (process.platform === "freebsd") {
292
- if (process.arch === "x64") {
293
- try {
294
- return require("./vize-vitrine.freebsd-x64.node");
295
- } catch (e) {
296
- loadErrors.push(e);
297
- }
298
- try {
299
- const binding = require("@vizejs/native-freebsd-x64");
300
- const bindingPackageVersion = require("@vizejs/native-freebsd-x64/package.json").version;
301
- if (
302
- bindingPackageVersion !== "0.78.0" &&
303
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
304
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
305
- ) {
306
- throw new Error(
307
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
308
- );
309
- }
310
- return binding;
311
- } catch (e) {
312
- loadErrors.push(e);
313
- }
314
- } else if (process.arch === "arm64") {
315
- try {
316
- return require("./vize-vitrine.freebsd-arm64.node");
317
- } catch (e) {
318
- loadErrors.push(e);
319
- }
320
- try {
321
- const binding = require("@vizejs/native-freebsd-arm64");
322
- const bindingPackageVersion = require("@vizejs/native-freebsd-arm64/package.json").version;
323
- if (
324
- bindingPackageVersion !== "0.78.0" &&
325
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
326
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
327
- ) {
328
- throw new Error(
329
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
330
- );
331
- }
332
- return binding;
333
- } catch (e) {
334
- loadErrors.push(e);
335
- }
336
- } else {
337
- loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
338
- }
339
- } else if (process.platform === "linux") {
340
- if (process.arch === "x64") {
341
- if (isMusl()) {
342
- try {
343
- return require("./vize-vitrine.linux-x64-musl.node");
344
- } catch (e) {
345
- loadErrors.push(e);
346
- }
347
- try {
348
- const binding = require("@vizejs/native-linux-x64-musl");
349
- const bindingPackageVersion =
350
- require("@vizejs/native-linux-x64-musl/package.json").version;
351
- if (
352
- bindingPackageVersion !== "0.78.0" &&
353
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
354
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
355
- ) {
356
- throw new Error(
357
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
358
- );
359
- }
360
- return binding;
361
- } catch (e) {
362
- loadErrors.push(e);
363
- }
364
- } else {
365
- try {
366
- return require("./vize-vitrine.linux-x64-gnu.node");
367
- } catch (e) {
368
- loadErrors.push(e);
369
- }
370
- try {
371
- const binding = require("@vizejs/native-linux-x64-gnu");
372
- const bindingPackageVersion =
373
- require("@vizejs/native-linux-x64-gnu/package.json").version;
374
- if (
375
- bindingPackageVersion !== "0.78.0" &&
376
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
377
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
378
- ) {
379
- throw new Error(
380
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
381
- );
382
- }
383
- return binding;
384
- } catch (e) {
385
- loadErrors.push(e);
386
- }
387
- }
388
- } else if (process.arch === "arm64") {
389
- if (isMusl()) {
390
- try {
391
- return require("./vize-vitrine.linux-arm64-musl.node");
392
- } catch (e) {
393
- loadErrors.push(e);
394
- }
395
- try {
396
- const binding = require("@vizejs/native-linux-arm64-musl");
397
- const bindingPackageVersion =
398
- require("@vizejs/native-linux-arm64-musl/package.json").version;
399
- if (
400
- bindingPackageVersion !== "0.78.0" &&
401
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
402
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
403
- ) {
404
- throw new Error(
405
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
406
- );
407
- }
408
- return binding;
409
- } catch (e) {
410
- loadErrors.push(e);
411
- }
412
- } else {
413
- try {
414
- return require("./vize-vitrine.linux-arm64-gnu.node");
415
- } catch (e) {
416
- loadErrors.push(e);
417
- }
418
- try {
419
- const binding = require("@vizejs/native-linux-arm64-gnu");
420
- const bindingPackageVersion =
421
- require("@vizejs/native-linux-arm64-gnu/package.json").version;
422
- if (
423
- bindingPackageVersion !== "0.78.0" &&
424
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
425
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
426
- ) {
427
- throw new Error(
428
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
429
- );
430
- }
431
- return binding;
432
- } catch (e) {
433
- loadErrors.push(e);
434
- }
435
- }
436
- } else if (process.arch === "arm") {
437
- if (isMusl()) {
438
- try {
439
- return require("./vize-vitrine.linux-arm-musleabihf.node");
440
- } catch (e) {
441
- loadErrors.push(e);
442
- }
443
- try {
444
- const binding = require("@vizejs/native-linux-arm-musleabihf");
445
- const bindingPackageVersion =
446
- require("@vizejs/native-linux-arm-musleabihf/package.json").version;
447
- if (
448
- bindingPackageVersion !== "0.78.0" &&
449
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
450
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
451
- ) {
452
- throw new Error(
453
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
454
- );
455
- }
456
- return binding;
457
- } catch (e) {
458
- loadErrors.push(e);
459
- }
460
- } else {
461
- try {
462
- return require("./vize-vitrine.linux-arm-gnueabihf.node");
463
- } catch (e) {
464
- loadErrors.push(e);
465
- }
466
- try {
467
- const binding = require("@vizejs/native-linux-arm-gnueabihf");
468
- const bindingPackageVersion =
469
- require("@vizejs/native-linux-arm-gnueabihf/package.json").version;
470
- if (
471
- bindingPackageVersion !== "0.78.0" &&
472
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
473
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
474
- ) {
475
- throw new Error(
476
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
477
- );
478
- }
479
- return binding;
480
- } catch (e) {
481
- loadErrors.push(e);
482
- }
483
- }
484
- } else if (process.arch === "loong64") {
485
- if (isMusl()) {
486
- try {
487
- return require("./vize-vitrine.linux-loong64-musl.node");
488
- } catch (e) {
489
- loadErrors.push(e);
490
- }
491
- try {
492
- const binding = require("@vizejs/native-linux-loong64-musl");
493
- const bindingPackageVersion =
494
- require("@vizejs/native-linux-loong64-musl/package.json").version;
495
- if (
496
- bindingPackageVersion !== "0.78.0" &&
497
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
498
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
499
- ) {
500
- throw new Error(
501
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
502
- );
503
- }
504
- return binding;
505
- } catch (e) {
506
- loadErrors.push(e);
507
- }
508
- } else {
509
- try {
510
- return require("./vize-vitrine.linux-loong64-gnu.node");
511
- } catch (e) {
512
- loadErrors.push(e);
513
- }
514
- try {
515
- const binding = require("@vizejs/native-linux-loong64-gnu");
516
- const bindingPackageVersion =
517
- require("@vizejs/native-linux-loong64-gnu/package.json").version;
518
- if (
519
- bindingPackageVersion !== "0.78.0" &&
520
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
521
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
522
- ) {
523
- throw new Error(
524
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
525
- );
526
- }
527
- return binding;
528
- } catch (e) {
529
- loadErrors.push(e);
530
- }
531
- }
532
- } else if (process.arch === "riscv64") {
533
- if (isMusl()) {
534
- try {
535
- return require("./vize-vitrine.linux-riscv64-musl.node");
536
- } catch (e) {
537
- loadErrors.push(e);
538
- }
539
- try {
540
- const binding = require("@vizejs/native-linux-riscv64-musl");
541
- const bindingPackageVersion =
542
- require("@vizejs/native-linux-riscv64-musl/package.json").version;
543
- if (
544
- bindingPackageVersion !== "0.78.0" &&
545
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
546
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
547
- ) {
548
- throw new Error(
549
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
550
- );
551
- }
552
- return binding;
553
- } catch (e) {
554
- loadErrors.push(e);
555
- }
556
- } else {
557
- try {
558
- return require("./vize-vitrine.linux-riscv64-gnu.node");
559
- } catch (e) {
560
- loadErrors.push(e);
561
- }
562
- try {
563
- const binding = require("@vizejs/native-linux-riscv64-gnu");
564
- const bindingPackageVersion =
565
- require("@vizejs/native-linux-riscv64-gnu/package.json").version;
566
- if (
567
- bindingPackageVersion !== "0.78.0" &&
568
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
569
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
570
- ) {
571
- throw new Error(
572
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
573
- );
574
- }
575
- return binding;
576
- } catch (e) {
577
- loadErrors.push(e);
578
- }
579
- }
580
- } else if (process.arch === "ppc64") {
581
- try {
582
- return require("./vize-vitrine.linux-ppc64-gnu.node");
583
- } catch (e) {
584
- loadErrors.push(e);
585
- }
586
- try {
587
- const binding = require("@vizejs/native-linux-ppc64-gnu");
588
- const bindingPackageVersion =
589
- require("@vizejs/native-linux-ppc64-gnu/package.json").version;
590
- if (
591
- bindingPackageVersion !== "0.78.0" &&
592
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
593
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
594
- ) {
595
- throw new Error(
596
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
597
- );
598
- }
599
- return binding;
600
- } catch (e) {
601
- loadErrors.push(e);
602
- }
603
- } else if (process.arch === "s390x") {
604
- try {
605
- return require("./vize-vitrine.linux-s390x-gnu.node");
606
- } catch (e) {
607
- loadErrors.push(e);
608
- }
609
- try {
610
- const binding = require("@vizejs/native-linux-s390x-gnu");
611
- const bindingPackageVersion =
612
- require("@vizejs/native-linux-s390x-gnu/package.json").version;
613
- if (
614
- bindingPackageVersion !== "0.78.0" &&
615
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
616
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
617
- ) {
618
- throw new Error(
619
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
620
- );
621
- }
622
- return binding;
623
- } catch (e) {
624
- loadErrors.push(e);
625
- }
626
- } else {
627
- loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`));
628
- }
629
- } else if (process.platform === "openharmony") {
630
- if (process.arch === "arm64") {
631
- try {
632
- return require("./vize-vitrine.openharmony-arm64.node");
633
- } catch (e) {
634
- loadErrors.push(e);
635
- }
636
- try {
637
- const binding = require("@vizejs/native-openharmony-arm64");
638
- const bindingPackageVersion =
639
- require("@vizejs/native-openharmony-arm64/package.json").version;
640
- if (
641
- bindingPackageVersion !== "0.78.0" &&
642
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
643
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
644
- ) {
645
- throw new Error(
646
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
647
- );
648
- }
649
- return binding;
650
- } catch (e) {
651
- loadErrors.push(e);
652
- }
653
- } else if (process.arch === "x64") {
654
- try {
655
- return require("./vize-vitrine.openharmony-x64.node");
656
- } catch (e) {
657
- loadErrors.push(e);
658
- }
659
- try {
660
- const binding = require("@vizejs/native-openharmony-x64");
661
- const bindingPackageVersion =
662
- require("@vizejs/native-openharmony-x64/package.json").version;
663
- if (
664
- bindingPackageVersion !== "0.78.0" &&
665
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
666
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
667
- ) {
668
- throw new Error(
669
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
670
- );
671
- }
672
- return binding;
673
- } catch (e) {
674
- loadErrors.push(e);
675
- }
676
- } else if (process.arch === "arm") {
677
- try {
678
- return require("./vize-vitrine.openharmony-arm.node");
679
- } catch (e) {
680
- loadErrors.push(e);
681
- }
682
- try {
683
- const binding = require("@vizejs/native-openharmony-arm");
684
- const bindingPackageVersion =
685
- require("@vizejs/native-openharmony-arm/package.json").version;
686
- if (
687
- bindingPackageVersion !== "0.78.0" &&
688
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
689
- process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
690
- ) {
691
- throw new Error(
692
- `Native binding package version mismatch, expected 0.78.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
693
- );
694
- }
695
- return binding;
696
- } catch (e) {
697
- loadErrors.push(e);
698
- }
699
- } else {
700
- loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
701
- }
702
- } else {
703
- loadErrors.push(
704
- new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`),
705
- );
706
- }
38
+ function generateDesignTokensMarkdown(categories, generatedAt) {
39
+ return tokenNativeBinding.generateDesignTokensMarkdown(stringifyJsonArg(categories), generatedAt);
707
40
  }
708
41
 
709
- nativeBinding = requireNative();
42
+ function parseDesignTokensFromJson(source) {
43
+ return parseJsonResult(tokenNativeBinding.parseDesignTokensFromJson(source));
44
+ }
45
+
46
+ function parseDesignTokensFromPath(tokensPath) {
47
+ return parseJsonResult(tokenNativeBinding.parseDesignTokensFromPath(tokensPath));
48
+ }
710
49
 
711
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
712
- let wasiBinding = null;
713
- let wasiBindingError = null;
714
- try {
715
- wasiBinding = require("./vize-vitrine.wasi.cjs");
716
- nativeBinding = wasiBinding;
717
- } catch (err) {
718
- if (process.env.NAPI_RS_FORCE_WASI) {
719
- wasiBindingError = err;
720
- }
721
- }
722
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
723
- try {
724
- wasiBinding = require("@vizejs/native-wasm32-wasi");
725
- nativeBinding = wasiBinding;
726
- } catch (err) {
727
- if (process.env.NAPI_RS_FORCE_WASI) {
728
- if (!wasiBindingError) {
729
- wasiBindingError = err;
730
- } else {
731
- wasiBindingError.cause = err;
732
- }
733
- loadErrors.push(err);
734
- }
735
- }
736
- }
737
- if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
738
- const error = new Error("WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
739
- error.cause = wasiBindingError;
740
- throw error;
741
- }
50
+ function resolveDesignTokenReferences(categories) {
51
+ return parseJsonResult(
52
+ tokenNativeBinding.resolveDesignTokenReferences(stringifyJsonArg(categories)),
53
+ );
742
54
  }
743
55
 
744
- if (!nativeBinding) {
745
- if (loadErrors.length > 0) {
746
- throw new Error(
747
- `Cannot find native binding. ` +
748
- `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
749
- "Please try `npm i` again after removing both package-lock.json and node_modules directory.",
750
- {
751
- cause: loadErrors.reduce((err, cur) => {
752
- cur.cause = err;
753
- return cur;
754
- }),
755
- },
756
- );
757
- }
758
- throw new Error(`Failed to load native binding`);
56
+ function validateDesignTokenReference(tokenMap, reference, selfPath) {
57
+ return parseJsonResult(
58
+ tokenNativeBinding.validateDesignTokenReference(
59
+ stringifyJsonArg(tokenMap),
60
+ reference,
61
+ selfPath,
62
+ ),
63
+ );
759
64
  }
760
65
 
761
66
  module.exports = nativeBinding;
762
67
  module.exports.artToCsf = nativeBinding.artToCsf;
68
+ module.exports.applyViteDefineReplacements = nativeBinding.applyViteDefineReplacements;
69
+ module.exports.buildDesignTokenMap = buildDesignTokenMap;
70
+ module.exports.classifyVitePluginRequest = nativeBinding.classifyVitePluginRequest;
71
+ module.exports.chunkVitePrecompileFiles = nativeBinding.chunkVitePrecompileFiles;
72
+ module.exports.collectSfcTemplateAssetUrls = nativeBinding.collectSfcTemplateAssetUrls;
763
73
  module.exports.compile = nativeBinding.compile;
764
74
  module.exports.compileCss = nativeBinding.compileCss;
765
75
  module.exports.compileSfc = nativeBinding.compileSfc;
766
76
  module.exports.compileSfcBatch = nativeBinding.compileSfcBatch;
767
77
  module.exports.compileSfcBatchWithResults = nativeBinding.compileSfcBatchWithResults;
768
78
  module.exports.compileVapor = nativeBinding.compileVapor;
79
+ module.exports.createViteBareImportBases = nativeBinding.createViteBareImportBases;
80
+ module.exports.createViteBareImportCandidates = nativeBinding.createViteBareImportCandidates;
81
+ module.exports.createViteVirtualId = nativeBinding.createViteVirtualId;
82
+ module.exports.detectViteHmrUpdateType = nativeBinding.detectViteHmrUpdateType;
83
+ module.exports.diffVitePrecompileFiles = nativeBinding.diffVitePrecompileFiles;
84
+ module.exports.extractSfcCustomBlocks = nativeBinding.extractSfcCustomBlocks;
85
+ module.exports.extractSfcSrcInfo = nativeBinding.extractSfcSrcInfo;
86
+ module.exports.extractSfcStyleBlocks = nativeBinding.extractSfcStyleBlocks;
87
+ module.exports.findDependentDesignTokens = findDependentDesignTokens;
88
+ module.exports.flattenDesignTokenCategories = flattenDesignTokenCategories;
769
89
  module.exports.formatSfc = nativeBinding.formatSfc;
90
+ module.exports.fromViteVirtualId = nativeBinding.fromViteVirtualId;
770
91
  module.exports.generateArtCatalog = nativeBinding.generateArtCatalog;
771
92
  module.exports.generateArtDoc = nativeBinding.generateArtDoc;
772
93
  module.exports.generateArtDocsBatch = nativeBinding.generateArtDocsBatch;
773
94
  module.exports.generateArtPalette = nativeBinding.generateArtPalette;
95
+ module.exports.generateDesignTokensMarkdown = generateDesignTokensMarkdown;
774
96
  module.exports.generateDeclaration = nativeBinding.generateDeclaration;
97
+ module.exports.generateSfcScopeId = nativeBinding.generateSfcScopeId;
775
98
  module.exports.generateVariants = nativeBinding.generateVariants;
99
+ module.exports.generateViteHmrCode = nativeBinding.generateViteHmrCode;
776
100
  module.exports.getPatinaRules = nativeBinding.getPatinaRules;
777
101
  module.exports.getTypeCheckCapabilities = nativeBinding.getTypeCheckCapabilities;
102
+ module.exports.hasSfcScopedStyle = nativeBinding.hasSfcScopedStyle;
103
+ module.exports.hasVitePrecompileFileMetadataChanged =
104
+ nativeBinding.hasVitePrecompileFileMetadataChanged;
105
+ module.exports.hasViteHmrChanges = nativeBinding.hasViteHmrChanges;
106
+ module.exports.isBuiltinViteDefine = nativeBinding.isBuiltinViteDefine;
107
+ module.exports.isSfcImportableAssetUrl = nativeBinding.isSfcImportableAssetUrl;
108
+ module.exports.isViteBareSpecifier = nativeBinding.isViteBareSpecifier;
778
109
  module.exports.lint = nativeBinding.lint;
779
110
  module.exports.lintPatinaSfc = nativeBinding.lintPatinaSfc;
111
+ module.exports.normalizeViteFsIdForBuild = nativeBinding.normalizeViteFsIdForBuild;
112
+ module.exports.normalizeViteCssModuleFilename = nativeBinding.normalizeViteCssModuleFilename;
113
+ module.exports.normalizeViteDevMiddlewareUrl = nativeBinding.normalizeViteDevMiddlewareUrl;
114
+ module.exports.normalizeVitePrecompileBatchSize = nativeBinding.normalizeVitePrecompileBatchSize;
115
+ module.exports.normalizeViteRequireBase = nativeBinding.normalizeViteRequireBase;
116
+ module.exports.normalizeViteResolvedVuePath = nativeBinding.normalizeViteResolvedVuePath;
117
+ module.exports.normalizeViteVirtualVueModuleId = nativeBinding.normalizeViteVirtualVueModuleId;
780
118
  module.exports.parseArt = nativeBinding.parseArt;
119
+ module.exports.parseDesignTokensFromJson = parseDesignTokensFromJson;
120
+ module.exports.parseDesignTokensFromPath = parseDesignTokensFromPath;
781
121
  module.exports.parseSfc = nativeBinding.parseSfc;
782
122
  module.exports.parseTemplate = nativeBinding.parseTemplate;
123
+ module.exports.resolveDesignTokenReferences = resolveDesignTokenReferences;
124
+ module.exports.resolveViteAliasRequest = nativeBinding.resolveViteAliasRequest;
125
+ module.exports.resolveViteCssImports = nativeBinding.resolveViteCssImports;
126
+ module.exports.resolveViteRelativeImport = nativeBinding.resolveViteRelativeImport;
127
+ module.exports.resolveViteVuePath = nativeBinding.resolveViteVuePath;
128
+ module.exports.rewriteViteDynamicTemplateImports = nativeBinding.rewriteViteDynamicTemplateImports;
129
+ module.exports.rewriteViteStaticAssetUrls = nativeBinding.rewriteViteStaticAssetUrls;
130
+ module.exports.runCli = nativeBinding.runCli;
131
+ module.exports.scopeViteCssForPipeline = nativeBinding.scopeViteCssForPipeline;
132
+ module.exports.shouldApplyViteDefineInVirtualModule =
133
+ nativeBinding.shouldApplyViteDefineInVirtualModule;
134
+ module.exports.splitViteIdQuery = nativeBinding.splitViteIdQuery;
135
+ module.exports.stripSfcScopedCssComments = nativeBinding.stripSfcScopedCssComments;
136
+ module.exports.toViteBrowserImportPrefix = nativeBinding.toViteBrowserImportPrefix;
783
137
  module.exports.typeCheck = nativeBinding.typeCheck;
784
138
  module.exports.typeCheckBatch = nativeBinding.typeCheckBatch;
139
+ module.exports.validateDesignTokenReference = validateDesignTokenReference;
140
+ module.exports.wrapSfcScopedPreprocessorStyle = nativeBinding.wrapSfcScopedPreprocessorStyle;