@anfenn/dync 1.0.22 → 1.0.24

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/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  SqliteQueryContext,
7
7
  SyncAction,
8
8
  createLocalId
9
- } from "./chunk-YSKDP34Q.js";
9
+ } from "./chunk-QA2TX54K.js";
10
10
  import "./chunk-SQB6E7V2.js";
11
11
  export {
12
12
  Dync,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Dync
3
- } from "../chunk-YSKDP34Q.js";
3
+ } from "../chunk-QA2TX54K.js";
4
4
  import "../chunk-SQB6E7V2.js";
5
5
 
6
6
  // src/react/useDync.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anfenn/dync",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
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": [
@@ -132,10 +132,28 @@ const buildCondition = (condition: SQLiteCondition): BuiltCondition => {
132
132
  };
133
133
 
134
134
  export const cloneValue = <T>(value: T): T => {
135
+ // Fast path for null/undefined/primitives
136
+ if (value == null || typeof value !== 'object') return value;
137
+
138
+ // Fast path for flat objects (common case for SQLite records)
139
+ if (!Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype) {
140
+ const obj = value as Record<string, unknown>;
141
+ let isFlat = true;
142
+ for (const key in obj) {
143
+ const v = obj[key];
144
+ if (v !== null && typeof v === 'object') {
145
+ isFlat = false;
146
+ break;
147
+ }
148
+ }
149
+ if (isFlat) return { ...obj } as T;
150
+ }
151
+
152
+ // Deep clone for arrays/nested objects
135
153
  if (typeof globalThis.structuredClone === 'function') {
136
154
  return globalThis.structuredClone(value);
137
155
  }
138
- return JSON.parse(JSON.stringify(value ?? null)) as T;
156
+ return JSON.parse(JSON.stringify(value)) as T;
139
157
  };
140
158
 
141
159
  export const quoteIdentifier = (name: string): string => `"${name.replace(/"/g, '""')}"`;