@quilted/deno 0.0.0-preview-20230922041245

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.
Files changed (91) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE.md +21 -0
  3. package/README.md +1 -0
  4. package/build/cjs/craft.cjs +106 -0
  5. package/build/cjs/index.cjs +2 -0
  6. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/TemplateTag/TemplateTag.cjs +168 -0
  7. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.cjs +8 -0
  8. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.cjs +8 -0
  9. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.cjs +8 -0
  10. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.cjs +10 -0
  11. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineArrayTransformer/inlineArrayTransformer.cjs +48 -0
  12. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.cjs +8 -0
  13. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.cjs +7 -0
  14. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.cjs +8 -0
  15. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.cjs +8 -0
  16. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.cjs +8 -0
  17. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.cjs +8 -0
  18. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.cjs +7 -0
  19. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/removeNonPrintingValuesTransformer/removeNonPrintingValuesTransformer.cjs +23 -0
  20. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceResultTransformer/replaceResultTransformer.cjs +22 -0
  21. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceSubstitutionTransformer/replaceSubstitutionTransformer.cjs +22 -0
  22. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.cjs +10 -0
  23. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/splitStringTransformer/splitStringTransformer.cjs +20 -0
  24. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.cjs +11 -0
  25. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndentTransformer/stripIndentTransformer.cjs +37 -0
  26. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.cjs +7 -0
  27. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/trimResultTransformer/trimResultTransformer.cjs +33 -0
  28. package/build/cjs/request-router.cjs +17 -0
  29. package/build/esm/craft.mjs +104 -0
  30. package/build/esm/index.mjs +1 -0
  31. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/TemplateTag/TemplateTag.mjs +164 -0
  32. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.mjs +6 -0
  33. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.mjs +6 -0
  34. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.mjs +6 -0
  35. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.mjs +8 -0
  36. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineArrayTransformer/inlineArrayTransformer.mjs +44 -0
  37. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.mjs +6 -0
  38. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.mjs +5 -0
  39. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.mjs +6 -0
  40. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.mjs +6 -0
  41. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.mjs +6 -0
  42. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.mjs +6 -0
  43. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.mjs +5 -0
  44. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/removeNonPrintingValuesTransformer/removeNonPrintingValuesTransformer.mjs +19 -0
  45. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceResultTransformer/replaceResultTransformer.mjs +18 -0
  46. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceSubstitutionTransformer/replaceSubstitutionTransformer.mjs +18 -0
  47. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.mjs +8 -0
  48. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/splitStringTransformer/splitStringTransformer.mjs +16 -0
  49. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.mjs +7 -0
  50. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndentTransformer/stripIndentTransformer.mjs +33 -0
  51. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.mjs +5 -0
  52. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/trimResultTransformer/trimResultTransformer.mjs +29 -0
  53. package/build/esm/request-router.mjs +15 -0
  54. package/build/esnext/craft.esnext +104 -0
  55. package/build/esnext/index.esnext +1 -0
  56. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/TemplateTag/TemplateTag.esnext +164 -0
  57. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.esnext +6 -0
  58. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.esnext +6 -0
  59. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.esnext +6 -0
  60. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.esnext +8 -0
  61. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineArrayTransformer/inlineArrayTransformer.esnext +44 -0
  62. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.esnext +6 -0
  63. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.esnext +5 -0
  64. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.esnext +6 -0
  65. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.esnext +6 -0
  66. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.esnext +6 -0
  67. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.esnext +6 -0
  68. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.esnext +5 -0
  69. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/removeNonPrintingValuesTransformer/removeNonPrintingValuesTransformer.esnext +19 -0
  70. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceResultTransformer/replaceResultTransformer.esnext +18 -0
  71. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceSubstitutionTransformer/replaceSubstitutionTransformer.esnext +18 -0
  72. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.esnext +8 -0
  73. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/splitStringTransformer/splitStringTransformer.esnext +16 -0
  74. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.esnext +7 -0
  75. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndentTransformer/stripIndentTransformer.esnext +33 -0
  76. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.esnext +5 -0
  77. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/trimResultTransformer/trimResultTransformer.esnext +29 -0
  78. package/build/esnext/request-router.esnext +15 -0
  79. package/build/tsconfig.tsbuildinfo +1 -0
  80. package/build/typescript/craft.d.ts +13 -0
  81. package/build/typescript/craft.d.ts.map +1 -0
  82. package/build/typescript/index.d.ts +2 -0
  83. package/build/typescript/index.d.ts.map +1 -0
  84. package/build/typescript/request-router.d.ts +8 -0
  85. package/build/typescript/request-router.d.ts.map +1 -0
  86. package/package.json +79 -0
  87. package/quilt.project.ts +5 -0
  88. package/source/craft.ts +128 -0
  89. package/source/index.ts +1 -0
  90. package/source/request-router.tsx +19 -0
  91. package/tsconfig.json +13 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # @quilted/deno
2
+
3
+ ## 0.0.0-preview-20230922041245
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix name of request router export in deno plugin
8
+
9
+ - Updated dependencies []:
10
+ - @quilted/craft@0.0.0-preview-20230922041245
11
+
12
+ ## 0.1.1
13
+
14
+ ### Patch Changes
15
+
16
+ - [`788c606b`](https://github.com/lemonmade/quilt/commit/788c606b4993cf8136d5743600a4ba52143d6738) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix name of request router export in deno plugin
17
+
18
+ - Updated dependencies []:
19
+ - @quilted/craft@0.1.231
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019-present, Chris Sauvé and contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # `@quilted/deno`
@@ -0,0 +1,106 @@
1
+ 'use strict';
2
+
3
+ require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/TemplateTag/TemplateTag.cjs');
4
+ require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.cjs');
5
+ require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.cjs');
6
+ require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.cjs');
7
+ require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.cjs');
8
+ require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.cjs');
9
+ require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.cjs');
10
+ require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.cjs');
11
+ require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.cjs');
12
+ require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.cjs');
13
+ require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.cjs');
14
+ require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.cjs');
15
+ require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.cjs');
16
+ var stripIndent = require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.cjs');
17
+ require('./node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.cjs');
18
+ var craft = require('@quilted/craft');
19
+
20
+ /**
21
+ * Configures any code generated for this project to run on Deno.
22
+ */
23
+ function deno(_ = {}) {
24
+ return craft.createProjectPlugin({
25
+ name: 'Quilt.Deno',
26
+ build({
27
+ project,
28
+ configure
29
+ }) {
30
+ configure(addConfiguration({
31
+ project,
32
+ mode: 'production'
33
+ }));
34
+ }
35
+ // develop({project, configure, hooks}) {
36
+ // hooks<DenoDevelopHooks>(() => ({}));
37
+
38
+ // configure(
39
+ // addConfiguration({
40
+ // project,
41
+ // mode: 'development',
42
+ // }),
43
+ // );
44
+ // },
45
+ });
46
+ }
47
+
48
+ function addConfiguration({
49
+ mode
50
+ }) {
51
+ return ({
52
+ runtimes,
53
+ browserslistTargets,
54
+ rollupPlugins,
55
+ rollupNodeBundle,
56
+ quiltRequestRouterPort,
57
+ quiltRequestRouterHost,
58
+ quiltServiceOutputFormat,
59
+ quiltAppServerOutputFormat,
60
+ quiltRequestRouterRuntimeContent,
61
+ quiltPolyfillFeaturesForEnvironment,
62
+ quiltRuntimeEnvironmentVariables
63
+ }, options) => {
64
+ if (!options.quiltAppServer && !options.quiltService) {
65
+ return;
66
+ }
67
+ runtimes?.(() => [{
68
+ target: 'deno'
69
+ }]);
70
+ browserslistTargets?.(() => ['last 1 chrome version']);
71
+ rollupPlugins?.(async plugins => {
72
+ const {
73
+ rollupReplaceProcessEnv
74
+ } = await import('@quilted/craft/rollup');
75
+ return [...plugins, await rollupReplaceProcessEnv({
76
+ mode,
77
+ preserve: false
78
+ })];
79
+ });
80
+ rollupNodeBundle?.(() => true);
81
+ quiltRuntimeEnvironmentVariables?.(() => `Deno.env.toObject()`);
82
+ quiltServiceOutputFormat?.(() => 'module');
83
+ quiltAppServerOutputFormat?.(() => 'module');
84
+ const polyfillsWithNativeWorkersSupport = new Set(['crypto', 'fetch', 'abort-controller']);
85
+ quiltPolyfillFeaturesForEnvironment?.(features => {
86
+ return features.filter(feature => !polyfillsWithNativeWorkersSupport.has(feature));
87
+ });
88
+
89
+ // @see https://deno.land/api@v1.37.0?s=Deno.ServeOptions
90
+ quiltRequestRouterRuntimeContent?.(async () => {
91
+ const [port, host] = await Promise.all([quiltRequestRouterPort.run(undefined), quiltRequestRouterHost.run(undefined)]);
92
+ return stripIndent["default"]`
93
+ import {createServeHandler} from '@quilted/deno/request-router';
94
+ import RequestRouter from ${JSON.stringify(craft.MAGIC_MODULE_REQUEST_ROUTER)};
95
+
96
+ const port = ${port ?? `Number.parseInt(Deno.env.get('PORT') ?? '8080', 10)`};
97
+ const hostname = ${host ? JSON.stringify(host) : 'undefined'};
98
+ const handleRequest = createServeHandler(RequestRouter);
99
+
100
+ Deno.serve({port, hostname}, handleRequest);
101
+ `;
102
+ });
103
+ };
104
+ }
105
+
106
+ exports.deno = deno;
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,168 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ 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; }; }();
6
+
7
+ var _templateObject = _taggedTemplateLiteral(['', ''], ['', '']);
8
+
9
+ function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
10
+
11
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
+
13
+ /**
14
+ * @class TemplateTag
15
+ * @classdesc Consumes a pipeline of composable transformer plugins and produces a template tag.
16
+ */
17
+ var TemplateTag = function () {
18
+ /**
19
+ * constructs a template tag
20
+ * @constructs TemplateTag
21
+ * @param {...Object} [...transformers] - an array or arguments list of transformers
22
+ * @return {Function} - a template tag
23
+ */
24
+ function TemplateTag() {
25
+ var _this = this;
26
+
27
+ for (var _len = arguments.length, transformers = Array(_len), _key = 0; _key < _len; _key++) {
28
+ transformers[_key] = arguments[_key];
29
+ }
30
+
31
+ _classCallCheck(this, TemplateTag);
32
+
33
+ this.tag = function (strings) {
34
+ for (var _len2 = arguments.length, expressions = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
35
+ expressions[_key2 - 1] = arguments[_key2];
36
+ }
37
+
38
+ if (typeof strings === 'function') {
39
+ // if the first argument passed is a function, assume it is a template tag and return
40
+ // an intermediary tag that processes the template using the aforementioned tag, passing the
41
+ // result to our tag
42
+ return _this.interimTag.bind(_this, strings);
43
+ }
44
+
45
+ if (typeof strings === 'string') {
46
+ // if the first argument passed is a string, just transform it
47
+ return _this.transformEndResult(strings);
48
+ }
49
+
50
+ // else, return a transformed end result of processing the template with our tag
51
+ strings = strings.map(_this.transformString.bind(_this));
52
+ return _this.transformEndResult(strings.reduce(_this.processSubstitutions.bind(_this, expressions)));
53
+ };
54
+
55
+ // if first argument is an array, extrude it as a list of transformers
56
+ if (transformers.length > 0 && Array.isArray(transformers[0])) {
57
+ transformers = transformers[0];
58
+ }
59
+
60
+ // if any transformers are functions, this means they are not initiated - automatically initiate them
61
+ this.transformers = transformers.map(function (transformer) {
62
+ return typeof transformer === 'function' ? transformer() : transformer;
63
+ });
64
+
65
+ // return an ES2015 template tag
66
+ return this.tag;
67
+ }
68
+
69
+ /**
70
+ * Applies all transformers to a template literal tagged with this method.
71
+ * If a function is passed as the first argument, assumes the function is a template tag
72
+ * and applies it to the template, returning a template tag.
73
+ * @param {(Function|String|Array<String>)} strings - Either a template tag or an array containing template strings separated by identifier
74
+ * @param {...*} ...expressions - Optional list of substitution values.
75
+ * @return {(String|Function)} - Either an intermediary tag function or the results of processing the template.
76
+ */
77
+
78
+
79
+ _createClass(TemplateTag, [{
80
+ key: 'interimTag',
81
+
82
+
83
+ /**
84
+ * An intermediary template tag that receives a template tag and passes the result of calling the template with the received
85
+ * template tag to our own template tag.
86
+ * @param {Function} nextTag - the received template tag
87
+ * @param {Array<String>} template - the template to process
88
+ * @param {...*} ...substitutions - `substitutions` is an array of all substitutions in the template
89
+ * @return {*} - the final processed value
90
+ */
91
+ value: function interimTag(previousTag, template) {
92
+ for (var _len3 = arguments.length, substitutions = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
93
+ substitutions[_key3 - 2] = arguments[_key3];
94
+ }
95
+
96
+ return this.tag(_templateObject, previousTag.apply(undefined, [template].concat(substitutions)));
97
+ }
98
+
99
+ /**
100
+ * Performs bulk processing on the tagged template, transforming each substitution and then
101
+ * concatenating the resulting values into a string.
102
+ * @param {Array<*>} substitutions - an array of all remaining substitutions present in this template
103
+ * @param {String} resultSoFar - this iteration's result string so far
104
+ * @param {String} remainingPart - the template chunk after the current substitution
105
+ * @return {String} - the result of joining this iteration's processed substitution with the result
106
+ */
107
+
108
+ }, {
109
+ key: 'processSubstitutions',
110
+ value: function processSubstitutions(substitutions, resultSoFar, remainingPart) {
111
+ var substitution = this.transformSubstitution(substitutions.shift(), resultSoFar);
112
+ return ''.concat(resultSoFar, substitution, remainingPart);
113
+ }
114
+
115
+ /**
116
+ * Iterate through each transformer, applying the transformer's `onString` method to the template
117
+ * strings before all substitutions are processed.
118
+ * @param {String} str - The input string
119
+ * @return {String} - The final results of processing each transformer
120
+ */
121
+
122
+ }, {
123
+ key: 'transformString',
124
+ value: function transformString(str) {
125
+ var cb = function cb(res, transform) {
126
+ return transform.onString ? transform.onString(res) : res;
127
+ };
128
+ return this.transformers.reduce(cb, str);
129
+ }
130
+
131
+ /**
132
+ * When a substitution is encountered, iterates through each transformer and applies the transformer's
133
+ * `onSubstitution` method to the substitution.
134
+ * @param {*} substitution - The current substitution
135
+ * @param {String} resultSoFar - The result up to and excluding this substitution.
136
+ * @return {*} - The final result of applying all substitution transformations.
137
+ */
138
+
139
+ }, {
140
+ key: 'transformSubstitution',
141
+ value: function transformSubstitution(substitution, resultSoFar) {
142
+ var cb = function cb(res, transform) {
143
+ return transform.onSubstitution ? transform.onSubstitution(res, resultSoFar) : res;
144
+ };
145
+ return this.transformers.reduce(cb, substitution);
146
+ }
147
+
148
+ /**
149
+ * Iterates through each transformer, applying the transformer's `onEndResult` method to the
150
+ * template literal after all substitutions have finished processing.
151
+ * @param {String} endResult - The processed template, just before it is returned from the tag
152
+ * @return {String} - The final results of processing each transformer
153
+ */
154
+
155
+ }, {
156
+ key: 'transformEndResult',
157
+ value: function transformEndResult(endResult) {
158
+ var cb = function cb(res, transform) {
159
+ return transform.onEndResult ? transform.onEndResult(res) : res;
160
+ };
161
+ return this.transformers.reduce(cb, endResult);
162
+ }
163
+ }]);
164
+
165
+ return TemplateTag;
166
+ }();
167
+
168
+ exports["default"] = TemplateTag;
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var TemplateTag = require('../TemplateTag/TemplateTag.cjs');
4
+ var stripIndentTransformer = require('../stripIndentTransformer/stripIndentTransformer.cjs');
5
+ var inlineArrayTransformer = require('../inlineArrayTransformer/inlineArrayTransformer.cjs');
6
+ var trimResultTransformer = require('../trimResultTransformer/trimResultTransformer.cjs');
7
+
8
+ new TemplateTag["default"](inlineArrayTransformer["default"]({ separator: ',' }), stripIndentTransformer["default"], trimResultTransformer["default"]);
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var TemplateTag = require('../TemplateTag/TemplateTag.cjs');
4
+ var stripIndentTransformer = require('../stripIndentTransformer/stripIndentTransformer.cjs');
5
+ var inlineArrayTransformer = require('../inlineArrayTransformer/inlineArrayTransformer.cjs');
6
+ var trimResultTransformer = require('../trimResultTransformer/trimResultTransformer.cjs');
7
+
8
+ new TemplateTag["default"](inlineArrayTransformer["default"]({ separator: ',', conjunction: 'and' }), stripIndentTransformer["default"], trimResultTransformer["default"]);
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var TemplateTag = require('../TemplateTag/TemplateTag.cjs');
4
+ var stripIndentTransformer = require('../stripIndentTransformer/stripIndentTransformer.cjs');
5
+ var inlineArrayTransformer = require('../inlineArrayTransformer/inlineArrayTransformer.cjs');
6
+ var trimResultTransformer = require('../trimResultTransformer/trimResultTransformer.cjs');
7
+
8
+ new TemplateTag["default"](inlineArrayTransformer["default"]({ separator: ',', conjunction: 'or' }), stripIndentTransformer["default"], trimResultTransformer["default"]);
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var TemplateTag = require('../TemplateTag/TemplateTag.cjs');
4
+ var stripIndentTransformer = require('../stripIndentTransformer/stripIndentTransformer.cjs');
5
+ var inlineArrayTransformer = require('../inlineArrayTransformer/inlineArrayTransformer.cjs');
6
+ var trimResultTransformer = require('../trimResultTransformer/trimResultTransformer.cjs');
7
+ var splitStringTransformer = require('../splitStringTransformer/splitStringTransformer.cjs');
8
+ var removeNonPrintingValuesTransformer = require('../removeNonPrintingValuesTransformer/removeNonPrintingValuesTransformer.cjs');
9
+
10
+ new TemplateTag["default"](splitStringTransformer["default"]('\n'), removeNonPrintingValuesTransformer["default"], inlineArrayTransformer["default"], stripIndentTransformer["default"], trimResultTransformer["default"]);
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var defaults = {
6
+ separator: '',
7
+ conjunction: '',
8
+ serial: false
9
+ };
10
+
11
+ /**
12
+ * Converts an array substitution to a string containing a list
13
+ * @param {String} [opts.separator = ''] - the character that separates each item
14
+ * @param {String} [opts.conjunction = ''] - replace the last separator with this
15
+ * @param {Boolean} [opts.serial = false] - include the separator before the conjunction? (Oxford comma use-case)
16
+ *
17
+ * @return {Object} - a TemplateTag transformer
18
+ */
19
+ var inlineArrayTransformer = function inlineArrayTransformer() {
20
+ var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaults;
21
+ return {
22
+ onSubstitution: function onSubstitution(substitution, resultSoFar) {
23
+ // only operate on arrays
24
+ if (Array.isArray(substitution)) {
25
+ var arrayLength = substitution.length;
26
+ var separator = opts.separator;
27
+ var conjunction = opts.conjunction;
28
+ var serial = opts.serial;
29
+ // join each item in the array into a string where each item is separated by separator
30
+ // be sure to maintain indentation
31
+ var indent = resultSoFar.match(/(\n?[^\S\n]+)$/);
32
+ if (indent) {
33
+ substitution = substitution.join(separator + indent[1]);
34
+ } else {
35
+ substitution = substitution.join(separator + ' ');
36
+ }
37
+ // if conjunction is set, replace the last separator with conjunction, but only if there is more than one substitution
38
+ if (conjunction && arrayLength > 1) {
39
+ var separatorIndex = substitution.lastIndexOf(separator);
40
+ substitution = substitution.slice(0, separatorIndex) + (serial ? separator : '') + ' ' + conjunction + substitution.slice(separatorIndex + 1);
41
+ }
42
+ }
43
+ return substitution;
44
+ }
45
+ };
46
+ };
47
+
48
+ exports["default"] = inlineArrayTransformer;
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var TemplateTag = require('../TemplateTag/TemplateTag.cjs');
4
+ var stripIndentTransformer = require('../stripIndentTransformer/stripIndentTransformer.cjs');
5
+ var inlineArrayTransformer = require('../inlineArrayTransformer/inlineArrayTransformer.cjs');
6
+ var trimResultTransformer = require('../trimResultTransformer/trimResultTransformer.cjs');
7
+
8
+ new TemplateTag["default"](inlineArrayTransformer["default"], stripIndentTransformer["default"], trimResultTransformer["default"]);
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var TemplateTag = require('../TemplateTag/TemplateTag.cjs');
4
+ var trimResultTransformer = require('../trimResultTransformer/trimResultTransformer.cjs');
5
+ var replaceResultTransformer = require('../replaceResultTransformer/replaceResultTransformer.cjs');
6
+
7
+ new TemplateTag["default"](replaceResultTransformer["default"](/(?:\n(?:\s*))+/g, ' '), trimResultTransformer["default"]);
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var TemplateTag = require('../TemplateTag/TemplateTag.cjs');
4
+ var inlineArrayTransformer = require('../inlineArrayTransformer/inlineArrayTransformer.cjs');
5
+ var trimResultTransformer = require('../trimResultTransformer/trimResultTransformer.cjs');
6
+ var replaceResultTransformer = require('../replaceResultTransformer/replaceResultTransformer.cjs');
7
+
8
+ new TemplateTag["default"](inlineArrayTransformer["default"]({ separator: ',' }), replaceResultTransformer["default"](/(?:\s+)/g, ' '), trimResultTransformer["default"]);
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var TemplateTag = require('../TemplateTag/TemplateTag.cjs');
4
+ var inlineArrayTransformer = require('../inlineArrayTransformer/inlineArrayTransformer.cjs');
5
+ var trimResultTransformer = require('../trimResultTransformer/trimResultTransformer.cjs');
6
+ var replaceResultTransformer = require('../replaceResultTransformer/replaceResultTransformer.cjs');
7
+
8
+ new TemplateTag["default"](inlineArrayTransformer["default"]({ separator: ',', conjunction: 'and' }), replaceResultTransformer["default"](/(?:\s+)/g, ' '), trimResultTransformer["default"]);
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var TemplateTag = require('../TemplateTag/TemplateTag.cjs');
4
+ var inlineArrayTransformer = require('../inlineArrayTransformer/inlineArrayTransformer.cjs');
5
+ var trimResultTransformer = require('../trimResultTransformer/trimResultTransformer.cjs');
6
+ var replaceResultTransformer = require('../replaceResultTransformer/replaceResultTransformer.cjs');
7
+
8
+ new TemplateTag["default"](inlineArrayTransformer["default"]({ separator: ',', conjunction: 'or' }), replaceResultTransformer["default"](/(?:\s+)/g, ' '), trimResultTransformer["default"]);
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var TemplateTag = require('../TemplateTag/TemplateTag.cjs');
4
+ var inlineArrayTransformer = require('../inlineArrayTransformer/inlineArrayTransformer.cjs');
5
+ var trimResultTransformer = require('../trimResultTransformer/trimResultTransformer.cjs');
6
+ var replaceResultTransformer = require('../replaceResultTransformer/replaceResultTransformer.cjs');
7
+
8
+ new TemplateTag["default"](inlineArrayTransformer["default"], replaceResultTransformer["default"](/(?:\s+)/g, ' '), trimResultTransformer["default"]);
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var TemplateTag = require('../TemplateTag/TemplateTag.cjs');
4
+ var trimResultTransformer = require('../trimResultTransformer/trimResultTransformer.cjs');
5
+ var replaceResultTransformer = require('../replaceResultTransformer/replaceResultTransformer.cjs');
6
+
7
+ new TemplateTag["default"](replaceResultTransformer["default"](/(?:\n\s*)/g, ''), trimResultTransformer["default"]);
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var isValidValue = function isValidValue(x) {
6
+ return x != null && !Number.isNaN(x) && typeof x !== 'boolean';
7
+ };
8
+
9
+ var removeNonPrintingValuesTransformer = function removeNonPrintingValuesTransformer() {
10
+ return {
11
+ onSubstitution: function onSubstitution(substitution) {
12
+ if (Array.isArray(substitution)) {
13
+ return substitution.filter(isValidValue);
14
+ }
15
+ if (isValidValue(substitution)) {
16
+ return substitution;
17
+ }
18
+ return '';
19
+ }
20
+ };
21
+ };
22
+
23
+ exports["default"] = removeNonPrintingValuesTransformer;
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * Replaces tabs, newlines and spaces with the chosen value when they occur in sequences
7
+ * @param {(String|RegExp)} replaceWhat - the value or pattern that should be replaced
8
+ * @param {*} replaceWith - the replacement value
9
+ * @return {Object} - a TemplateTag transformer
10
+ */
11
+ var replaceResultTransformer = function replaceResultTransformer(replaceWhat, replaceWith) {
12
+ return {
13
+ onEndResult: function onEndResult(endResult) {
14
+ if (replaceWhat == null || replaceWith == null) {
15
+ throw new Error('replaceResultTransformer requires at least 2 arguments.');
16
+ }
17
+ return endResult.replace(replaceWhat, replaceWith);
18
+ }
19
+ };
20
+ };
21
+
22
+ exports["default"] = replaceResultTransformer;
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var replaceSubstitutionTransformer = function replaceSubstitutionTransformer(replaceWhat, replaceWith) {
6
+ return {
7
+ onSubstitution: function onSubstitution(substitution, resultSoFar) {
8
+ if (replaceWhat == null || replaceWith == null) {
9
+ throw new Error('replaceSubstitutionTransformer requires at least 2 arguments.');
10
+ }
11
+
12
+ // Do not touch if null or undefined
13
+ if (substitution == null) {
14
+ return substitution;
15
+ } else {
16
+ return substitution.toString().replace(replaceWhat, replaceWith);
17
+ }
18
+ }
19
+ };
20
+ };
21
+
22
+ exports["default"] = replaceSubstitutionTransformer;
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var TemplateTag = require('../TemplateTag/TemplateTag.cjs');
4
+ var stripIndentTransformer = require('../stripIndentTransformer/stripIndentTransformer.cjs');
5
+ var inlineArrayTransformer = require('../inlineArrayTransformer/inlineArrayTransformer.cjs');
6
+ var trimResultTransformer = require('../trimResultTransformer/trimResultTransformer.cjs');
7
+ var splitStringTransformer = require('../splitStringTransformer/splitStringTransformer.cjs');
8
+ var replaceSubstitutionTransformer = require('../replaceSubstitutionTransformer/replaceSubstitutionTransformer.cjs');
9
+
10
+ new TemplateTag["default"](splitStringTransformer["default"]('\n'), inlineArrayTransformer["default"], stripIndentTransformer["default"], trimResultTransformer["default"], replaceSubstitutionTransformer["default"](/&/g, '&amp;'), replaceSubstitutionTransformer["default"](/</g, '&lt;'), replaceSubstitutionTransformer["default"](/>/g, '&gt;'), replaceSubstitutionTransformer["default"](/"/g, '&quot;'), replaceSubstitutionTransformer["default"](/'/g, '&#x27;'), replaceSubstitutionTransformer["default"](/`/g, '&#x60;'));
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var splitStringTransformer = function splitStringTransformer(splitBy) {
6
+ return {
7
+ onSubstitution: function onSubstitution(substitution, resultSoFar) {
8
+ if (splitBy != null && typeof splitBy === 'string') {
9
+ if (typeof substitution === 'string' && substitution.includes(splitBy)) {
10
+ substitution = substitution.split(splitBy);
11
+ }
12
+ } else {
13
+ throw new Error('You need to specify a string character to split by.');
14
+ }
15
+ return substitution;
16
+ }
17
+ };
18
+ };
19
+
20
+ exports["default"] = splitStringTransformer;
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var TemplateTag = require('../TemplateTag/TemplateTag.cjs');
6
+ var stripIndentTransformer = require('../stripIndentTransformer/stripIndentTransformer.cjs');
7
+ var trimResultTransformer = require('../trimResultTransformer/trimResultTransformer.cjs');
8
+
9
+ var stripIndent = new TemplateTag["default"](stripIndentTransformer["default"], trimResultTransformer["default"]);
10
+
11
+ exports["default"] = stripIndent;
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ 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); } }
6
+
7
+ /**
8
+ * strips indentation from a template literal
9
+ * @param {String} type = 'initial' - whether to remove all indentation or just leading indentation. can be 'all' or 'initial'
10
+ * @return {Object} - a TemplateTag transformer
11
+ */
12
+ var stripIndentTransformer = function stripIndentTransformer() {
13
+ var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'initial';
14
+ return {
15
+ onEndResult: function onEndResult(endResult) {
16
+ if (type === 'initial') {
17
+ // remove the shortest leading indentation from each line
18
+ var match = endResult.match(/^[^\S\n]*(?=\S)/gm);
19
+ var indent = match && Math.min.apply(Math, _toConsumableArray(match.map(function (el) {
20
+ return el.length;
21
+ })));
22
+ if (indent) {
23
+ var regexp = new RegExp('^.{' + indent + '}', 'gm');
24
+ return endResult.replace(regexp, '');
25
+ }
26
+ return endResult;
27
+ }
28
+ if (type === 'all') {
29
+ // remove all indentation from each line
30
+ return endResult.replace(/^[^\S\n]+/gm, '');
31
+ }
32
+ throw new Error('Unknown type: ' + type);
33
+ }
34
+ };
35
+ };
36
+
37
+ exports["default"] = stripIndentTransformer;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var TemplateTag = require('../TemplateTag/TemplateTag.cjs');
4
+ var stripIndentTransformer = require('../stripIndentTransformer/stripIndentTransformer.cjs');
5
+ var trimResultTransformer = require('../trimResultTransformer/trimResultTransformer.cjs');
6
+
7
+ new TemplateTag["default"](stripIndentTransformer["default"]('all'), trimResultTransformer["default"]);