Comparing version 2.1.1 to 3.0.0-beta.0
import { Language, PrismTheme } from 'prism-react-renderer'; | ||
import React from 'react'; | ||
import { LineOutputProps } from './prism'; | ||
declare type MapTokens = Omit<LineOutputProps, 'props'> & { | ||
import { LineOutputProps } from './prism.js'; | ||
type MapTokens = Omit<LineOutputProps, 'props'> & { | ||
getLineNumbers?: (line: number) => React.ReactNode; | ||
@@ -11,3 +11,3 @@ errorLocation?: { | ||
}; | ||
export declare const mapTokens: ({ tokens, getLineProps, getTokenProps, errorLocation, getLineNumbers, }: MapTokens) => JSX.Element; | ||
export declare const mapTokens: ({ tokens, getLineProps, getTokenProps, errorLocation, getLineNumbers, }: MapTokens) => import("react/jsx-runtime").JSX.Element; | ||
interface Props { | ||
@@ -21,3 +21,4 @@ className?: string; | ||
} | ||
declare function CodeBlock({ code, theme, language, lineNumbers, ...props }: Props): JSX.Element; | ||
declare function CodeBlock({ code, theme, language, lineNumbers, ...props }: Props): import("react/jsx-runtime").JSX.Element; | ||
export default CodeBlock; | ||
//# sourceMappingURL=CodeBlock.d.ts.map |
const _excluded = ["code", "theme", "language", "lineNumbers"]; | ||
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 _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else 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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
import Highlight, { Prism } from 'prism-react-renderer'; | ||
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); } | ||
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'; | ||
import LineNumber from './LineNumber.js'; | ||
function addErrorHighlight(props, index, errorLocation) { | ||
@@ -23,6 +17,4 @@ if (index + 1 === (errorLocation === null || errorLocation === void 0 ? void 0 : errorLocation.line)) { | ||
} | ||
return props; | ||
} | ||
export const mapTokens = ({ | ||
@@ -49,12 +41,10 @@ tokens, | ||
}))))))); | ||
function CodeBlock(_ref) { | ||
let { | ||
code, | ||
theme, | ||
language, | ||
lineNumbers | ||
} = _ref, | ||
props = _objectWithoutProperties(_ref, _excluded); | ||
code, | ||
theme, | ||
language, | ||
lineNumbers | ||
} = _ref, | ||
props = _objectWithoutProperties(_ref, _excluded); | ||
const style = typeof (theme === null || theme === void 0 ? void 0 : theme.plain) === 'object' ? theme.plain : {}; | ||
@@ -66,3 +56,3 @@ const getLineNumbers = lineNumbers ? num => /*#__PURE__*/React.createElement(LineNumber, { | ||
theme: theme, | ||
Prism: Prism, | ||
prism: Prism, | ||
code: code.trim(), | ||
@@ -77,3 +67,2 @@ language: language | ||
} | ||
export default CodeBlock; |
@@ -1,2 +0,2 @@ | ||
import { PrismTheme } from 'prism-react-renderer'; | ||
import { type PrismTheme } from 'prism-react-renderer'; | ||
import React from 'react'; | ||
@@ -21,1 +21,2 @@ export interface Props { | ||
export default Editor; | ||
//# sourceMappingURL=Editor.d.ts.map |
@@ -1,22 +0,18 @@ | ||
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 _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else 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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import Highlight, { Prism } from 'prism-react-renderer'; | ||
import useMergeState from '@restart/hooks/useMergeState'; | ||
import useStableMemo from '@restart/hooks/useStableMemo'; | ||
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 { Highlight, Prism } from 'prism-react-renderer'; | ||
import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'; | ||
import SimpleCodeEditor from 'react-simple-code-editor'; | ||
import { mapTokens } from './CodeBlock'; | ||
import InfoMessage from './InfoMessage'; | ||
import { useLiveContext } from './Provider'; | ||
import LineNumber from './LineNumber'; | ||
import { mapTokens } from './CodeBlock.js'; | ||
import InfoMessage from './InfoMessage.js'; | ||
import { useLiveContext } from './Provider.js'; | ||
import LineNumber from './LineNumber.js'; | ||
let uid = 0; | ||
function useStateFromProp(prop) { | ||
const state = useState(prop); | ||
const firstRef = useRef(true); | ||
useStableMemo(() => { | ||
useMemo(() => { | ||
if (firstRef.current) { | ||
@@ -26,3 +22,2 @@ firstRef.current = false; | ||
} | ||
state[1](prop); | ||
@@ -32,3 +27,2 @@ }, [prop]); | ||
} | ||
function useInlineStyle() { | ||
@@ -39,3 +33,2 @@ useEffect(() => { | ||
} | ||
const style = document.createElement('style'); | ||
@@ -59,3 +52,2 @@ document.head.append(style); | ||
} | ||
/** | ||
@@ -91,3 +83,3 @@ * The Editor is the code text editor component, some props can be supplied directly | ||
keyboardFocused | ||
}, setState] = useMergeState({ | ||
}, setState] = useState({ | ||
visible: false, | ||
@@ -98,3 +90,2 @@ ignoreTab: false, | ||
const id = useMemo(() => `described-by-${++uid}`, []); | ||
const handleKeyDown = event => { | ||
@@ -104,17 +95,14 @@ const { | ||
} = event; | ||
if (ignoreTab && key !== 'Tab' && key !== 'Shift') { | ||
if (key === 'Enter') event.preventDefault(); | ||
setState({ | ||
setState(prev => _objectSpread(_objectSpread({}, prev), {}, { | ||
ignoreTab: false | ||
}); | ||
})); | ||
} | ||
if (!ignoreTab && key === 'Escape') { | ||
setState({ | ||
setState(prev => _objectSpread(_objectSpread({}, prev), {}, { | ||
ignoreTab: true | ||
}); | ||
})); | ||
} | ||
}; | ||
const handleFocus = e => { | ||
@@ -128,10 +116,8 @@ if (e.target !== e.currentTarget) return; | ||
}; | ||
const handleBlur = e => { | ||
if (e.target !== e.currentTarget) return; | ||
setState({ | ||
setState(prev => _objectSpread(_objectSpread({}, prev), {}, { | ||
visible: false | ||
}); | ||
})); | ||
}; | ||
const handleMouseDown = () => { | ||
@@ -143,7 +129,6 @@ mouseDown.current = true; | ||
}; | ||
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, { | ||
theme: userTheme, | ||
Prism: Prism, | ||
prism: Prism, | ||
code: value, | ||
@@ -164,3 +149,2 @@ language: language | ||
}))), [userTheme, lineNumbers, language, errorLocation]); | ||
const baseTheme = _objectSpread(_objectSpread({ | ||
@@ -170,3 +154,2 @@ whiteSpace: 'pre', | ||
}, (userTheme === null || userTheme === void 0 ? void 0 : userTheme.plain) || {}), style); | ||
return /*#__PURE__*/React.createElement("div", { | ||
@@ -173,0 +156,0 @@ ref: ref, |
import React from 'react'; | ||
/** | ||
* Displays an sytax or runtime error that occured when rendering the code | ||
* | ||
* Displays an syntax or runtime error that occurred when rendering the code | ||
*/ | ||
export default function Error(props: React.HTMLProps<HTMLPreElement>): JSX.Element | null; | ||
export default function Error(props: React.HTMLProps<HTMLPreElement>): import("react/jsx-runtime").JSX.Element | null; | ||
//# sourceMappingURL=Error.d.ts.map |
import React from 'react'; | ||
import { useError } from './Provider'; | ||
import { useError } from './Provider.js'; | ||
/** | ||
* Displays an sytax or runtime error that occured when rendering the code | ||
* | ||
* Displays an syntax or runtime error that occurred when rendering the code | ||
*/ | ||
export default function Error(props) { | ||
@@ -9,0 +8,0 @@ const error = useError(); |
import React from 'react'; | ||
import { Context } from './Provider'; | ||
import { Context } from './Provider.js'; | ||
interface Props { | ||
@@ -14,1 +14,2 @@ element: React.ReactNode; | ||
export default CodeLiveErrorBoundary; | ||
//# sourceMappingURL=ErrorBoundary.d.ts.map |
import React from 'react'; | ||
import { Context } from './Provider'; | ||
import { Context } from './Provider.js'; | ||
class CodeLiveErrorBoundary extends React.Component { | ||
@@ -8,3 +7,2 @@ componentDidCatch(error) { | ||
} | ||
render() { | ||
@@ -16,6 +14,4 @@ const { | ||
} | ||
} | ||
CodeLiveErrorBoundary.contextType = Context; | ||
export default CodeLiveErrorBoundary; |
@@ -1,2 +0,3 @@ | ||
declare const _default: (code: string, language?: string | undefined) => string; | ||
declare const _default: (code: string, language?: string) => string; | ||
export default _default; | ||
//# sourceMappingURL=highlight.d.ts.map |
@@ -1,11 +0,12 @@ | ||
import { Prism } from 'prism-react-renderer'; | ||
import CodeBlock from './CodeBlock'; | ||
import Editor from './Editor'; | ||
import Error from './Error'; | ||
import InfoMessage from './InfoMessage'; | ||
import Preview from './Preview'; | ||
import Provider, { ImportResolver as _ImportResolver } from './Provider'; | ||
import highlight from './highlight'; | ||
export declare type ImportResolver = _ImportResolver; | ||
export { Prism, CodeBlock, Error, Editor, Preview, Provider, InfoMessage, highlight, }; | ||
import { Prism, themes } from 'prism-react-renderer'; | ||
import CodeBlock from './CodeBlock.js'; | ||
import Editor from './Editor.js'; | ||
import Error from './Error.js'; | ||
import InfoMessage from './InfoMessage.js'; | ||
import Preview from './Preview.js'; | ||
import Provider, { ImportResolver as _ImportResolver } from './Provider.js'; | ||
import highlight from './highlight.js'; | ||
export type ImportResolver = _ImportResolver; | ||
export { Prism, CodeBlock, Error, Editor, Preview, Provider, InfoMessage, highlight, themes, }; | ||
export type { PrismTheme, Language } from 'prism-react-renderer'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,9 +0,9 @@ | ||
import { Prism } from 'prism-react-renderer'; | ||
import CodeBlock from './CodeBlock'; | ||
import Editor from './Editor'; | ||
import Error from './Error'; | ||
import InfoMessage from './InfoMessage'; | ||
import Preview from './Preview'; | ||
import Provider from './Provider'; | ||
import highlight from './highlight'; | ||
export { Prism, CodeBlock, Error, Editor, Preview, Provider, InfoMessage, highlight }; | ||
import { Prism, themes } from 'prism-react-renderer'; | ||
import CodeBlock from './CodeBlock.js'; | ||
import Editor from './Editor.js'; | ||
import Error from './Error.js'; | ||
import InfoMessage from './InfoMessage.js'; | ||
import Preview from './Preview.js'; | ||
import Provider from './Provider.js'; | ||
import highlight from './highlight.js'; | ||
export { Prism, CodeBlock, Error, Editor, Preview, Provider, InfoMessage, highlight, themes }; |
import React from 'react'; | ||
export default function InfoMessage({ srOnly, ...props }: React.HTMLProps<HTMLDivElement> & { | ||
srOnly?: boolean; | ||
}): JSX.Element; | ||
}): import("react/jsx-runtime").JSX.Element; | ||
//# sourceMappingURL=InfoMessage.d.ts.map |
const _excluded = ["srOnly"]; | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
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 _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else 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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
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; } | ||
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); } | ||
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; } | ||
import React from 'react'; | ||
@@ -27,6 +22,5 @@ const srOnlyStyle = { | ||
let { | ||
srOnly = false | ||
} = _ref, | ||
props = _objectWithoutProperties(_ref, _excluded); | ||
srOnly = false | ||
} = _ref, | ||
props = _objectWithoutProperties(_ref, _excluded); | ||
return /*#__PURE__*/React.createElement("div", _extends({}, props, { | ||
@@ -33,0 +27,0 @@ style: _objectSpread({ |
@@ -1,2 +0,3 @@ | ||
declare function LineNumber({ children, className, theme, style }: any): JSX.Element; | ||
declare function LineNumber({ children, className, theme, style }: any): import("react/jsx-runtime").JSX.Element; | ||
export default LineNumber; | ||
//# sourceMappingURL=LineNumber.d.ts.map |
@@ -1,7 +0,6 @@ | ||
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 _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else 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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
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'; | ||
@@ -14,3 +13,2 @@ const lineNumberStyle = { | ||
}; | ||
function LineNumber({ | ||
@@ -28,3 +26,2 @@ children, | ||
} | ||
export default LineNumber; |
/** | ||
* The component that renders the user's code. | ||
*/ | ||
declare const Preview: ({ className, holderTheme, ...props }: { | ||
className?: string | undefined; | ||
/** An optional holder.js theme */ | ||
holderTheme?: any; | ||
}) => JSX.Element | null; | ||
declare const Preview: ({ className, showLastValid, ...props }: { | ||
className?: string; | ||
/** | ||
* Whether an error should reset the preview to an empty state or keep showing the last valid code result. | ||
*/ | ||
showLastValid?: boolean; | ||
}) => import("react/jsx-runtime").JSX.Element | null; | ||
export default Preview; | ||
//# sourceMappingURL=Preview.d.ts.map |
@@ -1,69 +0,37 @@ | ||
const _excluded = ["className", "holderTheme"]; | ||
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; } | ||
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); } | ||
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; } | ||
import ErrorBoundary from './ErrorBoundary.js'; | ||
import { useElement, useError } from './Provider.js'; | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
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 _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else 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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
import useCallbackRef from '@restart/hooks/useCallbackRef'; | ||
import React, { useEffect } from 'react'; | ||
import ErrorBoundary from './ErrorBoundary'; | ||
import { useElement, useError } from './Provider'; | ||
let holderjs; | ||
if (typeof window !== 'undefined') { | ||
try { | ||
holderjs = require('holderjs'); | ||
} catch (err) { | ||
/** ignore */ | ||
} | ||
} | ||
/** | ||
* The component that renders the user's code. | ||
*/ | ||
const Preview = _ref => { | ||
let { | ||
className, | ||
holderTheme | ||
} = _ref, | ||
props = _objectWithoutProperties(_ref, _excluded); | ||
const [example, attachRef] = useCallbackRef(); | ||
const hasTheme = !!holderTheme && holderjs; | ||
className, | ||
showLastValid = true | ||
} = _ref, | ||
props = _objectWithoutProperties(_ref, _excluded); | ||
const element = useElement(); | ||
const error = useError(); | ||
useEffect(() => { | ||
if (hasTheme) holderjs.addTheme('userTheme', holderTheme); // eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [hasTheme]); | ||
useEffect(() => { | ||
if (!example || !holderjs) return; | ||
holderjs.run({ | ||
theme: hasTheme ? 'userTheme' : undefined, | ||
images: example.querySelectorAll('img') | ||
}); | ||
}, [element, example, hasTheme]); // prevent links in examples from navigating | ||
// prevent links in examples from navigating | ||
const handleClick = e => { | ||
if (e.target.tagName === 'A' || e.target.closest('a')) e.preventDefault(); | ||
}; | ||
const previewProps = _objectSpread({ | ||
role: "region", | ||
"aria-label": "Code Example" | ||
role: 'region', | ||
'aria-label': 'Code Example' | ||
}, props); | ||
return error ? null : | ||
return !showLastValid && error ? null : | ||
/*#__PURE__*/ | ||
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events | ||
React.createElement("div", _extends({ | ||
ref: attachRef, | ||
className: className, | ||
@@ -75,3 +43,2 @@ onClick: handleClick | ||
}; | ||
export default Preview; |
@@ -1,3 +0,3 @@ | ||
export declare type Language = 'markup' | 'bash' | 'clike' | 'c' | 'cpp' | 'css' | 'javascript' | 'jsx' | 'coffeescript' | 'actionscript' | 'css-extr' | 'diff' | 'git' | 'go' | 'graphql' | 'handlebars' | 'json' | 'less' | 'makefile' | 'markdown' | 'objectivec' | 'ocaml' | 'python' | 'reason' | 'sass' | 'scss' | 'sql' | 'stylus' | 'tsx' | 'typescript' | 'wasm' | 'yaml'; | ||
export declare type PrismThemeEntry = { | ||
export type Language = 'markup' | 'bash' | 'clike' | 'c' | 'cpp' | 'css' | 'javascript' | 'jsx' | 'coffeescript' | 'actionscript' | 'css-extr' | 'diff' | 'git' | 'go' | 'graphql' | 'handlebars' | 'json' | 'less' | 'makefile' | 'markdown' | 'objectivec' | 'ocaml' | 'python' | 'reason' | 'sass' | 'scss' | 'sql' | 'stylus' | 'tsx' | 'typescript' | 'wasm' | 'yaml'; | ||
export type PrismThemeEntry = { | ||
color?: string; | ||
@@ -11,3 +11,3 @@ backgroundColor?: string; | ||
}; | ||
export declare type PrismTheme = { | ||
export type PrismTheme = { | ||
plain: PrismThemeEntry; | ||
@@ -20,3 +20,3 @@ styles: Array<{ | ||
}; | ||
export declare type ThemeDict = { | ||
export type ThemeDict = { | ||
root: StyleObj; | ||
@@ -26,3 +26,3 @@ plain: StyleObj; | ||
}; | ||
export declare type Token = { | ||
export type Token = { | ||
types: string[]; | ||
@@ -32,10 +32,10 @@ content: string; | ||
}; | ||
export declare type PrismToken = { | ||
export type PrismToken = { | ||
type: string; | ||
content: Array<PrismToken | string> | string; | ||
}; | ||
export declare type StyleObj = { | ||
export type StyleObj = { | ||
[key: string]: string | number | null; | ||
}; | ||
export declare type LineInputProps = { | ||
export type LineInputProps = { | ||
key?: string; | ||
@@ -47,3 +47,3 @@ style?: StyleObj; | ||
}; | ||
export declare type LineOutputProps = { | ||
export type LineOutputProps = { | ||
key?: string; | ||
@@ -54,3 +54,3 @@ style?: StyleObj; | ||
}; | ||
export declare type TokenInputProps = { | ||
export type TokenInputProps = { | ||
key?: string; | ||
@@ -62,3 +62,3 @@ style?: StyleObj; | ||
}; | ||
export declare type TokenOutputProps = { | ||
export type TokenOutputProps = { | ||
key?: string; | ||
@@ -70,3 +70,3 @@ style?: StyleObj; | ||
}; | ||
export declare type RenderProps = { | ||
export type RenderProps = { | ||
tokens: Token[][]; | ||
@@ -78,1 +78,2 @@ className: string; | ||
}; | ||
//# sourceMappingURL=prism.d.ts.map |
@@ -1,4 +0,4 @@ | ||
import { PrismTheme } from 'prism-react-renderer'; | ||
import type { PrismTheme } from 'prism-react-renderer'; | ||
import React, { ReactNode } from 'react'; | ||
export declare type LiveError = Error & { | ||
export type LiveError = Error & { | ||
location?: { | ||
@@ -13,3 +13,3 @@ line: number; | ||
}; | ||
export declare const isTypeScriptEnabled: (language?: string | undefined) => boolean; | ||
export declare const isTypeScriptEnabled: (language?: string) => boolean; | ||
export interface LiveContext { | ||
@@ -26,3 +26,3 @@ code?: string; | ||
export declare const Context: React.Context<LiveContext>; | ||
export declare type ImportResolver = (requests: string[]) => Promise<Record<string, any> | any[]>; | ||
export type ImportResolver = (requests: string[]) => Promise<Record<string, any> | any[]>; | ||
export interface Props<TScope> { | ||
@@ -88,2 +88,3 @@ /** | ||
*/ | ||
export default function Provider<TScope extends {} = {}>({ scope, children, code: rawCode, language, theme, exportToRender, showImports, renderAsComponent, resolveImports, }: Props<TScope>): JSX.Element; | ||
export default function Provider<TScope extends {} = {}>({ scope, children, code: rawCode, language, theme, exportToRender, showImports, renderAsComponent, resolveImports, }: Props<TScope>): import("react/jsx-runtime").JSX.Element; | ||
//# sourceMappingURL=Provider.d.ts.map |
@@ -1,16 +0,14 @@ | ||
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 _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else 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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import useEventCallback from '@restart/hooks/useEventCallback'; | ||
import useMounted from '@restart/hooks/useMounted'; | ||
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 { useEventCallback, useMounted } from '@restart/hooks'; | ||
import React, { useContext, useEffect, useMemo, useState, isValidElement, createElement, useCallback } from 'react'; | ||
import { isValidElementType } from 'react-is'; // import { decode } from 'sourcemap-codec'; | ||
import { isValidElementType } from 'react-is'; | ||
// import { decode } from 'sourcemap-codec'; | ||
import { transform } from './transform/index.js'; | ||
import { transform } from './transform'; // try and match render() calls with arguments to avoid false positives with class components | ||
// try and match render() calls with arguments to avoid false positives with class components | ||
const hasRenderCall = code => !!code.match(/render\((?!\s*\))/gm); | ||
const prettierComment = /(\{\s*\/\*\s+prettier-ignore\s+\*\/\s*\})|(\/\/\s+prettier-ignore)/gim; | ||
@@ -27,3 +25,2 @@ const hooks = {}; | ||
export const Context = /*#__PURE__*/React.createContext({}); | ||
const getRequire = imports => function require(request) { | ||
@@ -37,9 +34,7 @@ if (!imports) throw new Error('no imports'); | ||
}; | ||
function handleError(err, fn) { | ||
const fnStr = fn.toString(); // account for the function chrome lines | ||
const fnStr = fn.toString(); | ||
// account for the function chrome lines | ||
const offset = fnStr.slice(0, fnStr.indexOf('{')).split(/\n/).length; | ||
let pos; | ||
if ('line' in err) { | ||
@@ -57,3 +52,2 @@ pos = { | ||
var _err$stack; | ||
const [, line, col] = (_err$stack = err.stack) === null || _err$stack === void 0 ? void 0 : _err$stack.match(/at eval.+<anonymous>:(\d+):(\d+)/m); | ||
@@ -65,7 +59,10 @@ pos = { | ||
} | ||
if (!pos) return err; | ||
if (!pos) return err; // if (result.map) { | ||
// if (result.map) { | ||
// const decoded = decode(result.map.mappings); | ||
// const line = pos.line - offset; | ||
// const mapping = decoded[line]?.find(([col]) => col === pos.column); | ||
// if (mapping) { | ||
@@ -78,3 +75,2 @@ // err.location = { line: mapping[2], column: mapping[3] }; | ||
} | ||
function codeToComponent(compiledCode, { | ||
@@ -88,7 +84,5 @@ scope, | ||
const isInline = !hasRenderCall(compiledCode); | ||
if (renderAsComponent && !isInline) { | ||
throw new Error('Code using `render()` cannot use top level hooks. ' + 'Either provide your own stateful component, or return a jsx element directly.'); | ||
} | ||
const render = element => { | ||
@@ -99,10 +93,7 @@ if (element === undefined) { | ||
} | ||
resolve(element); | ||
}; | ||
resolve(element); | ||
}; // const [clearTimes, timers] = createTimers(); | ||
// DU NA NA NAAAH | ||
const finalScope = _objectSpread(_objectSpread({}, hooks), scope); | ||
const exports = {}; | ||
@@ -112,12 +103,10 @@ const args = ['React', 'render', 'exports'].concat(Object.keys(finalScope)); | ||
let body = compiledCode; | ||
if (renderAsComponent) { | ||
body = `return React.createElement(function StateContainer() {\n${body}\n})`; | ||
} | ||
if (preample) body = `${preample}\n\n${body}`; | ||
if (preample) body = `${preample}\n\n${body}`; // eslint-disable-next-line no-new-func | ||
// eslint-disable-next-line no-new-func | ||
const fn = new Function(...args, body); | ||
let element; | ||
try { | ||
@@ -129,15 +118,10 @@ element = fn(...values); | ||
} | ||
const exportedValues = Object.values(exports); | ||
if ('default' in exports) { | ||
var _exports$default; | ||
element = (_exports$default = exports.default) !== null && _exports$default !== void 0 ? _exports$default : element; | ||
} else if (exportedValues.length) { | ||
var _ref, _exports; | ||
element = (_ref = (_exports = exports[exportToRender]) !== null && _exports !== void 0 ? _exports : exportedValues[0]) !== null && _ref !== void 0 ? _ref : element; | ||
} | ||
if (element === undefined) { | ||
@@ -147,6 +131,4 @@ if (isInline) { | ||
} | ||
return; | ||
} | ||
if (! /*#__PURE__*/isValidElement(element)) { | ||
@@ -159,7 +141,5 @@ if (isValidElementType(element)) { | ||
} | ||
resolve(element); | ||
}); | ||
} | ||
export function useLiveContext() { | ||
@@ -175,3 +155,2 @@ return useContext(Context); | ||
export const objectZip = (arr, arr2) => Object.fromEntries(arr.map((v, i) => [v, arr2[i]])); | ||
function defaultResolveImports(sources) { | ||
@@ -181,3 +160,2 @@ // @ts-ignore | ||
} | ||
function useCompiledCode(consumerCode, showImports, isTypeScript, setError) { | ||
@@ -201,3 +179,2 @@ const compile = useCallback(nextCode => { | ||
}; | ||
if (showImports) { | ||
@@ -209,3 +186,2 @@ return { | ||
} | ||
try { | ||
@@ -232,2 +208,3 @@ return transform(nextCode, { | ||
} | ||
/** | ||
@@ -237,4 +214,2 @@ * The Provider supplies the context to the other components as well as handling | ||
*/ | ||
export default function Provider({ | ||
@@ -241,0 +216,0 @@ scope, |
import { SucraseContext } from 'sucrase'; | ||
import { TokenProcessor, CJSImportProcessor } from './parser'; | ||
export declare type Import = { | ||
import { TokenProcessor, type CJSImportProcessor } from './parser.js'; | ||
export type Import = { | ||
code: string; | ||
@@ -28,1 +28,2 @@ source: string; | ||
} | ||
//# sourceMappingURL=ImportTransformer.d.ts.map |
@@ -1,4 +0,5 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import { tt } from './parser'; | ||
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 { tt } from './parser.js'; | ||
export default class ImportRemoverTransformer { | ||
@@ -9,48 +10,37 @@ constructor(context, { | ||
_defineProperty(this, "tokens", void 0); | ||
_defineProperty(this, "importProcessor", void 0); | ||
_defineProperty(this, "imports", []); | ||
_defineProperty(this, "removeImports", void 0); | ||
_defineProperty(this, "num", 0); | ||
this.tokens = context.tokenProcessor; | ||
this.importProcessor = context.importProcessor; | ||
this.removeImports = removeImports || false; // clear the replacements b/c we are handling imports | ||
this.removeImports = removeImports || false; | ||
// clear the replacements b/c we are handling imports | ||
// @ts-ignore private | ||
this.importProcessor.identifierReplacements.clear(); | ||
} | ||
getPrefixCode() { | ||
return ''; | ||
} | ||
getHoistedCode() { | ||
return ''; | ||
} | ||
getSuffixCode() { | ||
return ''; | ||
} | ||
process() { | ||
if (!this.tokens.matches1(tt._import)) return false; // dynamic import | ||
if (!this.tokens.matches1(tt._import)) return false; | ||
// dynamic import | ||
if (this.tokens.matches2(tt._import, tt.parenL)) { | ||
return true; | ||
} | ||
this.tokens.removeInitialToken(); | ||
while (!this.tokens.matches1(tt.string)) { | ||
this.tokens.removeToken(); | ||
} | ||
const path = this.tokens.stringValue(); | ||
const detail = this.buildImport(path); | ||
this.importProcessor.claimImportCode(path); | ||
if (detail !== null && detail !== void 0 && detail.code) { | ||
@@ -62,14 +52,10 @@ this.imports.push(detail); | ||
} | ||
if (this.tokens.matches1(tt.semi)) { | ||
this.tokens.removeToken(); | ||
} | ||
return true; | ||
} | ||
getIdentifier(src) { | ||
return `${src.split('/').pop().replace(/\W/g, '_')}$${this.num++}`; | ||
} | ||
buildImport(path) { | ||
@@ -80,3 +66,2 @@ // @ts-ignore | ||
} | ||
let FN = 'require'; | ||
@@ -88,3 +73,4 @@ const { | ||
hasBareImport | ||
} = // @ts-ignore | ||
} = | ||
// @ts-ignore | ||
this.importProcessor.importInfoByPath.get(path); | ||
@@ -101,6 +87,5 @@ const req = `${FN}('${path}');`; | ||
namedImports.forEach(s => { | ||
if (this.importProcessor.isTypeName(s.localName)) { | ||
if (this.importProcessor.shouldAutomaticallyElideImportedName(s.localName)) { | ||
return; | ||
} | ||
named.push(s.localName === s.importedName ? s.localName : `${s.importedName}: ${s.localName}`); | ||
@@ -112,10 +97,8 @@ details.keys.push({ | ||
}); | ||
if (defaultNames.length || wildcardNames.length) { | ||
const name = defaultNames[0] || wildcardNames[0]; | ||
if (!this.importProcessor.isTypeName(name)) { | ||
details.base = name; // intentionally use `var` so that conflcits with Jarle provider scope get resolved naturally | ||
if (!this.importProcessor.shouldAutomaticallyElideImportedName(name)) { | ||
details.base = name; | ||
// intentionally use `var` so that conflcits with Jarle provider scope get resolved naturally | ||
// with the import overriding the scoped identifier | ||
if (wildcardNames.length) { | ||
@@ -128,15 +111,11 @@ details.code = `var ${name} = ${req}`; | ||
} | ||
if (named.length) { | ||
details.code += ` var { ${named.join(', ')} } = ${details.code ? `${tmp};` : req}`; | ||
} | ||
if (hasBareImport) { | ||
details.code = req; | ||
} | ||
details.code = details.code.trim(); | ||
return details; | ||
} | ||
} |
@@ -1,3 +0,3 @@ | ||
import { Transform } from 'sucrase/dist/Options'; | ||
import { Import } from './ImportTransformer'; | ||
import type { Transform } from 'sucrase'; | ||
import { Import } from './ImportTransformer.js'; | ||
export type { Import }; | ||
@@ -13,4 +13,5 @@ export interface Options { | ||
export declare function transform(code: string, options?: Options): { | ||
code: string; | ||
code: any; | ||
imports: Import[]; | ||
}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,43 +0,35 @@ | ||
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 _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else 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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import ImportRemoverTransformer from './ImportTransformer'; | ||
import { getSucraseContext, RootTransformer } from './parser'; | ||
import wrapLastExpression from './wrapLastExpression'; | ||
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 ImportRemoverTransformer from './ImportTransformer.js'; | ||
import { getSucraseContext, RootTransformer } from './parser.js'; | ||
import wrapLastExpression from './wrapLastExpression.js'; | ||
class JarleRootTransformer extends RootTransformer { | ||
constructor(context, options, parsingTransforms) { | ||
var _options$transforms; | ||
super(context, (_options$transforms = options.transforms) !== null && _options$transforms !== void 0 ? _options$transforms : [], false, _objectSpread({}, options)); | ||
_defineProperty(this, "importTransformer", void 0); | ||
_defineProperty(this, "wrapLastExpression", void 0); | ||
this.importTransformer = new ImportRemoverTransformer(context, options); | ||
this.importTransformer = new ImportRemoverTransformer(context, options); // @ts-ignore | ||
// @ts-ignore | ||
this.transformers.unshift(this.importTransformer); | ||
this.wrapLastExpression = options.wrapLastExpression ? result => { | ||
return wrapLastExpression(getSucraseContext(result, _objectSpread(_objectSpread({}, options), {}, { | ||
var _wrapLastExpression; | ||
return (_wrapLastExpression = wrapLastExpression(getSucraseContext(result.code, _objectSpread(_objectSpread({}, options), {}, { | ||
transforms: parsingTransforms | ||
}))); | ||
})))) !== null && _wrapLastExpression !== void 0 ? _wrapLastExpression : result; | ||
} : result => result; | ||
} | ||
get imports() { | ||
return this.importTransformer.imports; | ||
} | ||
transform() { | ||
let result = super.transform(); | ||
result = result.replace('"use strict";', '').replace('exports. default =', 'exports.default =').replace('Object.defineProperty(exports, "__esModule", {value: true});', ''); | ||
result.code = result.code.replace('"use strict";', '').replace('exports. default =', 'exports.default =').replace('Object.defineProperty(exports, "__esModule", {value: true});', ''); | ||
return this.wrapLastExpression(result); | ||
} | ||
} | ||
export function transform(code, options = {}) { | ||
@@ -47,7 +39,5 @@ const transforms = options.transforms || []; | ||
const isTypeScriptEnabled = options.syntax === 'typescript' || transforms.includes('typescript'); | ||
if (isTypeScriptEnabled) { | ||
parsingTransforms.push('typescript'); | ||
} | ||
const sucraseOptions = _objectSpread(_objectSpread({}, options), {}, { | ||
@@ -60,3 +50,2 @@ transforms, | ||
}); | ||
const ctx = getSucraseContext(code, _objectSpread(_objectSpread({}, sucraseOptions), {}, { | ||
@@ -67,5 +56,5 @@ transforms: parsingTransforms | ||
return { | ||
code: transformer.transform(), | ||
code: transformer.transform().code, | ||
imports: transformer.imports | ||
}; | ||
} |
import { SucraseContext } from 'sucrase'; | ||
export default function wrapLastExpression({ tokenProcessor }: SucraseContext): string; | ||
export default function wrapLastExpression({ tokenProcessor }: SucraseContext): import("sucrase/dist/types/TokenProcessor.js").TokenProcessorResult | undefined; | ||
//# sourceMappingURL=wrapLastExpression.d.ts.map |
@@ -1,30 +0,23 @@ | ||
import { tt } from './parser'; | ||
import { tt } from './parser.js'; | ||
function findLastExpression(tokens) { | ||
let lastExprIdx = null; | ||
for (let i = 0; i < tokens.tokens.length; i++) { | ||
if (tokens.matches2AtIndex(i, tt._export, tt._default)) { | ||
return null; | ||
} // @ts-ignore | ||
} | ||
// @ts-ignore | ||
if (tokens.tokens[i].isTopLevel) { | ||
const code = tokens.code.slice(tokens.tokens[i].start, tokens.tokens[i].end); | ||
if (code.startsWith('exports')) { | ||
return null; | ||
} | ||
if (tokens.matches1AtIndex(i, tt._return)) { | ||
return null; | ||
} | ||
lastExprIdx = i; | ||
} | ||
} | ||
return lastExprIdx; | ||
} | ||
function process(tokens, lastIndex) { | ||
@@ -34,6 +27,4 @@ if (tokens.currentIndex() !== lastIndex) { | ||
} | ||
let prev = tokens.currentIndex() - 1; | ||
let lastWasSemi = prev >= 0 && !tokens.matches1AtIndex(prev, tt.semi); | ||
if (tokens.matches2(tt._export, tt._default)) { | ||
@@ -44,13 +35,9 @@ tokens.removeInitialToken(); | ||
let code = `return ${tokens.currentTokenCode()}`; | ||
if (lastWasSemi) { | ||
code = `;${code}`; | ||
} | ||
tokens.replaceTokenTrimmingLeftWhitespace(code); | ||
} | ||
return true; | ||
} | ||
export default function wrapLastExpression({ | ||
@@ -60,10 +47,7 @@ tokenProcessor | ||
let lastExprIdx = findLastExpression(tokenProcessor); | ||
if (lastExprIdx == null) { | ||
return tokenProcessor.code; | ||
return; | ||
} | ||
while (!tokenProcessor.isAtEnd()) { | ||
let wasProcessed = process(tokenProcessor, lastExprIdx); | ||
if (!wasProcessed) { | ||
@@ -73,4 +57,3 @@ tokenProcessor.copyToken(); | ||
} | ||
return tokenProcessor.finish(); | ||
} |
@@ -1,3 +0,3 @@ | ||
import { Import } from './transform'; | ||
export declare type Options = { | ||
import { Import } from './transform/index.ts'; | ||
export type Options = { | ||
inline?: boolean; | ||
@@ -9,5 +9,6 @@ isTypeScript?: boolean; | ||
declare const _default: (input: string, { inline, isTypeScript, showImports }?: Options) => { | ||
code: string; | ||
code: any; | ||
imports: Import[]; | ||
}; | ||
export default _default; | ||
//# sourceMappingURL=transpile.d.ts.map |
@@ -1,28 +0,2 @@ | ||
import { transform } from './transform'; // function extractLeadingWhitespace(code: string): [string, string] { | ||
// let leadingWhitespace = ''; | ||
// let lines = code.split(/\n/); | ||
// for (const [idx, line] of lines.entries()) { | ||
// if (!line.trim().length) { | ||
// leadingWhitespace += '\n'; | ||
// } else { | ||
// return [leadingWhitespace, lines.slice(idx).join('\n')]; | ||
// } | ||
// } | ||
// return [leadingWhitespace, code]; | ||
// } | ||
// export function parseImports( | ||
// input: string, | ||
// remove: boolean, | ||
// isTypeScript: boolean | ||
// ) { | ||
// const { code, imports, map } = transform(input, { | ||
// removeImports: remove, | ||
// syntax: isTypeScript ? 'typescript' : 'js', | ||
// compiledFilename: 'compiled.js', | ||
// filename: 'example.js', | ||
// }); | ||
// const [leadingWhitespace, trailing] = extractLeadingWhitespace(code); | ||
// return { code: trailing, imports, map, leadingWhitespace }; | ||
// } | ||
import { transform } from './transform/index.ts'; | ||
export default ((input, { | ||
@@ -29,0 +3,0 @@ inline: _inline = false, |
@@ -30,1 +30,2 @@ /** | ||
export default useInterval; | ||
//# sourceMappingURL=useTest.d.ts.map |
import { useEffect } from 'react'; | ||
import useCommittedRef from '@restart/hooks/useCommittedRef'; | ||
import { useCommittedRef } from '@restart/hooks'; | ||
/** | ||
@@ -11,9 +12,28 @@ * Creates a `setInterval` that is properly cleaned up when a component unmounted | ||
/** | ||
* Creates a pausable `setInterval` that is properly cleaned up when a component unmounted | ||
* | ||
* @public | ||
* @param fn an function run on each interval | ||
* @param ms The milliseconds duration of the interval | ||
* @param paused Whether or not the interval is currently running | ||
*/ | ||
/** | ||
* Creates a pausable `setInterval` that is properly cleaned up when a component unmounted | ||
* | ||
* @public | ||
* @param fn an function run on each interval | ||
* @param ms The milliseconds duration of the interval | ||
* @param paused Whether or not the interval is currently running | ||
* @param runImmediately Whether to run the function immediately on mount or unpause | ||
* rather than waiting for the first interval to elapse | ||
*/ | ||
function useInterval(fn, ms, paused = false, runImmediately = false) { | ||
let handle; | ||
const fnRef = useCommittedRef(fn); // this ref is necessary b/c useEffect will sometimes miss a paused toggle | ||
const fnRef = useCommittedRef(fn); | ||
// this ref is necessary b/c useEffect will sometimes miss a paused toggle | ||
// orphaning a setTimeout chain in the aether, so relying on it's refresh logic is not reliable. | ||
const pausedRef = useCommittedRef(paused); | ||
const tick = () => { | ||
@@ -24,3 +44,2 @@ if (pausedRef.current) return; | ||
}; | ||
const schedule = () => { | ||
@@ -30,3 +49,2 @@ clearTimeout(handle); | ||
}; | ||
useEffect(() => { | ||
@@ -38,7 +56,5 @@ if (runImmediately) { | ||
} | ||
return () => clearTimeout(handle); | ||
}, [paused, runImmediately]); | ||
} | ||
export default useInterval; |
import { Language, PrismTheme } from 'prism-react-renderer'; | ||
import React from 'react'; | ||
import { LineOutputProps } from './prism'; | ||
declare type MapTokens = Omit<LineOutputProps, 'props'> & { | ||
import { LineOutputProps } from './prism.js'; | ||
type MapTokens = Omit<LineOutputProps, 'props'> & { | ||
getLineNumbers?: (line: number) => React.ReactNode; | ||
@@ -11,3 +11,3 @@ errorLocation?: { | ||
}; | ||
export declare const mapTokens: ({ tokens, getLineProps, getTokenProps, errorLocation, getLineNumbers, }: MapTokens) => JSX.Element; | ||
export declare const mapTokens: ({ tokens, getLineProps, getTokenProps, errorLocation, getLineNumbers, }: MapTokens) => import("react/jsx-runtime").JSX.Element; | ||
interface Props { | ||
@@ -21,3 +21,4 @@ className?: string; | ||
} | ||
declare function CodeBlock({ code, theme, language, lineNumbers, ...props }: Props): JSX.Element; | ||
declare function CodeBlock({ code, theme, language, lineNumbers, ...props }: Props): import("react/jsx-runtime").JSX.Element; | ||
export default CodeBlock; | ||
//# sourceMappingURL=CodeBlock.d.ts.map |
@@ -7,29 +7,15 @@ "use strict"; | ||
exports.mapTokens = exports.default = void 0; | ||
var _prismReactRenderer = _interopRequireWildcard(require("prism-react-renderer")); | ||
var _prismReactRenderer = require("prism-react-renderer"); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _LineNumber = _interopRequireDefault(require("./LineNumber")); | ||
var _LineNumber = _interopRequireDefault(require("./LineNumber.js")); | ||
const _excluded = ["code", "theme", "language", "lineNumbers"]; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
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 _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else 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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
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); } | ||
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) { | ||
@@ -39,6 +25,4 @@ if (index + 1 === (errorLocation === null || errorLocation === void 0 ? void 0 : errorLocation.line)) { | ||
} | ||
return props; | ||
} | ||
const mapTokens = ({ | ||
@@ -65,14 +49,11 @@ tokens, | ||
}))))))); | ||
exports.mapTokens = mapTokens; | ||
function CodeBlock(_ref) { | ||
let { | ||
code, | ||
theme, | ||
language, | ||
lineNumbers | ||
} = _ref, | ||
props = _objectWithoutProperties(_ref, _excluded); | ||
code, | ||
theme, | ||
language, | ||
lineNumbers | ||
} = _ref, | ||
props = _objectWithoutProperties(_ref, _excluded); | ||
const style = typeof (theme === null || theme === void 0 ? void 0 : theme.plain) === 'object' ? theme.plain : {}; | ||
@@ -82,5 +63,5 @@ const getLineNumbers = lineNumbers ? num => /*#__PURE__*/_react.default.createElement(_LineNumber.default, { | ||
}, num) : undefined; | ||
return /*#__PURE__*/_react.default.createElement(_prismReactRenderer.default, { | ||
return /*#__PURE__*/_react.default.createElement(_prismReactRenderer.Highlight, { | ||
theme: theme, | ||
Prism: _prismReactRenderer.Prism, | ||
prism: _prismReactRenderer.Prism, | ||
code: code.trim(), | ||
@@ -95,4 +76,2 @@ language: language | ||
} | ||
var _default = CodeBlock; | ||
exports.default = _default; | ||
var _default = exports.default = CodeBlock; |
@@ -1,2 +0,2 @@ | ||
import { PrismTheme } from 'prism-react-renderer'; | ||
import { type PrismTheme } from 'prism-react-renderer'; | ||
import React from 'react'; | ||
@@ -21,1 +21,2 @@ export interface Props { | ||
export default Editor; | ||
//# sourceMappingURL=Editor.d.ts.map |
@@ -7,39 +7,22 @@ "use strict"; | ||
exports.default = void 0; | ||
var _prismReactRenderer = _interopRequireWildcard(require("prism-react-renderer")); | ||
var _useMergeState = _interopRequireDefault(require("@restart/hooks/useMergeState")); | ||
var _useStableMemo = _interopRequireDefault(require("@restart/hooks/useStableMemo")); | ||
var _prismReactRenderer = require("prism-react-renderer"); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _reactSimpleCodeEditor = _interopRequireDefault(require("react-simple-code-editor")); | ||
var _CodeBlock = require("./CodeBlock"); | ||
var _InfoMessage = _interopRequireDefault(require("./InfoMessage")); | ||
var _Provider = require("./Provider"); | ||
var _LineNumber = _interopRequireDefault(require("./LineNumber")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
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 _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else 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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var _CodeBlock = require("./CodeBlock.js"); | ||
var _InfoMessage = _interopRequireDefault(require("./InfoMessage.js")); | ||
var _Provider = require("./Provider.js"); | ||
var _LineNumber = _interopRequireDefault(require("./LineNumber.js")); | ||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } | ||
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); } | ||
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; } | ||
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); } | ||
let uid = 0; | ||
function useStateFromProp(prop) { | ||
const state = (0, _react.useState)(prop); | ||
const firstRef = (0, _react.useRef)(true); | ||
(0, _useStableMemo.default)(() => { | ||
(0, _react.useMemo)(() => { | ||
if (firstRef.current) { | ||
@@ -49,3 +32,2 @@ firstRef.current = false; | ||
} | ||
state[1](prop); | ||
@@ -55,3 +37,2 @@ }, [prop]); | ||
} | ||
function useInlineStyle() { | ||
@@ -62,3 +43,2 @@ (0, _react.useEffect)(() => { | ||
} | ||
const style = document.createElement('style'); | ||
@@ -82,3 +62,2 @@ document.head.append(style); | ||
} | ||
/** | ||
@@ -114,3 +93,3 @@ * The Editor is the code text editor component, some props can be supplied directly | ||
keyboardFocused | ||
}, setState] = (0, _useMergeState.default)({ | ||
}, setState] = (0, _react.useState)({ | ||
visible: false, | ||
@@ -121,3 +100,2 @@ ignoreTab: false, | ||
const id = (0, _react.useMemo)(() => `described-by-${++uid}`, []); | ||
const handleKeyDown = event => { | ||
@@ -127,17 +105,14 @@ const { | ||
} = event; | ||
if (ignoreTab && key !== 'Tab' && key !== 'Shift') { | ||
if (key === 'Enter') event.preventDefault(); | ||
setState({ | ||
setState(prev => _objectSpread(_objectSpread({}, prev), {}, { | ||
ignoreTab: false | ||
}); | ||
})); | ||
} | ||
if (!ignoreTab && key === 'Escape') { | ||
setState({ | ||
setState(prev => _objectSpread(_objectSpread({}, prev), {}, { | ||
ignoreTab: true | ||
}); | ||
})); | ||
} | ||
}; | ||
const handleFocus = e => { | ||
@@ -151,10 +126,8 @@ if (e.target !== e.currentTarget) return; | ||
}; | ||
const handleBlur = e => { | ||
if (e.target !== e.currentTarget) return; | ||
setState({ | ||
setState(prev => _objectSpread(_objectSpread({}, prev), {}, { | ||
visible: false | ||
}); | ||
})); | ||
}; | ||
const handleMouseDown = () => { | ||
@@ -166,7 +139,6 @@ mouseDown.current = true; | ||
}; | ||
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.default, { | ||
const highlight = (0, _react.useCallback)(value => /*#__PURE__*/_react.default.createElement(_prismReactRenderer.Highlight, { | ||
theme: userTheme, | ||
Prism: _prismReactRenderer.Prism, | ||
prism: _prismReactRenderer.Prism, | ||
code: value, | ||
@@ -187,3 +159,2 @@ language: language | ||
}))), [userTheme, lineNumbers, language, errorLocation]); | ||
const baseTheme = _objectSpread(_objectSpread({ | ||
@@ -193,3 +164,2 @@ whiteSpace: 'pre', | ||
}, (userTheme === null || userTheme === void 0 ? void 0 : userTheme.plain) || {}), style); | ||
return /*#__PURE__*/_react.default.createElement("div", { | ||
@@ -232,4 +202,2 @@ ref: ref, | ||
}); | ||
var _default = Editor; | ||
exports.default = _default; | ||
var _default = exports.default = Editor; |
import React from 'react'; | ||
/** | ||
* Displays an sytax or runtime error that occured when rendering the code | ||
* | ||
* Displays an syntax or runtime error that occurred when rendering the code | ||
*/ | ||
export default function Error(props: React.HTMLProps<HTMLPreElement>): JSX.Element | null; | ||
export default function Error(props: React.HTMLProps<HTMLPreElement>): import("react/jsx-runtime").JSX.Element | null; | ||
//# sourceMappingURL=Error.d.ts.map |
@@ -7,12 +7,7 @@ "use strict"; | ||
exports.default = Error; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _Provider = require("./Provider"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _Provider = require("./Provider.js"); | ||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } | ||
/** | ||
* Displays an sytax or runtime error that occured when rendering the code | ||
* | ||
* Displays an syntax or runtime error that occurred when rendering the code | ||
*/ | ||
@@ -19,0 +14,0 @@ function Error(props) { |
import React from 'react'; | ||
import { Context } from './Provider'; | ||
import { Context } from './Provider.js'; | ||
interface Props { | ||
@@ -14,1 +14,2 @@ element: React.ReactNode; | ||
export default CodeLiveErrorBoundary; | ||
//# sourceMappingURL=ErrorBoundary.d.ts.map |
@@ -7,9 +7,5 @@ "use strict"; | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _Provider = require("./Provider"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _Provider = require("./Provider.js"); | ||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } | ||
class CodeLiveErrorBoundary extends _react.default.Component { | ||
@@ -19,3 +15,2 @@ componentDidCatch(error) { | ||
} | ||
render() { | ||
@@ -27,7 +22,4 @@ const { | ||
} | ||
} | ||
CodeLiveErrorBoundary.contextType = _Provider.Context; | ||
var _default = CodeLiveErrorBoundary; | ||
exports.default = _default; | ||
var _default = exports.default = CodeLiveErrorBoundary; |
@@ -1,2 +0,3 @@ | ||
declare const _default: (code: string, language?: string | undefined) => string; | ||
declare const _default: (code: string, language?: string) => string; | ||
export default _default; | ||
//# sourceMappingURL=highlight.d.ts.map |
@@ -7,5 +7,3 @@ "use strict"; | ||
exports.default = void 0; | ||
var _prismReactRenderer = require("prism-react-renderer"); | ||
var _default = (code, language) => { | ||
@@ -15,3 +13,2 @@ const grammar = language && _prismReactRenderer.Prism.languages[language]; | ||
}; | ||
exports.default = _default; |
@@ -1,11 +0,12 @@ | ||
import { Prism } from 'prism-react-renderer'; | ||
import CodeBlock from './CodeBlock'; | ||
import Editor from './Editor'; | ||
import Error from './Error'; | ||
import InfoMessage from './InfoMessage'; | ||
import Preview from './Preview'; | ||
import Provider, { ImportResolver as _ImportResolver } from './Provider'; | ||
import highlight from './highlight'; | ||
export declare type ImportResolver = _ImportResolver; | ||
export { Prism, CodeBlock, Error, Editor, Preview, Provider, InfoMessage, highlight, }; | ||
import { Prism, themes } from 'prism-react-renderer'; | ||
import CodeBlock from './CodeBlock.js'; | ||
import Editor from './Editor.js'; | ||
import Error from './Error.js'; | ||
import InfoMessage from './InfoMessage.js'; | ||
import Preview from './Preview.js'; | ||
import Provider, { ImportResolver as _ImportResolver } from './Provider.js'; | ||
import highlight from './highlight.js'; | ||
export type ImportResolver = _ImportResolver; | ||
export { Prism, CodeBlock, Error, Editor, Preview, Provider, InfoMessage, highlight, themes, }; | ||
export type { PrismTheme, Language } from 'prism-react-renderer'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -54,19 +54,16 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "themes", { | ||
enumerable: true, | ||
get: function () { | ||
return _prismReactRenderer.themes; | ||
} | ||
}); | ||
var _prismReactRenderer = require("prism-react-renderer"); | ||
var _CodeBlock = _interopRequireDefault(require("./CodeBlock")); | ||
var _Editor = _interopRequireDefault(require("./Editor")); | ||
var _Error = _interopRequireDefault(require("./Error")); | ||
var _InfoMessage = _interopRequireDefault(require("./InfoMessage")); | ||
var _Preview = _interopRequireDefault(require("./Preview")); | ||
var _Provider = _interopRequireDefault(require("./Provider")); | ||
var _highlight = _interopRequireDefault(require("./highlight")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _CodeBlock = _interopRequireDefault(require("./CodeBlock.js")); | ||
var _Editor = _interopRequireDefault(require("./Editor.js")); | ||
var _Error = _interopRequireDefault(require("./Error.js")); | ||
var _InfoMessage = _interopRequireDefault(require("./InfoMessage.js")); | ||
var _Preview = _interopRequireDefault(require("./Preview.js")); | ||
var _Provider = _interopRequireDefault(require("./Provider.js")); | ||
var _highlight = _interopRequireDefault(require("./highlight.js")); | ||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } |
import React from 'react'; | ||
export default function InfoMessage({ srOnly, ...props }: React.HTMLProps<HTMLDivElement> & { | ||
srOnly?: boolean; | ||
}): JSX.Element; | ||
}): import("react/jsx-runtime").JSX.Element; | ||
//# sourceMappingURL=InfoMessage.d.ts.map |
@@ -7,21 +7,13 @@ "use strict"; | ||
exports.default = InfoMessage; | ||
var _react = _interopRequireDefault(require("react")); | ||
const _excluded = ["srOnly"]; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
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 _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else 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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
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; } | ||
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); } | ||
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; } | ||
const srOnlyStyle = { | ||
@@ -36,9 +28,7 @@ clip: 'rect(1px, 1px, 1px, 1px)', | ||
}; | ||
function InfoMessage(_ref) { | ||
let { | ||
srOnly = false | ||
} = _ref, | ||
props = _objectWithoutProperties(_ref, _excluded); | ||
srOnly = false | ||
} = _ref, | ||
props = _objectWithoutProperties(_ref, _excluded); | ||
return /*#__PURE__*/_react.default.createElement("div", _extends({}, props, { | ||
@@ -45,0 +35,0 @@ style: _objectSpread({ |
@@ -1,2 +0,3 @@ | ||
declare function LineNumber({ children, className, theme, style }: any): JSX.Element; | ||
declare function LineNumber({ children, className, theme, style }: any): import("react/jsx-runtime").JSX.Element; | ||
export default LineNumber; | ||
//# sourceMappingURL=LineNumber.d.ts.map |
@@ -7,13 +7,9 @@ "use strict"; | ||
exports.default = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
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 _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else 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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
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); } | ||
const lineNumberStyle = { | ||
@@ -25,3 +21,2 @@ textAlign: 'right', | ||
}; | ||
function LineNumber({ | ||
@@ -39,4 +34,2 @@ children, | ||
} | ||
var _default = LineNumber; | ||
exports.default = _default; | ||
var _default = exports.default = LineNumber; |
/** | ||
* The component that renders the user's code. | ||
*/ | ||
declare const Preview: ({ className, holderTheme, ...props }: { | ||
className?: string | undefined; | ||
/** An optional holder.js theme */ | ||
holderTheme?: any; | ||
}) => JSX.Element | null; | ||
declare const Preview: ({ className, showLastValid, ...props }: { | ||
className?: string; | ||
/** | ||
* Whether an error should reset the preview to an empty state or keep showing the last valid code result. | ||
*/ | ||
showLastValid?: boolean; | ||
}) => import("react/jsx-runtime").JSX.Element | null; | ||
export default Preview; | ||
//# sourceMappingURL=Preview.d.ts.map |
@@ -7,89 +7,44 @@ "use strict"; | ||
exports.default = void 0; | ||
var _useCallbackRef = _interopRequireDefault(require("@restart/hooks/useCallbackRef")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _ErrorBoundary = _interopRequireDefault(require("./ErrorBoundary")); | ||
var _Provider = require("./Provider"); | ||
const _excluded = ["className", "holderTheme"]; | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
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 _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else 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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
let holderjs; | ||
if (typeof window !== 'undefined') { | ||
try { | ||
holderjs = require('holderjs'); | ||
} catch (err) { | ||
/** ignore */ | ||
} | ||
} | ||
var _ErrorBoundary = _interopRequireDefault(require("./ErrorBoundary.js")); | ||
var _Provider = require("./Provider.js"); | ||
const _excluded = ["className", "showLastValid"]; | ||
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; } | ||
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); } | ||
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; } | ||
/** | ||
* The component that renders the user's code. | ||
*/ | ||
const Preview = _ref => { | ||
let { | ||
className, | ||
holderTheme | ||
} = _ref, | ||
props = _objectWithoutProperties(_ref, _excluded); | ||
const [example, attachRef] = (0, _useCallbackRef.default)(); | ||
const hasTheme = !!holderTheme && holderjs; | ||
className, | ||
showLastValid = true | ||
} = _ref, | ||
props = _objectWithoutProperties(_ref, _excluded); | ||
const element = (0, _Provider.useElement)(); | ||
const error = (0, _Provider.useError)(); | ||
(0, _react.useEffect)(() => { | ||
if (hasTheme) holderjs.addTheme('userTheme', holderTheme); // eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [hasTheme]); | ||
(0, _react.useEffect)(() => { | ||
if (!example || !holderjs) return; | ||
holderjs.run({ | ||
theme: hasTheme ? 'userTheme' : undefined, | ||
images: example.querySelectorAll('img') | ||
}); | ||
}, [element, example, hasTheme]); // prevent links in examples from navigating | ||
// prevent links in examples from navigating | ||
const handleClick = e => { | ||
if (e.target.tagName === 'A' || e.target.closest('a')) e.preventDefault(); | ||
}; | ||
const previewProps = _objectSpread({ | ||
role: "region", | ||
"aria-label": "Code Example" | ||
role: 'region', | ||
'aria-label': 'Code Example' | ||
}, props); | ||
return error ? null : | ||
return !showLastValid && error ? null : | ||
/*#__PURE__*/ | ||
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events | ||
_react.default.createElement("div", _extends({ | ||
ref: attachRef, | ||
React.createElement("div", _extends({ | ||
className: className, | ||
onClick: handleClick | ||
}, previewProps), /*#__PURE__*/_react.default.createElement(_ErrorBoundary.default, { | ||
}, previewProps), /*#__PURE__*/React.createElement(_ErrorBoundary.default, { | ||
element: element | ||
})); | ||
}; | ||
var _default = Preview; | ||
exports.default = _default; | ||
var _default = exports.default = Preview; |
@@ -1,3 +0,3 @@ | ||
export declare type Language = 'markup' | 'bash' | 'clike' | 'c' | 'cpp' | 'css' | 'javascript' | 'jsx' | 'coffeescript' | 'actionscript' | 'css-extr' | 'diff' | 'git' | 'go' | 'graphql' | 'handlebars' | 'json' | 'less' | 'makefile' | 'markdown' | 'objectivec' | 'ocaml' | 'python' | 'reason' | 'sass' | 'scss' | 'sql' | 'stylus' | 'tsx' | 'typescript' | 'wasm' | 'yaml'; | ||
export declare type PrismThemeEntry = { | ||
export type Language = 'markup' | 'bash' | 'clike' | 'c' | 'cpp' | 'css' | 'javascript' | 'jsx' | 'coffeescript' | 'actionscript' | 'css-extr' | 'diff' | 'git' | 'go' | 'graphql' | 'handlebars' | 'json' | 'less' | 'makefile' | 'markdown' | 'objectivec' | 'ocaml' | 'python' | 'reason' | 'sass' | 'scss' | 'sql' | 'stylus' | 'tsx' | 'typescript' | 'wasm' | 'yaml'; | ||
export type PrismThemeEntry = { | ||
color?: string; | ||
@@ -11,3 +11,3 @@ backgroundColor?: string; | ||
}; | ||
export declare type PrismTheme = { | ||
export type PrismTheme = { | ||
plain: PrismThemeEntry; | ||
@@ -20,3 +20,3 @@ styles: Array<{ | ||
}; | ||
export declare type ThemeDict = { | ||
export type ThemeDict = { | ||
root: StyleObj; | ||
@@ -26,3 +26,3 @@ plain: StyleObj; | ||
}; | ||
export declare type Token = { | ||
export type Token = { | ||
types: string[]; | ||
@@ -32,10 +32,10 @@ content: string; | ||
}; | ||
export declare type PrismToken = { | ||
export type PrismToken = { | ||
type: string; | ||
content: Array<PrismToken | string> | string; | ||
}; | ||
export declare type StyleObj = { | ||
export type StyleObj = { | ||
[key: string]: string | number | null; | ||
}; | ||
export declare type LineInputProps = { | ||
export type LineInputProps = { | ||
key?: string; | ||
@@ -47,3 +47,3 @@ style?: StyleObj; | ||
}; | ||
export declare type LineOutputProps = { | ||
export type LineOutputProps = { | ||
key?: string; | ||
@@ -54,3 +54,3 @@ style?: StyleObj; | ||
}; | ||
export declare type TokenInputProps = { | ||
export type TokenInputProps = { | ||
key?: string; | ||
@@ -62,3 +62,3 @@ style?: StyleObj; | ||
}; | ||
export declare type TokenOutputProps = { | ||
export type TokenOutputProps = { | ||
key?: string; | ||
@@ -70,3 +70,3 @@ style?: StyleObj; | ||
}; | ||
export declare type RenderProps = { | ||
export type RenderProps = { | ||
tokens: Token[][]; | ||
@@ -78,1 +78,2 @@ className: string; | ||
}; | ||
//# sourceMappingURL=prism.d.ts.map |
@@ -1,4 +0,4 @@ | ||
import { PrismTheme } from 'prism-react-renderer'; | ||
import type { PrismTheme } from 'prism-react-renderer'; | ||
import React, { ReactNode } from 'react'; | ||
export declare type LiveError = Error & { | ||
export type LiveError = Error & { | ||
location?: { | ||
@@ -13,3 +13,3 @@ line: number; | ||
}; | ||
export declare const isTypeScriptEnabled: (language?: string | undefined) => boolean; | ||
export declare const isTypeScriptEnabled: (language?: string) => boolean; | ||
export interface LiveContext { | ||
@@ -26,3 +26,3 @@ code?: string; | ||
export declare const Context: React.Context<LiveContext>; | ||
export declare type ImportResolver = (requests: string[]) => Promise<Record<string, any> | any[]>; | ||
export type ImportResolver = (requests: string[]) => Promise<Record<string, any> | any[]>; | ||
export interface Props<TScope> { | ||
@@ -88,2 +88,3 @@ /** | ||
*/ | ||
export default function Provider<TScope extends {} = {}>({ scope, children, code: rawCode, language, theme, exportToRender, showImports, renderAsComponent, resolveImports, }: Props<TScope>): JSX.Element; | ||
export default function Provider<TScope extends {} = {}>({ scope, children, code: rawCode, language, theme, exportToRender, showImports, renderAsComponent, resolveImports, }: Props<TScope>): import("react/jsx-runtime").JSX.Element; | ||
//# sourceMappingURL=Provider.d.ts.map |
@@ -12,28 +12,15 @@ "use strict"; | ||
exports.useLiveContext = useLiveContext; | ||
var _useEventCallback = _interopRequireDefault(require("@restart/hooks/useEventCallback")); | ||
var _useMounted = _interopRequireDefault(require("@restart/hooks/useMounted")); | ||
var _hooks = require("@restart/hooks"); | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _reactIs = require("react-is"); | ||
var _transform = require("./transform"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
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 _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else 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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var _index = require("./transform/index.js"); | ||
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); } | ||
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; } | ||
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 { decode } from 'sourcemap-codec'; | ||
// try and match render() calls with arguments to avoid false positives with class components | ||
const hasRenderCall = code => !!code.match(/render\((?!\s*\))/gm); | ||
const prettierComment = /(\{\s*\/\*\s+prettier-ignore\s+\*\/\s*\})|(\/\/\s+prettier-ignore)/gim; | ||
@@ -44,3 +31,2 @@ const hooks = {}; | ||
}); | ||
const isTypeScriptEnabled = language => { | ||
@@ -51,9 +37,4 @@ if (!language) return false; | ||
}; | ||
exports.isTypeScriptEnabled = isTypeScriptEnabled; | ||
const Context = /*#__PURE__*/_react.default.createContext({}); | ||
exports.Context = Context; | ||
const Context = exports.Context = /*#__PURE__*/_react.default.createContext({}); | ||
const getRequire = imports => function require(request) { | ||
@@ -67,9 +48,7 @@ if (!imports) throw new Error('no imports'); | ||
}; | ||
function handleError(err, fn) { | ||
const fnStr = fn.toString(); // account for the function chrome lines | ||
const fnStr = fn.toString(); | ||
// account for the function chrome lines | ||
const offset = fnStr.slice(0, fnStr.indexOf('{')).split(/\n/).length; | ||
let pos; | ||
if ('line' in err) { | ||
@@ -87,3 +66,2 @@ pos = { | ||
var _err$stack; | ||
const [, line, col] = (_err$stack = err.stack) === null || _err$stack === void 0 ? void 0 : _err$stack.match(/at eval.+<anonymous>:(\d+):(\d+)/m); | ||
@@ -95,7 +73,10 @@ pos = { | ||
} | ||
if (!pos) return err; | ||
if (!pos) return err; // if (result.map) { | ||
// if (result.map) { | ||
// const decoded = decode(result.map.mappings); | ||
// const line = pos.line - offset; | ||
// const mapping = decoded[line]?.find(([col]) => col === pos.column); | ||
// if (mapping) { | ||
@@ -108,3 +89,2 @@ // err.location = { line: mapping[2], column: mapping[3] }; | ||
} | ||
function codeToComponent(compiledCode, { | ||
@@ -118,7 +98,5 @@ scope, | ||
const isInline = !hasRenderCall(compiledCode); | ||
if (renderAsComponent && !isInline) { | ||
throw new Error('Code using `render()` cannot use top level hooks. ' + 'Either provide your own stateful component, or return a jsx element directly.'); | ||
} | ||
const render = element => { | ||
@@ -129,10 +107,7 @@ if (element === undefined) { | ||
} | ||
resolve(element); | ||
}; | ||
resolve(element); | ||
}; // const [clearTimes, timers] = createTimers(); | ||
// DU NA NA NAAAH | ||
const finalScope = _objectSpread(_objectSpread({}, hooks), scope); | ||
const exports = {}; | ||
@@ -142,12 +117,10 @@ const args = ['React', 'render', 'exports'].concat(Object.keys(finalScope)); | ||
let body = compiledCode; | ||
if (renderAsComponent) { | ||
body = `return React.createElement(function StateContainer() {\n${body}\n})`; | ||
} | ||
if (preample) body = `${preample}\n\n${body}`; | ||
if (preample) body = `${preample}\n\n${body}`; // eslint-disable-next-line no-new-func | ||
// eslint-disable-next-line no-new-func | ||
const fn = new Function(...args, body); | ||
let element; | ||
try { | ||
@@ -159,15 +132,10 @@ element = fn(...values); | ||
} | ||
const exportedValues = Object.values(exports); | ||
if ('default' in exports) { | ||
var _exports$default; | ||
element = (_exports$default = exports.default) !== null && _exports$default !== void 0 ? _exports$default : element; | ||
} else if (exportedValues.length) { | ||
var _ref, _exports; | ||
element = (_ref = (_exports = exports[exportToRender]) !== null && _exports !== void 0 ? _exports : exportedValues[0]) !== null && _ref !== void 0 ? _ref : element; | ||
} | ||
if (element === undefined) { | ||
@@ -177,6 +145,4 @@ if (isInline) { | ||
} | ||
return; | ||
} | ||
if (! /*#__PURE__*/(0, _react.isValidElement)(element)) { | ||
@@ -189,23 +155,16 @@ if ((0, _reactIs.isValidElementType)(element)) { | ||
} | ||
resolve(element); | ||
}); | ||
} | ||
function useLiveContext() { | ||
return (0, _react.useContext)(Context); | ||
} | ||
function useElement() { | ||
return useLiveContext().element; | ||
} | ||
function useError() { | ||
return useLiveContext().error; | ||
} | ||
const objectZip = (arr, arr2) => Object.fromEntries(arr.map((v, i) => [v, arr2[i]])); | ||
exports.objectZip = objectZip; | ||
function defaultResolveImports(sources) { | ||
@@ -215,3 +174,2 @@ // @ts-ignore | ||
} | ||
function useCompiledCode(consumerCode, showImports, isTypeScript, setError) { | ||
@@ -221,3 +179,3 @@ const compile = (0, _react.useCallback)(nextCode => { | ||
nextCode = nextCode.replace(prettierComment, '').trim(); | ||
return (0, _transform.transform)(nextCode, { | ||
return (0, _index.transform)(nextCode, { | ||
compiledFilename: 'compiled.js', | ||
@@ -236,3 +194,2 @@ filename: 'example.js', | ||
}; | ||
if (showImports) { | ||
@@ -244,5 +201,4 @@ return { | ||
} | ||
try { | ||
return (0, _transform.transform)(nextCode, { | ||
return (0, _index.transform)(nextCode, { | ||
syntax: isTypeScript ? 'typescript' : 'js', | ||
@@ -267,2 +223,3 @@ compiledFilename: 'compiled.js', | ||
} | ||
/** | ||
@@ -272,4 +229,2 @@ * The Provider supplies the context to the other components as well as handling | ||
*/ | ||
function Provider({ | ||
@@ -286,3 +241,3 @@ scope, | ||
}) { | ||
const isMounted = (0, _useMounted.default)(); | ||
const isMounted = (0, _hooks.useMounted)(); | ||
const [error, setError] = (0, _react.useState)(null); | ||
@@ -297,3 +252,3 @@ const [{ | ||
const initialCompiledCode = initialResult.compiledCode; | ||
const handleChange = (0, _useEventCallback.default)(nextCode => { | ||
const handleChange = (0, _hooks.useEventCallback)(nextCode => { | ||
try { | ||
@@ -300,0 +255,0 @@ const { |
import { SucraseContext } from 'sucrase'; | ||
import { TokenProcessor, CJSImportProcessor } from './parser'; | ||
export declare type Import = { | ||
import { TokenProcessor, type CJSImportProcessor } from './parser.js'; | ||
export type Import = { | ||
code: string; | ||
@@ -28,1 +28,2 @@ source: string; | ||
} | ||
//# sourceMappingURL=ImportTransformer.d.ts.map |
@@ -7,7 +7,6 @@ "use strict"; | ||
exports.default = void 0; | ||
var _parser = require("./parser"); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var _parser = require("./parser.js"); | ||
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); } | ||
class ImportRemoverTransformer { | ||
@@ -18,48 +17,37 @@ constructor(context, { | ||
_defineProperty(this, "tokens", void 0); | ||
_defineProperty(this, "importProcessor", void 0); | ||
_defineProperty(this, "imports", []); | ||
_defineProperty(this, "removeImports", void 0); | ||
_defineProperty(this, "num", 0); | ||
this.tokens = context.tokenProcessor; | ||
this.importProcessor = context.importProcessor; | ||
this.removeImports = removeImports || false; // clear the replacements b/c we are handling imports | ||
this.removeImports = removeImports || false; | ||
// clear the replacements b/c we are handling imports | ||
// @ts-ignore private | ||
this.importProcessor.identifierReplacements.clear(); | ||
} | ||
getPrefixCode() { | ||
return ''; | ||
} | ||
getHoistedCode() { | ||
return ''; | ||
} | ||
getSuffixCode() { | ||
return ''; | ||
} | ||
process() { | ||
if (!this.tokens.matches1(_parser.tt._import)) return false; // dynamic import | ||
if (!this.tokens.matches1(_parser.tt._import)) return false; | ||
// dynamic import | ||
if (this.tokens.matches2(_parser.tt._import, _parser.tt.parenL)) { | ||
return true; | ||
} | ||
this.tokens.removeInitialToken(); | ||
while (!this.tokens.matches1(_parser.tt.string)) { | ||
this.tokens.removeToken(); | ||
} | ||
const path = this.tokens.stringValue(); | ||
const detail = this.buildImport(path); | ||
this.importProcessor.claimImportCode(path); | ||
if (detail !== null && detail !== void 0 && detail.code) { | ||
@@ -71,14 +59,10 @@ this.imports.push(detail); | ||
} | ||
if (this.tokens.matches1(_parser.tt.semi)) { | ||
this.tokens.removeToken(); | ||
} | ||
return true; | ||
} | ||
getIdentifier(src) { | ||
return `${src.split('/').pop().replace(/\W/g, '_')}$${this.num++}`; | ||
} | ||
buildImport(path) { | ||
@@ -89,3 +73,2 @@ // @ts-ignore | ||
} | ||
let FN = 'require'; | ||
@@ -97,3 +80,4 @@ const { | ||
hasBareImport | ||
} = // @ts-ignore | ||
} = | ||
// @ts-ignore | ||
this.importProcessor.importInfoByPath.get(path); | ||
@@ -110,6 +94,5 @@ const req = `${FN}('${path}');`; | ||
namedImports.forEach(s => { | ||
if (this.importProcessor.isTypeName(s.localName)) { | ||
if (this.importProcessor.shouldAutomaticallyElideImportedName(s.localName)) { | ||
return; | ||
} | ||
named.push(s.localName === s.importedName ? s.localName : `${s.importedName}: ${s.localName}`); | ||
@@ -121,10 +104,8 @@ details.keys.push({ | ||
}); | ||
if (defaultNames.length || wildcardNames.length) { | ||
const name = defaultNames[0] || wildcardNames[0]; | ||
if (!this.importProcessor.isTypeName(name)) { | ||
details.base = name; // intentionally use `var` so that conflcits with Jarle provider scope get resolved naturally | ||
if (!this.importProcessor.shouldAutomaticallyElideImportedName(name)) { | ||
details.base = name; | ||
// intentionally use `var` so that conflcits with Jarle provider scope get resolved naturally | ||
// with the import overriding the scoped identifier | ||
if (wildcardNames.length) { | ||
@@ -137,17 +118,12 @@ details.code = `var ${name} = ${req}`; | ||
} | ||
if (named.length) { | ||
details.code += ` var { ${named.join(', ')} } = ${details.code ? `${tmp};` : req}`; | ||
} | ||
if (hasBareImport) { | ||
details.code = req; | ||
} | ||
details.code = details.code.trim(); | ||
return details; | ||
} | ||
} | ||
exports.default = ImportRemoverTransformer; |
@@ -1,3 +0,3 @@ | ||
import { Transform } from 'sucrase/dist/Options'; | ||
import { Import } from './ImportTransformer'; | ||
import type { Transform } from 'sucrase'; | ||
import { Import } from './ImportTransformer.js'; | ||
export type { Import }; | ||
@@ -16,1 +16,2 @@ export interface Options { | ||
}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -7,49 +7,37 @@ "use strict"; | ||
exports.transform = transform; | ||
var _ImportTransformer = _interopRequireDefault(require("./ImportTransformer")); | ||
var _parser = require("./parser"); | ||
var _wrapLastExpression = _interopRequireDefault(require("./wrapLastExpression")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
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 _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else 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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var _ImportTransformer = _interopRequireDefault(require("./ImportTransformer.js")); | ||
var _parser = require("./parser.js"); | ||
var _wrapLastExpression2 = _interopRequireDefault(require("./wrapLastExpression.js")); | ||
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); } | ||
class JarleRootTransformer extends _parser.RootTransformer { | ||
constructor(context, options, parsingTransforms) { | ||
var _options$transforms; | ||
super(context, (_options$transforms = options.transforms) !== null && _options$transforms !== void 0 ? _options$transforms : [], false, _objectSpread({}, options)); | ||
_defineProperty(this, "importTransformer", void 0); | ||
_defineProperty(this, "wrapLastExpression", void 0); | ||
this.importTransformer = new _ImportTransformer.default(context, options); | ||
this.importTransformer = new _ImportTransformer.default(context, options); // @ts-ignore | ||
// @ts-ignore | ||
this.transformers.unshift(this.importTransformer); | ||
this.wrapLastExpression = options.wrapLastExpression ? result => { | ||
return (0, _wrapLastExpression.default)((0, _parser.getSucraseContext)(result, _objectSpread(_objectSpread({}, options), {}, { | ||
var _wrapLastExpression; | ||
return (_wrapLastExpression = (0, _wrapLastExpression2.default)((0, _parser.getSucraseContext)(result.code, _objectSpread(_objectSpread({}, options), {}, { | ||
transforms: parsingTransforms | ||
}))); | ||
})))) !== null && _wrapLastExpression !== void 0 ? _wrapLastExpression : result; | ||
} : result => result; | ||
} | ||
get imports() { | ||
return this.importTransformer.imports; | ||
} | ||
transform() { | ||
let result = super.transform(); | ||
result = result.replace('"use strict";', '').replace('exports. default =', 'exports.default =').replace('Object.defineProperty(exports, "__esModule", {value: true});', ''); | ||
result.code = result.code.replace('"use strict";', '').replace('exports. default =', 'exports.default =').replace('Object.defineProperty(exports, "__esModule", {value: true});', ''); | ||
return this.wrapLastExpression(result); | ||
} | ||
} | ||
function transform(code, options = {}) { | ||
@@ -59,7 +47,5 @@ const transforms = options.transforms || []; | ||
const isTypeScriptEnabled = options.syntax === 'typescript' || transforms.includes('typescript'); | ||
if (isTypeScriptEnabled) { | ||
parsingTransforms.push('typescript'); | ||
} | ||
const sucraseOptions = _objectSpread(_objectSpread({}, options), {}, { | ||
@@ -72,3 +58,2 @@ transforms, | ||
}); | ||
const ctx = (0, _parser.getSucraseContext)(code, _objectSpread(_objectSpread({}, sucraseOptions), {}, { | ||
@@ -79,5 +64,5 @@ transforms: parsingTransforms | ||
return { | ||
code: transformer.transform(), | ||
code: transformer.transform().code, | ||
imports: transformer.imports | ||
}; | ||
} |
import { SucraseContext } from 'sucrase'; | ||
export default function wrapLastExpression({ tokenProcessor }: SucraseContext): string; | ||
export default function wrapLastExpression({ tokenProcessor }: SucraseContext): import("sucrase/dist/types/TokenProcessor.js").TokenProcessorResult | undefined; | ||
//# sourceMappingURL=wrapLastExpression.d.ts.map |
@@ -7,32 +7,24 @@ "use strict"; | ||
exports.default = wrapLastExpression; | ||
var _parser = require("./parser"); | ||
var _parser = require("./parser.js"); | ||
function findLastExpression(tokens) { | ||
let lastExprIdx = null; | ||
for (let i = 0; i < tokens.tokens.length; i++) { | ||
if (tokens.matches2AtIndex(i, _parser.tt._export, _parser.tt._default)) { | ||
return null; | ||
} // @ts-ignore | ||
} | ||
// @ts-ignore | ||
if (tokens.tokens[i].isTopLevel) { | ||
const code = tokens.code.slice(tokens.tokens[i].start, tokens.tokens[i].end); | ||
if (code.startsWith('exports')) { | ||
return null; | ||
} | ||
if (tokens.matches1AtIndex(i, _parser.tt._return)) { | ||
return null; | ||
} | ||
lastExprIdx = i; | ||
} | ||
} | ||
return lastExprIdx; | ||
} | ||
function process(tokens, lastIndex) { | ||
@@ -42,6 +34,4 @@ if (tokens.currentIndex() !== lastIndex) { | ||
} | ||
let prev = tokens.currentIndex() - 1; | ||
let lastWasSemi = prev >= 0 && !tokens.matches1AtIndex(prev, _parser.tt.semi); | ||
if (tokens.matches2(_parser.tt._export, _parser.tt._default)) { | ||
@@ -52,13 +42,9 @@ tokens.removeInitialToken(); | ||
let code = `return ${tokens.currentTokenCode()}`; | ||
if (lastWasSemi) { | ||
code = `;${code}`; | ||
} | ||
tokens.replaceTokenTrimmingLeftWhitespace(code); | ||
} | ||
return true; | ||
} | ||
function wrapLastExpression({ | ||
@@ -68,10 +54,7 @@ tokenProcessor | ||
let lastExprIdx = findLastExpression(tokenProcessor); | ||
if (lastExprIdx == null) { | ||
return tokenProcessor.code; | ||
return; | ||
} | ||
while (!tokenProcessor.isAtEnd()) { | ||
let wasProcessed = process(tokenProcessor, lastExprIdx); | ||
if (!wasProcessed) { | ||
@@ -81,4 +64,3 @@ tokenProcessor.copyToken(); | ||
} | ||
return tokenProcessor.finish(); | ||
} |
@@ -1,3 +0,3 @@ | ||
import { Import } from './transform'; | ||
export declare type Options = { | ||
import { Import } from './transform/index.ts'; | ||
export type Options = { | ||
inline?: boolean; | ||
@@ -13,1 +13,2 @@ isTypeScript?: boolean; | ||
export default _default; | ||
//# sourceMappingURL=transpile.d.ts.map |
@@ -7,5 +7,3 @@ "use strict"; | ||
exports.default = void 0; | ||
var _transform = require("./transform"); | ||
var _index = require("./transform/index.ts"); | ||
var _default = (input, { | ||
@@ -19,3 +17,3 @@ inline: _inline = false, | ||
imports | ||
} = (0, _transform.transform)(input, { | ||
} = (0, _index.transform)(input, { | ||
removeImports: !showImports, | ||
@@ -32,3 +30,2 @@ wrapLastExpression: _inline, | ||
}; | ||
exports.default = _default; |
@@ -30,1 +30,2 @@ /** | ||
export default useInterval; | ||
//# sourceMappingURL=useTest.d.ts.map |
@@ -7,16 +7,38 @@ "use strict"; | ||
exports.default = void 0; | ||
var _react = require("react"); | ||
var _hooks = require("@restart/hooks"); | ||
/** | ||
* Creates a `setInterval` that is properly cleaned up when a component unmounted | ||
* | ||
* @public | ||
* @param fn an function run on each interval | ||
* @param ms The milliseconds duration of the interval | ||
*/ | ||
var _useCommittedRef = _interopRequireDefault(require("@restart/hooks/useCommittedRef")); | ||
/** | ||
* Creates a pausable `setInterval` that is properly cleaned up when a component unmounted | ||
* | ||
* @public | ||
* @param fn an function run on each interval | ||
* @param ms The milliseconds duration of the interval | ||
* @param paused Whether or not the interval is currently running | ||
*/ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
* Creates a pausable `setInterval` that is properly cleaned up when a component unmounted | ||
* | ||
* @public | ||
* @param fn an function run on each interval | ||
* @param ms The milliseconds duration of the interval | ||
* @param paused Whether or not the interval is currently running | ||
* @param runImmediately Whether to run the function immediately on mount or unpause | ||
* rather than waiting for the first interval to elapse | ||
*/ | ||
function useInterval(fn, ms, paused = false, runImmediately = false) { | ||
let handle; | ||
const fnRef = (0, _useCommittedRef.default)(fn); // this ref is necessary b/c useEffect will sometimes miss a paused toggle | ||
const fnRef = (0, _hooks.useCommittedRef)(fn); | ||
// this ref is necessary b/c useEffect will sometimes miss a paused toggle | ||
// orphaning a setTimeout chain in the aether, so relying on it's refresh logic is not reliable. | ||
const pausedRef = (0, _useCommittedRef.default)(paused); | ||
const pausedRef = (0, _hooks.useCommittedRef)(paused); | ||
const tick = () => { | ||
@@ -27,3 +49,2 @@ if (pausedRef.current) return; | ||
}; | ||
const schedule = () => { | ||
@@ -33,3 +54,2 @@ clearTimeout(handle); | ||
}; | ||
(0, _react.useEffect)(() => { | ||
@@ -41,8 +61,5 @@ if (runImmediately) { | ||
} | ||
return () => clearTimeout(handle); | ||
}, [paused, runImmediately]); | ||
} | ||
var _default = useInterval; | ||
exports.default = _default; | ||
var _default = exports.default = useInterval; |
{ | ||
"name": "jarle", | ||
"version": "2.1.1", | ||
"main": "lib/index.js", | ||
"module": "esm/index.js", | ||
"version": "3.0.0-beta.0", | ||
"repository": { | ||
@@ -13,25 +11,38 @@ "type": "git", | ||
"scripts": { | ||
"add-import": "sed -i '' 's/__IMPORT__/(s) => import(\\/\\* webpackIgnore: true \\*\\/ \\/\\* @vite-ignore \\*\\/ s)/' ./{lib,esm}/Provider.js", | ||
"build:parser": "yarn patch-package && yarn rollup -c rollup.config.js", | ||
"build": "yarn build:parser && 4c build src && yarn add-import && node ./build-themes.js", | ||
"build": "./build.sh", | ||
"prepublishOnly": "yarn run build", | ||
"release": "4c release", | ||
"tdd": "jest --watch", | ||
"test": "jest" | ||
"tdd": "vitest", | ||
"test": "vitest run" | ||
}, | ||
"files": [ | ||
"esm", | ||
"lib", | ||
"themes" | ||
"lib" | ||
], | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"require": { | ||
"types": "./lib/index.d.ts", | ||
"default": "./lib/index.js" | ||
}, | ||
"import": { | ||
"types": "./esm/index.d.ts", | ||
"default": "./esm/index.js" | ||
} | ||
}, | ||
"./*": { | ||
"require": { | ||
"types": "./lib/*.d.ts", | ||
"default": "./lib/*.js" | ||
}, | ||
"import": { | ||
"types": "./esm/*.d.ts", | ||
"default": "./esm/*.js" | ||
} | ||
} | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"jest": { | ||
"preset": "@4c/jest-preset", | ||
"testEnvironment": "jsdom", | ||
"setupFilesAfterEnv": [ | ||
"./test/setup.ts" | ||
] | ||
}, | ||
"prettier": { | ||
@@ -42,12 +53,10 @@ "singleQuote": true | ||
"@4c/cli": "^3.0.1", | ||
"@4c/jest-preset": "^1.6.2", | ||
"@4c/tsconfig": "^0.4.0", | ||
"@babel/cli": "^7.15.7", | ||
"@babel/core": "^7.15.8", | ||
"@babel/preset-env": "^7.15.8", | ||
"@babel/preset-typescript": "^7.15.0", | ||
"@babel/cli": "^7.24.7", | ||
"@babel/core": "^7.24.7", | ||
"@babel/preset-env": "^7.24.7", | ||
"@babel/preset-react": "^7.24.7", | ||
"@babel/preset-typescript": "^7.24.7", | ||
"@rollup/plugin-commonjs": "^21.0.1", | ||
"@rollup/plugin-node-resolve": "^13.0.6", | ||
"@types/enzyme": "^3.10.10", | ||
"@types/jest": "^27.0.2", | ||
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.5", | ||
@@ -57,11 +66,5 @@ "cpy": "^8.1.2", | ||
"enzyme-adapter-react-16": "^1.15.6", | ||
"eslint-config-4catalyzer-jest": "^2.1.2", | ||
"eslint-config-4catalyzer-react": "^1.1.3", | ||
"eslint-config-4catalyzer-typescript": "^3.1.2", | ||
"eslint-plugin-import": "^2.25.2", | ||
"eslint-plugin-jest": "^25.2.2", | ||
"eslint-plugin-react": "^7.26.1", | ||
"glob": "^7.2.0", | ||
"jest": "^27.3.1", | ||
"patch-package": "^6.4.7", | ||
"jsdom": "^24.1.0", | ||
"patch-package": "^8.0.0", | ||
"react": "^17.0.2", | ||
@@ -71,10 +74,12 @@ "react-dom": "^17.0.2", | ||
"rollup-plugin-dts": "^4.0.1", | ||
"sucrase": "^3.29.0" | ||
"sucrase": "^3.35.0", | ||
"typescript": "^5.4.5", | ||
"vitest": "^1.6.0" | ||
}, | ||
"dependencies": { | ||
"@restart/hooks": "^0.4.1", | ||
"@types/react": "^17.0.33", | ||
"@types/react-dom": "^17.0.10", | ||
"@restart/hooks": "^0.4.16", | ||
"@types/react": "^17.0.80", | ||
"@types/react-dom": "^17.0.25", | ||
"@types/react-is": "^17.0.3", | ||
"prism-react-renderer": "^1.2.1", | ||
"prism-react-renderer": "^2.3.1", | ||
"react-is": "^17.0.2", | ||
@@ -81,0 +86,0 @@ "react-simple-code-editor": "^0.11.0", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1378353
23
Yes
103
12377
2
+ Added@types/prismjs@1.26.5(transitive)
+ Addedclsx@2.1.1(transitive)
+ Addedprism-react-renderer@2.4.1(transitive)
- Removedprism-react-renderer@1.3.5(transitive)
Updated@restart/hooks@^0.4.16
Updated@types/react@^17.0.80
Updated@types/react-dom@^17.0.25
Updatedprism-react-renderer@^2.3.1