@builder.io/mitosis 0.5.23 → 0.5.24
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/generators/angular/helpers.d.ts +6 -0
- package/dist/src/generators/angular/helpers.js +14 -1
- package/dist/src/generators/angular/index.js +21 -18
- package/dist/src/generators/helpers/functions.d.ts +2 -2
- package/dist/src/generators/react/helpers.js +3 -2
- package/dist/src/generators/stencil/plugins/get-code-processor-plugins.d.ts +1 -1
- package/dist/src/helpers/component-file-extensions.js +21 -5
- package/dist/src/helpers/on-event.d.ts +2 -2
- package/dist/src/helpers/plugins/process-code/index.d.ts +2 -2
- package/dist/src/helpers/plugins/process-signals.d.ts +3 -3
- package/dist/src/helpers/plugins/process-target-blocks.d.ts +2 -2
- package/dist/src/modules/plugins.d.ts +6 -6
- package/dist/src/parsers/svelte/helpers/post-process.d.ts +1 -1
- package/dist/src/plugins/compile-away-builder-components.d.ts +2 -2
- package/dist/src/types/config.d.ts +11 -2
- package/dist/src/types/mitosis-component.d.ts +9 -0
- package/dist/src/types/plugins.d.ts +17 -9
- package/dist/src/types/transpiler.d.ts +12 -2
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type MitosisComponent } from '../../types/mitosis-component';
|
|
2
|
+
import { MitosisNode } from '../../types/mitosis-node';
|
|
2
3
|
export declare const HELPER_FUNCTIONS: (isTs?: boolean) => {
|
|
3
4
|
[key: string]: string;
|
|
4
5
|
};
|
|
@@ -33,3 +34,8 @@ export declare const getDefaultProps: ({ defaultProps }: MitosisComponent) => st
|
|
|
33
34
|
* @param json The MitosisComponent.
|
|
34
35
|
*/
|
|
35
36
|
export declare const transformState: (json: MitosisComponent) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if the first child has a "key" attribute - used for "For" elements
|
|
39
|
+
* @param node The node which should be "For"
|
|
40
|
+
*/
|
|
41
|
+
export declare const hasFirstChildKeyAttribute: (node: MitosisNode) => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformState = exports.getDefaultProps = exports.makeReactiveState = exports.addCodeToOnInit = exports.addCodeToOnUpdate = exports.getAppropriateTemplateFunctionKeys = exports.HELPER_FUNCTIONS = void 0;
|
|
3
|
+
exports.hasFirstChildKeyAttribute = exports.transformState = exports.getDefaultProps = exports.makeReactiveState = exports.addCodeToOnInit = exports.addCodeToOnUpdate = exports.getAppropriateTemplateFunctionKeys = exports.HELPER_FUNCTIONS = void 0;
|
|
4
4
|
const strip_state_and_props_refs_1 = require("../../helpers/strip-state-and-props-refs");
|
|
5
5
|
const HELPER_FUNCTIONS = (isTs) => ({
|
|
6
6
|
useObjectWrapper: `useObjectWrapper(...args${isTs ? ': any[]' : ''}) {
|
|
@@ -120,3 +120,16 @@ const transformState = (json) => {
|
|
|
120
120
|
});
|
|
121
121
|
};
|
|
122
122
|
exports.transformState = transformState;
|
|
123
|
+
/**
|
|
124
|
+
* Checks if the first child has a "key" attribute - used for "For" elements
|
|
125
|
+
* @param node The node which should be "For"
|
|
126
|
+
*/
|
|
127
|
+
const hasFirstChildKeyAttribute = (node) => {
|
|
128
|
+
var _a;
|
|
129
|
+
if (!node.children || node.children.length === 0) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
const firstChildBinding = node.children[0].bindings;
|
|
133
|
+
return Boolean(firstChildBinding && ((_a = firstChildBinding.key) === null || _a === void 0 ? void 0 : _a.code));
|
|
134
|
+
};
|
|
135
|
+
exports.hasFirstChildKeyAttribute = hasFirstChildKeyAttribute;
|
|
@@ -269,7 +269,7 @@ const handleNgOutletBindings = (node, options) => {
|
|
|
269
269
|
const blockToAngular = ({ root, json, options = {}, blockOptions = {
|
|
270
270
|
nativeAttributes: [],
|
|
271
271
|
}, }) => {
|
|
272
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q
|
|
272
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
273
273
|
const childComponents = (blockOptions === null || blockOptions === void 0 ? void 0 : blockOptions.childComponents) || [];
|
|
274
274
|
if (mappers[json.name]) {
|
|
275
275
|
return mappers[json.name](root, json, options, blockOptions);
|
|
@@ -296,19 +296,19 @@ const blockToAngular = ({ root, json, options = {}, blockOptions = {
|
|
|
296
296
|
const indexName = json.scope.indexName;
|
|
297
297
|
const forName = json.scope.forName;
|
|
298
298
|
// Check if "key" is present for the first child of the for loop
|
|
299
|
-
if (
|
|
300
|
-
const fnIndex = ((
|
|
299
|
+
if ((0, helpers_2.hasFirstChildKeyAttribute)(json)) {
|
|
300
|
+
const fnIndex = ((_b = root.meta) === null || _b === void 0 ? void 0 : _b._trackByForIndex) || 0;
|
|
301
301
|
const trackByFnName = `trackBy${forName ? forName.charAt(0).toUpperCase() + forName.slice(1) : ''}${fnIndex}`;
|
|
302
302
|
root.meta._trackByForIndex = fnIndex + 1;
|
|
303
|
-
let code = (
|
|
303
|
+
let code = (_c = json.children[0].bindings.key) === null || _c === void 0 ? void 0 : _c.code;
|
|
304
304
|
root.state[trackByFnName] = {
|
|
305
305
|
code: `${trackByFnName}(${indexName !== null && indexName !== void 0 ? indexName : '_'}, ${forName}) { return ${code}; }`,
|
|
306
306
|
type: 'method',
|
|
307
307
|
};
|
|
308
|
-
str += `<ng-container *ngFor="let ${forName !== null && forName !== void 0 ? forName : '_'} of ${(
|
|
308
|
+
str += `<ng-container *ngFor="let ${forName !== null && forName !== void 0 ? forName : '_'} of ${(_d = json.bindings.each) === null || _d === void 0 ? void 0 : _d.code}${indexName ? `; index as ${indexName}` : ''}; trackBy: ${trackByFnName}">`;
|
|
309
309
|
}
|
|
310
310
|
else {
|
|
311
|
-
str += `<ng-container *ngFor="let ${forName !== null && forName !== void 0 ? forName : '_'} of ${(
|
|
311
|
+
str += `<ng-container *ngFor="let ${forName !== null && forName !== void 0 ? forName : '_'} of ${(_e = json.bindings.each) === null || _e === void 0 ? void 0 : _e.code}${indexName ? `; index as ${indexName}` : ''}">`;
|
|
312
312
|
}
|
|
313
313
|
str += json.children
|
|
314
314
|
.map((item) => (0, exports.blockToAngular)({ root, json: item, options, blockOptions }))
|
|
@@ -316,7 +316,7 @@ const blockToAngular = ({ root, json, options = {}, blockOptions = {
|
|
|
316
316
|
str += `</ng-container>`;
|
|
317
317
|
}
|
|
318
318
|
else if (json.name === 'Show') {
|
|
319
|
-
let condition = (
|
|
319
|
+
let condition = (_f = json.bindings.when) === null || _f === void 0 ? void 0 : _f.code;
|
|
320
320
|
if (options.state === 'inline-with-wrappers' && (condition === null || condition === void 0 ? void 0 : condition.includes('typeof'))) {
|
|
321
321
|
let wordAfterTypeof = condition.split('typeof')[1].trim().split(' ')[0];
|
|
322
322
|
condition = condition.replace(`typeof ${wordAfterTypeof}`, `useTypeOf(${wordAfterTypeof})`);
|
|
@@ -327,7 +327,7 @@ const blockToAngular = ({ root, json, options = {}, blockOptions = {
|
|
|
327
327
|
.join('\n');
|
|
328
328
|
str += `</ng-container>`;
|
|
329
329
|
// else condition
|
|
330
|
-
if ((0, is_mitosis_node_1.isMitosisNode)((
|
|
330
|
+
if ((0, is_mitosis_node_1.isMitosisNode)((_g = json.meta) === null || _g === void 0 ? void 0 : _g.else)) {
|
|
331
331
|
str += `<ng-container *ngIf="!(${condition})">`;
|
|
332
332
|
str += (0, exports.blockToAngular)({ root, json: json.meta.else, options, blockOptions });
|
|
333
333
|
str += `</ng-container>`;
|
|
@@ -344,10 +344,10 @@ const blockToAngular = ({ root, json, options = {}, blockOptions = {
|
|
|
344
344
|
code: '{}' + (options.typescript ? ' as any' : ''),
|
|
345
345
|
type: 'property',
|
|
346
346
|
};
|
|
347
|
-
if (!((
|
|
347
|
+
if (!((_h = root.hooks.onInit) === null || _h === void 0 ? void 0 : _h.code.includes(inputsPropsStateName))) {
|
|
348
348
|
(0, helpers_2.addCodeToOnInit)(root, `this.${inputsPropsStateName} = {${allProps}};`);
|
|
349
349
|
}
|
|
350
|
-
if (!((
|
|
350
|
+
if (!((_j = root.hooks.onUpdate) === null || _j === void 0 ? void 0 : _j.map((hook) => hook.code).join('').includes(inputsPropsStateName))) {
|
|
351
351
|
(0, helpers_2.addCodeToOnUpdate)(root, `this.${inputsPropsStateName} = {${allProps}};`);
|
|
352
352
|
}
|
|
353
353
|
allProps = `${inputsPropsStateName}`;
|
|
@@ -371,7 +371,7 @@ const blockToAngular = ({ root, json, options = {}, blockOptions = {
|
|
|
371
371
|
try {
|
|
372
372
|
({ element, classNames, attributes } = (0, parse_selector_1.parse)(`${selector}`));
|
|
373
373
|
}
|
|
374
|
-
catch (
|
|
374
|
+
catch (_r) {
|
|
375
375
|
element = (0, lodash_1.kebabCase)(json.name);
|
|
376
376
|
}
|
|
377
377
|
}
|
|
@@ -406,13 +406,13 @@ const blockToAngular = ({ root, json, options = {}, blockOptions = {
|
|
|
406
406
|
str += ` ${key}="${value}" `;
|
|
407
407
|
}
|
|
408
408
|
for (const key in json.bindings) {
|
|
409
|
-
if (((
|
|
410
|
-
if (((
|
|
409
|
+
if (((_k = json.bindings[key]) === null || _k === void 0 ? void 0 : _k.type) === 'spread' && html_tags_1.VALID_HTML_TAGS.includes(json.name.trim())) {
|
|
410
|
+
if (((_l = json.bindings[key]) === null || _l === void 0 ? void 0 : _l.code) === 'this') {
|
|
411
411
|
// if its an arbitrary { ...props } spread then we skip because Angular needs a named prop to be defined
|
|
412
412
|
continue;
|
|
413
413
|
}
|
|
414
414
|
let refName = '';
|
|
415
|
-
if ((
|
|
415
|
+
if ((_m = json.bindings['spreadRef']) === null || _m === void 0 ? void 0 : _m.code) {
|
|
416
416
|
refName = json.bindings['spreadRef'].code;
|
|
417
417
|
}
|
|
418
418
|
else {
|
|
@@ -427,16 +427,16 @@ const blockToAngular = ({ root, json, options = {}, blockOptions = {
|
|
|
427
427
|
root.meta.onViewInit = (root.meta.onViewInit || { code: '' });
|
|
428
428
|
let spreadCode = '';
|
|
429
429
|
let changesCode = '';
|
|
430
|
-
if ((
|
|
430
|
+
if ((_o = json.bindings[key]) === null || _o === void 0 ? void 0 : _o.code.startsWith('{')) {
|
|
431
431
|
json.meta._spreadStateRef = json.meta._spreadStateRef || 0;
|
|
432
432
|
const name = `${refName}_state_${json.meta._spreadStateRef}`;
|
|
433
433
|
json.meta._spreadStateRef = json.meta._spreadStateRef + 1;
|
|
434
|
-
(0, helpers_2.makeReactiveState)(root, name, `this.${name} = ${(
|
|
434
|
+
(0, helpers_2.makeReactiveState)(root, name, `this.${name} = ${(_p = json.bindings[key]) === null || _p === void 0 ? void 0 : _p.code};`);
|
|
435
435
|
spreadCode = `this.${name}`;
|
|
436
436
|
changesCode = `changes['${spreadCode.replace('this.', '')}']?.currentValue`;
|
|
437
437
|
}
|
|
438
438
|
else {
|
|
439
|
-
spreadCode = `${(
|
|
439
|
+
spreadCode = `${(_q = json.bindings[key]) === null || _q === void 0 ? void 0 : _q.code}`;
|
|
440
440
|
changesCode = `changes['${spreadCode.replace('this.', '')}']?.currentValue`;
|
|
441
441
|
}
|
|
442
442
|
if (!root.compileContext) {
|
|
@@ -687,11 +687,14 @@ const componentToAngular = (userOptions = {}) => ({ component: _component }) =>
|
|
|
687
687
|
// so we need to use `this.` inside the class to access state and props
|
|
688
688
|
const isSpreadAttributeBinding = ((_a = node === null || node === void 0 ? void 0 : node.bindings[key]) === null || _a === void 0 ? void 0 : _a.type) === 'spread' &&
|
|
689
689
|
html_tags_1.VALID_HTML_TAGS.includes(node.name.trim());
|
|
690
|
+
// If we have a For loop with "key" it will be transformed to
|
|
691
|
+
// trackOfXXX, we need to use "this" for state properties
|
|
692
|
+
const isKey = key === 'key';
|
|
690
693
|
const newLocal = processAngularCode({
|
|
691
694
|
contextVars: [],
|
|
692
695
|
outputVars,
|
|
693
696
|
domRefs: [], // the template doesn't need the this keyword.
|
|
694
|
-
replaceWith: isSpreadAttributeBinding ? 'this' : undefined,
|
|
697
|
+
replaceWith: isKey || isSpreadAttributeBinding ? 'this' : undefined,
|
|
695
698
|
})(code);
|
|
696
699
|
return newLocal.replace(/"/g, '"');
|
|
697
700
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const FUNCTION_HACK_PLUGIN:
|
|
1
|
+
import { MitosisPlugin } from '../../modules/plugins';
|
|
2
|
+
export declare const FUNCTION_HACK_PLUGIN: MitosisPlugin;
|
|
@@ -30,8 +30,9 @@ function getFragment(type, options, node) {
|
|
|
30
30
|
let tag = '';
|
|
31
31
|
if (node && node.bindings && (0, exports.isFragmentWithKey)(node)) {
|
|
32
32
|
tag = options.preact ? 'Fragment' : 'React.Fragment';
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const keyCode = (_a = node.bindings['key']) === null || _a === void 0 ? void 0 : _a.code;
|
|
34
|
+
if (type === 'open' && keyCode) {
|
|
35
|
+
tag += ` key={${(0, exports.processBinding)(keyCode, options)}}`;
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
else if (options.preact) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ProcessBindingOptions } from '../../../generators/stencil/helpers/index';
|
|
2
2
|
import { ToStencilOptions } from '../../../generators/stencil/types';
|
|
3
|
-
export declare const getCodeProcessorPlugins: (options: ToStencilOptions, processBindingOptions: ProcessBindingOptions) => import("../../..").
|
|
3
|
+
export declare const getCodeProcessorPlugins: (options: ToStencilOptions, processBindingOptions: ProcessBindingOptions) => import("../../..").MitosisPlugin[];
|
|
@@ -19,11 +19,27 @@ exports.checkIsMitosisComponentFilePath = checkIsMitosisComponentFilePath;
|
|
|
19
19
|
* Matches `.svelte`, `.lite.tsx`, `.lite.jsx` files (with optional `.jsx`/`.tsx` extension)
|
|
20
20
|
*/
|
|
21
21
|
exports.INPUT_EXTENSION_REGEX = /\.(svelte|(lite(\.tsx|\.jsx)?))/g;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const getExplicitFileExtension = (path, explicitBuildFileExtensions) => {
|
|
23
|
+
if (explicitBuildFileExtensions) {
|
|
24
|
+
for (const [extension, regex] of Object.entries(explicitBuildFileExtensions)) {
|
|
25
|
+
const match = path.match(regex);
|
|
26
|
+
if (match) {
|
|
27
|
+
return extension;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
};
|
|
33
|
+
const renameComponentFile = ({ path, target, options, }) => {
|
|
34
|
+
var _a;
|
|
35
|
+
const explicitExtension = getExplicitFileExtension(path, (_a = options.options[target]) === null || _a === void 0 ? void 0 : _a.explicitBuildFileExtensions);
|
|
36
|
+
const extension = explicitExtension !== null && explicitExtension !== void 0 ? explicitExtension : (0, exports.getComponentFileExtensionForTarget)({
|
|
37
|
+
type: 'filename',
|
|
38
|
+
target,
|
|
39
|
+
isTypescript: (0, output_1.checkShouldOutputTypeScript)({ options, target }),
|
|
40
|
+
});
|
|
41
|
+
return path.replace(exports.INPUT_EXTENSION_REGEX, extension);
|
|
42
|
+
};
|
|
27
43
|
exports.renameComponentFile = renameComponentFile;
|
|
28
44
|
/**
|
|
29
45
|
* just like `INPUT_EXTENSION_REGEX`, but adds trailing quotes to the end of import paths.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MitosisComponent, MitosisNode,
|
|
1
|
+
import { MitosisComponent, MitosisNode, MitosisPlugin, OnEventHook } from '..';
|
|
2
2
|
export declare const getOnEventHandlerName: (hook: OnEventHook) => string;
|
|
3
3
|
export declare const getOnEventHooksForNode: ({ node, component, }: {
|
|
4
4
|
node: MitosisNode;
|
|
@@ -11,4 +11,4 @@ export declare const getOnEventHooksForNode: ({ node, component, }: {
|
|
|
11
11
|
export declare const processOnEventHooksPlugin: (args?: {
|
|
12
12
|
setBindings?: boolean;
|
|
13
13
|
includeRootEvents?: boolean;
|
|
14
|
-
}) =>
|
|
14
|
+
}) => MitosisPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MitosisComponent } from '../../../types/mitosis-component';
|
|
2
|
-
import {
|
|
2
|
+
import { MitosisPlugin } from '../../../types/plugins';
|
|
3
3
|
import { CodeProcessor } from './types';
|
|
4
4
|
export declare const createCodeProcessorPlugin: (codeProcessor: CodeProcessor, { processProperties }?: {
|
|
5
5
|
processProperties?: boolean | undefined;
|
|
@@ -9,4 +9,4 @@ export declare const createCodeProcessorPlugin: (codeProcessor: CodeProcessor, {
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const CODE_PROCESSOR_PLUGIN: (codeProcessor: (codeType: import("./types").CodeType, json: MitosisComponent, node?: import("../../..").MitosisNode | undefined) => (code: string, hookType: string) => string | (() => void), a_1?: {
|
|
11
11
|
processProperties?: boolean | undefined;
|
|
12
|
-
} | undefined) =>
|
|
12
|
+
} | undefined) => MitosisPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Node, types } from '@babel/core';
|
|
2
2
|
import { Target } from '../../types/config';
|
|
3
|
-
import {
|
|
3
|
+
import { MitosisPlugin } from '../../types/plugins';
|
|
4
4
|
export declare const replaceSignalSetters: ({ code, nodeMaps, }: {
|
|
5
5
|
code: string;
|
|
6
6
|
nodeMaps: {
|
|
@@ -13,10 +13,10 @@ export declare const replaceSignalSetters: ({ code, nodeMaps, }: {
|
|
|
13
13
|
*/
|
|
14
14
|
export declare const getSignalTypePlugin: ({ target }: {
|
|
15
15
|
target: Target;
|
|
16
|
-
}) =>
|
|
16
|
+
}) => MitosisPlugin;
|
|
17
17
|
/**
|
|
18
18
|
* Processes `mySignal.value` accessors for props, context, and state.
|
|
19
19
|
*/
|
|
20
20
|
export declare const getSignalAccessPlugin: ({ target }: {
|
|
21
21
|
target: Target;
|
|
22
|
-
}) =>
|
|
22
|
+
}) => MitosisPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Targets } from '../../targets';
|
|
2
|
-
import {
|
|
2
|
+
import { MitosisPlugin } from '../../types/plugins';
|
|
3
3
|
/**
|
|
4
4
|
* Processes `useTarget()` blocks for a given target.
|
|
5
5
|
*/
|
|
6
|
-
export declare const processTargetBlocks: (target: Targets) =>
|
|
6
|
+
export declare const processTargetBlocks: (target: Targets) => MitosisPlugin;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { MitosisComponent } from '../types/mitosis-component';
|
|
2
|
-
import {
|
|
3
|
-
export type {
|
|
2
|
+
import { MitosisPlugin } from '../types/plugins';
|
|
3
|
+
export type { MitosisPlugin };
|
|
4
4
|
export declare const runPreJsonPlugins: ({ json, plugins, options, }: {
|
|
5
5
|
json: MitosisComponent;
|
|
6
|
-
plugins:
|
|
6
|
+
plugins: MitosisPlugin[];
|
|
7
7
|
options?: any;
|
|
8
8
|
}) => MitosisComponent;
|
|
9
9
|
export declare const runPostJsonPlugins: ({ json, plugins, options, }: {
|
|
10
10
|
json: MitosisComponent;
|
|
11
|
-
plugins:
|
|
11
|
+
plugins: MitosisPlugin[];
|
|
12
12
|
options?: any;
|
|
13
13
|
}) => MitosisComponent;
|
|
14
14
|
export declare const runPreCodePlugins: ({ code, plugins, options, json, }: {
|
|
15
15
|
json: MitosisComponent;
|
|
16
16
|
code: string;
|
|
17
|
-
plugins:
|
|
17
|
+
plugins: MitosisPlugin[];
|
|
18
18
|
options?: any;
|
|
19
19
|
}) => string;
|
|
20
20
|
export declare const runPostCodePlugins: ({ code, plugins, options, json, }: {
|
|
21
21
|
json: MitosisComponent;
|
|
22
22
|
code: string;
|
|
23
|
-
plugins:
|
|
23
|
+
plugins: MitosisPlugin[];
|
|
24
24
|
options?: any;
|
|
25
25
|
}) => string;
|
|
@@ -7,7 +7,7 @@ type SveltosisStateValue = StateValue & {
|
|
|
7
7
|
export declare function preventNameCollissions(json: SveltosisComponent, item: SveltosisStateValue): {
|
|
8
8
|
code: string;
|
|
9
9
|
typeParameter?: string | undefined;
|
|
10
|
-
type: "function" | "
|
|
10
|
+
type: "function" | "method" | "property" | "getter";
|
|
11
11
|
propertyType?: import("../../../types/mitosis-component").ReactivityType | undefined;
|
|
12
12
|
arguments?: string[] | undefined;
|
|
13
13
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MitosisPlugin } from '..';
|
|
2
2
|
import { TraverseContext } from 'neotraverse/legacy';
|
|
3
3
|
import { MitosisComponent } from '../types/mitosis-component';
|
|
4
4
|
import { MitosisNode } from '../types/mitosis-node';
|
|
@@ -11,5 +11,5 @@ type CompileAwayBuilderComponentsOptions = {
|
|
|
11
11
|
omit?: string[];
|
|
12
12
|
};
|
|
13
13
|
export declare const compileAwayBuilderComponentsFromTree: (tree: MitosisNode | MitosisComponent, components: CompileAwayComponentsMap) => void;
|
|
14
|
-
export declare const compileAwayBuilderComponents: (pluginOptions?: CompileAwayBuilderComponentsOptions) =>
|
|
14
|
+
export declare const compileAwayBuilderComponents: (pluginOptions?: CompileAwayBuilderComponentsOptions) => MitosisPlugin;
|
|
15
15
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ParseMitosisOptions } from '../parsers/jsx
|
|
1
|
+
import type { ParseMitosisOptions } from '../parsers/jsx';
|
|
2
2
|
import { targets } from '../targets';
|
|
3
3
|
import type { MitosisComponent } from './mitosis-component';
|
|
4
|
-
import { BaseTranspilerOptions } from './transpiler';
|
|
4
|
+
import { BaseTranspilerOptions, TranspilerGenerator } from './transpiler';
|
|
5
5
|
export type Format = 'esm' | 'cjs';
|
|
6
6
|
export type Language = 'js' | 'ts';
|
|
7
7
|
interface TranspilerOptions {
|
|
@@ -17,6 +17,15 @@ export type GeneratorOptions = {
|
|
|
17
17
|
export type generatorsOption = {
|
|
18
18
|
[K in Target]: NonNullable<Targets[K]>;
|
|
19
19
|
};
|
|
20
|
+
export interface TargetContext {
|
|
21
|
+
target: Target;
|
|
22
|
+
generator: TranspilerGenerator<NonNullable<MitosisConfig['options'][Target]>>;
|
|
23
|
+
outputPath: string;
|
|
24
|
+
}
|
|
25
|
+
export interface OutputFiles {
|
|
26
|
+
outputDir: string;
|
|
27
|
+
outputFilePath: string;
|
|
28
|
+
}
|
|
20
29
|
export type MitosisConfig = {
|
|
21
30
|
generators?: generatorsOption;
|
|
22
31
|
/**
|
|
@@ -136,6 +136,15 @@ export type MitosisComponent = {
|
|
|
136
136
|
propsTypeRef?: string;
|
|
137
137
|
defaultProps?: MitosisState;
|
|
138
138
|
style?: string;
|
|
139
|
+
/**
|
|
140
|
+
* This data is filled inside cli to provide more data for plugins
|
|
141
|
+
*/
|
|
142
|
+
pluginData?: {
|
|
143
|
+
target?: Target;
|
|
144
|
+
path?: string;
|
|
145
|
+
outputDir?: string;
|
|
146
|
+
outputFilePath?: string;
|
|
147
|
+
};
|
|
139
148
|
/**
|
|
140
149
|
* Used to store context of a component for a specific framework
|
|
141
150
|
* that we need access only during compilation (for internal use only) and gets removed after compilation.
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
import { OutputFiles, TargetContext } from '../types/config';
|
|
1
2
|
import { MitosisComponent } from './mitosis-component';
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
export type MitosisBuildPlugin = (targetContext: TargetContext, files?: {
|
|
4
|
+
componentFiles: OutputFiles[];
|
|
5
|
+
nonComponentFiles: OutputFiles[];
|
|
6
|
+
}) => void | Promise<void>;
|
|
7
|
+
export type MitosisJsonPlugin = (json: MitosisComponent) => MitosisComponent | void;
|
|
8
|
+
export type MitosisCodePlugin = (code: string, json: MitosisComponent) => string;
|
|
9
|
+
export type MitosisHook<T> = {
|
|
10
|
+
pre?: T;
|
|
11
|
+
post?: T;
|
|
12
|
+
};
|
|
13
|
+
export type MitosisPlugin = (options?: any) => {
|
|
14
|
+
name?: string;
|
|
15
|
+
order?: number;
|
|
16
|
+
build?: MitosisHook<MitosisBuildPlugin>;
|
|
17
|
+
json?: MitosisHook<MitosisJsonPlugin>;
|
|
18
|
+
code?: MitosisHook<MitosisCodePlugin>;
|
|
11
19
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MitosisComponent } from './mitosis-component';
|
|
2
|
-
import {
|
|
2
|
+
import { MitosisPlugin } from './plugins';
|
|
3
3
|
export interface TranspilerArgs {
|
|
4
4
|
path?: string;
|
|
5
5
|
component: MitosisComponent;
|
|
@@ -20,7 +20,7 @@ export interface BaseTranspilerOptions {
|
|
|
20
20
|
/**
|
|
21
21
|
* Mitosis Plugins to run during codegen.
|
|
22
22
|
*/
|
|
23
|
-
plugins?:
|
|
23
|
+
plugins?: MitosisPlugin[];
|
|
24
24
|
/**
|
|
25
25
|
* Enable `typescript` output
|
|
26
26
|
*/
|
|
@@ -29,4 +29,14 @@ export interface BaseTranspilerOptions {
|
|
|
29
29
|
* Preserves explicit filename extensions in import statements.
|
|
30
30
|
*/
|
|
31
31
|
explicitImportFileExtension?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Can be used for cli builds. Preserves explicit filename extensions when regex matches, e.g.:
|
|
34
|
+
* {
|
|
35
|
+
* explicitBuildFileExtension: {
|
|
36
|
+
* ".ts":/*.figma.lite.tsx/g,
|
|
37
|
+
* ".md":/*.docs.lite.tsx/g
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
*/
|
|
41
|
+
explicitBuildFileExtensions?: Record<string, RegExp>;
|
|
32
42
|
}
|