@perspective-dev/client 4.0.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.md +193 -0
- package/README.md +3 -0
- package/dist/cdn/perspective-server.worker.js +2 -0
- package/dist/cdn/perspective-server.worker.js.map +7 -0
- package/dist/cdn/perspective.js +3 -0
- package/dist/cdn/perspective.js.map +7 -0
- package/dist/esm/perspective-server.worker.d.ts +1 -0
- package/dist/esm/perspective.browser.d.ts +14 -0
- package/dist/esm/perspective.inline.js +3 -0
- package/dist/esm/perspective.inline.js.map +7 -0
- package/dist/esm/perspective.js +3 -0
- package/dist/esm/perspective.js.map +7 -0
- package/dist/esm/perspective.node.d.ts +60 -0
- package/dist/esm/perspective.node.js +2431 -0
- package/dist/esm/perspective.node.js.map +7 -0
- package/dist/esm/ts-rs/Aggregate.d.ts +1 -0
- package/dist/esm/ts-rs/ColumnWindow.d.ts +4 -0
- package/dist/esm/ts-rs/DeleteOptions.d.ts +6 -0
- package/dist/esm/ts-rs/Expressions.d.ts +3 -0
- package/dist/esm/ts-rs/Filter.d.ts +2 -0
- package/dist/esm/ts-rs/FilterReducer.d.ts +1 -0
- package/dist/esm/ts-rs/FilterTerm.d.ts +2 -0
- package/dist/esm/ts-rs/OnUpdateMode.d.ts +9 -0
- package/dist/esm/ts-rs/OnUpdateOptions.d.ts +7 -0
- package/dist/esm/ts-rs/Scalar.d.ts +5 -0
- package/dist/esm/ts-rs/Sort.d.ts +2 -0
- package/dist/esm/ts-rs/SortDir.d.ts +1 -0
- package/dist/esm/ts-rs/SystemInfo.d.ts +40 -0
- package/dist/esm/ts-rs/TableInitOptions.d.ts +22 -0
- package/dist/esm/ts-rs/TableReadFormat.d.ts +7 -0
- package/dist/esm/ts-rs/UpdateOptions.d.ts +8 -0
- package/dist/esm/ts-rs/ViewConfigUpdate.d.ts +90 -0
- package/dist/esm/ts-rs/ViewOnUpdateResp.d.ts +4 -0
- package/dist/esm/ts-rs/ViewWindow.d.ts +23 -0
- package/dist/esm/wasm/browser.d.ts +21 -0
- package/dist/esm/wasm/decompress.d.ts +1 -0
- package/dist/esm/wasm/emscripten_api.d.ts +5 -0
- package/dist/esm/wasm/engine.d.ts +40 -0
- package/dist/esm/wasm/perspective-server.poly.d.ts +1 -0
- package/dist/esm/websocket.d.ts +4 -0
- package/dist/wasm/perspective-js.d.ts +712 -0
- package/dist/wasm/perspective-js.js +1934 -0
- package/dist/wasm/perspective-js.wasm +0 -0
- package/dist/wasm/perspective-js.wasm.d.ts +75 -0
- package/package.json +68 -0
- package/src/rust/client.rs +483 -0
- package/src/rust/lib.rs +70 -0
- package/src/rust/table.rs +364 -0
- package/src/rust/table_data.rs +159 -0
- package/src/rust/utils/browser.rs +39 -0
- package/src/rust/utils/console_logger.rs +236 -0
- package/src/rust/utils/errors.rs +288 -0
- package/src/rust/utils/futures.rs +174 -0
- package/src/rust/utils/json.rs +252 -0
- package/src/rust/utils/local_poll_loop.rs +63 -0
- package/src/rust/utils/mod.rs +32 -0
- package/src/rust/utils/serde.rs +46 -0
- package/src/rust/utils/trace_allocator.rs +98 -0
- package/src/rust/view.rs +355 -0
- package/src/ts/perspective-server.worker.ts +54 -0
- package/src/ts/perspective.browser.ts +132 -0
- package/src/ts/perspective.cdn.ts +22 -0
- package/src/ts/perspective.inline.ts +27 -0
- package/src/ts/perspective.node.ts +315 -0
- package/src/ts/ts-rs/Aggregate.ts +3 -0
- package/src/ts/ts-rs/ColumnWindow.ts +3 -0
- package/src/ts/ts-rs/DeleteOptions.ts +6 -0
- package/src/ts/ts-rs/Expressions.ts +3 -0
- package/src/ts/ts-rs/Filter.ts +4 -0
- package/src/ts/ts-rs/FilterReducer.ts +3 -0
- package/src/ts/ts-rs/FilterTerm.ts +4 -0
- package/src/ts/ts-rs/OnUpdateData.ts +8 -0
- package/src/ts/ts-rs/OnUpdateMode.ts +11 -0
- package/src/ts/ts-rs/OnUpdateOptions.ts +7 -0
- package/src/ts/ts-rs/Scalar.ts +7 -0
- package/src/ts/ts-rs/Sort.ts +4 -0
- package/src/ts/ts-rs/SortDir.ts +3 -0
- package/src/ts/ts-rs/SystemInfo.ts +41 -0
- package/src/ts/ts-rs/TableInitOptions.ts +21 -0
- package/src/ts/ts-rs/TableReadFormat.ts +9 -0
- package/src/ts/ts-rs/UpdateOptions.ts +7 -0
- package/src/ts/ts-rs/ViewConfigUpdate.ts +87 -0
- package/src/ts/ts-rs/ViewOnUpdateResp.ts +3 -0
- package/src/ts/ts-rs/ViewWindow.ts +17 -0
- package/src/ts/wasm/browser.ts +123 -0
- package/src/ts/wasm/decompress.ts +64 -0
- package/src/ts/wasm/emscripten_api.ts +63 -0
- package/src/ts/wasm/engine.ts +271 -0
- package/src/ts/wasm/perspective-server.poly.ts +244 -0
- package/src/ts/websocket.ts +95 -0
- package/tsconfig.json +20 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# Apache License
|
|
2
|
+
|
|
3
|
+
_Version 2.0, January 2004_
|
|
4
|
+
_<<http://www.apache.org/licenses/>>_
|
|
5
|
+
|
|
6
|
+
### Terms and Conditions for use, reproduction, and distribution
|
|
7
|
+
|
|
8
|
+
#### 1. Definitions
|
|
9
|
+
|
|
10
|
+
“License” shall mean the terms and conditions for use, reproduction, and
|
|
11
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
“Licensor” shall mean the copyright owner or entity authorized by the copyright
|
|
14
|
+
owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
“Legal Entity” shall mean the union of the acting entity and all other entities
|
|
17
|
+
that control, are controlled by, or are under common control with that entity.
|
|
18
|
+
For the purposes of this definition, “control” means **(i)** the power, direct or
|
|
19
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
20
|
+
contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or **(iii)** beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
“You” (or “Your”) shall mean an individual or Legal Entity exercising
|
|
24
|
+
permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
“Source” form shall mean the preferred form for making modifications, including
|
|
27
|
+
but not limited to software source code, documentation source, and configuration
|
|
28
|
+
files.
|
|
29
|
+
|
|
30
|
+
“Object” form shall mean any form resulting from mechanical transformation or
|
|
31
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
32
|
+
generated documentation, and conversions to other media types.
|
|
33
|
+
|
|
34
|
+
“Work” shall mean the work of authorship, whether in Source or Object form, made
|
|
35
|
+
available under the License, as indicated by a copyright notice that is included
|
|
36
|
+
in or attached to the work (an example is provided in the Appendix below).
|
|
37
|
+
|
|
38
|
+
“Derivative Works” shall mean any work, whether in Source or Object form, that
|
|
39
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
40
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
41
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
42
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
43
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
44
|
+
|
|
45
|
+
“Contribution” shall mean any work of authorship, including the original version
|
|
46
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
|
47
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
|
48
|
+
by the copyright owner or by an individual or Legal Entity authorized to submit
|
|
49
|
+
on behalf of the copyright owner. For the purposes of this definition,
|
|
50
|
+
“submitted” means any form of electronic, verbal, or written communication sent
|
|
51
|
+
to the Licensor or its representatives, including but not limited to
|
|
52
|
+
communication on electronic mailing lists, source code control systems, and
|
|
53
|
+
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
|
54
|
+
the purpose of discussing and improving the Work, but excluding communication
|
|
55
|
+
that is conspicuously marked or otherwise designated in writing by the copyright
|
|
56
|
+
owner as “Not a Contribution.”
|
|
57
|
+
|
|
58
|
+
“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
|
|
59
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
60
|
+
incorporated within the Work.
|
|
61
|
+
|
|
62
|
+
#### 2. Grant of Copyright License
|
|
63
|
+
|
|
64
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
65
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
66
|
+
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
|
67
|
+
publicly display, publicly perform, sublicense, and distribute the Work and such
|
|
68
|
+
Derivative Works in Source or Object form.
|
|
69
|
+
|
|
70
|
+
#### 3. Grant of Patent License
|
|
71
|
+
|
|
72
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
73
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
74
|
+
irrevocable (except as stated in this section) patent license to make, have
|
|
75
|
+
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
|
76
|
+
such license applies only to those patent claims licensable by such Contributor
|
|
77
|
+
that are necessarily infringed by their Contribution(s) alone or by combination
|
|
78
|
+
of their Contribution(s) with the Work to which such Contribution(s) was
|
|
79
|
+
submitted. If You institute patent litigation against any entity (including a
|
|
80
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
|
81
|
+
Contribution incorporated within the Work constitutes direct or contributory
|
|
82
|
+
patent infringement, then any patent licenses granted to You under this License
|
|
83
|
+
for that Work shall terminate as of the date such litigation is filed.
|
|
84
|
+
|
|
85
|
+
#### 4. Redistribution
|
|
86
|
+
|
|
87
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
|
88
|
+
in any medium, with or without modifications, and in Source or Object form,
|
|
89
|
+
provided that You meet the following conditions:
|
|
90
|
+
|
|
91
|
+
- **(a)** You must give any other recipients of the Work or Derivative Works a copy of
|
|
92
|
+
this License; and
|
|
93
|
+
- **(b)** You must cause any modified files to carry prominent notices stating that You
|
|
94
|
+
changed the files; and
|
|
95
|
+
- **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
|
|
96
|
+
all copyright, patent, trademark, and attribution notices from the Source form
|
|
97
|
+
of the Work, excluding those notices that do not pertain to any part of the
|
|
98
|
+
Derivative Works; and
|
|
99
|
+
- **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
|
|
100
|
+
Derivative Works that You distribute must include a readable copy of the
|
|
101
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
102
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
103
|
+
following places: within a NOTICE text file distributed as part of the
|
|
104
|
+
Derivative Works; within the Source form or documentation, if provided along
|
|
105
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
|
106
|
+
Works, if and wherever such third-party notices normally appear. The contents of
|
|
107
|
+
the NOTICE file are for informational purposes only and do not modify the
|
|
108
|
+
License. You may add Your own attribution notices within Derivative Works that
|
|
109
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
110
|
+
provided that such additional attribution notices cannot be construed as
|
|
111
|
+
modifying the License.
|
|
112
|
+
|
|
113
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
114
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
115
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
|
116
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
|
117
|
+
with the conditions stated in this License.
|
|
118
|
+
|
|
119
|
+
#### 5. Submission of Contributions
|
|
120
|
+
|
|
121
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
|
122
|
+
for inclusion in the Work by You to the Licensor shall be under the terms and
|
|
123
|
+
conditions of this License, without any additional terms or conditions.
|
|
124
|
+
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
|
125
|
+
any separate license agreement you may have executed with Licensor regarding
|
|
126
|
+
such Contributions.
|
|
127
|
+
|
|
128
|
+
#### 6. Trademarks
|
|
129
|
+
|
|
130
|
+
This License does not grant permission to use the trade names, trademarks,
|
|
131
|
+
service marks, or product names of the Licensor, except as required for
|
|
132
|
+
reasonable and customary use in describing the origin of the Work and
|
|
133
|
+
reproducing the content of the NOTICE file.
|
|
134
|
+
|
|
135
|
+
#### 7. Disclaimer of Warranty
|
|
136
|
+
|
|
137
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the
|
|
138
|
+
Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
|
|
139
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
|
140
|
+
including, without limitation, any warranties or conditions of TITLE,
|
|
141
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
|
142
|
+
solely responsible for determining the appropriateness of using or
|
|
143
|
+
redistributing the Work and assume any risks associated with Your exercise of
|
|
144
|
+
permissions under this License.
|
|
145
|
+
|
|
146
|
+
#### 8. Limitation of Liability
|
|
147
|
+
|
|
148
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
|
149
|
+
contract, or otherwise, unless required by applicable law (such as deliberate
|
|
150
|
+
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
|
151
|
+
liable to You for damages, including any direct, indirect, special, incidental,
|
|
152
|
+
or consequential damages of any character arising as a result of this License or
|
|
153
|
+
out of the use or inability to use the Work (including but not limited to
|
|
154
|
+
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
|
155
|
+
any and all other commercial damages or losses), even if such Contributor has
|
|
156
|
+
been advised of the possibility of such damages.
|
|
157
|
+
|
|
158
|
+
#### 9. Accepting Warranty or Additional Liability
|
|
159
|
+
|
|
160
|
+
While redistributing the Work or Derivative Works thereof, You may choose to
|
|
161
|
+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
|
162
|
+
other liability obligations and/or rights consistent with this License. However,
|
|
163
|
+
in accepting such obligations, You may act only on Your own behalf and on Your
|
|
164
|
+
sole responsibility, not on behalf of any other Contributor, and only if You
|
|
165
|
+
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
|
166
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
167
|
+
accepting any such warranty or additional liability.
|
|
168
|
+
|
|
169
|
+
_END OF TERMS AND CONDITIONS_
|
|
170
|
+
|
|
171
|
+
### APPENDIX: How to apply the Apache License to your work
|
|
172
|
+
|
|
173
|
+
To apply the Apache License to your work, attach the following boilerplate
|
|
174
|
+
notice, with the fields enclosed by brackets `[]` replaced with your own
|
|
175
|
+
identifying information. (Don't include the brackets!) The text should be
|
|
176
|
+
enclosed in the appropriate comment syntax for the file format. We also
|
|
177
|
+
recommend that a file or class name and description of purpose be included on
|
|
178
|
+
the same “printed page” as the copyright notice for easier identification within
|
|
179
|
+
third-party archives.
|
|
180
|
+
|
|
181
|
+
Copyright 2019 The Perspective Authors
|
|
182
|
+
|
|
183
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
184
|
+
you may not use this file except in compliance with the License.
|
|
185
|
+
You may obtain a copy of the License at
|
|
186
|
+
|
|
187
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
188
|
+
|
|
189
|
+
Unless required by applicable law or agreed to in writing, software
|
|
190
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
191
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
192
|
+
See the License for the specific language governing permissions and
|
|
193
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var b=class{poll_handle;server;constructor(t){this.server=t}set_poll_handle(){return this.poll_handle=new Promise((t,r)=>setTimeout(()=>this.server.poll().then(t).catch(r).finally(()=>{this.poll_handle=void 0}))),this.poll_handle}async on_poll_request(){this.poll_handle?await this.poll_handle.then(()=>{if(!this.poll_handle)return this.set_poll_handle()}):await this.set_poll_handle()}},v=class{clients;server;module;on_poll_request;constructor(t,r){this.clients=new Map,this.module=t,this.on_poll_request=r?.on_poll_request,this.server=t._psp_new_server(r?.on_poll_request?1:0)}make_session(t){let r=this.module._psp_new_session(this.server);return this.clients.set(r,t),new w(this.module,this.server,r,this.clients,this.on_poll_request&&(()=>this.on_poll_request(this)))}async poll(){let t=this.module._psp_poll(this.server);await P(this.module,t,async r=>{await this.clients.get(r.client_id)(r.data)})}delete(){this.module._psp_delete_server(this.server)}},w=class{constructor(t,r,n,a,l){this.mod=t;this.server=r;this.client_id=n;this.client_map=a;this.on_poll_request=l}async handle_request(t){let r=await B(this.mod,t,async n=>this.mod._psp_handle_request(this.server,this.client_id,n,this.mod._psp_is_memory64()?BigInt(t.byteLength):t.byteLength));await P(this.mod,r,async n=>{await this.client_map.get(n.client_id)(n.data)}),this.on_poll_request?await this.on_poll_request():await this.poll()}async poll(){let t=this.mod._psp_poll(this.server);await P(this.mod,t,async r=>{r.client_id===0?await this.client_map.get(this.client_id)(r.data):await this.client_map.get(r.client_id)(r.data)})}close(){this.mod._psp_close_session(this.server,this.client_id)}};async function B(i,t,r){let n=i._psp_alloc(i._psp_is_memory64()?BigInt(t.byteLength):t.byteLength);i.HEAPU8.set(t,Number(n));let a=await r(n);return i._psp_free(n),a}async function P(i,t,r){let n=i._psp_is_memory64(),a=new DataView(i.HEAPU8.buffer,Number(t),n?12:8),l=a.getUint32(0,!0),u=n?a.getBigInt64(4,!0):a.getUint32(4,!0),e=new DataView(i.HEAPU8.buffer,Number(u),l*(n?16:12));try{for(let s=0;s<l;s++){let[o,p,f]=n?[e.getBigInt64(s*16,!0),e.getInt32(s*16+8,!0),e.getInt32(s*16+12,!0)]:[e.getInt32(s*12,!0),e.getInt32(s*12+4,!0),e.getInt32(s*12+8,!0)],c=new Uint8Array(i.HEAPU8.buffer,Number(o),p);await r({client_id:f,data:c})}}finally{for(let s=0;s<l;s++){let o=n?e.getBigInt64(s*16,!0):e.getInt32(s*12,!0);i._psp_free(o)}i._psp_free(n?BigInt(e.byteOffset):e.byteOffset),i._psp_free(n?BigInt(a.byteOffset):a.byteOffset)}}var I=console.log.bind(console),S=console.error.bind(console),H=new TextDecoder("utf8"),q=[null,[],[]];function L(i,t=0,r=NaN){for(var n=t+r,a=t;i[a]&&!(a>=n);)++a;return H.decode(i instanceof Uint8Array?i.subarray(t,a):new Uint8Array(i.slice(t,a)))}function A(i,t){var r=q[i];t===0||t===10?((i===1?I:S)(L(r,0)),r.length=0):r.push(t)}async function E(i){let t,r=!1,n,a={HaveOffsetConverter(){console.error("HaveOffsetConverter")},__syscall_ftruncate64(...e){console.error("__syscall_frtuncate64",e)},__syscall_getdents64(...e){console.error("__syscall_frtuncate64",e)},__syscall_unlinkat(...e){console.error("__syscall_frtuncate64",e)},__throw_exception_with_stack_trace(e){let s=new WebAssembly.Exception(t.__cpp_exception,[e],{traceStack:!0});throw s.message="Unexpected internal error",s},clock_time_get(e,s,o){if(r){if(o=o,o=Number(o),!(e==0||e==1||e==2||e==3))return 28;var p;e===0?p=Date.now():p=performance.now();let c=Math.round(p*1e3*1e3),_=new BigInt64Array(n.buffer);return _[o/8]=BigInt(c),0}else{if(o=o,o>>>=0,!(e==0||e==1||e==2||e==3))return 28;var p;e===0?p=Date.now():p=performance.now();var f=Math.round(p*1e6);let _=new BigInt64Array(n.buffer);return _[o>>>3]=BigInt(f),0}},emscripten_asm_const_int(...e){return 0},emscripten_notify_memory_growth(e){r?e=Number(e):(e=e,e>>>=0),e!=0&&console.error("abort")},environ_get(...e){return 0},environ_sizes_get(...e){return 0},fd_close(...e){return console.error("fd_close",e),0},fd_read(...e){return console.error("fd_read",e),0},fd_seek(...e){return console.error("fs_seek",e),0},fd_write(e,s,o,p){let f=new Uint8Array(n.buffer);if(r){s=Number(s),o=Number(o),p=Number(p);let c=0,_=new BigUint64Array(n.buffer);for(let y=0;y<o;y++){let g=Number(_[s/8]),d=Number(_[(s+8)/8]);s+=16;for(let m=0;m<d;m++)A(e,f[g+m]);c+=d}return _[p/8]=BigInt(c),0}else{s=s,o=o,p=p,s>>>=0,o>>>=0,p>>>=0;let c=0,_=new Uint32Array(n.buffer);for(let y=0;y<o;y++){let g=_[s>>>2>>>0],d=_[s+4>>>2>>>0];s+=8;for(let m=0;m<d;m++)A(e,f[g+m>>>0]);c+=d}return _[p>>>2>>>0]=c,0}},proc_exit(e){return console.error("proc_exit",e),0}},l=await i.instantiateWasm({env:a,wasi_snapshot_preview1:a},e=>{t=e.exports,r=!!t.psp_is_memory64(),n=e.exports.memory,t._initialize()}),u={};for(let[e,s]of Object.entries(l))u[`_${e}`]=s;return{...l,...u,get HEAPU8(){return new Uint8Array(n.buffer)}}}async function U(i){let t=await E({locateFile(r){return r},instantiateWasm:async(r,n)=>{r.env={...r.env,psp_stack_trace(){let l=Error().stack||"",e=new TextEncoder().encode(l),s=t._psp_alloc(t._psp_is_memory64()?BigInt(e.byteLength+1):e.byteLength+1);return t.HEAPU8.set(e,Number(s)),t.HEAPU8[Number(s)+e.byteLength]=0,s},psp_heap_size(){return t._psp_is_memory64()?BigInt(t.HEAPU8.buffer.byteLength):t.HEAPU8.buffer.byteLength}};let a=await WebAssembly.instantiate(i,r);return n(a.instance),a.instance.exports}});return t}var h,M;function x(i){let t=i.ports[0],r;t.addEventListener("message",async n=>{if(n.data.cmd==="init"){let a=n.data.id;if(!h){let l=await U(n.data.args[0]);h=new v(l,{on_poll_request:()=>M.on_poll_request()}),M=new b(h)}r=h.make_session(async l=>{let u=l.slice().buffer;t.postMessage(u,{transfer:[u]})}),t.postMessage({id:a})}else await r.handle_request(new Uint8Array(n.data))}),t.start()}self.addEventListener("connect",x);self.addEventListener("message",x);
|
|
2
|
+
//# sourceMappingURL=perspective-server.worker.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ts/wasm/engine.ts", "../../src/ts/wasm/perspective-server.poly.ts", "../../src/ts/wasm/emscripten_api.ts", "../../src/ts/perspective-server.worker.ts"],
|
|
4
|
+
"sourcesContent": ["// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { MainModule } from \"@perspective-dev/server/dist/wasm/perspective-server.js\";\nimport type { EmscriptenServer, PspPtr } from \"./emscripten_api.ts\";\n\nexport type ApiResponse = {\n client_id: number;\n data: Uint8Array;\n};\n\nexport interface PerspectiveServerOptions {\n on_poll_request?: (x: PerspectiveServer) => Promise<void>;\n}\n\nexport class PerspectivePollThread {\n private poll_handle?: Promise<void>;\n private server: PerspectiveServer;\n constructor(server: PerspectiveServer) {\n this.server = server;\n }\n\n private set_poll_handle() {\n this.poll_handle = new Promise((resolve, reject) =>\n setTimeout(() =>\n this.server\n .poll()\n .then(resolve)\n .catch(reject)\n .finally(() => {\n this.poll_handle = undefined;\n }),\n ),\n );\n\n return this.poll_handle;\n }\n\n async on_poll_request() {\n if (!this.poll_handle) {\n await this.set_poll_handle();\n } else {\n await this.poll_handle.then(() => {\n if (!this.poll_handle) {\n return this.set_poll_handle();\n }\n });\n }\n }\n}\n\nexport class PerspectiveServer {\n clients: Map<number, (buffer: Uint8Array) => Promise<void>>;\n server: EmscriptenServer;\n module: MainModule;\n on_poll_request?: (x: PerspectiveServer) => Promise<void>;\n constructor(module: MainModule, options?: PerspectiveServerOptions) {\n this.clients = new Map();\n this.module = module;\n this.on_poll_request = options?.on_poll_request;\n this.server = module._psp_new_server(\n !!options?.on_poll_request ? 1 : 0,\n ) as EmscriptenServer;\n }\n\n /**\n * Helper function to create server emitter/receiver pairs\n */\n make_session(\n callback: (buffer: Uint8Array) => Promise<void>,\n ): PerspectiveSession {\n const client_id = this.module._psp_new_session(this.server as any);\n this.clients.set(client_id, callback);\n return new PerspectiveSession(\n this.module,\n this.server,\n client_id,\n this.clients,\n this.on_poll_request && (() => this.on_poll_request!(this)),\n );\n }\n\n async poll() {\n const polled = this.module._psp_poll(this.server as any);\n await decode_api_responses(\n this.module,\n polled,\n async (msg: ApiResponse) => {\n await this.clients.get(msg.client_id)!(msg.data);\n },\n );\n }\n\n delete() {\n this.module._psp_delete_server(this.server as any);\n }\n}\n\nexport class PerspectiveSession {\n constructor(\n private mod: MainModule,\n private server: EmscriptenServer,\n private client_id: number,\n private client_map: Map<number, (buffer: Uint8Array) => Promise<void>>,\n private on_poll_request?: () => Promise<void>,\n ) {}\n\n async handle_request(view: Uint8Array) {\n const ptr = await convert_typed_array_to_pointer(\n this.mod,\n view,\n async (viewPtr) => {\n return this.mod._psp_handle_request(\n this.server as any,\n this.client_id,\n viewPtr as any,\n this.mod._psp_is_memory64()\n ? (BigInt(view.byteLength) as any as number)\n : (view.byteLength as any),\n );\n },\n );\n\n await decode_api_responses(this.mod, ptr, async (msg: ApiResponse) => {\n await this.client_map.get(msg.client_id)!(msg.data);\n });\n\n if (this.on_poll_request) {\n await this.on_poll_request();\n } else {\n await this.poll();\n }\n }\n\n private async poll() {\n const polled = this.mod._psp_poll(this.server as any);\n await decode_api_responses(\n this.mod,\n polled,\n async (msg: ApiResponse) => {\n if (msg.client_id === 0) {\n await this.client_map.get(this.client_id)!(msg.data);\n } else {\n await this.client_map.get(msg.client_id)!(msg.data);\n }\n },\n );\n }\n\n close() {\n this.mod._psp_close_session(this.server as any, this.client_id);\n }\n}\n\nasync function convert_typed_array_to_pointer(\n core: MainModule,\n array: Uint8Array,\n callback: (_: PspPtr) => Promise<PspPtr>,\n): Promise<PspPtr> {\n const ptr = core._psp_alloc(\n core._psp_is_memory64()\n ? (BigInt(array.byteLength) as any as number)\n : (array.byteLength as any),\n );\n\n core.HEAPU8.set(array, Number(ptr));\n const msg = await callback(ptr);\n core._psp_free(ptr);\n return msg;\n}\n\n/**\n * Convert a pointer to WASM memory into an `ApiResponse[]`, via a custom\n * encoding.\n *\n * @param core The emscripten API\n * @param ptr A pointer to a fixed-sized struct representing a set of\n * `proto::Resp` payloads, encoded as a length-prefixed array of\n * (char* data, u32_t len, u32_t client_id) tuples:\n *\n * ```text\n * N data length client_id data length client_id\n * +-------------------------------------------------------------+\n * | 2 | 0xabc | 9 | 0 | 0xdef | 12 | 0 |\n * +-------------------------------------------------------------+\n * | |\n * | +-------------+ | +----------------+\n * +--| \"Test Data\" | +--| \"Hello, World\" |\n * +-------------+ +----------------+\n * ```\n *\n * @param callback A callback to which is passed the responses. THe responses\n * must be fully processed or copied before the callback returns, as it\n * references memory on the wasm stack.\n */\nasync function decode_api_responses(\n core: MainModule,\n ptr: PspPtr,\n callback: (_: ApiResponse) => Promise<void>,\n) {\n const is_64 = core._psp_is_memory64();\n const response = new DataView(\n core.HEAPU8.buffer,\n Number(ptr),\n is_64 ? 12 : 8,\n );\n\n const num_msgs = response.getUint32(0, true);\n const msgs_ptr = is_64\n ? response.getBigInt64(4, true)\n : response.getUint32(4, true);\n\n const messages = new DataView(\n core.HEAPU8.buffer,\n Number(msgs_ptr),\n num_msgs * (is_64 ? 16 : 12),\n );\n\n try {\n for (let i = 0; i < num_msgs; i++) {\n const [data_ptr, data_len, client_id] = is_64\n ? [\n messages.getBigInt64(i * 16, true),\n messages.getInt32(i * 16 + 8, true),\n messages.getInt32(i * 16 + 12, true),\n ]\n : [\n messages.getInt32(i * 12, true),\n messages.getInt32(i * 12 + 4, true),\n messages.getInt32(i * 12 + 8, true),\n ];\n\n const data = new Uint8Array(\n core.HEAPU8.buffer,\n Number(data_ptr),\n data_len,\n );\n\n const resp = { client_id, data };\n await callback(resp);\n }\n } finally {\n for (let i = 0; i < num_msgs; i++) {\n const data_ptr = is_64\n ? messages.getBigInt64(i * 16, true)\n : messages.getInt32(i * 12, true);\n\n core._psp_free(data_ptr as any);\n }\n\n core._psp_free(\n is_64\n ? (BigInt(messages.byteOffset) as any as number)\n : (messages.byteOffset as any),\n );\n core._psp_free(\n is_64\n ? (BigInt(response.byteOffset) as any as number)\n : (response.byteOffset as any),\n );\n }\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type * as perspective_server from \"@perspective-dev/server/dist/wasm/perspective-server.js\";\n\ntype PspPtr = bigint | number;\ntype EmscriptenServer = number;\n\nvar out = console.log.bind(console);\nvar err = console.error.bind(console);\n\nvar UTF8Decoder = new TextDecoder(\"utf8\");\nvar printCharBuffers: Array<Array<number> | null> = [null, [], []];\n\nfunction UTF8ArrayToString(\n heapOrArray: Uint8Array | Array<number>,\n idx = 0,\n maxBytesToRead = NaN,\n) {\n var endIdx = idx + maxBytesToRead;\n var endPtr = idx;\n while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;\n return UTF8Decoder.decode(\n heapOrArray instanceof Uint8Array\n ? heapOrArray.subarray(idx, endPtr)\n : new Uint8Array(heapOrArray.slice(idx, endPtr)),\n );\n}\n\nfunction printChar(stream: number, curr: number) {\n var buffer: Array<number> = printCharBuffers[stream]!;\n if (curr === 0 || curr === 10) {\n (stream === 1 ? out : err)(UTF8ArrayToString(buffer, 0));\n buffer.length = 0;\n } else {\n buffer.push(curr);\n }\n}\n\nexport default async function (obj: any) {\n let psp_module: perspective_server.MainModule;\n let is_memory64 = false;\n let wasm_memory: WebAssembly.Memory;\n const module = {\n HaveOffsetConverter() {\n console.error(\"HaveOffsetConverter\");\n },\n __syscall_ftruncate64(...args: any[]) {\n console.error(\"__syscall_frtuncate64\", args);\n },\n __syscall_getdents64(...args: any[]) {\n console.error(\"__syscall_frtuncate64\", args);\n },\n __syscall_unlinkat(...args: any[]) {\n console.error(\"__syscall_frtuncate64\", args);\n },\n __throw_exception_with_stack_trace(ex: number) {\n // @ts-ignore\n const e = new WebAssembly.Exception(\n (psp_module as any).__cpp_exception,\n [ex],\n {\n traceStack: true,\n },\n );\n\n // e.message = getExceptionMessage(e);\n e.message = \"Unexpected internal error\";\n throw e;\n },\n clock_time_get(\n clk_id: number,\n ignored_precision: bigint,\n ptime: bigint | number,\n ) {\n if (is_memory64) {\n ptime = ptime as bigint;\n ptime = Number(ptime);\n if (\n !(clk_id == 0 || clk_id == 1 || clk_id == 2 || clk_id == 3)\n ) {\n return 28;\n }\n var now;\n\n if (clk_id === 0) {\n now = Date.now();\n } else {\n now = performance.now();\n }\n\n const nsec = Math.round(now * 1000 * 1000);\n const HEAP64 = new BigInt64Array(wasm_memory.buffer);\n HEAP64[ptime / 8] = BigInt(nsec);\n return 0;\n } else {\n ptime = ptime as number;\n ptime >>>= 0;\n if (\n !(clk_id == 0 || clk_id == 1 || clk_id == 2 || clk_id == 3)\n ) {\n return 28;\n }\n\n var now;\n if (clk_id === 0) {\n now = Date.now();\n } else {\n now = performance.now();\n }\n\n var nsec = Math.round(now * 1e6);\n const HEAP64 = new BigInt64Array(wasm_memory.buffer);\n HEAP64[ptime >>> 3] = BigInt(nsec);\n return 0;\n }\n },\n emscripten_asm_const_int(...args: any[]) {\n return 0;\n },\n emscripten_notify_memory_growth(memoryIndex: bigint | number) {\n if (is_memory64) {\n memoryIndex = Number(memoryIndex as bigint);\n } else {\n memoryIndex = memoryIndex as number;\n memoryIndex >>>= 0;\n }\n\n if (memoryIndex != 0) {\n console.error(\"abort\");\n }\n },\n environ_get(...args: any[]) {\n return 0;\n },\n environ_sizes_get(...args: any[]) {\n return 0;\n },\n fd_close(...args: any[]) {\n console.error(\"fd_close\", args);\n return 0;\n },\n fd_read(...args: any[]) {\n console.error(\"fd_read\", args);\n return 0;\n },\n fd_seek(...args: any[]) {\n console.error(\"fs_seek\", args);\n return 0;\n },\n fd_write(\n fd: number,\n iov: number | bigint,\n iovcnt: number | bigint,\n pnum: number | bigint,\n ) {\n const HEAPU8 = new Uint8Array(wasm_memory.buffer);\n\n if (!is_memory64) {\n iov = iov as number;\n iovcnt = iovcnt as number;\n pnum = pnum as number;\n iov >>>= 0;\n iovcnt >>>= 0;\n pnum >>>= 0;\n let num = 0;\n const HEAPU32 = new Uint32Array(wasm_memory.buffer);\n\n for (let i = 0; i < iovcnt; i++) {\n let ptr = HEAPU32[(iov >>> 2) >>> 0];\n let len = HEAPU32[((iov + 4) >>> 2) >>> 0];\n iov += 8;\n for (let j = 0; j < len; j++) {\n printChar(fd, HEAPU8[(ptr + j) >>> 0]);\n }\n num += len;\n }\n HEAPU32[(pnum >>> 2) >>> 0] = num;\n return 0;\n } else {\n iov = Number(iov as bigint);\n iovcnt = Number(iovcnt as bigint);\n pnum = Number(pnum as bigint);\n let num = 0;\n const HEAPU64 = new BigUint64Array(wasm_memory.buffer);\n\n for (let i = 0; i < iovcnt; i++) {\n let ptr = Number(HEAPU64[iov / 8]);\n let len = Number(HEAPU64[(iov + 8) / 8]);\n iov += 16;\n for (let j = 0; j < len; j++) {\n printChar(fd, HEAPU8[ptr + j]);\n }\n\n num += len;\n }\n HEAPU64[pnum / 8] = BigInt(num);\n return 0;\n }\n },\n proc_exit(e: number) {\n console.error(\"proc_exit\", e);\n return 0;\n },\n };\n\n const x = await obj.instantiateWasm(\n { env: module, wasi_snapshot_preview1: module },\n (instance: WebAssembly.Instance) => {\n psp_module =\n instance.exports as any as perspective_server.MainModule;\n\n // @ts-ignore\n is_memory64 = !!psp_module.psp_is_memory64();\n wasm_memory = instance.exports.memory as WebAssembly.Memory;\n\n // @ts-ignore\n psp_module._initialize();\n },\n );\n\n const extensions: Record<string, any> = {};\n for (const [name, func] of Object.entries(x)) {\n extensions[`_${name}`] = func;\n }\n\n return {\n ...x,\n ...extensions,\n get HEAPU8() {\n // @ts-ignore\n return new Uint8Array(wasm_memory.buffer);\n },\n };\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport * as perspective_server from \"./perspective-server.poly.ts\";\nexport type * from \"../../../dist/wasm/perspective-js.js\";\nimport type * as perspective_server_t from \"@perspective-dev/server/dist/wasm/perspective-server.js\";\n\nexport type PspPtr = BigInt | number;\nexport type EmscriptenServer = bigint | number;\n\nexport async function compile_perspective(\n wasmBinary: ArrayBuffer,\n): Promise<perspective_server_t.MainModule> {\n const module = await perspective_server.default({\n locateFile(x: any) {\n return x;\n },\n instantiateWasm: async (\n imports: any,\n receive: (_: WebAssembly.Instance) => void,\n ) => {\n imports[\"env\"] = {\n ...imports[\"env\"],\n psp_stack_trace() {\n const str = Error().stack || \"\";\n const textEncoder = new TextEncoder();\n const bytes = textEncoder.encode(str);\n const ptr = module._psp_alloc(\n module._psp_is_memory64()\n ? (BigInt(bytes.byteLength + 1) as any as number)\n : bytes.byteLength + 1,\n );\n\n module.HEAPU8.set(bytes, Number(ptr));\n module.HEAPU8[Number(ptr) + bytes.byteLength] = 0;\n return ptr;\n },\n psp_heap_size() {\n if (module._psp_is_memory64()) {\n return BigInt(module.HEAPU8.buffer.byteLength);\n } else {\n return module.HEAPU8.buffer.byteLength;\n }\n },\n };\n\n const webasm = await WebAssembly.instantiate(wasmBinary, imports);\n receive(webasm.instance);\n return webasm.instance.exports;\n },\n });\n\n return module;\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport {\n PerspectiveSession,\n PerspectiveServer,\n PerspectivePollThread,\n} from \"./wasm/engine.ts\";\nimport { compile_perspective } from \"./wasm/emscripten_api.ts\";\n\nlet GLOBAL_SERVER: PerspectiveServer;\nlet POLL_THREAD: PerspectivePollThread;\n\nfunction bindPort(e: MessageEvent) {\n const port = e.ports[0];\n let session: PerspectiveSession;\n port.addEventListener(\"message\", async (msg) => {\n if (msg.data.cmd === \"init\") {\n const id = msg.data.id;\n if (!GLOBAL_SERVER) {\n const module = await compile_perspective(msg.data.args[0]);\n GLOBAL_SERVER = new PerspectiveServer(module, {\n on_poll_request: () => POLL_THREAD.on_poll_request(),\n });\n\n POLL_THREAD = new PerspectivePollThread(GLOBAL_SERVER);\n }\n\n session = GLOBAL_SERVER.make_session(async (resp) => {\n const f = resp.slice().buffer;\n port.postMessage(f, { transfer: [f] });\n });\n\n port.postMessage({ id });\n } else {\n await session.handle_request(new Uint8Array(msg.data));\n }\n });\n\n port.start();\n}\n\n// @ts-expect-error wrong scope\nself.addEventListener(\"connect\", bindPort);\nself.addEventListener(\"message\", bindPort);\n"],
|
|
5
|
+
"mappings": "AAwBO,IAAMA,EAAN,KAA4B,CACvB,YACA,OACR,YAAYC,EAA2B,CACnC,KAAK,OAASA,CAClB,CAEQ,iBAAkB,CACtB,YAAK,YAAc,IAAI,QAAQ,CAACC,EAASC,IACrC,WAAW,IACP,KAAK,OACA,KAAK,EACL,KAAKD,CAAO,EACZ,MAAMC,CAAM,EACZ,QAAQ,IAAM,CACX,KAAK,YAAc,MACvB,CAAC,CACT,CACJ,EAEO,KAAK,WAChB,CAEA,MAAM,iBAAkB,CACf,KAAK,YAGN,MAAM,KAAK,YAAY,KAAK,IAAM,CAC9B,GAAI,CAAC,KAAK,YACN,OAAO,KAAK,gBAAgB,CAEpC,CAAC,EAND,MAAM,KAAK,gBAAgB,CAQnC,CACJ,EAEaC,EAAN,KAAwB,CAC3B,QACA,OACA,OACA,gBACA,YAAYC,EAAoBC,EAAoC,CAChE,KAAK,QAAU,IAAI,IACnB,KAAK,OAASD,EACd,KAAK,gBAAkBC,GAAS,gBAChC,KAAK,OAASD,EAAO,gBACfC,GAAS,gBAAkB,EAAI,CACrC,CACJ,CAKA,aACIC,EACkB,CAClB,IAAMC,EAAY,KAAK,OAAO,iBAAiB,KAAK,MAAa,EACjE,YAAK,QAAQ,IAAIA,EAAWD,CAAQ,EAC7B,IAAIE,EACP,KAAK,OACL,KAAK,OACLD,EACA,KAAK,QACL,KAAK,kBAAoB,IAAM,KAAK,gBAAiB,IAAI,EAC7D,CACJ,CAEA,MAAM,MAAO,CACT,IAAME,EAAS,KAAK,OAAO,UAAU,KAAK,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BH,EAAI,KAAK,KAAK,CAAC,CAAC,EACzDN,EAAgB,IAAIU,EAAkBF,EAAQ,CAC1C,gBAAiB,IAAMP,EAAY,gBAAgB,CACvD,CAAC,EAEDA,EAAc,IAAIU,EAAsBX,CAAa,CACzD,CAEAK,EAAUL,EAAc,aAAa,MAAOY,GAAS,CACjD,IAAMC,EAAID,EAAK,MAAM,EAAE,OACvBR,EAAK,YAAYS,EAAG,CAAE,SAAU,CAACA,CAAC,CAAE,CAAC,CACzC,CAAC,EAEDT,EAAK,YAAY,CAAE,GAAAG,CAAG,CAAC,CAC3B,MACI,MAAMF,EAAQ,eAAe,IAAI,WAAWC,EAAI,IAAI,CAAC,CAE7D,CAAC,EAEDF,EAAK,MAAM,CACf,CAGA,KAAK,iBAAiB,UAAWF,CAAQ,EACzC,KAAK,iBAAiB,UAAWA,CAAQ",
|
|
6
|
+
"names": ["PerspectivePollThread", "server", "resolve", "reject", "PerspectiveServer", "module", "options", "callback", "client_id", "PerspectiveSession", "polled", "decode_api_responses", "msg", "mod", "client_map", "on_poll_request", "view", "ptr", "convert_typed_array_to_pointer", "viewPtr", "core", "array", "is_64", "response", "num_msgs", "msgs_ptr", "messages", "i", "data_ptr", "data_len", "data", "out", "err", "UTF8Decoder", "printCharBuffers", "UTF8ArrayToString", "heapOrArray", "idx", "maxBytesToRead", "endIdx", "endPtr", "printChar", "stream", "curr", "buffer", "perspective_server_poly_default", "obj", "psp_module", "is_memory64", "wasm_memory", "module", "args", "ex", "e", "clk_id", "ignored_precision", "ptime", "now", "nsec", "HEAP64", "memoryIndex", "fd", "iov", "iovcnt", "pnum", "HEAPU8", "num", "HEAPU64", "i", "ptr", "len", "j", "HEAPU32", "x", "instance", "extensions", "name", "func", "compile_perspective", "wasmBinary", "module", "perspective_server_poly_default", "x", "imports", "receive", "str", "bytes", "ptr", "webasm", "GLOBAL_SERVER", "POLL_THREAD", "bindPort", "e", "port", "session", "msg", "id", "module", "compile_perspective", "PerspectiveServer", "PerspectivePollThread", "resp", "f"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var ae=Object.defineProperty;var ue=(n,e)=>{for(var t in e)ae(n,t,{get:e[t],enumerable:!0})};var z={};ue(z,{Client:()=>O,ProxySession:()=>B,Table:()=>L,View:()=>P,default:()=>F,init:()=>q,initSync:()=>ve});var _,d=new Array(128).fill(void 0);d.push(void 0,null,!0,!1);function o(n){return d[n]}var y=0,j=null;function S(){return(j===null||j.byteLength===0)&&(j=new Uint8Array(_.memory.buffer)),j}var K=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},fe=function(n,e){return K.encodeInto(n,e)};function x(n,e,t){if(t===void 0){let b=K.encode(n),g=e(b.length,1)>>>0;return S().subarray(g,g+b.length).set(b),y=b.length,g}let r=n.length,s=e(r,1)>>>0,c=S(),u=0;for(;u<r;u++){let b=n.charCodeAt(u);if(b>127)break;c[s+u]=b}if(u!==r){u!==0&&(n=n.slice(u)),s=t(s,r,r=u+n.length*3,1)>>>0;let b=S().subarray(s+u,s+r),g=fe(n,b);u+=g.written,s=t(s,r,u,1)>>>0}return y=u,s}var A=null;function l(){return(A===null||A.buffer.detached===!0||A.buffer.detached===void 0&&A.buffer!==_.memory.buffer)&&(A=new DataView(_.memory.buffer)),A}var M=d.length;function i(n){M===d.length&&d.push(d.length+1);let e=M;return M=d[e],d[e]=n,e}function p(n,e){try{return n.apply(this,e)}catch(t){_.__wbindgen_export_2(i(t))}}var Q=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&Q.decode();function w(n,e){return n=n>>>0,Q.decode(S().subarray(n,n+e))}function be(n,e){return n=n>>>0,S().subarray(n/1,n/1+e)}function f(n){return n==null}function le(n){n<132||(d[n]=M,M=n)}function a(n){let e=o(n);return le(n),e}var U=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>{_.__wbindgen_export_4.get(n.dtor)(n.a,n.b)});function ge(n,e,t,r){let s={a:n,b:e,cnt:1,dtor:t},c=(...u)=>{s.cnt++;let b=s.a;s.a=0;try{return r(b,s.b,...u)}finally{--s.cnt===0?(_.__wbindgen_export_4.get(s.dtor)(b,s.b),U.unregister(s)):s.a=b}};return c.original=s,U.register(c,s,s),c}function we(n,e,t,r){let s={a:n,b:e,cnt:1,dtor:t},c=(...u)=>{s.cnt++;try{return r(s.a,s.b,...u)}finally{--s.cnt===0&&(_.__wbindgen_export_4.get(s.dtor)(s.a,s.b),s.a=0,U.unregister(s))}};return c.original=s,U.register(c,s,s),c}function C(n){let e=typeof n;if(e=="number"||e=="boolean"||n==null)return`${n}`;if(e=="string")return`"${n}"`;if(e=="symbol"){let s=n.description;return s==null?"Symbol":`Symbol(${s})`}if(e=="function"){let s=n.name;return typeof s=="string"&&s.length>0?`Function(${s})`:"Function"}if(Array.isArray(n)){let s=n.length,c="[";s>0&&(c+=C(n[0]));for(let u=1;u<s;u++)c+=", "+C(n[u]);return c+="]",c}let t=/\[object ([^\]]+)\]/.exec(toString.call(n)),r;if(t&&t.length>1)r=t[1];else return toString.call(n);if(r=="Object")try{return"Object("+JSON.stringify(n)+")"}catch{return"Object"}return n instanceof Error?`${n.name}: ${n.message}
|
|
2
|
+
${n.stack}`:r}function de(n,e){if(!(n instanceof e))throw new Error(`expected instance of ${e.name}`)}var I=128;function X(n){if(I==1)throw new Error("out of js stack");return d[--I]=n,I}function q(){_.init()}function pe(n,e){let t=_.__wbindgen_export_5(n,e);return a(t)}function ye(n,e,t){_.__wbindgen_export_6(n,e,i(t))}function me(n,e,t,r){_.__wbindgen_export_7(n,e,i(t),i(r))}var N=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>_.__wbg_client_free(n>>>0,1)),O=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,N.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,N.unregister(this),e}free(){let e=this.__destroy_into_raw();_.__wbg_client_free(e,0)}__getClassname(){let e,t;try{let c=_.__wbindgen_add_to_stack_pointer(-16);_.client___getClassname(c,this.__wbg_ptr);var r=l().getInt32(c+0,!0),s=l().getInt32(c+4,!0);return e=r,t=s,w(r,s)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_3(e,t,1)}}constructor(e,t){try{let u=_.__wbindgen_add_to_stack_pointer(-16);_.client_new(u,i(e),f(t)?0:i(t));var r=l().getInt32(u+0,!0),s=l().getInt32(u+4,!0),c=l().getInt32(u+8,!0);if(c)throw a(s);return this.__wbg_ptr=r>>>0,N.register(this,this.__wbg_ptr,this),this}finally{_.__wbindgen_add_to_stack_pointer(16)}}new_proxy_session(e){try{let t=_.client_new_proxy_session(this.__wbg_ptr,X(e));return B.__wrap(t)}finally{d[I++]=void 0}}handle_response(e){let t=_.client_handle_response(this.__wbg_ptr,i(e));return a(t)}handle_error(e,t){let r=x(e,_.__wbindgen_export_0,_.__wbindgen_export_1),s=y,c=_.client_handle_error(this.__wbg_ptr,r,s,f(t)?0:i(t));return a(c)}on_error(e){let t=_.client_on_error(this.__wbg_ptr,i(e));return a(t)}table(e,t){let r=_.client_table(this.__wbg_ptr,i(e),f(t)?0:i(t));return a(r)}terminate(){try{let s=_.__wbindgen_add_to_stack_pointer(-16);_.client_terminate(s,this.__wbg_ptr);var e=l().getInt32(s+0,!0),t=l().getInt32(s+4,!0),r=l().getInt32(s+8,!0);if(r)throw a(t);return a(e)}finally{_.__wbindgen_add_to_stack_pointer(16)}}open_table(e){let t=x(e,_.__wbindgen_export_0,_.__wbindgen_export_1),r=y,s=_.client_open_table(this.__wbg_ptr,t,r);return a(s)}get_hosted_table_names(){let e=_.client_get_hosted_table_names(this.__wbg_ptr);return a(e)}on_hosted_tables_update(e){let t=_.client_on_hosted_tables_update(this.__wbg_ptr,i(e));return a(t)}remove_hosted_tables_update(e){let t=_.client_remove_hosted_tables_update(this.__wbg_ptr,e);return a(t)}system_info(){let e=_.client_system_info(this.__wbg_ptr);return a(e)}},T=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>_.__wbg_proxysession_free(n>>>0,1)),B=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,T.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,T.unregister(this),e}free(){let e=this.__destroy_into_raw();_.__wbg_proxysession_free(e,0)}constructor(e,t){try{de(e,O);let r=_.client_new_proxy_session(e.__wbg_ptr,X(t));return this.__wbg_ptr=r>>>0,T.register(this,this.__wbg_ptr,this),this}finally{d[I++]=void 0}}handle_request(e){let t=_.proxysession_handle_request(this.__wbg_ptr,i(e));return a(t)}close(){let e=this.__destroy_into_raw(),t=_.proxysession_close(e);return a(t)}},V=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>_.__wbg_table_free(n>>>0,1)),L=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,V.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,V.unregister(this),e}free(){let e=this.__destroy_into_raw();_.__wbg_table_free(e,0)}__getClassname(){let e,t;try{let c=_.__wbindgen_add_to_stack_pointer(-16);_.table___getClassname(c,this.__wbg_ptr);var r=l().getInt32(c+0,!0),s=l().getInt32(c+4,!0);return e=r,t=s,w(r,s)}finally{_.__wbindgen_add_to_stack_pointer(16),_.__wbindgen_export_3(e,t,1)}}get_index(){let e=_.table_get_index(this.__wbg_ptr);return a(e)}get_client(){let e=_.table_get_client(this.__wbg_ptr);return a(e)}get_name(){let e=_.table_get_name(this.__wbg_ptr);return a(e)}get_limit(){let e=_.table_get_limit(this.__wbg_ptr);return a(e)}clear(){let e=_.table_clear(this.__wbg_ptr);return a(e)}delete(e){let t=this.__destroy_into_raw(),r=_.table_delete(t,f(e)?0:i(e));return a(r)}size(){let e=_.table_size(this.__wbg_ptr);return a(e)}schema(){let e=_.table_schema(this.__wbg_ptr);return a(e)}columns(){let e=_.table_columns(this.__wbg_ptr);return a(e)}make_port(){let e=_.table_make_port(this.__wbg_ptr);return a(e)}on_delete(e){let t=_.table_on_delete(this.__wbg_ptr,i(e));return a(t)}remove_delete(e){let t=_.table_remove_delete(this.__wbg_ptr,e);return a(t)}remove(e,t){let r=_.table_remove(this.__wbg_ptr,i(e),f(t)?0:i(t));return a(r)}replace(e,t){let r=_.table_replace(this.__wbg_ptr,i(e),f(t)?0:i(t));return a(r)}update(e,t){let r=_.table_update(this.__wbg_ptr,i(e),f(t)?0:i(t));return a(r)}view(e){let t=_.table_view(this.__wbg_ptr,f(e)?0:i(e));return a(t)}validate_expressions(e){let t=_.table_validate_expressions(this.__wbg_ptr,i(e));return a(t)}},J=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>_.__wbg_view_free(n>>>0,1)),P=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,J.register(t,t.__wbg_ptr,t),t}static __unwrap(e){return e instanceof n?e.__destroy_into_raw():0}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,J.unregister(this),e}free(){let e=this.__destroy_into_raw();_.__wbg_view_free(e,0)}__get_model(){let e=_.view___get_model(this.__wbg_ptr);return n.__wrap(e)}column_paths(e){let t=_.view_column_paths(this.__wbg_ptr,f(e)?0:i(e));return a(t)}delete(){let e=this.__destroy_into_raw(),t=_.view_delete(e);return a(t)}dimensions(){let e=_.view_dimensions(this.__wbg_ptr);return a(e)}expression_schema(){let e=_.view_expression_schema(this.__wbg_ptr);return a(e)}get_config(){let e=_.view_get_config(this.__wbg_ptr);return a(e)}get_min_max(e){let t=x(e,_.__wbindgen_export_0,_.__wbindgen_export_1),r=y,s=_.view_get_min_max(this.__wbg_ptr,t,r);return a(s)}num_rows(){let e=_.view_num_rows(this.__wbg_ptr);return a(e)}schema(){let e=_.view_schema(this.__wbg_ptr);return a(e)}to_arrow(e){let t=_.view_to_arrow(this.__wbg_ptr,f(e)?0:i(e));return a(t)}to_columns_string(e){let t=_.view_to_columns_string(this.__wbg_ptr,f(e)?0:i(e));return a(t)}to_columns(e){let t=_.view_to_columns(this.__wbg_ptr,f(e)?0:i(e));return a(t)}to_json_string(e){let t=_.view_to_json_string(this.__wbg_ptr,f(e)?0:i(e));return a(t)}to_json(e){let t=_.view_to_json(this.__wbg_ptr,f(e)?0:i(e));return a(t)}to_ndjson(e){let t=_.view_to_ndjson(this.__wbg_ptr,f(e)?0:i(e));return a(t)}to_csv(e){let t=_.view_to_csv(this.__wbg_ptr,f(e)?0:i(e));return a(t)}on_update(e,t){let r=_.view_on_update(this.__wbg_ptr,i(e),f(t)?0:i(t));return a(r)}remove_update(e){let t=_.view_remove_update(this.__wbg_ptr,e);return a(t)}on_delete(e){let t=_.view_on_delete(this.__wbg_ptr,i(e));return a(t)}num_columns(){let e=_.view_num_columns(this.__wbg_ptr);return a(e)}remove_delete(e){let t=_.view_remove_delete(this.__wbg_ptr,e);return a(t)}collapse(e){let t=_.view_collapse(this.__wbg_ptr,e);return a(t)}expand(e){let t=_.view_expand(this.__wbg_ptr,e);return a(t)}set_depth(e){let t=_.view_set_depth(this.__wbg_ptr,e);return a(t)}};async function he(n,e){if(typeof Response=="function"&&n instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(n,e)}catch(r){if(n.headers.get("Content-Type")!="application/wasm")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",r);else throw r}let t=await n.arrayBuffer();return await WebAssembly.instantiate(t,e)}else{let t=await WebAssembly.instantiate(n,e);return t instanceof WebAssembly.Instance?{instance:t,module:n}:t}}function Y(){let n={};return n.wbg={},n.wbg.__wbg_String_8f0eb39a4a4c2f66=function(e,t){let r=String(o(t)),s=x(r,_.__wbindgen_export_0,_.__wbindgen_export_1),c=y;l().setInt32(e+4,c,!0),l().setInt32(e+0,s,!0)},n.wbg.__wbg_at_7d852dd9f194d43e=function(e,t){let r=o(e).at(t);return i(r)},n.wbg.__wbg_buffer_09165b52af8c5237=function(e){let t=o(e).buffer;return i(t)},n.wbg.__wbg_buffer_609cc3eee51ed158=function(e){let t=o(e).buffer;return i(t)},n.wbg.__wbg_call_672a4d21634d4a24=function(){return p(function(e,t){let r=o(e).call(o(t));return i(r)},arguments)},n.wbg.__wbg_call_7cccdd69e0791ae2=function(){return p(function(e,t,r){let s=o(e).call(o(t),o(r));return i(s)},arguments)},n.wbg.__wbg_call_833bed5770ea2041=function(){return p(function(e,t,r,s){let c=o(e).call(o(t),o(r),o(s));return i(c)},arguments)},n.wbg.__wbg_client_new=function(e){let t=O.__wrap(e);return i(t)},n.wbg.__wbg_debug_3cb59063b29f58c1=function(e){console.debug(o(e))},n.wbg.__wbg_debug_e17b51583ca6a632=function(e,t,r,s){console.debug(o(e),o(t),o(r),o(s))},n.wbg.__wbg_done_769e5ede4b31c67b=function(e){return o(e).done},n.wbg.__wbg_entries_3265d4158b33e5dc=function(e){let t=Object.entries(o(e));return i(t)},n.wbg.__wbg_error_1004b8c64097413f=function(e,t){console.error(o(e),o(t))},n.wbg.__wbg_error_524f506f44df1645=function(e){console.error(o(e))},n.wbg.__wbg_error_7534b8e9a36f1ab4=function(e,t){let r,s;try{r=e,s=t,console.error(w(e,t))}finally{_.__wbindgen_export_3(r,s,1)}},n.wbg.__wbg_error_80de38b3f7cc3c3c=function(e,t,r,s){console.error(o(e),o(t),o(r),o(s))},n.wbg.__wbg_from_2a5d3e218e67aa85=function(e){let t=Array.from(o(e));return i(t)},n.wbg.__wbg_getEntriesByName_2a5a14d4b09f36a4=function(e,t,r,s,c){let u=o(e).getEntriesByName(w(t,r),w(s,c));return i(u)},n.wbg.__wbg_getRandomValues_21a0191e74d0e1d3=function(){return p(function(e,t){globalThis.crypto.getRandomValues(be(e,t))},arguments)},n.wbg.__wbg_get_67b2ba62fc30de12=function(){return p(function(e,t){let r=Reflect.get(o(e),o(t));return i(r)},arguments)},n.wbg.__wbg_get_74b8744f6a23f4fa=function(e,t,r){let s=o(e)[w(t,r)];return f(s)?0:i(s)},n.wbg.__wbg_get_b9b93047fe3cf45b=function(e,t){let r=o(e)[t>>>0];return i(r)},n.wbg.__wbg_getwithrefkey_1dc361bd10053bfe=function(e,t){let r=o(e)[o(t)];return i(r)},n.wbg.__wbg_has_a5ea9117f258a0ec=function(){return p(function(e,t){return Reflect.has(o(e),o(t))},arguments)},n.wbg.__wbg_info_033d8b8a0838f1d3=function(e,t,r,s){console.info(o(e),o(t),o(r),o(s))},n.wbg.__wbg_info_3daf2e093e091b66=function(e){console.info(o(e))},n.wbg.__wbg_instanceof_ArrayBuffer_e14585432e3737fc=function(e){let t;try{t=o(e)instanceof ArrayBuffer}catch{t=!1}return t},n.wbg.__wbg_instanceof_Array_6ac07133d621675a=function(e){let t;try{t=o(e)instanceof Array}catch{t=!1}return t},n.wbg.__wbg_instanceof_Error_4d54113b22d20306=function(e){let t;try{t=o(e)instanceof Error}catch{t=!1}return t},n.wbg.__wbg_instanceof_Map_f3469ce2244d2430=function(e){let t;try{t=o(e)instanceof Map}catch{t=!1}return t},n.wbg.__wbg_instanceof_Object_7f2dcef8f78644a4=function(e){let t;try{t=o(e)instanceof Object}catch{t=!1}return t},n.wbg.__wbg_instanceof_Uint8Array_17156bcf118086a9=function(e){let t;try{t=o(e)instanceof Uint8Array}catch{t=!1}return t},n.wbg.__wbg_instanceof_Window_def73ea0955fc569=function(e){let t;try{t=o(e)instanceof Window}catch{t=!1}return t},n.wbg.__wbg_isArray_a1eab7e0d067391b=function(e){return Array.isArray(o(e))},n.wbg.__wbg_isSafeInteger_343e2beeeece1bb0=function(e){return Number.isSafeInteger(o(e))},n.wbg.__wbg_iterator_9a24c88df860dc65=function(){return i(Symbol.iterator)},n.wbg.__wbg_keys_5c77a08ddc2fb8a6=function(e){let t=Object.keys(o(e));return i(t)},n.wbg.__wbg_length_a446193dc22c12f8=function(e){return o(e).length},n.wbg.__wbg_length_e2d2a49132c1b256=function(e){return o(e).length},n.wbg.__wbg_mark_001da84b098c950f=function(){return p(function(e,t,r){o(e).mark(w(t,r))},arguments)},n.wbg.__wbg_measure_65e49f8bc0e203a8=function(){return p(function(e,t,r,s,c){o(e).measure(w(t,r),w(s,c))},arguments)},n.wbg.__wbg_message_97a2af9b89d693a3=function(e){let t=o(e).message;return i(t)},n.wbg.__wbg_new_23a2665fac83c611=function(e,t){try{var r={a:e,b:t},s=(u,b)=>{let g=r.a;r.a=0;try{return me(g,r.b,u,b)}finally{r.a=g}};let c=new Promise(s);return i(c)}finally{r.a=r.b=0}},n.wbg.__wbg_new_405e22f390576ce2=function(){let e=new Object;return i(e)},n.wbg.__wbg_new_5e0be73521bc8c17=function(){return i(new Map)},n.wbg.__wbg_new_78feb108b6472713=function(){let e=new Array;return i(e)},n.wbg.__wbg_new_8a6f238a6ece86ea=function(){let e=new Error;return i(e)},n.wbg.__wbg_new_a12002a7f91c75be=function(e){let t=new Uint8Array(o(e));return i(t)},n.wbg.__wbg_new_c68d7209be747379=function(e,t){let r=new Error(w(e,t));return i(r)},n.wbg.__wbg_newnoargs_105ed471475aaf50=function(e,t){let r=new Function(w(e,t));return i(r)},n.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a=function(e,t,r){let s=new Uint8Array(o(e),t>>>0,r>>>0);return i(s)},n.wbg.__wbg_next_25feadfc0913fea9=function(e){let t=o(e).next;return i(t)},n.wbg.__wbg_next_6574e1a8a62d1055=function(){return p(function(e){let t=o(e).next();return i(t)},arguments)},n.wbg.__wbg_now_d18023d54d4e5500=function(e){return o(e).now()},n.wbg.__wbg_parse_def2e24ef1252aff=function(){return p(function(e,t){let r=JSON.parse(w(e,t));return i(r)},arguments)},n.wbg.__wbg_performance_c185c0cdc2766575=function(e){let t=o(e).performance;return f(t)?0:i(t)},n.wbg.__wbg_push_737cfc8c1432c2c6=function(e,t){return o(e).push(o(t))},n.wbg.__wbg_queueMicrotask_6808622725a52272=function(e){let t=o(e).queueMicrotask;return i(t)},n.wbg.__wbg_queueMicrotask_ef0e86b0263a71ee=function(e){queueMicrotask(o(e))},n.wbg.__wbg_reject_b3fcf99063186ff7=function(e){let t=Promise.reject(o(e));return i(t)},n.wbg.__wbg_resolve_4851785c9c5f573d=function(e){let t=Promise.resolve(o(e));return i(t)},n.wbg.__wbg_set_37837023f3d740e8=function(e,t,r){o(e)[t>>>0]=a(r)},n.wbg.__wbg_set_3f1d0b984ed272ed=function(e,t,r){o(e)[a(t)]=a(r)},n.wbg.__wbg_set_65595bdd868b3009=function(e,t,r){o(e).set(o(t),r>>>0)},n.wbg.__wbg_set_8fc6bf8a5b1071d1=function(e,t,r){let s=o(e).set(o(t),o(r));return i(s)},n.wbg.__wbg_stack_0ed75d68575b0f3c=function(e,t){let r=o(t).stack,s=x(r,_.__wbindgen_export_0,_.__wbindgen_export_1),c=y;l().setInt32(e+4,c,!0),l().setInt32(e+0,s,!0)},n.wbg.__wbg_startTime_c051731d0a31602f=function(e){return o(e).startTime},n.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07=function(){let e=typeof global>"u"?null:global;return f(e)?0:i(e)},n.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0=function(){let e=typeof globalThis>"u"?null:globalThis;return f(e)?0:i(e)},n.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819=function(){let e=typeof self>"u"?null:self;return f(e)?0:i(e)},n.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40=function(){let e=typeof window>"u"?null:window;return f(e)?0:i(e)},n.wbg.__wbg_stringify_f7ed6987935b4a24=function(){return p(function(e){let t=JSON.stringify(o(e));return i(t)},arguments)},n.wbg.__wbg_table_new=function(e){let t=L.__wrap(e);return i(t)},n.wbg.__wbg_then_44b73946d2fb3e7d=function(e,t){let r=o(e).then(o(t));return i(r)},n.wbg.__wbg_then_48b406749878a531=function(e,t,r){let s=o(e).then(o(t),o(r));return i(s)},n.wbg.__wbg_toString_5285597960676b7b=function(e){let t=o(e).toString();return i(t)},n.wbg.__wbg_trace_d12a9ac890a2cbb8=function(e,t,r,s){console.trace(o(e),o(t),o(r),o(s))},n.wbg.__wbg_trace_e758b839df8d34f1=function(e){console.trace(o(e))},n.wbg.__wbg_value_cd1ffa7b1ab794f1=function(e){let t=o(e).value;return i(t)},n.wbg.__wbg_values_fcb8ba8c0aad8b58=function(e){let t=Object.values(o(e));return i(t)},n.wbg.__wbg_view_new=function(e){let t=P.__wrap(e);return i(t)},n.wbg.__wbg_view_unwrap=function(e){return P.__unwrap(a(e))},n.wbg.__wbg_warn_4ca3906c248c47c4=function(e){console.warn(o(e))},n.wbg.__wbg_warn_aaf1f4664a035bd6=function(e,t,r,s){console.warn(o(e),o(t),o(r),o(s))},n.wbg.__wbindgen_as_number=function(e){return+o(e)},n.wbg.__wbindgen_bigint_from_i64=function(e){return i(e)},n.wbg.__wbindgen_bigint_from_u64=function(e){let t=BigInt.asUintN(64,e);return i(t)},n.wbg.__wbindgen_bigint_get_as_i64=function(e,t){let r=o(t),s=typeof r=="bigint"?r:void 0;l().setBigInt64(e+8,f(s)?BigInt(0):s,!0),l().setInt32(e+0,!f(s),!0)},n.wbg.__wbindgen_boolean_get=function(e){let t=o(e);return typeof t=="boolean"?t?1:0:2},n.wbg.__wbindgen_cb_drop=function(e){let t=a(e).original;return t.cnt--==1?(t.a=0,!0):!1},n.wbg.__wbindgen_closure_wrapper3224=function(e,t,r){let s=ge(e,t,468,ye);return i(s)},n.wbg.__wbindgen_closure_wrapper367=function(e,t,r){let s=we(e,t,7,pe);return i(s)},n.wbg.__wbindgen_debug_string=function(e,t){let r=C(o(t)),s=x(r,_.__wbindgen_export_0,_.__wbindgen_export_1),c=y;l().setInt32(e+4,c,!0),l().setInt32(e+0,s,!0)},n.wbg.__wbindgen_error_new=function(e,t){let r=new Error(w(e,t));return i(r)},n.wbg.__wbindgen_in=function(e,t){return o(e)in o(t)},n.wbg.__wbindgen_is_bigint=function(e){return typeof o(e)=="bigint"},n.wbg.__wbindgen_is_function=function(e){return typeof o(e)=="function"},n.wbg.__wbindgen_is_object=function(e){let t=o(e);return typeof t=="object"&&t!==null},n.wbg.__wbindgen_is_string=function(e){return typeof o(e)=="string"},n.wbg.__wbindgen_is_undefined=function(e){return o(e)===void 0},n.wbg.__wbindgen_jsval_eq=function(e,t){return o(e)===o(t)},n.wbg.__wbindgen_jsval_loose_eq=function(e,t){return o(e)==o(t)},n.wbg.__wbindgen_memory=function(){let e=_.memory;return i(e)},n.wbg.__wbindgen_number_get=function(e,t){let r=o(t),s=typeof r=="number"?r:void 0;l().setFloat64(e+8,f(s)?0:s,!0),l().setInt32(e+0,!f(s),!0)},n.wbg.__wbindgen_number_new=function(e){return i(e)},n.wbg.__wbindgen_object_clone_ref=function(e){let t=o(e);return i(t)},n.wbg.__wbindgen_object_drop_ref=function(e){a(e)},n.wbg.__wbindgen_string_get=function(e,t){let r=o(t),s=typeof r=="string"?r:void 0;var c=f(s)?0:x(s,_.__wbindgen_export_0,_.__wbindgen_export_1),u=y;l().setInt32(e+4,u,!0),l().setInt32(e+0,c,!0)},n.wbg.__wbindgen_string_new=function(e,t){let r=w(e,t);return i(r)},n.wbg.__wbindgen_throw=function(e,t){throw new Error(w(e,t))},n}function Z(n,e){return _=n.exports,ee.__wbindgen_wasm_module=e,A=null,j=null,_}function ve(n){if(_!==void 0)return _;typeof n<"u"&&(Object.getPrototypeOf(n)===Object.prototype?{module:n}=n:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let e=Y();n instanceof WebAssembly.Module||(n=new WebAssembly.Module(n));let t=new WebAssembly.Instance(n,e);return Z(t,n)}async function ee(n){if(_!==void 0)return _;typeof n<"u"&&(Object.getPrototypeOf(n)===Object.prototype?{module_or_path:n}=n:console.warn("using deprecated parameters for the initialization function; pass a single object instead"));let e=Y();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));let{instance:t,module:r}=await he(await n,e);return Z(t,r)}var F=ee;function Ae(){let n,e,t=new Promise((r,s)=>{n=r,e=s});return[n,t,e]}async function te(n,e,t,r){let s,c;async function u(){if(c?.readyState===n.CONNECTING||c?.readyState===n.OPEN){console.warn(`Already connected ${c.readyState}`);return}let[W,m,G]=Ae();c=new n(t,r),c.onopen=W,c.binaryType="arraybuffer",c.onerror=k=>{let E=k.message||"Generic Websocket Error";s.handle_error(E,u),G(E)},c.onclose=k=>{let E=`WebSocket closed ${k.code}`;s.handle_error(E,u),G(E)},c.onmessage=k=>{s.handle_response(k.data)},await m}async function b(W){if(c.readyState===n.CLOSING||c.readyState===n.CLOSED){let m=`WebSocket transport error (${c.readyState})`;throw s.handle_error(m,u),new Error(m)}else if(c.readyState===n.CONNECTING){let m=`WebSocket message dropped (${c.readyState})`;throw new Error(m)}else{let m=W.slice().buffer;c.send(m)}}async function g(){console.debug("Closing WebSocket"),c.close()}return s=new e(b,g),await u(),s}function We(){let n,e,t=new Promise((r,s)=>{n=r,e=s});return[n,t,e]}async function ke(n,e){let[t,r]=We();n.addEventListener("message",function s(c){n.removeEventListener("message",s),t(null)}),n.onmessage=function(c){n.onmessage=function(){},t(null)},n.onmessageerror=console.error,n.postMessage({cmd:"init",args:[e]},{transfer:e instanceof WebAssembly.Module?[]:[e]}),await r}async function ne(n,e,t){let[r,s]=await Promise.all([e,t]),{Client:c}=await n,u;if(typeof SharedWorker<"u"&&s instanceof SharedWorker)u=s.port;else{s=s;let g=new MessageChannel;s.postMessage(null,[g.port2]),u=g.port1}let b=new c(async g=>{let W=g.slice().buffer;u.postMessage(W,{transfer:[W]})},async()=>{console.debug("Closing WebWorker"),u.close(),s instanceof Worker&&s.terminate()});return await ke(u,r),u.addEventListener("message",g=>{b.handle_response(g.data)}),b}async function re(n,e){let{Client:t}=await n;return await te(WebSocket,t,e)}async function se(n){let e;typeof n?.then=="function"&&(n=await n),n instanceof Response?e=await WebAssembly.instantiateStreaming(n):typeof n=="string"?e=await WebAssembly.instantiateStreaming(fetch(n)):n instanceof ArrayBuffer?e=await WebAssembly.instantiate(n):n instanceof Uint8Array?e=await WebAssembly.instantiate(n.buffer):e=n;let t=e.instance.exports,[r]=WebAssembly.Module.customSections(e.module,"psp-runtime"),[s]=WebAssembly.Module.customSections(e.module,"psp-len"),c=new DataView(s).getUint32(0,!0),u=t.resize(r.byteLength);new Uint8Array(t.memory.buffer).set(new Uint8Array(r),u);let b=t.compile(r.byteLength,c);return new Uint8Array(t.memory.buffer).slice(b,c+b)}if(typeof WebAssembly>"u")throw new Error("WebAssembly not supported.");async function D(n){n instanceof Function&&(n=await n());try{return await se(n)}catch{return console.warn("Stage 0 wasm loading failed, skipping"),new Uint8Array(n)}}var H='"use strict";(()=>{var I=Object.defineProperty;var S=(s,t,r)=>t in s?I(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r;var f=(s,t,r)=>S(s,typeof t!="symbol"?t+"":t,r);var v=class{constructor(t){f(this,"poll_handle");f(this,"server");this.server=t}set_poll_handle(){return this.poll_handle=new Promise((t,r)=>setTimeout(()=>this.server.poll().then(t).catch(r).finally(()=>{this.poll_handle=void 0}))),this.poll_handle}async on_poll_request(){this.poll_handle?await this.poll_handle.then(()=>{if(!this.poll_handle)return this.set_poll_handle()}):await this.set_poll_handle()}},h=class{constructor(t,r){f(this,"clients");f(this,"server");f(this,"module");f(this,"on_poll_request");this.clients=new Map,this.module=t,this.on_poll_request=r?.on_poll_request,this.server=t._psp_new_server(r?.on_poll_request?1:0)}make_session(t){let r=this.module._psp_new_session(this.server);return this.clients.set(r,t),new P(this.module,this.server,r,this.clients,this.on_poll_request&&(()=>this.on_poll_request(this)))}async poll(){let t=this.module._psp_poll(this.server);await A(this.module,t,async r=>{await this.clients.get(r.client_id)(r.data)})}delete(){this.module._psp_delete_server(this.server)}},P=class{constructor(t,r,i,a,l){this.mod=t;this.server=r;this.client_id=i;this.client_map=a;this.on_poll_request=l}async handle_request(t){let r=await H(this.mod,t,async i=>this.mod._psp_handle_request(this.server,this.client_id,i,this.mod._psp_is_memory64()?BigInt(t.byteLength):t.byteLength));await A(this.mod,r,async i=>{await this.client_map.get(i.client_id)(i.data)}),this.on_poll_request?await this.on_poll_request():await this.poll()}async poll(){let t=this.mod._psp_poll(this.server);await A(this.mod,t,async r=>{r.client_id===0?await this.client_map.get(this.client_id)(r.data):await this.client_map.get(r.client_id)(r.data)})}close(){this.mod._psp_close_session(this.server,this.client_id)}};async function H(s,t,r){let i=s._psp_alloc(s._psp_is_memory64()?BigInt(t.byteLength):t.byteLength);s.HEAPU8.set(t,Number(i));let a=await r(i);return s._psp_free(i),a}async function A(s,t,r){let i=s._psp_is_memory64(),a=new DataView(s.HEAPU8.buffer,Number(t),i?12:8),l=a.getUint32(0,!0),u=i?a.getBigInt64(4,!0):a.getUint32(4,!0),e=new DataView(s.HEAPU8.buffer,Number(u),l*(i?16:12));try{for(let n=0;n<l;n++){let[o,p,y]=i?[e.getBigInt64(n*16,!0),e.getInt32(n*16+8,!0),e.getInt32(n*16+12,!0)]:[e.getInt32(n*12,!0),e.getInt32(n*12+4,!0),e.getInt32(n*12+8,!0)],c=new Uint8Array(s.HEAPU8.buffer,Number(o),p);await r({client_id:y,data:c})}}finally{for(let n=0;n<l;n++){let o=i?e.getBigInt64(n*16,!0):e.getInt32(n*12,!0);s._psp_free(o)}s._psp_free(i?BigInt(e.byteOffset):e.byteOffset),s._psp_free(i?BigInt(a.byteOffset):a.byteOffset)}}var q=console.log.bind(console),L=console.error.bind(console),N=new TextDecoder("utf8"),R=[null,[],[]];function j(s,t=0,r=NaN){for(var i=t+r,a=t;s[a]&&!(a>=i);)++a;return N.decode(s instanceof Uint8Array?s.subarray(t,a):new Uint8Array(s.slice(t,a)))}function E(s,t){var r=R[s];t===0||t===10?((s===1?q:L)(j(r,0)),r.length=0):r.push(t)}async function U(s){let t,r=!1,i,a={HaveOffsetConverter(){console.error("HaveOffsetConverter")},__syscall_ftruncate64(...e){console.error("__syscall_frtuncate64",e)},__syscall_getdents64(...e){console.error("__syscall_frtuncate64",e)},__syscall_unlinkat(...e){console.error("__syscall_frtuncate64",e)},__throw_exception_with_stack_trace(e){let n=new WebAssembly.Exception(t.__cpp_exception,[e],{traceStack:!0});throw n.message="Unexpected internal error",n},clock_time_get(e,n,o){if(r){if(o=o,o=Number(o),!(e==0||e==1||e==2||e==3))return 28;var p;e===0?p=Date.now():p=performance.now();let c=Math.round(p*1e3*1e3),_=new BigInt64Array(i.buffer);return _[o/8]=BigInt(c),0}else{if(o=o,o>>>=0,!(e==0||e==1||e==2||e==3))return 28;var p;e===0?p=Date.now():p=performance.now();var y=Math.round(p*1e6);let _=new BigInt64Array(i.buffer);return _[o>>>3]=BigInt(y),0}},emscripten_asm_const_int(...e){return 0},emscripten_notify_memory_growth(e){r?e=Number(e):(e=e,e>>>=0),e!=0&&console.error("abort")},environ_get(...e){return 0},environ_sizes_get(...e){return 0},fd_close(...e){return console.error("fd_close",e),0},fd_read(...e){return console.error("fd_read",e),0},fd_seek(...e){return console.error("fs_seek",e),0},fd_write(e,n,o,p){let y=new Uint8Array(i.buffer);if(r){n=Number(n),o=Number(o),p=Number(p);let c=0,_=new BigUint64Array(i.buffer);for(let d=0;d<o;d++){let w=Number(_[n/8]),b=Number(_[(n+8)/8]);n+=16;for(let m=0;m<b;m++)E(e,y[w+m]);c+=b}return _[p/8]=BigInt(c),0}else{n=n,o=o,p=p,n>>>=0,o>>>=0,p>>>=0;let c=0,_=new Uint32Array(i.buffer);for(let d=0;d<o;d++){let w=_[n>>>2>>>0],b=_[n+4>>>2>>>0];n+=8;for(let m=0;m<b;m++)E(e,y[w+m>>>0]);c+=b}return _[p>>>2>>>0]=c,0}},proc_exit(e){return console.error("proc_exit",e),0}},l=await s.instantiateWasm({env:a,wasi_snapshot_preview1:a},e=>{t=e.exports,r=!!t.psp_is_memory64(),i=e.exports.memory,t._initialize()}),u={};for(let[e,n]of Object.entries(l))u[`_${e}`]=n;return{...l,...u,get HEAPU8(){return new Uint8Array(i.buffer)}}}async function M(s){let t=await U({locateFile(r){return r},instantiateWasm:async(r,i)=>{r.env={...r.env,psp_stack_trace(){let l=Error().stack||"",e=new TextEncoder().encode(l),n=t._psp_alloc(t._psp_is_memory64()?BigInt(e.byteLength+1):e.byteLength+1);return t.HEAPU8.set(e,Number(n)),t.HEAPU8[Number(n)+e.byteLength]=0,n},psp_heap_size(){return t._psp_is_memory64()?BigInt(t.HEAPU8.buffer.byteLength):t.HEAPU8.buffer.byteLength}};let a=await WebAssembly.instantiate(s,r);return i(a.instance),a.instance.exports}});return t}var g,x;function B(s){let t=s.ports[0],r;t.addEventListener("message",async i=>{if(i.data.cmd==="init"){let a=i.data.id;if(!g){let l=await M(i.data.args[0]);g=new h(l,{on_poll_request:()=>x.on_poll_request()}),x=new v(g)}r=g.make_session(async l=>{let u=l.slice().buffer;t.postMessage(u,{transfer:[u]})}),t.postMessage({id:a})}else await r.handle_request(new Uint8Array(i.data))}),t.start()}self.addEventListener("connect",B);self.addEventListener("message",B);})();\n';function oe(n,e){function t(c,u){c==="message"&&n.push(u)}function r(c){let u=n.indexOf(c);u>-1&&n.splice(u,1)}function s(c,u){for(let b of e)b({data:c,ports:u})}return{addEventListener:t,removeEventListener:r,postMessage:s,location:{href:""}}}function Se(n){console.error("Running perspective in single-threaded mode");let e=Function("const self = arguments[0];"+n),t=[],r=[];return e(oe(t,r)),oe(r,t)}var Me=async function(){try{if(window.location.protocol.startsWith("file"))return console.warn("file:// protocol does not support Web Workers"),Se(H);{let n=new Blob([H],{type:"application/javascript"}),e=URL.createObjectURL(n);return new Worker(e,{type:"module"})}}catch(n){console.error("Error instantiating engine",n)}},_e=Me;var h;function Ie(n,e=!1){n instanceof Uint8Array?h=Promise.resolve(n.buffer):n instanceof Response?h=Promise.resolve(n):n instanceof Promise?h=n:h=Promise.resolve(n),e||(h=h.then(t=>D(t).then(r=>r.buffer)))}var v;async function R(n,e=!1){let t=e?n:await D(n);return await F({module_or_path:t}),await q(),z}function Oe(n,e=!1){n instanceof Uint8Array?v=R(n.buffer,e):n instanceof ArrayBuffer||n instanceof Response||n instanceof Promise?v=R(n,e):n instanceof Object&&(v=Promise.resolve(n))}function ce(){let n=customElements.get("perspective-viewer");if(n)v=Promise.resolve(n.__wasm_module__);else if(v===void 0)throw new Error("Missing perspective-client.wasm");return v}function Pe(){if(h===void 0)throw new Error("Missing perspective-server.wasm");return h.then(n=>n instanceof WebAssembly.Module?n:n.slice(0))}var ie;function Ue(){return ie===void 0?_e():ie()}async function Be(n){return await re(ce(),n)}async function Le(n){return typeof n>"u"&&(n=Ue()),await ne(ce(),Pe(),n)}var $={websocket:Be,worker:Le,init_client:Oe,init_server:Ie};var Re=new URL("../../../server/dist/wasm/perspective-server.wasm",import.meta.url);$.init_server(fetch(Re));var Je=$;export{Je as default,Oe as init_client,Ie as init_server,Be as websocket,Le as worker};
|
|
3
|
+
//# sourceMappingURL=perspective.js.map
|