@builder.io/mitosis 0.4.0 → 0.4.2
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/media-sizes.js +4 -5
- package/dist/src/generators/alpine/generate.js +114 -132
- package/dist/src/generators/alpine/render-mount-hook.js +8 -5
- package/dist/src/generators/alpine/render-update-hooks.js +13 -13
- package/dist/src/generators/angular/helpers.js +19 -9
- package/dist/src/generators/angular/index.js +599 -584
- package/dist/src/generators/builder.js +200 -165
- package/dist/src/generators/context/angular.js +32 -26
- package/dist/src/generators/context/helpers/context-with-symbol-key.js +25 -21
- package/dist/src/generators/context/qwik.js +21 -21
- package/dist/src/generators/context/react.js +22 -22
- package/dist/src/generators/context/rsc.js +20 -22
- package/dist/src/generators/context/solid.js +22 -22
- package/dist/src/generators/context/svelte.js +33 -28
- package/dist/src/generators/context/vue.js +1 -1
- package/dist/src/generators/helpers/context.js +6 -13
- package/dist/src/generators/helpers/functions.js +8 -8
- package/dist/src/generators/helpers/on-mount.js +9 -5
- package/dist/src/generators/helpers/rsc.js +7 -9
- package/dist/src/generators/html.js +995 -534
- package/dist/src/generators/liquid.js +81 -79
- package/dist/src/generators/lit/collect-class-string.js +10 -12
- package/dist/src/generators/lit/generate.js +204 -159
- package/dist/src/generators/marko/generate.js +193 -183
- package/dist/src/generators/minify.js +5 -9
- package/dist/src/generators/mitosis.js +135 -134
- package/dist/src/generators/qwik/component-generator.js +159 -154
- package/dist/src/generators/qwik/component.js +51 -81
- package/dist/src/generators/qwik/directives.js +68 -84
- package/dist/src/generators/qwik/helpers/add-prevent-default.js +6 -7
- package/dist/src/generators/qwik/helpers/convert-method-to-function.js +38 -38
- package/dist/src/generators/qwik/helpers/handlers.js +16 -25
- package/dist/src/generators/qwik/helpers/stable-inject.js +7 -8
- package/dist/src/generators/qwik/helpers/stable-serialize.js +7 -8
- package/dist/src/generators/qwik/helpers/state.js +36 -43
- package/dist/src/generators/qwik/helpers/styles.js +19 -40
- package/dist/src/generators/qwik/jsx.js +63 -75
- package/dist/src/generators/qwik/src-generator.js +134 -167
- package/dist/src/generators/react/blocks.js +122 -127
- package/dist/src/generators/react/generator.js +314 -259
- package/dist/src/generators/react/helpers.js +23 -28
- package/dist/src/generators/react/state.js +34 -51
- package/dist/src/generators/react-native/index.js +72 -84
- package/dist/src/generators/react-native/sanitize-react-native-block-styles.js +14 -26
- package/dist/src/generators/rsc.js +30 -36
- package/dist/src/generators/solid/blocks.js +46 -43
- package/dist/src/generators/solid/helpers/styles.js +11 -11
- package/dist/src/generators/solid/index.js +199 -190
- package/dist/src/generators/solid/state/helpers.js +76 -90
- package/dist/src/generators/solid/state/signals.js +30 -37
- package/dist/src/generators/solid/state/state.js +35 -48
- package/dist/src/generators/solid/state/store.js +40 -46
- package/dist/src/generators/stencil/collect-class-string.js +10 -12
- package/dist/src/generators/stencil/generate.js +158 -145
- package/dist/src/generators/svelte/blocks.js +146 -144
- package/dist/src/generators/svelte/helpers.js +10 -17
- package/dist/src/generators/svelte/svelte.js +321 -287
- package/dist/src/generators/swift-ui.js +162 -101
- package/dist/src/generators/taro.js +32 -36
- package/dist/src/generators/template.js +71 -74
- package/dist/src/generators/vue/blocks.js +116 -107
- package/dist/src/generators/vue/compositionApi.js +67 -50
- package/dist/src/generators/vue/helpers.js +71 -96
- package/dist/src/generators/vue/optionsApi.js +134 -105
- package/dist/src/generators/vue/vue.js +210 -207
- package/dist/src/helpers/babel-transform.js +40 -63
- package/dist/src/helpers/bindings.js +4 -12
- package/dist/src/helpers/camel-case.js +4 -5
- package/dist/src/helpers/capitalize.js +1 -1
- package/dist/src/helpers/component-file-extensions.js +23 -35
- package/dist/src/helpers/create-mitosis-component.js +22 -26
- package/dist/src/helpers/create-mitosis-context.js +5 -12
- package/dist/src/helpers/create-mitosis-node.js +10 -12
- package/dist/src/helpers/dash-case.js +2 -2
- package/dist/src/helpers/dedent.js +18 -22
- package/dist/src/helpers/event-handlers.js +1 -1
- package/dist/src/helpers/fast-clone.js +1 -1
- package/dist/src/helpers/filter-empty-text-nodes.js +2 -2
- package/dist/src/helpers/generic-format.js +7 -8
- package/dist/src/helpers/get-bindings.js +4 -4
- package/dist/src/helpers/get-components-used.js +3 -3
- package/dist/src/helpers/get-components.js +4 -4
- package/dist/src/helpers/get-custom-imports.js +10 -12
- package/dist/src/helpers/get-prop-functions.js +7 -8
- package/dist/src/helpers/get-props-ref.js +8 -8
- package/dist/src/helpers/get-props.js +12 -13
- package/dist/src/helpers/get-refs.js +4 -4
- package/dist/src/helpers/get-state-object-string.js +42 -61
- package/dist/src/helpers/get-state-used.js +7 -8
- package/dist/src/helpers/get-styles.js +6 -6
- package/dist/src/helpers/getters-to-functions.js +8 -12
- package/dist/src/helpers/handle-missing-state.js +3 -3
- package/dist/src/helpers/has-bindings-text.js +6 -6
- package/dist/src/helpers/has-component.js +4 -4
- package/dist/src/helpers/has-props.js +3 -3
- package/dist/src/helpers/has-stateful-dom.js +4 -4
- package/dist/src/helpers/has.js +3 -3
- package/dist/src/helpers/indent.js +2 -3
- package/dist/src/helpers/is-children.js +4 -5
- package/dist/src/helpers/is-component.js +1 -1
- package/dist/src/helpers/is-html-attribute.js +2 -11
- package/dist/src/helpers/is-mitosis-node.js +1 -1
- package/dist/src/helpers/is-root-text-node.js +1 -1
- package/dist/src/helpers/is-upper-case.js +1 -1
- package/dist/src/helpers/is-valid-attribute-name.js +1 -1
- package/dist/src/helpers/json.js +2 -2
- package/dist/src/helpers/map-refs.js +29 -40
- package/dist/src/helpers/merge-options.js +20 -31
- package/dist/src/helpers/mitosis-imports.js +5 -6
- package/dist/src/helpers/nodes/for.js +2 -3
- package/dist/src/helpers/nullable.js +1 -3
- package/dist/src/helpers/on-event.js +32 -36
- package/dist/src/helpers/output.js +4 -5
- package/dist/src/helpers/parse-node.js +13 -5
- package/dist/src/helpers/parsers.js +10 -14
- package/dist/src/helpers/patterns.js +6 -8
- package/dist/src/helpers/plugins/process-code/index.js +114 -120
- package/dist/src/helpers/plugins/process-signals.js +114 -125
- package/dist/src/helpers/plugins/process-target-blocks.js +18 -20
- package/dist/src/helpers/process-http-requests.js +8 -4
- package/dist/src/helpers/remove-surrounding-block.js +2 -2
- package/dist/src/helpers/render-imports.js +99 -111
- package/dist/src/helpers/replace-identifiers.js +40 -49
- package/dist/src/helpers/replace-new-lines-in-strings.js +3 -3
- package/dist/src/helpers/signals/signals.js +27 -35
- package/dist/src/helpers/slots.js +11 -20
- package/dist/src/helpers/state.js +1 -3
- package/dist/src/helpers/strip-meta-properties.js +6 -6
- package/dist/src/helpers/strip-state-and-props-refs.js +21 -32
- package/dist/src/helpers/styles/collect-css.js +39 -44
- package/dist/src/helpers/styles/collect-styled-components.js +30 -28
- package/dist/src/helpers/styles/helpers.js +23 -29
- package/dist/src/helpers/trace-reference-to-module-path.js +3 -4
- package/dist/src/helpers/transform-state-setters.js +16 -19
- package/dist/src/helpers/traverse-nodes.js +2 -2
- package/dist/src/helpers/try-prettier-format.js +3 -3
- package/dist/src/helpers/typescript-project.js +25 -25
- package/dist/src/helpers/typescript.js +1 -3
- package/dist/src/modules/plugins.js +20 -28
- package/dist/src/parsers/angular.js +49 -57
- package/dist/src/parsers/builder/builder.js +448 -343
- package/dist/src/parsers/builder/helpers.js +10 -10
- package/dist/src/parsers/context.js +15 -17
- package/dist/src/parsers/jsx/ast.js +11 -11
- package/dist/src/parsers/jsx/component-types.js +22 -32
- package/dist/src/parsers/jsx/context.js +12 -12
- package/dist/src/parsers/jsx/element-parser.js +43 -54
- package/dist/src/parsers/jsx/exports.js +12 -14
- package/dist/src/parsers/jsx/function-parser.js +108 -119
- package/dist/src/parsers/jsx/helpers.js +11 -13
- package/dist/src/parsers/jsx/hooks/helpers.js +14 -16
- package/dist/src/parsers/jsx/hooks/index.js +34 -44
- package/dist/src/parsers/jsx/hooks/use-target.js +27 -27
- package/dist/src/parsers/jsx/imports.js +7 -17
- package/dist/src/parsers/jsx/jsx.js +92 -91
- package/dist/src/parsers/jsx/props-types.js +8 -10
- package/dist/src/parsers/jsx/props.js +15 -23
- package/dist/src/parsers/jsx/signals.js +28 -29
- package/dist/src/parsers/jsx/state.d.ts +2 -4
- package/dist/src/parsers/jsx/state.js +59 -93
- package/dist/src/parsers/svelte/css/index.js +1 -1
- package/dist/src/parsers/svelte/helpers/bindings.js +18 -19
- package/dist/src/parsers/svelte/helpers/children.js +5 -6
- package/dist/src/parsers/svelte/helpers/expressions.js +7 -9
- package/dist/src/parsers/svelte/helpers/hooks.js +2 -2
- package/dist/src/parsers/svelte/helpers/post-process.js +49 -70
- package/dist/src/parsers/svelte/helpers/string.js +5 -5
- package/dist/src/parsers/svelte/html/actions.js +17 -10
- package/dist/src/parsers/svelte/html/each.js +11 -16
- package/dist/src/parsers/svelte/html/element.js +68 -78
- package/dist/src/parsers/svelte/html/fragment.js +3 -3
- package/dist/src/parsers/svelte/html/if-else.js +11 -18
- package/dist/src/parsers/svelte/html/index.js +14 -14
- package/dist/src/parsers/svelte/html/mustache-tag.js +5 -5
- package/dist/src/parsers/svelte/html/slot.js +5 -5
- package/dist/src/parsers/svelte/html/text.js +7 -14
- package/dist/src/parsers/svelte/index.js +23 -72
- package/dist/src/parsers/svelte/instance/context.js +17 -17
- package/dist/src/parsers/svelte/instance/expressions.js +2 -2
- package/dist/src/parsers/svelte/instance/functions.js +35 -30
- package/dist/src/parsers/svelte/instance/hooks.js +4 -5
- package/dist/src/parsers/svelte/instance/imports.js +11 -21
- package/dist/src/parsers/svelte/instance/index.js +22 -22
- package/dist/src/parsers/svelte/instance/properties.js +11 -23
- package/dist/src/parsers/svelte/instance/reactive.js +11 -11
- package/dist/src/parsers/svelte/instance/references.js +13 -13
- package/dist/src/parsers/svelte/instance/statements.js +3 -3
- package/dist/src/parsers/svelte/module/index.js +14 -26
- package/dist/src/parsers/svelte/typescript/index.js +27 -36
- package/dist/src/plugins/compile-away-builder-components.js +223 -156
- package/dist/src/plugins/compile-away-components.js +13 -21
- package/dist/src/plugins/map-styles.js +7 -7
- package/dist/src/symbols/symbol-processor.js +44 -62
- package/dist/src/targets.js +19 -19
- package/dist/src/types/mitosis-node.js +1 -1
- package/package.json +1 -1
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.contextToReact = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
console.error('Format error for file:', str);
|
|
22
|
-
throw err;
|
|
23
|
-
}
|
|
4
|
+
const get_state_object_string_1 = require("../../helpers/get-state-object-string");
|
|
5
|
+
const standalone_1 = require("prettier/standalone");
|
|
6
|
+
const contextToReact = (options = { typescript: false, preact: false }) => ({ context }) => {
|
|
7
|
+
let str = `
|
|
8
|
+
import { createContext } from '${options.preact ? 'preact' : 'react'}';
|
|
9
|
+
|
|
10
|
+
export default createContext${options.typescript ? '<any>' : ''}(${(0, get_state_object_string_1.stringifyContextValue)(context.value)})
|
|
11
|
+
`;
|
|
12
|
+
if (options.format !== false) {
|
|
13
|
+
try {
|
|
14
|
+
str = (0, standalone_1.format)(str, {
|
|
15
|
+
parser: 'typescript',
|
|
16
|
+
plugins: [
|
|
17
|
+
require('prettier/parser-typescript'), // To support running in browsers
|
|
18
|
+
],
|
|
19
|
+
});
|
|
24
20
|
}
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
catch (err) {
|
|
22
|
+
console.error('Format error for file:', str);
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return str;
|
|
27
27
|
};
|
|
28
28
|
exports.contextToReact = contextToReact;
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.contextToRsc = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const get_state_object_string_1 = require("../../helpers/get-state-object-string");
|
|
5
|
+
const standalone_1 = require("prettier/standalone");
|
|
6
6
|
/**
|
|
7
7
|
* React Server Components currently do not support context, so we use
|
|
8
8
|
* plain objects and prop drilling instead.
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
console.error('Format error for file:', str);
|
|
26
|
-
throw err;
|
|
27
|
-
}
|
|
10
|
+
const contextToRsc = (options = {}) => ({ context }) => {
|
|
11
|
+
let str = `
|
|
12
|
+
export default ${(0, get_state_object_string_1.stringifyContextValue)(context.value)}
|
|
13
|
+
`;
|
|
14
|
+
if (options.format !== false) {
|
|
15
|
+
try {
|
|
16
|
+
str = (0, standalone_1.format)(str, {
|
|
17
|
+
parser: 'typescript',
|
|
18
|
+
plugins: [
|
|
19
|
+
require('prettier/parser-typescript'), // To support running in browsers
|
|
20
|
+
],
|
|
21
|
+
});
|
|
28
22
|
}
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
catch (err) {
|
|
24
|
+
console.error('Format error for file:', str);
|
|
25
|
+
throw err;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return str;
|
|
31
29
|
};
|
|
32
30
|
exports.contextToRsc = contextToRsc;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.contextToSolid = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
console.error('Format error for file:', str);
|
|
22
|
-
throw err;
|
|
23
|
-
}
|
|
4
|
+
const get_state_object_string_1 = require("../../helpers/get-state-object-string");
|
|
5
|
+
const standalone_1 = require("prettier/standalone");
|
|
6
|
+
const contextToSolid = (options = {}) => ({ context }) => {
|
|
7
|
+
let str = `
|
|
8
|
+
import { createContext } from 'solid-js';
|
|
9
|
+
|
|
10
|
+
export default createContext(${(0, get_state_object_string_1.stringifyContextValue)(context.value)})
|
|
11
|
+
`;
|
|
12
|
+
if (options.format !== false) {
|
|
13
|
+
try {
|
|
14
|
+
str = (0, standalone_1.format)(str, {
|
|
15
|
+
parser: 'typescript',
|
|
16
|
+
plugins: [
|
|
17
|
+
require('prettier/parser-typescript'), // To support running in browsers
|
|
18
|
+
],
|
|
19
|
+
});
|
|
24
20
|
}
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
catch (err) {
|
|
22
|
+
console.error('Format error for file:', str);
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return str;
|
|
27
27
|
};
|
|
28
28
|
exports.contextToSolid = contextToSolid;
|
|
@@ -1,37 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.contextToSvelte = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const get_state_object_string_1 = require("../../helpers/get-state-object-string");
|
|
5
|
+
const standalone_1 = require("prettier/standalone");
|
|
6
6
|
/**
|
|
7
7
|
* TO-DO: support types
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
9
|
+
const contextToSvelte = (options) => ({ context }) => {
|
|
10
|
+
const isReactive = context.type === 'reactive';
|
|
11
|
+
let str = `
|
|
12
|
+
const key = Symbol();
|
|
13
|
+
${isReactive ? 'import {writable} from "svelte/store";' : ''}
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
${context.name}: ${[
|
|
17
|
+
isReactive && 'writable(',
|
|
18
|
+
(0, get_state_object_string_1.stringifyContextValue)(context.value),
|
|
19
|
+
isReactive && ')',
|
|
20
|
+
]
|
|
21
|
+
.filter(Boolean)
|
|
22
|
+
.join('')},
|
|
23
|
+
key
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
if (options.prettier !== false) {
|
|
27
|
+
try {
|
|
28
|
+
str = (0, standalone_1.format)(str, {
|
|
29
|
+
parser: 'typescript',
|
|
30
|
+
plugins: [
|
|
31
|
+
require('prettier/parser-typescript'), // To support running in browsers
|
|
32
|
+
],
|
|
33
|
+
});
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
catch (err) {
|
|
36
|
+
console.error('Format error for file:', str);
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return str;
|
|
36
41
|
};
|
|
37
42
|
exports.contextToSvelte = contextToSvelte;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.contextToVue = void 0;
|
|
4
|
-
|
|
4
|
+
const context_with_symbol_key_1 = require("./helpers/context-with-symbol-key");
|
|
5
5
|
exports.contextToVue = context_with_symbol_key_1.getContextWithSymbolKey;
|
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getContextType = exports.hasGetContext = exports.hasSetContext = exports.hasContext = void 0;
|
|
4
|
-
|
|
5
|
-
return (0, exports.hasSetContext)(component) || (0, exports.hasGetContext)(component);
|
|
6
|
-
};
|
|
4
|
+
const hasContext = (component) => (0, exports.hasSetContext)(component) || (0, exports.hasGetContext)(component);
|
|
7
5
|
exports.hasContext = hasContext;
|
|
8
|
-
|
|
9
|
-
return Object.keys(component.context.set).length > 0;
|
|
10
|
-
};
|
|
6
|
+
const hasSetContext = (component) => Object.keys(component.context.set).length > 0;
|
|
11
7
|
exports.hasSetContext = hasSetContext;
|
|
12
|
-
|
|
13
|
-
return Object.keys(component.context.get).length > 0;
|
|
14
|
-
};
|
|
8
|
+
const hasGetContext = (component) => Object.keys(component.context.get).length > 0;
|
|
15
9
|
exports.hasGetContext = hasGetContext;
|
|
16
|
-
|
|
17
|
-
var
|
|
18
|
-
var component = _a.component, context = _a.context;
|
|
10
|
+
const getContextType = ({ component, context, }) => {
|
|
11
|
+
var _a, _b;
|
|
19
12
|
// TO-DO: remove useMetadata check if no longer needed.
|
|
20
|
-
return ((
|
|
13
|
+
return ((_b = (_a = component.meta.useMetadata) === null || _a === void 0 ? void 0 : _a.contextTypes) === null || _b === void 0 ? void 0 : _b[context.name]) || context.type || 'normal';
|
|
21
14
|
};
|
|
22
15
|
exports.getContextType = getContextType;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FUNCTION_HACK_PLUGIN = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const patterns_1 = require("../../helpers/patterns");
|
|
5
|
+
const FUNCTION_HACK_PLUGIN = () => ({
|
|
6
6
|
json: {
|
|
7
|
-
pre:
|
|
7
|
+
pre: (json) => {
|
|
8
8
|
var _a, _b;
|
|
9
|
-
for (
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (const key in json.state) {
|
|
10
|
+
const value = (_a = json.state[key]) === null || _a === void 0 ? void 0 : _a.code;
|
|
11
|
+
const type = (_b = json.state[key]) === null || _b === void 0 ? void 0 : _b.type;
|
|
12
12
|
if (typeof value === 'string' && type === 'method') {
|
|
13
|
-
|
|
13
|
+
const newValue = (0, patterns_1.prefixWithFunction)(value);
|
|
14
14
|
json.state[key] = {
|
|
15
15
|
code: newValue,
|
|
16
16
|
type: 'method',
|
|
@@ -25,5 +25,5 @@ var FUNCTION_HACK_PLUGIN = function () { return ({
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
|
-
});
|
|
28
|
+
});
|
|
29
29
|
exports.FUNCTION_HACK_PLUGIN = FUNCTION_HACK_PLUGIN;
|
|
@@ -4,17 +4,21 @@ exports.stringifySingleScopeOnMount = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Helper for frameworks where all `onMount()`s must share a single scope.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const stringifySingleScopeOnMount = (json) => {
|
|
8
|
+
const hooks = json.hooks.onMount;
|
|
9
9
|
if (hooks.length === 0)
|
|
10
10
|
return '';
|
|
11
11
|
if (hooks.length === 1) {
|
|
12
12
|
return hooks[0].code;
|
|
13
13
|
}
|
|
14
14
|
return hooks
|
|
15
|
-
.map(
|
|
16
|
-
|
|
17
|
-
return
|
|
15
|
+
.map((hook, i) => {
|
|
16
|
+
const hookFnName = `onMountHook_${i}`;
|
|
17
|
+
return `
|
|
18
|
+
const ${hookFnName} = () => {
|
|
19
|
+
${hook.code}
|
|
20
|
+
}
|
|
21
|
+
${hookFnName}();`;
|
|
18
22
|
})
|
|
19
23
|
.join('');
|
|
20
24
|
};
|
|
@@ -4,12 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.checkIfIsClientComponent = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
var checkIfIsClientComponent = function (json) {
|
|
7
|
+
const is_mitosis_node_1 = require("../../helpers/is-mitosis-node");
|
|
8
|
+
const legacy_1 = __importDefault(require("neotraverse/legacy"));
|
|
9
|
+
const checkIsNodeAMitosisComponent = (node) => node.name[0] === node.name[0].toUpperCase();
|
|
10
|
+
const checkIfIsClientComponent = (json) => {
|
|
13
11
|
var _a, _b;
|
|
14
12
|
if (json.hooks.onMount.length)
|
|
15
13
|
return true;
|
|
@@ -23,12 +21,12 @@ var checkIfIsClientComponent = function (json) {
|
|
|
23
21
|
return true;
|
|
24
22
|
if (Object.keys(json.context.get).length)
|
|
25
23
|
return true;
|
|
26
|
-
if (Object.values(json.state).filter(
|
|
24
|
+
if (Object.values(json.state).filter((s) => (s === null || s === void 0 ? void 0 : s.type) === 'property').length)
|
|
27
25
|
return true;
|
|
28
|
-
|
|
26
|
+
let foundEventListener = false;
|
|
29
27
|
(0, legacy_1.default)(json).forEach(function (node) {
|
|
30
28
|
if ((0, is_mitosis_node_1.isMitosisNode)(node) && !checkIsNodeAMitosisComponent(node)) {
|
|
31
|
-
if (Object.keys(node.bindings).filter(
|
|
29
|
+
if (Object.keys(node.bindings).filter((item) => item.startsWith('on')).length) {
|
|
32
30
|
foundEventListener = true;
|
|
33
31
|
this.stop();
|
|
34
32
|
}
|