pcf-scripts
Version:
This package contains a module for building PowerApps Component Framework (PCF) controls. See project homepage how to install.
55 lines (53 loc) • 2.02 kB
JavaScript
// Copyright (C) Microsoft Corporation. All rights reserved.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DesignContext = void 0;
const fs_extra_1 = require("fs-extra");
const path = require("node:path");
const xml2js_1 = require("xml2js");
const constants = require("./constants");
const diagnosticMessages_generated_1 = require("./diagnosticMessages.generated");
class DesignContext {
constructor(diag, controlContext) {
this.controlContext = controlContext;
this.controlsPath = controlContext.getControlPath();
this.designTypeFilePath = this.controlsPath;
this.designMapsXmlFilePath = path.join(this.controlsPath, constants.DEFAULT_DESIGN_MAP_DIR);
this.loadDesignMappingFile(diag);
}
getParsedDesignMap() {
return this.parsedDesignMap["design-map"];
}
getPathForDesignTypeFile() {
return this.designTypeFilePath;
}
getMapXmlFilePath() {
return this.designMapsXmlFilePath;
}
getControlFolderName() {
return path.basename(this.controlsPath);
}
// Load design mapping input file
loadDesignMappingFile(diag) {
const filePath = this.controlContext.getControlManifest().data.manifest.control.$["design-mapping-file"];
const designMapXmlFile = path.join(this.controlsPath, filePath);
let rawXml;
try {
rawXml = (0, fs_extra_1.readFileSync)(designMapXmlFile);
}
catch {
diag.pushA(diagnosticMessages_generated_1.strings.error_reading_design_maps_file, [designMapXmlFile]);
return;
}
(0, xml2js_1.parseString)(rawXml, (err, result) => {
if (err) {
diag.pushA(diagnosticMessages_generated_1.strings.manifest_parsing_error, [err.message]);
}
else {
this.parsedDesignMap = result;
}
});
}
}
exports.DesignContext = DesignContext;
//# sourceMappingURL=designContext.js.map
;