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