From 7975e287c76da5b1d7e90c8870cde165865d64fb Mon Sep 17 00:00:00 2001 From: 2nthony Date: Sun, 10 Oct 2021 16:08:18 +0800 Subject: [PATCH] fix(store): integrate into `shared` (#28) --- indexes.json | 50 ++++++------------- meta/packages.ts | 6 --- packages/.vitepress/config.js | 1 + packages/core/indexes.json | 50 ++++++------------- packages/core/onClickOutside/demo.svelte | 4 +- packages/core/onClickOutside/index.md | 3 +- packages/core/package.json | 3 +- packages/core/useEventListener/index.md | 3 +- packages/core/useMutationObserver/demo.svelte | 2 +- packages/core/useMutationObserver/index.md | 3 +- packages/core/useTitle/index.ts | 2 +- packages/functions.md | 4 ++ packages/guide/index.md | 2 +- packages/shared/index.ts | 2 + packages/shared/package.json | 3 -- packages/{store => shared}/readable/index.md | 4 +- packages/{store => shared}/readable/index.ts | 7 +-- packages/shared/useInterval/index.ts | 2 +- packages/shared/useIntervalFn/demo.svelte | 2 +- packages/shared/useIntervalFn/index.ts | 4 +- packages/shared/useTimeout/index.ts | 2 +- packages/shared/useTimeoutFn/index.ts | 2 +- packages/shared/utils/index.ts | 3 +- packages/{store => shared}/writable/index.md | 4 +- packages/{store => shared}/writable/index.ts | 3 +- packages/store/README.md | 21 -------- packages/store/derived/index.md | 17 ------- packages/store/derived/index.ts | 1 - packages/store/get/index.md | 17 ------- packages/store/get/index.ts | 2 - packages/store/index.ts | 4 -- packages/store/package.json | 34 ------------- packages/vite.config.ts | 1 - pnpm-lock.yaml | 15 +----- 34 files changed, 64 insertions(+), 219 deletions(-) rename packages/{store => shared}/readable/index.md (67%) rename packages/{store => shared}/readable/index.ts (65%) rename packages/{store => shared}/writable/index.md (67%) rename packages/{store => shared}/writable/index.ts (93%) delete mode 100644 packages/store/README.md delete mode 100644 packages/store/derived/index.md delete mode 100644 packages/store/derived/index.ts delete mode 100644 packages/store/get/index.md delete mode 100644 packages/store/get/index.ts delete mode 100644 packages/store/index.ts delete mode 100644 packages/store/package.json diff --git a/indexes.json b/indexes.json index 63e5f89..6f2e24e 100644 --- a/indexes.json +++ b/indexes.json @@ -10,24 +10,25 @@ "display": "SvelteUse", "description": "Collection of essential Svelte Utilities", "dir": "packages/core" - }, - "store": { - "name": "store", - "display": "Store", - "description": "Enhancement for svelte/store", - "dir": "packages/store" } }, "categories": [ - "@Store", "Animation", "Browser", "Component", "Sensors", "State", + "Store", "Utilities" ], "functions": [ + { + "name": "readable", + "package": "shared", + "docs": "/shared/readable/", + "category": "Store", + "description": "auto unsubscribe on destory for `readable`" + }, { "name": "tryOnDestroy", "package": "shared", @@ -82,6 +83,13 @@ "category": "Utilities", "description": "shorthand for watching value to be truthy" }, + { + "name": "writable", + "package": "shared", + "docs": "/shared/writable/", + "category": "Store", + "description": "auto unsubscribe on destory for `writable`" + }, { "name": "onClickOutside", "package": "core", @@ -144,34 +152,6 @@ "docs": "/core/useTitle/", "category": "Browser", "description": "reactive document title" - }, - { - "name": "derived", - "package": "store", - "docs": "/store/derived/", - "category": "@Store", - "description": "origin [derived](https://svelte.dev/docs#derived)" - }, - { - "name": "get", - "package": "store", - "docs": "/store/get/", - "category": "@Store", - "description": "origin [get](https://svelte.dev/docs#get)" - }, - { - "name": "readable", - "package": "store", - "docs": "/store/readable/", - "category": "@Store", - "description": "auto unsubscribe on destory for `readable`" - }, - { - "name": "writable", - "package": "store", - "docs": "/store/writable/", - "category": "@Store", - "description": "auto unsubscribe on destory for `writable`" } ] } diff --git a/meta/packages.ts b/meta/packages.ts index ce92b02..778a527 100644 --- a/meta/packages.ts +++ b/meta/packages.ts @@ -10,10 +10,4 @@ export const packages: PackageManifest[] = [ display: 'SvelteUse', description: 'Collection of essential Svelte Utilities', }, - { - name: 'store', - display: 'Store', - description: 'Enhancement for svelte/store', - } ] - diff --git a/packages/.vitepress/config.js b/packages/.vitepress/config.js index d540931..6f4625f 100644 --- a/packages/.vitepress/config.js +++ b/packages/.vitepress/config.js @@ -8,6 +8,7 @@ const categoriesOrder = [ 'Sensors', 'Animation', 'State', + 'Store', 'Component', 'Watch', 'Formatters', diff --git a/packages/core/indexes.json b/packages/core/indexes.json index 63e5f89..6f2e24e 100644 --- a/packages/core/indexes.json +++ b/packages/core/indexes.json @@ -10,24 +10,25 @@ "display": "SvelteUse", "description": "Collection of essential Svelte Utilities", "dir": "packages/core" - }, - "store": { - "name": "store", - "display": "Store", - "description": "Enhancement for svelte/store", - "dir": "packages/store" } }, "categories": [ - "@Store", "Animation", "Browser", "Component", "Sensors", "State", + "Store", "Utilities" ], "functions": [ + { + "name": "readable", + "package": "shared", + "docs": "/shared/readable/", + "category": "Store", + "description": "auto unsubscribe on destory for `readable`" + }, { "name": "tryOnDestroy", "package": "shared", @@ -82,6 +83,13 @@ "category": "Utilities", "description": "shorthand for watching value to be truthy" }, + { + "name": "writable", + "package": "shared", + "docs": "/shared/writable/", + "category": "Store", + "description": "auto unsubscribe on destory for `writable`" + }, { "name": "onClickOutside", "package": "core", @@ -144,34 +152,6 @@ "docs": "/core/useTitle/", "category": "Browser", "description": "reactive document title" - }, - { - "name": "derived", - "package": "store", - "docs": "/store/derived/", - "category": "@Store", - "description": "origin [derived](https://svelte.dev/docs#derived)" - }, - { - "name": "get", - "package": "store", - "docs": "/store/get/", - "category": "@Store", - "description": "origin [get](https://svelte.dev/docs#get)" - }, - { - "name": "readable", - "package": "store", - "docs": "/store/readable/", - "category": "@Store", - "description": "auto unsubscribe on destory for `readable`" - }, - { - "name": "writable", - "package": "store", - "docs": "/store/writable/", - "category": "@Store", - "description": "auto unsubscribe on destory for `writable`" } ] } diff --git a/packages/core/onClickOutside/demo.svelte b/packages/core/onClickOutside/demo.svelte index 0c364ad..2dfb915 100644 --- a/packages/core/onClickOutside/demo.svelte +++ b/packages/core/onClickOutside/demo.svelte @@ -1,6 +1,6 @@ diff --git a/packages/store/readable/index.ts b/packages/shared/readable/index.ts similarity index 65% rename from packages/store/readable/index.ts rename to packages/shared/readable/index.ts index d9fe3ff..322f513 100644 --- a/packages/store/readable/index.ts +++ b/packages/shared/readable/index.ts @@ -1,8 +1,5 @@ -import { noop } from '@svelte-use/shared' -import { - Readable, - StartStopNotifier, -} from 'svelte/store' +import { noop } from '../utils' +import { Readable, StartStopNotifier } from 'svelte/store' import { writable } from '../writable' export function readable( diff --git a/packages/shared/useInterval/index.ts b/packages/shared/useInterval/index.ts index fc89945..38b51b2 100644 --- a/packages/shared/useInterval/index.ts +++ b/packages/shared/useInterval/index.ts @@ -1,4 +1,4 @@ -import { writable } from '@svelte-use/store' +import { writable } from '../writable' import { Writable } from 'svelte/store' import { useIntervalFn } from '../useIntervalFn' import { Pausable } from '../utils' diff --git a/packages/shared/useIntervalFn/demo.svelte b/packages/shared/useIntervalFn/demo.svelte index bbd0104..028b46d 100644 --- a/packages/shared/useIntervalFn/demo.svelte +++ b/packages/shared/useIntervalFn/demo.svelte @@ -1,5 +1,5 @@ diff --git a/packages/store/writable/index.ts b/packages/shared/writable/index.ts similarity index 93% rename from packages/store/writable/index.ts rename to packages/shared/writable/index.ts index 0a8b023..99f0015 100644 --- a/packages/store/writable/index.ts +++ b/packages/shared/writable/index.ts @@ -1,4 +1,5 @@ -import { Fn, noop, runAll, tryOnDestroy } from '@svelte-use/shared' +import { Fn, noop, runAll } from '../utils' +import { tryOnDestroy } from '../tryOnDestroy' import { writable as _writable, get, diff --git a/packages/store/README.md b/packages/store/README.md deleted file mode 100644 index bf71585..0000000 --- a/packages/store/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# @svelte-use/store - -This is an enhanced of [svelte/store](https://svelte.dev/docs#svelte_store). - -## Install - -```bash -npm i @svelte-use/store -``` - -## Functions - - - - - [`derived`](/store/derived/) — origin [derived](https://svelte.dev/docs#derived) - - [`get`](/store/get/) — origin [get](https://svelte.dev/docs#get) - - [`readable`](/store/readable/) — auto unsubscribe on destory for `readable` - - [`writable`](/store/writable/) — auto unsubscribe on destory for `writable` - - - diff --git a/packages/store/derived/index.md b/packages/store/derived/index.md deleted file mode 100644 index 796b195..0000000 --- a/packages/store/derived/index.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -category: '@Store' ---- - -# derived - -Origin [derived](https://svelte.dev/docs#derived). - -## Usage - -Please refer to [`derived`](https://svelte.dev/docs#derived). - -```html - -``` diff --git a/packages/store/derived/index.ts b/packages/store/derived/index.ts deleted file mode 100644 index 6511649..0000000 --- a/packages/store/derived/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { derived } from 'svelte/store' diff --git a/packages/store/get/index.md b/packages/store/get/index.md deleted file mode 100644 index 245827d..0000000 --- a/packages/store/get/index.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -category: '@Store' ---- - -# get - -Origin [get](https://svelte.dev/docs#get). - -## Usage - -Please refer to [`get`](https://svelte.dev/docs#get) - -```html - -``` diff --git a/packages/store/get/index.ts b/packages/store/get/index.ts deleted file mode 100644 index f06eb3d..0000000 --- a/packages/store/get/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { get } from 'svelte/store' - diff --git a/packages/store/index.ts b/packages/store/index.ts deleted file mode 100644 index 4f9ab77..0000000 --- a/packages/store/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './derived' -export * from './get' -export * from './readable' -export * from './writable' diff --git a/packages/store/package.json b/packages/store/package.json deleted file mode 100644 index 162098c..0000000 --- a/packages/store/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "@svelte-use/store", - "version": "0.8.1", - "description": "Enhancement for svelte/store", - "repository": { - "type": "git", - "url": "git+https://github.com/evillt/svelte-use.git" - }, - "keywords": [ - "svelte", - "svelte-use", - "utils" - ], - "author": "2nthony ", - "sideEffects": false, - "license": "MIT", - "bugs": { - "url": "https://github.com/evillt/svelte-use/issues" - }, - "homepage": "https://github.com/evillt/svelte-use/tree/main/packages/store#readme", - "types": "./index.d.ts", - "main": "./index.cjs", - "module": "./index.mjs", - "exports": { - ".": { - "import": "./index.mjs", - "require": "./index.cjs" - }, - "./*": "./*" - }, - "dependencies": { - "@svelte-use/shared": "workspace:*" - } -} diff --git a/packages/vite.config.ts b/packages/vite.config.ts index 5e1a61f..494996d 100644 --- a/packages/vite.config.ts +++ b/packages/vite.config.ts @@ -16,7 +16,6 @@ const config: UserConfig = { alias: { '@svelte-use/core': resolve(__dirname, 'core/index.ts'), '@svelte-use/shared': resolve(__dirname, 'shared/index.ts'), - '@svelte-use/store': resolve(__dirname, 'store/index.ts'), }, }, plugins: [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e40b9fc..02777fd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -96,23 +96,12 @@ importers: packages/core: specifiers: - '@svelte-use/shared': 0.8.1 - '@svelte-use/store': 0.8.1 + '@svelte-use/shared': workspace:* dependencies: '@svelte-use/shared': link:../shared - '@svelte-use/store': link:../store packages/shared: - specifiers: - '@svelte-use/store': 0.8.1 - dependencies: - '@svelte-use/store': link:../store - - packages/store: - specifiers: - '@svelte-use/shared': 0.8.1 - dependencies: - '@svelte-use/shared': link:../shared + specifiers: {} packages: