@ng-doc/builder
Version:
<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>
41 lines • 1.52 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPlaygroundMetadata = getPlaygroundMetadata;
const helpers_1 = require("../../../helpers");
/**
*
* @param page
* @param objectExpression
*/
function getPlaygroundMetadata(page, objectExpression) {
const expression = (0, helpers_1.getPlaygroundsExpression)(objectExpression);
if (expression) {
return (0, helpers_1.getPlaygroundsIds)(expression).reduce((metadata, id) => {
if (expression) {
const playground = (0, helpers_1.getPlaygroundById)(expression, id);
if (playground) {
metadata[id] = (0, helpers_1.buildPlaygroundMetadata)(id, playground, controlsToProperties(page.playgrounds?.[id]?.controls ?? {}));
}
}
return metadata;
}, {});
}
return {};
}
/**
*
* @param controls
*/
function controlsToProperties(controls) {
return Object.entries(controls).reduce((properties, [name, value]) => {
properties[name] = {
inputName: typeof value === 'string' ? name : value.alias ?? name,
type: typeof value === 'string' ? value : value.type,
description: typeof value === 'string' ? undefined : value.description ?? undefined,
options: typeof value === 'string' ? undefined : value.options ?? undefined,
isManual: true,
};
return properties;
}, {});
}
//# sourceMappingURL=get-playground-metadata.js.map
;