-
-
Notifications
You must be signed in to change notification settings - Fork 150
Expand file tree
/
Copy pathmanifest.schema.json
More file actions
653 lines (653 loc) · 19.6 KB
/
Copy pathmanifest.schema.json
File metadata and controls
653 lines (653 loc) · 19.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://docs.perryts.com/native-libraries/manifest.schema.json",
"title": "Perry native-library manifest (v1)",
"description": "Validates the `perry.nativeLibrary` field in a package.json that exports Rust-backed FFI bindings to Perry. See docs/src/native-libraries/manifest-v1.md for prose.",
"type": "object",
"properties": {
"perry": {
"type": "object",
"properties": {
"nativeLibrary": { "$ref": "#/$defs/nativeLibrary" }
}
}
},
"$defs": {
"nativeLibrary": {
"type": "object",
"additionalProperties": false,
"required": ["functions"],
"properties": {
"abiVersion": {
"type": "string",
"description": "Semver range of perry-ffi this wrapper was built against. Required from v0.6.0; warning-only in v0.5.x.",
"examples": ["0.5", "0.5.3", "^0.5"]
},
"functions": {
"type": "array",
"description": "FFI function declarations exported by the wrapper's staticlib.",
"items": { "$ref": "#/$defs/functionDecl" }
},
"targets": {
"type": "object",
"description": "Per-target build configuration.",
"additionalProperties": { "$ref": "#/$defs/targetConfig" },
"properties": {
"macos": { "$ref": "#/$defs/targetConfig" },
"ios": { "$ref": "#/$defs/targetConfig" },
"linux": { "$ref": "#/$defs/targetConfig" },
"windows": { "$ref": "#/$defs/targetConfig" },
"android": { "$ref": "#/$defs/targetConfig" },
"web": { "$ref": "#/$defs/targetConfig" },
"harmonyos": { "$ref": "#/$defs/targetConfig" },
"tvos": { "$ref": "#/$defs/targetConfig" },
"watchos": { "$ref": "#/$defs/targetConfig" },
"visionos": { "$ref": "#/$defs/targetConfig" }
}
}
}
},
"functionDecl": {
"type": "object",
"additionalProperties": false,
"required": ["name", "params", "returns"],
"properties": {
"name": {
"type": "string",
"pattern": "^[A-Za-z_][A-Za-z0-9_]*$",
"description": "C-style symbol name. Convention: `js_<package>_<function>`."
},
"params": {
"type": "array",
"items": { "$ref": "#/$defs/abiParamDescriptor" }
},
"returns": { "$ref": "#/$defs/abiReturnDescriptor" }
}
},
"abiParamDescriptor": {
"description": "Native ABI descriptor for one TypeScript argument. `buffer+len` consumes one JS argument and lowers to two native slots; `pod` consumes one JS object-shaped argument and lowers through a verifier-backed C-layout record pointer; `pod+count` consumes one JS POD view and lowers to `(ptr, usize record_count)`.",
"anyOf": [
{ "$ref": "#/$defs/abiParamString" },
{ "$ref": "#/$defs/abiStructuredParam" }
]
},
"abiReturnDescriptor": {
"description": "Native ABI descriptor for the return value. `buffer+len` and `pod` are parameter-only.",
"anyOf": [
{ "$ref": "#/$defs/abiReturnString" },
{ "$ref": "#/$defs/abiStructuredReturn" }
]
},
"abiDescriptor": {
"description": "Native ABI descriptor accepted as metadata, for example the result type inside `promise<T>`.",
"anyOf": [
{ "$ref": "#/$defs/abiDescriptorString" },
{ "$ref": "#/$defs/abiStructuredDescriptor" }
]
},
"abiParamString": {
"type": "string",
"anyOf": [
{
"enum": [
"jsvalue",
"js_value",
"string",
"bool",
"boolean",
"i32",
"i64",
"i64_str",
"u32",
"u64",
"usize",
"f32",
"f64",
"number",
"ptr",
"buffer_len",
"buffer+len",
"handle",
"promise"
]
},
{ "pattern": "^handle<[^>]+>$" },
{ "pattern": "^promise<[^>]+>$" }
]
},
"abiReturnString": {
"type": "string",
"anyOf": [
{
"enum": [
"jsvalue",
"js_value",
"string",
"bool",
"boolean",
"i32",
"i64",
"i64_str",
"u32",
"u64",
"usize",
"f32",
"f64",
"number",
"ptr",
"buffer_len",
"handle",
"promise",
"void"
]
},
{ "pattern": "^handle<[^>]+>$" },
{ "pattern": "^promise<[^>]+>$" }
]
},
"abiDescriptorString": {
"type": "string",
"anyOf": [
{
"enum": [
"jsvalue",
"js_value",
"string",
"bool",
"boolean",
"i32",
"i64",
"i64_str",
"u32",
"u64",
"usize",
"f32",
"f64",
"number",
"ptr",
"buffer_len",
"buffer+len",
"handle",
"promise",
"void"
]
},
{ "pattern": "^handle<[^>]+>$" },
{ "pattern": "^promise<[^>]+>$" }
]
},
"abiStructuredParam": {
"oneOf": [
{ "$ref": "#/$defs/abiStructuredParamDescriptor" }
],
"not": {
"type": "object",
"required": ["kind"],
"properties": { "kind": { "const": "void" } }
}
},
"abiStructuredReturn": {
"oneOf": [
{ "$ref": "#/$defs/abiStructuredReturnDescriptor" }
],
"not": {
"type": "object",
"required": ["kind"],
"properties": {
"kind": { "enum": ["buffer+len", "pod", "pod+count"] }
}
}
},
"abiStructuredParamDescriptor": {
"oneOf": [
{ "$ref": "#/$defs/abiParamHandleDescriptor" },
{ "$ref": "#/$defs/abiParamPromiseDescriptor" },
{ "$ref": "#/$defs/abiBufferAndLenDescriptor" },
{ "$ref": "#/$defs/abiPodDescriptor" },
{ "$ref": "#/$defs/abiPodAndCountDescriptor" },
{ "$ref": "#/$defs/abiScalarDescriptor" }
]
},
"abiStructuredReturnDescriptor": {
"oneOf": [
{ "$ref": "#/$defs/abiReturnHandleDescriptor" },
{ "$ref": "#/$defs/abiReturnPromiseDescriptor" },
{ "$ref": "#/$defs/abiBufferAndLenDescriptor" },
{ "$ref": "#/$defs/abiPodDescriptor" },
{ "$ref": "#/$defs/abiScalarDescriptor" }
]
},
"abiStructuredDescriptor": {
"oneOf": [
{ "$ref": "#/$defs/abiHandleDescriptor" },
{ "$ref": "#/$defs/abiMetadataPromiseDescriptor" },
{ "$ref": "#/$defs/abiBufferAndLenDescriptor" },
{ "$ref": "#/$defs/abiPodDescriptor" },
{ "$ref": "#/$defs/abiScalarDescriptor" }
]
},
"abiParamHandleDescriptor": {
"allOf": [
{ "$ref": "#/$defs/abiHandleDescriptor" },
{
"not": {
"type": "object",
"required": ["finalizer"]
},
"description": "Native handle parameters may not declare finalizers."
}
]
},
"abiReturnHandleDescriptor": {
"$ref": "#/$defs/abiHandleDescriptor"
},
"abiParamPromiseDescriptor": {
"allOf": [
{ "$ref": "#/$defs/abiPromiseDescriptor" },
{
"not": {
"type": "object",
"required": ["completion"],
"properties": { "completion": { "const": "native_async" } }
},
"description": "Native async promise completion is only valid on returns."
}
]
},
"abiReturnPromiseDescriptor": {
"$ref": "#/$defs/abiPromiseDescriptor"
},
"abiMetadataPromiseDescriptor": {
"allOf": [
{ "$ref": "#/$defs/abiPromiseDescriptor" },
{
"not": {
"type": "object",
"required": ["completion"],
"properties": { "completion": { "const": "native_async" } }
},
"description": "Nested promise metadata cannot opt into native async completion."
}
]
},
"abiHandleDescriptor": {
"type": "object",
"additionalProperties": false,
"required": ["kind"],
"allOf": [
{
"if": {
"type": "object",
"required": ["finalizer"]
},
"then": {
"type": "object",
"required": ["ownership"],
"properties": {
"ownership": { "const": "owned" }
}
}
}
],
"properties": {
"kind": { "const": "handle" },
"type": {
"type": "string",
"minLength": 1,
"pattern": "\\S",
"description": "Optional metadata naming the native handle type."
},
"ownership": {
"enum": ["borrowed", "owned"],
"default": "borrowed",
"description": "Whether JavaScript owns the wrapped native resource."
},
"nullable": {
"type": "boolean",
"default": false,
"description": "Whether a null native resource pointer is valid."
},
"thread": {
"enum": ["any", "main", "creator"],
"default": "any",
"description": "Thread-affinity contract enforced when unwrapping the handle."
},
"finalizer": {
"type": "string",
"minLength": 1,
"pattern": "\\S",
"description": "Optional one-shot finalizer symbol. Valid only on owned return handles."
},
"debugName": {
"type": "string",
"minLength": 1,
"pattern": "\\S",
"description": "Short debug name stored in the runtime handle payload."
}
}
},
"abiPromiseDescriptor": {
"type": "object",
"additionalProperties": false,
"required": ["kind"],
"properties": {
"kind": { "const": "promise" },
"result": {
"$ref": "#/$defs/abiDescriptor",
"description": "Optional metadata describing the JavaScript promise result."
},
"completion": {
"enum": ["direct", "native_async"],
"default": "direct",
"description": "Promise completion machinery. `native_async` is valid only for return descriptors."
},
"thread": {
"enum": ["any", "main"],
"default": "any",
"description": "Thread policy for native async completion requests."
}
}
},
"abiBufferAndLenDescriptor": {
"type": "object",
"additionalProperties": false,
"required": ["kind"],
"properties": {
"kind": { "const": "buffer+len" }
}
},
"abiPodDescriptor": {
"type": "object",
"additionalProperties": false,
"required": ["kind", "fields"],
"properties": {
"kind": { "const": "pod" },
"name": {
"type": "string",
"minLength": 1,
"pattern": "\\S",
"description": "Optional record name used in diagnostics and proof artifacts."
},
"fields": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#/$defs/abiPodFieldDescriptor" },
"description": "Ordered C-layout fields. Field order is part of the ABI."
}
}
},
"abiPodAndCountDescriptor": {
"type": "object",
"additionalProperties": false,
"required": ["kind", "fields"],
"properties": {
"kind": { "const": "pod+count" },
"name": {
"type": "string",
"minLength": 1,
"pattern": "\\S",
"description": "Optional record name used in diagnostics and proof artifacts."
},
"fields": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#/$defs/abiPodFieldDescriptor" },
"description": "Ordered C-layout record fields. The JS argument supplies a packed record view and Perry lowers it to data pointer plus record count."
}
}
},
"abiPodFieldDescriptor": {
"type": "object",
"additionalProperties": false,
"required": ["name"],
"oneOf": [
{ "required": ["type"] },
{ "required": ["abi"] }
],
"properties": {
"name": {
"type": "string",
"minLength": 1,
"pattern": "\\S",
"description": "JavaScript object property and C-layout field name."
},
"type": {
"$ref": "#/$defs/abiPodFieldType",
"description": "Native scalar ABI descriptor for this field."
},
"abi": {
"$ref": "#/$defs/abiPodFieldType",
"description": "Alias for `type` when the manifest author wants to avoid a JavaScript property named `type`."
}
}
},
"abiPodFieldType": {
"description": "Scalar ABI descriptor accepted inside a `pod` field.",
"anyOf": [
{ "$ref": "#/$defs/abiPodFieldString" },
{ "$ref": "#/$defs/abiPodFieldStructuredScalar" }
]
},
"abiPodFieldString": {
"type": "string",
"enum": [
"i32",
"i64",
"u32",
"u64",
"usize",
"f32",
"f64",
"number",
"buffer_len",
"handle_id"
]
},
"abiPodFieldStructuredScalar": {
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"required": ["kind"],
"properties": {
"kind": {
"enum": [
"i32",
"i64",
"u32",
"u64",
"usize",
"f32",
"f64",
"number",
"buffer_len",
"handle_id"
]
}
}
},
{
"$ref": "#/$defs/abiPodDescriptor"
}
]
},
"abiScalarDescriptor": {
"type": "object",
"additionalProperties": false,
"required": ["kind"],
"properties": {
"kind": {
"enum": [
"jsvalue",
"js_value",
"string",
"bool",
"boolean",
"i32",
"i64",
"i64_str",
"u32",
"u64",
"usize",
"f32",
"f64",
"number",
"ptr",
"buffer_len",
"void"
]
}
}
},
"targetConfig": {
"type": "object",
"additionalProperties": false,
"properties": {
"available": {
"type": "boolean",
"description": "Set false when this package intentionally does not ship the selected target. Perry skips the target config without requiring crate/lib/prebuilt metadata."
},
"unavailableReason": {
"type": "string",
"description": "Human-readable reason shown when available is false."
},
"unavailable_reason": {
"type": "string",
"description": "Snake_case alias for unavailableReason."
},
"crate": {
"type": "string",
"description": "Path (relative to package.json) to the Cargo crate that produces the staticlib."
},
"lib": {
"type": "string",
"description": "Library name (without `lib` prefix or `.a` extension)."
},
"frameworks": {
"type": "array",
"items": { "type": "string" },
"description": "Apple-only frameworks (-framework <name>)."
},
"libs": {
"type": "array",
"items": { "type": "string" },
"description": "System libraries (-l<name>)."
},
"pkgConfig": {
"type": "array",
"items": { "type": "string" }
},
"libDirs": {
"type": "array",
"items": { "type": "string" },
"description": "Additional library search paths, relative to package.json unless absolute."
},
"resources": {
"type": "array",
"items": { "type": "string" },
"description": "Native resource files/directories copied into NativeLibraries/<package>/ in the target bundle or output staging directory."
},
"shaderOutputs": {
"type": "array",
"items": { "type": "string" },
"description": "Precompiled shader/resource outputs copied into NativeLibraries/<package>/ in the target bundle or output staging directory."
},
"shader_outputs": {
"type": "array",
"items": { "type": "string" },
"description": "Snake_case alias for shaderOutputs."
},
"backends": {
"type": "object",
"additionalProperties": false,
"properties": {
"metal": { "$ref": "#/$defs/backendConfig" },
"vulkan": { "$ref": "#/$defs/backendConfig" },
"d3d12": { "$ref": "#/$defs/backendConfig" }
},
"description": "Backend-specific packaging metadata. Metal is Apple-only; Vulkan is supported on macOS/Linux/Windows/Android/HarmonyOS; D3D12 is Windows-only."
},
"swift_sources": {
"type": "array",
"items": { "type": "string" }
},
"metal_sources": {
"type": "array",
"items": { "type": "string" }
},
"prebuilt": {
"type": "string",
"description": "Path to a pre-built .a archive. When set, Perry skips `cargo build`."
}
}
},
"backendConfig": {
"type": "object",
"additionalProperties": false,
"properties": {
"available": {
"type": "boolean",
"description": "Set false when this backend is intentionally unavailable for this target."
},
"unavailableReason": {
"type": "string"
},
"unavailable_reason": {
"type": "string"
},
"prebuilt": {
"type": "string",
"description": "Backend-specific archive to link in addition to the target-level archive."
},
"frameworks": {
"type": "array",
"items": { "type": "string" }
},
"libs": {
"type": "array",
"items": { "type": "string" }
},
"libDirs": {
"type": "array",
"items": { "type": "string" }
},
"pkgConfig": {
"type": "array",
"items": { "type": "string" }
},
"shaderSources": {
"type": "array",
"items": { "type": "string" },
"description": "Source shaders compiled during packaging with xcrun metal, glslc, or dxc. Override discovery with PERRY_XCRUN, PERRY_GLSLC, or PERRY_DXC."
},
"shader_sources": {
"type": "array",
"items": { "type": "string" },
"description": "Snake_case alias for shaderSources."
},
"shaderOutputs": {
"type": "array",
"items": { "type": "string" }
},
"shader_outputs": {
"type": "array",
"items": { "type": "string" }
},
"resources": {
"type": "array",
"items": { "type": "string" }
},
"package": {
"type": "object",
"description": "Optional descriptive backend artifact metadata emitted as perry-backend-package.json inside NativeLibraries/<package>/<backend>/.",
"additionalProperties": false,
"properties": {
"name": { "type": "string" },
"version": { "type": "string" },
"kind": { "type": "string" }
}
}
}
}
}
}