@wraps.dev/cli 2.18.8 → 2.18.9
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/dist/cli.js
CHANGED
|
@@ -24181,6 +24181,72 @@ import { mkdir as mkdir6, readFile as readFile6, writeFile as writeFile8 } from
|
|
|
24181
24181
|
import { join as join15 } from "path";
|
|
24182
24182
|
import * as clack31 from "@clack/prompts";
|
|
24183
24183
|
import pc33 from "picocolors";
|
|
24184
|
+
|
|
24185
|
+
// src/utils/email/template-render.ts
|
|
24186
|
+
init_esm_shims();
|
|
24187
|
+
|
|
24188
|
+
// src/utils/email/template-mustache-case.ts
|
|
24189
|
+
init_esm_shims();
|
|
24190
|
+
var HANDLEBARS_BLOCK_HELPERS = /* @__PURE__ */ new Set(["if", "unless", "each", "with"]);
|
|
24191
|
+
function normalizePlainTextMustaches(text10, canonicalVars) {
|
|
24192
|
+
const canonicalByLower = /* @__PURE__ */ new Map();
|
|
24193
|
+
for (const name of canonicalVars) {
|
|
24194
|
+
canonicalByLower.set(name.toLowerCase(), name);
|
|
24195
|
+
}
|
|
24196
|
+
function restoreIdentifier(name) {
|
|
24197
|
+
const lower = name.toLowerCase();
|
|
24198
|
+
return canonicalByLower.get(lower) ?? name;
|
|
24199
|
+
}
|
|
24200
|
+
return text10.replace(
|
|
24201
|
+
/\{\{([#/]?)([A-Z][A-Z0-9_]*)((?:\s+[A-Z0-9_.]+)*)\s*\}\}/g,
|
|
24202
|
+
(match, sigil, name, args2) => {
|
|
24203
|
+
const lower = name.toLowerCase();
|
|
24204
|
+
const isHelper = lower === "else" || HANDLEBARS_BLOCK_HELPERS.has(lower);
|
|
24205
|
+
const restoredArgs = args2.split(/\s+/).filter(Boolean).map(restoreIdentifier).join(" ");
|
|
24206
|
+
if (isHelper) {
|
|
24207
|
+
const suffix = restoredArgs ? ` ${restoredArgs}` : "";
|
|
24208
|
+
return `{{${sigil}${lower}${suffix}}}`;
|
|
24209
|
+
}
|
|
24210
|
+
if (!args2 && canonicalByLower.has(lower)) {
|
|
24211
|
+
return `{{${sigil}${canonicalByLower.get(lower)}}}`;
|
|
24212
|
+
}
|
|
24213
|
+
return match;
|
|
24214
|
+
}
|
|
24215
|
+
);
|
|
24216
|
+
}
|
|
24217
|
+
|
|
24218
|
+
// src/utils/email/template-render.ts
|
|
24219
|
+
async function renderTemplateWithProxy(Component) {
|
|
24220
|
+
const accessedProps = /* @__PURE__ */ new Set();
|
|
24221
|
+
const props = new Proxy({}, {
|
|
24222
|
+
get: (_target, prop) => {
|
|
24223
|
+
if (typeof prop === "symbol") {
|
|
24224
|
+
return;
|
|
24225
|
+
}
|
|
24226
|
+
const name = String(prop);
|
|
24227
|
+
accessedProps.add(name);
|
|
24228
|
+
return `{{${name}}}`;
|
|
24229
|
+
}
|
|
24230
|
+
});
|
|
24231
|
+
const { render } = await import("@react-email/render");
|
|
24232
|
+
const element = Component(props);
|
|
24233
|
+
const html = await render(element);
|
|
24234
|
+
const rawText = await render(element, {
|
|
24235
|
+
plainText: true
|
|
24236
|
+
});
|
|
24237
|
+
const htmlVarNames = /* @__PURE__ */ new Set();
|
|
24238
|
+
const regex = /\{\{([a-zA-Z0-9_.]+)(?:\|[^}]*)?\}\}/g;
|
|
24239
|
+
let match = regex.exec(html);
|
|
24240
|
+
while (match !== null) {
|
|
24241
|
+
htmlVarNames.add(match[1]);
|
|
24242
|
+
match = regex.exec(html);
|
|
24243
|
+
}
|
|
24244
|
+
const canonicalVars = /* @__PURE__ */ new Set([...htmlVarNames, ...accessedProps]);
|
|
24245
|
+
const text10 = normalizePlainTextMustaches(rawText, canonicalVars);
|
|
24246
|
+
return { html, text: text10, accessedProps };
|
|
24247
|
+
}
|
|
24248
|
+
|
|
24249
|
+
// src/commands/email/templates/push.ts
|
|
24184
24250
|
init_config();
|
|
24185
24251
|
init_errors();
|
|
24186
24252
|
init_json_output();
|
|
@@ -24416,24 +24482,7 @@ async function compileTemplate(filePath, slug, source, sourceHash, wrapsDir) {
|
|
|
24416
24482
|
"Template must have a default export (React component function)"
|
|
24417
24483
|
);
|
|
24418
24484
|
}
|
|
24419
|
-
const
|
|
24420
|
-
const props = new Proxy(
|
|
24421
|
-
{},
|
|
24422
|
-
{
|
|
24423
|
-
get: (_target, prop) => {
|
|
24424
|
-
if (typeof prop === "symbol") {
|
|
24425
|
-
return;
|
|
24426
|
-
}
|
|
24427
|
-
const name = String(prop);
|
|
24428
|
-
accessedProps.add(name);
|
|
24429
|
-
return `{{${name}}}`;
|
|
24430
|
-
}
|
|
24431
|
-
}
|
|
24432
|
-
);
|
|
24433
|
-
const { render } = await import("@react-email/render");
|
|
24434
|
-
const element = Component(props);
|
|
24435
|
-
const html = await render(element);
|
|
24436
|
-
const text10 = await render(element, { plainText: true });
|
|
24485
|
+
const { html, text: text10, accessedProps } = await renderTemplateWithProxy(Component);
|
|
24437
24486
|
const variables = mergeVariables(extractVariables(html), accessedProps);
|
|
24438
24487
|
const sesSubject = transformVariablesForSes(subject);
|
|
24439
24488
|
const sesHtml = transformVariablesForSes(html);
|