@atlassian/clientside-extensions-webpack-plugin 2.4.1 → 2.5.0-84fa90d-kwd5ix2w
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ClientsideExtensionsWebpackPlugin.js +21 -20
- package/dist/cjs/ClientsideExtensionsWebpackPlugin.js.map +1 -1
- package/dist/cjs/annotations/index.js +2 -2
- package/dist/cjs/annotations/index.js.map +1 -1
- package/dist/cjs/annotations/key.js +1 -1
- package/dist/cjs/annotations/key.js.map +1 -1
- package/dist/cjs/annotations/label.js +2 -2
- package/dist/cjs/annotations/label.js.map +1 -1
- package/dist/cjs/annotations/link.js +2 -2
- package/dist/cjs/annotations/link.js.map +1 -1
- package/dist/cjs/annotations/parsers.js +14 -10
- package/dist/cjs/annotations/parsers.js.map +1 -1
- package/dist/cjs/generator/conditions.js +2 -2
- package/dist/cjs/generator/conditions.js.map +1 -1
- package/dist/cjs/generator/entrypoint.js +5 -4
- package/dist/cjs/generator/entrypoint.js.map +1 -1
- package/dist/cjs/generator/webfragmentDescriptor.js +7 -7
- package/dist/cjs/generator/webfragmentDescriptor.js.map +1 -1
- package/dist/cjs/generator/webpageDescriptor.js +6 -6
- package/dist/cjs/generator/webpageDescriptor.js.map +1 -1
- package/dist/cjs/generator/xml.js +7 -5
- package/dist/cjs/generator/xml.js.map +1 -1
- package/dist/cjs/tests/test-helper.js +8 -6
- package/dist/cjs/tests/test-helper.js.map +1 -1
- package/dist/cjs/transform-comment.js +4 -4
- package/dist/cjs/transform-comment.js.map +1 -1
- package/dist/cjs/utils.js +6 -3
- package/dist/cjs/utils.js.map +1 -1
- package/dist/types/ClientsideExtensionsWebpackPlugin.d.ts +21 -24
- package/dist/types/ClientsideExtensionsWebpackPlugin.d.ts.map +1 -1
- package/lib/ClientsideExtensionsWebpackPlugin.basic.test.ts +30 -17
- package/lib/ClientsideExtensionsWebpackPlugin.conditions.test.ts +20 -14
- package/lib/ClientsideExtensionsWebpackPlugin.metadata.test.ts +9 -4
- package/lib/ClientsideExtensionsWebpackPlugin.ts +4 -2
- package/lib/ClientsideExtensionsWebpackPlugin.webpages.test.ts +35 -22
- package/lib/generator/xml.ts +1 -1
- package/lib/tests/test-helper.ts +1 -1
- package/lib/transform-comment.ts +2 -2
- package/package.json +12 -11
- package/tsconfig.all.json +6 -0
- package/tsconfig.json +5 -1
- package/dist/cjs/ClientsideExtensionsWebpackPlugin.basic.test.js +0 -75
- package/dist/cjs/ClientsideExtensionsWebpackPlugin.basic.test.js.map +0 -1
- package/dist/cjs/ClientsideExtensionsWebpackPlugin.conditions.test.js +0 -201
- package/dist/cjs/ClientsideExtensionsWebpackPlugin.conditions.test.js.map +0 -1
- package/dist/cjs/ClientsideExtensionsWebpackPlugin.metadata.test.js +0 -62
- package/dist/cjs/ClientsideExtensionsWebpackPlugin.metadata.test.js.map +0 -1
- package/dist/cjs/ClientsideExtensionsWebpackPlugin.webpages.test.js +0 -442
- package/dist/cjs/ClientsideExtensionsWebpackPlugin.webpages.test.js.map +0 -1
- package/dist/types/ClientsideExtensionsWebpackPlugin.basic.test.d.ts +0 -2
- package/dist/types/ClientsideExtensionsWebpackPlugin.basic.test.d.ts.map +0 -1
- package/dist/types/ClientsideExtensionsWebpackPlugin.conditions.test.d.ts +0 -2
- package/dist/types/ClientsideExtensionsWebpackPlugin.conditions.test.d.ts.map +0 -1
- package/dist/types/ClientsideExtensionsWebpackPlugin.metadata.test.d.ts +0 -2
- package/dist/types/ClientsideExtensionsWebpackPlugin.metadata.test.d.ts.map +0 -1
- package/dist/types/ClientsideExtensionsWebpackPlugin.webpages.test.d.ts +0 -2
- package/dist/types/ClientsideExtensionsWebpackPlugin.webpages.test.d.ts.map +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const tslib_1 = require("tslib");
|
|
3
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
4
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
5
|
-
const glob_1 = tslib_1.__importDefault(require("glob"));
|
|
6
|
-
const kebabCase_1 = tslib_1.__importDefault(require("lodash/kebabCase"));
|
|
3
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
4
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
5
|
+
const glob_1 = (0, tslib_1.__importDefault)(require("glob"));
|
|
6
|
+
const kebabCase_1 = (0, tslib_1.__importDefault)(require("lodash/kebabCase"));
|
|
7
7
|
const pretty_data_1 = require("pretty-data");
|
|
8
|
-
const webpack_virtual_modules_1 = tslib_1.__importDefault(require("webpack-virtual-modules"));
|
|
9
|
-
const transform_comment_1 = tslib_1.__importDefault(require("./transform-comment"));
|
|
10
|
-
const annotations_1 = tslib_1.__importDefault(require("./annotations"));
|
|
11
|
-
const webfragmentDescriptor_1 = tslib_1.__importDefault(require("./generator/webfragmentDescriptor"));
|
|
12
|
-
const webpageDescriptor_1 = tslib_1.__importStar(require("./generator/webpageDescriptor"));
|
|
8
|
+
const webpack_virtual_modules_1 = (0, tslib_1.__importDefault)(require("webpack-virtual-modules"));
|
|
9
|
+
const transform_comment_1 = (0, tslib_1.__importDefault)(require("./transform-comment"));
|
|
10
|
+
const annotations_1 = (0, tslib_1.__importDefault)(require("./annotations"));
|
|
11
|
+
const webfragmentDescriptor_1 = (0, tslib_1.__importDefault)(require("./generator/webfragmentDescriptor"));
|
|
12
|
+
const webpageDescriptor_1 = (0, tslib_1.__importStar)(require("./generator/webpageDescriptor"));
|
|
13
13
|
const entrypoint_1 = require("./generator/entrypoint");
|
|
14
14
|
const utils_1 = require("./utils");
|
|
15
|
-
const conditions_1 = tslib_1.__importDefault(require("./generator/conditions"));
|
|
16
|
-
|
|
15
|
+
const conditions_1 = (0, tslib_1.__importDefault)(require("./generator/conditions"));
|
|
16
|
+
class ClientsideExtensionsWebpackPlugin {
|
|
17
17
|
constructor(options = {}) {
|
|
18
18
|
if (!options.pattern) {
|
|
19
19
|
throw new Error('No pattern was specified to match clientside extensions');
|
|
@@ -48,13 +48,13 @@ module.exports = class ClientsideExtensionsWebpackPlugin {
|
|
|
48
48
|
ClientsideExtensionsWebpackPlugin.addConditionToEntrypoint(extensionsOptions, wrmOptions);
|
|
49
49
|
const virtualModules = extensionsOptions.reduce((agg, extensionOption) => {
|
|
50
50
|
const fileName = ClientsideExtensionsWebpackPlugin.getFilenameForEntry(extensionOption.id);
|
|
51
|
-
agg[fileName] = entrypoint_1.generateEntrypointCode(extensionOption);
|
|
51
|
+
agg[fileName] = (0, entrypoint_1.generateEntrypointCode)(extensionOption);
|
|
52
52
|
return agg;
|
|
53
53
|
}, {});
|
|
54
54
|
new webpack_virtual_modules_1.default(virtualModules).apply(compiler);
|
|
55
55
|
compiler.hooks.compilation.tap('Tap compilation for XML generation', (compilation) => {
|
|
56
|
-
const webfragmentDescriptors = extensionsOptions.map((extensionOption) => webfragmentDescriptor_1.default(extensionOption));
|
|
57
|
-
const webpageDescriptors = extensionsOptions.map((extensionOption) => webpageDescriptor_1.default(extensionOption));
|
|
56
|
+
const webfragmentDescriptors = extensionsOptions.map((extensionOption) => (0, webfragmentDescriptor_1.default)(extensionOption));
|
|
57
|
+
const webpageDescriptors = extensionsOptions.map((extensionOption) => (0, webpageDescriptor_1.default)(extensionOption));
|
|
58
58
|
const descriptors = [...webfragmentDescriptors, ...webpageDescriptors].join('');
|
|
59
59
|
const xmlDescriptors = pretty_data_1.pd.xml(`<clientside-extension>${descriptors}</clientside-extension>`);
|
|
60
60
|
const xmlDescriptorDirname = path_1.default.dirname(path_1.default.relative(compiler.options.output.path || '', this.outputFilename || wrmOptions.xmlDescriptors));
|
|
@@ -93,13 +93,13 @@ module.exports = class ClientsideExtensionsWebpackPlugin {
|
|
|
93
93
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
94
94
|
const hasCondition = (extensionOptions) => Boolean(extensionOptions.condition);
|
|
95
95
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
96
|
-
const isNotPageExtension = (extensionOptions) => !entrypoint_1.isPageExtension(extensionOptions);
|
|
96
|
+
const isNotPageExtension = (extensionOptions) => !(0, entrypoint_1.isPageExtension)(extensionOptions);
|
|
97
97
|
extensionOptions
|
|
98
98
|
.filter(hasCondition)
|
|
99
99
|
.filter(isNotPageExtension)
|
|
100
100
|
.forEach((extensionOption) => {
|
|
101
101
|
const entrypointId = ClientsideExtensionsWebpackPlugin.getIdFromManifestKey(extensionOption.key);
|
|
102
|
-
const conditionMap = conditions_1.default(extensionOption.condition);
|
|
102
|
+
const conditionMap = (0, conditions_1.default)(extensionOption.condition);
|
|
103
103
|
const conditionMapPluginOption = wrmOptions.conditionMap;
|
|
104
104
|
conditionMapPluginOption.set(entrypointId, conditionMap);
|
|
105
105
|
});
|
|
@@ -112,7 +112,7 @@ module.exports = class ClientsideExtensionsWebpackPlugin {
|
|
|
112
112
|
const annotations = {};
|
|
113
113
|
const entries = Object.entries(annotations_1.default);
|
|
114
114
|
for (const [annotationKey, annotationParser] of entries) {
|
|
115
|
-
const rawAnnotation = utils_1.getKeyValue(rawAnnotations, annotationKey);
|
|
115
|
+
const rawAnnotation = (0, utils_1.getKeyValue)(rawAnnotations, annotationKey);
|
|
116
116
|
const newAnnotations = annotationParser(rawAnnotation, rawAnnotations, parserOptions);
|
|
117
117
|
if (newAnnotations !== null) {
|
|
118
118
|
Object.assign(annotations, newAnnotations);
|
|
@@ -127,7 +127,7 @@ module.exports = class ClientsideExtensionsWebpackPlugin {
|
|
|
127
127
|
}
|
|
128
128
|
static parseManifestFromComment(file, cwd) {
|
|
129
129
|
const fileContent = fs_1.default.readFileSync(file, 'utf8');
|
|
130
|
-
const annotations = transform_comment_1.default(fileContent);
|
|
130
|
+
const annotations = (0, transform_comment_1.default)(fileContent);
|
|
131
131
|
if (!annotations) {
|
|
132
132
|
console.warn(`Client-side Extension: The file: "${file}" does not contain meta comments. Skipping XML-descriptor generation.`);
|
|
133
133
|
return null;
|
|
@@ -162,7 +162,8 @@ module.exports = class ClientsideExtensionsWebpackPlugin {
|
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
164
|
static getIdFromManifestKey(key) {
|
|
165
|
-
return kebabCase_1.default(key);
|
|
165
|
+
return (0, kebabCase_1.default)(key);
|
|
166
166
|
}
|
|
167
|
-
}
|
|
167
|
+
}
|
|
168
|
+
module.exports = ClientsideExtensionsWebpackPlugin;
|
|
168
169
|
//# sourceMappingURL=ClientsideExtensionsWebpackPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientsideExtensionsWebpackPlugin.js","sourceRoot":"","sources":["../../lib/ClientsideExtensionsWebpackPlugin.ts"],"names":[],"mappings":";;AAAA,oDAAoB;AACpB,wDAAwB;AAExB,wDAAwB;AACxB,yEAAyC;AACzC,6CAA+C;AAC/C,8FAA0D;AAC1D,oFAAmD;AAEnD,wEAA+C;AAE/C,sGAA8E;AAC9E,2FAAuG;AACvG,uDAAiF;AAGjF,mCAAiD;AAEjD,gFAA4E;AAW5E,iBAAS,MAAM,iCAAiC;IAS5C,YAAY,UAA8C,EAAE;QACxD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YAClB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;SAC9E;QAED,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAExC,IAAI,CAAC,SAAS,GAAG,iCAAiC,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE;YAC1F,oBAAoB;YACpB,cAAc;SACjB,CAAC;aACG,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,iCAAiC,CAAC,wBAAwB,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CA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E,QAAsC;QAC5F,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAC;QAC7B,MAAM,WAAW,GAAG,cAAc,EAAE,EAAE,CAAC;QAEvC,OAAO;YACH,GAAG,QAAQ;YACX,SAAS;YACT,UAAU,EAAE,WAAW;YACvB,uBAAuB,EAAE,GAAG,SAAS,IAAI,GAAG,EAAE;SACjD,CAAC;IACN,CAAC;IAEO,MAAM,CAAC,oBAAoB,CAAC,GAAW;QAC3C,OAAO,mBAAS,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;CACJ,CAAC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport type { Compilation, Compiler, WebpackPluginInstance } from 'webpack';\nimport glob from 'glob';\nimport kebabCase from 'lodash/kebabCase';\nimport { pd as PrettyData } from 'pretty-data';\nimport VirtualModulePlugin from 'webpack-virtual-modules';\nimport transformComment from './transform-comment';\nimport type { AnnotationKey, AnnotationParserFunction, AnnotationParserOptions, Annotations, RawAnnotations } from './annotations';\nimport annotationsParsers from './annotations';\n\nimport generateWebfragmentDescriptor from './generator/webfragmentDescriptor';\nimport generateWebpageDescriptor, { PAGE_DATA_PROVIDER_DATA_KEY } from './generator/webpageDescriptor';\nimport { generateEntrypointCode, isPageExtension } from './generator/entrypoint';\n\nimport type { ClientsideExtensionsManifest, ClientsideExtensionsOptions, DataProvider, IWrmPluginOptions } from './types';\nimport { getKeyValue, isNotNull } from './utils';\n\nimport transformConditionToConditionMapObject from './generator/conditions';\n\n// Infer the type \"Source\" which is not exposed by Webpack\ntype Asset = Compilation['assets'] extends Record<string, infer S> ? S : never;\n\ninterface IClientsideExtensionsPluginOptions {\n pattern?: string;\n cwd?: string;\n xmlDescriptors?: string;\n}\n\nexport = class ClientsideExtensionsWebpackPlugin {\n private readonly pattern: string;\n\n private readonly cwd: string;\n\n private readonly outputFilename?: string;\n\n private manifests: ClientsideExtensionsManifest[];\n\n constructor(options: IClientsideExtensionsPluginOptions = {}) {\n if (!options.pattern) {\n throw new Error('No pattern was specified to match clientside extensions');\n }\n\n this.outputFilename = options.xmlDescriptors;\n this.pattern = options.pattern;\n this.cwd = options.cwd || process.cwd();\n\n this.manifests = ClientsideExtensionsWebpackPlugin.findFilesByPattern(this.pattern, this.cwd, [\n '**/node_modules/**',\n '**/target/**',\n ])\n .map((file) => ClientsideExtensionsWebpackPlugin.parseManifestFromComment(file, this.cwd))\n .filter(isNotNull);\n }\n\n public generateEntrypoints() {\n return this.manifests.reduce((agg, manifest) => {\n const id = ClientsideExtensionsWebpackPlugin.getIdFromManifestKey(manifest.key);\n agg[id] = ClientsideExtensionsWebpackPlugin.getFilenameForEntry(id);\n\n return agg;\n }, {} as { [key: string]: string });\n }\n\n apply(compiler: Compiler) {\n const wrmOptions = ClientsideExtensionsWebpackPlugin.getWrmWebpackPluginOptions(compiler);\n\n const extensionsOptions = this.manifests.map((manifest) => {\n return ClientsideExtensionsWebpackPlugin.manifestToPluginOptions(wrmOptions.pluginKey, manifest);\n });\n\n // side effect\n ClientsideExtensionsWebpackPlugin.addContextToEntrypoints(extensionsOptions, wrmOptions);\n\n // side effect\n ClientsideExtensionsWebpackPlugin.addDataProvidersToEntrypoints(extensionsOptions, wrmOptions);\n\n // side effect\n ClientsideExtensionsWebpackPlugin.addConditionToEntrypoint(extensionsOptions, wrmOptions);\n\n const virtualModules = extensionsOptions.reduce((agg, extensionOption) => {\n const fileName = ClientsideExtensionsWebpackPlugin.getFilenameForEntry(extensionOption.id);\n agg[fileName] = generateEntrypointCode(extensionOption);\n return agg;\n }, {} as Record<string, string>);\n new VirtualModulePlugin(virtualModules).apply(compiler);\n\n compiler.hooks.compilation.tap('Tap compilation for XML generation', (compilation) => {\n const webfragmentDescriptors = extensionsOptions.map((extensionOption) => generateWebfragmentDescriptor(extensionOption));\n const webpageDescriptors = extensionsOptions.map((extensionOption) => generateWebpageDescriptor(extensionOption));\n\n const descriptors = [...webfragmentDescriptors, ...webpageDescriptors].join('');\n const xmlDescriptors = PrettyData.xml(`<clientside-extension>${descriptors}</clientside-extension>`);\n\n const xmlDescriptorDirname = path.dirname(\n path.relative(compiler.options.output.path || '', this.outputFilename || wrmOptions.xmlDescriptors),\n );\n const xmlDescriptorFilename = path.basename(this.outputFilename || 'wr-generated-clientside-extensions.xml');\n const webpanelXmlDescriptorFilename = path.join(xmlDescriptorDirname, xmlDescriptorFilename);\n\n compilation.hooks.additionalAssets.tap('Generate clientside-extension XML', () => {\n compilation.assets[webpanelXmlDescriptorFilename] = {\n source: () => Buffer.from(xmlDescriptors),\n size: () => Buffer.byteLength(xmlDescriptors),\n } as Asset;\n });\n });\n }\n\n private static addContextToEntrypoints(extensionOptions: ClientsideExtensionsOptions[], wrmOptions: IWrmPluginOptions) {\n extensionOptions.forEach((extensionOption) => {\n const { contextMap } = wrmOptions;\n const entrypointId = ClientsideExtensionsWebpackPlugin.getIdFromManifestKey(extensionOption.key);\n const context = extensionOption.extensionPoint;\n\n contextMap.set(entrypointId, [context]);\n });\n }\n\n private static addDataProvidersToEntrypoints(extensionOptions: ClientsideExtensionsOptions[], wrmOptions: IWrmPluginOptions) {\n extensionOptions\n .filter((extensionOption) => Boolean(extensionOption.pageDataProvider))\n .forEach((extensionOption) => {\n const { dataProvidersMap } = wrmOptions;\n const entrypointId = ClientsideExtensionsWebpackPlugin.getIdFromManifestKey(extensionOption.key);\n const dataProvider: DataProvider = {\n key: PAGE_DATA_PROVIDER_DATA_KEY,\n class: extensionOption.pageDataProvider!,\n };\n\n dataProvidersMap.set(entrypointId, [dataProvider]);\n });\n }\n\n private static addConditionToEntrypoint(extensionOptions: ClientsideExtensionsOptions[], wrmOptions: IWrmPluginOptions) {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const hasCondition = (extensionOptions: ClientsideExtensionsOptions) => Boolean(extensionOptions.condition);\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const isNotPageExtension = (extensionOptions: ClientsideExtensionsOptions) => !isPageExtension(extensionOptions);\n\n extensionOptions\n .filter(hasCondition)\n .filter(isNotPageExtension)\n .forEach((extensionOption) => {\n const entrypointId = ClientsideExtensionsWebpackPlugin.getIdFromManifestKey(extensionOption.key);\n const conditionMap = transformConditionToConditionMapObject(extensionOption.condition!);\n\n const conditionMapPluginOption = wrmOptions.conditionMap as Map<string, object>;\n\n conditionMapPluginOption.set(entrypointId, conditionMap);\n });\n }\n\n private static transformAnnotationsIntoManifest(\n rawAnnotations: RawAnnotations,\n filePath: string,\n cwd: string,\n ): ClientsideExtensionsManifest {\n const parserOptions: AnnotationParserOptions = {\n cwd,\n filePath,\n };\n\n const annotations = {} as Annotations;\n const entries = Object.entries(annotationsParsers) as [[AnnotationKey, AnnotationParserFunction]];\n\n for (const [annotationKey, annotationParser] of entries) {\n const rawAnnotation = getKeyValue(rawAnnotations, annotationKey);\n const newAnnotations = annotationParser(rawAnnotation, rawAnnotations, parserOptions);\n\n if (newAnnotations !== null) {\n Object.assign(annotations, newAnnotations);\n }\n }\n\n const manifest: ClientsideExtensionsManifest = {\n id: ClientsideExtensionsWebpackPlugin.getIdFromManifestKey(annotations.key),\n filePath,\n ...annotations,\n };\n\n return manifest;\n }\n\n private static parseManifestFromComment(file: string, cwd: string): ClientsideExtensionsManifest | null {\n const fileContent = fs.readFileSync(file, 'utf8');\n const annotations = transformComment(fileContent);\n\n if (!annotations) {\n console.warn(`Client-side Extension: The file: \"${file}\" does not contain meta comments. Skipping XML-descriptor generation.`);\n return null;\n }\n\n return ClientsideExtensionsWebpackPlugin.transformAnnotationsIntoManifest(annotations, file, cwd);\n }\n\n private static findFilesByPattern(pattern: string, cwd: string, ignore?: string[]) {\n return glob.sync(pattern, { absolute: true, cwd, ignore });\n }\n\n private static getWrmWebpackPluginOptions(compiler: Compiler): IWrmPluginOptions {\n const { plugins } = compiler.options;\n if (!plugins) {\n throw new Error(`Something went mighty wrong. Can't find any plugins in webpack`);\n }\n const wrmPlugin = plugins.find((p) => p.constructor.name === 'WrmPlugin');\n\n if (!wrmPlugin) {\n throw new Error(\n `Can't find the WrmPlugin. Make sure you are using this plugin only in conjunction with the atlassian-webresource-webpack-plugin`,\n );\n }\n\n return (wrmPlugin as WebpackPluginInstance & { options: IWrmPluginOptions }).options;\n }\n\n private static getFilenameForEntry(manifestId: string) {\n return `./generated-clientside-extension/${manifestId}.js`;\n }\n\n private static manifestToPluginOptions(pluginKey: string, manifest: ClientsideExtensionsManifest): ClientsideExtensionsOptions {\n const { id, key } = manifest;\n const resourceKey = `entrypoint-${id}`;\n\n return {\n ...manifest,\n pluginKey,\n entryPoint: resourceKey,\n fullyQualifiedNamespace: `${pluginKey}:${key}`,\n };\n }\n\n private static getIdFromManifestKey(key: string) {\n return kebabCase(key);\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ClientsideExtensionsWebpackPlugin.js","sourceRoot":"","sources":["../../lib/ClientsideExtensionsWebpackPlugin.ts"],"names":[],"mappings":";;AAAA,yDAAoB;AACpB,6DAAwB;AAExB,6DAAwB;AACxB,8EAAyC;AACzC,6CAA+C;AAC/C,mGAA0D;AAC1D,yFAAmD;AAEnD,6EAA+C;AAE/C,2GAA8E;AAC9E,gGAAuG;AACvG,uDAAiF;AAGjF,mCAAiD;AAEjD,qFAA4E;AAW5E,MAAM,iCAAiC;IASnC,YAAY,UAA8C,EAAE;QACxD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YAClB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;SAC9E;QAED,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAExC,IAAI,CAAC,SAAS,GAAG,iCAAiC,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE;YAC1F,oBAAoB;YACpB,cAAc;SACjB,CAAC;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AC;IACzF,CAAC;IAEO,MAAM,CAAC,mBAAmB,CAAC,UAAkB;QACjD,OAAO,oCAAoC,UAAU,KAAK,CAAC;IAC/D,CAAC;IAEO,MAAM,CAAC,uBAAuB,CAAC,SAAiB,EAAE,QAAsC;QAC5F,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAC;QAC7B,MAAM,WAAW,GAAG,cAAc,EAAE,EAAE,CAAC;QAEvC,OAAO;YACH,GAAG,QAAQ;YACX,SAAS;YACT,UAAU,EAAE,WAAW;YACvB,uBAAuB,EAAE,GAAG,SAAS,IAAI,GAAG,EAAE;SACjD,CAAC;IACN,CAAC;IAEO,MAAM,CAAC,oBAAoB,CAAC,GAAW;QAC3C,OAAO,IAAA,mBAAS,EAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;CACJ;AAED,iBAAS,iCAAiC,CAAC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport type { Compilation, Compiler, WebpackPluginInstance } from 'webpack';\nimport glob from 'glob';\nimport kebabCase from 'lodash/kebabCase';\nimport { pd as PrettyData } from 'pretty-data';\nimport VirtualModulePlugin from 'webpack-virtual-modules';\nimport transformComment from './transform-comment';\nimport type { AnnotationKey, AnnotationParserFunction, AnnotationParserOptions, Annotations, RawAnnotations } from './annotations';\nimport annotationsParsers from './annotations';\n\nimport generateWebfragmentDescriptor from './generator/webfragmentDescriptor';\nimport generateWebpageDescriptor, { PAGE_DATA_PROVIDER_DATA_KEY } from './generator/webpageDescriptor';\nimport { generateEntrypointCode, isPageExtension } from './generator/entrypoint';\n\nimport type { ClientsideExtensionsManifest, ClientsideExtensionsOptions, DataProvider, IWrmPluginOptions } from './types';\nimport { getKeyValue, isNotNull } from './utils';\n\nimport transformConditionToConditionMapObject from './generator/conditions';\n\n// Infer the type \"Source\" which is not exposed by Webpack\ntype Asset = Compilation['assets'] extends Record<string, infer S> ? S : never;\n\ninterface IClientsideExtensionsPluginOptions {\n pattern?: string;\n cwd?: string;\n xmlDescriptors?: string;\n}\n\nclass ClientsideExtensionsWebpackPlugin {\n private readonly pattern: string;\n\n private readonly cwd: string;\n\n private readonly outputFilename?: string;\n\n private manifests: ClientsideExtensionsManifest[];\n\n constructor(options: IClientsideExtensionsPluginOptions = {}) {\n if (!options.pattern) {\n throw new Error('No pattern was specified to match clientside extensions');\n }\n\n this.outputFilename = options.xmlDescriptors;\n this.pattern = options.pattern;\n this.cwd = options.cwd || process.cwd();\n\n this.manifests = ClientsideExtensionsWebpackPlugin.findFilesByPattern(this.pattern, this.cwd, [\n '**/node_modules/**',\n '**/target/**',\n ])\n .map((file) => ClientsideExtensionsWebpackPlugin.parseManifestFromComment(file, this.cwd))\n .filter(isNotNull);\n }\n\n public generateEntrypoints() {\n return this.manifests.reduce((agg, manifest) => {\n const id = ClientsideExtensionsWebpackPlugin.getIdFromManifestKey(manifest.key);\n agg[id] = ClientsideExtensionsWebpackPlugin.getFilenameForEntry(id);\n\n return agg;\n }, {} as { [key: string]: string });\n }\n\n apply(compiler: Compiler) {\n const wrmOptions = ClientsideExtensionsWebpackPlugin.getWrmWebpackPluginOptions(compiler);\n\n const extensionsOptions = this.manifests.map((manifest) => {\n return ClientsideExtensionsWebpackPlugin.manifestToPluginOptions(wrmOptions.pluginKey, manifest);\n });\n\n // side effect\n ClientsideExtensionsWebpackPlugin.addContextToEntrypoints(extensionsOptions, wrmOptions);\n\n // side effect\n ClientsideExtensionsWebpackPlugin.addDataProvidersToEntrypoints(extensionsOptions, wrmOptions);\n\n // side effect\n ClientsideExtensionsWebpackPlugin.addConditionToEntrypoint(extensionsOptions, wrmOptions);\n\n const virtualModules = extensionsOptions.reduce((agg, extensionOption) => {\n const fileName = ClientsideExtensionsWebpackPlugin.getFilenameForEntry(extensionOption.id);\n agg[fileName] = generateEntrypointCode(extensionOption);\n return agg;\n }, {} as Record<string, string>);\n new VirtualModulePlugin(virtualModules).apply(compiler);\n\n compiler.hooks.compilation.tap('Tap compilation for XML generation', (compilation) => {\n const webfragmentDescriptors = extensionsOptions.map((extensionOption) => generateWebfragmentDescriptor(extensionOption));\n const webpageDescriptors = extensionsOptions.map((extensionOption) => generateWebpageDescriptor(extensionOption));\n\n const descriptors = [...webfragmentDescriptors, ...webpageDescriptors].join('');\n const xmlDescriptors = PrettyData.xml(`<clientside-extension>${descriptors}</clientside-extension>`);\n\n const xmlDescriptorDirname = path.dirname(\n path.relative(compiler.options.output.path || '', this.outputFilename || wrmOptions.xmlDescriptors),\n );\n const xmlDescriptorFilename = path.basename(this.outputFilename || 'wr-generated-clientside-extensions.xml');\n const webpanelXmlDescriptorFilename = path.join(xmlDescriptorDirname, xmlDescriptorFilename);\n\n compilation.hooks.additionalAssets.tap('Generate clientside-extension XML', () => {\n compilation.assets[webpanelXmlDescriptorFilename] = {\n source: () => Buffer.from(xmlDescriptors),\n size: () => Buffer.byteLength(xmlDescriptors),\n } as Asset;\n });\n });\n }\n\n private static addContextToEntrypoints(extensionOptions: ClientsideExtensionsOptions[], wrmOptions: IWrmPluginOptions) {\n extensionOptions.forEach((extensionOption) => {\n const { contextMap } = wrmOptions;\n const entrypointId = ClientsideExtensionsWebpackPlugin.getIdFromManifestKey(extensionOption.key);\n const context = extensionOption.extensionPoint;\n\n contextMap.set(entrypointId, [context]);\n });\n }\n\n private static addDataProvidersToEntrypoints(extensionOptions: ClientsideExtensionsOptions[], wrmOptions: IWrmPluginOptions) {\n extensionOptions\n .filter((extensionOption) => Boolean(extensionOption.pageDataProvider))\n .forEach((extensionOption) => {\n const { dataProvidersMap } = wrmOptions;\n const entrypointId = ClientsideExtensionsWebpackPlugin.getIdFromManifestKey(extensionOption.key);\n const dataProvider: DataProvider = {\n key: PAGE_DATA_PROVIDER_DATA_KEY,\n class: extensionOption.pageDataProvider!,\n };\n\n dataProvidersMap.set(entrypointId, [dataProvider]);\n });\n }\n\n private static addConditionToEntrypoint(extensionOptions: ClientsideExtensionsOptions[], wrmOptions: IWrmPluginOptions) {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const hasCondition = (extensionOptions: ClientsideExtensionsOptions) => Boolean(extensionOptions.condition);\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const isNotPageExtension = (extensionOptions: ClientsideExtensionsOptions) => !isPageExtension(extensionOptions);\n\n extensionOptions\n .filter(hasCondition)\n .filter(isNotPageExtension)\n .forEach((extensionOption) => {\n const entrypointId = ClientsideExtensionsWebpackPlugin.getIdFromManifestKey(extensionOption.key);\n const conditionMap = transformConditionToConditionMapObject(extensionOption.condition!);\n\n const conditionMapPluginOption = wrmOptions.conditionMap as Map<string, object>;\n\n conditionMapPluginOption.set(entrypointId, conditionMap);\n });\n }\n\n private static transformAnnotationsIntoManifest(\n rawAnnotations: RawAnnotations,\n filePath: string,\n cwd: string,\n ): ClientsideExtensionsManifest {\n const parserOptions: AnnotationParserOptions = {\n cwd,\n filePath,\n };\n\n const annotations = {} as Annotations;\n const entries = Object.entries(annotationsParsers) as [[AnnotationKey, AnnotationParserFunction]];\n\n for (const [annotationKey, annotationParser] of entries) {\n const rawAnnotation = getKeyValue(rawAnnotations, annotationKey);\n const newAnnotations = annotationParser(rawAnnotation, rawAnnotations, parserOptions);\n\n if (newAnnotations !== null) {\n Object.assign(annotations, newAnnotations);\n }\n }\n\n const manifest: ClientsideExtensionsManifest = {\n id: ClientsideExtensionsWebpackPlugin.getIdFromManifestKey(annotations.key),\n filePath,\n ...annotations,\n };\n\n return manifest;\n }\n\n private static parseManifestFromComment(file: string, cwd: string): ClientsideExtensionsManifest | null {\n const fileContent = fs.readFileSync(file, 'utf8');\n const annotations = transformComment(fileContent);\n\n if (!annotations) {\n console.warn(`Client-side Extension: The file: \"${file}\" does not contain meta comments. Skipping XML-descriptor generation.`);\n return null;\n }\n\n return ClientsideExtensionsWebpackPlugin.transformAnnotationsIntoManifest(annotations, file, cwd);\n }\n\n private static findFilesByPattern(pattern: string, cwd: string, ignore?: string[]) {\n return glob.sync(pattern, { absolute: true, cwd, ignore });\n }\n\n private static getWrmWebpackPluginOptions(compiler: Compiler): IWrmPluginOptions {\n const { plugins } = compiler.options;\n if (!plugins) {\n throw new Error(`Something went mighty wrong. Can't find any plugins in webpack`);\n }\n const wrmPlugin = plugins.find((p) => p.constructor.name === 'WrmPlugin');\n\n if (!wrmPlugin) {\n throw new Error(\n `Can't find the WrmPlugin. Make sure you are using this plugin only in conjunction with the atlassian-webresource-webpack-plugin`,\n );\n }\n\n return (wrmPlugin as WebpackPluginInstance & { options: IWrmPluginOptions }).options;\n }\n\n private static getFilenameForEntry(manifestId: string) {\n return `./generated-clientside-extension/${manifestId}.js`;\n }\n\n private static manifestToPluginOptions(pluginKey: string, manifest: ClientsideExtensionsManifest): ClientsideExtensionsOptions {\n const { id, key } = manifest;\n const resourceKey = `entrypoint-${id}`;\n\n return {\n ...manifest,\n pluginKey,\n entryPoint: resourceKey,\n fullyQualifiedNamespace: `${pluginKey}:${key}`,\n };\n }\n\n private static getIdFromManifestKey(key: string) {\n return kebabCase(key);\n }\n}\n\nexport = ClientsideExtensionsWebpackPlugin;\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const parsers = tslib_1.__importStar(require("./parsers"));
|
|
5
|
-
tslib_1.__exportStar(require("./types"), exports);
|
|
4
|
+
const parsers = (0, tslib_1.__importStar)(require("./parsers"));
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./types"), exports);
|
|
6
6
|
exports.default = parsers;
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/annotations/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/annotations/index.ts"],"names":[],"mappings":";;;AAAA,gEAAqC;AAGrC,uDAAwB;AAExB,kBAAe,OAA4B,CAAC","sourcesContent":["import * as parsers from './parsers';\nimport type { AnnotationParsers } from './types';\n\nexport * from './types';\n\nexport default parsers as AnnotationParsers;\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
4
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
5
5
|
const ANNOTATION_KEY = 'key';
|
|
6
6
|
const keyParser = (rawValue, rawAnnotations, options) => {
|
|
7
7
|
let key;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key.js","sourceRoot":"","sources":["../../../lib/annotations/key.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"key.js","sourceRoot":"","sources":["../../../lib/annotations/key.ts"],"names":[],"mappings":";;;AAAA,6DAAwB;AAGxB,MAAM,cAAc,GAAkB,KAAK,CAAC;AAE5C,MAAM,SAAS,GAAqC,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,EAAE;IACtF,IAAI,GAAW,CAAC;IAEhB,IAAI,QAAQ,EAAE;QACV,GAAG,GAAG,QAAQ,CAAC;KAClB;SAAM;QACH,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAClC,GAAG,GAAG,cAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;KACtC;IAED,sFAAsF;IACtF,4DAA4D;IAC5D,MAAM,MAAM,GAAG,iBAAiB,CAAC;IAEjC,OAAO;QACH,CAAC,cAAc,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC;KAC9C,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["import path from 'path';\nimport type { AnnotationKey, AnnotationParserFunction } from './types';\n\nconst ANNOTATION_KEY: AnnotationKey = 'key';\n\nconst keyParser: AnnotationParserFunction<string> = (rawValue, rawAnnotations, options) => {\n let key: string;\n\n if (rawValue) {\n key = rawValue;\n } else {\n const { cwd, filePath } = options;\n key = path.relative(cwd, filePath);\n }\n\n // Sanitize the key to keep only the alphanumeric characters, dashes, and underscores.\n // Keep the $ char since \"$key\" value is a reserved keyword.\n const regExp = /[^a-z0-9$_-]+/gi;\n\n return {\n [ANNOTATION_KEY]: key.replace(regExp, '__'),\n };\n};\n\nexport default keyParser;\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ANNOTATION_KEY = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const default_parser_1 = tslib_1.__importDefault(require("./default-parser"));
|
|
5
|
+
const default_parser_1 = (0, tslib_1.__importDefault)(require("./default-parser"));
|
|
6
6
|
exports.ANNOTATION_KEY = 'label';
|
|
7
|
-
exports.default = default_parser_1.default(exports.ANNOTATION_KEY);
|
|
7
|
+
exports.default = (0, default_parser_1.default)(exports.ANNOTATION_KEY);
|
|
8
8
|
//# sourceMappingURL=label.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../../lib/annotations/label.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../../lib/annotations/label.ts"],"names":[],"mappings":";;;;AAAA,mFAAgD;AAGnC,QAAA,cAAc,GAAkB,OAAO,CAAC;AAErD,kBAAe,IAAA,wBAAgB,EAAS,sBAAc,CAAC,CAAC","sourcesContent":["import getDefaultParser from './default-parser';\nimport type { AnnotationKey } from './types';\n\nexport const ANNOTATION_KEY: AnnotationKey = 'label';\n\nexport default getDefaultParser<string>(ANNOTATION_KEY);\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ANNOTATION_KEY = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const default_parser_1 = tslib_1.__importDefault(require("./default-parser"));
|
|
5
|
+
const default_parser_1 = (0, tslib_1.__importDefault)(require("./default-parser"));
|
|
6
6
|
exports.ANNOTATION_KEY = 'link';
|
|
7
|
-
exports.default = default_parser_1.default(exports.ANNOTATION_KEY);
|
|
7
|
+
exports.default = (0, default_parser_1.default)(exports.ANNOTATION_KEY);
|
|
8
8
|
//# sourceMappingURL=link.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../../lib/annotations/link.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../../lib/annotations/link.ts"],"names":[],"mappings":";;;;AAAA,mFAAgD;AAGnC,QAAA,cAAc,GAAmC,MAAM,CAAC;AAErE,kBAAe,IAAA,wBAAgB,EAAS,sBAAc,CAAC,CAAC","sourcesContent":["import getDefaultParser from './default-parser';\nimport type { AnnotationKey } from './types';\n\nexport const ANNOTATION_KEY: Extract<AnnotationKey, 'link'> = 'link';\n\nexport default getDefaultParser<string>(ANNOTATION_KEY);\n"]}
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.weight = exports.pageUrl = exports.pageTitle = exports.pageDecorator = exports.link = exports.label = exports.key = exports.extensionPoint = exports.pageDataProvider = exports.condition = void 0;
|
|
3
7
|
var condition_1 = require("./condition");
|
|
4
|
-
Object.defineProperty(exports, "condition", { enumerable: true, get: function () { return condition_1.default; } });
|
|
8
|
+
Object.defineProperty(exports, "condition", { enumerable: true, get: function () { return __importDefault(condition_1).default; } });
|
|
5
9
|
var page_data_provider_1 = require("./page-data-provider");
|
|
6
|
-
Object.defineProperty(exports, "pageDataProvider", { enumerable: true, get: function () { return page_data_provider_1.default; } });
|
|
10
|
+
Object.defineProperty(exports, "pageDataProvider", { enumerable: true, get: function () { return __importDefault(page_data_provider_1).default; } });
|
|
7
11
|
var extension_point_1 = require("./extension-point");
|
|
8
|
-
Object.defineProperty(exports, "extensionPoint", { enumerable: true, get: function () { return extension_point_1.default; } });
|
|
12
|
+
Object.defineProperty(exports, "extensionPoint", { enumerable: true, get: function () { return __importDefault(extension_point_1).default; } });
|
|
9
13
|
var key_1 = require("./key");
|
|
10
|
-
Object.defineProperty(exports, "key", { enumerable: true, get: function () { return key_1.default; } });
|
|
14
|
+
Object.defineProperty(exports, "key", { enumerable: true, get: function () { return __importDefault(key_1).default; } });
|
|
11
15
|
var label_1 = require("./label");
|
|
12
|
-
Object.defineProperty(exports, "label", { enumerable: true, get: function () { return label_1.default; } });
|
|
16
|
+
Object.defineProperty(exports, "label", { enumerable: true, get: function () { return __importDefault(label_1).default; } });
|
|
13
17
|
var link_1 = require("./link");
|
|
14
|
-
Object.defineProperty(exports, "link", { enumerable: true, get: function () { return link_1.default; } });
|
|
18
|
+
Object.defineProperty(exports, "link", { enumerable: true, get: function () { return __importDefault(link_1).default; } });
|
|
15
19
|
var page_decorator_1 = require("./page-decorator");
|
|
16
|
-
Object.defineProperty(exports, "pageDecorator", { enumerable: true, get: function () { return page_decorator_1.default; } });
|
|
20
|
+
Object.defineProperty(exports, "pageDecorator", { enumerable: true, get: function () { return __importDefault(page_decorator_1).default; } });
|
|
17
21
|
var page_title_1 = require("./page-title");
|
|
18
|
-
Object.defineProperty(exports, "pageTitle", { enumerable: true, get: function () { return page_title_1.default; } });
|
|
22
|
+
Object.defineProperty(exports, "pageTitle", { enumerable: true, get: function () { return __importDefault(page_title_1).default; } });
|
|
19
23
|
var page_url_1 = require("./page-url");
|
|
20
|
-
Object.defineProperty(exports, "pageUrl", { enumerable: true, get: function () { return page_url_1.default; } });
|
|
24
|
+
Object.defineProperty(exports, "pageUrl", { enumerable: true, get: function () { return __importDefault(page_url_1).default; } });
|
|
21
25
|
var weight_1 = require("./weight");
|
|
22
|
-
Object.defineProperty(exports, "weight", { enumerable: true, get: function () { return weight_1.default; } });
|
|
26
|
+
Object.defineProperty(exports, "weight", { enumerable: true, get: function () { return __importDefault(weight_1).default; } });
|
|
23
27
|
//# sourceMappingURL=parsers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsers.js","sourceRoot":"","sources":["../../../lib/annotations/parsers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parsers.js","sourceRoot":"","sources":["../../../lib/annotations/parsers.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAmD;AAA1C,uHAAA,OAAO,OAAa;AAC7B,2DAAmE;AAA1D,uIAAA,OAAO,OAAoB;AACpC,qDAA8D;AAArD,kIAAA,OAAO,OAAkB;AAClC,6BAAuC;AAA9B,2GAAA,OAAO,OAAO;AACvB,iCAA2C;AAAlC,+GAAA,OAAO,OAAS;AACzB,+BAAyC;AAAhC,6GAAA,OAAO,OAAQ;AACxB,mDAA4D;AAAnD,gIAAA,OAAO,OAAiB;AACjC,2CAAoD;AAA3C,wHAAA,OAAO,OAAa;AAC7B,uCAAgD;AAAvC,oHAAA,OAAO,OAAW;AAC3B,mCAA6C;AAApC,iHAAA,OAAO,OAAU","sourcesContent":["export { default as condition } from './condition';\nexport { default as pageDataProvider } from './page-data-provider';\nexport { default as extensionPoint } from './extension-point';\nexport { default as key } from './key';\nexport { default as label } from './label';\nexport { default as link } from './link';\nexport { default as pageDecorator } from './page-decorator';\nexport { default as pageTitle } from './page-title';\nexport { default as pageUrl } from './page-url';\nexport { default as weight } from './weight';\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const set_1 = tslib_1.__importDefault(require("lodash/set"));
|
|
4
|
+
const set_1 = (0, tslib_1.__importDefault)(require("lodash/set"));
|
|
5
5
|
function transformConditionToConditionMapObject(condition) {
|
|
6
6
|
const conditionMap = {};
|
|
7
7
|
try {
|
|
8
8
|
for (const [keyPath, value] of Object.entries(condition)) {
|
|
9
|
-
set_1.default(conditionMap, keyPath, value);
|
|
9
|
+
(0, set_1.default)(conditionMap, keyPath, value);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditions.js","sourceRoot":"","sources":["../../../lib/generator/conditions.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"conditions.js","sourceRoot":"","sources":["../../../lib/generator/conditions.ts"],"names":[],"mappings":";;;AAAA,kEAA6B;AAI7B,SAAwB,sCAAsC,CAAC,SAAuB;IAClF,MAAM,YAAY,GAAG,EAAe,CAAC;IAErC,IAAI;QACA,KAAK,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YACtD,IAAA,aAAG,EAAC,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;SACrC;KACJ;IAAC,OAAO,CAAC,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC;KAC9F;IAED,OAAO,YAAY,CAAC;AACxB,CAAC;AAZD,yDAYC","sourcesContent":["import set from 'lodash/set';\nimport type { ConditionMap } from '../annotations';\nimport type { Condition } from './xml';\n\nexport default function transformConditionToConditionMapObject(condition: ConditionMap): Condition {\n const conditionMap = {} as Condition;\n\n try {\n for (const [keyPath, value] of Object.entries(condition)) {\n set(conditionMap, keyPath, value);\n }\n } catch (e) {\n throw new Error(`Client-side Extension: The syntax of \"@condition\" annotation is invalid`);\n }\n\n return conditionMap;\n}\n"]}
|
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateEntrypointCode = exports.isPageExtension = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
5
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
6
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
7
7
|
const extensionEntrypointTemplate = fs_1.default.readFileSync(path_1.default.join(__dirname, '..', 'runtime', 'extension-entrypoint.js'), 'utf8');
|
|
8
8
|
const webPageEntrypointTemplate = fs_1.default.readFileSync(path_1.default.join(__dirname, '..', 'runtime', 'web-page-entrypoint.js'), 'utf8');
|
|
9
|
-
|
|
9
|
+
const isPageExtension = (extensionOptions) => {
|
|
10
10
|
return Boolean(extensionOptions.pageUrl);
|
|
11
11
|
};
|
|
12
|
+
exports.isPageExtension = isPageExtension;
|
|
12
13
|
const warnOnAnnotationDeprecation = (annotation, attribute = annotation) => {
|
|
13
14
|
console.error(`!!!
|
|
14
15
|
The "@${annotation}" annotation is deprecated. Please provide the "${attribute}" in your javascript code instead.
|
|
15
16
|
!!!`);
|
|
16
17
|
};
|
|
17
18
|
function generateEntrypointCode(extensionOption) {
|
|
18
|
-
const template = exports.isPageExtension(extensionOption) ? webPageEntrypointTemplate : extensionEntrypointTemplate;
|
|
19
|
+
const template = (0, exports.isPageExtension)(extensionOption) ? webPageEntrypointTemplate : extensionEntrypointTemplate;
|
|
19
20
|
const { weight, extensionPoint, label, link } = extensionOption;
|
|
20
21
|
if (label) {
|
|
21
22
|
warnOnAnnotationDeprecation('label');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoint.js","sourceRoot":"","sources":["../../../lib/generator/entrypoint.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"entrypoint.js","sourceRoot":"","sources":["../../../lib/generator/entrypoint.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AAe,CAAC,uBAAuB,CAAC;SAC3E,OAAO,CACJ,iCAAiC,EACjC,IAAI,CAAC,SAAS,CAAC;QACX,QAAQ,EAAE,cAAc;QACxB,KAAK;QACL,MAAM;QACN,GAAG,EAAE,IAAI;KACZ,CAAC,CACL,CAAC;AACV,CAAC;AA3BD,wDA2BC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport type { ClientsideExtensionsOptions } from '../types';\n\nconst extensionEntrypointTemplate = fs.readFileSync(path.join(__dirname, '..', 'runtime', 'extension-entrypoint.js'), 'utf8');\nconst webPageEntrypointTemplate = fs.readFileSync(path.join(__dirname, '..', 'runtime', 'web-page-entrypoint.js'), 'utf8');\n\nexport const isPageExtension = (extensionOptions: ClientsideExtensionsOptions) => {\n return Boolean(extensionOptions.pageUrl);\n};\n\nconst warnOnAnnotationDeprecation = (annotation: string, attribute: string = annotation): void => {\n console.error(`!!!\nThe \"@${annotation}\" annotation is deprecated. Please provide the \"${attribute}\" in your javascript code instead.\n!!!`);\n};\n\nexport function generateEntrypointCode(extensionOption: ClientsideExtensionsOptions) {\n const template = isPageExtension(extensionOption) ? webPageEntrypointTemplate : extensionEntrypointTemplate;\n\n const { weight, extensionPoint, label, link } = extensionOption;\n\n if (label) {\n warnOnAnnotationDeprecation('label');\n }\n if (weight) {\n warnOnAnnotationDeprecation('weight');\n }\n if (link) {\n warnOnAnnotationDeprecation('link', 'url');\n }\n\n return template\n .replace(/REPLACE_WITH_PATHNAME/g, extensionOption.filePath)\n .replace(/REPLACE_WITH_PLUGIN_ID/g, extensionOption.fullyQualifiedNamespace)\n .replace(\n /REPLACE_WITH_EXTENSION_OPTIONS/g,\n JSON.stringify({\n location: extensionPoint,\n label,\n weight,\n url: link,\n }),\n );\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const xml_1 = require("./xml");
|
|
5
|
-
const conditions_1 = tslib_1.__importDefault(require("./conditions"));
|
|
5
|
+
const conditions_1 = (0, tslib_1.__importDefault)(require("./conditions"));
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
7
|
/**
|
|
8
8
|
* This generator ensures that web-fragment tags are generated for the extension. It will generate:
|
|
@@ -12,17 +12,17 @@ const utils_1 = require("../utils");
|
|
|
12
12
|
* in a major version of all product. Currently, both CSE 1.x and 2.x are used by Bitbucket Server 7.x.
|
|
13
13
|
*/
|
|
14
14
|
function generateWebfragmentDescriptor(options) {
|
|
15
|
-
const label = xml_1.renderElement('label', { key: options.label });
|
|
16
|
-
const link = options.link && xml_1.renderElement('link', {}, options.link);
|
|
15
|
+
const label = (0, xml_1.renderElement)('label', { key: options.label });
|
|
16
|
+
const link = options.link && (0, xml_1.renderElement)('link', {}, options.link);
|
|
17
17
|
let conditions;
|
|
18
18
|
if (options.condition) {
|
|
19
|
-
const conditionMap = conditions_1.default(options.condition);
|
|
20
|
-
conditions = xml_1.renderCondition(conditionMap);
|
|
19
|
+
const conditionMap = (0, conditions_1.default)(options.condition);
|
|
20
|
+
conditions = (0, xml_1.renderCondition)(conditionMap);
|
|
21
21
|
}
|
|
22
22
|
const children = [label, link, conditions]
|
|
23
23
|
.filter(utils_1.isNotNullOrUndefined)
|
|
24
|
-
.map((value) => utils_1.replaceKey(value, options.fullyQualifiedNamespace));
|
|
25
|
-
return xml_1.renderElement('web-item', { key: options.key, section: options.extensionPoint, weight: options.weight }, children);
|
|
24
|
+
.map((value) => (0, utils_1.replaceKey)(value, options.fullyQualifiedNamespace));
|
|
25
|
+
return (0, xml_1.renderElement)('web-item', { key: options.key, section: options.extensionPoint, weight: options.weight }, children);
|
|
26
26
|
}
|
|
27
27
|
exports.default = generateWebfragmentDescriptor;
|
|
28
28
|
//# sourceMappingURL=webfragmentDescriptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webfragmentDescriptor.js","sourceRoot":"","sources":["../../../lib/generator/webfragmentDescriptor.ts"],"names":[],"mappings":";;;AAAA,+BAAuD;AAEvD,
|
|
1
|
+
{"version":3,"file":"webfragmentDescriptor.js","sourceRoot":"","sources":["../../../lib/generator/webfragmentDescriptor.ts"],"names":[],"mappings":";;;AAAA,+BAAuD;AAEvD,2EAAkE;AAClE,oCAA4D;AAE5D;;;;;;GAMG;AACH,SAAwB,6BAA6B,CAAC,OAAoC;IACtF,MAAM,KAAK,GAAG,IAAA,mBAAa,EAAC,OAAO,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,KAAM,EAAE,CAAC,CAAC;IAC9D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAA,mBAAa,EAAC,MAAM,EAAE,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAErE,IAAI,UAAU,CAAC;IAEf,IAAI,OAAO,CAAC,SAAS,EAAE;QACnB,MAAM,YAAY,GAAG,IAAA,oBAAsC,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAE/E,UAAU,GAAG,IAAA,qBAAe,EAAC,YAAY,CAAC,CAAC;KAC9C;IAED,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC;SACrC,MAAM,CAAC,4BAAoB,CAAC;SAC5B,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,kBAAU,EAAC,KAAK,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC;IAExE,OAAO,IAAA,mBAAa,EAAC,UAAU,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,MAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;AAC/H,CAAC;AAjBD,gDAiBC","sourcesContent":["import { renderElement, renderCondition } from './xml';\nimport type { ClientsideExtensionsOptions } from '../types';\nimport transformConditionToConditionMapObject from './conditions';\nimport { isNotNullOrUndefined, replaceKey } from '../utils';\n\n/**\n * This generator ensures that web-fragment tags are generated for the extension. It will generate:\n * - a <web-item> tag required for the PageExtension\n * - a legacy <web-item> descriptor required by the extensions in CSE version 1.x\n * The generation of the legacy <web-item> could be removed once all the products migrate to use only CSE 2+\n * in a major version of all product. Currently, both CSE 1.x and 2.x are used by Bitbucket Server 7.x.\n */\nexport default function generateWebfragmentDescriptor(options: ClientsideExtensionsOptions): string | null {\n const label = renderElement('label', { key: options.label! });\n const link = options.link && renderElement('link', {}, options.link);\n\n let conditions;\n\n if (options.condition) {\n const conditionMap = transformConditionToConditionMapObject(options.condition);\n\n conditions = renderCondition(conditionMap);\n }\n\n const children = [label, link, conditions]\n .filter(isNotNullOrUndefined)\n .map((value) => replaceKey(value, options.fullyQualifiedNamespace));\n\n return renderElement('web-item', { key: options.key, section: options.extensionPoint, weight: options.weight! }, children);\n}\n"]}
|
|
@@ -5,7 +5,7 @@ const xml_1 = require("./xml");
|
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
exports.PAGE_DATA_PROVIDER_DATA_KEY = 'data-provider';
|
|
7
7
|
const generateWebpageDescriptor = (options) => {
|
|
8
|
-
if (!utils_1.isPageExtension(options)) {
|
|
8
|
+
if (!(0, utils_1.isPageExtension)(options)) {
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
11
|
// Complete data provider key e.g. [groupId].[artifactId]:[webResourceKey].[dataKey]
|
|
@@ -25,16 +25,16 @@ const generateWebpageDescriptor = (options) => {
|
|
|
25
25
|
['page-decorator', options.pageDecorator],
|
|
26
26
|
];
|
|
27
27
|
const attributes = Object.fromEntries(webpageAttributes.filter(([, value]) => value));
|
|
28
|
-
const urlPatternNode = xml_1.renderElement('url-pattern', null, options.pageUrl);
|
|
28
|
+
const urlPatternNode = (0, xml_1.renderElement)('url-pattern', null, options.pageUrl);
|
|
29
29
|
let pageTitleNode;
|
|
30
30
|
if (options.pageTitle) {
|
|
31
|
-
pageTitleNode = xml_1.renderElement('page-title', { key: options.pageTitle });
|
|
31
|
+
pageTitleNode = (0, xml_1.renderElement)('page-title', { key: options.pageTitle });
|
|
32
32
|
}
|
|
33
|
-
const dependencyNode = xml_1.renderElement('dependency', null, webResourceKey);
|
|
33
|
+
const dependencyNode = (0, xml_1.renderElement)('dependency', null, webResourceKey);
|
|
34
34
|
const children = [urlPatternNode, pageTitleNode, dependencyNode]
|
|
35
35
|
.filter(utils_1.isNotNullOrUndefined)
|
|
36
|
-
.map((value) => utils_1.replaceKey(value, options.fullyQualifiedNamespace));
|
|
37
|
-
return xml_1.renderElement('web-page', attributes, children);
|
|
36
|
+
.map((value) => (0, utils_1.replaceKey)(value, options.fullyQualifiedNamespace));
|
|
37
|
+
return (0, xml_1.renderElement)('web-page', attributes, children);
|
|
38
38
|
};
|
|
39
39
|
exports.default = generateWebpageDescriptor;
|
|
40
40
|
//# sourceMappingURL=webpageDescriptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpageDescriptor.js","sourceRoot":"","sources":["../../../lib/generator/webpageDescriptor.ts"],"names":[],"mappings":";;;AAAA,+BAAsC;AAEtC,oCAA6E;AAEhE,QAAA,2BAA2B,GAAG,eAAe,CAAC;AAE3D,MAAM,yBAAyB,GAAG,CAAC,OAAoC,EAAiB,EAAE;IACtF,IAAI,CAAC,uBAAe,
|
|
1
|
+
{"version":3,"file":"webpageDescriptor.js","sourceRoot":"","sources":["../../../lib/generator/webpageDescriptor.ts"],"names":[],"mappings":";;;AAAA,+BAAsC;AAEtC,oCAA6E;AAEhE,QAAA,2BAA2B,GAAG,eAAe,CAAC;AAE3D,MAAM,yBAAyB,GAAG,CAAC,OAAoC,EAAiB,EAAE;IACtF,IAAI,CAAC,IAAA,uBAAe,EAAC,OAAO,CAAC,EAAE;QAC3B,OAAO,IAAI,CAAC;KACf;IAED,oFAAoF;IACpF,IAAI,mBAAmB,CAAC;IAExB,IAAI,OAAO,CAAC,gBAAgB,EAAE;QAC1B,mBAAmB,GAAG,GAAG,OAAO,CAAC,S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AExE,OAAO,IAAA,mBAAa,EAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC3D,CAAC,CAAC;AAEF,kBAAe,yBAAyB,CAAC","sourcesContent":["import { renderElement } from './xml';\nimport type { ClientsideExtensionsOptions } from '../types';\nimport { isNotNullOrUndefined, isPageExtension, replaceKey } from '../utils';\n\nexport const PAGE_DATA_PROVIDER_DATA_KEY = 'data-provider';\n\nconst generateWebpageDescriptor = (options: ClientsideExtensionsOptions): string | null => {\n if (!isPageExtension(options)) {\n return null;\n }\n\n // Complete data provider key e.g. [groupId].[artifactId]:[webResourceKey].[dataKey]\n let pageDataProviderKey;\n\n if (options.pageDataProvider) {\n pageDataProviderKey = `${options.pluginKey}:${options.entryPoint}.${PAGE_DATA_PROVIDER_DATA_KEY}`;\n }\n\n // Ensure the module descriptor key is unique\n const moduleKey = `webpage-${options.key}`;\n\n // Get a full web-resource key for the extension entrypoint web-resource\n const webResourceKey = `${options.pluginKey}:${options.entryPoint}`;\n\n const webpageAttributes = [\n ['key', moduleKey],\n ['extension-point', options.extensionPoint],\n ['extension-key', options.fullyQualifiedNamespace],\n ['page-data-provider-key', pageDataProviderKey],\n ['page-decorator', options.pageDecorator],\n ];\n\n const attributes = Object.fromEntries(webpageAttributes.filter(([, value]) => value));\n\n const urlPatternNode = renderElement('url-pattern', null, options.pageUrl);\n\n let pageTitleNode;\n if (options.pageTitle) {\n pageTitleNode = renderElement('page-title', { key: options.pageTitle });\n }\n\n const dependencyNode = renderElement('dependency', null, webResourceKey);\n\n const children = [urlPatternNode, pageTitleNode, dependencyNode]\n .filter(isNotNullOrUndefined)\n .map((value) => replaceKey(value, options.fullyQualifiedNamespace));\n\n return renderElement('web-page', attributes, children);\n};\n\nexport default generateWebpageDescriptor;\n"]}
|
|
@@ -15,7 +15,7 @@ const serializeAttributes = (attributes) => {
|
|
|
15
15
|
})
|
|
16
16
|
.join(' ');
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
const renderElement = (name, attributes, children) => {
|
|
19
19
|
// render self-closing tags based on whether there is no child input.
|
|
20
20
|
if (!children) {
|
|
21
21
|
return `<${name} ${serializeAttributes(attributes)}/>`;
|
|
@@ -26,13 +26,14 @@ exports.renderElement = (name, attributes, children) => {
|
|
|
26
26
|
}
|
|
27
27
|
return `<${name} ${serializeAttributes(attributes)}>${children}</${name}>`;
|
|
28
28
|
};
|
|
29
|
+
exports.renderElement = renderElement;
|
|
29
30
|
const renderParams = (params) => {
|
|
30
31
|
if (!params) {
|
|
31
32
|
return '';
|
|
32
33
|
}
|
|
33
|
-
return params.map((param) => exports.renderElement('param', param.attributes, param.value)).join('');
|
|
34
|
+
return params.map((param) => (0, exports.renderElement)('param', param.attributes, param.value)).join('');
|
|
34
35
|
};
|
|
35
|
-
|
|
36
|
+
const renderCondition = (condition) => {
|
|
36
37
|
if (!condition) {
|
|
37
38
|
return '';
|
|
38
39
|
}
|
|
@@ -42,8 +43,9 @@ exports.renderCondition = (condition) => {
|
|
|
42
43
|
}
|
|
43
44
|
// we have a "conditions"-joiner for multiple sub conditions
|
|
44
45
|
if (condition.type) {
|
|
45
|
-
return exports.renderElement('conditions', { type: condition.type }, exports.renderCondition(condition.conditions));
|
|
46
|
+
return (0, exports.renderElement)('conditions', { type: condition.type }, (0, exports.renderCondition)(condition.conditions));
|
|
46
47
|
}
|
|
47
|
-
return exports.renderElement('condition', `class="${condition.class}" ${condition.invert ?
|
|
48
|
+
return (0, exports.renderElement)('condition', `class="${condition.class}" ${condition.invert ? 'invert="true"' : ''}`, renderParams(condition.params));
|
|
48
49
|
};
|
|
50
|
+
exports.renderCondition = renderCondition;
|
|
49
51
|
//# sourceMappingURL=xml.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xml.js","sourceRoot":"","sources":["../../../lib/generator/xml.ts"],"names":[],"mappings":";;;AAGA,MAAM,mBAAmB,GAAG,CAAC,UAAsC,EAAE,EAAE;IACnE,IAAI,CAAC,UAAU,EAAE;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CAAC,CAAC,EAAE,EAAE,EACvE,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,CACjC,CAAC;AACN,CAAC,CAAC;AAnBW,QAAA,eAAe,mBAmB1B","sourcesContent":["type Attributes = {\n [key: string]: string | number;\n};\nconst serializeAttributes = (attributes: Attributes | string | null) => {\n if (!attributes) {\n return '';\n }\n\n if (typeof attributes === 'string') {\n return attributes;\n }\n\n return Object.keys(attributes)\n .map((key) => {\n const val = typeof attributes[key] === 'undefined' ? '' : String(attributes[key]);\n return `${key}=\"${val}\"`;\n })\n .join(' ');\n};\n\nexport const renderElement = (name: string, attributes: Attributes | string | null, children?: string | string[]) => {\n // render self-closing tags based on whether there is no child input.\n if (!children) {\n return `<${name} ${serializeAttributes(attributes)}/>`;\n }\n\n // convert children array in to a string.\n if (Array.isArray(children)) {\n children = children.join('\\n');\n }\n\n return `<${name} ${serializeAttributes(attributes)}>${children}</${name}>`;\n};\n\ntype Param = {\n attributes: Attributes;\n value: string | string[];\n};\nconst renderParams = (params: Param[]) => {\n if (!params) {\n return '';\n }\n return params.map((param) => renderElement('param', param.attributes, param.value)).join('');\n};\n\nexport type Condition = {\n conditions?: Condition[];\n type: string;\n invert: boolean;\n class: string;\n params: Param[];\n};\nexport const renderCondition = (condition?: null | Condition | Condition[]): string => {\n if (!condition) {\n return '';\n }\n\n // we have actual conditions\n if (Array.isArray(condition)) {\n return condition.map(renderCondition).join('');\n }\n // we have a \"conditions\"-joiner for multiple sub conditions\n if (condition.type) {\n return renderElement('conditions', { type: condition.type }, renderCondition(condition.conditions));\n }\n\n return renderElement(\n 'condition',\n `class=\"${condition.class}\" ${condition.invert ? 'invert=\"true\"' : ''}`,\n renderParams(condition.params),\n );\n};\n"]}
|
|
@@ -4,13 +4,14 @@ exports.getOutputContentAsJson = exports.fileContent = void 0;
|
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
// eslint-disable-next-line import/no-extraneous-dependencies,node/no-unpublished-import
|
|
6
6
|
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
7
|
-
|
|
8
|
-
if (!fs_1.existsSync(filePath)) {
|
|
9
|
-
|
|
7
|
+
const fileContent = (filePath) => {
|
|
8
|
+
if (!(0, fs_1.existsSync)(filePath)) {
|
|
9
|
+
throw new Error(`File generated by webpack "${filePath}" does not exist`);
|
|
10
10
|
}
|
|
11
|
-
return String(fs_1.readFileSync(filePath, { encoding: 'utf8' }));
|
|
11
|
+
return String((0, fs_1.readFileSync)(filePath, { encoding: 'utf8' }));
|
|
12
12
|
};
|
|
13
|
-
exports.
|
|
13
|
+
exports.fileContent = fileContent;
|
|
14
|
+
const getOutputContentAsJson = (content) => {
|
|
14
15
|
if (content.trim() === '') {
|
|
15
16
|
return '';
|
|
16
17
|
}
|
|
@@ -20,8 +21,9 @@ exports.getOutputContentAsJson = (content) => {
|
|
|
20
21
|
attrNodeName: 'attrs',
|
|
21
22
|
attributeNamePrefix: '',
|
|
22
23
|
};
|
|
23
|
-
const root = fast_xml_parser_1.parse(content, xmlParseOptions);
|
|
24
|
+
const root = (0, fast_xml_parser_1.parse)(content, xmlParseOptions);
|
|
24
25
|
const rootKey = Object.keys(root)[0];
|
|
25
26
|
return root[rootKey];
|
|
26
27
|
};
|
|
28
|
+
exports.getOutputContentAsJson = getOutputContentAsJson;
|
|
27
29
|
//# sourceMappingURL=test-helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-helper.js","sourceRoot":"","sources":["../../../lib/tests/test-helper.ts"],"names":[],"mappings":";;;AAAA,2BAA8C;AAC9C,wFAAwF;AACxF,qDAAoD;
|
|
1
|
+
{"version":3,"file":"test-helper.js","sourceRoot":"","sources":["../../../lib/tests/test-helper.ts"],"names":[],"mappings":";;;AAAA,2BAA8C;AAC9C,wFAAwF;AACxF,qDAAoD;AAE7C,MAAM,WAAW,GAAG,CAAC,QAAgB,EAAE,EAAE;IAC5C,IAAI,CAAC,IAAA,eAAU,EAAC,QAAQ,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,8BAA8B,QAAQ,kBAAkB,CAAC,CAAC;KAC7E;IAED,OAAO,MAAM,CAAC,IAAA,iBAAY,EAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAChE,CAAC,CAAC;AANW,QAAA,WAAW,eAMtB;AAEK,MAAM,sBAAsB,GAAG,CAAC,OAAe,EAAE,EAAE;IACtD,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACvB,OAAO,EAAE,CAAC;KACb;IAED,MAAM,eAAe,GAAG;QACpB,SAAS,EAAE,IAAI;QACf,gBAAgB,EAAE,KAAK;QACvB,YAAY,EAAE,OAAO;QACrB,mBAAmB,EAAE,EAAE;KAC1B,CAAC;IAEF,MAAM,IAAI,GAAG,IAAA,uBAAQ,EAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAErC,OAAO,IAAI,CAAC,OAAO,CAAc,CAAC;AACtC,CAAC,CAAC;AAhBW,QAAA,sBAAsB,0BAgBjC","sourcesContent":["import { readFileSync, existsSync } from 'fs';\n// eslint-disable-next-line import/no-extraneous-dependencies,node/no-unpublished-import\nimport { parse as parseXml } from 'fast-xml-parser';\n\nexport const fileContent = (filePath: string) => {\n if (!existsSync(filePath)) {\n throw new Error(`File generated by webpack \"${filePath}\" does not exist`);\n }\n\n return String(readFileSync(filePath, { encoding: 'utf8' }));\n};\n\nexport const getOutputContentAsJson = (content: string) => {\n if (content.trim() === '') {\n return '';\n }\n\n const xmlParseOptions = {\n arrayMode: true,\n ignoreAttributes: false,\n attrNodeName: 'attrs',\n attributeNamePrefix: '',\n };\n\n const root = parseXml(content, xmlParseOptions);\n const rootKey = Object.keys(root)[0];\n\n return root[rootKey] as [unknown];\n};\n"]}
|