UNPKG

@manuth/woltlab-compiler

Version:

A compiler for generating WoltLab-Package `.tar` Archives and other WoltLab-Package Components

57 lines 2.36 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { LocalizationProviderInstruction } from "../../../PackageSystem/Instructions/Globalization/LocalizationProviderInstruction.js"; import { InstructionCompiler } from "./InstructionCompiler.js"; import { LocalizationInstructionCompiler } from "./LocalizationInstructionCompiler.js"; /** * Provides the functionality to compile files which provide localizations. * * @template T * The type of the item which can be compiled by this compiler. */ export class LocalizationProviderCompiler extends InstructionCompiler { /** * Initializes a new instance of the {@link LocalizationProviderCompiler `LocalizationProviderCompiler<T>`} class. * * @param item * The item to compile. */ constructor(item) { super(item); } /** * @inheritdoc * * @returns * The serialized document. */ Serialize() { let document = super.Serialize(); if (Object.keys(this.Item.GetMessages()).length > 0) { let childNodes = new LocalizationInstructionCompiler(new LocalizationProviderInstruction(this.Item)).Serialize().childNodes; for (let i = 0; i < childNodes.length; i++) { let node = childNodes.item(i); document.appendChild(node); } } return document; } /** * @inheritdoc */ Compile() { return __awaiter(this, void 0, void 0, function* () { let compiler = new LocalizationInstructionCompiler(this.Item); compiler.DestinationPath = this.DestinationPath; yield compiler.Execute(); }); } } //# sourceMappingURL=LocalizationProviderCompiler.js.map