New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@teleporthq/teleport-uidl-resolver

Package Overview
Dependencies
Maintainers
4
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@teleporthq/teleport-uidl-resolver - npm Package Compare versions

Comparing version

to
0.23.4

dist/cjs/resolvers/embed-lottie-node/index.d.ts

22

dist/cjs/html-mapping.js

@@ -26,2 +26,24 @@ "use strict";

},
'html-node': {
elementType: 'dangerous-html',
dependency: {
type: 'package',
path: 'dangerous-html',
version: '0.1.11',
meta: {
importJustPath: true,
},
},
},
'lottie-node': {
elementType: 'lottie-player',
dependency: {
type: 'package',
path: '@lottiefiles/lottie-player',
version: '1.6.0',
meta: {
importJustPath: true,
},
},
},
textinput: {

@@ -28,0 +50,0 @@ elementType: 'input',

6

dist/cjs/resolver.js

@@ -42,2 +42,3 @@ "use strict";

var referenced_styles_1 = require("./resolvers/referenced-styles");
var embed_node_1 = require("./resolvers/embed-node");
/**

@@ -72,7 +73,8 @@ * The resolver takes the input UIDL and converts all the abstract node types into

var uidl = teleport_shared_1.UIDLUtils.cloneObject(input);
uidl.styleSetDefinitions = (0, style_set_definitions_1.resolveStyleSetDefinitions)(input.styleSetDefinitions || {});
uidl.styleSetDefinitions = (0, style_set_definitions_1.resolveStyleSetDefinitions)(input.styleSetDefinitions, newOptions);
teleport_shared_1.UIDLUtils.setFriendlyOutputOptions(uidl);
utils.checkForIllegalNames(uidl, mapping);
(0, abilities_1.resolveAbilities)(uidl, newOptions);
(0, referenced_styles_1.resolveReferencedStyle)(uidl);
(0, referenced_styles_1.resolveReferencedStyle)(uidl, newOptions);
(0, embed_node_1.resolveHtmlNode)(uidl, newOptions);
// TODO: Rename into apply mappings

@@ -79,0 +81,0 @@ utils.resolveNode(uidl.node, newOptions);

@@ -1,2 +0,2 @@

import { ComponentUIDL } from '@teleporthq/teleport-types';
export declare const resolveReferencedStyle: (input: ComponentUIDL) => void;
import { ComponentUIDL, GeneratorOptions } from '@teleporthq/teleport-types';
export declare const resolveReferencedStyle: (input: ComponentUIDL, options: GeneratorOptions) => void;

@@ -21,21 +21,22 @@ "use strict";

exports.resolveReferencedStyle = void 0;
var resolveReferencedStyle = function (input) {
input.node = sortReferencedStylesOnElement(input.node);
var utils_1 = require("../../utils");
var resolveReferencedStyle = function (input, options) {
input.node = sortReferencedStylesOnElement(input.node, options);
};
exports.resolveReferencedStyle = resolveReferencedStyle;
var sortReferencedStylesOnElement = function (node) {
var sortReferencedStylesOnElement = function (node, options) {
var _a, _b;
var _c = node.content.referencedStyles, referencedStyles = _c === void 0 ? {} : _c;
if (Object.keys(referencedStyles).length > 0) {
node.content.referencedStyles = sortByStateAndCondition(referencedStyles);
node.content.referencedStyles = sortByStateAndCondition(referencedStyles, options);
}
(_b = (_a = node.content) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.map(function (child) {
if (child.type === 'element') {
sortReferencedStylesOnElement(child);
sortReferencedStylesOnElement(child, options);
}
if (child.type === 'repeat') {
sortReferencedStylesOnElement(child.content.node);
sortReferencedStylesOnElement(child.content.node, options);
}
if (child.type === 'conditional' && child.content.node.type === 'element') {
sortReferencedStylesOnElement(child.content.node);
sortReferencedStylesOnElement(child.content.node, options);
}

@@ -46,3 +47,3 @@ return child;

};
var sortByStateAndCondition = function (styles) {
var sortByStateAndCondition = function (styles, options) {
if (Object.keys(styles).length === 0) {

@@ -61,6 +62,6 @@ return {};

if (styleRef.content.conditions[0].conditionType === 'screen-size') {
allMediaRelatedStyles[styleId] = styleRef;
allMediaRelatedStyles[styleId] = __assign(__assign({}, styleRef), { content: __assign(__assign({}, styleRef.content), { styles: (0, utils_1.prefixAssetURLs)(styleRef.content.styles, (options === null || options === void 0 ? void 0 : options.assetsPrefix) || '') }) });
}
if (styleRef.content.conditions[0].conditionType === 'element-state') {
allElementStateRelatedStyles[styleId] = styleRef;
allElementStateRelatedStyles[styleId] = __assign(__assign({}, styleRef), { content: __assign(__assign({}, styleRef.content), { styles: (0, utils_1.prefixAssetURLs)(styleRef.content.styles, (options === null || options === void 0 ? void 0 : options.assetsPrefix) || '') }) });
}

@@ -67,0 +68,0 @@ }

@@ -1,2 +0,2 @@

import { UIDLStyleSetDefinition } from '@teleporthq/teleport-types';
export declare const resolveStyleSetDefinitions: (styleSets: Record<string, UIDLStyleSetDefinition>) => Record<string, UIDLStyleSetDefinition>;
import { GeneratorOptions, UIDLStyleSetDefinition } from '@teleporthq/teleport-types';
export declare const resolveStyleSetDefinitions: (styleSets: Record<string, UIDLStyleSetDefinition>, options: GeneratorOptions) => Record<string, UIDLStyleSetDefinition>;

@@ -28,3 +28,5 @@ "use strict";

exports.resolveStyleSetDefinitions = void 0;
var resolveStyleSetDefinitions = function (styleSets) {
var utils_1 = require("../../utils");
var resolveStyleSetDefinitions = function (styleSets, options) {
if (styleSets === void 0) { styleSets = {}; }
return Object.keys(styleSets).reduce(function (acc, styleId) {

@@ -34,12 +36,16 @@ var styleRef = styleSets[styleId];

if (conditions.length === 0) {
acc[styleId] = styleRef;
acc[styleId] = __assign(__assign({}, styleRef), { content: (0, utils_1.prefixAssetURLs)(styleRef.content, (options === null || options === void 0 ? void 0 : options.assetsPrefix) || '') });
return acc;
}
var mediaConditions = conditions
.filter(function (item) { return item.type === 'screen-size'; })
.sort(function (a, b) {
return b.meta.maxWidth - a.meta.maxWidth;
});
var elementStateConditions = conditions.filter(function (item) { return item.type === 'element-state'; });
acc[styleId] = __assign(__assign({}, styleRef), { conditions: __spreadArray(__spreadArray([], elementStateConditions, true), mediaConditions, true) });
var _b = conditions.reduce(function (_a, item) {
var media = _a[0], state = _a[1];
if (item.type === 'screen-size') {
media.push(__assign(__assign({}, item), { content: (0, utils_1.prefixAssetURLs)(item.content, (options === null || options === void 0 ? void 0 : options.assetsPrefix) || '') }));
}
if (item.type === 'element-state') {
state.push(__assign(__assign({}, item), { content: (0, utils_1.prefixAssetURLs)(item.content, (options === null || options === void 0 ? void 0 : options.assetsPrefix) || '') }));
}
return [media, state];
}, [[], []]), mediaStyles = _b[0], elementStates = _b[1];
acc[styleId] = __assign(__assign({}, styleRef), { conditions: __spreadArray(__spreadArray([], elementStates, true), mediaStyles.sort(function (a, b) { return b.meta.maxWidth - a.meta.maxWidth; }), true) });
return acc;

@@ -46,0 +52,0 @@ }, {});

@@ -1,2 +0,2 @@

import { UIDLElement, UIDLNode, Mapping, GeneratorOptions, ComponentUIDL } from '@teleporthq/teleport-types';
import { UIDLElement, UIDLNode, Mapping, GeneratorOptions, ComponentUIDL, UIDLStyleSetTokenReference, UIDLStaticValue, UIDLDynamicReference } from '@teleporthq/teleport-types';
declare type ElementsLookup = Record<string, {

@@ -15,3 +15,9 @@ count: number;

export declare const ensureDataSourceUniqueness: (node: UIDLNode) => void;
/**
* Prefixes all urls inside the style object with the assetsPrefix
* @param style the style object on the current node
* @param assetsPrefix a string representing the asset prefix
*/
export declare const prefixAssetURLs: <T extends UIDLDynamicReference | UIDLStaticValue | UIDLStyleSetTokenReference>(style: Record<string, T>, assetsPrefix: string) => Record<string, T>;
export declare const checkForIllegalNames: (uidl: ComponentUIDL, mapping: Mapping) => void;
export {};

@@ -26,3 +26,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.checkForIllegalNames = exports.ensureDataSourceUniqueness = exports.createNodesLookup = exports.generateUniqueKeys = exports.resolveChildren = exports.resolveElement = exports.resolveNode = exports.removeIgnoredNodes = exports.resolveMetaTags = exports.mergeMappings = void 0;
exports.checkForIllegalNames = exports.prefixAssetURLs = exports.ensureDataSourceUniqueness = exports.createNodesLookup = exports.generateUniqueKeys = exports.resolveChildren = exports.resolveElement = exports.resolveNode = exports.removeIgnoredNodes = exports.resolveMetaTags = exports.mergeMappings = void 0;
var teleport_shared_1 = require("@teleporthq/teleport-shared");

@@ -106,3 +106,3 @@ var deepmerge_1 = __importDefault(require("deepmerge"));

if (originalElement.style && assetsPrefix) {
originalElement.style = prefixAssetURLs(originalElement.style, assetsPrefix);
originalElement.style = (0, exports.prefixAssetURLs)(originalElement.style, assetsPrefix);
}

@@ -326,2 +326,3 @@ // Map events separately

};
exports.prefixAssetURLs = prefixAssetURLs;
var resolveAttributes = function (mappedAttrs, uidlAttrs) {

@@ -328,0 +329,0 @@ // We gather the results here uniting the mapped attributes and the uidl attributes.

@@ -23,2 +23,24 @@ export var HTMLMapping = {

},
'html-node': {
elementType: 'dangerous-html',
dependency: {
type: 'package',
path: 'dangerous-html',
version: '0.1.11',
meta: {
importJustPath: true,
},
},
},
'lottie-node': {
elementType: 'lottie-player',
dependency: {
type: 'package',
path: '@lottiefiles/lottie-player',
version: '1.6.0',
meta: {
importJustPath: true,
},
},
},
textinput: {

@@ -25,0 +47,0 @@ elementType: 'input',

@@ -17,2 +17,3 @@ var __assign = (this && this.__assign) || function () {

import { resolveReferencedStyle } from './resolvers/referenced-styles';
import { resolveHtmlNode } from './resolvers/embed-node';
/**

@@ -47,7 +48,8 @@ * The resolver takes the input UIDL and converts all the abstract node types into

var uidl = UIDLUtils.cloneObject(input);
uidl.styleSetDefinitions = resolveStyleSetDefinitions(input.styleSetDefinitions || {});
uidl.styleSetDefinitions = resolveStyleSetDefinitions(input.styleSetDefinitions, newOptions);
UIDLUtils.setFriendlyOutputOptions(uidl);
utils.checkForIllegalNames(uidl, mapping);
resolveAbilities(uidl, newOptions);
resolveReferencedStyle(uidl);
resolveReferencedStyle(uidl, newOptions);
resolveHtmlNode(uidl, newOptions);
// TODO: Rename into apply mappings

@@ -54,0 +56,0 @@ utils.resolveNode(uidl.node, newOptions);

@@ -1,2 +0,2 @@

import { ComponentUIDL } from '@teleporthq/teleport-types';
export declare const resolveReferencedStyle: (input: ComponentUIDL) => void;
import { ComponentUIDL, GeneratorOptions } from '@teleporthq/teleport-types';
export declare const resolveReferencedStyle: (input: ComponentUIDL, options: GeneratorOptions) => void;

@@ -18,20 +18,21 @@ /*

};
export var resolveReferencedStyle = function (input) {
input.node = sortReferencedStylesOnElement(input.node);
import { prefixAssetURLs } from '../../utils';
export var resolveReferencedStyle = function (input, options) {
input.node = sortReferencedStylesOnElement(input.node, options);
};
var sortReferencedStylesOnElement = function (node) {
var sortReferencedStylesOnElement = function (node, options) {
var _a, _b;
var _c = node.content.referencedStyles, referencedStyles = _c === void 0 ? {} : _c;
if (Object.keys(referencedStyles).length > 0) {
node.content.referencedStyles = sortByStateAndCondition(referencedStyles);
node.content.referencedStyles = sortByStateAndCondition(referencedStyles, options);
}
(_b = (_a = node.content) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.map(function (child) {
if (child.type === 'element') {
sortReferencedStylesOnElement(child);
sortReferencedStylesOnElement(child, options);
}
if (child.type === 'repeat') {
sortReferencedStylesOnElement(child.content.node);
sortReferencedStylesOnElement(child.content.node, options);
}
if (child.type === 'conditional' && child.content.node.type === 'element') {
sortReferencedStylesOnElement(child.content.node);
sortReferencedStylesOnElement(child.content.node, options);
}

@@ -42,3 +43,3 @@ return child;

};
var sortByStateAndCondition = function (styles) {
var sortByStateAndCondition = function (styles, options) {
if (Object.keys(styles).length === 0) {

@@ -57,6 +58,6 @@ return {};

if (styleRef.content.conditions[0].conditionType === 'screen-size') {
allMediaRelatedStyles[styleId] = styleRef;
allMediaRelatedStyles[styleId] = __assign(__assign({}, styleRef), { content: __assign(__assign({}, styleRef.content), { styles: prefixAssetURLs(styleRef.content.styles, (options === null || options === void 0 ? void 0 : options.assetsPrefix) || '') }) });
}
if (styleRef.content.conditions[0].conditionType === 'element-state') {
allElementStateRelatedStyles[styleId] = styleRef;
allElementStateRelatedStyles[styleId] = __assign(__assign({}, styleRef), { content: __assign(__assign({}, styleRef.content), { styles: prefixAssetURLs(styleRef.content.styles, (options === null || options === void 0 ? void 0 : options.assetsPrefix) || '') }) });
}

@@ -63,0 +64,0 @@ }

@@ -1,2 +0,2 @@

import { UIDLStyleSetDefinition } from '@teleporthq/teleport-types';
export declare const resolveStyleSetDefinitions: (styleSets: Record<string, UIDLStyleSetDefinition>) => Record<string, UIDLStyleSetDefinition>;
import { GeneratorOptions, UIDLStyleSetDefinition } from '@teleporthq/teleport-types';
export declare const resolveStyleSetDefinitions: (styleSets: Record<string, UIDLStyleSetDefinition>, options: GeneratorOptions) => Record<string, UIDLStyleSetDefinition>;

@@ -25,3 +25,5 @@ /*

};
export var resolveStyleSetDefinitions = function (styleSets) {
import { prefixAssetURLs } from '../../utils';
export var resolveStyleSetDefinitions = function (styleSets, options) {
if (styleSets === void 0) { styleSets = {}; }
return Object.keys(styleSets).reduce(function (acc, styleId) {

@@ -31,12 +33,16 @@ var styleRef = styleSets[styleId];

if (conditions.length === 0) {
acc[styleId] = styleRef;
acc[styleId] = __assign(__assign({}, styleRef), { content: prefixAssetURLs(styleRef.content, (options === null || options === void 0 ? void 0 : options.assetsPrefix) || '') });
return acc;
}
var mediaConditions = conditions
.filter(function (item) { return item.type === 'screen-size'; })
.sort(function (a, b) {
return b.meta.maxWidth - a.meta.maxWidth;
});
var elementStateConditions = conditions.filter(function (item) { return item.type === 'element-state'; });
acc[styleId] = __assign(__assign({}, styleRef), { conditions: __spreadArray(__spreadArray([], elementStateConditions, true), mediaConditions, true) });
var _b = conditions.reduce(function (_a, item) {
var media = _a[0], state = _a[1];
if (item.type === 'screen-size') {
media.push(__assign(__assign({}, item), { content: prefixAssetURLs(item.content, (options === null || options === void 0 ? void 0 : options.assetsPrefix) || '') }));
}
if (item.type === 'element-state') {
state.push(__assign(__assign({}, item), { content: prefixAssetURLs(item.content, (options === null || options === void 0 ? void 0 : options.assetsPrefix) || '') }));
}
return [media, state];
}, [[], []]), mediaStyles = _b[0], elementStates = _b[1];
acc[styleId] = __assign(__assign({}, styleRef), { conditions: __spreadArray(__spreadArray([], elementStates, true), mediaStyles.sort(function (a, b) { return b.meta.maxWidth - a.meta.maxWidth; }), true) });
return acc;

@@ -43,0 +49,0 @@ }, {});

@@ -1,2 +0,2 @@

import { UIDLElement, UIDLNode, Mapping, GeneratorOptions, ComponentUIDL } from '@teleporthq/teleport-types';
import { UIDLElement, UIDLNode, Mapping, GeneratorOptions, ComponentUIDL, UIDLStyleSetTokenReference, UIDLStaticValue, UIDLDynamicReference } from '@teleporthq/teleport-types';
declare type ElementsLookup = Record<string, {

@@ -15,3 +15,9 @@ count: number;

export declare const ensureDataSourceUniqueness: (node: UIDLNode) => void;
/**
* Prefixes all urls inside the style object with the assetsPrefix
* @param style the style object on the current node
* @param assetsPrefix a string representing the asset prefix
*/
export declare const prefixAssetURLs: <T extends UIDLDynamicReference | UIDLStaticValue | UIDLStyleSetTokenReference>(style: Record<string, T>, assetsPrefix: string) => Record<string, T>;
export declare const checkForIllegalNames: (uidl: ComponentUIDL, mapping: Mapping) => void;
export {};

@@ -273,3 +273,3 @@ var __assign = (this && this.__assign) || function () {

*/
var prefixAssetURLs = function (style, assetsPrefix) {
export var prefixAssetURLs = function (style, assetsPrefix) {
// iterate through all the style keys

@@ -276,0 +276,0 @@ return Object.keys(style).reduce(function (acc, styleKey) {

{
"name": "@teleporthq/teleport-uidl-resolver",
"version": "0.23.3",
"version": "0.23.4",
"description": "A small package that handles the transition from UIDL to HTML elements and has support for custom mappings.",

@@ -32,3 +32,3 @@ "author": "teleportHQ",

},
"gitHead": "c3886e6f17949d4d130429cf531d3b6ff7b9e176"
"gitHead": "0a976d647a2515cbe4ab2156cb93f96f7d3e07e0"
}

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

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