@ak2021/store 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## v1.0.0(2023-07-07)
2
+
3
+ feat: init
package/README.md ADDED
@@ -0,0 +1 @@
1
+ ## pkg1
@@ -0,0 +1,13 @@
1
+ var Store = /*#__PURE__*/ function() {
2
+ function Store(options) {
3
+ if (options === void 0) options = {};
4
+ this.options = options;
5
+ }
6
+ var _proto = Store.prototype;
7
+ _proto.on = function on(type, fn) {
8
+ console.log(type, fn, this.options);
9
+ };
10
+ return Store;
11
+ }();
12
+
13
+ export { Store as default };
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var Store = /*#__PURE__*/ function() {
4
+ function Store(options) {
5
+ if (options === void 0) options = {};
6
+ this.options = options;
7
+ }
8
+ var _proto = Store.prototype;
9
+ _proto.on = function on(type, fn) {
10
+ console.log(type, fn, this.options);
11
+ };
12
+ return Store;
13
+ }();
14
+
15
+ module.exports = Store;
@@ -0,0 +1,21 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Store = factory());
5
+ })(this, (function () { 'use strict';
6
+
7
+ var Store = /*#__PURE__*/ function() {
8
+ function Store(options) {
9
+ if (options === void 0) options = {};
10
+ this.options = options;
11
+ }
12
+ var _proto = Store.prototype;
13
+ _proto.on = function on(type, fn) {
14
+ console.log(type, fn, this.options);
15
+ };
16
+ return Store;
17
+ }();
18
+
19
+ return Store;
20
+
21
+ }));
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@ak2021/store",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "dev": "rollup --config rollup.config.js --watch",
8
+ "build": "npm run clean && cross-env NODE_ENV=production rollup --config rollup.config.js",
9
+ "clean": "rimraf dist",
10
+ "prepublish": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "keywords": [],
13
+ "author": "ShineShao <xiaoshaoqq@gmail.com>",
14
+ "license": "MIT"
15
+ }
@@ -0,0 +1,18 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>pkg2</title>
7
+ <script src="./index.umd.js"></script>
8
+ </head>
9
+
10
+ <body>
11
+ <script>
12
+ (function () {
13
+ const store = new Store({ id: 'app' });
14
+ store.on('event', () => console.log('store'));
15
+ })();
16
+ </script>
17
+ </body>
18
+ </html>
@@ -0,0 +1,54 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ const commonjs = require('@rollup/plugin-commonjs');
3
+ const resolve = require('@rollup/plugin-node-resolve');
4
+ const swc = require('@rollup/plugin-swc');
5
+ const serve = require('rollup-plugin-serve');
6
+ const { upperCamel } = require('@skax/camel');
7
+ const pkg = require('./package.json');
8
+
9
+ const isDev = process.env.NODE_ENV !== 'production';
10
+
11
+ module.exports = {
12
+ input: 'src/index.ts',
13
+ output: [
14
+ {
15
+ file: 'dist/index.umd.js',
16
+ format: 'umd',
17
+ name: upperCamel(pkg.name.split('/')[1]),
18
+ },
19
+ {
20
+ exports: 'auto',
21
+ // Node 默认的模块规范, 可通过 Webpack 加载
22
+ // https://javascript.ruanyifeng.com/nodejs/module.html
23
+ // https://zh.wikipedia.org/wiki/CommonJS
24
+ file: 'dist/index.js',
25
+ format: 'cjs',
26
+ },
27
+ {
28
+ // ES2015 Module 规范,
29
+ // https://exploringjs.com/es6/ch_modules.html
30
+ exports: 'auto',
31
+ file: 'dist/index.esm.js',
32
+ format: 'esm',
33
+ },
34
+ ],
35
+ plugins: [
36
+ swc({
37
+ // https://swc.rs/docs/configuration/swcrc
38
+ swc: {
39
+ jsc: {
40
+ target: 'es5',
41
+ },
42
+ },
43
+ include: ['**/src/**/*.{ts,js}'],
44
+ }),
45
+ resolve(),
46
+ commonjs({ extensions: ['.js', '.ts'] }),
47
+ isDev
48
+ ? serve({
49
+ port: 3000,
50
+ contentBase: ['public', 'dist'],
51
+ })
52
+ : null,
53
+ ].filter(Boolean),
54
+ };
package/src/index.ts ADDED
@@ -0,0 +1,16 @@
1
+ export interface StoreOptions {
2
+ id?: string;
3
+ }
4
+
5
+ class Store {
6
+ options: StoreOptions;
7
+ constructor(options: Partial<StoreOptions> = {}) {
8
+ this.options = options;
9
+ }
10
+
11
+ on(type: string, fn: any) {
12
+ console.log(type, fn, this.options);
13
+ }
14
+ }
15
+
16
+ export default Store;