@posx/core 5.5.329 → 5.5.331
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/CLAUDE.md +23 -23
- package/LICENSE +21 -21
- package/README.md +85 -85
- package/build/index.d.ts +3 -0
- package/build/index.js +3 -0
- package/jest.config.cjs +36 -36
- package/jest.setup.cjs +80 -80
- package/package.json +1 -1
- package/package.publish.json +120 -120
- package/tsdown.config.ts +18 -18
- package/vite.config.ts +86 -86
package/CLAUDE.md
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
# Claude AI Development Guidelines
|
|
2
|
-
|
|
3
|
-
## Rules you have to follow strictly
|
|
4
|
-
|
|
5
|
-
- You are top-notch programmer who always write simplest code to achieve the ideal result
|
|
6
|
-
- you are one liner engineers and we believe "The Great Tao is Simple", so try to keep changes small and focused
|
|
7
|
-
- keep the changes as minimal as possible
|
|
8
|
-
- if or else has one line of code, then { } are not needed and it should be wrote into same line
|
|
9
|
-
- DO NOT write uncessary comment do not make newlines within a function and try to make the code compact
|
|
10
|
-
- All crucial code should have proper explanation in English
|
|
11
|
-
- Keep the simplifications as small and focused within the function or scope.
|
|
12
|
-
- Do not overhaul the whole file or codebase which is irrelevant to the current task.
|
|
13
|
-
|
|
14
|
-
## Best Practices for AI-Assisted Development
|
|
15
|
-
|
|
16
|
-
1. **在开始编码前先充分讨论和规划架构,确保理解用户的真实需求和使用场景,避免过度设计。**
|
|
17
|
-
|
|
18
|
-
2. **不要急于提交代码,应该等待用户明确指示后再进行 commit 和 push 操作。**
|
|
19
|
-
|
|
20
|
-
3. **优先选择简洁的实现方式(如函数导出而非类),并删除冗余的中间层方法以保持代码清晰。**
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
1
|
+
# Claude AI Development Guidelines
|
|
2
|
+
|
|
3
|
+
## Rules you have to follow strictly
|
|
4
|
+
|
|
5
|
+
- You are top-notch programmer who always write simplest code to achieve the ideal result
|
|
6
|
+
- you are one liner engineers and we believe "The Great Tao is Simple", so try to keep changes small and focused
|
|
7
|
+
- keep the changes as minimal as possible
|
|
8
|
+
- if or else has one line of code, then { } are not needed and it should be wrote into same line
|
|
9
|
+
- DO NOT write uncessary comment do not make newlines within a function and try to make the code compact
|
|
10
|
+
- All crucial code should have proper explanation in English
|
|
11
|
+
- Keep the simplifications as small and focused within the function or scope.
|
|
12
|
+
- Do not overhaul the whole file or codebase which is irrelevant to the current task.
|
|
13
|
+
|
|
14
|
+
## Best Practices for AI-Assisted Development
|
|
15
|
+
|
|
16
|
+
1. **在开始编码前先充分讨论和规划架构,确保理解用户的真实需求和使用场景,避免过度设计。**
|
|
17
|
+
|
|
18
|
+
2. **不要急于提交代码,应该等待用户明确指示后再进行 commit 和 push 操作。**
|
|
19
|
+
|
|
20
|
+
3. **优先选择简洁的实现方式(如函数导出而非类),并删除冗余的中间层方法以保持代码清晰。**
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
24
|
*This file contains guidelines learned from AI-human collaboration to improve development efficiency and code quality.*
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2019 Francisco Hodge
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Francisco Hodge
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
# 第一阶段
|
|
2
|
-
- 1. 创建,更新,删除都是通过 -> Http API
|
|
3
|
-
- 2. 读取是通过本地数据库 -> 本地, (例外:订单从云端读取)
|
|
4
|
-
|
|
5
|
-
# 第二阶段 (单机版)
|
|
6
|
-
1. 创建,更新,删除,读取都通过本地数据库,然后进行数据和云端同步(Web Worker)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<div align="center">
|
|
19
|
-
<img align="center" width="230" src="https://i.imgur.com/iHgtvmg.png" />
|
|
20
|
-
<h2>Typescript Library Boilerplate Basic</h2>
|
|
21
|
-
<blockquote>Minimal Library Starter Kit for your Typescript projects</blockquote>
|
|
22
|
-
|
|
23
|
-
<a href="https://www.npmjs.com/package/@hodgef/ts-library-boilerplate-basic"><img src="https://badgen.net/npm/v/@hodgef/ts-library-boilerplate-basic?color=blue" alt="npm version"></a> <a href="https://github.com/hodgef/ts-library-boilerplate"><img src="https://img.shields.io/github/last-commit/hodgef/ts-library-boilerplate" alt="latest commit"></a> <a href="https://github.com/hodgef/ts-library-boilerplate-basic/actions"><img alt="Build Status" src="https://github.com/hodgef/ts-library-boilerplate-basic/workflows/Build/badge.svg?color=green" /></a> <a href="https://github.com/hodgef/ts-library-boilerplate-basic/actions"> <img alt="Publish Status" src="https://github.com/hodgef/ts-library-boilerplate-basic/workflows/Publish/badge.svg?color=green" /></a>
|
|
24
|
-
|
|
25
|
-
<strong>For a plain Javascript alternative, check out [js-library-boilerplate-basic](https://github.com/hodgef/js-library-boilerplate-basic).</strong>
|
|
26
|
-
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
## ⭐️ Features
|
|
30
|
-
|
|
31
|
-
- Webpack 5
|
|
32
|
-
- Babel 7
|
|
33
|
-
- Hot reloading (`npm start`)
|
|
34
|
-
- Automatic Types file generation (index.d.ts)
|
|
35
|
-
- UMD exports, so your library works everywhere.
|
|
36
|
-
- Jest unit testing
|
|
37
|
-
- Customizable file headers for your build [(Example 1)](https://github.com/hodgef/ts-library-boilerplate-basic/blob/master/build/index.js) [(Example2)](https://github.com/hodgef/ts-library-boilerplate-basic/blob/master/build/css/index.css)
|
|
38
|
-
- Daily [dependabot](https://dependabot.com) dependency updates
|
|
39
|
-
|
|
40
|
-
## 📦 Getting Started
|
|
41
|
-
|
|
42
|
-
```
|
|
43
|
-
git clone https://github.com/hodgef/ts-library-boilerplate-basic.git myLibrary
|
|
44
|
-
npm install
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## 💎 Customization
|
|
48
|
-
|
|
49
|
-
> Before shipping, make sure to:
|
|
50
|
-
|
|
51
|
-
1. Edit `LICENSE` file
|
|
52
|
-
2. Edit `package.json` information (These will be used to generate the headers for your built files)
|
|
53
|
-
3. Edit `library: "MyLibrary"` with your library's export name in `./webpack.config.js`
|
|
54
|
-
|
|
55
|
-
## 🚀 Deployment
|
|
56
|
-
|
|
57
|
-
1. `npm publish`
|
|
58
|
-
2. Your users can include your library as usual
|
|
59
|
-
|
|
60
|
-
### npm
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
import MyLibrary from 'my-library';
|
|
64
|
-
const libraryInstance = new MyLibrary();
|
|
65
|
-
...
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### self-host/cdn
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
<script src="build/index.js"></script>
|
|
72
|
-
|
|
73
|
-
const MyLibrary = window.MyLibrary.default;
|
|
74
|
-
const libraryInstance = new MyLibrary();
|
|
75
|
-
...
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## ✅ Libraries built with this boilerplate
|
|
79
|
-
|
|
80
|
-
> Made a library using this starter kit? Share it here by [submitting a pull request](https://github.com/hodgef/ts-library-boilerplate-basic/pulls)!
|
|
81
|
-
|
|
82
|
-
- [simple-keyboard](https://github.com/hodgef/simple-keyboard) - Javascript Virtual Keyboard
|
|
83
|
-
- [react-simple-keyboard](https://github.com/hodgef/react-simple-keyboard) - React Virtual Keyboard
|
|
84
|
-
- [simple-keyboard-layouts](https://github.com/hodgef/simple-keyboard-layouts) - Keyboard layouts for simple-keyboard
|
|
85
|
-
- [atlas-monaco](https://github.com/datdao/atlas-monaco) - AtlasHCL for monaco editor
|
|
1
|
+
# 第一阶段
|
|
2
|
+
- 1. 创建,更新,删除都是通过 -> Http API
|
|
3
|
+
- 2. 读取是通过本地数据库 -> 本地, (例外:订单从云端读取)
|
|
4
|
+
|
|
5
|
+
# 第二阶段 (单机版)
|
|
6
|
+
1. 创建,更新,删除,读取都通过本地数据库,然后进行数据和云端同步(Web Worker)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
<div align="center">
|
|
19
|
+
<img align="center" width="230" src="https://i.imgur.com/iHgtvmg.png" />
|
|
20
|
+
<h2>Typescript Library Boilerplate Basic</h2>
|
|
21
|
+
<blockquote>Minimal Library Starter Kit for your Typescript projects</blockquote>
|
|
22
|
+
|
|
23
|
+
<a href="https://www.npmjs.com/package/@hodgef/ts-library-boilerplate-basic"><img src="https://badgen.net/npm/v/@hodgef/ts-library-boilerplate-basic?color=blue" alt="npm version"></a> <a href="https://github.com/hodgef/ts-library-boilerplate"><img src="https://img.shields.io/github/last-commit/hodgef/ts-library-boilerplate" alt="latest commit"></a> <a href="https://github.com/hodgef/ts-library-boilerplate-basic/actions"><img alt="Build Status" src="https://github.com/hodgef/ts-library-boilerplate-basic/workflows/Build/badge.svg?color=green" /></a> <a href="https://github.com/hodgef/ts-library-boilerplate-basic/actions"> <img alt="Publish Status" src="https://github.com/hodgef/ts-library-boilerplate-basic/workflows/Publish/badge.svg?color=green" /></a>
|
|
24
|
+
|
|
25
|
+
<strong>For a plain Javascript alternative, check out [js-library-boilerplate-basic](https://github.com/hodgef/js-library-boilerplate-basic).</strong>
|
|
26
|
+
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
## ⭐️ Features
|
|
30
|
+
|
|
31
|
+
- Webpack 5
|
|
32
|
+
- Babel 7
|
|
33
|
+
- Hot reloading (`npm start`)
|
|
34
|
+
- Automatic Types file generation (index.d.ts)
|
|
35
|
+
- UMD exports, so your library works everywhere.
|
|
36
|
+
- Jest unit testing
|
|
37
|
+
- Customizable file headers for your build [(Example 1)](https://github.com/hodgef/ts-library-boilerplate-basic/blob/master/build/index.js) [(Example2)](https://github.com/hodgef/ts-library-boilerplate-basic/blob/master/build/css/index.css)
|
|
38
|
+
- Daily [dependabot](https://dependabot.com) dependency updates
|
|
39
|
+
|
|
40
|
+
## 📦 Getting Started
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
git clone https://github.com/hodgef/ts-library-boilerplate-basic.git myLibrary
|
|
44
|
+
npm install
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 💎 Customization
|
|
48
|
+
|
|
49
|
+
> Before shipping, make sure to:
|
|
50
|
+
|
|
51
|
+
1. Edit `LICENSE` file
|
|
52
|
+
2. Edit `package.json` information (These will be used to generate the headers for your built files)
|
|
53
|
+
3. Edit `library: "MyLibrary"` with your library's export name in `./webpack.config.js`
|
|
54
|
+
|
|
55
|
+
## 🚀 Deployment
|
|
56
|
+
|
|
57
|
+
1. `npm publish`
|
|
58
|
+
2. Your users can include your library as usual
|
|
59
|
+
|
|
60
|
+
### npm
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
import MyLibrary from 'my-library';
|
|
64
|
+
const libraryInstance = new MyLibrary();
|
|
65
|
+
...
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### self-host/cdn
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
<script src="build/index.js"></script>
|
|
72
|
+
|
|
73
|
+
const MyLibrary = window.MyLibrary.default;
|
|
74
|
+
const libraryInstance = new MyLibrary();
|
|
75
|
+
...
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## ✅ Libraries built with this boilerplate
|
|
79
|
+
|
|
80
|
+
> Made a library using this starter kit? Share it here by [submitting a pull request](https://github.com/hodgef/ts-library-boilerplate-basic/pulls)!
|
|
81
|
+
|
|
82
|
+
- [simple-keyboard](https://github.com/hodgef/simple-keyboard) - Javascript Virtual Keyboard
|
|
83
|
+
- [react-simple-keyboard](https://github.com/hodgef/react-simple-keyboard) - React Virtual Keyboard
|
|
84
|
+
- [simple-keyboard-layouts](https://github.com/hodgef/simple-keyboard-layouts) - Keyboard layouts for simple-keyboard
|
|
85
|
+
- [atlas-monaco](https://github.com/datdao/atlas-monaco) - AtlasHCL for monaco editor
|
package/build/index.d.ts
CHANGED
|
@@ -3526,9 +3526,12 @@ declare class KdsConfig implements IKdsConfig {
|
|
|
3526
3526
|
interface ILabelConfig {
|
|
3527
3527
|
/** Flag for printing the label */
|
|
3528
3528
|
print: boolean;
|
|
3529
|
+
/** Convert text to raster image for compatibility (e.g., vscii) */
|
|
3530
|
+
text_to_raster: boolean;
|
|
3529
3531
|
}
|
|
3530
3532
|
declare class LabelConfig implements ILabelConfig {
|
|
3531
3533
|
print: boolean;
|
|
3534
|
+
text_to_raster: boolean;
|
|
3532
3535
|
constructor();
|
|
3533
3536
|
}
|
|
3534
3537
|
interface IOrderConfig {
|
package/build/index.js
CHANGED
|
@@ -977,6 +977,7 @@ var EscPosPrinter = class {
|
|
|
977
977
|
0
|
|
978
978
|
]);
|
|
979
979
|
} else if (template.codepage && Object.values(Codepages).includes(template.codepage)) encoder.codepage(template.codepage);
|
|
980
|
+
else encoder.codepage(Codepages.SimplifiedChinese);
|
|
980
981
|
for (const printItem of template.items) {
|
|
981
982
|
if (!printItem) throw new Error("Item is undefined or null");
|
|
982
983
|
switch (printItem.style) {
|
|
@@ -2047,6 +2048,7 @@ var KdsConfig = class {
|
|
|
2047
2048
|
var LabelConfig = class {
|
|
2048
2049
|
constructor() {
|
|
2049
2050
|
_defineProperty(this, "print", false);
|
|
2051
|
+
_defineProperty(this, "text_to_raster", false);
|
|
2050
2052
|
}
|
|
2051
2053
|
};
|
|
2052
2054
|
var OrderConfig = class {
|
|
@@ -5282,6 +5284,7 @@ var PrintTemplateService = class extends AppRemoteService {
|
|
|
5282
5284
|
const templateData = new TemplateData();
|
|
5283
5285
|
templateData.report_data = reportData;
|
|
5284
5286
|
templateData.config = config;
|
|
5287
|
+
printCommand.codepage = template.codepage || Codepages.SimplifiedChinese;
|
|
5285
5288
|
printCommand.items.push(...await this.renderPrintCommand(template.header, templateData));
|
|
5286
5289
|
printCommand.items.push(...await this.renderPrintCommand(template.body, templateData));
|
|
5287
5290
|
printCommand.items.push(...await this.renderPrintCommand(template.footer, templateData));
|
package/jest.config.cjs
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
// jest.config.js
|
|
2
|
-
module.exports = {
|
|
3
|
-
preset: 'ts-jest',
|
|
4
|
-
testEnvironment: 'jsdom',
|
|
5
|
-
setupFilesAfterEnv: ['<rootDir>/jest.setup.cjs'],
|
|
6
|
-
transform: {
|
|
7
|
-
'^.+\\.ts$': ['ts-jest', {
|
|
8
|
-
tsconfig: {
|
|
9
|
-
module: 'commonjs',
|
|
10
|
-
esModuleInterop: true,
|
|
11
|
-
}
|
|
12
|
-
}],
|
|
13
|
-
'^.+\\.(mjs|js)$': ['ts-jest', {
|
|
14
|
-
tsconfig: {
|
|
15
|
-
allowJs: true,
|
|
16
|
-
module: 'commonjs',
|
|
17
|
-
esModuleInterop: true,
|
|
18
|
-
}
|
|
19
|
-
}]
|
|
20
|
-
},
|
|
21
|
-
transformIgnorePatterns: [
|
|
22
|
-
'node_modules/(?!(.pnpm|nanoid|@litepos|dexie)/)', // Transform ESM packages
|
|
23
|
-
],
|
|
24
|
-
testMatch: [
|
|
25
|
-
'<rootDir>/src/test/**/*.test.ts'
|
|
26
|
-
],
|
|
27
|
-
moduleNameMapper: {
|
|
28
|
-
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/scripts/testMock.cjs',
|
|
29
|
-
'\\.(css|less)$': '<rootDir>/scripts/testMock.cjs',
|
|
30
|
-
'^nanoid$': '<rootDir>/src/test/__mocks__/nanoid.js',
|
|
31
|
-
'^dexie$': '<rootDir>/src/test/__mocks__/dexie.js',
|
|
32
|
-
'^@awesome-cordova-plugins/network-interface$': '<rootDir>/src/test/__mocks__/@awesome-cordova-plugins/network-interface.js',
|
|
33
|
-
'^canvas$': '<rootDir>/scripts/testMock.cjs'
|
|
34
|
-
},
|
|
35
|
-
moduleFileExtensions: ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'],
|
|
36
|
-
};
|
|
1
|
+
// jest.config.js
|
|
2
|
+
module.exports = {
|
|
3
|
+
preset: 'ts-jest',
|
|
4
|
+
testEnvironment: 'jsdom',
|
|
5
|
+
setupFilesAfterEnv: ['<rootDir>/jest.setup.cjs'],
|
|
6
|
+
transform: {
|
|
7
|
+
'^.+\\.ts$': ['ts-jest', {
|
|
8
|
+
tsconfig: {
|
|
9
|
+
module: 'commonjs',
|
|
10
|
+
esModuleInterop: true,
|
|
11
|
+
}
|
|
12
|
+
}],
|
|
13
|
+
'^.+\\.(mjs|js)$': ['ts-jest', {
|
|
14
|
+
tsconfig: {
|
|
15
|
+
allowJs: true,
|
|
16
|
+
module: 'commonjs',
|
|
17
|
+
esModuleInterop: true,
|
|
18
|
+
}
|
|
19
|
+
}]
|
|
20
|
+
},
|
|
21
|
+
transformIgnorePatterns: [
|
|
22
|
+
'node_modules/(?!(.pnpm|nanoid|@litepos|dexie)/)', // Transform ESM packages
|
|
23
|
+
],
|
|
24
|
+
testMatch: [
|
|
25
|
+
'<rootDir>/src/test/**/*.test.ts'
|
|
26
|
+
],
|
|
27
|
+
moduleNameMapper: {
|
|
28
|
+
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/scripts/testMock.cjs',
|
|
29
|
+
'\\.(css|less)$': '<rootDir>/scripts/testMock.cjs',
|
|
30
|
+
'^nanoid$': '<rootDir>/src/test/__mocks__/nanoid.js',
|
|
31
|
+
'^dexie$': '<rootDir>/src/test/__mocks__/dexie.js',
|
|
32
|
+
'^@awesome-cordova-plugins/network-interface$': '<rootDir>/src/test/__mocks__/@awesome-cordova-plugins/network-interface.js',
|
|
33
|
+
'^canvas$': '<rootDir>/scripts/testMock.cjs'
|
|
34
|
+
},
|
|
35
|
+
moduleFileExtensions: ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'],
|
|
36
|
+
};
|
package/jest.setup.cjs
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
// Jest setup file to polyfill File and Blob APIs
|
|
2
|
-
// This ensures consistent behavior across different Node.js versions and test environments
|
|
3
|
-
|
|
4
|
-
// Polyfill Blob.text() if not available
|
|
5
|
-
if (typeof Blob !== 'undefined' && !Blob.prototype.text) {
|
|
6
|
-
Blob.prototype.text = async function() {
|
|
7
|
-
const reader = new FileReader();
|
|
8
|
-
return new Promise((resolve, reject) => {
|
|
9
|
-
reader.onload = () => resolve(reader.result);
|
|
10
|
-
reader.onerror = reject;
|
|
11
|
-
reader.readAsText(this);
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Polyfill FileReader if not available
|
|
17
|
-
if (typeof FileReader === 'undefined') {
|
|
18
|
-
global.FileReader = class FileReader {
|
|
19
|
-
result = null;
|
|
20
|
-
error = null;
|
|
21
|
-
onload = null;
|
|
22
|
-
onerror = null;
|
|
23
|
-
|
|
24
|
-
readAsText(blob) {
|
|
25
|
-
try {
|
|
26
|
-
// For our polyfilled Blob
|
|
27
|
-
if (blob.parts) {
|
|
28
|
-
this.result = blob.parts.join('');
|
|
29
|
-
} else if (typeof blob === 'string') {
|
|
30
|
-
this.result = blob;
|
|
31
|
-
} else {
|
|
32
|
-
this.result = String(blob);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (this.onload) {
|
|
36
|
-
setTimeout(() => this.onload({ target: this }), 0);
|
|
37
|
-
}
|
|
38
|
-
} catch (err) {
|
|
39
|
-
this.error = err;
|
|
40
|
-
if (this.onerror) {
|
|
41
|
-
setTimeout(() => this.onerror({ target: this }), 0);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Polyfill Blob if not available (for Node.js < 18)
|
|
49
|
-
if (typeof Blob === 'undefined') {
|
|
50
|
-
global.Blob = class Blob {
|
|
51
|
-
constructor(parts = [], options = {}) {
|
|
52
|
-
this.parts = parts;
|
|
53
|
-
this.type = options.type || '';
|
|
54
|
-
this.size = parts.reduce((acc, part) => {
|
|
55
|
-
return acc + (typeof part === 'string' ? part.length : part.length || 0);
|
|
56
|
-
}, 0);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async text() {
|
|
60
|
-
return this.parts.join('');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async arrayBuffer() {
|
|
64
|
-
const text = await this.text();
|
|
65
|
-
const buffer = Buffer.from(text);
|
|
66
|
-
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Polyfill File if not available (for Node.js < 18)
|
|
72
|
-
if (typeof File === 'undefined') {
|
|
73
|
-
global.File = class File extends global.Blob {
|
|
74
|
-
constructor(bits, name, options = {}) {
|
|
75
|
-
super(bits, options);
|
|
76
|
-
this.name = name;
|
|
77
|
-
this.lastModified = options.lastModified || Date.now();
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
1
|
+
// Jest setup file to polyfill File and Blob APIs
|
|
2
|
+
// This ensures consistent behavior across different Node.js versions and test environments
|
|
3
|
+
|
|
4
|
+
// Polyfill Blob.text() if not available
|
|
5
|
+
if (typeof Blob !== 'undefined' && !Blob.prototype.text) {
|
|
6
|
+
Blob.prototype.text = async function() {
|
|
7
|
+
const reader = new FileReader();
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
reader.onload = () => resolve(reader.result);
|
|
10
|
+
reader.onerror = reject;
|
|
11
|
+
reader.readAsText(this);
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Polyfill FileReader if not available
|
|
17
|
+
if (typeof FileReader === 'undefined') {
|
|
18
|
+
global.FileReader = class FileReader {
|
|
19
|
+
result = null;
|
|
20
|
+
error = null;
|
|
21
|
+
onload = null;
|
|
22
|
+
onerror = null;
|
|
23
|
+
|
|
24
|
+
readAsText(blob) {
|
|
25
|
+
try {
|
|
26
|
+
// For our polyfilled Blob
|
|
27
|
+
if (blob.parts) {
|
|
28
|
+
this.result = blob.parts.join('');
|
|
29
|
+
} else if (typeof blob === 'string') {
|
|
30
|
+
this.result = blob;
|
|
31
|
+
} else {
|
|
32
|
+
this.result = String(blob);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (this.onload) {
|
|
36
|
+
setTimeout(() => this.onload({ target: this }), 0);
|
|
37
|
+
}
|
|
38
|
+
} catch (err) {
|
|
39
|
+
this.error = err;
|
|
40
|
+
if (this.onerror) {
|
|
41
|
+
setTimeout(() => this.onerror({ target: this }), 0);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Polyfill Blob if not available (for Node.js < 18)
|
|
49
|
+
if (typeof Blob === 'undefined') {
|
|
50
|
+
global.Blob = class Blob {
|
|
51
|
+
constructor(parts = [], options = {}) {
|
|
52
|
+
this.parts = parts;
|
|
53
|
+
this.type = options.type || '';
|
|
54
|
+
this.size = parts.reduce((acc, part) => {
|
|
55
|
+
return acc + (typeof part === 'string' ? part.length : part.length || 0);
|
|
56
|
+
}, 0);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async text() {
|
|
60
|
+
return this.parts.join('');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async arrayBuffer() {
|
|
64
|
+
const text = await this.text();
|
|
65
|
+
const buffer = Buffer.from(text);
|
|
66
|
+
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Polyfill File if not available (for Node.js < 18)
|
|
72
|
+
if (typeof File === 'undefined') {
|
|
73
|
+
global.File = class File extends global.Blob {
|
|
74
|
+
constructor(bits, name, options = {}) {
|
|
75
|
+
super(bits, options);
|
|
76
|
+
this.name = name;
|
|
77
|
+
this.lastModified = options.lastModified || Date.now();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
package/package.json
CHANGED
package/package.publish.json
CHANGED
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@posx/core",
|
|
3
|
-
"version": "5.5.
|
|
4
|
-
"description": "POSX core libraries",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./build/index.js",
|
|
7
|
-
"module": "./build/index.js",
|
|
8
|
-
"types": "./build/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"import": "./build/index.js",
|
|
12
|
-
"types": "./build/index.d.ts"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"build"
|
|
17
|
-
],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"up": "node ./scripts/upload-to-s3.cjs --trace-warnings",
|
|
20
|
-
"start": "tsdown --watch",
|
|
21
|
-
"build": "tsdown",
|
|
22
|
-
"build:dts": "tsdown --dts-only",
|
|
23
|
-
"post:build": "node ./scripts/clean-build.cjs",
|
|
24
|
-
"mvm": "mv build/*.map scripts/sourcemaps/ && mv build/**/*.map scripts/sourcemaps/ && find build -name '*.map' -type f -delete",
|
|
25
|
-
"build:demo": "vite build --mode demo",
|
|
26
|
-
"test": "jest",
|
|
27
|
-
"test:watch": "jest --watch",
|
|
28
|
-
"publish": "node ./scripts/publish.cjs",
|
|
29
|
-
"p": "pnpm i && npm test && npm run up:p && npm run build && npm run post:build && npm run publish && rm -rf build",
|
|
30
|
-
"debug": "npm run build && npm run post:build",
|
|
31
|
-
"coverage": "jest --coverage",
|
|
32
|
-
"trypublish": "npm publish || true",
|
|
33
|
-
"gen:index": "node ./scriptswc/generateIndex.cjs",
|
|
34
|
-
"up:p": "npm version patch && git push",
|
|
35
|
-
"up:m": "npm version minor && git push",
|
|
36
|
-
"docs": "typedoc --out docs src --excludePrivate --exclude '**/demo/**/*' --exclude '**/*+(interface|function|enum).ts'",
|
|
37
|
-
"see": "node ./scripts/lookup-sm.cjs"
|
|
38
|
-
},
|
|
39
|
-
"repository": {
|
|
40
|
-
"type": "git"
|
|
41
|
-
},
|
|
42
|
-
"author": "Steven Lee",
|
|
43
|
-
"license": "UNLICENSED",
|
|
44
|
-
"bugs": {
|
|
45
|
-
"url": ""
|
|
46
|
-
},
|
|
47
|
-
"homepage": "",
|
|
48
|
-
"keywords": [
|
|
49
|
-
"library",
|
|
50
|
-
"starter",
|
|
51
|
-
"es6"
|
|
52
|
-
],
|
|
53
|
-
"devDependencies": {
|
|
54
|
-
"@capacitor/core": "5.4.2",
|
|
55
|
-
"@litepos/autoquery": "5.0.6",
|
|
56
|
-
"@types/bcryptjs": "2.4.6",
|
|
57
|
-
"@types/jest": "30.0.0",
|
|
58
|
-
"@types/lodash": "4.14.199",
|
|
59
|
-
"@types/node": "20.8.2",
|
|
60
|
-
"@types/uuid": "9.0.4",
|
|
61
|
-
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
62
|
-
"@typescript-eslint/parser": "^4.33.0",
|
|
63
|
-
"@vitest/coverage-v8": "^2.1.0",
|
|
64
|
-
"ajv": "8.17.1",
|
|
65
|
-
"aws-sdk": "2.1550.0",
|
|
66
|
-
"colors": "1.4.0",
|
|
67
|
-
"eslint": "^7.32.0",
|
|
68
|
-
"fs-extra": "11.1.1",
|
|
69
|
-
"glob": "10.3.10",
|
|
70
|
-
"jest": "30.2.0",
|
|
71
|
-
"jest-environment-jsdom": "30.2.0",
|
|
72
|
-
"jsdom": "27.1.0",
|
|
73
|
-
"prompt-sync": "4.2.0",
|
|
74
|
-
"rollup-plugin-obfuscator": "^1.1.0",
|
|
75
|
-
"sqlite3": "5.1.6",
|
|
76
|
-
"terser": "^5.36.0",
|
|
77
|
-
"ts-jest": "29.4.5",
|
|
78
|
-
"tsdown": "0.16.1",
|
|
79
|
-
"typedoc": "^0.26.0",
|
|
80
|
-
"typescript": "^5.6.3",
|
|
81
|
-
"vite": "^5.4.11",
|
|
82
|
-
"vite-plugin-bundle-obfuscator": "1.8.0",
|
|
83
|
-
"vite-plugin-dts": "^4.3.0",
|
|
84
|
-
"vitest": "^2.1.0"
|
|
85
|
-
},
|
|
86
|
-
"dependencies": {
|
|
87
|
-
"@awesome-cordova-plugins/core": "6.6.0",
|
|
88
|
-
"@awesome-cordova-plugins/network-interface": "6.6.0",
|
|
89
|
-
"@microsoft/signalr": "7.0.11",
|
|
90
|
-
"axios": "1.5.1",
|
|
91
|
-
"bcryptjs": "2.4.3",
|
|
92
|
-
"buffer": "6.0.3",
|
|
93
|
-
"crypto-browserify": "3.12.0",
|
|
94
|
-
"crypto-js": "4.2.0",
|
|
95
|
-
"dayjs": "1.11.10",
|
|
96
|
-
"dexie": "3.2.4",
|
|
97
|
-
"esc-pos-encoder-ionic": "1.1.3",
|
|
98
|
-
"handlebars": "4.7.8",
|
|
99
|
-
"lodash": "4.17.21",
|
|
100
|
-
"mathjs": "12.3.2",
|
|
101
|
-
"nanoid": "3.3.4",
|
|
102
|
-
"save": "2.9.0",
|
|
103
|
-
"selecttransform": "1.6.1",
|
|
104
|
-
"sockets-for-cordova": "1.0.0",
|
|
105
|
-
"stream-browserify": "3.0.0",
|
|
106
|
-
"uuid": "9.0.1",
|
|
107
|
-
"vm-browserify": "1.1.2",
|
|
108
|
-
"wcwidth": "1.0.1",
|
|
109
|
-
"zod": "3.23.8"
|
|
110
|
-
},
|
|
111
|
-
"peerDependencies": {
|
|
112
|
-
"@litepos/autoquery": "^5.0.6",
|
|
113
|
-
"rxjs": "^7.0.0"
|
|
114
|
-
},
|
|
115
|
-
"peerDependenciesMeta": {
|
|
116
|
-
"rxjs": {
|
|
117
|
-
"optional": true
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@posx/core",
|
|
3
|
+
"version": "5.5.331",
|
|
4
|
+
"description": "POSX core libraries",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./build/index.js",
|
|
7
|
+
"module": "./build/index.js",
|
|
8
|
+
"types": "./build/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./build/index.js",
|
|
12
|
+
"types": "./build/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"build"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"up": "node ./scripts/upload-to-s3.cjs --trace-warnings",
|
|
20
|
+
"start": "tsdown --watch",
|
|
21
|
+
"build": "tsdown",
|
|
22
|
+
"build:dts": "tsdown --dts-only",
|
|
23
|
+
"post:build": "node ./scripts/clean-build.cjs",
|
|
24
|
+
"mvm": "mv build/*.map scripts/sourcemaps/ && mv build/**/*.map scripts/sourcemaps/ && find build -name '*.map' -type f -delete",
|
|
25
|
+
"build:demo": "vite build --mode demo",
|
|
26
|
+
"test": "jest",
|
|
27
|
+
"test:watch": "jest --watch",
|
|
28
|
+
"publish": "node ./scripts/publish.cjs",
|
|
29
|
+
"p": "pnpm i && npm test && npm run up:p && npm run build && npm run post:build && npm run publish && rm -rf build",
|
|
30
|
+
"debug": "npm run build && npm run post:build",
|
|
31
|
+
"coverage": "jest --coverage",
|
|
32
|
+
"trypublish": "npm publish || true",
|
|
33
|
+
"gen:index": "node ./scriptswc/generateIndex.cjs",
|
|
34
|
+
"up:p": "npm version patch && git push",
|
|
35
|
+
"up:m": "npm version minor && git push",
|
|
36
|
+
"docs": "typedoc --out docs src --excludePrivate --exclude '**/demo/**/*' --exclude '**/*+(interface|function|enum).ts'",
|
|
37
|
+
"see": "node ./scripts/lookup-sm.cjs"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git"
|
|
41
|
+
},
|
|
42
|
+
"author": "Steven Lee",
|
|
43
|
+
"license": "UNLICENSED",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": ""
|
|
46
|
+
},
|
|
47
|
+
"homepage": "",
|
|
48
|
+
"keywords": [
|
|
49
|
+
"library",
|
|
50
|
+
"starter",
|
|
51
|
+
"es6"
|
|
52
|
+
],
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@capacitor/core": "5.4.2",
|
|
55
|
+
"@litepos/autoquery": "5.0.6",
|
|
56
|
+
"@types/bcryptjs": "2.4.6",
|
|
57
|
+
"@types/jest": "30.0.0",
|
|
58
|
+
"@types/lodash": "4.14.199",
|
|
59
|
+
"@types/node": "20.8.2",
|
|
60
|
+
"@types/uuid": "9.0.4",
|
|
61
|
+
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
62
|
+
"@typescript-eslint/parser": "^4.33.0",
|
|
63
|
+
"@vitest/coverage-v8": "^2.1.0",
|
|
64
|
+
"ajv": "8.17.1",
|
|
65
|
+
"aws-sdk": "2.1550.0",
|
|
66
|
+
"colors": "1.4.0",
|
|
67
|
+
"eslint": "^7.32.0",
|
|
68
|
+
"fs-extra": "11.1.1",
|
|
69
|
+
"glob": "10.3.10",
|
|
70
|
+
"jest": "30.2.0",
|
|
71
|
+
"jest-environment-jsdom": "30.2.0",
|
|
72
|
+
"jsdom": "27.1.0",
|
|
73
|
+
"prompt-sync": "4.2.0",
|
|
74
|
+
"rollup-plugin-obfuscator": "^1.1.0",
|
|
75
|
+
"sqlite3": "5.1.6",
|
|
76
|
+
"terser": "^5.36.0",
|
|
77
|
+
"ts-jest": "29.4.5",
|
|
78
|
+
"tsdown": "0.16.1",
|
|
79
|
+
"typedoc": "^0.26.0",
|
|
80
|
+
"typescript": "^5.6.3",
|
|
81
|
+
"vite": "^5.4.11",
|
|
82
|
+
"vite-plugin-bundle-obfuscator": "1.8.0",
|
|
83
|
+
"vite-plugin-dts": "^4.3.0",
|
|
84
|
+
"vitest": "^2.1.0"
|
|
85
|
+
},
|
|
86
|
+
"dependencies": {
|
|
87
|
+
"@awesome-cordova-plugins/core": "6.6.0",
|
|
88
|
+
"@awesome-cordova-plugins/network-interface": "6.6.0",
|
|
89
|
+
"@microsoft/signalr": "7.0.11",
|
|
90
|
+
"axios": "1.5.1",
|
|
91
|
+
"bcryptjs": "2.4.3",
|
|
92
|
+
"buffer": "6.0.3",
|
|
93
|
+
"crypto-browserify": "3.12.0",
|
|
94
|
+
"crypto-js": "4.2.0",
|
|
95
|
+
"dayjs": "1.11.10",
|
|
96
|
+
"dexie": "3.2.4",
|
|
97
|
+
"esc-pos-encoder-ionic": "1.1.3",
|
|
98
|
+
"handlebars": "4.7.8",
|
|
99
|
+
"lodash": "4.17.21",
|
|
100
|
+
"mathjs": "12.3.2",
|
|
101
|
+
"nanoid": "3.3.4",
|
|
102
|
+
"save": "2.9.0",
|
|
103
|
+
"selecttransform": "1.6.1",
|
|
104
|
+
"sockets-for-cordova": "1.0.0",
|
|
105
|
+
"stream-browserify": "3.0.0",
|
|
106
|
+
"uuid": "9.0.1",
|
|
107
|
+
"vm-browserify": "1.1.2",
|
|
108
|
+
"wcwidth": "1.0.1",
|
|
109
|
+
"zod": "3.23.8"
|
|
110
|
+
},
|
|
111
|
+
"peerDependencies": {
|
|
112
|
+
"@litepos/autoquery": "^5.0.6",
|
|
113
|
+
"rxjs": "^7.0.0"
|
|
114
|
+
},
|
|
115
|
+
"peerDependenciesMeta": {
|
|
116
|
+
"rxjs": {
|
|
117
|
+
"optional": true
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
package/tsdown.config.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { defineConfig } from 'tsdown'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: 'src/index.ts',
|
|
5
|
-
outDir: 'build',
|
|
6
|
-
format: 'esm',
|
|
7
|
-
platform: 'neutral',
|
|
8
|
-
target: 'es2020',
|
|
9
|
-
clean: true,
|
|
10
|
-
sourcemap: true,
|
|
11
|
-
dts: {
|
|
12
|
-
resolve: true,
|
|
13
|
-
},
|
|
14
|
-
external: [
|
|
15
|
-
'@litepos/autoquery',
|
|
16
|
-
'rxjs',
|
|
17
|
-
],
|
|
18
|
-
})
|
|
1
|
+
import { defineConfig } from 'tsdown'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: 'src/index.ts',
|
|
5
|
+
outDir: 'build',
|
|
6
|
+
format: 'esm',
|
|
7
|
+
platform: 'neutral',
|
|
8
|
+
target: 'es2020',
|
|
9
|
+
clean: true,
|
|
10
|
+
sourcemap: true,
|
|
11
|
+
dts: {
|
|
12
|
+
resolve: true,
|
|
13
|
+
},
|
|
14
|
+
external: [
|
|
15
|
+
'@litepos/autoquery',
|
|
16
|
+
'rxjs',
|
|
17
|
+
],
|
|
18
|
+
})
|
package/vite.config.ts
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import { defineConfig, Plugin } from 'vite'
|
|
2
|
-
import { resolve } from 'path'
|
|
3
|
-
import vitePluginBundleObfuscator from 'vite-plugin-bundle-obfuscator'
|
|
4
|
-
import { getBanner } from './scripts/getBanner.mjs'
|
|
5
|
-
|
|
6
|
-
const bannerPlugin = (): Plugin => ({
|
|
7
|
-
name: 'banner-plugin',
|
|
8
|
-
generateBundle(_, bundle) {
|
|
9
|
-
for (const chunk of Object.values(bundle)) {
|
|
10
|
-
if (chunk.type === 'chunk' && chunk.fileName === 'index.js') {
|
|
11
|
-
chunk.code = getBanner() + '\n' + chunk.code
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
export default defineConfig({
|
|
18
|
-
plugins: [
|
|
19
|
-
bannerPlugin(),
|
|
20
|
-
vitePluginBundleObfuscator({
|
|
21
|
-
enable: true,
|
|
22
|
-
log: false,
|
|
23
|
-
autoExcludeNodeModules: true,
|
|
24
|
-
threadPool: { enable: true, size: 4 },
|
|
25
|
-
options: {
|
|
26
|
-
compact: true,
|
|
27
|
-
controlFlowFlattening: false,
|
|
28
|
-
deadCodeInjection: false,
|
|
29
|
-
debugProtection: false,
|
|
30
|
-
identifierNamesGenerator: 'hexadecimal',
|
|
31
|
-
renameGlobals: false,
|
|
32
|
-
selfDefending: false,
|
|
33
|
-
simplify: true,
|
|
34
|
-
stringArray: true,
|
|
35
|
-
stringArrayRotate: true,
|
|
36
|
-
stringArrayShuffle: true,
|
|
37
|
-
stringArrayIndexShift: true,
|
|
38
|
-
stringArrayThreshold: 0.6,
|
|
39
|
-
unicodeEscapeSequence: false,
|
|
40
|
-
},
|
|
41
|
-
}),
|
|
42
|
-
],
|
|
43
|
-
build: {
|
|
44
|
-
outDir: 'build',
|
|
45
|
-
lib: {
|
|
46
|
-
entry: resolve(__dirname, 'src/index.ts'),
|
|
47
|
-
name: '@posx/core',
|
|
48
|
-
formats: ['es'],
|
|
49
|
-
fileName: () => 'index.js',
|
|
50
|
-
},
|
|
51
|
-
rollupOptions: {
|
|
52
|
-
external: [
|
|
53
|
-
'@litepos/autoquery',
|
|
54
|
-
'rxjs',
|
|
55
|
-
],
|
|
56
|
-
output: {
|
|
57
|
-
preserveModules: false,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
sourcemap: true,
|
|
61
|
-
minify: 'terser',
|
|
62
|
-
terserOptions: {
|
|
63
|
-
compress: {
|
|
64
|
-
drop_console: true,
|
|
65
|
-
drop_debugger: true,
|
|
66
|
-
pure_funcs: ['console.log', 'console.info', 'console.debug', 'console.warn'],
|
|
67
|
-
passes: 2,
|
|
68
|
-
},
|
|
69
|
-
mangle: true,
|
|
70
|
-
format: {
|
|
71
|
-
comments: false,
|
|
72
|
-
beautify: false,
|
|
73
|
-
semicolons: true,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
cssMinify: true,
|
|
77
|
-
},
|
|
78
|
-
resolve: {
|
|
79
|
-
alias: {
|
|
80
|
-
buffer: 'buffer/',
|
|
81
|
-
crypto: 'crypto-browserify',
|
|
82
|
-
stream: 'stream-browserify',
|
|
83
|
-
vm: 'vm-browserify',
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
})
|
|
1
|
+
import { defineConfig, Plugin } from 'vite'
|
|
2
|
+
import { resolve } from 'path'
|
|
3
|
+
import vitePluginBundleObfuscator from 'vite-plugin-bundle-obfuscator'
|
|
4
|
+
import { getBanner } from './scripts/getBanner.mjs'
|
|
5
|
+
|
|
6
|
+
const bannerPlugin = (): Plugin => ({
|
|
7
|
+
name: 'banner-plugin',
|
|
8
|
+
generateBundle(_, bundle) {
|
|
9
|
+
for (const chunk of Object.values(bundle)) {
|
|
10
|
+
if (chunk.type === 'chunk' && chunk.fileName === 'index.js') {
|
|
11
|
+
chunk.code = getBanner() + '\n' + chunk.code
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
export default defineConfig({
|
|
18
|
+
plugins: [
|
|
19
|
+
bannerPlugin(),
|
|
20
|
+
vitePluginBundleObfuscator({
|
|
21
|
+
enable: true,
|
|
22
|
+
log: false,
|
|
23
|
+
autoExcludeNodeModules: true,
|
|
24
|
+
threadPool: { enable: true, size: 4 },
|
|
25
|
+
options: {
|
|
26
|
+
compact: true,
|
|
27
|
+
controlFlowFlattening: false,
|
|
28
|
+
deadCodeInjection: false,
|
|
29
|
+
debugProtection: false,
|
|
30
|
+
identifierNamesGenerator: 'hexadecimal',
|
|
31
|
+
renameGlobals: false,
|
|
32
|
+
selfDefending: false,
|
|
33
|
+
simplify: true,
|
|
34
|
+
stringArray: true,
|
|
35
|
+
stringArrayRotate: true,
|
|
36
|
+
stringArrayShuffle: true,
|
|
37
|
+
stringArrayIndexShift: true,
|
|
38
|
+
stringArrayThreshold: 0.6,
|
|
39
|
+
unicodeEscapeSequence: false,
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
],
|
|
43
|
+
build: {
|
|
44
|
+
outDir: 'build',
|
|
45
|
+
lib: {
|
|
46
|
+
entry: resolve(__dirname, 'src/index.ts'),
|
|
47
|
+
name: '@posx/core',
|
|
48
|
+
formats: ['es'],
|
|
49
|
+
fileName: () => 'index.js',
|
|
50
|
+
},
|
|
51
|
+
rollupOptions: {
|
|
52
|
+
external: [
|
|
53
|
+
'@litepos/autoquery',
|
|
54
|
+
'rxjs',
|
|
55
|
+
],
|
|
56
|
+
output: {
|
|
57
|
+
preserveModules: false,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
sourcemap: true,
|
|
61
|
+
minify: 'terser',
|
|
62
|
+
terserOptions: {
|
|
63
|
+
compress: {
|
|
64
|
+
drop_console: true,
|
|
65
|
+
drop_debugger: true,
|
|
66
|
+
pure_funcs: ['console.log', 'console.info', 'console.debug', 'console.warn'],
|
|
67
|
+
passes: 2,
|
|
68
|
+
},
|
|
69
|
+
mangle: true,
|
|
70
|
+
format: {
|
|
71
|
+
comments: false,
|
|
72
|
+
beautify: false,
|
|
73
|
+
semicolons: true,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
cssMinify: true,
|
|
77
|
+
},
|
|
78
|
+
resolve: {
|
|
79
|
+
alias: {
|
|
80
|
+
buffer: 'buffer/',
|
|
81
|
+
crypto: 'crypto-browserify',
|
|
82
|
+
stream: 'stream-browserify',
|
|
83
|
+
vm: 'vm-browserify',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
})
|