From cd2138587d596c79b1bf953bffac211987dc394e Mon Sep 17 00:00:00 2001 From: haozi Date: Tue, 12 Mar 2024 15:43:54 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20v1.14.10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .npmignore | 16 ++++++++-------- README.md | 4 ++-- README.zh-CN.md | 4 ++-- browser-storage.ts => browser-storage.d.ts | 0 demo/package.json | 2 +- package.json | 11 ++++------- plugins/browser-storage/README.md | 8 ++++++-- plugins/browser-storage/src/index.ts | 4 +++- plugins/node-fs/README.md | 6 +++++- pnpm-lock.yaml | 10 ++-------- vercel.json | 4 +--- vite.demo.config.ts | 2 +- 12 files changed, 35 insertions(+), 36 deletions(-) rename browser-storage.ts => browser-storage.d.ts (100%) diff --git a/.npmignore b/.npmignore index 66b3189..d35dad4 100644 --- a/.npmignore +++ b/.npmignore @@ -6,23 +6,23 @@ .vscode .npmrc coverage -demo -mock +**/demo +**/mock **/src **/docs **/test +**/scripts .vite node_modules index.html pnpm-lock.yaml +pnpm-workspace.yaml yarn.lock package-lock.json tsconfig.json vite.config.ts vite.*.config.ts - -plugins/**/scripts/ -plugins/**/src/ -plugins/**/package.json -plugins/**/tsconfig.json -plugins/**/node_modules +vercel.json +SECURITY.md +index.html +.* diff --git a/README.md b/README.md index 92a8f2a..02f089b 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ An elegant library to solve duplicate and concurrent calls for idempotent functi English | [简体中文](README.zh-CN.md) -- Demo +- Demo ## Usage @@ -141,7 +141,7 @@ In React, you can share requests using swr, Provider and more complex state mana 2. Provider: Needs centralized data management. The data center can't perceive which modules will consume the data, need to maintain the data for a long time, and dare not delete it in time 3. Redux: Should focus on state changes and sequences, not data sharing. `idmp` lets you focus more on local state -See [demo](https://idmp.vercel.app) and [source code](https://github.com/ha0z1/idmp/tree/main/demo) +See [demo](https://idmp-ha0z1.vercel.app) and [source code](https://github.com/ha0z1/idmp/tree/main/demo) So when module A or module B's code is deleted, there is no need to maintain their cache. diff --git a/README.zh-CN.md b/README.zh-CN.md index ff76a32..034dd34 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -11,7 +11,7 @@ [English](README.md) | 简体中文 -- Demo +- Demo ## 使用 @@ -141,7 +141,7 @@ fetchData2().then(...) // will skip cache 2. Provider 数据共享: 需要一个中心化的数据管理。数据中心无法感知到哪些模块会消费数据,需要长期维护这些数据,而不敢及时删除 3. Redux 等状态管理库:应该专注的是状态的变化和时序,而非共享数据。`idmp` 让你更关注于局部状态 -查看 [demo](https://idmp.vercel.app) 和[源码](https://github.com/ha0z1/idmp/tree/main/demo) +查看 [demo](https://idmp-ha0z1.vercel.app) 和[源码](https://github.com/ha0z1/idmp/tree/main/demo) 这样当模块 A 或者模块 B 的代码删除后,是不需要维护他们的缓存的。 diff --git a/browser-storage.ts b/browser-storage.d.ts similarity index 100% rename from browser-storage.ts rename to browser-storage.d.ts diff --git a/demo/package.json b/demo/package.json index 93e805c..0692170 100644 --- a/demo/package.json +++ b/demo/package.json @@ -1,7 +1,7 @@ { "private": true, "dependencies": { - "idmp": "1.14.4" + "idmp": "^1.14.10" }, "_dependencies": { "idmp": "1.13.0-alpha.5" diff --git a/package.json b/package.json index eb8ecff..cf3f54b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "idmp", - "version": "1.14.6", + "version": "1.14.10", "keywords": [ "deduplicate network requests", "idempotent function", @@ -16,7 +16,7 @@ "immutable data", "auto retry" ], - "homepage": "https://idmp.vercel.app", + "homepage": "https://idmp-ha0z1.vercel.app", "bugs": "https://github.com/ha0z1/idmp/issues", "repository": { "type": "git", @@ -26,15 +26,12 @@ "type": "module", "exports": { ".": "./dist/index.js", - "./node-fs": "./plugins/node-fs/dist/index.js" + "./node-fs": "./plugins/node-fs/dist/index.js", + "./browser-storage": "./plugins/browser-storage/dist/index.js" }, "main": "./dist/index.node.cjs", "module": "./dist/index.js", "types": "./dist/index.d.ts", - "files": [ - "**/dist", - "*.d.ts" - ], "scripts": { "api": "pnpm vite-node -w mock/api.ts", "build": "tsc && vite-node scripts/build.ts && pnpm run -r build", diff --git a/plugins/browser-storage/README.md b/plugins/browser-storage/README.md index da83f93..2899aed 100644 --- a/plugins/browser-storage/README.md +++ b/plugins/browser-storage/README.md @@ -1,6 +1,6 @@ -# idmp/node-fs +# idmp/browser-storage -## Useage +## Usage ```typescript import idmp from 'idmp' @@ -27,3 +27,7 @@ getUserDataWithlocalStorageIdmp('123').then((data) => { Cache data will be stored in `localStorage / sessionStorage` temporary directory and follow the same cache options as `idmp`. If the data is in the memory, it is read from the memory first. If it is not in the memory, it is read from the `localStorage / sessionStorage`. If the cache validity period expires, it will be read from the remote end. + +## Notice + +Data persistence only supports string type `globalKey` and data structures that can be serialized by `JSON.stringify` diff --git a/plugins/browser-storage/src/index.ts b/plugins/browser-storage/src/index.ts index d2f36a3..8ad0aea 100644 --- a/plugins/browser-storage/src/index.ts +++ b/plugins/browser-storage/src/index.ts @@ -76,7 +76,9 @@ const storageIdmpWrap = ( const localData = storage.get(globalKey) if (localData) { if (process.env.NODE_ENV !== 'production') { - console.log(`[idmp-plugin browser-storage debug] ${globalKey} from ${storageType}["${getCacheKey(globalKey)}"]`) + console.log( + `[idmp-plugin browser-storage debug] ${globalKey} from ${storageType}["${getCacheKey(globalKey)}"]`, + ) } return localData } diff --git a/plugins/node-fs/README.md b/plugins/node-fs/README.md index cff8482..8e77b0c 100644 --- a/plugins/node-fs/README.md +++ b/plugins/node-fs/README.md @@ -1,6 +1,6 @@ # idmp/node-fs -## Useage +## Usage ```typescript import idmp from 'idmp' @@ -19,3 +19,7 @@ await fsIdmp( Cache data will be stored in the `cacheDir` temporary directory and follow the same cache options as `idmp`. If the data is in the memory, it is read from the memory first. If it is not in the memory, it is read from the file system. If the cache validity period expires, it will be read from the remote end. + +## Notice + +Data persistence only supports string type `globalKey` and data structures that can be serialized by `JSON.stringify` diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e765413..dbe24be 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -70,8 +70,8 @@ importers: demo: dependencies: idmp: - specifier: 1.14.4 - version: 1.14.4 + specifier: ^1.14.10 + version: link:.. plugins/browser-storage: dependencies: @@ -2731,12 +2731,6 @@ packages: engines: {node: '>=16.17.0'} dev: true - /idmp@1.14.4: - resolution: {integrity: sha512-iC5J/tpwuSdYhqeD3iDER9yQbilptnA3s1zLAs+/fVfS60brF7KzQVHvchS0pvK+vsfSxB41054JOlsP0CvSAw==} - dependencies: - fs-extra: 11.2.0 - dev: false - /import-lazy@4.0.0: resolution: {integrity: sha512-rKtvo6a868b5Hu3heneU+L4yEQ4jYKLtjpnPeUdK7h0yzXGmyBTypknlkCvHFBqfX9YlorEiMM6Dnq/5atfHkw==} engines: {node: '>=8'} diff --git a/vercel.json b/vercel.json index 59fd940..3a48e56 100644 --- a/vercel.json +++ b/vercel.json @@ -1,5 +1,3 @@ { - "rewrites": [ - {"source": "/(.*)", "destination": "/"} - ] + "rewrites": [{ "source": "/(.*)", "destination": "/" }] } diff --git a/vite.demo.config.ts b/vite.demo.config.ts index 1ec276b..dce72b4 100644 --- a/vite.demo.config.ts +++ b/vite.demo.config.ts @@ -8,6 +8,6 @@ export default defineConfig({ define: { // __DEV__: "process.env.NODE_ENV !== 'production'", // 'process.env.NODE_ENV': JSON.stringify('production'), - 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) + 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), }, })