(ctx: ScriptCompileContext)
| 139 | } |
| 140 | |
| 141 | export function genRuntimeProps(ctx: ScriptCompileContext): string | undefined { |
| 142 | let propsDecls: undefined | string |
| 143 | |
| 144 | if (ctx.propsRuntimeDecl) { |
| 145 | propsDecls = ctx.getString(ctx.propsRuntimeDecl).trim() |
| 146 | if (ctx.propsDestructureDecl) { |
| 147 | const defaults: string[] = [] |
| 148 | for (const key in ctx.propsDestructuredBindings) { |
| 149 | const d = genDestructuredDefaultValue(ctx, key) |
| 150 | const finalKey = getEscapedPropName(key) |
| 151 | if (d) |
| 152 | defaults.push( |
| 153 | `${finalKey}: ${d.valueString}${ |
| 154 | d.needSkipFactory ? `, __skip_${finalKey}: true` : `` |
| 155 | }`, |
| 156 | ) |
| 157 | } |
| 158 | if (defaults.length) { |
| 159 | propsDecls = `/*@__PURE__*/${ctx.helper( |
| 160 | `mergeDefaults`, |
| 161 | )}(${propsDecls}, {\n ${defaults.join(',\n ')}\n})` |
| 162 | } |
| 163 | } |
| 164 | } else if (ctx.propsTypeDecl) { |
| 165 | propsDecls = extractRuntimeProps(ctx) |
| 166 | } |
| 167 | |
| 168 | const modelsDecls = genModelProps(ctx) |
| 169 | |
| 170 | if (propsDecls && modelsDecls) { |
| 171 | return `/*@__PURE__*/${ctx.helper( |
| 172 | 'mergeModels', |
| 173 | )}(${propsDecls}, ${modelsDecls})` |
| 174 | } else { |
| 175 | return modelsDecls || propsDecls |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | export function extractRuntimeProps( |
| 180 | ctx: TypeResolveContext, |
no test coverage detected