Skip to content

Commit

Permalink
Fixed optional paths in documents
Browse files Browse the repository at this point in the history
  • Loading branch information
acurrieclark committed Apr 4, 2023
1 parent 5d5f7a4 commit e350173
Show file tree
Hide file tree
Showing 12 changed files with 1,215 additions and 4,178 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
if: steps.tests.outcome == 'success'
uses: softprops/action-gh-release@v1
with:
name: Automerge Svelte Store v${{ needs.check_if_version_upgraded.outputs.version }}
name: v${{ needs.check_if_version_upgraded.outputs.version }}
tag_name: v${{ needs.check_if_version_upgraded.outputs.version }}
target_commitish: main
generate_release_notes: true
Expand Down
5,246 changes: 1,189 additions & 4,057 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@onsetsoftware/automerge-svelte",
"description": "A svelte store and utilities for automerge",
"version": "0.0.1",
"version": "0.1.0",
"type": "module",
"scripts": {
"build": "tsc && vite build",
Expand All @@ -28,8 +28,7 @@
"@onsetsoftware/automerge-patcher": "^0.6.0",
"@onsetsoftware/mutable-js": "^0.1.4",
"diff": "^5.1.0",
"dot-path-value": "^0.0.6",
"dot-prop": "^7.2.0"
"dot-path-value": "^0.0.9"
},
"files": [
"dist"
Expand Down
9 changes: 4 additions & 5 deletions src/actions/bind-checked.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { AutomergeSvelteStore } from "../automerge-svelte-store.type";
import type { Path, PathValue } from "dot-path-value";
import { getByPath } from "dot-path-value";
import { setByPath } from "../set-by-path";
import { getByPath, setByPath } from "dot-path-value";
import type { Extend } from "@automerge/automerge";

export function bindChecked<T extends Record<string, any>>(
Expand All @@ -10,7 +9,7 @@ export function bindChecked<T extends Record<string, any>>(
store,
path,
title,
}: { store: AutomergeSvelteStore<T>; path: Path<T>; title?: string }
}: { store: AutomergeSvelteStore<T>; path: Path<T>; title?: string },
) {
const subscription = store.subscribe((doc) => {
node.checked = getByPath(doc, path) as boolean;
Expand All @@ -22,10 +21,10 @@ export function bindChecked<T extends Record<string, any>>(
setByPath(
doc,
path as Path<Extend<T>>,
node.checked as PathValue<Extend<T>, Path<Extend<T>>>
node.checked as PathValue<Extend<T>, Path<Extend<T>>>,
);
},
title ? { message: `Update ${title}` } : {}
title ? { message: `Update ${title}` } : {},
);
};

Expand Down
9 changes: 4 additions & 5 deletions src/actions/bind-string-deferred.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { AutomergeSvelteStore } from "../automerge-svelte-store.type";
import type { Path, PathValue } from "dot-path-value";
import { getByPath } from "dot-path-value";
import { setByPath } from "../set-by-path";
import { getByPath, setByPath } from "dot-path-value";
import { getStringPatches } from "../diff-to-patches";
import { patch } from "@onsetsoftware/automerge-patcher";
import { quickClone } from "../helpers/quick-clone";
Expand All @@ -12,10 +11,10 @@ export function bindStringDeferred<T extends Record<string, any>>(
store,
path,
title,
}: { store: AutomergeSvelteStore<T>; path: Path<T>; title?: string }
}: { store: AutomergeSvelteStore<T>; path: Path<T>; title?: string },
) {
const subscription = store.subscribe((doc) => {
node.value = getByPath(doc, path)?.toString();
node.value = getByPath(doc, path)?.toString() || "";
});

let lastValue: string = node.value;
Expand All @@ -40,7 +39,7 @@ export function bindStringDeferred<T extends Record<string, any>>(
patch(doc, p);
});
},
title ? { message: `Update ${title}` } : {}
title ? { message: `Update ${title}` } : {},
);
};

Expand Down
6 changes: 3 additions & 3 deletions src/actions/bind-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export function bindString<T extends Record<string, any>>(
store,
path,
title,
}: { store: AutomergeSvelteStore<T>; path: Path<T>; title?: string }
}: { store: AutomergeSvelteStore<T>; path: Path<T>; title?: string },
) {
let lastValue: string;

const subscription = store.subscribe((doc) => {
node.value = lastValue = getByPath(doc, path).toString();
node.value = lastValue = getByPath(doc, path)?.toString() || "";
});

const inputListener = () => {
Expand All @@ -29,7 +29,7 @@ export function bindString<T extends Record<string, any>>(
patch(doc, p);
});
},
title ? { message: `Update ${title}` } : {}
title ? { message: `Update ${title}` } : {},
);
};

Expand Down
9 changes: 4 additions & 5 deletions src/actions/bind-text-deferred.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { AutomergeSvelteStore } from "../automerge-svelte-store.type";
import type { Path, PathValue } from "dot-path-value";
import { getByPath } from "dot-path-value";
import { setByPath } from "../set-by-path";
import { getByPath, setByPath } from "dot-path-value";
import { getTextPatches } from "../diff-to-patches";
import { patch } from "@onsetsoftware/automerge-patcher";
import { quickClone } from "../helpers/quick-clone";
Expand All @@ -12,10 +11,10 @@ export function bindTextDeferred<T extends Record<string, any>>(
store,
path,
title,
}: { store: AutomergeSvelteStore<T>; path: Path<T>; title?: string }
}: { store: AutomergeSvelteStore<T>; path: Path<T>; title?: string },
) {
const subscription = store.subscribe((doc) => {
node.value = getByPath(doc, path).toString();
node.value = getByPath(doc, path)?.toString();
});

let lastValue: string = node.value;
Expand All @@ -40,7 +39,7 @@ export function bindTextDeferred<T extends Record<string, any>>(
patch(doc, p);
});
},
title ? { message: `Update ${title}` } : {}
title ? { message: `Update ${title}` } : {},
);
};

Expand Down
9 changes: 4 additions & 5 deletions src/actions/bind-value-deferred.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { AutomergeSvelteStore } from "../automerge-svelte-store.type";
import type { Path, PathValue } from "dot-path-value";
import { getByPath } from "dot-path-value";
import { setByPath } from "../set-by-path";
import { getByPath, setByPath } from "dot-path-value";
import type { Extend } from "@automerge/automerge";
import { quickClone } from "../helpers/quick-clone";

Expand All @@ -11,7 +10,7 @@ export function bindValueDeferred<T extends Record<string, any>>(
store,
path,
title,
}: { store: AutomergeSvelteStore<T>; path: Path<T>; title?: string }
}: { store: AutomergeSvelteStore<T>; path: Path<T>; title?: string },
) {
const subscription = store.subscribe((doc) => {
node.value = (getByPath(doc, path) as string) || "";
Expand All @@ -32,10 +31,10 @@ export function bindValueDeferred<T extends Record<string, any>>(
setByPath(
doc,
path as Path<Extend<T>>,
node.value as PathValue<Extend<T>, Path<Extend<T>>>
node.value as PathValue<Extend<T>, Path<Extend<T>>>,
);
},
title ? { message: `Update ${title}` } : {}
title ? { message: `Update ${title}` } : {},
);
};

Expand Down
9 changes: 4 additions & 5 deletions src/actions/bind-value.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { AutomergeSvelteStore } from "../automerge-svelte-store.type";
import type { Path, PathValue } from "dot-path-value";
import { getByPath } from "dot-path-value";
import { setByPath } from "../set-by-path";
import { getByPath, setByPath } from "dot-path-value";
import type { Extend } from "@automerge/automerge";

export function bindValue<T extends Record<string, any>>(
Expand All @@ -10,7 +9,7 @@ export function bindValue<T extends Record<string, any>>(
store,
path,
title,
}: { store: AutomergeSvelteStore<T>; path: Path<T>; title?: string }
}: { store: AutomergeSvelteStore<T>; path: Path<T>; title?: string },
) {
const subscription = store.subscribe((doc) => {
node.value = (getByPath(doc, path) as string) || "";
Expand All @@ -22,10 +21,10 @@ export function bindValue<T extends Record<string, any>>(
setByPath(
doc,
path as Path<Extend<T>>,
node.value as PathValue<Extend<T>, Path<Extend<T>>>
node.value as PathValue<Extend<T>, Path<Extend<T>>>,
);
},
title ? { message: `Update ${title}` } : {}
title ? { message: `Update ${title}` } : {},
);
};

Expand Down
17 changes: 0 additions & 17 deletions src/set-by-path.ts

This file was deleted.

21 changes: 0 additions & 21 deletions tests/set-by-path.test.ts

This file was deleted.

51 changes: 0 additions & 51 deletions vite.config.ts.timestamp-1673962630620.mjs

This file was deleted.

0 comments on commit e350173

Please sign in to comment.