3 Commits
0.2 ... main

Author SHA1 Message Date
2bf158508a 版本号更新 2025-07-31 10:17:51 +08:00
32072e12a6 导出ProcessItem 2025-07-31 10:16:19 +08:00
fa5c87d35a 更新Readme.md 2025-07-31 09:43:36 +08:00
3 changed files with 58 additions and 2 deletions

View File

@@ -95,3 +95,58 @@ pnpm clean
pnpm build
pnpm release
```
## 开发
### 处理器类型
处理器的上下文类型应当提交至该项目以方便协作,包括处理器输入,输出以及配置类型。
这些类型应当定义在`src/models/processors/<处理器名>.ts`文件中。
例:
```ts
// src/models/processors/rectLayout.ts
// 矩形优化处理器类型
export interface RectLayoutProcInput {
blocks: Array<RectLayoutBlock>
}
export type RectLayoutProcOutput = never;
export class RectLayoutProcConfig extends ConfigBase {}
export interface RectLayoutBlock {}
```
定义类型时请遵循以下约定:
- 处理器的输入/输出/配置类型(以下称为*相关类型*)请按照特定规则进行命名,其大小写应当遵循[PascalCase](https://pascal-case.com/)
- 输入类型: `<处理器名>Input`
- 输出类型: `<处理器名>Output`
- 配置类型: `<处理器名>Config`
- 处理器的配置类型必须为一个Javascript类并继承自抽象类`ConfigBase`,输入和输出类型不限。
- 处理器相关类型的字段若涉及到附属类型,也一并定义在文件中,其命名不限,但必须与处理器的名字有所关联,不易于其它处理器混淆,例:
```ts
export interface RectLayoutProcInput {
blocks: Array<RectLayoutBlock> // 附属类型
}
// 同样定义在该文件中,
export interface RectLayoutBlock {}
```
- 若处理器相关类型中出现了唯一标识符,请统一使用`string | number`作为Typescript类型
```ts
export interface RectLayoutBlock {
id: string | number; // 使用string | number类型作为唯一标识符
}
```
- 若处理器相关类型中出现了平面尺寸相关的,请使用“长(`length`)/宽(`width`)”作为其名称,请勿使用“宽(`width`)/高(`height`)”。
> [!Warning]
> “长”指的是一个矩形板件在**横轴**上的尺寸,而“宽”指的是**纵轴**上的尺寸。
>
> 在旧版生产的数据中,“长/宽”与“宽/高”是混用的,在矩形优化后,原有板件的“长(l)”变为了“高(pbg)”,而“宽(w)”变为了“宽(pbk)”,因为矩形优化涉及到了坐标转换,后续还需要对规范进行统一。

View File

@@ -1,6 +1,6 @@
{
"name": "cut-abstractions",
"version": "0.2.0",
"version": "0.2.1",
"description": "",
"files": [
"dist/**/*"

View File

@@ -4,4 +4,5 @@ export * from './models/config';
export * from './models/knife';
export * from './models/file';
export * from './models/processors/rectLayout';
export * from './models/processors/cutOrder'
export * from './models/processors/cutOrder';
export * from './models/processItem';