(userProvidedOptions)
| 37 | |
| 38 | export const componentToSwift: TranspilerGenerator<ToSwiftOptions> = |
| 39 | (userProvidedOptions) => |
| 40 | ({ component }) => { |
| 41 | const options = initializeOptions({ |
| 42 | target: 'swift', |
| 43 | component, |
| 44 | defaults: DEFAULT_OPTIONS, |
| 45 | userOptions: userProvidedOptions, |
| 46 | }); |
| 47 | |
| 48 | options.plugins = [ |
| 49 | ...(options.plugins || []), |
| 50 | processOnEventHooksPlugin(), |
| 51 | CODE_PROCESSOR_PLUGIN((codeType) => { |
| 52 | switch (codeType) { |
| 53 | case 'bindings': |
| 54 | case 'properties': |
| 55 | case 'hooks': |
| 56 | case 'hooks-deps': |
| 57 | case 'hooks-deps-array': |
| 58 | case 'state': |
| 59 | case 'context-set': |
| 60 | case 'dynamic-jsx-elements': |
| 61 | case 'types': |
| 62 | return (x) => convertConsoleLogToPrint(x); |
| 63 | } |
| 64 | }), |
| 65 | CODE_PROCESSOR_PLUGIN((codeType) => { |
| 66 | switch (codeType) { |
| 67 | case 'hooks': |
| 68 | return (code: string) => stripStateAndProps({ json, options })(code); |
| 69 | case 'bindings': |
| 70 | case 'hooks-deps': |
| 71 | case 'state': |
| 72 | return (code: string) => stripGetter(stripStateAndProps({ json, options })(code)); |
| 73 | case 'properties': |
| 74 | case 'context-set': |
| 75 | return (code: string) => stripStateAndProps({ json, options })(code); |
| 76 | case 'dynamic-jsx-elements': |
| 77 | case 'hooks-deps-array': |
| 78 | case 'types': |
| 79 | return (x) => convertConsoleLogToPrint(x); |
| 80 | } |
| 81 | }), |
| 82 | ]; |
| 83 | |
| 84 | // Make a copy we can safely mutate |
| 85 | let json = fastClone(component); |
| 86 | json = runPreJsonPlugins({ json, plugins: options.plugins }); |
| 87 | |
| 88 | gettersToFunctions(json); |
| 89 | |
| 90 | const componentName = |
| 91 | options.classPrefix + (json.name || json.meta.useMetadata?.name || 'MitosisComponent'); |
| 92 | |
| 93 | // Process props |
| 94 | const filteredProps = Array.from(getProps(json)).filter((prop) => !isSlotProperty(prop)); |
| 95 | |
| 96 | const props = Array.from(new Set(filteredProps)); |
no test coverage detected