@mylasertools/kerfscript 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/CLA.md +8 -5
  3. package/COMMERCIAL-LICENSE.md +23 -28
  4. package/LANGUAGE.md +194 -60
  5. package/README.md +89 -39
  6. package/THIRD-PARTY-NOTICES.md +68 -4
  7. package/TRADEMARKS.md +16 -10
  8. package/dist/cli.js +773 -297
  9. package/dist/evaluator.d.cts +26 -0
  10. package/dist/evaluator.d.ts +26 -0
  11. package/dist/export/dxf.d.cts +1 -1
  12. package/dist/export/dxf.d.ts +1 -1
  13. package/dist/export/svg.d.cts +2 -0
  14. package/dist/export/svg.d.ts +2 -0
  15. package/dist/font.d.cts +3 -0
  16. package/dist/font.d.ts +3 -0
  17. package/dist/functions.d.cts +21 -2
  18. package/dist/functions.d.ts +21 -2
  19. package/dist/index.cjs +14 -14
  20. package/dist/index.d.cts +2 -2
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +14 -14
  23. package/dist/lexer.d.cts +4 -1
  24. package/dist/lexer.d.ts +4 -1
  25. package/dist/parser.d.cts +1 -1
  26. package/dist/parser.d.ts +1 -1
  27. package/dist/render.d.cts +3 -2
  28. package/dist/render.d.ts +3 -2
  29. package/dist/values.d.cts +10 -2
  30. package/dist/values.d.ts +10 -2
  31. package/dist/wasm.d.cts +1 -0
  32. package/dist/wasm.d.ts +1 -0
  33. package/docs/cli.md +69 -28
  34. package/docs/compatibility.md +40 -65
  35. package/docs/customizer.md +40 -28
  36. package/docs/desktop.md +96 -0
  37. package/docs/getting-started.md +48 -31
  38. package/docs/javascript.md +108 -51
  39. package/docs/kerf.md +36 -39
  40. package/docs/layers.md +71 -37
  41. package/docs/openscad.md +52 -48
  42. package/docs/parts-and-sheets.md +45 -31
  43. package/docs/versions.md +20 -30
  44. package/docs/webassembly.md +131 -0
  45. package/fonts/OFL.txt +92 -0
  46. package/package.json +10 -6
@@ -14,7 +14,19 @@ export interface EvalOptions {
14
14
  resolve?: (path: string) => string | undefined;
15
15
  fonts?: FontBook;
16
16
  maxSteps?: number;
17
+ limits?: Partial<Limits>;
17
18
  }
19
+ export interface Limits {
20
+ maxParts: number;
21
+ maxSegments: number;
22
+ maxListLength: number;
23
+ maxListItems: number;
24
+ maxTextLength: number;
25
+ maxPoints: number;
26
+ maxOutputPoints: number;
27
+ maxSheets: number;
28
+ }
29
+ export declare const DEFAULT_LIMITS: Limits;
18
30
  interface ModDef {
19
31
  params: Param[];
20
32
  body: Stmt[];
@@ -63,6 +75,10 @@ export declare class Evaluator {
63
75
  private steps;
64
76
  private depth;
65
77
  private maxSteps;
78
+ readonly limits: Limits;
79
+ private pointCount;
80
+ private itemCount;
81
+ private copies;
66
82
  readonly echoes: string[];
67
83
  readonly warnings: string[];
68
84
  readonly layers: Map<string, LayerDef>;
@@ -73,6 +89,7 @@ export declare class Evaluator {
73
89
  private tick;
74
90
  private load;
75
91
  private hoist;
92
+ private included;
76
93
  private assign;
77
94
  block(stmts: Stmt[], env: Env, top?: boolean): Shape;
78
95
  private stmt;
@@ -81,13 +98,19 @@ export declare class Evaluator {
81
98
  private loop;
82
99
  private evalArgs;
83
100
  private bindParams;
101
+ private unknownArg;
102
+ private warn;
84
103
  private callModule;
85
104
  private childStmts;
86
105
  callFunction(f: FnDef | Closure, args: Args, caller: Env, name: string): Value;
87
106
  expr(x: Expr, env: Env): Value;
88
107
  private listItem;
108
+ private grow;
109
+ private charge;
89
110
  private call;
90
111
  private specialFunction;
112
+ private assert;
113
+ private echo;
91
114
  private echoText;
92
115
  private arith;
93
116
  private arg;
@@ -95,6 +118,9 @@ export declare class Evaluator {
95
118
  private vec2;
96
119
  private points;
97
120
  private dyn;
121
+ private spend;
122
+ private checkValue;
123
+ private checkSize;
98
124
  private segs;
99
125
  private thickness;
100
126
  private fingerWidth;
@@ -14,7 +14,19 @@ export interface EvalOptions {
14
14
  resolve?: (path: string) => string | undefined;
15
15
  fonts?: FontBook;
16
16
  maxSteps?: number;
17
+ limits?: Partial<Limits>;
17
18
  }
19
+ export interface Limits {
20
+ maxParts: number;
21
+ maxSegments: number;
22
+ maxListLength: number;
23
+ maxListItems: number;
24
+ maxTextLength: number;
25
+ maxPoints: number;
26
+ maxOutputPoints: number;
27
+ maxSheets: number;
28
+ }
29
+ export declare const DEFAULT_LIMITS: Limits;
18
30
  interface ModDef {
19
31
  params: Param[];
20
32
  body: Stmt[];
@@ -63,6 +75,10 @@ export declare class Evaluator {
63
75
  private steps;
64
76
  private depth;
65
77
  private maxSteps;
78
+ readonly limits: Limits;
79
+ private pointCount;
80
+ private itemCount;
81
+ private copies;
66
82
  readonly echoes: string[];
67
83
  readonly warnings: string[];
68
84
  readonly layers: Map<string, LayerDef>;
@@ -73,6 +89,7 @@ export declare class Evaluator {
73
89
  private tick;
74
90
  private load;
75
91
  private hoist;
92
+ private included;
76
93
  private assign;
77
94
  block(stmts: Stmt[], env: Env, top?: boolean): Shape;
78
95
  private stmt;
@@ -81,13 +98,19 @@ export declare class Evaluator {
81
98
  private loop;
82
99
  private evalArgs;
83
100
  private bindParams;
101
+ private unknownArg;
102
+ private warn;
84
103
  private callModule;
85
104
  private childStmts;
86
105
  callFunction(f: FnDef | Closure, args: Args, caller: Env, name: string): Value;
87
106
  expr(x: Expr, env: Env): Value;
88
107
  private listItem;
108
+ private grow;
109
+ private charge;
89
110
  private call;
90
111
  private specialFunction;
112
+ private assert;
113
+ private echo;
91
114
  private echoText;
92
115
  private arith;
93
116
  private arg;
@@ -95,6 +118,9 @@ export declare class Evaluator {
95
118
  private vec2;
96
119
  private points;
97
120
  private dyn;
121
+ private spend;
122
+ private checkValue;
123
+ private checkSize;
98
124
  private segs;
99
125
  private thickness;
100
126
  private fingerWidth;
@@ -1,3 +1,3 @@
1
- import type { LayerDef } from '../evaluator.cjs';
1
+ import { type LayerDef } from '../evaluator.cjs';
2
2
  import type { Placed } from '../render.cjs';
3
3
  export declare function toDxf(items: Placed[], _width: number, height: number, layers: LayerDef[]): string;
@@ -1,3 +1,3 @@
1
- import type { LayerDef } from '../evaluator.js';
1
+ import { type LayerDef } from '../evaluator.js';
2
2
  import type { Placed } from '../render.js';
3
3
  export declare function toDxf(items: Placed[], _width: number, height: number, layers: LayerDef[]): string;
@@ -1,6 +1,8 @@
1
1
  import type { LayerDef } from '../evaluator.cjs';
2
+ import { type Poly } from '../geometry.cjs';
2
3
  import type { Placed } from '../render.cjs';
3
4
  export declare const n: (v: number) => string;
5
+ export declare function tidy(p: Poly, closed: boolean): [string, string][];
4
6
  export interface LayerPath {
5
7
  name: string;
6
8
  mode: LayerDef['mode'];
@@ -1,6 +1,8 @@
1
1
  import type { LayerDef } from '../evaluator.js';
2
+ import { type Poly } from '../geometry.js';
2
3
  import type { Placed } from '../render.js';
3
4
  export declare const n: (v: number) => string;
5
+ export declare function tidy(p: Poly, closed: boolean): [string, string][];
4
6
  export interface LayerPath {
5
7
  name: string;
6
8
  mode: LayerDef['mode'];
@@ -0,0 +1,3 @@
1
+ export declare const BUILTIN_FONT = "Atkinson";
2
+ /** Adds the built-in font after the given fonts, unless one has its name. */
3
+ export declare function withBuiltinFont(fonts: Record<string, Uint8Array>): Record<string, Uint8Array>;
package/dist/font.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare const BUILTIN_FONT = "Atkinson";
2
+ /** Adds the built-in font after the given fonts, unless one has its name. */
3
+ export declare function withBuiltinFont(fonts: Record<string, Uint8Array>): Record<string, Uint8Array>;
@@ -1,4 +1,23 @@
1
1
  import { type Value } from './values.cjs';
2
- type Fn = (args: Value[], named: Map<string, Value>) => Value;
3
- export declare const FUNCTIONS: Record<string, Fn>;
2
+ export interface FnCtx {
3
+ maxLength: number;
4
+ step: (n?: number) => void;
5
+ given: number;
6
+ }
7
+ type Run = (args: Value[], c: FnCtx) => Value;
8
+ export interface Builtin {
9
+ params: string[];
10
+ rest: boolean;
11
+ order?: (n: number) => string[];
12
+ run: Run;
13
+ }
14
+ export declare function givenTwice(f: Builtin, pos: Value[], named: Map<string, Value>): string[];
15
+ export declare function bindArgs(f: Builtin, pos: Value[], named: Map<string, Value>): Value[];
16
+ /**
17
+ * Steps a built-in takes to go through its arguments: one for each item of a
18
+ * list or range and each character of a string. len() of a list is a single
19
+ * step. A range is counted up to just past max, the most items it may hold.
20
+ */
21
+ export declare function argumentWork(name: string, args: Value[], max: number): number;
22
+ export declare const FUNCTIONS: Record<string, Builtin>;
4
23
  export {};
@@ -1,4 +1,23 @@
1
1
  import { type Value } from './values.js';
2
- type Fn = (args: Value[], named: Map<string, Value>) => Value;
3
- export declare const FUNCTIONS: Record<string, Fn>;
2
+ export interface FnCtx {
3
+ maxLength: number;
4
+ step: (n?: number) => void;
5
+ given: number;
6
+ }
7
+ type Run = (args: Value[], c: FnCtx) => Value;
8
+ export interface Builtin {
9
+ params: string[];
10
+ rest: boolean;
11
+ order?: (n: number) => string[];
12
+ run: Run;
13
+ }
14
+ export declare function givenTwice(f: Builtin, pos: Value[], named: Map<string, Value>): string[];
15
+ export declare function bindArgs(f: Builtin, pos: Value[], named: Map<string, Value>): Value[];
16
+ /**
17
+ * Steps a built-in takes to go through its arguments: one for each item of a
18
+ * list or range and each character of a string. len() of a list is a single
19
+ * step. A range is counted up to just past max, the most items it may hold.
20
+ */
21
+ export declare function argumentWork(name: string, args: Value[], max: number): number;
22
+ export declare const FUNCTIONS: Record<string, Builtin>;
4
23
  export {};