@crowdedkingdoms/crowdyjs 18.22.0 → 18.23.0-dev.1
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/README.md +56 -15
- package/dist/crowdy-dsh/bridge.d.ts +72 -3
- package/dist/crowdy-dsh/bridge.d.ts.map +1 -1
- package/dist/crowdy-dsh/bridge.js +243 -12
- package/dist/crowdy-dsh/game-paths.d.ts +8 -0
- package/dist/crowdy-dsh/game-paths.d.ts.map +1 -0
- package/dist/crowdy-dsh/game-paths.js +20 -0
- package/dist/crowdy-dsh/pane.d.ts +18 -1
- package/dist/crowdy-dsh/pane.d.ts.map +1 -1
- package/dist/crowdy-dsh/pane.js +86 -2
- package/dist/crowdy-dsh/protocol.d.ts +165 -2
- package/dist/crowdy-dsh/protocol.d.ts.map +1 -1
- package/dist/crowdy-dsh/protocol.js +24 -1
- package/dist/crowdy-studio/controller.d.ts +100 -0
- package/dist/crowdy-studio/controller.d.ts.map +1 -1
- package/dist/crowdy-studio/controller.js +363 -1
- package/dist/crowdy-studio/dom-shell.d.ts +11 -0
- package/dist/crowdy-studio/dom-shell.d.ts.map +1 -1
- package/dist/crowdy-studio/dom-shell.js +182 -0
- package/dist/crowdy-studio/draft/github-draft-store.d.ts +143 -0
- package/dist/crowdy-studio/draft/github-draft-store.d.ts.map +1 -0
- package/dist/crowdy-studio/draft/github-draft-store.js +477 -0
- package/dist/crowdy-studio/draft/hash.d.ts +12 -0
- package/dist/crowdy-studio/draft/hash.d.ts.map +1 -0
- package/dist/crowdy-studio/draft/hash.js +25 -0
- package/dist/crowdy-studio/draft/index.d.ts +6 -0
- package/dist/crowdy-studio/draft/index.d.ts.map +1 -0
- package/dist/crowdy-studio/draft/index.js +5 -0
- package/dist/crowdy-studio/draft/overlay-storage.d.ts +48 -0
- package/dist/crowdy-studio/draft/overlay-storage.d.ts.map +1 -0
- package/dist/crowdy-studio/draft/overlay-storage.js +94 -0
- package/dist/crowdy-studio/draft/paths.d.ts +20 -0
- package/dist/crowdy-studio/draft/paths.d.ts.map +1 -0
- package/dist/crowdy-studio/draft/paths.js +54 -0
- package/dist/crowdy-studio/draft/types.d.ts +137 -0
- package/dist/crowdy-studio/draft/types.d.ts.map +1 -0
- package/dist/crowdy-studio/draft/types.js +29 -0
- package/dist/crowdy-studio/editor.d.ts +2 -0
- package/dist/crowdy-studio/editor.d.ts.map +1 -1
- package/dist/crowdy-studio/embed/panel.d.ts +8 -0
- package/dist/crowdy-studio/embed/panel.d.ts.map +1 -1
- package/dist/crowdy-studio/embed/panel.js +2 -0
- package/dist/crowdy-studio/github/index.d.ts +1 -1
- package/dist/crowdy-studio/github/index.d.ts.map +1 -1
- package/dist/crowdy-studio/github/transport.d.ts +59 -0
- package/dist/crowdy-studio/github/transport.d.ts.map +1 -1
- package/dist/crowdy-studio/github/transport.js +30 -1
- package/dist/crowdy-studio/index.d.ts +1 -0
- package/dist/crowdy-studio/index.d.ts.map +1 -1
- package/dist/crowdy-studio/index.js +1 -0
- package/dist/crowdy-studio/models.d.ts +1 -1
- package/dist/crowdy-studio/models.d.ts.map +1 -1
- package/dist/crowdy-studio/monaco-editor.d.ts.map +1 -1
- package/dist/crowdy-studio/monaco-editor.js +16 -0
- package/dist/crowdy-studio/mount.d.ts +2 -0
- package/dist/crowdy-studio/mount.d.ts.map +1 -1
- package/dist/crowdy-studio/mount.js +2 -0
- package/dist/crowdy-studio/repository-tree.d.ts +14 -0
- package/dist/crowdy-studio/repository-tree.d.ts.map +1 -0
- package/dist/crowdy-studio/repository-tree.js +45 -0
- package/dist/crowdy-studio/styles.d.ts +1 -1
- package/dist/crowdy-studio/styles.d.ts.map +1 -1
- package/dist/crowdy-studio/styles.js +1 -0
- package/dist/crowdy-studio/textarea-editor.d.ts.map +1 -1
- package/dist/crowdy-studio/textarea-editor.js +10 -4
- package/dist/default-origin.d.ts +6 -6
- package/dist/default-origin.d.ts.map +1 -1
- package/dist/default-origin.js +6 -6
- package/dist/generated/graphql-schema.d.ts +84 -2
- package/dist/generated/graphql-schema.d.ts.map +1 -1
- package/dist/generated/graphql-schema.js +9 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
* its own origin with a `MessageChannel` relay is tracked as a follow-up.
|
|
25
25
|
*/
|
|
26
26
|
import { CROWDY_DSH_PROTOCOL_VERSION, isDshBridgeFrame, isDshFrameMessage, } from './protocol.js';
|
|
27
|
+
import { assertPlaybookPage } from './game-paths.js';
|
|
28
|
+
import { DraftError } from '../crowdy-studio/draft/index.js';
|
|
27
29
|
const DEFAULT_MAX_SIDE = 1280;
|
|
28
30
|
const HELLO_DEBOUNCE_MS = 1500;
|
|
29
31
|
export class StudioDshBridge {
|
|
@@ -50,10 +52,26 @@ export class StudioDshBridge {
|
|
|
50
52
|
this.status = { phase: 'idle' };
|
|
51
53
|
/** One live-deploy question at a time: a second request must not replace the first prompt. */
|
|
52
54
|
this.liveDeployPending = false;
|
|
55
|
+
/** One commit question at a time, for the same reason. */
|
|
56
|
+
this.commitPending = false;
|
|
57
|
+
/** The editor this boot mounted; fixed until the harness reboots. */
|
|
58
|
+
this.mode = 'mod';
|
|
59
|
+
/** The draft store whose changes are forwarded as `page.draftChanged`. */
|
|
60
|
+
this.watchedDraft = null;
|
|
61
|
+
this.draftUnsubscribe = null;
|
|
62
|
+
this.skills = null;
|
|
53
63
|
}
|
|
54
64
|
get currentStatus() {
|
|
55
65
|
return this.status;
|
|
56
66
|
}
|
|
67
|
+
/** The editor the harness was booted with (`game` edits the bound Construct game). */
|
|
68
|
+
get studioMode() {
|
|
69
|
+
return this.mode;
|
|
70
|
+
}
|
|
71
|
+
/** The editor the controller wants now; differs from {@link studioMode} when the harness must reboot. */
|
|
72
|
+
desiredStudioMode() {
|
|
73
|
+
return this.options.studioMode ?? (this.options.controller.getState().repositoryMode ? 'game' : 'mod');
|
|
74
|
+
}
|
|
57
75
|
/** The models the harness was booted with. */
|
|
58
76
|
get catalog() {
|
|
59
77
|
return this.models;
|
|
@@ -65,12 +83,20 @@ export class StudioDshBridge {
|
|
|
65
83
|
async attach(frame) {
|
|
66
84
|
this.detach();
|
|
67
85
|
this.setStatus({ phase: 'waiting-for-frame' });
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
86
|
+
// The editor is a boot-time choice: the boot message waits until the
|
|
87
|
+
// controller knows it. The frame listener goes in first so a harness that
|
|
88
|
+
// says `ready` early is still answered.
|
|
89
|
+
const prepared = (async () => {
|
|
90
|
+
await this.options.controller.whenEditorKnown();
|
|
91
|
+
this.mode = this.desiredStudioMode();
|
|
92
|
+
this.models = await this.options.transport.models(this.options.appId);
|
|
93
|
+
if (this.models.length === 0) {
|
|
94
|
+
throw new Error('No model is allowed for this app; ask the app owner to enable the Studio agent.');
|
|
95
|
+
}
|
|
96
|
+
this.connect();
|
|
97
|
+
})();
|
|
73
98
|
await new Promise((resolve, reject) => {
|
|
99
|
+
let bootPosted = false;
|
|
74
100
|
const timeout = setTimeout(() => {
|
|
75
101
|
cleanup();
|
|
76
102
|
reject(new Error('The agent did not start within 60s.'));
|
|
@@ -78,6 +104,10 @@ export class StudioDshBridge {
|
|
|
78
104
|
const cleanup = () => {
|
|
79
105
|
clearTimeout(timeout);
|
|
80
106
|
};
|
|
107
|
+
prepared.catch((error) => {
|
|
108
|
+
cleanup();
|
|
109
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
110
|
+
});
|
|
81
111
|
this.frameListener = (event) => {
|
|
82
112
|
if (event.source !== frame.contentWindow)
|
|
83
113
|
return;
|
|
@@ -87,10 +117,11 @@ export class StudioDshBridge {
|
|
|
87
117
|
if (!isDshFrameMessage(data))
|
|
88
118
|
return;
|
|
89
119
|
if (data.type === 'crowdy-dsh:ready') {
|
|
90
|
-
if (this.booted)
|
|
120
|
+
if (this.booted || bootPosted)
|
|
91
121
|
return;
|
|
122
|
+
bootPosted = true;
|
|
92
123
|
this.setStatus({ phase: 'booting' });
|
|
93
|
-
frame.contentWindow?.postMessage(this.bootMessage(), location.origin);
|
|
124
|
+
void prepared.then(() => frame.contentWindow?.postMessage(this.bootMessage(), location.origin), () => undefined);
|
|
94
125
|
}
|
|
95
126
|
else if (data.type === 'crowdy-dsh:booted') {
|
|
96
127
|
this.booted = true;
|
|
@@ -125,6 +156,9 @@ export class StudioDshBridge {
|
|
|
125
156
|
this.frameListener = null;
|
|
126
157
|
this.unsubscribeState?.();
|
|
127
158
|
this.unsubscribeState = null;
|
|
159
|
+
this.draftUnsubscribe?.();
|
|
160
|
+
this.draftUnsubscribe = null;
|
|
161
|
+
this.watchedDraft = null;
|
|
128
162
|
if (this.tokenTimer)
|
|
129
163
|
clearInterval(this.tokenTimer);
|
|
130
164
|
this.tokenTimer = null;
|
|
@@ -164,6 +198,7 @@ export class StudioDshBridge {
|
|
|
164
198
|
const projectId = this.options.controller.getState().project?.projectId ?? '';
|
|
165
199
|
// No token here: `crowdy.json` lands in the worker's filesystem. The
|
|
166
200
|
// token follows over the channel once the worker says it is ready.
|
|
201
|
+
const persistScope = this.persistScope();
|
|
167
202
|
const crowdy = {
|
|
168
203
|
graphqlUrl: this.options.graphqlUrl,
|
|
169
204
|
appId: this.options.appId,
|
|
@@ -171,19 +206,27 @@ export class StudioDshBridge {
|
|
|
171
206
|
bridgeChannel: this.channelName,
|
|
172
207
|
bridgeNonce: this.nonce,
|
|
173
208
|
root: '/dsh/workspace',
|
|
174
|
-
persistScope
|
|
209
|
+
persistScope,
|
|
210
|
+
studioMode: this.mode,
|
|
175
211
|
};
|
|
176
212
|
return {
|
|
177
213
|
type: 'crowdy-dsh:boot',
|
|
178
214
|
files: {
|
|
179
215
|
'crowdy.json': JSON.stringify(crowdy, null, 2),
|
|
180
|
-
'settings.yaml': renderSettingsYaml(this.options.transport.modelBaseUrl, this.models),
|
|
216
|
+
'settings.yaml': renderSettingsYaml(this.options.transport.modelBaseUrl, this.models, this.mode),
|
|
181
217
|
},
|
|
182
218
|
nonce: this.nonce,
|
|
183
|
-
persistScope
|
|
219
|
+
persistScope,
|
|
184
220
|
mount: '/dsh/workspace',
|
|
185
221
|
};
|
|
186
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Sessions of the two editors never share a store: a game session restored
|
|
225
|
+
* into a mod boot would talk about files and tools that are not there.
|
|
226
|
+
*/
|
|
227
|
+
persistScope() {
|
|
228
|
+
return this.mode === 'game' ? `${this.options.persistScope}/game` : this.options.persistScope;
|
|
229
|
+
}
|
|
187
230
|
// ── channel ─────────────────────────────────────────────────────────────────
|
|
188
231
|
openChannel() {
|
|
189
232
|
this.channel = new BroadcastChannel(this.channelName);
|
|
@@ -217,7 +260,9 @@ export class StudioDshBridge {
|
|
|
217
260
|
}
|
|
218
261
|
fail(id, error) {
|
|
219
262
|
const message = error instanceof Error ? error.message : String(error);
|
|
220
|
-
|
|
263
|
+
// A draft failure carries a stable code the worker maps onto its filesystem errors.
|
|
264
|
+
const code = error instanceof DraftError ? error.code : 'PAGE_ERROR';
|
|
265
|
+
const frame = { v: CROWDY_DSH_PROTOCOL_VERSION, n: this.nonce, from: 'page', t: 'err', id, code, message };
|
|
221
266
|
this.channel?.postMessage(frame);
|
|
222
267
|
}
|
|
223
268
|
async handle(data) {
|
|
@@ -249,6 +294,10 @@ export class StudioDshBridge {
|
|
|
249
294
|
case 'worker.ready': {
|
|
250
295
|
const ready = payload;
|
|
251
296
|
this.setStatus({ phase: 'ready', ...(ready.store ? { store: ready.store } : {}) });
|
|
297
|
+
// A harness build that predates game mode mounts the mod crates whatever the boot said.
|
|
298
|
+
if (this.mode === 'game' && !(ready.modes ?? []).includes('game')) {
|
|
299
|
+
this.options.onWarning?.('This agent build cannot edit the game repository. Update @crowdedkingdoms/crowdy-dsh to a release with game mode.');
|
|
300
|
+
}
|
|
252
301
|
this.hello();
|
|
253
302
|
return;
|
|
254
303
|
}
|
|
@@ -263,6 +312,12 @@ export class StudioDshBridge {
|
|
|
263
312
|
}
|
|
264
313
|
case 'worker.openFile': {
|
|
265
314
|
const ref = payload;
|
|
315
|
+
if (ref.target === 'REPO' || this.options.controller.getState().repositoryMode) {
|
|
316
|
+
void this.options.controller.openRepositoryFile(ref.path).catch(() => {
|
|
317
|
+
// The draft may not have the file yet; the tree shows what it listed.
|
|
318
|
+
});
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
266
321
|
try {
|
|
267
322
|
this.options.controller.openFile({ source: 'PROJECT', target: ref.target, path: ref.path });
|
|
268
323
|
}
|
|
@@ -378,10 +433,154 @@ export class StudioDshBridge {
|
|
|
378
433
|
}
|
|
379
434
|
case 'grid.programStatus':
|
|
380
435
|
return { programs: this.gridHost().programs() };
|
|
436
|
+
case 'studio.readPlaybook':
|
|
437
|
+
return this.readPlaybook(params?.page ?? '');
|
|
438
|
+
case 'studio.listSkills':
|
|
439
|
+
return { skills: await this.listSkills() };
|
|
440
|
+
case 'draft.tree':
|
|
441
|
+
return this.requireDraft().snapshot();
|
|
442
|
+
case 'draft.read': {
|
|
443
|
+
const { paths } = params;
|
|
444
|
+
if (!Array.isArray(paths) || paths.length > 200 || !paths.every((p) => typeof p === 'string')) {
|
|
445
|
+
throw new DraftError('DRAFT_PATH_REFUSED', 'draft.read takes 1 to 200 paths.');
|
|
446
|
+
}
|
|
447
|
+
return (await this.requireDraft().read(paths));
|
|
448
|
+
}
|
|
449
|
+
case 'draft.write': {
|
|
450
|
+
const { path, content, precondition } = params;
|
|
451
|
+
if (typeof path !== 'string' || typeof content !== 'string') {
|
|
452
|
+
throw new DraftError('DRAFT_PATH_REFUSED', 'draft.write takes a path and text content.');
|
|
453
|
+
}
|
|
454
|
+
const result = await this.requireDraft().write(path, content, { source: 'agent', precondition });
|
|
455
|
+
this.options.onDraftChanged?.({ paths: [result.path] });
|
|
456
|
+
return result;
|
|
457
|
+
}
|
|
458
|
+
case 'draft.delete': {
|
|
459
|
+
const { path, precondition } = params;
|
|
460
|
+
const result = await this.requireDraft().remove(path, { source: 'agent', precondition });
|
|
461
|
+
this.options.onDraftChanged?.({ paths: [result.path] });
|
|
462
|
+
return result;
|
|
463
|
+
}
|
|
464
|
+
case 'draft.commit':
|
|
465
|
+
return (await this.commitDraft(params));
|
|
466
|
+
case 'preview.status': {
|
|
467
|
+
const { afterRevision, timeoutMs } = (params ?? {});
|
|
468
|
+
const wait = Math.min(Math.max(Number(timeoutMs) || 10000, 1000), 60000);
|
|
469
|
+
const preview = this.options.host?.previewStatus;
|
|
470
|
+
if (!preview) {
|
|
471
|
+
return {
|
|
472
|
+
revision: this.requireDraft().snapshot().revision,
|
|
473
|
+
ok: true,
|
|
474
|
+
errors: [],
|
|
475
|
+
note: 'This game does not report whether the world took the draft; ask the player or take a screenshot.',
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
return (await preview({ ...(afterRevision !== undefined ? { afterRevision } : {}), timeoutMs: wait }));
|
|
479
|
+
}
|
|
381
480
|
default:
|
|
382
481
|
throw new Error(`Unsupported bridge method ${String(method)}`);
|
|
383
482
|
}
|
|
384
483
|
}
|
|
484
|
+
requireDraft() {
|
|
485
|
+
const draft = this.options.controller.draftStore;
|
|
486
|
+
if (!draft) {
|
|
487
|
+
throw new DraftError('DRAFT_UNAVAILABLE', 'The open project has no game draft; this is the mod editor.');
|
|
488
|
+
}
|
|
489
|
+
return draft;
|
|
490
|
+
}
|
|
491
|
+
/** The commit gate: the player sees the files and the agent's message, and says yes on the page. */
|
|
492
|
+
async commitDraft(params) {
|
|
493
|
+
const message = typeof params.message === 'string' ? params.message.trim() : '';
|
|
494
|
+
if (!message)
|
|
495
|
+
throw new DraftError('DRAFT_PATH_REFUSED', 'A commit needs a message describing the change.');
|
|
496
|
+
const paths = Array.isArray(params.paths) ? params.paths.filter((p) => typeof p === 'string') : undefined;
|
|
497
|
+
const confirm = this.options.confirmCommit;
|
|
498
|
+
if (!confirm) {
|
|
499
|
+
throw new DraftError('DRAFT_DECLINED', 'Commits from the agent are not enabled on this page; use Commit in Crowdy Studio.');
|
|
500
|
+
}
|
|
501
|
+
if (this.commitPending)
|
|
502
|
+
throw new DraftError('DRAFT_DECLINED', 'A commit is already waiting for the player. Wait for it before asking again.');
|
|
503
|
+
this.commitPending = true;
|
|
504
|
+
try {
|
|
505
|
+
const draft = this.requireDraft();
|
|
506
|
+
const snapshot = draft.snapshot();
|
|
507
|
+
const wanted = paths && paths.length > 0 ? new Set(paths) : null;
|
|
508
|
+
const files = snapshot.entries.filter((e) => e.dirty && (!wanted || wanted.has(e.path))).map((e) => e.path);
|
|
509
|
+
const deleted = snapshot.deleted.filter((p) => !wanted || wanted.has(p));
|
|
510
|
+
if (files.length + deleted.length === 0)
|
|
511
|
+
throw new DraftError('DRAFT_NOT_FOUND', 'The draft has nothing to commit.');
|
|
512
|
+
const projectName = this.options.controller.getState().project?.metadata.name ?? 'this game';
|
|
513
|
+
if (!(await confirm({ projectName, message, files, deleted }))) {
|
|
514
|
+
throw new DraftError('DRAFT_DECLINED', 'The player declined the commit. The draft is unchanged; ask before committing again.');
|
|
515
|
+
}
|
|
516
|
+
// Exactly what the player approved: a write made while they decided stays in the draft,
|
|
517
|
+
// and an approved file that changed meanwhile is not committed unseen.
|
|
518
|
+
const approved = [...files, ...deleted];
|
|
519
|
+
const after = draft.snapshot();
|
|
520
|
+
const versionIn = (view, path) => view.deleted.includes(path) ? null : (view.entries.find((e) => e.path === path)?.hash ?? null);
|
|
521
|
+
const changed = approved.filter((path) => versionIn(snapshot, path) !== versionIn(after, path));
|
|
522
|
+
if (changed.length > 0) {
|
|
523
|
+
throw new DraftError('DRAFT_STALE', `${changed.join(', ')} changed while the player was deciding; ask to commit again.`);
|
|
524
|
+
}
|
|
525
|
+
return await this.options.controller.commitRepository({ message, paths: approved });
|
|
526
|
+
}
|
|
527
|
+
finally {
|
|
528
|
+
this.commitPending = false;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
/** The skills the game offers in the game editor, from `<playbookBase>skills/index.json`. */
|
|
532
|
+
async listSkills() {
|
|
533
|
+
if (this.skills)
|
|
534
|
+
return this.skills;
|
|
535
|
+
const configured = this.options.host?.playbookBase;
|
|
536
|
+
if (!configured)
|
|
537
|
+
return [];
|
|
538
|
+
const root = playbookRoot(configured);
|
|
539
|
+
let body;
|
|
540
|
+
try {
|
|
541
|
+
const response = await fetch(new URL('skills/index.json', root));
|
|
542
|
+
if (!response.ok)
|
|
543
|
+
return [];
|
|
544
|
+
body = await response.json();
|
|
545
|
+
}
|
|
546
|
+
catch {
|
|
547
|
+
return [];
|
|
548
|
+
}
|
|
549
|
+
const listed = body?.skills;
|
|
550
|
+
const skills = [];
|
|
551
|
+
for (const raw of Array.isArray(listed) ? listed : []) {
|
|
552
|
+
const entry = raw;
|
|
553
|
+
if (typeof entry.name !== 'string' || !/^[a-z0-9][a-z0-9-]{0,63}$/.test(entry.name))
|
|
554
|
+
continue;
|
|
555
|
+
if (typeof entry.description !== 'string' || !entry.description.trim())
|
|
556
|
+
continue;
|
|
557
|
+
if (typeof entry.page !== 'string')
|
|
558
|
+
continue;
|
|
559
|
+
try {
|
|
560
|
+
skills.push({ name: entry.name, description: entry.description.trim().slice(0, 500), page: assertPlaybookPage(entry.page) });
|
|
561
|
+
}
|
|
562
|
+
catch {
|
|
563
|
+
// A page outside the shipped tree is not offered.
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
this.skills = skills;
|
|
567
|
+
return skills;
|
|
568
|
+
}
|
|
569
|
+
async readPlaybook(page) {
|
|
570
|
+
const safe = assertPlaybookPage(page);
|
|
571
|
+
const configured = this.options.host?.playbookBase;
|
|
572
|
+
if (!configured)
|
|
573
|
+
throw new Error('This game does not ship a playbook.');
|
|
574
|
+
const root = playbookRoot(configured);
|
|
575
|
+
const url = new URL(safe, root);
|
|
576
|
+
if (url.origin !== root.origin || !url.pathname.startsWith(root.pathname)) {
|
|
577
|
+
throw new Error('Playbook pages stay inside the game.');
|
|
578
|
+
}
|
|
579
|
+
const response = await fetch(url);
|
|
580
|
+
if (!response.ok)
|
|
581
|
+
throw new Error(`No playbook page ${safe}.`);
|
|
582
|
+
return { text: await response.text() };
|
|
583
|
+
}
|
|
385
584
|
gridHost() {
|
|
386
585
|
const grid = this.options.host?.grid;
|
|
387
586
|
if (!grid)
|
|
@@ -392,6 +591,9 @@ export class StudioDshBridge {
|
|
|
392
591
|
const controller = this.options.controller;
|
|
393
592
|
if (!controller.getState().project)
|
|
394
593
|
throw new Error('No project is open in Crowdy Studio.');
|
|
594
|
+
const authorize = this.options.host?.authorizeLiveModding;
|
|
595
|
+
if (authorize)
|
|
596
|
+
await authorize(mode === 'draft' ? 'draft_test' : 'deploy_live');
|
|
395
597
|
const result = mode === 'draft' ? await controller.testDraft() : await controller.deployLive();
|
|
396
598
|
const state = controller.getState();
|
|
397
599
|
const diagnostics = [...state.authoritativeDiagnostics, ...state.localDiagnostics].map(toDshDiagnostic);
|
|
@@ -468,9 +670,29 @@ export class StudioDshBridge {
|
|
|
468
670
|
this.emit('page.saved', { revision: state.project?.revision.id, githubSha });
|
|
469
671
|
}
|
|
470
672
|
this.lastSaveState = state.saveState;
|
|
673
|
+
this.watchDraft();
|
|
471
674
|
});
|
|
472
675
|
this.tokenTimer = setInterval(() => this.tokenChanged(), 20000);
|
|
473
676
|
}
|
|
677
|
+
/** Forward every change of the open game draft, the agent's own writes included. */
|
|
678
|
+
watchDraft() {
|
|
679
|
+
const draft = this.options.controller.draftStore;
|
|
680
|
+
if (draft === this.watchedDraft)
|
|
681
|
+
return;
|
|
682
|
+
this.draftUnsubscribe?.();
|
|
683
|
+
this.draftUnsubscribe = null;
|
|
684
|
+
this.watchedDraft = draft;
|
|
685
|
+
if (!draft)
|
|
686
|
+
return;
|
|
687
|
+
this.draftUnsubscribe = draft.subscribe((event) => {
|
|
688
|
+
this.emit('page.draftChanged', {
|
|
689
|
+
revision: event.revision,
|
|
690
|
+
baseCommitSha: event.baseCommitSha,
|
|
691
|
+
changes: event.changes,
|
|
692
|
+
source: event.source,
|
|
693
|
+
});
|
|
694
|
+
});
|
|
695
|
+
}
|
|
474
696
|
setStatus(status) {
|
|
475
697
|
this.status = status;
|
|
476
698
|
this.options.onStatus?.(status);
|
|
@@ -533,7 +755,7 @@ function summarizeProject(project) {
|
|
|
533
755
|
};
|
|
534
756
|
}
|
|
535
757
|
/** Render the harness settings that point its native adapter at the metered endpoint. */
|
|
536
|
-
export function renderSettingsYaml(modelBaseUrl, models) {
|
|
758
|
+
export function renderSettingsYaml(modelBaseUrl, models, mode = 'mod') {
|
|
537
759
|
const quote = (value) => JSON.stringify(value);
|
|
538
760
|
const lines = [
|
|
539
761
|
'# Written by Crowdy Studio at boot; the metered model endpoint fronts the platform key.',
|
|
@@ -555,8 +777,17 @@ export function renderSettingsYaml(modelBaseUrl, models) {
|
|
|
555
777
|
if (first) {
|
|
556
778
|
lines.push('agent-default-model:', ' provider: deepseek-official', ` model: ${quote(first.id)}`);
|
|
557
779
|
}
|
|
780
|
+
// The game editor is its own agent preset; the mod editor keeps the image's default.
|
|
781
|
+
if (mode === 'game')
|
|
782
|
+
lines.push('agent-presets:', ' default: crowdy-game');
|
|
558
783
|
return `${lines.join('\n')}\n`;
|
|
559
784
|
}
|
|
785
|
+
function playbookRoot(base) {
|
|
786
|
+
const withSlash = base.endsWith('/') ? base : `${base}/`;
|
|
787
|
+
if (/^https?:\/\//.test(withSlash))
|
|
788
|
+
return new URL(withSlash);
|
|
789
|
+
return new URL(withSlash, location.origin);
|
|
790
|
+
}
|
|
560
791
|
/** Downscale and PNG-encode a frame in the page. */
|
|
561
792
|
async function encodePng(source, maxSide) {
|
|
562
793
|
let bitmap;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playbook pages the agent may read: markdown the game ships under its
|
|
3
|
+
* `playbookBase`. Which repository paths the game editor may touch is
|
|
4
|
+
* `crowdy-studio/draft/paths.ts`.
|
|
5
|
+
*/
|
|
6
|
+
/** A relative markdown page under the playbook root. Refuses anything that leaves that tree. */
|
|
7
|
+
export declare function assertPlaybookPage(page: string): string;
|
|
8
|
+
//# sourceMappingURL=game-paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"game-paths.d.ts","sourceRoot":"","sources":["../../src/crowdy-dsh/game-paths.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,gGAAgG;AAChG,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAevD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playbook pages the agent may read: markdown the game ships under its
|
|
3
|
+
* `playbookBase`. Which repository paths the game editor may touch is
|
|
4
|
+
* `crowdy-studio/draft/paths.ts`.
|
|
5
|
+
*/
|
|
6
|
+
/** A relative markdown page under the playbook root. Refuses anything that leaves that tree. */
|
|
7
|
+
export function assertPlaybookPage(page) {
|
|
8
|
+
const trimmed = page.trim().replace(/^\/+/, '');
|
|
9
|
+
if (!trimmed ||
|
|
10
|
+
trimmed.includes('..') ||
|
|
11
|
+
trimmed.includes('\\') ||
|
|
12
|
+
/[?#\0]/.test(trimmed) ||
|
|
13
|
+
trimmed.startsWith('.')) {
|
|
14
|
+
throw new Error('Playbook pages are markdown files shipped with the game.');
|
|
15
|
+
}
|
|
16
|
+
if (!/^[\w./-]+\.md$/.test(trimmed)) {
|
|
17
|
+
throw new Error('Name a playbook page such as playbook/authoring-loop.md.');
|
|
18
|
+
}
|
|
19
|
+
return trimmed;
|
|
20
|
+
}
|
|
@@ -25,6 +25,12 @@ export interface CrowdyStudioDshPaneOptions {
|
|
|
25
25
|
host?: CrowdyStudioDshHost;
|
|
26
26
|
/** Studio origin for the wallet link; omitted hides the link. */
|
|
27
27
|
studioOrigin?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Force the editor the harness boots. Omitted, it follows the open project:
|
|
30
|
+
* the game editor for a Construct game with a draft store, the mod editor
|
|
31
|
+
* otherwise, rebooting the harness when that changes.
|
|
32
|
+
*/
|
|
33
|
+
studioMode?: 'mod' | 'game';
|
|
28
34
|
layout?: StudioLayoutController;
|
|
29
35
|
onWarning?(message: string): void;
|
|
30
36
|
}
|
|
@@ -41,7 +47,18 @@ export declare class CrowdyStudioDshPane {
|
|
|
41
47
|
private usageTimer;
|
|
42
48
|
private started;
|
|
43
49
|
private disposed;
|
|
50
|
+
private booted;
|
|
51
|
+
private rebooting;
|
|
52
|
+
private unsubscribeMode;
|
|
44
53
|
constructor(parent: HTMLElement, options: CrowdyStudioDshPaneOptions);
|
|
54
|
+
/**
|
|
55
|
+
* The page-side gate on a commit to the bound branch. The agent wrote the
|
|
56
|
+
* message; the player sees it and every file, and says yes here. Auto-declines
|
|
57
|
+
* after two minutes so a stale prompt cannot be accepted later.
|
|
58
|
+
*/
|
|
59
|
+
private confirmCommit;
|
|
60
|
+
/** Restart the harness in the editor the open project needs. */
|
|
61
|
+
private reboot;
|
|
45
62
|
/**
|
|
46
63
|
* The page-side gate on a deploy to the grid, live or a draft test (which deploys the mod to
|
|
47
64
|
* the grid too). The harness UI has its own approval for a live deploy inside the iframe, but
|
|
@@ -61,5 +78,5 @@ export declare class CrowdyStudioDshPane {
|
|
|
61
78
|
private say;
|
|
62
79
|
private run;
|
|
63
80
|
}
|
|
64
|
-
export declare const CROWDY_STUDIO_DSH_STYLES = "\n.ck-crowdy-studio-dsh{flex:none;display:flex;flex-direction:column;min-width:0;min-height:0;border-left:1px solid var(--ck-line);background:#0b1220}\n.ck-crowdy-studio-dsh>header{display:flex;align-items:center;gap:8px;padding:6px 10px;border-bottom:1px solid var(--ck-line)}\n.ck-crowdy-studio-dsh>header h2{margin:0;font-size:13px;flex:none}\n.ck-crowdy-studio-dsh-status{flex:1;min-width:0;color:var(--ck-muted);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.ck-crowdy-studio-dsh[data-phase=failed] .ck-crowdy-studio-dsh-status{color:#fca5a5}\n.ck-crowdy-studio-dsh-frame{flex:1;min-height:0;width:100%;border:0;background:#fff}\n.ck-crowdy-studio-dsh-notice{padding:10px;font-size:12px;color:var(--ck-text);border-bottom:1px solid var(--ck-line)}\n.ck-crowdy-studio-dsh-notice p{margin:0 0 8px}\n.ck-crowdy-studio-dsh-notice-actions{display:flex;gap:6px}\n.ck-crowdy-studio-dsh-spend{padding:4px 10px;font-size:11px;color:var(--ck-muted);border-top:1px solid var(--ck-line)}\n.ck-crowdy-studio-dsh-spend a{color:#bae6fd}\n.ck-crowdy-studio-dsh-message{padding:4px 10px;font-size:11px;color:#fde68a;border-top:1px solid var(--ck-line)}\n.ck-crowdy-studio-dsh-message button{font-size:11px;padding:2px 8px;margin-left:4px}\n.ck-crowdy-studio-dsh-confirm{background:#b91c1c;color:#fff;border:0;border-radius:3px}\n";
|
|
81
|
+
export declare const CROWDY_STUDIO_DSH_STYLES = "\n.ck-crowdy-studio-dsh{flex:none;display:flex;flex-direction:column;min-width:0;min-height:0;border-left:1px solid var(--ck-line);background:#0b1220}\n.ck-crowdy-studio-dsh>header{display:flex;align-items:center;gap:8px;padding:6px 10px;border-bottom:1px solid var(--ck-line)}\n.ck-crowdy-studio-dsh>header h2{margin:0;font-size:13px;flex:none}\n.ck-crowdy-studio-dsh-status{flex:1;min-width:0;color:var(--ck-muted);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.ck-crowdy-studio-dsh[data-phase=failed] .ck-crowdy-studio-dsh-status{color:#fca5a5}\n.ck-crowdy-studio-dsh-frame{flex:1;min-height:0;width:100%;border:0;background:#fff}\n.ck-crowdy-studio-dsh-notice{padding:10px;font-size:12px;color:var(--ck-text);border-bottom:1px solid var(--ck-line)}\n.ck-crowdy-studio-dsh-notice p{margin:0 0 8px}\n.ck-crowdy-studio-dsh-notice-actions{display:flex;gap:6px}\n.ck-crowdy-studio-dsh-spend{padding:4px 10px;font-size:11px;color:var(--ck-muted);border-top:1px solid var(--ck-line)}\n.ck-crowdy-studio-dsh-spend a{color:#bae6fd}\n.ck-crowdy-studio-dsh-message{padding:4px 10px;font-size:11px;color:#fde68a;border-top:1px solid var(--ck-line)}\n.ck-crowdy-studio-dsh-message button{font-size:11px;padding:2px 8px;margin-left:4px}\n.ck-crowdy-studio-dsh-confirm{background:#b91c1c;color:#fff;border:0;border-radius:3px}\n.ck-crowdy-studio-dsh-commit-files{margin:4px 0;padding-left:16px;max-height:120px;overflow:auto;color:var(--ck-text)}\n";
|
|
65
82
|
//# sourceMappingURL=pane.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pane.d.ts","sourceRoot":"","sources":["../../src/crowdy-dsh/pane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAA8B,MAAM,aAAa,CAAC;AACpG,OAAO,EAAE,wBAAwB,EAA+B,MAAM,gBAAgB,CAAC;AAEvF,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,sBAAsB,CAAC;IACnC,SAAS,EAAE,wBAAwB,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,IAAI,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAChC,SAAS,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAID,qBAAa,mBAAmB;
|
|
1
|
+
{"version":3,"file":"pane.d.ts","sourceRoot":"","sources":["../../src/crowdy-dsh/pane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAA8B,MAAM,aAAa,CAAC;AACpG,OAAO,EAAE,wBAAwB,EAA+B,MAAM,gBAAgB,CAAC;AAEvF,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,sBAAsB,CAAC;IACnC,SAAS,EAAE,wBAAwB,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,IAAI,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAChC,SAAS,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAID,qBAAa,mBAAmB;IAkB5B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAjB1B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;IACrC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;IACrC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAoB;IAClD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;IACtC,OAAO,CAAC,UAAU,CAA+C;IACjE,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,eAAe,CAA6B;gBAGlD,MAAM,EAAE,WAAW,EACF,OAAO,EAAE,0BAA0B;IAwEtD;;;;OAIG;IACH,OAAO,CAAC,aAAa;IA6CrB,gEAAgE;YAClD,MAAM;IAgBpB;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IA+BzB,iFAAiF;IAC3E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB5B,OAAO,IAAI,IAAI;YASD,IAAI;IAYlB,OAAO,CAAC,YAAY;IAuBpB,OAAO,CAAC,YAAY;YAsBN,YAAY;IAU1B,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,GAAG;YAKG,GAAG;CAOlB;AAQD,eAAO,MAAM,wBAAwB,+7CAgBpC,CAAC"}
|
package/dist/crowdy-dsh/pane.js
CHANGED
|
@@ -16,6 +16,9 @@ export class CrowdyStudioDshPane {
|
|
|
16
16
|
this.usageTimer = null;
|
|
17
17
|
this.started = false;
|
|
18
18
|
this.disposed = false;
|
|
19
|
+
this.booted = false;
|
|
20
|
+
this.rebooting = false;
|
|
21
|
+
this.unsubscribeMode = null;
|
|
19
22
|
this.root = el('section', 'ck-crowdy-studio-dsh');
|
|
20
23
|
this.root.setAttribute('aria-label', 'Crowdy Studio agent');
|
|
21
24
|
const header = el('header');
|
|
@@ -61,15 +64,89 @@ export class CrowdyStudioDshPane {
|
|
|
61
64
|
persistScope: options.persistScope,
|
|
62
65
|
getToken: options.getToken,
|
|
63
66
|
graphqlUrl: options.graphqlUrl,
|
|
67
|
+
...(options.studioMode ? { studioMode: options.studioMode } : {}),
|
|
64
68
|
host: options.host,
|
|
65
69
|
confirmLiveDeploy: (summary) => this.confirmLiveDeploy(summary.projectName, summary.mode),
|
|
70
|
+
confirmCommit: (summary) => this.confirmCommit(summary),
|
|
66
71
|
onWarning: (text) => {
|
|
67
72
|
this.say(text);
|
|
68
73
|
options.onWarning?.(text);
|
|
69
74
|
},
|
|
70
75
|
onStatus: (status) => this.renderStatus(status),
|
|
71
76
|
onFileChanged: (change) => this.say(`Agent updated ${change.target.toLowerCase()}/${change.path}.`),
|
|
77
|
+
onDraftChanged: (change) => this.say(`Agent drafted ${change.paths.join(', ')}.`),
|
|
72
78
|
});
|
|
79
|
+
// The editor is fixed per harness boot: a project that needs the other one reboots it.
|
|
80
|
+
this.unsubscribeMode = options.controller.subscribe(() => {
|
|
81
|
+
if (!this.booted || this.rebooting || this.disposed)
|
|
82
|
+
return;
|
|
83
|
+
if (this.bridge.desiredStudioMode() !== this.bridge.studioMode)
|
|
84
|
+
void this.reboot();
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The page-side gate on a commit to the bound branch. The agent wrote the
|
|
89
|
+
* message; the player sees it and every file, and says yes here. Auto-declines
|
|
90
|
+
* after two minutes so a stale prompt cannot be accepted later.
|
|
91
|
+
*/
|
|
92
|
+
confirmCommit(summary) {
|
|
93
|
+
return new Promise((resolve) => {
|
|
94
|
+
this.message.hidden = false;
|
|
95
|
+
this.message.replaceChildren();
|
|
96
|
+
const text = el('span');
|
|
97
|
+
const count = summary.files.length + summary.deleted.length;
|
|
98
|
+
text.textContent = `The agent wants to commit ${count} file${count === 1 ? '' : 's'} of ${summary.projectName} to GitHub: "${summary.message}". `;
|
|
99
|
+
const list = el('ul', 'ck-crowdy-studio-dsh-commit-files');
|
|
100
|
+
for (const path of summary.files) {
|
|
101
|
+
const item = el('li');
|
|
102
|
+
item.textContent = path;
|
|
103
|
+
list.append(item);
|
|
104
|
+
}
|
|
105
|
+
for (const path of summary.deleted) {
|
|
106
|
+
const item = el('li');
|
|
107
|
+
item.textContent = `${path} (delete)`;
|
|
108
|
+
list.append(item);
|
|
109
|
+
}
|
|
110
|
+
const approve = el('button', 'ck-crowdy-studio-dsh-confirm');
|
|
111
|
+
approve.type = 'button';
|
|
112
|
+
approve.textContent = 'Commit';
|
|
113
|
+
const decline = el('button', 'ck-crowdy-studio-dsh-decline');
|
|
114
|
+
decline.type = 'button';
|
|
115
|
+
decline.textContent = 'Not now';
|
|
116
|
+
let settled = false;
|
|
117
|
+
const finish = (answer) => {
|
|
118
|
+
if (settled)
|
|
119
|
+
return;
|
|
120
|
+
settled = true;
|
|
121
|
+
clearTimeout(timer);
|
|
122
|
+
this.message.replaceChildren();
|
|
123
|
+
this.message.hidden = true;
|
|
124
|
+
resolve(answer);
|
|
125
|
+
};
|
|
126
|
+
const timer = setTimeout(() => finish(false), 120000);
|
|
127
|
+
approve.addEventListener('click', () => finish(true));
|
|
128
|
+
decline.addEventListener('click', () => finish(false));
|
|
129
|
+
this.message.append(text, list, approve, ' ', decline);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/** Restart the harness in the editor the open project needs. */
|
|
133
|
+
async reboot() {
|
|
134
|
+
this.rebooting = true;
|
|
135
|
+
try {
|
|
136
|
+
this.booted = false;
|
|
137
|
+
if (this.usageTimer)
|
|
138
|
+
clearInterval(this.usageTimer);
|
|
139
|
+
this.usageTimer = null;
|
|
140
|
+
this.bridge.detach();
|
|
141
|
+
this.frame.src = 'about:blank';
|
|
142
|
+
await this.boot();
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
this.renderStatus({ phase: 'failed', message: error instanceof Error ? error.message : String(error) });
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
this.rebooting = false;
|
|
149
|
+
}
|
|
73
150
|
}
|
|
74
151
|
/**
|
|
75
152
|
* The page-side gate on a deploy to the grid, live or a draft test (which deploys the mod to
|
|
@@ -133,13 +210,18 @@ export class CrowdyStudioDshPane {
|
|
|
133
210
|
this.disposed = true;
|
|
134
211
|
if (this.usageTimer)
|
|
135
212
|
clearInterval(this.usageTimer);
|
|
213
|
+
this.unsubscribeMode?.();
|
|
214
|
+
this.unsubscribeMode = null;
|
|
136
215
|
this.bridge.detach();
|
|
137
216
|
this.root.remove();
|
|
138
217
|
}
|
|
139
218
|
async boot() {
|
|
140
219
|
const base = this.options.webBase.endsWith('/') ? this.options.webBase : `${this.options.webBase}/`;
|
|
220
|
+
const attached = this.bridge.attach(this.frame);
|
|
141
221
|
this.frame.src = `${base}index.html`;
|
|
142
|
-
await
|
|
222
|
+
await attached;
|
|
223
|
+
this.booted = true;
|
|
224
|
+
this.root.dataset.mode = this.bridge.studioMode;
|
|
143
225
|
this.captureButton.disabled = !this.options.host?.captureFrame;
|
|
144
226
|
await this.refreshUsage();
|
|
145
227
|
this.usageTimer = setInterval(() => void this.refreshUsage(), USAGE_REFRESH_MS);
|
|
@@ -177,7 +259,8 @@ export class CrowdyStudioDshPane {
|
|
|
177
259
|
this.status.textContent = 'Starting…';
|
|
178
260
|
break;
|
|
179
261
|
case 'ready':
|
|
180
|
-
this.status.textContent =
|
|
262
|
+
this.status.textContent =
|
|
263
|
+
this.bridge.studioMode === 'game' ? 'Ready · game' : status.store ? 'Ready · GitHub' : 'Ready';
|
|
181
264
|
this.status.title = status.store ?? '';
|
|
182
265
|
break;
|
|
183
266
|
case 'failed':
|
|
@@ -248,4 +331,5 @@ export const CROWDY_STUDIO_DSH_STYLES = `
|
|
|
248
331
|
.ck-crowdy-studio-dsh-message{padding:4px 10px;font-size:11px;color:#fde68a;border-top:1px solid var(--ck-line)}
|
|
249
332
|
.ck-crowdy-studio-dsh-message button{font-size:11px;padding:2px 8px;margin-left:4px}
|
|
250
333
|
.ck-crowdy-studio-dsh-confirm{background:#b91c1c;color:#fff;border:0;border-radius:3px}
|
|
334
|
+
.ck-crowdy-studio-dsh-commit-files{margin:4px 0;padding-left:16px;max-height:120px;overflow:auto;color:var(--ck-text)}
|
|
251
335
|
`;
|