@mermanjs/node-wasm 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.
Files changed (54) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE-APACHE +201 -0
  3. package/LICENSE-MIT +21 -0
  4. package/README.md +47 -0
  5. package/THIRD_PARTY_LICENSES/beautiful-mermaid/LICENSE +21 -0
  6. package/THIRD_PARTY_LICENSES/cose-base-v1/LICENSE +21 -0
  7. package/THIRD_PARTY_LICENSES/cose-base-v2/LICENSE +21 -0
  8. package/THIRD_PARTY_LICENSES/cytoscape/LICENSE +19 -0
  9. package/THIRD_PARTY_LICENSES/cytoscape-cose-bilkent/LICENSE +21 -0
  10. package/THIRD_PARTY_LICENSES/cytoscape-fcose/LICENSE +19 -0
  11. package/THIRD_PARTY_LICENSES/d3-shape/LICENSE +13 -0
  12. package/THIRD_PARTY_LICENSES/dagre/LICENSE +19 -0
  13. package/THIRD_PARTY_LICENSES/dompurify/LICENSE +202 -0
  14. package/THIRD_PARTY_LICENSES/eclipse-elk/LICENSE.md +264 -0
  15. package/THIRD_PARTY_LICENSES/elkjs/LICENSE.md +264 -0
  16. package/THIRD_PARTY_LICENSES/fmin/LICENSE +27 -0
  17. package/THIRD_PARTY_LICENSES/graphlib/LICENSE +19 -0
  18. package/THIRD_PARTY_LICENSES/katex-fonts/FONT_NOTICE.txt +12 -0
  19. package/THIRD_PARTY_LICENSES/katex-fonts/OFL.txt +85 -0
  20. package/THIRD_PARTY_LICENSES/layout-base-v1/LICENSE +21 -0
  21. package/THIRD_PARTY_LICENSES/layout-base-v2/LICENSE +21 -0
  22. package/THIRD_PARTY_LICENSES/mermaid/LICENSE +21 -0
  23. package/THIRD_PARTY_LICENSES/mermaid-ascii/LICENSE +21 -0
  24. package/THIRD_PARTY_LICENSES/mermaid-rs-renderer/LICENSE +21 -0
  25. package/THIRD_PARTY_LICENSES/non-layered-tidy-tree-layout/LICENSE +21 -0
  26. package/THIRD_PARTY_LICENSES/ratex/LICENSE +27 -0
  27. package/THIRD_PARTY_LICENSES/ratex/THIRD_PARTY_NOTICES.txt +19 -0
  28. package/THIRD_PARTY_LICENSES/rough-rs/LICENSE +21 -0
  29. package/THIRD_PARTY_LICENSES/roughjs/LICENSE +21 -0
  30. package/THIRD_PARTY_LICENSES/rust-cargo-dependencies.json +5581 -0
  31. package/THIRD_PARTY_LICENSES/sanitize-url/LICENSE +21 -0
  32. package/THIRD_PARTY_LICENSES/tree-sitter/LICENSE +21 -0
  33. package/THIRD_PARTY_LICENSES/tree-sitter-mermaid-monaqa/LICENSE +21 -0
  34. package/THIRD_PARTY_LICENSES/tree-sitter-mermaid-pappasam/LICENSE +21 -0
  35. package/THIRD_PARTY_LICENSES/tree-sitter-mermaid-singularity/LICENSE +22 -0
  36. package/THIRD_PARTY_LICENSES/venn-js/LICENSE +22 -0
  37. package/THIRD_PARTY_LICENSES/wasm-minimal-protocol/LICENSE +24 -0
  38. package/THIRD_PARTY_LICENSES/zenuml-core/LICENSE +21 -0
  39. package/THIRD_PARTY_NOTICES.md +648 -0
  40. package/artifact/merman_node.cjs +302 -0
  41. package/artifact/merman_node_bg.wasm +0 -0
  42. package/dist/bounded-executor.mjs +135 -0
  43. package/dist/candidates/wasm.mjs +87 -0
  44. package/dist/candidates/wrap-engine.mjs +36 -0
  45. package/dist/engine.mjs +1340 -0
  46. package/dist/errors.mjs +1318 -0
  47. package/dist/generated/binding-contract.mjs +1019 -0
  48. package/dist/generated/capability-surface.mjs +66 -0
  49. package/dist/generated/node-wire-contract.json +122 -0
  50. package/dist/index.d.ts +283 -0
  51. package/dist/index.mjs +37 -0
  52. package/dist/native-loader.mjs +125 -0
  53. package/dist/transport-contract.mjs +87 -0
  54. package/package.json +44 -0
@@ -0,0 +1,87 @@
1
+ import { createRequire } from "node:module";
2
+
3
+ const requireFromModule = createRequire(import.meta.url);
4
+ const contract = requireFromModule("./generated/node-wire-contract.json");
5
+
6
+ validateContract(contract);
7
+
8
+ export const NODE_WIRE_CONTRACT = deepFreeze(contract);
9
+ export const NODE_TRANSPORT_LIMITS = NODE_WIRE_CONTRACT.documents;
10
+ export const NODE_TRANSPORT_FIELD_LIMITS = NODE_WIRE_CONTRACT.fields;
11
+
12
+ function validateContract(value) {
13
+ if (
14
+ !value ||
15
+ value.schema_version !== 1 ||
16
+ value.package_id !== "@mermanjs/node" ||
17
+ value.artifact_id !== "merman-node-static-svg" ||
18
+ value.transport_api_version !== 1 ||
19
+ value.binding_result_payload_version !== 1 ||
20
+ !value.artifact ||
21
+ !value.documents ||
22
+ !value.fields
23
+ ) {
24
+ throw new Error("The generated Node wire contract is invalid.");
25
+ }
26
+ for (const field of [
27
+ "capability_ids",
28
+ "output_ids",
29
+ "system_adapter_ids",
30
+ "operation_ids",
31
+ "metadata_ids",
32
+ "option_group_ids",
33
+ "constructor_service_ids",
34
+ "text_measurement_provider_ids",
35
+ ]) {
36
+ const ids = value.artifact[field];
37
+ if (
38
+ !Array.isArray(ids) ||
39
+ ids.some((id) => typeof id !== "string" || id.length === 0) ||
40
+ ids.some((id, index) => index > 0 && ids[index - 1] >= id)
41
+ ) {
42
+ throw new Error(`The generated Node artifact field \`${field}\` is invalid.`);
43
+ }
44
+ }
45
+ if (
46
+ !Array.isArray(value.artifact.output_contracts) ||
47
+ value.artifact.output_contracts.length !== value.artifact.output_ids.length ||
48
+ value.artifact.output_contracts.some((contract, index) =>
49
+ !contract ||
50
+ contract.id !== value.artifact.output_ids[index] ||
51
+ typeof contract.media_type !== "string" ||
52
+ contract.media_type.length === 0 ||
53
+ !(contract.system_fonts === null || isObject(contract.system_fonts)) ||
54
+ !(contract.embedded_images === null || isObject(contract.embedded_images))
55
+ )
56
+ ) {
57
+ throw new Error("The generated Node artifact output contracts are invalid.");
58
+ }
59
+ for (const [id, limits] of Object.entries(value.documents)) {
60
+ if (
61
+ !limits ||
62
+ !Number.isSafeInteger(limits.max_utf8_bytes) ||
63
+ !Number.isSafeInteger(limits.max_depth) ||
64
+ !Number.isSafeInteger(limits.max_members) ||
65
+ !Number.isSafeInteger(limits.max_tokens) ||
66
+ !Number.isSafeInteger(limits.max_string_utf8_bytes) ||
67
+ Object.values(limits).some((limit) => limit <= 0)
68
+ ) {
69
+ throw new Error(`The generated Node wire document limit \`${id}\` is invalid.`);
70
+ }
71
+ }
72
+ for (const [id, limit] of Object.entries(value.fields)) {
73
+ if (!Number.isSafeInteger(limit) || limit <= 0) {
74
+ throw new Error(`The generated Node wire field limit \`${id}\` is invalid.`);
75
+ }
76
+ }
77
+ }
78
+
79
+ function isObject(value) {
80
+ return Boolean(value && typeof value === "object" && !Array.isArray(value));
81
+ }
82
+
83
+ function deepFreeze(value) {
84
+ if (!value || typeof value !== "object" || Object.isFrozen(value)) return value;
85
+ for (const child of Object.values(value)) deepFreeze(child);
86
+ return Object.freeze(value);
87
+ }
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@mermanjs/node-wasm",
3
+ "version": "0.8.0-alpha.6",
4
+ "description": "Explicit Node-targeted WebAssembly rendering package for Merman.",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=22.0.0"
8
+ },
9
+ "main": "./dist/index.mjs",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.mjs"
15
+ }
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/Latias94/merman.git"
20
+ },
21
+ "homepage": "https://github.com/Latias94/merman/tree/main/platforms/node#readme",
22
+ "keywords": [
23
+ "mermaid",
24
+ "diagram",
25
+ "svg",
26
+ "node",
27
+ "wasm",
28
+ "webassembly"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "files": [
34
+ "CHANGELOG.md",
35
+ "artifact",
36
+ "dist",
37
+ "LICENSE-APACHE",
38
+ "LICENSE-MIT",
39
+ "README.md",
40
+ "THIRD_PARTY_LICENSES",
41
+ "THIRD_PARTY_NOTICES.md"
42
+ ],
43
+ "license": "MIT OR Apache-2.0"
44
+ }