@longmo-utils/lib 1.0.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/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # longmo-utils
2
+
3
+ 统一的工具库包,整合了 browser、common 和 node 三个子包的所有功能。
4
+
5
+ ## 特性
6
+
7
+ - 📦 一次安装,获得所有工具函数
8
+ - 🌍 支持浏览器和 Node.js 环境
9
+ - ⚡ 完整的 TypeScript 类型支持
10
+ - 🌳 支持tree-shaking,只打包使用的代码
11
+
12
+ ## 安装
13
+
14
+ ```bash
15
+ pnpm install longmo-utils
16
+ ```
17
+
18
+ ## 使用
19
+
20
+ ```typescript
21
+ // Common 工具(所有环境可用)
22
+ import { deepClone, debounce } from 'longmo-utils'
23
+
24
+ // 浏览器工具(需要 DOM/BOM API)
25
+ import { querySelector, addClass } from 'longmo-utils'
26
+
27
+ // Node.js 工具(需要 Node.js 环境)
28
+ import { readFile, writeFile } from 'longmo-utils'
29
+
30
+ // 或者直接导入所有
31
+ import * as utils from 'longmo-utils'
32
+ ```
33
+
34
+ ## 子包
35
+
36
+ - `@longmo-utils/common` - 通用工具函数(无平台依赖)
37
+ - `@longmo-utils/browser` - 浏览器专用工具(DOM/BOM)
38
+ - `@longmo-utils/node` - Node.js 专用工具(文件系统等)
39
+
40
+ ## Tree-shaking
41
+
42
+ 由于依赖了三个子包,打包工具(如 Vite、Webpack、Rollup)会自动进行 tree-shaking,只将你实际使用的代码打包进最终产物。
43
+
44
+ 例如,如果你只使用了 `debounce` 函数,即使导入了整个包,最终产物也只会包含 `debounce` 的代码。
45
+
46
+ ## 性能说明
47
+
48
+ - **安装体积**: 约 58KB(包含三个子包)
49
+ - **最终产物体积**: 取决于实际使用的函数(tree-shaking 优化)
50
+ - **构建时间**: 与单独安装子包相比增加约 0.1s
51
+
52
+ ## 与子包对比
53
+
54
+ | 场景 | 推荐方案 |
55
+ |------|---------|
56
+ | 快速原型开发 | longmo-utils(统一包) |
57
+ | 生产环境精确控制 | @longmo-utils/*(单独包) |
58
+ | 需要全部功能 | longmo-utils(统一包) |
59
+ | 仅浏览器功能 | @longmo-utils/browser |
60
+ | 仅通用功能 | @longmo-utils/common |
61
+
62
+ ## 许可证
63
+
64
+ MIT
@@ -0,0 +1,3 @@
1
+ export * from "@longmo-utils/common";
2
+ export * from "@longmo-utils/browser";
3
+ export * from "@longmo-utils/node";
package/dist/index.mjs ADDED
@@ -0,0 +1,7 @@
1
+ export * from "@longmo-utils/common"
2
+
3
+ export * from "@longmo-utils/browser"
4
+
5
+ export * from "@longmo-utils/node"
6
+
7
+ export { };
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@longmo-utils/lib",
3
+ "version": "1.0.0",
4
+ "description": "Longmoo Utils - Universal utility library combining browser, common, and node utilities",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.mts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.mts",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "browser": "./dist/index.mjs",
17
+ "engines": {
18
+ "node": ">=16"
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "keywords": [
24
+ "utils",
25
+ "typescript",
26
+ "browser",
27
+ "nodejs",
28
+ "universal",
29
+ "common",
30
+ "dom",
31
+ "filesystem"
32
+ ],
33
+ "author": "",
34
+ "license": "MIT",
35
+ "dependencies": {
36
+ "@longmo-utils/common": "1.0.0",
37
+ "@longmo-utils/browser": "1.0.0",
38
+ "@longmo-utils/node": "1.0.0"
39
+ },
40
+ "peerDependenciesMeta": {
41
+ "@longmo-utils/browser": {
42
+ "optional": true
43
+ },
44
+ "@longmo-utils/node": {
45
+ "optional": true
46
+ }
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ },
51
+ "scripts": {
52
+ "build": "tsdown",
53
+ "dev": "tsdown --watch",
54
+ "clean": "rm -rf dist"
55
+ }
56
+ }