@isoloop/protocol 0.0.0-next.56111e3 → 0.0.0-next.5aa1a15

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/dist/index.d.ts CHANGED
@@ -13,13 +13,20 @@ export type Envelope<T extends string, P> = {
13
13
  id?: string;
14
14
  /** Id of the message this replies to. */
15
15
  re?: string;
16
+ /**
17
+ * The pool member a message is for (host → worker) or from (worker → host),
18
+ * on a pooled worker's isolate port (M2c, ADR 0001). Absent on an own
19
+ * worker's port, and on messages about the whole worker (`beat`).
20
+ */
21
+ isolate?: string;
16
22
  p: P;
17
23
  };
18
24
  /** Any envelope, before its type is known. */
19
25
  export type AnyEnvelope = Envelope<string, unknown>;
20
26
  /**
21
27
  * True for a well-formed envelope this build can read: `v` is a supported
22
- * version, `t` is a string, `id`/`re` are absent or strings, and `p` is present.
28
+ * version, `t` is a string, `id`/`re`/`isolate` are absent or strings, and `p`
29
+ * is present.
23
30
  * Says nothing about whether `t` is known; see the per-port guards.
24
31
  */
25
32
  export declare function isEnvelope(x: unknown): x is AnyEnvelope;
@@ -92,8 +99,12 @@ export type Mods = {
92
99
  meta: boolean;
93
100
  shift: boolean;
94
101
  };
95
- /** Event types the host forwards (design §4.6), plus `resize` for transferred canvases (§4.7). */
96
- export type EventType = "click" | "dblclick" | "input" | "change" | "keydown" | "keyup" | "submit" | "focusin" | "focusout" | "pointerdown" | "pointerup" | "pointermove" | "resize";
102
+ /**
103
+ * Event types the host forwards (design §4.6), plus `resize` for transferred
104
+ * canvases (§4.7). `pointermove` and `scroll` are opt-in per node and come at
105
+ * most once a frame.
106
+ */
107
+ export type EventType = "click" | "dblclick" | "input" | "change" | "keydown" | "keyup" | "submit" | "focusin" | "focusout" | "pointerdown" | "pointerup" | "pointermove" | "scroll" | "resize";
97
108
  /** A DOM event as it reaches an isolate (design §4.6). Node ids are the isolate's own. */
98
109
  export type SerializedEvent = {
99
110
  type: EventType;
@@ -111,6 +122,9 @@ export type SerializedEvent = {
111
122
  /** For `resize`. */
112
123
  width?: number;
113
124
  height?: number;
125
+ /** For `scroll`: the scrolled element's offsets (M3b). */
126
+ scrollTop?: number;
127
+ scrollLeft?: number;
114
128
  };
115
129
  /** Why the host asks an isolate to shut down. `suspend` keeps its offsets (M2, ADR 0001). */
116
130
  export type ShutdownReason = "stop" | "restart" | "suspend";
@@ -185,6 +199,7 @@ export type IsolateToHost = Envelope<"ready", {
185
199
  lagMs: number;
186
200
  heapBytes?: number;
187
201
  idle?: IdleReport;
202
+ members?: Record<string, IdleReport>;
188
203
  }> | Envelope<"error", ErrorPayload> | Envelope<"bye", Record<string, never>>;
189
204
  export declare const HOST_TO_ISOLATE: MessageTypes<HostToIsolate>;
190
205
  export declare const ISOLATE_TO_HOST: MessageTypes<IsolateToHost>;
package/dist/index.js CHANGED
@@ -8,11 +8,12 @@ const isRecord = (x) => typeof x === "object" && x !== null && !Array.isArray(x)
8
8
  const isOptionalString = (x) => x === void 0 || typeof x === "string";
9
9
  /**
10
10
  * True for a well-formed envelope this build can read: `v` is a supported
11
- * version, `t` is a string, `id`/`re` are absent or strings, and `p` is present.
11
+ * version, `t` is a string, `id`/`re`/`isolate` are absent or strings, and `p`
12
+ * is present.
12
13
  * Says nothing about whether `t` is known; see the per-port guards.
13
14
  */
14
15
  function isEnvelope(x) {
15
- return isRecord(x) && x["v"] === PROTOCOL.v && typeof x["t"] === "string" && "p" in x && isOptionalString(x["id"]) && isOptionalString(x["re"]);
16
+ return isRecord(x) && x["v"] === PROTOCOL.v && typeof x["t"] === "string" && "p" in x && isOptionalString(x["id"]) && isOptionalString(x["re"]) && isOptionalString(x["isolate"]);
16
17
  }
17
18
  /**
18
19
  * Builds a guard for one port's union from its message types. Each side drops
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isoloop/protocol",
3
- "version": "0.0.0-next.56111e3",
3
+ "version": "0.0.0-next.5aa1a15",
4
4
  "description": "Wire protocol types and guards shared by every Isoloop package.",
5
5
  "license": "MIT",
6
6
  "type": "module",