webs-sdk 0.19.64 → 0.19.66

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 (101) hide show
  1. package/AGENTS.md +44 -0
  2. package/CLAUDE.md +80 -0
  3. package/README.md +513 -490
  4. package/dist/components/ARFilters/ARFilters.js +54 -54
  5. package/dist/components/ArtGenerator.js +141 -141
  6. package/dist/components/AvatarAI.js +14 -14
  7. package/dist/components/CookieConsent/constants.js +31 -31
  8. package/dist/components/CreativeFaceSwap.js +23 -23
  9. package/dist/components/GifsIa.js +76 -76
  10. package/dist/components/MemeGenerator.js +12 -12
  11. package/dist/components/PasswordReset/constants.js +33 -33
  12. package/dist/components/RecoveryPassword/constants.js +27 -27
  13. package/dist/components/SpinningWheel/SpinningWheel.js +7 -7
  14. package/dist/components/SpinningWheel/index.d.ts +1 -1
  15. package/dist/components/SpinningWheel/index.d.ts.map +1 -1
  16. package/dist/components/SpinningWheel/index.js +2 -1
  17. package/dist/components/SpinningWheel/index.js.map +1 -1
  18. package/dist/components/ui/ConfiguredMediaPlayer.d.ts +49 -0
  19. package/dist/components/ui/ConfiguredMediaPlayer.d.ts.map +1 -0
  20. package/dist/components/ui/ConfiguredMediaPlayer.js +122 -0
  21. package/dist/components/ui/ConfiguredMediaPlayer.js.map +1 -0
  22. package/dist/components/ui/badge.d.ts +1 -0
  23. package/dist/components/ui/badge.d.ts.map +1 -1
  24. package/dist/components/ui/badge.js +1 -1
  25. package/dist/components/ui/badge.js.map +1 -1
  26. package/dist/components/ui/compose-refs.d.ts +6 -0
  27. package/dist/components/ui/compose-refs.d.ts.map +1 -0
  28. package/dist/components/ui/compose-refs.js +57 -0
  29. package/dist/components/ui/compose-refs.js.map +1 -0
  30. package/dist/components/ui/dropdown-menu.d.ts +3 -1
  31. package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
  32. package/dist/components/ui/dropdown-menu.js +2 -2
  33. package/dist/components/ui/dropdown-menu.js.map +1 -1
  34. package/dist/components/ui/index.d.ts +2 -0
  35. package/dist/components/ui/index.d.ts.map +1 -1
  36. package/dist/components/ui/index.js +2 -0
  37. package/dist/components/ui/index.js.map +1 -1
  38. package/dist/components/ui/media-player.d.ts +127 -0
  39. package/dist/components/ui/media-player.d.ts.map +1 -0
  40. package/dist/components/ui/media-player.js +1633 -0
  41. package/dist/components/ui/media-player.js.map +1 -0
  42. package/dist/components/ui/tooltip.d.ts +3 -1
  43. package/dist/components/ui/tooltip.d.ts.map +1 -1
  44. package/dist/components/ui/tooltip.js +2 -2
  45. package/dist/components/ui/tooltip.js.map +1 -1
  46. package/dist/components/ui/use-lazy-ref.d.ts +4 -0
  47. package/dist/components/ui/use-lazy-ref.d.ts.map +1 -0
  48. package/dist/components/ui/use-lazy-ref.js +45 -0
  49. package/dist/components/ui/use-lazy-ref.js.map +1 -0
  50. package/dist/index.d.ts +1 -1
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +4 -3
  53. package/dist/index.js.map +1 -1
  54. package/dist/network.d.ts +12 -0
  55. package/dist/network.d.ts.map +1 -0
  56. package/dist/network.js +15 -0
  57. package/dist/network.js.map +1 -0
  58. package/dist/server.d.ts +54 -0
  59. package/dist/server.d.ts.map +1 -0
  60. package/dist/server.js +74 -0
  61. package/dist/server.js.map +1 -0
  62. package/dist/types/media-chrome-store-types.d.ts +107 -0
  63. package/dist/types/media-chrome-store-types.d.ts.map +1 -0
  64. package/dist/types/media-chrome-store-types.js +3 -0
  65. package/dist/types/media-chrome-store-types.js.map +1 -0
  66. package/dist/utils/QRCode.d.ts +1 -0
  67. package/dist/utils/QRCode.d.ts.map +1 -0
  68. package/dist/utils/QRCode.js +2 -0
  69. package/dist/utils/QRCode.js.map +1 -0
  70. package/dist/utils/imageValidation.d.ts +6 -0
  71. package/dist/utils/imageValidation.d.ts.map +1 -0
  72. package/dist/utils/imageValidation.js +64 -0
  73. package/dist/utils/imageValidation.js.map +1 -0
  74. package/docs/CONFIGURED_MEDIA_PLAYER.md +40 -0
  75. package/docs/CORP_AUTH_USAGE.md +687 -0
  76. package/docs/EXAMPLES_WALLPAPERSNAME_IMPLEMENTATION.md +1445 -0
  77. package/docs/EXAMPLE_ENDPOINTS_COMUNICATION.md +55 -0
  78. package/docs/EXTERNAL_SDK_GUIDE.md +1340 -0
  79. package/docs/FOR_YOU_360_FACESWAP_FIX.md +400 -0
  80. package/docs/FOR_YOU_IMPLEMENTATION_GUIDE.md +1413 -0
  81. package/docs/FOR_YOU_QUIZ_ARCHITECTURE.md +753 -0
  82. package/docs/FOR_YOU_SDK_WALLPAPERSNAME_BUG.md +106 -0
  83. package/docs/FOR_YOU_WALLPAPERSNAME_ENHANCEMENT_PLAN.md +210 -0
  84. package/docs/LEGAL_USAGE.md +190 -0
  85. package/docs/STREAK_IMPLEMENTATION_GUIDE.md +430 -0
  86. package/package.json +106 -84
  87. package/public/spin2win/assets/border-afristream.svg +26 -26
  88. package/public/spin2win/assets/border-efc.svg +23 -23
  89. package/public/spin2win/assets/border-streetreel.svg +23 -23
  90. package/public/spin2win/assets/border-totalgym.svg +27 -27
  91. package/public/spin2win/assets/border-womantoday.svg +26 -26
  92. package/public/spin2win/assets/indicator-afristream.svg +28 -28
  93. package/public/spin2win/assets/indicator-efc.svg +29 -29
  94. package/public/spin2win/assets/indicator-streetreel.svg +29 -29
  95. package/public/spin2win/assets/indicator-totalgym.svg +29 -29
  96. package/public/spin2win/fonts/switzer/README.md +22 -22
  97. package/scripts/install-agent-skill.cjs +34 -0
  98. package/skills/webs-sdk-package/SKILL.md +21 -0
  99. package/skills/webs-sdk-package/references/components.md +32 -0
  100. package/skills/webs-sdk-package/references/integration.md +32 -0
  101. package/skills/webs-sdk-package/references/ui.md +197 -0
package/AGENTS.md ADDED
@@ -0,0 +1,44 @@
1
+ # Agent guide: webs-sdk
2
+
3
+ `webs-sdk` is a shared package for Nexum portals. Prefer an existing SDK export over copying a component or implementing shared behavior in a portal. This guide ships with the npm package. For automatic skill discovery in a consuming portal, run `npm exec -- webs-sdk-skill` after `npm install webs-sdk`; restart the agent. Pi can instead load the packaged skill with `pi install npm:webs-sdk --local` (requires a separate `npm install webs-sdk` for the portal). Without the skill, agents must explicitly read `node_modules/webs-sdk/AGENTS.md` because nested `node_modules` instructions are not automatically loaded. See `skills/webs-sdk-package/references/components.md` for the component map. Inspect `node_modules/webs-sdk/dist/index.d.ts` and `node_modules/webs-sdk/dist/components/ui/index.d.ts` for the **installed version's** exact exports and Props types; guides are not exhaustive. In the SDK source repository, read `CLAUDE.md` before editing code.
4
+
5
+ ## Choose the correct import
6
+
7
+ | Need | Import | Details |
8
+ | --- | --- | --- |
9
+ | Session, authentication, API, tracking, CDN, feature components | `webs-sdk` | Root public API in `src/index.ts`. Server/client suitability varies by export; do not put the whole `WebsSDK` singleton in a client component without checking its dependencies. |
10
+ | Radix primitives and media players | `webs-sdk/ui` | UI public API in `src/components/ui/index.ts`. Use this subpath, not private `dist/` paths. |
11
+ | Video with source, captions, controls configured via props | `ConfiguredMediaPlayer` from `webs-sdk/ui` | See `docs/CONFIGURED_MEDIA_PLAYER.md`. This is the preferred ready-to-use Radix player. |
12
+ | Custom video/audio control layout | `MediaPlayer` and `MediaPlayer*` from `webs-sdk/ui` | Compose children under `MediaPlayer`; no default media/controls are created for you. |
13
+ | Existing portals using the old video player | `VideoPlayer` from `webs-sdk/ui` | Legacy API (`videoUrl`, `posterImage`, `languages`). Do not silently replace with the new player: props and rendering differ. |
14
+
15
+ ## Portal integration: prop-configured video
16
+
17
+ ```tsx
18
+ 'use client';
19
+
20
+ import { ConfiguredMediaPlayer } from 'webs-sdk/ui';
21
+
22
+ export function ContentVideo({ url, poster }: { url: string; poster?: string }) {
23
+ return (
24
+ <ConfiguredMediaPlayer
25
+ src={url}
26
+ poster={poster}
27
+ label="Content video"
28
+ controls={{ seekButtons: true, captions: true, pictureInPicture: true }}
29
+ tracks={[{ src: '/subtitles/en.vtt', srcLang: 'en', label: 'English', kind: 'subtitles' }]}
30
+ />
31
+ );
32
+ }
33
+ ```
34
+
35
+ `src` is required, not `videoUrl`. `controls` overrides individual defaults; `settings` defaults to enabled, so use `{ settings: false, speed: true }` to show the standalone speed picker. HLS `.m3u8` loads natively where supported, otherwise loads `hls.js` on demand. Consumers need React/ReactDOM and the declared `lucide-react` peer dependency. Configure the portal's Tailwind v4 scan to include SDK UI files (`@source` path in `docs/CONFIGURED_MEDIA_PLAYER.md`); otherwise player controls may render without styling. Media playback requires a client component; merely importing an SDK component does not replace the portal's auth/session logic.
36
+
37
+ ## Before adding a reusable feature
38
+
39
+ 1. In a consuming portal, check the installed `webs-sdk` version and its `dist/index.d.ts` / `dist/components/ui/index.d.ts`, then inspect the exported Props declarations. Do not import from private `dist/` paths in application code.
40
+ 2. Prefer an existing SDK export in a portal. If no reusable feature exists, add it to the SDK source repository rather than copying implementations into multiple portals.
41
+ 3. When editing the SDK repository, check `src/index.ts` and `src/components/ui/index.ts`, use relative imports, export public Props/Config types, and add focused tests. Root exports require both `src/index.ts` and root `index.js`; `webs-sdk/ui` exports require `src/components/ui/index.ts` only.
42
+ 4. In the SDK repository, run `npm test`, `npm run test:types`, `npm run test:package`, and `npm run test:coverage` before release. Package checks verify `webs-sdk` and `webs-sdk/ui` entry points. Do not edit `dist/` by hand or bump the version manually.
43
+
44
+ Other guides: `CLAUDE.md` (development and publishing), `README.md` (public SDK overview), `docs/CONFIGURED_MEDIA_PLAYER.md` (media API), `docs/FOR_YOU_IMPLEMENTATION_GUIDE.md` and `docs/STREAK_IMPLEMENTATION_GUIDE.md` (feature integration).
package/CLAUDE.md ADDED
@@ -0,0 +1,80 @@
1
+ # CLAUDE.md
2
+
3
+ ## What this repo is
4
+
5
+ `webs-sdk` — internal npm package for Nexum web portals. Provides shared libraries (auth, sessions, networking, tracking, i18n, storage) and reusable React components (AvatarAI, Wallpapers, SpinningWheel, ARFilters, etc.). Published artifact is `dist/` (CommonJS, ES2017), plus `AGENTS.md`, `CLAUDE.md`, and `docs/` for agents working in consuming portals. The Next.js setup (`npm run dev`) is dev-only for visually testing components. For a portal integration decision tree and ready-to-copy media player example, start with `AGENTS.md`.
6
+
7
+ ## Commands
8
+
9
+ ```bash
10
+ npm run build # Compile src/ → dist/ via tsc (tsconfig.build.json)
11
+ npm run build:watch # Same, with --watch
12
+ npm run dev # Next.js dev server (component testing only)
13
+ npm run lint # ESLint (Next.js 16 flat config; existing source lint debt remains)
14
+ npm test # Vitest unit and browser-component tests (single run)
15
+ npm run test:watch # Vitest watch mode
16
+ npm run test:coverage # V8 coverage across all src/ files, including untouched files
17
+ npm run test:types # Typecheck SDK and test files without migration scratch files
18
+ npm run test:package # Build and verify published SDK/UI entry points and root exports
19
+ ```
20
+
21
+ Run `npm test`, `npm run test:types`, `npm run test:package`, and `npm run test:coverage` locally when changing SDK code. These tests do not call live backends. Test tooling needs Node.js 20.19+ (or 22.12+). Tests live in `tests/`; the build excludes them. Browser tests use `// @vitest-environment jsdom`. Coverage includes untested `src/` files at 0%; passing tests do not imply full SDK coverage. Full `npm run lint` currently reports pre-existing source errors; do not suppress them.
22
+
23
+ ## Architecture essentials
24
+
25
+ ```
26
+ src/
27
+ ├── index.ts # Source barrel — all public exports
28
+ ├── config.ts # Static defaults, mutated at runtime by executeInit()
29
+ ├── libraries/ # Core services (classes, instantiated as singletons)
30
+ │ ├── networking.ts # HTTP, events, /config init
31
+ │ ├── session.ts # Session orchestration (init flow entry point)
32
+ │ ├── auth.ts # JWT auth
33
+ │ ├── andromeda.ts # AI backend client
34
+ │ ├── calypso.ts # AI backend client (alt)
35
+ │ ├── mixpanel.ts # Mixpanel tracking
36
+ │ ├── storage.ts # localStorage wrapper
37
+ │ └── ...
38
+ ├── components/ # React components (self-contained, export types)
39
+ │ ├── AvatarAI.tsx # Single-file components with inline CSS
40
+ │ ├── SpinningWheel/ # Multi-file components in folders
41
+ │ └── ui/ # Shared UI primitives (radix-based)
42
+ └── utils/ # Pure utility functions
43
+ ```
44
+
45
+ **Public entry points (see `package.json`):**
46
+ - `webs-sdk` — `src/index.ts` is the TypeScript source barrel; root `/index.js` is the manually maintained CJS re-export. When adding a **root** export, update BOTH.
47
+ - `webs-sdk/ui` — `src/components/ui/index.ts` is its own barrel. When adding a **UI-only** export, update this barrel; no root export or root `/index.js` change is needed. Do not import from private `dist/` paths.
48
+
49
+ **Media player choice:** `ConfiguredMediaPlayer` accepts `src`, `poster`, `tracks`, `sources`, `controls`, and playback callbacks as props; use it for a ready-to-use Radix video/audio player. `MediaPlayer` plus `MediaPlayer*` parts is for custom control layouts. Existing `VideoPlayer` has a different API (`videoUrl`, `posterImage`, `languages`) and remains for backward compatibility. All three are in `webs-sdk/ui`. See `docs/CONFIGURED_MEDIA_PLAYER.md` for usage and Tailwind v4 `@source` integration; see `tests/mediaPlayer.test.tsx` for tests.
50
+
51
+ **Singleton SDK object** (`src/index.ts`): `WebsSDK` instantiates all libraries as singletons. A lazy `.pre` namespace provides preproduction instances (different backend URL).
52
+
53
+ **Init flow** (`Session.init()`):
54
+ 1. `storeSessionStructure()` — browser/device info
55
+ 2. `checkUserID()` — fetch or create user ID
56
+ 3. `networking.executeInit()` — fetches `/config`, mutates `config.ts` with endpoints, events, paywall data, image compression settings
57
+ 4. `checkFirstOpen()` — sends `first_open` event
58
+
59
+ ## Conventions
60
+
61
+ - **Language**: Code in English, comments often in Spanish
62
+ - **Components**: Most feature components are self-contained with inline CSS strings and export Props/Config/Theme/Texts types. UI primitives and Radix media players in `src/components/ui/` use Tailwind classes; consuming portals must scan the installed SDK UI files. See `docs/CONFIGURED_MEDIA_PLAYER.md`.
63
+ - **Libraries**: Class-based, each file exports a class and a default instance
64
+ - **Environment handling**: Constructor param `'production' | 'preproduction'` switches `backendBaseUrl`
65
+ - **Path aliases**: `@/*` → `./src/*` works in Next.js dev but NOT in the library build (`tsconfig.build.json` uses `moduleResolution: "node"`). Use relative imports in `src/`.
66
+ - **Tests** — add unit tests in `tests/` for new behavior, then run `npm test` and `npm run build`
67
+ - **Do not bump `package.json` version** manually
68
+
69
+ ## Publishing / CI
70
+
71
+ - `prepublishOnly` still runs only `npm run build`; local tests are not a publication gate
72
+ - Version bumping and publishing are handled by CI when commit messages contain a ticket reference `[ROAD-XXXXXX]`
73
+ - `builder.config.json` is for the visual Builder.io integration (dev only)
74
+
75
+ ## Gotchas
76
+
77
+ - `config.ts` exports a mutable object — `Networking.executeInit()` overwrites endpoint URLs, events, and feature flags at runtime
78
+ - The build uses `jsx: "react-jsx"` (see `tsconfig.build.json`)
79
+ - `tsconfig.build.json` extends `tsconfig.json` but overrides key settings (CommonJS, no emit in base, emit in build)
80
+ - `skipLibCheck: true` in build config — type errors in `node_modules` won't surface