@mermanjs/node-wasm 0.10.0 → 0.11.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.
@@ -119,6 +119,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
119
119
  "name": "version",
120
120
  "json_type": "unsigned-integer",
121
121
  "required": true,
122
+ "nullable": false,
122
123
  "integer_width_bits": 32,
123
124
  "open_value": false
124
125
  },
@@ -126,6 +127,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
126
127
  "name": "operation_id",
127
128
  "json_type": "string",
128
129
  "required": true,
130
+ "nullable": false,
129
131
  "integer_width_bits": null,
130
132
  "open_value": true
131
133
  },
@@ -133,6 +135,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
133
135
  "name": "media_type",
134
136
  "json_type": "string",
135
137
  "required": true,
138
+ "nullable": false,
136
139
  "integer_width_bits": null,
137
140
  "open_value": true
138
141
  },
@@ -140,6 +143,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
140
143
  "name": "runtime_policy",
141
144
  "json_type": "string",
142
145
  "required": true,
146
+ "nullable": false,
143
147
  "integer_width_bits": null,
144
148
  "open_value": true
145
149
  },
@@ -147,6 +151,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
147
151
  "name": "byte_length",
148
152
  "json_type": "unsigned-integer",
149
153
  "required": true,
154
+ "nullable": false,
150
155
  "integer_width_bits": 64,
151
156
  "open_value": false
152
157
  },
@@ -154,6 +159,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
154
159
  "name": "output_plan",
155
160
  "json_type": "object",
156
161
  "required": false,
162
+ "nullable": false,
157
163
  "integer_width_bits": null,
158
164
  "open_value": true
159
165
  },
@@ -161,6 +167,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
161
167
  "name": "layout_adaptation",
162
168
  "json_type": "object",
163
169
  "required": false,
170
+ "nullable": false,
164
171
  "integer_width_bits": null,
165
172
  "open_value": true
166
173
  },
@@ -168,6 +175,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
168
175
  "name": "theme_execution_evidence",
169
176
  "json_type": "object",
170
177
  "required": false,
178
+ "nullable": false,
171
179
  "integer_width_bits": null,
172
180
  "open_value": true
173
181
  }
@@ -180,6 +188,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
180
188
  "name": "kind",
181
189
  "json_type": "string",
182
190
  "required": true,
191
+ "nullable": false,
183
192
  "integer_width_bits": null,
184
193
  "open_value": false
185
194
  },
@@ -187,6 +196,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
187
196
  "name": "schema_version",
188
197
  "json_type": "unsigned-integer",
189
198
  "required": true,
199
+ "nullable": false,
190
200
  "integer_width_bits": 16,
191
201
  "open_value": false
192
202
  },
@@ -194,6 +204,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
194
204
  "name": "family",
195
205
  "json_type": "string",
196
206
  "required": true,
207
+ "nullable": false,
197
208
  "integer_width_bits": null,
198
209
  "open_value": true
199
210
  },
@@ -201,6 +212,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
201
212
  "name": "projection",
202
213
  "json_type": "string",
203
214
  "required": true,
215
+ "nullable": false,
204
216
  "integer_width_bits": null,
205
217
  "open_value": false
206
218
  },
@@ -208,6 +220,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
208
220
  "name": "encoding",
209
221
  "json_type": "string",
210
222
  "required": true,
223
+ "nullable": false,
211
224
  "integer_width_bits": null,
212
225
  "open_value": false
213
226
  },
@@ -215,6 +228,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
215
228
  "name": "primary_width",
216
229
  "json_type": "unsigned-integer",
217
230
  "required": true,
231
+ "nullable": true,
218
232
  "integer_width_bits": 64,
219
233
  "open_value": false
220
234
  },
@@ -222,6 +236,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
222
236
  "name": "primary_height",
223
237
  "json_type": "unsigned-integer",
224
238
  "required": true,
239
+ "nullable": true,
225
240
  "integer_width_bits": 64,
226
241
  "open_value": false
227
242
  },
@@ -229,6 +244,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
229
244
  "name": "emitted_width",
230
245
  "json_type": "unsigned-integer",
231
246
  "required": true,
247
+ "nullable": false,
232
248
  "integer_width_bits": 64,
233
249
  "open_value": false
234
250
  },
@@ -236,6 +252,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
236
252
  "name": "emitted_height",
237
253
  "json_type": "unsigned-integer",
238
254
  "required": true,
255
+ "nullable": false,
239
256
  "integer_width_bits": 64,
240
257
  "open_value": false
241
258
  },
@@ -243,6 +260,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
243
260
  "name": "width_profile",
244
261
  "json_type": "string",
245
262
  "required": true,
263
+ "nullable": false,
246
264
  "integer_width_bits": null,
247
265
  "open_value": false
248
266
  },
@@ -250,6 +268,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
250
268
  "name": "layout_profile",
251
269
  "json_type": "string",
252
270
  "required": true,
271
+ "nullable": true,
253
272
  "integer_width_bits": null,
254
273
  "open_value": false
255
274
  },
@@ -257,6 +276,15 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
257
276
  "name": "requested_layout_profile",
258
277
  "json_type": "string",
259
278
  "required": true,
279
+ "nullable": false,
280
+ "integer_width_bits": null,
281
+ "open_value": false
282
+ },
283
+ {
284
+ "name": "requested_graph_presentation",
285
+ "json_type": "string",
286
+ "required": true,
287
+ "nullable": false,
260
288
  "integer_width_bits": null,
261
289
  "open_value": false
262
290
  },
@@ -264,6 +292,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
264
292
  "name": "compact_attempted",
265
293
  "json_type": "boolean",
266
294
  "required": true,
295
+ "nullable": false,
267
296
  "integer_width_bits": null,
268
297
  "open_value": false
269
298
  },
@@ -271,13 +300,23 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
271
300
  "name": "requested_max_width",
272
301
  "json_type": "unsigned-integer",
273
302
  "required": false,
303
+ "nullable": false,
274
304
  "integer_width_bits": 64,
275
305
  "open_value": false
276
306
  },
277
307
  {
278
- "name": "overflowed",
308
+ "name": "primary_overflowed",
279
309
  "json_type": "boolean",
280
310
  "required": true,
311
+ "nullable": true,
312
+ "integer_width_bits": null,
313
+ "open_value": false
314
+ },
315
+ {
316
+ "name": "emitted_overflowed",
317
+ "json_type": "boolean",
318
+ "required": true,
319
+ "nullable": false,
281
320
  "integer_width_bits": null,
282
321
  "open_value": false
283
322
  },
@@ -285,6 +324,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
285
324
  "name": "outcome",
286
325
  "json_type": "string",
287
326
  "required": true,
327
+ "nullable": false,
288
328
  "integer_width_bits": null,
289
329
  "open_value": false
290
330
  },
@@ -292,6 +332,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
292
332
  "name": "fallback_capability",
293
333
  "json_type": "string",
294
334
  "required": true,
335
+ "nullable": false,
295
336
  "integer_width_bits": null,
296
337
  "open_value": false
297
338
  },
@@ -299,6 +340,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
299
340
  "name": "fallback_attempted",
300
341
  "json_type": "boolean",
301
342
  "required": true,
343
+ "nullable": false,
302
344
  "integer_width_bits": null,
303
345
  "open_value": false
304
346
  },
@@ -306,6 +348,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
306
348
  "name": "fallback_reason",
307
349
  "json_type": "string",
308
350
  "required": false,
351
+ "nullable": false,
309
352
  "integer_width_bits": null,
310
353
  "open_value": false
311
354
  },
@@ -313,6 +356,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
313
356
  "name": "trimmed",
314
357
  "json_type": "boolean",
315
358
  "required": true,
359
+ "nullable": false,
316
360
  "integer_width_bits": null,
317
361
  "open_value": false
318
362
  },
@@ -320,6 +364,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
320
364
  "name": "lossiness",
321
365
  "json_type": "string",
322
366
  "required": true,
367
+ "nullable": false,
323
368
  "integer_width_bits": null,
324
369
  "open_value": false
325
370
  }
@@ -332,6 +377,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
332
377
  "name": "kind",
333
378
  "json_type": "string",
334
379
  "required": true,
380
+ "nullable": false,
335
381
  "integer_width_bits": null,
336
382
  "open_value": false
337
383
  },
@@ -339,6 +385,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
339
385
  "name": "requested_width_px",
340
386
  "json_type": "number",
341
387
  "required": true,
388
+ "nullable": false,
342
389
  "integer_width_bits": null,
343
390
  "open_value": false
344
391
  },
@@ -346,6 +393,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
346
393
  "name": "requested_height_px",
347
394
  "json_type": "number",
348
395
  "required": true,
396
+ "nullable": false,
349
397
  "integer_width_bits": null,
350
398
  "open_value": false
351
399
  },
@@ -353,6 +401,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
353
401
  "name": "width_px",
354
402
  "json_type": "unsigned-integer",
355
403
  "required": true,
404
+ "nullable": false,
356
405
  "integer_width_bits": 32,
357
406
  "open_value": false
358
407
  },
@@ -360,6 +409,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
360
409
  "name": "height_px",
361
410
  "json_type": "unsigned-integer",
362
411
  "required": true,
412
+ "nullable": false,
363
413
  "integer_width_bits": 32,
364
414
  "open_value": false
365
415
  },
@@ -367,6 +417,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
367
417
  "name": "requested_scale",
368
418
  "json_type": "number",
369
419
  "required": true,
420
+ "nullable": false,
370
421
  "integer_width_bits": null,
371
422
  "open_value": false
372
423
  },
@@ -374,6 +425,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
374
425
  "name": "effective_scale",
375
426
  "json_type": "number",
376
427
  "required": true,
428
+ "nullable": false,
377
429
  "integer_width_bits": null,
378
430
  "open_value": false
379
431
  },
@@ -381,6 +433,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
381
433
  "name": "limited",
382
434
  "json_type": "boolean",
383
435
  "required": true,
436
+ "nullable": false,
384
437
  "integer_width_bits": null,
385
438
  "open_value": false
386
439
  }
@@ -393,6 +446,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
393
446
  "name": "kind",
394
447
  "json_type": "string",
395
448
  "required": true,
449
+ "nullable": false,
396
450
  "integer_width_bits": null,
397
451
  "open_value": false
398
452
  },
@@ -400,6 +454,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
400
454
  "name": "filtered_groups",
401
455
  "json_type": "unsigned-integer",
402
456
  "required": true,
457
+ "nullable": false,
403
458
  "integer_width_bits": 64,
404
459
  "open_value": false
405
460
  },
@@ -407,6 +462,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
407
462
  "name": "requested_scale",
408
463
  "json_type": "number",
409
464
  "required": true,
465
+ "nullable": false,
410
466
  "integer_width_bits": null,
411
467
  "open_value": false
412
468
  },
@@ -414,6 +470,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
414
470
  "name": "effective_scale",
415
471
  "json_type": "number",
416
472
  "required": true,
473
+ "nullable": false,
417
474
  "integer_width_bits": null,
418
475
  "open_value": false
419
476
  },
@@ -421,6 +478,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
421
478
  "name": "requested_image_pixels",
422
479
  "json_type": "unsigned-integer",
423
480
  "required": true,
481
+ "nullable": false,
424
482
  "integer_width_bits": 64,
425
483
  "open_value": false
426
484
  },
@@ -428,6 +486,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
428
486
  "name": "effective_image_pixels",
429
487
  "json_type": "unsigned-integer",
430
488
  "required": true,
489
+ "nullable": false,
431
490
  "integer_width_bits": 64,
432
491
  "open_value": false
433
492
  },
@@ -435,6 +494,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
435
494
  "name": "limited",
436
495
  "json_type": "boolean",
437
496
  "required": true,
497
+ "nullable": false,
438
498
  "integer_width_bits": null,
439
499
  "open_value": false
440
500
  }
@@ -449,6 +509,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
449
509
  "name": "version",
450
510
  "json_type": "unsigned-integer",
451
511
  "required": true,
512
+ "nullable": false,
452
513
  "integer_width_bits": 32,
453
514
  "open_value": false
454
515
  },
@@ -456,6 +517,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
456
517
  "name": "family_id",
457
518
  "json_type": "string",
458
519
  "required": true,
520
+ "nullable": false,
459
521
  "integer_width_bits": null,
460
522
  "open_value": true
461
523
  },
@@ -463,6 +525,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
463
525
  "name": "theme_status",
464
526
  "json_type": "string",
465
527
  "required": true,
528
+ "nullable": false,
466
529
  "integer_width_bits": null,
467
530
  "open_value": true
468
531
  },
@@ -470,6 +533,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
470
533
  "name": "output_mutated",
471
534
  "json_type": "boolean",
472
535
  "required": true,
536
+ "nullable": false,
473
537
  "integer_width_bits": null,
474
538
  "open_value": false
475
539
  },
@@ -477,6 +541,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
477
541
  "name": "target_kind",
478
542
  "json_type": "string",
479
543
  "required": true,
544
+ "nullable": false,
480
545
  "integer_width_bits": null,
481
546
  "open_value": true
482
547
  },
@@ -484,6 +549,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
484
549
  "name": "target_status",
485
550
  "json_type": "string",
486
551
  "required": true,
552
+ "nullable": false,
487
553
  "integer_width_bits": null,
488
554
  "open_value": true
489
555
  },
@@ -491,6 +557,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
491
557
  "name": "target_reason_ids",
492
558
  "json_type": "array",
493
559
  "required": true,
560
+ "nullable": false,
494
561
  "integer_width_bits": null,
495
562
  "open_value": true
496
563
  },
@@ -498,6 +565,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
498
565
  "name": "font_source",
499
566
  "json_type": "string",
500
567
  "required": true,
568
+ "nullable": false,
501
569
  "integer_width_bits": null,
502
570
  "open_value": true
503
571
  },
@@ -505,6 +573,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
505
573
  "name": "materialized_theme",
506
574
  "json_type": "string-or-null",
507
575
  "required": true,
576
+ "nullable": false,
508
577
  "integer_width_bits": null,
509
578
  "open_value": false
510
579
  },
@@ -512,6 +581,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
512
581
  "name": "diagnostics",
513
582
  "json_type": "array",
514
583
  "required": false,
584
+ "nullable": false,
515
585
  "integer_width_bits": null,
516
586
  "open_value": true
517
587
  }
@@ -526,6 +596,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
526
596
  "name": "mode",
527
597
  "json_type": "string",
528
598
  "required": true,
599
+ "nullable": false,
529
600
  "integer_width_bits": null,
530
601
  "open_value": true
531
602
  },
@@ -533,6 +604,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
533
604
  "name": "requested_width",
534
605
  "json_type": "number",
535
606
  "required": true,
607
+ "nullable": false,
536
608
  "integer_width_bits": null,
537
609
  "open_value": false
538
610
  },
@@ -540,6 +612,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
540
612
  "name": "actual_width",
541
613
  "json_type": "number",
542
614
  "required": true,
615
+ "nullable": false,
543
616
  "integer_width_bits": null,
544
617
  "open_value": false
545
618
  },
@@ -547,6 +620,7 @@ export const BINDING_OPERATION_METADATA_CONTRACT = {
547
620
  "name": "overflowed",
548
621
  "json_type": "boolean",
549
622
  "required": true,
623
+ "nullable": false,
550
624
  "integer_width_bits": null,
551
625
  "open_value": false
552
626
  }
@@ -898,6 +972,12 @@ export const BINDING_OPTION_GROUP_SPECS = [
898
972
  "any_capability_ids": [],
899
973
  "requires_svg_pipeline": false
900
974
  },
975
+ {
976
+ "id": "fixed_unix_millis",
977
+ "always_available": true,
978
+ "any_capability_ids": [],
979
+ "requires_svg_pipeline": false
980
+ },
901
981
  {
902
982
  "id": "jpeg",
903
983
  "always_available": false,
@@ -2,7 +2,7 @@
2
2
  "schema_version": 1,
3
3
  "package_id": "@mermanjs/node",
4
4
  "artifact_id": "merman-node-static-svg",
5
- "transport_api_version": 1,
5
+ "transport_api_version": 2,
6
6
  "binding_result_payload_version": 1,
7
7
  "artifact": {
8
8
  "capability_ids": [
@@ -42,6 +42,7 @@
42
42
  "environment",
43
43
  "fixed_local_offset_minutes",
44
44
  "fixed_today",
45
+ "fixed_unix_millis",
45
46
  "layout",
46
47
  "parse",
47
48
  "resources",
package/dist/index.d.ts CHANGED
@@ -4,9 +4,36 @@ export type MermanResourceProfile =
4
4
  | "trusted-native"
5
5
  | "unbounded-for-trusted-input";
6
6
 
7
+ export type MermanAsciiGraphPresentation = "strict" | "adaptive";
8
+
9
+ /** Options for the canonical `ascii` operation, also accepted through optionsJson. */
10
+ export interface MermanAsciiRenderOptions {
11
+ /** Defaults to strict. Adaptive is Plain-only for Flowchart, Swimlane, and State. */
12
+ graph_presentation?: MermanAsciiGraphPresentation;
13
+ graphPresentation?: MermanAsciiGraphPresentation;
14
+ /** State supports Canonical only; Auto requires a maximum width. */
15
+ layout_profile?: "canonical" | "compact" | "auto";
16
+ layoutProfile?: "canonical" | "compact" | "auto";
17
+ charset?: "ascii" | "unicode";
18
+ max_width?: number;
19
+ maxWidth?: number;
20
+ overflow?: "allow" | "fallback" | "error";
21
+ color_mode?:
22
+ | "plain" | "none"
23
+ | "ansi16" | "ansi-16" | "ansi_16"
24
+ | "ansi256" | "ansi-256" | "ansi_256"
25
+ | "truecolor" | "true-color" | "true_color" | "html";
26
+ colorMode?: MermanAsciiRenderOptions["color_mode"];
27
+ [key: string]: unknown;
28
+ }
29
+
7
30
  export interface MermanBindingOptions {
8
31
  version?: 3;
9
32
  runtime_policy?: "deterministic";
33
+ fixed_today?: string | null;
34
+ /** Exact host-supplied Unix milliseconds; mutually exclusive with a non-null fixed_today. */
35
+ fixed_unix_millis?: number | null;
36
+ fixed_local_offset_minutes?: number | null;
10
37
  environment?: {
11
38
  theme_portability?: "best-effort" | "require-portable";
12
39
  text_measurement?: "deterministic" | null;
@@ -18,6 +45,7 @@ export interface MermanBindingOptions {
18
45
  };
19
46
  /** A supplied selection replaces the complete constructor theme; null clears it. */
20
47
  theme?: DiagramThemeSelection | null;
48
+ ascii?: MermanAsciiRenderOptions;
21
49
  [key: string]: unknown;
22
50
  }
23
51
 
@@ -169,7 +197,11 @@ export interface MermanOperationRequest {
169
197
  operationId: string;
170
198
  source: string;
171
199
  uri?: string | null;
172
- /** Raw per-request options JSON merged over the reusable engine baseline. */
200
+ /**
201
+ * Raw per-request options JSON merged over the reusable engine baseline.
202
+ * For ASCII, use operationId "ascii" and JSON.stringify({ ascii: { graph_presentation: "adaptive" } }
203
+ * satisfies MermanBindingOptions). Admission is advertised by metadataJson("ascii-capabilities").
204
+ */
173
205
  optionsJson?: string;
174
206
  }
175
207
 
@@ -177,6 +209,7 @@ export interface MermanOperationResult {
177
209
  operation_id: string;
178
210
  media_type: string;
179
211
  data: string;
212
+ /** Canonical metadata JSON; ASCII output_plan uses report schema 4 within metadata version 1. */
180
213
  metadata_json: string;
181
214
  }
182
215
 
@@ -265,7 +298,7 @@ export interface MermanRuntimeConstructorServiceContract {
265
298
 
266
299
  export interface MermanRuntimeCatalog {
267
300
  schema_version: 1;
268
- transport_api_version: 1;
301
+ transport_api_version: 2;
269
302
  package_version: string;
270
303
  options_schema_versions: number[];
271
304
  payload_schemas: MermanRuntimePayloadSchema[];
@@ -5,8 +5,11 @@ import {
5
5
  MermanMissingPlatformPackageError,
6
6
  MermanNativeLoadError,
7
7
  MermanUnsupportedTargetError,
8
+ decodeWireCreationError,
8
9
  parseRuntimeCatalogJsonText,
10
+ validateTransportIdentityExport,
9
11
  } from "./errors.mjs";
12
+ import { wrapCandidateEngine } from "./candidates/wrap-engine.mjs";
10
13
 
11
14
  const TARGET_PACKAGES = Object.freeze({
12
15
  "darwin-arm64": "@mermanjs/node-darwin-arm64",
@@ -19,6 +22,8 @@ const TARGET_PACKAGES = Object.freeze({
19
22
  });
20
23
 
21
24
  const requireFromPackage = createRequire(import.meta.url);
25
+ // Only installed native addons can use the direct SVG input and result contract.
26
+ const directSvgTransports = new WeakSet();
22
27
  const loaderPackageManifest = requireFromPackage("../package.json");
23
28
  const loaderPackageVersion = loaderPackageManifest?.version;
24
29
 
@@ -89,6 +94,76 @@ export function loadNativeBinding({
89
94
  }
90
95
  }
91
96
 
97
+ export async function loadInstalledNativeTransport(optionsJson, iconPacksJson) {
98
+ let nativeAddon = false;
99
+ const binding = loadNativeBinding({
100
+ loadPackage(packageName) {
101
+ const entrypoint = requireFromPackage.resolve(packageName);
102
+ // The platform manifest loads the addon directly. JavaScript shims stay on the wire path.
103
+ nativeAddon = entrypoint.endsWith(".node");
104
+ return requireFromPackage(entrypoint);
105
+ },
106
+ });
107
+ const transport = await wrapNativeBinding(binding, optionsJson, iconPacksJson, {
108
+ directSvgAddon: nativeAddon,
109
+ });
110
+ if (nativeAddon) {
111
+ directSvgTransports.add(transport);
112
+ }
113
+ return transport;
114
+ }
115
+
116
+ export function supportsDirectNativeSvg(transport) {
117
+ return directSvgTransports.has(transport);
118
+ }
119
+
120
+ export async function wrapNativeBinding(
121
+ binding,
122
+ optionsJson,
123
+ iconPacksJson,
124
+ { directSvgAddon = false } = {},
125
+ ) {
126
+ const label = "The target-specific Merman addon";
127
+ const NativeEngine = binding?.NativeEngine ?? binding?.default?.NativeEngine;
128
+ if (typeof NativeEngine !== "function") {
129
+ throw new MermanInvalidTransportError(
130
+ "The target-specific Merman package does not export NativeEngine.",
131
+ );
132
+ }
133
+ validateTransportIdentityExport(binding?.transportIdentityJson, {
134
+ expectedPackageVersion: nodeLoaderPackageVersion(),
135
+ expectedTransport: "napi",
136
+ label: "The target-specific Merman package",
137
+ });
138
+ let transport;
139
+ try {
140
+ transport = wrapCandidateEngine(
141
+ iconPacksJson === undefined
142
+ ? new NativeEngine(optionsJson)
143
+ : new NativeEngine(optionsJson, iconPacksJson),
144
+ label,
145
+ { forwardsAbortSignal: true, directSvgAddon },
146
+ );
147
+ } catch (cause) {
148
+ throw decodeWireCreationError(cause, label);
149
+ }
150
+ try {
151
+ const runtimeCatalogJson = assertRuntimePackageVersion(transport.runtimeCatalogJson());
152
+ const wrapped = {
153
+ ...transport,
154
+ runtimeCatalogJson: () => runtimeCatalogJson,
155
+ };
156
+ return typeof wrapped.executeSvg === "function" ? Object.freeze(wrapped) : wrapped;
157
+ } catch (cause) {
158
+ try {
159
+ await transport.dispose();
160
+ } catch {
161
+ // Preserve the package-version failure that made the transport unusable.
162
+ }
163
+ throw cause;
164
+ }
165
+ }
166
+
92
167
  function linuxLibc(report, arch) {
93
168
  if (report?.header?.glibcVersionRuntime) return "gnu";
94
169
  if (
@@ -15,7 +15,7 @@ function validateContract(value) {
15
15
  value.schema_version !== 1 ||
16
16
  value.package_id !== "@mermanjs/node" ||
17
17
  value.artifact_id !== "merman-node-static-svg" ||
18
- value.transport_api_version !== 1 ||
18
+ value.transport_api_version !== 2 ||
19
19
  value.binding_result_payload_version !== 1 ||
20
20
  !value.artifact ||
21
21
  !value.documents ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mermanjs/node-wasm",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Explicit Node-targeted WebAssembly rendering package for Merman.",
5
5
  "type": "module",
6
6
  "engines": {