@mica-js/document 0.5.0 → 0.7.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance-data-H002cFE_.js","names":[],"sources":["../src/fused/diagnostics.ts","../src/fused/rules.ts","../src/fused/json.ts","../src/fused/read.ts","../src/fused/resource.ts","../src/fused/instance-data.ts"],"sourcesContent":["/** Diagnostics of the fused device package and fused `.sch` contracts. */\n\nexport type FusedDiagnosticSeverity = 'error' | 'warning';\n\n/**\n * Stable diagnostic codes of the fused contracts.\n *\n * The codes follow the RFC 0020 / 0021 / 0022 / 0024 / 0026 tables. `json/*` and `schema/*` cover\n * structural problems, `package/*` manifest and path problems, and the remaining families cover\n * the named runtime contract they belong to.\n */\nexport type FusedDiagnosticCode =\n | 'json/invalid'\n | 'json/duplicate-key'\n | 'json/not-object'\n | 'schema/unsupported-version'\n | 'schema/missing-field'\n | 'schema/invalid-type'\n | 'schema/invalid-value'\n | 'schema/unknown-field'\n | 'package/invalid-manifest'\n | 'package/invalid-path'\n | 'package/invalid-icon'\n | 'package/unsupported-engine'\n | 'document/duplicate-id'\n | 'document/duplicate-designator'\n | 'document/unlocked-device'\n | 'document/invalid-view-layout'\n | 'connection/unknown-endpoint'\n | 'connection/self-edge'\n | 'net/naming-conflict'\n | 'net/reference-conflict'\n | 'device/unresolved'\n | 'device/unknown-pin'\n | 'model/invalid-interface'\n | 'model/invalid-params'\n | 'model/invalid-result'\n | 'model/invalid-event'\n | 'type/unknown'\n | 'view2d/invalid-geometry'\n | 'view2d/pin-mismatch'\n | 'firmware/invalid-image'\n | 'firmware/out-of-range';\n\n/** JSON Pointer of a field path; segments escape `~` and `/` (RFC 6901). */\nexport function toPointer(path: readonly string[]): string {\n if (path.length === 0) {\n return '';\n }\n const segments = path.map((segment) => segment.replace(/~/g, '~0').replace(/\\//g, '~1'));\n return `/${segments.join('/')}`;\n}\n\n/** One problem found while validating fused device data. */\nexport interface FusedDiagnostic {\n readonly severity: FusedDiagnosticSeverity;\n /** Stable contract code; the human readable `message` is not part of the contract. */\n readonly code: FusedDiagnosticCode;\n readonly message: string;\n /** JSON Pointer of the offending member; the empty string addresses the whole document. */\n readonly pointer: string;\n}\n\n/**\n * Thrown when fused device data violates its contract.\n *\n * `diagnostics` carries every problem found, each with an explicit code and JSON Pointer, so a\n * host can report them without re-parsing.\n */\nexport class FusedDocumentError extends Error {\n readonly diagnostics: readonly FusedDiagnostic[];\n\n constructor(diagnostics: readonly FusedDiagnostic[]) {\n super(buildMessage(diagnostics));\n this.name = 'FusedDocumentError';\n this.diagnostics = diagnostics;\n }\n\n /** Code of the first diagnostic, for coarse programmatic handling. */\n get code(): FusedDiagnosticCode | undefined {\n return this.diagnostics[0]?.code;\n }\n\n /** Field path of the first diagnostic, for coarse programmatic handling. */\n get pointer(): string | undefined {\n return this.diagnostics[0]?.pointer;\n }\n}\n\n/** Records one diagnostic for `path` as an error. */\nexport function report(\n diagnostics: FusedDiagnostic[],\n code: FusedDiagnosticCode,\n message: string,\n path: readonly string[],\n): void {\n diagnostics.push({ severity: 'error', code, message, pointer: toPointer(path) });\n}\n\nfunction buildMessage(diagnostics: readonly FusedDiagnostic[]): string {\n const errors = diagnostics.filter((diagnostic) => diagnostic.severity === 'error');\n const relevant = errors.length > 0 ? errors : diagnostics;\n const [first, ...rest] = relevant;\n if (first === undefined) {\n return 'Fused device validation failed.';\n }\n const location = first.pointer === '' ? '' : ` at ${first.pointer}`;\n const suffix = rest.length === 0 ? '' : ` (and ${rest.length} more)`;\n return `${first.code}${location}: ${first.message}${suffix}`;\n}\n","/** Lexical rules of device identity, versions, paths and member names (RFC 0020 / RFC 0024). */\n\nconst NAME_SEGMENT = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\nconst DEVICE_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*:[a-z0-9]+(?:-[a-z0-9]+)*$/;\nconst SEMVER =\n /^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/;\nconst INTEGRITY = /^sha256:[0-9a-f]{64}$/;\nconst MEMBER_KEY = /^[A-Za-z][A-Za-z0-9]*$/;\nconst EVENT_KEY = /^onDid[A-Z][A-Za-z0-9]*$/;\nconst PIN_ID = /^[A-Za-z_][A-Za-z0-9_]*$/;\nconst CODICON = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;\nconst DESIGNATOR_PREFIX = /^[A-Za-z][A-Za-z0-9]*$/;\nconst EXTENSION = /^\\.[A-Za-z0-9]+$/;\nconst COLOR = /^#(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;\nconst DRIVE_LETTER = /^[A-Za-z]:/;\nconst URL_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*:/;\n/** True when the text carries C0 or DEL control characters. */\nfunction hasControlCharacters(value: string): boolean {\n for (const character of value) {\n const code = character.codePointAt(0) ?? 0;\n if (code < 0x20 || code === 0x7f) {\n return true;\n }\n }\n return false;\n}\n\n/** Publisher namespace or device name segment; defaults to `U` for designator prefixes. */\nexport function isNameSegment(value: string): boolean {\n return NAME_SEGMENT.test(value);\n}\n\n/** Full `publisher:name` device id (RFC 0020). */\nexport function isDeviceId(value: string): boolean {\n return DEVICE_ID.test(value);\n}\n\n/** Problem of a `publisher:name` device id, or `undefined` when it is well formed. */\nexport function deviceIdProblem(value: string): string | undefined {\n if (value.length === 0) {\n return 'must not be empty';\n }\n return isDeviceId(value)\n ? undefined\n : 'must be a \"publisher:name\" pair of lowercase dash-separated segments';\n}\n\n/** Full SemVer version, including prerelease and build metadata (RFC 0020). */\nexport function isSemVer(value: string): boolean {\n return SEMVER.test(value);\n}\n\n/** Release identity or file digest: `sha256:` plus 64 lowercase hex digits (RFC 0020). */\nexport function isIntegrity(value: string): boolean {\n return INTEGRITY.test(value);\n}\n\n/** Property, method, public type and view id key (RFC 0020). */\nexport function isMemberKey(value: string): boolean {\n return MEMBER_KEY.test(value);\n}\n\n/** Event key in `onDidXxx` form (RFC 0020 / RFC 0021). */\nexport function isEventKey(value: string): boolean {\n return EVENT_KEY.test(value);\n}\n\n/** Model pin name, matching the DDL identifier form (RFC 0021). */\nexport function isPinId(value: string): boolean {\n return PIN_ID.test(value);\n}\n\n/** VS Code Codicons name supplied by the editor (RFC 0020). */\nexport function isCodiconName(value: string): boolean {\n return CODICON.test(value);\n}\n\n/** Reference designator prefix (RFC 0020). */\nexport function isDesignatorPrefix(value: string): boolean {\n return DESIGNATOR_PREFIX.test(value);\n}\n\n/** `binary` extension filter entry, e.g. `.bin` (RFC 0020). */\nexport function isExtensionFilter(value: string): boolean {\n return EXTENSION.test(value);\n}\n\n/** `#RRGGBB` / `#RRGGBBAA` color (RFC 0009). */\nexport function isColor(value: string): boolean {\n return COLOR.test(value);\n}\n\n/**\n * Package-root relative POSIX file path problem, or `undefined` when it is well formed.\n *\n * Case sensitivity, empty segments, `.` / `..`, backslashes and absolute paths are rejected\n * (RFC 0020).\n */\nexport function packagePathProblem(path: string): string | undefined {\n return relativePathProblem(path, 'package root');\n}\n\n/** Project-root relative POSIX file path problem, or `undefined` when it is well formed. */\nexport function projectPathProblem(path: string): string | undefined {\n return relativePathProblem(path, 'project root');\n}\n\n/** `deviceData` directory relative POSIX file path problem, or `undefined` when well formed. */\nexport function deviceDataPathProblem(path: string): string | undefined {\n return relativePathProblem(path, 'deviceData directory');\n}\n\nfunction relativePathProblem(path: string, root: string): string | undefined {\n if (path.length === 0) {\n return 'must not be empty';\n }\n if (path.startsWith('/')) {\n return `must be relative to the ${root}, not absolute`;\n }\n if (DRIVE_LETTER.test(path)) {\n return 'must not carry a drive letter';\n }\n if (URL_SCHEME.test(path)) {\n return 'must not be a URL';\n }\n if (path.includes('\\\\')) {\n return 'must use POSIX separators';\n }\n if (hasControlCharacters(path)) {\n return 'must not contain control characters';\n }\n const segments = path.split('/');\n if (segments[segments.length - 1] === '') {\n return 'must name a file, not a directory';\n }\n for (const segment of segments) {\n if (segment.length === 0) {\n return 'must not contain empty segments';\n }\n if (segment === '.' || segment === '..') {\n return `must not contain \"${segment}\" segments`;\n }\n }\n return undefined;\n}\n\n/** Problem of a file name that must end in one of `extensions`, or `undefined` when it does. */\nexport function extensionProblem(path: string, extensions: readonly string[]): string | undefined {\n const lower = path.toLowerCase();\n const expected = extensions.map((extension) => extension.toLowerCase());\n return expected.some((extension) => lower.endsWith(extension))\n ? undefined\n : `must name a ${extensions.join(' or ')} file`;\n}\n\n/** `sha256:` digest problem of a release identity or file digest, or `undefined` when valid. */\nexport function integrityProblem(value: string): string | undefined {\n return isIntegrity(value)\n ? undefined\n : 'must be \"sha256:\" followed by 64 lowercase hexadecimal digits';\n}\n\n/** Normalizes `#RRGGBB` / `#RRGGBBAA` to upper case; `undefined` when the text is not a color. */\nexport function normalizeColor(value: string): string | undefined {\n return isColor(value) ? value.toUpperCase() : undefined;\n}\n","/**\n * Strict JSON reader for the fused contracts.\n *\n * `JSON.parse` silently keeps the last of two equal keys, which would let a manifest or a `.sch`\n * file carry two different values for one field. RFC 0020 and RFC 0024 require rejecting\n * duplicate keys, so the parsers decode JSON text with this reader instead. Keys are compared\n * after unescaping, so `\"a\"` and `\"\\u0061\"` are the same key.\n */\nimport { FusedDocumentError, report } from './diagnostics';\nimport type { FusedDiagnostic } from './diagnostics';\n\n/** Deepest object/array nesting the reader accepts. */\nexport const STRICT_JSON_MAX_DEPTH = 256;\n\nexport interface JsonDecodeSuccess {\n readonly ok: true;\n readonly value: unknown;\n}\n\nexport interface JsonDecodeFailure {\n readonly ok: false;\n readonly diagnostics: readonly FusedDiagnostic[];\n}\n\nexport type JsonDecodeResult = JsonDecodeSuccess | JsonDecodeFailure;\n\n/**\n * Decodes JSON text, rejecting duplicate keys and reporting every problem with a JSON Pointer.\n *\n * @throws {FusedDocumentError} when the text is not valid JSON or repeats an object key.\n */\nexport function parseStrictJson(text: string): unknown {\n const result = decodeStrictJson(text);\n if (!result.ok) {\n throw new FusedDocumentError(result.diagnostics);\n }\n return result.value;\n}\n\n/** Non-throwing form of {@link parseStrictJson}; the caller decides how to surface the problems. */\nexport function decodeStrictJson(text: string): JsonDecodeResult {\n return new Reader(text).decode();\n}\n\nclass Reader {\n readonly #text: string;\n readonly #diagnostics: FusedDiagnostic[] = [];\n #index = 0;\n #failed = false;\n\n constructor(text: string) {\n this.#text = text;\n }\n\n decode(): JsonDecodeResult {\n this.#skipWhitespace();\n const value = this.#readValue([], 0);\n if (this.#failed) {\n return this.#failure();\n }\n this.#skipWhitespace();\n if (this.#index !== this.#text.length) {\n this.#fail('Unexpected content after the JSON value.');\n return this.#failure();\n }\n if (this.#diagnostics.length > 0) {\n return this.#failure();\n }\n return { ok: true, value };\n }\n\n #failure(): JsonDecodeFailure {\n return { ok: false, diagnostics: this.#diagnostics };\n }\n\n #fail(message: string): undefined {\n if (!this.#failed) {\n report(\n this.#diagnostics,\n 'json/invalid',\n `Invalid JSON at offset ${String(this.#index)}: ${message}`,\n [],\n );\n }\n this.#failed = true;\n return undefined;\n }\n\n #skipWhitespace(): void {\n while (this.#index < this.#text.length) {\n const code = this.#text.charCodeAt(this.#index);\n if (code !== 0x20 && code !== 0x09 && code !== 0x0a && code !== 0x0d) {\n return;\n }\n this.#index += 1;\n }\n }\n\n #readValue(path: readonly string[], depth: number): unknown {\n this.#skipWhitespace();\n if (this.#index >= this.#text.length) {\n return this.#fail('Unexpected end of input; expected a value.');\n }\n if (depth > STRICT_JSON_MAX_DEPTH) {\n return this.#fail(`Nesting deeper than ${String(STRICT_JSON_MAX_DEPTH)} is not supported.`);\n }\n const character = this.#text[this.#index];\n switch (character) {\n case '{':\n return this.#readObject(path, depth + 1);\n case '[':\n return this.#readArray(path, depth + 1);\n case '\"':\n return this.#readString();\n case 't':\n return this.#readKeyword('true', true);\n case 'f':\n return this.#readKeyword('false', false);\n case 'n':\n return this.#readKeyword('null', null);\n default:\n return this.#readNumber();\n }\n }\n\n #readKeyword(keyword: string, value: unknown): unknown {\n if (this.#text.startsWith(keyword, this.#index)) {\n this.#index += keyword.length;\n return value;\n }\n return this.#fail(`Expected ${keyword}.`);\n }\n\n #readNumber(): number | undefined {\n NUMBER.lastIndex = this.#index;\n const match = NUMBER.exec(this.#text);\n if (match === null) {\n return this.#fail('Expected a value.');\n }\n this.#index = NUMBER.lastIndex;\n return Number(match[0]);\n }\n\n #readString(): string | undefined {\n this.#index += 1;\n let value = '';\n let chunkStart = this.#index;\n for (;;) {\n if (this.#index >= this.#text.length) {\n return this.#fail('Unterminated string.');\n }\n const code = this.#text.charCodeAt(this.#index);\n if (code === 0x22) {\n value += this.#text.slice(chunkStart, this.#index);\n this.#index += 1;\n return value;\n }\n if (code === 0x5c) {\n value += this.#text.slice(chunkStart, this.#index);\n this.#index += 1;\n const escape = this.#readEscape();\n if (escape === undefined) {\n return undefined;\n }\n value += escape;\n chunkStart = this.#index;\n continue;\n }\n if (code < 0x20) {\n return this.#fail('Control characters must be escaped inside strings.');\n }\n this.#index += 1;\n }\n }\n\n #readEscape(): string | undefined {\n if (this.#index >= this.#text.length) {\n return this.#fail('Unterminated escape sequence.');\n }\n const character = this.#text[this.#index];\n this.#index += 1;\n switch (character) {\n case '\"':\n return '\"';\n case '\\\\':\n return '\\\\';\n case '/':\n return '/';\n case 'b':\n return '\\b';\n case 'f':\n return '\\f';\n case 'n':\n return '\\n';\n case 'r':\n return '\\r';\n case 't':\n return '\\t';\n case 'u':\n return this.#readUnicodeEscape();\n default:\n return this.#fail(`Unknown escape sequence \"\\\\${String(character)}\".`);\n }\n }\n\n #readUnicodeEscape(): string | undefined {\n const digits = this.#text.slice(this.#index, this.#index + 4);\n if (!/^[0-9a-fA-F]{4}$/.test(digits)) {\n return this.#fail('Unicode escapes need exactly four hexadecimal digits.');\n }\n this.#index += 4;\n return String.fromCharCode(Number.parseInt(digits, 16));\n }\n\n #readObject(path: readonly string[], depth: number): Record<string, unknown> | undefined {\n this.#index += 1;\n const object: Record<string, unknown> = {};\n const keys = new Set<string>();\n this.#skipWhitespace();\n if (this.#text[this.#index] === '}') {\n this.#index += 1;\n return object;\n }\n for (;;) {\n this.#skipWhitespace();\n if (this.#text[this.#index] !== '\"') {\n return this.#fail('Expected a property name.');\n }\n const key = this.#readString();\n if (key === undefined) {\n return undefined;\n }\n this.#skipWhitespace();\n if (this.#text[this.#index] !== ':') {\n return this.#fail('Expected \":\" after the property name.');\n }\n this.#index += 1;\n\n const memberPath = [...path, key];\n const duplicate = keys.has(key);\n if (duplicate) {\n report(\n this.#diagnostics,\n 'json/duplicate-key',\n `Duplicate JSON key ${JSON.stringify(key)}; the contract does not allow one key twice.`,\n memberPath,\n );\n } else {\n keys.add(key);\n }\n\n const value = this.#readValue(memberPath, depth);\n if (this.#failed) {\n return undefined;\n }\n if (!duplicate) {\n Object.defineProperty(object, key, {\n value,\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n\n this.#skipWhitespace();\n const next = this.#text[this.#index];\n if (next === ',') {\n this.#index += 1;\n continue;\n }\n if (next === '}') {\n this.#index += 1;\n return object;\n }\n return this.#fail('Expected \",\" or \"}\" in the object.');\n }\n }\n\n #readArray(path: readonly string[], depth: number): unknown[] | undefined {\n this.#index += 1;\n const array: unknown[] = [];\n this.#skipWhitespace();\n if (this.#text[this.#index] === ']') {\n this.#index += 1;\n return array;\n }\n for (;;) {\n const item = this.#readValue([...path, String(array.length)], depth);\n if (this.#failed) {\n return undefined;\n }\n array.push(item);\n this.#skipWhitespace();\n const next = this.#text[this.#index];\n if (next === ',') {\n this.#index += 1;\n continue;\n }\n if (next === ']') {\n this.#index += 1;\n return array;\n }\n return this.#fail('Expected \",\" or \"]\" in the array.');\n }\n }\n}\n\nconst NUMBER = /-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?/y;\n","/** Structural readers shared by the fused parsers; every failure reports code and field path. */\nimport { report, toPointer } from './diagnostics';\nimport type { FusedDiagnostic } from './diagnostics';\nimport { decodeStrictJson } from './json';\n\nexport { report, toPointer };\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function hasOwn(value: Record<string, unknown>, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(value, key);\n}\n\nexport function hasErrors(diagnostics: readonly FusedDiagnostic[]): boolean {\n return diagnostics.some((diagnostic) => diagnostic.severity === 'error');\n}\n\nexport function forbidUnknownFields(\n value: Record<string, unknown>,\n allowed: readonly string[],\n path: readonly string[],\n diagnostics: FusedDiagnostic[],\n): void {\n for (const key of Object.keys(value)) {\n if (!allowed.includes(key)) {\n report(diagnostics, 'schema/unknown-field', `Unknown field \"${key}\".`, [...path, key]);\n }\n }\n}\n\nexport interface JsonInput {\n readonly ok: boolean;\n readonly value: unknown;\n}\n\n/**\n * Strings are decoded as strict JSON text, which rejects duplicate keys; any other value is\n * validated as-is so callers that already hold a plain object stay supported.\n */\nexport function parseJsonInput(input: unknown, diagnostics: FusedDiagnostic[]): JsonInput {\n if (typeof input !== 'string') {\n return { ok: true, value: input };\n }\n const decoded = decodeStrictJson(input);\n if (!decoded.ok) {\n diagnostics.push(...decoded.diagnostics);\n return { ok: false, value: undefined };\n }\n return { ok: true, value: decoded.value };\n}\n\nexport interface TextOptions {\n readonly nonEmpty?: boolean;\n}\n\nexport function readStringField(\n value: Record<string, unknown>,\n key: string,\n path: readonly string[],\n diagnostics: FusedDiagnostic[],\n required = true,\n options: TextOptions = {},\n): string | undefined {\n const fieldPath = [...path, key];\n if (!hasOwn(value, key)) {\n if (required) {\n report(diagnostics, 'schema/missing-field', `Missing required field \"${key}\".`, fieldPath);\n }\n return undefined;\n }\n const field = value[key];\n if (typeof field !== 'string') {\n report(diagnostics, 'schema/invalid-type', `Field \"${key}\" must be a string.`, fieldPath);\n return undefined;\n }\n if (options.nonEmpty === true && field.length === 0) {\n report(diagnostics, 'schema/invalid-value', `Field \"${key}\" must not be empty.`, fieldPath);\n return undefined;\n }\n return field;\n}\n\nexport function readNumberField(\n value: Record<string, unknown>,\n key: string,\n path: readonly string[],\n diagnostics: FusedDiagnostic[],\n required = true,\n): number | undefined {\n const fieldPath = [...path, key];\n if (!hasOwn(value, key)) {\n if (required) {\n report(diagnostics, 'schema/missing-field', `Missing required field \"${key}\".`, fieldPath);\n }\n return undefined;\n }\n const field = value[key];\n if (typeof field !== 'number') {\n report(diagnostics, 'schema/invalid-type', `Field \"${key}\" must be a number.`, fieldPath);\n return undefined;\n }\n if (!Number.isFinite(field)) {\n report(\n diagnostics,\n 'schema/invalid-value',\n `Field \"${key}\" must be a finite number.`,\n fieldPath,\n );\n return undefined;\n }\n return field;\n}\n\nexport function readIntegerField(\n value: Record<string, unknown>,\n key: string,\n path: readonly string[],\n diagnostics: FusedDiagnostic[],\n required = true,\n): number | undefined {\n const field = readNumberField(value, key, path, diagnostics, required);\n if (field === undefined) {\n return undefined;\n }\n if (!Number.isSafeInteger(field)) {\n report(diagnostics, 'schema/invalid-value', `Field \"${key}\" must be a safe integer.`, [\n ...path,\n key,\n ]);\n return undefined;\n }\n return field;\n}\n\nexport function readBooleanField(\n value: Record<string, unknown>,\n key: string,\n path: readonly string[],\n diagnostics: FusedDiagnostic[],\n required = true,\n): boolean | undefined {\n const fieldPath = [...path, key];\n if (!hasOwn(value, key)) {\n if (required) {\n report(diagnostics, 'schema/missing-field', `Missing required field \"${key}\".`, fieldPath);\n }\n return undefined;\n }\n const field = value[key];\n if (typeof field !== 'boolean') {\n report(diagnostics, 'schema/invalid-type', `Field \"${key}\" must be a boolean.`, fieldPath);\n return undefined;\n }\n return field;\n}\n\nexport function readObjectField(\n value: Record<string, unknown>,\n key: string,\n path: readonly string[],\n diagnostics: FusedDiagnostic[],\n required = true,\n): Record<string, unknown> | undefined {\n const fieldPath = [...path, key];\n if (!hasOwn(value, key)) {\n if (required) {\n report(diagnostics, 'schema/missing-field', `Missing required field \"${key}\".`, fieldPath);\n }\n return undefined;\n }\n const field = value[key];\n if (!isRecord(field)) {\n report(diagnostics, 'schema/invalid-type', `Field \"${key}\" must be an object.`, fieldPath);\n return undefined;\n }\n return field;\n}\n\nexport function readArrayField(\n value: Record<string, unknown>,\n key: string,\n path: readonly string[],\n diagnostics: FusedDiagnostic[],\n required = true,\n): unknown[] | undefined {\n const fieldPath = [...path, key];\n if (!hasOwn(value, key)) {\n if (required) {\n report(diagnostics, 'schema/missing-field', `Missing required field \"${key}\".`, fieldPath);\n }\n return undefined;\n }\n const field = value[key];\n if (!Array.isArray(field)) {\n report(diagnostics, 'schema/invalid-type', `Field \"${key}\" must be an array.`, fieldPath);\n return undefined;\n }\n return field;\n}\n\n/** Compares two strings by UTF-16 code unit, independent of the host locale. */\nexport function compareStrings(a: string, b: string): number {\n if (a === b) {\n return 0;\n }\n return a < b ? -1 : 1;\n}\n\n/**\n * Records an immutable snapshot of a parsed structure.\n *\n * Parsers only build plain objects and arrays, so freezing them is safe; array-buffer views are\n * left alone because their contents cannot be frozen.\n */\nexport function deepFreeze<T>(value: T): T {\n if (typeof value !== 'object' || value === null || ArrayBuffer.isView(value)) {\n return value;\n }\n if (Object.isFrozen(value)) {\n return value;\n }\n Object.freeze(value);\n for (const entry of Object.values(value as Record<string, unknown>)) {\n deepFreeze(entry);\n }\n return value;\n}\n","/**\n * Persistent property values of an instance: scalars, resource references and firmware references\n * (RFC 0024 with the RFC 0020 / RFC 0026 extensions).\n */\nimport type { FusedDiagnostic } from './diagnostics';\nimport type {\n DeviceDataReference,\n FirmwareFileReference,\n ProgramProjectReference,\n FirmwareReference,\n PropertyValue,\n ResourceMode,\n ResourceReference,\n} from './types/property';\nimport { deviceDataPathProblem, packagePathProblem } from './rules';\nimport {\n forbidUnknownFields,\n hasOwn,\n isRecord,\n readIntegerField,\n readStringField,\n report,\n} from './read';\n\nconst RESOURCE_MODES = ['asset', 'package'] as const;\n\n/** Reads one instance property value; `undefined` when it does not match the contract. */\nexport function readPropertyValue(\n value: unknown,\n path: readonly string[],\n diagnostics: FusedDiagnostic[],\n): PropertyValue | undefined {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') {\n return value;\n }\n if (typeof value === 'number') {\n if (!Number.isFinite(value)) {\n report(diagnostics, 'schema/invalid-value', 'Numeric property values must be finite.', path);\n return undefined;\n }\n return value;\n }\n if (isRecord(value)) {\n return readReference(value, path, diagnostics);\n }\n report(\n diagnostics,\n 'schema/invalid-type',\n 'Property value must be a scalar, a resource reference, a firmware reference or null.',\n path,\n );\n return undefined;\n}\n\nfunction readReference(\n value: Record<string, unknown>,\n path: readonly string[],\n diagnostics: FusedDiagnostic[],\n):\n | ResourceReference\n | FirmwareReference\n | ProgramProjectReference\n | DeviceDataReference\n | undefined {\n const mode = readStringField(value, 'mode', path, diagnostics, true, { nonEmpty: true });\n if (mode === undefined) {\n return undefined;\n }\n if (mode === 'project') {\n return readProjectReference(value, path, diagnostics);\n }\n if (mode === 'deviceData') {\n return readDeviceDataReference(value, path, diagnostics);\n }\n if (!(RESOURCE_MODES as readonly string[]).includes(mode)) {\n report(\n diagnostics,\n 'schema/invalid-value',\n 'Field \"mode\" must be \"asset\", \"package\", \"deviceData\" or \"project\".',\n [...path, 'mode'],\n );\n return undefined;\n }\n return readResourceReference(value, mode as ResourceMode, path, diagnostics);\n}\n\nfunction readDeviceDataReference(\n value: Record<string, unknown>,\n path: readonly string[],\n diagnostics: FusedDiagnostic[],\n): DeviceDataReference | undefined {\n forbidUnknownFields(value, ['mode', 'path'], path, diagnostics);\n const referencePath = readStringField(value, 'path', path, diagnostics, true, {\n nonEmpty: true,\n });\n if (referencePath === undefined) {\n return undefined;\n }\n const problem = deviceDataPathProblem(referencePath);\n if (problem !== undefined) {\n report(diagnostics, 'schema/invalid-value', `Field \"path\" ${problem}.`, [...path, 'path']);\n return undefined;\n }\n return { mode: 'deviceData', path: referencePath };\n}\n\nfunction readProjectReference(\n value: Record<string, unknown>,\n path: readonly string[],\n diagnostics: FusedDiagnostic[],\n): ProgramProjectReference | undefined {\n forbidUnknownFields(\n value,\n ['mode', 'projectId', 'name', 'addressSpace', 'loadAddress'],\n path,\n diagnostics,\n );\n const projectId = readStringField(value, 'projectId', path, diagnostics, true, {\n nonEmpty: true,\n });\n const overrides = readAddressOverrides(value, path, diagnostics);\n if (projectId === undefined || overrides === undefined) {\n return undefined;\n }\n const name = readStringField(value, 'name', path, diagnostics, false, { nonEmpty: true });\n return { mode: 'project', projectId, ...(name === undefined ? {} : { name }), ...overrides };\n}\n\nfunction readResourceReference(\n value: Record<string, unknown>,\n mode: ResourceMode,\n path: readonly string[],\n diagnostics: FusedDiagnostic[],\n): ResourceReference | FirmwareFileReference | undefined {\n const hasOverrides = hasOwn(value, 'addressSpace') || hasOwn(value, 'loadAddress');\n const fields = mode === 'asset' ? ['assetId', 'name', 'mode'] : ['src', 'mode'];\n forbidUnknownFields(\n value,\n hasOverrides ? [...fields, 'addressSpace', 'loadAddress'] : fields,\n path,\n diagnostics,\n );\n if (mode === 'asset') {\n const assetId = readStringField(value, 'assetId', path, diagnostics, true, { nonEmpty: true });\n const name = readStringField(value, 'name', path, diagnostics, true, { nonEmpty: true });\n const overrides = readAddressOverrides(value, path, diagnostics);\n if (assetId === undefined || name === undefined || overrides === undefined) return undefined;\n return { mode, assetId, name, ...overrides };\n }\n const src = readStringField(value, 'src', path, diagnostics, true, { nonEmpty: true });\n if (src === undefined) {\n return undefined;\n }\n const srcProblem = resourceSrcProblem(mode, src);\n if (srcProblem !== undefined) {\n report(diagnostics, 'schema/invalid-value', `Field \"src\" ${srcProblem}.`, [...path, 'src']);\n return undefined;\n }\n if (!hasOverrides) {\n return { src, mode };\n }\n const overrides = readAddressOverrides(value, path, diagnostics);\n if (overrides === undefined) {\n return undefined;\n }\n return { src, mode: 'package', ...overrides };\n}\n\n/** Reads optional `addressSpace` / `loadAddress` overrides of a firmware reference. */\nfunction readAddressOverrides(\n value: Record<string, unknown>,\n path: readonly string[],\n diagnostics: FusedDiagnostic[],\n): { readonly addressSpace?: string; readonly loadAddress?: number } | undefined {\n const addressSpace = readStringField(value, 'addressSpace', path, diagnostics, false, {\n nonEmpty: true,\n });\n const loadAddress = readIntegerField(value, 'loadAddress', path, diagnostics, false);\n if (loadAddress !== undefined && loadAddress < 0) {\n report(\n diagnostics,\n 'schema/invalid-value',\n 'Field \"loadAddress\" must be a non-negative safe integer.',\n [...path, 'loadAddress'],\n );\n return undefined;\n }\n if (hasOwn(value, 'addressSpace') && addressSpace === undefined) {\n return undefined;\n }\n if (hasOwn(value, 'loadAddress') && loadAddress === undefined) {\n return undefined;\n }\n return {\n ...(addressSpace === undefined ? {} : { addressSpace }),\n ...(loadAddress === undefined ? {} : { loadAddress }),\n };\n}\n\n/** Payload problem of a resource `src` for its mode, or `undefined` when it is well formed. */\nexport function resourceSrcProblem(mode: ResourceMode, src: string): string | undefined {\n switch (mode) {\n case 'package':\n return packagePathProblem(src);\n case 'asset':\n return src.length === 0 ? 'must not be empty' : undefined;\n }\n}\n","import type { FusedDiagnostic } from './diagnostics';\nimport { forbidUnknownFields, isRecord, readStringField, report } from './read';\nimport { readPropertyValue } from './resource';\nimport { deviceIdProblem, integrityProblem, isMemberKey, isSemVer } from './rules';\nimport type { DeviceDependency } from './types/document';\nimport type { PropertyValue } from './types/property';\n\nexport function readDependencies(\n value: Record<string, unknown> | undefined,\n path: readonly string[],\n diagnostics: FusedDiagnostic[],\n): Record<string, DeviceDependency> | undefined {\n if (value === undefined) {\n return undefined;\n }\n const dependencies: Record<string, DeviceDependency> = Object.create(null) as Record<\n string,\n DeviceDependency\n >;\n let failed = false;\n for (const [deviceId, raw] of Object.entries(value)) {\n const dependencyPath = [...path, deviceId];\n const idProblem = deviceIdProblem(deviceId);\n if (idProblem !== undefined) {\n report(\n diagnostics,\n 'schema/invalid-value',\n `Dependency key ${JSON.stringify(deviceId)} ${idProblem}.`,\n dependencyPath,\n );\n failed = true;\n continue;\n }\n if (!isRecord(raw)) {\n report(diagnostics, 'schema/invalid-type', 'Dependency must be an object.', dependencyPath);\n failed = true;\n continue;\n }\n forbidUnknownFields(raw, ['version', 'integrity'], dependencyPath, diagnostics);\n const version = readStringField(raw, 'version', dependencyPath, diagnostics, true, {\n nonEmpty: true,\n });\n if (version !== undefined && !isSemVer(version)) {\n report(\n diagnostics,\n 'schema/invalid-value',\n 'Dependency \"version\" must be a full SemVer version.',\n [...dependencyPath, 'version'],\n );\n failed = true;\n }\n const integrity = readStringField(raw, 'integrity', dependencyPath, diagnostics, true, {\n nonEmpty: true,\n });\n const integrityIssue = integrity === undefined ? undefined : integrityProblem(integrity);\n if (integrityIssue !== undefined) {\n report(diagnostics, 'schema/invalid-value', `Dependency \"integrity\" ${integrityIssue}.`, [\n ...dependencyPath,\n 'integrity',\n ]);\n failed = true;\n }\n if (version === undefined || integrity === undefined || integrityIssue !== undefined) {\n failed = true;\n continue;\n }\n dependencies[deviceId] = { version, integrity };\n }\n return failed ? undefined : dependencies;\n}\n\nexport function readProperties(\n raw: unknown,\n path: readonly string[],\n diagnostics: FusedDiagnostic[],\n): Readonly<Record<string, PropertyValue>> | undefined {\n if (!isRecord(raw)) {\n report(diagnostics, 'schema/invalid-type', 'Field \"properties\" must be an object.', path);\n return undefined;\n }\n const properties: Record<string, PropertyValue> = Object.create(null) as Record<\n string,\n PropertyValue\n >;\n let failed = false;\n for (const [key, value] of Object.entries(raw)) {\n const entryPath = [...path, key];\n if (!isMemberKey(key)) {\n report(\n diagnostics,\n 'schema/invalid-value',\n `Property key ${JSON.stringify(key)} must match [A-Za-z][A-Za-z0-9]*.`,\n entryPath,\n );\n failed = true;\n continue;\n }\n const property = readPropertyValue(value, entryPath, diagnostics);\n if (property === undefined) {\n failed = true;\n continue;\n }\n properties[key] = property;\n }\n return failed ? undefined : properties;\n}\n"],"mappings":";;AA6CA,SAAgB,UAAU,MAAiC;CACzD,I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ACH,WACF,CAAC;GACD,SAAS;EACX;EACA,IAAI,YAAY,KAAA,KAAa,cAAc,KAAA,KAAa,mBAAmB,KAAA,GAAW;GACpF,SAAS;GACT;EACF;EACA,aAAa,YAAY;GAAE;GAAS;EAAU;CAChD;CACA,OAAO,SAAS,KAAA,IAAY;AAC9B;AAEA,SAAgB,eACd,KACA,MACA,aACqD;CACrD,IAAI,CAAC,SAAS,GAAG,GAAG;EAClB,OAAO,aAAa,uBAAuB,2CAAyC,IAAI;EACxF;CACF;CACA,MAAM,aAA4C,OAAO,OAAO,IAAI;CAIpE,IAAI,SAAS;CACb,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,GAAG,GAAG;EAC9C,MAAM,YAAY,CAAC,GAAG,MAAM,GAAG;EAC/B,IAAI,CAAC,YAAY,GAAG,GAAG;GACrB,OACE,aACA,wBACA,gBAAgB,KAAK,UAAU,GAAG,EAAE,oCACpC,SACF;GACA,SAAS;GACT;EACF;EACA,MAAM,WAAW,kBAAkB,OAAO,WAAW,WAAW;EAChE,IAAI,aAAa,KAAA,GAAW;GAC1B,SAAS;GACT;EACF;EACA,WAAW,OAAO;CACpB;CACA,OAAO,SAAS,KAAA,IAAY;AAC9B"}
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Device data file next to the schematic (RFC 0024 / RFC 0029).
3
+ *
4
+ * `path` is a directory-root relative POSIX path inside the document's sibling `deviceData/`
5
+ * directory. A `disk` property accepts only this reference for a non-null value.
6
+ */
7
+ declare interface DeviceDataReference {
8
+ readonly mode: 'deviceData';
9
+ readonly path: string;
10
+ }
11
+
12
+ /** Exact release a document depends on (RFC 0020 / RFC 0024). */
13
+ declare interface DeviceDependency {
14
+ readonly version: string;
15
+ /** `sha256:` plus 64 lowercase hexadecimal digits of the release identity. */
16
+ readonly integrity: string;
17
+ }
18
+
19
+ /**
20
+ * `firmware` value that names a fixed file (RFC 0026). `addressSpace` and `loadAddress` override
21
+ * the attribute defaults for the address space and, for BIN, the load address.
22
+ */
23
+ declare type FirmwareFileReference = ResourceReference & {
24
+ readonly addressSpace?: string;
25
+ readonly loadAddress?: number;
26
+ };
27
+
28
+ /** One problem found while validating fused device data. */
29
+ declare interface FusedDiagnostic {
30
+ readonly severity: FusedDiagnosticSeverity;
31
+ /** Stable contract code; the human readable `message` is not part of the contract. */
32
+ readonly code: FusedDiagnosticCode;
33
+ readonly message: string;
34
+ /** JSON Pointer of the offending member; the empty string addresses the whole document. */
35
+ readonly pointer: string;
36
+ }
37
+
38
+ /**
39
+ * Stable diagnostic codes of the fused contracts.
40
+ *
41
+ * The codes follow the RFC 0020 / 0021 / 0022 / 0024 / 0026 tables. `json/*` and `schema/*` cover
42
+ * structural problems, `package/*` manifest and path problems, and the remaining families cover
43
+ * the named runtime contract they belong to.
44
+ */
45
+ 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';
46
+
47
+ /** Diagnostics of the fused device package and fused `.sch` contracts. */
48
+ declare type FusedDiagnosticSeverity = 'error' | 'warning';
49
+
50
+ /** Opens the versioned format. Structurally valid records survive unresolved references. */
51
+ export declare function openScene3D(input: unknown, bodies?: Scene3DBodyRegistry): Scene3DOpenResult;
52
+
53
+ export declare function openScene3DSession(input: unknown): Scene3DSessionResult;
54
+
55
+ /** Runtime gate after device scripts have registered their bodies. */
56
+ export declare function prepareScene3DRun(input: unknown, bodies: Scene3DBodyRegistry): Scene3DOpenResult;
57
+
58
+ declare type ProgramFileReference = FirmwareFileReference;
59
+
60
+ /** Program project resolved by the host at run preparation; the name is display metadata. */
61
+ declare interface ProgramProjectReference {
62
+ readonly mode: 'project';
63
+ readonly projectId: string;
64
+ readonly name?: string;
65
+ readonly addressSpace?: string;
66
+ readonly loadAddress?: number;
67
+ }
68
+
69
+ declare type ProgramReference = ProgramFileReference | ProgramProjectReference;
70
+
71
+ /**
72
+ * Instance property value stored in `FusedInstance.properties` (RFC 0024): a scalar, a resource
73
+ * reference, a firmware reference, a device data reference, or `null` for an explicitly cleared
74
+ * nullable property.
75
+ */
76
+ declare type PropertyValue = string | number | boolean | null | ResourceReference | ProgramReference | DeviceDataReference;
77
+
78
+ /**
79
+ * Reference to a resource instead of inline bytes (RFC 0024).
80
+ *
81
+ * `package` uses a package-root relative POSIX path; `asset` uses a host library identity.
82
+ */
83
+ declare type ResourceReference = {
84
+ readonly mode: 'package';
85
+ readonly src: string;
86
+ } | {
87
+ readonly mode: 'asset';
88
+ readonly assetId: string;
89
+ readonly name: string;
90
+ };
91
+
92
+ /** Instantiated packages register their public body IDs under the corresponding scene instance ID. */
93
+ export declare type Scene3DBodyRegistry = ReadonlyMap<string, ReadonlySet<string>>;
94
+
95
+ export declare type Scene3DCommand = {
96
+ readonly type: 'replace';
97
+ readonly document: Scene3DDocument;
98
+ } | {
99
+ readonly type: 'insertTemplate';
100
+ readonly template: Scene3DDocument;
101
+ } | {
102
+ readonly type: 'undo';
103
+ } | {
104
+ readonly type: 'redo';
105
+ } | {
106
+ readonly type: 'save';
107
+ };
108
+
109
+ export declare type Scene3DCommandResult = {
110
+ readonly ok: true;
111
+ readonly document: Scene3DDocument;
112
+ readonly diagnostics: readonly Scene3DDiagnostic[];
113
+ readonly text?: string;
114
+ } | {
115
+ readonly ok: false;
116
+ readonly diagnostics: readonly Scene3DDiagnostic[];
117
+ };
118
+
119
+ export declare interface Scene3DConnection {
120
+ readonly id: string;
121
+ readonly from: Scene3DContactEndpoint;
122
+ readonly to: Scene3DContactEndpoint;
123
+ readonly color?: string;
124
+ }
125
+
126
+ export declare interface Scene3DContactEndpoint {
127
+ readonly instance: string;
128
+ readonly contact: string;
129
+ }
130
+
131
+ export declare interface Scene3DDiagnostic extends Pick<FusedDiagnostic, 'severity' | 'pointer' | 'message'> {
132
+ readonly code: FusedDiagnostic['code'] | 'scene/legacy-format' | 'scene/dependency-conflict' | 'mount/unknown-instance' | 'mount/multiple-parents' | 'mount/cycle' | 'mount/invalid-root-pose' | 'mount/bodies-unregistered' | 'mount/unknown-body' | 'instance/invalid-name' | 'instance/duplicate-name';
133
+ }
134
+
135
+ export declare interface Scene3DDocument {
136
+ readonly version: typeof SCENE_3D_VERSION;
137
+ readonly dependencies: Readonly<Record<string, DeviceDependency>>;
138
+ readonly instances: readonly Scene3DInstance[];
139
+ readonly mounts: readonly Scene3DMount[];
140
+ readonly connections: readonly Scene3DConnection[];
141
+ }
142
+
143
+ export declare interface Scene3DInstance {
144
+ readonly id: string;
145
+ readonly device: string;
146
+ /** User-facing display name. Distinct instances may omit it and fall back to the manifest name. */
147
+ readonly name?: string;
148
+ readonly properties?: Readonly<Record<string, PropertyValue>>;
149
+ readonly pose?: Scene3DPose;
150
+ }
151
+
152
+ export declare interface Scene3DMount {
153
+ readonly child: string;
154
+ readonly parent: {
155
+ readonly instance: string;
156
+ readonly body?: string;
157
+ };
158
+ readonly localPose: Scene3DPose;
159
+ }
160
+
161
+ export declare type Scene3DOpenResult = {
162
+ readonly ok: true;
163
+ readonly document: Scene3DDocument;
164
+ readonly diagnostics: readonly Scene3DDiagnostic[];
165
+ } | {
166
+ readonly ok: false;
167
+ readonly diagnostics: readonly Scene3DDiagnostic[];
168
+ };
169
+
170
+ export declare interface Scene3DPose {
171
+ readonly positionMm: readonly [x: number, y: number, z: number];
172
+ readonly orientation: readonly [x: number, y: number, z: number, w: number];
173
+ }
174
+
175
+ export declare interface Scene3DSession {
176
+ readonly document: Scene3DDocument;
177
+ readonly canUndo: boolean;
178
+ readonly canRedo: boolean;
179
+ readonly undoDocument: Scene3DDocument | undefined;
180
+ readonly redoDocument: Scene3DDocument | undefined;
181
+ execute(command: Scene3DCommand): Scene3DCommandResult;
182
+ }
183
+
184
+ export declare type Scene3DSessionResult = {
185
+ readonly ok: true;
186
+ readonly session: Scene3DSession;
187
+ readonly diagnostics: readonly Scene3DDiagnostic[];
188
+ } | {
189
+ readonly ok: false;
190
+ readonly diagnostics: readonly Scene3DDiagnostic[];
191
+ };
192
+
193
+ export declare const SCENE_3D_VERSION = 2;
194
+
195
+ export declare const SCENE_NAME_MAX_LENGTH = 64;
196
+
197
+ /** Describes why an instance name is unusable, or returns undefined when it is valid. */
198
+ export declare function sceneNameProblem(name: string): string | undefined;
199
+
200
+ /** Appends a numeric suffix until the name is free within `taken`. */
201
+ export declare function uniqueSceneName(taken: ReadonlySet<string>, base: string): string;
202
+
203
+ export { }