kei-lisp-plugin-graphics 3.0.1 → 4.0.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.
package/dist/index.d.ts CHANGED
@@ -5,8 +5,15 @@ import { Cons, InterpretedSymbol, KeiLispPlugin, LispValue, PluginContext } from
5
5
  * @class
6
6
  * @classdesc Canvas2D drawing plugin for the kei-lisp interpreter. Implements
7
7
  * the `KeiLispPlugin` contract (`name` / `has` / `apply`) and
8
- * exposes 75 `g…` Lisp functions (plus two deprecated aliases)
9
- * that proxy to a 2D rendering context.
8
+ * exposes 75 `g…` Lisp functions that proxy to a 2D rendering
9
+ * context. Failures (wrong arity,
10
+ * type mismatch, closed canvas, canvas-level errors) signal an
11
+ * `EvalError` that Lisp callers can intercept with
12
+ * `(handler-case … (eval-error (e) …))`. Two exceptions still go
13
+ * to `process.stderr` as diagnostics: asynchronous work (image
14
+ * loading, OffscreenCanvas file writes), which fails after the
15
+ * call has returned, and `selectColor`'s best-effort color
16
+ * parsing, which falls back to black instead of failing.
10
17
  * @author Keisuke Ikeda
11
18
  */
12
19
  declare class GraphicsPlugin implements KeiLispPlugin {
@@ -40,37 +47,29 @@ declare class GraphicsPlugin implements KeiLispPlugin {
40
47
  * @param aSymbol - the call symbol
41
48
  * @param arguments_ - the evaluated argument list
42
49
  * @param _context - the interpreter context (unused by this plugin)
43
- * @return the method's result, or `Cons.nil` if dispatch fails
50
+ * @return the method's result
44
51
  */
45
52
  apply(aSymbol: InterpretedSymbol, arguments_: Cons, _context: PluginContext): LispValue;
46
- /**
47
- * Checks whether the canvas exposes a usable 2D context, and narrows
48
- * `this.ctx` to non-null for the caller when it returns true.
49
- * @return type predicate — true when context is non-null
50
- */
51
- checkSupport(): this is GraphicsPlugin & {
52
- ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
53
- };
54
53
  gAlpha(arguments_: Cons): LispValue;
55
54
  gArc(arguments_: Cons): LispValue;
56
55
  gArcTo(arguments_: Cons): LispValue;
57
56
  gBezCurveTo(arguments_: Cons): LispValue;
58
57
  gClear(arguments_: Cons): LispValue;
59
- gClose(): LispValue;
58
+ gClose(arguments_?: Cons): LispValue;
60
59
  gColor(arguments_: Cons): LispValue;
61
- gFill(): LispValue;
60
+ gFill(arguments_?: Cons): LispValue;
62
61
  gFillColor(arguments_: Cons): LispValue;
63
62
  gFillRect(arguments_: Cons): LispValue;
64
63
  gFillText(arguments_: Cons): LispValue;
65
64
  gFillTri(arguments_: Cons): LispValue;
66
- gFinishPath(): LispValue;
65
+ gFinishPath(arguments_?: Cons): LispValue;
67
66
  gImage(arguments_: Cons): LispValue;
68
67
  gLineTo(arguments_: Cons): LispValue;
69
68
  gLineCap(arguments_: Cons): LispValue;
70
69
  gLineJoin(arguments_: Cons): LispValue;
71
70
  gLineWidth(arguments_: Cons): LispValue;
72
71
  gMoveTo(arguments_: Cons): LispValue;
73
- gOpen(): LispValue;
72
+ gOpen(arguments_?: Cons): LispValue;
74
73
  gPattern(arguments_: Cons): LispValue;
75
74
  gQuadCurveTo(arguments_: Cons): LispValue;
76
75
  gSaveJpeg(arguments_: Cons): LispValue;
@@ -82,7 +81,7 @@ declare class GraphicsPlugin implements KeiLispPlugin {
82
81
  * @param arguments_ - the evaluated argument list (empty, or one path string)
83
82
  * @param mimeType - the image MIME type to encode
84
83
  * @param label - the format name used in diagnostics ("jpeg" / "png")
85
- * @return `t` on success, `Cons.nil` otherwise
84
+ * @return `t` on success
86
85
  */
87
86
  saveCanvas(arguments_: Cons, mimeType: string, label: string): LispValue;
88
87
  gScale(arguments_: Cons): LispValue;
@@ -91,8 +90,8 @@ declare class GraphicsPlugin implements KeiLispPlugin {
91
90
  gShadowOffsetX(arguments_: Cons): LispValue;
92
91
  gShadowOffsetY(arguments_: Cons): LispValue;
93
92
  gSleep(arguments_: Cons): LispValue;
94
- gStartPath(): LispValue;
95
- gStroke(): LispValue;
93
+ gStartPath(arguments_?: Cons): LispValue;
94
+ gStroke(arguments_?: Cons): LispValue;
96
95
  gStrokeColor(arguments_: Cons): LispValue;
97
96
  gStrokeRect(arguments_: Cons): LispValue;
98
97
  gStrokeText(arguments_: Cons): LispValue;
@@ -110,26 +109,26 @@ declare class GraphicsPlugin implements KeiLispPlugin {
110
109
  * state explicitly. Replaces the legacy per-method `context.save()` calls, which
111
110
  * pushed state on every draw with no matching `restore()` and grew the stack
112
111
  * unbounded.
113
- * @return `t` on success, `Cons.nil` otherwise
112
+ * @return `t` on success
114
113
  */
115
- gSave(): LispValue;
114
+ gSave(arguments_?: Cons): LispValue;
116
115
  /**
117
116
  * Pops the most recently saved drawing state off the context's state stack.
118
117
  * Pairs with `gSave`. Popping an empty stack is a no-op per the Canvas spec.
119
- * @return `t` on success, `Cons.nil` otherwise
118
+ * @return `t` on success
120
119
  */
121
- gRestore(): LispValue;
120
+ gRestore(arguments_?: Cons): LispValue;
122
121
  gEllipse(arguments_: Cons): LispValue;
123
122
  gRoundRect(arguments_: Cons): LispValue;
124
123
  gLineDash(arguments_: Cons): LispValue;
125
124
  gLineDashOffset(arguments_: Cons): LispValue;
126
125
  gMiterLimit(arguments_: Cons): LispValue;
127
- gClip(): LispValue;
126
+ gClip(arguments_?: Cons): LispValue;
128
127
  gIsPointInPath(arguments_: Cons): LispValue;
129
128
  gIsPointInStroke(arguments_: Cons): LispValue;
130
129
  gTransform(arguments_: Cons): LispValue;
131
130
  gSetTransform(arguments_: Cons): LispValue;
132
- gResetTransform(): LispValue;
131
+ gResetTransform(arguments_?: Cons): LispValue;
133
132
  gComposite(arguments_: Cons): LispValue;
134
133
  gFilter(arguments_: Cons): LispValue;
135
134
  gImageSmoothing(arguments_: Cons): LispValue;
@@ -141,9 +140,9 @@ declare class GraphicsPlugin implements KeiLispPlugin {
141
140
  gFontVariant(arguments_: Cons): LispValue;
142
141
  gTextRendering(arguments_: Cons): LispValue;
143
142
  gClearRect(arguments_: Cons): LispValue;
144
- gReset(): LispValue;
145
- gWidth(): LispValue;
146
- gHeight(): LispValue;
143
+ gReset(arguments_?: Cons): LispValue;
144
+ gWidth(arguments_?: Cons): LispValue;
145
+ gHeight(arguments_?: Cons): LispValue;
147
146
  gPixel(arguments_: Cons): LispValue;
148
147
  gSetPixel(arguments_: Cons): LispValue;
149
148
  gLinearGradient(arguments_: Cons): LispValue;
@@ -152,7 +151,8 @@ declare class GraphicsPlugin implements KeiLispPlugin {
152
151
  /**
153
152
  * Parses a color spec from the head of the argument Cons. Accepts
154
153
  * (1 string), (3 numbers — rgb), or (4 numbers — rgba); falls back to
155
- * `'black'` on anything else (legacy behavior).
154
+ * `'black'` on anything else (legacy behavior — a best-effort color parse
155
+ * that prints a diagnostic instead of signaling an error).
156
156
  * @param arguments_ - the argument Cons to parse
157
157
  * @return CSS color string
158
158
  */