UNPKG

@builder.io/mitosis

Version:

Write components once, run everywhere. Compiles to Vue, React, Solid, and Liquid. Import code from Figma and Builder.io

32 lines (31 loc) 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FUNCTION_HACK_PLUGIN = void 0; const patterns_1 = require("../../helpers/patterns"); const FUNCTION_HACK_PLUGIN = () => ({ json: { pre: (json) => { for (const key in json.state) { const state = json.state[key]; const value = state === null || state === void 0 ? void 0 : state.code; const type = state === null || state === void 0 ? void 0 : state.type; if (typeof value === 'string' && type === 'method') { const newValue = (0, patterns_1.prefixWithFunction)(value); json.state[key] = { ...state, code: newValue, type: 'method', }; } else if (typeof value === 'string' && type === 'function') { json.state[key] = { ...state, code: value, type: 'method', }; } } }, }, }); exports.FUNCTION_HACK_PLUGIN = FUNCTION_HACK_PLUGIN;