@posx/core 5.5.330 → 5.5.332

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 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
@@ -316,7 +316,7 @@ interface IAppCoreModel {
316
316
  * the date when the object is deleted
317
317
  * @ignore
318
318
  */
319
- deleted_at: Date;
319
+ deleted_at: Date | null;
320
320
  /**
321
321
  * timestamp in milliseconds
322
322
  * @ignore
@@ -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 {
@@ -3550,6 +3553,8 @@ interface IOrderConfig {
3550
3553
  hide_categories_when_ordering: boolean;
3551
3554
  /** Flag to end shift with open tables */
3552
3555
  end_shift_with_open_tables: boolean;
3556
+ /** Date time format for humanized dates */
3557
+ datetime_format: string;
3553
3558
  }
3554
3559
  declare class OrderConfig implements IOrderConfig {
3555
3560
  separation_line: boolean;
@@ -3561,6 +3566,7 @@ declare class OrderConfig implements IOrderConfig {
3561
3566
  hide_combo_item_on_interactive_view: boolean;
3562
3567
  hide_categories_when_ordering: boolean;
3563
3568
  end_shift_with_open_tables: boolean;
3569
+ datetime_format: string;
3564
3570
  constructor();
3565
3571
  }
3566
3572
  interface IPaymentConfig {
@@ -4177,6 +4183,7 @@ declare class TemplateData implements ITemplateData {
4177
4183
  normalized_printed_at: string;
4178
4184
  meta: Record<string, any>;
4179
4185
  is_cancel: boolean;
4186
+ constructor();
4180
4187
  }
4181
4188
  type IRenderPrintTemplateOptions = {
4182
4189
  printer_name: string;
@@ -5613,7 +5620,7 @@ declare const filterByParams: (params: {
5613
5620
  }) => (values: any) => boolean;
5614
5621
  //#endregion
5615
5622
  //#region src/utils/misc.utils.d.ts
5616
- declare function humanizedData(date: Date): string;
5623
+ declare function humanizedData(date: Date, format?: string): string;
5617
5624
  declare function normalizedDate(date: Date): string;
5618
5625
  //#endregion
5619
5626
  //#region src/types/ods.type.d.ts
package/build/index.js CHANGED
@@ -1266,21 +1266,8 @@ var PrintCommand = class {
1266
1266
 
1267
1267
  //#endregion
1268
1268
  //#region src/utils/misc.utils.ts
1269
- function humanizedData(date) {
1270
- return `${date.getFullYear()}-${[
1271
- "Jan",
1272
- "Feb",
1273
- "Mar",
1274
- "Apr",
1275
- "May",
1276
- "Jun",
1277
- "Jul",
1278
- "Aug",
1279
- "Sep",
1280
- "Oct",
1281
- "Nov",
1282
- "Dec"
1283
- ][date.getMonth()]}-${date.getDate().toString().padStart(2, "0")} ${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}:${date.getSeconds().toString().padStart(2, "0")}`;
1269
+ function humanizedData(date, format) {
1270
+ return dayjs(date).format(format || "YYYY-MMM-DD HH:mm:ss");
1284
1271
  }
1285
1272
  function normalizedDate(date) {
1286
1273
  return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")} ${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}:${date.getSeconds().toString().padStart(2, "0")}`;
@@ -1458,9 +1445,10 @@ var TemplateData = class {
1458
1445
  _defineProperty(this, "section_item", {});
1459
1446
  _defineProperty(this, "printer_name", "");
1460
1447
  _defineProperty(this, "printed_at", /* @__PURE__ */ new Date());
1461
- _defineProperty(this, "normalized_printed_at", humanizedData(this.printed_at));
1448
+ _defineProperty(this, "normalized_printed_at", "");
1462
1449
  _defineProperty(this, "meta", {});
1463
1450
  _defineProperty(this, "is_cancel", false);
1451
+ this.normalized_printed_at = humanizedData(this.printed_at);
1464
1452
  }
1465
1453
  };
1466
1454
  var RenderPrintTemplateOptions = class {
@@ -2048,6 +2036,7 @@ var KdsConfig = class {
2048
2036
  var LabelConfig = class {
2049
2037
  constructor() {
2050
2038
  _defineProperty(this, "print", false);
2039
+ _defineProperty(this, "text_to_raster", false);
2051
2040
  }
2052
2041
  };
2053
2042
  var OrderConfig = class {
@@ -2061,6 +2050,7 @@ var OrderConfig = class {
2061
2050
  _defineProperty(this, "hide_combo_item_on_interactive_view", false);
2062
2051
  _defineProperty(this, "hide_categories_when_ordering", false);
2063
2052
  _defineProperty(this, "end_shift_with_open_tables", false);
2053
+ _defineProperty(this, "datetime_format", "YYYY-MMM-DD HH:mm:ss");
2064
2054
  }
2065
2055
  };
2066
2056
  var PaymentConfig = class {
@@ -3462,7 +3452,8 @@ var InvoiceOperationService = class extends LineOperationService {
3462
3452
  this.addEmployeeToInvoice(invoice, employee);
3463
3453
  invoice.created_at = /* @__PURE__ */ new Date();
3464
3454
  invoice.created_at_timestamp = invoice.created_at.getTime();
3465
- invoice.humanized_created_at = humanizedData(invoice.created_at);
3455
+ const datetimeFormat = (await this.configService.getDefaultOne()).config?.order?.datetime_format;
3456
+ invoice.humanized_created_at = humanizedData(invoice.created_at, datetimeFormat);
3466
3457
  sectionItem.invoice_created_at = /* @__PURE__ */ new Date();
3467
3458
  const kitchenPrintJobs = await this.createKitchenPrintJobs(invoice);
3468
3459
  const labelPrintJobs = await this.createLabelPrintJobs(invoice);
@@ -3661,7 +3652,8 @@ var InvoiceOperationService = class extends LineOperationService {
3661
3652
  sectionItem.status = SectionItemStatus.CLOSED;
3662
3653
  this.addEmployeeToInvoice(invoice, employee);
3663
3654
  invoice.paid_at = /* @__PURE__ */ new Date();
3664
- invoice.humanized_paid_at = humanizedData(invoice.paid_at);
3655
+ const datetimeFormat = (await this.configService.getDefaultOne()).config?.order?.datetime_format;
3656
+ invoice.humanized_paid_at = humanizedData(invoice.paid_at, datetimeFormat);
3665
3657
  invoice.payment_has_cash = invoice.payments?.some((payment) => payment.payment_method?.is_cash === true);
3666
3658
  const stockChanges = await this.getStockChangeList(invoice, false);
3667
3659
  const labelPrintJobs = await this.createLabelPrintJobs(invoice);
@@ -3714,10 +3706,11 @@ var InvoiceOperationService = class extends LineOperationService {
3714
3706
  invoice.status = InvoiceStatus.Paid;
3715
3707
  if (employee != null) this.addEmployeeToInvoice(invoice, employee);
3716
3708
  invoice.paid_at = /* @__PURE__ */ new Date();
3717
- invoice.humanized_paid_at = humanizedData(invoice.paid_at);
3709
+ const datetimeFormat = (await this.configService.getDefaultOne()).config?.order?.datetime_format;
3710
+ invoice.humanized_paid_at = humanizedData(invoice.paid_at, datetimeFormat);
3718
3711
  invoice.created_at = /* @__PURE__ */ new Date();
3719
3712
  invoice.created_at_timestamp = invoice.created_at.getTime();
3720
- invoice.humanized_created_at = humanizedData(invoice.created_at);
3713
+ invoice.humanized_created_at = humanizedData(invoice.created_at, datetimeFormat);
3721
3714
  if (!invoice.ref_id) invoice.ref_id = await this.getRefId();
3722
3715
  if (!invoice.call_num) invoice.call_num = invoice.ref_id.slice(-3);
3723
3716
  invoice.payment_has_cash = invoice.payments?.some((payment) => payment.payment_method?.is_cash === true);
@@ -3762,7 +3755,8 @@ var InvoiceOperationService = class extends LineOperationService {
3762
3755
  const originalStatus = invoice.status;
3763
3756
  invoice.status = InvoiceStatus.Void;
3764
3757
  invoice.voided_at = /* @__PURE__ */ new Date();
3765
- invoice.humanized_voided_at = humanizedData(invoice.voided_at);
3758
+ const datetimeFormat = (await this.configService.getDefaultOne()).config?.order?.datetime_format;
3759
+ invoice.humanized_voided_at = humanizedData(invoice.voided_at, datetimeFormat);
3766
3760
  if (till) till.deleted_at = /* @__PURE__ */ new Date();
3767
3761
  this.addEmployeeToInvoice(invoice, employee);
3768
3762
  const config = (await this.configService.getDefaultOne()).config;
@@ -4908,12 +4902,12 @@ var AppReportService = class extends AppRemoteService {
4908
4902
  if (!printer) throw new SystemError("No default receipt printer found");
4909
4903
  const template = await this.printTemplateService.getOneByParams({ report_code_name: request.report_code_name });
4910
4904
  if (!template) throw new SystemError("No print template found");
4911
- const reportData = await this.getReportData(request);
4912
4905
  const appConfig = await this.configService.getDefaultOne();
4906
+ const reportData = await this.getReportData(request, appConfig.config?.order?.datetime_format);
4913
4907
  const printJob = new PrintJob(printer, await this.printTemplateService.renderReportPrintTemplate(reportData, appConfig.config, template), false, request.copies);
4914
4908
  await this.printJobService.addOne(printJob);
4915
4909
  }
4916
- async getReportData(request) {
4910
+ async getReportData(request, datetimeFormat) {
4917
4911
  const reportData = new ReportData();
4918
4912
  if (request.shift_uid) {
4919
4913
  await this.db.table("shifts").where("uid").equals(request.shift_uid).and((shift) => shift.deleted_at == null || shift.deleted_at == void 0).first();
@@ -4931,9 +4925,9 @@ var AppReportService = class extends AppRemoteService {
4931
4925
  }
4932
4926
  reportData.start_datetime = new Date(request.start_datetime).toISOString();
4933
4927
  reportData.end_datetime = new Date(request.end_datetime).toISOString();
4934
- reportData.humanized_start_datetime = humanizedData(new Date(request.start_datetime));
4935
- reportData.humanized_end_datetime = humanizedData(new Date(request.end_datetime));
4936
- reportData.humanized_printed_datetime = humanizedData(/* @__PURE__ */ new Date());
4928
+ reportData.humanized_start_datetime = humanizedData(new Date(request.start_datetime), datetimeFormat);
4929
+ reportData.humanized_end_datetime = humanizedData(new Date(request.end_datetime), datetimeFormat);
4930
+ reportData.humanized_printed_datetime = humanizedData(/* @__PURE__ */ new Date(), datetimeFormat);
4937
4931
  const query = new QueryBuilder().addParam("paid_at", "GreaterThanOrEqualTo", new Date(request.start_datetime).toISOString()).addParam("paid_at", "LessThanOrEqualTo", new Date(request.end_datetime).toISOString()).addParam("deleted_at", "IsNull", true).includeTotal(true);
4938
4932
  const invoices = (await this.invoiceService.autoQuery(query)).results || [];
4939
4933
  return this.processReportInvoicesData(reportData, invoices);
@@ -5271,6 +5265,7 @@ var PrintTemplateService = class extends AppRemoteService {
5271
5265
  const templateData = new TemplateData();
5272
5266
  templateData.invoice = invoice;
5273
5267
  templateData.config = config;
5268
+ templateData.normalized_printed_at = humanizedData(templateData.printed_at, config?.order?.datetime_format);
5274
5269
  templateData.printer_name = options.printer_name;
5275
5270
  if (options.is_cancel) templateData.is_cancel = options.is_cancel;
5276
5271
  printCommand.items.push(...await this.renderPrintCommand(template.header, templateData));
@@ -5283,6 +5278,7 @@ var PrintTemplateService = class extends AppRemoteService {
5283
5278
  const templateData = new TemplateData();
5284
5279
  templateData.report_data = reportData;
5285
5280
  templateData.config = config;
5281
+ templateData.normalized_printed_at = humanizedData(templateData.printed_at, config?.order?.datetime_format);
5286
5282
  printCommand.codepage = template.codepage || Codepages.SimplifiedChinese;
5287
5283
  printCommand.items.push(...await this.renderPrintCommand(template.header, templateData));
5288
5284
  printCommand.items.push(...await this.renderPrintCommand(template.body, 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posx/core",
3
- "version": "5.5.330",
3
+ "version": "5.5.332",
4
4
  "description": "POSX core libraries",
5
5
  "main": "./build/index.js",
6
6
  "author": "Steven Lee",
@@ -19,7 +19,7 @@
19
19
  "buffer": "6.0.3",
20
20
  "crypto-browserify": "3.12.0",
21
21
  "crypto-js": "4.2.0",
22
- "dayjs": "1.11.10",
22
+ "dayjs": "^1.11.10",
23
23
  "dexie": "3.2.4",
24
24
  "esc-pos-encoder-ionic": "1.1.3",
25
25
  "handlebars": "4.7.8",
@@ -1,120 +1,120 @@
1
- {
2
- "name": "@posx/core",
3
- "version": "5.5.330",
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.332",
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
+ })