Skip to content

Commit

Permalink
1.5.2 (#153)
Browse files Browse the repository at this point in the history
* feat: QweryProvider (#1)

* feat: useQwery hook (#2)

* feat: useQwery hook

* fix: proxy onChange for when a Promise is not returned, so onSuccess is not triggered

* chore: update readme (#3)

* feat: subscriptions and polling (#4)

* feat: useRememberScroll (#5)

* feat: refetchOnWindowFocus (#6)

* 0.0.1

* fix: awaiting initial value, either or can resolve to nullish (#8)

* types: useQweryOptions (#9)

* types: rough types for useQweryOptions

* fix: with makeMonitoredFetch, if a fetch is not enabled then it returns void so don't initialize the crdt in this case. update useRememberScroll to not execute server side

* chore: add vitest, react testing library, jsdom (#10)

* test: adding test api and redis (#11)

* test: add tests for useQwery, csr and ssr (#12)

* test: add tests for useQwery, csr and ssr

* chore: add gh actions

* 0.0.2

* chore: cleanup and update vite to build as lib (#14)

* chore: remove api.put (#15)

* chore: update deps, update exports, update types (#16)

* fix: effects don't run in ssr (#17)

* fix: effects don't run in ssr so return initialValue if it is an object, up to client to await and use suspense or what not. also update renderSsr to remove window while calling ReactDOMServer

* test: adding tests for async caches

* style: remove unused import

* types: update types

* refactor: update QweryProvider

* style: double quotes

* fix: silence act errors (#18)

* style: remove unused imports (#19)

* 0.0.3

* chore: update readme (#21)

* chore: update readme (#22)

* 1.0.0

* chore: update export locations (#24)

* 1.0.1

* chore: update README (#26)

* 1.0.2

* chore: update readme (#28)

* chore: update exports (#29)

* 1.0.3

* fix: unsubscribe (#31)

* fix: subscription return (#32)

* 1.0.4

* fix: fix build output issues making react and other deps external, update subscribe and onWindowFocus (#34)

* 1.0.5

* feat: to disable queries if offline (#36)

* 1.0.6

* feat: add broadcast channel support (#38)

* feat: add broadcast channel support

* fix: broadcast the diff

* 1.1.0

* feat: cancellable queries (#40)

* chore: update readme (#42)

* 1.2.0

* feat: suspense (#45)

* feat: suspense

* fix: suspense fetch before rendering

* 1.3.0

* fix: suspense throw errors (#53)

* 1.3.1

* fix: suspense onChange, throw errors after invoking onError (#55)

* chore: monorepo (#56)

* chore: monorepo

* chore: update github actions

* chore: lint in ci/cd

* Revert "chore: lint in ci/cd"

This reverts commit 567b07e.

* chore: lint in ci/cd

* chore: run lint, test and build concurrently (#57)

* feat: remove ability to manually handle broadcasts (#58)

* v1.3.2

* fix: trigger rerender after dispatching a broadcasted update (#60)

* fix: close broadcast channel (#61)

* fix: early return if broadcast next is same as current (#62)

* fix: early return if broadcast next is same as current. all listening channels receive a message even if on the same tab, and just reset to the next broadcasted state because otherwise we gotta determine if its an array and all

* style: remove unused import

* fix: only post next as a message

* docs: add comment

* fix: stablize id for each broadcaster, update some types, add pack script, fix issues with generated types (#63)

* v1.3.3

* refactor: rework types (#65)

* refactor: rework types

* refactor: splitting up types, accepting a refetch prop if refetchOnWindowFocus is true

* chore: update lint rules

* refactor: rearrange keys in base definitions to be in the same order

* refactor: reducing use of any (#66)

* refactor: reducing use of any

* refactor: alias InitialValue and Data

* chore: update package.json (#67)

* refactor: label next as Data

* chore: update package.json

* chore: point main to umd version

* refactor: update broadcast types

* refactor: fixing up untagged refetch base options

* refactor: any -> unknown for base options

* refactor: using any instead of unknown, less errors for no reason (#68)

* v1.4.0

* chore(vue): vue init (#70)

* feat(vue): useExecutionEnvironment (#71)

* feat: useExecutionEnvironment

* chore: update lockfile

* chore: update tsconfig

* feat(vue): use network mode (#72)

* chore(vue): use network mode

* fix: connectionStatus is computed

* fix(vue): run a fetch on mounted also when determining network status (#73)

* feat(vue): use remember scroll (#74)

* feat(vue): qwery context (#75)

* feat(vue): use qwery (#76)

* feat(vue): use qwery roughly

* refactor: tidy things up, use shallowReactive instead of ref

* refactor: remove todos and if suspense then first check the crdt state and if not check the result (initial render)

* chore(vue): update exports (#77)

* fix(vue): health check initially even for ssr (#78)

* fix(vue): check hasInjectionContext (#79)

* refactor(vue): add use id composable (#80)

* Revert "refactor(vue): add use id composable (#80)" (#82)

This reverts commit 4af9f64.

* chore(vue): add api and redis from react, add example test (#83)

* chore(vue): add api and redis from react, add example test

* chore(vue): update pnpm-lock

* chore(vue): revert change to tsconfig

* test(vue): csr (#84)

* test(vue): caches queries csr

* chore(vue): revert change to tsconfig

* test(vue): subscriptions, conditional queries, window focus

* test(vue): onChange

* test(vue): ssr (#85)

* refactor(vue): normal args instead of object (#86)

* test(vue): refactor, going with defineComponent (#87)

* refactor(react): initializeCrdt -> initializeCRDT, remove refetch (#88)

* refactor(vue): remove refetch (#89)

* chore(react,vue): update clean script (#90)

* chore: update readme (#91)

* v1.4.1

* types(react,vue): improve BaseQueryOptions (#94)

* fix(vue): make dispatch a getter instead of a computed ref, cleaner usage (#93)

* chore(react,vue): update readme (#95)

* v1.4.2

* chore(react,vue): use shared types (#97)

* chore(react,vue): bit of housekeeping, extracting out common types

* chore(react): using common types in react package

* fix(vue): void result of renderSsr

* chore(react): cleaning up imports

* chore(vue): migrate to shared types

* chore(vue,react): update vite config

* fix(vue,react): cache fetched initial value (#98)

* chore: update readme (#99)

* fix(vue,react): update cache on refetch (#100)

* chore: update deps (#101)

* v1.4.3

* chore(react,vue): update main entry point (#104)

* chore(svelte): svelte init (#103)

* chore: update gh actions (#105)

* chore: pnpm lerna run instead of pnpx (#106)

* types(vue,react): improve typing for UseQweryReturn (#107)

* types(vue): improve typing for UseQweryReturn

* types(react,vue): UseQueryReturnWithSuspense -> MaybePromise

* chore(vue): tsx -> ts (#108)

* chore(react,vue,svelte): make qwery-shared a dev dep (#109)

* chore(react,vue,svelte): make qwery-shared a dev dep, getting install not found errors

* chore(react,vue,svelte): relative link path

* v1.4.4

* feat(svelte): useExecutionEnvironment (#113)

* feat(svelte): context (#114)

* feat(svelte): useNetworkMode (#115)

* feat(svelte): useRememberScroll (#116)

* chore(svelte): update exports (#117)

* chore(svelte): update exports

* chore(svelte): update tsconfig

* feat(svelte): useQwery (#118)

* feat(svelte): useQwery

* fix(svelte): subscribe to store until dispatch has a value set

* chore(svelte): update exports

* fix(svelte): if suspense then we can just directly return dispatch from result if available because the reference will not change, same crdt always

* fix(vue): same for vue

* types(svelte,vue): add InferData utility type

* types(svelte,vue): remove ts expect error

* types(react): update types for broadcast

* chore(react,vue): update tsconfig (#119)

* types(react): type import UseNetworkModeOptions (#120)

* refactor(vue,svelte): computeInitialValueTest -> computeInitialValue (#121)

* refactor(react,vue,svelte): move no op cache to shared (#122)

* fix(svelte): for dispatch move subscribe out of getter (#123)

* fix(svelte): for dispatch move subscribe out of getter

* types(svelte,vue): InferData<I> instead of Data

* chore: update readme (#124)

* feat: add map reduce and maybe return a promise utility fn for change handlers (#125)

* chore: update readme (#126)

* refactor(shared): update mapReduceMaybePromise to be rest args instead (#127)

* feat(react,svelte,vue): useMonitoredFetch hook (#128)

* fix(react,vue,svelte): allow specifying other options (#129)

* types(react,vue,svelte): adding types (#130)

* chore(svelte): update build config (#131)

* chore: update readme (#132)

* chore(svelte): update package.json (#133)

* v1.5.0

* chore(react,vue,svelte): update readme with more accurate figures (#135)

* chore(react,vue,svelte): update readme with more accurate figures

* chore: update readme

* chore(solid): solid start (#136)

* chore(solid): solid start

* chore: add vitest and qwery-shared

* chore(react,vue,svelte,solid): update readme (#137)

* feat(solid): useMonitoredFetch (#138)

* feat(solid): useExecutionEnvironment (#139)

* feat(solid): useRememberScroll (#140)

* feat(solid): useNetworkMode (#141)

* fix(solid): useMonitoredFetch (#142)

* feat(solid): context (#143)

* chore(solid): update exports (#144)

* fix(solid): not destructuring props (#145)

* fix(solid): onCleanup (#146)

* fix(solid): onCleanup

* fix(solid): cleanup happens when scope reevaluates or is finally disposed

* feat(solid): useQwery (#147)

* feat(solid): useQwery

* chore(solid): update exports

* types(solid): update useQwery types (#148)

* chore(solid): update readme (#150)

* v1.5.1

* feat(vue,solid,svelte): proxy dispatch (#152)

* v1.5.2
  • Loading branch information
nmathew98 committed Mar 7, 2024
1 parent d3388c2 commit 5b1b41c
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 43 deletions.
10 changes: 4 additions & 6 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "1.5.1",
"packages": [
"packages/*"
],
"npmClient": "pnpm"
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "1.5.2",
"packages": ["packages/*"],
"npmClient": "pnpm"
}
2 changes: 1 addition & 1 deletion packages/solid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@b.s/solid-qwery",
"version": "1.5.1",
"version": "1.5.2",
"type": "module",
"repository": {
"type": "git",
Expand Down
24 changes: 18 additions & 6 deletions packages/solid/src/use-qwery/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
InferData,
} from "@b.s/qwery-shared";
import { createSignal, onCleanup, onMount, useContext } from "solid-js";
import type { UseQweryReturn } from "./types";
import type { UseQweryReturnSolid } from "./types";

export const useQwery = <
I extends InitialValue,
Expand All @@ -25,7 +25,7 @@ export const useQwery = <
refetchOnWindowFocus = false,
broadcast = false,
suspense = false,
}: UseQweryOptions<I, S>): MaybePromise<S, UseQweryReturn<I>> => {
}: UseQweryOptions<I, S>): MaybePromise<S, UseQweryReturnSolid<I>> => {
const context = useContext(QweryContext);

const id = Math.random().toString(36).substring(2);
Expand Down Expand Up @@ -265,20 +265,32 @@ export const useQwery = <
}
};

const dispatch = new Proxy(noOpFunction, {
apply: (
noOpFunction,
_thisArg,
args: Parameters<Dispatch<InferData<I>>>,
) => {
if (!crdt().dispatch) {
return noOpFunction();
}

return crdt().dispatch?.(...args);
},
}) as Dispatch<InferData<I>>;

if (suspense) {
return initializedCRDT.then(result => ({
data: () =>
crdt().data ?? result?.crdt.data ?? computeInitialValue(),
dispatch: result?.crdt.dispatch ?? noOpFunction,
dispatch,
versions: () => crdt().versions ?? result?.crdt.versions,
})) as any;
}

return {
data: () => crdt().data ?? computeInitialValue(),
get dispatch() {
return crdt().dispatch ?? noOpFunction;
},
dispatch,
versions: () => crdt().versions,
} as any;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/solid/src/use-qwery/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
} from "@b.s/qwery-shared";
import type { Accessor } from "solid-js";

export type UseQweryReturn<I extends InitialValue> = Computed<
export type UseQweryReturnSolid<I extends InitialValue> = Computed<
Maybe<Required<Omit<SharedUseQweryReturn<I>, "dispatch">>>
> &
Pick<SharedUseQweryReturn<I>, "dispatch">;
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@b.s/svelte-qwery",
"version": "1.5.1",
"version": "1.5.2",
"type": "module",
"repository": {
"type": "git",
Expand Down
40 changes: 21 additions & 19 deletions packages/svelte/src/use-qwery/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { derived, writable } from "svelte/store";
import { derived, get, writable } from "svelte/store";
import { onDestroy, onMount } from "svelte";
import { createCRDT, type CRDT, type Dispatch } from "@b.s/incremental";
import { useQweryContext } from "../context";
Expand All @@ -9,7 +9,7 @@ import type {
MaybePromise,
InferData,
} from "@b.s/qwery-shared";
import type { UseQweryReturn } from "./types";
import type { UseQweryReturnSvelte } from "./types";

export const useQwery = <
I extends InitialValue,
Expand All @@ -26,7 +26,7 @@ export const useQwery = <
refetchOnWindowFocus = false,
broadcast = false,
suspense = false,
}: UseQweryOptions<I, S>): MaybePromise<S, UseQweryReturn<I>> => {
}: UseQweryOptions<I, S>): MaybePromise<S, UseQweryReturnSvelte<I>> => {
const context = useQweryContext();

const id = Math.random().toString(36).substring(2);
Expand Down Expand Up @@ -266,38 +266,40 @@ export const useQwery = <
}
};

const dispatch = new Proxy(noOpFunction, {
apply: (
noOpFunction,
_thisArg,
args: Parameters<Dispatch<InferData<I>>>,
) => {
const value = get(crdt);

if (!value.dispatch) {
return noOpFunction();
}

return value.dispatch?.(...args);
},
}) as Dispatch<InferData<I>>;

if (suspense) {
return initializedCRDT.then(result => ({
data: derived(
crdt,
$crdt =>
$crdt.data ?? result?.crdt.data ?? computeInitialValue(),
),
dispatch: result?.crdt.dispatch ?? noOpFunction,
dispatch,
versions: derived(
crdt,
$crdt => $crdt.versions ?? result?.crdt.versions,
),
})) as any;
}

let dispatch: Dispatch<InferData<I>> | null = null;
const unsubscribe = crdt.subscribe($crdt => {
if ($crdt.dispatch) {
dispatch = $crdt.dispatch;
}
});

return {
data: derived(crdt, $crdt => $crdt.data ?? computeInitialValue()),
get dispatch() {
if (!dispatch) {
return noOpFunction;
}

unsubscribe();
return dispatch;
},
dispatch,
versions: derived(crdt, $crdt => $crdt.versions),
} as any;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/src/use-qwery/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
} from "@b.s/qwery-shared";
import type { Readable } from "svelte/store";

export type UseQweryReturn<I extends InitialValue> = Derived<
export type UseQweryReturnSvelte<I extends InitialValue> = Derived<
Maybe<Required<Omit<SharedUseQweryReturn<I>, "dispatch">>>
> &
Pick<SharedUseQweryReturn<I>, "dispatch">;
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@b.s/vue-qwery",
"version": "1.5.1",
"version": "1.5.2",
"type": "module",
"repository": {
"type": "git",
Expand Down
24 changes: 18 additions & 6 deletions packages/vue/src/use-qwery/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
MaybePromise,
InferData,
} from "@b.s/qwery-shared";
import type { UseQweryReturn } from "./types";
import type { UseQweryReturnVue } from "./types";

export const useQwery = <
I extends InitialValue,
Expand All @@ -25,7 +25,7 @@ export const useQwery = <
refetchOnWindowFocus = false,
broadcast = false,
suspense = false,
}: UseQweryOptions<I, S>): MaybePromise<S, UseQweryReturn<I>> => {
}: UseQweryOptions<I, S>): MaybePromise<S, UseQweryReturnVue<I>> => {
const context = useQweryContext();

const id = Math.random().toString(36).substring(2);
Expand Down Expand Up @@ -263,21 +263,33 @@ export const useQwery = <
}
};

const dispatch = new Proxy(noOpFunction, {
apply: (
noOpFunction,
_thisArg,
args: Parameters<Dispatch<InferData<I>>>,
) => {
if (!crdt.dispatch) {
return noOpFunction();
}

return crdt.dispatch?.(...args);
},
}) as Dispatch<InferData<I>>;

if (suspense) {
return initializedCRDT.then(result => ({
data: computed(
() => crdt.data ?? result?.crdt.data ?? computeInitialValue(),
),
dispatch: result?.crdt.dispatch ?? noOpFunction,
dispatch,
versions: computed(() => crdt.versions ?? result?.crdt.versions),
})) as any;
}

return {
data: computed(() => crdt.data ?? computeInitialValue()),
get dispatch() {
return crdt.dispatch ?? noOpFunction;
},
dispatch,
versions: computed(() => crdt.versions),
} as any;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/src/use-qwery/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
} from "@b.s/qwery-shared";
import type { ComputedRef } from "vue";

export type UseQweryReturn<I extends InitialValue> = Computed<
export type UseQweryReturnVue<I extends InitialValue> = Computed<
Maybe<Required<Omit<SharedUseQweryReturn<I>, "dispatch">>>
> &
Pick<SharedUseQweryReturn<I>, "dispatch">;
Expand Down

0 comments on commit 5b1b41c

Please sign in to comment.