sveld 0.25.4 → 0.25.5
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.
|
@@ -68,6 +68,8 @@ function addCommentLine(value, returnValue) {
|
|
|
68
68
|
return `* ${returnValue || value}\n`;
|
|
69
69
|
}
|
|
70
70
|
function genPropDef(def) {
|
|
71
|
+
// Collect existing prop names to avoid conflicts with snippet props
|
|
72
|
+
const existingPropNames = new Set(def.props.filter((prop) => !prop.isFunctionDeclaration && prop.kind !== "const").map((prop) => prop.name));
|
|
71
73
|
const initial_props = def.props
|
|
72
74
|
.filter((prop) => !prop.isFunctionDeclaration && prop.kind !== "const")
|
|
73
75
|
.map((prop) => {
|
|
@@ -91,7 +93,18 @@ function genPropDef(def) {
|
|
|
91
93
|
${prop_comments.length > 0 ? `/**\n${prop_comments}*/` : EMPTY_STR}
|
|
92
94
|
${prop.name}${prop.isRequired ? "" : "?"}: ${prop_value};`;
|
|
93
95
|
});
|
|
94
|
-
|
|
96
|
+
// Generate snippet props for named slots (Svelte 5 compatibility)
|
|
97
|
+
// Skip default slots and slots that conflict with existing prop names
|
|
98
|
+
const snippet_props = (def.slots || [])
|
|
99
|
+
.filter((slot) => !slot.default && slot.name != null && !existingPropNames.has(slot.name))
|
|
100
|
+
.map((slot) => {
|
|
101
|
+
const slotName = slot.name;
|
|
102
|
+
const key = clampKey(slotName);
|
|
103
|
+
const description = slot.description ? `/** ${slot.description} */\n ` : "";
|
|
104
|
+
return `
|
|
105
|
+
${description}${key}?: () => void;`;
|
|
106
|
+
});
|
|
107
|
+
const props = [...initial_props, ...snippet_props].join("\n");
|
|
95
108
|
const props_name = `${def.moduleName}Props`;
|
|
96
109
|
let prop_def = EMPTY_STR;
|
|
97
110
|
const genericsName = def.generics ? `<${def.generics[0]}>` : "";
|
|
@@ -443,6 +456,7 @@ function writeTsDefinition(component) {
|
|
|
443
456
|
rest_props,
|
|
444
457
|
extends: _extends,
|
|
445
458
|
generics,
|
|
459
|
+
slots,
|
|
446
460
|
});
|
|
447
461
|
const generic = generics ? `<${generics[1]}>` : "";
|
|
448
462
|
const genericProps = generics ? `${props_name}<${generics[0]}>` : props_name;
|