@quilted/rollup 0.1.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.
Files changed (114) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +1 -0
  3. package/build/cjs/app.cjs +137 -0
  4. package/build/cjs/constants.cjs +13 -0
  5. package/build/cjs/env.cjs +130 -0
  6. package/build/cjs/index.cjs +16 -0
  7. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/TemplateTag/TemplateTag.cjs +168 -0
  8. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.cjs +8 -0
  9. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.cjs +8 -0
  10. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.cjs +8 -0
  11. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.cjs +10 -0
  12. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineArrayTransformer/inlineArrayTransformer.cjs +48 -0
  13. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.cjs +8 -0
  14. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.cjs +7 -0
  15. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.cjs +8 -0
  16. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.cjs +8 -0
  17. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.cjs +8 -0
  18. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.cjs +8 -0
  19. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.cjs +7 -0
  20. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/removeNonPrintingValuesTransformer/removeNonPrintingValuesTransformer.cjs +23 -0
  21. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceResultTransformer/replaceResultTransformer.cjs +22 -0
  22. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceSubstitutionTransformer/replaceSubstitutionTransformer.cjs +22 -0
  23. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.cjs +10 -0
  24. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/splitStringTransformer/splitStringTransformer.cjs +20 -0
  25. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.cjs +11 -0
  26. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndentTransformer/stripIndentTransformer.cjs +37 -0
  27. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.cjs +7 -0
  28. package/build/cjs/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/trimResultTransformer/trimResultTransformer.cjs +33 -0
  29. package/build/cjs/request-router.cjs +30 -0
  30. package/build/cjs/shared/magic-module.cjs +44 -0
  31. package/build/cjs/shared/strings.cjs +16 -0
  32. package/build/esm/app.mjs +130 -0
  33. package/build/esm/constants.mjs +7 -0
  34. package/build/esm/env.mjs +108 -0
  35. package/build/esm/index.mjs +3 -0
  36. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/TemplateTag/TemplateTag.mjs +164 -0
  37. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.mjs +6 -0
  38. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.mjs +6 -0
  39. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.mjs +6 -0
  40. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.mjs +8 -0
  41. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineArrayTransformer/inlineArrayTransformer.mjs +44 -0
  42. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.mjs +6 -0
  43. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.mjs +5 -0
  44. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.mjs +6 -0
  45. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.mjs +6 -0
  46. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.mjs +6 -0
  47. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.mjs +6 -0
  48. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.mjs +5 -0
  49. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/removeNonPrintingValuesTransformer/removeNonPrintingValuesTransformer.mjs +19 -0
  50. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceResultTransformer/replaceResultTransformer.mjs +18 -0
  51. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceSubstitutionTransformer/replaceSubstitutionTransformer.mjs +18 -0
  52. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.mjs +8 -0
  53. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/splitStringTransformer/splitStringTransformer.mjs +16 -0
  54. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.mjs +7 -0
  55. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndentTransformer/stripIndentTransformer.mjs +33 -0
  56. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.mjs +5 -0
  57. package/build/esm/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/trimResultTransformer/trimResultTransformer.mjs +29 -0
  58. package/build/esm/request-router.mjs +28 -0
  59. package/build/esm/shared/magic-module.mjs +41 -0
  60. package/build/esm/shared/strings.mjs +14 -0
  61. package/build/esnext/app.esnext +130 -0
  62. package/build/esnext/constants.esnext +7 -0
  63. package/build/esnext/env.esnext +108 -0
  64. package/build/esnext/index.esnext +3 -0
  65. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/TemplateTag/TemplateTag.esnext +164 -0
  66. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.esnext +6 -0
  67. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.esnext +6 -0
  68. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.esnext +6 -0
  69. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.esnext +8 -0
  70. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineArrayTransformer/inlineArrayTransformer.esnext +44 -0
  71. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.esnext +6 -0
  72. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.esnext +5 -0
  73. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.esnext +6 -0
  74. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.esnext +6 -0
  75. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.esnext +6 -0
  76. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.esnext +6 -0
  77. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.esnext +5 -0
  78. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/removeNonPrintingValuesTransformer/removeNonPrintingValuesTransformer.esnext +19 -0
  79. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceResultTransformer/replaceResultTransformer.esnext +18 -0
  80. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/replaceSubstitutionTransformer/replaceSubstitutionTransformer.esnext +18 -0
  81. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.esnext +8 -0
  82. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/splitStringTransformer/splitStringTransformer.esnext +16 -0
  83. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.esnext +7 -0
  84. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndentTransformer/stripIndentTransformer.esnext +33 -0
  85. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.esnext +5 -0
  86. package/build/esnext/node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/trimResultTransformer/trimResultTransformer.esnext +29 -0
  87. package/build/esnext/request-router.esnext +28 -0
  88. package/build/esnext/shared/magic-module.esnext +41 -0
  89. package/build/esnext/shared/strings.esnext +14 -0
  90. package/build/tsconfig.tsbuildinfo +1 -0
  91. package/build/typescript/app.d.ts +163 -0
  92. package/build/typescript/app.d.ts.map +1 -0
  93. package/build/typescript/constants.d.ts +6 -0
  94. package/build/typescript/constants.d.ts.map +1 -0
  95. package/build/typescript/env.d.ts +51 -0
  96. package/build/typescript/env.d.ts.map +1 -0
  97. package/build/typescript/index.d.ts +4 -0
  98. package/build/typescript/index.d.ts.map +1 -0
  99. package/build/typescript/request-router.d.ts +15 -0
  100. package/build/typescript/request-router.d.ts.map +1 -0
  101. package/build/typescript/shared/magic-module.d.ts +32 -0
  102. package/build/typescript/shared/magic-module.d.ts.map +1 -0
  103. package/build/typescript/shared/strings.d.ts +2 -0
  104. package/build/typescript/shared/strings.d.ts.map +1 -0
  105. package/package.json +52 -0
  106. package/quilt.project.ts +5 -0
  107. package/source/app.ts +217 -0
  108. package/source/constants.ts +5 -0
  109. package/source/env.ts +153 -0
  110. package/source/index.ts +13 -0
  111. package/source/request-router.ts +33 -0
  112. package/source/shared/magic-module.ts +53 -0
  113. package/source/shared/strings.ts +17 -0
  114. package/tsconfig.json +10 -0
@@ -0,0 +1,130 @@
1
+ import { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_REQUEST_ROUTER, MAGIC_MODULE_BROWSER_ASSETS } from './constants.esnext';
2
+ import { magicModuleEnv } from './env.esnext';
3
+ import { magicModuleRequestRouterEntry } from './request-router.esnext';
4
+ import { multiline } from './shared/strings.esnext';
5
+ import { createMagicModulePlugin, createMagicModuleEntryPlugin } from './shared/magic-module.esnext';
6
+
7
+ function quiltApp({
8
+ env,
9
+ entry
10
+ } = {}) {
11
+ return {
12
+ name: '@quilted/app',
13
+ options(originalOptions) {
14
+ const newPlugins = [...(Array.isArray(originalOptions.plugins) ? originalOptions.plugins : originalOptions.plugins ? [originalOptions.plugins] : [])];
15
+ const newOptions = {
16
+ ...originalOptions,
17
+ plugins: newPlugins
18
+ };
19
+ if (env) {
20
+ newPlugins.push(typeof env === 'boolean' ? magicModuleEnv() : magicModuleEnv(env));
21
+ }
22
+ if (entry) {
23
+ newPlugins.push(magicModuleAppComponent({
24
+ entry
25
+ }));
26
+ }
27
+ return newOptions;
28
+ }
29
+ };
30
+ }
31
+ function quiltAppBrowser(options = {}) {
32
+ return {
33
+ name: '@quilted/app/browser',
34
+ options(originalOptions) {
35
+ const newPlugins = [...(Array.isArray(originalOptions.plugins) ? originalOptions.plugins : originalOptions.plugins ? [originalOptions.plugins] : [])];
36
+ const newOptions = {
37
+ ...originalOptions,
38
+ plugins: newPlugins
39
+ };
40
+ newPlugins.push(magicModuleAppBrowserEntry(options));
41
+ return newOptions;
42
+ }
43
+ };
44
+ }
45
+ function quiltAppServer(options = {}) {
46
+ return {
47
+ name: '@quilted/app/server',
48
+ options(originalOptions) {
49
+ const newPlugins = [...(Array.isArray(originalOptions.plugins) ? originalOptions.plugins : originalOptions.plugins ? [originalOptions.plugins] : [])];
50
+ const newOptions = {
51
+ ...originalOptions,
52
+ plugins: newPlugins
53
+ };
54
+ newPlugins.push(magicModuleRequestRouterEntry());
55
+ newPlugins.push(magicModuleAppRequestRouter(options));
56
+ return newOptions;
57
+ }
58
+ };
59
+ }
60
+ function magicModuleAppComponent({
61
+ entry
62
+ }) {
63
+ return createMagicModulePlugin({
64
+ name: '@quilted/magic-module/app',
65
+ module: MAGIC_MODULE_APP_COMPONENT,
66
+ alias: entry
67
+ });
68
+ }
69
+ function magicModuleAppRequestRouter({
70
+ entry
71
+ } = {}) {
72
+ return createMagicModulePlugin({
73
+ name: '@quilted/magic-module/app-request-router',
74
+ module: MAGIC_MODULE_REQUEST_ROUTER,
75
+ alias: entry,
76
+ source: entry ? undefined : async function source() {
77
+ return multiline`
78
+ import '@quilted/quilt/globals';
79
+
80
+ import {jsx} from 'react/jsx-runtime';
81
+ import {RequestRouter} from '@quilted/quilt/request-router';
82
+ import {renderToResponse} from '@quilted/quilt/server';
83
+
84
+ import App from ${JSON.stringify(MAGIC_MODULE_APP_COMPONENT)};
85
+ import {BrowserAssets} from ${JSON.stringify(MAGIC_MODULE_BROWSER_ASSETS)};
86
+
87
+ const router = new RequestRouter();
88
+ const assets = new BrowserAssets();
89
+
90
+ // For all GET requests, render our React application.
91
+ router.get(async (request) => {
92
+ const response = await renderToResponse(jsx(App), {
93
+ request,
94
+ assets,
95
+ });
96
+
97
+ return response;
98
+ });
99
+
100
+ export default router;
101
+ `;
102
+ }
103
+ });
104
+ }
105
+ function magicModuleAppBrowserEntry({
106
+ hydrate = true,
107
+ selector = '#app'
108
+ } = {}) {
109
+ return createMagicModuleEntryPlugin({
110
+ name: '@quilted/magic-module/app-browser-entry',
111
+ sideEffects: true,
112
+ async source() {
113
+ const reactRootFunction = hydrate ? 'hydrateRoot' : 'createRoot';
114
+ return multiline`
115
+ import '@quilted/quilt/globals';
116
+
117
+ import {jsx} from 'react/jsx-runtime';
118
+ import {${reactRootFunction}} from 'react-dom/client';
119
+
120
+ import App from ${JSON.stringify(MAGIC_MODULE_APP_COMPONENT)};
121
+
122
+ const element = document.querySelector(${JSON.stringify(selector)});
123
+
124
+ ${hydrate ? `${reactRootFunction}(element, jsx(App));` : `${reactRootFunction}(element).render(jsx(App));`}
125
+ `;
126
+ }
127
+ });
128
+ }
129
+
130
+ export { magicModuleAppBrowserEntry, magicModuleAppComponent, magicModuleAppRequestRouter, quiltApp, quiltAppBrowser, quiltAppServer };
@@ -0,0 +1,7 @@
1
+ const MAGIC_MODULE_ENV = 'quilt:module/env';
2
+ const MAGIC_MODULE_ENTRY = 'quilt:module/entry';
3
+ const MAGIC_MODULE_APP_COMPONENT = 'quilt:module/app';
4
+ const MAGIC_MODULE_BROWSER_ASSETS = 'quilt:module/assets';
5
+ const MAGIC_MODULE_REQUEST_ROUTER = 'quilt:module/request-router';
6
+
7
+ export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY, MAGIC_MODULE_ENV, MAGIC_MODULE_REQUEST_ROUTER };
@@ -0,0 +1,108 @@
1
+ import * as path from 'node:path';
2
+ import * as fs from 'node:fs';
3
+ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/TemplateTag/TemplateTag.esnext';
4
+ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaLists/commaLists.esnext';
5
+ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsAnd/commaListsAnd.esnext';
6
+ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/commaListsOr/commaListsOr.esnext';
7
+ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/html/html.esnext';
8
+ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/safeHtml/safeHtml.esnext';
9
+ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLine/oneLine.esnext';
10
+ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineTrim/oneLineTrim.esnext';
11
+ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaLists/oneLineCommaLists.esnext';
12
+ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsOr/oneLineCommaListsOr.esnext';
13
+ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineCommaListsAnd/oneLineCommaListsAnd.esnext';
14
+ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/inlineLists/inlineLists.esnext';
15
+ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/oneLineInlineLists/oneLineInlineLists.esnext';
16
+ import stripIndent from './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndent/stripIndent.esnext';
17
+ import './node_modules/.pnpm/common-tags@1.8.2/node_modules/common-tags/es/stripIndents/stripIndents.esnext';
18
+ import { MAGIC_MODULE_ENV } from './constants.esnext';
19
+ import { createMagicModulePlugin } from './shared/magic-module.esnext';
20
+
21
+ function magicModuleEnv({
22
+ mode,
23
+ dotenv = {
24
+ roots: ['.', 'configuration']
25
+ },
26
+ inline = [],
27
+ runtime = '{}'
28
+ } = {}) {
29
+ return createMagicModulePlugin({
30
+ name: '@quilted/magic-module/env',
31
+ module: MAGIC_MODULE_ENV,
32
+ async source() {
33
+ const inlineEnv = {};
34
+ if (mode) {
35
+ inlineEnv.MODE = mode;
36
+ }
37
+ const loadedEnv = await loadEnv.call(this, {
38
+ mode,
39
+ dotenv
40
+ });
41
+ for (const inlineVariable of inline.sort()) {
42
+ if (inlineVariable in inlineEnv) continue;
43
+ const value = process.env[inlineVariable] ?? loadedEnv[inlineVariable];
44
+ if (value == null) continue;
45
+ inlineEnv[inlineVariable] = typeof value === 'string' && value[0] === '"' && value[value.length - 1] === '"' ? JSON.parse(value) : value;
46
+ }
47
+ return stripIndent`
48
+ const runtime = (${runtime});
49
+ const inline = JSON.parse(${JSON.stringify(JSON.stringify(inlineEnv))});
50
+
51
+ const Env = new Proxy(
52
+ {},
53
+ {
54
+ get(_, property) {
55
+ return runtime[property] ?? inline[property];
56
+ },
57
+ },
58
+ );
59
+
60
+ export default Env;
61
+ `;
62
+ }
63
+ });
64
+ }
65
+
66
+ // Inspired by https://github.com/vitejs/vite/blob/e0a4d810598d1834933ed437ac5a2168cbbbf2f8/packages/vite/source/node/config.ts#L1050-L1113
67
+ async function loadEnv({
68
+ mode,
69
+ dotenv
70
+ }) {
71
+ const env = {
72
+ ...process.env
73
+ };
74
+ if (dotenv !== false) {
75
+ const {
76
+ parse
77
+ } = await import('dotenv');
78
+ let files = dotenv.files;
79
+ if (files == null) {
80
+ const testFiles = [
81
+ // default file
82
+ `.env`,
83
+ // local file
84
+ `.env.local`];
85
+ if (mode) {
86
+ testFiles.push(
87
+ // mode file
88
+ `.env.${mode}`,
89
+ // mode local file
90
+ `.env.${mode}.local`);
91
+ }
92
+ files = testFiles.flatMap(file => (dotenv.roots ?? ['.', 'configuration']).map(root => path.resolve(root, file)));
93
+ }
94
+ const envFileResults = await Promise.all(files.map(async file => {
95
+ if (fs.existsSync(file)) {
96
+ this.addWatchFile(file);
97
+ return parse(await fs.promises.readFile(file, 'utf-8'));
98
+ }
99
+ }));
100
+ for (const envFileResult of envFileResults) {
101
+ if (envFileResult == null) continue;
102
+ Object.assign(env, envFileResult);
103
+ }
104
+ }
105
+ return env;
106
+ }
107
+
108
+ export { magicModuleEnv };
@@ -0,0 +1,3 @@
1
+ export { magicModuleEnv } from './env.esnext';
2
+ export { magicModuleAppBrowserEntry, magicModuleAppComponent, magicModuleAppRequestRouter, quiltApp, quiltAppBrowser, quiltAppServer } from './app.esnext';
3
+ export { magicModuleRequestRouterEntry } from './request-router.esnext';
@@ -0,0 +1,164 @@
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 };
@@ -0,0 +1,6 @@
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);
@@ -0,0 +1,6 @@
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);
@@ -0,0 +1,6 @@
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);
@@ -0,0 +1,8 @@
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);
@@ -0,0 +1,44 @@
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 };
@@ -0,0 +1,6 @@
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);
@@ -0,0 +1,5 @@
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);
@@ -0,0 +1,6 @@
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);
@@ -0,0 +1,6 @@
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);
@@ -0,0 +1,6 @@
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);
@@ -0,0 +1,6 @@
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);
@@ -0,0 +1,5 @@
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);
@@ -0,0 +1,19 @@
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 };
@@ -0,0 +1,18 @@
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 };
@@ -0,0 +1,18 @@
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 };
@@ -0,0 +1,8 @@
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, '&amp;'), replaceSubstitutionTransformer(/</g, '&lt;'), replaceSubstitutionTransformer(/>/g, '&gt;'), replaceSubstitutionTransformer(/"/g, '&quot;'), replaceSubstitutionTransformer(/'/g, '&#x27;'), replaceSubstitutionTransformer(/`/g, '&#x60;'));
@@ -0,0 +1,16 @@
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 };
@@ -0,0 +1,7 @@
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 };