@blogmcp/community 0.4.0 → 0.5.0

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 (150) hide show
  1. package/dist/blogmcp-community-private.global.js +4 -0
  2. package/dist/blogmcp-community.global.js +3 -3
  3. package/dist/chunks/{mount-Ts_r2fwt.js → mount-SKmc4NgD.js} +39 -9
  4. package/dist/chunks/private-mount-bhCQeScD.js +5397 -0
  5. package/dist/core/attrs.d.ts +15 -0
  6. package/dist/core/settings.d.ts +5 -0
  7. package/dist/index.js +2 -2
  8. package/dist/private/core/dock.d.ts +38 -0
  9. package/dist/private/core/push.d.ts +49 -0
  10. package/dist/private/core/realtime.d.ts +57 -0
  11. package/dist/private/core/setup.d.ts +43 -0
  12. package/dist/private/core/view.d.ts +179 -0
  13. package/dist/private/dm/composer.d.ts +34 -0
  14. package/dist/private/dm/controller.d.ts +162 -0
  15. package/dist/private/dm/index.d.ts +14 -0
  16. package/dist/private/dm/links.d.ts +33 -0
  17. package/dist/private/dm/muted.d.ts +37 -0
  18. package/dist/private/dm/search.d.ts +7 -0
  19. package/dist/private/dm/text.d.ts +27 -0
  20. package/dist/private/dm/ui/DmBlocks.vue.d.ts +8 -0
  21. package/dist/private/dm/ui/DmCases.vue.d.ts +8 -0
  22. package/dist/private/dm/ui/DmComposer.vue.d.ts +20 -0
  23. package/dist/private/dm/ui/DmInbox.vue.d.ts +12 -0
  24. package/dist/private/dm/ui/DmLinkWarning.vue.d.ts +8 -0
  25. package/dist/private/dm/ui/DmLocalAids.vue.d.ts +8 -0
  26. package/dist/private/dm/ui/DmMessageText.vue.d.ts +8 -0
  27. package/dist/private/dm/ui/DmNew.vue.d.ts +12 -0
  28. package/dist/private/dm/ui/DmReport.vue.d.ts +8 -0
  29. package/dist/private/dm/ui/DmRequests.vue.d.ts +12 -0
  30. package/dist/private/dm/ui/DmScreens.vue.d.ts +9 -0
  31. package/dist/private/dm/ui/DmThread.vue.d.ts +9 -0
  32. package/dist/private/element.d.ts +23 -0
  33. package/dist/private/global.d.ts +10 -0
  34. package/dist/private/i18n.d.ts +41 -0
  35. package/dist/private/index.d.ts +32 -0
  36. package/dist/private/index.js +57 -0
  37. package/dist/private/mount.d.ts +55 -0
  38. package/dist/private/pages/api.d.ts +44 -0
  39. package/dist/private/pages/element.d.ts +6 -0
  40. package/dist/private/pages/fragment.d.ts +43 -0
  41. package/dist/private/pages/i18n.d.ts +25 -0
  42. package/dist/private/pages/index.d.ts +1 -0
  43. package/dist/private/pages/pages.d.ts +276 -0
  44. package/dist/private/pages/proof.d.ts +36 -0
  45. package/dist/private/pages/provider-view.d.ts +33 -0
  46. package/dist/private/pages/setup.d.ts +42 -0
  47. package/dist/private/pages/ui/AccountPageRoot.vue.d.ts +9 -0
  48. package/dist/private/pages/ui/PageActivation.vue.d.ts +9 -0
  49. package/dist/private/pages/ui/PageAddress.vue.d.ts +8 -0
  50. package/dist/private/pages/ui/PageDeviceApprove.vue.d.ts +8 -0
  51. package/dist/private/pages/ui/PageDevices.vue.d.ts +8 -0
  52. package/dist/private/pages/ui/PageExport.vue.d.ts +8 -0
  53. package/dist/private/pages/ui/PageMessages.vue.d.ts +9 -0
  54. package/dist/private/react.d.ts +12 -0
  55. package/dist/private/react.js +36 -0
  56. package/dist/private/ui/ChatDockRoot.vue.d.ts +20 -0
  57. package/dist/private/ui/LegalText.vue.d.ts +13 -0
  58. package/dist/private/ui/PrivateScreens.vue.d.ts +14 -0
  59. package/dist/private/ui/PrivateViewRoot.vue.d.ts +23 -0
  60. package/dist/private/ui/PromiseBlock.vue.d.ts +9 -0
  61. package/dist/private/ui/ProviderLine.vue.d.ts +8 -0
  62. package/dist/private/ui/ScreenActivation.vue.d.ts +8 -0
  63. package/dist/private/ui/ScreenAddress.vue.d.ts +8 -0
  64. package/dist/private/ui/ScreenApproval.vue.d.ts +8 -0
  65. package/dist/private/ui/ScreenDevices.vue.d.ts +8 -0
  66. package/dist/private/ui/ScreenHome.vue.d.ts +12 -0
  67. package/dist/private/ui/ScreenNotifications.vue.d.ts +8 -0
  68. package/dist/private/ui/ScreenReads.vue.d.ts +8 -0
  69. package/dist/private/ui/ScreenSettings.vue.d.ts +8 -0
  70. package/dist/private/ui/root.d.ts +35 -0
  71. package/dist/private/ui/text.d.ts +22 -0
  72. package/dist/private/vue.d.ts +88 -0
  73. package/dist/private/vue.js +72 -0
  74. package/dist/react.js +14 -14
  75. package/dist/vue.js +14 -14
  76. package/package.json +23 -6
  77. package/src/core/attrs.ts +19 -0
  78. package/src/core/settings.ts +55 -12
  79. package/src/private/core/dock.ts +105 -0
  80. package/src/private/core/push.ts +166 -0
  81. package/src/private/core/realtime.ts +109 -0
  82. package/src/private/core/setup.ts +75 -0
  83. package/src/private/core/view.ts +920 -0
  84. package/src/private/dm/composer.ts +74 -0
  85. package/src/private/dm/controller.ts +636 -0
  86. package/src/private/dm/index.ts +14 -0
  87. package/src/private/dm/links.ts +55 -0
  88. package/src/private/dm/muted.ts +160 -0
  89. package/src/private/dm/search.ts +18 -0
  90. package/src/private/dm/text.ts +60 -0
  91. package/src/private/dm/ui/DmBlocks.vue +27 -0
  92. package/src/private/dm/ui/DmCases.vue +58 -0
  93. package/src/private/dm/ui/DmComposer.vue +68 -0
  94. package/src/private/dm/ui/DmInbox.vue +34 -0
  95. package/src/private/dm/ui/DmLinkWarning.vue +27 -0
  96. package/src/private/dm/ui/DmLocalAids.vue +43 -0
  97. package/src/private/dm/ui/DmMessageText.vue +16 -0
  98. package/src/private/dm/ui/DmNew.vue +46 -0
  99. package/src/private/dm/ui/DmReport.vue +93 -0
  100. package/src/private/dm/ui/DmRequests.vue +50 -0
  101. package/src/private/dm/ui/DmScreens.vue +66 -0
  102. package/src/private/dm/ui/DmThread.vue +235 -0
  103. package/src/private/element.ts +90 -0
  104. package/src/private/global.ts +14 -0
  105. package/src/private/i18n.ts +127 -0
  106. package/src/private/index.ts +68 -0
  107. package/src/private/messages/cs.json +311 -0
  108. package/src/private/messages/en.json +319 -0
  109. package/src/private/mount.ts +103 -0
  110. package/src/private/pages/api.ts +96 -0
  111. package/src/private/pages/build.d.mts +2 -0
  112. package/src/private/pages/build.mjs +72 -0
  113. package/src/private/pages/element.ts +49 -0
  114. package/src/private/pages/fragment.ts +63 -0
  115. package/src/private/pages/i18n.ts +82 -0
  116. package/src/private/pages/index.ts +10 -0
  117. package/src/private/pages/messages/cs.json +97 -0
  118. package/src/private/pages/messages/en.json +97 -0
  119. package/src/private/pages/pages.ts +410 -0
  120. package/src/private/pages/proof.ts +110 -0
  121. package/src/private/pages/provider-view.ts +121 -0
  122. package/src/private/pages/setup.ts +79 -0
  123. package/src/private/pages/ui/AccountPageRoot.vue +45 -0
  124. package/src/private/pages/ui/PageActivation.vue +42 -0
  125. package/src/private/pages/ui/PageAddress.vue +39 -0
  126. package/src/private/pages/ui/PageDeviceApprove.vue +62 -0
  127. package/src/private/pages/ui/PageDevices.vue +84 -0
  128. package/src/private/pages/ui/PageExport.vue +35 -0
  129. package/src/private/pages/ui/PageMessages.vue +39 -0
  130. package/src/private/pages/ui/account.css +6 -0
  131. package/src/private/react.ts +49 -0
  132. package/src/private/shims.d.ts +6 -0
  133. package/src/private/ui/ChatDockRoot.vue +119 -0
  134. package/src/private/ui/LegalText.vue +18 -0
  135. package/src/private/ui/PrivateScreens.vue +61 -0
  136. package/src/private/ui/PrivateViewRoot.vue +70 -0
  137. package/src/private/ui/PromiseBlock.vue +18 -0
  138. package/src/private/ui/ProviderLine.vue +20 -0
  139. package/src/private/ui/ScreenActivation.vue +82 -0
  140. package/src/private/ui/ScreenAddress.vue +37 -0
  141. package/src/private/ui/ScreenApproval.vue +71 -0
  142. package/src/private/ui/ScreenDevices.vue +42 -0
  143. package/src/private/ui/ScreenHome.vue +29 -0
  144. package/src/private/ui/ScreenNotifications.vue +44 -0
  145. package/src/private/ui/ScreenReads.vue +23 -0
  146. package/src/private/ui/ScreenSettings.vue +44 -0
  147. package/src/private/ui/private.css +81 -0
  148. package/src/private/ui/root.ts +89 -0
  149. package/src/private/ui/text.ts +40 -0
  150. package/src/private/vue.ts +87 -0
@@ -0,0 +1,93 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * The report flow (§7.5, §7.8): the line (the website's rules, or illegal content), the category, and — before
4
+ * anything is sent — the preview of exactly what goes to whom („kdo to dostane“: the range of messages ending with the
5
+ * reported one, and the authorised persons by name or blogmcp's T&S). The box „zablokovat odesílatele“ is ticked by
6
+ * default (§7.5). A request is reported with „Zablokovat a nahlásit“: the request is the package, and it goes. It
7
+ * chooses the line too — `requests/block-report` takes only the category and kb-api routes by it (`lineOf`), so stranger
8
+ * spam or a threat in a request goes to blogmcp's T&S only when its illegal category can be picked here. A request has
9
+ * no preview; who receives it is said by the line.
10
+ * An adverse event also points to the manufacturer's poradna („Nahlásit výrobci“), which the member contacts in a step
11
+ * of their own: nothing of the report is passed on to it.
12
+ */
13
+ import { computed } from 'vue'
14
+ import type { PrivateDmReportLine } from '@blogmcp/sdk/community/private'
15
+ import type { CaseCategory } from '@blogmcp/sdk/community'
16
+ import type { Lang } from '../../i18n'
17
+ import { DM_ADVERSE_EVENT, categoriesOf, type DmViewController } from '../controller'
18
+ import { DM_CATEGORY_KEYS, DM_LINE_KEYS, dmText } from '../text'
19
+
20
+ const props = defineProps<{ dm: DmViewController; lang: Lang }>()
21
+ const tx = computed(() => dmText(props.lang))
22
+ const r = computed(() => props.dm.state.report)
23
+ const lines: PrivateDmReportLine[] = ['rules', 'illegal']
24
+ const categories = computed<readonly CaseCategory[]>(() => (r.value?.line ? categoriesOf(r.value.line) : []))
25
+ const poradna = computed(() => (r.value?.category === DM_ADVERSE_EVENT ? props.dm.consultationPath() : null))
26
+ const ready = computed(() => {
27
+ const x = r.value
28
+ if (!x || !x.category || x.done) return false
29
+ return x.kind === 'request' || x.preview !== null
30
+ })
31
+ const failure = computed(() => props.dm.state.failures.report ?? null)
32
+ </script>
33
+
34
+ <template>
35
+ <section v-if="r" class="bcm-p-screen bcm-p-dm-report" data-report :data-report-kind="r.kind">
36
+ <h3>{{ tx.pt(r.kind === 'request' ? 'private.dm.report.requestTitle' : 'private.dm.report.title') }}</h3>
37
+ <p v-if="poradna" class="bcm-p-note" data-poradna>
38
+ {{ tx.pt('private.dm.report.manufacturerWhy') }}
39
+ <a :href="poradna" class="bcm-p-link" data-action="poradna">{{ tx.pt('private.dm.report.manufacturer') }}</a>
40
+ </p>
41
+ <template v-if="r.done">
42
+ <p data-report-done>{{ tx.pt('private.dm.report.done') }}</p>
43
+ <button type="button" class="bcm-p-btn" data-action="report-close" @click="dm.cancelReport()">{{ tx.pt('private.close') }}</button>
44
+ </template>
45
+ <template v-else>
46
+ <fieldset>
47
+ <legend>{{ tx.pt('private.dm.report.line') }}</legend>
48
+ <label v-for="l in lines" :key="l" class="bcm-p-check">
49
+ <input type="radio" name="dmReportLine" :value="l" :checked="r.line === l" :data-line="l" @change="dm.reportLine(l)" />
50
+ {{ tx.pt(DM_LINE_KEYS[l]) }}
51
+ </label>
52
+ </fieldset>
53
+ <fieldset v-if="r.line">
54
+ <legend>{{ tx.pt('private.dm.report.category') }}</legend>
55
+ <label v-for="c in categories" :key="c" class="bcm-p-check">
56
+ <input type="radio" name="dmReportCategory" :value="c" :checked="r.category === c" :data-category="c" @change="dm.reportCategory(c)" />
57
+ {{ tx.pt(DM_CATEGORY_KEYS[c] ?? 'private.dm.report.category.other_illegal') }}
58
+ </label>
59
+ </fieldset>
60
+ <div v-if="r.preview" class="bcm-p-note" data-report-preview>
61
+ <h4>{{ tx.pt('private.dm.report.preview') }}</h4>
62
+ <p v-if="r.preview.recipients.kind === 'platform_ts'" data-recipients="platform_ts">{{ tx.pt('private.dm.report.toPlatform') }}</p>
63
+ <p v-else data-recipients="authorised_persons">{{ tx.pt('private.dm.report.toPersons', { names: r.preview.recipients.names.join(', ') }) }}</p>
64
+ <p class="bcm-p-muted">{{ tx.pt('private.dm.report.range', { count: r.preview.messages.length }) }}</p>
65
+ <ol class="bcm-p-list bcm-p-dm-range">
66
+ <li v-for="m in r.preview.messages" :key="m.seq" :data-preview-seq="m.seq">
67
+ <span class="bcm-p-badge">{{ tx.pt(m.mine ? 'private.dm.message.you' : 'private.dm.message.them') }}</span>
68
+ {{ m.state === 'visible' ? m.text : tx.pt(m.state === 'removed' ? 'private.dm.message.removed' : 'private.dm.message.tombstone') }}
69
+ </li>
70
+ </ol>
71
+ </div>
72
+ <template v-if="r.kind === 'request'">
73
+ <p v-if="r.line === 'illegal'" class="bcm-p-note" data-recipients="platform_ts">{{ tx.pt('private.dm.report.toPlatform') }}</p>
74
+ <p v-else-if="r.line === 'rules'" class="bcm-p-note" data-recipients="rules">{{ tx.pt('private.dm.report.requestToRules') }}</p>
75
+ <p class="bcm-p-muted">{{ tx.pt('private.dm.report.requestWhat') }}</p>
76
+ </template>
77
+ <label v-if="r.kind === 'message'" class="bcm-p-check">
78
+ <input v-model="r.block" type="checkbox" data-report-block />
79
+ {{ tx.pt('private.dm.report.block') }}
80
+ </label>
81
+ <label class="bcm-p-dm-note">
82
+ {{ tx.pt('private.dm.report.note') }}
83
+ <textarea v-model="r.note" class="bcm-p-input" rows="3" data-report-note />
84
+ </label>
85
+ <p class="bcm-p-muted">{{ tx.pt('private.dm.report.anonymous') }}</p>
86
+ <p v-if="failure" class="bcm-p-error" role="alert">{{ tx.err(failure) }}</p>
87
+ <div class="bcm-p-actions">
88
+ <button type="button" class="bcm-p-btn bcm-p-danger" :disabled="!ready || dm.state.busy" data-action="report-submit" @click="dm.submitReport()">{{ tx.pt(r.kind === 'request' ? 'private.dm.report.blockAndSend' : 'private.dm.report.send') }}</button>
89
+ <button type="button" class="bcm-p-btn" data-action="report-cancel" @click="dm.cancelReport()">{{ tx.pt('private.cancel') }}</button>
90
+ </div>
91
+ </template>
92
+ </section>
93
+ </template>
@@ -0,0 +1,50 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * The requests the member received (§7.3): each a card with the sender's profile card and the request's message — text
4
+ * only, its links inactive — and „Přijmout“, „Smazat“ and „Zablokovat a nahlásit“ (§7.5's `requests/block-report`: the
5
+ * request is the package, the sender is blocked, and the request goes). The sender is told only of an acceptance; a
6
+ * deleted or reported request is purged (`community.purge_dm_conversation`), so it also goes from the sender's own list
7
+ * — the words say so rather than promise that the sender cannot notice.
8
+ */
9
+ import { computed, ref } from 'vue'
10
+ import type { Lang } from '../../i18n'
11
+ import type { DmViewController } from '../controller'
12
+ import { dmText } from '../text'
13
+ import DmReport from './DmReport.vue'
14
+ import DmThread from './DmThread.vue'
15
+
16
+ const props = defineProps<{ dm: DmViewController; lang: Lang }>()
17
+ const emit = defineEmits<{ open: [conversationId: string] }>()
18
+ const tx = computed(() => dmText(props.lang))
19
+ const s = computed(() => props.dm.state)
20
+ const reading = ref<string | null>(null)
21
+
22
+ async function accept(cid: string): Promise<void> {
23
+ if (await props.dm.acceptRequest(cid)) emit('open', cid)
24
+ }
25
+ </script>
26
+
27
+ <template>
28
+ <section class="bcm-p-screen" data-dm-screen="requests">
29
+ <h3>{{ tx.pt('private.dm.requests.title') }}</h3>
30
+ <p class="bcm-p-muted">{{ tx.pt('private.dm.requests.why') }}</p>
31
+ <p v-if="s.failures.requests" class="bcm-p-error" role="alert">{{ tx.err(s.failures.requests) }}</p>
32
+ <p v-if="s.requests && s.requests.length === 0" class="bcm-p-muted" data-requests-empty>{{ tx.pt('private.dm.requests.empty') }}</p>
33
+ <ul v-if="s.requests && s.requests.length > 0" class="bcm-p-list">
34
+ <li v-for="r in s.requests" :key="r.conversationId" class="bcm-p-dm-request" :data-request-card="r.conversationId">
35
+ <p><strong>{{ tx.who(r.from) }}</strong></p>
36
+ <p class="bcm-p-muted">{{ tx.pt('private.dm.requests.at', { date: tx.when(r.lastMessageAt ?? r.createdAt) }) }}</p>
37
+ <button v-if="reading !== r.conversationId" type="button" class="bcm-p-link" data-action="read-request" @click="reading = r.conversationId">{{ tx.pt('private.dm.requests.read') }}</button>
38
+ <DmThread v-else :dm="dm" :conversation-id="r.conversationId" :lang="lang" />
39
+ <div class="bcm-p-actions">
40
+ <button type="button" class="bcm-p-btn bcm-p-primary" :disabled="s.busy" data-action="request-accept" @click="accept(r.conversationId)">{{ tx.pt('private.dm.request.accept') }}</button>
41
+ <button type="button" class="bcm-p-btn" :disabled="s.busy" data-action="request-delete" @click="dm.deleteRequest(r.conversationId)">{{ tx.pt('private.dm.request.delete') }}</button>
42
+ <button type="button" class="bcm-p-btn bcm-p-danger" :disabled="s.busy" data-action="request-block-report" @click="dm.startReport('request', r.conversationId)">{{ tx.pt('private.dm.request.blockReport') }}</button>
43
+ </div>
44
+ </li>
45
+ </ul>
46
+ <!-- Outside the list: a request reported goes from it, and the flow still says that the report was sent. -->
47
+ <DmReport v-if="s.report && s.report.kind === 'request'" :dm="dm" :lang="lang" />
48
+ <button v-if="s.requestsCursor" type="button" class="bcm-p-link" data-action="requests-more" @click="dm.loadRequests(true)">{{ tx.pt('private.dm.inbox.more') }}</button>
49
+ </section>
50
+ </template>
@@ -0,0 +1,66 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * The private view's `messages` screen (§7.8): the conversations' own screens — the inbox (with the requests waiting),
4
+ * one conversation, a new one, the requests, the private blocks and the member's cases. A dock opens a conversation
5
+ * in a window of its own instead (`openConversation`); without it the conversation opens here.
6
+ */
7
+ import { computed, onMounted } from 'vue'
8
+ import type { Lang } from '../../i18n'
9
+ import type { DmScreen, DmViewController } from '../controller'
10
+ import { dmText } from '../text'
11
+ import DmBlocks from './DmBlocks.vue'
12
+ import DmCases from './DmCases.vue'
13
+ import DmInbox from './DmInbox.vue'
14
+ import DmNew from './DmNew.vue'
15
+ import DmRequests from './DmRequests.vue'
16
+ import DmThread from './DmThread.vue'
17
+
18
+ const props = defineProps<{ dm: DmViewController | null; lang: Lang; openConversation?: (conversationId: string) => void }>()
19
+ const tx = computed(() => dmText(props.lang))
20
+ const s = computed(() => props.dm?.state ?? null)
21
+ const tabs: Array<{ screen: DmScreen; label: string }> = [
22
+ { screen: 'inbox', label: 'private.dm.tabs.inbox' },
23
+ { screen: 'new', label: 'private.dm.tabs.new' },
24
+ { screen: 'requests', label: 'private.dm.tabs.requests' },
25
+ { screen: 'blocks', label: 'private.dm.tabs.blocks' },
26
+ { screen: 'cases', label: 'private.dm.tabs.cases' },
27
+ ]
28
+ const waiting = computed(() => s.value?.requests?.length ?? 0)
29
+
30
+ function open(conversationId: string): void {
31
+ if (props.openConversation) props.openConversation(conversationId)
32
+ else void props.dm?.openConversation(conversationId)
33
+ }
34
+
35
+ onMounted(() => {
36
+ if (props.dm && props.dm.state.screen !== 'conversation') void props.dm.show(props.dm.state.screen)
37
+ })
38
+ </script>
39
+
40
+ <template>
41
+ <section class="bcm-p-screen" data-screen="messages">
42
+ <h2>{{ tx.pt('private.dm.title') }}</h2>
43
+ <p v-if="!dm || !s" class="bcm-p-muted" data-dm-unavailable>{{ tx.pt('private.dm.unavailable') }}</p>
44
+ <template v-else>
45
+ <p class="bcm-p-sr" role="status" aria-live="polite">
46
+ <span v-if="s.announcement" :key="s.announceId">{{ tx.pt(s.announcement.msg, s.announcement.params) }}</span>
47
+ </p>
48
+ <nav class="bcm-p-row bcm-p-dm-tabs" :aria-label="tx.pt('private.dm.title')">
49
+ <button v-for="t in tabs" :key="t.screen" type="button" class="bcm-p-link" :aria-current="s.screen === t.screen ? 'page' : undefined" :data-dm-open="t.screen" @click="dm.show(t.screen)">
50
+ {{ tx.pt(t.label) }}<span v-if="t.screen === 'requests' && waiting > 0" class="bcm-p-badge" data-requests-count>{{ waiting }}</span>
51
+ </button>
52
+ </nav>
53
+ <template v-if="s.screen === 'inbox'">
54
+ <p v-if="waiting > 0" class="bcm-p-note">
55
+ <button type="button" class="bcm-p-link" data-action="show-requests" @click="dm.show('requests')">{{ tx.pt('private.dm.requests.waiting', { count: waiting }) }}</button>
56
+ </p>
57
+ <DmInbox :dm="dm" :lang="lang" @open="open" />
58
+ </template>
59
+ <DmThread v-else-if="s.screen === 'conversation' && s.current" :dm="dm" :conversation-id="s.current" :lang="lang" />
60
+ <DmNew v-else-if="s.screen === 'new'" :dm="dm" :lang="lang" @opened="open" />
61
+ <DmRequests v-else-if="s.screen === 'requests'" :dm="dm" :lang="lang" @open="open" />
62
+ <DmBlocks v-else-if="s.screen === 'blocks'" :dm="dm" :lang="lang" />
63
+ <DmCases v-else-if="s.screen === 'cases'" :dm="dm" :lang="lang" />
64
+ </template>
65
+ </section>
66
+ </template>
@@ -0,0 +1,235 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * One conversation (§7.8): the messages at their newest revision, older ones on request, the member's sends still on
4
+ * their way (queued, sending, waiting with the reason, failed with „Zkusit znovu“ / „Zahodit“), „píše…“, the read
5
+ * receipt under the member's last message the other participant has read, search in the loaded messages, the
6
+ * affordances each message still has (reply; edit and delete for everyone within their windows; „Smazat u mě“ always;
7
+ * report on the other participant's), the report flow, the link warning and the composer. A dock window and the full
8
+ * view mount the same component; each watches the thread while it is mounted, and the last one to go drops its
9
+ * decrypted messages (controller.ts `watch`).
10
+ *
11
+ * Muted words fold a message away („Zobrazit“ shows it on this page), and a reply's quote of a folded message is folded
12
+ * too; a request's links are inactive (§7.3).
13
+ *
14
+ * **Read only while seen.** A loaded thread is marked read only while it is on the member's screen: not while the tab is
15
+ * hidden, and not while the host hides the dock (`hidden-by-host` on the custom element, which hides it by CSS and
16
+ * unmounts nothing) — the other participant would otherwise get a receipt for text nobody saw. When the tab or the dock
17
+ * shows again, what came meanwhile is marked read then, without waiting for the next message.
18
+ */
19
+ import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
20
+ import type { PrivateDmMessage } from '@blogmcp/sdk/community/private'
21
+ import type { Lang } from '../../i18n'
22
+ import { canDeleteForAll, canEdit, canReport } from '../composer'
23
+ import type { DmViewController } from '../controller'
24
+ import { mutedMatch } from '../muted'
25
+ import { searchLoaded } from '../search'
26
+ import { dmText } from '../text'
27
+ import DmComposer from './DmComposer.vue'
28
+ import DmLinkWarning from './DmLinkWarning.vue'
29
+ import DmMessageText from './DmMessageText.vue'
30
+ import DmReport from './DmReport.vue'
31
+ // The attribute's name only: element.ts defines the custom elements, which this component must not import.
32
+ const HIDDEN_BY_HOST_ATTR = 'hidden-by-host'
33
+
34
+ const props = defineProps<{ dm: DmViewController; conversationId: string; lang: Lang }>()
35
+ const tx = computed(() => dmText(props.lang))
36
+ const cid = computed(() => props.conversationId.toLowerCase())
37
+ const t = computed(() => props.dm.state.threads[cid.value] ?? null)
38
+ const messages = computed<readonly PrivateDmMessage[]>(() => t.value?.messages ?? [])
39
+ const pending = computed(() => t.value?.pending ?? [])
40
+ const conversation = computed(() => props.dm.state.inbox?.find((c) => c.conversationId === cid.value) ?? null)
41
+ const received = computed(() => props.dm.state.requests?.some((r) => r.conversationId === cid.value) === true)
42
+ /** A request (sent or received, not yet accepted): text only, its links inactive. */
43
+ const isRequest = computed(() => received.value || conversation.value?.state === 'request')
44
+ const counterpart = computed(() => props.dm.state.counterparts[cid.value] ?? conversation.value?.counterpart ?? null)
45
+ const firstMessage = computed(() => t.value?.loaded === true && !messages.value.some((m) => m.mine) && pending.value.length === 0)
46
+ /** The member's last message the other participant has read (receipts only flow when both turned them on). */
47
+ const readMark = computed(() => {
48
+ const upTo = t.value?.readUpTo ?? null
49
+ if (upTo === null) return null
50
+ const mine = messages.value.filter((m) => m.mine && m.seq <= upTo)
51
+ return mine.length > 0 ? mine[mine.length - 1]!.seq : null
52
+ })
53
+
54
+ const query = ref('')
55
+ const hits = computed(() => new Set(searchLoaded(messages.value, query.value)))
56
+ const searching = computed(() => query.value.trim().length > 0)
57
+
58
+ const selected = ref<number | null>(null)
59
+ const editing = ref<{ seq: number; text: string } | null>(null)
60
+ const replyTo = ref<{ seq: number; excerpt: string } | null>(null)
61
+ const confirm = ref<'clear' | 'block' | null>(null)
62
+
63
+ const folded = (m: PrivateDmMessage): boolean => m.state === 'visible' && !m.mine && mutedMatch(m.text, props.dm.state.muted) && !props.dm.state.unfolded[`${cid.value}:${m.seq}`]
64
+ const excerpt = (text: string | null): string => {
65
+ const s = (text ?? '').replace(/\s+/g, ' ').trim()
66
+ return s.length > 60 ? `${s.slice(0, 59)}…` : s
67
+ }
68
+ /** A reply's quote: the quoted message's excerpt, or the muted placeholder when that message is folded. */
69
+ const quoteOf = (seq: number): string => {
70
+ const q = messages.value.find((x) => x.seq === seq)
71
+ return q && folded(q) ? tx.value.pt('private.dm.message.muted') : excerpt(q?.text ?? null)
72
+ }
73
+ const pendingKey = (state: string): string =>
74
+ state === 'queued' ? 'private.dm.pending.queued' : state === 'waiting' ? 'private.dm.pending.waiting' : state === 'failed' ? 'private.dm.pending.failed' : 'private.dm.pending.sending'
75
+
76
+ const root = ref<HTMLElement | null>(null)
77
+ /** The custom element this thread renders in (its shadow root's host), where the host sets `hidden-by-host`. */
78
+ const hostElement = (): Element | null => {
79
+ const r = root.value?.getRootNode?.()
80
+ return r && typeof ShadowRoot !== 'undefined' && r instanceof ShadowRoot ? r.host : null
81
+ }
82
+ const onScreen = (): boolean => {
83
+ if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return false
84
+ return hostElement()?.hasAttribute(HIDDEN_BY_HOST_ATTR) !== true
85
+ }
86
+ // A loaded thread on screen is read: up to its newest message, only forward (the DM client asks once per mark).
87
+ function markIfSeen(): void {
88
+ if (t.value?.loaded && onScreen()) props.dm.markRead(cid.value)
89
+ }
90
+ const onVisibility = (): void => markIfSeen()
91
+ let hostObserver: MutationObserver | null = null
92
+
93
+ let unwatch: (() => void) | null = null
94
+ onMounted(() => {
95
+ unwatch = props.dm.watch(cid.value)
96
+ if (typeof document !== 'undefined') document.addEventListener('visibilitychange', onVisibility)
97
+ const host = hostElement()
98
+ if (host && typeof MutationObserver !== 'undefined') {
99
+ hostObserver = new MutationObserver(() => markIfSeen())
100
+ hostObserver.observe(host, { attributes: true, attributeFilter: [HIDDEN_BY_HOST_ATTR] })
101
+ }
102
+ })
103
+ watch(cid, (next, before) => {
104
+ if (next === before) return
105
+ unwatch?.()
106
+ unwatch = props.dm.watch(next)
107
+ selected.value = null
108
+ editing.value = null
109
+ replyTo.value = null
110
+ })
111
+ onBeforeUnmount(() => {
112
+ if (typeof document !== 'undefined') document.removeEventListener('visibilitychange', onVisibility)
113
+ hostObserver?.disconnect()
114
+ hostObserver = null
115
+ unwatch?.()
116
+ unwatch = null
117
+ })
118
+
119
+ watch(
120
+ () => [t.value?.loaded, messages.value.length ? messages.value[messages.value.length - 1]!.seq : 0] as const,
121
+ () => markIfSeen(),
122
+ )
123
+
124
+ async function saveEdit(m: PrivateDmMessage): Promise<void> {
125
+ const e = editing.value
126
+ if (!e) return
127
+ if (await props.dm.edit(cid.value, m, e.text)) editing.value = null
128
+ }
129
+
130
+ async function block(): Promise<void> {
131
+ confirm.value = null
132
+ const c = counterpart.value
133
+ if (c && c.memberId !== null) await props.dm.block(c.memberId)
134
+ }
135
+
136
+ async function clear(): Promise<void> {
137
+ confirm.value = null
138
+ await props.dm.clear(cid.value)
139
+ }
140
+ </script>
141
+
142
+ <template>
143
+ <section ref="root" class="bcm-p-screen bcm-p-dm-thread" data-thread :data-conversation="cid" :data-request="isRequest ? 'true' : 'false'">
144
+ <header class="bcm-p-row bcm-p-dm-head">
145
+ <h3>{{ tx.who(counterpart) }}</h3>
146
+ <span v-if="isRequest" class="bcm-p-badge" data-request-badge>{{ tx.pt(received ? 'private.dm.request.received' : 'private.dm.request.sent') }}</span>
147
+ </header>
148
+
149
+ <label class="bcm-p-dm-search">
150
+ <span class="bcm-p-sr">{{ tx.pt('private.dm.search.label') }}</span>
151
+ <input v-model="query" type="search" class="bcm-p-input" :placeholder="tx.pt('private.dm.search.placeholder')" data-search />
152
+ </label>
153
+ <p v-if="searching" class="bcm-p-muted" data-search-result>{{ tx.pt('private.dm.search.result', { count: hits.size }) }} {{ tx.pt('private.dm.search.local') }}</p>
154
+
155
+ <button v-if="t?.hasOlder" type="button" class="bcm-p-link" data-action="older" @click="dm.loadOlder(cid)">{{ tx.pt('private.dm.thread.older') }}</button>
156
+ <p v-if="t && !t.loaded && t.loading" class="bcm-p-muted">{{ tx.pt('private.loading') }}</p>
157
+ <p v-if="t?.error" class="bcm-p-error" role="alert">{{ tx.err(t.error) }}</p>
158
+ <p v-if="t?.loaded && messages.length === 0 && pending.length === 0" class="bcm-p-muted" data-empty>{{ tx.pt('private.dm.thread.empty') }}</p>
159
+
160
+ <ol class="bcm-p-list bcm-p-dm-messages" :aria-label="tx.pt('private.dm.thread.messages')">
161
+ <li
162
+ v-for="m in messages"
163
+ :key="m.seq"
164
+ :class="{ 'bcm-p-dm-mine': m.mine, 'bcm-p-dm-hit': hits.has(m.seq) }"
165
+ :data-seq="m.seq"
166
+ :data-state="m.state"
167
+ >
168
+ <p class="bcm-p-muted bcm-p-dm-meta">
169
+ {{ tx.pt(m.mine ? 'private.dm.message.you' : 'private.dm.message.them') }} · {{ tx.when(m.createdAt) }}
170
+ <span v-if="m.editedMark" class="bcm-p-badge" data-edited>{{ tx.pt('private.dm.message.editedMark') }}</span>
171
+ </p>
172
+ <p v-if="m.replyToSeq !== null" class="bcm-p-muted" data-reply-to>{{ tx.pt('private.dm.message.replyTo', { excerpt: quoteOf(m.replyToSeq) }) }}</p>
173
+ <p v-if="m.state === 'deleted'" class="bcm-p-muted" data-tombstone>{{ tx.pt('private.dm.message.tombstone') }}</p>
174
+ <p v-else-if="m.state === 'removed'" class="bcm-p-muted" data-removed>{{ tx.pt('private.dm.message.removed') }}</p>
175
+ <p v-else-if="folded(m)" class="bcm-p-muted" data-folded>
176
+ {{ tx.pt('private.dm.message.muted') }}
177
+ <button type="button" class="bcm-p-link" data-action="unfold" @click="dm.unfold(cid, m.seq)">{{ tx.pt('private.dm.message.show') }}</button>
178
+ </p>
179
+ <form v-else-if="editing && editing.seq === m.seq" class="bcm-p-form" data-editing @submit.prevent="saveEdit(m)">
180
+ <textarea v-model="editing.text" class="bcm-p-input" rows="3" :aria-label="tx.pt('private.dm.message.editLabel')" data-edit-box />
181
+ <div class="bcm-p-actions">
182
+ <button type="submit" class="bcm-p-btn bcm-p-primary" :disabled="dm.state.busy" data-action="edit-save">{{ tx.pt('private.dm.message.save') }}</button>
183
+ <button type="button" class="bcm-p-btn" @click="editing = null">{{ tx.pt('private.cancel') }}</button>
184
+ </div>
185
+ </form>
186
+ <p v-else class="bcm-p-dm-body"><DmMessageText :dm="dm" :text="m.text ?? ''" :links="!isRequest" /></p>
187
+ <p v-if="readMark === m.seq" class="bcm-p-muted" data-read-receipt>{{ tx.pt('private.dm.message.read') }}</p>
188
+
189
+ <button type="button" class="bcm-p-icon" :aria-label="tx.pt('private.dm.message.actions')" :aria-expanded="selected === m.seq" data-action="message-actions" @click="selected = selected === m.seq ? null : m.seq">⋯</button>
190
+ <div v-if="selected === m.seq" class="bcm-p-actions" data-message-actions>
191
+ <button v-if="m.state === 'visible' && !isRequest" type="button" class="bcm-p-btn" data-action="reply" @click="replyTo = { seq: m.seq, excerpt: excerpt(m.text) }; selected = null">{{ tx.pt('private.dm.message.reply') }}</button>
192
+ <button v-if="canEdit(m)" type="button" class="bcm-p-btn" data-action="edit" @click="editing = { seq: m.seq, text: m.text ?? '' }; selected = null">{{ tx.pt('private.dm.message.edit') }}</button>
193
+ <button v-if="canDeleteForAll(m)" type="button" class="bcm-p-btn bcm-p-danger" :disabled="dm.state.busy" data-action="delete-all" @click="dm.deleteForAll(cid, m.seq); selected = null">{{ tx.pt('private.dm.message.deleteForAll') }}</button>
194
+ <button type="button" class="bcm-p-btn" :disabled="dm.state.busy" data-action="hide" @click="dm.hide(cid, m.seq); selected = null">{{ tx.pt('private.dm.message.hide') }}</button>
195
+ <button v-if="canReport(m)" type="button" class="bcm-p-btn bcm-p-danger" data-action="report" @click="dm.startReport('message', cid, m.seq); selected = null">{{ tx.pt('private.dm.message.report') }}</button>
196
+ </div>
197
+ </li>
198
+ </ol>
199
+
200
+ <ul v-if="pending.length > 0" class="bcm-p-list bcm-p-dm-pending" data-pending>
201
+ <li v-for="p in pending" :key="p.clientMsgId" class="bcm-p-dm-mine" :data-pending-state="p.state">
202
+ <p class="bcm-p-dm-body">{{ p.text }}</p>
203
+ <p class="bcm-p-muted">
204
+ {{ tx.pt(pendingKey(p.state)) }}<template v-if="(p.state === 'waiting' || p.state === 'failed') && p.lastCode"> {{ tx.err(p.lastCode) }}</template>
205
+ </p>
206
+ <div v-if="p.state === 'failed'" class="bcm-p-actions">
207
+ <button type="button" class="bcm-p-btn" data-action="send-retry" @click="dm.retry(p.clientMsgId)">{{ tx.pt('private.retry') }}</button>
208
+ <button type="button" class="bcm-p-btn" data-action="send-discard" @click="dm.discard(p.clientMsgId)">{{ tx.pt('private.dm.pending.discard') }}</button>
209
+ </div>
210
+ </li>
211
+ </ul>
212
+
213
+ <p v-if="t?.typing" class="bcm-p-muted" aria-live="polite" data-typing>{{ tx.pt('private.dm.thread.typing') }}</p>
214
+ <p v-if="dm.state.failures.thread" class="bcm-p-error" role="alert">{{ tx.err(dm.state.failures.thread) }}</p>
215
+
216
+ <DmLinkWarning :dm="dm" :lang="lang" />
217
+ <DmReport v-if="dm.state.report && dm.state.report.conversationId === cid && dm.state.report.kind === 'message'" :dm="dm" :lang="lang" />
218
+
219
+ <p v-if="dm.readOnly()" class="bcm-p-note" data-read-only>{{ tx.pt('private.readOnly') }}</p>
220
+ <DmComposer v-else-if="!received" :dm="dm" :conversation-id="cid" :lang="lang" :first-message="firstMessage" :reply-to="replyTo" @sent="replyTo = null" @cancel-reply="replyTo = null" />
221
+
222
+ <div class="bcm-p-actions bcm-p-dm-tools">
223
+ <button v-if="confirm === null" type="button" class="bcm-p-link" data-action="clear" @click="confirm = 'clear'">{{ tx.pt('private.dm.thread.clear') }}</button>
224
+ <button v-if="confirm === null && counterpart && counterpart.memberId !== null" type="button" class="bcm-p-link" data-action="block" @click="confirm = 'block'">{{ tx.pt('private.dm.block.action') }}</button>
225
+ </div>
226
+ <template v-if="confirm">
227
+ <p class="bcm-p-note">{{ tx.pt(confirm === 'clear' ? 'private.dm.thread.clearConfirm' : 'private.dm.block.confirm') }}</p>
228
+ <div class="bcm-p-actions">
229
+ <button type="button" class="bcm-p-btn bcm-p-danger" :disabled="dm.state.busy" data-action="confirm" @click="confirm === 'clear' ? clear() : block()">{{ tx.pt('private.confirm') }}</button>
230
+ <button type="button" class="bcm-p-btn" @click="confirm = null">{{ tx.pt('private.cancel') }}</button>
231
+ </div>
232
+ </template>
233
+ <p v-if="dm.state.failures.blocks" class="bcm-p-error" role="alert">{{ tx.err(dm.state.failures.blocks) }}</p>
234
+ </section>
235
+ </template>
@@ -0,0 +1,90 @@
1
+ /// <reference path="../shims.d.ts" />
2
+ /**
3
+ * The private elements (m4-contracts.md §6.2, A.9), each a Vue component in a shadow root with ONE inline stylesheet
4
+ * admitted by the CSP nonce — the pattern of the public `src/element.ts`, kept here so that this entry never imports
5
+ * the public one (its bundle would carry every public view):
6
+ *
7
+ * <blogmcp-chat-dock> kb-origin, api-base, site-base, lang, routes, site-name, sw-path, account-origin, nonce,
8
+ * hidden-by-host (+ the `transport`, `client` and `realtime` properties)
9
+ * <blogmcp-private-view> the same but hidden-by-host, + screen (and the same three properties)
10
+ *
11
+ * Both roots carry `data-blogmcp-private` and tell the page (`markPrivateRoot`), so a host pauses its analytics and any
12
+ * RUM while they are on screen (§7.1). The dock's `hidden-by-host` hides it by CSS: nothing unmounts, so its session,
13
+ * its realtime subscription and its open windows survive the regulated preset's pages (§6.7).
14
+ */
15
+ import { defineCustomElement, type Component } from 'vue'
16
+ import ChatDockRoot from './ui/ChatDockRoot.vue'
17
+ import PrivateViewRoot from './ui/PrivateViewRoot.vue'
18
+ import css from './ui/private.css?inline'
19
+
20
+ export const CHAT_DOCK_ELEMENT_TAG = 'blogmcp-chat-dock'
21
+ export const PRIVATE_VIEW_ELEMENT_TAG = 'blogmcp-private-view'
22
+ /** The host attribute that hides the dock without unmounting it. */
23
+ export const HIDDEN_BY_HOST_ATTR = 'hidden-by-host'
24
+
25
+ export interface DefinePrivateElementOptions {
26
+ /** Another tag name for the element. */
27
+ tag?: string
28
+ /** CSP nonce for the element's `<style>` (else each element's own `nonce`). */
29
+ nonce?: string
30
+ }
31
+
32
+ export interface DefinePrivateElementsOptions {
33
+ nonce?: string
34
+ tags?: { chatDock?: string; privateView?: string }
35
+ }
36
+
37
+ /** Vue's ESM build reads three compile-time flags as globals; give them Vue's defaults where no bundler did (element.ts). */
38
+ function ensureVueFeatureFlags(): void {
39
+ const g = globalThis as Record<string, unknown>
40
+ const defaults: Record<string, boolean> = { __VUE_OPTIONS_API__: true, __VUE_PROD_DEVTOOLS__: false, __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false }
41
+ for (const [flag, value] of Object.entries(defaults)) if (typeof g[flag] === 'undefined') g[flag] = value
42
+ }
43
+
44
+ function ownNonce(el: HTMLElement): string | undefined {
45
+ const fromProperty = (el as HTMLElement & { nonce?: unknown }).nonce
46
+ if (typeof fromProperty === 'string' && fromProperty !== '') return fromProperty
47
+ return el.getAttribute('nonce') || undefined
48
+ }
49
+
50
+ function privateElement(component: Component, defineNonce: string | undefined): CustomElementConstructor {
51
+ const Base = defineCustomElement(component as Parameters<typeof defineCustomElement>[0])
52
+ return class PrivateElement extends Base {
53
+ override connectedCallback(): void {
54
+ const own = ownNonce(this)
55
+ const nonce = defineNonce || own
56
+ if (nonce && !own) (this as HTMLElement & { nonce: string }).nonce = nonce
57
+ const root = this.shadowRoot
58
+ if (root && !root.querySelector('style[data-bcm]')) {
59
+ const style = document.createElement('style')
60
+ style.setAttribute('data-bcm', '')
61
+ if (nonce) style.setAttribute('nonce', nonce)
62
+ style.textContent = css
63
+ root.prepend(style)
64
+ }
65
+ super.connectedCallback()
66
+ }
67
+ }
68
+ }
69
+
70
+ function define(tag: string, component: Component, nonce: string | undefined): void {
71
+ if (typeof customElements === 'undefined' || customElements.get(tag)) return
72
+ ensureVueFeatureFlags()
73
+ customElements.define(tag, privateElement(component, nonce))
74
+ }
75
+
76
+ /** Register `<blogmcp-chat-dock>` (once; later calls are no-ops). Browser only. */
77
+ export function defineChatDockElement(opts: DefinePrivateElementOptions = {}): void {
78
+ define(opts.tag ?? CHAT_DOCK_ELEMENT_TAG, ChatDockRoot, opts.nonce)
79
+ }
80
+
81
+ /** Register `<blogmcp-private-view>` (once). Browser only. */
82
+ export function definePrivateViewElement(opts: DefinePrivateElementOptions = {}): void {
83
+ define(opts.tag ?? PRIVATE_VIEW_ELEMENT_TAG, PrivateViewRoot, opts.nonce)
84
+ }
85
+
86
+ /** Register both (once). Browser only. */
87
+ export function definePrivateElements(opts: DefinePrivateElementsOptions = {}): void {
88
+ defineChatDockElement({ tag: opts.tags?.chatDock, nonce: opts.nonce })
89
+ definePrivateViewElement({ tag: opts.tags?.privateView, nonce: opts.nonce })
90
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The private `<script>` build (`blogmcp-community-private.global.js`): registers `<blogmcp-chat-dock>` and
3
+ * `<blogmcp-private-view>` with the script tag's own CSP nonce and exposes `window.BlogmcpCommunityPrivate`. It is a
4
+ * file of its own, never part of the public `blogmcp-community.global.js`: a page that shows no private view loads none
5
+ * of it. Load it only where the host's `me/get` names a live private block.
6
+ */
7
+ import { definePrivateElements } from './element'
8
+ import { mountChatDock, mountPrivateView } from './mount'
9
+ import { VERSION } from '../version'
10
+
11
+ const script = typeof document !== 'undefined' ? (document.currentScript as HTMLScriptElement | null) : null
12
+ definePrivateElements({ nonce: script?.nonce || undefined })
13
+
14
+ export { definePrivateElements, mountChatDock, mountPrivateView, VERSION }