@pol-studios/db 1.0.59 → 1.0.61

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.
@@ -3,7 +3,7 @@ import {
3
3
  createSupabaseAdapter,
4
4
  getPowerSyncAlias,
5
5
  stripSchemaPrefix
6
- } from "./chunk-VADZSRHY.js";
6
+ } from "./chunk-FWCHS5NN.js";
7
7
  import {
8
8
  DataLayerContext,
9
9
  DataLayerCoreContext,
@@ -1418,20 +1418,13 @@ var defaultSyncControl = {
1418
1418
  setScope: async () => {
1419
1419
  console.warn("Scope control not available: PowerSync not initialized");
1420
1420
  },
1421
- pauseAutoRetry: () => {
1422
- console.warn("Pause auto-retry not available: PowerSync not initialized");
1423
- },
1424
- resumeAutoRetry: () => {
1425
- console.warn("Resume auto-retry not available: PowerSync not initialized");
1426
- },
1427
- isAutoRetryPaused: false,
1428
1421
  addPendingMutation: () => {
1429
1422
  },
1430
1423
  removePendingMutation: () => {
1431
1424
  }
1432
1425
  };
1433
1426
  function DataLayerProvider(t0) {
1434
- const $ = _c(68);
1427
+ const $ = _c(70);
1435
1428
  const {
1436
1429
  config,
1437
1430
  children,
@@ -1562,7 +1555,7 @@ function DataLayerProvider(t0) {
1562
1555
  }
1563
1556
  const getPowerSyncTables = t9;
1564
1557
  let t10;
1565
- if ($[24] !== adapters.powerSync || $[25] !== adapters.supabase || $[26] !== adapters.syncTracking || $[27] !== config.tables) {
1558
+ if ($[24] !== adapters.powerSync || $[25] !== adapters.supabase || $[26] !== adapters.syncTracking || $[27] !== config.tables || $[28] !== hasSynced || $[29] !== isOnline) {
1566
1559
  t10 = (table_2, t112) => {
1567
1560
  t112 === void 0 ? "read" : t112;
1568
1561
  const tableWithoutSchema_1 = table_2.includes(".") ? stripSchemaPrefix(table_2) : table_2;
@@ -1570,18 +1563,33 @@ function DataLayerProvider(t0) {
1570
1563
  if (strategy_3?.strategy === "supabase") {
1571
1564
  return adapters.supabase;
1572
1565
  }
1573
- const isPowerSyncTable = !strategy_3 || strategy_3.strategy === "powersync" || strategy_3.strategy === "hybrid" || strategy_3.strategy === "auto";
1574
- if (isPowerSyncTable && adapters.powerSync) {
1566
+ if (strategy_3?.strategy === "cached") {
1567
+ return adapters.supabase;
1568
+ }
1569
+ if (strategy_3?.strategy === "powersync") {
1570
+ if (adapters.powerSync) {
1571
+ return adapters.syncTracking ?? adapters.powerSync;
1572
+ }
1573
+ return adapters.supabase;
1574
+ }
1575
+ const isAutoTable = !strategy_3 || strategy_3.strategy === "auto" || strategy_3.strategy === "hybrid";
1576
+ if (isAutoTable) {
1575
1577
  const powerSyncTableKeys = Object.keys(config.tables).filter((key_0) => {
1576
1578
  const s = config.tables[key_0];
1577
1579
  return s.strategy === "powersync" || s.strategy === "hybrid" || s.strategy === "auto";
1578
1580
  });
1579
1581
  const isConfigured = powerSyncTableKeys.some((key_1) => key_1 === table_2 || key_1 === tableWithoutSchema_1 || key_1.includes(".") && key_1.split(".")[1] === tableWithoutSchema_1);
1580
- if (isConfigured) {
1581
- return adapters.syncTracking ?? adapters.powerSync;
1582
+ if (!isConfigured) {
1583
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
1584
+ console.warn(`[DataLayerProvider] Table "${table_2}" is not configured for PowerSync. Using Supabase fallback.`);
1585
+ }
1586
+ return adapters.supabase;
1582
1587
  }
1583
- if (typeof __DEV__ !== "undefined" && __DEV__) {
1584
- console.warn(`[DataLayerProvider] Table "${table_2}" is not configured for PowerSync. Using Supabase fallback.`);
1588
+ if (isOnline && !hasSynced) {
1589
+ return adapters.supabase;
1590
+ }
1591
+ if (adapters.powerSync) {
1592
+ return adapters.syncTracking ?? adapters.powerSync;
1585
1593
  }
1586
1594
  }
1587
1595
  if (!adapters.supabase) {
@@ -1593,13 +1601,15 @@ function DataLayerProvider(t0) {
1593
1601
  $[25] = adapters.supabase;
1594
1602
  $[26] = adapters.syncTracking;
1595
1603
  $[27] = config.tables;
1596
- $[28] = t10;
1604
+ $[28] = hasSynced;
1605
+ $[29] = isOnline;
1606
+ $[30] = t10;
1597
1607
  } else {
1598
- t10 = $[28];
1608
+ t10 = $[30];
1599
1609
  }
1600
1610
  const getAdapter = t10;
1601
1611
  let t11;
1602
- if ($[29] !== adapters.powerSync || $[30] !== config.tables || $[31] !== getPowerSyncTables) {
1612
+ if ($[31] !== adapters.powerSync || $[32] !== config.tables || $[33] !== getPowerSyncTables) {
1603
1613
  t11 = () => ({
1604
1614
  isInitialized: true,
1605
1615
  hasPowerSync: adapters.powerSync !== null,
@@ -1607,15 +1617,15 @@ function DataLayerProvider(t0) {
1607
1617
  configuredTableCount: Object.keys(config.tables).length,
1608
1618
  powerSyncTables: getPowerSyncTables()
1609
1619
  });
1610
- $[29] = adapters.powerSync;
1611
- $[30] = config.tables;
1612
- $[31] = getPowerSyncTables;
1613
- $[32] = t11;
1620
+ $[31] = adapters.powerSync;
1621
+ $[32] = config.tables;
1622
+ $[33] = getPowerSyncTables;
1623
+ $[34] = t11;
1614
1624
  } else {
1615
- t11 = $[32];
1625
+ t11 = $[34];
1616
1626
  }
1617
1627
  let t12;
1618
- if ($[33] !== config || $[34] !== getAdapter || $[35] !== getPowerSyncTables || $[36] !== getTableAlias || $[37] !== getTableStrategy || $[38] !== t11 || $[39] !== usesPowerSync) {
1628
+ if ($[35] !== config || $[36] !== getAdapter || $[37] !== getPowerSyncTables || $[38] !== getTableAlias || $[39] !== getTableStrategy || $[40] !== t11 || $[41] !== usesPowerSync) {
1619
1629
  t12 = {
1620
1630
  getAdapter,
1621
1631
  getTableStrategy,
@@ -1626,20 +1636,20 @@ function DataLayerProvider(t0) {
1626
1636
  config,
1627
1637
  isInitialized: true
1628
1638
  };
1629
- $[33] = config;
1630
- $[34] = getAdapter;
1631
- $[35] = getPowerSyncTables;
1632
- $[36] = getTableAlias;
1633
- $[37] = getTableStrategy;
1634
- $[38] = t11;
1635
- $[39] = usesPowerSync;
1636
- $[40] = t12;
1639
+ $[35] = config;
1640
+ $[36] = getAdapter;
1641
+ $[37] = getPowerSyncTables;
1642
+ $[38] = getTableAlias;
1643
+ $[39] = getTableStrategy;
1644
+ $[40] = t11;
1645
+ $[41] = usesPowerSync;
1646
+ $[42] = t12;
1637
1647
  } else {
1638
- t12 = $[40];
1648
+ t12 = $[42];
1639
1649
  }
1640
1650
  const registry = t12;
1641
1651
  let t13;
1642
- if ($[41] !== config.schema || $[42] !== getAdapter || $[43] !== powerSyncInstance || $[44] !== queryClient || $[45] !== registry || $[46] !== supabaseClient || $[47] !== syncControl) {
1652
+ if ($[43] !== config.schema || $[44] !== getAdapter || $[45] !== powerSyncInstance || $[46] !== queryClient || $[47] !== registry || $[48] !== supabaseClient || $[49] !== syncControl) {
1643
1653
  t13 = {
1644
1654
  registry,
1645
1655
  getAdapter,
@@ -1649,22 +1659,22 @@ function DataLayerProvider(t0) {
1649
1659
  schema: config.schema,
1650
1660
  syncControl
1651
1661
  };
1652
- $[41] = config.schema;
1653
- $[42] = getAdapter;
1654
- $[43] = powerSyncInstance;
1655
- $[44] = queryClient;
1656
- $[45] = registry;
1657
- $[46] = supabaseClient;
1658
- $[47] = syncControl;
1659
- $[48] = t13;
1662
+ $[43] = config.schema;
1663
+ $[44] = getAdapter;
1664
+ $[45] = powerSyncInstance;
1665
+ $[46] = queryClient;
1666
+ $[47] = registry;
1667
+ $[48] = supabaseClient;
1668
+ $[49] = syncControl;
1669
+ $[50] = t13;
1660
1670
  } else {
1661
- t13 = $[48];
1671
+ t13 = $[50];
1662
1672
  }
1663
1673
  const coreContextValue = t13;
1664
1674
  const t14 = powerSyncInstance ? "powersync" : "supabase";
1665
1675
  const t15 = powerSyncInstance ? "available" /* AVAILABLE */ : "unavailable" /* UNAVAILABLE */;
1666
1676
  let t16;
1667
- if ($[49] !== hasSynced || $[50] !== isOnline || $[51] !== t14 || $[52] !== t15) {
1677
+ if ($[51] !== hasSynced || $[52] !== isOnline || $[53] !== t14 || $[54] !== t15) {
1668
1678
  t16 = {
1669
1679
  isInitialized: true,
1670
1680
  currentBackend: t14,
@@ -1674,66 +1684,66 @@ function DataLayerProvider(t0) {
1674
1684
  error: null,
1675
1685
  hasSynced
1676
1686
  };
1677
- $[49] = hasSynced;
1678
- $[50] = isOnline;
1679
- $[51] = t14;
1680
- $[52] = t15;
1681
- $[53] = t16;
1687
+ $[51] = hasSynced;
1688
+ $[52] = isOnline;
1689
+ $[53] = t14;
1690
+ $[54] = t15;
1691
+ $[55] = t16;
1682
1692
  } else {
1683
- t16 = $[53];
1693
+ t16 = $[55];
1684
1694
  }
1685
1695
  const status = t16;
1686
1696
  let t17;
1687
- if ($[54] !== status) {
1697
+ if ($[56] !== status) {
1688
1698
  t17 = {
1689
1699
  status,
1690
1700
  syncStatus: defaultSyncStatus
1691
1701
  };
1692
- $[54] = status;
1693
- $[55] = t17;
1702
+ $[56] = status;
1703
+ $[57] = t17;
1694
1704
  } else {
1695
- t17 = $[55];
1705
+ t17 = $[57];
1696
1706
  }
1697
1707
  const statusContextValue = t17;
1698
1708
  let t18;
1699
- if ($[56] !== coreContextValue || $[57] !== statusContextValue) {
1709
+ if ($[58] !== coreContextValue || $[59] !== statusContextValue) {
1700
1710
  t18 = {
1701
1711
  ...coreContextValue,
1702
1712
  ...statusContextValue
1703
1713
  };
1704
- $[56] = coreContextValue;
1705
- $[57] = statusContextValue;
1706
- $[58] = t18;
1714
+ $[58] = coreContextValue;
1715
+ $[59] = statusContextValue;
1716
+ $[60] = t18;
1707
1717
  } else {
1708
- t18 = $[58];
1718
+ t18 = $[60];
1709
1719
  }
1710
1720
  const contextValue = t18;
1711
1721
  let t19;
1712
- if ($[59] !== children || $[60] !== statusContextValue) {
1722
+ if ($[61] !== children || $[62] !== statusContextValue) {
1713
1723
  t19 = /* @__PURE__ */ jsx(DataLayerStatusContext.Provider, { value: statusContextValue, children });
1714
- $[59] = children;
1715
- $[60] = statusContextValue;
1716
- $[61] = t19;
1724
+ $[61] = children;
1725
+ $[62] = statusContextValue;
1726
+ $[63] = t19;
1717
1727
  } else {
1718
- t19 = $[61];
1728
+ t19 = $[63];
1719
1729
  }
1720
1730
  let t20;
1721
- if ($[62] !== coreContextValue || $[63] !== t19) {
1731
+ if ($[64] !== coreContextValue || $[65] !== t19) {
1722
1732
  t20 = /* @__PURE__ */ jsx(DataLayerCoreContext.Provider, { value: coreContextValue, children: t19 });
1723
- $[62] = coreContextValue;
1724
- $[63] = t19;
1725
- $[64] = t20;
1733
+ $[64] = coreContextValue;
1734
+ $[65] = t19;
1735
+ $[66] = t20;
1726
1736
  } else {
1727
- t20 = $[64];
1737
+ t20 = $[66];
1728
1738
  }
1729
1739
  let t21;
1730
- if ($[65] !== contextValue || $[66] !== t20) {
1740
+ if ($[67] !== contextValue || $[68] !== t20) {
1731
1741
  t21 = /* @__PURE__ */ jsx(DataLayerNestingContext.Provider, { value: true, children: /* @__PURE__ */ jsx(DataLayerContext.Provider, { value: contextValue, children: t20 }) });
1732
- $[65] = contextValue;
1733
- $[66] = t20;
1734
- $[67] = t21;
1742
+ $[67] = contextValue;
1743
+ $[68] = t20;
1744
+ $[69] = t21;
1735
1745
  } else {
1736
- t21 = $[67];
1746
+ t21 = $[69];
1737
1747
  }
1738
1748
  return t21;
1739
1749
  }
@@ -5012,4 +5022,4 @@ object-assign/index.js:
5012
5022
  @license MIT
5013
5023
  *)
5014
5024
  */
5015
- //# sourceMappingURL=chunk-K46TGKB2.js.map
5025
+ //# sourceMappingURL=chunk-7PBTPCRN.js.map