@drawmotive/textgraph 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +92 -0
- package/docs/api-v1.md +87 -0
- package/docs/releases.md +100 -0
- package/examples/browser.html +5 -0
- package/examples/browser.js +4 -0
- package/examples/node.mjs +4 -0
- package/examples/render-png.mjs +11 -0
- package/examples/worker.js +6 -0
- package/generated/wasm/DrawMotive.TextGraph.Bridge.runtimeconfig.json +52 -0
- package/generated/wasm/DrawMotive.TextGraph.Bridge.wasm +0 -0
- package/generated/wasm/FuzzyBubbles-LICENSE.txt +93 -0
- package/generated/wasm/FuzzyBubbles-Regular.ttf +0 -0
- package/generated/wasm/Graphics.Core.wasm +0 -0
- package/generated/wasm/Grpc.Core.Api.wasm +0 -0
- package/generated/wasm/HarfBuzzSharp.wasm +0 -0
- package/generated/wasm/MagicOnion.Abstractions.wasm +0 -0
- package/generated/wasm/MagicOnion.Serialization.MessagePack.wasm +0 -0
- package/generated/wasm/MagicOnion.Shared.wasm +0 -0
- package/generated/wasm/Markdig.wasm +0 -0
- package/generated/wasm/Math.Core.wasm +0 -0
- package/generated/wasm/MemoryPack.Core.wasm +0 -0
- package/generated/wasm/MessagePack.Annotations.wasm +0 -0
- package/generated/wasm/MessagePack.wasm +0 -0
- package/generated/wasm/Microsoft.AspNetCore.Components.Web.wasm +0 -0
- package/generated/wasm/Microsoft.Extensions.DependencyInjection.Abstractions.wasm +0 -0
- package/generated/wasm/Microsoft.Extensions.DependencyInjection.wasm +0 -0
- package/generated/wasm/Microsoft.Extensions.Hosting.Abstractions.wasm +0 -0
- package/generated/wasm/Microsoft.Extensions.Logging.Abstractions.wasm +0 -0
- package/generated/wasm/Microsoft.Extensions.Logging.wasm +0 -0
- package/generated/wasm/Microsoft.Extensions.Options.wasm +0 -0
- package/generated/wasm/Microsoft.Extensions.Primitives.wasm +0 -0
- package/generated/wasm/Microsoft.NET.StringTools.wasm +0 -0
- package/generated/wasm/Nanoid.wasm +0 -0
- package/generated/wasm/NotoSans-LICENSE.txt +93 -0
- package/generated/wasm/NotoSans-Regular.ttf +0 -0
- package/generated/wasm/Polly.Core.wasm +0 -0
- package/generated/wasm/Polly.wasm +0 -0
- package/generated/wasm/R3.BlazorWebAssembly.wasm +0 -0
- package/generated/wasm/R3.wasm +0 -0
- package/generated/wasm/RBush.wasm +0 -0
- package/generated/wasm/SkiaSharp.HarfBuzz.wasm +0 -0
- package/generated/wasm/SkiaSharp.wasm +0 -0
- package/generated/wasm/Stateless.wasm +0 -0
- package/generated/wasm/System.Collections.Concurrent.wasm +0 -0
- package/generated/wasm/System.Collections.Immutable.wasm +0 -0
- package/generated/wasm/System.Collections.NonGeneric.wasm +0 -0
- package/generated/wasm/System.Collections.Specialized.wasm +0 -0
- package/generated/wasm/System.Collections.wasm +0 -0
- package/generated/wasm/System.ComponentModel.Annotations.wasm +0 -0
- package/generated/wasm/System.ComponentModel.Primitives.wasm +0 -0
- package/generated/wasm/System.ComponentModel.TypeConverter.wasm +0 -0
- package/generated/wasm/System.ComponentModel.wasm +0 -0
- package/generated/wasm/System.Console.wasm +0 -0
- package/generated/wasm/System.Diagnostics.StackTrace.wasm +0 -0
- package/generated/wasm/System.Diagnostics.Tracing.wasm +0 -0
- package/generated/wasm/System.IO.Compression.Brotli.wasm +0 -0
- package/generated/wasm/System.IO.Compression.wasm +0 -0
- package/generated/wasm/System.IO.Pipelines.wasm +0 -0
- package/generated/wasm/System.Linq.Expressions.wasm +0 -0
- package/generated/wasm/System.Linq.wasm +0 -0
- package/generated/wasm/System.Memory.wasm +0 -0
- package/generated/wasm/System.Net.Http.wasm +0 -0
- package/generated/wasm/System.Net.Primitives.wasm +0 -0
- package/generated/wasm/System.Numerics.Vectors.wasm +0 -0
- package/generated/wasm/System.ObjectModel.wasm +0 -0
- package/generated/wasm/System.Private.CoreLib.wasm +0 -0
- package/generated/wasm/System.Private.Uri.wasm +0 -0
- package/generated/wasm/System.Reflection.Emit.ILGeneration.wasm +0 -0
- package/generated/wasm/System.Reflection.Emit.wasm +0 -0
- package/generated/wasm/System.Reflection.Primitives.wasm +0 -0
- package/generated/wasm/System.Runtime.InteropServices.JavaScript.wasm +0 -0
- package/generated/wasm/System.Runtime.InteropServices.wasm +0 -0
- package/generated/wasm/System.Runtime.Intrinsics.wasm +0 -0
- package/generated/wasm/System.Runtime.Loader.wasm +0 -0
- package/generated/wasm/System.Runtime.Numerics.wasm +0 -0
- package/generated/wasm/System.Runtime.Serialization.Primitives.wasm +0 -0
- package/generated/wasm/System.Runtime.wasm +0 -0
- package/generated/wasm/System.Security.Cryptography.wasm +0 -0
- package/generated/wasm/System.Text.Encoding.Extensions.wasm +0 -0
- package/generated/wasm/System.Text.Encodings.Web.wasm +0 -0
- package/generated/wasm/System.Text.Json.wasm +0 -0
- package/generated/wasm/System.Text.RegularExpressions.wasm +0 -0
- package/generated/wasm/System.Threading.Channels.wasm +0 -0
- package/generated/wasm/System.Threading.Thread.wasm +0 -0
- package/generated/wasm/System.Threading.ThreadPool.wasm +0 -0
- package/generated/wasm/System.Threading.wasm +0 -0
- package/generated/wasm/System.wasm +0 -0
- package/generated/wasm/ZstdSharp.wasm +0 -0
- package/generated/wasm/dotnet.boot.js +443 -0
- package/generated/wasm/dotnet.js +4 -0
- package/generated/wasm/dotnet.native.js +5513 -0
- package/generated/wasm/dotnet.native.wasm +0 -0
- package/generated/wasm/dotnet.runtime.js +4 -0
- package/generated/wasm/main.mjs +5 -0
- package/generated/wasm/netstandard.wasm +0 -0
- package/generated/wasm/themes.css +85 -0
- package/generated/wasm-manifest.js +572 -0
- package/generated/wasm-manifest.json +572 -0
- package/package.json +66 -0
- package/schemas/render.schema.json +167 -0
- package/schemas/validation.schema.json +70 -0
- package/schemas/wasm-manifest.schema.json +208 -0
- package/src/adapters.js +27 -0
- package/src/index.d.ts +171 -0
- package/src/index.js +78 -0
- package/src/platform/browser.d.ts +13 -0
- package/src/platform/browser.js +13 -0
- package/src/platform/node.d.ts +3 -0
- package/src/platform/node.js +12 -0
- package/src/platform/worker.d.ts +3 -0
- package/src/platform/worker.js +4 -0
- package/src/runtime/assets.js +27 -0
- package/src/runtime/browser.js +41 -0
- package/src/runtime/dotnet.js +100 -0
- package/src/runtime/errors.js +14 -0
- package/src/runtime/integrity.js +12 -0
- package/src/runtime/language-packs.js +32 -0
- package/src/runtime/lifecycle.js +84 -0
- package/src/runtime/manifest.js +60 -0
- package/src/runtime/node.js +21 -0
- package/src/runtime/render-resources.js +51 -0
- package/src/runtime/rendering.js +66 -0
- package/src/runtime/shared.js +17 -0
- package/src/runtime/validation.js +38 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"properties": {
|
|
4
|
+
"protocolVersion": {
|
|
5
|
+
"const": 1
|
|
6
|
+
},
|
|
7
|
+
"diagnostics": {
|
|
8
|
+
"type": "array",
|
|
9
|
+
"items": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"properties": {
|
|
12
|
+
"code": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"minLength": 1
|
|
15
|
+
},
|
|
16
|
+
"severity": {
|
|
17
|
+
"enum": [
|
|
18
|
+
"error",
|
|
19
|
+
"warning"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
"stage": {
|
|
23
|
+
"enum": [
|
|
24
|
+
"parse",
|
|
25
|
+
"semantic",
|
|
26
|
+
"layout",
|
|
27
|
+
"render",
|
|
28
|
+
"font"
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"message": {
|
|
32
|
+
"type": "string"
|
|
33
|
+
},
|
|
34
|
+
"location": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"properties": {
|
|
37
|
+
"line": {
|
|
38
|
+
"type": "integer",
|
|
39
|
+
"minimum": 0
|
|
40
|
+
},
|
|
41
|
+
"column": {
|
|
42
|
+
"type": "integer",
|
|
43
|
+
"minimum": 0
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"required": [
|
|
47
|
+
"line",
|
|
48
|
+
"column"
|
|
49
|
+
],
|
|
50
|
+
"additionalProperties": true
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"required": [
|
|
54
|
+
"code",
|
|
55
|
+
"severity",
|
|
56
|
+
"stage",
|
|
57
|
+
"message"
|
|
58
|
+
],
|
|
59
|
+
"additionalProperties": true
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"success": {
|
|
63
|
+
"type": "boolean"
|
|
64
|
+
},
|
|
65
|
+
"png": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"minLength": 4,
|
|
68
|
+
"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
|
|
69
|
+
},
|
|
70
|
+
"width": {
|
|
71
|
+
"type": "integer",
|
|
72
|
+
"minimum": 1,
|
|
73
|
+
"maximum": 2147483647
|
|
74
|
+
},
|
|
75
|
+
"height": {
|
|
76
|
+
"type": "integer",
|
|
77
|
+
"minimum": 1,
|
|
78
|
+
"maximum": 2147483647
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"required": [
|
|
82
|
+
"protocolVersion",
|
|
83
|
+
"success",
|
|
84
|
+
"diagnostics"
|
|
85
|
+
],
|
|
86
|
+
"additionalProperties": true,
|
|
87
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
88
|
+
"allOf": [
|
|
89
|
+
{
|
|
90
|
+
"if": {
|
|
91
|
+
"properties": {
|
|
92
|
+
"success": {
|
|
93
|
+
"const": true
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"then": {
|
|
98
|
+
"required": [
|
|
99
|
+
"png",
|
|
100
|
+
"width",
|
|
101
|
+
"height"
|
|
102
|
+
],
|
|
103
|
+
"properties": {
|
|
104
|
+
"diagnostics": {
|
|
105
|
+
"not": {
|
|
106
|
+
"contains": {
|
|
107
|
+
"type": "object",
|
|
108
|
+
"properties": {
|
|
109
|
+
"severity": {
|
|
110
|
+
"const": "error"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"type": "array"
|
|
116
|
+
},
|
|
117
|
+
"png": {},
|
|
118
|
+
"width": {},
|
|
119
|
+
"height": {}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"else": {
|
|
123
|
+
"not": {
|
|
124
|
+
"anyOf": [
|
|
125
|
+
{
|
|
126
|
+
"required": [
|
|
127
|
+
"png"
|
|
128
|
+
],
|
|
129
|
+
"properties": {
|
|
130
|
+
"png": {}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"required": [
|
|
135
|
+
"width"
|
|
136
|
+
],
|
|
137
|
+
"properties": {
|
|
138
|
+
"width": {}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"required": [
|
|
143
|
+
"height"
|
|
144
|
+
],
|
|
145
|
+
"properties": {
|
|
146
|
+
"height": {}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
"properties": {
|
|
152
|
+
"diagnostics": {
|
|
153
|
+
"contains": {
|
|
154
|
+
"type": "object",
|
|
155
|
+
"properties": {
|
|
156
|
+
"severity": {
|
|
157
|
+
"const": "error"
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
"type": "array"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"properties": {
|
|
4
|
+
"protocolVersion": {
|
|
5
|
+
"const": 1
|
|
6
|
+
},
|
|
7
|
+
"valid": {
|
|
8
|
+
"type": "boolean"
|
|
9
|
+
},
|
|
10
|
+
"diagnostics": {
|
|
11
|
+
"type": "array",
|
|
12
|
+
"items": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"properties": {
|
|
15
|
+
"code": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"minLength": 1
|
|
18
|
+
},
|
|
19
|
+
"severity": {
|
|
20
|
+
"enum": [
|
|
21
|
+
"error",
|
|
22
|
+
"warning"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"stage": {
|
|
26
|
+
"enum": [
|
|
27
|
+
"parse",
|
|
28
|
+
"semantic"
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"message": {
|
|
32
|
+
"type": "string"
|
|
33
|
+
},
|
|
34
|
+
"location": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"properties": {
|
|
37
|
+
"line": {
|
|
38
|
+
"type": "integer",
|
|
39
|
+
"minimum": 0
|
|
40
|
+
},
|
|
41
|
+
"column": {
|
|
42
|
+
"type": "integer",
|
|
43
|
+
"minimum": 0
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"required": [
|
|
47
|
+
"line",
|
|
48
|
+
"column"
|
|
49
|
+
],
|
|
50
|
+
"additionalProperties": true
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"required": [
|
|
54
|
+
"code",
|
|
55
|
+
"severity",
|
|
56
|
+
"stage",
|
|
57
|
+
"message"
|
|
58
|
+
],
|
|
59
|
+
"additionalProperties": true
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"required": [
|
|
64
|
+
"protocolVersion",
|
|
65
|
+
"valid",
|
|
66
|
+
"diagnostics"
|
|
67
|
+
],
|
|
68
|
+
"additionalProperties": true,
|
|
69
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema"
|
|
70
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"properties": {
|
|
4
|
+
"schemaVersion": {
|
|
5
|
+
"const": 1
|
|
6
|
+
},
|
|
7
|
+
"packageName": {
|
|
8
|
+
"const": "@drawmotive/textgraph"
|
|
9
|
+
},
|
|
10
|
+
"packageVersion": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"minLength": 1
|
|
13
|
+
},
|
|
14
|
+
"abiVersion": {
|
|
15
|
+
"const": "1.0.0"
|
|
16
|
+
},
|
|
17
|
+
"protocolVersion": {
|
|
18
|
+
"const": 1
|
|
19
|
+
},
|
|
20
|
+
"targetFramework": {
|
|
21
|
+
"const": "net10.0"
|
|
22
|
+
},
|
|
23
|
+
"privateSource": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"properties": {
|
|
26
|
+
"commit": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"pattern": "^[a-f0-9]{40}$"
|
|
29
|
+
},
|
|
30
|
+
"project": {
|
|
31
|
+
"const": "DrawMotive.TextGraph.Bridge"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"required": [
|
|
35
|
+
"commit",
|
|
36
|
+
"project"
|
|
37
|
+
],
|
|
38
|
+
"additionalProperties": true
|
|
39
|
+
},
|
|
40
|
+
"entryAssembly": {
|
|
41
|
+
"type": "string"
|
|
42
|
+
},
|
|
43
|
+
"runtimeWasm": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
},
|
|
46
|
+
"runtimeConfig": {
|
|
47
|
+
"type": "string"
|
|
48
|
+
},
|
|
49
|
+
"runtimeModule": {
|
|
50
|
+
"type": "string"
|
|
51
|
+
},
|
|
52
|
+
"bridge": {
|
|
53
|
+
"type": "object",
|
|
54
|
+
"properties": {
|
|
55
|
+
"assembly": {
|
|
56
|
+
"const": "DrawMotive.TextGraph.Bridge.dll"
|
|
57
|
+
},
|
|
58
|
+
"type": {
|
|
59
|
+
"const": "DrawMotive.TextGraph.Bridge.Program"
|
|
60
|
+
},
|
|
61
|
+
"info": {
|
|
62
|
+
"const": "GetRuntimeInfo"
|
|
63
|
+
},
|
|
64
|
+
"validate": {
|
|
65
|
+
"const": "Validate"
|
|
66
|
+
},
|
|
67
|
+
"execute": {
|
|
68
|
+
"const": "Execute"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"required": [
|
|
72
|
+
"assembly",
|
|
73
|
+
"type",
|
|
74
|
+
"info",
|
|
75
|
+
"validate"
|
|
76
|
+
],
|
|
77
|
+
"additionalProperties": true
|
|
78
|
+
},
|
|
79
|
+
"capabilities": {
|
|
80
|
+
"type": "array",
|
|
81
|
+
"items": {
|
|
82
|
+
"type": "string"
|
|
83
|
+
},
|
|
84
|
+
"uniqueItems": true,
|
|
85
|
+
"contains": {
|
|
86
|
+
"const": "textgraph-validate-v1"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"assets": {
|
|
90
|
+
"type": "array",
|
|
91
|
+
"minItems": 1,
|
|
92
|
+
"items": {
|
|
93
|
+
"type": "object",
|
|
94
|
+
"properties": {
|
|
95
|
+
"path": {
|
|
96
|
+
"type": "string",
|
|
97
|
+
"pattern": "^wasm/[A-Za-z0-9_-][A-Za-z0-9._-]*$"
|
|
98
|
+
},
|
|
99
|
+
"mediaType": {
|
|
100
|
+
"type": "string"
|
|
101
|
+
},
|
|
102
|
+
"bytes": {
|
|
103
|
+
"type": "integer",
|
|
104
|
+
"minimum": 0
|
|
105
|
+
},
|
|
106
|
+
"sha256": {
|
|
107
|
+
"type": "string",
|
|
108
|
+
"pattern": "^[a-f0-9]{64}$"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"required": [
|
|
112
|
+
"path",
|
|
113
|
+
"mediaType",
|
|
114
|
+
"bytes",
|
|
115
|
+
"sha256"
|
|
116
|
+
],
|
|
117
|
+
"additionalProperties": true
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"rendering": {
|
|
121
|
+
"type": "object",
|
|
122
|
+
"properties": {
|
|
123
|
+
"theme": {
|
|
124
|
+
"type": "string",
|
|
125
|
+
"pattern": "^wasm/[A-Za-z0-9_-][A-Za-z0-9._-]*[.]css$"
|
|
126
|
+
},
|
|
127
|
+
"fonts": {
|
|
128
|
+
"type": "array",
|
|
129
|
+
"minItems": 1,
|
|
130
|
+
"items": {
|
|
131
|
+
"type": "object",
|
|
132
|
+
"properties": {
|
|
133
|
+
"family": {
|
|
134
|
+
"type": "string",
|
|
135
|
+
"minLength": 1
|
|
136
|
+
},
|
|
137
|
+
"asset": {
|
|
138
|
+
"type": "string",
|
|
139
|
+
"pattern": "^wasm/[A-Za-z0-9_-][A-Za-z0-9._-]*[.](ttf|otf)$"
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"required": [
|
|
143
|
+
"family",
|
|
144
|
+
"asset"
|
|
145
|
+
],
|
|
146
|
+
"additionalProperties": true
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"required": [
|
|
151
|
+
"theme",
|
|
152
|
+
"fonts"
|
|
153
|
+
],
|
|
154
|
+
"additionalProperties": true
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
"required": [
|
|
158
|
+
"schemaVersion",
|
|
159
|
+
"packageName",
|
|
160
|
+
"packageVersion",
|
|
161
|
+
"abiVersion",
|
|
162
|
+
"protocolVersion",
|
|
163
|
+
"targetFramework",
|
|
164
|
+
"privateSource",
|
|
165
|
+
"entryAssembly",
|
|
166
|
+
"runtimeWasm",
|
|
167
|
+
"runtimeConfig",
|
|
168
|
+
"runtimeModule",
|
|
169
|
+
"bridge",
|
|
170
|
+
"capabilities",
|
|
171
|
+
"assets"
|
|
172
|
+
],
|
|
173
|
+
"additionalProperties": true,
|
|
174
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
175
|
+
"allOf": [
|
|
176
|
+
{
|
|
177
|
+
"if": {
|
|
178
|
+
"properties": {
|
|
179
|
+
"capabilities": {
|
|
180
|
+
"contains": {
|
|
181
|
+
"const": "textgraph-render-v1"
|
|
182
|
+
},
|
|
183
|
+
"type": "array"
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
"then": {
|
|
188
|
+
"required": [
|
|
189
|
+
"rendering"
|
|
190
|
+
],
|
|
191
|
+
"properties": {
|
|
192
|
+
"bridge": {
|
|
193
|
+
"type": "object",
|
|
194
|
+
"properties": {
|
|
195
|
+
"execute": {
|
|
196
|
+
"const": "Execute"
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"required": [
|
|
200
|
+
"execute"
|
|
201
|
+
]
|
|
202
|
+
},
|
|
203
|
+
"rendering": {}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
}
|
package/src/adapters.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DrawMotiveError } from './runtime/errors.js';
|
|
2
|
+
|
|
3
|
+
const contracts = Object.freeze({ files: ['open', 'save'], network: ['fetch'] });
|
|
4
|
+
|
|
5
|
+
/** Validates TextGraph host adapters and captures an immutable method snapshot. */
|
|
6
|
+
export function validateTextGraphAdapters(adapters = {}) {
|
|
7
|
+
if (adapters === null || typeof adapters !== 'object') invalid('adapters');
|
|
8
|
+
const snapshot = {};
|
|
9
|
+
for (const [name, methods] of Object.entries(contracts)) {
|
|
10
|
+
const adapter = adapters[name];
|
|
11
|
+
if (adapter === undefined) continue;
|
|
12
|
+
if (adapter === null || typeof adapter !== 'object') invalid(name);
|
|
13
|
+
const captured = {};
|
|
14
|
+
for (const method of methods) {
|
|
15
|
+
if (typeof adapter[method] !== 'function') invalid(name, method);
|
|
16
|
+
captured[method] = adapter[method].bind(adapter);
|
|
17
|
+
}
|
|
18
|
+
snapshot[name] = Object.freeze(captured);
|
|
19
|
+
}
|
|
20
|
+
return Object.freeze(snapshot);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function invalid(adapter, method) {
|
|
24
|
+
throw new DrawMotiveError('INVALID_ADAPTER', `Adapter ${adapter}${method ? `.${method}` : ''} does not satisfy its contract`, {
|
|
25
|
+
details: { adapter, method: method ?? null },
|
|
26
|
+
});
|
|
27
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
export interface TextGraphRuntimeManifest {
|
|
2
|
+
readonly packageName: '@drawmotive/textgraph';
|
|
3
|
+
readonly packageVersion: string;
|
|
4
|
+
readonly abiVersion: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface TextGraphAbiManifest extends TextGraphRuntimeManifest {
|
|
8
|
+
readonly schemaVersion: 1;
|
|
9
|
+
readonly protocolVersion: 1;
|
|
10
|
+
readonly targetFramework: 'net10.0';
|
|
11
|
+
readonly privateSource: { readonly commit: string; readonly project: string };
|
|
12
|
+
readonly entryAssembly: string;
|
|
13
|
+
readonly runtimeWasm: string;
|
|
14
|
+
readonly runtimeConfig: string;
|
|
15
|
+
readonly runtimeModule: string;
|
|
16
|
+
readonly bridge: { readonly assembly: string; readonly type: string; readonly info: string; readonly validate: string; readonly execute?: string };
|
|
17
|
+
readonly rendering?: {
|
|
18
|
+
readonly theme: string;
|
|
19
|
+
readonly fonts: readonly { readonly family: string; readonly asset: string }[];
|
|
20
|
+
};
|
|
21
|
+
readonly capabilities: readonly string[];
|
|
22
|
+
readonly assets: readonly Required<RuntimeAsset>[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface RuntimeAsset {
|
|
26
|
+
readonly path: string;
|
|
27
|
+
readonly mediaType?: string;
|
|
28
|
+
readonly bytes?: number;
|
|
29
|
+
readonly sha256?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface RuntimeAssetManifest {
|
|
33
|
+
readonly assets: readonly RuntimeAsset[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ResolvedRuntimeAsset {
|
|
37
|
+
readonly asset: RuntimeAsset;
|
|
38
|
+
readonly url: URL;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface LoadedRuntimeAsset extends Omit<RuntimeAsset, 'bytes'> {
|
|
42
|
+
readonly url: URL;
|
|
43
|
+
readonly bytes: Uint8Array;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface RuntimeAssetLoader {
|
|
47
|
+
readonly plan: readonly ResolvedRuntimeAsset[];
|
|
48
|
+
loadAssets(): Promise<ReadonlyMap<string, LoadedRuntimeAsset>>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface TextGraphInstance {
|
|
52
|
+
readonly state: 'ready' | 'disposing' | 'disposed';
|
|
53
|
+
readonly info: TextGraphRuntimeInfo;
|
|
54
|
+
validate(source: string, options?: { signal?: AbortSignal }): Promise<TextGraphValidationResult>;
|
|
55
|
+
renderPng(source: string, options?: TextGraphRenderPngOptions<'bytes'>): Promise<TextGraphRenderPngResult<Uint8Array>>;
|
|
56
|
+
renderPng(source: string, options: TextGraphRenderPngOptions<'base64'> & { encoding: 'base64' }): Promise<TextGraphRenderPngResult<string>>;
|
|
57
|
+
renderPng(source: string, options: TextGraphRenderPngOptions): Promise<TextGraphRenderPngResult<Uint8Array | string>>;
|
|
58
|
+
readonly<T>(operation: () => T | Promise<T>): Promise<T>;
|
|
59
|
+
mutate<T>(operation: () => T | Promise<T>): Promise<T>;
|
|
60
|
+
dispose(): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface TextGraphRuntime {
|
|
64
|
+
readonly abiVersion: string;
|
|
65
|
+
readonly capabilities?: readonly string[];
|
|
66
|
+
validate?(source: string): string | Promise<string>;
|
|
67
|
+
execute?(requestJson: string, context?: { signal?: AbortSignal }): string | Promise<string>;
|
|
68
|
+
dispose?(): void | Promise<void>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface AdapterContext {
|
|
72
|
+
readonly signal?: AbortSignal;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface FileAdapter {
|
|
76
|
+
open(path: string, context: AdapterContext): Promise<Uint8Array>;
|
|
77
|
+
save(path: string, data: Uint8Array, context: AdapterContext): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface NetworkAdapter {
|
|
81
|
+
fetch(input: RequestInfo | URL, init: RequestInit & AdapterContext): Promise<Response>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface TextGraphAdapters {
|
|
85
|
+
readonly files?: FileAdapter;
|
|
86
|
+
readonly network?: NetworkAdapter;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface TextGraphInitializeOptions {
|
|
90
|
+
/** Development hook. Default platform loading requires no custom runtime. */
|
|
91
|
+
loadRuntime?(options: TextGraphInitializeOptions): Promise<TextGraphRuntime>;
|
|
92
|
+
signal?: AbortSignal;
|
|
93
|
+
adapters?: TextGraphAdapters;
|
|
94
|
+
resolveAsset?(asset: RuntimeAsset, defaultUrl: URL): string | URL;
|
|
95
|
+
fetch?: typeof globalThis.fetch;
|
|
96
|
+
/** Font data is copied during initialization and loaded only before the first render. */
|
|
97
|
+
languagePacks?: readonly TextGraphLanguagePack[];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface TextGraphFont {
|
|
101
|
+
readonly family: string;
|
|
102
|
+
/** Use a URL (including file: in Node) or bytes; bytes are copied during initialization. */
|
|
103
|
+
readonly source: URL | Uint8Array;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface TextGraphLanguagePack {
|
|
107
|
+
readonly fonts: readonly TextGraphFont[];
|
|
108
|
+
/** Ordered fallback families supplied by this initialization, after explicit diagram fonts. */
|
|
109
|
+
readonly fallbackFamilies?: readonly string[];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export type TextGraphPngEncoding = 'bytes' | 'base64';
|
|
113
|
+
|
|
114
|
+
export interface TextGraphRenderPngOptions<Encoding extends TextGraphPngEncoding = TextGraphPngEncoding> {
|
|
115
|
+
/** Defaults to bytes. Base64 contains no data-URL prefix. */
|
|
116
|
+
encoding?: Encoding;
|
|
117
|
+
/** Positive render scale. Defaults to 2. */
|
|
118
|
+
scale?: number;
|
|
119
|
+
/** Non-negative padding in diagram units. Defaults to 10. */
|
|
120
|
+
padding?: number;
|
|
121
|
+
/** Positive integer upper bound on output width in pixels. */
|
|
122
|
+
maxWidth?: number;
|
|
123
|
+
/** Cancellation cannot preempt native work already running on this thread. */
|
|
124
|
+
signal?: AbortSignal;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export type TextGraphRenderPngResult<Png extends Uint8Array | string = Uint8Array | string> =
|
|
128
|
+
| { readonly success: true; readonly png: Png; readonly width: number; readonly height: number; readonly diagnostics: readonly TextGraphRenderDiagnostic[] }
|
|
129
|
+
| { readonly success: false; readonly diagnostics: readonly TextGraphRenderDiagnostic[] };
|
|
130
|
+
|
|
131
|
+
export interface TextGraphRuntimeInfo extends TextGraphRuntimeManifest {
|
|
132
|
+
readonly protocolVersion: 1;
|
|
133
|
+
readonly capabilities: readonly string[];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface TextGraphDiagnostic {
|
|
137
|
+
readonly code: string;
|
|
138
|
+
readonly severity: 'error' | 'warning';
|
|
139
|
+
readonly stage: 'parse' | 'semantic';
|
|
140
|
+
readonly message: string;
|
|
141
|
+
/** Zero-based line and UTF-16 column; no fabricated end range. */
|
|
142
|
+
readonly location?: { readonly line: number; readonly column: number };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface TextGraphValidationResult {
|
|
146
|
+
readonly valid: boolean;
|
|
147
|
+
readonly diagnostics: readonly TextGraphDiagnostic[];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface TextGraphRenderDiagnostic extends Omit<TextGraphDiagnostic, 'stage'> {
|
|
151
|
+
readonly stage: 'parse' | 'semantic' | 'layout' | 'render' | 'font';
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export declare const abiManifest: Readonly<TextGraphAbiManifest>;
|
|
155
|
+
|
|
156
|
+
export declare class DrawMotiveError extends Error {
|
|
157
|
+
readonly code: string;
|
|
158
|
+
readonly details: Readonly<Record<string, unknown>>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export declare function validateTextGraphAdapters(adapters?: TextGraphAdapters): Readonly<TextGraphAdapters>;
|
|
162
|
+
|
|
163
|
+
export declare function resolveRuntimeAssets(options: {
|
|
164
|
+
manifest: RuntimeAssetManifest;
|
|
165
|
+
moduleUrl?: string | URL;
|
|
166
|
+
resolveAsset?(asset: RuntimeAsset, defaultUrl: URL): string | URL;
|
|
167
|
+
}): readonly ResolvedRuntimeAsset[];
|
|
168
|
+
|
|
169
|
+
export declare function initializeTextGraph(
|
|
170
|
+
options?: TextGraphInitializeOptions,
|
|
171
|
+
): Promise<TextGraphInstance>;
|