@builder.io/mitosis 0.0.56-99 → 0.0.56
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/__tests__/data/blocks/content-slot-jsx.raw.jsx +4 -1
- package/dist/src/__tests__/data/blocks/form.raw.jsx +5 -5
- package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.d.ts +5 -1
- package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.jsx +3 -3
- package/dist/src/__tests__/data/jsx-json.spec.d.ts +2 -0
- package/dist/src/__tests__/data/jsx-json.spec.js +10226 -0
- package/dist/src/__tests__/shared.d.ts +7 -2
- package/dist/src/__tests__/shared.js +66 -9
- package/dist/src/constants/method-literal-prefix.d.ts +0 -1
- package/dist/src/constants/method-literal-prefix.js +0 -3
- package/dist/src/generators/angular.d.ts +2 -2
- package/dist/src/generators/angular.js +5 -3
- package/dist/src/generators/builder.d.ts +4 -11
- package/dist/src/generators/builder.js +3 -2
- package/dist/src/generators/context/svelte.d.ts +3 -0
- package/dist/src/generators/context/svelte.js +3 -0
- package/dist/src/generators/helpers/functions.d.ts +2 -0
- package/dist/src/generators/helpers/functions.js +28 -0
- package/dist/src/generators/html.d.ts +3 -3
- package/dist/src/generators/html.js +9 -7
- package/dist/src/generators/liquid.d.ts +2 -2
- package/dist/src/generators/liquid.js +4 -4
- package/dist/src/generators/lit/generate.d.ts +2 -2
- package/dist/src/generators/lit/generate.js +3 -2
- package/dist/src/generators/marko/generate.d.ts +2 -2
- package/dist/src/generators/marko/generate.js +10 -8
- package/dist/src/generators/mitosis.d.ts +3 -4
- package/dist/src/generators/mitosis.js +3 -2
- package/dist/src/generators/qwik/component-generator.d.ts +2 -2
- package/dist/src/generators/qwik/component-generator.js +49 -55
- package/dist/src/generators/qwik/component.d.ts +0 -1
- package/dist/src/generators/qwik/component.js +22 -19
- package/dist/src/generators/qwik/directives.d.ts +1 -0
- package/dist/src/generators/qwik/directives.js +11 -14
- package/dist/src/generators/qwik/jsx.d.ts +1 -1
- package/dist/src/generators/qwik/jsx.js +9 -5
- package/dist/src/generators/qwik/src-generator.js +9 -3
- package/dist/src/generators/qwik/stable-serialize.d.ts +6 -0
- package/dist/src/generators/qwik/stable-serialize.js +51 -0
- package/dist/src/generators/react/generator.d.ts +6 -0
- package/dist/src/generators/{react.js → react/generator.js} +58 -150
- package/dist/src/generators/react/helpers.d.ts +2 -0
- package/dist/src/generators/react/helpers.js +14 -0
- package/dist/src/generators/react/index.d.ts +2 -0
- package/dist/src/generators/react/index.js +18 -0
- package/dist/src/generators/react/state.d.ts +9 -0
- package/dist/src/generators/react/state.js +107 -0
- package/dist/src/generators/react/types.d.ts +10 -0
- package/dist/src/generators/react/types.js +2 -0
- package/dist/src/generators/react-native.d.ts +2 -2
- package/dist/src/generators/solid/index.d.ts +3 -0
- package/dist/src/generators/{solid.js → solid/index.js} +80 -40
- package/dist/src/generators/solid/state.d.ts +19 -0
- package/dist/src/generators/solid/state.js +144 -0
- package/dist/src/generators/solid/types.d.ts +6 -0
- package/dist/src/generators/solid/types.js +2 -0
- package/dist/src/generators/stencil/generate.d.ts +2 -2
- package/dist/src/generators/stencil/generate.js +5 -2
- package/dist/src/generators/svelte.d.ts +6 -7
- package/dist/src/generators/svelte.js +43 -40
- package/dist/src/generators/swift-ui.d.ts +3 -5
- package/dist/src/generators/swift-ui.js +3 -2
- package/dist/src/generators/template.d.ts +2 -2
- package/dist/src/generators/template.js +3 -2
- package/dist/src/generators/vue.d.ts +5 -3
- package/dist/src/generators/vue.js +256 -113
- package/dist/src/helpers/babel-transform.d.ts +3 -1
- package/dist/src/helpers/babel-transform.js +52 -56
- package/dist/src/helpers/get-bindings.js +3 -5
- package/dist/src/helpers/get-state-object-string.js +24 -21
- package/dist/src/helpers/getters-to-functions.js +1 -11
- package/dist/src/helpers/map-refs.js +25 -25
- package/dist/src/helpers/nodes/for.d.ts +4 -0
- package/dist/src/helpers/nodes/for.js +13 -0
- package/dist/src/helpers/nullable.d.ts +2 -0
- package/dist/src/helpers/nullable.js +7 -0
- package/dist/src/helpers/parse-reactive-script.js +66 -78
- package/dist/src/helpers/patterns.d.ts +2 -0
- package/dist/src/helpers/patterns.js +5 -1
- package/dist/src/helpers/render-imports.js +3 -3
- package/dist/src/helpers/replace-identifiers.d.ts +5 -0
- package/dist/src/helpers/{replace-idenifiers.js → replace-identifiers.js} +2 -1
- package/dist/src/helpers/slots.d.ts +2 -0
- package/dist/src/helpers/slots.js +15 -1
- package/dist/src/helpers/state.d.ts +0 -2
- package/dist/src/helpers/state.js +1 -10
- package/dist/src/helpers/strip-state-and-props-refs.d.ts +1 -1
- package/dist/src/helpers/strip-state-and-props-refs.js +43 -31
- package/dist/src/helpers/styles/helpers.d.ts +3 -2
- package/dist/src/parsers/angular.js +2 -2
- package/dist/src/parsers/builder.d.ts +2 -2
- package/dist/src/parsers/builder.js +61 -43
- package/dist/src/parsers/constants/outdated-prefixes.d.ts +10 -0
- package/dist/src/parsers/constants/outdated-prefixes.js +13 -0
- package/dist/src/parsers/context.js +2 -2
- package/dist/src/parsers/helpers/state.d.ts +3 -0
- package/dist/src/parsers/helpers/state.js +30 -0
- package/dist/src/parsers/jsx/component-types.d.ts +1 -1
- package/dist/src/parsers/jsx/component-types.js +15 -2
- package/dist/src/parsers/jsx/context.js +1 -1
- package/dist/src/parsers/jsx/element-parser.d.ts +6 -0
- package/dist/src/parsers/jsx/element-parser.js +243 -0
- package/dist/src/parsers/jsx/exports.d.ts +3 -0
- package/dist/src/parsers/jsx/exports.js +78 -0
- package/dist/src/parsers/jsx/function-parser.d.ts +7 -0
- package/dist/src/parsers/jsx/function-parser.js +291 -0
- package/dist/src/parsers/jsx/helpers.d.ts +2 -0
- package/dist/src/parsers/jsx/helpers.js +30 -1
- package/dist/src/parsers/jsx/imports.d.ts +7 -0
- package/dist/src/parsers/jsx/imports.js +65 -0
- package/dist/src/parsers/jsx/index.d.ts +1 -1
- package/dist/src/parsers/jsx/index.js +1 -2
- package/dist/src/parsers/jsx/jsx.js +29 -516
- package/dist/src/parsers/jsx/state.d.ts +2 -3
- package/dist/src/parsers/jsx/state.js +15 -22
- package/dist/src/plugins/compile-away-builder-components.js +6 -0
- package/dist/src/symbols/symbol-processor.js +3 -0
- package/dist/src/targets.d.ts +21 -28
- package/dist/src/targets.js +2 -2
- package/dist/src/types/config.d.ts +11 -1
- package/dist/src/types/mitosis-component.d.ts +12 -6
- package/dist/src/types/mitosis-component.js +11 -0
- package/dist/src/types/mitosis-context.d.ts +2 -2
- package/dist/src/types/mitosis-node.d.ts +14 -5
- package/dist/src/types/mitosis-node.js +3 -0
- package/dist/src/types/transpiler.d.ts +6 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +13 -9
- package/dist/src/__tests__/angular.test.d.ts +0 -1
- package/dist/src/__tests__/angular.test.js +0 -10
- package/dist/src/__tests__/builder.test.d.ts +0 -1
- package/dist/src/__tests__/builder.test.js +0 -235
- package/dist/src/__tests__/context.test.d.ts +0 -1
- package/dist/src/__tests__/context.test.js +0 -35
- package/dist/src/__tests__/hash-code.test.d.ts +0 -1
- package/dist/src/__tests__/hash-code.test.js +0 -11
- package/dist/src/__tests__/html.test.d.ts +0 -1
- package/dist/src/__tests__/html.test.js +0 -7
- package/dist/src/__tests__/liquid.test.d.ts +0 -1
- package/dist/src/__tests__/liquid.test.js +0 -7
- package/dist/src/__tests__/lit.test.d.ts +0 -1
- package/dist/src/__tests__/lit.test.js +0 -7
- package/dist/src/__tests__/marko.test.d.ts +0 -1
- package/dist/src/__tests__/marko.test.js +0 -14
- package/dist/src/__tests__/parse-jsx.test.d.ts +0 -1
- package/dist/src/__tests__/parse-jsx.test.js +0 -37
- package/dist/src/__tests__/qwik/convert-method-to-function.test.d.ts +0 -1
- package/dist/src/__tests__/qwik/convert-method-to-function.test.js +0 -37
- package/dist/src/__tests__/qwik/src-generator.test.d.ts +0 -1
- package/dist/src/__tests__/qwik/src-generator.test.js +0 -65
- package/dist/src/__tests__/qwik.directive.test.d.ts +0 -1
- package/dist/src/__tests__/qwik.directive.test.js +0 -108
- package/dist/src/__tests__/qwik.test.d.ts +0 -1
- package/dist/src/__tests__/qwik.test.js +0 -465
- package/dist/src/__tests__/react-native.test.d.ts +0 -1
- package/dist/src/__tests__/react-native.test.js +0 -7
- package/dist/src/__tests__/react.test.d.ts +0 -1
- package/dist/src/__tests__/react.test.js +0 -20
- package/dist/src/__tests__/solid.test.d.ts +0 -1
- package/dist/src/__tests__/solid.test.js +0 -10
- package/dist/src/__tests__/stencil.test.d.ts +0 -1
- package/dist/src/__tests__/stencil.test.js +0 -7
- package/dist/src/__tests__/styles.test.d.ts +0 -1
- package/dist/src/__tests__/styles.test.js +0 -23
- package/dist/src/__tests__/svelte.test.d.ts +0 -1
- package/dist/src/__tests__/svelte.test.js +0 -7
- package/dist/src/__tests__/vue.test.d.ts +0 -1
- package/dist/src/__tests__/vue.test.js +0 -7
- package/dist/src/__tests__/webcomponent.test.d.ts +0 -1
- package/dist/src/__tests__/webcomponent.test.js +0 -15
- package/dist/src/constants/function-literal-prefix.d.ts +0 -1
- package/dist/src/constants/function-literal-prefix.js +0 -4
- package/dist/src/generators/react.d.ts +0 -14
- package/dist/src/generators/solid.d.ts +0 -5
- package/dist/src/helpers/babel-transform.test.d.ts +0 -1
- package/dist/src/helpers/babel-transform.test.js +0 -7
- package/dist/src/helpers/generic-format.test.d.ts +0 -1
- package/dist/src/helpers/generic-format.test.js +0 -8
- package/dist/src/helpers/remove-surrounding-block.test.d.ts +0 -1
- package/dist/src/helpers/remove-surrounding-block.test.js +0 -9
- package/dist/src/helpers/render-imports.test.d.ts +0 -1
- package/dist/src/helpers/render-imports.test.js +0 -33
- package/dist/src/helpers/replace-idenifiers.d.ts +0 -1
- package/dist/src/helpers/styles/collect-css.test.d.ts +0 -1
- package/dist/src/helpers/styles/collect-css.test.js +0 -18
- package/dist/test/qwik/Accordion/high.jsx +0 -0
- package/dist/test/qwik/Accordion/low.jsx +0 -240
- package/dist/test/qwik/Accordion/med.jsx +0 -4
- package/dist/test/qwik/For/high.jsx +0 -0
- package/dist/test/qwik/For/low.jsx +0 -52
- package/dist/test/qwik/For/med.jsx +0 -4
- package/dist/test/qwik/Image/high.js +0 -9
- package/dist/test/qwik/Image/low.js +0 -0
- package/dist/test/qwik/Image/med.js +0 -155
- package/dist/test/qwik/Image.slow/high.js +0 -9
- package/dist/test/qwik/Image.slow/low.js +0 -0
- package/dist/test/qwik/Image.slow/med.js +0 -155
- package/dist/test/qwik/bindings/high.cjs +0 -0
- package/dist/test/qwik/bindings/low.cjs +0 -45
- package/dist/test/qwik/bindings/med.cjs +0 -3
- package/dist/test/qwik/button/high.js +0 -3
- package/dist/test/qwik/button/low.js +0 -25
- package/dist/test/qwik/button/med.js +0 -31
- package/dist/test/qwik/component/bindings/high.jsx +0 -0
- package/dist/test/qwik/component/bindings/low.jsx +0 -104
- package/dist/test/qwik/component/bindings/med.jsx +0 -7
- package/dist/test/qwik/component/component/inputs/high.cjsx +0 -9
- package/dist/test/qwik/component/component/inputs/low.cjsx +0 -0
- package/dist/test/qwik/component/component/inputs/med.cjsx +0 -68
- package/dist/test/qwik/for-loop.bindings/high.cjs +0 -0
- package/dist/test/qwik/for-loop.bindings/low.cjs +0 -56
- package/dist/test/qwik/for-loop.bindings/med.cjs +0 -5
- package/dist/test/qwik/hello_world/stylesheet/high.jsx +0 -0
- package/dist/test/qwik/hello_world/stylesheet/low.jsx +0 -26
- package/dist/test/qwik/hello_world/stylesheet/med.jsx +0 -4
- package/dist/test/qwik/mount/high.cjs +0 -0
- package/dist/test/qwik/mount/low.cjs +0 -47
- package/dist/test/qwik/mount/med.cjs +0 -3
- package/dist/test/qwik/page-with-symbol/high.js +0 -0
- package/dist/test/qwik/page-with-symbol/low.js +0 -33
- package/dist/test/qwik/page-with-symbol/med.js +0 -4
- package/dist/test/qwik/show-hide/high.jsx +0 -9
- package/dist/test/qwik/show-hide/low.jsx +0 -0
- package/dist/test/qwik/show-hide/med.jsx +0 -181
- package/dist/test/qwik/svg/high.js +0 -0
- package/dist/test/qwik/svg/low.js +0 -30
- package/dist/test/qwik/svg/med.js +0 -4
- package/dist/test/qwik/todo/Todo.cjs/high.cjs +0 -19
- package/dist/test/qwik/todo/Todo.cjs/low.cjs +0 -0
- package/dist/test/qwik/todo/Todo.cjs/med.cjs +0 -51
- package/dist/test/qwik/todo/Todo.js/high.js +0 -19
- package/dist/test/qwik/todo/Todo.js/low.js +0 -0
- package/dist/test/qwik/todo/Todo.js/med.js +0 -47
- package/dist/test/qwik/todo/Todo.tsx/high.tsx +0 -19
- package/dist/test/qwik/todo/Todo.tsx/low.tsx +0 -0
- package/dist/test/qwik/todo/Todo.tsx/med.tsx +0 -43
- package/dist/test/qwik/todos/Todo.tsx/high.tsx +0 -7
- package/dist/test/qwik/todos/Todo.tsx/low.tsx +0 -32
- package/dist/test/qwik/todos/Todo.tsx/med.tsx +0 -4
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -37,25 +37,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.parseStateObjectToMitosisState = exports.parseStateObject = exports.
|
|
40
|
+
exports.parseStateObjectToMitosisState = exports.parseStateObject = exports.mapStateIdentifiers = void 0;
|
|
41
41
|
var babel = __importStar(require("@babel/core"));
|
|
42
42
|
var generator_1 = __importDefault(require("@babel/generator"));
|
|
43
|
-
var
|
|
44
|
-
var method_literal_prefix_1 = require("../../constants/method-literal-prefix");
|
|
43
|
+
var outdated_prefixes_1 = require("../constants/outdated-prefixes");
|
|
45
44
|
var traverse_1 = __importDefault(require("traverse"));
|
|
46
45
|
var babel_transform_1 = require("../../helpers/babel-transform");
|
|
47
46
|
var capitalize_1 = require("../../helpers/capitalize");
|
|
48
47
|
var is_mitosis_node_1 = require("../../helpers/is-mitosis-node");
|
|
49
|
-
var
|
|
48
|
+
var replace_identifiers_1 = require("../../helpers/replace-identifiers");
|
|
50
49
|
var helpers_1 = require("./helpers");
|
|
51
50
|
var function_1 = require("fp-ts/lib/function");
|
|
52
|
-
var state_1 = require("
|
|
51
|
+
var state_1 = require("../helpers/state");
|
|
53
52
|
var types = babel.types;
|
|
54
|
-
function
|
|
53
|
+
function mapStateIdentifiersInExpression(expression, stateProperties) {
|
|
55
54
|
var setExpressions = stateProperties.map(function (propertyName) { return "set".concat((0, capitalize_1.capitalize)(propertyName)); });
|
|
56
55
|
return (0, babel_transform_1.babelTransformExpression)(
|
|
57
56
|
// foo -> state.foo
|
|
58
|
-
(0,
|
|
57
|
+
(0, replace_identifiers_1.replaceIdentifiers)({ code: expression, from: stateProperties, to: function (name) { return "state.".concat(name); } }), {
|
|
59
58
|
CallExpression: function (path) {
|
|
60
59
|
if (types.isIdentifier(path.node.callee)) {
|
|
61
60
|
if (setExpressions.includes(path.node.callee.name)) {
|
|
@@ -74,15 +73,13 @@ function mapReactIdentifiersInExpression(expression, stateProperties) {
|
|
|
74
73
|
* text -> state.text
|
|
75
74
|
* setText(...) -> state.text = ...
|
|
76
75
|
*/
|
|
77
|
-
function
|
|
78
|
-
var _a;
|
|
76
|
+
function mapStateIdentifiers(json) {
|
|
79
77
|
var stateProperties = Object.keys(json.state);
|
|
80
78
|
for (var key in json.state) {
|
|
81
|
-
var
|
|
82
|
-
if (typeof
|
|
79
|
+
var stateVal = json.state[key];
|
|
80
|
+
if (typeof (stateVal === null || stateVal === void 0 ? void 0 : stateVal.code) === 'string' && stateVal.type === 'function') {
|
|
83
81
|
json.state[key] = {
|
|
84
|
-
code:
|
|
85
|
-
mapReactIdentifiersInExpression(value.replace(function_literal_prefix_1.functionLiteralPrefix, ''), stateProperties),
|
|
82
|
+
code: mapStateIdentifiersInExpression(stateVal.code, stateProperties),
|
|
86
83
|
type: 'function',
|
|
87
84
|
};
|
|
88
85
|
}
|
|
@@ -94,7 +91,7 @@ function mapReactIdentifiers(json) {
|
|
|
94
91
|
var value = item.bindings[key];
|
|
95
92
|
if (value) {
|
|
96
93
|
item.bindings[key] = {
|
|
97
|
-
code:
|
|
94
|
+
code: mapStateIdentifiersInExpression(value.code, stateProperties),
|
|
98
95
|
};
|
|
99
96
|
if ((_a = value.arguments) === null || _a === void 0 ? void 0 : _a.length) {
|
|
100
97
|
item.bindings[key].arguments = value.arguments;
|
|
@@ -126,22 +123,18 @@ function mapReactIdentifiers(json) {
|
|
|
126
123
|
}
|
|
127
124
|
});
|
|
128
125
|
}
|
|
129
|
-
exports.
|
|
130
|
-
var createFunctionStringLiteral = function (node) {
|
|
131
|
-
return types.stringLiteral("".concat(function_literal_prefix_1.functionLiteralPrefix).concat((0, generator_1.default)(node).code));
|
|
132
|
-
};
|
|
126
|
+
exports.mapStateIdentifiers = mapStateIdentifiers;
|
|
133
127
|
var createFunctionStringLiteralObjectProperty = function (key, node) {
|
|
134
|
-
return types.objectProperty(key,
|
|
128
|
+
return types.objectProperty(key, types.stringLiteral("".concat(outdated_prefixes_1.__DO_NOT_USE_FUNCTION_LITERAL_PREFIX).concat((0, generator_1.default)(node).code)));
|
|
135
129
|
};
|
|
136
|
-
exports.createFunctionStringLiteralObjectProperty = createFunctionStringLiteralObjectProperty;
|
|
137
130
|
var parseStateValue = function (item) {
|
|
138
131
|
if (types.isObjectProperty(item)) {
|
|
139
132
|
if (types.isFunctionExpression(item.value) || types.isArrowFunctionExpression(item.value)) {
|
|
140
|
-
return
|
|
133
|
+
return createFunctionStringLiteralObjectProperty(item.key, item.value);
|
|
141
134
|
}
|
|
142
135
|
}
|
|
143
136
|
if (types.isObjectMethod(item)) {
|
|
144
|
-
return types.objectProperty(item.key, types.stringLiteral("".concat(
|
|
137
|
+
return types.objectProperty(item.key, types.stringLiteral("".concat(outdated_prefixes_1.__DO_NOT_USE_METHOD_LITERAL_PREFIX).concat((0, generator_1.default)(__assign(__assign({}, item), { returnType: null })).code)));
|
|
145
138
|
}
|
|
146
139
|
// Remove typescript types, e.g. from
|
|
147
140
|
// { foo: ('string' as SomeType) }
|
|
@@ -164,11 +164,17 @@ exports.components = {
|
|
|
164
164
|
});
|
|
165
165
|
},
|
|
166
166
|
CustomCode: function (node, context, components) {
|
|
167
|
+
var _a;
|
|
168
|
+
var bindings = {};
|
|
169
|
+
if ((_a = node === null || node === void 0 ? void 0 : node.bindings) === null || _a === void 0 ? void 0 : _a.code) {
|
|
170
|
+
bindings.innerHTML = node.bindings.code;
|
|
171
|
+
}
|
|
167
172
|
return wrapOutput(node, (0, create_mitosis_node_1.createMitosisNode)({
|
|
168
173
|
name: node.properties.builderTag || 'div',
|
|
169
174
|
properties: {
|
|
170
175
|
innerHTML: node.properties.code || '',
|
|
171
176
|
},
|
|
177
|
+
bindings: bindings,
|
|
172
178
|
}), components);
|
|
173
179
|
},
|
|
174
180
|
CoreSection: function (node, context, components) {
|
|
@@ -130,6 +130,9 @@ function convertBuilderElementToMitosisComponent(element) {
|
|
|
130
130
|
name: componentName,
|
|
131
131
|
options: symbolValue.data,
|
|
132
132
|
},
|
|
133
|
+
properties: {
|
|
134
|
+
'builder-content-id': id,
|
|
135
|
+
},
|
|
133
136
|
}),
|
|
134
137
|
];
|
|
135
138
|
var mitosisComponent = __assign(__assign({}, (0, builder_1.builderContentToMitosisComponent)(elContent, {
|
package/dist/src/targets.d.ts
CHANGED
|
@@ -1,30 +1,23 @@
|
|
|
1
|
+
export declare const builder: (options?: import("./generators/builder").ToBuilderOptions) => ({ component }: import(".").TranspilerArgs) => import("@builder.io/sdk").BuilderContent;
|
|
1
2
|
export declare const targets: {
|
|
2
|
-
angular: (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
vue: (vueOptions?: Omit<import("./generators/vue").ToVueOptions, "vueVersion"> | undefined) => import(".").Transpiler;
|
|
23
|
-
vue2: (vueOptions?: Omit<import("./generators/vue").ToVueOptions, "vueVersion"> | undefined) => import(".").Transpiler;
|
|
24
|
-
vue3: (vueOptions?: Omit<import("./generators/vue").ToVueOptions, "vueVersion"> | undefined) => import(".").Transpiler;
|
|
25
|
-
stencil: (options?: import("./generators/stencil").ToStencilOptions) => import(".").Transpiler;
|
|
26
|
-
qwik: (userOptions?: import("./generators/qwik/component-generator").ToQwikOptions) => import(".").Transpiler;
|
|
27
|
-
marko: (userOptions?: import("./generators/marko").ToMarkoOptions) => import(".").Transpiler;
|
|
28
|
-
preact: (reactOptions?: import("./generators/react").ToReactOptions) => import(".").Transpiler;
|
|
29
|
-
lit: (options?: import("./generators/lit").ToLitOptions) => import(".").Transpiler;
|
|
3
|
+
readonly angular: import(".").TranspilerGenerator<import("./generators/angular").ToAngularOptions, string>;
|
|
4
|
+
readonly customElement: import(".").TranspilerGenerator<import("./generators/html").ToHtmlOptions, string>;
|
|
5
|
+
readonly html: import(".").TranspilerGenerator<import("./generators/html").ToHtmlOptions, string>;
|
|
6
|
+
readonly mitosis: import(".").TranspilerGenerator<Partial<import("./generators/mitosis").ToMitosisOptions>, string>;
|
|
7
|
+
readonly liquid: import(".").TranspilerGenerator<import("./generators/liquid").ToLiquidOptions, string>;
|
|
8
|
+
readonly react: import(".").TranspilerGenerator<import("./generators/react").ToReactOptions, string>;
|
|
9
|
+
readonly reactNative: import(".").TranspilerGenerator<import("./generators/react-native").ToReactNativeOptions, string>;
|
|
10
|
+
readonly solid: import(".").TranspilerGenerator<Partial<import("./generators/solid/types").ToSolidOptions>, string>;
|
|
11
|
+
readonly svelte: import(".").TranspilerGenerator<import("./generators/svelte").ToSvelteOptions, string>;
|
|
12
|
+
readonly swift: import(".").TranspilerGenerator<import(".").BaseTranspilerOptions, string>;
|
|
13
|
+
readonly template: import(".").TranspilerGenerator<import("./generators/template").ToTemplateOptions, string>;
|
|
14
|
+
readonly webcomponent: import(".").TranspilerGenerator<import("./generators/html").ToHtmlOptions, string>;
|
|
15
|
+
readonly vue: (vueOptions?: Omit<import("./generators/vue").ToVueOptions, "vueVersion"> | undefined) => import(".").Transpiler<string>;
|
|
16
|
+
readonly vue2: (vueOptions?: Omit<import("./generators/vue").ToVueOptions, "vueVersion"> | undefined) => import(".").Transpiler<string>;
|
|
17
|
+
readonly vue3: (vueOptions?: Omit<import("./generators/vue").ToVueOptions, "vueVersion"> | undefined) => import(".").Transpiler<string>;
|
|
18
|
+
readonly stencil: import(".").TranspilerGenerator<import("./generators/stencil").ToStencilOptions, string>;
|
|
19
|
+
readonly qwik: import(".").TranspilerGenerator<import("./generators/qwik/component-generator").ToQwikOptions, string>;
|
|
20
|
+
readonly marko: import(".").TranspilerGenerator<import("./generators/marko").ToMarkoOptions, string>;
|
|
21
|
+
readonly preact: import(".").TranspilerGenerator<import("./generators/react").ToReactOptions, string>;
|
|
22
|
+
readonly lit: import(".").TranspilerGenerator<import("./generators/lit").ToLitOptions, string>;
|
|
30
23
|
};
|
package/dist/src/targets.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.targets = void 0;
|
|
3
|
+
exports.targets = exports.builder = void 0;
|
|
4
4
|
var angular_1 = require("./generators/angular");
|
|
5
5
|
var builder_1 = require("./generators/builder");
|
|
6
6
|
var html_1 = require("./generators/html");
|
|
@@ -18,9 +18,9 @@ var stencil_1 = require("./generators/stencil");
|
|
|
18
18
|
var qwik_1 = require("./generators/qwik");
|
|
19
19
|
var marko_1 = require("./generators/marko");
|
|
20
20
|
var lit_1 = require("./generators/lit");
|
|
21
|
+
exports.builder = builder_1.componentToBuilder;
|
|
21
22
|
exports.targets = {
|
|
22
23
|
angular: angular_1.componentToAngular,
|
|
23
|
-
builder: builder_1.componentToBuilder,
|
|
24
24
|
customElement: html_1.componentToCustomElement,
|
|
25
25
|
html: html_1.componentToHtml,
|
|
26
26
|
mitosis: mitosis_1.componentToMitosis,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { MitosisComponent } from './mitosis-component';
|
|
1
2
|
export declare type Format = 'esm' | 'cjs';
|
|
2
3
|
export declare type Language = 'js' | 'ts';
|
|
3
4
|
interface TranspilerOptions {
|
|
4
5
|
format?: Format;
|
|
5
|
-
languages?: Language[];
|
|
6
6
|
}
|
|
7
7
|
declare type Targets = typeof import('../targets').targets;
|
|
8
8
|
export declare type Target = keyof Targets;
|
|
@@ -50,5 +50,15 @@ export declare type MitosisConfig = {
|
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
52
|
options: Partial<GeneratorOptions>;
|
|
53
|
+
/**
|
|
54
|
+
* Configure the extension of the files you want to compile
|
|
55
|
+
* Default value: 'lite.tsx'
|
|
56
|
+
*/
|
|
57
|
+
extension?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Configure a custom parser function which takes a string and returns MitosisJSON
|
|
60
|
+
* Defaults to the JSXParser of this project (src/parsers/jsx)
|
|
61
|
+
*/
|
|
62
|
+
parser?: (code: string) => MitosisComponent;
|
|
53
63
|
};
|
|
54
64
|
export {};
|
|
@@ -34,7 +34,7 @@ export interface ContextGetInfo {
|
|
|
34
34
|
}
|
|
35
35
|
export interface ContextSetInfo {
|
|
36
36
|
name: string;
|
|
37
|
-
value?:
|
|
37
|
+
value?: MitosisState;
|
|
38
38
|
ref?: string;
|
|
39
39
|
}
|
|
40
40
|
export declare type ContextGet = {
|
|
@@ -58,12 +58,18 @@ export declare type MitosisExport = {
|
|
|
58
58
|
isFunction?: boolean;
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
|
-
declare type StateValueType = 'function' | 'getter' | 'method' | 'property';
|
|
61
|
+
export declare type StateValueType = 'function' | 'getter' | 'method' | 'property';
|
|
62
62
|
export declare type StateCode = _JSON;
|
|
63
|
-
|
|
63
|
+
declare type CodeValue = {
|
|
64
|
+
code: string;
|
|
65
|
+
type: Exclude<StateValueType, 'property'>;
|
|
66
|
+
};
|
|
67
|
+
export declare const checkIsCodeValue: (value: unknown) => value is CodeValue;
|
|
68
|
+
export declare type StateValue = CodeValue | {
|
|
64
69
|
code: StateCode;
|
|
65
|
-
type: StateValueType
|
|
66
|
-
}
|
|
70
|
+
type: Extract<StateValueType, 'property'>;
|
|
71
|
+
};
|
|
72
|
+
export declare type MitosisState = Dictionary<StateValue | undefined>;
|
|
67
73
|
export declare type MitosisComponent = {
|
|
68
74
|
'@type': '@builder.io/mitosis/component';
|
|
69
75
|
name: string;
|
|
@@ -73,7 +79,7 @@ export declare type MitosisComponent = {
|
|
|
73
79
|
useMetadata?: JSONObject;
|
|
74
80
|
};
|
|
75
81
|
inputs: MitosisComponentInput[];
|
|
76
|
-
state:
|
|
82
|
+
state: MitosisState;
|
|
77
83
|
context: {
|
|
78
84
|
get: ContextGet;
|
|
79
85
|
set: ContextSet;
|
|
@@ -1,2 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkIsCodeValue = void 0;
|
|
4
|
+
var checkIsCodeValue = function (value) {
|
|
5
|
+
return typeof value === 'object' &&
|
|
6
|
+
value &&
|
|
7
|
+
Object.keys(value).length === 2 &&
|
|
8
|
+
'type' in value &&
|
|
9
|
+
'code' in value
|
|
10
|
+
? ['function', 'getter', 'method'].includes(value.type)
|
|
11
|
+
: false;
|
|
12
|
+
};
|
|
13
|
+
exports.checkIsCodeValue = checkIsCodeValue;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { JSONObject } from './json';
|
|
2
|
-
export declare type
|
|
2
|
+
export declare type BaseNode = {
|
|
3
3
|
'@type': '@builder.io/mitosis/node';
|
|
4
|
-
name: string;
|
|
5
4
|
meta: JSONObject;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
5
|
+
name: string;
|
|
6
|
+
scope: {};
|
|
9
7
|
/**
|
|
10
8
|
* Key-value store of string values for DOM attributes.
|
|
11
9
|
* ```js
|
|
@@ -38,3 +36,14 @@ export declare type MitosisNode = {
|
|
|
38
36
|
};
|
|
39
37
|
children: MitosisNode[];
|
|
40
38
|
};
|
|
39
|
+
export declare type SpecialNodesNames = 'For' | 'Fragment' | 'Show' | 'Slot';
|
|
40
|
+
export declare type ForNode = BaseNode & {
|
|
41
|
+
name: 'For';
|
|
42
|
+
scope: {
|
|
43
|
+
forName: string | undefined;
|
|
44
|
+
indexName: string | undefined;
|
|
45
|
+
collectionName: string | undefined;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export declare type MitosisNode = BaseNode | ForNode;
|
|
49
|
+
export declare const checkIsForNode: (node: MitosisNode) => node is ForNode;
|
|
@@ -4,11 +4,16 @@ export interface TranspilerArgs {
|
|
|
4
4
|
path?: string;
|
|
5
5
|
component: MitosisComponent;
|
|
6
6
|
}
|
|
7
|
-
export declare type Transpiler = (args: TranspilerArgs) =>
|
|
7
|
+
export declare type Transpiler<R = string> = (args: TranspilerArgs) => R;
|
|
8
|
+
/**
|
|
9
|
+
* This type guarantees that all code generators receive the same base options
|
|
10
|
+
*/
|
|
11
|
+
export declare type TranspilerGenerator<X extends BaseTranspilerOptions, Y = string> = (args?: X) => Transpiler<Y>;
|
|
8
12
|
export interface BaseTranspilerOptions {
|
|
9
13
|
experimental?: {
|
|
10
14
|
[key: string]: any;
|
|
11
15
|
};
|
|
12
16
|
prettier?: boolean;
|
|
13
17
|
plugins?: Plugin[];
|
|
18
|
+
typescript?: boolean;
|
|
14
19
|
}
|