@c-technology/adaptive-ui 0.1.0 β 0.1.2
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 +32 -60
- package/dist/index.cjs +1 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -44
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# adaptive-ui
|
|
1
|
+
# @c-technology/adaptive-ui
|
|
2
2
|
|
|
3
3
|
> **Human-aware UI adaptation for modern web apps**
|
|
4
4
|
|
|
5
|
-
adaptive-ui is a **TypeScript-first library** that helps your UI adapt to **users**, not just screen sizes.
|
|
5
|
+
`@c-technology/adaptive-ui` is a **TypeScript-first library** that helps your UI adapt to **users**, not just screen sizes.
|
|
6
6
|
|
|
7
|
-
Instead of only responding to `mobile`, `desktop`, or `tablet`,
|
|
7
|
+
Instead of only responding to `mobile`, `desktop`, or `tablet`, this library reacts to **real conditions** like:
|
|
8
8
|
|
|
9
9
|
* slow network
|
|
10
10
|
* low battery
|
|
@@ -16,15 +16,14 @@ This README explains everything **from zero**, assuming you are a beginner.
|
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
## π¨ The Problem (Why adaptive-ui Exists)
|
|
19
|
+
## π¨ The Problem (Why @c-technology/adaptive-ui Exists)
|
|
20
20
|
|
|
21
21
|
Most web apps today:
|
|
22
22
|
|
|
23
23
|
* look responsive
|
|
24
24
|
* but feel frustrating
|
|
25
25
|
|
|
26
|
-
Why?
|
|
27
|
-
Because they adapt to **screens**, not **people**.
|
|
26
|
+
Why? Because they adapt to **screens**, not **people**.
|
|
28
27
|
|
|
29
28
|
Examples:
|
|
30
29
|
|
|
@@ -41,17 +40,17 @@ That approach:
|
|
|
41
40
|
* is hard to reason about
|
|
42
41
|
* creates messy code
|
|
43
42
|
|
|
44
|
-
|
|
43
|
+
`@c-technology/adaptive-ui` solves this by acting as a **decision layer** for your UI.
|
|
45
44
|
|
|
46
45
|
---
|
|
47
46
|
|
|
48
|
-
## π§ What
|
|
47
|
+
## π§ What It Is (And Is NOT)
|
|
49
48
|
|
|
50
49
|
### β
What it IS
|
|
51
50
|
|
|
52
51
|
* a **logic layer** for UI behavior
|
|
53
52
|
* a way to detect user context
|
|
54
|
-
* a strategy system for adapting interfaces
|
|
53
|
+
* a **strategy system** for adapting interfaces
|
|
55
54
|
* framework-friendly (React, Next.js, etc.)
|
|
56
55
|
|
|
57
56
|
### β What it is NOT
|
|
@@ -62,13 +61,11 @@ That approach:
|
|
|
62
61
|
* β an AI / ML system
|
|
63
62
|
* β a tracking library
|
|
64
63
|
|
|
65
|
-
|
|
64
|
+
This library **never renders UI**. It only helps you make better decisions.
|
|
66
65
|
|
|
67
66
|
---
|
|
68
67
|
|
|
69
|
-
## ποΈ How
|
|
70
|
-
|
|
71
|
-
adaptive-ui works in **three steps**:
|
|
68
|
+
## ποΈ How It Works (Simple Explanation)
|
|
72
69
|
|
|
73
70
|
### 1οΈβ£ Detect Signals
|
|
74
71
|
|
|
@@ -80,7 +77,7 @@ Signals are things like:
|
|
|
80
77
|
|
|
81
78
|
### 2οΈβ£ Build Context
|
|
82
79
|
|
|
83
|
-
From signals,
|
|
80
|
+
From signals, it builds a **context**, such as:
|
|
84
81
|
|
|
85
82
|
* `slow-network`
|
|
86
83
|
* `impatient`
|
|
@@ -102,25 +99,24 @@ Example:
|
|
|
102
99
|
## π¦ Installation
|
|
103
100
|
|
|
104
101
|
```bash
|
|
105
|
-
npm install adaptive-ui
|
|
102
|
+
npm install @c-technology/adaptive-ui
|
|
106
103
|
```
|
|
107
104
|
|
|
108
105
|
or
|
|
109
106
|
|
|
110
107
|
```bash
|
|
111
|
-
pnpm
|
|
108
|
+
pnpm add @c-technology/adaptive-ui
|
|
112
109
|
```
|
|
113
|
-
|
|
114
110
|
or
|
|
115
111
|
|
|
116
112
|
```bash
|
|
117
|
-
bun add adaptive-ui
|
|
113
|
+
bun add @c-technology/adaptive-ui
|
|
118
114
|
```
|
|
119
115
|
|
|
120
116
|
or
|
|
121
117
|
|
|
122
118
|
```bash
|
|
123
|
-
yarn add adaptive-ui
|
|
119
|
+
yarn add @c-technology/adaptive-ui
|
|
124
120
|
```
|
|
125
121
|
|
|
126
122
|
---
|
|
@@ -130,11 +126,9 @@ yarn add adaptive-ui
|
|
|
130
126
|
### Step 1: Import the hook
|
|
131
127
|
|
|
132
128
|
```ts
|
|
133
|
-
import { useAdaptive } from "adaptive-ui";
|
|
129
|
+
import { useAdaptive } from "@c-technology/adaptive-ui";
|
|
134
130
|
```
|
|
135
131
|
|
|
136
|
-
---
|
|
137
|
-
|
|
138
132
|
### Step 2: Use it inside a component
|
|
139
133
|
|
|
140
134
|
```tsx
|
|
@@ -151,25 +145,21 @@ This gives you access to the **adaptive engine**.
|
|
|
151
145
|
|
|
152
146
|
## π§© Context Detection (Beginner Friendly)
|
|
153
147
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
### Example: Check if user is impatient
|
|
148
|
+
Example: Check if user is impatient
|
|
157
149
|
|
|
158
|
-
```
|
|
150
|
+
```ts
|
|
159
151
|
if (ui.has("impatient")) {
|
|
160
152
|
console.log("User is impatient");
|
|
161
153
|
}
|
|
162
154
|
```
|
|
163
155
|
|
|
164
|
-
You donβt need to know
|
|
165
|
-
|
|
166
|
-
That logic is handled internally.
|
|
156
|
+
You donβt need to know how impatience is detected β the logic is handled internally.
|
|
167
157
|
|
|
168
158
|
---
|
|
169
159
|
|
|
170
160
|
## π§ Strategies (The Core Feature)
|
|
171
161
|
|
|
172
|
-
|
|
162
|
+
Define **how your UI should react**.
|
|
173
163
|
|
|
174
164
|
### Example: Lite UI on slow network
|
|
175
165
|
|
|
@@ -182,12 +172,6 @@ ui.strategy({
|
|
|
182
172
|
});
|
|
183
173
|
```
|
|
184
174
|
|
|
185
|
-
This means:
|
|
186
|
-
|
|
187
|
-
> If network is slow β switch to lite UI
|
|
188
|
-
|
|
189
|
-
---
|
|
190
|
-
|
|
191
175
|
### Example: Focus mode for impatient users
|
|
192
176
|
|
|
193
177
|
```ts
|
|
@@ -199,15 +183,13 @@ ui.strategy({
|
|
|
199
183
|
});
|
|
200
184
|
```
|
|
201
185
|
|
|
202
|
-
---
|
|
203
|
-
|
|
204
186
|
### Run strategies
|
|
205
187
|
|
|
206
188
|
```ts
|
|
207
189
|
ui.run();
|
|
208
190
|
```
|
|
209
191
|
|
|
210
|
-
|
|
192
|
+
Applies all matching strategies.
|
|
211
193
|
|
|
212
194
|
---
|
|
213
195
|
|
|
@@ -225,19 +207,19 @@ This applies all matching strategies.
|
|
|
225
207
|
}
|
|
226
208
|
```
|
|
227
209
|
|
|
228
|
-
Your UI
|
|
210
|
+
Your UI adapts without changing components.
|
|
229
211
|
|
|
230
212
|
---
|
|
231
213
|
|
|
232
|
-
## π§ͺ Debugging
|
|
214
|
+
## π§ͺ Debugging
|
|
233
215
|
|
|
234
|
-
|
|
216
|
+
Check why the UI changed:
|
|
235
217
|
|
|
236
218
|
```ts
|
|
237
219
|
console.log(ui.explain());
|
|
238
220
|
```
|
|
239
221
|
|
|
240
|
-
|
|
222
|
+
Example output:
|
|
241
223
|
|
|
242
224
|
```ts
|
|
243
225
|
{
|
|
@@ -246,25 +228,19 @@ Output:
|
|
|
246
228
|
}
|
|
247
229
|
```
|
|
248
230
|
|
|
249
|
-
This helps avoid confusion during development.
|
|
250
|
-
|
|
251
231
|
---
|
|
252
232
|
|
|
253
233
|
## βΏ Accessibility-Friendly by Design
|
|
254
234
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
*
|
|
258
|
-
* simplify layouts
|
|
259
|
-
* increase clarity
|
|
260
|
-
|
|
261
|
-
Without extra libraries.
|
|
235
|
+
* reduces motion
|
|
236
|
+
* simplifies layouts
|
|
237
|
+
* increases clarity
|
|
262
238
|
|
|
263
239
|
It reacts to **behavior**, not user labels.
|
|
264
240
|
|
|
265
241
|
---
|
|
266
242
|
|
|
267
|
-
## π Why Use
|
|
243
|
+
## π Why Use It?
|
|
268
244
|
|
|
269
245
|
* cleaner UI logic
|
|
270
246
|
* fewer edge cases
|
|
@@ -272,13 +248,9 @@ It reacts to **behavior**, not user labels.
|
|
|
272
248
|
* no heavy setup
|
|
273
249
|
* beginner-friendly
|
|
274
250
|
|
|
275
|
-
Once added, it quietly improves your app.
|
|
276
|
-
|
|
277
251
|
---
|
|
278
252
|
|
|
279
|
-
## π§± What
|
|
280
|
-
|
|
281
|
-
To keep trust high:
|
|
253
|
+
## π§± What It Will NEVER Do
|
|
282
254
|
|
|
283
255
|
* β no analytics
|
|
284
256
|
* β no tracking
|
|
@@ -311,7 +283,7 @@ Not planned:
|
|
|
311
283
|
|
|
312
284
|
> Good UI should feel invisible.
|
|
313
285
|
|
|
314
|
-
|
|
286
|
+
It helps you build interfaces that **respect users** without extra complexity.
|
|
315
287
|
|
|
316
288
|
---
|
|
317
289
|
|
|
@@ -329,4 +301,4 @@ If you are a beginner:
|
|
|
329
301
|
* add one strategy
|
|
330
302
|
* observe the effect
|
|
331
303
|
|
|
332
|
-
adaptive-ui grows
|
|
304
|
+
`@c-technology/adaptive-ui` grows with your understanding, not against it.
|
package/dist/index.cjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/adaptive.ts","../src/react.ts","../src/signals/network.ts","../src/signals/battery.ts","../src/signals/behavior.ts","../src/strategies.ts"],"sourcesContent":["export { AdaptiveUI } from \"./adaptive\";\nexport { useAdaptive } from \"./react\";\nexport * from \"./strategies\";\n","export type Context =\n | \"slow-network\"\n | \"low-battery\"\n | \"impatient\"\n | \"new-user\";\n\ntype Strategy = {\n conditions: Context[];\n actions: () => void;\n};\n\nexport class AdaptiveUI {\n private context = new Set<Context>();\n private strategies: Strategy[] = [];\n\n addContext(ctx: Context) {\n this.context.add(ctx);\n }\n\n has(ctx: Context) {\n return this.context.has(ctx);\n }\n\n strategy(strategy: Strategy) {\n this.strategies.push(strategy);\n }\n\n run() {\n for (const s of this.strategies) {\n if (s.conditions.every(c => this.context.has(c))) {\n s.actions();\n }\n }\n }\n\n explain() {\n return {\n context: Array.from(this.context),\n strategies: this.strategies.length,\n };\n }\n}\n","import { useEffect, useState } from \"react\";\nimport { AdaptiveUI } from \"./adaptive\";\nimport { detectSlowNetwork } from \"./signals/network\";\nimport { detectLowBattery } from \"./signals/battery\";\nimport { detectImpatience } from \"./signals/behavior\";\n\nexport function useAdaptive() {\n const [adaptive] = useState(() => new AdaptiveUI());\n\n useEffect(() => {\n detectSlowNetwork(() => adaptive.addContext(\"slow-network\"));\n detectLowBattery(() => adaptive.addContext(\"low-battery\"));\n detectImpatience(() => adaptive.addContext(\"impatient\"));\n }, []);\n\n return adaptive;\n}\n","export function detectSlowNetwork(onDetect: () => void) {\n const connection = (navigator as any).connection;\n if (!connection) return;\n\n if (\n connection.effectiveType === \"2g\" ||\n connection.effectiveType === \"slow-2g\"\n ) {\n onDetect();\n }\n}\n","export async function detectLowBattery(onDetect: () => void) {\n if (!(\"getBattery\" in navigator)) return;\n\n const battery = await (navigator as any).getBattery();\n if (battery.level < 0.2) {\n onDetect();\n }\n}\n","export function detectImpatience(onDetect: () => void) {\n let clicks = 0;\n\n window.addEventListener(\"click\", () => {\n clicks++;\n if (clicks >= 6) {\n onDetect();\n }\n });\n}\n","export function liteUI() {\n document.body.classList.add(\"ui-lite\");\n}\n\nexport function focusMode() {\n document.body.classList.add(\"ui-focus\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,IAAM,aAAN,MAAiB;AAAA,EAAjB;AACL,SAAQ,UAAU,oBAAI,IAAa;AACnC,SAAQ,aAAyB,CAAC;AAAA;AAAA,EAElC,WAAW,KAAc;AACvB,SAAK,QAAQ,IAAI,GAAG;AAAA,EACtB;AAAA,EAEA,IAAI,KAAc;AAChB,WAAO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K,UAAU,IAAI,SAAS;AACvC;AAEO,SAAS,YAAY;AAC1B,WAAS,KAAK,UAAU,IAAI,UAAU;AACxC;","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type Context = "slow-network" | "low-battery" | "impatient" | "new-user";
|
|
2
|
+
type Strategy = {
|
|
3
|
+
conditions: Context[];
|
|
4
|
+
actions: () => void;
|
|
5
|
+
};
|
|
6
|
+
declare class AdaptiveUI {
|
|
7
|
+
private context;
|
|
8
|
+
private strategies;
|
|
9
|
+
addContext(ctx: Context): void;
|
|
10
|
+
has(ctx: Context): boolean;
|
|
11
|
+
strategy(strategy: Strategy): void;
|
|
12
|
+
run(): void;
|
|
13
|
+
explain(): {
|
|
14
|
+
context: Context[];
|
|
15
|
+
strategies: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare function useAdaptive(): AdaptiveUI;
|
|
20
|
+
|
|
21
|
+
declare function liteUI(): void;
|
|
22
|
+
declare function focusMode(): void;
|
|
23
|
+
|
|
24
|
+
export { AdaptiveUI, focusMode, liteUI, useAdaptive };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// src/adaptive.ts
|
|
2
|
+
var AdaptiveUI = class {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.context = /* @__PURE__ */ new Set();
|
|
5
|
+
this.strategies = [];
|
|
6
|
+
}
|
|
7
|
+
addContext(ctx) {
|
|
8
|
+
this.context.add(ctx);
|
|
9
|
+
}
|
|
10
|
+
has(ctx) {
|
|
11
|
+
return this.context.has(ctx);
|
|
12
|
+
}
|
|
13
|
+
strategy(strategy) {
|
|
14
|
+
this.strategies.push(strategy);
|
|
15
|
+
}
|
|
16
|
+
run() {
|
|
17
|
+
for (const s of this.strategies) {
|
|
18
|
+
if (s.conditions.every((c) => this.context.has(c))) {
|
|
19
|
+
s.actions();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
explain() {
|
|
24
|
+
return {
|
|
25
|
+
context: Array.from(this.context),
|
|
26
|
+
strategies: this.strategies.length
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// src/react.ts
|
|
32
|
+
import { useEffect, useState } from "react";
|
|
33
|
+
|
|
34
|
+
// src/signals/network.ts
|
|
35
|
+
function detectSlowNetwork(onDetect) {
|
|
36
|
+
const connection = navigator.connection;
|
|
37
|
+
if (!connection) return;
|
|
38
|
+
if (connection.effectiveType === "2g" || connection.effectiveType === "slow-2g") {
|
|
39
|
+
onDetect();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/signals/battery.ts
|
|
44
|
+
async function detectLowBattery(onDetect) {
|
|
45
|
+
if (!("getBattery" in navigator)) return;
|
|
46
|
+
const battery = await navigator.getBattery();
|
|
47
|
+
if (battery.level < 0.2) {
|
|
48
|
+
onDetect();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/signals/behavior.ts
|
|
53
|
+
function detectImpatience(onDetect) {
|
|
54
|
+
let clicks = 0;
|
|
55
|
+
window.addEventListener("click", () => {
|
|
56
|
+
clicks++;
|
|
57
|
+
if (clicks >= 6) {
|
|
58
|
+
onDetect();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/react.ts
|
|
64
|
+
function useAdaptive() {
|
|
65
|
+
const [adaptive] = useState(() => new AdaptiveUI());
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
detectSlowNetwork(() => adaptive.addContext("slow-network"));
|
|
68
|
+
detectLowBattery(() => adaptive.addContext("low-battery"));
|
|
69
|
+
detectImpatience(() => adaptive.addContext("impatient"));
|
|
70
|
+
}, []);
|
|
71
|
+
return adaptive;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/strategies.ts
|
|
75
|
+
function liteUI() {
|
|
76
|
+
document.body.classList.add("ui-lite");
|
|
77
|
+
}
|
|
78
|
+
function focusMode() {
|
|
79
|
+
document.body.classList.add("ui-focus");
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
AdaptiveUI,
|
|
83
|
+
focusMode,
|
|
84
|
+
liteUI,
|
|
85
|
+
useAdaptive
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adaptive.ts","../src/react.ts","../src/signals/network.ts","../src/signals/battery.ts","../src/signals/behavior.ts","../src/strategies.ts"],"sourcesContent":["export type Context =\n | \"slow-network\"\n | \"low-battery\"\n | \"impatient\"\n | \"new-user\";\n\ntype Strategy = {\n conditions: Context[];\n actions: () => void;\n};\n\nexport class AdaptiveUI {\n private context = new Set<Context>();\n private strategies: Strategy[] = [];\n\n addContext(ctx: Context) {\n this.context.add(ctx);\n }\n\n has(ctx: Context) {\n return this.context.has(ctx);\n }\n\n strategy(strategy: Strategy) {\n this.strategies.push(strategy);\n }\n\n run() {\n for (const s of this.strategies) {\n if (s.conditions.every(c => this.context.has(c))) {\n s.actions();\n }\n }\n }\n\n explain() {\n return {\n context: Array.from(this.context),\n strategies: this.strategies.length,\n };\n }\n}\n","import { useEffect, useState } from \"react\";\nimport { AdaptiveUI } from \"./adaptive\";\nimport { detectSlowNetwork } from \"./signals/network\";\nimport { detectLowBattery } from \"./signals/battery\";\nimport { detectImpatience } from \"./signals/behavior\";\n\nexport function useAdaptive() {\n const [adaptive] = useState(() => new AdaptiveUI());\n\n useEffect(() => {\n detectSlowNetwork(() => adaptive.addContext(\"slow-network\"));\n detectLowBattery(() => adaptive.addContext(\"low-battery\"));\n detectImpatience(() => adaptive.addContext(\"impatient\"));\n }, []);\n\n return adaptive;\n}\n","export function detectSlowNetwork(onDetect: () => void) {\n const connection = (navigator as any).connection;\n if (!connection) return;\n\n if (\n connection.effectiveType === \"2g\" ||\n connection.effectiveType === \"slow-2g\"\n ) {\n onDetect();\n }\n}\n","export async function detectLowBattery(onDetect: () => void) {\n if (!(\"getBattery\" in navigator)) return;\n\n const battery = await (navigator as any).getBattery();\n if (battery.level < 0.2) {\n onDetect();\n }\n}\n","export function detectImpatience(onDetect: () => void) {\n let clicks = 0;\n\n window.addEventListener(\"click\", () => {\n clicks++;\n if (clicks >= 6) {\n onDetect();\n }\n });\n}\n","export function liteUI() {\n document.body.classList.add(\"ui-lite\");\n}\n\nexport function focusMode() {\n document.body.classList.add(\"ui-focus\");\n}\n"],"mappings":";AAWO,IAAM,aAAN,MAAiB;AAAA,EAAjB;AACL,SAAQ,UAAU,oBAAI,IAAa;AACnC,SAAQ,aAAyB,CAAC;AAAA;AAAA,EAElC,WAAW,KAAc;AACvB,SAAK,QAAQ,IAAI,GAAG;AAAA,EACtB;AAAA,EAEA,IAAI,KAAc;AAChB,WAAO,KAAK,QAAQ,IAAI,GAAG;AAAA,EAC7B;AAAA,EAEA,SAAS,UAAoB;AAC3B,SAAK,WAAW,KAAK,QAAQ;AAAA,EAC/B;AAAA,EAEA,MAAM;AACJ,eAAW,KAAK,KAAK,YAAY;AAC/B,UAAI,EAAE,WAAW,MAAM,OAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,GAAG;AAChD,UAAE,QAAQ;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAAA,EAEA,UAAU;AACR,WAAO;AAAA,MACL,SAAS,MAAM,KAAK,KAAK,OAAO;AAAA,MAChC,YAAY,KAAK,WAAW;AAAA,IAC9B;AAAA,EACF;AACF;;;ACzCA,SAAS,WAAW,gBAAgB;;;ACA7B,SAAS,kBAAkB,UAAsB;AACtD,QAAM,aAAc,UAAkB;AACtC,MAAI,CAAC,WAAY;AAEjB,MACE,WAAW,kBAAkB,QAC7B,WAAW,kBAAkB,WAC7B;AACA,aAAS;AAAA,EACX;AACF;;;ACVA,eAAsB,iBAAiB,UAAsB;AAC3D,MAAI,EAAE,gBAAgB,WAAY;AAElC,QAAM,U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|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
2
|
+
"name": "@c-technology/adaptive-ui",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Human-aware UI adaptation layer for web apps",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs.js",
|
|
7
|
+
"module": "./dist/index.esm.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.esm.js",
|
|
12
|
+
"require": "./dist/index.cjs.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsup",
|
|
22
|
+
"dev": "tsup --watch",
|
|
23
|
+
"lint": "tsc --noEmit",
|
|
24
|
+
"prepublishOnly": "npm run build"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"react": ">=18"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/react": "^19.2.7",
|
|
31
|
+
"react": "^19.2.3",
|
|
32
|
+
"tsup": "^8.5.1",
|
|
33
|
+
"typescript": "^5.3.0"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"adaptive-ui",
|
|
37
|
+
"ux",
|
|
38
|
+
"accessibility",
|
|
39
|
+
"frontend",
|
|
40
|
+
"react",
|
|
41
|
+
"typescript"
|
|
42
|
+
],
|
|
43
|
+
"author": "Your Name",
|
|
44
|
+
"license": "MIT"
|
|
45
|
+
}
|