MCPcopy
hub / github.com/BuilderIO/mitosis / componentToSolid

Function componentToSolid

packages/core/src/generators/solid/index.ts:101–273  ·  view source on GitHub ↗
(passedOptions)

Source from the content-addressed store, hash-verified

99
100export 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);

Callers 3

updateOutputFunction · 0.85
generateCodeFunction · 0.85
getOutputGeneratorFunction · 0.85

Calls 15

fastCloneFunction · 0.90
initializeOptionsFunction · 0.90
updateStateCodeFunction · 0.90
runPreJsonPluginsFunction · 0.90
hasCssFunction · 0.90
isRootTextNodeFunction · 0.90
runPostJsonPluginsFunction · 0.90
stripMetaPropertiesFunction · 0.90
collectCssFunction · 0.90
getStateFunction · 0.90
getComponentsUsedFunction · 0.90

Tested by

no test coverage detected