@teleporthq/teleport-plugin-react-base-component
Advanced tools
Comparing version 0.10.0-alpha.1 to 0.10.0-alpha.2
@@ -1,2 +0,2 @@ | ||
import { createPlugin } from '../src/index' | ||
import { createReactComponentPlugin } from '../src/index' | ||
import { component, elementNode } from '@teleporthq/teleport-uidl-builders' | ||
@@ -6,3 +6,3 @@ import { ComponentStructure, ChunkType } from '@teleporthq/teleport-types' | ||
describe('plugin-react-base-component', () => { | ||
const plugin = createPlugin({ | ||
const plugin = createReactComponentPlugin({ | ||
componentChunkName: 'component-chunk', | ||
@@ -9,0 +9,0 @@ exportChunkName: 'export-chunk', |
@@ -7,4 +7,4 @@ import { ComponentPluginFactory, ComponentPlugin } from '@teleporthq/teleport-types'; | ||
} | ||
export declare const createPlugin: ComponentPluginFactory<ReactPluginConfig>; | ||
export declare const createReactComponentPlugin: ComponentPluginFactory<ReactPluginConfig>; | ||
declare const _default: ComponentPlugin; | ||
export default _default; |
@@ -43,6 +43,6 @@ "use strict"; | ||
var constants_1 = require("./constants"); | ||
exports.createPlugin = function (config) { | ||
exports.createReactComponentPlugin = function (config) { | ||
var _a = config || {}, _b = _a.componentChunkName, componentChunkName = _b === void 0 ? constants_1.DEFAULT_COMPONENT_CHUNK_NAME : _b, _c = _a.exportChunkName, exportChunkName = _c === void 0 ? constants_1.DEFAULT_EXPORT_CHUNK_NAME : _c, _d = _a.importChunkName, importChunkName = _d === void 0 ? constants_1.DEFAULT_IMPORT_CHUNK_NAME : _d; | ||
var reactComponentPlugin = function (structure) { return __awaiter(_this, void 0, void 0, function () { | ||
var uidl, dependencies, _a, stateDefinitions, _b, propDefinitions, nodesLookup, jsxParams, jsxOptions, jsxTagStructure, pureComponent; | ||
var uidl, dependencies, _a, stateDefinitions, _b, propDefinitions, nodesLookup, jsxParams, jsxOptions, jsxTagStructure, componentName, pureComponent; | ||
return __generator(this, function (_c) { | ||
@@ -73,3 +73,4 @@ uidl = structure.uidl, dependencies = structure.dependencies; | ||
jsxTagStructure = teleport_shared_1.createJSXSyntax(uidl.node, jsxParams, jsxOptions); | ||
pureComponent = utils_1.createPureComponent(uidl.name, stateDefinitions, jsxTagStructure); | ||
componentName = teleport_shared_1.UIDLUtils.getComponentClassName(uidl); | ||
pureComponent = utils_1.createPureComponent(componentName, stateDefinitions, jsxTagStructure); | ||
structure.chunks.push({ | ||
@@ -90,3 +91,3 @@ type: teleport_types_1.ChunkType.AST, | ||
name: exportChunkName, | ||
content: teleport_shared_1.ASTBuilders.createDefaultExport(uidl.name), | ||
content: teleport_shared_1.ASTBuilders.createDefaultExport(componentName), | ||
linkAfter: [componentChunkName], | ||
@@ -99,3 +100,3 @@ }); | ||
}; | ||
exports.default = exports.createPlugin(); | ||
exports.default = exports.createReactComponentPlugin(); | ||
//# sourceMappingURL=index.js.map |
@@ -7,4 +7,4 @@ import { ComponentPluginFactory, ComponentPlugin } from '@teleporthq/teleport-types'; | ||
} | ||
export declare const createPlugin: ComponentPluginFactory<ReactPluginConfig>; | ||
export declare const createReactComponentPlugin: ComponentPluginFactory<ReactPluginConfig>; | ||
declare const _default: ComponentPlugin; | ||
export default _default; |
import { createPureComponent } from './utils'; | ||
import { createJSXSyntax, ASTBuilders } from '@teleporthq/teleport-shared'; | ||
import { createJSXSyntax, ASTBuilders, UIDLUtils, } from '@teleporthq/teleport-shared'; | ||
import { ChunkType, FileType, } from '@teleporthq/teleport-types'; | ||
import { DEFAULT_COMPONENT_CHUNK_NAME, DEFAULT_EXPORT_CHUNK_NAME, DEFAULT_IMPORT_CHUNK_NAME, REACT_LIBRARY_DEPENDENCY, USE_STATE_DEPENDENCY, } from './constants'; | ||
export const createPlugin = (config) => { | ||
export const createReactComponentPlugin = (config) => { | ||
const { componentChunkName = DEFAULT_COMPONENT_CHUNK_NAME, exportChunkName = DEFAULT_EXPORT_CHUNK_NAME, importChunkName = DEFAULT_IMPORT_CHUNK_NAME, } = config || {}; | ||
@@ -35,3 +35,4 @@ const reactComponentPlugin = async (structure) => { | ||
const jsxTagStructure = createJSXSyntax(uidl.node, jsxParams, jsxOptions); | ||
const pureComponent = createPureComponent(uidl.name, stateDefinitions, jsxTagStructure); | ||
const componentName = UIDLUtils.getComponentClassName(uidl); | ||
const pureComponent = createPureComponent(componentName, stateDefinitions, jsxTagStructure); | ||
structure.chunks.push({ | ||
@@ -52,3 +53,3 @@ type: ChunkType.AST, | ||
name: exportChunkName, | ||
content: ASTBuilders.createDefaultExport(uidl.name), | ||
content: ASTBuilders.createDefaultExport(componentName), | ||
linkAfter: [componentChunkName], | ||
@@ -60,3 +61,3 @@ }); | ||
}; | ||
export default createPlugin(); | ||
export default createReactComponentPlugin(); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@teleporthq/teleport-plugin-react-base-component", | ||
"version": "0.10.0-alpha.1", | ||
"version": "0.10.0-alpha.2", | ||
"description": "A plugin for handling the skeleton/baseline of a React component", | ||
@@ -11,2 +11,3 @@ "author": "teleportHQ", | ||
"module": "dist/esm/index.js", | ||
"sideEffects": false, | ||
"repository": { | ||
@@ -30,6 +31,6 @@ "type": "git", | ||
"@babel/types": "^7.5.5", | ||
"@teleporthq/teleport-shared": "^0.10.0-alpha.1", | ||
"@teleporthq/teleport-types": "^0.10.0-alpha.1" | ||
"@teleporthq/teleport-shared": "^0.10.0-alpha.2", | ||
"@teleporthq/teleport-types": "^0.10.0-alpha.2" | ||
}, | ||
"gitHead": "d4c96887909af2dd6b68054751aa7eca8a48a4d0" | ||
"gitHead": "b185c3fdb7dc94ff8c7eed63f7edba055fffa8d0" | ||
} |
import { createPureComponent } from './utils' | ||
import { createJSXSyntax, JSXGenerationOptions, ASTBuilders } from '@teleporthq/teleport-shared' | ||
import { | ||
createJSXSyntax, | ||
JSXGenerationOptions, | ||
ASTBuilders, | ||
UIDLUtils, | ||
} from '@teleporthq/teleport-shared' | ||
@@ -25,3 +30,3 @@ import { | ||
export const createPlugin: ComponentPluginFactory<ReactPluginConfig> = (config) => { | ||
export const createReactComponentPlugin: ComponentPluginFactory<ReactPluginConfig> = (config) => { | ||
const { | ||
@@ -67,3 +72,4 @@ componentChunkName = DEFAULT_COMPONENT_CHUNK_NAME, | ||
const pureComponent = createPureComponent(uidl.name, stateDefinitions, jsxTagStructure) | ||
const componentName = UIDLUtils.getComponentClassName(uidl) | ||
const pureComponent = createPureComponent(componentName, stateDefinitions, jsxTagStructure) | ||
@@ -86,3 +92,3 @@ structure.chunks.push({ | ||
name: exportChunkName, | ||
content: ASTBuilders.createDefaultExport(uidl.name), | ||
content: ASTBuilders.createDefaultExport(componentName), | ||
linkAfter: [componentChunkName], | ||
@@ -97,2 +103,2 @@ }) | ||
export default createPlugin() | ||
export default createReactComponentPlugin() |
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
308508
523