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

@cmpsr/cml

Package Overview
Dependencies
Maintainers
3
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cmpsr/cml - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0-canary-20230710151708

10

lib/getRgxInstance/getRgxInstance.js

@@ -5,6 +5,10 @@ "use strict";

});
exports.getRgxInstance = void 0;
Object.defineProperty(exports, "getRgxInstance", {
enumerable: true,
get: function() {
return getRgxInstance;
}
});
var getRgxInstance = function() {
return new RegExp('{{([^:^{]*):(\\w+)(?:\\((.+)?\\))?(\\[([^\\]]*)?\\])?(?::([^}}]*))?}}', 'g');
return new RegExp("{{([^:^{]*):(\\w+)(?:\\((.+)?\\))?(\\[([^\\]]*)?\\])?(?::([^}}]*))?}}", "g");
};
exports.getRgxInstance = getRgxInstance;

@@ -5,33 +5,15 @@ "use strict";

});
var _getRgxInstance = _interopRequireWildcard(require("./getRgxInstance"));
Object.keys(_getRgxInstance).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _getRgxInstance[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function() {
return _getRgxInstance[key];
_export_star(require("./getRgxInstance"), exports);
function _export_star(from, to) {
Object.keys(from).forEach(function(k) {
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
Object.defineProperty(to, k, {
enumerable: true,
get: function() {
return from[k];
}
});
}
});
});
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};
if (obj != null) {
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
if (desc.get || desc.set) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
}
newObj.default = obj;
return newObj;
}
return from;
}

@@ -5,59 +5,17 @@ "use strict";

});
var _exportNames = {};
var _getRgxInstance = _interopRequireWildcard(require("./getRgxInstance"));
Object.keys(_getRgxInstance).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _getRgxInstance[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function() {
return _getRgxInstance[key];
_export_star(require("./getRgxInstance/index"), exports);
_export_star(require("./replaceCmlPlaceholders/index"), exports);
_export_star(require("./types"), exports);
function _export_star(from, to) {
Object.keys(from).forEach(function(k) {
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
Object.defineProperty(to, k, {
enumerable: true,
get: function() {
return from[k];
}
});
}
});
});
var _replaceCmlPlaceholders = _interopRequireWildcard(require("./replaceCmlPlaceholders"));
Object.keys(_replaceCmlPlaceholders).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _replaceCmlPlaceholders[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function() {
return _replaceCmlPlaceholders[key];
}
});
});
var _types = _interopRequireWildcard(require("./types"));
Object.keys(_types).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _types[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function() {
return _types[key];
}
});
});
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};
if (obj != null) {
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
if (desc.get || desc.set) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
}
newObj.default = obj;
return newObj;
}
return from;
}

@@ -5,33 +5,15 @@ "use strict";

});
var _replaceCmlPlaceholders = _interopRequireWildcard(require("./replaceCmlPlaceholders"));
Object.keys(_replaceCmlPlaceholders).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _replaceCmlPlaceholders[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function() {
return _replaceCmlPlaceholders[key];
_export_star(require("./replaceCmlPlaceholders"), exports);
function _export_star(from, to) {
Object.keys(from).forEach(function(k) {
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
Object.defineProperty(to, k, {
enumerable: true,
get: function() {
return from[k];
}
});
}
});
});
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};
if (obj != null) {
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
if (desc.get || desc.set) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
}
newObj.default = obj;
return newObj;
}
return from;
}

@@ -5,8 +5,13 @@ "use strict";

});
exports.replaceCmlPlaceholders = void 0;
var _getRgxInstance = require("../getRgxInstance");
Object.defineProperty(exports, "replaceCmlPlaceholders", {
enumerable: true,
get: function() {
return replaceCmlPlaceholders;
}
});
var _getRgxInstance = require("../getRgxInstance/index");
var _types = require("../types");
var _mergeDeep = require("../utils/mergeDeep");
var _replaceAll = require("../utils/replaceAll");
function _arrayLikeToArray(arr, len) {
var _mergeDeep = require("../utils/mergeDeep/index");
var _replaceAll = require("../utils/replaceAll/index");
function _array_like_to_array(arr, len) {
if (len == null || len > arr.length) len = arr.length;

@@ -16,6 +21,6 @@ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];

}
function _arrayWithHoles(arr) {
function _array_with_holes(arr) {
if (Array.isArray(arr)) return arr;
}
function _defineProperty(obj, key, value) {
function _define_property(obj, key, value) {
if (key in obj) {

@@ -33,3 +38,3 @@ Object.defineProperty(obj, key, {

}
function _iterableToArrayLimit(arr, i) {
function _iterable_to_array_limit(arr, i) {
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];

@@ -58,6 +63,6 @@ if (_i == null) return;

}
function _nonIterableRest() {
function _non_iterable_rest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _objectSpread(target) {
function _object_spread(target) {
for(var i = 1; i < arguments.length; i++){

@@ -72,3 +77,3 @@ var source = arguments[i] != null ? arguments[i] : {};

ownKeys.forEach(function(key) {
_defineProperty(target, key, source[key]);
_define_property(target, key, source[key]);
});

@@ -78,5 +83,29 @@ }

}
function _objectWithoutProperties(source, excluded) {
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) {
symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
}
keys.push.apply(keys, symbols);
}
return keys;
}
function _object_spread_props(target, source) {
source = source != null ? source : {};
if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function(key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _object_without_properties(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var target = _object_without_properties_loose(source, excluded);
var key, i;

@@ -94,3 +123,3 @@ if (Object.getOwnPropertySymbols) {

}
function _objectWithoutPropertiesLoose(source, excluded) {
function _object_without_properties_loose(source, excluded) {
if (source == null) return {};

@@ -107,12 +136,12 @@ var target = {};

}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
function _sliced_to_array(arr, i) {
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _unsupportedIterableToArray(o, minLen) {
function _unsupported_iterable_to_array(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
if (typeof o === "string") return _array_like_to_array(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}

@@ -122,3 +151,3 @@ var replaceCmlPlaceholders = function(model, values) {

if (model[breakpoint] || values[breakpoint]) {
return _objectSpread({}, acc, _defineProperty({}, breakpoint, replacePropValues(getBreakpointValue(model, breakpoint), mergeValues(values, breakpoint))));
return _object_spread_props(_object_spread({}, acc), _define_property({}, breakpoint, replacePropValues(getBreakpointValue(model, breakpoint), mergeValues(values, breakpoint))));
} else {

@@ -129,8 +158,7 @@ return acc;

};
exports.replaceCmlPlaceholders = replaceCmlPlaceholders;
var replacePropValues = function(mdx) {
var values = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
if (!mdx) return '';
if (!mdx) return "";
var mdxCopy = mdx;
var instanceToGetAllMatches = (0, _getRgxInstance).getRgxInstance();
var instanceToGetAllMatches = (0, _getRgxInstance.getRgxInstance)();
var matches = mdxCopy.match(instanceToGetAllMatches) || [];

@@ -140,7 +168,7 @@ if (matches.length === 0) return mdx;

uniqueMatches.forEach(function(match) {
var patternToGetRgxGroups = (0, _getRgxInstance).getRgxInstance();
var patternToGetRgxGroups = (0, _getRgxInstance.getRgxInstance)();
var rgxGroups = patternToGetRgxGroups.exec(match) || [];
var propName = rgxGroups[1];
var fieldType = rgxGroups[2];
var defaultValue = rgxGroups[6] || '';
var defaultValue = rgxGroups[6] || "";
var propValue = values[propName];

@@ -150,24 +178,24 @@ var newValue = propValue ? propValue : defaultValue;

switch(fieldType){
case 'AiTextGenerator':
case "AiTextGenerator":
searchValue = match;
newValue = '';
newValue = "";
break;
case 'AccordionsGallery':
case 'Action':
case 'Actions':
case 'Bullets':
case 'Carousel':
case 'Column':
case 'Columns':
case 'Container':
case 'Icon':
case 'Image':
case 'Images':
case 'MediaBlock':
case 'Tag':
case 'Text':
case 'TextPairing':
case "AccordionsGallery":
case "Action":
case "Actions":
case "Bullets":
case "Carousel":
case "Column":
case "Columns":
case "Container":
case "Icon":
case "Image":
case "Images":
case "MediaBlock":
case "Tag":
case "Text":
case "TextPairing":
searchValue = match;
if (newValue === 'undefined' || propValue === undefined) {
newValue = '';
if (newValue === "undefined" || propValue === undefined) {
newValue = "";
} else {

@@ -177,23 +205,31 @@ newValue = renderComponent(defaultValue, propValue);

break;
case 'BoxProps':
case 'FlexProps':
case "BoxProps":
case "FlexProps":
searchValue = match;
if (typeof newValue === 'object') {
if (typeof newValue === "object") {
newValue = flatObject(newValue);
}
break;
case 'styling':
case "styling":
searchValue = match;
newValue = applyStyling(newValue, rgxGroups[5]);
break;
case 'boolean':
case 'number':
case "boolean":
case "number":
searchValue = match;
newValue = "{".concat(propValue, "}");
break;
case 'list':
case "json":
searchValue = match;
if (propValue && typeof propValue === "object") {
newValue = "{".concat(JSON.stringify(propValue), "}");
} else {
newValue = "{".concat(propValue, "}");
}
break;
case 'ENV_VAR':
case "list":
searchValue = match;
break;
case "ENV_VAR":
searchValue = match;
newValue = process.env[propName];

@@ -204,3 +240,3 @@ break;

}
mdxCopy = (0, _replaceAll).replaceAll(searchValue, newValue)(mdxCopy);
mdxCopy = (0, _replaceAll.replaceAll)(searchValue, newValue)(mdxCopy);
});

@@ -210,22 +246,22 @@ return replacePropValues(mdxCopy, values);

var renderComponent = function(componentName, props) {
if (typeof props === 'string') {
if (typeof props === "string") {
return "<".concat(componentName, " ").concat(props, "/>");
}
var children = props.children, rest = _objectWithoutProperties(props, [
var children = props.children, rest = _object_without_properties(props, [
"children"
]);
var props1 = flatObject(rest);
var child = Array.isArray(children) ? children.join('') : children;
var child = Array.isArray(children) ? children.join("") : children;
return children ? "<".concat(componentName, " ").concat(props1, ">").concat(child, "</").concat(componentName, ">") : "<".concat(componentName, " ").concat(props1, "/>");
};
var flatObject = function(obj) {
var result = '';
var result = "";
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
try {
for(var _iterator = Object.entries(obj)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
var patternToGetRgxGroups = (0, _getRgxInstance).getRgxInstance();
var isReplaceableValue = typeof value === 'boolean' || typeof value === 'number' || !!patternToGetRgxGroups.exec(value);
var wrapper = isReplaceableValue ? '{' : '"';
var endWrapper = isReplaceableValue ? ' }' : '"';
var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
var patternToGetRgxGroups = (0, _getRgxInstance.getRgxInstance)();
var isReplaceableValue = typeof value === "boolean" || typeof value === "number" || !!patternToGetRgxGroups.exec(value);
var wrapper = isReplaceableValue ? "{" : '"';
var endWrapper = isReplaceableValue ? " }" : '"';
result += "".concat(key, "=").concat(wrapper).concat(value).concat(endWrapper, " ");

@@ -250,8 +286,8 @@ }

var applyStyling = function(text, stylesStr) {
var styles = stylesStr.split(',');
var styles = stylesStr.split(",");
var styleWithValue = styles.reduce(function(prev, curr) {
var ref = _slicedToArray(curr.split('='), 2), prop = ref[0], value = ref[1];
return prev.concat(" ".concat(prop, "=\"").concat(value, "\""));
}, '').trim();
return "<Text as=\"span\" variant=\"inherited\" ".concat(styleWithValue, ">").concat(text, "</Text>");
var _curr_split = _sliced_to_array(curr.split("="), 2), prop = _curr_split[0], value = _curr_split[1];
return prev.concat(" ".concat(prop, '="').concat(value, '"'));
}, "").trim();
return '<Text as="span" variant="inherited" '.concat(styleWithValue, ">").concat(text, "</Text>");
};

@@ -272,3 +308,3 @@ var getBreakpointValue = function(values, breakpoint) {

if (currentValue) {
merged = (0, _mergeDeep).mergeDeep(merged, currentValue);
merged = (0, _mergeDeep.mergeDeep)(merged, currentValue);
}

@@ -275,0 +311,0 @@ }

@@ -5,4 +5,4 @@ export interface Block {

}
export declare type Model = ResponsiveValue<string>;
export declare type PropsValue = ResponsiveValue<Record<string, string | number | boolean | Record<string, string | string[] | number | boolean | number[] | boolean[]>>>;
export type Model = ResponsiveValue<string>;
export type PropsValue = ResponsiveValue<Record<string, string | number | boolean | Record<string, string | string[] | number | boolean | number[] | boolean[]>>>;
export interface ResponsiveValue<T> {

@@ -9,0 +9,0 @@ base?: T;

@@ -5,10 +5,14 @@ "use strict";

});
exports.breakpoints = void 0;
Object.defineProperty(exports, "breakpoints", {
enumerable: true,
get: function() {
return breakpoints;
}
});
var breakpoints = [
'base',
'md',
'lg',
'xl',
'xxl'
"base",
"md",
"lg",
"xl",
"xxl"
];
exports.breakpoints = breakpoints;

@@ -5,33 +5,15 @@ "use strict";

});
var _mergeDeep = _interopRequireWildcard(require("./mergeDeep"));
Object.keys(_mergeDeep).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _mergeDeep[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function() {
return _mergeDeep[key];
_export_star(require("./mergeDeep"), exports);
function _export_star(from, to) {
Object.keys(from).forEach(function(k) {
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
Object.defineProperty(to, k, {
enumerable: true,
get: function() {
return from[k];
}
});
}
});
});
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};
if (obj != null) {
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
if (desc.get || desc.set) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
}
newObj.default = obj;
return newObj;
}
return from;
}

@@ -5,4 +5,9 @@ "use strict";

});
exports.mergeDeep = void 0;
function _defineProperty(obj, key, value) {
Object.defineProperty(exports, "mergeDeep", {
enumerable: true,
get: function() {
return mergeDeep;
}
});
function _define_property(obj, key, value) {
if (key in obj) {

@@ -21,3 +26,3 @@ Object.defineProperty(obj, key, {

var isObject = function(item) {
return item && typeof item === 'object' && !Array.isArray(item);
return item && typeof item === "object" && !Array.isArray(item);
};

@@ -29,6 +34,6 @@ var mergeDeep = function(target, source) {

if (isObject(source[key])) {
if (!(key in target)) Object.assign(output, _defineProperty({}, key, source[key]));
else output[key] = exports.mergeDeep(target[key], source[key]);
if (!(key in target)) Object.assign(output, _define_property({}, key, source[key]));
else output[key] = mergeDeep(target[key], source[key]);
} else {
Object.assign(output, _defineProperty({}, key, source[key]));
Object.assign(output, _define_property({}, key, source[key]));
}

@@ -39,2 +44,1 @@ });

};
exports.mergeDeep = mergeDeep;

@@ -5,33 +5,15 @@ "use strict";

});
var _replaceAll = _interopRequireWildcard(require("./replaceAll"));
Object.keys(_replaceAll).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _replaceAll[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function() {
return _replaceAll[key];
_export_star(require("./replaceAll"), exports);
function _export_star(from, to) {
Object.keys(from).forEach(function(k) {
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
Object.defineProperty(to, k, {
enumerable: true,
get: function() {
return from[k];
}
});
}
});
});
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};
if (obj != null) {
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
if (desc.get || desc.set) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
}
newObj.default = obj;
return newObj;
}
return from;
}

@@ -5,11 +5,15 @@ "use strict";

});
exports.replaceAll = void 0;
Object.defineProperty(exports, "replaceAll", {
enumerable: true,
get: function() {
return replaceAll;
}
});
var replaceAll = function(searchValue, replaceValue) {
return function(str) {
return str.replace(new RegExp(escapeRegExp(searchValue), 'g'), replaceValue);
return str.replace(new RegExp(escapeRegExp(searchValue), "g"), replaceValue);
};
};
exports.replaceAll = replaceAll;
var escapeRegExp = function(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
};

@@ -10,3 +10,3 @@ {

},
"version": "0.5.0",
"version": "0.6.0-canary-20230710151708",
"author": "Takeichi Kanzaki Cabrera <me@tkanzakic.com>",

@@ -35,4 +35,4 @@ "license": "MIT",

"@types/jest": "^27.0.2",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"swc-loader": "^0.1.15"

@@ -39,0 +39,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc