@kubohiroya/turbowarp-http-server 0.5.0 → 0.5.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.ja.md +2 -2
- package/README.md +2 -2
- package/dist/compiler/ir-v2/parse.js +38 -0
- package/dist/compiler/ir-v2/parse.js.map +1 -1
- package/dist/compiler/ir-v2/types.d.ts +39 -2
- package/dist/compiler/ir-v2/types.js +10 -1
- package/dist/compiler/ir-v2/types.js.map +1 -1
- package/dist/compiler/manifest/operations.js +35 -14
- package/dist/compiler/manifest/operations.js.map +1 -1
- package/dist/compiler/pipeline/core-generator.js +63 -2
- package/dist/compiler/pipeline/core-generator.js.map +1 -1
- package/dist/compiler/pipeline/requirements.js +10 -0
- package/dist/compiler/pipeline/requirements.js.map +1 -1
- package/dist/compiler/structured-data/lowering.d.ts +21 -2
- package/dist/compiler/structured-data/lowering.js +202 -65
- package/dist/compiler/structured-data/lowering.js.map +1 -1
- package/dist/compiler/structured-data/runtime.d.ts +22 -1
- package/dist/compiler/structured-data/runtime.js +82 -1
- package/dist/compiler/structured-data/runtime.js.map +1 -1
- package/dist/compiler/turbowarp-v2.js +7 -1
- package/dist/compiler/turbowarp-v2.js.map +1 -1
- package/dist/compiler/validator/ir-validator.js +33 -1
- package/dist/compiler/validator/ir-validator.js.map +1 -1
- package/dist/turbowarp-http-server.js +48 -21
- package/docs/compiler-manifest-registry.ja.md +2 -2
- package/docs/deploy-ir-v2.ja.md +18 -3
- package/docs/ir-v2-conformance.ja.md +1 -0
- package/docs/server-executable-subset.ja.md +3 -1
- package/docs/structured-data-lowering.ja.md +124 -27
- package/docs/structured-data-named-values.ja.md +129 -0
- package/package.json +2 -1
- package/schemas/deploy-ir-v2.schema.json +69 -0
- package/src/compiler/ir-v2/parse.ts +48 -0
- package/src/compiler/ir-v2/types.ts +35 -2
- package/src/compiler/manifest/operations.ts +86 -51
- package/src/compiler/pipeline/core-generator.ts +63 -2
- package/src/compiler/pipeline/requirements.ts +5 -0
- package/src/compiler/structured-data/lowering.ts +225 -65
- package/src/compiler/structured-data/runtime.ts +79 -1
- package/src/compiler/turbowarp-v2.ts +6 -1
- package/src/compiler/validator/ir-validator.ts +49 -1
- package/src/fixed-input-editors.ts +44 -19
|
@@ -143,38 +143,63 @@ interface OptionalFixedHost {
|
|
|
143
143
|
gui?: {blockEditors?: {apiVersion?: number; registerFixedInputEditor?: (definition: FixedInputEditorOptions) => () => void}};
|
|
144
144
|
vm?: {runtime?: {on?: (event: string, listener: () => void) => void; off?: (event: string, listener: () => void) => void}};
|
|
145
145
|
}
|
|
146
|
-
/**
|
|
146
|
+
/**
|
|
147
|
+
* Registration follows the advertised opcode membership and the optional host capability.
|
|
148
|
+
* Loading a project disposes the runtime, which releases the registrations, but the extension
|
|
149
|
+
* stays loaded for the next project: they are registered again once that project has loaded.
|
|
150
|
+
* Only the owner's dispose is final.
|
|
151
|
+
*/
|
|
147
152
|
export function fixedInputRegistration(scratch: unknown) {
|
|
148
153
|
const host = (scratch ?? {}) as OptionalFixedHost;
|
|
149
154
|
let active: unknown;
|
|
150
155
|
let membership = '';
|
|
151
156
|
const removers: (() => void)[] = [];
|
|
152
157
|
let stopped = false;
|
|
158
|
+
let released = false;
|
|
159
|
+
let requested: readonly string[] = [];
|
|
153
160
|
const clear = () => {
|
|
154
|
-
host.vm?.runtime?.off?.('RUNTIME_DISPOSED',
|
|
161
|
+
host.vm?.runtime?.off?.('RUNTIME_DISPOSED', release);
|
|
162
|
+
host.vm?.runtime?.off?.('PROJECT_LOADED', restore);
|
|
155
163
|
for (const remove of removers.splice(0).reverse()) remove();
|
|
156
164
|
active = undefined;
|
|
157
165
|
membership = '';
|
|
158
166
|
};
|
|
159
|
-
const
|
|
167
|
+
const register = (visibleOpcodes: readonly string[]) => {
|
|
168
|
+
const api = host.gui?.blockEditors;
|
|
169
|
+
const definitions = fixedInputEditors.filter(definition => definition.opcodes.every(opcode => visibleOpcodes.includes(opcode)));
|
|
170
|
+
const key = definitions.map(definition => definition.editorId).join(',');
|
|
171
|
+
if (api === active && membership === key) return;
|
|
172
|
+
clear();
|
|
173
|
+
if (api?.apiVersion !== 1 || typeof api.registerFixedInputEditor !== 'function' || !definitions.length) return;
|
|
174
|
+
try {
|
|
175
|
+
for (const definition of definitions) {
|
|
176
|
+
const remove = api.registerFixedInputEditor.call(api, definition);
|
|
177
|
+
if (typeof remove !== 'function') throw new TypeError('Invalid fixed input cleanup.');
|
|
178
|
+
removers.push(remove);
|
|
179
|
+
}
|
|
180
|
+
active = api;
|
|
181
|
+
membership = key;
|
|
182
|
+
host.vm?.runtime?.on?.('RUNTIME_DISPOSED', release);
|
|
183
|
+
} catch (error) {clear(); throw error;}
|
|
184
|
+
};
|
|
185
|
+
/** The runtime of this project is gone; wait for the next project before registering again. */
|
|
186
|
+
const release = () => {
|
|
187
|
+
clear();
|
|
188
|
+
released = true;
|
|
189
|
+
host.vm?.runtime?.on?.('PROJECT_LOADED', restore);
|
|
190
|
+
};
|
|
191
|
+
const restore = () => {
|
|
192
|
+
if (stopped || !released) return;
|
|
193
|
+
released = false;
|
|
194
|
+
// A refusal here must not break the VM's event dispatch; the next getInfo() retries.
|
|
195
|
+
try {register(requested);} catch {/* retried by the next ensure() */}
|
|
196
|
+
};
|
|
197
|
+
const shutdown = () => {stopped = true; released = false; clear();};
|
|
160
198
|
return {
|
|
161
199
|
ensure(visibleOpcodes: readonly string[]) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (stopped || (api === active && membership === key)) return;
|
|
166
|
-
clear();
|
|
167
|
-
if (api?.apiVersion !== 1 || typeof api.registerFixedInputEditor !== 'function' || !definitions.length) return;
|
|
168
|
-
try {
|
|
169
|
-
for (const definition of definitions) {
|
|
170
|
-
const remove = api.registerFixedInputEditor.call(api, definition);
|
|
171
|
-
if (typeof remove !== 'function') throw new TypeError('Invalid fixed input cleanup.');
|
|
172
|
-
removers.push(remove);
|
|
173
|
-
}
|
|
174
|
-
active = api;
|
|
175
|
-
membership = key;
|
|
176
|
-
host.vm?.runtime?.on?.('RUNTIME_DISPOSED', shutdown);
|
|
177
|
-
} catch (error) {clear(); throw error;}
|
|
200
|
+
requested = visibleOpcodes;
|
|
201
|
+
if (stopped || released) return;
|
|
202
|
+
register(visibleOpcodes);
|
|
178
203
|
},
|
|
179
204
|
dispose: shutdown
|
|
180
205
|
};
|