132 lines
4.1 KiB
TypeScript
132 lines
4.1 KiB
TypeScript
// Metro module 8087 (f8088).
|
|
import _toArray from "../../../../_bundle/_toArray";
|
|
import { ProfileFrameLayerOrder } from "../../../../_bundle/Module8088";
|
|
import { ProfileFrameLayerType } from "../../../../_bundle/Module8089";
|
|
import { ProfileFrameLayerAnchor } from "../../../../_bundle/Module8090";
|
|
let c5131_3 = "preview";
|
|
let c5131_4 = "responsive";
|
|
const r33 = {
|
|
foreground: ProfileFrameLayerOrder.FRONT,
|
|
background: ProfileFrameLayerOrder.BACK
|
|
};
|
|
let c5131_5 = new Set([ProfileFrameLayerType.STAPLE, ProfileFrameLayerType.RAIL, ProfileFrameLayerType.BORDER]);
|
|
let c5131_6 = new Set([ProfileFrameLayerAnchor.TOP, ProfileFrameLayerAnchor.BOTTOM, ProfileFrameLayerAnchor.CENTER]);
|
|
let c5131_7 = {
|
|
WRONG_PART_COUNT: "wrong_part_count",
|
|
INVALID_INDEX: "invalid_index",
|
|
INVALID_TYPE: "invalid_type",
|
|
INVALID_ANCHOR: "invalid_anchor",
|
|
INVALID_RESPONSIVE: "invalid_responsive",
|
|
BORDER_HAS_ANCHOR: "border_has_anchor"
|
|
};
|
|
const r79 = {};
|
|
r79[c5131_7.WRONG_PART_COUNT] = "wrong filename format";
|
|
r79[c5131_7.INVALID_INDEX] = "invalid index";
|
|
r79[c5131_7.INVALID_TYPE] = `invalid type (expected: ${[...c5131_5].join(", ")})`;
|
|
r79[c5131_7.INVALID_ANCHOR] = `invalid anchor (expected: ${[...c5131_6].join(", ")})`;
|
|
r79[c5131_7.INVALID_RESPONSIVE] = `invalid suffix (expected 'responsive')`;
|
|
r79[c5131_7.BORDER_HAS_ANCHOR] = "border layers must omit the anchor";
|
|
const r109 = {};
|
|
r109[ProfileFrameLayerOrder.FRONT] = 0;
|
|
r109[ProfileFrameLayerOrder.BACK] = 1;
|
|
let c5131_8 = r109;
|
|
export const PREVIEW_FILENAME = "preview";
|
|
export const RESPONSIVE_KEYWORD = "responsive";
|
|
export { r33 as FOLDER_ORDER_MAP };
|
|
export { c5131_7 as ParseErrorKind };
|
|
export { r79 as PARSE_ERROR_LABELS };
|
|
export function parseLayerFilename(a0) {
|
|
const r18 = a0.replace(/\.\w+$/, "").split("_");
|
|
if (!(r18.length < 2) && !(r18.length > 4)) {
|
|
const r22 = _toArray(r18);
|
|
const r13 = r22[0];
|
|
const type = r22[1];
|
|
const r24 = r22.slice(2);
|
|
if (/^\d+$/.test(r13)) {
|
|
if (c5131_5.has(type)) {
|
|
if (type === ProfileFrameLayerType.BORDER) {
|
|
if (r24.length > 0 && c5131_6.has(r24[0])) {
|
|
return {
|
|
parsed: null,
|
|
errorType: c5131_7.BORDER_HAS_ANCHOR
|
|
};
|
|
}
|
|
if (r24.length > 1) {
|
|
return {
|
|
parsed: null,
|
|
errorType: c5131_7.WRONG_PART_COUNT
|
|
};
|
|
}
|
|
if (r24.length === 1 && r24[0] !== c5131_4) {
|
|
return {
|
|
parsed: null,
|
|
errorType: c5131_7.INVALID_RESPONSIVE
|
|
};
|
|
}
|
|
const length = r24.length;
|
|
return {
|
|
parsed: {
|
|
index: Number(r13),
|
|
type,
|
|
anchor: ProfileFrameLayerAnchor.CENTER,
|
|
responsive: length === 1
|
|
},
|
|
errorType: null
|
|
};
|
|
}
|
|
const anchor = r24[0];
|
|
if (anchor != null && c5131_6.has(anchor)) {
|
|
if (r24.length > 2) {
|
|
return {
|
|
parsed: null,
|
|
errorType: c5131_7.WRONG_PART_COUNT
|
|
};
|
|
}
|
|
if (r24.length === 2 && r24[1] !== c5131_4) {
|
|
return {
|
|
parsed: null,
|
|
errorType: c5131_7.INVALID_RESPONSIVE
|
|
};
|
|
}
|
|
const responsive = r24.length === 2 || type === ProfileFrameLayerType.RAIL;
|
|
return {
|
|
parsed: {
|
|
index: Number(r13),
|
|
type,
|
|
anchor,
|
|
responsive
|
|
},
|
|
errorType: null
|
|
};
|
|
}
|
|
return {
|
|
parsed: null,
|
|
errorType: c5131_7.INVALID_ANCHOR
|
|
};
|
|
}
|
|
return {
|
|
parsed: null,
|
|
errorType: c5131_7.INVALID_TYPE
|
|
};
|
|
}
|
|
return {
|
|
parsed: null,
|
|
errorType: c5131_7.INVALID_INDEX
|
|
};
|
|
}
|
|
return {
|
|
parsed: null,
|
|
errorType: c5131_7.WRONG_PART_COUNT
|
|
};
|
|
}
|
|
export function compareLayerFiles(a0, a1) {
|
|
let r9 = c5131_8[a0.order] - c5131_8[a1.order];
|
|
if (r9 === 0) {
|
|
r9 = a0.index - a1.index;
|
|
}
|
|
return r9;
|
|
}
|
|
export function isPreviewFilename(a0) {
|
|
return a0.replace(/\.\w+$/, "") === c5131_3;
|
|
}
|