@kubohiroya/turbowarp-openai-realtime-api 0.4.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
CHANGED
|
@@ -55,7 +55,7 @@ OpenAI Realtime APIと音声やテキストで会話し、ブロックで書い
|
|
|
55
55
|
npm packageとして使う場合は、検証済みのversionをexact pinします。
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
|
-
pnpm add --save-exact @kubohiroya/turbowarp-openai-realtime-api@0.
|
|
58
|
+
pnpm add --save-exact @kubohiroya/turbowarp-openai-realtime-api@0.5.1
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
## クイックスタート
|
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ The reviewed JavaScript build is committed to this repository, so users do not n
|
|
|
61
61
|
Install an exact version that you have reviewed:
|
|
62
62
|
|
|
63
63
|
```bash
|
|
64
|
-
pnpm add --save-exact @kubohiroya/turbowarp-openai-realtime-api@0.
|
|
64
|
+
pnpm add --save-exact @kubohiroya/turbowarp-openai-realtime-api@0.5.1
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
Standalone bundle:
|
|
@@ -196,26 +196,50 @@ function fixedInputEditorOptions() {
|
|
|
196
196
|
})
|
|
197
197
|
}));
|
|
198
198
|
}
|
|
199
|
-
/**
|
|
199
|
+
/**
|
|
200
|
+
* Register only visible static contracts; ordinary composition consumers load no editor runtime.
|
|
201
|
+
* Every project load disposes the runtime while the extension stays loaded for the next project,
|
|
202
|
+
* so RUNTIME_DISPOSED only releases the registrations and the next PROJECT_LOADED registers the
|
|
203
|
+
* same ones again. The returned dispose is final.
|
|
204
|
+
*/
|
|
200
205
|
function registerFixedInputEditors(scratch, runtime, visibleBlocks) {
|
|
201
206
|
const api = scratch.gui?.blockEditors;
|
|
202
207
|
if (api?.apiVersion !== 1 || typeof api.registerFixedInputEditor !== "function") return void 0;
|
|
208
|
+
const registerEditor = api.registerFixedInputEditor;
|
|
203
209
|
const visibleOpcodes = new Set(visibleBlocks.flatMap((block) => {
|
|
204
210
|
if (typeof block !== "object" || block === null || !("opcode" in block)) return [];
|
|
205
211
|
return typeof block.opcode === "string" ? [block.opcode] : [];
|
|
206
212
|
}));
|
|
213
|
+
const visibleOptions = fixedInputEditorOptions().filter((options) => options.opcodes.some((opcode) => visibleOpcodes.has(opcode.slice(25))));
|
|
207
214
|
const events = runtime;
|
|
208
215
|
const removers = [];
|
|
209
|
-
let
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
events?.off?.("RUNTIME_DISPOSED", dispose);
|
|
216
|
+
let registered = false;
|
|
217
|
+
let disposed = false;
|
|
218
|
+
const release = () => {
|
|
219
|
+
registered = false;
|
|
214
220
|
for (const remove of removers.splice(0).reverse()) remove();
|
|
215
221
|
};
|
|
222
|
+
const register = () => {
|
|
223
|
+
if (disposed || registered) return;
|
|
224
|
+
registered = true;
|
|
225
|
+
try {
|
|
226
|
+
for (const options of visibleOptions) removers.push(registerEditor.call(api, options));
|
|
227
|
+
} catch (error) {
|
|
228
|
+
release();
|
|
229
|
+
throw error;
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
const dispose = () => {
|
|
233
|
+
if (disposed) return;
|
|
234
|
+
disposed = true;
|
|
235
|
+
events?.off?.("RUNTIME_DISPOSED", release);
|
|
236
|
+
events?.off?.("PROJECT_LOADED", register);
|
|
237
|
+
release();
|
|
238
|
+
};
|
|
216
239
|
try {
|
|
217
|
-
|
|
218
|
-
events?.on?.("RUNTIME_DISPOSED",
|
|
240
|
+
register();
|
|
241
|
+
events?.on?.("RUNTIME_DISPOSED", release);
|
|
242
|
+
events?.on?.("PROJECT_LOADED", register);
|
|
219
243
|
} catch (error) {
|
|
220
244
|
dispose();
|
|
221
245
|
throw error;
|
|
@@ -534,7 +558,7 @@ var block_definitions_default = {
|
|
|
534
558
|
}
|
|
535
559
|
};
|
|
536
560
|
//#endregion
|
|
537
|
-
//#region node_modules/.pnpm/@kubohiroya+turbowarp-named-functions@0.4.
|
|
561
|
+
//#region node_modules/.pnpm/@kubohiroya+turbowarp-named-functions@0.4.1-rc.2/node_modules/@kubohiroya/turbowarp-named-functions/dist/composition.js
|
|
538
562
|
/**
|
|
539
563
|
* A small JSON Schema validator for function arguments and returns. It interprets the schema at run time and
|
|
540
564
|
* never generates code, so it also works where `eval` is unavailable (for example Cloudflare Workers).
|
|
@@ -10,6 +10,11 @@ export declare function readNumber(value: LiteralValue): number;
|
|
|
10
10
|
export declare function newNumberToken(value: JsonValue): string;
|
|
11
11
|
export declare function candidateValid(_opcode: string, _argument: string, schema: InputSchema, value: LiteralValue): boolean;
|
|
12
12
|
export declare function fixedInputEditorOptions(): readonly FixedInputEditorOptions[];
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Register only visible static contracts; ordinary composition consumers load no editor runtime.
|
|
15
|
+
* Every project load disposes the runtime while the extension stays loaded for the next project,
|
|
16
|
+
* so RUNTIME_DISPOSED only releases the registrations and the next PROJECT_LOADED registers the
|
|
17
|
+
* same ones again. The returned dispose is final.
|
|
18
|
+
*/
|
|
14
19
|
export declare function registerFixedInputEditors(scratch: unknown, runtime: unknown, visibleBlocks: readonly unknown[]): (() => void) | undefined;
|
|
15
20
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubohiroya/turbowarp-openai-realtime-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "A TurboWarp extension for the OpenAI Realtime API, using a localhost relay for credentials.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Hiroya Kubo",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@eslint/js": "^9.39.5",
|
|
67
67
|
"@kubohiroya/turbowarp-extension-manifest": "^0.5.0",
|
|
68
|
-
"@kubohiroya/vite-plugin-turbowarp-extension": "^0.
|
|
68
|
+
"@kubohiroya/vite-plugin-turbowarp-extension": "^0.11.0",
|
|
69
69
|
"@types/node": "^24.13.3",
|
|
70
70
|
"eslint": "^9.39.5",
|
|
71
71
|
"jiti": "^2.7.0",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"typescript-eslint": "^8.66.0",
|
|
74
74
|
"vite": "^8.2.2",
|
|
75
75
|
"vitest": "^5.0.0",
|
|
76
|
-
"@kubohiroya/turbowarp-extension-data-editor": "^0.
|
|
76
|
+
"@kubohiroya/turbowarp-extension-data-editor": "^0.8.1"
|
|
77
77
|
},
|
|
78
78
|
"exports": {
|
|
79
79
|
"./composition": {
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"./package.json": "./package.json"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@kubohiroya/turbowarp-named-functions": "^0.4.
|
|
87
|
+
"@kubohiroya/turbowarp-named-functions": "^0.4.1-rc.2"
|
|
88
88
|
},
|
|
89
89
|
"gitHead": "2386a92f281d6285af4c9c61f19e2577453708e5",
|
|
90
90
|
"x-turbowarp-source": {
|
|
@@ -157,7 +157,12 @@ interface RegistrationRuntime {
|
|
|
157
157
|
on?(event: string, listener: () => void): void;
|
|
158
158
|
off?(event: string, listener: () => void): void;
|
|
159
159
|
}
|
|
160
|
-
/**
|
|
160
|
+
/**
|
|
161
|
+
* Register only visible static contracts; ordinary composition consumers load no editor runtime.
|
|
162
|
+
* Every project load disposes the runtime while the extension stays loaded for the next project,
|
|
163
|
+
* so RUNTIME_DISPOSED only releases the registrations and the next PROJECT_LOADED registers the
|
|
164
|
+
* same ones again. The returned dispose is final.
|
|
165
|
+
*/
|
|
161
166
|
export function registerFixedInputEditors(
|
|
162
167
|
scratch: unknown,
|
|
163
168
|
runtime: unknown,
|
|
@@ -180,6 +185,7 @@ export function registerFixedInputEditors(
|
|
|
180
185
|
typeof api.registerFixedInputEditor !== "function"
|
|
181
186
|
)
|
|
182
187
|
return undefined;
|
|
188
|
+
const registerEditor = api.registerFixedInputEditor;
|
|
183
189
|
const visibleOpcodes = new Set(
|
|
184
190
|
visibleBlocks.flatMap((block) => {
|
|
185
191
|
if (typeof block !== "object" || block === null || !("opcode" in block))
|
|
@@ -187,25 +193,41 @@ export function registerFixedInputEditors(
|
|
|
187
193
|
return typeof block.opcode === "string" ? [block.opcode] : [];
|
|
188
194
|
}),
|
|
189
195
|
);
|
|
196
|
+
const visibleOptions = fixedInputEditorOptions().filter((options) =>
|
|
197
|
+
options.opcodes.some((opcode) =>
|
|
198
|
+
visibleOpcodes.has(opcode.slice(extensionId.length + 1)),
|
|
199
|
+
),
|
|
200
|
+
);
|
|
190
201
|
const events = runtime as RegistrationRuntime | undefined;
|
|
191
202
|
const removers: (() => void)[] = [];
|
|
192
|
-
let
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
events?.off?.("RUNTIME_DISPOSED", dispose);
|
|
203
|
+
let registered = false;
|
|
204
|
+
let disposed = false;
|
|
205
|
+
const release = () => {
|
|
206
|
+
registered = false;
|
|
197
207
|
for (const remove of removers.splice(0).reverse()) remove();
|
|
198
208
|
};
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
)
|
|
205
|
-
|
|
206
|
-
|
|
209
|
+
const register = () => {
|
|
210
|
+
if (disposed || registered) return;
|
|
211
|
+
registered = true;
|
|
212
|
+
try {
|
|
213
|
+
for (const options of visibleOptions)
|
|
214
|
+
removers.push(registerEditor.call(api, options));
|
|
215
|
+
} catch (error) {
|
|
216
|
+
release();
|
|
217
|
+
throw error;
|
|
207
218
|
}
|
|
208
|
-
|
|
219
|
+
};
|
|
220
|
+
const dispose = () => {
|
|
221
|
+
if (disposed) return;
|
|
222
|
+
disposed = true;
|
|
223
|
+
events?.off?.("RUNTIME_DISPOSED", release);
|
|
224
|
+
events?.off?.("PROJECT_LOADED", register);
|
|
225
|
+
release();
|
|
226
|
+
};
|
|
227
|
+
try {
|
|
228
|
+
register();
|
|
229
|
+
events?.on?.("RUNTIME_DISPOSED", release);
|
|
230
|
+
events?.on?.("PROJECT_LOADED", register);
|
|
209
231
|
} catch (error) {
|
|
210
232
|
dispose();
|
|
211
233
|
throw error;
|