@commercetools-frontend/mc-html-template 22.36.0 → 22.38.0
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.
|
@@ -70,15 +70,18 @@ const htmlScripts$1 = {
|
|
|
70
70
|
"publicPath": "window.__dynamicImportHandler__=function(n){return window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n.replace(/^(\\.\\/)?/,\"\")},window.__dynamicImportPreload__=function(n){return n.map(n=>window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n)};"
|
|
71
71
|
};
|
|
72
72
|
const toArray = value => _Array$isArray__default["default"](value) ? value : [value];
|
|
73
|
-
const
|
|
73
|
+
const mergeDirectives = function () {
|
|
74
74
|
for (var _len = arguments.length, directives = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
75
75
|
directives[_key] = arguments[_key];
|
|
76
76
|
}
|
|
77
|
-
return _reduceInstanceProperty__default["default"](directives).call(directives, (
|
|
77
|
+
return _reduceInstanceProperty__default["default"](directives).call(directives, (mergedDirectives, directive) => {
|
|
78
78
|
var _context;
|
|
79
|
-
return _Object$assign__default["default"](
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
return _Object$assign__default["default"](mergedDirectives, _reduceInstanceProperty__default["default"](_context = _Object$keys__default["default"](directive)).call(_context, (mergedDirectiveValues, directiveKey) => {
|
|
80
|
+
const existingDirectiveValue = mergedDirectives[directiveKey];
|
|
81
|
+
return _Object$assign__default["default"](mergedDirectiveValues, {
|
|
82
|
+
[directiveKey]: [...toArray(existingDirectiveValue ?? []), ...toArray(directive[directiveKey])]
|
|
83
|
+
});
|
|
84
|
+
}, {}));
|
|
82
85
|
}, {});
|
|
83
86
|
};
|
|
84
87
|
const toHeaderString = function () {
|
|
@@ -153,16 +156,14 @@ const processHeaders = applicationConfig => {
|
|
|
153
156
|
);
|
|
154
157
|
|
|
155
158
|
// Recursively merge the directives
|
|
156
|
-
const mergedCsp =
|
|
157
|
-
return _objectSpread(_objectSpread(
|
|
159
|
+
const mergedCsp = mergeDirectives(cspDirectives, applicationConfig.headers?.csp ?? {});
|
|
160
|
+
return _objectSpread(_objectSpread({}, constants.HTTP_SECURITY_HEADERS), {}, {
|
|
158
161
|
// The `Content-Security-Policy` header is always generated
|
|
159
162
|
// based on the Merchant Center customization config.
|
|
160
163
|
'Content-Security-Policy': toHeaderString(mergedCsp)
|
|
161
|
-
}, applicationConfig.headers?.
|
|
162
|
-
'Strict-Transport-Security': [constants.HTTP_SECURITY_HEADERS['Strict-Transport-Security'], ...applicationConfig.headers.strictTransportSecurity].join('; ')
|
|
163
|
-
}), applicationConfig.headers?.permissionsPolicies && {
|
|
164
|
+
}, applicationConfig.headers?.permissionsPolicies ? {
|
|
164
165
|
'Permissions-Policy': toStructuredHeaderString(applicationConfig.headers.permissionsPolicies)
|
|
165
|
-
});
|
|
166
|
+
} : {});
|
|
166
167
|
};
|
|
167
168
|
|
|
168
169
|
// https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
@@ -179,7 +180,7 @@ const replaceHtmlPlaceholders = (indexHtmlContent, options) => indexHtmlContent.
|
|
|
179
180
|
`${trimTrailingSlash(options.env.cdnUrl)}/` : '').replace(new RegExp('__MC_API_URL__', 'g'), trimTrailingSlash(options.env.mcApiUrl)).replace(new RegExp('__APPLICATION_ENVIRONMENT__', 'g'), `<script>window.app = ${sanitizeAppEnvironment(options.env)};</script>`).replace(new RegExp('__LOADING_SCREEN_JS__', 'g'), `<script>${htmlScripts.loadingScreen}</script>`).replace(new RegExp('__LOADING_SCREEN_CSS__', 'g'), `<style>${htmlStyles.loadingScreen}</style>`);
|
|
180
181
|
|
|
181
182
|
async function compileHtml(indexHtmlTemplatePath) {
|
|
182
|
-
const applicationConfig$1 = applicationConfig.processConfig();
|
|
183
|
+
const applicationConfig$1 = await applicationConfig.processConfig();
|
|
183
184
|
const compiledHeaders = processHeaders(applicationConfig$1);
|
|
184
185
|
const indexHtmlTemplateContent = fs__default["default"].readFileSync(indexHtmlTemplatePath, 'utf8');
|
|
185
186
|
const indexHtmlContent = replaceHtmlPlaceholders(indexHtmlTemplateContent, {
|
|
@@ -70,15 +70,18 @@ const htmlScripts$1 = {
|
|
|
70
70
|
"publicPath": "window.__dynamicImportHandler__=function(n){return window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n.replace(/^(\\.\\/)?/,\"\")},window.__dynamicImportPreload__=function(n){return n.map(n=>window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n)};"
|
|
71
71
|
};
|
|
72
72
|
const toArray = value => _Array$isArray__default["default"](value) ? value : [value];
|
|
73
|
-
const
|
|
73
|
+
const mergeDirectives = function () {
|
|
74
74
|
for (var _len = arguments.length, directives = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
75
75
|
directives[_key] = arguments[_key];
|
|
76
76
|
}
|
|
77
|
-
return _reduceInstanceProperty__default["default"](directives).call(directives, (
|
|
77
|
+
return _reduceInstanceProperty__default["default"](directives).call(directives, (mergedDirectives, directive) => {
|
|
78
78
|
var _context;
|
|
79
|
-
return _Object$assign__default["default"](
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
return _Object$assign__default["default"](mergedDirectives, _reduceInstanceProperty__default["default"](_context = _Object$keys__default["default"](directive)).call(_context, (mergedDirectiveValues, directiveKey) => {
|
|
80
|
+
const existingDirectiveValue = mergedDirectives[directiveKey];
|
|
81
|
+
return _Object$assign__default["default"](mergedDirectiveValues, {
|
|
82
|
+
[directiveKey]: [...toArray(existingDirectiveValue ?? []), ...toArray(directive[directiveKey])]
|
|
83
|
+
});
|
|
84
|
+
}, {}));
|
|
82
85
|
}, {});
|
|
83
86
|
};
|
|
84
87
|
const toHeaderString = function () {
|
|
@@ -153,16 +156,14 @@ const processHeaders = applicationConfig => {
|
|
|
153
156
|
);
|
|
154
157
|
|
|
155
158
|
// Recursively merge the directives
|
|
156
|
-
const mergedCsp =
|
|
157
|
-
return _objectSpread(_objectSpread(
|
|
159
|
+
const mergedCsp = mergeDirectives(cspDirectives, applicationConfig.headers?.csp ?? {});
|
|
160
|
+
return _objectSpread(_objectSpread({}, constants.HTTP_SECURITY_HEADERS), {}, {
|
|
158
161
|
// The `Content-Security-Policy` header is always generated
|
|
159
162
|
// based on the Merchant Center customization config.
|
|
160
163
|
'Content-Security-Policy': toHeaderString(mergedCsp)
|
|
161
|
-
}, applicationConfig.headers?.
|
|
162
|
-
'Strict-Transport-Security': [constants.HTTP_SECURITY_HEADERS['Strict-Transport-Security'], ...applicationConfig.headers.strictTransportSecurity].join('; ')
|
|
163
|
-
}), applicationConfig.headers?.permissionsPolicies && {
|
|
164
|
+
}, applicationConfig.headers?.permissionsPolicies ? {
|
|
164
165
|
'Permissions-Policy': toStructuredHeaderString(applicationConfig.headers.permissionsPolicies)
|
|
165
|
-
});
|
|
166
|
+
} : {});
|
|
166
167
|
};
|
|
167
168
|
|
|
168
169
|
// https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
@@ -179,7 +180,7 @@ const replaceHtmlPlaceholders = (indexHtmlContent, options) => indexHtmlContent.
|
|
|
179
180
|
`${trimTrailingSlash(options.env.cdnUrl)}/` : '').replace(new RegExp('__MC_API_URL__', 'g'), trimTrailingSlash(options.env.mcApiUrl)).replace(new RegExp('__APPLICATION_ENVIRONMENT__', 'g'), `<script>window.app = ${sanitizeAppEnvironment(options.env)};</script>`).replace(new RegExp('__LOADING_SCREEN_JS__', 'g'), `<script>${htmlScripts.loadingScreen}</script>`).replace(new RegExp('__LOADING_SCREEN_CSS__', 'g'), `<style>${htmlStyles.loadingScreen}</style>`);
|
|
180
181
|
|
|
181
182
|
async function compileHtml(indexHtmlTemplatePath) {
|
|
182
|
-
const applicationConfig$1 = applicationConfig.processConfig();
|
|
183
|
+
const applicationConfig$1 = await applicationConfig.processConfig();
|
|
183
184
|
const compiledHeaders = processHeaders(applicationConfig$1);
|
|
184
185
|
const indexHtmlTemplateContent = fs__default["default"].readFileSync(indexHtmlTemplatePath, 'utf8');
|
|
185
186
|
const indexHtmlContent = replaceHtmlPlaceholders(indexHtmlTemplateContent, {
|
|
@@ -46,15 +46,18 @@ const htmlScripts$1 = {
|
|
|
46
46
|
"publicPath": "window.__dynamicImportHandler__=function(n){return window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n.replace(/^(\\.\\/)?/,\"\")},window.__dynamicImportPreload__=function(n){return n.map(n=>window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n)};"
|
|
47
47
|
};
|
|
48
48
|
const toArray = value => _Array$isArray(value) ? value : [value];
|
|
49
|
-
const
|
|
49
|
+
const mergeDirectives = function () {
|
|
50
50
|
for (var _len = arguments.length, directives = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
51
51
|
directives[_key] = arguments[_key];
|
|
52
52
|
}
|
|
53
|
-
return _reduceInstanceProperty(directives).call(directives, (
|
|
53
|
+
return _reduceInstanceProperty(directives).call(directives, (mergedDirectives, directive) => {
|
|
54
54
|
var _context;
|
|
55
|
-
return _Object$assign(
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
return _Object$assign(mergedDirectives, _reduceInstanceProperty(_context = _Object$keys(directive)).call(_context, (mergedDirectiveValues, directiveKey) => {
|
|
56
|
+
const existingDirectiveValue = mergedDirectives[directiveKey];
|
|
57
|
+
return _Object$assign(mergedDirectiveValues, {
|
|
58
|
+
[directiveKey]: [...toArray(existingDirectiveValue ?? []), ...toArray(directive[directiveKey])]
|
|
59
|
+
});
|
|
60
|
+
}, {}));
|
|
58
61
|
}, {});
|
|
59
62
|
};
|
|
60
63
|
const toHeaderString = function () {
|
|
@@ -129,16 +132,14 @@ const processHeaders = applicationConfig => {
|
|
|
129
132
|
);
|
|
130
133
|
|
|
131
134
|
// Recursively merge the directives
|
|
132
|
-
const mergedCsp =
|
|
133
|
-
return _objectSpread(_objectSpread(
|
|
135
|
+
const mergedCsp = mergeDirectives(cspDirectives, applicationConfig.headers?.csp ?? {});
|
|
136
|
+
return _objectSpread(_objectSpread({}, HTTP_SECURITY_HEADERS), {}, {
|
|
134
137
|
// The `Content-Security-Policy` header is always generated
|
|
135
138
|
// based on the Merchant Center customization config.
|
|
136
139
|
'Content-Security-Policy': toHeaderString(mergedCsp)
|
|
137
|
-
}, applicationConfig.headers?.
|
|
138
|
-
'Strict-Transport-Security': [HTTP_SECURITY_HEADERS['Strict-Transport-Security'], ...applicationConfig.headers.strictTransportSecurity].join('; ')
|
|
139
|
-
}), applicationConfig.headers?.permissionsPolicies && {
|
|
140
|
+
}, applicationConfig.headers?.permissionsPolicies ? {
|
|
140
141
|
'Permissions-Policy': toStructuredHeaderString(applicationConfig.headers.permissionsPolicies)
|
|
141
|
-
});
|
|
142
|
+
} : {});
|
|
142
143
|
};
|
|
143
144
|
|
|
144
145
|
// https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
@@ -155,7 +156,7 @@ const replaceHtmlPlaceholders = (indexHtmlContent, options) => indexHtmlContent.
|
|
|
155
156
|
`${trimTrailingSlash(options.env.cdnUrl)}/` : '').replace(new RegExp('__MC_API_URL__', 'g'), trimTrailingSlash(options.env.mcApiUrl)).replace(new RegExp('__APPLICATION_ENVIRONMENT__', 'g'), `<script>window.app = ${sanitizeAppEnvironment(options.env)};</script>`).replace(new RegExp('__LOADING_SCREEN_JS__', 'g'), `<script>${htmlScripts.loadingScreen}</script>`).replace(new RegExp('__LOADING_SCREEN_CSS__', 'g'), `<style>${htmlStyles.loadingScreen}</style>`);
|
|
156
157
|
|
|
157
158
|
async function compileHtml(indexHtmlTemplatePath) {
|
|
158
|
-
const applicationConfig = processConfig();
|
|
159
|
+
const applicationConfig = await processConfig();
|
|
159
160
|
const compiledHeaders = processHeaders(applicationConfig);
|
|
160
161
|
const indexHtmlTemplateContent = fs.readFileSync(indexHtmlTemplatePath, 'utf8');
|
|
161
162
|
const indexHtmlContent = replaceHtmlPlaceholders(indexHtmlTemplateContent, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-frontend/mc-html-template",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.38.0",
|
|
4
4
|
"description": "Everything related to render the index.html for a MC application",
|
|
5
5
|
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
6
|
"repository": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@babel/runtime": "^7.22.15",
|
|
40
40
|
"@babel/runtime-corejs3": "^7.22.15",
|
|
41
|
-
"@commercetools-frontend/application-config": "22.
|
|
42
|
-
"@commercetools-frontend/constants": "22.
|
|
41
|
+
"@commercetools-frontend/application-config": "22.38.0",
|
|
42
|
+
"@commercetools-frontend/constants": "22.38.0",
|
|
43
43
|
"serialize-javascript": "6.0.2",
|
|
44
44
|
"uglify-js": "3.18.0",
|
|
45
45
|
"uglifycss": "0.0.29"
|