electron-pinia-sync 1.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.
@@ -0,0 +1,405 @@
1
+ # Contributing to electron-pinia-sync
2
+
3
+ Thank you for your interest in contributing! This guide will help you get started with local development.
4
+
5
+ ## Development Setup
6
+
7
+ ### Prerequisites
8
+
9
+ - Node.js >= 18.0.0
10
+ - npm (recommended) or npm/yarn
11
+ - Git
12
+
13
+ ### Initial Setup
14
+
15
+ 1. **Fork and Clone**
16
+
17
+ ```bash
18
+ git clone https://github.com/simpli-fyi/electron-pinia-sync.git
19
+ cd electron-pinia-sync
20
+ ```
21
+
22
+ 2. **Install Dependencies**
23
+
24
+ ```bash
25
+ npm install
26
+ ```
27
+
28
+ 3. **Build the Project**
29
+
30
+ ```bash
31
+ npm run build
32
+ ```
33
+
34
+ ## Project Structure
35
+
36
+ ```
37
+ electron-pinia-sync/
38
+ ├── src/
39
+ │ ├── main/ # Main process code
40
+ │ │ └── index.ts # MainSync class and exports
41
+ │ ├── renderer/ # Renderer process code
42
+ │ │ └── index.ts # Pinia plugin for renderer
43
+ │ ├── preload/ # Preload script
44
+ │ │ └── index.ts # contextBridge setup
45
+ │ ├── __tests__/ # Unit tests
46
+ │ │ ├── main.test.ts
47
+ │ │ └── renderer.test.ts
48
+ │ └── types.ts # Shared TypeScript types
49
+ ├── examples/ # Example applications
50
+ ├── dist/ # Build output (generated)
51
+ └── package.json
52
+ ```
53
+
54
+ ## Development Workflow
55
+
56
+ ### Building
57
+
58
+ Build all modules:
59
+
60
+ ```bash
61
+ npm run build
62
+ ```
63
+
64
+ Build specific modules:
65
+
66
+ ```bash
67
+ npm run build:main
68
+ npm run build:renderer
69
+ npm run build:preload
70
+ ```
71
+
72
+ Watch mode for development:
73
+
74
+ ```bash
75
+ npm run dev
76
+ ```
77
+
78
+ ### Testing
79
+
80
+ Run all tests:
81
+
82
+ ```bash
83
+ npm test
84
+ ```
85
+
86
+ Watch mode:
87
+
88
+ ```bash
89
+ npm test:watch
90
+ ```
91
+
92
+ Coverage report:
93
+
94
+ ```bash
95
+ npm test:coverage
96
+ ```
97
+
98
+ ### Code Quality
99
+
100
+ Type checking:
101
+
102
+ ```bash
103
+ npm run typecheck
104
+ ```
105
+
106
+ Linting:
107
+
108
+ ```bash
109
+ npm run lint
110
+ ```
111
+
112
+ Auto-fix linting issues:
113
+
114
+ ```bash
115
+ npm run lint:fix
116
+ ```
117
+
118
+ ### Clean Build
119
+
120
+ Remove build artifacts:
121
+
122
+ ```bash
123
+ npm run clean
124
+ ```
125
+
126
+ ## Testing Guidelines
127
+
128
+ ### Writing Tests
129
+
130
+ - Place tests in `src/__tests__/`
131
+ - Use descriptive test names
132
+ - Follow the Arrange-Act-Assert pattern
133
+ - Mock Electron APIs appropriately
134
+
135
+ Example:
136
+
137
+ ```typescript
138
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
139
+
140
+ describe('MainSync', () => {
141
+ beforeEach(() => {
142
+ // Setup
143
+ });
144
+
145
+ it('should register a store with persistence', () => {
146
+ // Arrange
147
+ const store = createTestStore();
148
+
149
+ // Act
150
+ mainSync.registerStore('test', store, { persist: true });
151
+
152
+ // Assert
153
+ expect(store.$state).toBeDefined();
154
+ });
155
+ });
156
+ ```
157
+
158
+ ### Mock Strategy
159
+
160
+ For Electron modules:
161
+
162
+ ```typescript
163
+ vi.mock('electron', () => ({
164
+ ipcMain: {
165
+ handle: vi.fn(),
166
+ removeHandler: vi.fn(),
167
+ },
168
+ BrowserWindow: {
169
+ getAllWindows: vi.fn(() => []),
170
+ },
171
+ }));
172
+ ```
173
+
174
+ ## Code Style
175
+
176
+ ### TypeScript
177
+
178
+ - Use strict mode
179
+ - Prefer interfaces over types for object shapes
180
+ - Export types that users might need
181
+ - Document public APIs with JSDoc comments
182
+
183
+ Example:
184
+
185
+ ```typescript
186
+ /**
187
+ * Creates and initializes the Main process sync manager
188
+ *
189
+ * @param options - Configuration options
190
+ * @returns MainSync instance
191
+ */
192
+ export function createMainSync(options?: MainSyncOptions): MainSync {
193
+ return new MainSync(options);
194
+ }
195
+ ```
196
+
197
+ ### Naming Conventions
198
+
199
+ - **Files**: kebab-case (`main-sync.ts`)
200
+ - **Classes**: PascalCase (`MainSync`)
201
+ - **Functions**: camelCase (`createMainSync`)
202
+ - **Constants**: UPPER_SNAKE_CASE (`IPC_CHANNELS`)
203
+ - **Interfaces**: PascalCase with descriptive names (`MainSyncOptions`)
204
+
205
+ ### Comments
206
+
207
+ - Use JSDoc for public APIs
208
+ - Add inline comments for complex logic
209
+ - Keep comments up-to-date with code changes
210
+
211
+ ## Pull Request Process
212
+
213
+ ### Before Submitting
214
+
215
+ 1. **Create a feature branch**
216
+
217
+ ```bash
218
+ git checkout -b feature/your-feature-name
219
+ ```
220
+
221
+ 2. **Make your changes**
222
+ - Write code
223
+ - Add/update tests
224
+ - Update documentation
225
+
226
+ 3. **Run quality checks**
227
+
228
+ ```bash
229
+ npm run typecheck
230
+ npm run lint
231
+ npm test
232
+ ```
233
+
234
+ 4. **Build the project**
235
+
236
+ ```bash
237
+ npm run build
238
+ ```
239
+
240
+ ### PR Guidelines
241
+
242
+ 1. **Title**: Use a clear, descriptive title
243
+ - ✅ `feat: Add support for encrypted storage`
244
+ - ❌ `Update code`
245
+
246
+ 2. **Description**: Include:
247
+ - What changes were made
248
+ - Why they were made
249
+ - Any breaking changes
250
+ - Related issue numbers
251
+
252
+ 3. **Commits**:
253
+ - Use conventional commits format
254
+ - Keep commits focused and atomic
255
+
256
+ Conventional commit format:
257
+
258
+ ```
259
+ type(scope): description
260
+
261
+ [optional body]
262
+
263
+ [optional footer]
264
+ ```
265
+
266
+ Types:
267
+ - `feat`: New feature
268
+ - `fix`: Bug fix
269
+ - `docs`: Documentation only
270
+ - `style`: Code style changes (formatting, etc.)
271
+ - `refactor`: Code refactoring
272
+ - `test`: Adding or updating tests
273
+ - `chore`: Maintenance tasks
274
+
275
+ Examples:
276
+
277
+ ```
278
+ feat(main): add encryption support for persisted stores
279
+
280
+ fix(renderer): prevent race condition during initialization
281
+
282
+ docs(readme): add troubleshooting section
283
+ ```
284
+
285
+ ### Review Process
286
+
287
+ 1. All tests must pass
288
+ 2. Code coverage should not decrease
289
+ 3. At least one maintainer approval required
290
+ 4. All review comments addressed
291
+
292
+ ## Adding Examples
293
+
294
+ Examples help users understand how to use the library:
295
+
296
+ 1. Create a new directory in `examples/`
297
+ 2. Include a complete, working Electron app
298
+ 3. Add a README.md explaining the example
299
+ 4. Keep it focused on one concept
300
+
301
+ Example structure:
302
+
303
+ ```
304
+ examples/
305
+ └── basic-counter/
306
+ ├── src/
307
+ │ ├── main.ts
308
+ │ ├── preload.ts
309
+ │ └── renderer.ts
310
+ ├── package.json
311
+ └── README.md
312
+ ```
313
+
314
+ ## Documentation
315
+
316
+ ### Updating README
317
+
318
+ When adding features:
319
+
320
+ 1. Update the relevant section in README.md
321
+ 2. Add code examples
322
+ 3. Update the API reference if applicable
323
+
324
+ ### JSDoc Comments
325
+
326
+ All public APIs should have JSDoc comments:
327
+
328
+ ```typescript
329
+ /**
330
+ * Register a store with the sync manager
331
+ *
332
+ * @param storeId - Unique identifier for the store
333
+ * @param store - Pinia store instance
334
+ * @param options - Configuration options
335
+ * @param options.persist - Persistence settings
336
+ *
337
+ * @example
338
+ * ```typescript
339
+ * mainSync.registerStore('counter', counterStore, {
340
+ * persist: true
341
+ * });
342
+ * ```
343
+ */
344
+ public registerStore(
345
+ storeId: string,
346
+ store: Store,
347
+ options: { persist?: boolean | PersistOptions } = {}
348
+ ): void {
349
+ // Implementation
350
+ }
351
+ ```
352
+
353
+ ## Release Process
354
+
355
+ (For maintainers)
356
+
357
+ 1. Update version in `package.json`
358
+ 2. Update CHANGELOG.md
359
+ 3. Create a git tag
360
+ 4. Push to GitHub
361
+ 5. Publish to npm
362
+
363
+ ```bash
364
+ npm version patch|minor|major
365
+ git push --follow-tags
366
+ npm publish
367
+ ```
368
+
369
+ ## Getting Help
370
+
371
+ - **Issues**: Open an issue for bugs or feature requests
372
+ - **Discussions**: Use GitHub Discussions for questions
373
+ - **Discord**: Join our community server (link in README)
374
+
375
+ ## Code of Conduct
376
+
377
+ ### Our Pledge
378
+
379
+ We are committed to providing a welcoming and inclusive experience for everyone.
380
+
381
+ ### Standards
382
+
383
+ - Be respectful and considerate
384
+ - Welcome newcomers
385
+ - Accept constructive criticism
386
+ - Focus on what's best for the community
387
+
388
+ ### Enforcement
389
+
390
+ Unacceptable behavior may result in temporary or permanent ban from the project.
391
+
392
+ ## License
393
+
394
+ By contributing, you agree that your contributions will be licensed under the MIT License.
395
+
396
+ ## Questions?
397
+
398
+ Feel free to reach out:
399
+
400
+ - Open an issue
401
+ - Start a discussion
402
+ - Email: [your-email@example.com]
403
+
404
+ Thank you for contributing! 🎉
405
+
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 simpli.fyi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.