@stoa-dev/kit 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +80 -2
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useOnlineStatus/index.js +14 -0
- package/dist/hooks/useOnlineStatus/index.js.map +1 -0
- package/dist/hooks/useRouting/index.js +17 -0
- package/dist/hooks/useRouting/index.js.map +1 -0
- package/dist/i18n/index.js +30 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/locales/at.json.js +16 -0
- package/dist/i18n/locales/at.json.js.map +1 -0
- package/dist/i18n/locales/de.json.js +16 -0
- package/dist/i18n/locales/de.json.js.map +1 -0
- package/dist/i18n/locales/en.json.js +16 -0
- package/dist/i18n/locales/en.json.js.map +1 -0
- package/dist/i18n/locales/it.json.js +16 -0
- package/dist/i18n/locales/it.json.js.map +1 -0
- package/dist/i18n/namespace.js +5 -0
- package/dist/i18n/namespace.js.map +1 -0
- package/dist/kit.css +1 -0
- package/dist/licensing/LicenseActivation/index.js +101 -0
- package/dist/licensing/LicenseActivation/index.js.map +1 -0
- package/dist/licensing/LicenseCard/index.js +149 -0
- package/dist/licensing/LicenseCard/index.js.map +1 -0
- package/dist/licensing/LicenseGate/index.js +72 -0
- package/dist/licensing/LicenseGate/index.js.map +1 -0
- package/dist/licensing/LicenseProvider/index.js +137 -0
- package/dist/licensing/LicenseProvider/index.js.map +1 -0
- package/dist/licensing/LicenseStatusBanner/index.js +135 -0
- package/dist/licensing/LicenseStatusBanner/index.js.map +1 -0
- package/dist/licensing/api.js +57 -0
- package/dist/licensing/api.js.map +1 -0
- package/dist/licensing/index.js +23 -0
- package/dist/licensing/index.js.map +1 -0
- package/dist/shell/AppNavigation/AppNavigation.module.scss.js +16 -0
- package/dist/shell/AppNavigation/AppNavigation.module.scss.js.map +1 -0
- package/dist/shell/AppNavigation/index.js +136 -0
- package/dist/shell/AppNavigation/index.js.map +1 -0
- package/dist/shell/BackHomeButton/index.js +23 -0
- package/dist/shell/BackHomeButton/index.js.map +1 -0
- package/dist/shell/BrandLines/BrandLines.module.scss.js +10 -0
- package/dist/shell/BrandLines/BrandLines.module.scss.js.map +1 -0
- package/dist/shell/BrandLines/index.js +25 -0
- package/dist/shell/BrandLines/index.js.map +1 -0
- package/dist/shell/ConfirmDialog/index.js +53 -0
- package/dist/shell/ConfirmDialog/index.js.map +1 -0
- package/dist/shell/DatePicker/index.js +219 -0
- package/dist/shell/DatePicker/index.js.map +1 -0
- package/dist/shell/ErrorBoundary/index.js +29 -0
- package/dist/shell/ErrorBoundary/index.js.map +1 -0
- package/dist/shell/NativeSelect/index.js +24 -0
- package/dist/shell/NativeSelect/index.js.map +1 -0
- package/dist/shell/PageHeading/PageHeading.module.scss.js +8 -0
- package/dist/shell/PageHeading/PageHeading.module.scss.js.map +1 -0
- package/dist/shell/PageHeading/index.js +14 -0
- package/dist/shell/PageHeading/index.js.map +1 -0
- package/dist/shell/SectionNavigation/index.js +116 -0
- package/dist/shell/SectionNavigation/index.js.map +1 -0
- package/dist/shell/Spinner/index.js +16 -0
- package/dist/shell/Spinner/index.js.map +1 -0
- package/dist/shell/UploadButton/index.js +44 -0
- package/dist/shell/UploadButton/index.js.map +1 -0
- package/dist/shell/index.js +29 -0
- package/dist/shell/index.js.map +1 -0
- package/dist/types/hooks/index.d.ts +3 -0
- package/dist/types/hooks/index.d.ts.map +1 -0
- package/dist/types/hooks/useOnlineStatus/index.d.ts +2 -0
- package/dist/types/hooks/useOnlineStatus/index.d.ts.map +1 -0
- package/dist/types/hooks/useRouting/index.d.ts +14 -0
- package/dist/types/hooks/useRouting/index.d.ts.map +1 -0
- package/dist/types/i18n/index.d.ts +582 -0
- package/dist/types/i18n/index.d.ts.map +1 -0
- package/dist/types/i18n/namespace.d.ts +3 -0
- package/dist/types/i18n/namespace.d.ts.map +1 -0
- package/dist/types/licensing/LicenseActivation/index.d.ts +8 -0
- package/dist/types/licensing/LicenseActivation/index.d.ts.map +1 -0
- package/dist/types/licensing/LicenseCard/index.d.ts +2 -0
- package/dist/types/licensing/LicenseCard/index.d.ts.map +1 -0
- package/dist/types/licensing/LicenseGate/index.d.ts +11 -0
- package/dist/types/licensing/LicenseGate/index.d.ts.map +1 -0
- package/dist/types/licensing/LicenseProvider/index.d.ts +20 -0
- package/dist/types/licensing/LicenseProvider/index.d.ts.map +1 -0
- package/dist/types/licensing/LicenseStatusBanner/index.d.ts +4 -0
- package/dist/types/licensing/LicenseStatusBanner/index.d.ts.map +1 -0
- package/dist/types/licensing/api.d.ts +28 -0
- package/dist/types/licensing/api.d.ts.map +1 -0
- package/dist/types/licensing/index.d.ts +7 -0
- package/dist/types/licensing/index.d.ts.map +1 -0
- package/dist/types/shell/AppNavigation/index.d.ts +45 -0
- package/dist/types/shell/AppNavigation/index.d.ts.map +1 -0
- package/dist/types/shell/BackHomeButton/index.d.ts +7 -0
- package/dist/types/shell/BackHomeButton/index.d.ts.map +1 -0
- package/dist/types/shell/BrandLines/index.d.ts +6 -0
- package/dist/types/shell/BrandLines/index.d.ts.map +1 -0
- package/dist/types/shell/ConfirmDialog/index.d.ts +21 -0
- package/dist/types/shell/ConfirmDialog/index.d.ts.map +1 -0
- package/dist/types/shell/DatePicker/index.d.ts +14 -0
- package/dist/types/shell/DatePicker/index.d.ts.map +1 -0
- package/dist/types/shell/ErrorBoundary/index.d.ts +20 -0
- package/dist/types/shell/ErrorBoundary/index.d.ts.map +1 -0
- package/dist/types/shell/NativeSelect/index.d.ts +3 -0
- package/dist/types/shell/NativeSelect/index.d.ts.map +1 -0
- package/dist/types/shell/PageHeading/index.d.ts +9 -0
- package/dist/types/shell/PageHeading/index.d.ts.map +1 -0
- package/dist/types/shell/SectionNavigation/index.d.ts +12 -0
- package/dist/types/shell/SectionNavigation/index.d.ts.map +1 -0
- package/dist/types/shell/Spinner/index.d.ts +6 -0
- package/dist/types/shell/Spinner/index.d.ts.map +1 -0
- package/dist/types/shell/UploadButton/index.d.ts +6 -0
- package/dist/types/shell/UploadButton/index.d.ts.map +1 -0
- package/dist/types/shell/index.d.ts +12 -0
- package/dist/types/shell/index.d.ts.map +1 -0
- package/dist/types/ui/accordion/index.d.ts +8 -0
- package/dist/types/ui/accordion/index.d.ts.map +1 -0
- package/dist/types/ui/button/index.d.ts +11 -0
- package/dist/types/ui/button/index.d.ts.map +1 -0
- package/dist/types/ui/calendar/index.d.ts +11 -0
- package/dist/types/ui/calendar/index.d.ts.map +1 -0
- package/dist/types/ui/card/index.d.ts +12 -0
- package/dist/types/ui/card/index.d.ts.map +1 -0
- package/dist/types/ui/dialog/index.d.ts +18 -0
- package/dist/types/ui/dialog/index.d.ts.map +1 -0
- package/dist/types/ui/dropdown-menu/index.d.ts +30 -0
- package/dist/types/ui/dropdown-menu/index.d.ts.map +1 -0
- package/dist/types/ui/field/index.d.ts +25 -0
- package/dist/types/ui/field/index.d.ts.map +1 -0
- package/dist/types/ui/index.d.ts +21 -0
- package/dist/types/ui/index.d.ts.map +1 -0
- package/dist/types/ui/input/index.d.ts +4 -0
- package/dist/types/ui/input/index.d.ts.map +1 -0
- package/dist/types/ui/input-group/index.d.ts +17 -0
- package/dist/types/ui/input-group/index.d.ts.map +1 -0
- package/dist/types/ui/label/index.d.ts +5 -0
- package/dist/types/ui/label/index.d.ts.map +1 -0
- package/dist/types/ui/popover/index.d.ts +11 -0
- package/dist/types/ui/popover/index.d.ts.map +1 -0
- package/dist/types/ui/radio-group/index.d.ts +6 -0
- package/dist/types/ui/radio-group/index.d.ts.map +1 -0
- package/dist/types/ui/scroll-area/index.d.ts +6 -0
- package/dist/types/ui/scroll-area/index.d.ts.map +1 -0
- package/dist/types/ui/select/index.d.ts +16 -0
- package/dist/types/ui/select/index.d.ts.map +1 -0
- package/dist/types/ui/separator/index.d.ts +5 -0
- package/dist/types/ui/separator/index.d.ts.map +1 -0
- package/dist/types/ui/sonner/index.d.ts +4 -0
- package/dist/types/ui/sonner/index.d.ts.map +1 -0
- package/dist/types/ui/switch/index.d.ts +7 -0
- package/dist/types/ui/switch/index.d.ts.map +1 -0
- package/dist/types/ui/textarea/index.d.ts +4 -0
- package/dist/types/ui/textarea/index.d.ts.map +1 -0
- package/dist/types/ui/toggle/index.d.ts +10 -0
- package/dist/types/ui/toggle/index.d.ts.map +1 -0
- package/dist/types/ui/tooltip/index.d.ts +8 -0
- package/dist/types/ui/tooltip/index.d.ts.map +1 -0
- package/dist/types/utils/cn.d.ts +3 -0
- package/dist/types/utils/cn.d.ts.map +1 -0
- package/dist/types/utils/colors.d.ts +3 -0
- package/dist/types/utils/colors.d.ts.map +1 -0
- package/dist/types/utils/dates.d.ts +9 -0
- package/dist/types/utils/dates.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/ui/accordion/index.js +65 -0
- package/dist/ui/accordion/index.js.map +1 -0
- package/dist/ui/button/index.js +57 -0
- package/dist/ui/button/index.js.map +1 -0
- package/dist/ui/calendar/index.js +179 -0
- package/dist/ui/calendar/index.js.map +1 -0
- package/dist/ui/card/index.js +102 -0
- package/dist/ui/card/index.js.map +1 -0
- package/dist/ui/dialog/index.js +158 -0
- package/dist/ui/dialog/index.js.map +1 -0
- package/dist/ui/dropdown-menu/index.js +252 -0
- package/dist/ui/dropdown-menu/index.js.map +1 -0
- package/dist/ui/field/index.js +209 -0
- package/dist/ui/field/index.js.map +1 -0
- package/dist/ui/index.js +112 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/input/index.js +20 -0
- package/dist/ui/input/index.js.map +1 -0
- package/dist/ui/input-group/index.js +143 -0
- package/dist/ui/input-group/index.js.map +1 -0
- package/dist/ui/label/index.js +23 -0
- package/dist/ui/label/index.js.map +1 -0
- package/dist/ui/popover/index.js +81 -0
- package/dist/ui/popover/index.js.map +1 -0
- package/dist/ui/radio-group/index.js +45 -0
- package/dist/ui/radio-group/index.js.map +1 -0
- package/dist/ui/scroll-area/index.js +60 -0
- package/dist/ui/scroll-area/index.js.map +1 -0
- package/dist/ui/select/index.js +182 -0
- package/dist/ui/select/index.js.map +1 -0
- package/dist/ui/separator/index.js +27 -0
- package/dist/ui/separator/index.js.map +1 -0
- package/dist/ui/sonner/index.js +37 -0
- package/dist/ui/sonner/index.js.map +1 -0
- package/dist/ui/switch/index.js +32 -0
- package/dist/ui/switch/index.js.map +1 -0
- package/dist/ui/textarea/index.js +19 -0
- package/dist/ui/textarea/index.js.map +1 -0
- package/dist/ui/toggle/index.js +44 -0
- package/dist/ui/toggle/index.js.map +1 -0
- package/dist/ui/tooltip/index.js +56 -0
- package/dist/ui/tooltip/index.js.map +1 -0
- package/dist/utils/cn.js +9 -0
- package/dist/utils/cn.js.map +1 -0
- package/dist/utils/colors.js +8 -0
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/dates.js +28 -0
- package/dist/utils/dates.js.map +1 -0
- package/dist/utils/index.js +12 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +112 -4
- package/scss/_index.scss +4 -0
- package/scss/_tools.scss +21 -0
- package/styles/theme.css +192 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/licensing/LicenseCard/index.tsx"],"sourcesContent":["import { ChevronRight, RefreshCw, ShieldAlert, ShieldCheck } from 'lucide-react'\nimport { useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { STOA_NS } from '../../i18n/namespace'\nimport { Button } from '../../ui/button'\nimport { Card, CardContent, CardHeader, CardTitle } from '../../ui/card'\nimport type { LicenseStatus } from '../api'\nimport { useLicense } from '../LicenseProvider'\n\nconst statusStyles: Record<LicenseStatus, string> = {\n\tactive:\n\t\t'border-emerald-500/30 bg-emerald-500/10 text-emerald-800 dark:text-emerald-300',\n\toffline_grace:\n\t\t'border-sky-500/30 bg-sky-500/10 text-sky-800 dark:text-sky-300',\n\texpired:\n\t\t'border-amber-500/30 bg-amber-500/10 text-amber-800 dark:text-amber-300',\n\trevoked: 'border-red-500/30 bg-red-500/10 text-red-800 dark:text-red-300',\n\tlicense_revoked:\n\t\t'border-red-500/30 bg-red-500/10 text-red-800 dark:text-red-300',\n\tunactivated: 'border-border bg-muted/30 text-muted-foreground',\n\tactivation_required:\n\t\t'border-amber-500/30 bg-amber-500/10 text-amber-800 dark:text-amber-300',\n\tinvalid: 'border-red-500/30 bg-red-500/10 text-red-800 dark:text-red-300',\n}\n\nexport function LicenseCard() {\n\tconst { license, loading, refreshing, refresh, error } = useLicense()\n\tconst { t, i18n } = useTranslation(STOA_NS)\n\tconst [synchronized, setSynchronized] = useState(false)\n\tconst status = license?.status ?? 'invalid'\n\tconst locallyValid = status === 'active' || status === 'offline_grace'\n\tconst StatusIcon = locallyValid ? ShieldCheck : ShieldAlert\n\n\tfunction formatDate(timestamp: number | null | undefined) {\n\t\tif (timestamp == null || !Number.isFinite(timestamp))\n\t\t\treturn t('licenseProfile.unknown')\n\t\tconst date = new Date(timestamp * 1000)\n\t\tif (!Number.isFinite(date.getTime())) return t('licenseProfile.unknown')\n\t\treturn new Intl.DateTimeFormat(i18n.resolvedLanguage || 'de', {\n\t\t\tdateStyle: 'medium',\n\t\t\ttimeStyle: 'short',\n\t\t}).format(date)\n\t}\n\n\tasync function synchronize() {\n\t\tsetSynchronized(false)\n\t\ttry {\n\t\t\tawait refresh()\n\t\t\tsetSynchronized(true)\n\t\t} catch {\n\t\t\t// The shared provider exposes the error and keeps Rust's current license state.\n\t\t}\n\t}\n\n\tconst nextSync = license?.nextSyncAt\n\tconst certificateExpiry = license?.certificateExpiresAt ?? license?.expiresAt\n\n\treturn (\n\t\t<Card\n\t\t\tclassName='mb-4'\n\t\t\trole='region'\n\t\t\taria-labelledby='profile-license-title'\n\t\t>\n\t\t\t<CardHeader>\n\t\t\t\t<div className='flex flex-wrap items-center justify-between gap-3'>\n\t\t\t\t\t<CardTitle id='profile-license-title'>\n\t\t\t\t\t\t{t('licenseProfile.title')}\n\t\t\t\t\t</CardTitle>\n\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={`inline-flex items-center gap-2 rounded-full border px-3 py-1 text-xs font-medium ${statusStyles[status]}`}\n\t\t\t\t\t>\n\t\t\t\t\t\t<StatusIcon className='size-4' aria-hidden='true' />\n\t\t\t\t\t\t{loading\n\t\t\t\t\t\t\t? t('licenseProfile.checking')\n\t\t\t\t\t\t\t: t(`licenseProfile.status.${status}.label`)}\n\t\t\t\t\t</span>\n\t\t\t\t</div>\n\t\t\t</CardHeader>\n\n\t\t\t<CardContent className='grid gap-5'>\n\t\t\t\t<p className='text-xs text-muted-foreground'>\n\t\t\t\t\t{loading\n\t\t\t\t\t\t? t('licenseProfile.checking')\n\t\t\t\t\t\t: t(`licenseProfile.status.${status}.description`)}\n\t\t\t\t</p>\n\n\t\t\t\t<dl className='grid gap-4 sm:grid-cols-2'>\n\t\t\t\t\t<div className='min-w-0 space-y-1'>\n\t\t\t\t\t\t<dt className='text-xs text-muted-foreground'>\n\t\t\t\t\t\t\t{t('licenseProfile.plan')}\n\t\t\t\t\t\t</dt>\n\t\t\t\t\t\t<dd className='wrap-break-word font-medium'>\n\t\t\t\t\t\t\t{license?.plan\n\t\t\t\t\t\t\t\t? t(`licenseProfile.plans.${license.plan}`, {\n\t\t\t\t\t\t\t\t\t\tdefaultValue: license.plan,\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t: t('licenseProfile.unknown')}\n\t\t\t\t\t\t</dd>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div className='min-w-0 space-y-1'>\n\t\t\t\t\t\t<dt className='text-xs text-muted-foreground'>\n\t\t\t\t\t\t\t{t('licenseProfile.licenseTerm')}\n\t\t\t\t\t\t</dt>\n\t\t\t\t\t\t<dd>{t('licenseProfile.termUnknown')}</dd>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div className='min-w-0 space-y-1'>\n\t\t\t\t\t\t<dt className='text-xs text-muted-foreground'>\n\t\t\t\t\t\t\t{t('licenseProfile.certificateExpires')}\n\t\t\t\t\t\t</dt>\n\t\t\t\t\t\t<dd>{formatDate(certificateExpiry)}</dd>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div className='min-w-0 space-y-1'>\n\t\t\t\t\t\t<dt className='text-xs text-muted-foreground'>\n\t\t\t\t\t\t\t{t('licenseProfile.nextSync')}\n\t\t\t\t\t\t</dt>\n\n\t\t\t\t\t\t<dd>\n\t\t\t\t\t\t\t{nextSync != null\n\t\t\t\t\t\t\t\t? nextSync <= Date.now() / 1000\n\t\t\t\t\t\t\t\t\t? t('licenseProfile.syncDue', {\n\t\t\t\t\t\t\t\t\t\t\tdate: formatDate(nextSync),\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t: formatDate(nextSync)\n\t\t\t\t\t\t\t\t: t('licenseProfile.noSyncScheduled')}\n\t\t\t\t\t\t</dd>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div className='space-y-2 sm:col-span-2'>\n\t\t\t\t\t\t<dt className='text-xs text-muted-foreground'>\n\t\t\t\t\t\t\t{t('licenseProfile.features')}\n\t\t\t\t\t\t</dt>\n\n\t\t\t\t\t\t<dd>\n\t\t\t\t\t\t\t{license?.features.length ? (\n\t\t\t\t\t\t\t\t<ul className='flex flex-wrap gap-2'>\n\t\t\t\t\t\t\t\t\t{[...new Set(license.features)].map((feature) => (\n\t\t\t\t\t\t\t\t\t\t<li\n\t\t\t\t\t\t\t\t\t\t\tkey={feature}\n\t\t\t\t\t\t\t\t\t\t\tclassName='max-w-full break-all rounded-md border px-2 py-1 text-xs'\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{t(`licenseProfile.featureLabels.${feature}`, {\n\t\t\t\t\t\t\t\t\t\t\t\tdefaultValue: feature,\n\t\t\t\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\tt('licenseProfile.noFeatures')\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</dd>\n\t\t\t\t\t</div>\n\t\t\t\t</dl>\n\n\t\t\t\t<p className='rounded-lg bg-muted/30 p-3 text-xs text-muted-foreground'>\n\t\t\t\t\t{t('licenseProfile.validityHint')}\n\t\t\t\t</p>\n\n\t\t\t\t<div className='flex flex-wrap items-center gap-3'>\n\t\t\t\t\t<Button\n\t\t\t\t\t\ttype='button'\n\t\t\t\t\t\tvariant='outline'\n\t\t\t\t\t\tdisabled={\n\t\t\t\t\t\t\tloading || refreshing || !license || status === 'unactivated'\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClick={() => void synchronize()}\n\t\t\t\t\t>\n\t\t\t\t\t\t<RefreshCw\n\t\t\t\t\t\t\taria-hidden='true'\n\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\trefreshing\n\t\t\t\t\t\t\t\t\t? 'animate-spin motion-reduce:animate-none'\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{t(\n\t\t\t\t\t\t\trefreshing\n\t\t\t\t\t\t\t\t? 'licenseProfile.syncing'\n\t\t\t\t\t\t\t\t: 'licenseProfile.synchronize',\n\t\t\t\t\t\t)}\n\t\t\t\t\t</Button>\n\t\t\t\t\t{synchronized && !error && (\n\t\t\t\t\t\t<p role='status' className='text-xs text-muted-foreground'>\n\t\t\t\t\t\t\t{t('licenseProfile.synchronized')}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\n\t\t\t\t{error && (\n\t\t\t\t\t<p role='alert' className='wrap-break-word text-sm text-destructive'>\n\t\t\t\t\t\t{error}\n\t\t\t\t\t</p>\n\t\t\t\t)}\n\t\t\t\t{license?.persistencePending && (\n\t\t\t\t\t<p role='alert' className='text-sm text-destructive'>\n\t\t\t\t\t\t{t('licenseProfile.persistencePending')}\n\t\t\t\t\t</p>\n\t\t\t\t)}\n\n\t\t\t\t<details className='group mt-1 border-t pt-5'>\n\t\t\t\t\t<summary className='flex w-fit cursor-pointer list-none items-center gap-2 rounded-sm text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden'>\n\t\t\t\t\t\t<ChevronRight\n\t\t\t\t\t\t\taria-hidden='true'\n\t\t\t\t\t\t\tclassName='size-4 transition-transform group-open:rotate-90 motion-reduce:transition-none'\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{t('licenseProfile.deviceDetails')}\n\t\t\t\t\t</summary>\n\n\t\t\t\t\t<div className='mt-3 grid gap-3'>\n\t\t\t\t\t\t<p className='text-xs text-muted-foreground'>\n\t\t\t\t\t\t\t{t('licenseProfile.deviceId')}\n\t\t\t\t\t\t</p>\n\n\t\t\t\t\t\t<code className='block select-all break-all rounded-md bg-muted/30 p-3 text-xs'>\n\t\t\t\t\t\t\t{license?.deviceId ?? t('licenseProfile.noDevice')}\n\t\t\t\t\t\t</code>\n\n\t\t\t\t\t\t<p className='text-xs text-muted-foreground'>\n\t\t\t\t\t\t\t{t('licenseProfile.deviceReleaseHint')}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t</details>\n\t\t\t</CardContent>\n\t\t</Card>\n\t)\n}\n"],"names":["statusStyles","LicenseCard","license","loading","refreshing","refresh","error","useLicense","t","i18n","useTranslation","STOA_NS","synchronized","setSynchronized","useState","status","StatusIcon","ShieldCheck","ShieldAlert","formatDate","timestamp","date","synchronize","nextSync","certificateExpiry","jsxs","Card","jsx","CardHeader","CardTitle","CardContent","feature","Button","RefreshCw","ChevronRight"],"mappings":";;;;;;;;AASA,MAAMA,IAA8C;AAAA,EACnD,QACC;AAAA,EACD,eACC;AAAA,EACD,SACC;AAAA,EACD,SAAS;AAAA,EACT,iBACC;AAAA,EACD,aAAa;AAAA,EACb,qBACC;AAAA,EAC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;AAAA,EAAA;AAGH;"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as t, Fragment as v, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import { useState as A, useEffect as k } from "react";
|
|
3
|
+
import { useTranslation as y } from "react-i18next";
|
|
4
|
+
import { STOA_NS as w } from "../../i18n/namespace.js";
|
|
5
|
+
import { Button as l } from "../../ui/button/index.js";
|
|
6
|
+
import { LicenseActivation as g } from "../LicenseActivation/index.js";
|
|
7
|
+
import { useLicense as N } from "../LicenseProvider/index.js";
|
|
8
|
+
function _({
|
|
9
|
+
children: o,
|
|
10
|
+
onInteractionRequired: d
|
|
11
|
+
}) {
|
|
12
|
+
const { t: i } = y(w), { license: e, enabled: n, loading: c, reload: a, refresh: p, refreshing: r, error: m } = N(), [x, u] = A(
|
|
13
|
+
null
|
|
14
|
+
), f = e ? `${e.status}:${e.deviceId}` : "", s = (e?.status === "activation_required" || e?.status === "invalid" && e.deviceId !== null) && x !== f;
|
|
15
|
+
return k(() => {
|
|
16
|
+
!c && n && (!e || e.status === "unactivated" || s) && d?.();
|
|
17
|
+
}, [c, n, e, s, d]), c ? null : n ? e ? e.status === "unactivated" ? /* @__PURE__ */ t(g, { onActivated: () => {
|
|
18
|
+
a().catch(() => {
|
|
19
|
+
});
|
|
20
|
+
} }) : s ? /* @__PURE__ */ h("main", { className: "app-shell flex min-h-screen flex-col items-center justify-center p-6", children: [
|
|
21
|
+
/* @__PURE__ */ t(
|
|
22
|
+
"p",
|
|
23
|
+
{
|
|
24
|
+
role: "status",
|
|
25
|
+
className: "max-w-md text-center text-sm text-muted-foreground",
|
|
26
|
+
children: i("licensing.gate.activationRequired")
|
|
27
|
+
}
|
|
28
|
+
),
|
|
29
|
+
/* @__PURE__ */ t("div", { className: "w-full max-w-md py-8", children: /* @__PURE__ */ t(
|
|
30
|
+
g,
|
|
31
|
+
{
|
|
32
|
+
replacement: !0,
|
|
33
|
+
onActivated: () => {
|
|
34
|
+
u(null), a().catch(() => {
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
) }),
|
|
39
|
+
m && /* @__PURE__ */ t("p", { role: "alert", className: "max-w-md text-center text-sm", children: m }),
|
|
40
|
+
/* @__PURE__ */ t(
|
|
41
|
+
l,
|
|
42
|
+
{
|
|
43
|
+
variant: "outline",
|
|
44
|
+
disabled: r,
|
|
45
|
+
onClick: () => {
|
|
46
|
+
p().catch(() => {
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
children: i(r ? "licensing.checking" : "licensing.checkAgain")
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
/* @__PURE__ */ t(
|
|
53
|
+
l,
|
|
54
|
+
{
|
|
55
|
+
variant: "ghost",
|
|
56
|
+
disabled: r,
|
|
57
|
+
onClick: () => u(f),
|
|
58
|
+
children: i("licensing.gate.readOnly")
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
] }) : /* @__PURE__ */ t(v, { children: o }) : /* @__PURE__ */ h("div", { children: [
|
|
62
|
+
i("licensing.gate.failed"),
|
|
63
|
+
/* @__PURE__ */ t(l, { onClick: () => {
|
|
64
|
+
a().catch(() => {
|
|
65
|
+
});
|
|
66
|
+
}, children: i("licensing.checkAgain") })
|
|
67
|
+
] }) : /* @__PURE__ */ t(v, { children: o });
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
_ as LicenseGate
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/licensing/LicenseGate/index.tsx"],"sourcesContent":["import { type ReactNode, useEffect, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { STOA_NS } from '../../i18n/namespace'\nimport { Button } from '../../ui/button'\nimport { LicenseActivation } from '../LicenseActivation'\nimport { useLicense } from '../LicenseProvider'\n\nexport interface LicenseGateProps {\n\tchildren: ReactNode\n\t/**\n\t * Called when the gate needs direct user input (activation / failure screen),\n\t * e.g. to dismiss a startup overlay. Pass a stable callback.\n\t */\n\tonInteractionRequired?: () => void\n}\n\nexport function LicenseGate({\n\tchildren,\n\tonInteractionRequired,\n}: LicenseGateProps) {\n\tconst { t } = useTranslation(STOA_NS)\n\tconst { license, enabled, loading, reload, refresh, refreshing, error } =\n\t\tuseLicense()\n\tconst [readOnlyActivation, setReadOnlyActivation] = useState<string | null>(\n\t\tnull,\n\t)\n\tconst activationIdentity = license\n\t\t? `${license.status}:${license.deviceId}`\n\t\t: ''\n\tconst needsActivation =\n\t\tlicense?.status === 'activation_required' ||\n\t\t(license?.status === 'invalid' && license.deviceId !== null)\n\tconst showActivation =\n\t\tneedsActivation && readOnlyActivation !== activationIdentity\n\n\tuseEffect(() => {\n\t\t// Activation and failure screens need immediate user input, not a loading overlay.\n\t\tif (\n\t\t\t!loading &&\n\t\t\tenabled &&\n\t\t\t(!license || license.status === 'unactivated' || showActivation)\n\t\t) {\n\t\t\tonInteractionRequired?.()\n\t\t}\n\t}, [loading, enabled, license, showActivation, onInteractionRequired])\n\n\tif (loading) {\n\t\treturn null\n\t}\n\n\tif (!enabled) return <>{children}</>\n\n\tif (!license) {\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t{t('licensing.gate.failed')}\n\t\t\t\t<Button onClick={() => void reload().catch(() => {})}>\n\t\t\t\t\t{t('licensing.checkAgain')}\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t)\n\t}\n\n\tif (license.status === 'unactivated') {\n\t\treturn (\n\t\t\t<LicenseActivation onActivated={() => void reload().catch(() => {})} />\n\t\t)\n\t}\n\n\tif (showActivation) {\n\t\treturn (\n\t\t\t<main className='app-shell flex min-h-screen flex-col items-center justify-center p-6'>\n\t\t\t\t<p\n\t\t\t\t\trole='status'\n\t\t\t\t\tclassName='max-w-md text-center text-sm text-muted-foreground'\n\t\t\t\t>\n\t\t\t\t\t{t('licensing.gate.activationRequired')}\n\t\t\t\t</p>\n\t\t\t\t<div className='w-full max-w-md py-8'>\n\t\t\t\t\t<LicenseActivation\n\t\t\t\t\t\treplacement\n\t\t\t\t\t\tonActivated={() => {\n\t\t\t\t\t\t\tsetReadOnlyActivation(null)\n\t\t\t\t\t\t\tvoid reload().catch(() => {})\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t{error && (\n\t\t\t\t\t<p role='alert' className='max-w-md text-center text-sm'>\n\t\t\t\t\t\t{error}\n\t\t\t\t\t</p>\n\t\t\t\t)}\n\t\t\t\t<Button\n\t\t\t\t\tvariant='outline'\n\t\t\t\t\tdisabled={refreshing}\n\t\t\t\t\tonClick={() => void refresh().catch(() => {})}\n\t\t\t\t>\n\t\t\t\t\t{t(refreshing ? 'licensing.checking' : 'licensing.checkAgain')}\n\t\t\t\t</Button>\n\t\t\t\t<Button\n\t\t\t\t\tvariant='ghost'\n\t\t\t\t\tdisabled={refreshing}\n\t\t\t\t\tonClick={() => setReadOnlyActivation(activationIdentity)}\n\t\t\t\t>\n\t\t\t\t\t{t('licensing.gate.readOnly')}\n\t\t\t\t</Button>\n\t\t\t</main>\n\t\t)\n\t}\n\n\treturn <>{children}</>\n}\n"],"names":["LicenseGate","children","onInteractionRequired","t","useTranslation","STOA_NS","license","enabled","loading","reload","refresh","refreshing","error","useLicense","readOnlyActivation","setReadOnlyActivation","useState","activationIdentity","showActivation","useEffect","jsx","LicenseActivation","jsxs","Button","Fragment"],"mappings":";;;;;;;AAgBO,SAASA,EAAY;AAAA,EAC3B,UAAAC;AAAA,EACA,uBAAAC;AACD,GAAqB;AACpB,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAeC,CAAO,GAC9B,EAAE,SAAAC,GAAS,SAAAC,GAAS,SAAAC,GAAS,QAAAC,GAAQ,SAAAC,GAAS,YAAAC,GAAY,OAAAC,EAAA,IAC/DC,EAAA,GACK,CAACC,GAAoBC,CAAqB,IAAIC;AAAA,IACnD;AAAA,EAAA,GAEKC,IAAqBX,IACxB,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,IAE9D,gBAAAS;AAAA,MAACG;AAAA,MAAA;AAAA,QACA,SAAQ;AAAA,QACR,UAAUZ;AAAA,QACV,SAAS,MAAMI,EAAsBE,CAAkB;AAAA,QAEtD,YAAE,yBAAyB;AAAA,MAAA;AAAA,IAAA;AAAA,EAC7B,GACD,2BAIQ,UAAAhB,GAAS,sBAxDhB,OAAA,EACC,UAAA;AAAA,IAAAE,EAAE,uBAAuB;AAAA,IAC1B,gBAAAiB,EAACG,KAAO,SAAS,MAAA;AAAM,MAAKd,EAAA,EAAS,MAAM,MAAM;AAAA,MAAC,CAAC;AAAA,OACjD,UAAAN,EAAE,sBAAsB,EAAA,CAC1B;AAAA,EAAA,GACD,IATmB,gBAAAiB,EAAAI,GAAA,EAAG,UAAAvB,EAAA,CAAS;AA6DlC;"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { jsx as M } from "react/jsx-runtime";
|
|
2
|
+
import { useState as f, useRef as v, useCallback as p, useEffect as N, useContext as O, createContext as W } from "react";
|
|
3
|
+
import { useTranslation as q } from "react-i18next";
|
|
4
|
+
import { STOA_NS as z } from "../../i18n/namespace.js";
|
|
5
|
+
import { licenseErrorMessage as B, getLicenseConfig as D, refreshLicense as G, changeLicense as H, getLicenseStatus as E, allowsLicenseFeature as J } from "../api.js";
|
|
6
|
+
const S = W(null);
|
|
7
|
+
function Y({ children: d }) {
|
|
8
|
+
const [h, c] = f(null), [y, A] = f(!0), [L, C] = f(!0), w = v(null), [b, g] = f(!1), [x, i] = f(null), { t: P } = q(z), R = x === null ? null : B(x, P), e = v(!1), s = v(null), l = v(!1), u = p((r) => {
|
|
9
|
+
if (l.current ||= r, s.current) return s.current;
|
|
10
|
+
const a = (async () => {
|
|
11
|
+
const o = async () => {
|
|
12
|
+
try {
|
|
13
|
+
return await E();
|
|
14
|
+
} catch (t) {
|
|
15
|
+
throw e.current && c(
|
|
16
|
+
(n) => n ? {
|
|
17
|
+
...n,
|
|
18
|
+
status: "invalid",
|
|
19
|
+
features: [],
|
|
20
|
+
nextSyncAt: null
|
|
21
|
+
} : {
|
|
22
|
+
status: "invalid",
|
|
23
|
+
plan: null,
|
|
24
|
+
features: [],
|
|
25
|
+
expiresAt: null,
|
|
26
|
+
certificateExpiresAt: null,
|
|
27
|
+
nextSyncAt: null,
|
|
28
|
+
deviceId: null,
|
|
29
|
+
persistencePending: !1
|
|
30
|
+
}
|
|
31
|
+
), t;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
try {
|
|
35
|
+
if (w.current === null && (w.current = (await D()).enabled, e.current && C(w.current)), !w.current) {
|
|
36
|
+
e.current && (c(null), i(null));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const t = await o();
|
|
40
|
+
e.current && c(t);
|
|
41
|
+
const n = l.current || t.persistencePending || t.status === "offline_grace" || t.status === "expired";
|
|
42
|
+
if (l.current = !1, n && t.status !== "unactivated") {
|
|
43
|
+
e.current && g(!0);
|
|
44
|
+
try {
|
|
45
|
+
const m = await G();
|
|
46
|
+
e.current && c(m);
|
|
47
|
+
} catch (m) {
|
|
48
|
+
const j = await o();
|
|
49
|
+
throw e.current && c(j), m;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
e.current && i(null);
|
|
53
|
+
} catch (t) {
|
|
54
|
+
throw e.current && i(t), t;
|
|
55
|
+
} finally {
|
|
56
|
+
s.current = null, l.current = !1, e.current && (A(!1), g(!1));
|
|
57
|
+
}
|
|
58
|
+
})();
|
|
59
|
+
return s.current = a, a;
|
|
60
|
+
}, []), I = p(() => u(!1), [u]), _ = p(() => u(!0), [u]), k = p(
|
|
61
|
+
async (r, a) => {
|
|
62
|
+
s.current && await s.current.catch(() => {
|
|
63
|
+
});
|
|
64
|
+
const o = (async () => {
|
|
65
|
+
e.current && g(!0);
|
|
66
|
+
try {
|
|
67
|
+
const t = await H(r, a);
|
|
68
|
+
return e.current && (c(t), i(null)), t;
|
|
69
|
+
} catch (t) {
|
|
70
|
+
try {
|
|
71
|
+
const n = await E();
|
|
72
|
+
e.current && c(n);
|
|
73
|
+
} catch {
|
|
74
|
+
e.current && c(
|
|
75
|
+
(n) => n ? {
|
|
76
|
+
...n,
|
|
77
|
+
status: "invalid",
|
|
78
|
+
features: [],
|
|
79
|
+
nextSyncAt: null
|
|
80
|
+
} : null
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
throw e.current && i(t), t;
|
|
84
|
+
} finally {
|
|
85
|
+
s.current = null, l.current = !1, e.current && g(!1);
|
|
86
|
+
}
|
|
87
|
+
})();
|
|
88
|
+
return s.current = o.then(
|
|
89
|
+
() => {
|
|
90
|
+
},
|
|
91
|
+
() => {
|
|
92
|
+
}
|
|
93
|
+
), o;
|
|
94
|
+
},
|
|
95
|
+
[]
|
|
96
|
+
), F = !y && (!L || h?.status === "active" || h?.status === "offline_grace"), T = (r) => !y && (!L || J(h, r));
|
|
97
|
+
return N(() => {
|
|
98
|
+
e.current = !0;
|
|
99
|
+
const r = () => {
|
|
100
|
+
u(!1).catch(() => {
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
u(!0).catch(() => {
|
|
104
|
+
});
|
|
105
|
+
const a = window.setInterval(r, 6e4);
|
|
106
|
+
return window.addEventListener("focus", r), () => {
|
|
107
|
+
e.current = !1, window.clearInterval(a), window.removeEventListener("focus", r);
|
|
108
|
+
};
|
|
109
|
+
}, [u]), /* @__PURE__ */ M(
|
|
110
|
+
S.Provider,
|
|
111
|
+
{
|
|
112
|
+
value: {
|
|
113
|
+
license: h,
|
|
114
|
+
enabled: L,
|
|
115
|
+
loading: y,
|
|
116
|
+
canWrite: F,
|
|
117
|
+
hasFeature: T,
|
|
118
|
+
refreshing: b,
|
|
119
|
+
error: R,
|
|
120
|
+
reload: I,
|
|
121
|
+
refresh: _,
|
|
122
|
+
change: k
|
|
123
|
+
},
|
|
124
|
+
children: d
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
function Z() {
|
|
129
|
+
const d = O(S);
|
|
130
|
+
if (!d) throw new Error("LicenseProvider is missing");
|
|
131
|
+
return d;
|
|
132
|
+
}
|
|
133
|
+
export {
|
|
134
|
+
Y as LicenseProvider,
|
|
135
|
+
Z as useLicense
|
|
136
|
+
};
|
|
137
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/licensing/LicenseProvider/index.tsx"],"sourcesContent":["import {\n\tcreateContext,\n\ttype ReactNode,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n} from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { STOA_NS } from '../../i18n/namespace'\nimport {\n\tallowsLicenseFeature,\n\tchangeLicense,\n\tgetLicenseConfig,\n\tgetLicenseStatus,\n\ttype LicenseState,\n\tlicenseErrorMessage,\n\trefreshLicense,\n} from '../api'\n\ntype LicenseContextValue = {\n\tlicense: LicenseState | null\n\tenabled: boolean\n\tloading: boolean\n\tcanWrite: boolean\n\thasFeature: (feature: string) => boolean\n\trefreshing: boolean\n\terror: string | null\n\treload: () => Promise<void>\n\trefresh: () => Promise<void>\n\tchange: (code: string, deviceName: string) => Promise<LicenseState>\n}\nconst LicenseContext = createContext<LicenseContextValue | null>(null)\n\nexport function LicenseProvider({ children }: { children: ReactNode }) {\n\tconst [license, setLicense] = useState<LicenseState | null>(null)\n\tconst [loading, setLoading] = useState(true)\n\tconst [enabled, setEnabled] = useState(true)\n\tconst licensingEnabled = useRef<boolean | null>(null)\n\tconst [refreshing, setRefreshing] = useState(false)\n\tconst [errorCause, setError] = useState<unknown>(null)\n\tconst { t } = useTranslation(STOA_NS)\n\tconst error = errorCause === null ? null : licenseErrorMessage(errorCause, t)\n\tconst mounted = useRef(false)\n\tconst pending = useRef<Promise<void> | null>(null)\n\tconst forceRefresh = useRef(false)\n\n\t// Status checks, focus events and manual refreshes share a single operation.\n\tconst check = useCallback((force: boolean): Promise<void> => {\n\t\tforceRefresh.current ||= force\n\t\tif (pending.current) return pending.current\n\t\tconst operation = (async () => {\n\t\t\tconst readLocal = async () => {\n\t\t\t\ttry {\n\t\t\t\t\treturn await getLicenseStatus()\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (mounted.current)\n\t\t\t\t\t\tsetLicense((previous) =>\n\t\t\t\t\t\t\tprevious\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t...previous,\n\t\t\t\t\t\t\t\t\t\tstatus: 'invalid',\n\t\t\t\t\t\t\t\t\t\tfeatures: [],\n\t\t\t\t\t\t\t\t\t\tnextSyncAt: null,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\tstatus: 'invalid',\n\t\t\t\t\t\t\t\t\t\tplan: null,\n\t\t\t\t\t\t\t\t\t\tfeatures: [],\n\t\t\t\t\t\t\t\t\t\texpiresAt: null,\n\t\t\t\t\t\t\t\t\t\tcertificateExpiresAt: null,\n\t\t\t\t\t\t\t\t\t\tnextSyncAt: null,\n\t\t\t\t\t\t\t\t\t\tdeviceId: null,\n\t\t\t\t\t\t\t\t\t\tpersistencePending: false,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\tthrow error\n\t\t\t\t}\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif (licensingEnabled.current === null) {\n\t\t\t\t\tlicensingEnabled.current = (await getLicenseConfig()).enabled\n\t\t\t\t\tif (mounted.current) setEnabled(licensingEnabled.current)\n\t\t\t\t}\n\t\t\t\tif (!licensingEnabled.current) {\n\t\t\t\t\tif (mounted.current) {\n\t\t\t\t\t\tsetLicense(null)\n\t\t\t\t\t\tsetError(null)\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst local = await readLocal()\n\t\t\t\tif (mounted.current) setLicense(local)\n\t\t\t\tconst shouldRefresh =\n\t\t\t\t\tforceRefresh.current ||\n\t\t\t\t\tlocal.persistencePending ||\n\t\t\t\t\tlocal.status === 'offline_grace' ||\n\t\t\t\t\tlocal.status === 'expired'\n\t\t\t\tforceRefresh.current = false\n\t\t\t\tif (shouldRefresh && local.status !== 'unactivated') {\n\t\t\t\t\tif (mounted.current) setRefreshing(true)\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst updated = await refreshLicense()\n\t\t\t\t\t\tif (mounted.current) setLicense(updated)\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t// In particular, retrieve the process-level revocation latch after a storage error.\n\t\t\t\t\t\tconst current = await readLocal()\n\t\t\t\t\t\tif (mounted.current) setLicense(current)\n\t\t\t\t\t\tthrow error\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (mounted.current) setError(null)\n\t\t\t} catch (error) {\n\t\t\t\tif (mounted.current) setError(error)\n\t\t\t\t// The backend remains authoritative; a refresh failure never extends validity.\n\t\t\t\tthrow error\n\t\t\t} finally {\n\t\t\t\tpending.current = null\n\t\t\t\tforceRefresh.current = false\n\t\t\t\tif (mounted.current) {\n\t\t\t\t\tsetLoading(false)\n\t\t\t\t\tsetRefreshing(false)\n\t\t\t\t}\n\t\t\t}\n\t\t})()\n\t\tpending.current = operation\n\t\treturn operation\n\t}, [])\n\n\tconst reload = useCallback(() => check(false), [check])\n\tconst refresh = useCallback(() => check(true), [check])\n\tconst change = useCallback(\n\t\tasync (code: string, deviceName: string): Promise<LicenseState> => {\n\t\t\t// Finish any status/refresh operation before switching; polling then shares this operation.\n\t\t\tif (pending.current) await pending.current.catch(() => {})\n\t\t\tconst operation = (async () => {\n\t\t\t\tif (mounted.current) setRefreshing(true)\n\t\t\t\ttry {\n\t\t\t\t\tconst updated = await changeLicense(code, deviceName)\n\t\t\t\t\tif (mounted.current) {\n\t\t\t\t\t\tsetLicense(updated)\n\t\t\t\t\t\tsetError(null)\n\t\t\t\t\t}\n\t\t\t\t\treturn updated\n\t\t\t\t} catch (error) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst current = await getLicenseStatus()\n\t\t\t\t\t\tif (mounted.current) setLicense(current)\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tif (mounted.current)\n\t\t\t\t\t\t\tsetLicense((previous) =>\n\t\t\t\t\t\t\t\tprevious\n\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t...previous,\n\t\t\t\t\t\t\t\t\t\t\tstatus: 'invalid',\n\t\t\t\t\t\t\t\t\t\t\tfeatures: [],\n\t\t\t\t\t\t\t\t\t\t\tnextSyncAt: null,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tif (mounted.current) setError(error)\n\t\t\t\t\tthrow error\n\t\t\t\t} finally {\n\t\t\t\t\tpending.current = null\n\t\t\t\t\tforceRefresh.current = false\n\t\t\t\t\tif (mounted.current) setRefreshing(false)\n\t\t\t\t}\n\t\t\t})()\n\t\t\tpending.current = operation.then(\n\t\t\t\t() => {},\n\t\t\t\t() => {},\n\t\t\t)\n\t\t\treturn operation\n\t\t},\n\t\t[],\n\t)\n\n\tconst canWrite =\n\t\t!loading &&\n\t\t(!enabled ||\n\t\t\tlicense?.status === 'active' ||\n\t\t\tlicense?.status === 'offline_grace')\n\tconst hasFeature = (feature: string) =>\n\t\t!loading && (!enabled || allowsLicenseFeature(license, feature))\n\tuseEffect(() => {\n\t\tmounted.current = true\n\t\tconst run = () => {\n\t\t\tvoid check(false).catch(() => {})\n\t\t}\n\t\t// Check the server on every app start, even while the local certificate is active.\n\t\t// loading stays true until this finishes; concurrent checks share pending.current.\n\t\tvoid check(true).catch(() => {})\n\t\tconst interval = window.setInterval(run, 60_000)\n\t\twindow.addEventListener('focus', run)\n\t\treturn () => {\n\t\t\tmounted.current = false\n\t\t\twindow.clearInterval(interval)\n\t\t\twindow.removeEventListener('focus', run)\n\t\t}\n\t}, [check])\n\n\treturn (\n\t\t<LicenseContext.Provider\n\t\t\tvalue={{\n\t\t\t\tlicense,\n\t\t\t\tenabled,\n\t\t\t\tloading,\n\t\t\t\tcanWrite,\n\t\t\t\thasFeature,\n\t\t\t\trefreshing,\n\t\t\t\terror,\n\t\t\t\treload,\n\t\t\t\trefresh,\n\t\t\t\tchange,\n\t\t\t}}\n\t\t>\n\t\t\t{children}\n\t\t</LicenseContext.Provider>\n\t)\n}\n\nexport function useLicense() {\n\tconst context = useContext(LicenseContext)\n\tif (!context) throw new Error('LicenseProvider is missing')\n\treturn context\n}\n"],"names":["LicenseContext","createContext","LicenseProvider","children","license","setLicense","useState","loading","setLoading","enabled","setEnabled","licensingEnabled","useRef","refreshing","setRefreshing","errorCause","setError","t","useTranslation","STOA_NS","error","licenseErrorMessage","mounted","pending","forceRefresh","check","useCallback","force","operation","readLocal","getLicenseStatus","previous","getLicenseConfig","local","shouldRefresh","updated","refreshLicense","current","reload","refresh","change","code","deviceName","changeLicense","canWrite","hasFeature","feature","allowsLicenseFeature","useEffect","run","interval","jsx","useLicense","context","useContext"],"mappings":";;;;;AAiCA,MAAMA,IAAiBC,EAA0C,IAAI;AAE9D,SAASC,EAAgB,EAAE,UAAAC,KAAqC;AACtE,QAAM,CAACC,GAASC,CAAU,IAAIC,EAA8B,IAAI,GAC1D,CAACC,GAASC,CAAU,IAAIF,EAAS,EAAI,GACrC,CAACG,GAASC,CAAU,IAAIJ,EAAS,EAAI,GACrCK,IAAmBC,EAAuB,IAAI,GAC9C,CAACC,GAAYC,CAAa,IAAIR,EAAS,EAAK,GAC5C,CAACS,GAAYC,CAAQ,IAAIV,EAAkB,IAAI,GAC/C,EAAE,GAAAW,EAAA,IAAMC,EAAeC,CAAO,GAC9BC,IAAQL,MAAe,OAAO,OAAOM,EAAoBN,GAAYE,CAAC,GACtEK,IAAUV,EAAO,EAAK,GACtBW,IAAUX,EAA6B,IAAI,GAC3CY,IAAeZ,EAAO,EAAK,GAG3Ba,IAAQC,EAAY,CAACC,MAAkC;AAE5D,QADAH,E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} from "react/jsx-runtime";
|
|
2
|
+
import { RefreshCw as k, ShieldAlert as x } from "lucide-react";
|
|
3
|
+
import { useState as w } from "react";
|
|
4
|
+
import { useTranslation as N } from "react-i18next";
|
|
5
|
+
import { STOA_NS as y } from "../../i18n/namespace.js";
|
|
6
|
+
import { Button as d } from "../../ui/button/index.js";
|
|
7
|
+
import { Dialog as C, DialogContent as D, DialogTitle as _, DialogDescription as O } from "../../ui/dialog/index.js";
|
|
8
|
+
import { cn as A } from "../../utils/cn.js";
|
|
9
|
+
import { LicenseActivation as P } from "../LicenseActivation/index.js";
|
|
10
|
+
import { useLicense as S } from "../LicenseProvider/index.js";
|
|
11
|
+
function K({ className: m }) {
|
|
12
|
+
const { t: e } = N(y), { license: n, canWrite: o, refresh: u, refreshing: t, error: l } = S(), [p, c] = w(!1);
|
|
13
|
+
if (!n) return null;
|
|
14
|
+
const a = n.persistencePending, f = !o || !!l || a, h = !!l || a || n.status === "activation_required" || n.status === "invalid", g = [
|
|
15
|
+
"revoked",
|
|
16
|
+
"license_revoked",
|
|
17
|
+
"expired",
|
|
18
|
+
"activation_required",
|
|
19
|
+
"invalid"
|
|
20
|
+
].includes(n.status);
|
|
21
|
+
if (!f) return null;
|
|
22
|
+
const v = n.status === "activation_required" ? e("licenseProfile.status.activation_required.label") : n.status === "license_revoked" ? e("licenseProfile.status.license_revoked.label") : n.status === "revoked" ? e("licenseProfile.status.revoked.label") : n.status === "expired" ? e("licenseProfile.status.expired.label") : e(o ? "licensing.banner.refreshFailed" : "licensing.banner.readOnlyTitle"), b = h ? /* @__PURE__ */ s(
|
|
23
|
+
d,
|
|
24
|
+
{
|
|
25
|
+
type: "button",
|
|
26
|
+
variant: "outline",
|
|
27
|
+
size: "sm",
|
|
28
|
+
disabled: t,
|
|
29
|
+
className: "w-full shrink-0 sm:w-auto",
|
|
30
|
+
onClick: () => {
|
|
31
|
+
u().catch(() => {
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ i(
|
|
36
|
+
k,
|
|
37
|
+
{
|
|
38
|
+
"aria-hidden": "true",
|
|
39
|
+
className: t ? "animate-spin" : void 0
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
e(t ? "licensing.checking" : a ? "licensing.banner.retryStorage" : "licensing.checkAgain")
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
) : null;
|
|
46
|
+
return /* @__PURE__ */ s(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
className: A("relative z-10 shrink-0 pb-4", m),
|
|
50
|
+
style: { top: "-10px" },
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ s(
|
|
53
|
+
"section",
|
|
54
|
+
{
|
|
55
|
+
role: "status",
|
|
56
|
+
"aria-live": "polite",
|
|
57
|
+
"aria-atomic": "true",
|
|
58
|
+
"aria-labelledby": "license-status-title",
|
|
59
|
+
className: "mx-auto flex max-w-6xl flex-col gap-4 rounded-lg border bg-amber-50 p-4 text-black sm:flex-row sm:items-start sm:justify-between dark:bg-amber-500",
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ s("div", { className: "flex min-w-0 items-start gap-3", children: [
|
|
62
|
+
/* @__PURE__ */ i(x, { "aria-hidden": "true", className: "mt-0.5 size-5 shrink-0" }),
|
|
63
|
+
/* @__PURE__ */ s("div", { className: "min-w-0 space-y-1 text-sm", children: [
|
|
64
|
+
/* @__PURE__ */ i("h2", { id: "license-status-title", className: "font-semibold", children: v }),
|
|
65
|
+
!o && /* @__PURE__ */ i("p", { children: e("licensing.banner.readOnlyDescription") }),
|
|
66
|
+
l && /* @__PURE__ */ i("p", { className: "wrap-break-word", children: l }),
|
|
67
|
+
a && /* @__PURE__ */ i("p", { children: e("licensing.banner.persistencePending") })
|
|
68
|
+
] })
|
|
69
|
+
] }),
|
|
70
|
+
/* @__PURE__ */ s("div", { className: "flex shrink-0 flex-col gap-2", children: [
|
|
71
|
+
g && /* @__PURE__ */ i(
|
|
72
|
+
d,
|
|
73
|
+
{
|
|
74
|
+
type: "button",
|
|
75
|
+
size: "sm",
|
|
76
|
+
disabled: t || a,
|
|
77
|
+
onClick: () => c(!0),
|
|
78
|
+
children: e("licensing.activation.renew")
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
b
|
|
82
|
+
] })
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ i(
|
|
87
|
+
C,
|
|
88
|
+
{
|
|
89
|
+
open: p,
|
|
90
|
+
onOpenChange: (r) => {
|
|
91
|
+
t || c(r);
|
|
92
|
+
},
|
|
93
|
+
children: /* @__PURE__ */ s(
|
|
94
|
+
D,
|
|
95
|
+
{
|
|
96
|
+
showCloseButton: !t,
|
|
97
|
+
onEscapeKeyDown: (r) => {
|
|
98
|
+
t && r.preventDefault();
|
|
99
|
+
},
|
|
100
|
+
onInteractOutside: (r) => {
|
|
101
|
+
t && r.preventDefault();
|
|
102
|
+
},
|
|
103
|
+
children: [
|
|
104
|
+
/* @__PURE__ */ i(_, { className: "sr-only", children: e("licensing.activation.renew") }),
|
|
105
|
+
/* @__PURE__ */ i(O, { className: "sr-only", children: e("licensing.activation.replacementNotice") }),
|
|
106
|
+
/* @__PURE__ */ i(
|
|
107
|
+
P,
|
|
108
|
+
{
|
|
109
|
+
replacement: !0,
|
|
110
|
+
onActivated: () => c(!1)
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
/* @__PURE__ */ i(
|
|
114
|
+
d,
|
|
115
|
+
{
|
|
116
|
+
type: "button",
|
|
117
|
+
variant: "ghost",
|
|
118
|
+
disabled: t,
|
|
119
|
+
onClick: () => c(!1),
|
|
120
|
+
children: e("actions.cancel")
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
export {
|
|
133
|
+
K as LicenseStatusBanner
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/licensing/LicenseStatusBanner/index.tsx"],"sourcesContent":["import { RefreshCw, ShieldAlert } from 'lucide-react'\nimport { useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { STOA_NS } from '../../i18n/namespace'\nimport { Button } from '../../ui/button'\nimport {\n\tDialog,\n\tDialogContent,\n\tDialogDescription,\n\tDialogTitle,\n} from '../../ui/dialog'\nimport { cn } from '../../utils/cn'\nimport { LicenseActivation } from '../LicenseActivation'\nimport { useLicense } from '../LicenseProvider'\n\nexport function LicenseStatusBanner({ className }: { className?: string }) {\n\tconst { t } = useTranslation(STOA_NS)\n\tconst { license, canWrite, refresh, refreshing, error } = useLicense()\n\tconst [changeOpen, setChangeOpen] = useState(false)\n\tif (!license) return null\n\n\tconst pending = license.persistencePending\n\tconst needsAttention = !canWrite || !!error || pending\n\tconst canRefresh =\n\t\t!!error ||\n\t\tpending ||\n\t\tlicense.status === 'activation_required' ||\n\t\tlicense.status === 'invalid'\n\tconst canChange = [\n\t\t'revoked',\n\t\t'license_revoked',\n\t\t'expired',\n\t\t'activation_required',\n\t\t'invalid',\n\t].includes(license.status)\n\tif (!needsAttention) return null\n\n\tconst title =\n\t\tlicense.status === 'activation_required'\n\t\t\t? t('licenseProfile.status.activation_required.label')\n\t\t\t: license.status === 'license_revoked'\n\t\t\t\t? t('licenseProfile.status.license_revoked.label')\n\t\t\t\t: license.status === 'revoked'\n\t\t\t\t\t? t('licenseProfile.status.revoked.label')\n\t\t\t\t\t: license.status === 'expired'\n\t\t\t\t\t\t? t('licenseProfile.status.expired.label')\n\t\t\t\t\t\t: !canWrite\n\t\t\t\t\t\t\t? t('licensing.banner.readOnlyTitle')\n\t\t\t\t\t\t\t: t('licensing.banner.refreshFailed')\n\n\tconst action = canRefresh ? (\n\t\t<Button\n\t\t\ttype='button'\n\t\t\tvariant='outline'\n\t\t\tsize='sm'\n\t\t\tdisabled={refreshing}\n\t\t\tclassName='w-full shrink-0 sm:w-auto'\n\t\t\tonClick={() => {\n\t\t\t\tvoid refresh().catch(() => {})\n\t\t\t}}\n\t\t>\n\t\t\t<RefreshCw\n\t\t\t\taria-hidden='true'\n\t\t\t\tclassName={refreshing ? 'animate-spin' : undefined}\n\t\t\t/>\n\t\t\t{refreshing\n\t\t\t\t? t('licensing.checking')\n\t\t\t\t: pending\n\t\t\t\t\t? t('licensing.banner.retryStorage')\n\t\t\t\t\t: t('licensing.checkAgain')}\n\t\t</Button>\n\t) : null\n\n\treturn (\n\t\t<div\n\t\t\tclassName={cn('relative z-10 shrink-0 pb-4', className)}\n\t\t\tstyle={{ top: '-10px' }}\n\t\t>\n\t\t\t<section\n\t\t\t\trole='status'\n\t\t\t\taria-live='polite'\n\t\t\t\taria-atomic='true'\n\t\t\t\taria-labelledby='license-status-title'\n\t\t\t\tclassName='mx-auto flex max-w-6xl flex-col gap-4 rounded-lg border bg-amber-50 p-4 text-black sm:flex-row sm:items-start sm:justify-between dark:bg-amber-500'\n\t\t\t>\n\t\t\t\t<div className='flex min-w-0 items-start gap-3'>\n\t\t\t\t\t<ShieldAlert aria-hidden='true' className='mt-0.5 size-5 shrink-0' />\n\t\t\t\t\t<div className='min-w-0 space-y-1 text-sm'>\n\t\t\t\t\t\t<h2 id='license-status-title' className='font-semibold'>\n\t\t\t\t\t\t\t{title}\n\t\t\t\t\t\t</h2>\n\n\t\t\t\t\t\t{!canWrite && <p>{t('licensing.banner.readOnlyDescription')}</p>}\n\n\t\t\t\t\t\t{error && <p className='wrap-break-word'>{error}</p>}\n\n\t\t\t\t\t\t{pending && <p>{t('licensing.banner.persistencePending')}</p>}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\n\t\t\t\t<div className='flex shrink-0 flex-col gap-2'>\n\t\t\t\t\t{canChange && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\ttype='button'\n\t\t\t\t\t\t\tsize='sm'\n\t\t\t\t\t\t\tdisabled={refreshing || pending}\n\t\t\t\t\t\t\tonClick={() => setChangeOpen(true)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{t('licensing.activation.renew')}\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t)}\n\t\t\t\t\t{action}\n\t\t\t\t</div>\n\t\t\t</section>\n\n\t\t\t<Dialog\n\t\t\t\topen={changeOpen}\n\t\t\t\tonOpenChange={(open) => {\n\t\t\t\t\tif (!refreshing) setChangeOpen(open)\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<DialogContent\n\t\t\t\t\tshowCloseButton={!refreshing}\n\t\t\t\t\tonEscapeKeyDown={(event) => {\n\t\t\t\t\t\tif (refreshing) event.preventDefault()\n\t\t\t\t\t}}\n\t\t\t\t\tonInteractOutside={(event) => {\n\t\t\t\t\t\tif (refreshing) event.preventDefault()\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<DialogTitle className='sr-only'>\n\t\t\t\t\t\t{t('licensing.activation.renew')}\n\t\t\t\t\t</DialogTitle>\n\n\t\t\t\t\t<DialogDescription className='sr-only'>\n\t\t\t\t\t\t{t('licensing.activation.replacementNotice')}\n\t\t\t\t\t</DialogDescription>\n\n\t\t\t\t\t<LicenseActivation\n\t\t\t\t\t\treplacement\n\t\t\t\t\t\tonActivated={() => setChangeOpen(false)}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<Button\n\t\t\t\t\t\ttype='button'\n\t\t\t\t\t\tvariant='ghost'\n\t\t\t\t\t\tdisabled={refreshing}\n\t\t\t\t\t\tonClick={() => setChangeOpen(false)}\n\t\t\t\t\t>\n\t\t\t\t\t\t{t('actions.cancel')}\n\t\t\t\t\t</Button>\n\t\t\t\t</DialogContent>\n\t\t\t</Dialog>\n\t\t</div>\n\t)\n}\n"],"names":["LicenseStatusBanner","className","t","useTranslation","STOA_NS","license","canWrite","refresh","refreshing","error","useLicense","changeOpen","setChangeOpen","useState","pending","needsAttention","canRefresh","canChange","title","action","jsxs","Button","jsx","RefreshCw","cn","ShieldAlert","Dialog","open","DialogContent","event","DialogTitle","DialogDescription","LicenseActivation"],"mappings":";;;;;;;;;;AAeO,SAASA,EAAoB,EAAE,WAAAC,KAAqC;AAC1E,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAeC,CAAO,GAC9B,EAAE,SAAAC,GAAS,UAAAC,GAAU,SAAAC,GAAS,YAAAC,GAAY,OAAAC,EAAA,IAAUC,EAAA,GACpD,CAACC,GAAYC,CAAa,IAAIC,EAAS,EAAK;AAClD,MAAI,CAACR,EAAS,QAAO;AAErB,QAAMS,IAAUT,EAAQ,oBAClBU,IAAiB,CAACT,KAAY,CAAC,CAACG,KAASK,GACzCE,IACL,CAAC,CAACP,KACFK,KACAT,EAAQ,WAAW,yBACnBA,EAAQ,WAAW,WACdY,IAAY;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,EACC,SAASZ,EAAQ,MAAM;AACzB,MAAI,CAACU,EAAgB,QAAO;AAE5B,QAAMG,IACLb,EAAQ,WAAW,wBAChBH,EAAE,iDAAiD,IACnDG,EAAQ,WAAW,oBAClBH,EAAE,6CAA6C,IAC/CG,EAAQ,WAAW,YAClBH,EAAE,qCAAqC,IACvCG,EAAQ,WAAW,YAClBH,EAAE,qCAAqC,IAGtCA,EAFAI,IAEE,mCADA,gCACgC,GAEpCa,IAASH,IACd,gBAAAI;AAAA,IAACC;AAAA,IAAA;AAAA,MACA,MAAK;AAAA,MACL,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,UAAUb;AAAA,MACV,WAAU;AAAA,MACV,SAAS,MAAM;AACd,QAAKD,EAAA,EAAU,MAAM,MAAM;AAAA,QAAC,CAAC;AAAA,MAC9B;AAAA,MAEA,UAAA;AAAA,QAAA,gBAAAe;AAAA,UAACC;AAAA,UAAA;AAAA,YACA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BAA4B;AAAA,kBAAA;AAAA,gBAAA;AAAA,gBAGhCO;AAAA,cAAA,EAAA,CACF;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,QAGD,gBAAAG;AAAA,UAACI;AAAA,UAAA;AAAA,YACA,MAAMf;AAAA,YACN,cAAc,CAACgB,MAAS;AACvB,cAAKnB,KAAYI,EAAce,CAAI;AAAA,YACpC;AAAA,YAEA,UAAA,gBAAAP;AAAA,cAACQ;AAAA,cAAA;AAAA,gBACA,iBAAiB,CAACpB;AAAA,gBAClB,iBAAiB,CAACqB,MAAU;AAC3B,kBAAIrB,OAAkB,eAAA;AAAA,gBACvB;AAAA,gBACA,mBAAmB,CAACqB,MAAU;AAC7B,kBAAIrB,OAAkB,eAAA;AAAA,gBACvB;AAAA,gBAEA,UAAA;AAAA,kBAAA,gBAAAc,EAACQ,GAAA,EAAY,WAAU,WACrB,UAAA5B,EAAE,4BAA4B,GAChC;AAAA,oCAEC6B,GAAA,EAAkB,WAAU,WAC3B,UAAA7B,EAAE,wCAAwC,GAC5C;AAAA,kBAEA,gBAAAoB;AAAA,oBAACU;AAAA,oBAAA;AAAA,sBACA,aAAW;AAAA,sBACX,aAAa,MAAMpB,EAAc,EAAK;AAAA,oBAAA;AAAA,kBAAA;AAAA,kBAGvC,gBAAAU;AAAA,oBAACD;AAAA,oBAAA;AAAA,sBACA,MAAK;AAAA,sBACL,SAAQ;AAAA,sBACR,UAAUb;AAAA,sBACV,SAAS,MAAMI,EAAc,EAAK;AAAA,sBAEjC,YAAE,gBAAgB;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBACpB;AAAA,cAAA;AAAA,YAAA;AAAA,UACD;AAAA,QAAA;AAAA,MACD;AAAA,IAAA;AAAA,EAAA;AAGH;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { invoke as t, isTauri as c } from "@tauri-apps/api/core";
|
|
2
|
+
import s from "i18next";
|
|
3
|
+
import { STOA_NS as r } from "../i18n/namespace.js";
|
|
4
|
+
function f(e, n) {
|
|
5
|
+
return (e?.status === "active" || e?.status === "offline_grace") && (e.features.includes("all_features") || e.features.includes(n));
|
|
6
|
+
}
|
|
7
|
+
function l() {
|
|
8
|
+
return t("license_status");
|
|
9
|
+
}
|
|
10
|
+
function A(e, n) {
|
|
11
|
+
return t("license_activate", {
|
|
12
|
+
code: e,
|
|
13
|
+
deviceName: n
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function d(e, n) {
|
|
17
|
+
return t("license_change", { code: e, deviceName: n });
|
|
18
|
+
}
|
|
19
|
+
function T() {
|
|
20
|
+
return t("license_refresh");
|
|
21
|
+
}
|
|
22
|
+
function o(e) {
|
|
23
|
+
const n = typeof e == "object" && e !== null && "code" in e ? e.code : typeof e == "string" ? e : null, i = {
|
|
24
|
+
ACTIVATION_REQUIRED: "activationRequired",
|
|
25
|
+
NETWORK: "network",
|
|
26
|
+
REVOKED: "deviceRevoked",
|
|
27
|
+
LICENSE_REVOKED: "licenseRevoked",
|
|
28
|
+
STORAGE: "storage",
|
|
29
|
+
CERTIFICATE: "certificate",
|
|
30
|
+
ALREADY_ACTIVATED: "alreadyActivated",
|
|
31
|
+
API: "api",
|
|
32
|
+
PROTOCOL: "protocol",
|
|
33
|
+
UNACTIVATED: "unactivated",
|
|
34
|
+
STATE_CHANGED: "stateChanged",
|
|
35
|
+
SYNCHRONIZATION: "synchronization",
|
|
36
|
+
LICENSE_READ_ONLY: "readOnly",
|
|
37
|
+
LICENSE_FEATURE_DENIED: "featureDenied"
|
|
38
|
+
};
|
|
39
|
+
return `licensing.errors.${typeof n == "string" && Object.getOwnPropertyDescriptor(i, n) !== void 0 ? i[n] : "unknown"}`;
|
|
40
|
+
}
|
|
41
|
+
function _(e, n = (i) => s.t(i, { ns: r })) {
|
|
42
|
+
return n(o(e));
|
|
43
|
+
}
|
|
44
|
+
async function O() {
|
|
45
|
+
return c() ? t("license_config") : { enabled: !1 };
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
A as activateLicense,
|
|
49
|
+
f as allowsLicenseFeature,
|
|
50
|
+
d as changeLicense,
|
|
51
|
+
O as getLicenseConfig,
|
|
52
|
+
l as getLicenseStatus,
|
|
53
|
+
o as licenseErrorKey,
|
|
54
|
+
_ as licenseErrorMessage,
|
|
55
|
+
T as refreshLicense
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sources":["../../src/licensing/api.ts"],"sourcesContent":["import { invoke, isTauri } from '@tauri-apps/api/core'\nimport i18next from 'i18next'\nimport { STOA_NS } from '../i18n/namespace'\n\nexport type LicenseStatus =\n\t| 'unactivated'\n\t| 'activation_required'\n\t| 'active'\n\t| 'offline_grace'\n\t| 'expired'\n\t| 'revoked'\n\t| 'license_revoked'\n\t| 'invalid'\n\nexport interface LicenseState {\n\tstatus: LicenseStatus\n\tplan: string | null\n\tfeatures: string[]\n\texpiresAt: number | null\n\t/** Signed offline certificate expiry; does not indicate the purchased license term. */\n\tcertificateExpiresAt: number | null\n\tnextSyncAt: number | null\n\tdeviceId: string | null\n\tpersistencePending: boolean\n}\n\n/** UI hint only; Rust verifies the signed license before protected operations. */\nexport function allowsLicenseFeature(\n\tlicense: LicenseState | null,\n\tfeature: string,\n): boolean {\n\treturn (\n\t\t(license?.status === 'active' || license?.status === 'offline_grace') &&\n\t\t(license.features.includes('all_features') ||\n\t\t\tlicense.features.includes(feature))\n\t)\n}\n\nexport function getLicenseStatus() {\n\treturn invoke<LicenseState>('license_status')\n}\n\nexport function activateLicense(code: string, deviceName: string) {\n\treturn invoke<LicenseState>('license_activate', {\n\t\tcode,\n\t\tdeviceName,\n\t})\n}\n\nexport function changeLicense(code: string, deviceName: string) {\n\treturn invoke<LicenseState>('license_change', { code, deviceName })\n}\n\nexport function refreshLicense() {\n\treturn invoke<LicenseState>('license_refresh')\n}\n\nexport interface LicenseError {\n\tcode: string\n\tdetail?: unknown\n}\n\nexport function licenseErrorKey(error: unknown): string {\n\tconst code =\n\t\ttypeof error === 'object' && error !== null && 'code' in error\n\t\t\t? error.code\n\t\t\t: typeof error === 'string'\n\t\t\t\t? error\n\t\t\t\t: null\n\tconst keys: Record<string, string> = {\n\t\tACTIVATION_REQUIRED: 'activationRequired',\n\t\tNETWORK: 'network',\n\t\tREVOKED: 'deviceRevoked',\n\t\tLICENSE_REVOKED: 'licenseRevoked',\n\t\tSTORAGE: 'storage',\n\t\tCERTIFICATE: 'certificate',\n\t\tALREADY_ACTIVATED: 'alreadyActivated',\n\t\tAPI: 'api',\n\t\tPROTOCOL: 'protocol',\n\t\tUNACTIVATED: 'unactivated',\n\t\tSTATE_CHANGED: 'stateChanged',\n\t\tSYNCHRONIZATION: 'synchronization',\n\t\tLICENSE_READ_ONLY: 'readOnly',\n\t\tLICENSE_FEATURE_DENIED: 'featureDenied',\n\t}\n\treturn `licensing.errors.${typeof code === 'string' && Object.getOwnPropertyDescriptor(keys, code) !== undefined ? keys[code] : 'unknown'}`\n}\n\nexport function licenseErrorMessage(\n\terror: unknown,\n\ttranslate: (key: string) => string = (key) => i18next.t(key, { ns: STOA_NS }),\n): string {\n\treturn translate(licenseErrorKey(error))\n}\n\nexport async function getLicenseConfig(): Promise<{ enabled: boolean }> {\n\treturn isTauri() ? invoke('license_config') : { enabled: false }\n}\n"],"names":["allowsLicenseFeature","license","feature","getLicenseStatus","invoke","activateLicense","code","deviceName","changeLicense","refreshLicense","licenseErrorKey","error","keys","licenseErrorMessage","translate","key","i18next","STOA_NS","getLicenseConfig","isTauri"],"mappings":";;;AA2BO,SAASA,EACfC,GACAC,GACU;AACV,UACED,GAAS,WAAW,YAAYA,GAAS,WAAW,qBACpDA,EAAQ,SAAS,SAAS,cAAc,KACxCA,EAAQ,SAAS,SAASC,CAAO;AAEpC;AAEO,SAASC,IAAmB;AAClC,SAAOC,EAAqB,gBAAgB;AAC7C;AAEO,SAASC,EAAgBC,GAAcC,GAAoB;AACjE,SAAOH,EAAqB,oBAAoB;AAAA,IAC/C,MAAAE;AAAA,IACA,YAAAC;AAAA,EAAA,CACA;AACF;AAEO,SAASC,EAAcF,GAAcC,GAAoB;AAC/D,SAAOH,EAAqB,kBAAkB,EAAE,MAAAE,GAAM,YAAAC,GAAY;AACnE;AAEO,SAASE,IAAiB;AAChC,SAAOL,EAAqB,iBAAiB;AAC9C;AAOO,SAASM,EAAgBC,GAAwB;AACvD,QAAML,IACL,OAAOK,KAAU,YAAYA,MAAU,QAAQ,UAAUA,IACtDA,EAAM,OACN,OAAOA,KAAU,WAChBA,IACA,MACCC,IAA+B;AAAA,IACpC,qBAAqB;AAAA,IACrB,SAAS;AAAA,IACT,SAAS;AAAA,IACT,iBAAiB;AAAA,IACjB,SAAS;AAAA,IACT,aAAa;AAAA,IACb,mBAAmB;AAAA,IACnB,KAAK;AAAA,IACL,UAAU;AAAA,IACV,aAAa;AAAA,IACb,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,mBAAmB;AAAA,IACnB,wBAAwB;AAAA,EAAA;AAEzB,SAAO,oBAAoB,OAAON,KAAS,YAAY,OAAO,yBAAyBM,GAAMN,CAAI,MAAM,SAAYM,EAAKN,CAAI,IAAI,SAAS;AAC1I;AAEO,SAASO,EACfF,GACAG,IAAqC,CAACC,MAAQC,EAAQ,EAAED,GAAK,EAAE,IAAIE,EAAA,CAAS,GACnE;AACT,SAAOH,EAAUJ,EAAgBC,CAAK,CAAC;AACxC;AAEA,eAAsBO,IAAkD;AACvE,SAAOC,MAAYf,EAAO,gBAAgB,IAAI,EAAE,SAAS,GAAA;AAC1D;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { activateLicense as s, allowsLicenseFeature as i, changeLicense as n, getLicenseConfig as o, getLicenseStatus as t, licenseErrorKey as c, licenseErrorMessage as a, refreshLicense as L } from "./api.js";
|
|
2
|
+
import { LicenseActivation as m } from "./LicenseActivation/index.js";
|
|
3
|
+
import { LicenseCard as x } from "./LicenseCard/index.js";
|
|
4
|
+
import { LicenseGate as l } from "./LicenseGate/index.js";
|
|
5
|
+
import { LicenseProvider as v, useLicense as d } from "./LicenseProvider/index.js";
|
|
6
|
+
import { LicenseStatusBanner as C } from "./LicenseStatusBanner/index.js";
|
|
7
|
+
export {
|
|
8
|
+
m as LicenseActivation,
|
|
9
|
+
x as LicenseCard,
|
|
10
|
+
l as LicenseGate,
|
|
11
|
+
v as LicenseProvider,
|
|
12
|
+
C as LicenseStatusBanner,
|
|
13
|
+
s as activateLicense,
|
|
14
|
+
i as allowsLicenseFeature,
|
|
15
|
+
n as changeLicense,
|
|
16
|
+
o as getLicenseConfig,
|
|
17
|
+
t as getLicenseStatus,
|
|
18
|
+
c as licenseErrorKey,
|
|
19
|
+
a as licenseErrorMessage,
|
|
20
|
+
L as refreshLicense,
|
|
21
|
+
d as useLicense
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const o = "stoa-AppNavigation-root-q2bm", t = "stoa-AppNavigation-logo-q27s", a = "stoa-AppNavigation-divider-1iif", i = "stoa-AppNavigation-spacer-19m9", s = "stoa-AppNavigation-menuButton-8y5h", n = {
|
|
2
|
+
root: o,
|
|
3
|
+
logo: t,
|
|
4
|
+
divider: a,
|
|
5
|
+
spacer: i,
|
|
6
|
+
menuButton: s
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
n as default,
|
|
10
|
+
a as divider,
|
|
11
|
+
t as logo,
|
|
12
|
+
s as menuButton,
|
|
13
|
+
o as root,
|
|
14
|
+
i as spacer
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=AppNavigation.module.scss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppNavigation.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|