elementdrawing 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 +21 -0
- package/dist/elementdrawing.min.js +3 -0
- package/dist/elementdrawing.min.js.LICENSE.txt +8 -0
- package/dist/elementdrawing.min.js.map +1 -0
- package/dist/index.html +1 -0
- package/package.json +127 -0
- package/src/core/bridge.h +855 -0
- package/src/core/diff.c +900 -0
- package/src/core/element.c +1078 -0
- package/src/core/event.c +813 -0
- package/src/core/fiber.c +1027 -0
- package/src/core/hooks.c +919 -0
- package/src/core/renderer.c +963 -0
- package/src/core/scheduler.c +702 -0
- package/src/core/state.c +803 -0
- package/src/css/animations.css +779 -0
- package/src/css/base.css +615 -0
- package/src/css/components.css +1311 -0
- package/src/css/tailwind.css +370 -0
- package/src/css/themes.css +517 -0
- package/src/css/utilities.css +475 -0
- package/src/index.js +746 -0
- package/src/js/animation.js +655 -0
- package/src/js/dom.js +665 -0
- package/src/js/events.js +585 -0
- package/src/js/http.js +446 -0
- package/src/js/index.js +26 -0
- package/src/js/router.js +483 -0
- package/src/js/store.js +539 -0
- package/src/js/utils.js +593 -0
- package/src/js/validator.js +529 -0
- package/src/jsx/components/Accordion.jsx +210 -0
- package/src/jsx/components/Alert.jsx +169 -0
- package/src/jsx/components/Avatar.jsx +214 -0
- package/src/jsx/components/Badge.jsx +136 -0
- package/src/jsx/components/Breadcrumb.jsx +200 -0
- package/src/jsx/components/Button.jsx +188 -0
- package/src/jsx/components/Card.jsx +192 -0
- package/src/jsx/components/Carousel.jsx +278 -0
- package/src/jsx/components/Checkbox.jsx +215 -0
- package/src/jsx/components/Dialog.jsx +242 -0
- package/src/jsx/components/Drawer.jsx +190 -0
- package/src/jsx/components/Dropdown.jsx +268 -0
- package/src/jsx/components/Form.jsx +274 -0
- package/src/jsx/components/Input.jsx +285 -0
- package/src/jsx/components/Menu.jsx +276 -0
- package/src/jsx/components/Modal.jsx +274 -0
- package/src/jsx/components/Navbar.jsx +292 -0
- package/src/jsx/components/Pagination.jsx +268 -0
- package/src/jsx/components/Progress.jsx +252 -0
- package/src/jsx/components/Radio.jsx +208 -0
- package/src/jsx/components/Select.jsx +397 -0
- package/src/jsx/components/Sidebar.jsx +250 -0
- package/src/jsx/components/Slider.jsx +310 -0
- package/src/jsx/components/Spinner.jsx +198 -0
- package/src/jsx/components/Switch.jsx +201 -0
- package/src/jsx/components/Table.jsx +332 -0
- package/src/jsx/components/Tabs.jsx +227 -0
- package/src/jsx/components/Textarea.jsx +212 -0
- package/src/jsx/components/Toast.jsx +270 -0
- package/src/jsx/components/Tooltip.jsx +178 -0
- package/src/jsx/components/Typography.jsx +299 -0
- package/src/jsx/components/index.jsx +70 -0
- package/src/jsx/core/element.js +3 -0
- package/src/jsx/hooks/index.js +356 -0
- package/src/jsx/hooks/useCallback.js +472 -0
- package/src/jsx/hooks/useContext.js +586 -0
- package/src/jsx/hooks/useEffect.js +704 -0
- package/src/jsx/hooks/useLayoutEffect.js +508 -0
- package/src/jsx/hooks/useMemo.js +689 -0
- package/src/jsx/hooks/useReducer.js +729 -0
- package/src/jsx/hooks/useRef.js +542 -0
- package/src/jsx/hooks/useState.js +854 -0
- package/src/jsx/runtime/commit.js +903 -0
- package/src/jsx/runtime/createElement.js +860 -0
- package/src/jsx/runtime/index.js +356 -0
- package/src/jsx/runtime/reconcile.js +687 -0
- package/src/jsx/runtime/render.js +914 -0
package/src/index.js
ADDED
|
@@ -0,0 +1,746 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ElementDrawing Framework - Main Entry Point
|
|
3
|
+
* Export everything from the framework, including runtime, hooks,
|
|
4
|
+
* components, utilities, and framework configuration.
|
|
5
|
+
*
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
* @license MIT
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
// ─── Runtime ──────────────────────────────────────────────────────────────────
|
|
13
|
+
|
|
14
|
+
const runtime = require('./jsx/runtime');
|
|
15
|
+
|
|
16
|
+
// Core createElement and render
|
|
17
|
+
const createElement = runtime.createElement;
|
|
18
|
+
const render = runtime.render;
|
|
19
|
+
const Fragment = runtime.Fragment;
|
|
20
|
+
const cloneElement = runtime.cloneElement;
|
|
21
|
+
const createPortal = runtime.createPortal;
|
|
22
|
+
const createSuspense = runtime.createSuspense;
|
|
23
|
+
const createStrictMode = runtime.createStrictMode;
|
|
24
|
+
const createErrorBoundary = runtime.createErrorBoundary;
|
|
25
|
+
const Suspense = runtime.Suspense;
|
|
26
|
+
const StrictMode = runtime.StrictMode;
|
|
27
|
+
const ErrorBoundary = runtime.ErrorBoundary;
|
|
28
|
+
const lazy = runtime.lazy;
|
|
29
|
+
const isValidElement = runtime.isValidElement;
|
|
30
|
+
const isValidElementType = runtime.isValidElementType;
|
|
31
|
+
const isFunctionComponent = runtime.isFunctionComponent;
|
|
32
|
+
const isClassComponent = runtime.isClassComponent;
|
|
33
|
+
const countChildren = runtime.countChildren;
|
|
34
|
+
const mapChildren = runtime.mapChildren;
|
|
35
|
+
const forEachChild = runtime.forEachChild;
|
|
36
|
+
const onlyChild = runtime.onlyChild;
|
|
37
|
+
const mergeProps = runtime.mergeProps;
|
|
38
|
+
|
|
39
|
+
// Render pipeline
|
|
40
|
+
const hydrate = runtime.hydrate;
|
|
41
|
+
const unmountContainer = runtime.unmountContainer;
|
|
42
|
+
const renderApp = runtime.renderApp;
|
|
43
|
+
const unmountApp = runtime.unmountApp;
|
|
44
|
+
|
|
45
|
+
// Runtime management
|
|
46
|
+
const initRuntime = runtime.initRuntime;
|
|
47
|
+
const onRuntimeInit = runtime.onRuntimeInit;
|
|
48
|
+
const isRuntimeInitialized = runtime.isRuntimeInitialized;
|
|
49
|
+
const configureRuntime = runtime.configureRuntime;
|
|
50
|
+
const getRuntimeConfig = runtime.getRuntimeConfig;
|
|
51
|
+
const getRuntimeStats = runtime.getRuntimeStats;
|
|
52
|
+
const registerDevToolsHandler = runtime.registerDevToolsHandler;
|
|
53
|
+
const sendDevToolsMessage = runtime.sendDevToolsMessage;
|
|
54
|
+
|
|
55
|
+
// Internal types
|
|
56
|
+
const REACT_ELEMENT_TYPE = runtime.REACT_ELEMENT_TYPE;
|
|
57
|
+
const REACT_FRAGMENT_TYPE = runtime.REACT_FRAGMENT_TYPE;
|
|
58
|
+
const REACT_PORTAL_TYPE = runtime.REACT_PORTAL_TYPE;
|
|
59
|
+
const REACT_SUSPENSE_TYPE = runtime.REACT_SUSPENSE_TYPE;
|
|
60
|
+
const REACT_LAZY_TYPE = runtime.REACT_LAZY_TYPE;
|
|
61
|
+
const REACT_STRICT_MODE_TYPE = runtime.REACT_STRICT_MODE_TYPE;
|
|
62
|
+
const REACT_ERROR_BOUNDARY_TYPE = runtime.REACT_ERROR_BOUNDARY_TYPE;
|
|
63
|
+
|
|
64
|
+
// ─── Hooks ────────────────────────────────────────────────────────────────────
|
|
65
|
+
|
|
66
|
+
const hooks = require('./jsx/hooks');
|
|
67
|
+
|
|
68
|
+
// Core hooks
|
|
69
|
+
const useState = hooks.useState;
|
|
70
|
+
const useEffect = hooks.useEffect;
|
|
71
|
+
const useContext = hooks.useContext;
|
|
72
|
+
const useReducer = hooks.useReducer;
|
|
73
|
+
const useCallback = hooks.useCallback;
|
|
74
|
+
const useMemo = hooks.useMemo;
|
|
75
|
+
const useRef = hooks.useRef;
|
|
76
|
+
const useLayoutEffect = hooks.useLayoutEffect;
|
|
77
|
+
|
|
78
|
+
// Extended hooks
|
|
79
|
+
const useInsertionEffect = hooks.useInsertionEffect;
|
|
80
|
+
const useIsomorphicLayoutEffect = hooks.useIsomorphicLayoutEffect;
|
|
81
|
+
const useTransition = hooks.useTransition;
|
|
82
|
+
const useDeferredValue = hooks.useDeferredValue;
|
|
83
|
+
const useDebouncedCallback = hooks.useDebouncedCallback;
|
|
84
|
+
const useThrottledCallback = hooks.useThrottledCallback;
|
|
85
|
+
const useOnceCallback = hooks.useOnceCallback;
|
|
86
|
+
const useDeepCompareCallback = hooks.useDeepCompareCallback;
|
|
87
|
+
const useDeepCompareMemo = hooks.useDeepCompareMemo;
|
|
88
|
+
const useDeepCompareEffect = hooks.useDeepCompareEffect;
|
|
89
|
+
const useMemoWith = hooks.useMemoWith;
|
|
90
|
+
const useMemoTTL = hooks.useMemoTTL;
|
|
91
|
+
const useEffectOnce = hooks.useEffectOnce;
|
|
92
|
+
const useUpdateEffect = hooks.useUpdateEffect;
|
|
93
|
+
const usePrevious = hooks.usePrevious;
|
|
94
|
+
const usePreviousWithInit = hooks.usePreviousWithInit;
|
|
95
|
+
const useMutationObserver = hooks.useMutationObserver;
|
|
96
|
+
const useResizeObserver = hooks.useResizeObserver;
|
|
97
|
+
const useAutoFocus = hooks.useAutoFocus;
|
|
98
|
+
const useContextSelector = hooks.useContextSelector;
|
|
99
|
+
const useContextObserver = hooks.useContextObserver;
|
|
100
|
+
|
|
101
|
+
// Context API
|
|
102
|
+
const createContext = hooks.createContext;
|
|
103
|
+
const useMergedContext = hooks.useMergedContext;
|
|
104
|
+
const composeContexts = hooks.composeContexts;
|
|
105
|
+
|
|
106
|
+
// Ref utilities
|
|
107
|
+
const createRef = hooks.createRef;
|
|
108
|
+
const useCallbackRef = hooks.useCallbackRef;
|
|
109
|
+
const forwardRef = hooks.forwardRef;
|
|
110
|
+
const isForwardRef = hooks.isForwardRef;
|
|
111
|
+
const useMergedRefs = hooks.useMergedRefs;
|
|
112
|
+
const useMeasureRef = hooks.useMeasureRef;
|
|
113
|
+
const useInViewRef = hooks.useInViewRef;
|
|
114
|
+
const useFocusRef = hooks.useFocusRef;
|
|
115
|
+
const useScrollRef = hooks.useScrollRef;
|
|
116
|
+
|
|
117
|
+
// Batching
|
|
118
|
+
const batchedUpdates = hooks.batchedUpdates;
|
|
119
|
+
const batchDispatches = hooks.batchDispatches;
|
|
120
|
+
const runWithPriority = hooks.runWithPriority;
|
|
121
|
+
const startTransition = hooks.startTransition;
|
|
122
|
+
|
|
123
|
+
// State comparison
|
|
124
|
+
const deepEqual = hooks.deepEqual;
|
|
125
|
+
const shallowEqual = hooks.shallowEqual;
|
|
126
|
+
const areDepsEqual = hooks.areDepsEqual;
|
|
127
|
+
const areDepsDeepEqual = hooks.areDepsDeepEqual;
|
|
128
|
+
|
|
129
|
+
// Framework integration
|
|
130
|
+
const setCurrentComponent = hooks.setCurrentComponent;
|
|
131
|
+
const resetHookIndex = hooks.resetHookIndex;
|
|
132
|
+
const cleanupComponent = hooks.cleanupComponent;
|
|
133
|
+
const flushAllEffects = hooks.flushAllEffects;
|
|
134
|
+
const postRenderProcess = hooks.postRenderProcess;
|
|
135
|
+
|
|
136
|
+
// Development tools
|
|
137
|
+
const registerDevTools = hooks.registerDevTools;
|
|
138
|
+
const setHookValidation = hooks.setHookValidation;
|
|
139
|
+
const validateHookOrder = hooks.validateHookOrder;
|
|
140
|
+
const setProfiling = hooks.setProfiling;
|
|
141
|
+
const getComponentProfile = hooks.getComponentProfile;
|
|
142
|
+
const setStrictMode = hooks.setStrictMode;
|
|
143
|
+
const isInStrictMode = hooks.isInStrictMode;
|
|
144
|
+
const cancelEffect = hooks.cancelEffect;
|
|
145
|
+
const getContextVersion = hooks.getContextVersion;
|
|
146
|
+
const getPendingEffectCounts = hooks.getPendingEffectCounts;
|
|
147
|
+
|
|
148
|
+
// Constants
|
|
149
|
+
const PRIORITY = hooks.PRIORITY;
|
|
150
|
+
const LAYOUT_PRIORITY = hooks.LAYOUT_PRIORITY;
|
|
151
|
+
|
|
152
|
+
// Persistence
|
|
153
|
+
const configurePersistence = hooks.configurePersistence;
|
|
154
|
+
|
|
155
|
+
// Middleware
|
|
156
|
+
const createLoggerMiddleware = hooks.createLoggerMiddleware;
|
|
157
|
+
const createValidationMiddleware = hooks.createValidationMiddleware;
|
|
158
|
+
const createTransformMiddleware = hooks.createTransformMiddleware;
|
|
159
|
+
const createThrottleMiddleware = hooks.createThrottleMiddleware;
|
|
160
|
+
const createActionCreators = hooks.createActionCreators;
|
|
161
|
+
const createAction = hooks.createAction;
|
|
162
|
+
|
|
163
|
+
// Memo invalidation
|
|
164
|
+
const invalidateMemo = hooks.invalidateMemo;
|
|
165
|
+
const invalidateAllMemos = hooks.invalidateAllMemos;
|
|
166
|
+
|
|
167
|
+
// ─── Components ───────────────────────────────────────────────────────────────
|
|
168
|
+
|
|
169
|
+
const components = require('./jsx/components');
|
|
170
|
+
|
|
171
|
+
const Button = components.Button;
|
|
172
|
+
const Card = components.Card;
|
|
173
|
+
const Modal = components.Modal;
|
|
174
|
+
const Input = components.Input;
|
|
175
|
+
const Table = components.Table;
|
|
176
|
+
const Navbar = components.Navbar;
|
|
177
|
+
const Sidebar = components.Sidebar;
|
|
178
|
+
const Form = components.Form;
|
|
179
|
+
const Tabs = components.Tabs;
|
|
180
|
+
const Accordion = components.Accordion;
|
|
181
|
+
const Alert = components.Alert;
|
|
182
|
+
const Avatar = components.Avatar;
|
|
183
|
+
const Badge = components.Badge;
|
|
184
|
+
const Breadcrumb = components.Breadcrumb;
|
|
185
|
+
const Carousel = components.Carousel;
|
|
186
|
+
const Checkbox = components.Checkbox;
|
|
187
|
+
const Dialog = components.Dialog;
|
|
188
|
+
const Drawer = components.Drawer;
|
|
189
|
+
const Dropdown = components.Dropdown;
|
|
190
|
+
const Menu = components.Menu;
|
|
191
|
+
const Pagination = components.Pagination;
|
|
192
|
+
const Progress = components.Progress;
|
|
193
|
+
const Radio = components.Radio;
|
|
194
|
+
const Select = components.Select;
|
|
195
|
+
const Slider = components.Slider;
|
|
196
|
+
const Spinner = components.Spinner;
|
|
197
|
+
const Switch = components.Switch;
|
|
198
|
+
const Textarea = components.Textarea;
|
|
199
|
+
const Toast = components.Toast;
|
|
200
|
+
const Tooltip = components.Tooltip;
|
|
201
|
+
const Typography = components.Typography;
|
|
202
|
+
|
|
203
|
+
// ─── DOM Utilities ────────────────────────────────────────────────────────────
|
|
204
|
+
|
|
205
|
+
const dom = require('./js/dom');
|
|
206
|
+
|
|
207
|
+
// ─── Event Utilities ──────────────────────────────────────────────────────────
|
|
208
|
+
|
|
209
|
+
const events = require('./js/events');
|
|
210
|
+
|
|
211
|
+
// ─── General Utilities ────────────────────────────────────────────────────────
|
|
212
|
+
|
|
213
|
+
const utils = require('./js/utils');
|
|
214
|
+
|
|
215
|
+
// ─── Animation Utilities ──────────────────────────────────────────────────────
|
|
216
|
+
|
|
217
|
+
const animation = require('./js/animation');
|
|
218
|
+
|
|
219
|
+
// ─── HTTP Client ──────────────────────────────────────────────────────────────
|
|
220
|
+
|
|
221
|
+
const http = require('./js/http');
|
|
222
|
+
|
|
223
|
+
// ─── Router ───────────────────────────────────────────────────────────────────
|
|
224
|
+
|
|
225
|
+
const router = require('./js/router');
|
|
226
|
+
|
|
227
|
+
// ─── Store ────────────────────────────────────────────────────────────────────
|
|
228
|
+
|
|
229
|
+
const store = require('./js/store');
|
|
230
|
+
|
|
231
|
+
// ─── Validator ────────────────────────────────────────────────────────────────
|
|
232
|
+
|
|
233
|
+
const validator = require('./js/validator');
|
|
234
|
+
|
|
235
|
+
// ─── Version ──────────────────────────────────────────────────────────────────
|
|
236
|
+
|
|
237
|
+
const VERSION = '1.0.0';
|
|
238
|
+
|
|
239
|
+
// ─── Framework Configuration ─────────────────────────────────────────────────
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Default framework configuration.
|
|
243
|
+
* @type {Object}
|
|
244
|
+
*/
|
|
245
|
+
const defaultConfig = {
|
|
246
|
+
version: VERSION,
|
|
247
|
+
strictMode: false,
|
|
248
|
+
profiling: false,
|
|
249
|
+
concurrentMode: false,
|
|
250
|
+
eventDelegation: true,
|
|
251
|
+
hydration: false,
|
|
252
|
+
devTools: false,
|
|
253
|
+
errorBoundaries: true,
|
|
254
|
+
suspense: true,
|
|
255
|
+
theme: 'light',
|
|
256
|
+
locale: 'en-US',
|
|
257
|
+
debug: false,
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Current framework configuration.
|
|
262
|
+
* @type {Object}
|
|
263
|
+
*/
|
|
264
|
+
let frameworkConfig = Object.assign({}, defaultConfig);
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Configure the ElementDrawing framework.
|
|
268
|
+
* @param {Object} config - Configuration options
|
|
269
|
+
* @returns {Object} The updated configuration
|
|
270
|
+
*/
|
|
271
|
+
function configure(config) {
|
|
272
|
+
frameworkConfig = Object.assign({}, frameworkConfig, config);
|
|
273
|
+
|
|
274
|
+
// Apply configuration to runtime
|
|
275
|
+
if (config.strictMode !== undefined || config.profiling !== undefined ||
|
|
276
|
+
config.concurrentMode !== undefined || config.devTools !== undefined) {
|
|
277
|
+
configureRuntime({
|
|
278
|
+
strictMode: config.strictMode,
|
|
279
|
+
profiling: config.profiling,
|
|
280
|
+
concurrentMode: config.concurrentMode,
|
|
281
|
+
devTools: config.devTools,
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Apply hook strict mode
|
|
286
|
+
if (config.strictMode !== undefined) {
|
|
287
|
+
setStrictMode(config.strictMode);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return Object.assign({}, frameworkConfig);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Get the current framework configuration.
|
|
295
|
+
* @returns {Object} A copy of the current configuration
|
|
296
|
+
*/
|
|
297
|
+
function getConfig() {
|
|
298
|
+
return Object.assign({}, frameworkConfig);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Reset framework configuration to defaults.
|
|
303
|
+
* @returns {Object} The default configuration
|
|
304
|
+
*/
|
|
305
|
+
function resetConfig() {
|
|
306
|
+
frameworkConfig = Object.assign({}, defaultConfig);
|
|
307
|
+
return Object.assign({}, frameworkConfig);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// ─── Component Registration ──────────────────────────────────────────────────
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Registry of custom components that can be registered at runtime.
|
|
314
|
+
* @type {Map<string, Function>}
|
|
315
|
+
*/
|
|
316
|
+
const componentRegistry = new Map();
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Register a custom component with the framework.
|
|
320
|
+
* @param {string} name - Component name
|
|
321
|
+
* @param {Function} component - Component function/class
|
|
322
|
+
* @returns {boolean} True if registration was successful
|
|
323
|
+
*/
|
|
324
|
+
function registerComponent(name, component) {
|
|
325
|
+
if (typeof name !== 'string' || name.trim() === '') {
|
|
326
|
+
console.error('[ElementDrawing] Component name must be a non-empty string');
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
if (typeof component !== 'function') {
|
|
330
|
+
console.error('[ElementDrawing] Component must be a function or class');
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
componentRegistry.set(name, component);
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Unregister a previously registered custom component.
|
|
339
|
+
* @param {string} name - Component name to unregister
|
|
340
|
+
* @returns {boolean} True if the component was found and removed
|
|
341
|
+
*/
|
|
342
|
+
function unregisterComponent(name) {
|
|
343
|
+
return componentRegistry.delete(name);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Get a registered custom component by name.
|
|
348
|
+
* @param {string} name - Component name
|
|
349
|
+
* @returns {Function|undefined}
|
|
350
|
+
*/
|
|
351
|
+
function getRegisteredComponent(name) {
|
|
352
|
+
return componentRegistry.get(name);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Get all registered custom component names.
|
|
357
|
+
* @returns {string[]}
|
|
358
|
+
*/
|
|
359
|
+
function getRegisteredComponents() {
|
|
360
|
+
return Array.from(componentRegistry.keys());
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// ─── Plugin System ────────────────────────────────────────────────────────────
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Registry of installed plugins.
|
|
367
|
+
* @type {Map<string, Object>}
|
|
368
|
+
*/
|
|
369
|
+
const pluginRegistry = new Map();
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Install a plugin into the framework.
|
|
373
|
+
* A plugin is an object with an `install` method that receives the framework.
|
|
374
|
+
* @param {Object} plugin - Plugin object with install method
|
|
375
|
+
* @param {Object} [options] - Plugin options
|
|
376
|
+
* @returns {boolean} True if installation was successful
|
|
377
|
+
*/
|
|
378
|
+
function usePlugin(plugin, options) {
|
|
379
|
+
if (!plugin || typeof plugin.install !== 'function') {
|
|
380
|
+
console.error('[ElementDrawing] Plugin must have an install method');
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const name = plugin.name || 'anonymous';
|
|
385
|
+
|
|
386
|
+
if (pluginRegistry.has(name)) {
|
|
387
|
+
console.warn('[ElementDrawing] Plugin "' + name + '" is already installed');
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
try {
|
|
392
|
+
const api = {
|
|
393
|
+
createElement,
|
|
394
|
+
render,
|
|
395
|
+
Fragment,
|
|
396
|
+
useState,
|
|
397
|
+
useEffect,
|
|
398
|
+
useContext,
|
|
399
|
+
useReducer,
|
|
400
|
+
useCallback,
|
|
401
|
+
useMemo,
|
|
402
|
+
useRef,
|
|
403
|
+
useLayoutEffect,
|
|
404
|
+
createContext,
|
|
405
|
+
registerComponent,
|
|
406
|
+
configure,
|
|
407
|
+
VERSION,
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
plugin.install(api, options);
|
|
411
|
+
pluginRegistry.set(name, { plugin, options });
|
|
412
|
+
return true;
|
|
413
|
+
} catch (error) {
|
|
414
|
+
console.error('[ElementDrawing] Plugin "' + name + '" installation failed:', error);
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Uninstall a previously installed plugin.
|
|
421
|
+
* @param {string} name - Plugin name
|
|
422
|
+
* @returns {boolean} True if the plugin was found and removed
|
|
423
|
+
*/
|
|
424
|
+
function uninstallPlugin(name) {
|
|
425
|
+
const entry = pluginRegistry.get(name);
|
|
426
|
+
if (!entry) return false;
|
|
427
|
+
|
|
428
|
+
if (typeof entry.plugin.uninstall === 'function') {
|
|
429
|
+
try {
|
|
430
|
+
entry.plugin.uninstall();
|
|
431
|
+
} catch (error) {
|
|
432
|
+
console.error('[ElementDrawing] Plugin "' + name + '" uninstall failed:', error);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
return pluginRegistry.delete(name);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Check if a plugin is installed.
|
|
441
|
+
* @param {string} name - Plugin name
|
|
442
|
+
* @returns {boolean}
|
|
443
|
+
*/
|
|
444
|
+
function isPluginInstalled(name) {
|
|
445
|
+
return pluginRegistry.has(name);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// ─── Global Error Handler ────────────────────────────────────────────────────
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Global error handler for the framework.
|
|
452
|
+
* @type {Function|null}
|
|
453
|
+
*/
|
|
454
|
+
let globalErrorHandler = null;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Set a global error handler for uncaught framework errors.
|
|
458
|
+
* @param {Function} handler - Error handler function (error) => void
|
|
459
|
+
*/
|
|
460
|
+
function setErrorHandler(handler) {
|
|
461
|
+
if (typeof handler === 'function') {
|
|
462
|
+
globalErrorHandler = handler;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Handle a framework error.
|
|
468
|
+
* @param {Error} error - The error to handle
|
|
469
|
+
* @param {string} [source] - Error source context
|
|
470
|
+
*/
|
|
471
|
+
function handleError(error, source) {
|
|
472
|
+
if (globalErrorHandler) {
|
|
473
|
+
try {
|
|
474
|
+
globalErrorHandler(error, source);
|
|
475
|
+
} catch (handlerError) {
|
|
476
|
+
console.error('[ElementDrawing] Error handler failed:', handlerError);
|
|
477
|
+
console.error('[ElementDrawing] Original error:', error);
|
|
478
|
+
}
|
|
479
|
+
} else {
|
|
480
|
+
console.error('[ElementDrawing]' + (source ? ' (' + source + ')' : '') + ':', error);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// ─── Debug Mode ───────────────────────────────────────────────────────────────
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Enable or disable debug mode.
|
|
488
|
+
* @param {boolean} enabled
|
|
489
|
+
*/
|
|
490
|
+
function setDebugMode(enabled) {
|
|
491
|
+
frameworkConfig.debug = !!enabled;
|
|
492
|
+
if (enabled) {
|
|
493
|
+
console.log('[ElementDrawing] Debug mode enabled (v' + VERSION + ')');
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Check if debug mode is enabled.
|
|
499
|
+
* @returns {boolean}
|
|
500
|
+
*/
|
|
501
|
+
function isDebugMode() {
|
|
502
|
+
return !!frameworkConfig.debug;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// ─── Framework Info ───────────────────────────────────────────────────────────
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Get comprehensive framework information.
|
|
509
|
+
* @returns {Object}
|
|
510
|
+
*/
|
|
511
|
+
function getFrameworkInfo() {
|
|
512
|
+
return {
|
|
513
|
+
name: 'ElementDrawing',
|
|
514
|
+
version: VERSION,
|
|
515
|
+
config: Object.assign({}, frameworkConfig),
|
|
516
|
+
runtime: getRuntimeStats(),
|
|
517
|
+
registeredComponents: getRegisteredComponents(),
|
|
518
|
+
installedPlugins: Array.from(pluginRegistry.keys()),
|
|
519
|
+
initialized: isRuntimeInitialized(),
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// ─── Exports ──────────────────────────────────────────────────────────────────
|
|
524
|
+
|
|
525
|
+
module.exports = {
|
|
526
|
+
// ── Version ──
|
|
527
|
+
VERSION,
|
|
528
|
+
|
|
529
|
+
// ── Runtime: createElement & render ──
|
|
530
|
+
createElement,
|
|
531
|
+
render,
|
|
532
|
+
Fragment,
|
|
533
|
+
cloneElement,
|
|
534
|
+
createPortal,
|
|
535
|
+
createSuspense,
|
|
536
|
+
createStrictMode,
|
|
537
|
+
createErrorBoundary,
|
|
538
|
+
Suspense,
|
|
539
|
+
StrictMode,
|
|
540
|
+
ErrorBoundary,
|
|
541
|
+
lazy,
|
|
542
|
+
isValidElement,
|
|
543
|
+
isValidElementType,
|
|
544
|
+
isFunctionComponent,
|
|
545
|
+
isClassComponent,
|
|
546
|
+
countChildren,
|
|
547
|
+
mapChildren,
|
|
548
|
+
forEachChild,
|
|
549
|
+
onlyChild,
|
|
550
|
+
mergeProps,
|
|
551
|
+
|
|
552
|
+
// ── Runtime: render pipeline ──
|
|
553
|
+
hydrate,
|
|
554
|
+
unmountContainer,
|
|
555
|
+
renderApp,
|
|
556
|
+
unmountApp,
|
|
557
|
+
|
|
558
|
+
// ── Runtime: management ──
|
|
559
|
+
initRuntime,
|
|
560
|
+
onRuntimeInit,
|
|
561
|
+
isRuntimeInitialized,
|
|
562
|
+
configureRuntime,
|
|
563
|
+
getRuntimeConfig,
|
|
564
|
+
getRuntimeStats,
|
|
565
|
+
registerDevToolsHandler,
|
|
566
|
+
sendDevToolsMessage,
|
|
567
|
+
|
|
568
|
+
// ── Runtime: internal types ──
|
|
569
|
+
REACT_ELEMENT_TYPE,
|
|
570
|
+
REACT_FRAGMENT_TYPE,
|
|
571
|
+
REACT_PORTAL_TYPE,
|
|
572
|
+
REACT_SUSPENSE_TYPE,
|
|
573
|
+
REACT_LAZY_TYPE,
|
|
574
|
+
REACT_STRICT_MODE_TYPE,
|
|
575
|
+
REACT_ERROR_BOUNDARY_TYPE,
|
|
576
|
+
|
|
577
|
+
// ── Hooks: core ──
|
|
578
|
+
useState,
|
|
579
|
+
useEffect,
|
|
580
|
+
useContext,
|
|
581
|
+
useReducer,
|
|
582
|
+
useCallback,
|
|
583
|
+
useMemo,
|
|
584
|
+
useRef,
|
|
585
|
+
useLayoutEffect,
|
|
586
|
+
|
|
587
|
+
// ── Hooks: extended ──
|
|
588
|
+
useInsertionEffect,
|
|
589
|
+
useIsomorphicLayoutEffect,
|
|
590
|
+
useTransition,
|
|
591
|
+
useDeferredValue,
|
|
592
|
+
useDebouncedCallback,
|
|
593
|
+
useThrottledCallback,
|
|
594
|
+
useOnceCallback,
|
|
595
|
+
useDeepCompareCallback,
|
|
596
|
+
useDeepCompareMemo,
|
|
597
|
+
useDeepCompareEffect,
|
|
598
|
+
useMemoWith,
|
|
599
|
+
useMemoTTL,
|
|
600
|
+
useEffectOnce,
|
|
601
|
+
useUpdateEffect,
|
|
602
|
+
usePrevious,
|
|
603
|
+
usePreviousWithInit,
|
|
604
|
+
useMutationObserver,
|
|
605
|
+
useResizeObserver,
|
|
606
|
+
useAutoFocus,
|
|
607
|
+
useContextSelector,
|
|
608
|
+
useContextObserver,
|
|
609
|
+
|
|
610
|
+
// ── Hooks: context API ──
|
|
611
|
+
createContext,
|
|
612
|
+
useMergedContext,
|
|
613
|
+
composeContexts,
|
|
614
|
+
|
|
615
|
+
// ── Hooks: ref utilities ──
|
|
616
|
+
createRef,
|
|
617
|
+
useCallbackRef,
|
|
618
|
+
forwardRef,
|
|
619
|
+
isForwardRef,
|
|
620
|
+
useMergedRefs,
|
|
621
|
+
useMeasureRef,
|
|
622
|
+
useInViewRef,
|
|
623
|
+
useFocusRef,
|
|
624
|
+
useScrollRef,
|
|
625
|
+
|
|
626
|
+
// ── Hooks: batching ──
|
|
627
|
+
batchedUpdates,
|
|
628
|
+
batchDispatches,
|
|
629
|
+
runWithPriority,
|
|
630
|
+
startTransition,
|
|
631
|
+
|
|
632
|
+
// ── Hooks: state comparison ──
|
|
633
|
+
deepEqual,
|
|
634
|
+
shallowEqual,
|
|
635
|
+
areDepsEqual,
|
|
636
|
+
areDepsDeepEqual,
|
|
637
|
+
|
|
638
|
+
// ── Hooks: framework integration ──
|
|
639
|
+
setCurrentComponent,
|
|
640
|
+
resetHookIndex,
|
|
641
|
+
cleanupComponent,
|
|
642
|
+
flushAllEffects,
|
|
643
|
+
postRenderProcess,
|
|
644
|
+
|
|
645
|
+
// ── Hooks: development tools ──
|
|
646
|
+
registerDevTools,
|
|
647
|
+
setHookValidation,
|
|
648
|
+
validateHookOrder,
|
|
649
|
+
setProfiling,
|
|
650
|
+
getComponentProfile,
|
|
651
|
+
setStrictMode,
|
|
652
|
+
isInStrictMode,
|
|
653
|
+
cancelEffect,
|
|
654
|
+
getContextVersion,
|
|
655
|
+
getPendingEffectCounts,
|
|
656
|
+
|
|
657
|
+
// ── Hooks: constants ──
|
|
658
|
+
PRIORITY,
|
|
659
|
+
LAYOUT_PRIORITY,
|
|
660
|
+
|
|
661
|
+
// ── Hooks: persistence ──
|
|
662
|
+
configurePersistence,
|
|
663
|
+
|
|
664
|
+
// ── Hooks: middleware ──
|
|
665
|
+
createLoggerMiddleware,
|
|
666
|
+
createValidationMiddleware,
|
|
667
|
+
createTransformMiddleware,
|
|
668
|
+
createThrottleMiddleware,
|
|
669
|
+
createActionCreators,
|
|
670
|
+
createAction,
|
|
671
|
+
|
|
672
|
+
// ── Hooks: memo invalidation ──
|
|
673
|
+
invalidateMemo,
|
|
674
|
+
invalidateAllMemos,
|
|
675
|
+
|
|
676
|
+
// ── Components ──
|
|
677
|
+
Button,
|
|
678
|
+
Card,
|
|
679
|
+
Modal,
|
|
680
|
+
Input,
|
|
681
|
+
Table,
|
|
682
|
+
Navbar,
|
|
683
|
+
Sidebar,
|
|
684
|
+
Form,
|
|
685
|
+
Tabs,
|
|
686
|
+
Accordion,
|
|
687
|
+
Alert,
|
|
688
|
+
Avatar,
|
|
689
|
+
Badge,
|
|
690
|
+
Breadcrumb,
|
|
691
|
+
Carousel,
|
|
692
|
+
Checkbox,
|
|
693
|
+
Dialog,
|
|
694
|
+
Drawer,
|
|
695
|
+
Dropdown,
|
|
696
|
+
Menu,
|
|
697
|
+
Pagination,
|
|
698
|
+
Progress,
|
|
699
|
+
Radio,
|
|
700
|
+
Select,
|
|
701
|
+
Slider,
|
|
702
|
+
Spinner,
|
|
703
|
+
Switch,
|
|
704
|
+
Textarea,
|
|
705
|
+
Toast,
|
|
706
|
+
Tooltip,
|
|
707
|
+
Typography,
|
|
708
|
+
|
|
709
|
+
// ── Utility Modules ──
|
|
710
|
+
dom,
|
|
711
|
+
events,
|
|
712
|
+
utils,
|
|
713
|
+
animation,
|
|
714
|
+
http,
|
|
715
|
+
router,
|
|
716
|
+
store,
|
|
717
|
+
validator,
|
|
718
|
+
|
|
719
|
+
// ── Framework Configuration ──
|
|
720
|
+
configure,
|
|
721
|
+
getConfig,
|
|
722
|
+
resetConfig,
|
|
723
|
+
defaultConfig,
|
|
724
|
+
|
|
725
|
+
// ── Component Registration ──
|
|
726
|
+
registerComponent,
|
|
727
|
+
unregisterComponent,
|
|
728
|
+
getRegisteredComponent,
|
|
729
|
+
getRegisteredComponents,
|
|
730
|
+
|
|
731
|
+
// ── Plugin System ──
|
|
732
|
+
usePlugin,
|
|
733
|
+
uninstallPlugin,
|
|
734
|
+
isPluginInstalled,
|
|
735
|
+
|
|
736
|
+
// ── Error Handling ──
|
|
737
|
+
setErrorHandler,
|
|
738
|
+
handleError,
|
|
739
|
+
|
|
740
|
+
// ── Debug Mode ──
|
|
741
|
+
setDebugMode,
|
|
742
|
+
isDebugMode,
|
|
743
|
+
|
|
744
|
+
// ── Framework Info ──
|
|
745
|
+
getFrameworkInfo,
|
|
746
|
+
};
|