@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,75 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
-
if (ar || !(i in from)) {
|
|
5
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
6
|
exports.generateOptionsApiScript = void 0;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
7
|
+
const get_components_used_1 = require("../../helpers/get-components-used");
|
|
8
|
+
const get_custom_imports_1 = require("../../helpers/get-custom-imports");
|
|
9
|
+
const get_state_object_string_1 = require("../../helpers/get-state-object-string");
|
|
10
|
+
const nullable_1 = require("../../helpers/nullable");
|
|
11
|
+
const render_imports_1 = require("../../helpers/render-imports");
|
|
12
|
+
const json5_1 = __importDefault(require("json5"));
|
|
13
|
+
const lodash_1 = require("lodash");
|
|
14
|
+
const on_mount_1 = require("../helpers/on-mount");
|
|
15
|
+
const helpers_1 = require("./helpers");
|
|
16
|
+
const getContextProvideString = (json, options) => {
|
|
17
|
+
return `{
|
|
18
|
+
${Object.values(json.context.set)
|
|
19
|
+
.map((setVal) => {
|
|
20
|
+
const key = (0, helpers_1.getContextKey)(setVal);
|
|
21
|
+
return `[${key}]: ${(0, helpers_1.getContextValue)(setVal)}`;
|
|
30
22
|
})
|
|
31
|
-
.join(',')
|
|
23
|
+
.join(',')}
|
|
24
|
+
}`;
|
|
32
25
|
};
|
|
33
26
|
function getContextInjectString(component, options) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
for (
|
|
37
|
-
|
|
38
|
-
str +=
|
|
27
|
+
let str = '{';
|
|
28
|
+
const contextGetters = component.context.get;
|
|
29
|
+
for (const key in contextGetters) {
|
|
30
|
+
const context = contextGetters[key];
|
|
31
|
+
str += `
|
|
32
|
+
${key}: ${(0, helpers_1.encodeQuotes)((0, helpers_1.getContextKey)(context))},
|
|
33
|
+
`;
|
|
39
34
|
}
|
|
40
35
|
str += '}';
|
|
41
36
|
return str;
|
|
42
37
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
};
|
|
38
|
+
const generateComponentImport = (options) => (componentName) => {
|
|
39
|
+
if (options.asyncComponentImports) {
|
|
40
|
+
return `'${componentName}': defineAsyncComponent(${componentName})`;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return `'${componentName}': ${componentName}`;
|
|
44
|
+
}
|
|
52
45
|
};
|
|
53
|
-
|
|
46
|
+
const generateComponents = (componentsUsed, options) => {
|
|
54
47
|
if (componentsUsed.length === 0) {
|
|
55
48
|
return '';
|
|
56
49
|
}
|
|
57
50
|
else {
|
|
58
|
-
return
|
|
51
|
+
return `components: { ${componentsUsed.map(generateComponentImport(options)).join(',')} },`;
|
|
59
52
|
}
|
|
60
53
|
};
|
|
61
|
-
|
|
62
|
-
var dataString = _a.dataString, newContent = _a.newContent;
|
|
63
|
-
return dataString.replace(/}$/, "".concat(newContent, "}"));
|
|
64
|
-
};
|
|
54
|
+
const appendToDataString = ({ dataString, newContent, }) => dataString.replace(/}$/, `${newContent}}`);
|
|
65
55
|
function generateOptionsApiScript(component, options, path, template, props, onUpdateWithDeps, onUpdateWithoutDeps) {
|
|
66
56
|
var _a, _b, _c;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
57
|
+
const { exports: localExports } = component;
|
|
58
|
+
const localVarAsData = [];
|
|
59
|
+
const localVarAsFunc = [];
|
|
60
|
+
const isTs = options.typescript;
|
|
71
61
|
if (localExports) {
|
|
72
|
-
Object.keys(localExports).forEach(
|
|
62
|
+
Object.keys(localExports).forEach((key) => {
|
|
73
63
|
if (localExports[key].usedInLocal) {
|
|
74
64
|
if (localExports[key].isFunction) {
|
|
75
65
|
localVarAsFunc.push(key);
|
|
@@ -80,102 +70,141 @@ function generateOptionsApiScript(component, options, path, template, props, onU
|
|
|
80
70
|
}
|
|
81
71
|
});
|
|
82
72
|
}
|
|
83
|
-
|
|
73
|
+
let dataString = (0, get_state_object_string_1.getStateObjectStringFromComponent)(component, {
|
|
84
74
|
data: true,
|
|
85
75
|
functions: false,
|
|
86
76
|
getters: false,
|
|
87
77
|
});
|
|
88
78
|
// Append refs to data as { foo, bar, etc }
|
|
89
79
|
dataString = appendToDataString({
|
|
90
|
-
dataString
|
|
80
|
+
dataString,
|
|
91
81
|
newContent: (0, get_custom_imports_1.getCustomImports)(component).join(','),
|
|
92
82
|
});
|
|
93
83
|
if (localVarAsData.length) {
|
|
94
|
-
dataString = appendToDataString({ dataString
|
|
84
|
+
dataString = appendToDataString({ dataString, newContent: localVarAsData.join(',') });
|
|
95
85
|
}
|
|
96
|
-
|
|
86
|
+
const getterString = (0, get_state_object_string_1.getStateObjectStringFromComponent)(component, {
|
|
97
87
|
data: false,
|
|
98
88
|
getters: true,
|
|
99
89
|
functions: false,
|
|
100
90
|
});
|
|
101
|
-
|
|
91
|
+
let functionsString = (0, get_state_object_string_1.getStateObjectStringFromComponent)(component, {
|
|
102
92
|
data: false,
|
|
103
93
|
getters: false,
|
|
104
94
|
functions: true,
|
|
105
95
|
});
|
|
106
|
-
|
|
96
|
+
const includeClassMapHelper = template.includes('_classStringToObject');
|
|
107
97
|
if (includeClassMapHelper) {
|
|
108
|
-
functionsString = functionsString.replace(/}\s*$/,
|
|
98
|
+
functionsString = functionsString.replace(/}\s*$/, `_classStringToObject(str${isTs ? ': string' : ''}) {
|
|
99
|
+
const obj${isTs ? ': Record<string, boolean>' : ''} = {};
|
|
100
|
+
if (typeof str !== 'string') { return obj }
|
|
101
|
+
const classNames = str.trim().split(/\\s+/);
|
|
102
|
+
for (const name of classNames) {
|
|
103
|
+
obj[name] = true;
|
|
104
|
+
}
|
|
105
|
+
return obj;
|
|
106
|
+
} }`);
|
|
109
107
|
}
|
|
110
108
|
if (localVarAsFunc.length) {
|
|
111
|
-
functionsString = functionsString.replace(/}\s*$/,
|
|
109
|
+
functionsString = functionsString.replace(/}\s*$/, `${localVarAsFunc.join(',')}}`);
|
|
112
110
|
}
|
|
113
111
|
// Component references to include in `component: { YourComponent, ... }
|
|
114
|
-
|
|
115
|
-
.filter(
|
|
112
|
+
const componentsUsedInTemplate = Array.from((0, get_components_used_1.getComponentsUsed)(component))
|
|
113
|
+
.filter((name) => name.length && !name.includes('.') && name[0].toUpperCase() === name[0])
|
|
116
114
|
// Strip out components that compile away
|
|
117
|
-
.filter(
|
|
115
|
+
.filter((name) => !['For', 'Show', 'Fragment', 'Slot', component.name].includes(name));
|
|
118
116
|
// get default imports from component files
|
|
119
|
-
|
|
117
|
+
const importedComponents = component.imports
|
|
120
118
|
.filter(render_imports_1.checkIsComponentImport)
|
|
121
|
-
.map(
|
|
122
|
-
var _ = _a[0], value = _a[1];
|
|
123
|
-
return value === 'default';
|
|
124
|
-
})) === null || _a === void 0 ? void 0 : _a[0]; })
|
|
119
|
+
.map((imp) => { var _a; return (_a = Object.entries(imp.imports).find(([_, value]) => value === 'default')) === null || _a === void 0 ? void 0 : _a[0]; })
|
|
125
120
|
.filter(nullable_1.checkIsDefined);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
var str = 'props: ';
|
|
121
|
+
const componentsUsed = (0, lodash_1.uniq)([...componentsUsedInTemplate, ...importedComponents]);
|
|
122
|
+
const getPropDefinition = ({ component, props, }) => {
|
|
123
|
+
const propsDefinition = Array.from(props).filter((prop) => prop !== 'children' && prop !== 'class');
|
|
124
|
+
let str = 'props: ';
|
|
131
125
|
if (component.defaultProps) {
|
|
132
|
-
|
|
133
|
-
.map(
|
|
126
|
+
const defalutPropsString = propsDefinition
|
|
127
|
+
.map((prop) => {
|
|
134
128
|
var _a;
|
|
135
|
-
|
|
129
|
+
const value = component.defaultProps.hasOwnProperty(prop)
|
|
136
130
|
? (_a = component.defaultProps[prop]) === null || _a === void 0 ? void 0 : _a.code
|
|
137
131
|
: 'undefined';
|
|
138
|
-
return
|
|
132
|
+
return `${prop}: { default: ${value} }`;
|
|
139
133
|
})
|
|
140
134
|
.join(',');
|
|
141
|
-
str +=
|
|
135
|
+
str += `{${defalutPropsString}}`;
|
|
142
136
|
}
|
|
143
137
|
else {
|
|
144
|
-
str +=
|
|
138
|
+
str += `${json5_1.default.stringify(propsDefinition)}`;
|
|
145
139
|
}
|
|
146
|
-
return
|
|
140
|
+
return `${str},`;
|
|
147
141
|
};
|
|
148
|
-
return
|
|
142
|
+
return `
|
|
143
|
+
export default ${options.defineComponent ? 'defineComponent(' : ''} {
|
|
144
|
+
${!component.name
|
|
149
145
|
? ''
|
|
150
|
-
:
|
|
146
|
+
: `name: '${path && ((_a = options.namePrefix) === null || _a === void 0 ? void 0 : _a.call(options, path)) ? ((_b = options.namePrefix) === null || _b === void 0 ? void 0 : _b.call(options, path)) + '-' : ''}${(0, lodash_1.kebabCase)(component.name)}',`}
|
|
147
|
+
${generateComponents(componentsUsed, options)}
|
|
148
|
+
${props.length ? getPropDefinition({ component, props }) : ''}
|
|
149
|
+
${dataString.length < 4
|
|
151
150
|
? ''
|
|
152
|
-
:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
?
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
151
|
+
: `
|
|
152
|
+
data() {
|
|
153
|
+
return ${dataString}
|
|
154
|
+
},
|
|
155
|
+
`}
|
|
156
|
+
|
|
157
|
+
${(0, lodash_1.size)(component.context.set)
|
|
158
|
+
? `provide() {
|
|
159
|
+
const _this = this;
|
|
160
|
+
return ${getContextProvideString(component, options)}
|
|
161
|
+
},`
|
|
162
|
+
: ''}
|
|
163
|
+
${(0, lodash_1.size)(component.context.get)
|
|
164
|
+
? `inject: ${getContextInjectString(component, options)},`
|
|
165
|
+
: ''}
|
|
166
|
+
${((_c = component.hooks.onInit) === null || _c === void 0 ? void 0 : _c.code)
|
|
167
|
+
? `created() {
|
|
168
|
+
${component.hooks.onInit.code}
|
|
169
|
+
},`
|
|
170
|
+
: ''}
|
|
171
|
+
${component.hooks.onMount.length
|
|
172
|
+
? `mounted() {
|
|
173
|
+
${(0, on_mount_1.stringifySingleScopeOnMount)(component)}
|
|
174
|
+
},`
|
|
175
|
+
: ''}
|
|
176
|
+
${onUpdateWithoutDeps.length
|
|
177
|
+
? `updated() {
|
|
178
|
+
${onUpdateWithoutDeps.map((hook) => hook.code).join('\n')}
|
|
179
|
+
},`
|
|
180
|
+
: ''}
|
|
181
|
+
${onUpdateWithDeps.length
|
|
182
|
+
? `watch: {
|
|
183
|
+
${onUpdateWithDeps
|
|
184
|
+
.map((hook, index) => `${(0, helpers_1.getOnUpdateHookName)(index)}: { handler() { ${hook.code} }, immediate: true }`)
|
|
185
|
+
.join(',')}
|
|
186
|
+
},`
|
|
187
|
+
: ''}
|
|
188
|
+
${component.hooks.onUnMount
|
|
189
|
+
? `unmounted() {
|
|
190
|
+
${component.hooks.onUnMount.code}
|
|
191
|
+
},`
|
|
192
|
+
: ''}
|
|
193
|
+
|
|
194
|
+
${getterString.length < 4
|
|
171
195
|
? ''
|
|
172
|
-
:
|
|
196
|
+
: `
|
|
197
|
+
computed: ${getterString},
|
|
198
|
+
`}
|
|
199
|
+
${functionsString.length < 4
|
|
173
200
|
? ''
|
|
174
|
-
:
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
.join(',')
|
|
201
|
+
: `
|
|
202
|
+
methods: ${functionsString},
|
|
203
|
+
`}
|
|
204
|
+
${Object.entries(component.meta.vueConfig || {})
|
|
205
|
+
.map(([k, v]) => `${k}: ${v}`)
|
|
206
|
+
.join(',')}
|
|
207
|
+
}
|
|
208
|
+
${options.defineComponent ? ')' : ''}`;
|
|
180
209
|
}
|
|
181
210
|
exports.generateOptionsApiScript = generateOptionsApiScript;
|