@wraps.dev/cli 2.18.8 → 2.18.10

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,76 @@ 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
+ return canonicalByLower.get(name.toLowerCase()) ?? name;
24198
+ }
24199
+ return text10.replace(
24200
+ /\{\{([#/]?)([A-Z][A-Z0-9_]*(?:\.[A-Z0-9_]+)*)((?:\s+[A-Z0-9_.]+)*)\s*\}\}/g,
24201
+ (match, sigil, name, args2) => {
24202
+ const lower = name.toLowerCase();
24203
+ const isHelper = lower === "else" || HANDLEBARS_BLOCK_HELPERS.has(lower);
24204
+ const restoredArgs = args2.split(/\s+/).filter(Boolean).map(restoreIdentifier).join(" ");
24205
+ if (isHelper) {
24206
+ const suffix = restoredArgs ? ` ${restoredArgs}` : "";
24207
+ return `{{${sigil}${lower}${suffix}}}`;
24208
+ }
24209
+ if (!args2 && canonicalByLower.has(lower)) {
24210
+ return `{{${sigil}${canonicalByLower.get(lower)}}}`;
24211
+ }
24212
+ return match;
24213
+ }
24214
+ );
24215
+ }
24216
+
24217
+ // src/utils/email/template-render.ts
24218
+ async function renderTemplateWithProxy(Component) {
24219
+ const accessedProps = /* @__PURE__ */ new Set();
24220
+ const props = new Proxy({}, {
24221
+ get: (_target, prop) => {
24222
+ if (typeof prop === "symbol") {
24223
+ return;
24224
+ }
24225
+ const name = String(prop);
24226
+ accessedProps.add(name);
24227
+ return `{{${name}}}`;
24228
+ }
24229
+ });
24230
+ const { render } = await import("@react-email/render");
24231
+ const element = Component(props);
24232
+ if (element === null) {
24233
+ throw new Error(
24234
+ "Template component returned null. Check that the component's default export returns a React element unconditionally."
24235
+ );
24236
+ }
24237
+ const html = await render(element);
24238
+ const rawText = await render(element, {
24239
+ plainText: true
24240
+ });
24241
+ const htmlVarNames = /* @__PURE__ */ new Set();
24242
+ const regex = /\{\{([a-zA-Z0-9_.]+)(?:\|[^}]*)?\}\}/g;
24243
+ let match = regex.exec(html);
24244
+ while (match !== null) {
24245
+ htmlVarNames.add(match[1]);
24246
+ match = regex.exec(html);
24247
+ }
24248
+ const canonicalVars = /* @__PURE__ */ new Set([...htmlVarNames, ...accessedProps]);
24249
+ const text10 = normalizePlainTextMustaches(rawText, canonicalVars);
24250
+ return { html, text: text10, accessedProps };
24251
+ }
24252
+
24253
+ // src/commands/email/templates/push.ts
24184
24254
  init_config();
24185
24255
  init_errors();
24186
24256
  init_json_output();
@@ -24416,24 +24486,7 @@ async function compileTemplate(filePath, slug, source, sourceHash, wrapsDir) {
24416
24486
  "Template must have a default export (React component function)"
24417
24487
  );
24418
24488
  }
24419
- const accessedProps = /* @__PURE__ */ new Set();
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 });
24489
+ const { html, text: text10, accessedProps } = await renderTemplateWithProxy(Component);
24437
24490
  const variables = mergeVariables(extractVariables(html), accessedProps);
24438
24491
  const sesSubject = transformVariablesForSes(subject);
24439
24492
  const sesHtml = transformVariablesForSes(html);