@plures/unum 0.2.2 → 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.
Files changed (58) hide show
  1. package/README.md +3 -6
  2. package/dist/adapters/index.d.ts +3 -0
  3. package/dist/adapters/index.d.ts.map +1 -0
  4. package/dist/adapters/index.js +3 -0
  5. package/dist/adapters/index.js.map +1 -0
  6. package/dist/adapters/memory.d.ts +7 -0
  7. package/dist/adapters/memory.d.ts.map +1 -0
  8. package/dist/adapters/memory.js +116 -0
  9. package/dist/adapters/memory.js.map +1 -0
  10. package/dist/adapters/pluresdb.d.ts +14 -0
  11. package/dist/adapters/pluresdb.d.ts.map +1 -0
  12. package/dist/adapters/pluresdb.js +48 -0
  13. package/dist/adapters/pluresdb.js.map +1 -0
  14. package/dist/context.d.ts +29 -0
  15. package/dist/context.d.ts.map +1 -0
  16. package/dist/context.js +43 -0
  17. package/dist/context.js.map +1 -0
  18. package/dist/index.d.ts +8 -53
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +9 -196
  21. package/dist/index.js.map +1 -1
  22. package/dist/runes.d.ts +17 -161
  23. package/dist/runes.d.ts.map +1 -1
  24. package/dist/runes.js +121 -290
  25. package/dist/runes.js.map +1 -1
  26. package/dist/store.d.ts +10 -21
  27. package/dist/store.d.ts.map +1 -1
  28. package/dist/store.js +31 -135
  29. package/dist/store.js.map +1 -1
  30. package/dist/types.d.ts +69 -0
  31. package/dist/types.d.ts.map +1 -0
  32. package/dist/types.js +7 -0
  33. package/dist/types.js.map +1 -0
  34. package/package.json +54 -49
  35. package/dist/GunContext.d.ts +0 -17
  36. package/dist/GunContext.d.ts.map +0 -1
  37. package/dist/GunContext.js +0 -180
  38. package/dist/GunContext.js.map +0 -1
  39. package/dist/actions.d.ts +0 -39
  40. package/dist/actions.d.ts.map +0 -1
  41. package/dist/actions.js +0 -89
  42. package/dist/actions.js.map +0 -1
  43. package/dist/gunComponent.d.ts +0 -44
  44. package/dist/gunComponent.d.ts.map +0 -1
  45. package/dist/gunComponent.js +0 -205
  46. package/dist/gunComponent.js.map +0 -1
  47. package/dist/gunify.d.ts +0 -46
  48. package/dist/gunify.d.ts.map +0 -1
  49. package/dist/gunify.js +0 -294
  50. package/dist/gunify.js.map +0 -1
  51. package/dist/plures-helper.d.ts +0 -41
  52. package/dist/plures-helper.d.ts.map +0 -1
  53. package/dist/plures-helper.js +0 -114
  54. package/dist/plures-helper.js.map +0 -1
  55. package/dist/universalGunBind.d.ts +0 -219
  56. package/dist/universalGunBind.d.ts.map +0 -1
  57. package/dist/universalGunBind.js +0 -394
  58. package/dist/universalGunBind.js.map +0 -1
@@ -1,180 +0,0 @@
1
- /**
2
- * PluresContext - Centralized PluresDB instance management
3
- *
4
- * This module provides a shared PluresDB instance for the entire application,
5
- * avoiding multiple initializations across components.
6
- *
7
- * PluresDB is available as the 'pluresdb' package on npm.
8
- */
9
- import { writable, derived } from 'svelte/store';
10
- // Check if we're in a browser environment
11
- const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
12
- // Store to hold the PluresDB instance
13
- const dbStore = writable(null);
14
- // Derived stores for common PluresDB paths
15
- export const todosRef = derived(dbStore, $db => $db?.get('todos') || null);
16
- export const messagesRef = derived(dbStore, $db => $db?.get('messages') || null);
17
- export const userProfileRef = derived(dbStore, $db => $db?.get('userProfile') || null);
18
- // Flag to prevent multiple initializations
19
- let initialized = false;
20
- let initializationAttempts = 0;
21
- const MAX_ATTEMPTS = 10;
22
- /**
23
- * Load PluresDB from CDN dynamically if not already loaded
24
- * Note: For production use, install pluresdb from npm instead of using CDN
25
- */
26
- function loadPluresScript() {
27
- return new Promise((resolve, reject) => {
28
- // If PluresDB is already available, resolve immediately
29
- // PluresDB can be loaded from pluresdb package
30
- if (typeof window !== 'undefined' && (window.PluresDB || window.GunDB || window.Gun)) {
31
- return resolve(window.PluresDB || window.GunDB || window.Gun);
32
- }
33
- // Check if the script is already in the DOM
34
- const existingScript = document.querySelector('script[src*="pluresdb"]') ||
35
- document.querySelector('script[src*="gun.js"]');
36
- if (existingScript) {
37
- // Script exists but hasn't loaded yet, wait for it
38
- existingScript.addEventListener('load', () => {
39
- const DB = window.PluresDB || window.GunDB || window.Gun;
40
- if (DB) {
41
- resolve(DB);
42
- }
43
- else {
44
- reject(new Error('PluresDB script loaded but not defined'));
45
- }
46
- });
47
- existingScript.addEventListener('error', () => {
48
- reject(new Error('Failed to load PluresDB script'));
49
- });
50
- return;
51
- }
52
- // Create and add the script element
53
- // For production, use: import { GunDB } from 'pluresdb'
54
- // Using Gun.js CDN as fallback for browser compatibility
55
- const script = document.createElement('script');
56
- script.src = 'https://cdn.jsdelivr.net/npm/gun/gun.js';
57
- script.async = true;
58
- script.addEventListener('load', () => {
59
- const DB = window.PluresDB || window.GunDB || window.Gun;
60
- if (DB) {
61
- resolve(DB);
62
- }
63
- else {
64
- reject(new Error('PluresDB script loaded but not defined'));
65
- }
66
- });
67
- script.addEventListener('error', () => {
68
- reject(new Error('Failed to load PluresDB script'));
69
- });
70
- document.head.appendChild(script);
71
- });
72
- }
73
- /**
74
- * Initialize PluresDB instance if not already done
75
- * Only runs in the browser
76
- */
77
- export function initializePlures() {
78
- if (initialized || !isBrowser)
79
- return;
80
- const attemptInitialization = async () => {
81
- // Only attempt initialization if not already initialized
82
- if (initialized)
83
- return;
84
- if (initializationAttempts >= MAX_ATTEMPTS) {
85
- console.error('Failed to initialize PluresDB after multiple attempts');
86
- return;
87
- }
88
- initializationAttempts++;
89
- try {
90
- // Ensure PluresDB is loaded (from pluresdb package or CDN)
91
- await loadPluresScript();
92
- const DB = window.PluresDB || window.GunDB || window.Gun;
93
- if (DB) {
94
- console.log('Initializing shared PluresDB instance');
95
- // Create a single DB instance for the app with reliable storage
96
- const db = new DB({
97
- localStorage: true, // Use localStorage adapter
98
- file: 'unum-demo', // Name for stored data
99
- radisk: true, // Use RAD to ensure data persistence
100
- multicast: false, // No multicast for this demo
101
- peers: ['http://localhost:8765/gun'],
102
- axe: false // Disable Axe by default
103
- });
104
- // Monitor all changes to the database
105
- db.on('put', function (data) {
106
- console.log('PluresDB PUT event:', data);
107
- });
108
- // Store in our Svelte store
109
- dbStore.set(db);
110
- initialized = true;
111
- // Initialize collections if they don't exist
112
- setTimeout(() => {
113
- if (initialized && db) {
114
- // Initialize todos collection
115
- db.get('todos').once((data) => {
116
- console.log('Checking todos collection:', data);
117
- // Add a test todo if empty
118
- if (!data || Object.keys(data).filter(k => k !== '_').length === 0) {
119
- console.log('Initializing empty todos collection');
120
- // Create a test todo item with explicit text field
121
- const testId = 'test-' + Date.now();
122
- db.get('todos').get(testId).put({
123
- text: 'Test Todo Item - ' + new Date().toLocaleTimeString(),
124
- completed: false,
125
- createdAt: Date.now()
126
- });
127
- console.log('Added test todo with ID:', testId);
128
- }
129
- else {
130
- // Verify all todo items have a text property
131
- console.log('Todos collection exists, checking items');
132
- db.get('todos').map().once((item, id) => {
133
- if (id === '_')
134
- return;
135
- console.log(`Checking todo ${id}:`, item);
136
- // If item exists but has no text, add a text property
137
- if (item && (!item.text || item.text === '')) {
138
- console.log(`Fixing missing text for todo ${id}`);
139
- db.get('todos').get(id).put({
140
- ...item,
141
- text: `Todo item ${id.substring(0, 6)}`,
142
- });
143
- }
144
- });
145
- }
146
- });
147
- }
148
- }, 500);
149
- }
150
- else if (!initialized) {
151
- console.warn('PluresDB not available even after loading script. Retrying...');
152
- // Retry after a delay - only if not initialized yet
153
- setTimeout(attemptInitialization, 500);
154
- }
155
- }
156
- catch (error) {
157
- console.error('Error initializing PluresDB:', error);
158
- // Retry after a delay - only if not initialized yet
159
- if (!initialized) {
160
- setTimeout(attemptInitialization, 500);
161
- }
162
- }
163
- };
164
- // Start the initialization process once
165
- attemptInitialization();
166
- return () => {
167
- console.log('Cleaning up PluresDB instance');
168
- // PluresDB doesn't have a formal cleanup method, but we can clear our reference
169
- dbStore.set(null);
170
- initialized = false;
171
- initializationAttempts = 0;
172
- };
173
- }
174
- // Export the db store for components to subscribe to
175
- export const plures = dbStore;
176
- export const db = dbStore;
177
- // Legacy export for backward compatibility
178
- export const gun = dbStore;
179
- export const initializeGun = initializePlures;
180
- //# sourceMappingURL=GunContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GunContext.js","sourceRoot":"","sources":["../src/GunContext.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEjD,0CAA0C;AAC1C,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,CAAC;AAEnF,sCAAsC;AACtC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;AAE/B,2CAA2C;AAC3C,MAAM,CAAC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC;AAC3E,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,CAAC;AACjF,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,CAAC;AAEvF,2CAA2C;AAC3C,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,IAAI,sBAAsB,GAAG,CAAC,CAAC;AAC/B,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB;;;GAGG;AACH,SAAS,gBAAgB;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,wDAAwD;QACxD,+CAA+C;QAC/C,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC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AG,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,wCAAwC;IACxC,qBAAqB,EAAE,CAAC;IAExB,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;QAC7C,gFAAgF;QAChF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,WAAW,GAAG,KAAK,CAAC;QACpB,sBAAsB,GAAG,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC;AAED,qDAAqD;AACrD,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC;AAC9B,MAAM,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC;AAE1B,2CAA2C;AAC3C,MAAM,CAAC,MAAM,GAAG,GAAG,OAAO,CAAC;AAC3B,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAC"}
package/dist/actions.d.ts DELETED
@@ -1,39 +0,0 @@
1
- /**
2
- * unum - Svelte action bindings for PluresDB
3
- *
4
- * This provides a pluresList action for binding PluresDB data to the DOM.
5
- */
6
- /**
7
- * Svelte action for handling PluresDB data binding in lists
8
- *
9
- * @example
10
- * ```svelte
11
- * <div use:pluresList={{ db: db.get('messages'), callback: updateMessages }}>
12
- * <!-- List rendering based on messages array -->
13
- * </div>
14
- * ```
15
- */
16
- export function pluresList(node: any, params: any): {
17
- update(newParams: any): void;
18
- destroy(): void;
19
- };
20
- /**
21
- * unum - Svelte action bindings for PluresDB
22
- *
23
- * This provides a pluresList action for binding PluresDB data to the DOM.
24
- */
25
- /**
26
- * Svelte action for handling PluresDB data binding in lists
27
- *
28
- * @example
29
- * ```svelte
30
- * <div use:pluresList={{ db: db.get('messages'), callback: updateMessages }}>
31
- * <!-- List rendering based on messages array -->
32
- * </div>
33
- * ```
34
- */
35
- export function gunList(node: any, params: any): {
36
- update(newParams: any): void;
37
- destroy(): void;
38
- };
39
- //# sourceMappingURL=actions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.js"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AACH;;;EA6EC;AA7FD;;;;GAIG;AAEH;;;;;;;;;GASG;AACH;;;EA6EC"}
package/dist/actions.js DELETED
@@ -1,89 +0,0 @@
1
- /**
2
- * unum - Svelte action bindings for PluresDB
3
- *
4
- * This provides a pluresList action for binding PluresDB data to the DOM.
5
- */
6
- /**
7
- * Svelte action for handling PluresDB data binding in lists
8
- *
9
- * @example
10
- * ```svelte
11
- * <div use:pluresList={{ db: db.get('messages'), callback: updateMessages }}>
12
- * <!-- List rendering based on messages array -->
13
- * </div>
14
- * ```
15
- */
16
- export function pluresList(node, params) {
17
- let unsubscribe = null;
18
- let dbRef = null;
19
- let callback = null;
20
- if (!params)
21
- return;
22
- if (params.db || params.gun) {
23
- dbRef = params.db || params.gun; // Support both 'db' and 'gun' for compatibility
24
- }
25
- if (params.callback && typeof params.callback === 'function') {
26
- callback = params.callback;
27
- }
28
- // Initialize subscription
29
- function init() {
30
- if (dbRef && typeof dbRef.map === 'function') {
31
- // Subscribe to changes
32
- try {
33
- const dataMap = {};
34
- unsubscribe = dbRef.map().on((data, key) => {
35
- if (key === '_')
36
- return;
37
- // Update data map
38
- dataMap[key] = data;
39
- // Call callback with all data
40
- if (callback) {
41
- callback(dataMap);
42
- }
43
- });
44
- }
45
- catch (error) {
46
- console.error('Error in pluresList subscription:', error);
47
- }
48
- }
49
- }
50
- // Initialize
51
- init();
52
- // Return action object
53
- return {
54
- update(newParams) {
55
- // Cleanup old subscription
56
- if (unsubscribe) {
57
- try {
58
- unsubscribe();
59
- }
60
- catch (error) {
61
- console.error('Error cleaning up pluresList subscription:', error);
62
- }
63
- }
64
- // Update parameters
65
- if (newParams.db || newParams.gun) {
66
- dbRef = newParams.db || newParams.gun;
67
- }
68
- if (newParams.callback && typeof newParams.callback === 'function') {
69
- callback = newParams.callback;
70
- }
71
- // Reinitialize
72
- init();
73
- },
74
- destroy() {
75
- // Clean up subscription
76
- if (unsubscribe) {
77
- try {
78
- unsubscribe();
79
- }
80
- catch (error) {
81
- console.error('Error cleaning up pluresList subscription:', error);
82
- }
83
- }
84
- }
85
- };
86
- }
87
- // Legacy export for backward compatibility
88
- export const gunList = pluresList;
89
- //# sourceMappingURL=actions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.js"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,IAAI,EAAE,MAAM;IACrC,IAAI,WAAW,GAAG,IAAI,CAAC;IACvB,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,IAAI,QAAQ,GAAG,IAAI,CAAC;IAEpB,IAAI,CAAC,MAAM;QAAE,OAAO;IAEpB,IAAI,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;QAC5B,KAAK,GAAG,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,gDAAgD;IACnF,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;QAC7D,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC7B,CAAC;IAED,0BAA0B;IAC1B,SAAS,IAAI;QACX,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;YAC7C,uBAAuB;YACvB,IAAI,CAAC;gBACH,MAAM,OAAO,GAAG,EAAE,CAAC;gBAEnB,WAAW,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;oBACzC,IAAI,GAAG,KAAK,GAAG;wBAAE,OAAO;oBAExB,kBAAkB;oBAClB,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;oBAEpB,8BAA8B;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+0,0 @@
1
- /**
2
- * Wraps any Svelte component with PluresDB integration
3
- *
4
- * @param {Component} Component - The Svelte component to wrap
5
- * @param {Object} options - Configuration options
6
- * @param {string} options.path - The PluresDB path to store data
7
- * @param {string} [options.id] - Optional ID for this specific instance
8
- * @param {Object} [options.defaultData] - Default data to use if PluresDB has no data
9
- * @returns {Component} A new component that wraps the original with PluresDB integration
10
- */
11
- export function gunComponent(Component: any, { path, id, defaultData }: {
12
- path: string;
13
- id?: string;
14
- defaultData?: any;
15
- }): any;
16
- /**
17
- * Creates a Svelte component that wraps another component with PluresDB integration
18
- * This provides a cleaner API for creating PluresDB-powered components
19
- *
20
- * @param {Component} Component - The component to wrap
21
- * @param {string} path - PluresDB path for data storage
22
- * @param {Object} [options] - Additional options
23
- * @param {string} [options.id] - Optional ID for this instance
24
- * @param {Object} [options.defaultData] - Default data to use
25
- * @returns {Component} A new Svelte component
26
- *
27
- * @example
28
- * // Create a PluresDB-powered TodoApp
29
- * import { wrapWithGun } from '$lib/unum/gunComponent';
30
- * import TodoApp from './TodoApp.svelte';
31
- *
32
- * // Simple API - component knows nothing about PluresDB
33
- * export const PluresTodοApp = wrapWithGun(TodoApp, 'todos', {
34
- * defaultData: { items: [] }
35
- * });
36
- *
37
- * // In a parent component, use it like a normal component
38
- * <PluresTodοApp title="My Todo List" />
39
- */
40
- export function wrapWithGun(Component: any, path: string, options?: {
41
- id?: string;
42
- defaultData?: any;
43
- }): any;
44
- //# sourceMappingURL=gunComponent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gunComponent.d.ts","sourceRoot":"","sources":["../src/gunComponent.js"],"names":[],"mappings":"AASA;;;;;;;;;GASG;AACH,wEALG;IAAwB,IAAI,EAApB,MAAM;IACW,EAAE,GAAnB,MAAM;IACW,WAAW;CACpC,OA4JF;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,kDAnBW,MAAM,YAEd;IAAyB,EAAE,GAAnB,MAAM;IACW,WAAW;CACpC,OAoDF"}
@@ -1,205 +0,0 @@
1
- /**
2
- * unum - PluresDB-powered Component Wrapper
3
- *
4
- * This module provides a higher-level component wrapper that simplifies
5
- * binding Svelte components to PluresDB (pluresdb npm package) data.
6
- */
7
- import { gun as gunStore } from './GunContext.js';
8
- import { writable, get } from 'svelte/store';
9
- /**
10
- * Wraps any Svelte component with PluresDB integration
11
- *
12
- * @param {Component} Component - The Svelte component to wrap
13
- * @param {Object} options - Configuration options
14
- * @param {string} options.path - The PluresDB path to store data
15
- * @param {string} [options.id] - Optional ID for this specific instance
16
- * @param {Object} [options.defaultData] - Default data to use if PluresDB has no data
17
- * @returns {Component} A new component that wraps the original with PluresDB integration
18
- */
19
- export function gunComponent(Component, { path, id, defaultData = {} }) {
20
- // Generate unique ID if not provided
21
- const instanceId = id || `${path}_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
22
- const gunPath = `${path}/${instanceId}`;
23
- // Create a component that properly works with Svelte 5 runes mode
24
- return function GunWrappedComponent(props) {
25
- // Create a store for our props
26
- const propsStore = writable({ ...defaultData, ...props });
27
- // Flag to prevent circular updates
28
- let isUpdatingFromGun = false;
29
- // Gun reference and unsubscribe function
30
- let gunNodeRef = null;
31
- let gunUnsubscribe = null;
32
- // Last known state for comparison
33
- let lastKnownState = { ...defaultData, ...props };
34
- // Setup Gun subscription
35
- let cleanup = null;
36
- // Set up our Gun subscription
37
- function setup() {
38
- const unsubGun = gunStore.subscribe($gun => {
39
- if (!$gun)
40
- return;
41
- // Get the Gun node for this component
42
- const gunNode = $gun.get(gunPath);
43
- gunNodeRef = gunNode;
44
- // Initialize with default data if empty
45
- gunNode.once(data => {
46
- if (!data || Object.keys(data).filter(k => k !== '_').length === 0) {
47
- // Initialize with combined default and initial props
48
- const initialData = { ...defaultData, ...props };
49
- gunNode.put(initialData);
50
- }
51
- });
52
- // Subscribe to Gun data changes
53
- if (gunUnsubscribe) {
54
- gunUnsubscribe();
55
- }
56
- // Listen for updates
57
- gunUnsubscribe = gunNode.on((data) => {
58
- if (!data)
59
- return;
60
- // Filter out Gun metadata
61
- const cleanData = {};
62
- for (const key in data) {
63
- if (key !== '_' && !key.startsWith('_')) {
64
- cleanData[key] = data[key];
65
- }
66
- }
67
- // Prevent circular updates
68
- if (JSON.stringify(cleanData) !== JSON.stringify(lastKnownState)) {
69
- isUpdatingFromGun = true;
70
- // Update store
71
- propsStore.set(cleanData);
72
- // Update last known state
73
- lastKnownState = { ...cleanData };
74
- // Reset update flag after a tick
75
- setTimeout(() => {
76
- isUpdatingFromGun = false;
77
- }, 0);
78
- }
79
- });
80
- });
81
- // Return cleanup function
82
- return () => {
83
- if (gunUnsubscribe) {
84
- gunUnsubscribe();
85
- gunUnsubscribe = null;
86
- }
87
- unsubGun();
88
- };
89
- }
90
- // Handle changes from the component
91
- function handleUpdate(event) {
92
- if (isUpdatingFromGun)
93
- return;
94
- const detail = event?.detail;
95
- if (!detail)
96
- return;
97
- // Update our state
98
- lastKnownState = { ...lastKnownState, ...detail };
99
- // Update Gun
100
- if (gunNodeRef) {
101
- gunNodeRef.put(lastKnownState);
102
- }
103
- }
104
- // Update Gun when props change
105
- function syncToGun() {
106
- if (isUpdatingFromGun || !gunNodeRef)
107
- return;
108
- // Get current props
109
- const currentProps = get(propsStore);
110
- // Update Gun if different
111
- if (JSON.stringify(currentProps) !== JSON.stringify(lastKnownState)) {
112
- lastKnownState = { ...currentProps };
113
- gunNodeRef.put(currentProps);
114
- }
115
- }
116
- // Create our component instance with proper lifecycle hooks
117
- return {
118
- // Set up when component is created
119
- $$render() {
120
- // Setup our Gun subscription if needed
121
- if (!cleanup) {
122
- cleanup = setup();
123
- }
124
- // Get derived props
125
- const $props = get(propsStore);
126
- // Sync to Gun when props change
127
- syncToGun();
128
- // Render the component with derived props
129
- return Component.render
130
- ? Component.render($props, {}) // For Svelte compiler >= 5
131
- : Component({ ...props, ...$props });
132
- },
133
- // Set up event handlers
134
- $$events: {
135
- update: handleUpdate,
136
- change: handleUpdate,
137
- input: handleUpdate,
138
- },
139
- // Clean up subscriptions when component is destroyed
140
- $$destroy() {
141
- if (cleanup) {
142
- cleanup();
143
- cleanup = null;
144
- }
145
- }
146
- };
147
- };
148
- }
149
- /**
150
- * Creates a Svelte component that wraps another component with PluresDB integration
151
- * This provides a cleaner API for creating PluresDB-powered components
152
- *
153
- * @param {Component} Component - The component to wrap
154
- * @param {string} path - PluresDB path for data storage
155
- * @param {Object} [options] - Additional options
156
- * @param {string} [options.id] - Optional ID for this instance
157
- * @param {Object} [options.defaultData] - Default data to use
158
- * @returns {Component} A new Svelte component
159
- *
160
- * @example
161
- * // Create a PluresDB-powered TodoApp
162
- * import { wrapWithGun } from '$lib/unum/gunComponent';
163
- * import TodoApp from './TodoApp.svelte';
164
- *
165
- * // Simple API - component knows nothing about PluresDB
166
- * export const PluresTodοApp = wrapWithGun(TodoApp, 'todos', {
167
- * defaultData: { items: [] }
168
- * });
169
- *
170
- * // In a parent component, use it like a normal component
171
- * <PluresTodοApp title="My Todo List" />
172
- */
173
- export function wrapWithGun(Component, path, options = {}) {
174
- // Create a properly formatted component wrapper
175
- const WrappedComponent = function (props) {
176
- const wrapper = gunComponent(Component, {
177
- path,
178
- id: options.id,
179
- defaultData: options.defaultData || {}
180
- });
181
- // Create a new instance of the wrapper with the props
182
- const instance = new wrapper(props);
183
- // Return the instance
184
- return instance;
185
- };
186
- // Make it look like a Svelte component
187
- WrappedComponent.$$render = function ($$props) {
188
- const props = $$props || {};
189
- const instance = new WrappedComponent(props);
190
- return instance.$$render ? instance.$$render() : '';
191
- };
192
- // Add other important Svelte component properties
193
- WrappedComponent.render = function (props, options) {
194
- const wrapper = gunComponent(Component, {
195
- path,
196
- id: options?.id || options.id,
197
- defaultData: options.defaultData || {}
198
- });
199
- // For Svelte 5
200
- const instance = new wrapper(props);
201
- return instance.$$render ? instance.$$render() : '';
202
- };
203
- return WrappedComponent;
204
- }
205
- //# sourceMappingURL=gunComponent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gunCom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AE,CAAC;QAC5B,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAC7C,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACtD,CAAC,CAAC;IAEF,kDAAkD;IAClD,gBAAgB,CAAC,MAAM,GAAG,UAAS,KAAK,EAAE,OAAO;QAC/C,MAAM,OAAO,GAAG,YAAY,CAAC,SAAS,EAAE;YACtC,IAAI;YACJ,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,OAAO,CAAC,EAAE;YAC7B,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE;SACvC,CAAC,CAAC;QAEH,eAAe;QACf,MAAM,QAAQ,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;QACpC,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACtD,CAAC,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
package/dist/gunify.d.ts DELETED
@@ -1,46 +0,0 @@
1
- /**
2
- * Creates a Gun-powered version of any Svelte component
3
- *
4
- * This function takes a component and returns a new function component
5
- * that automatically binds Gun.js data to the original component's props structure.
6
- *
7
- * @param {Component} Component - The Svelte component to enhance
8
- * @param {Object} options - Options for the binding
9
- * @param {string} options.path - Gun.js path for the data
10
- * @param {string} [options.id] - Optional ID for specific component instance
11
- * @param {Object} [options.defaultProps] - Default props to use when Gun data is not available
12
- * @returns {Component} A new component that wraps the original with Gun.js binding
13
- *
14
- * @example
15
- * // Create a Gun-powered TodoList component
16
- * import { unum } from '$lib/svgun/unum';
17
- * import TodoList from './TodoList.svelte';
18
- *
19
- * export const GunTodoList = unum(TodoList, {
20
- * path: 'todos',
21
- * defaultProps: { items: [] }
22
- * });
23
- *
24
- * // In a parent component or route
25
- * <GunTodoList />
26
- */
27
- export function unum(Component: any, options: {
28
- path: string;
29
- id?: string;
30
- defaultProps?: any;
31
- }): any;
32
- /**
33
- * Universal binding between Gun.js and any component data
34
- *
35
- * This function creates a reactive binding that syncs component data
36
- * to Gun.js in a generic way, without caring about the specific structure.
37
- *
38
- * @param {string} path - Gun.js path for the data
39
- * @param {Object} [options] - Configuration options
40
- * @param {Object} [options.defaultData={}] - Default data to use when Gun data is not available
41
- * @returns {Object} A binding object with subscriber, data object, and change handler
42
- */
43
- export function connect(path: string, options?: {
44
- defaultData?: any;
45
- }): any;
46
- //# sourceMappingURL=gunify.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gunify.d.ts","sourceRoot":"","sources":["../src/gunify.js"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,8CAlBG;IAAwB,IAAI,EAApB,MAAM;IACW,EAAE,GAAnB,MAAM;IACW,YAAY;CACrC,OAsIF;AAED;;;;;;;;;;GAUG;AACH,8BALW,MAAM,YAEd;IAAyB,WAAW;CACpC,OAwKF"}