@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.
Files changed (130) hide show
  1. package/LICENSE +235 -0
  2. package/LICENSE-EXCEPTION +32 -0
  3. package/NOTICE +11 -0
  4. package/README.en.md +456 -0
  5. package/README.md +458 -0
  6. package/dist/allium_renderer_wasm.js +14 -0
  7. package/dist/allium_renderer_wasm.wasm +0 -0
  8. package/dist/authoring.d.ts +14 -0
  9. package/dist/authoring.js +34 -0
  10. package/dist/cache/glyphPersistentCache.d.ts +145 -0
  11. package/dist/cache/glyphPersistentCache.js +346 -0
  12. package/dist/cache/indexedDbGlyphRecordStore.d.ts +26 -0
  13. package/dist/cache/indexedDbGlyphRecordStore.js +214 -0
  14. package/dist/cache/sessionImageResourceCache.d.ts +39 -0
  15. package/dist/cache/sessionImageResourceCache.js +156 -0
  16. package/dist/emscripten.d.ts +11 -0
  17. package/dist/emscripten.js +1 -0
  18. package/dist/fontProvider.d.ts +36 -0
  19. package/dist/fontProvider.js +84 -0
  20. package/dist/fontSdfAtlas.d.ts +92 -0
  21. package/dist/fontSdfAtlas.js +296 -0
  22. package/dist/gpu/browserSemanticResources.d.ts +64 -0
  23. package/dist/gpu/browserSemanticResources.js +232 -0
  24. package/dist/gpu/generalTextRenderPlacement.d.ts +8 -0
  25. package/dist/gpu/generalTextRenderPlacement.js +131 -0
  26. package/dist/gpu/previewTransformTextureLayout.d.ts +1 -0
  27. package/dist/gpu/previewTransformTextureLayout.js +12 -0
  28. package/dist/gpu/semanticCommandGeometry.d.ts +21 -0
  29. package/dist/gpu/semanticCommandGeometry.js +226 -0
  30. package/dist/gpu/semanticCommandPlanner.d.ts +131 -0
  31. package/dist/gpu/semanticCommandPlanner.js +203 -0
  32. package/dist/gpu/semanticTextGlyphBridge.d.ts +3 -0
  33. package/dist/gpu/semanticTextGlyphBridge.js +22 -0
  34. package/dist/gpu/semanticWebglSceneRenderer.d.ts +70 -0
  35. package/dist/gpu/semanticWebglSceneRenderer.js +211 -0
  36. package/dist/gpu/slotRanges.d.ts +5 -0
  37. package/dist/gpu/slotRanges.js +14 -0
  38. package/dist/gpu/webglSdfAtlasTexture.d.ts +17 -0
  39. package/dist/gpu/webglSdfAtlasTexture.js +72 -0
  40. package/dist/gpu/webglSdfGlyphPipeline.d.ts +26 -0
  41. package/dist/gpu/webglSdfGlyphPipeline.js +267 -0
  42. package/dist/gpu/webglSemanticCommandExecutor.d.ts +79 -0
  43. package/dist/gpu/webglSemanticCommandExecutor.js +686 -0
  44. package/dist/index.d.ts +18 -0
  45. package/dist/index.js +8 -0
  46. package/dist/interaction/numericTextRegions.d.ts +46 -0
  47. package/dist/interaction/numericTextRegions.js +44 -0
  48. package/dist/localizationProvider.d.ts +33 -0
  49. package/dist/localizationProvider.js +74 -0
  50. package/dist/originPrebuiltSdfAtlasPackage.d.ts +39 -0
  51. package/dist/originPrebuiltSdfAtlasPackage.js +316 -0
  52. package/dist/prebuiltSdfAtlas.d.ts +36 -0
  53. package/dist/prebuiltSdfAtlas.js +261 -0
  54. package/dist/protocol.d.ts +456 -0
  55. package/dist/protocol.js +1 -0
  56. package/dist/renderer.d.ts +218 -0
  57. package/dist/renderer.js +641 -0
  58. package/dist/resourceProvider.d.ts +24 -0
  59. package/dist/resourceProvider.js +41 -0
  60. package/dist/telemetry/rendererTelemetry.d.ts +158 -0
  61. package/dist/telemetry/rendererTelemetry.js +232 -0
  62. package/dist/third-party/freetype/FTL.txt +169 -0
  63. package/dist/types/atlas.d.ts +90 -0
  64. package/dist/types/atlas.js +1 -0
  65. package/dist/types/authoring.d.ts +81 -0
  66. package/dist/types/authoring.js +1 -0
  67. package/dist/types/core.d.ts +128 -0
  68. package/dist/types/core.js +1 -0
  69. package/dist/types/freeType.d.ts +54 -0
  70. package/dist/types/freeType.js +13 -0
  71. package/dist/types/glyph.d.ts +33 -0
  72. package/dist/types/glyph.js +1 -0
  73. package/dist/types/layout.d.ts +25 -0
  74. package/dist/types/layout.js +1 -0
  75. package/dist/types/text.d.ts +28 -0
  76. package/dist/types/text.js +1 -0
  77. package/dist/worker/glyphWorkScheduler.d.ts +29 -0
  78. package/dist/worker/glyphWorkScheduler.js +107 -0
  79. package/dist/worker-client.d.ts +114 -0
  80. package/dist/worker-client.js +413 -0
  81. package/dist/worker.d.ts +1 -0
  82. package/dist/worker.js +708 -0
  83. package/package.json +46 -0
  84. package/src/atlas.rs +652 -0
  85. package/src/authoring.ts +42 -0
  86. package/src/authoring_runtime.rs +303 -0
  87. package/src/cache/glyphPersistentCache.ts +463 -0
  88. package/src/cache/indexedDbGlyphRecordStore.ts +238 -0
  89. package/src/cache/sessionImageResourceCache.ts +186 -0
  90. package/src/edt.rs +97 -0
  91. package/src/emscripten.ts +17 -0
  92. package/src/fontProvider.ts +127 -0
  93. package/src/fontSdfAtlas.ts +431 -0
  94. package/src/geometry.rs +149 -0
  95. package/src/glyph_plan.rs +226 -0
  96. package/src/gpu/browserSemanticResources.ts +294 -0
  97. package/src/gpu/generalTextRenderPlacement.ts +175 -0
  98. package/src/gpu/previewTransformTextureLayout.ts +12 -0
  99. package/src/gpu/semanticCommandGeometry.ts +260 -0
  100. package/src/gpu/semanticCommandPlanner.ts +280 -0
  101. package/src/gpu/semanticTextGlyphBridge.ts +35 -0
  102. package/src/gpu/semanticWebglSceneRenderer.ts +261 -0
  103. package/src/gpu/slotRanges.ts +15 -0
  104. package/src/gpu/webglSdfAtlasTexture.ts +69 -0
  105. package/src/gpu/webglSdfGlyphPipeline.ts +299 -0
  106. package/src/gpu/webglSemanticCommandExecutor.ts +739 -0
  107. package/src/index.ts +84 -0
  108. package/src/interaction/numericTextRegions.ts +80 -0
  109. package/src/layout.rs +1882 -0
  110. package/src/lib.rs +1443 -0
  111. package/src/localizationProvider.ts +113 -0
  112. package/src/main.rs +55 -0
  113. package/src/masterdata_runtime.rs +496 -0
  114. package/src/originPrebuiltSdfAtlasPackage.ts +403 -0
  115. package/src/prebuiltSdfAtlas.ts +306 -0
  116. package/src/protocol.ts +150 -0
  117. package/src/renderer.ts +792 -0
  118. package/src/resourceProvider.ts +69 -0
  119. package/src/scene.rs +665 -0
  120. package/src/telemetry/rendererTelemetry.ts +358 -0
  121. package/src/types/atlas.ts +80 -0
  122. package/src/types/authoring.ts +85 -0
  123. package/src/types/core.ts +110 -0
  124. package/src/types/freeType.ts +63 -0
  125. package/src/types/glyph.ts +33 -0
  126. package/src/types/layout.ts +28 -0
  127. package/src/types/text.ts +28 -0
  128. package/src/worker/glyphWorkScheduler.ts +130 -0
  129. package/src/worker-client.ts +484 -0
  130. package/src/worker.ts +895 -0
@@ -0,0 +1,261 @@
1
+ import { glyphKey } from "./fontSdfAtlas.js";
2
+ const MAX_DECODED_PAGES_PER_PROVIDER = 6;
3
+ const providerCaches = new WeakMap();
4
+ export function createHttpPrebuiltSdfAtlasProvider(baseUrl) {
5
+ const root = baseUrl.replace(/\/+$/, "");
6
+ const familyPath = (family) => encodeURIComponent(family);
7
+ return {
8
+ async manifest(family, { signal }) {
9
+ const response = await fetch(`${root}/${familyPath(family)}/manifest.json`, { signal, cache: "force-cache" });
10
+ if (response.status === 404)
11
+ return null;
12
+ if (!response.ok)
13
+ throw new Error(`prebuilt atlas manifest ${family}: HTTP ${response.status}`);
14
+ return response.json();
15
+ },
16
+ async page(family, file, { signal }) {
17
+ if (!/^page-\d{3}\.r8swz\.br$/.test(file))
18
+ throw new Error(`invalid prebuilt atlas page path ${file}`);
19
+ const response = await fetch(`${root}/${familyPath(family)}/${file}`, { signal, cache: "force-cache" });
20
+ if (!response.ok)
21
+ throw new Error(`prebuilt atlas page ${family}/${file}: HTTP ${response.status}`);
22
+ return response.arrayBuffer();
23
+ },
24
+ };
25
+ }
26
+ export async function buildPrebuiltSdfAtlas(provider, requests, signal, maxPages = 6) {
27
+ const families = [...new Set(requests.map((request) => request.family))];
28
+ const manifests = new Map();
29
+ for (const family of families) {
30
+ const manifest = await cachedManifest(provider, family, signal);
31
+ if (!manifest || !isValidPrebuiltSdfAtlasManifest(manifest, family))
32
+ return null;
33
+ manifests.set(family, manifest);
34
+ }
35
+ const glyphByFamily = new Map([...manifests].map(([family, manifest]) => [
36
+ family,
37
+ new Map(manifest.glyphs.map((glyph) => [glyph.codepoint, glyph])),
38
+ ]));
39
+ const resolved = requests.map((request) => {
40
+ const codepoint = singleCodepoint(request.char);
41
+ const glyph = codepoint == null ? undefined : glyphByFamily.get(request.family)?.get(codepoint);
42
+ return glyph ? { request, glyph } : null;
43
+ });
44
+ if (resolved.some((entry) => entry == null))
45
+ return null;
46
+ const sourcePages = [...new Map(resolved.map((entry) => {
47
+ const value = entry;
48
+ const key = `${value.request.family}\0${value.glyph.page}`;
49
+ return [key, { family: value.request.family, sourcePage: value.glyph.page }];
50
+ })).values()];
51
+ if (sourcePages.length > maxPages)
52
+ return null;
53
+ const compactPage = new Map(sourcePages.map((page, index) => [`${page.family}\0${page.sourcePage}`, index]));
54
+ const pagePromises = new Map();
55
+ const controller = new AbortController();
56
+ const combined = combineSignals(signal, controller.signal);
57
+ let released = false;
58
+ const pagePixels = (page) => {
59
+ const cached = pagePromises.get(page);
60
+ if (cached)
61
+ return cached;
62
+ const source = sourcePages[page];
63
+ const manifest = manifests.get(source.family);
64
+ const descriptor = manifest.pages[source.sourcePage];
65
+ const promise = cachedDecodedPage(provider, source.family, descriptor, combined.signal);
66
+ pagePromises.set(page, promise);
67
+ return promise;
68
+ };
69
+ const glyphs = new Map(resolved.map((entry) => {
70
+ const { request, glyph } = entry;
71
+ const manifest = manifests.get(request.family);
72
+ const descriptor = manifest.pages[glyph.page];
73
+ const page = compactPage.get(`${request.family}\0${glyph.page}`);
74
+ const [x, y, width, height] = glyph.rect;
75
+ const key = glyphKey(request.region, request.fontSourceHash, request.family, request.char);
76
+ return [key, {
77
+ key,
78
+ resourceId: `prebuilt:${manifest.font_sha256}:${glyph.codepoint}`,
79
+ glyphIndex: glyph.codepoint,
80
+ page,
81
+ pageEpoch: 1,
82
+ region: request.region,
83
+ family: request.family,
84
+ fontSourceHash: request.fontSourceHash,
85
+ char: request.char,
86
+ u0: x / descriptor.width,
87
+ v0: y / descriptor.height,
88
+ u1: (x + width) / descriptor.width,
89
+ v1: (y + height) / descriptor.height,
90
+ width,
91
+ height,
92
+ advance: glyph.plane_advance_x,
93
+ xOffset: glyph.plane_bearing[0],
94
+ yOffset: glyph.plane_bearing[1],
95
+ planeBearingX: glyph.plane_bearing[0],
96
+ planeBearingY: glyph.plane_bearing[1],
97
+ planeWidth: glyph.plane_size[0],
98
+ planeHeight: glyph.plane_size[1],
99
+ drawable: width > 0 && height > 0,
100
+ }];
101
+ }));
102
+ const first = manifests.values().next().value;
103
+ const contractId = `prebuilt:${[...manifests.values()].map((manifest) => manifest.font_sha256).join(":")}:${sourcePages.map((page) => `${page.family}:${page.sourcePage}`).join(",")}`;
104
+ return {
105
+ width: 2048,
106
+ height: 2048,
107
+ depth: sourcePages.length,
108
+ baseSize: first.point_size,
109
+ spread: first.spread,
110
+ glyphs,
111
+ missing: [],
112
+ backend: "freetype-wasm",
113
+ sdfBackend: "edt",
114
+ contractId,
115
+ fontEngineFingerprint: first.generator_contract,
116
+ perf: {
117
+ backend: "edt",
118
+ fontBatches: [],
119
+ totalGlyphMs: 0,
120
+ totalFaceLoadMs: 0,
121
+ totalGlyphCount: 0,
122
+ totalPixelCount: 0,
123
+ worker: emptyWorkerStats(),
124
+ cache: {
125
+ hits: glyphs.size, misses: 0, generations: 0, bytes: sourcePages.length * 2048 * 2048,
126
+ sessionHits: glyphs.size, persistentHits: 0, persistentMisses: 0,
127
+ persistentWritesQueued: 0, pages: sourcePages.length, pinnedPages: sourcePages.length, pageEvictions: 0,
128
+ },
129
+ },
130
+ async pageUpdates(revisions) {
131
+ const updates = [];
132
+ for (let page = 0; page < sourcePages.length; page += 1) {
133
+ if ((revisions.get(page) ?? 0) >= 1)
134
+ continue;
135
+ updates.push({
136
+ page, pageWidth: 2048, pageEpoch: 1, revision: 1, fullUpload: true,
137
+ pixels: await pagePixels(page), dirtyRects: [],
138
+ });
139
+ }
140
+ return updates;
141
+ },
142
+ async release() {
143
+ if (released)
144
+ return;
145
+ released = true;
146
+ controller.abort();
147
+ combined.dispose();
148
+ pagePromises.clear();
149
+ },
150
+ };
151
+ }
152
+ function providerCache(provider) {
153
+ let cache = providerCaches.get(provider);
154
+ if (!cache) {
155
+ cache = { manifests: new Map(), decodedPages: new Map() };
156
+ providerCaches.set(provider, cache);
157
+ }
158
+ return cache;
159
+ }
160
+ async function cachedManifest(provider, family, signal) {
161
+ if (signal.aborted)
162
+ throw abortReason(signal);
163
+ const cache = providerCache(provider).manifests;
164
+ if (cache.has(family))
165
+ return cache.get(family) ?? null;
166
+ const manifest = await provider.manifest(family, { signal });
167
+ if (!signal.aborted)
168
+ cache.set(family, manifest);
169
+ return manifest;
170
+ }
171
+ async function cachedDecodedPage(provider, family, descriptor, signal) {
172
+ if (signal.aborted)
173
+ throw abortReason(signal);
174
+ const cache = providerCache(provider).decodedPages;
175
+ const key = `${family}\0${descriptor.file}\0${descriptor.file_sha256}`;
176
+ const cached = cache.get(key);
177
+ if (cached) {
178
+ cache.delete(key);
179
+ cache.set(key, cached);
180
+ return cached;
181
+ }
182
+ const buffer = await provider.page(family, descriptor.file, { signal });
183
+ const bytes = new Uint8Array(buffer);
184
+ await verifySha256(bytes, descriptor.file_sha256);
185
+ if (signal.aborted)
186
+ throw abortReason(signal);
187
+ const decoded = unswizzleR8(bytes, descriptor.width, descriptor.height);
188
+ cache.set(key, decoded);
189
+ while (cache.size > MAX_DECODED_PAGES_PER_PROVIDER) {
190
+ const oldest = cache.keys().next().value;
191
+ if (oldest == null)
192
+ break;
193
+ cache.delete(oldest);
194
+ }
195
+ return decoded;
196
+ }
197
+ function abortReason(signal) {
198
+ return signal.reason ?? new DOMException("The operation was aborted", "AbortError");
199
+ }
200
+ export function isValidPrebuiltSdfAtlasManifest(manifest, family) {
201
+ return manifest.schema === "allium.sdf-atlas-manifest.v1"
202
+ && manifest.font_family === family
203
+ && manifest.font_sha256.length === 64
204
+ && Number.isFinite(manifest.point_size) && manifest.point_size > 0
205
+ && Number.isFinite(manifest.spread) && manifest.spread > 0
206
+ && manifest.pages.length > 0
207
+ && manifest.pages.every((page) => page.width === 2048 && page.height === 2048 && /^page-\d{3}\.r8swz\.br$/.test(page.file));
208
+ }
209
+ function singleCodepoint(value) {
210
+ const values = [...value];
211
+ return values.length === 1 ? values[0].codePointAt(0) ?? null : null;
212
+ }
213
+ function unswizzleR8(bytes, width, height) {
214
+ const header = 64;
215
+ const payloadLength = width * height;
216
+ if (bytes.byteLength !== header + payloadLength)
217
+ throw new Error(`invalid R8SWZ page length ${bytes.byteLength}`);
218
+ if (new TextDecoder().decode(bytes.subarray(0, 10)) !== "ALLIUMSWZ8")
219
+ throw new Error("invalid R8SWZ page magic");
220
+ const output = new Uint8Array(payloadLength);
221
+ const blocksPerRow = width / 8;
222
+ for (let y = 0; y < height; y += 1) {
223
+ const blockY = Math.floor(y / 8);
224
+ const inY = y % 8;
225
+ for (let x = 0; x < width; x += 1) {
226
+ const block = blockY * blocksPerRow + Math.floor(x / 8);
227
+ output[y * width + x] = bytes[header + block * 64 + inY * 8 + (x % 8)];
228
+ }
229
+ }
230
+ return output;
231
+ }
232
+ async function verifySha256(bytes, expected) {
233
+ const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", bytes.slice().buffer));
234
+ const actual = [...digest].map((value) => value.toString(16).padStart(2, "0")).join("");
235
+ if (actual !== expected.toLowerCase())
236
+ throw new Error(`prebuilt atlas page hash mismatch: expected ${expected}, got ${actual}`);
237
+ }
238
+ function combineSignals(first, second) {
239
+ const controller = new AbortController();
240
+ const abort = (event) => controller.abort(event.target.reason);
241
+ first.addEventListener("abort", abort, { once: true });
242
+ second.addEventListener("abort", abort, { once: true });
243
+ if (first.aborted)
244
+ controller.abort(first.reason);
245
+ else if (second.aborted)
246
+ controller.abort(second.reason);
247
+ return {
248
+ signal: controller.signal,
249
+ dispose() {
250
+ first.removeEventListener("abort", abort);
251
+ second.removeEventListener("abort", abort);
252
+ },
253
+ };
254
+ }
255
+ function emptyWorkerStats() {
256
+ return {
257
+ protocol: "allium.renderer-worker/2",
258
+ initialized: true, scenes: 0, masterDataSessions: 0, atlasSessions: 0,
259
+ authoringSessions: 0, fonts: 0, requests: 0, failures: 0, wasmMs: 0, bridgeBytes: 0,
260
+ };
261
+ }
@@ -0,0 +1,456 @@
1
+ import type { CoreSceneCreateResponse, CoreSceneDelta, CoreSceneDump, StableId } from "./types/core.js";
2
+ import type { FreeTypeGlyphBatch, FreeTypeGlyphMapBatch } from "./types/freeType.js";
3
+ import type { WasmGlyphDemandBatch, WasmLayoutBatch } from "./types/layout.js";
4
+ import type { AtlasGenerateRequest, AtlasGlyphRecord, AtlasPageUpdate, GlyphRasterPlan, AtlasResolveResult, AtlasStats } from "./types/atlas.js";
5
+ import type { AuthoringCheckpoint, AuthoringCommand, AuthoringDelta, AuthoringSelection, GameProfileDocument } from "./types/authoring.js";
6
+ export declare const RENDERER_WORKER_PROTOCOL: "allium.renderer-worker/2";
7
+ export type RendererWorkerInit = {
8
+ moduleUrl: string;
9
+ wasmUrl?: string;
10
+ };
11
+ export type RegisteredFont = {
12
+ region: string;
13
+ family: string;
14
+ sourceHash: string;
15
+ bytes: ArrayBuffer;
16
+ };
17
+ export type GlyphBatchRequest = {
18
+ region: string;
19
+ family: string;
20
+ sourceHash: string;
21
+ chars: string[];
22
+ backend?: "edt" | "analytic";
23
+ supersample?: number;
24
+ };
25
+ export type RendererFontContract = {
26
+ font_engine_fingerprint: string;
27
+ freetype_version: string;
28
+ modules: string[];
29
+ load_contract: string;
30
+ };
31
+ export type LayerMaskOverride = {
32
+ layerId: StableId;
33
+ visible: boolean | null;
34
+ };
35
+ export type RendererWorkerStats = {
36
+ protocol: typeof RENDERER_WORKER_PROTOCOL;
37
+ initialized: boolean;
38
+ scenes: number;
39
+ masterDataSessions: number;
40
+ atlasSessions: number;
41
+ authoringSessions: number;
42
+ fonts: number;
43
+ requests: number;
44
+ failures: number;
45
+ wasmMs: number;
46
+ bridgeBytes: number;
47
+ };
48
+ export type RendererWorkerRequest = {
49
+ id: number;
50
+ kind: "init";
51
+ payload: RendererWorkerInit;
52
+ } | {
53
+ id: number;
54
+ kind: "contract";
55
+ payload: Record<string, never>;
56
+ } | {
57
+ id: number;
58
+ kind: "registerFont";
59
+ payload: RegisteredFont;
60
+ } | {
61
+ id: number;
62
+ kind: "mapGlyphs";
63
+ payload: GlyphBatchRequest;
64
+ } | {
65
+ id: number;
66
+ kind: "planGlyphs";
67
+ payload: GlyphBatchRequest;
68
+ } | {
69
+ id: number;
70
+ kind: "buildGlyphs";
71
+ payload: GlyphBatchRequest;
72
+ } | {
73
+ id: number;
74
+ kind: "createAtlas";
75
+ payload: {
76
+ pageWidth?: number;
77
+ pageHeight?: number;
78
+ softPages?: number;
79
+ hardPages?: number;
80
+ };
81
+ } | {
82
+ id: number;
83
+ kind: "resolveAtlas";
84
+ payload: {
85
+ atlasId: string;
86
+ keys: string[];
87
+ cached: AtlasGlyphRecord[];
88
+ generate: AtlasGenerateRequest[];
89
+ };
90
+ } | {
91
+ id: number;
92
+ kind: "atlasPages";
93
+ payload: {
94
+ atlasId: string;
95
+ revisions: Array<{
96
+ page: number;
97
+ revision: number;
98
+ }>;
99
+ };
100
+ } | {
101
+ id: number;
102
+ kind: "releaseAtlas";
103
+ payload: {
104
+ atlasId: string;
105
+ lease: number;
106
+ };
107
+ } | {
108
+ id: number;
109
+ kind: "destroyAtlas";
110
+ payload: {
111
+ atlasId: string;
112
+ };
113
+ } | {
114
+ id: number;
115
+ kind: "createAuthoringBlank";
116
+ payload: Record<string, never>;
117
+ } | {
118
+ id: number;
119
+ kind: "importAuthoringProfile";
120
+ payload: {
121
+ profile: unknown;
122
+ };
123
+ } | {
124
+ id: number;
125
+ kind: "restoreAuthoringCheckpoint";
126
+ payload: {
127
+ checkpoint: AuthoringCheckpoint;
128
+ };
129
+ } | {
130
+ id: number;
131
+ kind: "applyAuthoring";
132
+ payload: {
133
+ authoringId: string;
134
+ command: AuthoringCommand;
135
+ };
136
+ } | {
137
+ id: number;
138
+ kind: "selectAuthoring";
139
+ payload: {
140
+ authoringId: string;
141
+ id: number | null;
142
+ };
143
+ } | {
144
+ id: number;
145
+ kind: "elementsAuthoring";
146
+ payload: {
147
+ authoringId: string;
148
+ };
149
+ } | {
150
+ id: number;
151
+ kind: "beginAuthoringGesture";
152
+ payload: {
153
+ authoringId: string;
154
+ id: number;
155
+ };
156
+ } | {
157
+ id: number;
158
+ kind: "previewAuthoringGesture";
159
+ payload: {
160
+ authoringId: string;
161
+ command: AuthoringCommand;
162
+ };
163
+ } | {
164
+ id: number;
165
+ kind: "commitAuthoringGesture";
166
+ payload: {
167
+ authoringId: string;
168
+ };
169
+ } | {
170
+ id: number;
171
+ kind: "cancelAuthoringGesture";
172
+ payload: {
173
+ authoringId: string;
174
+ };
175
+ } | {
176
+ id: number;
177
+ kind: "appendAuthoringPage";
178
+ payload: {
179
+ authoringId: string;
180
+ };
181
+ } | {
182
+ id: number;
183
+ kind: "duplicateAuthoringPage";
184
+ payload: {
185
+ authoringId: string;
186
+ page: number;
187
+ };
188
+ } | {
189
+ id: number;
190
+ kind: "deleteAuthoringPage";
191
+ payload: {
192
+ authoringId: string;
193
+ page: number;
194
+ };
195
+ } | {
196
+ id: number;
197
+ kind: "moveAuthoringPage";
198
+ payload: {
199
+ authoringId: string;
200
+ fromPage: number;
201
+ page: number;
202
+ };
203
+ } | {
204
+ id: number;
205
+ kind: "undoAuthoring";
206
+ payload: {
207
+ authoringId: string;
208
+ };
209
+ } | {
210
+ id: number;
211
+ kind: "redoAuthoring";
212
+ payload: {
213
+ authoringId: string;
214
+ };
215
+ } | {
216
+ id: number;
217
+ kind: "exportAuthoring";
218
+ payload: {
219
+ authoringId: string;
220
+ };
221
+ } | {
222
+ id: number;
223
+ kind: "checkpointAuthoring";
224
+ payload: {
225
+ authoringId: string;
226
+ };
227
+ } | {
228
+ id: number;
229
+ kind: "destroyAuthoring";
230
+ payload: {
231
+ authoringId: string;
232
+ };
233
+ } | {
234
+ id: number;
235
+ kind: "layoutText";
236
+ payload: {
237
+ request: unknown;
238
+ };
239
+ } | {
240
+ id: number;
241
+ kind: "glyphDemand";
242
+ payload: {
243
+ request: unknown;
244
+ };
245
+ } | {
246
+ id: number;
247
+ kind: "createMasterData";
248
+ payload: {
249
+ region: string;
250
+ revision: string;
251
+ };
252
+ } | {
253
+ id: number;
254
+ kind: "putMasterDataTable";
255
+ payload: {
256
+ masterDataId: string;
257
+ name: string;
258
+ table: unknown;
259
+ };
260
+ } | {
261
+ id: number;
262
+ kind: "sealMasterData";
263
+ payload: {
264
+ masterDataId: string;
265
+ };
266
+ } | {
267
+ id: number;
268
+ kind: "prepareProfile";
269
+ payload: {
270
+ masterDataId: string;
271
+ request: unknown;
272
+ };
273
+ } | {
274
+ id: number;
275
+ kind: "createProfileScene";
276
+ payload: {
277
+ masterDataId: string;
278
+ request: unknown;
279
+ layoutRequest: unknown;
280
+ };
281
+ } | {
282
+ id: number;
283
+ kind: "destroyMasterData";
284
+ payload: {
285
+ masterDataId: string;
286
+ };
287
+ } | {
288
+ id: number;
289
+ kind: "createScene";
290
+ payload: {
291
+ request: unknown;
292
+ };
293
+ } | {
294
+ id: number;
295
+ kind: "advance";
296
+ payload: {
297
+ sceneId: string;
298
+ tick: number;
299
+ };
300
+ } | {
301
+ id: number;
302
+ kind: "setLayerMask";
303
+ payload: {
304
+ sceneId: string;
305
+ layerId: StableId;
306
+ visible: boolean;
307
+ };
308
+ } | {
309
+ id: number;
310
+ kind: "setLayerMasks";
311
+ payload: {
312
+ sceneId: string;
313
+ expectedLayerTableRevision: number;
314
+ overrides: LayerMaskOverride[];
315
+ };
316
+ } | {
317
+ id: number;
318
+ kind: "setTab";
319
+ payload: {
320
+ sceneId: string;
321
+ controlId: StableId;
322
+ value: string;
323
+ };
324
+ } | {
325
+ id: number;
326
+ kind: "scroll";
327
+ payload: {
328
+ sceneId: string;
329
+ controlId: StableId;
330
+ offset?: number;
331
+ delta?: number;
332
+ };
333
+ } | {
334
+ id: number;
335
+ kind: "dumpScene";
336
+ payload: {
337
+ sceneId: string;
338
+ };
339
+ } | {
340
+ id: number;
341
+ kind: "destroyScene";
342
+ payload: {
343
+ sceneId: string;
344
+ };
345
+ } | {
346
+ id: number;
347
+ kind: "stats";
348
+ payload: Record<string, never>;
349
+ };
350
+ export type RendererWorkerResult = {
351
+ kind: "init";
352
+ protocol: typeof RENDERER_WORKER_PROTOCOL;
353
+ } | {
354
+ kind: "contract";
355
+ contract: RendererFontContract;
356
+ } | {
357
+ kind: "registerFont";
358
+ registered: boolean;
359
+ } | {
360
+ kind: "mapGlyphs";
361
+ batch: FreeTypeGlyphMapBatch;
362
+ } | {
363
+ kind: "planGlyphs";
364
+ plan: GlyphRasterPlan;
365
+ } | {
366
+ kind: "buildGlyphs";
367
+ batch: FreeTypeGlyphBatch;
368
+ } | {
369
+ kind: "createAtlas";
370
+ atlasId: string;
371
+ stats: AtlasStats;
372
+ } | {
373
+ kind: "resolveAtlas";
374
+ result: AtlasResolveResult;
375
+ } | {
376
+ kind: "atlasPages";
377
+ updates: AtlasPageUpdate[];
378
+ } | {
379
+ kind: "releaseAtlas";
380
+ released: boolean;
381
+ } | {
382
+ kind: "destroyAtlas";
383
+ destroyed: boolean;
384
+ } | {
385
+ kind: "createAuthoring";
386
+ authoringId: string;
387
+ document: GameProfileDocument;
388
+ revision: number;
389
+ } | {
390
+ kind: "authoringDelta";
391
+ delta: AuthoringDelta | null;
392
+ } | {
393
+ kind: "elementsAuthoring";
394
+ elements: AuthoringSelection[];
395
+ } | {
396
+ kind: "exportAuthoring";
397
+ document: GameProfileDocument;
398
+ } | {
399
+ kind: "checkpointAuthoring";
400
+ checkpoint: AuthoringCheckpoint;
401
+ } | {
402
+ kind: "destroyAuthoring";
403
+ destroyed: boolean;
404
+ } | {
405
+ kind: "layoutText";
406
+ batch: WasmLayoutBatch;
407
+ } | {
408
+ kind: "glyphDemand";
409
+ batch: WasmGlyphDemandBatch;
410
+ } | {
411
+ kind: "createMasterData";
412
+ masterDataId: string;
413
+ report: Record<string, unknown>;
414
+ } | {
415
+ kind: "masterDataReport";
416
+ report: Record<string, unknown>;
417
+ } | {
418
+ kind: "prepareProfile";
419
+ preparation: Record<string, unknown>;
420
+ } | {
421
+ kind: "destroyMasterData";
422
+ destroyed: boolean;
423
+ } | {
424
+ kind: "createProfileScene";
425
+ sceneId: string;
426
+ response: CoreSceneCreateResponse;
427
+ layout: WasmLayoutBatch;
428
+ } | {
429
+ kind: "createScene";
430
+ sceneId: string;
431
+ response: CoreSceneCreateResponse;
432
+ } | {
433
+ kind: "delta";
434
+ delta: CoreSceneDelta;
435
+ } | {
436
+ kind: "dumpScene";
437
+ dump: CoreSceneDump;
438
+ } | {
439
+ kind: "destroyScene";
440
+ destroyed: boolean;
441
+ } | {
442
+ kind: "stats";
443
+ stats: RendererWorkerStats;
444
+ };
445
+ export type RendererWorkerResponse = {
446
+ id: number;
447
+ ok: true;
448
+ result: RendererWorkerResult;
449
+ } | {
450
+ id: number;
451
+ ok: false;
452
+ error: {
453
+ code: string;
454
+ message: string;
455
+ };
456
+ };
@@ -0,0 +1 @@
1
+ export const RENDERER_WORKER_PROTOCOL = "allium.renderer-worker/2";