@crowdedkingdoms/crowdyjs 9.0.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 +56 -34
- package/README.md +83 -50
- 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/rust-analysis.d.ts.map +1 -1
- package/dist/live-coding/rust-analysis.js +64 -1
- package/dist/live-coding/worker-transport.d.ts +3 -0
- package/dist/live-coding/worker-transport.d.ts.map +1 -1
- package/dist/live-coding/worker-transport.js +13 -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 +4 -4
- package/dist/live-coding/ide.d.ts +0 -23
- package/dist/live-coding/ide.d.ts.map +0 -1
- package/dist/live-coding/ide.js +0 -514
- package/dist/live-coding/index.d.ts +0 -8
- package/dist/live-coding/index.d.ts.map +0 -1
- package/dist/live-coding/index.js +0 -7
- 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
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { projectTargets, } from './models.js';
|
|
2
|
+
const SDK_VERSION = '0.1.5';
|
|
3
|
+
/** Create a compile-oriented starter without introducing a raw JSON source map. */
|
|
4
|
+
export function createModStudioStarterProject(options) {
|
|
5
|
+
const base = moduleName(options.name);
|
|
6
|
+
const targets = projectTargets(options.kind);
|
|
7
|
+
const metadata = {
|
|
8
|
+
name: options.name.trim() || 'Untitled mod',
|
|
9
|
+
...(options.description?.trim()
|
|
10
|
+
? { description: options.description.trim() }
|
|
11
|
+
: {}),
|
|
12
|
+
...(targets.includes('SERVER')
|
|
13
|
+
? { serverModuleName: `${base}-server` }
|
|
14
|
+
: {}),
|
|
15
|
+
...(targets.includes('CLIENT')
|
|
16
|
+
? { clientModuleName: `${base}-client` }
|
|
17
|
+
: {}),
|
|
18
|
+
pairingPreference: options.kind === 'FULL_STACK' ? 'REQUIRED' : 'NONE',
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
appId: options.appId,
|
|
22
|
+
gridId: options.gridId,
|
|
23
|
+
kind: options.kind,
|
|
24
|
+
metadata,
|
|
25
|
+
files: targets.flatMap((target) => starterFiles(target, target === 'SERVER'
|
|
26
|
+
? metadata.serverModuleName
|
|
27
|
+
: metadata.clientModuleName)),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function starterFiles(target, name) {
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
target,
|
|
34
|
+
path: 'Cargo.toml',
|
|
35
|
+
content: `[package]
|
|
36
|
+
name = "${name}"
|
|
37
|
+
version = "0.1.0"
|
|
38
|
+
edition = "2021"
|
|
39
|
+
|
|
40
|
+
[lib]
|
|
41
|
+
crate-type = ["cdylib"]
|
|
42
|
+
|
|
43
|
+
[dependencies]
|
|
44
|
+
crowdy-compute-sdk = "${SDK_VERSION}"
|
|
45
|
+
`,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
target,
|
|
49
|
+
path: 'src/lib.rs',
|
|
50
|
+
content: target === 'SERVER' ? serverSource() : clientSource(),
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
function serverSource() {
|
|
55
|
+
return `use crowdy_compute_sdk as crowdy;
|
|
56
|
+
|
|
57
|
+
fn on_init() {
|
|
58
|
+
// Runs once when this SERVER module starts on the owned grid.
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
fn on_tick(_dt_ms: u32) {
|
|
62
|
+
// Server host calls are permission checked and clamped to the owned grid.
|
|
63
|
+
// Type "crowdy::" for the platform-indexed host-call surface.
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
fn on_invoke(payload: &[u8]) -> Vec<u8> {
|
|
67
|
+
// Called by Mod Studio's Invoke panel or an allowed game caller.
|
|
68
|
+
payload.to_vec()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
crowdy::register_module!(init: on_init, tick: on_tick, invoke: on_invoke);
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
function clientSource() {
|
|
75
|
+
return `use crowdy_compute_sdk as crowdy;
|
|
76
|
+
|
|
77
|
+
fn on_init() {
|
|
78
|
+
// Runs after the hash-bound CLIENT artifact enters the browser sandbox.
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
fn on_tick(_dt_ms: u32) {
|
|
82
|
+
// Client host calls are allow-listed by PlayerCodeBroker. Presentation
|
|
83
|
+
// effects (for example HUD updates) never receive the page's app token.
|
|
84
|
+
// Type "crowdy::" for lifecycle and host-call completions.
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
fn on_invoke(payload: &[u8]) -> Vec<u8> {
|
|
88
|
+
payload.to_vec()
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
crowdy::register_module!(init: on_init, tick: on_tick, invoke: on_invoke);
|
|
92
|
+
`;
|
|
93
|
+
}
|
|
94
|
+
function moduleName(value) {
|
|
95
|
+
const slug = value
|
|
96
|
+
.trim()
|
|
97
|
+
.toLowerCase()
|
|
98
|
+
.replace(/[^a-z0-9]+/gu, '-')
|
|
99
|
+
.replace(/^-+|-+$/gu, '')
|
|
100
|
+
.slice(0, 48);
|
|
101
|
+
return slug || 'player-mod';
|
|
102
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const MOD_STUDIO_STYLES = "\n.ck-mod-studio{--ck-bg:#111827;--ck-panel:#182235;--ck-line:#334155;--ck-text:#e5e7eb;--ck-muted:#94a3b8;--ck-accent:#38bdf8;display:grid;grid-template-rows:auto auto minmax(360px,1fr) minmax(150px,.36fr);min-height:680px;background:var(--ck-bg);color:var(--ck-text);font:13px/1.4 ui-sans-serif,system-ui,sans-serif;border:1px solid var(--ck-line)}\n.ck-mod-studio *{box-sizing:border-box}.ck-mod-studio button,.ck-mod-studio input,.ck-mod-studio select,.ck-mod-studio textarea{font:inherit}.ck-mod-studio button,.ck-mod-studio select,.ck-mod-studio input{background:#0f172a;color:var(--ck-text);border:1px solid var(--ck-line);border-radius:4px;padding:5px 8px}.ck-mod-studio button{cursor:pointer}.ck-mod-studio button:hover{border-color:var(--ck-accent)}.ck-mod-studio button:disabled{opacity:.5;cursor:not-allowed}\n.ck-mod-studio-toolbar,.ck-mod-studio-actions,.ck-mod-studio-tabs,.ck-mod-studio-panel-tabs{display:flex;align-items:center;gap:6px;padding:7px;border-bottom:1px solid var(--ck-line)}.ck-mod-studio-toolbar{justify-content:space-between;flex-wrap:wrap}.ck-mod-studio-project-tools,.ck-mod-studio-runtime-tools{display:flex;align-items:center;gap:6px;flex-wrap:wrap}\n.ck-mod-studio-save[data-state=SAVED]{color:#86efac}.ck-mod-studio-save[data-state=SAVING]{color:#fde68a}.ck-mod-studio-save[data-state=CONFLICT]{color:#fca5a5}.ck-mod-studio-save[data-state=OFFLINE]{color:#fdba74}\n.ck-mod-studio-main{display:grid;grid-template-columns:230px minmax(0,1fr) 260px;min-height:0}.ck-mod-studio-explorer,.ck-mod-studio-settings{background:var(--ck-panel);overflow:auto;padding:8px}.ck-mod-studio-explorer{border-right:1px solid var(--ck-line)}.ck-mod-studio-settings{border-left:1px solid var(--ck-line)}.ck-mod-studio-editor-column{display:grid;grid-template-rows:auto minmax(0,1fr);min-width:0}\n.ck-mod-studio-editor{min-height:0;position:relative}.ck-mod-studio-textarea{width:100%;height:100%;min-height:330px;resize:none;background:#0b1020;color:var(--ck-text);border:0;padding:12px;font:13px/1.5 ui-monospace,SFMono-Regular,Consolas,monospace}.ck-mod-studio-editor-notice{padding:4px 8px;background:#78350f;color:#ffedd5}\n.ck-mod-studio-section{margin-bottom:12px}.ck-mod-studio-section-header{display:flex;align-items:center;justify-content:space-between;color:var(--ck-muted);font-weight:700;text-transform:uppercase;font-size:11px;margin-bottom:4px}.ck-mod-studio-file{display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:3px;align-items:center}.ck-mod-studio-file>button:first-child{text-align:left;overflow:hidden;text-overflow:ellipsis;border:0;background:transparent}.ck-mod-studio-file>button:not(:first-child){padding:1px 4px}\n.ck-mod-studio-tabs{padding:4px;overflow:auto}.ck-mod-studio-tab[data-active=true],.ck-mod-studio-panel-tab[data-active=true]{border-color:var(--ck-accent);color:#bae6fd}.ck-mod-studio-tab{white-space:nowrap}.ck-mod-studio-tab span{margin-left:7px;color:var(--ck-muted)}\n.ck-mod-studio-settings label{display:grid;gap:3px;margin-bottom:9px;color:var(--ck-muted)}.ck-mod-studio-settings input,.ck-mod-studio-settings select{width:100%}.ck-mod-studio-new{display:none;gap:6px;align-items:center;width:100%;padding:7px;border-bottom:1px solid var(--ck-line)}.ck-mod-studio-new[data-open=true]{display:flex}.ck-mod-studio-new input{flex:1}\n.ck-mod-studio-bottom{display:grid;grid-template-rows:auto minmax(0,1fr);min-height:0;border-top:1px solid var(--ck-line)}.ck-mod-studio-panel{display:none;overflow:auto;padding:8px}.ck-mod-studio-panel[data-active=true]{display:block}.ck-mod-studio-panel pre{white-space:pre-wrap;margin:0;font:12px/1.5 ui-monospace,SFMono-Regular,Consolas,monospace}.ck-mod-studio-problem{display:grid;grid-template-columns:auto auto 1fr;gap:8px;padding:3px;border-bottom:1px solid #243247}.ck-mod-studio-problem[data-source=rustc]{color:#fecaca}.ck-mod-studio-problem[data-source=local-advisory]{color:#fde68a}\n.ck-mod-studio-status{color:var(--ck-muted)}.ck-mod-studio-invoke{display:grid;grid-template-columns:180px 1fr auto;gap:6px}.ck-mod-studio-invoke textarea{min-height:70px;background:#0f172a;color:var(--ck-text);border:1px solid var(--ck-line)}.ck-mod-studio-empty{color:var(--ck-muted);padding:8px}\n@media(max-width:900px){.ck-mod-studio-main{grid-template-columns:180px minmax(0,1fr)}.ck-mod-studio-settings{display:none}}@media(max-width:620px){.ck-mod-studio-main{grid-template-columns:1fr}.ck-mod-studio-explorer{display:none}}\n";
|
|
2
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/mod-studio/styles.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,g2IAa7B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const MOD_STUDIO_STYLES = `
|
|
2
|
+
.ck-mod-studio{--ck-bg:#111827;--ck-panel:#182235;--ck-line:#334155;--ck-text:#e5e7eb;--ck-muted:#94a3b8;--ck-accent:#38bdf8;display:grid;grid-template-rows:auto auto minmax(360px,1fr) minmax(150px,.36fr);min-height:680px;background:var(--ck-bg);color:var(--ck-text);font:13px/1.4 ui-sans-serif,system-ui,sans-serif;border:1px solid var(--ck-line)}
|
|
3
|
+
.ck-mod-studio *{box-sizing:border-box}.ck-mod-studio button,.ck-mod-studio input,.ck-mod-studio select,.ck-mod-studio textarea{font:inherit}.ck-mod-studio button,.ck-mod-studio select,.ck-mod-studio input{background:#0f172a;color:var(--ck-text);border:1px solid var(--ck-line);border-radius:4px;padding:5px 8px}.ck-mod-studio button{cursor:pointer}.ck-mod-studio button:hover{border-color:var(--ck-accent)}.ck-mod-studio button:disabled{opacity:.5;cursor:not-allowed}
|
|
4
|
+
.ck-mod-studio-toolbar,.ck-mod-studio-actions,.ck-mod-studio-tabs,.ck-mod-studio-panel-tabs{display:flex;align-items:center;gap:6px;padding:7px;border-bottom:1px solid var(--ck-line)}.ck-mod-studio-toolbar{justify-content:space-between;flex-wrap:wrap}.ck-mod-studio-project-tools,.ck-mod-studio-runtime-tools{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
|
|
5
|
+
.ck-mod-studio-save[data-state=SAVED]{color:#86efac}.ck-mod-studio-save[data-state=SAVING]{color:#fde68a}.ck-mod-studio-save[data-state=CONFLICT]{color:#fca5a5}.ck-mod-studio-save[data-state=OFFLINE]{color:#fdba74}
|
|
6
|
+
.ck-mod-studio-main{display:grid;grid-template-columns:230px minmax(0,1fr) 260px;min-height:0}.ck-mod-studio-explorer,.ck-mod-studio-settings{background:var(--ck-panel);overflow:auto;padding:8px}.ck-mod-studio-explorer{border-right:1px solid var(--ck-line)}.ck-mod-studio-settings{border-left:1px solid var(--ck-line)}.ck-mod-studio-editor-column{display:grid;grid-template-rows:auto minmax(0,1fr);min-width:0}
|
|
7
|
+
.ck-mod-studio-editor{min-height:0;position:relative}.ck-mod-studio-textarea{width:100%;height:100%;min-height:330px;resize:none;background:#0b1020;color:var(--ck-text);border:0;padding:12px;font:13px/1.5 ui-monospace,SFMono-Regular,Consolas,monospace}.ck-mod-studio-editor-notice{padding:4px 8px;background:#78350f;color:#ffedd5}
|
|
8
|
+
.ck-mod-studio-section{margin-bottom:12px}.ck-mod-studio-section-header{display:flex;align-items:center;justify-content:space-between;color:var(--ck-muted);font-weight:700;text-transform:uppercase;font-size:11px;margin-bottom:4px}.ck-mod-studio-file{display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:3px;align-items:center}.ck-mod-studio-file>button:first-child{text-align:left;overflow:hidden;text-overflow:ellipsis;border:0;background:transparent}.ck-mod-studio-file>button:not(:first-child){padding:1px 4px}
|
|
9
|
+
.ck-mod-studio-tabs{padding:4px;overflow:auto}.ck-mod-studio-tab[data-active=true],.ck-mod-studio-panel-tab[data-active=true]{border-color:var(--ck-accent);color:#bae6fd}.ck-mod-studio-tab{white-space:nowrap}.ck-mod-studio-tab span{margin-left:7px;color:var(--ck-muted)}
|
|
10
|
+
.ck-mod-studio-settings label{display:grid;gap:3px;margin-bottom:9px;color:var(--ck-muted)}.ck-mod-studio-settings input,.ck-mod-studio-settings select{width:100%}.ck-mod-studio-new{display:none;gap:6px;align-items:center;width:100%;padding:7px;border-bottom:1px solid var(--ck-line)}.ck-mod-studio-new[data-open=true]{display:flex}.ck-mod-studio-new input{flex:1}
|
|
11
|
+
.ck-mod-studio-bottom{display:grid;grid-template-rows:auto minmax(0,1fr);min-height:0;border-top:1px solid var(--ck-line)}.ck-mod-studio-panel{display:none;overflow:auto;padding:8px}.ck-mod-studio-panel[data-active=true]{display:block}.ck-mod-studio-panel pre{white-space:pre-wrap;margin:0;font:12px/1.5 ui-monospace,SFMono-Regular,Consolas,monospace}.ck-mod-studio-problem{display:grid;grid-template-columns:auto auto 1fr;gap:8px;padding:3px;border-bottom:1px solid #243247}.ck-mod-studio-problem[data-source=rustc]{color:#fecaca}.ck-mod-studio-problem[data-source=local-advisory]{color:#fde68a}
|
|
12
|
+
.ck-mod-studio-status{color:var(--ck-muted)}.ck-mod-studio-invoke{display:grid;grid-template-columns:180px 1fr auto;gap:6px}.ck-mod-studio-invoke textarea{min-height:70px;background:#0f172a;color:var(--ck-text);border:1px solid var(--ck-line)}.ck-mod-studio-empty{color:var(--ck-muted);padding:8px}
|
|
13
|
+
@media(max-width:900px){.ck-mod-studio-main{grid-template-columns:180px minmax(0,1fr)}.ck-mod-studio-settings{display:none}}@media(max-width:620px){.ck-mod-studio-main{grid-template-columns:1fr}.ck-mod-studio-explorer{display:none}}
|
|
14
|
+
`;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ModStudioEditorAdapter, ModStudioEditorCallbacks } from './editor.js';
|
|
2
|
+
/**
|
|
3
|
+
* Target/file-aware fallback used when Monaco or the local Rust worker cannot
|
|
4
|
+
* start. It edits the active source file directly; project tabs and explorer
|
|
5
|
+
* continue to work and no JSON source blob is exposed.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createTextareaModStudioEditor(host: HTMLElement, callbacks: ModStudioEditorCallbacks): ModStudioEditorAdapter;
|
|
8
|
+
//# sourceMappingURL=textarea-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textarea-editor.d.ts","sourceRoot":"","sources":["../../src/mod-studio/textarea-editor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,aAAa,CAAC;AAGrB;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,wBAAwB,GAClC,sBAAsB,CAwDxB"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Target/file-aware fallback used when Monaco or the local Rust worker cannot
|
|
3
|
+
* start. It edits the active source file directly; project tabs and explorer
|
|
4
|
+
* continue to work and no JSON source blob is exposed.
|
|
5
|
+
*/
|
|
6
|
+
export function createTextareaModStudioEditor(host, callbacks) {
|
|
7
|
+
const notice = document.createElement('div');
|
|
8
|
+
notice.className = 'ck-mod-studio-editor-notice';
|
|
9
|
+
notice.textContent =
|
|
10
|
+
'Basic editor active — Monaco or the local Rust worker was unavailable.';
|
|
11
|
+
const textarea = document.createElement('textarea');
|
|
12
|
+
textarea.className = 'ck-mod-studio-textarea';
|
|
13
|
+
textarea.rows = 24;
|
|
14
|
+
textarea.spellcheck = false;
|
|
15
|
+
textarea.setAttribute('aria-label', 'Project source editor');
|
|
16
|
+
host.replaceChildren(notice, textarea);
|
|
17
|
+
let active = null;
|
|
18
|
+
let disposed = false;
|
|
19
|
+
const onInput = () => {
|
|
20
|
+
if (disposed ||
|
|
21
|
+
active?.source !== 'PROJECT' ||
|
|
22
|
+
!active.target) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
callbacks.onProjectFileChange(active.target, active.path, textarea.value);
|
|
26
|
+
};
|
|
27
|
+
textarea.addEventListener('input', onInput);
|
|
28
|
+
return {
|
|
29
|
+
mode: 'textarea',
|
|
30
|
+
sync(state) {
|
|
31
|
+
if (disposed)
|
|
32
|
+
return;
|
|
33
|
+
const next = state.activeFile;
|
|
34
|
+
active = next;
|
|
35
|
+
if (!next) {
|
|
36
|
+
textarea.value = '';
|
|
37
|
+
textarea.disabled = true;
|
|
38
|
+
textarea.placeholder = 'Create or open a project file';
|
|
39
|
+
delete textarea.dataset.target;
|
|
40
|
+
delete textarea.dataset.path;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
textarea.disabled = false;
|
|
44
|
+
textarea.readOnly = next.source !== 'PROJECT';
|
|
45
|
+
textarea.dataset.target = next.target ?? 'SHARED';
|
|
46
|
+
textarea.dataset.path = next.path;
|
|
47
|
+
const content = contentFor(state, next);
|
|
48
|
+
if (textarea.value !== content)
|
|
49
|
+
textarea.value = content;
|
|
50
|
+
},
|
|
51
|
+
layout() { },
|
|
52
|
+
dispose() {
|
|
53
|
+
if (disposed)
|
|
54
|
+
return;
|
|
55
|
+
disposed = true;
|
|
56
|
+
textarea.removeEventListener('input', onInput);
|
|
57
|
+
host.replaceChildren();
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function contentFor(state, ref) {
|
|
62
|
+
if (ref.source === 'PROJECT') {
|
|
63
|
+
return (state.project?.files.find((file) => file.target === ref.target && file.path === ref.path)?.content ?? '');
|
|
64
|
+
}
|
|
65
|
+
const files = ref.source === 'PERSONAL_LIBRARY'
|
|
66
|
+
? state.personalLibraryFiles
|
|
67
|
+
: state.commonFiles;
|
|
68
|
+
return (files.find((file) => ref.referenceId
|
|
69
|
+
? file.id === ref.referenceId
|
|
70
|
+
: file.path === ref.path && file.target === ref.target)?.content ?? '');
|
|
71
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crowdedkingdoms/crowdyjs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "Browser-first Crowded Kingdoms SDK with GraphQL, realtime, and local Rust authoring support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"import": "./dist/stores/index.js",
|
|
19
19
|
"types": "./dist/stores/index.d.ts"
|
|
20
20
|
},
|
|
21
|
-
"./
|
|
22
|
-
"import": "./dist/
|
|
23
|
-
"types": "./dist/
|
|
21
|
+
"./mod-studio": {
|
|
22
|
+
"import": "./dist/mod-studio/index.js",
|
|
23
|
+
"types": "./dist/mod-studio/index.d.ts"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"sideEffects": false,
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type LiveCodingHandle, type MountLiveCodingOptions } from './mount.js';
|
|
2
|
-
import { type PlatformIndex } from './platform-index.js';
|
|
3
|
-
export interface MountLiveCodingIDEOptions extends MountLiveCodingOptions {
|
|
4
|
-
/** Consumer-provided Monaco editor worker (bundler-specific). */
|
|
5
|
-
editorWorkerFactory?: () => Worker;
|
|
6
|
-
/** Optional module-worker factory; one worker is created for this editor. */
|
|
7
|
-
languageWorkerFactory?: () => Worker;
|
|
8
|
-
/**
|
|
9
|
-
* Generated platform symbol index. The worker strictly validates its schema;
|
|
10
|
-
* omit it to use the byte-identical embedded game export.
|
|
11
|
-
*/
|
|
12
|
-
platformIndex?: PlatformIndex | unknown;
|
|
13
|
-
/** JSON-RPC request timeout; defaults to 3 seconds. */
|
|
14
|
-
languageRequestTimeoutMs?: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Lazy Monaco live-coding IDE backed only by a browser module worker and local
|
|
18
|
-
* WASM parser assets. If Monaco, Worker, or WASM startup fails, the dependency-
|
|
19
|
-
* free textarea is mounted; there is deliberately no server fallback.
|
|
20
|
-
*/
|
|
21
|
-
export declare function mountLiveCodingIDE(el: HTMLElement, options: MountLiveCodingIDEOptions): Promise<LiveCodingHandle>;
|
|
22
|
-
export declare function isCurrentDiagnosticVersion(version: unknown, currentVersion: number): boolean;
|
|
23
|
-
//# sourceMappingURL=ide.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ide.d.ts","sourceRoot":"","sources":["../../src/live-coding/ide.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC5B,MAAM,YAAY,CAAC;AAUpB,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAY7B,MAAM,WAAW,yBAA0B,SAAQ,sBAAsB;IACvE,iEAAiE;IACjE,mBAAmB,CAAC,EAAE,MAAM,MAAM,CAAC;IACnC,6EAA6E;IAC7E,qBAAqB,CAAC,EAAE,MAAM,MAAM,CAAC;IACrC;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC;IACxC,uDAAuD;IACvD,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAgBD;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,EAAE,EAAE,WAAW,EACf,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,gBAAgB,CAAC,CAwX3B;AA8GD,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAKT"}
|