@tiun/types 0.4.0 → 0.10.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 (3) hide show
  1. package/README.md +1 -1
  2. package/index.d.ts +22 -4
  3. package/package.json +5 -2
package/README.md CHANGED
@@ -55,7 +55,7 @@ tiun.checkout({ productId: 'prod_123' });
55
55
 
56
56
  ## Auto-generated
57
57
 
58
- This package is auto-generated from `src/sdk/types.ts`.
58
+ The published `index.d.ts` is generated from `packages/types/src/index.ts` (the hand-written source of truth) via `npm run generate:types`.
59
59
 
60
60
  ## License
61
61
 
package/index.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * These types are for the global `tiun` object exposed by the tiun script.
7
7
  * Load the script, then use tiun.* with full TypeScript support.
8
8
  *
9
- * @generated from src/sdk/types.ts - Do not edit directly.
9
+ * @generated from packages/types/src/index.ts - Do not edit directly.
10
10
  * Run `npm run generate:types` to regenerate.
11
11
  */
12
12
 
@@ -16,6 +16,9 @@
16
16
 
17
17
  export type ContentType = 'active' | 'inactive' | 'paused';
18
18
  export type MediaType = 'text' | 'audio' | 'video';
19
+ export type SupportedLanguage = 'en' | 'de' | 'fr';
20
+ /** 'auto' follows the visitor's OS setting (prefers-color-scheme). */
21
+ export type Appearance = 'light' | 'dark' | 'auto';
19
22
  export type TiunEventType =
20
23
  | 'ready'
21
24
  | 'paywallShow'
@@ -38,19 +41,28 @@ export interface TiunConfig {
38
41
  snippetId?: string;
39
42
 
40
43
  /**
41
- * Language for the snippet UI.
44
+ * Language for the snippet UI. Case-insensitive ('en', 'EN', 'De' all work).
45
+ * Falls back to 'en' if an unsupported value is provided.
42
46
  * @default 'en'
43
47
  */
44
- language?: string;
48
+ language?: SupportedLanguage;
45
49
 
46
50
  /**
47
51
  * UI tone/style.
48
52
  * - 'formal': More professional tone
49
53
  * - 'informal': More casual/friendly tone
50
- * @default 'formal'
54
+ * @default 'informal'
51
55
  */
52
56
  tone?: 'formal' | 'informal';
53
57
 
58
+ /**
59
+ * Color theme for the snippet UI. Case-insensitive. 'auto' follows the
60
+ * visitor's OS setting and re-themes live when it changes.
61
+ * Change it later with `tiun.setAppearance()`.
62
+ * @default 'light'
63
+ */
64
+ appearance?: Appearance;
65
+
54
66
  /**
55
67
  * Enable debug logging to console.
56
68
  * @default false
@@ -211,6 +223,12 @@ export interface TiunSDK {
211
223
  */
212
224
  setContent(options: ContentOptions): Promise<void>;
213
225
 
226
+ /**
227
+ * Switch the snippet's color theme at runtime, e.g. when your site's theme
228
+ * toggle flips. Safe to call before the snippet is ready.
229
+ */
230
+ setAppearance(appearance: Appearance): void;
231
+
214
232
  /**
215
233
  * Open the OTP login modal for returning subscribers.
216
234
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiun/types",
3
- "version": "0.4.0",
3
+ "version": "0.10.0",
4
4
  "description": "TypeScript type definitions for tiun SDK (for script tag users)",
5
5
  "types": "./index.d.ts",
6
6
  "files": [
@@ -8,6 +8,9 @@
8
8
  "README.md",
9
9
  "LICENSE"
10
10
  ],
11
+ "scripts": {
12
+ "build": "node ../../scripts/generate-types.mjs"
13
+ },
11
14
  "keywords": [
12
15
  "tiun",
13
16
  "types",
@@ -19,7 +22,7 @@
19
22
  "type": "git",
20
23
  "url": "https://github.com/tiun-app/tiun-snippet"
21
24
  },
22
- "homepage": "https://tiun.io",
25
+ "homepage": "https://docs.tiun.io",
23
26
  "license": "MIT",
24
27
  "publishConfig": {
25
28
  "access": "public"