Skip to content

Commit 4bf0613

Browse files
committed
build index.d.ts by hand
1 parent 24f3315 commit 4bf0613

2 files changed

Lines changed: 71 additions & 1 deletion

File tree

_index.d.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import type {
2+
AutomergeUrl,
3+
Doc,
4+
DocHandle,
5+
DocHandleChangePayload,
6+
Repo,
7+
} from "@automerge/automerge-repo/slim"
8+
import type {MaybeAccessor} from "@solid-primitives/utils"
9+
import type {Context} from "solid-js"
10+
import type {Resource} from "solid-js"
11+
import type {Accessor} from "solid-js"
12+
13+
/**
14+
* convert automerge patches to solid producer operations
15+
* @param payload the
16+
* [DocHandleChangePayload](https://automerge.org/automerge-repo/interfaces/_automerge_automerge_repo.DocHandleChangePayload.html)
17+
* from the handle.on("change
18+
* @returns a callback for an immer-like function. e.g.
19+
* [produce](https://docs.solidjs.com/reference/store-utilities/produce) for
20+
* [Solid
21+
* Stores](https://docs.solidjs.com/reference/store-utilities/create-store)
22+
*/
23+
export default function autoproduce<T>(
24+
payload: DocHandleChangePayload<T>
25+
): (doc: T) => void
26+
/**
27+
* a [context](https://docs.solidjs.com/concepts/context) that provides access
28+
* to an Automerge Repo. you don't need this, you can pass the repo in the
29+
* second arg to the functions that need it.
30+
*/
31+
export declare const RepoContext: Context<Repo | null>
32+
33+
/**
34+
* get a fine-grained live view of a document from a handle. works with
35+
* {@link useDocHandle}.
36+
* @param handle an accessor (signal/resource) of a
37+
* [DocHandle](https://automerge.org/automerge-repo/classes/_automerge_automerge_repo.DocHandle.html)
38+
*/
39+
export default function createDocumentProjection<T>(
40+
handle: Accessor<DocHandle<T> | undefined>
41+
): Accessor<Doc<T> | undefined>
42+
43+
export interface UseDocHandleOptions {
44+
repo?: Repo
45+
"~skipInitialValue"?: boolean
46+
}
47+
/**
48+
* get a
49+
* [DocHandle](https://automerge.org/automerge-repo/classes/_automerge_automerge_repo.DocHandle.html)
50+
* from an
51+
* [AutomergeUrl](https://automerge.org/automerge-repo/types/_automerge_automerge_repo.AutomergeUrl.html)
52+
* as a
53+
* [Resource](https://docs.solidjs.com/reference/basic-reactivity/create-resource).
54+
* Waits for the handle to be
55+
* [ready](https://automerge.org/automerge-repo/variables/_automerge_automerge_repo.HandleState-1.html).
56+
*/
57+
export default function useDocHandle<T>(
58+
url: MaybeAccessor<AutomergeUrl | undefined>,
59+
options?: UseDocHandleOptions
60+
): Resource<DocHandle<T> | undefined>
61+
/**
62+
* get a fine-grained live view of a document, and its handle, from a URL.
63+
* @param url a function that returns a url
64+
*/
65+
export default function useDocument<T>(
66+
url: MaybeAccessor<AutomergeUrl | undefined>,
67+
options?: UseDocHandleOptions
68+
): [Accessor<Doc<T> | undefined>, Resource<DocHandle<T> | undefined>]
69+
/** grab the repo from the {@link RepoContext} */
70+
export default function useRepo(): Repo

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"main": "out/index.js",
77
"scripts": {
88
"prepublish": "pnpm mk",
9-
"mk": "rm -rf ./out ./docs; node --experimental-strip-types ./mk.ts && rm -f tsconfig.build.tsbuildinfo && pnpm tsc -p tsconfig.build.json && for file in out/*.d.ts; do cp $file ${file%%.d.ts}.ts.d.ts; done && typedoc --emit docs",
9+
"mk": "rm -rf ./out ./docs; node --experimental-strip-types ./mk.ts && typedoc --emit docs && cp _index.d.ts ./out/index.d.ts",
1010
"build": "pnpm mk",
1111
"test": "vitest run"
1212
},

0 commit comments

Comments
 (0)