@livequery/react 1.0.31 → 1.0.32

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,4 +3,4 @@ import { Transporter } from '@livequery/types';
3
3
  export declare type LiveQueryContextOption = {
4
4
  transporter: Transporter;
5
5
  };
6
- export declare const useLiveQuery: (props?: LiveQueryContextOption) => LiveQueryContextOption, useLiveQueryContext: () => LiveQueryContextOption, LiveQueryContextProvider: ({ children, ...value }: import("react").PropsWithChildren<LiveQueryContextOption>) => JSX.Element;
6
+ export declare const useLiveQueryContext: () => LiveQueryContextOption, LiveQueryContextProvider: ({ children, ...props }: import("react").PropsWithChildren<LiveQueryContextOption>) => JSX.Element;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.LiveQueryContextProvider = exports.useLiveQueryContext = exports.useLiveQuery = void 0;
4
+ exports.LiveQueryContextProvider = exports.useLiveQueryContext = void 0;
5
5
  const createContextFromHook_1 = require("./hooks/createContextFromHook");
6
- _a = createContextFromHook_1.createContextFromHook((props) => props), exports.useLiveQuery = _a[0], exports.useLiveQueryContext = _a[1], exports.LiveQueryContextProvider = _a[2];
6
+ _a = (0, createContextFromHook_1.createContextFromHook)((props) => props), exports.useLiveQueryContext = _a[0], exports.LiveQueryContextProvider = _a[1];
@@ -1,2 +1,2 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
- export declare const createContextFromHook: <T, K>(fn: (props?: T) => K) => [(props?: T) => K, () => K, ({ children, ...value }: React.PropsWithChildren<K>) => JSX.Element];
2
+ export declare const createContextFromHook: <T, K>(fn: (props?: T) => K) => [() => K, ({ children, ...props }: React.PropsWithChildren<T>) => JSX.Element];
@@ -18,12 +18,13 @@ exports.createContextFromHook = void 0;
18
18
  const react_1 = __importDefault(require("react"));
19
19
  const react_2 = require("react");
20
20
  const createContextFromHook = (fn) => {
21
- const context = react_2.createContext({});
22
- const getContext = () => react_2.useContext(context);
21
+ const context = (0, react_2.createContext)({});
22
+ const getContext = () => (0, react_2.useContext)(context);
23
23
  const Provider = (_a) => {
24
- var { children } = _a, value = __rest(_a, ["children"]);
24
+ var { children } = _a, props = __rest(_a, ["children"]);
25
+ const value = fn(props);
25
26
  return (react_1.default.createElement(context.Provider, { value: value }, children));
26
27
  };
27
- return [fn, getContext, Provider];
28
+ return [getContext, Provider];
28
29
  };
29
30
  exports.createContextFromHook = createContextFromHook;
@@ -9,10 +9,10 @@ function assert(fn, thiss) {
9
9
  return (fn || (() => { })).bind(thiss);
10
10
  }
11
11
  const useCollectionData = (ref, collection_options = {}) => {
12
- const { transporter } = LiveQueryContext_1.useLiveQueryContext();
13
- const client = react_1.useMemo(() => ref && new client_1.CollectionObservable(ref, Object.assign({ transporter }, collection_options)), [ref]);
14
- const { loading, has_more, error, items, options } = useObservable_1.useObservable(client, { options: {}, items: [], has_more: false });
15
- react_1.useEffect(() => {
12
+ const { transporter } = (0, LiveQueryContext_1.useLiveQueryContext)();
13
+ const client = (0, react_1.useMemo)(() => ref && new client_1.CollectionObservable(ref, Object.assign({ transporter }, collection_options)), [ref]);
14
+ const { loading, has_more, error, items, options } = (0, useObservable_1.useObservable)(client, { options: {}, items: [], has_more: false });
15
+ (0, react_1.useEffect)(() => {
16
16
  ref && !(collection_options === null || collection_options === void 0 ? void 0 : collection_options.lazy) && client.fetch_more();
17
17
  }, [ref]);
18
18
  return {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useDocumentData = void 0;
4
4
  const useCollectionData_1 = require("./useCollectionData");
5
5
  const useDocumentData = (ref, options) => {
6
- const { items, loading, error, reload } = useCollectionData_1.useCollectionData(ref, options);
6
+ const { items, loading, error, reload } = (0, useCollectionData_1.useCollectionData)(ref, options);
7
7
  return {
8
8
  item: items[0],
9
9
  loading,
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.useMonitor = void 0;
13
13
  const react_1 = require("react");
14
14
  const useMonitor = (fn) => {
15
- const [{ error, data, loading }, update] = react_1.useState({});
15
+ const [{ error, data, loading }, update] = (0, react_1.useState)({});
16
16
  const excute = ((...args) => __awaiter(void 0, void 0, void 0, function* () {
17
17
  update({ data: null, loading: true, error: null });
18
18
  try {
@@ -4,8 +4,8 @@ exports.useObservable = void 0;
4
4
  const react_1 = require("react");
5
5
  const useObservable = (o, default_value) => {
6
6
  let mounting = true;
7
- const [s, ss] = react_1.useState(default_value);
8
- react_1.useEffect(() => {
7
+ const [s, ss] = (0, react_1.useState)(default_value);
8
+ (0, react_1.useEffect)(() => {
9
9
  if (!o)
10
10
  return;
11
11
  const subcription = o === null || o === void 0 ? void 0 : o.subscribe(d => ss(Object.assign({}, d)));
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "repository": {
4
4
  "url": "https://github.com/livequery/react"
5
5
  },
6
- "version": "1.0.31",
6
+ "version": "1.0.32",
7
7
  "description": "",
8
8
  "main": "build/index.js",
9
9
  "types": "build/index.d.ts",
@@ -11,11 +11,11 @@
11
11
  "build/**/*"
12
12
  ],
13
13
  "dependencies": {
14
- "@livequery/client": "^1.0.25"
14
+ "@livequery/client": "^1.0.26"
15
15
  },
16
16
  "devDependencies": {
17
17
  "react": "^17.0.2",
18
- "@livequery/types": "^1.0.31",
18
+ "@livequery/types": "^1.0.34",
19
19
  "@types/react": "^17.0.11"
20
20
  },
21
21
  "peerDependencies": {