@protoc-gen-go-wasmjs/runtime 0.0.14

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/dist/index.mjs ADDED
@@ -0,0 +1,753 @@
1
+ // src/browser/service-manager.ts
2
+ var BrowserServiceManager = class {
3
+ constructor() {
4
+ this.processing = false;
5
+ this.serviceImplementations = /* @__PURE__ */ new Map();
6
+ }
7
+ /**
8
+ * Register a browser service implementation
9
+ */
10
+ registerService(name, implementation) {
11
+ this.serviceImplementations.set(name, implementation);
12
+ }
13
+ /**
14
+ * Set the WASM module reference
15
+ */
16
+ setWasmModule(wasmModule) {
17
+ this.wasmModule = wasmModule;
18
+ }
19
+ /**
20
+ * Start processing browser service calls
21
+ */
22
+ async startProcessing() {
23
+ if (this.processing) return;
24
+ this.processing = true;
25
+ while (this.processing) {
26
+ const call = this.getNextBrowserCall();
27
+ if (!call) {
28
+ await new Promise((resolve) => setTimeout(resolve, 10));
29
+ continue;
30
+ }
31
+ this.processCall(call);
32
+ }
33
+ }
34
+ /**
35
+ * Process a single browser service call asynchronously
36
+ */
37
+ async processCall(call) {
38
+ try {
39
+ const service = this.serviceImplementations.get(call.service);
40
+ if (!service) {
41
+ throw new Error(`No implementation registered for service: ${call.service}`);
42
+ }
43
+ const methodName = call.method.charAt(0).toLowerCase() + call.method.slice(1);
44
+ const method = service[methodName];
45
+ if (!method) {
46
+ throw new Error(`Method ${methodName} not found on service ${call.service}`);
47
+ }
48
+ const request = JSON.parse(call.request);
49
+ const response = await Promise.resolve(method.call(service, request));
50
+ console.log(`DEBUG: Browser service response for ${call.service}.${call.method}:`, response);
51
+ const jsonResponse = JSON.stringify(response);
52
+ console.log(`DEBUG: JSON stringified response:`, jsonResponse);
53
+ this.deliverBrowserResponse(call.id, jsonResponse, null);
54
+ } catch (error) {
55
+ this.deliverBrowserResponse(call.id, null, error.message || String(error));
56
+ }
57
+ }
58
+ /**
59
+ * Stop processing browser service calls
60
+ */
61
+ stopProcessing() {
62
+ this.processing = false;
63
+ }
64
+ /**
65
+ * Get the next browser call from WASM
66
+ */
67
+ getNextBrowserCall() {
68
+ if (typeof window.__wasmGetNextBrowserCall === "function") {
69
+ return window.__wasmGetNextBrowserCall();
70
+ }
71
+ return null;
72
+ }
73
+ /**
74
+ * Deliver a response back to WASM (called internally)
75
+ */
76
+ deliverBrowserResponse(callId, response, error) {
77
+ if (!window.__wasmDeliverBrowserResponse) {
78
+ return false;
79
+ }
80
+ return window.__wasmDeliverBrowserResponse(callId, response, error);
81
+ }
82
+ };
83
+
84
+ // src/schema/types.ts
85
+ var FieldType = /* @__PURE__ */ ((FieldType2) => {
86
+ FieldType2["STRING"] = "string";
87
+ FieldType2["NUMBER"] = "number";
88
+ FieldType2["BOOLEAN"] = "boolean";
89
+ FieldType2["MESSAGE"] = "message";
90
+ FieldType2["REPEATED"] = "repeated";
91
+ FieldType2["MAP"] = "map";
92
+ FieldType2["ONEOF"] = "oneof";
93
+ return FieldType2;
94
+ })(FieldType || {});
95
+
96
+ // src/schema/base-deserializer.ts
97
+ var BaseDeserializer = class {
98
+ constructor(schemaRegistry, factory) {
99
+ this.schemaRegistry = schemaRegistry;
100
+ this.factory = factory;
101
+ }
102
+ /**
103
+ * Deserialize an object using schema information
104
+ * @param instance The target instance to populate
105
+ * @param data The source data to deserialize from
106
+ * @param messageType The fully qualified message type (e.g., "library.v1.Book")
107
+ * @returns The populated instance
108
+ */
109
+ deserialize(instance, data, messageType) {
110
+ if (!data || typeof data !== "object") {
111
+ return instance;
112
+ }
113
+ const schema = this.schemaRegistry[messageType];
114
+ if (!schema) {
115
+ return this.fallbackDeserialize(instance, data);
116
+ }
117
+ for (const fieldSchema of schema.fields) {
118
+ const fieldValue = data[fieldSchema.name];
119
+ if (fieldValue === null || fieldValue === void 0) {
120
+ continue;
121
+ }
122
+ this.deserializeField(instance, fieldSchema, fieldValue);
123
+ }
124
+ return instance;
125
+ }
126
+ /**
127
+ * Deserialize a single field based on its schema
128
+ */
129
+ deserializeField(instance, fieldSchema, fieldValue) {
130
+ const fieldName = fieldSchema.name;
131
+ switch (fieldSchema.type) {
132
+ case "string" /* STRING */:
133
+ case "number" /* NUMBER */:
134
+ case "boolean" /* BOOLEAN */:
135
+ instance[fieldName] = fieldValue;
136
+ break;
137
+ case "message" /* MESSAGE */:
138
+ if (fieldSchema.repeated) {
139
+ instance[fieldName] = this.deserializeMessageArray(
140
+ fieldValue,
141
+ fieldSchema.messageType,
142
+ instance,
143
+ fieldName
144
+ );
145
+ } else {
146
+ instance[fieldName] = this.deserializeMessageField(
147
+ fieldValue,
148
+ fieldSchema.messageType,
149
+ instance,
150
+ fieldName
151
+ );
152
+ }
153
+ break;
154
+ case "repeated" /* REPEATED */:
155
+ if (Array.isArray(fieldValue)) {
156
+ instance[fieldName] = [...fieldValue];
157
+ }
158
+ break;
159
+ case "oneof" /* ONEOF */:
160
+ instance[fieldName] = fieldValue;
161
+ break;
162
+ case "map" /* MAP */:
163
+ instance[fieldName] = { ...fieldValue };
164
+ break;
165
+ default:
166
+ instance[fieldName] = fieldValue;
167
+ break;
168
+ }
169
+ }
170
+ /**
171
+ * Deserialize a single message field
172
+ */
173
+ deserializeMessageField(fieldValue, messageType, parent, attributeName) {
174
+ let factoryMethod;
175
+ if (this.factory.getFactoryMethod) {
176
+ factoryMethod = this.factory.getFactoryMethod(messageType);
177
+ } else {
178
+ const factoryMethodName = this.getFactoryMethodName(messageType);
179
+ factoryMethod = this.factory[factoryMethodName];
180
+ }
181
+ if (factoryMethod) {
182
+ const result = factoryMethod(parent, attributeName, void 0, fieldValue);
183
+ if (result.fullyLoaded) {
184
+ return result.instance;
185
+ } else {
186
+ return this.deserialize(result.instance, fieldValue, messageType);
187
+ }
188
+ }
189
+ return this.fallbackDeserialize({}, fieldValue);
190
+ }
191
+ /**
192
+ * Deserialize an array of message objects
193
+ */
194
+ deserializeMessageArray(fieldValue, messageType, parent, attributeName) {
195
+ if (!Array.isArray(fieldValue)) {
196
+ return [];
197
+ }
198
+ let factoryMethod;
199
+ if (this.factory.getFactoryMethod) {
200
+ factoryMethod = this.factory.getFactoryMethod(messageType);
201
+ } else {
202
+ const factoryMethodName = this.getFactoryMethodName(messageType);
203
+ factoryMethod = this.factory[factoryMethodName];
204
+ }
205
+ return fieldValue.map((item, index) => {
206
+ if (factoryMethod) {
207
+ const result = factoryMethod(parent, attributeName, index, item);
208
+ if (result.fullyLoaded) {
209
+ return result.instance;
210
+ } else {
211
+ return this.deserialize(result.instance, item, messageType);
212
+ }
213
+ }
214
+ return this.fallbackDeserialize({}, item);
215
+ });
216
+ }
217
+ /**
218
+ * Convert message type to factory method name
219
+ * "library.v1.Book" -> "newBook"
220
+ */
221
+ getFactoryMethodName(messageType) {
222
+ const parts = messageType.split(".");
223
+ const typeName = parts[parts.length - 1];
224
+ return "new" + typeName;
225
+ }
226
+ /**
227
+ * Fallback deserializer for when no schema is available
228
+ */
229
+ fallbackDeserialize(instance, data) {
230
+ if (!data || typeof data !== "object") {
231
+ return instance;
232
+ }
233
+ for (const [key, value] of Object.entries(data)) {
234
+ if (value !== null && value !== void 0) {
235
+ instance[key] = value;
236
+ }
237
+ }
238
+ return instance;
239
+ }
240
+ /**
241
+ * Create and deserialize a new instance of a message type
242
+ */
243
+ createAndDeserialize(messageType, data) {
244
+ let factoryMethod;
245
+ if (this.factory.getFactoryMethod) {
246
+ factoryMethod = this.factory.getFactoryMethod(messageType);
247
+ } else {
248
+ const factoryMethodName = this.getFactoryMethodName(messageType);
249
+ factoryMethod = this.factory[factoryMethodName];
250
+ }
251
+ if (!factoryMethod) {
252
+ throw new Error(`Could not find factory method to deserialize: ${messageType}`);
253
+ }
254
+ const result = factoryMethod(void 0, void 0, void 0, data);
255
+ if (result.fullyLoaded) {
256
+ return result.instance;
257
+ } else {
258
+ return this.deserialize(result.instance, data, messageType);
259
+ }
260
+ }
261
+ };
262
+
263
+ // src/schema/base-registry.ts
264
+ var BaseSchemaRegistry = class {
265
+ constructor(schemaRegistry) {
266
+ this.schemaRegistry = schemaRegistry;
267
+ }
268
+ /**
269
+ * Get schema for a message type
270
+ */
271
+ getSchema(messageType) {
272
+ return this.schemaRegistry[messageType];
273
+ }
274
+ /**
275
+ * Get field schema by name
276
+ */
277
+ getFieldSchema(messageType, fieldName) {
278
+ const schema = this.getSchema(messageType);
279
+ return schema?.fields.find((field) => field.name === fieldName);
280
+ }
281
+ /**
282
+ * Get field schema by proto field ID
283
+ */
284
+ getFieldSchemaById(messageType, fieldId) {
285
+ const schema = this.getSchema(messageType);
286
+ return schema?.fields.find((field) => field.id === fieldId);
287
+ }
288
+ /**
289
+ * Check if field is part of a oneof group
290
+ */
291
+ isOneofField(messageType, fieldName) {
292
+ const fieldSchema = this.getFieldSchema(messageType, fieldName);
293
+ return fieldSchema?.oneofGroup !== void 0;
294
+ }
295
+ /**
296
+ * Get all fields in a oneof group
297
+ */
298
+ getOneofFields(messageType, oneofGroup) {
299
+ const schema = this.getSchema(messageType);
300
+ return schema?.fields.filter((field) => field.oneofGroup === oneofGroup) || [];
301
+ }
302
+ };
303
+
304
+ // src/client/types.ts
305
+ var WasmError = class extends Error {
306
+ constructor(message, methodPath) {
307
+ super(message);
308
+ this.methodPath = methodPath;
309
+ this.name = "WasmError";
310
+ }
311
+ };
312
+
313
+ // src/client/base-client.ts
314
+ var WASMServiceClient = class {
315
+ constructor() {
316
+ this.wasmLoadPromise = null;
317
+ this.browserServiceManager = null;
318
+ this.browserServiceManager = new BrowserServiceManager();
319
+ }
320
+ /**
321
+ * Register a browser service implementation
322
+ * Can be used to register browser services from any package
323
+ */
324
+ registerBrowserService(name, implementation) {
325
+ if (!this.browserServiceManager) {
326
+ throw new Error("Browser service manager not initialized");
327
+ }
328
+ this.browserServiceManager.registerService(name, implementation);
329
+ }
330
+ /**
331
+ * Check if WASM is ready for operations
332
+ */
333
+ isReady() {
334
+ return this.wasm !== null && this.wasm !== void 0;
335
+ }
336
+ /**
337
+ * Wait for WASM to be ready (use during initialization)
338
+ */
339
+ async waitUntilReady() {
340
+ if (!this.wasmLoadPromise) {
341
+ throw new Error("WASM loading not started. Call loadWasm() first.");
342
+ }
343
+ await this.wasmLoadPromise;
344
+ }
345
+ /**
346
+ * Internal method to call WASM functions with JSON conversion
347
+ */
348
+ callMethod(methodPath, request) {
349
+ this.ensureWASMLoaded();
350
+ try {
351
+ const jsonReq = JSON.parse(JSON.stringify(request));
352
+ const wasmMethod = this.getWasmMethod(methodPath);
353
+ const wasmResponse = wasmMethod(JSON.stringify(jsonReq));
354
+ if (!wasmResponse.success) {
355
+ throw new WasmError(wasmResponse.message, methodPath);
356
+ }
357
+ return wasmResponse.data;
358
+ } catch (error) {
359
+ if (error instanceof WasmError) {
360
+ throw error;
361
+ }
362
+ throw new WasmError(
363
+ `Call error: ${error instanceof Error ? error.message : String(error)}`,
364
+ methodPath
365
+ );
366
+ }
367
+ }
368
+ /**
369
+ * Internal method to call async WASM functions with callback
370
+ */
371
+ callMethodWithCallback(methodPath, request, callback) {
372
+ this.ensureWASMLoaded();
373
+ try {
374
+ const jsonReq = JSON.parse(JSON.stringify(request));
375
+ const wasmMethod = this.getWasmMethod(methodPath);
376
+ const wasmResponse = wasmMethod(JSON.stringify(jsonReq), callback);
377
+ if (!wasmResponse.success) {
378
+ throw new WasmError(wasmResponse.message, methodPath);
379
+ }
380
+ return Promise.resolve();
381
+ } catch (error) {
382
+ if (error instanceof WasmError) {
383
+ throw error;
384
+ }
385
+ throw new WasmError(
386
+ `Call error: ${error instanceof Error ? error.message : String(error)}`,
387
+ methodPath
388
+ );
389
+ }
390
+ }
391
+ /**
392
+ * Internal method to call server streaming WASM functions
393
+ */
394
+ callStreamingMethod(methodPath, request, callback) {
395
+ this.ensureWASMLoaded();
396
+ try {
397
+ const jsonReq = JSON.parse(JSON.stringify(request));
398
+ const wasmMethod = this.getWasmMethod(methodPath);
399
+ const wrappedCallback = (responseStr, error, done) => {
400
+ let response = null;
401
+ if (responseStr && !error) {
402
+ try {
403
+ response = JSON.parse(responseStr);
404
+ } catch (e) {
405
+ response = responseStr;
406
+ }
407
+ }
408
+ return callback(response, error, done);
409
+ };
410
+ const wasmResponse = wasmMethod(JSON.stringify(jsonReq), wrappedCallback);
411
+ if (!wasmResponse.success) {
412
+ throw new WasmError(wasmResponse.message, methodPath);
413
+ }
414
+ } catch (error) {
415
+ if (error instanceof WasmError) {
416
+ throw error;
417
+ }
418
+ throw new WasmError(
419
+ `Streaming call error: ${error instanceof Error ? error.message : String(error)}`,
420
+ methodPath
421
+ );
422
+ }
423
+ }
424
+ /**
425
+ * Ensure WASM module is loaded (synchronous version for service calls)
426
+ */
427
+ ensureWASMLoaded() {
428
+ if (!this.isReady()) {
429
+ throw new Error("WASM module not loaded. Call loadWasm() and waitUntilReady() first.");
430
+ }
431
+ }
432
+ /**
433
+ * Load the WASM module asynchronously
434
+ */
435
+ async loadWasm(wasmPath) {
436
+ if (this.wasmLoadPromise) {
437
+ return this.wasmLoadPromise;
438
+ }
439
+ this.wasmLoadPromise = this.loadWASMModule(wasmPath);
440
+ return this.wasmLoadPromise;
441
+ }
442
+ };
443
+
444
+ // src/client/wasm-bundle.ts
445
+ var WASMBundle = class {
446
+ constructor(config) {
447
+ this.wasm = null;
448
+ this.wasmLoadPromise = null;
449
+ this.browserServiceManager = null;
450
+ this.config = config;
451
+ this.browserServiceManager = new BrowserServiceManager();
452
+ }
453
+ /**
454
+ * Register a browser service implementation
455
+ */
456
+ registerBrowserService(name, implementation) {
457
+ if (!this.browserServiceManager) {
458
+ throw new Error("Browser service manager not initialized");
459
+ }
460
+ this.browserServiceManager.registerService(name, implementation);
461
+ }
462
+ /**
463
+ * Check if WASM is ready for operations
464
+ */
465
+ isReady() {
466
+ return this.wasm !== null && this.wasm !== void 0;
467
+ }
468
+ /**
469
+ * Wait for WASM to be ready (use during initialization)
470
+ */
471
+ async waitUntilReady() {
472
+ if (!this.wasmLoadPromise) {
473
+ throw new Error("WASM loading not started. Call loadWasm() first.");
474
+ }
475
+ await this.wasmLoadPromise;
476
+ }
477
+ /**
478
+ * Load the WASM module asynchronously (singleton pattern)
479
+ */
480
+ async loadWasm(wasmPath) {
481
+ if (this.wasmLoadPromise) {
482
+ return this.wasmLoadPromise;
483
+ }
484
+ this.wasmLoadPromise = this.loadWASMModule(wasmPath);
485
+ return this.wasmLoadPromise;
486
+ }
487
+ /**
488
+ * Get WASM method function by path
489
+ */
490
+ getWasmMethod(methodPath) {
491
+ this.ensureWASMLoaded();
492
+ switch (this.config.apiStructure) {
493
+ case "namespaced":
494
+ const parts = methodPath.split(".");
495
+ let current = this.wasm;
496
+ for (const part of parts) {
497
+ current = current[part];
498
+ if (!current) {
499
+ throw new Error(`Method not found: ${methodPath}`);
500
+ }
501
+ }
502
+ return current;
503
+ case "flat":
504
+ const method = this.wasm[methodPath];
505
+ if (!method) {
506
+ throw new Error(`Method not found: ${methodPath}`);
507
+ }
508
+ return method;
509
+ case "service_based":
510
+ const serviceParts = methodPath.split(".");
511
+ let serviceCurrent = this.wasm;
512
+ for (const part of serviceParts) {
513
+ serviceCurrent = serviceCurrent[part];
514
+ if (!serviceCurrent) {
515
+ throw new Error(`Method not found: ${methodPath}`);
516
+ }
517
+ }
518
+ return serviceCurrent;
519
+ default:
520
+ throw new Error(`Unsupported API structure: ${this.config.apiStructure}`);
521
+ }
522
+ }
523
+ /**
524
+ * Internal method to call WASM functions with JSON conversion
525
+ */
526
+ callMethod(methodPath, request) {
527
+ try {
528
+ const jsonReq = JSON.parse(JSON.stringify(request));
529
+ const wasmMethod = this.getWasmMethod(methodPath);
530
+ const wasmResponse = wasmMethod(JSON.stringify(jsonReq));
531
+ if (!wasmResponse.success) {
532
+ throw new WasmError(wasmResponse.message, methodPath);
533
+ }
534
+ return wasmResponse.data;
535
+ } catch (error) {
536
+ if (error instanceof WasmError) {
537
+ throw error;
538
+ }
539
+ throw new WasmError(
540
+ `Call error: ${error instanceof Error ? error.message : String(error)}`,
541
+ methodPath
542
+ );
543
+ }
544
+ }
545
+ /**
546
+ * Internal method to call async WASM functions with callback
547
+ */
548
+ callMethodWithCallback(methodPath, request, callback) {
549
+ try {
550
+ const jsonReq = JSON.parse(JSON.stringify(request));
551
+ const wasmMethod = this.getWasmMethod(methodPath);
552
+ const wasmResponse = wasmMethod(JSON.stringify(jsonReq), callback);
553
+ if (!wasmResponse.success) {
554
+ throw new WasmError(wasmResponse.message, methodPath);
555
+ }
556
+ return Promise.resolve();
557
+ } catch (error) {
558
+ if (error instanceof WasmError) {
559
+ throw error;
560
+ }
561
+ throw new WasmError(
562
+ `Call error: ${error instanceof Error ? error.message : String(error)}`,
563
+ methodPath
564
+ );
565
+ }
566
+ }
567
+ /**
568
+ * Internal method to call server streaming WASM functions
569
+ */
570
+ callStreamingMethod(methodPath, request, callback) {
571
+ try {
572
+ const jsonReq = JSON.parse(JSON.stringify(request));
573
+ const wasmMethod = this.getWasmMethod(methodPath);
574
+ const wrappedCallback = (responseStr, error, done) => {
575
+ let response = null;
576
+ if (responseStr && !error) {
577
+ try {
578
+ response = JSON.parse(responseStr);
579
+ } catch (e) {
580
+ response = responseStr;
581
+ }
582
+ }
583
+ return callback(response, error, done);
584
+ };
585
+ const wasmResponse = wasmMethod(JSON.stringify(jsonReq), wrappedCallback);
586
+ if (!wasmResponse.success) {
587
+ throw new WasmError(wasmResponse.message, methodPath);
588
+ }
589
+ } catch (error) {
590
+ if (error instanceof WasmError) {
591
+ throw error;
592
+ }
593
+ throw new WasmError(
594
+ `Streaming call error: ${error instanceof Error ? error.message : String(error)}`,
595
+ methodPath
596
+ );
597
+ }
598
+ }
599
+ /**
600
+ * Ensure WASM module is loaded (synchronous version for service calls)
601
+ */
602
+ ensureWASMLoaded() {
603
+ if (!this.isReady()) {
604
+ throw new Error("WASM module not loaded. Call loadWasm() and waitUntilReady() first.");
605
+ }
606
+ }
607
+ /**
608
+ * Load the WASM module implementation
609
+ */
610
+ async loadWASMModule(wasmPath) {
611
+ console.log(`Loading ${this.config.moduleName} WASM module...`);
612
+ if (this.checkIfPreLoaded()) {
613
+ console.log("WASM module already loaded (pre-loaded in test environment)");
614
+ return;
615
+ }
616
+ if (!window.Go) {
617
+ const script = document.createElement("script");
618
+ script.src = "/wasm_exec.js";
619
+ document.head.appendChild(script);
620
+ await new Promise((resolve, reject) => {
621
+ script.onload = () => resolve();
622
+ script.onerror = () => reject(new Error("Failed to load wasm_exec.js"));
623
+ });
624
+ }
625
+ const go = new window.Go();
626
+ const wasmModule = await WebAssembly.instantiateStreaming(
627
+ fetch(wasmPath),
628
+ go.importObject
629
+ );
630
+ go.run(wasmModule.instance);
631
+ if (this.browserServiceManager) {
632
+ this.browserServiceManager.setWasmModule(window);
633
+ this.browserServiceManager.startProcessing();
634
+ }
635
+ this.verifyWASMLoaded();
636
+ console.log(`${this.config.moduleName} WASM module loaded successfully`);
637
+ }
638
+ /**
639
+ * Check if WASM is pre-loaded (for testing)
640
+ */
641
+ checkIfPreLoaded() {
642
+ switch (this.config.apiStructure) {
643
+ case "namespaced":
644
+ if (window[this.config.jsNamespace]) {
645
+ this.wasm = window[this.config.jsNamespace];
646
+ return true;
647
+ }
648
+ return false;
649
+ case "flat":
650
+ if (window[this.config.jsNamespace + "LoadUserData"]) {
651
+ this.wasm = window;
652
+ return true;
653
+ }
654
+ return false;
655
+ case "service_based":
656
+ if (window.services) {
657
+ this.wasm = window.services;
658
+ return true;
659
+ }
660
+ return false;
661
+ default:
662
+ return false;
663
+ }
664
+ }
665
+ /**
666
+ * Verify WASM APIs are available after loading
667
+ */
668
+ verifyWASMLoaded() {
669
+ switch (this.config.apiStructure) {
670
+ case "namespaced":
671
+ if (!window[this.config.jsNamespace]) {
672
+ throw new Error("WASM APIs not found - module may not have loaded correctly");
673
+ }
674
+ this.wasm = window[this.config.jsNamespace];
675
+ break;
676
+ case "flat":
677
+ if (!window[this.config.jsNamespace + "LoadUserData"]) {
678
+ throw new Error("WASM APIs not found - module may not have loaded correctly");
679
+ }
680
+ this.wasm = window;
681
+ break;
682
+ case "service_based":
683
+ if (!window.services) {
684
+ throw new Error("WASM APIs not found - module may not have loaded correctly");
685
+ }
686
+ this.wasm = window.services;
687
+ break;
688
+ default:
689
+ throw new Error(`Unsupported API structure: ${this.config.apiStructure}`);
690
+ }
691
+ }
692
+ };
693
+
694
+ // src/client/service-client.ts
695
+ var ServiceClient = class {
696
+ constructor(bundle) {
697
+ this.bundle = bundle;
698
+ }
699
+ /**
700
+ * Check if the underlying WASM bundle is ready
701
+ */
702
+ isReady() {
703
+ return this.bundle.isReady();
704
+ }
705
+ /**
706
+ * Wait for the underlying WASM bundle to be ready
707
+ */
708
+ async waitUntilReady() {
709
+ return this.bundle.waitUntilReady();
710
+ }
711
+ /**
712
+ * Call a synchronous WASM method
713
+ */
714
+ callMethod(methodPath, request) {
715
+ return this.bundle.callMethod(methodPath, request);
716
+ }
717
+ /**
718
+ * Call an asynchronous WASM method with callback
719
+ */
720
+ callMethodWithCallback(methodPath, request, callback) {
721
+ return this.bundle.callMethodWithCallback(methodPath, request, callback);
722
+ }
723
+ /**
724
+ * Call a server streaming WASM method
725
+ */
726
+ callStreamingMethod(methodPath, request, callback) {
727
+ return this.bundle.callStreamingMethod(methodPath, request, callback);
728
+ }
729
+ };
730
+
731
+ // src/types/patches.ts
732
+ var PatchOperation = /* @__PURE__ */ ((PatchOperation2) => {
733
+ PatchOperation2["SET"] = "SET";
734
+ PatchOperation2["INSERT_LIST"] = "INSERT_LIST";
735
+ PatchOperation2["REMOVE_LIST"] = "REMOVE_LIST";
736
+ PatchOperation2["MOVE_LIST"] = "MOVE_LIST";
737
+ PatchOperation2["INSERT_MAP"] = "INSERT_MAP";
738
+ PatchOperation2["REMOVE_MAP"] = "REMOVE_MAP";
739
+ PatchOperation2["CLEAR_LIST"] = "CLEAR_LIST";
740
+ PatchOperation2["CLEAR_MAP"] = "CLEAR_MAP";
741
+ return PatchOperation2;
742
+ })(PatchOperation || {});
743
+ var PatchSource = /* @__PURE__ */ ((PatchSource2) => {
744
+ PatchSource2["LOCAL"] = "LOCAL";
745
+ PatchSource2["REMOTE"] = "REMOTE";
746
+ PatchSource2["SERVER"] = "SERVER";
747
+ PatchSource2["STORAGE"] = "STORAGE";
748
+ return PatchSource2;
749
+ })(PatchSource || {});
750
+
751
+ export { BaseDeserializer, BaseSchemaRegistry, BrowserServiceManager, FieldType, PatchOperation, PatchSource, ServiceClient, WASMBundle, WASMServiceClient, WasmError };
752
+ //# sourceMappingURL=index.mjs.map
753
+ //# sourceMappingURL=index.mjs.map