@elytracms/core 0.0.6

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 (521) hide show
  1. package/LICENSE +21 -0
  2. package/dist/clipboard/build.d.ts +77 -0
  3. package/dist/clipboard/build.js +128 -0
  4. package/dist/clipboard/build.js.map +1 -0
  5. package/dist/clipboard/clipboard.d.ts +33 -0
  6. package/dist/clipboard/clipboard.js +45 -0
  7. package/dist/clipboard/clipboard.js.map +1 -0
  8. package/dist/clipboard/fragment.d.ts +112 -0
  9. package/dist/clipboard/fragment.js +79 -0
  10. package/dist/clipboard/fragment.js.map +1 -0
  11. package/dist/clipboard/html.d.ts +26 -0
  12. package/dist/clipboard/html.js +82 -0
  13. package/dist/clipboard/html.js.map +1 -0
  14. package/dist/clipboard/index.d.ts +15 -0
  15. package/dist/clipboard/index.js +16 -0
  16. package/dist/clipboard/index.js.map +1 -0
  17. package/dist/clipboard/references.d.ts +50 -0
  18. package/dist/clipboard/references.js +0 -0
  19. package/dist/clipboard/references.js.map +1 -0
  20. package/dist/clipboard/serialize.d.ts +69 -0
  21. package/dist/clipboard/serialize.js +130 -0
  22. package/dist/clipboard/serialize.js.map +1 -0
  23. package/dist/cms-core/collections.d.ts +82 -0
  24. package/dist/cms-core/collections.js +187 -0
  25. package/dist/cms-core/collections.js.map +1 -0
  26. package/dist/cms-core/documents.d.ts +71 -0
  27. package/dist/cms-core/documents.js +67 -0
  28. package/dist/cms-core/documents.js.map +1 -0
  29. package/dist/cms-core/envelopes.d.ts +80 -0
  30. package/dist/cms-core/envelopes.js +124 -0
  31. package/dist/cms-core/envelopes.js.map +1 -0
  32. package/dist/cms-core/fields.d.ts +220 -0
  33. package/dist/cms-core/fields.js +250 -0
  34. package/dist/cms-core/fields.js.map +1 -0
  35. package/dist/cms-core/fixtures.d.ts +92 -0
  36. package/dist/cms-core/fixtures.js +357 -0
  37. package/dist/cms-core/fixtures.js.map +1 -0
  38. package/dist/cms-core/hierarchy.d.ts +113 -0
  39. package/dist/cms-core/hierarchy.js +223 -0
  40. package/dist/cms-core/hierarchy.js.map +1 -0
  41. package/dist/cms-core/index.d.ts +25 -0
  42. package/dist/cms-core/index.js +26 -0
  43. package/dist/cms-core/index.js.map +1 -0
  44. package/dist/cms-core/infer.d.ts +103 -0
  45. package/dist/cms-core/infer.js +57 -0
  46. package/dist/cms-core/infer.js.map +1 -0
  47. package/dist/cms-core/issues.d.ts +92 -0
  48. package/dist/cms-core/issues.js +74 -0
  49. package/dist/cms-core/issues.js.map +1 -0
  50. package/dist/cms-core/json-schema.d.ts +25 -0
  51. package/dist/cms-core/json-schema.js +110 -0
  52. package/dist/cms-core/json-schema.js.map +1 -0
  53. package/dist/cms-core/localization.d.ts +51 -0
  54. package/dist/cms-core/localization.js +89 -0
  55. package/dist/cms-core/localization.js.map +1 -0
  56. package/dist/cms-core/routes.d.ts +76 -0
  57. package/dist/cms-core/routes.js +220 -0
  58. package/dist/cms-core/routes.js.map +1 -0
  59. package/dist/cms-core/self-type.d.ts +41 -0
  60. package/dist/cms-core/self-type.js +191 -0
  61. package/dist/cms-core/self-type.js.map +1 -0
  62. package/dist/cms-core/url-for-document.d.ts +39 -0
  63. package/dist/cms-core/url-for-document.js +138 -0
  64. package/dist/cms-core/url-for-document.js.map +1 -0
  65. package/dist/cms-core/validate-document.d.ts +121 -0
  66. package/dist/cms-core/validate-document.js +871 -0
  67. package/dist/cms-core/validate-document.js.map +1 -0
  68. package/dist/cms-core/versions.d.ts +75 -0
  69. package/dist/cms-core/versions.js +97 -0
  70. package/dist/cms-core/versions.js.map +1 -0
  71. package/dist/collaboration/approval.d.ts +68 -0
  72. package/dist/collaboration/approval.js +104 -0
  73. package/dist/collaboration/approval.js.map +1 -0
  74. package/dist/collaboration/collaboration.d.ts +49 -0
  75. package/dist/collaboration/collaboration.js +56 -0
  76. package/dist/collaboration/collaboration.js.map +1 -0
  77. package/dist/collaboration/comments.d.ts +72 -0
  78. package/dist/collaboration/comments.js +118 -0
  79. package/dist/collaboration/comments.js.map +1 -0
  80. package/dist/collaboration/core.d.ts +25 -0
  81. package/dist/collaboration/core.js +26 -0
  82. package/dist/collaboration/core.js.map +1 -0
  83. package/dist/collaboration/index.d.ts +14 -0
  84. package/dist/collaboration/index.js +15 -0
  85. package/dist/collaboration/index.js.map +1 -0
  86. package/dist/collaboration/presence.d.ts +62 -0
  87. package/dist/collaboration/presence.js +85 -0
  88. package/dist/collaboration/presence.js.map +1 -0
  89. package/dist/collaboration/publishing.d.ts +60 -0
  90. package/dist/collaboration/publishing.js +93 -0
  91. package/dist/collaboration/publishing.js.map +1 -0
  92. package/dist/collaboration/versions.d.ts +52 -0
  93. package/dist/collaboration/versions.js +81 -0
  94. package/dist/collaboration/versions.js.map +1 -0
  95. package/dist/component-registry/index.d.ts +3 -0
  96. package/dist/component-registry/index.js +4 -0
  97. package/dist/component-registry/index.js.map +1 -0
  98. package/dist/component-registry/issues.d.ts +6 -0
  99. package/dist/component-registry/issues.js +2 -0
  100. package/dist/component-registry/issues.js.map +1 -0
  101. package/dist/component-registry/manifest.d.ts +164 -0
  102. package/dist/component-registry/manifest.js +129 -0
  103. package/dist/component-registry/manifest.js.map +1 -0
  104. package/dist/component-registry/registry.d.ts +33 -0
  105. package/dist/component-registry/registry.js +90 -0
  106. package/dist/component-registry/registry.js.map +1 -0
  107. package/dist/content/__fixtures__/filterable-collections.d.ts +14 -0
  108. package/dist/content/__fixtures__/filterable-collections.js +15 -0
  109. package/dist/content/__fixtures__/filterable-collections.js.map +1 -0
  110. package/dist/content/__fixtures__/sample-accessor-types.d.ts +56 -0
  111. package/dist/content/__fixtures__/sample-accessor-types.js +5 -0
  112. package/dist/content/__fixtures__/sample-accessor-types.js.map +1 -0
  113. package/dist/content/__fixtures__/sample-delivery-types.d.ts +122 -0
  114. package/dist/content/__fixtures__/sample-delivery-types.js +5 -0
  115. package/dist/content/__fixtures__/sample-delivery-types.js.map +1 -0
  116. package/dist/content/assets.d.ts +53 -0
  117. package/dist/content/assets.js +38 -0
  118. package/dist/content/assets.js.map +1 -0
  119. package/dist/content/binding-sources.d.ts +53 -0
  120. package/dist/content/binding-sources.js +73 -0
  121. package/dist/content/binding-sources.js.map +1 -0
  122. package/dist/content/client.d.ts +90 -0
  123. package/dist/content/client.js +383 -0
  124. package/dist/content/client.js.map +1 -0
  125. package/dist/content/codegen.d.ts +54 -0
  126. package/dist/content/codegen.js +305 -0
  127. package/dist/content/codegen.js.map +1 -0
  128. package/dist/content/context.d.ts +38 -0
  129. package/dist/content/context.js +21 -0
  130. package/dist/content/context.js.map +1 -0
  131. package/dist/content/cursor.d.ts +33 -0
  132. package/dist/content/cursor.js +104 -0
  133. package/dist/content/cursor.js.map +1 -0
  134. package/dist/content/index.d.ts +28 -0
  135. package/dist/content/index.js +29 -0
  136. package/dist/content/index.js.map +1 -0
  137. package/dist/content/locale.d.ts +30 -0
  138. package/dist/content/locale.js +26 -0
  139. package/dist/content/locale.js.map +1 -0
  140. package/dist/content/perspective.d.ts +29 -0
  141. package/dist/content/perspective.js +31 -0
  142. package/dist/content/perspective.js.map +1 -0
  143. package/dist/content/populate.d.ts +25 -0
  144. package/dist/content/populate.js +22 -0
  145. package/dist/content/populate.js.map +1 -0
  146. package/dist/content/query.d.ts +122 -0
  147. package/dist/content/query.js +257 -0
  148. package/dist/content/query.js.map +1 -0
  149. package/dist/content/raw.d.ts +13 -0
  150. package/dist/content/raw.js +14 -0
  151. package/dist/content/raw.js.map +1 -0
  152. package/dist/content/resolve.d.ts +97 -0
  153. package/dist/content/resolve.js +261 -0
  154. package/dist/content/resolve.js.map +1 -0
  155. package/dist/content/serialize.d.ts +30 -0
  156. package/dist/content/serialize.js +57 -0
  157. package/dist/content/serialize.js.map +1 -0
  158. package/dist/content/tags.d.ts +54 -0
  159. package/dist/content/tags.js +40 -0
  160. package/dist/content/tags.js.map +1 -0
  161. package/dist/data-binding/fixtures.d.ts +20 -0
  162. package/dist/data-binding/fixtures.js +47 -0
  163. package/dist/data-binding/fixtures.js.map +1 -0
  164. package/dist/data-binding/index.d.ts +14 -0
  165. package/dist/data-binding/index.js +15 -0
  166. package/dist/data-binding/index.js.map +1 -0
  167. package/dist/data-binding/issues.d.ts +45 -0
  168. package/dist/data-binding/issues.js +46 -0
  169. package/dist/data-binding/issues.js.map +1 -0
  170. package/dist/data-binding/resolve.d.ts +87 -0
  171. package/dist/data-binding/resolve.js +204 -0
  172. package/dist/data-binding/resolve.js.map +1 -0
  173. package/dist/data-binding/sample.d.ts +21 -0
  174. package/dist/data-binding/sample.js +23 -0
  175. package/dist/data-binding/sample.js.map +1 -0
  176. package/dist/data-binding/sources.d.ts +225 -0
  177. package/dist/data-binding/sources.js +154 -0
  178. package/dist/data-binding/sources.js.map +1 -0
  179. package/dist/data-binding/tokens.d.ts +62 -0
  180. package/dist/data-binding/tokens.js +150 -0
  181. package/dist/data-binding/tokens.js.map +1 -0
  182. package/dist/design-tokens/css.d.ts +34 -0
  183. package/dist/design-tokens/css.js +51 -0
  184. package/dist/design-tokens/css.js.map +1 -0
  185. package/dist/design-tokens/index.d.ts +10 -0
  186. package/dist/design-tokens/index.js +11 -0
  187. package/dist/design-tokens/index.js.map +1 -0
  188. package/dist/design-tokens/style-guide.d.ts +30 -0
  189. package/dist/design-tokens/style-guide.js +31 -0
  190. package/dist/design-tokens/style-guide.js.map +1 -0
  191. package/dist/design-tokens/tokens.d.ts +89 -0
  192. package/dist/design-tokens/tokens.js +112 -0
  193. package/dist/design-tokens/tokens.js.map +1 -0
  194. package/dist/export-sync/builder-source.d.ts +85 -0
  195. package/dist/export-sync/builder-source.js +124 -0
  196. package/dist/export-sync/builder-source.js.map +1 -0
  197. package/dist/export-sync/check.d.ts +61 -0
  198. package/dist/export-sync/check.js +126 -0
  199. package/dist/export-sync/check.js.map +1 -0
  200. package/dist/export-sync/cli.d.ts +89 -0
  201. package/dist/export-sync/cli.js +323 -0
  202. package/dist/export-sync/cli.js.map +1 -0
  203. package/dist/export-sync/core.d.ts +58 -0
  204. package/dist/export-sync/core.js +41 -0
  205. package/dist/export-sync/core.js.map +1 -0
  206. package/dist/export-sync/eject.d.ts +28 -0
  207. package/dist/export-sync/eject.js +21 -0
  208. package/dist/export-sync/eject.js.map +1 -0
  209. package/dist/export-sync/fixtures.d.ts +25 -0
  210. package/dist/export-sync/fixtures.js +87 -0
  211. package/dist/export-sync/fixtures.js.map +1 -0
  212. package/dist/export-sync/generate.d.ts +7 -0
  213. package/dist/export-sync/generate.js +505 -0
  214. package/dist/export-sync/generate.js.map +1 -0
  215. package/dist/export-sync/index.d.ts +37 -0
  216. package/dist/export-sync/index.js +39 -0
  217. package/dist/export-sync/index.js.map +1 -0
  218. package/dist/export-sync/init.d.ts +123 -0
  219. package/dist/export-sync/init.js +234 -0
  220. package/dist/export-sync/init.js.map +1 -0
  221. package/dist/export-sync/manifest-host.d.ts +48 -0
  222. package/dist/export-sync/manifest-host.js +73 -0
  223. package/dist/export-sync/manifest-host.js.map +1 -0
  224. package/dist/export-sync/node.d.ts +20 -0
  225. package/dist/export-sync/node.js +101 -0
  226. package/dist/export-sync/node.js.map +1 -0
  227. package/dist/export-sync/push.d.ts +76 -0
  228. package/dist/export-sync/push.js +197 -0
  229. package/dist/export-sync/push.js.map +1 -0
  230. package/dist/export-sync/registry-sync-client.d.ts +59 -0
  231. package/dist/export-sync/registry-sync-client.js +97 -0
  232. package/dist/export-sync/registry-sync-client.js.map +1 -0
  233. package/dist/export-sync/sync.d.ts +47 -0
  234. package/dist/export-sync/sync.js +47 -0
  235. package/dist/export-sync/sync.js.map +1 -0
  236. package/dist/export-sync/typegen.d.ts +40 -0
  237. package/dist/export-sync/typegen.js +45 -0
  238. package/dist/export-sync/typegen.js.map +1 -0
  239. package/dist/export-sync/validate.d.ts +19 -0
  240. package/dist/export-sync/validate.js +102 -0
  241. package/dist/export-sync/validate.js.map +1 -0
  242. package/dist/export-sync/watch.d.ts +66 -0
  243. package/dist/export-sync/watch.js +70 -0
  244. package/dist/export-sync/watch.js.map +1 -0
  245. package/dist/operations/assets.d.ts +198 -0
  246. package/dist/operations/assets.js +75 -0
  247. package/dist/operations/assets.js.map +1 -0
  248. package/dist/operations/authorization.d.ts +49 -0
  249. package/dist/operations/authorization.js +128 -0
  250. package/dist/operations/authorization.js.map +1 -0
  251. package/dist/operations/changesets.d.ts +160 -0
  252. package/dist/operations/changesets.js +442 -0
  253. package/dist/operations/changesets.js.map +1 -0
  254. package/dist/operations/client.d.ts +49 -0
  255. package/dist/operations/client.js +57 -0
  256. package/dist/operations/client.js.map +1 -0
  257. package/dist/operations/core.d.ts +238 -0
  258. package/dist/operations/core.js +269 -0
  259. package/dist/operations/core.js.map +1 -0
  260. package/dist/operations/documents.d.ts +432 -0
  261. package/dist/operations/documents.js +344 -0
  262. package/dist/operations/documents.js.map +1 -0
  263. package/dist/operations/graph.d.ts +138 -0
  264. package/dist/operations/graph.js +78 -0
  265. package/dist/operations/graph.js.map +1 -0
  266. package/dist/operations/index.d.ts +19 -0
  267. package/dist/operations/index.js +20 -0
  268. package/dist/operations/index.js.map +1 -0
  269. package/dist/operations/members.d.ts +87 -0
  270. package/dist/operations/members.js +56 -0
  271. package/dist/operations/members.js.map +1 -0
  272. package/dist/operations/publishing.d.ts +89 -0
  273. package/dist/operations/publishing.js +57 -0
  274. package/dist/operations/publishing.js.map +1 -0
  275. package/dist/operations/references.d.ts +222 -0
  276. package/dist/operations/references.js +177 -0
  277. package/dist/operations/references.js.map +1 -0
  278. package/dist/operations/schema.d.ts +413 -0
  279. package/dist/operations/schema.js +138 -0
  280. package/dist/operations/schema.js.map +1 -0
  281. package/dist/operations/tokens.d.ts +79 -0
  282. package/dist/operations/tokens.js +102 -0
  283. package/dist/operations/tokens.js.map +1 -0
  284. package/dist/persistence/adapter.d.ts +79 -0
  285. package/dist/persistence/adapter.js +55 -0
  286. package/dist/persistence/adapter.js.map +1 -0
  287. package/dist/persistence/assets.d.ts +120 -0
  288. package/dist/persistence/assets.js +141 -0
  289. package/dist/persistence/assets.js.map +1 -0
  290. package/dist/persistence/backend-validation.d.ts +43 -0
  291. package/dist/persistence/backend-validation.js +57 -0
  292. package/dist/persistence/backend-validation.js.map +1 -0
  293. package/dist/persistence/cli-tokens.d.ts +50 -0
  294. package/dist/persistence/cli-tokens.js +66 -0
  295. package/dist/persistence/cli-tokens.js.map +1 -0
  296. package/dist/persistence/cms.d.ts +148 -0
  297. package/dist/persistence/cms.js +232 -0
  298. package/dist/persistence/cms.js.map +1 -0
  299. package/dist/persistence/contract-scenarios.d.ts +73 -0
  300. package/dist/persistence/contract-scenarios.js +496 -0
  301. package/dist/persistence/contract-scenarios.js.map +1 -0
  302. package/dist/persistence/core.d.ts +96 -0
  303. package/dist/persistence/core.js +110 -0
  304. package/dist/persistence/core.js.map +1 -0
  305. package/dist/persistence/graph.d.ts +61 -0
  306. package/dist/persistence/graph.js +98 -0
  307. package/dist/persistence/graph.js.map +1 -0
  308. package/dist/persistence/index.d.ts +22 -0
  309. package/dist/persistence/index.js +23 -0
  310. package/dist/persistence/index.js.map +1 -0
  311. package/dist/persistence/members.d.ts +70 -0
  312. package/dist/persistence/members.js +0 -0
  313. package/dist/persistence/members.js.map +1 -0
  314. package/dist/persistence/publishing.d.ts +59 -0
  315. package/dist/persistence/publishing.js +95 -0
  316. package/dist/persistence/publishing.js.map +1 -0
  317. package/dist/persistence/reference-extraction.d.ts +44 -0
  318. package/dist/persistence/reference-extraction.js +204 -0
  319. package/dist/persistence/reference-extraction.js.map +1 -0
  320. package/dist/persistence/reference-indexing.d.ts +68 -0
  321. package/dist/persistence/reference-indexing.js +112 -0
  322. package/dist/persistence/reference-indexing.js.map +1 -0
  323. package/dist/persistence/references.d.ts +257 -0
  324. package/dist/persistence/references.js +0 -0
  325. package/dist/persistence/references.js.map +1 -0
  326. package/dist/persistence/seed.d.ts +55 -0
  327. package/dist/persistence/seed.js +102 -0
  328. package/dist/persistence/seed.js.map +1 -0
  329. package/dist/persistence/self-maintaining-adapter.d.ts +41 -0
  330. package/dist/persistence/self-maintaining-adapter.js +79 -0
  331. package/dist/persistence/self-maintaining-adapter.js.map +1 -0
  332. package/dist/plugins/asset-storage.d.ts +76 -0
  333. package/dist/plugins/asset-storage.js +104 -0
  334. package/dist/plugins/asset-storage.js.map +1 -0
  335. package/dist/plugins/component-package.d.ts +54 -0
  336. package/dist/plugins/component-package.js +92 -0
  337. package/dist/plugins/component-package.js.map +1 -0
  338. package/dist/plugins/data-sources.d.ts +78 -0
  339. package/dist/plugins/data-sources.js +99 -0
  340. package/dist/plugins/data-sources.js.map +1 -0
  341. package/dist/plugins/examples.d.ts +47 -0
  342. package/dist/plugins/examples.js +205 -0
  343. package/dist/plugins/examples.js.map +1 -0
  344. package/dist/plugins/export-targets.d.ts +47 -0
  345. package/dist/plugins/export-targets.js +78 -0
  346. package/dist/plugins/export-targets.js.map +1 -0
  347. package/dist/plugins/field-types.d.ts +86 -0
  348. package/dist/plugins/field-types.js +93 -0
  349. package/dist/plugins/field-types.js.map +1 -0
  350. package/dist/plugins/hooks.d.ts +60 -0
  351. package/dist/plugins/hooks.js +94 -0
  352. package/dist/plugins/hooks.js.map +1 -0
  353. package/dist/plugins/index.d.ts +27 -0
  354. package/dist/plugins/index.js +28 -0
  355. package/dist/plugins/index.js.map +1 -0
  356. package/dist/plugins/marketplace.d.ts +90 -0
  357. package/dist/plugins/marketplace.js +110 -0
  358. package/dist/plugins/marketplace.js.map +1 -0
  359. package/dist/plugins/plugin.d.ts +107 -0
  360. package/dist/plugins/plugin.js +122 -0
  361. package/dist/plugins/plugin.js.map +1 -0
  362. package/dist/plugins/templates.d.ts +66 -0
  363. package/dist/plugins/templates.js +74 -0
  364. package/dist/plugins/templates.js.map +1 -0
  365. package/dist/project-graph/binding.d.ts +68 -0
  366. package/dist/project-graph/binding.js +39 -0
  367. package/dist/project-graph/binding.js.map +1 -0
  368. package/dist/project-graph/container.d.ts +126 -0
  369. package/dist/project-graph/container.js +221 -0
  370. package/dist/project-graph/container.js.map +1 -0
  371. package/dist/project-graph/edit.d.ts +66 -0
  372. package/dist/project-graph/edit.js +201 -0
  373. package/dist/project-graph/edit.js.map +1 -0
  374. package/dist/project-graph/fixtures.d.ts +51 -0
  375. package/dist/project-graph/fixtures.js +224 -0
  376. package/dist/project-graph/fixtures.js.map +1 -0
  377. package/dist/project-graph/ids.d.ts +17 -0
  378. package/dist/project-graph/ids.js +19 -0
  379. package/dist/project-graph/ids.js.map +1 -0
  380. package/dist/project-graph/index.d.ts +12 -0
  381. package/dist/project-graph/index.js +13 -0
  382. package/dist/project-graph/index.js.map +1 -0
  383. package/dist/project-graph/issues.d.ts +61 -0
  384. package/dist/project-graph/issues.js +44 -0
  385. package/dist/project-graph/issues.js.map +1 -0
  386. package/dist/project-graph/json.d.ts +6 -0
  387. package/dist/project-graph/json.js +10 -0
  388. package/dist/project-graph/json.js.map +1 -0
  389. package/dist/project-graph/node.d.ts +48 -0
  390. package/dist/project-graph/node.js +42 -0
  391. package/dist/project-graph/node.js.map +1 -0
  392. package/dist/project-graph/normalize.d.ts +17 -0
  393. package/dist/project-graph/normalize.js +110 -0
  394. package/dist/project-graph/normalize.js.map +1 -0
  395. package/dist/project-graph/serialize.d.ts +36 -0
  396. package/dist/project-graph/serialize.js +51 -0
  397. package/dist/project-graph/serialize.js.map +1 -0
  398. package/dist/project-graph/structure.d.ts +40 -0
  399. package/dist/project-graph/structure.js +36 -0
  400. package/dist/project-graph/structure.js.map +1 -0
  401. package/dist/project-graph/validate.d.ts +84 -0
  402. package/dist/project-graph/validate.js +158 -0
  403. package/dist/project-graph/validate.js.map +1 -0
  404. package/dist/rich-text/adapter.d.ts +43 -0
  405. package/dist/rich-text/adapter.js +24 -0
  406. package/dist/rich-text/adapter.js.map +1 -0
  407. package/dist/rich-text/dom-editor.d.ts +101 -0
  408. package/dist/rich-text/dom-editor.js +482 -0
  409. package/dist/rich-text/dom-editor.js.map +1 -0
  410. package/dist/rich-text/embed.d.ts +70 -0
  411. package/dist/rich-text/embed.js +70 -0
  412. package/dist/rich-text/embed.js.map +1 -0
  413. package/dist/rich-text/fixtures.d.ts +25 -0
  414. package/dist/rich-text/fixtures.js +115 -0
  415. package/dist/rich-text/fixtures.js.map +1 -0
  416. package/dist/rich-text/html.d.ts +5 -0
  417. package/dist/rich-text/html.js +309 -0
  418. package/dist/rich-text/html.js.map +1 -0
  419. package/dist/rich-text/index.d.ts +19 -0
  420. package/dist/rich-text/index.js +20 -0
  421. package/dist/rich-text/index.js.map +1 -0
  422. package/dist/rich-text/markdown.d.ts +7 -0
  423. package/dist/rich-text/markdown.js +235 -0
  424. package/dist/rich-text/markdown.js.map +1 -0
  425. package/dist/rich-text/portable-text.d.ts +50 -0
  426. package/dist/rich-text/portable-text.js +223 -0
  427. package/dist/rich-text/portable-text.js.map +1 -0
  428. package/dist/rich-text/registry.d.ts +48 -0
  429. package/dist/rich-text/registry.js +16 -0
  430. package/dist/rich-text/registry.js.map +1 -0
  431. package/dist/rich-text/render.d.ts +69 -0
  432. package/dist/rich-text/render.js +205 -0
  433. package/dist/rich-text/render.js.map +1 -0
  434. package/dist/rich-text/schema.d.ts +86 -0
  435. package/dist/rich-text/schema.js +80 -0
  436. package/dist/rich-text/schema.js.map +1 -0
  437. package/dist/rich-text/test-support.d.ts +7 -0
  438. package/dist/rich-text/test-support.js +8 -0
  439. package/dist/rich-text/test-support.js.map +1 -0
  440. package/dist/runtime-renderer/client.d.ts +14 -0
  441. package/dist/runtime-renderer/client.js +15 -0
  442. package/dist/runtime-renderer/client.js.map +1 -0
  443. package/dist/runtime-renderer/condition.d.ts +8 -0
  444. package/dist/runtime-renderer/condition.js +48 -0
  445. package/dist/runtime-renderer/condition.js.map +1 -0
  446. package/dist/runtime-renderer/content-client.d.ts +62 -0
  447. package/dist/runtime-renderer/content-client.js +37 -0
  448. package/dist/runtime-renderer/content-client.js.map +1 -0
  449. package/dist/runtime-renderer/context.d.ts +185 -0
  450. package/dist/runtime-renderer/context.js +7 -0
  451. package/dist/runtime-renderer/context.js.map +1 -0
  452. package/dist/runtime-renderer/fallback.d.ts +39 -0
  453. package/dist/runtime-renderer/fallback.js +45 -0
  454. package/dist/runtime-renderer/fallback.js.map +1 -0
  455. package/dist/runtime-renderer/index.d.ts +13 -0
  456. package/dist/runtime-renderer/index.js +13 -0
  457. package/dist/runtime-renderer/index.js.map +1 -0
  458. package/dist/runtime-renderer/primitives.d.ts +85 -0
  459. package/dist/runtime-renderer/primitives.js +442 -0
  460. package/dist/runtime-renderer/primitives.js.map +1 -0
  461. package/dist/runtime-renderer/render.d.ts +138 -0
  462. package/dist/runtime-renderer/render.js +825 -0
  463. package/dist/runtime-renderer/render.js.map +1 -0
  464. package/dist/runtime-renderer/rich-text.d.ts +26 -0
  465. package/dist/runtime-renderer/rich-text.js +113 -0
  466. package/dist/runtime-renderer/rich-text.js.map +1 -0
  467. package/dist/starter-kits/index.d.ts +13 -0
  468. package/dist/starter-kits/index.js +14 -0
  469. package/dist/starter-kits/index.js.map +1 -0
  470. package/dist/starter-kits/instantiate.d.ts +29 -0
  471. package/dist/starter-kits/instantiate.js +24 -0
  472. package/dist/starter-kits/instantiate.js.map +1 -0
  473. package/dist/starter-kits/kit.d.ts +61 -0
  474. package/dist/starter-kits/kit.js +37 -0
  475. package/dist/starter-kits/kit.js.map +1 -0
  476. package/dist/starter-kits/kits.d.ts +7 -0
  477. package/dist/starter-kits/kits.js +201 -0
  478. package/dist/starter-kits/kits.js.map +1 -0
  479. package/dist/starter-kits/manifests.d.ts +7 -0
  480. package/dist/starter-kits/manifests.js +111 -0
  481. package/dist/starter-kits/manifests.js.map +1 -0
  482. package/dist/starter-kits/upgrade.d.ts +39 -0
  483. package/dist/starter-kits/upgrade.js +54 -0
  484. package/dist/starter-kits/upgrade.js.map +1 -0
  485. package/dist/starter-kits/validate.d.ts +16 -0
  486. package/dist/starter-kits/validate.js +77 -0
  487. package/dist/starter-kits/validate.js.map +1 -0
  488. package/dist/studio-core/context.d.ts +27 -0
  489. package/dist/studio-core/context.js +44 -0
  490. package/dist/studio-core/context.js.map +1 -0
  491. package/dist/studio-core/errors.d.ts +58 -0
  492. package/dist/studio-core/errors.js +74 -0
  493. package/dist/studio-core/errors.js.map +1 -0
  494. package/dist/studio-core/fixtures.d.ts +18 -0
  495. package/dist/studio-core/fixtures.js +83 -0
  496. package/dist/studio-core/fixtures.js.map +1 -0
  497. package/dist/studio-core/ids.d.ts +22 -0
  498. package/dist/studio-core/ids.js +33 -0
  499. package/dist/studio-core/ids.js.map +1 -0
  500. package/dist/studio-core/index.d.ts +11 -0
  501. package/dist/studio-core/index.js +12 -0
  502. package/dist/studio-core/index.js.map +1 -0
  503. package/dist/studio-core/issues.d.ts +50 -0
  504. package/dist/studio-core/issues.js +33 -0
  505. package/dist/studio-core/issues.js.map +1 -0
  506. package/dist/studio-core/metadata.d.ts +109 -0
  507. package/dist/studio-core/metadata.js +74 -0
  508. package/dist/studio-core/metadata.js.map +1 -0
  509. package/dist/studio-core/repository.d.ts +73 -0
  510. package/dist/studio-core/repository.js +202 -0
  511. package/dist/studio-core/repository.js.map +1 -0
  512. package/dist/studio-core/sections.d.ts +73 -0
  513. package/dist/studio-core/sections.js +68 -0
  514. package/dist/studio-core/sections.js.map +1 -0
  515. package/dist/studio-core/validate.d.ts +15 -0
  516. package/dist/studio-core/validate.js +119 -0
  517. package/dist/studio-core/validate.js.map +1 -0
  518. package/dist/studio-core/workspace-config.d.ts +587 -0
  519. package/dist/studio-core/workspace-config.js +434 -0
  520. package/dist/studio-core/workspace-config.js.map +1 -0
  521. package/package.json +104 -0
@@ -0,0 +1,482 @@
1
+ /**
2
+ * Inline-editing DOM bridge (EC-159).
3
+ *
4
+ * The canvas edits rich text by making the *read-only rendered element itself*
5
+ * contenteditable (the EC-158 approach — typography and layout are identical
6
+ * between render and edit states by construction). This module owns the two
7
+ * pure halves of that session:
8
+ *
9
+ * - **pairing** ({@link collectPreservedPairs}): before editing starts, walk
10
+ * the storage tree and the rendered DOM in parallel (the renderer's mapping
11
+ * is deterministic) and find every node that cannot be reconstructed from
12
+ * markup — custom registry blocks/inlines, unknown nodes, images, embeds.
13
+ * The host stamps those elements with {@link PRESERVE_NODE_ATTR} carrying
14
+ * the node's exact JSON and `contenteditable=false`, so they render
15
+ * correctly *inside* the live editor and survive the session byte-exact.
16
+ *
17
+ * - **parse-back** ({@link richTextDocFromDom}): after editing, invert the
18
+ * renderer's markup (`render.tsx`) back into the storage tree. Stamped
19
+ * elements restore their original node verbatim; everything else maps
20
+ * structurally (p/h1..h6/ul/ol/li/blockquote/pre/br/hr + the built-in mark
21
+ * tags). Never throws.
22
+ *
23
+ * Both halves work against minimal structural DOM interfaces so they are
24
+ * unit-testable in a Node environment (this workspace has no DOM test env);
25
+ * real `Element`/`Text` nodes satisfy them in the browser.
26
+ *
27
+ * Storage-format integrity: an untouched session must leave the stored value
28
+ * byte-identical. The session guarantees that by *comparing*, not rewriting:
29
+ * {@link richTextDocsEquivalent} checks the parsed-back tree against the
30
+ * original (normalizing only DOM-induced text-run splits), and an equivalent
31
+ * tree commits nothing — the stored bytes are never replaced by a re-serialization.
32
+ */
33
+ /** Attribute carrying a preserved node's exact storage JSON during a session. */
34
+ export const PRESERVE_NODE_ATTR = 'data-ec-rt-preserve';
35
+ // ---------------------------------------------------------------------------
36
+ // Structural DOM slice (real DOM nodes satisfy these).
37
+ // ---------------------------------------------------------------------------
38
+ export const RT_ELEMENT_NODE = 1;
39
+ export const RT_TEXT_NODE = 3;
40
+ export function isRtElement(node) {
41
+ return node.nodeType === RT_ELEMENT_NODE;
42
+ }
43
+ export function isRtText(node) {
44
+ return node.nodeType === RT_TEXT_NODE;
45
+ }
46
+ function children(node) {
47
+ const out = [];
48
+ for (let i = 0; i < node.childNodes.length; i++)
49
+ out.push(node.childNodes[i]);
50
+ return out;
51
+ }
52
+ function tag(el) {
53
+ return el.tagName.toLowerCase();
54
+ }
55
+ // ---------------------------------------------------------------------------
56
+ // Invertibility: which storage node types the markup parser can reconstruct.
57
+ // ---------------------------------------------------------------------------
58
+ const INVERTIBLE_NODE_TYPES = new Set([
59
+ 'doc',
60
+ 'text',
61
+ 'paragraph',
62
+ 'heading',
63
+ 'bulletList',
64
+ 'orderedList',
65
+ 'listItem',
66
+ 'blockquote',
67
+ 'codeBlock',
68
+ 'hardBreak',
69
+ 'horizontalRule',
70
+ ]);
71
+ /**
72
+ * Whether a storage node type can be reconstructed from rendered markup.
73
+ * Images, embeds, custom registry nodes, and unknown nodes are *not* — they
74
+ * must be preserved verbatim during an editing session (atoms, not markup).
75
+ */
76
+ export function isInvertibleRichTextNodeType(type) {
77
+ return INVERTIBLE_NODE_TYPES.has(type);
78
+ }
79
+ /**
80
+ * Walk a document tree and its rendered DOM in parallel and return every
81
+ * non-invertible node paired with its element, so the host can stamp them
82
+ * before the DOM becomes editable. Returns `null` when the DOM does not match
83
+ * the renderer's deterministic mapping (the session should then refuse to
84
+ * start rather than risk lossy parsing).
85
+ */
86
+ export function collectPreservedPairs(doc, host) {
87
+ const pairs = [];
88
+ return pairChildren(doc.content ?? [], children(host), pairs) ? pairs : null;
89
+ }
90
+ /** Pair an ordered storage child list against an ordered DOM child list. */
91
+ function pairChildren(nodes, dom, out) {
92
+ if (nodes.length !== dom.length)
93
+ return false;
94
+ for (let i = 0; i < nodes.length; i++) {
95
+ if (!pairNode(nodes[i], dom[i], out))
96
+ return false;
97
+ }
98
+ return true;
99
+ }
100
+ function pairNode(node, dom, out) {
101
+ if (node.type === 'text') {
102
+ // Renders as a bare text node, or as a chain of mark wrappers around one.
103
+ return pairTextNode(node, dom);
104
+ }
105
+ if (!isRtElement(dom))
106
+ return false;
107
+ if (!isInvertibleRichTextNodeType(node.type)) {
108
+ out.push({ node, element: dom });
109
+ return true;
110
+ }
111
+ switch (node.type) {
112
+ case 'paragraph':
113
+ case 'heading':
114
+ case 'bulletList':
115
+ case 'orderedList':
116
+ case 'listItem':
117
+ case 'blockquote':
118
+ return pairChildren(node.content ?? [], children(dom), out);
119
+ case 'codeBlock': {
120
+ // pre > code > text — nothing preservable inside a code block.
121
+ return tag(dom) === 'pre';
122
+ }
123
+ case 'hardBreak':
124
+ return tag(dom) === 'br';
125
+ case 'horizontalRule':
126
+ return tag(dom) === 'hr';
127
+ default:
128
+ return true;
129
+ }
130
+ }
131
+ /** A text node renders as marks-nested wrappers ending in exactly one text node. */
132
+ function pairTextNode(node, dom) {
133
+ let current = dom;
134
+ let depth = 0;
135
+ const markCount = node.marks?.length ?? 0;
136
+ while (isRtElement(current)) {
137
+ const kids = children(current);
138
+ if (kids.length !== 1)
139
+ return false;
140
+ current = kids[0];
141
+ depth++;
142
+ if (depth > markCount + 4)
143
+ return false;
144
+ }
145
+ return isRtText(current) && current.data === (node.text ?? '');
146
+ }
147
+ const HEADING_LEVELS = { h1: 1, h2: 2, h3: 3, h4: 4, h5: 5, h6: 6 };
148
+ const MARK_BY_TAG = {
149
+ strong: 'bold',
150
+ b: 'bold',
151
+ em: 'italic',
152
+ i: 'italic',
153
+ code: 'code',
154
+ s: 'strike',
155
+ strike: 'strike',
156
+ del: 'strike',
157
+ u: 'underline',
158
+ };
159
+ const BLOCK_TAGS = new Set([
160
+ 'p',
161
+ 'h1',
162
+ 'h2',
163
+ 'h3',
164
+ 'h4',
165
+ 'h5',
166
+ 'h6',
167
+ 'ul',
168
+ 'ol',
169
+ 'li',
170
+ 'blockquote',
171
+ 'pre',
172
+ 'hr',
173
+ 'div',
174
+ 'section',
175
+ 'article',
176
+ 'aside',
177
+ 'figure',
178
+ ]);
179
+ /** Restore a stamped element's original storage node ({@link PRESERVE_NODE_ATTR}). */
180
+ function preservedNodeOf(el) {
181
+ const raw = el.getAttribute(PRESERVE_NODE_ATTR);
182
+ if (raw === null)
183
+ return null;
184
+ try {
185
+ const parsed = JSON.parse(raw);
186
+ if (typeof parsed === 'object' && parsed !== null && typeof parsed.type === 'string') {
187
+ return parsed;
188
+ }
189
+ }
190
+ catch {
191
+ // fall through to lossy handling
192
+ }
193
+ return null;
194
+ }
195
+ function textNodeOf(text, marks) {
196
+ return marks.length > 0 ? { type: 'text', text, marks: [...marks] } : { type: 'text', text };
197
+ }
198
+ /** Parse inline content. `outerMarks` is ordered outermost→innermost. */
199
+ function parseInline(nodes, outerMarks, ctx) {
200
+ const out = [];
201
+ for (const node of nodes) {
202
+ if (isRtText(node)) {
203
+ if (node.data.length > 0) {
204
+ // `outerMarks` is built by prepending on descent, so it already sits in
205
+ // storage order: innermost-first (render wraps marks[0] innermost).
206
+ out.push(textNodeOf(node.data, outerMarks));
207
+ }
208
+ continue;
209
+ }
210
+ if (!isRtElement(node))
211
+ continue;
212
+ const preserved = preservedNodeOf(node);
213
+ if (preserved) {
214
+ out.push(preserved);
215
+ continue;
216
+ }
217
+ const t = tag(node);
218
+ if (t === 'br') {
219
+ out.push({ type: 'hardBreak' });
220
+ continue;
221
+ }
222
+ if (t === 'img') {
223
+ out.push(imageNodeOf(node));
224
+ continue;
225
+ }
226
+ const mark = inlineMarkOf(node, ctx);
227
+ if (mark) {
228
+ out.push(...parseInline(children(node), [mark, ...outerMarks], ctx));
229
+ continue;
230
+ }
231
+ // Unknown inline wrapper (e.g. an editor-inserted span): descend transparently.
232
+ out.push(...parseInline(children(node), outerMarks, ctx));
233
+ }
234
+ return out;
235
+ }
236
+ /** The mark an inline wrapper element represents, if any. */
237
+ function inlineMarkOf(el, ctx) {
238
+ const t = tag(el);
239
+ const builtin = MARK_BY_TAG[t];
240
+ if (builtin)
241
+ return { type: builtin };
242
+ if (t === 'a') {
243
+ const attrs = { href: el.getAttribute('href') ?? '#' };
244
+ const target = el.getAttribute('target');
245
+ if (target)
246
+ attrs.target = target;
247
+ const rel = el.getAttribute('rel');
248
+ // The renderer synthesizes rel="noopener noreferrer" for target=_blank; do
249
+ // not read that synthesis back into storage attrs.
250
+ if (rel && !(target === '_blank' && rel === 'noopener noreferrer'))
251
+ attrs.rel = rel;
252
+ return { type: 'link', attrs };
253
+ }
254
+ const unknownMark = el.getAttribute('data-unknown-mark');
255
+ if (unknownMark) {
256
+ ctx.issues.push({
257
+ code: 'lossy-node',
258
+ message: `Unknown mark "${unknownMark}" was reconstructed without its attributes.`,
259
+ detail: unknownMark,
260
+ });
261
+ return { type: unknownMark };
262
+ }
263
+ return null;
264
+ }
265
+ function imageNodeOf(el) {
266
+ const attrs = {
267
+ src: el.getAttribute('src') ?? '',
268
+ alt: el.getAttribute('alt') ?? '',
269
+ };
270
+ const title = el.getAttribute('title');
271
+ if (title)
272
+ attrs.title = title;
273
+ return { type: 'image', attrs };
274
+ }
275
+ function embedNodeOf(el) {
276
+ const attrs = {
277
+ src: el.getAttribute('src') ?? '',
278
+ title: el.getAttribute('title') ?? 'Embedded content',
279
+ };
280
+ const provider = el.getAttribute('data-embed-provider');
281
+ if (provider)
282
+ attrs.provider = provider;
283
+ return { type: 'embed', attrs };
284
+ }
285
+ /** Whether a DOM child list contains block-level elements. */
286
+ function hasBlockChildren(nodes) {
287
+ return nodes.some((n) => isRtElement(n) && BLOCK_TAGS.has(tag(n)));
288
+ }
289
+ function parseBlocks(nodes, ctx) {
290
+ const out = [];
291
+ let looseInline = [];
292
+ const flushLoose = () => {
293
+ if (looseInline.length === 0)
294
+ return;
295
+ const inline = parseInline(looseInline, [], ctx);
296
+ looseInline = [];
297
+ if (inline.some((n) => n.type !== 'text' || (n.text ?? '').trim().length > 0)) {
298
+ out.push({ type: 'paragraph', content: inline });
299
+ }
300
+ };
301
+ for (const node of nodes) {
302
+ if (isRtText(node)) {
303
+ looseInline.push(node);
304
+ continue;
305
+ }
306
+ if (!isRtElement(node))
307
+ continue;
308
+ const preserved = preservedNodeOf(node);
309
+ if (preserved) {
310
+ flushLoose();
311
+ out.push(preserved);
312
+ continue;
313
+ }
314
+ const t = tag(node);
315
+ const block = parseBlockElement(node, t, ctx);
316
+ if (block === 'inline') {
317
+ looseInline.push(node);
318
+ continue;
319
+ }
320
+ flushLoose();
321
+ if (block !== null)
322
+ out.push(...block);
323
+ }
324
+ flushLoose();
325
+ return out;
326
+ }
327
+ /**
328
+ * Parse one block-level element. Returns the storage nodes it maps to, `null`
329
+ * to drop it, or `'inline'` when the element belongs to inline flow.
330
+ */
331
+ function parseBlockElement(el, t, ctx) {
332
+ const level = HEADING_LEVELS[t];
333
+ if (level !== undefined) {
334
+ return [{ type: 'heading', attrs: { level }, content: parseInline(children(el), [], ctx) }];
335
+ }
336
+ switch (t) {
337
+ case 'p':
338
+ return [{ type: 'paragraph', content: parseInline(children(el), [], ctx) }];
339
+ case 'ul':
340
+ return [{ type: 'bulletList', content: parseListItems(el, ctx) }];
341
+ case 'ol':
342
+ return [{ type: 'orderedList', content: parseListItems(el, ctx) }];
343
+ case 'blockquote':
344
+ return [{ type: 'blockquote', content: parseBlocks(children(el), ctx) }];
345
+ case 'pre':
346
+ return [parseCodeBlock(el)];
347
+ case 'hr':
348
+ return [{ type: 'horizontalRule' }];
349
+ case 'img':
350
+ return [imageNodeOf(el)];
351
+ case 'iframe':
352
+ return [embedNodeOf(el)];
353
+ case 'br':
354
+ return [{ type: 'paragraph', content: [{ type: 'hardBreak' }] }];
355
+ case 'style':
356
+ return null;
357
+ default: {
358
+ const unknownType = el.getAttribute('data-unknown-node');
359
+ if (unknownType) {
360
+ // An unknown-node fallback that was not stamped: keep the type visible,
361
+ // but its attrs/content cannot be reconstructed from the fallback text.
362
+ ctx.issues.push({
363
+ code: 'lossy-node',
364
+ message: `Unknown rich-text node "${unknownType}" was reconstructed without its attributes.`,
365
+ detail: unknownType,
366
+ });
367
+ return [{ type: unknownType }];
368
+ }
369
+ if (!BLOCK_TAGS.has(t))
370
+ return 'inline';
371
+ // Editor-inserted generic containers (e.g. Chrome's contenteditable
372
+ // `<div>` lines): blocks descend, inline runs become a paragraph.
373
+ const kids = children(el);
374
+ if (hasBlockChildren(kids))
375
+ return parseBlocks(kids, ctx);
376
+ return [{ type: 'paragraph', content: parseInline(kids, [], ctx) }];
377
+ }
378
+ }
379
+ }
380
+ function parseListItems(list, ctx) {
381
+ const items = [];
382
+ for (const node of children(list)) {
383
+ if (!isRtElement(node))
384
+ continue;
385
+ if (tag(node) !== 'li')
386
+ continue;
387
+ const kids = children(node);
388
+ const content = hasBlockChildren(kids)
389
+ ? parseBlocks(kids, ctx)
390
+ : [{ type: 'paragraph', content: parseInline(kids, [], ctx) }];
391
+ items.push({ type: 'listItem', content: content.length > 0 ? content : [{ type: 'paragraph', content: [] }] });
392
+ }
393
+ return items;
394
+ }
395
+ function parseCodeBlock(pre) {
396
+ // pre > optional code wrapper > text. Language from `language-*` className.
397
+ let host = pre;
398
+ const kids = children(pre);
399
+ const codeEl = kids.find((n) => isRtElement(n) && tag(n) === 'code');
400
+ if (codeEl)
401
+ host = codeEl;
402
+ const language = (host.getAttribute('class') ?? '').match(/language-([\w-]+)/)?.[1];
403
+ const text = collectText(host);
404
+ return {
405
+ type: 'codeBlock',
406
+ ...(language ? { attrs: { language } } : {}),
407
+ content: text.length > 0 ? [{ type: 'text', text }] : [],
408
+ };
409
+ }
410
+ function collectText(el) {
411
+ let out = '';
412
+ for (const node of children(el)) {
413
+ if (isRtText(node))
414
+ out += node.data;
415
+ else if (isRtElement(node))
416
+ out += tag(node) === 'br' ? '\n' : collectText(node);
417
+ }
418
+ return out;
419
+ }
420
+ /**
421
+ * Parse an editing host's DOM back into a storage document. Never throws;
422
+ * anything that could not be fully reconstructed is reported as an issue (and
423
+ * still yields a visible node, never silent loss).
424
+ */
425
+ export function richTextDocFromDom(host) {
426
+ const ctx = { issues: [] };
427
+ const content = parseBlocks(children(host), ctx);
428
+ return { doc: { type: 'doc', content }, issues: ctx.issues };
429
+ }
430
+ // ---------------------------------------------------------------------------
431
+ // Equivalence: did the session actually change the document?
432
+ // ---------------------------------------------------------------------------
433
+ function sameMarks(a, b) {
434
+ return canonicalJson(a ?? []) === canonicalJson(b ?? []);
435
+ }
436
+ /**
437
+ * Normalize a tree for comparison only (never for storage): merge adjacent
438
+ * text nodes carrying identical marks and drop empty text nodes — the splits
439
+ * and joins a contenteditable session performs without changing content.
440
+ */
441
+ export function normalizeForComparison(nodes) {
442
+ const out = [];
443
+ for (const node of nodes) {
444
+ const normalized = node.content
445
+ ? { ...node, content: normalizeForComparison(node.content) }
446
+ : { ...node };
447
+ if (normalized.type === 'text') {
448
+ if ((normalized.text ?? '') === '')
449
+ continue;
450
+ const prev = out[out.length - 1];
451
+ if (prev && prev.type === 'text' && sameMarks(prev.marks, normalized.marks)) {
452
+ out[out.length - 1] = { ...prev, text: (prev.text ?? '') + (normalized.text ?? '') };
453
+ continue;
454
+ }
455
+ }
456
+ out.push(normalized);
457
+ }
458
+ return out;
459
+ }
460
+ /** Key-order-insensitive canonical JSON (object keys sorted recursively). */
461
+ function canonicalJson(value) {
462
+ if (value === null || typeof value !== 'object')
463
+ return JSON.stringify(value) ?? 'null';
464
+ if (Array.isArray(value))
465
+ return `[${value.map(canonicalJson).join(',')}]`;
466
+ const entries = Object.entries(value)
467
+ .filter(([, v]) => v !== undefined)
468
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
469
+ .map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`);
470
+ return `{${entries.join(',')}}`;
471
+ }
472
+ /**
473
+ * Whether two documents carry the same content, ignoring object key order and
474
+ * DOM-induced text-run splits. An equivalent parse-back means the editing
475
+ * session changed nothing and must not dispatch — leaving the stored value
476
+ * byte-identical (it is never rewritten).
477
+ */
478
+ export function richTextDocsEquivalent(a, b) {
479
+ return (canonicalJson({ type: 'doc', content: normalizeForComparison(a.content ?? []) }) ===
480
+ canonicalJson({ type: 'doc', content: normalizeForComparison(b.content ?? []) }));
481
+ }
482
+ //# sourceMappingURL=dom-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-editor.js","sourceRoot":"","sources":["../../src/rich-text/dom-editor.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,iFAAiF;AACjF,MAAM,CAAC,MAAM,kBAAkB,GAAG,qBAAqB,CAAA;AAEvD,8EAA8E;AAC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ytracms/core/project-graph';
2
+ import type { JsonValue } from '@elytracms/core/project-graph';
3
+ import type { RichTextDoc, RichTextNode } from './schema';
4
+ /**
5
+ * Rich-text component embeds (EC-189, AD-12).
6
+ *
7
+ * A `componentEmbed` is a custom *block* node in the rich-text storage format
8
+ * whose single `attrs.node` holds a composition value — one `ComponentNode` (an
9
+ * embedded registry component plus its static field-value props). It is the third
10
+ * place constrained composition lives (after the page collection and `blocks`
11
+ * fields): a registry component embedded in long-form prose, Portable-Text-style.
12
+ *
13
+ * The embed serializes through the EXISTING storage format with no schema change:
14
+ * `richTextNodeSchema` keeps `type` an open string and `attrs` a plain-JSON bag, a
15
+ * `ComponentNode` is plain JSON (Zod-validated, no runtime handles), so an embed
16
+ * round-trips byte-for-byte through `parseRichTextValue`/`serializeRichTextValue`.
17
+ * The helpers below give the embed a named type, a typed accessor, and a
18
+ * constructor so consumers (renderer, extractor, validator) never reach into the
19
+ * raw `attrs` bag. An embed whose `attrs.node` is missing or malformed degrades to
20
+ * the renderer's visible fallback — never a crash, never silent (AGENTS.md).
21
+ */
22
+ /** The storage `node.type` for an embedded registry component. */
23
+ export declare const COMPONENT_EMBED_NODE_TYPE = "componentEmbed";
24
+ /**
25
+ * A rich-text embed node, narrowed: a `componentEmbed` whose `attrs.node` is the
26
+ * embedded composition value. `attrs.node` is typed `JsonValue` at the storage
27
+ * layer (the format never carries runtime handles); read it through
28
+ * {@link embeddedComponentNode}, which validates it as a `ComponentNode`.
29
+ */
30
+ export interface ComponentEmbedNode extends RichTextNode {
31
+ type: typeof COMPONENT_EMBED_NODE_TYPE;
32
+ attrs?: {
33
+ node?: JsonValue;
34
+ } & Record<string, JsonValue>;
35
+ }
36
+ /** Structural test for a `componentEmbed` node (by `node.type`). */
37
+ export declare function isComponentEmbedNode(node: RichTextNode): node is ComponentEmbedNode;
38
+ /**
39
+ * Read the embedded composition value (a single `ComponentNode`) from a
40
+ * `componentEmbed` node, validating it via `componentNodeSchema`. Returns
41
+ * `undefined` for an embed with no/malformed `attrs.node` (the renderer shows its
42
+ * visible fallback; validation reports the structured issue). Never throws.
43
+ */
44
+ export declare function embeddedComponentNode(node: RichTextNode): ComponentNode | undefined;
45
+ /**
46
+ * Build a `componentEmbed` storage node wrapping a single composition root. The
47
+ * node carries no `content` (an embed is an atom — the embedded component owns its
48
+ * own children through the composition's slots, not the rich-text tree).
49
+ */
50
+ export declare function componentEmbedNode(node: ComponentNode): ComponentEmbedNode;
51
+ /**
52
+ * One `componentEmbed` occurrence found while walking a rich-text document: the
53
+ * raw storage node, the embedded composition value (or `undefined` when malformed),
54
+ * and the `/`-joined content-index node path within the document tree (e.g.
55
+ * `doc/content/2`). The path mirrors the reference-extraction encoding so validation
56
+ * findings and where-used entries key the same location. Walks arbitrary depth.
57
+ */
58
+ export interface RichTextEmbedOccurrence {
59
+ node: ComponentEmbedNode;
60
+ embedded: ComponentNode | undefined;
61
+ nodePath: string;
62
+ }
63
+ /**
64
+ * Collect every `componentEmbed` in a rich-text document, at any nesting depth.
65
+ * Pure + structural; never throws. The returned `nodePath` is `doc`-rooted and
66
+ * `/`-joined (`doc/content/<i>/content/<j>/...`), matching the persistence
67
+ * reference-extraction path convention so a validation finding's `nodePath` lines
68
+ * up with the where-used entry for the same embed.
69
+ */
70
+ export declare function collectComponentEmbeds(doc: RichTextDoc): RichTextEmbedOccurrence[];
@@ -0,0 +1,70 @@
1
+ import { componentNodeSchema } from '@elytracms/core/project-graph';
2
+ /**
3
+ * Rich-text component embeds (EC-189, AD-12).
4
+ *
5
+ * A `componentEmbed` is a custom *block* node in the rich-text storage format
6
+ * whose single `attrs.node` holds a composition value — one `ComponentNode` (an
7
+ * embedded registry component plus its static field-value props). It is the third
8
+ * place constrained composition lives (after the page collection and `blocks`
9
+ * fields): a registry component embedded in long-form prose, Portable-Text-style.
10
+ *
11
+ * The embed serializes through the EXISTING storage format with no schema change:
12
+ * `richTextNodeSchema` keeps `type` an open string and `attrs` a plain-JSON bag, a
13
+ * `ComponentNode` is plain JSON (Zod-validated, no runtime handles), so an embed
14
+ * round-trips byte-for-byte through `parseRichTextValue`/`serializeRichTextValue`.
15
+ * The helpers below give the embed a named type, a typed accessor, and a
16
+ * constructor so consumers (renderer, extractor, validator) never reach into the
17
+ * raw `attrs` bag. An embed whose `attrs.node` is missing or malformed degrades to
18
+ * the renderer's visible fallback — never a crash, never silent (AGENTS.md).
19
+ */
20
+ /** The storage `node.type` for an embedded registry component. */
21
+ export const COMPONENT_EMBED_NODE_TYPE = 'componentEmbed';
22
+ /** Structural test for a `componentEmbed` node (by `node.type`). */
23
+ export function isComponentEmbedNode(node) {
24
+ return node.type === COMPONENT_EMBED_NODE_TYPE;
25
+ }
26
+ /**
27
+ * Read the embedded composition value (a single `ComponentNode`) from a
28
+ * `componentEmbed` node, validating it via `componentNodeSchema`. Returns
29
+ * `undefined` for an embed with no/malformed `attrs.node` (the renderer shows its
30
+ * visible fallback; validation reports the structured issue). Never throws.
31
+ */
32
+ export function embeddedComponentNode(node) {
33
+ if (!isComponentEmbedNode(node))
34
+ return undefined;
35
+ const raw = node.attrs?.node;
36
+ const parsed = componentNodeSchema.safeParse(raw);
37
+ return parsed.success ? parsed.data : undefined;
38
+ }
39
+ /**
40
+ * Build a `componentEmbed` storage node wrapping a single composition root. The
41
+ * node carries no `content` (an embed is an atom — the embedded component owns its
42
+ * own children through the composition's slots, not the rich-text tree).
43
+ */
44
+ export function componentEmbedNode(node) {
45
+ return { type: COMPONENT_EMBED_NODE_TYPE, attrs: { node: node } };
46
+ }
47
+ /**
48
+ * Collect every `componentEmbed` in a rich-text document, at any nesting depth.
49
+ * Pure + structural; never throws. The returned `nodePath` is `doc`-rooted and
50
+ * `/`-joined (`doc/content/<i>/content/<j>/...`), matching the persistence
51
+ * reference-extraction path convention so a validation finding's `nodePath` lines
52
+ * up with the where-used entry for the same embed.
53
+ */
54
+ export function collectComponentEmbeds(doc) {
55
+ const out = [];
56
+ const walk = (nodes, path) => {
57
+ if (!nodes)
58
+ return;
59
+ nodes.forEach((node, i) => {
60
+ const here = `${path}/content/${i}`;
61
+ if (isComponentEmbedNode(node)) {
62
+ out.push({ node, embedded: embeddedComponentNode(node), nodePath: here });
63
+ }
64
+ walk(node.content, here);
65
+ });
66
+ };
67
+ walk(doc.content, 'doc');
68
+ return out;
69
+ }
70
+ //# sourceMappingURL=embed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embed.js","sourceRoot":"","sources":["../../src/rich-text/embed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAKnE;;;;;;;;;;;;;;;;;GAiBG;AAEH,kEAAkE;AAClE,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAgB,CAAA;AAazD,oEAAoE;AACpE,MAAM,UAAU,oBAAoB,CAAC,IAAkB;IACrD,OAAO,IAAI,CAAC,IAAI,KAAK,yBAAyB,CAAA;AAChD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAkB;IACtD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAA;IACjD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,IAAI,CAAA;IAC5B,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IACjD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAmB;IACpD,OAAO,EAAE,IAAI,EAAE,yBAAyB,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAA4B,EAAE,EAAE,CAAA;AAC3F,CAAC;AAeD;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAgB;IACrD,MAAM,GAAG,GAA8B,EAAE,CAAA;IACzC,MAAM,IAAI,GAAG,CAAC,KAA0C,EAA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