priiisk 0.1.15 → 0.1.16
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/{chunk-GZXZWUNM.js → chunk-2GZVYWLT.js} +236 -205
- package/dist/{chunk-P2XRQCTQ.js → chunk-ALAKPNLX.js} +3368 -5814
- package/dist/chunk-RIJ2MTZK.js +25010 -0
- package/dist/{chunk-6VG25ZCJ.js → chunk-TWBFOIDV.js} +652 -1451
- package/dist/priiisk-host.js +91186 -13014
- package/dist/priiisk-host.js.LEGAL.txt +44 -0
- package/dist/priiisk.js +2200 -1249
- package/package.json +8 -11
- package/dist/chunk-FGO3XP54.js +0 -667
- package/dist/chunk-MMIWOGCI.js +0 -988
- package/dist/chunk-QKN5JC3T.js +0 -187
- package/dist/chunk-RIYKIIGA.js +0 -44717
- package/dist/chunk-VM4SQU53.js +0 -1189
- /package/dist/{chunk-P2XRQCTQ.js.LEGAL.txt → chunk-ALAKPNLX.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-6VG25ZCJ.js.LEGAL.txt → chunk-TWBFOIDV.js.LEGAL.txt} +0 -0
|
@@ -2,23 +2,55 @@ import { createRequire as __priiiskCreateRequire } from "node:module";
|
|
|
2
2
|
const require = __priiiskCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
CampAskState,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
Tag,
|
|
6
|
+
TaggedError,
|
|
7
|
+
_await,
|
|
8
|
+
_void,
|
|
9
|
+
acquireRelease,
|
|
10
|
+
addFinalizer2 as addFinalizer,
|
|
11
|
+
as2 as as,
|
|
12
|
+
catchAll,
|
|
13
|
+
catchAllCause2 as catchAllCause,
|
|
14
|
+
currentTimeMillis,
|
|
15
|
+
fail4 as fail,
|
|
16
|
+
flatMap4 as flatMap,
|
|
17
|
+
forEach,
|
|
18
|
+
forever2 as forever,
|
|
19
|
+
forkScoped,
|
|
20
|
+
gen,
|
|
21
|
+
get7 as get,
|
|
22
|
+
ignore,
|
|
23
|
+
isInterruptedOnly,
|
|
24
|
+
isSuccess,
|
|
25
|
+
make11 as make2,
|
|
26
|
+
make13 as make3,
|
|
27
|
+
make7 as make,
|
|
28
|
+
makeRuntime,
|
|
29
|
+
modify2 as modify,
|
|
30
|
+
modifyEffect,
|
|
31
|
+
pretty,
|
|
32
|
+
run2 as run,
|
|
33
|
+
runForEach,
|
|
34
|
+
runFork,
|
|
35
|
+
scoped,
|
|
36
|
+
set3 as set,
|
|
37
|
+
sleep,
|
|
38
|
+
succeed2 as succeed,
|
|
39
|
+
succeed3 as succeed2,
|
|
40
|
+
suspend2 as suspend,
|
|
41
|
+
sync2 as sync,
|
|
42
|
+
taggedEnum,
|
|
43
|
+
tagsExhaustive,
|
|
44
|
+
tap2 as tap,
|
|
45
|
+
type,
|
|
46
|
+
update2 as update,
|
|
47
|
+
zipRight2 as zipRight
|
|
48
|
+
} from "./chunk-RIJ2MTZK.js";
|
|
17
49
|
|
|
18
50
|
// packages/host-ui/src/backend/campUiBackend.ts
|
|
19
|
-
var CampUiBackendError = class extends
|
|
51
|
+
var CampUiBackendError = class extends TaggedError("CampUiBackendError") {
|
|
20
52
|
};
|
|
21
|
-
var CampUiBackend = class extends
|
|
53
|
+
var CampUiBackend = class extends Tag("priiisk/CampUiBackend")() {
|
|
22
54
|
};
|
|
23
55
|
|
|
24
56
|
// packages/host-ui/src/model/campUiModel.ts
|
|
@@ -101,21 +133,21 @@ var updateCampUiStringSet = (current, value, included) => {
|
|
|
101
133
|
};
|
|
102
134
|
|
|
103
135
|
// packages/host-ui/src/backend/campUiStore.ts
|
|
104
|
-
var CampUiControllerError = class extends
|
|
136
|
+
var CampUiControllerError = class extends TaggedError("CampUiControllerError") {
|
|
105
137
|
};
|
|
106
|
-
var makeCampUiStore = (initial, presentationNow = 0) =>
|
|
107
|
-
const modelRef = yield*
|
|
108
|
-
const updateState = (mutate) =>
|
|
138
|
+
var makeCampUiStore = (initial, presentationNow = 0) => gen(function* () {
|
|
139
|
+
const modelRef = yield* make3(makeCampUiModel(initial, presentationNow));
|
|
140
|
+
const updateState = (mutate) => update(modelRef, (model) => ({ ...model, state: mutate(model.state) }));
|
|
109
141
|
const controller = {
|
|
110
|
-
selectWorker: (workerId) =>
|
|
142
|
+
selectWorker: (workerId) => modifyEffect(
|
|
111
143
|
modelRef,
|
|
112
|
-
(model) => findCampUiWorker(model.snapshot, workerId) === void 0 ?
|
|
144
|
+
(model) => findCampUiWorker(model.snapshot, workerId) === void 0 ? fail(
|
|
113
145
|
new CampUiControllerError({
|
|
114
146
|
operation: "campUi.selectWorker",
|
|
115
147
|
code: "worker_not_found",
|
|
116
148
|
workerId
|
|
117
149
|
})
|
|
118
|
-
) :
|
|
150
|
+
) : succeed2([
|
|
119
151
|
void 0,
|
|
120
152
|
{
|
|
121
153
|
...model,
|
|
@@ -123,15 +155,15 @@ var makeCampUiStore = (initial, presentationNow = 0) => Effect_exports.gen(funct
|
|
|
123
155
|
}
|
|
124
156
|
])
|
|
125
157
|
),
|
|
126
|
-
openWorker: (workerId) =>
|
|
158
|
+
openWorker: (workerId) => modifyEffect(
|
|
127
159
|
modelRef,
|
|
128
|
-
(model) => findCampUiWorker(model.snapshot, workerId) === void 0 ?
|
|
160
|
+
(model) => findCampUiWorker(model.snapshot, workerId) === void 0 ? fail(
|
|
129
161
|
new CampUiControllerError({
|
|
130
162
|
operation: "campUi.openWorker",
|
|
131
163
|
code: "worker_not_found",
|
|
132
164
|
workerId
|
|
133
165
|
})
|
|
134
|
-
) :
|
|
166
|
+
) : succeed2([
|
|
135
167
|
void 0,
|
|
136
168
|
{
|
|
137
169
|
...model,
|
|
@@ -143,14 +175,14 @@ var makeCampUiStore = (initial, presentationNow = 0) => Effect_exports.gen(funct
|
|
|
143
175
|
}
|
|
144
176
|
])
|
|
145
177
|
),
|
|
146
|
-
activateScreen: (screen) =>
|
|
178
|
+
activateScreen: (screen) => modifyEffect(
|
|
147
179
|
modelRef,
|
|
148
|
-
(model) => screen === CampUiScreen.worker && model.state.selectedWorkerId === void 0 ?
|
|
180
|
+
(model) => screen === CampUiScreen.worker && model.state.selectedWorkerId === void 0 ? fail(
|
|
149
181
|
new CampUiControllerError({
|
|
150
182
|
operation: "campUi.activateScreen",
|
|
151
183
|
code: "worker_not_selected"
|
|
152
184
|
})
|
|
153
|
-
) :
|
|
185
|
+
) : succeed2([void 0, { ...model, state: { ...model.state, screen } }])
|
|
154
186
|
),
|
|
155
187
|
focusDetailBlock: (focusedDetailBlockId) => updateState((state) => {
|
|
156
188
|
if (focusedDetailBlockId !== void 0) return { ...state, focusedDetailBlockId };
|
|
@@ -189,9 +221,9 @@ var makeCampUiStore = (initial, presentationNow = 0) => Effect_exports.gen(funct
|
|
|
189
221
|
})
|
|
190
222
|
};
|
|
191
223
|
return {
|
|
192
|
-
current:
|
|
224
|
+
current: get(modelRef),
|
|
193
225
|
changes: modelRef.changes,
|
|
194
|
-
updateSnapshot: (snapshot) =>
|
|
226
|
+
updateSnapshot: (snapshot) => modify(modelRef, (current) => {
|
|
195
227
|
const stale = current.snapshot.generation === snapshot.generation && snapshot.revision <= current.snapshot.revision;
|
|
196
228
|
return stale ? [false, current] : [true, { snapshot, state: reconcileCampUiState(current, snapshot) }];
|
|
197
229
|
}),
|
|
@@ -248,19 +280,19 @@ var CampUiContributionStrategy = {
|
|
|
248
280
|
replace: "replace",
|
|
249
281
|
decorate: "decorate"
|
|
250
282
|
};
|
|
251
|
-
var CampUiCompositionError = class extends
|
|
283
|
+
var CampUiCompositionError = class extends TaggedError("CampUiCompositionError") {
|
|
252
284
|
};
|
|
253
285
|
var orderContributions = (contributions) => [...contributions].sort(
|
|
254
286
|
(left, right) => (left.order ?? 0) - (right.order ?? 0) || left.id.localeCompare(right.id)
|
|
255
287
|
);
|
|
256
|
-
var registerDispose = (component) => component.dispose === void 0 ?
|
|
257
|
-
|
|
288
|
+
var registerDispose = (component) => component.dispose === void 0 ? succeed2(component) : addFinalizer(() => component.dispose).pipe(
|
|
289
|
+
as(component)
|
|
258
290
|
);
|
|
259
291
|
var validateContributions = (defaults, contributions) => {
|
|
260
292
|
const ids = [...defaults, ...contributions].map((contribution) => contribution.id);
|
|
261
293
|
const duplicateId = ids.find((id, index) => ids.indexOf(id) !== index);
|
|
262
294
|
if (duplicateId !== void 0) {
|
|
263
|
-
return
|
|
295
|
+
return fail(
|
|
264
296
|
new CampUiCompositionError({ code: "duplicate_id", details: { id: duplicateId } })
|
|
265
297
|
);
|
|
266
298
|
}
|
|
@@ -268,19 +300,19 @@ var validateContributions = (defaults, contributions) => {
|
|
|
268
300
|
const duplicateSlot = replacementSlots.find(
|
|
269
301
|
(slotId, index) => replacementSlots.indexOf(slotId) !== index
|
|
270
302
|
);
|
|
271
|
-
return duplicateSlot === void 0 ?
|
|
303
|
+
return duplicateSlot === void 0 ? _void : fail(
|
|
272
304
|
new CampUiCompositionError({
|
|
273
305
|
code: "multiple_replacements",
|
|
274
306
|
details: { slotId: duplicateSlot }
|
|
275
307
|
})
|
|
276
308
|
);
|
|
277
309
|
};
|
|
278
|
-
var composeCampUiSlots = (context, defaults, contributions) =>
|
|
310
|
+
var composeCampUiSlots = (context, defaults, contributions) => gen(function* () {
|
|
279
311
|
yield* validateContributions(defaults, contributions);
|
|
280
312
|
const slotIds = [...new Set([...defaults, ...contributions].map((item) => item.slotId))];
|
|
281
|
-
const entries = yield*
|
|
313
|
+
const entries = yield* forEach(
|
|
282
314
|
slotIds,
|
|
283
|
-
(slotId) =>
|
|
315
|
+
(slotId) => gen(function* () {
|
|
284
316
|
const replacement = contributions.find(
|
|
285
317
|
(item) => item.slotId === slotId && item.strategy === CampUiContributionStrategy.replace
|
|
286
318
|
);
|
|
@@ -293,9 +325,9 @@ var composeCampUiSlots = (context, defaults, contributions) => Effect_exports.ge
|
|
|
293
325
|
...replacement === void 0 ? [] : [replacement],
|
|
294
326
|
...appended
|
|
295
327
|
]);
|
|
296
|
-
const components = yield*
|
|
328
|
+
const components = yield* forEach(
|
|
297
329
|
contentFactories,
|
|
298
|
-
(item) => item.mount(context).pipe(
|
|
330
|
+
(item) => item.mount(context).pipe(flatMap(registerDispose))
|
|
299
331
|
);
|
|
300
332
|
let content = components.length === 0 ? emptyCampUiComponent : makeCampUiComponentGroup(components);
|
|
301
333
|
const decorators = orderContributions(
|
|
@@ -304,7 +336,7 @@ var composeCampUiSlots = (context, defaults, contributions) => Effect_exports.ge
|
|
|
304
336
|
)
|
|
305
337
|
);
|
|
306
338
|
for (const decorator of decorators) {
|
|
307
|
-
content = yield* decorator.decorate(context, content).pipe(
|
|
339
|
+
content = yield* decorator.decorate(context, content).pipe(flatMap(registerDispose));
|
|
308
340
|
}
|
|
309
341
|
return [slotId, content];
|
|
310
342
|
})
|
|
@@ -318,7 +350,7 @@ var composeCampUiDetailBlocks = (defaults, contributions) => {
|
|
|
318
350
|
const renderers = [...defaults, ...contributions];
|
|
319
351
|
const ids = renderers.map((renderer) => renderer.id);
|
|
320
352
|
const duplicateId = ids.find((id, index) => ids.indexOf(id) !== index);
|
|
321
|
-
return duplicateId === void 0 ?
|
|
353
|
+
return duplicateId === void 0 ? succeed2(renderers.sort(byOrder)) : fail(
|
|
322
354
|
new CampUiCompositionError({
|
|
323
355
|
code: "duplicate_id",
|
|
324
356
|
details: { area: "detail-block", id: duplicateId }
|
|
@@ -364,57 +396,57 @@ var nextCampUiPendingAskTarget = (snapshot, focusedBlockId) => {
|
|
|
364
396
|
};
|
|
365
397
|
|
|
366
398
|
// packages/host-ui/src/interaction/campUiIntents.ts
|
|
367
|
-
var CampUiIntents =
|
|
368
|
-
var makeCampUiIntentHandler = (options) =>
|
|
369
|
-
|
|
399
|
+
var CampUiIntents = taggedEnum();
|
|
400
|
+
var makeCampUiIntentHandler = (options) => type().pipe(
|
|
401
|
+
tagsExhaustive({
|
|
370
402
|
ActivateScreen: ({ screen }) => options.controller.activateScreen(screen),
|
|
371
403
|
FocusDetailBlock: ({ blockId }) => options.controller.focusDetailBlock(blockId),
|
|
372
404
|
FocusSlot: ({ slotId }) => options.controller.focusSlot(slotId),
|
|
373
|
-
JumpToWorkerTail: ({ workerId }) => options.controller.focusDetailBlock(void 0).pipe(
|
|
374
|
-
NextPendingAsk: () =>
|
|
405
|
+
JumpToWorkerTail: ({ workerId }) => options.controller.focusDetailBlock(void 0).pipe(zipRight(options.controller.setScrollOffset(workerId, 0))),
|
|
406
|
+
NextPendingAsk: () => suspend(() => {
|
|
375
407
|
const model = options.readModel();
|
|
376
408
|
const target = nextCampUiPendingAskTarget(
|
|
377
409
|
model.snapshot,
|
|
378
410
|
model.state.focusedDetailBlockId
|
|
379
411
|
);
|
|
380
|
-
return target === void 0 ?
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
412
|
+
return target === void 0 ? _void : options.controller.openWorker(target.workerId).pipe(
|
|
413
|
+
zipRight(options.controller.setDetailBlockExpanded(target.blockId, true)),
|
|
414
|
+
zipRight(options.controller.focusDetailBlock(target.blockId)),
|
|
415
|
+
zipRight(options.controller.focusSlot(CampUiSlot.transcript))
|
|
384
416
|
);
|
|
385
417
|
}),
|
|
386
418
|
OpenWorker: ({ workerId }) => options.controller.openWorker(workerId),
|
|
387
|
-
ScrollWorker: ({ workerId, delta }) =>
|
|
419
|
+
ScrollWorker: ({ workerId, delta }) => suspend(() => {
|
|
388
420
|
const offset = options.readModel().state.scrollOffsets.get(workerId) ?? 0;
|
|
389
421
|
return options.controller.focusDetailBlock(void 0).pipe(
|
|
390
|
-
|
|
422
|
+
zipRight(
|
|
391
423
|
options.controller.setScrollOffset(workerId, Math.max(0, offset + delta))
|
|
392
424
|
)
|
|
393
425
|
);
|
|
394
426
|
}),
|
|
395
|
-
SelectRelativeWorker: ({ delta }) =>
|
|
427
|
+
SelectRelativeWorker: ({ delta }) => suspend(() => {
|
|
396
428
|
const model = options.readModel();
|
|
397
429
|
const workers = model.snapshot.workers;
|
|
398
|
-
if (workers.length === 0) return
|
|
430
|
+
if (workers.length === 0) return _void;
|
|
399
431
|
const current = workers.findIndex(
|
|
400
432
|
(worker) => worker.snapshot.worker.id === model.state.selectedWorkerId
|
|
401
433
|
);
|
|
402
434
|
const index = current < 0 ? 0 : Math.min(workers.length - 1, Math.max(0, current + delta));
|
|
403
435
|
const workerId = workers[index]?.snapshot.worker.id;
|
|
404
|
-
return workerId === void 0 ?
|
|
436
|
+
return workerId === void 0 ? _void : options.controller.selectWorker(workerId);
|
|
405
437
|
}),
|
|
406
438
|
SelectWorker: ({ workerId }) => options.controller.selectWorker(workerId),
|
|
407
439
|
SetDraft: ({ workerId, draft }) => options.controller.setDraft(workerId, draft),
|
|
408
440
|
SetScrollOffset: ({ workerId, offset }) => options.controller.setScrollOffset(workerId, offset),
|
|
409
441
|
SetTranscriptVisible: ({ visible }) => options.controller.setDetailVisible(visible),
|
|
410
|
-
Steer: ({ workerId, message }) => message.trim() === "" ?
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
(cause) => options.controller.setDraft(workerId, message).pipe(
|
|
442
|
+
Steer: ({ workerId, message }) => message.trim() === "" ? _void : options.backend.steer({ workerId, message }).pipe(
|
|
443
|
+
tap(() => options.controller.setActionError(void 0)),
|
|
444
|
+
tap(() => options.controller.setDraft(workerId, "")),
|
|
445
|
+
catchAll(
|
|
446
|
+
(cause) => options.controller.setDraft(workerId, message).pipe(zipRight(options.controller.setActionError(cause.message)))
|
|
415
447
|
)
|
|
416
448
|
),
|
|
417
|
-
ToggleDetailBlock: ({ blockId }) =>
|
|
449
|
+
ToggleDetailBlock: ({ blockId }) => suspend(
|
|
418
450
|
() => options.controller.setDetailBlockExpanded(
|
|
419
451
|
blockId,
|
|
420
452
|
!options.readModel().state.expandedDetailBlockIds.has(blockId)
|
|
@@ -1972,47 +2004,47 @@ var makeDefaultCampUiContributions = (tui, detailBlocks) => [
|
|
|
1972
2004
|
{
|
|
1973
2005
|
id: "default-camp-header",
|
|
1974
2006
|
slotId: CampUiSlot.campHeader,
|
|
1975
|
-
mount: (context) =>
|
|
2007
|
+
mount: (context) => succeed2(makeCampUiCampHeader(context))
|
|
1976
2008
|
},
|
|
1977
2009
|
{
|
|
1978
2010
|
id: "default-seat",
|
|
1979
2011
|
slotId: CampUiSlot.seat,
|
|
1980
|
-
mount: (context) =>
|
|
2012
|
+
mount: (context) => succeed2(makeCampUiSeat(context))
|
|
1981
2013
|
},
|
|
1982
2014
|
{
|
|
1983
2015
|
id: "default-resources",
|
|
1984
2016
|
slotId: CampUiSlot.resources,
|
|
1985
|
-
mount: (context) =>
|
|
2017
|
+
mount: (context) => succeed2(makeCampUiResources(context))
|
|
1986
2018
|
},
|
|
1987
2019
|
{
|
|
1988
2020
|
id: "default-roster",
|
|
1989
2021
|
slotId: CampUiSlot.roster,
|
|
1990
|
-
mount: (context) =>
|
|
2022
|
+
mount: (context) => succeed2(makeCampUiRoster(context))
|
|
1991
2023
|
},
|
|
1992
2024
|
{
|
|
1993
2025
|
id: "default-session-header",
|
|
1994
2026
|
slotId: CampUiSlot.sessionHeader,
|
|
1995
|
-
mount: (context) =>
|
|
2027
|
+
mount: (context) => succeed2(makeCampUiSessionHeader(context))
|
|
1996
2028
|
},
|
|
1997
2029
|
{
|
|
1998
2030
|
id: "default-transcript",
|
|
1999
2031
|
slotId: CampUiSlot.transcript,
|
|
2000
|
-
mount: (context) =>
|
|
2032
|
+
mount: (context) => succeed2(makeCampUiDetailComponent(context, detailBlocks))
|
|
2001
2033
|
},
|
|
2002
2034
|
{
|
|
2003
2035
|
id: "default-composer",
|
|
2004
2036
|
slotId: CampUiSlot.composer,
|
|
2005
|
-
mount: (context) =>
|
|
2037
|
+
mount: (context) => succeed2(makeCampUiComposerComponent(context, tui))
|
|
2006
2038
|
},
|
|
2007
2039
|
{
|
|
2008
2040
|
id: "default-camp-footer",
|
|
2009
2041
|
slotId: CampUiSlot.campFooter,
|
|
2010
|
-
mount: (context) =>
|
|
2042
|
+
mount: (context) => succeed2(makeCampUiCampFooter(context))
|
|
2011
2043
|
},
|
|
2012
2044
|
{
|
|
2013
2045
|
id: "default-session-footer",
|
|
2014
2046
|
slotId: CampUiSlot.sessionFooter,
|
|
2015
|
-
mount: (context) =>
|
|
2047
|
+
mount: (context) => succeed2(makeCampUiSessionFooter(context))
|
|
2016
2048
|
}
|
|
2017
2049
|
];
|
|
2018
2050
|
|
|
@@ -2084,9 +2116,9 @@ var makeCampUiSection = (options) => {
|
|
|
2084
2116
|
}
|
|
2085
2117
|
} : {},
|
|
2086
2118
|
...disposableComponents ? {
|
|
2087
|
-
dispose:
|
|
2119
|
+
dispose: forEach(
|
|
2088
2120
|
[...components].reverse(),
|
|
2089
|
-
(component) => component.dispose ??
|
|
2121
|
+
(component) => component.dispose ?? _void,
|
|
2090
2122
|
{ discard: true }
|
|
2091
2123
|
)
|
|
2092
2124
|
} : {}
|
|
@@ -2416,11 +2448,11 @@ var PiCampUiRoot = class {
|
|
|
2416
2448
|
var hasPendingCampUiAsk = (model) => model.snapshot.workers.some(
|
|
2417
2449
|
(worker) => worker.asks.some((ask) => ask.state === CampAskState.pending)
|
|
2418
2450
|
);
|
|
2419
|
-
var runCampUiPresentationClock = (readModel, controller) =>
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
() => hasPendingCampUiAsk(readModel()) ?
|
|
2451
|
+
var runCampUiPresentationClock = (readModel, controller) => forever(
|
|
2452
|
+
sleep("1 second").pipe(
|
|
2453
|
+
zipRight(
|
|
2454
|
+
suspend(
|
|
2455
|
+
() => hasPendingCampUiAsk(readModel()) ? currentTimeMillis.pipe(flatMap(controller.setPresentationNow)) : _void
|
|
2424
2456
|
)
|
|
2425
2457
|
)
|
|
2426
2458
|
)
|
|
@@ -2477,39 +2509,39 @@ var makeCampUiTerminalModes = (terminal) => {
|
|
|
2477
2509
|
};
|
|
2478
2510
|
|
|
2479
2511
|
// packages/host-ui/src/pi/mountPiCampUi.ts
|
|
2480
|
-
var closedOnPurpose = (exit) =>
|
|
2481
|
-
var mountPiCampUi = (options) =>
|
|
2482
|
-
const startedAt = yield*
|
|
2483
|
-
const healthRef = yield*
|
|
2512
|
+
var closedOnPurpose = (exit) => isSuccess(exit) || isInterruptedOnly(exit.cause);
|
|
2513
|
+
var mountPiCampUi = (options) => gen(function* () {
|
|
2514
|
+
const startedAt = yield* currentTimeMillis;
|
|
2515
|
+
const healthRef = yield* make3({
|
|
2484
2516
|
status: CampUiRuntimeStatus.starting,
|
|
2485
2517
|
operation: "ui.mount",
|
|
2486
2518
|
updatedAt: startedAt
|
|
2487
2519
|
});
|
|
2488
|
-
const setHealth = (health) =>
|
|
2489
|
-
|
|
2490
|
-
(current2) => sameCampUiRuntimeHealth(current2, { ...health, updatedAt: current2.updatedAt }) ?
|
|
2491
|
-
|
|
2492
|
-
(updatedAt) =>
|
|
2520
|
+
const setHealth = (health) => get(healthRef).pipe(
|
|
2521
|
+
flatMap(
|
|
2522
|
+
(current2) => sameCampUiRuntimeHealth(current2, { ...health, updatedAt: current2.updatedAt }) ? _void : currentTimeMillis.pipe(
|
|
2523
|
+
flatMap(
|
|
2524
|
+
(updatedAt) => set(healthRef, { ...health, updatedAt })
|
|
2493
2525
|
)
|
|
2494
2526
|
)
|
|
2495
2527
|
)
|
|
2496
2528
|
);
|
|
2497
|
-
yield*
|
|
2529
|
+
yield* sync(() => initTheme(void 0, false));
|
|
2498
2530
|
const initial = yield* options.backend.snapshot;
|
|
2499
2531
|
const store = yield* makeCampUiStore(initial, startedAt);
|
|
2500
2532
|
let current = yield* store.current;
|
|
2501
2533
|
const terminal = options.terminal ?? new ProcessTerminal();
|
|
2502
2534
|
const terminalModes = makeCampUiTerminalModes(terminal);
|
|
2503
|
-
yield*
|
|
2504
|
-
|
|
2505
|
-
() =>
|
|
2535
|
+
yield* acquireRelease(
|
|
2536
|
+
sync(() => terminalModes.enter()),
|
|
2537
|
+
() => sync(() => terminalModes.exit())
|
|
2506
2538
|
);
|
|
2507
2539
|
const tui = new TUI(terminal, true);
|
|
2508
|
-
const runEffect = yield*
|
|
2540
|
+
const runEffect = yield* makeRuntime();
|
|
2509
2541
|
const dispatch = (effect) => {
|
|
2510
2542
|
runEffect(
|
|
2511
2543
|
effect.pipe(
|
|
2512
|
-
|
|
2544
|
+
catchAllCause((cause) => store.controller.setActionError(pretty(cause)))
|
|
2513
2545
|
)
|
|
2514
2546
|
);
|
|
2515
2547
|
};
|
|
@@ -2542,62 +2574,62 @@ var mountPiCampUi = (options) => Effect_exports.gen(function* () {
|
|
|
2542
2574
|
);
|
|
2543
2575
|
tui.addChild(root);
|
|
2544
2576
|
tui.setFocus(root);
|
|
2545
|
-
yield*
|
|
2577
|
+
yield* sync(() => {
|
|
2546
2578
|
terminal.setTitle(initial.displayName);
|
|
2547
2579
|
terminal.clearScreen();
|
|
2548
2580
|
tui.start();
|
|
2549
2581
|
});
|
|
2550
|
-
yield*
|
|
2551
|
-
(exit) =>
|
|
2582
|
+
yield* addFinalizer(
|
|
2583
|
+
(exit) => sync(() => {
|
|
2552
2584
|
tui.stop();
|
|
2553
2585
|
terminal.setProgress(false);
|
|
2554
2586
|
}).pipe(
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
closedOnPurpose(exit) ? options.backend.shutdown.pipe(
|
|
2587
|
+
zipRight(setHealth({ status: CampUiRuntimeStatus.stopped, operation: "ui.stop" })),
|
|
2588
|
+
zipRight(
|
|
2589
|
+
closedOnPurpose(exit) ? options.backend.shutdown.pipe(ignore) : _void
|
|
2558
2590
|
)
|
|
2559
2591
|
)
|
|
2560
2592
|
);
|
|
2561
|
-
yield*
|
|
2562
|
-
|
|
2593
|
+
yield* forkScoped(
|
|
2594
|
+
gen(function* () {
|
|
2563
2595
|
for (let attempt = 0; attempt < 25; attempt += 1) {
|
|
2564
|
-
if (yield*
|
|
2565
|
-
yield*
|
|
2596
|
+
if (yield* sync(() => terminalModes.tryEnableAlternateScroll())) return;
|
|
2597
|
+
yield* sleep("10 millis");
|
|
2566
2598
|
}
|
|
2567
2599
|
})
|
|
2568
2600
|
);
|
|
2569
|
-
const fibers = yield*
|
|
2570
|
-
yield*
|
|
2601
|
+
const fibers = yield* make2();
|
|
2602
|
+
yield* run(
|
|
2571
2603
|
fibers,
|
|
2572
2604
|
store.changes.pipe(
|
|
2573
|
-
|
|
2574
|
-
(model) =>
|
|
2605
|
+
runForEach(
|
|
2606
|
+
(model) => sync(() => {
|
|
2575
2607
|
current = model;
|
|
2576
2608
|
tui.requestRender();
|
|
2577
2609
|
})
|
|
2578
2610
|
)
|
|
2579
2611
|
)
|
|
2580
2612
|
);
|
|
2581
|
-
yield*
|
|
2613
|
+
yield* run(
|
|
2582
2614
|
fibers,
|
|
2583
2615
|
runCampUiPresentationClock(() => current, store.controller)
|
|
2584
2616
|
);
|
|
2585
2617
|
yield* setHealth({ status: CampUiRuntimeStatus.ready, operation: "ui.mount" });
|
|
2586
2618
|
const runSubscription = (failures) => options.backend.changes.pipe(
|
|
2587
|
-
|
|
2619
|
+
runForEach(
|
|
2588
2620
|
(snapshot) => store.updateSnapshot(snapshot).pipe(
|
|
2589
|
-
|
|
2621
|
+
zipRight(
|
|
2590
2622
|
setHealth({ status: CampUiRuntimeStatus.ready, operation: "ui.subscribe" })
|
|
2591
2623
|
),
|
|
2592
|
-
|
|
2624
|
+
zipRight(store.controller.setActionError(void 0))
|
|
2593
2625
|
)
|
|
2594
2626
|
),
|
|
2595
|
-
|
|
2596
|
-
|
|
2627
|
+
zipRight(
|
|
2628
|
+
fail(
|
|
2597
2629
|
new Error("Camp UI backend subscription ended before the UI scope was closed")
|
|
2598
2630
|
)
|
|
2599
2631
|
),
|
|
2600
|
-
|
|
2632
|
+
catchAll((cause) => {
|
|
2601
2633
|
const attempt = failures + 1;
|
|
2602
2634
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
2603
2635
|
if (attempt > CAMP_UI_SUBSCRIPTION_MAX_RETRIES) {
|
|
@@ -2606,11 +2638,11 @@ var mountPiCampUi = (options) => Effect_exports.gen(function* () {
|
|
|
2606
2638
|
operation: "ui.subscribe",
|
|
2607
2639
|
message,
|
|
2608
2640
|
attempt
|
|
2609
|
-
}).pipe(
|
|
2641
|
+
}).pipe(zipRight(store.controller.setActionError(message)));
|
|
2610
2642
|
}
|
|
2611
2643
|
const delay = campUiSubscriptionRetryDelay(attempt);
|
|
2612
|
-
return
|
|
2613
|
-
|
|
2644
|
+
return currentTimeMillis.pipe(
|
|
2645
|
+
flatMap(
|
|
2614
2646
|
(now) => setHealth({
|
|
2615
2647
|
status: CampUiRuntimeStatus.retrying,
|
|
2616
2648
|
operation: "ui.subscribe",
|
|
@@ -2619,18 +2651,18 @@ var mountPiCampUi = (options) => Effect_exports.gen(function* () {
|
|
|
2619
2651
|
nextRetryAt: now + delay
|
|
2620
2652
|
})
|
|
2621
2653
|
),
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2654
|
+
zipRight(store.controller.setActionError(message)),
|
|
2655
|
+
zipRight(sleep(delay)),
|
|
2656
|
+
zipRight(suspend(() => runSubscription(attempt)))
|
|
2625
2657
|
);
|
|
2626
2658
|
})
|
|
2627
2659
|
);
|
|
2628
|
-
yield*
|
|
2660
|
+
yield* run(fibers, runSubscription(0));
|
|
2629
2661
|
tui.requestRender(true);
|
|
2630
2662
|
return {
|
|
2631
2663
|
controller: store.controller,
|
|
2632
2664
|
tui,
|
|
2633
|
-
health: { current:
|
|
2665
|
+
health: { current: get(healthRef), changes: healthRef.changes }
|
|
2634
2666
|
};
|
|
2635
2667
|
});
|
|
2636
2668
|
|
|
@@ -2699,132 +2731,131 @@ var PiCampRunSelectorRoot = class {
|
|
|
2699
2731
|
invalidate() {
|
|
2700
2732
|
}
|
|
2701
2733
|
};
|
|
2702
|
-
var selectCampRun = (options) =>
|
|
2703
|
-
|
|
2704
|
-
yield*
|
|
2705
|
-
const selected = yield*
|
|
2734
|
+
var selectCampRun = (options) => scoped(
|
|
2735
|
+
gen(function* () {
|
|
2736
|
+
yield* sync(() => initTheme2(void 0, false));
|
|
2737
|
+
const selected = yield* make();
|
|
2706
2738
|
const terminal = options.terminal ?? new ProcessTerminal2();
|
|
2707
2739
|
const modes = makeCampUiTerminalModes(terminal);
|
|
2708
|
-
yield*
|
|
2709
|
-
|
|
2710
|
-
() =>
|
|
2740
|
+
yield* acquireRelease(
|
|
2741
|
+
sync(() => modes.enter()),
|
|
2742
|
+
() => sync(() => modes.exit())
|
|
2711
2743
|
);
|
|
2712
2744
|
const tui = new TUI2(terminal, true);
|
|
2713
2745
|
const root = new PiCampRunSelectorRoot(
|
|
2714
2746
|
options.items,
|
|
2715
2747
|
() => terminal.rows,
|
|
2716
2748
|
(runId) => {
|
|
2717
|
-
|
|
2749
|
+
runFork(succeed(selected, runId));
|
|
2718
2750
|
},
|
|
2719
2751
|
() => tui.requestRender()
|
|
2720
2752
|
);
|
|
2721
2753
|
tui.addChild(root);
|
|
2722
2754
|
tui.setFocus(root);
|
|
2723
|
-
yield*
|
|
2724
|
-
|
|
2755
|
+
yield* acquireRelease(
|
|
2756
|
+
sync(() => {
|
|
2725
2757
|
terminal.setTitle("Resume camp");
|
|
2726
2758
|
terminal.clearScreen();
|
|
2727
2759
|
tui.start();
|
|
2728
2760
|
tui.requestRender(true);
|
|
2729
2761
|
}),
|
|
2730
|
-
() =>
|
|
2762
|
+
() => sync(() => tui.stop())
|
|
2731
2763
|
);
|
|
2732
|
-
return yield*
|
|
2764
|
+
return yield* _await(selected);
|
|
2733
2765
|
})
|
|
2734
2766
|
);
|
|
2735
2767
|
|
|
2736
2768
|
// packages/host-ui/src/index.ts
|
|
2737
2769
|
var PACKAGE = "@priiisk/host-ui";
|
|
2738
|
-
|
|
2739
2770
|
export {
|
|
2740
|
-
|
|
2771
|
+
CAMP_UI_BASH_PREVIEW_LINES,
|
|
2772
|
+
CAMP_UI_DEFAULT_TOOL_PREVIEW_LINES,
|
|
2773
|
+
CAMP_UI_EXPLORED_COLLAPSED_PATHS,
|
|
2774
|
+
CAMP_UI_EXPLORED_TOOL_NAMES,
|
|
2775
|
+
CAMP_UI_SUBSCRIPTION_BASE_DELAY_MS,
|
|
2776
|
+
CAMP_UI_SUBSCRIPTION_MAX_RETRIES,
|
|
2777
|
+
CampUiAssistantMessage,
|
|
2741
2778
|
CampUiBackend,
|
|
2742
|
-
|
|
2743
|
-
CampUiHealthStatus,
|
|
2744
|
-
CampUiScreen,
|
|
2745
|
-
campUiAskBlockId,
|
|
2746
|
-
makeInitialCampUiState,
|
|
2747
|
-
makeCampUiModel,
|
|
2748
|
-
findCampUiWorker,
|
|
2749
|
-
CampUiControllerError,
|
|
2750
|
-
makeCampUiStore,
|
|
2751
|
-
makeCampUiComponentGroup,
|
|
2752
|
-
emptyCampUiComponent,
|
|
2753
|
-
CampUiSlot,
|
|
2754
|
-
CampUiContributionStrategy,
|
|
2779
|
+
CampUiBackendError,
|
|
2755
2780
|
CampUiCompositionError,
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
renderCampUiDetailBlockLayout,
|
|
2760
|
-
campUiPendingAskTargets,
|
|
2761
|
-
nextCampUiPendingAskTarget,
|
|
2762
|
-
CampUiIntents,
|
|
2763
|
-
makeCampUiIntentHandler,
|
|
2764
|
-
makeCampUiIntentRouter,
|
|
2781
|
+
CampUiContributionStrategy,
|
|
2782
|
+
CampUiControllerError,
|
|
2783
|
+
CampUiExploredStatus,
|
|
2765
2784
|
CampUiFocusDirection,
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
allocateCampUiSectionRows,
|
|
2770
|
-
defaultCampUiLeftSectionSizes,
|
|
2785
|
+
CampUiGlyph,
|
|
2786
|
+
CampUiHealthStatus,
|
|
2787
|
+
CampUiIntents,
|
|
2771
2788
|
CampUiLayoutMode,
|
|
2772
|
-
|
|
2789
|
+
CampUiPlacement,
|
|
2773
2790
|
CampUiRuntimeStatus,
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
joinCampUiColumns,
|
|
2778
|
-
jsonText,
|
|
2779
|
-
compactNumber,
|
|
2791
|
+
CampUiScreen,
|
|
2792
|
+
CampUiSectionSizeKind,
|
|
2793
|
+
CampUiSlot,
|
|
2780
2794
|
CampUiTone,
|
|
2781
|
-
CampUiGlyph,
|
|
2782
|
-
styleCampUiTone,
|
|
2783
|
-
uniqueCampUiNames,
|
|
2784
|
-
renderCampUiStatus,
|
|
2785
|
-
renderCampUiState,
|
|
2786
|
-
renderCampUiWorkerState,
|
|
2787
|
-
renderSelectedCampUiRow,
|
|
2788
2795
|
DEFAULT_DIRECTED_BLOCK_BODY_LINES,
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
resetCampUiBlockCache,
|
|
2794
|
-
campUiBlockCacheSize,
|
|
2796
|
+
PACKAGE,
|
|
2797
|
+
PiCampRunSelectorRoot,
|
|
2798
|
+
PiCampUiRoot,
|
|
2799
|
+
allocateCampUiSectionRows,
|
|
2795
2800
|
cachedCampUiBlock,
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
makeCampUiComposerComponent,
|
|
2801
|
+
campUiAskBlockId,
|
|
2802
|
+
campUiBlockCacheSize,
|
|
2799
2803
|
campUiEquipmentBlockRenderer,
|
|
2800
|
-
renderCampUiPanel,
|
|
2801
|
-
CAMP_UI_EXPLORED_TOOL_NAMES,
|
|
2802
|
-
CAMP_UI_EXPLORED_COLLAPSED_PATHS,
|
|
2803
|
-
CampUiExploredStatus,
|
|
2804
|
-
isCampUiExploredTool,
|
|
2805
2804
|
campUiExploredReadPath,
|
|
2806
2805
|
campUiExploredReadRange,
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2806
|
+
campUiMessageSignature,
|
|
2807
|
+
campUiPendingAskBlockRenderer,
|
|
2808
|
+
campUiPendingAskTargets,
|
|
2809
|
+
campUiResultSignature,
|
|
2810
|
+
campUiSubscriptionRetryDelay,
|
|
2811
2811
|
campUiToolResultCacheSize,
|
|
2812
|
-
renderCampUiToolResult,
|
|
2813
2812
|
campUiTranscriptBlockRenderer,
|
|
2813
|
+
compactNumber,
|
|
2814
|
+
composeCampUiDetailBlocks,
|
|
2815
|
+
composeCampUiSlots,
|
|
2816
|
+
decorateDefaultCampUiSections,
|
|
2814
2817
|
defaultCampUiDetailBlockRenderers,
|
|
2818
|
+
defaultCampUiLayoutPolicy,
|
|
2819
|
+
defaultCampUiLeftSectionSizes,
|
|
2820
|
+
emptyCampUiComponent,
|
|
2821
|
+
findCampUiSpatialFocusTarget,
|
|
2822
|
+
findCampUiWorker,
|
|
2823
|
+
fitCampUiLine,
|
|
2824
|
+
fitCampUiLines,
|
|
2825
|
+
formatCampUiDuration,
|
|
2826
|
+
hasCampUiTextContent,
|
|
2827
|
+
hasPendingCampUiAsk,
|
|
2828
|
+
isCampUiExploredTool,
|
|
2829
|
+
joinCampUiColumns,
|
|
2830
|
+
jsonText,
|
|
2831
|
+
makeCampUiComponentGroup,
|
|
2832
|
+
makeCampUiComposerComponent,
|
|
2815
2833
|
makeCampUiDetailComponent,
|
|
2816
|
-
|
|
2834
|
+
makeCampUiIntentHandler,
|
|
2835
|
+
makeCampUiIntentRouter,
|
|
2836
|
+
makeCampUiModel,
|
|
2817
2837
|
makeCampUiSection,
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2838
|
+
makeCampUiStore,
|
|
2839
|
+
makeDefaultCampUiContributions,
|
|
2840
|
+
makeDefaultCampUiLayout,
|
|
2841
|
+
makeInitialCampUiState,
|
|
2842
|
+
mountPiCampUi,
|
|
2843
|
+
nextCampUiPendingAskTarget,
|
|
2844
|
+
renderCampUiDetailBlockLayout,
|
|
2845
|
+
renderCampUiDetailBlocks,
|
|
2846
|
+
renderCampUiDirectedBlock,
|
|
2847
|
+
renderCampUiExploredGroup,
|
|
2848
|
+
renderCampUiPanel,
|
|
2849
|
+
renderCampUiState,
|
|
2850
|
+
renderCampUiStatus,
|
|
2851
|
+
renderCampUiToolResult,
|
|
2852
|
+
renderCampUiWorkerState,
|
|
2853
|
+
renderSelectedCampUiRow,
|
|
2854
|
+
resetCampUiBlockCache,
|
|
2855
|
+
resetCampUiToolResultCache,
|
|
2821
2856
|
runCampUiPresentationClock,
|
|
2822
|
-
CAMP_UI_SUBSCRIPTION_MAX_RETRIES,
|
|
2823
|
-
CAMP_UI_SUBSCRIPTION_BASE_DELAY_MS,
|
|
2824
|
-
campUiSubscriptionRetryDelay,
|
|
2825
2857
|
sameCampUiRuntimeHealth,
|
|
2826
|
-
mountPiCampUi,
|
|
2827
|
-
PiCampRunSelectorRoot,
|
|
2828
2858
|
selectCampRun,
|
|
2829
|
-
|
|
2859
|
+
styleCampUiTone,
|
|
2860
|
+
uniqueCampUiNames
|
|
2830
2861
|
};
|