@ywfe/fe-tools 1.0.2-beta.5 → 1.0.2-beta.6

Sign up to get free protection for your applications and to get access to all the features.
package/jest.config.js ADDED
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ preset: 'ts-jest',
3
+ testEnvironment: 'jsdom',
4
+ moduleFileExtensions: ['js', 'jsx', 'json', 'ts', 'tsx'],
5
+ rootDir: '.',
6
+ roots: ['<rootDir>/src/'],
7
+ testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?|ts?)$',
8
+ transform: {
9
+ '^.+\\.(t|j)s$': 'ts-jest',
10
+ '^.+\\.(t|j)sx$': 'ts-jest',
11
+ },
12
+ };
package/package.json CHANGED
@@ -1,26 +1,32 @@
1
1
  {
2
+ "private": false,
2
3
  "name": "@ywfe/fe-tools",
3
- "version": "1.0.2-beta.5",
4
+ "version": "1.0.2-beta.6",
4
5
  "description": "工具函数库",
5
6
  "main": "lib/ywfe-tools.esm.js",
6
7
  "module": "lib/ywfe-tools.esm.js",
7
8
  "browser": "lib/ywfe-tools.umd.js",
8
9
  "types": "lib/index.d.ts",
9
- "type": "module",
10
10
  "scripts": {
11
- "build": "rollup -c",
12
- "prepublishOnly": "npm run build"
11
+ "build": "NODE_ENV=production rollup -c",
12
+ "build:type": "tsc -p ./tsconfig.type.json",
13
+ "publish:npm": "npm publish --access public",
14
+ "test": "jest --coverage"
13
15
  },
14
- "publishConfig": {
15
- "access": "public",
16
- "registry": "https://registry.npmjs.org/"
16
+ "repository": "ywfe",
17
+ "author": {
18
+ "name": "YWFE",
19
+ "email": "ywfe@ywwl.com",
20
+ "url": "http://ywfe.com"
17
21
  },
22
+ "license": "MIT",
18
23
  "dependencies": {
19
- "@ywfe/utils": "^0.10.74"
24
+ "@ywfe/utils": "^0.10.74",
25
+ "crypto-js": "^4.0.0",
26
+ "ramda": "^0.27.1",
27
+ "strtok3": "^6.3.0",
28
+ "token-types": "^4.2.0",
29
+ "uuid": "^8.3.2"
20
30
  },
21
- "devDependencies": {
22
- "typescript": "^5.4.5"
23
- },
24
- "author": "",
25
- "license": "ISC"
31
+ "gitHead": "795058c747c80a3a69f6904dccffb53c42acfcc7"
26
32
  }
package/rollup.config.js CHANGED
@@ -1,26 +1,77 @@
1
+ import nodeResolver from '@rollup/plugin-node-resolve';
2
+ import commonjs from '@rollup/plugin-commonjs';
3
+ import replace from '@rollup/plugin-replace';
4
+ import json from '@rollup/plugin-json';
5
+ import nodePolyfills from 'rollup-plugin-node-polyfills';
6
+ import clear from 'rollup-plugin-clear';
7
+ import progress from 'rollup-plugin-progress';
1
8
  import typescript from '@rollup/plugin-typescript';
2
- import commonjs from '@rollup/plugin-commonjs'
3
- import resolve from '@rollup/plugin-node-resolve';
4
- import babel from 'rollup-plugin-babel';
5
9
  import { terser } from 'rollup-plugin-terser';
6
- export default {
7
- input:'./index.ts', // 入口文件
8
- output:{
9
- file:'lib/ywfe-tools.esm.js', // 输出文件
10
- format: 'es', // 输出格式 amd / es / cjs / iife / umd / system
11
- name:'func', // 当format为iife和umd时必须提供,将作为全局变量挂在window(浏览器环境)下:window.A=...
12
- sourcemap:true // 生成bundle.js.map文件,方便调试
10
+ // import pkg from './package.json';
11
+
12
+ const isProd = process.env.NODE_ENV === 'production';
13
+
14
+ const formats = {
15
+ commonjs: {
16
+ format: 'cjs',
17
+ file: 'lib/ywfe-tools.esm.js',
18
+ sourcemap: true,
19
+ exports: 'named',
13
20
  },
14
- treeshake: true,
21
+ esm: {
22
+ format: 'esm',
23
+ file: 'lib/ywfe-tools.esm.js',
24
+ sourcemap: true,
25
+ exports: 'named',
26
+ },
27
+ umd: {
28
+ format: 'umd',
29
+ file: 'lib/ywfe-tools.umd.js',
30
+ name: 'YWTOOLS',
31
+ sourcemap: true,
32
+ exports: 'named',
33
+ globals: {
34
+ 'react': 'React',
35
+ 'react-dom': 'ReactDOM',
36
+ },
37
+ },
38
+ };
39
+
40
+ const config = {
41
+ input: './index.ts',
42
+ inlineDynamicImports: true,
43
+ output: [formats.esm, formats.commonjs],
44
+ external: ['react', 'react-dom'],
15
45
  plugins: [
16
- resolve(),
17
- typescript(),
18
- commonjs({
19
- include: /node_modules/,
20
- }),
21
- babel({
22
- exclude: 'node_modules/**', // 排除转换node_modules下的文件
46
+ clear({
47
+ targets: ['lib'],
48
+ }),
49
+ progress({
50
+ clearLine: false,
23
51
  }),
24
- // terser(), // 代码压缩
25
- ]
26
- }
52
+ replace({
53
+ NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development'),
54
+ }),
55
+ nodeResolver(),
56
+ commonjs(),
57
+ typescript(),
58
+ json(),
59
+ nodePolyfills(),
60
+ ],
61
+ watch: {
62
+ include: 'src/**',
63
+ exclude: 'node_modules/**',
64
+ },
65
+ };
66
+
67
+ if (isProd) {
68
+ const file = formats.umd.file;
69
+
70
+ config.output.push({
71
+ ...formats.umd,
72
+ file,
73
+ plugins: [terser()],
74
+ });
75
+ }
76
+
77
+ export default config;
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "rootDir": "./",
3
+ "rootDir": "./src",
4
4
  "outDir": "./lib",
5
5
  /* Basic Options */
6
6
  "target": "es2017",
@@ -33,6 +33,20 @@
33
33
  "pretty": true,
34
34
  "jsx": "react",
35
35
  "allowJs": true,
36
- "baseUrl": "./"
36
+ "baseUrl": "./",
37
+ "paths": {
38
+ "@/*": [
39
+ "src/*"
40
+ ]
41
+ }
37
42
  },
38
- }
43
+ "include": [
44
+ "src/**/*.ts",
45
+ "**/*.spec.ts",
46
+ "src/_internal/jsMD5.js"
47
+ ],
48
+ "exclude": [
49
+ "node_modules",
50
+ "src/**/*.js",
51
+ ]
52
+ }
@@ -1,8 +1,8 @@
1
1
  {
2
- "extends": "./tsconfig",
3
- "compilerOptions": {
4
- "declaration": true,
5
- "declarationDir": "./lib",
6
- "emitDeclarationOnly": true
7
- }
8
- }
2
+ "extends": "./tsconfig",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "declarationDir": "./lib",
6
+ "emitDeclarationOnly": true
7
+ }
8
+ }
@@ -4,8 +4,8 @@ interface userInput {
4
4
  rules?:string,
5
5
  }
6
6
  async function userInputToJson({input}:{input:userInput}){
7
- const {userInput, rules} = input
8
- console.log('cesh')
7
+ //const {userInput, rules} = input
8
+ console.log('cesh',input)
9
9
  //@ts-ignore
10
10
  const res = await feTools.request({
11
11
  input:{
@@ -1,5 +0,0 @@
1
- declare function JSON2String({ input }: {
2
- input: any;
3
- }): string;
4
- export default JSON2String;
5
- //# sourceMappingURL=JSON2String.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"JSON2String.d.ts","sourceRoot":"","sources":["../JSON2String.ts"],"names":[],"mappings":"AAGA,iBAAS,WAAW,CAAC,EAAE,KAAK,EAAE;;CAAA,UAO7B;AAED,eAAe,WAAW,CAAA"}
package/lib/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export { default as request } from './request';
2
- export { default as userInputToJson } from './userInputToJson';
3
- export { default as JSON2String } from './JSON2String';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA"}
package/lib/request.d.ts DELETED
@@ -1,10 +0,0 @@
1
- interface RequestOptions {
2
- url: string;
3
- method?: string;
4
- params?: any;
5
- }
6
- declare function request({ input }: {
7
- input: RequestOptions;
8
- }): Promise<any>;
9
- export default request;
10
- //# sourceMappingURL=request.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../request.ts"],"names":[],"mappings":"AAEA,UAAU,cAAc;IACtB,GAAG,EAAC,MAAM,CAAC;IACX,MAAM,CAAC,EAAC,MAAM,CAAC;IACf,MAAM,CAAC,EAAC,GAAG,CAAA;CACZ;AACD,iBAAe,OAAO,CAAC,EAAC,KAAK,EAAC,EAAC;IAAC,KAAK,EAAC,cAAc,CAAA;CAAC,gBAwCpD;AACD,eAAe,OAAO,CAAA"}
@@ -1,9 +0,0 @@
1
- interface userInput {
2
- userInput?: string;
3
- rules?: string;
4
- }
5
- declare function userInputToJson({ input }: {
6
- input: userInput;
7
- }): Promise<any>;
8
- export default userInputToJson;
9
- //# sourceMappingURL=userInputToJson.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"userInputToJson.d.ts","sourceRoot":"","sources":["../userInputToJson.ts"],"names":[],"mappings":"AACA,UAAU,SAAS;IACjB,SAAS,CAAC,EAAC,MAAM,CAAC;IAClB,KAAK,CAAC,EAAC,MAAM,CAAC;CACf;AACD,iBAAe,eAAe,CAAC,EAAC,KAAK,EAAC,EAAC;IAAC,KAAK,EAAC,SAAS,CAAA;CAAC,gBAWvD;AACD,eAAe,eAAe,CAAA"}