@teleporthq/teleport-plugin-react-base-component
Advanced tools
Comparing version
@@ -17,3 +17,3 @@ "use strict"; | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -49,10 +49,9 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
var reactComponentPlugin = function (structure) { return __awaiter(void 0, void 0, void 0, function () { | ||
var uidl, dependencies, options, projectContexts, projectResources, _a, stateDefinitions, _b, propDefinitions, nodesLookup, windowImports, jsxParams, jsxOptions, jsxTagStructure, componentName, pureComponent; | ||
var uidl, dependencies, _a, stateDefinitions, _b, propDefinitions, nodesLookup, windowImports, jsxParams, jsxOptions, jsxTagStructure, componentName, pureComponent; | ||
return __generator(this, function (_c) { | ||
uidl = structure.uidl, dependencies = structure.dependencies, options = structure.options; | ||
projectContexts = options.projectContexts, projectResources = options.projectResources; | ||
uidl = structure.uidl, dependencies = structure.dependencies; | ||
_a = uidl.stateDefinitions, stateDefinitions = _a === void 0 ? {} : _a, _b = uidl.propDefinitions, propDefinitions = _b === void 0 ? {} : _b; | ||
dependencies.React = constants_1.REACT_LIBRARY_DEPENDENCY; | ||
if (Object.keys(stateDefinitions).length > 0) { | ||
dependencies.useState = teleport_shared_1.Constants.USE_STATE_DEPENDENCY; | ||
dependencies.useState = constants_1.USE_STATE_DEPENDENCY; | ||
} | ||
@@ -66,4 +65,2 @@ nodesLookup = {}; | ||
dependencies: dependencies, | ||
projectContexts: projectContexts, | ||
projectResources: projectResources, | ||
windowImports: windowImports, | ||
@@ -76,3 +73,2 @@ }; | ||
local: '', | ||
ctx: '', | ||
}, | ||
@@ -88,3 +84,3 @@ dependencyHandling: 'import', | ||
if (Object.keys(windowImports).length) { | ||
dependencies.useEffect = teleport_shared_1.Constants.USE_STATE_DEPENDENCY; | ||
dependencies.useEffect = constants_1.USE_STATE_DEPENDENCY; | ||
} | ||
@@ -91,0 +87,0 @@ structure.chunks.push({ |
@@ -16,3 +16,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -39,17 +39,16 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
import { createDOMInjectionNode } from './utils'; | ||
import { Constants, UIDLUtils } from '@teleporthq/teleport-shared'; | ||
import { UIDLUtils } from '@teleporthq/teleport-shared'; | ||
import { createJSXSyntax, ASTBuilders, ASTUtils, } from '@teleporthq/teleport-plugin-common'; | ||
import { ChunkType, FileType, } from '@teleporthq/teleport-types'; | ||
import { DEFAULT_COMPONENT_CHUNK_NAME, DEFAULT_EXPORT_CHUNK_NAME, DEFAULT_IMPORT_CHUNK_NAME, REACT_LIBRARY_DEPENDENCY, } from './constants'; | ||
import { DEFAULT_COMPONENT_CHUNK_NAME, DEFAULT_EXPORT_CHUNK_NAME, DEFAULT_IMPORT_CHUNK_NAME, REACT_LIBRARY_DEPENDENCY, USE_STATE_DEPENDENCY, } from './constants'; | ||
export var createReactComponentPlugin = function (config) { | ||
var _a = config || {}, _b = _a.componentChunkName, componentChunkName = _b === void 0 ? DEFAULT_COMPONENT_CHUNK_NAME : _b, _c = _a.exportChunkName, exportChunkName = _c === void 0 ? DEFAULT_EXPORT_CHUNK_NAME : _c, _d = _a.importChunkName, importChunkName = _d === void 0 ? DEFAULT_IMPORT_CHUNK_NAME : _d; | ||
var reactComponentPlugin = function (structure) { return __awaiter(void 0, void 0, void 0, function () { | ||
var uidl, dependencies, options, projectContexts, projectResources, _a, stateDefinitions, _b, propDefinitions, nodesLookup, windowImports, jsxParams, jsxOptions, jsxTagStructure, componentName, pureComponent; | ||
var uidl, dependencies, _a, stateDefinitions, _b, propDefinitions, nodesLookup, windowImports, jsxParams, jsxOptions, jsxTagStructure, componentName, pureComponent; | ||
return __generator(this, function (_c) { | ||
uidl = structure.uidl, dependencies = structure.dependencies, options = structure.options; | ||
projectContexts = options.projectContexts, projectResources = options.projectResources; | ||
uidl = structure.uidl, dependencies = structure.dependencies; | ||
_a = uidl.stateDefinitions, stateDefinitions = _a === void 0 ? {} : _a, _b = uidl.propDefinitions, propDefinitions = _b === void 0 ? {} : _b; | ||
dependencies.React = REACT_LIBRARY_DEPENDENCY; | ||
if (Object.keys(stateDefinitions).length > 0) { | ||
dependencies.useState = Constants.USE_STATE_DEPENDENCY; | ||
dependencies.useState = USE_STATE_DEPENDENCY; | ||
} | ||
@@ -63,4 +62,2 @@ nodesLookup = {}; | ||
dependencies: dependencies, | ||
projectContexts: projectContexts, | ||
projectResources: projectResources, | ||
windowImports: windowImports, | ||
@@ -73,3 +70,2 @@ }; | ||
local: '', | ||
ctx: '', | ||
}, | ||
@@ -85,3 +81,3 @@ dependencyHandling: 'import', | ||
if (Object.keys(windowImports).length) { | ||
dependencies.useEffect = Constants.USE_STATE_DEPENDENCY; | ||
dependencies.useEffect = USE_STATE_DEPENDENCY; | ||
} | ||
@@ -88,0 +84,0 @@ structure.chunks.push({ |
{ | ||
"name": "@teleporthq/teleport-plugin-react-base-component", | ||
"version": "0.27.6-alpha.0", | ||
"version": "0.27.8", | ||
"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.27.6-alpha.0", | ||
"@teleporthq/teleport-shared": "^0.27.6-alpha.0", | ||
"@teleporthq/teleport-types": "^0.27.6-alpha.0" | ||
"@teleporthq/teleport-plugin-common": "^0.27.8", | ||
"@teleporthq/teleport-shared": "^0.27.8", | ||
"@teleporthq/teleport-types": "^0.27.8" | ||
}, | ||
"gitHead": "6c93c42321beedc5de5cedc424a5cbb184c2d55b" | ||
"gitHead": "3ae7c0728720e2b5b1663c57e08283ede422c227" | ||
} |
import { createDOMInjectionNode } from './utils' | ||
import { Constants, UIDLUtils } from '@teleporthq/teleport-shared' | ||
import { UIDLUtils } from '@teleporthq/teleport-shared' | ||
import { | ||
@@ -23,2 +23,3 @@ createJSXSyntax, | ||
REACT_LIBRARY_DEPENDENCY, | ||
USE_STATE_DEPENDENCY, | ||
} from './constants' | ||
@@ -40,4 +41,3 @@ | ||
const reactComponentPlugin: ComponentPlugin = async (structure) => { | ||
const { uidl, dependencies, options } = structure | ||
const { projectContexts, projectResources } = options | ||
const { uidl, dependencies } = structure | ||
const { stateDefinitions = {}, propDefinitions = {} } = uidl | ||
@@ -48,3 +48,3 @@ | ||
if (Object.keys(stateDefinitions).length > 0) { | ||
dependencies.useState = Constants.USE_STATE_DEPENDENCY | ||
dependencies.useState = USE_STATE_DEPENDENCY | ||
} | ||
@@ -62,4 +62,2 @@ | ||
dependencies, | ||
projectContexts, | ||
projectResources, | ||
windowImports, | ||
@@ -73,3 +71,2 @@ } | ||
local: '', | ||
ctx: '', | ||
}, | ||
@@ -93,3 +90,3 @@ dependencyHandling: 'import', | ||
if (Object.keys(windowImports).length) { | ||
dependencies.useEffect = Constants.USE_STATE_DEPENDENCY | ||
dependencies.useEffect = USE_STATE_DEPENDENCY | ||
} | ||
@@ -96,0 +93,0 @@ |
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
81228
1.7%541
-1.99%