diff --git a/package.json b/package.json index 1418720..1845720 100644 --- a/package.json +++ b/package.json @@ -6,14 +6,15 @@ "module": "dist/stockroom.es.js", "main": "dist/stockroom.js", "umd:main": "dist/stockroom.umd.js", - "typings": "index.d.ts", + "typings": "src/index.d.ts", "scripts": { - "build": "npm-run-all --silent bundle size docs", + "build": "npm-run-all --silent bundle size docs types", "bundle": "microbundle src/index.js -o dist/stockroom.js && microbundle src/inline.js -o inline/index.js && microbundle src/worker.js -o worker/index.js", "size": "strip-json-comments --no-whitespace dist/stockroom.js | gzip-size && bundlesize", "docs": "documentation readme src/*.js -q --section API && npm run -s fixreadme", "fixreadme": "node -e 'var fs=require(\"fs\");fs.writeFileSync(\"README.md\", fs.readFileSync(\"README.md\", \"utf8\").replace(/^- /gm, \"- \"))'", "test": "eslint src test && npm run bundle && karma start test/karma.conf.js --single-run", + "types": "cp-cli src/worker.d.ts worker/index.d.ts && cp-cli src/inline.d.ts inline/index.d.ts", "prepare": "npm t", "release": "npm t && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish" }, @@ -68,6 +69,7 @@ "babel-preset-stage-0": "^6.24.1", "bundlesize": "^0.15.3", "chai": "^4.1.2", + "cp-cli": "^1.1.2", "documentation": "^4.0.0", "eslint": "^4.16.0", "eslint-config-developit": "^1.1.1", diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..b11e237 --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1,5 @@ +// K - Store state + +import { Store } from "unistore"; + +export default function createStore(worker: Worker): Store; diff --git a/src/inline.d.ts b/src/inline.d.ts new file mode 100644 index 0000000..c7646d7 --- /dev/null +++ b/src/inline.d.ts @@ -0,0 +1,12 @@ +// K - Store state + +import { Store } from "unistore"; + +export interface WorkerStore extends Store { + freeze: () => void; + unfreeze: () => void; +} + +export default function createInlineStore( + workerStore: WorkerStore +): WorkerStore; diff --git a/src/worker.d.ts b/src/worker.d.ts new file mode 100644 index 0000000..73eb2df --- /dev/null +++ b/src/worker.d.ts @@ -0,0 +1,10 @@ +// K - Store state + +import { Store } from "unistore"; + +export interface WorkerStore extends Store { + freeze: () => void; + unfreeze: () => void; +} + +export default function createWorkerStore(initialState?: K): WorkerStore;