(
code: string,
options: InternalToHtmlOptions,
blockOptions: BlockOptions = {},
)
| 237 | |
| 238 | // TODO: overloaded function |
| 239 | const updateReferencesInCode = ( |
| 240 | code: string, |
| 241 | options: InternalToHtmlOptions, |
| 242 | blockOptions: BlockOptions = {}, |
| 243 | ): string => { |
| 244 | const contextVars = blockOptions.contextVars || []; |
| 245 | const context = blockOptions?.context || 'this.'; |
| 246 | if (options?.experimental?.updateReferencesInCode) { |
| 247 | return options?.experimental?.updateReferencesInCode(code, options, { |
| 248 | stripStateAndPropsRefs: deprecatedStripStateAndPropsRefs, |
| 249 | }); |
| 250 | } |
| 251 | if (options.format === 'class') { |
| 252 | return pipe( |
| 253 | stripStateAndPropsRefs(code, { |
| 254 | includeProps: false, |
| 255 | includeState: true, |
| 256 | replaceWith: context + 'state.', |
| 257 | }), |
| 258 | (newCode) => |
| 259 | stripStateAndPropsRefs(newCode, { |
| 260 | // TODO: replace with `this.` and add setters that call this.update() |
| 261 | includeProps: true, |
| 262 | includeState: false, |
| 263 | replaceWith: context + 'props.', |
| 264 | }), |
| 265 | (newCode) => DO_NOT_USE_CONTEXT_VARS_TRANSFORMS({ code: newCode, context, contextVars }), |
| 266 | ); |
| 267 | } |
| 268 | return code; |
| 269 | }; |
| 270 | |
| 271 | const addOnChangeJs = (id: string, options: InternalToHtmlOptions, code: string) => { |
| 272 | if (!options.onChangeJsById[id]) { |
no test coverage detected
searching dependent graphs…