@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.
- package/dist/src/core/index.cjs +35 -18
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +28 -8
- package/dist/src/core/index.d.ts +28 -8
- package/dist/src/core/index.js +35 -18
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs.map +1 -1
- package/package.json +15 -15
|
@@ -204,9 +204,9 @@ export declare function createPasswordState(field: PasswordField, styler?: Style
|
|
|
204
204
|
* @returns A {@link PromptInterface}
|
|
205
205
|
*
|
|
206
206
|
* @remarks
|
|
207
|
-
* The caller awaits the parked form's own `answer`. Timeout or teardown destroys the form,
|
|
208
|
-
* promise rejects with the Form package's `ABANDONED` error. Inject `options.timer` to
|
|
209
|
-
* expiry without real time.
|
|
207
|
+
* The caller awaits the parked form's own `answer`. Timeout, `stop`, or teardown destroys the form,
|
|
208
|
+
* so that promise rejects with the Form package's `ABANDONED` error. Inject `options.timer` to
|
|
209
|
+
* drive expiry without real time.
|
|
210
210
|
*
|
|
211
211
|
* @example
|
|
212
212
|
* ```ts
|
|
@@ -747,7 +747,7 @@ export declare interface PendingForm {
|
|
|
747
747
|
* @remarks
|
|
748
748
|
* - `pending` — parked, awaiting {@link PromptInterface.answer}.
|
|
749
749
|
* - `answered` — answered and accepted, so the parked form settled.
|
|
750
|
-
* - `expired` — timed out, or torn down by `destroy`, before an answer.
|
|
750
|
+
* - `expired` — timed out, released by `stop`, or torn down by `destroy`, before an answer.
|
|
751
751
|
*/
|
|
752
752
|
export declare type PendingFormStatus = 'pending' | 'answered' | 'expired';
|
|
753
753
|
|
|
@@ -758,7 +758,8 @@ export declare type PendingFormStatus = 'pending' | 'answered' | 'expired';
|
|
|
758
758
|
* @remarks
|
|
759
759
|
* A parked record carries one call to `serializeForm`. A failed fill or submit leaves the record
|
|
760
760
|
* parked for another answer. A successful submit settles the form once, emits `answer`, and removes
|
|
761
|
-
* the record. Timeout and teardown abandon
|
|
761
|
+
* the record. Timeout, `stop`, and teardown abandon unsettled forms through their own `destroy`
|
|
762
|
+
* method.
|
|
762
763
|
*
|
|
763
764
|
* @example
|
|
764
765
|
* ```ts
|
|
@@ -778,6 +779,9 @@ export declare class Prompt implements PromptInterface {
|
|
|
778
779
|
pending(id: string): PendingForm | undefined;
|
|
779
780
|
park(form: FormInterface, request?: ParkRequest): string;
|
|
780
781
|
answer(id: string, values: FormValues): Result<FormValues, AnswerError>;
|
|
782
|
+
stop(ids: readonly string[]): boolean;
|
|
783
|
+
stop(id: string): boolean;
|
|
784
|
+
stop(): void;
|
|
781
785
|
destroy(): void;
|
|
782
786
|
}
|
|
783
787
|
|
|
@@ -929,7 +933,7 @@ export declare interface PromptClientOptions {
|
|
|
929
933
|
* @remarks
|
|
930
934
|
* - `pending` — a form was parked; a transport forwards the wire record to remote clients.
|
|
931
935
|
* - `answer` — a parked form was answered and accepted, carrying its id and the settled values.
|
|
932
|
-
* - `expire` — a parked form timed out or was
|
|
936
|
+
* - `expire` — a parked form timed out or was released unanswered, carrying its id.
|
|
933
937
|
*/
|
|
934
938
|
export declare type PromptEventMap = {
|
|
935
939
|
readonly pending: readonly [form: PendingForm];
|
|
@@ -969,6 +973,19 @@ export declare type PromptIcon = 'question' | 'pointer' | 'dot' | 'selected' | '
|
|
|
969
973
|
* - **Timeout abandons.** An unanswered form is destroyed after `timeout` ms; `expire` fires and
|
|
970
974
|
* the caller's promise rejects on the form's own lifecycle. The timer is injectable.
|
|
971
975
|
* - **Accessors.** `pending()` lists the parked records; `pending(id)` looks one up.
|
|
976
|
+
* - **Batch stop.** The array overload is declared first: `stop(ids)` releases each listed parked
|
|
977
|
+
* form and reports whether all ids were parked; `stop(id)` releases one; `stop()` releases every
|
|
978
|
+
* parked form without destroying the broker. Release uses the existing expiry semantics.
|
|
979
|
+
*
|
|
980
|
+
* @example
|
|
981
|
+
* ```ts
|
|
982
|
+
* const prompt = createPrompt()
|
|
983
|
+
* const first = prompt.park(createForm({ fields: [{ control: 'text', name: 'first' }] }))
|
|
984
|
+
* const second = prompt.park(createForm({ fields: [{ control: 'text', name: 'second' }] }))
|
|
985
|
+
* prompt.stop(first) // true
|
|
986
|
+
* prompt.stop([second, 'missing']) // false; `second` was still released
|
|
987
|
+
* prompt.stop() // release every remaining form; the broker stays usable
|
|
988
|
+
* ```
|
|
972
989
|
*/
|
|
973
990
|
export declare interface PromptInterface {
|
|
974
991
|
readonly emitter: EmitterInterface<PromptEventMap>;
|
|
@@ -977,6 +994,9 @@ export declare interface PromptInterface {
|
|
|
977
994
|
pending(): readonly PendingForm[];
|
|
978
995
|
pending(id: string): PendingForm | undefined;
|
|
979
996
|
answer(id: string, values: FormValues): Result<FormValues, AnswerError>;
|
|
997
|
+
stop(ids: readonly string[]): boolean;
|
|
998
|
+
stop(id: string): boolean;
|
|
999
|
+
stop(): void;
|
|
980
1000
|
destroy(): void;
|
|
981
1001
|
}
|
|
982
1002
|
|
|
@@ -1159,7 +1179,7 @@ export declare function selectView(state: ReturnType<typeof createSelectState>):
|
|
|
1159
1179
|
*/
|
|
1160
1180
|
export declare const SEQUENCE_NAMES: Readonly<Record<string, string>>;
|
|
1161
1181
|
|
|
1162
|
-
/** Serialize a parked prompt's expiry into a {@link WireEvent} — event `'expire'`, `data` the JSON-stringified `{ id }` payload. */
|
|
1182
|
+
/** Serialize a parked prompt's expiry or release into a {@link WireEvent} — event `'expire'`, `data` the JSON-stringified `{ id }` payload. */
|
|
1163
1183
|
export declare function serializeExpire(id: string): WireEvent;
|
|
1164
1184
|
|
|
1165
1185
|
/** Serialize a parked {@link PendingForm} into a {@link WireEvent}. */
|
|
@@ -1185,7 +1205,7 @@ export declare const SSE_BUFFER_LIMIT = 1048576;
|
|
|
1185
1205
|
*
|
|
1186
1206
|
* @remarks
|
|
1187
1207
|
* - `pending` — a serialized {@link import('./types.js').PendingForm} to dispatch and answer.
|
|
1188
|
-
* - `expire` — an `{ id }` payload: the broker expired a parked prompt (the client drops it).
|
|
1208
|
+
* - `expire` — an `{ id }` payload: the broker expired or released a parked prompt (the client drops it).
|
|
1189
1209
|
* - `shutdown` — the broker is going away; the client disconnects (no auto-reconnect) but stays reusable.
|
|
1190
1210
|
*/
|
|
1191
1211
|
export declare const SSE_EVENTS: Readonly<{
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -204,9 +204,9 @@ export declare function createPasswordState(field: PasswordField, styler?: Style
|
|
|
204
204
|
* @returns A {@link PromptInterface}
|
|
205
205
|
*
|
|
206
206
|
* @remarks
|
|
207
|
-
* The caller awaits the parked form's own `answer`. Timeout or teardown destroys the form,
|
|
208
|
-
* promise rejects with the Form package's `ABANDONED` error. Inject `options.timer` to
|
|
209
|
-
* expiry without real time.
|
|
207
|
+
* The caller awaits the parked form's own `answer`. Timeout, `stop`, or teardown destroys the form,
|
|
208
|
+
* so that promise rejects with the Form package's `ABANDONED` error. Inject `options.timer` to
|
|
209
|
+
* drive expiry without real time.
|
|
210
210
|
*
|
|
211
211
|
* @example
|
|
212
212
|
* ```ts
|
|
@@ -747,7 +747,7 @@ export declare interface PendingForm {
|
|
|
747
747
|
* @remarks
|
|
748
748
|
* - `pending` — parked, awaiting {@link PromptInterface.answer}.
|
|
749
749
|
* - `answered` — answered and accepted, so the parked form settled.
|
|
750
|
-
* - `expired` — timed out, or torn down by `destroy`, before an answer.
|
|
750
|
+
* - `expired` — timed out, released by `stop`, or torn down by `destroy`, before an answer.
|
|
751
751
|
*/
|
|
752
752
|
export declare type PendingFormStatus = 'pending' | 'answered' | 'expired';
|
|
753
753
|
|
|
@@ -758,7 +758,8 @@ export declare type PendingFormStatus = 'pending' | 'answered' | 'expired';
|
|
|
758
758
|
* @remarks
|
|
759
759
|
* A parked record carries one call to `serializeForm`. A failed fill or submit leaves the record
|
|
760
760
|
* parked for another answer. A successful submit settles the form once, emits `answer`, and removes
|
|
761
|
-
* the record. Timeout and teardown abandon
|
|
761
|
+
* the record. Timeout, `stop`, and teardown abandon unsettled forms through their own `destroy`
|
|
762
|
+
* method.
|
|
762
763
|
*
|
|
763
764
|
* @example
|
|
764
765
|
* ```ts
|
|
@@ -778,6 +779,9 @@ export declare class Prompt implements PromptInterface {
|
|
|
778
779
|
pending(id: string): PendingForm | undefined;
|
|
779
780
|
park(form: FormInterface, request?: ParkRequest): string;
|
|
780
781
|
answer(id: string, values: FormValues): Result<FormValues, AnswerError>;
|
|
782
|
+
stop(ids: readonly string[]): boolean;
|
|
783
|
+
stop(id: string): boolean;
|
|
784
|
+
stop(): void;
|
|
781
785
|
destroy(): void;
|
|
782
786
|
}
|
|
783
787
|
|
|
@@ -929,7 +933,7 @@ export declare interface PromptClientOptions {
|
|
|
929
933
|
* @remarks
|
|
930
934
|
* - `pending` — a form was parked; a transport forwards the wire record to remote clients.
|
|
931
935
|
* - `answer` — a parked form was answered and accepted, carrying its id and the settled values.
|
|
932
|
-
* - `expire` — a parked form timed out or was
|
|
936
|
+
* - `expire` — a parked form timed out or was released unanswered, carrying its id.
|
|
933
937
|
*/
|
|
934
938
|
export declare type PromptEventMap = {
|
|
935
939
|
readonly pending: readonly [form: PendingForm];
|
|
@@ -969,6 +973,19 @@ export declare type PromptIcon = 'question' | 'pointer' | 'dot' | 'selected' | '
|
|
|
969
973
|
* - **Timeout abandons.** An unanswered form is destroyed after `timeout` ms; `expire` fires and
|
|
970
974
|
* the caller's promise rejects on the form's own lifecycle. The timer is injectable.
|
|
971
975
|
* - **Accessors.** `pending()` lists the parked records; `pending(id)` looks one up.
|
|
976
|
+
* - **Batch stop.** The array overload is declared first: `stop(ids)` releases each listed parked
|
|
977
|
+
* form and reports whether all ids were parked; `stop(id)` releases one; `stop()` releases every
|
|
978
|
+
* parked form without destroying the broker. Release uses the existing expiry semantics.
|
|
979
|
+
*
|
|
980
|
+
* @example
|
|
981
|
+
* ```ts
|
|
982
|
+
* const prompt = createPrompt()
|
|
983
|
+
* const first = prompt.park(createForm({ fields: [{ control: 'text', name: 'first' }] }))
|
|
984
|
+
* const second = prompt.park(createForm({ fields: [{ control: 'text', name: 'second' }] }))
|
|
985
|
+
* prompt.stop(first) // true
|
|
986
|
+
* prompt.stop([second, 'missing']) // false; `second` was still released
|
|
987
|
+
* prompt.stop() // release every remaining form; the broker stays usable
|
|
988
|
+
* ```
|
|
972
989
|
*/
|
|
973
990
|
export declare interface PromptInterface {
|
|
974
991
|
readonly emitter: EmitterInterface<PromptEventMap>;
|
|
@@ -977,6 +994,9 @@ export declare interface PromptInterface {
|
|
|
977
994
|
pending(): readonly PendingForm[];
|
|
978
995
|
pending(id: string): PendingForm | undefined;
|
|
979
996
|
answer(id: string, values: FormValues): Result<FormValues, AnswerError>;
|
|
997
|
+
stop(ids: readonly string[]): boolean;
|
|
998
|
+
stop(id: string): boolean;
|
|
999
|
+
stop(): void;
|
|
980
1000
|
destroy(): void;
|
|
981
1001
|
}
|
|
982
1002
|
|
|
@@ -1159,7 +1179,7 @@ export declare function selectView(state: ReturnType<typeof createSelectState>):
|
|
|
1159
1179
|
*/
|
|
1160
1180
|
export declare const SEQUENCE_NAMES: Readonly<Record<string, string>>;
|
|
1161
1181
|
|
|
1162
|
-
/** Serialize a parked prompt's expiry into a {@link WireEvent} — event `'expire'`, `data` the JSON-stringified `{ id }` payload. */
|
|
1182
|
+
/** Serialize a parked prompt's expiry or release into a {@link WireEvent} — event `'expire'`, `data` the JSON-stringified `{ id }` payload. */
|
|
1163
1183
|
export declare function serializeExpire(id: string): WireEvent;
|
|
1164
1184
|
|
|
1165
1185
|
/** Serialize a parked {@link PendingForm} into a {@link WireEvent}. */
|
|
@@ -1185,7 +1205,7 @@ export declare const SSE_BUFFER_LIMIT = 1048576;
|
|
|
1185
1205
|
*
|
|
1186
1206
|
* @remarks
|
|
1187
1207
|
* - `pending` — a serialized {@link import('./types.js').PendingForm} to dispatch and answer.
|
|
1188
|
-
* - `expire` — an `{ id }` payload: the broker expired a parked prompt (the client drops it).
|
|
1208
|
+
* - `expire` — an `{ id }` payload: the broker expired or released a parked prompt (the client drops it).
|
|
1189
1209
|
* - `shutdown` — the broker is going away; the client disconnects (no auto-reconnect) but stays reusable.
|
|
1190
1210
|
*/
|
|
1191
1211
|
export declare const SSE_EVENTS: Readonly<{
|
package/dist/src/core/index.js
CHANGED
|
@@ -231,7 +231,7 @@ var DEFAULT_RECONNECT_DELAY_MS = 2e3;
|
|
|
231
231
|
*
|
|
232
232
|
* @remarks
|
|
233
233
|
* - `pending` — a serialized {@link import('./types.js').PendingForm} to dispatch and answer.
|
|
234
|
-
* - `expire` — an `{ id }` payload: the broker expired a parked prompt (the client drops it).
|
|
234
|
+
* - `expire` — an `{ id }` payload: the broker expired or released a parked prompt (the client drops it).
|
|
235
235
|
* - `shutdown` — the broker is going away; the client disconnects (no auto-reconnect) but stays reusable.
|
|
236
236
|
*/
|
|
237
237
|
var SSE_EVENTS = Object.freeze({
|
|
@@ -561,13 +561,11 @@ function sanitizeSchema(schema) {
|
|
|
561
561
|
}))
|
|
562
562
|
});
|
|
563
563
|
break;
|
|
564
|
-
case "file":
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
});
|
|
570
|
-
break;
|
|
564
|
+
case "file": fields.push({
|
|
565
|
+
...field,
|
|
566
|
+
...shared,
|
|
567
|
+
...field.accept !== void 0 ? { accept: field.accept.map(sanitizeDisplayText) } : {}
|
|
568
|
+
});
|
|
571
569
|
}
|
|
572
570
|
}
|
|
573
571
|
return {
|
|
@@ -1128,7 +1126,7 @@ function serializePending(form) {
|
|
|
1128
1126
|
id: form.id
|
|
1129
1127
|
};
|
|
1130
1128
|
}
|
|
1131
|
-
/** Serialize a parked prompt's expiry into a {@link WireEvent} — event `'expire'`, `data` the JSON-stringified `{ id }` payload. */
|
|
1129
|
+
/** Serialize a parked prompt's expiry or release into a {@link WireEvent} — event `'expire'`, `data` the JSON-stringified `{ id }` payload. */
|
|
1132
1130
|
function serializeExpire(id) {
|
|
1133
1131
|
return {
|
|
1134
1132
|
event: "expire",
|
|
@@ -1151,7 +1149,8 @@ function serializeShutdown() {
|
|
|
1151
1149
|
* @remarks
|
|
1152
1150
|
* A parked record carries one call to `serializeForm`. A failed fill or submit leaves the record
|
|
1153
1151
|
* parked for another answer. A successful submit settles the form once, emits `answer`, and removes
|
|
1154
|
-
* the record. Timeout and teardown abandon
|
|
1152
|
+
* the record. Timeout, `stop`, and teardown abandon unsettled forms through their own `destroy`
|
|
1153
|
+
* method.
|
|
1155
1154
|
*
|
|
1156
1155
|
* @example
|
|
1157
1156
|
* ```ts
|
|
@@ -1231,6 +1230,22 @@ var Prompt = class {
|
|
|
1231
1230
|
}
|
|
1232
1231
|
};
|
|
1233
1232
|
}
|
|
1233
|
+
stop(ids) {
|
|
1234
|
+
if (ids === void 0) {
|
|
1235
|
+
for (const id of [...this.#parked.keys()]) this.#expire(id);
|
|
1236
|
+
return;
|
|
1237
|
+
}
|
|
1238
|
+
if (isArray(ids)) {
|
|
1239
|
+
let stopped = true;
|
|
1240
|
+
for (const id of ids) {
|
|
1241
|
+
const parked = this.#parked.get(id);
|
|
1242
|
+
if (parked === void 0 || parked.pending.status !== "pending") stopped = false;
|
|
1243
|
+
}
|
|
1244
|
+
for (const id of ids) this.#expire(id);
|
|
1245
|
+
return stopped;
|
|
1246
|
+
}
|
|
1247
|
+
return this.#expire(ids);
|
|
1248
|
+
}
|
|
1234
1249
|
destroy() {
|
|
1235
1250
|
if (this.#destroyed) return;
|
|
1236
1251
|
this.#destroyed = true;
|
|
@@ -1300,7 +1315,7 @@ var Prompt = class {
|
|
|
1300
1315
|
}
|
|
1301
1316
|
#expire(id) {
|
|
1302
1317
|
const parked = this.#parked.get(id);
|
|
1303
|
-
if (parked === void 0 || parked.pending.status !== "pending") return;
|
|
1318
|
+
if (parked === void 0 || parked.pending.status !== "pending") return false;
|
|
1304
1319
|
parked.cancel();
|
|
1305
1320
|
const expired = {
|
|
1306
1321
|
...parked,
|
|
@@ -1313,6 +1328,7 @@ var Prompt = class {
|
|
|
1313
1328
|
parked.form.destroy();
|
|
1314
1329
|
this.#emitter.emit("expire", id);
|
|
1315
1330
|
this.#parked.delete(id);
|
|
1331
|
+
return true;
|
|
1316
1332
|
}
|
|
1317
1333
|
};
|
|
1318
1334
|
//#endregion
|
|
@@ -1995,9 +2011,9 @@ var DatabaseTerminalStore = class {
|
|
|
1995
2011
|
* @returns A {@link PromptInterface}
|
|
1996
2012
|
*
|
|
1997
2013
|
* @remarks
|
|
1998
|
-
* The caller awaits the parked form's own `answer`. Timeout or teardown destroys the form,
|
|
1999
|
-
* promise rejects with the Form package's `ABANDONED` error. Inject `options.timer` to
|
|
2000
|
-
* expiry without real time.
|
|
2014
|
+
* The caller awaits the parked form's own `answer`. Timeout, `stop`, or teardown destroys the form,
|
|
2015
|
+
* so that promise rejects with the Form package's `ABANDONED` error. Inject `options.timer` to
|
|
2016
|
+
* drive expiry without real time.
|
|
2001
2017
|
*
|
|
2002
2018
|
* @example
|
|
2003
2019
|
* ```ts
|
|
@@ -2090,12 +2106,13 @@ function createMemoryTerminalStore() {
|
|
|
2090
2106
|
* ```
|
|
2091
2107
|
*/
|
|
2092
2108
|
function createDatabaseTerminalStore(driver = createMemoryDriver()) {
|
|
2109
|
+
const columns = {
|
|
2110
|
+
id: stringShape(),
|
|
2111
|
+
snapshot: rawShape({})
|
|
2112
|
+
};
|
|
2093
2113
|
return new DatabaseTerminalStore(createDatabase({
|
|
2094
2114
|
driver,
|
|
2095
|
-
tables: { terminals:
|
|
2096
|
-
id: stringShape(),
|
|
2097
|
-
snapshot: rawShape({})
|
|
2098
|
-
} }
|
|
2115
|
+
tables: { terminals: columns }
|
|
2099
2116
|
}).table("terminals"));
|
|
2100
2117
|
}
|
|
2101
2118
|
//#endregion
|