@quenk/wml 2.14.1 → 2.15.1

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/view/frame.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ViewFrame = exports.MultiFrame = void 0;
3
+ exports.ViewFrame = void 0;
4
4
  const dom = require("../dom");
5
5
  const maybe_1 = require("@quenk/noni/lib/data/maybe");
6
6
  const monitor_1 = require("../dom/monitor");
@@ -47,33 +47,6 @@ class SetList {
47
47
  this.cache.delete(node);
48
48
  }
49
49
  }
50
- /**
51
- * MultiFrame is a composite that allows more than one Frame to be rendered
52
- * at the same time.
53
- */
54
- class MultiFrame {
55
- constructor(frames = []) {
56
- this.frames = frames;
57
- }
58
- root(el) {
59
- for (let f of this.frames) {
60
- f.root(el);
61
- }
62
- }
63
- node(tag, attrs, children) {
64
- let results = this.frames.map((f) => f.node(tag, attrs, children));
65
- return results[0] ?? dom.createElement('div', {}, []);
66
- }
67
- widget(w, attrs) {
68
- let results = this.frames.map((f) => f.widget(w, attrs));
69
- return results[0] ?? dom.createElement('div', {}, []);
70
- }
71
- view(view) {
72
- let results = this.frames.map((f) => f.view(view));
73
- return results[0] ?? dom.createElement('div', {}, []);
74
- }
75
- }
76
- exports.MultiFrame = MultiFrame;
77
50
  /**
78
51
  * ViewFrame contains helper methods for retreiving elements by id or
79
52
  * group freeing the View class of such logic.
@@ -87,7 +60,7 @@ class ViewFrame {
87
60
  this.indexes = indexes;
88
61
  this.tree = tree;
89
62
  }
90
- _register(id, node, widget) {
63
+ register(id, node, widget) {
91
64
  let idx = this.nodes.add(node);
92
65
  this.ids.set(id, idx);
93
66
  this.indexes.set(idx, id);
@@ -95,7 +68,7 @@ class ViewFrame {
95
68
  this.widgets.set(idx, widget);
96
69
  }
97
70
  }
98
- _registerGroupMember(id, node, widget) {
71
+ registerGroupMember(id, node, widget) {
99
72
  let group = this.groups.get(id) ?? [];
100
73
  let idx = this.nodes.add(node);
101
74
  group.push(idx);
@@ -109,18 +82,18 @@ class ViewFrame {
109
82
  node(tag, attrs, children) {
110
83
  let elm = dom.createElement(tag, attrs, children, (attrs.wml && attrs.wml.ns) || "");
111
84
  if (attrs?.wml?.id)
112
- this._register(attrs.wml.id, elm);
85
+ this.register(attrs.wml.id, elm);
113
86
  if (attrs?.wml?.group)
114
- this._registerGroupMember(attrs.wml.group, elm);
87
+ this.registerGroupMember(attrs.wml.group, elm);
115
88
  return elm;
116
89
  }
117
90
  widget(w, attrs) {
118
91
  let tree = w.render();
119
92
  monitor_1.DOMMonitor.getInstance().monitor(tree, w);
120
93
  if (attrs?.wml?.id)
121
- this._register(attrs.wml.id, tree, w);
94
+ this.register(attrs.wml.id, tree, w);
122
95
  if (attrs?.wml?.group)
123
- this._registerGroupMember(attrs.wml.group, tree, w);
96
+ this.registerGroupMember(attrs.wml.group, tree, w);
124
97
  return tree;
125
98
  }
126
99
  view(view) {
@@ -129,9 +102,6 @@ class ViewFrame {
129
102
  this.root = root;
130
103
  return tree;
131
104
  }
132
- /**
133
- * findById returns the entry stored for the specified wml element.
134
- */
135
105
  findById(id) {
136
106
  let idx = this.ids.get(id) ?? -1;
137
107
  let node = this.nodes.get(idx);
@@ -142,9 +112,6 @@ class ViewFrame {
142
112
  widget: this.widgets.get(idx),
143
113
  });
144
114
  }
145
- /**
146
- * findByGroup returns all the entries stored fro a group.
147
- */
148
115
  findByGroup(id) {
149
116
  let result = [];
150
117
  for (let idx of this.groups.get(id) ?? []) {
@@ -156,18 +123,10 @@ class ViewFrame {
156
123
  }
157
124
  return result;
158
125
  }
159
- /**
160
- * replaceByIndex performs the heavy work of replacing a WMLElement
161
- * with the corresponding index from another ViewFrame.
162
- *
163
- * The replaced element will have its DOM content redrawn if a parentNode
164
- * is detected.
165
- */
166
126
  replaceByIndex(next, idx) {
167
127
  let originalNode = this.nodes.get(idx);
168
- let id = this.indexes.get(idx) ?? "";
169
128
  if (idx == null || originalNode == null) {
170
- console.warn(`Not replacing missing WMLElement for id "${id}"!`);
129
+ console.warn(`Not replacing missing element by index ${idx}!`);
171
130
  return;
172
131
  }
173
132
  let { parentNode } = originalNode;
@@ -177,6 +136,7 @@ class ViewFrame {
177
136
  // Remove references since the node no longer exists.
178
137
  this.nodes.delete(idx);
179
138
  this.widgets.delete(idx);
139
+ let id = this.indexes.get(idx) ?? "";
180
140
  this.ids.delete(id);
181
141
  this.indexes.delete(idx);
182
142
  if (parentNode)
@@ -190,15 +150,9 @@ class ViewFrame {
190
150
  if (parentNode)
191
151
  parentNode.replaceChild(node, originalNode);
192
152
  }
193
- /**
194
- * replaceById allows WMLElement replacement by using an id.
195
- */
196
153
  replaceById(next, id) {
197
154
  this.replaceByIndex(next, this.ids.get(id) ?? -1);
198
155
  }
199
- /**
200
- * replaceByGroup allows WMLElement replaced by using a group identifier.
201
- */
202
156
  replaceByGroup(next, id) {
203
157
  let group = this.groups.get(id) ?? [];
204
158
  let newGroup = [];
@@ -209,6 +163,7 @@ class ViewFrame {
209
163
  }
210
164
  this.groups.set(id, newGroup);
211
165
  }
166
+ destroy() { }
212
167
  }
213
168
  exports.ViewFrame = ViewFrame;
214
169
  //# sourceMappingURL=frame.js.map
@@ -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,G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,CAAC,CAAC;IAC9D,CAAC;IAED,WAAW,CAAC,IAAe,EAAE,EAAS;QACpC,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;IAED,cAAc,CAAC,IAAe,EAAE,EAAS;QACvC,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;QAEtC,IAAI,QAAQ,GAAG,EAAE,CAAC;QAClB,KAAK,IAAI,GAAG,IAAI,KAAK,EAAE,CAAC;YACtB,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC9C,CAAC;QAED,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) : void
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
- * MultiFrame is a composite that allows more than one Frame to be rendered
111
- * at the same time.
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
- root(el: Content) {
117
- for (let f of this.frames) {
118
- f.root(el);
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
- widget(w: Widget, attrs: Attrs): Content {
128
- let results = this.frames.map((f) => f.widget(w, attrs));
129
- return results[0] ?? dom.createElement('div', {}, []);
130
- }
131
-
132
- view(view: View): Content {
133
- let results = this.frames.map((f) => f.view(view));
134
- return results[0] ?? dom.createElement('div', {}, []);
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
- _register(id: WMLId, node: Content, widget?: Widget) {
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
- _registerGroupMember(id: WMLId, node: Content, widget?: Widget) {
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
- node(tag: string, attrs: Attrs, children: Content[]): Content {
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._register(attrs.wml.id, elm);
204
+ if (attrs?.wml?.id) this.register(attrs.wml.id, elm);
184
205
 
185
- if (attrs?.wml?.group) this._registerGroupMember(attrs.wml.group, elm);
206
+ if (attrs?.wml?.group) this.registerGroupMember(attrs.wml.group, elm);
186
207
 
187
208
  return elm;
188
209
  }
189
210
 
190
- widget(w: Widget, attrs: Attrs): Content {
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._register(attrs.wml.id, tree, w);
216
+ if (attrs?.wml?.id) this.register(attrs.wml.id, tree, w);
196
217
 
197
- if (attrs?.wml?.group) this._registerGroupMember(attrs.wml.group, tree, w);
218
+ if (attrs?.wml?.group) this.registerGroupMember(attrs.wml.group, tree, w);
198
219
 
199
220
  return tree;
200
221
  }
201
222
 
202
- view(view: View): Content {
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 WMLElement for id "${id}"!`);
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
  }
@@ -15,10 +15,11 @@ export interface View {
15
15
  /**
16
16
  * render the View.
17
17
  *
18
- * If a ViewFrame is provided, it will be used instead of creating a new one
19
- * internally. In this case the View itself will not be mutated internally.
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(frame?: ViewFrame): Content;
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: ViewFrame;
53
- constructor(context: object, renderer: Renderer, frame?: ViewFrame);
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(frame?: Frame): Content;
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(frame) {
41
+ render() {
42
+ this.frame?.destroy();
42
43
  this.frame = new frame_1.ViewFrame();
43
- this.renderer(frame ? new frame_1.MultiFrame([this.frame, frame]) : this.frame);
44
+ this.renderer(this.frame);
44
45
  return this.frame.tree;
45
46
  }
46
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAGA,mCAA8D;AA8C9D;;;;;GAKG;AACH,MAAa,QAAQ;IACnB,YACS,OAAe,EACf,QAAkB,EAClB,QAAQ,IAAI,iBAAS,EAAE;QAFvB,YAAO,GAAP,OAAO,CAAQ;QACf,aAAQ,GAAR,QAAQ,CAAU;QAClB,UAAK,GAAL,KAAK,CAAkB;IAC7B,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,U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I,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, MultiFrame, ViewFrame } from "./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 a ViewFrame is provided, it will be used instead of creating a new one
22
- * internally. In this case the View itself will not be mutated internally.
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(frame?: ViewFrame): Content;
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(frame?: Frame): Content {
94
+ render(): Content {
95
+ this.frame?.destroy();
94
96
  this.frame = new ViewFrame();
95
- this.renderer(frame ? new MultiFrame([this.frame, frame]) : this.frame);
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.14.1",
3
+ "version": "2.15.1",
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/mocha $(find -name *_test.ts)"
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
  },