intelligent-system-design-language 0.3.19 → 0.3.21

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 (55) hide show
  1. package/out/_handlebars.scss +0 -8
  2. package/out/_isdlStyles.scss +35 -12
  3. package/out/cli/components/_handlebars.scss +0 -8
  4. package/out/cli/components/_isdlStyles.scss +35 -12
  5. package/out/cli/components/derived-data-generator.js +22 -2
  6. package/out/cli/components/derived-data-generator.js.map +1 -1
  7. package/out/cli/components/method-generator.js +11 -3
  8. package/out/cli/components/method-generator.js.map +1 -1
  9. package/out/cli/components/utils.js +33 -1
  10. package/out/cli/components/utils.js.map +1 -1
  11. package/out/cli/components/vue/base-components/vue-attribute.js +6 -3
  12. package/out/cli/components/vue/base-components/vue-attribute.js.map +1 -1
  13. package/out/cli/components/vue/base-components/vue-document-choice.js +1 -0
  14. package/out/cli/components/vue/base-components/vue-document-choice.js.map +1 -1
  15. package/out/cli/components/vue/base-components/vue-inventory.js +1 -1
  16. package/out/cli/components/vue/base-components/vue-macro-choice.js +1 -0
  17. package/out/cli/components/vue/base-components/vue-macro-choice.js.map +1 -1
  18. package/out/cli/components/vue/base-components/vue-tracker.js +1 -1
  19. package/out/cli/components/vue/vue-datatable2-component-generator.js +29 -11
  20. package/out/cli/components/vue/vue-datatable2-component-generator.js.map +1 -1
  21. package/out/cli/components/vue/vue-generator.js +0 -7
  22. package/out/cli/components/vue/vue-generator.js.map +1 -1
  23. package/out/cli/components/vue/vue-sheet-application-generator.js +62 -38
  24. package/out/cli/components/vue/vue-sheet-application-generator.js.map +1 -1
  25. package/out/cli/components/vue/vue-sheet-class-generator.js +82 -6
  26. package/out/cli/components/vue/vue-sheet-class-generator.js.map +1 -1
  27. package/out/cli/generator.js +0 -25
  28. package/out/cli/generator.js.map +1 -1
  29. package/out/extension/main.cjs +716 -475
  30. package/out/extension/main.cjs.map +3 -3
  31. package/out/extension/package.json +1 -8
  32. package/out/language/generated/ast.js +34 -4
  33. package/out/language/generated/ast.js.map +1 -1
  34. package/out/language/generated/grammar.js +559 -469
  35. package/out/language/generated/grammar.js.map +1 -1
  36. package/out/language/intelligent-system-design-language-validator.js +45 -3
  37. package/out/language/intelligent-system-design-language-validator.js.map +1 -1
  38. package/out/language/isdl-hover-provider.js +1 -1
  39. package/out/language/isdl-hover-provider.js.map +1 -1
  40. package/out/language/isdl-scope-provider.js +17 -1
  41. package/out/language/isdl-scope-provider.js.map +1 -1
  42. package/out/language/main.cjs +716 -475
  43. package/out/language/main.cjs.map +3 -3
  44. package/out/package.json +1 -8
  45. package/out/test/validating/diagnostics.test.js +17 -0
  46. package/out/test/validating/diagnostics.test.js.map +1 -1
  47. package/package.json +1 -8
  48. package/out/cli/components/base-actor-sheet-generator.js +0 -125
  49. package/out/cli/components/base-actor-sheet-generator.js.map +0 -1
  50. package/out/cli/components/base-sheet-generator.js +0 -525
  51. package/out/cli/components/base-sheet-generator.js.map +0 -1
  52. package/out/cli/components/vue/vue-datatable-component-generator.js +0 -307
  53. package/out/cli/components/vue/vue-datatable-component-generator.js.map +0 -1
  54. package/out/datatables.min.css +0 -54
  55. package/out/datatables.min.js +0 -178
@@ -1,525 +0,0 @@
1
- import * as fs from 'node:fs';
2
- import * as path from 'node:path';
3
- import { expandToNode, toString } from 'langium/generate';
4
- export function generateBaseDocumentSheet(entry, id, destination) {
5
- const generatedFileDir = path.join(destination, "system", "sheets");
6
- const generatedFilePath = path.join(generatedFileDir, `${id}-sheet.mjs`);
7
- if (!fs.existsSync(generatedFileDir)) {
8
- fs.mkdirSync(generatedFileDir, { recursive: true });
9
- }
10
- const fileNode = expandToNode `
11
- export default class ${entry.config.name}DocumentSheet extends DocumentSheet {
12
-
13
- /** @override */
14
- static get defaultOptions() {
15
- return foundry.utils.mergeObject(super.defaultOptions, {
16
- classes: ["${id}", "sheet", "handlebars-sheet"],
17
- width: 1000,
18
- height: 950,
19
- resizable: true,
20
- submitOnClose: true,
21
- submitOnChange: true,
22
- closeOnSubmit: false,
23
- tabs: [
24
- {navSelector: ".pages", contentSelector: ".pages-container", initial: "main"},
25
- {navSelector: ".tabs", contentSelector: ".tabs-container", initial: "description"}
26
- ],
27
- dragDrop: [
28
- {dragSelector: "tr", dropSelector: ".tabs-container"},
29
- {dropSelector: ".single-document"},
30
- {dragSelector: ".paper-doll-slot", dropSelector: ".paper-doll-slot"}
31
- ],
32
- });
33
- }
34
-
35
- /* -------------------------------------------- */
36
-
37
- /** @override */
38
- get title() {
39
- return \`\${this.object.name} \${game.i18n.localize("Config")}\`;
40
- }
41
-
42
- /* -------------------------------------------- */
43
-
44
- /** @override */
45
- async getData() {
46
- const context = await super.getData();
47
- context.descriptionHTML = await TextEditor.enrichHTML(
48
- this.object.system.description,
49
- {async: true, secrets: this.object.isOwner}
50
- );
51
- return context;
52
- }
53
-
54
- /* -------------------------------------------- */
55
-
56
- activatedTables = [];
57
-
58
- /** @override */
59
- activateListeners(html) {
60
- super.activateListeners(html);
61
-
62
- this._swapBackground(this.defaultBackground);
63
-
64
-
65
- html.find(".row-action").click(this._onTableRowAction.bind(this));
66
- html.find(".single-document-remove").click(this._onSingleDocumentRemove.bind(this));
67
-
68
- this.activateDataTables(html);
69
- this.activateProgressBars(html);
70
- }
71
-
72
- dbInstance = null;
73
-
74
- // Open IndexedDB (Cached)
75
- openDB(version=1) {
76
- return new Promise((resolve, reject) => {
77
- if (this.dbInstance) return resolve(this.dbInstance);
78
-
79
- const request = indexedDB.open("datatableDB", version);
80
-
81
- request.onupgradeneeded = (event) => {
82
- let db = event.target.result;
83
- if (!db.objectStoreNames.contains("tableStates")) {
84
- db.createObjectStore("tableStates", { keyPath: "id" });
85
- }
86
- };
87
-
88
- request.onsuccess = (event) => {
89
- this.dbInstance = event.target.result;
90
- resolve(this.dbInstance);
91
- };
92
-
93
- request.onerror = () => reject("IndexedDB failed to open.");
94
- });
95
- }
96
-
97
- // Save table state
98
- saveTableState(name, data) {
99
- this.openDB().then((db) => {
100
- const tx = db.transaction("tableStates", "readwrite");
101
- const store = tx.objectStore("tableStates");
102
- store.put({ id: name, data });
103
-
104
- tx.oncomplete = () => {};
105
- tx.onerror = () => console.error(\`Failed to save state: \${name}\`);
106
- });
107
- }
108
-
109
- // Load table state
110
- loadTableState(name) {
111
- return new Promise((resolve) => {
112
- this.openDB().then((db) => {
113
- const tx = db.transaction("tableStates", "readonly");
114
- const store = tx.objectStore("tableStates");
115
- const request = store.get(name);
116
-
117
- request.onsuccess = () => resolve(request.result ? request.result.data : null);
118
- request.onerror = () => resolve(null);
119
- });
120
- });
121
- }
122
-
123
-
124
- /* -------------------------------------------- */
125
-
126
- activateDataTables(html) {
127
- for ( let t of this.activatedTables ) {
128
- try {
129
- t.destroy();
130
- } catch { }
131
- }
132
- this.activatedTables = [];
133
- var tables = this._element.find("table");
134
- for ( let t of tables ) {
135
- let table = new DataTable(t, {
136
- paging: false,
137
- scrollY: 250,
138
- stateSave: true,
139
- stateSaveCallback: (settings, data) => {
140
- const documentName = this.object.name;
141
- const documentType = this.object.type;
142
- const tableName = settings.nTable.closest(".tab").dataset.tab;
143
- const name = \`DataTables_\${documentName}_\${documentType}_\${tableName}\`;
144
- try {
145
- this.saveTableState(name, data);
146
- }
147
- catch (e) {
148
- console.error("Failed to save state:", e);
149
- }
150
- },
151
- stateLoadCallback: (settings, callback) => {
152
- const documentName = this.object.name;
153
- const documentType = this.object.type;
154
- const tableName = settings.nTable.closest(".tab").dataset.tab;
155
- const name = \`DataTables_\${documentName}_\${documentType}_\${tableName}\`;
156
-
157
-
158
- this.loadTableState(name).then((data) => {
159
- callback(data);
160
- }).catch((error) => {
161
- console.error("Failed to load table state:", name, error);
162
- callback(null); // Return null on failure
163
- });
164
- },
165
- responsive: true,
166
- scrollX: false,
167
- colReorder: true,
168
- layout: {
169
- topStart: {
170
- buttons: [
171
- {
172
- text: '<i class="fas fa-plus"></i> Add',
173
- action: (e, dt, node, config) => {
174
- // Find the parent tab so we know what type of Item to create
175
- const tab = e.currentTarget.closest(".tab");
176
- const type = tab.dataset.type;
177
- if ( type == "ActiveEffect" ) {
178
- ActiveEffect.createDocuments([{label: "New Effect"}], {parent: this.object}).then(effect => {
179
- effect[0].sheet.render(true);
180
- });
181
- }
182
- else {
183
- Item.createDocuments([{type: type, name: "New " + type}], {parent: this.object}).then(item => {
184
- item[0].sheet.render(true);
185
- });
186
- }
187
- }
188
- },
189
- 'colvis'
190
- ]
191
- }
192
- },
193
- columnDefs: [
194
- {
195
- targets: [0, 1, -1], // Image, Name, Actions
196
- responsivePriority: 1
197
- },
198
- {
199
- target: 0, // Image
200
- width: "40px"
201
- },
202
- {
203
- target: -1, // Actions
204
- orderable: false,
205
- width: "200px"
206
- },
207
- {
208
- target: 1, // Name
209
- width: "200px"
210
- }
211
- ],
212
- order: [
213
- [1, "asc"]
214
- ]
215
- });
216
-
217
- // When the table is re-ordered, update the sort attribute of each item
218
- table.on('row-reordered', function (e, diff, edit) {
219
- for (var i = 0, ien = diff.length; i < ien; i++) {
220
- const id = diff[i].node.dataset.id;
221
- const item = self.object.items.get(id);
222
- if (item) {
223
- item.update({sort: diff[i].newPosition});
224
- }
225
- }
226
- });
227
- this.activatedTables.push(table);
228
- }
229
- }
230
-
231
- /* -------------------------------------------- */
232
-
233
- lastKnownProgressBars = [];
234
- activateProgressBars(html) {
235
- const progressBars = html.find(".progress-bar");
236
- for ( let p of progressBars ) {
237
- const fromColor = p.dataset.colorFrom;
238
- const toColor = p.dataset.colorTo;
239
-
240
- // If we don't have a value and max, we can't create a progress bar
241
- if (p.dataset.value === undefined || p.dataset.max === undefined) continue;
242
-
243
- const value = parseFloat(p.dataset.value);
244
- const max = parseFloat(p.dataset.max);
245
-
246
- if ( isNaN(value) || isNaN(max) ) continue;
247
- if ( max <= 0 ) continue;
248
-
249
- const percent = Math.min(Math.max(value / max, 0), 1);
250
- const name = p.attributes.name.value;
251
- try {
252
- var bar = new ProgressBar.Line(p, {
253
- strokeWidth: 3,
254
- easing: 'easeInOut',
255
- duration: 1400,
256
- color: '#FFEA82',
257
- trailColor: '#eee',
258
- trailWidth: 1,
259
- svgStyle: {width: '100%', height: '100%'},
260
- from: {color: fromColor},
261
- to: {color: toColor},
262
- step: (state, bar) => {
263
- bar.path.setAttribute('stroke', state.color);
264
- }
265
- });
266
-
267
- // We store a name: value pair for each progress bar. If there is a last known value, we set that as the non-animated base then update to the new value..
268
- const lastKnown = this.lastKnownProgressBars.find(p => p.name === name);
269
- if ( lastKnown ) {
270
- bar.set(lastKnown.percent);
271
- bar.animate(percent);
272
- lastKnown.percent = percent;
273
- } else {
274
- bar.set(percent);
275
- this.lastKnownProgressBars.push({name: name, percent: percent});
276
- }
277
- }
278
- catch(err) {
279
- // Do nothing
280
- }
281
- }
282
- }
283
-
284
- /* -------------------------------------------- */
285
-
286
- get defaultBackground() {
287
- return "topography";
288
- }
289
-
290
- _currentBackground = null;
291
- _swapBackground(background) {
292
- const form = this.form;
293
- form.classList.remove("topography", "hideout", "graphpaper", "texture", "squares", "dominoes", "temple", "food", "anchors", "bubbles", "diamonds", "circuitboard", "bricks");
294
- form.classList.add(background);
295
- this._currentBackground = background;
296
- }
297
-
298
- /* -------------------------------------------- */
299
-
300
- /** @override */
301
- _onChangeTab(event, tabs, active) {
302
- super._onChangeTab(event, tabs, active);
303
-
304
- if ( tabs._content.classList.contains("pages-container") ) {
305
- // Get the new active page header
306
- const header = tabs._nav.querySelector(\`[data-tab="\${tabs.active}"]\`);
307
- if ( !header ) return;
308
-
309
- // Set the background
310
- const background = header.dataset.background;
311
-
312
- this._swapBackground(background);
313
- }
314
-
315
- // Redraw any DataTable instances which are active within the form for correct sizing
316
- for ( let table of this.activatedTables ) {
317
- table.draw();
318
- table.responsive.rebuild();
319
- table.responsive.recalc();
320
- }
321
-
322
- this.calculateHeight();
323
- }
324
-
325
- /* -------------------------------------------- */
326
-
327
- firstRender = true;
328
- /** @override */
329
- setPosition({left, top, width, height, scale}={}) {
330
- if ( !this.popOut && !this.options.resizable ) return;
331
- super.setPosition({left, top, width, height, scale});
332
-
333
- if ( this.firstRender ) {
334
- this.firstRender = false;
335
- this.calculateHeight();
336
- }
337
- }
338
-
339
- /* -------------------------------------------- */
340
-
341
- calculateHeight() {
342
- // Calculate the height of the drawn content and set the height of the sheet to that value
343
- const form = this.form;
344
- let calculatedInnerHeight = 0;
345
- for ( let c of form.children ) {
346
- calculatedInnerHeight += c.offsetHeight;
347
- }
348
- const formHeight = calculatedInnerHeight + 75;
349
- const maxHeight = window.innerHeight * 0.9; // 90% of the viewport height
350
-
351
- this.setPosition({height: Math.min(formHeight, maxHeight)});
352
- }
353
-
354
- /* -------------------------------------------- */
355
-
356
- /** @override */
357
- async close(options={}) {
358
-
359
- // Destroy any DataTable instances which are active within the form
360
- for ( let t of this.activatedTables ) {
361
- t.destroy();
362
- }
363
- this.activatedTables = [];
364
-
365
- // Call the base close method
366
- return super.close(options);
367
- }
368
-
369
- /* -------------------------------------------- */
370
-
371
- /** @override */
372
- _onResize(event) {
373
- super._onResize(event);
374
-
375
- // Redraw any DataTable instances which are active within the form for correct sizing
376
- for ( let table of this.activatedTables ) {
377
- table.draw();
378
- table.responsive.rebuild();
379
- table.responsive.recalc();
380
- }
381
- }
382
-
383
- /* -------------------------------------------- */
384
-
385
- async _onDrop(event) {
386
- super._onDrop(event);
387
- const data = JSON.parse(event.dataTransfer.getData("text/plain"));
388
-
389
- // If the drop target is a single document, handle it differently
390
- const linkedClasses = [ "single-document", "paper-doll-slot" ];
391
- const eventClasses = Array.from(event.currentTarget.classList);
392
- if (eventClasses.find(c => linkedClasses.includes(c))) {
393
- const doc = await fromUuid(data.uuid);
394
- if ( !doc ) return;
395
- if ( doc.type !== event.currentTarget.dataset.type ) {
396
- ui.notifications.error(\`Expected a \${event.currentTarget.dataset.type} type Document, but got a \${doc.type} type one instead. \`);
397
- return;
398
- }
399
-
400
- const update = {};
401
- update[event.currentTarget.dataset.name] = data.uuid;
402
- await this.object.update(update);
403
- return;
404
- }
405
-
406
- const dropTypes = ["Item", "ActiveEffect"];
407
- if ( !dropTypes.includes(data.type) ) return;
408
- const item = await fromUuid(data.uuid);
409
- if ( !item ) return;
410
-
411
- // Prevent duplicates when dropping an item that's already owned by this document
412
- if ( item.parent?.uuid === this.object.uuid ) return;
413
-
414
- if ( data.type === "ActiveEffect" ) {
415
- ActiveEffect.createDocuments([item], {parent: this.object})
416
- return;
417
- }
418
-
419
- await this.handleItemDrop(item);
420
- }
421
-
422
- /* -------------------------------------------- */
423
-
424
- async handleItemDrop(item) { }
425
-
426
- /* -------------------------------------------- */
427
-
428
- async _onTableRowAction(event) {
429
- event.preventDefault();
430
-
431
- const action = event.currentTarget.dataset.action;
432
- const id = event.currentTarget.closest("tr").dataset.id;
433
- const type = event.currentTarget.closest(".tab").dataset.type;
434
- const typeAccessor = type === "ActiveEffect" ? "effects" : "items";
435
- const item = this.object[typeAccessor].get(id);
436
-
437
- // If this is a .item-custom-action, route it to the item sheet handler
438
- if ( event.currentTarget.classList.contains("item-custom-action") ) {
439
- await item.sheet._onAction(event);
440
- return;
441
- }
442
-
443
- switch ( action ) {
444
- case "edit":
445
- item.sheet.render(true);
446
- break;
447
- case "delete":
448
- const shouldDelete = await Dialog.confirm({
449
- title: "Delete Confirmation",
450
- content: \`<p>Are you sure you would like to delete \${item.name}?</p>\`,
451
- defaultYes: false
452
- });
453
- if ( shouldDelete ) item.delete();
454
- break;
455
- case "sendToChat":
456
- const chatDescription = item.description ?? item.system.description;
457
- const content = await renderTemplate("systems/${id}/system/templates/chat/standard-card.hbs", {
458
- cssClass: "${id}",
459
- document: item,
460
- hasEffects: item.effects?.size > 0,
461
- description: chatDescription,
462
- hasDescription: chatDescription != ""
463
- });
464
- ChatMessage.create({
465
- content: content,
466
- speaker: ChatMessage.getSpeaker(),
467
- style: CONST.CHAT_MESSAGE_STYLES.IC
468
- });
469
- break;
470
- case "toggle":
471
- // If we haven't found an effect on the actor, check the actor.items
472
- if ( !item ) {
473
- const ae = this.object.items.find(i => i.effects.has(id)).effects.get(id);
474
- if ( !ae ) return;
475
- await ae.update({ "disabled": !ae.disabled });
476
- break;
477
- }
478
- await item.update({ "disabled": !item.disabled });
479
- break;
480
- default:
481
- await this.handleTableRowAction(item, action);
482
- break;
483
- }
484
- }
485
-
486
- /* -------------------------------------------- */
487
-
488
- async handleTableRowAction(item, action) { }
489
-
490
- /* -------------------------------------------- */
491
-
492
- async _onSingleDocumentRemove(event) {
493
- event.preventDefault();
494
- const update = {};
495
- update[event.currentTarget.dataset.name] = null;
496
- await this.object.update(update);
497
- }
498
-
499
- /* -------------------------------------------- */
500
-
501
- _onDragStart(event) {
502
- console.log("Drag Start");
503
-
504
- if (event.currentTarget.classList.contains("paper-doll-slot")) {
505
- // Remove the item from the slot
506
- const name = event.currentTarget.dataset.name;
507
- const update = {};
508
- update[name] = null;
509
- this.object.update(update);
510
- }
511
- else {
512
- const tr = event.currentTarget.closest("tr");
513
- const data = {
514
- type: tr.dataset.type == "ActiveEffect" ? "ActiveEffect" : "Item",
515
- uuid: tr.dataset.uuid
516
- };
517
-
518
- event.dataTransfer.setData("text/plain", JSON.stringify(data));
519
- }
520
- }
521
- }
522
- `.appendNewLineIfNotEmpty();
523
- fs.writeFileSync(generatedFilePath, toString(fileNode));
524
- }
525
- //# sourceMappingURL=base-sheet-generator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base-sheet-generator.js","sourceRoot":"","sources":["../../../src/cli/components/base-sheet-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE1D,MAAM,UAAU,yBAAyB,CAAC,KAAY,EAAE,EAAU,EAAE,WAAmB;IACnF,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACpE,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;IAEzE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QAClC,EAAE,CAAC,SAAS,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;KACvD;IAED,MAAM,QAAQ,GAAG,YAAY,CAAA;+BACF,KAAK,CAAC,MAAM,CAAC,IAAI;;;;;iCAKf,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wEAybqC,EAAE;yCACjC,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgEtC,CAAC,uBAAuB,EAAE,CAAC;IAE5B,EAAE,CAAC,aAAa,CAAC,iBAAiB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC5D,CAAC"}