@phtngyn/cms 0.1.0-beta.1 → 0.1.0-beta.2

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 (142) hide show
  1. package/README.md +192 -9
  2. package/package.json +30 -15
  3. package/src/Configuration-Br7tE9Qt.d.ts +68 -0
  4. package/src/{Configuration-DyKo0sLS.js → Configuration-CA_jvQKG.js} +26 -147
  5. package/src/Configuration-CA_jvQKG.js.map +1 -0
  6. package/src/Configuration.d.ts +2 -44
  7. package/src/Configuration.js +0 -1
  8. package/src/Configuration.js.map +1 -1
  9. package/src/{DocumentEngine-DYObwMDY.js → DocumentEngine-CgiBQU4g.js} +75 -27
  10. package/src/DocumentEngine-CgiBQU4g.js.map +1 -0
  11. package/src/DocumentModel-BB9igGC7.d.ts +34 -0
  12. package/src/DocumentModel.d.ts +2 -34
  13. package/src/DocumentModel.js +13 -3
  14. package/src/DocumentModel.js.map +1 -1
  15. package/src/Forms-BsJMev5_.d.ts +74 -0
  16. package/src/Forms-CfcI3tPU.js +79 -0
  17. package/src/Forms-CfcI3tPU.js.map +1 -0
  18. package/src/Forms-DxbkU3_5.js +367 -0
  19. package/src/Forms-DxbkU3_5.js.map +1 -0
  20. package/src/Forms.d.ts +35 -0
  21. package/src/Forms.js +13 -0
  22. package/src/Forms.js.map +1 -0
  23. package/src/{HttpPaths-BbS21Jy8.js → HttpPaths-c9nLZ9H2.js} +6 -2
  24. package/src/HttpPaths-c9nLZ9H2.js.map +1 -0
  25. package/src/I18n-DZK4CkJF.d.ts +21 -0
  26. package/src/I18n.d.ts +2 -0
  27. package/src/I18n.js +1 -0
  28. package/src/Module.js +57 -11
  29. package/src/Module.js.map +1 -1
  30. package/src/S3MediaObjects-JKMAWyVB.js +2664 -0
  31. package/src/S3MediaObjects-JKMAWyVB.js.map +1 -0
  32. package/src/Seed.d.ts +6 -0
  33. package/src/Seed.js +34 -0
  34. package/src/Seed.js.map +1 -0
  35. package/src/Seo-402YumpT.d.ts +198 -0
  36. package/src/{connection-CBTY-TzB.js → connection-B-iz0Y9Y.js} +5 -7
  37. package/src/connection-B-iz0Y9Y.js.map +1 -0
  38. package/src/{installation-DeuBiFRE.js → installation-DgF2M1gL.js} +1005 -2242
  39. package/src/installation-DgF2M1gL.js.map +1 -0
  40. package/src/internal/authoring-catalog.js +10 -4
  41. package/src/internal/authoring-catalog.js.map +1 -1
  42. package/src/internal/authoring-compiler.js +0 -1
  43. package/src/internal/authoring-compiler.js.map +1 -1
  44. package/src/internal/authoring-metadata.js +4 -4
  45. package/src/internal/authoring-metadata.js.map +1 -1
  46. package/src/internal/cms-config.js +0 -1
  47. package/src/internal/cms-config.js.map +1 -1
  48. package/src/internal/configuration.js +23 -10
  49. package/src/internal/configuration.js.map +1 -1
  50. package/src/internal/document-model.js +65 -20
  51. package/src/internal/document-model.js.map +1 -1
  52. package/src/internal/form-capabilities.js +12 -0
  53. package/src/internal/form-capabilities.js.map +1 -0
  54. package/src/internal/i18n.js +47 -0
  55. package/src/internal/i18n.js.map +1 -0
  56. package/src/internal/studio-app.js +2 -2
  57. package/src/internal/studio-app.js.map +1 -1
  58. package/src/{location-DtYv2aes.js → location-CFKTeK1K.js} +2 -3
  59. package/src/location-CFKTeK1K.js.map +1 -0
  60. package/src/{metadata-DE1Mc2td.js → metadata-BEZPWh-3.js} +3 -72
  61. package/src/metadata-BEZPWh-3.js.map +1 -0
  62. package/src/{models-C3witQBK.js → models-BWm1pTAf.js} +3 -2
  63. package/src/models-BWm1pTAf.js.map +1 -0
  64. package/src/{models-BkMgeaOL.js → models-DwYioyNV.js} +203 -32
  65. package/src/models-DwYioyNV.js.map +1 -0
  66. package/src/runtime/blocks.js +22 -9
  67. package/src/runtime/blocks.js.map +1 -1
  68. package/src/runtime/collaboration.js.map +1 -1
  69. package/src/runtime/delivery/DocumentRenderer.js +7 -4
  70. package/src/runtime/delivery/DocumentRenderer.js.map +1 -1
  71. package/src/runtime/delivery/blocks.js +3 -1
  72. package/src/runtime/delivery/blocks.js.map +1 -1
  73. package/src/runtime/delivery/context.js +1 -1
  74. package/src/runtime/delivery/document-page.js +12 -12
  75. package/src/runtime/delivery/document-page.js.map +1 -1
  76. package/src/runtime/delivery/document.js +4 -2
  77. package/src/runtime/delivery/document.js.map +1 -1
  78. package/src/runtime/delivery/error.js.map +1 -1
  79. package/src/runtime/delivery/plugin.js +22 -2
  80. package/src/runtime/delivery/plugin.js.map +1 -1
  81. package/src/runtime/delivery/types.d.ts +5 -0
  82. package/src/runtime/delivery/useCmsDocumentSeo.d.ts +56 -0
  83. package/src/runtime/delivery/useCmsDocumentSeo.js +99 -0
  84. package/src/runtime/delivery/useCmsDocumentSeo.js.map +1 -0
  85. package/src/runtime/delivery/useDocument.js +2 -2
  86. package/src/runtime/delivery/useDocument.js.map +1 -1
  87. package/src/runtime/delivery/useDocumentQuery.js +2 -2
  88. package/src/runtime/delivery/useDocumentQuery.js.map +1 -1
  89. package/src/runtime/forms/document.js +38 -0
  90. package/src/runtime/forms/document.js.map +1 -0
  91. package/src/runtime/forms/useCmsForm.js +149 -0
  92. package/src/runtime/forms/useCmsForm.js.map +1 -0
  93. package/src/runtime/i18n/translator.js +22 -0
  94. package/src/runtime/i18n/translator.js.map +1 -0
  95. package/src/runtime/i18n/useCmsI18n.d.ts +9 -0
  96. package/src/runtime/i18n/useCmsI18n.js +29 -0
  97. package/src/runtime/i18n/useCmsI18n.js.map +1 -0
  98. package/src/runtime/installation.js +1 -1
  99. package/src/runtime/plugin.js +1 -1
  100. package/src/runtime/plugin.js.map +1 -1
  101. package/src/runtime/preview/comark-document.js +0 -1
  102. package/src/runtime/preview/comark-document.js.map +1 -1
  103. package/src/runtime/preview/connection.js +1 -1
  104. package/src/runtime/preview/controller.js +10 -3
  105. package/src/runtime/preview/controller.js.map +1 -1
  106. package/src/runtime/preview/overlay.js.map +1 -1
  107. package/src/runtime/preview/plugin.client.js +59 -48
  108. package/src/runtime/preview/plugin.client.js.map +1 -1
  109. package/src/runtime/preview/protocol.js.map +1 -1
  110. package/src/runtime/preview/store.js +1 -1
  111. package/src/runtime/preview/targets.js +0 -1
  112. package/src/runtime/preview/targets.js.map +1 -1
  113. package/src/runtime/sitemap-entries.js +17 -0
  114. package/src/runtime/sitemap-entries.js.map +1 -0
  115. package/src/runtime/sitemap.js +24 -0
  116. package/src/runtime/sitemap.js.map +1 -0
  117. package/src/runtime/studio-app.js.map +1 -1
  118. package/src/runtime/studio-entry.js +2 -2
  119. package/src/runtime/studio-entry.js.map +1 -1
  120. package/src/runtime/studio-navigation.js +1 -1
  121. package/src/scalars-B2lgGUnj.js +26 -0
  122. package/src/scalars-B2lgGUnj.js.map +1 -0
  123. package/src/{store-CfFFx9Ua.js → store-DjJs3I7k.js} +12 -7
  124. package/src/store-DjJs3I7k.js.map +1 -0
  125. package/studio/{CreateDocumentDialog--L9lTfx6.js → CreateDocumentDialog-CTeIFlPb.js} +44 -44
  126. package/studio/{collaboration-DUuu678R.js → collaboration-DcK2F6v9.js} +7 -6
  127. package/studio/{documentPlanning-BXX04Woe.js → documentPlanning-Bfv-d7OU.js} +7310 -6479
  128. package/studio/{editor-PexnXkJY.js → editor-Bzlh3zXt.js} +7965 -7955
  129. package/studio/host.css +1 -1
  130. package/studio/host.js +10416 -7981
  131. package/src/Configuration-DyKo0sLS.js.map +0 -1
  132. package/src/DocumentEngine-DYObwMDY.js.map +0 -1
  133. package/src/HttpPaths-BbS21Jy8.js.map +0 -1
  134. package/src/StudioHttp-jR2-bc01.js +0 -718
  135. package/src/StudioHttp-jR2-bc01.js.map +0 -1
  136. package/src/connection-CBTY-TzB.js.map +0 -1
  137. package/src/installation-DeuBiFRE.js.map +0 -1
  138. package/src/location-DtYv2aes.js.map +0 -1
  139. package/src/metadata-DE1Mc2td.js.map +0 -1
  140. package/src/models-BkMgeaOL.js.map +0 -1
  141. package/src/models-C3witQBK.js.map +0 -1
  142. package/src/store-CfFFx9Ua.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scalars-B2lgGUnj.js","names":[],"sources":["../../../../protocol/src/internal/scalars.ts","../../../../protocol/src/internal/documents/scalars.ts"],"sourcesContent":["import { Schema } from 'effect'\n\nexport const nonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))\n\nexport const publicPathPattern = /^\\/(?!(?:[^/]+\\/)*\\.\\.?(?:\\/|$))(?:[^/?#\\\\]+(?:\\/[^/?#\\\\]+)*)?$/u\n","import { Schema } from 'effect'\nimport { nonNegativeInt, publicPathPattern } from '../scalars'\n\nconst relativeDocumentPathPattern = /^(?!(?:[^/]+\\/)*\\.\\.?(?:\\/|$))[^/?#\\\\]+(?:\\/[^/?#\\\\]+)*$/u\n\nconst slugPattern = /^[\\p{Letter}\\p{Number}][\\p{Letter}\\p{Number}_-]*$/u\n\nconst sourcePathPattern = /^(?!\\.)[^/?#\\\\]+(?:\\/(?!\\.)[^/?#\\\\]+)*\\.(?:md|mdc)$/u\n\nexport const DocumentGeneration = Schema.String.check(Schema.isPattern(/^(?:0|[1-9]\\d*)$/u)).pipe(\n Schema.brand('DocumentGeneration'),\n)\n\nexport type DocumentGeneration = typeof DocumentGeneration.Type\n\nexport const DocumentVersion = Schema.NonEmptyString.pipe(Schema.brand('DocumentVersion'))\n\nexport type DocumentVersion = typeof DocumentVersion.Type\n\nexport const DocumentHistoryCursor = Schema.NonEmptyString.pipe(Schema.brand('DocumentHistoryCursor'))\n\nexport type DocumentHistoryCursor = typeof DocumentHistoryCursor.Type\n\nexport const DocumentId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('DocumentId'))\n\nexport type DocumentId = typeof DocumentId.Type\n\nexport const EditorNodeId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('EditorNodeId'))\n\nexport type EditorNodeId = typeof EditorNodeId.Type\n\nexport const PublicPath = Schema.String.check(Schema.isPattern(publicPathPattern)).pipe(Schema.brand('PublicPath'))\n\nexport type PublicPath = typeof PublicPath.Type\n\nexport const RelativeDocumentPath = Schema.String.check(Schema.isPattern(relativeDocumentPathPattern)).pipe(\n Schema.brand('RelativeDocumentPath'),\n)\n\nexport type RelativeDocumentPath = typeof RelativeDocumentPath.Type\n\nexport const RevisionId = Schema.String.check(Schema.isUUID()).pipe(Schema.brand('RevisionId'))\n\nexport type RevisionId = typeof RevisionId.Type\n\nexport const RevisionNumber = nonNegativeInt.pipe(Schema.brand('RevisionNumber'))\n\nexport type RevisionNumber = typeof RevisionNumber.Type\n\nexport const Slug = Schema.String.check(Schema.isPattern(slugPattern)).pipe(Schema.brand('Slug'))\n\nexport type Slug = typeof Slug.Type\n\nexport const SourcePath = Schema.String.check(Schema.isPattern(sourcePathPattern)).pipe(Schema.brand('SourcePath'))\n\nexport type SourcePath = typeof SourcePath.Type\n"],"mappings":";;;AAEA,MAAa,iBAAiB,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CAAC;AAE/E,MAAa,oBAAoB;;;;ACDjC,MAAM,8BAA8B;AAEpC,MAAM,cAAc;AAEpB,MAAM,oBAAoB;AAE1B,MAAa,qBAAqB,OAAO,OAAO,MAAM,OAAO,UAAU,mBAAmB,CAAC,CAAC,CAAC,KAC3F,OAAO,MAAM,oBAAoB,CACnC;AAIA,MAAa,kBAAkB,OAAO,eAAe,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAIzF,MAAa,wBAAwB,OAAO,eAAe,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAIrG,MAAa,aAAa,OAAO,OAAO,MAAM,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC;AAI9F,MAAa,eAAe,OAAO,OAAO,MAAM,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,cAAc,CAAC;AAIlG,MAAa,aAAa,OAAO,OAAO,MAAM,OAAO,UAAU,iBAAiB,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC;AAIlH,MAAa,uBAAuB,OAAO,OAAO,MAAM,OAAO,UAAU,2BAA2B,CAAC,CAAC,CAAC,KACrG,OAAO,MAAM,sBAAsB,CACrC;AAIA,MAAa,aAAa,OAAO,OAAO,MAAM,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC;AAI9F,MAAa,iBAAiB,eAAe,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAIhF,MAAa,OAAO,OAAO,OAAO,MAAM,OAAO,UAAU,WAAW,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,MAAM,CAAC;AAIhG,MAAa,aAAa,OAAO,OAAO,MAAM,OAAO,UAAU,iBAAiB,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC"}
@@ -1,5 +1,8 @@
1
- import { gt as DocumentId, n as CmsMarkdownDocument, ut as CollectionName, yt as PublicPath } from "./models-BkMgeaOL.js";
2
- import { l as mutableJson, n as editorMetadata, u as mutableJsonObject } from "./metadata-DE1Mc2td.js";
1
+ import { o as PublicPath, r as DocumentId } from "./scalars-B2lgGUnj.js";
2
+ import { f as mutableJson, p as mutableJsonObject } from "./Forms-DxbkU3_5.js";
3
+ import { Et as CollectionName, n as CmsMarkdownDocument } from "./models-DwYioyNV.js";
4
+ import { n as editorMetadata } from "./metadata-BEZPWh-3.js";
5
+ import { prepareFormDocument } from "./runtime/forms/document.js";
3
6
  import { CMS_PREVIEW_INLINE_HOST_ATTRIBUTE, CMS_PREVIEW_MARKER_TAG, CMS_PREVIEW_NODE_ATTRIBUTE, CMS_PREVIEW_TARGET_ATTRIBUTE, CMS_PREVIEW_WRAPPER_ATTRIBUTE } from "./runtime/preview/protocol.js";
4
7
  import { toPreviewRenderDocument } from "./runtime/preview/comark-document.js";
5
8
  import { Predicate, Result, Schema } from "effect";
@@ -44,7 +47,6 @@ const INLINE_TAGS = /* @__PURE__ */ new Set([
44
47
  "strong",
45
48
  "u"
46
49
  ]);
47
- /** Projects private authoring identities into an ephemeral preview without mutating the canonical body. */
48
50
  function projectPreviewDocument(body, markers) {
49
51
  return Result.try({
50
52
  try: () => projectPreviewDocumentUnsafe(body, markers),
@@ -135,7 +137,7 @@ function hasInlineImplicitDefaultContent(nodes) {
135
137
 
136
138
  //#endregion
137
139
  //#region src/runtime/preview/store.ts
138
- function createStudioPreviewStore(route) {
140
+ function createStudioPreviewStore(route, forms = () => []) {
139
141
  const context = createComarkContext();
140
142
  const patches = shallowReactive(/* @__PURE__ */ new Map());
141
143
  const registrations = /* @__PURE__ */ new Map();
@@ -152,9 +154,12 @@ function createStudioPreviewStore(route) {
152
154
  manifest,
153
155
  async patch(document) {
154
156
  const preview = createPreviewDocument(document.body);
155
- const patched = Object.assign({}, document, { body: preview.body });
157
+ const patched = prepareFormDocument({
158
+ ...document,
159
+ body: preview.body
160
+ }, forms(), true);
156
161
  patches.set(document.id, patched);
157
- const renderBody = toPreviewRenderDocument(preview.body);
162
+ const renderBody = toPreviewRenderDocument(patched.body);
158
163
  context.get(document.id, renderBody).set(renderBody);
159
164
  notify();
160
165
  return preview.fallbacks;
@@ -218,4 +223,4 @@ function createPreviewDocument(body) {
218
223
 
219
224
  //#endregion
220
225
  export { createStudioPreviewStore as t };
221
- //# sourceMappingURL=store-CfFFx9Ua.js.map
226
+ //# sourceMappingURL=store-DjJs3I7k.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-DjJs3I7k.js","names":["CmsMarkdownDocumentSchema"],"sources":["../../../../document/src/PreviewProjection.ts","../../../src/runtime/preview/store.ts"],"sourcesContent":["import type { CmsMarkdownDocument, MarkdownNode } from '@internal/protocol/Documents'\nimport type { EditorNodeId } from '@internal/protocol/Documents'\nimport { CmsMarkdownDocument as CmsMarkdownDocumentSchema } from '@internal/protocol/Documents'\nimport { Predicate, Result, Schema } from 'effect'\nimport { mutableJson, mutableJsonObject } from './internal/comark/document-adapter'\nimport { editorMetadata } from './internal/editor/metadata'\n\nexport interface PreviewProjectionMarkers {\n readonly inlineHostAttribute: string\n readonly markerTag: string\n readonly nodeAttribute: string\n readonly targetAttribute: string\n readonly wrapperAttribute: string\n}\n\nexport interface PreviewProjection {\n readonly body: CmsMarkdownDocument\n readonly fallbacks: Readonly<Record<string, string>>\n}\n\nexport class PreviewProjectionInvalid extends Schema.TaggedError<PreviewProjectionInvalid>()(\n 'PreviewProjection.Invalid',\n {\n message: Schema.NonEmptyString,\n cause: Schema.Defect(),\n },\n) {}\n\nconst NATIVE_BLOCK_TAGS = new Set([\n 'blockquote',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'hr',\n 'img',\n 'li',\n 'math',\n 'ol',\n 'p',\n 'pre',\n 'table',\n 'tbody',\n 'td',\n 'th',\n 'thead',\n 'tr',\n 'ul',\n])\n\nconst INLINE_TAGS = new Set(['a', 'br', 'code', 'del', 'em', 'img', 'strong', 'u'])\n\nexport function projectPreviewDocument(\n body: CmsMarkdownDocument,\n markers: PreviewProjectionMarkers,\n): Result.Result<PreviewProjection, PreviewProjectionInvalid> {\n return Result.try({\n try: () => projectPreviewDocumentUnsafe(body, markers),\n catch: (cause) =>\n new PreviewProjectionInvalid({\n cause,\n message: cause instanceof Error && cause.message ? cause.message : 'The preview projection is invalid.',\n }),\n })\n}\n\nfunction projectPreviewDocumentUnsafe(body: CmsMarkdownDocument, markers: PreviewProjectionMarkers): PreviewProjection {\n const fallbacks: Record<string, string> = {}\n let identifiedTargets = 0\n\n const cloneNodes = (nodes: ReadonlyArray<MarkdownNode>, componentId?: EditorNodeId): ReadonlyArray<Schema.Json> =>\n nodes.map((node) => {\n if (Predicate.isString(node) || node[0] === null) return mutableJson(node)\n const [tag, originalAttributes, ...originalChildren] = node\n const isSlot = tag === 'template'\n const isNative = NATIVE_BLOCK_TAGS.has(tag)\n const attributes = mutableJsonObject(originalAttributes)\n const metadata = editorMetadata(attributes)\n const id = metadata?.nodeId\n\n if (id) {\n identifiedTargets++\n\n if (componentId) fallbacks[id] = componentId\n\n if (!isSlot && !isNative) {\n attributes[markers.nodeAttribute] = id\n attributes[markers.targetAttribute] = 'component'\n }\n }\n\n const nextComponentId = !isNative && !isSlot && id ? id : componentId\n const children = [...cloneNodes(originalChildren, nextComponentId)]\n\n if (id && metadata?.implicitSlotId && !isNative && !isSlot && hasImplicitDefaultContent(originalChildren)) {\n const slotId = metadata.implicitSlotId\n fallbacks[slotId] = id\n const markerChildren = hasInlineImplicitDefaultContent(originalChildren) ? children.splice(0) : []\n\n const markerAttributes = {\n [markers.nodeAttribute]: slotId,\n [markers.targetAttribute]: 'slot',\n [markers.wrapperAttribute]: '',\n }\n\n if (markerChildren.length) markerAttributes[markers.inlineHostAttribute] = ''\n children.unshift([markers.markerTag, markerAttributes, ...markerChildren])\n }\n\n if (isSlot && id) {\n children.unshift([\n markers.markerTag,\n {\n [markers.nodeAttribute]: id,\n [markers.targetAttribute]: 'slot',\n [markers.wrapperAttribute]: '',\n },\n ])\n }\n\n const cloned: Schema.Json = [tag, attributes, ...children]\n\n if (id && isNative) return previewWrapper(id, 'native', cloned, markers)\n\n if (id && !isNative && !isSlot) return previewWrapper(id, 'component', cloned, markers)\n\n return cloned\n })\n\n const nodes = cloneNodes(body.nodes)\n\n if (body.nodes.length && !identifiedTargets)\n throw new Error('Studio preview requires an identified authoring document.')\n\n return {\n body: CmsMarkdownDocumentSchema.make({\n frontmatter: mutableJsonObject(body.frontmatter),\n meta: mutableJsonObject(body.meta),\n nodes,\n }),\n fallbacks,\n }\n}\n\nfunction previewWrapper(\n nodeId: EditorNodeId,\n kind: 'component' | 'native' | 'slot',\n child: Schema.Json,\n markers: PreviewProjectionMarkers,\n): Schema.Json {\n return [\n markers.markerTag,\n {\n [markers.nodeAttribute]: nodeId,\n [markers.targetAttribute]: kind,\n [markers.wrapperAttribute]: '',\n },\n child,\n ]\n}\n\nfunction hasImplicitDefaultContent(nodes: ReadonlyArray<MarkdownNode>): boolean {\n const hasExplicitDefault = nodes.some(\n (node) => Array.isArray(node) && node[0] === 'template' && node[1].name === 'default',\n )\n\n return (\n !hasExplicitDefault && nodes.some((node) => (Predicate.isString(node) ? Boolean(node) : node[0] !== 'template'))\n )\n}\n\nfunction hasInlineImplicitDefaultContent(nodes: ReadonlyArray<MarkdownNode>): boolean {\n return (\n nodes.length > 0 &&\n nodes.every(\n (node) => Predicate.isString(node) || (Array.isArray(node) && node[0] !== null && INLINE_TAGS.has(node[0])),\n )\n )\n}\n","import { prepareFormDocument } from '../forms/document'\nimport type { ComponentDefinition } from '@internal/protocol/Configuration'\nimport type { RenderedCompiledDocument, RenderedDocumentManifest } from '@internal/protocol/Preview'\nimport { projectPreviewDocument } from '@internal/document/PreviewProjection'\nimport { CollectionName } from '@internal/protocol/Configuration'\nimport { DocumentId, PublicPath } from '@internal/protocol/Documents'\nimport { Result } from 'effect'\nimport { createComarkContext } from 'comark'\nimport { shallowReactive } from 'vue'\nimport type { DeliveryDocument as PreviewCompiledDocument } from '../delivery/types'\nimport type { DocumentPreviewStore, PreviewDocumentRole } from '../delivery/preview'\nimport { toPreviewRenderDocument } from './comark-document'\nimport {\n CMS_PREVIEW_INLINE_HOST_ATTRIBUTE,\n CMS_PREVIEW_MARKER_TAG,\n CMS_PREVIEW_NODE_ATTRIBUTE,\n CMS_PREVIEW_TARGET_ATTRIBUTE,\n CMS_PREVIEW_WRAPPER_ATTRIBUTE,\n} from './protocol'\n\nexport { documentPreviewStoreKey, type DocumentPreviewStore, type PreviewDocumentRole } from '../delivery/preview'\n\nexport type { DeliveryDocument as PreviewCompiledDocument } from '../delivery/types'\n\nexport interface StudioPreviewStore extends DocumentPreviewStore {\n readonly manifest: () => RenderedDocumentManifest\n readonly patch: (document: PreviewCompiledDocument) => Promise<Readonly<Record<string, string>>>\n readonly routeChanged: () => void\n readonly subscribe: (listener: (manifest: RenderedDocumentManifest) => void) => () => void\n}\n\nexport function createStudioPreviewStore(\n route: () => RenderedDocumentManifest['route'],\n forms: () => ReadonlyArray<ComponentDefinition> = () => [],\n): StudioPreviewStore {\n const context = createComarkContext()\n const patches = shallowReactive(new Map<string, PreviewCompiledDocument>())\n\n const registrations = new Map<\n symbol,\n { readonly document: PreviewCompiledDocument; readonly role: PreviewDocumentRole }\n >()\n\n const listeners = new Set<(manifest: RenderedDocumentManifest) => void>()\n\n const manifest = (): RenderedDocumentManifest => ({\n documents: renderedDocuments(registrations.values(), patches),\n route: route(),\n })\n\n const notify = (): void => {\n const value = manifest()\n\n for (const listener of listeners) listener(value)\n }\n\n return {\n manifest,\n async patch(document) {\n const preview = createPreviewDocument(document.body)\n const patched = prepareFormDocument({ ...document, body: preview.body }, forms(), true)\n patches.set(document.id, patched)\n const renderBody = toPreviewRenderDocument(patched.body)\n context.get(document.id, renderBody).set(renderBody)\n notify()\n\n return preview.fallbacks\n },\n register(document, role) {\n const registration = Symbol(document.id)\n registrations.set(registration, { document, role })\n notify()\n\n return () => {\n registrations.delete(registration)\n notify()\n }\n },\n resolve(document) {\n return patches.get(document.id) ?? document\n },\n routeChanged: notify,\n subscribe(listener) {\n listeners.add(listener)\n listener(manifest())\n\n return () => listeners.delete(listener)\n },\n }\n}\n\nfunction renderedDocuments(\n registrations: Iterable<{ readonly document: PreviewCompiledDocument; readonly role: PreviewDocumentRole }>,\n patches: ReadonlyMap<string, PreviewCompiledDocument>,\n): ReadonlyArray<RenderedCompiledDocument> {\n const priority = { embedded: 1, primary: 4, related: 2, summary: 3 } satisfies Record<PreviewDocumentRole, number>\n const documents = new Map<string, RenderedCompiledDocument>()\n\n for (const registration of registrations) {\n const document = patches.get(registration.document.id) ?? registration.document\n const current = documents.get(document.id)\n\n if (current && priority[current.role] >= priority[registration.role]) continue\n documents.set(document.id, {\n collection: CollectionName.make(document.collection),\n documentId: DocumentId.make(document.id),\n path: PublicPath.make(document.path),\n role: registration.role,\n title: document.title,\n })\n }\n\n return [...documents.values()].sort(\n (left, right) => priority[right.role] - priority[left.role] || left.title.localeCompare(right.title),\n )\n}\n\nfunction createPreviewDocument(body: PreviewCompiledDocument['body']) {\n const projection = projectPreviewDocument(body, {\n inlineHostAttribute: CMS_PREVIEW_INLINE_HOST_ATTRIBUTE,\n markerTag: CMS_PREVIEW_MARKER_TAG,\n nodeAttribute: CMS_PREVIEW_NODE_ATTRIBUTE,\n targetAttribute: CMS_PREVIEW_TARGET_ATTRIBUTE,\n wrapperAttribute: CMS_PREVIEW_WRAPPER_ATTRIBUTE,\n })\n\n if (Result.isFailure(projection)) throw projection.failure\n\n return projection.success\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,IAAa,2BAAb,cAA8C,OAAO,YAAsC,CAAC,CAC1F,6BACA;CACE,SAAS,OAAO;CAChB,OAAO,OAAO,OAAO;AACvB,CACF,CAAC,CAAC,CAAC;AAEH,MAAM,oCAAoB,IAAI,IAAI;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,8BAAc,IAAI,IAAI;CAAC;CAAK;CAAM;CAAQ;CAAO;CAAM;CAAO;CAAU;AAAG,CAAC;AAElF,SAAgB,uBACd,MACA,SAC4D;CAC5D,OAAO,OAAO,IAAI;EAChB,WAAW,6BAA6B,MAAM,OAAO;EACrD,QAAQ,UACN,IAAI,yBAAyB;GAC3B;GACA,SAAS,iBAAiB,SAAS,MAAM,UAAU,MAAM,UAAU;EACrE,CAAC;CACL,CAAC;AACH;AAEA,SAAS,6BAA6B,MAA2B,SAAsD;CACrH,MAAM,YAAoC,CAAC;CAC3C,IAAI,oBAAoB;CAExB,MAAM,cAAc,OAAoC,gBACtD,MAAM,KAAK,SAAS;EAClB,IAAI,UAAU,SAAS,IAAI,KAAK,KAAK,OAAO,MAAM,OAAO,YAAY,IAAI;EACzE,MAAM,CAAC,KAAK,oBAAoB,GAAG,oBAAoB;EACvD,MAAM,SAAS,QAAQ;EACvB,MAAM,WAAW,kBAAkB,IAAI,GAAG;EAC1C,MAAM,aAAa,kBAAkB,kBAAkB;EACvD,MAAM,WAAW,eAAe,UAAU;EAC1C,MAAM,KAAK,UAA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kB;CACpB,CAAC;CAED,IAAI,OAAO,UAAU,UAAU,GAAG,MAAM,WAAW;CAEnD,OAAO,WAAW;AACpB"}
@@ -1,19 +1,19 @@
1
- import { $ as e, $t as t, Ct as n, Ft as r, J as ee, K as te, Mt as i, Q as a, Tt as ne, Xt as o, Z as s, an as c, et as l, it as u, ot as d, pt as f, sn as p, tt as m, un as h, zt as g } from "./editor-PexnXkJY.js";
2
- import { A as _, D as v, F as y, Gn as b, Kn as x, M as re, N as ie, i as ae, j as oe, n as se, r as S, t as C, tr as w } from "./documentPlanning-BXX04Woe.js";
1
+ import { $ as e, $t as t, Ct as n, Ft as r, J as ee, K as i, Mt as a, Q as o, Tt as te, Z as s, an as c, et as l, it as u, ot as d, pt as f, sn as p, tt as m, un as h, zt as g } from "./editor-Bzlh3zXt.js";
2
+ import { A as _, F as v, I as y, N as b, P as x, R as S, a as ne, n as re, nr as C, pr as ie, r as ae, rr as oe, t as w } from "./documentPlanning-Bfv-d7OU.js";
3
3
  //#region src/documents/CreateDocumentDialog.vue?vue&type=script&setup=true&lang.ts
4
- var ce = { key: 2 }, T = { class: "grid grid-flow-col auto-cols-fr overflow-x-auto rounded-md border border-default" }, E = ["title", "onClick"], le = { class: "block truncate" }, ue = {
4
+ var se = { key: 2 }, ce = { class: "grid grid-flow-col auto-cols-fr overflow-x-auto rounded-md border border-default" }, T = ["title", "onClick"], E = { class: "block truncate" }, le = {
5
5
  key: 0,
6
6
  class: "mt-2 flex min-w-0 items-center justify-between gap-3 text-xs text-muted"
7
7
  }, D = { class: "truncate" }, O = { class: "shrink-0 font-mono text-[11px] text-dimmed" }, k = {
8
8
  key: 5,
9
9
  class: "flex min-w-0 items-center gap-3 rounded-md border border-default px-3 py-2"
10
- }, de = {
10
+ }, ue = {
11
11
  key: 6,
12
12
  class: "-mt-2 text-xs text-error"
13
- }, fe = {
13
+ }, de = {
14
14
  key: 7,
15
15
  class: "-mt-2 text-xs text-error"
16
- }, pe = { class: "flex w-full justify-end gap-2" }, A = "__top_level__", j = /* @__PURE__ */ d({
16
+ }, fe = { class: "flex w-full justify-end gap-2" }, A = "__top_level__", j = /* @__PURE__ */ d({
17
17
  __name: "CreateDocumentDialog",
18
18
  props: /*@__PURE__*/ f({
19
19
  catalog: {},
@@ -24,10 +24,10 @@ var ce = { key: 2 }, T = { class: "grid grid-flow-col auto-cols-fr overflow-x-au
24
24
  }),
25
25
  emits: /*@__PURE__*/ f(["close"], ["update:open"]),
26
26
  setup(d, { emit: f }) {
27
- let j = f, M = i(d, "open"), N = _(), P = N.bootstrap.documents, F = P.types.filter((e) => e.canCreate), I = (P.locales?.locales ?? []).map((e) => ({
28
- label: ge(e),
27
+ let j = f, M = a(d, "open"), N = b(), P = N.bootstrap.documents, F = P.types.filter((e) => e.canCreate), I = (P.locales?.locales ?? []).map((e) => ({
28
+ label: he(e),
29
29
  value: String(e)
30
- })), L = t(""), R = t(!1), z = o(""), B = o(""), V = o(!1), H = o(""), U = o(A), W = o(P.locales?.defaultLocale ?? ""), G = s(() => {
30
+ })), L = t(""), R = t(!1), z = t(""), B = t(""), V = t(!1), H = t(""), U = t(A), W = t(P.locales?.defaultLocale ?? ""), G = s(() => {
31
31
  let e = F.map((e) => ({
32
32
  collection: e.collection,
33
33
  description: e.description,
@@ -38,13 +38,13 @@ var ce = { key: 2 }, T = { class: "grid grid-flow-col auto-cols-fr overflow-x-au
38
38
  urlHint: e.addressPattern.replace(/:[a-z][\w.]*\*?/giu, "…")
39
39
  }));
40
40
  return [...F.filter((e) => e.addressPattern === "/:path*").slice(0, 1).flatMap((e) => {
41
- let t = C(P, {
41
+ let t = w(P, {
42
42
  collection: e.collection,
43
43
  locale: W.value || void 0,
44
44
  location: { kind: "home" },
45
45
  title: "Home"
46
46
  });
47
- return b(t) || d.catalog.entries.value.some((e) => e.document.path === t.success.path) ? [] : [{
47
+ return C(t) || d.catalog.entries.value.some((e) => e.document.path === t.success.path) ? [] : [{
48
48
  collection: e.collection,
49
49
  description: "The first document visitors see when they open the website.",
50
50
  key: `home:${e.collection}`,
@@ -69,22 +69,22 @@ var ce = { key: 2 }, T = { class: "grid grid-flow-col auto-cols-fr overflow-x-au
69
69
  location: q.value,
70
70
  title: z.value || "Untitled"
71
71
  };
72
- return C(P, W.value ? {
72
+ return w(P, W.value ? {
73
73
  ...t,
74
74
  locale: W.value
75
75
  } : t);
76
76
  }), Y = s(() => {
77
77
  let e = J.value;
78
- return e && x(e) ? e.success : void 0;
78
+ return e && oe(e) ? e.success : void 0;
79
79
  }), X = s(() => {
80
80
  let e = J.value;
81
- return e && b(e) ? e.failure : "";
82
- }), Z = s(() => Y.value && d.catalog.entries.value.some((e) => e.document.path === Y.value?.path)), me = s(() => {
81
+ return e && C(e) ? e.failure : "";
82
+ }), Z = s(() => Y.value && d.catalog.entries.value.some((e) => e.document.path === Y.value?.path)), pe = s(() => {
83
83
  let e = K.value;
84
84
  if (!e || e.kind === "home" || !e.type.hierarchy) return [];
85
85
  let t = d.catalog.entries.value.flatMap((t) => {
86
86
  if (t.document.collection !== e.collection || t.document.locale !== (W.value || void 0)) return [];
87
- let n = S(e.type, t);
87
+ let n = ae(e.type, t);
88
88
  return n ? [{
89
89
  label: `${t.document.title} · /${n}`,
90
90
  value: n
@@ -99,13 +99,13 @@ var ce = { key: 2 }, T = { class: "grid grid-flow-col auto-cols-fr overflow-x-au
99
99
  }, ...t];
100
100
  }), Q = s(() => !!z.value.trim() && !!K.value && !!Y.value && !Z.value);
101
101
  r(z, (e) => {
102
- V.value || (B.value = se(e));
102
+ V.value || (B.value = re(e));
103
103
  }), r(H, () => U.value = A, { flush: "sync" }), r(W, () => {
104
104
  U.value = A, K.value || (H.value = $());
105
105
  }, { flush: "sync" }), r(M, (e) => {
106
106
  e && (L.value = "", z.value = "", B.value = "", V.value = !1, W.value = d.context?.locale ?? P.locales?.defaultLocale ?? "", H.value = d.context?.collection ? `entry:${d.context.collection}` : $(), U.value = d.context?.parent || A, d.context?.slug && (B.value = d.context.slug, V.value = !0));
107
107
  }, { immediate: !0 });
108
- async function he() {
108
+ async function me() {
109
109
  let e = K.value;
110
110
  if (Q.value && e && !R.value) {
111
111
  R.value = !0, L.value = "";
@@ -123,7 +123,7 @@ var ce = { key: 2 }, T = { class: "grid grid-flow-col auto-cols-fr overflow-x-au
123
123
  if (!r) throw Error("The page was created but could not be opened.");
124
124
  j("close", r.document.id);
125
125
  } catch (e) {
126
- L.value = y(e);
126
+ L.value = S(e);
127
127
  } finally {
128
128
  R.value = !1;
129
129
  }
@@ -132,7 +132,7 @@ var ce = { key: 2 }, T = { class: "grid grid-flow-col auto-cols-fr overflow-x-au
132
132
  function $() {
133
133
  return G.value[0]?.key ?? "";
134
134
  }
135
- function ge(e) {
135
+ function he(e) {
136
136
  try {
137
137
  return new Intl.DisplayNames(void 0, { type: "language" }).of(e) ?? e.toLocaleUpperCase();
138
138
  } catch {
@@ -140,36 +140,36 @@ var ce = { key: 2 }, T = { class: "grid grid-flow-col auto-cols-fr overflow-x-au
140
140
  }
141
141
  }
142
142
  return (t, r) => {
143
- let i = ie, o = oe, s = re, d = ae, f = w, _ = v;
144
- return n(), e(_, {
143
+ let a = y, s = x, d = v, f = ne, b = ie, S = _;
144
+ return n(), e(S, {
145
145
  open: M.value,
146
146
  "onUpdate:open": r[6] ||= (e) => M.value = e,
147
147
  title: "New page",
148
148
  description: "Add a document to your website.",
149
149
  ui: { content: "max-w-lg" }
150
150
  }, {
151
- body: g(() => [a("form", {
151
+ body: g(() => [o("form", {
152
152
  id: "create-document-form",
153
153
  class: "space-y-4",
154
- onSubmit: te(he, ["prevent"])
154
+ onSubmit: i(me, ["prevent"])
155
155
  }, [
156
- L.value ? (n(), e(i, {
156
+ L.value ? (n(), e(a, {
157
157
  key: 0,
158
158
  description: L.value,
159
159
  color: "error",
160
160
  variant: "subtle"
161
161
  }, null, 8, ["description"])) : l("", !0),
162
- G.value.length ? G.value.length > 1 ? (n(), m("fieldset", ce, [
163
- r[7] ||= a("legend", { class: "mb-2 text-sm font-medium text-highlighted" }, "Collection", -1),
164
- a("div", T, [(n(!0), m(ee, null, ne(G.value, (e) => (n(), m("button", {
162
+ G.value.length ? G.value.length > 1 ? (n(), m("fieldset", se, [
163
+ r[7] ||= o("legend", { class: "mb-2 text-sm font-medium text-highlighted" }, "Collection", -1),
164
+ o("div", ce, [(n(!0), m(ee, null, te(G.value, (e) => (n(), m("button", {
165
165
  key: e.key,
166
166
  type: "button",
167
167
  title: e.description,
168
168
  class: p(["min-w-28 border-l border-default px-3 py-2 text-center text-sm transition-colors first:border-l-0", e.key === H.value ? "bg-muted font-medium text-highlighted" : "bg-default text-muted hover:bg-muted/50 hover:text-highlighted"]),
169
169
  onClick: (t) => H.value = e.key
170
- }, [a("span", le, h(e.label), 1)], 10, E))), 128))]),
171
- K.value ? (n(), m("div", ue, [a("span", D, h(K.value.description), 1), a("code", O, h(K.value.urlHint), 1)])) : l("", !0)
172
- ])) : l("", !0) : (n(), e(i, {
170
+ }, [o("span", E, h(e.label), 1)], 10, T))), 128))]),
171
+ K.value ? (n(), m("div", le, [o("span", D, h(K.value.description), 1), o("code", O, h(K.value.urlHint), 1)])) : l("", !0)
172
+ ])) : l("", !0) : (n(), e(a, {
173
173
  key: 1,
174
174
  title: "Document creation is not configured",
175
175
  description: "A developer needs to make at least one collection creatable in Studio.",
@@ -179,11 +179,11 @@ var ce = { key: 2 }, T = { class: "grid grid-flow-col auto-cols-fr overflow-x-au
179
179
  K.value ? (n(), m("div", {
180
180
  key: 3,
181
181
  class: p(["grid gap-4", c(I).length ? "sm:grid-cols-[minmax(0,2fr)_minmax(9rem,1fr)]" : ""])
182
- }, [u(s, {
182
+ }, [u(d, {
183
183
  label: "Title",
184
184
  required: ""
185
185
  }, {
186
- default: g(() => [u(o, {
186
+ default: g(() => [u(s, {
187
187
  modelValue: z.value,
188
188
  "onUpdate:modelValue": r[0] ||= (e) => z.value = e,
189
189
  autofocus: "",
@@ -191,11 +191,11 @@ var ce = { key: 2 }, T = { class: "grid grid-flow-col auto-cols-fr overflow-x-au
191
191
  class: "w-full"
192
192
  }, null, 8, ["modelValue"])]),
193
193
  _: 1
194
- }), c(I).length ? (n(), e(s, {
194
+ }), c(I).length ? (n(), e(d, {
195
195
  key: 0,
196
196
  label: "Language"
197
197
  }, {
198
- default: g(() => [u(d, {
198
+ default: g(() => [u(f, {
199
199
  modelValue: W.value,
200
200
  "onUpdate:modelValue": r[1] ||= (e) => W.value = e,
201
201
  items: c(I),
@@ -207,23 +207,23 @@ var ce = { key: 2 }, T = { class: "grid grid-flow-col auto-cols-fr overflow-x-au
207
207
  K.value?.kind === "entry" ? (n(), m("div", {
208
208
  key: 4,
209
209
  class: p(["grid gap-4", K.value.type.hierarchy ? "sm:grid-cols-2" : ""])
210
- }, [K.value.type.hierarchy ? (n(), e(s, {
210
+ }, [K.value.type.hierarchy ? (n(), e(d, {
211
211
  key: 0,
212
212
  label: "Parent document"
213
213
  }, {
214
- default: g(() => [u(d, {
214
+ default: g(() => [u(f, {
215
215
  modelValue: U.value,
216
216
  "onUpdate:modelValue": r[2] ||= (e) => U.value = e,
217
- items: me.value,
217
+ items: pe.value,
218
218
  "value-key": "value",
219
219
  class: "w-full"
220
220
  }, null, 8, ["modelValue", "items"])]),
221
221
  _: 1
222
- })) : l("", !0), u(s, {
222
+ })) : l("", !0), u(d, {
223
223
  label: "URL ending",
224
224
  required: ""
225
225
  }, {
226
- default: g(() => [u(o, {
226
+ default: g(() => [u(s, {
227
227
  modelValue: B.value,
228
228
  "onUpdate:modelValue": [r[3] ||= (e) => B.value = e, r[4] ||= (e) => V.value = !0],
229
229
  placeholder: "about-us",
@@ -231,15 +231,15 @@ var ce = { key: 2 }, T = { class: "grid grid-flow-col auto-cols-fr overflow-x-au
231
231
  }, null, 8, ["modelValue"])]),
232
232
  _: 1
233
233
  })], 2)) : l("", !0),
234
- K.value ? (n(), m("div", k, [r[8] ||= a("span", { class: "shrink-0 text-xs text-muted" }, "URL", -1), a("p", { class: p(["min-w-0 flex-1 truncate text-right font-mono text-xs", Z.value ? "text-error" : "text-highlighted"]) }, h(Y.value?.path || K.value.urlHint), 3)])) : l("", !0),
235
- Z.value ? (n(), m("p", de, "This URL is already in use.")) : X.value ? (n(), m("p", fe, h(X.value), 1)) : l("", !0)
234
+ K.value ? (n(), m("div", k, [r[8] ||= o("span", { class: "shrink-0 text-xs text-muted" }, "URL", -1), o("p", { class: p(["min-w-0 flex-1 truncate text-right font-mono text-xs", Z.value ? "text-error" : "text-highlighted"]) }, h(Y.value?.path || K.value.urlHint), 3)])) : l("", !0),
235
+ Z.value ? (n(), m("p", ue, "This URL is already in use.")) : X.value ? (n(), m("p", de, h(X.value), 1)) : l("", !0)
236
236
  ], 32)]),
237
- footer: g(() => [a("div", pe, [u(f, {
237
+ footer: g(() => [o("div", fe, [u(b, {
238
238
  color: "neutral",
239
239
  variant: "ghost",
240
240
  label: "Cancel",
241
241
  onClick: r[5] ||= (e) => M.value = !1
242
- }), u(f, {
242
+ }), u(b, {
243
243
  type: "submit",
244
244
  form: "create-document-form",
245
245
  color: "neutral",
@@ -4071,12 +4071,13 @@ var Ns = (e, t) => {
4071
4071
  onStatus: () => null,
4072
4072
  onDisconnect: () => null,
4073
4073
  onClose: () => null,
4074
+ onMaxAttemptsFailed: () => null,
4074
4075
  onDestroy: () => null,
4075
4076
  onAwarenessUpdate: () => null,
4076
4077
  onAwarenessChange: () => null,
4077
4078
  handleTimeout: null,
4078
4079
  providerMap: /* @__PURE__ */ new Map()
4079
- }, this.webSocket = null, this.webSocketHandlers = {}, this.shouldConnect = !0, this.status = $.Disconnected, this.lastMessageReceived = 0, this.identifier = 0, this.intervals = { connectionChecker: null }, this.connectionAttempt = null, this.receivedOnOpenPayload = void 0, this.closeTries = 0, this.setConfiguration(e), this.configuration.WebSocketPolyfill = e.WebSocketPolyfill ? e.WebSocketPolyfill : WebSocket, this.on("open", this.configuration.onOpen), this.on("open", this.onOpen.bind(this)), this.on("connect", this.configuration.onConnect), this.on("message", this.configuration.onMessage), this.on("outgoingMessage", this.configuration.onOutgoingMessage), this.on("status", this.configuration.onStatus), this.on("disconnect", this.configuration.onDisconnect), this.on("close", this.configuration.onClose), this.on("destroy", this.configuration.onDestroy), this.on("awarenessUpdate", this.configuration.onAwarenessUpdate), this.on("awarenessChange", this.configuration.onAwarenessChange), this.on("close", this.onClose.bind(this)), this.on("message", this.onMessage.bind(this)), this.intervals.connectionChecker = setInterval(this.checkConnection.bind(this), this.configuration.messageReconnectTimeout / 10), this.shouldConnect && this.connect();
4080
+ }, this.webSocket = null, this.webSocketHandlers = {}, this.shouldConnect = !0, this.status = $.Disconnected, this.lastMessageReceived = 0, this.identifier = 0, this.intervals = { connectionChecker: null }, this.connectionAttempt = null, this.receivedOnOpenPayload = void 0, this.closeTries = 0, this.setConfiguration(e), this.configuration.WebSocketPolyfill = e.WebSocketPolyfill ? e.WebSocketPolyfill : WebSocket, this.on("open", this.configuration.onOpen), this.on("open", this.onOpen.bind(this)), this.on("connect", this.configuration.onConnect), this.on("message", this.configuration.onMessage), this.on("outgoingMessage", this.configuration.onOutgoingMessage), this.on("status", this.configuration.onStatus), this.on("disconnect", this.configuration.onDisconnect), this.on("close", this.configuration.onClose), this.on("maxAttemptsFailed", this.configuration.onMaxAttemptsFailed), this.on("destroy", this.configuration.onDestroy), this.on("awarenessUpdate", this.configuration.onAwarenessUpdate), this.on("awarenessChange", this.configuration.onAwarenessChange), this.on("close", this.onClose.bind(this)), this.on("message", this.onMessage.bind(this)), this.intervals.connectionChecker = setInterval(this.checkConnection.bind(this), this.configuration.messageReconnectTimeout / 10), this.shouldConnect && this.connect();
4080
4081
  }
4081
4082
  async onOpen(e) {
4082
4083
  this.status = $.Connected, this.emit("status", { status: $.Connected }), this.cancelWebsocketRetry = void 0, this.receivedOnOpenPayload = e;
@@ -4116,7 +4117,7 @@ var Ns = (e, t) => {
4116
4117
  (!this.shouldConnect || e) && t.abort();
4117
4118
  }
4118
4119
  }).catch((e) => {
4119
- if (e && e.code !== "ATTEMPT_ABORTED") throw e;
4120
+ e?.code !== "ATTEMPT_ABORTED" && this.emit("maxAttemptsFailed", { error: e });
4120
4121
  }),
4121
4122
  cancelFunc: () => {
4122
4123
  e = !0;
@@ -4177,8 +4178,8 @@ var Ns = (e, t) => {
4177
4178
  stopConnectionAttempt() {
4178
4179
  this.connectionAttempt = null;
4179
4180
  }
4180
- rejectConnectionAttempt() {
4181
- this.connectionAttempt?.reject(), this.connectionAttempt = null;
4181
+ rejectConnectionAttempt(e) {
4182
+ this.connectionAttempt?.reject(e), this.connectionAttempt = null;
4182
4183
  }
4183
4184
  checkConnection() {
4184
4185
  this.status === $.Connected && this.lastMessageReceived && (this.configuration.messageReconnectTimeout >= O() - this.lastMessageReceived || (this.closeTries += 1, this.closeTries > 2 ? (this.onClose({ event: {
@@ -4228,7 +4229,7 @@ var Ns = (e, t) => {
4228
4229
  this.webSocket?.readyState === Os.Open ? this.webSocket.send(e) : this.addToQueue(e);
4229
4230
  }
4230
4231
  onClose({ event: e }) {
4231
- this.closeTries = 0, this.cleanupWebSocket(), this.connectionAttempt && this.rejectConnectionAttempt(), this.status = $.Disconnected, this.emit("status", { status: $.Disconnected }), this.emit("disconnect", { event: e }), !this.cancelWebsocketRetry && this.shouldConnect && setTimeout(() => {
4232
+ this.closeTries = 0, this.cleanupWebSocket(), this.connectionAttempt && this.rejectConnectionAttempt(/* @__PURE__ */ Error(`WebSocket closed before the connection was established (code: ${e?.code}, reason: ${e?.reason || "none"})`)), this.status = $.Disconnected, this.emit("status", { status: $.Disconnected }), this.emit("disconnect", { event: e }), !this.cancelWebsocketRetry && this.shouldConnect && setTimeout(() => {
4232
4233
  this.connect();
4233
4234
  }, this.configuration.delay);
4234
4235
  }
@@ -4305,7 +4306,7 @@ var Ns = (e, t) => {
4305
4306
  send(e) {
4306
4307
  e?.send(this.create());
4307
4308
  }
4308
- }, qs = "4.6.0", Js = class extends Hs {
4309
+ }, qs = "4.7.0", Js = class extends Hs {
4309
4310
  constructor(...e) {
4310
4311
  super(...e), this.type = Q.Auth, this.description = "Authentication";
4311
4312
  }