1"use strict";
2var __create = Object.create;
3var __defProp = Object.defineProperty;
4var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5var __getOwnPropNames = Object.getOwnPropertyNames;
6var __getProtoOf = Object.getPrototypeOf;
7var __hasOwnProp = Object.prototype.hasOwnProperty;
8var __export = (target, all) => {
9 for (var name in all)
10 __defProp(target, name, { get: all[name], enumerable: true });
11};
12var __copyProps = (to, from, except, desc) => {
13 if (from && typeof from === "object" || typeof from === "function") {
14 for (let key of __getOwnPropNames(from))
15 if (!__hasOwnProp.call(to, key) && key !== except)
16 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17 }
18 return to;
19};
20var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21 // If the importer is in node compatibility mode or this is not an ESM
22 // file that has been converted to a CommonJS file using a Babel-
23 // compatible transform (i.e. "__esModule" has not been set), then set
24 // "default" to the CommonJS "module.exports" for node compatibility.
25 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26 mod
27));
28var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
30// union_vector/union_vector.ts
31var union_vector_exports = {};
32__export(union_vector_exports, {
33 Attacker: () => Attacker,
34 AttackerT: () => AttackerT,
35 BookReader: () => BookReader,
36 BookReaderT: () => BookReaderT,
37 Character: () => Character,
38 FallingTub: () => FallingTub,
39 FallingTubT: () => FallingTubT,
40 Gadget: () => Gadget,
41 HandFan: () => HandFan,
42 HandFanT: () => HandFanT,
43 Movie: () => Movie,
44 MovieT: () => MovieT,
45 Rapunzel: () => Rapunzel,
46 RapunzelT: () => RapunzelT
47});
48module.exports = __toCommonJS(union_vector_exports);
49
50// union_vector/attacker.js
51var flatbuffers = __toESM(require("flatbuffers"), 1);
52var Attacker = class {
53 constructor() {
54 this.bb = null;
55 this.bb_pos = 0;
56 }
57 __init(i, bb) {
58 this.bb_pos = i;
59 this.bb = bb;
60 return this;
61 }
62 static getRootAsAttacker(bb, obj) {
63 return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
64 }
65 static getSizePrefixedRootAsAttacker(bb, obj) {
66 bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
67 return (obj || new Attacker()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
68 }
69 swordAttackDamage() {
70 const offset = this.bb.__offset(this.bb_pos, 4);
71 return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
72 }
73 mutate_sword_attack_damage(value) {
74 const offset = this.bb.__offset(this.bb_pos, 4);
75 if (offset === 0) {
76 return false;
77 }
78 this.bb.writeInt32(this.bb_pos + offset, value);
79 return true;
80 }
81 static getFullyQualifiedName() {
82 return "Attacker";
83 }
84 static startAttacker(builder) {
85 builder.startObject(1);
86 }
87 static addSwordAttackDamage(builder, swordAttackDamage) {
88 builder.addFieldInt32(0, swordAttackDamage, 0);
89 }
90 static endAttacker(builder) {
91 const offset = builder.endObject();
92 return offset;
93 }
94 static createAttacker(builder, swordAttackDamage) {
95 Attacker.startAttacker(builder);
96 Attacker.addSwordAttackDamage(builder, swordAttackDamage);
97 return Attacker.endAttacker(builder);
98 }
99 unpack() {
100 return new AttackerT(this.swordAttackDamage());
101 }
102 unpackTo(_o) {
103 _o.swordAttackDamage = this.swordAttackDamage();
104 }
105};
106var AttackerT = class {
107 constructor(swordAttackDamage = 0) {
108 this.swordAttackDamage = swordAttackDamage;
109 }
110 pack(builder) {
111 return Attacker.createAttacker(builder, this.swordAttackDamage);
112 }
113};
114
115// union_vector/book-reader.js
116var BookReader = class {
117 constructor() {
118 this.bb = null;
119 this.bb_pos = 0;
120 }
121 __init(i, bb) {
122 this.bb_pos = i;
123 this.bb = bb;
124 return this;
125 }
126 booksRead() {
127 return this.bb.readInt32(this.bb_pos);
128 }
129 mutate_books_read(value) {
130 this.bb.writeInt32(this.bb_pos + 0, value);
131 return true;
132 }
133 static getFullyQualifiedName() {
134 return "BookReader";
135 }
136 static sizeOf() {
137 return 4;
138 }
139 static createBookReader(builder, books_read) {
140 builder.prep(4, 4);
141 builder.writeInt32(books_read);
142 return builder.offset();
143 }
144 unpack() {
145 return new BookReaderT(this.booksRead());
146 }
147 unpackTo(_o) {
148 _o.booksRead = this.booksRead();
149 }
150};
151var BookReaderT = class {
152 constructor(booksRead = 0) {
153 this.booksRead = booksRead;
154 }
155 pack(builder) {
156 return BookReader.createBookReader(builder, this.booksRead);
157 }
158};
159
160// union_vector/rapunzel.js
161var Rapunzel = class {
162 constructor() {
163 this.bb = null;
164 this.bb_pos = 0;
165 }
166 __init(i, bb) {
167 this.bb_pos = i;
168 this.bb = bb;
169 return this;
170 }
171 hairLength() {
172 return this.bb.readInt32(this.bb_pos);
173 }
174 mutate_hair_length(value) {
175 this.bb.writeInt32(this.bb_pos + 0, value);
176 return true;
177 }
178 static getFullyQualifiedName() {
179 return "Rapunzel";
180 }
181 static sizeOf() {
182 return 4;
183 }
184 static createRapunzel(builder, hair_length) {
185 builder.prep(4, 4);
186 builder.writeInt32(hair_length);
187 return builder.offset();
188 }
189 unpack() {
190 return new RapunzelT(this.hairLength());
191 }
192 unpackTo(_o) {
193 _o.hairLength = this.hairLength();
194 }
195};
196var RapunzelT = class {
197 constructor(hairLength = 0) {
198 this.hairLength = hairLength;
199 }
200 pack(builder) {
201 return Rapunzel.createRapunzel(builder, this.hairLength);
202 }
203};
204
205// union_vector/character.js
206var Character;
207(function(Character2) {
208 Character2[Character2["NONE"] = 0] = "NONE";
209 Character2[Character2["MuLan"] = 1] = "MuLan";
210 Character2[Character2["Rapunzel"] = 2] = "Rapunzel";
211 Character2[Character2["Belle"] = 3] = "Belle";
212 Character2[Character2["BookFan"] = 4] = "BookFan";
213 Character2[Character2["Other"] = 5] = "Other";
214 Character2[Character2["Unused"] = 6] = "Unused";
215})(Character = Character || (Character = {}));
216function unionToCharacter(type, accessor) {
217 switch (Character[type]) {
218 case "NONE":
219 return null;
220 case "MuLan":
221 return accessor(new Attacker());
222 case "Rapunzel":
223 return accessor(new Rapunzel());
224 case "Belle":
225 return accessor(new BookReader());
226 case "BookFan":
227 return accessor(new BookReader());
228 case "Other":
229 return accessor("");
230 case "Unused":
231 return accessor("");
232 default:
233 return null;
234 }
235}
236function unionListToCharacter(type, accessor, index) {
237 switch (Character[type]) {
238 case "NONE":
239 return null;
240 case "MuLan":
241 return accessor(index, new Attacker());
242 case "Rapunzel":
243 return accessor(index, new Rapunzel());
244 case "Belle":
245 return accessor(index, new BookReader());
246 case "BookFan":
247 return accessor(index, new BookReader());
248 case "Other":
249 return accessor(index, "");
250 case "Unused":
251 return accessor(index, "");
252 default:
253 return null;
254 }
255}
256
257// union_vector/falling-tub.js
258var FallingTub = class {
259 constructor() {
260 this.bb = null;
261 this.bb_pos = 0;
262 }
263 __init(i, bb) {
264 this.bb_pos = i;
265 this.bb = bb;
266 return this;
267 }
268 weight() {
269 return this.bb.readInt32(this.bb_pos);
270 }
271 mutate_weight(value) {
272 this.bb.writeInt32(this.bb_pos + 0, value);
273 return true;
274 }
275 static getFullyQualifiedName() {
276 return "FallingTub";
277 }
278 static sizeOf() {
279 return 4;
280 }
281 static createFallingTub(builder, weight) {
282 builder.prep(4, 4);
283 builder.writeInt32(weight);
284 return builder.offset();
285 }
286 unpack() {
287 return new FallingTubT(this.weight());
288 }
289 unpackTo(_o) {
290 _o.weight = this.weight();
291 }
292};
293var FallingTubT = class {
294 constructor(weight = 0) {
295 this.weight = weight;
296 }
297 pack(builder) {
298 return FallingTub.createFallingTub(builder, this.weight);
299 }
300};
301
302// union_vector/hand-fan.js
303var flatbuffers2 = __toESM(require("flatbuffers"), 1);
304var HandFan = class {
305 constructor() {
306 this.bb = null;
307 this.bb_pos = 0;
308 }
309 __init(i, bb) {
310 this.bb_pos = i;
311 this.bb = bb;
312 return this;
313 }
314 static getRootAsHandFan(bb, obj) {
315 return (obj || new HandFan()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
316 }
317 static getSizePrefixedRootAsHandFan(bb, obj) {
318 bb.setPosition(bb.position() + flatbuffers2.SIZE_PREFIX_LENGTH);
319 return (obj || new HandFan()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
320 }
321 length() {
322 const offset = this.bb.__offset(this.bb_pos, 4);
323 return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
324 }
325 mutate_length(value) {
326 const offset = this.bb.__offset(this.bb_pos, 4);
327 if (offset === 0) {
328 return false;
329 }
330 this.bb.writeInt32(this.bb_pos + offset, value);
331 return true;
332 }
333 static getFullyQualifiedName() {
334 return "HandFan";
335 }
336 static startHandFan(builder) {
337 builder.startObject(1);
338 }
339 static addLength(builder, length) {
340 builder.addFieldInt32(0, length, 0);
341 }
342 static endHandFan(builder) {
343 const offset = builder.endObject();
344 return offset;
345 }
346 static createHandFan(builder, length) {
347 HandFan.startHandFan(builder);
348 HandFan.addLength(builder, length);
349 return HandFan.endHandFan(builder);
350 }
351 unpack() {
352 return new HandFanT(this.length());
353 }
354 unpackTo(_o) {
355 _o.length = this.length();
356 }
357};
358var HandFanT = class {
359 constructor(length = 0) {
360 this.length = length;
361 }
362 pack(builder) {
363 return HandFan.createHandFan(builder, this.length);
364 }
365};
366
367// union_vector/gadget.js
368var Gadget;
369(function(Gadget2) {
370 Gadget2[Gadget2["NONE"] = 0] = "NONE";
371 Gadget2[Gadget2["FallingTub"] = 1] = "FallingTub";
372 Gadget2[Gadget2["HandFan"] = 2] = "HandFan";
373})(Gadget = Gadget || (Gadget = {}));
374
375// union_vector/movie.js
376var flatbuffers3 = __toESM(require("flatbuffers"), 1);
377var Movie = class {
378 constructor() {
379 this.bb = null;
380 this.bb_pos = 0;
381 }
382 __init(i, bb) {
383 this.bb_pos = i;
384 this.bb = bb;
385 return this;
386 }
387 static getRootAsMovie(bb, obj) {
388 return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
389 }
390 static getSizePrefixedRootAsMovie(bb, obj) {
391 bb.setPosition(bb.position() + flatbuffers3.SIZE_PREFIX_LENGTH);
392 return (obj || new Movie()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
393 }
394 static bufferHasIdentifier(bb) {
395 return bb.__has_identifier("MOVI");
396 }
397 mainCharacterType() {
398 const offset = this.bb.__offset(this.bb_pos, 4);
399 return offset ? this.bb.readUint8(this.bb_pos + offset) : Character.NONE;
400 }
401 mainCharacter(obj) {
402 const offset = this.bb.__offset(this.bb_pos, 6);
403 return offset ? this.bb.__union_with_string(obj, this.bb_pos + offset) : null;
404 }
405 charactersType(index) {
406 const offset = this.bb.__offset(this.bb_pos, 8);
407 return offset ? this.bb.readUint8(this.bb.__vector(this.bb_pos + offset) + index) : 0;
408 }
409 charactersTypeLength() {
410 const offset = this.bb.__offset(this.bb_pos, 8);
411 return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
412 }
413 charactersTypeArray() {
414 const offset = this.bb.__offset(this.bb_pos, 8);
415 return offset ? new Uint8Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null;
416 }
417 characters(index, obj) {
418 const offset = this.bb.__offset(this.bb_pos, 10);
419 return offset ? this.bb.__union_with_string(obj, this.bb.__vector(this.bb_pos + offset) + index * 4) : null;
420 }
421 charactersLength() {
422 const offset = this.bb.__offset(this.bb_pos, 10);
423 return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
424 }
425 static getFullyQualifiedName() {
426 return "Movie";
427 }
428 static startMovie(builder) {
429 builder.startObject(4);
430 }
431 static addMainCharacterType(builder, mainCharacterType) {
432 builder.addFieldInt8(0, mainCharacterType, Character.NONE);
433 }
434 static addMainCharacter(builder, mainCharacterOffset) {
435 builder.addFieldOffset(1, mainCharacterOffset, 0);
436 }
437 static addCharactersType(builder, charactersTypeOffset) {
438 builder.addFieldOffset(2, charactersTypeOffset, 0);
439 }
440 static createCharactersTypeVector(builder, data) {
441 builder.startVector(1, data.length, 1);
442 for (let i = data.length - 1; i >= 0; i--) {
443 builder.addInt8(data[i]);
444 }
445 return builder.endVector();
446 }
447 static startCharactersTypeVector(builder, numElems) {
448 builder.startVector(1, numElems, 1);
449 }
450 static addCharacters(builder, charactersOffset) {
451 builder.addFieldOffset(3, charactersOffset, 0);
452 }
453 static createCharactersVector(builder, data) {
454 builder.startVector(4, data.length, 4);
455 for (let i = data.length - 1; i >= 0; i--) {
456 builder.addOffset(data[i]);
457 }
458 return builder.endVector();
459 }
460 static startCharactersVector(builder, numElems) {
461 builder.startVector(4, numElems, 4);
462 }
463 static endMovie(builder) {
464 const offset = builder.endObject();
465 return offset;
466 }
467 static finishMovieBuffer(builder, offset) {
468 builder.finish(offset, "MOVI");
469 }
470 static finishSizePrefixedMovieBuffer(builder, offset) {
471 builder.finish(offset, "MOVI", true);
472 }
473 static createMovie(builder, mainCharacterType, mainCharacterOffset, charactersTypeOffset, charactersOffset) {
474 Movie.startMovie(builder);
475 Movie.addMainCharacterType(builder, mainCharacterType);
476 Movie.addMainCharacter(builder, mainCharacterOffset);
477 Movie.addCharactersType(builder, charactersTypeOffset);
478 Movie.addCharacters(builder, charactersOffset);
479 return Movie.endMovie(builder);
480 }
481 unpack() {
482 return new MovieT(this.mainCharacterType(), (() => {
483 const temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
484 if (temp === null) {
485 return null;
486 }
487 if (typeof temp === "string") {
488 return temp;
489 }
490 return temp.unpack();
491 })(), this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength()), (() => {
492 const ret = [];
493 for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
494 const targetEnum = this.charactersType(targetEnumIndex);
495 if (targetEnum === null || Character[targetEnum] === "NONE") {
496 continue;
497 }
498 const temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
499 if (temp === null) {
500 continue;
501 }
502 if (typeof temp === "string") {
503 ret.push(temp);
504 continue;
505 }
506 ret.push(temp.unpack());
507 }
508 return ret;
509 })());
510 }
511 unpackTo(_o) {
512 _o.mainCharacterType = this.mainCharacterType();
513 _o.mainCharacter = (() => {
514 const temp = unionToCharacter(this.mainCharacterType(), this.mainCharacter.bind(this));
515 if (temp === null) {
516 return null;
517 }
518 if (typeof temp === "string") {
519 return temp;
520 }
521 return temp.unpack();
522 })();
523 _o.charactersType = this.bb.createScalarList(this.charactersType.bind(this), this.charactersTypeLength());
524 _o.characters = (() => {
525 const ret = [];
526 for (let targetEnumIndex = 0; targetEnumIndex < this.charactersTypeLength(); ++targetEnumIndex) {
527 const targetEnum = this.charactersType(targetEnumIndex);
528 if (targetEnum === null || Character[targetEnum] === "NONE") {
529 continue;
530 }
531 const temp = unionListToCharacter(targetEnum, this.characters.bind(this), targetEnumIndex);
532 if (temp === null) {
533 continue;
534 }
535 if (typeof temp === "string") {
536 ret.push(temp);
537 continue;
538 }
539 ret.push(temp.unpack());
540 }
541 return ret;
542 })();
543 }
544};
545var MovieT = class {
546 constructor(mainCharacterType = Character.NONE, mainCharacter = null, charactersType = [], characters = []) {
547 this.mainCharacterType = mainCharacterType;
548 this.mainCharacter = mainCharacter;
549 this.charactersType = charactersType;
550 this.characters = characters;
551 }
552 pack(builder) {
553 const mainCharacter = builder.createObjectOffset(this.mainCharacter);
554 const charactersType = Movie.createCharactersTypeVector(builder, this.charactersType);
555 const characters = Movie.createCharactersVector(builder, builder.createObjectOffsetList(this.characters));
556 return Movie.createMovie(builder, this.mainCharacterType, mainCharacter, charactersType, characters);
557 }
558};
View as plain text