@mica-js/sdk 0.3.3 → 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 +162 -24
- package/dist/build/cli.js +90 -26
- package/dist/build/config.d.ts +11 -0
- package/dist/build/config.js +15 -1
- package/dist/build/content.d.ts +2 -0
- package/dist/build/content.js +2 -1
- package/dist/build/prepare.d.ts +2 -0
- package/dist/build/prepare.js +2 -0
- package/dist/build/project.d.ts +6 -0
- package/dist/build/project.js +25 -8
- package/dist/build/unified-build.d.ts +38 -0
- package/dist/build/unified-build.js +65 -0
- package/dist/build/unified-defaults.d.ts +21 -0
- package/dist/build/unified-defaults.js +267 -0
- package/dist/build/unified-manifest.d.ts +34 -0
- package/dist/build/unified-manifest.js +113 -0
- package/dist/build/unified-package.d.ts +64 -0
- package/dist/build/unified-package.js +354 -0
- package/dist/build/unified-paths.d.ts +30 -0
- package/dist/build/unified-paths.js +94 -0
- package/dist/build/unified-prepare.d.ts +58 -0
- package/dist/build/unified-prepare.js +209 -0
- package/dist/build/unified-types.d.ts +20 -0
- package/dist/build/unified-types.js +253 -0
- package/dist/device.d.ts +13 -1
- package/dist/fused/agreement.d.ts +15 -0
- package/dist/fused/agreement.js +104 -0
- package/dist/fused/diagnostics.d.ts +51 -0
- package/dist/fused/diagnostics.js +97 -0
- package/dist/fused/firmware.d.ts +27 -0
- package/dist/fused/firmware.js +105 -0
- package/dist/fused/index.d.ts +29 -0
- package/dist/fused/index.js +11 -0
- package/dist/fused/model.d.ts +101 -0
- package/dist/fused/model.js +47 -0
- package/dist/fused/models.d.ts +113 -0
- package/dist/fused/models.js +445 -0
- package/dist/fused/node.d.ts +5 -0
- package/dist/fused/node.js +139 -0
- package/dist/fused/package.d.ts +40 -0
- package/dist/fused/package.js +270 -0
- package/dist/fused/prepare.d.ts +50 -0
- package/dist/fused/prepare.js +214 -0
- package/dist/fused/program-memory.d.ts +2 -0
- package/dist/fused/program-memory.js +174 -0
- package/dist/fused/program.d.ts +47 -0
- package/dist/fused/program.js +99 -0
- package/dist/fused/properties.d.ts +48 -0
- package/dist/fused/properties.js +465 -0
- package/dist/fused/runtime.d.ts +60 -0
- package/dist/fused/runtime.js +568 -0
- package/dist/fused/values.d.ts +27 -0
- package/dist/fused/values.js +98 -0
- package/package.json +20 -3
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { createFirmwareImage, readonlyBytes } from './firmware.js';
|
|
2
|
+
import { PROGRAM_LIMITS, ProgramError } from './program.js';
|
|
3
|
+
function invalid(message) {
|
|
4
|
+
throw new ProgramError('program/invalid-format', message);
|
|
5
|
+
}
|
|
6
|
+
export function decodeMemoryProgram(format, bytes, descriptor, reference) {
|
|
7
|
+
if (bytes.length > PROGRAM_LIMITS.maxMemoryBytes)
|
|
8
|
+
throw new ProgramError('program/resource-limit', 'Program input exceeds the fixed byte limit.');
|
|
9
|
+
if (!descriptor.formats?.includes(format))
|
|
10
|
+
throw new ProgramError('program/unsupported-format', `This program property does not accept ${format}.`);
|
|
11
|
+
if ((format !== 'bin' && reference.loadAddress !== undefined) ||
|
|
12
|
+
(format === 'elf' && reference.addressSpace !== undefined))
|
|
13
|
+
throw new ProgramError('schema/invalid-value', 'The program format does not accept the saved address overrides.');
|
|
14
|
+
const spaces = descriptor.addressSpaces ?? {};
|
|
15
|
+
const spaceId = reference.addressSpace ?? descriptor.defaults?.addressSpace;
|
|
16
|
+
if (format !== 'elf' && (spaceId === undefined || spaces[spaceId] === undefined))
|
|
17
|
+
throw new ProgramError('schema/invalid-value', 'The selected program address space does not exist.');
|
|
18
|
+
const chunks = format === 'bin'
|
|
19
|
+
? [{ address: reference.loadAddress ?? descriptor.defaults?.loadAddress ?? -1, data: bytes }]
|
|
20
|
+
: format === 'hex'
|
|
21
|
+
? decodeHex(bytes)
|
|
22
|
+
: decodeElf(bytes);
|
|
23
|
+
let total = 0;
|
|
24
|
+
const segments = chunks.map((chunk) => {
|
|
25
|
+
const end = chunk.address + chunk.data.length;
|
|
26
|
+
if (!Number.isSafeInteger(chunk.address) || chunk.address < 0 || !Number.isSafeInteger(end))
|
|
27
|
+
throw new ProgramError('program/out-of-range', 'Program address is outside the safe integer range.');
|
|
28
|
+
const candidates = format === 'elf'
|
|
29
|
+
? Object.entries(spaces)
|
|
30
|
+
.filter(([, space]) => chunk.address >= space.start && end <= space.start + space.size)
|
|
31
|
+
.map(([id]) => id)
|
|
32
|
+
: spaceId === undefined
|
|
33
|
+
? []
|
|
34
|
+
: [spaceId];
|
|
35
|
+
if (candidates.length > 1)
|
|
36
|
+
throw new ProgramError('program/ambiguous-address-space', 'ELF load segment matches multiple address spaces.');
|
|
37
|
+
const id = candidates[0];
|
|
38
|
+
const space = id === undefined ? undefined : spaces[id];
|
|
39
|
+
if (space === undefined ||
|
|
40
|
+
id === undefined ||
|
|
41
|
+
chunk.address < space.start ||
|
|
42
|
+
end > space.start + space.size)
|
|
43
|
+
throw new ProgramError('program/out-of-range', 'Program load segment leaves its declared address space.');
|
|
44
|
+
total += chunk.data.length;
|
|
45
|
+
if (total > PROGRAM_LIMITS.maxMemoryBytes)
|
|
46
|
+
throw new ProgramError('program/resource-limit', 'Decoded program exceeds the fixed byte limit.');
|
|
47
|
+
return { addressSpace: id, address: chunk.address, data: readonlyBytes(chunk.data) };
|
|
48
|
+
});
|
|
49
|
+
try {
|
|
50
|
+
return createFirmwareImage(segments);
|
|
51
|
+
}
|
|
52
|
+
catch (cause) {
|
|
53
|
+
if (!(cause instanceof RangeError))
|
|
54
|
+
throw cause;
|
|
55
|
+
throw new ProgramError('program/invalid-image', cause.message);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function decodeHex(bytes) {
|
|
59
|
+
let text;
|
|
60
|
+
try {
|
|
61
|
+
text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
62
|
+
}
|
|
63
|
+
catch (cause) {
|
|
64
|
+
if (!(cause instanceof TypeError))
|
|
65
|
+
throw cause;
|
|
66
|
+
invalid('Intel HEX is not valid text.');
|
|
67
|
+
}
|
|
68
|
+
const chunks = [];
|
|
69
|
+
let base = 0;
|
|
70
|
+
let ended = false;
|
|
71
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
72
|
+
const line = raw.trim();
|
|
73
|
+
if (line.length === 0)
|
|
74
|
+
continue;
|
|
75
|
+
if (ended || !/^:(?:[0-9a-fA-F]{2})+$/.test(line))
|
|
76
|
+
invalid('Invalid Intel HEX record or data after EOF.');
|
|
77
|
+
const record = Uint8Array.from(line.slice(1).match(/../g) ?? [], (pair) => Number.parseInt(pair, 16));
|
|
78
|
+
const length = record[0];
|
|
79
|
+
if (length === undefined ||
|
|
80
|
+
record.length !== length + 5 ||
|
|
81
|
+
(record.reduce((sum, byte) => sum + byte, 0) & 255) !== 0)
|
|
82
|
+
invalid('Intel HEX length or checksum mismatch.');
|
|
83
|
+
const address = (record[1] ?? 0) * 256 + (record[2] ?? 0);
|
|
84
|
+
const type = record[3];
|
|
85
|
+
const data = record.subarray(4, 4 + length);
|
|
86
|
+
switch (type) {
|
|
87
|
+
case 0:
|
|
88
|
+
if (address + length > 65536)
|
|
89
|
+
invalid('Intel HEX record crosses its address window.');
|
|
90
|
+
if (length > 0)
|
|
91
|
+
chunks.push({ address: base + address, data });
|
|
92
|
+
break;
|
|
93
|
+
case 1:
|
|
94
|
+
if (address !== 0 || length !== 0)
|
|
95
|
+
invalid('Invalid Intel HEX EOF.');
|
|
96
|
+
ended = true;
|
|
97
|
+
break;
|
|
98
|
+
case 2:
|
|
99
|
+
case 4:
|
|
100
|
+
if (address !== 0 || length !== 2)
|
|
101
|
+
invalid('Invalid Intel HEX extended address.');
|
|
102
|
+
base = ((data[0] ?? 0) * 256 + (data[1] ?? 0)) * (type === 2 ? 16 : 65536);
|
|
103
|
+
break;
|
|
104
|
+
case 3:
|
|
105
|
+
case 5:
|
|
106
|
+
if (address !== 0 || length !== 4)
|
|
107
|
+
invalid('Invalid Intel HEX start address.');
|
|
108
|
+
break;
|
|
109
|
+
default:
|
|
110
|
+
invalid('Unknown Intel HEX record type.');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (!ended)
|
|
114
|
+
invalid('Intel HEX has no EOF record.');
|
|
115
|
+
return chunks;
|
|
116
|
+
}
|
|
117
|
+
function decodeElf(bytes) {
|
|
118
|
+
if (bytes.length < 16 ||
|
|
119
|
+
bytes[0] !== 0x7f ||
|
|
120
|
+
bytes[1] !== 0x45 ||
|
|
121
|
+
bytes[2] !== 0x4c ||
|
|
122
|
+
bytes[3] !== 0x46 ||
|
|
123
|
+
bytes[6] !== 1)
|
|
124
|
+
invalid('Invalid ELF identification.');
|
|
125
|
+
const wide = bytes[4] === 2;
|
|
126
|
+
const headerSize = wide ? 64 : 52;
|
|
127
|
+
if ((bytes[4] !== 1 && !wide) || (bytes[5] !== 1 && bytes[5] !== 2) || bytes.length < headerSize)
|
|
128
|
+
invalid('Invalid ELF class, byte order or header.');
|
|
129
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
130
|
+
const little = bytes[5] === 1;
|
|
131
|
+
const u16 = (offset) => view.getUint16(offset, little);
|
|
132
|
+
const u32 = (offset) => view.getUint32(offset, little);
|
|
133
|
+
const word = (offset) => {
|
|
134
|
+
if (!wide)
|
|
135
|
+
return u32(offset);
|
|
136
|
+
const value = view.getBigUint64(offset, little);
|
|
137
|
+
if (value > BigInt(Number.MAX_SAFE_INTEGER))
|
|
138
|
+
invalid('ELF integer exceeds the safe range.');
|
|
139
|
+
return Number(value);
|
|
140
|
+
};
|
|
141
|
+
if (u16(16) !== 2 || u32(20) !== 1 || u16(wide ? 52 : 40) !== headerSize)
|
|
142
|
+
invalid('ELF must be a linked ET_EXEC image with a valid header.');
|
|
143
|
+
const offset = word(wide ? 32 : 28);
|
|
144
|
+
const stride = u16(wide ? 54 : 42);
|
|
145
|
+
const count = u16(wide ? 56 : 44);
|
|
146
|
+
if (count === 0)
|
|
147
|
+
return [];
|
|
148
|
+
if (count === 0xffff ||
|
|
149
|
+
stride < (wide ? 56 : 32) ||
|
|
150
|
+
offset < headerSize ||
|
|
151
|
+
!Number.isSafeInteger(offset + count * stride) ||
|
|
152
|
+
offset + count * stride > bytes.length)
|
|
153
|
+
invalid('Invalid ELF program header table.');
|
|
154
|
+
const chunks = [];
|
|
155
|
+
for (let i = 0; i < count; i++) {
|
|
156
|
+
const at = offset + i * stride;
|
|
157
|
+
const type = u32(at);
|
|
158
|
+
if (type === 2 || type === 3)
|
|
159
|
+
invalid('ELF dynamic loading is not supported.');
|
|
160
|
+
if (type !== 1)
|
|
161
|
+
continue;
|
|
162
|
+
const fileOffset = word(at + (wide ? 8 : 4));
|
|
163
|
+
const address = word(at + (wide ? 24 : 12));
|
|
164
|
+
const fileSize = word(at + (wide ? 32 : 16));
|
|
165
|
+
const memorySize = word(at + (wide ? 40 : 20));
|
|
166
|
+
if (fileSize > memorySize ||
|
|
167
|
+
!Number.isSafeInteger(fileOffset + fileSize) ||
|
|
168
|
+
fileOffset + fileSize > bytes.length)
|
|
169
|
+
invalid('Invalid ELF load segment bounds.');
|
|
170
|
+
if (fileSize > 0)
|
|
171
|
+
chunks.push({ address, data: bytes.subarray(fileOffset, fileOffset + fileSize) });
|
|
172
|
+
}
|
|
173
|
+
return chunks;
|
|
174
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ProgramFiles, ProgramFormat, ProgramLoader } from '@mica-js/document/fused';
|
|
2
|
+
export declare const PROGRAM_LIMITS: Readonly<{
|
|
3
|
+
maxFiles: 1024;
|
|
4
|
+
maxFileBytes: number;
|
|
5
|
+
maxTotalBytes: number;
|
|
6
|
+
maxMemoryBytes: number;
|
|
7
|
+
maxPathBytes: 1024;
|
|
8
|
+
maxDepth: 32;
|
|
9
|
+
}>;
|
|
10
|
+
export interface ProgramTarget {
|
|
11
|
+
readonly deviceId: string;
|
|
12
|
+
readonly property: string;
|
|
13
|
+
readonly loader: ProgramLoader;
|
|
14
|
+
}
|
|
15
|
+
export interface ProgramProject {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly title: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ProgramFile {
|
|
20
|
+
readonly path: string;
|
|
21
|
+
readonly data: Uint8Array;
|
|
22
|
+
}
|
|
23
|
+
export type ProgramArtifact = {
|
|
24
|
+
readonly kind: 'memory';
|
|
25
|
+
readonly format: ProgramFormat;
|
|
26
|
+
readonly data: Uint8Array;
|
|
27
|
+
} | {
|
|
28
|
+
readonly kind: 'filesystem';
|
|
29
|
+
readonly files: readonly ProgramFile[];
|
|
30
|
+
};
|
|
31
|
+
export interface ProgramProjectSelectionRequest extends ProgramTarget {
|
|
32
|
+
readonly templateIds: readonly string[];
|
|
33
|
+
}
|
|
34
|
+
export interface ProgramProjectProvider {
|
|
35
|
+
select?(request: ProgramProjectSelectionRequest, signal: AbortSignal): Promise<ProgramProject | undefined>;
|
|
36
|
+
resolve(projectId: string, target: ProgramTarget, signal?: AbortSignal): Promise<ProgramArtifact>;
|
|
37
|
+
}
|
|
38
|
+
export interface ProgramSources {
|
|
39
|
+
readonly projects?: ProgramProjectProvider;
|
|
40
|
+
}
|
|
41
|
+
export declare class ProgramError extends Error {
|
|
42
|
+
readonly code: string;
|
|
43
|
+
constructor(code: string, message: string);
|
|
44
|
+
}
|
|
45
|
+
export declare function readProgramArchive(data: Uint8Array): readonly ProgramFile[];
|
|
46
|
+
export declare function checkProgramPath(path: string): void;
|
|
47
|
+
export declare function createProgramFiles(files: readonly ProgramFile[]): ProgramFiles;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { projectPathProblem } from '@mica-js/document/fused';
|
|
2
|
+
import { readonlyBytes } from './firmware.js';
|
|
3
|
+
import { unzipSync } from 'fflate';
|
|
4
|
+
export const PROGRAM_LIMITS = Object.freeze({
|
|
5
|
+
maxFiles: 1024,
|
|
6
|
+
maxFileBytes: 32 * 1024 * 1024,
|
|
7
|
+
maxTotalBytes: 64 * 1024 * 1024,
|
|
8
|
+
maxMemoryBytes: 64 * 1024 * 1024,
|
|
9
|
+
maxPathBytes: 1024,
|
|
10
|
+
maxDepth: 32,
|
|
11
|
+
});
|
|
12
|
+
export class ProgramError extends Error {
|
|
13
|
+
code;
|
|
14
|
+
constructor(code, message) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.name = 'ProgramError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function readProgramArchive(data) {
|
|
21
|
+
if (data.byteLength > PROGRAM_LIMITS.maxTotalBytes)
|
|
22
|
+
throw new ProgramError('program/resource-limit', 'Program archive exceeds the byte limit.');
|
|
23
|
+
const names = new Set();
|
|
24
|
+
let total = 0;
|
|
25
|
+
try {
|
|
26
|
+
const files = unzipSync(data, {
|
|
27
|
+
filter(file) {
|
|
28
|
+
checkProgramPath(file.name.endsWith('/') ? file.name.slice(0, -1) : file.name);
|
|
29
|
+
if (file.name.endsWith('/'))
|
|
30
|
+
return false;
|
|
31
|
+
if (names.has(file.name))
|
|
32
|
+
throw new ProgramError('program/invalid-path', `Duplicate program path ${file.name}.`);
|
|
33
|
+
names.add(file.name);
|
|
34
|
+
total += file.originalSize;
|
|
35
|
+
if (names.size > PROGRAM_LIMITS.maxFiles ||
|
|
36
|
+
file.originalSize > PROGRAM_LIMITS.maxFileBytes ||
|
|
37
|
+
total > PROGRAM_LIMITS.maxTotalBytes)
|
|
38
|
+
throw new ProgramError('program/resource-limit', 'Program archive exceeds the file limits.');
|
|
39
|
+
return true;
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
return Object.entries(files).map(([path, bytes]) => ({ path, data: bytes }));
|
|
43
|
+
}
|
|
44
|
+
catch (cause) {
|
|
45
|
+
if (cause instanceof ProgramError)
|
|
46
|
+
throw cause;
|
|
47
|
+
throw new ProgramError('program/source-resolve-failed', `Cannot decode program ZIP: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export function checkProgramPath(path) {
|
|
51
|
+
const problem = projectPathProblem(path);
|
|
52
|
+
if (problem !== undefined)
|
|
53
|
+
throw new ProgramError('program/invalid-path', `Program path ${JSON.stringify(path)} ${problem}.`);
|
|
54
|
+
if (new TextEncoder().encode(path).length > PROGRAM_LIMITS.maxPathBytes ||
|
|
55
|
+
path.split('/').length > PROGRAM_LIMITS.maxDepth) {
|
|
56
|
+
throw new ProgramError('program/resource-limit', `Program path ${JSON.stringify(path)} exceeds the fixed path limits.`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function createProgramFiles(files) {
|
|
60
|
+
if (!Array.isArray(files))
|
|
61
|
+
throw new ProgramError('program/source-resolve-failed', 'A program file set must be an array.');
|
|
62
|
+
if (files.length > PROGRAM_LIMITS.maxFiles)
|
|
63
|
+
throw new ProgramError('program/resource-limit', 'Program file count exceeds the fixed limit.');
|
|
64
|
+
const snapshots = new Map();
|
|
65
|
+
let total = 0;
|
|
66
|
+
for (const file of files) {
|
|
67
|
+
if (file === null ||
|
|
68
|
+
typeof file !== 'object' ||
|
|
69
|
+
typeof file.path !== 'string' ||
|
|
70
|
+
!(file.data instanceof Uint8Array)) {
|
|
71
|
+
throw new ProgramError('program/source-resolve-failed', 'Program files require a path and Uint8Array data.');
|
|
72
|
+
}
|
|
73
|
+
checkProgramPath(file.path);
|
|
74
|
+
if (snapshots.has(file.path))
|
|
75
|
+
throw new ProgramError('program/invalid-path', `Duplicate program path ${file.path}.`);
|
|
76
|
+
total += file.data.byteLength;
|
|
77
|
+
if (file.data.byteLength > PROGRAM_LIMITS.maxFileBytes || total > PROGRAM_LIMITS.maxTotalBytes)
|
|
78
|
+
throw new ProgramError('program/resource-limit', 'Program file bytes exceed the fixed limit.');
|
|
79
|
+
snapshots.set(file.path, readonlyBytes(file.data));
|
|
80
|
+
}
|
|
81
|
+
const paths = Object.freeze([...snapshots.keys()].sort());
|
|
82
|
+
for (const path of paths) {
|
|
83
|
+
const parts = path.split('/');
|
|
84
|
+
for (let i = 1; i < parts.length; i++) {
|
|
85
|
+
if (snapshots.has(parts.slice(0, i).join('/')))
|
|
86
|
+
throw new ProgramError('program/invalid-path', `Program file ${path} conflicts with a parent file.`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return Object.freeze({
|
|
90
|
+
paths,
|
|
91
|
+
read(path) {
|
|
92
|
+
checkProgramPath(path);
|
|
93
|
+
const bytes = snapshots.get(path);
|
|
94
|
+
if (bytes === undefined)
|
|
95
|
+
throw new ProgramError('program/file-not-found', `Program file ${path} does not exist.`);
|
|
96
|
+
return bytes;
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instance property resolution of the headless runtime (RFC 0020 / RFC 0026).
|
|
3
|
+
*
|
|
4
|
+
* Every declared property is resolved from the document override or the manifest default before a
|
|
5
|
+
* model factory runs: resources become independent byte snapshots, firmware becomes a parsed
|
|
6
|
+
* read-only image, and scalar values are checked against the descriptor constraints. The same
|
|
7
|
+
* resolution feeds the board (IR-declared plain properties) and the model snapshot.
|
|
8
|
+
*/
|
|
9
|
+
import type { DevicePropertyDescriptor, PropertyValue, ResourceReference } from '@mica-js/document/fused';
|
|
10
|
+
import type { ValueTypeIR } from '@mica-js/device-model';
|
|
11
|
+
import { type VerifiedPackage } from './package.js';
|
|
12
|
+
import { type ProgramSources } from './program.js';
|
|
13
|
+
/** Property value handed to the simulator board; IR properties only. */
|
|
14
|
+
export type BoardPropertyValue = number | boolean | string | null | Uint8Array;
|
|
15
|
+
/** One external asset read the host must answer. */
|
|
16
|
+
export interface ResourceRequest {
|
|
17
|
+
readonly instanceId: string;
|
|
18
|
+
readonly property: string;
|
|
19
|
+
readonly reference: ResourceReference;
|
|
20
|
+
}
|
|
21
|
+
/** Explicit resolver of asset-library property resources. */
|
|
22
|
+
export type ResourceResolver = (request: ResourceRequest) => Promise<Uint8Array>;
|
|
23
|
+
export interface PropertyResolution {
|
|
24
|
+
/** Independent read-only snapshot handed to the model factory. */
|
|
25
|
+
readonly props: Readonly<Record<string, unknown>>;
|
|
26
|
+
/** IR-declared plain properties handed to the board. */
|
|
27
|
+
readonly boardProps: Readonly<Record<string, BoardPropertyValue>>;
|
|
28
|
+
}
|
|
29
|
+
export interface PropertyResolutionInput {
|
|
30
|
+
readonly instanceId: string;
|
|
31
|
+
/** Device package the instance locks; `package` references resolve inside it. */
|
|
32
|
+
readonly package: VerifiedPackage;
|
|
33
|
+
readonly descriptors: Readonly<Record<string, DevicePropertyDescriptor>>;
|
|
34
|
+
readonly overrides: Readonly<Record<string, PropertyValue>>;
|
|
35
|
+
/** Property declarations of the model IR, keyed by name. */
|
|
36
|
+
readonly irProperties: ReadonlyMap<string, ValueTypeIR>;
|
|
37
|
+
readonly resolveResource?: ResourceResolver;
|
|
38
|
+
readonly programs?: ProgramSources;
|
|
39
|
+
readonly signal?: AbortSignal;
|
|
40
|
+
/** JSON Pointer of the instance properties, used for preparational diagnostics. */
|
|
41
|
+
readonly pointer: readonly string[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resolves every declared property of one instance.
|
|
45
|
+
*
|
|
46
|
+
* @throws {PreparationError} listing every property that cannot be prepared.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveInstanceProperties(input: PropertyResolutionInput): Promise<PropertyResolution>;
|