intelligent-system-design-language 0.3.21 → 0.3.23
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/.claude/agents/langium-language-designer.md +38 -38
- package/.claude/agents/typescript-vscode-expert.md +29 -29
- package/.claude/agents/ui-ux-designer.md +36 -36
- package/.claude/settings.local.json +33 -33
- package/.idea/inspectionProfiles/Project_Default.xml +6 -6
- package/.idea/isdl.iml +13 -13
- package/.idea/modules.xml +8 -8
- package/.idea/vcs.xml +6 -6
- package/.idea/watcherTasks.xml +3 -3
- package/.vscodeignore +18 -18
- package/LICENSE +673 -673
- package/README.md +86 -86
- package/bin/cli.js +4 -4
- package/bin/lsp.js +8 -8
- package/out/_backgrounds.scss +91 -91
- package/out/_handlebars.scss +497 -497
- package/out/_isdlStyles.scss +1444 -1381
- package/out/_vuetifyOverrides.scss +425 -425
- package/out/_vuetifyStyles.scss +31957 -31957
- package/out/cli/components/_backgrounds.scss +91 -91
- package/out/cli/components/_handlebars.scss +497 -497
- package/out/cli/components/_isdlStyles.scss +1444 -1381
- package/out/cli/components/_vuetifyOverrides.scss +425 -425
- package/out/cli/components/_vuetifyStyles.scss +31957 -31957
- package/out/cli/components/active-effect-sheet-generator.js +453 -453
- package/out/cli/components/chat-card-generator.js +654 -651
- package/out/cli/components/chat-card-generator.js.map +1 -1
- package/out/cli/components/css-generator.js +4 -4
- package/out/cli/components/damage-roll-generator.js +160 -160
- package/out/cli/components/datamodel-generator.js +264 -257
- package/out/cli/components/datamodel-generator.js.map +1 -1
- package/out/cli/components/derived-data-generator.js +923 -923
- package/out/cli/components/hotbar-drop-hook-generator.js +82 -82
- package/out/cli/components/init-hook-generator.js +495 -495
- package/out/cli/components/language-generator.js +1 -1
- package/out/cli/components/language-generator.js.map +1 -1
- package/out/cli/components/measured-template-preview.js +221 -221
- package/out/cli/components/method-generator.js +979 -887
- package/out/cli/components/method-generator.js.map +1 -1
- package/out/cli/components/ready-hook-generator.js +404 -404
- package/out/cli/components/token-generator.js +116 -116
- package/out/cli/components/vue/base-components/vue-attribute.js +138 -138
- package/out/cli/components/vue/base-components/vue-boolean.js +64 -64
- package/out/cli/components/vue/base-components/vue-calculator.js +93 -93
- package/out/cli/components/vue/base-components/vue-damage-application.js +356 -356
- package/out/cli/components/vue/base-components/vue-damage-bonuses.js +165 -165
- package/out/cli/components/vue/base-components/vue-damage-resistances.js +196 -196
- package/out/cli/components/vue/base-components/vue-damage-track.js +121 -121
- package/out/cli/components/vue/base-components/vue-date-time.js +42 -42
- package/out/cli/components/vue/base-components/vue-dice.js +98 -98
- package/out/cli/components/vue/base-components/vue-die.js +73 -73
- package/out/cli/components/vue/base-components/vue-document-choice.js +149 -149
- package/out/cli/components/vue/base-components/vue-document-choices.js +179 -179
- package/out/cli/components/vue/base-components/vue-document-link.js +60 -60
- package/out/cli/components/vue/base-components/vue-extended-choice.js +88 -88
- package/out/cli/components/vue/base-components/vue-inventory.js +519 -519
- package/out/cli/components/vue/base-components/vue-macro-choice.js +138 -138
- package/out/cli/components/vue/base-components/vue-measured-template.js +530 -530
- package/out/cli/components/vue/base-components/vue-money.js +483 -483
- package/out/cli/components/vue/base-components/vue-number.js +174 -174
- package/out/cli/components/vue/base-components/vue-paperdoll.js +43 -43
- package/out/cli/components/vue/base-components/vue-parent-property-reference.js +76 -76
- package/out/cli/components/vue/base-components/vue-prosemirror.js +18 -18
- package/out/cli/components/vue/base-components/vue-resource.js +136 -136
- package/out/cli/components/vue/base-components/vue-roll-visualizer.js +286 -109
- package/out/cli/components/vue/base-components/vue-roll-visualizer.js.map +1 -1
- package/out/cli/components/vue/base-components/vue-self-property-reference.js +62 -62
- package/out/cli/components/vue/base-components/vue-string-choice.js +98 -98
- package/out/cli/components/vue/base-components/vue-string-choices.js +203 -203
- package/out/cli/components/vue/base-components/vue-string.js +60 -60
- package/out/cli/components/vue/base-components/vue-text-field.js +53 -53
- package/out/cli/components/vue/base-components/vue-tracker.js +431 -431
- package/out/cli/components/vue/vue-action-component-generator.js +64 -64
- package/out/cli/components/vue/vue-active-effect-sheet-generator.js +856 -856
- package/out/cli/components/vue/vue-datatable-sheet-class-generator.js +292 -292
- package/out/cli/components/vue/vue-datatable2-component-generator.js +824 -824
- package/out/cli/components/vue/vue-document-creation-app.js +121 -121
- package/out/cli/components/vue/vue-document-creation-sheet.js +94 -94
- package/out/cli/components/vue/vue-generator.js +40 -40
- package/out/cli/components/vue/vue-mixin.js +296 -296
- package/out/cli/components/vue/vue-pinned-datatable-component-generator.js +260 -260
- package/out/cli/components/vue/vue-prompt-generator.js +91 -76
- package/out/cli/components/vue/vue-prompt-generator.js.map +1 -1
- package/out/cli/components/vue/vue-prompt-sheet-class-generator.js +317 -317
- package/out/cli/components/vue/vue-sheet-application-generator.js +1177 -1167
- package/out/cli/components/vue/vue-sheet-application-generator.js.map +1 -1
- package/out/cli/components/vue/vue-sheet-class-generator.js +510 -510
- package/out/cli/generator.js +438 -433
- package/out/cli/generator.js.map +1 -1
- package/out/extension/github/githubAuthProvider.js +71 -29
- package/out/extension/github/githubAuthProvider.js.map +1 -1
- package/out/extension/github/githubGistManager.js +4 -3
- package/out/extension/github/githubGistManager.js.map +1 -1
- package/out/extension/github/githubManager.js +40 -38
- package/out/extension/github/githubManager.js.map +1 -1
- package/out/extension/github/githubQuickActions.js +120 -120
- package/out/extension/github/system-workflow.yml +47 -47
- package/out/extension/main.cjs +909 -532
- package/out/extension/main.cjs.map +3 -3
- package/out/extension/package.json +419 -419
- package/out/language/generated/ast.js +51 -2
- package/out/language/generated/ast.js.map +1 -1
- package/out/language/generated/grammar.js +14240 -13991
- package/out/language/generated/grammar.js.map +1 -1
- package/out/language/intelligent-system-design-language-validator.js +32 -2
- package/out/language/intelligent-system-design-language-validator.js.map +1 -1
- package/out/language/isdl-scope-provider.js +14 -1
- package/out/language/isdl-scope-provider.js.map +1 -1
- package/out/language/main.cjs +913 -569
- package/out/language/main.cjs.map +3 -3
- package/out/package.json +419 -419
- package/out/progressbar.min.js +6 -6
- package/out/styles.scss +762 -747
- package/out/test/validating/diagnostics.test.js +40 -0
- package/out/test/validating/diagnostics.test.js.map +1 -1
- package/package.json +419 -419
|
@@ -22,14 +22,21 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
22
22
|
if (initialParam && typeof (initialParam.value) === 'number') {
|
|
23
23
|
options += `, initial: ${initialParam.value}`;
|
|
24
24
|
}
|
|
25
|
+
else {
|
|
26
|
+
// Always give a number a concrete initial (its min, or 0) so it's never undefined.
|
|
27
|
+
// An undefined number breaks arithmetic -- e.g. a prompt field left blank yields
|
|
28
|
+
// undefined, and `undefined - undefined` is NaN, which a roll then rejects with
|
|
29
|
+
// "Unresolved StringTerm NaN". (null would coerce to 0; undefined does not.)
|
|
30
|
+
options += `, initial: ${(minParam && typeof (minParam.value) === 'number') ? minParam.value : 0}`;
|
|
31
|
+
}
|
|
25
32
|
if (minParam && typeof (minParam.value) === 'number') {
|
|
26
33
|
options += `, min: ${minParam.value}`;
|
|
27
34
|
}
|
|
28
35
|
if (maxParam && typeof (maxParam.value) === 'number') {
|
|
29
36
|
options += `, max: ${maxParam.value}`;
|
|
30
37
|
}
|
|
31
|
-
return expandToNode `
|
|
32
|
-
${property.name.toLowerCase()}: new fields.NumberField({${options}}),
|
|
38
|
+
return expandToNode `
|
|
39
|
+
${property.name.toLowerCase()}: new fields.NumberField({${options}}),
|
|
33
40
|
`;
|
|
34
41
|
}
|
|
35
42
|
if (isMoneyField(property)) {
|
|
@@ -39,24 +46,24 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
39
46
|
const denominationFields = property.denominations.map(denom => {
|
|
40
47
|
return `${denom.name.toLowerCase()}: new fields.NumberField({initial: 0, nullable: false})`;
|
|
41
48
|
}).join(',\n ');
|
|
42
|
-
return expandToNode `
|
|
43
|
-
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
44
|
-
${denominationFields}
|
|
45
|
-
}),
|
|
49
|
+
return expandToNode `
|
|
50
|
+
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
51
|
+
${denominationFields}
|
|
52
|
+
}),
|
|
46
53
|
`;
|
|
47
54
|
}
|
|
48
55
|
else {
|
|
49
56
|
// Single currency money - store as simple NumberField
|
|
50
57
|
const initialParam = property.params.find(p => p.$type === 'NumberParamInitial');
|
|
51
58
|
const initial = (initialParam === null || initialParam === void 0 ? void 0 : initialParam.value) || 0;
|
|
52
|
-
return expandToNode `
|
|
53
|
-
${property.name.toLowerCase()}: new fields.NumberField({initial: ${initial}, nullable: false}),
|
|
59
|
+
return expandToNode `
|
|
60
|
+
${property.name.toLowerCase()}: new fields.NumberField({initial: ${initial}, nullable: false}),
|
|
54
61
|
`;
|
|
55
62
|
}
|
|
56
63
|
}
|
|
57
64
|
if (isStringExp(property)) {
|
|
58
|
-
return expandToNode `
|
|
59
|
-
${property.name.toLowerCase()}: new fields.StringField({initial: ""}),
|
|
65
|
+
return expandToNode `
|
|
66
|
+
${property.name.toLowerCase()}: new fields.StringField({initial: ""}),
|
|
60
67
|
`;
|
|
61
68
|
}
|
|
62
69
|
if (isStringChoiceField(property)) {
|
|
@@ -105,27 +112,27 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
105
112
|
return acc;
|
|
106
113
|
}, []);
|
|
107
114
|
if (additionalFields.length > 0) {
|
|
108
|
-
return expandToNode `
|
|
109
|
-
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
110
|
-
value: new fields.StringField({
|
|
111
|
-
choices: [${choices.choices.map(x => `"${choiceValue(x)}"`).join(", ")}],
|
|
112
|
-
initial: "${choiceValue(choices.choices[0])}"
|
|
113
|
-
}),
|
|
114
|
-
icon: new fields.StringField({initial: ""}),
|
|
115
|
-
color: new fields.StringField({initial: "#ffffff"}),
|
|
116
|
-
${joinToNode(additionalFields, field => `${field.key.toLowerCase()}: new fields.${field.type.charAt(0).toUpperCase() + field.type.slice(1)}Field({initial: ${JSON.stringify(field.defaultValue)}})`, { appendNewLineIfNotEmpty: true, separator: ',' })}
|
|
117
|
-
}),
|
|
115
|
+
return expandToNode `
|
|
116
|
+
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
117
|
+
value: new fields.StringField({
|
|
118
|
+
choices: [${choices.choices.map(x => `"${choiceValue(x)}"`).join(", ")}],
|
|
119
|
+
initial: "${choiceValue(choices.choices[0])}"
|
|
120
|
+
}),
|
|
121
|
+
icon: new fields.StringField({initial: ""}),
|
|
122
|
+
color: new fields.StringField({initial: "#ffffff"}),
|
|
123
|
+
${joinToNode(additionalFields, field => `${field.key.toLowerCase()}: new fields.${field.type.charAt(0).toUpperCase() + field.type.slice(1)}Field({initial: ${JSON.stringify(field.defaultValue)}})`, { appendNewLineIfNotEmpty: true, separator: ',' })}
|
|
124
|
+
}),
|
|
118
125
|
`;
|
|
119
126
|
}
|
|
120
|
-
return expandToNode `
|
|
121
|
-
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
122
|
-
value: new fields.StringField({
|
|
123
|
-
choices: [${choices.choices.map(x => `"${choiceValue(x)}"`).join(", ")}],
|
|
124
|
-
initial: "${choiceValue(choices.choices[0])}"
|
|
125
|
-
}),
|
|
126
|
-
icon: new fields.StringField({initial: ""}),
|
|
127
|
-
color: new fields.StringField({initial: "#ffffff"})
|
|
128
|
-
}),
|
|
127
|
+
return expandToNode `
|
|
128
|
+
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
129
|
+
value: new fields.StringField({
|
|
130
|
+
choices: [${choices.choices.map(x => `"${choiceValue(x)}"`).join(", ")}],
|
|
131
|
+
initial: "${choiceValue(choices.choices[0])}"
|
|
132
|
+
}),
|
|
133
|
+
icon: new fields.StringField({initial: ""}),
|
|
134
|
+
color: new fields.StringField({initial: "#ffffff"})
|
|
135
|
+
}),
|
|
129
136
|
`;
|
|
130
137
|
}
|
|
131
138
|
if (isDamageTypeChoiceField(property)) {
|
|
@@ -174,38 +181,38 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
174
181
|
return acc;
|
|
175
182
|
}, []);
|
|
176
183
|
if (additionalFields.length > 0) {
|
|
177
|
-
return expandToNode `
|
|
178
|
-
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
179
|
-
value: new fields.StringField({
|
|
180
|
-
choices: [${choices.choices.map(x => `"${choiceValue(x)}"`).join(", ")}],
|
|
181
|
-
initial: "${choiceValue(choices.choices[0])}"
|
|
182
|
-
}),
|
|
183
|
-
icon: new fields.StringField({initial: ""}),
|
|
184
|
-
color: new fields.StringField({initial: "#ffffff"}),
|
|
185
|
-
${joinToNode(additionalFields, field => `${field.key.toLowerCase()}: new fields.${field.type.charAt(0).toUpperCase() + field.type.slice(1)}Field({initial: ${JSON.stringify(field.defaultValue)}})`, { appendNewLineIfNotEmpty: true, separator: ',' })}
|
|
186
|
-
}),
|
|
184
|
+
return expandToNode `
|
|
185
|
+
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
186
|
+
value: new fields.StringField({
|
|
187
|
+
choices: [${choices.choices.map(x => `"${choiceValue(x)}"`).join(", ")}],
|
|
188
|
+
initial: "${choiceValue(choices.choices[0])}"
|
|
189
|
+
}),
|
|
190
|
+
icon: new fields.StringField({initial: ""}),
|
|
191
|
+
color: new fields.StringField({initial: "#ffffff"}),
|
|
192
|
+
${joinToNode(additionalFields, field => `${field.key.toLowerCase()}: new fields.${field.type.charAt(0).toUpperCase() + field.type.slice(1)}Field({initial: ${JSON.stringify(field.defaultValue)}})`, { appendNewLineIfNotEmpty: true, separator: ',' })}
|
|
193
|
+
}),
|
|
187
194
|
`;
|
|
188
195
|
}
|
|
189
|
-
return expandToNode `
|
|
190
|
-
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
191
|
-
value: new fields.StringField({
|
|
192
|
-
choices: [${choices.choices.map(x => `"${choiceValue(x)}"`).join(", ")}],
|
|
193
|
-
initial: "${choiceValue(choices.choices[0])}"
|
|
194
|
-
}),
|
|
195
|
-
icon: new fields.StringField({initial: ""}),
|
|
196
|
-
color: new fields.StringField({initial: "#ffffff"})
|
|
197
|
-
}),
|
|
196
|
+
return expandToNode `
|
|
197
|
+
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
198
|
+
value: new fields.StringField({
|
|
199
|
+
choices: [${choices.choices.map(x => `"${choiceValue(x)}"`).join(", ")}],
|
|
200
|
+
initial: "${choiceValue(choices.choices[0])}"
|
|
201
|
+
}),
|
|
202
|
+
icon: new fields.StringField({initial: ""}),
|
|
203
|
+
color: new fields.StringField({initial: "#ffffff"})
|
|
204
|
+
}),
|
|
198
205
|
`;
|
|
199
206
|
}
|
|
200
207
|
if (isStringChoicesField(property)) {
|
|
201
208
|
let choices = property.params.find(p => p.$type === 'StringChoicesParamChoices');
|
|
202
209
|
if (!choices || !choices.choices || choices.choices.length === 0) {
|
|
203
210
|
// Fallback for simple string array if no choices defined
|
|
204
|
-
return expandToNode `
|
|
205
|
-
${property.name.toLowerCase()}: new fields.ArrayField(
|
|
206
|
-
new fields.StringField({}),
|
|
207
|
-
{initial: []}
|
|
208
|
-
),
|
|
211
|
+
return expandToNode `
|
|
212
|
+
${property.name.toLowerCase()}: new fields.ArrayField(
|
|
213
|
+
new fields.StringField({}),
|
|
214
|
+
{initial: []}
|
|
215
|
+
),
|
|
209
216
|
`;
|
|
210
217
|
}
|
|
211
218
|
function choiceValue(choice) {
|
|
@@ -238,13 +245,13 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
238
245
|
let hasExtendedChoices = choices.choices.some((choice) => isStringExtendedChoice(choice.value));
|
|
239
246
|
if (!hasExtendedChoices) {
|
|
240
247
|
// Simple string choices - use array of strings
|
|
241
|
-
return expandToNode `
|
|
242
|
-
${property.name.toLowerCase()}: new fields.ArrayField(
|
|
243
|
-
new fields.StringField({
|
|
244
|
-
choices: [${choices.choices.map((x) => `"${choiceValue(x)}"`).join(", ")}]
|
|
245
|
-
}),
|
|
246
|
-
{initial: []}
|
|
247
|
-
),
|
|
248
|
+
return expandToNode `
|
|
249
|
+
${property.name.toLowerCase()}: new fields.ArrayField(
|
|
250
|
+
new fields.StringField({
|
|
251
|
+
choices: [${choices.choices.map((x) => `"${choiceValue(x)}"`).join(", ")}]
|
|
252
|
+
}),
|
|
253
|
+
{initial: []}
|
|
254
|
+
),
|
|
248
255
|
`;
|
|
249
256
|
}
|
|
250
257
|
// Extended choices - use array of schema objects like choice<string>
|
|
@@ -265,56 +272,56 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
265
272
|
return acc;
|
|
266
273
|
}, []);
|
|
267
274
|
if (additionalFields.length > 0) {
|
|
268
|
-
return expandToNode `
|
|
269
|
-
${property.name.toLowerCase()}: new fields.ArrayField(
|
|
270
|
-
new fields.SchemaField({
|
|
271
|
-
value: new fields.StringField({
|
|
272
|
-
choices: [${choices.choices.map((x) => `"${choiceValue(x)}"`).join(", ")}]
|
|
273
|
-
}),
|
|
274
|
-
icon: new fields.StringField({initial: ""}),
|
|
275
|
-
color: new fields.StringField({initial: "#ffffff"}),
|
|
276
|
-
${joinToNode(additionalFields, (field) => `${field.key.toLowerCase()}: new fields.${field.type.charAt(0).toUpperCase() + field.type.slice(1)}Field({initial: ${JSON.stringify(field.defaultValue)}})`, { appendNewLineIfNotEmpty: true, separator: ',' })}
|
|
277
|
-
}),
|
|
278
|
-
{initial: []}
|
|
279
|
-
),
|
|
275
|
+
return expandToNode `
|
|
276
|
+
${property.name.toLowerCase()}: new fields.ArrayField(
|
|
277
|
+
new fields.SchemaField({
|
|
278
|
+
value: new fields.StringField({
|
|
279
|
+
choices: [${choices.choices.map((x) => `"${choiceValue(x)}"`).join(", ")}]
|
|
280
|
+
}),
|
|
281
|
+
icon: new fields.StringField({initial: ""}),
|
|
282
|
+
color: new fields.StringField({initial: "#ffffff"}),
|
|
283
|
+
${joinToNode(additionalFields, (field) => `${field.key.toLowerCase()}: new fields.${field.type.charAt(0).toUpperCase() + field.type.slice(1)}Field({initial: ${JSON.stringify(field.defaultValue)}})`, { appendNewLineIfNotEmpty: true, separator: ',' })}
|
|
284
|
+
}),
|
|
285
|
+
{initial: []}
|
|
286
|
+
),
|
|
280
287
|
`;
|
|
281
288
|
}
|
|
282
|
-
return expandToNode `
|
|
283
|
-
${property.name.toLowerCase()}: new fields.ArrayField(
|
|
284
|
-
new fields.SchemaField({
|
|
285
|
-
value: new fields.StringField({
|
|
286
|
-
choices: [${choices.choices.map((x) => `"${choiceValue(x)}"`).join(", ")}]
|
|
287
|
-
}),
|
|
288
|
-
icon: new fields.StringField({initial: ""}),
|
|
289
|
-
color: new fields.StringField({initial: "#ffffff"})
|
|
290
|
-
}),
|
|
291
|
-
{initial: []}
|
|
292
|
-
),
|
|
289
|
+
return expandToNode `
|
|
290
|
+
${property.name.toLowerCase()}: new fields.ArrayField(
|
|
291
|
+
new fields.SchemaField({
|
|
292
|
+
value: new fields.StringField({
|
|
293
|
+
choices: [${choices.choices.map((x) => `"${choiceValue(x)}"`).join(", ")}]
|
|
294
|
+
}),
|
|
295
|
+
icon: new fields.StringField({initial: ""}),
|
|
296
|
+
color: new fields.StringField({initial: "#ffffff"})
|
|
297
|
+
}),
|
|
298
|
+
{initial: []}
|
|
299
|
+
),
|
|
293
300
|
`;
|
|
294
301
|
}
|
|
295
302
|
if (isDateExp(property)) {
|
|
296
|
-
return expandToNode `
|
|
297
|
-
${property.name.toLowerCase()}: new fields.StringField({initial: new Intl.DateTimeFormat('en-CA').format(new Date()) }),
|
|
303
|
+
return expandToNode `
|
|
304
|
+
${property.name.toLowerCase()}: new fields.StringField({initial: new Intl.DateTimeFormat('en-CA').format(new Date()) }),
|
|
298
305
|
`;
|
|
299
306
|
}
|
|
300
307
|
if (isTimeExp(property)) {
|
|
301
|
-
return expandToNode `
|
|
302
|
-
${property.name.toLowerCase()}: new fields.StringField({initial: new Date().toTimeString().slice(0, 5) }),
|
|
308
|
+
return expandToNode `
|
|
309
|
+
${property.name.toLowerCase()}: new fields.StringField({initial: new Date().toTimeString().slice(0, 5) }),
|
|
303
310
|
`;
|
|
304
311
|
}
|
|
305
312
|
if (isDateTimeExp(property)) {
|
|
306
|
-
return expandToNode `
|
|
307
|
-
${property.name.toLowerCase()}: new fields.StringField({initial: new Date().toISOString().slice(0, 16) }),
|
|
313
|
+
return expandToNode `
|
|
314
|
+
${property.name.toLowerCase()}: new fields.StringField({initial: new Date().toISOString().slice(0, 16) }),
|
|
308
315
|
`;
|
|
309
316
|
}
|
|
310
317
|
if (isHtmlExp(property)) {
|
|
311
|
-
return expandToNode `
|
|
312
|
-
${property.name.toLowerCase()}: new fields.HTMLField({required: false, blank: true, initial: ""}),
|
|
318
|
+
return expandToNode `
|
|
319
|
+
${property.name.toLowerCase()}: new fields.HTMLField({required: false, blank: true, initial: ""}),
|
|
313
320
|
`;
|
|
314
321
|
}
|
|
315
322
|
if (isBooleanExp(property)) {
|
|
316
|
-
return expandToNode `
|
|
317
|
-
${property.name.toLowerCase()}: new fields.BooleanField(),
|
|
323
|
+
return expandToNode `
|
|
324
|
+
${property.name.toLowerCase()}: new fields.BooleanField(),
|
|
318
325
|
`;
|
|
319
326
|
}
|
|
320
327
|
function getNumberOrNothing(param) {
|
|
@@ -330,12 +337,12 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
330
337
|
const min = (_a = getNumberOrNothing(minParam)) !== null && _a !== void 0 ? _a : -100;
|
|
331
338
|
const max = (_b = getNumberOrNothing(maxParam)) !== null && _b !== void 0 ? _b : 100;
|
|
332
339
|
const initial = (_c = getNumberOrNothing(initialParam)) !== null && _c !== void 0 ? _c : 0;
|
|
333
|
-
return expandToNode `
|
|
334
|
-
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
335
|
-
value: new fields.NumberField({min: ${min}, initial: ${initial}, integer: true}),
|
|
336
|
-
temp: new fields.NumberField({initial: 0, min: 0, integer: true}),
|
|
337
|
-
max: new fields.NumberField({min: 0, initial: ${max}, integer: true}),
|
|
338
|
-
}),
|
|
340
|
+
return expandToNode `
|
|
341
|
+
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
342
|
+
value: new fields.NumberField({min: ${min}, initial: ${initial}, integer: true}),
|
|
343
|
+
temp: new fields.NumberField({initial: 0, min: 0, integer: true}),
|
|
344
|
+
max: new fields.NumberField({min: 0, initial: ${max}, integer: true}),
|
|
345
|
+
}),
|
|
339
346
|
`;
|
|
340
347
|
}
|
|
341
348
|
if (isAttributeExp(property)) {
|
|
@@ -343,11 +350,11 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
343
350
|
const maxParam = property.params.find(p => isNumberParamMax(p));
|
|
344
351
|
const min = (_d = minParam === null || minParam === void 0 ? void 0 : minParam.value) !== null && _d !== void 0 ? _d : 0;
|
|
345
352
|
const max = (_e = maxParam === null || maxParam === void 0 ? void 0 : maxParam.value) !== null && _e !== void 0 ? _e : 100;
|
|
346
|
-
return expandToNode `
|
|
347
|
-
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
348
|
-
value: new fields.NumberField({integer: true, min: ${min}, initial: ${min}}),
|
|
349
|
-
max: new fields.NumberField({integer: true, min: 0, initial: ${max}}),
|
|
350
|
-
}),
|
|
353
|
+
return expandToNode `
|
|
354
|
+
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
355
|
+
value: new fields.NumberField({integer: true, min: ${min}, initial: ${min}}),
|
|
356
|
+
max: new fields.NumberField({integer: true, min: 0, initial: ${max}}),
|
|
357
|
+
}),
|
|
351
358
|
`;
|
|
352
359
|
}
|
|
353
360
|
if (isTrackerExp(property)) {
|
|
@@ -357,13 +364,13 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
357
364
|
const min = (_f = getNumberOrNothing(minParam)) !== null && _f !== void 0 ? _f : -10;
|
|
358
365
|
const max = (_g = getNumberOrNothing(maxParam)) !== null && _g !== void 0 ? _g : 10;
|
|
359
366
|
const initial = (_h = getNumberOrNothing(initialParam)) !== null && _h !== void 0 ? _h : 0;
|
|
360
|
-
return expandToNode `
|
|
361
|
-
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
362
|
-
min: new fields.NumberField({integer: true, initial: ${min}}),
|
|
363
|
-
value: new fields.NumberField({integer: true, initial: ${initial}}),
|
|
364
|
-
temp: new fields.NumberField({initial: 0, min: 0, integer: true}),
|
|
365
|
-
max: new fields.NumberField({integer: true, min: 0, initial: ${max}}),
|
|
366
|
-
}),
|
|
367
|
+
return expandToNode `
|
|
368
|
+
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
369
|
+
min: new fields.NumberField({integer: true, initial: ${min}}),
|
|
370
|
+
value: new fields.NumberField({integer: true, initial: ${initial}}),
|
|
371
|
+
temp: new fields.NumberField({initial: 0, min: 0, integer: true}),
|
|
372
|
+
max: new fields.NumberField({integer: true, min: 0, initial: ${max}}),
|
|
373
|
+
}),
|
|
367
374
|
`;
|
|
368
375
|
}
|
|
369
376
|
if (isDamageTrackExp(property)) {
|
|
@@ -371,16 +378,16 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
371
378
|
const max = (_j = maxParam === null || maxParam === void 0 ? void 0 : maxParam.value) !== null && _j !== void 0 ? _j : 5;
|
|
372
379
|
const typesParam = property.params.find(x => isDamageTrackTypesParam(x));
|
|
373
380
|
const types = (_k = typesParam === null || typesParam === void 0 ? void 0 : typesParam.types) !== null && _k !== void 0 ? _k : [];
|
|
374
|
-
return expandToNode `
|
|
375
|
-
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
376
|
-
empty: new fields.NumberField({initial: ${max}, min: 0, max: ${max}, integer: true}),
|
|
377
|
-
${joinToNode(types, type => `${type}: new fields.NumberField({initial: 0, min: 0, max: ${max}, integer: true}),`, { appendNewLineIfNotEmpty: true })}
|
|
378
|
-
}),
|
|
381
|
+
return expandToNode `
|
|
382
|
+
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
383
|
+
empty: new fields.NumberField({initial: ${max}, min: 0, max: ${max}, integer: true}),
|
|
384
|
+
${joinToNode(types, type => `${type}: new fields.NumberField({initial: 0, min: 0, max: ${max}, integer: true}),`, { appendNewLineIfNotEmpty: true })}
|
|
385
|
+
}),
|
|
379
386
|
`;
|
|
380
387
|
}
|
|
381
388
|
if (isSingleDocumentExp(property) || isMacroField(property)) {
|
|
382
|
-
return expandToNode `
|
|
383
|
-
${property.name.toLowerCase()}: new UuidDocumentField(),
|
|
389
|
+
return expandToNode `
|
|
390
|
+
${property.name.toLowerCase()}: new UuidDocumentField(),
|
|
384
391
|
`;
|
|
385
392
|
}
|
|
386
393
|
if (isDocumentChoiceExp(property)) {
|
|
@@ -390,65 +397,65 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
390
397
|
// ${property.name.toLowerCase()}: new fields.ArrayField(new UuidDocumentField()),
|
|
391
398
|
// `;
|
|
392
399
|
// }
|
|
393
|
-
return expandToNode `
|
|
394
|
-
${property.name.toLowerCase()}: new UuidDocumentField(),
|
|
400
|
+
return expandToNode `
|
|
401
|
+
${property.name.toLowerCase()}: new UuidDocumentField(),
|
|
395
402
|
`;
|
|
396
403
|
}
|
|
397
404
|
if (isDocumentChoicesExp(property)) {
|
|
398
|
-
return expandToNode `
|
|
399
|
-
${property.name.toLowerCase()}: new UuidDocumentArrayField(),
|
|
405
|
+
return expandToNode `
|
|
406
|
+
${property.name.toLowerCase()}: new UuidDocumentArrayField(),
|
|
400
407
|
`;
|
|
401
408
|
}
|
|
402
409
|
if (isPaperDollExp(property)) {
|
|
403
410
|
function generatePaperDollElementField(property) {
|
|
404
|
-
return expandToNode `
|
|
405
|
-
${property.name.toLowerCase()}: new UuidDocumentField()
|
|
411
|
+
return expandToNode `
|
|
412
|
+
${property.name.toLowerCase()}: new UuidDocumentField()
|
|
406
413
|
`;
|
|
407
414
|
}
|
|
408
|
-
return expandToNode `
|
|
409
|
-
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
410
|
-
${joinToNode(property.elements, property => generatePaperDollElementField(property), { appendNewLineIfNotEmpty: true, separator: ',' })}
|
|
411
|
-
}),
|
|
415
|
+
return expandToNode `
|
|
416
|
+
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
417
|
+
${joinToNode(property.elements, property => generatePaperDollElementField(property), { appendNewLineIfNotEmpty: true, separator: ',' })}
|
|
418
|
+
}),
|
|
412
419
|
`;
|
|
413
420
|
}
|
|
414
421
|
if (isParentPropertyRefExp(property)) {
|
|
415
422
|
console.log(`Parent property ref: ${property.name}`);
|
|
416
|
-
return expandToNode `
|
|
417
|
-
${property.name.toLowerCase()}: new fields.StringField({initial: ""}),
|
|
423
|
+
return expandToNode `
|
|
424
|
+
${property.name.toLowerCase()}: new fields.StringField({initial: ""}),
|
|
418
425
|
`;
|
|
419
426
|
}
|
|
420
427
|
if (isSelfPropertyRefExp(property)) {
|
|
421
428
|
console.log(`Self property ref: ${property.name}`);
|
|
422
|
-
return expandToNode `
|
|
423
|
-
${property.name.toLowerCase()}: new fields.StringField({initial: ""}),
|
|
429
|
+
return expandToNode `
|
|
430
|
+
${property.name.toLowerCase()}: new fields.StringField({initial: ""}),
|
|
424
431
|
`;
|
|
425
432
|
}
|
|
426
433
|
if (isDiceFields(property)) {
|
|
427
434
|
let initialParam = property.params.find(p => isDieInitialParam(p));
|
|
428
435
|
let initialDie = (_l = initialParam === null || initialParam === void 0 ? void 0 : initialParam.value) !== null && _l !== void 0 ? _l : "d20";
|
|
429
436
|
if (isDieField(property)) {
|
|
430
|
-
return expandToNode `
|
|
431
|
-
${property.name.toLowerCase()}: new fields.StringField({initial: "${initialDie}"}),
|
|
437
|
+
return expandToNode `
|
|
438
|
+
${property.name.toLowerCase()}: new fields.StringField({initial: "${initialDie}"}),
|
|
432
439
|
`;
|
|
433
440
|
}
|
|
434
441
|
if (isDiceField(property)) {
|
|
435
|
-
return expandToNode `
|
|
436
|
-
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
437
|
-
die: new fields.StringField({initial: "${initialDie}"}),
|
|
438
|
-
number: new fields.NumberField({integer: true, initial: 0, min: 0}),
|
|
439
|
-
}),
|
|
442
|
+
return expandToNode `
|
|
443
|
+
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
444
|
+
die: new fields.StringField({initial: "${initialDie}"}),
|
|
445
|
+
number: new fields.NumberField({integer: true, initial: 0, min: 0}),
|
|
446
|
+
}),
|
|
440
447
|
`;
|
|
441
448
|
}
|
|
442
449
|
}
|
|
443
450
|
if (isMeasuredTemplateField(property)) {
|
|
444
|
-
return expandToNode `
|
|
445
|
-
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
446
|
-
type: new fields.StringField({initial: "circle"}),
|
|
447
|
-
distance: new fields.NumberField({integer: true, initial: 5}),
|
|
448
|
-
direction: new fields.NumberField({integer: true, initial: 0}),
|
|
449
|
-
angle: new fields.NumberField({integer: true, initial: 0}),
|
|
450
|
-
width: new fields.NumberField({integer: true, initial: 0}),
|
|
451
|
-
}),
|
|
451
|
+
return expandToNode `
|
|
452
|
+
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
453
|
+
type: new fields.StringField({initial: "circle"}),
|
|
454
|
+
distance: new fields.NumberField({integer: true, initial: 5}),
|
|
455
|
+
direction: new fields.NumberField({integer: true, initial: 0}),
|
|
456
|
+
angle: new fields.NumberField({integer: true, initial: 0}),
|
|
457
|
+
width: new fields.NumberField({integer: true, initial: 0}),
|
|
458
|
+
}),
|
|
452
459
|
`;
|
|
453
460
|
}
|
|
454
461
|
if (isLayout(property)) {
|
|
@@ -461,17 +468,17 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
461
468
|
if (whenParam == undefined || whenParam.when == undefined)
|
|
462
469
|
return undefined;
|
|
463
470
|
console.log(`Generating calculated status effect for ${property.name}`);
|
|
464
|
-
return expandToNode `
|
|
465
|
-
get ${property.name.toLowerCase()}() {
|
|
466
|
-
return ${translateExpression(entry, id, whenParam === null || whenParam === void 0 ? void 0 : whenParam.when, true, property)};
|
|
467
|
-
}
|
|
471
|
+
return expandToNode `
|
|
472
|
+
get ${property.name.toLowerCase()}() {
|
|
473
|
+
return ${translateExpression(entry, id, whenParam === null || whenParam === void 0 ? void 0 : whenParam.when, true, property)};
|
|
474
|
+
}
|
|
468
475
|
`.appendNewLine().appendNewLine();
|
|
469
476
|
}
|
|
470
477
|
function generateStatusEffect(property) {
|
|
471
|
-
return expandToNode `
|
|
472
|
-
get ${property.name.toLowerCase()}() {
|
|
473
|
-
return this.parent.statuses.has("${property.name.toLowerCase()}");
|
|
474
|
-
}
|
|
478
|
+
return expandToNode `
|
|
479
|
+
get ${property.name.toLowerCase()}() {
|
|
480
|
+
return this.parent.statuses.has("${property.name.toLowerCase()}");
|
|
481
|
+
}
|
|
475
482
|
`;
|
|
476
483
|
}
|
|
477
484
|
let statusEffects = getAllOfType(document.body, isStatusProperty);
|
|
@@ -525,42 +532,42 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
525
532
|
}
|
|
526
533
|
const damageTypeFields = damageTypes.map(damageType => {
|
|
527
534
|
const safeTypeName = damageType.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
528
|
-
return expandToNode `
|
|
529
|
-
// ${damageType} damage type fields
|
|
530
|
-
${safeTypeName}bonusdamage: new fields.NumberField({required: false, initial: 0, integer: true}),
|
|
531
|
-
${safeTypeName}damageresistanceflat: new fields.NumberField({required: false, initial: 0, integer: true}),
|
|
532
|
-
${safeTypeName}damageresistancepercent: new fields.NumberField({required: false, initial: 0, min: 0, max: 100, integer: true}),
|
|
535
|
+
return expandToNode `
|
|
536
|
+
// ${damageType} damage type fields
|
|
537
|
+
${safeTypeName}bonusdamage: new fields.NumberField({required: false, initial: 0, integer: true}),
|
|
538
|
+
${safeTypeName}damageresistanceflat: new fields.NumberField({required: false, initial: 0, integer: true}),
|
|
539
|
+
${safeTypeName}damageresistancepercent: new fields.NumberField({required: false, initial: 0, min: 0, max: 100, integer: true}),
|
|
533
540
|
`;
|
|
534
541
|
});
|
|
535
|
-
return expandToNode `
|
|
536
|
-
// Auto-generated damage type Active Effect fields
|
|
537
|
-
${joinToNode(damageTypeFields, field => field, { appendNewLineIfNotEmpty: true })}
|
|
542
|
+
return expandToNode `
|
|
543
|
+
// Auto-generated damage type Active Effect fields
|
|
544
|
+
${joinToNode(damageTypeFields, field => field, { appendNewLineIfNotEmpty: true })}
|
|
538
545
|
`;
|
|
539
546
|
}
|
|
540
|
-
const fileNode = expandToNode `
|
|
541
|
-
import ${config.name}Actor from "../../documents/actor.mjs";
|
|
542
|
-
import ${config.name}Item from "../../documents/item.mjs";
|
|
543
|
-
import UuidDocumentField from "../UuidDocumentField.mjs";
|
|
544
|
-
import UuidDocumentArrayField from "../UuidDocumentArrayField.mjs";
|
|
545
|
-
|
|
546
|
-
export default class ${document.name}TypeDataModel extends foundry.abstract.DataModel {
|
|
547
|
-
/** @inheritDoc */
|
|
548
|
-
static defineSchema() {
|
|
549
|
-
const fields = foundry.data.fields;
|
|
550
|
-
return {
|
|
551
|
-
description: new fields.HTMLField({required: false, blank: true, initial: ""}),
|
|
552
|
-
${joinToNode(document.body, property => generateField(property), { appendNewLineIfNotEmpty: true })}
|
|
553
|
-
${expandToNode `${generateDocumentPromptModels(document)}`.appendNewLineIfNotEmpty()}
|
|
554
|
-
${isActor(document) ? expandToNode `${generateDamageTypeFields(entry)}`.appendNewLineIfNotEmpty() : ""}
|
|
555
|
-
${!isActor(document) ? "pinned: new fields.BooleanField({initial: false})," : ""}
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
/* -------------------------------------------- */
|
|
560
|
-
|
|
561
|
-
${joinToNode(calculatedStatusEffects, effect => generateCalculatedStatusEffect(effect), { appendNewLineIfNotEmpty: true })}
|
|
562
|
-
${joinToNode(nonCalculatedStatusEffects, effect => generateStatusEffect(effect), { appendNewLineIfNotEmpty: true })}
|
|
563
|
-
};
|
|
547
|
+
const fileNode = expandToNode `
|
|
548
|
+
import ${config.name}Actor from "../../documents/actor.mjs";
|
|
549
|
+
import ${config.name}Item from "../../documents/item.mjs";
|
|
550
|
+
import UuidDocumentField from "../UuidDocumentField.mjs";
|
|
551
|
+
import UuidDocumentArrayField from "../UuidDocumentArrayField.mjs";
|
|
552
|
+
|
|
553
|
+
export default class ${document.name}TypeDataModel extends foundry.abstract.DataModel {
|
|
554
|
+
/** @inheritDoc */
|
|
555
|
+
static defineSchema() {
|
|
556
|
+
const fields = foundry.data.fields;
|
|
557
|
+
return {
|
|
558
|
+
description: new fields.HTMLField({required: false, blank: true, initial: ""}),
|
|
559
|
+
${joinToNode(document.body, property => generateField(property), { appendNewLineIfNotEmpty: true })}
|
|
560
|
+
${expandToNode `${generateDocumentPromptModels(document)}`.appendNewLineIfNotEmpty()}
|
|
561
|
+
${isActor(document) ? expandToNode `${generateDamageTypeFields(entry)}`.appendNewLineIfNotEmpty() : ""}
|
|
562
|
+
${!isActor(document) ? "pinned: new fields.BooleanField({initial: false})," : ""}
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/* -------------------------------------------- */
|
|
567
|
+
|
|
568
|
+
${joinToNode(calculatedStatusEffects, effect => generateCalculatedStatusEffect(effect), { appendNewLineIfNotEmpty: true })}
|
|
569
|
+
${joinToNode(nonCalculatedStatusEffects, effect => generateStatusEffect(effect), { appendNewLineIfNotEmpty: true })}
|
|
570
|
+
};
|
|
564
571
|
`.appendNewLineIfNotEmpty();
|
|
565
572
|
if (!fs.existsSync(dataModelPath)) {
|
|
566
573
|
fs.mkdirSync(dataModelPath, { recursive: true });
|
|
@@ -578,44 +585,44 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
578
585
|
function generatePromptModel(prompt) {
|
|
579
586
|
const variable = AstUtils.getContainerOfType(prompt.$container, isVariableExpression);
|
|
580
587
|
const action = AstUtils.getContainerOfType(prompt.$container, isAction);
|
|
581
|
-
return expandToNode `
|
|
582
|
-
${action === null || action === void 0 ? void 0 : action.name.toLowerCase()}${variable === null || variable === void 0 ? void 0 : variable.name.toLowerCase()}: new foundry.data.fields.SchemaField({
|
|
583
|
-
${joinToNode(prompt.body, property => generateField(property), { appendNewLineIfNotEmpty: true })}
|
|
584
|
-
}),
|
|
588
|
+
return expandToNode `
|
|
589
|
+
${action === null || action === void 0 ? void 0 : action.name.toLowerCase()}${variable === null || variable === void 0 ? void 0 : variable.name.toLowerCase()}: new foundry.data.fields.SchemaField({
|
|
590
|
+
${joinToNode(prompt.body, property => generateField(property), { appendNewLineIfNotEmpty: true })}
|
|
591
|
+
}),
|
|
585
592
|
`;
|
|
586
593
|
}
|
|
587
594
|
}
|
|
588
595
|
export function generateUuidDocumentField(destination) {
|
|
589
596
|
const dataModelPath = path.join(destination, "system", "datamodels");
|
|
590
597
|
const generatedFilePath = path.join(dataModelPath, "UuidDocumentField.mjs");
|
|
591
|
-
const fileNode = expandToNode `
|
|
592
|
-
export default class UuidDocumentField extends foundry.data.fields.StringField {
|
|
593
|
-
|
|
594
|
-
/** @inheritdoc */
|
|
595
|
-
static get _defaults() {
|
|
596
|
-
return foundry.utils.mergeObject(super._defaults, {
|
|
597
|
-
required: true,
|
|
598
|
-
blank: false,
|
|
599
|
-
nullable: true,
|
|
600
|
-
initial: null,
|
|
601
|
-
readonly: false,
|
|
602
|
-
validationError: "is not a valid Document UUID string"
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
/** @override */
|
|
607
|
-
_cast(value) {
|
|
608
|
-
if ( value instanceof foundry.abstract.Document ) return value.uuid;
|
|
609
|
-
else return String(value);
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
/** @inheritdoc */
|
|
613
|
-
initialize(value, model, options={}) {
|
|
614
|
-
if ( !game.collections ) return value; // server-side
|
|
615
|
-
|
|
616
|
-
return () => fromUuidSync(value);
|
|
617
|
-
}
|
|
618
|
-
}
|
|
598
|
+
const fileNode = expandToNode `
|
|
599
|
+
export default class UuidDocumentField extends foundry.data.fields.StringField {
|
|
600
|
+
|
|
601
|
+
/** @inheritdoc */
|
|
602
|
+
static get _defaults() {
|
|
603
|
+
return foundry.utils.mergeObject(super._defaults, {
|
|
604
|
+
required: true,
|
|
605
|
+
blank: false,
|
|
606
|
+
nullable: true,
|
|
607
|
+
initial: null,
|
|
608
|
+
readonly: false,
|
|
609
|
+
validationError: "is not a valid Document UUID string"
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/** @override */
|
|
614
|
+
_cast(value) {
|
|
615
|
+
if ( value instanceof foundry.abstract.Document ) return value.uuid;
|
|
616
|
+
else return String(value);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/** @inheritdoc */
|
|
620
|
+
initialize(value, model, options={}) {
|
|
621
|
+
if ( !game.collections ) return value; // server-side
|
|
622
|
+
|
|
623
|
+
return () => fromUuidSync(value);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
619
626
|
`.appendNewLineIfNotEmpty();
|
|
620
627
|
if (!fs.existsSync(dataModelPath)) {
|
|
621
628
|
fs.mkdirSync(dataModelPath, { recursive: true });
|
|
@@ -625,44 +632,44 @@ export function generateUuidDocumentField(destination) {
|
|
|
625
632
|
export function generateUuidDocumentArrayField(destination) {
|
|
626
633
|
const dataModelPath = path.join(destination, "system", "datamodels");
|
|
627
634
|
const generatedFilePath = path.join(dataModelPath, "UuidDocumentArrayField.mjs");
|
|
628
|
-
const fileNode = expandToNode `
|
|
629
|
-
export default class UuidDocumentArrayField extends foundry.data.fields.ArrayField {
|
|
630
|
-
|
|
631
|
-
constructor(options = {}) {
|
|
632
|
-
super(new foundry.data.fields.StringField({
|
|
633
|
-
required: false,
|
|
634
|
-
blank: false,
|
|
635
|
-
nullable: false,
|
|
636
|
-
initial: null,
|
|
637
|
-
readonly: false,
|
|
638
|
-
validationError: "is not a valid Document UUID string"
|
|
639
|
-
}), foundry.utils.mergeObject({
|
|
640
|
-
initial: []
|
|
641
|
-
}, options));
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
/** @override */
|
|
645
|
-
_cast(value) {
|
|
646
|
-
if (!Array.isArray(value)) return [];
|
|
647
|
-
return value.map(item => {
|
|
648
|
-
if (item instanceof foundry.abstract.Document) return item.uuid;
|
|
649
|
-
return String(item);
|
|
650
|
-
}).filter(uuid => uuid && uuid !== "null" && uuid !== "undefined");
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
/** @inheritdoc */
|
|
654
|
-
initialize(value, model, options={}) {
|
|
655
|
-
if (!game.collections) return value; // server-side
|
|
656
|
-
if (!Array.isArray(value)) return [];
|
|
657
|
-
|
|
658
|
-
return () => {
|
|
659
|
-
return value.map(uuid => {
|
|
660
|
-
if (!uuid || uuid === "null" || uuid === "undefined") return null;
|
|
661
|
-
return fromUuidSync(uuid);
|
|
662
|
-
}).filter(Boolean);
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}
|
|
635
|
+
const fileNode = expandToNode `
|
|
636
|
+
export default class UuidDocumentArrayField extends foundry.data.fields.ArrayField {
|
|
637
|
+
|
|
638
|
+
constructor(options = {}) {
|
|
639
|
+
super(new foundry.data.fields.StringField({
|
|
640
|
+
required: false,
|
|
641
|
+
blank: false,
|
|
642
|
+
nullable: false,
|
|
643
|
+
initial: null,
|
|
644
|
+
readonly: false,
|
|
645
|
+
validationError: "is not a valid Document UUID string"
|
|
646
|
+
}), foundry.utils.mergeObject({
|
|
647
|
+
initial: []
|
|
648
|
+
}, options));
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/** @override */
|
|
652
|
+
_cast(value) {
|
|
653
|
+
if (!Array.isArray(value)) return [];
|
|
654
|
+
return value.map(item => {
|
|
655
|
+
if (item instanceof foundry.abstract.Document) return item.uuid;
|
|
656
|
+
return String(item);
|
|
657
|
+
}).filter(uuid => uuid && uuid !== "null" && uuid !== "undefined");
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/** @inheritdoc */
|
|
661
|
+
initialize(value, model, options={}) {
|
|
662
|
+
if (!game.collections) return value; // server-side
|
|
663
|
+
if (!Array.isArray(value)) return [];
|
|
664
|
+
|
|
665
|
+
return () => {
|
|
666
|
+
return value.map(uuid => {
|
|
667
|
+
if (!uuid || uuid === "null" || uuid === "undefined") return null;
|
|
668
|
+
return fromUuidSync(uuid);
|
|
669
|
+
}).filter(Boolean);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
666
673
|
`.appendNewLineIfNotEmpty();
|
|
667
674
|
if (!fs.existsSync(dataModelPath)) {
|
|
668
675
|
fs.mkdirSync(dataModelPath, { recursive: true });
|