@legendapp/state 3.0.0-beta.37 → 3.0.0-beta.39

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 CHANGED
@@ -146,6 +146,16 @@ function isEvent(value$) {
146
146
  var _a;
147
147
  return value$ && ((_a = value$[symbolGetNode]) == null ? void 0 : _a.isEvent);
148
148
  }
149
+ function setNewValue(parentValue, key, newValue, useSetFn, useMapFn) {
150
+ if (useSetFn) {
151
+ parentValue.add(newValue);
152
+ } else if (useMapFn) {
153
+ parentValue.set(key, newValue);
154
+ } else {
155
+ parentValue[key] = newValue;
156
+ }
157
+ return newValue;
158
+ }
149
159
  function setNodeValue(node, newValue) {
150
160
  var _a;
151
161
  const parentNode = (_a = node.parent) != null ? _a : node;
@@ -169,13 +179,7 @@ function setNodeValue(node, newValue) {
169
179
  delete parentValue[key];
170
180
  }
171
181
  } else {
172
- if (useSetFn) {
173
- parentValue.add(newValue);
174
- } else if (useMapFn) {
175
- parentValue.set(key, newValue);
176
- } else {
177
- parentValue[key] = newValue;
178
- }
182
+ setNewValue(parentValue, key, newValue, useSetFn, useMapFn);
179
183
  }
180
184
  } finally {
181
185
  parentNode.isSetting--;
@@ -194,7 +198,7 @@ function getNodeValue(node) {
194
198
  let child = node.root._;
195
199
  for (let i = count - 1; child && i >= 0; i--) {
196
200
  const key = arrNodeKeys[i];
197
- child = key !== "size" && (isMap(child) || child instanceof WeakMap) ? child.get(key) : child[key];
201
+ child = key !== "size" && isMap(child) ? child.get(key) : child[key];
198
202
  }
199
203
  return child;
200
204
  }
@@ -229,7 +233,9 @@ function ensureNodeValue(node) {
229
233
  if (!value || isFunction(value)) {
230
234
  if (isChildNode(node)) {
231
235
  const parent = ensureNodeValue(node.parent);
232
- value = parent[node.key] = {};
236
+ const useSetFn = isSet(parent);
237
+ const useMapFn = isMap(parent);
238
+ value = setNewValue(parent, node.key, {}, useSetFn, useMapFn);
233
239
  } else {
234
240
  value = node.root._ = {};
235
241
  }
@@ -285,6 +291,14 @@ var ObservableHint = {
285
291
  }
286
292
  };
287
293
 
294
+ // src/checkPlain.ts
295
+ function checkPlain(node, value) {
296
+ var _a;
297
+ if (!node.isPlain && (((_a = node.parent) == null ? void 0 : _a.isPlain) || isHintPlain(value))) {
298
+ node.isPlain = true;
299
+ }
300
+ }
301
+
288
302
  // src/helpers.ts
289
303
  function computeSelector(selector, getOptions, e, retainObservable) {
290
304
  let c = selector;
@@ -611,37 +625,39 @@ function computeChangesAtNode(changesInBatch, node, isFromPersist, isFromSync, v
611
625
  }
612
626
  }
613
627
  function computeChangesRecursive(changesInBatch, node, loading, remote, value, path, pathTypes, valueAtPath, prevAtPath, immediate, level, whenOptimizedOnlyIf) {
614
- computeChangesAtNode(
615
- changesInBatch,
616
- node,
617
- loading,
618
- remote,
619
- value,
620
- path,
621
- pathTypes,
622
- valueAtPath,
623
- prevAtPath,
624
- immediate,
625
- level,
626
- whenOptimizedOnlyIf
627
- );
628
- if (node.linkedFromNodes) {
629
- for (const linkedFromNode of node.linkedFromNodes) {
630
- const childNode = getNodeAtPath(linkedFromNode, path);
631
- computeChangesRecursive(
632
- changesInBatch,
633
- childNode,
634
- loading,
635
- remote,
636
- valueAtPath,
637
- [],
638
- [],
639
- valueAtPath,
640
- prevAtPath,
641
- immediate,
642
- 0,
643
- whenOptimizedOnlyIf
644
- );
628
+ if (node.numListenersRecursive > 0) {
629
+ computeChangesAtNode(
630
+ changesInBatch,
631
+ node,
632
+ loading,
633
+ remote,
634
+ value,
635
+ path,
636
+ pathTypes,
637
+ valueAtPath,
638
+ prevAtPath,
639
+ immediate,
640
+ level,
641
+ whenOptimizedOnlyIf
642
+ );
643
+ if (node.linkedFromNodes) {
644
+ for (const linkedFromNode of node.linkedFromNodes) {
645
+ const childNode = getNodeAtPath(linkedFromNode, path);
646
+ computeChangesRecursive(
647
+ changesInBatch,
648
+ childNode,
649
+ loading,
650
+ remote,
651
+ valueAtPath,
652
+ [],
653
+ [],
654
+ valueAtPath,
655
+ prevAtPath,
656
+ immediate,
657
+ 0,
658
+ whenOptimizedOnlyIf
659
+ );
660
+ }
645
661
  }
646
662
  }
647
663
  if (node.parent) {
@@ -1706,6 +1722,7 @@ function setKey(node, key, newValue, level) {
1706
1722
  }
1707
1723
  }
1708
1724
  const isRoot = !node.parent && key === "_";
1725
+ checkPlain(node, newValue);
1709
1726
  if (node.parent && !getNodeValue(node) && !isFunction(newValue)) {
1710
1727
  set(node, { [key]: newValue });
1711
1728
  }
@@ -1723,8 +1740,8 @@ function setKey(node, key, newValue, level) {
1723
1740
  } while (parent = parent.parent);
1724
1741
  }
1725
1742
  const notify2 = !equals(savedValue, prevValue);
1726
- const forceNotify = !notify2 && childNode.isComputing && !isPrim;
1727
- if (notify2 || forceNotify) {
1743
+ const forceNotify = !notify2 && childNode.isComputing && !isPrim && !childNode.isPlain;
1744
+ if ((notify2 || forceNotify) && !(childNode.isComputing && childNode.isPlain && node.numListenersRecursive === 0)) {
1728
1745
  updateNodesAndNotify(
1729
1746
  node,
1730
1747
  savedValue,
@@ -1940,7 +1957,7 @@ function peek(node) {
1940
1957
  }
1941
1958
  var isFlushing = false;
1942
1959
  function peekInternal(node, activateRecursive) {
1943
- var _a, _b;
1960
+ var _a;
1944
1961
  isFlushing = true;
1945
1962
  if (activateRecursive && ((_a = node.dirtyChildren) == null ? void 0 : _a.size)) {
1946
1963
  const dirty = Array.from(node.dirtyChildren);
@@ -1955,9 +1972,6 @@ function peekInternal(node, activateRecursive) {
1955
1972
  }
1956
1973
  isFlushing = false;
1957
1974
  let value = getNodeValue(node);
1958
- if (((_b = node.parent) == null ? void 0 : _b.isPlain) || isHintPlain(value)) {
1959
- node.isPlain = true;
1960
- }
1961
1975
  if (!node.root.isLoadingLocal && !node.isPlain) {
1962
1976
  value = checkLazy(node, value, !!activateRecursive);
1963
1977
  }
@@ -1989,7 +2003,8 @@ function checkLazy(node, value, activateRecursive) {
1989
2003
  value = extractFunctionOrComputed(node.parent, node.key, value);
1990
2004
  }
1991
2005
  }
1992
- if ((lazy || node.needsExtract) && !isObservable(value) && !isPrimitive(value)) {
2006
+ checkPlain(node, value);
2007
+ if ((lazy || node.needsExtract) && !node.isPlain && !isObservable(value) && !isPrimitive(value)) {
1993
2008
  if (activateRecursive) {
1994
2009
  recursivelyAutoActivate(value, node);
1995
2010
  }
package/index.mjs CHANGED
@@ -144,6 +144,16 @@ function isEvent(value$) {
144
144
  var _a;
145
145
  return value$ && ((_a = value$[symbolGetNode]) == null ? void 0 : _a.isEvent);
146
146
  }
147
+ function setNewValue(parentValue, key, newValue, useSetFn, useMapFn) {
148
+ if (useSetFn) {
149
+ parentValue.add(newValue);
150
+ } else if (useMapFn) {
151
+ parentValue.set(key, newValue);
152
+ } else {
153
+ parentValue[key] = newValue;
154
+ }
155
+ return newValue;
156
+ }
147
157
  function setNodeValue(node, newValue) {
148
158
  var _a;
149
159
  const parentNode = (_a = node.parent) != null ? _a : node;
@@ -167,13 +177,7 @@ function setNodeValue(node, newValue) {
167
177
  delete parentValue[key];
168
178
  }
169
179
  } else {
170
- if (useSetFn) {
171
- parentValue.add(newValue);
172
- } else if (useMapFn) {
173
- parentValue.set(key, newValue);
174
- } else {
175
- parentValue[key] = newValue;
176
- }
180
+ setNewValue(parentValue, key, newValue, useSetFn, useMapFn);
177
181
  }
178
182
  } finally {
179
183
  parentNode.isSetting--;
@@ -192,7 +196,7 @@ function getNodeValue(node) {
192
196
  let child = node.root._;
193
197
  for (let i = count - 1; child && i >= 0; i--) {
194
198
  const key = arrNodeKeys[i];
195
- child = key !== "size" && (isMap(child) || child instanceof WeakMap) ? child.get(key) : child[key];
199
+ child = key !== "size" && isMap(child) ? child.get(key) : child[key];
196
200
  }
197
201
  return child;
198
202
  }
@@ -227,7 +231,9 @@ function ensureNodeValue(node) {
227
231
  if (!value || isFunction(value)) {
228
232
  if (isChildNode(node)) {
229
233
  const parent = ensureNodeValue(node.parent);
230
- value = parent[node.key] = {};
234
+ const useSetFn = isSet(parent);
235
+ const useMapFn = isMap(parent);
236
+ value = setNewValue(parent, node.key, {}, useSetFn, useMapFn);
231
237
  } else {
232
238
  value = node.root._ = {};
233
239
  }
@@ -283,6 +289,14 @@ var ObservableHint = {
283
289
  }
284
290
  };
285
291
 
292
+ // src/checkPlain.ts
293
+ function checkPlain(node, value) {
294
+ var _a;
295
+ if (!node.isPlain && (((_a = node.parent) == null ? void 0 : _a.isPlain) || isHintPlain(value))) {
296
+ node.isPlain = true;
297
+ }
298
+ }
299
+
286
300
  // src/helpers.ts
287
301
  function computeSelector(selector, getOptions, e, retainObservable) {
288
302
  let c = selector;
@@ -609,37 +623,39 @@ function computeChangesAtNode(changesInBatch, node, isFromPersist, isFromSync, v
609
623
  }
610
624
  }
611
625
  function computeChangesRecursive(changesInBatch, node, loading, remote, value, path, pathTypes, valueAtPath, prevAtPath, immediate, level, whenOptimizedOnlyIf) {
612
- computeChangesAtNode(
613
- changesInBatch,
614
- node,
615
- loading,
616
- remote,
617
- value,
618
- path,
619
- pathTypes,
620
- valueAtPath,
621
- prevAtPath,
622
- immediate,
623
- level,
624
- whenOptimizedOnlyIf
625
- );
626
- if (node.linkedFromNodes) {
627
- for (const linkedFromNode of node.linkedFromNodes) {
628
- const childNode = getNodeAtPath(linkedFromNode, path);
629
- computeChangesRecursive(
630
- changesInBatch,
631
- childNode,
632
- loading,
633
- remote,
634
- valueAtPath,
635
- [],
636
- [],
637
- valueAtPath,
638
- prevAtPath,
639
- immediate,
640
- 0,
641
- whenOptimizedOnlyIf
642
- );
626
+ if (node.numListenersRecursive > 0) {
627
+ computeChangesAtNode(
628
+ changesInBatch,
629
+ node,
630
+ loading,
631
+ remote,
632
+ value,
633
+ path,
634
+ pathTypes,
635
+ valueAtPath,
636
+ prevAtPath,
637
+ immediate,
638
+ level,
639
+ whenOptimizedOnlyIf
640
+ );
641
+ if (node.linkedFromNodes) {
642
+ for (const linkedFromNode of node.linkedFromNodes) {
643
+ const childNode = getNodeAtPath(linkedFromNode, path);
644
+ computeChangesRecursive(
645
+ changesInBatch,
646
+ childNode,
647
+ loading,
648
+ remote,
649
+ valueAtPath,
650
+ [],
651
+ [],
652
+ valueAtPath,
653
+ prevAtPath,
654
+ immediate,
655
+ 0,
656
+ whenOptimizedOnlyIf
657
+ );
658
+ }
643
659
  }
644
660
  }
645
661
  if (node.parent) {
@@ -1704,6 +1720,7 @@ function setKey(node, key, newValue, level) {
1704
1720
  }
1705
1721
  }
1706
1722
  const isRoot = !node.parent && key === "_";
1723
+ checkPlain(node, newValue);
1707
1724
  if (node.parent && !getNodeValue(node) && !isFunction(newValue)) {
1708
1725
  set(node, { [key]: newValue });
1709
1726
  }
@@ -1721,8 +1738,8 @@ function setKey(node, key, newValue, level) {
1721
1738
  } while (parent = parent.parent);
1722
1739
  }
1723
1740
  const notify2 = !equals(savedValue, prevValue);
1724
- const forceNotify = !notify2 && childNode.isComputing && !isPrim;
1725
- if (notify2 || forceNotify) {
1741
+ const forceNotify = !notify2 && childNode.isComputing && !isPrim && !childNode.isPlain;
1742
+ if ((notify2 || forceNotify) && !(childNode.isComputing && childNode.isPlain && node.numListenersRecursive === 0)) {
1726
1743
  updateNodesAndNotify(
1727
1744
  node,
1728
1745
  savedValue,
@@ -1938,7 +1955,7 @@ function peek(node) {
1938
1955
  }
1939
1956
  var isFlushing = false;
1940
1957
  function peekInternal(node, activateRecursive) {
1941
- var _a, _b;
1958
+ var _a;
1942
1959
  isFlushing = true;
1943
1960
  if (activateRecursive && ((_a = node.dirtyChildren) == null ? void 0 : _a.size)) {
1944
1961
  const dirty = Array.from(node.dirtyChildren);
@@ -1953,9 +1970,6 @@ function peekInternal(node, activateRecursive) {
1953
1970
  }
1954
1971
  isFlushing = false;
1955
1972
  let value = getNodeValue(node);
1956
- if (((_b = node.parent) == null ? void 0 : _b.isPlain) || isHintPlain(value)) {
1957
- node.isPlain = true;
1958
- }
1959
1973
  if (!node.root.isLoadingLocal && !node.isPlain) {
1960
1974
  value = checkLazy(node, value, !!activateRecursive);
1961
1975
  }
@@ -1987,7 +2001,8 @@ function checkLazy(node, value, activateRecursive) {
1987
2001
  value = extractFunctionOrComputed(node.parent, node.key, value);
1988
2002
  }
1989
2003
  }
1990
- if ((lazy || node.needsExtract) && !isObservable(value) && !isPrimitive(value)) {
2004
+ checkPlain(node, value);
2005
+ if ((lazy || node.needsExtract) && !node.isPlain && !isObservable(value) && !isPrimitive(value)) {
1991
2006
  if (activateRecursive) {
1992
2007
  recursivelyAutoActivate(value, node);
1993
2008
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/state",
3
- "version": "3.0.0-beta.37",
3
+ "version": "3.0.0-beta.39",
4
4
  "description": "legend-state",
5
5
  "sideEffects": false,
6
6
  "private": false,
@@ -5,6 +5,12 @@ var state = require('@legendapp/state');
5
5
  // src/persist-plugins/indexeddb.ts
6
6
  var MetadataSuffix = "__legend_metadata";
7
7
  var PrimitiveName = "__legend_primitive";
8
+ function getIndexedDB() {
9
+ if (typeof globalThis === "undefined") {
10
+ return void 0;
11
+ }
12
+ return globalThis.indexedDB;
13
+ }
8
14
  function requestToPromise(request) {
9
15
  return new Promise((resolve) => request.onsuccess = () => resolve());
10
16
  }
@@ -21,8 +27,9 @@ var ObservablePersistIndexedDB = class {
21
27
  }
22
28
  async initialize(configOptions) {
23
29
  const config = this.configuration || configOptions.indexedDB;
24
- if (typeof indexedDB === "undefined")
30
+ if (!getIndexedDB()) {
25
31
  return;
32
+ }
26
33
  if (process.env.NODE_ENV === "development" && !config) {
27
34
  console.error("[legend-state] Must configure ObservablePersistIndexedDB");
28
35
  }
@@ -69,6 +76,9 @@ var ObservablePersistIndexedDB = class {
69
76
  loadTable(table, config) {
70
77
  var _a;
71
78
  if (!this.db) {
79
+ if (!getIndexedDB()) {
80
+ return;
81
+ }
72
82
  throw new Error(
73
83
  "[legend-state] ObservablePersistIndexedDB loading without being initialized. This may happen when running outside of a browser."
74
84
  );
@@ -147,7 +157,7 @@ var ObservablePersistIndexedDB = class {
147
157
  }
148
158
  async set(table, changes, config) {
149
159
  var _a, _b;
150
- if (typeof indexedDB === "undefined")
160
+ if (!getIndexedDB())
151
161
  return;
152
162
  if (!this.pendingSaves.has(config)) {
153
163
  this.pendingSaves.set(config, {});
@@ -238,7 +248,7 @@ var ObservablePersistIndexedDB = class {
238
248
  delete this.tableData[tableName];
239
249
  delete this.tableData[tableName + "_transformed"];
240
250
  }
241
- if (typeof indexedDB === "undefined")
251
+ if (!getIndexedDB())
242
252
  return;
243
253
  this.deleteMetadata(table, config);
244
254
  if (data) {
@@ -3,6 +3,12 @@ import { when, isPromise, observable, setAtPath, isPrimitive } from '@legendapp/
3
3
  // src/persist-plugins/indexeddb.ts
4
4
  var MetadataSuffix = "__legend_metadata";
5
5
  var PrimitiveName = "__legend_primitive";
6
+ function getIndexedDB() {
7
+ if (typeof globalThis === "undefined") {
8
+ return void 0;
9
+ }
10
+ return globalThis.indexedDB;
11
+ }
6
12
  function requestToPromise(request) {
7
13
  return new Promise((resolve) => request.onsuccess = () => resolve());
8
14
  }
@@ -19,8 +25,9 @@ var ObservablePersistIndexedDB = class {
19
25
  }
20
26
  async initialize(configOptions) {
21
27
  const config = this.configuration || configOptions.indexedDB;
22
- if (typeof indexedDB === "undefined")
28
+ if (!getIndexedDB()) {
23
29
  return;
30
+ }
24
31
  if (process.env.NODE_ENV === "development" && !config) {
25
32
  console.error("[legend-state] Must configure ObservablePersistIndexedDB");
26
33
  }
@@ -67,6 +74,9 @@ var ObservablePersistIndexedDB = class {
67
74
  loadTable(table, config) {
68
75
  var _a;
69
76
  if (!this.db) {
77
+ if (!getIndexedDB()) {
78
+ return;
79
+ }
70
80
  throw new Error(
71
81
  "[legend-state] ObservablePersistIndexedDB loading without being initialized. This may happen when running outside of a browser."
72
82
  );
@@ -145,7 +155,7 @@ var ObservablePersistIndexedDB = class {
145
155
  }
146
156
  async set(table, changes, config) {
147
157
  var _a, _b;
148
- if (typeof indexedDB === "undefined")
158
+ if (!getIndexedDB())
149
159
  return;
150
160
  if (!this.pendingSaves.has(config)) {
151
161
  this.pendingSaves.set(config, {});
@@ -236,7 +246,7 @@ var ObservablePersistIndexedDB = class {
236
246
  delete this.tableData[tableName];
237
247
  delete this.tableData[tableName + "_transformed"];
238
248
  }
239
- if (typeof indexedDB === "undefined")
249
+ if (!getIndexedDB())
240
250
  return;
241
251
  this.deleteMetadata(table, config);
242
252
  if (data) {
package/react-web.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { FCReactiveObject } from '@legendapp/state/react';
2
+ import { JSX } from 'react';
2
3
 
3
4
  type IReactive = FCReactiveObject<JSX.IntrinsicElements>;
4
5
  declare const $React: IReactive;
package/react-web.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { FCReactiveObject } from '@legendapp/state/react';
2
+ import { JSX } from 'react';
2
3
 
3
4
  type IReactive = FCReactiveObject<JSX.IntrinsicElements>;
4
5
  declare const $React: IReactive;
@@ -11,7 +11,8 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
11
11
  type IsUnionOfStrings<T> = [T] extends [string] ? ([T] extends [UnionToIntersection<T>] ? false : true) : false;
12
12
  type SupabaseSchemaOf<Client extends SupabaseClient> = Client extends SupabaseClient<infer _, infer __, infer Schema> ? Schema : never;
13
13
  type SupabaseTableOf<Client extends SupabaseClient, SchemaName extends SchemaNameOf<Client>> = DatabaseOf<Client>[SchemaName]['Tables'];
14
- type SupabaseCollectionOf<Client extends SupabaseClient, SchemaName extends SchemaNameOf<Client>> = keyof SupabaseTableOf<Client, IsUnionOfStrings<SchemaName> extends true ? 'public' : SchemaName>;
14
+ type SupabaseViewOf<Client extends SupabaseClient, SchemaName extends SchemaNameOf<Client>> = DatabaseOf<Client>[SchemaName]['Views'];
15
+ type SupabaseCollectionOf<Client extends SupabaseClient, SchemaName extends SchemaNameOf<Client>> = keyof SupabaseTableOf<Client, IsUnionOfStrings<SchemaName> extends true ? 'public' : SchemaName> | keyof SupabaseViewOf<Client, IsUnionOfStrings<SchemaName> extends true ? 'public' : SchemaName>;
15
16
  type SupabaseRowOf<Client extends SupabaseClient, Collection extends SupabaseCollectionOf<Client, SchemaName>, SchemaName extends SchemaNameOf<Client>> = SupabaseTableOf<Client, SchemaName>[Collection]['Row'];
16
17
  type SyncedSupabaseConfig<TRemote extends {
17
18
  id: string | number;
@@ -50,4 +51,4 @@ declare function configureSyncedSupabase(config: SyncedSupabaseConfiguration): v
50
51
  declare function syncedSupabase<Client extends SupabaseClient<any, any>, Collection extends SupabaseCollectionOf<Client, SchemaName> & string, SchemaName extends SchemaNameOf<Client> = 'public', AsOption extends CrudAsOption = 'object', TRemote = SupabaseRowOf<Client, Collection, SchemaName>, TLocal = TRemote>(props: SyncedSupabasePropsWithSelect<Client, Collection, SchemaName, AsOption, TRemote, TLocal>): SyncedCrudReturnType<TLocal, AsOption>;
51
52
  declare function syncedSupabase<Client extends SupabaseClient<any, any>, Collection extends SupabaseCollectionOf<Client, SchemaName> & string, SchemaName extends SchemaNameOf<Client> = 'public', 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>;
52
53
 
53
- export { type SupabaseCollectionOf, type SupabaseRowOf, type SupabaseSchemaOf, type SupabaseTableOf, type SyncedSupabaseConfig, type SyncedSupabaseConfiguration, configureSyncedSupabase, getSyncedSupabaseConfiguration, syncedSupabase };
54
+ export { type SupabaseCollectionOf, type SupabaseRowOf, type SupabaseSchemaOf, type SupabaseTableOf, type SupabaseViewOf, type SyncedSupabaseConfig, type SyncedSupabaseConfiguration, configureSyncedSupabase, getSyncedSupabaseConfiguration, syncedSupabase };
@@ -11,7 +11,8 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
11
11
  type IsUnionOfStrings<T> = [T] extends [string] ? ([T] extends [UnionToIntersection<T>] ? false : true) : false;
12
12
  type SupabaseSchemaOf<Client extends SupabaseClient> = Client extends SupabaseClient<infer _, infer __, infer Schema> ? Schema : never;
13
13
  type SupabaseTableOf<Client extends SupabaseClient, SchemaName extends SchemaNameOf<Client>> = DatabaseOf<Client>[SchemaName]['Tables'];
14
- type SupabaseCollectionOf<Client extends SupabaseClient, SchemaName extends SchemaNameOf<Client>> = keyof SupabaseTableOf<Client, IsUnionOfStrings<SchemaName> extends true ? 'public' : SchemaName>;
14
+ type SupabaseViewOf<Client extends SupabaseClient, SchemaName extends SchemaNameOf<Client>> = DatabaseOf<Client>[SchemaName]['Views'];
15
+ type SupabaseCollectionOf<Client extends SupabaseClient, SchemaName extends SchemaNameOf<Client>> = keyof SupabaseTableOf<Client, IsUnionOfStrings<SchemaName> extends true ? 'public' : SchemaName> | keyof SupabaseViewOf<Client, IsUnionOfStrings<SchemaName> extends true ? 'public' : SchemaName>;
15
16
  type SupabaseRowOf<Client extends SupabaseClient, Collection extends SupabaseCollectionOf<Client, SchemaName>, SchemaName extends SchemaNameOf<Client>> = SupabaseTableOf<Client, SchemaName>[Collection]['Row'];
16
17
  type SyncedSupabaseConfig<TRemote extends {
17
18
  id: string | number;
@@ -50,4 +51,4 @@ declare function configureSyncedSupabase(config: SyncedSupabaseConfiguration): v
50
51
  declare function syncedSupabase<Client extends SupabaseClient<any, any>, Collection extends SupabaseCollectionOf<Client, SchemaName> & string, SchemaName extends SchemaNameOf<Client> = 'public', AsOption extends CrudAsOption = 'object', TRemote = SupabaseRowOf<Client, Collection, SchemaName>, TLocal = TRemote>(props: SyncedSupabasePropsWithSelect<Client, Collection, SchemaName, AsOption, TRemote, TLocal>): SyncedCrudReturnType<TLocal, AsOption>;
51
52
  declare function syncedSupabase<Client extends SupabaseClient<any, any>, Collection extends SupabaseCollectionOf<Client, SchemaName> & string, SchemaName extends SchemaNameOf<Client> = 'public', 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>;
52
53
 
53
- export { type SupabaseCollectionOf, type SupabaseRowOf, type SupabaseSchemaOf, type SupabaseTableOf, type SyncedSupabaseConfig, type SyncedSupabaseConfiguration, configureSyncedSupabase, getSyncedSupabaseConfiguration, syncedSupabase };
54
+ export { type SupabaseCollectionOf, type SupabaseRowOf, type SupabaseSchemaOf, type SupabaseTableOf, type SupabaseViewOf, type SyncedSupabaseConfig, type SyncedSupabaseConfiguration, configureSyncedSupabase, getSyncedSupabaseConfiguration, syncedSupabase };