@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.
- package/dist/blogmcp-community-private.global.js +4 -0
- package/dist/blogmcp-community.global.js +3 -3
- package/dist/chunks/{mount-Ts_r2fwt.js → mount-SKmc4NgD.js} +39 -9
- package/dist/chunks/private-mount-bhCQeScD.js +5397 -0
- package/dist/core/attrs.d.ts +15 -0
- package/dist/core/settings.d.ts +5 -0
- package/dist/index.js +2 -2
- package/dist/private/core/dock.d.ts +38 -0
- package/dist/private/core/push.d.ts +49 -0
- package/dist/private/core/realtime.d.ts +57 -0
- package/dist/private/core/setup.d.ts +43 -0
- package/dist/private/core/view.d.ts +179 -0
- package/dist/private/dm/composer.d.ts +34 -0
- package/dist/private/dm/controller.d.ts +162 -0
- package/dist/private/dm/index.d.ts +14 -0
- package/dist/private/dm/links.d.ts +33 -0
- package/dist/private/dm/muted.d.ts +37 -0
- package/dist/private/dm/search.d.ts +7 -0
- package/dist/private/dm/text.d.ts +27 -0
- package/dist/private/dm/ui/DmBlocks.vue.d.ts +8 -0
- package/dist/private/dm/ui/DmCases.vue.d.ts +8 -0
- package/dist/private/dm/ui/DmComposer.vue.d.ts +20 -0
- package/dist/private/dm/ui/DmInbox.vue.d.ts +12 -0
- package/dist/private/dm/ui/DmLinkWarning.vue.d.ts +8 -0
- package/dist/private/dm/ui/DmLocalAids.vue.d.ts +8 -0
- package/dist/private/dm/ui/DmMessageText.vue.d.ts +8 -0
- package/dist/private/dm/ui/DmNew.vue.d.ts +12 -0
- package/dist/private/dm/ui/DmReport.vue.d.ts +8 -0
- package/dist/private/dm/ui/DmRequests.vue.d.ts +12 -0
- package/dist/private/dm/ui/DmScreens.vue.d.ts +9 -0
- package/dist/private/dm/ui/DmThread.vue.d.ts +9 -0
- package/dist/private/element.d.ts +23 -0
- package/dist/private/global.d.ts +10 -0
- package/dist/private/i18n.d.ts +41 -0
- package/dist/private/index.d.ts +32 -0
- package/dist/private/index.js +57 -0
- package/dist/private/mount.d.ts +55 -0
- package/dist/private/pages/api.d.ts +44 -0
- package/dist/private/pages/element.d.ts +6 -0
- package/dist/private/pages/fragment.d.ts +43 -0
- package/dist/private/pages/i18n.d.ts +25 -0
- package/dist/private/pages/index.d.ts +1 -0
- package/dist/private/pages/pages.d.ts +276 -0
- package/dist/private/pages/proof.d.ts +36 -0
- package/dist/private/pages/provider-view.d.ts +33 -0
- package/dist/private/pages/setup.d.ts +42 -0
- package/dist/private/pages/ui/AccountPageRoot.vue.d.ts +9 -0
- package/dist/private/pages/ui/PageActivation.vue.d.ts +9 -0
- package/dist/private/pages/ui/PageAddress.vue.d.ts +8 -0
- package/dist/private/pages/ui/PageDeviceApprove.vue.d.ts +8 -0
- package/dist/private/pages/ui/PageDevices.vue.d.ts +8 -0
- package/dist/private/pages/ui/PageExport.vue.d.ts +8 -0
- package/dist/private/pages/ui/PageMessages.vue.d.ts +9 -0
- package/dist/private/react.d.ts +12 -0
- package/dist/private/react.js +36 -0
- package/dist/private/ui/ChatDockRoot.vue.d.ts +20 -0
- package/dist/private/ui/LegalText.vue.d.ts +13 -0
- package/dist/private/ui/PrivateScreens.vue.d.ts +14 -0
- package/dist/private/ui/PrivateViewRoot.vue.d.ts +23 -0
- package/dist/private/ui/PromiseBlock.vue.d.ts +9 -0
- package/dist/private/ui/ProviderLine.vue.d.ts +8 -0
- package/dist/private/ui/ScreenActivation.vue.d.ts +8 -0
- package/dist/private/ui/ScreenAddress.vue.d.ts +8 -0
- package/dist/private/ui/ScreenApproval.vue.d.ts +8 -0
- package/dist/private/ui/ScreenDevices.vue.d.ts +8 -0
- package/dist/private/ui/ScreenHome.vue.d.ts +12 -0
- package/dist/private/ui/ScreenNotifications.vue.d.ts +8 -0
- package/dist/private/ui/ScreenReads.vue.d.ts +8 -0
- package/dist/private/ui/ScreenSettings.vue.d.ts +8 -0
- package/dist/private/ui/root.d.ts +35 -0
- package/dist/private/ui/text.d.ts +22 -0
- package/dist/private/vue.d.ts +88 -0
- package/dist/private/vue.js +72 -0
- package/dist/react.js +14 -14
- package/dist/vue.js +14 -14
- package/package.json +23 -6
- package/src/core/attrs.ts +19 -0
- package/src/core/settings.ts +55 -12
- package/src/private/core/dock.ts +105 -0
- package/src/private/core/push.ts +166 -0
- package/src/private/core/realtime.ts +109 -0
- package/src/private/core/setup.ts +75 -0
- package/src/private/core/view.ts +920 -0
- package/src/private/dm/composer.ts +74 -0
- package/src/private/dm/controller.ts +636 -0
- package/src/private/dm/index.ts +14 -0
- package/src/private/dm/links.ts +55 -0
- package/src/private/dm/muted.ts +160 -0
- package/src/private/dm/search.ts +18 -0
- package/src/private/dm/text.ts +60 -0
- package/src/private/dm/ui/DmBlocks.vue +27 -0
- package/src/private/dm/ui/DmCases.vue +58 -0
- package/src/private/dm/ui/DmComposer.vue +68 -0
- package/src/private/dm/ui/DmInbox.vue +34 -0
- package/src/private/dm/ui/DmLinkWarning.vue +27 -0
- package/src/private/dm/ui/DmLocalAids.vue +43 -0
- package/src/private/dm/ui/DmMessageText.vue +16 -0
- package/src/private/dm/ui/DmNew.vue +46 -0
- package/src/private/dm/ui/DmReport.vue +93 -0
- package/src/private/dm/ui/DmRequests.vue +50 -0
- package/src/private/dm/ui/DmScreens.vue +66 -0
- package/src/private/dm/ui/DmThread.vue +235 -0
- package/src/private/element.ts +90 -0
- package/src/private/global.ts +14 -0
- package/src/private/i18n.ts +127 -0
- package/src/private/index.ts +68 -0
- package/src/private/messages/cs.json +311 -0
- package/src/private/messages/en.json +319 -0
- package/src/private/mount.ts +103 -0
- package/src/private/pages/api.ts +96 -0
- package/src/private/pages/build.d.mts +2 -0
- package/src/private/pages/build.mjs +72 -0
- package/src/private/pages/element.ts +49 -0
- package/src/private/pages/fragment.ts +63 -0
- package/src/private/pages/i18n.ts +82 -0
- package/src/private/pages/index.ts +10 -0
- package/src/private/pages/messages/cs.json +97 -0
- package/src/private/pages/messages/en.json +97 -0
- package/src/private/pages/pages.ts +410 -0
- package/src/private/pages/proof.ts +110 -0
- package/src/private/pages/provider-view.ts +121 -0
- package/src/private/pages/setup.ts +79 -0
- package/src/private/pages/ui/AccountPageRoot.vue +45 -0
- package/src/private/pages/ui/PageActivation.vue +42 -0
- package/src/private/pages/ui/PageAddress.vue +39 -0
- package/src/private/pages/ui/PageDeviceApprove.vue +62 -0
- package/src/private/pages/ui/PageDevices.vue +84 -0
- package/src/private/pages/ui/PageExport.vue +35 -0
- package/src/private/pages/ui/PageMessages.vue +39 -0
- package/src/private/pages/ui/account.css +6 -0
- package/src/private/react.ts +49 -0
- package/src/private/shims.d.ts +6 -0
- package/src/private/ui/ChatDockRoot.vue +119 -0
- package/src/private/ui/LegalText.vue +18 -0
- package/src/private/ui/PrivateScreens.vue +61 -0
- package/src/private/ui/PrivateViewRoot.vue +70 -0
- package/src/private/ui/PromiseBlock.vue +18 -0
- package/src/private/ui/ProviderLine.vue +20 -0
- package/src/private/ui/ScreenActivation.vue +82 -0
- package/src/private/ui/ScreenAddress.vue +37 -0
- package/src/private/ui/ScreenApproval.vue +71 -0
- package/src/private/ui/ScreenDevices.vue +42 -0
- package/src/private/ui/ScreenHome.vue +29 -0
- package/src/private/ui/ScreenNotifications.vue +44 -0
- package/src/private/ui/ScreenReads.vue +23 -0
- package/src/private/ui/ScreenSettings.vue +44 -0
- package/src/private/ui/private.css +81 -0
- package/src/private/ui/root.ts +89 -0
- package/src/private/ui/text.ts +40 -0
- package/src/private/vue.ts +87 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* From the element's attributes to its page's controller (m4-contracts.md §6.4). kb-api's template names the page and,
|
|
3
|
+
* for `/zpravy`, the kb-api origin and the site's hand-off route — from configuration only; this file checks them once
|
|
4
|
+
* more (an https origin, an http(s) URL without query or fragment) and makes the controller. The capability comes from
|
|
5
|
+
* the fragment (fragment.ts), read once when the page starts.
|
|
6
|
+
*/
|
|
7
|
+
import { kbOriginOf } from '@blogmcp/sdk/community/private'
|
|
8
|
+
import { createAccountApi, type AccountApi } from './api'
|
|
9
|
+
import { takeCapability, type Capability, type FragmentWindow } from './fragment'
|
|
10
|
+
import { createActivationPage, createAddressPage, createDeviceApprovePage, createDevicesPage, createExportPage } from './pages'
|
|
11
|
+
import { createMessagesPage } from './provider-view'
|
|
12
|
+
import { findDeviceKey } from './proof'
|
|
13
|
+
|
|
14
|
+
export const ACCOUNT_PAGE_IDS = ['address', 'device-approve', 'devices', 'export', 'messages', 'activation-dispute', 'activation-end'] as const
|
|
15
|
+
export type AccountPageId = (typeof ACCOUNT_PAGE_IDS)[number]
|
|
16
|
+
|
|
17
|
+
export interface AccountPageInput {
|
|
18
|
+
page?: string | null
|
|
19
|
+
kbOrigin?: string | null
|
|
20
|
+
handoffUrl?: string | null
|
|
21
|
+
siteName?: string | null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** A hand-off route: an absolute http(s) URL without credentials, query or fragment; else null. */
|
|
25
|
+
export function handoffUrlOf(value: unknown): string | null {
|
|
26
|
+
if (typeof value !== 'string' || value === '') return null
|
|
27
|
+
try {
|
|
28
|
+
const url = new URL(value)
|
|
29
|
+
if ((url.protocol !== 'https:' && url.protocol !== 'http:') || url.username || url.password || url.search || url.hash) return null
|
|
30
|
+
return url.href
|
|
31
|
+
} catch {
|
|
32
|
+
return null
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type AccountPageSetup =
|
|
37
|
+
| { page: 'address'; controller: ReturnType<typeof createAddressPage> }
|
|
38
|
+
| { page: 'device-approve'; controller: ReturnType<typeof createDeviceApprovePage> }
|
|
39
|
+
| { page: 'devices'; controller: ReturnType<typeof createDevicesPage> }
|
|
40
|
+
| { page: 'export'; controller: ReturnType<typeof createExportPage> }
|
|
41
|
+
| { page: 'activation-dispute' | 'activation-end'; controller: ReturnType<typeof createActivationPage> }
|
|
42
|
+
| { page: 'messages'; controller: ReturnType<typeof createMessagesPage> }
|
|
43
|
+
|
|
44
|
+
export interface AccountPageDeps {
|
|
45
|
+
api?: AccountApi
|
|
46
|
+
/** The fragment's capability (default read from the page, once). */
|
|
47
|
+
capability?: Capability | null
|
|
48
|
+
window?: FragmentWindow
|
|
49
|
+
origin?: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The page's controller, or null for a page this bundle does not know or `/zpravy` without its configuration. */
|
|
53
|
+
export function accountPageSetup(input: AccountPageInput, deps: AccountPageDeps = {}): AccountPageSetup | null {
|
|
54
|
+
const page = (ACCOUNT_PAGE_IDS as readonly string[]).includes(input.page ?? '') ? (input.page as AccountPageId) : null
|
|
55
|
+
if (page === null) return null
|
|
56
|
+
if (page === 'messages') {
|
|
57
|
+
const kbOrigin = kbOriginOf(input.kbOrigin ?? null)
|
|
58
|
+
const handoffUrl = handoffUrlOf(input.handoffUrl)
|
|
59
|
+
if (kbOrigin === null || handoffUrl === null) return null
|
|
60
|
+
const siteName = typeof input.siteName === 'string' && input.siteName !== '' ? input.siteName : new URL(handoffUrl).hostname
|
|
61
|
+
return { page, controller: createMessagesPage({ kbOrigin, handoffUrl, siteName }) }
|
|
62
|
+
}
|
|
63
|
+
const api = deps.api ?? createAccountApi()
|
|
64
|
+
const capability = deps.capability !== undefined ? deps.capability : takeCapability(deps.window)
|
|
65
|
+
switch (page) {
|
|
66
|
+
case 'address':
|
|
67
|
+
return { page, controller: createAddressPage({ api, capability }) }
|
|
68
|
+
case 'device-approve':
|
|
69
|
+
return { page, controller: createDeviceApprovePage({ api, capability, origin: deps.origin ?? location.origin, findKey: (jkt) => findDeviceKey(jkt) }) }
|
|
70
|
+
case 'devices':
|
|
71
|
+
return { page, controller: createDevicesPage({ api, capability }) }
|
|
72
|
+
case 'export':
|
|
73
|
+
return { page, controller: createExportPage({ api, capability }) }
|
|
74
|
+
case 'activation-dispute':
|
|
75
|
+
return { page, controller: createActivationPage({ api, capability, act: 'dispute' }) }
|
|
76
|
+
case 'activation-end':
|
|
77
|
+
return { page, controller: createActivationPage({ api, capability, act: 'end' }) }
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* `<blogmcp-account-page>` (m4-contracts.md §6.4): one account page, chosen by the `page` attribute kb-api's template
|
|
4
|
+
* sets. Every page carries the title, the page itself, a live region for what it did, and the line saying who runs the
|
|
5
|
+
* page — blogmcp, not the website the member writes on.
|
|
6
|
+
*/
|
|
7
|
+
import { computed, onBeforeUnmount, onMounted, shallowRef } from 'vue'
|
|
8
|
+
import { documentLang, pickLang } from '../../../core/i18n'
|
|
9
|
+
import { accountText } from '../i18n'
|
|
10
|
+
import { accountPageSetup, type AccountPageSetup } from '../setup'
|
|
11
|
+
import PageActivation from './PageActivation.vue'
|
|
12
|
+
import PageAddress from './PageAddress.vue'
|
|
13
|
+
import PageDeviceApprove from './PageDeviceApprove.vue'
|
|
14
|
+
import PageDevices from './PageDevices.vue'
|
|
15
|
+
import PageExport from './PageExport.vue'
|
|
16
|
+
import PageMessages from './PageMessages.vue'
|
|
17
|
+
|
|
18
|
+
const props = defineProps<{ page?: string; kbOrigin?: string; handoffUrl?: string; siteName?: string; lang?: string }>()
|
|
19
|
+
const lang = computed(() => pickLang(props.lang, documentLang()))
|
|
20
|
+
const tx = computed(() => accountText(lang.value))
|
|
21
|
+
const setup = shallowRef<AccountPageSetup | null>(null)
|
|
22
|
+
|
|
23
|
+
onMounted(() => {
|
|
24
|
+
setup.value = accountPageSetup({ page: props.page, kbOrigin: props.kbOrigin, handoffUrl: props.handoffUrl, siteName: props.siteName })
|
|
25
|
+
const s = setup.value
|
|
26
|
+
if (s?.page === 'device-approve' || s?.page === 'devices' || s?.page === 'messages') void s.controller.load()
|
|
27
|
+
})
|
|
28
|
+
onBeforeUnmount(() => {
|
|
29
|
+
if (setup.value?.page === 'messages') setup.value.controller.dispose()
|
|
30
|
+
})
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<main class="bcm-a-root bcm-p-root" :data-page="setup?.page ?? 'none'">
|
|
35
|
+
<h1 class="bcm-a-title">{{ tx.at('account.title') }}</h1>
|
|
36
|
+
<p v-if="!setup" role="alert">{{ tx.at('account.noToken') }}</p>
|
|
37
|
+
<PageAddress v-else-if="setup.page === 'address'" :controller="setup.controller" :lang="lang" />
|
|
38
|
+
<PageDeviceApprove v-else-if="setup.page === 'device-approve'" :controller="setup.controller" :lang="lang" />
|
|
39
|
+
<PageDevices v-else-if="setup.page === 'devices'" :controller="setup.controller" :lang="lang" />
|
|
40
|
+
<PageExport v-else-if="setup.page === 'export'" :controller="setup.controller" :lang="lang" />
|
|
41
|
+
<PageActivation v-else-if="setup.page === 'activation-dispute' || setup.page === 'activation-end'" :controller="setup.controller" :act="setup.page === 'activation-dispute' ? 'dispute' : 'end'" :lang="lang" />
|
|
42
|
+
<PageMessages v-else-if="setup.page === 'messages'" :controller="setup.controller" :site-name="siteName ?? ''" :lang="lang" />
|
|
43
|
+
<footer class="bcm-a-footer bcm-p-muted">{{ tx.at('account.provider') }}</footer>
|
|
44
|
+
</main>
|
|
45
|
+
</template>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* `/aktivace/spor` and `/aktivace/konec`: what the step does, then its operation only after the page's second
|
|
4
|
+
* confirmation (pages.ts `createActivationPage`, PS4, B-58).
|
|
5
|
+
*/
|
|
6
|
+
import { computed } from 'vue'
|
|
7
|
+
import type { Lang } from '../i18n'
|
|
8
|
+
import { accountText } from '../i18n'
|
|
9
|
+
import type { createActivationPage } from '../pages'
|
|
10
|
+
|
|
11
|
+
const props = defineProps<{ controller: ReturnType<typeof createActivationPage>; act: 'dispute' | 'end'; lang: Lang }>()
|
|
12
|
+
const tx = computed(() => accountText(props.lang))
|
|
13
|
+
const s = computed(() => props.controller.state)
|
|
14
|
+
const keys = computed(() =>
|
|
15
|
+
props.act === 'dispute'
|
|
16
|
+
? { title: 'account.dispute.title', intro: 'account.dispute.intro', submit: 'account.dispute.submit' }
|
|
17
|
+
: { title: 'account.end.title', intro: 'account.end.intro', submit: 'account.end.submit' },
|
|
18
|
+
)
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<section class="bcm-a-page" :data-account-page="act === 'dispute' ? 'activation-dispute' : 'activation-end'">
|
|
23
|
+
<h2>{{ tx.at(keys.title) }}</h2>
|
|
24
|
+
<p v-if="s.phase === 'noToken'" role="alert">{{ tx.at('account.noToken') }}</p>
|
|
25
|
+
<template v-else-if="s.phase === 'ready'">
|
|
26
|
+
<p>{{ tx.at(keys.intro) }}</p>
|
|
27
|
+
<template v-if="s.armed">
|
|
28
|
+
<p class="bcm-p-warning" role="alert">{{ tx.at('account.confirmAgain') }}</p>
|
|
29
|
+
<div class="bcm-p-actions">
|
|
30
|
+
<button type="button" class="bcm-p-btn bcm-p-danger" :disabled="s.busy" data-action="confirm" @click="controller.confirm()">{{ tx.at(keys.submit) }}</button>
|
|
31
|
+
<button type="button" class="bcm-p-btn" :disabled="s.busy" data-action="cancel" @click="controller.cancel()">{{ tx.at('account.cancel') }}</button>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
<button v-else type="button" class="bcm-p-btn" data-action="arm" @click="controller.arm()">{{ tx.at('account.continue') }}</button>
|
|
35
|
+
</template>
|
|
36
|
+
<template v-else-if="s.phase === 'done'">
|
|
37
|
+
<p v-if="act === 'dispute'" role="status" data-result="disputed">{{ tx.at('account.dispute.done', { count: s.devicesRemoved ?? 0 }) }}</p>
|
|
38
|
+
<p v-else role="status" data-result="ended">{{ tx.at(s.kind === 'withdrawal' ? 'account.end.done.withdrawal' : 'account.end.done.termination') }}</p>
|
|
39
|
+
</template>
|
|
40
|
+
<p v-if="s.failure" class="bcm-p-error" role="alert">{{ tx.refusal(s.failure.code) }}</p>
|
|
41
|
+
</section>
|
|
42
|
+
</template>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/** `/adresa`: set, verify, or confirm the change of the approval address (pages.ts `createAddressPage`). */
|
|
3
|
+
import { computed, ref } from 'vue'
|
|
4
|
+
import type { Lang } from '../i18n'
|
|
5
|
+
import { accountText } from '../i18n'
|
|
6
|
+
import type { createAddressPage } from '../pages'
|
|
7
|
+
|
|
8
|
+
const props = defineProps<{ controller: ReturnType<typeof createAddressPage>; lang: Lang }>()
|
|
9
|
+
const tx = computed(() => accountText(props.lang))
|
|
10
|
+
const s = computed(() => props.controller.state)
|
|
11
|
+
const email = ref('')
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<section class="bcm-a-page" data-account-page="address">
|
|
16
|
+
<h2>{{ tx.at('account.address.title') }}</h2>
|
|
17
|
+
<p v-if="s.phase === 'noToken'" role="alert">{{ tx.at('account.noToken') }}</p>
|
|
18
|
+
<template v-else-if="s.phase === 'ready' && s.mode === 'set'">
|
|
19
|
+
<p>{{ tx.at('account.address.setIntro') }}</p>
|
|
20
|
+
<div class="bcm-p-row">
|
|
21
|
+
<input v-model="email" class="bcm-p-input" type="email" autocomplete="email" :aria-label="tx.at('account.address.emailLabel')" :placeholder="tx.at('account.address.emailLabel')" data-input="email" @keydown.enter.prevent="controller.submit(email)" />
|
|
22
|
+
<button type="button" class="bcm-p-btn bcm-p-primary" :disabled="s.busy || email.trim() === ''" data-action="set" @click="controller.submit(email)">{{ tx.at('account.address.submit') }}</button>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
<template v-else-if="s.phase === 'ready' && s.mode === 'verify'">
|
|
26
|
+
<p>{{ tx.at('account.address.verifyIntro') }}</p>
|
|
27
|
+
<button type="button" class="bcm-p-btn bcm-p-primary" :disabled="s.busy" data-action="verify" @click="controller.verify()">{{ tx.at('account.address.verify') }}</button>
|
|
28
|
+
</template>
|
|
29
|
+
<template v-else-if="s.phase === 'ready' && s.mode === 'confirm'">
|
|
30
|
+
<p>{{ tx.at('account.address.confirmIntro') }}</p>
|
|
31
|
+
<button type="button" class="bcm-p-btn bcm-p-primary" :disabled="s.busy" data-action="confirm" @click="controller.confirm()">{{ tx.at('account.address.confirm') }}</button>
|
|
32
|
+
</template>
|
|
33
|
+
<p v-else-if="s.phase === 'done' && s.sent" role="status" data-result="sent">{{ tx.at('account.address.sent', { email: s.sent.email, time: tx.when(s.sent.expiresAt) }) }}</p>
|
|
34
|
+
<p v-else-if="s.phase === 'done' && s.result === 'changed'" role="status" data-result="changed">{{ tx.at('account.address.changed') }}</p>
|
|
35
|
+
<p v-else-if="s.phase === 'done' && s.result === 'confirmed'" role="status" data-result="confirmed">{{ tx.at('account.address.confirmed') }}</p>
|
|
36
|
+
<p v-else-if="s.phase === 'done'" role="status" data-result="verified">{{ tx.at('account.address.verified') }}</p>
|
|
37
|
+
<p v-if="s.failure" class="bcm-p-error" role="alert">{{ tx.refusal(s.failure.code) }}</p>
|
|
38
|
+
</section>
|
|
39
|
+
</template>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* `/zarizeni`: the device that asks, shown before the button (label, website, time, network, the website's key), the
|
|
4
|
+
* network warning, and the approval bound as kb-api says — the new device's code under tenant rendering, the pending
|
|
5
|
+
* key's proof from this browser under `provider_page` (pages.ts `createDeviceApprovePage`). A key-bound proof carries
|
|
6
|
+
* this browser's clock and kb-api admits ±300 s, so a refused one may be a wrong clock: the page says so beside the
|
|
7
|
+
* refusal (the page has no server clock to correct it by).
|
|
8
|
+
*/
|
|
9
|
+
import { computed, ref } from 'vue'
|
|
10
|
+
import type { Lang } from '../i18n'
|
|
11
|
+
import { accountText } from '../i18n'
|
|
12
|
+
import type { createDeviceApprovePage } from '../pages'
|
|
13
|
+
|
|
14
|
+
const props = defineProps<{ controller: ReturnType<typeof createDeviceApprovePage>; lang: Lang }>()
|
|
15
|
+
const tx = computed(() => accountText(props.lang))
|
|
16
|
+
const s = computed(() => props.controller.state)
|
|
17
|
+
const v = computed(() => s.value.view)
|
|
18
|
+
const site = computed(() => {
|
|
19
|
+
const origin = v.value?.origin ?? ''
|
|
20
|
+
try {
|
|
21
|
+
return origin ? new URL(origin).hostname : ''
|
|
22
|
+
} catch {
|
|
23
|
+
return origin
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
const code = ref('')
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<section class="bcm-a-page" data-account-page="device-approve">
|
|
31
|
+
<h2>{{ tx.at('account.approve.title') }}</h2>
|
|
32
|
+
<p v-if="s.phase === 'noToken'" role="alert">{{ tx.at('account.noToken') }}</p>
|
|
33
|
+
<p v-else-if="s.phase === 'loading'" class="bcm-p-muted">{{ tx.at('account.loading') }}</p>
|
|
34
|
+
<template v-else-if="v && (s.phase === 'ready' || s.phase === 'approved')">
|
|
35
|
+
<p>{{ tx.at('account.approve.intro') }}</p>
|
|
36
|
+
<ul class="bcm-p-list" data-device>
|
|
37
|
+
<li>{{ tx.at('account.approve.device', { label: v.label }) }}</li>
|
|
38
|
+
<li v-if="v.origin">{{ tx.at('account.approve.origin', { origin: v.origin }) }}</li>
|
|
39
|
+
<li>{{ tx.at('account.approve.created', { time: tx.when(v.createdAt) }) }}</li>
|
|
40
|
+
<li v-if="v.ipPrefix">{{ tx.at('account.approve.network', { ip: v.ipPrefix }) }}</li>
|
|
41
|
+
<li v-if="v.mintKeyId">{{ tx.at('account.approve.mintKey', { key: v.mintKeyId }) }}</li>
|
|
42
|
+
</ul>
|
|
43
|
+
<p v-if="!v.sameNetwork" class="bcm-p-warning" role="alert" data-other-network>{{ tx.at('account.approve.otherNetwork') }}</p>
|
|
44
|
+
<p v-if="s.phase === 'approved'" role="status" data-result="approved">{{ tx.at('account.approve.approved') }}</p>
|
|
45
|
+
<template v-else-if="v.binding === 'code'">
|
|
46
|
+
<p class="bcm-p-note">{{ tx.at('account.approve.codeWhere', { site }) }}</p>
|
|
47
|
+
<div class="bcm-p-row">
|
|
48
|
+
<input v-model="code" class="bcm-p-input" autocomplete="one-time-code" inputmode="text" :aria-label="tx.at('account.approve.codeLabel')" :placeholder="tx.at('account.approve.codeLabel')" data-input="code" @keydown.enter.prevent="controller.approveWithCode(code)" />
|
|
49
|
+
<button type="button" class="bcm-p-btn bcm-p-primary" :disabled="s.busy || code.trim() === ''" data-action="approve-code" @click="controller.approveWithCode(code)">{{ tx.at('account.approve.submitCode') }}</button>
|
|
50
|
+
</div>
|
|
51
|
+
</template>
|
|
52
|
+
<template v-else-if="s.keyHere">
|
|
53
|
+
<p class="bcm-p-note">{{ tx.at('account.approve.keyIntro') }}</p>
|
|
54
|
+
<button type="button" class="bcm-p-btn bcm-p-primary" :disabled="s.busy" data-action="approve-key" @click="controller.approveWithKey()">{{ tx.at('account.approve.submitKey') }}</button>
|
|
55
|
+
</template>
|
|
56
|
+
<p v-else class="bcm-p-warning" role="alert" data-key-missing>{{ tx.at('account.approve.keyMissing') }}</p>
|
|
57
|
+
<p v-if="s.phase === 'ready'" class="bcm-p-muted">{{ tx.at('account.approve.expires', { time: tx.when(v.expiresAt) }) }}</p>
|
|
58
|
+
</template>
|
|
59
|
+
<p v-if="s.failure" class="bcm-p-error" role="alert">{{ tx.refusal(s.failure.code) }}</p>
|
|
60
|
+
<p v-if="s.failure?.code === 'APPROVAL_INVALID' && v?.binding === 'key'" class="bcm-p-note" data-clock-hint>{{ tx.at('account.approve.clockHint') }}</p>
|
|
61
|
+
</section>
|
|
62
|
+
</template>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* `/zarizeni/seznam`: the member's devices with the signals a stranger is recognised by, their sign-out (one or all,
|
|
4
|
+
* each after a second confirmation), the read log on request, and the change of the approval address
|
|
5
|
+
* (pages.ts `createDevicesPage`).
|
|
6
|
+
*/
|
|
7
|
+
import { computed, ref } from 'vue'
|
|
8
|
+
import type { Lang } from '../i18n'
|
|
9
|
+
import { accountText } from '../i18n'
|
|
10
|
+
import type { createDevicesPage } from '../pages'
|
|
11
|
+
|
|
12
|
+
const props = defineProps<{ controller: ReturnType<typeof createDevicesPage>; lang: Lang }>()
|
|
13
|
+
const tx = computed(() => accountText(props.lang))
|
|
14
|
+
const s = computed(() => props.controller.state)
|
|
15
|
+
const labels = computed(() => new Map((s.value.devices ?? []).map((d) => [d.id, d.label])))
|
|
16
|
+
const newEmail = ref('')
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<section class="bcm-a-page" data-account-page="devices">
|
|
21
|
+
<h2>{{ tx.at('account.devices.title') }}</h2>
|
|
22
|
+
<p v-if="s.phase === 'noToken'" role="alert">{{ tx.at('account.noToken') }}</p>
|
|
23
|
+
<p v-else-if="s.phase === 'loading'" class="bcm-p-muted">{{ tx.at('account.loading') }}</p>
|
|
24
|
+
<template v-else-if="s.phase === 'ready'">
|
|
25
|
+
<p>{{ tx.at('account.devices.intro') }}</p>
|
|
26
|
+
<p class="bcm-p-note">{{ tx.at('account.devices.hostStep') }}</p>
|
|
27
|
+
<p class="bcm-p-sr" role="status" aria-live="polite">
|
|
28
|
+
<span v-if="s.signedOut?.kind === 'one'">{{ tx.at('account.devices.signedOut') }}</span>
|
|
29
|
+
<span v-else-if="s.signedOut?.kind === 'all'">{{ tx.at('account.devices.signedOutAll', { count: s.signedOut.count }) }}</span>
|
|
30
|
+
</p>
|
|
31
|
+
<p v-if="s.devices && s.devices.length === 0">{{ tx.at('account.devices.empty') }}</p>
|
|
32
|
+
<ul v-else class="bcm-p-list">
|
|
33
|
+
<li v-for="d in s.devices ?? []" :key="d.id" :data-device="d.id">
|
|
34
|
+
<p>
|
|
35
|
+
<strong>{{ d.label }}</strong>
|
|
36
|
+
<span class="bcm-p-badge">{{ tx.at(`account.devices.state.${d.state}`) }}</span>
|
|
37
|
+
</p>
|
|
38
|
+
<p v-if="d.origin" class="bcm-p-muted">{{ tx.at('account.devices.origin', { origin: d.origin }) }}</p>
|
|
39
|
+
<p v-if="d.signIn.at" class="bcm-p-muted">{{ tx.at('account.devices.signedIn', { time: tx.when(d.signIn.at), ip: d.signIn.ipPrefix ?? '' }) }}</p>
|
|
40
|
+
<p class="bcm-p-muted">{{ tx.at('account.devices.lastSeen', { time: tx.when(d.lastSeenAt) }) }}</p>
|
|
41
|
+
<template v-if="s.armed?.kind === 'one' && s.armed.deviceId === d.id">
|
|
42
|
+
<p class="bcm-p-warning" role="alert">{{ tx.at('account.devices.signOutConfirm', { label: d.label }) }}</p>
|
|
43
|
+
<div class="bcm-p-actions">
|
|
44
|
+
<button type="button" class="bcm-p-btn bcm-p-danger" :disabled="s.busy" data-action="confirm-sign-out" @click="controller.confirmSignOut()">{{ tx.at('account.devices.signOut') }}</button>
|
|
45
|
+
<button type="button" class="bcm-p-btn" :disabled="s.busy" data-action="cancel" @click="controller.cancel()">{{ tx.at('account.cancel') }}</button>
|
|
46
|
+
</div>
|
|
47
|
+
</template>
|
|
48
|
+
<button v-else type="button" class="bcm-p-btn" :disabled="s.busy" data-action="sign-out" @click="controller.armSignOut(d)">{{ tx.at('account.devices.signOut') }}</button>
|
|
49
|
+
</li>
|
|
50
|
+
</ul>
|
|
51
|
+
<template v-if="s.devices && s.devices.length > 0">
|
|
52
|
+
<template v-if="s.armed?.kind === 'all'">
|
|
53
|
+
<p class="bcm-p-warning" role="alert">{{ tx.at('account.devices.signOutAllConfirm') }}</p>
|
|
54
|
+
<div class="bcm-p-actions">
|
|
55
|
+
<button type="button" class="bcm-p-btn bcm-p-danger" :disabled="s.busy" data-action="confirm-sign-out-all" @click="controller.confirmSignOut()">{{ tx.at('account.devices.signOutAll') }}</button>
|
|
56
|
+
<button type="button" class="bcm-p-btn" :disabled="s.busy" data-action="cancel" @click="controller.cancel()">{{ tx.at('account.cancel') }}</button>
|
|
57
|
+
</div>
|
|
58
|
+
</template>
|
|
59
|
+
<button v-else type="button" class="bcm-p-btn bcm-p-danger" :disabled="s.busy" data-action="sign-out-all" @click="controller.armSignOutAll()">{{ tx.at('account.devices.signOutAll') }}</button>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<h3>{{ tx.at('account.reads.title') }}</h3>
|
|
63
|
+
<p class="bcm-p-muted">{{ tx.at('account.reads.intro') }}</p>
|
|
64
|
+
<button v-if="s.reads === null" type="button" class="bcm-p-btn" :disabled="s.busy" data-action="reads" @click="controller.showReads()">{{ tx.at('account.reads.show') }}</button>
|
|
65
|
+
<p v-else-if="s.reads.length === 0">{{ tx.at('account.reads.empty') }}</p>
|
|
66
|
+
<ul v-else class="bcm-p-list" data-reads>
|
|
67
|
+
<li v-for="r in s.reads" :key="`${r.deviceId}:${r.hour}`">
|
|
68
|
+
{{ tx.at('account.reads.row', { time: tx.when(r.hour), label: labels.get(r.deviceId) ?? tx.at('account.reads.removedDevice'), count: r.reads }) }}
|
|
69
|
+
</li>
|
|
70
|
+
</ul>
|
|
71
|
+
|
|
72
|
+
<h3>{{ tx.at('account.change.title') }}</h3>
|
|
73
|
+
<p v-if="s.change" role="status" data-result="change-sent">{{ tx.at('account.change.sent', { time: tx.when(s.change.expiresAt) }) }}</p>
|
|
74
|
+
<template v-else>
|
|
75
|
+
<p class="bcm-p-muted">{{ tx.at('account.change.intro') }}</p>
|
|
76
|
+
<div class="bcm-p-row">
|
|
77
|
+
<input v-model="newEmail" class="bcm-p-input" type="email" autocomplete="email" :aria-label="tx.at('account.change.label')" :placeholder="tx.at('account.change.label')" data-input="new-email" />
|
|
78
|
+
<button type="button" class="bcm-p-btn" :disabled="s.busy || newEmail.trim() === ''" data-action="change" @click="controller.requestChange(newEmail)">{{ tx.at('account.change.submit') }}</button>
|
|
79
|
+
</div>
|
|
80
|
+
</template>
|
|
81
|
+
</template>
|
|
82
|
+
<p v-if="s.failure" class="bcm-p-error" role="alert">{{ tx.refusal(s.failure.code) }}</p>
|
|
83
|
+
</section>
|
|
84
|
+
</template>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/** `/export`: the confirmation, then the download on this origin (pages.ts `createExportPage`, B-3, DM7b). */
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
import type { Lang } from '../i18n'
|
|
5
|
+
import { accountText } from '../i18n'
|
|
6
|
+
import type { createExportPage } from '../pages'
|
|
7
|
+
|
|
8
|
+
const props = defineProps<{ controller: ReturnType<typeof createExportPage>; lang: Lang }>()
|
|
9
|
+
const tx = computed(() => accountText(props.lang))
|
|
10
|
+
const s = computed(() => props.controller.state)
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<section class="bcm-a-page" data-account-page="export">
|
|
15
|
+
<h2>{{ tx.at('account.export.title') }}</h2>
|
|
16
|
+
<p v-if="s.phase === 'noToken'" role="alert">{{ tx.at('account.noToken') }}</p>
|
|
17
|
+
<template v-else-if="s.phase === 'ready'">
|
|
18
|
+
<p>{{ tx.at('account.export.intro') }}</p>
|
|
19
|
+
<template v-if="s.armed">
|
|
20
|
+
<p class="bcm-p-warning" role="alert">{{ tx.at('account.confirmAgain') }}</p>
|
|
21
|
+
<div class="bcm-p-actions">
|
|
22
|
+
<button type="button" class="bcm-p-btn bcm-p-primary" :disabled="s.busy" data-action="confirm" @click="controller.confirm()">{{ tx.at('account.export.confirm') }}</button>
|
|
23
|
+
<button type="button" class="bcm-p-btn" :disabled="s.busy" data-action="cancel" @click="controller.cancel()">{{ tx.at('account.cancel') }}</button>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
<button v-else type="button" class="bcm-p-btn bcm-p-primary" data-action="arm" @click="controller.arm()">{{ tx.at('account.continue') }}</button>
|
|
27
|
+
</template>
|
|
28
|
+
<template v-else-if="s.phase === 'confirmed'">
|
|
29
|
+
<p role="status">{{ tx.at('account.export.ready') }}</p>
|
|
30
|
+
<button type="button" class="bcm-p-btn bcm-p-primary" :disabled="s.busy" data-action="download" @click="controller.download()">{{ tx.at('account.export.download') }}</button>
|
|
31
|
+
</template>
|
|
32
|
+
<p v-else-if="s.phase === 'downloaded'" role="status" data-result="downloaded">{{ tx.at('account.export.downloaded') }}</p>
|
|
33
|
+
<p v-if="s.failure" class="bcm-p-error" role="alert">{{ tx.refusal(s.failure.code) }}</p>
|
|
34
|
+
</section>
|
|
35
|
+
</template>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* `/zpravy` under `provider_page`: the hand-off's phases, then the private elements' screens over this origin's
|
|
4
|
+
* session (provider-view.ts `createMessagesPage`), with the live inbox the view runs (`data-realtime`).
|
|
5
|
+
*/
|
|
6
|
+
import { computed } from 'vue'
|
|
7
|
+
import PrivateScreens from '../../ui/PrivateScreens.vue'
|
|
8
|
+
import { screenText } from '../../ui/text'
|
|
9
|
+
import type { Lang } from '../i18n'
|
|
10
|
+
import { accountText } from '../i18n'
|
|
11
|
+
import type { createMessagesPage } from '../provider-view'
|
|
12
|
+
|
|
13
|
+
const props = defineProps<{ controller: ReturnType<typeof createMessagesPage>; siteName: string; lang: Lang }>()
|
|
14
|
+
const tx = computed(() => accountText(props.lang))
|
|
15
|
+
const ptx = computed(() => screenText(props.lang))
|
|
16
|
+
const s = computed(() => props.controller.state)
|
|
17
|
+
const view = computed(() => (s.value.phase === 'open' ? props.controller.view : null))
|
|
18
|
+
const viewPhase = computed(() => view.value?.state.phase ?? 'idle')
|
|
19
|
+
/** The live inbox's state (the view's `realtime`: off, connecting, live, ended), for the page's own checks. */
|
|
20
|
+
const live = computed(() => view.value?.state.realtime ?? 'off')
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<section class="bcm-a-page" data-account-page="messages" :data-phase="s.phase" :data-realtime="live">
|
|
25
|
+
<p v-if="s.phase === 'starting' || s.phase === 'redirecting'" class="bcm-p-muted">{{ tx.at('account.messages.opening', { site: siteName }) }}</p>
|
|
26
|
+
<template v-else-if="s.phase === 'signIn' || s.phase === 'invalid' || s.phase === 'failed'">
|
|
27
|
+
<p role="alert">{{ s.phase === 'signIn' ? tx.at('account.messages.signIn', { site: siteName }) : s.phase === 'invalid' ? tx.at('account.messages.invalid') : tx.refusal(s.code) }}</p>
|
|
28
|
+
<button type="button" class="bcm-p-btn bcm-p-primary" data-action="reopen" @click="controller.reopen()">{{ tx.at('account.messages.reopen') }}</button>
|
|
29
|
+
</template>
|
|
30
|
+
<template v-else-if="view">
|
|
31
|
+
<p v-if="viewPhase === 'loading' || viewPhase === 'idle'" class="bcm-p-muted">{{ ptx.pt('private.loading') }}</p>
|
|
32
|
+
<template v-else-if="viewPhase === 'failed' || viewPhase === 'signIn' || viewPhase === 'dark'">
|
|
33
|
+
<p role="alert">{{ ptx.refText(view.state.failure ?? { msg: 'private.failed' }) }}</p>
|
|
34
|
+
<button type="button" class="bcm-p-btn bcm-p-primary" data-action="reopen" @click="controller.reopen()">{{ tx.at('account.messages.reopen') }}</button>
|
|
35
|
+
</template>
|
|
36
|
+
<PrivateScreens v-else :controller="view" :lang="lang" />
|
|
37
|
+
</template>
|
|
38
|
+
</section>
|
|
39
|
+
</template>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/* The account pages' own rules, after the private elements' stylesheet (one <style> with the CSP nonce). */
|
|
2
|
+
:host { display: block; max-width: 40rem; margin: 2rem auto; padding: 0 1rem; font-family: system-ui, sans-serif; line-height: 1.5; color-scheme: light dark; }
|
|
3
|
+
.bcm-a-title { font-size: 1.4em; margin: 0 0 1em; }
|
|
4
|
+
.bcm-a-page h2 { font-size: 1.15em; margin: 0 0 0.5em; }
|
|
5
|
+
.bcm-a-page h3 { font-size: 1em; margin: 1.25em 0 0.25em; }
|
|
6
|
+
.bcm-a-footer { margin-top: 2.5em; border-top: 1px solid color-mix(in srgb, var(--bcm-p-muted) 35%, transparent); padding-top: 0.75em; }
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<KbChatDock>` and `<KbPrivateView>` for React (18 and 19, Next.js App Router included — this module is a client
|
|
3
|
+
* component): each mounts its element after hydration and removes it on unmount; each renders one empty `<div>` as the
|
|
4
|
+
* mount point. The element's module is imported lazily, so a server render never loads the browser-only private SDK.
|
|
5
|
+
* `hiddenByHost` toggles the dock's attribute in place and never remounts it.
|
|
6
|
+
*/
|
|
7
|
+
import { createElement, useEffect, useRef, type ReactElement } from 'react'
|
|
8
|
+
import type { MountChatDockOptions, MountPrivateViewOptions } from './mount'
|
|
9
|
+
|
|
10
|
+
export type KbChatDockProps = Omit<MountChatDockOptions, 'container'>
|
|
11
|
+
export type KbPrivateViewProps = Omit<MountPrivateViewOptions, 'container'>
|
|
12
|
+
|
|
13
|
+
const HIDDEN_BY_HOST = 'hidden-by-host'
|
|
14
|
+
/** The options that, changed, mount the element anew (functions by identity, and `inPlace` keys, left out). */
|
|
15
|
+
const keyOf = (props: object, inPlace: readonly string[]): string =>
|
|
16
|
+
JSON.stringify(props, (k, v: unknown) => (inPlace.includes(k) ? undefined : typeof v === 'function' ? '[fn]' : v))
|
|
17
|
+
|
|
18
|
+
function useMounted<P extends object>(kind: string, props: P, load: () => Promise<(o: P & { container: Element }) => () => void>, inPlace: readonly string[] = []) {
|
|
19
|
+
const host = useRef<HTMLDivElement>(null)
|
|
20
|
+
const latest = useRef(props)
|
|
21
|
+
latest.current = props
|
|
22
|
+
const key = keyOf(props, inPlace)
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
let unmount: (() => void) | null = null
|
|
25
|
+
let gone = false
|
|
26
|
+
void load().then((mount) => {
|
|
27
|
+
if (!gone && host.current) unmount = mount({ ...latest.current, container: host.current })
|
|
28
|
+
})
|
|
29
|
+
return () => {
|
|
30
|
+
gone = true
|
|
31
|
+
unmount?.()
|
|
32
|
+
}
|
|
33
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
+
}, [key])
|
|
35
|
+
return { host, element: createElement('div', { ref: host, 'data-blogmcp-community': kind }) }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function KbChatDock(props: KbChatDockProps): ReactElement {
|
|
39
|
+
// The mount reads the latest `hiddenByHost`; a later change toggles the attribute on the mounted element in place.
|
|
40
|
+
const { host, element } = useMounted('chat-dock', props, async () => (await import('./mount')).mountChatDock, ['hiddenByHost'])
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
host.current?.firstElementChild?.toggleAttribute(HIDDEN_BY_HOST, props.hiddenByHost === true)
|
|
43
|
+
}, [host, props.hiddenByHost])
|
|
44
|
+
return element
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function KbPrivateView(props: KbPrivateViewProps): ReactElement {
|
|
48
|
+
return useMounted('private-view', props, async () => (await import('./mount')).mountPrivateView).element
|
|
49
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// The private elements' catalogues are JSON (i18n.ts says why); a TypeScript consumer reading this package's sources
|
|
2
|
+
// sees each as a flat record of strings, as the build does.
|
|
3
|
+
declare module '*.json' {
|
|
4
|
+
const messages: Readonly<Record<string, string>>
|
|
5
|
+
export default messages
|
|
6
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* `<blogmcp-chat-dock>` (m4-contracts.md §6.2): the launcher with the private unread dot, the panel (the conversation
|
|
4
|
+
* list, DM8b's inbox, and the account's screens), and the windows (core/dock.ts) — a conversation or a screen each. It renders nothing for a
|
|
5
|
+
* visitor or on a dark instance — not even while the host's `me/get` is still loading: it appears only once a private
|
|
6
|
+
* block that is live or read_only was seen — and under `provider_page` only a launcher that is the link to the account
|
|
7
|
+
* host. The panel carries the provider line (§5.11), as every private screen does.
|
|
8
|
+
*
|
|
9
|
+
* `realtime` (a property): the SDK's `createPrivateRealtime` (or a source of the host's own, `{ subscribe(listener) }`),
|
|
10
|
+
* whose events are the inbox's content-free `{ k }` (§6.3). The dock's controller starts it once the view is ready and
|
|
11
|
+
* keeps it across client-side navigation and `hidden-by-host`; an account event refreshes the unread dot, `resync`
|
|
12
|
+
* reloads the view (core/view.ts). A refusal no retry cures (FINAL_REFUSALS) removes the launcher too.
|
|
13
|
+
*/
|
|
14
|
+
import { computed, onBeforeUnmount, watch } from 'vue'
|
|
15
|
+
import type { PrivateClient } from '@blogmcp/sdk/community/private'
|
|
16
|
+
import type { CommunityTransport } from '@blogmcp/sdk/community'
|
|
17
|
+
import { createDock, type PrivateDockRealtime } from '../core/dock'
|
|
18
|
+
import type { PrivatePushPort } from '../core/push'
|
|
19
|
+
import { isFinalFailure, type PrivateScreen } from '../core/view'
|
|
20
|
+
import PrivateScreens from './PrivateScreens.vue'
|
|
21
|
+
import ProviderLine from './ProviderLine.vue'
|
|
22
|
+
import DmInbox from '../dm/ui/DmInbox.vue'
|
|
23
|
+
import DmThread from '../dm/ui/DmThread.vue'
|
|
24
|
+
import { dmText } from '../dm/text'
|
|
25
|
+
import { httpsHref, screenText } from './text'
|
|
26
|
+
import { usePrivateRoot } from './root'
|
|
27
|
+
|
|
28
|
+
const props = defineProps<{
|
|
29
|
+
kbOrigin?: string
|
|
30
|
+
apiBase?: string
|
|
31
|
+
siteBase?: string
|
|
32
|
+
routes?: string
|
|
33
|
+
lang?: string
|
|
34
|
+
siteName?: string
|
|
35
|
+
swPath?: string
|
|
36
|
+
accountOrigin?: string
|
|
37
|
+
transport?: CommunityTransport
|
|
38
|
+
client?: PrivateClient
|
|
39
|
+
push?: PrivatePushPort | null
|
|
40
|
+
realtime?: PrivateDockRealtime
|
|
41
|
+
}>()
|
|
42
|
+
const { setup, lang } = usePrivateRoot(props)
|
|
43
|
+
const dock = createDock()
|
|
44
|
+
const tx = computed(() => screenText(lang.value))
|
|
45
|
+
const controller = computed(() => setup.value?.controller ?? null)
|
|
46
|
+
const phase = computed(() => controller.value?.state.phase ?? 'idle')
|
|
47
|
+
const unread = computed(() => controller.value?.state.unread ?? 0)
|
|
48
|
+
const accountUrl = computed(() => httpsHref(setup.value?.accountUrl ?? null))
|
|
49
|
+
const messagesPath = computed(() => setup.value?.routes.messagesPath ?? null)
|
|
50
|
+
/** A private block that is live or read_only and rendered here: until it is seen, the dock shows nothing at all. */
|
|
51
|
+
const admitted = computed(() => {
|
|
52
|
+
const b = controller.value?.state.block ?? null
|
|
53
|
+
return b !== null && (b.state === 'live' || b.state === 'read_only') && b.rendering !== 'provider_page'
|
|
54
|
+
})
|
|
55
|
+
// A reload (a `resync`, a forget) keeps the dock while it runs; a first load or a failure shows it only once admitted.
|
|
56
|
+
const final = computed(() => (controller.value ? isFinalFailure(controller.value.state) : false))
|
|
57
|
+
const shown = computed(() => phase.value === 'ready' || ((phase.value === 'loading' || (phase.value === 'failed' && !final.value)) && admitted.value))
|
|
58
|
+
const live = computed(() => controller.value?.state.realtime ?? 'off')
|
|
59
|
+
const entries: PrivateScreen[] = ['home', 'messages', 'notifications', 'devices', 'settings']
|
|
60
|
+
const titleKey = (screen: PrivateScreen): string => (screen === 'home' ? 'private.dock.account' : `private.menu.${screen}`)
|
|
61
|
+
const dm = computed(() => controller.value?.state.dm ?? null)
|
|
62
|
+
// A conversation window stays mounted while a ready view reloads (a `resync`): the view keeps its phase `ready` through
|
|
63
|
+
// the reload (core/view.ts `reloading`) and the DM controller lives on, so neither the window nor the panel flashes the
|
|
64
|
+
// loading placeholder, and an edit in progress survives. The controller is ended on every way out of the ready view,
|
|
65
|
+
// so `dm` is null wherever the conversations must go.
|
|
66
|
+
const threadsShown = computed(() => dm.value !== null && phase.value === 'ready')
|
|
67
|
+
const dmTx = computed(() => dmText(lang.value))
|
|
68
|
+
// The conversations ended (a sign-out, another member, a forgotten key) or were made anew: the windows of the ones
|
|
69
|
+
// before go, so nothing of the previous member's conversations stays on screen or waits to be filled.
|
|
70
|
+
watch(dm, (next, before) => {
|
|
71
|
+
if (before && next !== before) dock.closeConversations()
|
|
72
|
+
})
|
|
73
|
+
// The panel's list is read when the panel opens (and moved by the inbox events while it is open).
|
|
74
|
+
watch(
|
|
75
|
+
() => [dock.state.panelOpen, dm.value] as const,
|
|
76
|
+
([open, d]) => {
|
|
77
|
+
if (open && d) void d.loadInbox()
|
|
78
|
+
},
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
onBeforeUnmount(() => {
|
|
82
|
+
dock.dispose()
|
|
83
|
+
})
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
<template>
|
|
87
|
+
<div v-if="phase === 'link' && accountUrl" class="bcm-p-root bcm-p-dock">
|
|
88
|
+
<a class="bcm-p-launcher" :href="accountUrl" rel="noopener" :aria-label="tx.pt('private.dock.open')" data-launcher>{{ tx.pt('private.title') }}</a>
|
|
89
|
+
</div>
|
|
90
|
+
<div v-else-if="shown" class="bcm-p-root bcm-p-dock" :class="{ 'bcm-p-mobile': dock.state.mobile }" :data-phase="phase" :data-realtime="live">
|
|
91
|
+
<div class="bcm-p-windows" :aria-label="tx.pt('private.dock.windows')">
|
|
92
|
+
<section v-for="w in dock.state.windows" :key="w.id" class="bcm-p-window" :data-window="w.screen" :data-window-conversation="w.conversationId">
|
|
93
|
+
<header class="bcm-p-window-head">
|
|
94
|
+
<h2>{{ w.conversationId ? dmTx.who(dm?.state.counterparts[w.conversationId] ?? null) : tx.pt(titleKey(w.screen)) }}</h2>
|
|
95
|
+
<button type="button" class="bcm-p-icon" :aria-label="tx.pt('private.close')" data-action="close-window" @click="dock.closeWindow(w.id)">×</button>
|
|
96
|
+
</header>
|
|
97
|
+
<DmThread v-if="w.conversationId && dm && threadsShown" :dm="dm" :conversation-id="w.conversationId" :lang="lang" />
|
|
98
|
+
<PrivateScreens v-else-if="!w.conversationId && controller && phase === 'ready'" :controller="controller" :lang="lang" :screen="w.screen" :navigate="(s: PrivateScreen) => dock.openWindow(s)" :open-conversation="(c: string) => dock.openConversation(c)" />
|
|
99
|
+
</section>
|
|
100
|
+
</div>
|
|
101
|
+
<div v-if="dock.state.panelOpen" class="bcm-p-panel" data-panel>
|
|
102
|
+
<h2>{{ tx.pt('private.dock.conversations') }}</h2>
|
|
103
|
+
<DmInbox v-if="dm && phase === 'ready'" :dm="dm" :lang="lang" @open="(c: string) => dock.openConversation(c)" />
|
|
104
|
+
<p v-else class="bcm-p-muted">{{ tx.pt('private.dock.noConversations') }}</p>
|
|
105
|
+
<p v-if="phase === 'loading'" class="bcm-p-muted">{{ tx.pt('private.loading') }}</p>
|
|
106
|
+
<p v-else-if="phase === 'failed'" role="alert">{{ tx.refText(controller?.state.failure ?? null) }}</p>
|
|
107
|
+
<ul v-else class="bcm-p-menu">
|
|
108
|
+
<li v-for="e in entries" :key="e">
|
|
109
|
+
<button type="button" class="bcm-p-link" :data-open="e" @click="dock.openWindow(e)">{{ tx.pt(titleKey(e)) }}</button>
|
|
110
|
+
</li>
|
|
111
|
+
</ul>
|
|
112
|
+
<a v-if="messagesPath" :href="messagesPath" class="bcm-p-link" data-full-page>{{ tx.pt('private.dock.fullPage') }}</a>
|
|
113
|
+
<ProviderLine :provider="controller?.state.provider ?? null" :lang="lang" />
|
|
114
|
+
</div>
|
|
115
|
+
<button type="button" class="bcm-p-launcher" :aria-expanded="dock.state.panelOpen" :aria-label="tx.pt('private.dock.open')" data-launcher @click="dock.togglePanel()">
|
|
116
|
+
{{ tx.pt('private.title') }}<span v-if="unread > 0" class="bcm-p-dot" :aria-label="tx.pt('private.dock.unread')" data-unread-dot />
|
|
117
|
+
</button>
|
|
118
|
+
</div>
|
|
119
|
+
</template>
|