@thoughtspot/visual-embed-sdk 1.49.2 → 1.49.3
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/cjs/package.json +4 -10
- package/cjs/src/embed/app.d.ts +7 -1
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts +6 -0
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/spotter-viz-utils.d.ts +29 -0
- package/cjs/src/embed/spotter-viz-utils.d.ts.map +1 -1
- package/cjs/src/embed/spotter-viz-utils.js.map +1 -1
- package/cjs/src/index.d.ts +2 -2
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.spec.js +15 -0
- package/cjs/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
- package/cjs/src/utils.js +2 -3
- package/cjs/src/utils.js.map +1 -1
- package/dist/{index-CS7yJ2Jj.js → index-DsSQndIB.js} +303 -187
- package/dist/src/embed/app.d.ts +7 -1
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts +6 -0
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/spotter-viz-utils.d.ts +29 -0
- package/dist/src/embed/spotter-viz-utils.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +32 -15
- package/dist/tsembed-react.js +333 -200
- package/dist/tsembed.es.js +32 -15
- package/dist/tsembed.js +333 -200
- package/dist/visual-embed-sdk-react-full.d.ts +42 -1
- package/dist/visual-embed-sdk-react.d.ts +42 -1
- package/dist/visual-embed-sdk.d.ts +42 -1
- package/lib/package.json +4 -10
- package/lib/src/embed/app.d.ts +7 -1
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts +6 -0
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/spotter-viz-utils.d.ts +29 -0
- package/lib/src/embed/spotter-viz-utils.d.ts.map +1 -1
- package/lib/src/embed/spotter-viz-utils.js.map +1 -1
- package/lib/src/index.d.ts +2 -2
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.spec.js +15 -0
- package/lib/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
- package/lib/src/utils.js +1 -1
- package/lib/src/utils.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +42 -1
- package/package.json +4 -10
- package/src/embed/app.ts +7 -1
- package/src/embed/liveboard.ts +6 -0
- package/src/embed/spotter-viz-utils.ts +30 -0
- package/src/index.ts +2 -1
- package/src/utils/graphql/answerService/answerService.spec.ts +18 -0
- package/src/utils.ts +1 -1
package/dist/tsembed-react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @thoughtspot/visual-embed-sdk version 1.49.
|
|
1
|
+
/* @thoughtspot/visual-embed-sdk version 1.49.3 */
|
|
2
2
|
'use client';
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
|
|
@@ -163,28 +163,45 @@
|
|
|
163
163
|
}
|
|
164
164
|
return false;
|
|
165
165
|
};
|
|
166
|
-
const
|
|
166
|
+
const UNSAFE_KEYS = new Set([
|
|
167
|
+
"__proto__",
|
|
168
|
+
"constructor",
|
|
169
|
+
"prototype",
|
|
170
|
+
"toString",
|
|
171
|
+
"valueOf",
|
|
172
|
+
"hasOwnProperty",
|
|
173
|
+
"isPrototypeOf",
|
|
174
|
+
"propertyIsEnumerable",
|
|
175
|
+
"toLocaleString",
|
|
176
|
+
]);
|
|
177
|
+
const merge$1 = (...objects) => objects.reduce((result, current) => {
|
|
178
|
+
if (current === undefined) {
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
167
181
|
if (Array.isArray(current)) {
|
|
168
182
|
throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
|
|
169
183
|
}
|
|
170
184
|
Object.keys(current).forEach((key) => {
|
|
171
|
-
if (
|
|
185
|
+
if (UNSAFE_KEYS.has(key)) {
|
|
172
186
|
return;
|
|
173
187
|
}
|
|
174
188
|
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
175
|
-
result[key] = merge.options.mergeArrays
|
|
176
|
-
? merge.options.uniqueArrayItems
|
|
189
|
+
result[key] = merge$1.options.mergeArrays
|
|
190
|
+
? merge$1.options.uniqueArrayItems
|
|
177
191
|
? Array.from(new Set(result[key].concat(current[key])))
|
|
178
192
|
: [...result[key], ...current[key]]
|
|
179
193
|
: current[key];
|
|
180
194
|
}
|
|
181
195
|
else if (isObject$1(result[key]) && isObject$1(current[key])) {
|
|
182
|
-
result[key] = merge(result[key], current[key]);
|
|
196
|
+
result[key] = merge$1(result[key], current[key]);
|
|
197
|
+
}
|
|
198
|
+
else if (!isObject$1(result[key]) && isObject$1(current[key])) {
|
|
199
|
+
result[key] = merge$1(current[key], undefined);
|
|
183
200
|
}
|
|
184
201
|
else {
|
|
185
202
|
result[key] =
|
|
186
203
|
current[key] === undefined
|
|
187
|
-
? merge.options.allowUndefinedOverrides
|
|
204
|
+
? merge$1.options.allowUndefinedOverrides
|
|
188
205
|
? current[key]
|
|
189
206
|
: result[key]
|
|
190
207
|
: current[key];
|
|
@@ -197,11 +214,11 @@
|
|
|
197
214
|
mergeArrays: true,
|
|
198
215
|
uniqueArrayItems: true,
|
|
199
216
|
};
|
|
200
|
-
merge.options = defaultOptions;
|
|
201
|
-
merge.withOptions = (options, ...objects) => {
|
|
202
|
-
merge.options = Object.assign(Object.assign({}, defaultOptions), options);
|
|
203
|
-
const result = merge(...objects);
|
|
204
|
-
merge.options = defaultOptions;
|
|
217
|
+
merge$1.options = defaultOptions;
|
|
218
|
+
merge$1.withOptions = (options, ...objects) => {
|
|
219
|
+
merge$1.options = Object.assign(Object.assign({}, defaultOptions), options);
|
|
220
|
+
const result = merge$1(...objects);
|
|
221
|
+
merge$1.options = defaultOptions;
|
|
205
222
|
return result;
|
|
206
223
|
};
|
|
207
224
|
|
|
@@ -6645,7 +6662,7 @@
|
|
|
6645
6662
|
TableContentDensity["Compact"] = "COMPACT";
|
|
6646
6663
|
})(TableContentDensity || (TableContentDensity = {}));
|
|
6647
6664
|
|
|
6648
|
-
var version$1="1.49.
|
|
6665
|
+
var version$1="1.49.3";var pkg = {version:version$1};
|
|
6649
6666
|
|
|
6650
6667
|
const { version } = pkg;
|
|
6651
6668
|
|
|
@@ -7013,7 +7030,7 @@
|
|
|
7013
7030
|
}
|
|
7014
7031
|
return null;
|
|
7015
7032
|
}
|
|
7016
|
-
const deepMerge = (target, source) => merge(target, source);
|
|
7033
|
+
const deepMerge = (target, source) => merge$1(target, source);
|
|
7017
7034
|
const getOperationNameFromQuery = (query) => {
|
|
7018
7035
|
const regex = /(?:query|mutation)\s+(\w+)/;
|
|
7019
7036
|
const matches = query.match(regex);
|
|
@@ -25061,8 +25078,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25061
25078
|
return {
|
|
25062
25079
|
onAnchor: (source) => {
|
|
25063
25080
|
aliasObjects.push(source);
|
|
25064
|
-
|
|
25065
|
-
prevAnchors = anchorNames(doc);
|
|
25081
|
+
prevAnchors ?? (prevAnchors = anchorNames(doc));
|
|
25066
25082
|
const anchor = findNewAnchor(prefix, prevAnchors);
|
|
25067
25083
|
prevAnchors.add(anchor);
|
|
25068
25084
|
return anchor;
|
|
@@ -25226,23 +25242,38 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25226
25242
|
* Resolve the value of this alias within `doc`, finding the last
|
|
25227
25243
|
* instance of the `source` anchor before this node.
|
|
25228
25244
|
*/
|
|
25229
|
-
resolve(doc) {
|
|
25245
|
+
resolve(doc, ctx) {
|
|
25246
|
+
if (ctx?.maxAliasCount === 0)
|
|
25247
|
+
throw new ReferenceError('Alias resolution is disabled');
|
|
25248
|
+
let nodes;
|
|
25249
|
+
if (ctx?.aliasResolveCache) {
|
|
25250
|
+
nodes = ctx.aliasResolveCache;
|
|
25251
|
+
}
|
|
25252
|
+
else {
|
|
25253
|
+
nodes = [];
|
|
25254
|
+
visit$1(doc, {
|
|
25255
|
+
Node: (_key, node) => {
|
|
25256
|
+
if (isAlias(node) || hasAnchor(node))
|
|
25257
|
+
nodes.push(node);
|
|
25258
|
+
}
|
|
25259
|
+
});
|
|
25260
|
+
if (ctx)
|
|
25261
|
+
ctx.aliasResolveCache = nodes;
|
|
25262
|
+
}
|
|
25230
25263
|
let found = undefined;
|
|
25231
|
-
|
|
25232
|
-
|
|
25233
|
-
|
|
25234
|
-
|
|
25235
|
-
|
|
25236
|
-
|
|
25237
|
-
}
|
|
25238
|
-
});
|
|
25264
|
+
for (const node of nodes) {
|
|
25265
|
+
if (node === this)
|
|
25266
|
+
break;
|
|
25267
|
+
if (node.anchor === this.source)
|
|
25268
|
+
found = node;
|
|
25269
|
+
}
|
|
25239
25270
|
return found;
|
|
25240
25271
|
}
|
|
25241
25272
|
toJSON(_arg, ctx) {
|
|
25242
25273
|
if (!ctx)
|
|
25243
25274
|
return { source: this.source };
|
|
25244
25275
|
const { anchors, doc, maxAliasCount } = ctx;
|
|
25245
|
-
const source = this.resolve(doc);
|
|
25276
|
+
const source = this.resolve(doc, ctx);
|
|
25246
25277
|
if (!source) {
|
|
25247
25278
|
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
25248
25279
|
throw new ReferenceError(msg);
|
|
@@ -25254,7 +25285,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25254
25285
|
data = anchors.get(source);
|
|
25255
25286
|
}
|
|
25256
25287
|
/* istanbul ignore if */
|
|
25257
|
-
if (
|
|
25288
|
+
if (data?.res === undefined) {
|
|
25258
25289
|
const msg = 'This should not happen: Alias anchor was not resolved?';
|
|
25259
25290
|
throw new ReferenceError(msg);
|
|
25260
25291
|
}
|
|
@@ -25361,8 +25392,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25361
25392
|
if (aliasDuplicateObjects && value && typeof value === 'object') {
|
|
25362
25393
|
ref = sourceObjects.get(value);
|
|
25363
25394
|
if (ref) {
|
|
25364
|
-
|
|
25365
|
-
ref.anchor = onAnchor(value);
|
|
25395
|
+
ref.anchor ?? (ref.anchor = onAnchor(value));
|
|
25366
25396
|
return new Alias(ref.anchor);
|
|
25367
25397
|
}
|
|
25368
25398
|
else {
|
|
@@ -25873,7 +25903,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25873
25903
|
const { blockQuote, commentString, lineWidth } = ctx.options;
|
|
25874
25904
|
// 1. Block can't end in whitespace unless the last line is non-empty.
|
|
25875
25905
|
// 2. Strings consisting of only whitespace are best rendered explicitly.
|
|
25876
|
-
if (!blockQuote || /\n[\t ]+$/.test(value)
|
|
25906
|
+
if (!blockQuote || /\n[\t ]+$/.test(value)) {
|
|
25877
25907
|
return quotedString(value, ctx);
|
|
25878
25908
|
}
|
|
25879
25909
|
const indent = ctx.indent ||
|
|
@@ -25933,23 +25963,32 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25933
25963
|
start = start.replace(/\n+/g, `$&${indent}`);
|
|
25934
25964
|
}
|
|
25935
25965
|
const indentSize = indent ? '2' : '1'; // root is at -1
|
|
25936
|
-
|
|
25966
|
+
// Leading | or > is added later
|
|
25967
|
+
let header = (startWithSpace ? indentSize : '') + chomp;
|
|
25937
25968
|
if (comment) {
|
|
25938
25969
|
header += ' ' + commentString(comment.replace(/ ?[\r\n]+/g, ' '));
|
|
25939
25970
|
if (onComment)
|
|
25940
25971
|
onComment();
|
|
25941
25972
|
}
|
|
25942
|
-
if (literal) {
|
|
25943
|
-
|
|
25944
|
-
|
|
25973
|
+
if (!literal) {
|
|
25974
|
+
const foldedValue = value
|
|
25975
|
+
.replace(/\n+/g, '\n$&')
|
|
25976
|
+
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
|
|
25977
|
+
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
|
|
25978
|
+
.replace(/\n+/g, `$&${indent}`);
|
|
25979
|
+
let literalFallback = false;
|
|
25980
|
+
const foldOptions = getFoldOptions(ctx, true);
|
|
25981
|
+
if (blockQuote !== 'folded' && type !== Scalar.BLOCK_FOLDED) {
|
|
25982
|
+
foldOptions.onOverflow = () => {
|
|
25983
|
+
literalFallback = true;
|
|
25984
|
+
};
|
|
25985
|
+
}
|
|
25986
|
+
const body = foldFlowLines(`${start}${foldedValue}${end}`, indent, FOLD_BLOCK, foldOptions);
|
|
25987
|
+
if (!literalFallback)
|
|
25988
|
+
return `>${header}\n${indent}${body}`;
|
|
25945
25989
|
}
|
|
25946
|
-
value = value
|
|
25947
|
-
|
|
25948
|
-
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
|
|
25949
|
-
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
|
|
25950
|
-
.replace(/\n+/g, `$&${indent}`);
|
|
25951
|
-
const body = foldFlowLines(`${start}${value}${end}`, indent, FOLD_BLOCK, getFoldOptions(ctx, true));
|
|
25952
|
-
return `${header}\n${indent}${body}`;
|
|
25990
|
+
value = value.replace(/\n+/g, `$&${indent}`);
|
|
25991
|
+
return `|${header}\n${indent}${start}${value}${end}`;
|
|
25953
25992
|
}
|
|
25954
25993
|
function plainString(item, ctx, onComment, onChompKeep) {
|
|
25955
25994
|
const { type, value } = item;
|
|
@@ -25958,10 +25997,9 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25958
25997
|
(inFlow && /[[\]{},]/.test(value))) {
|
|
25959
25998
|
return quotedString(value, ctx);
|
|
25960
25999
|
}
|
|
25961
|
-
if (
|
|
25962
|
-
/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
|
|
26000
|
+
if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
|
|
25963
26001
|
// not allowed:
|
|
25964
|
-
// -
|
|
26002
|
+
// - '-' or '?'
|
|
25965
26003
|
// - start with an indicator character (except [?:-]) or /[?-] /
|
|
25966
26004
|
// - '\n ', ': ' or ' \n' anywhere
|
|
25967
26005
|
// - '#' not preceded by a non-space char
|
|
@@ -26056,6 +26094,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26056
26094
|
nullStr: 'null',
|
|
26057
26095
|
simpleKeys: false,
|
|
26058
26096
|
singleQuote: null,
|
|
26097
|
+
trailingComma: false,
|
|
26059
26098
|
trueStr: 'true',
|
|
26060
26099
|
verifyAliasOrder: true
|
|
26061
26100
|
}, doc.schema.toStringOptions, options);
|
|
@@ -26090,7 +26129,12 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26090
26129
|
let obj;
|
|
26091
26130
|
if (isScalar$1(item)) {
|
|
26092
26131
|
obj = item.value;
|
|
26093
|
-
|
|
26132
|
+
let match = tags.filter(t => t.identify?.(obj));
|
|
26133
|
+
if (match.length > 1) {
|
|
26134
|
+
const testMatch = match.filter(t => t.test);
|
|
26135
|
+
if (testMatch.length > 0)
|
|
26136
|
+
match = testMatch;
|
|
26137
|
+
}
|
|
26094
26138
|
tagObj =
|
|
26095
26139
|
match.find(t => t.format === item.format) ?? match.find(t => !t.format);
|
|
26096
26140
|
}
|
|
@@ -26099,7 +26143,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26099
26143
|
tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
|
|
26100
26144
|
}
|
|
26101
26145
|
if (!tagObj) {
|
|
26102
|
-
const name = obj?.constructor?.name ?? typeof obj;
|
|
26146
|
+
const name = obj?.constructor?.name ?? (obj === null ? 'null' : typeof obj);
|
|
26103
26147
|
throw new Error(`Tag not resolved for ${name} value`);
|
|
26104
26148
|
}
|
|
26105
26149
|
return tagObj;
|
|
@@ -26114,7 +26158,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26114
26158
|
anchors.add(anchor);
|
|
26115
26159
|
props.push(`&${anchor}`);
|
|
26116
26160
|
}
|
|
26117
|
-
const tag = node.tag
|
|
26161
|
+
const tag = node.tag ?? (tagObj.default ? null : tagObj.tag);
|
|
26118
26162
|
if (tag)
|
|
26119
26163
|
props.push(doc.directives.tagString(tag));
|
|
26120
26164
|
return props.join(' ');
|
|
@@ -26140,8 +26184,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26140
26184
|
const node = isNode(item)
|
|
26141
26185
|
? item
|
|
26142
26186
|
: ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
|
|
26143
|
-
|
|
26144
|
-
tagObj = getTagObject(ctx.doc.schema.tags, node);
|
|
26187
|
+
tagObj ?? (tagObj = getTagObject(ctx.doc.schema.tags, node));
|
|
26145
26188
|
const props = stringifyProps(node, tagObj, ctx);
|
|
26146
26189
|
if (props.length > 0)
|
|
26147
26190
|
ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
|
|
@@ -26255,7 +26298,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26255
26298
|
ws += `\n${indentComment(cs, ctx.indent)}`;
|
|
26256
26299
|
}
|
|
26257
26300
|
if (valueStr === '' && !ctx.inFlow) {
|
|
26258
|
-
if (ws === '\n')
|
|
26301
|
+
if (ws === '\n' && valueComment)
|
|
26259
26302
|
ws = '\n\n';
|
|
26260
26303
|
}
|
|
26261
26304
|
else {
|
|
@@ -26303,54 +26346,10 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26303
26346
|
|
|
26304
26347
|
function warn(logLevel, warning) {
|
|
26305
26348
|
if (logLevel === 'debug' || logLevel === 'warn') {
|
|
26306
|
-
|
|
26307
|
-
process.emitWarning(warning);
|
|
26308
|
-
else
|
|
26309
|
-
console.warn(warning);
|
|
26349
|
+
console.warn(warning);
|
|
26310
26350
|
}
|
|
26311
26351
|
}
|
|
26312
26352
|
|
|
26313
|
-
const MERGE_KEY = '<<';
|
|
26314
|
-
function addPairToJSMap(ctx, map, { key, value }) {
|
|
26315
|
-
if (ctx?.doc.schema.merge && isMergeKey(key)) {
|
|
26316
|
-
value = isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
26317
|
-
if (isSeq(value))
|
|
26318
|
-
for (const it of value.items)
|
|
26319
|
-
mergeToJSMap(ctx, map, it);
|
|
26320
|
-
else if (Array.isArray(value))
|
|
26321
|
-
for (const it of value)
|
|
26322
|
-
mergeToJSMap(ctx, map, it);
|
|
26323
|
-
else
|
|
26324
|
-
mergeToJSMap(ctx, map, value);
|
|
26325
|
-
}
|
|
26326
|
-
else {
|
|
26327
|
-
const jsKey = toJS(key, '', ctx);
|
|
26328
|
-
if (map instanceof Map) {
|
|
26329
|
-
map.set(jsKey, toJS(value, jsKey, ctx));
|
|
26330
|
-
}
|
|
26331
|
-
else if (map instanceof Set) {
|
|
26332
|
-
map.add(jsKey);
|
|
26333
|
-
}
|
|
26334
|
-
else {
|
|
26335
|
-
const stringKey = stringifyKey(key, jsKey, ctx);
|
|
26336
|
-
const jsValue = toJS(value, stringKey, ctx);
|
|
26337
|
-
if (stringKey in map)
|
|
26338
|
-
Object.defineProperty(map, stringKey, {
|
|
26339
|
-
value: jsValue,
|
|
26340
|
-
writable: true,
|
|
26341
|
-
enumerable: true,
|
|
26342
|
-
configurable: true
|
|
26343
|
-
});
|
|
26344
|
-
else
|
|
26345
|
-
map[stringKey] = jsValue;
|
|
26346
|
-
}
|
|
26347
|
-
}
|
|
26348
|
-
return map;
|
|
26349
|
-
}
|
|
26350
|
-
const isMergeKey = (key) => key === MERGE_KEY ||
|
|
26351
|
-
(isScalar$1(key) &&
|
|
26352
|
-
key.value === MERGE_KEY &&
|
|
26353
|
-
(!key.type || key.type === Scalar.PLAIN));
|
|
26354
26353
|
// If the value associated with a merge key is a single mapping node, each of
|
|
26355
26354
|
// its key/value pairs is inserted into the current mapping, unless the key
|
|
26356
26355
|
// already exists in it. If the value associated with the merge key is a
|
|
@@ -26358,8 +26357,36 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26358
26357
|
// of these nodes is merged in turn according to its order in the sequence.
|
|
26359
26358
|
// Keys in mapping nodes earlier in the sequence override keys specified in
|
|
26360
26359
|
// later mapping nodes. -- http://yaml.org/type/merge.html
|
|
26361
|
-
|
|
26362
|
-
|
|
26360
|
+
const MERGE_KEY = '<<';
|
|
26361
|
+
const merge = {
|
|
26362
|
+
identify: value => value === MERGE_KEY ||
|
|
26363
|
+
(typeof value === 'symbol' && value.description === MERGE_KEY),
|
|
26364
|
+
default: 'key',
|
|
26365
|
+
tag: 'tag:yaml.org,2002:merge',
|
|
26366
|
+
test: /^<<$/,
|
|
26367
|
+
resolve: () => Object.assign(new Scalar(Symbol(MERGE_KEY)), {
|
|
26368
|
+
addToJSMap: addMergeToJSMap
|
|
26369
|
+
}),
|
|
26370
|
+
stringify: () => MERGE_KEY
|
|
26371
|
+
};
|
|
26372
|
+
const isMergeKey = (ctx, key) => (merge.identify(key) ||
|
|
26373
|
+
(isScalar$1(key) &&
|
|
26374
|
+
(!key.type || key.type === Scalar.PLAIN) &&
|
|
26375
|
+
merge.identify(key.value))) &&
|
|
26376
|
+
ctx?.doc.schema.tags.some(tag => tag.tag === merge.tag && tag.default);
|
|
26377
|
+
function addMergeToJSMap(ctx, map, value) {
|
|
26378
|
+
const source = resolveAliasValue(ctx, value);
|
|
26379
|
+
if (isSeq(source))
|
|
26380
|
+
for (const it of source.items)
|
|
26381
|
+
mergeValue(ctx, map, it);
|
|
26382
|
+
else if (Array.isArray(source))
|
|
26383
|
+
for (const it of source)
|
|
26384
|
+
mergeValue(ctx, map, it);
|
|
26385
|
+
else
|
|
26386
|
+
mergeValue(ctx, map, source);
|
|
26387
|
+
}
|
|
26388
|
+
function mergeValue(ctx, map, value) {
|
|
26389
|
+
const source = resolveAliasValue(ctx, value);
|
|
26363
26390
|
if (!isMap(source))
|
|
26364
26391
|
throw new Error('Merge sources must be maps or map aliases');
|
|
26365
26392
|
const srcMap = source.toJSON(null, ctx, Map);
|
|
@@ -26382,9 +26409,44 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26382
26409
|
}
|
|
26383
26410
|
return map;
|
|
26384
26411
|
}
|
|
26412
|
+
function resolveAliasValue(ctx, value) {
|
|
26413
|
+
return ctx && isAlias(value) ? value.resolve(ctx.doc, ctx) : value;
|
|
26414
|
+
}
|
|
26415
|
+
|
|
26416
|
+
function addPairToJSMap(ctx, map, { key, value }) {
|
|
26417
|
+
if (isNode(key) && key.addToJSMap)
|
|
26418
|
+
key.addToJSMap(ctx, map, value);
|
|
26419
|
+
// TODO: Should drop this special case for bare << handling
|
|
26420
|
+
else if (isMergeKey(ctx, key))
|
|
26421
|
+
addMergeToJSMap(ctx, map, value);
|
|
26422
|
+
else {
|
|
26423
|
+
const jsKey = toJS(key, '', ctx);
|
|
26424
|
+
if (map instanceof Map) {
|
|
26425
|
+
map.set(jsKey, toJS(value, jsKey, ctx));
|
|
26426
|
+
}
|
|
26427
|
+
else if (map instanceof Set) {
|
|
26428
|
+
map.add(jsKey);
|
|
26429
|
+
}
|
|
26430
|
+
else {
|
|
26431
|
+
const stringKey = stringifyKey(key, jsKey, ctx);
|
|
26432
|
+
const jsValue = toJS(value, stringKey, ctx);
|
|
26433
|
+
if (stringKey in map)
|
|
26434
|
+
Object.defineProperty(map, stringKey, {
|
|
26435
|
+
value: jsValue,
|
|
26436
|
+
writable: true,
|
|
26437
|
+
enumerable: true,
|
|
26438
|
+
configurable: true
|
|
26439
|
+
});
|
|
26440
|
+
else
|
|
26441
|
+
map[stringKey] = jsValue;
|
|
26442
|
+
}
|
|
26443
|
+
}
|
|
26444
|
+
return map;
|
|
26445
|
+
}
|
|
26385
26446
|
function stringifyKey(key, jsKey, ctx) {
|
|
26386
26447
|
if (jsKey === null)
|
|
26387
26448
|
return '';
|
|
26449
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
26388
26450
|
if (typeof jsKey !== 'object')
|
|
26389
26451
|
return String(jsKey);
|
|
26390
26452
|
if (isNode(key) && ctx?.doc) {
|
|
@@ -26537,12 +26599,22 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26537
26599
|
if (comment)
|
|
26538
26600
|
reqNewline = true;
|
|
26539
26601
|
let str = stringify$2(item, itemCtx, () => (comment = null));
|
|
26540
|
-
|
|
26602
|
+
reqNewline || (reqNewline = lines.length > linesAtValue || str.includes('\n'));
|
|
26603
|
+
if (i < items.length - 1) {
|
|
26541
26604
|
str += ',';
|
|
26605
|
+
}
|
|
26606
|
+
else if (ctx.options.trailingComma) {
|
|
26607
|
+
if (ctx.options.lineWidth > 0) {
|
|
26608
|
+
reqNewline || (reqNewline = lines.reduce((sum, line) => sum + line.length + 2, 2) +
|
|
26609
|
+
(str.length + 2) >
|
|
26610
|
+
ctx.options.lineWidth);
|
|
26611
|
+
}
|
|
26612
|
+
if (reqNewline) {
|
|
26613
|
+
str += ',';
|
|
26614
|
+
}
|
|
26615
|
+
}
|
|
26542
26616
|
if (comment)
|
|
26543
26617
|
str += lineComment(str, itemIndent, commentString(comment));
|
|
26544
|
-
if (!reqNewline && (lines.length > linesAtValue || str.includes('\n')))
|
|
26545
|
-
reqNewline = true;
|
|
26546
26618
|
lines.push(str);
|
|
26547
26619
|
linesAtValue = lines.length;
|
|
26548
26620
|
}
|
|
@@ -26887,11 +26959,12 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26887
26959
|
const num = typeof value === 'number' ? value : Number(value);
|
|
26888
26960
|
if (!isFinite(num))
|
|
26889
26961
|
return isNaN(num) ? '.nan' : num < 0 ? '-.inf' : '.inf';
|
|
26890
|
-
let n = JSON.stringify(value);
|
|
26962
|
+
let n = Object.is(value, -0) ? '-0' : JSON.stringify(value);
|
|
26891
26963
|
if (!format &&
|
|
26892
26964
|
minFractionDigits &&
|
|
26893
26965
|
(!tag || tag === 'tag:yaml.org,2002:float') &&
|
|
26894
|
-
|
|
26966
|
+
/^-?\d/.test(n) &&
|
|
26967
|
+
!n.includes('e')) {
|
|
26895
26968
|
let i = n.indexOf('.');
|
|
26896
26969
|
if (i < 0) {
|
|
26897
26970
|
i = n.length;
|
|
@@ -27017,7 +27090,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
27017
27090
|
identify: value => typeof value === 'boolean',
|
|
27018
27091
|
default: true,
|
|
27019
27092
|
tag: 'tag:yaml.org,2002:bool',
|
|
27020
|
-
test: /^true
|
|
27093
|
+
test: /^true$|^false$/,
|
|
27021
27094
|
resolve: str => str === 'true',
|
|
27022
27095
|
stringify: stringifyJSON
|
|
27023
27096
|
},
|
|
@@ -27062,10 +27135,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
27062
27135
|
* document.querySelector('#photo').src = URL.createObjectURL(blob)
|
|
27063
27136
|
*/
|
|
27064
27137
|
resolve(src, onError) {
|
|
27065
|
-
if (typeof
|
|
27066
|
-
return Buffer.from(src, 'base64');
|
|
27067
|
-
}
|
|
27068
|
-
else if (typeof atob === 'function') {
|
|
27138
|
+
if (typeof atob === 'function') {
|
|
27069
27139
|
// On IE 11, atob() can't handle newlines
|
|
27070
27140
|
const str = atob(src.replace(/[\n\r]/g, ''));
|
|
27071
27141
|
const buffer = new Uint8Array(str.length);
|
|
@@ -27079,15 +27149,11 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
27079
27149
|
}
|
|
27080
27150
|
},
|
|
27081
27151
|
stringify({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
27152
|
+
if (!value)
|
|
27153
|
+
return '';
|
|
27082
27154
|
const buf = value; // checked earlier by binary.identify()
|
|
27083
27155
|
let str;
|
|
27084
|
-
if (typeof
|
|
27085
|
-
str =
|
|
27086
|
-
buf instanceof Buffer
|
|
27087
|
-
? buf.toString('base64')
|
|
27088
|
-
: Buffer.from(buf.buffer).toString('base64');
|
|
27089
|
-
}
|
|
27090
|
-
else if (typeof btoa === 'function') {
|
|
27156
|
+
if (typeof btoa === 'function') {
|
|
27091
27157
|
let s = '';
|
|
27092
27158
|
for (let i = 0; i < buf.length; ++i)
|
|
27093
27159
|
s += String.fromCharCode(buf[i]);
|
|
@@ -27096,8 +27162,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
27096
27162
|
else {
|
|
27097
27163
|
throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
|
|
27098
27164
|
}
|
|
27099
|
-
|
|
27100
|
-
type = Scalar.BLOCK_LITERAL;
|
|
27165
|
+
type ?? (type = Scalar.BLOCK_LITERAL);
|
|
27101
27166
|
if (type !== Scalar.QUOTE_DOUBLE) {
|
|
27102
27167
|
const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
|
|
27103
27168
|
const n = Math.ceil(str.length / lineWidth);
|
|
@@ -27566,7 +27631,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
27566
27631
|
}
|
|
27567
27632
|
return new Date(date);
|
|
27568
27633
|
},
|
|
27569
|
-
stringify: ({ value }) => value
|
|
27634
|
+
stringify: ({ value }) => value?.toISOString().replace(/(T00:00:00)?\.000Z$/, '') ?? ''
|
|
27570
27635
|
};
|
|
27571
27636
|
|
|
27572
27637
|
const schema = [
|
|
@@ -27584,6 +27649,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
27584
27649
|
floatExp,
|
|
27585
27650
|
float,
|
|
27586
27651
|
binary,
|
|
27652
|
+
merge,
|
|
27587
27653
|
omap,
|
|
27588
27654
|
pairs,
|
|
27589
27655
|
set,
|
|
@@ -27611,6 +27677,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
27611
27677
|
intOct: intOct$1,
|
|
27612
27678
|
intTime,
|
|
27613
27679
|
map,
|
|
27680
|
+
merge,
|
|
27614
27681
|
null: nullTag,
|
|
27615
27682
|
omap,
|
|
27616
27683
|
pairs,
|
|
@@ -27620,13 +27687,20 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
27620
27687
|
};
|
|
27621
27688
|
const coreKnownTags = {
|
|
27622
27689
|
'tag:yaml.org,2002:binary': binary,
|
|
27690
|
+
'tag:yaml.org,2002:merge': merge,
|
|
27623
27691
|
'tag:yaml.org,2002:omap': omap,
|
|
27624
27692
|
'tag:yaml.org,2002:pairs': pairs,
|
|
27625
27693
|
'tag:yaml.org,2002:set': set,
|
|
27626
27694
|
'tag:yaml.org,2002:timestamp': timestamp
|
|
27627
27695
|
};
|
|
27628
|
-
function getTags(customTags, schemaName) {
|
|
27629
|
-
|
|
27696
|
+
function getTags(customTags, schemaName, addMergeTag) {
|
|
27697
|
+
const schemaTags = schemas.get(schemaName);
|
|
27698
|
+
if (schemaTags && !customTags) {
|
|
27699
|
+
return addMergeTag && !schemaTags.includes(merge)
|
|
27700
|
+
? schemaTags.concat(merge)
|
|
27701
|
+
: schemaTags.slice();
|
|
27702
|
+
}
|
|
27703
|
+
let tags = schemaTags;
|
|
27630
27704
|
if (!tags) {
|
|
27631
27705
|
if (Array.isArray(customTags))
|
|
27632
27706
|
tags = [];
|
|
@@ -27645,17 +27719,21 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
27645
27719
|
else if (typeof customTags === 'function') {
|
|
27646
27720
|
tags = customTags(tags.slice());
|
|
27647
27721
|
}
|
|
27648
|
-
|
|
27649
|
-
|
|
27650
|
-
|
|
27651
|
-
const tagObj = tagsByName[tag];
|
|
27652
|
-
if (tagObj)
|
|
27653
|
-
|
|
27654
|
-
|
|
27655
|
-
|
|
27656
|
-
|
|
27657
|
-
|
|
27658
|
-
|
|
27722
|
+
if (addMergeTag)
|
|
27723
|
+
tags = tags.concat(merge);
|
|
27724
|
+
return tags.reduce((tags, tag) => {
|
|
27725
|
+
const tagObj = typeof tag === 'string' ? tagsByName[tag] : tag;
|
|
27726
|
+
if (!tagObj) {
|
|
27727
|
+
const tagName = JSON.stringify(tag);
|
|
27728
|
+
const keys = Object.keys(tagsByName)
|
|
27729
|
+
.map(key => JSON.stringify(key))
|
|
27730
|
+
.join(', ');
|
|
27731
|
+
throw new Error(`Unknown custom tag ${tagName}; use one of ${keys}`);
|
|
27732
|
+
}
|
|
27733
|
+
if (!tags.includes(tagObj))
|
|
27734
|
+
tags.push(tagObj);
|
|
27735
|
+
return tags;
|
|
27736
|
+
}, []);
|
|
27659
27737
|
}
|
|
27660
27738
|
|
|
27661
27739
|
const sortMapEntriesByKey = (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
|
|
@@ -27666,10 +27744,9 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
27666
27744
|
: compat
|
|
27667
27745
|
? getTags(null, compat)
|
|
27668
27746
|
: null;
|
|
27669
|
-
this.merge = !!merge;
|
|
27670
27747
|
this.name = (typeof schema === 'string' && schema) || 'core';
|
|
27671
27748
|
this.knownTags = resolveKnownTags ? coreKnownTags : {};
|
|
27672
|
-
this.tags = getTags(customTags, this.name);
|
|
27749
|
+
this.tags = getTags(customTags, this.name, merge);
|
|
27673
27750
|
this.toStringOptions = toStringDefaults ?? null;
|
|
27674
27751
|
Object.defineProperty(this, MAP, { value: map });
|
|
27675
27752
|
Object.defineProperty(this, SCALAR$1, { value: string });
|
|
@@ -27794,6 +27871,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
27794
27871
|
logLevel: 'warn',
|
|
27795
27872
|
prettyErrors: true,
|
|
27796
27873
|
strict: true,
|
|
27874
|
+
stringKeys: false,
|
|
27797
27875
|
uniqueKeys: true,
|
|
27798
27876
|
version: '1.2'
|
|
27799
27877
|
}, options);
|
|
@@ -28017,7 +28095,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28017
28095
|
this.directives.yaml.version = '1.1';
|
|
28018
28096
|
else
|
|
28019
28097
|
this.directives = new Directives({ version: '1.1' });
|
|
28020
|
-
opt = {
|
|
28098
|
+
opt = { resolveKnownTags: false, schema: 'yaml-1.1' };
|
|
28021
28099
|
break;
|
|
28022
28100
|
case '1.2':
|
|
28023
28101
|
case 'next':
|
|
@@ -28025,7 +28103,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28025
28103
|
this.directives.yaml.version = version;
|
|
28026
28104
|
else
|
|
28027
28105
|
this.directives = new Directives({ version });
|
|
28028
|
-
opt = {
|
|
28106
|
+
opt = { resolveKnownTags: true, schema: 'core' };
|
|
28029
28107
|
break;
|
|
28030
28108
|
case null:
|
|
28031
28109
|
if (this.directives)
|
|
@@ -28138,7 +28216,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28138
28216
|
if (/[^ ]/.test(lineStr)) {
|
|
28139
28217
|
let count = 1;
|
|
28140
28218
|
const end = error.linePos[1];
|
|
28141
|
-
if (end
|
|
28219
|
+
if (end?.line === line && end.col > col) {
|
|
28142
28220
|
count = Math.max(1, Math.min(end.col - col, 80 - ci));
|
|
28143
28221
|
}
|
|
28144
28222
|
const pointer = ' '.repeat(ci) + '^'.repeat(count);
|
|
@@ -28203,7 +28281,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28203
28281
|
if (atNewline) {
|
|
28204
28282
|
if (comment)
|
|
28205
28283
|
comment += token.source;
|
|
28206
|
-
else
|
|
28284
|
+
else if (!found || indicator !== 'seq-item-ind')
|
|
28207
28285
|
spaceBefore = true;
|
|
28208
28286
|
}
|
|
28209
28287
|
else
|
|
@@ -28220,8 +28298,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28220
28298
|
if (token.source.endsWith(':'))
|
|
28221
28299
|
onError(token.offset + token.source.length - 1, 'BAD_ALIAS', 'Anchor ending in : is ambiguous', true);
|
|
28222
28300
|
anchor = token;
|
|
28223
|
-
|
|
28224
|
-
start = token.offset;
|
|
28301
|
+
start ?? (start = token.offset);
|
|
28225
28302
|
atNewline = false;
|
|
28226
28303
|
hasSpace = false;
|
|
28227
28304
|
reqSpace = true;
|
|
@@ -28230,8 +28307,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28230
28307
|
if (tag)
|
|
28231
28308
|
onError(token, 'MULTIPLE_TAGS', 'A node can have at most one tag');
|
|
28232
28309
|
tag = token;
|
|
28233
|
-
|
|
28234
|
-
start = token.offset;
|
|
28310
|
+
start ?? (start = token.offset);
|
|
28235
28311
|
atNewline = false;
|
|
28236
28312
|
hasSpace = false;
|
|
28237
28313
|
reqSpace = true;
|
|
@@ -28344,11 +28420,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28344
28420
|
return false;
|
|
28345
28421
|
const isEqual = typeof uniqueKeys === 'function'
|
|
28346
28422
|
? uniqueKeys
|
|
28347
|
-
: (a, b) => a === b ||
|
|
28348
|
-
(isScalar$1(a) &&
|
|
28349
|
-
isScalar$1(b) &&
|
|
28350
|
-
a.value === b.value &&
|
|
28351
|
-
!(a.value === '<<' && ctx.schema.merge));
|
|
28423
|
+
: (a, b) => a === b || (isScalar$1(a) && isScalar$1(b) && a.value === b.value);
|
|
28352
28424
|
return items.some(pair => isEqual(pair.key, search));
|
|
28353
28425
|
}
|
|
28354
28426
|
|
|
@@ -28397,12 +28469,14 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28397
28469
|
onError(offset, 'BAD_INDENT', startColMsg);
|
|
28398
28470
|
}
|
|
28399
28471
|
// key value
|
|
28472
|
+
ctx.atKey = true;
|
|
28400
28473
|
const keyStart = keyProps.end;
|
|
28401
28474
|
const keyNode = key
|
|
28402
28475
|
? composeNode(ctx, key, keyProps, onError)
|
|
28403
28476
|
: composeEmptyNode(ctx, keyStart, start, null, keyProps, onError);
|
|
28404
28477
|
if (ctx.schema.compat)
|
|
28405
28478
|
flowIndentCheck(bm.indent, key, onError);
|
|
28479
|
+
ctx.atKey = false;
|
|
28406
28480
|
if (mapIncludes(ctx, map.items, keyNode))
|
|
28407
28481
|
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
|
|
28408
28482
|
// value properties
|
|
@@ -28462,6 +28536,8 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28462
28536
|
const seq = new NodeClass(ctx.schema);
|
|
28463
28537
|
if (ctx.atRoot)
|
|
28464
28538
|
ctx.atRoot = false;
|
|
28539
|
+
if (ctx.atKey)
|
|
28540
|
+
ctx.atKey = false;
|
|
28465
28541
|
let offset = bs.offset;
|
|
28466
28542
|
let commentEnd = null;
|
|
28467
28543
|
for (const { start, value } of bs.items) {
|
|
@@ -28475,7 +28551,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28475
28551
|
});
|
|
28476
28552
|
if (!props.found) {
|
|
28477
28553
|
if (props.anchor || props.tag || value) {
|
|
28478
|
-
if (value
|
|
28554
|
+
if (value?.type === 'block-seq')
|
|
28479
28555
|
onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column');
|
|
28480
28556
|
else
|
|
28481
28557
|
onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator');
|
|
@@ -28546,6 +28622,8 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28546
28622
|
const atRoot = ctx.atRoot;
|
|
28547
28623
|
if (atRoot)
|
|
28548
28624
|
ctx.atRoot = false;
|
|
28625
|
+
if (ctx.atKey)
|
|
28626
|
+
ctx.atKey = false;
|
|
28549
28627
|
let offset = fc.offset + fc.start.source.length;
|
|
28550
28628
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
28551
28629
|
const collItem = fc.items[i];
|
|
@@ -28625,12 +28703,14 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28625
28703
|
else {
|
|
28626
28704
|
// item is a key+value pair
|
|
28627
28705
|
// key value
|
|
28706
|
+
ctx.atKey = true;
|
|
28628
28707
|
const keyStart = props.end;
|
|
28629
28708
|
const keyNode = key
|
|
28630
28709
|
? composeNode(ctx, key, props, onError)
|
|
28631
28710
|
: composeEmptyNode(ctx, keyStart, start, null, props, onError);
|
|
28632
28711
|
if (isBlock(key))
|
|
28633
28712
|
onError(keyNode.range, 'BLOCK_IN_FLOW', blockMsg);
|
|
28713
|
+
ctx.atKey = false;
|
|
28634
28714
|
// value properties
|
|
28635
28715
|
const valueProps = resolveProps(sep ?? [], {
|
|
28636
28716
|
flow: fcName,
|
|
@@ -28657,7 +28737,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28657
28737
|
}
|
|
28658
28738
|
}
|
|
28659
28739
|
else if (value) {
|
|
28660
|
-
if ('source' in value && value.source
|
|
28740
|
+
if ('source' in value && value.source?.[0] === ':')
|
|
28661
28741
|
onError(value, 'MISSING_CHAR', `Missing space after : in ${fcName}`);
|
|
28662
28742
|
else
|
|
28663
28743
|
onError(valueProps.start, 'MISSING_CHAR', `Missing , or : between ${fcName} items`);
|
|
@@ -28701,7 +28781,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28701
28781
|
const expectedEnd = isMap ? '}' : ']';
|
|
28702
28782
|
const [ce, ...ee] = fc.end;
|
|
28703
28783
|
let cePos = offset;
|
|
28704
|
-
if (ce
|
|
28784
|
+
if (ce?.source === expectedEnd)
|
|
28705
28785
|
cePos = ce.offset + ce.source.length;
|
|
28706
28786
|
else {
|
|
28707
28787
|
const name = fcName[0].toUpperCase() + fcName.substring(1);
|
|
@@ -28781,13 +28861,13 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28781
28861
|
let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType);
|
|
28782
28862
|
if (!tag) {
|
|
28783
28863
|
const kt = ctx.schema.knownTags[tagName];
|
|
28784
|
-
if (kt
|
|
28864
|
+
if (kt?.collection === expType) {
|
|
28785
28865
|
ctx.schema.tags.push(Object.assign({}, kt, { default: false }));
|
|
28786
28866
|
tag = kt;
|
|
28787
28867
|
}
|
|
28788
28868
|
else {
|
|
28789
|
-
if (kt
|
|
28790
|
-
onError(tagToken, 'BAD_COLLECTION_TYPE', `${kt.tag} used for ${expType} collection, but expects ${kt.collection}`, true);
|
|
28869
|
+
if (kt) {
|
|
28870
|
+
onError(tagToken, 'BAD_COLLECTION_TYPE', `${kt.tag} used for ${expType} collection, but expects ${kt.collection ?? 'scalar'}`, true);
|
|
28791
28871
|
}
|
|
28792
28872
|
else {
|
|
28793
28873
|
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, true);
|
|
@@ -29143,7 +29223,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
29143
29223
|
next = source[++i + 1];
|
|
29144
29224
|
}
|
|
29145
29225
|
else if (next === 'x' || next === 'u' || next === 'U') {
|
|
29146
|
-
const length =
|
|
29226
|
+
const length = next === 'x' ? 2 : next === 'u' ? 4 : 8;
|
|
29147
29227
|
res += parseCharCode(source, i + 1, length, onError);
|
|
29148
29228
|
i += length;
|
|
29149
29229
|
}
|
|
@@ -29213,12 +29293,14 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
29213
29293
|
const cc = source.substr(offset, length);
|
|
29214
29294
|
const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
|
|
29215
29295
|
const code = ok ? parseInt(cc, 16) : NaN;
|
|
29216
|
-
|
|
29296
|
+
try {
|
|
29297
|
+
return String.fromCodePoint(code);
|
|
29298
|
+
}
|
|
29299
|
+
catch {
|
|
29217
29300
|
const raw = source.substr(offset - 2, length + 2);
|
|
29218
29301
|
onError(offset - 2, 'BAD_DQ_ESCAPE', `Invalid escape sequence ${raw}`);
|
|
29219
29302
|
return raw;
|
|
29220
29303
|
}
|
|
29221
|
-
return String.fromCodePoint(code);
|
|
29222
29304
|
}
|
|
29223
29305
|
|
|
29224
29306
|
function composeScalar(ctx, token, tagToken, onError) {
|
|
@@ -29228,11 +29310,16 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
29228
29310
|
const tagName = tagToken
|
|
29229
29311
|
? ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg))
|
|
29230
29312
|
: null;
|
|
29231
|
-
|
|
29232
|
-
|
|
29233
|
-
|
|
29234
|
-
|
|
29235
|
-
|
|
29313
|
+
let tag;
|
|
29314
|
+
if (ctx.options.stringKeys && ctx.atKey) {
|
|
29315
|
+
tag = ctx.schema[SCALAR$1];
|
|
29316
|
+
}
|
|
29317
|
+
else if (tagName)
|
|
29318
|
+
tag = findScalarTagByName(ctx.schema, value, tagName, tagToken, onError);
|
|
29319
|
+
else if (token.type === 'scalar')
|
|
29320
|
+
tag = findScalarTagByTest(ctx, value, token, onError);
|
|
29321
|
+
else
|
|
29322
|
+
tag = ctx.schema[SCALAR$1];
|
|
29236
29323
|
let scalar;
|
|
29237
29324
|
try {
|
|
29238
29325
|
const res = tag.resolve(value, msg => onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg), ctx.options);
|
|
@@ -29280,8 +29367,9 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
29280
29367
|
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, tagName !== 'tag:yaml.org,2002:str');
|
|
29281
29368
|
return schema[SCALAR$1];
|
|
29282
29369
|
}
|
|
29283
|
-
function findScalarTagByTest({ directives, schema }, value, token, onError) {
|
|
29284
|
-
const tag = schema.tags.find(tag => tag.default && tag.
|
|
29370
|
+
function findScalarTagByTest({ atKey, directives, schema }, value, token, onError) {
|
|
29371
|
+
const tag = schema.tags.find(tag => (tag.default === true || (atKey && tag.default === 'key')) &&
|
|
29372
|
+
tag.test?.test(value)) || schema[SCALAR$1];
|
|
29285
29373
|
if (schema.compat) {
|
|
29286
29374
|
const compat = schema.compat.find(tag => tag.default && tag.test?.test(value)) ??
|
|
29287
29375
|
schema[SCALAR$1];
|
|
@@ -29297,8 +29385,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
29297
29385
|
|
|
29298
29386
|
function emptyScalarPosition(offset, before, pos) {
|
|
29299
29387
|
if (before) {
|
|
29300
|
-
|
|
29301
|
-
pos = before.length;
|
|
29388
|
+
pos ?? (pos = before.length);
|
|
29302
29389
|
for (let i = pos - 1; i >= 0; --i) {
|
|
29303
29390
|
let st = before[i];
|
|
29304
29391
|
switch (st.type) {
|
|
@@ -29323,6 +29410,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
29323
29410
|
|
|
29324
29411
|
const CN = { composeNode, composeEmptyNode };
|
|
29325
29412
|
function composeNode(ctx, token, props, onError) {
|
|
29413
|
+
const atKey = ctx.atKey;
|
|
29326
29414
|
const { spaceBefore, comment, anchor, tag } = props;
|
|
29327
29415
|
let node;
|
|
29328
29416
|
let isSrcToken = true;
|
|
@@ -29343,21 +29431,36 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
29343
29431
|
case 'block-map':
|
|
29344
29432
|
case 'block-seq':
|
|
29345
29433
|
case 'flow-collection':
|
|
29346
|
-
|
|
29347
|
-
|
|
29348
|
-
|
|
29434
|
+
try {
|
|
29435
|
+
node = composeCollection(CN, ctx, token, props, onError);
|
|
29436
|
+
if (anchor)
|
|
29437
|
+
node.anchor = anchor.source.substring(1);
|
|
29438
|
+
}
|
|
29439
|
+
catch (error) {
|
|
29440
|
+
// Almost certainly here due to a stack overflow
|
|
29441
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
29442
|
+
onError(token, 'RESOURCE_EXHAUSTION', message);
|
|
29443
|
+
}
|
|
29349
29444
|
break;
|
|
29350
29445
|
default: {
|
|
29351
29446
|
const message = token.type === 'error'
|
|
29352
29447
|
? token.message
|
|
29353
29448
|
: `Unsupported token (type: ${token.type})`;
|
|
29354
29449
|
onError(token, 'UNEXPECTED_TOKEN', message);
|
|
29355
|
-
node = composeEmptyNode(ctx, token.offset, undefined, null, props, onError);
|
|
29356
29450
|
isSrcToken = false;
|
|
29357
29451
|
}
|
|
29358
29452
|
}
|
|
29453
|
+
node ?? (node = composeEmptyNode(ctx, token.offset, undefined, null, props, onError));
|
|
29359
29454
|
if (anchor && node.anchor === '')
|
|
29360
29455
|
onError(anchor, 'BAD_ALIAS', 'Anchor cannot be an empty string');
|
|
29456
|
+
if (atKey &&
|
|
29457
|
+
ctx.options.stringKeys &&
|
|
29458
|
+
(!isScalar$1(node) ||
|
|
29459
|
+
typeof node.value !== 'string' ||
|
|
29460
|
+
(node.tag && node.tag !== 'tag:yaml.org,2002:str'))) {
|
|
29461
|
+
const msg = 'With stringKeys, all keys must be strings';
|
|
29462
|
+
onError(tag ?? token, 'NON_STRING_KEY', msg);
|
|
29463
|
+
}
|
|
29361
29464
|
if (spaceBefore)
|
|
29362
29465
|
node.spaceBefore = true;
|
|
29363
29466
|
if (comment) {
|
|
@@ -29410,6 +29513,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
29410
29513
|
const opts = Object.assign({ _directives: directives }, options);
|
|
29411
29514
|
const doc = new Document(undefined, opts);
|
|
29412
29515
|
const ctx = {
|
|
29516
|
+
atKey: false,
|
|
29413
29517
|
atRoot: true,
|
|
29414
29518
|
directives: doc.directives,
|
|
29415
29519
|
options: doc.options,
|
|
@@ -29531,8 +29635,10 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
29531
29635
|
}
|
|
29532
29636
|
}
|
|
29533
29637
|
if (afterDoc) {
|
|
29534
|
-
|
|
29535
|
-
|
|
29638
|
+
for (let i = 0; i < this.errors.length; ++i)
|
|
29639
|
+
doc.errors.push(this.errors[i]);
|
|
29640
|
+
for (let i = 0; i < this.warnings.length; ++i)
|
|
29641
|
+
doc.warnings.push(this.warnings[i]);
|
|
29536
29642
|
}
|
|
29537
29643
|
else {
|
|
29538
29644
|
doc.errors = this.errors;
|
|
@@ -30435,7 +30541,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
30435
30541
|
const n = (yield* this.pushCount(1)) + (yield* this.pushSpaces(true));
|
|
30436
30542
|
this.indentNext = this.indentValue + 1;
|
|
30437
30543
|
this.indentValue += n;
|
|
30438
|
-
return
|
|
30544
|
+
return 'block-start';
|
|
30439
30545
|
}
|
|
30440
30546
|
return 'doc';
|
|
30441
30547
|
}
|
|
@@ -30756,32 +30862,36 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
30756
30862
|
return 0;
|
|
30757
30863
|
}
|
|
30758
30864
|
*pushIndicators() {
|
|
30759
|
-
|
|
30760
|
-
|
|
30761
|
-
|
|
30762
|
-
|
|
30763
|
-
|
|
30764
|
-
|
|
30765
|
-
|
|
30766
|
-
|
|
30767
|
-
|
|
30768
|
-
|
|
30769
|
-
|
|
30770
|
-
|
|
30771
|
-
|
|
30772
|
-
|
|
30773
|
-
|
|
30774
|
-
|
|
30775
|
-
|
|
30776
|
-
|
|
30777
|
-
|
|
30778
|
-
|
|
30779
|
-
|
|
30780
|
-
|
|
30865
|
+
let n = 0;
|
|
30866
|
+
loop: while (true) {
|
|
30867
|
+
switch (this.charAt(0)) {
|
|
30868
|
+
case '!':
|
|
30869
|
+
n += yield* this.pushTag();
|
|
30870
|
+
n += yield* this.pushSpaces(true);
|
|
30871
|
+
continue loop;
|
|
30872
|
+
case '&':
|
|
30873
|
+
n += yield* this.pushUntil(isNotAnchorChar);
|
|
30874
|
+
n += yield* this.pushSpaces(true);
|
|
30875
|
+
continue loop;
|
|
30876
|
+
case '-': // this is an error
|
|
30877
|
+
case '?': // this is an error outside flow collections
|
|
30878
|
+
case ':': {
|
|
30879
|
+
const inFlow = this.flowLevel > 0;
|
|
30880
|
+
const ch1 = this.charAt(1);
|
|
30881
|
+
if (isEmpty(ch1) || (inFlow && flowIndicatorChars.has(ch1))) {
|
|
30882
|
+
if (!inFlow)
|
|
30883
|
+
this.indentNext = this.indentValue + 1;
|
|
30884
|
+
else if (this.flowKey)
|
|
30885
|
+
this.flowKey = false;
|
|
30886
|
+
n += yield* this.pushCount(1);
|
|
30887
|
+
n += yield* this.pushSpaces(true);
|
|
30888
|
+
continue loop;
|
|
30889
|
+
}
|
|
30781
30890
|
}
|
|
30782
30891
|
}
|
|
30892
|
+
break loop;
|
|
30783
30893
|
}
|
|
30784
|
-
return
|
|
30894
|
+
return n;
|
|
30785
30895
|
}
|
|
30786
30896
|
*pushTag() {
|
|
30787
30897
|
if (this.charAt(1) === '<') {
|
|
@@ -30943,6 +31053,14 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
30943
31053
|
}
|
|
30944
31054
|
return prev.splice(i, prev.length);
|
|
30945
31055
|
}
|
|
31056
|
+
function arrayPushArray(target, source) {
|
|
31057
|
+
// May exhaust call stack with large `source` array
|
|
31058
|
+
if (source.length < 1e5)
|
|
31059
|
+
Array.prototype.push.apply(target, source);
|
|
31060
|
+
else
|
|
31061
|
+
for (let i = 0; i < source.length; ++i)
|
|
31062
|
+
target.push(source[i]);
|
|
31063
|
+
}
|
|
30946
31064
|
function fixFlowSeqItems(fc) {
|
|
30947
31065
|
if (fc.start.type === 'flow-seq-start') {
|
|
30948
31066
|
for (const it of fc.items) {
|
|
@@ -30955,12 +31073,12 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
30955
31073
|
delete it.key;
|
|
30956
31074
|
if (isFlowToken(it.value)) {
|
|
30957
31075
|
if (it.value.end)
|
|
30958
|
-
|
|
31076
|
+
arrayPushArray(it.value.end, it.sep);
|
|
30959
31077
|
else
|
|
30960
31078
|
it.value.end = it.sep;
|
|
30961
31079
|
}
|
|
30962
31080
|
else
|
|
30963
|
-
|
|
31081
|
+
arrayPushArray(it.start, it.sep);
|
|
30964
31082
|
delete it.sep;
|
|
30965
31083
|
}
|
|
30966
31084
|
}
|
|
@@ -31102,7 +31220,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
31102
31220
|
}
|
|
31103
31221
|
*step() {
|
|
31104
31222
|
const top = this.peek(1);
|
|
31105
|
-
if (this.type === 'doc-end' &&
|
|
31223
|
+
if (this.type === 'doc-end' && top?.type !== 'doc-end') {
|
|
31106
31224
|
while (this.stack.length > 0)
|
|
31107
31225
|
yield* this.pop();
|
|
31108
31226
|
this.stack.push({
|
|
@@ -31378,7 +31496,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
31378
31496
|
const prev = map.items[map.items.length - 2];
|
|
31379
31497
|
const end = prev?.value?.end;
|
|
31380
31498
|
if (Array.isArray(end)) {
|
|
31381
|
-
|
|
31499
|
+
arrayPushArray(end, it.start);
|
|
31382
31500
|
end.push(this.sourceToken);
|
|
31383
31501
|
map.items.pop();
|
|
31384
31502
|
return;
|
|
@@ -31544,7 +31662,20 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
31544
31662
|
default: {
|
|
31545
31663
|
const bv = this.startBlockValue(map);
|
|
31546
31664
|
if (bv) {
|
|
31547
|
-
if (
|
|
31665
|
+
if (bv.type === 'block-seq') {
|
|
31666
|
+
if (!it.explicitKey &&
|
|
31667
|
+
it.sep &&
|
|
31668
|
+
!includesToken(it.sep, 'newline')) {
|
|
31669
|
+
yield* this.pop({
|
|
31670
|
+
type: 'error',
|
|
31671
|
+
offset: this.offset,
|
|
31672
|
+
message: 'Unexpected block-seq-ind on same line with key',
|
|
31673
|
+
source: this.source
|
|
31674
|
+
});
|
|
31675
|
+
return;
|
|
31676
|
+
}
|
|
31677
|
+
}
|
|
31678
|
+
else if (atMapIndent) {
|
|
31548
31679
|
map.items.push({ start });
|
|
31549
31680
|
}
|
|
31550
31681
|
this.stack.push(bv);
|
|
@@ -31580,7 +31711,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
31580
31711
|
const prev = seq.items[seq.items.length - 2];
|
|
31581
31712
|
const end = prev?.value?.end;
|
|
31582
31713
|
if (Array.isArray(end)) {
|
|
31583
|
-
|
|
31714
|
+
arrayPushArray(end, it.start);
|
|
31584
31715
|
end.push(this.sourceToken);
|
|
31585
31716
|
seq.items.pop();
|
|
31586
31717
|
return;
|
|
@@ -31621,7 +31752,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
31621
31752
|
do {
|
|
31622
31753
|
yield* this.pop();
|
|
31623
31754
|
top = this.peek(1);
|
|
31624
|
-
} while (top
|
|
31755
|
+
} while (top?.type === 'flow-collection');
|
|
31625
31756
|
}
|
|
31626
31757
|
else if (fc.end.length === 0) {
|
|
31627
31758
|
switch (this.type) {
|
|
@@ -31915,6 +32046,8 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
31915
32046
|
if (!keepUndefined)
|
|
31916
32047
|
return undefined;
|
|
31917
32048
|
}
|
|
32049
|
+
if (isDocument(value) && !_replacer)
|
|
32050
|
+
return value.toString(options);
|
|
31918
32051
|
return new Document(value, _replacer, options).toString(options);
|
|
31919
32052
|
}
|
|
31920
32053
|
|