smallstonesk
4 years ago
8 changed files with 103 additions and 0 deletions
@ -0,0 +1,3 @@ |
|||
{ |
|||
"extends": "../../.babelrc" |
|||
} |
@ -0,0 +1 @@ |
|||
node_modules |
@ -0,0 +1,45 @@ |
|||
{ |
|||
"name": "@imove/plugin-store", |
|||
"version": "0.0.1", |
|||
"description": "iMove plugin that supports persisting data", |
|||
"keywords": [ |
|||
"imove", |
|||
"plugin", |
|||
"store" |
|||
], |
|||
"author": "smallstonesk <575913857@qq.com>", |
|||
"homepage": "https://github.com/suanmei/iMove#readme", |
|||
"license": "MIT", |
|||
"main": "dist/core.common.js", |
|||
"module": "dist/core.esm.js", |
|||
"types": "dist/types/index.d.ts", |
|||
"directories": { |
|||
"dist": "dist" |
|||
}, |
|||
"files": [ |
|||
"dist" |
|||
], |
|||
"publishConfig": { |
|||
"access": "public", |
|||
"registry": "http://registry.npmjs.org/" |
|||
}, |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git+https://github.com/suanmei/iMove.git" |
|||
}, |
|||
"scripts": { |
|||
"prepublishOnly": "node scripts/prepublish.js", |
|||
"declare-type": "tsc --emitDeclarationOnly", |
|||
"build": "rollup -c & npm run declare-type", |
|||
"watch": "watch 'npm run build' ./src" |
|||
}, |
|||
"bugs": { |
|||
"url": "https://github.com/suanmei/iMove/issues" |
|||
}, |
|||
"devDependencies": { |
|||
"rollup": "^2.7.3", |
|||
"watch": "^1.0.2" |
|||
}, |
|||
"dependencies": { |
|||
} |
|||
} |
@ -0,0 +1,17 @@ |
|||
import path from 'path'; |
|||
import rollupBaseConfig from '../../rollup.config'; |
|||
import pkg from './package.json'; |
|||
|
|||
export default Object.assign(rollupBaseConfig, { |
|||
input: path.join(__dirname, './src/index.ts'), |
|||
output: [ |
|||
{ |
|||
file: pkg.main, |
|||
format: 'cjs', |
|||
}, |
|||
{ |
|||
file: pkg.module, |
|||
format: 'es', |
|||
}, |
|||
] |
|||
}); |
@ -0,0 +1,6 @@ |
|||
#!/usr/bin/env node
|
|||
|
|||
const path = require('path'); |
|||
const prePublish = require('../../../scripts/prepublish'); |
|||
|
|||
prePublish('@imove/plugin-store', path.join(__dirname, '../')); |
@ -0,0 +1,24 @@ |
|||
const storeSymbol = Symbol('store'); |
|||
|
|||
const plugin = (logic: any) => { |
|||
return { |
|||
ctxCreated(ctx: { [key: string]: any }) { |
|||
if (!logic[storeSymbol]) { |
|||
logic[storeSymbol] = {}; |
|||
} |
|||
ctx.store = { |
|||
set(key: string, val: any) { |
|||
logic[storeSymbol][key] = val; |
|||
}, |
|||
get(key: string) { |
|||
return logic[storeSymbol][key]; |
|||
}, |
|||
remove(key: string) { |
|||
delete logic[storeSymbol][key]; |
|||
} |
|||
}; |
|||
} |
|||
}; |
|||
}; |
|||
|
|||
export default plugin; |
@ -0,0 +1,7 @@ |
|||
{ |
|||
"extends": "../../tsconfig", |
|||
"compilerOptions": { |
|||
"outDir": "dist/types" |
|||
}, |
|||
"include": ["./src", "./types"] |
|||
} |
Loading…
Reference in new issue