@thoughtspot/visual-embed-sdk 1.42.1-alpha.2 → 1.42.1-alpha.4
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 +1 -2
- package/cjs/src/api-intercept.d.ts +9 -6
- package/cjs/src/api-intercept.d.ts.map +1 -1
- package/cjs/src/api-intercept.js +10 -7
- package/cjs/src/api-intercept.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +0 -85
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/react/util.d.ts +0 -1
- package/cjs/src/react/util.d.ts.map +1 -1
- package/cjs/src/utils/processData.spec.js.map +1 -1
- package/dist/index-BaESA9rq.js +7371 -0
- package/dist/index-DhFH7b7U.js +7447 -0
- package/dist/src/api-intercept.d.ts +9 -6
- package/dist/src/api-intercept.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/dist/src/react/util.d.ts +0 -1
- package/dist/src/react/util.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +13 -10
- package/dist/tsembed-react.js +233 -154
- package/dist/tsembed.es.js +13 -10
- package/dist/tsembed.js +233 -154
- package/lib/package.json +1 -2
- package/lib/src/api-intercept.d.ts +9 -6
- package/lib/src/api-intercept.d.ts.map +1 -1
- package/lib/src/api-intercept.js +10 -7
- package/lib/src/api-intercept.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +0 -85
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/react/util.d.ts +0 -1
- package/lib/src/react/util.d.ts.map +1 -1
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/package.json +1 -2
- package/src/api-intercept.ts +11 -8
- package/src/embed/ts-embed.spec.ts +0 -105
- package/src/utils/processData.spec.ts +0 -1
- package/src/api-intercept.spec.ts +0 -147
package/dist/tsembed-react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @thoughtspot/visual-embed-sdk version 1.42.1-alpha.
|
|
1
|
+
/* @thoughtspot/visual-embed-sdk version 1.42.1-alpha.4 */
|
|
2
2
|
'use client';
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
}
|
|
164
164
|
return false;
|
|
165
165
|
};
|
|
166
|
-
const merge = (...objects) => objects.reduce((result, current) => {
|
|
166
|
+
const merge$1 = (...objects) => objects.reduce((result, current) => {
|
|
167
167
|
if (Array.isArray(current)) {
|
|
168
168
|
throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");
|
|
169
169
|
}
|
|
@@ -172,19 +172,19 @@
|
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
174
|
if (Array.isArray(result[key]) && Array.isArray(current[key])) {
|
|
175
|
-
result[key] = merge.options.mergeArrays
|
|
176
|
-
? merge.options.uniqueArrayItems
|
|
175
|
+
result[key] = merge$1.options.mergeArrays
|
|
176
|
+
? merge$1.options.uniqueArrayItems
|
|
177
177
|
? Array.from(new Set(result[key].concat(current[key])))
|
|
178
178
|
: [...result[key], ...current[key]]
|
|
179
179
|
: current[key];
|
|
180
180
|
}
|
|
181
181
|
else if (isObject$1(result[key]) && isObject$1(current[key])) {
|
|
182
|
-
result[key] = merge(result[key], current[key]);
|
|
182
|
+
result[key] = merge$1(result[key], current[key]);
|
|
183
183
|
}
|
|
184
184
|
else {
|
|
185
185
|
result[key] =
|
|
186
186
|
current[key] === undefined
|
|
187
|
-
? merge.options.allowUndefinedOverrides
|
|
187
|
+
? merge$1.options.allowUndefinedOverrides
|
|
188
188
|
? current[key]
|
|
189
189
|
: result[key]
|
|
190
190
|
: current[key];
|
|
@@ -197,11 +197,11 @@
|
|
|
197
197
|
mergeArrays: true,
|
|
198
198
|
uniqueArrayItems: true,
|
|
199
199
|
};
|
|
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;
|
|
200
|
+
merge$1.options = defaultOptions;
|
|
201
|
+
merge$1.withOptions = (options, ...objects) => {
|
|
202
|
+
merge$1.options = Object.assign(Object.assign({}, defaultOptions), options);
|
|
203
|
+
const result = merge$1(...objects);
|
|
204
|
+
merge$1.options = defaultOptions;
|
|
205
205
|
return result;
|
|
206
206
|
};
|
|
207
207
|
|
|
@@ -4892,7 +4892,7 @@
|
|
|
4892
4892
|
function getDOMNode(domSelector) {
|
|
4893
4893
|
return typeof domSelector === 'string' ? document.querySelector(domSelector) : domSelector;
|
|
4894
4894
|
}
|
|
4895
|
-
const deepMerge = (target, source) => merge(target, source);
|
|
4895
|
+
const deepMerge = (target, source) => merge$1(target, source);
|
|
4896
4896
|
const getOperationNameFromQuery = (query) => {
|
|
4897
4897
|
const regex = /(?:query|mutation)\s+(\w+)/;
|
|
4898
4898
|
const matches = query.match(regex);
|
|
@@ -17501,7 +17501,7 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
|
|
|
17501
17501
|
return eventData;
|
|
17502
17502
|
}
|
|
17503
17503
|
|
|
17504
|
-
var name="@thoughtspot/visual-embed-sdk";var version$1="1.42.1-alpha.
|
|
17504
|
+
var name="@thoughtspot/visual-embed-sdk";var version$1="1.42.1-alpha.4";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**","cjs/**"];var exports$1={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p tsconfig.build.json --incremental false; tsc -p tsconfig.build.json --incremental false --module commonjs --outDir cjs","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts-file":"dts-bundle-generator --config ./dts-config/dts-bundle-file.config.js","bundle-dts":"dts-bundle-generator --config ./dts-config/dts-bundle.config.js","bundle-dts-react":"dts-bundle-generator --config ./dts-config/dts-bundle-react.config.js","bundle-dts-react-full":"dts-bundle-generator --config ./dts-config/dts-bundle-react-full.config.js",build:"rollup -c",watch:"rollup -cw",docgen:"typedoc --tsconfig tsconfig.build.json --theme typedoc-theme --json static/typedoc/typedoc.json --disableOutputCheck","test-sdk":"jest -c jest.config.sdk.js --runInBand",test:"npm run test-sdk",posttest:"cat ./coverage/sdk/lcov.info | npx coveralls-next","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest",dev:"vite -c vite.local.config.ts"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={classnames:"^2.3.1",eventemitter3:"^4.0.7",lodash:"^4.17.21","mixpanel-browser":"2.47.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","use-deep-compare-effect":"^1.8.1",yaml:"^2.5.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^11.2.0","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/lodash":"^4.17.0","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^8.28.0","@typescript-eslint/parser":"^8.28.0",ajv:"^8.17.1",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1","coveralls-next":"^5.0.0",crypto:"^1.0.1","current-git-branch":"^1.1.0","dts-bundle-generator":"^9.5.1",eslint:"^9.23.0","eslint-config-airbnb-base":"^15.0.0","eslint-config-prettier":"^10.1.1","eslint-import-resolver-typescript":"^4.2.5","eslint-plugin-comment-length":"2.2.1","eslint-plugin-import":"^2.31.0","eslint-plugin-jsdoc":"^50.6.9","eslint-plugin-prettier":"^5.2.5","eslint-plugin-react":"^7.37.5","eslint-plugin-react-hooks":"^5.2.0","fs-extra":"^10.0.0","gh-pages":"6.3.0",globals:"^16.0.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^2.0.0",jest:"^26.6.3","jest-fetch-mock":"^3.0.3",jsdom:"^17.0.0",prettier:"2.1.2",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"4.24.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","typescript-eslint":"^8.29.1","url-search-params-polyfill":"^8.1.0",util:"^0.12.4",vite:"^6.3.5"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embedded","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version$1,description:description,module:module,main:main,types:types,files:files,exports:exports$1,typesVersions:typesVersions,"size-limit":[{path:"dist/tsembed.es.js",limit:"32 kB"}],scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
|
|
17505
17505
|
|
|
17506
17506
|
/**
|
|
17507
17507
|
* Reloads the ThoughtSpot iframe.
|
|
@@ -17753,14 +17753,17 @@ mutation GetUnsavedAnswerTML($session: BachSessionIdInput!, $exportDependencies:
|
|
|
17753
17753
|
const desc = (_b = payload === null || payload === void 0 ? void 0 : payload.data) === null || _b === void 0 ? void 0 : _b.errorDescription;
|
|
17754
17754
|
const payloadToSend = {
|
|
17755
17755
|
execute: (_c = payload === null || payload === void 0 ? void 0 : payload.data) === null || _c === void 0 ? void 0 : _c.execute,
|
|
17756
|
-
|
|
17757
|
-
|
|
17758
|
-
|
|
17759
|
-
|
|
17760
|
-
|
|
17756
|
+
body: {
|
|
17757
|
+
errors: [
|
|
17758
|
+
{
|
|
17759
|
+
errorObj: {
|
|
17760
|
+
title,
|
|
17761
|
+
desc
|
|
17762
|
+
}
|
|
17761
17763
|
}
|
|
17762
|
-
|
|
17763
|
-
|
|
17764
|
+
],
|
|
17765
|
+
},
|
|
17766
|
+
status: 200,
|
|
17764
17767
|
};
|
|
17765
17768
|
return { data: payloadToSend };
|
|
17766
17769
|
};
|
|
@@ -21849,8 +21852,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
21849
21852
|
return {
|
|
21850
21853
|
onAnchor: (source) => {
|
|
21851
21854
|
aliasObjects.push(source);
|
|
21852
|
-
|
|
21853
|
-
prevAnchors = anchorNames(doc);
|
|
21855
|
+
prevAnchors ?? (prevAnchors = anchorNames(doc));
|
|
21854
21856
|
const anchor = findNewAnchor(prefix, prevAnchors);
|
|
21855
21857
|
prevAnchors.add(anchor);
|
|
21856
21858
|
return anchor;
|
|
@@ -22014,23 +22016,36 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22014
22016
|
* Resolve the value of this alias within `doc`, finding the last
|
|
22015
22017
|
* instance of the `source` anchor before this node.
|
|
22016
22018
|
*/
|
|
22017
|
-
resolve(doc) {
|
|
22019
|
+
resolve(doc, ctx) {
|
|
22020
|
+
let nodes;
|
|
22021
|
+
if (ctx?.aliasResolveCache) {
|
|
22022
|
+
nodes = ctx.aliasResolveCache;
|
|
22023
|
+
}
|
|
22024
|
+
else {
|
|
22025
|
+
nodes = [];
|
|
22026
|
+
visit$1(doc, {
|
|
22027
|
+
Node: (_key, node) => {
|
|
22028
|
+
if (isAlias(node) || hasAnchor(node))
|
|
22029
|
+
nodes.push(node);
|
|
22030
|
+
}
|
|
22031
|
+
});
|
|
22032
|
+
if (ctx)
|
|
22033
|
+
ctx.aliasResolveCache = nodes;
|
|
22034
|
+
}
|
|
22018
22035
|
let found = undefined;
|
|
22019
|
-
|
|
22020
|
-
|
|
22021
|
-
|
|
22022
|
-
|
|
22023
|
-
|
|
22024
|
-
|
|
22025
|
-
}
|
|
22026
|
-
});
|
|
22036
|
+
for (const node of nodes) {
|
|
22037
|
+
if (node === this)
|
|
22038
|
+
break;
|
|
22039
|
+
if (node.anchor === this.source)
|
|
22040
|
+
found = node;
|
|
22041
|
+
}
|
|
22027
22042
|
return found;
|
|
22028
22043
|
}
|
|
22029
22044
|
toJSON(_arg, ctx) {
|
|
22030
22045
|
if (!ctx)
|
|
22031
22046
|
return { source: this.source };
|
|
22032
22047
|
const { anchors, doc, maxAliasCount } = ctx;
|
|
22033
|
-
const source = this.resolve(doc);
|
|
22048
|
+
const source = this.resolve(doc, ctx);
|
|
22034
22049
|
if (!source) {
|
|
22035
22050
|
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
22036
22051
|
throw new ReferenceError(msg);
|
|
@@ -22149,8 +22164,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22149
22164
|
if (aliasDuplicateObjects && value && typeof value === 'object') {
|
|
22150
22165
|
ref = sourceObjects.get(value);
|
|
22151
22166
|
if (ref) {
|
|
22152
|
-
|
|
22153
|
-
ref.anchor = onAnchor(value);
|
|
22167
|
+
ref.anchor ?? (ref.anchor = onAnchor(value));
|
|
22154
22168
|
return new Alias(ref.anchor);
|
|
22155
22169
|
}
|
|
22156
22170
|
else {
|
|
@@ -22661,7 +22675,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22661
22675
|
const { blockQuote, commentString, lineWidth } = ctx.options;
|
|
22662
22676
|
// 1. Block can't end in whitespace unless the last line is non-empty.
|
|
22663
22677
|
// 2. Strings consisting of only whitespace are best rendered explicitly.
|
|
22664
|
-
if (!blockQuote || /\n[\t ]+$/.test(value)
|
|
22678
|
+
if (!blockQuote || /\n[\t ]+$/.test(value)) {
|
|
22665
22679
|
return quotedString(value, ctx);
|
|
22666
22680
|
}
|
|
22667
22681
|
const indent = ctx.indent ||
|
|
@@ -22721,23 +22735,32 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22721
22735
|
start = start.replace(/\n+/g, `$&${indent}`);
|
|
22722
22736
|
}
|
|
22723
22737
|
const indentSize = indent ? '2' : '1'; // root is at -1
|
|
22724
|
-
|
|
22738
|
+
// Leading | or > is added later
|
|
22739
|
+
let header = (startWithSpace ? indentSize : '') + chomp;
|
|
22725
22740
|
if (comment) {
|
|
22726
22741
|
header += ' ' + commentString(comment.replace(/ ?[\r\n]+/g, ' '));
|
|
22727
22742
|
if (onComment)
|
|
22728
22743
|
onComment();
|
|
22729
22744
|
}
|
|
22730
|
-
if (literal) {
|
|
22731
|
-
|
|
22732
|
-
|
|
22745
|
+
if (!literal) {
|
|
22746
|
+
const foldedValue = value
|
|
22747
|
+
.replace(/\n+/g, '\n$&')
|
|
22748
|
+
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
|
|
22749
|
+
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
|
|
22750
|
+
.replace(/\n+/g, `$&${indent}`);
|
|
22751
|
+
let literalFallback = false;
|
|
22752
|
+
const foldOptions = getFoldOptions(ctx, true);
|
|
22753
|
+
if (blockQuote !== 'folded' && type !== Scalar.BLOCK_FOLDED) {
|
|
22754
|
+
foldOptions.onOverflow = () => {
|
|
22755
|
+
literalFallback = true;
|
|
22756
|
+
};
|
|
22757
|
+
}
|
|
22758
|
+
const body = foldFlowLines(`${start}${foldedValue}${end}`, indent, FOLD_BLOCK, foldOptions);
|
|
22759
|
+
if (!literalFallback)
|
|
22760
|
+
return `>${header}\n${indent}${body}`;
|
|
22733
22761
|
}
|
|
22734
|
-
value = value
|
|
22735
|
-
|
|
22736
|
-
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
|
|
22737
|
-
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
|
|
22738
|
-
.replace(/\n+/g, `$&${indent}`);
|
|
22739
|
-
const body = foldFlowLines(`${start}${value}${end}`, indent, FOLD_BLOCK, getFoldOptions(ctx, true));
|
|
22740
|
-
return `${header}\n${indent}${body}`;
|
|
22762
|
+
value = value.replace(/\n+/g, `$&${indent}`);
|
|
22763
|
+
return `|${header}\n${indent}${start}${value}${end}`;
|
|
22741
22764
|
}
|
|
22742
22765
|
function plainString(item, ctx, onComment, onChompKeep) {
|
|
22743
22766
|
const { type, value } = item;
|
|
@@ -22746,10 +22769,9 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22746
22769
|
(inFlow && /[[\]{},]/.test(value))) {
|
|
22747
22770
|
return quotedString(value, ctx);
|
|
22748
22771
|
}
|
|
22749
|
-
if (
|
|
22750
|
-
/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
|
|
22772
|
+
if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
|
|
22751
22773
|
// not allowed:
|
|
22752
|
-
// -
|
|
22774
|
+
// - '-' or '?'
|
|
22753
22775
|
// - start with an indicator character (except [?:-]) or /[?-] /
|
|
22754
22776
|
// - '\n ', ': ' or ' \n' anywhere
|
|
22755
22777
|
// - '#' not preceded by a non-space char
|
|
@@ -22878,7 +22900,12 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22878
22900
|
let obj;
|
|
22879
22901
|
if (isScalar$1(item)) {
|
|
22880
22902
|
obj = item.value;
|
|
22881
|
-
|
|
22903
|
+
let match = tags.filter(t => t.identify?.(obj));
|
|
22904
|
+
if (match.length > 1) {
|
|
22905
|
+
const testMatch = match.filter(t => t.test);
|
|
22906
|
+
if (testMatch.length > 0)
|
|
22907
|
+
match = testMatch;
|
|
22908
|
+
}
|
|
22882
22909
|
tagObj =
|
|
22883
22910
|
match.find(t => t.format === item.format) ?? match.find(t => !t.format);
|
|
22884
22911
|
}
|
|
@@ -22887,7 +22914,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22887
22914
|
tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
|
|
22888
22915
|
}
|
|
22889
22916
|
if (!tagObj) {
|
|
22890
|
-
const name = obj?.constructor?.name ?? typeof obj;
|
|
22917
|
+
const name = obj?.constructor?.name ?? (obj === null ? 'null' : typeof obj);
|
|
22891
22918
|
throw new Error(`Tag not resolved for ${name} value`);
|
|
22892
22919
|
}
|
|
22893
22920
|
return tagObj;
|
|
@@ -22902,7 +22929,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22902
22929
|
anchors.add(anchor);
|
|
22903
22930
|
props.push(`&${anchor}`);
|
|
22904
22931
|
}
|
|
22905
|
-
const tag = node.tag
|
|
22932
|
+
const tag = node.tag ?? (tagObj.default ? null : tagObj.tag);
|
|
22906
22933
|
if (tag)
|
|
22907
22934
|
props.push(doc.directives.tagString(tag));
|
|
22908
22935
|
return props.join(' ');
|
|
@@ -22928,8 +22955,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22928
22955
|
const node = isNode(item)
|
|
22929
22956
|
? item
|
|
22930
22957
|
: ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
|
|
22931
|
-
|
|
22932
|
-
tagObj = getTagObject(ctx.doc.schema.tags, node);
|
|
22958
|
+
tagObj ?? (tagObj = getTagObject(ctx.doc.schema.tags, node));
|
|
22933
22959
|
const props = stringifyProps(node, tagObj, ctx);
|
|
22934
22960
|
if (props.length > 0)
|
|
22935
22961
|
ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
|
|
@@ -23091,54 +23117,10 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
23091
23117
|
|
|
23092
23118
|
function warn(logLevel, warning) {
|
|
23093
23119
|
if (logLevel === 'debug' || logLevel === 'warn') {
|
|
23094
|
-
|
|
23095
|
-
process.emitWarning(warning);
|
|
23096
|
-
else
|
|
23097
|
-
console.warn(warning);
|
|
23120
|
+
console.warn(warning);
|
|
23098
23121
|
}
|
|
23099
23122
|
}
|
|
23100
23123
|
|
|
23101
|
-
const MERGE_KEY = '<<';
|
|
23102
|
-
function addPairToJSMap(ctx, map, { key, value }) {
|
|
23103
|
-
if (ctx?.doc.schema.merge && isMergeKey(key)) {
|
|
23104
|
-
value = isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
23105
|
-
if (isSeq(value))
|
|
23106
|
-
for (const it of value.items)
|
|
23107
|
-
mergeToJSMap(ctx, map, it);
|
|
23108
|
-
else if (Array.isArray(value))
|
|
23109
|
-
for (const it of value)
|
|
23110
|
-
mergeToJSMap(ctx, map, it);
|
|
23111
|
-
else
|
|
23112
|
-
mergeToJSMap(ctx, map, value);
|
|
23113
|
-
}
|
|
23114
|
-
else {
|
|
23115
|
-
const jsKey = toJS(key, '', ctx);
|
|
23116
|
-
if (map instanceof Map) {
|
|
23117
|
-
map.set(jsKey, toJS(value, jsKey, ctx));
|
|
23118
|
-
}
|
|
23119
|
-
else if (map instanceof Set) {
|
|
23120
|
-
map.add(jsKey);
|
|
23121
|
-
}
|
|
23122
|
-
else {
|
|
23123
|
-
const stringKey = stringifyKey(key, jsKey, ctx);
|
|
23124
|
-
const jsValue = toJS(value, stringKey, ctx);
|
|
23125
|
-
if (stringKey in map)
|
|
23126
|
-
Object.defineProperty(map, stringKey, {
|
|
23127
|
-
value: jsValue,
|
|
23128
|
-
writable: true,
|
|
23129
|
-
enumerable: true,
|
|
23130
|
-
configurable: true
|
|
23131
|
-
});
|
|
23132
|
-
else
|
|
23133
|
-
map[stringKey] = jsValue;
|
|
23134
|
-
}
|
|
23135
|
-
}
|
|
23136
|
-
return map;
|
|
23137
|
-
}
|
|
23138
|
-
const isMergeKey = (key) => key === MERGE_KEY ||
|
|
23139
|
-
(isScalar$1(key) &&
|
|
23140
|
-
key.value === MERGE_KEY &&
|
|
23141
|
-
(!key.type || key.type === Scalar.PLAIN));
|
|
23142
23124
|
// If the value associated with a merge key is a single mapping node, each of
|
|
23143
23125
|
// its key/value pairs is inserted into the current mapping, unless the key
|
|
23144
23126
|
// already exists in it. If the value associated with the merge key is a
|
|
@@ -23146,7 +23128,35 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
23146
23128
|
// of these nodes is merged in turn according to its order in the sequence.
|
|
23147
23129
|
// Keys in mapping nodes earlier in the sequence override keys specified in
|
|
23148
23130
|
// later mapping nodes. -- http://yaml.org/type/merge.html
|
|
23149
|
-
|
|
23131
|
+
const MERGE_KEY = '<<';
|
|
23132
|
+
const merge = {
|
|
23133
|
+
identify: value => value === MERGE_KEY ||
|
|
23134
|
+
(typeof value === 'symbol' && value.description === MERGE_KEY),
|
|
23135
|
+
default: 'key',
|
|
23136
|
+
tag: 'tag:yaml.org,2002:merge',
|
|
23137
|
+
test: /^<<$/,
|
|
23138
|
+
resolve: () => Object.assign(new Scalar(Symbol(MERGE_KEY)), {
|
|
23139
|
+
addToJSMap: addMergeToJSMap
|
|
23140
|
+
}),
|
|
23141
|
+
stringify: () => MERGE_KEY
|
|
23142
|
+
};
|
|
23143
|
+
const isMergeKey = (ctx, key) => (merge.identify(key) ||
|
|
23144
|
+
(isScalar$1(key) &&
|
|
23145
|
+
(!key.type || key.type === Scalar.PLAIN) &&
|
|
23146
|
+
merge.identify(key.value))) &&
|
|
23147
|
+
ctx?.doc.schema.tags.some(tag => tag.tag === merge.tag && tag.default);
|
|
23148
|
+
function addMergeToJSMap(ctx, map, value) {
|
|
23149
|
+
value = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
23150
|
+
if (isSeq(value))
|
|
23151
|
+
for (const it of value.items)
|
|
23152
|
+
mergeValue(ctx, map, it);
|
|
23153
|
+
else if (Array.isArray(value))
|
|
23154
|
+
for (const it of value)
|
|
23155
|
+
mergeValue(ctx, map, it);
|
|
23156
|
+
else
|
|
23157
|
+
mergeValue(ctx, map, value);
|
|
23158
|
+
}
|
|
23159
|
+
function mergeValue(ctx, map, value) {
|
|
23150
23160
|
const source = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
23151
23161
|
if (!isMap(source))
|
|
23152
23162
|
throw new Error('Merge sources must be maps or map aliases');
|
|
@@ -23170,9 +23180,41 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
23170
23180
|
}
|
|
23171
23181
|
return map;
|
|
23172
23182
|
}
|
|
23183
|
+
|
|
23184
|
+
function addPairToJSMap(ctx, map, { key, value }) {
|
|
23185
|
+
if (isNode(key) && key.addToJSMap)
|
|
23186
|
+
key.addToJSMap(ctx, map, value);
|
|
23187
|
+
// TODO: Should drop this special case for bare << handling
|
|
23188
|
+
else if (isMergeKey(ctx, key))
|
|
23189
|
+
addMergeToJSMap(ctx, map, value);
|
|
23190
|
+
else {
|
|
23191
|
+
const jsKey = toJS(key, '', ctx);
|
|
23192
|
+
if (map instanceof Map) {
|
|
23193
|
+
map.set(jsKey, toJS(value, jsKey, ctx));
|
|
23194
|
+
}
|
|
23195
|
+
else if (map instanceof Set) {
|
|
23196
|
+
map.add(jsKey);
|
|
23197
|
+
}
|
|
23198
|
+
else {
|
|
23199
|
+
const stringKey = stringifyKey(key, jsKey, ctx);
|
|
23200
|
+
const jsValue = toJS(value, stringKey, ctx);
|
|
23201
|
+
if (stringKey in map)
|
|
23202
|
+
Object.defineProperty(map, stringKey, {
|
|
23203
|
+
value: jsValue,
|
|
23204
|
+
writable: true,
|
|
23205
|
+
enumerable: true,
|
|
23206
|
+
configurable: true
|
|
23207
|
+
});
|
|
23208
|
+
else
|
|
23209
|
+
map[stringKey] = jsValue;
|
|
23210
|
+
}
|
|
23211
|
+
}
|
|
23212
|
+
return map;
|
|
23213
|
+
}
|
|
23173
23214
|
function stringifyKey(key, jsKey, ctx) {
|
|
23174
23215
|
if (jsKey === null)
|
|
23175
23216
|
return '';
|
|
23217
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
23176
23218
|
if (typeof jsKey !== 'object')
|
|
23177
23219
|
return String(jsKey);
|
|
23178
23220
|
if (isNode(key) && ctx?.doc) {
|
|
@@ -23805,7 +23847,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
23805
23847
|
identify: value => typeof value === 'boolean',
|
|
23806
23848
|
default: true,
|
|
23807
23849
|
tag: 'tag:yaml.org,2002:bool',
|
|
23808
|
-
test: /^true
|
|
23850
|
+
test: /^true$|^false$/,
|
|
23809
23851
|
resolve: str => str === 'true',
|
|
23810
23852
|
stringify: stringifyJSON
|
|
23811
23853
|
},
|
|
@@ -23850,10 +23892,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
23850
23892
|
* document.querySelector('#photo').src = URL.createObjectURL(blob)
|
|
23851
23893
|
*/
|
|
23852
23894
|
resolve(src, onError) {
|
|
23853
|
-
if (typeof
|
|
23854
|
-
return Buffer.from(src, 'base64');
|
|
23855
|
-
}
|
|
23856
|
-
else if (typeof atob === 'function') {
|
|
23895
|
+
if (typeof atob === 'function') {
|
|
23857
23896
|
// On IE 11, atob() can't handle newlines
|
|
23858
23897
|
const str = atob(src.replace(/[\n\r]/g, ''));
|
|
23859
23898
|
const buffer = new Uint8Array(str.length);
|
|
@@ -23867,15 +23906,11 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
23867
23906
|
}
|
|
23868
23907
|
},
|
|
23869
23908
|
stringify({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
23909
|
+
if (!value)
|
|
23910
|
+
return '';
|
|
23870
23911
|
const buf = value; // checked earlier by binary.identify()
|
|
23871
23912
|
let str;
|
|
23872
|
-
if (typeof
|
|
23873
|
-
str =
|
|
23874
|
-
buf instanceof Buffer
|
|
23875
|
-
? buf.toString('base64')
|
|
23876
|
-
: Buffer.from(buf.buffer).toString('base64');
|
|
23877
|
-
}
|
|
23878
|
-
else if (typeof btoa === 'function') {
|
|
23913
|
+
if (typeof btoa === 'function') {
|
|
23879
23914
|
let s = '';
|
|
23880
23915
|
for (let i = 0; i < buf.length; ++i)
|
|
23881
23916
|
s += String.fromCharCode(buf[i]);
|
|
@@ -23884,8 +23919,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
23884
23919
|
else {
|
|
23885
23920
|
throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
|
|
23886
23921
|
}
|
|
23887
|
-
|
|
23888
|
-
type = Scalar.BLOCK_LITERAL;
|
|
23922
|
+
type ?? (type = Scalar.BLOCK_LITERAL);
|
|
23889
23923
|
if (type !== Scalar.QUOTE_DOUBLE) {
|
|
23890
23924
|
const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
|
|
23891
23925
|
const n = Math.ceil(str.length / lineWidth);
|
|
@@ -24354,7 +24388,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24354
24388
|
}
|
|
24355
24389
|
return new Date(date);
|
|
24356
24390
|
},
|
|
24357
|
-
stringify: ({ value }) => value
|
|
24391
|
+
stringify: ({ value }) => value?.toISOString().replace(/(T00:00:00)?\.000Z$/, '') ?? ''
|
|
24358
24392
|
};
|
|
24359
24393
|
|
|
24360
24394
|
const schema = [
|
|
@@ -24372,6 +24406,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24372
24406
|
floatExp,
|
|
24373
24407
|
float,
|
|
24374
24408
|
binary,
|
|
24409
|
+
merge,
|
|
24375
24410
|
omap,
|
|
24376
24411
|
pairs,
|
|
24377
24412
|
set,
|
|
@@ -24399,6 +24434,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24399
24434
|
intOct: intOct$1,
|
|
24400
24435
|
intTime,
|
|
24401
24436
|
map,
|
|
24437
|
+
merge,
|
|
24402
24438
|
null: nullTag,
|
|
24403
24439
|
omap,
|
|
24404
24440
|
pairs,
|
|
@@ -24408,13 +24444,20 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24408
24444
|
};
|
|
24409
24445
|
const coreKnownTags = {
|
|
24410
24446
|
'tag:yaml.org,2002:binary': binary,
|
|
24447
|
+
'tag:yaml.org,2002:merge': merge,
|
|
24411
24448
|
'tag:yaml.org,2002:omap': omap,
|
|
24412
24449
|
'tag:yaml.org,2002:pairs': pairs,
|
|
24413
24450
|
'tag:yaml.org,2002:set': set,
|
|
24414
24451
|
'tag:yaml.org,2002:timestamp': timestamp
|
|
24415
24452
|
};
|
|
24416
|
-
function getTags(customTags, schemaName) {
|
|
24417
|
-
|
|
24453
|
+
function getTags(customTags, schemaName, addMergeTag) {
|
|
24454
|
+
const schemaTags = schemas.get(schemaName);
|
|
24455
|
+
if (schemaTags && !customTags) {
|
|
24456
|
+
return addMergeTag && !schemaTags.includes(merge)
|
|
24457
|
+
? schemaTags.concat(merge)
|
|
24458
|
+
: schemaTags.slice();
|
|
24459
|
+
}
|
|
24460
|
+
let tags = schemaTags;
|
|
24418
24461
|
if (!tags) {
|
|
24419
24462
|
if (Array.isArray(customTags))
|
|
24420
24463
|
tags = [];
|
|
@@ -24433,17 +24476,21 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24433
24476
|
else if (typeof customTags === 'function') {
|
|
24434
24477
|
tags = customTags(tags.slice());
|
|
24435
24478
|
}
|
|
24436
|
-
|
|
24437
|
-
|
|
24438
|
-
|
|
24439
|
-
const tagObj = tagsByName[tag];
|
|
24440
|
-
if (tagObj)
|
|
24441
|
-
|
|
24442
|
-
|
|
24443
|
-
|
|
24444
|
-
|
|
24445
|
-
|
|
24446
|
-
|
|
24479
|
+
if (addMergeTag)
|
|
24480
|
+
tags = tags.concat(merge);
|
|
24481
|
+
return tags.reduce((tags, tag) => {
|
|
24482
|
+
const tagObj = typeof tag === 'string' ? tagsByName[tag] : tag;
|
|
24483
|
+
if (!tagObj) {
|
|
24484
|
+
const tagName = JSON.stringify(tag);
|
|
24485
|
+
const keys = Object.keys(tagsByName)
|
|
24486
|
+
.map(key => JSON.stringify(key))
|
|
24487
|
+
.join(', ');
|
|
24488
|
+
throw new Error(`Unknown custom tag ${tagName}; use one of ${keys}`);
|
|
24489
|
+
}
|
|
24490
|
+
if (!tags.includes(tagObj))
|
|
24491
|
+
tags.push(tagObj);
|
|
24492
|
+
return tags;
|
|
24493
|
+
}, []);
|
|
24447
24494
|
}
|
|
24448
24495
|
|
|
24449
24496
|
const sortMapEntriesByKey = (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
|
|
@@ -24454,10 +24501,9 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24454
24501
|
: compat
|
|
24455
24502
|
? getTags(null, compat)
|
|
24456
24503
|
: null;
|
|
24457
|
-
this.merge = !!merge;
|
|
24458
24504
|
this.name = (typeof schema === 'string' && schema) || 'core';
|
|
24459
24505
|
this.knownTags = resolveKnownTags ? coreKnownTags : {};
|
|
24460
|
-
this.tags = getTags(customTags, this.name);
|
|
24506
|
+
this.tags = getTags(customTags, this.name, merge);
|
|
24461
24507
|
this.toStringOptions = toStringDefaults ?? null;
|
|
24462
24508
|
Object.defineProperty(this, MAP, { value: map });
|
|
24463
24509
|
Object.defineProperty(this, SCALAR$1, { value: string });
|
|
@@ -24582,6 +24628,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24582
24628
|
logLevel: 'warn',
|
|
24583
24629
|
prettyErrors: true,
|
|
24584
24630
|
strict: true,
|
|
24631
|
+
stringKeys: false,
|
|
24585
24632
|
uniqueKeys: true,
|
|
24586
24633
|
version: '1.2'
|
|
24587
24634
|
}, options);
|
|
@@ -24805,7 +24852,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24805
24852
|
this.directives.yaml.version = '1.1';
|
|
24806
24853
|
else
|
|
24807
24854
|
this.directives = new Directives({ version: '1.1' });
|
|
24808
|
-
opt = {
|
|
24855
|
+
opt = { resolveKnownTags: false, schema: 'yaml-1.1' };
|
|
24809
24856
|
break;
|
|
24810
24857
|
case '1.2':
|
|
24811
24858
|
case 'next':
|
|
@@ -24813,7 +24860,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24813
24860
|
this.directives.yaml.version = version;
|
|
24814
24861
|
else
|
|
24815
24862
|
this.directives = new Directives({ version });
|
|
24816
|
-
opt = {
|
|
24863
|
+
opt = { resolveKnownTags: true, schema: 'core' };
|
|
24817
24864
|
break;
|
|
24818
24865
|
case null:
|
|
24819
24866
|
if (this.directives)
|
|
@@ -24991,7 +25038,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24991
25038
|
if (atNewline) {
|
|
24992
25039
|
if (comment)
|
|
24993
25040
|
comment += token.source;
|
|
24994
|
-
else
|
|
25041
|
+
else if (!found || indicator !== 'seq-item-ind')
|
|
24995
25042
|
spaceBefore = true;
|
|
24996
25043
|
}
|
|
24997
25044
|
else
|
|
@@ -25008,8 +25055,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25008
25055
|
if (token.source.endsWith(':'))
|
|
25009
25056
|
onError(token.offset + token.source.length - 1, 'BAD_ALIAS', 'Anchor ending in : is ambiguous', true);
|
|
25010
25057
|
anchor = token;
|
|
25011
|
-
|
|
25012
|
-
start = token.offset;
|
|
25058
|
+
start ?? (start = token.offset);
|
|
25013
25059
|
atNewline = false;
|
|
25014
25060
|
hasSpace = false;
|
|
25015
25061
|
reqSpace = true;
|
|
@@ -25018,8 +25064,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25018
25064
|
if (tag)
|
|
25019
25065
|
onError(token, 'MULTIPLE_TAGS', 'A node can have at most one tag');
|
|
25020
25066
|
tag = token;
|
|
25021
|
-
|
|
25022
|
-
start = token.offset;
|
|
25067
|
+
start ?? (start = token.offset);
|
|
25023
25068
|
atNewline = false;
|
|
25024
25069
|
hasSpace = false;
|
|
25025
25070
|
reqSpace = true;
|
|
@@ -25132,11 +25177,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25132
25177
|
return false;
|
|
25133
25178
|
const isEqual = typeof uniqueKeys === 'function'
|
|
25134
25179
|
? uniqueKeys
|
|
25135
|
-
: (a, b) => a === b ||
|
|
25136
|
-
(isScalar$1(a) &&
|
|
25137
|
-
isScalar$1(b) &&
|
|
25138
|
-
a.value === b.value &&
|
|
25139
|
-
!(a.value === '<<' && ctx.schema.merge));
|
|
25180
|
+
: (a, b) => a === b || (isScalar$1(a) && isScalar$1(b) && a.value === b.value);
|
|
25140
25181
|
return items.some(pair => isEqual(pair.key, search));
|
|
25141
25182
|
}
|
|
25142
25183
|
|
|
@@ -25185,12 +25226,14 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25185
25226
|
onError(offset, 'BAD_INDENT', startColMsg);
|
|
25186
25227
|
}
|
|
25187
25228
|
// key value
|
|
25229
|
+
ctx.atKey = true;
|
|
25188
25230
|
const keyStart = keyProps.end;
|
|
25189
25231
|
const keyNode = key
|
|
25190
25232
|
? composeNode(ctx, key, keyProps, onError)
|
|
25191
25233
|
: composeEmptyNode(ctx, keyStart, start, null, keyProps, onError);
|
|
25192
25234
|
if (ctx.schema.compat)
|
|
25193
25235
|
flowIndentCheck(bm.indent, key, onError);
|
|
25236
|
+
ctx.atKey = false;
|
|
25194
25237
|
if (mapIncludes(ctx, map.items, keyNode))
|
|
25195
25238
|
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
|
|
25196
25239
|
// value properties
|
|
@@ -25250,6 +25293,8 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25250
25293
|
const seq = new NodeClass(ctx.schema);
|
|
25251
25294
|
if (ctx.atRoot)
|
|
25252
25295
|
ctx.atRoot = false;
|
|
25296
|
+
if (ctx.atKey)
|
|
25297
|
+
ctx.atKey = false;
|
|
25253
25298
|
let offset = bs.offset;
|
|
25254
25299
|
let commentEnd = null;
|
|
25255
25300
|
for (const { start, value } of bs.items) {
|
|
@@ -25334,6 +25379,8 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25334
25379
|
const atRoot = ctx.atRoot;
|
|
25335
25380
|
if (atRoot)
|
|
25336
25381
|
ctx.atRoot = false;
|
|
25382
|
+
if (ctx.atKey)
|
|
25383
|
+
ctx.atKey = false;
|
|
25337
25384
|
let offset = fc.offset + fc.start.source.length;
|
|
25338
25385
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
25339
25386
|
const collItem = fc.items[i];
|
|
@@ -25413,12 +25460,14 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25413
25460
|
else {
|
|
25414
25461
|
// item is a key+value pair
|
|
25415
25462
|
// key value
|
|
25463
|
+
ctx.atKey = true;
|
|
25416
25464
|
const keyStart = props.end;
|
|
25417
25465
|
const keyNode = key
|
|
25418
25466
|
? composeNode(ctx, key, props, onError)
|
|
25419
25467
|
: composeEmptyNode(ctx, keyStart, start, null, props, onError);
|
|
25420
25468
|
if (isBlock(key))
|
|
25421
25469
|
onError(keyNode.range, 'BLOCK_IN_FLOW', blockMsg);
|
|
25470
|
+
ctx.atKey = false;
|
|
25422
25471
|
// value properties
|
|
25423
25472
|
const valueProps = resolveProps(sep ?? [], {
|
|
25424
25473
|
flow: fcName,
|
|
@@ -25574,8 +25623,8 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25574
25623
|
tag = kt;
|
|
25575
25624
|
}
|
|
25576
25625
|
else {
|
|
25577
|
-
if (kt
|
|
25578
|
-
onError(tagToken, 'BAD_COLLECTION_TYPE', `${kt.tag} used for ${expType} collection, but expects ${kt.collection}`, true);
|
|
25626
|
+
if (kt) {
|
|
25627
|
+
onError(tagToken, 'BAD_COLLECTION_TYPE', `${kt.tag} used for ${expType} collection, but expects ${kt.collection ?? 'scalar'}`, true);
|
|
25579
25628
|
}
|
|
25580
25629
|
else {
|
|
25581
25630
|
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, true);
|
|
@@ -26016,11 +26065,16 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26016
26065
|
const tagName = tagToken
|
|
26017
26066
|
? ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg))
|
|
26018
26067
|
: null;
|
|
26019
|
-
|
|
26020
|
-
|
|
26021
|
-
|
|
26022
|
-
|
|
26023
|
-
|
|
26068
|
+
let tag;
|
|
26069
|
+
if (ctx.options.stringKeys && ctx.atKey) {
|
|
26070
|
+
tag = ctx.schema[SCALAR$1];
|
|
26071
|
+
}
|
|
26072
|
+
else if (tagName)
|
|
26073
|
+
tag = findScalarTagByName(ctx.schema, value, tagName, tagToken, onError);
|
|
26074
|
+
else if (token.type === 'scalar')
|
|
26075
|
+
tag = findScalarTagByTest(ctx, value, token, onError);
|
|
26076
|
+
else
|
|
26077
|
+
tag = ctx.schema[SCALAR$1];
|
|
26024
26078
|
let scalar;
|
|
26025
26079
|
try {
|
|
26026
26080
|
const res = tag.resolve(value, msg => onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg), ctx.options);
|
|
@@ -26068,8 +26122,9 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26068
26122
|
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, tagName !== 'tag:yaml.org,2002:str');
|
|
26069
26123
|
return schema[SCALAR$1];
|
|
26070
26124
|
}
|
|
26071
|
-
function findScalarTagByTest({ directives, schema }, value, token, onError) {
|
|
26072
|
-
const tag = schema.tags.find(tag => tag.default && tag.
|
|
26125
|
+
function findScalarTagByTest({ atKey, directives, schema }, value, token, onError) {
|
|
26126
|
+
const tag = schema.tags.find(tag => (tag.default === true || (atKey && tag.default === 'key')) &&
|
|
26127
|
+
tag.test?.test(value)) || schema[SCALAR$1];
|
|
26073
26128
|
if (schema.compat) {
|
|
26074
26129
|
const compat = schema.compat.find(tag => tag.default && tag.test?.test(value)) ??
|
|
26075
26130
|
schema[SCALAR$1];
|
|
@@ -26085,8 +26140,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26085
26140
|
|
|
26086
26141
|
function emptyScalarPosition(offset, before, pos) {
|
|
26087
26142
|
if (before) {
|
|
26088
|
-
|
|
26089
|
-
pos = before.length;
|
|
26143
|
+
pos ?? (pos = before.length);
|
|
26090
26144
|
for (let i = pos - 1; i >= 0; --i) {
|
|
26091
26145
|
let st = before[i];
|
|
26092
26146
|
switch (st.type) {
|
|
@@ -26111,6 +26165,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26111
26165
|
|
|
26112
26166
|
const CN = { composeNode, composeEmptyNode };
|
|
26113
26167
|
function composeNode(ctx, token, props, onError) {
|
|
26168
|
+
const atKey = ctx.atKey;
|
|
26114
26169
|
const { spaceBefore, comment, anchor, tag } = props;
|
|
26115
26170
|
let node;
|
|
26116
26171
|
let isSrcToken = true;
|
|
@@ -26146,6 +26201,14 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26146
26201
|
}
|
|
26147
26202
|
if (anchor && node.anchor === '')
|
|
26148
26203
|
onError(anchor, 'BAD_ALIAS', 'Anchor cannot be an empty string');
|
|
26204
|
+
if (atKey &&
|
|
26205
|
+
ctx.options.stringKeys &&
|
|
26206
|
+
(!isScalar$1(node) ||
|
|
26207
|
+
typeof node.value !== 'string' ||
|
|
26208
|
+
(node.tag && node.tag !== 'tag:yaml.org,2002:str'))) {
|
|
26209
|
+
const msg = 'With stringKeys, all keys must be strings';
|
|
26210
|
+
onError(tag ?? token, 'NON_STRING_KEY', msg);
|
|
26211
|
+
}
|
|
26149
26212
|
if (spaceBefore)
|
|
26150
26213
|
node.spaceBefore = true;
|
|
26151
26214
|
if (comment) {
|
|
@@ -26198,6 +26261,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26198
26261
|
const opts = Object.assign({ _directives: directives }, options);
|
|
26199
26262
|
const doc = new Document(undefined, opts);
|
|
26200
26263
|
const ctx = {
|
|
26264
|
+
atKey: false,
|
|
26201
26265
|
atRoot: true,
|
|
26202
26266
|
directives: doc.directives,
|
|
26203
26267
|
options: doc.options,
|
|
@@ -28332,7 +28396,20 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28332
28396
|
default: {
|
|
28333
28397
|
const bv = this.startBlockValue(map);
|
|
28334
28398
|
if (bv) {
|
|
28335
|
-
if (
|
|
28399
|
+
if (bv.type === 'block-seq') {
|
|
28400
|
+
if (!it.explicitKey &&
|
|
28401
|
+
it.sep &&
|
|
28402
|
+
!includesToken(it.sep, 'newline')) {
|
|
28403
|
+
yield* this.pop({
|
|
28404
|
+
type: 'error',
|
|
28405
|
+
offset: this.offset,
|
|
28406
|
+
message: 'Unexpected block-seq-ind on same line with key',
|
|
28407
|
+
source: this.source
|
|
28408
|
+
});
|
|
28409
|
+
return;
|
|
28410
|
+
}
|
|
28411
|
+
}
|
|
28412
|
+
else if (atMapIndent) {
|
|
28336
28413
|
map.items.push({ start });
|
|
28337
28414
|
}
|
|
28338
28415
|
this.stack.push(bv);
|
|
@@ -28703,6 +28780,8 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28703
28780
|
if (!keepUndefined)
|
|
28704
28781
|
return undefined;
|
|
28705
28782
|
}
|
|
28783
|
+
if (isDocument(value) && !_replacer)
|
|
28784
|
+
return value.toString(options);
|
|
28706
28785
|
return new Document(value, _replacer, options).toString(options);
|
|
28707
28786
|
}
|
|
28708
28787
|
|