@mermanjs/node 0.8.0-alpha.5 → 0.8.0-alpha.6

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.ts CHANGED
@@ -7,6 +7,10 @@ export type MermanResourceProfile =
7
7
  export interface MermanBindingOptions {
8
8
  version?: 2;
9
9
  runtime_policy?: "deterministic";
10
+ environment?: {
11
+ text_measurement?: "deterministic";
12
+ [key: string]: unknown;
13
+ };
10
14
  resources?: {
11
15
  profile?: MermanResourceProfile;
12
16
  limits?: Record<string, number>;
@@ -22,10 +26,17 @@ export interface CreateNodeEngineOptions {
22
26
 
23
27
  export interface RenderSvgOptions {
24
28
  /**
25
- * Cancels only while the request is waiting in the JS queue. Work that has started is not
26
- * preempted and its Promise settles with the actual operation result.
29
+ * Cancels queued work immediately and requests cooperative cancellation after Rust work starts.
30
+ * A queued request rejects with AbortError; a started request rejects with MermanOperationError
31
+ * carrying canonical cancellation details once transport admission or a renderer checkpoint
32
+ * observes the request.
27
33
  */
28
34
  signal?: AbortSignal;
35
+ /**
36
+ * Relative monotonic deadline in milliseconds, starting when the Rust transport admits the
37
+ * operation. Values must be integers from 0 through 4,294,967,295.
38
+ */
39
+ timeoutMs?: number;
29
40
  /** Raw per-request options JSON merged by the shared binding contract. */
30
41
  optionsJson?: string;
31
42
  }
@@ -184,9 +195,12 @@ export declare class MermanEngine {
184
195
  metadataJson(id: string): string;
185
196
  executeOperation(
186
197
  request: MermanOperationRequest,
187
- options?: Pick<RenderSvgOptions, "signal">,
198
+ options?: Pick<RenderSvgOptions, "signal" | "timeoutMs">,
188
199
  ): Promise<MermanOperationResult>;
189
- executeOperationSync(request: MermanOperationRequest): MermanOperationResult;
200
+ executeOperationSync(
201
+ request: MermanOperationRequest,
202
+ options?: Pick<RenderSvgOptions, "timeoutMs">,
203
+ ): MermanOperationResult;
190
204
  dispose(): Promise<void>;
191
205
  }
192
206
 
@@ -213,12 +227,38 @@ export interface MermanResourceErrorDetails {
213
227
  readonly profile: string;
214
228
  }
215
229
 
230
+ export interface MermanDiagnosticSpan {
231
+ readonly start: number;
232
+ readonly end: number;
233
+ readonly kind: "exact" | "insertion-point" | "fallback" | string;
234
+ }
235
+
236
+ export interface MermanDiagnosticErrorDetails {
237
+ readonly code: string;
238
+ readonly span: MermanDiagnosticSpan | null;
239
+ readonly field: string | null;
240
+ readonly diagram_type: string | null;
241
+ readonly requested_max_width?: number | null;
242
+ readonly actual_width?: number | null;
243
+ readonly width_profile?: string | null;
244
+ readonly fallback_reason?: string | null;
245
+ }
246
+
247
+ export interface MermanCancellationErrorDetails {
248
+ readonly reason: "requested" | "deadline_exceeded";
249
+ /** Renderer phase identifier; new Merman versions may add phases. */
250
+ readonly phase: string;
251
+ readonly [key: string]: unknown;
252
+ }
253
+
216
254
  export declare class MermanOperationError extends MermanError {
217
255
  readonly status: number | null;
218
256
  readonly codeName: string | null;
219
257
  readonly kind: "generic" | "unknown-operation" | "missing-capability" | string;
220
258
  readonly capabilityId: string | null;
221
259
  readonly resourceDetails: MermanResourceErrorDetails | null;
260
+ readonly diagnosticDetails: MermanDiagnosticErrorDetails | null;
261
+ readonly cancellationDetails: MermanCancellationErrorDetails | null;
222
262
  }
223
263
 
224
264
  export declare class MermanQueueSaturatedError extends MermanError {
@@ -232,6 +272,10 @@ export declare class MermanMissingPlatformPackageError extends MermanError {
232
272
  readonly packageName: string;
233
273
  readonly target: string;
234
274
  }
275
+ export declare class MermanNativeLoadError extends MermanError {
276
+ readonly packageName: string;
277
+ readonly target: string;
278
+ }
235
279
  export declare class MermanUnsupportedTargetError extends MermanError {
236
280
  readonly platform: string;
237
281
  readonly arch: string;
package/dist/index.mjs CHANGED
@@ -16,6 +16,7 @@ export {
16
16
  MermanInvalidTransportError,
17
17
  MermanLifecycleError,
18
18
  MermanMissingPlatformPackageError,
19
+ MermanNativeLoadError,
19
20
  MermanOperationError,
20
21
  MermanQueueSaturatedError,
21
22
  MermanUnsupportedTargetError,
@@ -3,6 +3,7 @@ import { createRequire } from "node:module";
3
3
  import {
4
4
  MermanInvalidTransportError,
5
5
  MermanMissingPlatformPackageError,
6
+ MermanNativeLoadError,
6
7
  MermanUnsupportedTargetError,
7
8
  parseRuntimeCatalogJsonText,
8
9
  } from "./errors.mjs";
@@ -79,6 +80,9 @@ export function loadNativeBinding({
79
80
  if (isMissingModule(cause)) {
80
81
  throw new MermanMissingPlatformPackageError({ packageName, target, cause });
81
82
  }
83
+ if (isNativeLoadFailure(cause)) {
84
+ throw new MermanNativeLoadError({ packageName, target, cause });
85
+ }
82
86
  throw cause;
83
87
  }
84
88
  }
@@ -110,3 +114,12 @@ function isMissingModule(error) {
110
114
  (error.code === "MODULE_NOT_FOUND" || error.code === "ERR_MODULE_NOT_FOUND"),
111
115
  );
112
116
  }
117
+
118
+ function isNativeLoadFailure(error) {
119
+ if (!error || typeof error !== "object") return false;
120
+ if (error.code === "ERR_DLOPEN_FAILED") return true;
121
+ return typeof error.message === "string" &&
122
+ /(?:GLIBC(?:XX)?_|CXXABI_|invalid ELF|wrong ELF|shared object file|not a valid Win32|mach-?o)/i.test(
123
+ error.message,
124
+ );
125
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mermanjs/node",
3
- "version": "0.8.0-alpha.5",
3
+ "version": "0.8.0-alpha.6",
4
4
  "description": "Experimental native Node.js and static-site rendering bindings for Merman.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -41,10 +41,10 @@
41
41
  ],
42
42
  "license": "MIT OR Apache-2.0",
43
43
  "optionalDependencies": {
44
- "@mermanjs/node-darwin-arm64": "0.8.0-alpha.5",
45
- "@mermanjs/node-darwin-x64": "0.8.0-alpha.5",
46
- "@mermanjs/node-linux-x64-gnu": "0.8.0-alpha.5",
47
- "@mermanjs/node-linux-x64-musl": "0.8.0-alpha.5",
48
- "@mermanjs/node-win32-x64-msvc": "0.8.0-alpha.5"
44
+ "@mermanjs/node-darwin-arm64": "0.8.0-alpha.6",
45
+ "@mermanjs/node-darwin-x64": "0.8.0-alpha.6",
46
+ "@mermanjs/node-linux-x64-gnu": "0.8.0-alpha.6",
47
+ "@mermanjs/node-linux-x64-musl": "0.8.0-alpha.6",
48
+ "@mermanjs/node-win32-x64-msvc": "0.8.0-alpha.6"
49
49
  }
50
50
  }