@runeditrun/rer 0.2.83 → 0.2.85

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 (269) hide show
  1. package/README.md +21 -24
  2. package/cli/README.md +17 -1
  3. package/cli/authoring.mjs +1 -0
  4. package/cli/bounded.mjs +1 -1
  5. package/cli/business/carry.mjs +149 -0
  6. package/cli/business/command.mjs +6 -1
  7. package/cli/business/connect.mjs +1 -1
  8. package/cli/business/local-commands.mjs +2 -0
  9. package/cli/business/opt-ins.mjs +8 -4
  10. package/cli/business/questions.mjs +4 -1
  11. package/cli/business/state.mjs +1 -1
  12. package/cli/business/supervisor.mjs +7 -1
  13. package/cli/container-transfer.mjs +2 -2
  14. package/cli/contract.mjs +7 -7
  15. package/cli/demo-host.mjs +5 -1
  16. package/cli/demo-native.mjs +2 -1
  17. package/cli/demo.mjs +6 -1
  18. package/cli/deploy-command.mjs +6 -4
  19. package/cli/deploy.mjs +9 -7
  20. package/cli/errors.mjs +1 -1
  21. package/cli/export.mjs +1 -1
  22. package/cli/human-error.mjs +20 -0
  23. package/cli/lifecycle.mjs +23 -5
  24. package/cli/main.mjs +1 -1
  25. package/cli/managed-data-schema.mjs +114 -0
  26. package/cli/managed-data-zip.mjs +116 -0
  27. package/cli/managed-data.mjs +110 -0
  28. package/cli/managed-server.mjs +25 -14
  29. package/cli/native-owner-entry.mjs +86 -0
  30. package/cli/output.mjs +3 -2
  31. package/cli/parse.mjs +3 -3
  32. package/cli/portability-empty.mjs +59 -0
  33. package/cli/portability-migrations.mjs +7 -5
  34. package/cli/portability-policy.mjs +5 -2
  35. package/cli/portability-worker.mjs +15 -6
  36. package/cli/portability.mjs +30 -8
  37. package/cli/ready-summary.mjs +9 -0
  38. package/cli/run-transfers.mjs +37 -0
  39. package/cli/runtime-front-door.mjs +4 -4
  40. package/cli/server-proxy.mjs +4 -3
  41. package/cli/server-registry.mjs +13 -8
  42. package/cli/site.mjs +6 -1
  43. package/cli/transfers.mjs +17 -4
  44. package/edition-authoring/base-copies.mjs +125 -30
  45. package/edition-authoring/copy-checkout.mjs +7 -120
  46. package/edition-authoring/edition-migrations.mjs +41 -0
  47. package/edition-authoring/files.mjs +67 -0
  48. package/edition-authoring/lock.mjs +2 -2
  49. package/edition-authoring/module-closure.mjs +232 -0
  50. package/edition-authoring/module-edges.mjs +100 -0
  51. package/edition-authoring/module-resolution.mjs +66 -0
  52. package/edition-authoring/module-syntax.mjs +57 -0
  53. package/edition-authoring/package-target.mjs +92 -0
  54. package/edition-authoring/runtime-dependencies.mjs +74 -97
  55. package/edition-authoring/vendor/babel-parser/LICENSE +22 -0
  56. package/edition-authoring/vendor/babel-parser/README.md +21 -0
  57. package/edition-authoring/vendor/babel-parser/babel-helper-string-parser/index.mjs +292 -0
  58. package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/identifier.mjs +66 -0
  59. package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/index.mjs +13 -0
  60. package/edition-authoring/vendor/babel-parser/babel-helper-validator-identifier/keyword.mjs +31 -0
  61. package/edition-authoring/vendor/babel-parser/babel-parser/index.mjs +99 -0
  62. package/edition-authoring/vendor/babel-parser/babel-parser/options.mjs +81 -0
  63. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/bind-operator-errors.mjs +8 -0
  64. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/module-errors.mjs +15 -0
  65. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/parse-expression-errors.mjs +10 -0
  66. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/pipeline-operator-errors.mjs +29 -0
  67. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/standard-errors.mjs +224 -0
  68. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/strict-mode-errors.mjs +17 -0
  69. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error/to-node-description.mjs +31 -0
  70. package/edition-authoring/vendor/babel-parser/babel-parser/parse-error.mjs +114 -0
  71. package/edition-authoring/vendor/babel-parser/babel-parser/parser/base.mjs +34 -0
  72. package/edition-authoring/vendor/babel-parser/babel-parser/parser/comments.mjs +199 -0
  73. package/edition-authoring/vendor/babel-parser/babel-parser/parser/expression.mjs +1794 -0
  74. package/edition-authoring/vendor/babel-parser/babel-parser/parser/index.mjs +76 -0
  75. package/edition-authoring/vendor/babel-parser/babel-parser/parser/lval.mjs +439 -0
  76. package/edition-authoring/vendor/babel-parser/babel-parser/parser/node.mjs +111 -0
  77. package/edition-authoring/vendor/babel-parser/babel-parser/parser/statement.mjs +1962 -0
  78. package/edition-authoring/vendor/babel-parser/babel-parser/parser/util.mjs +244 -0
  79. package/edition-authoring/vendor/babel-parser/babel-parser/plugin-utils.mjs +116 -0
  80. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/estree.mjs +417 -0
  81. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/flow/index.mjs +2412 -0
  82. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/flow/scope.mjs +37 -0
  83. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/jsx/index.mjs +420 -0
  84. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/jsx/xhtml.mjs +261 -0
  85. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/placeholders.mjs +205 -0
  86. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/typescript/index.mjs +2889 -0
  87. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/typescript/scope.mjs +115 -0
  88. package/edition-authoring/vendor/babel-parser/babel-parser/plugins/v8intrinsic.mjs +26 -0
  89. package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/context.mjs +22 -0
  90. package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/index.mjs +1037 -0
  91. package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/state.mjs +178 -0
  92. package/edition-authoring/vendor/babel-parser/babel-parser/tokenizer/types.mjs +583 -0
  93. package/edition-authoring/vendor/babel-parser/babel-parser/types.mjs +1 -0
  94. package/edition-authoring/vendor/babel-parser/babel-parser/util/class-scope.mjs +82 -0
  95. package/edition-authoring/vendor/babel-parser/babel-parser/util/expression-scope.mjs +121 -0
  96. package/edition-authoring/vendor/babel-parser/babel-parser/util/identifier.mjs +23 -0
  97. package/edition-authoring/vendor/babel-parser/babel-parser/util/location.mjs +34 -0
  98. package/edition-authoring/vendor/babel-parser/babel-parser/util/production-parameter.mjs +40 -0
  99. package/edition-authoring/vendor/babel-parser/babel-parser/util/scope.mjs +173 -0
  100. package/edition-authoring/vendor/babel-parser/babel-parser/util/scopeflags.mjs +66 -0
  101. package/edition-authoring/vendor/babel-parser/babel-parser/util/whitespace.mjs +61 -0
  102. package/edition-authoring/vendor/yaml/LICENSE +13 -0
  103. package/edition-authoring/vendor/yaml/README.md +11 -0
  104. package/edition-authoring/vendor/yaml/compose/compose-collection.mjs +88 -0
  105. package/edition-authoring/vendor/yaml/compose/compose-doc.mjs +43 -0
  106. package/edition-authoring/vendor/yaml/compose/compose-node.mjs +110 -0
  107. package/edition-authoring/vendor/yaml/compose/compose-scalar.mjs +86 -0
  108. package/edition-authoring/vendor/yaml/compose/composer.mjs +218 -0
  109. package/edition-authoring/vendor/yaml/compose/resolve-block-map.mjs +115 -0
  110. package/edition-authoring/vendor/yaml/compose/resolve-block-scalar.mjs +198 -0
  111. package/edition-authoring/vendor/yaml/compose/resolve-block-seq.mjs +49 -0
  112. package/edition-authoring/vendor/yaml/compose/resolve-end.mjs +37 -0
  113. package/edition-authoring/vendor/yaml/compose/resolve-flow-collection.mjs +207 -0
  114. package/edition-authoring/vendor/yaml/compose/resolve-flow-scalar.mjs +228 -0
  115. package/edition-authoring/vendor/yaml/compose/resolve-props.mjs +148 -0
  116. package/edition-authoring/vendor/yaml/compose/util-contains-newline.mjs +34 -0
  117. package/edition-authoring/vendor/yaml/compose/util-empty-scalar-position.mjs +27 -0
  118. package/edition-authoring/vendor/yaml/compose/util-flow-indent-check.mjs +15 -0
  119. package/edition-authoring/vendor/yaml/compose/util-map-includes.mjs +13 -0
  120. package/edition-authoring/vendor/yaml/doc/Document.mjs +333 -0
  121. package/edition-authoring/vendor/yaml/doc/anchors.mjs +74 -0
  122. package/edition-authoring/vendor/yaml/doc/applyReviver.mjs +54 -0
  123. package/edition-authoring/vendor/yaml/doc/createNode.mjs +88 -0
  124. package/edition-authoring/vendor/yaml/doc/directives.mjs +176 -0
  125. package/edition-authoring/vendor/yaml/errors.mjs +57 -0
  126. package/edition-authoring/vendor/yaml/index.mjs +17 -0
  127. package/edition-authoring/vendor/yaml/log.mjs +11 -0
  128. package/edition-authoring/vendor/yaml/nodes/Alias.mjs +119 -0
  129. package/edition-authoring/vendor/yaml/nodes/Collection.mjs +147 -0
  130. package/edition-authoring/vendor/yaml/nodes/Node.mjs +38 -0
  131. package/edition-authoring/vendor/yaml/nodes/Pair.mjs +36 -0
  132. package/edition-authoring/vendor/yaml/nodes/Scalar.mjs +24 -0
  133. package/edition-authoring/vendor/yaml/nodes/YAMLMap.mjs +144 -0
  134. package/edition-authoring/vendor/yaml/nodes/YAMLSeq.mjs +113 -0
  135. package/edition-authoring/vendor/yaml/nodes/addPairToJSMap.mjs +62 -0
  136. package/edition-authoring/vendor/yaml/nodes/identity.mjs +36 -0
  137. package/edition-authoring/vendor/yaml/nodes/toJS.mjs +35 -0
  138. package/edition-authoring/vendor/yaml/parse/cst-scalar.mjs +214 -0
  139. package/edition-authoring/vendor/yaml/parse/cst-stringify.mjs +61 -0
  140. package/edition-authoring/vendor/yaml/parse/cst-visit.mjs +97 -0
  141. package/edition-authoring/vendor/yaml/parse/cst.mjs +98 -0
  142. package/edition-authoring/vendor/yaml/parse/lexer.mjs +722 -0
  143. package/edition-authoring/vendor/yaml/parse/line-counter.mjs +39 -0
  144. package/edition-authoring/vendor/yaml/parse/parser.mjs +975 -0
  145. package/edition-authoring/vendor/yaml/public-api.mjs +102 -0
  146. package/edition-authoring/vendor/yaml/schema/Schema.mjs +37 -0
  147. package/edition-authoring/vendor/yaml/schema/common/map.mjs +17 -0
  148. package/edition-authoring/vendor/yaml/schema/common/null.mjs +15 -0
  149. package/edition-authoring/vendor/yaml/schema/common/seq.mjs +17 -0
  150. package/edition-authoring/vendor/yaml/schema/common/string.mjs +14 -0
  151. package/edition-authoring/vendor/yaml/schema/core/bool.mjs +19 -0
  152. package/edition-authoring/vendor/yaml/schema/core/float.mjs +43 -0
  153. package/edition-authoring/vendor/yaml/schema/core/int.mjs +38 -0
  154. package/edition-authoring/vendor/yaml/schema/core/schema.mjs +23 -0
  155. package/edition-authoring/vendor/yaml/schema/json/schema.mjs +62 -0
  156. package/edition-authoring/vendor/yaml/schema/tags.mjs +96 -0
  157. package/edition-authoring/vendor/yaml/schema/yaml-1.1/binary.mjs +59 -0
  158. package/edition-authoring/vendor/yaml/schema/yaml-1.1/bool.mjs +26 -0
  159. package/edition-authoring/vendor/yaml/schema/yaml-1.1/float.mjs +46 -0
  160. package/edition-authoring/vendor/yaml/schema/yaml-1.1/int.mjs +71 -0
  161. package/edition-authoring/vendor/yaml/schema/yaml-1.1/merge.mjs +67 -0
  162. package/edition-authoring/vendor/yaml/schema/yaml-1.1/omap.mjs +74 -0
  163. package/edition-authoring/vendor/yaml/schema/yaml-1.1/pairs.mjs +78 -0
  164. package/edition-authoring/vendor/yaml/schema/yaml-1.1/schema.mjs +39 -0
  165. package/edition-authoring/vendor/yaml/schema/yaml-1.1/set.mjs +93 -0
  166. package/edition-authoring/vendor/yaml/schema/yaml-1.1/timestamp.mjs +101 -0
  167. package/edition-authoring/vendor/yaml/stringify/foldFlowLines.mjs +146 -0
  168. package/edition-authoring/vendor/yaml/stringify/stringify.mjs +130 -0
  169. package/edition-authoring/vendor/yaml/stringify/stringifyCollection.mjs +155 -0
  170. package/edition-authoring/vendor/yaml/stringify/stringifyComment.mjs +20 -0
  171. package/edition-authoring/vendor/yaml/stringify/stringifyDocument.mjs +85 -0
  172. package/edition-authoring/vendor/yaml/stringify/stringifyNumber.mjs +25 -0
  173. package/edition-authoring/vendor/yaml/stringify/stringifyPair.mjs +150 -0
  174. package/edition-authoring/vendor/yaml/stringify/stringifyString.mjs +338 -0
  175. package/edition-authoring/vendor/yaml/util.mjs +11 -0
  176. package/edition-authoring/vendor/yaml/visit.mjs +233 -0
  177. package/edition-authoring/workflow-copies.mjs +125 -0
  178. package/edition-authoring/workflow-scripts.mjs +112 -0
  179. package/foundation/runtime/contract-docs.mjs +754 -0
  180. package/foundation/runtime/run-data.d.mts +1 -0
  181. package/foundation/runtime/run-data.mjs +2 -0
  182. package/global/CHANGELOG.md +55 -3
  183. package/global/README.md +21 -24
  184. package/global/cli/command.mjs +8 -2
  185. package/global/cli/install.mjs +4 -5
  186. package/global/cli/path-link.mjs +3 -2
  187. package/global/cli/repo-command.mjs +3 -7
  188. package/global/launch/dev.mjs +12 -2
  189. package/global/launch/facts.mjs +2 -2
  190. package/global/launch/render.mjs +16 -9
  191. package/global/launch/state.mjs +4 -4
  192. package/global/main.mjs +12 -7
  193. package/install.sh +17 -6
  194. package/modules/container/README.md +6 -1
  195. package/modules/container/adapters/d1-limits.mjs +286 -0
  196. package/modules/container/adapters/d1-sqlite.mjs +95 -0
  197. package/modules/container/adapters/d1-workerd-preload.mjs +19 -0
  198. package/modules/container/adapters/d1-workerd-setup.mjs +26 -0
  199. package/modules/container/adapters/d1-workerd.mjs +5 -0
  200. package/modules/container/adapters/sqlite-worker.mjs +5 -3
  201. package/modules/container/build.mjs +1 -0
  202. package/modules/container/image-variables.mjs +8 -3
  203. package/modules/container/transfer.mjs +14 -4
  204. package/modules/container/worker-engine.mjs +3 -3
  205. package/modules/demo/declaration.mjs +1 -4
  206. package/modules/demo/vite.mjs +1 -1
  207. package/modules/demo-host/build.mjs +1 -0
  208. package/modules/demo-host/native/prepare.mjs +2 -1
  209. package/modules/demo-host/native/sql.mjs +7 -2
  210. package/modules/deploy-kit/README.md +23 -3
  211. package/modules/deploy-kit/d1-import-diagnostics.mjs +56 -0
  212. package/modules/deploy-kit/d1-import.mjs +17 -5
  213. package/modules/deploy-kit/diagnostics.mjs +29 -3
  214. package/modules/deploy-kit/owner-cli.mjs +20 -7
  215. package/modules/deploy-kit/provider-transport.mjs +19 -4
  216. package/modules/deploy-kit/provider.mjs +57 -22
  217. package/modules/deploy-kit/readiness-window.mjs +1 -1
  218. package/modules/deploy-kit/site.mjs +8 -3
  219. package/modules/deploy-kit/templates.mjs +3 -3
  220. package/modules/deploy-kit/worker.mjs +4 -4
  221. package/modules/import-kit/src/d1/README.md +23 -4
  222. package/modules/import-kit/src/d1/atomic-prefix.ts +2 -2
  223. package/modules/import-kit/src/d1/budget.ts +15 -7
  224. package/modules/import-kit/src/d1/column-layout.ts +5 -0
  225. package/modules/import-kit/src/d1/creation.ts +15 -8
  226. package/modules/import-kit/src/d1/database.ts +3 -3
  227. package/modules/import-kit/src/d1/erasure-pages.ts +2 -1
  228. package/modules/import-kit/src/d1/erasure.ts +2 -2
  229. package/modules/import-kit/src/d1/jobs.ts +10 -6
  230. package/modules/import-kit/src/d1/plans.ts +14 -8
  231. package/modules/import-kit/src/d1/retirement.ts +2 -2
  232. package/modules/import-kit/src/d1/sets.ts +1 -3
  233. package/modules/import-kit/src/d1/staged-creation.ts +3 -3
  234. package/modules/import-kit/src/door/limits.ts +1 -1
  235. package/modules/import-kit/src/door/refusals.ts +1 -1
  236. package/modules/portability/README.md +112 -4
  237. package/modules/portability/backfills.mjs +9 -8
  238. package/modules/portability/bridge.mjs +12 -5
  239. package/modules/portability/catalogue.mjs +12 -5
  240. package/modules/portability/files.mjs +4 -3
  241. package/modules/portability/http.mjs +3 -3
  242. package/modules/portability/import.mjs +18 -9
  243. package/modules/portability/index.d.mts +4 -3
  244. package/modules/portability/index.mjs +1 -1
  245. package/modules/portability/ledgers.mjs +3 -2
  246. package/modules/portability/legacy-safety.mjs +11 -2
  247. package/modules/portability/migration-history.mjs +2 -2
  248. package/modules/portability/progress.mjs +1 -0
  249. package/modules/portability/restore-empty.mjs +12 -0
  250. package/modules/release/github-verify.mjs +11 -2
  251. package/onboarding/adapter.mjs +35 -6
  252. package/onboarding/app-fetch.mjs +6 -4
  253. package/onboarding/development-runtime.mjs +19 -0
  254. package/onboarding/local/operation.mjs +45 -27
  255. package/onboarding/loopback-fetch.mjs +16 -0
  256. package/onboarding/operator-installer.mjs +4 -6
  257. package/onboarding/process-diagnostics.mjs +6 -2
  258. package/onboarding/production-runtime.mjs +4 -2
  259. package/onboarding/readiness.mjs +1 -0
  260. package/package.json +1 -1
  261. package/scripts/publish-check/README.md +6 -0
  262. package/scripts/publish-check/history_scan.py +5 -3
  263. package/scripts/publish-check/hygiene_config.py +2 -1
  264. package/scripts/publish-check/public_hygiene.py +1 -1
  265. package/scripts/publish-check/report.py +9 -3
  266. package/scripts/publish-check/third-party-notices.json +13 -0
  267. package/scripts/publish-check/third_party_notices.py +38 -0
  268. package/scripts/publish-check/tree_scan.py +6 -0
  269. package/scripts/publish-check.mjs +1 -1
@@ -0,0 +1,198 @@
1
+ import { Scalar } from '../nodes/Scalar.mjs';
2
+
3
+ function resolveBlockScalar(ctx, scalar, onError) {
4
+ const start = scalar.offset;
5
+ const header = parseBlockScalarHeader(scalar, ctx.options.strict, onError);
6
+ if (!header)
7
+ return { value: '', type: null, comment: '', range: [start, start, start] };
8
+ const type = header.mode === '>' ? Scalar.BLOCK_FOLDED : Scalar.BLOCK_LITERAL;
9
+ const lines = scalar.source ? splitLines(scalar.source) : [];
10
+ // determine the end of content & start of chomping
11
+ let chompStart = lines.length;
12
+ for (let i = lines.length - 1; i >= 0; --i) {
13
+ const content = lines[i][1];
14
+ if (content === '' || content === '\r')
15
+ chompStart = i;
16
+ else
17
+ break;
18
+ }
19
+ // shortcut for empty contents
20
+ if (chompStart === 0) {
21
+ const value = header.chomp === '+' && lines.length > 0
22
+ ? '\n'.repeat(Math.max(1, lines.length - 1))
23
+ : '';
24
+ let end = start + header.length;
25
+ if (scalar.source)
26
+ end += scalar.source.length;
27
+ return { value, type, comment: header.comment, range: [start, end, end] };
28
+ }
29
+ // find the indentation level to trim from start
30
+ let trimIndent = scalar.indent + header.indent;
31
+ let offset = scalar.offset + header.length;
32
+ let contentStart = 0;
33
+ for (let i = 0; i < chompStart; ++i) {
34
+ const [indent, content] = lines[i];
35
+ if (content === '' || content === '\r') {
36
+ if (header.indent === 0 && indent.length > trimIndent)
37
+ trimIndent = indent.length;
38
+ }
39
+ else {
40
+ if (indent.length < trimIndent) {
41
+ const message = 'Block scalars with more-indented leading empty lines must use an explicit indentation indicator';
42
+ onError(offset + indent.length, 'MISSING_CHAR', message);
43
+ }
44
+ if (header.indent === 0)
45
+ trimIndent = indent.length;
46
+ contentStart = i;
47
+ if (trimIndent === 0 && !ctx.atRoot) {
48
+ const message = 'Block scalar values in collections must be indented';
49
+ onError(offset, 'BAD_INDENT', message);
50
+ }
51
+ break;
52
+ }
53
+ offset += indent.length + content.length + 1;
54
+ }
55
+ // include trailing more-indented empty lines in content
56
+ for (let i = lines.length - 1; i >= chompStart; --i) {
57
+ if (lines[i][0].length > trimIndent)
58
+ chompStart = i + 1;
59
+ }
60
+ let value = '';
61
+ let sep = '';
62
+ let prevMoreIndented = false;
63
+ // leading whitespace is kept intact
64
+ for (let i = 0; i < contentStart; ++i)
65
+ value += lines[i][0].slice(trimIndent) + '\n';
66
+ for (let i = contentStart; i < chompStart; ++i) {
67
+ let [indent, content] = lines[i];
68
+ offset += indent.length + content.length + 1;
69
+ const crlf = content[content.length - 1] === '\r';
70
+ if (crlf)
71
+ content = content.slice(0, -1);
72
+ /* istanbul ignore if already caught in lexer */
73
+ if (content && indent.length < trimIndent) {
74
+ const src = header.indent
75
+ ? 'explicit indentation indicator'
76
+ : 'first line';
77
+ const message = `Block scalar lines must not be less indented than their ${src}`;
78
+ onError(offset - content.length - (crlf ? 2 : 1), 'BAD_INDENT', message);
79
+ indent = '';
80
+ }
81
+ if (type === Scalar.BLOCK_LITERAL) {
82
+ value += sep + indent.slice(trimIndent) + content;
83
+ sep = '\n';
84
+ }
85
+ else if (indent.length > trimIndent || content[0] === '\t') {
86
+ // more-indented content within a folded block
87
+ if (sep === ' ')
88
+ sep = '\n';
89
+ else if (!prevMoreIndented && sep === '\n')
90
+ sep = '\n\n';
91
+ value += sep + indent.slice(trimIndent) + content;
92
+ sep = '\n';
93
+ prevMoreIndented = true;
94
+ }
95
+ else if (content === '') {
96
+ // empty line
97
+ if (sep === '\n')
98
+ value += '\n';
99
+ else
100
+ sep = '\n';
101
+ }
102
+ else {
103
+ value += sep + content;
104
+ sep = ' ';
105
+ prevMoreIndented = false;
106
+ }
107
+ }
108
+ switch (header.chomp) {
109
+ case '-':
110
+ break;
111
+ case '+':
112
+ for (let i = chompStart; i < lines.length; ++i)
113
+ value += '\n' + lines[i][0].slice(trimIndent);
114
+ if (value[value.length - 1] !== '\n')
115
+ value += '\n';
116
+ break;
117
+ default:
118
+ value += '\n';
119
+ }
120
+ const end = start + header.length + scalar.source.length;
121
+ return { value, type, comment: header.comment, range: [start, end, end] };
122
+ }
123
+ function parseBlockScalarHeader({ offset, props }, strict, onError) {
124
+ /* istanbul ignore if should not happen */
125
+ if (props[0].type !== 'block-scalar-header') {
126
+ onError(props[0], 'IMPOSSIBLE', 'Block scalar header not found');
127
+ return null;
128
+ }
129
+ const { source } = props[0];
130
+ const mode = source[0];
131
+ let indent = 0;
132
+ let chomp = '';
133
+ let error = -1;
134
+ for (let i = 1; i < source.length; ++i) {
135
+ const ch = source[i];
136
+ if (!chomp && (ch === '-' || ch === '+'))
137
+ chomp = ch;
138
+ else {
139
+ const n = Number(ch);
140
+ if (!indent && n)
141
+ indent = n;
142
+ else if (error === -1)
143
+ error = offset + i;
144
+ }
145
+ }
146
+ if (error !== -1)
147
+ onError(error, 'UNEXPECTED_TOKEN', `Block scalar header includes extra characters: ${source}`);
148
+ let hasSpace = false;
149
+ let comment = '';
150
+ let length = source.length;
151
+ for (let i = 1; i < props.length; ++i) {
152
+ const token = props[i];
153
+ switch (token.type) {
154
+ case 'space':
155
+ hasSpace = true;
156
+ // fallthrough
157
+ case 'newline':
158
+ length += token.source.length;
159
+ break;
160
+ case 'comment':
161
+ if (strict && !hasSpace) {
162
+ const message = 'Comments must be separated from other tokens by white space characters';
163
+ onError(token, 'MISSING_CHAR', message);
164
+ }
165
+ length += token.source.length;
166
+ comment = token.source.substring(1);
167
+ break;
168
+ case 'error':
169
+ onError(token, 'UNEXPECTED_TOKEN', token.message);
170
+ length += token.source.length;
171
+ break;
172
+ /* istanbul ignore next should not happen */
173
+ default: {
174
+ const message = `Unexpected token in block scalar header: ${token.type}`;
175
+ onError(token, 'UNEXPECTED_TOKEN', message);
176
+ const ts = token.source;
177
+ if (ts && typeof ts === 'string')
178
+ length += ts.length;
179
+ }
180
+ }
181
+ }
182
+ return { mode, indent, chomp, comment, length };
183
+ }
184
+ /** @returns Array of lines split up as `[indent, content]` */
185
+ function splitLines(source) {
186
+ const split = source.split(/\n( *)/);
187
+ const first = split[0];
188
+ const m = first.match(/^( *)/);
189
+ const line0 = m?.[1]
190
+ ? [m[1], first.slice(m[1].length)]
191
+ : ['', first];
192
+ const lines = [line0];
193
+ for (let i = 1; i < split.length; i += 2)
194
+ lines.push([split[i], split[i + 1]]);
195
+ return lines;
196
+ }
197
+
198
+ export { resolveBlockScalar };
@@ -0,0 +1,49 @@
1
+ import { YAMLSeq } from '../nodes/YAMLSeq.mjs';
2
+ import { resolveProps } from './resolve-props.mjs';
3
+ import { flowIndentCheck } from './util-flow-indent-check.mjs';
4
+
5
+ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, tag) {
6
+ const NodeClass = tag?.nodeClass ?? YAMLSeq;
7
+ const seq = new NodeClass(ctx.schema);
8
+ if (ctx.atRoot)
9
+ ctx.atRoot = false;
10
+ if (ctx.atKey)
11
+ ctx.atKey = false;
12
+ let offset = bs.offset;
13
+ let commentEnd = null;
14
+ for (const { start, value } of bs.items) {
15
+ const props = resolveProps(start, {
16
+ indicator: 'seq-item-ind',
17
+ next: value,
18
+ offset,
19
+ onError,
20
+ parentIndent: bs.indent,
21
+ startOnNewline: true
22
+ });
23
+ if (!props.found) {
24
+ if (props.anchor || props.tag || value) {
25
+ if (value?.type === 'block-seq')
26
+ onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column');
27
+ else
28
+ onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator');
29
+ }
30
+ else {
31
+ commentEnd = props.end;
32
+ if (props.comment)
33
+ seq.comment = props.comment;
34
+ continue;
35
+ }
36
+ }
37
+ const node = value
38
+ ? composeNode(ctx, value, props, onError)
39
+ : composeEmptyNode(ctx, props.end, start, null, props, onError);
40
+ if (ctx.schema.compat)
41
+ flowIndentCheck(bs.indent, value, onError);
42
+ offset = node.range[2];
43
+ seq.items.push(node);
44
+ }
45
+ seq.range = [bs.offset, offset, commentEnd ?? offset];
46
+ return seq;
47
+ }
48
+
49
+ export { resolveBlockSeq };
@@ -0,0 +1,37 @@
1
+ function resolveEnd(end, offset, reqSpace, onError) {
2
+ let comment = '';
3
+ if (end) {
4
+ let hasSpace = false;
5
+ let sep = '';
6
+ for (const token of end) {
7
+ const { source, type } = token;
8
+ switch (type) {
9
+ case 'space':
10
+ hasSpace = true;
11
+ break;
12
+ case 'comment': {
13
+ if (reqSpace && !hasSpace)
14
+ onError(token, 'MISSING_CHAR', 'Comments must be separated from other tokens by white space characters');
15
+ const cb = source.substring(1) || ' ';
16
+ if (!comment)
17
+ comment = cb;
18
+ else
19
+ comment += sep + cb;
20
+ sep = '';
21
+ break;
22
+ }
23
+ case 'newline':
24
+ if (comment)
25
+ sep += source;
26
+ hasSpace = true;
27
+ break;
28
+ default:
29
+ onError(token, 'UNEXPECTED_TOKEN', `Unexpected ${type} at node end`);
30
+ }
31
+ offset += source.length;
32
+ }
33
+ }
34
+ return { comment, offset };
35
+ }
36
+
37
+ export { resolveEnd };
@@ -0,0 +1,207 @@
1
+ import { isPair } from '../nodes/identity.mjs';
2
+ import { Pair } from '../nodes/Pair.mjs';
3
+ import { YAMLMap } from '../nodes/YAMLMap.mjs';
4
+ import { YAMLSeq } from '../nodes/YAMLSeq.mjs';
5
+ import { resolveEnd } from './resolve-end.mjs';
6
+ import { resolveProps } from './resolve-props.mjs';
7
+ import { containsNewline } from './util-contains-newline.mjs';
8
+ import { mapIncludes } from './util-map-includes.mjs';
9
+
10
+ const blockMsg = 'Block collections are not allowed within flow collections';
11
+ const isBlock = (token) => token && (token.type === 'block-map' || token.type === 'block-seq');
12
+ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onError, tag) {
13
+ const isMap = fc.start.source === '{';
14
+ const fcName = isMap ? 'flow map' : 'flow sequence';
15
+ const NodeClass = (tag?.nodeClass ?? (isMap ? YAMLMap : YAMLSeq));
16
+ const coll = new NodeClass(ctx.schema);
17
+ coll.flow = true;
18
+ const atRoot = ctx.atRoot;
19
+ if (atRoot)
20
+ ctx.atRoot = false;
21
+ if (ctx.atKey)
22
+ ctx.atKey = false;
23
+ let offset = fc.offset + fc.start.source.length;
24
+ for (let i = 0; i < fc.items.length; ++i) {
25
+ const collItem = fc.items[i];
26
+ const { start, key, sep, value } = collItem;
27
+ const props = resolveProps(start, {
28
+ flow: fcName,
29
+ indicator: 'explicit-key-ind',
30
+ next: key ?? sep?.[0],
31
+ offset,
32
+ onError,
33
+ parentIndent: fc.indent,
34
+ startOnNewline: false
35
+ });
36
+ if (!props.found) {
37
+ if (!props.anchor && !props.tag && !sep && !value) {
38
+ if (i === 0 && props.comma)
39
+ onError(props.comma, 'UNEXPECTED_TOKEN', `Unexpected , in ${fcName}`);
40
+ else if (i < fc.items.length - 1)
41
+ onError(props.start, 'UNEXPECTED_TOKEN', `Unexpected empty item in ${fcName}`);
42
+ if (props.comment) {
43
+ if (coll.comment)
44
+ coll.comment += '\n' + props.comment;
45
+ else
46
+ coll.comment = props.comment;
47
+ }
48
+ offset = props.end;
49
+ continue;
50
+ }
51
+ if (!isMap && ctx.options.strict && containsNewline(key))
52
+ onError(key, // checked by containsNewline()
53
+ 'MULTILINE_IMPLICIT_KEY', 'Implicit keys of flow sequence pairs need to be on a single line');
54
+ }
55
+ if (i === 0) {
56
+ if (props.comma)
57
+ onError(props.comma, 'UNEXPECTED_TOKEN', `Unexpected , in ${fcName}`);
58
+ }
59
+ else {
60
+ if (!props.comma)
61
+ onError(props.start, 'MISSING_CHAR', `Missing , between ${fcName} items`);
62
+ if (props.comment) {
63
+ let prevItemComment = '';
64
+ loop: for (const st of start) {
65
+ switch (st.type) {
66
+ case 'comma':
67
+ case 'space':
68
+ break;
69
+ case 'comment':
70
+ prevItemComment = st.source.substring(1);
71
+ break loop;
72
+ default:
73
+ break loop;
74
+ }
75
+ }
76
+ if (prevItemComment) {
77
+ let prev = coll.items[coll.items.length - 1];
78
+ if (isPair(prev))
79
+ prev = prev.value ?? prev.key;
80
+ if (prev.comment)
81
+ prev.comment += '\n' + prevItemComment;
82
+ else
83
+ prev.comment = prevItemComment;
84
+ props.comment = props.comment.substring(prevItemComment.length + 1);
85
+ }
86
+ }
87
+ }
88
+ if (!isMap && !sep && !props.found) {
89
+ // item is a value in a seq
90
+ // → key & sep are empty, start does not include ? or :
91
+ const valueNode = value
92
+ ? composeNode(ctx, value, props, onError)
93
+ : composeEmptyNode(ctx, props.end, sep, null, props, onError);
94
+ coll.items.push(valueNode);
95
+ offset = valueNode.range[2];
96
+ if (isBlock(value))
97
+ onError(valueNode.range, 'BLOCK_IN_FLOW', blockMsg);
98
+ }
99
+ else {
100
+ // item is a key+value pair
101
+ // key value
102
+ ctx.atKey = true;
103
+ const keyStart = props.end;
104
+ const keyNode = key
105
+ ? composeNode(ctx, key, props, onError)
106
+ : composeEmptyNode(ctx, keyStart, start, null, props, onError);
107
+ if (isBlock(key))
108
+ onError(keyNode.range, 'BLOCK_IN_FLOW', blockMsg);
109
+ ctx.atKey = false;
110
+ // value properties
111
+ const valueProps = resolveProps(sep ?? [], {
112
+ flow: fcName,
113
+ indicator: 'map-value-ind',
114
+ next: value,
115
+ offset: keyNode.range[2],
116
+ onError,
117
+ parentIndent: fc.indent,
118
+ startOnNewline: false
119
+ });
120
+ if (valueProps.found) {
121
+ if (!isMap && !props.found && ctx.options.strict) {
122
+ if (sep)
123
+ for (const st of sep) {
124
+ if (st === valueProps.found)
125
+ break;
126
+ if (st.type === 'newline') {
127
+ onError(st, 'MULTILINE_IMPLICIT_KEY', 'Implicit keys of flow sequence pairs need to be on a single line');
128
+ break;
129
+ }
130
+ }
131
+ if (props.start < valueProps.found.offset - 1024)
132
+ onError(valueProps.found, 'KEY_OVER_1024_CHARS', 'The : indicator must be at most 1024 chars after the start of an implicit flow sequence key');
133
+ }
134
+ }
135
+ else if (value) {
136
+ if ('source' in value && value.source?.[0] === ':')
137
+ onError(value, 'MISSING_CHAR', `Missing space after : in ${fcName}`);
138
+ else
139
+ onError(valueProps.start, 'MISSING_CHAR', `Missing , or : between ${fcName} items`);
140
+ }
141
+ // value value
142
+ const valueNode = value
143
+ ? composeNode(ctx, value, valueProps, onError)
144
+ : valueProps.found
145
+ ? composeEmptyNode(ctx, valueProps.end, sep, null, valueProps, onError)
146
+ : null;
147
+ if (valueNode) {
148
+ if (isBlock(value))
149
+ onError(valueNode.range, 'BLOCK_IN_FLOW', blockMsg);
150
+ }
151
+ else if (valueProps.comment) {
152
+ if (keyNode.comment)
153
+ keyNode.comment += '\n' + valueProps.comment;
154
+ else
155
+ keyNode.comment = valueProps.comment;
156
+ }
157
+ const pair = new Pair(keyNode, valueNode);
158
+ if (ctx.options.keepSourceTokens)
159
+ pair.srcToken = collItem;
160
+ if (isMap) {
161
+ const map = coll;
162
+ if (mapIncludes(ctx, map.items, keyNode))
163
+ onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
164
+ map.items.push(pair);
165
+ }
166
+ else {
167
+ const map = new YAMLMap(ctx.schema);
168
+ map.flow = true;
169
+ map.items.push(pair);
170
+ const endRange = (valueNode ?? keyNode).range;
171
+ map.range = [keyNode.range[0], endRange[1], endRange[2]];
172
+ coll.items.push(map);
173
+ }
174
+ offset = valueNode ? valueNode.range[2] : valueProps.end;
175
+ }
176
+ }
177
+ const expectedEnd = isMap ? '}' : ']';
178
+ const [ce, ...ee] = fc.end;
179
+ let cePos = offset;
180
+ if (ce?.source === expectedEnd)
181
+ cePos = ce.offset + ce.source.length;
182
+ else {
183
+ const name = fcName[0].toUpperCase() + fcName.substring(1);
184
+ const msg = atRoot
185
+ ? `${name} must end with a ${expectedEnd}`
186
+ : `${name} in block collection must be sufficiently indented and end with a ${expectedEnd}`;
187
+ onError(offset, atRoot ? 'MISSING_CHAR' : 'BAD_INDENT', msg);
188
+ if (ce && ce.source.length !== 1)
189
+ ee.unshift(ce);
190
+ }
191
+ if (ee.length > 0) {
192
+ const end = resolveEnd(ee, cePos, ctx.options.strict, onError);
193
+ if (end.comment) {
194
+ if (coll.comment)
195
+ coll.comment += '\n' + end.comment;
196
+ else
197
+ coll.comment = end.comment;
198
+ }
199
+ coll.range = [fc.offset, cePos, end.offset];
200
+ }
201
+ else {
202
+ coll.range = [fc.offset, cePos, cePos];
203
+ }
204
+ return coll;
205
+ }
206
+
207
+ export { resolveFlowCollection };