@imperialbower/bowery 0.0.0-stage → 0.1.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-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/MANIFEST.sha256 +8 -0
- package/README.md +92 -2
- package/bowery.css +73 -0
- package/bowery.js +413 -0
- package/bowery_wasm.js +609 -0
- package/bowery_wasm_bg.wasm +0 -0
- package/package.json +28 -4
package/bowery_wasm.js
ADDED
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One element's table, for JavaScript.
|
|
3
|
+
*
|
|
4
|
+
* # Examples
|
|
5
|
+
*
|
|
6
|
+
* ```
|
|
7
|
+
* use bowery::wasm::BoweryTable;
|
|
8
|
+
*
|
|
9
|
+
* let table = BoweryTable::new("
|
|
10
|
+
* mode: play
|
|
11
|
+
* table: { stakes: { small_blind: 1.0, big_blind: 2.0 } }
|
|
12
|
+
* players: [ { seat: 0, stack: 200 }, { seat: 1, stack: 200, bot: abc } ]
|
|
13
|
+
* ").unwrap();
|
|
14
|
+
* assert!(table.state().contains(r#""mode":"play""#));
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export class BoweryTable {
|
|
18
|
+
__destroy_into_raw() {
|
|
19
|
+
const ptr = this.__wbg_ptr;
|
|
20
|
+
this.__wbg_ptr = 0;
|
|
21
|
+
BoweryTableFinalization.unregister(this);
|
|
22
|
+
return ptr;
|
|
23
|
+
}
|
|
24
|
+
free() {
|
|
25
|
+
const ptr = this.__destroy_into_raw();
|
|
26
|
+
wasm.__wbg_bowerytable_free(ptr, 0);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The reader acts: `{"action":"raise","amount":600}`.
|
|
30
|
+
*
|
|
31
|
+
* # Errors
|
|
32
|
+
*
|
|
33
|
+
* The JSON does not read, or the game refuses the action.
|
|
34
|
+
*
|
|
35
|
+
* # Examples
|
|
36
|
+
*
|
|
37
|
+
* ```
|
|
38
|
+
* use bowery::wasm::BoweryTable;
|
|
39
|
+
*
|
|
40
|
+
* let mut table = BoweryTable::new("
|
|
41
|
+
* mode: play
|
|
42
|
+
* table: { button: 0, stakes: { small_blind: 1.0, big_blind: 2.0 } }
|
|
43
|
+
* players: [ { seat: 0, stack: 200 }, { seat: 1, stack: 200, bot: abc } ]
|
|
44
|
+
* ").unwrap();
|
|
45
|
+
* assert!(table.act(r#"{"action":"call"}"#).is_ok());
|
|
46
|
+
* ```
|
|
47
|
+
* @param {string} action_json
|
|
48
|
+
*/
|
|
49
|
+
act(action_json) {
|
|
50
|
+
const ptr0 = passStringToWasm0(action_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
51
|
+
const len0 = WASM_VECTOR_LEN;
|
|
52
|
+
const ret = wasm.bowerytable_act(this.__wbg_ptr, ptr0, len0);
|
|
53
|
+
if (ret[1]) {
|
|
54
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* One step: `"acted"`, `"dealt"`, `"waiting"` or `"over"`.
|
|
59
|
+
*
|
|
60
|
+
* # Errors
|
|
61
|
+
*
|
|
62
|
+
* The engine failed.
|
|
63
|
+
*
|
|
64
|
+
* # Examples
|
|
65
|
+
*
|
|
66
|
+
* ```
|
|
67
|
+
* use bowery::wasm::BoweryTable;
|
|
68
|
+
*
|
|
69
|
+
* let mut table = BoweryTable::new("
|
|
70
|
+
* mode: play
|
|
71
|
+
* table: { button: 0, stakes: { small_blind: 1.0, big_blind: 2.0 } }
|
|
72
|
+
* players: [ { seat: 0, stack: 200 }, { seat: 1, stack: 200, bot: abc } ]
|
|
73
|
+
* ").unwrap();
|
|
74
|
+
* assert_eq!("waiting", table.advance().unwrap());
|
|
75
|
+
* ```
|
|
76
|
+
* @returns {string}
|
|
77
|
+
*/
|
|
78
|
+
advance() {
|
|
79
|
+
let deferred2_0;
|
|
80
|
+
let deferred2_1;
|
|
81
|
+
try {
|
|
82
|
+
const ret = wasm.bowerytable_advance(this.__wbg_ptr);
|
|
83
|
+
var ptr1 = ret[0];
|
|
84
|
+
var len1 = ret[1];
|
|
85
|
+
if (ret[3]) {
|
|
86
|
+
ptr1 = 0; len1 = 0;
|
|
87
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
88
|
+
}
|
|
89
|
+
deferred2_0 = ptr1;
|
|
90
|
+
deferred2_1 = len1;
|
|
91
|
+
return getStringFromWasm0(ptr1, len1);
|
|
92
|
+
} finally {
|
|
93
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Back to the record at the takeover moment.
|
|
98
|
+
*
|
|
99
|
+
* # Examples
|
|
100
|
+
*
|
|
101
|
+
* ```
|
|
102
|
+
* use bowery::wasm::BoweryTable;
|
|
103
|
+
*
|
|
104
|
+
* let mut table = BoweryTable::new("
|
|
105
|
+
* mode: play
|
|
106
|
+
* table: { stakes: { small_blind: 1.0, big_blind: 2.0 } }
|
|
107
|
+
* players: [ { seat: 0, stack: 200 }, { seat: 1, stack: 200, bot: abc } ]
|
|
108
|
+
* ").unwrap();
|
|
109
|
+
* table.back_to_record();
|
|
110
|
+
* assert!(table.state().contains(r#""record":"none""#));
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
back_to_record() {
|
|
114
|
+
wasm.bowerytable_back_to_record(this.__wbg_ptr);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Reads, checks and builds a table from a YAML config.
|
|
118
|
+
*
|
|
119
|
+
* # Errors
|
|
120
|
+
*
|
|
121
|
+
* The config's problems as a JSON string (see
|
|
122
|
+
* [`crate::element::problems_json`]).
|
|
123
|
+
*
|
|
124
|
+
* # Examples
|
|
125
|
+
*
|
|
126
|
+
* ```
|
|
127
|
+
* use bowery::wasm::BoweryTable;
|
|
128
|
+
*
|
|
129
|
+
* let table = BoweryTable::new("
|
|
130
|
+
* mode: play
|
|
131
|
+
* table: { stakes: { small_blind: 1.0, big_blind: 2.0 } }
|
|
132
|
+
* players: [ { seat: 0, stack: 200 }, { seat: 1, stack: 200, bot: abc } ]
|
|
133
|
+
* ");
|
|
134
|
+
* assert!(table.is_ok());
|
|
135
|
+
* ```
|
|
136
|
+
* @param {string} config_yaml
|
|
137
|
+
*/
|
|
138
|
+
constructor(config_yaml) {
|
|
139
|
+
const ptr0 = passStringToWasm0(config_yaml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
140
|
+
const len0 = WASM_VECTOR_LEN;
|
|
141
|
+
const ret = wasm.bowerytable_new(ptr0, len0);
|
|
142
|
+
if (ret[2]) {
|
|
143
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
144
|
+
}
|
|
145
|
+
this.__wbg_ptr = ret[0];
|
|
146
|
+
BoweryTableFinalization.register(this, this.__wbg_ptr, this);
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Play: deals the next hand.
|
|
151
|
+
*
|
|
152
|
+
* # Errors
|
|
153
|
+
*
|
|
154
|
+
* Not play mode, the hand is not over, or the table is broken.
|
|
155
|
+
*
|
|
156
|
+
* # Examples
|
|
157
|
+
*
|
|
158
|
+
* ```
|
|
159
|
+
* use bowery::wasm::BoweryTable;
|
|
160
|
+
*
|
|
161
|
+
* let mut table = BoweryTable::new("
|
|
162
|
+
* mode: play
|
|
163
|
+
* table: { button: 0, stakes: { small_blind: 1.0, big_blind: 2.0 } }
|
|
164
|
+
* players: [ { seat: 0, stack: 200 }, { seat: 1, stack: 200, bot: abc } ]
|
|
165
|
+
* ").unwrap();
|
|
166
|
+
* table.act(r#"{"action":"fold"}"#).unwrap();
|
|
167
|
+
* while table.advance().unwrap() != "over" {}
|
|
168
|
+
* assert!(table.next_hand().is_ok());
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
next_hand() {
|
|
172
|
+
const ret = wasm.bowerytable_next_hand(this.__wbg_ptr);
|
|
173
|
+
if (ret[1]) {
|
|
174
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Moves to moment `index`, from 0; past the end, to the last.
|
|
179
|
+
*
|
|
180
|
+
* # Examples
|
|
181
|
+
*
|
|
182
|
+
* ```
|
|
183
|
+
* use bowery::wasm::BoweryTable;
|
|
184
|
+
*
|
|
185
|
+
* let mut table = BoweryTable::new("
|
|
186
|
+
* mode: play
|
|
187
|
+
* table: { stakes: { small_blind: 1.0, big_blind: 2.0 } }
|
|
188
|
+
* players: [ { seat: 0, stack: 200 }, { seat: 1, stack: 200, bot: abc } ]
|
|
189
|
+
* ").unwrap();
|
|
190
|
+
* table.seek(0);
|
|
191
|
+
* assert!(table.state().contains(r#""moment":1"#));
|
|
192
|
+
* ```
|
|
193
|
+
* @param {number} index
|
|
194
|
+
*/
|
|
195
|
+
seek(index) {
|
|
196
|
+
wasm.bowerytable_seek(this.__wbg_ptr, index);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Draws in `layout` from now on: `ring`, `spotlight` or `ledger`.
|
|
200
|
+
*
|
|
201
|
+
* # Errors
|
|
202
|
+
*
|
|
203
|
+
* Any other name.
|
|
204
|
+
*
|
|
205
|
+
* # Examples
|
|
206
|
+
*
|
|
207
|
+
* ```
|
|
208
|
+
* use bowery::wasm::BoweryTable;
|
|
209
|
+
*
|
|
210
|
+
* let mut table = BoweryTable::new("
|
|
211
|
+
* mode: play
|
|
212
|
+
* table: { stakes: { small_blind: 1.0, big_blind: 2.0 } }
|
|
213
|
+
* players: [ { seat: 0, stack: 200 }, { seat: 1, stack: 200, bot: abc } ]
|
|
214
|
+
* ").unwrap();
|
|
215
|
+
* assert!(table.set_layout("ledger").is_ok());
|
|
216
|
+
* ```
|
|
217
|
+
* @param {string} layout
|
|
218
|
+
*/
|
|
219
|
+
set_layout(layout) {
|
|
220
|
+
const ptr0 = passStringToWasm0(layout, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
221
|
+
const len0 = WASM_VECTOR_LEN;
|
|
222
|
+
const ret = wasm.bowerytable_set_layout(this.__wbg_ptr, ptr0, len0);
|
|
223
|
+
if (ret[1]) {
|
|
224
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Draws in `view` from now on: `all` or `seat`.
|
|
229
|
+
*
|
|
230
|
+
* # Errors
|
|
231
|
+
*
|
|
232
|
+
* Any other name.
|
|
233
|
+
*
|
|
234
|
+
* # Examples
|
|
235
|
+
*
|
|
236
|
+
* ```
|
|
237
|
+
* use bowery::wasm::BoweryTable;
|
|
238
|
+
*
|
|
239
|
+
* let mut table = BoweryTable::new("
|
|
240
|
+
* mode: play
|
|
241
|
+
* table: { stakes: { small_blind: 1.0, big_blind: 2.0 } }
|
|
242
|
+
* players: [ { seat: 0, stack: 200 }, { seat: 1, stack: 200, bot: abc } ]
|
|
243
|
+
* ").unwrap();
|
|
244
|
+
* assert!(table.set_view("all").is_ok());
|
|
245
|
+
* ```
|
|
246
|
+
* @param {string} view
|
|
247
|
+
*/
|
|
248
|
+
set_view(view) {
|
|
249
|
+
const ptr0 = passStringToWasm0(view, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
250
|
+
const len0 = WASM_VECTOR_LEN;
|
|
251
|
+
const ret = wasm.bowerytable_set_view(this.__wbg_ptr, ptr0, len0);
|
|
252
|
+
if (ret[1]) {
|
|
253
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Play: a new game seeded with `seed`.
|
|
258
|
+
*
|
|
259
|
+
* # Errors
|
|
260
|
+
*
|
|
261
|
+
* Not play mode.
|
|
262
|
+
*
|
|
263
|
+
* # Examples
|
|
264
|
+
*
|
|
265
|
+
* ```
|
|
266
|
+
* use bowery::wasm::BoweryTable;
|
|
267
|
+
*
|
|
268
|
+
* let mut table = BoweryTable::new("
|
|
269
|
+
* mode: play
|
|
270
|
+
* table: { stakes: { small_blind: 1.0, big_blind: 2.0 } }
|
|
271
|
+
* players: [ { seat: 0, stack: 200 }, { seat: 1, stack: 200, bot: abc } ]
|
|
272
|
+
* ").unwrap();
|
|
273
|
+
* assert!(table.shuffle(9).is_ok());
|
|
274
|
+
* ```
|
|
275
|
+
* @param {number} seed
|
|
276
|
+
*/
|
|
277
|
+
shuffle(seed) {
|
|
278
|
+
const ret = wasm.bowerytable_shuffle(this.__wbg_ptr, seed);
|
|
279
|
+
if (ret[1]) {
|
|
280
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* The controls' state as JSON (see [`crate::element::State`]).
|
|
285
|
+
*
|
|
286
|
+
* # Examples
|
|
287
|
+
*
|
|
288
|
+
* ```
|
|
289
|
+
* use bowery::wasm::BoweryTable;
|
|
290
|
+
*
|
|
291
|
+
* let table = BoweryTable::new("
|
|
292
|
+
* mode: play
|
|
293
|
+
* table: { stakes: { small_blind: 1.0, big_blind: 2.0 } }
|
|
294
|
+
* players: [ { seat: 0, stack: 200 }, { seat: 1, stack: 200, bot: abc } ]
|
|
295
|
+
* ").unwrap();
|
|
296
|
+
* assert!(table.state().contains(r#""moment":1"#));
|
|
297
|
+
* ```
|
|
298
|
+
* @returns {string}
|
|
299
|
+
*/
|
|
300
|
+
state() {
|
|
301
|
+
let deferred1_0;
|
|
302
|
+
let deferred1_1;
|
|
303
|
+
try {
|
|
304
|
+
const ret = wasm.bowerytable_state(this.__wbg_ptr);
|
|
305
|
+
deferred1_0 = ret[0];
|
|
306
|
+
deferred1_1 = ret[1];
|
|
307
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
308
|
+
} finally {
|
|
309
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* The table on screen as SVG, `width` pixels wide, dark or light.
|
|
314
|
+
*
|
|
315
|
+
* # Examples
|
|
316
|
+
*
|
|
317
|
+
* ```
|
|
318
|
+
* use bowery::wasm::BoweryTable;
|
|
319
|
+
*
|
|
320
|
+
* let table = BoweryTable::new("
|
|
321
|
+
* mode: play
|
|
322
|
+
* table: { stakes: { small_blind: 1.0, big_blind: 2.0 } }
|
|
323
|
+
* players: [ { seat: 0, stack: 200 }, { seat: 1, stack: 200, bot: abc } ]
|
|
324
|
+
* ").unwrap();
|
|
325
|
+
* assert!(table.svg(400, true).contains(r#"width="400""#));
|
|
326
|
+
* ```
|
|
327
|
+
* @param {number} width
|
|
328
|
+
* @param {boolean} dark
|
|
329
|
+
* @returns {string}
|
|
330
|
+
*/
|
|
331
|
+
svg(width, dark) {
|
|
332
|
+
let deferred1_0;
|
|
333
|
+
let deferred1_1;
|
|
334
|
+
try {
|
|
335
|
+
const ret = wasm.bowerytable_svg(this.__wbg_ptr, width, dark);
|
|
336
|
+
deferred1_0 = ret[0];
|
|
337
|
+
deferred1_1 = ret[1];
|
|
338
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
339
|
+
} finally {
|
|
340
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* The reader takes `seat` (interactive).
|
|
345
|
+
*
|
|
346
|
+
* # Errors
|
|
347
|
+
*
|
|
348
|
+
* The game's reason, as a string.
|
|
349
|
+
*
|
|
350
|
+
* # Examples
|
|
351
|
+
*
|
|
352
|
+
* ```
|
|
353
|
+
* use bowery::wasm::BoweryTable;
|
|
354
|
+
*
|
|
355
|
+
* let mut table = BoweryTable::new("
|
|
356
|
+
* mode: interactive
|
|
357
|
+
* hand:
|
|
358
|
+
* hand: { id: ex, game: holdem }
|
|
359
|
+
* table: { seats: 2, button: 0, stakes: { small_blind: 1.0, big_blind: 2.0 } }
|
|
360
|
+
* players: [ { seat: 0, name: A, stack: 100.0 }, { seat: 1, name: B, stack: 100.0 } ]
|
|
361
|
+
* streets: { preflop: { actions: [ { seat: 0, action: fold } ] } }
|
|
362
|
+
* ").unwrap();
|
|
363
|
+
* assert!(table.take_seat(0).is_ok());
|
|
364
|
+
* ```
|
|
365
|
+
* @param {number} seat
|
|
366
|
+
*/
|
|
367
|
+
take_seat(seat) {
|
|
368
|
+
const ret = wasm.bowerytable_take_seat(this.__wbg_ptr, seat);
|
|
369
|
+
if (ret[1]) {
|
|
370
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* This crate's version.
|
|
375
|
+
*
|
|
376
|
+
* # Examples
|
|
377
|
+
*
|
|
378
|
+
* ```
|
|
379
|
+
* use bowery::wasm::BoweryTable;
|
|
380
|
+
*
|
|
381
|
+
* assert_eq!(env!("CARGO_PKG_VERSION"), BoweryTable::version());
|
|
382
|
+
* ```
|
|
383
|
+
* @returns {string}
|
|
384
|
+
*/
|
|
385
|
+
static version() {
|
|
386
|
+
let deferred1_0;
|
|
387
|
+
let deferred1_1;
|
|
388
|
+
try {
|
|
389
|
+
const ret = wasm.bowerytable_version();
|
|
390
|
+
deferred1_0 = ret[0];
|
|
391
|
+
deferred1_1 = ret[1];
|
|
392
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
393
|
+
} finally {
|
|
394
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (Symbol.dispose) BoweryTable.prototype[Symbol.dispose] = BoweryTable.prototype.free;
|
|
399
|
+
function __wbg_get_imports() {
|
|
400
|
+
const import0 = {
|
|
401
|
+
__proto__: null,
|
|
402
|
+
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
403
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
404
|
+
},
|
|
405
|
+
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
406
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
407
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
408
|
+
return ret;
|
|
409
|
+
},
|
|
410
|
+
__wbindgen_init_externref_table: function() {
|
|
411
|
+
const table = wasm.__wbindgen_externrefs;
|
|
412
|
+
const offset = table.grow(4);
|
|
413
|
+
table.set(0, undefined);
|
|
414
|
+
table.set(offset + 0, undefined);
|
|
415
|
+
table.set(offset + 1, null);
|
|
416
|
+
table.set(offset + 2, true);
|
|
417
|
+
table.set(offset + 3, false);
|
|
418
|
+
},
|
|
419
|
+
};
|
|
420
|
+
return {
|
|
421
|
+
__proto__: null,
|
|
422
|
+
"./bowery_wasm_bg.js": import0,
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
const BoweryTableFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
427
|
+
? { register: () => {}, unregister: () => {} }
|
|
428
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_bowerytable_free(ptr, 1));
|
|
429
|
+
|
|
430
|
+
function getStringFromWasm0(ptr, len) {
|
|
431
|
+
return decodeText(ptr >>> 0, len);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
let cachedUint8ArrayMemory0 = null;
|
|
435
|
+
function getUint8ArrayMemory0() {
|
|
436
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
437
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
438
|
+
}
|
|
439
|
+
return cachedUint8ArrayMemory0;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
443
|
+
if (realloc === undefined) {
|
|
444
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
445
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
446
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
447
|
+
WASM_VECTOR_LEN = buf.length;
|
|
448
|
+
return ptr;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
let len = arg.length;
|
|
452
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
453
|
+
|
|
454
|
+
const mem = getUint8ArrayMemory0();
|
|
455
|
+
|
|
456
|
+
let offset = 0;
|
|
457
|
+
|
|
458
|
+
for (; offset < len; offset++) {
|
|
459
|
+
const code = arg.charCodeAt(offset);
|
|
460
|
+
if (code > 0x7F) break;
|
|
461
|
+
mem[ptr + offset] = code;
|
|
462
|
+
}
|
|
463
|
+
if (offset !== len) {
|
|
464
|
+
if (offset !== 0) {
|
|
465
|
+
arg = arg.slice(offset);
|
|
466
|
+
}
|
|
467
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
468
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
469
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
470
|
+
|
|
471
|
+
offset += ret.written;
|
|
472
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
WASM_VECTOR_LEN = offset;
|
|
476
|
+
return ptr;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
function takeFromExternrefTable0(idx) {
|
|
480
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
481
|
+
wasm.__externref_table_dealloc(idx);
|
|
482
|
+
return value;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
486
|
+
cachedTextDecoder.decode();
|
|
487
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
488
|
+
let numBytesDecoded = 0;
|
|
489
|
+
function decodeText(ptr, len) {
|
|
490
|
+
numBytesDecoded += len;
|
|
491
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
492
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
493
|
+
cachedTextDecoder.decode();
|
|
494
|
+
numBytesDecoded = len;
|
|
495
|
+
}
|
|
496
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const cachedTextEncoder = new TextEncoder();
|
|
500
|
+
|
|
501
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
502
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
503
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
504
|
+
view.set(buf);
|
|
505
|
+
return {
|
|
506
|
+
read: arg.length,
|
|
507
|
+
written: buf.length
|
|
508
|
+
};
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
let WASM_VECTOR_LEN = 0;
|
|
513
|
+
|
|
514
|
+
let wasmModule, wasmInstance, wasm;
|
|
515
|
+
function __wbg_finalize_init(instance, module) {
|
|
516
|
+
wasmInstance = instance;
|
|
517
|
+
wasm = instance.exports;
|
|
518
|
+
wasmModule = module;
|
|
519
|
+
cachedUint8ArrayMemory0 = null;
|
|
520
|
+
wasm.__wbindgen_start();
|
|
521
|
+
return wasm;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
async function __wbg_load(module, imports) {
|
|
525
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
526
|
+
if (!module.ok) {
|
|
527
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
531
|
+
try {
|
|
532
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
533
|
+
} catch (e) {
|
|
534
|
+
const validResponse = expectedResponseType(module.type);
|
|
535
|
+
|
|
536
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
537
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
538
|
+
|
|
539
|
+
} else { throw e; }
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
const bytes = await module.arrayBuffer();
|
|
544
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
545
|
+
} else {
|
|
546
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
547
|
+
|
|
548
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
549
|
+
return { instance, module };
|
|
550
|
+
} else {
|
|
551
|
+
return instance;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
function expectedResponseType(type) {
|
|
556
|
+
switch (type) {
|
|
557
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
558
|
+
}
|
|
559
|
+
return false;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function initSync(module) {
|
|
564
|
+
if (wasm !== undefined) return wasm;
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
if (module !== undefined) {
|
|
568
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
569
|
+
({module} = module)
|
|
570
|
+
} else {
|
|
571
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
const imports = __wbg_get_imports();
|
|
576
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
577
|
+
module = new WebAssembly.Module(module);
|
|
578
|
+
}
|
|
579
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
580
|
+
return __wbg_finalize_init(instance, module);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
async function __wbg_init(module_or_path) {
|
|
584
|
+
if (wasm !== undefined) return wasm;
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
if (module_or_path !== undefined) {
|
|
588
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
589
|
+
({module_or_path} = module_or_path)
|
|
590
|
+
} else {
|
|
591
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
if (module_or_path === undefined) {
|
|
596
|
+
module_or_path = new URL('bowery_wasm_bg.wasm', import.meta.url);
|
|
597
|
+
}
|
|
598
|
+
const imports = __wbg_get_imports();
|
|
599
|
+
|
|
600
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
601
|
+
module_or_path = fetch(module_or_path);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
605
|
+
|
|
606
|
+
return __wbg_finalize_init(instance, module);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imperialbower/bowery",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "One poker table control, configured not compiled: <bowery-table>.",
|
|
5
|
+
"license": "MIT OR Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "bowery.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./bowery.js",
|
|
10
|
+
"./bowery.css": "./bowery.css"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bowery.js",
|
|
14
|
+
"bowery.css",
|
|
15
|
+
"bowery_wasm.js",
|
|
16
|
+
"bowery_wasm_bg.wasm",
|
|
17
|
+
"LICENSE-MIT",
|
|
18
|
+
"LICENSE-APACHE",
|
|
19
|
+
"MANIFEST.sha256",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"sideEffects": true,
|
|
23
|
+
"keywords": ["poker", "web-component", "custom-element", "wasm", "svg", "hand-history"],
|
|
24
|
+
"homepage": "https://github.com/ImperialBower/bowery",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/ImperialBower/bowery.git"
|
|
28
|
+
},
|
|
29
|
+
"bugs": "https://github.com/ImperialBower/bowery/issues"
|
|
30
|
+
}
|