intelligent-system-design-language 0.3.22 → 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 -1444
- 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 -1444
- 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 -654
- 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 +257 -257
- 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/measured-template-preview.js +221 -221
- package/out/cli/components/method-generator.js +548 -548
- 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 +285 -285
- 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 +80 -80
- package/out/cli/components/vue/vue-prompt-sheet-class-generator.js +317 -317
- package/out/cli/components/vue/vue-sheet-application-generator.js +1171 -1171
- package/out/cli/components/vue/vue-sheet-class-generator.js +510 -510
- package/out/cli/generator.js +438 -438
- package/out/extension/github/githubManager.js +35 -35
- package/out/extension/github/githubQuickActions.js +120 -120
- package/out/extension/github/system-workflow.yml +47 -47
- package/out/extension/main.cjs.map +1 -1
- package/out/extension/package.json +419 -419
- package/out/language/generated/grammar.js +14240 -14240
- package/out/language/main.cjs.map +1 -1
- package/out/package.json +419 -419
- package/out/progressbar.min.js +6 -6
- package/out/styles.scss +762 -762
- package/package.json +419 -419
|
@@ -35,8 +35,8 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
35
35
|
if (maxParam && typeof (maxParam.value) === 'number') {
|
|
36
36
|
options += `, max: ${maxParam.value}`;
|
|
37
37
|
}
|
|
38
|
-
return expandToNode `
|
|
39
|
-
${property.name.toLowerCase()}: new fields.NumberField({${options}}),
|
|
38
|
+
return expandToNode `
|
|
39
|
+
${property.name.toLowerCase()}: new fields.NumberField({${options}}),
|
|
40
40
|
`;
|
|
41
41
|
}
|
|
42
42
|
if (isMoneyField(property)) {
|
|
@@ -46,24 +46,24 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
46
46
|
const denominationFields = property.denominations.map(denom => {
|
|
47
47
|
return `${denom.name.toLowerCase()}: new fields.NumberField({initial: 0, nullable: false})`;
|
|
48
48
|
}).join(',\n ');
|
|
49
|
-
return expandToNode `
|
|
50
|
-
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
51
|
-
${denominationFields}
|
|
52
|
-
}),
|
|
49
|
+
return expandToNode `
|
|
50
|
+
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
51
|
+
${denominationFields}
|
|
52
|
+
}),
|
|
53
53
|
`;
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
56
|
// Single currency money - store as simple NumberField
|
|
57
57
|
const initialParam = property.params.find(p => p.$type === 'NumberParamInitial');
|
|
58
58
|
const initial = (initialParam === null || initialParam === void 0 ? void 0 : initialParam.value) || 0;
|
|
59
|
-
return expandToNode `
|
|
60
|
-
${property.name.toLowerCase()}: new fields.NumberField({initial: ${initial}, nullable: false}),
|
|
59
|
+
return expandToNode `
|
|
60
|
+
${property.name.toLowerCase()}: new fields.NumberField({initial: ${initial}, nullable: false}),
|
|
61
61
|
`;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
if (isStringExp(property)) {
|
|
65
|
-
return expandToNode `
|
|
66
|
-
${property.name.toLowerCase()}: new fields.StringField({initial: ""}),
|
|
65
|
+
return expandToNode `
|
|
66
|
+
${property.name.toLowerCase()}: new fields.StringField({initial: ""}),
|
|
67
67
|
`;
|
|
68
68
|
}
|
|
69
69
|
if (isStringChoiceField(property)) {
|
|
@@ -112,27 +112,27 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
112
112
|
return acc;
|
|
113
113
|
}, []);
|
|
114
114
|
if (additionalFields.length > 0) {
|
|
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
|
-
}),
|
|
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
|
+
}),
|
|
125
125
|
`;
|
|
126
126
|
}
|
|
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
|
-
}),
|
|
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
|
+
}),
|
|
136
136
|
`;
|
|
137
137
|
}
|
|
138
138
|
if (isDamageTypeChoiceField(property)) {
|
|
@@ -181,38 +181,38 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
181
181
|
return acc;
|
|
182
182
|
}, []);
|
|
183
183
|
if (additionalFields.length > 0) {
|
|
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
|
-
}),
|
|
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
|
+
}),
|
|
194
194
|
`;
|
|
195
195
|
}
|
|
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
|
-
}),
|
|
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
|
+
}),
|
|
205
205
|
`;
|
|
206
206
|
}
|
|
207
207
|
if (isStringChoicesField(property)) {
|
|
208
208
|
let choices = property.params.find(p => p.$type === 'StringChoicesParamChoices');
|
|
209
209
|
if (!choices || !choices.choices || choices.choices.length === 0) {
|
|
210
210
|
// Fallback for simple string array if no choices defined
|
|
211
|
-
return expandToNode `
|
|
212
|
-
${property.name.toLowerCase()}: new fields.ArrayField(
|
|
213
|
-
new fields.StringField({}),
|
|
214
|
-
{initial: []}
|
|
215
|
-
),
|
|
211
|
+
return expandToNode `
|
|
212
|
+
${property.name.toLowerCase()}: new fields.ArrayField(
|
|
213
|
+
new fields.StringField({}),
|
|
214
|
+
{initial: []}
|
|
215
|
+
),
|
|
216
216
|
`;
|
|
217
217
|
}
|
|
218
218
|
function choiceValue(choice) {
|
|
@@ -245,13 +245,13 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
245
245
|
let hasExtendedChoices = choices.choices.some((choice) => isStringExtendedChoice(choice.value));
|
|
246
246
|
if (!hasExtendedChoices) {
|
|
247
247
|
// Simple string choices - use array of strings
|
|
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
|
+
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
|
+
),
|
|
255
255
|
`;
|
|
256
256
|
}
|
|
257
257
|
// Extended choices - use array of schema objects like choice<string>
|
|
@@ -272,56 +272,56 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
272
272
|
return acc;
|
|
273
273
|
}, []);
|
|
274
274
|
if (additionalFields.length > 0) {
|
|
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
|
-
),
|
|
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
|
+
),
|
|
287
287
|
`;
|
|
288
288
|
}
|
|
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
|
-
),
|
|
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
|
+
),
|
|
300
300
|
`;
|
|
301
301
|
}
|
|
302
302
|
if (isDateExp(property)) {
|
|
303
|
-
return expandToNode `
|
|
304
|
-
${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()) }),
|
|
305
305
|
`;
|
|
306
306
|
}
|
|
307
307
|
if (isTimeExp(property)) {
|
|
308
|
-
return expandToNode `
|
|
309
|
-
${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) }),
|
|
310
310
|
`;
|
|
311
311
|
}
|
|
312
312
|
if (isDateTimeExp(property)) {
|
|
313
|
-
return expandToNode `
|
|
314
|
-
${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) }),
|
|
315
315
|
`;
|
|
316
316
|
}
|
|
317
317
|
if (isHtmlExp(property)) {
|
|
318
|
-
return expandToNode `
|
|
319
|
-
${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: ""}),
|
|
320
320
|
`;
|
|
321
321
|
}
|
|
322
322
|
if (isBooleanExp(property)) {
|
|
323
|
-
return expandToNode `
|
|
324
|
-
${property.name.toLowerCase()}: new fields.BooleanField(),
|
|
323
|
+
return expandToNode `
|
|
324
|
+
${property.name.toLowerCase()}: new fields.BooleanField(),
|
|
325
325
|
`;
|
|
326
326
|
}
|
|
327
327
|
function getNumberOrNothing(param) {
|
|
@@ -337,12 +337,12 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
337
337
|
const min = (_a = getNumberOrNothing(minParam)) !== null && _a !== void 0 ? _a : -100;
|
|
338
338
|
const max = (_b = getNumberOrNothing(maxParam)) !== null && _b !== void 0 ? _b : 100;
|
|
339
339
|
const initial = (_c = getNumberOrNothing(initialParam)) !== null && _c !== void 0 ? _c : 0;
|
|
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
|
-
}),
|
|
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
|
+
}),
|
|
346
346
|
`;
|
|
347
347
|
}
|
|
348
348
|
if (isAttributeExp(property)) {
|
|
@@ -350,11 +350,11 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
350
350
|
const maxParam = property.params.find(p => isNumberParamMax(p));
|
|
351
351
|
const min = (_d = minParam === null || minParam === void 0 ? void 0 : minParam.value) !== null && _d !== void 0 ? _d : 0;
|
|
352
352
|
const max = (_e = maxParam === null || maxParam === void 0 ? void 0 : maxParam.value) !== null && _e !== void 0 ? _e : 100;
|
|
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
|
-
}),
|
|
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
|
+
}),
|
|
358
358
|
`;
|
|
359
359
|
}
|
|
360
360
|
if (isTrackerExp(property)) {
|
|
@@ -364,13 +364,13 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
364
364
|
const min = (_f = getNumberOrNothing(minParam)) !== null && _f !== void 0 ? _f : -10;
|
|
365
365
|
const max = (_g = getNumberOrNothing(maxParam)) !== null && _g !== void 0 ? _g : 10;
|
|
366
366
|
const initial = (_h = getNumberOrNothing(initialParam)) !== null && _h !== void 0 ? _h : 0;
|
|
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
|
+
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
|
+
}),
|
|
374
374
|
`;
|
|
375
375
|
}
|
|
376
376
|
if (isDamageTrackExp(property)) {
|
|
@@ -378,16 +378,16 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
378
378
|
const max = (_j = maxParam === null || maxParam === void 0 ? void 0 : maxParam.value) !== null && _j !== void 0 ? _j : 5;
|
|
379
379
|
const typesParam = property.params.find(x => isDamageTrackTypesParam(x));
|
|
380
380
|
const types = (_k = typesParam === null || typesParam === void 0 ? void 0 : typesParam.types) !== null && _k !== void 0 ? _k : [];
|
|
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
|
-
}),
|
|
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
|
+
}),
|
|
386
386
|
`;
|
|
387
387
|
}
|
|
388
388
|
if (isSingleDocumentExp(property) || isMacroField(property)) {
|
|
389
|
-
return expandToNode `
|
|
390
|
-
${property.name.toLowerCase()}: new UuidDocumentField(),
|
|
389
|
+
return expandToNode `
|
|
390
|
+
${property.name.toLowerCase()}: new UuidDocumentField(),
|
|
391
391
|
`;
|
|
392
392
|
}
|
|
393
393
|
if (isDocumentChoiceExp(property)) {
|
|
@@ -397,65 +397,65 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
397
397
|
// ${property.name.toLowerCase()}: new fields.ArrayField(new UuidDocumentField()),
|
|
398
398
|
// `;
|
|
399
399
|
// }
|
|
400
|
-
return expandToNode `
|
|
401
|
-
${property.name.toLowerCase()}: new UuidDocumentField(),
|
|
400
|
+
return expandToNode `
|
|
401
|
+
${property.name.toLowerCase()}: new UuidDocumentField(),
|
|
402
402
|
`;
|
|
403
403
|
}
|
|
404
404
|
if (isDocumentChoicesExp(property)) {
|
|
405
|
-
return expandToNode `
|
|
406
|
-
${property.name.toLowerCase()}: new UuidDocumentArrayField(),
|
|
405
|
+
return expandToNode `
|
|
406
|
+
${property.name.toLowerCase()}: new UuidDocumentArrayField(),
|
|
407
407
|
`;
|
|
408
408
|
}
|
|
409
409
|
if (isPaperDollExp(property)) {
|
|
410
410
|
function generatePaperDollElementField(property) {
|
|
411
|
-
return expandToNode `
|
|
412
|
-
${property.name.toLowerCase()}: new UuidDocumentField()
|
|
411
|
+
return expandToNode `
|
|
412
|
+
${property.name.toLowerCase()}: new UuidDocumentField()
|
|
413
413
|
`;
|
|
414
414
|
}
|
|
415
|
-
return expandToNode `
|
|
416
|
-
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
417
|
-
${joinToNode(property.elements, property => generatePaperDollElementField(property), { appendNewLineIfNotEmpty: true, separator: ',' })}
|
|
418
|
-
}),
|
|
415
|
+
return expandToNode `
|
|
416
|
+
${property.name.toLowerCase()}: new fields.SchemaField({
|
|
417
|
+
${joinToNode(property.elements, property => generatePaperDollElementField(property), { appendNewLineIfNotEmpty: true, separator: ',' })}
|
|
418
|
+
}),
|
|
419
419
|
`;
|
|
420
420
|
}
|
|
421
421
|
if (isParentPropertyRefExp(property)) {
|
|
422
422
|
console.log(`Parent property ref: ${property.name}`);
|
|
423
|
-
return expandToNode `
|
|
424
|
-
${property.name.toLowerCase()}: new fields.StringField({initial: ""}),
|
|
423
|
+
return expandToNode `
|
|
424
|
+
${property.name.toLowerCase()}: new fields.StringField({initial: ""}),
|
|
425
425
|
`;
|
|
426
426
|
}
|
|
427
427
|
if (isSelfPropertyRefExp(property)) {
|
|
428
428
|
console.log(`Self property ref: ${property.name}`);
|
|
429
|
-
return expandToNode `
|
|
430
|
-
${property.name.toLowerCase()}: new fields.StringField({initial: ""}),
|
|
429
|
+
return expandToNode `
|
|
430
|
+
${property.name.toLowerCase()}: new fields.StringField({initial: ""}),
|
|
431
431
|
`;
|
|
432
432
|
}
|
|
433
433
|
if (isDiceFields(property)) {
|
|
434
434
|
let initialParam = property.params.find(p => isDieInitialParam(p));
|
|
435
435
|
let initialDie = (_l = initialParam === null || initialParam === void 0 ? void 0 : initialParam.value) !== null && _l !== void 0 ? _l : "d20";
|
|
436
436
|
if (isDieField(property)) {
|
|
437
|
-
return expandToNode `
|
|
438
|
-
${property.name.toLowerCase()}: new fields.StringField({initial: "${initialDie}"}),
|
|
437
|
+
return expandToNode `
|
|
438
|
+
${property.name.toLowerCase()}: new fields.StringField({initial: "${initialDie}"}),
|
|
439
439
|
`;
|
|
440
440
|
}
|
|
441
441
|
if (isDiceField(property)) {
|
|
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
|
-
}),
|
|
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
|
+
}),
|
|
447
447
|
`;
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
if (isMeasuredTemplateField(property)) {
|
|
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
|
-
}),
|
|
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
|
+
}),
|
|
459
459
|
`;
|
|
460
460
|
}
|
|
461
461
|
if (isLayout(property)) {
|
|
@@ -468,17 +468,17 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
468
468
|
if (whenParam == undefined || whenParam.when == undefined)
|
|
469
469
|
return undefined;
|
|
470
470
|
console.log(`Generating calculated status effect for ${property.name}`);
|
|
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
|
-
}
|
|
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
|
+
}
|
|
475
475
|
`.appendNewLine().appendNewLine();
|
|
476
476
|
}
|
|
477
477
|
function generateStatusEffect(property) {
|
|
478
|
-
return expandToNode `
|
|
479
|
-
get ${property.name.toLowerCase()}() {
|
|
480
|
-
return this.parent.statuses.has("${property.name.toLowerCase()}");
|
|
481
|
-
}
|
|
478
|
+
return expandToNode `
|
|
479
|
+
get ${property.name.toLowerCase()}() {
|
|
480
|
+
return this.parent.statuses.has("${property.name.toLowerCase()}");
|
|
481
|
+
}
|
|
482
482
|
`;
|
|
483
483
|
}
|
|
484
484
|
let statusEffects = getAllOfType(document.body, isStatusProperty);
|
|
@@ -532,42 +532,42 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
532
532
|
}
|
|
533
533
|
const damageTypeFields = damageTypes.map(damageType => {
|
|
534
534
|
const safeTypeName = damageType.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
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}),
|
|
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}),
|
|
540
540
|
`;
|
|
541
541
|
});
|
|
542
|
-
return expandToNode `
|
|
543
|
-
// Auto-generated damage type Active Effect fields
|
|
544
|
-
${joinToNode(damageTypeFields, field => field, { appendNewLineIfNotEmpty: true })}
|
|
542
|
+
return expandToNode `
|
|
543
|
+
// Auto-generated damage type Active Effect fields
|
|
544
|
+
${joinToNode(damageTypeFields, field => field, { appendNewLineIfNotEmpty: true })}
|
|
545
545
|
`;
|
|
546
546
|
}
|
|
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
|
-
};
|
|
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
|
+
};
|
|
571
571
|
`.appendNewLineIfNotEmpty();
|
|
572
572
|
if (!fs.existsSync(dataModelPath)) {
|
|
573
573
|
fs.mkdirSync(dataModelPath, { recursive: true });
|
|
@@ -585,44 +585,44 @@ export function generateDocumentDataModel(entry, document, destination) {
|
|
|
585
585
|
function generatePromptModel(prompt) {
|
|
586
586
|
const variable = AstUtils.getContainerOfType(prompt.$container, isVariableExpression);
|
|
587
587
|
const action = AstUtils.getContainerOfType(prompt.$container, isAction);
|
|
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
|
-
}),
|
|
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
|
+
}),
|
|
592
592
|
`;
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
595
|
export function generateUuidDocumentField(destination) {
|
|
596
596
|
const dataModelPath = path.join(destination, "system", "datamodels");
|
|
597
597
|
const generatedFilePath = path.join(dataModelPath, "UuidDocumentField.mjs");
|
|
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
|
-
}
|
|
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
|
+
}
|
|
626
626
|
`.appendNewLineIfNotEmpty();
|
|
627
627
|
if (!fs.existsSync(dataModelPath)) {
|
|
628
628
|
fs.mkdirSync(dataModelPath, { recursive: true });
|
|
@@ -632,44 +632,44 @@ export function generateUuidDocumentField(destination) {
|
|
|
632
632
|
export function generateUuidDocumentArrayField(destination) {
|
|
633
633
|
const dataModelPath = path.join(destination, "system", "datamodels");
|
|
634
634
|
const generatedFilePath = path.join(dataModelPath, "UuidDocumentArrayField.mjs");
|
|
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
|
-
}
|
|
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
|
+
}
|
|
673
673
|
`.appendNewLineIfNotEmpty();
|
|
674
674
|
if (!fs.existsSync(dataModelPath)) {
|
|
675
675
|
fs.mkdirSync(dataModelPath, { recursive: true });
|