@viceme-ai/sdk 0.2.0 → 0.4.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/README.md +46 -17
- package/dist/browser-events.d.ts +49 -0
- package/dist/browser-events.d.ts.map +1 -0
- package/dist/capability-mount.d.ts +15 -0
- package/dist/capability-mount.d.ts.map +1 -0
- package/dist/chunks/client-Cbldd7F2.js +949 -0
- package/dist/chunks/client-Cbldd7F2.js.map +1 -0
- package/dist/chunks/{version-BbUa2jZV.js → errors-B-Qv_azy.js} +27 -17
- package/dist/chunks/errors-B-Qv_azy.js.map +1 -0
- package/dist/chunks/version-C8DeBm39.js +6 -0
- package/dist/chunks/version-C8DeBm39.js.map +1 -0
- package/dist/core/build-endpoints.d.ts +5 -0
- package/dist/core/build-endpoints.d.ts.map +1 -1
- package/dist/core/capabilities.d.ts +79 -0
- package/dist/core/capabilities.d.ts.map +1 -0
- package/dist/core/client.d.ts +36 -8
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/config.d.ts +14 -4
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/errors.d.ts +1 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/presentation.d.ts +29 -0
- package/dist/core/presentation.d.ts.map +1 -0
- package/dist/danmaku/index.d.ts +1 -0
- package/dist/danmaku/index.d.ts.map +1 -1
- package/dist/danmaku/mount.d.ts +1 -1
- package/dist/danmaku/mount.d.ts.map +1 -1
- package/dist/danmaku.js +127 -125
- package/dist/danmaku.js.map +1 -1
- package/dist/generated/public-contract.d.ts +291 -43
- package/dist/generated/public-contract.d.ts.map +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +114 -95
- package/dist/index.js.map +1 -1
- package/dist/loader/attributes.d.ts +3 -2
- package/dist/loader/attributes.d.ts.map +1 -1
- package/dist/loader/auto-loader.d.ts +1 -1
- package/dist/loader/auto-loader.d.ts.map +1 -1
- package/dist/loader/events.d.ts +1 -44
- package/dist/loader/events.d.ts.map +1 -1
- package/dist/loader/registry.d.ts +2 -1
- package/dist/loader/registry.d.ts.map +1 -1
- package/dist/manifest.json +44 -19
- package/dist/session/session.d.ts +68 -0
- package/dist/session/session.d.ts.map +1 -0
- package/dist/testing/test-adapter.d.ts +59 -0
- package/dist/testing/test-adapter.d.ts.map +1 -0
- package/dist/testing.d.ts +9 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +76 -0
- package/dist/testing.js.map +1 -0
- package/dist/tip/index.d.ts +22 -0
- package/dist/tip/index.d.ts.map +1 -0
- package/dist/tip/mount.d.ts +5 -0
- package/dist/tip/mount.d.ts.map +1 -0
- package/dist/tip.js +137 -0
- package/dist/tip.js.map +1 -0
- package/dist/transport/transport.d.ts +46 -0
- package/dist/transport/transport.d.ts.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/viceme.min.js +212 -1
- package/dist/viceme.min.js.map +1 -1
- package/package.json +10 -2
- package/dist/chunks/version-BbUa2jZV.js.map +0 -1
- package/dist/loader/mount-handle.d.ts +0 -25
- package/dist/loader/mount-handle.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-Cbldd7F2.js","sources":["../../src/core/config.ts","../../src/core/lifecycle.ts","../../src/session/session.ts","../../src/core/presentation.ts","../../src/core/capabilities.ts","../../src/core/client.ts"],"sourcesContent":["/**\n * Public client configuration.\n *\n * Production `createViceMe()` accepts exactly `workKey`, `region`, and\n * `signal`. Anything else (transport, clock, request ids, base URLs) is a\n * testing-only concern and lives in `@viceme-ai/sdk/testing`, so Agents can\n * never bake temporary or internal endpoints into user projects.\n */\n\nimport { configInvalid } from './errors.ts';\nimport { BUILD_API_BASE_URLS } from './build-endpoints.ts';\nexport type ViceMeRegion = 'cn' | 'global';\n\nexport interface ViceMeConfig {\n /** Public opaque work key (`wrk_…`). Locates a Work; it is not a secret. */\n workKey: string;\n /** Routes public API and CDN traffic. */\n region: ViceMeRegion;\n /** Optional abort signal owned by the host page. */\n signal?: AbortSignal;\n}\n\nconst REGIONS: ReadonlySet<string> = new Set(['cn', 'global']);\n\n/**\n * Public API origins per region. These are the only production endpoints the\n * SDK may contact; B1 confirms final hostnames and any change happens here in\n * one place (never via a public `apiBaseUrl` option).\n */\nexport const PUBLIC_API_BASE_URLS: Readonly<Record<ViceMeRegion, string>> = {\n cn: BUILD_API_BASE_URLS.cn,\n global: BUILD_API_BASE_URLS.global,\n};\n\nexport function resolveApiBaseUrl(region: ViceMeRegion): string {\n return PUBLIC_API_BASE_URLS[region];\n}\n\nexport function isValidWorkKey(value: unknown): value is string {\n return typeof value === 'string' && /^wrk_[A-Za-z0-9_-]{4,124}$/.test(value);\n}\n\nexport function isValidRegion(value: unknown): value is ViceMeRegion {\n return typeof value === 'string' && REGIONS.has(value);\n}\n\n/**\n * Validate unknown input as a public client config. Throws a CONFIG_INVALID\n * ViceMeError that never echoes values back beyond the offending field name.\n */\nexport function validatePublicConfig(input: unknown): ViceMeConfig {\n if (typeof input !== 'object' || input === null) {\n throw configInvalid('createViceMe expects a configuration object.');\n }\n const raw = input as Record<string, unknown>;\n\n const known = new Set(['workKey', 'region', 'signal']);\n for (const key of Object.keys(raw)) {\n if (!known.has(key)) {\n throw configInvalid(`Unknown configuration field \"${key}\".`);\n }\n }\n if (!isValidWorkKey(raw.workKey)) {\n throw configInvalid('Configuration field \"workKey\" must be a public work key (\"wrk_…\").');\n }\n if (!isValidRegion(raw.region)) {\n throw configInvalid('Configuration field \"region\" must be \"cn\" or \"global\".');\n }\n if (raw.signal !== undefined && !(raw.signal instanceof AbortSignal)) {\n throw configInvalid('Configuration field \"signal\" must be an AbortSignal.');\n }\n return {\n workKey: raw.workKey,\n region: raw.region,\n signal: raw.signal,\n };\n}\n","/**\n * Client lifecycle state machine.\n *\n * ```text\n * CREATED -> READY -> DESTROYED\n * READY -> DEGRADED (single capability unavailable; host page keeps working)\n * ```\n *\n * State is exposed read-only; consumers can never assign it directly.\n */\n\nimport { ViceMeError, clientDestroyed } from './errors.ts';\n\nexport type ViceMeClientState = 'CREATED' | 'READY' | 'DEGRADED' | 'DESTROYED';\n\nconst ALLOWED_TRANSITIONS: Readonly<Record<ViceMeClientState, readonly ViceMeClientState[]>> = {\n CREATED: ['READY', 'DESTROYED'],\n READY: ['DEGRADED', 'DESTROYED'],\n DEGRADED: ['DESTROYED'],\n DESTROYED: [],\n};\n\nexport type LifecycleListener = (state: ViceMeClientState) => void;\n\nexport class Lifecycle {\n #state: ViceMeClientState = 'CREATED';\n #listeners = new Set<LifecycleListener>();\n\n get state(): ViceMeClientState {\n return this.#state;\n }\n\n get destroyed(): boolean {\n return this.#state === 'DESTROYED';\n }\n\n transition(next: ViceMeClientState): void {\n if (next === this.#state) return;\n if (!ALLOWED_TRANSITIONS[this.#state]!.includes(next)) {\n throw new ViceMeError({\n code: 'INTERNAL_ERROR',\n message: `Illegal lifecycle transition ${this.#state} -> ${next}.`,\n retryable: false,\n });\n }\n this.#state = next;\n for (const listener of this.#listeners) listener(next);\n }\n\n /** Any operation on a destroyed client must fail closed with this guard. */\n assertAlive(): void {\n if (this.destroyed) throw clientDestroyed();\n }\n\n subscribe(listener: LifecycleListener): () => void {\n this.#listeners.add(listener);\n return () => {\n this.#listeners.delete(listener);\n };\n }\n\n clearListeners(): void {\n this.#listeners.clear();\n }\n}\n","/**\n * Public visitor session.\n *\n * ```text\n * SDK + workKey + Origin -> POST /v1/public/work-sdk/sessions\n * -> short-lived capability token -> public capability calls\n * ```\n *\n * The token lives in memory only (never localStorage/cookies), is bound to the\n * Work, Origin, capability set, and expiry by the server, and is dropped on\n * `destroy()`. `workKey` locates the Work — it is never an authorization\n * credential.\n */\n\nimport { ViceMeError } from '../core/errors.ts';\nimport type { Transport, TransportRequest, TransportResponse } from '../transport/transport.ts';\nexport interface CreateWorkSessionRequestDto {\n workKey: string;\n}\n\nexport interface WorkDescriptor {\n key: string;\n /** Capability names enabled for this work. */\n capabilities: string[];\n}\n\nexport interface WorkSessionSnapshot {\n work: WorkDescriptor;\n /** Opaque short-lived capability token; memory-only. */\n token?: string;\n /** Epoch milliseconds when the token expires, when provided by the server. */\n expiresAt?: number;\n user?: WorkUser;\n userToken?: string;\n}\n\nexport interface WorkUser {\n subject: string;\n nickname: string | null;\n avatarUrl: string | null;\n}\n\nexport interface SessionManagerOptions {\n workKey: string;\n transport: Transport;\n signal?: AbortSignal;\n timeoutMs?: number;\n /** Injectable clock for tests. */\n now?: () => number;\n}\n\nfunction parseSessionResponse(body: unknown, workKey: string): WorkSessionSnapshot {\n if (typeof body !== 'object' || body === null) {\n throw malformedSessionResponse();\n }\n const raw = body as Record<string, unknown>;\n if (\n typeof raw.workKey !== 'string' ||\n !Array.isArray(raw.capabilities) ||\n !raw.capabilities.every((c) => typeof c === 'string')\n ) {\n throw malformedSessionResponse();\n }\n if (raw.workKey !== workKey) {\n throw new ViceMeError({\n code: 'WORK_NOT_FOUND',\n message: 'Work-session response did not match the requested work key.',\n retryable: false,\n });\n }\n const snapshot: WorkSessionSnapshot = {\n work: {\n key: raw.workKey,\n capabilities: raw.capabilities as string[],\n },\n };\n // Unknown extra fields are allowed and ignored (forward compatibility).\n if (typeof raw.token === 'string') snapshot.token = raw.token;\n if (typeof raw.expiresAt === 'string') {\n const expiresAt = new Date(raw.expiresAt).getTime();\n if (!Number.isNaN(expiresAt)) snapshot.expiresAt = expiresAt;\n }\n return snapshot;\n}\n\nfunction malformedSessionResponse(): ViceMeError {\n return new ViceMeError({\n code: 'INTERNAL_ERROR',\n message: 'Malformed work-session response.',\n retryable: true,\n });\n}\n\nexport class SessionManager {\n readonly #options: SessionManagerOptions;\n readonly #now: () => number;\n #snapshot: WorkSessionSnapshot | undefined;\n #pending: Promise<WorkSessionSnapshot> | undefined;\n\n constructor(options: SessionManagerOptions) {\n this.#options = options;\n this.#now = options.now ?? (() => Date.now());\n }\n\n get snapshot(): WorkSessionSnapshot | undefined {\n return this.#snapshot;\n }\n\n /** True when the cached snapshot's server-provided expiry has passed. */\n #isExpired(): boolean {\n const expiresAt = this.#snapshot?.expiresAt;\n return expiresAt !== undefined && expiresAt <= this.#now();\n }\n\n /**\n * Establish (or return the established) public session.\n *\n * A cached snapshot is reused only while it is unexpired; an expired\n * snapshot is dropped and re-authenticated. Concurrent callers share one\n * in-flight request (single flight).\n */\n establish(): Promise<WorkSessionSnapshot> {\n if (this.#snapshot) {\n if (!this.#isExpired()) return Promise.resolve(this.#snapshot);\n this.#snapshot = undefined;\n }\n this.#pending ??= this.#options.transport\n .request({\n method: 'POST',\n path: '/v1/public/work-sdk/sessions',\n body: { workKey: this.#options.workKey } satisfies CreateWorkSessionRequestDto,\n signal: this.#options.signal,\n timeoutMs: this.#options.timeoutMs,\n })\n .then((response) => {\n const snapshot = parseSessionResponse(response.body, this.#options.workKey);\n this.#snapshot = snapshot;\n return snapshot;\n })\n .finally(() => {\n this.#pending = undefined;\n });\n return this.#pending;\n }\n\n async request(\n request: Omit<TransportRequest, 'authorization' | 'userAuthorization' | 'signal'>,\n ): Promise<TransportResponse> {\n const snapshot = await this.establish();\n if (!snapshot.token) throw malformedSessionResponse();\n try {\n return await this.#options.transport.request({\n ...request,\n authorization: snapshot.token,\n userAuthorization: snapshot.userToken,\n signal: this.#options.signal,\n });\n } catch (error) {\n if (!(error instanceof ViceMeError) || error.code !== 'SESSION_EXPIRED') throw error;\n if (this.#snapshot === snapshot) this.invalidate();\n const refreshed = await this.establish();\n if (!refreshed.token) throw malformedSessionResponse();\n return this.#options.transport.request({\n ...request,\n authorization: refreshed.token,\n userAuthorization: refreshed.userToken,\n signal: this.#options.signal,\n });\n }\n }\n\n authenticate(input: { userToken: string; user: WorkUser }): void {\n if (!this.#snapshot) throw malformedSessionResponse();\n this.#snapshot = {\n ...this.#snapshot,\n userToken: input.userToken,\n user: input.user,\n };\n }\n\n async signOut(): Promise<void> {\n this.invalidate();\n await this.establish();\n }\n\n /** Drop the token; next `establish()` re-authenticates. */\n invalidate(): void {\n this.#snapshot = undefined;\n }\n\n /** Hard cleanup: forget the token and pending work. */\n destroy(): void {\n this.invalidate();\n this.#pending = undefined;\n }\n}\n","import type { FollowTarget } from './capabilities.ts';\nimport { isViceMeError } from './errors.ts';\n\nexport type AccessInteractionAction = 'SIGN_IN' | 'FOLLOW' | 'CHECKOUT';\n\nexport interface AccessInteraction {\n featureKey: string;\n reason: string;\n action: AccessInteractionAction;\n followTarget?: FollowTarget;\n perform(): Promise<AccessActionResult>;\n}\n\nexport interface AccessCompletedAction {\n type: 'completed';\n}\n\nexport interface AccessFrameAction {\n type: 'frame';\n url: string;\n completion: Promise<void>;\n cancel(): void;\n}\n\nexport interface AccessExternalAction {\n type: 'external';\n completion: Promise<void>;\n cancel(): void;\n}\n\nexport type AccessActionResult = AccessCompletedAction | AccessFrameAction | AccessExternalAction;\n\nexport type AccessPresentationResult = 'acted' | 'dismissed';\n\n/** Internal interaction seam used by the ViceMe layer and deterministic tests. */\nexport type AccessPresenter = (interaction: AccessInteraction) => Promise<AccessPresentationResult>;\n\nconst ELEMENT_NAME = 'viceme-access-layer';\nconst PROFILE_DESCRIPTION_LIMIT = 50;\n\ninterface AccessLayerElement extends HTMLElement {\n interaction: AccessInteraction;\n}\n\nfunction actionCopy(action: AccessInteractionAction): {\n description: string;\n label: string;\n} {\n switch (action) {\n case 'SIGN_IN':\n return {\n description: '',\n label: '授权',\n };\n case 'FOLLOW':\n return {\n description: '',\n label: '关注',\n };\n case 'CHECKOUT':\n return {\n description: '',\n label: '打开支付',\n };\n }\n}\n\nfunction actionErrorCopy(error: unknown): string {\n if (!isViceMeError(error)) return '操作未完成,请重试。';\n switch (error.code) {\n case 'CONFIG_INVALID':\n return '微信授权配置无效,请稍后重试。';\n case 'AUTH_CANCELLED':\n return '微信授权已取消,请重试。';\n case 'SESSION_EXPIRED':\n return '授权会话已过期,请重试。';\n case 'NETWORK_TIMEOUT':\n return '网络连接超时,请重试。';\n default:\n return error.requestId\n ? `操作未完成,请重试。请求 ID:${error.requestId}`\n : '操作未完成,请重试。';\n }\n}\n\nfunction ensureAccessLayerElement(): void {\n if (customElements.get(ELEMENT_NAME)) return;\n\n class ViceMeAccessLayerElement extends HTMLElement implements AccessLayerElement {\n interaction!: AccessInteraction;\n\n connectedCallback(): void {\n const copy = actionCopy(this.interaction.action);\n const shadow = this.attachShadow({ mode: 'open' });\n shadow.innerHTML = `\n <style>\n :host {\n position: fixed;\n inset: 0;\n z-index: 2147483000;\n display: grid;\n align-items: end;\n color: #18181b;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"PingFang SC\", \"Hiragino Sans GB\", \"Microsoft YaHei\", sans-serif;\n font-size: 16px;\n line-height: 1.5;\n }\n [data-viceme='backdrop'] {\n position: absolute;\n inset: 0;\n border: 0;\n border-radius: 0;\n background: transparent;\n }\n [data-viceme='panel'] {\n position: relative;\n box-sizing: border-box;\n display: flex;\n width: 100%;\n max-height: min(92dvh, 46rem);\n flex-direction: column;\n overflow: auto;\n border-radius: 1.25rem 1.25rem 0 0;\n background: #ffffff;\n color: #18181b;\n padding: 3.75rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));\n box-shadow: 0 -1rem 3rem rgb(0 0 0 / 18%);\n }\n [data-viceme='content'] { display: flex; min-height: 0; flex-direction: column; }\n [data-viceme='close'] {\n position: absolute;\n top: 0.75rem;\n left: 0.75rem;\n width: 2.75rem;\n height: 2.75rem;\n border: 0;\n border-radius: 999px;\n padding: 0;\n background: transparent;\n color: #52525b;\n font-size: 2rem;\n font-weight: 400;\n line-height: 1;\n }\n [data-viceme='description'] { margin: 0.75rem 0 1.25rem; color: #71717a; line-height: 1.6; }\n [data-viceme='profile'] {\n display: none;\n margin: 0;\n border: 1px solid #e4e4e7;\n border-radius: 1rem;\n padding: 1.5rem;\n background: #ffffff;\n box-shadow: 0 0.75rem 2rem rgb(0 0 0 / 6%);\n text-align: center;\n }\n [data-viceme='profile'][data-visible='true'] { display: block; }\n [data-viceme='avatar'] {\n display: block;\n width: 5.5rem;\n height: 5.5rem;\n margin: 0 auto 1rem;\n border-radius: 999px;\n object-fit: cover;\n background: #f4f4f5;\n }\n [data-viceme='avatar-fallback'] {\n display: grid;\n width: 5.5rem;\n height: 5.5rem;\n margin: 0 auto 1rem;\n place-items: center;\n border-radius: 999px;\n background: #f4f4f5;\n color: #18181b;\n font-size: 2rem;\n font-weight: 700;\n }\n [data-viceme='avatar'][hidden], [data-viceme='avatar-fallback'][hidden] { display: none; }\n [data-viceme='profile-summary'] {\n display: flex;\n min-width: 0;\n align-items: baseline;\n justify-content: center;\n gap: 0.5rem;\n }\n [data-viceme='profile-name'] { margin: 0; font-size: 1.375rem; font-weight: 700; }\n [data-viceme='profile-separator'], [data-viceme='profile-stats'] {\n color: #71717a;\n }\n [data-viceme='profile-description'] {\n margin: 0.25rem 0 0;\n overflow-wrap: anywhere;\n color: #71717a;\n }\n [data-viceme='profile-description']:empty { display: none; }\n [data-viceme='profile-stats'] {\n margin: 0;\n font-size: 0.875rem;\n }\n [data-viceme='profile-header'] { min-width: 0; }\n [data-viceme='panel'][data-action='SIGN_IN'] [data-viceme='description'] { display: none; }\n [data-viceme='panel'][data-action='SIGN_IN'] [data-viceme='profile'][data-visible='true'] {\n display: block;\n border: 0;\n padding: 0;\n background: transparent;\n box-shadow: none;\n text-align: center;\n }\n [data-viceme='panel'][data-action='SIGN_IN'] [data-viceme='profile-name'] {\n font-size: 1.125rem;\n }\n [data-viceme='panel'][data-action='SIGN_IN'] [data-viceme='profile-description'] {\n margin-top: 0.75rem;\n line-height: 1.625;\n }\n [data-viceme='panel'][data-action='SIGN_IN'] [data-viceme='action'] {\n width: 100%;\n }\n [data-viceme='actions'] {\n display: flex;\n justify-content: flex-end;\n gap: 0.75rem;\n margin-top: 1.25rem;\n }\n button {\n box-sizing: border-box;\n display: inline-flex;\n height: 3.25rem;\n align-items: center;\n justify-content: center;\n border-radius: 0.75rem;\n padding: 0.625rem 1rem;\n font: 600 1rem/1.5 -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"PingFang SC\", \"Hiragino Sans GB\", \"Microsoft YaHei\", sans-serif;\n cursor: pointer;\n }\n button:focus-visible, iframe:focus-visible { outline: 2px solid #18181b; outline-offset: 2px; }\n [data-viceme='action'] {\n width: min(11rem, 48%);\n border: 1px solid #18181b;\n background: #18181b;\n color: #ffffff;\n }\n [data-viceme='action']:hover { background: #3f3f46; border-color: #3f3f46; }\n [data-viceme='actions'][data-single='true'] [data-viceme='action'] { width: 100%; }\n button:disabled { cursor: wait; opacity: 0.5; }\n button[hidden] { display: none; }\n [data-viceme='error'] { margin: 0.75rem 0 0; color: #b91c1c; font-size: 0.875rem; }\n [data-viceme='error']:empty { display: none; }\n [data-viceme='frame'] {\n display: none;\n width: 100%;\n min-height: 0;\n flex: 1 1 auto;\n border: 0;\n border-radius: 0.75rem;\n background: #ffffff;\n }\n [data-viceme='panel'][data-frame='true'] {\n height: min(92dvh, 46rem);\n max-height: 92dvh;\n overflow: hidden;\n }\n [data-viceme='panel'][data-frame='true'] [data-viceme='content'] { display: none; }\n [data-viceme='panel'][data-frame='true'] [data-viceme='frame'] { display: block; }\n @media (min-width: 48rem) {\n :host { place-items: center; padding: 1.5rem; }\n [data-viceme='panel'] {\n width: min(24rem, 100%);\n border-radius: 1.25rem;\n padding: 3.75rem 1.25rem 1.25rem;\n box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 24%);\n }\n [data-viceme='panel'][data-frame='true'] { width: min(30rem, 100%); }\n [data-viceme='panel'][data-action='SIGN_IN'] { width: min(30rem, 100%); }\n }\n @media (prefers-reduced-motion: no-preference) {\n [data-viceme='panel'] { animation: viceme-enter 160ms ease-out; }\n @keyframes viceme-enter { from { opacity: 0; transform: translateY(1rem); } }\n }\n </style>\n <button data-viceme=\"backdrop\" type=\"button\" tabindex=\"-1\" aria-label=\"关闭\"></button>\n <section data-viceme=\"panel\" role=\"dialog\" aria-modal=\"true\" aria-label=\"ViceMe 授权\">\n <button data-viceme=\"close\" type=\"button\" aria-label=\"关闭\">×</button>\n <div data-viceme=\"content\">\n <p data-viceme=\"description\"></p>\n <section data-viceme=\"profile\" aria-label=\"创作者\">\n <div data-viceme=\"profile-header\">\n <img data-viceme=\"avatar\" hidden />\n <span data-viceme=\"avatar-fallback\" aria-hidden=\"true\"></span>\n <div data-viceme=\"profile-summary\">\n <p data-viceme=\"profile-name\"></p>\n <span data-viceme=\"profile-separator\" aria-hidden=\"true\">·</span>\n <p data-viceme=\"profile-stats\"></p>\n </div>\n </div>\n <p data-viceme=\"profile-description\"></p>\n </section>\n <p data-viceme=\"error\" role=\"alert\" aria-live=\"polite\"></p>\n <div data-viceme=\"actions\">\n <button data-viceme=\"action\" type=\"button\"></button>\n </div>\n </div>\n <iframe data-viceme=\"frame\" title=\"\" referrerpolicy=\"no-referrer\" allow=\"payment\"></iframe>\n </section>\n `;\n const panel = shadow.querySelector<HTMLElement>(\"[data-viceme='panel']\")!;\n panel.dataset.action = this.interaction.action;\n panel.dataset.frame = 'false';\n const description = shadow.querySelector<HTMLElement>(\"[data-viceme='description']\")!;\n description.textContent = copy.description;\n const action = shadow.querySelector<HTMLButtonElement>(\"[data-viceme='action']\")!;\n const mainActions = action.parentElement!;\n const closeAction = shadow.querySelector<HTMLButtonElement>(\"[data-viceme='close']\")!;\n const backdrop = shadow.querySelector<HTMLButtonElement>(\"[data-viceme='backdrop']\")!;\n const error = shadow.querySelector<HTMLElement>(\"[data-viceme='error']\")!;\n const frame = shadow.querySelector<HTMLIFrameElement>(\"[data-viceme='frame']\")!;\n const profile = shadow.querySelector<HTMLElement>(\"[data-viceme='profile']\")!;\n const avatar = shadow.querySelector<HTMLImageElement>(\"[data-viceme='avatar']\")!;\n const avatarFallback = shadow.querySelector<HTMLElement>(\"[data-viceme='avatar-fallback']\")!;\n const profileName = shadow.querySelector<HTMLElement>(\"[data-viceme='profile-name']\")!;\n const profileDescription = shadow.querySelector<HTMLElement>(\n \"[data-viceme='profile-description']\",\n )!;\n const profileStats = shadow.querySelector<HTMLElement>(\"[data-viceme='profile-stats']\")!;\n action.textContent = copy.label;\n action.hidden = false;\n mainActions.dataset.single = 'true';\n const idleActionLabel = copy.label;\n frame.title = this.interaction.action === 'SIGN_IN' ? '登录授权' : '支付';\n\n const target = this.interaction.followTarget;\n if (target) {\n panel.setAttribute(\n 'aria-label',\n this.interaction.action === 'SIGN_IN'\n ? `授权 ${target.displayName}`\n : `关注 ${target.displayName}`,\n );\n profile.dataset.visible = 'true';\n profileName.textContent = target.displayName;\n const descriptionCharacters = [...(target.description ?? '')];\n profileDescription.textContent =\n descriptionCharacters.length > PROFILE_DESCRIPTION_LIMIT\n ? `${descriptionCharacters.slice(0, PROFILE_DESCRIPTION_LIMIT).join('')}…`\n : descriptionCharacters.join('');\n if (descriptionCharacters.length > PROFILE_DESCRIPTION_LIMIT) {\n profileDescription.title = target.description!;\n }\n profileStats.textContent = `${target.workCount} 个作品`;\n avatarFallback.textContent = target.displayName.trim().slice(0, 1) || 'V';\n if (target.avatarUrl) {\n avatar.src = target.avatarUrl;\n avatar.alt = `${target.displayName}的头像`;\n avatar.hidden = false;\n avatarFallback.hidden = true;\n }\n }\n\n let activeAction: AccessFrameAction | AccessExternalAction | null = null;\n const close = (result: AccessPresentationResult) => {\n this.dispatchEvent(new CustomEvent('viceme:access-layer-close', { detail: result }));\n };\n const dismissLayer = () => {\n activeAction?.cancel();\n close('dismissed');\n };\n backdrop.addEventListener('click', dismissLayer);\n closeAction.addEventListener('click', dismissLayer);\n this.addEventListener('keydown', (event) => {\n if (event.key === 'Escape') dismissLayer();\n if (event.key === 'Tab') {\n event.preventDefault();\n if (activeAction?.type === 'frame') {\n frame.focus();\n return;\n }\n const focusable = [closeAction, ...(action.hidden ? [] : [action])];\n const available = focusable.filter((element) => !element.disabled && !element.hidden);\n if (available.length === 0) return;\n const currentIndex = available.indexOf(shadow.activeElement as HTMLButtonElement);\n const direction = event.shiftKey ? -1 : 1;\n available[(currentIndex + direction + available.length) % available.length]?.focus();\n }\n });\n const performAction = async () => {\n action.disabled = true;\n action.setAttribute('aria-busy', 'true');\n action.textContent = '正在打开…';\n error.textContent = '';\n try {\n const result = await this.interaction.perform();\n if (result.type === 'frame') {\n activeAction = result;\n panel.dataset.frame = 'true';\n frame.src = result.url;\n frame.focus();\n await result.completion;\n } else if (result.type === 'external') {\n activeAction = result;\n await result.completion;\n }\n close('acted');\n } catch (caught) {\n activeAction?.cancel();\n activeAction = null;\n panel.dataset.frame = 'false';\n frame.removeAttribute('src');\n error.textContent = actionErrorCopy(caught);\n action.hidden = false;\n action.disabled = false;\n action.removeAttribute('aria-busy');\n action.textContent = idleActionLabel;\n action.focus();\n }\n };\n action.addEventListener('click', performAction);\n queueMicrotask(() => action.focus());\n }\n }\n\n customElements.define(ELEMENT_NAME, ViceMeAccessLayerElement);\n}\n\nexport const defaultAccessPresenter: AccessPresenter = async (interaction) => {\n if (typeof document === 'undefined' || typeof customElements === 'undefined') {\n return 'dismissed';\n }\n ensureAccessLayerElement();\n const element = document.createElement(ELEMENT_NAME) as AccessLayerElement;\n element.interaction = interaction;\n const previousOverflow = document.documentElement.style.overflow;\n const previousFocus =\n document.activeElement instanceof HTMLElement ? document.activeElement : null;\n document.documentElement.style.overflow = 'hidden';\n document.body.append(element);\n try {\n return await new Promise<AccessPresentationResult>((resolve) => {\n element.addEventListener(\n 'viceme:access-layer-close',\n (event) => resolve((event as CustomEvent<AccessPresentationResult>).detail),\n { once: true },\n );\n });\n } finally {\n element.remove();\n document.documentElement.style.overflow = previousOverflow;\n previousFocus?.focus();\n }\n};\n","import { ViceMeError } from './errors.ts';\nimport {\n defaultAccessPresenter,\n type AccessActionResult,\n type AccessFrameAction,\n type AccessPresenter,\n} from './presentation.ts';\nimport type { SessionManager, WorkUser } from '../session/session.ts';\n\nexport interface AuthState {\n authenticated: boolean;\n user: WorkUser | null;\n}\n\nexport interface FollowState {\n following: boolean;\n followedAt: string | null;\n target: FollowTarget;\n}\n\nexport interface FollowTarget {\n kind: 'CREATOR' | 'USER';\n displayName: string;\n avatarUrl: string | null;\n description: string | null;\n workCount: number;\n}\n\nexport type AccessReason =\n | 'PUBLIC'\n | 'OWNER'\n | 'FOLLOWING'\n | 'ENTITLED'\n | 'AUTH_REQUIRED'\n | 'FOLLOW_REQUIRED'\n | 'PURCHASE_REQUIRED'\n | 'FEATURE_NOT_FOUND'\n | 'FEATURE_DISABLED';\n\nexport interface AccessDecision {\n allowed: boolean;\n reason: AccessReason;\n nextAction: 'SIGN_IN' | 'FOLLOW' | 'CHECKOUT' | null;\n}\n\nexport type AccessPolicyType = 'PUBLIC' | 'FOLLOW_OWNER' | 'WORK_ENTITLEMENT';\n\nexport interface AccessFeaturePresentation {\n featureKey: string;\n title: string;\n policy: { type: AccessPolicyType };\n price: { amountCents: number; currency: 'CNY' } | null;\n}\n\nexport interface CheckoutOptions {\n featureKey: string;\n locale?: 'zh-CN' | 'en-US';\n}\n\nexport interface CheckoutResult {\n checkoutUrl: string;\n alreadyOwned: boolean;\n}\n\nexport interface AuthCapability {\n getState(): Promise<AuthState>;\n signIn(): Promise<AuthState>;\n signOut(): Promise<void>;\n}\n\nexport interface FollowCapability {\n getState(): Promise<FollowState>;\n follow(): Promise<FollowState>;\n unfollow(): Promise<FollowState>;\n}\n\nexport interface AccessCapability {\n getFeatures(): Promise<AccessFeaturePresentation[]>;\n check(featureKey: string): Promise<AccessDecision>;\n checkMany(featureKeys: string[]): Promise<Record<string, AccessDecision>>;\n require(featureKey: string): Promise<AccessDecision>;\n refresh(): Promise<void>;\n}\n\nexport interface CheckoutCapability {\n open(options: CheckoutOptions): Promise<CheckoutResult>;\n}\n\ninterface CapabilityDeps {\n session: SessionManager;\n workKey: string;\n widgetOrigin: string;\n presenter?: AccessPresenter;\n ready: () => Promise<void>;\n}\n\nfunction objectBody(value: unknown): Record<string, unknown> {\n if (typeof value !== 'object' || value === null) throw malformedResponse();\n return value as Record<string, unknown>;\n}\n\nfunction malformedResponse(): ViceMeError {\n return new ViceMeError({\n code: 'INTERNAL_ERROR',\n message: 'Malformed public API response.',\n retryable: true,\n });\n}\n\nfunction parseUser(value: unknown): WorkUser {\n const body = objectBody(value);\n if (\n typeof body.id !== 'string' ||\n !(typeof body.displayName === 'string' || body.displayName === null) ||\n !(typeof body.avatarUrl === 'string' || body.avatarUrl === null)\n ) {\n throw malformedResponse();\n }\n return {\n subject: body.id,\n nickname: body.displayName,\n avatarUrl: body.avatarUrl,\n };\n}\n\nfunction parseFollowState(value: unknown): FollowState {\n const body = objectBody(value);\n if (\n typeof body.following !== 'boolean' ||\n !(typeof body.followedAt === 'string' || body.followedAt === null)\n ) {\n throw malformedResponse();\n }\n const target = objectBody(body.creator);\n if (\n typeof target.displayName !== 'string' ||\n !(typeof target.avatarUrl === 'string' || target.avatarUrl === null) ||\n !(typeof target.description === 'string' || target.description === null) ||\n !Number.isInteger(target.publishedWorkCount) ||\n (target.publishedWorkCount as number) < 0\n ) {\n throw malformedResponse();\n }\n return {\n following: body.following,\n followedAt: body.followedAt,\n target: {\n kind: 'CREATOR',\n displayName: target.displayName,\n avatarUrl: target.avatarUrl,\n description: target.description,\n workCount: target.publishedWorkCount as number,\n },\n };\n}\n\nfunction parseDecision(value: unknown): AccessDecision {\n const body = objectBody(value);\n const reasons: ReadonlySet<string> = new Set([\n 'PUBLIC',\n 'OWNER',\n 'FOLLOWING',\n 'ENTITLED',\n 'AUTH_REQUIRED',\n 'FOLLOW_REQUIRED',\n 'PURCHASE_REQUIRED',\n 'FEATURE_NOT_FOUND',\n 'FEATURE_DISABLED',\n ]);\n const actions: ReadonlySet<unknown> = new Set([null, 'SIGN_IN', 'FOLLOW', 'CHECKOUT']);\n if (\n typeof body.allowed !== 'boolean' ||\n typeof body.reason !== 'string' ||\n !reasons.has(body.reason) ||\n !actions.has(body.nextAction)\n ) {\n throw malformedResponse();\n }\n return {\n allowed: body.allowed,\n reason: body.reason as AccessReason,\n nextAction: body.nextAction as AccessDecision['nextAction'],\n };\n}\n\nfunction parseFeaturePresentation(value: unknown): AccessFeaturePresentation {\n const body = objectBody(value);\n if (\n typeof body.featureKey !== 'string' ||\n !/^[a-z][a-z0-9_-]{1,63}$/.test(body.featureKey) ||\n typeof body.title !== 'string' ||\n body.title.trim().length === 0 ||\n body.title.length > 120 ||\n !(\n body.policyType === 'PUBLIC' ||\n body.policyType === 'FOLLOW_OWNER' ||\n body.policyType === 'WORK_ENTITLEMENT'\n )\n ) {\n throw malformedResponse();\n }\n const price = body.price === null ? null : objectBody(body.price);\n if (\n price !== null &&\n (!Number.isInteger(price.amountCents) ||\n (price.amountCents as number) <= 0 ||\n price.currency !== 'CNY')\n ) {\n throw malformedResponse();\n }\n if ((body.policyType === 'WORK_ENTITLEMENT') !== (price !== null)) {\n throw malformedResponse();\n }\n return {\n featureKey: body.featureKey,\n title: body.title,\n policy: { type: body.policyType },\n price: price === null ? null : { amountCents: price.amountCents as number, currency: 'CNY' },\n };\n}\n\nfunction randomVerifier(): string {\n const bytes = crypto.getRandomValues(new Uint8Array(32));\n return base64Url(bytes);\n}\n\nfunction base64Url(bytes: Uint8Array): string {\n let binary = '';\n for (const byte of bytes) binary += String.fromCharCode(byte);\n return btoa(binary).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');\n}\n\nfunction resolveLocale(): 'zh-CN' | 'en-US' {\n return typeof document !== 'undefined' && document.documentElement.lang.toLowerCase() === 'en-us'\n ? 'en-US'\n : 'zh-CN';\n}\n\nexport function createCapabilities(deps: CapabilityDeps): {\n auth: AuthCapability;\n follow: FollowCapability;\n access: AccessCapability;\n checkout: CheckoutCapability;\n} {\n const cancelled = () =>\n new ViceMeError({\n code: 'AUTH_CANCELLED',\n message: 'The interactive action was cancelled.',\n retryable: false,\n });\n\n const embeddedFrame = (\n url: string,\n completionOrigin: string,\n channel: string,\n type: 'auth',\n initialization: Record<string, unknown>,\n complete: (data: Record<string, unknown>) => Promise<void>,\n ): AccessFrameAction => {\n if (typeof window === 'undefined') {\n throw new ViceMeError({\n code: 'CONFIG_INVALID',\n message: 'Interactive access requires a browser window.',\n retryable: false,\n });\n }\n let active = true;\n let settle!: () => void;\n let fail!: (error: unknown) => void;\n const cleanup = () => {\n if (!active) return;\n active = false;\n window.removeEventListener('message', receive);\n };\n const completion = new Promise<void>((resolve, reject) => {\n settle = resolve;\n fail = reject;\n });\n const receive = (event: MessageEvent) => {\n if (!active || event.origin !== completionOrigin) return;\n if (typeof event.data !== 'object' || event.data === null) return;\n const data = event.data as Record<string, unknown>;\n if (data.workKey !== deps.workKey || data.channel !== channel) return;\n if (data.type === `viceme:${type}:ready`) {\n if (event.source && 'postMessage' in event.source) {\n (event.source as WindowProxy).postMessage(\n {\n type: `viceme:${type}:init`,\n workKey: deps.workKey,\n channel,\n ...initialization,\n },\n completionOrigin,\n );\n }\n return;\n }\n if (data.type === `viceme:${type}:cancelled`) {\n cleanup();\n fail(cancelled());\n return;\n }\n if (data.type !== `viceme:${type}:complete`) return;\n cleanup();\n void complete(data).then(settle, fail);\n };\n window.addEventListener('message', receive);\n return {\n type: 'frame',\n url,\n completion,\n cancel() {\n cleanup();\n settle();\n },\n };\n };\n\n const startSignIn = async (): Promise<AccessActionResult> => {\n await deps.ready();\n if (typeof window === 'undefined') {\n throw new ViceMeError({\n code: 'CONFIG_INVALID',\n message: 'Interactive access requires a browser window.',\n retryable: false,\n });\n }\n const channel = randomVerifier();\n const authorizationUrl = new URL('/sdk/login', deps.widgetOrigin);\n authorizationUrl.search = new URLSearchParams({\n workKey: deps.workKey,\n channel,\n parentOrigin: window.location.origin,\n locale: resolveLocale(),\n }).toString();\n const workSessionToken = deps.session.snapshot?.token;\n if (!workSessionToken) throw malformedResponse();\n return embeddedFrame(\n authorizationUrl.toString(),\n deps.widgetOrigin,\n channel,\n 'auth',\n { workSessionToken },\n async (data) => {\n if (typeof data.userToken !== 'string') {\n throw malformedResponse();\n }\n deps.session.authenticate({ userToken: data.userToken, user: parseUser(data.user) });\n },\n );\n };\n\n const getFollowState = async (): Promise<FollowState> => {\n await deps.ready();\n return parseFollowState(\n (await deps.session.request({ method: 'GET', path: '/v1/public/work-sdk/follow' })).body,\n );\n };\n\n const updateFollow = async (): Promise<FollowState> => {\n await deps.ready();\n return parseFollowState(\n (await deps.session.request({ method: 'PUT', path: '/v1/public/work-sdk/follow' })).body,\n );\n };\n\n const auth: AuthCapability = {\n async getState() {\n await deps.ready();\n const user = deps.session.snapshot?.user ?? null;\n return { authenticated: user !== null, user };\n },\n async signIn() {\n const presenter = deps.presenter ?? defaultAccessPresenter;\n const result = await presenter({\n featureKey: 'auth',\n reason: 'AUTH_REQUIRED',\n action: 'SIGN_IN',\n perform: startSignIn,\n });\n if (result === 'dismissed') throw cancelled();\n return this.getState();\n },\n async signOut() {\n await deps.ready();\n await deps.session.signOut();\n },\n };\n\n const follow: FollowCapability = {\n getState: getFollowState,\n follow: updateFollow,\n unfollow: async () => {\n throw new ViceMeError({\n code: 'CAPABILITY_DISABLED',\n message: 'Unfollow is not exposed by website access.',\n retryable: false,\n });\n },\n };\n\n const checkMany = async (featureKeys: string[]): Promise<Record<string, AccessDecision>> => {\n await deps.ready();\n const response = objectBody(\n (\n await deps.session.request({\n method: 'POST',\n path: '/v1/public/work-sdk/access/check',\n body: { featureKeys },\n })\n ).body,\n );\n const raw = objectBody(response.decisions);\n return Object.fromEntries(\n Object.entries(raw).map(([key, value]) => [key, parseDecision(value)]),\n );\n };\n\n const createCheckout = async (\n featureKey: string,\n options: Omit<CheckoutOptions, 'featureKey'> = {},\n ): Promise<CheckoutResult> => {\n await deps.ready();\n const body = {\n featureKey,\n locale: options.locale ?? 'zh-CN',\n };\n const response = objectBody(\n (\n await deps.session.request({\n method: 'POST',\n path: '/v1/public/work-sdk/checkout',\n body,\n })\n ).body,\n );\n if (typeof response.checkoutUrl !== 'string' || typeof response.alreadyOwned !== 'boolean') {\n throw malformedResponse();\n }\n try {\n new URL(response.checkoutUrl as string);\n } catch {\n throw malformedResponse();\n }\n return {\n checkoutUrl: response.checkoutUrl,\n alreadyOwned: response.alreadyOwned,\n };\n };\n\n const openCheckout = (result: CheckoutResult, featureKey: string): AccessActionResult => {\n if (result.alreadyOwned) return { type: 'completed' };\n if (typeof window === 'undefined') {\n throw new ViceMeError({\n code: 'CONFIG_INVALID',\n message: 'Hosted checkout requires a browser window.',\n retryable: false,\n });\n }\n const checkoutWindow = window.open(result.checkoutUrl, '_blank', 'popup,width=520,height=760');\n if (!checkoutWindow) {\n throw new ViceMeError({\n code: 'AUTH_CANCELLED',\n message: 'The hosted checkout window was blocked.',\n retryable: false,\n });\n }\n\n let active = true;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let settle!: () => void;\n let fail!: (error: unknown) => void;\n const completion = new Promise<void>((resolve, reject) => {\n settle = resolve;\n fail = reject;\n });\n const poll = async () => {\n if (!active) return;\n try {\n const decision = (await checkMany([featureKey]))[featureKey];\n if (!decision) throw malformedResponse();\n if (decision.allowed) {\n active = false;\n checkoutWindow.close();\n settle();\n return;\n }\n if (checkoutWindow.closed) {\n active = false;\n fail(cancelled());\n return;\n }\n timer = setTimeout(() => void poll(), 1_500);\n } catch (error) {\n active = false;\n fail(error);\n }\n };\n timer = setTimeout(() => void poll(), 1_500);\n return {\n type: 'external',\n completion,\n cancel() {\n if (!active) return;\n active = false;\n if (timer) clearTimeout(timer);\n checkoutWindow.close();\n settle();\n },\n };\n };\n\n const checkout: CheckoutCapability = {\n async open(options) {\n const checkoutResult = await createCheckout(options.featureKey, options);\n if (checkoutResult.alreadyOwned) return checkoutResult;\n const presenter = deps.presenter ?? defaultAccessPresenter;\n const presented = await presenter({\n featureKey: options.featureKey,\n reason: 'PURCHASE_REQUIRED',\n action: 'CHECKOUT',\n perform: async () => openCheckout(checkoutResult, options.featureKey),\n });\n if (presented === 'dismissed') throw cancelled();\n return checkoutResult;\n },\n };\n\n const access: AccessCapability = {\n async getFeatures() {\n await deps.ready();\n const response = objectBody(\n (\n await deps.session.request({\n method: 'GET',\n path: '/v1/public/work-sdk/access/features',\n })\n ).body,\n );\n if (!Array.isArray(response.features) || response.features.length > 100) {\n throw malformedResponse();\n }\n return response.features.map(parseFeaturePresentation);\n },\n async check(featureKey) {\n const decisions = await checkMany([featureKey]);\n const decision = decisions[featureKey];\n if (!decision) throw malformedResponse();\n return decision;\n },\n checkMany,\n async require(featureKey) {\n let decision = await this.check(featureKey);\n const presenter = deps.presenter ?? defaultAccessPresenter;\n for (\n let attempts = 0;\n !decision.allowed && decision.nextAction && attempts < 3;\n attempts += 1\n ) {\n const nextAction = decision.nextAction;\n const followTarget = nextAction === 'FOLLOW' ? (await follow.getState()).target : undefined;\n const checkoutResult =\n nextAction === 'CHECKOUT' ? await createCheckout(featureKey) : undefined;\n if (checkoutResult?.alreadyOwned) {\n decision = await this.check(featureKey);\n continue;\n }\n const result = await presenter({\n featureKey,\n reason: decision.reason,\n action: nextAction,\n ...(followTarget ? { followTarget } : {}),\n perform: async () => {\n if (nextAction === 'SIGN_IN') {\n return startSignIn();\n } else if (nextAction === 'FOLLOW') {\n await follow.follow();\n return { type: 'completed' };\n } else {\n return openCheckout(checkoutResult!, featureKey);\n }\n },\n });\n if (result === 'dismissed') return decision;\n decision = await this.check(featureKey);\n }\n return decision;\n },\n async refresh() {\n await deps.ready();\n },\n };\n\n return { auth, follow, access, checkout };\n}\n","/**\n * ViceMe client for hosted capabilities and optional website access.\n *\n * `ready()` and access checks remain headless. Interactive authentication and\n * checkout touch `window` only when the caller explicitly invokes them. `ready()` is\n * Hosted capability initialization stays local and synchronous. Website\n * access establishes its Work session lazily on the first access operation.\n * `ready()` is idempotent per instance (shares one promise), `destroy()` is idempotent and\n * synchronously cancels requests and subscriptions; every business method on a\n * destroyed client fails with `CLIENT_DESTROYED`.\n */\n\nimport { clientDestroyed } from './errors.ts';\nimport { Lifecycle, type ViceMeClientState } from './lifecycle.ts';\nimport type { ViceMeConfig, ViceMeRegion } from './config.ts';\nimport { SessionManager } from '../session/session.ts';\nimport type { Transport } from '../transport/transport.ts';\nimport { API_MAJOR, SDK_VERSION } from '../version.ts';\nimport {\n createCapabilities,\n type AccessCapability,\n type AuthCapability,\n type CheckoutCapability,\n} from './capabilities.ts';\nimport type { AccessPresenter } from './presentation.ts';\nimport { BUILD_WIDGET_ORIGINS } from './build-endpoints.ts';\n\nexport interface ViceMeClient {\n readonly version: string;\n readonly workKey: string;\n readonly region: ViceMeRegion;\n readonly state: ViceMeClientState;\n readonly auth: AuthCapability;\n readonly access: AccessCapability;\n readonly checkout: CheckoutCapability;\n ready(): Promise<void>;\n hasCapability(name: string): boolean;\n destroy(): void;\n}\n\nexport interface ViceMeMountedInstance {\n readonly instanceKey: string;\n readonly capability: string;\n destroy(): void;\n}\n\n/** Internal loader hook; keeps degradation outside the public client contract. */\nexport function markClientDegraded(client: ViceMeClient): void {\n if (client instanceof ViceMeClientImpl) client.markDegraded();\n}\n\n/** Marker so in-flight requests cancelled by `destroy()` map to CLIENT_DESTROYED. */\nclass DestroySignalReason extends DOMException {\n constructor() {\n super('ViceMe client destroyed.', 'AbortError');\n }\n}\n\nexport interface ViceMeClientDeps {\n config: ViceMeConfig;\n transport: Transport;\n /** Interaction override for the testing entry only. */\n presenter?: AccessPresenter;\n /** Injectable clock (testing only). */\n now?: () => number;\n}\n\nexport class ViceMeClientImpl implements ViceMeClient {\n readonly #lifecycle = new Lifecycle();\n readonly #session: SessionManager;\n readonly #config: ViceMeConfig;\n readonly #internalSignal = new AbortController();\n #readyPromise: Promise<void> | undefined;\n readonly auth: AuthCapability;\n readonly access: AccessCapability;\n readonly checkout: CheckoutCapability;\n /** Detaches the caller-signal listener; undefined when none was attached. */\n #detachCallerAbort: (() => void) | undefined;\n\n constructor(deps: ViceMeClientDeps) {\n this.#config = deps.config;\n this.#session = new SessionManager({\n workKey: deps.config.workKey,\n transport: deps.transport,\n signal: this.#internalSignal.signal,\n ...(deps.now !== undefined ? { now: deps.now } : {}),\n });\n const capabilities = createCapabilities({\n session: this.#session,\n workKey: deps.config.workKey,\n widgetOrigin: BUILD_WIDGET_ORIGINS[deps.config.region],\n presenter: deps.presenter,\n ready: () => this.#readyAccess(),\n });\n this.auth = capabilities.auth;\n this.access = capabilities.access;\n this.checkout = capabilities.checkout;\n const callerSignal = deps.config.signal;\n if (callerSignal) {\n // Propagate the caller's own abort reason when one was set.\n const abortInternal = () => {\n this.#internalSignal.abort(\n callerSignal.reason instanceof Error\n ? callerSignal.reason\n : new DOMException('Caller signal aborted.', 'AbortError'),\n );\n };\n // An already-aborted signal never fires the listener; check\n // synchronously so a pre-cancelled caller cannot issue session\n // requests or reach the network at all.\n if (callerSignal.aborted) abortInternal();\n else {\n callerSignal.addEventListener('abort', abortInternal, { once: true });\n this.#detachCallerAbort = () => {\n callerSignal.removeEventListener('abort', abortInternal);\n };\n }\n }\n }\n\n get version(): string {\n return SDK_VERSION;\n }\n\n get workKey(): string {\n return this.#config.workKey;\n }\n\n get region(): ViceMeRegion {\n return this.#config.region;\n }\n\n get state(): ViceMeClientState {\n return this.#lifecycle.state;\n }\n\n /** Internal: public API major, used by the loader registry namespace. */\n get apiMajor(): number {\n return API_MAJOR;\n }\n\n ready(): Promise<void> {\n if (this.#lifecycle.destroyed) return Promise.reject(clientDestroyed());\n if (!this.#readyPromise) {\n this.#lifecycle.transition('READY');\n this.#readyPromise = Promise.resolve();\n }\n return this.#readyPromise;\n }\n\n async #readyAccess(): Promise<void> {\n if (this.#lifecycle.destroyed) throw clientDestroyed();\n await this.ready();\n try {\n await this.#session.establish();\n if (this.#lifecycle.destroyed) throw clientDestroyed();\n } catch (error) {\n if (this.#lifecycle.destroyed) throw clientDestroyed();\n this.#session.invalidate();\n throw error;\n }\n }\n\n hasCapability(name: string): boolean {\n if (this.#lifecycle.destroyed) return false;\n const capabilities = this.#session.snapshot?.work.capabilities;\n return name === 'danmaku' || name === 'tip' || capabilities?.includes(name) === true;\n }\n\n /** Names of capabilities enabled for this work (empty before `ready()`). */\n get capabilities(): readonly string[] {\n return this.#session.snapshot?.work.capabilities ?? [];\n }\n\n /**\n * Internal: mark one capability unavailable without taking down the client\n * (loader uses this when a feature chunk fails after the core is READY).\n */\n markDegraded(): void {\n if (this.#lifecycle.state === 'READY') this.#lifecycle.transition('DEGRADED');\n }\n\n /** Internal: session snapshot access for capability modules. */\n get sessionSnapshot() {\n return this.#session.snapshot;\n }\n\n destroy(): void {\n if (this.#lifecycle.destroyed) return;\n this.#lifecycle.transition('DESTROYED');\n this.#internalSignal.abort(new DestroySignalReason());\n this.#session.destroy();\n this.#lifecycle.clearListeners();\n this.#readyPromise = undefined;\n // A destroyed client must not stay reachable through the caller's own\n // (possibly long-lived, never-aborting) signal.\n this.#detachCallerAbort?.();\n this.#detachCallerAbort = undefined;\n }\n}\n"],"names":["REGIONS","PUBLIC_API_BASE_URLS","BUILD_API_BASE_URLS","resolveApiBaseUrl","region","isValidWorkKey","value","isValidRegion","validatePublicConfig","input","configInvalid","raw","known","key","ALLOWED_TRANSITIONS","Lifecycle","#state","#listeners","next","ViceMeError","listener","clientDestroyed","parseSessionResponse","body","workKey","malformedSessionResponse","snapshot","expiresAt","SessionManager","#options","#now","#snapshot","#pending","options","#isExpired","response","request","error","refreshed","ELEMENT_NAME","PROFILE_DESCRIPTION_LIMIT","actionCopy","action","actionErrorCopy","isViceMeError","ensureAccessLayerElement","ViceMeAccessLayerElement","copy","shadow","panel","description","mainActions","closeAction","backdrop","frame","profile","avatar","avatarFallback","profileName","profileDescription","profileStats","idleActionLabel","target","descriptionCharacters","activeAction","close","result","dismissLayer","event","available","element","currentIndex","direction","performAction","caught","defaultAccessPresenter","interaction","previousOverflow","previousFocus","resolve","objectBody","malformedResponse","parseUser","parseFollowState","parseDecision","reasons","actions","parseFeaturePresentation","price","randomVerifier","bytes","base64Url","binary","byte","resolveLocale","createCapabilities","deps","cancelled","embeddedFrame","url","completionOrigin","channel","type","initialization","complete","active","settle","fail","cleanup","receive","completion","reject","data","startSignIn","authorizationUrl","workSessionToken","getFollowState","updateFollow","auth","user","follow","checkMany","featureKeys","createCheckout","featureKey","openCheckout","checkoutWindow","timer","poll","decision","presenter","attempts","nextAction","followTarget","checkoutResult","DestroySignalReason","ViceMeClientImpl","#lifecycle","#session","#config","#internalSignal","#readyPromise","#detachCallerAbort","capabilities","BUILD_WIDGET_ORIGINS","#readyAccess","callerSignal","abortInternal","SDK_VERSION","API_MAJOR","name"],"mappings":";;AAsBA,MAAMA,IAA+B,oBAAI,IAAI,CAAC,MAAM,QAAQ,CAAC,GAOhDC,IAA+D;AAAA,EAC1E,IAAIC,EAAoB;AAAA,EACxB,QAAQA,EAAoB;AAC9B;AAEO,SAASC,GAAkBC,GAA8B;AAC9D,SAAOH,EAAqBG,CAAM;AACpC;AAEO,SAASC,EAAeC,GAAiC;AAC9D,SAAO,OAAOA,KAAU,YAAY,6BAA6B,KAAKA,CAAK;AAC7E;AAEO,SAASC,EAAcD,GAAuC;AACnE,SAAO,OAAOA,KAAU,YAAYN,EAAQ,IAAIM,CAAK;AACvD;AAMO,SAASE,GAAqBC,GAA8B;AACjE,MAAI,OAAOA,KAAU,YAAYA,MAAU;AACzC,UAAMC,EAAc,8CAA8C;AAEpE,QAAMC,IAAMF,GAENG,IAAQ,oBAAI,IAAI,CAAC,WAAW,UAAU,QAAQ,CAAC;AACrD,aAAWC,KAAO,OAAO,KAAKF,CAAG;AAC/B,QAAI,CAACC,EAAM,IAAIC,CAAG;AAChB,YAAMH,EAAc,gCAAgCG,CAAG,IAAI;AAG/D,MAAI,CAACR,EAAeM,EAAI,OAAO;AAC7B,UAAMD,EAAc,oEAAoE;AAE1F,MAAI,CAACH,EAAcI,EAAI,MAAM;AAC3B,UAAMD,EAAc,wDAAwD;AAE9E,MAAIC,EAAI,WAAW,UAAa,EAAEA,EAAI,kBAAkB;AACtD,UAAMD,EAAc,sDAAsD;AAE5E,SAAO;AAAA,IACL,SAASC,EAAI;AAAA,IACb,QAAQA,EAAI;AAAA,IACZ,QAAQA,EAAI;AAAA,EAAA;AAEhB;AC7DA,MAAMG,IAAyF;AAAA,EAC7F,SAAS,CAAC,SAAS,WAAW;AAA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,GAAS,UAAU,KAAK,gBAAgB,CAAA;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,eAAqB;AACnB,IAAI,KAAKD,GAAW,UAAU,WAAS,KAAKA,GAAW,WAAW,UAAU;AAAA,EAC9E;AAAA;AAAA,EAGA,IAAI,kBAAkB;AACpB,WAAO,KAAKC,GAAS;AAAA,EACvB;AAAA,EAEA,UAAgB;AACd,IAAI,KAAKD,GAAW,cACpB,KAAKA,GAAW,WAAW,WAAW,GACtC,KAAKG,GAAgB,MAAM,IAAIL,GAAA,CAAqB,GACpD,KAAKG,GAAS,QAAA,GACd,KAAKD,GAAW,eAAA,GAChB,KAAKI,KAAgB,QAGrB,KAAKC,KAAA,GACL,KAAKA,KAAqB;AAAA,EAC5B;AACF;"}
|
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const a = {
|
|
2
|
+
cn: "https://api.viceme.cn",
|
|
3
|
+
global: "https://api.viceme.ai"
|
|
4
|
+
}, c = {
|
|
5
|
+
cn: "https://viceme.cn",
|
|
6
|
+
global: "https://viceme.ai"
|
|
7
|
+
}, r = /* @__PURE__ */ new Set([
|
|
8
|
+
"RATE_LIMITED",
|
|
9
|
+
"NETWORK_TIMEOUT",
|
|
10
|
+
"CHECKOUT_UNAVAILABLE",
|
|
11
|
+
"INTERNAL_ERROR"
|
|
12
|
+
]);
|
|
13
|
+
class s extends Error {
|
|
3
14
|
code;
|
|
4
15
|
retryable;
|
|
5
16
|
requestId;
|
|
6
17
|
capability;
|
|
7
18
|
constructor(e) {
|
|
8
|
-
super(e.message), this.name = "ViceMeError", this.code = e.code, this.retryable = e.retryable ??
|
|
19
|
+
super(e.message), this.name = "ViceMeError", this.code = e.code, this.retryable = e.retryable ?? r.has(e.code), this.requestId = e.requestId, this.capability = e.capability;
|
|
9
20
|
}
|
|
10
21
|
/** Safe, stable-shape serialization for logs and `viceme:error` events. */
|
|
11
22
|
toJSON() {
|
|
@@ -13,26 +24,25 @@ class r extends Error {
|
|
|
13
24
|
return this.requestId !== void 0 && (e.requestId = this.requestId), this.capability !== void 0 && (e.capability = this.capability), e;
|
|
14
25
|
}
|
|
15
26
|
}
|
|
16
|
-
function
|
|
17
|
-
return t instanceof
|
|
27
|
+
function i(t) {
|
|
28
|
+
return t instanceof s;
|
|
18
29
|
}
|
|
19
|
-
function
|
|
20
|
-
return new
|
|
30
|
+
function o(t) {
|
|
31
|
+
return new s({ code: "CONFIG_INVALID", message: t, retryable: !1 });
|
|
21
32
|
}
|
|
22
|
-
function
|
|
23
|
-
return new
|
|
33
|
+
function n() {
|
|
34
|
+
return new s({
|
|
24
35
|
code: "CLIENT_DESTROYED",
|
|
25
36
|
message: "ViceMe client has been destroyed.",
|
|
26
37
|
retryable: !1
|
|
27
38
|
});
|
|
28
39
|
}
|
|
29
|
-
const o = "0.2.0", n = 1;
|
|
30
40
|
export {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
c,
|
|
36
|
-
|
|
41
|
+
c as B,
|
|
42
|
+
s as V,
|
|
43
|
+
o as a,
|
|
44
|
+
a as b,
|
|
45
|
+
n as c,
|
|
46
|
+
i
|
|
37
47
|
};
|
|
38
|
-
//# sourceMappingURL=
|
|
48
|
+
//# sourceMappingURL=errors-B-Qv_azy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-B-Qv_azy.js","sources":["../../src/core/build-endpoints.ts","../../src/core/errors.ts"],"sourcesContent":["declare const __VICEME_BUILD_CN_API_BASE_URL__: string | undefined;\ndeclare const __VICEME_BUILD_GLOBAL_API_BASE_URL__: string | undefined;\ndeclare const __VICEME_BUILD_CN_WIDGET_ORIGIN__: string | undefined;\ndeclare const __VICEME_BUILD_GLOBAL_WIDGET_ORIGIN__: string | undefined;\n\n/** Public Shop API origins baked into immutable release artifacts. */\nexport const BUILD_API_BASE_URLS = {\n cn:\n typeof __VICEME_BUILD_CN_API_BASE_URL__ === 'string'\n ? __VICEME_BUILD_CN_API_BASE_URL__\n : 'https://api.viceme.cn',\n global:\n typeof __VICEME_BUILD_GLOBAL_API_BASE_URL__ === 'string'\n ? __VICEME_BUILD_GLOBAL_API_BASE_URL__\n : 'https://api.viceme.ai',\n} as const;\n\n/** Hosted Shop origins baked into immutable release artifacts. */\nexport const BUILD_WIDGET_ORIGINS = {\n cn:\n typeof __VICEME_BUILD_CN_WIDGET_ORIGIN__ === 'string'\n ? __VICEME_BUILD_CN_WIDGET_ORIGIN__\n : 'https://viceme.cn',\n global:\n typeof __VICEME_BUILD_GLOBAL_WIDGET_ORIGIN__ === 'string'\n ? __VICEME_BUILD_GLOBAL_WIDGET_ORIGIN__\n : 'https://viceme.ai',\n} as const;\n","/**\n * Public error model.\n *\n * Consumers branch on the stable `code` only — never on `message` text.\n * Error payloads must never contain provider responses, tokens, cookies, or\n * internal stack traces; `toJSON()` exposes the safe diagnostic subset.\n */\n\nexport type ViceMeErrorCode =\n | 'CONFIG_INVALID'\n | 'WORK_NOT_FOUND'\n | 'CAPABILITY_DISABLED'\n | 'CLIENT_DESTROYED'\n | 'SESSION_EXPIRED'\n | 'AUTH_REQUIRED'\n | 'AUTH_CANCELLED'\n | 'RETURN_URL_NOT_ALLOWED'\n | 'RATE_LIMITED'\n | 'NETWORK_TIMEOUT'\n | 'CHECKOUT_UNAVAILABLE'\n | 'INTERNAL_ERROR';\n\nexport interface ViceMeErrorInit {\n code: ViceMeErrorCode;\n message: string;\n retryable?: boolean;\n /** Server-assigned request id echoed back for support correlation. */\n requestId?: string;\n /** Capability the error belongs to, when scoped to one. */\n capability?: string;\n}\n\nconst RETRYABLE_BY_DEFAULT: ReadonlySet<ViceMeErrorCode> = new Set([\n 'RATE_LIMITED',\n 'NETWORK_TIMEOUT',\n 'CHECKOUT_UNAVAILABLE',\n 'INTERNAL_ERROR',\n]);\n\nexport class ViceMeError extends Error {\n readonly code: ViceMeErrorCode;\n readonly retryable: boolean;\n readonly requestId?: string;\n readonly capability?: string;\n\n constructor(init: ViceMeErrorInit) {\n super(init.message);\n this.name = 'ViceMeError';\n this.code = init.code;\n this.retryable = init.retryable ?? RETRYABLE_BY_DEFAULT.has(init.code);\n this.requestId = init.requestId;\n this.capability = init.capability;\n }\n\n /** Safe, stable-shape serialization for logs and `viceme:error` events. */\n toJSON(): {\n code: ViceMeErrorCode;\n retryable: boolean;\n requestId?: string;\n capability?: string;\n } {\n const json: {\n code: ViceMeErrorCode;\n retryable: boolean;\n requestId?: string;\n capability?: string;\n } = { code: this.code, retryable: this.retryable };\n if (this.requestId !== undefined) json.requestId = this.requestId;\n if (this.capability !== undefined) json.capability = this.capability;\n return json;\n }\n}\n\nexport function isViceMeError(value: unknown): value is ViceMeError {\n return value instanceof ViceMeError;\n}\n\n/** Build a CONFIG_INVALID error with a stable, non-sensitive message. */\nexport function configInvalid(message: string): ViceMeError {\n return new ViceMeError({ code: 'CONFIG_INVALID', message, retryable: false });\n}\n\n/** Build a CLIENT_DESTROYED error for post-destroy calls. */\nexport function clientDestroyed(): ViceMeError {\n return new ViceMeError({\n code: 'CLIENT_DESTROYED',\n message: 'ViceMe client has been destroyed.',\n retryable: false,\n });\n}\n"],"names":["BUILD_API_BASE_URLS","BUILD_WIDGET_ORIGINS","RETRYABLE_BY_DEFAULT","ViceMeError","init","json","isViceMeError","value","configInvalid","message","clientDestroyed"],"mappings":"AAMO,MAAMA,IAAsB;AAAA,EACjC,IAEM;AAAA,EAEN,QAEM;AAER,GAGaC,IAAuB;AAAA,EAClC,IAEM;AAAA,EAEN,QAEM;AAER,GCKMC,wBAAyD,IAAI;AAAA,EACjE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,MAAMC,UAAoB,MAAM;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAYC,GAAuB;AACjC,UAAMA,EAAK,OAAO,GAClB,KAAK,OAAO,eACZ,KAAK,OAAOA,EAAK,MACjB,KAAK,YAAYA,EAAK,aAAaF,EAAqB,IAAIE,EAAK,IAAI,GACrE,KAAK,YAAYA,EAAK,WACtB,KAAK,aAAaA,EAAK;AAAA,EACzB;AAAA;AAAA,EAGA,SAKE;AACA,UAAMC,IAKF,EAAE,MAAM,KAAK,MAAM,WAAW,KAAK,UAAA;AACvC,WAAI,KAAK,cAAc,WAAWA,EAAK,YAAY,KAAK,YACpD,KAAK,eAAe,WAAWA,EAAK,aAAa,KAAK,aACnDA;AAAA,EACT;AACF;AAEO,SAASC,EAAcC,GAAsC;AAClE,SAAOA,aAAiBJ;AAC1B;AAGO,SAASK,EAAcC,GAA8B;AAC1D,SAAO,IAAIN,EAAY,EAAE,MAAM,kBAAkB,SAAAM,GAAS,WAAW,IAAO;AAC9E;AAGO,SAASC,IAA+B;AAC7C,SAAO,IAAIP,EAAY;AAAA,IACrB,MAAM;AAAA,IACN,SAAS;AAAA,IACT,WAAW;AAAA,EAAA,CACZ;AACH;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-C8DeBm39.js","sources":["../../src/version.ts"],"sourcesContent":["/**\n * Single source of truth for the SDK runtime version.\n *\n * Kept in sync with `packages/sdk/package.json#version`; a unit test enforces\n * the match so the loader, release manifest, and npm metadata can never drift.\n */\nexport const SDK_VERSION = '0.4.0';\n\n/** Public API major carried by this build (loader namespace `v1`). */\nexport const API_MAJOR = 1;\n"],"names":["SDK_VERSION","API_MAJOR"],"mappings":"AAMO,MAAMA,IAAc,SAGdC,IAAY;"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/** Public Shop API origins baked into immutable release artifacts. */
|
|
2
|
+
export declare const BUILD_API_BASE_URLS: {
|
|
3
|
+
readonly cn: string;
|
|
4
|
+
readonly global: string;
|
|
5
|
+
};
|
|
1
6
|
/** Hosted Shop origins baked into immutable release artifacts. */
|
|
2
7
|
export declare const BUILD_WIDGET_ORIGINS: {
|
|
3
8
|
readonly cn: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-endpoints.d.ts","sourceRoot":"","sources":["../../src/core/build-endpoints.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-endpoints.d.ts","sourceRoot":"","sources":["../../src/core/build-endpoints.ts"],"names":[],"mappings":"AAKA,sEAAsE;AACtE,eAAO,MAAM,mBAAmB;;;CAStB,CAAC;AAEX,kEAAkE;AAClE,eAAO,MAAM,oBAAoB;;;CASvB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type AccessPresenter } from './presentation.ts';
|
|
2
|
+
import type { SessionManager, WorkUser } from '../session/session.ts';
|
|
3
|
+
export interface AuthState {
|
|
4
|
+
authenticated: boolean;
|
|
5
|
+
user: WorkUser | null;
|
|
6
|
+
}
|
|
7
|
+
export interface FollowState {
|
|
8
|
+
following: boolean;
|
|
9
|
+
followedAt: string | null;
|
|
10
|
+
target: FollowTarget;
|
|
11
|
+
}
|
|
12
|
+
export interface FollowTarget {
|
|
13
|
+
kind: 'CREATOR' | 'USER';
|
|
14
|
+
displayName: string;
|
|
15
|
+
avatarUrl: string | null;
|
|
16
|
+
description: string | null;
|
|
17
|
+
workCount: number;
|
|
18
|
+
}
|
|
19
|
+
export type AccessReason = 'PUBLIC' | 'OWNER' | 'FOLLOWING' | 'ENTITLED' | 'AUTH_REQUIRED' | 'FOLLOW_REQUIRED' | 'PURCHASE_REQUIRED' | 'FEATURE_NOT_FOUND' | 'FEATURE_DISABLED';
|
|
20
|
+
export interface AccessDecision {
|
|
21
|
+
allowed: boolean;
|
|
22
|
+
reason: AccessReason;
|
|
23
|
+
nextAction: 'SIGN_IN' | 'FOLLOW' | 'CHECKOUT' | null;
|
|
24
|
+
}
|
|
25
|
+
export type AccessPolicyType = 'PUBLIC' | 'FOLLOW_OWNER' | 'WORK_ENTITLEMENT';
|
|
26
|
+
export interface AccessFeaturePresentation {
|
|
27
|
+
featureKey: string;
|
|
28
|
+
title: string;
|
|
29
|
+
policy: {
|
|
30
|
+
type: AccessPolicyType;
|
|
31
|
+
};
|
|
32
|
+
price: {
|
|
33
|
+
amountCents: number;
|
|
34
|
+
currency: 'CNY';
|
|
35
|
+
} | null;
|
|
36
|
+
}
|
|
37
|
+
export interface CheckoutOptions {
|
|
38
|
+
featureKey: string;
|
|
39
|
+
locale?: 'zh-CN' | 'en-US';
|
|
40
|
+
}
|
|
41
|
+
export interface CheckoutResult {
|
|
42
|
+
checkoutUrl: string;
|
|
43
|
+
alreadyOwned: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface AuthCapability {
|
|
46
|
+
getState(): Promise<AuthState>;
|
|
47
|
+
signIn(): Promise<AuthState>;
|
|
48
|
+
signOut(): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
export interface FollowCapability {
|
|
51
|
+
getState(): Promise<FollowState>;
|
|
52
|
+
follow(): Promise<FollowState>;
|
|
53
|
+
unfollow(): Promise<FollowState>;
|
|
54
|
+
}
|
|
55
|
+
export interface AccessCapability {
|
|
56
|
+
getFeatures(): Promise<AccessFeaturePresentation[]>;
|
|
57
|
+
check(featureKey: string): Promise<AccessDecision>;
|
|
58
|
+
checkMany(featureKeys: string[]): Promise<Record<string, AccessDecision>>;
|
|
59
|
+
require(featureKey: string): Promise<AccessDecision>;
|
|
60
|
+
refresh(): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
export interface CheckoutCapability {
|
|
63
|
+
open(options: CheckoutOptions): Promise<CheckoutResult>;
|
|
64
|
+
}
|
|
65
|
+
interface CapabilityDeps {
|
|
66
|
+
session: SessionManager;
|
|
67
|
+
workKey: string;
|
|
68
|
+
widgetOrigin: string;
|
|
69
|
+
presenter?: AccessPresenter;
|
|
70
|
+
ready: () => Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
export declare function createCapabilities(deps: CapabilityDeps): {
|
|
73
|
+
auth: AuthCapability;
|
|
74
|
+
follow: FollowCapability;
|
|
75
|
+
access: AccessCapability;
|
|
76
|
+
checkout: CheckoutCapability;
|
|
77
|
+
};
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/core/capabilities.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtE,MAAM,WAAW,SAAS;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,OAAO,GACP,WAAW,GACX,UAAU,GACV,eAAe,GACf,iBAAiB,GACjB,mBAAmB,GACnB,mBAAmB,GACnB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,YAAY,CAAC;IACrB,UAAU,EAAE,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,IAAI,CAAC;CACtD;AAED,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,cAAc,GAAG,kBAAkB,CAAC;AAE9E,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE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,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAgJD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,GAAG;IACxD,IAAI,EAAE,cAAc,CAAC;IACrB,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,EAAE,gBAAgB,CAAC;IACzB,QAAQ,EAAE,kBAAkB,CAAC;CAC9B,CA+VA"}
|
package/dist/core/client.d.ts
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* ViceMe client for hosted capabilities and optional website access.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* `ready()` and access checks remain headless. Interactive authentication and
|
|
5
|
+
* checkout touch `window` only when the caller explicitly invokes them. `ready()` is
|
|
6
|
+
* Hosted capability initialization stays local and synchronous. Website
|
|
7
|
+
* access establishes its Work session lazily on the first access operation.
|
|
8
|
+
* `ready()` is idempotent per instance (shares one promise), `destroy()` is idempotent and
|
|
9
|
+
* synchronously cancels requests and subscriptions; every business method on a
|
|
10
|
+
* destroyed client fails with `CLIENT_DESTROYED`.
|
|
6
11
|
*/
|
|
7
12
|
import { type ViceMeClientState } from './lifecycle.ts';
|
|
8
13
|
import type { ViceMeConfig, ViceMeRegion } from './config.ts';
|
|
9
|
-
|
|
14
|
+
import type { Transport } from '../transport/transport.ts';
|
|
15
|
+
import { type AccessCapability, type AuthCapability, type CheckoutCapability } from './capabilities.ts';
|
|
16
|
+
import type { AccessPresenter } from './presentation.ts';
|
|
10
17
|
export interface ViceMeClient {
|
|
18
|
+
readonly version: string;
|
|
11
19
|
readonly workKey: string;
|
|
12
20
|
readonly region: ViceMeRegion;
|
|
13
21
|
readonly state: ViceMeClientState;
|
|
22
|
+
readonly auth: AuthCapability;
|
|
23
|
+
readonly access: AccessCapability;
|
|
24
|
+
readonly checkout: CheckoutCapability;
|
|
14
25
|
ready(): Promise<void>;
|
|
15
26
|
hasCapability(name: string): boolean;
|
|
16
27
|
destroy(): void;
|
|
@@ -20,22 +31,39 @@ export interface ViceMeMountedInstance {
|
|
|
20
31
|
readonly capability: string;
|
|
21
32
|
destroy(): void;
|
|
22
33
|
}
|
|
23
|
-
/** Internal loader hook;
|
|
34
|
+
/** Internal loader hook; keeps degradation outside the public client contract. */
|
|
24
35
|
export declare function markClientDegraded(client: ViceMeClient): void;
|
|
36
|
+
export interface ViceMeClientDeps {
|
|
37
|
+
config: ViceMeConfig;
|
|
38
|
+
transport: Transport;
|
|
39
|
+
/** Interaction override for the testing entry only. */
|
|
40
|
+
presenter?: AccessPresenter;
|
|
41
|
+
/** Injectable clock (testing only). */
|
|
42
|
+
now?: () => number;
|
|
43
|
+
}
|
|
25
44
|
export declare class ViceMeClientImpl implements ViceMeClient {
|
|
26
45
|
#private;
|
|
27
|
-
|
|
46
|
+
readonly auth: AuthCapability;
|
|
47
|
+
readonly access: AccessCapability;
|
|
48
|
+
readonly checkout: CheckoutCapability;
|
|
49
|
+
constructor(deps: ViceMeClientDeps);
|
|
50
|
+
get version(): string;
|
|
28
51
|
get workKey(): string;
|
|
29
52
|
get region(): ViceMeRegion;
|
|
30
53
|
get state(): ViceMeClientState;
|
|
54
|
+
/** Internal: public API major, used by the loader registry namespace. */
|
|
55
|
+
get apiMajor(): number;
|
|
31
56
|
ready(): Promise<void>;
|
|
32
57
|
hasCapability(name: string): boolean;
|
|
58
|
+
/** Names of capabilities enabled for this work (empty before `ready()`). */
|
|
59
|
+
get capabilities(): readonly string[];
|
|
33
60
|
/**
|
|
34
61
|
* Internal: mark one capability unavailable without taking down the client
|
|
35
62
|
* (loader uses this when a feature chunk fails after the core is READY).
|
|
36
63
|
*/
|
|
37
|
-
|
|
64
|
+
markDegraded(): void;
|
|
65
|
+
/** Internal: session snapshot access for capability modules. */
|
|
66
|
+
get sessionSnapshot(): import("../session/session.ts").WorkSessionSnapshot | undefined;
|
|
38
67
|
destroy(): void;
|
|
39
68
|
}
|
|
40
|
-
export {};
|
|
41
69
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAa,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACrC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC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
4
|
+
* Production `createViceMe()` accepts exactly `workKey`, `region`, and
|
|
5
|
+
* `signal`. Anything else (transport, clock, request ids, base URLs) is a
|
|
6
|
+
* testing-only concern and lives in `@viceme-ai/sdk/testing`, so Agents can
|
|
7
|
+
* never bake temporary or internal endpoints into user projects.
|
|
7
8
|
*/
|
|
8
9
|
export type ViceMeRegion = 'cn' | 'global';
|
|
9
10
|
export interface ViceMeConfig {
|
|
10
11
|
/** Public opaque work key (`wrk_…`). Locates a Work; it is not a secret. */
|
|
11
12
|
workKey: string;
|
|
12
|
-
/**
|
|
13
|
+
/** Routes public API and CDN traffic. */
|
|
13
14
|
region: ViceMeRegion;
|
|
15
|
+
/** Optional abort signal owned by the host page. */
|
|
16
|
+
signal?: AbortSignal;
|
|
14
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Public API origins per region. These are the only production endpoints the
|
|
20
|
+
* SDK may contact; B1 confirms final hostnames and any change happens here in
|
|
21
|
+
* one place (never via a public `apiBaseUrl` option).
|
|
22
|
+
*/
|
|
23
|
+
export declare const PUBLIC_API_BASE_URLS: Readonly<Record<ViceMeRegion, string>>;
|
|
24
|
+
export declare function resolveApiBaseUrl(region: ViceMeRegion): string;
|
|
15
25
|
export declare function isValidWorkKey(value: unknown): value is string;
|
|
16
26
|
export declare function isValidRegion(value: unknown): value is ViceMeRegion;
|
|
17
27
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,QAAQ,CAAC;AAE3C,MAAM,WAAW,YAAY;IAC3B,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,MAAM,EAAE,YAAY,CAAC;IACrB,oDAAoD;IACpD,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAID;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAGvE,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAE9D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE9D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEnE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CA0BjE"}
|
package/dist/core/errors.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Error payloads must never contain provider responses, tokens, cookies, or
|
|
6
6
|
* internal stack traces; `toJSON()` exposes the safe diagnostic subset.
|
|
7
7
|
*/
|
|
8
|
-
export type ViceMeErrorCode = 'CONFIG_INVALID' | 'CAPABILITY_DISABLED' | 'CLIENT_DESTROYED' | 'INTERNAL_ERROR';
|
|
8
|
+
export type ViceMeErrorCode = 'CONFIG_INVALID' | 'WORK_NOT_FOUND' | 'CAPABILITY_DISABLED' | 'CLIENT_DESTROYED' | 'SESSION_EXPIRED' | 'AUTH_REQUIRED' | 'AUTH_CANCELLED' | 'RETURN_URL_NOT_ALLOWED' | 'RATE_LIMITED' | 'NETWORK_TIMEOUT' | 'CHECKOUT_UNAVAILABLE' | 'INTERNAL_ERROR';
|
|
9
9
|
export interface ViceMeErrorInit {
|
|
10
10
|
code: ViceMeErrorCode;
|
|
11
11
|
message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,eAAe,GACvB,gBAAgB,GAChB,gBAAgB,GAChB,qBAAqB,GACrB,kBAAkB,GAClB,iBAAiB,GACjB,eAAe,GACf,gBAAgB,GAChB,wBAAwB,GACxB,cAAc,GACd,iBAAiB,GACjB,sBAAsB,GACtB,gBAAgB,CAAC;AAErB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AASD,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAEjB,IAAI,EAAE,eAAe;IASjC,2EAA2E;IAC3E,MAAM,IAAI;QACR,IAAI,EAAE,eAAe,CAAC;QACtB,SAAS,EAAE,OAAO,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB;CAWF;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAE1D;AAED,6DAA6D;AAC7D,wBAAgB,eAAe,IAAI,WAAW,CAM7C"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FollowTarget } from './capabilities.ts';
|
|
2
|
+
export type AccessInteractionAction = 'SIGN_IN' | 'FOLLOW' | 'CHECKOUT';
|
|
3
|
+
export interface AccessInteraction {
|
|
4
|
+
featureKey: string;
|
|
5
|
+
reason: string;
|
|
6
|
+
action: AccessInteractionAction;
|
|
7
|
+
followTarget?: FollowTarget;
|
|
8
|
+
perform(): Promise<AccessActionResult>;
|
|
9
|
+
}
|
|
10
|
+
export interface AccessCompletedAction {
|
|
11
|
+
type: 'completed';
|
|
12
|
+
}
|
|
13
|
+
export interface AccessFrameAction {
|
|
14
|
+
type: 'frame';
|
|
15
|
+
url: string;
|
|
16
|
+
completion: Promise<void>;
|
|
17
|
+
cancel(): void;
|
|
18
|
+
}
|
|
19
|
+
export interface AccessExternalAction {
|
|
20
|
+
type: 'external';
|
|
21
|
+
completion: Promise<void>;
|
|
22
|
+
cancel(): void;
|
|
23
|
+
}
|
|
24
|
+
export type AccessActionResult = AccessCompletedAction | AccessFrameAction | AccessExternalAction;
|
|
25
|
+
export type AccessPresentationResult = 'acted' | 'dismissed';
|
|
26
|
+
/** Internal interaction seam used by the ViceMe layer and deterministic tests. */
|
|
27
|
+
export type AccessPresenter = (interaction: AccessInteraction) => Promise<AccessPresentationResult>;
|
|
28
|
+
export declare const defaultAccessPresenter: AccessPresenter;
|
|
29
|
+
//# sourceMappingURL=presentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../../src/core/presentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAExE,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,uBAAuB,CAAC;IAChC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,OAAO,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,GAAG,iBAAiB,GAAG,oBAAoB,CAAC;AAElG,MAAM,MAAM,wBAAwB,GAAG,OAAO,GAAG,WAAW,CAAC;AAE7D,kFAAkF;AAClF,MAAM,MAAM,eAAe,GAAG,CAAC,WAAW,EAAE,iBAAiB,KAAK,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAqYpG,eAAO,MAAM,sBAAsB,EAAE,eAyBpC,CAAC"}
|
package/dist/danmaku/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/danmaku/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/danmaku/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,OAAO,IAAI,IAAI,CAAC;CACjB;AAID,kFAAkF;AAClF,wBAAgB,YAAY,CAC1B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,CAgC7B"}
|
package/dist/danmaku/mount.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ViceMeClient } from '../core/client.ts';
|
|
2
|
-
import type { CapabilityMountHandle, CapabilityMountOptions } from '../
|
|
2
|
+
import type { CapabilityMountHandle, CapabilityMountOptions } from '../capability-mount.ts';
|
|
3
3
|
export declare const FRAME_READY_TIMEOUT_MS = 8000;
|
|
4
4
|
export declare function mount(client: ViceMeClient, options: CapabilityMountOptions): Promise<CapabilityMountHandle>;
|
|
5
5
|
//# sourceMappingURL=mount.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/danmaku/mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/danmaku/mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAqB5F,eAAO,MAAM,sBAAsB,OAAQ,CAAC;AAE5C,wBAAsB,KAAK,CACzB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CA4UhC"}
|