@anfenn/dync 1.1.0 → 1.1.3

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.
@@ -1,5 +1,5 @@
1
- import { a as SyncApi, k as SyncState } from '../types-DhCTdAep.cjs';
2
- import '../dexie-3VOQSn1s.cjs';
1
+ import { a as SyncApi, k as SyncState } from '../types-Di82FTAL.cjs';
2
+ import '../dexie-BRWUYM02.cjs';
3
3
  import 'dexie';
4
4
  import '../types-6-NyRQ0D.cjs';
5
5
 
@@ -1,5 +1,5 @@
1
- import { a as SyncApi, k as SyncState } from '../types-BIJhsSOf.js';
2
- import '../dexie-D85rTx4g.js';
1
+ import { a as SyncApi, k as SyncState } from '../types-DhlgTu1o.js';
2
+ import '../dexie-B3Ihrrxi.js';
3
3
  import 'dexie';
4
4
  import '../types-6-NyRQ0D.js';
5
5
 
@@ -1,4 +1,4 @@
1
- import { d as StorageAdapter, a as StorageTable } from './dexie-D85rTx4g.js';
1
+ import { d as StorageAdapter, a as StorageTable } from './dexie-B3Ihrrxi.js';
2
2
 
3
3
  type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
4
4
  interface Logger {
@@ -1,4 +1,4 @@
1
- import { d as StorageAdapter, a as StorageTable } from './dexie-3VOQSn1s.cjs';
1
+ import { d as StorageAdapter, a as StorageTable } from './dexie-BRWUYM02.cjs';
2
2
 
3
3
  type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
4
4
  interface Logger {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anfenn/dync",
3
- "version": "1.1.0",
3
+ "version": "1.1.3",
4
4
  "private": false,
5
5
  "description": "Write once, run IndexedDB & SQLite with sync anywhere - React, React Native, Expo, Capacitor, Electron & Node.js",
6
6
  "keywords": [
@@ -143,8 +143,10 @@
143
143
  "test:ci": "pnpm --filter tests test:ci",
144
144
  "test:browser:full": "pnpm --filter tests test:browser:full",
145
145
  "reinstall": "find . -name node_modules -type d -prune -exec rm -rf {} + && pnpm install",
146
- "push": "bash -c '[ -n \"$1\" ] && git add . && git commit -m \"$1\" && git push' --",
147
- "release": "bash -c '[ -n \"$1\" ] || { echo \"Usage: pnpm release <commit-message> [--no-patch]\"; exit 1; } && pnpm build:all && pnpm test:all && pnpm test:browser:full && git add . && git commit -m \"$1\" && { [ \"$2\" = \"--no-patch\" ] || npm version patch; } && git push && npm login && npm publish' --"
146
+ "smoke": "pnpm build:all && pnpm test",
147
+ "hascommits": "[ -n \"$(git log @{u}.. --oneline)\" ] || { echo \"No unpushed commits, aborting.\"; exit 1; }",
148
+ "prepush": "pnpm hascommits && pnpm build:all && pnpm test:all && pnpm test:browser:full",
149
+ "release": "bash -c 'pnpm prepush && { [ \"$1\" = \"--no-patch\" ] || npm version patch --no-tag --force; } && git push && npm login && npm publish' --"
148
150
  },
149
151
  "devDependencies": {
150
152
  "@capacitor-community/sqlite": "7.0.2",
@@ -203,8 +203,7 @@ export class SQLiteAdapter implements StorageAdapter {
203
203
  async query(statement: string, values?: any[]): Promise<SQLiteQueryResult>;
204
204
  async query<R>(arg1: string | ((ctx: SQLiteQueryContext) => Promise<R>), arg2?: any[]): Promise<R | SQLiteQueryResult> {
205
205
  if (typeof arg1 === 'function') {
206
- const driver = await this.getDriver();
207
- return arg1(new SQLiteQueryContext(driver, this));
206
+ return arg1(new SQLiteQueryContext(this));
208
207
  }
209
208
  const statement = arg1;
210
209
  const values = arg2;
@@ -1,28 +1,7 @@
1
- import type { StorageTable, StorageTransactionContext, TransactionMode } from '../types';
2
- import type { SQLiteDatabaseDriver, SQLiteRunResult } from './types';
3
1
  import { SQLiteAdapter } from './SQLiteAdapter';
4
2
 
5
3
  export class SQLiteQueryContext {
6
- constructor(
7
- private readonly driver: SQLiteDatabaseDriver,
8
- private readonly adapter: SQLiteAdapter,
9
- ) {}
10
-
11
- table<T = any>(name: string): StorageTable<T> {
12
- return this.adapter.table(name);
13
- }
14
-
15
- transaction<T>(mode: TransactionMode, tableNames: string[], callback: (context: StorageTransactionContext) => Promise<T>): Promise<T> {
16
- return this.adapter.transaction(mode, tableNames, callback);
17
- }
18
-
19
- async execute(statement: string): Promise<void> {
20
- return this.driver.execute(statement);
21
- }
22
-
23
- async run(statement: string, values?: any[]): Promise<SQLiteRunResult> {
24
- return this.driver.run(statement, values);
25
- }
4
+ constructor(private readonly adapter: SQLiteAdapter) {}
26
5
 
27
6
  async queryRows(statement: string, values?: any[]): Promise<Array<Record<string, any>>> {
28
7
  return this.adapter.queryRows(statement, values);