UNPKG

aia-kit

Version:

Read, Parse, Edit, Write, Analyze AIA/AIX/AIS files.

39 lines 1.41 kB
import simpleComponentsJson from '../simple_components.json' with { type: "json" }; import { getTextFileContent } from "./zipjs.js"; import { getProperties } from "properties-file"; import { Project } from "../project.js"; /** * Convert the color in &HAARRGGBB format to #RRGGBBAA format * @param color */ export function parseAiColor(color) { return '#' + color.substring(4, 10) + color.substring(2, 4); } export function parseAiBoolean(bool) { return bool === 'True'; } export function getFileInfo(file) { // return name and type const a = file.filename.lastIndexOf('/'); const b = file.filename.lastIndexOf('.'); return [file.filename.substring(a + 1, b), file.filename.substring(b + 1)]; } export async function readProjectProperties(file) { const content = await getTextFileContent(file); return getProperties(content); } export function getDescriptor(componentType, project) { // First check built-in components let descriptor = simpleComponentsJson.find(x => x.type === 'com.google.appinventor.components.runtime.' + componentType); if (descriptor !== undefined) { return descriptor; } // Then check extensions for (let extension of project.extensions) { if (extension.name.split('.').pop() === componentType) { return extension.descriptorJSON; } } return null; } //# sourceMappingURL=utils.js.map