@legendapp/state 3.0.0-alpha.26 → 3.0.0-alpha.27
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/index.js +20 -17
- package/index.mjs +20 -17
- package/package.json +1 -1
- package/sync-plugins/supabase.d.mts +11 -6
- package/sync-plugins/supabase.d.ts +11 -6
- package/sync-plugins/supabase.js +5 -3
- package/sync-plugins/supabase.mjs +5 -3
- package/sync.js +1 -5
- package/sync.mjs +1 -5
package/index.js
CHANGED
|
@@ -1908,14 +1908,15 @@ function activateNodeFunction(node, lazyFn) {
|
|
|
1908
1908
|
}
|
|
1909
1909
|
let value = activateFn();
|
|
1910
1910
|
let didSetToObs = false;
|
|
1911
|
-
|
|
1912
|
-
|
|
1911
|
+
const isObs = isObservable(value);
|
|
1912
|
+
if (isObs || node.linkedToNode) {
|
|
1913
|
+
didSetToObs = isObs;
|
|
1913
1914
|
value = setToObservable(node, value);
|
|
1914
1915
|
}
|
|
1915
1916
|
if (isFunction(value) && value.length === 0) {
|
|
1916
1917
|
value = value();
|
|
1917
1918
|
}
|
|
1918
|
-
const activated = !
|
|
1919
|
+
const activated = !isObs ? value == null ? void 0 : value[symbolLinked] : void 0;
|
|
1919
1920
|
if (activated) {
|
|
1920
1921
|
node.activationState = activated;
|
|
1921
1922
|
value = void 0;
|
|
@@ -2081,23 +2082,25 @@ function activateNodeBase(node, value) {
|
|
|
2081
2082
|
}
|
|
2082
2083
|
function setToObservable(node, value) {
|
|
2083
2084
|
var _a;
|
|
2084
|
-
const linkedNode = getNode(value);
|
|
2085
|
+
const linkedNode = value ? getNode(value) : void 0;
|
|
2085
2086
|
if (linkedNode !== node && (linkedNode == null ? void 0 : linkedNode.linkedToNode) !== node) {
|
|
2086
2087
|
node.linkedToNode = linkedNode;
|
|
2087
|
-
linkedNode.linkedFromNodes || (linkedNode.linkedFromNodes = /* @__PURE__ */ new Set());
|
|
2088
|
-
linkedNode.linkedFromNodes.add(node);
|
|
2089
2088
|
(_a = node.linkedToNodeDispose) == null ? void 0 : _a.call(node);
|
|
2090
|
-
|
|
2091
|
-
linkedNode
|
|
2092
|
-
()
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2089
|
+
if (linkedNode) {
|
|
2090
|
+
linkedNode.linkedFromNodes || (linkedNode.linkedFromNodes = /* @__PURE__ */ new Set());
|
|
2091
|
+
linkedNode.linkedFromNodes.add(node);
|
|
2092
|
+
node.linkedToNodeDispose = onChange(
|
|
2093
|
+
linkedNode,
|
|
2094
|
+
() => {
|
|
2095
|
+
value = peekInternal(linkedNode);
|
|
2096
|
+
if (!isFunction(value)) {
|
|
2097
|
+
set(node, value);
|
|
2098
|
+
}
|
|
2099
|
+
},
|
|
2100
|
+
{ initial: true },
|
|
2101
|
+
/* @__PURE__ */ new Set([node])
|
|
2102
|
+
);
|
|
2103
|
+
}
|
|
2101
2104
|
}
|
|
2102
2105
|
return value;
|
|
2103
2106
|
}
|
package/index.mjs
CHANGED
|
@@ -1906,14 +1906,15 @@ function activateNodeFunction(node, lazyFn) {
|
|
|
1906
1906
|
}
|
|
1907
1907
|
let value = activateFn();
|
|
1908
1908
|
let didSetToObs = false;
|
|
1909
|
-
|
|
1910
|
-
|
|
1909
|
+
const isObs = isObservable(value);
|
|
1910
|
+
if (isObs || node.linkedToNode) {
|
|
1911
|
+
didSetToObs = isObs;
|
|
1911
1912
|
value = setToObservable(node, value);
|
|
1912
1913
|
}
|
|
1913
1914
|
if (isFunction(value) && value.length === 0) {
|
|
1914
1915
|
value = value();
|
|
1915
1916
|
}
|
|
1916
|
-
const activated = !
|
|
1917
|
+
const activated = !isObs ? value == null ? void 0 : value[symbolLinked] : void 0;
|
|
1917
1918
|
if (activated) {
|
|
1918
1919
|
node.activationState = activated;
|
|
1919
1920
|
value = void 0;
|
|
@@ -2079,23 +2080,25 @@ function activateNodeBase(node, value) {
|
|
|
2079
2080
|
}
|
|
2080
2081
|
function setToObservable(node, value) {
|
|
2081
2082
|
var _a;
|
|
2082
|
-
const linkedNode = getNode(value);
|
|
2083
|
+
const linkedNode = value ? getNode(value) : void 0;
|
|
2083
2084
|
if (linkedNode !== node && (linkedNode == null ? void 0 : linkedNode.linkedToNode) !== node) {
|
|
2084
2085
|
node.linkedToNode = linkedNode;
|
|
2085
|
-
linkedNode.linkedFromNodes || (linkedNode.linkedFromNodes = /* @__PURE__ */ new Set());
|
|
2086
|
-
linkedNode.linkedFromNodes.add(node);
|
|
2087
2086
|
(_a = node.linkedToNodeDispose) == null ? void 0 : _a.call(node);
|
|
2088
|
-
|
|
2089
|
-
linkedNode
|
|
2090
|
-
()
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2087
|
+
if (linkedNode) {
|
|
2088
|
+
linkedNode.linkedFromNodes || (linkedNode.linkedFromNodes = /* @__PURE__ */ new Set());
|
|
2089
|
+
linkedNode.linkedFromNodes.add(node);
|
|
2090
|
+
node.linkedToNodeDispose = onChange(
|
|
2091
|
+
linkedNode,
|
|
2092
|
+
() => {
|
|
2093
|
+
value = peekInternal(linkedNode);
|
|
2094
|
+
if (!isFunction(value)) {
|
|
2095
|
+
set(node, value);
|
|
2096
|
+
}
|
|
2097
|
+
},
|
|
2098
|
+
{ initial: true },
|
|
2099
|
+
/* @__PURE__ */ new Set([node])
|
|
2100
|
+
);
|
|
2101
|
+
}
|
|
2099
2102
|
}
|
|
2100
2103
|
return value;
|
|
2101
2104
|
}
|
package/package.json
CHANGED
|
@@ -4,10 +4,14 @@ import { SyncedCrudPropsBase, CrudAsOption, SyncedCrudReturnType, SyncedCrudProp
|
|
|
4
4
|
import { PostgrestQueryBuilder, PostgrestFilterBuilder } from '@supabase/postgrest-js';
|
|
5
5
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
6
6
|
|
|
7
|
+
type DatabaseOf<Client extends SupabaseClient> = Client extends SupabaseClient<infer TDB> ? TDB : never;
|
|
8
|
+
type SchemaNameOf<Client extends SupabaseClient> = keyof DatabaseOf<Client>;
|
|
9
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
10
|
+
type IsUnionOfStrings<T> = [T] extends [string] ? ([T] extends [UnionToIntersection<T>] ? false : true) : false;
|
|
7
11
|
type SupabaseSchemaOf<Client extends SupabaseClient> = Client extends SupabaseClient<infer _, infer __, infer Schema> ? Schema : never;
|
|
8
|
-
type SupabaseTableOf<Client extends SupabaseClient
|
|
9
|
-
type SupabaseCollectionOf<Client extends SupabaseClient
|
|
10
|
-
type SupabaseRowOf<Client extends SupabaseClient, Collection extends SupabaseCollectionOf<Client>> = SupabaseTableOf<Client>[Collection]['Row'];
|
|
12
|
+
type SupabaseTableOf<Client extends SupabaseClient, SchemaName extends SchemaNameOf<Client>> = DatabaseOf<Client>[SchemaName]['Tables'];
|
|
13
|
+
type SupabaseCollectionOf<Client extends SupabaseClient, SchemaName extends SchemaNameOf<Client>> = keyof SupabaseTableOf<Client, IsUnionOfStrings<SchemaName> extends true ? 'public' : SchemaName>;
|
|
14
|
+
type SupabaseRowOf<Client extends SupabaseClient, Collection extends SupabaseCollectionOf<Client, SchemaName>, SchemaName extends SchemaNameOf<Client>> = SupabaseTableOf<Client, SchemaName>[Collection]['Row'];
|
|
11
15
|
type SyncedSupabaseConfig<TRemote extends {
|
|
12
16
|
id: string | number;
|
|
13
17
|
}, TLocal> = Omit<SyncedCrudPropsBase<TRemote, TLocal>, 'create' | 'update' | 'delete'>;
|
|
@@ -20,10 +24,11 @@ interface SyncedSupabaseConfiguration extends Omit<SyncedSupabaseConfig<{
|
|
|
20
24
|
enabled?: Observable<boolean>;
|
|
21
25
|
as?: Exclude<CrudAsOption, 'value'>;
|
|
22
26
|
}
|
|
23
|
-
interface SyncedSupabaseProps<Client extends SupabaseClient, Collection extends SupabaseCollectionOf<Client>, TOption extends CrudAsOption = 'object', TRemote extends SupabaseRowOf<Client, Collection> = SupabaseRowOf<Client, Collection>, TLocal = TRemote> extends SyncedSupabaseConfig<TRemote, TLocal>, SyncedCrudPropsMany<TRemote, TRemote, TOption> {
|
|
27
|
+
interface SyncedSupabaseProps<Client extends SupabaseClient<any, any>, Collection extends SupabaseCollectionOf<Client, SchemaName>, SchemaName extends SchemaNameOf<Client>, TOption extends CrudAsOption = 'object', TRemote extends SupabaseRowOf<Client, Collection, SchemaName> = SupabaseRowOf<Client, Collection, SchemaName>, TLocal = TRemote> extends SyncedSupabaseConfig<TRemote, TLocal>, SyncedCrudPropsMany<TRemote, TRemote, TOption> {
|
|
24
28
|
supabase: Client;
|
|
25
29
|
collection: Collection;
|
|
26
|
-
|
|
30
|
+
schema?: SchemaName;
|
|
31
|
+
select?: (query: PostgrestQueryBuilder<SupabaseSchemaOf<Client>, SupabaseTableOf<Client, SchemaName>[Collection], Collection>) => PostgrestFilterBuilder<SupabaseSchemaOf<Client>, TRemote, TRemote[], Collection, []>;
|
|
27
32
|
filter?: (select: PostgrestFilterBuilder<SupabaseSchemaOf<Client>, TRemote, TRemote[], Collection, []>, params: SyncedGetParams<TRemote>) => PostgrestFilterBuilder<SupabaseSchemaOf<Client>, TRemote, TRemote[], Collection, []>;
|
|
28
33
|
actions?: ('create' | 'read' | 'update' | 'delete')[];
|
|
29
34
|
realtime?: boolean | {
|
|
@@ -34,6 +39,6 @@ interface SyncedSupabaseProps<Client extends SupabaseClient, Collection extends
|
|
|
34
39
|
}
|
|
35
40
|
declare function getSyncedSupabaseConfiguration(): SyncedSupabaseConfiguration;
|
|
36
41
|
declare function configureSyncedSupabase(config: SyncedSupabaseConfiguration): void;
|
|
37
|
-
declare function syncedSupabase<Client extends SupabaseClient, Collection extends SupabaseCollectionOf<Client> & string, AsOption extends CrudAsOption = 'object', TRemote extends SupabaseRowOf<Client, Collection> = SupabaseRowOf<Client, Collection>, TLocal = TRemote>(props: SyncedSupabaseProps<Client, Collection, AsOption, TRemote, TLocal>): SyncedCrudReturnType<TLocal, AsOption>;
|
|
42
|
+
declare function syncedSupabase<Client extends SupabaseClient<any, any>, Collection extends SupabaseCollectionOf<Client, SchemaName> & string, SchemaName extends SchemaNameOf<Client>, AsOption extends CrudAsOption = 'object', TRemote extends SupabaseRowOf<Client, Collection, SchemaName> = SupabaseRowOf<Client, Collection, SchemaName>, TLocal = TRemote>(props: SyncedSupabaseProps<Client, Collection, SchemaName, AsOption, TRemote, TLocal>): SyncedCrudReturnType<TLocal, AsOption>;
|
|
38
43
|
|
|
39
44
|
export { type SupabaseCollectionOf, type SupabaseRowOf, type SupabaseSchemaOf, type SupabaseTableOf, type SyncedSupabaseConfig, type SyncedSupabaseConfiguration, configureSyncedSupabase, getSyncedSupabaseConfiguration, syncedSupabase };
|
|
@@ -4,10 +4,14 @@ import { SyncedCrudPropsBase, CrudAsOption, SyncedCrudReturnType, SyncedCrudProp
|
|
|
4
4
|
import { PostgrestQueryBuilder, PostgrestFilterBuilder } from '@supabase/postgrest-js';
|
|
5
5
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
6
6
|
|
|
7
|
+
type DatabaseOf<Client extends SupabaseClient> = Client extends SupabaseClient<infer TDB> ? TDB : never;
|
|
8
|
+
type SchemaNameOf<Client extends SupabaseClient> = keyof DatabaseOf<Client>;
|
|
9
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
10
|
+
type IsUnionOfStrings<T> = [T] extends [string] ? ([T] extends [UnionToIntersection<T>] ? false : true) : false;
|
|
7
11
|
type SupabaseSchemaOf<Client extends SupabaseClient> = Client extends SupabaseClient<infer _, infer __, infer Schema> ? Schema : never;
|
|
8
|
-
type SupabaseTableOf<Client extends SupabaseClient
|
|
9
|
-
type SupabaseCollectionOf<Client extends SupabaseClient
|
|
10
|
-
type SupabaseRowOf<Client extends SupabaseClient, Collection extends SupabaseCollectionOf<Client>> = SupabaseTableOf<Client>[Collection]['Row'];
|
|
12
|
+
type SupabaseTableOf<Client extends SupabaseClient, SchemaName extends SchemaNameOf<Client>> = DatabaseOf<Client>[SchemaName]['Tables'];
|
|
13
|
+
type SupabaseCollectionOf<Client extends SupabaseClient, SchemaName extends SchemaNameOf<Client>> = keyof SupabaseTableOf<Client, IsUnionOfStrings<SchemaName> extends true ? 'public' : SchemaName>;
|
|
14
|
+
type SupabaseRowOf<Client extends SupabaseClient, Collection extends SupabaseCollectionOf<Client, SchemaName>, SchemaName extends SchemaNameOf<Client>> = SupabaseTableOf<Client, SchemaName>[Collection]['Row'];
|
|
11
15
|
type SyncedSupabaseConfig<TRemote extends {
|
|
12
16
|
id: string | number;
|
|
13
17
|
}, TLocal> = Omit<SyncedCrudPropsBase<TRemote, TLocal>, 'create' | 'update' | 'delete'>;
|
|
@@ -20,10 +24,11 @@ interface SyncedSupabaseConfiguration extends Omit<SyncedSupabaseConfig<{
|
|
|
20
24
|
enabled?: Observable<boolean>;
|
|
21
25
|
as?: Exclude<CrudAsOption, 'value'>;
|
|
22
26
|
}
|
|
23
|
-
interface SyncedSupabaseProps<Client extends SupabaseClient, Collection extends SupabaseCollectionOf<Client>, TOption extends CrudAsOption = 'object', TRemote extends SupabaseRowOf<Client, Collection> = SupabaseRowOf<Client, Collection>, TLocal = TRemote> extends SyncedSupabaseConfig<TRemote, TLocal>, SyncedCrudPropsMany<TRemote, TRemote, TOption> {
|
|
27
|
+
interface SyncedSupabaseProps<Client extends SupabaseClient<any, any>, Collection extends SupabaseCollectionOf<Client, SchemaName>, SchemaName extends SchemaNameOf<Client>, TOption extends CrudAsOption = 'object', TRemote extends SupabaseRowOf<Client, Collection, SchemaName> = SupabaseRowOf<Client, Collection, SchemaName>, TLocal = TRemote> extends SyncedSupabaseConfig<TRemote, TLocal>, SyncedCrudPropsMany<TRemote, TRemote, TOption> {
|
|
24
28
|
supabase: Client;
|
|
25
29
|
collection: Collection;
|
|
26
|
-
|
|
30
|
+
schema?: SchemaName;
|
|
31
|
+
select?: (query: PostgrestQueryBuilder<SupabaseSchemaOf<Client>, SupabaseTableOf<Client, SchemaName>[Collection], Collection>) => PostgrestFilterBuilder<SupabaseSchemaOf<Client>, TRemote, TRemote[], Collection, []>;
|
|
27
32
|
filter?: (select: PostgrestFilterBuilder<SupabaseSchemaOf<Client>, TRemote, TRemote[], Collection, []>, params: SyncedGetParams<TRemote>) => PostgrestFilterBuilder<SupabaseSchemaOf<Client>, TRemote, TRemote[], Collection, []>;
|
|
28
33
|
actions?: ('create' | 'read' | 'update' | 'delete')[];
|
|
29
34
|
realtime?: boolean | {
|
|
@@ -34,6 +39,6 @@ interface SyncedSupabaseProps<Client extends SupabaseClient, Collection extends
|
|
|
34
39
|
}
|
|
35
40
|
declare function getSyncedSupabaseConfiguration(): SyncedSupabaseConfiguration;
|
|
36
41
|
declare function configureSyncedSupabase(config: SyncedSupabaseConfiguration): void;
|
|
37
|
-
declare function syncedSupabase<Client extends SupabaseClient, Collection extends SupabaseCollectionOf<Client> & string, AsOption extends CrudAsOption = 'object', TRemote extends SupabaseRowOf<Client, Collection> = SupabaseRowOf<Client, Collection>, TLocal = TRemote>(props: SyncedSupabaseProps<Client, Collection, AsOption, TRemote, TLocal>): SyncedCrudReturnType<TLocal, AsOption>;
|
|
42
|
+
declare function syncedSupabase<Client extends SupabaseClient<any, any>, Collection extends SupabaseCollectionOf<Client, SchemaName> & string, SchemaName extends SchemaNameOf<Client>, AsOption extends CrudAsOption = 'object', TRemote extends SupabaseRowOf<Client, Collection, SchemaName> = SupabaseRowOf<Client, Collection, SchemaName>, TLocal = TRemote>(props: SyncedSupabaseProps<Client, Collection, SchemaName, AsOption, TRemote, TLocal>): SyncedCrudReturnType<TLocal, AsOption>;
|
|
38
43
|
|
|
39
44
|
export { type SupabaseCollectionOf, type SupabaseRowOf, type SupabaseSchemaOf, type SupabaseTableOf, type SyncedSupabaseConfig, type SyncedSupabaseConfiguration, configureSyncedSupabase, getSyncedSupabaseConfiguration, syncedSupabase };
|
package/sync-plugins/supabase.js
CHANGED
|
@@ -24,6 +24,7 @@ function syncedSupabase(props) {
|
|
|
24
24
|
supabase: client,
|
|
25
25
|
collection,
|
|
26
26
|
select: selectFn,
|
|
27
|
+
schema,
|
|
27
28
|
filter,
|
|
28
29
|
actions,
|
|
29
30
|
fieldCreatedAt: fieldCreatedAtParam,
|
|
@@ -44,7 +45,8 @@ function syncedSupabase(props) {
|
|
|
44
45
|
const fieldDeleted = fieldDeletedParam || (changesSince === "last-sync" ? "deleted" : void 0);
|
|
45
46
|
const list = !actions || actions.includes("read") ? async (params) => {
|
|
46
47
|
const { lastSync } = params;
|
|
47
|
-
const
|
|
48
|
+
const clientSchema = schema ? client.schema(schema) : client;
|
|
49
|
+
const from = clientSchema.from(collection);
|
|
48
50
|
let select = selectFn ? selectFn(from) : from.select();
|
|
49
51
|
if (changesSince === "last-sync" && lastSync) {
|
|
50
52
|
const date = new Date(lastSync).toISOString();
|
|
@@ -91,13 +93,13 @@ function syncedSupabase(props) {
|
|
|
91
93
|
}
|
|
92
94
|
} : void 0;
|
|
93
95
|
const subscribe = realtime ? ({ node, value$, update: update2 }) => {
|
|
94
|
-
const { filter: filter2, schema } = state.isObject(realtime) ? realtime : {};
|
|
96
|
+
const { filter: filter2, schema: schema2 } = state.isObject(realtime) ? realtime : {};
|
|
95
97
|
const channel = client.channel(`LS_${node.key || ""}${channelNum++}`).on(
|
|
96
98
|
"postgres_changes",
|
|
97
99
|
{
|
|
98
100
|
event: "*",
|
|
99
101
|
table: collection,
|
|
100
|
-
schema:
|
|
102
|
+
schema: schema2 || "public",
|
|
101
103
|
filter: filter2 || void 0
|
|
102
104
|
},
|
|
103
105
|
(payload) => {
|
|
@@ -22,6 +22,7 @@ function syncedSupabase(props) {
|
|
|
22
22
|
supabase: client,
|
|
23
23
|
collection,
|
|
24
24
|
select: selectFn,
|
|
25
|
+
schema,
|
|
25
26
|
filter,
|
|
26
27
|
actions,
|
|
27
28
|
fieldCreatedAt: fieldCreatedAtParam,
|
|
@@ -42,7 +43,8 @@ function syncedSupabase(props) {
|
|
|
42
43
|
const fieldDeleted = fieldDeletedParam || (changesSince === "last-sync" ? "deleted" : void 0);
|
|
43
44
|
const list = !actions || actions.includes("read") ? async (params) => {
|
|
44
45
|
const { lastSync } = params;
|
|
45
|
-
const
|
|
46
|
+
const clientSchema = schema ? client.schema(schema) : client;
|
|
47
|
+
const from = clientSchema.from(collection);
|
|
46
48
|
let select = selectFn ? selectFn(from) : from.select();
|
|
47
49
|
if (changesSince === "last-sync" && lastSync) {
|
|
48
50
|
const date = new Date(lastSync).toISOString();
|
|
@@ -89,13 +91,13 @@ function syncedSupabase(props) {
|
|
|
89
91
|
}
|
|
90
92
|
} : void 0;
|
|
91
93
|
const subscribe = realtime ? ({ node, value$, update: update2 }) => {
|
|
92
|
-
const { filter: filter2, schema } = isObject(realtime) ? realtime : {};
|
|
94
|
+
const { filter: filter2, schema: schema2 } = isObject(realtime) ? realtime : {};
|
|
93
95
|
const channel = client.channel(`LS_${node.key || ""}${channelNum++}`).on(
|
|
94
96
|
"postgres_changes",
|
|
95
97
|
{
|
|
96
98
|
event: "*",
|
|
97
99
|
table: collection,
|
|
98
|
-
schema:
|
|
100
|
+
schema: schema2 || "public",
|
|
99
101
|
filter: filter2 || void 0
|
|
100
102
|
},
|
|
101
103
|
(payload) => {
|
package/sync.js
CHANGED
|
@@ -241,12 +241,11 @@ function mergeChanges(changes) {
|
|
|
241
241
|
function mergeQueuedChanges(allChanges) {
|
|
242
242
|
const changesByOptionsRemote = /* @__PURE__ */ new Map();
|
|
243
243
|
const changesByOptionsLocal = /* @__PURE__ */ new Map();
|
|
244
|
-
const previousByOptions = /* @__PURE__ */ new Map();
|
|
245
244
|
const outRemote = /* @__PURE__ */ new Map();
|
|
246
245
|
const outLocal = /* @__PURE__ */ new Map();
|
|
247
246
|
for (let i = 0; i < allChanges.length; i++) {
|
|
248
247
|
const value = allChanges[i];
|
|
249
|
-
const { changes, inRemoteChange,
|
|
248
|
+
const { changes, inRemoteChange, syncOptions } = value;
|
|
250
249
|
const targetMap = inRemoteChange ? outRemote : outLocal;
|
|
251
250
|
const changesMap = inRemoteChange ? changesByOptionsRemote : changesByOptionsLocal;
|
|
252
251
|
const existing = changesMap.get(syncOptions);
|
|
@@ -254,9 +253,6 @@ function mergeQueuedChanges(allChanges) {
|
|
|
254
253
|
const merged = mergeChanges(newChanges);
|
|
255
254
|
changesMap.set(syncOptions, merged);
|
|
256
255
|
value.changes = merged;
|
|
257
|
-
if (!previousByOptions.has(syncOptions)) {
|
|
258
|
-
previousByOptions.set(syncOptions, getPrevious());
|
|
259
|
-
}
|
|
260
256
|
targetMap.set(syncOptions, value);
|
|
261
257
|
}
|
|
262
258
|
return Array.from(outRemote.values()).concat(Array.from(outLocal.values()));
|
package/sync.mjs
CHANGED
|
@@ -239,12 +239,11 @@ function mergeChanges(changes) {
|
|
|
239
239
|
function mergeQueuedChanges(allChanges) {
|
|
240
240
|
const changesByOptionsRemote = /* @__PURE__ */ new Map();
|
|
241
241
|
const changesByOptionsLocal = /* @__PURE__ */ new Map();
|
|
242
|
-
const previousByOptions = /* @__PURE__ */ new Map();
|
|
243
242
|
const outRemote = /* @__PURE__ */ new Map();
|
|
244
243
|
const outLocal = /* @__PURE__ */ new Map();
|
|
245
244
|
for (let i = 0; i < allChanges.length; i++) {
|
|
246
245
|
const value = allChanges[i];
|
|
247
|
-
const { changes, inRemoteChange,
|
|
246
|
+
const { changes, inRemoteChange, syncOptions } = value;
|
|
248
247
|
const targetMap = inRemoteChange ? outRemote : outLocal;
|
|
249
248
|
const changesMap = inRemoteChange ? changesByOptionsRemote : changesByOptionsLocal;
|
|
250
249
|
const existing = changesMap.get(syncOptions);
|
|
@@ -252,9 +251,6 @@ function mergeQueuedChanges(allChanges) {
|
|
|
252
251
|
const merged = mergeChanges(newChanges);
|
|
253
252
|
changesMap.set(syncOptions, merged);
|
|
254
253
|
value.changes = merged;
|
|
255
|
-
if (!previousByOptions.has(syncOptions)) {
|
|
256
|
-
previousByOptions.set(syncOptions, getPrevious());
|
|
257
|
-
}
|
|
258
254
|
targetMap.set(syncOptions, value);
|
|
259
255
|
}
|
|
260
256
|
return Array.from(outRemote.values()).concat(Array.from(outLocal.values()));
|