@cataract6545/tmui
Version:
tm-vuetify是一个新势力由主题驱动的UI组件库,相比其它优势大,组件全,设计趋势紧跟未来。具有主题生成,主题实时切换,暗黑实时切换,lottie动画,图表等新颖功能,tmui TMUI
1,588 lines (1,546 loc) • 119 kB
JavaScript
/////////////////////////////////////////////////////////////////////////////////////////////////
//
// Tencent is pleased to support the open source community by making libpag available.
//
// Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// unless required by applicable law or agreed to in writing, software distributed under the
// license is distributed on an "as is" basis, without warranties or conditions of any kind,
// either express or implied. see the license for the specific language governing permissions
// and limitations under the license.
//
/////////////////////////////////////////////////////////////////////////////////////////////////
let getTime;
try {
getTime = performance.now.bind(performance);
} catch (e) {
getTime = Date.now;
}
class Clock {
constructor() {
this.startTime = getTime();
this.markers = {};
}
reset() {
this.startTime = getTime();
this.markers = {};
}
mark(key) {
if (!key) {
console.log("Clock.mark(): An empty marker name was specified!");
return;
}
if (Object.keys(this.markers).find((markerKey) => markerKey === key)) {
console.log(`Clock.mark(): The specified marker name '${key}' already exists!`);
return;
}
this.markers[key] = getTime();
}
measure(makerFrom, makerTo) {
let start;
let end;
if (!makerFrom) {
start = this.startTime;
} else {
if (!Object.keys(this.markers).find((markerKey) => markerKey === makerFrom)) {
console.log(`Clock.measure(): The specified makerFrom '${makerFrom}' does not exist!`);
return 0;
}
start = this.markers[makerFrom];
}
if (!makerTo) {
end = getTime();
} else {
if (!Object.keys(this.markers).find((markerKey) => markerKey === makerTo)) {
console.log(`Clock.measure(): The specified makerTo '${makerTo}' does not exist!`);
return 0;
}
end = this.markers[makerTo];
}
return end - start;
}
}
var CompositionType = /* @__PURE__ */ ((CompositionType2) => {
CompositionType2[CompositionType2["Unknown"] = 0] = "Unknown";
CompositionType2[CompositionType2["Vector"] = 1] = "Vector";
CompositionType2[CompositionType2["Bitmap"] = 2] = "Bitmap";
CompositionType2[CompositionType2["Video"] = 3] = "Video";
return CompositionType2;
})(CompositionType || {});
var TagCode = /* @__PURE__ */ ((TagCode2) => {
TagCode2[TagCode2["End"] = 0] = "End";
TagCode2[TagCode2["FontTables"] = 1] = "FontTables";
TagCode2[TagCode2["VectorCompositionBlock"] = 2] = "VectorCompositionBlock";
TagCode2[TagCode2["CompositionAttributes"] = 3] = "CompositionAttributes";
TagCode2[TagCode2["ImageTables"] = 4] = "ImageTables";
TagCode2[TagCode2["LayerBlock"] = 5] = "LayerBlock";
TagCode2[TagCode2["LayerAttributes"] = 6] = "LayerAttributes";
TagCode2[TagCode2["SolidColor"] = 7] = "SolidColor";
TagCode2[TagCode2["TextSource"] = 8] = "TextSource";
TagCode2[TagCode2["TextPathOption"] = 9] = "TextPathOption";
TagCode2[TagCode2["TextMoreOption"] = 10] = "TextMoreOption";
TagCode2[TagCode2["ImageReference"] = 11] = "ImageReference";
TagCode2[TagCode2["CompositionReference"] = 12] = "CompositionReference";
TagCode2[TagCode2["Transform2D"] = 13] = "Transform2D";
TagCode2[TagCode2["MaskBlock"] = 14] = "MaskBlock";
TagCode2[TagCode2["ShapeGroup"] = 15] = "ShapeGroup";
TagCode2[TagCode2["Rectangle"] = 16] = "Rectangle";
TagCode2[TagCode2["Ellipse"] = 17] = "Ellipse";
TagCode2[TagCode2["PolyStar"] = 18] = "PolyStar";
TagCode2[TagCode2["ShapePath"] = 19] = "ShapePath";
TagCode2[TagCode2["Fill"] = 20] = "Fill";
TagCode2[TagCode2["Stroke"] = 21] = "Stroke";
TagCode2[TagCode2["GradientFill"] = 22] = "GradientFill";
TagCode2[TagCode2["GradientStroke"] = 23] = "GradientStroke";
TagCode2[TagCode2["MergePaths"] = 24] = "MergePaths";
TagCode2[TagCode2["TrimPaths"] = 25] = "TrimPaths";
TagCode2[TagCode2["Repeater"] = 26] = "Repeater";
TagCode2[TagCode2["RoundCorners"] = 27] = "RoundCorners";
TagCode2[TagCode2["Performance"] = 28] = "Performance";
TagCode2[TagCode2["DropShadowStyle"] = 29] = "DropShadowStyle";
TagCode2[TagCode2["InnerShadowStyle"] = 30] = "InnerShadowStyle";
TagCode2[TagCode2["OuterGlowStyle"] = 31] = "OuterGlowStyle";
TagCode2[TagCode2["InnerGlowStyle"] = 32] = "InnerGlowStyle";
TagCode2[TagCode2["BevelAndEmbossStyle"] = 33] = "BevelAndEmbossStyle";
TagCode2[TagCode2["SatinStyle"] = 34] = "SatinStyle";
TagCode2[TagCode2["ColorOverlayStyle"] = 35] = "ColorOverlayStyle";
TagCode2[TagCode2["GradientOverlayStyle"] = 36] = "GradientOverlayStyle";
TagCode2[TagCode2["StrokeStyle"] = 37] = "StrokeStyle";
TagCode2[TagCode2["TintEffect"] = 38] = "TintEffect";
TagCode2[TagCode2["FillEffect"] = 39] = "FillEffect";
TagCode2[TagCode2["StrokeEffect"] = 40] = "StrokeEffect";
TagCode2[TagCode2["TritoneEffect"] = 41] = "TritoneEffect";
TagCode2[TagCode2["DropShadowEffect"] = 42] = "DropShadowEffect";
TagCode2[TagCode2["RadialWipeEffect"] = 43] = "RadialWipeEffect";
TagCode2[TagCode2["DisplacementMapEffect"] = 44] = "DisplacementMapEffect";
TagCode2[TagCode2["BitmapCompositionBlock"] = 45] = "BitmapCompositionBlock";
TagCode2[TagCode2["BitmapSequence"] = 46] = "BitmapSequence";
TagCode2[TagCode2["ImageBytes"] = 47] = "ImageBytes";
TagCode2[TagCode2["ImageBytes2"] = 48] = "ImageBytes2";
TagCode2[TagCode2["ImageBytes3"] = 49] = "ImageBytes3";
TagCode2[TagCode2["VideoCompositionBlock"] = 50] = "VideoCompositionBlock";
TagCode2[TagCode2["VideoSequence"] = 51] = "VideoSequence";
TagCode2[TagCode2["LayerAttributesV2"] = 52] = "LayerAttributesV2";
TagCode2[TagCode2["Count"] = 53] = "Count";
return TagCode2;
})(TagCode || {});
const readTagHeader = (byteBuffer) => {
const codeAndLength = byteBuffer.readUint16();
let length = (codeAndLength & 63) >>> 0;
const code = codeAndLength >> 6;
if (length === 63) {
length = byteBuffer.readUint32();
}
if (byteBuffer.context.tagLevel < code) {
byteBuffer.context.tagLevel = code;
}
return { code, length };
};
function readTags(byteArray, parameter, reader) {
let header = readTagHeader(byteArray);
while (header.code !== TagCode.End) {
const tagBytes = byteArray.readBytes(header.length);
reader(tagBytes, header.code, parameter);
if (byteArray.context.tagLevel < tagBytes.context.tagLevel) {
byteArray.context.tagLevel = tagBytes.context.tagLevel;
}
header = readTagHeader(byteArray);
}
}
const ZERO_ID = 0;
const ZERO_TIME = 0;
const OPAQUE = 255;
const WEBGL_CONTEXT_ATTRIBUTES = {
alpha: true,
depth: false,
stencil: false,
antialias: false
};
var BlendMode = /* @__PURE__ */ ((BlendMode2) => {
BlendMode2[BlendMode2["Normal"] = 0] = "Normal";
BlendMode2[BlendMode2["Multiply"] = 1] = "Multiply";
BlendMode2[BlendMode2["Screen"] = 2] = "Screen";
BlendMode2[BlendMode2["Overlay"] = 3] = "Overlay";
BlendMode2[BlendMode2["Darken"] = 4] = "Darken";
BlendMode2[BlendMode2["Lighten"] = 5] = "Lighten";
BlendMode2[BlendMode2["ColorDodge"] = 6] = "ColorDodge";
BlendMode2[BlendMode2["ColorBurn"] = 7] = "ColorBurn";
BlendMode2[BlendMode2["HardLight"] = 8] = "HardLight";
BlendMode2[BlendMode2["SoftLight"] = 9] = "SoftLight";
BlendMode2[BlendMode2["Difference"] = 10] = "Difference";
BlendMode2[BlendMode2["Exclusion"] = 11] = "Exclusion";
BlendMode2[BlendMode2["Hue"] = 12] = "Hue";
BlendMode2[BlendMode2["Saturation"] = 13] = "Saturation";
BlendMode2[BlendMode2["Color"] = 14] = "Color";
BlendMode2[BlendMode2["Luminosity"] = 15] = "Luminosity";
BlendMode2[BlendMode2["DestinationIn"] = 21] = "DestinationIn";
BlendMode2[BlendMode2["DestinationOut"] = 22] = "DestinationOut";
BlendMode2[BlendMode2["DestinationATop"] = 23] = "DestinationATop";
BlendMode2[BlendMode2["SourceIn"] = 24] = "SourceIn";
BlendMode2[BlendMode2["SourceOut"] = 25] = "SourceOut";
BlendMode2[BlendMode2["Xor"] = 26] = "Xor";
return BlendMode2;
})(BlendMode || {});
var KeyframeInterpolationType = /* @__PURE__ */ ((KeyframeInterpolationType2) => {
KeyframeInterpolationType2[KeyframeInterpolationType2["None"] = 0] = "None";
KeyframeInterpolationType2[KeyframeInterpolationType2["Linear"] = 1] = "Linear";
KeyframeInterpolationType2[KeyframeInterpolationType2["Bezier"] = 2] = "Bezier";
KeyframeInterpolationType2[KeyframeInterpolationType2["Hold"] = 3] = "Hold";
return KeyframeInterpolationType2;
})(KeyframeInterpolationType || {});
const IS_IOS = navigator && /(ios|ipad|iphone)/.test(navigator.userAgent.toLowerCase());
const Black = { red: 0, green: 0, blue: 0 };
const White = { red: 255, green: 255, blue: 255 };
const verifyFailed = () => {
console.error("PAG Verify Failed!");
};
const verifyAndReturn = (expression) => {
if (expression) {
return true;
}
console.error("PAG Verify Failed!");
return false;
};
const _Composition = class {
constructor() {
this.id = ZERO_ID;
this.width = 0;
this.height = 0;
this.duration = ZERO_TIME;
this.frameRate = 30;
this.backgroundColor = White;
this.cacheID = 0;
this.cacheID = _Composition.cacheIDCount;
_Composition.cacheIDCount += 1;
}
type() {
return CompositionType.Unknown;
}
getStaticTimeRanges() {
return [];
}
verify() {
return verifyAndReturn(this.width > 0 && this.height > 0 && this.duration > 0 && this.frameRate > 0);
}
};
let Composition = _Composition;
Composition.cacheIDCount = 1;
class VideoComposition extends Composition {
constructor() {
super(...arguments);
this.hasAlpha = false;
this.sequences = [];
this.staticTimeRanges = [];
this.staticTimeRangeUpdated = false;
}
type() {
return CompositionType.Video;
}
getStaticTimeRanges() {
if (!this.staticTimeRangeUpdated) {
this.staticTimeRangeUpdated = true;
this.updateStaticTimeRanges();
}
return this.staticTimeRanges;
}
updateStaticTimeRanges() {
if (this.duration <= 1)
return;
if (this.sequences.length > 0) {
let sequence = this.sequences[0];
for (let i = 1; i < this.sequences.length; i++) {
const item = this.sequences[i];
if (item.frameRate > sequence.frameRate)
sequence = item;
}
const timeScale = this.frameRate / sequence.frameRate;
for (const timeRange of sequence.staticTimeRanges) {
timeRange.start = Math.round(timeRange.start * timeScale);
timeRange.end = Math.round(timeRange.end * timeScale);
this.staticTimeRanges.push(timeRange);
}
} else {
const range = { start: 0, end: this.duration - 1 };
this.staticTimeRanges.push(range);
}
}
hasImageContent() {
return true;
}
verify() {
if (!super.verify() || this.sequences.length <= 0) {
verifyFailed();
return false;
}
for (const sequence of this.sequences) {
if (!sequence || !sequence.verify()) {
verifyFailed();
return false;
}
}
return true;
}
}
class Ratio {
constructor(numerator, denominator) {
this.numerator = 1;
this.denominator = 1;
this.numerator = numerator;
this.denominator = denominator;
}
value() {
return this.numerator / this.denominator;
}
}
const DefaultRatio = new Ratio(1, 1);
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
}
const ZERO_POINT = new Point(0, 0);
var TrackMatteType = /* @__PURE__ */ ((TrackMatteType2) => {
TrackMatteType2[TrackMatteType2["None"] = 0] = "None";
TrackMatteType2[TrackMatteType2["Alpha"] = 1] = "Alpha";
TrackMatteType2[TrackMatteType2["AlphaInverted"] = 2] = "AlphaInverted";
TrackMatteType2[TrackMatteType2["Luma"] = 3] = "Luma";
TrackMatteType2[TrackMatteType2["LumaInverted"] = 4] = "LumaInverted";
return TrackMatteType2;
})(TrackMatteType || {});
var LayerType = /* @__PURE__ */ ((LayerType2) => {
LayerType2[LayerType2["Unknown"] = 0] = "Unknown";
LayerType2[LayerType2["undefined"] = 1] = "undefined";
LayerType2[LayerType2["Solid"] = 2] = "Solid";
LayerType2[LayerType2["Text"] = 3] = "Text";
LayerType2[LayerType2["Shape"] = 4] = "Shape";
LayerType2[LayerType2["Image"] = 5] = "Image";
LayerType2[LayerType2["PreCompose"] = 6] = "PreCompose";
return LayerType2;
})(LayerType || {});
class Layer {
constructor() {
this.id = 0;
this.parent = void 0;
this.containingComposition = void 0;
this.stretch = DefaultRatio;
this.startTime = ZERO_ID;
this.duration = ZERO_TIME;
this.autoOrientation = false;
this.transform = void 0;
this.isActive = true;
this.blendMode = BlendMode.Normal;
this.trackMatteType = 0 /* None */;
this.trackMatteLayer = void 0;
this.timeRemap = void 0;
this.masks = void 0;
this.effects = void 0;
this.layerStyles = void 0;
this.layerCache = void 0;
this.maxScale = void 0;
}
type() {
return 0 /* Unknown */;
}
excludeVaryingRanges(timeRanges) {
var _a;
(_a = this.transform) == null ? void 0 : _a.excludeVaryingRanges(timeRanges);
if (this.timeRemap !== void 0) {
this.timeRemap.excludeVaryingRanges(timeRanges);
}
if (this.masks !== void 0) {
for (const mask of this.masks) {
mask.excludeVaryingRanges(timeRanges);
}
}
if (this.effects !== void 0 && this.effects.length > 0) {
for (const effect of this.effects) {
effect.excludeVaryingRanges(timeRanges);
}
}
if (this.layerStyles !== void 0 && this.layerStyles.length > 0) {
for (const layerStyle of this.layerStyles) {
layerStyle.excludeVaryingRanges(timeRanges);
}
}
}
gotoFrame(frame) {
var _a;
(_a = this.transform) == null ? void 0 : _a.gotoFrame(frame);
if (this.timeRemap !== void 0) {
this.timeRemap.gotoFrame(frame);
}
if (this.masks !== void 0 && this.masks.length > 0) {
for (const mask of this.masks) {
mask.gotoFrame(frame);
}
}
if (this.effects !== void 0 && this.effects.length > 0) {
for (const effect of this.effects) {
effect.gotoFrame(frame);
}
}
if (this.layerStyles !== void 0 && this.layerStyles.length > 0) {
for (const layerStyle of this.layerStyles) {
layerStyle.gotoFrame(frame);
}
}
}
verify() {
if (!this.containingComposition || this.duration <= 0 || !this.transform) {
verifyFailed();
return false;
}
if (!this.transform.verify()) {
verifyFailed();
return false;
}
if (this.masks && this.masks.length > 0) {
for (const mask of this.masks) {
if (!mask || !mask.verify()) {
verifyFailed();
return false;
}
}
}
if (this.layerStyles && this.layerStyles.length > 0) {
for (const layerStyle of this.layerStyles) {
if (!layerStyle || !layerStyle.verify()) {
verifyFailed();
return false;
}
}
}
if (this.effects && this.effects.length > 0) {
for (const effect of this.effects) {
if (!effect || !effect.verify()) {
verifyFailed();
return false;
}
}
}
return true;
}
getMaxScaleFactor() {
if (this.maxScale !== void 0) {
return this.maxScale;
}
this.maxScale = new Point(1, 1);
const property = this.transform.scale;
if (property.animatable()) {
const { keyframes } = property;
let scaleX = Math.abs(keyframes[0].startValue.x);
let scaleY = Math.abs(keyframes[0].startValue.y);
if (keyframes !== void 0 && keyframes.length > 0) {
for (const keyframe of keyframes) {
const x = Math.abs(keyframe.endValue.x);
const y = Math.abs(keyframe.endValue.y);
if (scaleX < x) {
scaleX = x;
}
if (scaleY < y) {
scaleY = y;
}
}
}
this.maxScale.x = scaleX;
this.maxScale.y = scaleY;
} else {
this.maxScale.x = Math.abs(property.value.x);
this.maxScale.y = Math.abs(property.value.y);
}
if (this.parent !== void 0) {
const parentScale = this.parent.getMaxScaleFactor();
this.maxScale.x *= parentScale.x;
this.maxScale.y *= parentScale.y;
}
return this.maxScale;
}
}
const SPATIAL_PRECISION = 0.05;
const BEZIER_PRECISION = 5e-3;
const readRatio = (byteArray) => {
const numeratorValue = byteArray.readEncodeInt32();
const denominatorValue = byteArray.readEncodedUint32();
const ration = new Ratio(numeratorValue, denominatorValue);
return ration;
};
const readColor = (byteArray) => {
const redNum = byteArray.readUint8();
const greenNum = byteArray.readUint8();
const blueNum = byteArray.readUint8();
const color = { red: redNum, green: greenNum, blue: blueNum };
return color;
};
const readTime = (byteArray) => byteArray.readEncodedUint64();
const readLayerID = (byteArray) => {
const id = byteArray.readEncodedUint32();
if (id === 0)
throw new Error("Layer ID is 0");
const layer = new Layer();
layer.id = id;
return layer;
};
const readPoint = (byteArray) => {
const x = byteArray.readFloat32();
const y = byteArray.readFloat32();
return new Point(x, y);
};
const readCompositionAttributes = (byteArray, composition) => {
composition.width = byteArray.readEncodeInt32();
composition.height = byteArray.readEncodeInt32();
composition.duration = readTime(byteArray);
composition.frameRate = byteArray.readFloat32();
composition.backgroundColor = readColor(byteArray);
};
class Context$1 {
constructor() {
this.tagLevel = 0;
this.compositions = [];
this.errorMessages = [];
}
throwException(message) {
this.errorMessages.push(message);
}
releaseCompositions() {
const compositions = this.compositions.slice();
this.compositions = [];
return compositions;
}
}
const ErrorMessage = {
PAGDecodeError: "PAG file decode error!"
};
const LENGTH_FOR_STORE_NUM_BITS = 5;
class ByteArray {
constructor(buffer, littleEndian) {
this._position = 0;
this.bitPosition = 0;
this.dataView = new DataView(buffer);
this.littleEndian = !!littleEndian;
this.context = new Context$1();
}
get length() {
return this.dataView.byteLength;
}
get bytesAvailable() {
return this.dataView.byteLength - this._position;
}
data() {
return this.dataView.buffer;
}
get position() {
return this._position;
}
alignWithBytes() {
this.bitPosition = this._position * 8;
}
readBoolean() {
const value = this.dataView.getInt8(this._position);
this._position += 1;
this.positonChanged();
return Boolean(value);
}
readChar() {
if (this._position >= this.length)
throw new Error(ErrorMessage.PAGDecodeError);
const value = this.dataView.getInt8(this._position);
this._position += 1;
this.positonChanged();
return String.fromCharCode(value);
}
readUint8() {
if (this._position >= this.length)
throw new Error(ErrorMessage.PAGDecodeError);
const value = this.dataView.getUint8(this._position);
this._position += 1;
this.positonChanged();
return value;
}
readInt8() {
if (this._position >= this.length)
throw new Error(ErrorMessage.PAGDecodeError);
const value = this.dataView.getInt8(this._position);
this._position += 1;
this.positonChanged();
return value;
}
readInt16() {
if (this._position >= this.length - 1)
throw new Error(ErrorMessage.PAGDecodeError);
const value = this.dataView.getInt16(this._position, this.littleEndian);
this._position += 2;
this.positonChanged();
return value;
}
readUint16() {
if (this._position >= this.length - 1)
throw new Error(ErrorMessage.PAGDecodeError);
const value = this.dataView.getUint16(this._position, this.littleEndian);
this._position += 2;
this.positonChanged();
return value;
}
readInt24() {
if (this._position >= this.length - 2)
throw new Error(ErrorMessage.PAGDecodeError);
const left = this.dataView.getInt16(this._position, this.littleEndian);
const right = this.dataView.getInt8(this._position + 2);
this._position += 3;
this.positonChanged();
return this.littleEndian ? left + 2 ** 16 * right : 2 ** 16 * left + right;
}
readUint24() {
if (this._position >= this.length - 2)
throw new Error(ErrorMessage.PAGDecodeError);
const left = this.dataView.getUint16(this._position, this.littleEndian);
const right = this.dataView.getUint8(this._position + 2);
this._position += 3;
this.positonChanged();
return this.littleEndian ? left + 2 ** 16 * right : 2 ** 16 * left + right;
}
readInt32() {
if (this._position >= this.length - 3)
throw new Error(ErrorMessage.PAGDecodeError);
const value = this.dataView.getInt32(this._position, this.littleEndian);
this._position += 4;
this.positonChanged();
return value;
}
readUint32() {
if (this._position >= this.length - 3)
throw new Error(ErrorMessage.PAGDecodeError);
const value = this.dataView.getUint32(this._position, this.littleEndian);
this._position += 4;
this.positonChanged();
return value;
}
readInt64() {
if (this._position >= this.length - 7)
throw new Error(ErrorMessage.PAGDecodeError);
const left = this.dataView.getInt32(this._position, this.littleEndian);
const right = this.dataView.getInt32(this._position + 4, this.littleEndian);
this._position += 8;
this.positonChanged();
return this.littleEndian ? left + 2 ** 32 * right : 2 ** 32 * left + right;
}
readUint64() {
if (this._position >= this.length - 7)
throw new Error(ErrorMessage.PAGDecodeError);
const left = this.dataView.getUint32(this._position, this.littleEndian);
const right = this.dataView.getUint32(this._position + 4, this.littleEndian);
this._position += 8;
this.positonChanged();
return this.littleEndian ? left + 2 ** 32 * right : 2 ** 32 * left + right;
}
readFloat32() {
if (this._position >= this.length - 3)
throw new Error(ErrorMessage.PAGDecodeError);
const value = this.dataView.getFloat32(this._position, this.littleEndian);
this._position += 4;
this.positonChanged();
return value;
}
readDouble() {
if (this._position >= this.length - 7)
throw new Error(ErrorMessage.PAGDecodeError);
const value = this.dataView.getFloat64(this._position, this.littleEndian);
this._position += 8;
this.positonChanged();
return value;
}
readUTF8String() {
if (this._position >= this.length)
throw new Error(ErrorMessage.PAGDecodeError);
let encoded = "";
let dataLength = 0;
for (let i = this._position; i < this.length; i++) {
if (this.dataView.getUint8(i) === 0) {
break;
}
encoded += `%${this.dataView.getUint8(i).toString(16)}`;
dataLength += 1;
}
this._position += dataLength;
this.positonChanged();
return decodeURIComponent(encoded);
}
readEncodedUint32() {
const valueMask = 127;
const hasNext = 128;
let value = 0;
let byte = 0;
for (let i = 0; i < 32; i += 7) {
if (this._position >= this.length) {
throw Error("readEncodedUint32 End of file was encountered.");
}
byte = this.dataView.getUint8(this._position);
this._position += 1;
value |= (byte & valueMask) << i;
if ((byte & hasNext) === 0) {
break;
}
}
this.positonChanged();
return value;
}
readEncodeInt32() {
const data = this.readEncodedUint32();
const value = data >> 1;
return (data & 1) > 0 ? -value : value;
}
readEncodedUint64() {
const valueMask = 127;
const hasNext = 128;
let value = 0;
let byte = 0;
for (let i = 0; i < 64; i += 7) {
if (this._position >= this.length) {
throw Error("readEncodedUint64 End of file was encountered.");
}
byte = this.dataView.getUint8(this._position);
this._position += 1;
value |= (byte & valueMask) << i;
if ((byte & hasNext) === 0) {
break;
}
}
this.positonChanged();
return value;
}
readEncodeInt64() {
const data = this.readEncodedUint64();
const value = data << 0;
return (data & 1) > 0 ? -value : value;
}
readBytes(length) {
const len = length || this.length - this._position;
if (this._position > this.length - len)
throw new Error(ErrorMessage.PAGDecodeError);
const newBuffer = this.dataView.buffer.slice(this._position, this._position + len);
this._position += len;
this.positonChanged();
return new ByteArray(newBuffer, this.littleEndian);
}
readUBits(numBits) {
const bitMasks = [0, 1, 3, 7, 15, 31, 63, 127, 255];
let value = 0;
if (this.bitPosition > this.length * 8 - numBits)
throw new Error(ErrorMessage.PAGDecodeError);
let pos = 0;
while (pos < numBits) {
const bytePosition = Math.floor(this.bitPosition * 0.125);
const bitPosition = this.bitPosition % 8;
let byte = this.dataView.getUint8(bytePosition) >> bitPosition;
const bitLength = Math.min(8 - bitPosition, numBits - pos);
byte &= bitMasks[bitLength];
value |= byte << pos;
pos += bitLength;
this.bitPosition += bitLength;
}
this.bitPositionChanged();
return value;
}
readBits(numBits) {
let value = this.readUBits(numBits);
value <<= 32 - numBits;
const data = value << 0;
return data >> 32 - numBits;
}
readNumBits() {
return this.readUBits(LENGTH_FOR_STORE_NUM_BITS) + 1;
}
readInt32List(count) {
const numBits = this.readNumBits();
const value = new Array(count);
for (let i = 0; i < count; i++) {
value[i] = this.readBits(numBits);
}
return value;
}
readUint32List(count) {
const numBits = this.readNumBits();
const value = new Array(count);
for (let i = 0; i < count; i++) {
value[i] = this.readUBits(numBits);
}
return value;
}
readBitBoolean() {
return this.readUBits(1) !== 0;
}
readFloatList(count, precision) {
const numBits = this.readNumBits();
const value = new Array(count);
for (let i = 0; i < count; i++) {
value[i] = this.readBits(numBits) * precision;
}
return value;
}
bitPositionChanged() {
this._position = Math.ceil(this.bitPosition * 0.125);
}
positonChanged() {
this.bitPosition = this._position * 8;
}
}
class ByteData {
constructor(data, length) {
this.length = 0;
this.data = data;
this.length = length;
}
}
class VideoFrame {
constructor() {
this.isKeyframe = false;
this.frame = 0;
this.fileBytes = new ByteData(new ByteArray(new ArrayBuffer(0)), 0);
}
}
class Sequence {
constructor() {
this.composition = void 0;
this.id = 0;
this.width = 0;
this.height = 0;
this.frameRate = 0;
this.frameCount = 0;
this.isKeyFrameFlags = [];
}
verify() {
return verifyAndReturn(this.composition !== void 0 && this.width > 0 && this.height > 0 && this.frameRate > 0);
}
}
class VideoSequence extends Sequence {
constructor() {
super(...arguments);
this.alphaStartX = 0;
this.alphaStartY = 0;
this.frames = [];
this.headers = [];
this.staticTimeRanges = [];
}
verify() {
if (!super.verify() || this.frames.length <= 0) {
verifyFailed();
return false;
}
for (const frame of this.frames) {
if (!frame || !frame.fileBytes) {
verifyFailed();
return false;
}
}
for (const header of this.headers) {
if (!header) {
verifyFailed();
return false;
}
}
return true;
}
getVideoWidth() {
let videoWidth = this.alphaStartX + this.width;
if (videoWidth % 2 === 1) {
videoWidth += 1;
}
return videoWidth;
}
getVideoHeight() {
let videoHeight = this.alphaStartY + this.height;
if (videoHeight % 2 === 1) {
videoHeight += 1;
}
return videoHeight;
}
}
const memcpy = (dst, dstOffset, src, srcOffset, num) => {
if (dstOffset >= dst.byteLength || srcOffset >= src.byteLength || src.byteLength - srcOffset > dst.byteLength - dstOffset || num > src.byteLength)
return;
const dstUint8Array = new Uint8Array(dst);
const srcUint8Array = new Uint8Array(src, srcOffset, num);
dstUint8Array.set(srcUint8Array, dstOffset);
};
const concatUint8Arrays = (arrays) => {
let totalLength = 0;
for (const arr of arrays) {
totalLength += arr.byteLength;
}
const result = new Uint8Array(totalLength);
let offset = 0;
for (const arr of arrays) {
result.set(arr, offset);
offset += arr.byteLength;
}
return result;
};
const readByteDataWithStartCode = (byteArray) => {
const length = byteArray.readEncodedUint32();
const bytes = byteArray.readBytes(length);
if (length === 0)
throw new Error("Read start code with length 0!");
const data = new ArrayBuffer(length + 4);
const dataView = new DataView(data);
dataView.setUint32(0, length);
memcpy(data, 4, bytes.data(), 0, length);
return new ByteData(new ByteArray(data), length + 4);
};
const readVideoSequence = (byteArray, hasAlpha) => {
const videoSequence = new VideoSequence();
videoSequence.width = byteArray.readEncodeInt32();
videoSequence.height = byteArray.readEncodeInt32();
videoSequence.frameRate = byteArray.readFloat32();
if (hasAlpha) {
videoSequence.alphaStartX = byteArray.readEncodeInt32();
videoSequence.alphaStartY = byteArray.readEncodeInt32();
}
const sps = readByteDataWithStartCode(byteArray);
const pps = readByteDataWithStartCode(byteArray);
videoSequence.headers.push(sps, pps);
videoSequence.frameCount = byteArray.readEncodedUint32();
for (let i = 0; i < videoSequence.frameCount; i++) {
const videoFrame = new VideoFrame();
videoFrame.isKeyframe = byteArray.readBitBoolean();
videoSequence.frames.push(videoFrame);
}
for (let i = 0; i < videoSequence.frameCount; i++) {
const videoFrame = videoSequence.frames[i];
videoFrame.frame = readTime(byteArray);
videoFrame.fileBytes = readByteDataWithStartCode(byteArray);
}
if (byteArray.bytesAvailable > 0) {
const count = byteArray.readEncodedUint32();
for (let i = 0; i < count; i++) {
const staticTimeRange = { start: 0, end: 0 };
staticTimeRange.start = readTime(byteArray);
staticTimeRange.end = readTime(byteArray);
videoSequence.staticTimeRanges.push(staticTimeRange);
}
}
return videoSequence;
};
const readVideoComposition = (byteArray) => {
const composition = new VideoComposition();
composition.id = byteArray.readEncodedUint32();
composition.hasAlpha = byteArray.readBoolean();
const parameter = { composition, hasAlpha: composition.hasAlpha };
readTags(byteArray, parameter, ReadTagsOfVideoComposition);
return composition;
};
const ReadTagsOfVideoComposition = (byteArray, code, parameter) => {
const { composition } = parameter;
switch (code) {
case TagCode.CompositionAttributes:
readCompositionAttributes(byteArray, composition);
break;
case TagCode.VideoSequence: {
const sequence = readVideoSequence(byteArray, parameter.hasAlpha);
sequence.composition = composition;
composition.sequences.push(sequence);
break;
}
}
};
var EffectType = /* @__PURE__ */ ((EffectType2) => {
EffectType2[EffectType2["Unknown"] = 0] = "Unknown";
EffectType2[EffectType2["Tint"] = 1] = "Tint";
EffectType2[EffectType2["Fill"] = 2] = "Fill";
EffectType2[EffectType2["Stroke"] = 3] = "Stroke";
EffectType2[EffectType2["Tritone"] = 4] = "Tritone";
EffectType2[EffectType2["DropShadow"] = 5] = "DropShadow";
EffectType2[EffectType2["RadialWipe"] = 6] = "RadialWipe";
EffectType2[EffectType2["DisplacementMap"] = 7] = "DisplacementMap";
return EffectType2;
})(EffectType || {});
function subtractFromTimeRanges(timeRanges, startTime, endTime) {
if (endTime < startTime) {
return;
}
const size = timeRanges.length;
for (let i = size - 1; i >= 0; i--) {
const timeRange = timeRanges[i];
if (timeRange.end < startTime || timeRange.start > endTime) {
continue;
}
if (timeRange.start < startTime && timeRange.end > endTime) {
const range = { start: endTime + 1, end: timeRange.end };
timeRange.end = startTime - 1;
if (range.end > range.start) {
timeRanges.splice(i + 1, 0, range);
}
if (timeRange.end <= timeRange.start) {
timeRanges.splice(i, 1);
}
break;
}
if (timeRange.start >= startTime && timeRange.end <= endTime) {
timeRanges.splice(i, 1);
} else if (timeRange.start < startTime) {
timeRange.end = startTime - 1;
if (timeRange.end <= timeRange.start) {
timeRanges.splice(i, 1);
}
} else {
timeRange.start = endTime + 1;
if (timeRange.end <= timeRange.start) {
timeRanges.splice(i, 1);
}
}
}
}
function splitTimeRangesAt(timeRanges, startTime) {
const size = timeRanges.length;
for (let i = size - 1; i >= 0; i--) {
const timeRange = timeRanges[i];
if (timeRange.start === startTime || timeRange.end <= startTime) {
break;
}
if (timeRange.start < startTime && timeRange.end > startTime) {
const range = { start: startTime, end: timeRange.end };
timeRange.end = startTime - 1;
if (range.end > range.start) {
timeRanges.splice(i + 1, 0, range);
}
if (timeRange.end <= timeRange.start) {
timeRanges.splice(i, 1);
}
break;
}
}
}
class VectorComposition extends Composition {
constructor() {
super(...arguments);
this.layers = [];
this.staticTimeRanges = [];
this.staticTimeRangeUpdated = false;
}
type() {
return CompositionType.Vector;
}
getStaticTimeRanges() {
if (!this.staticTimeRangeUpdated) {
this.staticTimeRangeUpdated = true;
this.updateStaticTimeRanges();
}
return this.staticTimeRanges;
}
verify() {
if (!super.verify()) {
verifyFailed();
return false;
}
for (const layer of this.layers) {
if (!layer || !layer.verify()) {
verifyFailed();
return false;
}
}
return true;
}
updateStaticTimeRanges() {
if (this.duration > 1) {
const range = { start: 0, end: this.duration - 1 };
this.staticTimeRanges = [range];
for (const layer of this.layers) {
if (this.staticTimeRanges.length <= 0) {
break;
}
layer.excludeVaryingRanges(this.staticTimeRanges);
splitTimeRangesAt(this.staticTimeRanges, layer.startTime);
splitTimeRangesAt(this.staticTimeRanges, layer.startTime + layer.duration);
}
}
}
}
class Property {
constructor(value) {
this.value = value;
}
animatable() {
return false;
}
excludeVaryingRanges(_timeRanges) {
}
gotoFrame(_time) {
}
}
class Transform2D {
static createDefaultTransform2D() {
const transform = new Transform2D();
return transform;
}
constructor() {
this.anchorPoint = new Property(ZERO_POINT);
this.position = new Property(ZERO_POINT);
this.xPosition = new Property(0);
this.yPosition = new Property(0);
this.scale = new Property(new Point(1, 1));
this.rotation = new Property(0);
this.opacity = new Property(OPAQUE);
}
excludeVaryingRanges(timeRanges) {
this.anchorPoint.excludeVaryingRanges(timeRanges);
if (this.position !== void 0) {
this.position.excludeVaryingRanges(timeRanges);
} else {
this.xPosition.excludeVaryingRanges(timeRanges);
this.yPosition.excludeVaryingRanges(timeRanges);
}
this.scale.excludeVaryingRanges(timeRanges);
this.rotation.excludeVaryingRanges(timeRanges);
this.opacity.excludeVaryingRanges(timeRanges);
}
gotoFrame(frame) {
this.anchorPoint.gotoFrame(frame);
if (this.position !== void 0) {
this.position.gotoFrame(frame);
} else {
this.xPosition.gotoFrame(frame);
this.yPosition.gotoFrame(frame);
}
this.scale.gotoFrame(frame);
this.rotation.gotoFrame(frame);
this.opacity.gotoFrame(frame);
}
verify() {
return this.anchorPoint !== void 0 && (this.position !== void 0 || this.xPosition !== void 0 && this.yPosition !== void 0) && this.scale !== void 0 && this.rotation !== void 0 && this.opacity !== void 0;
}
}
class PreComposeLayer extends Layer {
constructor() {
super(...arguments);
this.composition = void 0;
this.compositionStartTime = ZERO_TIME;
this.staticTimeRanges = void 0;
this.staticTimeRangeUpdated = false;
}
static wrap(composition) {
const layer = new PreComposeLayer();
layer.duration = composition.duration;
const transform = new Transform2D();
layer.transform = transform;
layer.composition = composition;
return layer;
}
type() {
return LayerType.PreCompose;
}
excludeVaryingRanges(timeRanges) {
super.excludeVaryingRanges(timeRanges);
if (!timeRanges || timeRanges.length === 0) {
return;
}
this.updateStaticTimeRanges();
}
gotoFrame(frame) {
super.gotoFrame(frame);
}
verify() {
if (!super.verify()) {
return false;
}
if (this.composition) {
return true;
}
return false;
}
updateStaticTimeRanges() {
var _a;
if (this.staticTimeRangeUpdated) {
return;
}
this.staticTimeRangeUpdated = true;
const ranges = (_a = this.composition) == null ? void 0 : _a.getStaticTimeRanges();
if (!ranges)
return;
for (let i = ranges.length - 1; i >= 0; i--) {
const range = ranges[i];
range.start += this.compositionStartTime;
range.end += this.compositionStartTime;
if (range.end <= this.startTime) {
ranges.pop();
} else if (range.start < this.startTime) {
range.start = 0;
} else if (range.start >= this.startTime + this.duration - 1) {
ranges.pop();
} else if (range.end > this.startTime + this.duration - 1) {
range.end = this.startTime + this.duration - 1;
}
}
this.staticTimeRanges = ranges;
}
}
class ShapeLayer extends Layer {
constructor() {
super(...arguments);
this.contents = [];
}
type() {
return LayerType.Shape;
}
excludeVaryingRanges(timeRanges) {
super.excludeVaryingRanges(timeRanges);
for (const element of this.contents) {
element.excludeVaryingRanges(timeRanges);
}
}
gotoFrame(frame) {
super.gotoFrame(frame);
for (const element of this.contents) {
element.gotoFrame(frame);
}
}
verify() {
if (!super.verify()) {
return false;
}
for (const element of this.contents) {
if (element === void 0 || !element.verify()) {
return false;
}
}
return true;
}
}
class SolidLayer extends Layer {
constructor() {
super(...arguments);
this.solidColor = Black;
this.width = 0;
this.height = 0;
}
type() {
return LayerType.Solid;
}
excludeVaryingRanges(timeRanges) {
super.excludeVaryingRanges(timeRanges);
}
gotoFrame(frame) {
super.gotoFrame(frame);
}
verify() {
if (!super.verify()) {
verifyFailed();
return false;
}
return verifyAndReturn(this.width > 0 && this.height > 0);
}
}
class UnDefinedLayer extends Layer {
type() {
return LayerType.undefined;
}
}
class Keyframe {
constructor() {
this.startTime = 0;
this.endTime = 0;
this.interpolationType = KeyframeInterpolationType.Hold;
this.bezierOut = [];
this.bezierIn = [];
this.spatialOut = ZERO_POINT;
this.spatialIn = ZERO_POINT;
}
initialize() {
}
getValue(_time) {
return this.startValue;
}
containsTime(time) {
return time >= this.startTime && time < this.endTime;
}
}
class AnimatableProperty extends Property {
constructor(keyframes) {
if (!keyframes || keyframes.length === 0)
throw new Error("keyframes is required");
if (keyframes[0].startValue === void 0)
throw new Error("startValue is required");
super(keyframes[0].startValue);
this.keyframes = keyframes;
this.lastKeyframeIndex = 0;
for (const keyframe of keyframes) {
keyframe.initialize();
}
}
animatable() {
return true;
}
excludeVaryingRanges(timeRanges) {
for (const keyframe of this.keyframes) {
switch (keyframe.interpolationType) {
case KeyframeInterpolationType.Bezier:
case KeyframeInterpolationType.Linear:
subtractFromTimeRanges(timeRanges, keyframe.startTime, keyframe.endTime - 1);
break;
default:
splitTimeRangesAt(timeRanges, keyframe.startTime);
splitTimeRangesAt(timeRanges, keyframe.endTime);
break;
}
}
}
gotoFrame(frame) {
let lastKeyframe = this.keyframes[this.lastKeyframeIndex];
if (lastKeyframe.containsTime(frame)) {
this.value = lastKeyframe.getValue(frame);
return;
}
if (frame < lastKeyframe.startTime) {
while (this.lastKeyframeIndex > 0) {
this.lastKeyframeIndex -= 1;
if (this.keyframes[this.lastKeyframeIndex].containsTime(frame)) {
break;
}
}
} else {
while (this.lastKeyframeIndex < this.keyframes.length - 1) {
this.lastKeyframeIndex += 1;
if (this.keyframes[this.lastKeyframeIndex].containsTime(frame)) {
break;
}
}
}
lastKeyframe = this.keyframes[this.lastKeyframeIndex];
if (lastKeyframe.startValue !== void 0 && frame <= lastKeyframe.startTime) {
this.value = lastKeyframe.startValue;
} else if (lastKeyframe.endValue !== void 0 && frame >= lastKeyframe.endTime) {
this.value = lastKeyframe.endValue;
} else {
this.value = lastKeyframe.getValue(frame);
}
}
}
var AttributeType = /* @__PURE__ */ ((AttributeType2) => {
AttributeType2[AttributeType2["Value"] = 0] = "Value";
AttributeType2[AttributeType2["FixedValue"] = 1] = "FixedValue";
AttributeType2[AttributeType2["SimpleProperty"] = 2] = "SimpleProperty";
AttributeType2[AttributeType2["DiscreteProperty"] = 3] = "DiscreteProperty";
AttributeType2[AttributeType2["MultiDimensionProperty"] = 4] = "MultiDimensionProperty";
AttributeType2[AttributeType2["SpatialProperty"] = 5] = "SpatialProperty";
AttributeType2[AttributeType2["BitFlag"] = 6] = "BitFlag";
AttributeType2[AttributeType2["Custom"] = 7] = "Custom";
return AttributeType2;
})(AttributeType || {});
const readTagBlock = (byteArray, parameter, blockConfig) => {
const tagConfig = blockConfig;
const flags = [];
if (!tagConfig.configs || tagConfig.configs.length === 0) {
return parameter;
}
for (const config of tagConfig.configs) {
const flag = readAttributeFlag(byteArray, config);
flags.push(flag);
}
byteArray.alignWithBytes();
let index = 0;
for (const config of tagConfig.configs) {
const flag = flags[index];
const target = config.key;
config.readAttribute(byteArray, flag, parameter, target);
index += 1;
}
return parameter;
};
class BaseAttribute {
constructor(key, attributeType, defaultValue) {
this.attributeType = attributeType;
this.defaultValue = defaultValue;
this.key = key;
}
readAttribute(_byteArray, _flag, _targetClass, _target) {
}
readValue(_byteArray) {
return void 0;
}
readValueList(_byteArray, _list, _count) {
}
dimensionality() {
return 1;
}
newKeyframe(_flag) {
return new Keyframe();
}
}
const readAttribute = (byteArray, flag, targetClass, target, config) => {
if (config.attributeType === 6 /* BitFlag */) {
targetClass[target] = flag.exist;
} else if (config.attributeType === 1 /* FixedValue */) {
targetClass[target] = config.readValue(byteArray);
} else if (config.attributeType === 0 /* Value */) {
targetClass[target] = readValue(byteArray, config, flag);
} else {
targetClass[target] = readProperty(byteArray, config, flag);
}
};
const readProperty = (byteArray, config, flag) => {
let property;
if (flag.exist) {
if (flag.animatable) {
const keyframes = readKeyframes(byteArray, config, flag);
if (!keyframes || keyframes.length === 0) {
throw new Error("Wrong number of keyframes!");
}
readTimeAndValue(byteArray, keyframes, config);
readTimeEase(byteArray, keyframes, config);
if (flag.hasSpatial);
property = new AnimatableProperty(keyframes);
} else {
property = new Property(readValue(byteArray, config, flag));
}
} else {
property = new Property(config.defaultValue);
}
return property;
};
const readValue = (byteArray, config, flag) => {
if (flag.exist) {
return config.readValue(byteArray);
}
return config.defaultValue;
};
const readAttributeFlag = (byteArray, config) => {
const flag = { exist: false, animatable: false, hasSpatial: false };
const { attributeType } = config;
if (attributeType === 1 /* FixedValue */) {
flag.exist = true;
return flag;
}
flag.exist = byteArray.readBitBoolean();
if (!flag.exist || attributeType === 0 /* Value */ || attributeType === 6 /* BitFlag */ || attributeType === 7 /* Custom */) {
return flag;
}
flag.animatable = byteArray.readBitBoolean();
if (!flag.animatable || attributeType !== 5 /* SpatialProperty */) {
return flag;
}
flag.hasSpatial = byteArray.readBitBoolean();
return flag;
};
const readKeyframes = (byteArray, config, flag) => {
const keyframes = [];
const numFrames = byteArray.readEncodedUint32();
for (let i = 0; i < numFrames; i++) {
let keyframe;
if (config.attributeType === 3 /* DiscreteProperty */) {
keyframe = new Keyframe();
} else {
const interpolationType = byteArray.readUBits(2);
if (interpolationType === KeyframeInterpolationType.Hold) {
keyframe = new Keyframe();
} else {
keyframe = config.newKeyframe(flag);
keyframe.interpolationType = interpolationType;
}
}
keyframes.push(keyframe);
}
return keyframes;
};
const readTimeAndValue = (byteArray, keyframes, config) => {
const numFrames = keyframes.length;
keyframes[0].startTime = readTime(byteArray);
for (let i = 0; i < numFrames; i++) {
const time = readTime(byteArray);
keyframes[i].endTime = time;
if (i < numFrames - 1) {
keyframes[i + 1].startTime = time;
}
}
const list = [];
config.readValueList(byteArray, list, numFrames + 1);
let index = 0;
keyframes[0].startValue = list[index];
index += 1;
for (let i = 0; i < numFrames; i++) {
const value = list[index];
index += 1;
keyframes[i].endValue = value;
if (i < numFrames - 1) {
keyframes[i + 1].startValue = value;
}
}
};
const readTimeEase = (byteArray, keyframes, config) => {
const dimensionality = config.attributeType === 4 /* MultiDimensionProperty */ ? config.dimensionality() : 1;
const numBits = byteArray.readNumBits();
for (const keyframe of keyframes) {
if (keyframe.interpolationType !== KeyframeInterpolationType.Bezier) {
continue;
}
let x;
let y;
for (let i = 0; i < dimensionality; i++) {
x = byteArray.readBits(numBits) * BEZIER_PRECISION;
y = byteArray.readBits(numBits) * BEZIER_PRECISION;
keyframe.bezierOut.push({ x, y });
x = byteArray.readBits(numBits) * BEZIER_PRECISION;
y = byteArray.readBits(numBits) * BEZIER_PRECISION;
keyframe.bezierIn.push({ x, y });
}
}
};
function readSolidColor(byteArray, layer) {
layer.solidColor = readColor(byteArray);
layer.width = byteArray.readEncodeInt32();
layer.height = byteArray.readEncodeInt32();
}
function interpolateFloat(a, b, t) {
return a + (b - a) * t;
}
class Interpolator {
getInterpolation(input) {
return input;
}
}
class MultiDimensionPointKeyframe extends Keyframe {
initialize() {
super.initialize();
if (this.interpolationType === KeyframeInterpolationType.Bezier); else {
this.xInterpolator = new Interpolator();
this.yInterpolator = new Interpolator();
}
}
getValue(time) {
var _a, _b, _c, _d;
const progress = (time - this.startTime) / (this.endTime - this.startTime);
const xProgress = (_b = (_a = this.xInterpolator) == null ? void 0 : _a.getInterpolation(progress)) != null ? _b : progress;
const yProgress = (_d = (_c = this.yInterpolator) == null ? void 0 : _c.getInterpolation(progress)) != null ? _d : progress;
const x = interpolateFloat(this.startValue.x, this.endValue.x, xProgress);
const y = interpolateFloat(this.startValue.y, this.endValue.y, yProgress);
return { x, y };
}
}
class SingleEaseKeyframe extends Keyframe {
initialize() {
if (this.interpolationType === KeyframeInterpolationType.Bezier); else {
this.interpolator = new Interpolator();
}
}
getProgress(time) {
var _a, _b;
const progress = (time - this.startTime) / (this.endTime - this.startTime);
return (_b = (_a = this.interpolator) == null ? void 0 : _a.getInterpolation(progress)) != null ? _b : progress;
}
getValue(time) {
const progress = this.getProgress(time);
return interpolateFloat(this.startValue, this.endValue, progress);
}
}
class FloatAttributeConfig extends BaseAttribute {
constructor(key, attributeType, defaultValue) {
super(key, attributeType, defaultValue);
}
readAttribute(byteArray, flag, targetClass, target) {
readAttribute(byteArray, flag, targetClass, target, this);
}
readValue(byteArray) {
return byteArray.readFloat32();
}