@quenk/wml 2.14.1 → 2.15.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/lib/compile/codegen.d.ts +9 -0
- package/lib/compile/codegen.js +45 -3
- package/lib/compile/codegen.js.map +1 -1
- package/lib/compile/codegen.ts +55 -1
- package/lib/parse/ast.d.ts +20 -6
- package/lib/parse/ast.js +25 -8
- package/lib/parse/ast.js.map +1 -1
- package/lib/parse/ast.ts +27 -6
- package/lib/parse/generated.js +2914 -2403
- package/lib/parse/test.js +29 -56
- package/lib/parse/test.js.map +1 -1
- package/lib/parse/test.ts +29 -68
- package/lib/parse/wml.y +59 -19
- package/lib/view/frame.d.ts +43 -31
- package/lib/view/frame.js +10 -55
- package/lib/view/frame.js.map +1 -1
- package/lib/view/frame.ts +69 -62
- package/lib/view/index.d.ts +7 -6
- package/lib/view/index.js +3 -2
- package/lib/view/index.js.map +1 -1
- package/lib/view/index.ts +9 -7
- package/package.json +6 -2
package/lib/view/frame.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.js","sourceRoot":"","sources":["frame.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAE9B,sDAAmD;AAEnD,4CAA4C;AAmB5C;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO;IACX,YACS,QAAmB,EAAE,EACrB,QAA6B,IAAI,GAAG,EAAE;QADtC,UAAK,GAAL,KAAK,CAAgB;QACrB,UAAK,GAAL,KAAK,CAAiC;IAC5C,CAAC;IAEJ,GAAG,CAAC,IAAa;QACf,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5D,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC1B,OAAO,GAAG,CAAC;IACb,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AED,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,KAAI,CAAC;CACb;AA3ID,8BA2IC"}
|
package/lib/view/frame.ts
CHANGED
|
@@ -75,64 +75,85 @@ class SetList {
|
|
|
75
75
|
* renders.
|
|
76
76
|
*
|
|
77
77
|
* Each time the render() method is called a new Frame is created and passed
|
|
78
|
-
* to the rendering logic so that a DOM tree is built along with accesible
|
|
78
|
+
* to the rendering logic so that a DOM tree is built along with accesible
|
|
79
79
|
* wml ids and groups.
|
|
80
80
|
*/
|
|
81
81
|
export interface Frame {
|
|
82
|
+
/**
|
|
83
|
+
* tree when sets is the rendered DOM content of the view
|
|
84
|
+
*/
|
|
85
|
+
tree?: Content;
|
|
82
86
|
|
|
83
87
|
/**
|
|
84
88
|
* root sets the root element of a View's tree.
|
|
85
89
|
*/
|
|
86
|
-
root(el: Content)
|
|
90
|
+
root(el: Content): void;
|
|
87
91
|
|
|
88
92
|
/**
|
|
89
93
|
* node constructs a DOM node to be used in the View's tree.
|
|
90
94
|
*
|
|
91
95
|
* Any id or group assignment will be honored.
|
|
92
96
|
*/
|
|
93
|
-
node(tag: string, attrs: Attrs, children: Content[]): Content
|
|
97
|
+
node(tag: string, attrs: Attrs, children: Content[]): Content;
|
|
94
98
|
|
|
95
99
|
/**
|
|
96
100
|
* widget constructs a DOM sub-tree for a Widget in the View's tree.
|
|
97
101
|
*
|
|
98
102
|
* Any id or group assignment will be honored.
|
|
99
103
|
*/
|
|
100
|
-
widget(w: Widget, attrs: Attrs): Content
|
|
101
|
-
|
|
104
|
+
widget(w: Widget, attrs: Attrs): Content;
|
|
105
|
+
|
|
102
106
|
/**
|
|
103
107
|
* view renders the content of another view, saving its ids and groups to
|
|
104
108
|
* this one.
|
|
105
109
|
*/
|
|
106
|
-
view(view: View): Content
|
|
107
|
-
}
|
|
110
|
+
view(view: View): Content;
|
|
108
111
|
|
|
109
|
-
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
export class MultiFrame implements Frame {
|
|
114
|
-
constructor(public frames: Frame[] = []) {}
|
|
112
|
+
/**
|
|
113
|
+
* register content and widget under the specified id.
|
|
114
|
+
*/
|
|
115
|
+
register(id: WMLId, node: Content, widget?: Widget): void;
|
|
115
116
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
node(tag: string, attrs: Attrs, children: Content[]): Content {
|
|
123
|
-
let results = this.frames.map((f) => f.node(tag, attrs, children));
|
|
124
|
-
return results[0] ?? dom.createElement('div', {}, []);
|
|
125
|
-
}
|
|
117
|
+
/**
|
|
118
|
+
* registerGroupMember registers a content and widget as a member of a group.
|
|
119
|
+
*/
|
|
120
|
+
registerGroupMember(id: WMLId, node: Content, widget?: Widget): void;
|
|
126
121
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
122
|
+
/**
|
|
123
|
+
* findById returns the entry stored for the specified wml element.
|
|
124
|
+
*/
|
|
125
|
+
findById(id: WMLId): Maybe<Entry>;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* findByGroup returns all the entries stored fro a group.
|
|
129
|
+
*/
|
|
130
|
+
findByGroup(id: WMLId): Entry[];
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* replaceByIndex performs the heavy work of replacing a WMLElement
|
|
134
|
+
* with the corresponding index from another ViewFrame.
|
|
135
|
+
*
|
|
136
|
+
* The replaced element will have its DOM content redrawn if a parentNode
|
|
137
|
+
* is detected.
|
|
138
|
+
*/
|
|
139
|
+
replaceByIndex(next: ViewFrame, idx: Index): void;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* replaceById allows WMLElement replacement by using an id.
|
|
143
|
+
*/
|
|
144
|
+
replaceById(next: ViewFrame, id: WMLId): void;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* replaceByGroup allows WMLElement replaced by using a group identifier.
|
|
148
|
+
*/
|
|
149
|
+
replaceByGroup(next: ViewFrame, id: WMLId): void;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* destroy the frame.
|
|
153
|
+
*
|
|
154
|
+
* Currently a no-op but may be used in the future.
|
|
155
|
+
*/
|
|
156
|
+
destroy(): void;
|
|
136
157
|
}
|
|
137
158
|
|
|
138
159
|
/**
|
|
@@ -149,7 +170,7 @@ export class ViewFrame implements Frame {
|
|
|
149
170
|
public tree?: Content,
|
|
150
171
|
) {}
|
|
151
172
|
|
|
152
|
-
|
|
173
|
+
register(id: WMLId, node: Content, widget?: Widget) {
|
|
153
174
|
let idx = this.nodes.add(node);
|
|
154
175
|
this.ids.set(id, idx);
|
|
155
176
|
this.indexes.set(idx, id);
|
|
@@ -158,7 +179,7 @@ export class ViewFrame implements Frame {
|
|
|
158
179
|
}
|
|
159
180
|
}
|
|
160
181
|
|
|
161
|
-
|
|
182
|
+
registerGroupMember(id: WMLId, node: Content, widget?: Widget) {
|
|
162
183
|
let group = this.groups.get(id) ?? [];
|
|
163
184
|
let idx = this.nodes.add(node);
|
|
164
185
|
group.push(idx);
|
|
@@ -172,7 +193,7 @@ export class ViewFrame implements Frame {
|
|
|
172
193
|
this.tree = el;
|
|
173
194
|
}
|
|
174
195
|
|
|
175
|
-
|
|
196
|
+
node(tag: string, attrs: Attrs, children: Content[]): Content {
|
|
176
197
|
let elm = dom.createElement(
|
|
177
198
|
tag,
|
|
178
199
|
<dom.WMLDOMAttrs>attrs,
|
|
@@ -180,35 +201,32 @@ export class ViewFrame implements Frame {
|
|
|
180
201
|
(attrs.wml && attrs.wml.ns) || "",
|
|
181
202
|
);
|
|
182
203
|
|
|
183
|
-
if (attrs?.wml?.id) this.
|
|
204
|
+
if (attrs?.wml?.id) this.register(attrs.wml.id, elm);
|
|
184
205
|
|
|
185
|
-
if (attrs?.wml?.group) this.
|
|
206
|
+
if (attrs?.wml?.group) this.registerGroupMember(attrs.wml.group, elm);
|
|
186
207
|
|
|
187
208
|
return elm;
|
|
188
209
|
}
|
|
189
210
|
|
|
190
|
-
|
|
211
|
+
widget(w: Widget, attrs: Attrs): Content {
|
|
191
212
|
let tree = w.render();
|
|
192
213
|
|
|
193
214
|
DOMMonitor.getInstance().monitor(tree, w);
|
|
194
215
|
|
|
195
|
-
if (attrs?.wml?.id) this.
|
|
216
|
+
if (attrs?.wml?.id) this.register(attrs.wml.id, tree, w);
|
|
196
217
|
|
|
197
|
-
if (attrs?.wml?.group) this.
|
|
218
|
+
if (attrs?.wml?.group) this.registerGroupMember(attrs.wml.group, tree, w);
|
|
198
219
|
|
|
199
220
|
return tree;
|
|
200
221
|
}
|
|
201
222
|
|
|
202
|
-
|
|
223
|
+
view(view: View): Content {
|
|
203
224
|
let { root } = this;
|
|
204
225
|
let tree = view.render(this);
|
|
205
226
|
this.root = root;
|
|
206
227
|
return tree;
|
|
207
228
|
}
|
|
208
229
|
|
|
209
|
-
/**
|
|
210
|
-
* findById returns the entry stored for the specified wml element.
|
|
211
|
-
*/
|
|
212
230
|
findById(id: WMLId): Maybe<Entry> {
|
|
213
231
|
let idx = this.ids.get(id) ?? -1;
|
|
214
232
|
let node = this.nodes.get(idx);
|
|
@@ -219,9 +237,6 @@ export class ViewFrame implements Frame {
|
|
|
219
237
|
});
|
|
220
238
|
}
|
|
221
239
|
|
|
222
|
-
/**
|
|
223
|
-
* findByGroup returns all the entries stored fro a group.
|
|
224
|
-
*/
|
|
225
240
|
findByGroup(id: WMLId): Entry[] {
|
|
226
241
|
let result = [];
|
|
227
242
|
for (let idx of this.groups.get(id) ?? []) {
|
|
@@ -233,19 +248,11 @@ export class ViewFrame implements Frame {
|
|
|
233
248
|
return result;
|
|
234
249
|
}
|
|
235
250
|
|
|
236
|
-
/**
|
|
237
|
-
* replaceByIndex performs the heavy work of replacing a WMLElement
|
|
238
|
-
* with the corresponding index from another ViewFrame.
|
|
239
|
-
*
|
|
240
|
-
* The replaced element will have its DOM content redrawn if a parentNode
|
|
241
|
-
* is detected.
|
|
242
|
-
*/
|
|
243
251
|
replaceByIndex(next: ViewFrame, idx: Index) {
|
|
244
252
|
let originalNode = this.nodes.get(idx);
|
|
245
|
-
let id = this.indexes.get(idx) ?? "";
|
|
246
253
|
|
|
247
254
|
if (idx == null || originalNode == null) {
|
|
248
|
-
console.warn(`Not replacing missing
|
|
255
|
+
console.warn(`Not replacing missing element by index ${idx}!`);
|
|
249
256
|
return;
|
|
250
257
|
}
|
|
251
258
|
|
|
@@ -253,12 +260,16 @@ export class ViewFrame implements Frame {
|
|
|
253
260
|
|
|
254
261
|
let node = next.nodes.get(idx);
|
|
255
262
|
let widget = next.widgets.get(idx);
|
|
263
|
+
|
|
256
264
|
if (node == null) {
|
|
257
265
|
// Remove references since the node no longer exists.
|
|
258
266
|
this.nodes.delete(idx);
|
|
259
267
|
this.widgets.delete(idx);
|
|
268
|
+
|
|
269
|
+
let id = this.indexes.get(idx) ?? "";
|
|
260
270
|
this.ids.delete(id);
|
|
261
271
|
this.indexes.delete(idx);
|
|
272
|
+
|
|
262
273
|
if (parentNode) parentNode.removeChild(originalNode);
|
|
263
274
|
return;
|
|
264
275
|
}
|
|
@@ -271,16 +282,10 @@ export class ViewFrame implements Frame {
|
|
|
271
282
|
if (parentNode) parentNode.replaceChild(node, originalNode);
|
|
272
283
|
}
|
|
273
284
|
|
|
274
|
-
/**
|
|
275
|
-
* replaceById allows WMLElement replacement by using an id.
|
|
276
|
-
*/
|
|
277
285
|
replaceById(next: ViewFrame, id: WMLId) {
|
|
278
286
|
this.replaceByIndex(next, this.ids.get(id) ?? -1);
|
|
279
287
|
}
|
|
280
288
|
|
|
281
|
-
/**
|
|
282
|
-
* replaceByGroup allows WMLElement replaced by using a group identifier.
|
|
283
|
-
*/
|
|
284
289
|
replaceByGroup(next: ViewFrame, id: WMLId) {
|
|
285
290
|
let group = this.groups.get(id) ?? [];
|
|
286
291
|
|
|
@@ -292,4 +297,6 @@ export class ViewFrame implements Frame {
|
|
|
292
297
|
|
|
293
298
|
this.groups.set(id, newGroup);
|
|
294
299
|
}
|
|
300
|
+
|
|
301
|
+
destroy() {}
|
|
295
302
|
}
|
package/lib/view/index.d.ts
CHANGED
|
@@ -15,10 +15,11 @@ export interface View {
|
|
|
15
15
|
/**
|
|
16
16
|
* render the View.
|
|
17
17
|
*
|
|
18
|
-
* If
|
|
19
|
-
*
|
|
18
|
+
* If parent is provided, it is treated as the parent Frame to the internal
|
|
19
|
+
* frame the view will be created. This allows ids from this frame to be
|
|
20
|
+
* accessed in the parent scope.
|
|
20
21
|
*/
|
|
21
|
-
render(
|
|
22
|
+
render(parent?: ViewFrame): Content;
|
|
22
23
|
/**
|
|
23
24
|
* invalidate this View causing the DOM to be re-rendered.
|
|
24
25
|
*
|
|
@@ -49,10 +50,10 @@ export interface View {
|
|
|
49
50
|
export declare class BaseView implements View {
|
|
50
51
|
context: object;
|
|
51
52
|
renderer: Renderer;
|
|
52
|
-
frame:
|
|
53
|
-
constructor(context: object, renderer: Renderer, frame?:
|
|
53
|
+
frame: Frame;
|
|
54
|
+
constructor(context: object, renderer: Renderer, frame?: Frame);
|
|
54
55
|
findById<E extends WMLElement>(id: string): Maybe<E>;
|
|
55
56
|
findGroupById<E extends WMLElement>(name: string): E[];
|
|
56
57
|
invalidate(id?: WMLId): void;
|
|
57
|
-
render(
|
|
58
|
+
render(): Content;
|
|
58
59
|
}
|
package/lib/view/index.js
CHANGED
|
@@ -38,9 +38,10 @@ class BaseView {
|
|
|
38
38
|
frame.tree.parentNode.replaceChild(this.render(), frame.tree);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
render(
|
|
41
|
+
render() {
|
|
42
|
+
this.frame?.destroy();
|
|
42
43
|
this.frame = new frame_1.ViewFrame();
|
|
43
|
-
this.renderer(
|
|
44
|
+
this.renderer(this.frame);
|
|
44
45
|
return this.frame.tree;
|
|
45
46
|
}
|
|
46
47
|
}
|
package/lib/view/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAGA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAGA,mCAAkD;AA+ClD;;;;;GAKG;AACH,MAAa,QAAQ;IACnB,YACS,OAAe,EACf,QAAkB,EAClB,QAAe,IAAI,iBAAS,EAAE;QAF9B,YAAO,GAAP,OAAO,CAAQ;QACf,aAAQ,GAAR,QAAQ,CAAU;QAClB,UAAK,GAAL,KAAK,CAAyB;IACpC,CAAC;IAEJ,QAAQ,CAAuB,EAAU;QACvC,OAAO,IAAI,CAAC,KAAK;aACd,QAAQ,CAAC,EAAE,CAAC;aACZ,GAAG,CAAC,CAAC,GAAU,EAAE,EAAE,CAAI,CAAC,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,aAAa,CAAuB,IAAY;QAC9C,OAAY,CACV,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,CACxE,CAAC;IACJ,CAAC;IAED,UAAU,CAAC,EAAU;QACnB,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAErB,IAAI,KAAK,CAAC,IAAI,IAAI,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI;YACrD,OAAO,OAAO,CAAC,IAAI,CACjB,mEAAmE,CACpE,CAAC;QAEJ,IAAI,EAAE,EAAE,CAAC;YACP,IAAI,IAAI,GAAG,IAAI,iBAAS,EAAE,CAAC;YAC3B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACpB,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG;gBAAE,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;;gBACtD,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,IAAI,iBAAS,EAAE,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,OAAgB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IAClC,CAAC;CACF;AA3CD,4BA2CC"}
|
package/lib/view/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "@quenk/noni/lib/data/maybe";
|
|
2
2
|
|
|
3
3
|
import { Content, WMLElement, WMLId } from "..";
|
|
4
|
-
import { Entry, Frame,
|
|
4
|
+
import { Entry, Frame, ViewFrame } from "./frame";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Renderer is a function that builds up a ViewFrame on behalf of the view.
|
|
@@ -18,10 +18,11 @@ export interface View {
|
|
|
18
18
|
/**
|
|
19
19
|
* render the View.
|
|
20
20
|
*
|
|
21
|
-
* If
|
|
22
|
-
*
|
|
21
|
+
* If parent is provided, it is treated as the parent Frame to the internal
|
|
22
|
+
* frame the view will be created. This allows ids from this frame to be
|
|
23
|
+
* accessed in the parent scope.
|
|
23
24
|
*/
|
|
24
|
-
render(
|
|
25
|
+
render(parent?: ViewFrame): Content;
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* invalidate this View causing the DOM to be re-rendered.
|
|
@@ -57,7 +58,7 @@ export class BaseView implements View {
|
|
|
57
58
|
constructor(
|
|
58
59
|
public context: object,
|
|
59
60
|
public renderer: Renderer,
|
|
60
|
-
public frame = new ViewFrame(),
|
|
61
|
+
public frame: Frame = new ViewFrame(),
|
|
61
62
|
) {}
|
|
62
63
|
|
|
63
64
|
findById<E extends WMLElement>(id: string): Maybe<E> {
|
|
@@ -90,9 +91,10 @@ export class BaseView implements View {
|
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
render(
|
|
94
|
+
render(): Content {
|
|
95
|
+
this.frame?.destroy();
|
|
94
96
|
this.frame = new ViewFrame();
|
|
95
|
-
this.renderer(
|
|
97
|
+
this.renderer(this.frame);
|
|
96
98
|
return <Content>this.frame.tree;
|
|
97
99
|
}
|
|
98
100
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenk/wml",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0",
|
|
4
4
|
"description": "(WML) is a DSL for describing user interfaces in web applications.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "./node_modules/.bin/
|
|
7
|
+
"test": "./node_modules/.bin/jest test"
|
|
8
8
|
},
|
|
9
9
|
"types": "lib/index.d.ts",
|
|
10
10
|
"files": [
|
|
@@ -16,13 +16,17 @@
|
|
|
16
16
|
"author": "Quenk Technologies Limited <info@quenk.com> (https://quenk.com)",
|
|
17
17
|
"license": "Apache-2.0",
|
|
18
18
|
"devDependencies": {
|
|
19
|
+
"@jest/globals": "^30.2.0",
|
|
19
20
|
"@quenk/test": "^2.4.0",
|
|
20
21
|
"@types/docopt": "^0.6.31",
|
|
22
|
+
"@types/jest": "^30.0.0",
|
|
21
23
|
"@types/mocha": "^8.2.2",
|
|
22
24
|
"@types/node": "^24.3.0",
|
|
25
|
+
"jest": "^30.2.0",
|
|
23
26
|
"jison-gho": "^0.6.1-216",
|
|
24
27
|
"mocha": "^9.0.0",
|
|
25
28
|
"prettier": "^3.5.3",
|
|
29
|
+
"ts-jest": "^29.4.6",
|
|
26
30
|
"ts-node": "^10.5.0",
|
|
27
31
|
"typescript": "^5.9.2"
|
|
28
32
|
},
|