@viceme-ai/sdk 0.6.2 → 0.7.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 +18 -6
- package/dist/capability-mount.d.ts +2 -0
- package/dist/capability-mount.d.ts.map +1 -1
- package/dist/chunks/{client-DEg6YouY.js → client-C1Sw400H.js} +386 -300
- package/dist/chunks/client-C1Sw400H.js.map +1 -0
- package/dist/chunks/integration-CTsnJ8mN.js +38 -0
- package/dist/chunks/integration-CTsnJ8mN.js.map +1 -0
- package/dist/chunks/version-CAPPYmfK.js +6 -0
- package/dist/chunks/{version-BJiUVcir.js.map → version-CAPPYmfK.js.map} +1 -1
- package/dist/core/capabilities.d.ts.map +1 -1
- package/dist/core/presentation.d.ts +5 -0
- package/dist/core/presentation.d.ts.map +1 -1
- package/dist/danmaku/mount.d.ts.map +1 -1
- package/dist/danmaku.js +117 -91
- package/dist/danmaku.js.map +1 -1
- package/dist/engagement/integration.d.ts +15 -0
- package/dist/engagement/integration.d.ts.map +1 -0
- package/dist/generated/public-contract.d.ts +15 -1
- package/dist/generated/public-contract.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/loader/auto-loader.d.ts.map +1 -1
- package/dist/manifest.json +36 -27
- package/dist/session/session.d.ts +12 -0
- package/dist/session/session.d.ts.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/tip/index.d.ts +2 -0
- package/dist/tip/index.d.ts.map +1 -1
- package/dist/tip/mount.d.ts.map +1 -1
- package/dist/tip.js +211 -194
- package/dist/tip.js.map +1 -1
- package/dist/transport/transport.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/viceme.min.js +46 -4
- package/dist/viceme.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/client-DEg6YouY.js.map +0 -1
- package/dist/chunks/version-BJiUVcir.js +0 -6
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { V as n } from "./chunks/errors-C7DfLKcF.js";
|
|
2
2
|
import { i as L } from "./chunks/errors-C7DfLKcF.js";
|
|
3
|
-
import { v as A, V as b, r as h } from "./chunks/client-
|
|
4
|
-
import { A as S, S as V } from "./chunks/version-
|
|
3
|
+
import { v as A, V as b, r as h } from "./chunks/client-C1Sw400H.js";
|
|
4
|
+
import { A as S, S as V } from "./chunks/version-CAPPYmfK.js";
|
|
5
5
|
const m = 1e4, p = /* @__PURE__ */ new Map([
|
|
6
6
|
[400, "CONFIG_INVALID"],
|
|
7
7
|
[401, "SESSION_EXPIRED"],
|
|
@@ -31,7 +31,7 @@ function O(s) {
|
|
|
31
31
|
function _() {
|
|
32
32
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `req-${Math.random().toString(36).slice(2)}`;
|
|
33
33
|
}
|
|
34
|
-
class
|
|
34
|
+
class g {
|
|
35
35
|
#e;
|
|
36
36
|
#t;
|
|
37
37
|
#r;
|
|
@@ -73,6 +73,7 @@ class R {
|
|
|
73
73
|
throw i;
|
|
74
74
|
a = void 0;
|
|
75
75
|
}
|
|
76
|
+
if (r.signal.aborted) throw r.signal.reason;
|
|
76
77
|
const u = o.headers.get("x-request-id") ?? void 0;
|
|
77
78
|
if (!o.ok) {
|
|
78
79
|
const i = O(a), f = i.code ?? p.get(o.status) ?? "INTERNAL_ERROR";
|
|
@@ -105,8 +106,8 @@ class R {
|
|
|
105
106
|
return e.reason instanceof Error ? e.reason : new DOMException("ViceMe request aborted by caller.", "AbortError");
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
|
-
function
|
|
109
|
-
return new
|
|
109
|
+
function R(s) {
|
|
110
|
+
return new g(s);
|
|
110
111
|
}
|
|
111
112
|
class I extends DOMException {
|
|
112
113
|
constructor(e = !0) {
|
|
@@ -114,7 +115,7 @@ class I extends DOMException {
|
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
117
|
function D(s) {
|
|
117
|
-
const e = A(s), t = h(e.region), r =
|
|
118
|
+
const e = A(s), t = h(e.region), r = R({
|
|
118
119
|
apiBaseUrl: t
|
|
119
120
|
});
|
|
120
121
|
return new b({ config: e, transport: r });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/transport/transport.ts","../src/index.ts"],"sourcesContent":["/**\n * HTTP transport for the public API.\n *\n * Responsibilities: request execution with timeout, abort, client request ids,\n * and normalization of every failure into the public `ViceMeError` model.\n * Capabilities and the loader never build their own `fetch` calls — they go\n * through a Transport so tests can swap in `createMemoryTransport`.\n */\n\nimport { ViceMeError, type ViceMeErrorCode } from '../core/errors.ts';\n\nexport interface TransportRequest {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE';\n /** Absolute path under the public API base. */\n path: string;\n /** JSON-serializable request body. */\n body?: unknown;\n /** Work-session token. It is never persisted by the transport. */\n authorization?: string;\n /** Optional memory-only signed-in widget token. */\n userAuthorization?: string;\n signal?: AbortSignal;\n /** Per-request timeout; defaults to the transport default. */\n timeoutMs?: number;\n}\n\nexport interface TransportResponse {\n status: number;\n body?: unknown;\n /** Echoed server request id, when provided. */\n requestId?: string;\n}\n\nexport interface Transport {\n request(request: TransportRequest): Promise<TransportResponse>;\n}\n\nexport interface FetchTransportOptions {\n apiBaseUrl: string;\n /** Injectable for tests; defaults to global `fetch`. */\n fetchImpl?: typeof fetch;\n defaultTimeoutMs?: number;\n /** Injectable id generator (default: `crypto.randomUUID`). */\n generateRequestId?: () => string;\n}\n\nconst DEFAULT_TIMEOUT_MS = 10_000;\n\nconst STATUS_CODE_MAP: ReadonlyMap<number, ViceMeErrorCode> = new Map([\n [400, 'CONFIG_INVALID'],\n [401, 'SESSION_EXPIRED'],\n [403, 'CAPABILITY_DISABLED'],\n [404, 'WORK_NOT_FOUND'],\n [409, 'CONFIG_INVALID'],\n [422, 'CONFIG_INVALID'],\n [429, 'RATE_LIMITED'],\n]);\n\nconst KNOWN_CODES: ReadonlySet<string> = new Set([\n 'CONFIG_INVALID',\n 'WORK_NOT_FOUND',\n 'CAPABILITY_DISABLED',\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]);\n\n/** Extract a stable error payload from a JSON error body, if well-formed. */\nfunction parseErrorBody(body: unknown): {\n code?: ViceMeErrorCode;\n message?: string;\n retryable?: boolean;\n requestId?: string;\n} {\n if (typeof body !== 'object' || body === null) return {};\n const raw = body as Record<string, unknown>;\n const candidate =\n typeof raw.error === 'object' && raw.error !== null\n ? (raw.error as Record<string, unknown>)\n : raw;\n const result: {\n code?: ViceMeErrorCode;\n message?: string;\n retryable?: boolean;\n requestId?: string;\n } = {};\n if (typeof candidate.code === 'string' && KNOWN_CODES.has(candidate.code)) {\n result.code = candidate.code as ViceMeErrorCode;\n }\n if (typeof candidate.message === 'string') {\n result.message = candidate.message.slice(0, 200);\n }\n if (typeof candidate.retryable === 'boolean') {\n result.retryable = candidate.retryable;\n }\n if (typeof candidate.requestId === 'string') {\n result.requestId = candidate.requestId;\n }\n return result;\n}\n\nfunction defaultRequestId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `req-${Math.random().toString(36).slice(2)}`;\n}\n\nexport class FetchTransport implements Transport {\n readonly #apiBaseUrl: string;\n readonly #fetchImpl: typeof fetch;\n readonly #defaultTimeoutMs: number;\n readonly #generateRequestId: () => string;\n\n constructor(options: FetchTransportOptions) {\n this.#apiBaseUrl = options.apiBaseUrl.replace(/\\/+$/, '');\n this.#fetchImpl = options.fetchImpl ?? globalThis.fetch.bind(globalThis);\n this.#defaultTimeoutMs = options.defaultTimeoutMs ?? DEFAULT_TIMEOUT_MS;\n this.#generateRequestId = options.generateRequestId ?? defaultRequestId;\n }\n\n async request(request: TransportRequest): Promise<TransportResponse> {\n // A pre-aborted signal must never reach the network. Preserve the\n // caller's abort reason when one was set.\n if (request.signal?.aborted) {\n throw this.#callerAbortError(request.signal);\n }\n const timeoutMs = request.timeoutMs ?? this.#defaultTimeoutMs;\n const controller = new AbortController();\n // Engine notes: Chrome/Firefox reject fetch with the abort reason and\n // WebKit may reject with a plain error — so timeout/abort classification\n // keys off our own timer/signal state, never off the exception shape.\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n controller.abort(new TimeoutAbort());\n }, timeoutMs);\n const onOuterAbort = () => controller.abort(new TimeoutAbort(false));\n request.signal?.addEventListener('abort', onOuterAbort, { once: true });\n\n const requestId = this.#generateRequestId();\n try {\n const response = await this.#fetchImpl(`${this.#apiBaseUrl}${request.path}`, {\n method: request.method,\n // Public API is CORS-only; credentials must stay off so Shop session\n // cookies can never attach to public SDK requests.\n credentials: 'omit',\n mode: 'cors',\n headers: {\n 'content-type': 'application/json',\n 'x-client-request-id': requestId,\n ...(request.authorization !== undefined\n ? { authorization: `Bearer ${request.authorization}` }\n : {}),\n ...(request.userAuthorization !== undefined\n ? { 'x-viceme-user-token': request.userAuthorization }\n : {}),\n },\n body: request.body !== undefined ? JSON.stringify(request.body) : undefined,\n signal: controller.signal,\n });\n\n // Body reading stays inside the same timeout/abort lifecycle: a server\n // that returns headers and then stalls the body still hits\n // NETWORK_TIMEOUT, caller abort still cancels the read, and a late\n // body can never outlive a destroyed client/session.\n let body: unknown;\n try {\n body = await response.json();\n } catch (error) {\n // A malformed/empty body is tolerated; a cancelled read must\n // propagate so the outer handler can classify it.\n if (request.signal?.aborted || timedOut) {\n throw error;\n }\n body = undefined;\n }\n\n const serverRequestId = response.headers.get('x-request-id') ?? undefined;\n if (!response.ok) {\n const parsed = parseErrorBody(body);\n const code = parsed.code ?? STATUS_CODE_MAP.get(response.status) ?? 'INTERNAL_ERROR';\n throw new ViceMeError({\n code,\n message: parsed.message ?? 'Public API request failed.',\n retryable: parsed.retryable,\n requestId: parsed.requestId ?? serverRequestId,\n });\n }\n return { status: response.status, body, requestId: serverRequestId };\n } catch (cause) {\n if (request.signal?.aborted) {\n throw this.#callerAbortError(request.signal);\n }\n if (timedOut) {\n throw new ViceMeError({\n code: 'NETWORK_TIMEOUT',\n message: 'Public API request timed out.',\n retryable: true,\n requestId,\n });\n }\n // Non-OK statuses already carry a normalized error — pass it through.\n if (cause instanceof ViceMeError) {\n throw cause;\n }\n if (cause instanceof DOMException && cause.name === 'AbortError') {\n throw new DOMException('ViceMe request aborted by caller.', 'AbortError');\n }\n throw new ViceMeError({\n code: 'INTERNAL_ERROR',\n message: 'Public API request failed.',\n retryable: true,\n requestId,\n });\n } finally {\n clearTimeout(timer);\n request.signal?.removeEventListener('abort', onOuterAbort);\n }\n }\n\n /** Caller-abort error that preserves the caller's own abort reason. */\n #callerAbortError(signal: AbortSignal): unknown {\n return signal.reason instanceof Error\n ? signal.reason\n : new DOMException('ViceMe request aborted by caller.', 'AbortError');\n }\n}\n\nexport function createFetchTransport(options: FetchTransportOptions): Transport {\n return new FetchTransport(options);\n}\n\n/** Internal marker distinguishing timeout aborts from caller aborts. */\nclass TimeoutAbort extends DOMException {\n constructor(timedOut = true) {\n super(timedOut ? 'ViceMe request timed out.' : 'ViceMe request aborted.', 'AbortError');\n }\n}\n","/**\n * `@viceme-ai/sdk` public entry.\n *\n * Production consumers get `createViceMe` plus public types. Test injection\n * lives under `@viceme-ai/sdk/testing`.\n */\n\nimport { createFetchTransport } from './transport/transport.ts';\nimport { resolveApiBaseUrl, validatePublicConfig } from './core/config.ts';\nimport { ViceMeClientImpl } from './core/client.ts';\nimport { ViceMeError, isViceMeError, type ViceMeErrorCode } from './core/errors.ts';\nimport type { ViceMeClient, ViceMeMountedInstance } from './core/client.ts';\nimport type { ViceMeRegion, ViceMeConfig } from './core/config.ts';\nimport type { ViceMeClientState } from './core/lifecycle.ts';\nimport type {\n AccessCapability,\n AccessDecision,\n AccessFeaturePresentation,\n AccessPolicyType,\n AccessReason,\n AuthCapability,\n AuthState,\n CheckoutCapability,\n CheckoutOptions,\n CheckoutResult,\n} from './core/capabilities.ts';\nimport type { WorkUser } from './session/session.ts';\nimport { SDK_VERSION, API_MAJOR } from './version.ts';\n\nexport { ViceMeError, isViceMeError, SDK_VERSION, API_MAJOR, resolveApiBaseUrl };\nexport type {\n ViceMeClient,\n ViceMeMountedInstance,\n ViceMeConfig,\n ViceMeRegion,\n ViceMeClientState,\n ViceMeErrorCode,\n AccessCapability,\n AccessDecision,\n AccessFeaturePresentation,\n AccessPolicyType,\n AccessReason,\n AuthCapability,\n AuthState,\n CheckoutCapability,\n CheckoutOptions,\n CheckoutResult,\n WorkUser,\n};\n\n/**\n * Create a ViceMe client for one Work. Hosted capabilities initialize locally;\n * website access establishes a short-lived Work session only when used.\n *\n * @example\n * ```ts\n * const client = createViceMe({ workKey: 'wrk_live_demo', region: 'cn' });\n * await client.ready();\n * client.destroy();\n * ```\n */\nexport function createViceMe(config: unknown): ViceMeClient {\n const validated = validatePublicConfig(config);\n const apiBaseUrl = resolveApiBaseUrl(validated.region);\n const transport = createFetchTransport({\n apiBaseUrl,\n });\n return new ViceMeClientImpl({ config: validated, transport });\n}\n"],"names":["DEFAULT_TIMEOUT_MS","STATUS_CODE_MAP","KNOWN_CODES","parseErrorBody","body","raw","candidate","result","defaultRequestId","FetchTransport","#apiBaseUrl","#fetchImpl","#defaultTimeoutMs","#generateRequestId","options","request","#callerAbortError","timeoutMs","controller","timedOut","timer","TimeoutAbort","onOuterAbort","requestId","response","error","serverRequestId","parsed","code","ViceMeError","cause","signal","createFetchTransport","createViceMe","config","validated","validatePublicConfig","apiBaseUrl","resolveApiBaseUrl","transport","ViceMeClientImpl"],"mappings":";;;;AA8CA,MAAMA,IAAqB,KAErBC,wBAA4D,IAAI;AAAA,EACpE,CAAC,KAAK,gBAAgB;AAAA,EACtB,CAAC,KAAK,iBAAiB;AAAA,EACvB,CAAC,KAAK,qBAAqB;AAAA,EAC3B,CAAC,K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AAA,IACrC,YAAAK;AAAA,EAAA,CACD;AACD,SAAO,IAAIG,EAAiB,EAAE,QAAQL,GAAW,WAAAI,GAAW;AAC9D;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/transport/transport.ts","../src/index.ts"],"sourcesContent":["/**\n * HTTP transport for the public API.\n *\n * Responsibilities: request execution with timeout, abort, client request ids,\n * and normalization of every failure into the public `ViceMeError` model.\n * Capabilities and the loader never build their own `fetch` calls — they go\n * through a Transport so tests can swap in `createMemoryTransport`.\n */\n\nimport { ViceMeError, type ViceMeErrorCode } from '../core/errors.ts';\n\nexport interface TransportRequest {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE';\n /** Absolute path under the public API base. */\n path: string;\n /** JSON-serializable request body. */\n body?: unknown;\n /** Work-session token. It is never persisted by the transport. */\n authorization?: string;\n /** Optional memory-only signed-in widget token. */\n userAuthorization?: string;\n signal?: AbortSignal;\n /** Per-request timeout; defaults to the transport default. */\n timeoutMs?: number;\n}\n\nexport interface TransportResponse {\n status: number;\n body?: unknown;\n /** Echoed server request id, when provided. */\n requestId?: string;\n}\n\nexport interface Transport {\n request(request: TransportRequest): Promise<TransportResponse>;\n}\n\nexport interface FetchTransportOptions {\n apiBaseUrl: string;\n /** Injectable for tests; defaults to global `fetch`. */\n fetchImpl?: typeof fetch;\n defaultTimeoutMs?: number;\n /** Injectable id generator (default: `crypto.randomUUID`). */\n generateRequestId?: () => string;\n}\n\nconst DEFAULT_TIMEOUT_MS = 10_000;\n\nconst STATUS_CODE_MAP: ReadonlyMap<number, ViceMeErrorCode> = new Map([\n [400, 'CONFIG_INVALID'],\n [401, 'SESSION_EXPIRED'],\n [403, 'CAPABILITY_DISABLED'],\n [404, 'WORK_NOT_FOUND'],\n [409, 'CONFIG_INVALID'],\n [422, 'CONFIG_INVALID'],\n [429, 'RATE_LIMITED'],\n]);\n\nconst KNOWN_CODES: ReadonlySet<string> = new Set([\n 'CONFIG_INVALID',\n 'WORK_NOT_FOUND',\n 'CAPABILITY_DISABLED',\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]);\n\n/** Extract a stable error payload from a JSON error body, if well-formed. */\nfunction parseErrorBody(body: unknown): {\n code?: ViceMeErrorCode;\n message?: string;\n retryable?: boolean;\n requestId?: string;\n} {\n if (typeof body !== 'object' || body === null) return {};\n const raw = body as Record<string, unknown>;\n const candidate =\n typeof raw.error === 'object' && raw.error !== null\n ? (raw.error as Record<string, unknown>)\n : raw;\n const result: {\n code?: ViceMeErrorCode;\n message?: string;\n retryable?: boolean;\n requestId?: string;\n } = {};\n if (typeof candidate.code === 'string' && KNOWN_CODES.has(candidate.code)) {\n result.code = candidate.code as ViceMeErrorCode;\n }\n if (typeof candidate.message === 'string') {\n result.message = candidate.message.slice(0, 200);\n }\n if (typeof candidate.retryable === 'boolean') {\n result.retryable = candidate.retryable;\n }\n if (typeof candidate.requestId === 'string') {\n result.requestId = candidate.requestId;\n }\n return result;\n}\n\nfunction defaultRequestId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `req-${Math.random().toString(36).slice(2)}`;\n}\n\nexport class FetchTransport implements Transport {\n readonly #apiBaseUrl: string;\n readonly #fetchImpl: typeof fetch;\n readonly #defaultTimeoutMs: number;\n readonly #generateRequestId: () => string;\n\n constructor(options: FetchTransportOptions) {\n this.#apiBaseUrl = options.apiBaseUrl.replace(/\\/+$/, '');\n this.#fetchImpl = options.fetchImpl ?? globalThis.fetch.bind(globalThis);\n this.#defaultTimeoutMs = options.defaultTimeoutMs ?? DEFAULT_TIMEOUT_MS;\n this.#generateRequestId = options.generateRequestId ?? defaultRequestId;\n }\n\n async request(request: TransportRequest): Promise<TransportResponse> {\n // A pre-aborted signal must never reach the network. Preserve the\n // caller's abort reason when one was set.\n if (request.signal?.aborted) {\n throw this.#callerAbortError(request.signal);\n }\n const timeoutMs = request.timeoutMs ?? this.#defaultTimeoutMs;\n const controller = new AbortController();\n // Engine notes: Chrome/Firefox reject fetch with the abort reason and\n // WebKit may reject with a plain error — so timeout/abort classification\n // keys off our own timer/signal state, never off the exception shape.\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n controller.abort(new TimeoutAbort());\n }, timeoutMs);\n const onOuterAbort = () => controller.abort(new TimeoutAbort(false));\n request.signal?.addEventListener('abort', onOuterAbort, { once: true });\n\n const requestId = this.#generateRequestId();\n try {\n const response = await this.#fetchImpl(`${this.#apiBaseUrl}${request.path}`, {\n method: request.method,\n // Public API is CORS-only; credentials must stay off so Shop session\n // cookies can never attach to public SDK requests.\n credentials: 'omit',\n mode: 'cors',\n headers: {\n 'content-type': 'application/json',\n 'x-client-request-id': requestId,\n ...(request.authorization !== undefined\n ? { authorization: `Bearer ${request.authorization}` }\n : {}),\n ...(request.userAuthorization !== undefined\n ? { 'x-viceme-user-token': request.userAuthorization }\n : {}),\n },\n body: request.body !== undefined ? JSON.stringify(request.body) : undefined,\n signal: controller.signal,\n });\n\n // Body reading stays inside the same timeout/abort lifecycle: a server\n // that returns headers and then stalls the body still hits\n // NETWORK_TIMEOUT, caller abort still cancels the read, and a late\n // body can never outlive a destroyed client/session.\n let body: unknown;\n try {\n body = await response.json();\n } catch (error) {\n // A malformed/empty body is tolerated; a cancelled read must\n // propagate so the outer handler can classify it.\n if (request.signal?.aborted || timedOut) {\n throw error;\n }\n body = undefined;\n }\n\n // A fulfilled body promise cannot be rejected by abort(). Recheck before\n // delivering it so cancellation between parsing and this continuation\n // cannot turn into a successful request or a cached Work session.\n if (controller.signal.aborted) throw controller.signal.reason;\n\n const serverRequestId = response.headers.get('x-request-id') ?? undefined;\n if (!response.ok) {\n const parsed = parseErrorBody(body);\n const code = parsed.code ?? STATUS_CODE_MAP.get(response.status) ?? 'INTERNAL_ERROR';\n throw new ViceMeError({\n code,\n message: parsed.message ?? 'Public API request failed.',\n retryable: parsed.retryable,\n requestId: parsed.requestId ?? serverRequestId,\n });\n }\n return { status: response.status, body, requestId: serverRequestId };\n } catch (cause) {\n if (request.signal?.aborted) {\n throw this.#callerAbortError(request.signal);\n }\n if (timedOut) {\n throw new ViceMeError({\n code: 'NETWORK_TIMEOUT',\n message: 'Public API request timed out.',\n retryable: true,\n requestId,\n });\n }\n // Non-OK statuses already carry a normalized error — pass it through.\n if (cause instanceof ViceMeError) {\n throw cause;\n }\n if (cause instanceof DOMException && cause.name === 'AbortError') {\n throw new DOMException('ViceMe request aborted by caller.', 'AbortError');\n }\n throw new ViceMeError({\n code: 'INTERNAL_ERROR',\n message: 'Public API request failed.',\n retryable: true,\n requestId,\n });\n } finally {\n clearTimeout(timer);\n request.signal?.removeEventListener('abort', onOuterAbort);\n }\n }\n\n /** Caller-abort error that preserves the caller's own abort reason. */\n #callerAbortError(signal: AbortSignal): unknown {\n return signal.reason instanceof Error\n ? signal.reason\n : new DOMException('ViceMe request aborted by caller.', 'AbortError');\n }\n}\n\nexport function createFetchTransport(options: FetchTransportOptions): Transport {\n return new FetchTransport(options);\n}\n\n/** Internal marker distinguishing timeout aborts from caller aborts. */\nclass TimeoutAbort extends DOMException {\n constructor(timedOut = true) {\n super(timedOut ? 'ViceMe request timed out.' : 'ViceMe request aborted.', 'AbortError');\n }\n}\n","/**\n * `@viceme-ai/sdk` public entry.\n *\n * Production consumers get `createViceMe` plus public types. Test injection\n * lives under `@viceme-ai/sdk/testing`.\n */\n\nimport { createFetchTransport } from './transport/transport.ts';\nimport { resolveApiBaseUrl, validatePublicConfig } from './core/config.ts';\nimport { ViceMeClientImpl } from './core/client.ts';\nimport { ViceMeError, isViceMeError, type ViceMeErrorCode } from './core/errors.ts';\nimport type { ViceMeClient, ViceMeMountedInstance } from './core/client.ts';\nimport type { ViceMeRegion, ViceMeConfig } from './core/config.ts';\nimport type { ViceMeClientState } from './core/lifecycle.ts';\nimport type {\n AccessCapability,\n AccessDecision,\n AccessFeaturePresentation,\n AccessPolicyType,\n AccessReason,\n AuthCapability,\n AuthState,\n CheckoutCapability,\n CheckoutOptions,\n CheckoutResult,\n} from './core/capabilities.ts';\nimport type { WorkUser } from './session/session.ts';\nimport { SDK_VERSION, API_MAJOR } from './version.ts';\n\nexport { ViceMeError, isViceMeError, SDK_VERSION, API_MAJOR, resolveApiBaseUrl };\nexport type {\n ViceMeClient,\n ViceMeMountedInstance,\n ViceMeConfig,\n ViceMeRegion,\n ViceMeClientState,\n ViceMeErrorCode,\n AccessCapability,\n AccessDecision,\n AccessFeaturePresentation,\n AccessPolicyType,\n AccessReason,\n AuthCapability,\n AuthState,\n CheckoutCapability,\n CheckoutOptions,\n CheckoutResult,\n WorkUser,\n};\n\n/**\n * Create a ViceMe client for one Work. Hosted capabilities initialize locally;\n * website access establishes a short-lived Work session only when used.\n *\n * @example\n * ```ts\n * const client = createViceMe({ workKey: 'wrk_live_demo', region: 'cn' });\n * await client.ready();\n * client.destroy();\n * ```\n */\nexport function createViceMe(config: unknown): ViceMeClient {\n const validated = validatePublicConfig(config);\n const apiBaseUrl = resolveApiBaseUrl(validated.region);\n const transport = createFetchTransport({\n apiBaseUrl,\n });\n return new ViceMeClientImpl({ config: validated, transport });\n}\n"],"names":["DEFAULT_TIMEOUT_MS","STATUS_CODE_MAP","KNOWN_CODES","parseErrorBody","body","raw","candidate","result","defaultRequestId","FetchTransport","#apiBaseUrl","#fetchImpl","#defaultTimeoutMs","#generateRequestId","options","request","#callerAbortError","timeoutMs","controller","timedOut","timer","TimeoutAbort","onOuterAbort","requestId","response","error","serverRequestId","parsed","code","ViceMeError","cause","signal","createFetchTransport","createViceMe","config","validated","validatePublicConfig","apiBaseUrl","resolveApiBaseUrl","transport","ViceMeClientImpl"],"mappings":";;;;AA8CA,MAAMA,IAAqB,KAErBC,wBAA4D,IAAI;AAAA,EACpE,CAAC,KAAK,gBAAgB;AAAA,EACtB,CAA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|
package/dist/manifest.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.7.0",
|
|
3
3
|
"apiMajor": 1,
|
|
4
4
|
"loader": "viceme.min.js",
|
|
5
5
|
"features": {
|
|
6
6
|
"danmaku": "danmaku.js",
|
|
7
7
|
"tip": "tip.js"
|
|
8
8
|
},
|
|
9
|
+
"integrations": {
|
|
10
|
+
"engagement": "danmaku-tip-v1"
|
|
11
|
+
},
|
|
9
12
|
"files": {
|
|
10
13
|
"chunks/build-endpoints-NrDmg6jf.js": {
|
|
11
14
|
"sha256": "e8bce296ef95b4a5701d8379b7266c97fe0694230f0598d98d11d237d2b36fa9",
|
|
@@ -13,11 +16,11 @@
|
|
|
13
16
|
"bytes": 230,
|
|
14
17
|
"gzipBytes": 159
|
|
15
18
|
},
|
|
16
|
-
"chunks/client-
|
|
17
|
-
"sha256": "
|
|
18
|
-
"sri": "sha384-
|
|
19
|
-
"bytes":
|
|
20
|
-
"gzipBytes":
|
|
19
|
+
"chunks/client-C1Sw400H.js": {
|
|
20
|
+
"sha256": "bbb1ce01e43d80d63b496dfffb21f83b8f1a55a9b365121dbc7d5245c2dfe51e",
|
|
21
|
+
"sri": "sha384-bOhx9JeT3w3WoPlb9oMoenQpdB25GbuoxRfvBafZSXB5EHVn6mZ3BRpM+CgU+XKN",
|
|
22
|
+
"bytes": 36824,
|
|
23
|
+
"gzipBytes": 10165
|
|
21
24
|
},
|
|
22
25
|
"chunks/errors-C7DfLKcF.js": {
|
|
23
26
|
"sha256": "6ed053a2ab0ff6d4969ed644fb4e4ae89e850526f32c7841294a964447d2d1f3",
|
|
@@ -25,41 +28,47 @@
|
|
|
25
28
|
"bytes": 1060,
|
|
26
29
|
"gzipBytes": 569
|
|
27
30
|
},
|
|
31
|
+
"chunks/integration-CTsnJ8mN.js": {
|
|
32
|
+
"sha256": "b7417641e74bf05e42a3c5b517e80bf7c2b4eab2801505ef49d5a9f282577cee",
|
|
33
|
+
"sri": "sha384-EVR2gQHRN7rcn1CpLvncHa3JV70NPWzgYLxulJle/3AehbmRcooW+kjSQlJb1htw",
|
|
34
|
+
"bytes": 949,
|
|
35
|
+
"gzipBytes": 404
|
|
36
|
+
},
|
|
28
37
|
"chunks/validation-patAYhXC.js": {
|
|
29
38
|
"sha256": "4f5555a1c8f88023a34fb634aa7b929994a93629d464fed6a36097c36f49f28c",
|
|
30
39
|
"sri": "sha384-+iwC/1352gO5xHupqPqG75gtro0m6lI/7r2zS3orfHrFUvH1je0kMHVhPZjmPflV",
|
|
31
40
|
"bytes": 1379,
|
|
32
41
|
"gzipBytes": 657
|
|
33
42
|
},
|
|
34
|
-
"chunks/version-
|
|
35
|
-
"sha256": "
|
|
36
|
-
"sri": "sha384-
|
|
43
|
+
"chunks/version-CAPPYmfK.js": {
|
|
44
|
+
"sha256": "04fbb6975ce58451b582bee61bccddee2f31d1570734c5e19d871a1654ef21b7",
|
|
45
|
+
"sri": "sha384-Vp5afNogyOaQ14y0AFsiaye67KEsiDKMI9ie36KYnzBiNUwQyybBSq7OvcjSjA7n",
|
|
37
46
|
"bytes": 102,
|
|
38
47
|
"gzipBytes": 119
|
|
39
48
|
},
|
|
40
49
|
"danmaku.js": {
|
|
41
|
-
"sha256": "
|
|
42
|
-
"sri": "sha384-
|
|
43
|
-
"bytes":
|
|
44
|
-
"gzipBytes":
|
|
50
|
+
"sha256": "c9dcb06b90fba528640c6f9758db14fd492b163afd12e168e16fa662a8a8ca2c",
|
|
51
|
+
"sri": "sha384-wOuLfAjuepgH0jLIlG9/rH1FiZCe2Ij+0q/E60WBsSR/X79pGp+wgz5Ewfs2HtPG",
|
|
52
|
+
"bytes": 10426,
|
|
53
|
+
"gzipBytes": 3660
|
|
45
54
|
},
|
|
46
55
|
"index.js": {
|
|
47
|
-
"sha256": "
|
|
48
|
-
"sri": "sha384-
|
|
49
|
-
"bytes":
|
|
50
|
-
"gzipBytes":
|
|
56
|
+
"sha256": "6ffa1035b7fe005f74527533fbd3c1349c37619f9a1ebfef10b2488b753d1fc4",
|
|
57
|
+
"sri": "sha384-UIrCeSJl8+UfIPVprZaSRiB2Rd8/jqda4e5esmbtNbExFghTIkWKXfT9bNjkMjws",
|
|
58
|
+
"bytes": 4523,
|
|
59
|
+
"gzipBytes": 1858
|
|
51
60
|
},
|
|
52
61
|
"testing.js": {
|
|
53
|
-
"sha256": "
|
|
54
|
-
"sri": "sha384
|
|
62
|
+
"sha256": "119378a8d3ea100ebbe6b76a97d0bc2a8606249855b50129946ff85827651cfc",
|
|
63
|
+
"sri": "sha384-/Tt0lz2Krdll4rEbeRIGV8/UmixqYisl4W6Uiv54O+Vw/l1p8sI3H/yJH/WSPYN0",
|
|
55
64
|
"bytes": 2300,
|
|
56
65
|
"gzipBytes": 1025
|
|
57
66
|
},
|
|
58
67
|
"tip.js": {
|
|
59
|
-
"sha256": "
|
|
60
|
-
"sri": "sha384-
|
|
61
|
-
"bytes":
|
|
62
|
-
"gzipBytes":
|
|
68
|
+
"sha256": "fd3df8a0b2f9541cb39c7c55eaeeb7a8cd150615150b8fb7980b99d3575847e6",
|
|
69
|
+
"sri": "sha384-0KLV4poX0J5b7reY1Wvy5st3obvH7dBGC63CRGqSA+Nghp5i64BfclFVz/pBS0io",
|
|
70
|
+
"bytes": 18912,
|
|
71
|
+
"gzipBytes": 5619
|
|
63
72
|
},
|
|
64
73
|
"tip/testing.js": {
|
|
65
74
|
"sha256": "e08b67e78313587a6efbf75ff3cc5f8cc20a86daff9fff721c00eec2dcdb8198",
|
|
@@ -68,10 +77,10 @@
|
|
|
68
77
|
"gzipBytes": 540
|
|
69
78
|
},
|
|
70
79
|
"viceme.min.js": {
|
|
71
|
-
"sha256": "
|
|
72
|
-
"sri": "sha384-
|
|
73
|
-
"bytes":
|
|
74
|
-
"gzipBytes":
|
|
80
|
+
"sha256": "c81eb557104b940a3cbdc0d5eb7bdb194f8a46be5f2746a579f33b25c91f5466",
|
|
81
|
+
"sri": "sha384-S9WTNMsrBT7Bc6LcmaWAfi/foxS9BQdX+v2mKB9RxLtLlSOF4ereiQXLaZptgNSX",
|
|
82
|
+
"bytes": 42106,
|
|
83
|
+
"gzipBytes": 12750
|
|
75
84
|
}
|
|
76
85
|
}
|
|
77
86
|
}
|
|
@@ -19,6 +19,18 @@ export interface WorkDescriptor {
|
|
|
19
19
|
key: string;
|
|
20
20
|
/** Capability names enabled for this work. */
|
|
21
21
|
capabilities: string[];
|
|
22
|
+
creator?: WorkCreatorDescriptor;
|
|
23
|
+
details?: WorkPresentationDescriptor;
|
|
24
|
+
}
|
|
25
|
+
export interface WorkCreatorDescriptor {
|
|
26
|
+
displayName: string;
|
|
27
|
+
avatarUrl: string | null;
|
|
28
|
+
publishedWorkCount: number;
|
|
29
|
+
}
|
|
30
|
+
export interface WorkPresentationDescriptor {
|
|
31
|
+
title: string;
|
|
32
|
+
summary: string;
|
|
33
|
+
coverUrl: string | null;
|
|
22
34
|
}
|
|
23
35
|
export interface WorkSessionSnapshot {
|
|
24
36
|
work: WorkDescriptor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/session/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAChG,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,YAAY,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/session/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAChG,MAAM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AMG;IACH,SAAS,IAAI,OAAO,CAAC,mBAAmB,CAAC;IA8BnC,OAAO,CACX,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,eAAe,GAAG,mBAAmB,GAAG,QAAQ,CAAC,GAChF,OAAO,CAAC,iBAAiB,CAAC;IAe7B,YAAY,CAAC,KAAK,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,QAAQ,CAAA;KAAE,GAAG,IAAI;IAU1D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAM9B,2DAA2D;IAC3D,UAAU,IAAI,IAAI;IAMlB,uDAAuD;IACvD,OAAO,IAAI,IAAI;CAoChB"}
|
package/dist/testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as i } from "./chunks/errors-C7DfLKcF.js";
|
|
2
|
-
import { i as l, a as u, V as k } from "./chunks/client-
|
|
2
|
+
import { i as l, a as u, V as k } from "./chunks/client-C1Sw400H.js";
|
|
3
3
|
function g(e) {
|
|
4
4
|
const s = [], o = [...e.sessionFailures ?? []], a = e.latencyMs ?? 0;
|
|
5
5
|
return {
|
package/dist/tip/index.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ export interface TipClient {
|
|
|
42
42
|
export interface TipMountOptions {
|
|
43
43
|
target: Element;
|
|
44
44
|
theme: 'light' | 'dark' | 'auto';
|
|
45
|
+
/** Keep Tip hidden until the matching danmaku bar opens its official dialog. */
|
|
46
|
+
presentation?: 'inline' | 'integrated';
|
|
45
47
|
signal?: AbortSignal;
|
|
46
48
|
}
|
|
47
49
|
export interface TipMountHandle {
|
package/dist/tip/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tip/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAItD,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,QAAQ,CAA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AAS,CAEzD;AAED,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAgChG"}
|
package/dist/tip/mount.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/tip/mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAItD,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/tip/mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAItD,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAU5F,eAAO,MAAM,sBAAsB,OAAQ,CAAC;AAY5C,wBAAsB,KAAK,CACzB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAqPhC"}
|