@teleporthq/teleport-plugin-html-base-component
Advanced tools
Comparing version
@@ -10,3 +10,3 @@ import { ComponentPlugin, ComponentDefaultPluginParams, ComponentUIDL } from '@teleporthq/teleport-types'; | ||
} | ||
declare type HtmlPluginFactory<T> = (config?: Partial<T & ComponentDefaultPluginParams>) => HtmlPlugin; | ||
type HtmlPluginFactory<T> = (config?: Partial<T & ComponentDefaultPluginParams>) => HtmlPlugin; | ||
export declare const createHTMLBasePlugin: HtmlPluginFactory<HtmlPluginConfig>; | ||
@@ -13,0 +13,0 @@ declare const _default: HtmlPlugin; |
@@ -28,3 +28,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; | ||
@@ -31,0 +31,0 @@ if (y = 0, t) op = [op[0] & 2, t.value]; |
import { UIDLNode, HastNode, UIDLPropDefinition, UIDLStateDefinition, HastText, ComponentUIDL, ChunkDefinition, UIDLDependency, GeneratorOptions, UIDLRouteDefinitions } from '@teleporthq/teleport-types'; | ||
declare type NodeToHTML<NodeType, ReturnType> = (node: NodeType, templatesLookUp: Record<string, unknown>, propDefinitions: Record<string, UIDLPropDefinition>, stateDefinitions: Record<string, UIDLStateDefinition>, externals: Record<string, ComponentUIDL>, routeDefinitions: UIDLRouteDefinitions, structure: { | ||
type NodeToHTML<NodeType, ReturnType> = (node: NodeType, templatesLookUp: Record<string, unknown>, propDefinitions: Record<string, UIDLPropDefinition>, stateDefinitions: Record<string, UIDLStateDefinition>, externals: Record<string, ComponentUIDL>, routeDefinitions: UIDLRouteDefinitions, structure: { | ||
chunks: ChunkDefinition[]; | ||
@@ -4,0 +4,0 @@ dependencies: Record<string, UIDLDependency>; |
@@ -28,3 +28,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; | ||
@@ -70,2 +70,3 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (node.type) { | ||
case 'inject': | ||
case 'raw': | ||
@@ -314,3 +315,3 @@ return [2 /*return*/, teleport_plugin_common_1.HASTBuilders.createTextNode(node.content.toString())]; | ||
if (attrValue.type === 'raw') { | ||
teleport_plugin_common_1.HASTUtils.addAttributeToNode(htmlNode, attrKey, String(attrValue.content)); | ||
teleport_plugin_common_1.HASTUtils.addAttributeToNode(htmlNode, attrKey, attrValue.content); | ||
return; | ||
@@ -329,3 +330,3 @@ } | ||
var getValueFromReference = function (key, definitions) { | ||
var usedReferenceValue = definitions[key]; | ||
var usedReferenceValue = definitions[key.includes('.') ? key.split('.')[0] : key]; | ||
if (!usedReferenceValue) { | ||
@@ -337,3 +338,3 @@ throw new teleport_types_1.HTMLComponentGeneratorError("Definition for ".concat(key, " is missing from ").concat(JSON.stringify(definitions, null, 2))); | ||
} | ||
if (!['string', 'number'].includes(usedReferenceValue === null || usedReferenceValue === void 0 ? void 0 : usedReferenceValue.type)) { | ||
if (!['string', 'number', 'object'].includes(usedReferenceValue === null || usedReferenceValue === void 0 ? void 0 : usedReferenceValue.type)) { | ||
throw new teleport_types_1.HTMLComponentGeneratorError("Attribute is using dynamic value, but received of type ".concat(JSON.stringify(usedReferenceValue, null, 2))); | ||
@@ -340,0 +341,0 @@ } |
@@ -10,3 +10,3 @@ import { ComponentPlugin, ComponentDefaultPluginParams, ComponentUIDL } from '@teleporthq/teleport-types'; | ||
} | ||
declare type HtmlPluginFactory<T> = (config?: Partial<T & ComponentDefaultPluginParams>) => HtmlPlugin; | ||
type HtmlPluginFactory<T> = (config?: Partial<T & ComponentDefaultPluginParams>) => HtmlPlugin; | ||
export declare const createHTMLBasePlugin: HtmlPluginFactory<HtmlPluginConfig>; | ||
@@ -13,0 +13,0 @@ declare const _default: HtmlPlugin; |
@@ -27,3 +27,3 @@ var __assign = (this && this.__assign) || function () { | ||
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; | ||
@@ -30,0 +30,0 @@ if (y = 0, t) op = [op[0] & 2, t.value]; |
import { UIDLNode, HastNode, UIDLPropDefinition, UIDLStateDefinition, HastText, ComponentUIDL, ChunkDefinition, UIDLDependency, GeneratorOptions, UIDLRouteDefinitions } from '@teleporthq/teleport-types'; | ||
declare type NodeToHTML<NodeType, ReturnType> = (node: NodeType, templatesLookUp: Record<string, unknown>, propDefinitions: Record<string, UIDLPropDefinition>, stateDefinitions: Record<string, UIDLStateDefinition>, externals: Record<string, ComponentUIDL>, routeDefinitions: UIDLRouteDefinitions, structure: { | ||
type NodeToHTML<NodeType, ReturnType> = (node: NodeType, templatesLookUp: Record<string, unknown>, propDefinitions: Record<string, UIDLPropDefinition>, stateDefinitions: Record<string, UIDLStateDefinition>, externals: Record<string, ComponentUIDL>, routeDefinitions: UIDLRouteDefinitions, structure: { | ||
chunks: ChunkDefinition[]; | ||
@@ -4,0 +4,0 @@ dependencies: Record<string, UIDLDependency>; |
@@ -27,3 +27,3 @@ var __assign = (this && this.__assign) || function () { | ||
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; | ||
@@ -67,2 +67,3 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (node.type) { | ||
case 'inject': | ||
case 'raw': | ||
@@ -310,3 +311,3 @@ return [2 /*return*/, HASTBuilders.createTextNode(node.content.toString())]; | ||
if (attrValue.type === 'raw') { | ||
HASTUtils.addAttributeToNode(htmlNode, attrKey, String(attrValue.content)); | ||
HASTUtils.addAttributeToNode(htmlNode, attrKey, attrValue.content); | ||
return; | ||
@@ -325,3 +326,3 @@ } | ||
var getValueFromReference = function (key, definitions) { | ||
var usedReferenceValue = definitions[key]; | ||
var usedReferenceValue = definitions[key.includes('.') ? key.split('.')[0] : key]; | ||
if (!usedReferenceValue) { | ||
@@ -333,3 +334,3 @@ throw new HTMLComponentGeneratorError("Definition for ".concat(key, " is missing from ").concat(JSON.stringify(definitions, null, 2))); | ||
} | ||
if (!['string', 'number'].includes(usedReferenceValue === null || usedReferenceValue === void 0 ? void 0 : usedReferenceValue.type)) { | ||
if (!['string', 'number', 'object'].includes(usedReferenceValue === null || usedReferenceValue === void 0 ? void 0 : usedReferenceValue.type)) { | ||
throw new HTMLComponentGeneratorError("Attribute is using dynamic value, but received of type ".concat(JSON.stringify(usedReferenceValue, null, 2))); | ||
@@ -336,0 +337,0 @@ } |
{ | ||
"name": "@teleporthq/teleport-plugin-html-base-component", | ||
"version": "0.27.5-alpha.0", | ||
"version": "0.27.5", | ||
"description": "A plugin for handling the skeleton/baseline of a base html component", | ||
@@ -27,9 +27,9 @@ "author": "teleportHQ", | ||
"dependencies": { | ||
"@teleporthq/teleport-plugin-common": "^0.27.5-alpha.0", | ||
"@teleporthq/teleport-plugin-css": "^0.27.5-alpha.0", | ||
"@teleporthq/teleport-shared": "^0.27.5-alpha.0", | ||
"@teleporthq/teleport-types": "^0.27.5-alpha.0", | ||
"@teleporthq/teleport-uidl-builders": "^0.27.5-alpha.0" | ||
"@teleporthq/teleport-plugin-common": "^0.27.5", | ||
"@teleporthq/teleport-plugin-css": "^0.27.5", | ||
"@teleporthq/teleport-shared": "^0.27.5", | ||
"@teleporthq/teleport-types": "^0.27.5", | ||
"@teleporthq/teleport-uidl-builders": "^0.27.5" | ||
}, | ||
"gitHead": "46bbbd44f6b43dfdf9cfaf1c3428e9ee106eeecd" | ||
"gitHead": "d8869ea13f974bb6c1613b494e8bcb2fbadc5eb7" | ||
} |
@@ -51,2 +51,3 @@ import { | ||
switch (node.type) { | ||
case 'inject': | ||
case 'raw': | ||
@@ -112,3 +113,2 @@ return HASTBuilders.createTextNode(node.content.toString()) | ||
} = node.content | ||
const elementNode = HASTBuilders.createHTMLNode(elementType) | ||
@@ -234,3 +234,2 @@ templatesLookUp[key] = elementNode | ||
const combinedProps = { ...propDefinitions, ...(comp?.propDefinitions || {}) } | ||
const propsForInstance = Object.keys(combinedProps).reduce( | ||
@@ -268,3 +267,2 @@ (acc: Record<string, UIDLPropDefinition>, propKey) => { | ||
) | ||
const elementNode = HASTBuilders.createHTMLNode(StringUtils.camelCaseToDashCase(elementType)) | ||
@@ -416,3 +414,3 @@ lookUpTemplates[key] = elementNode | ||
if (attrValue.type === 'raw') { | ||
HASTUtils.addAttributeToNode(htmlNode, attrKey, String(attrValue.content)) | ||
HASTUtils.addAttributeToNode(htmlNode, attrKey, attrValue.content) | ||
return | ||
@@ -435,3 +433,3 @@ } | ||
): string => { | ||
const usedReferenceValue = definitions[key] | ||
const usedReferenceValue = definitions[key.includes('.') ? key.split('.')[0] : key] | ||
@@ -454,3 +452,3 @@ if (!usedReferenceValue) { | ||
if (!['string', 'number'].includes(usedReferenceValue?.type)) { | ||
if (!['string', 'number', 'object'].includes(usedReferenceValue?.type)) { | ||
throw new HTMLComponentGeneratorError( | ||
@@ -457,0 +455,0 @@ `Attribute is using dynamic value, but received of type ${JSON.stringify( |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
151881
1.93%1490
0.2%