@kywi-software/js 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +75 -0
  3. package/dist/audience/adapter-runner.d.ts +10 -0
  4. package/dist/audience/adapter-runner.d.ts.map +1 -0
  5. package/dist/audience/behavioral-collector.d.ts +15 -0
  6. package/dist/audience/behavioral-collector.d.ts.map +1 -0
  7. package/dist/audience/data-layer.d.ts +11 -0
  8. package/dist/audience/data-layer.d.ts.map +1 -0
  9. package/dist/audience/dom-patcher.d.ts +2 -0
  10. package/dist/audience/dom-patcher.d.ts.map +1 -0
  11. package/dist/audience/evaluate.d.ts +3 -0
  12. package/dist/audience/evaluate.d.ts.map +1 -0
  13. package/dist/audience/index.d.ts +24 -0
  14. package/dist/audience/index.d.ts.map +1 -0
  15. package/dist/audience/preview.d.ts +6 -0
  16. package/dist/audience/preview.d.ts.map +1 -0
  17. package/dist/audience/selfid-collector.d.ts +3 -0
  18. package/dist/audience/selfid-collector.d.ts.map +1 -0
  19. package/dist/audience/selfid-submit.d.ts +3 -0
  20. package/dist/audience/selfid-submit.d.ts.map +1 -0
  21. package/dist/audience/selfid-widget.d.ts +39 -0
  22. package/dist/audience/selfid-widget.d.ts.map +1 -0
  23. package/dist/audience/transparency-styles.d.ts +3 -0
  24. package/dist/audience/transparency-styles.d.ts.map +1 -0
  25. package/dist/audience/transparency.d.ts +12 -0
  26. package/dist/audience/transparency.d.ts.map +1 -0
  27. package/dist/consent.d.ts +24 -0
  28. package/dist/consent.d.ts.map +1 -0
  29. package/dist/context.d.ts +3 -0
  30. package/dist/context.d.ts.map +1 -0
  31. package/dist/cookies.d.ts +13 -0
  32. package/dist/cookies.d.ts.map +1 -0
  33. package/dist/entity.d.ts +3 -0
  34. package/dist/entity.d.ts.map +1 -0
  35. package/dist/experiments/index.d.ts +27 -0
  36. package/dist/experiments/index.d.ts.map +1 -0
  37. package/dist/feed.d.ts +51 -0
  38. package/dist/feed.d.ts.map +1 -0
  39. package/dist/form-hooks.d.ts +3 -0
  40. package/dist/form-hooks.d.ts.map +1 -0
  41. package/dist/index.d.ts +24 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/kywi.esm.js +1314 -0
  44. package/dist/kywi.esm.js.map +7 -0
  45. package/dist/kywi.js +1339 -0
  46. package/dist/kywi.js.map +7 -0
  47. package/dist/module-system.d.ts +2 -0
  48. package/dist/module-system.d.ts.map +1 -0
  49. package/dist/personalization/badge.d.ts +2 -0
  50. package/dist/personalization/badge.d.ts.map +1 -0
  51. package/dist/render-feed.d.ts +17 -0
  52. package/dist/render-feed.d.ts.map +1 -0
  53. package/dist/types.d.ts +44 -0
  54. package/dist/types.d.ts.map +1 -0
  55. package/package.json +48 -0
package/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # @kywi-software/js
2
+
3
+ The Kywi CMS browser runtime — audience personalization (variant swaps,
4
+ transparency badge), A/B experiment exposure/conversion beacons, the
5
+ self-ID widget, and content-form hooks. It reads a small JSON context that
6
+ `@kywi-software/core`'s server-rendered pages embed in the page, then patches
7
+ the DOM client-side. See the
8
+ [root README](https://github.com/kywi-software/kywi#readme) for how it fits
9
+ into the rest of Kywi.
10
+
11
+ This package ships two builds from the same source
12
+ (`packages/kywi-js/src/index.ts`):
13
+
14
+ - `dist/kywi.js` — an IIFE bundle that exposes a `Kywi` global. This is the
15
+ one Kywi CMS serves at the public URL `/kywi.js` (hence the package name).
16
+ - `dist/kywi.esm.js` — an ES module, for bundler-based setups.
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ npm install @kywi-software/js
22
+ ```
23
+
24
+ Most projects don't install this directly — a Kywi CMS site (any deployment
25
+ mode) serves the built bundle at `/kywi.js` automatically, and pages that
26
+ need it load it with a plain `<script>` tag (see below). Install it directly
27
+ if you're building a decoupled frontend and want to import it as an ES
28
+ module instead.
29
+
30
+ ## Usage: script tag (how Kywi CMS itself loads it)
31
+
32
+ ```html
33
+ <script src="/kywi.js" data-kywi-js defer></script>
34
+ ```
35
+
36
+ `Kywi` boots itself on `DOMContentLoaded` (or immediately if the document
37
+ has already loaded) — reads its context from `<meta name="kywi:*">` tags and
38
+ `data-kywi-*` attributes that the server-rendered page embeds
39
+ (`site-id`, `theme-path`, `base-path`, `csrf-token`, plus `<html lang>` and
40
+ `.kywi-edit-mode`), patches personalization variants and the transparency
41
+ badge into the DOM, and wires experiment exposure/conversion beacons and
42
+ form hooks. No manual `Kywi.boot()` call needed for the default flow; use
43
+ `Kywi.preInit(fn)` if you need to run code before boot.
44
+
45
+ ## Usage: ES module
46
+
47
+ ```ts
48
+ import { Kywi } from '@kywi-software/js'
49
+
50
+ Kywi.preInit((kywi) => {
51
+ // runs before boot — e.g. register a custom module via kywi.UI.extend(...)
52
+ })
53
+ ```
54
+
55
+ ## What it does
56
+
57
+ - **Personalization**: swaps `display:none` variant containers
58
+ (`data-kywi-variant`) based on the visitor's resolved audience, and fills
59
+ the transparency badge mount (`data-kywi-personalization-badge`) with an
60
+ opt-in/opt-out control.
61
+ - **Experiments**: confirms exposure of the server-rendered A/B variant and
62
+ wires conversion signals (pageview, auto-emitted on boot; form-submit,
63
+ auto-wired). The exported `bootExperiments()` (also usable standalone)
64
+ returns an `ExperimentRuntime` with `.track(eventName)` /
65
+ `.trackConversion(signal)` for custom conversions.
66
+ - **Self-ID widget**: renders the audience self-identification UI
67
+ (hello bar / modal / inline / drawer) authored in `/admin/audiences/self-id-widget`.
68
+ - **Feeds**: `Kywi.getFeed(type)` / `Kywi.renderFeed(options)` for
69
+ client-rendered content feeds.
70
+ - **Entities**: `Kywi.getEntity(type)` — a thin fetch wrapper over the
71
+ `/api/v1` REST API, scoped with the page's CSRF token.
72
+
73
+ `packages/kywi-js/src/index.ts` and its tests
74
+ (`packages/kywi-js/src/__tests__/*.test.ts`) are the source of truth for
75
+ exact behavior.
@@ -0,0 +1,10 @@
1
+ import type { VisitorSignals } from '@kywi-software/core/audiences/types';
2
+ interface PullAdapter {
3
+ id: string;
4
+ side: 'client' | 'server-proxy';
5
+ fields: string[];
6
+ collect: (signals: Partial<VisitorSignals>) => Promise<Record<string, unknown>>;
7
+ }
8
+ export declare function runClientAdapters(adapters: PullAdapter[], currentSignals: Partial<VisitorSignals>, apiBase?: string): Promise<Record<string, unknown>>;
9
+ export {};
10
+ //# sourceMappingURL=adapter-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter-runner.d.ts","sourceRoot":"","sources":["../../src/audience/adapter-runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AAEzE,UAAU,WAAW;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,QAAQ,GAAG,cAAc,CAAA;IAC/B,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAChF;AAcD,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,WAAW,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC,EAChE,OAAO,SAAY,GAClB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA8BlC"}
@@ -0,0 +1,15 @@
1
+ export interface BehavioralResult {
2
+ session: {
3
+ pageViewCount: number;
4
+ totalPageViews: number;
5
+ sessionDuration: number;
6
+ entryPage: string;
7
+ pagesVisited: string[];
8
+ };
9
+ behavioral: {
10
+ categoryScores: Record<string, number>;
11
+ totalScore: number;
12
+ };
13
+ }
14
+ export declare function collectBehavioral(currentPath: string, category?: string): BehavioralResult;
15
+ //# sourceMappingURL=behavioral-collector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"behavioral-collector.d.ts","sourceRoot":"","sources":["../../src/audience/behavioral-collector.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;IAC9H,UAAU,EAAE;QAAE,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAA;CAC3E;AAsBD,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAqB1F"}
@@ -0,0 +1,11 @@
1
+ import type { KywiVisitor } from '../types.js';
2
+ export declare function populateDataLayer(visitor: KywiVisitor): void;
3
+ export declare function fireKywiReady(): void;
4
+ export interface ServerMeta {
5
+ audienceId: string | null;
6
+ experimentId: string | null;
7
+ variantId: string | null;
8
+ visitorId: string;
9
+ }
10
+ export declare function readServerMeta(): ServerMeta;
11
+ //# sourceMappingURL=data-layer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-layer.d.ts","sourceRoot":"","sources":["../../src/audience/data-layer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAI5D;AAED,wBAAgB,aAAa,IAAI,IAAI,CAAuD;AAE5F,MAAM,WAAW,UAAU;IAAG,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;AAEnI,wBAAgB,cAAc,IAAI,UAAU,CAG3C"}
@@ -0,0 +1,2 @@
1
+ export declare function patchVariantContainers(winningAudienceId: string | null): void;
2
+ //# sourceMappingURL=dom-patcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-patcher.d.ts","sourceRoot":"","sources":["../../src/audience/dom-patcher.ts"],"names":[],"mappings":"AACA,wBAAgB,sBAAsB,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAe7E"}
@@ -0,0 +1,3 @@
1
+ import type { Audience, VisitorSignals, AudienceResult } from '@kywi-software/core/audiences/types';
2
+ export declare function evaluateClientSide(audiences: Audience[], serverSignals: Partial<VisitorSignals>, currentPath: string, pageCategory?: string): AudienceResult;
3
+ //# sourceMappingURL=evaluate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/audience/evaluate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AAenG,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,QAAQ,EAAE,EAAE,aAAa,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GACxG,cAAc,CAQhB"}
@@ -0,0 +1,24 @@
1
+ import type { Audience, VisitorSignals } from '@kywi-software/core/audiences/types';
2
+ import { type SelfIdWidgetConfig } from './selfid-widget.js';
3
+ export interface AudienceBootConfig {
4
+ audiences: Audience[];
5
+ currentPath: string;
6
+ pageCategory?: string;
7
+ serverSignals?: Partial<VisitorSignals>;
8
+ adapters?: Array<{
9
+ id: string;
10
+ side: 'client' | 'server-proxy';
11
+ fields: string[];
12
+ collect: (s: Partial<VisitorSignals>) => Promise<Record<string, unknown>>;
13
+ }>;
14
+ selfIdWidget?: SelfIdWidgetConfig;
15
+ /**
16
+ * Base path of the mounted CMS API (e.g. `/api/v1`). Runtime calls
17
+ * (server-proxy adapters, audience assignment) are made under `{apiBase}/kywi/*`.
18
+ * Defaults to the same `{basePath}/api/v1` derivation the entity/feed factories
19
+ * use, so it matches the reference app's mount out of the box.
20
+ */
21
+ apiBase?: string;
22
+ }
23
+ export declare function bootAudienceEngine(config: AudienceBootConfig): Promise<void>;
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/audience/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AASnF,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAGhF,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,QAAQ,EAAE,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IACvC,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,QAAQ,GAAG,cAAc,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;KAAE,CAAC,CAAA;IAC9J,YAAY,CAAC,EAAE,kBAAkB,CAAA;IACjC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAUD,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6DlF"}
@@ -0,0 +1,6 @@
1
+ export declare function getPreviewAudienceId(): string | null;
2
+ export declare function setPreviewAudienceId(id: string): void;
3
+ export declare function clearPreview(): void;
4
+ export declare function checkPreviewInit(): void;
5
+ export declare function renderPreviewBanner(audienceName: string): void;
6
+ //# sourceMappingURL=preview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../src/audience/preview.ts"],"names":[],"mappings":"AAKA,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,IAAI,CAA+C;AACpG,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAA4C;AAClG,wBAAgB,YAAY,IAAI,IAAI,CAA2C;AAE/E,wBAAgB,gBAAgB,IAAI,IAAI,CAIvC;AAED,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAmB9D"}
@@ -0,0 +1,3 @@
1
+ export declare function collectSelfId(): Record<string, string>;
2
+ export declare function storeSelfId(responses: Record<string, string>): void;
3
+ //# sourceMappingURL=selfid-collector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selfid-collector.d.ts","sourceRoot":"","sources":["../../src/audience/selfid-collector.ts"],"names":[],"mappings":"AAGA,wBAAgB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAItD;AAED,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAEnE"}
@@ -0,0 +1,3 @@
1
+ import type { Audience } from '@kywi-software/core/audiences/types';
2
+ export declare function handleSelfIdSubmit(responses: Record<string, string>, audiences?: Audience[], currentPath?: string): void;
3
+ //# sourceMappingURL=selfid-submit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selfid-submit.d.ts","sourceRoot":"","sources":["../../src/audience/selfid-submit.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAkB,MAAM,qCAAqC,CAAA;AAEnF,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,SAAS,CAAC,EAAE,QAAQ,EAAE,EACtB,WAAW,CAAC,EAAE,MAAM,GACnB,IAAI,CAuBN"}
@@ -0,0 +1,39 @@
1
+ export interface SelfIdFieldConfig {
2
+ id: string;
3
+ label: string;
4
+ type: 'text' | 'select' | 'email';
5
+ options?: string[];
6
+ required?: boolean;
7
+ }
8
+ /** When the widget is shown, once frequency allows. Defaults to immediate. */
9
+ export type SelfIdWidgetTrigger = {
10
+ type: 'immediate';
11
+ } | {
12
+ type: 'scroll';
13
+ depth: number;
14
+ } | {
15
+ type: 'delay';
16
+ seconds: number;
17
+ } | {
18
+ type: 'manual';
19
+ };
20
+ export interface SelfIdWidgetConfig {
21
+ fields: SelfIdFieldConfig[];
22
+ headline?: string;
23
+ subheadline?: string;
24
+ submitLabel?: string;
25
+ skipLabel?: string;
26
+ displayMode?: 'modal' | 'inline' | 'slide-in';
27
+ frequency?: 'once' | 'session' | 'daily' | 'always';
28
+ trigger?: SelfIdWidgetTrigger;
29
+ audiences?: string[];
30
+ currentPath?: string;
31
+ }
32
+ export interface SelfIdWidget {
33
+ shouldShow(): boolean;
34
+ markShown(): void;
35
+ render(container: HTMLElement): void;
36
+ handleSubmit(responses: Record<string, string>): void;
37
+ }
38
+ export declare function createSelfIdWidget(config: SelfIdWidgetConfig): SelfIdWidget;
39
+ //# sourceMappingURL=selfid-widget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selfid-widget.d.ts","sourceRoot":"","sources":["../../src/audience/selfid-widget.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;IACjC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,8EAA8E;AAC9E,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAA;AAEtB,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,iBAAiB,EAAE,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAA;IAC7C,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAA;IACnD,OAAO,CAAC,EAAE,mBAAmB,CAAA;IAC7B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,IAAI,OAAO,CAAA;IACrB,SAAS,IAAI,IAAI,CAAA;IACjB,MAAM,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAA;IACpC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAA;CACtD;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CA0I3E"}
@@ -0,0 +1,3 @@
1
+ /** Injects the transparency bar's stylesheet into `<head>` exactly once. */
2
+ export declare function ensureTransparencyStyles(): void;
3
+ //# sourceMappingURL=transparency-styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transparency-styles.d.ts","sourceRoot":"","sources":["../../src/audience/transparency-styles.ts"],"names":[],"mappings":"AAmGA,4EAA4E;AAC5E,wBAAgB,wBAAwB,IAAI,IAAI,CAO/C"}
@@ -0,0 +1,12 @@
1
+ export declare function isDismissed(): boolean;
2
+ export declare function dismiss(): void;
3
+ export declare function optOut(): void;
4
+ export declare function optIn(): void;
5
+ interface TransparencyState {
6
+ isPersonalized: boolean;
7
+ isOptedOut: boolean;
8
+ hasMatchAvailable: boolean;
9
+ }
10
+ export declare function renderTransparencyBar(state: TransparencyState): void;
11
+ export {};
12
+ //# sourceMappingURL=transparency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transparency.d.ts","sourceRoot":"","sources":["../../src/audience/transparency.ts"],"names":[],"mappings":"AAMA,wBAAgB,WAAW,IAAI,OAAO,CAAuD;AAC7F,wBAAgB,OAAO,IAAI,IAAI,CAA0D;AAIzF,wBAAgB,MAAM,IAAI,IAAI,CAA8F;AAC5H,wBAAgB,KAAK,IAAI,IAAI,CAAsC;AAEnE,UAAU,iBAAiB;IAAG,cAAc,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,iBAAiB,EAAE,OAAO,CAAA;CAAE;AAWxG,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAmCpE"}
@@ -0,0 +1,24 @@
1
+ export declare const CONSENT_COOKIE: "kywi_consent";
2
+ export type ConsentCategory = 'essential' | 'analytics' | 'marketing' | 'personalization';
3
+ export interface ConsentState {
4
+ essential: boolean;
5
+ analytics: boolean;
6
+ marketing: boolean;
7
+ personalization: boolean;
8
+ }
9
+ /**
10
+ * Read the current consent state from the `kywi_consent` cookie.
11
+ * Returns the parsed ConsentState, or null if the cookie is missing or malformed.
12
+ */
13
+ export declare function getConsentState(): ConsentState | null;
14
+ /**
15
+ * Set consent preferences. Essential is always forced to true.
16
+ * The cookie is stored with a 1-year Max-Age.
17
+ */
18
+ export declare function setConsent(prefs: Partial<Omit<ConsentState, 'essential'>>): void;
19
+ /**
20
+ * Check whether a specific consent category has been granted.
21
+ * Returns false if no consent cookie exists or the category is unknown.
22
+ */
23
+ export declare function hasConsent(category: ConsentCategory): boolean;
24
+ //# sourceMappingURL=consent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consent.d.ts","sourceRoot":"","sources":["../src/consent.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,EAAG,cAAuB,CAAA;AAErD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,iBAAiB,CAAA;AAEzF,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,eAAe,EAAE,OAAO,CAAA;CACzB;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,YAAY,GAAG,IAAI,CAYrD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,GAC9C,IAAI,CASN;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAI7D"}
@@ -0,0 +1,3 @@
1
+ import type { KywiContext } from './types.js';
2
+ export declare function readContext(): KywiContext;
3
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,wBAAgB,WAAW,IAAI,WAAW,CAczC"}
@@ -0,0 +1,13 @@
1
+ export declare const COOKIE_NAMES: {
2
+ readonly SIGNALS: "kywi_signals";
3
+ readonly VISITOR: "kywi_visitor";
4
+ readonly UTM: "kywi_utm";
5
+ readonly AUDIENCE: "kywi_audience";
6
+ readonly OPTOUT: "kywi_optout";
7
+ readonly KNOWN: "kywi_known";
8
+ readonly PREVIEW_INIT: "kywi_preview_init";
9
+ };
10
+ export declare function readCookies(): Map<string, string>;
11
+ export declare function setCookie(name: string, value: string, maxAge?: number): void;
12
+ export declare function deleteCookie(name: string): void;
13
+ //# sourceMappingURL=cookies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookies.d.ts","sourceRoot":"","sources":["../src/cookies.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,YAAY;;;;;;;;CAIf,CAAA;AAEV,wBAAgB,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAUjD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAI5E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE/C"}
@@ -0,0 +1,3 @@
1
+ import type { KywiEntityObject } from './types.js';
2
+ export declare function createEntityFactory(basePath: string, csrfToken: string): (type: string) => KywiEntityObject;
3
+ //# sourceMappingURL=entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../src/entity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAuClD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,IAC7D,MAAM,MAAM,KAAG,gBAAgB,CACxC"}
@@ -0,0 +1,27 @@
1
+ import type { KywiContext } from '../types.js';
2
+ export interface ConversionSignal {
3
+ type: 'pageview' | 'form_submit' | 'custom';
4
+ url?: string;
5
+ formId?: string;
6
+ eventName?: string;
7
+ }
8
+ export interface ExperimentBootConfig {
9
+ context?: KywiContext;
10
+ apiBase?: string;
11
+ visitorId?: string;
12
+ currentPath?: string;
13
+ /** Auto-emit a pageview conversion signal on boot (default true). */
14
+ autoPageview?: boolean;
15
+ }
16
+ export interface ExperimentRuntime {
17
+ /** Emit a custom conversion event, e.g. kywi.track('signup'). */
18
+ track(eventName: string): void;
19
+ /** Emit a raw conversion signal. */
20
+ trackConversion(signal: ConversionSignal): void;
21
+ }
22
+ /**
23
+ * Boot the experiment beacons. Safe to call once per page load; when no
24
+ * experiment meta is present it only wires the conversion listeners.
25
+ */
26
+ export declare function bootExperiments(config?: ExperimentBootConfig): ExperimentRuntime;
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/experiments/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,UAAU,GAAG,aAAa,GAAG,QAAQ,CAAA;IAC3C,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qEAAqE;IACrE,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,iEAAiE;IACjE,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,oCAAoC;IACpC,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAChD;AA4CD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,GAAE,oBAAyB,GAAG,iBAAiB,CAyCpF"}
package/dist/feed.d.ts ADDED
@@ -0,0 +1,51 @@
1
+ import type { KywiFeedResult } from './types.js';
2
+ interface Filter {
3
+ field: string;
4
+ operator: string;
5
+ value?: unknown;
6
+ conjunction: 'and' | 'or';
7
+ }
8
+ export type AggregateFunction = 'count' | 'sum' | 'min' | 'max' | 'avg';
9
+ export type AggregateResult = Record<string, unknown>;
10
+ declare class PropBuilder {
11
+ private builder;
12
+ private field;
13
+ private conj;
14
+ constructor(builder: FeedBuilder, field: string, conj: 'and' | 'or');
15
+ private add;
16
+ isEQ(v: unknown): FeedBuilder;
17
+ isNEQ(v: unknown): FeedBuilder;
18
+ isLT(v: unknown): FeedBuilder;
19
+ isLTE(v: unknown): FeedBuilder;
20
+ isGT(v: unknown): FeedBuilder;
21
+ isGTE(v: unknown): FeedBuilder;
22
+ beginsWith(v: unknown): FeedBuilder;
23
+ endsWith(v: unknown): FeedBuilder;
24
+ contains(v: unknown): FeedBuilder;
25
+ isNull(): FeedBuilder;
26
+ isNotNull(): FeedBuilder;
27
+ }
28
+ declare class FeedBuilder {
29
+ private contentType;
30
+ private basePath;
31
+ private csrfToken;
32
+ _filters: Filter[];
33
+ private _sort;
34
+ private _limit;
35
+ private _page;
36
+ constructor(contentType: string, basePath: string, csrfToken: string);
37
+ where(): this;
38
+ prop(field: string): PropBuilder;
39
+ andProp(field: string): PropBuilder;
40
+ orProp(field: string): PropBuilder;
41
+ sort(field: string, direction?: 'asc' | 'desc'): this;
42
+ maxItems(n: number): this;
43
+ page(n: number): this;
44
+ private buildBody;
45
+ private buildHeaders;
46
+ aggregate(fn: AggregateFunction, field?: string): Promise<AggregateResult>;
47
+ getQuery(): Promise<KywiFeedResult>;
48
+ }
49
+ export declare function createFeedFactory(basePath: string, csrfToken: string): (type: string) => FeedBuilder;
50
+ export {};
51
+ //# sourceMappingURL=feed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feed.d.ts","sourceRoot":"","sources":["../src/feed.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,YAAY,CAAA;AAElE,UAAU,MAAM;IAAG,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,KAAK,GAAG,IAAI,CAAA;CAAE;AAEhG,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAA;AACvE,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAErD,cAAM,WAAW;IACH,OAAO,CAAC,OAAO;IAAe,OAAO,CAAC,KAAK;IAAU,OAAO,CAAC,IAAI;gBAAzD,OAAO,EAAE,WAAW,EAAU,KAAK,EAAE,MAAM,EAAU,IAAI,EAAE,KAAK,GAAG,IAAI;IAC3F,OAAO,CAAC,GAAG;IACX,IAAI,CAAC,CAAC,EAAE,OAAO;IACf,KAAK,CAAC,CAAC,EAAE,OAAO;IAChB,IAAI,CAAC,CAAC,EAAE,OAAO;IACf,KAAK,CAAC,CAAC,EAAE,OAAO;IAChB,IAAI,CAAC,CAAC,EAAE,OAAO;IACf,KAAK,CAAC,CAAC,EAAE,OAAO;IAChB,UAAU,CAAC,CAAC,EAAE,OAAO;IACrB,QAAQ,CAAC,CAAC,EAAE,OAAO;IACnB,QAAQ,CAAC,CAAC,EAAE,OAAO;IACnB,MAAM;IACN,SAAS;CACV;AAED,cAAM,WAAW;IAKH,OAAO,CAAC,WAAW;IAAU,OAAO,CAAC,QAAQ;IAAU,OAAO,CAAC,SAAS;IAJpF,QAAQ,EAAE,MAAM,EAAE,CAAK;IACvB,OAAO,CAAC,KAAK,CAA4D;IACzE,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,KAAK,CAAsB;gBACf,WAAW,EAAE,MAAM,EAAU,QAAQ,EAAE,MAAM,EAAU,SAAS,EAAE,MAAM;IAE5F,KAAK,IAAI,IAAI;IACb,IAAI,CAAC,KAAK,EAAE,MAAM;IAClB,OAAO,CAAC,KAAK,EAAE,MAAM;IACrB,MAAM,CAAC,KAAK,EAAE,MAAM;IACpB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,GAAE,KAAK,GAAG,MAAc,GAAG,IAAI;IAC5D,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IACzB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAErB,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,YAAY;IAMd,SAAS,CAAC,EAAE,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAe1E,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;CAoC1C;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,IAC3D,MAAM,MAAM,iBACrB"}
@@ -0,0 +1,3 @@
1
+ export declare function initFormHooks(): void;
2
+ export declare function submitKywiForm(form: HTMLFormElement, endpoint: string): Promise<void>;
3
+ //# sourceMappingURL=form-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-hooks.d.ts","sourceRoot":"","sources":["../src/form-hooks.ts"],"names":[],"mappings":"AAGA,wBAAgB,aAAa,IAAI,IAAI,CAapC;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB3F"}
@@ -0,0 +1,24 @@
1
+ import type { KywiContext, KywiModuleDefinition } from './types.js';
2
+ type PreInitCallback = (kywi: typeof Kywi) => void;
3
+ export declare const Kywi: {
4
+ version: string;
5
+ context: KywiContext;
6
+ Module: Record<string, KywiModuleDefinition>;
7
+ preInit(fn: PreInitCallback): void;
8
+ UI: {
9
+ extend(definition: KywiModuleDefinition): KywiModuleDefinition;
10
+ };
11
+ DisplayObject: {
12
+ Form: {
13
+ _hooks: Record<string, (...args: unknown[]) => unknown>;
14
+ extend(methods: Record<string, (...args: unknown[]) => unknown>): void;
15
+ };
16
+ };
17
+ getEntity: (type: string) => any;
18
+ getFeed: (type: string) => any;
19
+ renderFeed: (options: any) => void;
20
+ boot(): void;
21
+ };
22
+ export { bootAudienceEngine } from './audience/index.js';
23
+ export { bootExperiments, type ExperimentRuntime, type ConversionSignal } from './experiments/index.js';
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AASnE,KAAK,eAAe,GAAG,CAAC,IAAI,EAAE,OAAO,IAAI,KAAK,IAAI,CAAA;AAIlD,eAAO,MAAM,IAAI;;aAEa,WAAW;YACzB,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;gBACtC,eAAe,GAAG,IAAI;;2BAIb,oBAAoB,GAAG,oBAAoB;;;;oBAM9C,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;4BAC7C,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,GAAG,IAAI;;;eAK5C,CAAC,IAAI,EAAE,MAAM,KAAK,GAAG;aACvB,CAAC,IAAI,EAAE,MAAM,KAAK,GAAG;gBAClB,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI;YAC7C,IAAI;CAeb,CAAA;AAWD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAA"}