@automerge/automerge-repo-svelte-store 1.0.1 → 1.0.3
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/dist/index.d.ts +56 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -0
- package/package.json +3 -3
- package/src/index.ts +57 -0
- package/typedoc.json +5 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* # Svelte store for Automerge Repo
|
|
3
|
+
*
|
|
4
|
+
* ## Example Usage
|
|
5
|
+
*
|
|
6
|
+
* For a working example, see the [Svelte counter demo](../automerge-repo-demo-counter-svelte/).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```svelte
|
|
11
|
+
* // App.svelte
|
|
12
|
+
* <script lang="ts">
|
|
13
|
+
* import { Repo } from "@automerge/automerge-repo"
|
|
14
|
+
* import Counter from './lib/Counter.svelte'
|
|
15
|
+
* import { setContextRepo } from "@automerge/automerge-repo-svelte-store"
|
|
16
|
+
*
|
|
17
|
+
* const repo = new Repo({storage: new SomeStorage() })
|
|
18
|
+
*
|
|
19
|
+
* // Make the `Repo` available to child components (via Svelte's `setContext`).
|
|
20
|
+
* setContextRepo(repo)
|
|
21
|
+
*
|
|
22
|
+
* const docId = repo.create()
|
|
23
|
+
* </script>
|
|
24
|
+
*
|
|
25
|
+
* <main>
|
|
26
|
+
* <div class="card">
|
|
27
|
+
* <Counter {docId}/>
|
|
28
|
+
* </div>
|
|
29
|
+
* </main>
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
*
|
|
33
|
+
* ```svelte
|
|
34
|
+
* // Counter.svelte`
|
|
35
|
+
* <script lang="ts">
|
|
36
|
+
* import type { DocumentId } from "@automerge/automerge-repo"
|
|
37
|
+
* import { document } from "@automerge/automerge-repo-svelte-store"
|
|
38
|
+
*
|
|
39
|
+
* export let docId: DocumentId
|
|
40
|
+
*
|
|
41
|
+
* // `document` calls `getContextRepo` internally to access the closest `Repo`.
|
|
42
|
+
* const doc = document<{count?: number}>(docId)
|
|
43
|
+
* const increment = () => {
|
|
44
|
+
* doc.change((d) => d.count = (d.count || 0) + 1)
|
|
45
|
+
* }
|
|
46
|
+
* </script>
|
|
47
|
+
*
|
|
48
|
+
* <button on:click={increment}>
|
|
49
|
+
* count is {$doc?.count || 0}
|
|
50
|
+
* </button>
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* ## Contributors
|
|
54
|
+
* Originally written by Dylan MacKenzie ([@ecstatic-morse](https://github.com/ecstatic-morse)).
|
|
55
|
+
* * @packageDocumentation
|
|
56
|
+
**/
|
|
1
57
|
/// <reference types="svelte" />
|
|
2
58
|
import type { ChangeFn, Doc } from "@automerge/automerge/next";
|
|
3
59
|
import { AutomergeUrl, Repo } from "@automerge/automerge-repo";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EACL,YAAY,EAEZ,IAAI,EACL,MAAM,2BAA2B,CAAA;AAMlC,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,QAExC;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,UAAU,EAAE,YAAY;;iBAWnC,SAAS,CAAC,CAAC;EAI3B"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* # Svelte store for Automerge Repo
|
|
3
|
+
*
|
|
4
|
+
* ## Example Usage
|
|
5
|
+
*
|
|
6
|
+
* For a working example, see the [Svelte counter demo](../automerge-repo-demo-counter-svelte/).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```svelte
|
|
11
|
+
* // App.svelte
|
|
12
|
+
* <script lang="ts">
|
|
13
|
+
* import { Repo } from "@automerge/automerge-repo"
|
|
14
|
+
* import Counter from './lib/Counter.svelte'
|
|
15
|
+
* import { setContextRepo } from "@automerge/automerge-repo-svelte-store"
|
|
16
|
+
*
|
|
17
|
+
* const repo = new Repo({storage: new SomeStorage() })
|
|
18
|
+
*
|
|
19
|
+
* // Make the `Repo` available to child components (via Svelte's `setContext`).
|
|
20
|
+
* setContextRepo(repo)
|
|
21
|
+
*
|
|
22
|
+
* const docId = repo.create()
|
|
23
|
+
* </script>
|
|
24
|
+
*
|
|
25
|
+
* <main>
|
|
26
|
+
* <div class="card">
|
|
27
|
+
* <Counter {docId}/>
|
|
28
|
+
* </div>
|
|
29
|
+
* </main>
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
*
|
|
33
|
+
* ```svelte
|
|
34
|
+
* // Counter.svelte`
|
|
35
|
+
* <script lang="ts">
|
|
36
|
+
* import type { DocumentId } from "@automerge/automerge-repo"
|
|
37
|
+
* import { document } from "@automerge/automerge-repo-svelte-store"
|
|
38
|
+
*
|
|
39
|
+
* export let docId: DocumentId
|
|
40
|
+
*
|
|
41
|
+
* // `document` calls `getContextRepo` internally to access the closest `Repo`.
|
|
42
|
+
* const doc = document<{count?: number}>(docId)
|
|
43
|
+
* const increment = () => {
|
|
44
|
+
* doc.change((d) => d.count = (d.count || 0) + 1)
|
|
45
|
+
* }
|
|
46
|
+
* </script>
|
|
47
|
+
*
|
|
48
|
+
* <button on:click={increment}>
|
|
49
|
+
* count is {$doc?.count || 0}
|
|
50
|
+
* </button>
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* ## Contributors
|
|
54
|
+
* Originally written by Dylan MacKenzie ([@ecstatic-morse](https://github.com/ecstatic-morse)).
|
|
55
|
+
* * @packageDocumentation
|
|
56
|
+
**/
|
|
1
57
|
import { getContext, setContext } from "svelte";
|
|
2
58
|
import { writable } from "svelte/store";
|
|
3
59
|
const ContextRepoKey = Symbol("svelte-context-automerge-repo");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automerge/automerge-repo-svelte-store",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "A Svelte store containing your automerge documentsj",
|
|
5
5
|
"repository": "https://github.com/automerge/automerge-repo",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@automerge/automerge": "^2.1.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@automerge/automerge-repo": "^1.0.
|
|
18
|
+
"@automerge/automerge-repo": "^1.0.3",
|
|
19
19
|
"svelte": ">=3.0.0"
|
|
20
20
|
},
|
|
21
21
|
"watch": {
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "4f3391cd33cd0cabfebde48dbd56749ddb6922da"
|
|
33
33
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* # Svelte store for Automerge Repo
|
|
3
|
+
*
|
|
4
|
+
* ## Example Usage
|
|
5
|
+
*
|
|
6
|
+
* For a working example, see the [Svelte counter demo](../automerge-repo-demo-counter-svelte/).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```svelte
|
|
11
|
+
* // App.svelte
|
|
12
|
+
* <script lang="ts">
|
|
13
|
+
* import { Repo } from "@automerge/automerge-repo"
|
|
14
|
+
* import Counter from './lib/Counter.svelte'
|
|
15
|
+
* import { setContextRepo } from "@automerge/automerge-repo-svelte-store"
|
|
16
|
+
*
|
|
17
|
+
* const repo = new Repo({storage: new SomeStorage() })
|
|
18
|
+
*
|
|
19
|
+
* // Make the `Repo` available to child components (via Svelte's `setContext`).
|
|
20
|
+
* setContextRepo(repo)
|
|
21
|
+
*
|
|
22
|
+
* const docId = repo.create()
|
|
23
|
+
* </script>
|
|
24
|
+
*
|
|
25
|
+
* <main>
|
|
26
|
+
* <div class="card">
|
|
27
|
+
* <Counter {docId}/>
|
|
28
|
+
* </div>
|
|
29
|
+
* </main>
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
*
|
|
33
|
+
* ```svelte
|
|
34
|
+
* // Counter.svelte`
|
|
35
|
+
* <script lang="ts">
|
|
36
|
+
* import type { DocumentId } from "@automerge/automerge-repo"
|
|
37
|
+
* import { document } from "@automerge/automerge-repo-svelte-store"
|
|
38
|
+
*
|
|
39
|
+
* export let docId: DocumentId
|
|
40
|
+
*
|
|
41
|
+
* // `document` calls `getContextRepo` internally to access the closest `Repo`.
|
|
42
|
+
* const doc = document<{count?: number}>(docId)
|
|
43
|
+
* const increment = () => {
|
|
44
|
+
* doc.change((d) => d.count = (d.count || 0) + 1)
|
|
45
|
+
* }
|
|
46
|
+
* </script>
|
|
47
|
+
*
|
|
48
|
+
* <button on:click={increment}>
|
|
49
|
+
* count is {$doc?.count || 0}
|
|
50
|
+
* </button>
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* ## Contributors
|
|
54
|
+
* Originally written by Dylan MacKenzie ([@ecstatic-morse](https://github.com/ecstatic-morse)).
|
|
55
|
+
* * @packageDocumentation
|
|
56
|
+
**/
|
|
57
|
+
|
|
1
58
|
import type { ChangeFn, Doc } from "@automerge/automerge/next"
|
|
2
59
|
import {
|
|
3
60
|
AutomergeUrl,
|