@anker-in/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/.gitkeep ADDED
File without changes
@@ -0,0 +1,27 @@
1
+
2
+ > @anker-in/lib@1.0.0 build /Users/anker/Desktop/ANKER/headless-ui/packages/lib
3
+ > tsup
4
+
5
+ CLI Building entry: src/index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v8.4.0
8
+ CLI Using tsup config: /Users/anker/Desktop/ANKER/headless-ui/packages/lib/tsup.config.ts
9
+ CLI Target: esnext
10
+ CLI Cleaning output folder
11
+ ESM Build start
12
+ CJS Build start
13
+ IIFE Build start
14
+ If you do not supply "output.name", you may not be able to access the exports of an IIFE bundle.
15
+ ESM dist/index.mjs 130.00 B
16
+ ESM dist/index.mjs.map 390.00 B
17
+ ESM ⚡️ Build success in 120ms
18
+ IIFE dist/index.global.js 198.00 B
19
+ IIFE dist/index.global.js.map 397.00 B
20
+ IIFE ⚡️ Build success in 119ms
21
+ CJS dist/index.js 143.00 B
22
+ CJS dist/index.js.map 389.00 B
23
+ CJS ⚡️ Build success in 121ms
24
+ DTS Build start
25
+ DTS ⚡️ Build success in 2189ms
26
+ DTS dist/index.d.mts 161.00 B
27
+ DTS dist/index.d.ts 161.00 B
@@ -0,0 +1,14 @@
1
+
2
+ > @anker-in/lib@1.0.0 test /Users/anker/Desktop/ANKER/headless-ui/packages/lib
3
+ > jest --passWithNoTests
4
+
5
+ PASS src/__tests__/math.test.ts
6
+ math functions
7
+ ✓ add should correctly add two numbers (2 ms)
8
+ ✓ subtract should correctly subtract two numbers
9
+
10
+ Test Suites: 1 passed, 1 total
11
+ Tests: 2 passed, 2 total
12
+ Snapshots: 0 total
13
+ Time: 2.327 s
14
+ Ran all test suites.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # 公共逻辑库
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 这是一个demo 模版
3
+ */
4
+ declare const add: (a: number, b: number) => number;
5
+ declare const subtract: (a: number, b: number) => number;
6
+
7
+ export { add, subtract };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 这是一个demo 模版
3
+ */
4
+ declare const add: (a: number, b: number) => number;
5
+ declare const subtract: (a: number, b: number) => number;
6
+
7
+ export { add, subtract };
@@ -0,0 +1,2 @@
1
+ (function(exports){'use strict';var t=(r,e)=>r+e,n=(r,e)=>r-e;exports.add=t;exports.subtract=n;return exports;})({});//# sourceMappingURL=index.global.js.map
2
+ //# sourceMappingURL=index.global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/math.ts"],"names":["add","a","b","subtract"],"mappings":"gCAGaA,IAAAA,CAAAA,CAAM,CAACC,CAAAA,CAAWC,CAAcD,GAAAA,CAAAA,CAAIC,EACpCC,CAAW,CAAA,CAACF,CAAWC,CAAAA,CAAAA,GAAcD,CAAIC,CAAAA","file":"index.global.js","sourcesContent":["/**\n * 这是一个demo 模版\n */\nexport const add = (a: number, b: number) => a + b\nexport const subtract = (a: number, b: number) => a - b\n"]}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ 'use strict';var t=(r,e)=>r+e,n=(r,e)=>r-e;exports.add=t;exports.subtract=n;//# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/math.ts"],"names":["add","a","b","subtract"],"mappings":"aAGaA,IAAAA,CAAAA,CAAM,CAACC,CAAAA,CAAWC,CAAcD,GAAAA,CAAAA,CAAIC,EACpCC,CAAW,CAAA,CAACF,CAAWC,CAAAA,CAAAA,GAAcD,CAAIC,CAAAA","file":"index.js","sourcesContent":["/**\n * 这是一个demo 模版\n */\nexport const add = (a: number, b: number) => a + b\nexport const subtract = (a: number, b: number) => a - b\n"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ var t=(r,e)=>r+e,n=(r,e)=>r-e;export{t as add,n as subtract};//# sourceMappingURL=index.mjs.map
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/math.ts"],"names":["add","a","b","subtract"],"mappings":"AAGaA,IAAAA,CAAAA,CAAM,CAACC,CAAAA,CAAWC,CAAcD,GAAAA,CAAAA,CAAIC,EACpCC,CAAW,CAAA,CAACF,CAAWC,CAAAA,CAAAA,GAAcD,CAAIC,CAAAA","file":"index.mjs","sourcesContent":["/**\n * 这是一个demo 模版\n */\nexport const add = (a: number, b: number) => a + b\nexport const subtract = (a: number, b: number) => a - b\n"]}
package/jest.config.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { JestConfigWithTsJest } from 'ts-jest'
2
+
3
+ const config: JestConfigWithTsJest = {
4
+ preset: 'ts-jest',
5
+ testEnvironment: 'jsdom', // 使用 node 环境(如果是浏览器库可改成 'jsdom')
6
+ clearMocks: true, // 每次测试后自动清除 mock
7
+ coverageDirectory: 'coverage', // 输出覆盖率报告
8
+ testMatch: ['**/__tests__/**/*.test.ts'], // 匹配测试文件路径
9
+ moduleFileExtensions: ['ts', 'js', 'json'],
10
+ }
11
+
12
+ export default config
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@anker-in/lib",
3
+ "version": "1.0.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "devDependencies": {
7
+ "@types/jest": "^29.5.12",
8
+ "jest": "^29.0.0",
9
+ "ts-jest": "^29.2.6",
10
+ "tsup": "^8.4.0",
11
+ "typescript": "^5.0.0"
12
+ },
13
+ "scripts": {
14
+ "dev": "tsup --watch",
15
+ "build": "tsup",
16
+ "test": "jest --passWithNoTests",
17
+ "test:watch": "jest --watch",
18
+ "coverage": "jest --coverage",
19
+ "clean": "rm -rf .turbo node_modules dist"
20
+ }
21
+ }
@@ -0,0 +1,15 @@
1
+ import { add, subtract } from '../math'
2
+
3
+ describe('math functions', () => {
4
+ test('add should correctly add two numbers', () => {
5
+ expect(add(2, 3)).toBe(5)
6
+ expect(add(-1, -1)).toBe(-2)
7
+ expect(add(0, 5)).toBe(5)
8
+ })
9
+
10
+ test('subtract should correctly subtract two numbers', () => {
11
+ expect(subtract(5, 3)).toBe(2)
12
+ expect(subtract(0, 5)).toBe(-5)
13
+ expect(subtract(-1, -1)).toBe(0)
14
+ })
15
+ })
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './math'
package/src/math.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 这是一个demo 模版
3
+ */
4
+ export const add = (a: number, b: number) => a + b
5
+ export const subtract = (a: number, b: number) => a - b
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "dist",
4
+ "target": "esnext",
5
+ "module": "esnext",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "sourceMap": true,
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true
12
+ },
13
+ "include": ["src"],
14
+ "exclude": ["node_modules", "dist"]
15
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { defineConfig } from 'tsup'
2
+
3
+ export default defineConfig({
4
+ entry: ['src/index.ts'],
5
+ format: ['esm', 'cjs', 'iife'],
6
+ dts: true, // 生成 .d.ts 文件
7
+ splitting: true,
8
+ sourcemap: true,
9
+ clean: true,
10
+ minify: true,
11
+ treeshake: true,
12
+ outDir: 'dist',
13
+ platform: 'browser',
14
+ target: 'esnext',
15
+ })