@crowdedkingdoms/crowdyjs 8.22.0 → 10.0.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/MIGRATION.md +66 -0
- package/README.md +111 -7
- package/dist/crowdy-client.d.ts +3 -0
- package/dist/crowdy-client.d.ts.map +1 -1
- package/dist/crowdy-client.js +2 -0
- package/dist/domains/playerCodeProjects.d.ts +25 -0
- package/dist/domains/playerCodeProjects.d.ts.map +1 -0
- package/dist/domains/playerCodeProjects.js +299 -0
- package/dist/domains/playerCompute.d.ts +1 -1
- package/dist/domains/playerCompute.js +1 -1
- package/dist/generated/graphql.d.ts +792 -7
- package/dist/generated/graphql.d.ts.map +1 -1
- package/dist/generated/graphql.js +57 -0
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -5
- package/dist/kit/npcs.d.ts.map +1 -1
- package/dist/kit/social.d.ts.map +1 -1
- package/dist/live-coding/assets/browser-authoring-index.json +1 -0
- package/dist/live-coding/assets/manifest.json +19 -0
- package/dist/live-coding/assets/tree-sitter-rust.wasm +0 -0
- package/dist/live-coding/assets/web-tree-sitter.wasm +0 -0
- package/dist/live-coding/browser-authoring-index.generated.d.ts +2 -0
- package/dist/live-coding/browser-authoring-index.generated.d.ts.map +1 -0
- package/dist/live-coding/browser-authoring-index.generated.js +5127 -0
- package/dist/live-coding/lsp-protocol.d.ts +98 -0
- package/dist/live-coding/lsp-protocol.d.ts.map +1 -0
- package/dist/live-coding/lsp-protocol.js +70 -0
- package/dist/live-coding/monaco-services.d.ts +22 -0
- package/dist/live-coding/monaco-services.d.ts.map +1 -0
- package/dist/live-coding/monaco-services.js +69 -0
- package/dist/live-coding/platform-index.d.ts +29 -0
- package/dist/live-coding/platform-index.d.ts.map +1 -0
- package/dist/live-coding/platform-index.js +281 -0
- package/dist/live-coding/rust-analysis.d.ts +24 -0
- package/dist/live-coding/rust-analysis.d.ts.map +1 -0
- package/dist/live-coding/rust-analysis.js +375 -0
- package/dist/live-coding/rust-lsp-server.d.ts +43 -0
- package/dist/live-coding/rust-lsp-server.d.ts.map +1 -0
- package/dist/live-coding/rust-lsp-server.js +455 -0
- package/dist/live-coding/rust-lsp.worker.d.ts +2 -0
- package/dist/live-coding/rust-lsp.worker.d.ts.map +1 -0
- package/dist/live-coding/rust-lsp.worker.js +26 -0
- package/dist/live-coding/vfs.d.ts +41 -0
- package/dist/live-coding/vfs.d.ts.map +1 -0
- package/dist/live-coding/vfs.js +174 -0
- package/dist/live-coding/worker-transport.d.ts +63 -0
- package/dist/live-coding/worker-transport.d.ts.map +1 -0
- package/dist/live-coding/worker-transport.js +217 -0
- package/dist/mod-studio/controller.d.ts +188 -0
- package/dist/mod-studio/controller.d.ts.map +1 -0
- package/dist/mod-studio/controller.js +915 -0
- package/dist/mod-studio/diagnostics.d.ts +22 -0
- package/dist/mod-studio/diagnostics.d.ts.map +1 -0
- package/dist/mod-studio/diagnostics.js +141 -0
- package/dist/mod-studio/dom-shell.d.ts +55 -0
- package/dist/mod-studio/dom-shell.d.ts.map +1 -0
- package/dist/mod-studio/dom-shell.js +527 -0
- package/dist/mod-studio/editor.d.ts +17 -0
- package/dist/mod-studio/editor.d.ts.map +1 -0
- package/dist/mod-studio/editor.js +1 -0
- package/dist/mod-studio/index.d.ts +10 -0
- package/dist/mod-studio/index.d.ts.map +1 -0
- package/dist/mod-studio/index.js +9 -0
- package/dist/mod-studio/models.d.ts +149 -0
- package/dist/mod-studio/models.d.ts.map +1 -0
- package/dist/mod-studio/models.js +62 -0
- package/dist/mod-studio/monaco-editor.d.ts +16 -0
- package/dist/mod-studio/monaco-editor.d.ts.map +1 -0
- package/dist/mod-studio/monaco-editor.js +548 -0
- package/dist/mod-studio/mount.d.ts +17 -0
- package/dist/mod-studio/mount.d.ts.map +1 -0
- package/dist/mod-studio/mount.js +86 -0
- package/dist/mod-studio/starter-projects.d.ts +11 -0
- package/dist/mod-studio/starter-projects.d.ts.map +1 -0
- package/dist/mod-studio/starter-projects.js +102 -0
- package/dist/mod-studio/styles.d.ts +2 -0
- package/dist/mod-studio/styles.d.ts.map +1 -0
- package/dist/mod-studio/styles.js +14 -0
- package/dist/mod-studio/textarea-editor.d.ts +8 -0
- package/dist/mod-studio/textarea-editor.d.ts.map +1 -0
- package/dist/mod-studio/textarea-editor.js +71 -0
- package/package.json +18 -6
- package/dist/live-coding/ide.d.ts +0 -16
- package/dist/live-coding/ide.d.ts.map +0 -1
- package/dist/live-coding/ide.js +0 -399
- package/dist/live-coding/live-coding-controller.d.ts +0 -75
- package/dist/live-coding/live-coding-controller.d.ts.map +0 -1
- package/dist/live-coding/live-coding-controller.js +0 -141
- package/dist/live-coding/mount.d.ts +0 -26
- package/dist/live-coding/mount.d.ts.map +0 -1
- package/dist/live-coding/mount.js +0 -108
- package/dist/live-coding/templates.d.ts +0 -17
- package/dist/live-coding/templates.d.ts.map +0 -1
- package/dist/live-coding/templates.js +0 -59
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { LiveCodingController, } from './live-coding-controller.js';
|
|
2
|
-
import { PLAYER_CODE_TEMPLATES, } from './templates.js';
|
|
3
|
-
/**
|
|
4
|
-
* Mount the live-coding panel into a host element (08 option A). Deliberately
|
|
5
|
-
* dependency-free DOM: a textarea editor, target + template pickers, deploy /
|
|
6
|
-
* draft-deploy / stop buttons, a status+console line, and the quota/wallet
|
|
7
|
-
* meter. Games skin it via the returned nodes or their own CSS; a game that
|
|
8
|
-
* wants a custom UI can drive LiveCodingController directly instead.
|
|
9
|
-
*
|
|
10
|
-
* Safe to import in non-DOM contexts; mounting throws only if called without
|
|
11
|
-
* a document.
|
|
12
|
-
*/
|
|
13
|
-
export function mountLiveCoding(el, options) {
|
|
14
|
-
if (typeof document === 'undefined') {
|
|
15
|
-
throw new Error('mountLiveCoding requires a DOM document');
|
|
16
|
-
}
|
|
17
|
-
const templates = options.templates ?? PLAYER_CODE_TEMPLATES;
|
|
18
|
-
const moduleName = options.moduleName ?? 'scratch-mod';
|
|
19
|
-
const root = document.createElement('div');
|
|
20
|
-
root.className = 'ck-live-coding';
|
|
21
|
-
const targetSelect = document.createElement('select');
|
|
22
|
-
for (const t of ['server', 'client']) {
|
|
23
|
-
const opt = document.createElement('option');
|
|
24
|
-
opt.value = t;
|
|
25
|
-
opt.textContent = t;
|
|
26
|
-
targetSelect.appendChild(opt);
|
|
27
|
-
}
|
|
28
|
-
const templateSelect = document.createElement('select');
|
|
29
|
-
const editor = document.createElement('textarea');
|
|
30
|
-
editor.className = 'ck-live-coding-editor';
|
|
31
|
-
editor.rows = 20;
|
|
32
|
-
const refreshTemplates = () => {
|
|
33
|
-
templateSelect.innerHTML = '';
|
|
34
|
-
for (const t of templates.filter((t) => t.target === targetSelect.value)) {
|
|
35
|
-
const opt = document.createElement('option');
|
|
36
|
-
opt.value = t.id;
|
|
37
|
-
opt.textContent = t.title;
|
|
38
|
-
templateSelect.appendChild(opt);
|
|
39
|
-
}
|
|
40
|
-
const first = templates.find((t) => t.target === targetSelect.value);
|
|
41
|
-
if (first)
|
|
42
|
-
editor.value = first.sourceFilesJson;
|
|
43
|
-
};
|
|
44
|
-
templateSelect.addEventListener('change', () => {
|
|
45
|
-
const t = templates.find((t) => t.id === templateSelect.value);
|
|
46
|
-
if (t)
|
|
47
|
-
editor.value = t.sourceFilesJson;
|
|
48
|
-
});
|
|
49
|
-
targetSelect.addEventListener('change', refreshTemplates);
|
|
50
|
-
const deployBtn = button('Deploy');
|
|
51
|
-
const draftBtn = button('Deploy draft');
|
|
52
|
-
const stopBtn = button('Stop');
|
|
53
|
-
const status = document.createElement('pre');
|
|
54
|
-
status.className = 'ck-live-coding-status';
|
|
55
|
-
const meter = document.createElement('div');
|
|
56
|
-
meter.className = 'ck-live-coding-meter';
|
|
57
|
-
const controller = new LiveCodingController({
|
|
58
|
-
...options,
|
|
59
|
-
onStatus: (s) => renderStatus(status, meter, s),
|
|
60
|
-
});
|
|
61
|
-
const doDeploy = (draft) => void controller
|
|
62
|
-
.deploy({
|
|
63
|
-
name: moduleName,
|
|
64
|
-
target: targetSelect.value,
|
|
65
|
-
sourceFilesJson: editor.value,
|
|
66
|
-
draft: draft || options.draftByDefault,
|
|
67
|
-
})
|
|
68
|
-
.catch((err) => {
|
|
69
|
-
status.textContent = `error: ${err.message}`;
|
|
70
|
-
});
|
|
71
|
-
deployBtn.addEventListener('click', () => doDeploy(false));
|
|
72
|
-
draftBtn.addEventListener('click', () => doDeploy(true));
|
|
73
|
-
stopBtn.addEventListener('click', () => controller.stop());
|
|
74
|
-
const controls = document.createElement('div');
|
|
75
|
-
controls.className = 'ck-live-coding-controls';
|
|
76
|
-
controls.append(targetSelect, templateSelect, deployBtn, draftBtn, stopBtn);
|
|
77
|
-
root.append(controls, editor, status, meter);
|
|
78
|
-
el.appendChild(root);
|
|
79
|
-
refreshTemplates();
|
|
80
|
-
void controller.refreshUsage().catch(() => { });
|
|
81
|
-
return {
|
|
82
|
-
controller,
|
|
83
|
-
destroy: () => {
|
|
84
|
-
controller.stop();
|
|
85
|
-
root.remove();
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function button(label) {
|
|
90
|
-
const b = document.createElement('button');
|
|
91
|
-
b.type = 'button';
|
|
92
|
-
b.textContent = label;
|
|
93
|
-
return b;
|
|
94
|
-
}
|
|
95
|
-
function renderStatus(status, meter, s) {
|
|
96
|
-
const parts = [`[${s.target}] ${s.phase}`];
|
|
97
|
-
if (s.message)
|
|
98
|
-
parts.push(s.message);
|
|
99
|
-
if (s.compileLog)
|
|
100
|
-
parts.push('\n' + s.compileLog);
|
|
101
|
-
status.textContent = parts.join(' ');
|
|
102
|
-
if (s.usage) {
|
|
103
|
-
const gate = s.usage.gateStatus === 'active'
|
|
104
|
-
? 'active'
|
|
105
|
-
: `${s.usage.gateStatus}${s.usage.gateReason ? ` (${s.usage.gateReason})` : ''}`;
|
|
106
|
-
meter.textContent = `units ${s.usage.hourUnitsUsed}/${s.usage.unitsPerHour ?? '∞'} · compiles ${s.usage.compilesThisHour}/${s.usage.maxCompilesPerHour} · gate ${gate}`;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Starter templates for the live-coding panel (08 §5). These are minimal,
|
|
3
|
-
* compile-ready single-file mods written against the public host surface —
|
|
4
|
-
* the panel seeds them and games (BWF) supply their own richer set. Each
|
|
5
|
-
* value is the JSON source map playerComputeDeploy expects.
|
|
6
|
-
*/
|
|
7
|
-
export interface PlayerCodeTemplate {
|
|
8
|
-
id: string;
|
|
9
|
-
title: string;
|
|
10
|
-
target: 'server' | 'client';
|
|
11
|
-
description: string;
|
|
12
|
-
/** JSON string: { "Cargo.toml": "...", "src/lib.rs": "..." } */
|
|
13
|
-
sourceFilesJson: string;
|
|
14
|
-
}
|
|
15
|
-
export declare const PLAYER_CODE_TEMPLATES: PlayerCodeTemplate[];
|
|
16
|
-
export declare function templateById(id: string): PlayerCodeTemplate | undefined;
|
|
17
|
-
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/live-coding/templates.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,eAAe,EAAE,MAAM,CAAC;CACzB;AAoBD,eAAO,MAAM,qBAAqB,EAAE,kBAAkB,EAiDrD,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAEvE"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
function cargo(name) {
|
|
2
|
-
return `[package]
|
|
3
|
-
name = "${name}"
|
|
4
|
-
version = "0.1.0"
|
|
5
|
-
edition = "2021"
|
|
6
|
-
|
|
7
|
-
[lib]
|
|
8
|
-
crate-type = ["cdylib"]
|
|
9
|
-
|
|
10
|
-
[dependencies]
|
|
11
|
-
crowdy-compute-sdk = "0.1.5"
|
|
12
|
-
`;
|
|
13
|
-
}
|
|
14
|
-
function src(name, lib) {
|
|
15
|
-
return JSON.stringify({ 'Cargo.toml': cargo(name), 'src/lib.rs': lib });
|
|
16
|
-
}
|
|
17
|
-
export const PLAYER_CODE_TEMPLATES = [
|
|
18
|
-
{
|
|
19
|
-
id: 'server-ticker',
|
|
20
|
-
title: 'Grid ticker (server)',
|
|
21
|
-
target: 'server',
|
|
22
|
-
description: 'A low-rate server tick you can grow into an auto-farm or spawner.',
|
|
23
|
-
sourceFilesJson: src('grid-ticker', `fn on_init() {}
|
|
24
|
-
fn on_tick(_dt: u32) {
|
|
25
|
-
// Runs on the server as the grid owner while someone is in the grid.
|
|
26
|
-
// Read/write only inside your grid; egress is grid-clamped.
|
|
27
|
-
}
|
|
28
|
-
fn on_invoke(_payload: &[u8]) -> Vec<u8> { Vec::new() }
|
|
29
|
-
crowdy_compute_sdk::register_module!(init: on_init, tick: on_tick, invoke: on_invoke);`),
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
id: 'server-invoke',
|
|
33
|
-
title: 'Invoke tool (server)',
|
|
34
|
-
target: 'server',
|
|
35
|
-
description: 'A callable export a client tool or automation can invoke as you.',
|
|
36
|
-
sourceFilesJson: src('invoke-tool', `fn on_init() {}
|
|
37
|
-
fn on_tick(_dt: u32) {}
|
|
38
|
-
fn on_invoke(_payload: &[u8]) -> Vec<u8> {
|
|
39
|
-
b"{\\"ok\\":true}".to_vec()
|
|
40
|
-
}
|
|
41
|
-
crowdy_compute_sdk::register_module!(init: on_init, tick: on_tick, invoke: on_invoke);`),
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
id: 'client-hud',
|
|
45
|
-
title: 'Grid HUD (client)',
|
|
46
|
-
target: 'client',
|
|
47
|
-
description: 'A browser mod that draws a HUD panel for your grid via the presentation hook.',
|
|
48
|
-
sourceFilesJson: src('grid-hud', `fn on_init() {}
|
|
49
|
-
fn on_tick(_dt: u32) {
|
|
50
|
-
// Client-side, runs as you in the browser sandbox. Use the hud_set host
|
|
51
|
-
// call (via the SDK) to render into the game's mod HUD region.
|
|
52
|
-
}
|
|
53
|
-
fn on_invoke(_payload: &[u8]) -> Vec<u8> { Vec::new() }
|
|
54
|
-
crowdy_compute_sdk::register_module!(init: on_init, tick: on_tick, invoke: on_invoke);`),
|
|
55
|
-
},
|
|
56
|
-
];
|
|
57
|
-
export function templateById(id) {
|
|
58
|
-
return PLAYER_CODE_TEMPLATES.find((t) => t.id === id);
|
|
59
|
-
}
|