@agentshouse/mdmodel 0.1.0-alpha.9 → 0.1.0-c00ddc0c7ef71

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 (597) hide show
  1. package/API.md +374 -0
  2. package/README.md +41 -197
  3. package/dist/body.d.ts +85 -0
  4. package/dist/body.d.ts.map +1 -0
  5. package/dist/body.js +1083 -0
  6. package/dist/built-in.d.ts +4 -0
  7. package/dist/built-in.d.ts.map +1 -0
  8. package/dist/built-in.js +19 -0
  9. package/dist/definition.d.ts +91 -34
  10. package/dist/definition.d.ts.map +1 -1
  11. package/dist/definition.js +889 -144
  12. package/dist/document.d.ts +20 -3
  13. package/dist/document.d.ts.map +1 -1
  14. package/dist/document.js +1042 -188
  15. package/dist/event.d.ts +77 -0
  16. package/dist/event.d.ts.map +1 -0
  17. package/dist/event.js +200 -0
  18. package/dist/facts.d.ts +15 -0
  19. package/dist/facts.d.ts.map +1 -0
  20. package/dist/facts.js +42 -0
  21. package/dist/fields.d.ts +6 -0
  22. package/dist/fields.d.ts.map +1 -0
  23. package/dist/fields.js +10 -0
  24. package/dist/form.d.ts +4 -0
  25. package/dist/form.d.ts.map +1 -0
  26. package/dist/form.js +153 -0
  27. package/dist/house-model.d.ts +920 -0
  28. package/dist/house-model.d.ts.map +1 -0
  29. package/dist/house-model.js +504 -0
  30. package/dist/house-references/crockford.d.ts +4 -0
  31. package/dist/house-references/crockford.d.ts.map +1 -0
  32. package/dist/house-references/crockford.js +3 -0
  33. package/dist/house-references/patterns.d.ts +9 -0
  34. package/dist/house-references/patterns.d.ts.map +1 -0
  35. package/dist/house-references/patterns.js +13 -0
  36. package/dist/index.d.ts +46 -5
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +28 -6
  39. package/dist/indexed.d.ts +9 -0
  40. package/dist/indexed.d.ts.map +1 -0
  41. package/dist/indexed.js +55 -0
  42. package/dist/kinds.d.ts +21 -0
  43. package/dist/kinds.d.ts.map +1 -0
  44. package/dist/kinds.js +210 -0
  45. package/dist/markdown.d.ts +71 -0
  46. package/dist/markdown.d.ts.map +1 -0
  47. package/dist/markdown.js +232 -0
  48. package/dist/media-type.d.ts +72 -0
  49. package/dist/media-type.d.ts.map +1 -0
  50. package/dist/media-type.js +157 -0
  51. package/dist/moment.d.ts +7 -0
  52. package/dist/moment.d.ts.map +1 -0
  53. package/dist/moment.js +18 -0
  54. package/dist/not-ready.d.ts +2 -0
  55. package/dist/not-ready.d.ts.map +1 -0
  56. package/dist/not-ready.js +5 -0
  57. package/dist/paths.d.ts +31 -5
  58. package/dist/paths.d.ts.map +1 -1
  59. package/dist/paths.js +236 -35
  60. package/dist/pattern.d.ts +10 -0
  61. package/dist/pattern.d.ts.map +1 -0
  62. package/dist/pattern.js +356 -0
  63. package/dist/query/language.d.ts +257 -0
  64. package/dist/query/language.d.ts.map +1 -0
  65. package/dist/query/language.js +621 -0
  66. package/dist/query/match.d.ts +14 -0
  67. package/dist/query/match.d.ts.map +1 -0
  68. package/dist/query/match.js +129 -0
  69. package/dist/query/rows.d.ts +36 -0
  70. package/dist/query/rows.d.ts.map +1 -0
  71. package/dist/query/rows.js +179 -0
  72. package/dist/query/sql.d.ts +45 -0
  73. package/dist/query/sql.d.ts.map +1 -0
  74. package/dist/query/sql.js +296 -0
  75. package/dist/query/walk.d.ts +69 -0
  76. package/dist/query/walk.d.ts.map +1 -0
  77. package/dist/query/walk.js +274 -0
  78. package/dist/references.d.ts +4 -0
  79. package/dist/references.d.ts.map +1 -0
  80. package/dist/references.js +30 -0
  81. package/dist/refuse.d.ts +1 -0
  82. package/dist/refuse.d.ts.map +1 -1
  83. package/dist/refuse.js +3 -10
  84. package/dist/reserved.d.ts +7 -0
  85. package/dist/reserved.d.ts.map +1 -0
  86. package/dist/reserved.js +32 -0
  87. package/dist/room-types.d.ts +8 -0
  88. package/dist/room-types.d.ts.map +1 -0
  89. package/dist/room-types.js +144 -0
  90. package/dist/schema.d.ts +6 -5
  91. package/dist/schema.d.ts.map +1 -1
  92. package/dist/schema.js +143 -41
  93. package/dist/types.d.ts +90 -11
  94. package/dist/types.d.ts.map +1 -1
  95. package/dist/types.js +1 -3
  96. package/dist/validate.d.ts +39 -2
  97. package/dist/validate.d.ts.map +1 -1
  98. package/dist/validate.js +419 -158
  99. package/dist/version.d.ts +1 -1
  100. package/dist/version.d.ts.map +1 -1
  101. package/dist/version.js +1 -3
  102. package/dist/view.d.ts +5 -0
  103. package/dist/view.d.ts.map +1 -0
  104. package/dist/view.js +27 -0
  105. package/dist/yaml.d.ts +12 -4
  106. package/dist/yaml.d.ts.map +1 -1
  107. package/dist/yaml.js +455 -209
  108. package/fixtures/README.md +131 -67
  109. package/fixtures/cases/absent-link-dangles/library/item.md +8 -0
  110. package/fixtures/cases/absent-link-dangles/schema.md +7 -0
  111. package/fixtures/cases/absent-optional-field/expected.json +1 -0
  112. package/fixtures/cases/absent-optional-field/library/companies/acme.md +4 -0
  113. package/fixtures/cases/absent-optional-field/library/deals/lead.md +6 -0
  114. package/fixtures/cases/absent-optional-field/schema.md +57 -0
  115. package/fixtures/cases/absolute-link/expected.json +5 -0
  116. package/fixtures/cases/absolute-link/library/item.md +8 -0
  117. package/fixtures/cases/absolute-link/schema.md +7 -0
  118. package/fixtures/cases/attachment-reference-any-file/context.json +1 -0
  119. package/fixtures/cases/attachment-reference-any-file/expected.json +1 -0
  120. package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +4 -0
  121. package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +18 -0
  122. package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +4 -0
  123. package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +4 -0
  124. package/fixtures/cases/attachment-reference-any-file/library/products/support.md +4 -0
  125. package/fixtures/cases/attachment-reference-any-file/schema.md +34 -0
  126. package/fixtures/cases/attachment-reference-dangles/context.json +1 -0
  127. package/fixtures/cases/attachment-reference-dangles/expected.json +1 -0
  128. package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +4 -0
  129. package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +18 -0
  130. package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +4 -0
  131. package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +4 -0
  132. package/fixtures/cases/attachment-reference-dangles/library/products/support.md +4 -0
  133. package/fixtures/cases/attachment-reference-dangles/schema.md +34 -0
  134. package/fixtures/cases/attachment-reference-outside/context.json +1 -0
  135. package/fixtures/cases/attachment-reference-outside/expected.json +7 -0
  136. package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +4 -0
  137. package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +18 -0
  138. package/fixtures/cases/attachment-reference-outside/library/places/depot.md +4 -0
  139. package/fixtures/cases/attachment-reference-outside/library/products/seats.md +4 -0
  140. package/fixtures/cases/attachment-reference-outside/library/products/support.md +4 -0
  141. package/fixtures/cases/attachment-reference-outside/schema.md +34 -0
  142. package/fixtures/cases/binary-any-reference/expected.json +2 -2
  143. package/fixtures/cases/binary-any-reference/library/notes/draft.md +1 -1
  144. package/fixtures/cases/binary-any-reference/schema.md +6 -0
  145. package/fixtures/cases/binary-document-collision/expected.json +1 -2
  146. package/fixtures/cases/binary-document-collision/schema.md +3 -0
  147. package/fixtures/cases/binary-image-dangles/expected.json +1 -0
  148. package/fixtures/cases/binary-image-dangles/schema.md +3 -0
  149. package/fixtures/cases/binary-link-dangles/expected.json +1 -0
  150. package/fixtures/cases/binary-link-dangles/schema.md +3 -0
  151. package/fixtures/cases/binary-link-outside-collection/expected.json +1 -2
  152. package/fixtures/cases/binary-link-outside-collection/schema.md +3 -0
  153. package/fixtures/cases/binary-prototype-reference/expected.json +2 -2
  154. package/fixtures/cases/binary-prototype-reference/library/notes/draft.md +1 -1
  155. package/fixtures/cases/binary-prototype-reference/schema.md +6 -0
  156. package/fixtures/cases/binary-typed-reference/expected.json +2 -2
  157. package/fixtures/cases/binary-typed-reference/library/notes/draft.md +1 -1
  158. package/fixtures/cases/binary-typed-reference/schema.md +7 -0
  159. package/fixtures/cases/block-scalar-frontmatter/context.json +1 -0
  160. package/fixtures/cases/block-scalar-frontmatter/expected.json +1 -0
  161. package/fixtures/cases/block-scalar-frontmatter/library/notes/literal.md +17 -0
  162. package/fixtures/cases/block-scalar-frontmatter/library/skills/notes/SKILL.md +10 -0
  163. package/fixtures/cases/boolean-field/context.json +1 -0
  164. package/fixtures/cases/boolean-field/expected.json +7 -0
  165. package/fixtures/cases/boolean-field/library/companies/acme.md +4 -0
  166. package/fixtures/cases/boolean-field/library/deals/renewal.md +56 -0
  167. package/fixtures/cases/boolean-field/schema.md +57 -0
  168. package/fixtures/cases/bracketed-link-definition/library/item.md +1 -1
  169. package/fixtures/cases/bracketed-link-definition/schema.md +7 -0
  170. package/fixtures/cases/closed-nested-object/context.json +1 -0
  171. package/fixtures/cases/closed-nested-object/expected.json +7 -0
  172. package/fixtures/cases/closed-nested-object/library/companies/acme.md +4 -0
  173. package/fixtures/cases/closed-nested-object/library/deals/renewal.md +57 -0
  174. package/fixtures/cases/closed-nested-object/schema.md +57 -0
  175. package/fixtures/cases/composed-root-reference/context.json +1 -0
  176. package/fixtures/cases/composed-root-reference/expected.json +6 -0
  177. package/fixtures/cases/composed-root-reference/library/a.md +5 -0
  178. package/fixtures/cases/composed-root-reference/schema.md +15 -0
  179. package/fixtures/cases/conditional-long-text/context.json +1 -0
  180. package/fixtures/cases/conditional-long-text/expected.json +7 -0
  181. package/fixtures/cases/conditional-long-text/library/questions/hosting.md +9 -0
  182. package/fixtures/cases/conditional-long-text/library/questions/payments.md +12 -0
  183. package/fixtures/cases/conditional-long-text/schema.md +15 -0
  184. package/fixtures/cases/cross-room-link/context.json +1 -0
  185. package/fixtures/cases/cross-room-link/expected.json +1 -0
  186. package/fixtures/cases/cross-room-link/library/clients/acme.md +6 -0
  187. package/fixtures/cases/cross-room-link/schema.md +5 -0
  188. package/fixtures/cases/cross-room-reference/context.json +1 -0
  189. package/fixtures/cases/cross-room-reference/expected.json +1 -0
  190. package/fixtures/cases/cross-room-reference/library/clients/acme.md +9 -0
  191. package/fixtures/cases/cross-room-reference/schema.md +10 -0
  192. package/fixtures/cases/date-time-format/context.json +1 -0
  193. package/fixtures/cases/date-time-format/expected.json +7 -0
  194. package/fixtures/cases/date-time-format/library/companies/acme.md +4 -0
  195. package/fixtures/cases/date-time-format/library/deals/renewal.md +56 -0
  196. package/fixtures/cases/date-time-format/schema.md +57 -0
  197. package/fixtures/cases/declared-binary-links/schema.md +3 -0
  198. package/fixtures/cases/default-unfilled/context.json +1 -0
  199. package/fixtures/cases/default-unfilled/expected.json +6 -0
  200. package/fixtures/cases/default-unfilled/library/companies/acme.md +4 -0
  201. package/fixtures/cases/default-unfilled/library/deals/renewal.md +54 -0
  202. package/fixtures/cases/default-unfilled/schema.md +57 -0
  203. package/fixtures/cases/defs-pattern/context.json +1 -0
  204. package/fixtures/cases/defs-pattern/expected.json +7 -0
  205. package/fixtures/cases/defs-pattern/library/companies/acme.md +4 -0
  206. package/fixtures/cases/defs-pattern/library/deals/renewal.md +56 -0
  207. package/fixtures/cases/defs-pattern/schema.md +57 -0
  208. package/fixtures/cases/dependent-rule/context.json +1 -0
  209. package/fixtures/cases/dependent-rule/expected.json +6 -0
  210. package/fixtures/cases/dependent-rule/library/companies/acme.md +4 -0
  211. package/fixtures/cases/dependent-rule/library/deals/renewal.md +55 -0
  212. package/fixtures/cases/dependent-rule/schema.md +57 -0
  213. package/fixtures/cases/duplicate-link-definition/library/item.md +1 -1
  214. package/fixtures/cases/duplicate-link-definition/schema.md +7 -0
  215. package/fixtures/cases/email-format/context.json +1 -0
  216. package/fixtures/cases/email-format/expected.json +7 -0
  217. package/fixtures/cases/email-format/library/companies/acme.md +4 -0
  218. package/fixtures/cases/email-format/library/deals/renewal.md +56 -0
  219. package/fixtures/cases/email-format/schema.md +57 -0
  220. package/fixtures/cases/equal-labels/context.json +1 -0
  221. package/fixtures/cases/equal-labels/expected.json +5 -0
  222. package/fixtures/cases/equal-labels/schema.md +6 -0
  223. package/fixtures/cases/fenced-link-definition/library/item.md +1 -1
  224. package/fixtures/cases/fenced-link-definition/schema.md +7 -0
  225. package/fixtures/cases/field-enum/expected.json +3 -3
  226. package/fixtures/cases/field-enum/library/item.md +2 -2
  227. package/fixtures/cases/field-enum/schema.md +8 -0
  228. package/fixtures/cases/frontmatter-construct/context.json +1 -0
  229. package/fixtures/cases/frontmatter-construct/expected.json +7 -0
  230. package/fixtures/cases/frontmatter-construct/library/note.md +6 -0
  231. package/fixtures/cases/integer-field/context.json +1 -0
  232. package/fixtures/cases/integer-field/expected.json +7 -0
  233. package/fixtures/cases/integer-field/library/companies/acme.md +4 -0
  234. package/fixtures/cases/integer-field/library/deals/renewal.md +56 -0
  235. package/fixtures/cases/integer-field/schema.md +57 -0
  236. package/fixtures/cases/interrupted-link-definition/schema.md +3 -0
  237. package/fixtures/cases/json-schema-constructs/context.json +1 -0
  238. package/fixtures/cases/json-schema-constructs/expected.json +1 -0
  239. package/fixtures/cases/json-schema-constructs/library/companies/acme.md +4 -0
  240. package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +56 -0
  241. package/fixtures/cases/json-schema-constructs/schema.md +57 -0
  242. package/fixtures/cases/labels-in-the-rooms-language/context.json +1 -0
  243. package/fixtures/cases/labels-in-the-rooms-language/expected.json +1 -0
  244. package/fixtures/cases/labels-in-the-rooms-language/library/deals/atlas.md +7 -0
  245. package/fixtures/cases/labels-in-the-rooms-language/schema.md +11 -0
  246. package/fixtures/cases/lazy-list-item/context.json +1 -0
  247. package/fixtures/cases/lazy-list-item/expected.json +3 -0
  248. package/fixtures/cases/lazy-list-item/library/item.md +10 -0
  249. package/fixtures/cases/lazy-list-item/schema.md +5 -0
  250. package/fixtures/cases/link-into-a-reserved-name/context.json +1 -0
  251. package/fixtures/cases/link-into-a-reserved-name/expected.json +5 -0
  252. package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +6 -0
  253. package/fixtures/cases/link-into-a-reserved-name/schema.md +5 -0
  254. package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/context.json +1 -0
  255. package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/expected.json +5 -0
  256. package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/library/notes/b.md +5 -0
  257. package/fixtures/cases/list-item-enum/context.json +1 -0
  258. package/fixtures/cases/list-item-enum/expected.json +7 -0
  259. package/fixtures/cases/list-item-enum/library/task.md +7 -0
  260. package/fixtures/cases/list-item-enum/schema.md +5 -0
  261. package/fixtures/cases/list-item-kind/context.json +1 -0
  262. package/fixtures/cases/list-item-kind/expected.json +7 -0
  263. package/fixtures/cases/list-item-kind/library/task.md +6 -0
  264. package/fixtures/cases/list-item-kind/schema.md +5 -0
  265. package/fixtures/cases/list-items/context.json +1 -0
  266. package/fixtures/cases/list-items/expected.json +1 -0
  267. package/fixtures/cases/list-items/library/other.md +3 -0
  268. package/fixtures/cases/list-items/library/page.md +26 -0
  269. package/fixtures/cases/list-items/schema.md +12 -0
  270. package/fixtures/cases/list-of-objects-closed/context.json +1 -0
  271. package/fixtures/cases/list-of-objects-closed/expected.json +7 -0
  272. package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +4 -0
  273. package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +56 -0
  274. package/fixtures/cases/list-of-objects-closed/schema.md +57 -0
  275. package/fixtures/cases/list-of-objects-item/context.json +1 -0
  276. package/fixtures/cases/list-of-objects-item/expected.json +7 -0
  277. package/fixtures/cases/list-of-objects-item/library/companies/acme.md +4 -0
  278. package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +56 -0
  279. package/fixtures/cases/list-of-objects-item/schema.md +57 -0
  280. package/fixtures/cases/list-of-objects-reference/context.json +1 -0
  281. package/fixtures/cases/list-of-objects-reference/expected.json +7 -0
  282. package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +4 -0
  283. package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +17 -0
  284. package/fixtures/cases/list-of-objects-reference/library/places/depot.md +4 -0
  285. package/fixtures/cases/list-of-objects-reference/library/products/seats.md +4 -0
  286. package/fixtures/cases/list-of-objects-reference/library/products/support.md +4 -0
  287. package/fixtures/cases/list-of-objects-reference/schema.md +34 -0
  288. package/fixtures/cases/list-reference-path/context.json +1 -0
  289. package/fixtures/cases/list-reference-path/expected.json +7 -0
  290. package/fixtures/cases/list-reference-path/library/other.md +3 -0
  291. package/fixtures/cases/list-reference-path/library/page.md +5 -0
  292. package/fixtures/cases/list-reference-path/schema.md +5 -0
  293. package/fixtures/cases/list-reference-type/context.json +1 -0
  294. package/fixtures/cases/list-reference-type/expected.json +7 -0
  295. package/fixtures/cases/list-reference-type/library/note.md +1 -0
  296. package/fixtures/cases/list-reference-type/library/page.md +6 -0
  297. package/fixtures/cases/list-reference-type/schema.md +5 -0
  298. package/fixtures/cases/list-size/context.json +1 -0
  299. package/fixtures/cases/list-size/expected.json +7 -0
  300. package/fixtures/cases/list-size/library/companies/acme.md +4 -0
  301. package/fixtures/cases/list-size/library/deals/renewal.md +58 -0
  302. package/fixtures/cases/list-size/schema.md +57 -0
  303. package/fixtures/cases/long-fence-link-definition/schema.md +3 -0
  304. package/fixtures/cases/long-value-past-six-levels/context.json +1 -0
  305. package/fixtures/cases/long-value-past-six-levels/expected.json +5 -0
  306. package/fixtures/cases/long-value-past-six-levels/schema.md +17 -0
  307. package/fixtures/cases/malformed-definition/expected.json +2 -4
  308. package/fixtures/cases/malformed-definition/schema.md +5 -0
  309. package/fixtures/cases/malformed-list/context.json +1 -0
  310. package/fixtures/cases/malformed-list/expected.json +7 -0
  311. package/fixtures/cases/{structured-section → malformed-list}/library/item.md +1 -1
  312. package/fixtures/cases/malformed-list/schema.md +8 -0
  313. package/fixtures/cases/member-document/context.json +1 -0
  314. package/fixtures/cases/member-document/expected.json +1 -0
  315. package/fixtures/cases/member-document/library/people/ana.md +5 -0
  316. package/fixtures/cases/member-document/schema.md +7 -0
  317. package/fixtures/cases/member-on-an-untyped-document/context.json +1 -0
  318. package/fixtures/cases/member-on-an-untyped-document/expected.json +6 -0
  319. package/fixtures/cases/member-on-an-untyped-document/library/note.md +4 -0
  320. package/fixtures/cases/member-on-another-type/context.json +1 -0
  321. package/fixtures/cases/member-on-another-type/expected.json +6 -0
  322. package/fixtures/cases/member-on-another-type/library/note.md +4 -0
  323. package/fixtures/cases/member-on-another-type/schema.md +9 -0
  324. package/fixtures/cases/missing-required-field/expected.json +2 -3
  325. package/fixtures/cases/missing-required-field/library/item.md +1 -1
  326. package/fixtures/cases/missing-required-field/schema.md +8 -0
  327. package/fixtures/cases/misspelled-key/context.json +1 -0
  328. package/fixtures/cases/misspelled-key/expected.json +7 -0
  329. package/fixtures/cases/misspelled-key/library/companies/acme.md +4 -0
  330. package/fixtures/cases/misspelled-key/library/deals/renewal.md +57 -0
  331. package/fixtures/cases/misspelled-key/schema.md +57 -0
  332. package/fixtures/cases/name-not-a-string/context.json +1 -0
  333. package/fixtures/cases/name-not-a-string/expected.json +5 -0
  334. package/fixtures/cases/name-not-a-string/schema.md +7 -0
  335. package/fixtures/cases/nested-defs/context.json +1 -0
  336. package/fixtures/cases/nested-defs/expected.json +7 -0
  337. package/fixtures/cases/nested-defs/library/deal.md +6 -0
  338. package/fixtures/cases/nested-defs/schema.md +13 -0
  339. package/fixtures/cases/nested-object-reference/context.json +1 -0
  340. package/fixtures/cases/nested-object-reference/expected.json +7 -0
  341. package/fixtures/cases/nested-object-reference/library/companies/acme.md +4 -0
  342. package/fixtures/cases/nested-object-reference/library/deals/renewal.md +17 -0
  343. package/fixtures/cases/nested-object-reference/library/places/depot.md +4 -0
  344. package/fixtures/cases/nested-object-reference/library/products/seats.md +4 -0
  345. package/fixtures/cases/nested-object-reference/library/products/support.md +4 -0
  346. package/fixtures/cases/nested-object-reference/schema.md +34 -0
  347. package/fixtures/cases/nested-reference/context.json +1 -0
  348. package/fixtures/cases/nested-reference/expected.json +1 -0
  349. package/fixtures/cases/nested-reference/library/companies/acme.md +4 -0
  350. package/fixtures/cases/nested-reference/library/deals/renewal.md +18 -0
  351. package/fixtures/cases/nested-reference/library/places/depot.md +4 -0
  352. package/fixtures/cases/nested-reference/library/products/seats.md +4 -0
  353. package/fixtures/cases/nested-reference/library/products/support.md +4 -0
  354. package/fixtures/cases/nested-reference/schema.md +34 -0
  355. package/fixtures/cases/nested-required-field/context.json +1 -0
  356. package/fixtures/cases/nested-required-field/expected.json +7 -0
  357. package/fixtures/cases/nested-required-field/library/companies/acme.md +4 -0
  358. package/fixtures/cases/nested-required-field/library/deals/renewal.md +55 -0
  359. package/fixtures/cases/nested-required-field/schema.md +57 -0
  360. package/fixtures/cases/numeric-range/context.json +1 -0
  361. package/fixtures/cases/numeric-range/expected.json +7 -0
  362. package/fixtures/cases/numeric-range/library/companies/acme.md +4 -0
  363. package/fixtures/cases/numeric-range/library/deals/renewal.md +56 -0
  364. package/fixtures/cases/numeric-range/schema.md +57 -0
  365. package/fixtures/cases/one-key-two-labels/context.json +1 -0
  366. package/fixtures/cases/one-key-two-labels/expected.json +5 -0
  367. package/fixtures/cases/one-key-two-labels/schema.md +7 -0
  368. package/fixtures/cases/one-key-two-types/context.json +1 -0
  369. package/fixtures/cases/one-key-two-types/expected.json +5 -0
  370. package/fixtures/cases/one-key-two-types/schema.md +6 -0
  371. package/fixtures/cases/one-of-variant/context.json +1 -0
  372. package/fixtures/cases/one-of-variant/expected.json +7 -0
  373. package/fixtures/cases/one-of-variant/library/companies/acme.md +4 -0
  374. package/fixtures/cases/one-of-variant/library/deals/renewal.md +56 -0
  375. package/fixtures/cases/one-of-variant/schema.md +57 -0
  376. package/fixtures/cases/other-room-reference/context.json +1 -0
  377. package/fixtures/cases/other-room-reference/expected.json +7 -0
  378. package/fixtures/cases/other-room-reference/library/companies/acme.md +4 -0
  379. package/fixtures/cases/other-room-reference/library/deals/renewal.md +17 -0
  380. package/fixtures/cases/other-room-reference/library/places/depot.md +4 -0
  381. package/fixtures/cases/other-room-reference/library/products/seats.md +4 -0
  382. package/fixtures/cases/other-room-reference/library/products/support.md +4 -0
  383. package/fixtures/cases/other-room-reference/schema.md +34 -0
  384. package/fixtures/cases/paragraph-link-definition/schema.md +3 -0
  385. package/fixtures/cases/prototype-field/expected.json +3 -3
  386. package/fixtures/cases/prototype-field/library/item.md +2 -2
  387. package/fixtures/cases/prototype-field/schema.md +7 -0
  388. package/fixtures/cases/quoted-link-definition/expected.json +1 -2
  389. package/fixtures/cases/quoted-link-definition/library/notes/draft.md +1 -1
  390. package/fixtures/cases/quoted-link-definition/schema.md +3 -0
  391. package/fixtures/cases/reference-into-a-reserved-name/context.json +1 -0
  392. package/fixtures/cases/reference-into-a-reserved-name/expected.json +7 -0
  393. package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +4 -0
  394. package/fixtures/cases/reference-into-a-reserved-name/library/settings/brief.md +1 -0
  395. package/fixtures/cases/reference-into-a-reserved-name/schema.md +5 -0
  396. package/fixtures/cases/reference-to-any-file-name/context.json +1 -0
  397. package/fixtures/cases/reference-to-any-file-name/expected.json +1 -0
  398. package/fixtures/cases/reference-to-any-file-name/library/people/100%.md +4 -0
  399. package/fixtures/cases/reference-to-any-file-name/library/people/C#.md +4 -0
  400. package/fixtures/cases/reference-to-any-file-name/library/people/My notes.md +4 -0
  401. package/fixtures/cases/reference-to-any-file-name/library/people/[draft].md +4 -0
  402. package/fixtures/cases/reference-to-any-file-name/library/people/c (d).md +4 -0
  403. package/fixtures/cases/reference-to-any-file-name/library/people/caf/303/251.md +4 -0
  404. package/fixtures/cases/reference-to-any-file-name/library/people//320/236/321/202/321/207/321/221/321/202.md +4 -0
  405. package/fixtures/cases/reference-to-any-file-name/library/tasks/bracket.md +9 -0
  406. package/fixtures/cases/reference-to-any-file-name/library/tasks/cyrillic.md +9 -0
  407. package/fixtures/cases/reference-to-any-file-name/library/tasks/decomposed.md +9 -0
  408. package/fixtures/cases/reference-to-any-file-name/library/tasks/hash.md +9 -0
  409. package/fixtures/cases/reference-to-any-file-name/library/tasks/parenthesis.md +9 -0
  410. package/fixtures/cases/reference-to-any-file-name/library/tasks/percent.md +9 -0
  411. package/fixtures/cases/reference-to-any-file-name/library/tasks/spaced.md +9 -0
  412. package/fixtures/cases/reference-to-any-file-name/schema.md +12 -0
  413. package/fixtures/cases/referenced-missing-file/expected.json +0 -1
  414. package/fixtures/cases/referenced-missing-file/library/a.md +2 -2
  415. package/fixtures/cases/referenced-missing-file/library/b.md +2 -2
  416. package/fixtures/cases/referenced-missing-file/schema.md +12 -0
  417. package/fixtures/cases/referenced-missing-non-latin-file/context.json +1 -0
  418. package/fixtures/cases/referenced-missing-non-latin-file/expected.json +6 -0
  419. package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/a.md +9 -0
  420. package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/b.md +9 -0
  421. package/fixtures/cases/referenced-missing-non-latin-file/schema.md +12 -0
  422. package/fixtures/cases/remote-ref/context.json +1 -0
  423. package/fixtures/cases/remote-ref/expected.json +5 -0
  424. package/fixtures/cases/remote-ref/schema.md +5 -0
  425. package/fixtures/cases/room-md-declares-a-type/context.json +1 -0
  426. package/fixtures/cases/room-md-declares-a-type/expected.json +6 -0
  427. package/fixtures/cases/room-md-declares-a-type/library/ROOM.md +5 -0
  428. package/fixtures/cases/schema-body-ignored/context.json +1 -0
  429. package/fixtures/cases/schema-body-ignored/expected.json +1 -0
  430. package/fixtures/cases/schema-body-ignored/schema.md +9 -0
  431. package/fixtures/cases/schema-type-named-folders/context.json +1 -0
  432. package/fixtures/cases/schema-type-named-folders/expected.json +5 -0
  433. package/fixtures/cases/schema-type-named-folders/schema.md +5 -0
  434. package/fixtures/cases/schema-type-named-type/context.json +1 -0
  435. package/fixtures/cases/schema-type-named-type/expected.json +5 -0
  436. package/fixtures/cases/schema-type-named-type/schema.md +5 -0
  437. package/fixtures/cases/second-member-document/context.json +1 -0
  438. package/fixtures/cases/second-member-document/expected.json +5 -0
  439. package/fixtures/cases/second-member-document/schema.md +6 -0
  440. package/fixtures/cases/sections-keyword-refused/context.json +1 -0
  441. package/fixtures/cases/sections-keyword-refused/expected.json +5 -0
  442. package/fixtures/cases/sections-keyword-refused/schema.md +8 -0
  443. package/fixtures/cases/shortcut-reference-link/context.json +1 -0
  444. package/fixtures/cases/shortcut-reference-link/expected.json +5 -0
  445. package/fixtures/cases/shortcut-reference-link/library/item.md +10 -0
  446. package/fixtures/cases/shortcut-reference-link/schema.md +7 -0
  447. package/fixtures/cases/string-length/context.json +1 -0
  448. package/fixtures/cases/string-length/expected.json +7 -0
  449. package/fixtures/cases/string-length/library/companies/acme.md +4 -0
  450. package/fixtures/cases/string-length/library/deals/renewal.md +56 -0
  451. package/fixtures/cases/string-length/schema.md +57 -0
  452. package/fixtures/cases/submission-keys/context.json +1 -0
  453. package/fixtures/cases/submission-keys/expected.json +1 -0
  454. package/fixtures/cases/submission-keys/library/notes/visitor.md +8 -0
  455. package/fixtures/cases/submission-keys/schema.md +6 -0
  456. package/fixtures/cases/text-field-kind/context.json +1 -0
  457. package/fixtures/cases/text-field-kind/expected.json +3 -0
  458. package/fixtures/cases/text-field-kind/library/page.md +4 -0
  459. package/fixtures/cases/text-field-kind/schema.md +6 -0
  460. package/fixtures/cases/thematic-break-ends-the-values/context.json +1 -0
  461. package/fixtures/cases/thematic-break-ends-the-values/expected.json +1 -0
  462. package/fixtures/cases/thematic-break-ends-the-values/library/item.md +10 -0
  463. package/fixtures/cases/thematic-break-ends-the-values/schema.md +5 -0
  464. package/fixtures/cases/truncated-link-definition/expected.json +1 -2
  465. package/fixtures/cases/truncated-link-definition/library/notes/draft.md +1 -1
  466. package/fixtures/cases/truncated-link-definition/schema.md +3 -0
  467. package/fixtures/cases/typed-path-names-another-type/context.json +11 -0
  468. package/fixtures/cases/typed-path-names-another-type/expected.json +6 -0
  469. package/fixtures/cases/typed-path-names-another-type/library/settings/prefs/one.md +3 -0
  470. package/fixtures/cases/typed-path-names-another-type/schema.md +8 -0
  471. package/fixtures/cases/typed-path-names-its-type/context.json +11 -0
  472. package/fixtures/cases/typed-path-names-its-type/expected.json +3 -0
  473. package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/deeper/two.md +1 -0
  474. package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +4 -0
  475. package/fixtures/cases/typed-path-names-its-type/schema.md +8 -0
  476. package/fixtures/cases/typed-path-names-no-type/context.json +11 -0
  477. package/fixtures/cases/typed-path-names-no-type/expected.json +6 -0
  478. package/fixtures/cases/typed-path-names-no-type/library/settings/prefs/one.md +1 -0
  479. package/fixtures/cases/typed-path-names-no-type/schema.md +8 -0
  480. package/fixtures/cases/types-folder-content/context.json +1 -0
  481. package/fixtures/cases/types-folder-content/expected.json +1 -0
  482. package/fixtures/cases/types-folder-content/library/types/task.md +4 -0
  483. package/fixtures/cases/types-folder-content/schema.md +6 -0
  484. package/fixtures/cases/unclosed-frontmatter/expected.json +1 -2
  485. package/fixtures/cases/undeclared-field/expected.json +3 -3
  486. package/fixtures/cases/undeclared-field/library/item.md +2 -2
  487. package/fixtures/cases/undeclared-field/schema.md +7 -0
  488. package/fixtures/cases/unevaluated-items-closed/context.json +1 -0
  489. package/fixtures/cases/unevaluated-items-closed/expected.json +7 -0
  490. package/fixtures/cases/unevaluated-items-closed/library/trip.md +16 -0
  491. package/fixtures/cases/unevaluated-items-closed/schema.md +12 -0
  492. package/fixtures/cases/unknown-type/context.json +1 -0
  493. package/fixtures/cases/unknown-type/expected.json +6 -0
  494. package/fixtures/cases/unknown-type/library/item.md +3 -0
  495. package/fixtures/cases/unknown-type/schema.md +5 -0
  496. package/fixtures/cases/unlisted-reference-type/context.json +1 -0
  497. package/fixtures/cases/unlisted-reference-type/expected.json +5 -0
  498. package/fixtures/cases/unlisted-reference-type/schema.md +5 -0
  499. package/fixtures/cases/unnamed-typed-path-checks-its-fields/context.json +11 -0
  500. package/fixtures/cases/unnamed-typed-path-checks-its-fields/expected.json +6 -0
  501. package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +5 -0
  502. package/fixtures/cases/unnamed-typed-path-checks-its-fields/schema.md +7 -0
  503. package/fixtures/cases/unnamed-typed-path-names-a-type/context.json +11 -0
  504. package/fixtures/cases/unnamed-typed-path-names-a-type/expected.json +6 -0
  505. package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +7 -0
  506. package/fixtures/cases/unnamed-typed-path-names-a-type/schema.md +7 -0
  507. package/fixtures/cases/unnamed-typed-path-reads-its-type/context.json +11 -0
  508. package/fixtures/cases/unnamed-typed-path-reads-its-type/expected.json +3 -0
  509. package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/plan.md +1 -0
  510. package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +6 -0
  511. package/fixtures/cases/unnamed-typed-path-reads-its-type/schema.md +7 -0
  512. package/fixtures/cases/unnamed-typed-path-without-a-body/context.json +11 -0
  513. package/fixtures/cases/unnamed-typed-path-without-a-body/expected.json +5 -0
  514. package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +5 -0
  515. package/fixtures/cases/unnamed-typed-path-without-a-body/schema.md +7 -0
  516. package/fixtures/cases/unresolved-link/expected.json +1 -2
  517. package/fixtures/cases/unresolved-link/library/item.md +2 -2
  518. package/fixtures/cases/unresolved-link/schema.md +7 -0
  519. package/fixtures/cases/valid-typed-document/library/people/ada.md +1 -1
  520. package/fixtures/cases/valid-typed-document/library/tasks/one.md +11 -11
  521. package/fixtures/cases/valid-typed-document/schema.md +17 -0
  522. package/fixtures/cases/wide-item-fence-link/schema.md +3 -0
  523. package/fixtures/forms.json +371 -0
  524. package/fixtures/preamble.json +29 -8
  525. package/fixtures/queries.json +1562 -0
  526. package/package.json +20 -13
  527. package/dist/definition.js.map +0 -1
  528. package/dist/document.js.map +0 -1
  529. package/dist/index.js.map +0 -1
  530. package/dist/links.d.ts +0 -25
  531. package/dist/links.d.ts.map +0 -1
  532. package/dist/links.js +0 -380
  533. package/dist/links.js.map +0 -1
  534. package/dist/paths.js.map +0 -1
  535. package/dist/profile.d.ts +0 -6
  536. package/dist/profile.d.ts.map +0 -1
  537. package/dist/profile.js +0 -7
  538. package/dist/profile.js.map +0 -1
  539. package/dist/project.d.ts +0 -3
  540. package/dist/project.d.ts.map +0 -1
  541. package/dist/project.js +0 -122
  542. package/dist/project.js.map +0 -1
  543. package/dist/refuse.js.map +0 -1
  544. package/dist/schema.js.map +0 -1
  545. package/dist/sections.d.ts +0 -10
  546. package/dist/sections.d.ts.map +0 -1
  547. package/dist/sections.js +0 -79
  548. package/dist/sections.js.map +0 -1
  549. package/dist/types.js.map +0 -1
  550. package/dist/validate.js.map +0 -1
  551. package/dist/version.js.map +0 -1
  552. package/dist/yaml.js.map +0 -1
  553. package/fixtures/cases/binary-any-reference/library/types/note.md +0 -5
  554. package/fixtures/cases/binary-document-collision/library/types/note.md +0 -3
  555. package/fixtures/cases/binary-link-outside-collection/library/types/note.md +0 -3
  556. package/fixtures/cases/binary-prototype-reference/library/types/note.md +0 -5
  557. package/fixtures/cases/binary-typed-reference/library/types/note.md +0 -5
  558. package/fixtures/cases/binary-typed-reference/library/types/person.md +0 -3
  559. package/fixtures/cases/bracketed-link-definition/library/types/task.md +0 -7
  560. package/fixtures/cases/declared-binary-links/library/types/note.md +0 -3
  561. package/fixtures/cases/duplicate-link-definition/library/types/task.md +0 -7
  562. package/fixtures/cases/fenced-link-definition/library/types/task.md +0 -7
  563. package/fixtures/cases/field-enum/library/types/task.md +0 -8
  564. package/fixtures/cases/interrupted-link-definition/library/types/note.md +0 -3
  565. package/fixtures/cases/long-fence-link-definition/library/types/note.md +0 -3
  566. package/fixtures/cases/malformed-definition/library/types/task.md +0 -5
  567. package/fixtures/cases/missing-binary-image/expected.json +0 -6
  568. package/fixtures/cases/missing-binary-image/library/types/note.md +0 -3
  569. package/fixtures/cases/missing-binary-link/expected.json +0 -6
  570. package/fixtures/cases/missing-binary-link/library/types/note.md +0 -3
  571. package/fixtures/cases/missing-required-field/library/types/task.md +0 -8
  572. package/fixtures/cases/missing-section-item-kind/expected.json +0 -7
  573. package/fixtures/cases/missing-section-item-kind/library/types/task.md +0 -7
  574. package/fixtures/cases/paragraph-link-definition/library/types/note.md +0 -3
  575. package/fixtures/cases/prd-definition/library/types/task.md +0 -16
  576. package/fixtures/cases/prototype-field/library/types/task.md +0 -7
  577. package/fixtures/cases/quoted-link-definition/library/types/note.md +0 -3
  578. package/fixtures/cases/referenced-missing-file/library/types/person.md +0 -5
  579. package/fixtures/cases/referenced-missing-file/library/types/task.md +0 -8
  580. package/fixtures/cases/structured-section/expected.json +0 -7
  581. package/fixtures/cases/structured-section/library/types/task.md +0 -8
  582. package/fixtures/cases/truncated-link-definition/library/types/note.md +0 -3
  583. package/fixtures/cases/undeclared-field/library/types/task.md +0 -7
  584. package/fixtures/cases/unresolved-link/library/types/task.md +0 -7
  585. package/fixtures/cases/valid-typed-document/library/types/person.md +0 -5
  586. package/fixtures/cases/valid-typed-document/library/types/task.md +0 -13
  587. package/fixtures/cases/wide-item-fence-link/library/types/note.md +0 -3
  588. package/fixtures/projection.json +0 -186
  589. package/markdown-syntax-profile.md +0 -9
  590. /package/fixtures/cases/{missing-section-item-kind → absent-link-dangles}/context.json +0 -0
  591. /package/fixtures/cases/{prd-definition → absent-link-dangles}/expected.json +0 -0
  592. /package/fixtures/cases/{prd-definition → absent-optional-field}/context.json +0 -0
  593. /package/fixtures/cases/{structured-section → absolute-link}/context.json +0 -0
  594. /package/fixtures/cases/{missing-binary-image → binary-image-dangles}/context.json +0 -0
  595. /package/fixtures/cases/{missing-binary-image → binary-image-dangles}/library/notes/draft.md +0 -0
  596. /package/fixtures/cases/{missing-binary-link → binary-link-dangles}/context.json +0 -0
  597. /package/fixtures/cases/{missing-binary-link → binary-link-dangles}/library/notes/draft.md +0 -0
package/dist/yaml.js CHANGED
@@ -1,28 +1,49 @@
1
1
  export class YamlError extends Error {
2
2
  offset;
3
- constructor(offset){
4
- super('yaml'), this.offset = offset;
3
+ construct;
4
+ constructor(offset, construct) {
5
+ super();
6
+ this.offset = offset;
7
+ this.construct = construct;
5
8
  this.name = 'YamlError';
6
9
  }
7
10
  }
11
+ const YAML_DEPTH_MAX = 64;
12
+ function nested(c, parse) {
13
+ if (c.depth >= YAML_DEPTH_MAX)
14
+ throw new YamlError(c.i, 'nesting');
15
+ c.depth += 1;
16
+ try {
17
+ return parse();
18
+ }
19
+ finally {
20
+ c.depth -= 1;
21
+ }
22
+ }
8
23
  function peek(c) {
9
24
  return c.i < c.end ? c.text[c.i] : '';
10
25
  }
11
26
  function skipEol(c) {
12
- if (peek(c) === '\r') c.i += 1;
13
- if (peek(c) === '\n') c.i += 1;
27
+ if (peek(c) === '\r')
28
+ c.i += 1;
29
+ if (peek(c) === '\n')
30
+ c.i += 1;
14
31
  }
15
32
  function skipSpaces(c) {
16
- while(peek(c) === ' ')c.i += 1;
17
- if (peek(c) === '\t') throw new YamlError(c.i);
33
+ while (peek(c) === ' ')
34
+ c.i += 1;
35
+ if (peek(c) === '\t')
36
+ throw new YamlError(c.i, 'tab');
18
37
  }
19
38
  function skipToEol(c) {
20
- while(c.i < c.end && peek(c) !== '\n' && peek(c) !== '\r')c.i += 1;
39
+ while (c.i < c.end && peek(c) !== '\n' && peek(c) !== '\r')
40
+ c.i += 1;
21
41
  }
22
42
  function skipBlankAndComments(c) {
23
- while(c.i < c.end){
43
+ while (c.i < c.end) {
24
44
  skipSpaces(c);
25
- if (peek(c) === '#') skipToEol(c);
45
+ if (peek(c) === '#')
46
+ skipToEol(c);
26
47
  if (peek(c) === '\r' || peek(c) === '\n') {
27
48
  skipEol(c);
28
49
  continue;
@@ -31,7 +52,7 @@ function skipBlankAndComments(c) {
31
52
  }
32
53
  }
33
54
  function skipFlowSpace(c) {
34
- while(c.i < c.end){
55
+ while (c.i < c.end) {
35
56
  const ch = peek(c);
36
57
  if (ch === ' ' || ch === '\n' || ch === '\r') {
37
58
  c.i += 1;
@@ -41,157 +62,199 @@ function skipFlowSpace(c) {
41
62
  skipToEol(c);
42
63
  continue;
43
64
  }
44
- if (ch === '\t') throw new YamlError(c.i);
65
+ if (ch === '\t')
66
+ throw new YamlError(c.i, 'tab');
45
67
  break;
46
68
  }
47
69
  }
48
70
  function indentAt(c) {
49
71
  let j = c.i;
50
- while(j > 0 && c.text[j - 1] !== '\n')j -= 1;
72
+ while (j > 0 && c.text[j - 1] !== '\n' && c.text[j - 1] !== '\r')
73
+ j -= 1;
51
74
  let n = 0;
52
- while(j < c.i){
75
+ while (j < c.i) {
53
76
  const ch = c.text[j];
54
- if (ch === ' ') n += 1;
55
- else if (ch === '\t') throw new YamlError(j);
56
- else break;
77
+ if (ch === ' ')
78
+ n += 1;
79
+ else if (ch === '\t')
80
+ throw new YamlError(j, 'tab');
81
+ else
82
+ break;
57
83
  j += 1;
58
84
  }
59
85
  return n;
60
86
  }
87
+ const UNHELD_TEXT = /[\0\ud800-\udfff]/u;
61
88
  function scalar(value, start, end) {
62
- return {
63
- kind: 'scalar',
64
- value,
65
- start,
66
- end
67
- };
68
- }
69
- function interpretPlain(text) {
70
- if (text === 'true') return true;
71
- if (text === 'false') return false;
72
- if (text === 'null' || text === '') return null;
73
- if (/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$/.test(text)) return Number(text);
89
+ if (typeof value === 'string' && UNHELD_TEXT.test(value))
90
+ throw new YamlError(start, 'unheld-character');
91
+ return { kind: 'scalar', value, start, end };
92
+ }
93
+ export function interpretPlain(text) {
94
+ if (text === 'true')
95
+ return true;
96
+ if (text === 'false')
97
+ return false;
98
+ if (text === 'null' || text === '')
99
+ return null;
100
+ if (/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$/.test(text))
101
+ return Number(text);
74
102
  return text;
75
103
  }
104
+ const ESCAPES = {
105
+ b: '\b',
106
+ f: '\f',
107
+ n: '\n',
108
+ r: '\r',
109
+ t: '\t',
110
+ '"': '"',
111
+ '/': '/',
112
+ '\\': '\\',
113
+ };
114
+ function parseEscape(c) {
115
+ c.i += 1;
116
+ const escaped = peek(c);
117
+ const held = ESCAPES[escaped];
118
+ if (held !== undefined) {
119
+ c.i += 1;
120
+ return held;
121
+ }
122
+ const hex = c.text.slice(c.i + 1, c.i + 5);
123
+ if (escaped !== 'u' || c.i + 5 > c.end || !/^[0-9A-Fa-f]{4}$/.test(hex))
124
+ throw new YamlError(c.i, 'escape');
125
+ c.i += 5;
126
+ return String.fromCharCode(Number.parseInt(hex, 16));
127
+ }
76
128
  function parseQuoted(c) {
77
129
  const quote = peek(c);
78
130
  const start = c.i;
79
131
  c.i += 1;
80
132
  let out = '';
81
- while(c.i < c.end){
133
+ while (c.i < c.end) {
82
134
  const ch = peek(c);
83
- if (ch === quote) {
84
- c.i += 1;
85
- return scalar(out, start, c.i);
86
- }
87
- if (ch === '\n' || ch === '\r') throw new YamlError(c.i);
88
- if (quote === "'" && ch === "'" && c.text[c.i + 1] === "'") {
135
+ if (quote === "'" && ch === "'" && c.i + 1 < c.end && c.text[c.i + 1] === "'") {
89
136
  out += "'";
90
137
  c.i += 2;
91
138
  continue;
92
139
  }
93
- if (quote === '"' && ch === '\\') {
94
- c.i += 1;
95
- const escaped = peek(c);
96
- if (escaped === 'n') out += '\n';
97
- else if (escaped === 't') out += '\t';
98
- else if (escaped === '"') out += '"';
99
- else if (escaped === '\\') out += '\\';
100
- else throw new YamlError(c.i);
140
+ if (ch === quote) {
101
141
  c.i += 1;
142
+ return scalar(out, start, c.i);
143
+ }
144
+ if (ch === '\n' || ch === '\r')
145
+ throw new YamlError(c.i, 'multi-line-scalar');
146
+ if (quote === '"' && ch === '\\') {
147
+ out += parseEscape(c);
102
148
  continue;
103
149
  }
104
150
  out += ch;
105
151
  c.i += 1;
106
152
  }
107
- throw new YamlError(c.i);
153
+ throw new YamlError(c.i, 'multi-line-scalar');
108
154
  }
109
155
  function parsePlain(c, flow) {
110
156
  const start = c.i;
111
- while(c.i < c.end){
157
+ while (c.i < c.end) {
112
158
  const ch = peek(c);
113
- if (flow && (ch === ',' || ch === ']' || ch === '}')) break;
114
- if (ch === '\n' || ch === '\r') break;
115
- if (ch === '#' && (c.i === start || c.text[c.i - 1] === ' ' || c.text[c.i - 1] === '\t')) break;
159
+ if (flow && (ch === ',' || ch === ']' || ch === '}'))
160
+ break;
161
+ if (ch === '\n' || ch === '\r')
162
+ break;
163
+ if (ch === '#' && (c.i === start || c.text[c.i - 1] === ' ' || c.text[c.i - 1] === '\t'))
164
+ break;
116
165
  c.i += 1;
117
166
  }
118
- if (c.i === start) throw new YamlError(c.i);
167
+ if (c.i === start)
168
+ throw new YamlError(c.i, 'flow-collection');
119
169
  const raw = c.text.slice(start, c.i);
120
170
  const trimmed = raw.trimEnd();
121
171
  return scalar(interpretPlain(trimmed), start, start + trimmed.length);
122
172
  }
123
173
  function parseScalar(c, flow) {
124
174
  const ch = peek(c);
125
- if (ch === '"' || ch === "'") return parseQuoted(c);
175
+ if (ch === '"' || ch === "'")
176
+ return parseQuoted(c);
126
177
  return parsePlain(c, flow);
127
178
  }
128
- function parseKey(c) {
179
+ function parseKey(c, refused) {
129
180
  const start = c.i;
130
181
  if (peek(c) === '"' || peek(c) === "'") {
131
182
  const quoted = parseQuoted(c);
132
- if (typeof quoted.value !== 'string') throw new YamlError(start);
133
- return {
134
- name: quoted.value,
135
- start,
136
- end: c.i
137
- };
183
+ if (typeof quoted.value !== 'string')
184
+ throw new YamlError(start, refused);
185
+ return { name: quoted.value, start, end: c.i };
138
186
  }
139
187
  let end = c.i;
140
- while(c.i < c.end){
188
+ while (c.i < c.end) {
141
189
  const ch = peek(c);
142
- if (ch === ':' || ch === '\n' || ch === '\r' || ch === ',' || ch === '}' || ch === ']' || ch === '#' || ch === '{' || ch === '[') {
190
+ if (ch === ':' ||
191
+ ch === '\n' ||
192
+ ch === '\r' ||
193
+ ch === ',' ||
194
+ ch === '}' ||
195
+ ch === ']' ||
196
+ ch === '#' ||
197
+ ch === '{' ||
198
+ ch === '[') {
143
199
  break;
144
200
  }
145
201
  c.i += 1;
146
- if (ch !== ' ' && ch !== '\t') end = c.i;
202
+ if (ch !== ' ' && ch !== '\t')
203
+ end = c.i;
147
204
  }
148
- if (end === start) throw new YamlError(c.i);
205
+ if (end === start)
206
+ throw new YamlError(c.i, refused);
149
207
  c.i = end;
150
- return {
151
- name: c.text.slice(start, end),
152
- start,
153
- end
154
- };
208
+ return { name: c.text.slice(start, end), start, end };
155
209
  }
156
210
  function parseFlowValue(c) {
157
211
  skipFlowSpace(c);
158
212
  const ch = peek(c);
159
- if (ch === '{') return parseFlowMap(c);
160
- if (ch === '[') return parseFlowSeq(c);
161
- if (ch === '|' || ch === '>') throw new YamlError(c.i);
213
+ if (ch === '{')
214
+ return parseFlowMap(c);
215
+ if (ch === '[')
216
+ return parseFlowSeq(c);
217
+ if (ch === '|' || ch === '>')
218
+ throw new YamlError(c.i, 'block-scalar-in-flow');
162
219
  return parseScalar(c, true);
163
220
  }
221
+ function closed(c, parse) {
222
+ const start = c.i;
223
+ try {
224
+ return parse();
225
+ }
226
+ catch (error) {
227
+ if (error instanceof YamlError && error.offset >= c.end)
228
+ throw new YamlError(start, 'flow-collection');
229
+ throw error;
230
+ }
231
+ }
164
232
  function parseFlowMap(c) {
233
+ return nested(c, () => closed(c, () => flowMap(c)));
234
+ }
235
+ function flowMap(c) {
165
236
  const start = c.i;
166
- if (peek(c) !== '{') throw new YamlError(c.i);
167
237
  c.i += 1;
168
238
  skipFlowSpace(c);
169
239
  const entries = [];
170
240
  const seen = new Set();
171
241
  if (peek(c) === '}') {
172
242
  c.i += 1;
173
- return {
174
- kind: 'map',
175
- entries,
176
- start,
177
- end: c.i
178
- };
243
+ return { kind: 'map', entries, start, end: c.i };
179
244
  }
180
- while(c.i < c.end){
245
+ while (c.i < c.end) {
181
246
  skipFlowSpace(c);
182
- const key = parseKey(c);
247
+ const key = parseKey(c, 'flow-collection');
183
248
  skipFlowSpace(c);
184
- if (peek(c) !== ':') throw new YamlError(c.i);
249
+ if (peek(c) !== ':')
250
+ throw new YamlError(c.i, 'flow-collection');
185
251
  c.i += 1;
252
+ const after = c.i;
186
253
  const value = parseFlowValue(c);
187
- if (seen.has(key.name)) throw new YamlError(key.start);
254
+ if (seen.has(key.name))
255
+ throw new YamlError(key.start, 'duplicate-key');
188
256
  seen.add(key.name);
189
- entries.push({
190
- key: key.name,
191
- keyStart: key.start,
192
- keyEnd: key.end,
193
- value
194
- });
257
+ entries.push({ key: key.name, after, value });
195
258
  skipFlowSpace(c);
196
259
  if (peek(c) === ',') {
197
260
  c.i += 1;
@@ -199,33 +262,25 @@ function parseFlowMap(c) {
199
262
  }
200
263
  if (peek(c) === '}') {
201
264
  c.i += 1;
202
- return {
203
- kind: 'map',
204
- entries,
205
- start,
206
- end: c.i
207
- };
265
+ return { kind: 'map', entries, start, end: c.i };
208
266
  }
209
- throw new YamlError(c.i);
267
+ throw new YamlError(c.i, 'flow-collection');
210
268
  }
211
- throw new YamlError(c.i);
269
+ throw new YamlError(c.i, 'flow-collection');
212
270
  }
213
271
  function parseFlowSeq(c) {
272
+ return nested(c, () => closed(c, () => flowSeq(c)));
273
+ }
274
+ function flowSeq(c) {
214
275
  const start = c.i;
215
- if (peek(c) !== '[') throw new YamlError(c.i);
216
276
  c.i += 1;
217
277
  skipFlowSpace(c);
218
278
  const items = [];
219
279
  if (peek(c) === ']') {
220
280
  c.i += 1;
221
- return {
222
- kind: 'seq',
223
- items,
224
- start,
225
- end: c.i
226
- };
281
+ return { kind: 'seq', items, start, end: c.i };
227
282
  }
228
- while(c.i < c.end){
283
+ while (c.i < c.end) {
229
284
  items.push(parseFlowValue(c));
230
285
  skipFlowSpace(c);
231
286
  if (peek(c) === ',') {
@@ -235,138 +290,331 @@ function parseFlowSeq(c) {
235
290
  }
236
291
  if (peek(c) === ']') {
237
292
  c.i += 1;
238
- return {
239
- kind: 'seq',
240
- items,
241
- start,
242
- end: c.i
243
- };
293
+ return { kind: 'seq', items, start, end: c.i };
244
294
  }
245
- throw new YamlError(c.i);
295
+ throw new YamlError(c.i, 'flow-collection');
246
296
  }
247
- throw new YamlError(c.i);
297
+ throw new YamlError(c.i, 'flow-collection');
248
298
  }
249
299
  function parseValue(c, parentKeyIndent) {
300
+ const at = c.i;
250
301
  skipSpaces(c);
251
- if (peek(c) === '#') skipToEol(c);
302
+ if (peek(c) === '#')
303
+ skipToEol(c);
252
304
  const ch = peek(c);
253
305
  if (ch === '' || ch === '\n' || ch === '\r') {
254
306
  skipEol(c);
255
307
  skipBlankAndComments(c);
256
- if (c.i >= c.end) return scalar(null, c.i, c.i);
308
+ if (c.i >= c.end)
309
+ return scalar(null, at, at);
257
310
  const nextIndent = indentAt(c);
258
- if (nextIndent <= parentKeyIndent) return scalar(null, c.i, c.i);
259
- if (peek(c) === '-') return parseBlockSeq(c, nextIndent);
260
- if (peek(c) === '[') return parseFlowSeq(c);
261
- if (peek(c) === '{') return parseFlowMap(c);
311
+ if (nextIndent === parentKeyIndent && seqAhead(c))
312
+ return parseBlockSeq(c, nextIndent);
313
+ if (nextIndent <= parentKeyIndent)
314
+ return scalar(null, at, at);
315
+ if (peek(c) === '-')
316
+ return parseBlockSeq(c, nextIndent);
317
+ if (peek(c) === '[')
318
+ return parseFlowSeq(c);
319
+ if (peek(c) === '{')
320
+ return parseFlowMap(c);
321
+ if (peek(c) === '|' || peek(c) === '>')
322
+ return parseBlockScalar(c, parentKeyIndent);
262
323
  return parseBlockMap(c, nextIndent);
263
324
  }
264
- if (ch === '{') return parseFlowMap(c);
265
- if (ch === '[') return parseFlowSeq(c);
266
- if (ch === '|' || ch === '>') throw new YamlError(c.i);
325
+ if (ch === '{')
326
+ return parseFlowMap(c);
327
+ if (ch === '[')
328
+ return parseFlowSeq(c);
329
+ if (ch === '|' || ch === '>')
330
+ return parseBlockScalar(c, parentKeyIndent);
267
331
  return parseScalar(c, false);
268
332
  }
333
+ function scalarLine(c, start) {
334
+ let at = start;
335
+ while (at < c.end && c.text[at] === ' ')
336
+ at += 1;
337
+ const indent = at - start;
338
+ while (at < c.end && c.text[at] !== '\n' && c.text[at] !== '\r')
339
+ at += 1;
340
+ let next = at;
341
+ if (next < c.end && c.text[next] === '\r')
342
+ next += 1;
343
+ if (next < c.end && c.text[next] === '\n')
344
+ next += 1;
345
+ return { start, indent, end: at, next };
346
+ }
347
+ function blank(line) {
348
+ return line.start + line.indent === line.end;
349
+ }
350
+ function folded(texts) {
351
+ let out = '';
352
+ let previous = null;
353
+ let empty = 0;
354
+ for (const text of texts) {
355
+ if (text === null) {
356
+ empty += 1;
357
+ continue;
358
+ }
359
+ const spaced = text.startsWith(' ') || text.startsWith('\t');
360
+ if (previous === null)
361
+ out += '\n'.repeat(empty);
362
+ else if (previous === 'text' && !spaced)
363
+ out += empty === 0 ? ' ' : '\n'.repeat(empty);
364
+ else
365
+ out += '\n'.repeat(empty + 1);
366
+ out += text;
367
+ previous = spaced ? 'spaced' : 'text';
368
+ empty = 0;
369
+ }
370
+ return out;
371
+ }
372
+ function parseBlockScalar(c, parentIndent) {
373
+ const start = c.i;
374
+ const fold = peek(c) === '>';
375
+ c.i += 1;
376
+ let chomping = '';
377
+ let explicit = 0;
378
+ for (;;) {
379
+ const ch = peek(c);
380
+ if (chomping === '' && (ch === '-' || ch === '+'))
381
+ chomping = ch;
382
+ else if (explicit === 0 && ch >= '1' && ch <= '9')
383
+ explicit = Number(ch);
384
+ else
385
+ break;
386
+ c.i += 1;
387
+ }
388
+ const header = c.i;
389
+ if (peek(c) === ' ' || peek(c) === '\t') {
390
+ skipSpaces(c);
391
+ if (peek(c) === '#')
392
+ skipToEol(c);
393
+ }
394
+ if (c.i < c.end && peek(c) !== '\n' && peek(c) !== '\r')
395
+ throw new YamlError(c.i, 'block-scalar-header');
396
+ skipEol(c);
397
+ const lines = [];
398
+ let indent = explicit === 0 ? null : parentIndent + explicit;
399
+ let leading = 0;
400
+ while (c.i < c.end) {
401
+ const line = scalarLine(c, c.i);
402
+ if (indent === null && blank(line))
403
+ leading = Math.max(leading, line.indent);
404
+ else if (indent === null) {
405
+ if (line.indent <= parentIndent)
406
+ break;
407
+ if (leading > line.indent)
408
+ throw new YamlError(line.start + line.indent, 'indentation');
409
+ indent = line.indent;
410
+ }
411
+ if (indent !== null && !blank(line) && line.indent < indent)
412
+ break;
413
+ lines.push(line);
414
+ c.i = line.next;
415
+ }
416
+ const texts = lines.map((line) => indent === null || (blank(line) && line.indent <= indent)
417
+ ? null
418
+ : c.text.slice(line.start + indent, line.end));
419
+ let last = texts.length - 1;
420
+ while (last >= 0 && texts[last] === null)
421
+ last -= 1;
422
+ const content = texts.slice(0, last + 1);
423
+ const body = fold ? folded(content) : content.map((text) => text ?? '').join('\n');
424
+ const broken = (line) => line.next > line.end;
425
+ const final = last >= 0 && broken(lines[last]) ? '\n' : '';
426
+ const kept = '\n'.repeat(lines.slice(last + 1).filter(broken).length);
427
+ const value = chomping === '-' ? body : chomping === '+' ? body + final + kept : body + final;
428
+ return scalar(value, start, last >= 0 ? lines[last].end : header);
429
+ }
430
+ function seqAhead(c) {
431
+ const next = c.text[c.i + 1];
432
+ return peek(c) === '-' && (next === ' ' || next === '\n' || next === '\r' || c.i + 1 >= c.end);
433
+ }
434
+ function mappingAhead(c) {
435
+ const start = c.i;
436
+ try {
437
+ if (peek(c) === '{' || peek(c) === '[')
438
+ return false;
439
+ parseKey(c, 'mapping-entry');
440
+ skipSpaces(c);
441
+ if (peek(c) !== ':')
442
+ return false;
443
+ const next = c.text[c.i + 1];
444
+ return next === ' ' || next === '\n' || next === '\r' || c.i + 1 >= c.end;
445
+ }
446
+ catch {
447
+ return false;
448
+ }
449
+ finally {
450
+ c.i = start;
451
+ }
452
+ }
453
+ function plainScalar(c, node) {
454
+ return node?.kind === 'scalar' && node.end > node.start && !`"'|>`.includes(c.text[node.start]);
455
+ }
456
+ function deeperLine(c, held) {
457
+ const continued = plainScalar(c, held) && !mappingAhead(c);
458
+ return new YamlError(c.i, continued ? 'multi-line-scalar' : 'indentation');
459
+ }
460
+ function lineStartOf(c) {
461
+ let j = c.i;
462
+ while (j > 0 && c.text[j - 1] !== '\n' && c.text[j - 1] !== '\r')
463
+ j -= 1;
464
+ return j;
465
+ }
466
+ function parseSeqItem(c, indent) {
467
+ skipSpaces(c);
468
+ if (peek(c) !== '#' && peek(c) !== '\n' && peek(c) !== '\r' && c.i < c.end && mappingAhead(c))
469
+ return parseBlockMap(c, c.i - lineStartOf(c), true);
470
+ return parseValue(c, indent);
471
+ }
269
472
  function parseBlockSeq(c, indent) {
473
+ return nested(c, () => blockSeq(c, indent));
474
+ }
475
+ function blockSeq(c, indent) {
270
476
  const start = c.i;
271
477
  const items = [];
272
478
  let end = start;
273
- while(c.i < c.end){
479
+ while (c.i < c.end) {
274
480
  skipBlankAndComments(c);
275
- if (c.i >= c.end) break;
276
- if (indentAt(c) !== indent) break;
277
- if (peek(c) !== '-') break;
481
+ if (c.i >= c.end)
482
+ break;
483
+ if (indentAt(c) > indent)
484
+ throw deeperLine(c, items[items.length - 1]);
485
+ if (indentAt(c) < indent)
486
+ break;
487
+ if (peek(c) !== '-')
488
+ break;
278
489
  c.i += 1;
279
- items.push(parseValue(c, indent));
280
- end = c.i;
490
+ const item = parseSeqItem(c, indent);
491
+ items.push(item);
492
+ end = item.end;
281
493
  }
282
- return {
283
- kind: 'seq',
284
- items,
285
- start,
286
- end
287
- };
288
- }
289
- function parseBlockMap(c, indent) {
494
+ return { kind: 'seq', items, start, end };
495
+ }
496
+ function parseBlockMap(c, indent, inline = false) {
497
+ return nested(c, () => blockMap(c, indent, inline));
498
+ }
499
+ function blockMap(c, indent, inline) {
290
500
  const start = c.i;
291
501
  const entries = [];
292
502
  const seen = new Set();
293
503
  let end = start;
294
- while(c.i < c.end){
295
- skipBlankAndComments(c);
296
- if (c.i >= c.end) break;
297
- if (indentAt(c) < indent) break;
298
- if (indentAt(c) > indent) throw new YamlError(c.i);
299
- const key = parseKey(c);
504
+ let first = inline;
505
+ while (c.i < c.end) {
506
+ if (!first) {
507
+ skipBlankAndComments(c);
508
+ if (c.i >= c.end)
509
+ break;
510
+ if (indentAt(c) < indent)
511
+ break;
512
+ if (indentAt(c) > indent)
513
+ throw deeperLine(c, entries[entries.length - 1]?.value);
514
+ }
515
+ first = false;
516
+ const key = parseKey(c, 'mapping-entry');
300
517
  skipSpaces(c);
301
- if (peek(c) !== ':') throw new YamlError(c.i);
518
+ if (peek(c) !== ':')
519
+ throw new YamlError(c.i, 'mapping-entry');
302
520
  c.i += 1;
521
+ const after = c.i;
303
522
  const value = parseValue(c, indent);
304
- if (seen.has(key.name)) throw new YamlError(key.start);
523
+ if (seen.has(key.name))
524
+ throw new YamlError(key.start, 'duplicate-key');
305
525
  seen.add(key.name);
306
- entries.push({
307
- key: key.name,
308
- keyStart: key.start,
309
- keyEnd: key.end,
310
- value
311
- });
312
- end = c.i;
526
+ entries.push({ key: key.name, after, value });
527
+ end = value.end;
313
528
  }
314
- return {
315
- kind: 'map',
316
- entries,
317
- start,
318
- end
319
- };
529
+ return { kind: 'map', entries, start, end };
320
530
  }
321
531
  export function parseYamlMapping(text, start, end) {
322
- const c = {
323
- text,
324
- i: start,
325
- end
326
- };
532
+ const c = { text, i: start, end, depth: 0 };
327
533
  skipBlankAndComments(c);
328
- if (c.i >= end) return {
329
- kind: 'map',
330
- entries: [],
331
- start,
332
- end
333
- };
534
+ if (c.i >= end)
535
+ return { kind: 'map', entries: [], start, end };
334
536
  if (peek(c) === '{') {
335
537
  const mapped = parseFlowMap(c);
336
538
  skipBlankAndComments(c);
337
- if (c.i < end) throw new YamlError(c.i);
539
+ if (c.i < end)
540
+ throw new YamlError(c.i, 'flow-collection');
338
541
  return mapped;
339
542
  }
340
543
  const mapped = parseBlockMap(c, indentAt(c));
341
544
  skipBlankAndComments(c);
342
- if (c.i < end) throw new YamlError(c.i);
545
+ if (c.i < end)
546
+ throw new YamlError(c.i, 'indentation');
343
547
  return mapped;
344
548
  }
345
549
  export function jsValue(node) {
346
- if (node.kind === 'scalar') return node.value;
347
- if (node.kind === 'seq') return node.items.map(jsValue);
550
+ if (node.kind === 'scalar')
551
+ return node.value;
552
+ if (node.kind === 'seq')
553
+ return node.items.map(jsValue);
348
554
  const record = Object.create(null);
349
- for (const entry of node.entries)record[entry.key] = jsValue(entry.value);
555
+ for (const entry of node.entries)
556
+ record[entry.key] = jsValue(entry.value);
350
557
  return record;
351
558
  }
352
559
  export function mapEntry(map, key) {
353
- return map.entries.find((entry)=>entry.key === key);
560
+ return map.entries.find((entry) => entry.key === key);
354
561
  }
355
562
  export function isPlainSafe(text) {
356
- if (text === '' || text === 'true' || text === 'false' || text === 'null') return false;
357
- if (/[\s#:{}[\],&*!|>'"%@`]/.test(text)) return false;
358
- if (text.startsWith('-') || text.startsWith('?') || text.startsWith(':')) return false;
359
- if (/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$/.test(text)) return false;
563
+ if (text === '' || text === 'true' || text === 'false' || text === 'null')
564
+ return false;
565
+ if (/[\s#:{}[\],&*!|>'"%@`]/.test(text))
566
+ return false;
567
+ if (text.startsWith('-') || text.startsWith('?') || text.startsWith(':'))
568
+ return false;
569
+ if (/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$/.test(text))
570
+ return false;
360
571
  return true;
361
572
  }
573
+ export function plain(value) {
574
+ if (!isRecord(value))
575
+ return false;
576
+ const prototype = Object.getPrototypeOf(value);
577
+ return prototype === Object.prototype || prototype === null;
578
+ }
579
+ function listed(value) {
580
+ const keys = Object.keys(value);
581
+ return keys.length === value.length && keys.every((key, index) => key === String(index));
582
+ }
583
+ function heldWithin(value, within) {
584
+ if (typeof value === 'string')
585
+ return !UNHELD_TEXT.test(value);
586
+ if (value === null || typeof value === 'boolean')
587
+ return true;
588
+ if (typeof value === 'number')
589
+ return Number.isFinite(value);
590
+ if (typeof value !== 'object' || within.includes(value))
591
+ return false;
592
+ if (within.length + 1 >= YAML_DEPTH_MAX)
593
+ return false;
594
+ const path = [...within, value];
595
+ const held = (item) => heldWithin(item, path);
596
+ if (Array.isArray(value))
597
+ return listed(value) && value.every(held);
598
+ return (plain(value) &&
599
+ Object.keys(value).every((key) => !UNHELD_TEXT.test(key)) &&
600
+ Object.values(value).every(held));
601
+ }
602
+ export function documentValue(value) {
603
+ return heldWithin(value, []);
604
+ }
362
605
  export function serializeJs(value) {
363
- if (value === null) return 'null';
364
- if (value === true) return 'true';
365
- if (value === false) return 'false';
366
- if (typeof value === 'number' && Number.isFinite(value)) return JSON.stringify(value);
367
- if (typeof value === 'string') return isPlainSafe(value) ? value : JSON.stringify(value);
368
- if (Array.isArray(value)) return `[${value.map(serializeJs).join(', ')}]`;
369
- throw new YamlError(0);
606
+ if (typeof value === 'string')
607
+ return isPlainSafe(value) ? value : JSON.stringify(value);
608
+ if (value === null || typeof value !== 'object')
609
+ return JSON.stringify(value);
610
+ if (Array.isArray(value))
611
+ return `[${value.map(serializeJs).join(', ')}]`;
612
+ return `{${Object.entries(value)
613
+ .map(([key, held]) => `${serializeKey(key)}: ${serializeJs(held)}`)
614
+ .join(', ')}}`;
615
+ }
616
+ export function isRecord(value) {
617
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
370
618
  }
371
619
  export function serializeKey(name) {
372
620
  return isPlainSafe(name) || /^[A-Za-z][A-Za-z0-9_-]*$/.test(name) ? name : JSON.stringify(name);
@@ -383,47 +631,45 @@ export function bodyAfterFrontmatter(content) {
383
631
  return content.slice(bodyStartOf(content));
384
632
  }
385
633
  export function extractFrontmatter(content) {
386
- if (!content.startsWith('---')) return {
387
- kind: 'none'
388
- };
634
+ if (!content.startsWith('---'))
635
+ return { kind: 'none' };
389
636
  const firstNl = content.indexOf('\n');
390
- const firstLine = firstNl === -1 ? content : content.slice(0, content[firstNl - 1] === '\r' ? firstNl - 1 : firstNl);
391
- if (!/^---[ \t]*$/.test(firstLine)) return {
392
- kind: 'none'
393
- };
394
- if (firstNl === -1) return {
395
- kind: 'unclosed'
396
- };
637
+ const firstLine = firstNl === -1
638
+ ? content
639
+ : content.slice(0, content[firstNl - 1] === '\r' ? firstNl - 1 : firstNl);
640
+ if (!/^---[ \t]*$/.test(firstLine))
641
+ return { kind: 'none' };
642
+ if (firstNl === -1)
643
+ return { kind: 'unclosed' };
397
644
  const yamlStart = firstNl + 1;
398
645
  let i = yamlStart;
399
- while(i <= content.length){
646
+ for (;;) {
400
647
  const nl = content.indexOf('\n', i);
401
648
  const lineEnd = nl === -1 ? content.length : nl;
402
649
  let line = content.slice(i, lineEnd);
403
- if (line.endsWith('\r')) line = line.slice(0, -1);
404
- if (/^---[ \t]*$/.test(line)) return {
405
- kind: 'ok',
406
- yamlStart,
407
- yamlEnd: i
408
- };
409
- if (nl === -1) return {
410
- kind: 'unclosed'
411
- };
650
+ if (line.endsWith('\r'))
651
+ line = line.slice(0, -1);
652
+ if (/^---[ \t]*$/.test(line))
653
+ return { kind: 'ok', yamlStart, yamlEnd: i };
654
+ if (nl === -1)
655
+ return { kind: 'unclosed' };
412
656
  i = nl + 1;
413
657
  }
414
- return {
415
- kind: 'unclosed'
416
- };
417
658
  }
418
659
  export function equalValue(left, right) {
419
- if (left === right) return true;
660
+ if (left === right)
661
+ return true;
420
662
  if (Array.isArray(left) && Array.isArray(right)) {
421
- return left.length === right.length && left.every((item, index)=>equalValue(item, right[index]));
663
+ return (left.length === right.length &&
664
+ Array.from(left).every((item, index) => equalValue(item, right[index])));
665
+ }
666
+ if (isRecord(left) && isRecord(right)) {
667
+ const keys = Object.keys(left);
668
+ return (keys.length === Object.keys(right).length &&
669
+ keys.every((key) => Object.hasOwn(right, key) && equalValue(left[key], right[key])));
422
670
  }
423
671
  return false;
424
672
  }
425
673
  export function lineEnding(content) {
426
674
  return content.includes('\r\n') ? '\r\n' : '\n';
427
675
  }
428
-
429
- //# sourceMappingURL=yaml.js.map