@powersync/react 0.0.0-dev-20250804151331 → 0.0.0-dev-20250807074601

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
1
  import { AbstractPowerSyncDatabase, WatchCompatibleQuery, WatchedQuery } from '@powersync/common';
2
- import { DifferentialHookOptions } from './hooks/watched/watch-types';
2
+ import { DifferentialHookOptions } from './hooks/watched/watch-types.js';
3
3
  export declare function generateQueryKey(sqlStatement: string, parameters: ReadonlyArray<unknown>, options: DifferentialHookOptions<unknown>): string;
4
4
  export declare class QueryStore {
5
5
  private db;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { usePowerSync } from '../PowerSyncContext';
2
+ import { usePowerSync } from '../PowerSyncContext.js';
3
3
  /**
4
4
  * @deprecated use {@link useQuery} instead.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  import { useContext, useEffect, useState } from 'react';
2
- import { PowerSyncContext } from '../PowerSyncContext';
2
+ import { PowerSyncContext } from '../PowerSyncContext.js';
3
3
  /**
4
4
  * @deprecated Use {@link useStatus} instead.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { usePowerSync } from '../PowerSyncContext';
2
+ import { usePowerSync } from '../PowerSyncContext.js';
3
3
  /**
4
4
  * @deprecated use {@link useQuery} instead.
5
5
  *
@@ -1,3 +1,3 @@
1
- import { QueryResult, ReadonlyQueryResult } from '../watched/watch-types';
1
+ import { QueryResult, ReadonlyQueryResult } from '../watched/watch-types.js';
2
2
  export type SuspenseQueryResult<T> = Pick<QueryResult<T>, 'data' | 'refresh'>;
3
3
  export type ReadonlySuspenseQueryResult<T> = Pick<ReadonlyQueryResult<T>, 'data' | 'refresh'>;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ const NO_OP_RELEASE = () => { };
2
3
  /**
3
4
  * The store will dispose this query if it has no subscribers attached to it.
4
5
  * The suspense promise adds a subscriber to the query, but the promise could resolve
@@ -8,15 +9,18 @@ import React from 'react';
8
9
  * @returns a function to release the hold
9
10
  */
10
11
  export const useTemporaryHold = (watchedQuery) => {
11
- const releaseTemporaryHold = React.useRef(undefined);
12
+ // Defaults to a no-op. If the provided WatchedQuery is not loading, we don't need a
13
+ // temporary hold.
14
+ const releaseTemporaryHold = React.useRef(NO_OP_RELEASE);
12
15
  const addedHoldTo = React.useRef(undefined);
13
16
  if (addedHoldTo.current !== watchedQuery) {
14
17
  releaseTemporaryHold.current?.();
18
+ releaseTemporaryHold.current = NO_OP_RELEASE;
15
19
  addedHoldTo.current = watchedQuery;
16
20
  if (!watchedQuery || !watchedQuery.state.isLoading) {
17
21
  // No query to hold or no reason to hold, return a no-op
18
22
  return {
19
- releaseHold: () => { }
23
+ releaseHold: releaseTemporaryHold.current
20
24
  };
21
25
  }
22
26
  const disposeSubscription = watchedQuery.registerListener({
@@ -1,6 +1,6 @@
1
1
  import { CompilableQuery } from '@powersync/common';
2
- import { AdditionalOptions } from '../watched/watch-types';
3
- import { SuspenseQueryResult } from './SuspenseQueryResult';
2
+ import { AdditionalOptions } from '../watched/watch-types.js';
3
+ import { SuspenseQueryResult } from './SuspenseQueryResult.js';
4
4
  /**
5
5
  * Use a query which is not watched, but suspends until the initial result has loaded.
6
6
  * Internally this uses a WatchedQuery during suspense for state management. The watched
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { generateQueryKey, getQueryStore } from '../../QueryStore';
3
- import { usePowerSync } from '../PowerSyncContext';
4
- import { constructCompatibleQuery } from '../watched/watch-utils';
5
- import { createSuspendingPromise, useTemporaryHold } from './suspense-utils';
2
+ import { generateQueryKey, getQueryStore } from '../../QueryStore.js';
3
+ import { usePowerSync } from '../PowerSyncContext.js';
4
+ import { constructCompatibleQuery } from '../watched/watch-utils.js';
5
+ import { createSuspendingPromise, useTemporaryHold } from './suspense-utils.js';
6
6
  /**
7
7
  * Use a query which is not watched, but suspends until the initial result has loaded.
8
8
  * Internally this uses a WatchedQuery during suspense for state management. The watched
@@ -1,6 +1,6 @@
1
1
  import { CompilableQuery } from '@powersync/common';
2
- import { AdditionalOptions, DifferentialHookOptions } from '../watched/watch-types';
3
- import { ReadonlySuspenseQueryResult, SuspenseQueryResult } from './SuspenseQueryResult';
2
+ import { AdditionalOptions, DifferentialHookOptions } from '../watched/watch-types.js';
3
+ import { ReadonlySuspenseQueryResult, SuspenseQueryResult } from './SuspenseQueryResult.js';
4
4
  /**
5
5
  * A hook to access the results of a watched query that suspends until the initial result has loaded.
6
6
  * @example
@@ -1,5 +1,5 @@
1
- import { useSingleSuspenseQuery } from './useSingleSuspenseQuery';
2
- import { useWatchedSuspenseQuery } from './useWatchedSuspenseQuery';
1
+ import { useSingleSuspenseQuery } from './useSingleSuspenseQuery.js';
2
+ import { useWatchedSuspenseQuery } from './useWatchedSuspenseQuery.js';
3
3
  export function useSuspenseQuery(query, parameters = [], options = {}) {
4
4
  switch (options?.runQueryOnce) {
5
5
  case true:
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { createSuspendingPromise, useTemporaryHold } from './suspense-utils';
2
+ import { createSuspendingPromise, useTemporaryHold } from './suspense-utils.js';
3
3
  /**
4
4
  * A hook to access and subscribe to the results of an existing {@link WatchedQuery}.
5
5
  * @example
@@ -1,5 +1,5 @@
1
1
  import { CompilableQuery } from '@powersync/common';
2
- import { AdditionalOptions } from '../watched/watch-types';
2
+ import { AdditionalOptions } from '../watched/watch-types.js';
3
3
  /**
4
4
  * @internal This is not exported in the index.ts
5
5
  */
@@ -1,7 +1,7 @@
1
- import { generateQueryKey, getQueryStore } from '../../QueryStore';
2
- import { usePowerSync } from '../PowerSyncContext';
3
- import { constructCompatibleQuery } from '../watched/watch-utils';
4
- import { useWatchedQuerySuspenseSubscription } from './useWatchedQuerySuspenseSubscription';
1
+ import { generateQueryKey, getQueryStore } from '../../QueryStore.js';
2
+ import { usePowerSync } from '../PowerSyncContext.js';
3
+ import { constructCompatibleQuery } from '../watched/watch-utils.js';
4
+ import { useWatchedQuerySuspenseSubscription } from './useWatchedQuerySuspenseSubscription.js';
5
5
  /**
6
6
  * @internal This is not exported in the index.ts
7
7
  */
@@ -1,4 +1,4 @@
1
- import { usePowerSyncStatus } from './deprecated/usePowerSyncStatus';
1
+ import { usePowerSyncStatus } from './deprecated/usePowerSyncStatus.js';
2
2
  /**
3
3
  * Custom hook that provides access to the current status of PowerSync.
4
4
  * @returns The PowerSync Database status.
@@ -1,5 +1,5 @@
1
1
  import { type CompilableQuery } from '@powersync/common';
2
- import { AdditionalOptions, DifferentialHookOptions, QueryResult, ReadonlyQueryResult } from './watch-types';
2
+ import { AdditionalOptions, DifferentialHookOptions, QueryResult, ReadonlyQueryResult } from './watch-types.js';
3
3
  /**
4
4
  * A hook to access the results of a watched query.
5
5
  * @example
@@ -1,7 +1,7 @@
1
- import { usePowerSync } from '../PowerSyncContext';
2
- import { useSingleQuery } from './useSingleQuery';
3
- import { useWatchedQuery } from './useWatchedQuery';
4
- import { constructCompatibleQuery } from './watch-utils';
1
+ import { usePowerSync } from '../PowerSyncContext.js';
2
+ import { useSingleQuery } from './useSingleQuery.js';
3
+ import { useWatchedQuery } from './useWatchedQuery.js';
4
+ import { constructCompatibleQuery } from './watch-utils.js';
5
5
  export function useQuery(query, parameters = [], options = {}) {
6
6
  const powerSync = usePowerSync();
7
7
  if (!powerSync) {
@@ -1,3 +1,3 @@
1
- import { QueryResult } from './watch-types';
2
- import { InternalHookOptions } from './watch-utils';
1
+ import { QueryResult } from './watch-types.js';
2
+ import { InternalHookOptions } from './watch-utils.js';
3
3
  export declare const useSingleQuery: <RowType = any>(options: InternalHookOptions<RowType[]>) => QueryResult<RowType>;
@@ -1,5 +1,5 @@
1
- import { DifferentialHookOptions, QueryResult, ReadonlyQueryResult } from './watch-types';
2
- import { InternalHookOptions } from './watch-utils';
1
+ import { DifferentialHookOptions, QueryResult, ReadonlyQueryResult } from './watch-types.js';
2
+ import { InternalHookOptions } from './watch-utils.js';
3
3
  /**
4
4
  * @internal This is not exported from the index.ts
5
5
  *
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { useWatchedQuerySubscription } from './useWatchedQuerySubscription';
2
+ import { useWatchedQuerySubscription } from './useWatchedQuerySubscription.js';
3
3
  /**
4
4
  * @internal This is not exported from the index.ts
5
5
  *
@@ -1,5 +1,5 @@
1
1
  import { AbstractPowerSyncDatabase, CompilableQuery, WatchCompatibleQuery } from '@powersync/common';
2
- import { AdditionalOptions } from './watch-types';
2
+ import { AdditionalOptions } from './watch-types.js';
3
3
  export type InternalHookOptions<DataType> = {
4
4
  query: WatchCompatibleQuery<DataType>;
5
5
  powerSync: AbstractPowerSyncDatabase;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { usePowerSync } from '../PowerSyncContext';
2
+ import { usePowerSync } from '../PowerSyncContext.js';
3
3
  export const checkQueryChanged = (query, options) => {
4
4
  let _compiled;
5
5
  try {
package/lib/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export { usePowerSyncQuery } from './hooks/deprecated/usePowerSyncQuery';
2
- export { usePowerSyncStatus } from './hooks/deprecated/usePowerSyncStatus';
3
- export { usePowerSyncWatchedQuery } from './hooks/deprecated/usePowerSyncWatchedQuery';
4
- export * from './hooks/PowerSyncContext';
5
- export { SuspenseQueryResult } from './hooks/suspense/SuspenseQueryResult';
6
- export { useSuspenseQuery } from './hooks/suspense/useSuspenseQuery';
7
- export { useWatchedQuerySuspenseSubscription } from './hooks/suspense/useWatchedQuerySuspenseSubscription';
8
- export { useStatus } from './hooks/useStatus';
9
- export { useQuery } from './hooks/watched/useQuery';
10
- export { useWatchedQuerySubscription } from './hooks/watched/useWatchedQuerySubscription';
11
- export { AdditionalOptions } from './hooks/watched/watch-types';
1
+ export { usePowerSyncQuery } from './hooks/deprecated/usePowerSyncQuery.js';
2
+ export { usePowerSyncStatus } from './hooks/deprecated/usePowerSyncStatus.js';
3
+ export { usePowerSyncWatchedQuery } from './hooks/deprecated/usePowerSyncWatchedQuery.js';
4
+ export * from './hooks/PowerSyncContext.js';
5
+ export { SuspenseQueryResult } from './hooks/suspense/SuspenseQueryResult.js';
6
+ export { useSuspenseQuery } from './hooks/suspense/useSuspenseQuery.js';
7
+ export { useWatchedQuerySuspenseSubscription } from './hooks/suspense/useWatchedQuerySuspenseSubscription.js';
8
+ export { useStatus } from './hooks/useStatus.js';
9
+ export { useQuery } from './hooks/watched/useQuery.js';
10
+ export { useWatchedQuerySubscription } from './hooks/watched/useWatchedQuerySubscription.js';
11
+ export { AdditionalOptions } from './hooks/watched/watch-types.js';
package/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
- export { usePowerSyncQuery } from './hooks/deprecated/usePowerSyncQuery';
2
- export { usePowerSyncStatus } from './hooks/deprecated/usePowerSyncStatus';
3
- export { usePowerSyncWatchedQuery } from './hooks/deprecated/usePowerSyncWatchedQuery';
4
- export * from './hooks/PowerSyncContext';
5
- export { useSuspenseQuery } from './hooks/suspense/useSuspenseQuery';
6
- export { useWatchedQuerySuspenseSubscription } from './hooks/suspense/useWatchedQuerySuspenseSubscription';
7
- export { useStatus } from './hooks/useStatus';
8
- export { useQuery } from './hooks/watched/useQuery';
9
- export { useWatchedQuerySubscription } from './hooks/watched/useWatchedQuerySubscription';
1
+ export { usePowerSyncQuery } from './hooks/deprecated/usePowerSyncQuery.js';
2
+ export { usePowerSyncStatus } from './hooks/deprecated/usePowerSyncStatus.js';
3
+ export { usePowerSyncWatchedQuery } from './hooks/deprecated/usePowerSyncWatchedQuery.js';
4
+ export * from './hooks/PowerSyncContext.js';
5
+ export { useSuspenseQuery } from './hooks/suspense/useSuspenseQuery.js';
6
+ export { useWatchedQuerySuspenseSubscription } from './hooks/suspense/useWatchedQuerySuspenseSubscription.js';
7
+ export { useStatus } from './hooks/useStatus.js';
8
+ export { useQuery } from './hooks/watched/useQuery.js';
9
+ export { useWatchedQuerySubscription } from './hooks/watched/useWatchedQuerySubscription.js';
package/package.json CHANGED
@@ -1,24 +1,18 @@
1
1
  {
2
2
  "name": "@powersync/react",
3
- "version": "0.0.0-dev-20250804151331",
3
+ "version": "0.0.0-dev-20250807074601",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
7
7
  },
8
8
  "description": "React components for JourneyApps PowerSync",
9
+ "type": "module",
9
10
  "main": "./lib/index.js",
10
11
  "module": "./lib/index.js",
11
12
  "types": "./lib/index.d.ts",
12
13
  "files": [
13
14
  "lib"
14
15
  ],
15
- "exports": {
16
- ".": {
17
- "types": "./lib/index.d.ts",
18
- "import": "./lib/index.js",
19
- "default": "./lib/index.js"
20
- }
21
- },
22
16
  "repository": {
23
17
  "type": "git",
24
18
  "url": "git+https://github.com/powersync-ja/powersync-js.git"
@@ -30,7 +24,7 @@
30
24
  },
31
25
  "homepage": "https://docs.powersync.com",
32
26
  "peerDependencies": {
33
- "@powersync/common": "^1.35.0",
27
+ "@powersync/common": "0.0.0-dev-20250807074601",
34
28
  "react": "*"
35
29
  },
36
30
  "devDependencies": {
@@ -41,14 +35,15 @@
41
35
  "react": "18.3.1",
42
36
  "react-dom": "18.3.1",
43
37
  "react-error-boundary": "^4.1.0",
44
- "@powersync/common": "1.35.0",
45
- "@powersync/web": "1.25.0"
38
+ "@powersync/common": "0.0.0-dev-20250807074601",
39
+ "@powersync/web": "0.0.0-dev-20250807074601"
46
40
  },
47
41
  "scripts": {
48
42
  "build": "tsc -b",
49
43
  "build:prod": "tsc -b --sourceMap false",
50
44
  "clean": "rm -rf lib tsconfig.tsbuildinfo",
51
45
  "test": "vitest",
46
+ "test:exports": "attw --pack --profile=esm-only .",
52
47
  "watch": "tsc -b -w"
53
48
  }
54
49
  }