@mica-js/document 0.3.0 → 0.5.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.
@@ -79,8 +79,10 @@ export declare interface DevicePropertyDescriptor {
79
79
  readonly alpha?: boolean;
80
80
  /** `enum`: non-empty option list. */
81
81
  readonly options?: readonly PropertyOption[];
82
- /** `image` / `binary` / `firmware`: host-side payload limit in bytes. */
82
+ /** `image` / `binary` / `disk` / `firmware`: host-side payload limit in bytes. */
83
83
  readonly maxBytes?: number;
84
+ /** `disk`: access to the session image, defaulting to read-only. */
85
+ readonly access?: 'read-only' | 'read-write';
84
86
  /** `image`: host-side pixel limit. */
85
87
  readonly maxPixels?: number;
86
88
  /** `binary`: file extension filter, each entry matching `\.[A-Za-z0-9]+`. */
@@ -98,13 +100,22 @@ export declare interface DevicePropertyDescriptor {
98
100
  }
99
101
 
100
102
  /** 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';
103
+ export declare type DevicePropertyType = 'string' | 'integer' | 'number' | 'boolean' | 'color' | 'enum' | 'image' | 'binary' | 'disk' | 'firmware' | 'program';
102
104
 
103
- /** Resolves a lock to the package bytes hosted by the current mode (RFC 0020). */
105
+ /** Selects available releases and opens exact locks (RFC 0020). */
104
106
  export declare interface DeviceRegistry {
107
+ /** Selects a release by SemVer range and `engines.mica`. */
108
+ resolve?(query: DeviceResolutionQuery): Promise<DeviceLock>;
105
109
  open(lock: DeviceLock): Promise<PackageFiles>;
106
110
  }
107
111
 
112
+ /** Query for the highest available release compatible with a host. */
113
+ export declare interface DeviceResolutionQuery {
114
+ readonly id: string;
115
+ readonly range: string;
116
+ readonly hostApiVersion: string;
117
+ }
118
+
108
119
  /** Connection target of a wire, label or voltage reference (RFC 0024). */
109
120
  export declare type Endpoint = {
110
121
  readonly kind: 'pin';
@@ -709,6 +709,7 @@ var PROPERTY_TYPES = [
709
709
  "enum",
710
710
  "image",
711
711
  "binary",
712
+ "disk",
712
713
  "firmware",
713
714
  "program"
714
715
  ];
@@ -750,6 +751,11 @@ var TYPE_FIELDS = {
750
751
  "maxBytes",
751
752
  "extensions"
752
753
  ],
754
+ disk: [
755
+ ...COMMON_FIELDS,
756
+ "maxBytes",
757
+ "access"
758
+ ],
753
759
  firmware: [
754
760
  ...COMMON_FIELDS,
755
761
  "maxBytes",
@@ -851,10 +857,22 @@ function readPropertyDescriptor(value, path, diagnostics) {
851
857
  }
852
858
  case "image":
853
859
  case "binary":
860
+ case "disk":
854
861
  case "firmware": {
855
862
  const maxBytes = readCount(value, "maxBytes", path, diagnostics);
856
863
  if (maxBytes === "invalid") failed = true;
857
- else if (maxBytes !== void 0) draft.maxBytes = maxBytes;
864
+ else if (type === "disk" && maxBytes === 0) {
865
+ report(diagnostics, "package/invalid-manifest", "maxBytes must be positive.", [...path, "maxBytes"]);
866
+ failed = true;
867
+ } else if (maxBytes !== void 0) draft.maxBytes = maxBytes;
868
+ if (type === "disk" && hasOwn(value, "access")) {
869
+ const access = value["access"];
870
+ if (access === "read-only" || access === "read-write") draft.access = access;
871
+ else {
872
+ report(diagnostics, "package/invalid-manifest", "Invalid disk access mode.", [...path, "access"]);
873
+ failed = true;
874
+ }
875
+ }
858
876
  if (type === "image") {
859
877
  const maxPixels = readCount(value, "maxPixels", path, diagnostics);
860
878
  if (maxPixels === "invalid") failed = true;
@@ -1175,6 +1193,7 @@ function checkDefault(value, descriptor, path, diagnostics) {
1175
1193
  const allowed = (descriptor.options ?? []).map((option) => option.value);
1176
1194
  return typeof value === "string" && allowed.includes(value) ? { value } : fail(`Default must be one of ${allowed.map((entry) => JSON.stringify(entry)).join(", ")}.`);
1177
1195
  }
1196
+ case "disk": return fail("A disk default must be null. Bind an asset on the instance.");
1178
1197
  case "image":
1179
1198
  case "binary": {
1180
1199
  const reference = checkPackageReference(value, path, diagnostics);