@atlaskit/code 14.4.8 → 14.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cjs/bidi-warning/bidi-warning-decorator.js +8 -0
  3. package/dist/cjs/bidi-warning/ui/index.js +8 -0
  4. package/dist/cjs/code-block.js +22 -20
  5. package/dist/cjs/internal/theme/styles.js +20 -9
  6. package/dist/cjs/syntax-highlighter/async.js +88 -0
  7. package/dist/cjs/syntax-highlighter/index.js +44 -0
  8. package/dist/cjs/syntax-highlighter/lib/highlight.js +91 -0
  9. package/dist/cjs/syntax-highlighter/lib/process/create-line-element.js +74 -0
  10. package/dist/cjs/syntax-highlighter/lib/process/create-line.js +32 -0
  11. package/dist/cjs/syntax-highlighter/lib/process/flatten-code-tree.js +29 -0
  12. package/dist/cjs/syntax-highlighter/lib/process/get-code-tree.js +22 -0
  13. package/dist/cjs/syntax-highlighter/lib/process/get-inline-line-number.js +23 -0
  14. package/dist/cjs/syntax-highlighter/lib/process/index.js +122 -0
  15. package/dist/cjs/syntax-highlighter/lib/react-renderer/create-children.js +21 -0
  16. package/dist/cjs/syntax-highlighter/lib/react-renderer/create-element.js +57 -0
  17. package/dist/cjs/syntax-highlighter/lib/react-renderer/index.js +30 -0
  18. package/dist/cjs/syntax-highlighter/types.js +31 -0
  19. package/dist/cjs/version.json +1 -1
  20. package/dist/es2019/bidi-warning/bidi-warning-decorator.js +8 -0
  21. package/dist/es2019/bidi-warning/ui/index.js +8 -0
  22. package/dist/es2019/code-block.js +18 -18
  23. package/dist/es2019/internal/theme/styles.js +20 -9
  24. package/dist/es2019/syntax-highlighter/async.js +51 -0
  25. package/dist/es2019/syntax-highlighter/index.js +38 -0
  26. package/dist/es2019/syntax-highlighter/lib/highlight.js +73 -0
  27. package/dist/es2019/syntax-highlighter/lib/process/create-line-element.js +65 -0
  28. package/dist/es2019/syntax-highlighter/lib/process/create-line.js +23 -0
  29. package/dist/es2019/syntax-highlighter/lib/process/flatten-code-tree.js +18 -0
  30. package/dist/es2019/syntax-highlighter/lib/process/get-code-tree.js +16 -0
  31. package/dist/es2019/syntax-highlighter/lib/process/get-inline-line-number.js +17 -0
  32. package/dist/es2019/syntax-highlighter/lib/process/index.js +114 -0
  33. package/dist/es2019/syntax-highlighter/lib/react-renderer/create-children.js +12 -0
  34. package/dist/es2019/syntax-highlighter/lib/react-renderer/create-element.js +53 -0
  35. package/dist/es2019/syntax-highlighter/lib/react-renderer/index.js +23 -0
  36. package/dist/es2019/syntax-highlighter/types.js +9 -0
  37. package/dist/es2019/version.json +1 -1
  38. package/dist/esm/bidi-warning/bidi-warning-decorator.js +8 -0
  39. package/dist/esm/bidi-warning/ui/index.js +8 -0
  40. package/dist/esm/code-block.js +20 -19
  41. package/dist/esm/internal/theme/styles.js +20 -9
  42. package/dist/esm/syntax-highlighter/async.js +76 -0
  43. package/dist/esm/syntax-highlighter/index.js +38 -0
  44. package/dist/esm/syntax-highlighter/lib/highlight.js +84 -0
  45. package/dist/esm/syntax-highlighter/lib/process/create-line-element.js +67 -0
  46. package/dist/esm/syntax-highlighter/lib/process/create-line.js +24 -0
  47. package/dist/esm/syntax-highlighter/lib/process/flatten-code-tree.js +22 -0
  48. package/dist/esm/syntax-highlighter/lib/process/get-code-tree.js +16 -0
  49. package/dist/esm/syntax-highlighter/lib/process/get-inline-line-number.js +17 -0
  50. package/dist/esm/syntax-highlighter/lib/process/index.js +115 -0
  51. package/dist/esm/syntax-highlighter/lib/react-renderer/create-children.js +14 -0
  52. package/dist/esm/syntax-highlighter/lib/react-renderer/create-element.js +50 -0
  53. package/dist/esm/syntax-highlighter/lib/react-renderer/index.js +24 -0
  54. package/dist/esm/syntax-highlighter/types.js +24 -0
  55. package/dist/esm/version.json +1 -1
  56. package/dist/types/bidi-warning/bidi-warning-decorator.d.ts +7 -0
  57. package/dist/types/bidi-warning/ui/index.d.ts +8 -0
  58. package/dist/types/bidi-warning/ui/types.d.ts +11 -15
  59. package/dist/types/extract-react-types/code-block.d.ts +24 -14
  60. package/dist/types/internal/theme/styles.d.ts +1 -1
  61. package/dist/types/internal/types.d.ts +31 -18
  62. package/dist/types/syntax-highlighter/async.d.ts +3 -0
  63. package/dist/types/syntax-highlighter/index.d.ts +36 -0
  64. package/dist/types/syntax-highlighter/lib/highlight.d.ts +12 -0
  65. package/dist/types/syntax-highlighter/lib/process/create-line-element.d.ts +9 -0
  66. package/dist/types/syntax-highlighter/lib/process/create-line.d.ts +3 -0
  67. package/dist/types/syntax-highlighter/lib/process/flatten-code-tree.d.ts +2 -0
  68. package/dist/types/syntax-highlighter/lib/process/get-code-tree.d.ts +2 -0
  69. package/dist/types/syntax-highlighter/lib/process/get-inline-line-number.d.ts +2 -0
  70. package/dist/types/syntax-highlighter/lib/process/index.d.ts +17 -0
  71. package/dist/types/syntax-highlighter/lib/react-renderer/create-children.d.ts +3 -0
  72. package/dist/types/syntax-highlighter/lib/react-renderer/create-element.d.ts +7 -0
  73. package/dist/types/syntax-highlighter/lib/react-renderer/index.d.ts +15 -0
  74. package/dist/types/syntax-highlighter/types.d.ts +129 -0
  75. package/dist/types/types.d.ts +10 -11
  76. package/package.json +14 -10
  77. package/report.api.md +1 -0
  78. package/dist/cjs/react-syntax-highlighter-bidi-warning-renderer.js +0 -156
  79. package/dist/es2019/react-syntax-highlighter-bidi-warning-renderer.js +0 -149
  80. package/dist/esm/react-syntax-highlighter-bidi-warning-renderer.js +0 -155
  81. package/dist/types/react-syntax-highlighter-bidi-warning-renderer.d.ts +0 -9
@@ -1,149 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- // @ts-nocheck
3
- import React from 'react';
4
- import CodeBidiWarning from './bidi-warning';
5
- import codeBidiWarningDecorator from './bidi-warning/bidi-warning-decorator';
6
-
7
- // File mostly vendored from react-syntax-highlighter
8
- //
9
- // - https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/efc3f7b7537d1729193b7a472067bcbe6cbecaf1/src/highlight.js#L272-L281
10
- // - https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/efc3f7b7537d1729193b7a472067bcbe6cbecaf1/src/create-element.js
11
- //
12
- // Patching react syntax-highlighter with a decoration feature is likely preferable
13
-
14
- export function createBidiWarningRenderer(codeBidiWarningConfig) {
15
- return function bidiWarningRenderer({
16
- rows,
17
- stylesheet,
18
- useInlineStyles
19
- }) {
20
- return rows.map((node, i) => createElement({
21
- node,
22
- stylesheet,
23
- useInlineStyles,
24
- codeBidiWarningConfig,
25
- key: `code-segement${i}`
26
- }));
27
- };
28
- }
29
-
30
- // Get all possible permutations of all power sets
31
- //
32
- // Super simple, non-algorithmic solution since the
33
- // number of class names will not be greater than 4
34
- function powerSetPermutations(arr) {
35
- const arrLength = arr.length;
36
- if (arrLength === 0 || arrLength === 1) {
37
- return arr;
38
- }
39
- if (arrLength === 2) {
40
- // prettier-ignore
41
- return [arr[0], arr[1], `${arr[0]}.${arr[1]}`, `${arr[1]}.${arr[0]}`];
42
- }
43
- if (arrLength === 3) {
44
- return [arr[0], arr[1], arr[2], `${arr[0]}.${arr[1]}`, `${arr[0]}.${arr[2]}`, `${arr[1]}.${arr[0]}`, `${arr[1]}.${arr[2]}`, `${arr[2]}.${arr[0]}`, `${arr[2]}.${arr[1]}`, `${arr[0]}.${arr[1]}.${arr[2]}`, `${arr[0]}.${arr[2]}.${arr[1]}`, `${arr[1]}.${arr[0]}.${arr[2]}`, `${arr[1]}.${arr[2]}.${arr[0]}`, `${arr[2]}.${arr[0]}.${arr[1]}`, `${arr[2]}.${arr[1]}.${arr[0]}`];
45
- }
46
- if (arrLength >= 4) {
47
- // Currently does not support more than 4 extra
48
- // class names (after `.token` has been removed)
49
- return [arr[0], arr[1], arr[2], arr[3], `${arr[0]}.${arr[1]}`, `${arr[0]}.${arr[2]}`, `${arr[0]}.${arr[3]}`, `${arr[1]}.${arr[0]}`, `${arr[1]}.${arr[2]}`, `${arr[1]}.${arr[3]}`, `${arr[2]}.${arr[0]}`, `${arr[2]}.${arr[1]}`, `${arr[2]}.${arr[3]}`, `${arr[3]}.${arr[0]}`, `${arr[3]}.${arr[1]}`, `${arr[3]}.${arr[2]}`, `${arr[0]}.${arr[1]}.${arr[2]}`, `${arr[0]}.${arr[1]}.${arr[3]}`, `${arr[0]}.${arr[2]}.${arr[1]}`, `${arr[0]}.${arr[2]}.${arr[3]}`, `${arr[0]}.${arr[3]}.${arr[1]}`, `${arr[0]}.${arr[3]}.${arr[2]}`, `${arr[1]}.${arr[0]}.${arr[2]}`, `${arr[1]}.${arr[0]}.${arr[3]}`, `${arr[1]}.${arr[2]}.${arr[0]}`, `${arr[1]}.${arr[2]}.${arr[3]}`, `${arr[1]}.${arr[3]}.${arr[0]}`, `${arr[1]}.${arr[3]}.${arr[2]}`, `${arr[2]}.${arr[0]}.${arr[1]}`, `${arr[2]}.${arr[0]}.${arr[3]}`, `${arr[2]}.${arr[1]}.${arr[0]}`, `${arr[2]}.${arr[1]}.${arr[3]}`, `${arr[2]}.${arr[3]}.${arr[0]}`, `${arr[2]}.${arr[3]}.${arr[1]}`, `${arr[3]}.${arr[0]}.${arr[1]}`, `${arr[3]}.${arr[0]}.${arr[2]}`, `${arr[3]}.${arr[1]}.${arr[0]}`, `${arr[3]}.${arr[1]}.${arr[2]}`, `${arr[3]}.${arr[2]}.${arr[0]}`, `${arr[3]}.${arr[2]}.${arr[1]}`, `${arr[0]}.${arr[1]}.${arr[2]}.${arr[3]}`, `${arr[0]}.${arr[1]}.${arr[3]}.${arr[2]}`, `${arr[0]}.${arr[2]}.${arr[1]}.${arr[3]}`, `${arr[0]}.${arr[2]}.${arr[3]}.${arr[1]}`, `${arr[0]}.${arr[3]}.${arr[1]}.${arr[2]}`, `${arr[0]}.${arr[3]}.${arr[2]}.${arr[1]}`, `${arr[1]}.${arr[0]}.${arr[2]}.${arr[3]}`, `${arr[1]}.${arr[0]}.${arr[3]}.${arr[2]}`, `${arr[1]}.${arr[2]}.${arr[0]}.${arr[3]}`, `${arr[1]}.${arr[2]}.${arr[3]}.${arr[0]}`, `${arr[1]}.${arr[3]}.${arr[0]}.${arr[2]}`, `${arr[1]}.${arr[3]}.${arr[2]}.${arr[0]}`, `${arr[2]}.${arr[0]}.${arr[1]}.${arr[3]}`, `${arr[2]}.${arr[0]}.${arr[3]}.${arr[1]}`, `${arr[2]}.${arr[1]}.${arr[0]}.${arr[3]}`, `${arr[2]}.${arr[1]}.${arr[3]}.${arr[0]}`, `${arr[2]}.${arr[3]}.${arr[0]}.${arr[1]}`, `${arr[2]}.${arr[3]}.${arr[1]}.${arr[0]}`, `${arr[3]}.${arr[0]}.${arr[1]}.${arr[2]}`, `${arr[3]}.${arr[0]}.${arr[2]}.${arr[1]}`, `${arr[3]}.${arr[1]}.${arr[0]}.${arr[2]}`, `${arr[3]}.${arr[1]}.${arr[2]}.${arr[0]}`, `${arr[3]}.${arr[2]}.${arr[0]}.${arr[1]}`, `${arr[3]}.${arr[2]}.${arr[1]}.${arr[0]}`];
50
- }
51
- }
52
- const classNameCombinations = {};
53
- function getClassNameCombinations(classNames) {
54
- if (classNames.length === 0 || classNames.length === 1) {
55
- return classNames;
56
- }
57
- const key = classNames.join('.');
58
- if (!classNameCombinations[key]) {
59
- classNameCombinations[key] = powerSetPermutations(classNames);
60
- }
61
- return classNameCombinations[key];
62
- }
63
- export function createStyleObject(classNames, elementStyle = {}, stylesheet) {
64
- const nonTokenClassNames = classNames.filter(className => className !== 'token');
65
- const classNamesCombinations = getClassNameCombinations(nonTokenClassNames);
66
- return classNamesCombinations.reduce((styleObject, className) => {
67
- return {
68
- ...styleObject,
69
- ...stylesheet[className]
70
- };
71
- }, elementStyle);
72
- }
73
- export function createClassNameString(classNames) {
74
- return classNames.join(' ');
75
- }
76
- export function createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig) {
77
- let childrenCount = 0;
78
- return children => {
79
- childrenCount += 1;
80
- return children.map((child, i) => createElement({
81
- node: child,
82
- stylesheet,
83
- useInlineStyles,
84
- codeBidiWarningConfig,
85
- key: `code-segment-${childrenCount}-${i}`
86
- }));
87
- };
88
- }
89
- function createElement({
90
- node,
91
- stylesheet,
92
- style = {},
93
- useInlineStyles,
94
- codeBidiWarningConfig,
95
- key
96
- }) {
97
- const {
98
- properties,
99
- type,
100
- tagName: TagName,
101
- value
102
- } = node;
103
- if (type === 'text') {
104
- // occasionally react-syntax-highlighter passes a numeric value when the
105
- // type is text
106
- const textValue = value + '';
107
- const decorated = codeBidiWarningDecorator(textValue, ({
108
- bidiCharacter,
109
- index
110
- }) => /*#__PURE__*/React.createElement(CodeBidiWarning, {
111
- bidiCharacter: bidiCharacter,
112
- key: index,
113
- label: codeBidiWarningConfig.codeBidiWarningLabel,
114
- tooltipEnabled: codeBidiWarningConfig.codeBidiWarningTooltipEnabled
115
- }));
116
- return decorated;
117
- } else if (TagName) {
118
- const childrenCreator = createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig);
119
- let props;
120
- if (!useInlineStyles) {
121
- props = {
122
- ...properties,
123
- className: createClassNameString(properties.className)
124
- };
125
- } else {
126
- const allStylesheetSelectors = Object.keys(stylesheet).reduce((classes, selector) => {
127
- selector.split('.').forEach(className => {
128
- if (!classes.includes(className)) {
129
- classes.push(className);
130
- }
131
- });
132
- return classes;
133
- }, []);
134
-
135
- // For compatibility with older versions of react-syntax-highlighter
136
- const startingClassName = properties.className && properties.className.includes('token') ? ['token'] : [];
137
- const className = properties.className && startingClassName.concat(properties.className.filter(className => !allStylesheetSelectors.includes(className)));
138
- props = {
139
- ...properties,
140
- className: createClassNameString(className) || undefined,
141
- style: createStyleObject(properties.className, Object.assign({}, properties.style, style), stylesheet)
142
- };
143
- }
144
- const children = childrenCreator(node.children);
145
- return /*#__PURE__*/React.createElement(TagName, _extends({
146
- key: key
147
- }, props), children);
148
- }
149
- }
@@ -1,155 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
- // @ts-nocheck
6
- import React from 'react';
7
- import CodeBidiWarning from './bidi-warning';
8
- import codeBidiWarningDecorator from './bidi-warning/bidi-warning-decorator';
9
-
10
- // File mostly vendored from react-syntax-highlighter
11
- //
12
- // - https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/efc3f7b7537d1729193b7a472067bcbe6cbecaf1/src/highlight.js#L272-L281
13
- // - https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/efc3f7b7537d1729193b7a472067bcbe6cbecaf1/src/create-element.js
14
- //
15
- // Patching react syntax-highlighter with a decoration feature is likely preferable
16
-
17
- export function createBidiWarningRenderer(codeBidiWarningConfig) {
18
- return function bidiWarningRenderer(_ref) {
19
- var rows = _ref.rows,
20
- stylesheet = _ref.stylesheet,
21
- useInlineStyles = _ref.useInlineStyles;
22
- return rows.map(function (node, i) {
23
- return createElement({
24
- node: node,
25
- stylesheet: stylesheet,
26
- useInlineStyles: useInlineStyles,
27
- codeBidiWarningConfig: codeBidiWarningConfig,
28
- key: "code-segement".concat(i)
29
- });
30
- });
31
- };
32
- }
33
-
34
- // Get all possible permutations of all power sets
35
- //
36
- // Super simple, non-algorithmic solution since the
37
- // number of class names will not be greater than 4
38
- function powerSetPermutations(arr) {
39
- var arrLength = arr.length;
40
- if (arrLength === 0 || arrLength === 1) {
41
- return arr;
42
- }
43
- if (arrLength === 2) {
44
- // prettier-ignore
45
- return [arr[0], arr[1], "".concat(arr[0], ".").concat(arr[1]), "".concat(arr[1], ".").concat(arr[0])];
46
- }
47
- if (arrLength === 3) {
48
- return [arr[0], arr[1], arr[2], "".concat(arr[0], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[0]), "".concat(arr[1], ".").concat(arr[2]), "".concat(arr[2], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[1], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[2], ".").concat(arr[1]), "".concat(arr[1], ".").concat(arr[0], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[2], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[0], ".").concat(arr[1]), "".concat(arr[2], ".").concat(arr[1], ".").concat(arr[0])];
49
- }
50
- if (arrLength >= 4) {
51
- // Currently does not support more than 4 extra
52
- // class names (after `.token` has been removed)
53
- return [arr[0], arr[1], arr[2], arr[3], "".concat(arr[0], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[3]), "".concat(arr[1], ".").concat(arr[0]), "".concat(arr[1], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[3]), "".concat(arr[2], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[1]), "".concat(arr[2], ".").concat(arr[3]), "".concat(arr[3], ".").concat(arr[0]), "".concat(arr[3], ".").concat(arr[1]), "".concat(arr[3], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[1], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[1], ".").concat(arr[3]), "".concat(arr[0], ".").concat(arr[2], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[2], ".").concat(arr[3]), "".concat(arr[0], ".").concat(arr[3], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[3], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[0], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[0], ".").concat(arr[3]), "".concat(arr[1], ".").concat(arr[2], ".").concat(arr[0]), "".concat(arr[1], ".").concat(arr[2], ".").concat(arr[3]), "".concat(arr[1], ".").concat(arr[3], ".").concat(arr[0]), "".concat(arr[1], ".").concat(arr[3], ".").concat(arr[2]), "".concat(arr[2], ".").concat(arr[0], ".").concat(arr[1]), "".concat(arr[2], ".").concat(arr[0], ".").concat(arr[3]), "".concat(arr[2], ".").concat(arr[1], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[1], ".").concat(arr[3]), "".concat(arr[2], ".").concat(arr[3], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[3], ".").concat(arr[1]), "".concat(arr[3], ".").concat(arr[0], ".").concat(arr[1]), "".concat(arr[3], ".").concat(arr[0], ".").concat(arr[2]), "".concat(arr[3], ".").concat(arr[1], ".").concat(arr[0]), "".concat(arr[3], ".").concat(arr[1], ".").concat(arr[2]), "".concat(arr[3], ".").concat(arr[2], ".").concat(arr[0]), "".concat(arr[3], ".").concat(arr[2], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[1], ".").concat(arr[2], ".").concat(arr[3]), "".concat(arr[0], ".").concat(arr[1], ".").concat(arr[3], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[2], ".").concat(arr[1], ".").concat(arr[3]), "".concat(arr[0], ".").concat(arr[2], ".").concat(arr[3], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[3], ".").concat(arr[1], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[3], ".").concat(arr[2], ".").concat(arr[1]), "".concat(arr[1], ".").concat(arr[0], ".").concat(arr[2], ".").concat(arr[3]), "".concat(arr[1], ".").concat(arr[0], ".").concat(arr[3], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[2], ".").concat(arr[0], ".").concat(arr[3]), "".concat(arr[1], ".").concat(arr[2], ".").concat(arr[3], ".").concat(arr[0]), "".concat(arr[1], ".").concat(arr[3], ".").concat(arr[0], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[3], ".").concat(arr[2], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[0], ".").concat(arr[1], ".").concat(arr[3]), "".concat(arr[2], ".").concat(arr[0], ".").concat(arr[3], ".").concat(arr[1]), "".concat(arr[2], ".").concat(arr[1], ".").concat(arr[0], ".").concat(arr[3]), "".concat(arr[2], ".").concat(arr[1], ".").concat(arr[3], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[3], ".").concat(arr[0], ".").concat(arr[1]), "".concat(arr[2], ".").concat(arr[3], ".").concat(arr[1], ".").concat(arr[0]), "".concat(arr[3], ".").concat(arr[0], ".").concat(arr[1], ".").concat(arr[2]), "".concat(arr[3], ".").concat(arr[0], ".").concat(arr[2], ".").concat(arr[1]), "".concat(arr[3], ".").concat(arr[1], ".").concat(arr[0], ".").concat(arr[2]), "".concat(arr[3], ".").concat(arr[1], ".").concat(arr[2], ".").concat(arr[0]), "".concat(arr[3], ".").concat(arr[2], ".").concat(arr[0], ".").concat(arr[1]), "".concat(arr[3], ".").concat(arr[2], ".").concat(arr[1], ".").concat(arr[0])];
54
- }
55
- }
56
- var classNameCombinations = {};
57
- function getClassNameCombinations(classNames) {
58
- if (classNames.length === 0 || classNames.length === 1) {
59
- return classNames;
60
- }
61
- var key = classNames.join('.');
62
- if (!classNameCombinations[key]) {
63
- classNameCombinations[key] = powerSetPermutations(classNames);
64
- }
65
- return classNameCombinations[key];
66
- }
67
- export function createStyleObject(classNames) {
68
- var elementStyle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
69
- var stylesheet = arguments.length > 2 ? arguments[2] : undefined;
70
- var nonTokenClassNames = classNames.filter(function (className) {
71
- return className !== 'token';
72
- });
73
- var classNamesCombinations = getClassNameCombinations(nonTokenClassNames);
74
- return classNamesCombinations.reduce(function (styleObject, className) {
75
- return _objectSpread(_objectSpread({}, styleObject), stylesheet[className]);
76
- }, elementStyle);
77
- }
78
- export function createClassNameString(classNames) {
79
- return classNames.join(' ');
80
- }
81
- export function createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig) {
82
- var childrenCount = 0;
83
- return function (children) {
84
- childrenCount += 1;
85
- return children.map(function (child, i) {
86
- return createElement({
87
- node: child,
88
- stylesheet: stylesheet,
89
- useInlineStyles: useInlineStyles,
90
- codeBidiWarningConfig: codeBidiWarningConfig,
91
- key: "code-segment-".concat(childrenCount, "-").concat(i)
92
- });
93
- });
94
- };
95
- }
96
- function createElement(_ref2) {
97
- var node = _ref2.node,
98
- stylesheet = _ref2.stylesheet,
99
- _ref2$style = _ref2.style,
100
- style = _ref2$style === void 0 ? {} : _ref2$style,
101
- useInlineStyles = _ref2.useInlineStyles,
102
- codeBidiWarningConfig = _ref2.codeBidiWarningConfig,
103
- key = _ref2.key;
104
- var properties = node.properties,
105
- type = node.type,
106
- TagName = node.tagName,
107
- value = node.value;
108
- if (type === 'text') {
109
- // occasionally react-syntax-highlighter passes a numeric value when the
110
- // type is text
111
- var textValue = value + '';
112
- var decorated = codeBidiWarningDecorator(textValue, function (_ref3) {
113
- var bidiCharacter = _ref3.bidiCharacter,
114
- index = _ref3.index;
115
- return /*#__PURE__*/React.createElement(CodeBidiWarning, {
116
- bidiCharacter: bidiCharacter,
117
- key: index,
118
- label: codeBidiWarningConfig.codeBidiWarningLabel,
119
- tooltipEnabled: codeBidiWarningConfig.codeBidiWarningTooltipEnabled
120
- });
121
- });
122
- return decorated;
123
- } else if (TagName) {
124
- var childrenCreator = createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig);
125
- var props;
126
- if (!useInlineStyles) {
127
- props = _objectSpread(_objectSpread({}, properties), {}, {
128
- className: createClassNameString(properties.className)
129
- });
130
- } else {
131
- var allStylesheetSelectors = Object.keys(stylesheet).reduce(function (classes, selector) {
132
- selector.split('.').forEach(function (className) {
133
- if (!classes.includes(className)) {
134
- classes.push(className);
135
- }
136
- });
137
- return classes;
138
- }, []);
139
-
140
- // For compatibility with older versions of react-syntax-highlighter
141
- var startingClassName = properties.className && properties.className.includes('token') ? ['token'] : [];
142
- var className = properties.className && startingClassName.concat(properties.className.filter(function (className) {
143
- return !allStylesheetSelectors.includes(className);
144
- }));
145
- props = _objectSpread(_objectSpread({}, properties), {}, {
146
- className: createClassNameString(className) || undefined,
147
- style: createStyleObject(properties.className, Object.assign({}, properties.style, style), stylesheet)
148
- });
149
- }
150
- var children = childrenCreator(node.children);
151
- return /*#__PURE__*/React.createElement(TagName, _extends({
152
- key: key
153
- }, props), children);
154
- }
155
- }
@@ -1,9 +0,0 @@
1
- declare type CodeBidiWarningConfig = {
2
- codeBidiWarningLabel?: string;
3
- codeBidiWarningTooltipEnabled: boolean;
4
- };
5
- export declare function createBidiWarningRenderer(codeBidiWarningConfig: CodeBidiWarningConfig): ({ rows, stylesheet, useInlineStyles, }: any) => any;
6
- export declare function createStyleObject(classNames: any, elementStyle: {} | undefined, stylesheet: any): any;
7
- export declare function createClassNameString(classNames: any): any;
8
- export declare function createChildren(stylesheet: any, useInlineStyles: any, codeBidiWarningConfig: any): (children: any) => any;
9
- export {};