@nice2dev/ui-core 1.0.10
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/CHANGELOG.md +63 -0
- package/README.md +62 -0
- package/dist/core/NiceInlineHelp.d.ts +69 -0
- package/dist/core/NiceInlineHelp.d.ts.map +1 -0
- package/dist/core/NiceThemeProvider.d.ts +31 -0
- package/dist/core/NiceThemeProvider.d.ts.map +1 -0
- package/dist/core/NiceThemeVariants.d.ts +55 -0
- package/dist/core/NiceThemeVariants.d.ts.map +1 -0
- package/dist/core/NiceUserPreferences.d.ts +304 -0
- package/dist/core/NiceUserPreferences.d.ts.map +1 -0
- package/dist/core/a11y-advanced.d.ts +157 -0
- package/dist/core/a11y-advanced.d.ts.map +1 -0
- package/dist/core/a11y.d.ts +299 -0
- package/dist/core/a11y.d.ts.map +1 -0
- package/dist/core/access-control.d.ts +59 -0
- package/dist/core/access-control.d.ts.map +1 -0
- package/dist/core/adapters.d.ts +178 -0
- package/dist/core/adapters.d.ts.map +1 -0
- package/dist/core/ai.d.ts +191 -0
- package/dist/core/ai.d.ts.map +1 -0
- package/dist/core/animations.d.ts +48 -0
- package/dist/core/animations.d.ts.map +1 -0
- package/dist/core/colorBlind.d.ts +22 -0
- package/dist/core/colorBlind.d.ts.map +1 -0
- package/dist/core/datasource-advanced.d.ts +261 -0
- package/dist/core/datasource-advanced.d.ts.map +1 -0
- package/dist/core/datasource-aggregation.d.ts +221 -0
- package/dist/core/datasource-aggregation.d.ts.map +1 -0
- package/dist/core/datasource-hooks.d.ts +93 -0
- package/dist/core/datasource-hooks.d.ts.map +1 -0
- package/dist/core/datasource-offline.d.ts +201 -0
- package/dist/core/datasource-offline.d.ts.map +1 -0
- package/dist/core/datasource.d.ts +181 -0
- package/dist/core/datasource.d.ts.map +1 -0
- package/dist/core/displayMode.d.ts +46 -0
- package/dist/core/displayMode.d.ts.map +1 -0
- package/dist/core/displayStyle.d.ts +79 -0
- package/dist/core/displayStyle.d.ts.map +1 -0
- package/dist/core/helpContext.d.ts +97 -0
- package/dist/core/helpContext.d.ts.map +1 -0
- package/dist/core/hooks.d.ts +149 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/i18n.d.ts +10 -0
- package/dist/core/i18n.d.ts.map +1 -0
- package/dist/core/i18nDictionaries.d.ts +4 -0
- package/dist/core/i18nDictionaries.d.ts.map +1 -0
- package/dist/core/icons.d.ts +45 -0
- package/dist/core/icons.d.ts.map +1 -0
- package/dist/core/icuMessageFormat.d.ts +10 -0
- package/dist/core/icuMessageFormat.d.ts.map +1 -0
- package/dist/core/leak-detector.d.ts +263 -0
- package/dist/core/leak-detector.d.ts.map +1 -0
- package/dist/core/omniverkTypes.d.ts +164 -0
- package/dist/core/omniverkTypes.d.ts.map +1 -0
- package/dist/core/pluginSystem.d.ts +97 -0
- package/dist/core/pluginSystem.d.ts.map +1 -0
- package/dist/core/profiling.d.ts +276 -0
- package/dist/core/profiling.d.ts.map +1 -0
- package/dist/core/responsive.d.ts +107 -0
- package/dist/core/responsive.d.ts.map +1 -0
- package/dist/core/rtl.d.ts +47 -0
- package/dist/core/rtl.d.ts.map +1 -0
- package/dist/core/sanitizeHtml.d.ts +16 -0
- package/dist/core/sanitizeHtml.d.ts.map +1 -0
- package/dist/core/testing.d.ts +107 -0
- package/dist/core/testing.d.ts.map +1 -0
- package/dist/core/theme.d.ts +213 -0
- package/dist/core/theme.d.ts.map +1 -0
- package/dist/core/themeGallery.d.ts +104 -0
- package/dist/core/themeGallery.d.ts.map +1 -0
- package/dist/core/themePacks.d.ts +53 -0
- package/dist/core/themePacks.d.ts.map +1 -0
- package/dist/core/themePacksExtended.d.ts +59 -0
- package/dist/core/themePacksExtended.d.ts.map +1 -0
- package/dist/core/themePresets.d.ts +10 -0
- package/dist/core/themePresets.d.ts.map +1 -0
- package/dist/core/themeVariants.d.ts +204 -0
- package/dist/core/themeVariants.d.ts.map +1 -0
- package/dist/core/touch.d.ts +208 -0
- package/dist/core/touch.d.ts.map +1 -0
- package/dist/core/traceless.d.ts +461 -0
- package/dist/core/traceless.d.ts.map +1 -0
- package/dist/core/types.d.ts +105 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/useThemeIsDark.d.ts +15 -0
- package/dist/core/useThemeIsDark.d.ts.map +1 -0
- package/dist/index.cjs +128 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +16881 -0
- package/dist/index.mjs.map +1 -0
- package/dist/performance/concurrent.d.ts +190 -0
- package/dist/performance/concurrent.d.ts.map +1 -0
- package/dist/performance/images.d.ts +189 -0
- package/dist/performance/images.d.ts.map +1 -0
- package/dist/performance/index.d.ts +17 -0
- package/dist/performance/index.d.ts.map +1 -0
- package/dist/performance/memory.d.ts +223 -0
- package/dist/performance/memory.d.ts.map +1 -0
- package/dist/performance/virtualization.d.ts +166 -0
- package/dist/performance/virtualization.d.ts.map +1 -0
- package/dist/performance/workers.d.ts +125 -0
- package/dist/performance/workers.d.ts.map +1 -0
- package/dist/viewSchema.d.ts +81 -0
- package/dist/viewSchema.d.ts.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omniverkTypes.d.ts","sourceRoot":"","sources":["../../src/core/omniverkTypes.ts"],"names":[],"mappings":"AAMA,oFAAoF;AACpF,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAID,oDAAoD;AACpD,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAA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BAAgB,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAID,yDAAyD;AACzD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAIpG;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yBAAyB;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NicePluginSystem — runtime plugin loading skeleton (v1.0.10 stub, E2.5).
|
|
3
|
+
*
|
|
4
|
+
* Goals:
|
|
5
|
+
* - Discover, register, activate and deactivate plugins at runtime.
|
|
6
|
+
* - Decouple plugin authors from internal modules via a typed `NicePluginContext`.
|
|
7
|
+
* - Stay framework-agnostic: zero React imports, safe to use from SSR or workers.
|
|
8
|
+
*
|
|
9
|
+
* NOT IN SCOPE (deferred to v1.0.11+):
|
|
10
|
+
* - Sandbox / iframe execution
|
|
11
|
+
* - Permission prompts UI
|
|
12
|
+
* - Marketplace fetching / version resolution
|
|
13
|
+
* - Hot reload semantics
|
|
14
|
+
*/
|
|
15
|
+
/** Lifecycle phase a plugin is currently in. */
|
|
16
|
+
export type NicePluginStatus = 'registered' | 'activating' | 'active' | 'deactivating' | 'inactive' | 'error';
|
|
17
|
+
/** Permission a plugin may request. Coarse-grained by design. */
|
|
18
|
+
export type NicePluginPermission = 'storage:read' | 'storage:write' | 'network:fetch' | 'ui:overlay' | 'ui:command' | 'theme:read' | 'i18n:contribute' | 'events:listen' | 'events:emit';
|
|
19
|
+
/** Static metadata supplied by plugin authors. */
|
|
20
|
+
export interface NicePluginManifest {
|
|
21
|
+
/** Stable, unique id (reverse-DNS recommended, e.g. `com.acme.timer`). */
|
|
22
|
+
id: string;
|
|
23
|
+
/** Human-readable name. */
|
|
24
|
+
name: string;
|
|
25
|
+
/** SemVer string. */
|
|
26
|
+
version: string;
|
|
27
|
+
/** Short description (≤ 160 chars). */
|
|
28
|
+
description?: string;
|
|
29
|
+
/** Author display name. */
|
|
30
|
+
author?: string;
|
|
31
|
+
/** Permissions the plugin requests. Empty = sandbox mode. */
|
|
32
|
+
permissions?: NicePluginPermission[];
|
|
33
|
+
/** IDs of other plugins this one depends on. */
|
|
34
|
+
dependsOn?: string[];
|
|
35
|
+
/** Optional entry-point hint (URL or module path). */
|
|
36
|
+
entry?: string;
|
|
37
|
+
/** Free-form metadata (icons, tags, marketplace info). */
|
|
38
|
+
meta?: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
/** Runtime context handed to a plugin during activation. */
|
|
41
|
+
export interface NicePluginContext {
|
|
42
|
+
/** The granted permissions (intersection of requested + host policy). */
|
|
43
|
+
readonly permissions: ReadonlySet<NicePluginPermission>;
|
|
44
|
+
/** Logger scoped to this plugin id. */
|
|
45
|
+
log: (level: 'debug' | 'info' | 'warn' | 'error', ...args: unknown[]) => void;
|
|
46
|
+
/** Subscribe to a host event. Returns an unsubscribe function. */
|
|
47
|
+
on: (event: string, handler: (payload: unknown) => void) => () => void;
|
|
48
|
+
/** Emit an event to the host (subject to `events:emit` permission). */
|
|
49
|
+
emit: (event: string, payload?: unknown) => void;
|
|
50
|
+
/** Persist a value (subject to `storage:write`). */
|
|
51
|
+
setItem: (key: string, value: unknown) => Promise<void>;
|
|
52
|
+
/** Read a previously stored value (subject to `storage:read`). */
|
|
53
|
+
getItem: <T = unknown>(key: string) => Promise<T | undefined>;
|
|
54
|
+
}
|
|
55
|
+
/** A loadable plugin module. */
|
|
56
|
+
export interface NicePlugin {
|
|
57
|
+
manifest: NicePluginManifest;
|
|
58
|
+
/** Called once when the plugin is activated. */
|
|
59
|
+
activate(ctx: NicePluginContext): void | Promise<void>;
|
|
60
|
+
/** Called when the plugin is deactivated or unloaded. */
|
|
61
|
+
deactivate?(): void | Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
/** Public registry record exposed to consumers. */
|
|
64
|
+
export interface NicePluginRecord {
|
|
65
|
+
manifest: NicePluginManifest;
|
|
66
|
+
status: NicePluginStatus;
|
|
67
|
+
error?: string;
|
|
68
|
+
activatedAt?: number;
|
|
69
|
+
}
|
|
70
|
+
/** Options accepted by {@link createNicePluginSystem}. */
|
|
71
|
+
export interface NicePluginSystemOptions {
|
|
72
|
+
/** Default permission policy. Returns the subset that should be granted. */
|
|
73
|
+
permissionPolicy?: (requested: ReadonlyArray<NicePluginPermission>, manifest: NicePluginManifest) => NicePluginPermission[];
|
|
74
|
+
/** Storage backend (defaults to in-memory map). */
|
|
75
|
+
storage?: {
|
|
76
|
+
getItem: (key: string) => Promise<unknown>;
|
|
77
|
+
setItem: (key: string, value: unknown) => Promise<void>;
|
|
78
|
+
};
|
|
79
|
+
/** Optional logger sink. */
|
|
80
|
+
logger?: (pluginId: string, level: 'debug' | 'info' | 'warn' | 'error', args: unknown[]) => void;
|
|
81
|
+
}
|
|
82
|
+
/** Public surface returned by {@link createNicePluginSystem}. */
|
|
83
|
+
export interface NicePluginSystem {
|
|
84
|
+
register(plugin: NicePlugin): NicePluginRecord;
|
|
85
|
+
unregister(id: string): boolean;
|
|
86
|
+
activate(id: string): Promise<NicePluginRecord>;
|
|
87
|
+
deactivate(id: string): Promise<NicePluginRecord>;
|
|
88
|
+
list(): NicePluginRecord[];
|
|
89
|
+
get(id: string): NicePluginRecord | undefined;
|
|
90
|
+
on(event: 'register' | 'activate' | 'deactivate' | 'error', handler: (record: NicePluginRecord) => void): () => void;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create a fresh plugin system instance. Multiple isolated systems can coexist
|
|
94
|
+
* (e.g. one per workspace, one for tests).
|
|
95
|
+
*/
|
|
96
|
+
export declare function createNicePluginSystem(options?: NicePluginSystemOptions): NicePluginSystem;
|
|
97
|
+
//# sourceMappingURL=pluginSystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginSystem.d.ts","sourceRoot":"","sources":["../../src/core/pluginSystem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,gDAAgD;AAChD,MAAM,MAAM,gBAAgB,GACxB,YAAY,GACZ,YAAY,GACZ,QAAQ,GACR,cAAc,GACd,UAAU,GACV,OAAO,CAAC;AAEZ,iEAAiE;AACjE,MAAM,MAAM,oBAAoB,GAC5B,cAAc,GACd,eAAe,GACf,eAAe,GACf,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,iBAAiB,GACjB,eAAe,GACf,aAAa,CAAC;AAElB,kDAAkD;AAClD,MAAM,WAAW,kBAAkB;IACjC,0EAA0E;IAC1E,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACrC,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAA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GAAE,uBAA4B,GAAG,gBAAgB,CAyL9F"}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file profiling.tsx
|
|
3
|
+
* @description Performance profiling tools for Nice2Dev UI components
|
|
4
|
+
*
|
|
5
|
+
* Features:
|
|
6
|
+
* - Component render profiling
|
|
7
|
+
* - Re-render detection
|
|
8
|
+
* - Performance marks and measures
|
|
9
|
+
* - React DevTools Profiler integration
|
|
10
|
+
* - User Timing API integration
|
|
11
|
+
* - Render count tracking
|
|
12
|
+
* - Performance regression detection
|
|
13
|
+
*
|
|
14
|
+
* @version 1.0.0
|
|
15
|
+
* @since 2026-03
|
|
16
|
+
* @license MIT
|
|
17
|
+
*/
|
|
18
|
+
import React from 'react';
|
|
19
|
+
/**
|
|
20
|
+
* Render timing data
|
|
21
|
+
*/
|
|
22
|
+
export interface RenderTiming {
|
|
23
|
+
/** Component name */
|
|
24
|
+
componentName: string;
|
|
25
|
+
/** Unique render ID */
|
|
26
|
+
renderId: string;
|
|
27
|
+
/** Render phase */
|
|
28
|
+
phase: 'mount' | 'update' | 'nested-update';
|
|
29
|
+
/** Actual render duration (ms) */
|
|
30
|
+
actualDuration: number;
|
|
31
|
+
/** Base render duration without memoization (ms) */
|
|
32
|
+
baseDuration: number;
|
|
33
|
+
/** Start time relative to page load */
|
|
34
|
+
startTime: number;
|
|
35
|
+
/** Commit time */
|
|
36
|
+
commitTime: number;
|
|
37
|
+
/** Interactions that triggered render */
|
|
38
|
+
interactions: Set<{
|
|
39
|
+
id: number;
|
|
40
|
+
name: string;
|
|
41
|
+
timestamp: number;
|
|
42
|
+
}>;
|
|
43
|
+
/** Timestamp */
|
|
44
|
+
timestamp: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Component render stats
|
|
48
|
+
*/
|
|
49
|
+
export interface RenderStats {
|
|
50
|
+
/** Component name */
|
|
51
|
+
componentName: string;
|
|
52
|
+
/** Total render count */
|
|
53
|
+
renderCount: number;
|
|
54
|
+
/** Mount count */
|
|
55
|
+
mountCount: number;
|
|
56
|
+
/** Update count */
|
|
57
|
+
updateCount: number;
|
|
58
|
+
/** Average render time (ms) */
|
|
59
|
+
avgRenderTime: number;
|
|
60
|
+
/** Max render time (ms) */
|
|
61
|
+
maxRenderTime: number;
|
|
62
|
+
/** Min render time (ms) */
|
|
63
|
+
minRenderTime: number;
|
|
64
|
+
/** Total render time (ms) */
|
|
65
|
+
totalRenderTime: number;
|
|
66
|
+
/** Last render timestamp */
|
|
67
|
+
lastRenderAt: number;
|
|
68
|
+
/** Slow render count (>16ms) */
|
|
69
|
+
slowRenderCount: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Profiler configuration
|
|
73
|
+
*/
|
|
74
|
+
export interface ProfilerConfig {
|
|
75
|
+
/** Enable profiling (default: true in dev) */
|
|
76
|
+
enabled?: boolean;
|
|
77
|
+
/** Log renders to console */
|
|
78
|
+
logToConsole?: boolean;
|
|
79
|
+
/** Slow render threshold (ms) */
|
|
80
|
+
slowRenderThreshold?: number;
|
|
81
|
+
/** Custom render callback */
|
|
82
|
+
onRender?: (timing: RenderTiming) => void;
|
|
83
|
+
/** Custom slow render callback */
|
|
84
|
+
onSlowRender?: (timing: RenderTiming) => void;
|
|
85
|
+
/** Sampling rate (0-1) */
|
|
86
|
+
samplingRate?: number;
|
|
87
|
+
/** Component names to ignore */
|
|
88
|
+
ignoreComponents?: string[];
|
|
89
|
+
/** Enable User Timing API marks */
|
|
90
|
+
enableUserTiming?: boolean;
|
|
91
|
+
/** Track individual props changes */
|
|
92
|
+
trackPropsChanges?: boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Props change info
|
|
96
|
+
*/
|
|
97
|
+
export interface PropsChange {
|
|
98
|
+
propName: string;
|
|
99
|
+
oldValue: unknown;
|
|
100
|
+
newValue: unknown;
|
|
101
|
+
timestamp: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Performance mark
|
|
105
|
+
*/
|
|
106
|
+
export interface PerformanceMark {
|
|
107
|
+
name: string;
|
|
108
|
+
startTime: number;
|
|
109
|
+
duration?: number;
|
|
110
|
+
detail?: Record<string, unknown>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Configure the profiler globally
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```tsx
|
|
117
|
+
* configureProfiler({
|
|
118
|
+
* enabled: true,
|
|
119
|
+
* logToConsole: true,
|
|
120
|
+
* slowRenderThreshold: 16,
|
|
121
|
+
* onSlowRender: (timing) => reportSlowRender(timing),
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare function configureProfiler(config: Partial<ProfilerConfig>): void;
|
|
126
|
+
/**
|
|
127
|
+
* Get profiler stats for all components
|
|
128
|
+
*/
|
|
129
|
+
export declare function getProfilingStats(): Map<string, RenderStats>;
|
|
130
|
+
/**
|
|
131
|
+
* Get profiling stats for a specific component
|
|
132
|
+
*/
|
|
133
|
+
export declare function getComponentStats(componentName: string): RenderStats | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* Get recent render timings
|
|
136
|
+
*/
|
|
137
|
+
export declare function getRecentTimings(limit?: number): RenderTiming[];
|
|
138
|
+
/**
|
|
139
|
+
* Clear all profiling data
|
|
140
|
+
*/
|
|
141
|
+
export declare function clearProfilingData(): void;
|
|
142
|
+
/**
|
|
143
|
+
* Get slow renders (above threshold)
|
|
144
|
+
*/
|
|
145
|
+
export declare function getSlowRenders(thresholdMs?: number): RenderTiming[];
|
|
146
|
+
interface NiceProfilerProps {
|
|
147
|
+
/** Unique ID for the profiler */
|
|
148
|
+
id: string;
|
|
149
|
+
/** Children to profile */
|
|
150
|
+
children: React.ReactNode;
|
|
151
|
+
/** Additional render callback */
|
|
152
|
+
onRender?: (timing: RenderTiming) => void;
|
|
153
|
+
/** Additional slow render callback */
|
|
154
|
+
onSlowRender?: (timing: RenderTiming) => void;
|
|
155
|
+
/** Override slow threshold */
|
|
156
|
+
slowThreshold?: number;
|
|
157
|
+
/** Enable console logging for this profiler */
|
|
158
|
+
logToConsole?: boolean;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* NiceProfiler - Wrapper component for profiling
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```tsx
|
|
165
|
+
* <NiceProfiler id="DataGrid" onSlowRender={handleSlowRender}>
|
|
166
|
+
* <NiceDataGrid data={data} />
|
|
167
|
+
* </NiceProfiler>
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
export declare const NiceProfiler: React.FC<NiceProfilerProps>;
|
|
171
|
+
/**
|
|
172
|
+
* Hook to track why a component re-rendered
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```tsx
|
|
176
|
+
* function MyComponent({ items, onClick }) {
|
|
177
|
+
* useWhyDidYouRender('MyComponent', { items, onClick });
|
|
178
|
+
* return <div>...</div>;
|
|
179
|
+
* }
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
export declare function useWhyDidYouRender(componentName: string, props: Record<string, unknown>): void;
|
|
183
|
+
/**
|
|
184
|
+
* HOC version of useWhyDidYouRender
|
|
185
|
+
*/
|
|
186
|
+
export declare function withWhyDidYouRender<P extends object>(Component: React.ComponentType<P>, displayName?: string): React.FC<P>;
|
|
187
|
+
/**
|
|
188
|
+
* Hook to count component renders
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```tsx
|
|
192
|
+
* function MyComponent() {
|
|
193
|
+
* const renderCount = useRenderCount('MyComponent');
|
|
194
|
+
* console.log('Render count:', renderCount);
|
|
195
|
+
* return <div>...</div>;
|
|
196
|
+
* }
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
export declare function useRenderCount(componentName?: string): number;
|
|
200
|
+
/**
|
|
201
|
+
* Start a performance mark
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```tsx
|
|
205
|
+
* startMark('fetchData');
|
|
206
|
+
* await fetchData();
|
|
207
|
+
* const duration = endMark('fetchData');
|
|
208
|
+
* console.log('Fetch took:', duration, 'ms');
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
export declare function startMark(name: string, detail?: Record<string, unknown>): void;
|
|
212
|
+
/**
|
|
213
|
+
* End a performance mark and return duration
|
|
214
|
+
*/
|
|
215
|
+
export declare function endMark(name: string): number;
|
|
216
|
+
/**
|
|
217
|
+
* Measure an async operation
|
|
218
|
+
*/
|
|
219
|
+
export declare function measureAsync<T>(name: string, operation: () => Promise<T>, detail?: Record<string, unknown>): Promise<T>;
|
|
220
|
+
/**
|
|
221
|
+
* Measure a sync operation
|
|
222
|
+
*/
|
|
223
|
+
export declare function measureSync<T>(name: string, operation: () => T, detail?: Record<string, unknown>): T;
|
|
224
|
+
/**
|
|
225
|
+
* Hook for measuring effect duration
|
|
226
|
+
*/
|
|
227
|
+
export declare function useMeasureEffect(name: string, effect: () => void | (() => void), deps: React.DependencyList): void;
|
|
228
|
+
/**
|
|
229
|
+
* Get a complete performance report
|
|
230
|
+
*/
|
|
231
|
+
export declare function getPerformanceReport(): {
|
|
232
|
+
stats: RenderStats[];
|
|
233
|
+
slowRenders: RenderTiming[];
|
|
234
|
+
totalRenders: number;
|
|
235
|
+
avgRenderTime: number;
|
|
236
|
+
marks: PerformanceMark[];
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Print performance report to console
|
|
240
|
+
*/
|
|
241
|
+
export declare function printPerformanceReport(): void;
|
|
242
|
+
/**
|
|
243
|
+
* Save current stats as baseline for regression detection
|
|
244
|
+
*/
|
|
245
|
+
export declare function saveBaseline(): void;
|
|
246
|
+
/**
|
|
247
|
+
* Compare current stats against baseline
|
|
248
|
+
*/
|
|
249
|
+
export declare function checkRegression(thresholdPercent?: number): Array<{
|
|
250
|
+
componentName: string;
|
|
251
|
+
metric: string;
|
|
252
|
+
baseline: number;
|
|
253
|
+
current: number;
|
|
254
|
+
changePercent: number;
|
|
255
|
+
}>;
|
|
256
|
+
interface ProfilerOverlayProps {
|
|
257
|
+
/** Position on screen */
|
|
258
|
+
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
259
|
+
/** Initial collapsed state */
|
|
260
|
+
defaultCollapsed?: boolean;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Debug overlay showing profiling stats
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```tsx
|
|
267
|
+
* {process.env.NODE_ENV === 'development' && <ProfilerOverlay position="bottom-right" />}
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
export declare const ProfilerOverlay: React.FC<ProfilerOverlayProps>;
|
|
271
|
+
/**
|
|
272
|
+
* Setup integration with React DevTools Profiler
|
|
273
|
+
*/
|
|
274
|
+
export declare function setupReactDevToolsIntegration(): void;
|
|
275
|
+
export {};
|
|
276
|
+
//# sourceMappingURL=profiling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiling.d.ts","sourceRoot":"","sources":["../../src/core/profiling.tsx"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KASN,MAAM,OAAO,CAAC;AAMf;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,qBAAqB;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB;IACnB,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,eAAe,CAAC;IAC5C,kCAAkC;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,YAAY,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,YAAY,EAAE,GAAG,CAAC;QAAE,EAAE,E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ceBreakpoints;
|
|
10
|
+
export type NiceBreakpoint = keyof NiceBreakpoints;
|
|
11
|
+
export interface UseBreakpointResult {
|
|
12
|
+
/** Current breakpoint name */
|
|
13
|
+
current: NiceBreakpoint;
|
|
14
|
+
/** Window width in pixels */
|
|
15
|
+
width: number;
|
|
16
|
+
/** True if viewport >= the given breakpoint */
|
|
17
|
+
isAbove: (bp: NiceBreakpoint) => boolean;
|
|
18
|
+
/** True if viewport < the given breakpoint */
|
|
19
|
+
isBelow: (bp: NiceBreakpoint) => boolean;
|
|
20
|
+
/** True if viewport is between two breakpoints (inclusive lower, exclusive upper) */
|
|
21
|
+
isBetween: (lower: NiceBreakpoint, upper: NiceBreakpoint) => boolean;
|
|
22
|
+
/** True if viewport is mobile (< md) */
|
|
23
|
+
isMobile: boolean;
|
|
24
|
+
/** True if viewport is tablet (md–lg) */
|
|
25
|
+
isTablet: boolean;
|
|
26
|
+
/** True if viewport is desktop (>= lg) */
|
|
27
|
+
isDesktop: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare function useBreakpoint(breakpoints?: NiceBreakpoints): UseBreakpointResult;
|
|
30
|
+
export declare function useMediaQuery(query: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Define a value per breakpoint. Missing breakpoints inherit from the
|
|
33
|
+
* nearest smaller breakpoint.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const cols = useResponsiveValue({ xs: 1, sm: 2, lg: 4 });
|
|
37
|
+
* // On a 1024px screen (lg), cols = 4
|
|
38
|
+
* // On a 600px screen (sm), cols = 2
|
|
39
|
+
*/
|
|
40
|
+
export type NiceResponsiveValue<T> = T | Partial<Record<NiceBreakpoint, T>>;
|
|
41
|
+
export declare function useResponsiveValue<T>(value: NiceResponsiveValue<T>, breakpoints?: NiceBreakpoints): T;
|
|
42
|
+
export interface UseContainerSizeResult {
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
}
|
|
46
|
+
export declare function useContainerSize(ref: React.RefObject<HTMLElement | null>): UseContainerSizeResult;
|
|
47
|
+
export interface UseDeviceResult {
|
|
48
|
+
/** Is a mobile device (phone/tablet based on screen + touch) */
|
|
49
|
+
isMobile: boolean;
|
|
50
|
+
/** Has touch capability */
|
|
51
|
+
isTouch: boolean;
|
|
52
|
+
/** Is a phone-sized device (< 768px and touch) */
|
|
53
|
+
isPhone: boolean;
|
|
54
|
+
/** Is a tablet-sized device (768-1024px and touch) */
|
|
55
|
+
isTablet: boolean;
|
|
56
|
+
/** Is a desktop device (no touch OR > 1024px) */
|
|
57
|
+
isDesktop: boolean;
|
|
58
|
+
/** Prefers reduced motion */
|
|
59
|
+
prefersReducedMotion: boolean;
|
|
60
|
+
/** Is in portrait orientation */
|
|
61
|
+
isPortrait: boolean;
|
|
62
|
+
/** Device pixel ratio */
|
|
63
|
+
pixelRatio: number;
|
|
64
|
+
}
|
|
65
|
+
export declare function useDevice(): UseDeviceResult;
|
|
66
|
+
export type AdaptiveVariant = 'desktop' | 'tablet' | 'mobile';
|
|
67
|
+
export interface UseAdaptiveVariantOptions {
|
|
68
|
+
/** Force a specific variant */
|
|
69
|
+
forceVariant?: AdaptiveVariant;
|
|
70
|
+
/** Breakpoints config */
|
|
71
|
+
breakpoints?: NiceBreakpoints;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Hook to determine which component variant to render.
|
|
75
|
+
* Returns 'mobile', 'tablet', or 'desktop' based on device.
|
|
76
|
+
*/
|
|
77
|
+
export declare function useAdaptiveVariant(options?: UseAdaptiveVariantOptions): AdaptiveVariant;
|
|
78
|
+
export interface UseShowAtOptions {
|
|
79
|
+
/** Show at these breakpoints */
|
|
80
|
+
showAt?: NiceBreakpoint[];
|
|
81
|
+
/** Hide at these breakpoints */
|
|
82
|
+
hideAt?: NiceBreakpoint[];
|
|
83
|
+
/** Show only on mobile */
|
|
84
|
+
mobileOnly?: boolean;
|
|
85
|
+
/** Show only on desktop */
|
|
86
|
+
desktopOnly?: boolean;
|
|
87
|
+
/** Show only on tablet */
|
|
88
|
+
tabletOnly?: boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Hook to determine visibility based on breakpoint.
|
|
92
|
+
*/
|
|
93
|
+
export declare function useShowAt(options?: UseShowAtOptions): boolean;
|
|
94
|
+
export type ScreenOrientation = 'portrait' | 'landscape';
|
|
95
|
+
export declare function useOrientation(): ScreenOrientation;
|
|
96
|
+
export interface SafeAreaInsets {
|
|
97
|
+
top: number;
|
|
98
|
+
right: number;
|
|
99
|
+
bottom: number;
|
|
100
|
+
left: number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Hook to get safe area insets for notched devices.
|
|
104
|
+
* Returns CSS env() values as numbers.
|
|
105
|
+
*/
|
|
106
|
+
export declare function useSafeAreaInsets(): SafeAreaInsets;
|
|
107
|
+
//# sourceMappingURL=responsive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responsive.d.ts","sourceRoot":"","sources":["../../src/core/responsive.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,gBAAgB,EAAE,eAO9B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,eAAe,CAAC;AAMnD,MAAM,WAAW,mBAAmB;IAClC,8BAA8B;IAC9B,OAAO,EAAE,cAAc,CAAC;IACxB,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,OAAO,EAAE,CAAC,EAAE,EAAE,cAAc,KAAK,OAAO,CAAC;IACzC,8CAA8C;IAC9C,OAAO,EAAE,CAAC,EAAE,EAAE,cAAc,KAAK,OAAO,CAAC;IACzC,qF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AAgB,SAAS,IAAI,eAAe,CAkC3C;AAID,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE9D,MAAM,WAAW,yBAAyB;IACxC,+BAA+B;IAC/B,YAAY,CAAC,EAAE,eAAe,CAAC;IAC/B,yBAAyB;IACzB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG,eAAe,CA4B3F;AAID,MAAM,WAAW,gBAAgB;IAC/B,gCAAgC;IAChC,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;IAC1B,gCAAgC;IAChC,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;IAC1B,0BAA0B;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,2BAA2B;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0BAA0B;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAsBjE;AAID,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,WAAW,CAAC;AAEzD,wBAAgB,cAAc,IAAI,iBAAiB,CAGlD;AAID,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CAsDlD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type NiceDirection = 'ltr' | 'rtl' | 'auto';
|
|
3
|
+
export interface NiceRTLConfig {
|
|
4
|
+
direction: NiceDirection;
|
|
5
|
+
}
|
|
6
|
+
export interface NiceRTLProviderProps {
|
|
7
|
+
direction: NiceDirection;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
interface RTLContextValue {
|
|
11
|
+
direction: 'ltr' | 'rtl';
|
|
12
|
+
isRTL: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Flip a CSS logical value: swaps 'left' ↔ 'right',
|
|
15
|
+
* 'start' ↔ 'end' for RTL mode.
|
|
16
|
+
*/
|
|
17
|
+
flip: (value: 'left' | 'right' | 'start' | 'end') => 'left' | 'right' | 'start' | 'end';
|
|
18
|
+
/**
|
|
19
|
+
* Flip a horizontal numeric value (e.g., margin-left → margin-right).
|
|
20
|
+
* Returns { marginInlineStart: v } style for use in inline styles.
|
|
21
|
+
*/
|
|
22
|
+
flipStyle: (property: 'paddingLeft' | 'paddingRight' | 'marginLeft' | 'marginRight', value: string | number) => React.CSSProperties;
|
|
23
|
+
}
|
|
24
|
+
export declare const NiceRTLProvider: React.FC<NiceRTLProviderProps>;
|
|
25
|
+
export declare function useNiceRTL(): RTLContextValue;
|
|
26
|
+
/**
|
|
27
|
+
* Convert physical CSS properties to logical equivalents.
|
|
28
|
+
* Use these instead of left/right for RTL-safe components.
|
|
29
|
+
*/
|
|
30
|
+
export declare const logicalProps: {
|
|
31
|
+
marginStart: "marginInlineStart";
|
|
32
|
+
marginEnd: "marginInlineEnd";
|
|
33
|
+
paddingStart: "paddingInlineStart";
|
|
34
|
+
paddingEnd: "paddingInlineEnd";
|
|
35
|
+
borderStart: "borderInlineStart";
|
|
36
|
+
borderEnd: "borderInlineEnd";
|
|
37
|
+
insetStart: "insetInlineStart";
|
|
38
|
+
insetEnd: "insetInlineEnd";
|
|
39
|
+
start: "insetInlineStart";
|
|
40
|
+
end: "insetInlineEnd";
|
|
41
|
+
textAlign: {
|
|
42
|
+
start: "start";
|
|
43
|
+
end: "end";
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=rtl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rtl.d.ts","sourceRoot":"","sources":["../../src/core/rtl.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAqE,MAAM,OAAO,CAAC;AAI1F,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AAEnD,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,aAAa,CAAC;CAC1B;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,aAAa,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAID,UAAU,eAAe;IACvB,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,KAAK,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;IACxF;;;OAGG;IACH,SAAS,EAAE,CACT,QAAQ,EAAE,aAAa,GAAG,cAAc,GAAG,YAAY,GAAG,aAAa,EACvE,KAAK,EAAE,MAAM,GAAG,MAAM,KACnB,KAAK,CAAC,aAAa,CAAC;CAC1B;AAWD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAgF1D,CAAC;AAMF,wBAAgB,UAAU,IAAI,eAAe,CAE5C;AAID;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;CAexB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sanitizeHtml — lightweight HTML sanitizer for dangerouslySetInnerHTML.
|
|
3
|
+
*
|
|
4
|
+
* Strips known XSS vectors (script tags, event handlers, javascript: URIs)
|
|
5
|
+
* without requiring an external dependency. For full-featured sanitization,
|
|
6
|
+
* consider using DOMPurify.
|
|
7
|
+
*/
|
|
8
|
+
/** Remove <script> tags, event handler attributes, and dangerous URIs from HTML. */
|
|
9
|
+
export declare function sanitizeHtml(html: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Validate a URL for use in href/src attributes.
|
|
12
|
+
* Allows only http:, https:, data:image, blob:, and relative paths.
|
|
13
|
+
* Rejects javascript:, vbscript:, data:text/html, and other dangerous schemes.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isSafeUrl(url: string): boolean;
|
|
16
|
+
//# sourceMappingURL=sanitizeHtml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitizeHtml.d.ts","sourceRoot":"","sources":["../../src/core/sanitizeHtml.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqBjD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAgB9C"}
|