Commit graph

219 commits

Author SHA1 Message Date
Alex Good
dbf438f7cb
Track whether a transaction is observed in types
With the `OpObserver` moving to the transaction rather than being passed
in to the `Transaction::commit` method we have needed to add a way to
get the observer back out of the transaction (via
`Transaction::observer` and `AutoCommit::observer`). This `Observer`
type is then used to handle patch generation logic. However, there are
cases where we might not want an `OpObserver` and in these cases we can
execute various things fast - so we need to have something like an
`Option<OpObserver>`. In order to track the presence or otherwise of the
observer at the type level introduce
`automerge::transaction::observation`, which is a type level `Option`.
This allows us to efficiently choose the right code paths whilst
maintaining correct types for `Transaction::observer` and
`AutoCommit::observer`
2022-10-06 22:38:37 +01:00
Orion Henry
8b7fa5d33f typescript fixes 2022-10-04 14:09:38 -05:00
Orion Henry
4e17d798be
move automerge-js onto the applyPatches model 2022-10-04 18:17:03 +01:00
Orion Henry
210e9648bf
The patch interface needs an accurate path per patch op
For the path to be accurate it needs to be calculated at the moment of op insert
not at commit.  This is because the path may contain list indexes in parent
objects that could change by inserts and deletes later in the transaction.

The primary change was adding op_observer to the transaction object and
removing it from commit options.  The beginnings of a wasm level
`applyPatch` system is laid out here.
2022-10-04 18:15:49 +01:00
Alex Good
da51492327 build both nodejs and bundler packages in yarn build 2022-10-04 17:23:37 +01:00
Alex Good
577bda3e7f update wasm-bindgen 2022-10-04 17:23:37 +01:00
Alex Good
a9e23308ce Remove async automerge-wasm wrapper
By moving to wasm-bindgens `bundler` target rather than using the `web`
target we remove the need for an async initialization step on the
automerge-wasm package. This means that the automerge-js package can now
depend directly on automerge-wasm and perform initialization itself,
thus making automerge-js a drop in replacement for the `automerge` JS
package (hopefully).

We bump the versions of automerge-wasm
2022-10-04 17:23:37 +01:00
Alex Good
e57548f6e2
Fix broken encode/decode change
Previous ceremonies to appease clippy resulted in the
encodeChange/decodeChange wasm functions being slightly broken. Here we
fix them.
2022-09-29 15:49:31 -05:00
Alex Good
c7e370a1df
Appease clippy 2022-09-28 17:18:37 -05:00
Orion Henry
59bde120ee automerge-js adding trace to out of date errors 2022-08-26 14:17:56 -05:00
Alex Good
9ac8827219
Remove storage-v2 feature flag
Signed-off-by: Alex Good <alex@memoryandthought.me>
2022-08-22 21:21:21 +01:00
Alex Good
fc94d43e53
Expose storage-v2 in automerge-wasm
Signed-off-by: Alex Good <alex@memoryandthought.me>
2022-08-22 21:16:47 +01:00
Alex Good
d785c319b8
Add ScalarValue::Unknown
The colunar storage format allows for values which we do not know the
type of. In order that we can handle these types in a forward compatible
way we add ScalarValue::Unknown.

Signed-off-by: Alex Good <alex@memoryandthought.me>
2022-08-22 21:04:19 +01:00
Orion Henry
ff90327b52
Merge pull request #414 from jkankiewicz/port_WASM_basic_tests_to_C
Port the WASM API's basic tests to C
2022-08-11 19:00:11 -05:00
Orion Henry
1a955e1f0d fix some typescript errors - depricate default export of the wasm package 2022-08-11 18:24:21 -05:00
Jason Kankiewicz
14bd8fbe97 Port the WASM API's basic unit tests to C.
Weave the original TypeScript code into the C ports of the WASM API's
sync tests.
Fix misnomers in the WASM API's basic and sync unit tests.
Fix misspellings in the WASM API's basic and sync unit tests.
2022-08-06 16:18:59 -07:00
Ryan Fitzgerald
88073c0cf4 Fix TypeScript syntax error in automerge-wasm definitions
I'm not sure if there are some configurations under which this works,
but I get

    index.d.ts:2:21 - error TS1005: ';' expected.

    2 export default from "automerge-types"
                          ~~~~~~~~~~~~~~~~~

both in my project that depends on `automerge-wasm` and when I run `tsc`
in this repo.

It seems like `export default from` is still a Stage 1 proposal, so I
wouldn't expect it to be supported by TS, although I couldn't really
find hard evidence one way or the other. It does seem like this syntax
should be exactly equivalent based on the proposal doc though.
2022-06-17 20:11:26 -07:00
Orion Henry
9a0dd24714 fmt / tests 2022-06-01 08:08:01 -04:00
Orion Henry
8ce10dab69 some api changes/tweaks - basic js package 2022-05-31 13:49:18 -04:00
Orion Henry
210c6d2045 move types to their own package 2022-05-27 10:23:51 -07:00
Orion Henry
07f5678a2b linting in wasm 2022-05-22 13:54:59 -04:00
Orion Henry
d638a41a6c record type 2022-05-22 13:53:11 -04:00
Orion Henry
bd35361354 fixed typescript errors, pull wasm dep (mostly) out 2022-05-22 13:53:11 -04:00
Orion Henry
515a2eb94b removing some ts errors 2022-05-22 13:53:11 -04:00
Orion Henry
1eec70f116 example webpack for js 2022-05-22 13:53:11 -04:00
Orion Henry
4f898b67b3 able to build npm package 2022-05-22 13:53:11 -04:00
Orion Henry
551f6e1343 convert automerge-js to typescript 2022-05-22 13:53:11 -04:00
Orion Henry
c353abfe4e
Merge pull request #375 from jeffa5/get-changes-opt
Get changes opt
2022-05-22 10:30:24 -07:00
Andrew Jeffery
8b1c3c73cd Use BTreeSet for sync::State to allow deriving Hash 2022-05-20 16:13:10 +01:00
Andrew Jeffery
16f1304345 Fix wasm test calling getChanges with wrong heads 2022-05-20 10:05:08 +01:00
Andrew Jeffery
933bf5ee07 Return an error when getting clock for missing hash 2022-05-20 10:05:08 +01:00
Orion Henry
e1f3ecfcf5 typescript implicit any 2022-05-16 15:09:55 -04:00
Orion Henry
81dd1a56eb add start script - split up outputs 2022-05-16 11:33:08 -04:00
Orion Henry
d01e7ceb0e add webpack example and move into wasm folder 2022-05-15 11:53:55 -04:00
Andrew Jeffery
0aab13a990 Set rust-version in cargo.tomls 2022-05-02 21:18:00 +01:00
Orion Henry
1f86a92ca1 typo 2022-04-25 12:47:13 -04:00
Andrew Jeffery
ec446f4839 Add favicon 2022-04-23 11:31:58 +01:00
Andrew Jeffery
48e397e82f Add lints 2022-04-23 11:05:43 +01:00
Andrew Jeffery
5b0ce54229 Add logo to docs 2022-04-23 10:46:03 +01:00
Orion Henry
e41c5ae021 typescript bugfix 2022-04-20 22:05:05 -04:00
Orion Henry
1bee30c784
Merge branch 'main' into observer-counters 2022-04-20 20:35:07 -04:00
Andrew Jeffery
d667552a98 Add increment observation for observer 2022-04-20 14:44:04 +01:00
Orion Henry
439b9104d6 touch up readme and package files 2022-04-19 14:48:33 -04:00
Andrew Jeffery
aa3c32cea3 Add ApplyOptions 2022-04-19 18:15:22 +01:00
Andrew Jeffery
76a19185b7 Add separate functions for with op_observer 2022-04-19 17:48:11 +01:00
Andrew Jeffery
702a0ec172 Add lifetimes to transact_with and fixup watch example 2022-04-19 17:30:06 +01:00
Andrew Jeffery
b6fd7ac26e Add op_observer to documents and transactions
This replaces the built-in patches with a more generic mechanism, and
includes a convenience observer which uses the old patches.
2022-04-19 17:30:05 +01:00
Orion Henry
a791714f74 extend documentation 2022-04-08 18:34:04 -04:00
Orion Henry
965240d8f6 Merge remote-tracking branch 'origin/experiment' into wasm_readme 2022-04-08 18:07:44 -04:00
Orion Henry
5555d50693 readme fixes 2022-04-08 17:10:53 -04:00