@posx/core 5.5.350 → 5.5.351
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 +55 -53
- package/build/index.js +84 -67
- 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
|
@@ -3589,10 +3589,11 @@ declare class OrderConfig implements IOrderConfig {
|
|
|
3589
3589
|
constructor();
|
|
3590
3590
|
}
|
|
3591
3591
|
interface IOrderDisplaySystemConfig {
|
|
3592
|
-
|
|
3592
|
+
enabled: boolean;
|
|
3593
3593
|
language: string;
|
|
3594
3594
|
}
|
|
3595
3595
|
declare class OrderDisplaySystemConfig implements IOrderDisplaySystemConfig {
|
|
3596
|
+
enabled: boolean;
|
|
3596
3597
|
language: string;
|
|
3597
3598
|
constructor();
|
|
3598
3599
|
}
|
|
@@ -5005,6 +5006,56 @@ declare class PrinterService extends AppRemoteService<IPrinter> implements IPrin
|
|
|
5005
5006
|
openCashDrawer(): Promise<void>;
|
|
5006
5007
|
}
|
|
5007
5008
|
//#endregion
|
|
5009
|
+
//#region src/types/ods.type.d.ts
|
|
5010
|
+
interface IOrderDisplay extends IAppCoreModel {
|
|
5011
|
+
order_number: string;
|
|
5012
|
+
status: OrderDisplayStatus;
|
|
5013
|
+
}
|
|
5014
|
+
declare class OrderDisplay extends AppCoreModel implements IOrderDisplay {
|
|
5015
|
+
uid: string;
|
|
5016
|
+
order_number: string;
|
|
5017
|
+
status: OrderDisplayStatus;
|
|
5018
|
+
constructor();
|
|
5019
|
+
}
|
|
5020
|
+
declare enum OrderDisplayStatus {
|
|
5021
|
+
Preparing = "preparing",
|
|
5022
|
+
ReadyForPickup = "ready_for_pickup",
|
|
5023
|
+
}
|
|
5024
|
+
//#endregion
|
|
5025
|
+
//#region src/services/ods.service.d.ts
|
|
5026
|
+
/**
|
|
5027
|
+
* Represents the interface for the Order Display Service.
|
|
5028
|
+
* Extends the IAppRemoteService interface with the IOrderDisplay type.
|
|
5029
|
+
*/
|
|
5030
|
+
interface IOrderDisplayService extends IAppRemoteService<IOrderDisplay> {
|
|
5031
|
+
/**
|
|
5032
|
+
* Changes the status of the order to ready for pickup
|
|
5033
|
+
* @param uid The uid of the order
|
|
5034
|
+
* @returns The updated order
|
|
5035
|
+
*/
|
|
5036
|
+
toPickUp(uid: string): Promise<IOrderDisplay>;
|
|
5037
|
+
/**
|
|
5038
|
+
* Changes the status of the order to preparing
|
|
5039
|
+
* @param uid The uid of the order
|
|
5040
|
+
*/
|
|
5041
|
+
toPreparing(uid: string): Promise<IOrderDisplay>;
|
|
5042
|
+
/**
|
|
5043
|
+
* Undoes the last order that was marked as ready for pickup
|
|
5044
|
+
*/
|
|
5045
|
+
undo(): Promise<IOrderDisplay>;
|
|
5046
|
+
}
|
|
5047
|
+
declare class OrderDisplayService extends AppRemoteService<IOrderDisplay> implements IOrderDisplayService {
|
|
5048
|
+
readonly http: AxiosInstance$1;
|
|
5049
|
+
readonly db: Dexie;
|
|
5050
|
+
readonly options: IServiceOptions;
|
|
5051
|
+
readonly moduleName: string;
|
|
5052
|
+
readonly methodName: string;
|
|
5053
|
+
constructor(http: AxiosInstance$1, db: Dexie, options: IServiceOptions, moduleName?: string, methodName?: string);
|
|
5054
|
+
toPickUp(uid: string): Promise<IOrderDisplay>;
|
|
5055
|
+
toPreparing(uid: string): Promise<IOrderDisplay>;
|
|
5056
|
+
undo(): Promise<IOrderDisplay>;
|
|
5057
|
+
}
|
|
5058
|
+
//#endregion
|
|
5008
5059
|
//#region src/services/invoice.service.d.ts
|
|
5009
5060
|
interface IInvoiceBaseService extends IAppRemoteService<IInvoice> {
|
|
5010
5061
|
calculate(invoice: IInvoice, appConfig: IAppConfig, disableRounding?: boolean): IInvoice;
|
|
@@ -5032,7 +5083,7 @@ type LineOptions = {
|
|
|
5032
5083
|
remark?: string;
|
|
5033
5084
|
};
|
|
5034
5085
|
declare class InvoiceBaseService extends AppRemoteService<IInvoice> implements IInvoiceBaseService {
|
|
5035
|
-
readonly http: AxiosInstance
|
|
5086
|
+
readonly http: AxiosInstance;
|
|
5036
5087
|
readonly db: Dexie;
|
|
5037
5088
|
readonly options: IServiceOptions;
|
|
5038
5089
|
readonly moduleName: string;
|
|
@@ -5044,7 +5095,8 @@ declare class InvoiceBaseService extends AppRemoteService<IInvoice> implements I
|
|
|
5044
5095
|
protected printerService: PrinterService;
|
|
5045
5096
|
protected printJobService: PrintJobService;
|
|
5046
5097
|
protected itemService: IItemService;
|
|
5047
|
-
|
|
5098
|
+
protected orderDisplayService: OrderDisplayService;
|
|
5099
|
+
constructor(http: AxiosInstance, db: Dexie, options: IServiceOptions, moduleName?: string, methodName?: string);
|
|
5048
5100
|
calculate(invoice: IInvoice, appConfig: IAppConfig, disableRounding?: boolean): IInvoice;
|
|
5049
5101
|
calculateLines(invoice: IInvoice): void;
|
|
5050
5102
|
calculateLine(line: IInvoiceLine): void;
|
|
@@ -5650,56 +5702,6 @@ declare const filterByParams: (params: {
|
|
|
5650
5702
|
declare function humanizedData(date: Date, format?: string): string;
|
|
5651
5703
|
declare function normalizedDate(date: Date): string;
|
|
5652
5704
|
//#endregion
|
|
5653
|
-
//#region src/types/ods.type.d.ts
|
|
5654
|
-
interface IOrderDisplay extends IAppCoreModel {
|
|
5655
|
-
order_number: string;
|
|
5656
|
-
status: OrderDisplayStatus;
|
|
5657
|
-
}
|
|
5658
|
-
declare class OrderDisplay extends AppCoreModel implements IOrderDisplay {
|
|
5659
|
-
uid: string;
|
|
5660
|
-
order_number: string;
|
|
5661
|
-
status: OrderDisplayStatus;
|
|
5662
|
-
constructor();
|
|
5663
|
-
}
|
|
5664
|
-
declare enum OrderDisplayStatus {
|
|
5665
|
-
Preparing = "preparing",
|
|
5666
|
-
ReadyForPickup = "ready_for_pickup",
|
|
5667
|
-
}
|
|
5668
|
-
//#endregion
|
|
5669
|
-
//#region src/services/ods.service.d.ts
|
|
5670
|
-
/**
|
|
5671
|
-
* Represents the interface for the Order Display Service.
|
|
5672
|
-
* Extends the IAppRemoteService interface with the IOrderDisplay type.
|
|
5673
|
-
*/
|
|
5674
|
-
interface IOrderDisplayService extends IAppRemoteService<IOrderDisplay> {
|
|
5675
|
-
/**
|
|
5676
|
-
* Changes the status of the order to ready for pickup
|
|
5677
|
-
* @param uid The uid of the order
|
|
5678
|
-
* @returns The updated order
|
|
5679
|
-
*/
|
|
5680
|
-
toPickUp(uid: string): Promise<IOrderDisplay>;
|
|
5681
|
-
/**
|
|
5682
|
-
* Changes the status of the order to preparing
|
|
5683
|
-
* @param uid The uid of the order
|
|
5684
|
-
*/
|
|
5685
|
-
toPreparing(uid: string): Promise<IOrderDisplay>;
|
|
5686
|
-
/**
|
|
5687
|
-
* Undoes the last order that was marked as ready for pickup
|
|
5688
|
-
*/
|
|
5689
|
-
undo(): Promise<IOrderDisplay>;
|
|
5690
|
-
}
|
|
5691
|
-
declare class OrderDisplayService extends AppRemoteService<IOrderDisplay> implements IOrderDisplayService {
|
|
5692
|
-
readonly http: AxiosInstance;
|
|
5693
|
-
readonly db: Dexie;
|
|
5694
|
-
readonly options: IServiceOptions;
|
|
5695
|
-
readonly moduleName: string;
|
|
5696
|
-
readonly methodName: string;
|
|
5697
|
-
constructor(http: AxiosInstance, db: Dexie, options: IServiceOptions, moduleName?: string, methodName?: string);
|
|
5698
|
-
toPickUp(uid: string): Promise<IOrderDisplay>;
|
|
5699
|
-
toPreparing(uid: string): Promise<IOrderDisplay>;
|
|
5700
|
-
undo(): Promise<IOrderDisplay>;
|
|
5701
|
-
}
|
|
5702
|
-
//#endregion
|
|
5703
5705
|
//#region src/types/csv.type.d.ts
|
|
5704
5706
|
/**
|
|
5705
5707
|
* Interface for CSV export rows
|
package/build/index.js
CHANGED
|
@@ -2063,6 +2063,7 @@ var OrderConfig = class {
|
|
|
2063
2063
|
};
|
|
2064
2064
|
var OrderDisplaySystemConfig = class {
|
|
2065
2065
|
constructor() {
|
|
2066
|
+
_defineProperty(this, "enabled", false);
|
|
2066
2067
|
_defineProperty(this, "language", "en");
|
|
2067
2068
|
}
|
|
2068
2069
|
};
|
|
@@ -3191,6 +3192,69 @@ function helpers(options) {
|
|
|
3191
3192
|
*/
|
|
3192
3193
|
var helpers_register_default = helpers;
|
|
3193
3194
|
|
|
3195
|
+
//#endregion
|
|
3196
|
+
//#region src/types/ods.type.ts
|
|
3197
|
+
var OrderDisplay = class extends AppCoreModel {
|
|
3198
|
+
constructor() {
|
|
3199
|
+
super();
|
|
3200
|
+
_defineProperty(this, "uid", ModelPrefix.OrderDisplaySystem + nanoid());
|
|
3201
|
+
_defineProperty(this, "order_number", "");
|
|
3202
|
+
_defineProperty(this, "status", OrderDisplayStatus.Preparing);
|
|
3203
|
+
}
|
|
3204
|
+
};
|
|
3205
|
+
let OrderDisplayStatus = /* @__PURE__ */ function(OrderDisplayStatus$1) {
|
|
3206
|
+
OrderDisplayStatus$1["Preparing"] = "preparing";
|
|
3207
|
+
OrderDisplayStatus$1["ReadyForPickup"] = "ready_for_pickup";
|
|
3208
|
+
return OrderDisplayStatus$1;
|
|
3209
|
+
}({});
|
|
3210
|
+
|
|
3211
|
+
//#endregion
|
|
3212
|
+
//#region src/services/ods.service.ts
|
|
3213
|
+
var OrderDisplayService = class extends AppRemoteService {
|
|
3214
|
+
constructor(http, db, options, moduleName = "order_displays", methodName = "order_display") {
|
|
3215
|
+
super();
|
|
3216
|
+
this.http = http;
|
|
3217
|
+
this.db = db;
|
|
3218
|
+
this.options = options;
|
|
3219
|
+
this.moduleName = moduleName;
|
|
3220
|
+
this.methodName = methodName;
|
|
3221
|
+
}
|
|
3222
|
+
async toPickUp(uid) {
|
|
3223
|
+
const orderDisplay = await this.getOne(uid);
|
|
3224
|
+
if (!orderDisplay) throw new SystemError("Display order not found");
|
|
3225
|
+
if (orderDisplay.status == "ready_for_pickup") throw new SystemError("Order is already ready for pickup");
|
|
3226
|
+
orderDisplay.status = OrderDisplayStatus.ReadyForPickup;
|
|
3227
|
+
orderDisplay.updated_at = /* @__PURE__ */ new Date();
|
|
3228
|
+
if (orderDisplay.id_in_server == 0) throw new SystemError("Order is not synced with server");
|
|
3229
|
+
await this.updateOne(orderDisplay.id_in_server, orderDisplay);
|
|
3230
|
+
return orderDisplay;
|
|
3231
|
+
}
|
|
3232
|
+
async toPreparing(uid) {
|
|
3233
|
+
const orderDisplay = await this.getOne(uid);
|
|
3234
|
+
if (!orderDisplay) throw new SystemError("Display order not found");
|
|
3235
|
+
if (orderDisplay.status == "preparing") throw new SystemError("Order is already preparing");
|
|
3236
|
+
orderDisplay.status = OrderDisplayStatus.Preparing;
|
|
3237
|
+
orderDisplay.updated_at = /* @__PURE__ */ new Date();
|
|
3238
|
+
if (orderDisplay.id_in_server == 0) throw new SystemError("Order is not synced with server");
|
|
3239
|
+
await this.updateOne(orderDisplay.id_in_server, orderDisplay);
|
|
3240
|
+
return orderDisplay;
|
|
3241
|
+
}
|
|
3242
|
+
async undo() {
|
|
3243
|
+
const orderDisplays = await this.db.table(this.moduleName).filter((x) => x.status == OrderDisplayStatus.ReadyForPickup).reverse().limit(100).toArray();
|
|
3244
|
+
if (orderDisplays.length === 0) throw new SystemError("No order to undo");
|
|
3245
|
+
orderDisplays.sort((a, b) => {
|
|
3246
|
+
const dateA = new Date(a.updated_at).getTime();
|
|
3247
|
+
return new Date(b.updated_at).getTime() - dateA;
|
|
3248
|
+
});
|
|
3249
|
+
const latestOrderDisplay = orderDisplays[0];
|
|
3250
|
+
latestOrderDisplay.status = OrderDisplayStatus.Preparing;
|
|
3251
|
+
latestOrderDisplay.updated_at = /* @__PURE__ */ new Date();
|
|
3252
|
+
if (latestOrderDisplay.id_in_server == 0) throw new SystemError("Order is not synced with server");
|
|
3253
|
+
await this.updateOne(latestOrderDisplay.id_in_server, latestOrderDisplay);
|
|
3254
|
+
return latestOrderDisplay;
|
|
3255
|
+
}
|
|
3256
|
+
};
|
|
3257
|
+
|
|
3194
3258
|
//#endregion
|
|
3195
3259
|
//#region src/services/invoice.service.ts
|
|
3196
3260
|
helpers_register_default({ handlebars: Handlebars });
|
|
@@ -3214,6 +3278,7 @@ var InvoiceBaseService = class extends AppRemoteService {
|
|
|
3214
3278
|
_defineProperty(this, "printerService", void 0);
|
|
3215
3279
|
_defineProperty(this, "printJobService", void 0);
|
|
3216
3280
|
_defineProperty(this, "itemService", void 0);
|
|
3281
|
+
_defineProperty(this, "orderDisplayService", void 0);
|
|
3217
3282
|
this.tillService = new TillService(http, db, options, "tills", "till");
|
|
3218
3283
|
this.sectionItemService = new SectionItemService(http, db, options, "section_items", "section_item");
|
|
3219
3284
|
this.configService = new ConfigService(http, db, options, "configs", "config");
|
|
@@ -3221,6 +3286,7 @@ var InvoiceBaseService = class extends AppRemoteService {
|
|
|
3221
3286
|
this.printerService = new PrinterService(http, db, options, "printers", "printer");
|
|
3222
3287
|
this.printJobService = new PrintJobService(http, db, options, "print_jobs", "print_job");
|
|
3223
3288
|
this.itemService = new ItemService(http, db, options, "items", "item");
|
|
3289
|
+
this.orderDisplayService = new OrderDisplayService(http, db, options);
|
|
3224
3290
|
}
|
|
3225
3291
|
calculate(invoice, appConfig, disableRounding = false) {
|
|
3226
3292
|
if (invoice.lines == null || invoice.lines.length < 1) {
|
|
@@ -3968,7 +4034,8 @@ var InvoiceOperationService = class extends LineOperationService {
|
|
|
3968
4034
|
sectionItem.status = SectionItemStatus.CLOSED;
|
|
3969
4035
|
this.addEmployeeToInvoice(invoice, employee);
|
|
3970
4036
|
invoice.paid_at = /* @__PURE__ */ new Date();
|
|
3971
|
-
const
|
|
4037
|
+
const config = (await this.configService.getDefaultOne()).config;
|
|
4038
|
+
const datetimeFormat = config?.order?.datetime_format;
|
|
3972
4039
|
invoice.humanized_paid_at = humanizedData(invoice.paid_at, datetimeFormat);
|
|
3973
4040
|
invoice.payment_has_cash = invoice.payments?.some((payment) => payment.payment_method?.is_cash === true);
|
|
3974
4041
|
const stockChanges = await this.getStockChangeList(invoice, false);
|
|
@@ -4010,7 +4077,13 @@ var InvoiceOperationService = class extends LineOperationService {
|
|
|
4010
4077
|
this.sectionItemService.saveOne(res.data);
|
|
4011
4078
|
options.section_item = res.data;
|
|
4012
4079
|
throw new SystemError(`${res.error}, system has updated the data and please try again`);
|
|
4013
|
-
}
|
|
4080
|
+
}
|
|
4081
|
+
if (stockChanges.length > 0) await this.itemService.changeItemsStock(stockChanges);
|
|
4082
|
+
if (invoice.call_num && config?.ods?.enabled) {
|
|
4083
|
+
const orderDisplay = new OrderDisplay();
|
|
4084
|
+
orderDisplay.order_number = invoice.call_num;
|
|
4085
|
+
await this.orderDisplayService.addOne(orderDisplay);
|
|
4086
|
+
}
|
|
4014
4087
|
return options;
|
|
4015
4088
|
} catch (error) {
|
|
4016
4089
|
invoice.kitchen_print_job_uids.length = previousKitchenUidsLength;
|
|
@@ -4022,7 +4095,8 @@ var InvoiceOperationService = class extends LineOperationService {
|
|
|
4022
4095
|
invoice.status = InvoiceStatus.Paid;
|
|
4023
4096
|
if (employee != null) this.addEmployeeToInvoice(invoice, employee);
|
|
4024
4097
|
invoice.paid_at = /* @__PURE__ */ new Date();
|
|
4025
|
-
const
|
|
4098
|
+
const config = (await this.configService.getDefaultOne()).config;
|
|
4099
|
+
const datetimeFormat = config?.order?.datetime_format;
|
|
4026
4100
|
invoice.humanized_paid_at = humanizedData(invoice.paid_at, datetimeFormat);
|
|
4027
4101
|
invoice.created_at = /* @__PURE__ */ new Date();
|
|
4028
4102
|
invoice.created_at_timestamp = invoice.created_at.getTime();
|
|
@@ -4063,7 +4137,13 @@ var InvoiceOperationService = class extends LineOperationService {
|
|
|
4063
4137
|
this.saveOne(res.data);
|
|
4064
4138
|
options.invoice = res.data;
|
|
4065
4139
|
throw new SystemError(res.error);
|
|
4066
|
-
}
|
|
4140
|
+
}
|
|
4141
|
+
if (stockChanges.length > 0) await this.itemService.changeItemsStock(stockChanges);
|
|
4142
|
+
if (invoice.call_num && config?.ods?.enabled) {
|
|
4143
|
+
const orderDisplay = new OrderDisplay();
|
|
4144
|
+
orderDisplay.order_number = invoice.call_num;
|
|
4145
|
+
await this.orderDisplayService.addOne(orderDisplay);
|
|
4146
|
+
}
|
|
4067
4147
|
return options;
|
|
4068
4148
|
}
|
|
4069
4149
|
async voidInvoice(invoice, till, reason, employee) {
|
|
@@ -5707,69 +5787,6 @@ function createInstance(baseURL, uid, token) {
|
|
|
5707
5787
|
return instance;
|
|
5708
5788
|
}
|
|
5709
5789
|
|
|
5710
|
-
//#endregion
|
|
5711
|
-
//#region src/types/ods.type.ts
|
|
5712
|
-
var OrderDisplay = class extends AppCoreModel {
|
|
5713
|
-
constructor() {
|
|
5714
|
-
super();
|
|
5715
|
-
_defineProperty(this, "uid", ModelPrefix.OrderDisplaySystem + nanoid());
|
|
5716
|
-
_defineProperty(this, "order_number", "");
|
|
5717
|
-
_defineProperty(this, "status", OrderDisplayStatus.Preparing);
|
|
5718
|
-
}
|
|
5719
|
-
};
|
|
5720
|
-
let OrderDisplayStatus = /* @__PURE__ */ function(OrderDisplayStatus$1) {
|
|
5721
|
-
OrderDisplayStatus$1["Preparing"] = "preparing";
|
|
5722
|
-
OrderDisplayStatus$1["ReadyForPickup"] = "ready_for_pickup";
|
|
5723
|
-
return OrderDisplayStatus$1;
|
|
5724
|
-
}({});
|
|
5725
|
-
|
|
5726
|
-
//#endregion
|
|
5727
|
-
//#region src/services/ods.service.ts
|
|
5728
|
-
var OrderDisplayService = class extends AppRemoteService {
|
|
5729
|
-
constructor(http, db, options, moduleName = "order_displays", methodName = "order_display") {
|
|
5730
|
-
super();
|
|
5731
|
-
this.http = http;
|
|
5732
|
-
this.db = db;
|
|
5733
|
-
this.options = options;
|
|
5734
|
-
this.moduleName = moduleName;
|
|
5735
|
-
this.methodName = methodName;
|
|
5736
|
-
}
|
|
5737
|
-
async toPickUp(uid) {
|
|
5738
|
-
const orderDisplay = await this.getOne(uid);
|
|
5739
|
-
if (!orderDisplay) throw new SystemError("Display order not found");
|
|
5740
|
-
if (orderDisplay.status == "ready_for_pickup") throw new SystemError("Order is already ready for pickup");
|
|
5741
|
-
orderDisplay.status = OrderDisplayStatus.ReadyForPickup;
|
|
5742
|
-
orderDisplay.updated_at = /* @__PURE__ */ new Date();
|
|
5743
|
-
if (orderDisplay.id_in_server == 0) throw new SystemError("Order is not synced with server");
|
|
5744
|
-
await this.updateOne(orderDisplay.id_in_server, orderDisplay);
|
|
5745
|
-
return orderDisplay;
|
|
5746
|
-
}
|
|
5747
|
-
async toPreparing(uid) {
|
|
5748
|
-
const orderDisplay = await this.getOne(uid);
|
|
5749
|
-
if (!orderDisplay) throw new SystemError("Display order not found");
|
|
5750
|
-
if (orderDisplay.status == "preparing") throw new SystemError("Order is already preparing");
|
|
5751
|
-
orderDisplay.status = OrderDisplayStatus.Preparing;
|
|
5752
|
-
orderDisplay.updated_at = /* @__PURE__ */ new Date();
|
|
5753
|
-
if (orderDisplay.id_in_server == 0) throw new SystemError("Order is not synced with server");
|
|
5754
|
-
await this.updateOne(orderDisplay.id_in_server, orderDisplay);
|
|
5755
|
-
return orderDisplay;
|
|
5756
|
-
}
|
|
5757
|
-
async undo() {
|
|
5758
|
-
const orderDisplays = await this.db.table(this.moduleName).filter((x) => x.status == OrderDisplayStatus.ReadyForPickup).reverse().limit(100).toArray();
|
|
5759
|
-
if (orderDisplays.length === 0) throw new SystemError("No order to undo");
|
|
5760
|
-
orderDisplays.sort((a, b) => {
|
|
5761
|
-
const dateA = new Date(a.updated_at).getTime();
|
|
5762
|
-
return new Date(b.updated_at).getTime() - dateA;
|
|
5763
|
-
});
|
|
5764
|
-
const latestOrderDisplay = orderDisplays[0];
|
|
5765
|
-
latestOrderDisplay.status = OrderDisplayStatus.Preparing;
|
|
5766
|
-
latestOrderDisplay.updated_at = /* @__PURE__ */ new Date();
|
|
5767
|
-
if (latestOrderDisplay.id_in_server == 0) throw new SystemError("Order is not synced with server");
|
|
5768
|
-
await this.updateOne(latestOrderDisplay.id_in_server, latestOrderDisplay);
|
|
5769
|
-
return latestOrderDisplay;
|
|
5770
|
-
}
|
|
5771
|
-
};
|
|
5772
|
-
|
|
5773
5790
|
//#endregion
|
|
5774
5791
|
//#region src/service.factory.ts
|
|
5775
5792
|
const serviceProvider = new Map([
|
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 --maxWorkers=2",
|
|
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.351",
|
|
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 --maxWorkers=2",
|
|
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
|
+
})
|