@builder.io/mitosis 0.0.64 → 0.0.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/constants/html_tags.js +63 -0
- package/dist/src/flow.d.ts +3 -0
- package/dist/src/flow.js +5 -1
- package/dist/src/generators/qwik/component-generator.js +7 -7
- package/dist/src/generators/react/generator.js +4 -2
- package/dist/src/generators/react-native.js +51 -34
- package/dist/src/generators/svelte.js +1 -0
- package/dist/src/index.d.ts +9 -1
- package/dist/src/index.js +4 -0
- package/dist/src/types/config.d.ts +3 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/__tests__/data/advanced-ref.raw.d.ts +0 -4
- package/dist/src/__tests__/data/advanced-ref.raw.jsx +0 -39
- package/dist/src/__tests__/data/basic-boolean-attribute-component.raw.d.ts +0 -6
- package/dist/src/__tests__/data/basic-boolean-attribute-component.raw.jsx +0 -8
- package/dist/src/__tests__/data/basic-boolean-attribute.raw.d.ts +0 -6
- package/dist/src/__tests__/data/basic-boolean-attribute.raw.jsx +0 -15
- package/dist/src/__tests__/data/basic-child-component.raw.d.ts +0 -1
- package/dist/src/__tests__/data/basic-child-component.raw.jsx +0 -21
- package/dist/src/__tests__/data/basic-context.raw.d.ts +0 -1
- package/dist/src/__tests__/data/basic-context.raw.jsx +0 -29
- package/dist/src/__tests__/data/basic-custom-mitosis-package.raw.d.ts +0 -1
- package/dist/src/__tests__/data/basic-custom-mitosis-package.raw.jsx +0 -10
- package/dist/src/__tests__/data/basic-for-show.raw.d.ts +0 -1
- package/dist/src/__tests__/data/basic-for-show.raw.jsx +0 -20
- package/dist/src/__tests__/data/basic-for.raw.d.ts +0 -1
- package/dist/src/__tests__/data/basic-for.raw.jsx +0 -23
- package/dist/src/__tests__/data/basic-forwardRef-metadata.raw.d.ts +0 -5
- package/dist/src/__tests__/data/basic-forwardRef-metadata.raw.jsx +0 -17
- package/dist/src/__tests__/data/basic-forwardRef.raw.d.ts +0 -5
- package/dist/src/__tests__/data/basic-forwardRef.raw.jsx +0 -14
- package/dist/src/__tests__/data/basic-onChange.raw.d.ts +0 -1
- package/dist/src/__tests__/data/basic-onChange.raw.jsx +0 -17
- package/dist/src/__tests__/data/basic-onMount-update.raw.d.ts +0 -5
- package/dist/src/__tests__/data/basic-onMount-update.raw.jsx +0 -17
- package/dist/src/__tests__/data/basic-onUpdate-return.raw.d.ts +0 -1
- package/dist/src/__tests__/data/basic-onUpdate-return.raw.jsx +0 -24
- package/dist/src/__tests__/data/basic-outputs-meta.raw.d.ts +0 -1
- package/dist/src/__tests__/data/basic-outputs-meta.raw.jsx +0 -17
- package/dist/src/__tests__/data/basic-outputs.raw.d.ts +0 -1
- package/dist/src/__tests__/data/basic-outputs.raw.jsx +0 -14
- package/dist/src/__tests__/data/basic-preserve-export-or-local-statement.raw.d.ts +0 -6
- package/dist/src/__tests__/data/basic-preserve-export-or-local-statement.raw.jsx +0 -14
- package/dist/src/__tests__/data/basic-props-destructure.raw.d.ts +0 -6
- package/dist/src/__tests__/data/basic-props-destructure.raw.jsx +0 -14
- package/dist/src/__tests__/data/basic-props.raw.d.ts +0 -6
- package/dist/src/__tests__/data/basic-props.raw.jsx +0 -13
- package/dist/src/__tests__/data/basic-ref-assignment.raw.d.ts +0 -4
- package/dist/src/__tests__/data/basic-ref-assignment.raw.jsx +0 -15
- package/dist/src/__tests__/data/basic-ref-usePrevious.raw.d.ts +0 -5
- package/dist/src/__tests__/data/basic-ref-usePrevious.raw.jsx +0 -35
- package/dist/src/__tests__/data/basic-ref.raw.d.ts +0 -4
- package/dist/src/__tests__/data/basic-ref.raw.jsx +0 -36
- package/dist/src/__tests__/data/basic.raw.d.ts +0 -6
- package/dist/src/__tests__/data/basic.raw.jsx +0 -22
- package/dist/src/__tests__/data/blocks/button-with-metadata.raw.d.ts +0 -7
- package/dist/src/__tests__/data/blocks/button-with-metadata.raw.jsx +0 -23
- package/dist/src/__tests__/data/blocks/button.raw.d.ts +0 -7
- package/dist/src/__tests__/data/blocks/button.raw.jsx +0 -18
- package/dist/src/__tests__/data/blocks/classname-jsx.raw.d.ts +0 -7
- package/dist/src/__tests__/data/blocks/classname-jsx.raw.jsx +0 -15
- package/dist/src/__tests__/data/blocks/columns.raw.d.ts +0 -12
- package/dist/src/__tests__/data/blocks/columns.raw.jsx +0 -42
- package/dist/src/__tests__/data/blocks/content-slot-html.raw.d.ts +0 -7
- package/dist/src/__tests__/data/blocks/content-slot-html.raw.jsx +0 -15
- package/dist/src/__tests__/data/blocks/content-slot-jsx.raw.d.ts +0 -6
- package/dist/src/__tests__/data/blocks/content-slot-jsx.raw.jsx +0 -15
- package/dist/src/__tests__/data/blocks/custom-code.raw.d.ts +0 -5
- package/dist/src/__tests__/data/blocks/custom-code.raw.jsx +0 -48
- package/dist/src/__tests__/data/blocks/embed.raw.d.ts +0 -4
- package/dist/src/__tests__/data/blocks/embed.raw.jsx +0 -48
- package/dist/src/__tests__/data/blocks/form.raw.d.ts +0 -25
- package/dist/src/__tests__/data/blocks/form.raw.jsx +0 -272
- package/dist/src/__tests__/data/blocks/image.raw.d.ts +0 -15
- package/dist/src/__tests__/data/blocks/image.raw.jsx +0 -65
- package/dist/src/__tests__/data/blocks/img-state.raw.d.ts +0 -1
- package/dist/src/__tests__/data/blocks/img-state.raw.jsx +0 -17
- package/dist/src/__tests__/data/blocks/img.raw.d.ts +0 -9
- package/dist/src/__tests__/data/blocks/img.raw.jsx +0 -11
- package/dist/src/__tests__/data/blocks/input.raw.d.ts +0 -11
- package/dist/src/__tests__/data/blocks/input.raw.jsx +0 -8
- package/dist/src/__tests__/data/blocks/multiple-onUpdate.raw.d.ts +0 -1
- package/dist/src/__tests__/data/blocks/multiple-onUpdate.raw.jsx +0 -13
- package/dist/src/__tests__/data/blocks/multiple-onUpdateWithDeps.raw.d.ts +0 -1
- package/dist/src/__tests__/data/blocks/multiple-onUpdateWithDeps.raw.jsx +0 -25
- package/dist/src/__tests__/data/blocks/onInit-onMount.raw.d.ts +0 -1
- package/dist/src/__tests__/data/blocks/onInit-onMount.raw.jsx +0 -13
- package/dist/src/__tests__/data/blocks/onInit.raw.d.ts +0 -8
- package/dist/src/__tests__/data/blocks/onInit.raw.jsx +0 -20
- package/dist/src/__tests__/data/blocks/onMount.raw.d.ts +0 -1
- package/dist/src/__tests__/data/blocks/onMount.raw.jsx +0 -13
- package/dist/src/__tests__/data/blocks/onUpdate.raw.d.ts +0 -1
- package/dist/src/__tests__/data/blocks/onUpdate.raw.jsx +0 -10
- package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.d.ts +0 -5
- package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.jsx +0 -14
- package/dist/src/__tests__/data/blocks/raw-text.raw.d.ts +0 -5
- package/dist/src/__tests__/data/blocks/raw-text.raw.jsx +0 -7
- package/dist/src/__tests__/data/blocks/root-fragment-multi-node.raw.d.ts +0 -7
- package/dist/src/__tests__/data/blocks/root-fragment-multi-node.raw.jsx +0 -18
- package/dist/src/__tests__/data/blocks/rootShow.raw.d.ts +0 -3
- package/dist/src/__tests__/data/blocks/rootShow.raw.jsx +0 -9
- package/dist/src/__tests__/data/blocks/section-state.raw.d.ts +0 -6
- package/dist/src/__tests__/data/blocks/section-state.raw.jsx +0 -17
- package/dist/src/__tests__/data/blocks/section.raw.d.ts +0 -7
- package/dist/src/__tests__/data/blocks/section.raw.jsx +0 -11
- package/dist/src/__tests__/data/blocks/select.raw.d.ts +0 -11
- package/dist/src/__tests__/data/blocks/select.raw.jsx +0 -14
- package/dist/src/__tests__/data/blocks/self-referencing-component-with-children.raw.d.ts +0 -1
- package/dist/src/__tests__/data/blocks/self-referencing-component-with-children.raw.jsx +0 -15
- package/dist/src/__tests__/data/blocks/self-referencing-component.raw.d.ts +0 -1
- package/dist/src/__tests__/data/blocks/self-referencing-component.raw.jsx +0 -12
- package/dist/src/__tests__/data/blocks/shadow-dom.raw.d.ts +0 -6
- package/dist/src/__tests__/data/blocks/shadow-dom.raw.jsx +0 -52
- package/dist/src/__tests__/data/blocks/slot-html.raw.d.ts +0 -5
- package/dist/src/__tests__/data/blocks/slot-html.raw.jsx +0 -15
- package/dist/src/__tests__/data/blocks/slot-jsx.raw.d.ts +0 -5
- package/dist/src/__tests__/data/blocks/slot-jsx.raw.jsx +0 -12
- package/dist/src/__tests__/data/blocks/stamped-io.raw.d.ts +0 -6
- package/dist/src/__tests__/data/blocks/stamped-io.raw.jsx +0 -60
- package/dist/src/__tests__/data/blocks/submit-button.raw.d.ts +0 -6
- package/dist/src/__tests__/data/blocks/submit-button.raw.jsx +0 -9
- package/dist/src/__tests__/data/blocks/text.raw.d.ts +0 -8
- package/dist/src/__tests__/data/blocks/text.raw.jsx +0 -19
- package/dist/src/__tests__/data/blocks/textarea.raw.d.ts +0 -8
- package/dist/src/__tests__/data/blocks/textarea.raw.jsx +0 -6
- package/dist/src/__tests__/data/blocks/video.raw.d.ts +0 -17
- package/dist/src/__tests__/data/blocks/video.raw.jsx +0 -21
- package/dist/src/__tests__/data/context/component-with-context.lite.d.ts +0 -3
- package/dist/src/__tests__/data/context/component-with-context.lite.jsx +0 -21
- package/dist/src/__tests__/data/context/simple.context.lite.d.ts +0 -9
- package/dist/src/__tests__/data/context/simple.context.lite.js +0 -15
- package/dist/src/__tests__/data/default-props/default-props.raw.d.ts +0 -7
- package/dist/src/__tests__/data/default-props/default-props.raw.jsx +0 -23
- package/dist/src/__tests__/data/import.raw.d.ts +0 -1
- package/dist/src/__tests__/data/import.raw.jsx +0 -6
- package/dist/src/__tests__/data/jsx-json.spec.d.ts +0 -2
- package/dist/src/__tests__/data/jsx-json.spec.js +0 -10226
- package/dist/src/__tests__/data/nested-styles.lite.d.ts +0 -1
- package/dist/src/__tests__/data/nested-styles.lite.jsx +0 -20
- package/dist/src/__tests__/data/show/nested-show.raw.d.ts +0 -6
- package/dist/src/__tests__/data/show/nested-show.raw.jsx +0 -11
- package/dist/src/__tests__/data/show/show-with-for.raw.d.ts +0 -6
- package/dist/src/__tests__/data/show/show-with-for.raw.jsx +0 -9
- package/dist/src/__tests__/data/styles/class-and-className.raw.d.ts +0 -1
- package/dist/src/__tests__/data/styles/class-and-className.raw.jsx +0 -10
- package/dist/src/__tests__/data/styles/class.raw.d.ts +0 -1
- package/dist/src/__tests__/data/styles/class.raw.jsx +0 -10
- package/dist/src/__tests__/data/styles/className.raw.d.ts +0 -1
- package/dist/src/__tests__/data/styles/className.raw.jsx +0 -10
- package/dist/src/__tests__/data/styles/classState.raw.d.ts +0 -1
- package/dist/src/__tests__/data/styles/classState.raw.jsx +0 -13
- package/dist/src/__tests__/data/types/component-props-interface.raw.d.ts +0 -6
- package/dist/src/__tests__/data/types/component-props-interface.raw.jsx +0 -6
- package/dist/src/__tests__/data/types/component-props-type.raw.d.ts +0 -6
- package/dist/src/__tests__/data/types/component-props-type.raw.jsx +0 -6
- package/dist/src/__tests__/data/types/component-with-default-values-types.raw.d.ts +0 -5
- package/dist/src/__tests__/data/types/component-with-default-values-types.raw.jsx +0 -9
- package/dist/src/__tests__/data/types/foo-type.d.ts +0 -1
- package/dist/src/__tests__/data/types/foo-type.js +0 -2
- package/dist/src/__tests__/data/types/preserve-typing.raw.d.ts +0 -8
- package/dist/src/__tests__/data/types/preserve-typing.raw.jsx +0 -6
- package/dist/src/__tests__/data/types/type-dependency.raw.d.ts +0 -7
- package/dist/src/__tests__/data/types/type-dependency.raw.jsx +0 -6
- package/dist/src/__tests__/data/types/type-export.lite.d.ts +0 -3
- package/dist/src/__tests__/data/types/type-export.lite.jsx +0 -6
- package/dist/src/__tests__/shared.d.ts +0 -8
- package/dist/src/__tests__/shared.js +0 -373
|
@@ -116,4 +116,67 @@ exports.VALID_HTML_TAGS = [
|
|
|
116
116
|
'summary',
|
|
117
117
|
'slot',
|
|
118
118
|
'template',
|
|
119
|
+
// tags below are SVG tags. See the below article for list of SVG tags
|
|
120
|
+
// https://developer.mozilla.org/en-US/docs/Web/SVG/Element
|
|
121
|
+
'animate',
|
|
122
|
+
'animateMotion',
|
|
123
|
+
'animateTransform',
|
|
124
|
+
'circle',
|
|
125
|
+
'clipPath',
|
|
126
|
+
'defs',
|
|
127
|
+
'desc',
|
|
128
|
+
'discard',
|
|
129
|
+
'ellipse',
|
|
130
|
+
'feBlend',
|
|
131
|
+
'feColorMatrix',
|
|
132
|
+
'feComponentTransfer',
|
|
133
|
+
'feComposite',
|
|
134
|
+
'feConvolveMatrix',
|
|
135
|
+
'feDiffuseLighting',
|
|
136
|
+
'feDisplacementMap',
|
|
137
|
+
'feDistantLight',
|
|
138
|
+
'feDropShadow',
|
|
139
|
+
'feFlood',
|
|
140
|
+
'feFuncA',
|
|
141
|
+
'feFuncB',
|
|
142
|
+
'feFuncG',
|
|
143
|
+
'feFuncR',
|
|
144
|
+
'feGaussianBlur',
|
|
145
|
+
'feImage',
|
|
146
|
+
'feMerge',
|
|
147
|
+
'feMergeNode',
|
|
148
|
+
'feMorphology',
|
|
149
|
+
'feOffset',
|
|
150
|
+
'fePointLight',
|
|
151
|
+
'feSpecularLighting',
|
|
152
|
+
'feSpotLight',
|
|
153
|
+
'feTile',
|
|
154
|
+
'feTurbulence',
|
|
155
|
+
'filter',
|
|
156
|
+
'foreignObject',
|
|
157
|
+
'g',
|
|
158
|
+
'hatch',
|
|
159
|
+
'hatchpath',
|
|
160
|
+
'image',
|
|
161
|
+
'line',
|
|
162
|
+
'linearGradient',
|
|
163
|
+
'marker',
|
|
164
|
+
'mask',
|
|
165
|
+
'metadata',
|
|
166
|
+
'mpath',
|
|
167
|
+
'path',
|
|
168
|
+
'pattern',
|
|
169
|
+
'polygon',
|
|
170
|
+
'polyline',
|
|
171
|
+
'radialGradient',
|
|
172
|
+
'rect',
|
|
173
|
+
'set',
|
|
174
|
+
'stop',
|
|
175
|
+
'switch',
|
|
176
|
+
'symbol',
|
|
177
|
+
'text',
|
|
178
|
+
'textPath',
|
|
179
|
+
'tspan',
|
|
180
|
+
'use',
|
|
181
|
+
'view',
|
|
119
182
|
];
|
package/dist/src/flow.d.ts
CHANGED
package/dist/src/flow.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Show = exports.Slot = exports.For = void 0;
|
|
3
|
+
exports.Fragment = exports.Show = exports.Slot = exports.For = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Flow control based on Solid
|
|
6
6
|
*
|
|
@@ -21,3 +21,7 @@ function Show(props) {
|
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
23
|
exports.Show = Show;
|
|
24
|
+
function Fragment(props) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
exports.Fragment = Fragment;
|
|
@@ -63,6 +63,7 @@ var componentToQwik = function (userOptions) {
|
|
|
63
63
|
var css_1 = null;
|
|
64
64
|
var componentFn = (0, src_generator_1.arrowFnBlock)(['props'], [
|
|
65
65
|
function () {
|
|
66
|
+
var _a, _b;
|
|
66
67
|
css_1 = emitUseStyles(file, component);
|
|
67
68
|
emitUseContext(file, component);
|
|
68
69
|
emitUseRef(file, component);
|
|
@@ -71,7 +72,8 @@ var componentToQwik = function (userOptions) {
|
|
|
71
72
|
emitUseMount(file, component);
|
|
72
73
|
emitUseWatch(file, component);
|
|
73
74
|
emitUseCleanup(file, component);
|
|
74
|
-
emitTagNameHack(file, component);
|
|
75
|
+
emitTagNameHack(file, component, (_a = component.meta.useMetadata) === null || _a === void 0 ? void 0 : _a.elementTag);
|
|
76
|
+
emitTagNameHack(file, component, (_b = component.meta.useMetadata) === null || _b === void 0 ? void 0 : _b.componentElementTag);
|
|
75
77
|
emitJSX(file, component, mutable_1);
|
|
76
78
|
},
|
|
77
79
|
], [component.propsTypeRef + (isLightComponent ? '&{key?:any}' : '') || 'any']);
|
|
@@ -95,11 +97,9 @@ var componentToQwik = function (userOptions) {
|
|
|
95
97
|
};
|
|
96
98
|
};
|
|
97
99
|
exports.componentToQwik = componentToQwik;
|
|
98
|
-
function emitTagNameHack(file, component) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (elementTag) {
|
|
102
|
-
file.src.emit(elementTag, '=', (0, convert_method_to_function_1.convertMethodToFunction)(elementTag, stateToMethodOrGetter(component.state), getLexicalScopeVars(component)), ';');
|
|
100
|
+
function emitTagNameHack(file, component, metadataValue) {
|
|
101
|
+
if (typeof metadataValue === 'string' && metadataValue) {
|
|
102
|
+
file.src.emit(metadataValue, '=', (0, convert_method_to_function_1.convertMethodToFunction)(metadataValue, stateToMethodOrGetter(component.state), getLexicalScopeVars(component)), ';');
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
function emitUseMount(file, component) {
|
|
@@ -215,7 +215,7 @@ function emitUseStore(file, stateInit) {
|
|
|
215
215
|
}
|
|
216
216
|
else {
|
|
217
217
|
// TODO hack for now so that `state` variable is defined, even though it is never read.
|
|
218
|
-
file.src.emit('const state
|
|
218
|
+
file.src.emit('const state' + (file.options.isTypeScript ? ': any' : '') + ' = {};');
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
function emitTypes(file, component) {
|
|
@@ -83,7 +83,6 @@ var NODE_MAPPERS = {
|
|
|
83
83
|
},
|
|
84
84
|
Fragment: function (json, options) {
|
|
85
85
|
var wrap = wrapInFragment(json);
|
|
86
|
-
var tagName = options.preact ? 'Fragment' : '';
|
|
87
86
|
return "".concat(wrap ? getFragment('open', options) : '').concat(json.children
|
|
88
87
|
.map(function (item) { return (0, exports.blockToReact)(item, options); })
|
|
89
88
|
.join('\n')).concat(wrap ? getFragment('close', options) : '');
|
|
@@ -409,7 +408,10 @@ var _componentToReact = function (json, options, isSubComponent) {
|
|
|
409
408
|
? "/** @jsx jsx */\n import { jsx } from '@emotion/react'".trim()
|
|
410
409
|
: '', hasState && stateType === 'valtio' ? "import { useLocalProxy } from 'valtio/utils';" : '', hasState && stateType === 'solid' ? "import { useMutable } from 'react-solid-state';" : '', stateType === 'mobx' && hasState
|
|
411
410
|
? "import { useLocalObservable } from 'mobx-react-lite';"
|
|
412
|
-
: '', json.types ? json.types.join('\n') : '', (0, render_imports_1.renderPreComponent)({
|
|
411
|
+
: '', json.types ? json.types.join('\n') : '', (0, render_imports_1.renderPreComponent)({
|
|
412
|
+
component: json,
|
|
413
|
+
target: options.type === 'native' ? 'reactNative' : 'react',
|
|
414
|
+
}), isSubComponent ? '' : 'export default ', isForwardRef ? "forwardRef".concat(forwardRefType ? "<".concat(forwardRefType, ">") : '', "(") : '', json.name || 'MyComponent', propsArgs, isForwardRef ? ", ".concat(options.forwardRef) : '', hasStateArgument ? '' : refsString, hasState
|
|
413
415
|
? stateType === 'mobx'
|
|
414
416
|
? "const state = useLocalObservable(() => (".concat((0, get_state_object_string_1.getStateObjectStringFromComponent)(json), "));")
|
|
415
417
|
: stateType === 'useState'
|
|
@@ -10,6 +10,15 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
13
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
24
|
};
|
|
@@ -66,45 +75,53 @@ var collectReactNativeStyles = function (json) {
|
|
|
66
75
|
return styleMap;
|
|
67
76
|
};
|
|
68
77
|
exports.collectReactNativeStyles = collectReactNativeStyles;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
if (node.bindings.className) {
|
|
94
|
-
delete node.bindings.className;
|
|
95
|
-
}
|
|
78
|
+
/**
|
|
79
|
+
* Plugin that handles necessary transformations from React to React Native:
|
|
80
|
+
* - Converts DOM tags to <View /> and <Text />
|
|
81
|
+
* - Removes redundant `class`/`className` attributes
|
|
82
|
+
*/
|
|
83
|
+
var PROCESS_REACT_NATIVE_PLUGIN = function () { return ({
|
|
84
|
+
json: {
|
|
85
|
+
pre: function (json) {
|
|
86
|
+
(0, traverse_1.default)(json).forEach(function (node) {
|
|
87
|
+
var _a, _b, _c, _d;
|
|
88
|
+
if ((0, is_mitosis_node_1.isMitosisNode)(node)) {
|
|
89
|
+
// TODO: handle TextInput, Image, etc
|
|
90
|
+
if (node.name.toLowerCase() === node.name) {
|
|
91
|
+
node.name = 'View';
|
|
92
|
+
}
|
|
93
|
+
if (((_a = node.properties._text) === null || _a === void 0 ? void 0 : _a.trim().length) || ((_d = (_c = (_b = node.bindings._text) === null || _b === void 0 ? void 0 : _b.code) === null || _c === void 0 ? void 0 : _c.trim()) === null || _d === void 0 ? void 0 : _d.length)) {
|
|
94
|
+
node.name = 'Text';
|
|
95
|
+
}
|
|
96
|
+
if (node.properties.class) {
|
|
97
|
+
delete node.properties.class;
|
|
98
|
+
}
|
|
99
|
+
if (node.properties.className) {
|
|
100
|
+
delete node.properties.className;
|
|
96
101
|
}
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
if (node.bindings.class) {
|
|
103
|
+
delete node.bindings.class;
|
|
104
|
+
}
|
|
105
|
+
if (node.bindings.className) {
|
|
106
|
+
delete node.bindings.className;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
99
110
|
},
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
var
|
|
103
|
-
|
|
111
|
+
},
|
|
112
|
+
}); };
|
|
113
|
+
var DEFAULT_OPTIONS = {
|
|
114
|
+
stateType: 'useState',
|
|
115
|
+
stylesType: 'react-native',
|
|
116
|
+
plugins: [PROCESS_REACT_NATIVE_PLUGIN],
|
|
117
|
+
};
|
|
118
|
+
var componentToReactNative = function (_options) {
|
|
119
|
+
if (_options === void 0) { _options = {}; }
|
|
104
120
|
return function (_a) {
|
|
105
121
|
var component = _a.component, path = _a.path;
|
|
106
122
|
var json = (0, fast_clone_1.fastClone)(component);
|
|
107
|
-
|
|
123
|
+
var options = __assign(__assign(__assign({}, DEFAULT_OPTIONS), _options), { plugins: __spreadArray(__spreadArray([], (DEFAULT_OPTIONS.plugins || []), true), (_options.plugins || []), true), type: 'native' });
|
|
124
|
+
return (0, react_1.componentToReact)(options)({ component: json, path: path });
|
|
108
125
|
};
|
|
109
126
|
};
|
|
110
127
|
exports.componentToReactNative = componentToReactNative;
|
|
@@ -165,6 +165,7 @@ var getTagName = function (_a) {
|
|
|
165
165
|
var stripStateAndProps = function (code, options) {
|
|
166
166
|
return (0, strip_state_and_props_refs_1.stripStateAndPropsRefs)(code, {
|
|
167
167
|
includeState: options.stateType === 'variables',
|
|
168
|
+
replaceWith: function (name) { return (name === 'children' ? '$$slots.default' : name); },
|
|
168
169
|
});
|
|
169
170
|
};
|
|
170
171
|
var blockToSvelte = function (_a) {
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { JSX } from '@builder.io/mitosis/jsx-runtime';
|
|
1
2
|
export * from './flow';
|
|
2
|
-
|
|
3
|
+
declare function Provider<T>(props: {
|
|
4
|
+
value: T;
|
|
5
|
+
children: JSX.Element;
|
|
6
|
+
}): any;
|
|
7
|
+
export declare type Context<T> = {
|
|
8
|
+
Provider: typeof Provider<T>;
|
|
9
|
+
};
|
|
3
10
|
export declare const useStore: <T>(obj: T) => T;
|
|
4
11
|
export declare const useState: <T>(obj: T) => [T, (value: T) => void];
|
|
5
12
|
export declare const useRef: <T>(obj?: void | T | null | undefined) => T;
|
|
@@ -54,6 +61,7 @@ export * from './types/mitosis-node';
|
|
|
54
61
|
export * from './types/mitosis-component';
|
|
55
62
|
export * from './types/config';
|
|
56
63
|
export * from './types/transpiler';
|
|
64
|
+
export * from './types/plugins';
|
|
57
65
|
export * from './plugins/compile-away-builder-components';
|
|
58
66
|
export * from './plugins/compile-away-components';
|
|
59
67
|
export * from './plugins/map-styles';
|
package/dist/src/index.js
CHANGED
|
@@ -16,6 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.useDefaultProps = exports.useMetadata = exports.onError = exports.useDynamicTag = exports.onUnMount = exports.onInit = exports.onCreate = exports.onUpdate = exports.onMount = exports.setContext = exports.createContext = exports.useContext = exports.useRef = exports.useState = exports.useStore = void 0;
|
|
18
18
|
__exportStar(require("./flow"), exports);
|
|
19
|
+
function Provider(props) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
19
22
|
// These compile away
|
|
20
23
|
var useStore = function (obj) {
|
|
21
24
|
throw new Error('useStore: Mitosis hook should have been compiled away');
|
|
@@ -95,6 +98,7 @@ __exportStar(require("./types/mitosis-node"), exports);
|
|
|
95
98
|
__exportStar(require("./types/mitosis-component"), exports);
|
|
96
99
|
__exportStar(require("./types/config"), exports);
|
|
97
100
|
__exportStar(require("./types/transpiler"), exports);
|
|
101
|
+
__exportStar(require("./types/plugins"), exports);
|
|
98
102
|
__exportStar(require("./plugins/compile-away-builder-components"), exports);
|
|
99
103
|
__exportStar(require("./plugins/compile-away-components"), exports);
|
|
100
104
|
__exportStar(require("./plugins/map-styles"), exports);
|
|
@@ -64,6 +64,8 @@ export declare type MitosisConfig = {
|
|
|
64
64
|
* Configure a custom function that provides the output path for each target.
|
|
65
65
|
* If you provide this function, you must provide a value for every target yourself.
|
|
66
66
|
*/
|
|
67
|
-
getTargetPath
|
|
67
|
+
getTargetPath: ({ target }: {
|
|
68
|
+
target: Target;
|
|
69
|
+
}) => string;
|
|
68
70
|
};
|
|
69
71
|
export {};
|