@teleporthq/teleport-plugin-react-base-component
Advanced tools
Comparing version 0.38.0-alpha.0 to 0.38.0
@@ -63,3 +63,2 @@ "use strict"; | ||
exports.createReactComponentPlugin = void 0; | ||
var utils_1 = require("./utils"); | ||
var teleport_shared_1 = require("@teleporthq/teleport-shared"); | ||
@@ -73,6 +72,5 @@ var teleport_plugin_common_1 = require("@teleporthq/teleport-plugin-common"); | ||
var reactComponentPlugin = function (structure) { return __awaiter(void 0, void 0, void 0, function () { | ||
var uidl, dependencies, options, projectResources, _a, stateDefinitions, _b, propDefinitions, nodesLookup, windowImports, jsxParams, jsxOptions, jsxTagStructure, componentName, pureComponent, routerAST, componentBody; | ||
return __generator(this, function (_c) { | ||
uidl = structure.uidl, dependencies = structure.dependencies, options = structure.options; | ||
projectResources = options.projectResources; | ||
var uidl, dependencies, _a, stateDefinitions, _b, propDefinitions, nodesLookup, windowImports, jsxParams, jsxOptions, _i, _c, propKey, prop, jsxTagStructure, componentName, pureComponent, routerAST, componentBody; | ||
return __generator(this, function (_d) { | ||
uidl = structure.uidl, dependencies = structure.dependencies; | ||
_a = uidl.stateDefinitions, stateDefinitions = _a === void 0 ? {} : _a, _b = uidl.propDefinitions, propDefinitions = _b === void 0 ? {} : _b; | ||
@@ -90,4 +88,5 @@ dependencies.React = constants_1.REACT_LIBRARY_DEPENDENCY; | ||
dependencies: dependencies, | ||
projectResources: projectResources, | ||
windowImports: windowImports, | ||
localeReferences: [], | ||
globalReferences: [], | ||
}; | ||
@@ -103,4 +102,15 @@ jsxOptions = { | ||
slotHandling: 'props', | ||
domHTMLInjection: function (content) { return (0, utils_1.createDOMInjectionNode)(content); }, | ||
domHTMLInjection: function (content) { return teleport_plugin_common_1.ASTBuilders.createDOMInjectionNode(content); }, | ||
}; | ||
/* | ||
We need to generate jsx structure of every node that is defined in the UIDL. | ||
If we use these nodes in the later stage of the code-generation depends on the usage of these nodes. | ||
*/ | ||
for (_i = 0, _c = Object.keys(propDefinitions); _i < _c.length; _i++) { | ||
propKey = _c[_i]; | ||
prop = propDefinitions[propKey]; | ||
if (prop.type === 'element' && typeof prop.defaultValue === 'object') { | ||
(0, teleport_plugin_common_1.createJSXSyntax)(prop.defaultValue, jsxParams, jsxOptions); | ||
} | ||
} | ||
jsxTagStructure = (0, teleport_plugin_common_1.createJSXSyntax)(uidl.node, jsxParams, jsxOptions); | ||
@@ -127,2 +137,4 @@ componentName = teleport_shared_1.UIDLUtils.getComponentClassName(uidl); | ||
dynamicRefPrefix: jsxOptions.dynamicReferencePrefixMap, | ||
localeReferences: jsxParams.localeReferences, | ||
globalReferences: jsxParams.globalReferences, | ||
}, | ||
@@ -129,0 +141,0 @@ content: pureComponent, |
@@ -37,3 +37,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
import { createDOMInjectionNode } from './utils'; | ||
import { Constants, UIDLUtils } from '@teleporthq/teleport-shared'; | ||
@@ -47,6 +46,5 @@ import { createJSXSyntax, ASTBuilders, ASTUtils, } from '@teleporthq/teleport-plugin-common'; | ||
var reactComponentPlugin = function (structure) { return __awaiter(void 0, void 0, void 0, function () { | ||
var uidl, dependencies, options, projectResources, _a, stateDefinitions, _b, propDefinitions, nodesLookup, windowImports, jsxParams, jsxOptions, jsxTagStructure, componentName, pureComponent, routerAST, componentBody; | ||
return __generator(this, function (_c) { | ||
uidl = structure.uidl, dependencies = structure.dependencies, options = structure.options; | ||
projectResources = options.projectResources; | ||
var uidl, dependencies, _a, stateDefinitions, _b, propDefinitions, nodesLookup, windowImports, jsxParams, jsxOptions, _i, _c, propKey, prop, jsxTagStructure, componentName, pureComponent, routerAST, componentBody; | ||
return __generator(this, function (_d) { | ||
uidl = structure.uidl, dependencies = structure.dependencies; | ||
_a = uidl.stateDefinitions, stateDefinitions = _a === void 0 ? {} : _a, _b = uidl.propDefinitions, propDefinitions = _b === void 0 ? {} : _b; | ||
@@ -64,4 +62,5 @@ dependencies.React = REACT_LIBRARY_DEPENDENCY; | ||
dependencies: dependencies, | ||
projectResources: projectResources, | ||
windowImports: windowImports, | ||
localeReferences: [], | ||
globalReferences: [], | ||
}; | ||
@@ -77,4 +76,15 @@ jsxOptions = { | ||
slotHandling: 'props', | ||
domHTMLInjection: function (content) { return createDOMInjectionNode(content); }, | ||
domHTMLInjection: function (content) { return ASTBuilders.createDOMInjectionNode(content); }, | ||
}; | ||
/* | ||
We need to generate jsx structure of every node that is defined in the UIDL. | ||
If we use these nodes in the later stage of the code-generation depends on the usage of these nodes. | ||
*/ | ||
for (_i = 0, _c = Object.keys(propDefinitions); _i < _c.length; _i++) { | ||
propKey = _c[_i]; | ||
prop = propDefinitions[propKey]; | ||
if (prop.type === 'element' && typeof prop.defaultValue === 'object') { | ||
createJSXSyntax(prop.defaultValue, jsxParams, jsxOptions); | ||
} | ||
} | ||
jsxTagStructure = createJSXSyntax(uidl.node, jsxParams, jsxOptions); | ||
@@ -101,2 +111,4 @@ componentName = UIDLUtils.getComponentClassName(uidl); | ||
dynamicRefPrefix: jsxOptions.dynamicReferencePrefixMap, | ||
localeReferences: jsxParams.localeReferences, | ||
globalReferences: jsxParams.globalReferences, | ||
}, | ||
@@ -103,0 +115,0 @@ content: pureComponent, |
{ | ||
"name": "@teleporthq/teleport-plugin-react-base-component", | ||
"version": "0.38.0-alpha.0", | ||
"version": "0.38.0", | ||
"description": "A plugin for handling the skeleton/baseline of a React component", | ||
@@ -28,7 +28,7 @@ "author": "teleportHQ", | ||
"@babel/types": "^7.5.5", | ||
"@teleporthq/teleport-plugin-common": "^0.38.0-alpha.0", | ||
"@teleporthq/teleport-shared": "^0.36.0-alpha.0", | ||
"@teleporthq/teleport-types": "^0.36.0-alpha.0" | ||
"@teleporthq/teleport-plugin-common": "^0.38.0", | ||
"@teleporthq/teleport-shared": "^0.38.0", | ||
"@teleporthq/teleport-types": "^0.38.0" | ||
}, | ||
"gitHead": "1980115403a1773980f2b4bd78fd366f1fca58da" | ||
"gitHead": "548a7be5f9a1724936fab263db22261cecd2dc91" | ||
} |
@@ -1,2 +0,1 @@ | ||
import { createDOMInjectionNode } from './utils' | ||
import { Constants, UIDLUtils } from '@teleporthq/teleport-shared' | ||
@@ -8,2 +7,3 @@ import { | ||
ASTUtils, | ||
JSXGenerationParams, | ||
} from '@teleporthq/teleport-plugin-common' | ||
@@ -16,2 +16,3 @@ | ||
FileType, | ||
UIDLElementNode, | ||
} from '@teleporthq/teleport-types' | ||
@@ -41,4 +42,3 @@ import * as types from '@babel/types' | ||
const reactComponentPlugin: ComponentPlugin = async (structure) => { | ||
const { uidl, dependencies, options } = structure | ||
const { projectResources } = options | ||
const { uidl, dependencies } = structure | ||
const { stateDefinitions = {}, propDefinitions = {} } = uidl | ||
@@ -57,3 +57,3 @@ | ||
const windowImports: Record<string, types.ExpressionStatement> = {} | ||
const jsxParams = { | ||
const jsxParams: JSXGenerationParams = { | ||
propDefinitions, | ||
@@ -63,4 +63,5 @@ stateDefinitions, | ||
dependencies, | ||
projectResources, | ||
windowImports, | ||
localeReferences: [], | ||
globalReferences: [], | ||
} | ||
@@ -77,5 +78,16 @@ | ||
slotHandling: 'props', | ||
domHTMLInjection: (content: string) => createDOMInjectionNode(content), | ||
domHTMLInjection: (content: string) => ASTBuilders.createDOMInjectionNode(content), | ||
} | ||
/* | ||
We need to generate jsx structure of every node that is defined in the UIDL. | ||
If we use these nodes in the later stage of the code-generation depends on the usage of these nodes. | ||
*/ | ||
for (const propKey of Object.keys(propDefinitions)) { | ||
const prop = propDefinitions[propKey] | ||
if (prop.type === 'element' && typeof prop.defaultValue === 'object') { | ||
createJSXSyntax(prop.defaultValue as UIDLElementNode, jsxParams, jsxOptions) | ||
} | ||
} | ||
const jsxTagStructure = createJSXSyntax(uidl.node, jsxParams, jsxOptions) | ||
@@ -116,2 +128,4 @@ | ||
dynamicRefPrefix: jsxOptions.dynamicReferencePrefixMap, | ||
localeReferences: jsxParams.localeReferences, | ||
globalReferences: jsxParams.globalReferences, | ||
}, | ||
@@ -118,0 +132,0 @@ content: pureComponent, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
92295
25
568
- Removed@teleporthq/teleport-shared@0.36.6(transitive)
- Removed@teleporthq/teleport-types@0.36.6(transitive)