nuxt-generation-emails 1.4.0 → 1.4.1
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/module.json +1 -1
- package/dist/module.mjs +116 -21
- package/dist/runtime/components/EmailTemplateSelector.vue +11 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -309,30 +309,125 @@ function evaluateAstExpression(node) {
|
|
|
309
309
|
}
|
|
310
310
|
function extractPropTypesFromSource(scriptContent) {
|
|
311
311
|
const result = {};
|
|
312
|
-
|
|
313
|
-
if (!
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
312
|
+
let typeBody = extractInlineTypeBody(scriptContent);
|
|
313
|
+
if (!typeBody) {
|
|
314
|
+
typeBody = resolveNamedTypeBody(scriptContent);
|
|
315
|
+
}
|
|
316
|
+
if (!typeBody) return result;
|
|
317
|
+
parsePropEntries(typeBody, result);
|
|
318
|
+
return result;
|
|
319
|
+
}
|
|
320
|
+
function extractInlineTypeBody(scriptContent) {
|
|
321
|
+
const definePropsMatch = scriptContent.match(/defineProps\s*<\s*\{/);
|
|
322
|
+
if (!definePropsMatch || definePropsMatch.index === void 0) return null;
|
|
323
|
+
const braceStart = scriptContent.indexOf("{", definePropsMatch.index + "defineProps".length);
|
|
324
|
+
if (braceStart === -1) return null;
|
|
325
|
+
let depth = 1;
|
|
326
|
+
let i = braceStart + 1;
|
|
327
|
+
while (i < scriptContent.length && depth > 0) {
|
|
328
|
+
const ch = scriptContent[i];
|
|
329
|
+
if (ch === "{") depth++;
|
|
330
|
+
else if (ch === "}") depth--;
|
|
331
|
+
if (depth > 0) i++;
|
|
332
|
+
}
|
|
333
|
+
if (depth !== 0) return null;
|
|
334
|
+
return scriptContent.slice(braceStart + 1, i);
|
|
335
|
+
}
|
|
336
|
+
function resolveNamedTypeBody(scriptContent) {
|
|
337
|
+
const namedMatch = scriptContent.match(/defineProps\s*<\s*(\w+)\s*>\s*\(/);
|
|
338
|
+
if (!namedMatch) return null;
|
|
339
|
+
const typeName = namedMatch[1];
|
|
340
|
+
const interfacePattern = new RegExp(`interface\\s+${typeName}\\s*\\{`);
|
|
341
|
+
const interfaceMatch = interfacePattern.exec(scriptContent);
|
|
342
|
+
if (interfaceMatch && interfaceMatch.index !== void 0) {
|
|
343
|
+
const braceStart = scriptContent.indexOf("{", interfaceMatch.index);
|
|
344
|
+
if (braceStart !== -1) {
|
|
345
|
+
return extractBalancedBraceContent(scriptContent, braceStart);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
const typeAliasPattern = new RegExp(`type\\s+${typeName}\\s*=\\s*\\{`);
|
|
349
|
+
const typeAliasMatch = typeAliasPattern.exec(scriptContent);
|
|
350
|
+
if (typeAliasMatch && typeAliasMatch.index !== void 0) {
|
|
351
|
+
const braceStart = scriptContent.indexOf("{", typeAliasMatch.index);
|
|
352
|
+
if (braceStart !== -1) {
|
|
353
|
+
return extractBalancedBraceContent(scriptContent, braceStart);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
function extractBalancedBraceContent(source, braceStart) {
|
|
359
|
+
let depth = 1;
|
|
360
|
+
let i = braceStart + 1;
|
|
361
|
+
while (i < source.length && depth > 0) {
|
|
362
|
+
const ch = source[i];
|
|
363
|
+
if (ch === "{") depth++;
|
|
364
|
+
else if (ch === "}") depth--;
|
|
365
|
+
if (depth > 0) i++;
|
|
366
|
+
}
|
|
367
|
+
if (depth !== 0) return null;
|
|
368
|
+
return source.slice(braceStart + 1, i);
|
|
369
|
+
}
|
|
370
|
+
function classifyTsType(tsType) {
|
|
371
|
+
const trimmed = tsType.trim();
|
|
372
|
+
if (trimmed.includes("|")) {
|
|
373
|
+
const members = trimmed.split("|").map((m) => m.trim()).filter((m) => m !== "null" && m !== "undefined");
|
|
374
|
+
if (members.length === 1) return classifyTsType(members[0]);
|
|
375
|
+
const types = new Set(members.map((m) => classifyTsType(m)));
|
|
376
|
+
if (types.size === 1) return types.values().next().value;
|
|
377
|
+
return "object";
|
|
378
|
+
}
|
|
379
|
+
if (trimmed.endsWith("[]") || /^Array\s*</.test(trimmed) || /^ReadonlyArray\s*</.test(trimmed)) {
|
|
380
|
+
return "object";
|
|
381
|
+
}
|
|
382
|
+
if (/^\w+\s*</.test(trimmed)) {
|
|
383
|
+
return "object";
|
|
384
|
+
}
|
|
385
|
+
switch (trimmed.toLowerCase()) {
|
|
386
|
+
case "string":
|
|
387
|
+
return "string";
|
|
388
|
+
case "number":
|
|
389
|
+
return "number";
|
|
390
|
+
case "boolean":
|
|
391
|
+
return "boolean";
|
|
392
|
+
default:
|
|
393
|
+
return "object";
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
function parsePropEntries(typeBody, result) {
|
|
397
|
+
const cleaned = typeBody.replace(/\/\/[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
398
|
+
let i = 0;
|
|
399
|
+
while (i < cleaned.length) {
|
|
400
|
+
while (i < cleaned.length && /\s/.test(cleaned[i])) i++;
|
|
401
|
+
if (i >= cleaned.length) break;
|
|
402
|
+
const propNameMatch = cleaned.slice(i).match(/^(\w+)\s*(\?)?\s*:/);
|
|
403
|
+
if (!propNameMatch) {
|
|
404
|
+
const next = cleaned.indexOf(";", i);
|
|
405
|
+
if (next === -1) break;
|
|
406
|
+
i = next + 1;
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
const propName = propNameMatch[1];
|
|
410
|
+
i += propNameMatch[0].length;
|
|
411
|
+
const typeStart = i;
|
|
412
|
+
let depth = 0;
|
|
413
|
+
while (i < cleaned.length) {
|
|
414
|
+
const ch = cleaned[i];
|
|
415
|
+
if (ch === "<" || ch === "{" || ch === "[" || ch === "(") {
|
|
416
|
+
depth++;
|
|
417
|
+
} else if (ch === ">" || ch === "}" || ch === "]" || ch === ")") {
|
|
418
|
+
if (depth > 0) depth--;
|
|
419
|
+
else break;
|
|
420
|
+
} else if ((ch === ";" || ch === "\n") && depth === 0) {
|
|
332
421
|
break;
|
|
422
|
+
}
|
|
423
|
+
i++;
|
|
333
424
|
}
|
|
425
|
+
const typeText = cleaned.slice(typeStart, i).trim();
|
|
426
|
+
if (typeText) {
|
|
427
|
+
result[propName] = classifyTsType(typeText);
|
|
428
|
+
}
|
|
429
|
+
if (i < cleaned.length && (cleaned[i] === ";" || cleaned[i] === "\n")) i++;
|
|
334
430
|
}
|
|
335
|
-
return result;
|
|
336
431
|
}
|
|
337
432
|
function extractDefaultsFromSource(scriptContent) {
|
|
338
433
|
const defaultsText = extractDefaultsObjectText(scriptContent);
|
|
@@ -69,8 +69,19 @@ function toggleDirectory(path) {
|
|
|
69
69
|
expandedDirs.value.add(path);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
+
function expandToCurrentTemplate() {
|
|
73
|
+
const current = currentTemplate.value;
|
|
74
|
+
if (!current || current === "Select a template") return;
|
|
75
|
+
const parts = current.split("/");
|
|
76
|
+
for (let i = 1; i < parts.length; i++) {
|
|
77
|
+
expandedDirs.value.add(parts.slice(0, i).join("/"));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
72
80
|
function toggleDropdown() {
|
|
73
81
|
isOpen.value = !isOpen.value;
|
|
82
|
+
if (isOpen.value) {
|
|
83
|
+
expandToCurrentTemplate();
|
|
84
|
+
}
|
|
74
85
|
}
|
|
75
86
|
function handleClickOutside(event) {
|
|
76
87
|
const target = event.target;
|
package/package.json
CHANGED