@kubohiroya/turbowarp-camera-source 0.17.0 → 0.17.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
@@ -26,13 +26,13 @@ TurboWarp-Camera-Sourceは、MediaDevicesのカメラストリームを名前付
26
26
  次のURLをunsandboxed custom extensionとして読み込みます。
27
27
 
28
28
  ```text
29
- https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-source@0.17.0/dist/camera-source.js
29
+ https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-source@0.17.1/dist/camera-source.js
30
30
  ```
31
31
 
32
32
  npm hostでは次を使います。
33
33
 
34
34
  ```bash
35
- pnpm add @kubohiroya/turbowarp-camera-source@0.17.0
35
+ pnpm add @kubohiroya/turbowarp-camera-source@0.17.1
36
36
  ```
37
37
 
38
38
  ## Quick start
@@ -332,3 +332,5 @@ GitHub Pages用の静的サイトは`docs/`にあり、英語版は`docs/index.h
332
332
  ## ライセンス
333
333
 
334
334
  SPDX-License-Identifier: MPL-2.0
335
+
336
+ 固定入力の編集は拡張構築時の任意editor APIを使います。後からのAPI追加・差替えにはGUI再読込と拡張インスタンス再構築が必要です。Dialogs/FixedInputsは起動時既定OFFです。未変更rawは保持し、reporterは評価しません。機器・sessionの実行条件は実行時検証の責務です。固定fieldのSchema正本は`schemas/block-editor-fixed-inputs.schema.json`、`docs/schemas/`は`scripts/generate-fixed-input-docs.mjs`による生成物です。Schema URIは識別子で、編集時に取得しません。
package/README.md CHANGED
@@ -30,13 +30,13 @@ or select separate cameras for separate roles.
30
30
  Load this URL as an unsandboxed custom extension:
31
31
 
32
32
  ```text
33
- https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-source@0.17.0/dist/camera-source.js
33
+ https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-camera-source@0.17.1/dist/camera-source.js
34
34
  ```
35
35
 
36
36
  For npm hosts:
37
37
 
38
38
  ```bash
39
- pnpm add @kubohiroya/turbowarp-camera-source@0.17.0
39
+ pnpm add @kubohiroya/turbowarp-camera-source@0.17.1
40
40
  ```
41
41
 
42
42
  ## Quick Start
@@ -826,3 +826,5 @@ pnpm run docs
826
826
  ## License
827
827
 
828
828
  SPDX-License-Identifier: MPL-2.0
829
+
830
+ Fixed input editing uses the optional editor API present at extension construction; late API replacement requires GUI reload and instance reconstruction. Dialogs and FixedInputs are startup flags, both off by default. Unchanged literals stay raw; reporters are never evaluated. Device/session prerequisites remain runtime checks. The canonical fixed field schema is `schemas/block-editor-fixed-inputs.schema.json`; `docs/schemas/` is generated by `scripts/generate-fixed-input-docs.mjs`. The schema URI identifies the contract and is not fetched during editing.
@@ -55,6 +55,147 @@
55
55
  license: "MPL-2.0",
56
56
  unsandboxed: true
57
57
  };
58
+ var block_editor_fixed_inputs_schema_default = {
59
+ $schema: "https://json-schema.org/draft/2020-12/schema",
60
+ $id: "https://kubohiroya.github.io/turbowarp-camera-source/schemas/block-editor-fixed-inputs.schema.json",
61
+ $defs: { "showCameraPreview": {
62
+ "type": "object",
63
+ "properties": { "PREVIEW_FLIP": {
64
+ "type": "string",
65
+ "enum": [
66
+ "none",
67
+ "horizontal",
68
+ "vertical",
69
+ "both"
70
+ ]
71
+ } },
72
+ "additionalProperties": false
73
+ } }
74
+ };
75
+ /** Canonical fixed field fragments; URI is identity only, never fetched. */
76
+ function fixedInputBundle(opcode, argument) {
77
+ const source = {
78
+ repository: "turbowarp-camera-source",
79
+ path: "schemas/block-editor-fixed-inputs.schema.json",
80
+ symbol: `#/$defs/${opcode}/properties/${argument}`
81
+ };
82
+ const definitions = block_editor_fixed_inputs_schema_default.$defs;
83
+ return {
84
+ identity: {
85
+ ownerId: "turbowarp-camera-source",
86
+ contractId: "fixed-inputs",
87
+ revision: "1",
88
+ variantId: opcode + "." + argument
89
+ },
90
+ dialect: "2020-12",
91
+ root: {
92
+ retrievalUri: block_editor_fixed_inputs_schema_default.$id,
93
+ document: definitions[opcode].properties[argument],
94
+ artifact: {
95
+ role: "canonical-schema",
96
+ source
97
+ }
98
+ },
99
+ resources: [],
100
+ provenance: {
101
+ canonicalSources: [source, ...[{
102
+ "repository": "turbowarp-camera-source",
103
+ "path": "src/flip.ts",
104
+ "symbol": "FLIPS / isFlip / toFlip"
105
+ }]],
106
+ generatedFiles: [{
107
+ repository: "turbowarp-camera-source",
108
+ path: "docs/schemas/block-editor-fixed-inputs.schema.json"
109
+ }],
110
+ generationSources: [{
111
+ repository: "turbowarp-camera-source",
112
+ path: "scripts/generate-fixed-input-docs.mjs"
113
+ }],
114
+ referenceSchemas: []
115
+ }
116
+ };
117
+ }
118
+ var invalid = () => [{ message: "Invalid fixed input." }];
119
+ function enumBinding(opcode, argument, choices, normalization) {
120
+ const project = (value) => {
121
+ if (typeof value !== "string") return value;
122
+ const normalized = normalization === "none" ? value : normalization === "trim" ? value.trim() : value.trim().toLowerCase();
123
+ return choices.includes(normalized) ? normalized : value;
124
+ };
125
+ return {
126
+ argument,
127
+ schemaBundle: fixedInputBundle(opcode, argument),
128
+ control: {
129
+ label: argument,
130
+ kind: "enum",
131
+ choices: choices.map((value) => ({ value }))
132
+ },
133
+ read: project,
134
+ encode(value) {
135
+ if (typeof value !== "string" || !choices.includes(value)) throw new TypeError("Choose a known value.");
136
+ return value;
137
+ },
138
+ validateCandidate(candidate, _context, finalSnapshot) {
139
+ try {
140
+ return typeof candidate === "string" && choices.includes(candidate) && ownerCheck(opcode, argument, candidate, finalSnapshot) ? [] : invalid();
141
+ } catch {
142
+ return invalid();
143
+ }
144
+ }
145
+ };
146
+ }
147
+ function ownerCheck(_opcode, _argument, _candidate, _snapshot) {
148
+ return true;
149
+ }
150
+ var extensionId = "kubohiroyacamerasource";
151
+ var validationContext = () => ({
152
+ consumerId: "turbowarp-camera-source",
153
+ nowMs: 0,
154
+ settings: null
155
+ });
156
+ var fixedInputEditors = [{
157
+ apiVersion: 1,
158
+ extensionId,
159
+ editorId: "showCameraPreview-fixed",
160
+ opcodes: [`${extensionId}_showCameraPreview`],
161
+ contractId: "turbowarp-camera-source/showCameraPreview",
162
+ contractRevision: "1",
163
+ validationContext,
164
+ readOnlyArguments: [],
165
+ bindings: [enumBinding("showCameraPreview", "PREVIEW_FLIP", [
166
+ "none",
167
+ "horizontal",
168
+ "vertical",
169
+ "both"
170
+ ], "none")]
171
+ }];
172
+ /** Register metadata only; the GUI startup capability owns editor activation. */
173
+ function registerFixedInputEditors(scratch, definitions, runtimeOverride) {
174
+ const host = scratch;
175
+ const api = host.gui?.blockEditors;
176
+ if (!definitions.length || api?.apiVersion !== 1 || typeof api.registerFixedInputEditor !== "function") return () => {};
177
+ const runtime = runtimeOverride ?? host.vm?.runtime;
178
+ const removers = [];
179
+ let active = true;
180
+ const dispose = () => {
181
+ if (!active) return;
182
+ active = false;
183
+ runtime?.off?.("RUNTIME_DISPOSED", dispose);
184
+ for (const remove of removers.splice(0).reverse()) remove();
185
+ };
186
+ try {
187
+ for (const definition of definitions) {
188
+ const remove = api.registerFixedInputEditor.call(api, definition);
189
+ if (typeof remove !== "function") throw new TypeError("Invalid fixed input registration disposer.");
190
+ removers.push(remove);
191
+ }
192
+ runtime?.on?.("RUNTIME_DISPOSED", dispose);
193
+ } catch (error) {
194
+ dispose();
195
+ throw error;
196
+ }
197
+ return dispose;
198
+ }
58
199
  var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
59
200
  Object.defineProperty(exports, "__esModule", { value: true });
60
201
  exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0;
@@ -10874,7 +11015,9 @@
10874
11015
  this.devices = [];
10875
11016
  this.storedProfileOutcomes = /* @__PURE__ */ new Map();
10876
11017
  this.storedProfilesGeneration = 0;
11018
+ this.removeFixedEditors = () => {};
10877
11019
  this.dispose = () => {
11020
+ this.removeFixedEditors();
10878
11021
  this.removeSourceEditors();
10879
11022
  this.stopAllCameras();
10880
11023
  const runtime = Scratch.vm.runtime;
@@ -10890,25 +11033,31 @@
10890
11033
  this.storedProfileOutcomes.clear();
10891
11034
  };
10892
11035
  this.removeSourceEditors = registerSourceEditors(Scratch);
10893
- this.profileStore = options.profileStore ?? createIndexedDbCameraProfileStore();
10894
- this.profileChannel = this.openProfileChannel();
10895
- Scratch.vm.runtime[cameraSourceRuntimeKey] = this;
10896
- this.capability = createRuntimeCapability({
10897
- registerProfile: (document) => this.profiles.register(document),
10898
- forgetProfile: (cameraId) => this.profiles.forget(cameraId),
10899
- profileFor: (cameraId) => this.profiles.get(cameraId),
10900
- calibratedCameras: () => this.profiles.cameraIds(),
10901
- assessProfile: (cameraId) => {
10902
- return this.assessmentOf(cameraId);
10903
- },
10904
- intrinsicsFor: (cameraId) => this.intrinsicsOf(cameraId),
10905
- conditionsFor: (cameraId) => this.conditionsOf(cameraId),
10906
- conditionsGeneration: (cameraId) => this.generationOf(cameraId)
10907
- });
10908
- Scratch.vm.runtime[cameraSourceCapabilityKey] = this.capability;
10909
- Scratch.vm.runtime.on?.("PROJECT_STOP_ALL", this.handleProjectBoundary);
10910
- Scratch.vm.runtime.on?.("PROJECT_LOADED", this.handleProjectBoundary);
10911
- Scratch.vm.runtime.on?.("RUNTIME_DISPOSED", this.dispose);
11036
+ try {
11037
+ this.removeFixedEditors = registerFixedInputEditors(Scratch, fixedInputEditors);
11038
+ this.profileStore = options.profileStore ?? createIndexedDbCameraProfileStore();
11039
+ this.profileChannel = this.openProfileChannel();
11040
+ Scratch.vm.runtime[cameraSourceRuntimeKey] = this;
11041
+ this.capability = createRuntimeCapability({
11042
+ registerProfile: (document) => this.profiles.register(document),
11043
+ forgetProfile: (cameraId) => this.profiles.forget(cameraId),
11044
+ profileFor: (cameraId) => this.profiles.get(cameraId),
11045
+ calibratedCameras: () => this.profiles.cameraIds(),
11046
+ assessProfile: (cameraId) => {
11047
+ return this.assessmentOf(cameraId);
11048
+ },
11049
+ intrinsicsFor: (cameraId) => this.intrinsicsOf(cameraId),
11050
+ conditionsFor: (cameraId) => this.conditionsOf(cameraId),
11051
+ conditionsGeneration: (cameraId) => this.generationOf(cameraId)
11052
+ });
11053
+ Scratch.vm.runtime[cameraSourceCapabilityKey] = this.capability;
11054
+ Scratch.vm.runtime.on?.("PROJECT_STOP_ALL", this.handleProjectBoundary);
11055
+ Scratch.vm.runtime.on?.("PROJECT_LOADED", this.handleProjectBoundary);
11056
+ Scratch.vm.runtime.on?.("RUNTIME_DISPOSED", this.dispose);
11057
+ } catch (error) {
11058
+ this.dispose();
11059
+ throw error;
11060
+ }
10912
11061
  }
10913
11062
  getInfo() {
10914
11063
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubohiroya/turbowarp-camera-source",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "author": "Hiroya Kubo <hiroya@cuc.ac.jp>",
5
5
  "description": "A TurboWarp capability extension for sharing one MediaDevices camera stream across extensions.",
6
6
  "type": "module",
@@ -54,7 +54,7 @@
54
54
  "lint": "eslint src tests vite.config.ts",
55
55
  "format": "eslint src tests vite.config.ts --fix",
56
56
  "test": "vitest run",
57
- "docs": "node scripts/generate-readme.ts",
57
+ "docs": "node scripts/generate-readme.ts && node scripts/generate-fixed-input-docs.mjs",
58
58
  "docs:check": "pnpm run docs && git diff --exit-code -- README.md README.ja.md",
59
59
  "docs:pages:check": "node scripts/check-pages.ts",
60
60
  "repo:check": "node scripts/check-repo.ts",
@@ -68,8 +68,8 @@
68
68
  },
69
69
  "devDependencies": {
70
70
  "@eslint/js": "^9.39.5",
71
- "@kubohiroya/turbowarp-extension-manifest": "0.2.0",
72
- "@kubohiroya/vite-plugin-turbowarp-extension": "0.4.0",
71
+ "@kubohiroya/turbowarp-extension-manifest": "0.3.2",
72
+ "@kubohiroya/vite-plugin-turbowarp-extension": "0.6.1",
73
73
  "@types/node": "^24.13.3",
74
74
  "ajv": "^8.20.0",
75
75
  "eslint": "^9.39.5",
@@ -88,6 +88,12 @@
88
88
  "getusermedia"
89
89
  ],
90
90
  "dependencies": {
91
- "@kubohiroya/turbowarp-extension-data-editor": "git+https://github.com/kubohiroya/turbowarp-extension-data-editor.git#76fa1d50a3c188082ceef723ea018a9d8769ea6e"
91
+ "@kubohiroya/turbowarp-extension-data-editor": "0.2.1"
92
+ },
93
+ "gitHead": "e23f2e1e3db28c5b7e0290949cf99004b689d90c",
94
+ "x-turbowarp-source": {
95
+ "revision": "e23f2e1e3db28c5b7e0290949cf99004b689d90c",
96
+ "revisionRole": "base-commit",
97
+ "sourceState": "local-release-overlay"
92
98
  }
93
99
  }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://kubohiroya.github.io/turbowarp-camera-source/schemas/block-editor-fixed-inputs.schema.json",
4
+ "$defs": {
5
+ "showCameraPreview": {
6
+ "type": "object",
7
+ "properties": {
8
+ "PREVIEW_FLIP": {
9
+ "type": "string",
10
+ "enum": [
11
+ "none",
12
+ "horizontal",
13
+ "vertical",
14
+ "both"
15
+ ]
16
+ }
17
+ },
18
+ "additionalProperties": false
19
+ }
20
+ }
21
+ }