castle-web-cli 0.4.64 → 0.4.65
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/castle-host/host.d.ts +1 -0
- package/dist/castle-host/host.js +9 -4
- package/dist/config.js +5 -0
- package/dist/ide.js +46 -650
- package/dist/index.js +20 -5
- package/dist/save-deck.d.ts +7 -1
- package/dist/save-deck.js +19 -7
- package/dist/shell/assets/index-BN8WsJWO.js +106 -0
- package/dist/shell/assets/index-CwmQcHeX.css +1 -0
- package/dist/shell/index.html +13 -0
- package/kits/basic-2d/editors/CodeEditor.jsx +2 -1
- package/package.json +3 -2
- package/dist/buildArchive.d.ts +0 -1
- package/dist/buildArchive.js +0 -108
- package/dist/chat-client.d.ts +0 -1
- package/dist/chat-client.js +0 -538
- package/dist/ide-client.d.ts +0 -1
- package/dist/ide-client.js +0 -569
package/dist/index.js
CHANGED
|
@@ -9,7 +9,16 @@ import { init } from './init.js';
|
|
|
9
9
|
import { connectWS, savePreviewImage, savePreviewIfNeeded, takeScreenshot } from './preview.js';
|
|
10
10
|
const args = process.argv.slice(2);
|
|
11
11
|
const command = args[0];
|
|
12
|
-
const FLAGS_WITH_VALUES = new Set([
|
|
12
|
+
const FLAGS_WITH_VALUES = new Set([
|
|
13
|
+
'--port',
|
|
14
|
+
'--out',
|
|
15
|
+
'--host',
|
|
16
|
+
'--kit',
|
|
17
|
+
'--deck-id',
|
|
18
|
+
'--title',
|
|
19
|
+
'--caption',
|
|
20
|
+
'--visibility',
|
|
21
|
+
]);
|
|
13
22
|
function findPositionalDir() {
|
|
14
23
|
for (let i = 1; i < args.length; i++) {
|
|
15
24
|
if (args[i].startsWith('--')) {
|
|
@@ -53,7 +62,7 @@ function usage() {
|
|
|
53
62
|
castle-web restart [--port PORT]
|
|
54
63
|
castle-web screenshot [--out FILE] [--port PORT]
|
|
55
64
|
castle-web save-preview-image [dir] [--port PORT] [--no-restart]
|
|
56
|
-
castle-web save-deck [dir]
|
|
65
|
+
castle-web save-deck [dir] [--title TITLE] [--caption TEXT] [--visibility unlisted|private]
|
|
57
66
|
castle-web get-deck <dir> [--deck-id ID]
|
|
58
67
|
castle-web login
|
|
59
68
|
|
|
@@ -87,9 +96,15 @@ async function main() {
|
|
|
87
96
|
}
|
|
88
97
|
case 'save-deck': {
|
|
89
98
|
const dir = findPositionalDir();
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
99
|
+
const title = getFlagValue('--title');
|
|
100
|
+
const caption = getFlagValue('--caption');
|
|
101
|
+
const visibility = getFlagValue('--visibility');
|
|
102
|
+
await saveDeck(dir, { title, caption, visibility });
|
|
103
|
+
// --no-preview: skip the WS canvas capture (no browser tab in headless/cloud saves).
|
|
104
|
+
if (!args.includes('--no-preview')) {
|
|
105
|
+
const wsPort = getWsPort(dir);
|
|
106
|
+
await savePreviewIfNeeded(dir, wsPort);
|
|
107
|
+
}
|
|
93
108
|
break;
|
|
94
109
|
}
|
|
95
110
|
case 'get-deck': {
|
package/dist/save-deck.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
export declare function archiveSource(projectDir: string): Promise<Buffer>;
|
|
2
|
-
export
|
|
2
|
+
export type SaveVisibility = 'unlisted' | 'private';
|
|
3
|
+
export interface SaveDeckOptions {
|
|
4
|
+
title?: string;
|
|
5
|
+
caption?: string;
|
|
6
|
+
visibility?: SaveVisibility;
|
|
7
|
+
}
|
|
8
|
+
export declare function saveDeck(dir: string, opts?: SaveDeckOptions): Promise<void>;
|
package/dist/save-deck.js
CHANGED
|
@@ -85,11 +85,16 @@ function buildSceneData(bundle) {
|
|
|
85
85
|
},
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
-
export async function saveDeck(dir) {
|
|
88
|
+
export async function saveDeck(dir, opts = {}) {
|
|
89
89
|
if (!config.getToken()) {
|
|
90
90
|
console.error('Not logged in. Run `castle-web login` first.');
|
|
91
91
|
process.exit(1);
|
|
92
92
|
}
|
|
93
|
+
const visibility = opts.visibility ?? 'unlisted';
|
|
94
|
+
if (visibility !== 'unlisted' && visibility !== 'private') {
|
|
95
|
+
console.error(`Invalid visibility "${visibility}". Use unlisted or private.`);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
93
98
|
const projectDir = path.resolve(dir);
|
|
94
99
|
if (!fs.existsSync(path.join(projectDir, 'index.html'))) {
|
|
95
100
|
console.error(`No index.html found in ${projectDir}`);
|
|
@@ -128,17 +133,24 @@ export async function saveDeck(dir) {
|
|
|
128
133
|
if (s3Res.status >= 300) {
|
|
129
134
|
throw new Error(`Upload failed: HTTP ${s3Res.status}`);
|
|
130
135
|
}
|
|
131
|
-
|
|
132
|
-
const
|
|
136
|
+
const title = opts.title ?? castleJson?.title ?? path.basename(path.resolve(projectDir));
|
|
137
|
+
const deckInput = { deckId, title, visibility };
|
|
138
|
+
if (opts.caption !== undefined)
|
|
139
|
+
deckInput.caption = opts.caption;
|
|
133
140
|
try {
|
|
134
|
-
const result = await api.updateCardAndDeckV2(
|
|
141
|
+
const result = await api.updateCardAndDeckV2(deckInput, {
|
|
142
|
+
cardId,
|
|
143
|
+
blocks: [],
|
|
144
|
+
uploadId: uploadConfig.uploadId,
|
|
145
|
+
makeInitialCard: true,
|
|
146
|
+
});
|
|
147
|
+
const newCastleJson = { deckId: result.deckId, cardId: result.cardId, title };
|
|
148
|
+
fs.writeFileSync(path.join(projectDir, 'castle.json'), JSON.stringify(newCastleJson, null, 2) + '\n', 'utf-8');
|
|
135
149
|
if (isNew) {
|
|
136
|
-
const newCastleJson = { deckId: result.deckId, cardId: result.cardId };
|
|
137
|
-
fs.writeFileSync(path.join(projectDir, 'castle.json'), JSON.stringify(newCastleJson, null, 2) + '\n', 'utf-8');
|
|
138
150
|
console.log(`Created deck "${title}" (${result.deckId}). Saved castle.json.`);
|
|
139
151
|
}
|
|
140
152
|
else {
|
|
141
|
-
console.log(
|
|
153
|
+
console.log(`Saved "${title}" to Castle.`);
|
|
142
154
|
}
|
|
143
155
|
console.log('Uploading source archive...');
|
|
144
156
|
await uploadSource(projectDir, result.deckId);
|