UNPKG

atlassian-webresource-webpack-plugin

Version:

Auto-generates web-resource definitions from your webpacked code, for usage in an Atlassian product or plugin.

44 lines 2.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDeprecationInfoForEntry = exports.getDataProvidersForEntry = exports.getConditionForEntry = exports.getWebresourceAttributesForEntry = exports.getContextForEntry = void 0; const web_resource_parser_1 = require("./web-resource-parser"); const getContextForEntry = (entry, contextMap, addEntrypointNameAsContext) => { const initialArray = addEntrypointNameAsContext ? [entry] : []; if (!contextMap.has(entry)) { return initialArray; } // TODO: verify if we need the typecheck here, as Intellij is rightfully complaining about the typecheck here as `contextMap` should only return "strings" // noinspection SuspiciousTypeOfGuard return initialArray .concat(contextMap.get(entry)) .filter((context) => typeof context === 'string' && context.trim() !== ''); }; exports.getContextForEntry = getContextForEntry; const getWebresourceAttributesForEntry = (entry, webresourceKeyMap) => { const wrKey = webresourceKeyMap.get(entry); // Create the default attribute values let attrs = { key: `entrypoint-${entry}`, moduleId: entry }; // Extend the attributes with parsed, valid values if (typeof wrKey === 'object') { attrs = Object.assign(attrs, (0, web_resource_parser_1.parseWebResourceAttributes)(wrKey)); } // Override the key if a non-empty string is provided if (typeof wrKey === 'string') { attrs = Object.assign(attrs, (0, web_resource_parser_1.parseWebResourceAttributes)({ key: wrKey })); } return attrs; }; exports.getWebresourceAttributesForEntry = getWebresourceAttributesForEntry; const getConditionForEntry = (entry, conditionMap) => { return conditionMap.get(entry); }; exports.getConditionForEntry = getConditionForEntry; const getDataProvidersForEntry = (entrypoint, dataProvidersMap) => { return dataProvidersMap.get(entrypoint) || []; }; exports.getDataProvidersForEntry = getDataProvidersForEntry; const getDeprecationInfoForEntry = (entrypoint, deprecationMap) => { return deprecationMap.get(entrypoint); }; exports.getDeprecationInfoForEntry = getDeprecationInfoForEntry; //# sourceMappingURL=web-resource-entrypoints.js.map