@mylasertools/kerfscript 0.4.0 → 0.6.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 (68) hide show
  1. package/CHANGELOG.md +125 -1
  2. package/LANGUAGE.md +26 -11
  3. package/README.md +79 -5
  4. package/dist/ast.d.cts +13 -1
  5. package/dist/ast.d.ts +13 -1
  6. package/dist/cli.js +7509 -1629
  7. package/dist/diagnostics.d.cts +6 -0
  8. package/dist/diagnostics.d.ts +6 -0
  9. package/dist/evaluator.d.cts +12 -0
  10. package/dist/evaluator.d.ts +12 -0
  11. package/dist/format.d.cts +4 -0
  12. package/dist/format.d.ts +4 -0
  13. package/dist/highlight.cjs +151 -0
  14. package/dist/highlight.d.cts +13 -0
  15. package/dist/highlight.d.ts +13 -0
  16. package/dist/highlight.js +131 -0
  17. package/dist/import/dbg.d.cts +1 -0
  18. package/dist/import/dbg.d.ts +1 -0
  19. package/dist/import/index.d.cts +16 -0
  20. package/dist/import/index.d.ts +16 -0
  21. package/dist/import/shapes.d.cts +76 -0
  22. package/dist/import/shapes.d.ts +76 -0
  23. package/dist/import/svg.d.cts +48 -0
  24. package/dist/import/svg.d.ts +48 -0
  25. package/dist/import/xml.d.cts +12 -0
  26. package/dist/import/xml.d.ts +12 -0
  27. package/dist/index.cjs +391 -13
  28. package/dist/index.d.cts +7 -3
  29. package/dist/index.d.ts +7 -3
  30. package/dist/index.js +391 -13
  31. package/dist/language.cjs +417 -0
  32. package/dist/language.d.cts +143 -0
  33. package/dist/language.d.ts +143 -0
  34. package/dist/language.js +417 -0
  35. package/dist/lexer.d.cts +17 -0
  36. package/dist/lexer.d.ts +17 -0
  37. package/dist/libraries.cjs +380 -0
  38. package/dist/libraries.d.cts +112 -0
  39. package/dist/libraries.d.ts +112 -0
  40. package/dist/libraries.js +380 -0
  41. package/dist/lsp.d.cts +12 -0
  42. package/dist/lsp.d.ts +12 -0
  43. package/dist/paths.d.cts +1 -1
  44. package/dist/paths.d.ts +1 -1
  45. package/dist/signatures.cjs +675 -0
  46. package/dist/signatures.d.cts +20 -0
  47. package/dist/signatures.d.ts +20 -0
  48. package/dist/signatures.js +655 -0
  49. package/docs/cli.md +54 -2
  50. package/docs/desktop.md +5 -0
  51. package/docs/editors.md +121 -0
  52. package/docs/import.md +149 -0
  53. package/docs/javascript.md +177 -10
  54. package/docs/kerf.md +10 -0
  55. package/docs/library/box.svg +11 -0
  56. package/docs/library/calibration.svg +11 -0
  57. package/docs/library/dividers.svg +11 -0
  58. package/docs/library/enclosure.svg +11 -0
  59. package/docs/library/hanging.svg +11 -0
  60. package/docs/library/hinge.svg +11 -0
  61. package/docs/library/tabs.svg +11 -0
  62. package/docs/library.md +339 -0
  63. package/docs/mcp.md +88 -0
  64. package/docs/openscad.md +1 -1
  65. package/docs/shared-libraries.md +229 -0
  66. package/docs/specification.md +529 -0
  67. package/docs/versions.md +2 -2
  68. package/package.json +52 -6
@@ -0,0 +1,143 @@
1
+ import { type Parameter } from './customizer.cjs';
2
+ import { type RenderOptions } from './render.cjs';
3
+ import { type Signature } from './signatures.cjs';
4
+ export type NameKind = 'variable' | 'function' | 'module' | 'parameter';
5
+ export interface Definition {
6
+ name: string;
7
+ kind: NameKind;
8
+ start: number;
9
+ end: number;
10
+ range: [number, number];
11
+ file?: string;
12
+ value?: string;
13
+ doc?: string;
14
+ params?: Definition[];
15
+ owner?: Definition;
16
+ }
17
+ export interface Reference {
18
+ name: string;
19
+ start: number;
20
+ end: number;
21
+ def?: Definition;
22
+ builtin?: Signature;
23
+ arg?: string;
24
+ }
25
+ export interface Scope {
26
+ start: number;
27
+ end: number;
28
+ parent?: Scope;
29
+ vars: Map<string, Definition[]>;
30
+ fns: Map<string, Definition[]>;
31
+ mods: Map<string, Definition[]>;
32
+ }
33
+ export interface LibraryLink {
34
+ path: string;
35
+ include: boolean;
36
+ start: number;
37
+ end: number;
38
+ found: boolean;
39
+ }
40
+ export interface Analysis {
41
+ source: string;
42
+ parsed: boolean;
43
+ definitions: Definition[];
44
+ references: Reference[];
45
+ scopes: Scope[];
46
+ libraries: LibraryLink[];
47
+ available: string[];
48
+ settings: Parameter[];
49
+ }
50
+ export interface AnalyzeOptions {
51
+ resolve?: (path: string) => string | undefined;
52
+ libraries?: string[];
53
+ }
54
+ /** Reads a program for an editor: its names, scopes and libraries. Works on
55
+ * programs that do not parse, leaving out the lines with errors. */
56
+ export declare function analyze(source: string, options?: AnalyzeOptions): Analysis;
57
+ /** The definition of the name at an offset: in the program, or in a
58
+ * library when it has `file`. */
59
+ export declare function definition(a: Analysis, offset: number): Definition | undefined;
60
+ /** Every place in the program a name is defined and used, for the name at
61
+ * an offset. Assignments to the same variable in the same scope count as
62
+ * one name. */
63
+ export declare function references(a: Analysis, offset: number, includeDefinitions?: boolean): {
64
+ start: number;
65
+ end: number;
66
+ definition: boolean;
67
+ }[];
68
+ /** Where the name at an offset can be renamed, or why it cannot. */
69
+ export declare function renameTarget(a: Analysis, offset: number): {
70
+ start: number;
71
+ end: number;
72
+ name: string;
73
+ } | {
74
+ error: string;
75
+ };
76
+ /** The edits that rename the name at an offset, or why it cannot be. */
77
+ export declare function rename(a: Analysis, offset: number, name: string): {
78
+ start: number;
79
+ end: number;
80
+ }[] | {
81
+ error: string;
82
+ };
83
+ export interface Hover {
84
+ start: number;
85
+ end: number;
86
+ text: string;
87
+ }
88
+ /** What the name or library path at an offset is, as Markdown. */
89
+ export declare function hover(a: Analysis, offset: number, options?: Pick<AnalyzeOptions, 'resolve'>): Hover | undefined;
90
+ export type CompletionKind = 'module' | 'function' | 'variable' | 'parameter' | 'argument' | 'keyword' | 'constant' | 'library' | 'property';
91
+ export interface Completion {
92
+ label: string;
93
+ kind: CompletionKind;
94
+ detail?: string;
95
+ doc?: string;
96
+ insert?: string;
97
+ first?: boolean;
98
+ builtin?: boolean;
99
+ }
100
+ /** What can be typed at an offset. The items replace the source from
101
+ * `from` to `to`. */
102
+ export declare function complete(a: Analysis, offset: number): {
103
+ from: number;
104
+ to: number;
105
+ items: Completion[];
106
+ };
107
+ export interface SignatureHelp {
108
+ label: string;
109
+ doc?: string;
110
+ params: {
111
+ start: number;
112
+ end: number;
113
+ doc?: string;
114
+ }[];
115
+ active: number;
116
+ }
117
+ /** The parameters of the call being typed at an offset. */
118
+ export declare function signatureHelp(a: Analysis, offset: number): SignatureHelp | undefined;
119
+ export interface OutlineItem {
120
+ name: string;
121
+ kind: 'module' | 'function' | 'variable';
122
+ detail?: string;
123
+ range: [number, number];
124
+ start: number;
125
+ end: number;
126
+ children: OutlineItem[];
127
+ }
128
+ /** The program's modules, functions and assignments, nested as written. */
129
+ export declare function outline(a: Analysis): OutlineItem[];
130
+ export interface Problem {
131
+ severity: 'error' | 'warning';
132
+ message: string;
133
+ start: number;
134
+ end: number;
135
+ related?: {
136
+ message: string;
137
+ start: number;
138
+ end: number;
139
+ }[];
140
+ }
141
+ /** Runs the program and returns its errors and warnings with where they
142
+ * are. Takes render()'s options, such as resolve and fonts. */
143
+ export declare function problems(source: string, options?: RenderOptions): Problem[];
@@ -0,0 +1,143 @@
1
+ import { type Parameter } from './customizer.js';
2
+ import { type RenderOptions } from './render.js';
3
+ import { type Signature } from './signatures.js';
4
+ export type NameKind = 'variable' | 'function' | 'module' | 'parameter';
5
+ export interface Definition {
6
+ name: string;
7
+ kind: NameKind;
8
+ start: number;
9
+ end: number;
10
+ range: [number, number];
11
+ file?: string;
12
+ value?: string;
13
+ doc?: string;
14
+ params?: Definition[];
15
+ owner?: Definition;
16
+ }
17
+ export interface Reference {
18
+ name: string;
19
+ start: number;
20
+ end: number;
21
+ def?: Definition;
22
+ builtin?: Signature;
23
+ arg?: string;
24
+ }
25
+ export interface Scope {
26
+ start: number;
27
+ end: number;
28
+ parent?: Scope;
29
+ vars: Map<string, Definition[]>;
30
+ fns: Map<string, Definition[]>;
31
+ mods: Map<string, Definition[]>;
32
+ }
33
+ export interface LibraryLink {
34
+ path: string;
35
+ include: boolean;
36
+ start: number;
37
+ end: number;
38
+ found: boolean;
39
+ }
40
+ export interface Analysis {
41
+ source: string;
42
+ parsed: boolean;
43
+ definitions: Definition[];
44
+ references: Reference[];
45
+ scopes: Scope[];
46
+ libraries: LibraryLink[];
47
+ available: string[];
48
+ settings: Parameter[];
49
+ }
50
+ export interface AnalyzeOptions {
51
+ resolve?: (path: string) => string | undefined;
52
+ libraries?: string[];
53
+ }
54
+ /** Reads a program for an editor: its names, scopes and libraries. Works on
55
+ * programs that do not parse, leaving out the lines with errors. */
56
+ export declare function analyze(source: string, options?: AnalyzeOptions): Analysis;
57
+ /** The definition of the name at an offset: in the program, or in a
58
+ * library when it has `file`. */
59
+ export declare function definition(a: Analysis, offset: number): Definition | undefined;
60
+ /** Every place in the program a name is defined and used, for the name at
61
+ * an offset. Assignments to the same variable in the same scope count as
62
+ * one name. */
63
+ export declare function references(a: Analysis, offset: number, includeDefinitions?: boolean): {
64
+ start: number;
65
+ end: number;
66
+ definition: boolean;
67
+ }[];
68
+ /** Where the name at an offset can be renamed, or why it cannot. */
69
+ export declare function renameTarget(a: Analysis, offset: number): {
70
+ start: number;
71
+ end: number;
72
+ name: string;
73
+ } | {
74
+ error: string;
75
+ };
76
+ /** The edits that rename the name at an offset, or why it cannot be. */
77
+ export declare function rename(a: Analysis, offset: number, name: string): {
78
+ start: number;
79
+ end: number;
80
+ }[] | {
81
+ error: string;
82
+ };
83
+ export interface Hover {
84
+ start: number;
85
+ end: number;
86
+ text: string;
87
+ }
88
+ /** What the name or library path at an offset is, as Markdown. */
89
+ export declare function hover(a: Analysis, offset: number, options?: Pick<AnalyzeOptions, 'resolve'>): Hover | undefined;
90
+ export type CompletionKind = 'module' | 'function' | 'variable' | 'parameter' | 'argument' | 'keyword' | 'constant' | 'library' | 'property';
91
+ export interface Completion {
92
+ label: string;
93
+ kind: CompletionKind;
94
+ detail?: string;
95
+ doc?: string;
96
+ insert?: string;
97
+ first?: boolean;
98
+ builtin?: boolean;
99
+ }
100
+ /** What can be typed at an offset. The items replace the source from
101
+ * `from` to `to`. */
102
+ export declare function complete(a: Analysis, offset: number): {
103
+ from: number;
104
+ to: number;
105
+ items: Completion[];
106
+ };
107
+ export interface SignatureHelp {
108
+ label: string;
109
+ doc?: string;
110
+ params: {
111
+ start: number;
112
+ end: number;
113
+ doc?: string;
114
+ }[];
115
+ active: number;
116
+ }
117
+ /** The parameters of the call being typed at an offset. */
118
+ export declare function signatureHelp(a: Analysis, offset: number): SignatureHelp | undefined;
119
+ export interface OutlineItem {
120
+ name: string;
121
+ kind: 'module' | 'function' | 'variable';
122
+ detail?: string;
123
+ range: [number, number];
124
+ start: number;
125
+ end: number;
126
+ children: OutlineItem[];
127
+ }
128
+ /** The program's modules, functions and assignments, nested as written. */
129
+ export declare function outline(a: Analysis): OutlineItem[];
130
+ export interface Problem {
131
+ severity: 'error' | 'warning';
132
+ message: string;
133
+ start: number;
134
+ end: number;
135
+ related?: {
136
+ message: string;
137
+ start: number;
138
+ end: number;
139
+ }[];
140
+ }
141
+ /** Runs the program and returns its errors and warnings with where they
142
+ * are. Takes render()'s options, such as resolve and fonts. */
143
+ export declare function problems(source: string, options?: RenderOptions): Problem[];