├── .gitignore ├── .mocharc.json ├── .npmignore ├── README.md ├── babel.config.json ├── demo ├── actions.ts ├── index.html ├── index.ts ├── main.tsx ├── selectors.ts ├── store.ts ├── tsconfig.json └── types.ts ├── docs ├── index.html ├── index.js ├── index.js.map ├── selectors-0165158a.js ├── selectors-0165158a.js.map ├── selectors-0825d3f5.js ├── selectors-0825d3f5.js.map ├── selectors-23e421b4.js ├── selectors-23e421b4.js.map ├── selectors-4d5eb81d.js ├── selectors-4d5eb81d.js.map ├── selectors-5348b7c3.js ├── selectors-5348b7c3.js.map ├── selectors-6e9e04a0.js ├── selectors-6e9e04a0.js.map ├── selectors-81c38f95.js ├── selectors-81c38f95.js.map ├── selectors-bcd53b37.js ├── selectors-bcd53b37.js.map ├── selectors-bd7b3cc7.js ├── selectors-bd7b3cc7.js.map ├── selectors-c75dd2ec.js ├── selectors-c75dd2ec.js.map ├── selectors-d25cc1ab.js ├── selectors-d25cc1ab.js.map ├── selectors-d7ee1f2f.js ├── selectors-d7ee1f2f.js.map ├── selectors-e275a285.js ├── selectors-e275a285.js.map ├── selectors-e76456f7.js ├── selectors-e76456f7.js.map ├── selectors-f931d2e7.js ├── selectors-f931d2e7.js.map ├── store-116f3a41.js ├── store-116f3a41.js.map ├── store-17ff7cea.js ├── store-17ff7cea.js.map ├── store-214b901a.js ├── store-214b901a.js.map ├── store-30809fea.js ├── store-30809fea.js.map ├── store-3be5956b.js ├── store-3be5956b.js.map ├── store-57001cb7.js ├── store-57001cb7.js.map ├── store-6c69f58d.js ├── store-6c69f58d.js.map ├── store-74036116.js ├── store-74036116.js.map ├── store-8382a735.js ├── store-8382a735.js.map ├── store-a0cfcf87.js ├── store-a0cfcf87.js.map ├── store-a78b227a.js ├── store-a78b227a.js.map ├── store-b1479177.js ├── store-b1479177.js.map ├── store-bd60a451.js ├── store-bd60a451.js.map ├── store-eb2781ee.js ├── store-eb2781ee.js.map ├── store-ed92604c.js └── store-ed92604c.js.map ├── out ├── index.cjs ├── index.cjs.map ├── index.esm.js ├── index.esm.js.map ├── index.modern.js ├── index.modern.js.map ├── index.umd.js ├── index.umd.js.map ├── src │ ├── index.d.ts │ ├── main-thread-functions.d.ts │ ├── types.d.ts │ └── worker-functions.d.ts └── test │ ├── helpers.d.ts │ ├── main-thread-functions.test.d.ts │ └── worker-functions.test.d.ts ├── package-lock.json ├── package.json ├── rollup.config.js ├── src ├── index.ts ├── main-thread-functions.ts ├── types.ts └── worker-functions.ts ├── test ├── helpers.ts ├── main-thread-functions.test.ts └── worker-functions.test.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .idea 3 | .DS_Store 4 | .fleet -------------------------------------------------------------------------------- /.mocharc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extension": ["ts"], 3 | "node-option": [ 4 | "experimental-specifier-resolution=node", 5 | "loader=ts-node/esm" 6 | ], 7 | "spec": ["./test/*.test.ts"] 8 | } 9 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | demo 2 | docs 3 | dist 4 | rollup.config.js 5 | babel.config.json 6 | tsconfig.json 7 | test 8 | .mocharc.json 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React Redux off the main thread (omt) 2 | 3 | `react-redux` is a great library for state management. At a certain point, you may want to store an awful lot of data in redux. This can lead to storing lots of memory on the main thread. With this in mind, I constructed a few functions that will help you move your redux store off the main thread and into a worker 4 | 5 | ## Install 6 | 7 | ``` 8 | npm i react-redux-omt 9 | ``` 10 | 11 | ## Demo 12 | 13 | [react-redux-omt](https://sbesh91.github.io/react-redux-omt/) 14 | 15 | ## Typical Redux configuration 16 | 17 | ```typescript 18 | const rootReducer = combineReducers({ 19 | counterSliceReducer, 20 | }); 21 | 22 | const init: RootState = { 23 | counterSliceReducer: counterStoreState, 24 | }; 25 | 26 | const store = configureStore({ 27 | reducer: rootReducer, 28 | preloadedState: init, 29 | }); 30 | 31 | /* 32 | After configuration of your store, call this to set up worker events and subscriptions 33 | */ 34 | initializeWorkerStore(store, selectors); 35 | ``` 36 | 37 | ## Write your actions as usual 38 | 39 | ```typescript 40 | export let counterStoreState: CounterSliceState = { 41 | counter: 0, 42 | }; 43 | 44 | export const counterSlice = createSlice({ 45 | name: "counter", 46 | initialState: counterStoreState, 47 | reducers: { 48 | increment: produce( 49 | (draft: CounterSliceState, action: PayloadAction) => { 50 | draft.counter += action.payload; 51 | } 52 | ), 53 | decrement: produce( 54 | (draft: CounterSliceState, action: PayloadAction) => { 55 | draft.counter -= action.payload; 56 | } 57 | ), 58 | }, 59 | }); 60 | 61 | export const { increment, decrement } = counterSlice.actions; 62 | export const counterSliceReducer = counterSlice.reducer; 63 | ``` 64 | 65 | ## Write your selectors as usual 66 | 67 | ```typescript 68 | function cacheByValue(_: RootState, val: T) { 69 | return "" + val || ""; 70 | } 71 | 72 | function one(state: RootState) { 73 | return state.counterSliceReducer.counter; 74 | } 75 | 76 | function two(state: RootState, hello: string) { 77 | return `${hello} ${one(state) / 2}`; 78 | } 79 | 80 | const three = createSelector( 81 | one, 82 | (state: RootState) => state, 83 | (res, state) => { 84 | return res + state.counterSliceReducer.counter * 2; 85 | } 86 | ); 87 | 88 | const four = createCachedSelector( 89 | (state: RootState) => state, 90 | (_: RootState, val: number) => val, 91 | three, 92 | (_, val, res) => { 93 | return res * 3 - val; 94 | } 95 | )({ 96 | keySelector: cacheByValue, 97 | cacheObject: new LruMapCache({ cacheSize: 5 }), 98 | }); 99 | 100 | function five(state: RootState, one: number, two: number, three: string) { 101 | return `${three}: ${state.counterSliceReducer.counter}, sum: ${one + two}`; 102 | } 103 | 104 | /* 105 | Here's our little glue code. 106 | Your selectors must be stored in an object like this. 107 | The string passed as the first parameter to `createWorkerSelector` must match the json key exactly. 108 | */ 109 | export const selectors = { 110 | one: createWorkerSelector("one", one), 111 | two: createWorkerSelector("two", two), 112 | three: createWorkerSelector("three", three), 113 | four: createWorkerSelector("four", four), 114 | five: createWorkerSelector("five", five), 115 | } as const; 116 | ``` 117 | 118 | ## Putting it all together in React 119 | 120 | Two of our functions are used here. 121 | 122 | - `useWorkerSelector` 123 | - `dispatch` 124 | 125 | `useWorkerSelector` is my version of `useSelector`. The api is designed to have the user pass a reference to your selector function and the parameters it requires to run. This way, we can avoid the problem of sending a function over to our worker thread since we can look up the selector by name on the worker side. 126 | 127 | `dispatch` is the same basic function as `useDispatch` gives you, but without the hook to get a reference to it. You can pass your exported actions to it exactly as you would with `useDispatch` and `react-redux` on the main thread 128 | 129 | ```typescript 130 | const CounterDemo = () => { 131 | const one = useWorkerSelector(selectors.one); 132 | const two = useWorkerSelector(selectors.two, { 133 | params: ["hello"], 134 | defaultValue: "", 135 | }); 136 | const three = useWorkerSelector(selectors.three, { 137 | params: [1], 138 | }); 139 | const four = useWorkerSelector(selectors.four, { 140 | params: [one.value ?? 0], 141 | }); 142 | const five = useWorkerSelector(selectors.five, { 143 | params: [2, 4, "world"], 144 | defaultValue: "initial rendered value", 145 | }); 146 | 147 | return ( 148 |
149 |

Welcome

150 |

The current counter is: {one.value}

151 |

A modification of that value is: {two}

152 |

What about a different modification: {three}

153 |

Here's yet another different modification: {four}

154 |

{five}

155 | 156 | 157 |
158 | ); 159 | }; 160 | ``` 161 | 162 | ## Last but not least, configure your worker 163 | 164 | Our function `initializeWorkerStoreListener` starts the message listener from the main thread side, so that when you send actions for `dispatch` or subscribed to selectors you'll receive responses just as you would from a normal `react-redux` configuration 165 | 166 | ```typescript 167 | const worker = new Worker(new URL("store.ts", import.meta.url), { 168 | type: "module", 169 | }); 170 | initializeWorkerStoreListener(worker); 171 | ``` 172 | -------------------------------------------------------------------------------- /babel.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [["@babel/preset-typescript"]], 3 | "env": { 4 | "production": { 5 | "presets": ["minify"] 6 | } 7 | }, 8 | "plugins": [ 9 | "@babel/plugin-transform-react-jsx-source", 10 | [ 11 | "@babel/plugin-transform-react-jsx", 12 | { 13 | "useBuiltIns": true 14 | } 15 | ] 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /demo/actions.ts: -------------------------------------------------------------------------------- 1 | import { createSlice, PayloadAction } from "@reduxjs/toolkit"; 2 | import produce from "immer"; 3 | import { CounterSliceState } from "./types"; 4 | 5 | export let counterStoreState: CounterSliceState = { 6 | counter: 0, 7 | }; 8 | 9 | export const counterSlice = createSlice({ 10 | name: "counter", 11 | initialState: counterStoreState, 12 | reducers: { 13 | increment: produce( 14 | (draft: CounterSliceState, action: PayloadAction) => { 15 | draft.counter += action.payload; 16 | } 17 | ), 18 | decrement: produce( 19 | (draft: CounterSliceState, action: PayloadAction) => { 20 | draft.counter -= action.payload; 21 | } 22 | ), 23 | }, 24 | }); 25 | 26 | export const { increment, decrement } = counterSlice.actions; 27 | export const counterSliceReducer = counterSlice.reducer; 28 | -------------------------------------------------------------------------------- /demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 |
11 | 12 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /demo/index.ts: -------------------------------------------------------------------------------- 1 | import "./main.tsx"; 2 | -------------------------------------------------------------------------------- /demo/main.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import {useEffect} from "react"; 3 | import {render} from "react-dom"; 4 | import {decrement, increment} from "./actions"; 5 | import {selectors} from "./selectors"; 6 | import { 7 | dispatch, 8 | initializeWorkerStoreListener, 9 | useWorkerSelector, 10 | } from "../src"; 11 | 12 | const worker = new Worker(new URL("store.ts", import.meta.url), { 13 | type: "module", 14 | }); 15 | initializeWorkerStoreListener(worker); 16 | 17 | function run() { 18 | render(, document.getElementById("root")); 19 | } 20 | 21 | const CounterDemo = () => { 22 | const one = useWorkerSelector(selectors.one); 23 | const two = useWorkerSelector(selectors.two, { 24 | params: ["hello"], 25 | defaultValue: "", 26 | }); 27 | const three = useWorkerSelector(selectors.three, { 28 | params: [1], 29 | }); 30 | const four = useWorkerSelector(selectors.four, { 31 | params: [one.value ?? 0], 32 | }); 33 | const five = useWorkerSelector(selectors.five, { 34 | params: [2, 4, "world"], 35 | defaultValue: "initial rendered value", 36 | }); 37 | const test = useWorkerSelector(selectors.test, { 38 | params: [1, 2] 39 | }) 40 | 41 | console.log(test.value); 42 | 43 | useEffect(() => { 44 | // const interval = setInterval(() => { 45 | // dispatch(increment(2)); 46 | // }, 1); 47 | // return () => clearInterval(interval); 48 | }, []); 49 | 50 | return ( 51 |
52 |

Welcome

53 |

The current counter is: {one.value}

54 |

A modification of that value is: {two.value}

55 |

What about a different modification: {three.value}

56 |

Here's yet another different modification: {four.value}

57 |

{five.value}

58 |

Deeply nested and parameterized {test.value}

59 | 60 | 61 |
62 | ); 63 | }; 64 | 65 | run(); 66 | -------------------------------------------------------------------------------- /demo/selectors.ts: -------------------------------------------------------------------------------- 1 | import {createSelector} from "@reduxjs/toolkit"; 2 | import createCachedSelector, {LruMapCache} from "re-reselect"; 3 | import {RootState} from "./types"; 4 | import {createWorkerSelector} from "../src"; 5 | 6 | function cacheByValue(_: RootState, val: T) { 7 | return "" + val || ""; 8 | } 9 | 10 | function one(state: RootState) { 11 | return state.counterSliceReducer.counter; 12 | } 13 | 14 | function two(state: RootState, hello: string) { 15 | return `${hello} ${one(state) / 2}`; 16 | } 17 | 18 | const three = createSelector( 19 | one, 20 | (state: RootState) => state, 21 | (_: RootState, param: number) => param, 22 | (res, state, param) => { 23 | return res + state.counterSliceReducer.counter * 2 + param; 24 | } 25 | ); 26 | 27 | const test = createSelector( 28 | three, 29 | (_: RootState, param: number) => param, 30 | (_: RootState, _param: number, extra: number) => extra, 31 | (res, param, extra) => { 32 | return res + param + extra; 33 | } 34 | ); 35 | 36 | const four = createCachedSelector( 37 | (state: RootState) => state, 38 | (_: RootState, val: number) => val, 39 | three, 40 | (_, val, res) => { 41 | return res * 3 - val; 42 | } 43 | )({ 44 | keySelector: cacheByValue, 45 | cacheObject: new LruMapCache({cacheSize: 5}), 46 | }); 47 | 48 | function five(state: RootState, one: number, two: number, three: string) { 49 | return `${three}: ${state.counterSliceReducer.counter}, sum: ${one + two}`; 50 | } 51 | 52 | export const selectors = { 53 | one: createWorkerSelector("one", one), 54 | two: createWorkerSelector("two", two), 55 | three: createWorkerSelector("three", three), 56 | four: createWorkerSelector("four", four), 57 | five: createWorkerSelector("five", five), 58 | test: createWorkerSelector("test", test), 59 | } as const; 60 | -------------------------------------------------------------------------------- /demo/store.ts: -------------------------------------------------------------------------------- 1 | import { configureStore } from "@reduxjs/toolkit"; 2 | import { combineReducers } from "redux"; 3 | import { RootState } from "./types"; 4 | import { initializeWorkerStore } from "../src"; 5 | import { counterSliceReducer, counterStoreState } from "./actions"; 6 | import { selectors } from "./selectors"; 7 | 8 | const rootReducer = combineReducers({ 9 | counterSliceReducer, 10 | }); 11 | 12 | const init: RootState = { 13 | counterSliceReducer: counterStoreState, 14 | }; 15 | 16 | const store = configureStore({ 17 | reducer: rootReducer, 18 | preloadedState: init, 19 | }); 20 | 21 | initializeWorkerStore(store, selectors); 22 | -------------------------------------------------------------------------------- /demo/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | // project options 4 | "lib": [ 5 | "ESNext", 6 | "dom" 7 | ], 8 | // specifies which default set of type definitions to use ("DOM", "ES6", etc) 9 | "outDir": "lib", 10 | // .js (as well as .d.ts, .js.map, etc.) files will be emitted into this directory., 11 | "removeComments": true, 12 | // Strips all comments from TypeScript files when converting into JavaScript- you rarely read compiled code so this saves space 13 | "target": "ES6", 14 | // Target environment. Most modern browsers support ES6, but you may want to set it to newer or older. (defaults to ES3) 15 | "module": "ESNext", 16 | // Module resolution 17 | "baseUrl": "/", 18 | // Lets you set a base directory to resolve non-absolute module names. 19 | "esModuleInterop": true, 20 | // fixes some issues TS originally had with the ES6 spec where TypeScript treats CommonJS/AMD/UMD modules similar to ES6 module 21 | "moduleResolution": "node", 22 | // Pretty much always node for modern JS. Other option is "classic" 23 | "paths": {}, 24 | // A series of entries which re-map imports to lookup locations relative to the baseUrl 25 | 26 | // Source Map 27 | "sourceMap": true, 28 | // enables the use of source maps for debuggers and error reporting etc 29 | "sourceRoot": "/", 30 | // Specify the location where a debugger should locate TypeScript files instead of relative source locations. 31 | 32 | // Strict Checks 33 | "strict": true, 34 | "alwaysStrict": true, 35 | // Ensures that your files are parsed in the ECMAScript strict mode, and emit “use strict” for each source file. 36 | "allowUnreachableCode": false, 37 | // pick up dead code paths 38 | "noImplicitAny": true, 39 | // In some cases where no type annotations are present, TypeScript will fall back to a type of any for a variable when it cannot infer the type. 40 | "strictNullChecks": true, 41 | // When strictNullChecks is true, null and undefined have their own distinct types and you’ll get a type error if you try to use them where a concrete value is expected. 42 | "strictFunctionTypes": true, 43 | // Linter Checks 44 | "noImplicitReturns": true, 45 | "noUncheckedIndexedAccess": true, 46 | // accessing index must always check for undefined 47 | "noUnusedLocals": true, 48 | // Report errors on unused local variables. 49 | "noUnusedParameters": true, 50 | // Report errors on unused parameters in functions 51 | "jsx": "react", 52 | "skipLibCheck": true 53 | }, 54 | "include": [ 55 | "./**/*.ts" 56 | ], 57 | "exclude": [ 58 | "node_modules/**/*" 59 | ] 60 | } 61 | -------------------------------------------------------------------------------- /demo/types.ts: -------------------------------------------------------------------------------- 1 | import { CombinedState } from "@reduxjs/toolkit"; 2 | 3 | export type RootState = CombinedState<{ 4 | counterSliceReducer: CounterSliceState; 5 | }>; 6 | export interface CounterSliceState { 7 | counter: number; 8 | } 9 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Document 6 | 7 | 8 |
9 | 10 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /docs/store-116f3a41.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific language governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | // If the loader is already loaded, just stop. 15 | if (!self.define) { 16 | let registry = {}; 17 | 18 | // Used for `eval` and `importScripts` where we can't get script URL by other means. 19 | // In both cases, it's safe to use a global var because those functions are synchronous. 20 | let nextDefineUri; 21 | 22 | const singleRequire = (uri, parentUri) => { 23 | uri = new URL(uri + ".js", parentUri).href; 24 | return registry[uri] || ( 25 | 26 | new Promise(resolve => { 27 | if ("document" in self) { 28 | const script = document.createElement("script"); 29 | script.src = uri; 30 | script.onload = resolve; 31 | document.head.appendChild(script); 32 | } else { 33 | nextDefineUri = uri; 34 | importScripts(uri); 35 | resolve(); 36 | } 37 | }) 38 | 39 | .then(() => { 40 | let promise = registry[uri]; 41 | if (!promise) { 42 | throw new Error(`Module ${uri} didn’t register its module`); 43 | } 44 | return promise; 45 | }) 46 | ); 47 | }; 48 | 49 | self.define = (depsNames, factory) => { 50 | const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href; 51 | if (registry[uri]) { 52 | // Module is already loading or loaded. 53 | return; 54 | } 55 | let exports = {}; 56 | const require = depUri => singleRequire(depUri, uri); 57 | const specialDeps = { 58 | module: { uri }, 59 | exports, 60 | require 61 | }; 62 | registry[uri] = Promise.all(depsNames.map( 63 | depName => specialDeps[depName] || require(depName) 64 | )).then(deps => { 65 | factory(...deps); 66 | return exports; 67 | }); 68 | }; 69 | } 70 | define(['./selectors-bcd53b37'], (function (selectors) { 'use strict'; 71 | 72 | const rootReducer = selectors.combineReducers({ 73 | counterSliceReducer: selectors.counterSliceReducer 74 | }); 75 | const init = { 76 | counterSliceReducer: selectors.counterStoreState 77 | }; 78 | const store = selectors.configureStore({ 79 | reducer: rootReducer, 80 | preloadedState: init 81 | }); 82 | selectors.initializeWorkerStore(store, selectors.selectors); 83 | 84 | })); 85 | //# sourceMappingURL=store-116f3a41.js.map 86 | -------------------------------------------------------------------------------- /docs/store-116f3a41.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"store-116f3a41.js","sources":["../demo/store.ts"],"sourcesContent":["import { configureStore } from \"@reduxjs/toolkit\";\nimport { combineReducers } from \"redux\";\nimport { RootState } from \"./types\";\nimport { initializeWorkerStore } from \"../src\";\nimport { counterSliceReducer, counterStoreState } from \"./actions\";\nimport { selectors } from \"./selectors\";\n\nconst rootReducer = combineReducers({\n counterSliceReducer,\n});\n\nconst init: RootState = {\n counterSliceReducer: counterStoreState,\n};\n\nconst store = configureStore({\n reducer: rootReducer,\n preloadedState: init,\n});\n\ninitializeWorkerStore(store, selectors);\n"],"names":["rootReducer","combineReducers","counterSliceReducer","init","counterStoreState","store","configureStore","reducer","preloadedState","initializeWorkerStore","selectors"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,CAAMA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAe,CAAC,CAAA;AAClCC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA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A;AAClB,CAAA,CAAA,CAAC,CAAC,CAAA;AAEFM,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAqB,CAACJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAK,CAAEK,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAS,CAAC,CAAA;;"} -------------------------------------------------------------------------------- /docs/store-17ff7cea.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific language governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | // If the loader is already loaded, just stop. 15 | if (!self.define) { 16 | let registry = {}; 17 | 18 | // Used for `eval` and `importScripts` where we can't get script URL by other means. 19 | // In both cases, it's safe to use a global var because those functions are synchronous. 20 | let nextDefineUri; 21 | 22 | const singleRequire = (uri, parentUri) => { 23 | uri = new URL(uri + ".js", parentUri).href; 24 | return registry[uri] || ( 25 | 26 | new Promise(resolve => { 27 | if ("document" in self) { 28 | const script = document.createElement("script"); 29 | script.src = uri; 30 | script.onload = resolve; 31 | document.head.appendChild(script); 32 | } else { 33 | nextDefineUri = uri; 34 | importScripts(uri); 35 | resolve(); 36 | } 37 | }) 38 | 39 | .then(() => { 40 | let promise = registry[uri]; 41 | if (!promise) { 42 | throw new Error(`Module ${uri} didn’t register its module`); 43 | } 44 | return promise; 45 | }) 46 | ); 47 | }; 48 | 49 | self.define = (depsNames, factory) => { 50 | const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href; 51 | if (registry[uri]) { 52 | // Module is already loading or loaded. 53 | return; 54 | } 55 | let exports = {}; 56 | const require = depUri => singleRequire(depUri, uri); 57 | const specialDeps = { 58 | module: { uri }, 59 | exports, 60 | require 61 | }; 62 | registry[uri] = Promise.all(depsNames.map( 63 | depName => specialDeps[depName] || require(depName) 64 | )).then(deps => { 65 | factory(...deps); 66 | return exports; 67 | }); 68 | }; 69 | } 70 | define(['./selectors-e76456f7'], (function (selectors) { 'use strict'; 71 | 72 | const rootReducer = selectors.combineReducers({ 73 | counterSliceReducer: selectors.counterSliceReducer 74 | }); 75 | const init = { 76 | counterSliceReducer: selectors.counterStoreState 77 | }; 78 | const store = selectors.configureStore({ 79 | reducer: rootReducer, 80 | preloadedState: init 81 | }); 82 | selectors.initializeWorkerStore(store, selectors.selectors); 83 | 84 | })); 85 | //# sourceMappingURL=store-17ff7cea.js.map 86 | -------------------------------------------------------------------------------- /docs/store-17ff7cea.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"store-17ff7cea.js","sources":["../demo/store.ts"],"sourcesContent":["import { configureStore } from \"@reduxjs/toolkit\";\nimport { combineReducers } from \"redux\";\nimport { RootState } from \"./types\";\nimport { initializeWorkerStore } from \"../src\";\nimport { counterSliceReducer, counterStoreState } from \"./actions\";\nimport { selectors } from \"./selectors\";\n\nconst rootReducer = combineReducers({\n counterSliceReducer,\n});\n\nconst init: RootState = {\n counterSliceReducer: counterStoreState,\n};\n\nconst store = configureStore({\n reducer: rootReducer,\n preloadedState: init,\n});\n\ninitializeWorkerStore(store, selectors);\n"],"names":["rootReducer","combineReducers","counterSliceReducer","init","counterStoreState","store","configureStore","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------------------------------------------------------------- /docs/store-214b901a.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific language governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | // If the loader is already loaded, just stop. 15 | if (!self.define) { 16 | let registry = {}; 17 | 18 | // Used for `eval` and `importScripts` where we can't get script URL by other means. 19 | // In both cases, it's safe to use a global var because those functions are synchronous. 20 | let nextDefineUri; 21 | 22 | const singleRequire = (uri, parentUri) => { 23 | uri = new URL(uri + ".js", parentUri).href; 24 | return registry[uri] || ( 25 | 26 | new Promise(resolve => { 27 | if ("document" in self) { 28 | const script = document.createElement("script"); 29 | script.src = uri; 30 | script.onload = resolve; 31 | document.head.appendChild(script); 32 | } else { 33 | nextDefineUri = uri; 34 | importScripts(uri); 35 | resolve(); 36 | } 37 | }) 38 | 39 | .then(() => { 40 | let promise = registry[uri]; 41 | if (!promise) { 42 | throw new Error(`Module ${uri} didn’t register its module`); 43 | } 44 | return promise; 45 | }) 46 | ); 47 | }; 48 | 49 | self.define = (depsNames, factory) => { 50 | const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href; 51 | if (registry[uri]) { 52 | // Module is already loading or loaded. 53 | return; 54 | } 55 | let exports = {}; 56 | const require = depUri => singleRequire(depUri, uri); 57 | const specialDeps = { 58 | module: { uri }, 59 | exports, 60 | require 61 | }; 62 | registry[uri] = Promise.all(depsNames.map( 63 | depName => specialDeps[depName] || require(depName) 64 | )).then(deps => { 65 | factory(...deps); 66 | return exports; 67 | }); 68 | }; 69 | } 70 | define(['./selectors-d25cc1ab'], (function (selectors) { 'use strict'; 71 | 72 | const rootReducer = selectors.combineReducers({ 73 | counterSliceReducer: selectors.counterSliceReducer 74 | }); 75 | const init = { 76 | counterSliceReducer: selectors.counterStoreState 77 | }; 78 | const store = selectors.configureStore({ 79 | reducer: rootReducer, 80 | preloadedState: init 81 | }); 82 | selectors.initializeWorkerStore(store, selectors.selectors); 83 | 84 | })); 85 | //# sourceMappingURL=store-214b901a.js.map 86 | -------------------------------------------------------------------------------- /docs/store-214b901a.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"store-214b901a.js","sources":["../demo/store.ts"],"sourcesContent":["import { configureStore } from \"@reduxjs/toolkit\";\nimport { combineReducers } from \"redux\";\nimport { RootState } from \"./types\";\nimport { initializeWorkerStore } from \"../src\";\nimport { counterSliceReducer, counterStoreState } from \"./actions\";\nimport { selectors } from \"./selectors\";\n\nconst rootReducer = combineReducers({\n counterSliceReducer,\n});\n\nconst init: RootState = {\n counterSliceReducer: counterStoreState,\n};\n\nconst store = configureStore({\n reducer: rootReducer,\n preloadedState: init,\n});\n\ninitializeWorkerStore(store, selectors);\n"],"names":["rootReducer","combineReducers","counterSliceReducer","init","counterStoreState","store","configureStore","reducer","preloadedState","initializeWorkerStore","selectors"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,CAAMA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAe,CAAC,CAAA;AAClCC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA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P,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;EACpBQ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAc,EAAEL,CAAAA,CAAAA,CAAAA,CAAAA;AAClB,CAAA,CAAA,CAAC,CAAC,CAAA;AAEFM,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAqB,CAACJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAK,CAAEK,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAS,CAAC,CAAA;;"} -------------------------------------------------------------------------------- /docs/store-30809fea.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific language governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | // If the loader is already loaded, just stop. 15 | if (!self.define) { 16 | let registry = {}; 17 | 18 | // Used for `eval` and `importScripts` where we can't get script URL by other means. 19 | // In both cases, it's safe to use a global var because those functions are synchronous. 20 | let nextDefineUri; 21 | 22 | const singleRequire = (uri, parentUri) => { 23 | uri = new URL(uri + ".js", parentUri).href; 24 | return registry[uri] || ( 25 | 26 | new Promise(resolve => { 27 | if ("document" in self) { 28 | const script = document.createElement("script"); 29 | script.src = uri; 30 | script.onload = resolve; 31 | document.head.appendChild(script); 32 | } else { 33 | nextDefineUri = uri; 34 | importScripts(uri); 35 | resolve(); 36 | } 37 | }) 38 | 39 | .then(() => { 40 | let promise = registry[uri]; 41 | if (!promise) { 42 | throw new Error(`Module ${uri} didn’t register its module`); 43 | } 44 | return promise; 45 | }) 46 | ); 47 | }; 48 | 49 | self.define = (depsNames, factory) => { 50 | const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href; 51 | if (registry[uri]) { 52 | // Module is already loading or loaded. 53 | return; 54 | } 55 | let exports = {}; 56 | const require = depUri => singleRequire(depUri, uri); 57 | const specialDeps = { 58 | module: { uri }, 59 | exports, 60 | require 61 | }; 62 | registry[uri] = Promise.all(depsNames.map( 63 | depName => specialDeps[depName] || require(depName) 64 | )).then(deps => { 65 | factory(...deps); 66 | return exports; 67 | }); 68 | }; 69 | } 70 | define(['./selectors-c75dd2ec'], (function (selectors) { 'use strict'; 71 | 72 | const rootReducer = selectors.combineReducers({ 73 | counterSliceReducer: selectors.counterSliceReducer 74 | }); 75 | const init = { 76 | counterSliceReducer: selectors.counterStoreState 77 | }; 78 | const store = selectors.configureStore({ 79 | reducer: rootReducer, 80 | preloadedState: init 81 | }); 82 | selectors.initializeWorkerStore(store, selectors.selectors); 83 | 84 | })); 85 | //# sourceMappingURL=store-30809fea.js.map 86 | -------------------------------------------------------------------------------- /docs/store-30809fea.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"store-30809fea.js","sources":["../demo/store.ts"],"sourcesContent":["import { configureStore } from \"@reduxjs/toolkit\";\nimport { combineReducers } from \"redux\";\nimport { RootState } from \"./types\";\nimport { initializeWorkerStore } from \"../src\";\nimport { counterSliceReducer, counterStoreState } from \"./actions\";\nimport { selectors } from \"./selectors\";\n\nconst rootReducer = combineReducers({\n counterSliceReducer,\n});\n\nconst init: RootState = {\n counterSliceReducer: counterStoreState,\n};\n\nconst store = configureStore({\n reducer: rootReducer,\n preloadedState: init,\n});\n\ninitializeWorkerStore(store, selectors);\n"],"names":["rootReducer","combineReducers","counterSliceReducer","init","counterStoreState","store","configureStore","reducer","preloadedState","initializeWorkerStore","selectors"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,CAAMA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAe,CAAC,CAAA;AAClCC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA;AACF,CAAA,CAAA,CAAC,CAAC,CAAA;AAEF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAMC,IAAe,CAAG,CAAA,CAAA,CAAA;EACtBD,CAAAA,CAAAA,CAAAA,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AA,CAAqB,CAACJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAK,CAAEK,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAS,CAAC,CAAA;;"} -------------------------------------------------------------------------------- /docs/store-3be5956b.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific language governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | // If the loader is already loaded, just stop. 15 | if (!self.define) { 16 | let registry = {}; 17 | 18 | // Used for `eval` and `importScripts` where we can't get script URL by other means. 19 | // In both cases, it's safe to use a global var because those functions are synchronous. 20 | let nextDefineUri; 21 | 22 | const singleRequire = (uri, parentUri) => { 23 | uri = new URL(uri + ".js", parentUri).href; 24 | return registry[uri] || ( 25 | 26 | new Promise(resolve => { 27 | if ("document" in self) { 28 | const script = document.createElement("script"); 29 | script.src = uri; 30 | script.onload = resolve; 31 | document.head.appendChild(script); 32 | } else { 33 | nextDefineUri = uri; 34 | importScripts(uri); 35 | resolve(); 36 | } 37 | }) 38 | 39 | .then(() => { 40 | let promise = registry[uri]; 41 | if (!promise) { 42 | throw new Error(`Module ${uri} didn’t register its module`); 43 | } 44 | return promise; 45 | }) 46 | ); 47 | }; 48 | 49 | self.define = (depsNames, factory) => { 50 | const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href; 51 | if (registry[uri]) { 52 | // Module is already loading or loaded. 53 | return; 54 | } 55 | let exports = {}; 56 | const require = depUri => singleRequire(depUri, uri); 57 | const specialDeps = { 58 | module: { uri }, 59 | exports, 60 | require 61 | }; 62 | registry[uri] = Promise.all(depsNames.map( 63 | depName => specialDeps[depName] || require(depName) 64 | )).then(deps => { 65 | factory(...deps); 66 | return exports; 67 | }); 68 | }; 69 | } 70 | define(['./selectors-bd7b3cc7'], (function (selectors) { 'use strict'; 71 | 72 | const rootReducer = selectors.combineReducers({ 73 | counterSliceReducer: selectors.counterSliceReducer 74 | }); 75 | const init = { 76 | counterSliceReducer: selectors.counterStoreState 77 | }; 78 | const store = selectors.configureStore({ 79 | reducer: rootReducer, 80 | preloadedState: init 81 | }); 82 | selectors.initializeWorkerStore(store, selectors.selectors); 83 | 84 | })); 85 | //# sourceMappingURL=store-3be5956b.js.map 86 | -------------------------------------------------------------------------------- /docs/store-3be5956b.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"store-3be5956b.js","sources":["../demo/store.ts"],"sourcesContent":["import { configureStore } from \"@reduxjs/toolkit\";\nimport { combineReducers } from \"redux\";\nimport { RootState } from \"./types\";\nimport { initializeWorkerStore } from \"../src\";\nimport { counterSliceReducer, counterStoreState } from \"./actions\";\nimport { selectors } from \"./selectors\";\n\nconst rootReducer = combineReducers({\n counterSliceReducer,\n});\n\nconst init: RootState = {\n counterSliceReducer: counterStoreState,\n};\n\nconst store = configureStore({\n reducer: rootReducer,\n preloadedState: init,\n});\n\ninitializeWorkerStore(store, selectors);\n"],"names":["rootReducer","combineReducers","counterSliceReducer","init","counterStoreState","store","configureStore","reducer","preloadedState","initializeWorkerStore","selectors"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,CAAMA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAGC,CAAAA,CAAAA,CAA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AAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAc,CAAC,CAAA;EAC3BC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAO,EAAEP,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;EACpBQ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAc,EAAEL,CAAAA,CAAAA,CAAAA,CAAAA;AAClB,CAAA,CAAA,CAAC,CAAC,CAAA;AAEFM,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAqB,CAACJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAK,CAAEK,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAS,CAAC,CAAA;;"} -------------------------------------------------------------------------------- /docs/store-57001cb7.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific language governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | // If the loader is already loaded, just stop. 15 | if (!self.define) { 16 | let registry = {}; 17 | 18 | // Used for `eval` and `importScripts` where we can't get script URL by other means. 19 | // In both cases, it's safe to use a global var because those functions are synchronous. 20 | let nextDefineUri; 21 | 22 | const singleRequire = (uri, parentUri) => { 23 | uri = new URL(uri + ".js", parentUri).href; 24 | return registry[uri] || ( 25 | 26 | new Promise(resolve => { 27 | if ("document" in self) { 28 | const script = document.createElement("script"); 29 | script.src = uri; 30 | script.onload = resolve; 31 | document.head.appendChild(script); 32 | } else { 33 | nextDefineUri = uri; 34 | importScripts(uri); 35 | resolve(); 36 | } 37 | }) 38 | 39 | .then(() => { 40 | let promise = registry[uri]; 41 | if (!promise) { 42 | throw new Error(`Module ${uri} didn’t register its module`); 43 | } 44 | return promise; 45 | }) 46 | ); 47 | }; 48 | 49 | self.define = (depsNames, factory) => { 50 | const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href; 51 | if (registry[uri]) { 52 | // Module is already loading or loaded. 53 | return; 54 | } 55 | let exports = {}; 56 | const require = depUri => singleRequire(depUri, uri); 57 | const specialDeps = { 58 | module: { uri }, 59 | exports, 60 | require 61 | }; 62 | registry[uri] = Promise.all(depsNames.map( 63 | depName => specialDeps[depName] || require(depName) 64 | )).then(deps => { 65 | factory(...deps); 66 | return exports; 67 | }); 68 | }; 69 | } 70 | define(['./selectors-5348b7c3'], (function (selectors) { 'use strict'; 71 | 72 | const rootReducer = selectors.combineReducers({ 73 | counterSliceReducer: selectors.counterSliceReducer 74 | }); 75 | const init = { 76 | counterSliceReducer: selectors.counterStoreState 77 | }; 78 | const store = selectors.configureStore({ 79 | reducer: rootReducer, 80 | preloadedState: init 81 | }); 82 | selectors.initializeWorkerStore(store, selectors.selectors); 83 | 84 | })); 85 | //# sourceMappingURL=store-57001cb7.js.map 86 | -------------------------------------------------------------------------------- /docs/store-57001cb7.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"store-57001cb7.js","sources":["../demo/store.ts"],"sourcesContent":["import { configureStore } from \"@reduxjs/toolkit\";\nimport { combineReducers } from \"redux\";\nimport { RootState } from \"./types\";\nimport { initializeWorkerStore } from \"../src\";\nimport { counterSliceReducer, counterStoreState } from \"./actions\";\nimport { selectors } from \"./selectors\";\n\nconst rootReducer = combineReducers({\n counterSliceReducer,\n});\n\nconst init: RootState = {\n counterSliceReducer: counterStoreState,\n};\n\nconst store = configureStore({\n reducer: rootReducer,\n preloadedState: init,\n});\n\ninitializeWorkerStore(store, selectors);\n"],"names":["rootReducer","combineReducers","counterSliceReducer","init","counterStoreState","store","configureStore","reducer","preloadedState","initializeWorkerStore","selectors"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,CAAMA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAe,CAAC,CAAA;AAClCC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CA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AEFM,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAqB,CAACJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAK,CAAEK,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAS,CAAC,CAAA;;"} -------------------------------------------------------------------------------- /docs/store-6c69f58d.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific language governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | // If the loader is already loaded, just stop. 15 | if (!self.define) { 16 | let registry = {}; 17 | 18 | // Used for `eval` and `importScripts` where we can't get script URL by other means. 19 | // In both cases, it's safe to use a global var because those functions are synchronous. 20 | let nextDefineUri; 21 | 22 | const singleRequire = (uri, parentUri) => { 23 | uri = new URL(uri + ".js", parentUri).href; 24 | return registry[uri] || ( 25 | 26 | new Promise(resolve => { 27 | if ("document" in self) { 28 | const script = document.createElement("script"); 29 | script.src = uri; 30 | script.onload = resolve; 31 | document.head.appendChild(script); 32 | } else { 33 | nextDefineUri = uri; 34 | importScripts(uri); 35 | resolve(); 36 | } 37 | }) 38 | 39 | .then(() => { 40 | let promise = registry[uri]; 41 | if (!promise) { 42 | throw new Error(`Module ${uri} didn’t register its module`); 43 | } 44 | return promise; 45 | }) 46 | ); 47 | }; 48 | 49 | self.define = (depsNames, factory) => { 50 | const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href; 51 | if (registry[uri]) { 52 | // Module is already loading or loaded. 53 | return; 54 | } 55 | let exports = {}; 56 | const require = depUri => singleRequire(depUri, uri); 57 | const specialDeps = { 58 | module: { uri }, 59 | exports, 60 | require 61 | }; 62 | registry[uri] = Promise.all(depsNames.map( 63 | depName => specialDeps[depName] || require(depName) 64 | )).then(deps => { 65 | factory(...deps); 66 | return exports; 67 | }); 68 | }; 69 | } 70 | define(['./selectors-0165158a'], (function (selectors) { 'use strict'; 71 | 72 | const rootReducer = selectors.combineReducers({ 73 | counterSliceReducer: selectors.counterSliceReducer 74 | }); 75 | const init = { 76 | counterSliceReducer: selectors.counterStoreState 77 | }; 78 | const store = selectors.configureStore({ 79 | reducer: rootReducer, 80 | preloadedState: init 81 | }); 82 | selectors.initializeWorkerStore(store, selectors.selectors); 83 | 84 | })); 85 | //# sourceMappingURL=store-6c69f58d.js.map 86 | -------------------------------------------------------------------------------- /docs/store-6c69f58d.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"store-6c69f58d.js","sources":["../demo/store.ts"],"sourcesContent":["import { configureStore } from \"@reduxjs/toolkit\";\nimport { combineReducers } from \"redux\";\nimport { RootState } from \"./types\";\nimport { initializeWorkerStore } from \"../src\";\nimport { counterSliceReducer, counterStoreState } from \"./actions\";\nimport { selectors } from \"./selectors\";\n\nconst rootReducer = combineReducers({\n counterSliceReducer,\n});\n\nconst init: RootState = {\n counterSliceReducer: counterStoreState,\n};\n\nconst store = configureStore({\n reducer: rootReducer,\n preloadedState: init,\n});\n\ninitializeWorkerStore(store, selectors);\n"],"names":["rootReducer","combineReducers","counterSliceReducer","init","counterStoreState","store","configureStore","reducer","preloadedState","initializeWorkerStore","selectors"],"mappings":";;;;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A,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA;AACvB,CAAA,CAAA,CAAC,CAAA;EAED,CAAMC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAK,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAc,CAAC,CAAA;EAC3BC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAO,EAAEP,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;EACpBQ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAc,EAAEL,CAAAA,CAAAA,CAAAA,CAAAA;AAClB,CAAA,CAAA,CAAC,CAAC,CAAA;AAEFM,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAqB,CAACJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAK,CAAEK,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAS,CAAC,CAAA;;"} -------------------------------------------------------------------------------- /docs/store-74036116.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific language governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | // If the loader is already loaded, just stop. 15 | if (!self.define) { 16 | let registry = {}; 17 | 18 | // Used for `eval` and `importScripts` where we can't get script URL by other means. 19 | // In both cases, it's safe to use a global var because those functions are synchronous. 20 | let nextDefineUri; 21 | 22 | const singleRequire = (uri, parentUri) => { 23 | uri = new URL(uri + ".js", parentUri).href; 24 | return registry[uri] || ( 25 | 26 | new Promise(resolve => { 27 | if ("document" in self) { 28 | const script = document.createElement("script"); 29 | script.src = uri; 30 | script.onload = resolve; 31 | document.head.appendChild(script); 32 | } else { 33 | nextDefineUri = uri; 34 | importScripts(uri); 35 | resolve(); 36 | } 37 | }) 38 | 39 | .then(() => { 40 | let promise = registry[uri]; 41 | if (!promise) { 42 | throw new Error(`Module ${uri} didn’t register its module`); 43 | } 44 | return promise; 45 | }) 46 | ); 47 | }; 48 | 49 | self.define = (depsNames, factory) => { 50 | const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href; 51 | if (registry[uri]) { 52 | // Module is already loading or loaded. 53 | return; 54 | } 55 | let exports = {}; 56 | const require = depUri => singleRequire(depUri, uri); 57 | const specialDeps = { 58 | module: { uri }, 59 | exports, 60 | require 61 | }; 62 | registry[uri] = Promise.all(depsNames.map( 63 | depName => specialDeps[depName] || require(depName) 64 | )).then(deps => { 65 | factory(...deps); 66 | return exports; 67 | }); 68 | }; 69 | } 70 | define(['./selectors-d7ee1f2f'], (function (selectors) { 'use strict'; 71 | 72 | const rootReducer = selectors.combineReducers({ 73 | counterSliceReducer: selectors.counterSliceReducer 74 | }); 75 | const init = { 76 | counterSliceReducer: selectors.counterStoreState 77 | }; 78 | const store = selectors.configureStore({ 79 | reducer: rootReducer, 80 | preloadedState: init 81 | }); 82 | selectors.initializeWorkerStore(store, selectors.selectors); 83 | 84 | })); 85 | //# sourceMappingURL=store-74036116.js.map 86 | -------------------------------------------------------------------------------- /docs/store-74036116.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"store-74036116.js","sources":["../demo/store.ts"],"sourcesContent":["import { configureStore } from \"@reduxjs/toolkit\";\nimport { combineReducers } from \"redux\";\nimport { RootState } from \"./types\";\nimport { initializeWorkerStore } from \"../src\";\nimport { counterSliceReducer, counterStoreState } from \"./actions\";\nimport { selectors } from \"./selectors\";\n\nconst rootReducer = combineReducers({\n counterSliceReducer,\n});\n\nconst init: RootState = {\n counterSliceReducer: counterStoreState,\n};\n\nconst store = configureStore({\n reducer: rootReducer,\n preloadedState: init,\n});\n\ninitializeWorkerStore(store, selectors);\n"],"names":["rootReducer","combineReducers","counterSliceReducer","init","counterStoreState","store","configureStore","reducer","preloadedState","initializeWorkerStore","selectors"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,CAAMA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAe,CAAC,CAAA;AAClCC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,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CAAA,CAAA,CAAA,CAAA,CAAA;EACpBQ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAc,EAAEL,CAAAA,CAAAA,CAAAA,CAAAA;AAClB,CAAA,CAAA,CAAC,CAAC,CAAA;AAEFM,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAqB,CAACJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAK,CAAEK,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAS,CAAC,CAAA;;"} -------------------------------------------------------------------------------- /docs/store-8382a735.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific language governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | // If the loader is already loaded, just stop. 15 | if (!self.define) { 16 | let registry = {}; 17 | 18 | // Used for `eval` and `importScripts` where we can't get script URL by other means. 19 | // In both cases, it's safe to use a global var because those functions are synchronous. 20 | let nextDefineUri; 21 | 22 | const singleRequire = (uri, parentUri) => { 23 | uri = new URL(uri + ".js", parentUri).href; 24 | return registry[uri] || ( 25 | 26 | new Promise(resolve => { 27 | if ("document" in self) { 28 | const script = document.createElement("script"); 29 | script.src = uri; 30 | script.onload = resolve; 31 | document.head.appendChild(script); 32 | } else { 33 | nextDefineUri = uri; 34 | importScripts(uri); 35 | resolve(); 36 | } 37 | }) 38 | 39 | .then(() => { 40 | let promise = registry[uri]; 41 | if (!promise) { 42 | throw new Error(`Module ${uri} didn’t register its module`); 43 | } 44 | return promise; 45 | }) 46 | ); 47 | }; 48 | 49 | self.define = (depsNames, factory) => { 50 | const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href; 51 | if (registry[uri]) { 52 | // Module is already loading or loaded. 53 | return; 54 | } 55 | let exports = {}; 56 | const require = depUri => singleRequire(depUri, uri); 57 | const specialDeps = { 58 | module: { uri }, 59 | exports, 60 | require 61 | }; 62 | registry[uri] = Promise.all(depsNames.map( 63 | depName => specialDeps[depName] || require(depName) 64 | )).then(deps => { 65 | factory(...deps); 66 | return exports; 67 | }); 68 | }; 69 | } 70 | define(['./selectors-f931d2e7'], (function (selectors) { 'use strict'; 71 | 72 | const rootReducer = selectors.combineReducers({ 73 | counterSliceReducer: selectors.counterSliceReducer 74 | }); 75 | const init = { 76 | counterSliceReducer: selectors.counterStoreState 77 | }; 78 | const store = selectors.configureStore({ 79 | reducer: rootReducer, 80 | preloadedState: init 81 | }); 82 | selectors.initializeWorkerStore(store, selectors.selectors); 83 | 84 | })); 85 | //# sourceMappingURL=store-8382a735.js.map 86 | -------------------------------------------------------------------------------- /docs/store-8382a735.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"store-8382a735.js","sources":["../demo/store.ts"],"sourcesContent":["import { configureStore } from \"@reduxjs/toolkit\";\nimport { combineReducers } from \"redux\";\nimport { RootState } from \"./types\";\nimport { initializeWorkerStore } from \"../src\";\nimport { counterSliceReducer, counterStoreState } from \"./actions\";\nimport { selectors } from \"./selectors\";\n\nconst rootReducer = combineReducers({\n counterSliceReducer,\n});\n\nconst init: RootState = {\n counterSliceReducer: counterStoreState,\n};\n\nconst store = configureStore({\n reducer: rootReducer,\n preloadedState: init,\n});\n\ninitializeWorkerStore(store, selectors);\n"],"names":["rootReducer","combineReducers","counterSliceReducer","init","counterStoreState","store","configureStore","reducer","preloadedState","initializeWorkerStore","selectors"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,CAAMA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAe,CAAC,CAAA;AAClCC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA;AACF,CAAA,CAAA,CAAC,CAAC,CAAA;AAEF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAMC,IAAe,CAAG,CAAA,CAAA,CAAA;EACtBD,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CA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,CAAK,CAAEK,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAS,CAAC,CAAA;;"} -------------------------------------------------------------------------------- /docs/store-a0cfcf87.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific language governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | // If the loader is already loaded, just stop. 15 | if (!self.define) { 16 | let registry = {}; 17 | 18 | // Used for `eval` and `importScripts` where we can't get script URL by other means. 19 | // In both cases, it's safe to use a global var because those functions are synchronous. 20 | let nextDefineUri; 21 | 22 | const singleRequire = (uri, parentUri) => { 23 | uri = new URL(uri + ".js", parentUri).href; 24 | return registry[uri] || ( 25 | 26 | new Promise(resolve => { 27 | if ("document" in self) { 28 | const script = document.createElement("script"); 29 | script.src = uri; 30 | script.onload = resolve; 31 | document.head.appendChild(script); 32 | } else { 33 | nextDefineUri = uri; 34 | importScripts(uri); 35 | resolve(); 36 | } 37 | }) 38 | 39 | .then(() => { 40 | let promise = registry[uri]; 41 | if (!promise) { 42 | throw new Error(`Module ${uri} didn’t register its module`); 43 | } 44 | return promise; 45 | }) 46 | ); 47 | }; 48 | 49 | self.define = (depsNames, factory) => { 50 | const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href; 51 | if (registry[uri]) { 52 | // Module is already loading or loaded. 53 | return; 54 | } 55 | let exports = {}; 56 | const require = depUri => singleRequire(depUri, uri); 57 | const specialDeps = { 58 | module: { uri }, 59 | exports, 60 | require 61 | }; 62 | registry[uri] = Promise.all(depsNames.map( 63 | depName => specialDeps[depName] || require(depName) 64 | )).then(deps => { 65 | factory(...deps); 66 | return exports; 67 | }); 68 | }; 69 | } 70 | define(['./selectors-0825d3f5'], (function (selectors) { 'use strict'; 71 | 72 | const rootReducer = selectors.combineReducers({ 73 | counterSliceReducer: selectors.counterSliceReducer 74 | }); 75 | const init = { 76 | counterSliceReducer: selectors.counterStoreState 77 | }; 78 | const store = selectors.configureStore({ 79 | reducer: rootReducer, 80 | preloadedState: init 81 | }); 82 | selectors.initializeWorkerStore(store, selectors.selectors); 83 | 84 | })); 85 | //# sourceMappingURL=store-a0cfcf87.js.map 86 | -------------------------------------------------------------------------------- /docs/store-a0cfcf87.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"store-a0cfcf87.js","sources":["../demo/store.ts"],"sourcesContent":["import { configureStore } from \"@reduxjs/toolkit\";\nimport { combineReducers } from \"redux\";\nimport { RootState } from \"./types\";\nimport { initializeWorkerStore } from \"../src\";\nimport { counterSliceReducer, counterStoreState } from \"./actions\";\nimport { selectors } from \"./selectors\";\n\nconst rootReducer = combineReducers({\n counterSliceReducer,\n});\n\nconst init: RootState = {\n counterSliceReducer: counterStoreState,\n};\n\nconst store = configureStore({\n reducer: rootReducer,\n preloadedState: init,\n});\n\ninitializeWorkerStore(store, selectors);\n"],"names":["rootReducer","combineReducers","counterSliceReducer","init","counterStoreState","store","configureStore","reducer","preloadedState","initializeWorkerStore","selectors"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,CAAMA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA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A,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAc,CAAC,CAAA;EAC3BC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAO,EAAEP,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;EACpBQ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAc,EAAEL,CAAAA,CAAAA,CAAAA,CAAAA;AAClB,CAAA,CAAA,CAAC,CAAC,CAAA;AAEFM,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAqB,CAACJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAK,CAAEK,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAS,CAAC,CAAA;;"} -------------------------------------------------------------------------------- /docs/store-a78b227a.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific language governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | // If the loader is already loaded, just stop. 15 | if (!self.define) { 16 | let registry = {}; 17 | 18 | // Used for `eval` and `importScripts` where we can't get script URL by other means. 19 | // In both cases, it's safe to use a global var because those functions are synchronous. 20 | let nextDefineUri; 21 | 22 | const singleRequire = (uri, parentUri) => { 23 | uri = new URL(uri + ".js", parentUri).href; 24 | return registry[uri] || ( 25 | 26 | new Promise(resolve => { 27 | if ("document" in self) { 28 | const script = document.createElement("script"); 29 | script.src = uri; 30 | script.onload = resolve; 31 | document.head.appendChild(script); 32 | } else { 33 | nextDefineUri = uri; 34 | importScripts(uri); 35 | resolve(); 36 | } 37 | }) 38 | 39 | .then(() => { 40 | let promise = registry[uri]; 41 | if (!promise) { 42 | throw new Error(`Module ${uri} didn’t register its module`); 43 | } 44 | return promise; 45 | }) 46 | ); 47 | }; 48 | 49 | self.define = (depsNames, factory) => { 50 | const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href; 51 | if (registry[uri]) { 52 | // Module is already loading or loaded. 53 | return; 54 | } 55 | let exports = {}; 56 | const require = depUri => singleRequire(depUri, uri); 57 | const specialDeps = { 58 | module: { uri }, 59 | exports, 60 | require 61 | }; 62 | registry[uri] = Promise.all(depsNames.map( 63 | depName => specialDeps[depName] || require(depName) 64 | )).then(deps => { 65 | factory(...deps); 66 | return exports; 67 | }); 68 | }; 69 | } 70 | define(['./selectors-81c38f95'], (function (selectors) { 'use strict'; 71 | 72 | const rootReducer = selectors.combineReducers({ 73 | counterSliceReducer: selectors.counterSliceReducer 74 | }); 75 | const init = { 76 | counterSliceReducer: selectors.counterStoreState 77 | }; 78 | const store = selectors.configureStore({ 79 | reducer: rootReducer, 80 | preloadedState: init 81 | }); 82 | selectors.initializeWorkerStore(store, selectors.selectors); 83 | 84 | })); 85 | //# sourceMappingURL=store-a78b227a.js.map 86 | -------------------------------------------------------------------------------- /docs/store-a78b227a.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"store-a78b227a.js","sources":["../demo/store.ts"],"sourcesContent":["import { configureStore } from \"@reduxjs/toolkit\";\nimport { combineReducers } from \"redux\";\nimport { RootState } from \"./types\";\nimport { initializeWorkerStore } from \"../src\";\nimport { counterSliceReducer, counterStoreState } from \"./actions\";\nimport { selectors } from \"./selectors\";\n\nconst rootReducer = combineReducers({\n counterSliceReducer,\n});\n\nconst init: RootState = {\n counterSliceReducer: counterStoreState,\n};\n\nconst store = configureStore({\n reducer: rootReducer,\n preloadedState: init,\n});\n\ninitializeWorkerStore(store, selectors);\n"],"names":["rootReducer","combineReducers","counterSliceReducer","init","counterStoreState","store","configureStore","reducer","preloadedState","initializeWorkerStore","selectors"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,CAAMA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAe,CAAC,CAAA;AAClCC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA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A,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAqB,CAACJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAK,CAAEK,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAS,CAAC,CAAA;;"} -------------------------------------------------------------------------------- /docs/store-b1479177.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific language governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | // If the loader is already loaded, just stop. 15 | if (!self.define) { 16 | let registry = {}; 17 | 18 | // Used for `eval` and `importScripts` where we can't get script URL by other means. 19 | // In both cases, it's safe to use a global var because those functions are synchronous. 20 | let nextDefineUri; 21 | 22 | const singleRequire = (uri, parentUri) => { 23 | uri = new URL(uri + ".js", parentUri).href; 24 | return registry[uri] || ( 25 | 26 | new Promise(resolve => { 27 | if ("document" in self) { 28 | const script = document.createElement("script"); 29 | script.src = uri; 30 | script.onload = resolve; 31 | document.head.appendChild(script); 32 | } else { 33 | nextDefineUri = uri; 34 | importScripts(uri); 35 | resolve(); 36 | } 37 | }) 38 | 39 | .then(() => { 40 | let promise = registry[uri]; 41 | if (!promise) { 42 | throw new Error(`Module ${uri} didn’t register its module`); 43 | } 44 | return promise; 45 | }) 46 | ); 47 | }; 48 | 49 | self.define = (depsNames, factory) => { 50 | const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href; 51 | if (registry[uri]) { 52 | // Module is already loading or loaded. 53 | return; 54 | } 55 | let exports = {}; 56 | const require = depUri => singleRequire(depUri, uri); 57 | const specialDeps = { 58 | module: { uri }, 59 | exports, 60 | require 61 | }; 62 | registry[uri] = Promise.all(depsNames.map( 63 | depName => specialDeps[depName] || require(depName) 64 | )).then(deps => { 65 | factory(...deps); 66 | return exports; 67 | }); 68 | }; 69 | } 70 | define(['./selectors-4d5eb81d'], (function (selectors) { 'use strict'; 71 | 72 | const rootReducer = selectors.combineReducers({ 73 | counterSliceReducer: selectors.counterSliceReducer 74 | }); 75 | const init = { 76 | counterSliceReducer: selectors.counterStoreState 77 | }; 78 | const store = selectors.configureStore({ 79 | reducer: rootReducer, 80 | preloadedState: init 81 | }); 82 | selectors.initializeWorkerStore(store, selectors.selectors); 83 | 84 | })); 85 | //# sourceMappingURL=store-b1479177.js.map 86 | -------------------------------------------------------------------------------- /docs/store-b1479177.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"store-b1479177.js","sources":["../demo/store.ts"],"sourcesContent":["import { configureStore } from \"@reduxjs/toolkit\";\nimport { combineReducers } from \"redux\";\nimport { RootState } from \"./types\";\nimport { initializeWorkerStore } from \"../src\";\nimport { counterSliceReducer, counterStoreState } from \"./actions\";\nimport { selectors } from \"./selectors\";\n\nconst rootReducer = combineReducers({\n counterSliceReducer,\n});\n\nconst init: RootState = {\n counterSliceReducer: counterStoreState,\n};\n\nconst store = configureStore({\n reducer: rootReducer,\n preloadedState: init,\n});\n\ninitializeWorkerStore(store, selectors);\n"],"names":["rootReducer","combineReducers","counterSliceReducer","init","counterStoreState","store","configureStore","reducer","preloadedState","initializeWorkerStore","selectors"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAAAA,CAAAA,CAAAA;AACvB,CAAA,CAAA,CAAC,CAAA;EAED,CAAMC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAK,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAc,CAAC,CAAA;EAC3BC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAO,EAAEP,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;EACpBQ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAc,EAAEL,CAAAA,CAAAA,CAAAA,CAAAA;AAClB,CAAA,CAAA,CAAC,CAAC,CAAA;AAEFM,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAqB,CAACJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAK,CAAEK,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAS,CAAC,CAAA;;"} -------------------------------------------------------------------------------- /docs/store-bd60a451.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific language governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | // If the loader is already loaded, just stop. 15 | if (!self.define) { 16 | let registry = {}; 17 | 18 | // Used for `eval` and `importScripts` where we can't get script URL by other means. 19 | // In both cases, it's safe to use a global var because those functions are synchronous. 20 | let nextDefineUri; 21 | 22 | const singleRequire = (uri, parentUri) => { 23 | uri = new URL(uri + ".js", parentUri).href; 24 | return registry[uri] || ( 25 | 26 | new Promise(resolve => { 27 | if ("document" in self) { 28 | const script = document.createElement("script"); 29 | script.src = uri; 30 | script.onload = resolve; 31 | document.head.appendChild(script); 32 | } else { 33 | nextDefineUri = uri; 34 | importScripts(uri); 35 | resolve(); 36 | } 37 | }) 38 | 39 | .then(() => { 40 | let promise = registry[uri]; 41 | if (!promise) { 42 | throw new Error(`Module ${uri} didn’t register its module`); 43 | } 44 | return promise; 45 | }) 46 | ); 47 | }; 48 | 49 | self.define = (depsNames, factory) => { 50 | const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href; 51 | if (registry[uri]) { 52 | // Module is already loading or loaded. 53 | return; 54 | } 55 | let exports = {}; 56 | const require = depUri => singleRequire(depUri, uri); 57 | const specialDeps = { 58 | module: { uri }, 59 | exports, 60 | require 61 | }; 62 | registry[uri] = Promise.all(depsNames.map( 63 | depName => specialDeps[depName] || require(depName) 64 | )).then(deps => { 65 | factory(...deps); 66 | return exports; 67 | }); 68 | }; 69 | } 70 | define(['./selectors-23e421b4'], (function (selectors) { 'use strict'; 71 | 72 | const rootReducer = selectors.combineReducers({ 73 | counterSliceReducer: selectors.counterSliceReducer 74 | }); 75 | const init = { 76 | counterSliceReducer: selectors.counterStoreState 77 | }; 78 | const store = selectors.configureStore({ 79 | reducer: rootReducer, 80 | preloadedState: init 81 | }); 82 | selectors.initializeWorkerStore(store, selectors.selectors); 83 | 84 | })); 85 | //# sourceMappingURL=store-bd60a451.js.map 86 | -------------------------------------------------------------------------------- /docs/store-bd60a451.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"store-bd60a451.js","sources":["../demo/store.ts"],"sourcesContent":["import { configureStore } from \"@reduxjs/toolkit\";\nimport { combineReducers } from \"redux\";\nimport { RootState } from \"./types\";\nimport { initializeWorkerStore } from \"../src\";\nimport { counterSliceReducer, counterStoreState } from \"./actions\";\nimport { selectors } from \"./selectors\";\n\nconst rootReducer = combineReducers({\n counterSliceReducer,\n});\n\nconst init: RootState = {\n counterSliceReducer: counterStoreState,\n};\n\nconst store = configureStore({\n reducer: rootReducer,\n preloadedState: init,\n});\n\ninitializeWorkerStore(store, selectors);\n"],"names":["rootReducer","combineReducers","counterSliceReducer","init","counterStoreState","store","configureStore","reducer","preloadedState","initializeWorkerStore","selectors"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,CAAMA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAe,CAAC,CAAA;AAClCC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAA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AAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAc,EAAEL,CAAAA,CAAAA,CAAAA,CAAAA;AAClB,CAAA,CAAA,CAAC,CAAC,CAAA;AAEFM,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAqB,CAACJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAK,CAAEK,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAS,CAAC,CAAA;;"} -------------------------------------------------------------------------------- /docs/store-eb2781ee.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific language governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | // If the loader is already loaded, just stop. 15 | if (!self.define) { 16 | let registry = {}; 17 | 18 | // Used for `eval` and `importScripts` where we can't get script URL by other means. 19 | // In both cases, it's safe to use a global var because those functions are synchronous. 20 | let nextDefineUri; 21 | 22 | const singleRequire = (uri, parentUri) => { 23 | uri = new URL(uri + ".js", parentUri).href; 24 | return registry[uri] || ( 25 | 26 | new Promise(resolve => { 27 | if ("document" in self) { 28 | const script = document.createElement("script"); 29 | script.src = uri; 30 | script.onload = resolve; 31 | document.head.appendChild(script); 32 | } else { 33 | nextDefineUri = uri; 34 | importScripts(uri); 35 | resolve(); 36 | } 37 | }) 38 | 39 | .then(() => { 40 | let promise = registry[uri]; 41 | if (!promise) { 42 | throw new Error(`Module ${uri} didn’t register its module`); 43 | } 44 | return promise; 45 | }) 46 | ); 47 | }; 48 | 49 | self.define = (depsNames, factory) => { 50 | const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href; 51 | if (registry[uri]) { 52 | // Module is already loading or loaded. 53 | return; 54 | } 55 | let exports = {}; 56 | const require = depUri => singleRequire(depUri, uri); 57 | const specialDeps = { 58 | module: { uri }, 59 | exports, 60 | require 61 | }; 62 | registry[uri] = Promise.all(depsNames.map( 63 | depName => specialDeps[depName] || require(depName) 64 | )).then(deps => { 65 | factory(...deps); 66 | return exports; 67 | }); 68 | }; 69 | } 70 | define(['./selectors-6e9e04a0'], (function (selectors) { 'use strict'; 71 | 72 | const rootReducer = selectors.combineReducers({ 73 | counterSliceReducer: selectors.counterSliceReducer 74 | }); 75 | const init = { 76 | counterSliceReducer: selectors.counterStoreState 77 | }; 78 | const store = selectors.configureStore({ 79 | reducer: rootReducer, 80 | preloadedState: init 81 | }); 82 | selectors.initializeWorkerStore(store, selectors.selectors); 83 | 84 | })); 85 | //# sourceMappingURL=store-eb2781ee.js.map 86 | -------------------------------------------------------------------------------- /docs/store-eb2781ee.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"store-eb2781ee.js","sources":["../demo/store.ts"],"sourcesContent":["import { configureStore } from \"@reduxjs/toolkit\";\nimport { combineReducers } from \"redux\";\nimport { RootState } from \"./types\";\nimport { initializeWorkerStore } from \"../src\";\nimport { counterSliceReducer, counterStoreState } from \"./actions\";\nimport { selectors } from \"./selectors\";\n\nconst rootReducer = combineReducers({\n counterSliceReducer,\n});\n\nconst init: RootState = {\n counterSliceReducer: counterStoreState,\n};\n\nconst store = configureStore({\n reducer: rootReducer,\n preloadedState: init,\n});\n\ninitializeWorkerStore(store, selectors);\n"],"names":["rootReducer","combineReducers","counterSliceReducer","init","counterStoreState","store","configureStore","reducer","preloadedState","initializeWorkerStore","selectors"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,CAAMA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAe,CAAC,CAAA;AAClCC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA;AACF,CAAA,CAAA,CAAC,CAAC,CAAA;AAEF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAMC,IAAe,CAAG,CAAA,CAAA,CAAA;EACtBD,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CA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CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAS,CAAC,CAAA;;"} -------------------------------------------------------------------------------- /docs/store-ed92604c.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2018 Google Inc. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * Unless required by applicable law or agreed to in writing, software 8 | * distributed under the License is distributed on an "AS IS" BASIS, 9 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | * See the License for the specific language governing permissions and 11 | * limitations under the License. 12 | */ 13 | 14 | // If the loader is already loaded, just stop. 15 | if (!self.define) { 16 | let registry = {}; 17 | 18 | // Used for `eval` and `importScripts` where we can't get script URL by other means. 19 | // In both cases, it's safe to use a global var because those functions are synchronous. 20 | let nextDefineUri; 21 | 22 | const singleRequire = (uri, parentUri) => { 23 | uri = new URL(uri + ".js", parentUri).href; 24 | return registry[uri] || ( 25 | 26 | new Promise(resolve => { 27 | if ("document" in self) { 28 | const script = document.createElement("script"); 29 | script.src = uri; 30 | script.onload = resolve; 31 | document.head.appendChild(script); 32 | } else { 33 | nextDefineUri = uri; 34 | importScripts(uri); 35 | resolve(); 36 | } 37 | }) 38 | 39 | .then(() => { 40 | let promise = registry[uri]; 41 | if (!promise) { 42 | throw new Error(`Module ${uri} didn’t register its module`); 43 | } 44 | return promise; 45 | }) 46 | ); 47 | }; 48 | 49 | self.define = (depsNames, factory) => { 50 | const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href; 51 | if (registry[uri]) { 52 | // Module is already loading or loaded. 53 | return; 54 | } 55 | let exports = {}; 56 | const require = depUri => singleRequire(depUri, uri); 57 | const specialDeps = { 58 | module: { uri }, 59 | exports, 60 | require 61 | }; 62 | registry[uri] = Promise.all(depsNames.map( 63 | depName => specialDeps[depName] || require(depName) 64 | )).then(deps => { 65 | factory(...deps); 66 | return exports; 67 | }); 68 | }; 69 | } 70 | define(['./selectors-e275a285'], (function (selectors) { 'use strict'; 71 | 72 | const rootReducer = selectors.combineReducers({ 73 | counterSliceReducer: selectors.counterSliceReducer 74 | }); 75 | const init = { 76 | counterSliceReducer: selectors.counterStoreState 77 | }; 78 | const store = selectors.configureStore({ 79 | reducer: rootReducer, 80 | preloadedState: init 81 | }); 82 | selectors.initializeWorkerStore(store, selectors.selectors); 83 | 84 | })); 85 | //# sourceMappingURL=store-ed92604c.js.map 86 | -------------------------------------------------------------------------------- /docs/store-ed92604c.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"store-ed92604c.js","sources":["../demo/store.ts"],"sourcesContent":["import { configureStore } from \"@reduxjs/toolkit\";\nimport { combineReducers } from \"redux\";\nimport { RootState } from \"./types\";\nimport { initializeWorkerStore } from \"../src\";\nimport { counterSliceReducer, counterStoreState } from \"./actions\";\nimport { selectors } from \"./selectors\";\n\nconst rootReducer = combineReducers({\n counterSliceReducer,\n});\n\nconst init: RootState = {\n counterSliceReducer: counterStoreState,\n};\n\nconst store = configureStore({\n reducer: rootReducer,\n preloadedState: init,\n});\n\ninitializeWorkerStore(store, selectors);\n"],"names":["rootReducer","combineReducers","counterSliceReducer","init","counterStoreState","store","configureStore","reducer","preloadedState","initializeWorkerStore","selectors"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,CAAMA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAW,CAAGC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAA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AAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAc,CAAC,CAAA;EAC3BC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAO,EAAEP,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;EACpBQ,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAc,EAAEL,CAAAA,CAAAA,CAAAA,CAAAA;AAClB,CAAA,CAAA,CAAC,CAAC,CAAA;AAEFM,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAqB,CAACJ,CAAAA,CAAAA,CAAAA,CAAAA,CAAK,CAAEK,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAS,CAAC,CAAA;;"} -------------------------------------------------------------------------------- /out/index.cjs: -------------------------------------------------------------------------------- 1 | var e=require("@preact/signals-react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a,r=/*#__PURE__*/t(require("use-deep-compare-effect")),n=new e.Signal(null),u=new Map;exports.createWorkerSelector=function(e,t){return{name:e,fn:t}},exports.dispatch=function(e){var t;null==(t=a)||t.postMessage({type:"dispatch",action:e})},exports.initializeWorkerStore=function(e,t){function a(a,r){var n,u=null==t||null==(n=t[a.selector])?void 0:n.fn,s=a.params;if(u){var i=u.apply(void 0,[e.getState()].concat(s));postMessage({uuid:r,value:i})}}addEventListener("message",function(t){var r=t.data;switch(r.type){case"dispatch":e.dispatch(r.action);break;case"subscribe":u.set(r.uuid,r.selector),a(r.selector,r.uuid);break;case"unsubscribe":u.delete(r.uuid)}}),e.subscribe(function(){u.forEach(a)})},exports.initializeWorkerStoreListener=function(e){a=e,e.addEventListener("message",function(e){n.value=e.data})},exports.useWorkerSelector=function(t,u){var s=null==u?void 0:u.defaultValue,i=u&&"params"in u?u.params:[],o=e.useSignal(""),c=e.useSignal(s);return e.useSignalEffect(function(){var e=n.value;e&&e.uuid===o.peek()&&(c.value=e.value)}),r.default(function(){var e,r=crypto.randomUUID();return o.value=r,null==(e=a)||e.postMessage({type:"subscribe",uuid:r,selector:{selector:t.name,params:i}}),function(){var e;null==(e=a)||e.postMessage({type:"unsubscribe",uuid:r})}},[t,i]),c}; 2 | //# sourceMappingURL=index.cjs.map 3 | -------------------------------------------------------------------------------- /out/index.cjs.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.cjs","sources":["../src/main-thread-functions.ts","../src/worker-functions.ts"],"sourcesContent":["import { Signal, useSignal, useSignalEffect } from \"@preact/signals-react\";\nimport { Action } from \"redux\";\nimport useDeepCompareEffect from \"use-deep-compare-effect\";\nimport {\n FunctionParameters,\n SelectorFunction,\n SelectorReturn,\n WorkerSelector,\n} from \"./types\";\n\nlet worker: Worker | undefined;\nconst workerEvent = new Signal | null>(null);\n\nfunction initializeWorkerStoreListener(w: Worker) {\n worker = w;\n\n w.addEventListener(\n \"message\",\n ({ data }: MessageEvent>) => {\n workerEvent.value = data;\n }\n );\n}\n\nfunction dispatch(action: Action) {\n worker?.postMessage({ type: \"dispatch\", action });\n}\n\nfunction useWorkerSelector<\n Fn extends SelectorFunction[0], ReturnType>,\n Params extends FunctionParameters,\n Return extends ReturnType,\n RequiredParams extends [Params[0]] extends [undefined]\n ? {}\n : { params: Params },\n Options extends { defaultValue?: Return } & RequiredParams\n>(selector: WorkerSelector, options: Options): Signal;\n\nfunction useWorkerSelector<\n Fn extends SelectorFunction[0], ReturnType>,\n Params extends FunctionParameters,\n Return extends ReturnType,\n RequiredParams extends [Params[0]] extends [undefined]\n ? {}\n : { params: Params },\n Options extends { defaultValue?: Return } & RequiredParams\n>(selector: WorkerSelector, options?: Options): Signal;\n\nfunction useWorkerSelector<\n Fn extends SelectorFunction[0], ReturnType>,\n Return extends ReturnType,\n Params extends FunctionParameters,\n RequiredParams extends [Params[0]] extends [undefined]\n ? {}\n : { params: Params },\n Options extends { defaultValue?: Return } & RequiredParams\n>(selector: WorkerSelector, options?: Options): Signal {\n const defaultValue = options?.defaultValue;\n const params = options && \"params\" in options ? options.params : [];\n const currentUuid = useSignal(\"\");\n const state = useSignal(defaultValue);\n\n useSignalEffect(() => {\n const data = workerEvent.value;\n if (data && data.uuid === currentUuid.peek()) {\n state.value = data.value as Return;\n }\n });\n\n useDeepCompareEffect(() => {\n const uuid = crypto.randomUUID();\n currentUuid.value = uuid;\n\n worker?.postMessage({\n type: \"subscribe\",\n uuid,\n selector: { selector: selector.name, params },\n });\n\n return () => {\n worker?.postMessage({ type: \"unsubscribe\", uuid });\n };\n }, [selector, params]);\n\n return state;\n}\n\nexport {\n workerEvent,\n useWorkerSelector,\n initializeWorkerStoreListener,\n dispatch,\n};\n","import { ToolkitStore } from \"@reduxjs/toolkit/dist/configureStore\";\nimport {\n SelectorReference,\n MessageType,\n SelectorFunction,\n WorkerSelector,\n} from \"./types\";\n\nconst listeners = new Map();\n\nfunction initializeWorkerStore(\n store: ToolkitStore,\n selectors: Record>>\n) {\n addEventListener(\"message\", ({ data }: MessageEvent) => {\n switch (data.type) {\n case \"dispatch\":\n store.dispatch(data.action);\n break;\n case \"subscribe\":\n listeners.set(data.uuid, data.selector);\n runSelector(data.selector, data.uuid);\n break;\n case \"unsubscribe\":\n listeners.delete(data.uuid);\n break;\n }\n });\n\n store.subscribe(() => {\n listeners.forEach(runSelector);\n });\n\n function runSelector(value: SelectorReference, key: string) {\n const selector: SelectorFunction | undefined =\n selectors?.[value.selector]?.fn;\n const params = value.params;\n\n if (selector) {\n const returnValue = selector(store.getState(), ...params);\n\n postMessage({\n uuid: key,\n value: returnValue,\n });\n }\n }\n}\n\nfunction createWorkerSelector[0]>>(\n name: string,\n selector: T\n): WorkerSelector {\n return {\n name,\n fn: selector,\n };\n}\n\nexport { initializeWorkerStore, createWorkerSelector };\n"],"names":["worker","workerEvent","Signal","name","selector","fn","action","_worker","postMessage","type","store","selectors","runSelector","value","key","_selectors$value$sele","params","returnValue","apply","getState","concat","uuid","addEventListener","_ref","data","dispatch","listeners","set","subscribe","forEach","w","options","defaultValue","currentUuid","useSignal","state","useSignalEffect","peek","useDeepCompareEffect","_worker2","crypto","randomUUID","_worker3"],"mappings":"mHAUIA,uDACaC,EAAG,IAAIC,EAAMA,OAAiC,QCH7C,qCAyClB,SACEC,EACAC,GAEA,MAAO,CACLD,KAAAA,EACAE,GAAID,EAER,mBDjCA,SAAkBE,GAAc,IAAAC,EACxB,SAANP,IAAAO,EAAQC,YAAY,CAAEC,KAAM,WAAYH,OAAAA,GAC1C,gCChBA,SACEI,EACAC,GAqBA,SAAoBC,EAACC,EAA0BC,GAC7C,IAAAC,UACEJ,GAAA,SAAAA,EAAYE,EAAMT,kBAAlBW,EAA6BV,KAChBQ,EAAMG,OAErB,GAAIZ,EAAU,CACZ,IAAMa,EAAcb,EAAQc,WAAA,EAAA,CAACR,EAAMS,YAAUC,OAAKJ,IAElDR,YAAY,CACVa,KAAMP,EACND,MAAOI,GAEV,CACH,CAhCAK,iBAAiB,UAAW,SAAAC,OAAOC,EAAAD,EAAJC,KAC7B,OAAQA,EAAKf,MACX,IAAK,WACHC,EAAMe,SAASD,EAAKlB,QACpB,MACF,IAAK,YACHoB,EAAUC,IAAIH,EAAKH,KAAMG,EAAKpB,UAC9BQ,EAAYY,EAAKpB,SAAUoB,EAAKH,MAChC,MACF,IAAK,cACHK,EAAS,OAAQF,EAAKH,MAG5B,GAEAX,EAAMkB,UAAU,WACdF,EAAUG,QAAQjB,EACpB,EAgBF,wCDlCA,SAAuCkB,GACrC9B,EAAS8B,EAETA,EAAER,iBACA,UACA,SAAoDC,GAClDtB,EAAYY,MADPU,EAAJC,IAEH,EAEJ,4BA0BA,SAQEpB,EAA8B2B,GAC9B,IAAMC,EAAeD,MAAAA,OAAAA,EAAAA,EAASC,aAClBhB,EAAGe,GAAW,WAAmBA,EAAGA,EAAQf,OAAS,GAC3DiB,EAAcC,EAAAA,UAAU,IACxBC,EAAQD,EAAAA,UAAUF,GAwBxB,OAtBAI,EAAAA,gBAAgB,WACd,IAAUZ,EAAGvB,EAAYY,MACrBW,GAAQA,EAAKH,OAASY,EAAYI,SACpCF,EAAMtB,MAAQW,EAAKX,MAEvB,GAEAyB,EAAoB,QAAC,WAAK,IAAAC,EAClBlB,EAAOmB,OAAOC,aASpB,OARAR,EAAYpB,MAAQQ,EAEpB,OAAArB,EAAAA,IAAAuC,EAAQ/B,YAAY,CAClBC,KAAM,YACNY,KAAAA,EACAjB,SAAU,CAAEA,SAAUA,EAASD,KAAMa,OAAAA,KAG3B,WAAA,IAAA0B,EACV,OAAA1C,EAAAA,IAAA0C,EAAQlC,YAAY,CAAEC,KAAM,cAAeY,KAAAA,GAC7C,CACF,EAAG,CAACjB,EAAUY,IAEPmB,CACT"} -------------------------------------------------------------------------------- /out/index.esm.js: -------------------------------------------------------------------------------- 1 | import{Signal as e,useSignal as a,useSignalEffect as t}from"@preact/signals-react";import n from"use-deep-compare-effect";var u,s=new e(null);function r(e){u=e,e.addEventListener("message",function(e){s.value=e.data})}function i(e){var a;null==(a=u)||a.postMessage({type:"dispatch",action:e})}function c(e,r){var i=null==r?void 0:r.defaultValue,c=r&&"params"in r?r.params:[],o=a(""),l=a(i);return t(function(){var e=s.value;e&&e.uuid===o.peek()&&(l.value=e.value)}),n(function(){var a,t=crypto.randomUUID();return o.value=t,null==(a=u)||a.postMessage({type:"subscribe",uuid:t,selector:{selector:e.name,params:c}}),function(){var e;null==(e=u)||e.postMessage({type:"unsubscribe",uuid:t})}},[e,c]),l}var o=new Map;function l(e,a){function t(t,n){var u,s=null==a||null==(u=a[t.selector])?void 0:u.fn,r=t.params;if(s){var i=s.apply(void 0,[e.getState()].concat(r));postMessage({uuid:n,value:i})}}addEventListener("message",function(a){var n=a.data;switch(n.type){case"dispatch":e.dispatch(n.action);break;case"subscribe":o.set(n.uuid,n.selector),t(n.selector,n.uuid);break;case"unsubscribe":o.delete(n.uuid)}}),e.subscribe(function(){o.forEach(t)})}function p(e,a){return{name:e,fn:a}}export{p as createWorkerSelector,i as dispatch,l as initializeWorkerStore,r as initializeWorkerStoreListener,c as useWorkerSelector}; 2 | //# sourceMappingURL=index.esm.js.map 3 | -------------------------------------------------------------------------------- /out/index.esm.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.esm.js","sources":["../src/main-thread-functions.ts","../src/worker-functions.ts"],"sourcesContent":["import { Signal, useSignal, useSignalEffect } from \"@preact/signals-react\";\nimport { Action } from \"redux\";\nimport useDeepCompareEffect from \"use-deep-compare-effect\";\nimport {\n FunctionParameters,\n SelectorFunction,\n SelectorReturn,\n WorkerSelector,\n} from \"./types\";\n\nlet worker: Worker | undefined;\nconst workerEvent = new Signal | null>(null);\n\nfunction initializeWorkerStoreListener(w: Worker) {\n worker = w;\n\n w.addEventListener(\n \"message\",\n ({ data }: MessageEvent>) => {\n workerEvent.value = data;\n }\n );\n}\n\nfunction dispatch(action: Action) {\n worker?.postMessage({ type: \"dispatch\", action });\n}\n\nfunction useWorkerSelector<\n Fn extends SelectorFunction[0], ReturnType>,\n Params extends FunctionParameters,\n Return extends ReturnType,\n RequiredParams extends [Params[0]] extends [undefined]\n ? {}\n : { params: Params },\n Options extends { defaultValue?: Return } & RequiredParams\n>(selector: WorkerSelector, options: Options): Signal;\n\nfunction useWorkerSelector<\n Fn extends SelectorFunction[0], ReturnType>,\n Params extends FunctionParameters,\n Return extends ReturnType,\n RequiredParams extends [Params[0]] extends [undefined]\n ? {}\n : { params: Params },\n Options extends { defaultValue?: Return } & RequiredParams\n>(selector: WorkerSelector, options?: Options): Signal;\n\nfunction useWorkerSelector<\n Fn extends SelectorFunction[0], ReturnType>,\n Return extends ReturnType,\n Params extends FunctionParameters,\n RequiredParams extends [Params[0]] extends [undefined]\n ? {}\n : { params: Params },\n Options extends { defaultValue?: Return } & RequiredParams\n>(selector: WorkerSelector, options?: Options): Signal {\n const defaultValue = options?.defaultValue;\n const params = options && \"params\" in options ? options.params : [];\n const currentUuid = useSignal(\"\");\n const state = useSignal(defaultValue);\n\n useSignalEffect(() => {\n const data = workerEvent.value;\n if (data && data.uuid === currentUuid.peek()) {\n state.value = data.value as Return;\n }\n });\n\n useDeepCompareEffect(() => {\n const uuid = crypto.randomUUID();\n currentUuid.value = uuid;\n\n worker?.postMessage({\n type: \"subscribe\",\n uuid,\n selector: { selector: selector.name, params },\n });\n\n return () => {\n worker?.postMessage({ type: \"unsubscribe\", uuid });\n };\n }, [selector, params]);\n\n return state;\n}\n\nexport {\n workerEvent,\n useWorkerSelector,\n initializeWorkerStoreListener,\n dispatch,\n};\n","import { ToolkitStore } from \"@reduxjs/toolkit/dist/configureStore\";\nimport {\n SelectorReference,\n MessageType,\n SelectorFunction,\n WorkerSelector,\n} from \"./types\";\n\nconst listeners = new Map();\n\nfunction initializeWorkerStore(\n store: ToolkitStore,\n selectors: Record>>\n) {\n addEventListener(\"message\", ({ data }: MessageEvent) => {\n switch (data.type) {\n case \"dispatch\":\n store.dispatch(data.action);\n break;\n case \"subscribe\":\n listeners.set(data.uuid, data.selector);\n runSelector(data.selector, data.uuid);\n break;\n case \"unsubscribe\":\n listeners.delete(data.uuid);\n break;\n }\n });\n\n store.subscribe(() => {\n listeners.forEach(runSelector);\n });\n\n function runSelector(value: SelectorReference, key: string) {\n const selector: SelectorFunction | undefined =\n selectors?.[value.selector]?.fn;\n const params = value.params;\n\n if (selector) {\n const returnValue = selector(store.getState(), ...params);\n\n postMessage({\n uuid: key,\n value: returnValue,\n });\n }\n }\n}\n\nfunction createWorkerSelector[0]>>(\n name: string,\n selector: T\n): WorkerSelector {\n return {\n name,\n fn: selector,\n };\n}\n\nexport { initializeWorkerStore, createWorkerSelector };\n"],"names":["worker","workerEvent","Signal","initializeWorkerStoreListener","w","addEventListener","_ref","value","data","dispatch","action","_worker","postMessage","type","useWorkerSelector","selector","options","defaultValue","params","currentUuid","useSignal","state","useSignalEffect","uuid","peek","useDeepCompareEffect","_worker2","crypto","randomUUID","name","_worker3","store","selectors","runSelector","key","_selectors$value$sele","fn","returnValue","apply","getState","concat","listeners","set","subscribe","forEach","createWorkerSelector"],"mappings":"0HAUA,IAAIA,EACaC,EAAG,IAAIC,EAAuC,MAE/D,SAASC,EAA8BC,GACrCJ,EAASI,EAETA,EAAEC,iBACA,UACA,SAAoDC,GAClDL,EAAYM,MADPD,EAAJE,IAEH,EAEJ,CAEA,SAASC,EAASC,GAAc,IAAAC,EACxB,SAANX,IAAAW,EAAQC,YAAY,CAAEC,KAAM,WAAYH,OAAAA,GAC1C,CAsBA,SAASI,EAQPC,EAA8BC,GAC9B,IAAMC,EAAeD,MAAAA,OAAAA,EAAAA,EAASC,aAClBC,EAAGF,GAAW,WAAmBA,EAAGA,EAAQE,OAAS,GAC3DC,EAAcC,EAAU,IACxBC,EAAQD,EAAUH,GAwBxB,OAtBAK,EAAgB,WACd,IAAUd,EAAGP,EAAYM,MACrBC,GAAQA,EAAKe,OAASJ,EAAYK,SACpCH,EAAMd,MAAQC,EAAKD,MAEvB,GAEAkB,EAAqB,WAAK,IAAAC,EAClBH,EAAOI,OAAOC,aASpB,OARAT,EAAYZ,MAAQgB,EAEpB,OAAAvB,EAAAA,IAAA0B,EAAQd,YAAY,CAClBC,KAAM,YACNU,KAAAA,EACAR,SAAU,CAAEA,SAAUA,EAASc,KAAMX,OAAAA,KAG3B,WAAA,IAAAY,EACV,OAAA9B,EAAAA,IAAA8B,EAAQlB,YAAY,CAAEC,KAAM,cAAeU,KAAAA,GAC7C,CACF,EAAG,CAACR,EAAUG,IAEPG,CACT,CC7EA,MAAkB,QAElB,WACEU,EACAC,GAqBA,SAAoBC,EAAC1B,EAA0B2B,GAC7C,IAAAC,UACEH,GAAA,SAAAA,EAAYzB,EAAMQ,kBAAlBoB,EAA6BC,KAChB7B,EAAMW,OAErB,GAAIH,EAAU,CACZ,IAAMsB,EAActB,EAAQuB,WAAA,EAAA,CAACP,EAAMQ,YAAUC,OAAKtB,IAElDN,YAAY,CACVW,KAAMW,EACN3B,MAAO8B,GAEV,CACH,CAhCAhC,iBAAiB,UAAW,SAAAC,OAAOE,EAAAF,EAAJE,KAC7B,OAAQA,EAAKK,MACX,IAAK,WACHkB,EAAMtB,SAASD,EAAKE,QACpB,MACF,IAAK,YACH+B,EAAUC,IAAIlC,EAAKe,KAAMf,EAAKO,UAC9BkB,EAAYzB,EAAKO,SAAUP,EAAKe,MAChC,MACF,IAAK,cACHkB,EAAS,OAAQjC,EAAKe,MAG5B,GAEAQ,EAAMY,UAAU,WACdF,EAAUG,QAAQX,EACpB,EAgBF,CAEA,SAA6BY,EAC3BhB,EACAd,GAEA,MAAO,CACLc,KAAAA,EACAO,GAAIrB,EAER"} -------------------------------------------------------------------------------- /out/index.modern.js: -------------------------------------------------------------------------------- 1 | import{Signal as e,useSignal as s,useSignalEffect as t}from"@preact/signals-react";import a from"use-deep-compare-effect";let n;const u=new e(null);function r(e){n=e,e.addEventListener("message",({data:e})=>{u.value=e})}function c(e){var s;null==(s=n)||s.postMessage({type:"dispatch",action:e})}function o(e,r){const c=null==r?void 0:r.defaultValue,o=r&&"params"in r?r.params:[],i=s(""),l=s(c);return t(()=>{const e=u.value;e&&e.uuid===i.peek()&&(l.value=e.value)}),a(()=>{var s;const t=crypto.randomUUID();return i.value=t,null==(s=n)||s.postMessage({type:"subscribe",uuid:t,selector:{selector:e.name,params:o}}),()=>{var e;null==(e=n)||e.postMessage({type:"unsubscribe",uuid:t})}},[e,o]),l}const i=new Map;function l(e,s){function t(t,a){var n;const u=null==s||null==(n=s[t.selector])?void 0:n.fn,r=t.params;if(u){const s=u(e.getState(),...r);postMessage({uuid:a,value:s})}}addEventListener("message",({data:s})=>{switch(s.type){case"dispatch":e.dispatch(s.action);break;case"subscribe":i.set(s.uuid,s.selector),t(s.selector,s.uuid);break;case"unsubscribe":i.delete(s.uuid)}}),e.subscribe(()=>{i.forEach(t)})}function p(e,s){return{name:e,fn:s}}export{p as createWorkerSelector,c as dispatch,l as initializeWorkerStore,r as initializeWorkerStoreListener,o as useWorkerSelector}; 2 | //# sourceMappingURL=index.modern.js.map 3 | -------------------------------------------------------------------------------- /out/index.modern.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.modern.js","sources":["../src/main-thread-functions.ts","../src/worker-functions.ts"],"sourcesContent":["import { Signal, useSignal, useSignalEffect } from \"@preact/signals-react\";\nimport { Action } from \"redux\";\nimport useDeepCompareEffect from \"use-deep-compare-effect\";\nimport {\n FunctionParameters,\n SelectorFunction,\n SelectorReturn,\n WorkerSelector,\n} from \"./types\";\n\nlet worker: Worker | undefined;\nconst workerEvent = new Signal | null>(null);\n\nfunction initializeWorkerStoreListener(w: Worker) {\n worker = w;\n\n w.addEventListener(\n \"message\",\n ({ data }: MessageEvent>) => {\n workerEvent.value = data;\n }\n );\n}\n\nfunction dispatch(action: Action) {\n worker?.postMessage({ type: \"dispatch\", action });\n}\n\nfunction useWorkerSelector<\n Fn extends SelectorFunction[0], ReturnType>,\n Params extends FunctionParameters,\n Return extends ReturnType,\n RequiredParams extends [Params[0]] extends [undefined]\n ? {}\n : { params: Params },\n Options extends { defaultValue?: Return } & RequiredParams\n>(selector: WorkerSelector, options: Options): Signal;\n\nfunction useWorkerSelector<\n Fn extends SelectorFunction[0], ReturnType>,\n Params extends FunctionParameters,\n Return extends ReturnType,\n RequiredParams extends [Params[0]] extends [undefined]\n ? {}\n : { params: Params },\n Options extends { defaultValue?: Return } & RequiredParams\n>(selector: WorkerSelector, options?: Options): Signal;\n\nfunction useWorkerSelector<\n Fn extends SelectorFunction[0], ReturnType>,\n Return extends ReturnType,\n Params extends FunctionParameters,\n RequiredParams extends [Params[0]] extends [undefined]\n ? {}\n : { params: Params },\n Options extends { defaultValue?: Return } & RequiredParams\n>(selector: WorkerSelector, options?: Options): Signal {\n const defaultValue = options?.defaultValue;\n const params = options && \"params\" in options ? options.params : [];\n const currentUuid = useSignal(\"\");\n const state = useSignal(defaultValue);\n\n useSignalEffect(() => {\n const data = workerEvent.value;\n if (data && data.uuid === currentUuid.peek()) {\n state.value = data.value as Return;\n }\n });\n\n useDeepCompareEffect(() => {\n const uuid = crypto.randomUUID();\n currentUuid.value = uuid;\n\n worker?.postMessage({\n type: \"subscribe\",\n uuid,\n selector: { selector: selector.name, params },\n });\n\n return () => {\n worker?.postMessage({ type: \"unsubscribe\", uuid });\n };\n }, [selector, params]);\n\n return state;\n}\n\nexport {\n workerEvent,\n useWorkerSelector,\n initializeWorkerStoreListener,\n dispatch,\n};\n","import { ToolkitStore } from \"@reduxjs/toolkit/dist/configureStore\";\nimport {\n SelectorReference,\n MessageType,\n SelectorFunction,\n WorkerSelector,\n} from \"./types\";\n\nconst listeners = new Map();\n\nfunction initializeWorkerStore(\n store: ToolkitStore,\n selectors: Record>>\n) {\n addEventListener(\"message\", ({ data }: MessageEvent) => {\n switch (data.type) {\n case \"dispatch\":\n store.dispatch(data.action);\n break;\n case \"subscribe\":\n listeners.set(data.uuid, data.selector);\n runSelector(data.selector, data.uuid);\n break;\n case \"unsubscribe\":\n listeners.delete(data.uuid);\n break;\n }\n });\n\n store.subscribe(() => {\n listeners.forEach(runSelector);\n });\n\n function runSelector(value: SelectorReference, key: string) {\n const selector: SelectorFunction | undefined =\n selectors?.[value.selector]?.fn;\n const params = value.params;\n\n if (selector) {\n const returnValue = selector(store.getState(), ...params);\n\n postMessage({\n uuid: key,\n value: returnValue,\n });\n }\n }\n}\n\nfunction createWorkerSelector[0]>>(\n name: string,\n selector: T\n): WorkerSelector {\n return {\n name,\n fn: selector,\n };\n}\n\nexport { initializeWorkerStore, createWorkerSelector };\n"],"names":["worker","workerEvent","Signal","initializeWorkerStoreListener","w","addEventListener","data","value","dispatch","action","_worker","postMessage","type","useWorkerSelector","selector","options","defaultValue","params","currentUuid","useSignal","state","useSignalEffect","uuid","peek","useDeepCompareEffect","_worker2","crypto","randomUUID","name","_worker3","store","selectors","runSelector","key","_selectors$value$sele","fn","getState","returnValue","listeners","set","delete","subscribe","forEach"],"mappings":"0HAUA,IAA8BA,EAC9B,MAAMC,EAAc,IAAUC,EAAiC,MAE/D,SAAsCC,EAACC,GACrCJ,EAASI,EAETA,EAAEC,iBACA,UACA,EAAGC,WACDL,EAAYM,MAAQD,CAAAA,EAG1B,CAEA,SAASE,EAASC,GAChB,IAAAC,EAAM,OAANA,EAAAV,IAAAU,EAAQC,YAAY,CAAEC,KAAM,WAAYH,UAC1C,CAsBA,SAA0BI,EAQxBC,EAA8BC,GAC9B,MAAkBC,EAAU,MAAPD,OAAO,EAAPA,EAASC,aAClBC,EAAGF,GAAW,WAAmBA,EAAGA,EAAQE,OAAS,GAC3DC,EAAcC,EAAU,IACxBC,EAAQD,EAAUH,GAwBxB,OAtBAK,EAAgB,KACd,MAAUf,EAAGL,EAAYM,MACrBD,GAAQA,EAAKgB,OAASJ,EAAYK,SACpCH,EAAMb,MAAQD,EAAKC,MACpB,GAGHiB,EAAqB,KAAK,IAAAC,EACxB,MAAMH,EAAOI,OAAOC,aASpB,OARAT,EAAYX,MAAQe,EAEpB,OAAAtB,EAAAA,IAAAyB,EAAQd,YAAY,CAClBC,KAAM,YACNU,OACAR,SAAU,CAAEA,SAAUA,EAASc,KAAMX,YAGhC,KACL,IAAAY,EAAM,OAANA,EAAA7B,IAAA6B,EAAQlB,YAAY,CAAEC,KAAM,cAAeU,QAAM,CACnD,EACC,CAACR,EAAUG,IAEPG,CACT,CC7EA,QAAkB,QAElB,WACEU,EACAC,GAqBA,SAASC,EAAYzB,EAA0B0B,GAAW,IAAAC,EACxD,MAAcpB,EACZiB,MAAAA,GAA2B,OAA3BA,EAAAA,EAAYxB,EAAMO,gBAAlBiB,EAAAG,EAA6BC,GACnBlB,EAAGV,EAAMU,OAErB,GAAIH,EAAU,CACZ,QAAoBA,EAASgB,EAAMM,cAAenB,GAElDN,YAAY,CACVW,KAAMW,EACN1B,MAAO8B,GAEV,CACH,CAhCAhC,iBAAiB,UAAW,EAAGC,WAC7B,OAAQA,EAAKM,MACX,IAAK,WACHkB,EAAMtB,SAASF,EAAKG,QACpB,MACF,IAAK,YACH6B,EAAUC,IAAIjC,EAAKgB,KAAMhB,EAAKQ,UAC9BkB,EAAY1B,EAAKQ,SAAUR,EAAKgB,MAChC,MACF,IAAK,cACHgB,EAAUE,OAAOlC,EAAKgB,MAChB,GAIZQ,EAAMW,UAAU,KACdH,EAAUI,QAAQV,EAAW,EAiBjC,CAEA,WACEJ,EACAd,GAEA,MAAO,CACLc,OACAO,GAAIrB,EAER"} -------------------------------------------------------------------------------- /out/index.umd.js: -------------------------------------------------------------------------------- 1 | !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@preact/signals-react"),require("use-deep-compare-effect")):"function"==typeof define&&define.amd?define(["exports","@preact/signals-react","use-deep-compare-effect"],t):t((e||self).reactReduxOmt={},e.signalsReact,e.useDeepCompareEffect)}(this,function(e,t,a){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u,i=/*#__PURE__*/n(a),r=new t.Signal(null),s=new Map;e.createWorkerSelector=function(e,t){return{name:e,fn:t}},e.dispatch=function(e){var t;null==(t=u)||t.postMessage({type:"dispatch",action:e})},e.initializeWorkerStore=function(e,t){function a(a,n){var u,i=null==t||null==(u=t[a.selector])?void 0:u.fn,r=a.params;if(i){var s=i.apply(void 0,[e.getState()].concat(r));postMessage({uuid:n,value:s})}}addEventListener("message",function(t){var n=t.data;switch(n.type){case"dispatch":e.dispatch(n.action);break;case"subscribe":s.set(n.uuid,n.selector),a(n.selector,n.uuid);break;case"unsubscribe":s.delete(n.uuid)}}),e.subscribe(function(){s.forEach(a)})},e.initializeWorkerStoreListener=function(e){u=e,e.addEventListener("message",function(e){r.value=e.data})},e.useWorkerSelector=function(e,a){var n=null==a?void 0:a.defaultValue,s=a&&"params"in a?a.params:[],o=t.useSignal(""),c=t.useSignal(n);return t.useSignalEffect(function(){var e=r.value;e&&e.uuid===o.peek()&&(c.value=e.value)}),i.default(function(){var t,a=crypto.randomUUID();return o.value=a,null==(t=u)||t.postMessage({type:"subscribe",uuid:a,selector:{selector:e.name,params:s}}),function(){var e;null==(e=u)||e.postMessage({type:"unsubscribe",uuid:a})}},[e,s]),c}}); 2 | //# sourceMappingURL=index.umd.js.map 3 | -------------------------------------------------------------------------------- /out/index.umd.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.umd.js","sources":["../src/main-thread-functions.ts","../src/worker-functions.ts"],"sourcesContent":["import { Signal, useSignal, useSignalEffect } from \"@preact/signals-react\";\nimport { Action } from \"redux\";\nimport useDeepCompareEffect from \"use-deep-compare-effect\";\nimport {\n FunctionParameters,\n SelectorFunction,\n SelectorReturn,\n WorkerSelector,\n} from \"./types\";\n\nlet worker: Worker | undefined;\nconst workerEvent = new Signal | null>(null);\n\nfunction initializeWorkerStoreListener(w: Worker) {\n worker = w;\n\n w.addEventListener(\n \"message\",\n ({ data }: MessageEvent>) => {\n workerEvent.value = data;\n }\n );\n}\n\nfunction dispatch(action: Action) {\n worker?.postMessage({ type: \"dispatch\", action });\n}\n\nfunction useWorkerSelector<\n Fn extends SelectorFunction[0], ReturnType>,\n Params extends FunctionParameters,\n Return extends ReturnType,\n RequiredParams extends [Params[0]] extends [undefined]\n ? {}\n : { params: Params },\n Options extends { defaultValue?: Return } & RequiredParams\n>(selector: WorkerSelector, options: Options): Signal;\n\nfunction useWorkerSelector<\n Fn extends SelectorFunction[0], ReturnType>,\n Params extends FunctionParameters,\n Return extends ReturnType,\n RequiredParams extends [Params[0]] extends [undefined]\n ? {}\n : { params: Params },\n Options extends { defaultValue?: Return } & RequiredParams\n>(selector: WorkerSelector, options?: Options): Signal;\n\nfunction useWorkerSelector<\n Fn extends SelectorFunction[0], ReturnType>,\n Return extends ReturnType,\n Params extends FunctionParameters,\n RequiredParams extends [Params[0]] extends [undefined]\n ? {}\n : { params: Params },\n Options extends { defaultValue?: Return } & RequiredParams\n>(selector: WorkerSelector, options?: Options): Signal {\n const defaultValue = options?.defaultValue;\n const params = options && \"params\" in options ? options.params : [];\n const currentUuid = useSignal(\"\");\n const state = useSignal(defaultValue);\n\n useSignalEffect(() => {\n const data = workerEvent.value;\n if (data && data.uuid === currentUuid.peek()) {\n state.value = data.value as Return;\n }\n });\n\n useDeepCompareEffect(() => {\n const uuid = crypto.randomUUID();\n currentUuid.value = uuid;\n\n worker?.postMessage({\n type: \"subscribe\",\n uuid,\n selector: { selector: selector.name, params },\n });\n\n return () => {\n worker?.postMessage({ type: \"unsubscribe\", uuid });\n };\n }, [selector, params]);\n\n return state;\n}\n\nexport {\n workerEvent,\n useWorkerSelector,\n initializeWorkerStoreListener,\n dispatch,\n};\n","import { ToolkitStore } from \"@reduxjs/toolkit/dist/configureStore\";\nimport {\n SelectorReference,\n MessageType,\n SelectorFunction,\n WorkerSelector,\n} from \"./types\";\n\nconst listeners = new Map();\n\nfunction initializeWorkerStore(\n store: ToolkitStore,\n selectors: Record>>\n) {\n addEventListener(\"message\", ({ data }: MessageEvent) => {\n switch (data.type) {\n case \"dispatch\":\n store.dispatch(data.action);\n break;\n case \"subscribe\":\n listeners.set(data.uuid, data.selector);\n runSelector(data.selector, data.uuid);\n break;\n case \"unsubscribe\":\n listeners.delete(data.uuid);\n break;\n }\n });\n\n store.subscribe(() => {\n listeners.forEach(runSelector);\n });\n\n function runSelector(value: SelectorReference, key: string) {\n const selector: SelectorFunction | undefined =\n selectors?.[value.selector]?.fn;\n const params = value.params;\n\n if (selector) {\n const returnValue = selector(store.getState(), ...params);\n\n postMessage({\n uuid: key,\n value: returnValue,\n });\n }\n }\n}\n\nfunction createWorkerSelector[0]>>(\n name: string,\n selector: T\n): WorkerSelector {\n return {\n name,\n fn: selector,\n };\n}\n\nexport { initializeWorkerStore, createWorkerSelector };\n"],"names":["worker","workerEvent","Signal","name","selector","fn","action","_worker","postMessage","type","store","selectors","runSelector","value","key","_selectors$value$sele","params","returnValue","apply","getState","concat","uuid","addEventListener","_ref","data","dispatch","listeners","set","subscribe","forEach","w","options","defaultValue","currentUuid","useSignal","state","useSignalEffect","peek","useDeepCompareEffect","_worker2","crypto","randomUUID","_worker3"],"mappings":"mdAUIA,sBACaC,EAAG,IAAIC,EAAMA,OAAiC,QCH7C,+BAyClB,SACEC,EACAC,GAEA,MAAO,CACLD,KAAAA,EACAE,GAAID,EAER,aDjCA,SAAkBE,GAAc,IAAAC,EACxB,SAANP,IAAAO,EAAQC,YAAY,CAAEC,KAAM,WAAYH,OAAAA,GAC1C,0BChBA,SACEI,EACAC,GAqBA,SAAoBC,EAACC,EAA0BC,GAC7C,IAAAC,UACEJ,GAAA,SAAAA,EAAYE,EAAMT,kBAAlBW,EAA6BV,KAChBQ,EAAMG,OAErB,GAAIZ,EAAU,CACZ,IAAMa,EAAcb,EAAQc,WAAA,EAAA,CAACR,EAAMS,YAAUC,OAAKJ,IAElDR,YAAY,CACVa,KAAMP,EACND,MAAOI,GAEV,CACH,CAhCAK,iBAAiB,UAAW,SAAAC,OAAOC,EAAAD,EAAJC,KAC7B,OAAQA,EAAKf,MACX,IAAK,WACHC,EAAMe,SAASD,EAAKlB,QACpB,MACF,IAAK,YACHoB,EAAUC,IAAIH,EAAKH,KAAMG,EAAKpB,UAC9BQ,EAAYY,EAAKpB,SAAUoB,EAAKH,MAChC,MACF,IAAK,cACHK,EAAS,OAAQF,EAAKH,MAG5B,GAEAX,EAAMkB,UAAU,WACdF,EAAUG,QAAQjB,EACpB,EAgBF,kCDlCA,SAAuCkB,GACrC9B,EAAS8B,EAETA,EAAER,iBACA,UACA,SAAoDC,GAClDtB,EAAYY,MADPU,EAAJC,IAEH,EAEJ,sBA0BA,SAQEpB,EAA8B2B,GAC9B,IAAMC,EAAeD,MAAAA,OAAAA,EAAAA,EAASC,aAClBhB,EAAGe,GAAW,WAAmBA,EAAGA,EAAQf,OAAS,GAC3DiB,EAAcC,EAAAA,UAAU,IACxBC,EAAQD,EAAAA,UAAUF,GAwBxB,OAtBAI,EAAAA,gBAAgB,WACd,IAAUZ,EAAGvB,EAAYY,MACrBW,GAAQA,EAAKH,OAASY,EAAYI,SACpCF,EAAMtB,MAAQW,EAAKX,MAEvB,GAEAyB,EAAoB,QAAC,WAAK,IAAAC,EAClBlB,EAAOmB,OAAOC,aASpB,OARAR,EAAYpB,MAAQQ,EAEpB,OAAArB,EAAAA,IAAAuC,EAAQ/B,YAAY,CAClBC,KAAM,YACNY,KAAAA,EACAjB,SAAU,CAAEA,SAAUA,EAASD,KAAMa,OAAAA,KAG3B,WAAA,IAAA0B,EACV,OAAA1C,EAAAA,IAAA0C,EAAQlC,YAAY,CAAEC,KAAM,cAAeY,KAAAA,GAC7C,CACF,EAAG,CAACjB,EAAUY,IAEPmB,CACT"} -------------------------------------------------------------------------------- /out/src/index.d.ts: -------------------------------------------------------------------------------- 1 | export { dispatch, initializeWorkerStoreListener, useWorkerSelector, } from "./main-thread-functions"; 2 | export { createWorkerSelector, initializeWorkerStore, } from "./worker-functions"; 3 | -------------------------------------------------------------------------------- /out/src/main-thread-functions.d.ts: -------------------------------------------------------------------------------- 1 | import { Signal } from "@preact/signals-react"; 2 | import { Action } from "redux"; 3 | import { FunctionParameters, SelectorFunction, SelectorReturn, WorkerSelector } from "./types"; 4 | declare const workerEvent: Signal | null>; 5 | declare function initializeWorkerStoreListener(w: Worker): void; 6 | declare function dispatch(action: Action): void; 7 | declare function useWorkerSelector[0], ReturnType>, Params extends FunctionParameters, Return extends ReturnType, RequiredParams extends [Params[0]] extends [undefined] ? {} : { 8 | params: Params; 9 | }, Options extends { 10 | defaultValue?: Return; 11 | } & RequiredParams>(selector: WorkerSelector, options: Options): Signal; 12 | declare function useWorkerSelector[0], ReturnType>, Params extends FunctionParameters, Return extends ReturnType, RequiredParams extends [Params[0]] extends [undefined] ? {} : { 13 | params: Params; 14 | }, Options extends { 15 | defaultValue?: Return; 16 | } & RequiredParams>(selector: WorkerSelector, options?: Options): Signal; 17 | export { workerEvent, useWorkerSelector, initializeWorkerStoreListener, dispatch, }; 18 | -------------------------------------------------------------------------------- /out/src/types.d.ts: -------------------------------------------------------------------------------- 1 | import { Action } from "@reduxjs/toolkit"; 2 | export type MessageType = { 3 | type: "dispatch"; 4 | action: Action; 5 | } | { 6 | type: "subscribe"; 7 | selector: SelectorReference; 8 | uuid: string; 9 | } | { 10 | type: "unsubscribe"; 11 | uuid: string; 12 | }; 13 | export type SelectorReference = { 14 | selector: string; 15 | params: ReadonlyArray; 16 | }; 17 | export type SelectorReturn = { 18 | uuid: string; 19 | value: T; 20 | }; 21 | export type SelectorFunction = (state: T, ...params: any[]) => K; 22 | export interface WorkerSelector { 23 | name: string; 24 | fn: T; 25 | } 26 | export type FunctionParameters = [Parameters[1]] | [Parameters[1], Parameters[2]] | [Parameters[1], Parameters[2], Parameters[3]] | [Parameters[1], Parameters[2], Parameters[3], Parameters[4]] | [ 27 | Parameters[1], 28 | Parameters[2], 29 | Parameters[3], 30 | Parameters[4], 31 | Parameters[5] 32 | ]; 33 | -------------------------------------------------------------------------------- /out/src/worker-functions.d.ts: -------------------------------------------------------------------------------- 1 | import { ToolkitStore } from "@reduxjs/toolkit/dist/configureStore"; 2 | import { SelectorFunction, WorkerSelector } from "./types"; 3 | declare function initializeWorkerStore(store: ToolkitStore, selectors: Record>>): void; 4 | declare function createWorkerSelector[0]>>(name: string, selector: T): WorkerSelector; 5 | export { initializeWorkerStore, createWorkerSelector }; 6 | -------------------------------------------------------------------------------- /out/test/helpers.d.ts: -------------------------------------------------------------------------------- 1 | export declare class Worker { 2 | onmessage: (m?: any) => void; 3 | constructor(); 4 | addEventListener(_event: string, func: () => void): void; 5 | postMessage(msg: any): void; 6 | } 7 | -------------------------------------------------------------------------------- /out/test/main-thread-functions.test.d.ts: -------------------------------------------------------------------------------- 1 | import "mocha"; 2 | -------------------------------------------------------------------------------- /out/test/worker-functions.test.d.ts: -------------------------------------------------------------------------------- 1 | import "mocha"; 2 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-redux-omt", 3 | "version": "0.2.0", 4 | "description": "Tools for running actions, selectors, and redux off the main thread.", 5 | "type": "module", 6 | "source": "./src/index.ts", 7 | "main": "./out/index.js", 8 | "types": "./out/index.d.ts", 9 | "scripts": { 10 | "clean": "rm -rf out && rm -rf docs", 11 | "build": "npm run clean && microbundle && npm run demo", 12 | "test": "ts-mocha --exit", 13 | "deploy": "np", 14 | "watch-demo": "rollup -c -w -m", 15 | "demo": "rollup -c -m", 16 | "serve": "statikk --port 8080 --coi docs" 17 | }, 18 | "keywords": [ 19 | "react-redux", 20 | "redux", 21 | "worker", 22 | "web-worker", 23 | "off the main thread", 24 | "state" 25 | ], 26 | "author": "sbesh91", 27 | "license": "Apache-2.0", 28 | "peerDependencies": { 29 | "@preact/signals-react": "1.2.2", 30 | "use-deep-compare-effect": "1.8.1" 31 | }, 32 | "devDependencies": { 33 | "@babel/core": "^7.20.12", 34 | "@babel/helper-builder-react-jsx": "^7.19.0", 35 | "@babel/plugin-transform-react-jsx": "^7.20.13", 36 | "@babel/plugin-transform-react-jsx-source": "^7.19.6", 37 | "@babel/preset-typescript": "^7.18.6", 38 | "@open-wc/rollup-plugin-html": "^1.2.5", 39 | "@preact/signals-react": "^1.2.2", 40 | "@reduxjs/toolkit": "^1.9.2", 41 | "@rollup/plugin-babel": "^6.0.3", 42 | "@rollup/plugin-commonjs": "^24.0.1", 43 | "@rollup/plugin-node-resolve": "^15.0.1", 44 | "@testing-library/react": "^13.4.0", 45 | "@types/mocha": "^10.0.1", 46 | "@types/react-dom": "^18.0.10", 47 | "@surma/rollup-plugin-off-main-thread": "2.2.3", 48 | "immer": "^9.0.19", 49 | "microbundle": "^0.15.1", 50 | "mocha": "^10.2.0", 51 | "np": "^7.6.3", 52 | "re-reselect": "^4.0.1", 53 | "react": "^18.2.0", 54 | "react-dom": "^18.2.0", 55 | "react-redux": "^8.0.5", 56 | "redux": "^4.2.1", 57 | "rollup": "^3.13.0", 58 | "rollup-plugin-replace": "^2.2.0", 59 | "statikk": "^2.2.0", 60 | "ts-mocha": "^10.0.0", 61 | "use-deep-compare-effect": "^1.8.1", 62 | "web-worker": "^1.2.0" 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import commonjs from "@rollup/plugin-commonjs"; 2 | import nodeResolve from "@rollup/plugin-node-resolve"; 3 | import replace from "rollup-plugin-replace"; 4 | import OMT from "@surma/rollup-plugin-off-main-thread"; 5 | import babel from "@rollup/plugin-babel"; 6 | import html from "@open-wc/rollup-plugin-html"; 7 | 8 | const isProduction = process.env.NODE_ENV === "production"; 9 | 10 | const extensions = [".js", ".jsx", ".ts", ".tsx"]; 11 | 12 | export default { 13 | input: "demo/index.html", 14 | output: { 15 | dir: "docs", 16 | format: "amd", 17 | }, 18 | context: "globalThis", 19 | plugins: [ 20 | nodeResolve({ 21 | extensions, 22 | preferBuiltins: false, 23 | browser: true, 24 | }), 25 | commonjs(), 26 | babel({ 27 | babelHelpers: "bundled", 28 | compact: isProduction, 29 | minified: isProduction, 30 | configFile: "./babel.config.json", 31 | extensions, 32 | include: ["./**/*"], 33 | exclude: "node_modules/**", 34 | sourceMaps: "both", 35 | }), 36 | replace({ 37 | "process.env.NODE_ENV": JSON.stringify("production"), 38 | }), 39 | OMT(), 40 | html(), 41 | ], 42 | }; 43 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | dispatch, 3 | initializeWorkerStoreListener, 4 | useWorkerSelector, 5 | } from "./main-thread-functions"; 6 | export { 7 | createWorkerSelector, 8 | initializeWorkerStore, 9 | } from "./worker-functions"; 10 | -------------------------------------------------------------------------------- /src/main-thread-functions.ts: -------------------------------------------------------------------------------- 1 | import { Signal, useSignal, useSignalEffect } from "@preact/signals-react"; 2 | import { Action } from "redux"; 3 | import useDeepCompareEffect from "use-deep-compare-effect"; 4 | import { 5 | FunctionParameters, 6 | SelectorFunction, 7 | SelectorReturn, 8 | WorkerSelector, 9 | } from "./types"; 10 | 11 | let worker: Worker | undefined; 12 | const workerEvent = new Signal | null>(null); 13 | 14 | function initializeWorkerStoreListener(w: Worker) { 15 | worker = w; 16 | 17 | w.addEventListener( 18 | "message", 19 | ({ data }: MessageEvent>) => { 20 | workerEvent.value = data; 21 | } 22 | ); 23 | } 24 | 25 | function dispatch(action: Action) { 26 | worker?.postMessage({ type: "dispatch", action }); 27 | } 28 | 29 | function useWorkerSelector< 30 | Fn extends SelectorFunction[0], ReturnType>, 31 | Params extends FunctionParameters, 32 | Return extends ReturnType, 33 | RequiredParams extends [Params[0]] extends [undefined] 34 | ? {} 35 | : { params: Params }, 36 | Options extends { defaultValue: Return } & RequiredParams, 37 | >(selector: WorkerSelector, options: Options): Signal; 38 | 39 | function useWorkerSelector< 40 | Fn extends SelectorFunction[0], ReturnType>, 41 | Params extends FunctionParameters, 42 | Return extends ReturnType, 43 | RequiredParams extends [Params[0]] extends [undefined] 44 | ? {} 45 | : { params: Params }, 46 | Options extends { defaultValue?: Return } & RequiredParams 47 | >(selector: WorkerSelector, options?: Options): Signal; 48 | 49 | function useWorkerSelector< 50 | Fn extends SelectorFunction[0], ReturnType>, 51 | Return extends ReturnType, 52 | Params extends FunctionParameters, 53 | RequiredParams extends [Params[0]] extends [undefined] 54 | ? {} 55 | : { params: Params }, 56 | Options extends { defaultValue?: Return } & RequiredParams 57 | >(selector: WorkerSelector, options?: Options): Signal { 58 | const defaultValue = options?.defaultValue; 59 | const params = options && "params" in options ? options.params : []; 60 | const currentUuid = useSignal(""); 61 | const state = useSignal(defaultValue); 62 | 63 | useSignalEffect(() => { 64 | const data = workerEvent.value; 65 | if (data && data.uuid === currentUuid.peek()) { 66 | state.value = data.value as Return; 67 | } 68 | }); 69 | 70 | useDeepCompareEffect(() => { 71 | const uuid = crypto.randomUUID(); 72 | currentUuid.value = uuid; 73 | 74 | worker?.postMessage({ 75 | type: "subscribe", 76 | uuid, 77 | selector: { selector: selector.name, params }, 78 | }); 79 | 80 | return () => { 81 | worker?.postMessage({ type: "unsubscribe", uuid }); 82 | }; 83 | }, [selector, params]); 84 | 85 | return state; 86 | } 87 | 88 | export { 89 | workerEvent, 90 | useWorkerSelector, 91 | initializeWorkerStoreListener, 92 | dispatch, 93 | }; 94 | -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | import { Action } from "@reduxjs/toolkit"; 2 | 3 | export type MessageType = 4 | | { 5 | type: "dispatch"; 6 | action: Action; 7 | } 8 | | { type: "subscribe"; selector: SelectorReference; uuid: string } 9 | | { type: "unsubscribe"; uuid: string }; 10 | 11 | export type SelectorReference = { 12 | selector: string; 13 | params: ReadonlyArray; 14 | }; 15 | 16 | export type SelectorReturn = { 17 | uuid: string; 18 | value: T; 19 | }; 20 | 21 | export type SelectorFunction = ( 22 | state: T, 23 | ...params: any[] 24 | ) => K; 25 | 26 | export interface WorkerSelector { 27 | name: string; 28 | fn: T; 29 | } 30 | 31 | export type FunctionParameters = 32 | | [Parameters[1]] 33 | | [Parameters[1], Parameters[2]] 34 | | [Parameters[1], Parameters[2], Parameters[3]] 35 | | [Parameters[1], Parameters[2], Parameters[3], Parameters[4]] 36 | | [ 37 | Parameters[1], 38 | Parameters[2], 39 | Parameters[3], 40 | Parameters[4], 41 | Parameters[5] 42 | ]; 43 | -------------------------------------------------------------------------------- /src/worker-functions.ts: -------------------------------------------------------------------------------- 1 | import { ToolkitStore } from "@reduxjs/toolkit/dist/configureStore"; 2 | import { 3 | SelectorReference, 4 | MessageType, 5 | SelectorFunction, 6 | WorkerSelector, 7 | } from "./types"; 8 | 9 | const listeners = new Map(); 10 | 11 | function initializeWorkerStore( 12 | store: ToolkitStore, 13 | selectors: Record>> 14 | ) { 15 | addEventListener("message", ({ data }: MessageEvent) => { 16 | switch (data.type) { 17 | case "dispatch": 18 | store.dispatch(data.action); 19 | break; 20 | case "subscribe": 21 | listeners.set(data.uuid, data.selector); 22 | runSelector(data.selector, data.uuid); 23 | break; 24 | case "unsubscribe": 25 | listeners.delete(data.uuid); 26 | break; 27 | } 28 | }); 29 | 30 | store.subscribe(() => { 31 | listeners.forEach(runSelector); 32 | }); 33 | 34 | function runSelector(value: SelectorReference, key: string) { 35 | const selector: SelectorFunction | undefined = 36 | selectors?.[value.selector]?.fn; 37 | const params = value.params; 38 | 39 | if (selector) { 40 | const returnValue = selector(store.getState(), ...params); 41 | 42 | postMessage({ 43 | uuid: key, 44 | value: returnValue, 45 | }); 46 | } 47 | } 48 | } 49 | 50 | function createWorkerSelector[0]>>( 51 | name: string, 52 | selector: T 53 | ): WorkerSelector { 54 | return { 55 | name, 56 | fn: selector, 57 | }; 58 | } 59 | 60 | export { initializeWorkerStore, createWorkerSelector }; 61 | -------------------------------------------------------------------------------- /test/helpers.ts: -------------------------------------------------------------------------------- 1 | export class Worker { 2 | onmessage: (m?: any) => void; 3 | constructor() { 4 | this.onmessage = () => {}; 5 | } 6 | 7 | addEventListener(_event: string, func: () => void) { 8 | this.onmessage = func; 9 | } 10 | 11 | postMessage(msg: any) { 12 | this.onmessage(msg); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/main-thread-functions.test.ts: -------------------------------------------------------------------------------- 1 | import { 2 | initializeWorkerStoreListener, 3 | workerEvent, 4 | dispatch, 5 | } from "../src/main-thread-functions"; 6 | import * as assert from "assert"; 7 | import "mocha"; 8 | import crypto from "crypto"; 9 | import { Worker } from "./helpers"; 10 | 11 | describe("initialize worker store listener", () => { 12 | const worker = new Worker() as any; 13 | 14 | beforeEach(() => { 15 | workerEvent.value = null; 16 | }); 17 | 18 | it("should construct a worker", () => { 19 | assert.ok(worker, "worker must be defined"); 20 | }); 21 | 22 | it("should listen to worker for events", () => { 23 | const uuid = crypto.randomUUID(); 24 | initializeWorkerStoreListener(worker); 25 | 26 | worker.postMessage({ 27 | type: "subscribe", 28 | uuid, 29 | selector: { selector: "one", params: [] }, 30 | }); 31 | 32 | assert.ok(workerEvent.value !== null, "events should not be null"); 33 | }); 34 | 35 | it("dispatch should send events to the worker", () => { 36 | dispatch({ type: "test" }); 37 | 38 | assert.ok(workerEvent.value !== null, "events should not be null"); 39 | }); 40 | }); 41 | -------------------------------------------------------------------------------- /test/worker-functions.test.ts: -------------------------------------------------------------------------------- 1 | import { createWorkerSelector } from "../src"; 2 | import * as assert from "assert"; 3 | import "mocha"; 4 | 5 | describe("create worker selector", () => { 6 | it("should return the correct shape", () => { 7 | const { name, fn } = createWorkerSelector( 8 | "one", 9 | (_rootState: unknown) => {} 10 | ); 11 | 12 | assert.strictEqual(name, "one", "Expects name to be unchanged"); 13 | assert.ok(typeof fn === "function", "Expects function type"); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | // project options 4 | "module": "ESNext", 5 | "lib": ["ESNext", "dom"], // specifies which default set of type definitions to use ("DOM", "ES6", etc) 6 | "outDir": "lib", // .js (as well as .d.ts, .js.map, etc.) files will be emitted into this directory., 7 | "removeComments": true, // Strips all comments from TypeScript files when converting into JavaScript- you rarely read compiled code so this saves space 8 | "target": "ESNext", // Target environment. Most modern browsers support ES6, but you may want to set it to newer or older. (defaults to ES3) 9 | 10 | // Module resolution 11 | "baseUrl": "./src", // Lets you set a base directory to resolve non-absolute module names. 12 | "esModuleInterop": true, // fixes some issues TS originally had with the ES6 spec where TypeScript treats CommonJS/AMD/UMD modules similar to ES6 module 13 | "moduleResolution": "node", // Pretty much always node for modern JS. Other option is "classic" 14 | "paths": {}, // A series of entries which re-map imports to lookup locations relative to the baseUrl 15 | 16 | // Source Map 17 | "sourceMap": true, // enables the use of source maps for debuggers and error reporting etc 18 | "sourceRoot": "/src", // Specify the location where a debugger should locate TypeScript files instead of relative source locations. 19 | 20 | // Strict Checks 21 | "strict": true, 22 | "alwaysStrict": true, // Ensures that your files are parsed in the ECMAScript strict mode, and emit “use strict” for each source file. 23 | "allowUnreachableCode": false, // pick up dead code paths 24 | "noImplicitAny": true, // In some cases where no type annotations are present, TypeScript will fall back to a type of any for a variable when it cannot infer the type. 25 | "strictNullChecks": true, // When strictNullChecks is true, null and undefined have their own distinct types and you’ll get a type error if you try to use them where a concrete value is expected. 26 | "strictFunctionTypes": true, 27 | // Linter Checks 28 | "noImplicitReturns": true, 29 | "noUncheckedIndexedAccess": true, // accessing index must always check for undefined 30 | "noUnusedLocals": true, // Report errors on unused local variables. 31 | "noUnusedParameters": true, 32 | // Report errors on unused parameters in functions 33 | "jsx": "react", 34 | "skipLibCheck": true 35 | }, 36 | "include": ["./src/**/*.ts", "./test/**/*.ts"], 37 | "exclude": ["node_modules/**/*"] 38 | } 39 | --------------------------------------------------------------------------------