diff --git a/CHANGELOG.md b/CHANGELOG.md index ee0778eb5..4a972ba4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). - @@ -30,6 +40,7 @@ _2020-04-05_ - [useValidation] - Fix tracking of `$value` when is not `ref` - [TailwindCSS](https://pikax.me/vue-composable/composable/breakpoint/breakpointTailwindCSS) - improve typings and fix bug when sending custom breakpoints + > > > > > > > master ## 1.0.0-dev.16 diff --git a/docs/.vuepress/components/ValidationExample.vue b/docs/.vuepress/components/ValidationExample.vue index 9cdbc4bef..4e4e61976 100644 --- a/docs/.vuepress/components/ValidationExample.vue +++ b/docs/.vuepress/components/ValidationExample.vue @@ -25,12 +25,12 @@ diff --git a/docs/.vuepress/components/WorkerFunctionExample.vue b/docs/.vuepress/components/WorkerFunctionExample.vue new file mode 100644 index 000000000..1468b0b46 --- /dev/null +++ b/docs/.vuepress/components/WorkerFunctionExample.vue @@ -0,0 +1,108 @@ + + + diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 932f6be45..0d73570dc 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -171,7 +171,9 @@ module.exports = { ["composable/web/language", "Language"], ["composable/web/broadcastChannel", "BroadcastChannel API"], ["composable/web/geolocation", "Geolocation API"], - ["composable/web/cssVariables", "CSS variables"] + ["composable/web/cssVariables", "CSS variables"], + ["composable/web/worker", "WebWorker API"], + ["composable/web/workerFunction", "WebWorker Function"] ] }, { diff --git a/docs/.vuepress/public/worker.example.js b/docs/.vuepress/public/worker.example.js new file mode 100644 index 000000000..ad636968e --- /dev/null +++ b/docs/.vuepress/public/worker.example.js @@ -0,0 +1,56 @@ +// expose worker code without typing +// based from https://github.com/dai-shi/react-hooks-worker/blob/1e842ad15c558fc04dd7339a62aaa43f46d1c7cd/src/exposeWorker.js +// code from /packages/web/worker.ts +function exposeWorker(func) { + this.onmessage = async e => { + const r = func(e.data); + + if (r === undefined) { + if (__DEV__) { + console.warn( + `[exposeWorker] returned \`${r}\`, this might cause unexpected behaviour` + ); + } + this.postMessage(r); + } else if (r === null) { + this.postMessage(r); + } else if (Array.isArray(r)) { + this.postMessage(r); + } else if (r[Symbol.asyncIterator]) { + for await (const i of r) this.postMessage(i); + } else if (r[Symbol.iterator]) { + for (const i of r) this.postMessage(i); + } else { + this.postMessage(await r); + } + }; +} +// / exposeWorker + +function* bubbleSort(input) { + let swap; + let n = input.length - 1; + const sortedArray = input.slice(); + + yield ["sorting", `${input.length} items`]; + do { + swap = false; + for (let index = 0; index < n; index += 1) { + if (sortedArray[index] > sortedArray[index + 1]) { + const tmp = sortedArray[index]; + sortedArray[index] = sortedArray[index + 1]; + sortedArray[index + 1] = tmp; + swap = true; + } + } + n -= 1; + + if (Math.floor(input.length / 2) === n) { + yield ["sorted", `${n} items processed`]; + } + } while (swap); + + yield sortedArray; +} + +exposeWorker(bubbleSort); diff --git a/docs/README.md b/docs/README.md index 7be903b9b..133678c69 100644 --- a/docs/README.md +++ b/docs/README.md @@ -105,6 +105,8 @@ Check out the [examples folder](examples) or start hacking on [codesandbox](http - [BroadcastChannel](composable/web/broadcastChannel) - reactive `BroadcastChannel API` - [Geolocation](composable/web/geolocation) - reactive `Geolocation API` - [CSS variables](composable/web/cssVariables) - reactive `CSS variables` +- [Worker](https://pikax.me/vue-composable/composable/web/worker) - `Web worker API` +- [WorkerFunction](https://pikax.me/vue-composable/composable/web/workerFunction) - Webworker Function, offload a function to webworker ### Validation diff --git a/docs/api/core.api.md b/docs/api/core.api.md index 3736812c6..ede0a9c0c 100644 --- a/docs/api/core.api.md +++ b/docs/api/core.api.md @@ -3,13 +3,13 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts - -import { Ref } from '@vue/composition-api'; +import { Ref } from "@vue/composition-api"; // @public (undocumented) -export interface ArrayPaginationResult> extends PaginationResult { - // (undocumented) - result: Readonly>; +export interface ArrayPaginationResult> + extends PaginationResult { + // (undocumented) + result: Readonly>; } // Warning: (ae-forgotten-export) The symbol "i18nDefinition" needs to be exported by the entry point index.d.ts @@ -17,21 +17,36 @@ export interface ArrayPaginationResult> extends PaginationR // Warning: (ae-forgotten-export) The symbol "I18nExtractLocale" needs to be exported by the entry point index.d.ts // // @public (undocumented) -export function buildI18n, TMessage extends Record Promise)>>(definition: T): i18nResult>; +export function buildI18n< + T extends i18nDefinition, + TMessage extends Record Promise)> +>( + definition: T +): i18nResult< + keyof T["messages"], + I18nExtractLocale +>; // @public (undocumented) export interface CancellablePromiseResult { - // (undocumented) - cancel: (result?: TCancel) => void; - // (undocumented) - cancelled: Ref; + // (undocumented) + cancel: (result?: TCancel) => void; + // (undocumented) + cancelled: Ref; } // @public (undocumented) -export function debounce(func: F, waitMilliseconds?: number, options?: Options): F; +export function debounce( + func: F, + waitMilliseconds?: number, + options?: Options +): F; // @public (undocumented) -export function deepClone(result: T, ...sources: T[]): T; +export function deepClone( + result: T, + ...sources: T[] +): T; // Warning: (ae-forgotten-export) The symbol "RetryDelayFactory" needs to be exported by the entry point index.d.ts // @@ -43,18 +58,20 @@ export const FALSE_OP: () => boolean; // @public (undocumented) export interface FormatObject { - // (undocumented) - [id: string]: FormatValue; + // (undocumented) + [id: string]: FormatValue; } // @public (undocumented) -export type FormatValue = RefTyped | RefTyped | RefTyped; +export type FormatValue = + | RefTyped + | RefTyped + | RefTyped; // Warning: (ae-forgotten-export) The symbol "i18nMessageValue" needs to be exported by the entry point index.d.ts // // @public (undocumented) -export interface i18n extends Record { -} +export interface i18n extends Record {} // @public (undocumented) export const isArray: (arg: any) => arg is any[]; @@ -100,47 +117,47 @@ export const noDelay: RetryDelayFactory; // @public (undocumented) export interface NowOptions { - refreshMs?: number; - sync?: boolean; + refreshMs?: number; + sync?: boolean; } // @public (undocumented) export type Options = { - isImmediate: boolean; + isImmediate: boolean; }; // @public (undocumented) export interface PaginationOptions { - // (undocumented) - currentPage: RefTyped; - // (undocumented) - pageSize: RefTyped; - // (undocumented) - total: RefTyped; + // (undocumented) + currentPage: RefTyped; + // (undocumented) + pageSize: RefTyped; + // (undocumented) + total: RefTyped; } // @public (undocumented) export interface PaginationResult { - // (undocumented) - currentPage: Ref; - // (undocumented) - first: PaginationControl; - // (undocumented) - last: PaginationControl; - // (undocumented) - lastPage: Readonly>; - // Warning: (ae-forgotten-export) The symbol "PaginationControl" needs to be exported by the entry point index.d.ts - // - // (undocumented) - next: PaginationControl; - // (undocumented) - offset: Ref; - // (undocumented) - pageSize: Ref; - // (undocumented) - prev: PaginationControl; - // (undocumented) - total: Ref; + // (undocumented) + currentPage: Ref; + // (undocumented) + first: PaginationControl; + // (undocumented) + last: PaginationControl; + // (undocumented) + lastPage: Readonly>; + // Warning: (ae-forgotten-export) The symbol "PaginationControl" needs to be exported by the entry point index.d.ts + // + // (undocumented) + next: PaginationControl; + // (undocumented) + offset: Ref; + // (undocumented) + pageSize: Ref; + // (undocumented) + prev: PaginationControl; + // (undocumented) + total: Ref; } // @public (undocumented) @@ -154,18 +171,21 @@ export function promisedTimeout(timeout: number): Promise; // @public (undocumented) export interface PromiseOptions { - lazy?: boolean; - throwException?: boolean; + lazy?: boolean; + throwException?: boolean; } // Warning: (ae-forgotten-export) The symbol "PromiseResult" needs to be exported by the entry point index.d.ts // // @public (undocumented) -export interface PromiseResultFactory, TArgs extends Array = Array> extends PromiseResult { - // Warning: (ae-forgotten-export) The symbol "PromiseType" needs to be exported by the entry point index.d.ts - // - // (undocumented) - exec: (...args: TArgs) => Promise | undefined>; +export interface PromiseResultFactory< + T extends Promise, + TArgs extends Array = Array +> extends PromiseResult { + // Warning: (ae-forgotten-export) The symbol "PromiseType" needs to be exported by the entry point index.d.ts + // + // (undocumented) + exec: (...args: TArgs) => Promise | undefined>; } // @public (undocumented) @@ -177,17 +197,26 @@ export type RefTyped = T | Ref; // Warning: (ae-forgotten-export) The symbol "RetryReturn" needs to be exported by the entry point index.d.ts // // @public (undocumented) -export interface RetryReturnFactory> extends RetryReturn { - exec(...args: TArgs): T; +export interface RetryReturnFactory> + extends RetryReturn { + exec(...args: TArgs): T; } // @public (undocumented) export interface RetryReturnNoFactory extends RetryReturn { - exec(fn: () => T): T; + exec(fn: () => T): T; } // @public (undocumented) -export function setI18n, TMessage extends Record Promise)>>(definition: T): i18nResult>; +export function setI18n< + T extends i18nDefinition, + TMessage extends Record Promise)> +>( + definition: T +): i18nResult< + keyof T["messages"], + I18nExtractLocale +>; // @public (undocumented) export function unwrap(o: RefTyped): T; @@ -196,162 +225,301 @@ export function unwrap(o: RefTyped): T; export type UnwrapRef = T extends Ref ? R : T; // @public (undocumented) -export function useArrayPagination, TR>(array: RefTyped, options?: Partial>): ArrayPaginationResult; +export function useArrayPagination, TR>( + array: RefTyped, + options?: Partial> +): ArrayPaginationResult; // @public (undocumented) -export function useCancellablePromise>(fn: (...args: TArgs) => Promise): PromiseResultFactory, TArgs> & CancellablePromiseResult; +export function useCancellablePromise>( + fn: (...args: TArgs) => Promise +): PromiseResultFactory, TArgs> & CancellablePromiseResult; // @public (undocumented) -export function useCancellablePromise>(fn: (...args: TArgs) => Promise, lazy: boolean): PromiseResultFactory, TArgs> & CancellablePromiseResult; +export function useCancellablePromise>( + fn: (...args: TArgs) => Promise, + lazy: boolean +): PromiseResultFactory, TArgs> & CancellablePromiseResult; // @public (undocumented) -export function useCancellablePromise>(fn: (...args: TArgs) => Promise, options: PromiseOptions): PromiseResultFactory, TArgs> & CancellablePromiseResult; +export function useCancellablePromise>( + fn: (...args: TArgs) => Promise, + options: PromiseOptions +): PromiseResultFactory, TArgs> & CancellablePromiseResult; // @public (undocumented) -export function useCancellablePromise(fn: () => T): PromiseResultFactory> & CancellablePromiseResult; +export function useCancellablePromise( + fn: () => T +): PromiseResultFactory> & CancellablePromiseResult; // @public (undocumented) -export function useCancellablePromise(fn: () => T, lazy: boolean): PromiseResultFactory> & CancellablePromiseResult; +export function useCancellablePromise( + fn: () => T, + lazy: boolean +): PromiseResultFactory> & CancellablePromiseResult; // @public (undocumented) -export function useCancellablePromise(fn: () => T, options: PromiseOptions): PromiseResultFactory> & CancellablePromiseResult; +export function useCancellablePromise( + fn: () => T, + options: PromiseOptions +): PromiseResultFactory> & CancellablePromiseResult; // @public (undocumented) -export function useCancellablePromise, TR, TArgs extends Array>(fn: (...args: TArgs) => T): PromiseResultFactory & CancellablePromiseResult; +export function useCancellablePromise< + T extends Promise, + TR, + TArgs extends Array +>( + fn: (...args: TArgs) => T +): PromiseResultFactory & CancellablePromiseResult; // @public (undocumented) -export function useCancellablePromise, TR, TArgs extends Array>(fn: (...args: TArgs) => T, lazy: boolean): PromiseResultFactory & CancellablePromiseResult; +export function useCancellablePromise< + T extends Promise, + TR, + TArgs extends Array +>( + fn: (...args: TArgs) => T, + lazy: boolean +): PromiseResultFactory & CancellablePromiseResult; // @public (undocumented) -export function useCancellablePromise, TR, TArgs extends Array>(fn: (...args: TArgs) => T, options: PromiseOptions): PromiseResultFactory & CancellablePromiseResult; +export function useCancellablePromise< + T extends Promise, + TR, + TArgs extends Array +>( + fn: (...args: TArgs) => T, + options: PromiseOptions +): PromiseResultFactory & CancellablePromiseResult; // @public (undocumented) -export function useCancellablePromise(fn: () => T): PromiseResultFactory> & CancellablePromiseResult; +export function useCancellablePromise( + fn: () => T +): PromiseResultFactory> & CancellablePromiseResult; // @public (undocumented) -export function useCancellablePromise(fn: () => T, lazy: boolean): PromiseResultFactory> & CancellablePromiseResult; +export function useCancellablePromise( + fn: () => T, + lazy: boolean +): PromiseResultFactory> & CancellablePromiseResult; // @public (undocumented) -export function useCancellablePromise(fn: () => T, options: PromiseOptions): PromiseResultFactory> & CancellablePromiseResult; +export function useCancellablePromise( + fn: () => T, + options: PromiseOptions +): PromiseResultFactory> & CancellablePromiseResult; // @public (undocumented) -export function useCancellablePromise, TR>(fn: () => T): PromiseResultFactory & CancellablePromiseResult; +export function useCancellablePromise, TR>( + fn: () => T +): PromiseResultFactory & CancellablePromiseResult; // @public -export function useDateNow(options?: NowOptions): { - now: import("@vue/composition-api").Ref; - remove: () => void; +export function useDateNow( + options?: NowOptions +): { + now: import("@vue/composition-api").Ref; + remove: () => void; }; // @public -export function useDebounce(handler: T, wait?: number, options?: Options): T; +export function useDebounce( + handler: T, + wait?: number, + options?: Options +): T; // @public (undocumented) -export function useFormat(format: RefTyped>, obj?: RefTyped): Readonly>; +export function useFormat( + format: RefTyped>, + obj?: RefTyped +): Readonly>; // @public (undocumented) -export function useFormat(format: Readonly>, obj?: RefTyped): Readonly>; +export function useFormat( + format: Readonly>, + obj?: RefTyped +): Readonly>; // @public (undocumented) -export function useFormat(format: Readonly>, ...args: Array): Readonly>; +export function useFormat( + format: Readonly>, + ...args: Array +): Readonly>; // @public (undocumented) -export function useFormat(format: Readonly>, obj?: RefTyped | Array): Readonly>; +export function useFormat( + format: Readonly>, + obj?: RefTyped | Array +): Readonly>; // @public (undocumented) -export function useFormat(format: RefTyped, args: any): Readonly>; +export function useFormat( + format: RefTyped, + args: any +): Readonly>; // @public (undocumented) -export function useI18n, TMessage extends Record Promise)>>(definition: T): i18nResult; +export function useI18n< + T extends i18nDefinition, + TMessage extends Record Promise)> +>(definition: T): i18nResult; // @public (undocumented) export function useI18n(): i18nResult | void; // @public -export function useNow(options?: NowOptions & UseNowOptions): { - now: import("@vue/composition-api").Ref; - remove: () => void; +export function useNow( + options?: NowOptions & UseNowOptions +): { + now: import("@vue/composition-api").Ref; + remove: () => void; }; // @public (undocumented) export interface UseNowOptions { - timeFn?: () => number; + timeFn?: () => number; } // @public (undocumented) export function usePagination(options: PaginationOptions): PaginationResult; // @public (undocumented) -export function usePath(source: RefTyped, path: RefTyped, separator?: string, notFoundReturn?: UsePathNotFoundReturn): Ref>; +export function usePath( + source: RefTyped, + path: RefTyped, + separator?: string, + notFoundReturn?: UsePathNotFoundReturn +): Ref>; // @public (undocumented) -export type UsePathNotFoundReturn = (path: string, source: any, fullPath: string, originalSource: any) => T; +export type UsePathNotFoundReturn = ( + path: string, + source: any, + fullPath: string, + originalSource: any +) => T; // @public -export function usePerformanceNow(options?: NowOptions): { - now: import("@vue/composition-api").Ref; - remove: () => void; +export function usePerformanceNow( + options?: NowOptions +): { + now: import("@vue/composition-api").Ref; + remove: () => void; }; // @public (undocumented) -export function usePromise = Array>(fn: (...args: TArgs) => Promise, lazy?: boolean): PromiseResultFactory, TArgs>; +export function usePromise = Array>( + fn: (...args: TArgs) => Promise, + lazy?: boolean +): PromiseResultFactory, TArgs>; // @public (undocumented) -export function usePromise = Array>(fn: (...args: TArgs) => Promise, options: PromiseOptions): PromiseResultFactory, TArgs>; +export function usePromise = Array>( + fn: (...args: TArgs) => Promise, + options: PromiseOptions +): PromiseResultFactory, TArgs>; // @public (undocumented) -export function usePromise = Array>(fn: (...args: TArgs) => Promise): PromiseResultFactory, TArgs>; +export function usePromise = Array>( + fn: (...args: TArgs) => Promise +): PromiseResultFactory, TArgs>; // @public (undocumented) -export function usePromise = Array>(fn: (...args: TArgs) => T, lazy: boolean): PromiseResultFactory, TArgs>; +export function usePromise = Array>( + fn: (...args: TArgs) => T, + lazy: boolean +): PromiseResultFactory, TArgs>; // @public (undocumented) -export function usePromise = Array>(fn: (...args: TArgs) => T, options: PromiseOptions): PromiseResultFactory, TArgs>; +export function usePromise = Array>( + fn: (...args: TArgs) => T, + options: PromiseOptions +): PromiseResultFactory, TArgs>; // @public (undocumented) -export function usePromise = Array>(fn: (...args: TArgs) => T): PromiseResultFactory, TArgs>; +export function usePromise = Array>( + fn: (...args: TArgs) => T +): PromiseResultFactory, TArgs>; // @public (undocumented) -export function usePromise(fn: () => Promise, lazy: boolean): PromiseResultFactory>; +export function usePromise( + fn: () => Promise, + lazy: boolean +): PromiseResultFactory>; // @public (undocumented) -export function usePromise(fn: () => Promise, options: PromiseOptions): PromiseResultFactory>; +export function usePromise( + fn: () => Promise, + options: PromiseOptions +): PromiseResultFactory>; // @public (undocumented) -export function usePromise(fn: () => Promise): PromiseResultFactory>; +export function usePromise( + fn: () => Promise +): PromiseResultFactory>; // @public (undocumented) -export function usePromise(fn: () => T, lazy: boolean): PromiseResultFactory>; +export function usePromise( + fn: () => T, + lazy: boolean +): PromiseResultFactory>; // @public (undocumented) -export function usePromise(fn: () => T, options: PromiseOptions): PromiseResultFactory>; +export function usePromise( + fn: () => T, + options: PromiseOptions +): PromiseResultFactory>; // @public (undocumented) -export function usePromise(fn: () => T): PromiseResultFactory>; +export function usePromise( + fn: () => T +): PromiseResultFactory>; // @public -export function usePromiseLazy = Array>(fn: (...args: TArgs) => Promise, throwException?: boolean): PromiseResultFactory, TArgs>; +export function usePromiseLazy = Array>( + fn: (...args: TArgs) => Promise, + throwException?: boolean +): PromiseResultFactory, TArgs>; // @public (undocumented) -export function usePromiseLazy = Array>(fn: (...args: TArgs) => Promise): PromiseResultFactory, TArgs>; +export function usePromiseLazy = Array>( + fn: (...args: TArgs) => Promise +): PromiseResultFactory, TArgs>; // @public (undocumented) -export function usePromiseLazy = Array>(fn: (...args: TArgs) => T, throwException: boolean): PromiseResultFactory, TArgs>; +export function usePromiseLazy = Array>( + fn: (...args: TArgs) => T, + throwException: boolean +): PromiseResultFactory, TArgs>; // @public (undocumented) -export function usePromiseLazy = Array>(fn: (...args: TArgs) => T): PromiseResultFactory, TArgs>; +export function usePromiseLazy = Array>( + fn: (...args: TArgs) => T +): PromiseResultFactory, TArgs>; // @public (undocumented) -export function usePromiseLazy(fn: () => Promise, throwException: boolean): PromiseResultFactory>; +export function usePromiseLazy( + fn: () => Promise, + throwException: boolean +): PromiseResultFactory>; // @public (undocumented) -export function usePromiseLazy(fn: () => Promise): PromiseResultFactory>; +export function usePromiseLazy( + fn: () => Promise +): PromiseResultFactory>; // @public (undocumented) -export function usePromiseLazy(fn: () => T, throwException: boolean): PromiseResultFactory>; +export function usePromiseLazy( + fn: () => T, + throwException: boolean +): PromiseResultFactory>; // @public (undocumented) -export function usePromiseLazy(fn: () => T): PromiseResultFactory>; +export function usePromiseLazy( + fn: () => T +): PromiseResultFactory>; // Warning: (ae-forgotten-export) The symbol "RetryOptions" needs to be exported by the entry point index.d.ts // @@ -361,17 +529,24 @@ export function useRetry(options?: RetryOptions): RetryReturnNoFactory; // Warning: (ae-forgotten-export) The symbol "Factory" needs to be exported by the entry point index.d.ts // // @public (undocumented) -export function useRetry>(factory: Factory): RetryReturnFactory; +export function useRetry>( + factory: Factory +): RetryReturnFactory; // @public (undocumented) -export function useRetry>(options: RetryOptions, factory: Factory): RetryReturnFactory; +export function useRetry>( + options: RetryOptions, + factory: Factory +): RetryReturnFactory; // Warning: (ae-forgotten-export) The symbol "UseValidation" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ValidationOutput" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ValidationGroupResult" needs to be exported by the entry point index.d.ts // // @public (undocumented) -export function useValidation, E = any>(input: E): ValidationOutput & ValidationGroupResult; +export function useValidation, E = any>( + input: E +): ValidationOutput & ValidationGroupResult; // @public (undocumented) export function wrap(o: RefElement): Ref; @@ -382,7 +557,5 @@ export function wrap(o: RefTyped): Ref; // @public (undocumented) export type WrapRef = T extends Ref ? T : Ref; - // (No @packageDocumentation comment for this package) - ``` diff --git a/docs/api/web.api.md b/docs/api/web.api.md index 0c5b8122e..3c759dec4 100644 --- a/docs/api/web.api.md +++ b/docs/api/web.api.md @@ -3,30 +3,30 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts - -import { PromiseResultFactory } from '@vue-composable/core'; -import { Ref } from '@vue/composition-api'; -import { RefElement } from '@vue-composable/core'; -import { RefTyped } from '@vue-composable/core'; +import { PromiseResultFactory } from "@vue-composable/core"; +import { Ref } from "@vue/composition-api"; +import { RefElement } from "@vue-composable/core"; +import { RefTyped } from "@vue-composable/core"; // @public (undocumented) export type BreakpointObject = Record; // @public (undocumented) -export type BreakpointReturn = Record> & BreakpointReturnObject; +export type BreakpointReturn = Record> & + BreakpointReturnObject; // @public (undocumented) export interface BreakpointReturnObject { - // (undocumented) - current: Ref; - // (undocumented) - remove: RemoveEventFunction; + // (undocumented) + current: Ref; + // (undocumented) + remove: RemoveEventFunction; } // @public (undocumented) export interface BroadcastMessageEvent extends MessageEvent { - // (undocumented) - readonly data: T; + // (undocumented) + readonly data: T; } // @public @@ -34,10 +34,10 @@ export type CssVarDef = CssVarDefinition | string; // @public export interface CssVarDefinition { - // (undocumented) - name: string; - // (undocumented) - value: RefTyped; + // (undocumented) + name: string; + // (undocumented) + value: RefTyped; } // @public @@ -51,56 +51,62 @@ export type CssVariableObject = Record>; // @public export interface CssVariablesMethods { - observing: Ref; - resume: () => void; - stop: () => void; - // (undocumented) - supported: boolean; + observing: Ref; + resume: () => void; + stop: () => void; + // (undocumented) + supported: boolean; } +// @public (undocumented) +export function exposeWorker(this: Worker, func: (...args: any[]) => any): void; + // @public (undocumented) export interface GeolocationOptions { - immediate?: boolean; + immediate?: boolean; } // @public -export function getCssVariableFor(element: HTMLElement, name: string): CssVariable; +export function getCssVariableFor( + element: HTMLElement, + name: string +): CssVariable; // @public (undocumented) export interface IntersectionObserverOptions { - // (undocumented) - root?: RefTyped | null; - // (undocumented) - rootMargin?: RefTyped | string; - // (undocumented) - threshold?: RefTyped | number | number[]; + // (undocumented) + root?: RefTyped | null; + // (undocumented) + rootMargin?: RefTyped | string; + // (undocumented) + threshold?: RefTyped | number | number[]; } // @public (undocumented) export interface IntersectionObserverResult { - // (undocumented) - disconnect: () => void; - // (undocumented) - elements: Ref; - // (undocumented) - readonly isIntersecting: Ref; - // (undocumented) - observe: (el: RefTyped) => void; - // (undocumented) - supported: boolean; - // (undocumented) - unobserve: (el: RefTyped) => void; + // (undocumented) + disconnect: () => void; + // (undocumented) + elements: Ref; + // (undocumented) + readonly isIntersecting: Ref; + // (undocumented) + observe: (el: RefTyped) => void; + // (undocumented) + supported: boolean; + // (undocumented) + unobserve: (el: RefTyped) => void; } // @public (undocumented) export interface LocalStorageReturn { - clear: () => void; - remove: () => void; - setSync: (sync: boolean) => void; - // (undocumented) - storage: Ref; - // (undocumented) - supported: boolean; + clear: () => void; + remove: () => void; + setSync: (sync: boolean) => void; + // (undocumented) + storage: Ref; + // (undocumented) + supported: boolean; } // @public (undocumented) @@ -108,112 +114,144 @@ export type LocalStorageTyped = string; // @public (undocumented) export interface MouseMoveResult { - // (undocumented) - mouseX: Ref; - // (undocumented) - mouseY: Ref; - // (undocumented) - remove: RemoveEventFunction; + // (undocumented) + mouseX: Ref; + // (undocumented) + mouseY: Ref; + // (undocumented) + remove: RemoveEventFunction; } // @public (undocumented) export interface NetworkInformation { - // Warning: (ae-forgotten-export) The symbol "NetworkInformationEventMap" needs to be exported by the entry point index.d.ts - // - // (undocumented) - addEventListener(type: K, listener: (this: NetworkInformation, ev: NetworkInformationEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - // (undocumented) - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - // (undocumented) - readonly downlink: number; - // (undocumented) - readonly downlinkMax: number; - // Warning: (ae-forgotten-export) The symbol "NetworkInformationEffectiveType" needs to be exported by the entry point index.d.ts - // - // (undocumented) - readonly effectiveType: NetworkInformationEffectiveType; - // (undocumented) - onchange: (this: NetworkInformation, ev: Event) => void; - // (undocumented) - removeEventListener(type: K, listener: (this: NetworkInformation, ev: NetworkInformationEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - // (undocumented) - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; - // (undocumented) - readonly rtt: number; - // (undocumented) - readonly saveData: Boolean; - // Warning: (ae-forgotten-export) The symbol "NetworkInformationType" needs to be exported by the entry point index.d.ts - // - // (undocumented) - readonly type: NetworkInformationType; + // Warning: (ae-forgotten-export) The symbol "NetworkInformationEventMap" needs to be exported by the entry point index.d.ts + // + // (undocumented) + addEventListener( + type: K, + listener: ( + this: NetworkInformation, + ev: NetworkInformationEventMap[K] + ) => any, + options?: boolean | AddEventListenerOptions + ): void; + // (undocumented) + addEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | AddEventListenerOptions + ): void; + // (undocumented) + readonly downlink: number; + // (undocumented) + readonly downlinkMax: number; + // Warning: (ae-forgotten-export) The symbol "NetworkInformationEffectiveType" needs to be exported by the entry point index.d.ts + // + // (undocumented) + readonly effectiveType: NetworkInformationEffectiveType; + // (undocumented) + onchange: (this: NetworkInformation, ev: Event) => void; + // (undocumented) + removeEventListener( + type: K, + listener: ( + this: NetworkInformation, + ev: NetworkInformationEventMap[K] + ) => any, + options?: boolean | EventListenerOptions + ): void; + // (undocumented) + removeEventListener( + type: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | EventListenerOptions + ): void; + // (undocumented) + readonly rtt: number; + // (undocumented) + readonly saveData: Boolean; + // Warning: (ae-forgotten-export) The symbol "NetworkInformationType" needs to be exported by the entry point index.d.ts + // + // (undocumented) + readonly type: NetworkInformationType; } // @public (undocumented) -export function refShared(defaultValue?: RefTyped, id?: string): Ref>; +export function refShared( + defaultValue?: RefTyped, + id?: string +): Ref>; // @public (undocumented) -export type RefSharedMessage = RefSharedMessageInit | RefSharedMessageSync | RefSharedMessageLeave | RefSharedMessageUpdate | RefSharedMessageSetMind | RefSharedMessagePing | RefSharedMessagePong; +export type RefSharedMessage = + | RefSharedMessageInit + | RefSharedMessageSync + | RefSharedMessageLeave + | RefSharedMessageUpdate + | RefSharedMessageSetMind + | RefSharedMessagePing + | RefSharedMessagePong; // @public (undocumented) export type RefSharedMessageInit = { - type: RefSharedMessageType.INIT; + type: RefSharedMessageType.INIT; }; // @public (undocumented) export type RefSharedMessageLeave = { - type: RefSharedMessageType.LEAVE; - id: number; + type: RefSharedMessageType.LEAVE; + id: number; }; // @public (undocumented) export type RefSharedMessagePing = { - type: RefSharedMessageType.PING; - id: number; + type: RefSharedMessageType.PING; + id: number; }; // @public (undocumented) export type RefSharedMessagePong = { - type: RefSharedMessageType.PONG; - id: number; + type: RefSharedMessageType.PONG; + id: number; }; // @public (undocumented) export type RefSharedMessageSetMind = { - type: RefSharedMessageType.SET_MIND; - mind: SharedRefMind; - id: number; + type: RefSharedMessageType.SET_MIND; + mind: SharedRefMind; + id: number; }; // @public (undocumented) export type RefSharedMessageSync = { - type: RefSharedMessageType.SYNC; - value: T; - mind: SharedRefMind; + type: RefSharedMessageType.SYNC; + value: T; + mind: SharedRefMind; }; // @public (undocumented) export const enum RefSharedMessageType { - // (undocumented) - INIT = 0, - // (undocumented) - LEAVE = 4, - // (undocumented) - PING = 5, - // (undocumented) - PONG = 6, - // (undocumented) - SET_MIND = 3, - // (undocumented) - SYNC = 1, - // (undocumented) - UPDATE = 2 + // (undocumented) + INIT = 0, + // (undocumented) + LEAVE = 4, + // (undocumented) + PING = 5, + // (undocumented) + PONG = 6, + // (undocumented) + SET_MIND = 3, + // (undocumented) + SYNC = 1, + // (undocumented) + UPDATE = 2 } // @public (undocumented) export type RefSharedMessageUpdate = { - type: RefSharedMessageType.UPDATE; - value: T; - mind: SharedRefMind; + type: RefSharedMessageType.UPDATE; + value: T; + mind: SharedRefMind; }; // @public (undocumented) @@ -221,48 +259,56 @@ export type RemoveEventFunction = () => void; // @public (undocumented) export interface ResizeResult { - // (undocumented) - height: Ref; - // (undocumented) - remove: RemoveEventFunction; - // (undocumented) - width: Ref; + // (undocumented) + height: Ref; + // (undocumented) + remove: RemoveEventFunction; + // (undocumented) + width: Ref; } // @public (undocumented) export interface ScrollResult { - // (undocumented) - remove: RemoveEventFunction; - // (undocumented) - scrollLeft: Ref; - // (undocumented) - scrollLeftTo: (x: number) => void; - // (undocumented) - scrollTo: Element["scrollTo"]; - // (undocumented) - scrollTop: Ref; - // (undocumented) - scrollTopTo: (y: number) => void; + // (undocumented) + remove: RemoveEventFunction; + // (undocumented) + scrollLeft: Ref; + // (undocumented) + scrollLeftTo: (x: number) => void; + // (undocumented) + scrollTo: Element["scrollTo"]; + // (undocumented) + scrollTop: Ref; + // (undocumented) + scrollTopTo: (y: number) => void; } // Warning: (ae-forgotten-export) The symbol "TailwindConfigEmpty" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ExtractTailwindScreens" needs to be exported by the entry point index.d.ts // // @public (undocumented) -export function setBreakpointTailwindCSS(tailwindConfig: T): BreakpointReturn>; +export function setBreakpointTailwindCSS( + tailwindConfig: T +): BreakpointReturn>; // @public (undocumented) -export function setBreakpointTailwindCSS(breakpoints: T): BreakpointReturn; +export function setBreakpointTailwindCSS( + breakpoints: T +): BreakpointReturn; // @public -export function setCssVariableFor(element: HTMLElement, name: string, value: CssVariable): void; +export function setCssVariableFor( + element: HTMLElement, + name: string, + value: CssVariable +): void; // @public (undocumented) export const enum SharedRefMind { - // (undocumented) - HIVE = 0, - // (undocumented) - MASTER = 1 + // (undocumented) + HIVE = 0, + // (undocumented) + MASTER = 1 } // @public (undocumented) @@ -270,14 +316,16 @@ export function storageAvailable(storage?: Storage): boolean; // @public (undocumented) export interface StorageSerializer { - // (undocumented) - parse(data: string): T; - // (undocumented) - stringify(item: T): string; + // (undocumented) + parse(data: string): T; + // (undocumented) + stringify(item: T): string; } // @public (undocumented) -export function useBreakpoint(breakpoints: Record): BreakpointReturn; +export function useBreakpoint( + breakpoints: Record +): BreakpointReturn; // Warning: (ae-forgotten-export) The symbol "ChromeBreakpoint" needs to be exported by the entry point index.d.ts // @@ -285,110 +333,189 @@ export function useBreakpoint(breakpoints: Record; // @public (undocumented) -export function useBreakpointTailwindCSS(tailwindConfig: T): BreakpointReturn>; +export function useBreakpointTailwindCSS( + tailwindConfig: T +): BreakpointReturn>; // @public (undocumented) -export function useBreakpointTailwindCSS(): BreakpointReturn>; +export function useBreakpointTailwindCSS< + T extends TailwindConfigEmpty +>(): BreakpointReturn>; // Warning: (ae-forgotten-export) The symbol "DefaultTailwindBreakpoints" needs to be exported by the entry point index.d.ts // // @public (undocumented) -export function useBreakpointTailwindCSS(): BreakpointReturn; - -// @public (undocumented) -export function useBreakpointTailwindCSS(): BreakpointReturn; - -// @public (undocumented) -export function useBroadcastChannel(name: string, onBeforeClose?: Function): { - supported: boolean; - data: import("@vue/composition-api").Ref; - messageEvent: import("@vue/composition-api").Ref; - errorEvent: import("@vue/composition-api").Ref; - errored: import("@vue/composition-api").Ref; - isClosed: import("@vue/composition-api").Ref; - send: (data: T) => void; - close: Function; - addListener: (cb: (ev: BroadcastMessageEvent) => void, options?: boolean | AddEventListenerOptions | undefined) => void; +export function useBreakpointTailwindCSS(): BreakpointReturn< + DefaultTailwindBreakpoints +>; + +// @public (undocumented) +export function useBreakpointTailwindCSS< + T extends BreakpointObject +>(): BreakpointReturn; + +// @public (undocumented) +export function useBroadcastChannel( + name: string, + onBeforeClose?: Function +): { + supported: boolean; + data: import("@vue/composition-api").Ref; + messageEvent: import("@vue/composition-api").Ref; + errorEvent: import("@vue/composition-api").Ref; + errored: import("@vue/composition-api").Ref; + isClosed: import("@vue/composition-api").Ref; + send: (data: T) => void; + close: Function; + addListener: ( + cb: (ev: BroadcastMessageEvent) => void, + options?: boolean | AddEventListenerOptions | undefined + ) => void; }; // @public export type UseCssVariables = CssVariableObject & CssVariablesMethods; // @public (undocumented) -export function useCssVariables(variables: T): UseCssVariables; +export function useCssVariables( + variables: T +): UseCssVariables; // @public (undocumented) -export function useCssVariables(variables: T, options?: MutationObserverInit): UseCssVariables; +export function useCssVariables( + variables: T, + options?: MutationObserverInit +): UseCssVariables; // @public (undocumented) -export function useCssVariables(variables: T, element: RefTyped, options?: MutationObserverInit): UseCssVariables; +export function useCssVariables( + variables: T, + element: RefTyped, + options?: MutationObserverInit +): UseCssVariables; // @public (undocumented) -export function useEvent any; +export function useEvent< + T extends { + addEventListener: ( + name: string, + listener: EventListenerOrEventListenerObject + ) => any; removeEventListener: Function; -}, M, K extends keyof M>(el: T | Ref, name: K, listener: (this: T, ev: M[K]) => any): RemoveEventFunction; - -// @public (undocumented) -export function useEvent any; + }, + M, + K extends keyof M +>( + el: T | Ref, + name: K, + listener: (this: T, ev: M[K]) => any +): RemoveEventFunction; + +// @public (undocumented) +export function useEvent< + T extends { + addEventListener: ( + name: string, + listener: EventListenerOrEventListenerObject, + options?: boolean | AddEventListenerOptions + ) => any; removeEventListener: Function; -}, M, K extends keyof M>(el: T | Ref, name: K, listener: (this: T, ev: M[K]) => any, options?: boolean | AddEventListenerOptions): RemoveEventFunction; - -// @public (undocumented) -export function useEvent(el: RefTyped, name: K, listener: (this: Document, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions): RemoveEventFunction; - -// @public (undocumented) -export function useEvent(el: Element | Ref, name: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): RemoveEventFunction; + }, + M, + K extends keyof M +>( + el: T | Ref, + name: K, + listener: (this: T, ev: M[K]) => any, + options?: boolean | AddEventListenerOptions +): RemoveEventFunction; + +// @public (undocumented) +export function useEvent( + el: RefTyped, + name: K, + listener: (this: Document, ev: WindowEventMap[K]) => any, + options?: boolean | AddEventListenerOptions +): RemoveEventFunction; + +// @public (undocumented) +export function useEvent( + el: Element | Ref, + name: K, + listener: (this: Document, ev: DocumentEventMap[K]) => any, + options?: boolean | AddEventListenerOptions +): RemoveEventFunction; // Warning: (ae-forgotten-export) The symbol "FetchReturn" needs to be exported by the entry point index.d.ts // // @public (undocumented) -export function useFetch(request?: Partial, init?: RequestInit & UseFetchOptions): FetchReturn; +export function useFetch( + request?: Partial, + init?: RequestInit & UseFetchOptions +): FetchReturn; // @public (undocumented) -export function useFetch(init?: RequestInit & UseFetchOptions): FetchReturn; +export function useFetch( + init?: RequestInit & UseFetchOptions +): FetchReturn; // @public (undocumented) export interface UseFetchOptions { - isJson?: boolean; - parseImmediate?: boolean; + isJson?: boolean; + parseImmediate?: boolean; } // @public (undocumented) -export function useGeolocation(options?: PositionOptions & GeolocationOptions): { - supported: boolean; - refresh: () => void; - error: import("@vue/composition-api").Ref; - timestamp: import("@vue/composition-api").Ref; - coords: import("@vue/composition-api").Ref; - highAccuracy: import("@vue/composition-api").Ref; +export function useGeolocation( + options?: PositionOptions & GeolocationOptions +): { + supported: boolean; + refresh: () => void; + error: import("@vue/composition-api").Ref; + timestamp: import("@vue/composition-api").Ref; + coords: import("@vue/composition-api").Ref; + highAccuracy: import("@vue/composition-api").Ref; }; // @public (undocumented) -export function useIntersectionObserver(el: RefElement, options?: RefTyped): IntersectionObserverResult; +export function useIntersectionObserver( + el: RefElement, + options?: RefTyped +): IntersectionObserverResult; // @public (undocumented) -export function useIntersectionObserver(options: RefTyped): IntersectionObserverResult; +export function useIntersectionObserver( + options: RefTyped +): IntersectionObserverResult; // @public (undocumented) export function useLanguage(): { - language: Ref; - languages: Ref; + language: Ref; + languages: Ref; }; // @public (undocumented) -export function useLocalStorage(key: string, defaultValue?: RefTyped, sync?: boolean): LocalStorageReturn; +export function useLocalStorage( + key: string, + defaultValue?: RefTyped, + sync?: boolean +): LocalStorageReturn; // @public (undocumented) -export function useLocalStorage(key: LocalStorageTyped | string, defaultValue?: RefTyped, sync?: boolean): LocalStorageReturn; +export function useLocalStorage( + key: LocalStorageTyped | string, + defaultValue?: RefTyped, + sync?: boolean +): LocalStorageReturn; // @public (undocumented) -export function useMatchMedia(query: string): { - supported: boolean; - mediaQueryList: Ref; - matches: Ref; - remove: () => void; +export function useMatchMedia( + query: string +): { + supported: boolean; + mediaQueryList: Ref; + matches: Ref; + remove: () => void; }; // Warning: (ae-forgotten-export) The symbol "NetworkInformationReturn" needs to be exported by the entry point index.d.ts @@ -398,33 +525,52 @@ export function useNetworkInformation(): NetworkInformationReturn; // @public (undocumented) export function useOnline(): { - supported: boolean; - online: Ref; + supported: boolean; + online: Ref; }; // @public (undocumented) -export function useOnMouseMove(el: RefTyped, wait: number): MouseMoveResult; +export function useOnMouseMove( + el: RefTyped, + wait: number +): MouseMoveResult; // @public (undocumented) -export function useOnMouseMove(el: RefTyped, options?: boolean | AddEventListenerOptions, wait?: number): MouseMoveResult; +export function useOnMouseMove( + el: RefTyped, + options?: boolean | AddEventListenerOptions, + wait?: number +): MouseMoveResult; // @public (undocumented) export function useOnMouseMove(el: RefElement, wait: number): MouseMoveResult; // @public (undocumented) -export function useOnMouseMove(el: RefElement, options?: boolean | AddEventListenerOptions, wait?: number): MouseMoveResult; +export function useOnMouseMove( + el: RefElement, + options?: boolean | AddEventListenerOptions, + wait?: number +): MouseMoveResult; // @public (undocumented) export function useOnResize(el: RefTyped, wait: number): ResizeResult; // @public (undocumented) -export function useOnResize(el: RefTyped, options?: boolean | AddEventListenerOptions, wait?: number): ResizeResult; +export function useOnResize( + el: RefTyped, + options?: boolean | AddEventListenerOptions, + wait?: number +): ResizeResult; // @public (undocumented) export function useOnResize(el: RefElement, wait: number): ResizeResult; // @public (undocumented) -export function useOnResize(el: RefElement, options?: boolean | AddEventListenerOptions, wait?: number): ResizeResult; +export function useOnResize( + el: RefElement, + options?: boolean | AddEventListenerOptions, + wait?: number +): ResizeResult; // @public (undocumented) export function useOnScroll(): ScrollResult; @@ -433,99 +579,169 @@ export function useOnScroll(): ScrollResult; export function useOnScroll(wait: number): ScrollResult; // @public (undocumented) -export function useOnScroll(options: boolean | AddEventListenerOptions, wait?: number): ScrollResult; +export function useOnScroll( + options: boolean | AddEventListenerOptions, + wait?: number +): ScrollResult; // @public (undocumented) export function useOnScroll(el: RefTyped, wait: number): ScrollResult; // @public (undocumented) -export function useOnScroll(el: RefTyped, options?: boolean | AddEventListenerOptions, wait?: number): ScrollResult; +export function useOnScroll( + el: RefTyped, + options?: boolean | AddEventListenerOptions, + wait?: number +): ScrollResult; // @public (undocumented) export function useOnScroll(el: RefElement, wait: number): ScrollResult; // @public (undocumented) -export function useOnScroll(el: RefElement, options?: boolean | AddEventListenerOptions, wait?: number): ScrollResult; +export function useOnScroll( + el: RefElement, + options?: boolean | AddEventListenerOptions, + wait?: number +): ScrollResult; // @public (undocumented) export function usePageVisibility(): { - visibility: Ref; - hidden: Ref; + visibility: Ref; + hidden: Ref; }; // @public (undocumented) -export function useSessionStorage(key: string, defaultValue?: RefTyped, sync?: boolean): LocalStorageReturn; - -// @public (undocumented) -export function useSessionStorage(key: LocalStorageTyped | string, defaultValue?: RefTyped, sync?: boolean): LocalStorageReturn; - -// @public (undocumented) -export function useSharedRef(name: string, defaultValue?: T): { - supported: boolean; - id: number; - data: Ref; - master: Ref; - mind: Ref; - editable: Readonly>; - targets: Ref; - ping: () => void; - setMind: (t: SharedRefMind) => void; - addListener: (cb: (ev: BroadcastMessageEvent>) => void, options?: boolean | AddEventListenerOptions | undefined) => void; +export function useSessionStorage( + key: string, + defaultValue?: RefTyped, + sync?: boolean +): LocalStorageReturn; + +// @public (undocumented) +export function useSessionStorage( + key: LocalStorageTyped | string, + defaultValue?: RefTyped, + sync?: boolean +): LocalStorageReturn; + +// @public (undocumented) +export function useSharedRef( + name: string, + defaultValue?: T +): { + supported: boolean; + id: number; + data: Ref; + master: Ref; + mind: Ref; + editable: Readonly>; + targets: Ref; + ping: () => void; + setMind: (t: SharedRefMind) => void; + addListener: ( + cb: (ev: BroadcastMessageEvent>) => void, + options?: boolean | AddEventListenerOptions | undefined + ) => void; }; // @public (undocumented) -export function useStorage(key: string, defaultValue?: RefTyped, sync?: boolean): LocalStorageReturn; +export function useStorage( + key: string, + defaultValue?: RefTyped, + sync?: boolean +): LocalStorageReturn; + +// @public (undocumented) +export function useStorage( + key: LocalStorageTyped | string, + defaultValue?: RefTyped, + sync?: boolean +): LocalStorageReturn; + +// @public (undocumented) +export function useWebSocket( + url: string, + protocols?: string | string[] +): { + supported: boolean; + ws: WebSocket | null; + send: ( + data: string | ArrayBuffer | SharedArrayBuffer | Blob | ArrayBufferView + ) => void; + close: (code?: number | undefined, reason?: string | undefined) => void; + messageEvent: import("@vue/composition-api").Ref; + errorEvent: import("@vue/composition-api").Ref; + data: import("@vue/composition-api").Ref; + isOpen: import("@vue/composition-api").Ref; + isClosed: import("@vue/composition-api").Ref; + errored: import("@vue/composition-api").Ref; +}; +// Warning: (ae-forgotten-export) The symbol "WebStorageType" needs to be exported by the entry point index.d.ts +// // @public (undocumented) -export function useStorage(key: LocalStorageTyped | string, defaultValue?: RefTyped, sync?: boolean): LocalStorageReturn; +export function useWebStorage( + type: WebStorageType, + serializer?: StorageSerializer, + ms?: number +): { + supported: boolean; + quotaError: Ref; + store: WebStorage; + remove: () => boolean; +}; // @public (undocumented) -export function useWebSocket(url: string, protocols?: string | string[]): { - supported: boolean; - ws: WebSocket | null; - send: (data: string | ArrayBuffer | SharedArrayBuffer | Blob | ArrayBufferView) => void; - close: (code?: number | undefined, reason?: string | undefined) => void; - messageEvent: import("@vue/composition-api").Ref; - errorEvent: import("@vue/composition-api").Ref; - data: import("@vue/composition-api").Ref; - isOpen: import("@vue/composition-api").Ref; - isClosed: import("@vue/composition-api").Ref; - errored: import("@vue/composition-api").Ref; +export function useWorker( + stringUrl: string | URL, + args?: TArgs, + options?: WorkerOptions +): { + worker: Worker; + data: import("@vue/composition-api").Ref; + postMessage: (data: TArgs) => void; + terminate: () => void; + errorEvent: import("@vue/composition-api").Ref; + errored: import("@vue/composition-api").Ref; + terminated: import("@vue/composition-api").Ref; }; -// Warning: (ae-forgotten-export) The symbol "WebStorageType" needs to be exported by the entry point index.d.ts -// // @public (undocumented) -export function useWebStorage(type: WebStorageType, serializer?: StorageSerializer, ms?: number): { - supported: boolean; - quotaError: Ref; - store: WebStorage; - remove: () => boolean; -}; +export function useWorkerFunction>( + fn: (...args: TArgs) => T, + options?: WebWorkerFunctionOptions +): import("../../../core/src").PromiseResultFactory, TArgs> & + import("../../../core/src").CancellablePromiseResult; // @public (undocumented) export interface WebStorage { - // (undocumented) - $quotaError: Ref; - // (undocumented) - $refMap: Map>; - // (undocumented) - $syncKeys: Record; - // (undocumented) - $watchHandlers: Map; - clear(): void; - getItem(key: string): Ref | null; - key(index: number): string | null; - readonly length: number; - removeItem(key: string): void; - setItem(key: string, value: T): Ref; - // (undocumented) - setSync(key: string, sync: boolean): void; - // (undocumented) - updateItem(key: string, value: string): void; + // (undocumented) + $quotaError: Ref; + // (undocumented) + $refMap: Map>; + // (undocumented) + $syncKeys: Record; + // (undocumented) + $watchHandlers: Map; + clear(): void; + getItem(key: string): Ref | null; + key(index: number): string | null; + readonly length: number; + removeItem(key: string): void; + setItem(key: string, value: T): Ref; + // (undocumented) + setSync(key: string, sync: boolean): void; + // (undocumented) + updateItem(key: string, value: string): void; } +// @public (undocumented) +export interface WebWorkerFunctionOptions { + // (undocumented) + dependencies?: RefTyped; + // (undocumented) + timeout?: RefTyped; +} // (No @packageDocumentation comment for this package) - ``` diff --git a/docs/composable/validation/validation.md b/docs/composable/validation/validation.md index 6562c5117..4f9201225 100644 --- a/docs/composable/validation/validation.md +++ b/docs/composable/validation/validation.md @@ -249,12 +249,12 @@ interface ValidationGroupResult { +``` diff --git a/docs/composable/web/workerFunction.md b/docs/composable/web/workerFunction.md new file mode 100644 index 000000000..9007ede99 --- /dev/null +++ b/docs/composable/web/workerFunction.md @@ -0,0 +1,208 @@ +# WebWorker Function + +> Creates a WebWorker based on a function, useful for offloading heavy tasks easily + +The `useWorkerFunction` function uses [CancellablePromise](../promise/cancellablePromise) + +## Parameters + +```ts +import { useWorkerFunction } from "vue-composable"; + +useWorkerFunction(fn, options); + +interface WebWorkerFunctionOptions { + dependencies?: RefTyped; + timeout?: RefTyped; +} +``` + +| Parameters | Type | Required | Default | Description | +| ---------- | -------------------------- | -------- | ----------- | ----------------------------------------- | +| fn | `Function` | `true` | | Function we want to execute in the worker | +| options | `WebWorkerFunctionOptions` | `false` | `undefined` | Options for the webworker | + +## State + +The `useWorkerFunction` function exposes the following reactive state: + +```js +import { useWorkerFunction } from "vue-composable"; + +const { promise, result, loading, error, cancelled } = useWorkerFunction(); +``` + +| State | Type | Description | +| --------- | --------- | -------------------------------- | +| promise | `Promise` | Current worker process | +| result | `any` | Resolved value | +| loading | `boolean` | Waiting for the worker to finish | +| error | `any` | Promise error | +| cancelled | `boolean` | Was cancelled | + +## Methods + +The `useWorkerFunction` function exposes the following methods: + +```js +import { useWorkerFunction } from "vue-composable"; + +const { exec, cancel } = useWorkerFunction(); +``` + +| Signature | Description | +| ---------------- | --------------------- | +| `exec(args?)` | Resolves new promise | +| `cancel(error?)` | Terminates the worker | + +## Example + + + + +### Code + +```vue + + + +``` diff --git a/examples/vue-composable-example/src/components/HelloWorld.vue b/examples/vue-composable-example/src/components/HelloWorld.vue index 41bc71e55..b36b6622a 100644 --- a/examples/vue-composable-example/src/components/HelloWorld.vue +++ b/examples/vue-composable-example/src/components/HelloWorld.vue @@ -2,20 +2,133 @@

Vue composable examples

Select one above

+ +
+ + + + + + +
+

loading: {{ loading }}

+ + + + +
diff --git a/examples/vue-composable-example/src/components/TodoList.vue b/examples/vue-composable-example/src/components/TodoList.vue index 8eefeeea3..bc37a4eb4 100644 --- a/examples/vue-composable-example/src/components/TodoList.vue +++ b/examples/vue-composable-example/src/components/TodoList.vue @@ -8,7 +8,7 @@