r1-create 1.0.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.
- package/LICENSE +201 -0
- package/README.md +245 -0
- package/dist/hardware/index.d.ts +87 -0
- package/dist/hardware/index.d.ts.map +1 -0
- package/dist/hardware/index.js +172 -0
- package/dist/hardware/index.js.map +1 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +196 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/index.d.ts +100 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +177 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/media/index.d.ts +176 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/index.js +396 -0
- package/dist/media/index.js.map +1 -0
- package/dist/storage/index.d.ts +115 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +179 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/types/index.d.ts +66 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/ui/index.d.ts +170 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +311 -0
- package/dist/ui/index.js.map +1 -0
- package/examples/README.md +64 -0
- package/examples/basic/index.html +157 -0
- package/package.json +49 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Storage API module for R1 plugin data persistence
|
|
4
|
+
* Provides both plain and secure storage with automatic Base64 encoding
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.storage = exports.R1Storage = exports.Base64Utils = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Utility functions for Base64 encoding/decoding
|
|
10
|
+
*/
|
|
11
|
+
class Base64Utils {
|
|
12
|
+
/**
|
|
13
|
+
* Encode data to Base64 string
|
|
14
|
+
* @param data Data to encode (string or object)
|
|
15
|
+
*/
|
|
16
|
+
static encode(data) {
|
|
17
|
+
const jsonString = typeof data === 'string' ? data : JSON.stringify(data);
|
|
18
|
+
return btoa(jsonString);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Decode Base64 string to data
|
|
22
|
+
* @param encoded Base64 encoded string
|
|
23
|
+
* @param parseJson Whether to parse as JSON (default: true)
|
|
24
|
+
*/
|
|
25
|
+
static decode(encoded, parseJson = true) {
|
|
26
|
+
const decoded = atob(encoded);
|
|
27
|
+
return parseJson ? JSON.parse(decoded) : decoded;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Safely decode Base64 string, returns null if invalid
|
|
31
|
+
* @param encoded Base64 encoded string
|
|
32
|
+
* @param parseJson Whether to parse as JSON (default: true)
|
|
33
|
+
*/
|
|
34
|
+
static safeDecode(encoded, parseJson = true) {
|
|
35
|
+
if (!encoded)
|
|
36
|
+
return null;
|
|
37
|
+
try {
|
|
38
|
+
const decoded = atob(encoded);
|
|
39
|
+
return parseJson ? JSON.parse(decoded) : decoded;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.warn('Failed to decode storage data:', error);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.Base64Utils = Base64Utils;
|
|
48
|
+
/**
|
|
49
|
+
* Enhanced storage wrapper with automatic Base64 encoding and JSON support
|
|
50
|
+
*/
|
|
51
|
+
class StorageWrapper {
|
|
52
|
+
constructor(storage) {
|
|
53
|
+
this.storage = storage;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Store data with automatic Base64 encoding
|
|
57
|
+
* @param key Storage key
|
|
58
|
+
* @param value Data to store (will be JSON stringified and Base64 encoded)
|
|
59
|
+
*/
|
|
60
|
+
async setItem(key, value) {
|
|
61
|
+
const encoded = Base64Utils.encode(value);
|
|
62
|
+
await this.storage.setItem(key, encoded);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Retrieve and decode data
|
|
66
|
+
* @param key Storage key
|
|
67
|
+
* @param parseJson Whether to parse as JSON (default: true)
|
|
68
|
+
*/
|
|
69
|
+
async getItem(key, parseJson = true) {
|
|
70
|
+
const encoded = await this.storage.getItem(key);
|
|
71
|
+
return Base64Utils.safeDecode(encoded, parseJson);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Remove item from storage
|
|
75
|
+
* @param key Storage key
|
|
76
|
+
*/
|
|
77
|
+
async removeItem(key) {
|
|
78
|
+
await this.storage.removeItem(key);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Clear all storage
|
|
82
|
+
*/
|
|
83
|
+
async clear() {
|
|
84
|
+
await this.storage.clear();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Store raw Base64 data (for manual encoding)
|
|
88
|
+
* @param key Storage key
|
|
89
|
+
* @param base64Value Base64 encoded string
|
|
90
|
+
*/
|
|
91
|
+
async setRaw(key, base64Value) {
|
|
92
|
+
await this.storage.setItem(key, base64Value);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get raw Base64 data (without decoding)
|
|
96
|
+
* @param key Storage key
|
|
97
|
+
*/
|
|
98
|
+
async getRaw(key) {
|
|
99
|
+
return await this.storage.getItem(key);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Enhanced Creation Storage with Base64 utilities
|
|
104
|
+
*/
|
|
105
|
+
class R1Storage {
|
|
106
|
+
/**
|
|
107
|
+
* Plain storage (unencrypted, Base64 encoded)
|
|
108
|
+
*/
|
|
109
|
+
get plain() {
|
|
110
|
+
if (!this._plain) {
|
|
111
|
+
if (!window.creationStorage?.plain) {
|
|
112
|
+
throw new Error('Plain storage not available. Make sure you are running in R1 environment.');
|
|
113
|
+
}
|
|
114
|
+
this._plain = new StorageWrapper(window.creationStorage.plain);
|
|
115
|
+
}
|
|
116
|
+
return this._plain;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Secure storage (hardware-encrypted, Base64 encoded)
|
|
120
|
+
* Requires Android M or higher
|
|
121
|
+
*/
|
|
122
|
+
get secure() {
|
|
123
|
+
if (!this._secure) {
|
|
124
|
+
if (!window.creationStorage?.secure) {
|
|
125
|
+
throw new Error('Secure storage not available. Make sure you are running on Android M+ in R1 environment.');
|
|
126
|
+
}
|
|
127
|
+
this._secure = new StorageWrapper(window.creationStorage.secure);
|
|
128
|
+
}
|
|
129
|
+
return this._secure;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Check if storage is available
|
|
133
|
+
*/
|
|
134
|
+
static isAvailable() {
|
|
135
|
+
return typeof window !== 'undefined' && !!window.creationStorage;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Check if secure storage is available
|
|
139
|
+
*/
|
|
140
|
+
static isSecureAvailable() {
|
|
141
|
+
return this.isAvailable() && !!window.creationStorage.secure;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Utility to store user preferences with type safety
|
|
145
|
+
* @param prefs User preferences object
|
|
146
|
+
* @param useSecure Whether to use secure storage (default: false)
|
|
147
|
+
*/
|
|
148
|
+
async setPreferences(prefs, useSecure = false) {
|
|
149
|
+
const storage = useSecure ? this.secure : this.plain;
|
|
150
|
+
await storage.setItem('user_preferences', prefs);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Utility to get user preferences with type safety
|
|
154
|
+
* @param useSecure Whether to use secure storage (default: false)
|
|
155
|
+
*/
|
|
156
|
+
async getPreferences(useSecure = false) {
|
|
157
|
+
const storage = useSecure ? this.secure : this.plain;
|
|
158
|
+
return await storage.getItem('user_preferences');
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Utility to store sensitive data (API keys, tokens, etc.)
|
|
162
|
+
* @param key Storage key
|
|
163
|
+
* @param value Sensitive data
|
|
164
|
+
*/
|
|
165
|
+
async setSecret(key, value) {
|
|
166
|
+
await this.secure.setItem(`secret_${key}`, value);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Utility to get sensitive data
|
|
170
|
+
* @param key Storage key
|
|
171
|
+
*/
|
|
172
|
+
async getSecret(key) {
|
|
173
|
+
return await this.secure.getItem(`secret_${key}`, false);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.R1Storage = R1Storage;
|
|
177
|
+
// Export singleton instance
|
|
178
|
+
exports.storage = new R1Storage();
|
|
179
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;GAEG;AACH,MAAa,WAAW;IACtB;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,IAAS;QACrB,MAAM,UAAU,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC1E,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAU,OAAe,EAAE,YAAqB,IAAI;QAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAE,OAAa,CAAC;IAC1D,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAU,OAAsB,EAAE,YAAqB,IAAI;QAC1E,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC;QAE1B,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;YAC9B,OAAO,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KA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;QACrD,MAAM,OAAO,CAAC,OAAO,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;IACnD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,cAAc,CAAgC,YAAqB,KAAK;QAC5E,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;QACrD,OAAO,MAAM,OAAO,CAAC,OAAO,CAAI,kBAAkB,CAAC,CAAC;IACtD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,SAAS,CAAC,GAAW,EAAE,KAAa;QACxC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,SAAS,CAAC,GAAW;QACzB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAS,UAAU,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;IACnE,CAAC;CACF;AAhFD,8BAgFC;AAED,4BAA4B;AACf,QAAA,OAAO,GAAG,IAAI,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for R1/RabbitOS Plugin SDK
|
|
3
|
+
*/
|
|
4
|
+
export interface AccelerometerData {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
z: number;
|
|
8
|
+
}
|
|
9
|
+
export interface AccelerometerOptions {
|
|
10
|
+
frequency?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface TouchEvent {
|
|
13
|
+
type: 'tap' | 'down' | 'up' | 'move' | 'cancel';
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
}
|
|
17
|
+
export interface StorageAPI {
|
|
18
|
+
setItem(key: string, value: string): Promise<void>;
|
|
19
|
+
getItem(key: string): Promise<string | null>;
|
|
20
|
+
removeItem(key: string): Promise<void>;
|
|
21
|
+
clear(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export interface CreationStorage {
|
|
24
|
+
plain: StorageAPI;
|
|
25
|
+
secure: StorageAPI;
|
|
26
|
+
}
|
|
27
|
+
export interface PluginMessage {
|
|
28
|
+
message: string;
|
|
29
|
+
useLLM?: boolean;
|
|
30
|
+
wantsR1Response?: boolean;
|
|
31
|
+
wantsJournalEntry?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface PluginMessageResponse {
|
|
34
|
+
message: string;
|
|
35
|
+
pluginId: string;
|
|
36
|
+
data?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface R1Dimensions {
|
|
39
|
+
width: 240;
|
|
40
|
+
height: 282;
|
|
41
|
+
}
|
|
42
|
+
export type HardwareEventType = 'sideClick' | 'longPressStart' | 'longPressEnd' | 'scrollUp' | 'scrollDown';
|
|
43
|
+
declare global {
|
|
44
|
+
interface Window {
|
|
45
|
+
creationStorage: CreationStorage;
|
|
46
|
+
creationSensors: {
|
|
47
|
+
accelerometer: {
|
|
48
|
+
isAvailable(): Promise<boolean>;
|
|
49
|
+
start(callback: (data: AccelerometerData) => void, options?: AccelerometerOptions): void;
|
|
50
|
+
stop(): void;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
onPluginMessage?: (data: PluginMessageResponse) => void;
|
|
54
|
+
}
|
|
55
|
+
const PluginMessageHandler: {
|
|
56
|
+
postMessage(message: string): void;
|
|
57
|
+
};
|
|
58
|
+
const closeWebView: {
|
|
59
|
+
postMessage(message: string): void;
|
|
60
|
+
};
|
|
61
|
+
const TouchEventHandler: {
|
|
62
|
+
postMessage(message: string): void;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,MAAM,W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YAAY,CAAC;AAGjB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,eAAe,EAAE,eAAe,CAAC;QACjC,eAAe,EAAE;YACf,aAAa,EAAE;gBACb,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;gBAChC,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;gBACzF,IAAI,IAAI,IAAI,CAAC;aACd,CAAC;SACH,CAAC;QACF,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,IAAI,CAAC;KACzD;IAGD,MAAM,oBAAoB,EAAE;QAC1B,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACpC,CAAC;IAEF,MAAM,YAAY,EAAE;QAClB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACpC,CAAC;IAEF,MAAM,iBAAiB,EAAE;QACvB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACpC,CAAC;CACH;AAED,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI utilities module for R1 display optimization
|
|
3
|
+
* Provides tools for 240x282px display, hardware-accelerated CSS, and DOM optimization
|
|
4
|
+
*/
|
|
5
|
+
import type { R1Dimensions } from '../types';
|
|
6
|
+
export declare const R1_DIMENSIONS: R1Dimensions;
|
|
7
|
+
/**
|
|
8
|
+
* CSS utilities for hardware-accelerated animations and R1 optimization
|
|
9
|
+
*/
|
|
10
|
+
export declare class CSSUtils {
|
|
11
|
+
/**
|
|
12
|
+
* Apply hardware-accelerated transform
|
|
13
|
+
* @param element Target element
|
|
14
|
+
* @param transform Transform value (e.g., 'translateX(10px)')
|
|
15
|
+
*/
|
|
16
|
+
static setTransform(element: HTMLElement, transform: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* Apply hardware-accelerated opacity
|
|
19
|
+
* @param element Target element
|
|
20
|
+
* @param opacity Opacity value (0-1)
|
|
21
|
+
*/
|
|
22
|
+
static setOpacity(element: HTMLElement, opacity: number): void;
|
|
23
|
+
/**
|
|
24
|
+
* Reset will-change property to optimize performance
|
|
25
|
+
* @param element Target element
|
|
26
|
+
*/
|
|
27
|
+
static resetWillChange(element: HTMLElement): void;
|
|
28
|
+
/**
|
|
29
|
+
* Add hardware-accelerated transition
|
|
30
|
+
* @param element Target element
|
|
31
|
+
* @param property CSS property to transition
|
|
32
|
+
* @param duration Duration in milliseconds
|
|
33
|
+
* @param easing Easing function (default: ease-out)
|
|
34
|
+
*/
|
|
35
|
+
static addTransition(element: HTMLElement, property: string, duration: number, easing?: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Create optimized CSS animation class
|
|
38
|
+
* @param name Animation name
|
|
39
|
+
* @param keyframes CSS keyframes
|
|
40
|
+
* @param duration Duration in milliseconds
|
|
41
|
+
* @param easing Easing function
|
|
42
|
+
*/
|
|
43
|
+
static createAnimation(name: string, keyframes: string, duration: number, easing?: string): void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* DOM optimization utilities for minimal DOM changes
|
|
47
|
+
*/
|
|
48
|
+
export declare class DOMUtils {
|
|
49
|
+
private static documentFragment;
|
|
50
|
+
/**
|
|
51
|
+
* Batch DOM operations using DocumentFragment
|
|
52
|
+
* @param operations Function containing DOM operations
|
|
53
|
+
* @param container Container element to append fragment to
|
|
54
|
+
*/
|
|
55
|
+
static batchOperations(operations: (fragment: DocumentFragment) => void, container: HTMLElement): void;
|
|
56
|
+
/**
|
|
57
|
+
* Efficiently update element content without full innerHTML replacement
|
|
58
|
+
* @param element Target element
|
|
59
|
+
* @param content New content
|
|
60
|
+
*/
|
|
61
|
+
static updateContent(element: HTMLElement, content: string): void;
|
|
62
|
+
/**
|
|
63
|
+
* Toggle class efficiently
|
|
64
|
+
* @param element Target element
|
|
65
|
+
* @param className Class name to toggle
|
|
66
|
+
* @param condition Optional condition for toggle
|
|
67
|
+
*/
|
|
68
|
+
static toggleClass(element: HTMLElement, className: string, condition?: boolean): void;
|
|
69
|
+
/**
|
|
70
|
+
* Create element with optimized attributes
|
|
71
|
+
* @param tagName Element tag name
|
|
72
|
+
* @param attributes Element attributes
|
|
73
|
+
* @param textContent Optional text content
|
|
74
|
+
*/
|
|
75
|
+
static createElement<K extends keyof HTMLElementTagNameMap>(tagName: K, attributes?: Record<string, string>, textContent?: string): HTMLElementTagNameMap[K];
|
|
76
|
+
/**
|
|
77
|
+
* Debounce function for reducing DOM updates
|
|
78
|
+
* @param func Function to debounce
|
|
79
|
+
* @param delay Delay in milliseconds
|
|
80
|
+
*/
|
|
81
|
+
static debounce<T extends (...args: any[]) => any>(func: T, delay: number): T;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Layout utilities for R1 display
|
|
85
|
+
*/
|
|
86
|
+
export declare class LayoutUtils {
|
|
87
|
+
/**
|
|
88
|
+
* Check if coordinates are within R1 display bounds
|
|
89
|
+
* @param x X coordinate
|
|
90
|
+
* @param y Y coordinate
|
|
91
|
+
*/
|
|
92
|
+
static isWithinBounds(x: number, y: number): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Clamp coordinates to R1 display bounds
|
|
95
|
+
* @param x X coordinate
|
|
96
|
+
* @param y Y coordinate
|
|
97
|
+
*/
|
|
98
|
+
static clampToBounds(x: number, y: number): {
|
|
99
|
+
x: number;
|
|
100
|
+
y: number;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Calculate responsive font size based on container
|
|
104
|
+
* @param containerWidth Container width
|
|
105
|
+
* @param baseSize Base font size in px
|
|
106
|
+
* @param minSize Minimum font size in px
|
|
107
|
+
* @param maxSize Maximum font size in px
|
|
108
|
+
*/
|
|
109
|
+
static calculateFontSize(containerWidth: number, baseSize?: number, minSize?: number, maxSize?: number): number;
|
|
110
|
+
/**
|
|
111
|
+
* Create CSS for R1-optimized container
|
|
112
|
+
*/
|
|
113
|
+
static createR1Container(): string;
|
|
114
|
+
/**
|
|
115
|
+
* Apply R1 container styles to element
|
|
116
|
+
* @param element Target element
|
|
117
|
+
*/
|
|
118
|
+
static applyR1Container(element: HTMLElement): void;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Performance monitoring utilities
|
|
122
|
+
*/
|
|
123
|
+
export declare class PerformanceUtils {
|
|
124
|
+
private static performanceMarks;
|
|
125
|
+
/**
|
|
126
|
+
* Start performance measurement
|
|
127
|
+
* @param name Measurement name
|
|
128
|
+
*/
|
|
129
|
+
static startMeasure(name: string): void;
|
|
130
|
+
/**
|
|
131
|
+
* End performance measurement and log result
|
|
132
|
+
* @param name Measurement name
|
|
133
|
+
* @param logToConsole Whether to log to console
|
|
134
|
+
*/
|
|
135
|
+
static endMeasure(name: string, logToConsole?: boolean): number;
|
|
136
|
+
/**
|
|
137
|
+
* Monitor frame rate
|
|
138
|
+
* @param duration Duration to monitor in seconds
|
|
139
|
+
* @param callback Callback with average FPS
|
|
140
|
+
*/
|
|
141
|
+
static monitorFPS(duration: number, callback: (fps: number) => void): void;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* R1 UI Component base class
|
|
145
|
+
*/
|
|
146
|
+
export declare abstract class R1Component {
|
|
147
|
+
protected element: HTMLElement;
|
|
148
|
+
protected mounted: boolean;
|
|
149
|
+
constructor(tagName?: string, className?: string);
|
|
150
|
+
/**
|
|
151
|
+
* Mount component to container
|
|
152
|
+
* @param container Container element
|
|
153
|
+
*/
|
|
154
|
+
mount(container: HTMLElement): void;
|
|
155
|
+
/**
|
|
156
|
+
* Unmount component
|
|
157
|
+
*/
|
|
158
|
+
unmount(): void;
|
|
159
|
+
/**
|
|
160
|
+
* Get component element
|
|
161
|
+
*/
|
|
162
|
+
getElement(): HTMLElement;
|
|
163
|
+
/**
|
|
164
|
+
* Check if component is mounted
|
|
165
|
+
*/
|
|
166
|
+
isMounted(): boolean;
|
|
167
|
+
protected abstract onMount(): void;
|
|
168
|
+
protected abstract onUnmount(): void;
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,aAAa,EAAE,YAG3B,CAAC;AAEF;;GAEG;AACH,qBAAa,QAAQ;IACnB;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAKlE;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAK9D;;;OAGG;IACH,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAIlD;;;;;;OAMG;IACH,MAAM,CAAC,aAAa,CAClB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,MAAmB,GAC1B,IAAI;IAIP;;;;;;OAMG;IACH,MAAM,CAAC,eAAe,CACpB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,MAAmB,GAC1B,IAAI;CAYR;AAED;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAiC;IAEhE;;;;OAIG;IACH,MAAM,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IA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