projen 0.71.68 → 0.71.69

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 (240) hide show
  1. package/.jsii +2 -2
  2. package/lib/awscdk/auto-discover.js +5 -5
  3. package/lib/awscdk/awscdk-app-java.js +1 -1
  4. package/lib/awscdk/awscdk-app-py.js +1 -1
  5. package/lib/awscdk/awscdk-app-ts.js +1 -1
  6. package/lib/awscdk/awscdk-construct.js +2 -2
  7. package/lib/awscdk/awscdk-deps-java.js +1 -1
  8. package/lib/awscdk/awscdk-deps-js.js +1 -1
  9. package/lib/awscdk/awscdk-deps-py.js +1 -1
  10. package/lib/awscdk/awscdk-deps.js +1 -1
  11. package/lib/awscdk/cdk-config.js +1 -1
  12. package/lib/awscdk/cdk-tasks.js +1 -1
  13. package/lib/awscdk/integration-test.js +1 -1
  14. package/lib/awscdk/lambda-extension.js +1 -1
  15. package/lib/awscdk/lambda-function.js +2 -2
  16. package/lib/build/build-workflow.js +1 -1
  17. package/lib/cdk/auto-discover-base.js +2 -2
  18. package/lib/cdk/construct-lib.js +1 -1
  19. package/lib/cdk/integration-test-base.js +1 -1
  20. package/lib/cdk/jsii-docgen.js +1 -1
  21. package/lib/cdk/jsii-project.js +1 -1
  22. package/lib/cdk8s/auto-discover.js +2 -2
  23. package/lib/cdk8s/cdk8s-app-py.js +1 -1
  24. package/lib/cdk8s/cdk8s-app-ts.js +1 -1
  25. package/lib/cdk8s/cdk8s-construct.js +1 -1
  26. package/lib/cdk8s/cdk8s-deps-py.js +1 -1
  27. package/lib/cdk8s/cdk8s-deps.js +1 -1
  28. package/lib/cdk8s/integration-test.js +1 -1
  29. package/lib/cdktf/cdktf-construct.js +1 -1
  30. package/lib/circleci/circleci.js +1 -1
  31. package/lib/component.js +1 -1
  32. package/lib/dependencies.js +1 -1
  33. package/lib/dev-env.js +1 -1
  34. package/lib/docker-compose/docker-compose-service.js +1 -1
  35. package/lib/docker-compose/docker-compose.js +1 -1
  36. package/lib/file.js +1 -1
  37. package/lib/gitattributes.js +1 -1
  38. package/lib/github/actions-provider.js +1 -1
  39. package/lib/github/auto-approve.js +1 -1
  40. package/lib/github/auto-merge.js +1 -1
  41. package/lib/github/dependabot.js +1 -1
  42. package/lib/github/github-credentials.js +1 -1
  43. package/lib/github/github-project.js +1 -1
  44. package/lib/github/github.js +1 -1
  45. package/lib/github/mergify.js +1 -1
  46. package/lib/github/pr-template.js +1 -1
  47. package/lib/github/pull-request-lint.js +1 -1
  48. package/lib/github/stale.js +1 -1
  49. package/lib/github/task-workflow.js +1 -1
  50. package/lib/github/workflow-actions.js +1 -1
  51. package/lib/github/workflow-jobs.js +1 -1
  52. package/lib/github/workflows.js +1 -1
  53. package/lib/gitlab/configuration.js +1 -1
  54. package/lib/gitlab/gitlab-configuration.js +1 -1
  55. package/lib/gitlab/nested-configuration.js +1 -1
  56. package/lib/gitpod.js +1 -1
  57. package/lib/ignore-file.js +1 -1
  58. package/lib/ini.js +1 -1
  59. package/lib/java/java-project.js +1 -1
  60. package/lib/java/junit.js +1 -1
  61. package/lib/java/maven-compile.js +1 -1
  62. package/lib/java/maven-packaging.js +1 -1
  63. package/lib/java/maven-sample.js +1 -1
  64. package/lib/java/pom.js +1 -1
  65. package/lib/java/projenrc.js +1 -1
  66. package/lib/javascript/bundler.js +1 -1
  67. package/lib/javascript/eslint.js +1 -1
  68. package/lib/javascript/jest.js +4 -4
  69. package/lib/javascript/node-package.js +1 -1
  70. package/lib/javascript/node-project.js +1 -1
  71. package/lib/javascript/npm-config.js +1 -1
  72. package/lib/javascript/prettier.js +1 -1
  73. package/lib/javascript/projenrc.js +1 -1
  74. package/lib/javascript/typescript-config.js +2 -2
  75. package/lib/javascript/upgrade-dependencies.js +2 -2
  76. package/lib/json-patch.js +1 -1
  77. package/lib/json.js +1 -1
  78. package/lib/license.js +1 -1
  79. package/lib/logger.js +1 -1
  80. package/lib/makefile.js +1 -1
  81. package/lib/object-file.js +1 -1
  82. package/lib/project-build.js +1 -1
  83. package/lib/project.js +1 -1
  84. package/lib/projects.js +1 -1
  85. package/lib/projenrc-json.js +2 -2
  86. package/lib/projenrc.js +1 -1
  87. package/lib/python/pip.js +1 -1
  88. package/lib/python/poetry.js +2 -2
  89. package/lib/python/projenrc.js +1 -1
  90. package/lib/python/pytest-sample.js +1 -1
  91. package/lib/python/pytest.js +1 -1
  92. package/lib/python/python-project.js +1 -1
  93. package/lib/python/python-sample.js +1 -1
  94. package/lib/python/requirements-file.js +1 -1
  95. package/lib/python/setuppy.js +1 -1
  96. package/lib/python/setuptools.js +1 -1
  97. package/lib/python/venv.js +1 -1
  98. package/lib/readme.js +1 -1
  99. package/lib/release/publisher.js +1 -1
  100. package/lib/release/release-trigger.js +1 -1
  101. package/lib/release/release.js +1 -1
  102. package/lib/renovatebot.js +1 -1
  103. package/lib/sample-file.js +2 -2
  104. package/lib/semver.js +1 -1
  105. package/lib/source-code.js +1 -1
  106. package/lib/task-runtime.js +1 -1
  107. package/lib/task.js +1 -1
  108. package/lib/tasks.js +1 -1
  109. package/lib/testing.js +1 -1
  110. package/lib/textfile.js +1 -1
  111. package/lib/toml.js +1 -1
  112. package/lib/typescript/projenrc-ts.js +1 -1
  113. package/lib/typescript/projenrc.js +1 -1
  114. package/lib/typescript/typescript-typedoc.js +1 -1
  115. package/lib/typescript/typescript.js +3 -3
  116. package/lib/version.js +1 -1
  117. package/lib/vscode/devcontainer.js +1 -1
  118. package/lib/vscode/extensions.js +1 -1
  119. package/lib/vscode/launch-config.js +1 -1
  120. package/lib/vscode/settings.js +1 -1
  121. package/lib/vscode/vscode.js +1 -1
  122. package/lib/web/next.js +3 -3
  123. package/lib/web/postcss.js +1 -1
  124. package/lib/web/react.js +4 -4
  125. package/lib/web/tailwind.js +1 -1
  126. package/lib/xmlfile.js +1 -1
  127. package/lib/yaml.js +1 -1
  128. package/node_modules/yaml/README.md +4 -0
  129. package/node_modules/yaml/browser/dist/compose/compose-collection.js +46 -29
  130. package/node_modules/yaml/browser/dist/compose/compose-doc.js +1 -0
  131. package/node_modules/yaml/browser/dist/compose/compose-scalar.js +1 -1
  132. package/node_modules/yaml/browser/dist/compose/composer.js +1 -1
  133. package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +3 -2
  134. package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +3 -2
  135. package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +4 -5
  136. package/node_modules/yaml/browser/dist/compose/util-map-includes.js +1 -1
  137. package/node_modules/yaml/browser/dist/doc/Document.js +12 -10
  138. package/node_modules/yaml/browser/dist/doc/anchors.js +1 -1
  139. package/node_modules/yaml/browser/dist/doc/createNode.js +6 -2
  140. package/node_modules/yaml/browser/dist/doc/directives.js +1 -1
  141. package/node_modules/yaml/browser/dist/index.js +1 -1
  142. package/node_modules/yaml/browser/dist/node_modules/tslib/tslib.es6.js +6 -149
  143. package/node_modules/yaml/browser/dist/nodes/Alias.js +9 -2
  144. package/node_modules/yaml/browser/dist/nodes/Collection.js +2 -1
  145. package/node_modules/yaml/browser/dist/nodes/Node.js +25 -35
  146. package/node_modules/yaml/browser/dist/nodes/Pair.js +1 -1
  147. package/node_modules/yaml/browser/dist/nodes/Scalar.js +2 -1
  148. package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +30 -2
  149. package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +17 -1
  150. package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +1 -1
  151. package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
  152. package/node_modules/yaml/browser/dist/nodes/toJS.js +1 -1
  153. package/node_modules/yaml/browser/dist/schema/Schema.js +1 -1
  154. package/node_modules/yaml/browser/dist/schema/common/map.js +3 -28
  155. package/node_modules/yaml/browser/dist/schema/common/seq.js +3 -19
  156. package/node_modules/yaml/browser/dist/schema/tags.js +1 -1
  157. package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +9 -8
  158. package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +1 -1
  159. package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +14 -13
  160. package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +1 -1
  161. package/node_modules/yaml/browser/dist/stringify/stringify.js +1 -1
  162. package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +1 -1
  163. package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +1 -1
  164. package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +1 -1
  165. package/node_modules/yaml/browser/dist/stringify/stringifyString.js +10 -1
  166. package/node_modules/yaml/browser/dist/util.js +2 -0
  167. package/node_modules/yaml/browser/dist/visit.js +1 -1
  168. package/node_modules/yaml/dist/compose/compose-collection.d.ts +1 -1
  169. package/node_modules/yaml/dist/compose/compose-collection.js +47 -30
  170. package/node_modules/yaml/dist/compose/compose-doc.d.ts +2 -1
  171. package/node_modules/yaml/dist/compose/compose-doc.js +1 -0
  172. package/node_modules/yaml/dist/compose/compose-scalar.js +7 -7
  173. package/node_modules/yaml/dist/compose/composer.d.ts +5 -5
  174. package/node_modules/yaml/dist/compose/composer.js +3 -3
  175. package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +2 -1
  176. package/node_modules/yaml/dist/compose/resolve-block-map.js +3 -2
  177. package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +2 -1
  178. package/node_modules/yaml/dist/compose/resolve-block-seq.js +3 -2
  179. package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +2 -1
  180. package/node_modules/yaml/dist/compose/resolve-flow-collection.js +5 -6
  181. package/node_modules/yaml/dist/compose/util-map-includes.d.ts +3 -3
  182. package/node_modules/yaml/dist/compose/util-map-includes.js +3 -3
  183. package/node_modules/yaml/dist/doc/Document.d.ts +11 -9
  184. package/node_modules/yaml/dist/doc/Document.js +22 -20
  185. package/node_modules/yaml/dist/doc/anchors.d.ts +4 -4
  186. package/node_modules/yaml/dist/doc/anchors.js +2 -2
  187. package/node_modules/yaml/dist/doc/createNode.d.ts +1 -1
  188. package/node_modules/yaml/dist/doc/createNode.js +13 -9
  189. package/node_modules/yaml/dist/doc/directives.js +3 -3
  190. package/node_modules/yaml/dist/errors.d.ts +1 -1
  191. package/node_modules/yaml/dist/index.d.ts +2 -1
  192. package/node_modules/yaml/dist/index.js +9 -9
  193. package/node_modules/yaml/dist/nodes/Alias.d.ts +1 -1
  194. package/node_modules/yaml/dist/nodes/Alias.js +12 -5
  195. package/node_modules/yaml/dist/nodes/Collection.d.ts +3 -2
  196. package/node_modules/yaml/dist/nodes/Collection.js +10 -9
  197. package/node_modules/yaml/dist/nodes/Node.d.ts +5 -18
  198. package/node_modules/yaml/dist/nodes/Node.js +25 -51
  199. package/node_modules/yaml/dist/nodes/Pair.d.ts +2 -2
  200. package/node_modules/yaml/dist/nodes/Pair.js +4 -4
  201. package/node_modules/yaml/dist/nodes/Scalar.js +2 -1
  202. package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +7 -1
  203. package/node_modules/yaml/dist/nodes/YAMLMap.js +37 -9
  204. package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +3 -1
  205. package/node_modules/yaml/dist/nodes/YAMLSeq.js +21 -5
  206. package/node_modules/yaml/dist/nodes/addPairToJSMap.js +7 -7
  207. package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
  208. package/node_modules/yaml/dist/nodes/identity.js +53 -0
  209. package/node_modules/yaml/dist/nodes/toJS.d.ts +2 -5
  210. package/node_modules/yaml/dist/nodes/toJS.js +2 -2
  211. package/node_modules/yaml/dist/public-api.d.ts +3 -3
  212. package/node_modules/yaml/dist/schema/Schema.d.ts +1 -1
  213. package/node_modules/yaml/dist/schema/Schema.js +4 -4
  214. package/node_modules/yaml/dist/schema/common/map.js +4 -29
  215. package/node_modules/yaml/dist/schema/common/seq.js +4 -20
  216. package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -1
  217. package/node_modules/yaml/dist/schema/json/schema.d.ts +1 -1
  218. package/node_modules/yaml/dist/schema/tags.d.ts +1 -1
  219. package/node_modules/yaml/dist/schema/types.d.ts +11 -3
  220. package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +4 -1
  221. package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +11 -10
  222. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +1 -1
  223. package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +5 -5
  224. package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -1
  225. package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +3 -1
  226. package/node_modules/yaml/dist/schema/yaml-1.1/set.js +17 -16
  227. package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +1 -1
  228. package/node_modules/yaml/dist/stringify/stringify.js +8 -8
  229. package/node_modules/yaml/dist/stringify/stringifyCollection.js +8 -8
  230. package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -3
  231. package/node_modules/yaml/dist/stringify/stringifyDocument.js +2 -2
  232. package/node_modules/yaml/dist/stringify/stringifyPair.js +9 -9
  233. package/node_modules/yaml/dist/stringify/stringifyString.js +10 -1
  234. package/node_modules/yaml/dist/test-events.js +8 -8
  235. package/node_modules/yaml/dist/util.d.ts +4 -1
  236. package/node_modules/yaml/dist/util.js +4 -0
  237. package/node_modules/yaml/dist/visit.js +18 -18
  238. package/node_modules/yaml/package.json +8 -6
  239. package/package.json +3 -3
  240. package/node_modules/yaml/util.d.ts +0 -3
@@ -1,2 +1,2 @@
1
1
  import { CollectionTag, ScalarTag } from '../types.js';
2
- export declare const schema: (ScalarTag | CollectionTag)[];
2
+ export declare const schema: (CollectionTag | ScalarTag)[];
@@ -36,5 +36,5 @@ export declare const coreKnownTags: {
36
36
  test: RegExp;
37
37
  };
38
38
  };
39
- export declare function getTags(customTags: SchemaOptions['customTags'] | undefined, schemaName: string): (ScalarTag | CollectionTag)[];
39
+ export declare function getTags(customTags: SchemaOptions['customTags'] | undefined, schemaName: string): (CollectionTag | ScalarTag)[];
40
40
  export {};
@@ -1,11 +1,11 @@
1
1
  import type { CreateNodeContext } from '../doc/createNode.js';
2
- import type { Schema } from './Schema.js';
3
2
  import type { Node } from '../nodes/Node.js';
4
3
  import type { Scalar } from '../nodes/Scalar.js';
5
4
  import type { YAMLMap } from '../nodes/YAMLMap.js';
6
5
  import type { YAMLSeq } from '../nodes/YAMLSeq.js';
7
6
  import type { ParseOptions } from '../options.js';
8
7
  import type { StringifyContext } from '../stringify/stringify.js';
8
+ import type { Schema } from './Schema.js';
9
9
  interface TagBase {
10
10
  /**
11
11
  * An optional factory function, used e.g. by collections when wrapping JS objects as AST nodes.
@@ -71,12 +71,20 @@ export interface CollectionTag extends TagBase {
71
71
  /**
72
72
  * The `Node` child class that implements this tag.
73
73
  * If set, used to select this tag when stringifying.
74
+ *
75
+ * If the class provides a static `from` method, then that
76
+ * will be used if the tag object doesn't have a `createNode` method.
74
77
  */
75
- nodeClass?: new () => Node;
78
+ nodeClass?: {
79
+ new (schema?: Schema): Node;
80
+ from?: (schema: Schema, obj: unknown, ctx: CreateNodeContext) => Node;
81
+ };
76
82
  /**
77
83
  * Turns a value into an AST node.
78
84
  * If returning a non-`Node` value, the output will be wrapped as a `Scalar`.
85
+ *
86
+ * Note: this is required if nodeClass is not provided.
79
87
  */
80
- resolve(value: YAMLMap.Parsed | YAMLSeq.Parsed, onError: (message: string) => void, options: ParseOptions): unknown;
88
+ resolve?: (value: YAMLMap.Parsed | YAMLSeq.Parsed, onError: (message: string) => void, options: ParseOptions) => unknown;
81
89
  }
82
90
  export {};
@@ -1,5 +1,7 @@
1
- import { YAMLSeq } from '../../nodes/YAMLSeq.js';
2
1
  import { ToJSContext } from '../../nodes/toJS.js';
2
+ import { YAMLSeq } from '../../nodes/YAMLSeq.js';
3
+ import { CreateNodeContext } from '../../util.js';
4
+ import type { Schema } from '../Schema.js';
3
5
  import { CollectionTag } from '../types.js';
4
6
  export declare class YAMLOMap extends YAMLSeq {
5
7
  static tag: string;
@@ -21,5 +23,6 @@ export declare class YAMLOMap extends YAMLSeq {
21
23
  * but TypeScript won't allow widening the signature of a child method.
22
24
  */
23
25
  toJSON(_?: unknown, ctx?: ToJSContext): unknown[];
26
+ static from(schema: Schema, iterable: unknown, ctx: CreateNodeContext): YAMLOMap;
24
27
  }
25
28
  export declare const omap: CollectionTag;
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var YAMLSeq = require('../../nodes/YAMLSeq.js');
3
+ var identity = require('../../nodes/identity.js');
4
4
  var toJS = require('../../nodes/toJS.js');
5
- var Node = require('../../nodes/Node.js');
6
5
  var YAMLMap = require('../../nodes/YAMLMap.js');
6
+ var YAMLSeq = require('../../nodes/YAMLSeq.js');
7
7
  var pairs = require('./pairs.js');
8
8
 
9
9
  class YAMLOMap extends YAMLSeq.YAMLSeq {
@@ -28,7 +28,7 @@ class YAMLOMap extends YAMLSeq.YAMLSeq {
28
28
  ctx.onCreate(map);
29
29
  for (const pair of this.items) {
30
30
  let key, value;
31
- if (Node.isPair(pair)) {
31
+ if (identity.isPair(pair)) {
32
32
  key = toJS.toJS(pair.key, '', ctx);
33
33
  value = toJS.toJS(pair.value, key, ctx);
34
34
  }
@@ -41,6 +41,12 @@ class YAMLOMap extends YAMLSeq.YAMLSeq {
41
41
  }
42
42
  return map;
43
43
  }
44
+ static from(schema, iterable, ctx) {
45
+ const pairs$1 = pairs.createPairs(schema, iterable, ctx);
46
+ const omap = new this();
47
+ omap.items = pairs$1.items;
48
+ return omap;
49
+ }
44
50
  }
45
51
  YAMLOMap.tag = 'tag:yaml.org,2002:omap';
46
52
  const omap = {
@@ -53,7 +59,7 @@ const omap = {
53
59
  const pairs$1 = pairs.resolvePairs(seq, onError);
54
60
  const seenKeys = [];
55
61
  for (const { key } of pairs$1.items) {
56
- if (Node.isScalar(key)) {
62
+ if (identity.isScalar(key)) {
57
63
  if (seenKeys.includes(key.value)) {
58
64
  onError(`Ordered maps must not include duplicate keys: ${key.value}`);
59
65
  }
@@ -64,12 +70,7 @@ const omap = {
64
70
  }
65
71
  return Object.assign(new YAMLOMap(), pairs$1);
66
72
  },
67
- createNode(schema, iterable, ctx) {
68
- const pairs$1 = pairs.createPairs(schema, iterable, ctx);
69
- const omap = new YAMLOMap();
70
- omap.items = pairs$1.items;
71
- return omap;
72
- }
73
+ createNode: (schema, iterable, ctx) => YAMLOMap.from(schema, iterable, ctx)
73
74
  };
74
75
 
75
76
  exports.YAMLOMap = YAMLOMap;
@@ -1,5 +1,5 @@
1
1
  import type { CreateNodeContext } from '../../doc/createNode.js';
2
- import { ParsedNode } from '../../nodes/Node.js';
2
+ import type { ParsedNode } from '../../nodes/Node.js';
3
3
  import { Pair } from '../../nodes/Pair.js';
4
4
  import { YAMLMap } from '../../nodes/YAMLMap.js';
5
5
  import { YAMLSeq } from '../../nodes/YAMLSeq.js';
@@ -1,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var Node = require('../../nodes/Node.js');
3
+ var identity = require('../../nodes/identity.js');
4
4
  var Pair = require('../../nodes/Pair.js');
5
5
  var Scalar = require('../../nodes/Scalar.js');
6
6
  var YAMLSeq = require('../../nodes/YAMLSeq.js');
7
7
 
8
8
  function resolvePairs(seq, onError) {
9
- if (Node.isSeq(seq)) {
9
+ if (identity.isSeq(seq)) {
10
10
  for (let i = 0; i < seq.items.length; ++i) {
11
11
  let item = seq.items[i];
12
- if (Node.isPair(item))
12
+ if (identity.isPair(item))
13
13
  continue;
14
- else if (Node.isMap(item)) {
14
+ else if (identity.isMap(item)) {
15
15
  if (item.items.length > 1)
16
16
  onError('Each pair must have its own sequence indicator');
17
17
  const pair = item.items[0] || new Pair.Pair(new Scalar.Scalar(null));
@@ -27,7 +27,7 @@ function resolvePairs(seq, onError) {
27
27
  }
28
28
  item = pair;
29
29
  }
30
- seq.items[i] = Node.isPair(item) ? item : new Pair.Pair(item);
30
+ seq.items[i] = identity.isPair(item) ? item : new Pair.Pair(item);
31
31
  }
32
32
  }
33
33
  else
@@ -1 +1 @@
1
- export declare const schema: (import("../types.js").ScalarTag | import("../types.js").CollectionTag)[];
1
+ export declare const schema: (import("../types.js").CollectionTag | import("../types.js").ScalarTag)[];
@@ -1,9 +1,10 @@
1
- import type { Schema } from '../../schema/Schema.js';
2
1
  import { Pair } from '../../nodes/Pair.js';
3
2
  import { Scalar } from '../../nodes/Scalar.js';
4
3
  import { ToJSContext } from '../../nodes/toJS.js';
5
4
  import { YAMLMap } from '../../nodes/YAMLMap.js';
5
+ import type { Schema } from '../../schema/Schema.js';
6
6
  import type { StringifyContext } from '../../stringify/stringify.js';
7
+ import { CreateNodeContext } from '../../util.js';
7
8
  import type { CollectionTag } from '../types.js';
8
9
  export declare class YAMLSet<T = unknown> extends YAMLMap<T, Scalar<null> | null> {
9
10
  static tag: string;
@@ -22,5 +23,6 @@ export declare class YAMLSet<T = unknown> extends YAMLMap<T, Scalar<null> | null
22
23
  set(key: T, value: null): void;
23
24
  toJSON(_?: unknown, ctx?: ToJSContext): any;
24
25
  toString(ctx?: StringifyContext, onComment?: () => void, onChompKeep?: () => void): string;
26
+ static from(schema: Schema, iterable: unknown, ctx: CreateNodeContext): YAMLSet<unknown>;
25
27
  }
26
28
  export declare const set: CollectionTag;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var Node = require('../../nodes/Node.js');
3
+ var identity = require('../../nodes/identity.js');
4
4
  var Pair = require('../../nodes/Pair.js');
5
5
  var YAMLMap = require('../../nodes/YAMLMap.js');
6
6
 
@@ -11,7 +11,7 @@ class YAMLSet extends YAMLMap.YAMLMap {
11
11
  }
12
12
  add(key) {
13
13
  let pair;
14
- if (Node.isPair(key))
14
+ if (identity.isPair(key))
15
15
  pair = key;
16
16
  else if (key &&
17
17
  typeof key === 'object' &&
@@ -31,8 +31,8 @@ class YAMLSet extends YAMLMap.YAMLMap {
31
31
  */
32
32
  get(key, keepPair) {
33
33
  const pair = YAMLMap.findPair(this.items, key);
34
- return !keepPair && Node.isPair(pair)
35
- ? Node.isScalar(pair.key)
34
+ return !keepPair && identity.isPair(pair)
35
+ ? identity.isScalar(pair.key)
36
36
  ? pair.key.value
37
37
  : pair.key
38
38
  : pair;
@@ -59,6 +59,17 @@ class YAMLSet extends YAMLMap.YAMLMap {
59
59
  else
60
60
  throw new Error('Set items must all have null values');
61
61
  }
62
+ static from(schema, iterable, ctx) {
63
+ const { replacer } = ctx;
64
+ const set = new this(schema);
65
+ if (iterable && Symbol.iterator in Object(iterable))
66
+ for (let value of iterable) {
67
+ if (typeof replacer === 'function')
68
+ value = replacer.call(iterable, value, value);
69
+ set.items.push(Pair.createPair(value, null, ctx));
70
+ }
71
+ return set;
72
+ }
62
73
  }
63
74
  YAMLSet.tag = 'tag:yaml.org,2002:set';
64
75
  const set = {
@@ -67,8 +78,9 @@ const set = {
67
78
  nodeClass: YAMLSet,
68
79
  default: false,
69
80
  tag: 'tag:yaml.org,2002:set',
81
+ createNode: (schema, iterable, ctx) => YAMLSet.from(schema, iterable, ctx),
70
82
  resolve(map, onError) {
71
- if (Node.isMap(map)) {
83
+ if (identity.isMap(map)) {
72
84
  if (map.hasAllNullValues(true))
73
85
  return Object.assign(new YAMLSet(), map);
74
86
  else
@@ -77,17 +89,6 @@ const set = {
77
89
  else
78
90
  onError('Expected a mapping for this tag');
79
91
  return map;
80
- },
81
- createNode(schema, iterable, ctx) {
82
- const { replacer } = ctx;
83
- const set = new YAMLSet(schema);
84
- if (iterable && Symbol.iterator in Object(iterable))
85
- for (let value of iterable) {
86
- if (typeof replacer === 'function')
87
- value = replacer.call(iterable, value, value);
88
- set.items.push(Pair.createPair(value, null, ctx));
89
- }
90
- return set;
91
92
  }
92
93
  };
93
94
 
@@ -45,7 +45,7 @@ function stringifySexagesimal(node) {
45
45
  }
46
46
  return (sign +
47
47
  parts
48
- .map(n => (n < 10 ? '0' + String(n) : String(n)))
48
+ .map(n => String(n).padStart(2, '0'))
49
49
  .join(':')
50
50
  .replace(/000000\d*$/, '') // % 60 may introduce error
51
51
  );
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var anchors = require('../doc/anchors.js');
4
- var Node = require('../nodes/Node.js');
4
+ var identity = require('../nodes/identity.js');
5
5
  var stringifyComment = require('./stringifyComment.js');
6
6
  var stringifyString = require('./stringifyString.js');
7
7
 
@@ -54,7 +54,7 @@ function getTagObject(tags, item) {
54
54
  }
55
55
  let tagObj = undefined;
56
56
  let obj;
57
- if (Node.isScalar(item)) {
57
+ if (identity.isScalar(item)) {
58
58
  obj = item.value;
59
59
  const match = tags.filter(t => t.identify?.(obj));
60
60
  tagObj =
@@ -75,7 +75,7 @@ function stringifyProps(node, tagObj, { anchors: anchors$1, doc }) {
75
75
  if (!doc.directives)
76
76
  return '';
77
77
  const props = [];
78
- const anchor = (Node.isScalar(node) || Node.isCollection(node)) && node.anchor;
78
+ const anchor = (identity.isScalar(node) || identity.isCollection(node)) && node.anchor;
79
79
  if (anchor && anchors.anchorIsValid(anchor)) {
80
80
  anchors$1.add(anchor);
81
81
  props.push(`&${anchor}`);
@@ -86,9 +86,9 @@ function stringifyProps(node, tagObj, { anchors: anchors$1, doc }) {
86
86
  return props.join(' ');
87
87
  }
88
88
  function stringify(item, ctx, onComment, onChompKeep) {
89
- if (Node.isPair(item))
89
+ if (identity.isPair(item))
90
90
  return item.toString(ctx, onComment, onChompKeep);
91
- if (Node.isAlias(item)) {
91
+ if (identity.isAlias(item)) {
92
92
  if (ctx.doc.directives)
93
93
  return item.toString(ctx);
94
94
  if (ctx.resolvedAliases?.has(item)) {
@@ -103,7 +103,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
103
103
  }
104
104
  }
105
105
  let tagObj = undefined;
106
- const node = Node.isNode(item)
106
+ const node = identity.isNode(item)
107
107
  ? item
108
108
  : ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
109
109
  if (!tagObj)
@@ -113,12 +113,12 @@ function stringify(item, ctx, onComment, onChompKeep) {
113
113
  ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
114
114
  const str = typeof tagObj.stringify === 'function'
115
115
  ? tagObj.stringify(node, ctx, onComment, onChompKeep)
116
- : Node.isScalar(node)
116
+ : identity.isScalar(node)
117
117
  ? stringifyString.stringifyString(node, ctx, onComment, onChompKeep)
118
118
  : node.toString(ctx, onComment, onChompKeep);
119
119
  if (!props)
120
120
  return str;
121
- return Node.isScalar(node) || str[0] === '{' || str[0] === '['
121
+ return identity.isScalar(node) || str[0] === '{' || str[0] === '['
122
122
  ? `${props} ${str}`
123
123
  : `${props}\n${ctx.indent}${str}`;
124
124
  }
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var Collection = require('../nodes/Collection.js');
4
- var Node = require('../nodes/Node.js');
4
+ var identity = require('../nodes/identity.js');
5
5
  var stringify = require('./stringify.js');
6
6
  var stringifyComment = require('./stringifyComment.js');
7
7
 
@@ -18,15 +18,15 @@ function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, fl
18
18
  for (let i = 0; i < items.length; ++i) {
19
19
  const item = items[i];
20
20
  let comment = null;
21
- if (Node.isNode(item)) {
21
+ if (identity.isNode(item)) {
22
22
  if (!chompKeep && item.spaceBefore)
23
23
  lines.push('');
24
24
  addCommentBefore(ctx, lines, item.commentBefore, chompKeep);
25
25
  if (item.comment)
26
26
  comment = item.comment;
27
27
  }
28
- else if (Node.isPair(item)) {
29
- const ik = Node.isNode(item.key) ? item.key : null;
28
+ else if (identity.isPair(item)) {
29
+ const ik = identity.isNode(item.key) ? item.key : null;
30
30
  if (ik) {
31
31
  if (!chompKeep && ik.spaceBefore)
32
32
  lines.push('');
@@ -75,15 +75,15 @@ function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemInden
75
75
  for (let i = 0; i < items.length; ++i) {
76
76
  const item = items[i];
77
77
  let comment = null;
78
- if (Node.isNode(item)) {
78
+ if (identity.isNode(item)) {
79
79
  if (item.spaceBefore)
80
80
  lines.push('');
81
81
  addCommentBefore(ctx, lines, item.commentBefore, false);
82
82
  if (item.comment)
83
83
  comment = item.comment;
84
84
  }
85
- else if (Node.isPair(item)) {
86
- const ik = Node.isNode(item.key) ? item.key : null;
85
+ else if (identity.isPair(item)) {
86
+ const ik = identity.isNode(item.key) ? item.key : null;
87
87
  if (ik) {
88
88
  if (ik.spaceBefore)
89
89
  lines.push('');
@@ -91,7 +91,7 @@ function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemInden
91
91
  if (ik.comment)
92
92
  reqNewline = true;
93
93
  }
94
- const iv = Node.isNode(item.value) ? item.value : null;
94
+ const iv = identity.isNode(item.value) ? item.value : null;
95
95
  if (iv) {
96
96
  if (iv.comment)
97
97
  comment = iv.comment;
@@ -1,3 +1,4 @@
1
- import { Document } from '../doc/Document.js';
2
- import { ToStringOptions } from '../options.js';
3
- export declare function stringifyDocument(doc: Readonly<Document>, options: ToStringOptions): string;
1
+ import type { Document } from '../doc/Document.js';
2
+ import type { Node } from '../nodes/Node.js';
3
+ import type { ToStringOptions } from '../options.js';
4
+ export declare function stringifyDocument(doc: Readonly<Document<Node, boolean>>, options: ToStringOptions): string;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var Node = require('../nodes/Node.js');
3
+ var identity = require('../nodes/identity.js');
4
4
  var stringify = require('./stringify.js');
5
5
  var stringifyComment = require('./stringifyComment.js');
6
6
 
@@ -29,7 +29,7 @@ function stringifyDocument(doc, options) {
29
29
  let chompKeep = false;
30
30
  let contentComment = null;
31
31
  if (doc.contents) {
32
- if (Node.isNode(doc.contents)) {
32
+ if (identity.isNode(doc.contents)) {
33
33
  if (doc.contents.spaceBefore && hasDirectives)
34
34
  lines.push('');
35
35
  if (doc.contents.commentBefore) {
@@ -1,18 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var Node = require('../nodes/Node.js');
3
+ var identity = require('../nodes/identity.js');
4
4
  var Scalar = require('../nodes/Scalar.js');
5
5
  var stringify = require('./stringify.js');
6
6
  var stringifyComment = require('./stringifyComment.js');
7
7
 
8
8
  function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
9
9
  const { allNullValues, doc, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx;
10
- let keyComment = (Node.isNode(key) && key.comment) || null;
10
+ let keyComment = (identity.isNode(key) && key.comment) || null;
11
11
  if (simpleKeys) {
12
12
  if (keyComment) {
13
13
  throw new Error('With simple keys, key nodes cannot have comments');
14
14
  }
15
- if (Node.isCollection(key)) {
15
+ if (identity.isCollection(key)) {
16
16
  const msg = 'With simple keys, collection cannot be used as a key value';
17
17
  throw new Error(msg);
18
18
  }
@@ -20,8 +20,8 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
20
20
  let explicitKey = !simpleKeys &&
21
21
  (!key ||
22
22
  (keyComment && value == null && !ctx.inFlow) ||
23
- Node.isCollection(key) ||
24
- (Node.isScalar(key)
23
+ identity.isCollection(key) ||
24
+ (identity.isScalar(key)
25
25
  ? key.type === Scalar.Scalar.BLOCK_FOLDED || key.type === Scalar.Scalar.BLOCK_LITERAL
26
26
  : typeof key === 'object'));
27
27
  ctx = Object.assign({}, ctx, {
@@ -66,7 +66,7 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
66
66
  str += stringifyComment.lineComment(str, ctx.indent, commentString(keyComment));
67
67
  }
68
68
  let vsb, vcb, valueComment;
69
- if (Node.isNode(value)) {
69
+ if (identity.isNode(value)) {
70
70
  vsb = !!value.spaceBefore;
71
71
  vcb = value.commentBefore;
72
72
  valueComment = value.comment;
@@ -79,14 +79,14 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
79
79
  value = doc.createNode(value);
80
80
  }
81
81
  ctx.implicitKey = false;
82
- if (!explicitKey && !keyComment && Node.isScalar(value))
82
+ if (!explicitKey && !keyComment && identity.isScalar(value))
83
83
  ctx.indentAtStart = str.length + 1;
84
84
  chompKeep = false;
85
85
  if (!indentSeq &&
86
86
  indentStep.length >= 2 &&
87
87
  !ctx.inFlow &&
88
88
  !explicitKey &&
89
- Node.isSeq(value) &&
89
+ identity.isSeq(value) &&
90
90
  !value.flow &&
91
91
  !value.tag &&
92
92
  !value.anchor) {
@@ -110,7 +110,7 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
110
110
  ws += `\n${ctx.indent}`;
111
111
  }
112
112
  }
113
- else if (!explicitKey && Node.isCollection(value)) {
113
+ else if (!explicitKey && identity.isCollection(value)) {
114
114
  const vs0 = valueStr[0];
115
115
  const nl0 = valueStr.indexOf('\n');
116
116
  const hasNewline = nl0 !== -1;
@@ -148,6 +148,15 @@ function quotedString(value, ctx) {
148
148
  }
149
149
  return qs(value, ctx);
150
150
  }
151
+ // The negative lookbehind avoids a polynomial search,
152
+ // but isn't supported yet on Safari: https://caniuse.com/js-regexp-lookbehind
153
+ let blockEndNewlines;
154
+ try {
155
+ blockEndNewlines = new RegExp('(^|(?<!\n))\n+(?!\n|$)', 'g');
156
+ }
157
+ catch {
158
+ blockEndNewlines = /\n+(?!\n|$)/g;
159
+ }
151
160
  function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
152
161
  const { blockQuote, commentString, lineWidth } = ctx.options;
153
162
  // 1. Block can't end in whitespace unless the last line is non-empty.
@@ -191,7 +200,7 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
191
200
  value = value.slice(0, -end.length);
192
201
  if (end[end.length - 1] === '\n')
193
202
  end = end.slice(0, -1);
194
- end = end.replace(/\n+(?!\n|$)/g, `$&${indent}`);
203
+ end = end.replace(blockEndNewlines, `$&${indent}`);
195
204
  }
196
205
  // determine indent indicator from whitespace at value start
197
206
  let startWithSpace = false;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var Node = require('./nodes/Node.js');
3
+ var identity = require('./nodes/identity.js');
4
4
  var publicApi = require('./public-api.js');
5
5
  var visit = require('./visit.js');
6
6
 
@@ -66,10 +66,10 @@ function addEvents(events, doc, errPos, node) {
66
66
  events.push('=VAL :');
67
67
  return;
68
68
  }
69
- if (errPos !== -1 && Node.isNode(node) && node.range[0] >= errPos)
69
+ if (errPos !== -1 && identity.isNode(node) && node.range[0] >= errPos)
70
70
  throw new Error();
71
71
  let props = '';
72
- let anchor = Node.isScalar(node) || Node.isCollection(node) ? node.anchor : undefined;
72
+ let anchor = identity.isScalar(node) || identity.isCollection(node) ? node.anchor : undefined;
73
73
  if (anchor) {
74
74
  if (/\d$/.test(anchor)) {
75
75
  const alt = anchor.replace(/\d$/, '');
@@ -78,9 +78,9 @@ function addEvents(events, doc, errPos, node) {
78
78
  }
79
79
  props = ` &${anchor}`;
80
80
  }
81
- if (Node.isNode(node) && node.tag)
81
+ if (identity.isNode(node) && node.tag)
82
82
  props += ` <${node.tag}>`;
83
- if (Node.isMap(node)) {
83
+ if (identity.isMap(node)) {
84
84
  const ev = node.flow ? '+MAP {}' : '+MAP';
85
85
  events.push(`${ev}${props}`);
86
86
  node.items.forEach(({ key, value }) => {
@@ -89,7 +89,7 @@ function addEvents(events, doc, errPos, node) {
89
89
  });
90
90
  events.push('-MAP');
91
91
  }
92
- else if (Node.isSeq(node)) {
92
+ else if (identity.isSeq(node)) {
93
93
  const ev = node.flow ? '+SEQ []' : '+SEQ';
94
94
  events.push(`${ev}${props}`);
95
95
  node.items.forEach(item => {
@@ -97,13 +97,13 @@ function addEvents(events, doc, errPos, node) {
97
97
  });
98
98
  events.push('-SEQ');
99
99
  }
100
- else if (Node.isPair(node)) {
100
+ else if (identity.isPair(node)) {
101
101
  events.push(`+MAP${props}`);
102
102
  addEvents(events, doc, errPos, node.key);
103
103
  addEvents(events, doc, errPos, node.value);
104
104
  events.push('-MAP');
105
105
  }
106
- else if (Node.isAlias(node)) {
106
+ else if (identity.isAlias(node)) {
107
107
  let alias = node.source;
108
108
  if (alias && /\d$/.test(alias)) {
109
109
  const alt = alias.replace(/\d$/, '');
@@ -1,9 +1,12 @@
1
+ export { createNode, CreateNodeContext } from './doc/createNode.js';
1
2
  export { debug, LogLevelId, warn } from './log.js';
3
+ export { createPair } from './nodes/Pair.js';
2
4
  export { findPair } from './nodes/YAMLMap.js';
3
5
  export { toJS, ToJSContext } from './nodes/toJS.js';
4
6
  export { map as mapTag } from './schema/common/map.js';
5
7
  export { seq as seqTag } from './schema/common/seq.js';
6
8
  export { string as stringTag } from './schema/common/string.js';
7
- export { foldFlowLines } from './stringify/foldFlowLines';
9
+ export { foldFlowLines, FoldOptions } from './stringify/foldFlowLines';
10
+ export { StringifyContext } from './stringify/stringify.js';
8
11
  export { stringifyNumber } from './stringify/stringifyNumber.js';
9
12
  export { stringifyString } from './stringify/stringifyString.js';
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ var createNode = require('./doc/createNode.js');
3
4
  var log = require('./log.js');
5
+ var Pair = require('./nodes/Pair.js');
4
6
  var YAMLMap = require('./nodes/YAMLMap.js');
5
7
  var toJS = require('./nodes/toJS.js');
6
8
  var map = require('./schema/common/map.js');
@@ -12,8 +14,10 @@ var stringifyString = require('./stringify/stringifyString.js');
12
14
 
13
15
 
14
16
 
17
+ exports.createNode = createNode.createNode;
15
18
  exports.debug = log.debug;
16
19
  exports.warn = log.warn;
20
+ exports.createPair = Pair.createPair;
17
21
  exports.findPair = YAMLMap.findPair;
18
22
  exports.toJS = toJS.toJS;
19
23
  exports.mapTag = map.map;