@instantdb/vue 0.0.0
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/README.md +62 -0
- package/dist/InstantVueDatabase.d.ts +189 -0
- package/dist/InstantVueDatabase.d.ts.map +1 -0
- package/dist/InstantVueDatabase.js +265 -0
- package/dist/InstantVueDatabase.js.map +1 -0
- package/dist/InstantVueRoom.d.ts +84 -0
- package/dist/InstantVueRoom.d.ts.map +1 -0
- package/dist/InstantVueRoom.js +180 -0
- package/dist/InstantVueRoom.js.map +1 -0
- package/dist/chunks/Cursor.vue_vue_type_script_setup_true_lang-DeM0moKd.js +32 -0
- package/dist/chunks/Cursor.vue_vue_type_script_setup_true_lang-DeM0moKd.js.map +1 -0
- package/dist/chunks/Cursors.vue_vue_type_script_setup_true_lang-C6eE1KRI.js +128 -0
- package/dist/chunks/Cursors.vue_vue_type_script_setup_true_lang-C6eE1KRI.js.map +1 -0
- package/dist/chunks/SignedIn.vue_vue_type_script_setup_true_lang-MJrQPE2B.js +18 -0
- package/dist/chunks/SignedIn.vue_vue_type_script_setup_true_lang-MJrQPE2B.js.map +1 -0
- package/dist/chunks/SignedOut.vue_vue_type_script_setup_true_lang-CcoDHmXu.js +18 -0
- package/dist/chunks/SignedOut.vue_vue_type_script_setup_true_lang-CcoDHmXu.js.map +1 -0
- package/dist/components/Cursor.js +5 -0
- package/dist/components/Cursor.js.map +1 -0
- package/dist/components/Cursor.vue.d.ts +6 -0
- package/dist/components/Cursor.vue.d.ts.map +1 -0
- package/dist/components/Cursors.js +5 -0
- package/dist/components/Cursors.js.map +1 -0
- package/dist/components/Cursors.vue.d.ts +32 -0
- package/dist/components/Cursors.vue.d.ts.map +1 -0
- package/dist/components/SignedIn.js +5 -0
- package/dist/components/SignedIn.js.map +1 -0
- package/dist/components/SignedIn.vue.d.ts +18 -0
- package/dist/components/SignedIn.vue.d.ts.map +1 -0
- package/dist/components/SignedOut.js +5 -0
- package/dist/components/SignedOut.js.map +1 -0
- package/dist/components/SignedOut.vue.d.ts +18 -0
- package/dist/components/SignedOut.vue.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/useInfiniteQuery.d.ts +25 -0
- package/dist/useInfiniteQuery.d.ts.map +1 -0
- package/dist/useInfiniteQuery.js +57 -0
- package/dist/useInfiniteQuery.js.map +1 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +12 -0
- package/dist/utils.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { InstaQLResponse, ValidQuery, InstantCoreDatabase, InstantSchemaDef, InstaQLOptions } from '@instantdb/core';
|
|
2
|
+
import type { ShallowRef, Ref, MaybeRefOrGetter } from 'vue';
|
|
3
|
+
export type InfiniteQueryResult<Schema extends InstantSchemaDef<any, any, any>, Q extends ValidQuery<Q, Schema>, UseDates extends boolean> = {
|
|
4
|
+
isLoading: Ref<boolean>;
|
|
5
|
+
data: ShallowRef<InstaQLResponse<Schema, Q, UseDates> | undefined>;
|
|
6
|
+
error: ShallowRef<{
|
|
7
|
+
message: string;
|
|
8
|
+
} | undefined>;
|
|
9
|
+
canLoadNextPage: Ref<boolean>;
|
|
10
|
+
loadNextPage: () => void;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Subscribe to a query and incrementally load more items.
|
|
14
|
+
*
|
|
15
|
+
* Only one top-level namespace in the query is allowed. Changing the query or
|
|
16
|
+
* options while the subscription is active resets and starts over.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const { data, isLoading, error, loadNextPage, canLoadNextPage } =
|
|
20
|
+
* db.useInfiniteQuery({
|
|
21
|
+
* posts: { $: { limit: 20, order: { createdAt: 'desc' } } },
|
|
22
|
+
* });
|
|
23
|
+
*/
|
|
24
|
+
export declare function useInfiniteQuery<Schema extends InstantSchemaDef<any, any, any>, Q extends ValidQuery<Q, Schema>, UseDates extends boolean>(core: InstantCoreDatabase<Schema, UseDates>, query: MaybeRefOrGetter<Q | null>, opts?: MaybeRefOrGetter<InstaQLOptions | undefined>): InfiniteQueryResult<Schema, Q, UseDates>;
|
|
25
|
+
//# sourceMappingURL=useInfiniteQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInfiniteQuery.d.ts","sourceRoot":"","sources":["../src/useInfiniteQuery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EAEV,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAI7D,MAAM,MAAM,mBAAmB,CAC7B,MAAM,SAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC9C,CAAC,SAAS,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,EAC/B,QAAQ,SAAS,OAAO,IACtB;IACF,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACxB,IAAI,EAAE,UAAU,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC,CAAC;IACnE,KAAK,EAAE,UAAU,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IACnD,eAAe,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9B,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,SAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC9C,CAAC,SAAS,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,EAC/B,QAAQ,SAAS,OAAO,EAExB,IAAI,EAAE,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,EAC3C,KAAK,EAAE,gBAAgB,CAAC,CAAC,GAAG,IAAI,CAAC,EACjC,IAAI,CAAC,EAAE,gBAAgB,CAAC,cAAc,GAAG,SAAS,CAAC,GAClD,mBAAmB,CAAC,MAAM,EAAE,CAAC,EAAE,QAAQ,CAAC,CA6D1C"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { getInfiniteQueryInitialSnapshot, weakHash } from "@instantdb/core";
|
|
2
|
+
import { toValue, ref, shallowRef, watch } from "vue";
|
|
3
|
+
import { tryOnScopeDispose } from "./utils.js";
|
|
4
|
+
function useInfiniteQuery(core, query, opts) {
|
|
5
|
+
const initialQuery = toValue(query);
|
|
6
|
+
const snapshot = initialQuery ? getInfiniteQueryInitialSnapshot(core, initialQuery, toValue(opts)) : { data: void 0, error: void 0, canLoadNextPage: false };
|
|
7
|
+
const isLoading = ref(!snapshot.data && !snapshot.error);
|
|
8
|
+
const data = shallowRef(
|
|
9
|
+
snapshot.data
|
|
10
|
+
);
|
|
11
|
+
const error = shallowRef(snapshot.error);
|
|
12
|
+
const canLoadNextPage = ref(snapshot.canLoadNextPage);
|
|
13
|
+
let subRef = null;
|
|
14
|
+
const stop = watch(
|
|
15
|
+
[() => weakHash(toValue(query)), () => weakHash(toValue(opts))],
|
|
16
|
+
(_, __, onCleanup) => {
|
|
17
|
+
subRef = null;
|
|
18
|
+
error.value = void 0;
|
|
19
|
+
data.value = void 0;
|
|
20
|
+
isLoading.value = true;
|
|
21
|
+
canLoadNextPage.value = false;
|
|
22
|
+
const q = toValue(query);
|
|
23
|
+
if (!q) return;
|
|
24
|
+
const sub = core.subscribeInfiniteQuery(
|
|
25
|
+
q,
|
|
26
|
+
(resp) => {
|
|
27
|
+
error.value = resp.error;
|
|
28
|
+
data.value = resp.data;
|
|
29
|
+
isLoading.value = false;
|
|
30
|
+
canLoadNextPage.value = resp.canLoadNextPage;
|
|
31
|
+
},
|
|
32
|
+
toValue(opts)
|
|
33
|
+
);
|
|
34
|
+
subRef = sub;
|
|
35
|
+
onCleanup(() => {
|
|
36
|
+
sub.unsubscribe();
|
|
37
|
+
if (subRef === sub) subRef = null;
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
{ immediate: true }
|
|
41
|
+
);
|
|
42
|
+
const loadNextPage = () => {
|
|
43
|
+
subRef == null ? void 0 : subRef.loadNextPage();
|
|
44
|
+
};
|
|
45
|
+
tryOnScopeDispose(stop);
|
|
46
|
+
return {
|
|
47
|
+
isLoading,
|
|
48
|
+
data,
|
|
49
|
+
error,
|
|
50
|
+
canLoadNextPage,
|
|
51
|
+
loadNextPage
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
useInfiniteQuery
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=useInfiniteQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInfiniteQuery.js","sources":["../src/useInfiniteQuery.ts"],"sourcesContent":["import { weakHash, getInfiniteQueryInitialSnapshot } from '@instantdb/core';\nimport type {\n InstaQLResponse,\n ValidQuery,\n InfiniteQuerySubscription,\n InstantCoreDatabase,\n InstantSchemaDef,\n InstaQLOptions,\n} from '@instantdb/core';\nimport { shallowRef, ref, watch, toValue } from 'vue';\nimport type { ShallowRef, Ref, MaybeRefOrGetter } from 'vue';\n\nimport { tryOnScopeDispose } from './utils.js';\n\nexport type InfiniteQueryResult<\n Schema extends InstantSchemaDef<any, any, any>,\n Q extends ValidQuery<Q, Schema>,\n UseDates extends boolean,\n> = {\n isLoading: Ref<boolean>;\n data: ShallowRef<InstaQLResponse<Schema, Q, UseDates> | undefined>;\n error: ShallowRef<{ message: string } | undefined>;\n canLoadNextPage: Ref<boolean>;\n loadNextPage: () => void;\n};\n\n/**\n * Subscribe to a query and incrementally load more items.\n *\n * Only one top-level namespace in the query is allowed. Changing the query or\n * options while the subscription is active resets and starts over.\n *\n * @example\n * const { data, isLoading, error, loadNextPage, canLoadNextPage } =\n * db.useInfiniteQuery({\n * posts: { $: { limit: 20, order: { createdAt: 'desc' } } },\n * });\n */\nexport function useInfiniteQuery<\n Schema extends InstantSchemaDef<any, any, any>,\n Q extends ValidQuery<Q, Schema>,\n UseDates extends boolean,\n>(\n core: InstantCoreDatabase<Schema, UseDates>,\n query: MaybeRefOrGetter<Q | null>,\n opts?: MaybeRefOrGetter<InstaQLOptions | undefined>,\n): InfiniteQueryResult<Schema, Q, UseDates> {\n const initialQuery = toValue(query);\n const snapshot = initialQuery\n ? getInfiniteQueryInitialSnapshot(core, initialQuery, toValue(opts))\n : { data: undefined, error: undefined, canLoadNextPage: false };\n\n const isLoading = ref(!snapshot.data && !snapshot.error);\n const data = shallowRef<InstaQLResponse<Schema, Q, UseDates> | undefined>(\n snapshot.data as any,\n );\n const error = shallowRef<{ message: string } | undefined>(snapshot.error);\n const canLoadNextPage = ref(snapshot.canLoadNextPage);\n\n let subRef: InfiniteQuerySubscription | null = null;\n\n const stop = watch(\n [() => weakHash(toValue(query)), () => weakHash(toValue(opts))],\n (_, __, onCleanup) => {\n subRef = null;\n error.value = undefined;\n data.value = undefined;\n isLoading.value = true;\n canLoadNextPage.value = false;\n\n const q = toValue(query);\n if (!q) return;\n\n const sub = core.subscribeInfiniteQuery(\n q,\n (resp: any) => {\n error.value = resp.error;\n data.value = resp.data;\n isLoading.value = false;\n canLoadNextPage.value = resp.canLoadNextPage;\n },\n toValue(opts),\n );\n\n subRef = sub;\n\n onCleanup(() => {\n sub.unsubscribe();\n if (subRef === sub) subRef = null;\n });\n },\n { immediate: true },\n );\n\n const loadNextPage = () => {\n subRef?.loadNextPage();\n };\n\n tryOnScopeDispose(stop);\n\n return {\n isLoading,\n data,\n error,\n canLoadNextPage,\n loadNextPage,\n }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F;"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run `fn` when the current effect scope is disposed. Returns true if a scope
|
|
3
|
+
* was active (and the callback was registered), false otherwise. Lets hooks
|
|
4
|
+
* work both inside component setup and inside a manual `effectScope()` without
|
|
5
|
+
* blowing up when called outside any scope.
|
|
6
|
+
*/
|
|
7
|
+
export declare function tryOnScopeDispose(fn: () => void): boolean;
|
|
8
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,OAAO,CAMzD"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import { onScopeDispose, getCurrentScope } from 'vue';\n\n/**\n * Run `fn` when the current effect scope is disposed. Returns true if a scope\n * was active (and the callback was registered), false otherwise. Lets hooks\n * work both inside component setup and inside a manual `effectScope()` without\n * blowing up when called outside any scope.\n */\nexport function tryOnScopeDispose(fn: () => void): boolean {\n if (getCurrentScope()) {\n onScopeDispose(fn);\n return true;\n }\n return false;\n}\n"],"names":[],"mappings":";AAQO,SAAS,kBAAkB,IAAyB;AACzD,MAAI,mBAAmB;AACrB,mBAAe,EAAE;AACV,WAAA;AAAA,EAAA;AAEF,SAAA;AACT;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,eAAe,OAAO,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@instantdb/vue",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"description": "Vue client for InstantDB",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"homepage": "https://github.com/instantdb/instant/tree/main/client/packages/vue",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/instantdb/instant.git",
|
|
11
|
+
"directory": "client/packages/vue"
|
|
12
|
+
},
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
"./package.json": "./package.json",
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"!dist/**/*.test.*",
|
|
27
|
+
"!dist/**/*.spec.*"
|
|
28
|
+
],
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"vue": "^3.4.0"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@instantdb/core": "0.0.0",
|
|
34
|
+
"@instantdb/version": "0.0.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@vitejs/plugin-vue": "^5.2.0",
|
|
38
|
+
"@vue/test-utils": "^2.4.0",
|
|
39
|
+
"jsdom": "^25.0.0",
|
|
40
|
+
"typescript": "^5.0.0",
|
|
41
|
+
"vite": "^5.2.0",
|
|
42
|
+
"vitest": "^2.0.0",
|
|
43
|
+
"vue": "^3.5.0",
|
|
44
|
+
"vue-tsc": "^2.2.0"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"test:watch": "vitest",
|
|
49
|
+
"check": "vue-tsc --noEmit",
|
|
50
|
+
"build:types": "vue-tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
51
|
+
"build:js": "vite build",
|
|
52
|
+
"build": "rm -rf dist && pnpm build:types && pnpm build:js",
|
|
53
|
+
"dev": "vite build --watch",
|
|
54
|
+
"publish-package": "pnpm pack && npm publish *.tgz --access public"
|
|
55
|
+
}
|
|
56
|
+
}
|