@redis-ui/components 51.27.0 → 51.29.0
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.
- package/dist/CodeBlock/CodeBlock.cjs +32 -15
- package/dist/CodeBlock/CodeBlock.js +32 -15
- package/dist/CodeBlock/CodeBlock.style.d.ts +4 -3
- package/dist/CodeBlock/CodeBlock.types.cjs +7 -0
- package/dist/CodeBlock/CodeBlock.types.d.ts +9 -1
- package/dist/CodeBlock/CodeBlock.types.js +7 -1
- package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.cjs +29 -0
- package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.constants.cjs +34 -0
- package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.constants.d.ts +25 -0
- package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.constants.js +32 -0
- package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.d.ts +6 -0
- package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.js +29 -0
- package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.types.d.ts +10 -0
- package/dist/CodeBlock/components/HighlightedCode/HighlightedCode.types.js +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +2 -2
- package/dist/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.cjs +8 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js +8 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.cjs +7 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js +7 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/defineProperty.cjs +12 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/defineProperty.js +12 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/extends.cjs +17 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/extends.js +12 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/iterableToArray.cjs +6 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/iterableToArray.js +6 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.cjs +6 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js +6 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.cjs +13 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js +13 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.cjs +12 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/toConsumableArray.cjs +10 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js +10 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/toPrimitive.cjs +14 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +14 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/toPropertyKey.cjs +9 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +9 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/typeof.cjs +16 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/typeof.js +11 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.cjs +11 -0
- package/dist/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js +11 -0
- package/dist/node_modules/character-entities-legacy/index.cjs +116 -0
- package/dist/node_modules/character-entities-legacy/index.js +116 -0
- package/dist/node_modules/character-reference-invalid/index.cjs +38 -0
- package/dist/node_modules/character-reference-invalid/index.js +38 -0
- package/dist/node_modules/comma-separated-tokens/index.cjs +43 -0
- package/dist/node_modules/comma-separated-tokens/index.js +43 -0
- package/dist/node_modules/decode-named-character-reference/index.dom.cjs +15 -0
- package/dist/node_modules/decode-named-character-reference/index.dom.js +15 -0
- package/dist/node_modules/hast-util-parse-selector/lib/index.cjs +76 -0
- package/dist/node_modules/hast-util-parse-selector/lib/index.js +76 -0
- package/dist/node_modules/hastscript/lib/create-h.cjs +262 -0
- package/dist/node_modules/hastscript/lib/create-h.js +262 -0
- package/dist/node_modules/hastscript/lib/index.cjs +21 -0
- package/dist/node_modules/hastscript/lib/index.js +21 -0
- package/dist/node_modules/hastscript/lib/svg-case-sensitive-tag-names.cjs +49 -0
- package/dist/node_modules/hastscript/lib/svg-case-sensitive-tag-names.js +49 -0
- package/dist/node_modules/is-alphabetical/index.cjs +14 -0
- package/dist/node_modules/is-alphabetical/index.js +14 -0
- package/dist/node_modules/is-alphanumerical/index.cjs +15 -0
- package/dist/node_modules/is-alphanumerical/index.js +15 -0
- package/dist/node_modules/is-decimal/index.cjs +14 -0
- package/dist/node_modules/is-decimal/index.js +14 -0
- package/dist/node_modules/is-hexadecimal/index.cjs +14 -0
- package/dist/node_modules/is-hexadecimal/index.js +14 -0
- package/dist/node_modules/parse-entities/lib/index.cjs +232 -0
- package/dist/node_modules/parse-entities/lib/index.js +232 -0
- package/dist/node_modules/property-information/index.cjs +27 -0
- package/dist/node_modules/property-information/index.js +26 -0
- package/dist/node_modules/property-information/lib/aria.cjs +60 -0
- package/dist/node_modules/property-information/lib/aria.js +61 -0
- package/dist/node_modules/property-information/lib/find.cjs +81 -0
- package/dist/node_modules/property-information/lib/find.js +81 -0
- package/dist/node_modules/property-information/lib/html.cjs +326 -0
- package/dist/node_modules/property-information/lib/html.js +326 -0
- package/dist/node_modules/property-information/lib/normalize.cjs +15 -0
- package/dist/node_modules/property-information/lib/normalize.js +15 -0
- package/dist/node_modules/property-information/lib/svg.cjs +564 -0
- package/dist/node_modules/property-information/lib/svg.js +564 -0
- package/dist/node_modules/property-information/lib/util/case-insensitive-transform.cjs +15 -0
- package/dist/node_modules/property-information/lib/util/case-insensitive-transform.js +15 -0
- package/dist/node_modules/property-information/lib/util/case-sensitive-transform.cjs +14 -0
- package/dist/node_modules/property-information/lib/util/case-sensitive-transform.js +14 -0
- package/dist/node_modules/property-information/lib/util/create.cjs +53 -0
- package/dist/node_modules/property-information/lib/util/create.js +53 -0
- package/dist/node_modules/property-information/lib/util/defined-info.cjs +49 -0
- package/dist/node_modules/property-information/lib/util/defined-info.js +49 -0
- package/dist/node_modules/property-information/lib/util/info.cjs +33 -0
- package/dist/node_modules/property-information/lib/util/info.js +33 -0
- package/dist/node_modules/property-information/lib/util/merge.cjs +26 -0
- package/dist/node_modules/property-information/lib/util/merge.js +26 -0
- package/dist/node_modules/property-information/lib/util/schema.cjs +27 -0
- package/dist/node_modules/property-information/lib/util/schema.js +27 -0
- package/dist/node_modules/property-information/lib/util/types.cjs +35 -0
- package/dist/node_modules/property-information/lib/util/types.js +24 -0
- package/dist/node_modules/property-information/lib/xlink.cjs +18 -0
- package/dist/node_modules/property-information/lib/xlink.js +19 -0
- package/dist/node_modules/property-information/lib/xml.cjs +14 -0
- package/dist/node_modules/property-information/lib/xml.js +15 -0
- package/dist/node_modules/property-information/lib/xmlns.cjs +14 -0
- package/dist/node_modules/property-information/lib/xmlns.js +14 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/checkForListedLanguage.cjs +6 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/checkForListedLanguage.js +6 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/create-element.cjs +183 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/create-element.js +181 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/highlight.cjs +308 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/highlight.js +306 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/bash.cjs +4 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/bash.js +5 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/json.cjs +4 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/json.js +5 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/python.cjs +4 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/python.js +5 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/typescript.cjs +4 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/languages/prism/typescript.js +5 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/prism-light.cjs +12 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/prism-light.js +12 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vs.cjs +121 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vs.js +121 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vsc-dark-plus.cjs +147 -0
- package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/prism/vsc-dark-plus.js +147 -0
- package/dist/node_modules/refractor/lang/bash.cjs +190 -0
- package/dist/node_modules/refractor/lang/bash.js +190 -0
- package/dist/node_modules/refractor/lang/clike.cjs +37 -0
- package/dist/node_modules/refractor/lang/clike.js +37 -0
- package/dist/node_modules/refractor/lang/javascript.cjs +122 -0
- package/dist/node_modules/refractor/lang/javascript.js +122 -0
- package/dist/node_modules/refractor/lang/json.cjs +36 -0
- package/dist/node_modules/refractor/lang/json.js +36 -0
- package/dist/node_modules/refractor/lang/python.cjs +71 -0
- package/dist/node_modules/refractor/lang/python.js +71 -0
- package/dist/node_modules/refractor/lang/typescript.cjs +55 -0
- package/dist/node_modules/refractor/lang/typescript.js +55 -0
- package/dist/node_modules/refractor/lib/core.cjs +214 -0
- package/dist/node_modules/refractor/lib/core.js +214 -0
- package/dist/node_modules/refractor/lib/prism-core.cjs +595 -0
- package/dist/node_modules/refractor/lib/prism-core.js +595 -0
- package/dist/node_modules/space-separated-tokens/index.cjs +15 -0
- package/dist/node_modules/space-separated-tokens/index.js +15 -0
- package/package.json +3 -1
- package/skills/redis-ui-components/references/CodeBlock.md +27 -6
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
//#region ../../node_modules/refractor/lib/prism-core.js
|
|
2
|
+
var uniqueId = 0;
|
|
3
|
+
var plainTextGrammar = {};
|
|
4
|
+
var _ = {
|
|
5
|
+
/**
|
|
6
|
+
* A namespace for utility methods.
|
|
7
|
+
*
|
|
8
|
+
* All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
|
|
9
|
+
* change or disappear at any time.
|
|
10
|
+
*
|
|
11
|
+
* @namespace
|
|
12
|
+
* @memberof Prism
|
|
13
|
+
*/
|
|
14
|
+
util: {
|
|
15
|
+
/**
|
|
16
|
+
* Returns the name of the type of the given value.
|
|
17
|
+
*
|
|
18
|
+
* @param {any} o
|
|
19
|
+
* @returns {string}
|
|
20
|
+
* @example
|
|
21
|
+
* type(null) === 'Null'
|
|
22
|
+
* type(undefined) === 'Undefined'
|
|
23
|
+
* type(123) === 'Number'
|
|
24
|
+
* type('foo') === 'String'
|
|
25
|
+
* type(true) === 'Boolean'
|
|
26
|
+
* type([1, 2]) === 'Array'
|
|
27
|
+
* type({}) === 'Object'
|
|
28
|
+
* type(String) === 'Function'
|
|
29
|
+
* type(/abc+/) === 'RegExp'
|
|
30
|
+
*/
|
|
31
|
+
type: function(o) {
|
|
32
|
+
return Object.prototype.toString.call(o).slice(8, -1);
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* Returns a unique number for the given object. Later calls will still return the same number.
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} obj
|
|
38
|
+
* @returns {number}
|
|
39
|
+
*/
|
|
40
|
+
objId: function(obj) {
|
|
41
|
+
if (!obj["__id"]) Object.defineProperty(obj, "__id", { value: ++uniqueId });
|
|
42
|
+
return obj["__id"];
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* Creates a deep clone of the given object.
|
|
46
|
+
*
|
|
47
|
+
* The main intended use of this function is to clone language definitions.
|
|
48
|
+
*
|
|
49
|
+
* @param {T} o
|
|
50
|
+
* @param {Record<number, any>} [visited]
|
|
51
|
+
* @returns {T}
|
|
52
|
+
* @template T
|
|
53
|
+
*/
|
|
54
|
+
clone: function deepClone(o, visited) {
|
|
55
|
+
visited = visited || {};
|
|
56
|
+
var clone;
|
|
57
|
+
var id;
|
|
58
|
+
switch (_.util.type(o)) {
|
|
59
|
+
case "Object":
|
|
60
|
+
id = _.util.objId(o);
|
|
61
|
+
if (visited[id]) return visited[id];
|
|
62
|
+
clone = {};
|
|
63
|
+
visited[id] = clone;
|
|
64
|
+
for (var key in o) if (o.hasOwnProperty(key)) clone[key] = deepClone(o[key], visited);
|
|
65
|
+
return clone;
|
|
66
|
+
case "Array":
|
|
67
|
+
id = _.util.objId(o);
|
|
68
|
+
if (visited[id]) return visited[id];
|
|
69
|
+
clone = [];
|
|
70
|
+
visited[id] = clone;
|
|
71
|
+
/** @type {Array} */ o.forEach(function(v, i) {
|
|
72
|
+
clone[i] = deepClone(v, visited);
|
|
73
|
+
});
|
|
74
|
+
return clone;
|
|
75
|
+
default: return o;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
/**
|
|
80
|
+
* This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
|
|
81
|
+
*
|
|
82
|
+
* @namespace
|
|
83
|
+
* @memberof Prism
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
languages: {
|
|
87
|
+
/**
|
|
88
|
+
* The grammar for plain, unformatted text.
|
|
89
|
+
*/
|
|
90
|
+
plain: plainTextGrammar,
|
|
91
|
+
plaintext: plainTextGrammar,
|
|
92
|
+
text: plainTextGrammar,
|
|
93
|
+
txt: plainTextGrammar,
|
|
94
|
+
/**
|
|
95
|
+
* Creates a deep copy of the language with the given id and appends the given tokens.
|
|
96
|
+
*
|
|
97
|
+
* If a token in `redef` also appears in the copied language, then the existing token in the copied language
|
|
98
|
+
* will be overwritten at its original position.
|
|
99
|
+
*
|
|
100
|
+
* ## Best practices
|
|
101
|
+
*
|
|
102
|
+
* Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
|
|
103
|
+
* doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
|
|
104
|
+
* understand the language definition because, normally, the order of tokens matters in Prism grammars.
|
|
105
|
+
*
|
|
106
|
+
* Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
|
|
107
|
+
* Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
|
|
108
|
+
*
|
|
109
|
+
* @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
|
|
110
|
+
* @param {Grammar} redef The new tokens to append.
|
|
111
|
+
* @returns {Grammar} The new language created.
|
|
112
|
+
* @public
|
|
113
|
+
* @example
|
|
114
|
+
* Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
|
|
115
|
+
* // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
|
|
116
|
+
* // at its original position
|
|
117
|
+
* 'comment': { ... },
|
|
118
|
+
* // CSS doesn't have a 'color' token, so this token will be appended
|
|
119
|
+
* 'color': /\b(?:red|green|blue)\b/
|
|
120
|
+
* });
|
|
121
|
+
*/
|
|
122
|
+
extend: function(id, redef) {
|
|
123
|
+
var lang = _.util.clone(_.languages[id]);
|
|
124
|
+
for (var key in redef) lang[key] = redef[key];
|
|
125
|
+
return lang;
|
|
126
|
+
},
|
|
127
|
+
/**
|
|
128
|
+
* Inserts tokens _before_ another token in a language definition or any other grammar.
|
|
129
|
+
*
|
|
130
|
+
* ## Usage
|
|
131
|
+
*
|
|
132
|
+
* This helper method makes it easy to modify existing languages. For example, the CSS language definition
|
|
133
|
+
* not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
|
|
134
|
+
* in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
|
|
135
|
+
* appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
|
|
136
|
+
* this:
|
|
137
|
+
*
|
|
138
|
+
* ```js
|
|
139
|
+
* Prism.languages.markup.style = {
|
|
140
|
+
* // token
|
|
141
|
+
* };
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
|
|
145
|
+
* before existing tokens. For the CSS example above, you would use it like this:
|
|
146
|
+
*
|
|
147
|
+
* ```js
|
|
148
|
+
* Prism.languages.insertBefore('markup', 'cdata', {
|
|
149
|
+
* 'style': {
|
|
150
|
+
* // token
|
|
151
|
+
* }
|
|
152
|
+
* });
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* ## Special cases
|
|
156
|
+
*
|
|
157
|
+
* If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
|
|
158
|
+
* will be ignored.
|
|
159
|
+
*
|
|
160
|
+
* This behavior can be used to insert tokens after `before`:
|
|
161
|
+
*
|
|
162
|
+
* ```js
|
|
163
|
+
* Prism.languages.insertBefore('markup', 'comment', {
|
|
164
|
+
* 'comment': Prism.languages.markup.comment,
|
|
165
|
+
* // tokens after 'comment'
|
|
166
|
+
* });
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* ## Limitations
|
|
170
|
+
*
|
|
171
|
+
* The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
|
|
172
|
+
* properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
|
|
173
|
+
* differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
|
|
174
|
+
* deleting properties which is necessary to insert at arbitrary positions.
|
|
175
|
+
*
|
|
176
|
+
* To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
|
|
177
|
+
* Instead, it will create a new object and replace all references to the target object with the new one. This
|
|
178
|
+
* can be done without temporarily deleting properties, so the iteration order is well-defined.
|
|
179
|
+
*
|
|
180
|
+
* However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
|
|
181
|
+
* you hold the target object in a variable, then the value of the variable will not change.
|
|
182
|
+
*
|
|
183
|
+
* ```js
|
|
184
|
+
* var oldMarkup = Prism.languages.markup;
|
|
185
|
+
* var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
|
|
186
|
+
*
|
|
187
|
+
* assert(oldMarkup !== Prism.languages.markup);
|
|
188
|
+
* assert(newMarkup === Prism.languages.markup);
|
|
189
|
+
* ```
|
|
190
|
+
*
|
|
191
|
+
* @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
|
|
192
|
+
* object to be modified.
|
|
193
|
+
* @param {string} before The key to insert before.
|
|
194
|
+
* @param {Grammar} insert An object containing the key-value pairs to be inserted.
|
|
195
|
+
* @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
|
|
196
|
+
* object to be modified.
|
|
197
|
+
*
|
|
198
|
+
* Defaults to `Prism.languages`.
|
|
199
|
+
* @returns {Grammar} The new grammar object.
|
|
200
|
+
* @public
|
|
201
|
+
*/
|
|
202
|
+
insertBefore: function(inside, before, insert, root) {
|
|
203
|
+
root = root || _.languages;
|
|
204
|
+
var grammar = root[inside];
|
|
205
|
+
/** @type {Grammar} */
|
|
206
|
+
var ret = {};
|
|
207
|
+
for (var token in grammar) if (grammar.hasOwnProperty(token)) {
|
|
208
|
+
if (token == before) {
|
|
209
|
+
for (var newToken in insert) if (insert.hasOwnProperty(newToken)) ret[newToken] = insert[newToken];
|
|
210
|
+
}
|
|
211
|
+
if (!insert.hasOwnProperty(token)) ret[token] = grammar[token];
|
|
212
|
+
}
|
|
213
|
+
var old = root[inside];
|
|
214
|
+
root[inside] = ret;
|
|
215
|
+
_.languages.DFS(_.languages, function(key, value) {
|
|
216
|
+
if (value === old && key != inside) this[key] = ret;
|
|
217
|
+
});
|
|
218
|
+
return ret;
|
|
219
|
+
},
|
|
220
|
+
DFS: function DFS(o, callback, type, visited) {
|
|
221
|
+
visited = visited || {};
|
|
222
|
+
var objId = _.util.objId;
|
|
223
|
+
for (var i in o) if (o.hasOwnProperty(i)) {
|
|
224
|
+
callback.call(o, i, o[i], type || i);
|
|
225
|
+
var property = o[i];
|
|
226
|
+
var propertyType = _.util.type(property);
|
|
227
|
+
if (propertyType === "Object" && !visited[objId(property)]) {
|
|
228
|
+
visited[objId(property)] = true;
|
|
229
|
+
DFS(property, callback, null, visited);
|
|
230
|
+
} else if (propertyType === "Array" && !visited[objId(property)]) {
|
|
231
|
+
visited[objId(property)] = true;
|
|
232
|
+
DFS(property, callback, i, visited);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
plugins: {},
|
|
238
|
+
/**
|
|
239
|
+
* Low-level function, only use if you know what you’re doing. It accepts a string of text as input
|
|
240
|
+
* and the language definitions to use, and returns a string with the HTML produced.
|
|
241
|
+
*
|
|
242
|
+
* The following hooks will be run:
|
|
243
|
+
* 1. `before-tokenize`
|
|
244
|
+
* 2. `after-tokenize`
|
|
245
|
+
* 3. `wrap`: On each {@link Token}.
|
|
246
|
+
*
|
|
247
|
+
* @param {string} text A string with the code to be highlighted.
|
|
248
|
+
* @param {Grammar} grammar An object containing the tokens to use.
|
|
249
|
+
*
|
|
250
|
+
* Usually a language definition like `Prism.languages.markup`.
|
|
251
|
+
* @param {string} language The name of the language definition passed to `grammar`.
|
|
252
|
+
* @returns {string} The highlighted HTML.
|
|
253
|
+
* @memberof Prism
|
|
254
|
+
* @public
|
|
255
|
+
* @example
|
|
256
|
+
* Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
|
|
257
|
+
*/
|
|
258
|
+
highlight: function(text, grammar, language) {
|
|
259
|
+
var env = {
|
|
260
|
+
code: text,
|
|
261
|
+
grammar,
|
|
262
|
+
language
|
|
263
|
+
};
|
|
264
|
+
_.hooks.run("before-tokenize", env);
|
|
265
|
+
if (!env.grammar) throw new Error("The language \"" + env.language + "\" has no grammar.");
|
|
266
|
+
env.tokens = _.tokenize(env.code, env.grammar);
|
|
267
|
+
_.hooks.run("after-tokenize", env);
|
|
268
|
+
return Token.stringify(_.util.encode(env.tokens), env.language);
|
|
269
|
+
},
|
|
270
|
+
/**
|
|
271
|
+
* This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
|
|
272
|
+
* and the language definitions to use, and returns an array with the tokenized code.
|
|
273
|
+
*
|
|
274
|
+
* When the language definition includes nested tokens, the function is called recursively on each of these tokens.
|
|
275
|
+
*
|
|
276
|
+
* This method could be useful in other contexts as well, as a very crude parser.
|
|
277
|
+
*
|
|
278
|
+
* @param {string} text A string with the code to be highlighted.
|
|
279
|
+
* @param {Grammar} grammar An object containing the tokens to use.
|
|
280
|
+
*
|
|
281
|
+
* Usually a language definition like `Prism.languages.markup`.
|
|
282
|
+
* @returns {TokenStream} An array of strings and tokens, a token stream.
|
|
283
|
+
* @memberof Prism
|
|
284
|
+
* @public
|
|
285
|
+
* @example
|
|
286
|
+
* let code = `var foo = 0;`;
|
|
287
|
+
* let tokens = Prism.tokenize(code, Prism.languages.javascript);
|
|
288
|
+
* tokens.forEach(token => {
|
|
289
|
+
* if (token instanceof Prism.Token && token.type === 'number') {
|
|
290
|
+
* console.log(`Found numeric literal: ${token.content}`);
|
|
291
|
+
* }
|
|
292
|
+
* });
|
|
293
|
+
*/
|
|
294
|
+
tokenize: function(text, grammar) {
|
|
295
|
+
var rest = grammar.rest;
|
|
296
|
+
if (rest) {
|
|
297
|
+
for (var token in rest) grammar[token] = rest[token];
|
|
298
|
+
delete grammar.rest;
|
|
299
|
+
}
|
|
300
|
+
var tokenList = new LinkedList();
|
|
301
|
+
addAfter(tokenList, tokenList.head, text);
|
|
302
|
+
matchGrammar(text, tokenList, grammar, tokenList.head, 0);
|
|
303
|
+
return toArray(tokenList);
|
|
304
|
+
},
|
|
305
|
+
/**
|
|
306
|
+
* @namespace
|
|
307
|
+
* @memberof Prism
|
|
308
|
+
* @public
|
|
309
|
+
*/
|
|
310
|
+
hooks: {
|
|
311
|
+
all: {},
|
|
312
|
+
/**
|
|
313
|
+
* Adds the given callback to the list of callbacks for the given hook.
|
|
314
|
+
*
|
|
315
|
+
* The callback will be invoked when the hook it is registered for is run.
|
|
316
|
+
* Hooks are usually directly run by a highlight function but you can also run hooks yourself.
|
|
317
|
+
*
|
|
318
|
+
* One callback function can be registered to multiple hooks and the same hook multiple times.
|
|
319
|
+
*
|
|
320
|
+
* @param {string} name The name of the hook.
|
|
321
|
+
* @param {HookCallback} callback The callback function which is given environment variables.
|
|
322
|
+
* @public
|
|
323
|
+
*/
|
|
324
|
+
add: function(name, callback) {
|
|
325
|
+
var hooks = _.hooks.all;
|
|
326
|
+
hooks[name] = hooks[name] || [];
|
|
327
|
+
hooks[name].push(callback);
|
|
328
|
+
},
|
|
329
|
+
/**
|
|
330
|
+
* Runs a hook invoking all registered callbacks with the given environment variables.
|
|
331
|
+
*
|
|
332
|
+
* Callbacks will be invoked synchronously and in the order in which they were registered.
|
|
333
|
+
*
|
|
334
|
+
* @param {string} name The name of the hook.
|
|
335
|
+
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
|
336
|
+
* @public
|
|
337
|
+
*/
|
|
338
|
+
run: function(name, env) {
|
|
339
|
+
var callbacks = _.hooks.all[name];
|
|
340
|
+
if (!callbacks || !callbacks.length) return;
|
|
341
|
+
for (var i = 0, callback; callback = callbacks[i++];) callback(env);
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
Token
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Creates a new token.
|
|
348
|
+
*
|
|
349
|
+
* @param {string} type See {@link Token#type type}
|
|
350
|
+
* @param {string | TokenStream} content See {@link Token#content content}
|
|
351
|
+
* @param {string|string[]} [alias] The alias(es) of the token.
|
|
352
|
+
* @param {string} [matchedStr=""] A copy of the full string this token was created from.
|
|
353
|
+
* @class
|
|
354
|
+
* @global
|
|
355
|
+
* @public
|
|
356
|
+
*/
|
|
357
|
+
function Token(type, content, alias, matchedStr) {
|
|
358
|
+
/**
|
|
359
|
+
* The type of the token.
|
|
360
|
+
*
|
|
361
|
+
* This is usually the key of a pattern in a {@link Grammar}.
|
|
362
|
+
*
|
|
363
|
+
* @type {string}
|
|
364
|
+
* @see GrammarToken
|
|
365
|
+
* @public
|
|
366
|
+
*/
|
|
367
|
+
this.type = type;
|
|
368
|
+
/**
|
|
369
|
+
* The strings or tokens contained by this token.
|
|
370
|
+
*
|
|
371
|
+
* This will be a token stream if the pattern matched also defined an `inside` grammar.
|
|
372
|
+
*
|
|
373
|
+
* @type {string | TokenStream}
|
|
374
|
+
* @public
|
|
375
|
+
*/
|
|
376
|
+
this.content = content;
|
|
377
|
+
/**
|
|
378
|
+
* The alias(es) of the token.
|
|
379
|
+
*
|
|
380
|
+
* @type {string|string[]}
|
|
381
|
+
* @see GrammarToken
|
|
382
|
+
* @public
|
|
383
|
+
*/
|
|
384
|
+
this.alias = alias;
|
|
385
|
+
this.length = (matchedStr || "").length | 0;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* A token stream is an array of strings and {@link Token Token} objects.
|
|
389
|
+
*
|
|
390
|
+
* Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
|
|
391
|
+
* them.
|
|
392
|
+
*
|
|
393
|
+
* 1. No adjacent strings.
|
|
394
|
+
* 2. No empty strings.
|
|
395
|
+
*
|
|
396
|
+
* The only exception here is the token stream that only contains the empty string and nothing else.
|
|
397
|
+
*
|
|
398
|
+
* @typedef {Array<string | Token>} TokenStream
|
|
399
|
+
* @global
|
|
400
|
+
* @public
|
|
401
|
+
*/
|
|
402
|
+
/**
|
|
403
|
+
* @param {RegExp} pattern
|
|
404
|
+
* @param {number} pos
|
|
405
|
+
* @param {string} text
|
|
406
|
+
* @param {boolean} lookbehind
|
|
407
|
+
* @returns {RegExpExecArray | null}
|
|
408
|
+
*/
|
|
409
|
+
function matchPattern(pattern, pos, text, lookbehind) {
|
|
410
|
+
pattern.lastIndex = pos;
|
|
411
|
+
var match = pattern.exec(text);
|
|
412
|
+
if (match && lookbehind && match[1]) {
|
|
413
|
+
var lookbehindLength = match[1].length;
|
|
414
|
+
match.index += lookbehindLength;
|
|
415
|
+
match[0] = match[0].slice(lookbehindLength);
|
|
416
|
+
}
|
|
417
|
+
return match;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* @param {string} text
|
|
421
|
+
* @param {LinkedList<string | Token>} tokenList
|
|
422
|
+
* @param {any} grammar
|
|
423
|
+
* @param {LinkedListNode<string | Token>} startNode
|
|
424
|
+
* @param {number} startPos
|
|
425
|
+
* @param {RematchOptions} [rematch]
|
|
426
|
+
* @returns {void}
|
|
427
|
+
* @private
|
|
428
|
+
*
|
|
429
|
+
* @typedef RematchOptions
|
|
430
|
+
* @property {string} cause
|
|
431
|
+
* @property {number} reach
|
|
432
|
+
*/
|
|
433
|
+
function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
|
|
434
|
+
for (var token in grammar) {
|
|
435
|
+
if (!grammar.hasOwnProperty(token) || !grammar[token]) continue;
|
|
436
|
+
var patterns = grammar[token];
|
|
437
|
+
patterns = Array.isArray(patterns) ? patterns : [patterns];
|
|
438
|
+
for (var j = 0; j < patterns.length; ++j) {
|
|
439
|
+
if (rematch && rematch.cause == token + "," + j) return;
|
|
440
|
+
var patternObj = patterns[j];
|
|
441
|
+
var inside = patternObj.inside;
|
|
442
|
+
var lookbehind = !!patternObj.lookbehind;
|
|
443
|
+
var greedy = !!patternObj.greedy;
|
|
444
|
+
var alias = patternObj.alias;
|
|
445
|
+
if (greedy && !patternObj.pattern.global) {
|
|
446
|
+
var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
|
|
447
|
+
patternObj.pattern = RegExp(patternObj.pattern.source, flags + "g");
|
|
448
|
+
}
|
|
449
|
+
/** @type {RegExp} */
|
|
450
|
+
var pattern = patternObj.pattern || patternObj;
|
|
451
|
+
for (var currentNode = startNode.next, pos = startPos; currentNode !== tokenList.tail; pos += currentNode.value.length, currentNode = currentNode.next) {
|
|
452
|
+
if (rematch && pos >= rematch.reach) break;
|
|
453
|
+
var str = currentNode.value;
|
|
454
|
+
if (tokenList.length > text.length) return;
|
|
455
|
+
if (str instanceof Token) continue;
|
|
456
|
+
var removeCount = 1;
|
|
457
|
+
var match;
|
|
458
|
+
if (greedy) {
|
|
459
|
+
match = matchPattern(pattern, pos, text, lookbehind);
|
|
460
|
+
if (!match || match.index >= text.length) break;
|
|
461
|
+
var from = match.index;
|
|
462
|
+
var to = match.index + match[0].length;
|
|
463
|
+
var p = pos;
|
|
464
|
+
p += currentNode.value.length;
|
|
465
|
+
while (from >= p) {
|
|
466
|
+
currentNode = currentNode.next;
|
|
467
|
+
p += currentNode.value.length;
|
|
468
|
+
}
|
|
469
|
+
p -= currentNode.value.length;
|
|
470
|
+
pos = p;
|
|
471
|
+
if (currentNode.value instanceof Token) continue;
|
|
472
|
+
for (var k = currentNode; k !== tokenList.tail && (p < to || typeof k.value === "string"); k = k.next) {
|
|
473
|
+
removeCount++;
|
|
474
|
+
p += k.value.length;
|
|
475
|
+
}
|
|
476
|
+
removeCount--;
|
|
477
|
+
str = text.slice(pos, p);
|
|
478
|
+
match.index -= pos;
|
|
479
|
+
} else {
|
|
480
|
+
match = matchPattern(pattern, 0, str, lookbehind);
|
|
481
|
+
if (!match) continue;
|
|
482
|
+
}
|
|
483
|
+
var from = match.index;
|
|
484
|
+
var matchStr = match[0];
|
|
485
|
+
var before = str.slice(0, from);
|
|
486
|
+
var after = str.slice(from + matchStr.length);
|
|
487
|
+
var reach = pos + str.length;
|
|
488
|
+
if (rematch && reach > rematch.reach) rematch.reach = reach;
|
|
489
|
+
var removeFrom = currentNode.prev;
|
|
490
|
+
if (before) {
|
|
491
|
+
removeFrom = addAfter(tokenList, removeFrom, before);
|
|
492
|
+
pos += before.length;
|
|
493
|
+
}
|
|
494
|
+
removeRange(tokenList, removeFrom, removeCount);
|
|
495
|
+
var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
|
|
496
|
+
currentNode = addAfter(tokenList, removeFrom, wrapped);
|
|
497
|
+
if (after) addAfter(tokenList, currentNode, after);
|
|
498
|
+
if (removeCount > 1) {
|
|
499
|
+
/** @type {RematchOptions} */
|
|
500
|
+
var nestedRematch = {
|
|
501
|
+
cause: token + "," + j,
|
|
502
|
+
reach
|
|
503
|
+
};
|
|
504
|
+
matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
|
|
505
|
+
if (rematch && nestedRematch.reach > rematch.reach) rematch.reach = nestedRematch.reach;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* @typedef LinkedListNode
|
|
513
|
+
* @property {T} value
|
|
514
|
+
* @property {LinkedListNode<T> | null} prev The previous node.
|
|
515
|
+
* @property {LinkedListNode<T> | null} next The next node.
|
|
516
|
+
* @template T
|
|
517
|
+
* @private
|
|
518
|
+
*/
|
|
519
|
+
/**
|
|
520
|
+
* @template T
|
|
521
|
+
* @private
|
|
522
|
+
*/
|
|
523
|
+
function LinkedList() {
|
|
524
|
+
/** @type {LinkedListNode<T>} */
|
|
525
|
+
var head = {
|
|
526
|
+
value: null,
|
|
527
|
+
prev: null,
|
|
528
|
+
next: null
|
|
529
|
+
};
|
|
530
|
+
/** @type {LinkedListNode<T>} */
|
|
531
|
+
var tail = {
|
|
532
|
+
value: null,
|
|
533
|
+
prev: head,
|
|
534
|
+
next: null
|
|
535
|
+
};
|
|
536
|
+
head.next = tail;
|
|
537
|
+
/** @type {LinkedListNode<T>} */
|
|
538
|
+
this.head = head;
|
|
539
|
+
/** @type {LinkedListNode<T>} */
|
|
540
|
+
this.tail = tail;
|
|
541
|
+
this.length = 0;
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Adds a new node with the given value to the list.
|
|
545
|
+
*
|
|
546
|
+
* @param {LinkedList<T>} list
|
|
547
|
+
* @param {LinkedListNode<T>} node
|
|
548
|
+
* @param {T} value
|
|
549
|
+
* @returns {LinkedListNode<T>} The added node.
|
|
550
|
+
* @template T
|
|
551
|
+
*/
|
|
552
|
+
function addAfter(list, node, value) {
|
|
553
|
+
var next = node.next;
|
|
554
|
+
var newNode = {
|
|
555
|
+
value,
|
|
556
|
+
prev: node,
|
|
557
|
+
next
|
|
558
|
+
};
|
|
559
|
+
node.next = newNode;
|
|
560
|
+
next.prev = newNode;
|
|
561
|
+
list.length++;
|
|
562
|
+
return newNode;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Removes `count` nodes after the given node. The given node will not be removed.
|
|
566
|
+
*
|
|
567
|
+
* @param {LinkedList<T>} list
|
|
568
|
+
* @param {LinkedListNode<T>} node
|
|
569
|
+
* @param {number} count
|
|
570
|
+
* @template T
|
|
571
|
+
*/
|
|
572
|
+
function removeRange(list, node, count) {
|
|
573
|
+
var next = node.next;
|
|
574
|
+
for (var i = 0; i < count && next !== list.tail; i++) next = next.next;
|
|
575
|
+
node.next = next;
|
|
576
|
+
next.prev = node;
|
|
577
|
+
list.length -= i;
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* @param {LinkedList<T>} list
|
|
581
|
+
* @returns {T[]}
|
|
582
|
+
* @template T
|
|
583
|
+
*/
|
|
584
|
+
function toArray(list) {
|
|
585
|
+
var array = [];
|
|
586
|
+
var node = list.head.next;
|
|
587
|
+
while (node !== list.tail) {
|
|
588
|
+
array.push(node.value);
|
|
589
|
+
node = node.next;
|
|
590
|
+
}
|
|
591
|
+
return array;
|
|
592
|
+
}
|
|
593
|
+
var Prism = _;
|
|
594
|
+
//#endregion
|
|
595
|
+
export { Prism };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region ../../node_modules/space-separated-tokens/index.js
|
|
2
|
+
/**
|
|
3
|
+
* Parse space-separated tokens to an array of strings.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} value
|
|
6
|
+
* Space-separated tokens.
|
|
7
|
+
* @returns {Array<string>}
|
|
8
|
+
* List of tokens.
|
|
9
|
+
*/
|
|
10
|
+
function parse(value) {
|
|
11
|
+
const input = String(value || "").trim();
|
|
12
|
+
return input ? input.split(/[ \t\n\r\f]+/g) : [];
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.parse = parse;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region ../../node_modules/space-separated-tokens/index.js
|
|
2
|
+
/**
|
|
3
|
+
* Parse space-separated tokens to an array of strings.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} value
|
|
6
|
+
* Space-separated tokens.
|
|
7
|
+
* @returns {Array<string>}
|
|
8
|
+
* List of tokens.
|
|
9
|
+
*/
|
|
10
|
+
function parse(value) {
|
|
11
|
+
const input = String(value || "").trim();
|
|
12
|
+
return input ? input.split(/[ \t\n\r\f]+/g) : [];
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { parse };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redis-ui/components",
|
|
3
3
|
"license": "UNLICENSED",
|
|
4
|
-
"version": "51.
|
|
4
|
+
"version": "51.29.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"repository": "git@github.com:redislabsdev/redis-ui.git",
|
|
@@ -58,11 +58,13 @@
|
|
|
58
58
|
"@tanstack/react-hotkeys": "^0.10.0",
|
|
59
59
|
"react-children-utilities": "2.9.0",
|
|
60
60
|
"react-loading-skeleton": "^3.5.0",
|
|
61
|
+
"react-syntax-highlighter": "^16.1.2",
|
|
61
62
|
"react-toastify": "11.1.0",
|
|
62
63
|
"type-fest": "^5.4.4",
|
|
63
64
|
"virtua": "^0.36.3"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
67
|
+
"@types/react-syntax-highlighter": "^15.5.13",
|
|
66
68
|
"@types/styled-components": "^5.1.26",
|
|
67
69
|
"vi-canvas-mock": "^1.0.0",
|
|
68
70
|
"vite-plugin-babel-macros": "^1.0.6",
|