@livequery/react 1.0.32 → 1.0.33

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 @@ var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.LiveQueryContextProvider = exports.useLiveQueryContext = void 0;
5
5
  const createContextFromHook_1 = require("./hooks/createContextFromHook");
6
- _a = (0, createContextFromHook_1.createContextFromHook)((props) => props), exports.useLiveQueryContext = _a[0], exports.LiveQueryContextProvider = _a[1];
6
+ _a = createContextFromHook_1.createContextFromHook((props) => props), exports.useLiveQueryContext = _a[0], exports.LiveQueryContextProvider = _a[1];
@@ -18,8 +18,8 @@ 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 = (0, react_2.createContext)({});
22
- const getContext = () => (0, react_2.useContext)(context);
21
+ const context = react_2.createContext({});
22
+ const getContext = () => react_2.useContext(context);
23
23
  const Provider = (_a) => {
24
24
  var { children } = _a, props = __rest(_a, ["children"]);
25
25
  const value = fn(props);
@@ -1,4 +1,4 @@
1
- import { QueryOption } from "../../types/build";
1
+ import { QueryOption } from "@livequery/types";
2
2
  import { CollectionOption } from "@livequery/client";
3
3
  export declare type useCollectionDataOptions<T = any> = CollectionOption<T> & {
4
4
  lazy?: boolean;
@@ -6,10 +6,10 @@ export declare type useCollectionDataOptions<T = any> = CollectionOption<T> & {
6
6
  };
7
7
  export declare const useCollectionData: <T extends {
8
8
  id: string;
9
- }>(ref: string, collection_options?: Partial<useCollectionDataOptions<T>>) => {
9
+ }>(ref: string | undefined | '' | null | 0 | false, collection_options?: Partial<useCollectionDataOptions<T>>) => {
10
10
  items: import("@livequery/client").SmartQueryItem<T>[];
11
11
  loading: boolean;
12
- error: import("../../types/build").ErrorInfo;
12
+ error: import("@livequery/types").ErrorInfo;
13
13
  has_more: boolean;
14
14
  empty: boolean;
15
15
  filters: Partial<QueryOption<T>>;
@@ -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 } = (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)(() => {
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(() => {
16
16
  ref && !(collection_options === null || collection_options === void 0 ? void 0 : collection_options.lazy) && client.fetch_more();
17
17
  }, [ref]);
18
18
  return {
@@ -4,7 +4,7 @@ export declare type useDocumentDataOptions<T = any> = Omit<CollectionOption<T>,
4
4
  };
5
5
  export declare const useDocumentData: <T extends {
6
6
  id: string;
7
- }>(ref: string, options?: useDocumentDataOptions) => {
7
+ }>(ref: string | undefined | '' | null | 0 | false, options?: useDocumentDataOptions) => {
8
8
  item: import("@livequery/client").SmartQueryItem<T>;
9
9
  loading: boolean;
10
10
  error: import("@livequery/types").ErrorInfo;
@@ -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 } = (0, useCollectionData_1.useCollectionData)(ref, options);
6
+ const { items, loading, error, reload } = 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] = (0, react_1.useState)({});
15
+ const [{ error, data, loading }, update] = 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] = (0, react_1.useState)(default_value);
8
- (0, react_1.useEffect)(() => {
7
+ const [s, ss] = react_1.useState(default_value);
8
+ 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.32",
6
+ "version": "1.0.33",
7
7
  "description": "",
8
8
  "main": "build/index.js",
9
9
  "types": "build/index.d.ts",