@mica-js/document 0.2.0 → 0.4.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.
- package/README.md +11 -2
- package/dist/canvas/index.js +2 -1
- package/dist/canvas/index.js.map +1 -1
- package/dist/fused/index.d.ts +652 -0
- package/dist/fused/index.js +2878 -0
- package/dist/fused/index.js.map +1 -0
- package/dist/schematic/index.js +2 -1
- package/dist/schematic/index.js.map +1 -1
- package/dist/uuid-DegOw3iI.js +10 -0
- package/dist/uuid-DegOw3iI.js.map +1 -0
- package/dist/{validate-Cz-ZbbEr.js → validate-Co8aIzz6.js} +2 -9
- package/dist/validate-Co8aIzz6.js.map +1 -0
- package/package.json +6 -2
- package/dist/validate-Cz-ZbbEr.js.map +0 -1
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
/** Explicit connection node: a drawn branch point or a free wire end (RFC 0024). */
|
|
2
|
+
export declare interface ConnectionNode extends Point2D {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly kind: 'junction' | 'free';
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/** Connection edge between two endpoints with its intermediate bends (RFC 0024). */
|
|
8
|
+
export declare interface ConnectionWire {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly from: Endpoint;
|
|
11
|
+
readonly to: Endpoint;
|
|
12
|
+
/** Intermediate points only; the full polyline is derived from the endpoints. */
|
|
13
|
+
readonly bends: readonly Point2D[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Non-throwing form of {@link parseStrictJson}; the caller decides how to surface the problems. */
|
|
17
|
+
export declare function decodeStrictJson(text: string): JsonDecodeResult;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Derives the nets of `document` using the pinned pins of `manifests`.
|
|
21
|
+
*
|
|
22
|
+
* @throws {FusedDocumentError} when an instance has no manifest, a pin endpoint is not declared,
|
|
23
|
+
* a connection endpoint is missing, or a net has conflicting names or ideal voltages.
|
|
24
|
+
*/
|
|
25
|
+
export declare function deriveFusedTopology(document: FusedDocument, manifests: ReadonlyMap<string, UnifiedDeviceManifest>): FusedTopology;
|
|
26
|
+
|
|
27
|
+
/** Exact release a document depends on (RFC 0020 / RFC 0024). */
|
|
28
|
+
export declare interface DeviceDependency {
|
|
29
|
+
readonly version: string;
|
|
30
|
+
/** `sha256:` plus 64 lowercase hexadecimal digits of the release identity. */
|
|
31
|
+
readonly integrity: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Read interfaces of locked device packages and resolved firmware images (RFC 0020 / RFC 0026).
|
|
36
|
+
*
|
|
37
|
+
* These are pure data contracts: the host implements them, the document package only consumes
|
|
38
|
+
* their shape.
|
|
39
|
+
*/
|
|
40
|
+
/** Release a document locks (RFC 0020). */
|
|
41
|
+
export declare interface DeviceLock {
|
|
42
|
+
/** Full `publisher:name` device id. */
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly version: string;
|
|
45
|
+
/** `sha256:` plus 64 lowercase hexadecimal digits of the release identity. */
|
|
46
|
+
readonly integrity: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Description of one device property (RFC 0009, extended by RFC 0020 and RFC 0026).
|
|
51
|
+
*
|
|
52
|
+
* The constraints that apply depend on `type`; a descriptor that declares a constraint of another
|
|
53
|
+
* type is rejected instead of being partially interpreted.
|
|
54
|
+
*/
|
|
55
|
+
export declare interface DevicePropertyDescriptor {
|
|
56
|
+
readonly type: DevicePropertyType;
|
|
57
|
+
readonly title?: string;
|
|
58
|
+
readonly description?: string;
|
|
59
|
+
/** Declared default; absent when the description omits it. */
|
|
60
|
+
readonly default?: PropertyValue;
|
|
61
|
+
/** When true an explicit `null` is a valid instance value. */
|
|
62
|
+
readonly nullable?: boolean;
|
|
63
|
+
readonly group?: string;
|
|
64
|
+
/** Panel ordering hint; a non-negative integer. */
|
|
65
|
+
readonly order?: number;
|
|
66
|
+
/** `string`: maximum length in Unicode code points. */
|
|
67
|
+
readonly maxLength?: number;
|
|
68
|
+
/** `integer` / `number`: closed lower bound. */
|
|
69
|
+
readonly min?: number;
|
|
70
|
+
/** `integer` / `number`: closed upper bound. */
|
|
71
|
+
readonly max?: number;
|
|
72
|
+
/** `number`: open lower bound. */
|
|
73
|
+
readonly exclusiveMin?: number;
|
|
74
|
+
/** `integer` / `number`: editing step, always greater than zero. */
|
|
75
|
+
readonly step?: number;
|
|
76
|
+
/** `number` display unit of the stored value. */
|
|
77
|
+
readonly unit?: string;
|
|
78
|
+
/** `color`: whether `#RRGGBBAA` values are accepted. */
|
|
79
|
+
readonly alpha?: boolean;
|
|
80
|
+
/** `enum`: non-empty option list. */
|
|
81
|
+
readonly options?: readonly PropertyOption[];
|
|
82
|
+
/** `image` / `binary` / `firmware`: host-side payload limit in bytes. */
|
|
83
|
+
readonly maxBytes?: number;
|
|
84
|
+
/** `image`: host-side pixel limit. */
|
|
85
|
+
readonly maxPixels?: number;
|
|
86
|
+
/** `binary`: file extension filter, each entry matching `\.[A-Za-z0-9]+`. */
|
|
87
|
+
readonly extensions?: readonly string[];
|
|
88
|
+
/** `firmware`: non-empty address space map (RFC 0026). */
|
|
89
|
+
readonly addressSpaces?: Readonly<Record<string, FirmwareAddressSpace>>;
|
|
90
|
+
/** `firmware`: default address space id, present in `addressSpaces`. */
|
|
91
|
+
readonly addressSpace?: string;
|
|
92
|
+
/** `firmware`: default BIN load address inside the default address space. */
|
|
93
|
+
readonly loadAddress?: number;
|
|
94
|
+
readonly loader?: ProgramLoader;
|
|
95
|
+
readonly formats?: readonly ProgramFormat[];
|
|
96
|
+
readonly defaults?: ProgramDefaults;
|
|
97
|
+
readonly templates?: readonly string[];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Predefined property value kinds of a device property description (RFC 0009 / RFC 0020). */
|
|
101
|
+
export declare type DevicePropertyType = 'string' | 'integer' | 'number' | 'boolean' | 'color' | 'enum' | 'image' | 'binary' | 'firmware' | 'program';
|
|
102
|
+
|
|
103
|
+
/** Selects available releases and opens exact locks (RFC 0020). */
|
|
104
|
+
export declare interface DeviceRegistry {
|
|
105
|
+
/** Selects a release by SemVer range and `engines.mica`. */
|
|
106
|
+
resolve?(query: DeviceResolutionQuery): Promise<DeviceLock>;
|
|
107
|
+
open(lock: DeviceLock): Promise<PackageFiles>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Query for the highest available release compatible with a host. */
|
|
111
|
+
export declare interface DeviceResolutionQuery {
|
|
112
|
+
readonly id: string;
|
|
113
|
+
readonly range: string;
|
|
114
|
+
readonly hostApiVersion: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Connection target of a wire, label or voltage reference (RFC 0024). */
|
|
118
|
+
export declare type Endpoint = {
|
|
119
|
+
readonly kind: 'pin';
|
|
120
|
+
readonly instance: string;
|
|
121
|
+
readonly pin: string;
|
|
122
|
+
} | {
|
|
123
|
+
readonly kind: 'node';
|
|
124
|
+
readonly node: string;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/** Declared firmware address space (RFC 0026). */
|
|
128
|
+
export declare interface FirmwareAddressSpace {
|
|
129
|
+
readonly title?: string;
|
|
130
|
+
/** First address the space allows, in bytes. */
|
|
131
|
+
readonly start: number;
|
|
132
|
+
/** Number of bytes the space allows. */
|
|
133
|
+
readonly size: number;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* `firmware` value that names a fixed file (RFC 0026). `addressSpace` and `loadAddress` override
|
|
138
|
+
* the attribute defaults for the address space and, for BIN, the load address.
|
|
139
|
+
*/
|
|
140
|
+
export declare type FirmwareFileReference = ResourceReference & {
|
|
141
|
+
readonly addressSpace?: string;
|
|
142
|
+
readonly loadAddress?: number;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/** Resolved firmware program handed to a model factory (RFC 0026). */
|
|
146
|
+
export declare interface FirmwareImage {
|
|
147
|
+
readonly segments: readonly FirmwareSegment[];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Persistent `firmware` property value (RFC 0026). */
|
|
151
|
+
export declare type FirmwareReference = FirmwareFileReference;
|
|
152
|
+
|
|
153
|
+
/** One contiguous firmware load into a declared address space (RFC 0026). */
|
|
154
|
+
export declare interface FirmwareSegment {
|
|
155
|
+
/** Address space id declared by the firmware property. */
|
|
156
|
+
readonly addressSpace: string;
|
|
157
|
+
/** Absolute byte address inside that space. */
|
|
158
|
+
readonly address: number;
|
|
159
|
+
readonly data: ReadonlyBytes;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Last floating rectangle of an HTML view, relative to the editor's available area (RFC 0024). */
|
|
163
|
+
export declare interface FloatingBounds extends Point2D {
|
|
164
|
+
readonly width: number;
|
|
165
|
+
readonly height: number;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Version of the fused schematic document contract (RFC 0024). */
|
|
169
|
+
export declare const FUSED_DOCUMENT_VERSION = 2;
|
|
170
|
+
|
|
171
|
+
/** One problem found while validating fused device data. */
|
|
172
|
+
export declare interface FusedDiagnostic {
|
|
173
|
+
readonly severity: FusedDiagnosticSeverity;
|
|
174
|
+
/** Stable contract code; the human readable `message` is not part of the contract. */
|
|
175
|
+
readonly code: FusedDiagnosticCode;
|
|
176
|
+
readonly message: string;
|
|
177
|
+
/** JSON Pointer of the offending member; the empty string addresses the whole document. */
|
|
178
|
+
readonly pointer: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Stable diagnostic codes of the fused contracts.
|
|
183
|
+
*
|
|
184
|
+
* The codes follow the RFC 0020 / 0021 / 0022 / 0024 / 0026 tables. `json/*` and `schema/*` cover
|
|
185
|
+
* structural problems, `package/*` manifest and path problems, and the remaining families cover
|
|
186
|
+
* the named runtime contract they belong to.
|
|
187
|
+
*/
|
|
188
|
+
export declare type FusedDiagnosticCode = 'json/invalid' | 'json/duplicate-key' | 'json/not-object' | 'schema/unsupported-version' | 'schema/missing-field' | 'schema/invalid-type' | 'schema/invalid-value' | 'schema/unknown-field' | 'package/invalid-manifest' | 'package/invalid-path' | 'package/invalid-icon' | 'package/unsupported-engine' | 'document/duplicate-id' | 'document/duplicate-designator' | 'document/unlocked-device' | 'document/invalid-view-layout' | 'connection/unknown-endpoint' | 'connection/self-edge' | 'net/naming-conflict' | 'net/reference-conflict' | 'device/unresolved' | 'device/unknown-pin' | 'model/invalid-interface' | 'model/invalid-params' | 'model/invalid-result' | 'model/invalid-event' | 'type/unknown' | 'view2d/invalid-geometry' | 'view2d/pin-mismatch' | 'firmware/invalid-image' | 'firmware/out-of-range';
|
|
189
|
+
|
|
190
|
+
/** Diagnostics of the fused device package and fused `.sch` contracts. */
|
|
191
|
+
export declare type FusedDiagnosticSeverity = 'error' | 'warning';
|
|
192
|
+
|
|
193
|
+
/** Run-time body and designator display settings of the document (RFC 0024). */
|
|
194
|
+
export declare interface FusedDisplaySettings {
|
|
195
|
+
readonly body?: boolean;
|
|
196
|
+
readonly designators?: boolean;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** Root contract of a fused `.sch` version 2 file (RFC 0024). */
|
|
200
|
+
export declare interface FusedDocument {
|
|
201
|
+
readonly version: FusedDocumentVersion;
|
|
202
|
+
/** Device id to locked release; every instance device must be locked here. */
|
|
203
|
+
readonly dependencies: Readonly<Record<string, DeviceDependency>>;
|
|
204
|
+
readonly instances: readonly FusedInstance[];
|
|
205
|
+
readonly nodes: readonly ConnectionNode[];
|
|
206
|
+
readonly wires: readonly ConnectionWire[];
|
|
207
|
+
readonly labels: readonly NetLabel[];
|
|
208
|
+
readonly references: readonly VoltageReference[];
|
|
209
|
+
readonly display?: FusedDisplaySettings;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Thrown when fused device data violates its contract.
|
|
214
|
+
*
|
|
215
|
+
* `diagnostics` carries every problem found, each with an explicit code and JSON Pointer, so a
|
|
216
|
+
* host can report them without re-parsing.
|
|
217
|
+
*/
|
|
218
|
+
export declare class FusedDocumentError extends Error {
|
|
219
|
+
readonly diagnostics: readonly FusedDiagnostic[];
|
|
220
|
+
constructor(diagnostics: readonly FusedDiagnostic[]);
|
|
221
|
+
/** Code of the first diagnostic, for coarse programmatic handling. */
|
|
222
|
+
get code(): FusedDiagnosticCode | undefined;
|
|
223
|
+
/** Field path of the first diagnostic, for coarse programmatic handling. */
|
|
224
|
+
get pointer(): string | undefined;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export declare type FusedDocumentVersion = typeof FUSED_DOCUMENT_VERSION;
|
|
228
|
+
|
|
229
|
+
/** One placed device or display-only object (RFC 0024). */
|
|
230
|
+
export declare interface FusedInstance {
|
|
231
|
+
/** Document-unique UUID v4. */
|
|
232
|
+
readonly id: string;
|
|
233
|
+
/** Full `publisher:name` device id, locked by the dependency table. */
|
|
234
|
+
readonly device: string;
|
|
235
|
+
readonly designator?: string;
|
|
236
|
+
/** Offset from the package's designator anchor, in device-local millimetres. */
|
|
237
|
+
readonly designatorOffset?: Point2D;
|
|
238
|
+
readonly placement: Placement2D;
|
|
239
|
+
readonly properties?: Readonly<Record<string, PropertyValue>>;
|
|
240
|
+
/** Per-instance body image override; falls back to the document setting. */
|
|
241
|
+
readonly display?: {
|
|
242
|
+
readonly body?: boolean;
|
|
243
|
+
};
|
|
244
|
+
readonly viewLayout?: InstanceViewLayout;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** One derived electrical net: its stable id, deduplicated pins and ideal voltage. */
|
|
248
|
+
export declare interface FusedNet {
|
|
249
|
+
/** Derived from the sorted connection endpoint identities of the net. */
|
|
250
|
+
readonly id: string;
|
|
251
|
+
readonly pins: readonly FusedNetPin[];
|
|
252
|
+
/** Ideal voltage attached to the net; absent when the net has no voltage reference. */
|
|
253
|
+
readonly voltage?: number;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** One device pin inside a derived net (RFC 0024). */
|
|
257
|
+
export declare interface FusedNetPin {
|
|
258
|
+
readonly instance: string;
|
|
259
|
+
readonly pin: string;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export declare interface FusedTopology {
|
|
263
|
+
readonly nets: readonly FusedNet[];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** Resolved 2D presentation geometry of a device (RFC 0022). */
|
|
267
|
+
export declare interface Geometry2D {
|
|
268
|
+
readonly sizing: 'physical' | 'flexible';
|
|
269
|
+
/** Drawing extent; drawn content must stay inside it. */
|
|
270
|
+
readonly bounds: Rect2D;
|
|
271
|
+
/** Body extent used for layout diagnostics. */
|
|
272
|
+
readonly bodyBounds: Rect2D;
|
|
273
|
+
/** Package-root relative PNG or self-contained static SVG body image. */
|
|
274
|
+
readonly bodyImage?: string;
|
|
275
|
+
/** Pin id to geometry; the key set matches the manifest pin ids exactly. */
|
|
276
|
+
readonly pins: Readonly<Record<string, PinGeometry2D>>;
|
|
277
|
+
/** Reference designator anchor; defaults to the body's top-left corner. */
|
|
278
|
+
readonly designator?: Point2D;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** One HTML view declaration (RFC 0020 / RFC 0023). */
|
|
282
|
+
export declare interface HtmlViewDefinition {
|
|
283
|
+
/** Non-empty title used for the view header, tooltip and accessible name. */
|
|
284
|
+
readonly title: string;
|
|
285
|
+
/** Package-root relative `.html` path. */
|
|
286
|
+
readonly entry: string;
|
|
287
|
+
/** Initial location; defaults to `sidebar`. */
|
|
288
|
+
readonly defaultLocation?: 'sidebar' | 'floating';
|
|
289
|
+
/** VS Code Codicons name supplied by the editor. */
|
|
290
|
+
readonly icon?: string;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** Layout of one HTML view of the owning device type (RFC 0024). */
|
|
294
|
+
export declare interface HtmlViewLayout extends SidebarViewLayout {
|
|
295
|
+
readonly viewId: string;
|
|
296
|
+
readonly location: 'sidebar' | 'floating';
|
|
297
|
+
readonly floatingBounds?: FloatingBounds;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** Per-instance sidebar and HTML view layout (RFC 0024). */
|
|
301
|
+
export declare interface InstanceViewLayout {
|
|
302
|
+
readonly properties: SidebarViewLayout;
|
|
303
|
+
readonly views: readonly HtmlViewLayout[];
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** VS Code Codicons name supplied by the editor (RFC 0020). */
|
|
307
|
+
export declare function isCodiconName(value: string): boolean;
|
|
308
|
+
|
|
309
|
+
/** Full `publisher:name` device id (RFC 0020). */
|
|
310
|
+
export declare function isDeviceId(value: string): boolean;
|
|
311
|
+
|
|
312
|
+
/** Event key in `onDidXxx` form (RFC 0020 / RFC 0021). */
|
|
313
|
+
export declare function isEventKey(value: string): boolean;
|
|
314
|
+
|
|
315
|
+
/** Release identity or file digest: `sha256:` plus 64 lowercase hex digits (RFC 0020). */
|
|
316
|
+
export declare function isIntegrity(value: string): boolean;
|
|
317
|
+
|
|
318
|
+
/** Property, method, public type and view id key (RFC 0020). */
|
|
319
|
+
export declare function isMemberKey(value: string): boolean;
|
|
320
|
+
|
|
321
|
+
/** Lexical rules of device identity, versions, paths and member names (RFC 0020 / RFC 0024). */
|
|
322
|
+
/** Publisher namespace or device name segment; defaults to `U` for designator prefixes. */
|
|
323
|
+
export declare function isNameSegment(value: string): boolean;
|
|
324
|
+
|
|
325
|
+
/** Model pin name, matching the DDL identifier form (RFC 0021). */
|
|
326
|
+
export declare function isPinId(value: string): boolean;
|
|
327
|
+
|
|
328
|
+
/** Full SemVer version, including prerelease and build metadata (RFC 0020). */
|
|
329
|
+
export declare function isSemVer(value: string): boolean;
|
|
330
|
+
|
|
331
|
+
export declare interface JsonDecodeFailure {
|
|
332
|
+
readonly ok: false;
|
|
333
|
+
readonly diagnostics: readonly FusedDiagnostic[];
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export declare type JsonDecodeResult = JsonDecodeSuccess | JsonDecodeFailure;
|
|
337
|
+
|
|
338
|
+
export declare interface JsonDecodeSuccess {
|
|
339
|
+
readonly ok: true;
|
|
340
|
+
readonly value: unknown;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export declare type MemoryProgram = FirmwareImage;
|
|
344
|
+
|
|
345
|
+
/** One declared model method (RFC 0021). */
|
|
346
|
+
export declare interface MethodDefinition {
|
|
347
|
+
readonly params: ValueType;
|
|
348
|
+
readonly returns: ValueType;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* The `model` object of a unified device manifest (RFC 0020 / RFC 0021).
|
|
353
|
+
*
|
|
354
|
+
* `types` declares the public payload type names that `ref` addresses, `methods` and `events`
|
|
355
|
+
* declare the instance interface the model entry must implement.
|
|
356
|
+
*/
|
|
357
|
+
export declare interface ModelDefinition {
|
|
358
|
+
/** Package-root relative `.js` path of the model entry. */
|
|
359
|
+
readonly entry: string;
|
|
360
|
+
readonly types?: Readonly<Record<string, ValueType>>;
|
|
361
|
+
readonly methods?: Readonly<Record<string, MethodDefinition>>;
|
|
362
|
+
readonly events?: Readonly<Record<string, ValueType>>;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/** Net name declared on one endpoint (RFC 0024). */
|
|
366
|
+
export declare interface NetLabel {
|
|
367
|
+
readonly id: string;
|
|
368
|
+
readonly target: Endpoint;
|
|
369
|
+
readonly name: string;
|
|
370
|
+
readonly offset?: Point2D;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/** One file of a release file list (RFC 0020). */
|
|
374
|
+
export declare interface PackageFile {
|
|
375
|
+
/** Original byte length. */
|
|
376
|
+
readonly size: number;
|
|
377
|
+
/** `sha256:` plus 64 lowercase hexadecimal digits of the file bytes. */
|
|
378
|
+
readonly integrity: string;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/** Read-only view of one locked package (RFC 0020). */
|
|
382
|
+
export declare interface PackageFiles {
|
|
383
|
+
readonly lock: DeviceLock;
|
|
384
|
+
/** Package-root relative path to declared size and digest. */
|
|
385
|
+
readonly files: Readonly<Record<string, PackageFile>>;
|
|
386
|
+
/** Returns independent bytes; `path` is a normalized package-root relative path. */
|
|
387
|
+
read(path: string): Promise<Uint8Array>;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Package-root relative POSIX file path problem, or `undefined` when it is well formed.
|
|
392
|
+
*
|
|
393
|
+
* Case sensitivity, empty segments, `.` / `..`, backslashes and absolute paths are rejected
|
|
394
|
+
* (RFC 0020).
|
|
395
|
+
*/
|
|
396
|
+
export declare function packagePathProblem(path: string): string | undefined;
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Parses a fused `.sch` version 2 document (RFC 0024).
|
|
400
|
+
*
|
|
401
|
+
* Strings are parsed as JSON text; any other value is validated as-is.
|
|
402
|
+
*
|
|
403
|
+
* @throws {FusedDocumentError} with the diagnostic code and JSON Pointer of every violation.
|
|
404
|
+
*/
|
|
405
|
+
export declare function parseFusedDocument(input: unknown): FusedDocument;
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Parses a `Geometry2D` declaration (RFC 0022).
|
|
409
|
+
*
|
|
410
|
+
* `pins` is the authoritative pin id set; when given, the geometry pin keys must match it exactly.
|
|
411
|
+
*
|
|
412
|
+
* @throws {FusedDocumentError} with the diagnostic code and JSON Pointer of every violation.
|
|
413
|
+
*/
|
|
414
|
+
export declare function parseGeometry2D(value: unknown, pins?: readonly string[]): Geometry2D;
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Decodes JSON text, rejecting duplicate keys and reporting every problem with a JSON Pointer.
|
|
418
|
+
*
|
|
419
|
+
* @throws {FusedDocumentError} when the text is not valid JSON or repeats an object key.
|
|
420
|
+
*/
|
|
421
|
+
export declare function parseStrictJson(text: string): unknown;
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Parses a unified device manifest (RFC 0020).
|
|
425
|
+
*
|
|
426
|
+
* Strings are parsed as JSON text; any other value is validated as-is.
|
|
427
|
+
*
|
|
428
|
+
* @throws {FusedDocumentError} with the diagnostic code and JSON Pointer of every violation.
|
|
429
|
+
*/
|
|
430
|
+
export declare function parseUnifiedManifest(input: unknown): UnifiedDeviceManifest;
|
|
431
|
+
|
|
432
|
+
/** Display information of one declared pin (RFC 0020). */
|
|
433
|
+
export declare interface PinDeclaration {
|
|
434
|
+
readonly label?: string;
|
|
435
|
+
readonly description?: string;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/** Anchoring of one pin inside a device's local coordinate system (RFC 0022). */
|
|
439
|
+
export declare interface PinGeometry2D {
|
|
440
|
+
readonly position: Point2D;
|
|
441
|
+
/** Non-zero direction the host normalizes for the pin stub and the label orientation. */
|
|
442
|
+
readonly outward: Point2D;
|
|
443
|
+
readonly label?: PinLabelGeometry2D;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/** Optional pin label placement; `visible` defaults to `true` (RFC 0022). */
|
|
447
|
+
export declare interface PinLabelGeometry2D {
|
|
448
|
+
readonly position: Point2D;
|
|
449
|
+
readonly visible?: boolean;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/** Placement of an instance in scene millimetres (RFC 0024). */
|
|
453
|
+
export declare interface Placement2D extends Point2D {
|
|
454
|
+
/** Clockwise rotation in degrees around the device's local origin. */
|
|
455
|
+
readonly rotation: number;
|
|
456
|
+
/** Flexible devices carry a finite positive layout width. */
|
|
457
|
+
readonly width?: number;
|
|
458
|
+
/** Flexible devices carry a finite positive layout height. */
|
|
459
|
+
readonly height?: number;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/** Static two-dimensional geometry of a device (RFC 0022). */
|
|
463
|
+
/** Local coordinate; `x` points right and `y` points down (RFC 0022). */
|
|
464
|
+
export declare interface Point2D {
|
|
465
|
+
readonly x: number;
|
|
466
|
+
readonly y: number;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
export declare type ProgramAddressSpace = FirmwareAddressSpace;
|
|
470
|
+
|
|
471
|
+
export declare interface ProgramDefaults {
|
|
472
|
+
readonly addressSpace: string;
|
|
473
|
+
readonly loadAddress?: number;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
export declare type ProgramFileReference = FirmwareFileReference;
|
|
477
|
+
|
|
478
|
+
export declare interface ProgramFiles {
|
|
479
|
+
readonly paths: readonly string[];
|
|
480
|
+
read(path: string): ReadonlyBytes;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
export declare type ProgramFormat = 'bin' | 'hex' | 'elf';
|
|
484
|
+
|
|
485
|
+
export declare type ProgramLoader = 'memory' | 'filesystem';
|
|
486
|
+
|
|
487
|
+
/** Program project resolved by the host at run preparation; the name is display metadata. */
|
|
488
|
+
export declare interface ProgramProjectReference {
|
|
489
|
+
readonly mode: 'project';
|
|
490
|
+
readonly projectId: string;
|
|
491
|
+
readonly name?: string;
|
|
492
|
+
readonly addressSpace?: string;
|
|
493
|
+
readonly loadAddress?: number;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
export declare type ProgramReference = ProgramFileReference | ProgramProjectReference;
|
|
497
|
+
|
|
498
|
+
export declare type ProgramSegment = FirmwareSegment;
|
|
499
|
+
|
|
500
|
+
/** Project-root relative POSIX file path problem, or `undefined` when it is well formed. */
|
|
501
|
+
export declare function projectPathProblem(path: string): string | undefined;
|
|
502
|
+
|
|
503
|
+
/** One selectable `enum` option (RFC 0009). */
|
|
504
|
+
export declare interface PropertyOption {
|
|
505
|
+
readonly value: string;
|
|
506
|
+
readonly label: string;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Instance property value stored in `FusedInstance.properties` (RFC 0024): a scalar, a resource
|
|
511
|
+
* reference, a firmware reference, or `null` for an explicitly cleared nullable property.
|
|
512
|
+
*/
|
|
513
|
+
export declare type PropertyValue = string | number | boolean | null | ResourceReference | ProgramReference;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Structural read-only byte snapshot: read-only access plus a `slice` that returns an independent
|
|
517
|
+
* mutable copy (see `docs/spec/javascript/interfaces.rst`).
|
|
518
|
+
*/
|
|
519
|
+
export declare interface ReadonlyBytes {
|
|
520
|
+
readonly length: number;
|
|
521
|
+
readonly byteLength: number;
|
|
522
|
+
readonly [index: number]: number | undefined;
|
|
523
|
+
[Symbol.iterator](): IterableIterator<number>;
|
|
524
|
+
slice(start?: number, end?: number): Uint8Array;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/** Axis-aligned rectangle in local coordinates (RFC 0022). */
|
|
528
|
+
export declare interface Rect2D extends Point2D {
|
|
529
|
+
readonly width: number;
|
|
530
|
+
readonly height: number;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Persistent instance property values of the fused document (RFC 0024) with the resource and
|
|
535
|
+
* firmware extensions of RFC 0020 / RFC 0026.
|
|
536
|
+
*/
|
|
537
|
+
/** Where an `image` / `binary` / `firmware` value lives (RFC 0020). */
|
|
538
|
+
export declare type ResourceMode = 'asset' | 'package';
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Reference to a resource instead of inline bytes (RFC 0024).
|
|
542
|
+
*
|
|
543
|
+
* `package` uses a package-root relative POSIX path; `asset` uses a host library identity.
|
|
544
|
+
*/
|
|
545
|
+
export declare type ResourceReference = {
|
|
546
|
+
readonly mode: 'package';
|
|
547
|
+
readonly src: string;
|
|
548
|
+
} | {
|
|
549
|
+
readonly mode: 'asset';
|
|
550
|
+
readonly assetId: string;
|
|
551
|
+
readonly name: string;
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
/** Collapsible sidebar panel layout of the built-in property view (RFC 0024). */
|
|
555
|
+
export declare interface SidebarViewLayout {
|
|
556
|
+
/** Content height in CSS px while expanded. */
|
|
557
|
+
readonly height: number;
|
|
558
|
+
readonly collapsed: boolean;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/** Deepest object/array nesting the reader accepts. */
|
|
562
|
+
export declare const STRICT_JSON_MAX_DEPTH = 256;
|
|
563
|
+
|
|
564
|
+
/** Reserved non-2D entry points of a device package (RFC 0020). */
|
|
565
|
+
export declare interface UnifiedDeviceEntries {
|
|
566
|
+
/** Package-root relative `.js` path of the 3D view entry. */
|
|
567
|
+
readonly view3d?: string;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/** Root contract of a single-device package manifest (RFC 0020). */
|
|
571
|
+
export declare interface UnifiedDeviceManifest {
|
|
572
|
+
readonly publisher: string;
|
|
573
|
+
readonly name: string;
|
|
574
|
+
readonly version: string;
|
|
575
|
+
readonly description?: string;
|
|
576
|
+
readonly license?: string;
|
|
577
|
+
/** Host API compatibility range; `mica` is required. */
|
|
578
|
+
readonly engines: {
|
|
579
|
+
readonly mica: string;
|
|
580
|
+
};
|
|
581
|
+
readonly displayName: string;
|
|
582
|
+
/** Package-root relative PNG or self-contained static SVG icon. */
|
|
583
|
+
readonly icon?: string;
|
|
584
|
+
/** Reference designator prefix; defaults to `U`. */
|
|
585
|
+
readonly designatorPrefix?: string;
|
|
586
|
+
readonly entries?: UnifiedDeviceEntries;
|
|
587
|
+
readonly properties?: Readonly<Record<string, DevicePropertyDescriptor>>;
|
|
588
|
+
readonly pins?: Readonly<Record<string, PinDeclaration>>;
|
|
589
|
+
readonly model?: ModelDefinition;
|
|
590
|
+
readonly view2d?: View2DDefinition;
|
|
591
|
+
readonly view?: Readonly<Record<string, HtmlViewDefinition>>;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Validates one model value against its declared type (RFC 0021).
|
|
596
|
+
*
|
|
597
|
+
* @throws {FusedDocumentError} with the diagnostic code and JSON Pointer of every violation.
|
|
598
|
+
*/
|
|
599
|
+
export declare function validateModelValue(value: unknown, type: ValueType, types?: Readonly<Record<string, ValueType>>): void;
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Public model interface declared by a unified device manifest (RFC 0021).
|
|
603
|
+
*
|
|
604
|
+
* The value domain is the MessagePack subset of RFC 0021: `null`, boolean, finite binary64
|
|
605
|
+
* numbers, strings, bytes, arrays and plain string-keyed objects without cycles.
|
|
606
|
+
*/
|
|
607
|
+
/** A value exchanged with a device model (RFC 0021). */
|
|
608
|
+
export declare type Value = null | boolean | number | string | Uint8Array | readonly Value[] | {
|
|
609
|
+
readonly [key: string]: Value;
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
/** Payload type of a model parameter, result or event (RFC 0021). */
|
|
613
|
+
export declare type ValueType = {
|
|
614
|
+
readonly type: 'null' | 'boolean' | 'number' | 'string' | 'binary';
|
|
615
|
+
} | {
|
|
616
|
+
readonly type: 'array';
|
|
617
|
+
readonly items: ValueType;
|
|
618
|
+
} | {
|
|
619
|
+
readonly type: 'object';
|
|
620
|
+
readonly properties: Readonly<Record<string, ValueType>>;
|
|
621
|
+
readonly optional?: readonly string[];
|
|
622
|
+
readonly additionalProperties?: ValueType;
|
|
623
|
+
} | {
|
|
624
|
+
readonly ref: string;
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
/** 2D presentation declaration of a device (RFC 0022). */
|
|
628
|
+
export declare interface View2DDefinition {
|
|
629
|
+
/** Inline geometry or a package-root relative `.json` path. */
|
|
630
|
+
readonly geometry: Geometry2D | string;
|
|
631
|
+
/** Optional package-root relative `.js` dynamic overlay entry. */
|
|
632
|
+
readonly entry?: string;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/** Ideal voltage reference attached to one endpoint (RFC 0024). */
|
|
636
|
+
export declare interface VoltageReference {
|
|
637
|
+
readonly id: string;
|
|
638
|
+
readonly target: Endpoint;
|
|
639
|
+
/** `0` is the global ground reference. */
|
|
640
|
+
readonly voltage: number;
|
|
641
|
+
/** Built-in power or ground symbol; omitted when only the voltage constraint is stored. */
|
|
642
|
+
readonly symbol?: 'power' | 'ground';
|
|
643
|
+
/** Clockwise rotation in degrees; defaults to `0`. */
|
|
644
|
+
readonly rotation?: number;
|
|
645
|
+
/** Net name owned by the symbol together with its display offset. */
|
|
646
|
+
readonly label?: {
|
|
647
|
+
readonly name: string;
|
|
648
|
+
readonly offset?: Point2D;
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
export { }
|