@viceme-ai/sdk 0.1.6 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +29 -5
  2. package/dist/bootstrap.min.js +1 -1
  3. package/dist/bootstrap.min.js.map +1 -1
  4. package/dist/chunks/client-DKsaEtwq.js +941 -0
  5. package/dist/chunks/client-DKsaEtwq.js.map +1 -0
  6. package/dist/chunks/version-C3KVoLNb.js +51 -0
  7. package/dist/chunks/version-C3KVoLNb.js.map +1 -0
  8. package/dist/core/build-endpoints.d.ts +9 -0
  9. package/dist/core/build-endpoints.d.ts.map +1 -0
  10. package/dist/core/capabilities.d.ts +79 -0
  11. package/dist/core/capabilities.d.ts.map +1 -0
  12. package/dist/core/client.d.ts +14 -2
  13. package/dist/core/client.d.ts.map +1 -1
  14. package/dist/core/config.d.ts.map +1 -1
  15. package/dist/core/errors.d.ts +1 -1
  16. package/dist/core/errors.d.ts.map +1 -1
  17. package/dist/core/presentation.d.ts +24 -0
  18. package/dist/core/presentation.d.ts.map +1 -0
  19. package/dist/danmaku/anchor.d.ts +14 -0
  20. package/dist/danmaku/anchor.d.ts.map +1 -0
  21. package/dist/danmaku/index.d.ts +12 -0
  22. package/dist/danmaku/index.d.ts.map +1 -0
  23. package/dist/danmaku/mount.d.ts +5 -0
  24. package/dist/danmaku/mount.d.ts.map +1 -0
  25. package/dist/danmaku.js +198 -0
  26. package/dist/danmaku.js.map +1 -0
  27. package/dist/generated/public-contract.d.ts +630 -14
  28. package/dist/generated/public-contract.d.ts.map +1 -1
  29. package/dist/index.d.ts +5 -4
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +52 -50
  32. package/dist/index.js.map +1 -1
  33. package/dist/loader/attributes.d.ts +1 -1
  34. package/dist/loader/attributes.d.ts.map +1 -1
  35. package/dist/loader/auto-loader.d.ts +6 -6
  36. package/dist/loader/auto-loader.d.ts.map +1 -1
  37. package/dist/loader/mount-handle.d.ts +2 -2
  38. package/dist/loader/mount-handle.d.ts.map +1 -1
  39. package/dist/loader/registry.d.ts +2 -2
  40. package/dist/manifest.json +37 -23
  41. package/dist/session/session.d.ts +15 -2
  42. package/dist/session/session.d.ts.map +1 -1
  43. package/dist/testing/test-adapter.d.ts +3 -1
  44. package/dist/testing/test-adapter.d.ts.map +1 -1
  45. package/dist/testing.js +14 -8
  46. package/dist/testing.js.map +1 -1
  47. package/dist/transport/transport.d.ts +4 -2
  48. package/dist/transport/transport.d.ts.map +1 -1
  49. package/dist/version.d.ts +1 -1
  50. package/dist/viceme.min.js +232 -1
  51. package/dist/viceme.min.js.map +1 -1
  52. package/package.json +8 -5
  53. package/dist/chunks/client-BAlcnQI_.js +0 -275
  54. package/dist/chunks/client-BAlcnQI_.js.map +0 -1
package/README.md CHANGED
@@ -18,13 +18,38 @@ import { createViceMe } from '@viceme-ai/sdk';
18
18
  const client = createViceMe({ workKey: 'wrk_public_xxx', region: 'cn' });
19
19
  await client.ready();
20
20
 
21
- if (client.hasCapability('danmaku')) {
22
- // capability subpath, e.g. '@viceme-ai/sdk/danmaku'
23
- }
21
+ // Use server-authoritative titles and prices in the host site's existing
22
+ // Button/Card components. This does not open or customize ViceMe checkout.
23
+ const features = await client.access.getFeatures();
24
+ const emperor = features.find((feature) => feature.featureKey === 'emperor');
25
+
26
+ const access = await client.access.checkMany(['dingdong', 'emperor']);
27
+ if (access.dingdong.allowed) enableDingdong();
28
+ if (access.emperor.allowed) enableEmperor();
29
+
30
+ // Call from a user gesture. A denied decision opens the ViceMe
31
+ // bottom-sheet/in-page Web Component. Creator details and recent work covers appear
32
+ // above one authorization action; accepted authorization automatically follows.
33
+ const decision = await client.access.require('emperor');
34
+ if (decision.allowed) enableEmperor();
24
35
 
25
36
  client.destroy();
26
37
  ```
27
38
 
39
+ When adding a host-side locked state or purchase entry, preserve the site's
40
+ existing component library, design tokens, responsive behavior, and feedback
41
+ patterns. Keep the original business action unchanged and call it only after
42
+ `access.require()` returns an allowed decision. Never hard-code a price from
43
+ local configuration; `getFeatures()` returns the current display price. The
44
+ ViceMe-owned authorization and checkout layer remains isolated and unchanged.
45
+
46
+ The SDK registers and mounts `<viceme-access-layer>` with isolated ViceMe-owned
47
+ styles. Authorization and checkout remain inside its iframe area and complete through
48
+ an origin- and channel-validated message; no browser popup, page navigation,
49
+ `confirm`, or `alert` is used. Custom site presenters and style inference are
50
+ not part of the current public contract. WeChat opens directly inside the frame,
51
+ and the checkout frame keeps a stable height while its content loads.
52
+
28
53
  Static HTML sites can use the CDN auto-loader instead — see the
29
54
  [repository README](https://github.com/ViceMe-AI/sdk).
30
55
 
@@ -44,5 +69,4 @@ await client.ready();
44
69
  ```
45
70
 
46
71
  Consumers branch on stable `ViceMeError.code` values only — never on error
47
- messages. Status: `0.x` infrastructure phase; capability subpaths land as
48
- their public API contracts go live.
72
+ messages. Work-session tokens and work-scoped users remain in memory only.
@@ -1,2 +1,2 @@
1
- (function(){"use strict";(()=>{const t=document.currentScript;if(!(t instanceof HTMLScriptElement)||!t.src)return;const c=typeof AbortSignal<"u"&&typeof AbortSignal.timeout=="function"?AbortSignal.timeout(8e3):void 0;fetch(new URL("/viceme-sdk/-/aliases/v1",t.src),{credentials:"omit",signal:c}).then(e=>{if(!e.ok)throw new Error(`pointer HTTP ${e.status}`);return e.text()}).then(e=>{const i=e.trim();if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(i))throw new Error("invalid pointer");const r=document.createElement("script");for(const n of t.getAttributeNames())n==="src"||n==="integrity"||r.setAttribute(n,t.getAttribute(n)??"");r.src=new URL(`/viceme-sdk/${i}/viceme.min.js`,t.src).href,(document.head??document.documentElement).append(r)}).catch(()=>{document.dispatchEvent(new CustomEvent("viceme:error",{detail:{code:"CONFIG_INVALID",retryable:!1},bubbles:!0,composed:!0}))})})()})();
1
+ (function(){"use strict";(()=>{const t=document.currentScript;if(!(t instanceof HTMLScriptElement)||!t.src)return;const c=typeof AbortSignal<"u"&&typeof AbortSignal.timeout=="function"?AbortSignal.timeout(8e3):void 0;fetch(new URL("/viceme-sdk/-/aliases/v1",t.src),{credentials:"omit",signal:c}).then(e=>{if(!e.ok)throw new Error(`pointer HTTP ${e.status}`);return e.text()}).then(e=>{const i=e.trim();if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(i))throw new Error("invalid pointer");const r=document.createElement("script");for(const n of t.getAttributeNames())n==="src"||n==="integrity"||n==="nonce"||r.setAttribute(n,t.getAttribute(n)??"");r.nonce=t.nonce,r.src=new URL(`/viceme-sdk/${i}/viceme.min.js`,t.src).href,(document.head??document.documentElement).append(r)}).catch(()=>{document.dispatchEvent(new CustomEvent("viceme:error",{detail:{code:"CONFIG_INVALID",retryable:!1},bubbles:!0,composed:!0}))})})()})();
2
2
  //# sourceMappingURL=bootstrap.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.min.js","sources":["../src/loader/bootstrap.ts"],"sourcesContent":["/**\n * FIXED alias bootstrap — the ONLY object under /viceme-sdk/v1/.\n *\n * Byte-stable for the whole API major (this file must not grow feature\n * logic): it reads the version pointer at /viceme-sdk/-/aliases/v1 and\n * injects the full versioned auto-loader at\n * /viceme-sdk/<version>/viceme.min.js with the same data-viceme-*\n * attributes. The full loader (and every future fix to it) lives in the\n * immutable exact-version directory, so the alias bytes never need to\n * change when releases ship.\n */\n(() => {\n const script = document.currentScript;\n if (!(script instanceof HTMLScriptElement) || !script.src) return;\n\n const signal =\n typeof AbortSignal !== 'undefined' && typeof AbortSignal.timeout === 'function'\n ? AbortSignal.timeout(8_000)\n : undefined;\n\n fetch(new URL('/viceme-sdk/-/aliases/v1', script.src), {\n credentials: 'omit',\n signal,\n })\n .then((response) => {\n if (!response.ok) throw new Error(`pointer HTTP ${response.status}`);\n return response.text();\n })\n .then((text) => {\n const version = text.trim();\n if (!/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$/.test(version)) {\n throw new Error('invalid pointer');\n }\n const loader = document.createElement('script');\n for (const name of script.getAttributeNames()) {\n // The loader gets its own src; integrity pins are not transferable.\n if (name === 'src' || name === 'integrity') continue;\n loader.setAttribute(name, script.getAttribute(name) ?? '');\n }\n loader.src = new URL(`/viceme-sdk/${version}/viceme.min.js`, script.src).href;\n (document.head ?? document.documentElement).append(loader);\n })\n .catch(() => {\n document.dispatchEvent(\n new CustomEvent('viceme:error', {\n detail: { code: 'CONFIG_INVALID', retryable: false },\n bubbles: true,\n composed: true,\n }),\n );\n });\n})();\n"],"names":["script","signal","response","text","version","loader","name"],"mappings":"0BAWC,IAAM,CACL,MAAMA,EAAS,SAAS,cACxB,GAAI,EAAEA,aAAkB,oBAAsB,CAACA,EAAO,IAAK,OAE3D,MAAMC,EACJ,OAAO,YAAgB,KAAe,OAAO,YAAY,SAAY,WACjE,YAAY,QAAQ,GAAK,EACzB,OAEN,MAAM,IAAI,IAAI,2BAA4BD,EAAO,GAAG,EAAG,CACrD,YAAa,OACb,OAAAC,CAAA,CACD,EACE,KAAMC,GAAa,CAClB,GAAI,CAACA,EAAS,GAAI,MAAM,IAAI,MAAM,gBAAgBA,EAAS,MAAM,EAAE,EACnE,OAAOA,EAAS,KAAA,CAClB,CAAC,EACA,KAAMC,GAAS,CACd,MAAMC,EAAUD,EAAK,KAAA,EACrB,GAAI,CAAC,sCAAsC,KAAKC,CAAO,EACrD,MAAM,IAAI,MAAM,iBAAiB,EAEnC,MAAMC,EAAS,SAAS,cAAc,QAAQ,EAC9C,UAAWC,KAAQN,EAAO,oBAEpBM,IAAS,OAASA,IAAS,aAC/BD,EAAO,aAAaC,EAAMN,EAAO,aAAaM,CAAI,GAAK,EAAE,EAE3DD,EAAO,IAAM,IAAI,IAAI,eAAeD,CAAO,iBAAkBJ,EAAO,GAAG,EAAE,MACxE,SAAS,MAAQ,SAAS,iBAAiB,OAAOK,CAAM,CAC3D,CAAC,EACA,MAAM,IAAM,CACX,SAAS,cACP,IAAI,YAAY,eAAgB,CAC9B,OAAQ,CAAE,KAAM,iBAAkB,UAAW,EAAA,EAC7C,QAAS,GACT,SAAU,EAAA,CACX,CAAA,CAEL,CAAC,CACL,GAAA"}
1
+ {"version":3,"file":"bootstrap.min.js","sources":["../src/loader/bootstrap.ts"],"sourcesContent":["/**\n * FIXED alias bootstrap — the ONLY object under /viceme-sdk/v1/.\n *\n * Byte-stable for the whole API major (this file must not grow feature\n * logic): it reads the version pointer at /viceme-sdk/-/aliases/v1 and\n * injects the full versioned auto-loader at\n * /viceme-sdk/<version>/viceme.min.js with the same data-viceme-*\n * attributes. The full loader (and every future fix to it) lives in the\n * immutable exact-version directory, so the alias bytes never need to\n * change when releases ship.\n */\n(() => {\n const script = document.currentScript;\n if (!(script instanceof HTMLScriptElement) || !script.src) return;\n\n const signal =\n typeof AbortSignal !== 'undefined' && typeof AbortSignal.timeout === 'function'\n ? AbortSignal.timeout(8_000)\n : undefined;\n\n fetch(new URL('/viceme-sdk/-/aliases/v1', script.src), {\n credentials: 'omit',\n signal,\n })\n .then((response) => {\n if (!response.ok) throw new Error(`pointer HTTP ${response.status}`);\n return response.text();\n })\n .then((text) => {\n const version = text.trim();\n if (!/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$/.test(version)) {\n throw new Error('invalid pointer');\n }\n const loader = document.createElement('script');\n for (const name of script.getAttributeNames()) {\n // The loader gets its own src; integrity pins are not transferable.\n if (name === 'src' || name === 'integrity' || name === 'nonce') continue;\n loader.setAttribute(name, script.getAttribute(name) ?? '');\n }\n loader.nonce = script.nonce;\n loader.src = new URL(`/viceme-sdk/${version}/viceme.min.js`, script.src).href;\n (document.head ?? document.documentElement).append(loader);\n })\n .catch(() => {\n document.dispatchEvent(\n new CustomEvent('viceme:error', {\n detail: { code: 'CONFIG_INVALID', retryable: false },\n bubbles: true,\n composed: true,\n }),\n );\n });\n})();\n"],"names":["script","signal","response","text","version","loader","name"],"mappings":"0BAWC,IAAM,CACL,MAAMA,EAAS,SAAS,cACxB,GAAI,EAAEA,aAAkB,oBAAsB,CAACA,EAAO,IAAK,OAE3D,MAAMC,EACJ,OAAO,YAAgB,KAAe,OAAO,YAAY,SAAY,WACjE,YAAY,QAAQ,GAAK,EACzB,OAEN,MAAM,IAAI,IAAI,2BAA4BD,EAAO,GAAG,EAAG,CACrD,YAAa,OACb,OAAAC,CAAA,CACD,EACE,KAAMC,GAAa,CAClB,GAAI,CAACA,EAAS,GAAI,MAAM,IAAI,MAAM,gBAAgBA,EAAS,MAAM,EAAE,EACnE,OAAOA,EAAS,KAAA,CAClB,CAAC,EACA,KAAMC,GAAS,CACd,MAAMC,EAAUD,EAAK,KAAA,EACrB,GAAI,CAAC,sCAAsC,KAAKC,CAAO,EACrD,MAAM,IAAI,MAAM,iBAAiB,EAEnC,MAAMC,EAAS,SAAS,cAAc,QAAQ,EAC9C,UAAWC,KAAQN,EAAO,oBAEpBM,IAAS,OAASA,IAAS,aAAeA,IAAS,SACvDD,EAAO,aAAaC,EAAMN,EAAO,aAAaM,CAAI,GAAK,EAAE,EAE3DD,EAAO,MAAQL,EAAO,MACtBK,EAAO,IAAM,IAAI,IAAI,eAAeD,CAAO,iBAAkBJ,EAAO,GAAG,EAAE,MACxE,SAAS,MAAQ,SAAS,iBAAiB,OAAOK,CAAM,CAC3D,CAAC,EACA,MAAM,IAAM,CACX,SAAS,cACP,IAAI,YAAY,eAAgB,CAC9B,OAAQ,CAAE,KAAM,iBAAkB,UAAW,EAAA,EAC7C,QAAS,GACT,SAAU,EAAA,CACX,CAAA,CAEL,CAAC,CACL,GAAA"}