@thoughtspot/visual-embed-sdk 1.42.1-alpha.3 → 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/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-DhFH7b7U.js +7447 -0
- 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 +3 -3
- package/dist/tsembed-react.js +223 -147
- package/dist/tsembed.es.js +3 -3
- package/dist/tsembed.js +223 -147
- package/lib/package.json +1 -2
- 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/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.
|
|
@@ -21852,8 +21852,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
21852
21852
|
return {
|
|
21853
21853
|
onAnchor: (source) => {
|
|
21854
21854
|
aliasObjects.push(source);
|
|
21855
|
-
|
|
21856
|
-
prevAnchors = anchorNames(doc);
|
|
21855
|
+
prevAnchors ?? (prevAnchors = anchorNames(doc));
|
|
21857
21856
|
const anchor = findNewAnchor(prefix, prevAnchors);
|
|
21858
21857
|
prevAnchors.add(anchor);
|
|
21859
21858
|
return anchor;
|
|
@@ -22017,23 +22016,36 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22017
22016
|
* Resolve the value of this alias within `doc`, finding the last
|
|
22018
22017
|
* instance of the `source` anchor before this node.
|
|
22019
22018
|
*/
|
|
22020
|
-
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
|
+
}
|
|
22021
22035
|
let found = undefined;
|
|
22022
|
-
|
|
22023
|
-
|
|
22024
|
-
|
|
22025
|
-
|
|
22026
|
-
|
|
22027
|
-
|
|
22028
|
-
}
|
|
22029
|
-
});
|
|
22036
|
+
for (const node of nodes) {
|
|
22037
|
+
if (node === this)
|
|
22038
|
+
break;
|
|
22039
|
+
if (node.anchor === this.source)
|
|
22040
|
+
found = node;
|
|
22041
|
+
}
|
|
22030
22042
|
return found;
|
|
22031
22043
|
}
|
|
22032
22044
|
toJSON(_arg, ctx) {
|
|
22033
22045
|
if (!ctx)
|
|
22034
22046
|
return { source: this.source };
|
|
22035
22047
|
const { anchors, doc, maxAliasCount } = ctx;
|
|
22036
|
-
const source = this.resolve(doc);
|
|
22048
|
+
const source = this.resolve(doc, ctx);
|
|
22037
22049
|
if (!source) {
|
|
22038
22050
|
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
22039
22051
|
throw new ReferenceError(msg);
|
|
@@ -22152,8 +22164,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22152
22164
|
if (aliasDuplicateObjects && value && typeof value === 'object') {
|
|
22153
22165
|
ref = sourceObjects.get(value);
|
|
22154
22166
|
if (ref) {
|
|
22155
|
-
|
|
22156
|
-
ref.anchor = onAnchor(value);
|
|
22167
|
+
ref.anchor ?? (ref.anchor = onAnchor(value));
|
|
22157
22168
|
return new Alias(ref.anchor);
|
|
22158
22169
|
}
|
|
22159
22170
|
else {
|
|
@@ -22664,7 +22675,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22664
22675
|
const { blockQuote, commentString, lineWidth } = ctx.options;
|
|
22665
22676
|
// 1. Block can't end in whitespace unless the last line is non-empty.
|
|
22666
22677
|
// 2. Strings consisting of only whitespace are best rendered explicitly.
|
|
22667
|
-
if (!blockQuote || /\n[\t ]+$/.test(value)
|
|
22678
|
+
if (!blockQuote || /\n[\t ]+$/.test(value)) {
|
|
22668
22679
|
return quotedString(value, ctx);
|
|
22669
22680
|
}
|
|
22670
22681
|
const indent = ctx.indent ||
|
|
@@ -22724,23 +22735,32 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22724
22735
|
start = start.replace(/\n+/g, `$&${indent}`);
|
|
22725
22736
|
}
|
|
22726
22737
|
const indentSize = indent ? '2' : '1'; // root is at -1
|
|
22727
|
-
|
|
22738
|
+
// Leading | or > is added later
|
|
22739
|
+
let header = (startWithSpace ? indentSize : '') + chomp;
|
|
22728
22740
|
if (comment) {
|
|
22729
22741
|
header += ' ' + commentString(comment.replace(/ ?[\r\n]+/g, ' '));
|
|
22730
22742
|
if (onComment)
|
|
22731
22743
|
onComment();
|
|
22732
22744
|
}
|
|
22733
|
-
if (literal) {
|
|
22734
|
-
|
|
22735
|
-
|
|
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}`;
|
|
22736
22761
|
}
|
|
22737
|
-
value = value
|
|
22738
|
-
|
|
22739
|
-
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
|
|
22740
|
-
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
|
|
22741
|
-
.replace(/\n+/g, `$&${indent}`);
|
|
22742
|
-
const body = foldFlowLines(`${start}${value}${end}`, indent, FOLD_BLOCK, getFoldOptions(ctx, true));
|
|
22743
|
-
return `${header}\n${indent}${body}`;
|
|
22762
|
+
value = value.replace(/\n+/g, `$&${indent}`);
|
|
22763
|
+
return `|${header}\n${indent}${start}${value}${end}`;
|
|
22744
22764
|
}
|
|
22745
22765
|
function plainString(item, ctx, onComment, onChompKeep) {
|
|
22746
22766
|
const { type, value } = item;
|
|
@@ -22749,10 +22769,9 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22749
22769
|
(inFlow && /[[\]{},]/.test(value))) {
|
|
22750
22770
|
return quotedString(value, ctx);
|
|
22751
22771
|
}
|
|
22752
|
-
if (
|
|
22753
|
-
/^[\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)) {
|
|
22754
22773
|
// not allowed:
|
|
22755
|
-
// -
|
|
22774
|
+
// - '-' or '?'
|
|
22756
22775
|
// - start with an indicator character (except [?:-]) or /[?-] /
|
|
22757
22776
|
// - '\n ', ': ' or ' \n' anywhere
|
|
22758
22777
|
// - '#' not preceded by a non-space char
|
|
@@ -22881,7 +22900,12 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22881
22900
|
let obj;
|
|
22882
22901
|
if (isScalar$1(item)) {
|
|
22883
22902
|
obj = item.value;
|
|
22884
|
-
|
|
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
|
+
}
|
|
22885
22909
|
tagObj =
|
|
22886
22910
|
match.find(t => t.format === item.format) ?? match.find(t => !t.format);
|
|
22887
22911
|
}
|
|
@@ -22890,7 +22914,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22890
22914
|
tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
|
|
22891
22915
|
}
|
|
22892
22916
|
if (!tagObj) {
|
|
22893
|
-
const name = obj?.constructor?.name ?? typeof obj;
|
|
22917
|
+
const name = obj?.constructor?.name ?? (obj === null ? 'null' : typeof obj);
|
|
22894
22918
|
throw new Error(`Tag not resolved for ${name} value`);
|
|
22895
22919
|
}
|
|
22896
22920
|
return tagObj;
|
|
@@ -22905,7 +22929,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22905
22929
|
anchors.add(anchor);
|
|
22906
22930
|
props.push(`&${anchor}`);
|
|
22907
22931
|
}
|
|
22908
|
-
const tag = node.tag
|
|
22932
|
+
const tag = node.tag ?? (tagObj.default ? null : tagObj.tag);
|
|
22909
22933
|
if (tag)
|
|
22910
22934
|
props.push(doc.directives.tagString(tag));
|
|
22911
22935
|
return props.join(' ');
|
|
@@ -22931,8 +22955,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
22931
22955
|
const node = isNode(item)
|
|
22932
22956
|
? item
|
|
22933
22957
|
: ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
|
|
22934
|
-
|
|
22935
|
-
tagObj = getTagObject(ctx.doc.schema.tags, node);
|
|
22958
|
+
tagObj ?? (tagObj = getTagObject(ctx.doc.schema.tags, node));
|
|
22936
22959
|
const props = stringifyProps(node, tagObj, ctx);
|
|
22937
22960
|
if (props.length > 0)
|
|
22938
22961
|
ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
|
|
@@ -23094,54 +23117,10 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
23094
23117
|
|
|
23095
23118
|
function warn(logLevel, warning) {
|
|
23096
23119
|
if (logLevel === 'debug' || logLevel === 'warn') {
|
|
23097
|
-
|
|
23098
|
-
process.emitWarning(warning);
|
|
23099
|
-
else
|
|
23100
|
-
console.warn(warning);
|
|
23120
|
+
console.warn(warning);
|
|
23101
23121
|
}
|
|
23102
23122
|
}
|
|
23103
23123
|
|
|
23104
|
-
const MERGE_KEY = '<<';
|
|
23105
|
-
function addPairToJSMap(ctx, map, { key, value }) {
|
|
23106
|
-
if (ctx?.doc.schema.merge && isMergeKey(key)) {
|
|
23107
|
-
value = isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
23108
|
-
if (isSeq(value))
|
|
23109
|
-
for (const it of value.items)
|
|
23110
|
-
mergeToJSMap(ctx, map, it);
|
|
23111
|
-
else if (Array.isArray(value))
|
|
23112
|
-
for (const it of value)
|
|
23113
|
-
mergeToJSMap(ctx, map, it);
|
|
23114
|
-
else
|
|
23115
|
-
mergeToJSMap(ctx, map, value);
|
|
23116
|
-
}
|
|
23117
|
-
else {
|
|
23118
|
-
const jsKey = toJS(key, '', ctx);
|
|
23119
|
-
if (map instanceof Map) {
|
|
23120
|
-
map.set(jsKey, toJS(value, jsKey, ctx));
|
|
23121
|
-
}
|
|
23122
|
-
else if (map instanceof Set) {
|
|
23123
|
-
map.add(jsKey);
|
|
23124
|
-
}
|
|
23125
|
-
else {
|
|
23126
|
-
const stringKey = stringifyKey(key, jsKey, ctx);
|
|
23127
|
-
const jsValue = toJS(value, stringKey, ctx);
|
|
23128
|
-
if (stringKey in map)
|
|
23129
|
-
Object.defineProperty(map, stringKey, {
|
|
23130
|
-
value: jsValue,
|
|
23131
|
-
writable: true,
|
|
23132
|
-
enumerable: true,
|
|
23133
|
-
configurable: true
|
|
23134
|
-
});
|
|
23135
|
-
else
|
|
23136
|
-
map[stringKey] = jsValue;
|
|
23137
|
-
}
|
|
23138
|
-
}
|
|
23139
|
-
return map;
|
|
23140
|
-
}
|
|
23141
|
-
const isMergeKey = (key) => key === MERGE_KEY ||
|
|
23142
|
-
(isScalar$1(key) &&
|
|
23143
|
-
key.value === MERGE_KEY &&
|
|
23144
|
-
(!key.type || key.type === Scalar.PLAIN));
|
|
23145
23124
|
// If the value associated with a merge key is a single mapping node, each of
|
|
23146
23125
|
// its key/value pairs is inserted into the current mapping, unless the key
|
|
23147
23126
|
// already exists in it. If the value associated with the merge key is a
|
|
@@ -23149,7 +23128,35 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
23149
23128
|
// of these nodes is merged in turn according to its order in the sequence.
|
|
23150
23129
|
// Keys in mapping nodes earlier in the sequence override keys specified in
|
|
23151
23130
|
// later mapping nodes. -- http://yaml.org/type/merge.html
|
|
23152
|
-
|
|
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) {
|
|
23153
23160
|
const source = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
23154
23161
|
if (!isMap(source))
|
|
23155
23162
|
throw new Error('Merge sources must be maps or map aliases');
|
|
@@ -23173,9 +23180,41 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
23173
23180
|
}
|
|
23174
23181
|
return map;
|
|
23175
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
|
+
}
|
|
23176
23214
|
function stringifyKey(key, jsKey, ctx) {
|
|
23177
23215
|
if (jsKey === null)
|
|
23178
23216
|
return '';
|
|
23217
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
23179
23218
|
if (typeof jsKey !== 'object')
|
|
23180
23219
|
return String(jsKey);
|
|
23181
23220
|
if (isNode(key) && ctx?.doc) {
|
|
@@ -23808,7 +23847,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
23808
23847
|
identify: value => typeof value === 'boolean',
|
|
23809
23848
|
default: true,
|
|
23810
23849
|
tag: 'tag:yaml.org,2002:bool',
|
|
23811
|
-
test: /^true
|
|
23850
|
+
test: /^true$|^false$/,
|
|
23812
23851
|
resolve: str => str === 'true',
|
|
23813
23852
|
stringify: stringifyJSON
|
|
23814
23853
|
},
|
|
@@ -23853,10 +23892,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
23853
23892
|
* document.querySelector('#photo').src = URL.createObjectURL(blob)
|
|
23854
23893
|
*/
|
|
23855
23894
|
resolve(src, onError) {
|
|
23856
|
-
if (typeof
|
|
23857
|
-
return Buffer.from(src, 'base64');
|
|
23858
|
-
}
|
|
23859
|
-
else if (typeof atob === 'function') {
|
|
23895
|
+
if (typeof atob === 'function') {
|
|
23860
23896
|
// On IE 11, atob() can't handle newlines
|
|
23861
23897
|
const str = atob(src.replace(/[\n\r]/g, ''));
|
|
23862
23898
|
const buffer = new Uint8Array(str.length);
|
|
@@ -23870,15 +23906,11 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
23870
23906
|
}
|
|
23871
23907
|
},
|
|
23872
23908
|
stringify({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
23909
|
+
if (!value)
|
|
23910
|
+
return '';
|
|
23873
23911
|
const buf = value; // checked earlier by binary.identify()
|
|
23874
23912
|
let str;
|
|
23875
|
-
if (typeof
|
|
23876
|
-
str =
|
|
23877
|
-
buf instanceof Buffer
|
|
23878
|
-
? buf.toString('base64')
|
|
23879
|
-
: Buffer.from(buf.buffer).toString('base64');
|
|
23880
|
-
}
|
|
23881
|
-
else if (typeof btoa === 'function') {
|
|
23913
|
+
if (typeof btoa === 'function') {
|
|
23882
23914
|
let s = '';
|
|
23883
23915
|
for (let i = 0; i < buf.length; ++i)
|
|
23884
23916
|
s += String.fromCharCode(buf[i]);
|
|
@@ -23887,8 +23919,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
23887
23919
|
else {
|
|
23888
23920
|
throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
|
|
23889
23921
|
}
|
|
23890
|
-
|
|
23891
|
-
type = Scalar.BLOCK_LITERAL;
|
|
23922
|
+
type ?? (type = Scalar.BLOCK_LITERAL);
|
|
23892
23923
|
if (type !== Scalar.QUOTE_DOUBLE) {
|
|
23893
23924
|
const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
|
|
23894
23925
|
const n = Math.ceil(str.length / lineWidth);
|
|
@@ -24357,7 +24388,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24357
24388
|
}
|
|
24358
24389
|
return new Date(date);
|
|
24359
24390
|
},
|
|
24360
|
-
stringify: ({ value }) => value
|
|
24391
|
+
stringify: ({ value }) => value?.toISOString().replace(/(T00:00:00)?\.000Z$/, '') ?? ''
|
|
24361
24392
|
};
|
|
24362
24393
|
|
|
24363
24394
|
const schema = [
|
|
@@ -24375,6 +24406,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24375
24406
|
floatExp,
|
|
24376
24407
|
float,
|
|
24377
24408
|
binary,
|
|
24409
|
+
merge,
|
|
24378
24410
|
omap,
|
|
24379
24411
|
pairs,
|
|
24380
24412
|
set,
|
|
@@ -24402,6 +24434,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24402
24434
|
intOct: intOct$1,
|
|
24403
24435
|
intTime,
|
|
24404
24436
|
map,
|
|
24437
|
+
merge,
|
|
24405
24438
|
null: nullTag,
|
|
24406
24439
|
omap,
|
|
24407
24440
|
pairs,
|
|
@@ -24411,13 +24444,20 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24411
24444
|
};
|
|
24412
24445
|
const coreKnownTags = {
|
|
24413
24446
|
'tag:yaml.org,2002:binary': binary,
|
|
24447
|
+
'tag:yaml.org,2002:merge': merge,
|
|
24414
24448
|
'tag:yaml.org,2002:omap': omap,
|
|
24415
24449
|
'tag:yaml.org,2002:pairs': pairs,
|
|
24416
24450
|
'tag:yaml.org,2002:set': set,
|
|
24417
24451
|
'tag:yaml.org,2002:timestamp': timestamp
|
|
24418
24452
|
};
|
|
24419
|
-
function getTags(customTags, schemaName) {
|
|
24420
|
-
|
|
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;
|
|
24421
24461
|
if (!tags) {
|
|
24422
24462
|
if (Array.isArray(customTags))
|
|
24423
24463
|
tags = [];
|
|
@@ -24436,17 +24476,21 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24436
24476
|
else if (typeof customTags === 'function') {
|
|
24437
24477
|
tags = customTags(tags.slice());
|
|
24438
24478
|
}
|
|
24439
|
-
|
|
24440
|
-
|
|
24441
|
-
|
|
24442
|
-
const tagObj = tagsByName[tag];
|
|
24443
|
-
if (tagObj)
|
|
24444
|
-
|
|
24445
|
-
|
|
24446
|
-
|
|
24447
|
-
|
|
24448
|
-
|
|
24449
|
-
|
|
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
|
+
}, []);
|
|
24450
24494
|
}
|
|
24451
24495
|
|
|
24452
24496
|
const sortMapEntriesByKey = (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
|
|
@@ -24457,10 +24501,9 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24457
24501
|
: compat
|
|
24458
24502
|
? getTags(null, compat)
|
|
24459
24503
|
: null;
|
|
24460
|
-
this.merge = !!merge;
|
|
24461
24504
|
this.name = (typeof schema === 'string' && schema) || 'core';
|
|
24462
24505
|
this.knownTags = resolveKnownTags ? coreKnownTags : {};
|
|
24463
|
-
this.tags = getTags(customTags, this.name);
|
|
24506
|
+
this.tags = getTags(customTags, this.name, merge);
|
|
24464
24507
|
this.toStringOptions = toStringDefaults ?? null;
|
|
24465
24508
|
Object.defineProperty(this, MAP, { value: map });
|
|
24466
24509
|
Object.defineProperty(this, SCALAR$1, { value: string });
|
|
@@ -24585,6 +24628,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24585
24628
|
logLevel: 'warn',
|
|
24586
24629
|
prettyErrors: true,
|
|
24587
24630
|
strict: true,
|
|
24631
|
+
stringKeys: false,
|
|
24588
24632
|
uniqueKeys: true,
|
|
24589
24633
|
version: '1.2'
|
|
24590
24634
|
}, options);
|
|
@@ -24808,7 +24852,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24808
24852
|
this.directives.yaml.version = '1.1';
|
|
24809
24853
|
else
|
|
24810
24854
|
this.directives = new Directives({ version: '1.1' });
|
|
24811
|
-
opt = {
|
|
24855
|
+
opt = { resolveKnownTags: false, schema: 'yaml-1.1' };
|
|
24812
24856
|
break;
|
|
24813
24857
|
case '1.2':
|
|
24814
24858
|
case 'next':
|
|
@@ -24816,7 +24860,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24816
24860
|
this.directives.yaml.version = version;
|
|
24817
24861
|
else
|
|
24818
24862
|
this.directives = new Directives({ version });
|
|
24819
|
-
opt = {
|
|
24863
|
+
opt = { resolveKnownTags: true, schema: 'core' };
|
|
24820
24864
|
break;
|
|
24821
24865
|
case null:
|
|
24822
24866
|
if (this.directives)
|
|
@@ -24994,7 +25038,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
24994
25038
|
if (atNewline) {
|
|
24995
25039
|
if (comment)
|
|
24996
25040
|
comment += token.source;
|
|
24997
|
-
else
|
|
25041
|
+
else if (!found || indicator !== 'seq-item-ind')
|
|
24998
25042
|
spaceBefore = true;
|
|
24999
25043
|
}
|
|
25000
25044
|
else
|
|
@@ -25011,8 +25055,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25011
25055
|
if (token.source.endsWith(':'))
|
|
25012
25056
|
onError(token.offset + token.source.length - 1, 'BAD_ALIAS', 'Anchor ending in : is ambiguous', true);
|
|
25013
25057
|
anchor = token;
|
|
25014
|
-
|
|
25015
|
-
start = token.offset;
|
|
25058
|
+
start ?? (start = token.offset);
|
|
25016
25059
|
atNewline = false;
|
|
25017
25060
|
hasSpace = false;
|
|
25018
25061
|
reqSpace = true;
|
|
@@ -25021,8 +25064,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25021
25064
|
if (tag)
|
|
25022
25065
|
onError(token, 'MULTIPLE_TAGS', 'A node can have at most one tag');
|
|
25023
25066
|
tag = token;
|
|
25024
|
-
|
|
25025
|
-
start = token.offset;
|
|
25067
|
+
start ?? (start = token.offset);
|
|
25026
25068
|
atNewline = false;
|
|
25027
25069
|
hasSpace = false;
|
|
25028
25070
|
reqSpace = true;
|
|
@@ -25135,11 +25177,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25135
25177
|
return false;
|
|
25136
25178
|
const isEqual = typeof uniqueKeys === 'function'
|
|
25137
25179
|
? uniqueKeys
|
|
25138
|
-
: (a, b) => a === b ||
|
|
25139
|
-
(isScalar$1(a) &&
|
|
25140
|
-
isScalar$1(b) &&
|
|
25141
|
-
a.value === b.value &&
|
|
25142
|
-
!(a.value === '<<' && ctx.schema.merge));
|
|
25180
|
+
: (a, b) => a === b || (isScalar$1(a) && isScalar$1(b) && a.value === b.value);
|
|
25143
25181
|
return items.some(pair => isEqual(pair.key, search));
|
|
25144
25182
|
}
|
|
25145
25183
|
|
|
@@ -25188,12 +25226,14 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25188
25226
|
onError(offset, 'BAD_INDENT', startColMsg);
|
|
25189
25227
|
}
|
|
25190
25228
|
// key value
|
|
25229
|
+
ctx.atKey = true;
|
|
25191
25230
|
const keyStart = keyProps.end;
|
|
25192
25231
|
const keyNode = key
|
|
25193
25232
|
? composeNode(ctx, key, keyProps, onError)
|
|
25194
25233
|
: composeEmptyNode(ctx, keyStart, start, null, keyProps, onError);
|
|
25195
25234
|
if (ctx.schema.compat)
|
|
25196
25235
|
flowIndentCheck(bm.indent, key, onError);
|
|
25236
|
+
ctx.atKey = false;
|
|
25197
25237
|
if (mapIncludes(ctx, map.items, keyNode))
|
|
25198
25238
|
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
|
|
25199
25239
|
// value properties
|
|
@@ -25253,6 +25293,8 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25253
25293
|
const seq = new NodeClass(ctx.schema);
|
|
25254
25294
|
if (ctx.atRoot)
|
|
25255
25295
|
ctx.atRoot = false;
|
|
25296
|
+
if (ctx.atKey)
|
|
25297
|
+
ctx.atKey = false;
|
|
25256
25298
|
let offset = bs.offset;
|
|
25257
25299
|
let commentEnd = null;
|
|
25258
25300
|
for (const { start, value } of bs.items) {
|
|
@@ -25337,6 +25379,8 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25337
25379
|
const atRoot = ctx.atRoot;
|
|
25338
25380
|
if (atRoot)
|
|
25339
25381
|
ctx.atRoot = false;
|
|
25382
|
+
if (ctx.atKey)
|
|
25383
|
+
ctx.atKey = false;
|
|
25340
25384
|
let offset = fc.offset + fc.start.source.length;
|
|
25341
25385
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
25342
25386
|
const collItem = fc.items[i];
|
|
@@ -25416,12 +25460,14 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25416
25460
|
else {
|
|
25417
25461
|
// item is a key+value pair
|
|
25418
25462
|
// key value
|
|
25463
|
+
ctx.atKey = true;
|
|
25419
25464
|
const keyStart = props.end;
|
|
25420
25465
|
const keyNode = key
|
|
25421
25466
|
? composeNode(ctx, key, props, onError)
|
|
25422
25467
|
: composeEmptyNode(ctx, keyStart, start, null, props, onError);
|
|
25423
25468
|
if (isBlock(key))
|
|
25424
25469
|
onError(keyNode.range, 'BLOCK_IN_FLOW', blockMsg);
|
|
25470
|
+
ctx.atKey = false;
|
|
25425
25471
|
// value properties
|
|
25426
25472
|
const valueProps = resolveProps(sep ?? [], {
|
|
25427
25473
|
flow: fcName,
|
|
@@ -25577,8 +25623,8 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
25577
25623
|
tag = kt;
|
|
25578
25624
|
}
|
|
25579
25625
|
else {
|
|
25580
|
-
if (kt
|
|
25581
|
-
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);
|
|
25582
25628
|
}
|
|
25583
25629
|
else {
|
|
25584
25630
|
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, true);
|
|
@@ -26019,11 +26065,16 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26019
26065
|
const tagName = tagToken
|
|
26020
26066
|
? ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg))
|
|
26021
26067
|
: null;
|
|
26022
|
-
|
|
26023
|
-
|
|
26024
|
-
|
|
26025
|
-
|
|
26026
|
-
|
|
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];
|
|
26027
26078
|
let scalar;
|
|
26028
26079
|
try {
|
|
26029
26080
|
const res = tag.resolve(value, msg => onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg), ctx.options);
|
|
@@ -26071,8 +26122,9 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26071
26122
|
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, tagName !== 'tag:yaml.org,2002:str');
|
|
26072
26123
|
return schema[SCALAR$1];
|
|
26073
26124
|
}
|
|
26074
|
-
function findScalarTagByTest({ directives, schema }, value, token, onError) {
|
|
26075
|
-
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];
|
|
26076
26128
|
if (schema.compat) {
|
|
26077
26129
|
const compat = schema.compat.find(tag => tag.default && tag.test?.test(value)) ??
|
|
26078
26130
|
schema[SCALAR$1];
|
|
@@ -26088,8 +26140,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26088
26140
|
|
|
26089
26141
|
function emptyScalarPosition(offset, before, pos) {
|
|
26090
26142
|
if (before) {
|
|
26091
|
-
|
|
26092
|
-
pos = before.length;
|
|
26143
|
+
pos ?? (pos = before.length);
|
|
26093
26144
|
for (let i = pos - 1; i >= 0; --i) {
|
|
26094
26145
|
let st = before[i];
|
|
26095
26146
|
switch (st.type) {
|
|
@@ -26114,6 +26165,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26114
26165
|
|
|
26115
26166
|
const CN = { composeNode, composeEmptyNode };
|
|
26116
26167
|
function composeNode(ctx, token, props, onError) {
|
|
26168
|
+
const atKey = ctx.atKey;
|
|
26117
26169
|
const { spaceBefore, comment, anchor, tag } = props;
|
|
26118
26170
|
let node;
|
|
26119
26171
|
let isSrcToken = true;
|
|
@@ -26149,6 +26201,14 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26149
26201
|
}
|
|
26150
26202
|
if (anchor && node.anchor === '')
|
|
26151
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
|
+
}
|
|
26152
26212
|
if (spaceBefore)
|
|
26153
26213
|
node.spaceBefore = true;
|
|
26154
26214
|
if (comment) {
|
|
@@ -26201,6 +26261,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
26201
26261
|
const opts = Object.assign({ _directives: directives }, options);
|
|
26202
26262
|
const doc = new Document(undefined, opts);
|
|
26203
26263
|
const ctx = {
|
|
26264
|
+
atKey: false,
|
|
26204
26265
|
atRoot: true,
|
|
26205
26266
|
directives: doc.directives,
|
|
26206
26267
|
options: doc.options,
|
|
@@ -28335,7 +28396,20 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28335
28396
|
default: {
|
|
28336
28397
|
const bv = this.startBlockValue(map);
|
|
28337
28398
|
if (bv) {
|
|
28338
|
-
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) {
|
|
28339
28413
|
map.items.push({ start });
|
|
28340
28414
|
}
|
|
28341
28415
|
this.stack.push(bv);
|
|
@@ -28706,6 +28780,8 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
|
|
|
28706
28780
|
if (!keepUndefined)
|
|
28707
28781
|
return undefined;
|
|
28708
28782
|
}
|
|
28783
|
+
if (isDocument(value) && !_replacer)
|
|
28784
|
+
return value.toString(options);
|
|
28709
28785
|
return new Document(value, _replacer, options).toString(options);
|
|
28710
28786
|
}
|
|
28711
28787
|
|