Skip to content

Commit

Permalink
type: module
Browse files Browse the repository at this point in the history
  • Loading branch information
hazae41 committed Oct 10, 2022
1 parent add66c9 commit 34a9443
Show file tree
Hide file tree
Showing 105 changed files with 830 additions and 2,110 deletions.
1 change: 1 addition & 0 deletions dist/index.cjs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * as XSWR from "./mods";
export * as XSWR from "./mods/index.js";
2 changes: 1 addition & 1 deletion dist/index.esm.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/index.js

This file was deleted.

16 changes: 8 additions & 8 deletions dist/mods/core.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/// <reference types="node" />
import { Ortho } from "../libs/ortho";
import { ScrollHelper } from "./scroll";
import { SingleHelper } from "./single";
import { Mutator } from "./types/mutator";
import { Params } from "./types/params";
import { State } from "./types/state";
import { Lock } from "./utils/lock";
/// <reference types="node" resolution-mode="require"/>
import { Ortho } from "../libs/ortho.js";
import { ScrollHelper } from "./scroll/helper.js";
import { SingleHelper } from "./single/helper.js";
import { Mutator } from "./types/mutator.js";
import { Params } from "./types/params.js";
import { State } from "./types/state.js";
import { Lock } from "./utils/lock.js";
export declare type Listener<D = any, E = any, K = any> = (x?: State<D, E, K>) => void;
export declare class Core extends Ortho<string, State | undefined> {
readonly params: Params;
Expand Down
2 changes: 1 addition & 1 deletion dist/mods/errors/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./abort";
export * from "./abort.js";
16 changes: 8 additions & 8 deletions dist/mods/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export * from "./core";
export * from "./errors";
export * from "./react";
export * from "./scroll";
export * from "./single";
export * from "./storages";
export * from "./types";
export * from "./utils";
export * from "./core.js";
export * from "./errors/index.js";
export * from "./react/index.js";
export * from "./scroll/index.js";
export * from "./single/index.js";
export * from "./storages/index.js";
export * from "./types/index.js";
export * from "./utils/index.js";
8 changes: 4 additions & 4 deletions dist/mods/react/contexts/core.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChildrenProps } from "../../../libs/react";
import { Core } from "../../core";
import { Params } from "../../types/params";
import * as React from "react";
import { ChildrenProps } from "../../../libs/react.js";
import { Core } from "../../core.js";
import { Params } from "../../types/params.js";
import React from "react";
export declare const CoreContext: React.Context<Core | undefined>;
export declare function useCore(): Core;
export declare function useCoreProvider(params: Params): Core;
Expand Down
2 changes: 1 addition & 1 deletion dist/mods/react/contexts/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./core";
export * from "./core.js";
20 changes: 10 additions & 10 deletions dist/mods/react/hooks/blocks/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export * from "./use-debug";
export * from "./use-error";
export * from "./use-fallback";
export * from "./use-fetch";
export * from "./use-interval";
export * from "./use-mount";
export * from "./use-once";
export * from "./use-online";
export * from "./use-retry";
export * from "./use-visible";
export * from "./use-debug.js";
export * from "./use-error.js";
export * from "./use-fallback.js";
export * from "./use-fetch.js";
export * from "./use-interval.js";
export * from "./use-mount.js";
export * from "./use-once.js";
export * from "./use-online.js";
export * from "./use-retry.js";
export * from "./use-visible.js";
2 changes: 1 addition & 1 deletion dist/mods/react/hooks/blocks/use-debug.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Handle } from "../handles";
import { Handle } from "../handles/handle.js";
/**
* Show handle in console when it changes
* @param handle
Expand Down
2 changes: 1 addition & 1 deletion dist/mods/react/hooks/blocks/use-error.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Handle } from "../handles";
import { Handle } from "../handles/handle.js";
/**
* Call a function on error
* @param handle
Expand Down
4 changes: 2 additions & 2 deletions dist/mods/react/hooks/blocks/use-fallback.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Handle } from "../handles";
import { State } from "../../../types/state";
import { Handle } from "../handles/handle.js";
import { State } from "../../../types/state.js";
/**
* Fallback to given data/error if there is no data/error
* @example You got some data/error using SSR/ISR and want to display it on first render
Expand Down
2 changes: 1 addition & 1 deletion dist/mods/react/hooks/blocks/use-fetch.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Handle } from "../handles";
import { Handle } from "../handles/handle.js";
/**
* Do a request on mount and url change
* @see useMount for doing a request on mount only
Expand Down
2 changes: 1 addition & 1 deletion dist/mods/react/hooks/blocks/use-interval.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Handle } from "../handles";
import { Handle } from "../handles/handle.js";
/**
* Do a request on interval
* @see useRetry for error retry
Expand Down
2 changes: 1 addition & 1 deletion dist/mods/react/hooks/blocks/use-mount.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Handle } from "../handles";
import { Handle } from "../handles/handle.js";
/**
* Do a request on mount only
* @see useFetch for doing a request on url change
Expand Down
2 changes: 1 addition & 1 deletion dist/mods/react/hooks/blocks/use-once.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Handle } from "../handles";
import { Handle } from "../handles/handle.js";
/**
* Do a request on mount and url change only if there is no data yet
* @warning Will still try to fetch is there is an error
Expand Down
2 changes: 1 addition & 1 deletion dist/mods/react/hooks/blocks/use-online.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Handle } from "../handles";
import { Handle } from "../handles/handle.js";
/**
* Do a request when the browser is online
* @param handle
Expand Down
2 changes: 1 addition & 1 deletion dist/mods/react/hooks/blocks/use-retry.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Handle } from "../handles";
import { Handle } from "../handles/handle.js";
export interface RetryOptions {
init?: number;
base?: number;
Expand Down
2 changes: 1 addition & 1 deletion dist/mods/react/hooks/blocks/use-visible.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Handle } from "../handles";
import { Handle } from "../handles/handle.js";
/**
* Do a request when the tab is visible
* @param handle
Expand Down
4 changes: 2 additions & 2 deletions dist/mods/react/hooks/handles/handle.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Mutator } from "../../../types/mutator";
import { State } from "../../../types/state";
import { Mutator } from "../../../types/mutator.js";
import { State } from "../../../types/state.js";
export interface Handle<D = any, E = any, K = any> {
/**
* Arbitrary key, must be serializable
Expand Down
8 changes: 4 additions & 4 deletions dist/mods/react/hooks/handles/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from "./handle";
export * from "./router";
export * from "./scroll";
export * from "./single";
export * from "./handle.js";
export * from "./router.js";
export * from "./scroll.js";
export * from "./single.js";
8 changes: 4 additions & 4 deletions dist/mods/react/hooks/handles/router.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ScrollSchema } from "../../../scroll";
import { SingleSchema } from "../../../single";
import { ScrollSchema } from "../../../scroll/schema.js";
import { SingleSchema } from "../../../single/schema.js";
import { DependencyList } from "react";
import { ScrollHandle } from "./scroll";
import { SingleHandle } from "./single";
import { ScrollHandle } from "./scroll.js";
import { SingleHandle } from "./single.js";
export declare function use<D = any, E = any, K = any, L extends DependencyList = []>(factory: (...deps: L) => SingleSchema<D, E, K>, deps: L): SingleHandle<D, E, K>;
export declare function use<D = any, E = any, K = any, L extends DependencyList = []>(factory: (...deps: L) => ScrollSchema<D, E, K>, deps: L): ScrollHandle<D, E, K>;
10 changes: 5 additions & 5 deletions dist/mods/react/hooks/handles/scroll.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Fetcher } from "../../../types/fetcher";
import { Params } from "../../../types/params";
import { Scroller } from "../../../types/scroller";
import { State } from "../../../types/state";
import { Handle } from "./handle";
import { Fetcher } from "../../../types/fetcher.js";
import { Params } from "../../../types/params.js";
import { Scroller } from "../../../types/scroller.js";
import { State } from "../../../types/state.js";
import { Handle } from "./handle.js";
/**
* Handle for a scrolling resource
*/
Expand Down
10 changes: 5 additions & 5 deletions dist/mods/react/hooks/handles/single.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Fetcher } from "../../../index";
import { Params } from "../../../types/params";
import { State } from "../../../types/state";
import { Updater, UpdaterParams } from "../../../types/updater";
import { Handle } from "./handle";
import { Fetcher } from "../../../types/fetcher.js";
import { Params } from "../../../types/params.js";
import { State } from "../../../types/state.js";
import { Updater, UpdaterParams } from "../../../types/updater.js";
import { Handle } from "./handle.js";
/**
* Handle for a single resource
*/
Expand Down
6 changes: 3 additions & 3 deletions dist/mods/react/hooks/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./blocks";
export * from "./handles";
export * from "./xswr";
export * from "./blocks/index.js";
export * from "./handles/index.js";
export * from "./xswr.js";
6 changes: 3 additions & 3 deletions dist/mods/react/hooks/xswr.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Object } from "../../types/object";
import { Schema } from "../../types/schema";
import { Object } from "../../types/object.js";
import { Schema } from "../../types/schema.js";
export declare type Maker = <D = any, E = any, K = any, O extends Object<D, E, K> = Object<D, E, K>>(schema: Schema<D, E, K, O>) => O;
export declare function useXSWR(): {
core: import("../../core").Core;
core: import("../../core.js").Core;
make: Maker;
};
4 changes: 2 additions & 2 deletions dist/mods/react/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./contexts";
export * from "./hooks";
export * from "./contexts/index.js";
export * from "./hooks/index.js";
10 changes: 5 additions & 5 deletions dist/mods/scroll/helper.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Core } from "../core";
import { Fetcher } from "../types/fetcher";
import { Params } from "../types/params";
import { Scroller } from "../types/scroller";
import { State } from "../types/state";
import { Core } from "../core.js";
import { Fetcher } from "../types/fetcher.js";
import { Params } from "../types/params.js";
import { Scroller } from "../types/scroller.js";
import { State } from "../types/state.js";
export declare class ScrollHelper {
readonly core: Core;
constructor(core: Core);
Expand Down
6 changes: 3 additions & 3 deletions dist/mods/scroll/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./helper";
export * from "./object";
export * from "./schema";
export * from "./helper.js";
export * from "./object.js";
export * from "./schema.js";
14 changes: 7 additions & 7 deletions dist/mods/scroll/object.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Core } from "../core";
import { Fetcher } from "../index";
import { Mutator } from "../types/mutator";
import { Object } from "../types/object";
import { Params } from "../types/params";
import { Scroller } from "../types/scroller";
import { State } from "../types/state";
import { Core } from "../core.js";
import { Fetcher } from "../types/fetcher.js";
import { Mutator } from "../types/mutator.js";
import { Object } from "../types/object.js";
import { Params } from "../types/params.js";
import { Scroller } from "../types/scroller.js";
import { State } from "../types/state.js";
export declare function getScrollStorageKey<D = any, E = any, K = any>(key: K, params: Params): string | undefined;
/**
* Non-React version of ScrollHandle
Expand Down
14 changes: 7 additions & 7 deletions dist/mods/scroll/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Core } from "../core";
import { NormalizerMore } from "../index";
import { Fetcher } from "../types/fetcher";
import { Params } from "../types/params";
import { Schema } from "../types/schema";
import { Scroller } from "../types/scroller";
import { ScrollObject } from "./object";
import { Core } from "../core.js";
import { Fetcher } from "../types/fetcher.js";
import { NormalizerMore } from "../types/normalizer.js";
import { Params } from "../types/params.js";
import { Schema } from "../types/schema.js";
import { Scroller } from "../types/scroller.js";
import { ScrollObject } from "./object.js";
export declare function scroll<D = any, E = any, K = any>(scroller: Scroller<D, E, K>, fetcher: Fetcher<D, E, K> | undefined, params?: Params<D[], E, K>): ScrollSchema<D, E, K>;
export declare class ScrollSchema<D = any, E = any, K = any> implements Schema<D[], E, K, ScrollObject<D, E, K>> {
readonly scroller: Scroller<D, E, K>;
Expand Down
10 changes: 5 additions & 5 deletions dist/mods/single/helper.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Core } from "../core";
import { Fetcher } from "../types/fetcher";
import { Params } from "../types/params";
import { State } from "../types/state";
import { Updater } from "../types/updater";
import { Core } from "../core.js";
import { Fetcher } from "../types/fetcher.js";
import { Params } from "../types/params.js";
import { State } from "../types/state.js";
import { Updater } from "../types/updater.js";
export declare class SingleHelper {
readonly core: Core;
constructor(core: Core);
Expand Down
6 changes: 3 additions & 3 deletions dist/mods/single/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./helper";
export * from "./object";
export * from "./schema";
export * from "./helper.js";
export * from "./object.js";
export * from "./schema.js";
14 changes: 7 additions & 7 deletions dist/mods/single/object.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Core } from "../core";
import { Fetcher } from "../index";
import { Mutator } from "../types/mutator";
import { Object } from "../types/object";
import { Params } from "../types/params";
import { State } from "../types/state";
import { Updater, UpdaterParams } from "../types/updater";
import { Core } from "../core.js";
import { Fetcher } from "../types/fetcher.js";
import { Mutator } from "../types/mutator.js";
import { Object } from "../types/object.js";
import { Params } from "../types/params.js";
import { State } from "../types/state.js";
import { Updater, UpdaterParams } from "../types/updater.js";
export declare function getSingleStorageKey<D = any, E = any, K = any>(key: K, params: Params): string | undefined;
/**
* Non-React version of SingleHandle
Expand Down
12 changes: 6 additions & 6 deletions dist/mods/single/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Core } from "../core";
import { Fetcher } from "../index";
import { NormalizerMore } from "../types/normalizer";
import { Params } from "../types/params";
import { Schema } from "../types/schema";
import { SingleObject } from "./object";
import { Core } from "../core.js";
import { Fetcher } from "../types/fetcher.js";
import { NormalizerMore } from "../types/normalizer.js";
import { Params } from "../types/params.js";
import { Schema } from "../types/schema.js";
import { SingleObject } from "./object.js";
export declare function single<D = any, E = any, K = any>(key: K | undefined, fetcher: Fetcher<D, E, K> | undefined, params?: Params<D, E, K>): SingleSchema<D, E, K>;
export declare class SingleSchema<D = any, E = any, K = any> implements Schema<D, E, K, SingleObject<D, E, K>> {
readonly key: K | undefined;
Expand Down
2 changes: 1 addition & 1 deletion dist/mods/storages/idb/async.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AsyncStorage } from "../../types/storage";
import { AsyncStorage } from "../../types/storage.js";
export declare function useIDBStorage(name: string): IDBStorage;
export declare class IDBStorage implements AsyncStorage {
readonly name: string;
Expand Down
2 changes: 1 addition & 1 deletion dist/mods/storages/idb/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./async";
export * from "./async.js";
4 changes: 2 additions & 2 deletions dist/mods/storages/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./idb";
export * from "./localStorage";
export * from "./idb/index.js";
export * from "./localStorage/index.js";
4 changes: 2 additions & 2 deletions dist/mods/storages/localStorage/async.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Serializer } from "../../types/serializer";
import { AsyncStorage } from "../../types/storage";
import { Serializer } from "../../types/serializer.js";
import { AsyncStorage } from "../../types/storage.js";
/**
* Asynchronous local storage
*
Expand Down
4 changes: 2 additions & 2 deletions dist/mods/storages/localStorage/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./async";
export * from "./sync";
export * from "./async.js";
export * from "./sync.js";
4 changes: 2 additions & 2 deletions dist/mods/storages/localStorage/sync.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Serializer } from "../../types/serializer";
import { SyncStorage } from "../../types/storage";
import { Serializer } from "../../types/serializer.js";
import { SyncStorage } from "../../types/storage.js";
/**
* Synchronous local storage
*
Expand Down
2 changes: 1 addition & 1 deletion dist/mods/types/fetcher.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Result } from "./result";
import { Result } from "./result.js";
export declare type Fetcher<D = any, E = any, K = any> = (key: K, more: FetcherMore) => Promise<Result<D, E, K>>;
export interface FetcherMore<D = any, E = any, K = any> {
signal?: AbortSignal;
Expand Down
22 changes: 11 additions & 11 deletions dist/mods/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export * from "./fetcher";
export * from "./normalizer";
export * from "./object";
export * from "./params";
export * from "./result";
export * from "./schema";
export * from "./scroller";
export * from "./serializer";
export * from "./state";
export * from "./storage";
export * from "./updater";
export * from "./fetcher.js";
export * from "./normalizer.js";
export * from "./object.js";
export * from "./params.js";
export * from "./result.js";
export * from "./schema.js";
export * from "./scroller.js";
export * from "./serializer.js";
export * from "./state.js";
export * from "./storage.js";
export * from "./updater.js";
Loading

0 comments on commit 34a9443

Please sign in to comment.