react-email 2.1.7-canary.2 → 2.2.0-alpha-7f567f6f-20240814
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-preview-server.mjs +24 -0
- package/cli/index.js +27 -31
- package/cli/index.mjs +24 -35
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +2753 -0
- package/dist/cli/index.mjs +1254 -0
- package/next.config.js +1 -1
- package/package.json +30 -30
- package/src/actions/get-emails-directory-metadata.spec.ts +8 -0
- package/src/actions/get-emails-directory-metadata.ts +21 -11
- package/src/actions/render-email-by-path.tsx +40 -0
- package/src/app/layout.tsx +2 -0
- package/src/app/preview/[...slug]/page.tsx +4 -1
- package/src/app/preview/[...slug]/preview.tsx +3 -0
- package/src/components/shell.tsx +4 -1
- package/src/components/sidebar/sidebar-directory-children.tsx +5 -12
- package/src/components/sidebar/sidebar-directory.tsx +5 -18
- package/src/components/topbar.tsx +2 -1
- package/src/contexts/emails.tsx +5 -16
- package/src/hooks/use-hot-reload.ts +0 -4
- package/src/utils/close-ora-on-sigint.ts +15 -0
- package/src/utils/emails-directory-absolute-path.ts +7 -31
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { existsSync, promises as fs } from 'node:fs';
|
|
3
|
+
|
|
4
|
+
const nextBuildProcess = spawn('next', ['build'], {
|
|
5
|
+
detached: true,
|
|
6
|
+
stdio: "inherit"
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
process.on('SIGINT', () => {
|
|
10
|
+
nextBuildProcess.kill('SIGINT');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
nextBuildProcess.on('exit', async (code) => {
|
|
14
|
+
if (code !== 0) {
|
|
15
|
+
process.exit(code);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (existsSync('dist/preview')) {
|
|
19
|
+
await fs.rm('dist/preview', { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
await fs.mkdir('dist/preview', { recursive: true });
|
|
22
|
+
await fs.rename('.next', 'dist/preview/.next');
|
|
23
|
+
});
|
|
24
|
+
|
package/cli/index.js
CHANGED
|
@@ -340,7 +340,7 @@ var import_commander = require("commander");
|
|
|
340
340
|
// package.json
|
|
341
341
|
var package_default = {
|
|
342
342
|
name: "react-email",
|
|
343
|
-
version: "2.1.
|
|
343
|
+
version: "2.1.6",
|
|
344
344
|
description: "A live preview of your emails right in your browser.",
|
|
345
345
|
bin: {
|
|
346
346
|
email: "./cli/index.js"
|
|
@@ -376,7 +376,7 @@ var package_default = {
|
|
|
376
376
|
"@radix-ui/react-toggle-group": "1.1.0",
|
|
377
377
|
"@radix-ui/react-tooltip": "1.1.1",
|
|
378
378
|
"@swc/core": "1.3.101",
|
|
379
|
-
"@types/react": "
|
|
379
|
+
"@types/react": "18.2.47",
|
|
380
380
|
"@types/react-dom": "^18.2.0",
|
|
381
381
|
"@types/webpack": "5.28.5",
|
|
382
382
|
autoprefixer: "10.4.14",
|
|
@@ -388,19 +388,19 @@ var package_default = {
|
|
|
388
388
|
esbuild: "0.19.11",
|
|
389
389
|
"eslint-config-prettier": "9.0.0",
|
|
390
390
|
"eslint-config-turbo": "1.10.12",
|
|
391
|
-
"framer-motion": "
|
|
391
|
+
"framer-motion": "10.17.4",
|
|
392
392
|
glob: "10.3.4",
|
|
393
393
|
"log-symbols": "4.1.0",
|
|
394
394
|
"mime-types": "2.1.35",
|
|
395
|
-
next: "14.
|
|
395
|
+
next: "14.1.4",
|
|
396
396
|
"normalize-path": "3.0.0",
|
|
397
397
|
ora: "5.4.1",
|
|
398
|
-
postcss: "8.4.
|
|
398
|
+
postcss: "8.4.38",
|
|
399
399
|
"prism-react-renderer": "2.1.0",
|
|
400
|
-
react: "18.
|
|
401
|
-
"react-dom": "18.
|
|
402
|
-
"socket.io": "4.7.
|
|
403
|
-
"socket.io-client": "4.7.
|
|
400
|
+
react: "^18.2.0",
|
|
401
|
+
"react-dom": "^18.2.0",
|
|
402
|
+
"socket.io": "4.7.3",
|
|
403
|
+
"socket.io-client": "4.7.3",
|
|
404
404
|
sonner: "1.3.1",
|
|
405
405
|
"source-map-js": "1.0.2",
|
|
406
406
|
"stacktrace-parser": "0.1.10",
|
|
@@ -587,8 +587,7 @@ var getImportedModules = function(contents) {
|
|
|
587
587
|
errorRecovery: true,
|
|
588
588
|
plugins: [
|
|
589
589
|
"jsx",
|
|
590
|
-
"typescript"
|
|
591
|
-
"decorators"
|
|
590
|
+
"typescript"
|
|
592
591
|
]
|
|
593
592
|
});
|
|
594
593
|
(0, import_core.traverse)(parsedContents, {
|
|
@@ -1908,12 +1907,12 @@ var mergeDirectoriesWithSubDirectories = function(emailsDirectoryMetadata) {
|
|
|
1908
1907
|
};
|
|
1909
1908
|
var getEmailsDirectoryMetadata = function() {
|
|
1910
1909
|
var _ref = _async_to_generator(function(absolutePathToEmailsDirectory) {
|
|
1911
|
-
var keepFileExtensions,
|
|
1910
|
+
var keepFileExtensions, dirents, emailFilenames, subDirectories;
|
|
1912
1911
|
var _arguments = arguments;
|
|
1913
1912
|
return _ts_generator(this, function(_state) {
|
|
1914
1913
|
switch(_state.label){
|
|
1915
1914
|
case 0:
|
|
1916
|
-
keepFileExtensions = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : false
|
|
1915
|
+
keepFileExtensions = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : false;
|
|
1917
1916
|
if (!import_node_fs5.default.existsSync(absolutePathToEmailsDirectory)) return [
|
|
1918
1917
|
2
|
|
1919
1918
|
];
|
|
@@ -1935,20 +1934,19 @@ var getEmailsDirectoryMetadata = function() {
|
|
|
1935
1934
|
Promise.all(dirents.filter(function(dirent) {
|
|
1936
1935
|
return dirent.isDirectory() && !dirent.name.startsWith("_") && dirent.name !== "static";
|
|
1937
1936
|
}).map(function(dirent) {
|
|
1938
|
-
return getEmailsDirectoryMetadata(import_node_path6.default.join(absolutePathToEmailsDirectory, dirent.name)
|
|
1937
|
+
return getEmailsDirectoryMetadata(import_node_path6.default.join(absolutePathToEmailsDirectory, dirent.name));
|
|
1939
1938
|
}))
|
|
1940
1939
|
];
|
|
1941
1940
|
case 2:
|
|
1942
1941
|
subDirectories = _state.sent();
|
|
1943
|
-
emailsMetadata = {
|
|
1944
|
-
absolutePath: absolutePathToEmailsDirectory,
|
|
1945
|
-
directoryName: absolutePathToEmailsDirectory.split(import_node_path6.default.sep).pop(),
|
|
1946
|
-
emailFilenames: emailFilenames,
|
|
1947
|
-
subDirectories: subDirectories
|
|
1948
|
-
};
|
|
1949
1942
|
return [
|
|
1950
1943
|
2,
|
|
1951
|
-
|
|
1944
|
+
mergeDirectoriesWithSubDirectories({
|
|
1945
|
+
absolutePath: absolutePathToEmailsDirectory,
|
|
1946
|
+
directoryName: absolutePathToEmailsDirectory.split(import_node_path6.default.sep).pop(),
|
|
1947
|
+
emailFilenames: emailFilenames,
|
|
1948
|
+
subDirectories: subDirectories
|
|
1949
|
+
})
|
|
1952
1950
|
];
|
|
1953
1951
|
}
|
|
1954
1952
|
});
|
|
@@ -1957,17 +1955,15 @@ var getEmailsDirectoryMetadata = function() {
|
|
|
1957
1955
|
return _ref.apply(this, arguments);
|
|
1958
1956
|
};
|
|
1959
1957
|
}();
|
|
1960
|
-
// src/utils/esbuild
|
|
1958
|
+
// src/utils/render-resolver-esbuild-plugin.ts
|
|
1961
1959
|
var import_node_path7 = __toESM(require("path"));
|
|
1962
1960
|
var import_node_fs6 = require("fs");
|
|
1963
|
-
// src/utils/esbuild/escape-string-for-regex.ts
|
|
1964
1961
|
function escapeStringForRegex(string) {
|
|
1965
1962
|
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
1966
1963
|
}
|
|
1967
|
-
|
|
1968
|
-
var renderingUtilitiesExporter = function(emailTemplates) {
|
|
1964
|
+
var renderResolver = function(emailTemplates) {
|
|
1969
1965
|
return {
|
|
1970
|
-
name: "
|
|
1966
|
+
name: "render-resolver",
|
|
1971
1967
|
setup: function(b) {
|
|
1972
1968
|
b.onLoad({
|
|
1973
1969
|
filter: new RegExp(emailTemplates.map(function(emailPath) {
|
|
@@ -1991,7 +1987,7 @@ var renderingUtilitiesExporter = function(emailTemplates) {
|
|
|
1991
1987
|
2,
|
|
1992
1988
|
(_tmp.contents = _1.apply(_, [
|
|
1993
1989
|
_state.sent(),
|
|
1994
|
-
";\n export { renderAsync } from 'react-email-module-that-will-export-render'\n
|
|
1990
|
+
";\n export { renderAsync } from 'react-email-module-that-will-export-render'\n "
|
|
1995
1991
|
]), _tmp.loader = import_node_path7.default.extname(pathToFile).slice(1), _tmp)
|
|
1996
1992
|
];
|
|
1997
1993
|
}
|
|
@@ -2051,6 +2047,7 @@ var renderingUtilitiesExporter = function(emailTemplates) {
|
|
|
2051
2047
|
};
|
|
2052
2048
|
};
|
|
2053
2049
|
// src/cli/commands/export.ts
|
|
2050
|
+
var import_react = require("react");
|
|
2054
2051
|
var getEmailTemplatesFromDirectory = function(emailDirectory) {
|
|
2055
2052
|
var templatePaths = [];
|
|
2056
2053
|
emailDirectory.emailFilenames.forEach(function(filename) {
|
|
@@ -2109,7 +2106,7 @@ var exportTemplates = function() {
|
|
|
2109
2106
|
bundle: true,
|
|
2110
2107
|
entryPoints: allTemplates,
|
|
2111
2108
|
plugins: [
|
|
2112
|
-
|
|
2109
|
+
renderResolver(allTemplates)
|
|
2113
2110
|
],
|
|
2114
2111
|
platform: "node",
|
|
2115
2112
|
format: "cjs",
|
|
@@ -2184,7 +2181,7 @@ var exportTemplates = function() {
|
|
|
2184
2181
|
emailModule = require(template);
|
|
2185
2182
|
return [
|
|
2186
2183
|
4,
|
|
2187
|
-
emailModule.renderAsync(
|
|
2184
|
+
emailModule.renderAsync((0, import_react.createElement)(emailModule.default, {}), options)
|
|
2188
2185
|
];
|
|
2189
2186
|
case 9:
|
|
2190
2187
|
rendered = _state.sent();
|
|
@@ -2470,8 +2467,7 @@ var npmInstall = function() {
|
|
|
2470
2467
|
return _ts_generator(this, function(_state) {
|
|
2471
2468
|
childProc = (0, import_node_child_process.spawn)(packageManager, [
|
|
2472
2469
|
"install",
|
|
2473
|
-
"--silent"
|
|
2474
|
-
"--force"
|
|
2470
|
+
"--silent"
|
|
2475
2471
|
], {
|
|
2476
2472
|
cwd: builtPreviewAppPath,
|
|
2477
2473
|
shell: true
|
package/cli/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { program } from "commander";
|
|
|
13
13
|
// package.json
|
|
14
14
|
var package_default = {
|
|
15
15
|
name: "react-email",
|
|
16
|
-
version: "2.1.
|
|
16
|
+
version: "2.1.6",
|
|
17
17
|
description: "A live preview of your emails right in your browser.",
|
|
18
18
|
bin: {
|
|
19
19
|
email: "./cli/index.js"
|
|
@@ -49,7 +49,7 @@ var package_default = {
|
|
|
49
49
|
"@radix-ui/react-toggle-group": "1.1.0",
|
|
50
50
|
"@radix-ui/react-tooltip": "1.1.1",
|
|
51
51
|
"@swc/core": "1.3.101",
|
|
52
|
-
"@types/react": "
|
|
52
|
+
"@types/react": "18.2.47",
|
|
53
53
|
"@types/react-dom": "^18.2.0",
|
|
54
54
|
"@types/webpack": "5.28.5",
|
|
55
55
|
autoprefixer: "10.4.14",
|
|
@@ -61,19 +61,19 @@ var package_default = {
|
|
|
61
61
|
esbuild: "0.19.11",
|
|
62
62
|
"eslint-config-prettier": "9.0.0",
|
|
63
63
|
"eslint-config-turbo": "1.10.12",
|
|
64
|
-
"framer-motion": "
|
|
64
|
+
"framer-motion": "10.17.4",
|
|
65
65
|
glob: "10.3.4",
|
|
66
66
|
"log-symbols": "4.1.0",
|
|
67
67
|
"mime-types": "2.1.35",
|
|
68
|
-
next: "14.
|
|
68
|
+
next: "14.1.4",
|
|
69
69
|
"normalize-path": "3.0.0",
|
|
70
70
|
ora: "5.4.1",
|
|
71
|
-
postcss: "8.4.
|
|
71
|
+
postcss: "8.4.38",
|
|
72
72
|
"prism-react-renderer": "2.1.0",
|
|
73
|
-
react: "18.
|
|
74
|
-
"react-dom": "18.
|
|
75
|
-
"socket.io": "4.7.
|
|
76
|
-
"socket.io-client": "4.7.
|
|
73
|
+
react: "^18.2.0",
|
|
74
|
+
"react-dom": "^18.2.0",
|
|
75
|
+
"socket.io": "4.7.3",
|
|
76
|
+
"socket.io-client": "4.7.3",
|
|
77
77
|
sonner: "1.3.1",
|
|
78
78
|
"source-map-js": "1.0.2",
|
|
79
79
|
"stacktrace-parser": "0.1.10",
|
|
@@ -175,7 +175,7 @@ var getImportedModules = (contents) => {
|
|
|
175
175
|
sourceType: "unambiguous",
|
|
176
176
|
strictMode: false,
|
|
177
177
|
errorRecovery: true,
|
|
178
|
-
plugins: ["jsx", "typescript"
|
|
178
|
+
plugins: ["jsx", "typescript"]
|
|
179
179
|
});
|
|
180
180
|
traverse(parsedContents, {
|
|
181
181
|
ImportDeclaration({ node }) {
|
|
@@ -747,7 +747,7 @@ var mergeDirectoriesWithSubDirectories = (emailsDirectoryMetadata) => {
|
|
|
747
747
|
}
|
|
748
748
|
return currentResultingMergedDirectory;
|
|
749
749
|
};
|
|
750
|
-
var getEmailsDirectoryMetadata = async (absolutePathToEmailsDirectory, keepFileExtensions = false
|
|
750
|
+
var getEmailsDirectoryMetadata = async (absolutePathToEmailsDirectory, keepFileExtensions = false) => {
|
|
751
751
|
if (!fs5.existsSync(absolutePathToEmailsDirectory))
|
|
752
752
|
return;
|
|
753
753
|
const dirents = await fs5.promises.readdir(absolutePathToEmailsDirectory, {
|
|
@@ -763,33 +763,26 @@ var getEmailsDirectoryMetadata = async (absolutePathToEmailsDirectory, keepFileE
|
|
|
763
763
|
(dirent) => dirent.isDirectory() && !dirent.name.startsWith("_") && dirent.name !== "static"
|
|
764
764
|
).map(
|
|
765
765
|
(dirent) => getEmailsDirectoryMetadata(
|
|
766
|
-
path7.join(absolutePathToEmailsDirectory, dirent.name)
|
|
767
|
-
keepFileExtensions,
|
|
768
|
-
true
|
|
766
|
+
path7.join(absolutePathToEmailsDirectory, dirent.name)
|
|
769
767
|
)
|
|
770
768
|
)
|
|
771
769
|
);
|
|
772
|
-
|
|
770
|
+
return mergeDirectoriesWithSubDirectories({
|
|
773
771
|
absolutePath: absolutePathToEmailsDirectory,
|
|
774
772
|
directoryName: absolutePathToEmailsDirectory.split(path7.sep).pop(),
|
|
775
773
|
emailFilenames,
|
|
776
774
|
subDirectories
|
|
777
|
-
};
|
|
778
|
-
return isSubDirectory ? mergeDirectoriesWithSubDirectories(emailsMetadata) : emailsMetadata;
|
|
775
|
+
});
|
|
779
776
|
};
|
|
780
777
|
|
|
781
|
-
// src/utils/esbuild
|
|
778
|
+
// src/utils/render-resolver-esbuild-plugin.ts
|
|
782
779
|
import path8 from "path";
|
|
783
780
|
import { promises as fs6 } from "fs";
|
|
784
|
-
|
|
785
|
-
// src/utils/esbuild/escape-string-for-regex.ts
|
|
786
781
|
function escapeStringForRegex(string) {
|
|
787
782
|
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
788
783
|
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
var renderingUtilitiesExporter = (emailTemplates) => ({
|
|
792
|
-
name: "rendering-utilities-exporter",
|
|
784
|
+
var renderResolver = (emailTemplates) => ({
|
|
785
|
+
name: "render-resolver",
|
|
793
786
|
setup: (b) => {
|
|
794
787
|
b.onLoad(
|
|
795
788
|
{
|
|
@@ -801,7 +794,6 @@ var renderingUtilitiesExporter = (emailTemplates) => ({
|
|
|
801
794
|
return {
|
|
802
795
|
contents: `${await fs6.readFile(pathToFile, "utf8")};
|
|
803
796
|
export { renderAsync } from 'react-email-module-that-will-export-render'
|
|
804
|
-
export { createElement as reactEmailCreateReactElement } from 'react';
|
|
805
797
|
`,
|
|
806
798
|
loader: path8.extname(pathToFile).slice(1)
|
|
807
799
|
};
|
|
@@ -831,6 +823,7 @@ var renderingUtilitiesExporter = (emailTemplates) => ({
|
|
|
831
823
|
});
|
|
832
824
|
|
|
833
825
|
// src/cli/commands/export.ts
|
|
826
|
+
import { createElement } from "react";
|
|
834
827
|
var getEmailTemplatesFromDirectory = (emailDirectory) => {
|
|
835
828
|
const templatePaths = [];
|
|
836
829
|
emailDirectory.emailFilenames.forEach(
|
|
@@ -868,7 +861,7 @@ var exportTemplates = async (pathToWhereEmailMarkupShouldBeDumped, emailsDirecto
|
|
|
868
861
|
await build({
|
|
869
862
|
bundle: true,
|
|
870
863
|
entryPoints: allTemplates,
|
|
871
|
-
plugins: [
|
|
864
|
+
plugins: [renderResolver(allTemplates)],
|
|
872
865
|
platform: "node",
|
|
873
866
|
format: "cjs",
|
|
874
867
|
loader: { ".js": "jsx" },
|
|
@@ -910,7 +903,7 @@ ${allTemplates.map((p) => `- ${p}`).join("\n")}`
|
|
|
910
903
|
delete __require.cache[template];
|
|
911
904
|
const emailModule = __require(template);
|
|
912
905
|
const rendered = await emailModule.renderAsync(
|
|
913
|
-
|
|
906
|
+
createElement(emailModule.default, {}),
|
|
914
907
|
options
|
|
915
908
|
);
|
|
916
909
|
const htmlPath = template.replace(
|
|
@@ -1103,14 +1096,10 @@ var updatePackageJson = async (builtPreviewAppPath) => {
|
|
|
1103
1096
|
};
|
|
1104
1097
|
var npmInstall = async (builtPreviewAppPath, packageManager) => {
|
|
1105
1098
|
return new Promise(async (resolve2, reject) => {
|
|
1106
|
-
const childProc = spawn(
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
cwd: builtPreviewAppPath,
|
|
1111
|
-
shell: true
|
|
1112
|
-
}
|
|
1113
|
-
);
|
|
1099
|
+
const childProc = spawn(packageManager, ["install", "--silent"], {
|
|
1100
|
+
cwd: builtPreviewAppPath,
|
|
1101
|
+
shell: true
|
|
1102
|
+
});
|
|
1114
1103
|
childProc.stdout.pipe(process.stdout);
|
|
1115
1104
|
childProc.stderr.pipe(process.stderr);
|
|
1116
1105
|
childProc.on("close", (code) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|