Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jarle

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jarle - npm Package Compare versions

Comparing version 3.0.0-beta.0 to 3.0.0-beta.1

65

esm/CodeBlock.js
const _excluded = ["code", "theme", "language", "lineNumbers"];
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }

@@ -7,8 +9,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }

function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import { Highlight, Prism } from 'prism-react-renderer';
import React from 'react';
import LineNumber from './LineNumber.js';
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
function addErrorHighlight(props, index, errorLocation) {

@@ -26,17 +26,19 @@ if (index + 1 === (errorLocation === null || errorLocation === void 0 ? void 0 : errorLocation.line)) {

getLineNumbers
}) => /*#__PURE__*/React.createElement(React.Fragment, null, tokens.map((line, i) =>
/*#__PURE__*/
// eslint-disable-next-line react/no-array-index-key
React.createElement("div", addErrorHighlight(getLineProps({
line,
key: String(i)
}), i, errorLocation), getLineNumbers === null || getLineNumbers === void 0 ? void 0 : getLineNumbers(i + 1), line.map((token, ii) =>
/*#__PURE__*/
// eslint-disable-next-line react/no-array-index-key
React.createElement("span", _extends({
key: ii
}, getTokenProps({
token,
key: String(ii)
})))))));
}) => /*#__PURE__*/_jsx(_Fragment, {
children: tokens.map((line, i) =>
/*#__PURE__*/
// eslint-disable-next-line react/no-array-index-key
_jsxs("div", _objectSpread(_objectSpread({}, addErrorHighlight(getLineProps({
line,
key: String(i)
}), i, errorLocation)), {}, {
children: [getLineNumbers === null || getLineNumbers === void 0 ? void 0 : getLineNumbers(i + 1), line.map((token, ii) =>
/*#__PURE__*/
// eslint-disable-next-line react/no-array-index-key
_jsx("span", _objectSpread({}, getTokenProps({
token,
key: String(ii)
})), ii))]
})))
});
function CodeBlock(_ref) {

@@ -51,17 +53,22 @@ let {

const style = typeof (theme === null || theme === void 0 ? void 0 : theme.plain) === 'object' ? theme.plain : {};
const getLineNumbers = lineNumbers ? num => /*#__PURE__*/React.createElement(LineNumber, {
theme: theme
}, num) : undefined;
return /*#__PURE__*/React.createElement(Highlight, {
const getLineNumbers = lineNumbers ? num => /*#__PURE__*/_jsx(LineNumber, {
theme: theme,
children: num
}) : undefined;
return /*#__PURE__*/_jsx(Highlight, {
theme: theme,
prism: Prism,
code: code.trim(),
language: language
}, hl => /*#__PURE__*/React.createElement("pre", {
className: `${props.className || ''} ${hl.className}`,
style: _objectSpread(_objectSpread(_objectSpread({}, props.style), style), hl.style)
}, /*#__PURE__*/React.createElement("code", null, mapTokens(_objectSpread(_objectSpread({}, hl), {}, {
getLineNumbers
})))));
language: language,
children: hl => /*#__PURE__*/_jsx("pre", {
className: `${props.className || ''} ${hl.className}`,
style: _objectSpread(_objectSpread(_objectSpread({}, props.style), style), hl.style),
children: /*#__PURE__*/_jsx("code", {
children: mapTokens(_objectSpread(_objectSpread({}, hl), {}, {
getLineNumbers
}))
})
})
});
}
export default CodeBlock;

@@ -13,2 +13,3 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }

import LineNumber from './LineNumber.js';
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
let uid = 0;

@@ -123,20 +124,22 @@ function useStateFromProp(prop) {

const errorLocation = (error === null || error === void 0 ? void 0 : error.location) || (error === null || error === void 0 ? void 0 : error.loc);
const highlight = useCallback(value => /*#__PURE__*/React.createElement(Highlight, {
const highlight = useCallback(value => /*#__PURE__*/_jsx(Highlight, {
theme: userTheme,
prism: Prism,
code: value,
language: language
}, hl => mapTokens(_objectSpread(_objectSpread({}, hl), {}, {
lineNumbers,
theme: userTheme,
errorLocation,
getLineNumbers: line => lineNumbers ? /*#__PURE__*/React.createElement(LineNumber, {
style: {
position: 'absolute',
transform: 'translateX(-100%)',
left: 0
},
theme: userTheme
}, line) : null
}))), [userTheme, lineNumbers, language, errorLocation]);
language: language,
children: hl => mapTokens(_objectSpread(_objectSpread({}, hl), {}, {
lineNumbers,
theme: userTheme,
errorLocation,
getLineNumbers: line => lineNumbers ? /*#__PURE__*/_jsx(LineNumber, {
style: {
position: 'absolute',
transform: 'translateX(-100%)',
left: 0
},
theme: userTheme,
children: line
}) : null
}))
}), [userTheme, lineNumbers, language, errorLocation]);
const baseTheme = _objectSpread(_objectSpread({

@@ -146,39 +149,51 @@ whiteSpace: 'pre',

}, (userTheme === null || userTheme === void 0 ? void 0 : userTheme.plain) || {}), style);
return /*#__PURE__*/React.createElement("div", {
return /*#__PURE__*/_jsxs("div", {
ref: ref,
className: `${className || ''} __jarle`,
style: _objectSpread({}, baseTheme)
}, /*#__PURE__*/React.createElement("div", {
className: "line-numbers"
}, lineNumbers && (code || '').split(/\n/g).map((_, i) => /*#__PURE__*/React.createElement(LineNumber, {
key: i,
theme: userTheme,
className: i + 1 === (errorLocation === null || errorLocation === void 0 ? void 0 : errorLocation.line) && 'token-line-error',
style: {
display: 'block'
}
}, /*#__PURE__*/React.createElement("span", {
style: {
visibility: 'hidden'
}
}, i + 1)))), /*#__PURE__*/React.createElement(SimpleCodeEditor, {
value: code || '',
onFocus: handleFocus,
onBlur: handleBlur,
onKeyDown: handleKeyDown,
onMouseDown: handleMouseDown,
onValueChange: setCode,
highlight: highlight,
ignoreTabKey: ignoreTab,
"aria-describedby": id,
"aria-label": "Example code editor",
style: {
overflow: 'visible'
}
}), visible && (keyboardFocused || !ignoreTab) && /*#__PURE__*/React.createElement(Info, {
id: id,
"aria-live": "polite",
srOnly: _infoSrOnly
}, ignoreTab ? /*#__PURE__*/React.createElement(React.Fragment, null, "Press ", /*#__PURE__*/React.createElement("kbd", null, "enter"), " or type a key to enable tab-to-indent") : /*#__PURE__*/React.createElement(React.Fragment, null, "Press ", /*#__PURE__*/React.createElement("kbd", null, "esc"), " to disable tab-to-indent")));
style: _objectSpread({}, baseTheme),
children: [/*#__PURE__*/_jsx("div", {
className: "line-numbers",
children: lineNumbers && (code || '').split(/\n/g).map((_, i) => /*#__PURE__*/_jsx(LineNumber, {
theme: userTheme,
className: i + 1 === (errorLocation === null || errorLocation === void 0 ? void 0 : errorLocation.line) && 'token-line-error',
style: {
display: 'block'
},
children: /*#__PURE__*/_jsx("span", {
style: {
visibility: 'hidden'
},
children: i + 1
})
}, i))
}), /*#__PURE__*/_jsx(SimpleCodeEditor, {
value: code || '',
onFocus: handleFocus,
onBlur: handleBlur,
onKeyDown: handleKeyDown,
onMouseDown: handleMouseDown,
onValueChange: setCode,
highlight: highlight,
ignoreTabKey: ignoreTab,
"aria-describedby": id,
"aria-label": "Example code editor",
style: {
overflow: 'visible'
}
}), visible && (keyboardFocused || !ignoreTab) && /*#__PURE__*/_jsx(Info, {
id: id,
"aria-live": "polite",
srOnly: _infoSrOnly,
children: ignoreTab ? /*#__PURE__*/_jsxs(_Fragment, {
children: ["Press ", /*#__PURE__*/_jsx("kbd", {
children: "enter"
}), " or type a key to enable tab-to-indent"]
}) : /*#__PURE__*/_jsxs(_Fragment, {
children: ["Press ", /*#__PURE__*/_jsx("kbd", {
children: "esc"
}), " to disable tab-to-indent"]
})
})]
});
});
export default Editor;

@@ -0,1 +1,6 @@

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import React from 'react';

@@ -7,5 +12,8 @@ import { useError } from './Provider.js';

*/
import { jsx as _jsx } from "react/jsx-runtime";
export default function Error(props) {
const error = useError();
return error ? /*#__PURE__*/React.createElement("pre", props, error.toString()) : null;
return error ? /*#__PURE__*/_jsx("pre", _objectSpread(_objectSpread({}, props), {}, {
children: error.toString()
})) : null;
}
import React from 'react';
import { Context } from './Provider.js';
import { jsx as _jsx } from "react/jsx-runtime";
class CodeLiveErrorBoundary extends React.Component {

@@ -11,3 +12,3 @@ componentDidCatch(error) {

} = this.props;
return typeof Element === 'function' ? /*#__PURE__*/React.createElement(Element, null) : Element;
return typeof Element === 'function' ? /*#__PURE__*/_jsx(Element, {}) : Element;
}

@@ -14,0 +15,0 @@ }

const _excluded = ["srOnly"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }

@@ -11,2 +10,3 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }

import React from 'react';
import { jsx as _jsx } from "react/jsx-runtime";
const srOnlyStyle = {

@@ -26,3 +26,3 @@ clip: 'rect(1px, 1px, 1px, 1px)',

props = _objectWithoutProperties(_ref, _excluded);
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({}, props), {}, {
style: _objectSpread({

@@ -29,0 +29,0 @@ pointerEvents: 'none',

@@ -7,2 +7,3 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }

import React from 'react';
import { jsx as _jsx } from "react/jsx-runtime";
const lineNumberStyle = {

@@ -20,8 +21,9 @@ textAlign: 'right',

}) {
return /*#__PURE__*/React.createElement("span", {
return /*#__PURE__*/_jsx("span", {
"aria-hidden": true,
className: `${className || ''} line-number`,
style: theme ? _objectSpread(_objectSpread(_objectSpread({}, style), lineNumberStyle), theme.lineNumber) : undefined
}, children);
style: theme ? _objectSpread(_objectSpread(_objectSpread({}, style), lineNumberStyle), theme.lineNumber) : undefined,
children: children
});
}
export default LineNumber;
const _excluded = ["className", "showLastValid"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }

@@ -16,2 +15,3 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }

*/
import { jsx as _jsx } from "react/jsx-runtime";
const Preview = _ref => {

@@ -37,9 +37,11 @@ let {

// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events
React.createElement("div", _extends({
_jsx("div", _objectSpread(_objectSpread({
className: className,
onClick: handleClick
}, previewProps), /*#__PURE__*/React.createElement(ErrorBoundary, {
element: element
}, previewProps), {}, {
children: /*#__PURE__*/_jsx(ErrorBoundary, {
element: element
})
}));
};
export default Preview;

@@ -13,2 +13,3 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }

// try and match render() calls with arguments to avoid false positives with class components
import { jsx as _jsx } from "react/jsx-runtime";
const hasRenderCall = code => !!code.match(/render\((?!\s*\))/gm);

@@ -262,5 +263,6 @@ const prettierComment = /(\{\s*\/\*\s+prettier-ignore\s+\*\/\s*\})|(\/\/\s+prettier-ignore)/gim;

}), [initialCompiledCode, element, error, handleChange, language, theme]);
return /*#__PURE__*/React.createElement(Context.Provider, {
value: context
}, children);
return /*#__PURE__*/_jsx(Context.Provider, {
value: context,
children: children
});
}

@@ -10,4 +10,7 @@ "use strict";

var _LineNumber = _interopRequireDefault(require("./LineNumber.js"));
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["code", "theme", "language", "lineNumbers"];
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }

@@ -18,5 +21,2 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }

function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function addErrorHighlight(props, index, errorLocation) {

@@ -34,17 +34,19 @@ if (index + 1 === (errorLocation === null || errorLocation === void 0 ? void 0 : errorLocation.line)) {

getLineNumbers
}) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, tokens.map((line, i) =>
/*#__PURE__*/
// eslint-disable-next-line react/no-array-index-key
_react.default.createElement("div", addErrorHighlight(getLineProps({
line,
key: String(i)
}), i, errorLocation), getLineNumbers === null || getLineNumbers === void 0 ? void 0 : getLineNumbers(i + 1), line.map((token, ii) =>
/*#__PURE__*/
// eslint-disable-next-line react/no-array-index-key
_react.default.createElement("span", _extends({
key: ii
}, getTokenProps({
token,
key: String(ii)
})))))));
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
children: tokens.map((line, i) =>
/*#__PURE__*/
// eslint-disable-next-line react/no-array-index-key
(0, _jsxRuntime.jsxs)("div", _objectSpread(_objectSpread({}, addErrorHighlight(getLineProps({
line,
key: String(i)
}), i, errorLocation)), {}, {
children: [getLineNumbers === null || getLineNumbers === void 0 ? void 0 : getLineNumbers(i + 1), line.map((token, ii) =>
/*#__PURE__*/
// eslint-disable-next-line react/no-array-index-key
(0, _jsxRuntime.jsx)("span", _objectSpread({}, getTokenProps({
token,
key: String(ii)
})), ii))]
})))
});
exports.mapTokens = mapTokens;

@@ -60,17 +62,22 @@ function CodeBlock(_ref) {

const style = typeof (theme === null || theme === void 0 ? void 0 : theme.plain) === 'object' ? theme.plain : {};
const getLineNumbers = lineNumbers ? num => /*#__PURE__*/_react.default.createElement(_LineNumber.default, {
theme: theme
}, num) : undefined;
return /*#__PURE__*/_react.default.createElement(_prismReactRenderer.Highlight, {
const getLineNumbers = lineNumbers ? num => /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineNumber.default, {
theme: theme,
children: num
}) : undefined;
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_prismReactRenderer.Highlight, {
theme: theme,
prism: _prismReactRenderer.Prism,
code: code.trim(),
language: language
}, hl => /*#__PURE__*/_react.default.createElement("pre", {
className: `${props.className || ''} ${hl.className}`,
style: _objectSpread(_objectSpread(_objectSpread({}, props.style), style), hl.style)
}, /*#__PURE__*/_react.default.createElement("code", null, mapTokens(_objectSpread(_objectSpread({}, hl), {}, {
getLineNumbers
})))));
language: language,
children: hl => /*#__PURE__*/(0, _jsxRuntime.jsx)("pre", {
className: `${props.className || ''} ${hl.className}`,
style: _objectSpread(_objectSpread(_objectSpread({}, props.style), style), hl.style),
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("code", {
children: mapTokens(_objectSpread(_objectSpread({}, hl), {}, {
getLineNumbers
}))
})
})
});
}
var _default = exports.default = CodeBlock;

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

var _LineNumber = _interopRequireDefault(require("./LineNumber.js"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }

@@ -132,20 +133,22 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }

const errorLocation = (error === null || error === void 0 ? void 0 : error.location) || (error === null || error === void 0 ? void 0 : error.loc);
const highlight = (0, _react.useCallback)(value => /*#__PURE__*/_react.default.createElement(_prismReactRenderer.Highlight, {
const highlight = (0, _react.useCallback)(value => /*#__PURE__*/(0, _jsxRuntime.jsx)(_prismReactRenderer.Highlight, {
theme: userTheme,
prism: _prismReactRenderer.Prism,
code: value,
language: language
}, hl => (0, _CodeBlock.mapTokens)(_objectSpread(_objectSpread({}, hl), {}, {
lineNumbers,
theme: userTheme,
errorLocation,
getLineNumbers: line => lineNumbers ? /*#__PURE__*/_react.default.createElement(_LineNumber.default, {
style: {
position: 'absolute',
transform: 'translateX(-100%)',
left: 0
},
theme: userTheme
}, line) : null
}))), [userTheme, lineNumbers, language, errorLocation]);
language: language,
children: hl => (0, _CodeBlock.mapTokens)(_objectSpread(_objectSpread({}, hl), {}, {
lineNumbers,
theme: userTheme,
errorLocation,
getLineNumbers: line => lineNumbers ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineNumber.default, {
style: {
position: 'absolute',
transform: 'translateX(-100%)',
left: 0
},
theme: userTheme,
children: line
}) : null
}))
}), [userTheme, lineNumbers, language, errorLocation]);
const baseTheme = _objectSpread(_objectSpread({

@@ -155,39 +158,51 @@ whiteSpace: 'pre',

}, (userTheme === null || userTheme === void 0 ? void 0 : userTheme.plain) || {}), style);
return /*#__PURE__*/_react.default.createElement("div", {
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
ref: ref,
className: `${className || ''} __jarle`,
style: _objectSpread({}, baseTheme)
}, /*#__PURE__*/_react.default.createElement("div", {
className: "line-numbers"
}, lineNumbers && (code || '').split(/\n/g).map((_, i) => /*#__PURE__*/_react.default.createElement(_LineNumber.default, {
key: i,
theme: userTheme,
className: i + 1 === (errorLocation === null || errorLocation === void 0 ? void 0 : errorLocation.line) && 'token-line-error',
style: {
display: 'block'
}
}, /*#__PURE__*/_react.default.createElement("span", {
style: {
visibility: 'hidden'
}
}, i + 1)))), /*#__PURE__*/_react.default.createElement(_reactSimpleCodeEditor.default, {
value: code || '',
onFocus: handleFocus,
onBlur: handleBlur,
onKeyDown: handleKeyDown,
onMouseDown: handleMouseDown,
onValueChange: setCode,
highlight: highlight,
ignoreTabKey: ignoreTab,
"aria-describedby": id,
"aria-label": "Example code editor",
style: {
overflow: 'visible'
}
}), visible && (keyboardFocused || !ignoreTab) && /*#__PURE__*/_react.default.createElement(Info, {
id: id,
"aria-live": "polite",
srOnly: _infoSrOnly
}, ignoreTab ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "Press ", /*#__PURE__*/_react.default.createElement("kbd", null, "enter"), " or type a key to enable tab-to-indent") : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "Press ", /*#__PURE__*/_react.default.createElement("kbd", null, "esc"), " to disable tab-to-indent")));
style: _objectSpread({}, baseTheme),
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
className: "line-numbers",
children: lineNumbers && (code || '').split(/\n/g).map((_, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineNumber.default, {
theme: userTheme,
className: i + 1 === (errorLocation === null || errorLocation === void 0 ? void 0 : errorLocation.line) && 'token-line-error',
style: {
display: 'block'
},
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
style: {
visibility: 'hidden'
},
children: i + 1
})
}, i))
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactSimpleCodeEditor.default, {
value: code || '',
onFocus: handleFocus,
onBlur: handleBlur,
onKeyDown: handleKeyDown,
onMouseDown: handleMouseDown,
onValueChange: setCode,
highlight: highlight,
ignoreTabKey: ignoreTab,
"aria-describedby": id,
"aria-label": "Example code editor",
style: {
overflow: 'visible'
}
}), visible && (keyboardFocused || !ignoreTab) && /*#__PURE__*/(0, _jsxRuntime.jsx)(Info, {
id: id,
"aria-live": "polite",
srOnly: _infoSrOnly,
children: ignoreTab ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
children: ["Press ", /*#__PURE__*/(0, _jsxRuntime.jsx)("kbd", {
children: "enter"
}), " or type a key to enable tab-to-indent"]
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
children: ["Press ", /*#__PURE__*/(0, _jsxRuntime.jsx)("kbd", {
children: "esc"
}), " to disable tab-to-indent"]
})
})]
});
});
var _default = exports.default = Editor;

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

var _Provider = require("./Provider.js");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/**
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /**
* Displays an syntax or runtime error that occurred when rendering the code

@@ -16,3 +21,5 @@ */

const error = (0, _Provider.useError)();
return error ? /*#__PURE__*/_react.default.createElement("pre", props, error.toString()) : null;
return error ? /*#__PURE__*/(0, _jsxRuntime.jsx)("pre", _objectSpread(_objectSpread({}, props), {}, {
children: error.toString()
})) : null;
}

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

var _Provider = require("./Provider.js");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }

@@ -19,3 +20,3 @@ class CodeLiveErrorBoundary extends _react.default.Component {

} = this.props;
return typeof Element === 'function' ? /*#__PURE__*/_react.default.createElement(Element, null) : Element;
return typeof Element === 'function' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Element, {}) : Element;
}

@@ -22,0 +23,0 @@ }

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

var _react = _interopRequireDefault(require("react"));
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["srOnly"];
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }

@@ -33,3 +33,3 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }

props = _objectWithoutProperties(_ref, _excluded);
return /*#__PURE__*/_react.default.createElement("div", _extends({}, props, {
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, props), {}, {
style: _objectSpread({

@@ -36,0 +36,0 @@ pointerEvents: 'none',

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

var _react = _interopRequireDefault(require("react"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }

@@ -27,8 +28,9 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }

}) {
return /*#__PURE__*/_react.default.createElement("span", {
return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
"aria-hidden": true,
className: `${className || ''} line-number`,
style: theme ? _objectSpread(_objectSpread(_objectSpread({}, style), lineNumberStyle), theme.lineNumber) : undefined
}, children);
style: theme ? _objectSpread(_objectSpread(_objectSpread({}, style), lineNumberStyle), theme.lineNumber) : undefined,
children: children
});
}
var _default = exports.default = LineNumber;

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

var _Provider = require("./Provider.js");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["className", "showLastValid"];
/**
* The component that renders the user's code.
*/
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }

@@ -20,5 +23,2 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }

function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
/**
* The component that renders the user's code.
*/
const Preview = _ref => {

@@ -44,9 +44,11 @@ let {

// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events
React.createElement("div", _extends({
(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({
className: className,
onClick: handleClick
}, previewProps), /*#__PURE__*/React.createElement(_ErrorBoundary.default, {
element: element
}, previewProps), {}, {
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ErrorBoundary.default, {
element: element
})
}));
};
var _default = exports.default = Preview;

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

var _index = require("./transform/index.js");
var _jsxRuntime = require("react/jsx-runtime");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }

@@ -275,5 +276,6 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }

}), [initialCompiledCode, element, error, handleChange, language, theme]);
return /*#__PURE__*/_react.default.createElement(Context.Provider, {
value: context
}, children);
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Context.Provider, {
value: context,
children: children
});
}
{
"name": "jarle",
"version": "3.0.0-beta.0",
"version": "3.0.0-beta.1",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

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