@thoughtspot/visual-embed-sdk 1.42.1-alpha.3 → 1.42.1-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/cjs/package.json +1 -2
  2. package/cjs/src/api-intercept.d.ts +10 -8
  3. package/cjs/src/api-intercept.d.ts.map +1 -1
  4. package/cjs/src/api-intercept.js +12 -10
  5. package/cjs/src/api-intercept.js.map +1 -1
  6. package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -1
  7. package/cjs/src/embed/ts-embed.spec.js +0 -85
  8. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  9. package/cjs/src/react/util.d.ts +0 -1
  10. package/cjs/src/react/util.d.ts.map +1 -1
  11. package/cjs/src/utils/processData.spec.js.map +1 -1
  12. package/dist/index-DFnPKcjZ.js +7447 -0
  13. package/dist/index-DhFH7b7U.js +7447 -0
  14. package/dist/src/api-intercept.d.ts +10 -8
  15. package/dist/src/api-intercept.d.ts.map +1 -1
  16. package/dist/src/embed/ts-embed.spec.d.ts.map +1 -1
  17. package/dist/src/react/util.d.ts +0 -1
  18. package/dist/src/react/util.d.ts.map +1 -1
  19. package/dist/tsembed-react.es.js +15 -13
  20. package/dist/tsembed-react.js +235 -157
  21. package/dist/tsembed.es.js +15 -13
  22. package/dist/tsembed.js +235 -157
  23. package/lib/package.json +1 -2
  24. package/lib/src/api-intercept.d.ts +10 -8
  25. package/lib/src/api-intercept.d.ts.map +1 -1
  26. package/lib/src/api-intercept.js +12 -10
  27. package/lib/src/api-intercept.js.map +1 -1
  28. package/lib/src/embed/ts-embed.spec.d.ts.map +1 -1
  29. package/lib/src/embed/ts-embed.spec.js +0 -85
  30. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  31. package/lib/src/react/util.d.ts +0 -1
  32. package/lib/src/react/util.d.ts.map +1 -1
  33. package/lib/src/utils/processData.spec.js.map +1 -1
  34. package/package.json +1 -2
  35. package/src/api-intercept.ts +12 -10
  36. package/src/embed/ts-embed.spec.ts +0 -105
  37. package/src/utils/processData.spec.ts +0 -1
  38. package/src/api-intercept.spec.ts +0 -147
@@ -1,4 +1,4 @@
1
- /* @thoughtspot/visual-embed-sdk version 1.42.1-alpha.3 */
1
+ /* @thoughtspot/visual-embed-sdk version 1.42.1-alpha.5 */
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.3";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/mixpanel-browser":"^2.35.6","@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};
17504
+ var name="@thoughtspot/visual-embed-sdk";var version$1="1.42.1-alpha.5";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,17 +17753,19 @@ 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
- body: {
17757
- errors: [
17758
- {
17759
- errorObj: {
17760
- title,
17761
- desc
17756
+ response: {
17757
+ body: {
17758
+ errors: [
17759
+ {
17760
+ errorObj: {
17761
+ title,
17762
+ desc
17763
+ }
17762
17764
  }
17763
- }
17764
- ],
17765
- },
17766
- status: 200,
17765
+ ],
17766
+ },
17767
+ status: 200,
17768
+ }
17767
17769
  };
17768
17770
  return { data: payloadToSend };
17769
17771
  };
@@ -21852,8 +21854,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
21852
21854
  return {
21853
21855
  onAnchor: (source) => {
21854
21856
  aliasObjects.push(source);
21855
- if (!prevAnchors)
21856
- prevAnchors = anchorNames(doc);
21857
+ prevAnchors ?? (prevAnchors = anchorNames(doc));
21857
21858
  const anchor = findNewAnchor(prefix, prevAnchors);
21858
21859
  prevAnchors.add(anchor);
21859
21860
  return anchor;
@@ -22017,23 +22018,36 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
22017
22018
  * Resolve the value of this alias within `doc`, finding the last
22018
22019
  * instance of the `source` anchor before this node.
22019
22020
  */
22020
- resolve(doc) {
22021
+ resolve(doc, ctx) {
22022
+ let nodes;
22023
+ if (ctx?.aliasResolveCache) {
22024
+ nodes = ctx.aliasResolveCache;
22025
+ }
22026
+ else {
22027
+ nodes = [];
22028
+ visit$1(doc, {
22029
+ Node: (_key, node) => {
22030
+ if (isAlias(node) || hasAnchor(node))
22031
+ nodes.push(node);
22032
+ }
22033
+ });
22034
+ if (ctx)
22035
+ ctx.aliasResolveCache = nodes;
22036
+ }
22021
22037
  let found = undefined;
22022
- visit$1(doc, {
22023
- Node: (_key, node) => {
22024
- if (node === this)
22025
- return visit$1.BREAK;
22026
- if (node.anchor === this.source)
22027
- found = node;
22028
- }
22029
- });
22038
+ for (const node of nodes) {
22039
+ if (node === this)
22040
+ break;
22041
+ if (node.anchor === this.source)
22042
+ found = node;
22043
+ }
22030
22044
  return found;
22031
22045
  }
22032
22046
  toJSON(_arg, ctx) {
22033
22047
  if (!ctx)
22034
22048
  return { source: this.source };
22035
22049
  const { anchors, doc, maxAliasCount } = ctx;
22036
- const source = this.resolve(doc);
22050
+ const source = this.resolve(doc, ctx);
22037
22051
  if (!source) {
22038
22052
  const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
22039
22053
  throw new ReferenceError(msg);
@@ -22152,8 +22166,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
22152
22166
  if (aliasDuplicateObjects && value && typeof value === 'object') {
22153
22167
  ref = sourceObjects.get(value);
22154
22168
  if (ref) {
22155
- if (!ref.anchor)
22156
- ref.anchor = onAnchor(value);
22169
+ ref.anchor ?? (ref.anchor = onAnchor(value));
22157
22170
  return new Alias(ref.anchor);
22158
22171
  }
22159
22172
  else {
@@ -22664,7 +22677,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
22664
22677
  const { blockQuote, commentString, lineWidth } = ctx.options;
22665
22678
  // 1. Block can't end in whitespace unless the last line is non-empty.
22666
22679
  // 2. Strings consisting of only whitespace are best rendered explicitly.
22667
- if (!blockQuote || /\n[\t ]+$/.test(value) || /^\s*$/.test(value)) {
22680
+ if (!blockQuote || /\n[\t ]+$/.test(value)) {
22668
22681
  return quotedString(value, ctx);
22669
22682
  }
22670
22683
  const indent = ctx.indent ||
@@ -22724,23 +22737,32 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
22724
22737
  start = start.replace(/\n+/g, `$&${indent}`);
22725
22738
  }
22726
22739
  const indentSize = indent ? '2' : '1'; // root is at -1
22727
- let header = (literal ? '|' : '>') + (startWithSpace ? indentSize : '') + chomp;
22740
+ // Leading | or > is added later
22741
+ let header = (startWithSpace ? indentSize : '') + chomp;
22728
22742
  if (comment) {
22729
22743
  header += ' ' + commentString(comment.replace(/ ?[\r\n]+/g, ' '));
22730
22744
  if (onComment)
22731
22745
  onComment();
22732
22746
  }
22733
- if (literal) {
22734
- value = value.replace(/\n+/g, `$&${indent}`);
22735
- return `${header}\n${indent}${start}${value}${end}`;
22747
+ if (!literal) {
22748
+ const foldedValue = value
22749
+ .replace(/\n+/g, '\n$&')
22750
+ .replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
22751
+ // ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
22752
+ .replace(/\n+/g, `$&${indent}`);
22753
+ let literalFallback = false;
22754
+ const foldOptions = getFoldOptions(ctx, true);
22755
+ if (blockQuote !== 'folded' && type !== Scalar.BLOCK_FOLDED) {
22756
+ foldOptions.onOverflow = () => {
22757
+ literalFallback = true;
22758
+ };
22759
+ }
22760
+ const body = foldFlowLines(`${start}${foldedValue}${end}`, indent, FOLD_BLOCK, foldOptions);
22761
+ if (!literalFallback)
22762
+ return `>${header}\n${indent}${body}`;
22736
22763
  }
22737
- value = value
22738
- .replace(/\n+/g, '\n$&')
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}`;
22764
+ value = value.replace(/\n+/g, `$&${indent}`);
22765
+ return `|${header}\n${indent}${start}${value}${end}`;
22744
22766
  }
22745
22767
  function plainString(item, ctx, onComment, onChompKeep) {
22746
22768
  const { type, value } = item;
@@ -22749,10 +22771,9 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
22749
22771
  (inFlow && /[[\]{},]/.test(value))) {
22750
22772
  return quotedString(value, ctx);
22751
22773
  }
22752
- if (!value ||
22753
- /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
22774
+ if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
22754
22775
  // not allowed:
22755
- // - empty string, '-' or '?'
22776
+ // - '-' or '?'
22756
22777
  // - start with an indicator character (except [?:-]) or /[?-] /
22757
22778
  // - '\n ', ': ' or ' \n' anywhere
22758
22779
  // - '#' not preceded by a non-space char
@@ -22881,7 +22902,12 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
22881
22902
  let obj;
22882
22903
  if (isScalar$1(item)) {
22883
22904
  obj = item.value;
22884
- const match = tags.filter(t => t.identify?.(obj));
22905
+ let match = tags.filter(t => t.identify?.(obj));
22906
+ if (match.length > 1) {
22907
+ const testMatch = match.filter(t => t.test);
22908
+ if (testMatch.length > 0)
22909
+ match = testMatch;
22910
+ }
22885
22911
  tagObj =
22886
22912
  match.find(t => t.format === item.format) ?? match.find(t => !t.format);
22887
22913
  }
@@ -22890,7 +22916,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
22890
22916
  tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
22891
22917
  }
22892
22918
  if (!tagObj) {
22893
- const name = obj?.constructor?.name ?? typeof obj;
22919
+ const name = obj?.constructor?.name ?? (obj === null ? 'null' : typeof obj);
22894
22920
  throw new Error(`Tag not resolved for ${name} value`);
22895
22921
  }
22896
22922
  return tagObj;
@@ -22905,7 +22931,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
22905
22931
  anchors.add(anchor);
22906
22932
  props.push(`&${anchor}`);
22907
22933
  }
22908
- const tag = node.tag ? node.tag : tagObj.default ? null : tagObj.tag;
22934
+ const tag = node.tag ?? (tagObj.default ? null : tagObj.tag);
22909
22935
  if (tag)
22910
22936
  props.push(doc.directives.tagString(tag));
22911
22937
  return props.join(' ');
@@ -22931,8 +22957,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
22931
22957
  const node = isNode(item)
22932
22958
  ? item
22933
22959
  : ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
22934
- if (!tagObj)
22935
- tagObj = getTagObject(ctx.doc.schema.tags, node);
22960
+ tagObj ?? (tagObj = getTagObject(ctx.doc.schema.tags, node));
22936
22961
  const props = stringifyProps(node, tagObj, ctx);
22937
22962
  if (props.length > 0)
22938
22963
  ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
@@ -23094,54 +23119,10 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
23094
23119
 
23095
23120
  function warn(logLevel, warning) {
23096
23121
  if (logLevel === 'debug' || logLevel === 'warn') {
23097
- if (typeof process !== 'undefined' && process.emitWarning)
23098
- process.emitWarning(warning);
23099
- else
23100
- console.warn(warning);
23122
+ console.warn(warning);
23101
23123
  }
23102
23124
  }
23103
23125
 
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
23126
  // If the value associated with a merge key is a single mapping node, each of
23146
23127
  // its key/value pairs is inserted into the current mapping, unless the key
23147
23128
  // already exists in it. If the value associated with the merge key is a
@@ -23149,7 +23130,35 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
23149
23130
  // of these nodes is merged in turn according to its order in the sequence.
23150
23131
  // Keys in mapping nodes earlier in the sequence override keys specified in
23151
23132
  // later mapping nodes. -- http://yaml.org/type/merge.html
23152
- function mergeToJSMap(ctx, map, value) {
23133
+ const MERGE_KEY = '<<';
23134
+ const merge = {
23135
+ identify: value => value === MERGE_KEY ||
23136
+ (typeof value === 'symbol' && value.description === MERGE_KEY),
23137
+ default: 'key',
23138
+ tag: 'tag:yaml.org,2002:merge',
23139
+ test: /^<<$/,
23140
+ resolve: () => Object.assign(new Scalar(Symbol(MERGE_KEY)), {
23141
+ addToJSMap: addMergeToJSMap
23142
+ }),
23143
+ stringify: () => MERGE_KEY
23144
+ };
23145
+ const isMergeKey = (ctx, key) => (merge.identify(key) ||
23146
+ (isScalar$1(key) &&
23147
+ (!key.type || key.type === Scalar.PLAIN) &&
23148
+ merge.identify(key.value))) &&
23149
+ ctx?.doc.schema.tags.some(tag => tag.tag === merge.tag && tag.default);
23150
+ function addMergeToJSMap(ctx, map, value) {
23151
+ value = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
23152
+ if (isSeq(value))
23153
+ for (const it of value.items)
23154
+ mergeValue(ctx, map, it);
23155
+ else if (Array.isArray(value))
23156
+ for (const it of value)
23157
+ mergeValue(ctx, map, it);
23158
+ else
23159
+ mergeValue(ctx, map, value);
23160
+ }
23161
+ function mergeValue(ctx, map, value) {
23153
23162
  const source = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
23154
23163
  if (!isMap(source))
23155
23164
  throw new Error('Merge sources must be maps or map aliases');
@@ -23173,9 +23182,41 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
23173
23182
  }
23174
23183
  return map;
23175
23184
  }
23185
+
23186
+ function addPairToJSMap(ctx, map, { key, value }) {
23187
+ if (isNode(key) && key.addToJSMap)
23188
+ key.addToJSMap(ctx, map, value);
23189
+ // TODO: Should drop this special case for bare << handling
23190
+ else if (isMergeKey(ctx, key))
23191
+ addMergeToJSMap(ctx, map, value);
23192
+ else {
23193
+ const jsKey = toJS(key, '', ctx);
23194
+ if (map instanceof Map) {
23195
+ map.set(jsKey, toJS(value, jsKey, ctx));
23196
+ }
23197
+ else if (map instanceof Set) {
23198
+ map.add(jsKey);
23199
+ }
23200
+ else {
23201
+ const stringKey = stringifyKey(key, jsKey, ctx);
23202
+ const jsValue = toJS(value, stringKey, ctx);
23203
+ if (stringKey in map)
23204
+ Object.defineProperty(map, stringKey, {
23205
+ value: jsValue,
23206
+ writable: true,
23207
+ enumerable: true,
23208
+ configurable: true
23209
+ });
23210
+ else
23211
+ map[stringKey] = jsValue;
23212
+ }
23213
+ }
23214
+ return map;
23215
+ }
23176
23216
  function stringifyKey(key, jsKey, ctx) {
23177
23217
  if (jsKey === null)
23178
23218
  return '';
23219
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
23179
23220
  if (typeof jsKey !== 'object')
23180
23221
  return String(jsKey);
23181
23222
  if (isNode(key) && ctx?.doc) {
@@ -23808,7 +23849,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
23808
23849
  identify: value => typeof value === 'boolean',
23809
23850
  default: true,
23810
23851
  tag: 'tag:yaml.org,2002:bool',
23811
- test: /^true|false$/,
23852
+ test: /^true$|^false$/,
23812
23853
  resolve: str => str === 'true',
23813
23854
  stringify: stringifyJSON
23814
23855
  },
@@ -23853,10 +23894,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
23853
23894
  * document.querySelector('#photo').src = URL.createObjectURL(blob)
23854
23895
  */
23855
23896
  resolve(src, onError) {
23856
- if (typeof Buffer === 'function') {
23857
- return Buffer.from(src, 'base64');
23858
- }
23859
- else if (typeof atob === 'function') {
23897
+ if (typeof atob === 'function') {
23860
23898
  // On IE 11, atob() can't handle newlines
23861
23899
  const str = atob(src.replace(/[\n\r]/g, ''));
23862
23900
  const buffer = new Uint8Array(str.length);
@@ -23870,15 +23908,11 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
23870
23908
  }
23871
23909
  },
23872
23910
  stringify({ comment, type, value }, ctx, onComment, onChompKeep) {
23911
+ if (!value)
23912
+ return '';
23873
23913
  const buf = value; // checked earlier by binary.identify()
23874
23914
  let str;
23875
- if (typeof Buffer === 'function') {
23876
- str =
23877
- buf instanceof Buffer
23878
- ? buf.toString('base64')
23879
- : Buffer.from(buf.buffer).toString('base64');
23880
- }
23881
- else if (typeof btoa === 'function') {
23915
+ if (typeof btoa === 'function') {
23882
23916
  let s = '';
23883
23917
  for (let i = 0; i < buf.length; ++i)
23884
23918
  s += String.fromCharCode(buf[i]);
@@ -23887,8 +23921,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
23887
23921
  else {
23888
23922
  throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
23889
23923
  }
23890
- if (!type)
23891
- type = Scalar.BLOCK_LITERAL;
23924
+ type ?? (type = Scalar.BLOCK_LITERAL);
23892
23925
  if (type !== Scalar.QUOTE_DOUBLE) {
23893
23926
  const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
23894
23927
  const n = Math.ceil(str.length / lineWidth);
@@ -24357,7 +24390,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
24357
24390
  }
24358
24391
  return new Date(date);
24359
24392
  },
24360
- stringify: ({ value }) => value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, '')
24393
+ stringify: ({ value }) => value?.toISOString().replace(/(T00:00:00)?\.000Z$/, '') ?? ''
24361
24394
  };
24362
24395
 
24363
24396
  const schema = [
@@ -24375,6 +24408,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
24375
24408
  floatExp,
24376
24409
  float,
24377
24410
  binary,
24411
+ merge,
24378
24412
  omap,
24379
24413
  pairs,
24380
24414
  set,
@@ -24402,6 +24436,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
24402
24436
  intOct: intOct$1,
24403
24437
  intTime,
24404
24438
  map,
24439
+ merge,
24405
24440
  null: nullTag,
24406
24441
  omap,
24407
24442
  pairs,
@@ -24411,13 +24446,20 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
24411
24446
  };
24412
24447
  const coreKnownTags = {
24413
24448
  'tag:yaml.org,2002:binary': binary,
24449
+ 'tag:yaml.org,2002:merge': merge,
24414
24450
  'tag:yaml.org,2002:omap': omap,
24415
24451
  'tag:yaml.org,2002:pairs': pairs,
24416
24452
  'tag:yaml.org,2002:set': set,
24417
24453
  'tag:yaml.org,2002:timestamp': timestamp
24418
24454
  };
24419
- function getTags(customTags, schemaName) {
24420
- let tags = schemas.get(schemaName);
24455
+ function getTags(customTags, schemaName, addMergeTag) {
24456
+ const schemaTags = schemas.get(schemaName);
24457
+ if (schemaTags && !customTags) {
24458
+ return addMergeTag && !schemaTags.includes(merge)
24459
+ ? schemaTags.concat(merge)
24460
+ : schemaTags.slice();
24461
+ }
24462
+ let tags = schemaTags;
24421
24463
  if (!tags) {
24422
24464
  if (Array.isArray(customTags))
24423
24465
  tags = [];
@@ -24436,17 +24478,21 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
24436
24478
  else if (typeof customTags === 'function') {
24437
24479
  tags = customTags(tags.slice());
24438
24480
  }
24439
- return tags.map(tag => {
24440
- if (typeof tag !== 'string')
24441
- return tag;
24442
- const tagObj = tagsByName[tag];
24443
- if (tagObj)
24444
- return tagObj;
24445
- const keys = Object.keys(tagsByName)
24446
- .map(key => JSON.stringify(key))
24447
- .join(', ');
24448
- throw new Error(`Unknown custom tag "${tag}"; use one of ${keys}`);
24449
- });
24481
+ if (addMergeTag)
24482
+ tags = tags.concat(merge);
24483
+ return tags.reduce((tags, tag) => {
24484
+ const tagObj = typeof tag === 'string' ? tagsByName[tag] : tag;
24485
+ if (!tagObj) {
24486
+ const tagName = JSON.stringify(tag);
24487
+ const keys = Object.keys(tagsByName)
24488
+ .map(key => JSON.stringify(key))
24489
+ .join(', ');
24490
+ throw new Error(`Unknown custom tag ${tagName}; use one of ${keys}`);
24491
+ }
24492
+ if (!tags.includes(tagObj))
24493
+ tags.push(tagObj);
24494
+ return tags;
24495
+ }, []);
24450
24496
  }
24451
24497
 
24452
24498
  const sortMapEntriesByKey = (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
@@ -24457,10 +24503,9 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
24457
24503
  : compat
24458
24504
  ? getTags(null, compat)
24459
24505
  : null;
24460
- this.merge = !!merge;
24461
24506
  this.name = (typeof schema === 'string' && schema) || 'core';
24462
24507
  this.knownTags = resolveKnownTags ? coreKnownTags : {};
24463
- this.tags = getTags(customTags, this.name);
24508
+ this.tags = getTags(customTags, this.name, merge);
24464
24509
  this.toStringOptions = toStringDefaults ?? null;
24465
24510
  Object.defineProperty(this, MAP, { value: map });
24466
24511
  Object.defineProperty(this, SCALAR$1, { value: string });
@@ -24585,6 +24630,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
24585
24630
  logLevel: 'warn',
24586
24631
  prettyErrors: true,
24587
24632
  strict: true,
24633
+ stringKeys: false,
24588
24634
  uniqueKeys: true,
24589
24635
  version: '1.2'
24590
24636
  }, options);
@@ -24808,7 +24854,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
24808
24854
  this.directives.yaml.version = '1.1';
24809
24855
  else
24810
24856
  this.directives = new Directives({ version: '1.1' });
24811
- opt = { merge: true, resolveKnownTags: false, schema: 'yaml-1.1' };
24857
+ opt = { resolveKnownTags: false, schema: 'yaml-1.1' };
24812
24858
  break;
24813
24859
  case '1.2':
24814
24860
  case 'next':
@@ -24816,7 +24862,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
24816
24862
  this.directives.yaml.version = version;
24817
24863
  else
24818
24864
  this.directives = new Directives({ version });
24819
- opt = { merge: false, resolveKnownTags: true, schema: 'core' };
24865
+ opt = { resolveKnownTags: true, schema: 'core' };
24820
24866
  break;
24821
24867
  case null:
24822
24868
  if (this.directives)
@@ -24994,7 +25040,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
24994
25040
  if (atNewline) {
24995
25041
  if (comment)
24996
25042
  comment += token.source;
24997
- else
25043
+ else if (!found || indicator !== 'seq-item-ind')
24998
25044
  spaceBefore = true;
24999
25045
  }
25000
25046
  else
@@ -25011,8 +25057,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
25011
25057
  if (token.source.endsWith(':'))
25012
25058
  onError(token.offset + token.source.length - 1, 'BAD_ALIAS', 'Anchor ending in : is ambiguous', true);
25013
25059
  anchor = token;
25014
- if (start === null)
25015
- start = token.offset;
25060
+ start ?? (start = token.offset);
25016
25061
  atNewline = false;
25017
25062
  hasSpace = false;
25018
25063
  reqSpace = true;
@@ -25021,8 +25066,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
25021
25066
  if (tag)
25022
25067
  onError(token, 'MULTIPLE_TAGS', 'A node can have at most one tag');
25023
25068
  tag = token;
25024
- if (start === null)
25025
- start = token.offset;
25069
+ start ?? (start = token.offset);
25026
25070
  atNewline = false;
25027
25071
  hasSpace = false;
25028
25072
  reqSpace = true;
@@ -25135,11 +25179,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
25135
25179
  return false;
25136
25180
  const isEqual = typeof uniqueKeys === 'function'
25137
25181
  ? 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));
25182
+ : (a, b) => a === b || (isScalar$1(a) && isScalar$1(b) && a.value === b.value);
25143
25183
  return items.some(pair => isEqual(pair.key, search));
25144
25184
  }
25145
25185
 
@@ -25188,12 +25228,14 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
25188
25228
  onError(offset, 'BAD_INDENT', startColMsg);
25189
25229
  }
25190
25230
  // key value
25231
+ ctx.atKey = true;
25191
25232
  const keyStart = keyProps.end;
25192
25233
  const keyNode = key
25193
25234
  ? composeNode(ctx, key, keyProps, onError)
25194
25235
  : composeEmptyNode(ctx, keyStart, start, null, keyProps, onError);
25195
25236
  if (ctx.schema.compat)
25196
25237
  flowIndentCheck(bm.indent, key, onError);
25238
+ ctx.atKey = false;
25197
25239
  if (mapIncludes(ctx, map.items, keyNode))
25198
25240
  onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
25199
25241
  // value properties
@@ -25253,6 +25295,8 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
25253
25295
  const seq = new NodeClass(ctx.schema);
25254
25296
  if (ctx.atRoot)
25255
25297
  ctx.atRoot = false;
25298
+ if (ctx.atKey)
25299
+ ctx.atKey = false;
25256
25300
  let offset = bs.offset;
25257
25301
  let commentEnd = null;
25258
25302
  for (const { start, value } of bs.items) {
@@ -25337,6 +25381,8 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
25337
25381
  const atRoot = ctx.atRoot;
25338
25382
  if (atRoot)
25339
25383
  ctx.atRoot = false;
25384
+ if (ctx.atKey)
25385
+ ctx.atKey = false;
25340
25386
  let offset = fc.offset + fc.start.source.length;
25341
25387
  for (let i = 0; i < fc.items.length; ++i) {
25342
25388
  const collItem = fc.items[i];
@@ -25416,12 +25462,14 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
25416
25462
  else {
25417
25463
  // item is a key+value pair
25418
25464
  // key value
25465
+ ctx.atKey = true;
25419
25466
  const keyStart = props.end;
25420
25467
  const keyNode = key
25421
25468
  ? composeNode(ctx, key, props, onError)
25422
25469
  : composeEmptyNode(ctx, keyStart, start, null, props, onError);
25423
25470
  if (isBlock(key))
25424
25471
  onError(keyNode.range, 'BLOCK_IN_FLOW', blockMsg);
25472
+ ctx.atKey = false;
25425
25473
  // value properties
25426
25474
  const valueProps = resolveProps(sep ?? [], {
25427
25475
  flow: fcName,
@@ -25577,8 +25625,8 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
25577
25625
  tag = kt;
25578
25626
  }
25579
25627
  else {
25580
- if (kt?.collection) {
25581
- onError(tagToken, 'BAD_COLLECTION_TYPE', `${kt.tag} used for ${expType} collection, but expects ${kt.collection}`, true);
25628
+ if (kt) {
25629
+ onError(tagToken, 'BAD_COLLECTION_TYPE', `${kt.tag} used for ${expType} collection, but expects ${kt.collection ?? 'scalar'}`, true);
25582
25630
  }
25583
25631
  else {
25584
25632
  onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, true);
@@ -26019,11 +26067,16 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
26019
26067
  const tagName = tagToken
26020
26068
  ? ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg))
26021
26069
  : null;
26022
- const tag = tagToken && tagName
26023
- ? findScalarTagByName(ctx.schema, value, tagName, tagToken, onError)
26024
- : token.type === 'scalar'
26025
- ? findScalarTagByTest(ctx, value, token, onError)
26026
- : ctx.schema[SCALAR$1];
26070
+ let tag;
26071
+ if (ctx.options.stringKeys && ctx.atKey) {
26072
+ tag = ctx.schema[SCALAR$1];
26073
+ }
26074
+ else if (tagName)
26075
+ tag = findScalarTagByName(ctx.schema, value, tagName, tagToken, onError);
26076
+ else if (token.type === 'scalar')
26077
+ tag = findScalarTagByTest(ctx, value, token, onError);
26078
+ else
26079
+ tag = ctx.schema[SCALAR$1];
26027
26080
  let scalar;
26028
26081
  try {
26029
26082
  const res = tag.resolve(value, msg => onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg), ctx.options);
@@ -26071,8 +26124,9 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
26071
26124
  onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, tagName !== 'tag:yaml.org,2002:str');
26072
26125
  return schema[SCALAR$1];
26073
26126
  }
26074
- function findScalarTagByTest({ directives, schema }, value, token, onError) {
26075
- const tag = schema.tags.find(tag => tag.default && tag.test?.test(value)) || schema[SCALAR$1];
26127
+ function findScalarTagByTest({ atKey, directives, schema }, value, token, onError) {
26128
+ const tag = schema.tags.find(tag => (tag.default === true || (atKey && tag.default === 'key')) &&
26129
+ tag.test?.test(value)) || schema[SCALAR$1];
26076
26130
  if (schema.compat) {
26077
26131
  const compat = schema.compat.find(tag => tag.default && tag.test?.test(value)) ??
26078
26132
  schema[SCALAR$1];
@@ -26088,8 +26142,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
26088
26142
 
26089
26143
  function emptyScalarPosition(offset, before, pos) {
26090
26144
  if (before) {
26091
- if (pos === null)
26092
- pos = before.length;
26145
+ pos ?? (pos = before.length);
26093
26146
  for (let i = pos - 1; i >= 0; --i) {
26094
26147
  let st = before[i];
26095
26148
  switch (st.type) {
@@ -26114,6 +26167,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
26114
26167
 
26115
26168
  const CN = { composeNode, composeEmptyNode };
26116
26169
  function composeNode(ctx, token, props, onError) {
26170
+ const atKey = ctx.atKey;
26117
26171
  const { spaceBefore, comment, anchor, tag } = props;
26118
26172
  let node;
26119
26173
  let isSrcToken = true;
@@ -26149,6 +26203,14 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
26149
26203
  }
26150
26204
  if (anchor && node.anchor === '')
26151
26205
  onError(anchor, 'BAD_ALIAS', 'Anchor cannot be an empty string');
26206
+ if (atKey &&
26207
+ ctx.options.stringKeys &&
26208
+ (!isScalar$1(node) ||
26209
+ typeof node.value !== 'string' ||
26210
+ (node.tag && node.tag !== 'tag:yaml.org,2002:str'))) {
26211
+ const msg = 'With stringKeys, all keys must be strings';
26212
+ onError(tag ?? token, 'NON_STRING_KEY', msg);
26213
+ }
26152
26214
  if (spaceBefore)
26153
26215
  node.spaceBefore = true;
26154
26216
  if (comment) {
@@ -26201,6 +26263,7 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
26201
26263
  const opts = Object.assign({ _directives: directives }, options);
26202
26264
  const doc = new Document(undefined, opts);
26203
26265
  const ctx = {
26266
+ atKey: false,
26204
26267
  atRoot: true,
26205
26268
  directives: doc.directives,
26206
26269
  options: doc.options,
@@ -28335,7 +28398,20 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
28335
28398
  default: {
28336
28399
  const bv = this.startBlockValue(map);
28337
28400
  if (bv) {
28338
- if (atMapIndent && bv.type !== 'block-seq') {
28401
+ if (bv.type === 'block-seq') {
28402
+ if (!it.explicitKey &&
28403
+ it.sep &&
28404
+ !includesToken(it.sep, 'newline')) {
28405
+ yield* this.pop({
28406
+ type: 'error',
28407
+ offset: this.offset,
28408
+ message: 'Unexpected block-seq-ind on same line with key',
28409
+ source: this.source
28410
+ });
28411
+ return;
28412
+ }
28413
+ }
28414
+ else if (atMapIndent) {
28339
28415
  map.items.push({ start });
28340
28416
  }
28341
28417
  this.stack.push(bv);
@@ -28706,6 +28782,8 @@ query SendMessage($params: Input_convassist_SendMessageRequest) {
28706
28782
  if (!keepUndefined)
28707
28783
  return undefined;
28708
28784
  }
28785
+ if (isDocument(value) && !_replacer)
28786
+ return value.toString(options);
28709
28787
  return new Document(value, _replacer, options).toString(options);
28710
28788
  }
28711
28789