@nearstack-dev/svelte 0.0.1

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.
@@ -0,0 +1,5 @@
1
+ import { type Writable } from 'svelte/store';
2
+ import type { Model } from '@nearstack-dev/core';
3
+ export declare function modelStore<T = any>(model: Model<T>, id: string): Writable<T | undefined>;
4
+ export declare function liveQuery<T = any>(query: () => Promise<T>): Writable<T | undefined>;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD,wBAAgB,UAAU,CAAC,CAAC,GAAG,GAAG,EAChC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EACf,EAAE,EAAE,MAAM,GACT,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAC,CAiBzB;AAED,wBAAgB,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAC,CASnF"}
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ // Svelte store adapter (simple bridge)
2
+ import { writable } from 'svelte/store';
3
+ export function modelStore(model, id) {
4
+ const store = writable(undefined);
5
+ // Initialize the store with data from the model
6
+ model.store.get(id).then((value) => {
7
+ store.set(value);
8
+ });
9
+ return {
10
+ ...store,
11
+ set: (value) => {
12
+ store.set(value);
13
+ if (value !== undefined) {
14
+ model.store.set(id, value);
15
+ }
16
+ },
17
+ };
18
+ }
19
+ export function liveQuery(query) {
20
+ const store = writable(undefined);
21
+ // Execute the query and update the store
22
+ query().then((value) => {
23
+ store.set(value);
24
+ });
25
+ return store;
26
+ }
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AAEvC,OAAO,EAAE,QAAQ,EAAiB,MAAM,cAAc,CAAC;AAGvD,MAAM,UAAU,UAAU,CACxB,KAAe,EACf,EAAU;IAEV,MAAM,KAAK,GAAG,QAAQ,CAAgB,SAAS,CAAC,CAAC;IAEjD,gDAAgD;IAChD,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;QACjC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,KAAK;QACR,GAAG,EAAE,CAAC,KAAoB,EAAE,EAAE;YAC5B,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACjB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,SAAS,CAAU,KAAuB;IACxD,MAAM,KAAK,GAAG,QAAQ,CAAgB,SAAS,CAAC,CAAC;IAEjD,yCAAyC;IACzC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;QACrB,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC"}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@nearstack-dev/svelte",
3
+ "version": "0.0.1",
4
+ "description": "Svelte store adapter (simple bridge)",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "author": "Dakota Kim",
15
+ "license": "MIT",
16
+ "peerDependencies": {
17
+ "svelte": "^4.0.0"
18
+ },
19
+ "dependencies": {
20
+ "@nearstack-dev/core": "0.0.1"
21
+ },
22
+ "devDependencies": {
23
+ "svelte": "^4.2.10",
24
+ "typescript": "^5.3.3"
25
+ },
26
+ "scripts": {
27
+ "build": "tsc",
28
+ "dev": "tsc --watch",
29
+ "test": "echo \"Error: no test specified\" && exit 1"
30
+ }
31
+ }