@quilted/rollup 0.1.0 → 0.1.2
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/CHANGELOG.md +15 -0
- package/build/cjs/app.cjs +85 -15
- package/build/cjs/env.cjs +21 -16
- package/build/cjs/request-router.cjs +2 -1
- package/build/cjs/shared/magic-module.cjs +0 -12
- package/build/cjs/shared/rollup.cjs +37 -0
- package/build/esm/app.mjs +65 -14
- package/build/esm/env.mjs +21 -17
- package/build/esm/request-router.mjs +4 -3
- package/build/esm/shared/magic-module.mjs +1 -12
- package/build/esm/shared/rollup.mjs +33 -0
- package/build/esnext/app.esnext +65 -14
- package/build/esnext/env.esnext +21 -17
- package/build/esnext/request-router.esnext +4 -3
- package/build/esnext/shared/magic-module.esnext +1 -12
- package/build/esnext/shared/rollup.esnext +33 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/app.d.ts +32 -10
- package/build/typescript/app.d.ts.map +1 -1
- package/build/typescript/env.d.ts +4 -0
- package/build/typescript/env.d.ts.map +1 -1
- package/build/typescript/request-router.d.ts.map +1 -1
- package/build/typescript/shared/magic-module.d.ts +0 -13
- package/build/typescript/shared/magic-module.d.ts.map +1 -1
- package/build/typescript/shared/rollup.d.ts +7 -0
- package/build/typescript/shared/rollup.d.ts.map +1 -0
- package/package.json +10 -2
- package/source/app.ts +85 -41
- package/source/env.ts +25 -2
- package/source/request-router.ts +4 -3
- package/source/shared/magic-module.ts +0 -11
- package/source/shared/rollup.ts +68 -0
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/TemplateTag/TemplateTag.cjs +0 -168
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.cjs +0 -8
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.cjs +0 -8
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.cjs +0 -8
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.cjs +0 -10
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineArrayTransformer/inlineArrayTransformer.cjs +0 -48
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.cjs +0 -8
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.cjs +0 -7
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.cjs +0 -8
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.cjs +0 -8
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.cjs +0 -8
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.cjs +0 -8
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.cjs +0 -7
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/removeNonPrintingValuesTransformer/removeNonPrintingValuesTransformer.cjs +0 -23
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceResultTransformer/replaceResultTransformer.cjs +0 -22
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceSubstitutionTransformer/replaceSubstitutionTransformer.cjs +0 -22
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.cjs +0 -10
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/splitStringTransformer/splitStringTransformer.cjs +0 -20
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.cjs +0 -11
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndentTransformer/stripIndentTransformer.cjs +0 -37
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.cjs +0 -7
- package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/trimResultTransformer/trimResultTransformer.cjs +0 -33
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/TemplateTag/TemplateTag.mjs +0 -164
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.mjs +0 -6
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.mjs +0 -6
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.mjs +0 -6
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.mjs +0 -8
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineArrayTransformer/inlineArrayTransformer.mjs +0 -44
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.mjs +0 -6
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.mjs +0 -5
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.mjs +0 -6
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.mjs +0 -6
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.mjs +0 -6
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.mjs +0 -6
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.mjs +0 -5
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/removeNonPrintingValuesTransformer/removeNonPrintingValuesTransformer.mjs +0 -19
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceResultTransformer/replaceResultTransformer.mjs +0 -18
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceSubstitutionTransformer/replaceSubstitutionTransformer.mjs +0 -18
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.mjs +0 -8
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/splitStringTransformer/splitStringTransformer.mjs +0 -16
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.mjs +0 -7
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndentTransformer/stripIndentTransformer.mjs +0 -33
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.mjs +0 -5
- package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/trimResultTransformer/trimResultTransformer.mjs +0 -29
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/TemplateTag/TemplateTag.esnext +0 -164
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.esnext +0 -6
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.esnext +0 -6
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.esnext +0 -6
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.esnext +0 -8
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineArrayTransformer/inlineArrayTransformer.esnext +0 -44
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.esnext +0 -6
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.esnext +0 -5
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.esnext +0 -6
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.esnext +0 -6
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.esnext +0 -6
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.esnext +0 -6
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.esnext +0 -5
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/removeNonPrintingValuesTransformer/removeNonPrintingValuesTransformer.esnext +0 -19
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceResultTransformer/replaceResultTransformer.esnext +0 -18
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceSubstitutionTransformer/replaceSubstitutionTransformer.esnext +0 -18
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.esnext +0 -8
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/splitStringTransformer/splitStringTransformer.esnext +0 -16
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.esnext +0 -7
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndentTransformer/stripIndentTransformer.esnext +0 -33
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.esnext +0 -5
- package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/trimResultTransformer/trimResultTransformer.esnext +0 -29
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* strips indentation from a template literal
|
|
5
|
-
* @param {String} type = 'initial' - whether to remove all indentation or just leading indentation. can be 'all' or 'initial'
|
|
6
|
-
* @return {Object} - a TemplateTag transformer
|
|
7
|
-
*/
|
|
8
|
-
var stripIndentTransformer = function stripIndentTransformer() {
|
|
9
|
-
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'initial';
|
|
10
|
-
return {
|
|
11
|
-
onEndResult: function onEndResult(endResult) {
|
|
12
|
-
if (type === 'initial') {
|
|
13
|
-
// remove the shortest leading indentation from each line
|
|
14
|
-
var match = endResult.match(/^[^\S\n]*(?=\S)/gm);
|
|
15
|
-
var indent = match && Math.min.apply(Math, _toConsumableArray(match.map(function (el) {
|
|
16
|
-
return el.length;
|
|
17
|
-
})));
|
|
18
|
-
if (indent) {
|
|
19
|
-
var regexp = new RegExp('^.{' + indent + '}', 'gm');
|
|
20
|
-
return endResult.replace(regexp, '');
|
|
21
|
-
}
|
|
22
|
-
return endResult;
|
|
23
|
-
}
|
|
24
|
-
if (type === 'all') {
|
|
25
|
-
// remove all indentation from each line
|
|
26
|
-
return endResult.replace(/^[^\S\n]+/gm, '');
|
|
27
|
-
}
|
|
28
|
-
throw new Error('Unknown type: ' + type);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export { stripIndentTransformer as default };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import TemplateTag from '../TemplateTag/TemplateTag.mjs';
|
|
2
|
-
import stripIndentTransformer from '../stripIndentTransformer/stripIndentTransformer.mjs';
|
|
3
|
-
import trimResultTransformer from '../trimResultTransformer/trimResultTransformer.mjs';
|
|
4
|
-
|
|
5
|
-
new TemplateTag(stripIndentTransformer('all'), trimResultTransformer);
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TemplateTag transformer that trims whitespace on the end result of a tagged template
|
|
3
|
-
* @param {String} side = '' - The side of the string to trim. Can be 'start' or 'end' (alternatively 'left' or 'right')
|
|
4
|
-
* @return {Object} - a TemplateTag transformer
|
|
5
|
-
*/
|
|
6
|
-
var trimResultTransformer = function trimResultTransformer() {
|
|
7
|
-
var side = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
8
|
-
return {
|
|
9
|
-
onEndResult: function onEndResult(endResult) {
|
|
10
|
-
if (side === '') {
|
|
11
|
-
return endResult.trim();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
side = side.toLowerCase();
|
|
15
|
-
|
|
16
|
-
if (side === 'start' || side === 'left') {
|
|
17
|
-
return endResult.replace(/^\s*/, '');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (side === 'end' || side === 'right') {
|
|
21
|
-
return endResult.replace(/\s*$/, '');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
throw new Error('Side not supported: ' + side);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export { trimResultTransformer as default };
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
2
|
-
|
|
3
|
-
var _templateObject = _taggedTemplateLiteral(['', ''], ['', '']);
|
|
4
|
-
|
|
5
|
-
function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
6
|
-
|
|
7
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @class TemplateTag
|
|
11
|
-
* @classdesc Consumes a pipeline of composable transformer plugins and produces a template tag.
|
|
12
|
-
*/
|
|
13
|
-
var TemplateTag = function () {
|
|
14
|
-
/**
|
|
15
|
-
* constructs a template tag
|
|
16
|
-
* @constructs TemplateTag
|
|
17
|
-
* @param {...Object} [...transformers] - an array or arguments list of transformers
|
|
18
|
-
* @return {Function} - a template tag
|
|
19
|
-
*/
|
|
20
|
-
function TemplateTag() {
|
|
21
|
-
var _this = this;
|
|
22
|
-
|
|
23
|
-
for (var _len = arguments.length, transformers = Array(_len), _key = 0; _key < _len; _key++) {
|
|
24
|
-
transformers[_key] = arguments[_key];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
_classCallCheck(this, TemplateTag);
|
|
28
|
-
|
|
29
|
-
this.tag = function (strings) {
|
|
30
|
-
for (var _len2 = arguments.length, expressions = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
31
|
-
expressions[_key2 - 1] = arguments[_key2];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (typeof strings === 'function') {
|
|
35
|
-
// if the first argument passed is a function, assume it is a template tag and return
|
|
36
|
-
// an intermediary tag that processes the template using the aforementioned tag, passing the
|
|
37
|
-
// result to our tag
|
|
38
|
-
return _this.interimTag.bind(_this, strings);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (typeof strings === 'string') {
|
|
42
|
-
// if the first argument passed is a string, just transform it
|
|
43
|
-
return _this.transformEndResult(strings);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// else, return a transformed end result of processing the template with our tag
|
|
47
|
-
strings = strings.map(_this.transformString.bind(_this));
|
|
48
|
-
return _this.transformEndResult(strings.reduce(_this.processSubstitutions.bind(_this, expressions)));
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// if first argument is an array, extrude it as a list of transformers
|
|
52
|
-
if (transformers.length > 0 && Array.isArray(transformers[0])) {
|
|
53
|
-
transformers = transformers[0];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// if any transformers are functions, this means they are not initiated - automatically initiate them
|
|
57
|
-
this.transformers = transformers.map(function (transformer) {
|
|
58
|
-
return typeof transformer === 'function' ? transformer() : transformer;
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// return an ES2015 template tag
|
|
62
|
-
return this.tag;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Applies all transformers to a template literal tagged with this method.
|
|
67
|
-
* If a function is passed as the first argument, assumes the function is a template tag
|
|
68
|
-
* and applies it to the template, returning a template tag.
|
|
69
|
-
* @param {(Function|String|Array<String>)} strings - Either a template tag or an array containing template strings separated by identifier
|
|
70
|
-
* @param {...*} ...expressions - Optional list of substitution values.
|
|
71
|
-
* @return {(String|Function)} - Either an intermediary tag function or the results of processing the template.
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
_createClass(TemplateTag, [{
|
|
76
|
-
key: 'interimTag',
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* An intermediary template tag that receives a template tag and passes the result of calling the template with the received
|
|
81
|
-
* template tag to our own template tag.
|
|
82
|
-
* @param {Function} nextTag - the received template tag
|
|
83
|
-
* @param {Array<String>} template - the template to process
|
|
84
|
-
* @param {...*} ...substitutions - `substitutions` is an array of all substitutions in the template
|
|
85
|
-
* @return {*} - the final processed value
|
|
86
|
-
*/
|
|
87
|
-
value: function interimTag(previousTag, template) {
|
|
88
|
-
for (var _len3 = arguments.length, substitutions = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
89
|
-
substitutions[_key3 - 2] = arguments[_key3];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return this.tag(_templateObject, previousTag.apply(undefined, [template].concat(substitutions)));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Performs bulk processing on the tagged template, transforming each substitution and then
|
|
97
|
-
* concatenating the resulting values into a string.
|
|
98
|
-
* @param {Array<*>} substitutions - an array of all remaining substitutions present in this template
|
|
99
|
-
* @param {String} resultSoFar - this iteration's result string so far
|
|
100
|
-
* @param {String} remainingPart - the template chunk after the current substitution
|
|
101
|
-
* @return {String} - the result of joining this iteration's processed substitution with the result
|
|
102
|
-
*/
|
|
103
|
-
|
|
104
|
-
}, {
|
|
105
|
-
key: 'processSubstitutions',
|
|
106
|
-
value: function processSubstitutions(substitutions, resultSoFar, remainingPart) {
|
|
107
|
-
var substitution = this.transformSubstitution(substitutions.shift(), resultSoFar);
|
|
108
|
-
return ''.concat(resultSoFar, substitution, remainingPart);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Iterate through each transformer, applying the transformer's `onString` method to the template
|
|
113
|
-
* strings before all substitutions are processed.
|
|
114
|
-
* @param {String} str - The input string
|
|
115
|
-
* @return {String} - The final results of processing each transformer
|
|
116
|
-
*/
|
|
117
|
-
|
|
118
|
-
}, {
|
|
119
|
-
key: 'transformString',
|
|
120
|
-
value: function transformString(str) {
|
|
121
|
-
var cb = function cb(res, transform) {
|
|
122
|
-
return transform.onString ? transform.onString(res) : res;
|
|
123
|
-
};
|
|
124
|
-
return this.transformers.reduce(cb, str);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* When a substitution is encountered, iterates through each transformer and applies the transformer's
|
|
129
|
-
* `onSubstitution` method to the substitution.
|
|
130
|
-
* @param {*} substitution - The current substitution
|
|
131
|
-
* @param {String} resultSoFar - The result up to and excluding this substitution.
|
|
132
|
-
* @return {*} - The final result of applying all substitution transformations.
|
|
133
|
-
*/
|
|
134
|
-
|
|
135
|
-
}, {
|
|
136
|
-
key: 'transformSubstitution',
|
|
137
|
-
value: function transformSubstitution(substitution, resultSoFar) {
|
|
138
|
-
var cb = function cb(res, transform) {
|
|
139
|
-
return transform.onSubstitution ? transform.onSubstitution(res, resultSoFar) : res;
|
|
140
|
-
};
|
|
141
|
-
return this.transformers.reduce(cb, substitution);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Iterates through each transformer, applying the transformer's `onEndResult` method to the
|
|
146
|
-
* template literal after all substitutions have finished processing.
|
|
147
|
-
* @param {String} endResult - The processed template, just before it is returned from the tag
|
|
148
|
-
* @return {String} - The final results of processing each transformer
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
}, {
|
|
152
|
-
key: 'transformEndResult',
|
|
153
|
-
value: function transformEndResult(endResult) {
|
|
154
|
-
var cb = function cb(res, transform) {
|
|
155
|
-
return transform.onEndResult ? transform.onEndResult(res) : res;
|
|
156
|
-
};
|
|
157
|
-
return this.transformers.reduce(cb, endResult);
|
|
158
|
-
}
|
|
159
|
-
}]);
|
|
160
|
-
|
|
161
|
-
return TemplateTag;
|
|
162
|
-
}();
|
|
163
|
-
|
|
164
|
-
export { TemplateTag as default };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import TemplateTag from '../TemplateTag/TemplateTag.esnext';
|
|
2
|
-
import stripIndentTransformer from '../stripIndentTransformer/stripIndentTransformer.esnext';
|
|
3
|
-
import inlineArrayTransformer from '../inlineArrayTransformer/inlineArrayTransformer.esnext';
|
|
4
|
-
import trimResultTransformer from '../trimResultTransformer/trimResultTransformer.esnext';
|
|
5
|
-
|
|
6
|
-
new TemplateTag(inlineArrayTransformer({ separator: ',' }), stripIndentTransformer, trimResultTransformer);
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import TemplateTag from '../TemplateTag/TemplateTag.esnext';
|
|
2
|
-
import stripIndentTransformer from '../stripIndentTransformer/stripIndentTransformer.esnext';
|
|
3
|
-
import inlineArrayTransformer from '../inlineArrayTransformer/inlineArrayTransformer.esnext';
|
|
4
|
-
import trimResultTransformer from '../trimResultTransformer/trimResultTransformer.esnext';
|
|
5
|
-
|
|
6
|
-
new TemplateTag(inlineArrayTransformer({ separator: ',', conjunction: 'and' }), stripIndentTransformer, trimResultTransformer);
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import TemplateTag from '../TemplateTag/TemplateTag.esnext';
|
|
2
|
-
import stripIndentTransformer from '../stripIndentTransformer/stripIndentTransformer.esnext';
|
|
3
|
-
import inlineArrayTransformer from '../inlineArrayTransformer/inlineArrayTransformer.esnext';
|
|
4
|
-
import trimResultTransformer from '../trimResultTransformer/trimResultTransformer.esnext';
|
|
5
|
-
|
|
6
|
-
new TemplateTag(inlineArrayTransformer({ separator: ',', conjunction: 'or' }), stripIndentTransformer, trimResultTransformer);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import TemplateTag from '../TemplateTag/TemplateTag.esnext';
|
|
2
|
-
import stripIndentTransformer from '../stripIndentTransformer/stripIndentTransformer.esnext';
|
|
3
|
-
import inlineArrayTransformer from '../inlineArrayTransformer/inlineArrayTransformer.esnext';
|
|
4
|
-
import trimResultTransformer from '../trimResultTransformer/trimResultTransformer.esnext';
|
|
5
|
-
import splitStringTransformer from '../splitStringTransformer/splitStringTransformer.esnext';
|
|
6
|
-
import removeNonPrintingValuesTransformer from '../removeNonPrintingValuesTransformer/removeNonPrintingValuesTransformer.esnext';
|
|
7
|
-
|
|
8
|
-
new TemplateTag(splitStringTransformer('\n'), removeNonPrintingValuesTransformer, inlineArrayTransformer, stripIndentTransformer, trimResultTransformer);
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
var defaults = {
|
|
2
|
-
separator: '',
|
|
3
|
-
conjunction: '',
|
|
4
|
-
serial: false
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Converts an array substitution to a string containing a list
|
|
9
|
-
* @param {String} [opts.separator = ''] - the character that separates each item
|
|
10
|
-
* @param {String} [opts.conjunction = ''] - replace the last separator with this
|
|
11
|
-
* @param {Boolean} [opts.serial = false] - include the separator before the conjunction? (Oxford comma use-case)
|
|
12
|
-
*
|
|
13
|
-
* @return {Object} - a TemplateTag transformer
|
|
14
|
-
*/
|
|
15
|
-
var inlineArrayTransformer = function inlineArrayTransformer() {
|
|
16
|
-
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaults;
|
|
17
|
-
return {
|
|
18
|
-
onSubstitution: function onSubstitution(substitution, resultSoFar) {
|
|
19
|
-
// only operate on arrays
|
|
20
|
-
if (Array.isArray(substitution)) {
|
|
21
|
-
var arrayLength = substitution.length;
|
|
22
|
-
var separator = opts.separator;
|
|
23
|
-
var conjunction = opts.conjunction;
|
|
24
|
-
var serial = opts.serial;
|
|
25
|
-
// join each item in the array into a string where each item is separated by separator
|
|
26
|
-
// be sure to maintain indentation
|
|
27
|
-
var indent = resultSoFar.match(/(\n?[^\S\n]+)$/);
|
|
28
|
-
if (indent) {
|
|
29
|
-
substitution = substitution.join(separator + indent[1]);
|
|
30
|
-
} else {
|
|
31
|
-
substitution = substitution.join(separator + ' ');
|
|
32
|
-
}
|
|
33
|
-
// if conjunction is set, replace the last separator with conjunction, but only if there is more than one substitution
|
|
34
|
-
if (conjunction && arrayLength > 1) {
|
|
35
|
-
var separatorIndex = substitution.lastIndexOf(separator);
|
|
36
|
-
substitution = substitution.slice(0, separatorIndex) + (serial ? separator : '') + ' ' + conjunction + substitution.slice(separatorIndex + 1);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return substitution;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export { inlineArrayTransformer as default };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import TemplateTag from '../TemplateTag/TemplateTag.esnext';
|
|
2
|
-
import stripIndentTransformer from '../stripIndentTransformer/stripIndentTransformer.esnext';
|
|
3
|
-
import inlineArrayTransformer from '../inlineArrayTransformer/inlineArrayTransformer.esnext';
|
|
4
|
-
import trimResultTransformer from '../trimResultTransformer/trimResultTransformer.esnext';
|
|
5
|
-
|
|
6
|
-
new TemplateTag(inlineArrayTransformer, stripIndentTransformer, trimResultTransformer);
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import TemplateTag from '../TemplateTag/TemplateTag.esnext';
|
|
2
|
-
import trimResultTransformer from '../trimResultTransformer/trimResultTransformer.esnext';
|
|
3
|
-
import replaceResultTransformer from '../replaceResultTransformer/replaceResultTransformer.esnext';
|
|
4
|
-
|
|
5
|
-
new TemplateTag(replaceResultTransformer(/(?:\n(?:\s*))+/g, ' '), trimResultTransformer);
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import TemplateTag from '../TemplateTag/TemplateTag.esnext';
|
|
2
|
-
import inlineArrayTransformer from '../inlineArrayTransformer/inlineArrayTransformer.esnext';
|
|
3
|
-
import trimResultTransformer from '../trimResultTransformer/trimResultTransformer.esnext';
|
|
4
|
-
import replaceResultTransformer from '../replaceResultTransformer/replaceResultTransformer.esnext';
|
|
5
|
-
|
|
6
|
-
new TemplateTag(inlineArrayTransformer({ separator: ',' }), replaceResultTransformer(/(?:\s+)/g, ' '), trimResultTransformer);
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import TemplateTag from '../TemplateTag/TemplateTag.esnext';
|
|
2
|
-
import inlineArrayTransformer from '../inlineArrayTransformer/inlineArrayTransformer.esnext';
|
|
3
|
-
import trimResultTransformer from '../trimResultTransformer/trimResultTransformer.esnext';
|
|
4
|
-
import replaceResultTransformer from '../replaceResultTransformer/replaceResultTransformer.esnext';
|
|
5
|
-
|
|
6
|
-
new TemplateTag(inlineArrayTransformer({ separator: ',', conjunction: 'and' }), replaceResultTransformer(/(?:\s+)/g, ' '), trimResultTransformer);
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import TemplateTag from '../TemplateTag/TemplateTag.esnext';
|
|
2
|
-
import inlineArrayTransformer from '../inlineArrayTransformer/inlineArrayTransformer.esnext';
|
|
3
|
-
import trimResultTransformer from '../trimResultTransformer/trimResultTransformer.esnext';
|
|
4
|
-
import replaceResultTransformer from '../replaceResultTransformer/replaceResultTransformer.esnext';
|
|
5
|
-
|
|
6
|
-
new TemplateTag(inlineArrayTransformer({ separator: ',', conjunction: 'or' }), replaceResultTransformer(/(?:\s+)/g, ' '), trimResultTransformer);
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import TemplateTag from '../TemplateTag/TemplateTag.esnext';
|
|
2
|
-
import inlineArrayTransformer from '../inlineArrayTransformer/inlineArrayTransformer.esnext';
|
|
3
|
-
import trimResultTransformer from '../trimResultTransformer/trimResultTransformer.esnext';
|
|
4
|
-
import replaceResultTransformer from '../replaceResultTransformer/replaceResultTransformer.esnext';
|
|
5
|
-
|
|
6
|
-
new TemplateTag(inlineArrayTransformer, replaceResultTransformer(/(?:\s+)/g, ' '), trimResultTransformer);
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import TemplateTag from '../TemplateTag/TemplateTag.esnext';
|
|
2
|
-
import trimResultTransformer from '../trimResultTransformer/trimResultTransformer.esnext';
|
|
3
|
-
import replaceResultTransformer from '../replaceResultTransformer/replaceResultTransformer.esnext';
|
|
4
|
-
|
|
5
|
-
new TemplateTag(replaceResultTransformer(/(?:\n\s*)/g, ''), trimResultTransformer);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
var isValidValue = function isValidValue(x) {
|
|
2
|
-
return x != null && !Number.isNaN(x) && typeof x !== 'boolean';
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
var removeNonPrintingValuesTransformer = function removeNonPrintingValuesTransformer() {
|
|
6
|
-
return {
|
|
7
|
-
onSubstitution: function onSubstitution(substitution) {
|
|
8
|
-
if (Array.isArray(substitution)) {
|
|
9
|
-
return substitution.filter(isValidValue);
|
|
10
|
-
}
|
|
11
|
-
if (isValidValue(substitution)) {
|
|
12
|
-
return substitution;
|
|
13
|
-
}
|
|
14
|
-
return '';
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export { removeNonPrintingValuesTransformer as default };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Replaces tabs, newlines and spaces with the chosen value when they occur in sequences
|
|
3
|
-
* @param {(String|RegExp)} replaceWhat - the value or pattern that should be replaced
|
|
4
|
-
* @param {*} replaceWith - the replacement value
|
|
5
|
-
* @return {Object} - a TemplateTag transformer
|
|
6
|
-
*/
|
|
7
|
-
var replaceResultTransformer = function replaceResultTransformer(replaceWhat, replaceWith) {
|
|
8
|
-
return {
|
|
9
|
-
onEndResult: function onEndResult(endResult) {
|
|
10
|
-
if (replaceWhat == null || replaceWith == null) {
|
|
11
|
-
throw new Error('replaceResultTransformer requires at least 2 arguments.');
|
|
12
|
-
}
|
|
13
|
-
return endResult.replace(replaceWhat, replaceWith);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export { replaceResultTransformer as default };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
var replaceSubstitutionTransformer = function replaceSubstitutionTransformer(replaceWhat, replaceWith) {
|
|
2
|
-
return {
|
|
3
|
-
onSubstitution: function onSubstitution(substitution, resultSoFar) {
|
|
4
|
-
if (replaceWhat == null || replaceWith == null) {
|
|
5
|
-
throw new Error('replaceSubstitutionTransformer requires at least 2 arguments.');
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
// Do not touch if null or undefined
|
|
9
|
-
if (substitution == null) {
|
|
10
|
-
return substitution;
|
|
11
|
-
} else {
|
|
12
|
-
return substitution.toString().replace(replaceWhat, replaceWith);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export { replaceSubstitutionTransformer as default };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import TemplateTag from '../TemplateTag/TemplateTag.esnext';
|
|
2
|
-
import stripIndentTransformer from '../stripIndentTransformer/stripIndentTransformer.esnext';
|
|
3
|
-
import inlineArrayTransformer from '../inlineArrayTransformer/inlineArrayTransformer.esnext';
|
|
4
|
-
import trimResultTransformer from '../trimResultTransformer/trimResultTransformer.esnext';
|
|
5
|
-
import splitStringTransformer from '../splitStringTransformer/splitStringTransformer.esnext';
|
|
6
|
-
import replaceSubstitutionTransformer from '../replaceSubstitutionTransformer/replaceSubstitutionTransformer.esnext';
|
|
7
|
-
|
|
8
|
-
new TemplateTag(splitStringTransformer('\n'), inlineArrayTransformer, stripIndentTransformer, trimResultTransformer, replaceSubstitutionTransformer(/&/g, '&'), replaceSubstitutionTransformer(/</g, '<'), replaceSubstitutionTransformer(/>/g, '>'), replaceSubstitutionTransformer(/"/g, '"'), replaceSubstitutionTransformer(/'/g, '''), replaceSubstitutionTransformer(/`/g, '`'));
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
var splitStringTransformer = function splitStringTransformer(splitBy) {
|
|
2
|
-
return {
|
|
3
|
-
onSubstitution: function onSubstitution(substitution, resultSoFar) {
|
|
4
|
-
if (splitBy != null && typeof splitBy === 'string') {
|
|
5
|
-
if (typeof substitution === 'string' && substitution.includes(splitBy)) {
|
|
6
|
-
substitution = substitution.split(splitBy);
|
|
7
|
-
}
|
|
8
|
-
} else {
|
|
9
|
-
throw new Error('You need to specify a string character to split by.');
|
|
10
|
-
}
|
|
11
|
-
return substitution;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { splitStringTransformer as default };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import TemplateTag from '../TemplateTag/TemplateTag.esnext';
|
|
2
|
-
import stripIndentTransformer from '../stripIndentTransformer/stripIndentTransformer.esnext';
|
|
3
|
-
import trimResultTransformer from '../trimResultTransformer/trimResultTransformer.esnext';
|
|
4
|
-
|
|
5
|
-
var stripIndent = new TemplateTag(stripIndentTransformer, trimResultTransformer);
|
|
6
|
-
|
|
7
|
-
export { stripIndent as default };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* strips indentation from a template literal
|
|
5
|
-
* @param {String} type = 'initial' - whether to remove all indentation or just leading indentation. can be 'all' or 'initial'
|
|
6
|
-
* @return {Object} - a TemplateTag transformer
|
|
7
|
-
*/
|
|
8
|
-
var stripIndentTransformer = function stripIndentTransformer() {
|
|
9
|
-
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'initial';
|
|
10
|
-
return {
|
|
11
|
-
onEndResult: function onEndResult(endResult) {
|
|
12
|
-
if (type === 'initial') {
|
|
13
|
-
// remove the shortest leading indentation from each line
|
|
14
|
-
var match = endResult.match(/^[^\S\n]*(?=\S)/gm);
|
|
15
|
-
var indent = match && Math.min.apply(Math, _toConsumableArray(match.map(function (el) {
|
|
16
|
-
return el.length;
|
|
17
|
-
})));
|
|
18
|
-
if (indent) {
|
|
19
|
-
var regexp = new RegExp('^.{' + indent + '}', 'gm');
|
|
20
|
-
return endResult.replace(regexp, '');
|
|
21
|
-
}
|
|
22
|
-
return endResult;
|
|
23
|
-
}
|
|
24
|
-
if (type === 'all') {
|
|
25
|
-
// remove all indentation from each line
|
|
26
|
-
return endResult.replace(/^[^\S\n]+/gm, '');
|
|
27
|
-
}
|
|
28
|
-
throw new Error('Unknown type: ' + type);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export { stripIndentTransformer as default };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import TemplateTag from '../TemplateTag/TemplateTag.esnext';
|
|
2
|
-
import stripIndentTransformer from '../stripIndentTransformer/stripIndentTransformer.esnext';
|
|
3
|
-
import trimResultTransformer from '../trimResultTransformer/trimResultTransformer.esnext';
|
|
4
|
-
|
|
5
|
-
new TemplateTag(stripIndentTransformer('all'), trimResultTransformer);
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TemplateTag transformer that trims whitespace on the end result of a tagged template
|
|
3
|
-
* @param {String} side = '' - The side of the string to trim. Can be 'start' or 'end' (alternatively 'left' or 'right')
|
|
4
|
-
* @return {Object} - a TemplateTag transformer
|
|
5
|
-
*/
|
|
6
|
-
var trimResultTransformer = function trimResultTransformer() {
|
|
7
|
-
var side = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
8
|
-
return {
|
|
9
|
-
onEndResult: function onEndResult(endResult) {
|
|
10
|
-
if (side === '') {
|
|
11
|
-
return endResult.trim();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
side = side.toLowerCase();
|
|
15
|
-
|
|
16
|
-
if (side === 'start' || side === 'left') {
|
|
17
|
-
return endResult.replace(/^\s*/, '');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (side === 'end' || side === 'right') {
|
|
21
|
-
return endResult.replace(/\s*$/, '');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
throw new Error('Side not supported: ' + side);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export { trimResultTransformer as default };
|