(passedOptions)
| 99 | |
| 100 | export const componentToSolid: TranspilerGenerator<Partial<ToSolidOptions>> = |
| 101 | (passedOptions) => |
| 102 | ({ component }) => { |
| 103 | let json = fastClone(component); |
| 104 | |
| 105 | const options = initializeOptions({ |
| 106 | target: 'solid', |
| 107 | component, |
| 108 | defaults: DEFAULT_OPTIONS, |
| 109 | userOptions: passedOptions, |
| 110 | }); |
| 111 | options.plugins = [ |
| 112 | ...(options.plugins || []), |
| 113 | processOnEventHooksPlugin(), |
| 114 | CODE_PROCESSOR_PLUGIN((codeType) => { |
| 115 | switch (codeType) { |
| 116 | case 'state': |
| 117 | case 'context-set': |
| 118 | case 'dynamic-jsx-elements': |
| 119 | case 'types': |
| 120 | return (c) => c; |
| 121 | case 'bindings': |
| 122 | case 'hooks': |
| 123 | case 'hooks-deps': |
| 124 | case 'hooks-deps-array': |
| 125 | case 'properties': |
| 126 | return updateStateCode({ |
| 127 | component: json, |
| 128 | options, |
| 129 | updateSetters: codeType === 'properties' ? false : true, |
| 130 | }); |
| 131 | } |
| 132 | }), |
| 133 | ]; |
| 134 | |
| 135 | if (options.plugins) { |
| 136 | json = runPreJsonPlugins({ json, plugins: options.plugins }); |
| 137 | } |
| 138 | addProviderComponents(json, options); |
| 139 | const componentHasStyles = hasCss(json); |
| 140 | const hasCustomStyles = !!json.style?.length; |
| 141 | const shouldInjectCustomStyles = hasCustomStyles && options.stylesType === 'styled-components'; |
| 142 | const addWrapper = |
| 143 | json.children.filter(filterEmptyTextNodes).length !== 1 || |
| 144 | options.stylesType === 'style-tag' || |
| 145 | shouldInjectCustomStyles || |
| 146 | isRootTextNode(json); |
| 147 | |
| 148 | // we need to run this before we run the code processor plugin, so the dynamic component variables are transformed |
| 149 | const foundDynamicComponents = processDynamicComponents(json, options); |
| 150 | |
| 151 | if (options.plugins) { |
| 152 | json = runPostJsonPlugins({ json, plugins: options.plugins }); |
| 153 | } |
| 154 | stripMetaProperties(json); |
| 155 | const css = options.stylesType === 'style-tag' && collectCss(json, { prefix: hash(json) }); |
| 156 | |
| 157 | const state = getState({ json, options }); |
| 158 | const componentsUsed = getComponentsUsed(json); |
no test coverage detected