easyutilssdk 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -1,103 +1,15 @@
1
- # TSDX User Guide
1
+ # 🚀 Welcome to your new awesome project!
2
2
 
3
- Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s here and how to use it.
3
+ This project has been created using **webpack-cli**, you can now run
4
4
 
5
- > This TSDX setup is meant for developing libraries (not apps!) that can be published to NPM. If you’re looking to build a Node app, you could use `ts-node-dev`, plain `ts-node`, or simple `tsc`.
6
-
7
- > If you’re new to TypeScript, checkout [this handy cheatsheet](https://devhints.io/typescript)
8
-
9
- ## Commands
10
-
11
- TSDX scaffolds your new library inside `/src`.
12
-
13
- To run TSDX, use:
14
-
15
- ```bash
16
- npm start # or yarn start
17
5
  ```
18
-
19
- This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`.
20
-
21
- To do a one-off build, use `npm run build` or `yarn build`.
22
-
23
- To run tests, use `npm test` or `yarn test`.
24
-
25
- ## Configuration
26
-
27
- Code quality is set up for you with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.
28
-
29
- ### Jest
30
-
31
- Jest tests are set up to run with `npm test` or `yarn test`.
32
-
33
- ### Bundle Analysis
34
-
35
- [`size-limit`](https://github.com/ai/size-limit) is set up to calculate the real cost of your library with `npm run size` and visualize the bundle with `npm run analyze`.
36
-
37
- #### Setup Files
38
-
39
- This is the folder structure we set up for you:
40
-
41
- ```txt
42
- /src
43
- index.tsx # EDIT THIS
44
- /test
45
- blah.test.tsx # EDIT THIS
46
- .gitignore
47
- package.json
48
- README.md # EDIT THIS
49
- tsconfig.json
6
+ npm run build
50
7
  ```
51
8
 
52
- ### Rollup
53
-
54
- TSDX uses [Rollup](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details.
55
-
56
- ### TypeScript
9
+ or
57
10
 
58
- `tsconfig.json` is set up to interpret `dom` and `esnext` types, as well as `react` for `jsx`. Adjust according to your needs.
59
-
60
- ## Continuous Integration
61
-
62
- ### GitHub Actions
63
-
64
- Two actions are added by default:
65
-
66
- - `main` which installs deps w/ cache, lints, tests, and builds on all pushes against a Node and OS matrix
67
- - `size` which comments cost comparison of your library on every pull request using [`size-limit`](https://github.com/ai/size-limit)
68
-
69
- ## Optimizations
70
-
71
- Please see the main `tsdx` [optimizations docs](https://github.com/palmerhq/tsdx#optimizations). In particular, know that you can take advantage of development-only optimizations:
72
-
73
- ```js
74
- // ./types/index.d.ts
75
- declare var __DEV__: boolean;
76
-
77
- // inside your code...
78
- if (__DEV__) {
79
- console.log('foo');
80
- }
11
+ ```
12
+ yarn build
81
13
  ```
82
14
 
83
- You can also choose to install and use [invariant](https://github.com/palmerhq/tsdx#invariant) and [warning](https://github.com/palmerhq/tsdx#warning) functions.
84
-
85
- ## Module Formats
86
-
87
- CJS, ESModules, and UMD module formats are supported.
88
-
89
- The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.
90
-
91
- ## Named Exports
92
-
93
- Per Palmer Group guidelines, [always use named exports.](https://github.com/palmerhq/typescript#exports) Code split inside your React app instead of your React library.
94
-
95
- ## Including Styles
96
-
97
- There are many ways to ship styles, including with CSS-in-JS. TSDX has no opinion on this, configure how you like.
98
-
99
- For vanilla CSS, you can include it at the root directory and add it to the `files` section in your `package.json`, so that it can be imported separately by your users and run through their bundler's loader.
100
-
101
- ## Publishing to NPM
102
-
103
- We recommend using [np](https://github.com/sindresorhus/np).
15
+ to bundle your application
File without changes
package/dist/index.d.ts CHANGED
@@ -1 +1,8 @@
1
- export declare const sum: (a: number, b: number) => number;
1
+ export type { SortOptions } from './json';
2
+ declare const easyutilssdk: {
3
+ json: {
4
+ sortObjectKeys: (obj: any, { sortType }?: import("./json").SortOptions) => object | null;
5
+ sortJson: (jsonString: string, { sortType }?: import("./json").SortOptions) => string;
6
+ };
7
+ };
8
+ export default easyutilssdk;
package/dist/json.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export interface SortOptions {
2
+ sortType?: 'asc' | 'desc';
3
+ }
4
+ declare const jsonUtils: {
5
+ sortObjectKeys: (obj: any, { sortType }?: SortOptions) => object | null;
6
+ sortJson: (jsonString: string, { sortType }?: SortOptions) => string;
7
+ };
8
+ export default jsonUtils;
@@ -0,0 +1,27 @@
1
+ export interface LoopFolderCallback {
2
+ (filePath: string, isDirectory: boolean, index: number): void;
3
+ }
4
+ /**
5
+ * 读取文件并转换为JSON
6
+ * @param filePath 文件路径
7
+ * @returns 转换之后的JSON对象
8
+ */
9
+ export declare const readFileToJSONSync: (filePath: string) => object;
10
+ /**
11
+ * 拷贝文件夹至目标目录
12
+ * @param source 源文件夹
13
+ * @param target 目标文件夹
14
+ */
15
+ export declare const copyFolderSync: (source: string, target: string) => void;
16
+ /**
17
+ * 递归遍历文件夹执行特定回调
18
+ * @param folderPath 文件夹路径
19
+ * @param callBack 回调方法
20
+ */
21
+ export declare const loopFolderSync: (folderPath: string, callBack: LoopFolderCallback) => void;
22
+ declare const fsUtils: {
23
+ readFileToJSONSync: (filePath: string) => object;
24
+ copyFolderSync: (source: string, target: string) => void;
25
+ loopFolderSync: (folderPath: string, callBack: LoopFolderCallback) => void;
26
+ };
27
+ export default fsUtils;
@@ -0,0 +1,13 @@
1
+ export type { LoopFolderCallback } from './fs';
2
+ declare const _default: {
3
+ fs: {
4
+ readFileToJSONSync: (filePath: string) => object;
5
+ copyFolderSync: (source: string, target: string) => void;
6
+ loopFolderSync: (folderPath: string, callBack: import("./fs").LoopFolderCallback) => void;
7
+ };
8
+ json: {
9
+ sortObjectKeys: (obj: any, { sortType }?: import("../src/json").SortOptions) => object | null;
10
+ sortJson: (jsonString: string, { sortType }?: import("../src/json").SortOptions) => string;
11
+ };
12
+ };
13
+ export default _default;
@@ -0,0 +1,156 @@
1
+ /**
2
+ * 版本信息
3
+ * realBranch(真实分支): dev
4
+ * buildTime(打包时间): 2025/6/13 14:04:02
5
+ * commitId(最后一条提交SHA): cf6388cbd07d30888bee6f48775ceab6d99ae7da
6
+ */
7
+
8
+ /*
9
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
10
+ * This devtool is neither made for production nor for readable output files.
11
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
12
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
13
+ * or disable the default devtool with "devtool: false".
14
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
15
+ */
16
+ /******/ (() => { // webpackBootstrap
17
+ /******/ "use strict";
18
+ /******/ var __webpack_modules__ = ({
19
+
20
+ /***/ "./node/fs.ts":
21
+ /*!********************!*\
22
+ !*** ./node/fs.ts ***!
23
+ \********************/
24
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
25
+
26
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ copyFolderSync: () => (/* binding */ copyFolderSync),\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__),\n/* harmony export */ loopFolderSync: () => (/* binding */ loopFolderSync),\n/* harmony export */ readFileToJSONSync: () => (/* binding */ readFileToJSONSync)\n/* harmony export */ });\n/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fs */ \"fs\");\n/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! path */ \"path\");\n/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);\n\n\n/**\n * 读取文件并转换为JSON\n * @param filePath 文件路径\n * @returns 转换之后的JSON对象\n */\nvar readFileToJSONSync = function (filePath) {\n try {\n var fileStr = fs__WEBPACK_IMPORTED_MODULE_0__.readFileSync(filePath, 'utf8');\n return JSON.parse(fileStr);\n }\n catch (error) {\n console.error(\"Failed to read or parse setting file \".concat(filePath, \":\"), error);\n return {};\n }\n};\n/**\n * 拷贝文件夹至目标目录\n * @param source 源文件夹\n * @param target 目标文件夹\n */\nvar copyFolderSync = function (source, target) {\n if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(target)) {\n fs__WEBPACK_IMPORTED_MODULE_0__.mkdirSync(target);\n }\n var files = fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync(source);\n for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {\n var file = files_1[_i];\n var sourcePath = path__WEBPACK_IMPORTED_MODULE_1__.join(source, file);\n var targetPath = path__WEBPACK_IMPORTED_MODULE_1__.join(target, file);\n if (fs__WEBPACK_IMPORTED_MODULE_0__.lstatSync(sourcePath).isDirectory()) {\n copyFolderSync(sourcePath, targetPath);\n }\n else {\n fs__WEBPACK_IMPORTED_MODULE_0__.copyFileSync(sourcePath, targetPath);\n }\n }\n};\n/**\n * 递归遍历文件夹执行特定回调\n * @param folderPath 文件夹路径\n * @param callBack 回调方法\n */\nvar loopFolderSync = function (folderPath, callBack) {\n if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(folderPath)) {\n return;\n }\n fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync(folderPath).forEach(function (file, index) {\n var curPath = path__WEBPACK_IMPORTED_MODULE_1__.join(folderPath, file);\n var isDirectory = fs__WEBPACK_IMPORTED_MODULE_0__.lstatSync(curPath).isDirectory();\n if (isDirectory) {\n loopFolderSync(curPath, callBack);\n }\n callBack(curPath, isDirectory, index);\n });\n};\nvar fsUtils = {\n readFileToJSONSync: readFileToJSONSync,\n copyFolderSync: copyFolderSync,\n loopFolderSync: loopFolderSync\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (fsUtils);\n\n\n//# sourceURL=webpack://easyutilssdk/./node/fs.ts?");
27
+
28
+ /***/ }),
29
+
30
+ /***/ "./node/index.ts":
31
+ /*!***********************!*\
32
+ !*** ./node/index.ts ***!
33
+ \***********************/
34
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
35
+
36
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fs */ \"./node/fs.ts\");\n/* harmony import */ var _src_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../src/index */ \"./src/index.ts\");\nvar __assign = (undefined && undefined.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\n// 使用命名导出替代默认导出\n\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (__assign(__assign({}, _src_index__WEBPACK_IMPORTED_MODULE_1__[\"default\"]), { fs: _fs__WEBPACK_IMPORTED_MODULE_0__[\"default\"] }));\n\n\n//# sourceURL=webpack://easyutilssdk/./node/index.ts?");
37
+
38
+ /***/ }),
39
+
40
+ /***/ "./src/index.ts":
41
+ /*!**********************!*\
42
+ !*** ./src/index.ts ***!
43
+ \**********************/
44
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
45
+
46
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _json__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./json */ \"./src/json.ts\");\n// 使用命名导出替代默认导出\n\nvar easyutilssdk = {\n json: _json__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (easyutilssdk);\n\n\n//# sourceURL=webpack://easyutilssdk/./src/index.ts?");
47
+
48
+ /***/ }),
49
+
50
+ /***/ "./src/json.ts":
51
+ /*!*********************!*\
52
+ !*** ./src/json.ts ***!
53
+ \*********************/
54
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
55
+
56
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/**\n * 对JSON对象按照key进行升序或者降序排序\n * @param obj JSON对象\n * @param SortOptions 排序参数:sortType为排序方式,asc升序,desc降序,默认asc\n * @returns 排序之后的JSON对象\n */\nvar sortObjectKeys = function (obj, _a) {\n var _b = _a === void 0 ? {} : _a, _c = _b.sortType, sortType = _c === void 0 ? 'asc' : _c;\n if (typeof obj !== 'object' || obj === null) {\n return obj;\n }\n if (Array.isArray(obj)) {\n return obj.map(function (item) { return sortObjectKeys(item, { sortType: sortType }); });\n }\n return Object.keys(obj)\n .sort(function (a, b) {\n var res = sortType === 'desc'\n ? b.toLowerCase().localeCompare(a.toLowerCase())\n : a.toLowerCase().localeCompare(b.toLowerCase());\n return res;\n })\n .reduce(function (acc, key) {\n acc[key] = sortObjectKeys(obj[key], { sortType: sortType });\n return acc;\n }, {});\n};\n/**\n * 将JSON字符串格式化并按照key进行排序\n * @param jsonString 原始JSON字符串\n * @param SortOptions 排序参数:sortType为排序方式,asc升序,desc降序,默认asc\n * @returns 格式化之后的JSON字符串\n */\nvar sortJson = function (jsonString, _a) {\n var _b = _a === void 0 ? {} : _a, _c = _b.sortType, sortType = _c === void 0 ? 'asc' : _c;\n try {\n var parsed = JSON.parse(jsonString);\n var sortedParsed = sortObjectKeys(parsed, { sortType: sortType });\n return JSON.stringify(sortedParsed, null, 2);\n }\n catch (e) {\n console.error('Failed to parse JSON string:', e);\n return jsonString; // Return original string if parsing fails\n }\n};\nvar jsonUtils = {\n sortObjectKeys: sortObjectKeys,\n sortJson: sortJson\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (jsonUtils);\n\n\n//# sourceURL=webpack://easyutilssdk/./src/json.ts?");
57
+
58
+ /***/ }),
59
+
60
+ /***/ "fs":
61
+ /*!*********************!*\
62
+ !*** external "fs" ***!
63
+ \*********************/
64
+ /***/ ((module) => {
65
+
66
+ module.exports = require("fs");
67
+
68
+ /***/ }),
69
+
70
+ /***/ "path":
71
+ /*!***********************!*\
72
+ !*** external "path" ***!
73
+ \***********************/
74
+ /***/ ((module) => {
75
+
76
+ module.exports = require("path");
77
+
78
+ /***/ })
79
+
80
+ /******/ });
81
+ /************************************************************************/
82
+ /******/ // The module cache
83
+ /******/ var __webpack_module_cache__ = {};
84
+ /******/
85
+ /******/ // The require function
86
+ /******/ function __webpack_require__(moduleId) {
87
+ /******/ // Check if module is in cache
88
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
89
+ /******/ if (cachedModule !== undefined) {
90
+ /******/ return cachedModule.exports;
91
+ /******/ }
92
+ /******/ // Create a new module (and put it into the cache)
93
+ /******/ var module = __webpack_module_cache__[moduleId] = {
94
+ /******/ // no module.id needed
95
+ /******/ // no module.loaded needed
96
+ /******/ exports: {}
97
+ /******/ };
98
+ /******/
99
+ /******/ // Execute the module function
100
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
101
+ /******/
102
+ /******/ // Return the exports of the module
103
+ /******/ return module.exports;
104
+ /******/ }
105
+ /******/
106
+ /************************************************************************/
107
+ /******/ /* webpack/runtime/compat get default export */
108
+ /******/ (() => {
109
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
110
+ /******/ __webpack_require__.n = (module) => {
111
+ /******/ var getter = module && module.__esModule ?
112
+ /******/ () => (module['default']) :
113
+ /******/ () => (module);
114
+ /******/ __webpack_require__.d(getter, { a: getter });
115
+ /******/ return getter;
116
+ /******/ };
117
+ /******/ })();
118
+ /******/
119
+ /******/ /* webpack/runtime/define property getters */
120
+ /******/ (() => {
121
+ /******/ // define getter functions for harmony exports
122
+ /******/ __webpack_require__.d = (exports, definition) => {
123
+ /******/ for(var key in definition) {
124
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
125
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
126
+ /******/ }
127
+ /******/ }
128
+ /******/ };
129
+ /******/ })();
130
+ /******/
131
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
132
+ /******/ (() => {
133
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
134
+ /******/ })();
135
+ /******/
136
+ /******/ /* webpack/runtime/make namespace object */
137
+ /******/ (() => {
138
+ /******/ // define __esModule on exports
139
+ /******/ __webpack_require__.r = (exports) => {
140
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
141
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
142
+ /******/ }
143
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
144
+ /******/ };
145
+ /******/ })();
146
+ /******/
147
+ /************************************************************************/
148
+ /******/
149
+ /******/ // startup
150
+ /******/ // Load entry module and return exports
151
+ /******/ // This entry module can't be inlined because the eval devtool is used.
152
+ /******/ var __webpack_exports__ = __webpack_require__("./node/index.ts");
153
+ /******/ module.exports = __webpack_exports__;
154
+ /******/
155
+ /******/ })()
156
+ ;
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Webpack App</title>
6
+ <script defer src="index.js"></script></head>
7
+ <body>
8
+ <h1>Hello world!</h1>
9
+ <h2>Tip: Check your console</h2>
10
+ </body>
11
+
12
+ </html>
@@ -0,0 +1,101 @@
1
+ /**
2
+ * 版本信息
3
+ * realBranch(真实分支): dev
4
+ * buildTime(打包时间): 2025/6/13 14:03:58
5
+ * commitId(最后一条提交SHA): cf6388cbd07d30888bee6f48775ceab6d99ae7da
6
+ */
7
+
8
+ /*
9
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
10
+ * This devtool is neither made for production nor for readable output files.
11
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
12
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
13
+ * or disable the default devtool with "devtool: false".
14
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
15
+ */
16
+ /******/ var __webpack_modules__ = ({
17
+
18
+ /***/ "./src/index.ts":
19
+ /*!**********************!*\
20
+ !*** ./src/index.ts ***!
21
+ \**********************/
22
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
23
+
24
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _json__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./json */ \"./src/json.ts\");\n// 使用命名导出替代默认导出\n\nvar easyutilssdk = {\n json: _json__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (easyutilssdk);\n\n\n//# sourceURL=webpack://easyutilssdk/./src/index.ts?");
25
+
26
+ /***/ }),
27
+
28
+ /***/ "./src/json.ts":
29
+ /*!*********************!*\
30
+ !*** ./src/json.ts ***!
31
+ \*********************/
32
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
33
+
34
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/**\n * 对JSON对象按照key进行升序或者降序排序\n * @param obj JSON对象\n * @param SortOptions 排序参数:sortType为排序方式,asc升序,desc降序,默认asc\n * @returns 排序之后的JSON对象\n */\nvar sortObjectKeys = function (obj, _a) {\n var _b = _a === void 0 ? {} : _a, _c = _b.sortType, sortType = _c === void 0 ? 'asc' : _c;\n if (typeof obj !== 'object' || obj === null) {\n return obj;\n }\n if (Array.isArray(obj)) {\n return obj.map(function (item) { return sortObjectKeys(item, { sortType: sortType }); });\n }\n return Object.keys(obj)\n .sort(function (a, b) {\n var res = sortType === 'desc'\n ? b.toLowerCase().localeCompare(a.toLowerCase())\n : a.toLowerCase().localeCompare(b.toLowerCase());\n return res;\n })\n .reduce(function (acc, key) {\n acc[key] = sortObjectKeys(obj[key], { sortType: sortType });\n return acc;\n }, {});\n};\n/**\n * 将JSON字符串格式化并按照key进行排序\n * @param jsonString 原始JSON字符串\n * @param SortOptions 排序参数:sortType为排序方式,asc升序,desc降序,默认asc\n * @returns 格式化之后的JSON字符串\n */\nvar sortJson = function (jsonString, _a) {\n var _b = _a === void 0 ? {} : _a, _c = _b.sortType, sortType = _c === void 0 ? 'asc' : _c;\n try {\n var parsed = JSON.parse(jsonString);\n var sortedParsed = sortObjectKeys(parsed, { sortType: sortType });\n return JSON.stringify(sortedParsed, null, 2);\n }\n catch (e) {\n console.error('Failed to parse JSON string:', e);\n return jsonString; // Return original string if parsing fails\n }\n};\nvar jsonUtils = {\n sortObjectKeys: sortObjectKeys,\n sortJson: sortJson\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (jsonUtils);\n\n\n//# sourceURL=webpack://easyutilssdk/./src/json.ts?");
35
+
36
+ /***/ })
37
+
38
+ /******/ });
39
+ /************************************************************************/
40
+ /******/ // The module cache
41
+ /******/ var __webpack_module_cache__ = {};
42
+ /******/
43
+ /******/ // The require function
44
+ /******/ function __webpack_require__(moduleId) {
45
+ /******/ // Check if module is in cache
46
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
47
+ /******/ if (cachedModule !== undefined) {
48
+ /******/ return cachedModule.exports;
49
+ /******/ }
50
+ /******/ // Create a new module (and put it into the cache)
51
+ /******/ var module = __webpack_module_cache__[moduleId] = {
52
+ /******/ // no module.id needed
53
+ /******/ // no module.loaded needed
54
+ /******/ exports: {}
55
+ /******/ };
56
+ /******/
57
+ /******/ // Execute the module function
58
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
59
+ /******/
60
+ /******/ // Return the exports of the module
61
+ /******/ return module.exports;
62
+ /******/ }
63
+ /******/
64
+ /************************************************************************/
65
+ /******/ /* webpack/runtime/define property getters */
66
+ /******/ (() => {
67
+ /******/ // define getter functions for harmony exports
68
+ /******/ __webpack_require__.d = (exports, definition) => {
69
+ /******/ for(var key in definition) {
70
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
71
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
72
+ /******/ }
73
+ /******/ }
74
+ /******/ };
75
+ /******/ })();
76
+ /******/
77
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
78
+ /******/ (() => {
79
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
80
+ /******/ })();
81
+ /******/
82
+ /******/ /* webpack/runtime/make namespace object */
83
+ /******/ (() => {
84
+ /******/ // define __esModule on exports
85
+ /******/ __webpack_require__.r = (exports) => {
86
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
87
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
88
+ /******/ }
89
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
90
+ /******/ };
91
+ /******/ })();
92
+ /******/
93
+ /************************************************************************/
94
+ /******/
95
+ /******/ // startup
96
+ /******/ // Load entry module and return exports
97
+ /******/ // This entry module can't be inlined because the eval devtool is used.
98
+ /******/ var __webpack_exports__ = __webpack_require__("./src/index.ts");
99
+ /******/ const __webpack_exports__default = __webpack_exports__["default"];
100
+ /******/ export { __webpack_exports__default as default };
101
+ /******/
package/dist/yyds.d.ts ADDED
File without changes
package/index.html ADDED
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Webpack App</title>
6
+ </head>
7
+ <body>
8
+ <h1>Hello world!</h1>
9
+ <h2>Tip: Check your console</h2>
10
+ </body>
11
+
12
+ </html>
package/package.json CHANGED
@@ -1,55 +1,36 @@
1
1
  {
2
- "version": "0.1.0",
2
+ "name": "easyutilssdk",
3
+ "version": "0.1.2",
4
+ "main": "dist/node/index.js",
5
+ "browser": "dist/web/index.js",
6
+ "author": "liuyk",
3
7
  "license": "MIT",
4
- "main": "dist/index.js",
5
- "typings": "dist/index.d.ts",
6
- "files": [
7
- "dist",
8
- "src"
9
- ],
10
- "engines": {
11
- "node": ">=10"
12
- },
13
8
  "scripts": {
14
- "start": "tsdx watch",
15
- "build": "tsdx build",
16
- "test": "tsdx test",
17
- "lint": "tsdx lint",
18
- "prepare": "tsdx build",
19
- "size": "size-limit",
20
- "analyze": "size-limit --why"
21
- },
22
- "peerDependencies": {},
23
- "husky": {
24
- "hooks": {
25
- "pre-commit": "tsdx lint"
26
- }
9
+ "prepublishOnly": "npm run build",
10
+ "build:web": "webpack --config webpack.web.config.js",
11
+ "build:node": "webpack --config webpack.node.config.js",
12
+ "build": "npm run build:web && npm run build:node",
13
+ "watch": "webpack --watch",
14
+ "serve": "webpack serve"
27
15
  },
28
- "prettier": {
29
- "printWidth": 80,
30
- "semi": true,
31
- "singleQuote": true,
32
- "trailingComma": "es5"
33
- },
34
- "name": "easyutilssdk",
35
- "author": "lyk",
36
- "module": "dist/easyutilssdk.esm.js",
37
- "size-limit": [
38
- {
39
- "path": "dist/easyutilssdk.cjs.production.min.js",
40
- "limit": "10 KB"
41
- },
42
- {
43
- "path": "dist/easyutilssdk.esm.js",
44
- "limit": "10 KB"
45
- }
46
- ],
47
16
  "devDependencies": {
48
- "@size-limit/preset-small-lib": "^11.2.0",
49
- "husky": "^9.1.7",
50
- "size-limit": "^11.2.0",
51
- "tsdx": "^0.14.1",
52
- "tslib": "^2.8.1",
53
- "typescript": "^5.8.3"
54
- }
17
+ "@webpack-cli/generators": "^3.0.7",
18
+ "autoprefixer": "^10.4.21",
19
+ "css-loader": "^7.1.2",
20
+ "html-webpack-plugin": "^5.6.3",
21
+ "less": "^4.3.0",
22
+ "less-loader": "^12.2.0",
23
+ "mini-css-extract-plugin": "^2.9.2",
24
+ "postcss": "^8.5.3",
25
+ "postcss-loader": "^8.1.1",
26
+ "prettier": "^3.5.3",
27
+ "style-loader": "^4.0.0",
28
+ "ts-loader": "^9.5.2",
29
+ "typescript": "^5.8.3",
30
+ "webpack": "^5.99.7",
31
+ "webpack-cli": "^5.1.4",
32
+ "webpack-dev-server": "^5.2.1",
33
+ "webpack-node-externals": "^3.0.0"
34
+ },
35
+ "description": "easyutilssdk"
55
36
  }
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var sum = function sum(a, b) {
6
- {
7
- console.log('boop');
8
- }
9
- return a + b;
10
- };
11
-
12
- exports.sum = sum;
13
- //# sourceMappingURL=easyutilssdk.cjs.development.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"easyutilssdk.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["export const sum = (a: number, b: number) => {\n if ('development' === process.env.NODE_ENV) {\n console.log('boop');\n }\n return a + b;\n};\n"],"names":["sum","a","b","console","log"],"mappings":";;;;IAAaA,GAAG,GAAG,SAANA,GAAGA,CAAIC,CAAS,EAAEC,CAAS;EACM;IAC1CC,OAAO,CAACC,GAAG,CAAC,MAAM,CAAC;;EAErB,OAAOH,CAAC,GAAGC,CAAC;AACd;;;;"}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.sum=function(e,t){return e+t};
2
- //# sourceMappingURL=easyutilssdk.cjs.production.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"easyutilssdk.cjs.production.min.js","sources":["../src/index.ts"],"sourcesContent":["export const sum = (a: number, b: number) => {\n if ('development' === process.env.NODE_ENV) {\n console.log('boop');\n }\n return a + b;\n};\n"],"names":["a","b"],"mappings":"gFAAmB,SAACA,EAAWC,GAI7B,OAAOD,EAAIC"}
@@ -1,9 +0,0 @@
1
- var sum = function sum(a, b) {
2
- if ('development' === process.env.NODE_ENV) {
3
- console.log('boop');
4
- }
5
- return a + b;
6
- };
7
-
8
- export { sum };
9
- //# sourceMappingURL=easyutilssdk.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"easyutilssdk.esm.js","sources":["../src/index.ts"],"sourcesContent":["export const sum = (a: number, b: number) => {\n if ('development' === process.env.NODE_ENV) {\n console.log('boop');\n }\n return a + b;\n};\n"],"names":["sum","a","b","process","env","NODE_ENV","console","log"],"mappings":"IAAaA,GAAG,GAAG,SAANA,GAAGA,CAAIC,CAAS,EAAEC,CAAS;EACtC,IAAI,aAAa,KAAKC,OAAO,CAACC,GAAG,CAACC,QAAQ,EAAE;IAC1CC,OAAO,CAACC,GAAG,CAAC,MAAM,CAAC;;EAErB,OAAON,CAAC,GAAGC,CAAC;AACd;;;;"}
package/dist/index.js DELETED
@@ -1,8 +0,0 @@
1
-
2
- 'use strict'
3
-
4
- if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./easyutilssdk.cjs.production.min.js')
6
- } else {
7
- module.exports = require('./easyutilssdk.cjs.development.js')
8
- }
package/src/index.ts DELETED
@@ -1,6 +0,0 @@
1
- export const sum = (a: number, b: number) => {
2
- if ('development' === process.env.NODE_ENV) {
3
- console.log('boop');
4
- }
5
- return a + b;
6
- };