@substratedb/sync-core 0.0.0-stage → 0.1.4
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 +202 -0
- package/README.md +151 -2
- package/dist/web/glue.d.ts +54 -0
- package/dist/web/glue.js +388 -0
- package/dist/web/index.d.ts +13 -0
- package/dist/web/index.js +38 -0
- package/dist/web/wasm.d.ts +1 -0
- package/dist/web/wasm.js +2 -0
- package/package.json +34 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
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,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,152 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Substrate sync core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The part of every Substrate SDK that must behave the same everywhere, in
|
|
4
|
+
Rust and with no I/O. It speaks the realtime protocol in
|
|
5
|
+
[`docs/architecture/REALTIME_PROTOCOL.md`](../../docs/architecture/REALTIME_PROTOCOL.md).
|
|
6
|
+
|
|
7
|
+
Events go in as JSON and instructions come out as a JSON array:
|
|
8
|
+
|
|
9
|
+
| Event | Fields |
|
|
10
|
+
| --------------------- | -------------------------------------------------------------------------------- |
|
|
11
|
+
| `restored` | `version`, `resumeToken`, `queries` stored |
|
|
12
|
+
| `connected` | `now`: the socket finished `hello` |
|
|
13
|
+
| `disconnected` | |
|
|
14
|
+
| `watch` | `query`: `queryId`, `canonicalQueryHash`, and `program` or `call` |
|
|
15
|
+
| `unwatch` | `queryId` |
|
|
16
|
+
| `write` | `write`: `executionId`, `idempotencyKey`, and `program` or `command`; `now` |
|
|
17
|
+
| `commandAnswer` | `executionId`, `now`, and `result` (`committedVersion`, `projection`) or `error` |
|
|
18
|
+
| `message` | `message` from the server, `now` |
|
|
19
|
+
| `tick` | `now`: acknowledgement batching, chunk timeouts, channel retries and deadlines |
|
|
20
|
+
| `watchLog` | `logId`, `call`: a live log call, `input.after` its cursor |
|
|
21
|
+
| `unwatchLog` | `logId` |
|
|
22
|
+
| `joinChannel` | `subscriptionId` (the shell's name for it), `feature`, `channel` |
|
|
23
|
+
| `leaveChannel` | `subscriptionId` |
|
|
24
|
+
| `channelWrite` | `subscriptionId`, `writeId`, `value` of the session's key, `now` |
|
|
25
|
+
| `channelSend` | `subscriptionId`, `writeId`, `value` of a message, `now` |
|
|
26
|
+
| `channelsInterrupted` | `error`: the socket cannot authorize |
|
|
27
|
+
| `ended` | `error`: the shell ended the session (a deleted branch, a closed client) |
|
|
28
|
+
| `close` | nothing needs the session: it ends in order and the next socket starts fresh |
|
|
29
|
+
|
|
30
|
+
| Instruction | The shell |
|
|
31
|
+
| -------------------- | --------------------------------------------------------------------------------------------- |
|
|
32
|
+
| `send` | sends `message` on the socket |
|
|
33
|
+
| `postCommand` | posts `request`'s command to `/runtime/commands` and answers with `commandAnswer` |
|
|
34
|
+
| `store` | stores the cursor and `queries`, drops `removed` (all, with `replace`), in one transaction |
|
|
35
|
+
| `queriesChanged` | reads the named queries' rows with `rows(queryId)` and shows them |
|
|
36
|
+
| `reflected` | the server's rows now include these writes, or they left the queue answered and shown nowhere |
|
|
37
|
+
| `optimistic` | write `executionId`'s module `result`, shown until the branch answers |
|
|
38
|
+
| `writeResult` | the branch ran write `executionId`: its `result` |
|
|
39
|
+
| `writeFailed` | write `executionId` left the queue with `error`; its effect is gone |
|
|
40
|
+
| `queryFailed` | the server cannot serve this query |
|
|
41
|
+
| `failed` | the session cannot continue |
|
|
42
|
+
| `logEntries` | gives log `logId` its `entries` (`seq`, `payload`) after the last ones, in order |
|
|
43
|
+
| `logFailed` | log `logId` ended with `error` |
|
|
44
|
+
| `channelEntries` | shows channel `subscriptionId`'s keys: all of them (`replace`), else the changed `entries` |
|
|
45
|
+
| `channelWriteResult` | answers write or message `writeId`: its `key` and `version`, or `error` |
|
|
46
|
+
| `channelWritten` | the branch wrote the session's `key`, also when a join wrote it again |
|
|
47
|
+
| `channelValue` | the session's key now holds `value` (null: none), after a refusal |
|
|
48
|
+
| `channelDropped` | the branch refused the value it accepted before: the session holds no key |
|
|
49
|
+
| `channelMessage` | another session's message `value`, named by its sender's `key` |
|
|
50
|
+
| `channelInterrupted` | the channel waits to join, since the socket cannot authorize |
|
|
51
|
+
| `channelFailed` | the channel ended with `error` |
|
|
52
|
+
| `channelReport` | a failure no write waits for, such as a refused removal after a leave |
|
|
53
|
+
|
|
54
|
+
The core applies a transition whole or not at all, checks every version
|
|
55
|
+
step, joins chunks and rows parts, acknowledges at once or in batches of
|
|
56
|
+
32 (or after 1 second), repairs one gap at a time, and subscribes fresh
|
|
57
|
+
when a resume has expired.
|
|
58
|
+
|
|
59
|
+
## Modules
|
|
60
|
+
|
|
61
|
+
A queued Strata write shows at once on every watched read of the source
|
|
62
|
+
it writes: data, state stores and object stores each project it over the
|
|
63
|
+
rows the server returned. A
|
|
64
|
+
projection never makes a row up. When it cannot be exact (a field the rows
|
|
65
|
+
lack, a key the read left out, a full limit window, a file's rendered
|
|
66
|
+
path) the core asks the branch for every query's rows again, once until
|
|
67
|
+
another query becomes inexact. Before a write is queued, each data create
|
|
68
|
+
without an id takes one: the first the UUID of the `sx1` execution id,
|
|
69
|
+
later ones a UUID drawn from it, so a resend names the same rows. A create
|
|
70
|
+
that needs an id under any other execution id fails
|
|
71
|
+
(`INVALID_EXECUTION_IDENTITY`).
|
|
72
|
+
|
|
73
|
+
A feature command (`module`, `command`, `input`: a flag override, a
|
|
74
|
+
cohort member, an inbox read, a machine call) is queued with the Strata
|
|
75
|
+
writes, in one order, under an `sx1` execution id. The core hands the one
|
|
76
|
+
at the queue's head to the shell (`postCommand`), which posts it with its
|
|
77
|
+
idempotency key and gives back the branch's answer (`commandAnswer`); a
|
|
78
|
+
write behind it waits for that answer, which the shell always gives (a
|
|
79
|
+
lost one as a retryable `NETWORK_ERROR`): a post stays in flight across a
|
|
80
|
+
reconnect, so it is never posted twice at once. A retryable failure posts
|
|
81
|
+
it again with the same key after the same backoff as a write; the branch
|
|
82
|
+
replays a key it already ran. Flags, cohorts and
|
|
83
|
+
notifications show a command at once on the reads it changes, with the
|
|
84
|
+
same rules as a write's projection; other modules show it once the
|
|
85
|
+
branch's rows hold it.
|
|
86
|
+
|
|
87
|
+
## Live logs
|
|
88
|
+
|
|
89
|
+
A live log call (K-LOG) is a live call whose input names its cursor
|
|
90
|
+
`after`. The core gives the shell each entry once, in order, after a first
|
|
91
|
+
read that may hold none. Each log has its own query (`<hash>:<logId>`); once
|
|
92
|
+
it holds a full window (64 entries) the core moves it, in one subscribe, to
|
|
93
|
+
a query after the last entry it gave. A reconnect gives only entries after
|
|
94
|
+
that one. An expired cursor moves the log past the entries given, and fails
|
|
95
|
+
it with `KERNEL_LOG_CURSOR_EXPIRED` only when none were. A log opened again
|
|
96
|
+
under its name (a new `generation`) fails with `KERNEL_LOG_REPLACED`.
|
|
97
|
+
|
|
98
|
+
## Channels
|
|
99
|
+
|
|
100
|
+
Channels (K-EPH) hold presence and other ephemeral state, never stored. A
|
|
101
|
+
channel writes only while it is joined, from the snapshot that answers its
|
|
102
|
+
join (every part of it) until the socket closes or the branch resets its
|
|
103
|
+
channels; each join writes the session's kept value again. A snapshot shows every
|
|
104
|
+
key (`replace`); a change shows only the keys it changed (`key`, `value`,
|
|
105
|
+
null for a removed one), so the shell keeps the keys. The core reads a
|
|
106
|
+
push as typed fields and keeps each value as the text it arrived as; a push
|
|
107
|
+
it cannot read changes nothing and is reported (`channelReport`,
|
|
108
|
+
`CHANNEL_PUSH_INVALID`). A refused value
|
|
109
|
+
falls back to the last one accepted, or removes the key. A retryable
|
|
110
|
+
refusal joins again after 1 s, doubling, five times. Each write and message
|
|
111
|
+
is answered once: by the branch, a refusal, or its 30 s deadline (`tick`).
|
|
112
|
+
A message is never sent twice: one the socket lost fails with
|
|
113
|
+
`CHANNEL_SEND_INTERRUPTED`. When the session fails, every channel ends with
|
|
114
|
+
it, answered before `failed`; a session the shell ends (`ended`) ends
|
|
115
|
+
them the same way. Each join subscribes under an id of the core's own, so
|
|
116
|
+
a channel joined again under the shell's name never hears the answers of
|
|
117
|
+
the one before.
|
|
118
|
+
|
|
119
|
+
## Building
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
pnpm --filter @substratedb/sync-core test # cargo test, then the packaged web core
|
|
123
|
+
pnpm --filter @substratedb/sync-core build # the web core in dist/web (feature wasm)
|
|
124
|
+
./build-xcframework.sh # iOS device, simulator and macOS, with the Swift bindings
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`rust-toolchain.toml` pins Rust and the WebAssembly target. The web build
|
|
128
|
+
also needs `wasm-bindgen-cli` at the crate's version
|
|
129
|
+
(`cargo install --locked wasm-bindgen-cli --version 0.2.130`). It writes
|
|
130
|
+
`dist/web`, the package's `./web` export: the wasm-bindgen glue with the
|
|
131
|
+
WebAssembly inlined (gzipped, then base64), so an app's bundler needs no
|
|
132
|
+
setup. `loadSyncCore()` imports the bytes as their own chunk, unpacks them
|
|
133
|
+
with `DecompressionStream` and instantiates the core once per realm, so a
|
|
134
|
+
page loads the core apart from its first paint; a load that failed is
|
|
135
|
+
tried again by the next call. It needs `DecompressionStream`: Chrome 80,
|
|
136
|
+
Safari 16.4, Firefox 113, Node 20 or later. Every core of a realm draws on one WebAssembly memory
|
|
137
|
+
(4 GiB at most, never shrinking); `memoryBytes()` is its size, and the web
|
|
138
|
+
engine opens no new core past 3 GiB (`SYNC_CORE_MEMORY_EXHAUSTED`).
|
|
139
|
+
|
|
140
|
+
Swift and Kotlin bind through UniFFI (feature `uniffi`); the web through
|
|
141
|
+
wasm-bindgen (feature `wasm`). Both expose `SyncCore(clientId, requestPrefix, capabilities)` with `hello()`, `handle(event)` and `rows(queryId)`.
|
|
142
|
+
|
|
143
|
+
## Capabilities
|
|
144
|
+
|
|
145
|
+
The SDK names the capabilities it implements when it creates the core
|
|
146
|
+
(`channels`, `execution-batch`, `keyed-resume`, `live-calls`, `surfaces`); an
|
|
147
|
+
unknown name is refused. `hello()` answers the `protocolVersion` and
|
|
148
|
+
`capabilities` for the shell's `hello`. Without `live-calls` a live call is
|
|
149
|
+
refused (`CAPABILITY_NOT_DECLARED`), without `keyed-resume` a call with
|
|
150
|
+
`since` is, and without `execution-batch` writes go one at a time. A
|
|
151
|
+
`hello_ack` that lacks a declared capability ends the session
|
|
152
|
+
(`REALTIME_CAPABILITY_UNSUPPORTED`).
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class SyncCore {
|
|
5
|
+
free(): void;
|
|
6
|
+
handle(event: string): string;
|
|
7
|
+
hello(): string;
|
|
8
|
+
constructor(client_id: string, request_prefix: string, capabilities: string[]);
|
|
9
|
+
rows(query_id: string): string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function queryHash(query: string): string;
|
|
13
|
+
|
|
14
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
15
|
+
|
|
16
|
+
export interface InitOutput {
|
|
17
|
+
readonly memory: WebAssembly.Memory;
|
|
18
|
+
readonly __wbg_synccore_free: (a: number, b: number) => void;
|
|
19
|
+
readonly queryHash: (a: number, b: number) => [number, number, number, number];
|
|
20
|
+
readonly synccore_handle: (a: number, b: number, c: number) => [number, number, number, number];
|
|
21
|
+
readonly synccore_hello: (a: number) => [number, number, number, number];
|
|
22
|
+
readonly synccore_new: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
23
|
+
readonly synccore_rows: (a: number, b: number, c: number) => [number, number, number, number];
|
|
24
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
25
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
26
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
27
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
28
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
29
|
+
readonly __externref_table_alloc: () => number;
|
|
30
|
+
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
31
|
+
readonly __wbindgen_start: () => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
38
|
+
* a precompiled `WebAssembly.Module`.
|
|
39
|
+
*
|
|
40
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
41
|
+
*
|
|
42
|
+
* @returns {InitOutput}
|
|
43
|
+
*/
|
|
44
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
48
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
49
|
+
*
|
|
50
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
51
|
+
*
|
|
52
|
+
* @returns {Promise<InitOutput>}
|
|
53
|
+
*/
|
|
54
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|