@empty-sekai/sekai-custom-profile-sdk 0.3.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/LICENSE +235 -0
- package/LICENSE-EXCEPTION +32 -0
- package/NOTICE +11 -0
- package/README.en.md +456 -0
- package/README.md +458 -0
- package/dist/allium_renderer_wasm.js +14 -0
- package/dist/allium_renderer_wasm.wasm +0 -0
- package/dist/authoring.d.ts +14 -0
- package/dist/authoring.js +34 -0
- package/dist/cache/glyphPersistentCache.d.ts +145 -0
- package/dist/cache/glyphPersistentCache.js +346 -0
- package/dist/cache/indexedDbGlyphRecordStore.d.ts +26 -0
- package/dist/cache/indexedDbGlyphRecordStore.js +214 -0
- package/dist/cache/sessionImageResourceCache.d.ts +39 -0
- package/dist/cache/sessionImageResourceCache.js +156 -0
- package/dist/emscripten.d.ts +11 -0
- package/dist/emscripten.js +1 -0
- package/dist/fontProvider.d.ts +36 -0
- package/dist/fontProvider.js +84 -0
- package/dist/fontSdfAtlas.d.ts +92 -0
- package/dist/fontSdfAtlas.js +296 -0
- package/dist/gpu/browserSemanticResources.d.ts +64 -0
- package/dist/gpu/browserSemanticResources.js +232 -0
- package/dist/gpu/generalTextRenderPlacement.d.ts +8 -0
- package/dist/gpu/generalTextRenderPlacement.js +131 -0
- package/dist/gpu/previewTransformTextureLayout.d.ts +1 -0
- package/dist/gpu/previewTransformTextureLayout.js +12 -0
- package/dist/gpu/semanticCommandGeometry.d.ts +21 -0
- package/dist/gpu/semanticCommandGeometry.js +226 -0
- package/dist/gpu/semanticCommandPlanner.d.ts +131 -0
- package/dist/gpu/semanticCommandPlanner.js +203 -0
- package/dist/gpu/semanticTextGlyphBridge.d.ts +3 -0
- package/dist/gpu/semanticTextGlyphBridge.js +22 -0
- package/dist/gpu/semanticWebglSceneRenderer.d.ts +70 -0
- package/dist/gpu/semanticWebglSceneRenderer.js +211 -0
- package/dist/gpu/slotRanges.d.ts +5 -0
- package/dist/gpu/slotRanges.js +14 -0
- package/dist/gpu/webglSdfAtlasTexture.d.ts +17 -0
- package/dist/gpu/webglSdfAtlasTexture.js +72 -0
- package/dist/gpu/webglSdfGlyphPipeline.d.ts +26 -0
- package/dist/gpu/webglSdfGlyphPipeline.js +267 -0
- package/dist/gpu/webglSemanticCommandExecutor.d.ts +79 -0
- package/dist/gpu/webglSemanticCommandExecutor.js +686 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +8 -0
- package/dist/interaction/numericTextRegions.d.ts +46 -0
- package/dist/interaction/numericTextRegions.js +44 -0
- package/dist/localizationProvider.d.ts +33 -0
- package/dist/localizationProvider.js +74 -0
- package/dist/originPrebuiltSdfAtlasPackage.d.ts +39 -0
- package/dist/originPrebuiltSdfAtlasPackage.js +316 -0
- package/dist/prebuiltSdfAtlas.d.ts +36 -0
- package/dist/prebuiltSdfAtlas.js +261 -0
- package/dist/protocol.d.ts +456 -0
- package/dist/protocol.js +1 -0
- package/dist/renderer.d.ts +218 -0
- package/dist/renderer.js +641 -0
- package/dist/resourceProvider.d.ts +24 -0
- package/dist/resourceProvider.js +41 -0
- package/dist/telemetry/rendererTelemetry.d.ts +158 -0
- package/dist/telemetry/rendererTelemetry.js +232 -0
- package/dist/third-party/freetype/FTL.txt +169 -0
- package/dist/types/atlas.d.ts +90 -0
- package/dist/types/atlas.js +1 -0
- package/dist/types/authoring.d.ts +81 -0
- package/dist/types/authoring.js +1 -0
- package/dist/types/core.d.ts +128 -0
- package/dist/types/core.js +1 -0
- package/dist/types/freeType.d.ts +54 -0
- package/dist/types/freeType.js +13 -0
- package/dist/types/glyph.d.ts +33 -0
- package/dist/types/glyph.js +1 -0
- package/dist/types/layout.d.ts +25 -0
- package/dist/types/layout.js +1 -0
- package/dist/types/text.d.ts +28 -0
- package/dist/types/text.js +1 -0
- package/dist/worker/glyphWorkScheduler.d.ts +29 -0
- package/dist/worker/glyphWorkScheduler.js +107 -0
- package/dist/worker-client.d.ts +114 -0
- package/dist/worker-client.js +413 -0
- package/dist/worker.d.ts +1 -0
- package/dist/worker.js +708 -0
- package/package.json +46 -0
- package/src/atlas.rs +652 -0
- package/src/authoring.ts +42 -0
- package/src/authoring_runtime.rs +303 -0
- package/src/cache/glyphPersistentCache.ts +463 -0
- package/src/cache/indexedDbGlyphRecordStore.ts +238 -0
- package/src/cache/sessionImageResourceCache.ts +186 -0
- package/src/edt.rs +97 -0
- package/src/emscripten.ts +17 -0
- package/src/fontProvider.ts +127 -0
- package/src/fontSdfAtlas.ts +431 -0
- package/src/geometry.rs +149 -0
- package/src/glyph_plan.rs +226 -0
- package/src/gpu/browserSemanticResources.ts +294 -0
- package/src/gpu/generalTextRenderPlacement.ts +175 -0
- package/src/gpu/previewTransformTextureLayout.ts +12 -0
- package/src/gpu/semanticCommandGeometry.ts +260 -0
- package/src/gpu/semanticCommandPlanner.ts +280 -0
- package/src/gpu/semanticTextGlyphBridge.ts +35 -0
- package/src/gpu/semanticWebglSceneRenderer.ts +261 -0
- package/src/gpu/slotRanges.ts +15 -0
- package/src/gpu/webglSdfAtlasTexture.ts +69 -0
- package/src/gpu/webglSdfGlyphPipeline.ts +299 -0
- package/src/gpu/webglSemanticCommandExecutor.ts +739 -0
- package/src/index.ts +84 -0
- package/src/interaction/numericTextRegions.ts +80 -0
- package/src/layout.rs +1882 -0
- package/src/lib.rs +1443 -0
- package/src/localizationProvider.ts +113 -0
- package/src/main.rs +55 -0
- package/src/masterdata_runtime.rs +496 -0
- package/src/originPrebuiltSdfAtlasPackage.ts +403 -0
- package/src/prebuiltSdfAtlas.ts +306 -0
- package/src/protocol.ts +150 -0
- package/src/renderer.ts +792 -0
- package/src/resourceProvider.ts +69 -0
- package/src/scene.rs +665 -0
- package/src/telemetry/rendererTelemetry.ts +358 -0
- package/src/types/atlas.ts +80 -0
- package/src/types/authoring.ts +85 -0
- package/src/types/core.ts +110 -0
- package/src/types/freeType.ts +63 -0
- package/src/types/glyph.ts +33 -0
- package/src/types/layout.ts +28 -0
- package/src/types/text.ts +28 -0
- package/src/worker/glyphWorkScheduler.ts +130 -0
- package/src/worker-client.ts +484 -0
- package/src/worker.ts +895 -0
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
export class RendererWorkerClient {
|
|
2
|
+
worker;
|
|
3
|
+
pending = new Map();
|
|
4
|
+
sequence = 0;
|
|
5
|
+
closed = false;
|
|
6
|
+
constructor(worker) {
|
|
7
|
+
this.worker = worker;
|
|
8
|
+
worker.onmessage = (event) => this.receive(event.data);
|
|
9
|
+
worker.onerror = (event) => this.failAll(new RendererWorkerError("WORKER_CRASHED", event.message));
|
|
10
|
+
}
|
|
11
|
+
static async create(options = {}) {
|
|
12
|
+
const workerUrl = options.workerUrl ?? new URL("./worker.js", import.meta.url);
|
|
13
|
+
const moduleUrl = options.moduleUrl ?? new URL("./allium_renderer_wasm.js", import.meta.url);
|
|
14
|
+
const wasmUrl = options.wasmUrl ?? new URL("./allium_renderer_wasm.wasm", import.meta.url);
|
|
15
|
+
const worker = options.workerFactory?.(workerUrl) ?? new Worker(workerUrl, { type: "module", name: "sekai-custom-profile-sdk" });
|
|
16
|
+
const client = new RendererWorkerClient(worker);
|
|
17
|
+
const result = await client.request("init", {
|
|
18
|
+
moduleUrl: moduleUrl.toString(),
|
|
19
|
+
wasmUrl: wasmUrl.toString(),
|
|
20
|
+
});
|
|
21
|
+
if (result.kind !== "init")
|
|
22
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid init response");
|
|
23
|
+
return client;
|
|
24
|
+
}
|
|
25
|
+
async registerFont(font) {
|
|
26
|
+
const bytes = font.bytes.slice(0);
|
|
27
|
+
const result = await this.request("registerFont", { ...font, bytes }, [bytes]);
|
|
28
|
+
if (result.kind !== "registerFont" || !result.registered)
|
|
29
|
+
throw new RendererWorkerError("FONT_REGISTRATION_FAILED", "Renderer worker rejected the font");
|
|
30
|
+
}
|
|
31
|
+
async contract() {
|
|
32
|
+
const result = await this.request("contract", {});
|
|
33
|
+
if (result.kind !== "contract")
|
|
34
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid contract response");
|
|
35
|
+
return result.contract;
|
|
36
|
+
}
|
|
37
|
+
async mapGlyphs(request) {
|
|
38
|
+
const result = await this.request("mapGlyphs", request);
|
|
39
|
+
if (result.kind !== "mapGlyphs")
|
|
40
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid glyph-map response");
|
|
41
|
+
return result.batch;
|
|
42
|
+
}
|
|
43
|
+
async planGlyphs(request) {
|
|
44
|
+
const result = await this.request("planGlyphs", request);
|
|
45
|
+
if (result.kind !== "planGlyphs")
|
|
46
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid glyph-plan response");
|
|
47
|
+
return result.plan;
|
|
48
|
+
}
|
|
49
|
+
async buildGlyphs(request) {
|
|
50
|
+
const result = await this.request("buildGlyphs", request);
|
|
51
|
+
if (result.kind !== "buildGlyphs")
|
|
52
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid glyph response");
|
|
53
|
+
return result.batch;
|
|
54
|
+
}
|
|
55
|
+
async layoutText(request) {
|
|
56
|
+
const result = await this.request("layoutText", { request });
|
|
57
|
+
if (result.kind !== "layoutText")
|
|
58
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid text-layout response");
|
|
59
|
+
return result.batch;
|
|
60
|
+
}
|
|
61
|
+
async glyphDemand(request) {
|
|
62
|
+
const result = await this.request("glyphDemand", { request });
|
|
63
|
+
if (result.kind !== "glyphDemand")
|
|
64
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid glyph-demand response");
|
|
65
|
+
return result.batch;
|
|
66
|
+
}
|
|
67
|
+
async createAtlas() {
|
|
68
|
+
const result = await this.request("createAtlas", {});
|
|
69
|
+
if (result.kind !== "createAtlas")
|
|
70
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid atlas response");
|
|
71
|
+
return new RendererAtlas(this, result.atlasId, result.stats);
|
|
72
|
+
}
|
|
73
|
+
async createAuthoringDocument(profile) {
|
|
74
|
+
const result = profile === undefined
|
|
75
|
+
? await this.request("createAuthoringBlank", {})
|
|
76
|
+
: await this.request("importAuthoringProfile", { profile });
|
|
77
|
+
if (result.kind !== "createAuthoring") {
|
|
78
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid authoring response");
|
|
79
|
+
}
|
|
80
|
+
return new RendererAuthoringDocument(this, result.authoringId, result.document, result.revision);
|
|
81
|
+
}
|
|
82
|
+
async restoreAuthoringDocument(checkpoint) {
|
|
83
|
+
const result = await this.request("restoreAuthoringCheckpoint", { checkpoint });
|
|
84
|
+
if (result.kind !== "createAuthoring") {
|
|
85
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid restored authoring response");
|
|
86
|
+
}
|
|
87
|
+
return new RendererAuthoringDocument(this, result.authoringId, result.document, result.revision);
|
|
88
|
+
}
|
|
89
|
+
async createMasterData(region, revision) {
|
|
90
|
+
const result = await this.request("createMasterData", { region, revision });
|
|
91
|
+
if (result.kind !== "createMasterData")
|
|
92
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid master-data response");
|
|
93
|
+
const requiredTables = Array.isArray(result.report.required_tables)
|
|
94
|
+
? result.report.required_tables.filter((value) => typeof value === "string")
|
|
95
|
+
: [];
|
|
96
|
+
return new RendererMasterData(this, result.masterDataId, region, revision, requiredTables);
|
|
97
|
+
}
|
|
98
|
+
async stats() {
|
|
99
|
+
const result = await this.request("stats", {});
|
|
100
|
+
if (result.kind !== "stats")
|
|
101
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid stats response");
|
|
102
|
+
return result.stats;
|
|
103
|
+
}
|
|
104
|
+
terminate() {
|
|
105
|
+
if (this.closed)
|
|
106
|
+
return;
|
|
107
|
+
this.closed = true;
|
|
108
|
+
this.worker.terminate();
|
|
109
|
+
this.failAll(new RendererWorkerError("WORKER_TERMINATED", "Renderer worker was terminated"));
|
|
110
|
+
}
|
|
111
|
+
async sceneRequest(kind, payload) {
|
|
112
|
+
return this.request(kind, payload);
|
|
113
|
+
}
|
|
114
|
+
request(kind, payload, transfers = []) {
|
|
115
|
+
if (this.closed)
|
|
116
|
+
return Promise.reject(new RendererWorkerError("WORKER_TERMINATED", "Renderer worker is closed"));
|
|
117
|
+
const id = ++this.sequence;
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
this.pending.set(id, { resolve, reject });
|
|
120
|
+
this.worker.postMessage({ id, kind, payload }, transfers);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
receive(response) {
|
|
124
|
+
const pending = this.pending.get(response.id);
|
|
125
|
+
if (!pending)
|
|
126
|
+
return;
|
|
127
|
+
this.pending.delete(response.id);
|
|
128
|
+
if (response.ok)
|
|
129
|
+
pending.resolve(response.result);
|
|
130
|
+
else
|
|
131
|
+
pending.reject(new RendererWorkerError(response.error.code, response.error.message));
|
|
132
|
+
}
|
|
133
|
+
failAll(error) {
|
|
134
|
+
for (const pending of this.pending.values())
|
|
135
|
+
pending.reject(error);
|
|
136
|
+
this.pending.clear();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
export class RendererAuthoringDocument {
|
|
140
|
+
client;
|
|
141
|
+
id;
|
|
142
|
+
initialDocument;
|
|
143
|
+
initialRevision;
|
|
144
|
+
destroyed = false;
|
|
145
|
+
constructor(client, id, initialDocument, initialRevision) {
|
|
146
|
+
this.client = client;
|
|
147
|
+
this.id = id;
|
|
148
|
+
this.initialDocument = initialDocument;
|
|
149
|
+
this.initialRevision = initialRevision;
|
|
150
|
+
}
|
|
151
|
+
async apply(command) {
|
|
152
|
+
this.assertAlive();
|
|
153
|
+
const result = await this.client.sceneRequest("applyAuthoring", { authoringId: this.id, command });
|
|
154
|
+
if (result.kind !== "authoringDelta" || result.delta == null) {
|
|
155
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid authoring delta");
|
|
156
|
+
}
|
|
157
|
+
return result.delta;
|
|
158
|
+
}
|
|
159
|
+
async select(id) {
|
|
160
|
+
return this.delta("selectAuthoring", { authoringId: this.id, id });
|
|
161
|
+
}
|
|
162
|
+
async elements() {
|
|
163
|
+
this.assertAlive();
|
|
164
|
+
const result = await this.client.sceneRequest("elementsAuthoring", { authoringId: this.id });
|
|
165
|
+
if (result.kind !== "elementsAuthoring") {
|
|
166
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned invalid authoring elements");
|
|
167
|
+
}
|
|
168
|
+
return result.elements;
|
|
169
|
+
}
|
|
170
|
+
async beginGesture(id) {
|
|
171
|
+
return this.delta("beginAuthoringGesture", { authoringId: this.id, id });
|
|
172
|
+
}
|
|
173
|
+
async previewGesture(command) {
|
|
174
|
+
return this.delta("previewAuthoringGesture", { authoringId: this.id, command });
|
|
175
|
+
}
|
|
176
|
+
async commitGesture() {
|
|
177
|
+
return this.delta("commitAuthoringGesture", { authoringId: this.id });
|
|
178
|
+
}
|
|
179
|
+
async cancelGesture() {
|
|
180
|
+
return this.delta("cancelAuthoringGesture", { authoringId: this.id });
|
|
181
|
+
}
|
|
182
|
+
async appendPage() {
|
|
183
|
+
return this.delta("appendAuthoringPage", { authoringId: this.id });
|
|
184
|
+
}
|
|
185
|
+
async duplicatePage(page) {
|
|
186
|
+
return this.delta("duplicateAuthoringPage", { authoringId: this.id, page });
|
|
187
|
+
}
|
|
188
|
+
async deletePage(page) {
|
|
189
|
+
return this.delta("deleteAuthoringPage", { authoringId: this.id, page });
|
|
190
|
+
}
|
|
191
|
+
async movePage(fromPage, page) {
|
|
192
|
+
return this.delta("moveAuthoringPage", { authoringId: this.id, fromPage, page });
|
|
193
|
+
}
|
|
194
|
+
async undo() {
|
|
195
|
+
return this.history("undoAuthoring");
|
|
196
|
+
}
|
|
197
|
+
async redo() {
|
|
198
|
+
return this.history("redoAuthoring");
|
|
199
|
+
}
|
|
200
|
+
async export() {
|
|
201
|
+
this.assertAlive();
|
|
202
|
+
const result = await this.client.sceneRequest("exportAuthoring", { authoringId: this.id });
|
|
203
|
+
if (result.kind !== "exportAuthoring") {
|
|
204
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid authoring export");
|
|
205
|
+
}
|
|
206
|
+
return result.document;
|
|
207
|
+
}
|
|
208
|
+
async checkpoint() {
|
|
209
|
+
this.assertAlive();
|
|
210
|
+
const result = await this.client.sceneRequest("checkpointAuthoring", { authoringId: this.id });
|
|
211
|
+
if (result.kind !== "checkpointAuthoring") {
|
|
212
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid authoring checkpoint");
|
|
213
|
+
}
|
|
214
|
+
return result.checkpoint;
|
|
215
|
+
}
|
|
216
|
+
async destroy() {
|
|
217
|
+
if (this.destroyed)
|
|
218
|
+
return;
|
|
219
|
+
const result = await this.client.sceneRequest("destroyAuthoring", { authoringId: this.id });
|
|
220
|
+
if (result.kind !== "destroyAuthoring" || !result.destroyed) {
|
|
221
|
+
throw new RendererWorkerError("AUTHORING_DESTROY_FAILED", "Renderer worker did not destroy the authoring session");
|
|
222
|
+
}
|
|
223
|
+
this.destroyed = true;
|
|
224
|
+
}
|
|
225
|
+
async history(kind) {
|
|
226
|
+
this.assertAlive();
|
|
227
|
+
const result = await this.client.sceneRequest(kind, { authoringId: this.id });
|
|
228
|
+
if (result.kind !== "authoringDelta") {
|
|
229
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid authoring history response");
|
|
230
|
+
}
|
|
231
|
+
return result.delta;
|
|
232
|
+
}
|
|
233
|
+
async delta(kind, payload) {
|
|
234
|
+
this.assertAlive();
|
|
235
|
+
const result = await this.client.sceneRequest(kind, payload);
|
|
236
|
+
if (result.kind !== "authoringDelta" || result.delta == null) {
|
|
237
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid authoring delta");
|
|
238
|
+
}
|
|
239
|
+
return result.delta;
|
|
240
|
+
}
|
|
241
|
+
assertAlive() {
|
|
242
|
+
if (this.destroyed)
|
|
243
|
+
throw new RendererWorkerError("AUTHORING_DESTROYED", "Renderer authoring session is destroyed");
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
export class RendererAtlas {
|
|
247
|
+
client;
|
|
248
|
+
id;
|
|
249
|
+
initialStats;
|
|
250
|
+
destroyed = false;
|
|
251
|
+
constructor(client, id, initialStats) {
|
|
252
|
+
this.client = client;
|
|
253
|
+
this.id = id;
|
|
254
|
+
this.initialStats = initialStats;
|
|
255
|
+
}
|
|
256
|
+
async resolve(keys, cached, generate) {
|
|
257
|
+
this.assertAlive();
|
|
258
|
+
const result = await this.client.sceneRequest("resolveAtlas", { atlasId: this.id, keys, cached, generate });
|
|
259
|
+
if (result.kind !== "resolveAtlas")
|
|
260
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid atlas resolution");
|
|
261
|
+
return result.result;
|
|
262
|
+
}
|
|
263
|
+
async pages(revisions) {
|
|
264
|
+
this.assertAlive();
|
|
265
|
+
const result = await this.client.sceneRequest("atlasPages", {
|
|
266
|
+
atlasId: this.id,
|
|
267
|
+
revisions: [...revisions].map(([page, revision]) => ({ page, revision })),
|
|
268
|
+
});
|
|
269
|
+
if (result.kind !== "atlasPages")
|
|
270
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned invalid atlas pages");
|
|
271
|
+
return result.updates;
|
|
272
|
+
}
|
|
273
|
+
async release(lease) {
|
|
274
|
+
if (this.destroyed)
|
|
275
|
+
return;
|
|
276
|
+
const result = await this.client.sceneRequest("releaseAtlas", { atlasId: this.id, lease });
|
|
277
|
+
if (result.kind !== "releaseAtlas")
|
|
278
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid atlas lease response");
|
|
279
|
+
}
|
|
280
|
+
async destroy() {
|
|
281
|
+
if (this.destroyed)
|
|
282
|
+
return;
|
|
283
|
+
const result = await this.client.sceneRequest("destroyAtlas", { atlasId: this.id });
|
|
284
|
+
if (result.kind !== "destroyAtlas" || !result.destroyed)
|
|
285
|
+
throw new RendererWorkerError("ATLAS_DESTROY_FAILED", "Renderer worker did not destroy the atlas session");
|
|
286
|
+
this.destroyed = true;
|
|
287
|
+
}
|
|
288
|
+
assertAlive() {
|
|
289
|
+
if (this.destroyed)
|
|
290
|
+
throw new RendererWorkerError("ATLAS_DESTROYED", "Renderer atlas session is destroyed");
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
export class RendererMasterData {
|
|
294
|
+
client;
|
|
295
|
+
id;
|
|
296
|
+
region;
|
|
297
|
+
revision;
|
|
298
|
+
requiredTables;
|
|
299
|
+
destroyed = false;
|
|
300
|
+
constructor(client, id, region, revision, requiredTables) {
|
|
301
|
+
this.client = client;
|
|
302
|
+
this.id = id;
|
|
303
|
+
this.region = region;
|
|
304
|
+
this.revision = revision;
|
|
305
|
+
this.requiredTables = requiredTables;
|
|
306
|
+
}
|
|
307
|
+
async putTable(name, table) {
|
|
308
|
+
return this.report("putMasterDataTable", { masterDataId: this.id, name, table });
|
|
309
|
+
}
|
|
310
|
+
async seal() {
|
|
311
|
+
return this.report("sealMasterData", { masterDataId: this.id });
|
|
312
|
+
}
|
|
313
|
+
async prepareProfile(request) {
|
|
314
|
+
this.assertAlive();
|
|
315
|
+
const result = await this.client.sceneRequest("prepareProfile", { masterDataId: this.id, request });
|
|
316
|
+
if (result.kind !== "prepareProfile")
|
|
317
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid profile preparation");
|
|
318
|
+
return result.preparation;
|
|
319
|
+
}
|
|
320
|
+
/** @internal Profile compilation stays behind BrowserRenderer. */
|
|
321
|
+
async createProfileScene(request, layoutRequest) {
|
|
322
|
+
this.assertAlive();
|
|
323
|
+
const result = await this.client.sceneRequest("createProfileScene", { masterDataId: this.id, request, layoutRequest });
|
|
324
|
+
if (result.kind !== "createProfileScene")
|
|
325
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid profile scene");
|
|
326
|
+
return {
|
|
327
|
+
scene: new RendererScene(this.client, result.sceneId, result.response),
|
|
328
|
+
layout: result.layout,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
async destroy() {
|
|
332
|
+
if (this.destroyed)
|
|
333
|
+
return;
|
|
334
|
+
const result = await this.client.sceneRequest("destroyMasterData", { masterDataId: this.id });
|
|
335
|
+
if (result.kind !== "destroyMasterData" || !result.destroyed)
|
|
336
|
+
throw new RendererWorkerError("MASTERDATA_DESTROY_FAILED", "Renderer worker did not destroy the master-data session");
|
|
337
|
+
this.destroyed = true;
|
|
338
|
+
}
|
|
339
|
+
async report(kind, payload) {
|
|
340
|
+
this.assertAlive();
|
|
341
|
+
const result = await this.client.sceneRequest(kind, payload);
|
|
342
|
+
if (result.kind !== "masterDataReport")
|
|
343
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid master-data report");
|
|
344
|
+
return result.report;
|
|
345
|
+
}
|
|
346
|
+
assertAlive() {
|
|
347
|
+
if (this.destroyed)
|
|
348
|
+
throw new RendererWorkerError("MASTERDATA_DESTROYED", "Renderer master-data session is destroyed");
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
export class RendererScene {
|
|
352
|
+
client;
|
|
353
|
+
id;
|
|
354
|
+
initial;
|
|
355
|
+
destroyed = false;
|
|
356
|
+
constructor(client, id, initial) {
|
|
357
|
+
this.client = client;
|
|
358
|
+
this.id = id;
|
|
359
|
+
this.initial = initial;
|
|
360
|
+
}
|
|
361
|
+
async advance(tick) {
|
|
362
|
+
return this.delta("advance", { sceneId: this.id, tick });
|
|
363
|
+
}
|
|
364
|
+
async setLayerVisible(layerId, visible) {
|
|
365
|
+
return this.delta("setLayerMask", { sceneId: this.id, layerId, visible });
|
|
366
|
+
}
|
|
367
|
+
async setLayerMasks(expectedLayerTableRevision, overrides) {
|
|
368
|
+
return this.delta("setLayerMasks", { sceneId: this.id, expectedLayerTableRevision, overrides });
|
|
369
|
+
}
|
|
370
|
+
async setTab(controlId, value) {
|
|
371
|
+
return this.delta("setTab", { sceneId: this.id, controlId, value });
|
|
372
|
+
}
|
|
373
|
+
async setScrollOffset(controlId, offset) {
|
|
374
|
+
return this.delta("scroll", { sceneId: this.id, controlId, offset });
|
|
375
|
+
}
|
|
376
|
+
async scrollBy(controlId, delta) {
|
|
377
|
+
return this.delta("scroll", { sceneId: this.id, controlId, delta });
|
|
378
|
+
}
|
|
379
|
+
async dump() {
|
|
380
|
+
this.assertAlive();
|
|
381
|
+
const result = await this.client.sceneRequest("dumpScene", { sceneId: this.id });
|
|
382
|
+
if (result.kind !== "dumpScene")
|
|
383
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid dump response");
|
|
384
|
+
return result.dump;
|
|
385
|
+
}
|
|
386
|
+
async destroy() {
|
|
387
|
+
if (this.destroyed)
|
|
388
|
+
return;
|
|
389
|
+
const result = await this.client.sceneRequest("destroyScene", { sceneId: this.id });
|
|
390
|
+
if (result.kind !== "destroyScene" || !result.destroyed)
|
|
391
|
+
throw new RendererWorkerError("SCENE_DESTROY_FAILED", "Renderer worker did not destroy the scene");
|
|
392
|
+
this.destroyed = true;
|
|
393
|
+
}
|
|
394
|
+
async delta(kind, payload) {
|
|
395
|
+
this.assertAlive();
|
|
396
|
+
const result = await this.client.sceneRequest(kind, payload);
|
|
397
|
+
if (result.kind !== "delta")
|
|
398
|
+
throw new RendererWorkerError("PROTOCOL_MISMATCH", "Renderer worker returned an invalid scene delta");
|
|
399
|
+
return result.delta;
|
|
400
|
+
}
|
|
401
|
+
assertAlive() {
|
|
402
|
+
if (this.destroyed)
|
|
403
|
+
throw new RendererWorkerError("SCENE_DESTROYED", "Renderer scene is destroyed");
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
export class RendererWorkerError extends Error {
|
|
407
|
+
code;
|
|
408
|
+
constructor(code, message) {
|
|
409
|
+
super(message);
|
|
410
|
+
this.code = code;
|
|
411
|
+
this.name = "RendererWorkerError";
|
|
412
|
+
}
|
|
413
|
+
}
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|