{"version":3,"sources":["../src/lib.ts","../src/components/For.tsx","../src/helpers/nodeToElement.tsx","../src/helpers/renderProp.ts","../src/components/Show.tsx","../src/components/Switch.tsx","../src/components/Match.tsx","../src/components/ErrorBoundary.tsx","../src/components/Dynamic.tsx","../src/components/Portal.tsx","../src/components/Await.tsx","../src/models/Resource.ts","../src/models/AbortError.ts","../src/models/NullishError.ts","../src/hooks/useResource.ts","../src/hooks/useResourceReducer.ts"],"sourcesContent":["export { For } from \"./components/For\";\nexport { Show } from \"./components/Show\";\nexport { Switch } from \"./components/Switch\";\nexport { Match } from \"./components/Match\";\nexport { ErrorBoundary } from \"./components/ErrorBoundary\";\nexport { Dynamic } from \"./components/Dynamic\";\nexport { Portal } from \"./components/Portal\";\nexport { Await } from \"./components/Await\";\n\nexport * from \"./models/Resource\";\nexport { AbortError } from \"./models/AbortError\";\nexport { NullishError } from \"./models/NullishError\";\nexport { useResource } from \"./hooks/useResource\";","import React, { Fragment, isValidElement } from \"react\";\nimport type { ReactElement, ReactNode } from \"react\";\nimport { nodeToElement } from \"../helpers/nodeToElement\";\n\ninterface ForProps<T, U extends ReactNode> {\n  /** Array to iterate over */\n  each: ReadonlyArray<T> | undefined | null;\n  /** RenderProp for children generation\n   * OR a static element displayed each.length times */\n  children: ReactNode | ((item: T, idx: number) => U);\n  /** Fallback item, displayed if *each* has zero length, or isn't an array */\n  fallback?: ReactNode;\n}\n\n/** Component for mapping an array into collection of ReactNode's\n * Omits nullish children and provides keys if they're not specified.\n */\nexport function For<T, U extends ReactNode>({\n  children,\n  each,\n  fallback = null,\n}: ForProps<T, U>): ReactElement | null {\n  if (!Array.isArray(each) || !each.length || children == null) {\n    return nodeToElement(fallback);\n  }\n\n  if (typeof children !== \"function\") {\n    return (\n      <>{each.map((_, idx) => <Fragment key={idx}>{children}</Fragment>)}</>\n    );\n  }\n\n  const content: ReactElement[] = [];\n  for (let i = 0; i < each.length; i++) {\n    const child = children(each[i], i);\n    if (child == null) {\n      continue;\n    }\n    if (!isValidElement(child) || !child.key) {\n      content.push((<Fragment key={i}>{child}</Fragment>));\n    } else {\n      content.push(child);\n    }\n  }\n  if (!content.length) {\n    return nodeToElement(fallback);\n  }\n\n  return <>{content}</>;\n}","import React from \"react\";\nimport { isValidElement } from \"react\";\nimport type { ReactElement, ReactNode } from \"react\";\n\nexport function nodeToElement(item: ReactNode | undefined | null): ReactElement | null {\n  if (item == null) {\n    return null;\n  }\n  if (isValidElement(item)) {\n    return item;\n  }\n  return <>{item}</>;\n}","import type { ReactElement, ReactNode } from \"react\";\nimport { nodeToElement } from \"./nodeToElement\";\n\nexport function renderProp<TArgs extends ReadonlyArray<unknown>>(\n  prop: ((...args: TArgs) => ReactNode) | ReactNode,\n  ...args: TArgs\n): ReactElement | null {\n  if (typeof prop === \"function\") {\n    return nodeToElement(prop(...args));\n  }\n  return nodeToElement(prop);\n}","import { ReactElement, ReactNode } from \"react\";\nimport { nodeToElement } from \"../helpers/nodeToElement\";\nimport { renderProp } from \"../helpers/renderProp\";\n\ninterface ShowProps<T> {\n  /** predicate */\n  when: T | undefined | null | false;\n  /** content (or renderProp) to display when predicate is truthy */\n  children: ReactNode | ((item: NonNullable<T>) => ReactNode);\n  /** content to display when predicate is falsy */\n  fallback?: ReactNode;\n}\n/** Conditional rendering component */\nexport function Show<T>({\n  fallback = null,\n  ...props\n}: ShowProps<T>): ReactElement | null {\n  if (!props.when) {\n    return nodeToElement(fallback);\n  }\n  return renderProp(props.children, props.when);\n}","import { Children, ReactElement, isValidElement } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { nodeToElement } from \"../helpers/nodeToElement\";\n\ninterface SwitchProps {\n  children: ReactNode;\n  /** content to display if no Match predicate is truthy */\n  fallback?: ReactNode;\n}\n/** Component to display one exclusive condition out of many,\n * using Match component\n */\nexport function Switch(props: SwitchProps): ReactElement | null {\n  for (const item of Children.toArray(props.children)) {\n    if (isValidElement(item) && item.props.when) {\n      return item;\n    }\n  }\n  return nodeToElement(props.fallback);\n}","import { ReactElement, ReactNode } from \"react\";\nimport { renderProp } from \"../helpers/renderProp\";\n\ninterface MatchProps<T> {\n  /** predicate */\n  when: T | undefined | null | false;\n  /** content (or renderProp) to display if predicate is truthy */\n  children?: ReactNode | ((item: NonNullable<T>) => ReactNode);\n}\n\n/** Single branch of Switch component. */\nexport function Match<T>({ when, children }: MatchProps<T>): ReactElement | null {\n  if (!when) {\n    return null;\n  }\n  return renderProp(children, when);\n}\n","import { Component } from \"react\";\nimport type { ReactNode } from \"react\";\n\ninterface ErrorBoundaryProps {\n  /** renderProp (or static content) to display if error has occured */\n  fallback?: ReactNode | ((err: unknown, reset: () => void) => ReactNode);\n  /** content to display when no error was catched */\n  children?: ReactNode;\n  /** callback to call, when an error happens */\n  onCatch?: (error: unknown, errorInfo: unknown) => void;\n}\n\ninterface ErrorBoundaryState {\n  error: unknown;\n}\n\n/** General ErrorBoundary component */\nexport class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {\n  constructor(props: ErrorBoundaryProps) {\n    super(props);\n    this.resetError = this.resetError.bind(this);\n  }\n\n  state: ErrorBoundaryState = {\n    error: undefined,\n  };\n\n  static getDerivedStateFromError(error: unknown) {\n    return { error };\n  }\n\n  componentDidCatch(error: unknown, errorInfo: unknown) {\n    this.props.onCatch?.(error, errorInfo);\n    this.setState({ error });\n  }\n\n  resetError() {\n    this.setState({ error: undefined });\n  }\n\n  render() {\n    if (this.state.error === undefined) {\n      return this.props.children;\n    }\n    if (typeof this.props.fallback === \"function\") {\n      return this.props.fallback(this.state.error, this.resetError);\n    }\n    return this.props.fallback;\n  }\n}\n","import React, { forwardRef } from \"react\";\nimport type { ComponentType, ReactElement, Ref, RefAttributes } from \"react\";\n\n/* eslint-disable @typescript-eslint/ban-types */\n// as React types use {} we also use that.\n\nconst genericForwardRef = forwardRef as any as (<T, P = {}>(\n  render: (props: P, ref: Ref<T>) => ReactElement | null\n) => ((props: P & RefAttributes<T>) => ReactElement | null));\n\n\ntype DynamicProps<T> = T & {\n  children?: any;\n  component?: ComponentType<T> | string | keyof JSX.IntrinsicElements;\n}\n\n/** This component lets you insert an arbitrary Component or tag and passes\n * the props through to it.\n * For example, it can be usefull when you need to conditionally render\n * <a> or <span> */\nexport const Dynamic = genericForwardRef(\n  function Dynamic<T extends {}>(\n    {\n      component: Component,\n      ...props\n    }: DynamicProps<T>,\n    ref: Ref<unknown>,\n  ): ReactElement | null {\n    if (!Component) {\n      return null;\n    }\n    return (\n      <Component {...props as any} ref={ref} />\n    );\n  },\n);\n","import { ReactNode, ReactPortal } from \"react\";\nimport { createPortal } from \"react-dom\";\n\ninterface PortalProps {\n  mount?: Element | DocumentFragment | string;\n  // TODO create this for solidJs compatibility?\n  // useShadow?: boolean;\n  children?: ReactNode;\n}\n\n/** Component for rendering children outside of the Component Hierarchy root node. */\nexport function Portal({\n  mount,\n  ...props\n}: PortalProps): ReactPortal | null {\n  const target = (\n    mount == null ||\n    mount instanceof Element ||\n    mount instanceof DocumentFragment\n  ) ? mount : document.querySelector(mount);\n\n  if (!target) {\n    return null;\n  }\n  return createPortal(props.children, target);\n}","import { ReactElement, ReactNode } from \"react\";\nimport { ResourceLike } from \"../models/Resource\";\nimport { renderProp } from \"../helpers/renderProp\";\n\ninterface AwaitProps<T> {\n  /** resource to wait for */\n  for: ResourceLike<T>;\n  /** renderProp (or static content) to display while loading */\n  fallback?: (() => ReactNode) | ReactNode;\n  /** renderProp (or static content) to display if resource was rejected */\n  catch?: ((err: unknown) => ReactNode) | ReactNode;\n  /** renderProp (or static content) to display when resource is resolved */\n  children?: ((data: Awaited<T>) => ReactNode) | ReactNode;\n}\n\n/** Component for displaying a Resource */\nexport function Await<T>(props: AwaitProps<T>): ReactElement | null {\n  if (props.for == null) {\n    return null;\n  }\n  if (props.for.loading) {\n    return renderProp(props.fallback);\n  }\n  if (props.for.error != null) {\n    return renderProp(props.catch, props.for.error);\n  }\n  return renderProp(props.children, props.for.data!);\n}","\nexport interface ResourceLike<T> {\n  /** Is new data currently loading */\n  loading?: boolean;\n  /** Resolved resource data for sync access */\n  data: Awaited<T> | undefined;\n  /** Rejected resource error */\n  error: unknown;\n}\n\nexport type ResourceState = \"unresolved\" | \"pending\" | \"ready\" | \"refreshing\" | \"errored\";\n\nexport class Resource<T> implements ResourceLike<T> {\n  loading: boolean;\n  data: Awaited<T> | undefined;\n  error: unknown;\n\n  /** State name\n   *\n   * | state      | data  | loading | error |\n   * |:-----------|:-----:|:-------:|:-----:|\n   * | unresolved | No    | No      | No    |\n   * | pending    | No    | Yes     | No    |\n   * | ready      | Yes   | No      | No    |\n   * | refreshing | Yes   | Yes     | No    |\n   * | errored    | No    | No      | Yes   |\n   */\n  state: ResourceState;\n  /** last resolved value\n  *\n  * This can be useful if you want to show the out-of-date data while the new\n  * data is loading.\n  */\n  latest: Awaited<T> | undefined;\n\n  constructor(init?: Partial<ResourceLike<T>>, previous?: { latest?: Awaited<T>}) {\n    this.data = init?.data;\n    this.error = init?.error;\n    this.loading = !!init?.loading;\n\n    if (this.data !== undefined) {\n      this.latest = this.data;\n    } else {\n      this.latest = previous?.latest;\n    }\n\n    this.state = Resource.getState(this);\n  }\n\n  static from<T>(data: Promise<T> | Awaited<T> | undefined, pend?: boolean): Resource<T> {\n    const isAsync = data instanceof Promise;\n    return new Resource(isAsync ? {\n      loading: true,\n    } : {\n      data,\n      loading: !!pend,\n    });\n  }\n\n  /**\n   * Determine resource-like state, based on its fields values.\n   *\n   * | state      | data  | loading | error |\n   * |:-----------|:-----:|:-------:|:-----:|\n   * | unresolved | No    | No      | No    |\n   * | pending    | No    | Yes     | No*   |\n   * | ready      | Yes   | No      | No    |\n   * | refreshing | Yes   | Yes     | No*   |\n   * | errored    | No*   | No      | Yes   |\n   *\n   * Values marked with * are expected to equal the specified value,\n   * but actually ignored, when determining the status.\n   */\n  static getState(r: ResourceLike<unknown>): ResourceState {\n    if (r.data !== undefined && r.loading) {\n      return \"refreshing\";\n    }\n    if (r.loading) {\n      return \"pending\";\n    }\n    if (r.error !== undefined) {\n      return \"errored\";\n    }\n    if (r.data !== undefined) {\n      return \"ready\";\n    }\n    return \"unresolved\";\n  }\n}","/*\n * Technically, AbortError should be a descendant of DOMException, but\n * DOMException was only added in node v17.0.0, so we're using Error directly.\n */\nexport class AbortError extends Error {\n  readonly name = \"AbortError\" as const;\n  readonly code = 20 as const;\n\n  constructor(message = \"The operation was aborted.\") {\n    super(message);\n  }\n}","export class NullishError extends Error {\n  readonly name = \"NullishError\" as const;\n}","import { useCallback, useEffect, useRef } from \"react\";\nimport { useResourceReducer } from \"./useResourceReducer\";\nimport type { Resource } from \"../models/Resource\";\nimport type { Initializer } from \"../models/Initializer\";\n\nexport type ResourceReturn<T, TArgs extends readonly unknown[]> = [\n  Resource<T>,\n  {\n    /** Manually set the value.\n     *\n     * If fetcher was currently pending, it's aborted.\n     */\n    mutate: (v: Awaited<T>) => void;\n    /**\n     * Call refetch with supplied args.\n     *\n     * Fetcher opts added automatically. If fetcher was currently pending, it's aborted.\n     */\n    refetch: (...args: TArgs) => Promise<T> | T;\n    /** Imperatively abort the current fetcher call.\n     *\n     * If abort is performed with no reason, or with AbortError instance, then\n     * the state is still considered pending/refreshing, resource.error is\n     * not updated, and onError callback is not called.\n     * Any other reason will result in erorred resource state.\n     *\n     * Resource won't be refetched untill deps change again.\n     */\n    abort: (reason?: any) => void;\n  },\n];\n\nexport type ResourceOptions<T> = {\n  /** Initial value for the resource */\n  initialValue?: Initializer<Awaited<T>>;\n  /** resolve callback */\n  onCompleted?: (data: Awaited<T>) => void;\n  /** rejection callback */\n  onError?: (error: unknown) => void;\n  /** Skip first run (before params change)  */\n  skipFirstRun?: boolean;\n  /** Skip calls of fetcher (can still be called manually with refresh)\n   *\n   * Can be useful if you're waiting for some of deps to be in certain state\n   * before calling the fetcher or if you want to trigger the fetcher only\n   * manually on some event.\n   */\n  skip?: boolean;\n  /** Don't memoize getter, rerun it every time it changes */\n  skipFnMemoization?: boolean;\n};\n\nexport interface FetcherOpts {\n  /** is true, if the call to fetcher was triggered manually with refetch function,\n   * false otherwise */\n  refetching: boolean;\n  /** can be used to abort operations in fetcher function, i.e. passed to fetch options */\n  signal: AbortSignal;\n}\n\nexport function useResource<T, TArgs extends readonly any[]>(\n  fetcher:\n    | ((...args: [...TArgs, FetcherOpts]) => Promise<T> | T)\n    | ((...args: TArgs) => Promise<T> | T),\n  deps: [...TArgs] = [] as unknown as [...TArgs],\n  {\n    initialValue,\n    onCompleted,\n    onError,\n    skipFirstRun = false,\n    skip = false,\n    skipFnMemoization,\n  }: ResourceOptions<T> = {},\n): ResourceReturn<T, TArgs> {\n  // it's actually initialized in the effect bellow, so we don't create empty controllers\n  // on each render\n  const controller = useRef<AbortController>();\n  const skipFirst = useRef<boolean>(skipFirstRun);\n\n  const [resource, dispatch] = useResourceReducer(initialValue, skip || skipFirstRun);\n\n  const mutate = useCallback((val: Awaited<T>) => {\n    controller.current?.abort();\n    controller.current = new AbortController();\n    dispatch({ type: \"SYNC-RESULT\", payload: val });\n  }, [dispatch]);\n\n  const fetcherFn = useCallback(\n    (refetching: boolean, ...args: [...TArgs]): T | Promise<T> => {\n      let val: Promise<T> | T;\n      const cont = controller.current;\n      try {\n        // in theory, this error should never happen, but better be on the safe side\n        if (cont == null) {\n          throw new Error(\"resource state error, abort controller is null during the fetch operation\");\n        }\n        val = fetcher(...[...args, {\n          signal: cont.signal,\n          refetching,\n        }] as unknown as TArgs);\n        if (val instanceof Promise) {\n          handler(val);\n        } else {\n          dispatch({ type: \"SYNC-RESULT\", payload: val as Awaited<T> });\n        }\n        return val;\n      } catch (e) {\n        dispatch({ type: \"REJECT\", payload: e });\n        if (refetching) {\n          throw e;\n        }\n        return undefined as never;\n      }\n\n      async function handler(val: Promise<T>) {\n        dispatch({ type: \"PEND\" });\n        try {\n          const result = await val;\n          // As fetcher can completely ignore AbortController we're checking\n          // for race conditions separately, by checking that AbortController\n          // instance hasn't changed between calls.\n          if (cont !== controller.current) { return }\n          dispatch({ type: \"RESOLVE\", payload: result });\n          onCompleted?.(result);\n        } catch (e) {\n          if (isAbortError(e)) { return }\n          if (cont !== controller.current) { return }\n          dispatch({ type: \"REJECT\", payload: e });\n          onError?.(e);\n        }\n      }\n    },\n    skipFnMemoization ? [fetcher] : [],\n  );\n\n  const refetch = useCallback((...args: TArgs) => {\n    controller.current?.abort();\n    controller.current = new AbortController();\n    return fetcherFn(true, ...args);\n  }, [fetcherFn]);\n\n  const abort = useCallback((reason?: any) => {\n    controller.current?.abort(reason);\n  }, []);\n\n  useEffect(() => {\n    skipFirst.current = skipFirstRun;\n    if (!controller.current) {\n      controller.current = new AbortController();\n    }\n  }, [skipFirstRun]);\n\n  useEffect(() => {\n    if (skipFirst.current) {\n      skipFirst.current = false;\n      return;\n    }\n    if (skip) {\n      return;\n    }\n    fetcherFn(false, ...deps);\n\n    return () => {\n      controller.current?.abort();\n      controller.current = new AbortController();\n    };\n    // onCompleted and onError are intentionally ommited, as we don't want to\n    // retrigger the fetching, if someone forgot to memoize it\n  }, [...deps, skip, fetcherFn]);\n\n  return [resource, { mutate, refetch, abort }];\n}\n\nfunction isAbortError(e: any): e is { name: \"AbortError\" } {\n  // We can't really check if it's an instanceof DOMException as it doesn't\n  // exist in older node version, and we can't check if it's an instanceof\n  // Error, as jsdom implementation of DOMException isn't an instance of it.\n  return e != null && e.name === \"AbortError\";\n}","import { Resource } from \"../models/Resource\";\nimport { useReducer, Reducer } from \"react\";\nimport { NullishError } from \"../models/NullishError\";\nimport type { Initializer } from \"../models/Initializer\";\n\nexport function useResourceReducer<T>(\n  initialValue?: Initializer<Awaited<T>>,\n  skipFirstRun?: boolean,\n) {\n  return useReducer(\n    resourceReducer as Reducer<Resource<T>, Action<T>>,\n    [initialValue, skipFirstRun] as const,\n    resourceInitializer,\n  );\n}\n\nfunction resourceInitializer<T>(init: readonly [\n  val: Initializer<Awaited<T>> | undefined,\n  skip: boolean | undefined,\n]): Resource<T> {\n  const [val, skip = false] = init;\n  const value = (typeof val === \"function\") ? val() : val;\n  return Resource.from(value, !skip);\n}\n\ntype Action<T> =\n  | { type: \"PEND\" /* -> \"pending\" | \"refreshing\" */ }\n  | { type: \"RESOLVE\" /* -> \"ready\" */, payload: Awaited<T> }\n  | { type: \"SYNC-RESULT\" /* -> \"ready\" */, payload: Awaited<T> }\n  | { type: \"REJECT\" /* -> \"errored\" */, payload: any }\n\nexport function resourceReducer<T>(resource: Resource<T>, action: Action<T>): Resource<T> {\n  const type = action?.type;\n  switch (type) {\n    case \"PEND\":\n      return new Resource({\n        loading: true,\n        error: undefined,\n        data: resource.data,\n      }, resource);\n    case \"RESOLVE\":\n      return new Resource({\n        ...resource,\n        loading: false,\n        error: undefined,\n        data: action.payload,\n      }, resource);\n    case \"SYNC-RESULT\":\n      return new Resource({\n        loading: false,\n        error: undefined,\n        data: action.payload,\n      }, resource);\n    case \"REJECT\":\n      return new Resource<T>({\n        loading: false,\n        error: action.payload ?? new NullishError(\n          \"resource rejected with a nullish error\",\n          { cause: action.payload },\n        ),\n        data: undefined,\n      }, resource);\n    default:\n      assertExhaustiveState(type);\n  }\n}\n\nfunction assertExhaustiveState(_: never): never {\n  throw new Error(\"Invalid action type\");\n}\n"],"mappings":"8jBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,gBAAAE,EAAA,UAAAC,EAAA,YAAAC,EAAA,kBAAAC,EAAA,QAAAC,EAAA,UAAAC,EAAA,iBAAAC,EAAA,WAAAC,EAAA,aAAAC,EAAA,SAAAC,EAAA,WAAAC,EAAA,gBAAAC,IAAA,eAAAC,GAAAd,ICAA,IAAAe,EAAgD,sBCAhD,IAAAC,EAAkB,sBAClBA,EAA+B,iBAGxB,SAASC,EAAcC,EAAyD,CACrF,OAAIA,GAAQ,KACH,QAEL,kBAAeA,CAAI,EACdA,EAEF,EAAAC,QAAA,gBAAAA,QAAA,cAAGD,CAAK,CACjB,CDKO,SAASE,EAA4B,CAC1C,SAAAC,EACA,KAAAC,EACA,SAAAC,EAAW,IACb,EAAwC,CACtC,GAAI,CA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AAE,OAAS,YACjC","names":["lib_exports","__export","AbortError","Await","Dynamic","ErrorBoundary","For","Match","NullishError","Portal","Resource","Show","Switch","useResource","__toCommonJS","import_react","import_react","nodeToElement","item","React","For","children","each","fallback","nodeToElement","React","_","idx","content","i","child","renderProp","prop","args","nodeToElement","Show","fallback","props","renderProp","nodeToElement","import_react","Switch","props","item","nodeToElement","Match","when","children","renderProp","import_react","ErrorBoundary","props","error","errorInfo","import_react","genericForwardRef","Dynamic","Component","props","ref","React","import_react_dom","Portal","mount","props","target","Await","props","renderProp","Resource","_Resource","init","previous","data","pend","isAsync","AbortError","message","NullishError","import_react","import_react","useResourceReducer","initialValue","skipFirstRun","resourceReducer","resourceInitializer","init","val","skip","value","Resource","resource","action","type","NullishError","assertExhaustiveState","_","useResource","fetcher","deps","initialValue","onCompleted","onError","skipFirstRun","skip","skipFnMemoization","controller","skipFirst","resource","dispatch","useResourceReducer","mutate","val","fetcherFn","refetching","args","cont","handler","e","result","isAbortError","refetch","abort","reason"]}