@openfairygui/cli 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +1193 -1214
- package/package.json +4 -4
package/dist/cli.mjs
CHANGED
|
@@ -910,7 +910,7 @@ var ExtensibleProperty = class extends Property {
|
|
|
910
910
|
};
|
|
911
911
|
//#endregion
|
|
912
912
|
//#region ../core/src/constants.ts
|
|
913
|
-
const VERSION = `v0.
|
|
913
|
+
const VERSION = `v0.6.0`;
|
|
914
914
|
/** Binary package file magic number: "FGUI" as uint32. */
|
|
915
915
|
const FGUI_MAGIC = 1179080009;
|
|
916
916
|
/** Null string index in the binary string table. */
|
|
@@ -19119,6 +19119,258 @@ var ReaderContext = class {
|
|
|
19119
19119
|
}
|
|
19120
19120
|
};
|
|
19121
19121
|
//#endregion
|
|
19122
|
+
//#region ../core/src/io/display-object-xml-text.ts
|
|
19123
|
+
function createTextDisplayObject(doc, tagName, name, attrs) {
|
|
19124
|
+
switch (tagName) {
|
|
19125
|
+
case "text": {
|
|
19126
|
+
const isInputText = parseBool(readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.input));
|
|
19127
|
+
const g = isInputText ? doc.createGTextInput(name) : doc.createGTextField(name);
|
|
19128
|
+
const textValue = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.text);
|
|
19129
|
+
if (textValue !== void 0) g.setText(String(textValue));
|
|
19130
|
+
const textFontSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.fontSize);
|
|
19131
|
+
if (textFontSize !== void 0) g.setFontSize(parseInt2(textFontSize));
|
|
19132
|
+
const textFont = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.font);
|
|
19133
|
+
if (textFont) g.setFont(textFont);
|
|
19134
|
+
const textColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.color);
|
|
19135
|
+
if (textColor) g.setColor(textColor);
|
|
19136
|
+
const textAlign = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.align);
|
|
19137
|
+
if (textAlign) g.setAlign({
|
|
19138
|
+
left: 0,
|
|
19139
|
+
center: 1,
|
|
19140
|
+
right: 2
|
|
19141
|
+
}[textAlign] ?? 0);
|
|
19142
|
+
const textVAlign = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.vAlign);
|
|
19143
|
+
if (textVAlign) g.setVAlign({
|
|
19144
|
+
top: 0,
|
|
19145
|
+
middle: 1,
|
|
19146
|
+
bottom: 2
|
|
19147
|
+
}[textVAlign] ?? 0);
|
|
19148
|
+
const textAutoSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.autoSize);
|
|
19149
|
+
if (textAutoSize) g.setAutoSize({
|
|
19150
|
+
none: 0,
|
|
19151
|
+
both: 1,
|
|
19152
|
+
height: 2,
|
|
19153
|
+
shrink: 3,
|
|
19154
|
+
ellipsis: 4
|
|
19155
|
+
}[textAutoSize] ?? 1);
|
|
19156
|
+
const textSingleLine = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.singleLine);
|
|
19157
|
+
if (textSingleLine !== void 0) g.setSingleLine(parseBool(textSingleLine));
|
|
19158
|
+
const textAutoClearText = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.autoClearText);
|
|
19159
|
+
if (textAutoClearText !== void 0) g.setAutoClearText?.(parseBool(textAutoClearText));
|
|
19160
|
+
const textDemoText = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.demoText);
|
|
19161
|
+
if (textDemoText !== void 0) g.setDemoText?.(String(textDemoText));
|
|
19162
|
+
const textVars = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.vars);
|
|
19163
|
+
if (textVars !== void 0) g.setTemplateVarsEnabled?.(parseBool(textVars));
|
|
19164
|
+
const textFaceDilate = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.faceDilate);
|
|
19165
|
+
if (textFaceDilate !== void 0) g.setFaceDilate?.(parseFloat2(textFaceDilate));
|
|
19166
|
+
const textOutlineSoftness = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.outlineSoftness);
|
|
19167
|
+
if (textOutlineSoftness !== void 0) g.setOutlineSoftness?.(parseFloat2(textOutlineSoftness));
|
|
19168
|
+
const textUnderlaySoftness = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.underlaySoftness);
|
|
19169
|
+
if (textUnderlaySoftness !== void 0) g.setUnderlaySoftness?.(parseFloat2(textUnderlaySoftness));
|
|
19170
|
+
const textUbb = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.ubb);
|
|
19171
|
+
if (textUbb !== void 0) g.setUbbEnabled(parseBool(textUbb));
|
|
19172
|
+
const textLeading = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.leading);
|
|
19173
|
+
if (textLeading !== void 0) g.setLeading?.(parseInt2(textLeading));
|
|
19174
|
+
const textLetterSpacing = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.letterSpacing);
|
|
19175
|
+
if (textLetterSpacing !== void 0) g.setLetterSpacing?.(parseInt2(textLetterSpacing));
|
|
19176
|
+
const textUnderline = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.underline);
|
|
19177
|
+
if (textUnderline !== void 0) g.setUnderline?.(parseBool(textUnderline));
|
|
19178
|
+
const textItalic = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.italic);
|
|
19179
|
+
if (textItalic !== void 0) g.setItalic?.(parseBool(textItalic));
|
|
19180
|
+
const textBold = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.bold);
|
|
19181
|
+
if (textBold !== void 0) g.setBold?.(parseBool(textBold));
|
|
19182
|
+
const textStrikethrough = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strikethrough);
|
|
19183
|
+
if (textStrikethrough !== void 0) g.setStrikethrough?.(parseBool(textStrikethrough));
|
|
19184
|
+
const textStrokeColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strokeColor);
|
|
19185
|
+
if (textStrokeColor) {
|
|
19186
|
+
g.setStrokeColor?.(textStrokeColor);
|
|
19187
|
+
const textStrokeSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strokeSize);
|
|
19188
|
+
g.setStrokeSize?.(parseFloat2(textStrokeSize, 1));
|
|
19189
|
+
}
|
|
19190
|
+
const textShadowColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.shadowColor);
|
|
19191
|
+
if (textShadowColor) {
|
|
19192
|
+
g.setShadowColor?.(textShadowColor);
|
|
19193
|
+
const textShadowOffset = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.shadowOffset);
|
|
19194
|
+
const shadowParts = String(textShadowOffset ?? "1,1").split(",");
|
|
19195
|
+
g.setShadowOffset?.({
|
|
19196
|
+
x: parseFloat2(shadowParts[0], 1),
|
|
19197
|
+
y: parseFloat2(shadowParts[1], 1)
|
|
19198
|
+
});
|
|
19199
|
+
}
|
|
19200
|
+
if (isInputText) {
|
|
19201
|
+
const input = g;
|
|
19202
|
+
const prompt = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.prompt);
|
|
19203
|
+
if (prompt !== void 0) input.setPromptText(String(prompt));
|
|
19204
|
+
const inputMaxLength = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.maxLength);
|
|
19205
|
+
if (inputMaxLength !== void 0) input.setMaxLength(parseInt2(inputMaxLength));
|
|
19206
|
+
const inputRestrict = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.restrict);
|
|
19207
|
+
if (inputRestrict !== void 0) input.setRestrict(String(inputRestrict));
|
|
19208
|
+
const inputPassword = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.password);
|
|
19209
|
+
if (inputPassword !== void 0) input.setPassword(parseBool(inputPassword));
|
|
19210
|
+
const inputKeyboardType = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.keyboardType);
|
|
19211
|
+
if (inputKeyboardType !== void 0) input.setKeyboardType?.(parseInt2(inputKeyboardType));
|
|
19212
|
+
}
|
|
19213
|
+
return g;
|
|
19214
|
+
}
|
|
19215
|
+
case "richtext": {
|
|
19216
|
+
const g = doc.createGRichTextField(name);
|
|
19217
|
+
const richText = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.text);
|
|
19218
|
+
if (richText !== void 0) g.setText(String(richText));
|
|
19219
|
+
const richTextFontSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.fontSize);
|
|
19220
|
+
if (richTextFontSize !== void 0) g.setFontSize(parseInt2(richTextFontSize));
|
|
19221
|
+
const richTextFont = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.font);
|
|
19222
|
+
if (richTextFont) g.setFont(richTextFont);
|
|
19223
|
+
const richTextColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.color);
|
|
19224
|
+
if (richTextColor) g.setColor(richTextColor);
|
|
19225
|
+
const richTextAlign = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.align);
|
|
19226
|
+
if (richTextAlign) g.setAlign({
|
|
19227
|
+
left: 0,
|
|
19228
|
+
center: 1,
|
|
19229
|
+
right: 2
|
|
19230
|
+
}[richTextAlign] ?? 0);
|
|
19231
|
+
const richTextVAlign = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.vAlign);
|
|
19232
|
+
if (richTextVAlign) g.setVAlign({
|
|
19233
|
+
top: 0,
|
|
19234
|
+
middle: 1,
|
|
19235
|
+
bottom: 2
|
|
19236
|
+
}[richTextVAlign] ?? 0);
|
|
19237
|
+
const richTextLeading = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.leading);
|
|
19238
|
+
if (richTextLeading !== void 0) g.setLeading?.(parseInt2(richTextLeading));
|
|
19239
|
+
const richTextLetterSpacing = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.letterSpacing);
|
|
19240
|
+
if (richTextLetterSpacing !== void 0) g.setLetterSpacing?.(parseInt2(richTextLetterSpacing));
|
|
19241
|
+
const richTextUbb = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.ubb);
|
|
19242
|
+
if (richTextUbb !== void 0) g.setUbbEnabled?.(parseBool(richTextUbb));
|
|
19243
|
+
const richTextAutoSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.autoSize);
|
|
19244
|
+
if (richTextAutoSize) g.setAutoSize({
|
|
19245
|
+
none: 0,
|
|
19246
|
+
both: 1,
|
|
19247
|
+
height: 2,
|
|
19248
|
+
shrink: 3,
|
|
19249
|
+
ellipsis: 4
|
|
19250
|
+
}[richTextAutoSize] ?? 1);
|
|
19251
|
+
const richTextSingleLine = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.singleLine);
|
|
19252
|
+
if (richTextSingleLine !== void 0) g.setSingleLine?.(parseBool(richTextSingleLine));
|
|
19253
|
+
const richTextAutoClearText = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.autoClearText);
|
|
19254
|
+
if (richTextAutoClearText !== void 0) g.setAutoClearText?.(parseBool(richTextAutoClearText));
|
|
19255
|
+
const richTextOutlineSoftness = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.richText.attrs.outlineSoftness);
|
|
19256
|
+
if (richTextOutlineSoftness !== void 0) g.setOutlineSoftness?.(parseFloat2(richTextOutlineSoftness));
|
|
19257
|
+
const richTextUnderlaySoftness = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.richText.attrs.underlaySoftness);
|
|
19258
|
+
if (richTextUnderlaySoftness !== void 0) g.setUnderlaySoftness?.(parseFloat2(richTextUnderlaySoftness));
|
|
19259
|
+
const richTextUnderline = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.underline);
|
|
19260
|
+
if (richTextUnderline !== void 0) g.setUnderline?.(parseBool(richTextUnderline));
|
|
19261
|
+
const richTextItalic = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.italic);
|
|
19262
|
+
if (richTextItalic !== void 0) g.setItalic?.(parseBool(richTextItalic));
|
|
19263
|
+
const richTextBold = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.bold);
|
|
19264
|
+
if (richTextBold !== void 0) g.setBold?.(parseBool(richTextBold));
|
|
19265
|
+
const richTextStrikethrough = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strikethrough);
|
|
19266
|
+
if (richTextStrikethrough !== void 0) g.setStrikethrough?.(parseBool(richTextStrikethrough));
|
|
19267
|
+
const richTextStrokeColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strokeColor);
|
|
19268
|
+
if (richTextStrokeColor) {
|
|
19269
|
+
g.setStrokeColor?.(richTextStrokeColor);
|
|
19270
|
+
const richTextStrokeSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strokeSize);
|
|
19271
|
+
g.setStrokeSize?.(parseFloat2(richTextStrokeSize, 1));
|
|
19272
|
+
}
|
|
19273
|
+
const richTextShadowColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.shadowColor);
|
|
19274
|
+
if (richTextShadowColor) {
|
|
19275
|
+
g.setShadowColor?.(richTextShadowColor);
|
|
19276
|
+
const richTextShadowOffset = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.shadowOffset);
|
|
19277
|
+
const shadowParts = String(richTextShadowOffset ?? "1,1").split(",");
|
|
19278
|
+
g.setShadowOffset?.({
|
|
19279
|
+
x: parseFloat2(shadowParts[0], 1),
|
|
19280
|
+
y: parseFloat2(shadowParts[1], 1)
|
|
19281
|
+
});
|
|
19282
|
+
}
|
|
19283
|
+
return g;
|
|
19284
|
+
}
|
|
19285
|
+
case "inputtext": {
|
|
19286
|
+
const g = doc.createGTextInput(name);
|
|
19287
|
+
const inputText = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.text);
|
|
19288
|
+
if (inputText !== void 0) g.setText(String(inputText));
|
|
19289
|
+
const inputFontSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.fontSize);
|
|
19290
|
+
if (inputFontSize !== void 0) g.setFontSize(parseInt2(inputFontSize));
|
|
19291
|
+
const inputFont = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.font);
|
|
19292
|
+
if (inputFont) g.setFont(inputFont);
|
|
19293
|
+
const inputColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.color);
|
|
19294
|
+
if (inputColor) g.setColor(inputColor);
|
|
19295
|
+
const inputAlign = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.align);
|
|
19296
|
+
if (inputAlign) g.setAlign({
|
|
19297
|
+
left: 0,
|
|
19298
|
+
center: 1,
|
|
19299
|
+
right: 2
|
|
19300
|
+
}[inputAlign] ?? 0);
|
|
19301
|
+
const inputVAlign = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.vAlign);
|
|
19302
|
+
if (inputVAlign) g.setVAlign({
|
|
19303
|
+
top: 0,
|
|
19304
|
+
middle: 1,
|
|
19305
|
+
bottom: 2
|
|
19306
|
+
}[inputVAlign] ?? 0);
|
|
19307
|
+
const inputLeading = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.leading);
|
|
19308
|
+
if (inputLeading !== void 0) g.setLeading?.(parseInt2(inputLeading));
|
|
19309
|
+
const inputLetterSpacing = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.letterSpacing);
|
|
19310
|
+
if (inputLetterSpacing !== void 0) g.setLetterSpacing?.(parseInt2(inputLetterSpacing));
|
|
19311
|
+
const inputAutoSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.autoSize);
|
|
19312
|
+
if (inputAutoSize) g.setAutoSize({
|
|
19313
|
+
none: 0,
|
|
19314
|
+
both: 1,
|
|
19315
|
+
height: 2,
|
|
19316
|
+
shrink: 3,
|
|
19317
|
+
ellipsis: 4
|
|
19318
|
+
}[inputAutoSize] ?? 1);
|
|
19319
|
+
const inputSingleLine = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.singleLine);
|
|
19320
|
+
if (inputSingleLine !== void 0) g.setSingleLine?.(parseBool(inputSingleLine));
|
|
19321
|
+
const inputAutoClearText = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.autoClearText);
|
|
19322
|
+
if (inputAutoClearText !== void 0) g.setAutoClearText?.(parseBool(inputAutoClearText));
|
|
19323
|
+
const inputDemoText = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.demoText);
|
|
19324
|
+
if (inputDemoText !== void 0) g.setDemoText?.(String(inputDemoText));
|
|
19325
|
+
const inputVars = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.vars);
|
|
19326
|
+
if (inputVars !== void 0) g.setTemplateVarsEnabled?.(parseBool(inputVars));
|
|
19327
|
+
const inputFaceDilate = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.faceDilate);
|
|
19328
|
+
if (inputFaceDilate !== void 0) g.setFaceDilate?.(parseFloat2(inputFaceDilate));
|
|
19329
|
+
const inputOutlineSoftness = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.outlineSoftness);
|
|
19330
|
+
if (inputOutlineSoftness !== void 0) g.setOutlineSoftness?.(parseFloat2(inputOutlineSoftness));
|
|
19331
|
+
const inputUnderlaySoftness = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.underlaySoftness);
|
|
19332
|
+
if (inputUnderlaySoftness !== void 0) g.setUnderlaySoftness?.(parseFloat2(inputUnderlaySoftness));
|
|
19333
|
+
const inputUbb = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.ubb);
|
|
19334
|
+
if (inputUbb !== void 0) g.setUbbEnabled?.(parseBool(inputUbb));
|
|
19335
|
+
const inputUnderline = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.underline);
|
|
19336
|
+
if (inputUnderline !== void 0) g.setUnderline?.(parseBool(inputUnderline));
|
|
19337
|
+
const inputItalic = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.italic);
|
|
19338
|
+
if (inputItalic !== void 0) g.setItalic?.(parseBool(inputItalic));
|
|
19339
|
+
const inputBold = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.bold);
|
|
19340
|
+
if (inputBold !== void 0) g.setBold?.(parseBool(inputBold));
|
|
19341
|
+
const inputStrikethrough = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strikethrough);
|
|
19342
|
+
if (inputStrikethrough !== void 0) g.setStrikethrough?.(parseBool(inputStrikethrough));
|
|
19343
|
+
const inputStrokeColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strokeColor);
|
|
19344
|
+
if (inputStrokeColor) {
|
|
19345
|
+
g.setStrokeColor?.(inputStrokeColor);
|
|
19346
|
+
const inputStrokeSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strokeSize);
|
|
19347
|
+
g.setStrokeSize?.(parseFloat2(inputStrokeSize, 1));
|
|
19348
|
+
}
|
|
19349
|
+
const inputShadowColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.shadowColor);
|
|
19350
|
+
if (inputShadowColor) {
|
|
19351
|
+
g.setShadowColor?.(inputShadowColor);
|
|
19352
|
+
const inputShadowOffset = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.shadowOffset);
|
|
19353
|
+
const shadowParts = String(inputShadowOffset ?? "1,1").split(",");
|
|
19354
|
+
g.setShadowOffset?.({
|
|
19355
|
+
x: parseFloat2(shadowParts[0], 1),
|
|
19356
|
+
y: parseFloat2(shadowParts[1], 1)
|
|
19357
|
+
});
|
|
19358
|
+
}
|
|
19359
|
+
const prompt = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.prompt);
|
|
19360
|
+
if (prompt !== void 0) g.setPromptText(prompt);
|
|
19361
|
+
const inputMaxLength = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.maxLength);
|
|
19362
|
+
if (inputMaxLength !== void 0) g.setMaxLength(parseInt2(inputMaxLength));
|
|
19363
|
+
const inputRestrict = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.restrict);
|
|
19364
|
+
if (inputRestrict !== void 0) g.setRestrict(inputRestrict);
|
|
19365
|
+
const inputPassword = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.password);
|
|
19366
|
+
if (inputPassword !== void 0) g.setPassword(parseBool(inputPassword));
|
|
19367
|
+
const inputKeyboardType = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.keyboardType);
|
|
19368
|
+
if (inputKeyboardType !== void 0) g.setKeyboardType?.(parseInt2(inputKeyboardType));
|
|
19369
|
+
return g;
|
|
19370
|
+
}
|
|
19371
|
+
}
|
|
19372
|
+
}
|
|
19373
|
+
//#endregion
|
|
19122
19374
|
//#region ../core/src/io/tree-item-hierarchy.ts
|
|
19123
19375
|
/**
|
|
19124
19376
|
* Resolves a tree item's folder state using the editor's flat hierarchy rules.
|
|
@@ -19134,7 +19386,218 @@ function resolveTreeItemIsFolder(items, index) {
|
|
|
19134
19386
|
return next !== void 0 && (next.level ?? 0) > (item.level ?? 0);
|
|
19135
19387
|
}
|
|
19136
19388
|
//#endregion
|
|
19137
|
-
//#region ../core/src/io/display-object-xml-
|
|
19389
|
+
//#region ../core/src/io/display-object-xml-shared.ts
|
|
19390
|
+
function getXmlNode$2(value) {
|
|
19391
|
+
const node = Array.isArray(value) ? value[0] : value;
|
|
19392
|
+
if (!node || typeof node !== "object" || Array.isArray(node)) return null;
|
|
19393
|
+
return node;
|
|
19394
|
+
}
|
|
19395
|
+
function getProtocolChildName$2(protocol, childName) {
|
|
19396
|
+
return protocol.children?.[childName] ? childName : null;
|
|
19397
|
+
}
|
|
19398
|
+
function parsePropertyOverrides(source, protocol) {
|
|
19399
|
+
const childName = getProtocolChildName$2(protocol, "property");
|
|
19400
|
+
if (!childName) return [];
|
|
19401
|
+
return ensureArray(source[childName]).map((raw, index) => {
|
|
19402
|
+
const property = getXmlNode$2(raw);
|
|
19403
|
+
const specs = PROJECT_XML_PROTOCOL.propertyOverride.attrs;
|
|
19404
|
+
const target = property ? readXmlAttr(property, specs.target) : void 0;
|
|
19405
|
+
const rawPropertyId = property ? readXmlAttr(property, specs.propertyId) : void 0;
|
|
19406
|
+
const propertyId = typeof rawPropertyId === "number" ? rawPropertyId : typeof rawPropertyId === "string" && /^\d+$/.test(rawPropertyId) ? Number(rawPropertyId) : NaN;
|
|
19407
|
+
const value = property ? readXmlAttr(property, specs.value) : void 0;
|
|
19408
|
+
if (!target || !Number.isSafeInteger(propertyId) || propertyId < 0 || value === void 0) throw new Error(`Invalid property override at ${childName}[${index}].`);
|
|
19409
|
+
return {
|
|
19410
|
+
target,
|
|
19411
|
+
propertyId,
|
|
19412
|
+
value: String(value)
|
|
19413
|
+
};
|
|
19414
|
+
});
|
|
19415
|
+
}
|
|
19416
|
+
//#endregion
|
|
19417
|
+
//#region ../core/src/io/display-object-xml-list.ts
|
|
19418
|
+
function inferTreeItemFolderFlags(items) {
|
|
19419
|
+
return items.map((item, index) => {
|
|
19420
|
+
if (item.isFolder !== null) return item;
|
|
19421
|
+
return {
|
|
19422
|
+
...item,
|
|
19423
|
+
isFolder: resolveTreeItemIsFolder(items, index)
|
|
19424
|
+
};
|
|
19425
|
+
});
|
|
19426
|
+
}
|
|
19427
|
+
function parseListItemXmlNode(item) {
|
|
19428
|
+
const specs = PROJECT_XML_PROTOCOL.listItem.attrs;
|
|
19429
|
+
const isFolder = readXmlAttr(item, specs.isFolder);
|
|
19430
|
+
const controllers = readXmlAttr(item, specs.controllers);
|
|
19431
|
+
const propertyOverrides = parsePropertyOverrides(item, PROJECT_XML_PROTOCOL.listItem);
|
|
19432
|
+
return {
|
|
19433
|
+
title: readXmlAttr(item, specs.title) ?? null,
|
|
19434
|
+
icon: readXmlAttr(item, specs.icon) ?? null,
|
|
19435
|
+
url: readXmlAttr(item, specs.url) ?? null,
|
|
19436
|
+
name: readXmlAttr(item, specs.name) ?? null,
|
|
19437
|
+
selectedTitle: readXmlAttr(item, specs.selectedTitle) ?? null,
|
|
19438
|
+
selectedIcon: readXmlAttr(item, specs.selectedIcon) ?? null,
|
|
19439
|
+
level: parseInt2(readXmlAttr(item, specs.level)),
|
|
19440
|
+
isFolder: isFolder !== void 0 ? parseBool(isFolder) : null,
|
|
19441
|
+
...controllers !== void 0 ? { controllers } : {},
|
|
19442
|
+
...propertyOverrides.length > 0 ? { propertyOverrides } : {}
|
|
19443
|
+
};
|
|
19444
|
+
}
|
|
19445
|
+
function createListDisplayObject(doc, name, attrs) {
|
|
19446
|
+
const treeView = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.treeView);
|
|
19447
|
+
const isTree = treeView !== void 0 && parseBool(treeView);
|
|
19448
|
+
let g;
|
|
19449
|
+
if (isTree) {
|
|
19450
|
+
g = doc.createGTree(name).setTreeView(true);
|
|
19451
|
+
const indent = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.indent);
|
|
19452
|
+
if (indent !== void 0) g.setIndent(parseInt2(indent));
|
|
19453
|
+
const clickToExpand = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.clickToExpand);
|
|
19454
|
+
if (clickToExpand !== void 0) g.setClickToExpand(parseInt2(clickToExpand));
|
|
19455
|
+
} else g = doc.createGList(name);
|
|
19456
|
+
const src = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.src);
|
|
19457
|
+
g.setSrc(src || "");
|
|
19458
|
+
const defaultItem = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.defaultItem);
|
|
19459
|
+
if (defaultItem) g.setDefaultItem(defaultItem);
|
|
19460
|
+
const scrollBarRes = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scrollBarRes);
|
|
19461
|
+
if (scrollBarRes) {
|
|
19462
|
+
const parts = String(scrollBarRes).split(",");
|
|
19463
|
+
g.setVtScrollBarRes?.(parts[0] ?? "");
|
|
19464
|
+
g.setHzScrollBarRes?.(parts[1] ?? "");
|
|
19465
|
+
}
|
|
19466
|
+
const ptrRes = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.ptrRes);
|
|
19467
|
+
if (ptrRes) {
|
|
19468
|
+
const parts = String(ptrRes).split(",");
|
|
19469
|
+
g.setHeaderRes?.(parts[0] ?? "");
|
|
19470
|
+
g.setFooterRes?.(parts[1] ?? "");
|
|
19471
|
+
}
|
|
19472
|
+
const controllerOverrides = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.controllerOverrides);
|
|
19473
|
+
if (controllerOverrides) g.setControllerOverrides?.(controllerOverrides);
|
|
19474
|
+
const pageController = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.pageController);
|
|
19475
|
+
if (pageController) g.setPageController?.(pageController);
|
|
19476
|
+
const layout = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.layout);
|
|
19477
|
+
if (layout) g.setLayout({
|
|
19478
|
+
singleColumn: 0,
|
|
19479
|
+
singleRow: 1,
|
|
19480
|
+
flowHorizontal: 2,
|
|
19481
|
+
flowVertical: 3,
|
|
19482
|
+
pagination: 4,
|
|
19483
|
+
single_column: 0,
|
|
19484
|
+
single_row: 1,
|
|
19485
|
+
flow_hz: 2,
|
|
19486
|
+
flow_vt: 3,
|
|
19487
|
+
column: 0,
|
|
19488
|
+
row: 1
|
|
19489
|
+
}[layout] ?? 0);
|
|
19490
|
+
const align = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.align);
|
|
19491
|
+
if (align) g.setAlign({
|
|
19492
|
+
left: 0,
|
|
19493
|
+
center: 1,
|
|
19494
|
+
right: 2
|
|
19495
|
+
}[align] ?? 0);
|
|
19496
|
+
const vAlign = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.vAlign);
|
|
19497
|
+
if (vAlign) g.setVAlign({
|
|
19498
|
+
top: 0,
|
|
19499
|
+
middle: 1,
|
|
19500
|
+
bottom: 2
|
|
19501
|
+
}[vAlign] ?? 0);
|
|
19502
|
+
const lineGap = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.lineGap);
|
|
19503
|
+
if (lineGap !== void 0) g.setLineGap(parseInt2(lineGap));
|
|
19504
|
+
const columnGap = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.columnGap);
|
|
19505
|
+
if (columnGap !== void 0) g.setColumnGap(parseInt2(columnGap));
|
|
19506
|
+
const lineItemCount = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.lineItemCount);
|
|
19507
|
+
const lineItemCount2 = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.lineItemCount2);
|
|
19508
|
+
if (layout) {
|
|
19509
|
+
const resolvedLayout = g.getLayout?.() ?? 0;
|
|
19510
|
+
if (resolvedLayout === 2 || resolvedLayout === 4) {
|
|
19511
|
+
if (lineItemCount !== void 0) g.setColumnCount?.(parseInt2(lineItemCount));
|
|
19512
|
+
} else if (resolvedLayout === 3 && lineItemCount !== void 0) g.setLineCount?.(parseInt2(lineItemCount));
|
|
19513
|
+
if (resolvedLayout === 4 && lineItemCount2 !== void 0) g.setLineCount?.(parseInt2(lineItemCount2));
|
|
19514
|
+
}
|
|
19515
|
+
const autoResizeItem = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.autoResizeItem);
|
|
19516
|
+
g.setAutoResizeItem?.(autoResizeItem === void 0 ? getDefaultListAutoResizeItem(g.getLayout?.() ?? 0) : parseBool(autoResizeItem));
|
|
19517
|
+
const childrenRenderOrder = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.childrenRenderOrder);
|
|
19518
|
+
if (childrenRenderOrder) g.setChildrenRenderOrder?.({
|
|
19519
|
+
ascent: 0,
|
|
19520
|
+
descent: 1,
|
|
19521
|
+
arch: 2
|
|
19522
|
+
}[childrenRenderOrder] ?? 0);
|
|
19523
|
+
const apexIndex = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.apexIndex);
|
|
19524
|
+
if (apexIndex !== void 0) g.setApexIndex?.(parseInt2(apexIndex));
|
|
19525
|
+
const selectionMode = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.selectionMode);
|
|
19526
|
+
if (selectionMode) g.setSelectionMode({
|
|
19527
|
+
single: 0,
|
|
19528
|
+
multiple: 1,
|
|
19529
|
+
multipleSingleClick: 2,
|
|
19530
|
+
none: 3
|
|
19531
|
+
}[selectionMode] ?? 0);
|
|
19532
|
+
const selectionController = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.selectionController);
|
|
19533
|
+
if (selectionController !== void 0) g.setSelectionController?.(selectionController);
|
|
19534
|
+
const overflow = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.overflow);
|
|
19535
|
+
const scroll = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scroll);
|
|
19536
|
+
const scrollBar = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scrollBar);
|
|
19537
|
+
const scrollBarFlags = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scrollBarFlags);
|
|
19538
|
+
const margin = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.margin);
|
|
19539
|
+
if (overflow || scroll || scrollBar || scrollBarFlags !== void 0 || margin) {
|
|
19540
|
+
if (overflow) g.setOverflow({
|
|
19541
|
+
visible: 0,
|
|
19542
|
+
hidden: 1,
|
|
19543
|
+
scroll: 2
|
|
19544
|
+
}[overflow] ?? 0);
|
|
19545
|
+
if (scroll) g.setScrollType({
|
|
19546
|
+
horizontal: 0,
|
|
19547
|
+
vertical: 1,
|
|
19548
|
+
both: 2
|
|
19549
|
+
}[scroll] ?? 1);
|
|
19550
|
+
if (scrollBar) g.setScrollBarDisplay({
|
|
19551
|
+
default: 0,
|
|
19552
|
+
visible: 1,
|
|
19553
|
+
auto: 2,
|
|
19554
|
+
hidden: 3
|
|
19555
|
+
}[scrollBar] ?? 0);
|
|
19556
|
+
if (scrollBarFlags !== void 0) g.setScrollBarFlags(parseInt2(scrollBarFlags));
|
|
19557
|
+
if (margin) {
|
|
19558
|
+
const parts = margin.split(",").map(Number);
|
|
19559
|
+
g.setMargin({
|
|
19560
|
+
top: parts[0] ?? 0,
|
|
19561
|
+
bottom: parts[1] ?? 0,
|
|
19562
|
+
left: parts[2] ?? 0,
|
|
19563
|
+
right: parts[3] ?? 0
|
|
19564
|
+
});
|
|
19565
|
+
}
|
|
19566
|
+
}
|
|
19567
|
+
const scrollBarMargin = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scrollBarMargin);
|
|
19568
|
+
if (scrollBarMargin) {
|
|
19569
|
+
const parts = scrollBarMargin.split(",").map(Number);
|
|
19570
|
+
g.setScrollBarMargin?.({
|
|
19571
|
+
top: parts[0] ?? 0,
|
|
19572
|
+
bottom: parts[1] ?? 0,
|
|
19573
|
+
left: parts[2] ?? 0,
|
|
19574
|
+
right: parts[3] ?? 0
|
|
19575
|
+
});
|
|
19576
|
+
}
|
|
19577
|
+
const clipSoftness = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.clipSoftness);
|
|
19578
|
+
if (clipSoftness) {
|
|
19579
|
+
const csParts = clipSoftness.split(",").map(Number);
|
|
19580
|
+
g.setClipSoftness({
|
|
19581
|
+
x: csParts[0] ?? 0,
|
|
19582
|
+
y: csParts[1] ?? 0
|
|
19583
|
+
});
|
|
19584
|
+
}
|
|
19585
|
+
const scrollItemToViewOnClick = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scrollItemToViewOnClick);
|
|
19586
|
+
if (scrollItemToViewOnClick !== void 0) g.setScrollItemToViewOnClick?.(parseBool(scrollItemToViewOnClick));
|
|
19587
|
+
const foldInvisibleItems = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.foldInvisibleItems);
|
|
19588
|
+
if (foldInvisibleItems !== void 0) g.setFoldInvisibleItems?.(parseBool(foldInvisibleItems));
|
|
19589
|
+
const autoClearItems = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.autoClearItems);
|
|
19590
|
+
if (autoClearItems !== void 0) g.setAutoClearItems?.(parseBool(autoClearItems));
|
|
19591
|
+
const listItemChildName = getProtocolChildName$2(PROJECT_XML_PROTOCOL.list, "item");
|
|
19592
|
+
const items = listItemChildName ? ensureArray(attrs[listItemChildName]) : [];
|
|
19593
|
+
if (items.length > 0) {
|
|
19594
|
+
const listItems = items.map((itemDef) => getXmlNode$2(itemDef)).filter((itemDef) => itemDef !== null).map((itemDef) => parseListItemXmlNode(itemDef));
|
|
19595
|
+
g.setListItems(isTree ? inferTreeItemFolderFlags(listItems) : listItems);
|
|
19596
|
+
}
|
|
19597
|
+
return g;
|
|
19598
|
+
}
|
|
19599
|
+
//#endregion
|
|
19600
|
+
//#region ../core/src/io/display-object-xml-behaviors.ts
|
|
19138
19601
|
function _parseEaseType$1(ease) {
|
|
19139
19602
|
const map = {
|
|
19140
19603
|
Linear: 0,
|
|
@@ -19173,21 +19636,76 @@ function _parseEaseType$1(ease) {
|
|
|
19173
19636
|
const normalized = ease.replace(/[.\s_-]/g, "");
|
|
19174
19637
|
return map[ease] ?? map[normalized] ?? 5;
|
|
19175
19638
|
}
|
|
19176
|
-
const
|
|
19177
|
-
|
|
19178
|
-
|
|
19179
|
-
|
|
19180
|
-
|
|
19181
|
-
|
|
19182
|
-
|
|
19183
|
-
|
|
19184
|
-
|
|
19185
|
-
|
|
19186
|
-
|
|
19187
|
-
component: "GComponent",
|
|
19188
|
-
list: "GList",
|
|
19189
|
-
tree: "GTree"
|
|
19639
|
+
const GEAR_TAG_MAP = {
|
|
19640
|
+
gearDisplay: GearType.Display,
|
|
19641
|
+
gearXY: GearType.XY,
|
|
19642
|
+
gearSize: GearType.Size,
|
|
19643
|
+
gearLook: GearType.Look,
|
|
19644
|
+
gearColor: GearType.Color,
|
|
19645
|
+
gearAni: GearType.Animation,
|
|
19646
|
+
gearText: GearType.Text,
|
|
19647
|
+
gearIcon: GearType.Icon,
|
|
19648
|
+
gearDisplay2: GearType.Display2,
|
|
19649
|
+
gearFontSize: GearType.FontSize
|
|
19190
19650
|
};
|
|
19651
|
+
function getProtocolGearChildNames(protocol) {
|
|
19652
|
+
return Object.keys(protocol.children ?? {}).filter((name) => name in GEAR_TAG_MAP);
|
|
19653
|
+
}
|
|
19654
|
+
function parseGear(doc, obj, gearTag, attrs, localControllers) {
|
|
19655
|
+
const gearType = GEAR_TAG_MAP[gearTag];
|
|
19656
|
+
if (gearType === void 0) return;
|
|
19657
|
+
const gear = doc.createGear();
|
|
19658
|
+
gear.setGearType(gearType);
|
|
19659
|
+
const tween = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.tween);
|
|
19660
|
+
gear.setTween(parseBool(tween));
|
|
19661
|
+
const positionsInPercent = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.positionsInPercent);
|
|
19662
|
+
if (positionsInPercent !== void 0) gear.setPositionsInPercent(parseBool(positionsInPercent));
|
|
19663
|
+
const ctrlName = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.controller) || "";
|
|
19664
|
+
const controller = localControllers.get(ctrlName) || null;
|
|
19665
|
+
if (controller) gear.setController(controller);
|
|
19666
|
+
const pages = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.pages);
|
|
19667
|
+
if (pages) gear.setPages(pages);
|
|
19668
|
+
const values = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.values);
|
|
19669
|
+
if (gearType === GearType.Text || gearType === GearType.Icon || values) gear.setValues(values ?? "");
|
|
19670
|
+
const defaultValue = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.default);
|
|
19671
|
+
if (defaultValue !== void 0) gear.setDefaultValue(defaultValue);
|
|
19672
|
+
const condition = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.condition);
|
|
19673
|
+
if (condition !== void 0) gear.setCondition(String(condition));
|
|
19674
|
+
const ease = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.ease);
|
|
19675
|
+
if (ease) gear.setEaseType(_parseEaseType$1(ease));
|
|
19676
|
+
const duration = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.duration);
|
|
19677
|
+
if (duration !== void 0) gear.setTweenDuration(parseFloat2(duration));
|
|
19678
|
+
const delay = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.delay);
|
|
19679
|
+
if (delay !== void 0) gear.setTweenDelay(parseFloat2(delay));
|
|
19680
|
+
obj.addGear(gear);
|
|
19681
|
+
}
|
|
19682
|
+
function readDisplayBehaviors(doc, obj, attrs, objectProtocol, localControllers) {
|
|
19683
|
+
for (const gearTag of getProtocolGearChildNames(objectProtocol)) {
|
|
19684
|
+
const gearDefs = ensureArray(attrs[gearTag]);
|
|
19685
|
+
for (const gearDef of gearDefs) {
|
|
19686
|
+
const parsedGear = getXmlNode$2(gearDef);
|
|
19687
|
+
if (!parsedGear) continue;
|
|
19688
|
+
parseGear(doc, obj, gearTag, parsedGear, localControllers);
|
|
19689
|
+
}
|
|
19690
|
+
}
|
|
19691
|
+
const relationChildName = getProtocolChildName$2(objectProtocol, "relation");
|
|
19692
|
+
const relations = relationChildName ? ensureArray(attrs[relationChildName]) : [];
|
|
19693
|
+
for (const relDef of relations) {
|
|
19694
|
+
const parsedRelation = getXmlNode$2(relDef);
|
|
19695
|
+
if (!parsedRelation) continue;
|
|
19696
|
+
const sidePairs = parseSidePair(readXmlAttr(parsedRelation, PROJECT_XML_PROTOCOL.relation.attrs.sidePair) || "");
|
|
19697
|
+
for (const sp of sidePairs) {
|
|
19698
|
+
const rel = {
|
|
19699
|
+
target: readXmlAttr(parsedRelation, PROJECT_XML_PROTOCOL.relation.attrs.target) || "",
|
|
19700
|
+
type: sp.type,
|
|
19701
|
+
usePercent: sp.usePercent
|
|
19702
|
+
};
|
|
19703
|
+
obj.addRelation(rel);
|
|
19704
|
+
}
|
|
19705
|
+
}
|
|
19706
|
+
}
|
|
19707
|
+
//#endregion
|
|
19708
|
+
//#region ../core/src/io/display-object-xml-instance.ts
|
|
19191
19709
|
const EXTENSION_PROTOCOL_MAP$2 = {
|
|
19192
19710
|
Button: PROJECT_XML_PROTOCOL.buttonExtension,
|
|
19193
19711
|
Label: PROJECT_XML_PROTOCOL.labelExtension,
|
|
@@ -19196,6 +19714,94 @@ const EXTENSION_PROTOCOL_MAP$2 = {
|
|
|
19196
19714
|
Slider: PROJECT_XML_PROTOCOL.sliderExtension,
|
|
19197
19715
|
ScrollBar: PROJECT_XML_PROTOCOL.scrollBarExtension
|
|
19198
19716
|
};
|
|
19717
|
+
function getProtocolExtensionChildNames(protocol) {
|
|
19718
|
+
return Object.keys(protocol.children ?? {}).filter((name) => name in EXTENSION_PROTOCOL_MAP$2);
|
|
19719
|
+
}
|
|
19720
|
+
function parseComboBoxItemXmlNode(item) {
|
|
19721
|
+
const specs = PROJECT_XML_PROTOCOL.comboBoxItem.attrs;
|
|
19722
|
+
return {
|
|
19723
|
+
title: readXmlAttr(item, specs.title) ?? null,
|
|
19724
|
+
value: readXmlAttr(item, specs.value) ?? null,
|
|
19725
|
+
icon: readXmlAttr(item, specs.icon) ?? null
|
|
19726
|
+
};
|
|
19727
|
+
}
|
|
19728
|
+
function readComponentInstanceOverlays(obj, attrs) {
|
|
19729
|
+
if (obj.propertyType === "GComponent") obj.setPropertyOverrides(parsePropertyOverrides(attrs, PROJECT_XML_PROTOCOL.componentInstance));
|
|
19730
|
+
for (const extTypeName of getProtocolExtensionChildNames(PROJECT_XML_PROTOCOL.componentInstance)) {
|
|
19731
|
+
const extElement = attrs[extTypeName];
|
|
19732
|
+
if (extElement) {
|
|
19733
|
+
const extAttrs = getXmlNode$2(extElement);
|
|
19734
|
+
if (!extAttrs || obj.propertyType !== "GComponent") continue;
|
|
19735
|
+
const componentObj = obj;
|
|
19736
|
+
const extSpecs = EXTENSION_PROTOCOL_MAP$2[extTypeName].attrs;
|
|
19737
|
+
componentObj.setInstanceExtType?.(extTypeName);
|
|
19738
|
+
const title = extSpecs.title ? readXmlAttr(extAttrs, extSpecs.title) : void 0;
|
|
19739
|
+
if (title !== void 0) componentObj.setInstanceTitle?.(title);
|
|
19740
|
+
const selectedTitle = extSpecs.selectedTitle ? readXmlAttr(extAttrs, extSpecs.selectedTitle) : void 0;
|
|
19741
|
+
if (selectedTitle !== void 0) componentObj.setInstanceSelectedTitle?.(selectedTitle);
|
|
19742
|
+
const icon = extSpecs.icon ? readXmlAttr(extAttrs, extSpecs.icon) : void 0;
|
|
19743
|
+
if (icon !== void 0) componentObj.setInstanceIcon?.(icon);
|
|
19744
|
+
const selectedIcon = extSpecs.selectedIcon ? readXmlAttr(extAttrs, extSpecs.selectedIcon) : void 0;
|
|
19745
|
+
if (selectedIcon !== void 0) componentObj.setInstanceSelectedIcon?.(selectedIcon);
|
|
19746
|
+
const titleColor = extSpecs.titleColor ? readXmlAttr(extAttrs, extSpecs.titleColor) : void 0;
|
|
19747
|
+
if (titleColor !== void 0) componentObj.setInstanceTitleColor?.(titleColor);
|
|
19748
|
+
const titleFontSize = extSpecs.titleFontSize ? readXmlAttr(extAttrs, extSpecs.titleFontSize) : void 0;
|
|
19749
|
+
if (titleFontSize !== void 0) componentObj.setInstanceTitleFontSize?.(parseInt2(titleFontSize));
|
|
19750
|
+
const controller = extSpecs.controller ? readXmlAttr(extAttrs, extSpecs.controller) : void 0;
|
|
19751
|
+
if (controller !== void 0) componentObj.setInstanceController?.(controller);
|
|
19752
|
+
const page = extSpecs.page ? readXmlAttr(extAttrs, extSpecs.page) : void 0;
|
|
19753
|
+
if (page !== void 0) componentObj.setInstancePage?.(page);
|
|
19754
|
+
const checked = extSpecs.checked ? readXmlAttr(extAttrs, extSpecs.checked) : void 0;
|
|
19755
|
+
if (checked !== void 0) componentObj.setInstanceChecked?.(parseBool(checked));
|
|
19756
|
+
const sound = extSpecs.sound ? readXmlAttr(extAttrs, extSpecs.sound) : void 0;
|
|
19757
|
+
if (sound !== void 0) componentObj.setInstanceSound?.(sound);
|
|
19758
|
+
const soundVolumeScale = extSpecs.soundVolumeScale ? readXmlAttr(extAttrs, extSpecs.soundVolumeScale) : void 0;
|
|
19759
|
+
if (soundVolumeScale !== void 0) componentObj.setInstanceSoundVolumeScale?.(parseFloat2(soundVolumeScale, 100) / 100);
|
|
19760
|
+
const popupDirection = extSpecs.popupDirection ? readXmlAttr(extAttrs, extSpecs.popupDirection) : void 0;
|
|
19761
|
+
if (popupDirection !== void 0) componentObj.setInstancePopupDirection?.({
|
|
19762
|
+
auto: 0,
|
|
19763
|
+
up: 1,
|
|
19764
|
+
down: 2
|
|
19765
|
+
}[popupDirection] ?? 0);
|
|
19766
|
+
const prompt = extSpecs.prompt ? readXmlAttr(extAttrs, extSpecs.prompt) : void 0;
|
|
19767
|
+
if (prompt !== void 0) componentObj.setInstancePromptText?.(prompt);
|
|
19768
|
+
const selectionController = extSpecs.selectionController ? readXmlAttr(extAttrs, extSpecs.selectionController) : void 0;
|
|
19769
|
+
if (selectionController !== void 0) componentObj.setInstanceSelectionController?.(selectionController);
|
|
19770
|
+
const visibleItemCount = extSpecs.visibleItemCount ? readXmlAttr(extAttrs, extSpecs.visibleItemCount) : void 0;
|
|
19771
|
+
if (visibleItemCount !== void 0) componentObj.setInstanceVisibleItemCount?.(parseInt2(visibleItemCount));
|
|
19772
|
+
const autoClearItems = extSpecs.autoClearItems ? readXmlAttr(extAttrs, extSpecs.autoClearItems) : void 0;
|
|
19773
|
+
if (autoClearItems !== void 0) componentObj.setInstanceAutoClearItems?.(parseBool(autoClearItems));
|
|
19774
|
+
const value = extSpecs.value ? readXmlAttr(extAttrs, extSpecs.value) : void 0;
|
|
19775
|
+
if (value !== void 0) componentObj.setInstanceValue?.(parseInt2(value));
|
|
19776
|
+
const max = extSpecs.max ? readXmlAttr(extAttrs, extSpecs.max) : void 0;
|
|
19777
|
+
if (max !== void 0) componentObj.setInstanceMax?.(parseInt2(max, 100));
|
|
19778
|
+
const min = extSpecs.min ? readXmlAttr(extAttrs, extSpecs.min) : void 0;
|
|
19779
|
+
if (min !== void 0) componentObj.setInstanceMin?.(parseInt2(min));
|
|
19780
|
+
const comboBoxItemChildName = getProtocolChildName$2(PROJECT_XML_PROTOCOL.comboBoxExtension, "item");
|
|
19781
|
+
if (extTypeName === "ComboBox" && comboBoxItemChildName && extAttrs[comboBoxItemChildName]) {
|
|
19782
|
+
const comboItems = ensureArray(extAttrs[comboBoxItemChildName]);
|
|
19783
|
+
componentObj.setInstanceComboItems?.(comboItems.map((itemDef) => getXmlNode$2(itemDef)).filter((itemDef) => itemDef !== null).map((itemDef) => parseComboBoxItemXmlNode(itemDef)));
|
|
19784
|
+
}
|
|
19785
|
+
}
|
|
19786
|
+
}
|
|
19787
|
+
}
|
|
19788
|
+
//#endregion
|
|
19789
|
+
//#region ../core/src/io/display-object-xml-reader.ts
|
|
19790
|
+
const DISPLAY_TAG_MAP = {
|
|
19791
|
+
image: "GImage",
|
|
19792
|
+
text: "GTextField",
|
|
19793
|
+
richtext: "GRichTextField",
|
|
19794
|
+
inputtext: "GTextInput",
|
|
19795
|
+
graph: "GGraph",
|
|
19796
|
+
group: "GGroup",
|
|
19797
|
+
loader: "GLoader",
|
|
19798
|
+
loader3d: "GLoader3D",
|
|
19799
|
+
movieclip: "GMovieClip",
|
|
19800
|
+
jta: "GMovieClip",
|
|
19801
|
+
component: "GComponent",
|
|
19802
|
+
list: "GList",
|
|
19803
|
+
tree: "GTree"
|
|
19804
|
+
};
|
|
19199
19805
|
const DISPLAY_OBJECT_PROTOCOL_MAP = {
|
|
19200
19806
|
image: PROJECT_XML_PROTOCOL.image,
|
|
19201
19807
|
text: PROJECT_XML_PROTOCOL.text,
|
|
@@ -19214,50 +19820,6 @@ const DISPLAY_OBJECT_PROTOCOL_MAP = {
|
|
|
19214
19820
|
const DISPLAY_LIST_CONTAINER$1 = PROJECT_XML_PROTOCOL.componentRoot.containers?.displayList;
|
|
19215
19821
|
if (!DISPLAY_LIST_CONTAINER$1) throw new Error("PROJECT_XML_PROTOCOL.componentRoot must define containers.displayList");
|
|
19216
19822
|
const DISPLAY_LIST_ALLOWED_VARIANTS$1 = new Set(Object.keys(DISPLAY_LIST_CONTAINER$1.items));
|
|
19217
|
-
const GEAR_TAG_MAP = {
|
|
19218
|
-
gearDisplay: GearType.Display,
|
|
19219
|
-
gearXY: GearType.XY,
|
|
19220
|
-
gearSize: GearType.Size,
|
|
19221
|
-
gearLook: GearType.Look,
|
|
19222
|
-
gearColor: GearType.Color,
|
|
19223
|
-
gearAni: GearType.Animation,
|
|
19224
|
-
gearText: GearType.Text,
|
|
19225
|
-
gearIcon: GearType.Icon,
|
|
19226
|
-
gearDisplay2: GearType.Display2,
|
|
19227
|
-
gearFontSize: GearType.FontSize
|
|
19228
|
-
};
|
|
19229
|
-
function getXmlNode$2(value) {
|
|
19230
|
-
const node = Array.isArray(value) ? value[0] : value;
|
|
19231
|
-
if (!node || typeof node !== "object" || Array.isArray(node)) return null;
|
|
19232
|
-
return node;
|
|
19233
|
-
}
|
|
19234
|
-
function getProtocolChildName$2(protocol, childName) {
|
|
19235
|
-
return protocol.children?.[childName] ? childName : null;
|
|
19236
|
-
}
|
|
19237
|
-
function parsePropertyOverrides(source, protocol) {
|
|
19238
|
-
const childName = getProtocolChildName$2(protocol, "property");
|
|
19239
|
-
if (!childName) return [];
|
|
19240
|
-
return ensureArray(source[childName]).map((raw, index) => {
|
|
19241
|
-
const property = getXmlNode$2(raw);
|
|
19242
|
-
const specs = PROJECT_XML_PROTOCOL.propertyOverride.attrs;
|
|
19243
|
-
const target = property ? readXmlAttr(property, specs.target) : void 0;
|
|
19244
|
-
const rawPropertyId = property ? readXmlAttr(property, specs.propertyId) : void 0;
|
|
19245
|
-
const propertyId = typeof rawPropertyId === "number" ? rawPropertyId : typeof rawPropertyId === "string" && /^\d+$/.test(rawPropertyId) ? Number(rawPropertyId) : NaN;
|
|
19246
|
-
const value = property ? readXmlAttr(property, specs.value) : void 0;
|
|
19247
|
-
if (!target || !Number.isSafeInteger(propertyId) || propertyId < 0 || value === void 0) throw new Error(`Invalid property override at ${childName}[${index}].`);
|
|
19248
|
-
return {
|
|
19249
|
-
target,
|
|
19250
|
-
propertyId,
|
|
19251
|
-
value: String(value)
|
|
19252
|
-
};
|
|
19253
|
-
});
|
|
19254
|
-
}
|
|
19255
|
-
function getProtocolGearChildNames(protocol) {
|
|
19256
|
-
return Object.keys(protocol.children ?? {}).filter((name) => name in GEAR_TAG_MAP);
|
|
19257
|
-
}
|
|
19258
|
-
function getProtocolExtensionChildNames(protocol) {
|
|
19259
|
-
return Object.keys(protocol.children ?? {}).filter((name) => name in EXTENSION_PROTOCOL_MAP$2);
|
|
19260
|
-
}
|
|
19261
19823
|
function getDisplayListVariantName$1(tagName, attrs) {
|
|
19262
19824
|
if (tagName === "loader3d") return "loader3D";
|
|
19263
19825
|
if (tagName === "text") {
|
|
@@ -19273,41 +19835,6 @@ function assertDisplayListTagAllowed(tagName, attrs, componentName) {
|
|
|
19273
19835
|
const variantName = getDisplayListVariantName$1(tagName, attrs);
|
|
19274
19836
|
if (!DISPLAY_LIST_ALLOWED_VARIANTS$1.has(variantName)) throw new Error(`displayList variant "${variantName}" derived from tag "${tagName}" is not declared in protocol for component "${componentName}"`);
|
|
19275
19837
|
}
|
|
19276
|
-
function inferTreeItemFolderFlags(items) {
|
|
19277
|
-
return items.map((item, index) => {
|
|
19278
|
-
if (item.isFolder !== null) return item;
|
|
19279
|
-
return {
|
|
19280
|
-
...item,
|
|
19281
|
-
isFolder: resolveTreeItemIsFolder(items, index)
|
|
19282
|
-
};
|
|
19283
|
-
});
|
|
19284
|
-
}
|
|
19285
|
-
function parseListItemXmlNode(item) {
|
|
19286
|
-
const specs = PROJECT_XML_PROTOCOL.listItem.attrs;
|
|
19287
|
-
const isFolder = readXmlAttr(item, specs.isFolder);
|
|
19288
|
-
const controllers = readXmlAttr(item, specs.controllers);
|
|
19289
|
-
const propertyOverrides = parsePropertyOverrides(item, PROJECT_XML_PROTOCOL.listItem);
|
|
19290
|
-
return {
|
|
19291
|
-
title: readXmlAttr(item, specs.title) ?? null,
|
|
19292
|
-
icon: readXmlAttr(item, specs.icon) ?? null,
|
|
19293
|
-
url: readXmlAttr(item, specs.url) ?? null,
|
|
19294
|
-
name: readXmlAttr(item, specs.name) ?? null,
|
|
19295
|
-
selectedTitle: readXmlAttr(item, specs.selectedTitle) ?? null,
|
|
19296
|
-
selectedIcon: readXmlAttr(item, specs.selectedIcon) ?? null,
|
|
19297
|
-
level: parseInt2(readXmlAttr(item, specs.level)),
|
|
19298
|
-
isFolder: isFolder !== void 0 ? parseBool(isFolder) : null,
|
|
19299
|
-
...controllers !== void 0 ? { controllers } : {},
|
|
19300
|
-
...propertyOverrides.length > 0 ? { propertyOverrides } : {}
|
|
19301
|
-
};
|
|
19302
|
-
}
|
|
19303
|
-
function parseComboBoxItemXmlNode(item) {
|
|
19304
|
-
const specs = PROJECT_XML_PROTOCOL.comboBoxItem.attrs;
|
|
19305
|
-
return {
|
|
19306
|
-
title: readXmlAttr(item, specs.title) ?? null,
|
|
19307
|
-
value: readXmlAttr(item, specs.value) ?? null,
|
|
19308
|
-
icon: readXmlAttr(item, specs.icon) ?? null
|
|
19309
|
-
};
|
|
19310
|
-
}
|
|
19311
19838
|
function readCommonDisplayState(source, object, protocol) {
|
|
19312
19839
|
const specs = protocol.attrs;
|
|
19313
19840
|
const xy = specs.xy ? readXmlAttr(source, specs.xy) : void 0;
|
|
@@ -19368,8 +19895,7 @@ function readCommonDisplayState(source, object, protocol) {
|
|
|
19368
19895
|
const filterData = specs.filterData ? readXmlAttr(source, specs.filterData) : void 0;
|
|
19369
19896
|
if (filterData !== void 0) object.setFilterData(filterData);
|
|
19370
19897
|
}
|
|
19371
|
-
|
|
19372
|
-
function createDisplayObject$1(ctx, doc, tagName, attrs, localControllers) {
|
|
19898
|
+
function createDisplayObject$1(_ctx, doc, tagName, attrs, localControllers) {
|
|
19373
19899
|
const name = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.displayObject.attrs.name) ?? "";
|
|
19374
19900
|
let obj;
|
|
19375
19901
|
switch (tagName) {
|
|
@@ -19392,277 +19918,33 @@ function createDisplayObject$1(ctx, doc, tagName, attrs, localControllers) {
|
|
|
19392
19918
|
vt: 2,
|
|
19393
19919
|
vertical: 2,
|
|
19394
19920
|
both: 3
|
|
19395
|
-
}[flipRaw] ?? parseInt2(imageFlip));
|
|
19396
|
-
}
|
|
19397
|
-
const imageFillMethod = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.image.attrs.fillMethod);
|
|
19398
|
-
const imageFillOrigin = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.image.attrs.fillOrigin);
|
|
19399
|
-
const imageFillClockwise = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.image.attrs.fillClockwise);
|
|
19400
|
-
const imageFillAmount = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.image.attrs.fillAmount);
|
|
19401
|
-
if (imageFillMethod || imageFillOrigin !== void 0 || imageFillClockwise !== void 0 || imageFillAmount !== void 0) {
|
|
19402
|
-
g.setFillMethod({
|
|
19403
|
-
none: 0,
|
|
19404
|
-
hz: 1,
|
|
19405
|
-
vt: 2,
|
|
19406
|
-
radial90: 3,
|
|
19407
|
-
radial180: 4,
|
|
19408
|
-
radial360: 5
|
|
19409
|
-
}[imageFillMethod ?? ""] ?? 0);
|
|
19410
|
-
g.setFillOrigin(parseInt2(imageFillOrigin));
|
|
19411
|
-
g.setFillClockwise(imageFillClockwise !== "false");
|
|
19412
|
-
g.setFillAmount(parseInt2(imageFillAmount, 100) / 100);
|
|
19413
|
-
}
|
|
19414
|
-
obj = g;
|
|
19415
|
-
break;
|
|
19416
|
-
}
|
|
19417
|
-
case "text": {
|
|
19418
|
-
const isInputText = parseBool(readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.input));
|
|
19419
|
-
const g = isInputText ? doc.createGTextInput(name) : doc.createGTextField(name);
|
|
19420
|
-
const textValue = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.text);
|
|
19421
|
-
if (textValue !== void 0) g.setText(String(textValue));
|
|
19422
|
-
const textFontSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.fontSize);
|
|
19423
|
-
if (textFontSize !== void 0) g.setFontSize(parseInt2(textFontSize));
|
|
19424
|
-
const textFont = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.font);
|
|
19425
|
-
if (textFont) g.setFont(textFont);
|
|
19426
|
-
const textColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.color);
|
|
19427
|
-
if (textColor) g.setColor(textColor);
|
|
19428
|
-
const textAlign = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.align);
|
|
19429
|
-
if (textAlign) g.setAlign({
|
|
19430
|
-
left: 0,
|
|
19431
|
-
center: 1,
|
|
19432
|
-
right: 2
|
|
19433
|
-
}[textAlign] ?? 0);
|
|
19434
|
-
const textVAlign = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.vAlign);
|
|
19435
|
-
if (textVAlign) g.setVAlign({
|
|
19436
|
-
top: 0,
|
|
19437
|
-
middle: 1,
|
|
19438
|
-
bottom: 2
|
|
19439
|
-
}[textVAlign] ?? 0);
|
|
19440
|
-
const textAutoSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.autoSize);
|
|
19441
|
-
if (textAutoSize) g.setAutoSize({
|
|
19442
|
-
none: 0,
|
|
19443
|
-
both: 1,
|
|
19444
|
-
height: 2,
|
|
19445
|
-
shrink: 3,
|
|
19446
|
-
ellipsis: 4
|
|
19447
|
-
}[textAutoSize] ?? 1);
|
|
19448
|
-
const textSingleLine = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.singleLine);
|
|
19449
|
-
if (textSingleLine !== void 0) g.setSingleLine(parseBool(textSingleLine));
|
|
19450
|
-
const textAutoClearText = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.autoClearText);
|
|
19451
|
-
if (textAutoClearText !== void 0) g.setAutoClearText?.(parseBool(textAutoClearText));
|
|
19452
|
-
const textDemoText = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.demoText);
|
|
19453
|
-
if (textDemoText !== void 0) g.setDemoText?.(String(textDemoText));
|
|
19454
|
-
const textVars = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.vars);
|
|
19455
|
-
if (textVars !== void 0) g.setTemplateVarsEnabled?.(parseBool(textVars));
|
|
19456
|
-
const textFaceDilate = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.faceDilate);
|
|
19457
|
-
if (textFaceDilate !== void 0) g.setFaceDilate?.(parseFloat2(textFaceDilate));
|
|
19458
|
-
const textOutlineSoftness = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.outlineSoftness);
|
|
19459
|
-
if (textOutlineSoftness !== void 0) g.setOutlineSoftness?.(parseFloat2(textOutlineSoftness));
|
|
19460
|
-
const textUnderlaySoftness = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.underlaySoftness);
|
|
19461
|
-
if (textUnderlaySoftness !== void 0) g.setUnderlaySoftness?.(parseFloat2(textUnderlaySoftness));
|
|
19462
|
-
const textUbb = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.ubb);
|
|
19463
|
-
if (textUbb !== void 0) g.setUbbEnabled(parseBool(textUbb));
|
|
19464
|
-
const textLeading = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.leading);
|
|
19465
|
-
if (textLeading !== void 0) g.setLeading?.(parseInt2(textLeading));
|
|
19466
|
-
const textLetterSpacing = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.letterSpacing);
|
|
19467
|
-
if (textLetterSpacing !== void 0) g.setLetterSpacing?.(parseInt2(textLetterSpacing));
|
|
19468
|
-
const textUnderline = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.underline);
|
|
19469
|
-
if (textUnderline !== void 0) g.setUnderline?.(parseBool(textUnderline));
|
|
19470
|
-
const textItalic = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.italic);
|
|
19471
|
-
if (textItalic !== void 0) g.setItalic?.(parseBool(textItalic));
|
|
19472
|
-
const textBold = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.bold);
|
|
19473
|
-
if (textBold !== void 0) g.setBold?.(parseBool(textBold));
|
|
19474
|
-
const textStrikethrough = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strikethrough);
|
|
19475
|
-
if (textStrikethrough !== void 0) g.setStrikethrough?.(parseBool(textStrikethrough));
|
|
19476
|
-
const textStrokeColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strokeColor);
|
|
19477
|
-
if (textStrokeColor) {
|
|
19478
|
-
g.setStrokeColor?.(textStrokeColor);
|
|
19479
|
-
const textStrokeSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strokeSize);
|
|
19480
|
-
g.setStrokeSize?.(parseFloat2(textStrokeSize, 1));
|
|
19481
|
-
}
|
|
19482
|
-
const textShadowColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.shadowColor);
|
|
19483
|
-
if (textShadowColor) {
|
|
19484
|
-
g.setShadowColor?.(textShadowColor);
|
|
19485
|
-
const textShadowOffset = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.shadowOffset);
|
|
19486
|
-
const shadowParts = String(textShadowOffset ?? "1,1").split(",");
|
|
19487
|
-
g.setShadowOffset?.({
|
|
19488
|
-
x: parseFloat2(shadowParts[0], 1),
|
|
19489
|
-
y: parseFloat2(shadowParts[1], 1)
|
|
19490
|
-
});
|
|
19491
|
-
}
|
|
19492
|
-
if (isInputText) {
|
|
19493
|
-
const input = g;
|
|
19494
|
-
const prompt = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.prompt);
|
|
19495
|
-
if (prompt !== void 0) input.setPromptText(String(prompt));
|
|
19496
|
-
const inputMaxLength = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.maxLength);
|
|
19497
|
-
if (inputMaxLength !== void 0) input.setMaxLength(parseInt2(inputMaxLength));
|
|
19498
|
-
const inputRestrict = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.restrict);
|
|
19499
|
-
if (inputRestrict !== void 0) input.setRestrict(String(inputRestrict));
|
|
19500
|
-
const inputPassword = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.password);
|
|
19501
|
-
if (inputPassword !== void 0) input.setPassword(parseBool(inputPassword));
|
|
19502
|
-
const inputKeyboardType = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.keyboardType);
|
|
19503
|
-
if (inputKeyboardType !== void 0) input.setKeyboardType?.(parseInt2(inputKeyboardType));
|
|
19504
|
-
}
|
|
19505
|
-
obj = g;
|
|
19506
|
-
break;
|
|
19507
|
-
}
|
|
19508
|
-
case "richtext": {
|
|
19509
|
-
const g = doc.createGRichTextField(name);
|
|
19510
|
-
const richText = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.text);
|
|
19511
|
-
if (richText !== void 0) g.setText(String(richText));
|
|
19512
|
-
const richTextFontSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.fontSize);
|
|
19513
|
-
if (richTextFontSize !== void 0) g.setFontSize(parseInt2(richTextFontSize));
|
|
19514
|
-
const richTextFont = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.font);
|
|
19515
|
-
if (richTextFont) g.setFont(richTextFont);
|
|
19516
|
-
const richTextColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.color);
|
|
19517
|
-
if (richTextColor) g.setColor(richTextColor);
|
|
19518
|
-
const richTextAlign = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.align);
|
|
19519
|
-
if (richTextAlign) g.setAlign({
|
|
19520
|
-
left: 0,
|
|
19521
|
-
center: 1,
|
|
19522
|
-
right: 2
|
|
19523
|
-
}[richTextAlign] ?? 0);
|
|
19524
|
-
const richTextVAlign = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.vAlign);
|
|
19525
|
-
if (richTextVAlign) g.setVAlign({
|
|
19526
|
-
top: 0,
|
|
19527
|
-
middle: 1,
|
|
19528
|
-
bottom: 2
|
|
19529
|
-
}[richTextVAlign] ?? 0);
|
|
19530
|
-
const richTextLeading = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.leading);
|
|
19531
|
-
if (richTextLeading !== void 0) g.setLeading?.(parseInt2(richTextLeading));
|
|
19532
|
-
const richTextLetterSpacing = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.letterSpacing);
|
|
19533
|
-
if (richTextLetterSpacing !== void 0) g.setLetterSpacing?.(parseInt2(richTextLetterSpacing));
|
|
19534
|
-
const richTextUbb = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.ubb);
|
|
19535
|
-
if (richTextUbb !== void 0) g.setUbbEnabled?.(parseBool(richTextUbb));
|
|
19536
|
-
const richTextAutoSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.autoSize);
|
|
19537
|
-
if (richTextAutoSize) g.setAutoSize({
|
|
19538
|
-
none: 0,
|
|
19539
|
-
both: 1,
|
|
19540
|
-
height: 2,
|
|
19541
|
-
shrink: 3,
|
|
19542
|
-
ellipsis: 4
|
|
19543
|
-
}[richTextAutoSize] ?? 1);
|
|
19544
|
-
const richTextSingleLine = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.singleLine);
|
|
19545
|
-
if (richTextSingleLine !== void 0) g.setSingleLine?.(parseBool(richTextSingleLine));
|
|
19546
|
-
const richTextAutoClearText = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.autoClearText);
|
|
19547
|
-
if (richTextAutoClearText !== void 0) g.setAutoClearText?.(parseBool(richTextAutoClearText));
|
|
19548
|
-
const richTextOutlineSoftness = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.richText.attrs.outlineSoftness);
|
|
19549
|
-
if (richTextOutlineSoftness !== void 0) g.setOutlineSoftness?.(parseFloat2(richTextOutlineSoftness));
|
|
19550
|
-
const richTextUnderlaySoftness = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.richText.attrs.underlaySoftness);
|
|
19551
|
-
if (richTextUnderlaySoftness !== void 0) g.setUnderlaySoftness?.(parseFloat2(richTextUnderlaySoftness));
|
|
19552
|
-
const richTextUnderline = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.underline);
|
|
19553
|
-
if (richTextUnderline !== void 0) g.setUnderline?.(parseBool(richTextUnderline));
|
|
19554
|
-
const richTextItalic = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.italic);
|
|
19555
|
-
if (richTextItalic !== void 0) g.setItalic?.(parseBool(richTextItalic));
|
|
19556
|
-
const richTextBold = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.bold);
|
|
19557
|
-
if (richTextBold !== void 0) g.setBold?.(parseBool(richTextBold));
|
|
19558
|
-
const richTextStrikethrough = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strikethrough);
|
|
19559
|
-
if (richTextStrikethrough !== void 0) g.setStrikethrough?.(parseBool(richTextStrikethrough));
|
|
19560
|
-
const richTextStrokeColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strokeColor);
|
|
19561
|
-
if (richTextStrokeColor) {
|
|
19562
|
-
g.setStrokeColor?.(richTextStrokeColor);
|
|
19563
|
-
const richTextStrokeSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strokeSize);
|
|
19564
|
-
g.setStrokeSize?.(parseFloat2(richTextStrokeSize, 1));
|
|
19921
|
+
}[flipRaw] ?? parseInt2(imageFlip));
|
|
19565
19922
|
}
|
|
19566
|
-
const
|
|
19567
|
-
|
|
19568
|
-
|
|
19569
|
-
|
|
19570
|
-
|
|
19571
|
-
g.
|
|
19572
|
-
|
|
19573
|
-
|
|
19574
|
-
|
|
19923
|
+
const imageFillMethod = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.image.attrs.fillMethod);
|
|
19924
|
+
const imageFillOrigin = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.image.attrs.fillOrigin);
|
|
19925
|
+
const imageFillClockwise = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.image.attrs.fillClockwise);
|
|
19926
|
+
const imageFillAmount = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.image.attrs.fillAmount);
|
|
19927
|
+
if (imageFillMethod || imageFillOrigin !== void 0 || imageFillClockwise !== void 0 || imageFillAmount !== void 0) {
|
|
19928
|
+
g.setFillMethod({
|
|
19929
|
+
none: 0,
|
|
19930
|
+
hz: 1,
|
|
19931
|
+
vt: 2,
|
|
19932
|
+
radial90: 3,
|
|
19933
|
+
radial180: 4,
|
|
19934
|
+
radial360: 5
|
|
19935
|
+
}[imageFillMethod ?? ""] ?? 0);
|
|
19936
|
+
g.setFillOrigin(parseInt2(imageFillOrigin));
|
|
19937
|
+
g.setFillClockwise(imageFillClockwise !== "false");
|
|
19938
|
+
g.setFillAmount(parseInt2(imageFillAmount, 100) / 100);
|
|
19575
19939
|
}
|
|
19576
19940
|
obj = g;
|
|
19577
19941
|
break;
|
|
19578
19942
|
}
|
|
19579
|
-
case "
|
|
19580
|
-
|
|
19581
|
-
|
|
19582
|
-
|
|
19583
|
-
const inputFontSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.fontSize);
|
|
19584
|
-
if (inputFontSize !== void 0) g.setFontSize(parseInt2(inputFontSize));
|
|
19585
|
-
const inputFont = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.font);
|
|
19586
|
-
if (inputFont) g.setFont(inputFont);
|
|
19587
|
-
const inputColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.color);
|
|
19588
|
-
if (inputColor) g.setColor(inputColor);
|
|
19589
|
-
const inputAlign = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.align);
|
|
19590
|
-
if (inputAlign) g.setAlign({
|
|
19591
|
-
left: 0,
|
|
19592
|
-
center: 1,
|
|
19593
|
-
right: 2
|
|
19594
|
-
}[inputAlign] ?? 0);
|
|
19595
|
-
const inputVAlign = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.vAlign);
|
|
19596
|
-
if (inputVAlign) g.setVAlign({
|
|
19597
|
-
top: 0,
|
|
19598
|
-
middle: 1,
|
|
19599
|
-
bottom: 2
|
|
19600
|
-
}[inputVAlign] ?? 0);
|
|
19601
|
-
const inputLeading = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.leading);
|
|
19602
|
-
if (inputLeading !== void 0) g.setLeading?.(parseInt2(inputLeading));
|
|
19603
|
-
const inputLetterSpacing = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.letterSpacing);
|
|
19604
|
-
if (inputLetterSpacing !== void 0) g.setLetterSpacing?.(parseInt2(inputLetterSpacing));
|
|
19605
|
-
const inputAutoSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.autoSize);
|
|
19606
|
-
if (inputAutoSize) g.setAutoSize({
|
|
19607
|
-
none: 0,
|
|
19608
|
-
both: 1,
|
|
19609
|
-
height: 2,
|
|
19610
|
-
shrink: 3,
|
|
19611
|
-
ellipsis: 4
|
|
19612
|
-
}[inputAutoSize] ?? 1);
|
|
19613
|
-
const inputSingleLine = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.singleLine);
|
|
19614
|
-
if (inputSingleLine !== void 0) g.setSingleLine?.(parseBool(inputSingleLine));
|
|
19615
|
-
const inputAutoClearText = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.autoClearText);
|
|
19616
|
-
if (inputAutoClearText !== void 0) g.setAutoClearText?.(parseBool(inputAutoClearText));
|
|
19617
|
-
const inputDemoText = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.demoText);
|
|
19618
|
-
if (inputDemoText !== void 0) g.setDemoText?.(String(inputDemoText));
|
|
19619
|
-
const inputVars = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.vars);
|
|
19620
|
-
if (inputVars !== void 0) g.setTemplateVarsEnabled?.(parseBool(inputVars));
|
|
19621
|
-
const inputFaceDilate = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.faceDilate);
|
|
19622
|
-
if (inputFaceDilate !== void 0) g.setFaceDilate?.(parseFloat2(inputFaceDilate));
|
|
19623
|
-
const inputOutlineSoftness = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.outlineSoftness);
|
|
19624
|
-
if (inputOutlineSoftness !== void 0) g.setOutlineSoftness?.(parseFloat2(inputOutlineSoftness));
|
|
19625
|
-
const inputUnderlaySoftness = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.underlaySoftness);
|
|
19626
|
-
if (inputUnderlaySoftness !== void 0) g.setUnderlaySoftness?.(parseFloat2(inputUnderlaySoftness));
|
|
19627
|
-
const inputUbb = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.ubb);
|
|
19628
|
-
if (inputUbb !== void 0) g.setUbbEnabled?.(parseBool(inputUbb));
|
|
19629
|
-
const inputUnderline = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.underline);
|
|
19630
|
-
if (inputUnderline !== void 0) g.setUnderline?.(parseBool(inputUnderline));
|
|
19631
|
-
const inputItalic = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.italic);
|
|
19632
|
-
if (inputItalic !== void 0) g.setItalic?.(parseBool(inputItalic));
|
|
19633
|
-
const inputBold = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.bold);
|
|
19634
|
-
if (inputBold !== void 0) g.setBold?.(parseBool(inputBold));
|
|
19635
|
-
const inputStrikethrough = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strikethrough);
|
|
19636
|
-
if (inputStrikethrough !== void 0) g.setStrikethrough?.(parseBool(inputStrikethrough));
|
|
19637
|
-
const inputStrokeColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strokeColor);
|
|
19638
|
-
if (inputStrokeColor) {
|
|
19639
|
-
g.setStrokeColor?.(inputStrokeColor);
|
|
19640
|
-
const inputStrokeSize = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.strokeSize);
|
|
19641
|
-
g.setStrokeSize?.(parseFloat2(inputStrokeSize, 1));
|
|
19642
|
-
}
|
|
19643
|
-
const inputShadowColor = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.shadowColor);
|
|
19644
|
-
if (inputShadowColor) {
|
|
19645
|
-
g.setShadowColor?.(inputShadowColor);
|
|
19646
|
-
const inputShadowOffset = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.text.attrs.shadowOffset);
|
|
19647
|
-
const shadowParts = String(inputShadowOffset ?? "1,1").split(",");
|
|
19648
|
-
g.setShadowOffset?.({
|
|
19649
|
-
x: parseFloat2(shadowParts[0], 1),
|
|
19650
|
-
y: parseFloat2(shadowParts[1], 1)
|
|
19651
|
-
});
|
|
19652
|
-
}
|
|
19653
|
-
const prompt = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.prompt);
|
|
19654
|
-
if (prompt !== void 0) g.setPromptText(prompt);
|
|
19655
|
-
const inputMaxLength = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.maxLength);
|
|
19656
|
-
if (inputMaxLength !== void 0) g.setMaxLength(parseInt2(inputMaxLength));
|
|
19657
|
-
const inputRestrict = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.restrict);
|
|
19658
|
-
if (inputRestrict !== void 0) g.setRestrict(inputRestrict);
|
|
19659
|
-
const inputPassword = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.password);
|
|
19660
|
-
if (inputPassword !== void 0) g.setPassword(parseBool(inputPassword));
|
|
19661
|
-
const inputKeyboardType = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.textInput.attrs.keyboardType);
|
|
19662
|
-
if (inputKeyboardType !== void 0) g.setKeyboardType?.(parseInt2(inputKeyboardType));
|
|
19663
|
-
obj = g;
|
|
19943
|
+
case "text":
|
|
19944
|
+
case "richtext":
|
|
19945
|
+
case "inputtext":
|
|
19946
|
+
obj = createTextDisplayObject(doc, tagName, name, attrs);
|
|
19664
19947
|
break;
|
|
19665
|
-
}
|
|
19666
19948
|
case "graph": {
|
|
19667
19949
|
const g = doc.createGGraph(name);
|
|
19668
19950
|
const graphType = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.graph.attrs.type);
|
|
@@ -19866,278 +20148,19 @@ function createDisplayObject$1(ctx, doc, tagName, attrs, localControllers) {
|
|
|
19866
20148
|
obj = g;
|
|
19867
20149
|
break;
|
|
19868
20150
|
}
|
|
19869
|
-
case "list":
|
|
19870
|
-
|
|
19871
|
-
const isTree = treeView !== void 0 && parseBool(treeView);
|
|
19872
|
-
let g;
|
|
19873
|
-
if (isTree) {
|
|
19874
|
-
g = doc.createGTree(name).setTreeView(true);
|
|
19875
|
-
const indent = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.indent);
|
|
19876
|
-
if (indent !== void 0) g.setIndent(parseInt2(indent));
|
|
19877
|
-
const clickToExpand = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.clickToExpand);
|
|
19878
|
-
if (clickToExpand !== void 0) g.setClickToExpand(parseInt2(clickToExpand));
|
|
19879
|
-
} else g = doc.createGList(name);
|
|
19880
|
-
const src = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.src);
|
|
19881
|
-
g.setSrc(src || "");
|
|
19882
|
-
const defaultItem = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.defaultItem);
|
|
19883
|
-
if (defaultItem) g.setDefaultItem(defaultItem);
|
|
19884
|
-
const scrollBarRes = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scrollBarRes);
|
|
19885
|
-
if (scrollBarRes) {
|
|
19886
|
-
const parts = String(scrollBarRes).split(",");
|
|
19887
|
-
g.setVtScrollBarRes?.(parts[0] ?? "");
|
|
19888
|
-
g.setHzScrollBarRes?.(parts[1] ?? "");
|
|
19889
|
-
}
|
|
19890
|
-
const ptrRes = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.ptrRes);
|
|
19891
|
-
if (ptrRes) {
|
|
19892
|
-
const parts = String(ptrRes).split(",");
|
|
19893
|
-
g.setHeaderRes?.(parts[0] ?? "");
|
|
19894
|
-
g.setFooterRes?.(parts[1] ?? "");
|
|
19895
|
-
}
|
|
19896
|
-
const controllerOverrides = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.controllerOverrides);
|
|
19897
|
-
if (controllerOverrides) g.setControllerOverrides?.(controllerOverrides);
|
|
19898
|
-
const pageController = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.pageController);
|
|
19899
|
-
if (pageController) g.setPageController?.(pageController);
|
|
19900
|
-
const layout = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.layout);
|
|
19901
|
-
if (layout) g.setLayout({
|
|
19902
|
-
singleColumn: 0,
|
|
19903
|
-
singleRow: 1,
|
|
19904
|
-
flowHorizontal: 2,
|
|
19905
|
-
flowVertical: 3,
|
|
19906
|
-
pagination: 4,
|
|
19907
|
-
single_column: 0,
|
|
19908
|
-
single_row: 1,
|
|
19909
|
-
flow_hz: 2,
|
|
19910
|
-
flow_vt: 3,
|
|
19911
|
-
column: 0,
|
|
19912
|
-
row: 1
|
|
19913
|
-
}[layout] ?? 0);
|
|
19914
|
-
const align = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.align);
|
|
19915
|
-
if (align) g.setAlign({
|
|
19916
|
-
left: 0,
|
|
19917
|
-
center: 1,
|
|
19918
|
-
right: 2
|
|
19919
|
-
}[align] ?? 0);
|
|
19920
|
-
const vAlign = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.vAlign);
|
|
19921
|
-
if (vAlign) g.setVAlign({
|
|
19922
|
-
top: 0,
|
|
19923
|
-
middle: 1,
|
|
19924
|
-
bottom: 2
|
|
19925
|
-
}[vAlign] ?? 0);
|
|
19926
|
-
const lineGap = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.lineGap);
|
|
19927
|
-
if (lineGap !== void 0) g.setLineGap(parseInt2(lineGap));
|
|
19928
|
-
const columnGap = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.columnGap);
|
|
19929
|
-
if (columnGap !== void 0) g.setColumnGap(parseInt2(columnGap));
|
|
19930
|
-
const lineItemCount = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.lineItemCount);
|
|
19931
|
-
const lineItemCount2 = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.lineItemCount2);
|
|
19932
|
-
if (layout) {
|
|
19933
|
-
const resolvedLayout = g.getLayout?.() ?? 0;
|
|
19934
|
-
if (resolvedLayout === 2 || resolvedLayout === 4) {
|
|
19935
|
-
if (lineItemCount !== void 0) g.setColumnCount?.(parseInt2(lineItemCount));
|
|
19936
|
-
} else if (resolvedLayout === 3 && lineItemCount !== void 0) g.setLineCount?.(parseInt2(lineItemCount));
|
|
19937
|
-
if (resolvedLayout === 4 && lineItemCount2 !== void 0) g.setLineCount?.(parseInt2(lineItemCount2));
|
|
19938
|
-
}
|
|
19939
|
-
const autoResizeItem = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.autoResizeItem);
|
|
19940
|
-
g.setAutoResizeItem?.(autoResizeItem === void 0 ? getDefaultListAutoResizeItem(g.getLayout?.() ?? 0) : parseBool(autoResizeItem));
|
|
19941
|
-
const childrenRenderOrder = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.childrenRenderOrder);
|
|
19942
|
-
if (childrenRenderOrder) g.setChildrenRenderOrder?.({
|
|
19943
|
-
ascent: 0,
|
|
19944
|
-
descent: 1,
|
|
19945
|
-
arch: 2
|
|
19946
|
-
}[childrenRenderOrder] ?? 0);
|
|
19947
|
-
const apexIndex = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.apexIndex);
|
|
19948
|
-
if (apexIndex !== void 0) g.setApexIndex?.(parseInt2(apexIndex));
|
|
19949
|
-
const selectionMode = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.selectionMode);
|
|
19950
|
-
if (selectionMode) g.setSelectionMode({
|
|
19951
|
-
single: 0,
|
|
19952
|
-
multiple: 1,
|
|
19953
|
-
multipleSingleClick: 2,
|
|
19954
|
-
none: 3
|
|
19955
|
-
}[selectionMode] ?? 0);
|
|
19956
|
-
const selectionController = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.selectionController);
|
|
19957
|
-
if (selectionController !== void 0) g.setSelectionController?.(selectionController);
|
|
19958
|
-
const overflow = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.overflow);
|
|
19959
|
-
const scroll = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scroll);
|
|
19960
|
-
const scrollBar = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scrollBar);
|
|
19961
|
-
const scrollBarFlags = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scrollBarFlags);
|
|
19962
|
-
const margin = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.margin);
|
|
19963
|
-
if (overflow || scroll || scrollBar || scrollBarFlags !== void 0 || margin) {
|
|
19964
|
-
if (overflow) g.setOverflow({
|
|
19965
|
-
visible: 0,
|
|
19966
|
-
hidden: 1,
|
|
19967
|
-
scroll: 2
|
|
19968
|
-
}[overflow] ?? 0);
|
|
19969
|
-
if (scroll) g.setScrollType({
|
|
19970
|
-
horizontal: 0,
|
|
19971
|
-
vertical: 1,
|
|
19972
|
-
both: 2
|
|
19973
|
-
}[scroll] ?? 1);
|
|
19974
|
-
if (scrollBar) g.setScrollBarDisplay({
|
|
19975
|
-
default: 0,
|
|
19976
|
-
visible: 1,
|
|
19977
|
-
auto: 2,
|
|
19978
|
-
hidden: 3
|
|
19979
|
-
}[scrollBar] ?? 0);
|
|
19980
|
-
if (scrollBarFlags !== void 0) g.setScrollBarFlags(parseInt2(scrollBarFlags));
|
|
19981
|
-
if (margin) {
|
|
19982
|
-
const parts = margin.split(",").map(Number);
|
|
19983
|
-
g.setMargin({
|
|
19984
|
-
top: parts[0] ?? 0,
|
|
19985
|
-
bottom: parts[1] ?? 0,
|
|
19986
|
-
left: parts[2] ?? 0,
|
|
19987
|
-
right: parts[3] ?? 0
|
|
19988
|
-
});
|
|
19989
|
-
}
|
|
19990
|
-
}
|
|
19991
|
-
const scrollBarMargin = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scrollBarMargin);
|
|
19992
|
-
if (scrollBarMargin) {
|
|
19993
|
-
const parts = scrollBarMargin.split(",").map(Number);
|
|
19994
|
-
g.setScrollBarMargin?.({
|
|
19995
|
-
top: parts[0] ?? 0,
|
|
19996
|
-
bottom: parts[1] ?? 0,
|
|
19997
|
-
left: parts[2] ?? 0,
|
|
19998
|
-
right: parts[3] ?? 0
|
|
19999
|
-
});
|
|
20000
|
-
}
|
|
20001
|
-
const clipSoftness = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.clipSoftness);
|
|
20002
|
-
if (clipSoftness) {
|
|
20003
|
-
const csParts = clipSoftness.split(",").map(Number);
|
|
20004
|
-
g.setClipSoftness({
|
|
20005
|
-
x: csParts[0] ?? 0,
|
|
20006
|
-
y: csParts[1] ?? 0
|
|
20007
|
-
});
|
|
20008
|
-
}
|
|
20009
|
-
const scrollItemToViewOnClick = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.scrollItemToViewOnClick);
|
|
20010
|
-
if (scrollItemToViewOnClick !== void 0) g.setScrollItemToViewOnClick?.(parseBool(scrollItemToViewOnClick));
|
|
20011
|
-
const foldInvisibleItems = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.foldInvisibleItems);
|
|
20012
|
-
if (foldInvisibleItems !== void 0) g.setFoldInvisibleItems?.(parseBool(foldInvisibleItems));
|
|
20013
|
-
const autoClearItems = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.list.attrs.autoClearItems);
|
|
20014
|
-
if (autoClearItems !== void 0) g.setAutoClearItems?.(parseBool(autoClearItems));
|
|
20015
|
-
const listItemChildName = getProtocolChildName$2(PROJECT_XML_PROTOCOL.list, "item");
|
|
20016
|
-
const items = listItemChildName ? ensureArray(attrs[listItemChildName]) : [];
|
|
20017
|
-
if (items.length > 0) {
|
|
20018
|
-
const listItems = items.map((itemDef) => getXmlNode$2(itemDef)).filter((itemDef) => itemDef !== null).map((itemDef) => parseListItemXmlNode(itemDef));
|
|
20019
|
-
g.setListItems(isTree ? inferTreeItemFolderFlags(listItems) : listItems);
|
|
20020
|
-
}
|
|
20021
|
-
obj = g;
|
|
20151
|
+
case "list":
|
|
20152
|
+
obj = createListDisplayObject(doc, name, attrs);
|
|
20022
20153
|
break;
|
|
20023
|
-
}
|
|
20024
20154
|
default: return null;
|
|
20025
20155
|
}
|
|
20026
20156
|
const objectId = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.displayObject.attrs.id);
|
|
20027
20157
|
obj.setId(objectId || "");
|
|
20028
20158
|
const objectProtocol = DISPLAY_OBJECT_PROTOCOL_MAP[tagName];
|
|
20029
20159
|
readCommonDisplayState(attrs, obj, objectProtocol);
|
|
20030
|
-
|
|
20031
|
-
|
|
20032
|
-
for (const gearDef of gearDefs) {
|
|
20033
|
-
const parsedGear = getXmlNode$2(gearDef);
|
|
20034
|
-
if (!parsedGear) continue;
|
|
20035
|
-
parseGear(ctx, doc, obj, gearTag, parsedGear, localControllers);
|
|
20036
|
-
}
|
|
20037
|
-
}
|
|
20038
|
-
const relationChildName = getProtocolChildName$2(objectProtocol, "relation");
|
|
20039
|
-
const relations = relationChildName ? ensureArray(attrs[relationChildName]) : [];
|
|
20040
|
-
for (const relDef of relations) {
|
|
20041
|
-
const parsedRelation = getXmlNode$2(relDef);
|
|
20042
|
-
if (!parsedRelation) continue;
|
|
20043
|
-
const sidePairs = parseSidePair(readXmlAttr(parsedRelation, PROJECT_XML_PROTOCOL.relation.attrs.sidePair) || "");
|
|
20044
|
-
for (const sp of sidePairs) {
|
|
20045
|
-
const rel = {
|
|
20046
|
-
target: readXmlAttr(parsedRelation, PROJECT_XML_PROTOCOL.relation.attrs.target) || "",
|
|
20047
|
-
type: sp.type,
|
|
20048
|
-
usePercent: sp.usePercent
|
|
20049
|
-
};
|
|
20050
|
-
obj.addRelation(rel);
|
|
20051
|
-
}
|
|
20052
|
-
}
|
|
20053
|
-
if (obj.propertyType === "GComponent") obj.setPropertyOverrides(parsePropertyOverrides(attrs, PROJECT_XML_PROTOCOL.componentInstance));
|
|
20054
|
-
for (const extTypeName of getProtocolExtensionChildNames(PROJECT_XML_PROTOCOL.componentInstance)) {
|
|
20055
|
-
const extElement = attrs[extTypeName];
|
|
20056
|
-
if (extElement) {
|
|
20057
|
-
const extAttrs = getXmlNode$2(extElement);
|
|
20058
|
-
if (!extAttrs || obj.propertyType !== "GComponent") continue;
|
|
20059
|
-
const componentObj = obj;
|
|
20060
|
-
const extSpecs = EXTENSION_PROTOCOL_MAP$2[extTypeName].attrs;
|
|
20061
|
-
componentObj.setInstanceExtType?.(extTypeName);
|
|
20062
|
-
const title = extSpecs.title ? readXmlAttr(extAttrs, extSpecs.title) : void 0;
|
|
20063
|
-
if (title !== void 0) componentObj.setInstanceTitle?.(title);
|
|
20064
|
-
const selectedTitle = extSpecs.selectedTitle ? readXmlAttr(extAttrs, extSpecs.selectedTitle) : void 0;
|
|
20065
|
-
if (selectedTitle !== void 0) componentObj.setInstanceSelectedTitle?.(selectedTitle);
|
|
20066
|
-
const icon = extSpecs.icon ? readXmlAttr(extAttrs, extSpecs.icon) : void 0;
|
|
20067
|
-
if (icon !== void 0) componentObj.setInstanceIcon?.(icon);
|
|
20068
|
-
const selectedIcon = extSpecs.selectedIcon ? readXmlAttr(extAttrs, extSpecs.selectedIcon) : void 0;
|
|
20069
|
-
if (selectedIcon !== void 0) componentObj.setInstanceSelectedIcon?.(selectedIcon);
|
|
20070
|
-
const titleColor = extSpecs.titleColor ? readXmlAttr(extAttrs, extSpecs.titleColor) : void 0;
|
|
20071
|
-
if (titleColor !== void 0) componentObj.setInstanceTitleColor?.(titleColor);
|
|
20072
|
-
const titleFontSize = extSpecs.titleFontSize ? readXmlAttr(extAttrs, extSpecs.titleFontSize) : void 0;
|
|
20073
|
-
if (titleFontSize !== void 0) componentObj.setInstanceTitleFontSize?.(parseInt2(titleFontSize));
|
|
20074
|
-
const controller = extSpecs.controller ? readXmlAttr(extAttrs, extSpecs.controller) : void 0;
|
|
20075
|
-
if (controller !== void 0) componentObj.setInstanceController?.(controller);
|
|
20076
|
-
const page = extSpecs.page ? readXmlAttr(extAttrs, extSpecs.page) : void 0;
|
|
20077
|
-
if (page !== void 0) componentObj.setInstancePage?.(page);
|
|
20078
|
-
const checked = extSpecs.checked ? readXmlAttr(extAttrs, extSpecs.checked) : void 0;
|
|
20079
|
-
if (checked !== void 0) componentObj.setInstanceChecked?.(parseBool(checked));
|
|
20080
|
-
const sound = extSpecs.sound ? readXmlAttr(extAttrs, extSpecs.sound) : void 0;
|
|
20081
|
-
if (sound !== void 0) componentObj.setInstanceSound?.(sound);
|
|
20082
|
-
const soundVolumeScale = extSpecs.soundVolumeScale ? readXmlAttr(extAttrs, extSpecs.soundVolumeScale) : void 0;
|
|
20083
|
-
if (soundVolumeScale !== void 0) componentObj.setInstanceSoundVolumeScale?.(parseFloat2(soundVolumeScale, 100) / 100);
|
|
20084
|
-
const popupDirection = extSpecs.popupDirection ? readXmlAttr(extAttrs, extSpecs.popupDirection) : void 0;
|
|
20085
|
-
if (popupDirection !== void 0) componentObj.setInstancePopupDirection?.({
|
|
20086
|
-
auto: 0,
|
|
20087
|
-
up: 1,
|
|
20088
|
-
down: 2
|
|
20089
|
-
}[popupDirection] ?? 0);
|
|
20090
|
-
const prompt = extSpecs.prompt ? readXmlAttr(extAttrs, extSpecs.prompt) : void 0;
|
|
20091
|
-
if (prompt !== void 0) componentObj.setInstancePromptText?.(prompt);
|
|
20092
|
-
const selectionController = extSpecs.selectionController ? readXmlAttr(extAttrs, extSpecs.selectionController) : void 0;
|
|
20093
|
-
if (selectionController !== void 0) componentObj.setInstanceSelectionController?.(selectionController);
|
|
20094
|
-
const visibleItemCount = extSpecs.visibleItemCount ? readXmlAttr(extAttrs, extSpecs.visibleItemCount) : void 0;
|
|
20095
|
-
if (visibleItemCount !== void 0) componentObj.setInstanceVisibleItemCount?.(parseInt2(visibleItemCount));
|
|
20096
|
-
const autoClearItems = extSpecs.autoClearItems ? readXmlAttr(extAttrs, extSpecs.autoClearItems) : void 0;
|
|
20097
|
-
if (autoClearItems !== void 0) componentObj.setInstanceAutoClearItems?.(parseBool(autoClearItems));
|
|
20098
|
-
const value = extSpecs.value ? readXmlAttr(extAttrs, extSpecs.value) : void 0;
|
|
20099
|
-
if (value !== void 0) componentObj.setInstanceValue?.(parseInt2(value));
|
|
20100
|
-
const max = extSpecs.max ? readXmlAttr(extAttrs, extSpecs.max) : void 0;
|
|
20101
|
-
if (max !== void 0) componentObj.setInstanceMax?.(parseInt2(max, 100));
|
|
20102
|
-
const min = extSpecs.min ? readXmlAttr(extAttrs, extSpecs.min) : void 0;
|
|
20103
|
-
if (min !== void 0) componentObj.setInstanceMin?.(parseInt2(min));
|
|
20104
|
-
const comboBoxItemChildName = getProtocolChildName$2(PROJECT_XML_PROTOCOL.comboBoxExtension, "item");
|
|
20105
|
-
if (extTypeName === "ComboBox" && comboBoxItemChildName && extAttrs[comboBoxItemChildName]) {
|
|
20106
|
-
const comboItems = ensureArray(extAttrs[comboBoxItemChildName]);
|
|
20107
|
-
componentObj.setInstanceComboItems?.(comboItems.map((itemDef) => getXmlNode$2(itemDef)).filter((itemDef) => itemDef !== null).map((itemDef) => parseComboBoxItemXmlNode(itemDef)));
|
|
20108
|
-
}
|
|
20109
|
-
}
|
|
20110
|
-
}
|
|
20160
|
+
readDisplayBehaviors(doc, obj, attrs, objectProtocol, localControllers);
|
|
20161
|
+
readComponentInstanceOverlays(obj, attrs);
|
|
20111
20162
|
return obj;
|
|
20112
20163
|
}
|
|
20113
|
-
function parseGear(_ctx, doc, obj, gearTag, attrs, localControllers) {
|
|
20114
|
-
const gearType = GEAR_TAG_MAP[gearTag];
|
|
20115
|
-
if (gearType === void 0) return;
|
|
20116
|
-
const gear = doc.createGear();
|
|
20117
|
-
gear.setGearType(gearType);
|
|
20118
|
-
const tween = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.tween);
|
|
20119
|
-
gear.setTween(parseBool(tween));
|
|
20120
|
-
const positionsInPercent = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.positionsInPercent);
|
|
20121
|
-
if (positionsInPercent !== void 0) gear.setPositionsInPercent(parseBool(positionsInPercent));
|
|
20122
|
-
const ctrlName = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.controller) || "";
|
|
20123
|
-
const controller = localControllers.get(ctrlName) || null;
|
|
20124
|
-
if (controller) gear.setController(controller);
|
|
20125
|
-
const pages = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.pages);
|
|
20126
|
-
if (pages) gear.setPages(pages);
|
|
20127
|
-
const values = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.values);
|
|
20128
|
-
if (gearType === GearType.Text || gearType === GearType.Icon || values) gear.setValues(values ?? "");
|
|
20129
|
-
const defaultValue = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.default);
|
|
20130
|
-
if (defaultValue !== void 0) gear.setDefaultValue(defaultValue);
|
|
20131
|
-
const condition = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.condition);
|
|
20132
|
-
if (condition !== void 0) gear.setCondition(String(condition));
|
|
20133
|
-
const ease = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.ease);
|
|
20134
|
-
if (ease) gear.setEaseType(_parseEaseType$1(ease));
|
|
20135
|
-
const duration = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.duration);
|
|
20136
|
-
if (duration !== void 0) gear.setTweenDuration(parseFloat2(duration));
|
|
20137
|
-
const delay = readXmlAttr(attrs, PROJECT_XML_PROTOCOL.gear.attrs.delay);
|
|
20138
|
-
if (delay !== void 0) gear.setTweenDelay(parseFloat2(delay));
|
|
20139
|
-
obj.addGear(gear);
|
|
20140
|
-
}
|
|
20141
20164
|
//#endregion
|
|
20142
20165
|
//#region ../core/src/io/component-xml-reader.ts
|
|
20143
20166
|
function _parseEaseType(ease) {
|
|
@@ -21130,12 +21153,7 @@ var ProjectReader = class {
|
|
|
21130
21153
|
});
|
|
21131
21154
|
await this._readSettings(ctx);
|
|
21132
21155
|
const assetsPath = fs.join(basePath, "assets");
|
|
21133
|
-
|
|
21134
|
-
try {
|
|
21135
|
-
packageDirs = await fs.readdir(assetsPath);
|
|
21136
|
-
} catch {
|
|
21137
|
-
packageDirs = [];
|
|
21138
|
-
}
|
|
21156
|
+
const packageDirs = await this._readDirectory(ctx, assetsPath, diagnostics !== void 0, true) ?? [];
|
|
21139
21157
|
for (const dirName of packageDirs) {
|
|
21140
21158
|
const pkgXmlPath = fs.join(assetsPath, dirName, "package.xml");
|
|
21141
21159
|
if (!await fs.exists(pkgXmlPath)) continue;
|
|
@@ -21201,21 +21219,10 @@ var ProjectReader = class {
|
|
|
21201
21219
|
}
|
|
21202
21220
|
async _readPackageBranches(ctx, options, collectDiagnostics = false) {
|
|
21203
21221
|
const fs = this._fs;
|
|
21204
|
-
|
|
21205
|
-
try {
|
|
21206
|
-
dirNames = await fs.readdir(ctx.basePath);
|
|
21207
|
-
} catch {
|
|
21208
|
-
return [];
|
|
21209
|
-
}
|
|
21210
|
-
const branchNames = dirNames.filter((dirName) => dirName.startsWith("assets_") && dirName.length > 7).map((dirName) => dirName.slice(7)).sort((a, b) => a.localeCompare(b));
|
|
21222
|
+
const branchNames = (await this._readDirectory(ctx, ctx.basePath, collectDiagnostics) ?? []).filter((dirName) => dirName.startsWith("assets_") && dirName.length > 7).map((dirName) => dirName.slice(7)).sort((a, b) => a.localeCompare(b));
|
|
21211
21223
|
for (const branchName of branchNames) {
|
|
21212
21224
|
const branchAssetsPath = fs.join(ctx.basePath, `assets_${branchName}`);
|
|
21213
|
-
|
|
21214
|
-
try {
|
|
21215
|
-
packageDirs = await fs.readdir(branchAssetsPath);
|
|
21216
|
-
} catch {
|
|
21217
|
-
continue;
|
|
21218
|
-
}
|
|
21225
|
+
const packageDirs = await this._readDirectory(ctx, branchAssetsPath, collectDiagnostics) ?? [];
|
|
21219
21226
|
for (const dirName of packageDirs) {
|
|
21220
21227
|
const pkgXmlPath = fs.join(branchAssetsPath, dirName, "package_branch.xml");
|
|
21221
21228
|
if (!await fs.exists(pkgXmlPath)) continue;
|
|
@@ -21233,7 +21240,25 @@ var ProjectReader = class {
|
|
|
21233
21240
|
}
|
|
21234
21241
|
}
|
|
21235
21242
|
}
|
|
21236
|
-
return branchNames;
|
|
21243
|
+
return branchNames;
|
|
21244
|
+
}
|
|
21245
|
+
async _readDirectory(ctx, path, collectDiagnostics, optional = false, probe = false) {
|
|
21246
|
+
try {
|
|
21247
|
+
return await this._fs.readdir(path);
|
|
21248
|
+
} catch (error) {
|
|
21249
|
+
const failure = error;
|
|
21250
|
+
if (probe && (failure?.code === "ENOTDIR" || failure?.name === "TypeMismatchError")) return null;
|
|
21251
|
+
if (optional && (failure?.code === "ENOENT" || failure?.name === "NotFoundError")) return [];
|
|
21252
|
+
if (!collectDiagnostics) throw error;
|
|
21253
|
+
ctx.addDiagnostic({
|
|
21254
|
+
severity: "error",
|
|
21255
|
+
code: "unreadable_source",
|
|
21256
|
+
path: "packages",
|
|
21257
|
+
message: `Failed to enumerate project directory: ${error instanceof Error ? error.message : String(error)}`,
|
|
21258
|
+
sourcePath: path
|
|
21259
|
+
});
|
|
21260
|
+
return null;
|
|
21261
|
+
}
|
|
21237
21262
|
}
|
|
21238
21263
|
async _readSettings(ctx) {
|
|
21239
21264
|
const fs = this._fs;
|
|
@@ -21355,7 +21380,7 @@ var ProjectReader = class {
|
|
|
21355
21380
|
const resources = desc.resources;
|
|
21356
21381
|
const orderedResources = getOrderedPackageResourceItems(content);
|
|
21357
21382
|
const folderEntries = orderedResources.length > 0 ? orderedResources.filter((entry) => entry.tagName === "folder").map((entry) => entry.attrs) : ensureArray(resources?.folder).map((entry) => getXmlNode(entry)).filter((entry) => !!entry);
|
|
21358
|
-
await this._readPackageFolders(pkg, packageDir, branchName, folderEntries);
|
|
21383
|
+
await this._readPackageFolders(ctx, pkg, packageDir, branchName, folderEntries, validateSyntax);
|
|
21359
21384
|
if (!resources) return;
|
|
21360
21385
|
const createdResources = [];
|
|
21361
21386
|
if (orderedResources.length > 0) {
|
|
@@ -21391,26 +21416,18 @@ var ProjectReader = class {
|
|
|
21391
21416
|
await this._hydratePackageImageSizes(createdResources, packageDir);
|
|
21392
21417
|
if (options.hydrateResourceBytes) await this._hydratePackageResourceBytes(ctx, createdResources, packageDir, pkg.getId());
|
|
21393
21418
|
}
|
|
21394
|
-
async _readPackageFolders(pkg, packageDir, branch, metadataEntries) {
|
|
21419
|
+
async _readPackageFolders(ctx, pkg, packageDir, branch, metadataEntries, collectDiagnostics) {
|
|
21395
21420
|
const metadata = new Map(metadataEntries.map((attrs) => {
|
|
21396
21421
|
return [normalizeResourceFolderPath(`${readXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageResourceFolder.attrs.path) ?? "/"}/${readXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageResourceFolder.attrs.name) ?? ""}`), attrs];
|
|
21397
21422
|
}));
|
|
21398
21423
|
const folders = pkg.listResourceFolders();
|
|
21399
21424
|
const visit = async (directory, parentPath, entries) => {
|
|
21400
|
-
|
|
21401
|
-
if (!names) try {
|
|
21402
|
-
names = await this._fs.readdir(directory);
|
|
21403
|
-
} catch {
|
|
21404
|
-
return;
|
|
21405
|
-
}
|
|
21425
|
+
const names = entries ?? await this._readDirectory(ctx, directory, collectDiagnostics) ?? [];
|
|
21406
21426
|
for (const name of [...names].sort((left, right) => left.localeCompare(right))) {
|
|
21407
21427
|
const childDirectory = this._fs.join(directory, name);
|
|
21408
|
-
|
|
21409
|
-
|
|
21410
|
-
|
|
21411
|
-
} catch {
|
|
21412
|
-
continue;
|
|
21413
|
-
}
|
|
21428
|
+
if (this._fs.stat && !(await this._fs.stat(childDirectory)).isDirectory()) continue;
|
|
21429
|
+
const childEntries = await this._readDirectory(ctx, childDirectory, collectDiagnostics, false, !this._fs.stat);
|
|
21430
|
+
if (childEntries === null) continue;
|
|
21414
21431
|
const path = normalizeResourceFolderPath(`${parentPath}/${name}`);
|
|
21415
21432
|
const attrs = metadata.get(path);
|
|
21416
21433
|
folders.push({
|
|
@@ -22038,7 +22055,7 @@ function writeCommonDisplayState(target, object, protocol) {
|
|
|
22038
22055
|
if (specs.aspect && object.getAspect?.()) writeXmlAttr(target, specs.aspect, "true");
|
|
22039
22056
|
const pivotX = object.getPivotX?.() ?? 0;
|
|
22040
22057
|
const pivotY = object.getPivotY?.() ?? 0;
|
|
22041
|
-
if (specs.pivot && (pivotX !== 0 || pivotY !== 0)) {
|
|
22058
|
+
if (specs.pivot && (pivotX !== 0 || pivotY !== 0 || object.getPivotAsAnchor?.())) {
|
|
22042
22059
|
writeXmlAttr(target, specs.pivot, `${pivotX},${pivotY}`);
|
|
22043
22060
|
if (specs.anchor && object.getPivotAsAnchor?.()) writeXmlAttr(target, specs.anchor, "true");
|
|
22044
22061
|
}
|
|
@@ -22720,7 +22737,7 @@ async function writeComponent(fs, comp, pkgDir, sourceRelativePath) {
|
|
|
22720
22737
|
const [w, h] = [typedComp.getWidth?.() ?? 0, typedComp.getHeight?.() ?? 0];
|
|
22721
22738
|
if (w || h) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.size, formatProjectInt32List([w, h], "component size"));
|
|
22722
22739
|
const [pivotX, pivotY] = [typedComp.getPivotX?.() ?? 0, typedComp.getPivotY?.() ?? 0];
|
|
22723
|
-
if (pivotX !== 0 || pivotY !== 0) {
|
|
22740
|
+
if (pivotX !== 0 || pivotY !== 0 || typedComp.getPivotAsAnchor?.()) {
|
|
22724
22741
|
writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.pivot, `${pivotX},${pivotY}`);
|
|
22725
22742
|
if (typedComp.getPivotAsAnchor?.()) writeXmlAttr(compAttrs, PROJECT_XML_PROTOCOL.componentRoot.attrs.anchor, "true");
|
|
22726
22743
|
}
|
|
@@ -22984,9 +23001,7 @@ function serializeTransition(trans) {
|
|
|
22984
23001
|
}
|
|
22985
23002
|
//#endregion
|
|
22986
23003
|
//#region ../core/src/io/project-writer.ts
|
|
22987
|
-
|
|
22988
|
-
return resource.getExtras?.()?._suppressPackageSize !== true;
|
|
22989
|
-
}
|
|
23004
|
+
const imageWriteHints = /* @__PURE__ */ new WeakMap();
|
|
22990
23005
|
function compareResourceIdSequence(a, b) {
|
|
22991
23006
|
const left = a.toLowerCase();
|
|
22992
23007
|
const right = b.toLowerCase();
|
|
@@ -22995,6 +23010,15 @@ function compareResourceIdSequence(a, b) {
|
|
|
22995
23010
|
}
|
|
22996
23011
|
var ProjectWriter = class {
|
|
22997
23012
|
_fs;
|
|
23013
|
+
/** Replaces hints for every subsequent write of this image, including another Writer instance. */
|
|
23014
|
+
static setImageWriteHints(resource, hints) {
|
|
23015
|
+
if (hints.packageOrder && (typeof hints.packageOrder.afterId !== "string" || !Number.isFinite(hints.packageOrder.weight))) throw new TypeError("Image package order requires a string afterId and finite weight.");
|
|
23016
|
+
if (hints.omitPackageSize === true || hints.packageOrder) imageWriteHints.set(resource, {
|
|
23017
|
+
omitPackageSize: hints.omitPackageSize,
|
|
23018
|
+
packageOrder: hints.packageOrder && { ...hints.packageOrder }
|
|
23019
|
+
});
|
|
23020
|
+
else imageWriteHints.delete(resource);
|
|
23021
|
+
}
|
|
22998
23022
|
constructor(fs) {
|
|
22999
23023
|
this._fs = fs;
|
|
23000
23024
|
}
|
|
@@ -23169,9 +23193,17 @@ var ProjectWriter = class {
|
|
|
23169
23193
|
await fs.writeFileRaw(targetPath, new Uint8Array(data));
|
|
23170
23194
|
}
|
|
23171
23195
|
}
|
|
23196
|
+
async _stalePaths(currentPaths, stalePaths) {
|
|
23197
|
+
const fs = this._fs;
|
|
23198
|
+
const identity = async (path) => fs.resolvePath && await fs.exists(path) ? fs.resolvePath(path) : path;
|
|
23199
|
+
const current = new Set(await Promise.all([...currentPaths].map(identity)));
|
|
23200
|
+
const candidates = [];
|
|
23201
|
+
for (const path of stalePaths) if (!current.has(await identity(path))) candidates.push(path);
|
|
23202
|
+
return candidates;
|
|
23203
|
+
}
|
|
23172
23204
|
async _removeStaleSourceFiles(currentSourceFilePaths, staleSourceFilePaths) {
|
|
23173
23205
|
const fs = this._fs;
|
|
23174
|
-
const candidates =
|
|
23206
|
+
const candidates = await this._stalePaths(currentSourceFilePaths, staleSourceFilePaths);
|
|
23175
23207
|
if (candidates.length === 0) return;
|
|
23176
23208
|
if (!fs.unlink) throw new Error("Project source cleanup requires a FileSystem.unlink() implementation.");
|
|
23177
23209
|
for (const filePath of candidates) {
|
|
@@ -23180,7 +23212,7 @@ var ProjectWriter = class {
|
|
|
23180
23212
|
}
|
|
23181
23213
|
}
|
|
23182
23214
|
async _removeStaleResourceFolders(currentResourceFolderPaths, staleResourceFolderPaths) {
|
|
23183
|
-
const candidates =
|
|
23215
|
+
const candidates = (await this._stalePaths(currentResourceFolderPaths, staleResourceFolderPaths)).sort((left, right) => right.length - left.length);
|
|
23184
23216
|
if (candidates.length === 0) return;
|
|
23185
23217
|
if (!this._fs.rmdir) throw new Error("Project resource folder cleanup requires a FileSystem.rmdir() implementation.");
|
|
23186
23218
|
for (const folderPath of candidates) {
|
|
@@ -23189,7 +23221,7 @@ var ProjectWriter = class {
|
|
|
23189
23221
|
}
|
|
23190
23222
|
}
|
|
23191
23223
|
async _removeStaleBranchDirectories(currentBranchDirectoryPaths, staleBranchDirectoryPaths) {
|
|
23192
|
-
const candidates =
|
|
23224
|
+
const candidates = (await this._stalePaths(currentBranchDirectoryPaths, staleBranchDirectoryPaths)).sort((left, right) => right.length - left.length);
|
|
23193
23225
|
for (const directoryPath of candidates) {
|
|
23194
23226
|
if (!await this._fs.exists(directoryPath)) continue;
|
|
23195
23227
|
await this._fs.rmdir(directoryPath);
|
|
@@ -23216,6 +23248,7 @@ var ProjectWriter = class {
|
|
|
23216
23248
|
...foldersByBranch.keys()
|
|
23217
23249
|
])) {
|
|
23218
23250
|
const resources = resourcesByBranch.get(branchName) ?? [];
|
|
23251
|
+
this._orderedPackageResources(resources, pkg.getExtras()._preservePackageResourceOrder === true);
|
|
23219
23252
|
if (branchName) this._assertSafePathSegment(branchName, "branch name");
|
|
23220
23253
|
const targets = new Map([[branchName ? "package_branch.xml" : "package.xml", "package descriptor"]]);
|
|
23221
23254
|
for (const folder of foldersByBranch.get(branchName) ?? []) {
|
|
@@ -23326,33 +23359,35 @@ var ProjectWriter = class {
|
|
|
23326
23359
|
}
|
|
23327
23360
|
_orderedPackageResources(resources, preserveResourceOrder) {
|
|
23328
23361
|
const original = preserveResourceOrder ? [...resources] : [...resources].sort((a, b) => compareResourceIdSequence(a.getId?.() ?? "", b.getId?.() ?? ""));
|
|
23329
|
-
const
|
|
23362
|
+
const orderOf = (resource) => resource.propertyType === "ImageResource" ? imageWriteHints.get(resource)?.packageOrder : void 0;
|
|
23363
|
+
const anchors = new Set(original.filter((resource) => !orderOf(resource)).map((resource) => resource.getId()));
|
|
23364
|
+
const resourcesAfter = /* @__PURE__ */ new Map();
|
|
23330
23365
|
const trailing = [];
|
|
23331
23366
|
for (const resource of original) {
|
|
23332
|
-
const
|
|
23333
|
-
|
|
23334
|
-
const
|
|
23367
|
+
const order = orderOf(resource);
|
|
23368
|
+
if (!order) continue;
|
|
23369
|
+
const { afterId, weight } = order;
|
|
23335
23370
|
if (afterId) {
|
|
23336
|
-
|
|
23371
|
+
if (!anchors.has(afterId)) throw new Error(`Invalid image package order anchor "${afterId}" for "${resource.getId()}".`);
|
|
23372
|
+
const bucket = resourcesAfter.get(afterId) ?? [];
|
|
23337
23373
|
bucket.push({
|
|
23338
23374
|
resource,
|
|
23339
23375
|
weight
|
|
23340
23376
|
});
|
|
23341
|
-
|
|
23377
|
+
resourcesAfter.set(afterId, bucket);
|
|
23342
23378
|
continue;
|
|
23343
23379
|
}
|
|
23344
|
-
|
|
23380
|
+
trailing.push({
|
|
23345
23381
|
resource,
|
|
23346
23382
|
weight
|
|
23347
23383
|
});
|
|
23348
23384
|
}
|
|
23349
23385
|
const result = [];
|
|
23350
23386
|
for (const resource of original) {
|
|
23351
|
-
|
|
23352
|
-
if (extras._packageOrderAfterId || extras._syntheticFontGlyph === true || extras._syntheticFontTexture === true) continue;
|
|
23387
|
+
if (orderOf(resource)) continue;
|
|
23353
23388
|
result.push(resource);
|
|
23354
23389
|
const id = resource.getId?.() ?? "";
|
|
23355
|
-
const bucket =
|
|
23390
|
+
const bucket = resourcesAfter.get(id) ?? [];
|
|
23356
23391
|
bucket.sort((a, b) => a.weight - b.weight || compareResourceIdSequence(a.resource.getId?.() ?? "", b.resource.getId?.() ?? ""));
|
|
23357
23392
|
for (const entry of bucket) result.push(entry.resource);
|
|
23358
23393
|
}
|
|
@@ -23391,7 +23426,7 @@ var ProjectWriter = class {
|
|
|
23391
23426
|
const g = imgRes.getScale9Grid?.();
|
|
23392
23427
|
if (g) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageImageResource.attrs.scale9grid, `${g[0]},${g[1]},${g[2]},${g[3]}`);
|
|
23393
23428
|
} else if (scaleOpt === 2) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageImageResource.attrs.scale, "tile");
|
|
23394
|
-
if (
|
|
23429
|
+
if (imageWriteHints.get(res)?.omitPackageSize !== true) {
|
|
23395
23430
|
const width = imgRes.getWidth?.() ?? 0;
|
|
23396
23431
|
if (width !== 0) writeXmlAttr(attrs, PROJECT_XML_PROTOCOL.packageImageResource.attrs.width, String(width));
|
|
23397
23432
|
const height = imgRes.getHeight?.() ?? 0;
|
|
@@ -23470,7 +23505,7 @@ var ProjectWriter = class {
|
|
|
23470
23505
|
return name;
|
|
23471
23506
|
}
|
|
23472
23507
|
_projectTypeName(type) {
|
|
23473
|
-
|
|
23508
|
+
const names = {
|
|
23474
23509
|
0: "Unity",
|
|
23475
23510
|
1: "Flash",
|
|
23476
23511
|
2: "Starling",
|
|
@@ -23480,8 +23515,13 @@ var ProjectWriter = class {
|
|
|
23480
23515
|
6: "Haxe",
|
|
23481
23516
|
7: "Pixi",
|
|
23482
23517
|
8: "LibGDX",
|
|
23483
|
-
9: "Unreal"
|
|
23484
|
-
|
|
23518
|
+
9: "Unreal",
|
|
23519
|
+
10: "CryEngine",
|
|
23520
|
+
11: "MonoGame",
|
|
23521
|
+
12: "Vision"
|
|
23522
|
+
};
|
|
23523
|
+
if (names[type] === void 0) throw new Error(`Unsupported project type "${type}".`);
|
|
23524
|
+
return names[type];
|
|
23485
23525
|
}
|
|
23486
23526
|
};
|
|
23487
23527
|
//#endregion
|
|
@@ -23507,6 +23547,7 @@ var ByteBuffer = class ByteBuffer {
|
|
|
23507
23547
|
return this._pos;
|
|
23508
23548
|
}
|
|
23509
23549
|
set pos(v) {
|
|
23550
|
+
if (!Number.isInteger(v) || v < 0 || v > this.byteLength) throw new RangeError("Binary buffer position is out of bounds.");
|
|
23510
23551
|
this._pos = v;
|
|
23511
23552
|
}
|
|
23512
23553
|
get buffer() {
|
|
@@ -23519,7 +23560,10 @@ var ByteBuffer = class ByteBuffer {
|
|
|
23519
23560
|
return this._view.byteLength;
|
|
23520
23561
|
}
|
|
23521
23562
|
skip(count) {
|
|
23522
|
-
this._pos
|
|
23563
|
+
this.pos = this._pos + count;
|
|
23564
|
+
}
|
|
23565
|
+
assertAvailable(count) {
|
|
23566
|
+
if (!Number.isInteger(count) || count < 0 || count > this.byteLength - this._pos) throw new RangeError("Binary buffer read is out of bounds.");
|
|
23523
23567
|
}
|
|
23524
23568
|
getUint8() {
|
|
23525
23569
|
return this._view.getUint8(this._pos++);
|
|
@@ -23567,12 +23611,11 @@ var ByteBuffer = class ByteBuffer {
|
|
|
23567
23611
|
/** Read a uint16-prefixed UTF-8 string. */
|
|
23568
23612
|
readUTFString() {
|
|
23569
23613
|
const len = this.getUint16();
|
|
23570
|
-
|
|
23571
|
-
this._pos += len;
|
|
23572
|
-
return new TextDecoder("utf-8").decode(bytes);
|
|
23614
|
+
return this.getCustomString(len);
|
|
23573
23615
|
}
|
|
23574
23616
|
/** Read a raw UTF-8 string of exactly `len` bytes (no length prefix). */
|
|
23575
23617
|
getCustomString(len) {
|
|
23618
|
+
this.assertAvailable(len);
|
|
23576
23619
|
const bytes = new Uint8Array(this._view.buffer, this._view.byteOffset + this._pos, len);
|
|
23577
23620
|
this._pos += len;
|
|
23578
23621
|
return new TextDecoder("utf-8").decode(bytes);
|
|
@@ -23585,7 +23628,8 @@ var ByteBuffer = class ByteBuffer {
|
|
|
23585
23628
|
const index = this.getUint16();
|
|
23586
23629
|
if (index === 65534) return null;
|
|
23587
23630
|
if (index === 65533) return "";
|
|
23588
|
-
|
|
23631
|
+
if (index >= this.stringTable.length) throw new RangeError(`Invalid string table index ${index}.`);
|
|
23632
|
+
return this.stringTable[index];
|
|
23589
23633
|
}
|
|
23590
23634
|
readSArray(cnt) {
|
|
23591
23635
|
const result = [];
|
|
@@ -23593,8 +23637,8 @@ var ByteBuffer = class ByteBuffer {
|
|
|
23593
23637
|
return result;
|
|
23594
23638
|
}
|
|
23595
23639
|
/** Read a uint32-prefixed sub-buffer slice (shares the same underlying ArrayBuffer). */
|
|
23596
|
-
readBuffer() {
|
|
23597
|
-
|
|
23640
|
+
readBuffer(count = this.getUint32()) {
|
|
23641
|
+
this.assertAvailable(count);
|
|
23598
23642
|
const ba = new ByteBuffer(this._view.buffer, this._view.byteOffset + this._pos, count);
|
|
23599
23643
|
this._pos += count;
|
|
23600
23644
|
ba.stringTable = this.stringTable;
|
|
@@ -23613,19 +23657,20 @@ var ByteBuffer = class ByteBuffer {
|
|
|
23613
23657
|
*/
|
|
23614
23658
|
seek(indexTablePos, blockIndex) {
|
|
23615
23659
|
const saved = this._pos;
|
|
23616
|
-
|
|
23660
|
+
if (!Number.isInteger(blockIndex) || blockIndex < 0) throw new RangeError("Invalid block index.");
|
|
23661
|
+
this.pos = indexTablePos;
|
|
23617
23662
|
if (blockIndex < this.getUint8()) {
|
|
23618
23663
|
const useShort = this.getUint8() === 1;
|
|
23619
23664
|
let newPos;
|
|
23620
23665
|
if (useShort) {
|
|
23621
|
-
this.
|
|
23666
|
+
this.skip(2 * blockIndex);
|
|
23622
23667
|
newPos = this.getUint16();
|
|
23623
23668
|
} else {
|
|
23624
|
-
this.
|
|
23669
|
+
this.skip(4 * blockIndex);
|
|
23625
23670
|
newPos = this.getUint32();
|
|
23626
23671
|
}
|
|
23627
23672
|
if (newPos > 0) {
|
|
23628
|
-
this.
|
|
23673
|
+
this.pos = indexTablePos + newPos;
|
|
23629
23674
|
return true;
|
|
23630
23675
|
}
|
|
23631
23676
|
}
|
|
@@ -23686,9 +23731,7 @@ function decodeComponentControllers(doc, resource, buf) {
|
|
|
23686
23731
|
for (let controllerIndex = 0; controllerIndex < controllerCount && remainingBytes(buf) >= 2; controllerIndex += 1) {
|
|
23687
23732
|
const chunkSize = buf.getInt16();
|
|
23688
23733
|
const nextPos = buf.pos + chunkSize;
|
|
23689
|
-
const controllerBuf =
|
|
23690
|
-
controllerBuf.stringTable = buf.stringTable;
|
|
23691
|
-
controllerBuf.version = buf.version;
|
|
23734
|
+
const controllerBuf = buf.readBuffer(chunkSize);
|
|
23692
23735
|
const controller = doc.createController(`controller${controllerIndex}`);
|
|
23693
23736
|
if (controllerBuf.seek(0, 0) && remainingBytes(controllerBuf) >= 2) controller.setName(controllerBuf.readS() ?? `controller${controllerIndex}`).setAutoRadioGroupDepth(remainingBytes(controllerBuf) >= 1 ? controllerBuf.readBool() : false);
|
|
23694
23737
|
if (controllerBuf.seek(0, 1) && remainingBytes(controllerBuf) >= 2) {
|
|
@@ -23736,9 +23779,7 @@ function decodeComponentControllers(doc, resource, buf) {
|
|
|
23736
23779
|
for (let actionIndex = 0; actionIndex < actionCount && remainingBytes(controllerBuf) >= 2; actionIndex += 1) {
|
|
23737
23780
|
const actionSize = controllerBuf.getInt16();
|
|
23738
23781
|
const actionNextPos = controllerBuf.pos + actionSize;
|
|
23739
|
-
const actionBuf =
|
|
23740
|
-
actionBuf.stringTable = controllerBuf.stringTable;
|
|
23741
|
-
actionBuf.version = controllerBuf.version;
|
|
23782
|
+
const actionBuf = controllerBuf.readBuffer(actionSize);
|
|
23742
23783
|
const action = doc.createControllerAction(`${controller.getName()}_action${actionIndex}`);
|
|
23743
23784
|
if (remainingBytes(actionBuf) >= 1) {
|
|
23744
23785
|
const actionType = actionBuf.getUint8();
|
|
@@ -23957,9 +23998,7 @@ function decodeComponentTransitions(doc, resource, buf) {
|
|
|
23957
23998
|
for (let itemIndex = 0; itemIndex < itemCount && remainingBytes(buf) >= 2; itemIndex += 1) {
|
|
23958
23999
|
const itemSize = buf.getInt16();
|
|
23959
24000
|
const itemNextPos = buf.pos + itemSize;
|
|
23960
|
-
const itemBuf =
|
|
23961
|
-
itemBuf.stringTable = buf.stringTable;
|
|
23962
|
-
itemBuf.version = buf.version;
|
|
24001
|
+
const itemBuf = buf.readBuffer(itemSize);
|
|
23963
24002
|
const item = doc.createTransitionItem(`${transition.getName()}_${itemIndex}`);
|
|
23964
24003
|
if (itemBuf.seek(0, 0) && remainingBytes(itemBuf) >= 10) {
|
|
23965
24004
|
const actionType = itemBuf.getUint8();
|
|
@@ -24524,9 +24563,7 @@ function decodeComponentDisplayList(doc, resource, buf) {
|
|
|
24524
24563
|
for (let index = 0; index < childCount && remainingBytes(buf) >= 2; index += 1) {
|
|
24525
24564
|
const chunkSize = buf.getInt16();
|
|
24526
24565
|
const nextPos = buf.pos + chunkSize;
|
|
24527
|
-
const childBuf =
|
|
24528
|
-
childBuf.stringTable = buf.stringTable;
|
|
24529
|
-
childBuf.version = buf.version;
|
|
24566
|
+
const childBuf = buf.readBuffer(chunkSize);
|
|
24530
24567
|
const child = decodeChildBlock0(doc, childBuf);
|
|
24531
24568
|
if (child) {
|
|
24532
24569
|
const groupIndex = decodeChildBlock1(child, childBuf);
|
|
@@ -25011,8 +25048,8 @@ var BinaryReader = class {
|
|
|
25011
25048
|
const pixelWidth = buf.getInt32();
|
|
25012
25049
|
const scaleDenominator = buf.getUint8();
|
|
25013
25050
|
const byteLength = buf.getInt32();
|
|
25014
|
-
const
|
|
25015
|
-
|
|
25051
|
+
const pixelBuffer = buf.readBuffer(byteLength);
|
|
25052
|
+
const pixels = new Uint8Array(pixelBuffer.buffer, pixelBuffer.byteOffset, pixelBuffer.byteLength).slice();
|
|
25016
25053
|
if (itemId) pixelHitTests.set(itemId, {
|
|
25017
25054
|
itemId,
|
|
25018
25055
|
pixelWidth,
|
|
@@ -25373,7 +25410,7 @@ function _writeComponentHeader(buf, comp) {
|
|
|
25373
25410
|
}
|
|
25374
25411
|
const pivotX = comp.getPivotX?.() ?? 0;
|
|
25375
25412
|
const pivotY = comp.getPivotY?.() ?? 0;
|
|
25376
|
-
const hasPivot = pivotX !== 0 || pivotY !== 0;
|
|
25413
|
+
const hasPivot = pivotX !== 0 || pivotY !== 0 || comp.getPivotAsAnchor();
|
|
25377
25414
|
buf.writeBool(hasPivot);
|
|
25378
25415
|
if (hasPivot) {
|
|
25379
25416
|
buf.writeFloat32(pivotX);
|
|
@@ -26098,7 +26135,7 @@ function _writeDisplayList(buf, comp, doc, pkg, version) {
|
|
|
26098
26135
|
}
|
|
26099
26136
|
const px = child.getPivotX?.() ?? 0;
|
|
26100
26137
|
const py = child.getPivotY?.() ?? 0;
|
|
26101
|
-
const hasPivot = px !== 0 || py !== 0;
|
|
26138
|
+
const hasPivot = px !== 0 || py !== 0 || (child.getPivotAsAnchor?.() ?? false);
|
|
26102
26139
|
buf.writeBool(hasPivot);
|
|
26103
26140
|
if (hasPivot) {
|
|
26104
26141
|
buf.writeFloat32(px);
|
|
@@ -27789,7 +27826,6 @@ function collectPackagePublishContext(pkg, options) {
|
|
|
27789
27826
|
const resourceMap = new Map(resources.map((resource) => [resource.getId(), resource]));
|
|
27790
27827
|
const referencedIds = collectPackageResourceReferences(pkg).localResourceIds;
|
|
27791
27828
|
const pixelHitTestImageIds = /* @__PURE__ */ new Set();
|
|
27792
|
-
const spriteItemIds = /* @__PURE__ */ new Set();
|
|
27793
27829
|
const collectExportedResourceIds = (sourceResources, sourcePublishedResourceIds) => {
|
|
27794
27830
|
const exportedResourceIds = new Set(sourcePublishedResourceIds);
|
|
27795
27831
|
const resourcesById = new Map(sourceResources.map((resource) => [resource.getId(), resource]));
|
|
@@ -27814,7 +27850,6 @@ function collectPackagePublishContext(pkg, options) {
|
|
|
27814
27850
|
}
|
|
27815
27851
|
return exportedResourceIds;
|
|
27816
27852
|
};
|
|
27817
|
-
for (const atlas of pkg.listAtlases()) for (const sprite of atlas.listSprites()) if (!excludedResourceIds.has(sprite.getItemId())) spriteItemIds.add(sprite.getItemId());
|
|
27818
27853
|
for (const resource of resources) {
|
|
27819
27854
|
if (!isComponentResource(resource)) continue;
|
|
27820
27855
|
const component = resource;
|
|
@@ -27829,7 +27864,7 @@ function collectPackagePublishContext(pkg, options) {
|
|
|
27829
27864
|
}
|
|
27830
27865
|
}
|
|
27831
27866
|
}
|
|
27832
|
-
const publishedResourceIds = new Set(
|
|
27867
|
+
const publishedResourceIds = /* @__PURE__ */ new Set();
|
|
27833
27868
|
for (const resource of resources) {
|
|
27834
27869
|
const resourceId = resource.getId();
|
|
27835
27870
|
if (!resourceId || excludedResourceIds.has(resourceId)) continue;
|
|
@@ -27838,7 +27873,7 @@ function collectPackagePublishContext(pkg, options) {
|
|
|
27838
27873
|
continue;
|
|
27839
27874
|
}
|
|
27840
27875
|
if (isImageResource(resource)) {
|
|
27841
|
-
if (resource.getExported() || referencedIds.has(resourceId) ||
|
|
27876
|
+
if (resource.getExported() || referencedIds.has(resourceId) || pixelHitTestImageIds.has(resourceId)) publishedResourceIds.add(resourceId);
|
|
27842
27877
|
continue;
|
|
27843
27878
|
}
|
|
27844
27879
|
if (isMovieClipResource(resource) || isSoundResource(resource)) {
|
|
@@ -28386,9 +28421,6 @@ async function collectFontTexture(doc, fontRes, pkg, options) {
|
|
|
28386
28421
|
} catch {}
|
|
28387
28422
|
}
|
|
28388
28423
|
}
|
|
28389
|
-
function isPackableResource(resource) {
|
|
28390
|
-
return isImageResource(resource) || isMovieClipResource(resource) || isFontResource(resource) && !resource.isExternalFont();
|
|
28391
|
-
}
|
|
28392
28424
|
function isResolvedBuffer(value) {
|
|
28393
28425
|
return typeof value === "object" && value !== null && "data" in value && "info" in value;
|
|
28394
28426
|
}
|
|
@@ -29749,10 +29781,6 @@ function atlas(_options = {}) {
|
|
|
29749
29781
|
const skeletonDependencyImageIds = getSelectedSkeletonDependencyImageIds(allResources);
|
|
29750
29782
|
const orderedResources = await resolveEditorCompatibleResourceOrder(pkg, allResources);
|
|
29751
29783
|
const orderedAllResources = sortResourcesByOrder(allResources, new Map(orderedResources.map((resource, index) => [resource.getId(), index])), new Map(allResources.map((resource, index) => [resource.getId(), index])));
|
|
29752
|
-
if (!allResources.some((resource) => {
|
|
29753
|
-
if (isImageResource(resource) && skeletonDependencyImageIds.has(resource.getId())) return false;
|
|
29754
|
-
return isPackableResource(resource);
|
|
29755
|
-
})) continue;
|
|
29756
29784
|
const inputs = [];
|
|
29757
29785
|
const referencedIds = collectPackageResourceReferences(pkg).localResourceIds;
|
|
29758
29786
|
for (const res of orderedAllResources) {
|
|
@@ -29771,17 +29799,29 @@ function atlas(_options = {}) {
|
|
|
29771
29799
|
if (selectedPublishIds.size === 0 && !res.getExported() && referencedIds.size > 0 && !referencedIds.has(resId)) continue;
|
|
29772
29800
|
await collectMovieClipFrames(doc, res, pkg, inputs, encoder, options, logger);
|
|
29773
29801
|
}
|
|
29774
|
-
if (inputs.length
|
|
29775
|
-
|
|
29776
|
-
|
|
29777
|
-
|
|
29778
|
-
|
|
29779
|
-
|
|
29780
|
-
|
|
29781
|
-
|
|
29782
|
-
|
|
29783
|
-
|
|
29784
|
-
|
|
29802
|
+
if (inputs.length > 0 && options.strictOutput && (!encoder || !options.basePath || !options.outputPath)) throw new Error(`atlas: Package "${pkg.getName()}" requires encoder, basePath, and outputPath for complete raster output.`);
|
|
29803
|
+
const previousAtlases = pkg.listAtlases();
|
|
29804
|
+
try {
|
|
29805
|
+
await emitAtlasInputs({
|
|
29806
|
+
doc,
|
|
29807
|
+
pkg,
|
|
29808
|
+
allResources,
|
|
29809
|
+
inputs,
|
|
29810
|
+
options,
|
|
29811
|
+
encoder,
|
|
29812
|
+
logger
|
|
29813
|
+
});
|
|
29814
|
+
} catch (error) {
|
|
29815
|
+
for (const atlas of pkg.listAtlases().filter((item) => !previousAtlases.includes(item))) {
|
|
29816
|
+
for (const sprite of atlas.listSprites()) sprite.dispose();
|
|
29817
|
+
atlas.dispose();
|
|
29818
|
+
}
|
|
29819
|
+
throw error;
|
|
29820
|
+
}
|
|
29821
|
+
for (const atlas of previousAtlases) {
|
|
29822
|
+
for (const sprite of atlas.listSprites()) sprite.dispose();
|
|
29823
|
+
atlas.dispose();
|
|
29824
|
+
}
|
|
29785
29825
|
}
|
|
29786
29826
|
});
|
|
29787
29827
|
}
|
|
@@ -31422,11 +31462,233 @@ async function commitRestoreOutput(stagingDir, outputDir, fs) {
|
|
|
31422
31462
|
}
|
|
31423
31463
|
}
|
|
31424
31464
|
//#endregion
|
|
31425
|
-
//#region ../functions/src/restore-internals/
|
|
31465
|
+
//#region ../functions/src/restore-internals/resource-paths.ts
|
|
31466
|
+
function assertSafeRestoreSegment(value, label) {
|
|
31467
|
+
if (!value || value === "." || value === ".." || value.includes("\0") || /[\\/:]/u.test(value)) throw new Error(`restore: Invalid ${label} "${value}".`);
|
|
31468
|
+
}
|
|
31426
31469
|
function resourceFileName$1(resource) {
|
|
31427
|
-
return resource.getFileName
|
|
31470
|
+
return ("getFileName" in resource ? resource.getFileName() : "getFile" in resource ? resource.getFile() : "") || resource.getName();
|
|
31471
|
+
}
|
|
31472
|
+
function resourcePublishedFileName(resource) {
|
|
31473
|
+
const publishedFile = (resource.getExtras() ?? {})._publishedFile;
|
|
31474
|
+
return typeof publishedFile === "string" ? publishedFile : resourceFileName$1(resource);
|
|
31475
|
+
}
|
|
31476
|
+
function normalizePublishedLooseResourceFileName(resource, fileName) {
|
|
31477
|
+
if (resource.propertyType === "MiscResource" && /\.atlas\.txt$/i.test(fileName)) return fileName.replace(/\.atlas\.txt$/i, ".atlas");
|
|
31478
|
+
if (resource.propertyType === "SpineResource" && /\.skel\.bytes$/i.test(fileName)) return fileName.replace(/\.skel\.bytes$/i, ".skel");
|
|
31479
|
+
return fileName;
|
|
31480
|
+
}
|
|
31481
|
+
function replaceLooseResourceBaseName(resource, fileName) {
|
|
31482
|
+
const normalized = normalizePublishedLooseResourceFileName(resource, fileName);
|
|
31483
|
+
const displayName = resource.getName() ?? "";
|
|
31484
|
+
if (!displayName) return normalized;
|
|
31485
|
+
const baseName = fileBaseName(normalized);
|
|
31486
|
+
const ext = /((?:\.[^.\\/]+)+)$/u.exec(baseName)?.[1] ?? "";
|
|
31487
|
+
const currentBaseName = ext ? baseName.slice(0, -ext.length) : baseName;
|
|
31488
|
+
const resourceId = resource.getId() ?? "";
|
|
31489
|
+
if (!resourceId || currentBaseName.toLowerCase() !== resourceId.toLowerCase()) return normalized;
|
|
31490
|
+
return `${normalized.slice(0, normalized.length - baseName.length)}${displayName}${ext}`;
|
|
31491
|
+
}
|
|
31492
|
+
function fileBaseName(fileName) {
|
|
31493
|
+
return fileName.split(/[\\/]/).pop() ?? fileName;
|
|
31428
31494
|
}
|
|
31429
31495
|
function stripExtension$1(fileName) {
|
|
31496
|
+
return fileBaseName(fileName).replace(/\.[^.]+$/u, "");
|
|
31497
|
+
}
|
|
31498
|
+
function resourceInstanceFileName(resource) {
|
|
31499
|
+
const fileName = (resource.propertyType === "Component" ? `${resource.getName() ?? resource.getId() ?? "component"}.xml` : resourceFileName$1(resource)).replace(/\\/g, "/").replace(/^\/+/, "");
|
|
31500
|
+
if (!fileName) return "";
|
|
31501
|
+
if (fileName.includes("/")) return fileName;
|
|
31502
|
+
const virtualPath = normalizeRestoreResourcePath(resource.getPath());
|
|
31503
|
+
return virtualPath ? `${virtualPath}/${fileName}` : fileName;
|
|
31504
|
+
}
|
|
31505
|
+
function sameVirtualPath(a, b) {
|
|
31506
|
+
return normalizeRestoreResourcePath(a.getPath()) === normalizeRestoreResourcePath(b.getPath());
|
|
31507
|
+
}
|
|
31508
|
+
function imageFileName(resource) {
|
|
31509
|
+
const current = resource.getFileName() ?? "";
|
|
31510
|
+
if (current) return current;
|
|
31511
|
+
const name = resource.getName() ?? resource.getId() ?? "image";
|
|
31512
|
+
const fileName = /\.[a-z0-9]+$/i.test(name) ? name : `${name}.png`;
|
|
31513
|
+
resource.setFileName(fileName);
|
|
31514
|
+
return fileName;
|
|
31515
|
+
}
|
|
31516
|
+
function assertDocumentPaths(doc) {
|
|
31517
|
+
for (const pkg of doc.getRoot().listPackages()) {
|
|
31518
|
+
assertSafeRestoreSegment(pkg.getName(), "package name");
|
|
31519
|
+
assertSafeRestoreSegment(pkg.getPublishName() || pkg.getName(), "package publish name");
|
|
31520
|
+
for (const resource of pkg.listResources()) {
|
|
31521
|
+
normalizeRestoreResourcePath(resource.getPath());
|
|
31522
|
+
const branch = resource.getBranch() ?? "";
|
|
31523
|
+
if (branch) assertSafeRestoreSegment(branch, "branch name");
|
|
31524
|
+
const fileName = resourceFileName$1(resource);
|
|
31525
|
+
if (fileName) assertSafeRestoreSegment(fileName, "resource file name");
|
|
31526
|
+
const publishedFileName = resourcePublishedFileName(resource);
|
|
31527
|
+
if (publishedFileName) assertSafeRestoreSegment(publishedFileName, "published resource file name");
|
|
31528
|
+
}
|
|
31529
|
+
}
|
|
31530
|
+
}
|
|
31531
|
+
function sourceFileCandidates(pkg, fileName, outputFileName = fileName) {
|
|
31532
|
+
const publishName = pkg.getPublishName() || pkg.getName();
|
|
31533
|
+
assertSafeRestoreSegment(publishName, "package publish name");
|
|
31534
|
+
assertSafeRestoreSegment(fileName, "published source file name");
|
|
31535
|
+
assertSafeRestoreSegment(outputFileName, "published source file name");
|
|
31536
|
+
const candidates = Array.from(new Set([
|
|
31537
|
+
`${publishName}_${fileName}`,
|
|
31538
|
+
fileName,
|
|
31539
|
+
`${publishName}_${outputFileName}`,
|
|
31540
|
+
outputFileName
|
|
31541
|
+
]));
|
|
31542
|
+
for (const candidate of candidates) assertSafeRestoreSegment(candidate, "published source file name");
|
|
31543
|
+
return candidates;
|
|
31544
|
+
}
|
|
31545
|
+
async function resolveLooseSourceFile(fs, pkg, sourceDir, outputFileName) {
|
|
31546
|
+
return resolveSourceFile(fs, sourceDir, outputFileName.endsWith(".atlas") ? sourceFileCandidates(pkg, `${outputFileName}.txt`, outputFileName) : outputFileName.endsWith(".skel") ? sourceFileCandidates(pkg, `${outputFileName}.bytes`, outputFileName) : sourceFileCandidates(pkg, outputFileName));
|
|
31547
|
+
}
|
|
31548
|
+
async function resolveSourceFile(fs, sourceDir, candidates) {
|
|
31549
|
+
const resolvedSourceDir = await Promise.resolve(fs.resolvePath(sourceDir));
|
|
31550
|
+
for (const candidate of candidates) {
|
|
31551
|
+
assertSafeRestoreSegment(candidate, "published source file name");
|
|
31552
|
+
const sourcePath = fs.join(sourceDir, candidate);
|
|
31553
|
+
if (!await fs.isFile(sourcePath)) continue;
|
|
31554
|
+
const resolvedSourcePath = await Promise.resolve(fs.resolvePath(sourcePath));
|
|
31555
|
+
if (!isPathWithin(resolvedSourceDir, resolvedSourcePath)) throw new Error(`restore: Published source file resolves outside the input directory: ${candidate}.`);
|
|
31556
|
+
return resolvedSourcePath;
|
|
31557
|
+
}
|
|
31558
|
+
return null;
|
|
31559
|
+
}
|
|
31560
|
+
function resourceOutputPath(fs, outputProjectPath, pkg, resource, fileName) {
|
|
31561
|
+
const basePath = fs.dirname(outputProjectPath);
|
|
31562
|
+
const branch = resource.getBranch() ?? "";
|
|
31563
|
+
assertSafeRestoreSegment(pkg.getName(), "package name");
|
|
31564
|
+
if (branch) assertSafeRestoreSegment(branch, "branch name");
|
|
31565
|
+
assertSafeRestoreSegment(fileName, "resource file name");
|
|
31566
|
+
const assetsDir = branch ? `assets_${branch}` : "assets";
|
|
31567
|
+
const virtualPath = normalizeRestoreResourcePath(resource.getPath());
|
|
31568
|
+
const pkgDir = fs.join(basePath, assetsDir, pkg.getName());
|
|
31569
|
+
return virtualPath ? fs.join(pkgDir, virtualPath, fileName) : fs.join(pkgDir, fileName);
|
|
31570
|
+
}
|
|
31571
|
+
//#endregion
|
|
31572
|
+
//#region ../functions/src/restore-internals/skeleton.ts
|
|
31573
|
+
async function synthesizeLooseSkeletonResources(fs, doc, sourceDir) {
|
|
31574
|
+
for (const pkg of doc.getRoot().listPackages()) for (const resource of [...pkg.listResources()]) {
|
|
31575
|
+
let current = resource;
|
|
31576
|
+
if (resource.propertyType === "DragonBonesResource" && /\.skel\.bytes$/i.test(resourceFileName$1(resource))) {
|
|
31577
|
+
const normalizedFile = resourceFileName$1(resource).replace(/\.skel\.bytes$/i, ".skel");
|
|
31578
|
+
if (await resolveLooseSourceFile(fs, pkg, sourceDir, `${stripExtension$1(normalizedFile).replace(/-(?:pro|ess)$/i, "-pma")}.atlas`)) current = replaceSkeletonResourceType(doc, pkg, resource, "SpineResource", normalizedFile);
|
|
31579
|
+
}
|
|
31580
|
+
if (current.propertyType === "SpineResource") await ensureSpineSidecarResources(fs, doc, pkg, current, sourceDir);
|
|
31581
|
+
else if (current.propertyType === "DragonBonesResource") await ensureDragonBonesSidecarResources(fs, doc, pkg, current, sourceDir);
|
|
31582
|
+
}
|
|
31583
|
+
}
|
|
31584
|
+
function initializeRestoredResourceRelations(doc) {
|
|
31585
|
+
for (const pkg of doc.getRoot().listPackages()) {
|
|
31586
|
+
const resources = pkg.listResources();
|
|
31587
|
+
for (const resource of resources) if (resource.propertyType === "SpineResource") initializeSpineResourceRelation(resource, resources);
|
|
31588
|
+
else if (resource.propertyType === "DragonBonesResource") initializeDragonBonesResourceRelation(resource, resources);
|
|
31589
|
+
}
|
|
31590
|
+
}
|
|
31591
|
+
function replaceSkeletonResourceType(doc, pkg, resource, targetType, fileName) {
|
|
31592
|
+
const replacement = targetType === "SpineResource" ? doc.createSpineResource(resource.getName() ?? "") : doc.createDragonBonesResource(resource.getName() ?? "");
|
|
31593
|
+
replacement.setId(resource.getId() ?? "").setPath(resource.getPath() ?? "/").setFile(fileName).setExported(resource.getExported() ?? false).setWidth(resource.getWidth() ?? 0).setHeight(resource.getHeight() ?? 0).setRequireIds(resource.getRequireIds() ?? []).setAtlasNames(resource.getAtlasNames() ?? []).setAnchor(resource.getAnchorX() ?? 0, resource.getAnchorY() ?? 0).setBranch(resource.getBranch() ?? "").setBranchItemIds(resource.getBranchItemIds() ?? []);
|
|
31594
|
+
replacement.setExtras({ ...resource.getExtras() ?? {} });
|
|
31595
|
+
pkg.removeResource(resource);
|
|
31596
|
+
pkg.addResource(replacement);
|
|
31597
|
+
return replacement;
|
|
31598
|
+
}
|
|
31599
|
+
async function ensureSpineSidecarResources(fs, doc, pkg, resource, sourceDir) {
|
|
31600
|
+
const skeletonBase = stripExtension$1(resourceFileName$1(resource).replace(/\.skel\.bytes$/i, ".skel"));
|
|
31601
|
+
if (!skeletonBase) return;
|
|
31602
|
+
const atlasBase = skeletonBase.replace(/-(?:pro|ess)$/i, "-pma");
|
|
31603
|
+
const atlas = await ensureLooseMiscResource(fs, doc, pkg, resource, sourceDir, `${atlasBase}.atlas`);
|
|
31604
|
+
const texture = await ensureLooseImageResource(fs, doc, pkg, resource, sourceDir, `${atlasBase}.png`);
|
|
31605
|
+
const requireIds = [atlas?.getId(), texture?.getId()].filter((id) => !!id);
|
|
31606
|
+
if (requireIds.length > 0) resource.setRequireIds(requireIds);
|
|
31607
|
+
if (atlas) resource.setAtlasNames([atlasBase]);
|
|
31608
|
+
}
|
|
31609
|
+
async function ensureDragonBonesSidecarResources(fs, doc, pkg, resource, sourceDir) {
|
|
31610
|
+
const skeletonBase = stripExtension$1(resourceFileName$1(resource)).replace(/_ske$/i, "");
|
|
31611
|
+
if (!skeletonBase) return;
|
|
31612
|
+
const textureJson = await ensureLooseMiscResource(fs, doc, pkg, resource, sourceDir, `${skeletonBase}_tex.json`);
|
|
31613
|
+
const textureImage = await ensureLooseImageResource(fs, doc, pkg, resource, sourceDir, `${skeletonBase}.png`);
|
|
31614
|
+
const requireIds = [textureJson?.getId(), textureImage?.getId()].filter((id) => !!id);
|
|
31615
|
+
if (requireIds.length > 0) resource.setRequireIds(requireIds);
|
|
31616
|
+
}
|
|
31617
|
+
async function ensureLooseMiscResource(fs, doc, pkg, owner, sourceDir, fileName) {
|
|
31618
|
+
const existing = findResourceByFile(pkg.listResources().filter((entry) => entry.propertyType === "MiscResource"), owner, fileName);
|
|
31619
|
+
if (existing) return existing;
|
|
31620
|
+
const sourcePath = await resolveLooseSourceFile(fs, pkg, sourceDir, fileName);
|
|
31621
|
+
if (!sourcePath) return null;
|
|
31622
|
+
const resource = doc.createMiscResource(stripExtension$1(fileName));
|
|
31623
|
+
resource.setId(generateId()).setPath(owner.getPath() ?? "/").setBranch(owner.getBranch() ?? "").setBranchItemIds(owner.getBranchItemIds() ?? []).setExported(false).setFile(fileName);
|
|
31624
|
+
resource.setExtras({
|
|
31625
|
+
...resource.getExtras() ?? {},
|
|
31626
|
+
_publishedFile: fileBaseName(sourcePath)
|
|
31627
|
+
});
|
|
31628
|
+
pkg.addResource(resource);
|
|
31629
|
+
return resource;
|
|
31630
|
+
}
|
|
31631
|
+
async function ensureLooseImageResource(fs, doc, pkg, owner, sourceDir, fileName) {
|
|
31632
|
+
const existing = findResourceByFile(pkg.listResources().filter((entry) => entry.propertyType === "ImageResource"), owner, fileName);
|
|
31633
|
+
const sourcePath = await resolveLooseSourceFile(fs, pkg, sourceDir, fileName);
|
|
31634
|
+
if (!sourcePath) return existing ?? null;
|
|
31635
|
+
if (existing) {
|
|
31636
|
+
existing.setExtras({
|
|
31637
|
+
...existing.getExtras() ?? {},
|
|
31638
|
+
_publishedFile: fileBaseName(sourcePath),
|
|
31639
|
+
_restoreAsLooseImage: true
|
|
31640
|
+
});
|
|
31641
|
+
return existing;
|
|
31642
|
+
}
|
|
31643
|
+
const resource = doc.createImageResource(stripExtension$1(fileName));
|
|
31644
|
+
resource.setId(generateId()).setPath(owner.getPath() ?? "/").setBranch(owner.getBranch() ?? "").setBranchItemIds(owner.getBranchItemIds() ?? []).setExported(false).setFileName(fileName);
|
|
31645
|
+
resource.setExtras({
|
|
31646
|
+
...resource.getExtras() ?? {},
|
|
31647
|
+
_publishedFile: fileBaseName(sourcePath),
|
|
31648
|
+
_restoreAsLooseImage: true
|
|
31649
|
+
});
|
|
31650
|
+
ProjectWriter.setImageWriteHints(resource, { omitPackageSize: true });
|
|
31651
|
+
pkg.addResource(resource);
|
|
31652
|
+
return resource;
|
|
31653
|
+
}
|
|
31654
|
+
function initializeSpineResourceRelation(resource, resources) {
|
|
31655
|
+
const skeletonBase = stripExtension$1(resourceFileName$1(resource));
|
|
31656
|
+
if (!skeletonBase) return;
|
|
31657
|
+
const atlasBase = skeletonBase.replace(/-(?:pro|ess)$/i, "-pma");
|
|
31658
|
+
const requireIds = [];
|
|
31659
|
+
const atlas = findResourceByFile(resources.filter((entry) => entry.propertyType === "MiscResource"), resource, `${atlasBase}.atlas`);
|
|
31660
|
+
const texture = findResourceByFile(resources.filter((entry) => entry.propertyType === "ImageResource"), resource, `${atlasBase}.png`);
|
|
31661
|
+
if (atlas?.getId()) requireIds.push(atlas.getId());
|
|
31662
|
+
if (texture?.getId()) requireIds.push(texture.getId());
|
|
31663
|
+
if (requireIds.length > 0) resource.setRequireIds(requireIds);
|
|
31664
|
+
if (atlas) resource.setAtlasNames([atlasBase]);
|
|
31665
|
+
}
|
|
31666
|
+
function initializeDragonBonesResourceRelation(resource, resources) {
|
|
31667
|
+
const skeletonBase = stripExtension$1(resourceFileName$1(resource)).replace(/_ske$/i, "");
|
|
31668
|
+
if (!skeletonBase) return;
|
|
31669
|
+
const requireIds = [];
|
|
31670
|
+
const textureJson = findResourceByFile(resources.filter((entry) => entry.propertyType === "MiscResource"), resource, `${skeletonBase}_tex.json`);
|
|
31671
|
+
const textureImage = findResourceByFile(resources.filter((entry) => entry.propertyType === "ImageResource"), resource, `${skeletonBase}.png`);
|
|
31672
|
+
if (textureJson?.getId()) requireIds.push(textureJson.getId());
|
|
31673
|
+
if (textureImage?.getId()) requireIds.push(textureImage.getId());
|
|
31674
|
+
if (requireIds.length > 0) resource.setRequireIds(requireIds);
|
|
31675
|
+
}
|
|
31676
|
+
function findResourceByFile(resources, owner, fileName) {
|
|
31677
|
+
const expected = fileName.toLowerCase();
|
|
31678
|
+
return resources.find((resource) => {
|
|
31679
|
+
return sameVirtualPath(owner, resource) && fileBaseName(resourceFileName$1(resource)).toLowerCase() === expected;
|
|
31680
|
+
}) ?? null;
|
|
31681
|
+
}
|
|
31682
|
+
//#endregion
|
|
31683
|
+
//#region ../functions/src/restore-internals/font.ts
|
|
31684
|
+
const syntheticFontGlyphImages = /* @__PURE__ */ new WeakSet();
|
|
31685
|
+
function isSyntheticFontGlyphImage(image) {
|
|
31686
|
+
return syntheticFontGlyphImages.has(image);
|
|
31687
|
+
}
|
|
31688
|
+
function resourceFileName(resource) {
|
|
31689
|
+
return ("getFileName" in resource ? resource.getFileName() : "getFile" in resource ? resource.getFile() : "") || resource.getName();
|
|
31690
|
+
}
|
|
31691
|
+
function stripExtension(fileName) {
|
|
31430
31692
|
return fileName.split(/[\\/]/).pop()?.replace(/\.[^.]+$/u, "") ?? "";
|
|
31431
31693
|
}
|
|
31432
31694
|
function fontGlyphCharId(glyph) {
|
|
@@ -31436,25 +31698,25 @@ function fontGlyphCharId(glyph) {
|
|
|
31436
31698
|
return char ? char.codePointAt(0) ?? 0 : 0;
|
|
31437
31699
|
}
|
|
31438
31700
|
function serializeTtfFontHeader(pkg, resource, glyphs) {
|
|
31439
|
-
const face = stripExtension
|
|
31440
|
-
const lineHeight = resource.getLineHeight
|
|
31441
|
-
const fontSize = resource.getFontSize
|
|
31442
|
-
const textureId = resource.getTextureId
|
|
31443
|
-
const textureResource = textureId ? pkg.
|
|
31444
|
-
const textureName = textureResource ? resourceFileName
|
|
31445
|
-
const scaleW = textureResource?.getWidth
|
|
31446
|
-
const scaleH = textureResource?.getHeight
|
|
31701
|
+
const face = stripExtension(resourceFileName(resource)) || resource.getName() || "Font";
|
|
31702
|
+
const lineHeight = resource.getLineHeight() ?? 0;
|
|
31703
|
+
const fontSize = resource.getFontSize() ?? lineHeight;
|
|
31704
|
+
const textureId = resource.getTextureId() ?? "";
|
|
31705
|
+
const textureResource = textureId ? pkg.listImageResources().find((image) => image.getId() === textureId) ?? null : null;
|
|
31706
|
+
const textureName = textureResource ? resourceFileName(textureResource) : `${face}_atlas.png`;
|
|
31707
|
+
const scaleW = textureResource?.getWidth() ?? 256;
|
|
31708
|
+
const scaleH = textureResource?.getHeight() ?? 256;
|
|
31447
31709
|
const base = Math.max(Math.min(fontSize, lineHeight) - 6, 0);
|
|
31448
31710
|
return [
|
|
31449
31711
|
`info face="${face}" size=${fontSize} bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1 outline=0`,
|
|
31450
|
-
`common lineHeight=${lineHeight} base=${base} scaleW=${scaleW} scaleH=${scaleH} pages=1 packed=0 alphaChnl=${resource.getTint
|
|
31712
|
+
`common lineHeight=${lineHeight} base=${base} scaleW=${scaleW} scaleH=${scaleH} pages=1 packed=0 alphaChnl=${resource.getTint() ? 1 : 0} redChnl=0 greenChnl=0 blueChnl=0`,
|
|
31451
31713
|
`page id=0 file="${textureName}"`,
|
|
31452
31714
|
`chars count=${glyphs.length}`
|
|
31453
31715
|
];
|
|
31454
31716
|
}
|
|
31455
31717
|
function serializeFont(pkg, resource, glyphs) {
|
|
31456
|
-
const isTtf = resource.getTtf
|
|
31457
|
-
const lines = isTtf ? serializeTtfFontHeader(pkg, resource, glyphs) : ["info creator=UIBuilder", `common lineHeight=${resource.getLineHeight
|
|
31718
|
+
const isTtf = resource.getTtf() === true;
|
|
31719
|
+
const lines = isTtf ? serializeTtfFontHeader(pkg, resource, glyphs) : ["info creator=UIBuilder", `common lineHeight=${resource.getLineHeight() ?? 0}`];
|
|
31458
31720
|
for (const glyph of glyphs) {
|
|
31459
31721
|
const charId = fontGlyphCharId(glyph);
|
|
31460
31722
|
if (isTtf) lines.push(`char id=${charId} x=${glyph.getX()} y=${glyph.getY()} width=${glyph.getWidth()} height=${glyph.getHeight()} xoffset=${glyph.getXOffset()} yoffset=${glyph.getYOffset()} xadvance=${glyph.getAdvance()} page=0 chnl=${glyph.getChannel()}`);
|
|
@@ -31462,77 +31724,28 @@ function serializeFont(pkg, resource, glyphs) {
|
|
|
31462
31724
|
}
|
|
31463
31725
|
return `${lines.join("\n")}\n`;
|
|
31464
31726
|
}
|
|
31465
|
-
function
|
|
31466
|
-
|
|
31467
|
-
if (char) return char;
|
|
31468
|
-
const charId = glyph.getCharId();
|
|
31469
|
-
if (charId <= 0) return "";
|
|
31470
|
-
try {
|
|
31471
|
-
return String.fromCodePoint(charId);
|
|
31472
|
-
} catch {
|
|
31473
|
-
return "";
|
|
31474
|
-
}
|
|
31475
|
-
}
|
|
31476
|
-
function sanitizeGlyphFileSegment(char) {
|
|
31477
|
-
if (!char) return "glyph";
|
|
31478
|
-
return char.replace(/\s/gu, "space").replace(/[\\/:*?"<>|]/gu, "_").replace(/\./gu, "_").split("").filter((item) => {
|
|
31479
|
-
return (item.codePointAt(0) ?? 0) >= 32;
|
|
31480
|
-
}).join("") || "glyph";
|
|
31481
|
-
}
|
|
31482
|
-
function syntheticFontGlyphVirtualPath(pkg, font) {
|
|
31483
|
-
const pkgName = pkg.getName?.() ?? "";
|
|
31484
|
-
const fontBase = stripExtension$1(resourceFileName$1(font)).toLowerCase();
|
|
31485
|
-
if (pkgName === "EmitNumbers") return "/";
|
|
31486
|
-
if (pkgName === "Transition" && fontBase === "number3") return "/";
|
|
31487
|
-
return "/images/";
|
|
31488
|
-
}
|
|
31489
|
-
function syntheticFontGlyphFileName(pkg, font, glyph, index, glyphCount) {
|
|
31490
|
-
const pkgName = pkg.getName?.() ?? "";
|
|
31491
|
-
const char = glyphDisplayChar(glyph);
|
|
31492
|
-
const fontBase = stripExtension$1(resourceFileName$1(font));
|
|
31493
|
-
if (/^(hitnumber|number3)$/i.test(fontBase) && /^[0-9]$/u.test(char)) return `h${char}.png`;
|
|
31494
|
-
if (/^cdtime$/i.test(fontBase) && /^[0-9]$/u.test(char)) return `${char}(4)_png.png`;
|
|
31495
|
-
if (pkgName === "EmitNumbers" && /^number1$/i.test(fontBase)) {
|
|
31496
|
-
if (/^[0-9]$/u.test(char)) return `${char}(2)5_png.png`;
|
|
31497
|
-
if (char === "-") return "m2_png.png";
|
|
31498
|
-
}
|
|
31499
|
-
if (pkgName === "EmitNumbers" && /^number2$/i.test(fontBase)) {
|
|
31500
|
-
if (/^[0-9]$/u.test(char)) return `${char}(4)_png.png`;
|
|
31501
|
-
if (char === "-") return "m1_png.png";
|
|
31502
|
-
}
|
|
31503
|
-
if (pkgName === "Transition" && /^number1$/i.test(fontBase)) {
|
|
31504
|
-
const display = char === "0" && index === glyphCount - 1 ? "0-" : sanitizeGlyphFileSegment(char);
|
|
31505
|
-
return `${String(index).padStart(4, "0")}_${display}_png.png`;
|
|
31506
|
-
}
|
|
31507
|
-
if (pkgName === "Transition" && /^number2$/i.test(fontBase)) return `${String(index).padStart(4, "0")}_${sanitizeGlyphFileSegment(char)}.png`;
|
|
31508
|
-
const display = sanitizeGlyphFileSegment(char);
|
|
31509
|
-
return `${String(index).padStart(4, "0")}_${display}.png`;
|
|
31727
|
+
function syntheticFontGlyphFileName(glyphId) {
|
|
31728
|
+
return `glyph-${Array.from(new TextEncoder().encode(glyphId), (byte) => byte.toString(16).padStart(2, "0")).join("")}.png`;
|
|
31510
31729
|
}
|
|
31511
31730
|
function syntheticFontTextureFileName(font) {
|
|
31512
|
-
return `${stripExtension
|
|
31731
|
+
return `${stripExtension(resourceFileName(font)) || font.getId() || "font"}_atlas.png`;
|
|
31513
31732
|
}
|
|
31514
31733
|
function initializeFontGlyphImageResources(doc) {
|
|
31515
31734
|
for (const pkg of doc.getRoot().listPackages()) for (const resource of [...pkg.listResources()]) {
|
|
31516
31735
|
if (resource.propertyType !== "FontResource") continue;
|
|
31517
|
-
const
|
|
31518
|
-
for (const
|
|
31519
|
-
const glyphId = glyph.getImg?.() ?? "";
|
|
31520
|
-
if (!glyphId || glyphEntries.has(glyphId)) continue;
|
|
31521
|
-
glyphEntries.set(glyphId, {
|
|
31522
|
-
glyph,
|
|
31523
|
-
index
|
|
31524
|
-
});
|
|
31525
|
-
}
|
|
31526
|
-
for (const [glyphId, entry] of glyphEntries) {
|
|
31736
|
+
const glyphIds = new Set(resource.listGlyphs().map((glyph) => glyph.getImg()).filter(Boolean));
|
|
31737
|
+
for (const glyphId of glyphIds) {
|
|
31527
31738
|
if (pkg.getResourceById(glyphId)) continue;
|
|
31528
31739
|
const image = doc.createImageResource(glyphId);
|
|
31529
|
-
image.setId(glyphId).setPath(
|
|
31530
|
-
|
|
31531
|
-
|
|
31532
|
-
|
|
31533
|
-
|
|
31534
|
-
|
|
31740
|
+
image.setId(glyphId).setPath("/images/").setBranch(resource.getBranch() ?? "").setFileName(syntheticFontGlyphFileName(glyphId));
|
|
31741
|
+
ProjectWriter.setImageWriteHints(image, {
|
|
31742
|
+
omitPackageSize: true,
|
|
31743
|
+
packageOrder: {
|
|
31744
|
+
afterId: resource.getId(),
|
|
31745
|
+
weight: 1
|
|
31746
|
+
}
|
|
31535
31747
|
});
|
|
31748
|
+
syntheticFontGlyphImages.add(image);
|
|
31536
31749
|
pkg.addResource(image);
|
|
31537
31750
|
}
|
|
31538
31751
|
}
|
|
@@ -31540,15 +31753,16 @@ function initializeFontGlyphImageResources(doc) {
|
|
|
31540
31753
|
function initializeFontTextureImageResources(doc) {
|
|
31541
31754
|
for (const pkg of doc.getRoot().listPackages()) for (const resource of [...pkg.listResources()]) {
|
|
31542
31755
|
if (resource.propertyType !== "FontResource") continue;
|
|
31543
|
-
const textureId = resource.getTextureId
|
|
31756
|
+
const textureId = resource.getTextureId() ?? "";
|
|
31544
31757
|
if (!textureId || pkg.getResourceById(textureId)) continue;
|
|
31545
31758
|
const image = doc.createImageResource(textureId);
|
|
31546
|
-
image.setId(textureId).setPath(resource.getPath
|
|
31547
|
-
|
|
31548
|
-
|
|
31549
|
-
|
|
31550
|
-
|
|
31551
|
-
|
|
31759
|
+
image.setId(textureId).setPath(resource.getPath() ?? "/").setBranch(resource.getBranch() ?? "").setFileName(syntheticFontTextureFileName(resource));
|
|
31760
|
+
ProjectWriter.setImageWriteHints(image, {
|
|
31761
|
+
omitPackageSize: true,
|
|
31762
|
+
packageOrder: {
|
|
31763
|
+
afterId: resource.getId(),
|
|
31764
|
+
weight: 0
|
|
31765
|
+
}
|
|
31552
31766
|
});
|
|
31553
31767
|
pkg.addResource(image);
|
|
31554
31768
|
}
|
|
@@ -31556,20 +31770,20 @@ function initializeFontTextureImageResources(doc) {
|
|
|
31556
31770
|
function initializePublishedFontDefaults(doc) {
|
|
31557
31771
|
for (const pkg of doc.getRoot().listPackages()) for (const resource of pkg.listResources()) {
|
|
31558
31772
|
if (resource.propertyType !== "FontResource") continue;
|
|
31559
|
-
const fileName = resourceFileName
|
|
31773
|
+
const fileName = resourceFileName(resource);
|
|
31560
31774
|
if (!/\bsdf\b/i.test(fileName)) continue;
|
|
31561
|
-
if (!resource.getRenderMode
|
|
31562
|
-
if (!resource.getSamplePointSize
|
|
31775
|
+
if (!resource.getRenderMode()) resource.setRenderMode("sdfaa");
|
|
31776
|
+
if (!resource.getSamplePointSize()) resource.setSamplePointSize(60);
|
|
31563
31777
|
}
|
|
31564
31778
|
}
|
|
31565
31779
|
function initializePublishedTextFontResources(doc) {
|
|
31566
31780
|
for (const pkg of doc.getRoot().listPackages()) {
|
|
31567
31781
|
const fontResources = pkg.listResources().filter((resource) => resource.propertyType === "FontResource");
|
|
31568
|
-
const fontByFileName = new Map(fontResources.map((resource) => [resourceFileName
|
|
31569
|
-
const fontByDisplayName = new Map(fontResources.map((resource) => [stripExtension
|
|
31570
|
-
for (const component of pkg.listComponents()) for (const
|
|
31571
|
-
|
|
31572
|
-
const font = text.getFont
|
|
31782
|
+
const fontByFileName = new Map(fontResources.map((resource) => [resourceFileName(resource).toLowerCase(), resource]));
|
|
31783
|
+
const fontByDisplayName = new Map(fontResources.map((resource) => [stripExtension(resourceFileName(resource)).toLowerCase(), resource]));
|
|
31784
|
+
for (const component of pkg.listComponents()) for (const text of component.listChildren()) {
|
|
31785
|
+
if (!(text instanceof GTextField)) continue;
|
|
31786
|
+
const font = text.getFont() ?? "";
|
|
31573
31787
|
if (!font || font.startsWith("ui://")) continue;
|
|
31574
31788
|
if (!/\bsdf\b/i.test(font)) continue;
|
|
31575
31789
|
const normalized = font.trim().toLowerCase();
|
|
@@ -31581,7 +31795,7 @@ function initializePublishedTextFontResources(doc) {
|
|
|
31581
31795
|
fontByDisplayName.set(normalized, resource);
|
|
31582
31796
|
fontByFileName.set(`${normalized}.ttf`, resource);
|
|
31583
31797
|
}
|
|
31584
|
-
text.setFont
|
|
31798
|
+
text.setFont(`ui://${pkg.getId()}${resource.getId() ?? ""}`);
|
|
31585
31799
|
}
|
|
31586
31800
|
}
|
|
31587
31801
|
}
|
|
@@ -31590,13 +31804,13 @@ function initializePublishedFontTextureIds(doc) {
|
|
|
31590
31804
|
const resources = pkg.listResources();
|
|
31591
31805
|
for (const resource of resources) {
|
|
31592
31806
|
if (resource.propertyType !== "FontResource") continue;
|
|
31593
|
-
if (resource.getTextureId
|
|
31594
|
-
if (resource.getTtf
|
|
31807
|
+
if (resource.getTextureId()) continue;
|
|
31808
|
+
if (resource.getTtf() !== true) continue;
|
|
31595
31809
|
const expectedFileName = syntheticFontTextureFileName(resource).toLowerCase();
|
|
31596
31810
|
const texture = resources.find((candidate) => {
|
|
31597
|
-
return candidate.propertyType === "ImageResource" && normalizeRestoreResourcePath(resource.getPath()) === normalizeRestoreResourcePath(candidate.getPath()) && resourceFileName
|
|
31811
|
+
return candidate.propertyType === "ImageResource" && normalizeRestoreResourcePath(resource.getPath()) === normalizeRestoreResourcePath(candidate.getPath()) && resourceFileName(candidate).split(/[\\/]/).pop()?.toLowerCase() === expectedFileName;
|
|
31598
31812
|
});
|
|
31599
|
-
if (texture?.getId
|
|
31813
|
+
if (texture?.getId()) resource.setTextureId(texture.getId());
|
|
31600
31814
|
}
|
|
31601
31815
|
}
|
|
31602
31816
|
}
|
|
@@ -31653,11 +31867,11 @@ function serializeMovieClip(resource, frames, textures) {
|
|
|
31653
31867
|
writeByte(0),
|
|
31654
31868
|
writeUint16(0),
|
|
31655
31869
|
writeUint16(0),
|
|
31656
|
-
writeUint16(resource.getWidth
|
|
31657
|
-
writeUint16(resource.getHeight
|
|
31658
|
-
writeByte(jtaSpeed(resource.getInterval
|
|
31659
|
-
writeByte(scaledFrameDelay(resource.getRepeatDelay
|
|
31660
|
-
writeByte(resource.getSwing
|
|
31870
|
+
writeUint16(resource.getWidth() ?? 0),
|
|
31871
|
+
writeUint16(resource.getHeight() ?? 0),
|
|
31872
|
+
writeByte(jtaSpeed(resource.getInterval() ?? 0)),
|
|
31873
|
+
writeByte(scaledFrameDelay(resource.getRepeatDelay() ?? 0)),
|
|
31874
|
+
writeByte(resource.getSwing() ? 1 : 0),
|
|
31661
31875
|
writeInt16(frames.length)
|
|
31662
31876
|
];
|
|
31663
31877
|
for (const [index, frame] of frames.entries()) chunks.push(writeInt16(scaledFrameDelay(frame.getAddDelay())), writeInt16(frame.getRectX()), writeInt16(frame.getRectY()), writeInt16(frame.getRectWidth()), writeInt16(frame.getRectHeight()), writeInt16(textures[index]?.byteLength === 0 ? -1 : index));
|
|
@@ -31666,7 +31880,7 @@ function serializeMovieClip(resource, frames, textures) {
|
|
|
31666
31880
|
return concatBytes(chunks);
|
|
31667
31881
|
}
|
|
31668
31882
|
//#endregion
|
|
31669
|
-
//#region ../functions/src/restore.ts
|
|
31883
|
+
//#region ../functions/src/restore-internals/asset-output.ts
|
|
31670
31884
|
const TRANSPARENT_PNG_1X1 = Uint8Array.from([
|
|
31671
31885
|
137,
|
|
31672
31886
|
80,
|
|
@@ -31736,67 +31950,143 @@ const TRANSPARENT_PNG_1X1 = Uint8Array.from([
|
|
|
31736
31950
|
96,
|
|
31737
31951
|
130
|
|
31738
31952
|
]);
|
|
31739
|
-
function
|
|
31740
|
-
|
|
31741
|
-
}
|
|
31742
|
-
function resourceFileName(resource) {
|
|
31743
|
-
return resource.getFileName?.() || resource.getFile?.() || resource.getName?.() || "";
|
|
31744
|
-
}
|
|
31745
|
-
function resourcePublishedFileName(resource) {
|
|
31746
|
-
const publishedFile = (resource.getExtras?.() ?? {})._publishedFile;
|
|
31747
|
-
return typeof publishedFile === "string" ? publishedFile : resourceFileName(resource);
|
|
31748
|
-
}
|
|
31749
|
-
function normalizePublishedLooseResourceFileName(resource, fileName) {
|
|
31750
|
-
if (resource.propertyType === "MiscResource" && /\.atlas\.txt$/i.test(fileName)) return fileName.replace(/\.atlas\.txt$/i, ".atlas");
|
|
31751
|
-
if (resource.propertyType === "SpineResource" && /\.skel\.bytes$/i.test(fileName)) return fileName.replace(/\.skel\.bytes$/i, ".skel");
|
|
31752
|
-
return fileName;
|
|
31753
|
-
}
|
|
31754
|
-
function replaceLooseResourceBaseName(resource, fileName) {
|
|
31755
|
-
const normalized = normalizePublishedLooseResourceFileName(resource, fileName);
|
|
31756
|
-
const displayName = resource.getName?.() ?? "";
|
|
31757
|
-
if (!displayName) return normalized;
|
|
31758
|
-
const baseName = fileBaseName(normalized);
|
|
31759
|
-
const ext = /((?:\.[^.\\/]+)+)$/u.exec(baseName)?.[1] ?? "";
|
|
31760
|
-
const currentBaseName = ext ? baseName.slice(0, -ext.length) : baseName;
|
|
31761
|
-
const resourceId = resource.getId?.() ?? "";
|
|
31762
|
-
if (!resourceId || currentBaseName.toLowerCase() !== resourceId.toLowerCase()) return normalized;
|
|
31763
|
-
return `${normalized.slice(0, normalized.length - baseName.length)}${displayName}${ext}`;
|
|
31764
|
-
}
|
|
31765
|
-
function fileBaseName(fileName) {
|
|
31766
|
-
return fileName.split(/[\\/]/).pop() ?? fileName;
|
|
31767
|
-
}
|
|
31768
|
-
function stripExtension(fileName) {
|
|
31769
|
-
return fileBaseName(fileName).replace(/\.[^.]+$/u, "");
|
|
31770
|
-
}
|
|
31771
|
-
function resourceInstanceFileName(resource) {
|
|
31772
|
-
const fileName = (resource.propertyType === "Component" ? `${resource.getName?.() ?? resource.getId?.() ?? "component"}.xml` : resourceFileName(resource)).replace(/\\/g, "/").replace(/^\/+/, "");
|
|
31773
|
-
if (!fileName) return "";
|
|
31774
|
-
if (fileName.includes("/")) return fileName;
|
|
31775
|
-
const virtualPath = normalizeRestoreResourcePath(resource.getPath?.());
|
|
31776
|
-
return virtualPath ? `${virtualPath}/${fileName}` : fileName;
|
|
31777
|
-
}
|
|
31778
|
-
function isSyntheticFontGlyphResource(resource) {
|
|
31779
|
-
return resource.getExtras?.()?._syntheticFontGlyph === true;
|
|
31780
|
-
}
|
|
31781
|
-
function defaultSyntheticFontGlyphFileName(resourceId) {
|
|
31782
|
-
return `${resourceId}.png`;
|
|
31953
|
+
function findImageResource(pkg, itemId) {
|
|
31954
|
+
return pkg.listImageResources().find((resource) => resource.getId() === itemId) ?? null;
|
|
31783
31955
|
}
|
|
31784
|
-
function
|
|
31785
|
-
|
|
31956
|
+
async function restoreAssets(fs, doc, options, warnings) {
|
|
31957
|
+
for (const pkg of doc.getRoot().listPackages()) {
|
|
31958
|
+
await restoreAtlasImages(fs, pkg, options);
|
|
31959
|
+
await writeGeneratedResources(fs, pkg, options, warnings);
|
|
31960
|
+
await copyLooseResources(fs, pkg, options, warnings);
|
|
31961
|
+
}
|
|
31962
|
+
}
|
|
31963
|
+
async function restoreAtlasImages(fs, pkg, options) {
|
|
31964
|
+
if (!options.cropImage) return;
|
|
31965
|
+
for (const atlas of pkg.listAtlases()) {
|
|
31966
|
+
const sourceAtlas = await resolveSourceFile(fs, options.sourceDir, sourceFileCandidates(pkg, atlas.getFile()));
|
|
31967
|
+
if (!sourceAtlas) throw new Error(`Atlas image not found for package "${pkg.getName()}": ${sourceFileCandidates(pkg, atlas.getFile()).join(", ")}`);
|
|
31968
|
+
for (const sprite of atlas.listSprites()) {
|
|
31969
|
+
const image = findImageResource(pkg, sprite.getItemId());
|
|
31970
|
+
if (!image) continue;
|
|
31971
|
+
if (sprite.getRectWidth() <= 0 || sprite.getRectHeight() <= 0) continue;
|
|
31972
|
+
const outputPath = resourceOutputPath(fs, options.outputProjectPath, pkg, image, imageFileName(image));
|
|
31973
|
+
const imageWidth = image.getWidth() ?? 0;
|
|
31974
|
+
const imageHeight = image.getHeight() ?? 0;
|
|
31975
|
+
const spriteWidth = sprite.getRotated() ? sprite.getRectHeight() : sprite.getRectWidth();
|
|
31976
|
+
const spriteHeight = sprite.getRotated() ? sprite.getRectWidth() : sprite.getRectHeight();
|
|
31977
|
+
await fs.mkdir(fs.dirname(outputPath));
|
|
31978
|
+
await options.cropImage({
|
|
31979
|
+
sourcePath: sourceAtlas,
|
|
31980
|
+
outputPath,
|
|
31981
|
+
left: sprite.getRectX(),
|
|
31982
|
+
top: sprite.getRectY(),
|
|
31983
|
+
width: sprite.getRectWidth(),
|
|
31984
|
+
height: sprite.getRectHeight(),
|
|
31985
|
+
rotated: sprite.getRotated(),
|
|
31986
|
+
offsetX: sprite.getOffsetX(),
|
|
31987
|
+
offsetY: sprite.getOffsetY(),
|
|
31988
|
+
expectedWidth: Math.max(imageWidth, sprite.getOriginalWidth(), spriteWidth),
|
|
31989
|
+
expectedHeight: Math.max(imageHeight, sprite.getOriginalHeight(), spriteHeight)
|
|
31990
|
+
});
|
|
31991
|
+
}
|
|
31992
|
+
}
|
|
31786
31993
|
}
|
|
31787
|
-
function
|
|
31788
|
-
const
|
|
31789
|
-
|
|
31790
|
-
|
|
31791
|
-
|
|
31792
|
-
|
|
31793
|
-
|
|
31994
|
+
async function copyLooseResources(fs, pkg, options, warnings) {
|
|
31995
|
+
for (const resource of pkg.listResources()) {
|
|
31996
|
+
const restoreAsLooseImage = resource.getExtras()?._restoreAsLooseImage === true;
|
|
31997
|
+
if (![
|
|
31998
|
+
"SoundResource",
|
|
31999
|
+
"MiscResource",
|
|
32000
|
+
"SpineResource",
|
|
32001
|
+
"DragonBonesResource"
|
|
32002
|
+
].includes(resource.propertyType) && !restoreAsLooseImage) continue;
|
|
32003
|
+
const fileName = resourceFileName$1(resource);
|
|
32004
|
+
if (!fileName) continue;
|
|
32005
|
+
const sourcePath = await resolveSourceFile(fs, options.sourceDir, sourceFileCandidates(pkg, resourcePublishedFileName(resource), fileName));
|
|
32006
|
+
if (!sourcePath) {
|
|
32007
|
+
warnings.push(`Loose resource not found for package "${pkg.getName()}": ${fileName}`);
|
|
32008
|
+
continue;
|
|
32009
|
+
}
|
|
32010
|
+
const outputPath = resourceOutputPath(fs, options.outputProjectPath, pkg, resource, fileName);
|
|
32011
|
+
await fs.mkdir(fs.dirname(outputPath));
|
|
32012
|
+
await fs.writeFileRaw(outputPath, await fs.readFileRaw(sourcePath));
|
|
32013
|
+
}
|
|
32014
|
+
}
|
|
32015
|
+
async function writeGeneratedResources(fs, pkg, options, warnings) {
|
|
32016
|
+
for (const resource of pkg.listResources()) if (resource.propertyType === "FontResource") await writeFontFile(fs, pkg, resource, options.outputProjectPath);
|
|
32017
|
+
else if (resource.propertyType === "MovieClipResource") await writeMovieClipFile(fs, pkg, resource, options, warnings);
|
|
32018
|
+
await writeSyntheticFontGlyphImages(fs, pkg, options.outputProjectPath);
|
|
32019
|
+
}
|
|
32020
|
+
async function writeFontFile(fs, pkg, resource, outputProjectPath) {
|
|
32021
|
+
const fileName = resourceFileName$1(resource);
|
|
32022
|
+
if (!/\.fnt$/i.test(fileName)) return;
|
|
32023
|
+
const glyphs = resource.listGlyphs() ?? [];
|
|
32024
|
+
if (glyphs.length === 0) return;
|
|
32025
|
+
const outputPath = resourceOutputPath(fs, outputProjectPath, pkg, resource, fileName);
|
|
32026
|
+
await fs.mkdir(fs.dirname(outputPath));
|
|
32027
|
+
await fs.writeFile(outputPath, serializeFont(pkg, resource, glyphs));
|
|
32028
|
+
}
|
|
32029
|
+
async function writeMovieClipFile(fs, pkg, resource, options, warnings) {
|
|
32030
|
+
const fileName = resourceFileName$1(resource);
|
|
32031
|
+
if (!/\.jta$/i.test(fileName)) return;
|
|
32032
|
+
const frames = resource.listFrames() ?? [];
|
|
32033
|
+
if (frames.length === 0) return;
|
|
32034
|
+
if (!options.extractImage) {
|
|
32035
|
+
warnings.push(`MovieClip file not generated for package "${pkg.getName()}": ${fileName}`);
|
|
32036
|
+
return;
|
|
32037
|
+
}
|
|
32038
|
+
const sprites = await buildSpriteLookup(fs, pkg, options);
|
|
32039
|
+
const textures = [];
|
|
32040
|
+
for (const [index, frame] of frames.entries()) {
|
|
32041
|
+
const spriteEntry = sprites.get(frame.getSpriteId());
|
|
32042
|
+
if (!spriteEntry) {
|
|
32043
|
+
warnings.push(`MovieClip frame sprite not found for package "${pkg.getName()}": ${fileName} frame ${index}`);
|
|
32044
|
+
return;
|
|
32045
|
+
}
|
|
32046
|
+
const sprite = spriteEntry.sprite;
|
|
32047
|
+
if (sprite.getRectWidth() <= 0 || sprite.getRectHeight() <= 0) {
|
|
32048
|
+
textures.push(new Uint8Array(0));
|
|
32049
|
+
continue;
|
|
32050
|
+
}
|
|
32051
|
+
textures.push(await options.extractImage({
|
|
32052
|
+
sourcePath: spriteEntry.sourceAtlas,
|
|
32053
|
+
left: sprite.getRectX(),
|
|
32054
|
+
top: sprite.getRectY(),
|
|
32055
|
+
width: sprite.getRectWidth(),
|
|
32056
|
+
height: sprite.getRectHeight(),
|
|
32057
|
+
rotated: sprite.getRotated(),
|
|
32058
|
+
offsetX: 0,
|
|
32059
|
+
offsetY: 0,
|
|
32060
|
+
expectedWidth: sprite.getRotated() ? sprite.getRectHeight() : sprite.getRectWidth(),
|
|
32061
|
+
expectedHeight: sprite.getRotated() ? sprite.getRectWidth() : sprite.getRectHeight()
|
|
32062
|
+
}));
|
|
32063
|
+
}
|
|
32064
|
+
const outputPath = resourceOutputPath(fs, options.outputProjectPath, pkg, resource, fileName);
|
|
32065
|
+
await fs.mkdir(fs.dirname(outputPath));
|
|
32066
|
+
await fs.writeFileRaw(outputPath, serializeMovieClip(resource, frames, textures));
|
|
31794
32067
|
}
|
|
31795
|
-
function
|
|
31796
|
-
|
|
31797
|
-
|
|
31798
|
-
|
|
32068
|
+
async function writeSyntheticFontGlyphImages(fs, pkg, outputProjectPath) {
|
|
32069
|
+
for (const resource of pkg.listResources()) {
|
|
32070
|
+
if (resource.propertyType !== "ImageResource" || !isSyntheticFontGlyphImage(resource)) continue;
|
|
32071
|
+
const outputPath = resourceOutputPath(fs, outputProjectPath, pkg, resource, resourceFileName$1(resource) || `${resource.getId() ?? "glyph"}.png`);
|
|
32072
|
+
await fs.mkdir(fs.dirname(outputPath));
|
|
32073
|
+
await fs.writeFileRaw(outputPath, TRANSPARENT_PNG_1X1);
|
|
32074
|
+
}
|
|
32075
|
+
}
|
|
32076
|
+
async function buildSpriteLookup(fs, pkg, options) {
|
|
32077
|
+
const sprites = /* @__PURE__ */ new Map();
|
|
32078
|
+
for (const atlas of pkg.listAtlases()) {
|
|
32079
|
+
const sourceAtlas = await resolveSourceFile(fs, options.sourceDir, sourceFileCandidates(pkg, atlas.getFile()));
|
|
32080
|
+
if (!sourceAtlas) throw new Error(`Atlas image not found for package "${pkg.getName()}": ${sourceFileCandidates(pkg, atlas.getFile()).join(", ")}`);
|
|
32081
|
+
for (const sprite of atlas.listSprites()) sprites.set(sprite.getItemId(), {
|
|
32082
|
+
sourceAtlas,
|
|
32083
|
+
sprite
|
|
32084
|
+
});
|
|
32085
|
+
}
|
|
32086
|
+
return sprites;
|
|
31799
32087
|
}
|
|
32088
|
+
//#endregion
|
|
32089
|
+
//#region ../functions/src/restore.ts
|
|
31800
32090
|
function isPublishedBinaryFile(fileName) {
|
|
31801
32091
|
return /_fui\.bytes$/i.test(fileName) || /\.fui$/i.test(fileName) || /\.bin$/i.test(fileName);
|
|
31802
32092
|
}
|
|
@@ -31859,40 +32149,25 @@ var RestoreWorkflow = class {
|
|
|
31859
32149
|
}
|
|
31860
32150
|
async prepare(options) {
|
|
31861
32151
|
const doc = await new BinaryReader(this._fs).readMany(options.binaryPaths);
|
|
31862
|
-
|
|
32152
|
+
assertDocumentPaths(doc);
|
|
31863
32153
|
this._initializeProjectDefaults(doc, options.projectType);
|
|
31864
32154
|
this._initializeImageFileNames(doc);
|
|
31865
32155
|
this._initializeLooseResourceFileNames(doc);
|
|
31866
|
-
|
|
31867
|
-
await this.
|
|
31868
|
-
|
|
32156
|
+
assertDocumentPaths(doc);
|
|
32157
|
+
await synthesizeLooseSkeletonResources(this._fs, doc, options.sourceDir);
|
|
32158
|
+
initializeRestoredResourceRelations(doc);
|
|
31869
32159
|
initializePublishedFontTextureIds(doc);
|
|
31870
32160
|
initializeFontTextureImageResources(doc);
|
|
31871
32161
|
initializeFontGlyphImageResources(doc);
|
|
31872
32162
|
initializePublishedTextFontResources(doc);
|
|
31873
32163
|
this._initializeDisplayObjectFileNames(doc);
|
|
31874
32164
|
initializePublishedFontDefaults(doc);
|
|
31875
|
-
|
|
32165
|
+
assertDocumentPaths(doc);
|
|
31876
32166
|
return doc;
|
|
31877
32167
|
}
|
|
31878
32168
|
async write(doc, options, warnings) {
|
|
31879
32169
|
await new ProjectWriter(this._fs).write(doc, options.outputProjectPath);
|
|
31880
|
-
await this.
|
|
31881
|
-
}
|
|
31882
|
-
_assertDocumentPaths(doc) {
|
|
31883
|
-
for (const pkg of doc.getRoot().listPackages()) {
|
|
31884
|
-
assertSafeRestoreSegment(pkg.getName(), "package name");
|
|
31885
|
-
assertSafeRestoreSegment(pkg.getPublishName() || pkg.getName(), "package publish name");
|
|
31886
|
-
for (const resource of pkg.listResources()) {
|
|
31887
|
-
normalizeRestoreResourcePath(resource.getPath?.());
|
|
31888
|
-
const branch = resource.getBranch?.() ?? "";
|
|
31889
|
-
if (branch) assertSafeRestoreSegment(branch, "branch name");
|
|
31890
|
-
const fileName = resourceFileName(resource);
|
|
31891
|
-
if (fileName) assertSafeRestoreSegment(fileName, "resource file name");
|
|
31892
|
-
const publishedFileName = resourcePublishedFileName(resource);
|
|
31893
|
-
if (publishedFileName) assertSafeRestoreSegment(publishedFileName, "published resource file name");
|
|
31894
|
-
}
|
|
31895
|
-
}
|
|
32170
|
+
await restoreAssets(this._fs, doc, options, warnings);
|
|
31896
32171
|
}
|
|
31897
32172
|
_initializeProjectDefaults(doc, projectType) {
|
|
31898
32173
|
doc.getRoot().setProjectId(generateId()).setProjectType(projectType ?? ProjectType.Unity).setVersion("3.0").setSettings({
|
|
@@ -31917,327 +32192,30 @@ var RestoreWorkflow = class {
|
|
|
31917
32192
|
for (const pkg of doc.getRoot().listPackages()) for (const resource of pkg.listResources()) {
|
|
31918
32193
|
if (resource.propertyType !== "ImageResource") continue;
|
|
31919
32194
|
imageFileName(resource);
|
|
31920
|
-
|
|
31921
|
-
...resource.getExtras?.() ?? {},
|
|
31922
|
-
_suppressPackageSize: true
|
|
31923
|
-
});
|
|
32195
|
+
ProjectWriter.setImageWriteHints(resource, { omitPackageSize: true });
|
|
31924
32196
|
}
|
|
31925
32197
|
}
|
|
31926
32198
|
_initializeLooseResourceFileNames(doc) {
|
|
31927
32199
|
for (const pkg of doc.getRoot().listPackages()) for (const resource of pkg.listResources()) {
|
|
31928
|
-
if (
|
|
31929
|
-
|
|
31930
|
-
"SpineResource",
|
|
31931
|
-
"DragonBonesResource",
|
|
31932
|
-
"SoundResource"
|
|
31933
|
-
].includes(resource.propertyType)) continue;
|
|
31934
|
-
const current = resource.getFile?.() ?? "";
|
|
32200
|
+
if (resource.propertyType !== "MiscResource" && resource.propertyType !== "SpineResource" && resource.propertyType !== "DragonBonesResource" && resource.propertyType !== "SoundResource") continue;
|
|
32201
|
+
const current = resource.getFile() ?? "";
|
|
31935
32202
|
if (!current) continue;
|
|
31936
32203
|
const normalized = replaceLooseResourceBaseName(resource, current);
|
|
31937
|
-
if (normalized !== current) resource.setFile
|
|
31938
|
-
}
|
|
31939
|
-
}
|
|
31940
|
-
async _synthesizeLooseSkeletonResources(doc, sourceDir) {
|
|
31941
|
-
for (const pkg of doc.getRoot().listPackages()) for (const resource of [...pkg.listResources()]) {
|
|
31942
|
-
let current = resource;
|
|
31943
|
-
if (resource.propertyType === "DragonBonesResource" && /\.skel\.bytes$/i.test(resourceFileName(resource))) {
|
|
31944
|
-
const normalizedFile = resourceFileName(resource).replace(/\.skel\.bytes$/i, ".skel");
|
|
31945
|
-
const atlasBase = stripExtension(normalizedFile).replace(/-(?:pro|ess)$/i, "-pma");
|
|
31946
|
-
if (await this._resolveLooseSourceFile(pkg, sourceDir, `${atlasBase}.atlas`)) current = this._replaceSkeletonResourceType(doc, pkg, resource, "SpineResource", normalizedFile);
|
|
31947
|
-
}
|
|
31948
|
-
if (current.propertyType === "SpineResource") await this._ensureSpineSidecarResources(doc, pkg, current, sourceDir);
|
|
31949
|
-
else if (current.propertyType === "DragonBonesResource") await this._ensureDragonBonesSidecarResources(doc, pkg, current, sourceDir);
|
|
31950
|
-
}
|
|
31951
|
-
}
|
|
31952
|
-
_initializeRestoredResourceRelations(doc) {
|
|
31953
|
-
for (const pkg of doc.getRoot().listPackages()) {
|
|
31954
|
-
const resources = pkg.listResources();
|
|
31955
|
-
for (const resource of resources) if (resource.propertyType === "SpineResource") this._initializeSpineResourceRelation(resource, resources);
|
|
31956
|
-
else if (resource.propertyType === "DragonBonesResource") this._initializeDragonBonesResourceRelation(resource, resources);
|
|
31957
|
-
}
|
|
31958
|
-
}
|
|
31959
|
-
_replaceSkeletonResourceType(doc, pkg, resource, targetType, fileName) {
|
|
31960
|
-
const replacement = targetType === "SpineResource" ? doc.createSpineResource(resource.getName?.() ?? "") : doc.createDragonBonesResource(resource.getName?.() ?? "");
|
|
31961
|
-
replacement.setId?.(resource.getId?.() ?? "").setPath?.(resource.getPath?.() ?? "/").setFile?.(fileName).setExported?.(resource.getExported?.() ?? false).setWidth?.(resource.getWidth?.() ?? 0).setHeight?.(resource.getHeight?.() ?? 0).setRequireIds?.(resource.getRequireIds?.() ?? []).setAtlasNames?.(resource.getAtlasNames?.() ?? []).setAnchor?.(resource.getAnchorX?.() ?? 0, resource.getAnchorY?.() ?? 0).setBranch?.(resource.getBranch?.() ?? "").setBranchItemIds?.(resource.getBranchItemIds?.() ?? []);
|
|
31962
|
-
replacement.setExtras?.({ ...resource.getExtras?.() ?? {} });
|
|
31963
|
-
pkg.removeResource(resource);
|
|
31964
|
-
pkg.addResource(replacement);
|
|
31965
|
-
return replacement;
|
|
31966
|
-
}
|
|
31967
|
-
async _ensureSpineSidecarResources(doc, pkg, resource, sourceDir) {
|
|
31968
|
-
const skeletonBase = stripExtension(resourceFileName(resource).replace(/\.skel\.bytes$/i, ".skel"));
|
|
31969
|
-
if (!skeletonBase) return;
|
|
31970
|
-
const atlasBase = skeletonBase.replace(/-(?:pro|ess)$/i, "-pma");
|
|
31971
|
-
const atlas = await this._ensureLooseMiscResource(doc, pkg, resource, sourceDir, `${atlasBase}.atlas`);
|
|
31972
|
-
const texture = await this._ensureLooseImageResource(doc, pkg, resource, sourceDir, `${atlasBase}.png`);
|
|
31973
|
-
const requireIds = [atlas?.getId?.(), texture?.getId?.()].filter((id) => !!id);
|
|
31974
|
-
if (requireIds.length > 0) resource.setRequireIds?.(requireIds);
|
|
31975
|
-
if (atlas) resource.setAtlasNames?.([atlasBase]);
|
|
31976
|
-
}
|
|
31977
|
-
async _ensureDragonBonesSidecarResources(doc, pkg, resource, sourceDir) {
|
|
31978
|
-
const skeletonBase = stripExtension(resourceFileName(resource)).replace(/_ske$/i, "");
|
|
31979
|
-
if (!skeletonBase) return;
|
|
31980
|
-
const textureJson = await this._ensureLooseMiscResource(doc, pkg, resource, sourceDir, `${skeletonBase}_tex.json`);
|
|
31981
|
-
const textureImage = await this._ensureLooseImageResource(doc, pkg, resource, sourceDir, `${skeletonBase}.png`);
|
|
31982
|
-
const requireIds = [textureJson?.getId?.(), textureImage?.getId?.()].filter((id) => !!id);
|
|
31983
|
-
if (requireIds.length > 0) resource.setRequireIds?.(requireIds);
|
|
31984
|
-
}
|
|
31985
|
-
async _ensureLooseMiscResource(doc, pkg, owner, sourceDir, fileName) {
|
|
31986
|
-
const resources = pkg.listResources();
|
|
31987
|
-
const existing = this._findResourceByFile(resources, owner, "MiscResource", fileName);
|
|
31988
|
-
if (existing) return existing;
|
|
31989
|
-
const sourcePath = await this._resolveLooseSourceFile(pkg, sourceDir, fileName);
|
|
31990
|
-
if (!sourcePath) return null;
|
|
31991
|
-
const resource = doc.createMiscResource(stripExtension(fileName));
|
|
31992
|
-
resource.setId(generateId()).setPath(owner.getPath?.() ?? "/").setBranch(owner.getBranch?.() ?? "").setBranchItemIds(owner.getBranchItemIds?.() ?? []).setExported(false).setFile(fileName);
|
|
31993
|
-
resource.setExtras?.({
|
|
31994
|
-
...resource.getExtras?.() ?? {},
|
|
31995
|
-
_publishedFile: fileBaseName(sourcePath)
|
|
31996
|
-
});
|
|
31997
|
-
pkg.addResource(resource);
|
|
31998
|
-
return resource;
|
|
31999
|
-
}
|
|
32000
|
-
async _ensureLooseImageResource(doc, pkg, owner, sourceDir, fileName) {
|
|
32001
|
-
const resources = pkg.listResources();
|
|
32002
|
-
const existing = this._findResourceByFile(resources, owner, "ImageResource", fileName);
|
|
32003
|
-
const sourcePath = await this._resolveLooseSourceFile(pkg, sourceDir, fileName);
|
|
32004
|
-
if (!sourcePath) return existing ?? null;
|
|
32005
|
-
if (existing) {
|
|
32006
|
-
existing.setExtras?.({
|
|
32007
|
-
...existing.getExtras?.() ?? {},
|
|
32008
|
-
_publishedFile: fileBaseName(sourcePath),
|
|
32009
|
-
_restoreAsLooseImage: true
|
|
32010
|
-
});
|
|
32011
|
-
return existing;
|
|
32204
|
+
if (normalized !== current) resource.setFile(normalized);
|
|
32012
32205
|
}
|
|
32013
|
-
const resource = doc.createImageResource(stripExtension(fileName));
|
|
32014
|
-
resource.setId(generateId()).setPath(owner.getPath?.() ?? "/").setBranch(owner.getBranch?.() ?? "").setBranchItemIds(owner.getBranchItemIds?.() ?? []).setExported(false).setFileName(fileName);
|
|
32015
|
-
resource.setExtras?.({
|
|
32016
|
-
...resource.getExtras?.() ?? {},
|
|
32017
|
-
_publishedFile: fileBaseName(sourcePath),
|
|
32018
|
-
_suppressPackageSize: true,
|
|
32019
|
-
_restoreAsLooseImage: true
|
|
32020
|
-
});
|
|
32021
|
-
pkg.addResource(resource);
|
|
32022
|
-
return resource;
|
|
32023
32206
|
}
|
|
32024
32207
|
_initializeDisplayObjectFileNames(doc) {
|
|
32025
32208
|
for (const pkg of doc.getRoot().listPackages()) for (const component of pkg.listComponents()) for (const child of component.listChildren()) {
|
|
32026
|
-
if (!child
|
|
32209
|
+
if (!(child instanceof GComponent || child instanceof GImage || child instanceof GMovieClip) || child.getFileName()) continue;
|
|
32027
32210
|
const resource = this._resolveDisplayObjectResource(doc, pkg, child);
|
|
32028
32211
|
const fileName = resource ? resourceInstanceFileName(resource) : "";
|
|
32029
32212
|
if (fileName) child.setFileName(fileName);
|
|
32030
32213
|
}
|
|
32031
32214
|
}
|
|
32032
32215
|
_resolveDisplayObjectResource(doc, pkg, child) {
|
|
32033
|
-
const src = child.getSrc
|
|
32216
|
+
const src = child.getSrc() ?? "";
|
|
32034
32217
|
if (!src) return null;
|
|
32035
|
-
return (child.getPackageId
|
|
32036
|
-
}
|
|
32037
|
-
_initializeSpineResourceRelation(resource, resources) {
|
|
32038
|
-
const skeletonBase = stripExtension(resourceFileName(resource));
|
|
32039
|
-
if (!skeletonBase) return;
|
|
32040
|
-
const atlasBase = skeletonBase.replace(/-(?:pro|ess)$/i, "-pma");
|
|
32041
|
-
const requireIds = [];
|
|
32042
|
-
const atlas = this._findResourceByFile(resources, resource, "MiscResource", `${atlasBase}.atlas`);
|
|
32043
|
-
const texture = this._findResourceByFile(resources, resource, "ImageResource", `${atlasBase}.png`);
|
|
32044
|
-
if (atlas?.getId?.()) requireIds.push(atlas.getId());
|
|
32045
|
-
if (texture?.getId?.()) requireIds.push(texture.getId());
|
|
32046
|
-
if (requireIds.length > 0) resource.setRequireIds?.(requireIds);
|
|
32047
|
-
if (atlas) resource.setAtlasNames?.([atlasBase]);
|
|
32048
|
-
}
|
|
32049
|
-
_initializeDragonBonesResourceRelation(resource, resources) {
|
|
32050
|
-
const skeletonBase = stripExtension(resourceFileName(resource)).replace(/_ske$/i, "");
|
|
32051
|
-
if (!skeletonBase) return;
|
|
32052
|
-
const requireIds = [];
|
|
32053
|
-
const textureJson = this._findResourceByFile(resources, resource, "MiscResource", `${skeletonBase}_tex.json`);
|
|
32054
|
-
const textureImage = this._findResourceByFile(resources, resource, "ImageResource", `${skeletonBase}.png`);
|
|
32055
|
-
if (textureJson?.getId?.()) requireIds.push(textureJson.getId());
|
|
32056
|
-
if (textureImage?.getId?.()) requireIds.push(textureImage.getId());
|
|
32057
|
-
if (requireIds.length > 0) resource.setRequireIds?.(requireIds);
|
|
32058
|
-
}
|
|
32059
|
-
_findResourceByFile(resources, owner, propertyType, fileName) {
|
|
32060
|
-
const expected = fileName.toLowerCase();
|
|
32061
|
-
return resources.find((resource) => {
|
|
32062
|
-
return resource.propertyType === propertyType && sameVirtualPath(owner, resource) && fileBaseName(resourceFileName(resource)).toLowerCase() === expected;
|
|
32063
|
-
}) ?? null;
|
|
32064
|
-
}
|
|
32065
|
-
async _restoreAssets(doc, options, warnings) {
|
|
32066
|
-
for (const pkg of doc.getRoot().listPackages()) {
|
|
32067
|
-
await this._restoreAtlasImages(pkg, options);
|
|
32068
|
-
await this._writeGeneratedResources(pkg, options, warnings);
|
|
32069
|
-
await this._copyLooseResources(pkg, options, warnings);
|
|
32070
|
-
}
|
|
32071
|
-
}
|
|
32072
|
-
async _restoreAtlasImages(pkg, options) {
|
|
32073
|
-
if (!options.cropImage) return;
|
|
32074
|
-
for (const atlas of pkg.listAtlases()) {
|
|
32075
|
-
const sourceAtlas = await this._resolveSourceFile(options.sourceDir, this._sourceFileCandidates(pkg, atlas.getFile()));
|
|
32076
|
-
if (!sourceAtlas) throw new Error(`Atlas image not found for package "${pkg.getName()}": ${this._sourceFileCandidates(pkg, atlas.getFile()).join(", ")}`);
|
|
32077
|
-
for (const sprite of atlas.listSprites()) {
|
|
32078
|
-
const image = findImageResource(pkg, sprite.getItemId());
|
|
32079
|
-
if (!image) continue;
|
|
32080
|
-
if (sprite.getRectWidth() <= 0 || sprite.getRectHeight() <= 0) continue;
|
|
32081
|
-
const outputPath = this._resourceOutputPath(options.outputProjectPath, pkg, image, imageFileName(image));
|
|
32082
|
-
const imageWidth = image.getWidth?.() ?? 0;
|
|
32083
|
-
const imageHeight = image.getHeight?.() ?? 0;
|
|
32084
|
-
const spriteWidth = sprite.getRotated() ? sprite.getRectHeight() : sprite.getRectWidth();
|
|
32085
|
-
const spriteHeight = sprite.getRotated() ? sprite.getRectWidth() : sprite.getRectHeight();
|
|
32086
|
-
await this._mkdirForFile(outputPath);
|
|
32087
|
-
await options.cropImage({
|
|
32088
|
-
sourcePath: sourceAtlas,
|
|
32089
|
-
outputPath,
|
|
32090
|
-
left: sprite.getRectX(),
|
|
32091
|
-
top: sprite.getRectY(),
|
|
32092
|
-
width: sprite.getRectWidth(),
|
|
32093
|
-
height: sprite.getRectHeight(),
|
|
32094
|
-
rotated: sprite.getRotated(),
|
|
32095
|
-
offsetX: sprite.getOffsetX(),
|
|
32096
|
-
offsetY: sprite.getOffsetY(),
|
|
32097
|
-
expectedWidth: Math.max(imageWidth, sprite.getOriginalWidth(), spriteWidth),
|
|
32098
|
-
expectedHeight: Math.max(imageHeight, sprite.getOriginalHeight(), spriteHeight)
|
|
32099
|
-
});
|
|
32100
|
-
}
|
|
32101
|
-
}
|
|
32102
|
-
}
|
|
32103
|
-
async _copyLooseResources(pkg, options, warnings) {
|
|
32104
|
-
for (const resource of pkg.listResources()) {
|
|
32105
|
-
const restoreAsLooseImage = resource.getExtras?.()?._restoreAsLooseImage === true;
|
|
32106
|
-
if (![
|
|
32107
|
-
"SoundResource",
|
|
32108
|
-
"MiscResource",
|
|
32109
|
-
"SpineResource",
|
|
32110
|
-
"DragonBonesResource"
|
|
32111
|
-
].includes(resource.propertyType) && !restoreAsLooseImage) continue;
|
|
32112
|
-
const fileName = resourceFileName(resource);
|
|
32113
|
-
if (!fileName) continue;
|
|
32114
|
-
const sourcePath = await this._resolveSourceFile(options.sourceDir, this._sourceFileCandidates(pkg, resourcePublishedFileName(resource), fileName));
|
|
32115
|
-
if (!sourcePath) {
|
|
32116
|
-
warnings.push(`Loose resource not found for package "${pkg.getName()}": ${fileName}`);
|
|
32117
|
-
continue;
|
|
32118
|
-
}
|
|
32119
|
-
const outputPath = this._resourceOutputPath(options.outputProjectPath, pkg, resource, fileName);
|
|
32120
|
-
await this._mkdirForFile(outputPath);
|
|
32121
|
-
await this._fs.writeFileRaw(outputPath, await this._fs.readFileRaw(sourcePath));
|
|
32122
|
-
}
|
|
32123
|
-
}
|
|
32124
|
-
async _writeGeneratedResources(pkg, options, warnings) {
|
|
32125
|
-
for (const resource of pkg.listResources()) if (resource.propertyType === "FontResource") await this._writeFontFile(pkg, resource, options.outputProjectPath);
|
|
32126
|
-
else if (resource.propertyType === "MovieClipResource") await this._writeMovieClipFile(pkg, resource, options, warnings);
|
|
32127
|
-
await this._writeSyntheticFontGlyphImages(pkg, options.outputProjectPath);
|
|
32128
|
-
}
|
|
32129
|
-
async _writeFontFile(pkg, resource, outputProjectPath) {
|
|
32130
|
-
const fileName = resourceFileName(resource);
|
|
32131
|
-
if (!/\.fnt$/i.test(fileName)) return;
|
|
32132
|
-
const glyphs = resource.listGlyphs?.() ?? [];
|
|
32133
|
-
if (glyphs.length === 0) return;
|
|
32134
|
-
const outputPath = this._resourceOutputPath(outputProjectPath, pkg, resource, fileName);
|
|
32135
|
-
await this._mkdirForFile(outputPath);
|
|
32136
|
-
await this._fs.writeFile(outputPath, serializeFont(pkg, resource, glyphs));
|
|
32137
|
-
}
|
|
32138
|
-
async _writeMovieClipFile(pkg, resource, options, warnings) {
|
|
32139
|
-
const fileName = resourceFileName(resource);
|
|
32140
|
-
if (!/\.jta$/i.test(fileName)) return;
|
|
32141
|
-
const frames = resource.listFrames?.() ?? [];
|
|
32142
|
-
if (frames.length === 0) return;
|
|
32143
|
-
if (!options.extractImage) {
|
|
32144
|
-
warnings.push(`MovieClip file not generated for package "${pkg.getName()}": ${fileName}`);
|
|
32145
|
-
return;
|
|
32146
|
-
}
|
|
32147
|
-
const sprites = await this._buildSpriteLookup(pkg, options);
|
|
32148
|
-
const textures = [];
|
|
32149
|
-
for (const [index, frame] of frames.entries()) {
|
|
32150
|
-
const spriteEntry = sprites.get(frame.getSpriteId());
|
|
32151
|
-
if (!spriteEntry) {
|
|
32152
|
-
warnings.push(`MovieClip frame sprite not found for package "${pkg.getName()}": ${fileName} frame ${index}`);
|
|
32153
|
-
return;
|
|
32154
|
-
}
|
|
32155
|
-
const sprite = spriteEntry.sprite;
|
|
32156
|
-
if (sprite.getRectWidth() <= 0 || sprite.getRectHeight() <= 0) {
|
|
32157
|
-
textures.push(new Uint8Array(0));
|
|
32158
|
-
continue;
|
|
32159
|
-
}
|
|
32160
|
-
textures.push(await options.extractImage({
|
|
32161
|
-
sourcePath: spriteEntry.sourceAtlas,
|
|
32162
|
-
left: sprite.getRectX(),
|
|
32163
|
-
top: sprite.getRectY(),
|
|
32164
|
-
width: sprite.getRectWidth(),
|
|
32165
|
-
height: sprite.getRectHeight(),
|
|
32166
|
-
rotated: sprite.getRotated(),
|
|
32167
|
-
offsetX: 0,
|
|
32168
|
-
offsetY: 0,
|
|
32169
|
-
expectedWidth: sprite.getRotated() ? sprite.getRectHeight() : sprite.getRectWidth(),
|
|
32170
|
-
expectedHeight: sprite.getRotated() ? sprite.getRectWidth() : sprite.getRectHeight()
|
|
32171
|
-
}));
|
|
32172
|
-
}
|
|
32173
|
-
const outputPath = this._resourceOutputPath(options.outputProjectPath, pkg, resource, fileName);
|
|
32174
|
-
await this._mkdirForFile(outputPath);
|
|
32175
|
-
await this._fs.writeFileRaw(outputPath, serializeMovieClip(resource, frames, textures));
|
|
32176
|
-
}
|
|
32177
|
-
async _writeSyntheticFontGlyphImages(pkg, outputProjectPath) {
|
|
32178
|
-
for (const resource of pkg.listResources()) {
|
|
32179
|
-
if (resource.propertyType !== "ImageResource" || !isSyntheticFontGlyphResource(resource)) continue;
|
|
32180
|
-
const fileName = resourceFileName(resource) || defaultSyntheticFontGlyphFileName(resource.getId?.() ?? "glyph");
|
|
32181
|
-
const outputPath = this._resourceOutputPath(outputProjectPath, pkg, resource, fileName);
|
|
32182
|
-
await this._mkdirForFile(outputPath);
|
|
32183
|
-
await this._fs.writeFileRaw(outputPath, TRANSPARENT_PNG_1X1);
|
|
32184
|
-
}
|
|
32185
|
-
}
|
|
32186
|
-
async _buildSpriteLookup(pkg, options) {
|
|
32187
|
-
const sprites = /* @__PURE__ */ new Map();
|
|
32188
|
-
for (const atlas of pkg.listAtlases()) {
|
|
32189
|
-
const sourceAtlas = await this._resolveSourceFile(options.sourceDir, this._sourceFileCandidates(pkg, atlas.getFile()));
|
|
32190
|
-
if (!sourceAtlas) throw new Error(`Atlas image not found for package "${pkg.getName()}": ${this._sourceFileCandidates(pkg, atlas.getFile()).join(", ")}`);
|
|
32191
|
-
for (const sprite of atlas.listSprites()) sprites.set(sprite.getItemId(), {
|
|
32192
|
-
sourceAtlas,
|
|
32193
|
-
sprite
|
|
32194
|
-
});
|
|
32195
|
-
}
|
|
32196
|
-
return sprites;
|
|
32197
|
-
}
|
|
32198
|
-
_sourceFileCandidates(pkg, fileName, outputFileName = fileName) {
|
|
32199
|
-
const publishName = pkg.getPublishName() || pkg.getName();
|
|
32200
|
-
assertSafeRestoreSegment(publishName, "package publish name");
|
|
32201
|
-
assertSafeRestoreSegment(fileName, "published source file name");
|
|
32202
|
-
assertSafeRestoreSegment(outputFileName, "published source file name");
|
|
32203
|
-
const candidates = Array.from(new Set([
|
|
32204
|
-
`${publishName}_${fileName}`,
|
|
32205
|
-
fileName,
|
|
32206
|
-
`${publishName}_${outputFileName}`,
|
|
32207
|
-
outputFileName
|
|
32208
|
-
]));
|
|
32209
|
-
for (const candidate of candidates) assertSafeRestoreSegment(candidate, "published source file name");
|
|
32210
|
-
return candidates;
|
|
32211
|
-
}
|
|
32212
|
-
async _resolveLooseSourceFile(pkg, sourceDir, outputFileName) {
|
|
32213
|
-
const candidates = outputFileName.endsWith(".atlas") ? this._sourceFileCandidates(pkg, `${outputFileName}.txt`, outputFileName) : outputFileName.endsWith(".skel") ? this._sourceFileCandidates(pkg, `${outputFileName}.bytes`, outputFileName) : this._sourceFileCandidates(pkg, outputFileName);
|
|
32214
|
-
return this._resolveSourceFile(sourceDir, candidates);
|
|
32215
|
-
}
|
|
32216
|
-
async _resolveSourceFile(sourceDir, candidates) {
|
|
32217
|
-
const resolvedSourceDir = await Promise.resolve(this._fs.resolvePath(sourceDir));
|
|
32218
|
-
for (const candidate of candidates) {
|
|
32219
|
-
assertSafeRestoreSegment(candidate, "published source file name");
|
|
32220
|
-
const sourcePath = this._fs.join(sourceDir, candidate);
|
|
32221
|
-
if (!await this._fs.isFile(sourcePath)) continue;
|
|
32222
|
-
const resolvedSourcePath = await Promise.resolve(this._fs.resolvePath(sourcePath));
|
|
32223
|
-
if (!isPathWithin(resolvedSourceDir, resolvedSourcePath)) throw new Error(`restore: Published source file resolves outside the input directory: ${candidate}.`);
|
|
32224
|
-
return resolvedSourcePath;
|
|
32225
|
-
}
|
|
32226
|
-
return null;
|
|
32227
|
-
}
|
|
32228
|
-
_resourceOutputPath(outputProjectPath, pkg, resource, fileName) {
|
|
32229
|
-
const basePath = this._fs.dirname(outputProjectPath);
|
|
32230
|
-
const branch = resource.getBranch?.() ?? "";
|
|
32231
|
-
assertSafeRestoreSegment(pkg.getName(), "package name");
|
|
32232
|
-
if (branch) assertSafeRestoreSegment(branch, "branch name");
|
|
32233
|
-
assertSafeRestoreSegment(fileName, "resource file name");
|
|
32234
|
-
const assetsDir = branch ? `assets_${branch}` : "assets";
|
|
32235
|
-
const virtualPath = normalizeRestoreResourcePath(resource.getPath?.());
|
|
32236
|
-
const pkgDir = this._fs.join(basePath, assetsDir, pkg.getName());
|
|
32237
|
-
return virtualPath ? this._fs.join(pkgDir, virtualPath, fileName) : this._fs.join(pkgDir, fileName);
|
|
32238
|
-
}
|
|
32239
|
-
async _mkdirForFile(filePath) {
|
|
32240
|
-
await this._fs.mkdir(this._fs.dirname(filePath));
|
|
32218
|
+
return (child.getPackageId() ? doc.getRoot().getPackageById(child.getPackageId() ?? "") : pkg)?.getResourceById(src) ?? null;
|
|
32241
32219
|
}
|
|
32242
32220
|
};
|
|
32243
32221
|
//#endregion
|
|
@@ -32646,6 +32624,7 @@ function _computeDependencies(doc, pkg, pkgMap) {
|
|
|
32646
32624
|
var NodeIO = class extends PlatformIO {
|
|
32647
32625
|
createFileSystem() {
|
|
32648
32626
|
return {
|
|
32627
|
+
resolvePath: (filePath) => fs$1.realpath(filePath),
|
|
32649
32628
|
async readFile(filePath) {
|
|
32650
32629
|
return fs$1.readFile(filePath, "utf-8");
|
|
32651
32630
|
},
|
|
@@ -33287,7 +33266,7 @@ function registerValidateCommand(program) {
|
|
|
33287
33266
|
//#region src/utils/package-version.ts
|
|
33288
33267
|
const require$1 = createRequire(import.meta.url);
|
|
33289
33268
|
function getInjectedPackageVersion() {
|
|
33290
|
-
const version = "0.
|
|
33269
|
+
const version = "0.6.0";
|
|
33291
33270
|
return typeof version === "string" && true ? version : null;
|
|
33292
33271
|
}
|
|
33293
33272
|
function readPackageVersion() {
|