@namiml/sdk-core 3.4.0-dev.202603271304
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 +68 -0
- package/dist/index.cjs +63830 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2912 -0
- package/dist/index.mjs +63695 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @namiml/sdk-core
|
|
2
|
+
|
|
3
|
+
Private, platform-agnostic core package. Contains all shared business logic, API interactions, state management, and type definitions consumed by the platform-specific SDKs.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn add @namiml/sdk-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> This package is **private** and consumed by `@namiml/web-sdk` and `@namiml/rn-sdk`. End users should not install it directly.
|
|
12
|
+
|
|
13
|
+
## What's Included
|
|
14
|
+
|
|
15
|
+
- **Managers** — `Nami`, `NamiCampaignManager`, `NamiCustomerManager`, `NamiPaywallManager`, `NamiEntitlementManager`, `NamiFlowManager`
|
|
16
|
+
- **State** — `PaywallState` (singleton, observable paywall state)
|
|
17
|
+
- **Services** — `StorageService`, `SessionService`, `LoggerService`, conversion tracking
|
|
18
|
+
- **API layer** — `NamiAPI`, campaign rules, paywall configs, products, entitlements
|
|
19
|
+
- **Types** — All public and internal type definitions
|
|
20
|
+
- **Adapters** — `IStorageAdapter`, `IDeviceAdapter`, `IUIAdapter` interfaces for platform injection
|
|
21
|
+
|
|
22
|
+
## Adapter Pattern
|
|
23
|
+
|
|
24
|
+
The core is 100% platform-agnostic. It requires platform SDKs to register adapters at startup:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { registerPlatformAdapters } from '@namiml/sdk-core';
|
|
28
|
+
|
|
29
|
+
registerPlatformAdapters({
|
|
30
|
+
storage: new YourStorageAdapter(),
|
|
31
|
+
device: new YourDeviceAdapter(),
|
|
32
|
+
ui: new YourUIAdapter(),
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### IStorageAdapter
|
|
37
|
+
Provides key-value storage (localStorage on web, MMKV on RN).
|
|
38
|
+
|
|
39
|
+
### IDeviceAdapter
|
|
40
|
+
Provides device info, screen dimensions, language, UUID generation.
|
|
41
|
+
|
|
42
|
+
### IUIAdapter
|
|
43
|
+
Provides paywall presentation and dismissal.
|
|
44
|
+
|
|
45
|
+
## Building
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
yarn install
|
|
49
|
+
yarn build # Development build
|
|
50
|
+
yarn build:prod # Production build
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Outputs:
|
|
54
|
+
- `dist/index.mjs` — ES Module
|
|
55
|
+
- `dist/index.cjs` — CommonJS
|
|
56
|
+
- `dist/index.d.ts` — TypeScript declarations
|
|
57
|
+
|
|
58
|
+
## Testing
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
yarn test
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Enforced Constraints
|
|
65
|
+
|
|
66
|
+
ESLint rules prevent platform-specific code from leaking into core:
|
|
67
|
+
- **no-restricted-globals**: `window`, `document`, `localStorage`, `sessionStorage`, `navigator`, `location`, `alert`, `confirm`, `prompt`, `self`
|
|
68
|
+
- **no-restricted-imports**: `lit`, `lit-html`, `lit-element`, `react`, `react-native`
|