@orkestrel/terminal 0.0.9 → 0.0.11

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.
@@ -232,7 +232,7 @@ var DEFAULT_RECONNECT_DELAY_MS = 2e3;
232
232
  *
233
233
  * @remarks
234
234
  * - `pending` — a serialized {@link import('./types.js').PendingForm} to dispatch and answer.
235
- * - `expire` — an `{ id }` payload: the broker expired a parked prompt (the client drops it).
235
+ * - `expire` — an `{ id }` payload: the broker expired or released a parked prompt (the client drops it).
236
236
  * - `shutdown` — the broker is going away; the client disconnects (no auto-reconnect) but stays reusable.
237
237
  */
238
238
  var SSE_EVENTS = Object.freeze({
@@ -562,13 +562,11 @@ function sanitizeSchema(schema) {
562
562
  }))
563
563
  });
564
564
  break;
565
- case "file":
566
- fields.push({
567
- ...field,
568
- ...shared,
569
- ...field.accept !== void 0 ? { accept: field.accept.map(sanitizeDisplayText) } : {}
570
- });
571
- break;
565
+ case "file": fields.push({
566
+ ...field,
567
+ ...shared,
568
+ ...field.accept !== void 0 ? { accept: field.accept.map(sanitizeDisplayText) } : {}
569
+ });
572
570
  }
573
571
  }
574
572
  return {
@@ -1129,7 +1127,7 @@ function serializePending(form) {
1129
1127
  id: form.id
1130
1128
  };
1131
1129
  }
1132
- /** Serialize a parked prompt's expiry into a {@link WireEvent} — event `'expire'`, `data` the JSON-stringified `{ id }` payload. */
1130
+ /** Serialize a parked prompt's expiry or release into a {@link WireEvent} — event `'expire'`, `data` the JSON-stringified `{ id }` payload. */
1133
1131
  function serializeExpire(id) {
1134
1132
  return {
1135
1133
  event: "expire",
@@ -1152,7 +1150,8 @@ function serializeShutdown() {
1152
1150
  * @remarks
1153
1151
  * A parked record carries one call to `serializeForm`. A failed fill or submit leaves the record
1154
1152
  * parked for another answer. A successful submit settles the form once, emits `answer`, and removes
1155
- * the record. Timeout and teardown abandon every unsettled form through its own `destroy` method.
1153
+ * the record. Timeout, `stop`, and teardown abandon unsettled forms through their own `destroy`
1154
+ * method.
1156
1155
  *
1157
1156
  * @example
1158
1157
  * ```ts
@@ -1232,6 +1231,22 @@ var Prompt = class {
1232
1231
  }
1233
1232
  };
1234
1233
  }
1234
+ stop(ids) {
1235
+ if (ids === void 0) {
1236
+ for (const id of [...this.#parked.keys()]) this.#expire(id);
1237
+ return;
1238
+ }
1239
+ if ((0, _orkestrel_contract.isArray)(ids)) {
1240
+ let stopped = true;
1241
+ for (const id of ids) {
1242
+ const parked = this.#parked.get(id);
1243
+ if (parked === void 0 || parked.pending.status !== "pending") stopped = false;
1244
+ }
1245
+ for (const id of ids) this.#expire(id);
1246
+ return stopped;
1247
+ }
1248
+ return this.#expire(ids);
1249
+ }
1235
1250
  destroy() {
1236
1251
  if (this.#destroyed) return;
1237
1252
  this.#destroyed = true;
@@ -1301,7 +1316,7 @@ var Prompt = class {
1301
1316
  }
1302
1317
  #expire(id) {
1303
1318
  const parked = this.#parked.get(id);
1304
- if (parked === void 0 || parked.pending.status !== "pending") return;
1319
+ if (parked === void 0 || parked.pending.status !== "pending") return false;
1305
1320
  parked.cancel();
1306
1321
  const expired = {
1307
1322
  ...parked,
@@ -1314,6 +1329,7 @@ var Prompt = class {
1314
1329
  parked.form.destroy();
1315
1330
  this.#emitter.emit("expire", id);
1316
1331
  this.#parked.delete(id);
1332
+ return true;
1317
1333
  }
1318
1334
  };
1319
1335
  //#endregion
@@ -1996,9 +2012,9 @@ var DatabaseTerminalStore = class {
1996
2012
  * @returns A {@link PromptInterface}
1997
2013
  *
1998
2014
  * @remarks
1999
- * The caller awaits the parked form's own `answer`. Timeout or teardown destroys the form, so that
2000
- * promise rejects with the Form package's `ABANDONED` error. Inject `options.timer` to drive
2001
- * expiry without real time.
2015
+ * The caller awaits the parked form's own `answer`. Timeout, `stop`, or teardown destroys the form,
2016
+ * so that promise rejects with the Form package's `ABANDONED` error. Inject `options.timer` to
2017
+ * drive expiry without real time.
2002
2018
  *
2003
2019
  * @example
2004
2020
  * ```ts
@@ -2091,12 +2107,13 @@ function createMemoryTerminalStore() {
2091
2107
  * ```
2092
2108
  */
2093
2109
  function createDatabaseTerminalStore(driver = (0, _orkestrel_database.createMemoryDriver)()) {
2110
+ const columns = {
2111
+ id: (0, _orkestrel_contract.stringShape)(),
2112
+ snapshot: (0, _orkestrel_contract.rawShape)({})
2113
+ };
2094
2114
  return new DatabaseTerminalStore((0, _orkestrel_database.createDatabase)({
2095
2115
  driver,
2096
- tables: { terminals: {
2097
- id: (0, _orkestrel_contract.stringShape)(),
2098
- snapshot: (0, _orkestrel_contract.rawShape)({})
2099
- } }
2116
+ tables: { terminals: columns }
2100
2117
  }).table("terminals"));
2101
2118
  }
2102
2119
  //#endregion