@plures/unum 0.2.3 → 0.3.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/dist/adapters/index.d.ts +3 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/memory.d.ts +7 -0
- package/dist/adapters/memory.d.ts.map +1 -0
- package/dist/adapters/memory.js +116 -0
- package/dist/adapters/memory.js.map +1 -0
- package/dist/adapters/pluresdb.d.ts +14 -0
- package/dist/adapters/pluresdb.d.ts.map +1 -0
- package/dist/adapters/pluresdb.js +48 -0
- package/dist/adapters/pluresdb.js.map +1 -0
- package/dist/context.d.ts +29 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +43 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +8 -53
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -196
- package/dist/index.js.map +1 -1
- package/dist/runes.d.ts +17 -161
- package/dist/runes.d.ts.map +1 -1
- package/dist/runes.js +121 -290
- package/dist/runes.js.map +1 -1
- package/dist/store.d.ts +10 -21
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +31 -135
- package/dist/store.js.map +1 -1
- package/dist/types.d.ts +69 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +54 -49
- package/dist/GunContext.d.ts +0 -17
- package/dist/GunContext.d.ts.map +0 -1
- package/dist/GunContext.js +0 -180
- package/dist/GunContext.js.map +0 -1
- package/dist/actions.d.ts +0 -39
- package/dist/actions.d.ts.map +0 -1
- package/dist/actions.js +0 -89
- package/dist/actions.js.map +0 -1
- package/dist/gunComponent.d.ts +0 -44
- package/dist/gunComponent.d.ts.map +0 -1
- package/dist/gunComponent.js +0 -205
- package/dist/gunComponent.js.map +0 -1
- package/dist/gunify.d.ts +0 -46
- package/dist/gunify.d.ts.map +0 -1
- package/dist/gunify.js +0 -294
- package/dist/gunify.js.map +0 -1
- package/dist/plures-helper.d.ts +0 -41
- package/dist/plures-helper.d.ts.map +0 -1
- package/dist/plures-helper.js +0 -114
- package/dist/plures-helper.js.map +0 -1
- package/dist/universalGunBind.d.ts +0 -219
- package/dist/universalGunBind.d.ts.map +0 -1
- package/dist/universalGunBind.js +0 -394
- package/dist/universalGunBind.js.map +0 -1
package/dist/runes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runes.js","sourceRoot":"","sources":["../src/runes.
|
|
1
|
+
{"version":3,"file":"runes.js","sourceRoot":"","sources":["../src/runes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,UAAU,CACxB,IAAY,EACZ,EAAkB;IAElB,IAAI,KAAK,GAAwB,EAAE,CAAC;IACpC,IAAI,IAAI,GAA4B,EAAE,CAAC;IACvC,MAAM,MAAM,GAAkB,EAAE,CAAC;IAEjC,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAE3B,SAAS,MAAM;QACb,KAAK,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;YACtB,IAAI,CAAC;gBAAC,EAAE,CAAC,KAAK,CAAC,CAAC;YAAC,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBAAC,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;YAAC,CAAC;QACpE,CAAC;IACH,CAAC;IAED,IAAI,EAAE,EAAE,CAAC;QACP,sBAAsB;QACtB,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,IAAS,EAAE,EAAE;YACrC,IAAI,IAAI,EAAE,CAAC;gBACT,KAAK,GAA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,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IACH,OAAO;QACL,IAAI,KAAK,KAAK,OAAO,OAAO,CAAC,CAAC,CAAC;QAC/B,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC;KACvB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,MAAe,EAAE,KAAa;IACvD,IAAI,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QACvC,MAAM,GAAG,KAAK,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;IACH,OAAO;QACL,IAAI,KAAK,KAAK,OAAO,MAAM,CAAC,CAAC,CAAC;QAC9B,IAAI,KAAK,CAAC,CAAM;YACd,MAAM,GAAG,CAAC,CAAC;YACX,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC;KACvB,CAAC;AACJ,CAAC"}
|
package/dist/store.d.ts
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* PluresStore — Svelte-compatible writable store backed by PluresDB.
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
store: import("svelte/store").Writable<any>;
|
|
13
|
-
setupDbSubscription(): void;
|
|
14
|
-
unsubscribe: any;
|
|
15
|
-
ensureTextProperties(data: any): any;
|
|
16
|
-
subscribe(run: any): import("svelte/store").Unsubscriber;
|
|
17
|
-
set(value: any): void;
|
|
18
|
-
update(updater: any): void;
|
|
4
|
+
export declare class PluresStore<T = any> {
|
|
5
|
+
private store;
|
|
6
|
+
private unsub;
|
|
7
|
+
private isUpdatingFromDb;
|
|
8
|
+
constructor(path: string, initialValue?: T);
|
|
9
|
+
subscribe(run: (value: T) => void): import("svelte/store").Unsubscriber;
|
|
10
|
+
set(value: T): void;
|
|
11
|
+
update(updater: (current: T) => T): void;
|
|
19
12
|
destroy(): void;
|
|
20
13
|
}
|
|
21
|
-
export
|
|
22
|
-
/**
|
|
23
|
-
* Creates a PluresStore with proper error handling
|
|
24
|
-
*/
|
|
25
|
-
export function createGunStore(db: any, options?: {}): PluresStore;
|
|
14
|
+
export declare function createPluresStore<T = any>(path: string, initialValue?: T): PluresStore<T>;
|
|
26
15
|
//# sourceMappingURL=store.d.ts.map
|
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,qBAAa,WAAW,CAAC,CAAC,GAAG,GAAG;IAC9B,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,gBAAgB,CAAS;gBAErB,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC;IAgB1C,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI;IAIjC,GAAG,CAAC,KAAK,EAAE,CAAC;IAOZ,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC;IAUjC,OAAO;CAIR;AAED,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAEzF"}
|
package/dist/store.js
CHANGED
|
@@ -1,154 +1,50 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* This provides a writable store implementation for PluresDB data.
|
|
2
|
+
* PluresStore — Svelte-compatible writable store backed by PluresDB.
|
|
5
3
|
*/
|
|
6
4
|
import { writable } from 'svelte/store';
|
|
7
|
-
|
|
8
|
-
* A Svelte-compatible store for PluresDB data
|
|
9
|
-
* This provides a reactive interface between PluresDB and Svelte
|
|
10
|
-
*/
|
|
5
|
+
import { getRoot } from './context.js';
|
|
11
6
|
export class PluresStore {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this.
|
|
25
|
-
console.log('PluresDB.once initial data snapshot:', data);
|
|
26
|
-
if (data) {
|
|
27
|
-
// Ensure the data has text properties where needed
|
|
28
|
-
this.ensureTextProperties(data);
|
|
29
|
-
// Initialize the store with existing data
|
|
30
|
-
this.store.set(data);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
// If no data exists, set an empty object
|
|
34
|
-
console.log('No initial data, setting empty object');
|
|
35
|
-
this.store.set({});
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
// Then subscribe to ongoing updates
|
|
39
|
-
this.unsubscribe = this.db.on((data, key) => {
|
|
40
|
-
try {
|
|
41
|
-
console.log('PluresDB.on received data:', data, 'with key:', key);
|
|
42
|
-
if (data === null) {
|
|
43
|
-
console.log('Received null data, setting store to empty object');
|
|
44
|
-
this.store.set({});
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
console.log('Setting store with data:', data);
|
|
48
|
-
// Ensure the data has text properties where needed
|
|
49
|
-
this.ensureTextProperties(data);
|
|
50
|
-
// Simple, clean update - let Svelte handle the reactivity
|
|
51
|
-
this.store.set(data);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
console.error('Error updating store with PluresDB data:', error);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
console.error('Error setting up PluresDB subscription:', error);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
// Helper method to ensure text properties exist
|
|
64
|
-
ensureTextProperties(data) {
|
|
65
|
-
if (!data || typeof data !== 'object')
|
|
66
|
-
return data;
|
|
67
|
-
// Process all non-underscore properties
|
|
68
|
-
Object.keys(data).forEach(key => {
|
|
69
|
-
if (key === '_')
|
|
70
|
-
return; // Skip PluresDB metadata
|
|
71
|
-
const item = data[key];
|
|
72
|
-
if (item && typeof item === 'object') {
|
|
73
|
-
// If the item exists but has no text property, add one
|
|
74
|
-
if (!item.text || typeof item.text !== 'string') {
|
|
75
|
-
console.log(`Adding missing text property to item ${key}`);
|
|
76
|
-
data[key] = {
|
|
77
|
-
...item,
|
|
78
|
-
text: `Item ${key.substring(0, 6)}`
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
7
|
+
store;
|
|
8
|
+
unsub = null;
|
|
9
|
+
isUpdatingFromDb = false;
|
|
10
|
+
constructor(path, initialValue) {
|
|
11
|
+
this.store = writable(initialValue);
|
|
12
|
+
const ref = getRoot().get(path);
|
|
13
|
+
// Subscribe to DB updates
|
|
14
|
+
this.unsub = ref.on((data) => {
|
|
15
|
+
if (data == null)
|
|
16
|
+
return;
|
|
17
|
+
this.isUpdatingFromDb = true;
|
|
18
|
+
this.store.set(data);
|
|
19
|
+
this.isUpdatingFromDb = false;
|
|
82
20
|
});
|
|
83
|
-
|
|
21
|
+
// Expose put for writes
|
|
22
|
+
this._ref = ref;
|
|
84
23
|
}
|
|
85
24
|
subscribe(run) {
|
|
86
25
|
return this.store.subscribe(run);
|
|
87
26
|
}
|
|
88
27
|
set(value) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
try {
|
|
94
|
-
console.log('PluresStore.set called with value:', value);
|
|
95
|
-
// Update PluresDB - this will trigger the .on() callback above
|
|
96
|
-
this.db.put(value);
|
|
97
|
-
// Also update the store directly for immediate UI feedback
|
|
98
|
-
this.store.set(value);
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
console.error('Error setting PluresDB data:', error);
|
|
28
|
+
this.store.set(value);
|
|
29
|
+
if (!this.isUpdatingFromDb) {
|
|
30
|
+
this._ref.put(value);
|
|
102
31
|
}
|
|
103
32
|
}
|
|
104
33
|
update(updater) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
console.warn('Updating undefined PluresDB value');
|
|
113
|
-
const newValue = updater({});
|
|
114
|
-
this.db.put(newValue);
|
|
115
|
-
return newValue;
|
|
116
|
-
}
|
|
117
|
-
const newValue = updater(currentValue);
|
|
118
|
-
this.db.put(newValue);
|
|
119
|
-
return newValue;
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
console.error('Error updating PluresDB data:', error);
|
|
124
|
-
}
|
|
34
|
+
this.store.update((cur) => {
|
|
35
|
+
const next = updater(cur);
|
|
36
|
+
if (!this.isUpdatingFromDb) {
|
|
37
|
+
this._ref.put(next);
|
|
38
|
+
}
|
|
39
|
+
return next;
|
|
40
|
+
});
|
|
125
41
|
}
|
|
126
42
|
destroy() {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
this.unsubscribe();
|
|
130
|
-
}
|
|
131
|
-
catch (error) {
|
|
132
|
-
console.error('Error unsubscribing from PluresDB:', error);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
43
|
+
this.unsub?.();
|
|
44
|
+
this.unsub = null;
|
|
135
45
|
}
|
|
136
46
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
*/
|
|
140
|
-
export function createPluresStore(db, options = {}) {
|
|
141
|
-
if (!db) {
|
|
142
|
-
console.error('No PluresDB instance provided to createPluresStore');
|
|
143
|
-
// Return a dummy store that won't crash
|
|
144
|
-
return new PluresStore({
|
|
145
|
-
on: () => () => { },
|
|
146
|
-
put: () => { },
|
|
147
|
-
}, options);
|
|
148
|
-
}
|
|
149
|
-
return new PluresStore(db, options);
|
|
47
|
+
export function createPluresStore(path, initialValue) {
|
|
48
|
+
return new PluresStore(path, initialValue);
|
|
150
49
|
}
|
|
151
|
-
// Legacy exports for backward compatibility
|
|
152
|
-
export const GunStore = PluresStore;
|
|
153
|
-
export const createGunStore = createPluresStore;
|
|
154
50
|
//# sourceMappingURL=store.js.map
|
package/dist/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAiB,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,MAAM,OAAO,WAAW;IACd,KAAK,CAAc;IACnB,KAAK,GAAuB,IAAI,CAAC;IACjC,gBAAgB,GAAG,KAAK,CAAC;IAEjC,YAAY,IAAY,EAAE,YAAgB;QACxC,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAI,YAAiB,CAAC,CAAC;QAC5C,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAEhC,0BAA0B;QAC1B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,IAAS,EAAE,EAAE;YAChC,IAAI,IAAI,IAAI,IAAI;gBAAE,OAAO;YACzB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAC7B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAS,CAAC,CAAC;YAC1B,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAChC,CAAC,CAAC,CAAC;QAEH,wBAAwB;QACvB,IAAY,CAAC,IAAI,GAAG,GAAG,CAAC;IAC3B,CAAC;IAED,SAAS,CAAC,GAAuB;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED,GAAG,CAAC,KAAQ;QACV,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,IAAY,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED,MAAM,CAAC,OAA0B;QAC/B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;YACxB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;YAC1B,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC1B,IAAY,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;CACF;AAED,MAAM,UAAU,iBAAiB,CAAU,IAAY,EAAE,YAAgB;IACvE,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;AAC7C,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* unum — Reactive Svelte bindings for PluresDB
|
|
3
|
+
*
|
|
4
|
+
* Core types for the database adapter interface.
|
|
5
|
+
*/
|
|
6
|
+
/** Callback for data subscriptions */
|
|
7
|
+
export type DataCallback = (data: any, key?: string) => void;
|
|
8
|
+
/** Unsubscribe function returned by on() */
|
|
9
|
+
export type Unsubscribe = () => void;
|
|
10
|
+
/**
|
|
11
|
+
* Chain node — the fluent API for navigating and mutating data.
|
|
12
|
+
* Mirrors PluresDB/Gun's chain API but is backend-agnostic.
|
|
13
|
+
*/
|
|
14
|
+
export interface ChainNode {
|
|
15
|
+
/** Navigate to a child key */
|
|
16
|
+
get(key: string): ChainNode;
|
|
17
|
+
/** Write data at this path */
|
|
18
|
+
put(data: any, cb?: DataCallback): ChainNode;
|
|
19
|
+
/** Add an item to a collection (auto-generates key) */
|
|
20
|
+
set(data: any, cb?: DataCallback): ChainNode;
|
|
21
|
+
/** Subscribe to live updates */
|
|
22
|
+
on(cb: DataCallback): Unsubscribe;
|
|
23
|
+
/** Read once */
|
|
24
|
+
once(cb: DataCallback): void;
|
|
25
|
+
/** Iterate over collection children */
|
|
26
|
+
map(): ChainNode;
|
|
27
|
+
/** Unsubscribe all listeners at this path */
|
|
28
|
+
off(): void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Database adapter — implement this to plug in any backend.
|
|
32
|
+
*/
|
|
33
|
+
export interface DbAdapter {
|
|
34
|
+
/** Get the root chain node */
|
|
35
|
+
root(): ChainNode;
|
|
36
|
+
/** Optional cleanup */
|
|
37
|
+
destroy?(): void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Options for pluresData()
|
|
41
|
+
*/
|
|
42
|
+
export interface PluresDataOptions {
|
|
43
|
+
/** Initial/default data before first load */
|
|
44
|
+
defaults?: Record<string, any>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Reactive data reference returned by pluresData()
|
|
48
|
+
*/
|
|
49
|
+
export interface DataRef<T = Record<string, any>> {
|
|
50
|
+
/** Current state snapshot */
|
|
51
|
+
readonly state: T;
|
|
52
|
+
/** For collections: array of items. For single items: the item. */
|
|
53
|
+
readonly value: any;
|
|
54
|
+
/** Get all items as an array (collections only) */
|
|
55
|
+
list(): Array<T & {
|
|
56
|
+
id: string;
|
|
57
|
+
}>;
|
|
58
|
+
/** Add an item to the collection */
|
|
59
|
+
add(data: any): void;
|
|
60
|
+
/** Update an item or the current item */
|
|
61
|
+
update(idOrUpdater: string | Partial<T> | ((item: T) => Partial<T>), updater?: Partial<T> | ((item: T) => Partial<T>)): void;
|
|
62
|
+
/** Remove an item by ID */
|
|
63
|
+
remove(id?: string): void;
|
|
64
|
+
/** Svelte-compatible subscribe */
|
|
65
|
+
subscribe(cb: (state: T) => void): Unsubscribe;
|
|
66
|
+
/** Cleanup subscriptions */
|
|
67
|
+
destroy(): void;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,sCAAsC;AACtC,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAE7D,4CAA4C;AAC5C,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,8BAA8B;IAC9B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,8BAA8B;IAC9B,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IAC7C,uDAAuD;IACvD,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IAC7C,gCAAgC;IAChC,EAAE,CAAC,EAAE,EAAE,YAAY,GAAG,WAAW,CAAC;IAClC,gBAAgB;IAChB,IAAI,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAAC;IAC7B,uCAAuC;IACvC,GAAG,IAAI,SAAS,CAAC;IACjB,6CAA6C;IAC7C,GAA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
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/package.json
CHANGED
|
@@ -1,49 +1,54 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@plures/unum",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@plures/unum",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Reactive Svelte bindings for PluresDB — backend-agnostic, TypeScript-first",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./adapters": {
|
|
14
|
+
"types": "./dist/adapters/index.d.ts",
|
|
15
|
+
"import": "./dist/adapters/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"LICENSE.md"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"test": "vitest run",
|
|
25
|
+
"test:watch": "vitest",
|
|
26
|
+
"prepublishOnly": "npm run build"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"svelte",
|
|
30
|
+
"svelte5",
|
|
31
|
+
"reactive",
|
|
32
|
+
"store",
|
|
33
|
+
"runes",
|
|
34
|
+
"pluresdb",
|
|
35
|
+
"database",
|
|
36
|
+
"p2p",
|
|
37
|
+
"typescript"
|
|
38
|
+
],
|
|
39
|
+
"author": "Oasis Team",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "https://github.com/plures/unum"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"svelte": "^4.0.0 || ^5.0.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"jsdom": "^29.0.0",
|
|
50
|
+
"svelte": "^5.0.0",
|
|
51
|
+
"typescript": "^5.8.2",
|
|
52
|
+
"vitest": "^1.0.0"
|
|
53
|
+
}
|
|
54
|
+
}
|
package/dist/GunContext.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Initialize PluresDB instance if not already done
|
|
3
|
-
* Only runs in the browser
|
|
4
|
-
*/
|
|
5
|
-
export function initializePlures(): () => void;
|
|
6
|
-
export const todosRef: import("svelte/store").Readable<any>;
|
|
7
|
-
export const messagesRef: import("svelte/store").Readable<any>;
|
|
8
|
-
export const userProfileRef: import("svelte/store").Readable<any>;
|
|
9
|
-
export const plures: import("svelte/store").Writable<any>;
|
|
10
|
-
export const db: import("svelte/store").Writable<any>;
|
|
11
|
-
export const gun: import("svelte/store").Writable<any>;
|
|
12
|
-
/**
|
|
13
|
-
* Initialize PluresDB instance if not already done
|
|
14
|
-
* Only runs in the browser
|
|
15
|
-
*/
|
|
16
|
-
export function initializeGun(): () => void;
|
|
17
|
-
//# sourceMappingURL=GunContext.d.ts.map
|
package/dist/GunContext.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GunContext.d.ts","sourceRoot":"","sources":["../src/GunContext.js"],"names":[],"mappings":"AAiFA;;;GAGG;AACH,+CA2GC;AA/KD,4DAA2E;AAC3E,+DAAiF;AACjF,kEAAuF;AAgLvF,0DAA8B;AAC9B,sDAA0B;AAG1B,uDAA2B;AAtH3B;;;GAGG;AACH,4CA2GC"}
|