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.3

__tests__/embed-lottie-node/index.ts

11

dist/cjs/html-mapping.js

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

},
'html-node': {
elementType: 'dangerous-html',
dependency: {
type: 'package',
path: 'dangerous-html',
version: '0.1.11',
meta: {
importJustPath: true,
},
},
},
textinput: {

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

6

dist/cjs/resolver.js

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

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

@@ -73,8 +72,7 @@ * 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, newOptions);
uidl.styleSetDefinitions = (0, style_set_definitions_1.resolveStyleSetDefinitions)(input.styleSetDefinitions || {});
teleport_shared_1.UIDLUtils.setFriendlyOutputOptions(uidl);
utils.checkForIllegalNames(uidl, mapping);
(0, abilities_1.resolveAbilities)(uidl, newOptions);
(0, referenced_styles_1.resolveReferencedStyle)(uidl, newOptions);
(0, html_node_1.resolveHtmlNode)(uidl, newOptions);
(0, referenced_styles_1.resolveReferencedStyle)(uidl);
// TODO: Rename into apply mappings

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

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

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

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

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

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

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

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

if (styleRef.content.conditions[0].conditionType === 'screen-size') {
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) || '') }) });
allMediaRelatedStyles[styleId] = styleRef;
}
if (styleRef.content.conditions[0].conditionType === 'element-state') {
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) || '') }) });
allElementStateRelatedStyles[styleId] = styleRef;
}

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

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

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

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

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

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

if (conditions.length === 0) {
acc[styleId] = __assign(__assign({}, styleRef), { content: (0, utils_1.prefixAssetURLs)(styleRef.content, (options === null || options === void 0 ? void 0 : options.assetsPrefix) || '') });
acc[styleId] = styleRef;
return acc;
}
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) });
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) });
return acc;

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

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

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

@@ -15,9 +15,3 @@ 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 UIDLStaticValue | UIDLDynamicReference | 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.prefixAssetURLs = exports.ensureDataSourceUniqueness = exports.createNodesLookup = exports.generateUniqueKeys = exports.resolveChildren = exports.resolveElement = exports.resolveNode = exports.removeIgnoredNodes = exports.resolveMetaTags = exports.mergeMappings = void 0;
exports.checkForIllegalNames = 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 = (0, exports.prefixAssetURLs)(originalElement.style, assetsPrefix);
originalElement.style = prefixAssetURLs(originalElement.style, assetsPrefix);
}

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

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

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

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

},
'html-node': {
elementType: 'dangerous-html',
dependency: {
type: 'package',
path: 'dangerous-html',
version: '0.1.11',
meta: {
importJustPath: true,
},
},
},
textinput: {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

if (conditions.length === 0) {
acc[styleId] = __assign(__assign({}, styleRef), { content: prefixAssetURLs(styleRef.content, (options === null || options === void 0 ? void 0 : options.assetsPrefix) || '') });
acc[styleId] = styleRef;
return acc;
}
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) });
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) });
return acc;

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

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

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

@@ -15,9 +15,3 @@ 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 UIDLStaticValue | UIDLDynamicReference | 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 () {

*/
export var prefixAssetURLs = function (style, assetsPrefix) {
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.2",
"version": "0.23.3",
"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": "4fbd5057b0aaa1b2075c467f08798b39745618e1"
"gitHead": "c3886e6f17949d4d130429cf531d3b6ff7b9e176"
}

@@ -36,2 +36,13 @@ import { Mapping } from '@teleporthq/teleport-types'

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

@@ -38,0 +49,0 @@ elementType: 'input',

@@ -7,3 +7,3 @@ import * as utils from './utils'

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

@@ -10,0 +10,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

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