@neta-art/cohub-cli 10.23.0 → 10.25.0
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 +18 -5
- package/bin/cohub.js +4 -1
- package/dist/board-gpu/page.js +1566 -71230
- package/dist/bootstrap.js +67 -27
- package/dist/build.json +1 -1
- package/dist/{board-kernel/FilterPipe.js → chunks/Geometry.js} +10447 -10469
- package/dist/chunks/about.js +102 -0
- package/dist/chunks/app-realtime.js +2216 -0
- package/dist/chunks/app-realtime2.js +2 -0
- package/dist/chunks/app-ref.js +88 -0
- package/dist/chunks/apps.js +1423 -0
- package/dist/chunks/auth.js +175 -0
- package/dist/chunks/avatar.js +146 -0
- package/dist/chunks/board-export-resources.js +232 -0
- package/dist/chunks/board-export.js +874 -0
- package/dist/chunks/board-export2.js +2 -0
- package/dist/{board-kernel.js → chunks/board-kernel.js} +18032 -28512
- package/dist/chunks/board-kernel2.js +4 -0
- package/dist/chunks/board-profile.js +69 -0
- package/dist/chunks/board-simulate.js +315 -0
- package/dist/chunks/board-time.js +34 -0
- package/dist/chunks/boards.js +1943 -0
- package/dist/{board-kernel → chunks}/browserAll.js +9 -8
- package/dist/chunks/channels.js +64 -0
- package/dist/chunks/client.js +12606 -0
- package/dist/chunks/command-input.js +17 -0
- package/dist/chunks/commander.js +2962 -0
- package/dist/chunks/cron-jobs.js +163 -0
- package/dist/chunks/daemon.js +545 -0
- package/dist/chunks/daemon2.js +2 -0
- package/dist/chunks/desktop.js +172 -0
- package/dist/chunks/endpoint-options.js +26 -0
- package/dist/chunks/env-proxy.js +35 -0
- package/dist/chunks/environment.js +154 -0
- package/dist/chunks/feedback.js +120 -0
- package/dist/chunks/generations.js +379 -0
- package/dist/chunks/host.js +9 -0
- package/dist/chunks/http-put.js +131 -0
- package/dist/chunks/id.js +2416 -0
- package/dist/{board-kernel → chunks}/init.js +1 -1
- package/dist/chunks/install.js +11959 -0
- package/dist/chunks/launch.js +374 -0
- package/dist/chunks/local-media.js +47 -0
- package/dist/chunks/me.js +134 -0
- package/dist/chunks/media.js +315 -0
- package/dist/chunks/models.js +242 -0
- package/dist/chunks/operands.js +46 -0
- package/dist/chunks/package-paths.js +13 -0
- package/dist/chunks/policy.js +221 -0
- package/dist/chunks/preferences.js +29 -0
- package/dist/chunks/profile.js +64 -0
- package/dist/chunks/prompts.js +41 -0
- package/dist/chunks/public.js +2 -0
- package/dist/chunks/public2.js +244 -0
- package/dist/chunks/references.js +197 -0
- package/dist/chunks/referrals.js +90 -0
- package/dist/chunks/rolldown-runtime.js +26 -0
- package/dist/chunks/rooms-connect.js +2 -0
- package/dist/chunks/rooms-connect2.js +151 -0
- package/dist/chunks/rooms-rtc.js +309 -0
- package/dist/chunks/rooms.js +211 -0
- package/dist/chunks/run.js +220 -0
- package/dist/chunks/runtime.js +638 -0
- package/dist/chunks/runtime2.js +286 -0
- package/dist/chunks/runtimes.js +48 -0
- package/dist/chunks/safe-remote-image.js +198 -0
- package/dist/chunks/schemas.js +6017 -0
- package/dist/chunks/search.js +113 -0
- package/dist/chunks/self-update.js +238 -0
- package/dist/chunks/serve.js +1246 -0
- package/dist/chunks/session-status.js +24 -0
- package/dist/chunks/skills.js +35 -0
- package/dist/chunks/spaces.js +5080 -0
- package/dist/chunks/src.js +405 -0
- package/dist/chunks/supervisor.js +2511 -0
- package/dist/chunks/supervisor2.js +2 -0
- package/dist/chunks/tasks.js +82 -0
- package/dist/chunks/themes.js +2898 -0
- package/dist/chunks/version.js +2 -0
- package/dist/chunks/version2.js +22 -0
- package/dist/chunks/version3.js +18 -0
- package/dist/chunks/web.js +7 -0
- package/dist/{board-kernel → chunks}/webworkerAll.js +1 -1
- package/dist/runtime/native/pi-extension.js +174 -166
- package/dist/runtime/worker.js +27 -16
- package/package.json +8 -9
- package/dist/about.d.ts +0 -2
- package/dist/about.js +0 -71
- package/dist/app-download.d.ts +0 -11
- package/dist/app-download.js +0 -252
- package/dist/app-ref.d.ts +0 -5
- package/dist/app-ref.js +0 -8
- package/dist/app-target.d.ts +0 -26
- package/dist/app-target.js +0 -55
- package/dist/auth.d.ts +0 -45
- package/dist/auth.js +0 -307
- package/dist/avatar.d.ts +0 -55
- package/dist/avatar.js +0 -104
- package/dist/board-command-support.d.ts +0 -6
- package/dist/board-command-support.js +0 -88
- package/dist/board-export-resources.d.ts +0 -12
- package/dist/board-export-resources.js +0 -51
- package/dist/board-export.d.ts +0 -110
- package/dist/board-export.js +0 -592
- package/dist/board-fonts.d.ts +0 -11
- package/dist/board-fonts.js +0 -10
- package/dist/board-gpu/daemon.d.ts +0 -11
- package/dist/board-gpu/daemon.js +0 -295
- package/dist/board-gpu/index.d.ts +0 -33
- package/dist/board-gpu/index.js +0 -189
- package/dist/board-gpu/protocol.d.ts +0 -77
- package/dist/board-gpu/protocol.js +0 -1
- package/dist/board-kernel.d.ts +0 -5
- package/dist/board-media-export.d.ts +0 -17
- package/dist/board-media-export.js +0 -164
- package/dist/board-media.d.ts +0 -5
- package/dist/board-media.js +0 -66
- package/dist/board-profile.d.ts +0 -21
- package/dist/board-profile.js +0 -67
- package/dist/board-simulate.d.ts +0 -67
- package/dist/board-simulate.js +0 -259
- package/dist/board-time.d.ts +0 -3
- package/dist/board-time.js +0 -34
- package/dist/bootstrap.d.ts +0 -2
- package/dist/client.d.ts +0 -5
- package/dist/client.js +0 -24
- package/dist/command-input.d.ts +0 -4
- package/dist/command-input.js +0 -16
- package/dist/commands/app-commerce.d.ts +0 -2
- package/dist/commands/app-commerce.js +0 -228
- package/dist/commands/app-domains.d.ts +0 -2
- package/dist/commands/app-domains.js +0 -133
- package/dist/commands/apps.d.ts +0 -4
- package/dist/commands/apps.js +0 -827
- package/dist/commands/auth.d.ts +0 -2
- package/dist/commands/auth.js +0 -186
- package/dist/commands/boards/authoring.d.ts +0 -2
- package/dist/commands/boards/authoring.js +0 -166
- package/dist/commands/boards/examples.d.ts +0 -10
- package/dist/commands/boards/examples.js +0 -118
- package/dist/commands/boards.d.ts +0 -13
- package/dist/commands/boards.js +0 -836
- package/dist/commands/channels.d.ts +0 -2
- package/dist/commands/channels.js +0 -74
- package/dist/commands/cron-jobs.d.ts +0 -2
- package/dist/commands/cron-jobs.js +0 -155
- package/dist/commands/decision.d.ts +0 -4
- package/dist/commands/decision.js +0 -113
- package/dist/commands/desktop.d.ts +0 -10
- package/dist/commands/desktop.js +0 -233
- package/dist/commands/feedback.d.ts +0 -2
- package/dist/commands/feedback.js +0 -131
- package/dist/commands/generations.d.ts +0 -2
- package/dist/commands/generations.js +0 -427
- package/dist/commands/host.d.ts +0 -2
- package/dist/commands/host.js +0 -11
- package/dist/commands/me.d.ts +0 -2
- package/dist/commands/me.js +0 -118
- package/dist/commands/models.d.ts +0 -28
- package/dist/commands/models.js +0 -271
- package/dist/commands/profile.d.ts +0 -2
- package/dist/commands/profile.js +0 -81
- package/dist/commands/prompts.d.ts +0 -2
- package/dist/commands/prompts.js +0 -37
- package/dist/commands/public.d.ts +0 -20
- package/dist/commands/public.js +0 -291
- package/dist/commands/references.d.ts +0 -2
- package/dist/commands/references.js +0 -193
- package/dist/commands/referrals.d.ts +0 -2
- package/dist/commands/referrals.js +0 -88
- package/dist/commands/rooms-connect.d.ts +0 -17
- package/dist/commands/rooms-connect.js +0 -140
- package/dist/commands/rooms-rtc-binary.d.ts +0 -2
- package/dist/commands/rooms-rtc-binary.js +0 -107
- package/dist/commands/rooms-rtc.d.ts +0 -21
- package/dist/commands/rooms-rtc.js +0 -171
- package/dist/commands/rooms.d.ts +0 -3
- package/dist/commands/rooms.js +0 -277
- package/dist/commands/run.d.ts +0 -13
- package/dist/commands/run.js +0 -246
- package/dist/commands/runtime.d.ts +0 -3
- package/dist/commands/runtime.js +0 -320
- package/dist/commands/sandboxd-binary.d.ts +0 -11
- package/dist/commands/sandboxd-binary.js +0 -238
- package/dist/commands/search.d.ts +0 -2
- package/dist/commands/search.js +0 -114
- package/dist/commands/session-access.d.ts +0 -2
- package/dist/commands/session-access.js +0 -70
- package/dist/commands/skills.d.ts +0 -2
- package/dist/commands/skills.js +0 -34
- package/dist/commands/space-activity.d.ts +0 -26
- package/dist/commands/space-activity.js +0 -147
- package/dist/commands/space-commerce.d.ts +0 -2
- package/dist/commands/space-commerce.js +0 -514
- package/dist/commands/space-displays.d.ts +0 -2
- package/dist/commands/space-displays.js +0 -620
- package/dist/commands/space-files.d.ts +0 -5
- package/dist/commands/space-files.js +0 -215
- package/dist/commands/space-invitations.d.ts +0 -29
- package/dist/commands/space-invitations.js +0 -189
- package/dist/commands/space-turns.d.ts +0 -49
- package/dist/commands/space-turns.js +0 -205
- package/dist/commands/space-wallet.d.ts +0 -2
- package/dist/commands/space-wallet.js +0 -64
- package/dist/commands/space-webhooks.d.ts +0 -7
- package/dist/commands/space-webhooks.js +0 -73
- package/dist/commands/spaces.d.ts +0 -25
- package/dist/commands/spaces.js +0 -2139
- package/dist/commands/tasks.d.ts +0 -8
- package/dist/commands/tasks.js +0 -80
- package/dist/commands/version.d.ts +0 -2
- package/dist/commands/version.js +0 -21
- package/dist/endpoint-options.d.ts +0 -4
- package/dist/endpoint-options.js +0 -26
- package/dist/env-proxy.d.ts +0 -5
- package/dist/env-proxy.js +0 -20
- package/dist/help-path.d.ts +0 -18
- package/dist/help-path.js +0 -223
- package/dist/host/auth.d.ts +0 -20
- package/dist/host/auth.js +0 -119
- package/dist/host/login-env.d.ts +0 -1
- package/dist/host/login-env.js +0 -31
- package/dist/host/runtime.d.ts +0 -35
- package/dist/host/runtime.js +0 -395
- package/dist/host/runtimes.d.ts +0 -9
- package/dist/host/runtimes.js +0 -42
- package/dist/host/serve.d.ts +0 -2
- package/dist/host/serve.js +0 -117
- package/dist/host/workspaces.d.ts +0 -2
- package/dist/host/workspaces.js +0 -18
- package/dist/http-put.d.ts +0 -25
- package/dist/http-put.js +0 -132
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -129
- package/dist/launcher.d.ts +0 -4
- package/dist/launcher.js +0 -38
- package/dist/local-media.d.ts +0 -2
- package/dist/local-media.js +0 -30
- package/dist/network-error.d.ts +0 -3
- package/dist/network-error.js +0 -22
- package/dist/output.d.ts +0 -46
- package/dist/output.js +0 -244
- package/dist/runtime/archive-store.d.ts +0 -54
- package/dist/runtime/archive-store.js +0 -379
- package/dist/runtime/cli-path.d.ts +0 -5
- package/dist/runtime/cli-path.js +0 -27
- package/dist/runtime/codex-usage.d.ts +0 -7
- package/dist/runtime/codex-usage.js +0 -11
- package/dist/runtime/connection.d.ts +0 -42
- package/dist/runtime/connection.js +0 -789
- package/dist/runtime/diagnostics.d.ts +0 -107
- package/dist/runtime/diagnostics.js +0 -392
- package/dist/runtime/harnesses/chained-projection.d.ts +0 -40
- package/dist/runtime/harnesses/chained-projection.js +0 -95
- package/dist/runtime/harnesses/chained-transcript.d.ts +0 -24
- package/dist/runtime/harnesses/chained-transcript.js +0 -62
- package/dist/runtime/harnesses/claude-approval.d.ts +0 -34
- package/dist/runtime/harnesses/claude-approval.js +0 -124
- package/dist/runtime/harnesses/claude-transcript.d.ts +0 -8
- package/dist/runtime/harnesses/claude-transcript.js +0 -138
- package/dist/runtime/harnesses/claude.d.ts +0 -8
- package/dist/runtime/harnesses/claude.js +0 -225
- package/dist/runtime/harnesses/codex-approval.d.ts +0 -25
- package/dist/runtime/harnesses/codex-approval.js +0 -69
- package/dist/runtime/harnesses/codex.d.ts +0 -4
- package/dist/runtime/harnesses/codex.js +0 -269
- package/dist/runtime/harnesses/cursor-transcript.d.ts +0 -37
- package/dist/runtime/harnesses/cursor-transcript.js +0 -183
- package/dist/runtime/harnesses/cursor.d.ts +0 -24
- package/dist/runtime/harnesses/cursor.js +0 -620
- package/dist/runtime/harnesses/index.d.ts +0 -16
- package/dist/runtime/harnesses/index.js +0 -73
- package/dist/runtime/harnesses/pi.d.ts +0 -4
- package/dist/runtime/harnesses/pi.js +0 -247
- package/dist/runtime/harnesses/process.d.ts +0 -31
- package/dist/runtime/harnesses/process.js +0 -75
- package/dist/runtime/harnesses/stream-json.d.ts +0 -48
- package/dist/runtime/harnesses/stream-json.js +0 -336
- package/dist/runtime/harnesses/types.d.ts +0 -117
- package/dist/runtime/harnesses/types.js +0 -1
- package/dist/runtime/harnesses/workbuddy-transcript.d.ts +0 -8
- package/dist/runtime/harnesses/workbuddy-transcript.js +0 -127
- package/dist/runtime/harnesses/workbuddy.d.ts +0 -21
- package/dist/runtime/harnesses/workbuddy.js +0 -123
- package/dist/runtime/instance.d.ts +0 -20
- package/dist/runtime/instance.js +0 -247
- package/dist/runtime/json-rpc.d.ts +0 -53
- package/dist/runtime/json-rpc.js +0 -212
- package/dist/runtime/launch.d.ts +0 -25
- package/dist/runtime/launch.js +0 -247
- package/dist/runtime/local-workspace.d.ts +0 -15
- package/dist/runtime/local-workspace.js +0 -52
- package/dist/runtime/model-catalog.d.ts +0 -12
- package/dist/runtime/model-catalog.js +0 -84
- package/dist/runtime/native/adapters.d.ts +0 -15
- package/dist/runtime/native/adapters.js +0 -11
- package/dist/runtime/native/approvals.d.ts +0 -18
- package/dist/runtime/native/approvals.js +0 -54
- package/dist/runtime/native/archive.d.ts +0 -19
- package/dist/runtime/native/archive.js +0 -142
- package/dist/runtime/native/attach.d.ts +0 -36
- package/dist/runtime/native/attach.js +0 -128
- package/dist/runtime/native/codex-link.d.ts +0 -60
- package/dist/runtime/native/codex-link.js +0 -322
- package/dist/runtime/native/config.d.ts +0 -16
- package/dist/runtime/native/config.js +0 -24
- package/dist/runtime/native/daemon.d.ts +0 -92
- package/dist/runtime/native/daemon.js +0 -380
- package/dist/runtime/native/execution.d.ts +0 -26
- package/dist/runtime/native/execution.js +0 -34
- package/dist/runtime/native/identity.d.ts +0 -9
- package/dist/runtime/native/identity.js +0 -15
- package/dist/runtime/native/ingest.d.ts +0 -263
- package/dist/runtime/native/ingest.js +0 -884
- package/dist/runtime/native/install.d.ts +0 -9
- package/dist/runtime/native/install.js +0 -113
- package/dist/runtime/native/paths.d.ts +0 -2
- package/dist/runtime/native/paths.js +0 -7
- package/dist/runtime/native/pi-extension.d.ts +0 -36
- package/dist/runtime/native/pi-link.d.ts +0 -69
- package/dist/runtime/native/pi-link.js +0 -269
- package/dist/runtime/native/results.d.ts +0 -41
- package/dist/runtime/native/results.js +0 -128
- package/dist/runtime/native/sessions.d.ts +0 -45
- package/dist/runtime/native/sessions.js +0 -87
- package/dist/runtime/native/transcript.d.ts +0 -89
- package/dist/runtime/native/transcript.js +0 -656
- package/dist/runtime/native/translate.d.ts +0 -46
- package/dist/runtime/native/translate.js +0 -299
- package/dist/runtime/native/transport.d.ts +0 -7
- package/dist/runtime/native/transport.js +0 -16
- package/dist/runtime/native/version.d.ts +0 -5
- package/dist/runtime/native/version.js +0 -21
- package/dist/runtime/preferences.d.ts +0 -7
- package/dist/runtime/preferences.js +0 -22
- package/dist/runtime/presentation.d.ts +0 -32
- package/dist/runtime/presentation.js +0 -124
- package/dist/runtime/process-group.d.ts +0 -5
- package/dist/runtime/process-group.js +0 -161
- package/dist/runtime/projection-store.d.ts +0 -27
- package/dist/runtime/projection-store.js +0 -30
- package/dist/runtime/space-binding.d.ts +0 -48
- package/dist/runtime/space-binding.js +0 -342
- package/dist/runtime/supervisor.d.ts +0 -19
- package/dist/runtime/supervisor.js +0 -441
- package/dist/runtime/turn-projection.d.ts +0 -41
- package/dist/runtime/turn-projection.js +0 -120
- package/dist/runtime/worker.d.ts +0 -1
- package/dist/safe-remote-image.d.ts +0 -36
- package/dist/safe-remote-image.js +0 -191
- package/dist/self-update.d.ts +0 -7
- package/dist/self-update.js +0 -202
- package/dist/session-status.d.ts +0 -6
- package/dist/session-status.js +0 -16
- package/dist/space-files/limit.d.ts +0 -2
- package/dist/space-files/limit.js +0 -16
- package/dist/space-files/operands.d.ts +0 -17
- package/dist/space-files/operands.js +0 -33
- package/dist/space-files/transfer.d.ts +0 -53
- package/dist/space-files/transfer.js +0 -297
- package/dist/space-files/upload.d.ts +0 -17
- package/dist/space-files/upload.js +0 -76
- package/dist/space.d.ts +0 -44
- package/dist/space.js +0 -192
- package/dist/version.d.ts +0 -2
- package/dist/version.js +0 -17
- package/dist/web.d.ts +0 -1
- package/dist/web.js +0 -4
- /package/dist/{board-kernel → chunks}/lexer.js +0 -0
package/dist/commands/auth.d.ts
DELETED
package/dist/commands/auth.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { authSource, loginWithDeviceFlow, readAuthSession, refreshAccessToken, requestDeviceCode, requireAccessToken, revokeAndClearAuthSession, verifyDeviceCode } from "../auth.js";
|
|
2
|
-
import { clearHomeSpaceCache } from "../space.js";
|
|
3
|
-
import { createClient } from "../client.js";
|
|
4
|
-
import { table, json as outJson, jsonRequested, ok, error, spinner, handleHttp } from "../output.js";
|
|
5
|
-
export function registerAuth(program) {
|
|
6
|
-
const auth = program.command("auth").description("Authentication management");
|
|
7
|
-
auth
|
|
8
|
-
.command("login")
|
|
9
|
-
.description("Sign in with Logto device authorization")
|
|
10
|
-
.option("--request-code", "Request a device code without polling")
|
|
11
|
-
.option("--verify-code", "Exchange a previously requested device code")
|
|
12
|
-
.option("--json", "Output as JSON")
|
|
13
|
-
.action(async (opts) => {
|
|
14
|
-
const asJson = jsonRequested(opts);
|
|
15
|
-
if (opts.requestCode && opts.verifyCode) {
|
|
16
|
-
return error("Conflicting options", "Use only one of --request-code or --verify-code");
|
|
17
|
-
}
|
|
18
|
-
try {
|
|
19
|
-
if (opts.requestCode) {
|
|
20
|
-
const code = await requestDeviceCode();
|
|
21
|
-
if (asJson)
|
|
22
|
-
return outJson(code);
|
|
23
|
-
printDeviceCode(code);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
if (opts.verifyCode) {
|
|
27
|
-
await verifyDeviceCode();
|
|
28
|
-
return showSignedIn(asJson);
|
|
29
|
-
}
|
|
30
|
-
const sp = spinner();
|
|
31
|
-
sp.start("Starting login");
|
|
32
|
-
await loginWithDeviceFlow((code) => {
|
|
33
|
-
sp.stop("Login started");
|
|
34
|
-
printDeviceCode(code);
|
|
35
|
-
process.stderr.write(" Waiting for authorization...\n");
|
|
36
|
-
});
|
|
37
|
-
return showSignedIn(asJson);
|
|
38
|
-
}
|
|
39
|
-
catch (e) {
|
|
40
|
-
handleHttp(e);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
auth
|
|
44
|
-
.command("whoami")
|
|
45
|
-
.description("Show current user info")
|
|
46
|
-
.option("--json", "Output as JSON")
|
|
47
|
-
.action(async (opts) => {
|
|
48
|
-
const asJson = jsonRequested(opts);
|
|
49
|
-
return showSignedIn(asJson);
|
|
50
|
-
});
|
|
51
|
-
auth
|
|
52
|
-
.command("token")
|
|
53
|
-
.description("Print a valid access token, refreshing it when needed")
|
|
54
|
-
.action(async () => {
|
|
55
|
-
try {
|
|
56
|
-
process.stdout.write(`${await requireAccessToken()}\n`);
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
handleHttp(e);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
auth
|
|
63
|
-
.command("refresh")
|
|
64
|
-
.description("Refresh the stored Logto access token")
|
|
65
|
-
.action(async () => {
|
|
66
|
-
try {
|
|
67
|
-
if (authSource() === "execution-token") {
|
|
68
|
-
return error("Cannot refresh COHUB_EXECUTION_TOKEN", "Run `cohub auth login` for long-lived Logto auth.");
|
|
69
|
-
}
|
|
70
|
-
await refreshAccessToken();
|
|
71
|
-
ok("Token refreshed");
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
74
|
-
handleHttp(e);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
auth
|
|
78
|
-
.command("logout")
|
|
79
|
-
.description("Clear stored Logto session")
|
|
80
|
-
.action(async () => {
|
|
81
|
-
await revokeAndClearAuthSession();
|
|
82
|
-
clearHomeSpaceCache();
|
|
83
|
-
if (process.env.COHUB_EXECUTION_TOKEN?.trim()) {
|
|
84
|
-
ok("Local session cleared. COHUB_EXECUTION_TOKEN is still set.");
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
ok("Signed out");
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
async function showSignedIn(asJson) {
|
|
92
|
-
const source = authSource();
|
|
93
|
-
if (!source)
|
|
94
|
-
return error("Not authenticated", "Run `cohub auth login`.");
|
|
95
|
-
const client = createClient();
|
|
96
|
-
const sp = asJson ? null : spinner();
|
|
97
|
-
sp?.start("Fetching user info");
|
|
98
|
-
try {
|
|
99
|
-
const user = await client.user.getMe();
|
|
100
|
-
sp?.stop("Done");
|
|
101
|
-
const session = readAuthSession();
|
|
102
|
-
const payload = {
|
|
103
|
-
source,
|
|
104
|
-
refreshable: source === "logto" && Boolean(session?.refreshToken),
|
|
105
|
-
user,
|
|
106
|
-
};
|
|
107
|
-
if (asJson)
|
|
108
|
-
return outJson(payload);
|
|
109
|
-
const u = flattenMeForTable(user);
|
|
110
|
-
console.log(` Auth source: ${source}`);
|
|
111
|
-
console.log(` Token: ${payload.refreshable ? "refreshable" : "ephemeral"}\n`);
|
|
112
|
-
table([u], [
|
|
113
|
-
{ key: "uuid", label: "UUID" },
|
|
114
|
-
{ key: "username", label: "Username" },
|
|
115
|
-
{ key: "displayName", label: "Name" },
|
|
116
|
-
{ key: "email", label: "Email" },
|
|
117
|
-
]);
|
|
118
|
-
}
|
|
119
|
-
catch (e) {
|
|
120
|
-
if (source === "execution-token") {
|
|
121
|
-
sp?.stop("Using local execution token");
|
|
122
|
-
return showExecutionTokenFallback(asJson);
|
|
123
|
-
}
|
|
124
|
-
sp?.stop("Failed");
|
|
125
|
-
handleHttp(e);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function flattenMeForTable(user) {
|
|
129
|
-
const profile = user.profile && typeof user.profile === "object" ? user.profile : {};
|
|
130
|
-
return {
|
|
131
|
-
uuid: user.uuid,
|
|
132
|
-
username: profile.username,
|
|
133
|
-
displayName: profile.displayName,
|
|
134
|
-
email: user.email,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
function decodeExecutionTokenPayload() {
|
|
138
|
-
const token = process.env.COHUB_EXECUTION_TOKEN?.trim();
|
|
139
|
-
const payload = token?.split(".")[1];
|
|
140
|
-
if (!payload)
|
|
141
|
-
return null;
|
|
142
|
-
try {
|
|
143
|
-
const decoded = Buffer.from(payload, "base64url").toString("utf-8");
|
|
144
|
-
const parsed = JSON.parse(decoded);
|
|
145
|
-
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
146
|
-
}
|
|
147
|
-
catch {
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
function showExecutionTokenFallback(asJson) {
|
|
152
|
-
const payload = decodeExecutionTokenPayload();
|
|
153
|
-
const execution = {
|
|
154
|
-
actorUserId: typeof payload?.actorUserId === "string" ? payload.actorUserId : null,
|
|
155
|
-
spaceId: typeof payload?.spaceId === "string" ? payload.spaceId : null,
|
|
156
|
-
sessionId: typeof payload?.sessionId === "string" ? payload.sessionId : null,
|
|
157
|
-
source: typeof payload?.source === "string" ? payload.source : null,
|
|
158
|
-
expiresAt: typeof payload?.exp === "number" ? new Date(payload.exp * 1000).toISOString() : null,
|
|
159
|
-
};
|
|
160
|
-
const result = {
|
|
161
|
-
source: "execution-token",
|
|
162
|
-
refreshable: false,
|
|
163
|
-
user: execution.actorUserId ? { uuid: execution.actorUserId } : null,
|
|
164
|
-
execution,
|
|
165
|
-
};
|
|
166
|
-
if (asJson) {
|
|
167
|
-
outJson(result);
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
console.log(" Auth source: execution-token");
|
|
171
|
-
console.log(" Token: ephemeral\n");
|
|
172
|
-
table([execution], [
|
|
173
|
-
{ key: "actorUserId", label: "Actor" },
|
|
174
|
-
{ key: "spaceId", label: "Space" },
|
|
175
|
-
{ key: "sessionId", label: "Session" },
|
|
176
|
-
{ key: "source", label: "Source" },
|
|
177
|
-
{ key: "expiresAt", label: "Expires" },
|
|
178
|
-
]);
|
|
179
|
-
}
|
|
180
|
-
function printDeviceCode(code) {
|
|
181
|
-
console.log("\nOpen this URL to sign in:\n");
|
|
182
|
-
console.log(` ${code.verificationUriComplete}\n`);
|
|
183
|
-
console.log("Or enter this code manually:\n");
|
|
184
|
-
console.log(` ${code.userCode}\n`);
|
|
185
|
-
console.log(`Code expires at ${new Date(code.expiresAt).toLocaleString()}.`);
|
|
186
|
-
}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { readBoardJsonObject } from "../../board-command-support.js";
|
|
2
|
-
import { loadBoardDocument, resolveBundledFonts } from "../../board-export.js";
|
|
3
|
-
import { settleBoardDocument, settleBoardMediaDurations } from "../../board-media.js";
|
|
4
|
-
import { boardFrameRegions, boardPathTrack, boardPlacePatch, boardRegionStep, boardSequencePatch, buildBoardScene, createBoardAnimationSampler, createNodeBoardRenderer, inspectBoardItems, } from "../../board-kernel.js";
|
|
5
|
-
import { parseBoardTime, parseBoardTimes } from "../../board-time.js";
|
|
6
|
-
import { handleHttp, json as outJson, jsonRequested, table } from "../../output.js";
|
|
7
|
-
import { resolveSpace } from "../../space.js";
|
|
8
|
-
const DIRECTIONS = ["left", "right", "up", "down"];
|
|
9
|
-
export function registerBoardAuthoringCommands(boards) {
|
|
10
|
-
boards
|
|
11
|
-
.command("inspect <board>")
|
|
12
|
-
.description("Measure items and report visible layout hints without changing the Board")
|
|
13
|
-
.option("--animation <id>", "Animation to sample")
|
|
14
|
-
.option("--at <times>", "Time, comma-separated times, or start:end:step (up to 100 samples)", "0")
|
|
15
|
-
.option("--items <ids>", "Limit measurements to comma-separated item ids")
|
|
16
|
-
.option("--json", "Output as JSON")
|
|
17
|
-
.addHelpText("after", `
|
|
18
|
-
Without --animation, inspects the static document, not playback.
|
|
19
|
-
Bounds use world units with x/y at the top left; worldBounds includes rotation.
|
|
20
|
-
Checks native layout only, not camera cropping or content drawn inside scripts.
|
|
21
|
-
Example: cohub boards inspect lesson.board --animation lecture --at 0:20s:1s --json`)
|
|
22
|
-
.action(async (target, options) => {
|
|
23
|
-
try {
|
|
24
|
-
const spaceId = await resolveSpace(boards);
|
|
25
|
-
const document = await settleBoardDocument(spaceId, (await loadBoardDocument(spaceId, target)).document);
|
|
26
|
-
const times = parseBoardTimes(options.at, "--at", 100);
|
|
27
|
-
const sampler = options.animation ? createBoardAnimationSampler(document, options.animation) : null;
|
|
28
|
-
const renderer = await createNodeBoardRenderer({ fonts: resolveBundledFonts() });
|
|
29
|
-
try {
|
|
30
|
-
const ids = options.items ? new Set(options.items.split(",")) : null;
|
|
31
|
-
outJson({
|
|
32
|
-
mode: sampler ? "animation" : "static",
|
|
33
|
-
animation: options.animation ?? null,
|
|
34
|
-
coverage: "Native layout in world coordinates; excludes camera cropping and script-drawn content.",
|
|
35
|
-
samples: times.map((time) => ({
|
|
36
|
-
time,
|
|
37
|
-
...inspectBoardItems(sampler?.at(time).scene ?? buildBoardScene(document), ids ?? undefined),
|
|
38
|
-
})),
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
finally {
|
|
42
|
-
renderer.destroy();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
catch (cause) {
|
|
46
|
-
handleHttp(cause);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
boards
|
|
50
|
-
.command("frames <board>")
|
|
51
|
-
.description("List the frames viewers step through, in order, and where each arrow leads")
|
|
52
|
-
.option("--json", "Output as JSON")
|
|
53
|
-
.addHelpText("after", `
|
|
54
|
-
Order follows placement: rows top to bottom, each left to right. Move a frame to
|
|
55
|
-
change where it falls. A plain (decoration: none) frame with a label is a page;
|
|
56
|
-
without one, the frames inside it count. Frames inside pages do not. Left and right continue in reading order past a row's end.
|
|
57
|
-
Viewers step with N, the arrow keys and swipes; #focus=<frame>&present presents.`)
|
|
58
|
-
.action(async (target, options) => {
|
|
59
|
-
try {
|
|
60
|
-
const { document } = await loadBoardDocument(await resolveSpace(boards), target);
|
|
61
|
-
const regions = boardFrameRegions(buildBoardScene(document));
|
|
62
|
-
const frames = regions.map((region, index) => ({
|
|
63
|
-
index: index + 1,
|
|
64
|
-
id: region.id,
|
|
65
|
-
label: region.label ?? null,
|
|
66
|
-
rect: region.rect,
|
|
67
|
-
...Object.fromEntries(DIRECTIONS.map((direction) => [direction, boardRegionStep(regions, region, direction)?.id ?? null])),
|
|
68
|
-
}));
|
|
69
|
-
if (jsonRequested(options))
|
|
70
|
-
return outJson({ frames });
|
|
71
|
-
table(frames, [
|
|
72
|
-
{ key: "index", label: "#" },
|
|
73
|
-
{ key: "id", label: "ID" },
|
|
74
|
-
{ key: "label", label: "Label", format: (value) => value ?? "" },
|
|
75
|
-
...DIRECTIONS.map((direction) => ({ key: direction, label: direction[0]?.toUpperCase() + direction.slice(1), format: (value) => value ?? "–" })),
|
|
76
|
-
]);
|
|
77
|
-
}
|
|
78
|
-
catch (cause) {
|
|
79
|
-
handleHttp(cause);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
boards
|
|
83
|
-
.command("sequence <board>")
|
|
84
|
-
.description("Compile chapters to an apply-ready animation patch; does not write")
|
|
85
|
-
.requiredOption("-i, --input <file>", "JSON with a chapters array; use - for stdin")
|
|
86
|
-
.requiredOption("--animation <id>", "Parent animation id; recompiling replaces its tracks")
|
|
87
|
-
.action(async (target, options) => {
|
|
88
|
-
try {
|
|
89
|
-
const input = await readBoardJsonObject(options.input);
|
|
90
|
-
if (!Array.isArray(input.chapters) ||
|
|
91
|
-
input.chapters.some((chapter) => !chapter || typeof chapter !== "object" || typeof chapter.animation !== "string"))
|
|
92
|
-
throw new Error("Input needs a chapters array with animation IDs.");
|
|
93
|
-
const { document } = await loadBoardDocument(await resolveSpace(boards), target);
|
|
94
|
-
outJson(boardSequencePatch(document, options.animation, input.chapters));
|
|
95
|
-
}
|
|
96
|
-
catch (cause) {
|
|
97
|
-
handleHttp(cause);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
boards
|
|
101
|
-
.command("place <board>")
|
|
102
|
-
.description("Put items or animations on a timeline as clips; prints a patch for apply, does not write")
|
|
103
|
-
.requiredOption("--animation <id>", "Animation to place them in; created when missing")
|
|
104
|
-
.requiredOption("--targets <ids>", "Comma-separated item or animation ids, laid end to end")
|
|
105
|
-
.option("--at <time>", "Where the first one starts", "0")
|
|
106
|
-
.option("--duration <time>", "Length of each; defaults to what is left of the media or animation, else 3s")
|
|
107
|
-
.option("--from <time>", "Where media or an animation starts playing in its own time", "0")
|
|
108
|
-
.option("--rate <number>", "Playback speed of media and animations", "1")
|
|
109
|
-
.option("--together", "Start them all at --at instead of one after another")
|
|
110
|
-
.addHelpText("after", `
|
|
111
|
-
Each target is shown only during its clip (a visible track); video, audio and
|
|
112
|
-
animations also play (a props.time or time track), and sound in exports while
|
|
113
|
-
their time moves forward. Placing a target that is already on the timeline moves it.
|
|
114
|
-
cohub boards place cut.board --animation cut --targets intro,talk,outro | cohub boards apply cut.board -i -
|
|
115
|
-
cohub boards place cut.board --animation cut --targets music --at 0 --duration 30s --from 12s`)
|
|
116
|
-
.action(async (target, options) => {
|
|
117
|
-
try {
|
|
118
|
-
const targets = options.targets.split(",").map((id) => id.trim()).filter(Boolean);
|
|
119
|
-
if (!targets.length)
|
|
120
|
-
throw new Error("--targets needs at least one id.");
|
|
121
|
-
const rate = Number(options.rate);
|
|
122
|
-
if (!Number.isFinite(rate) || rate <= 0)
|
|
123
|
-
throw new Error("--rate must be a positive number.");
|
|
124
|
-
const spaceId = await resolveSpace(boards);
|
|
125
|
-
const { document: loaded } = await loadBoardDocument(spaceId, target);
|
|
126
|
-
const durations = options.duration ? {} : await settleBoardMediaDurations(spaceId, loaded, targets);
|
|
127
|
-
const document = { ...loaded, items: { ...loaded.items, ...durations } };
|
|
128
|
-
const patch = boardPlacePatch(document, options.animation, targets, {
|
|
129
|
-
at: parseBoardTime(options.at, "--at"),
|
|
130
|
-
from: parseBoardTime(options.from, "--from"),
|
|
131
|
-
rate,
|
|
132
|
-
...(options.duration ? { duration: parseBoardTime(options.duration, "--duration") } : {}),
|
|
133
|
-
together: options.together,
|
|
134
|
-
});
|
|
135
|
-
const items = Object.fromEntries(Object.entries(durations).map(([id, item]) => [id, { props: { snapshot: { durationMs: item.props.snapshot?.durationMs } } }]));
|
|
136
|
-
outJson(Object.keys(items).length ? { ...patch, items } : patch);
|
|
137
|
-
}
|
|
138
|
-
catch (cause) {
|
|
139
|
-
handleHttp(cause);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
boards
|
|
143
|
-
.command("path <target>")
|
|
144
|
-
.description("Sample a polyline into a position track; does not write")
|
|
145
|
-
.requiredOption("-i, --input <file>", "JSON with points, duration (ms), optional at, samples and orient")
|
|
146
|
-
.action(async (target, options) => {
|
|
147
|
-
try {
|
|
148
|
-
const input = await readBoardJsonObject(options.input);
|
|
149
|
-
if (!Array.isArray(input.points) || input.points.some((point) => !point || typeof point !== "object"))
|
|
150
|
-
throw new Error("Input needs a points array.");
|
|
151
|
-
if (typeof input.duration !== "number")
|
|
152
|
-
throw new Error("Input needs duration in milliseconds.");
|
|
153
|
-
if (input.orient !== undefined && typeof input.orient !== "boolean")
|
|
154
|
-
throw new Error("orient must be boolean.");
|
|
155
|
-
outJson(boardPathTrack(target, input.points, {
|
|
156
|
-
duration: input.duration,
|
|
157
|
-
...(input.at === undefined ? {} : { at: Number(input.at) }),
|
|
158
|
-
...(input.samples === undefined ? {} : { samples: Number(input.samples) }),
|
|
159
|
-
orient: input.orient,
|
|
160
|
-
}));
|
|
161
|
-
}
|
|
162
|
-
catch (cause) {
|
|
163
|
-
handleHttp(cause);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Command } from "commander";
|
|
2
|
-
/**
|
|
3
|
-
* Starter documents for `boards create -i` and patches for `boards apply -i`.
|
|
4
|
-
* Every example is a valid Board patch; `boards.test.ts` checks that.
|
|
5
|
-
*/
|
|
6
|
-
export declare const BOARD_EXAMPLES: Record<string, {
|
|
7
|
-
description: string;
|
|
8
|
-
value: Record<string, unknown>;
|
|
9
|
-
}>;
|
|
10
|
-
export declare function registerBoardExampleCommands(boards: Command): void;
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { json } from "../../output.js";
|
|
2
|
-
import { BOARD_SCRIPT_DRAWING_EXAMPLE, BOARD_SCRIPT_RAIN_EXAMPLE } from "../../board-kernel.js";
|
|
3
|
-
const MODULES = {
|
|
4
|
-
custom: BOARD_SCRIPT_DRAWING_EXAMPLE,
|
|
5
|
-
rain: BOARD_SCRIPT_RAIN_EXAMPLE,
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Starter documents for `boards create -i` and patches for `boards apply -i`.
|
|
9
|
-
* Every example is a valid Board patch; `boards.test.ts` checks that.
|
|
10
|
-
*/
|
|
11
|
-
export const BOARD_EXAMPLES = {
|
|
12
|
-
basic: {
|
|
13
|
-
description: "A title, a note and a shape.",
|
|
14
|
-
value: {
|
|
15
|
-
board: { title: "Launch plan" },
|
|
16
|
-
items: {
|
|
17
|
-
title: { type: "text", position: { x: 80, y: 60 }, props: { text: "Launch plan", fontSize: 40, fontWeight: 700 } },
|
|
18
|
-
note: { type: "text", position: { x: 80, y: 128 }, props: { text: "Ship the beta to ten design partners, then widen.", width: 420 } },
|
|
19
|
-
goal: { type: "shape", position: { x: 600, y: 60 }, size: { width: 200, height: 140 }, style: { stroke: "green", fill: "green", fillOpacity: 0.12, radius: 16 }, props: { text: "Beta in March" } },
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
workflow: {
|
|
24
|
-
description: "Steps joined by bound arrows with relations.",
|
|
25
|
-
value: {
|
|
26
|
-
items: {
|
|
27
|
-
request: { type: "shape", position: { x: 80, y: 160 }, size: { width: 200, height: 110 }, style: { stroke: "brand" }, props: { geometry: "rounded", text: "Request" } },
|
|
28
|
-
agent: { type: "shape", position: { x: 400, y: 160 }, size: { width: 200, height: 110 }, style: { stroke: "blue", fill: "blue", fillOpacity: 0.08 }, props: { geometry: "rounded", text: "Agent" } },
|
|
29
|
-
result: { type: "shape", position: { x: 720, y: 160 }, size: { width: 200, height: 110 }, style: { stroke: "green", fill: "green", fillOpacity: 0.08 }, props: { geometry: "rounded", text: "Result" } },
|
|
30
|
-
"request-agent": { type: "arrow", props: { start: { item: "request" }, end: { item: "agent" }, relation: "triggers", label: "invoke" } },
|
|
31
|
-
"agent-result": { type: "arrow", props: { start: { item: "agent" }, end: { item: "result" }, relation: "produces", label: "output" } },
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
slides: {
|
|
36
|
-
description: "960×540 frames as slides; children move and clip with their frame.",
|
|
37
|
-
value: {
|
|
38
|
-
items: {
|
|
39
|
-
s1: { type: "frame", position: { x: 0, y: 0 }, size: { width: 960, height: 540 }, props: { label: "Intro" } },
|
|
40
|
-
"s1-title": { type: "text", parent: "s1", position: { x: 72, y: 72 }, props: { text: "Special relativity", fontSize: 56, fontWeight: 700 } },
|
|
41
|
-
"s1-sub": { type: "text", parent: "s1", position: { x: 72, y: 160 }, props: { text: "Nothing outruns light" } },
|
|
42
|
-
s2: { type: "frame", position: { x: 1080, y: 0 }, size: { width: 960, height: 540 }, props: { label: "Time dilation" } },
|
|
43
|
-
"s2-title": { type: "text", parent: "s2", position: { x: 72, y: 72 }, props: { text: "Moving clocks run slow", fontSize: 40, fontWeight: 700 } },
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
lesson: {
|
|
48
|
-
description: "An animated lesson: entrances, a drawn arrow, typed text and camera moves with pause markers.",
|
|
49
|
-
value: {
|
|
50
|
-
items: {
|
|
51
|
-
s1: { type: "frame", size: { width: 960, height: 540 }, props: { label: "Length contraction" } },
|
|
52
|
-
title: { type: "text", parent: "s1", position: { x: 72, y: 60 }, props: { text: "Moving rulers get shorter", fontSize: 40, fontWeight: 700 } },
|
|
53
|
-
ruler: { type: "shape", parent: "s1", position: { x: 120, y: 252 }, size: { width: 480, height: 40 }, style: { stroke: "blue", fill: "blue", fillOpacity: 0.15 }, props: { text: "1 m", fontSize: 16 } },
|
|
54
|
-
caption: { type: "text", parent: "s1", position: { x: 120, y: 336 }, props: { text: "L = L₀ √(1 − v²/c²)", font: "serif", reveal: 1 } },
|
|
55
|
-
motion: { type: "arrow", parent: "s1", style: { stroke: "rose", strokeWidth: 3 }, props: { start: { x: 120, y: 216 }, end: { x: 600, y: 216 }, label: "v → c" } },
|
|
56
|
-
glow: { type: "effect", parent: "s1", position: { x: 630, y: 224 }, size: { width: 96, height: 96 }, style: { fill: "amber" }, props: { kind: "glow" } },
|
|
57
|
-
},
|
|
58
|
-
animations: {
|
|
59
|
-
lecture: {
|
|
60
|
-
markers: [{ at: 1500, label: "Ruler", pause: true }, { at: 5000, label: "Formula", pause: true }],
|
|
61
|
-
tracks: {
|
|
62
|
-
"title-in": { target: "title", property: "opacity", composite: "add", keyframes: [{ at: 0, value: 0 }, { at: 600, value: 1, ease: "ease-out" }] },
|
|
63
|
-
"arrow-draw": { target: "motion", property: "style.trim", keyframes: [{ at: 800, value: 0 }, { at: 1800, value: 1, ease: "ease-in-out" }] },
|
|
64
|
-
"ruler-shrink": { target: "ruler", property: "scale", keyframes: [{ at: 2000, value: 1 }, { at: 4000, value: { x: 0.45, y: 1 }, ease: "ease-in-out" }] },
|
|
65
|
-
"caption-type": { target: "caption", property: "props.reveal", keyframes: [{ at: 4200, value: 0 }, { at: 6000, value: 1 }] },
|
|
66
|
-
"camera-focus": { target: "camera", property: "focus", keyframes: [{ at: 0, value: "s1" }, { at: 2000, value: "ruler" }, { at: 4500, value: "s1" }] },
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
custom: {
|
|
73
|
-
description: "Custom Canvas content; use --module to print scripts/wave.js.",
|
|
74
|
-
value: {
|
|
75
|
-
items: {
|
|
76
|
-
wave: { type: "custom", position: { x: 0, y: 0 }, size: { width: 480, height: 270 }, script: { src: "scripts/wave.js", params: { amplitude: 48 } } },
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
rain: {
|
|
81
|
-
description: "A Board script whose shader rains over the view and splashes on cards; use --module to print scripts/rain.js.",
|
|
82
|
-
value: {
|
|
83
|
-
board: { scripts: { rain: { src: "scripts/rain.js", params: { density: 0.7 } } } },
|
|
84
|
-
items: {
|
|
85
|
-
title: { type: "text", position: { x: 80, y: 40 }, props: { text: "Rainy day", fontSize: 48 } },
|
|
86
|
-
left: { type: "shape", position: { x: 80, y: 180 }, size: { width: 320, height: 180 }, style: { fill: "blue", fillOpacity: 0.16, radius: 16 }, props: { text: "Drops land on top" } },
|
|
87
|
-
right: { type: "shape", position: { x: 480, y: 300 }, size: { width: 280, height: 160 }, rotation: -6, style: { fill: "green", fillOpacity: 0.16, radius: 16 }, props: { text: "and bounce off edges" } },
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
export function registerBoardExampleCommands(boards) {
|
|
93
|
-
boards.command("examples [name]")
|
|
94
|
-
.description("Print a starter Board document or list the examples")
|
|
95
|
-
.option("--module", `Print the example's JavaScript module (${Object.keys(MODULES).join(", ")})`)
|
|
96
|
-
.addHelpText("after", `
|
|
97
|
-
Examples are valid input for create and apply:
|
|
98
|
-
cohub boards examples lesson > lesson.json
|
|
99
|
-
cohub boards create lesson.board -i lesson.json`)
|
|
100
|
-
.action((name, options) => {
|
|
101
|
-
if (options.module) {
|
|
102
|
-
const module = name ? MODULES[name] : undefined;
|
|
103
|
-
if (!module)
|
|
104
|
-
throw new Error(`--module needs one of these examples: ${Object.keys(MODULES).join(", ")}.`);
|
|
105
|
-
process.stdout.write(module);
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (!name) {
|
|
109
|
-
for (const [key, example] of Object.entries(BOARD_EXAMPLES))
|
|
110
|
-
console.log(`${key.padEnd(10)} ${example.description}`);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const example = BOARD_EXAMPLES[name];
|
|
114
|
-
if (!example)
|
|
115
|
-
throw new Error(`Unknown example ${name}; expected ${Object.keys(BOARD_EXAMPLES).join(", ")}`);
|
|
116
|
-
json(example.value);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Command } from "commander";
|
|
2
|
-
import { parseBoardJsonObject } from "../board-command-support.js";
|
|
3
|
-
export declare const parseJsonObject: typeof parseBoardJsonObject;
|
|
4
|
-
export declare function boardSchemaField(schema: Record<string, unknown> | undefined, path: string): unknown;
|
|
5
|
-
export declare function parseRect(value: string, name?: string): {
|
|
6
|
-
x: number;
|
|
7
|
-
y: number;
|
|
8
|
-
width: number;
|
|
9
|
-
height: number;
|
|
10
|
-
};
|
|
11
|
-
/** `frames/%04d.png` → `frames/0012.png`; a sequence needs a `%d` placeholder. */
|
|
12
|
-
export declare function framePath(pattern: string, index: number): string;
|
|
13
|
-
export declare function registerBoards(program: Command): Command;
|