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.
Files changed (78) hide show
  1. package/LICENSE +21 -0
  2. package/dist/elementdrawing.min.js +3 -0
  3. package/dist/elementdrawing.min.js.LICENSE.txt +8 -0
  4. package/dist/elementdrawing.min.js.map +1 -0
  5. package/dist/index.html +1 -0
  6. package/package.json +127 -0
  7. package/src/core/bridge.h +855 -0
  8. package/src/core/diff.c +900 -0
  9. package/src/core/element.c +1078 -0
  10. package/src/core/event.c +813 -0
  11. package/src/core/fiber.c +1027 -0
  12. package/src/core/hooks.c +919 -0
  13. package/src/core/renderer.c +963 -0
  14. package/src/core/scheduler.c +702 -0
  15. package/src/core/state.c +803 -0
  16. package/src/css/animations.css +779 -0
  17. package/src/css/base.css +615 -0
  18. package/src/css/components.css +1311 -0
  19. package/src/css/tailwind.css +370 -0
  20. package/src/css/themes.css +517 -0
  21. package/src/css/utilities.css +475 -0
  22. package/src/index.js +746 -0
  23. package/src/js/animation.js +655 -0
  24. package/src/js/dom.js +665 -0
  25. package/src/js/events.js +585 -0
  26. package/src/js/http.js +446 -0
  27. package/src/js/index.js +26 -0
  28. package/src/js/router.js +483 -0
  29. package/src/js/store.js +539 -0
  30. package/src/js/utils.js +593 -0
  31. package/src/js/validator.js +529 -0
  32. package/src/jsx/components/Accordion.jsx +210 -0
  33. package/src/jsx/components/Alert.jsx +169 -0
  34. package/src/jsx/components/Avatar.jsx +214 -0
  35. package/src/jsx/components/Badge.jsx +136 -0
  36. package/src/jsx/components/Breadcrumb.jsx +200 -0
  37. package/src/jsx/components/Button.jsx +188 -0
  38. package/src/jsx/components/Card.jsx +192 -0
  39. package/src/jsx/components/Carousel.jsx +278 -0
  40. package/src/jsx/components/Checkbox.jsx +215 -0
  41. package/src/jsx/components/Dialog.jsx +242 -0
  42. package/src/jsx/components/Drawer.jsx +190 -0
  43. package/src/jsx/components/Dropdown.jsx +268 -0
  44. package/src/jsx/components/Form.jsx +274 -0
  45. package/src/jsx/components/Input.jsx +285 -0
  46. package/src/jsx/components/Menu.jsx +276 -0
  47. package/src/jsx/components/Modal.jsx +274 -0
  48. package/src/jsx/components/Navbar.jsx +292 -0
  49. package/src/jsx/components/Pagination.jsx +268 -0
  50. package/src/jsx/components/Progress.jsx +252 -0
  51. package/src/jsx/components/Radio.jsx +208 -0
  52. package/src/jsx/components/Select.jsx +397 -0
  53. package/src/jsx/components/Sidebar.jsx +250 -0
  54. package/src/jsx/components/Slider.jsx +310 -0
  55. package/src/jsx/components/Spinner.jsx +198 -0
  56. package/src/jsx/components/Switch.jsx +201 -0
  57. package/src/jsx/components/Table.jsx +332 -0
  58. package/src/jsx/components/Tabs.jsx +227 -0
  59. package/src/jsx/components/Textarea.jsx +212 -0
  60. package/src/jsx/components/Toast.jsx +270 -0
  61. package/src/jsx/components/Tooltip.jsx +178 -0
  62. package/src/jsx/components/Typography.jsx +299 -0
  63. package/src/jsx/components/index.jsx +70 -0
  64. package/src/jsx/core/element.js +3 -0
  65. package/src/jsx/hooks/index.js +356 -0
  66. package/src/jsx/hooks/useCallback.js +472 -0
  67. package/src/jsx/hooks/useContext.js +586 -0
  68. package/src/jsx/hooks/useEffect.js +704 -0
  69. package/src/jsx/hooks/useLayoutEffect.js +508 -0
  70. package/src/jsx/hooks/useMemo.js +689 -0
  71. package/src/jsx/hooks/useReducer.js +729 -0
  72. package/src/jsx/hooks/useRef.js +542 -0
  73. package/src/jsx/hooks/useState.js +854 -0
  74. package/src/jsx/runtime/commit.js +903 -0
  75. package/src/jsx/runtime/createElement.js +860 -0
  76. package/src/jsx/runtime/index.js +356 -0
  77. package/src/jsx/runtime/reconcile.js +687 -0
  78. package/src/jsx/runtime/render.js +914 -0
@@ -0,0 +1,855 @@
1
+ #ifndef ELEMENTDRAWING_BRIDGE_H
2
+ #define ELEMENTDRAWING_BRIDGE_H
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ #include <stdio.h>
9
+ #include <stdlib.h>
10
+ #include <string.h>
11
+ #include <stdint.h>
12
+ #include <stdbool.h>
13
+ #include <stdarg.h>
14
+
15
+ /* ============================================================
16
+ * ElementDrawing C-Core Engine Bridge Header
17
+ * High-performance rendering engine for the ElementDrawing framework
18
+ * ============================================================ */
19
+
20
+ /* ---- Version Information ---- */
21
+ #define ED_VERSION_MAJOR 1
22
+ #define ED_VERSION_MINOR 0
23
+ #define ED_VERSION_PATCH 0
24
+ #define ED_VERSION_STRING "1.0.0"
25
+
26
+ /* ---- Memory Management Constants ---- */
27
+ #define ED_INITIAL_POOL_SIZE (1024 * 1024)
28
+ #define ED_MAX_POOL_SIZE (64 * 1024 * 1024)
29
+ #define ED_POOL_BLOCK_SIZE 4096
30
+ #define ED_GC_THRESHOLD 0.75
31
+ #define ED_GC_INCREMENTAL_STEP 256
32
+ #define ED_WEAK_REF_TABLE_SIZE 1024
33
+ #define ED_STRING_TABLE_SIZE 4096
34
+ #define ED_STRING_CACHE_SIZE 1024
35
+ #define ED_SYMBOL_TABLE_SIZE 2048
36
+
37
+ /* ---- Virtual DOM Constants ---- */
38
+ #define ED_MAX_CHILDREN 65536
39
+ #define ED_MAX_DEPTH 1024
40
+ #define ED_MAX_PROPS 512
41
+ #define ED_MAX_PROP_KEY_LEN 256
42
+ #define ED_MAX_PROP_VALUE_LEN 4096
43
+ #define ED_MAX_TAG_NAME_LEN 128
44
+ #define ED_MAX_TEXT_LEN 1048576
45
+ #define ED_MAX_EVENT_HANDLERS 256
46
+ #define ED_MAX_REF_COUNT 65536
47
+ #define ED_MAX_KEY_LEN 256
48
+
49
+ /* ---- Fiber Constants ---- */
50
+ #define ED_FIBER_POOL_SIZE 4096
51
+ #define ED_FIBER_MAX_SIBLINGS 1024
52
+ #define ED_FIBER_WORK_EXPIRATION 5000
53
+ #define ED_FIBER_PRIORITY_IMMEDIATE 1
54
+ #define ED_FIBER_PRIORITY_USER_BLOCKING 2
55
+ #define ED_FIBER_PRIORITY_NORMAL 3
56
+ #define ED_FIBER_PRIORITY_LOW 4
57
+ #define ED_FIBER_PRIORITY_IDLE 5
58
+
59
+ /* ---- Scheduler Constants ---- */
60
+ #define ED_SCHEDULER_MAX_QUEUE_SIZE 8192
61
+ #define ED_SCHEDULER_MAX_CALLBACKS 2048
62
+ #define ED_SCHEDULER_FRAME_BUDGET 16
63
+ #define ED_SCHEDULER_YIELD_AFTER 5
64
+ #define ED_SCHEDULER_MIN_PRIORITY 1
65
+ #define ED_SCHEDULER_MAX_PRIORITY 5
66
+
67
+ /* ---- Diff/Patch Constants ---- */
68
+ #define ED_DIFF_MAX_OPERATIONS 8192
69
+ #define ED_PATCH_QUEUE_SIZE 4096
70
+ #define ED_DIFF_KEY_CACHE_SIZE 2048
71
+ #define ED_DIFF_MAX_MOVED_NODES 1024
72
+
73
+ /* ---- Rendering Constants ---- */
74
+ #define ED_RENDER_MAX_STYLES 512
75
+ #define ED_RENDER_MAX_CLASSES 256
76
+ #define ED_RENDER_MAX_ATTRIBUTES 256
77
+ #define ED_RENDER_BATCH_SIZE 64
78
+ #define ED_RENDER_FLUSH_INTERVAL 16
79
+
80
+ /* ---- Event Constants ---- */
81
+ #define ED_EVENT_MAX_LISTENERS 4096
82
+ #define ED_EVENT_BUBBLE_DEPTH 64
83
+ #define ED_EVENT_CAPTURE_PHASE 1
84
+ #define ED_EVENT_BUBBLE_PHASE 2
85
+ #define ED_EVENT_DEFAULT_PHASE 3
86
+
87
+ /* ---- Hooks Constants ---- */
88
+ #define ED_HOOKS_MAX_PER_COMPONENT 256
89
+ #define ED_HOOKS_STATE_SLOTS 1024
90
+ #define ED_HOOKS_EFFECT_SLOTS 1024
91
+ #define ED_HOOKS_REF_SLOTS 512
92
+ #define ED_HOOKS_MEMO_SLOTS 512
93
+ #define ED_HOOKS_CALLBACK_SLOTS 512
94
+
95
+ /* ---- Error Codes ---- */
96
+ #define ED_OK 0
97
+ #define ED_ERR_MEMORY -1
98
+ #define ED_ERR_NULL_PTR -2
99
+ #define ED_ERR_INVALID_ARG -3
100
+ #define ED_ERR_OUT_OF_BOUNDS -4
101
+ #define ED_ERR_TYPE_MISMATCH -5
102
+ #define ED_ERR_MAX_DEPTH -6
103
+ #define ED_ERR_MAX_CHILDREN -7
104
+ #define ED_ERR_POOL_EXHAUSTED -8
105
+ #define ED_ERR_GC_FAILED -9
106
+ #define ED_ERR_INVALID_STATE -10
107
+ #define ED_ERR_SCHEDULE_FAILED -11
108
+ #define ED_ERR_DIFF_FAILED -12
109
+ #define ED_ERR_PATCH_FAILED -13
110
+ #define ED_ERR_RENDER_FAILED -14
111
+ #define ED_ERR_EVENT_FAILED -15
112
+ #define ED_ERR_HOOK_VIOLATION -16
113
+
114
+ /* ---- Node Types ---- */
115
+ typedef enum {
116
+ ED_NODE_ELEMENT = 0,
117
+ ED_NODE_TEXT = 1,
118
+ ED_NODE_COMMENT = 2,
119
+ ED_NODE_FRAGMENT = 3,
120
+ ED_NODE_PORTAL = 4,
121
+ ED_NODE_SUSPENSE = 5,
122
+ ED_NODE_LAZY = 6,
123
+ ED_NODE_MEMO = 7,
124
+ ED_NODE_FORWARD_REF = 8,
125
+ ED_NODE_CONTEXT_PROVIDER = 9,
126
+ ED_NODE_CONTEXT_CONSUMER = 10,
127
+ ED_NODE_PROFILER = 11,
128
+ ED_NODE_STRICT_MODE = 12,
129
+ ED_NODE_CONCURRENT_MODE = 13
130
+ } EDNodeType;
131
+
132
+ /* ---- Fiber Tags ---- */
133
+ typedef enum {
134
+ ED_FIBER_HOST_ROOT = 0,
135
+ ED_FIBER_HOST_COMPONENT = 1,
136
+ ED_FIBER_HOST_TEXT = 2,
137
+ ED_FIBER_CLASS_COMPONENT = 3,
138
+ ED_FIBER_FUNCTION_COMPONENT = 4,
139
+ ED_FIBER_INDIRECT_COMPONENT = 5,
140
+ ED_FIBER_CONTEXT_PROVIDER = 6,
141
+ ED_FIBER_CONTEXT_CONSUMER = 7,
142
+ ED_FIBER_FORWARD_REF = 8,
143
+ ED_FIBER_FRAGMENT = 9,
144
+ ED_FIBER_MODE = 10,
145
+ ED_FIBER_PROFILER = 11,
146
+ ED_FIBER_SUSPENSE_COMPONENT = 12,
147
+ ED_FIBER_SUSPENSE_LIST = 13,
148
+ ED_FIBER_MEMO_COMPONENT = 14,
149
+ ED_FIBER_LAZY_COMPONENT = 15,
150
+ ED_FIBER_SCOPE = 16,
151
+ ED_FIBER_OFFSCREEN = 17,
152
+ ED_FIBER_LEGACY_HIDDEN = 18,
153
+ ED_FIBER_CACHE = 19,
154
+ ED_FIBER_TRACING_MARKER = 20
155
+ } EDFiberTag;
156
+
157
+ /* ---- Fiber Flags (bitmask) ---- */
158
+ typedef enum {
159
+ ED_FIBER_FLAG_NONE = 0,
160
+ ED_FIBER_FLAG_PERFORMED_WORK = 1 << 0,
161
+ ED_FIBER_FLAG_PLACEMENT = 1 << 1,
162
+ ED_FIBER_FLAG_UPDATE = 1 << 2,
163
+ ED_FIBER_FLAG_DELETION = 1 << 3,
164
+ ED_FIBER_FLAG_CHILD_DELETION = 1 << 4,
165
+ ED_FIBER_FLAG_REF = 1 << 5,
166
+ ED_FIBER_FLAG_CALLBACK = 1 << 6,
167
+ ED_FIBER_FLAG_DID_CAPTURE = 1 << 7,
168
+ ED_FIBER_FLAG_SHOULD_DELETE = 1 << 8,
169
+ ED_FIBER_FLAG_CONTENT_RESET = 1 << 9,
170
+ ED_FIBER_FLAG_TRIGGERED = 1 << 10,
171
+ ED_FIBER_FLAG_ERRORED = 1 << 11,
172
+ ED_FIBER_FLAG_FORCE_UPDATE = 1 << 12,
173
+ ED_FIBER_FLAG_PASSIVE = 1 << 13,
174
+ ED_FIBER_FLAG_LAYOUT = 1 << 14,
175
+ ED_FIBER_FLAG_HAS_EFFECT = 1 << 15,
176
+ ED_FIBER_FLAG_INCOMPLETE = 1 << 16,
177
+ ED_FIBER_FLAG_SHOULD_SUSPEND = 1 << 17,
178
+ ED_FIBER_FLAG_NEEDS_UPDATE = 1 << 18,
179
+ ED_FIBER_FLAG_MUTATION = 1 << 19,
180
+ ED_FIBER_FLAG_PERSISTED = 1 << 20,
181
+ ED_FIBER_FLAG_HIDDEN = 1 << 21,
182
+ ED_FIBER_FLAG_VISIBLE = 1 << 22,
183
+ ED_FIBER_FLAG_FORKED = 1 << 23,
184
+ ED_FIBER_FLAG_CLONED = 1 << 24,
185
+ ED_FIBER_FLAG_URGENT = 1 << 25,
186
+ ED_FIBER_FLAG_SCHEDULED = 1 << 26,
187
+ ED_FIBER_FLAG_REUSABLE = 1 << 27,
188
+ ED_FIBER_FLAG_WORK_IN_PROGRESS = 1 << 28
189
+ } EDFiberFlags;
190
+
191
+ /* ---- Scheduler Priority ---- */
192
+ typedef enum {
193
+ ED_PRIORITY_IMMEDIATE = 1,
194
+ ED_PRIORITY_USER_BLOCKING = 2,
195
+ ED_PRIORITY_NORMAL = 3,
196
+ ED_PRIORITY_LOW = 4,
197
+ ED_PRIORITY_IDLE = 5
198
+ } EDSchedulerPriority;
199
+
200
+ /* ---- Effect Types ---- */
201
+ typedef enum {
202
+ ED_EFFECT_MUTATION = 0,
203
+ ED_EFFECT_LAYOUT = 1,
204
+ ED_EFFECT_PASSIVE = 2,
205
+ ED_EFFECT_INSERTION = 3
206
+ } EDEffectType;
207
+
208
+ /* ---- Diff Operation Types ---- */
209
+ typedef enum {
210
+ ED_DIFF_NONE = 0,
211
+ ED_DIFF_INSERT = 1,
212
+ ED_DIFF_DELETE = 2,
213
+ ED_DIFF_REPLACE = 3,
214
+ ED_DIFF_UPDATE = 4,
215
+ ED_DIFF_MOVE = 5,
216
+ ED_DIFF_REORDER = 6,
217
+ ED_DIFF_PROP_UPDATE = 7,
218
+ ED_DIFF_PROP_ADD = 8,
219
+ ED_DIFF_PROP_REMOVE = 9,
220
+ ED_DIFF_TEXT_UPDATE = 10
221
+ } EDDiffOpType;
222
+
223
+ /* ---- Patch Operation Types ---- */
224
+ typedef enum {
225
+ ED_PATCH_SET_ATTRIBUTE = 0,
226
+ ED_PATCH_REMOVE_ATTRIBUTE = 1,
227
+ ED_PATCH_SET_STYLE = 2,
228
+ ED_PATCH_REMOVE_STYLE = 3,
229
+ ED_PATCH_ADD_CLASS = 4,
230
+ ED_PATCH_REMOVE_CLASS = 5,
231
+ ED_PATCH_INSERT_CHILD = 6,
232
+ ED_PATCH_REMOVE_CHILD = 7,
233
+ ED_PATCH_REPLACE_CHILD = 8,
234
+ ED_PATCH_MOVE_CHILD = 9,
235
+ ED_PATCH_SET_TEXT = 10,
236
+ ED_PATCH_SET_EVENT = 11,
237
+ ED_PATCH_REMOVE_EVENT = 12,
238
+ ED_PATCH_SET_REF = 13,
239
+ ED_PATCH_REMOVE_REF = 14
240
+ } EDPatchOpType;
241
+
242
+ /* ---- Event Phases ---- */
243
+ typedef enum {
244
+ ED_EVENT_PHASE_NONE = 0,
245
+ ED_EVENT_PHASE_CAPTURE = 1,
246
+ ED_EVENT_PHASE_AT_TARGET = 2,
247
+ ED_EVENT_PHASE_BUBBLE = 3
248
+ } EDEventPhase;
249
+
250
+ /* ---- Hook Types ---- */
251
+ typedef enum {
252
+ ED_HOOK_STATE = 0,
253
+ ED_HOOK_REDUCER = 1,
254
+ ED_HOOK_EFFECT = 2,
255
+ ED_HOOK_LAYOUT_EFFECT = 3,
256
+ ED_HOOK_CALLBACK = 4,
257
+ ED_HOOK_MEMO = 5,
258
+ ED_HOOK_REF = 6,
259
+ ED_HOOK_CONTEXT = 7,
260
+ ED_HOOK_DEBUG_VALUE = 8,
261
+ ED_HOOK_DEFERRED_VALUE = 9,
262
+ ED_HOOK_TRANSITION = 10,
263
+ ED_HOOK_ID = 11,
264
+ ED_HOOK_INSERTION_EFFECT = 12,
265
+ ED_HOOK_SYNC_EXTERNAL_STORE = 13,
266
+ ED_HOOK_USE = 14
267
+ } EDHookType;
268
+
269
+ /* ---- Forward Declarations ---- */
270
+ typedef struct EDVirtualNode EDVirtualNode;
271
+ typedef struct EDVirtualProp EDVirtualProp;
272
+ typedef struct EDFiberNode EDFiberNode;
273
+ typedef struct EDFiberPool EDFiberPool;
274
+ typedef struct EDScheduler EDScheduler;
275
+ typedef struct EDSchedulerTask EDSchedulerTask;
276
+ typedef struct EDDiffResult EDDiffResult;
277
+ typedef struct EDDiffOperation EDDiffOperation;
278
+ typedef struct EDPatchOperation EDPatchOperation;
279
+ typedef struct EDPatchQueue EDPatchQueue;
280
+ typedef struct EDEvent EDEvent;
281
+ typedef struct EDEventListener EDEventListener;
282
+ typedef struct EDEventSystem EDEventSystem;
283
+ typedef struct EDHookNode EDHookNode;
284
+ typedef struct EDHookQueue EDHookQueue;
285
+ typedef struct EDStateNode EDStateNode;
286
+ typedef struct EDStateManager EDStateManager;
287
+ typedef struct EDRenderBatch EDRenderBatch;
288
+ typedef struct EDStringEntry EDStringEntry;
289
+ typedef struct EDPoolBlock EDPoolBlock;
290
+ typedef struct EDMemoryPool EDMemoryPool;
291
+ typedef struct EDWeakRef EDWeakRef;
292
+ typedef struct EDSymbolEntry EDSymbolEntry;
293
+
294
+ /* ---- Property Structure ---- */
295
+ struct EDVirtualProp {
296
+ char key[ED_MAX_PROP_KEY_LEN];
297
+ char value[ED_MAX_PROP_VALUE_LEN];
298
+ uint32_t hash;
299
+ uint8_t type; /* 0=string, 1=number, 2=bool, 3=function, 4=object, 5=array */
300
+ bool is_event;
301
+ bool is_style;
302
+ bool is_class;
303
+ bool is_ref;
304
+ bool is_key;
305
+ bool is_children;
306
+ bool is_dangerous_html;
307
+ EDVirtualProp* next;
308
+ };
309
+
310
+ /* ---- Virtual Node Structure ---- */
311
+ struct EDVirtualNode {
312
+ EDNodeType type;
313
+ char tag[ED_MAX_TAG_NAME_LEN];
314
+ char text[ED_MAX_TEXT_LEN];
315
+ char key[ED_MAX_KEY_LEN];
316
+ uint32_t ref_id;
317
+
318
+ /* Properties */
319
+ EDVirtualProp* props;
320
+ uint32_t prop_count;
321
+
322
+ /* Children */
323
+ EDVirtualNode** children;
324
+ uint32_t child_count;
325
+ uint32_t child_capacity;
326
+
327
+ /* Tree structure */
328
+ EDVirtualNode* parent;
329
+ EDVirtualNode* sibling;
330
+ EDVirtualNode* first_child;
331
+ EDVirtualNode* last_child;
332
+
333
+ /* State */
334
+ uint32_t version;
335
+ uint32_t hash;
336
+ bool is_dirty;
337
+ bool is_committed;
338
+ bool is_suspended;
339
+ bool is_hidden;
340
+
341
+ /* Memory management */
342
+ uint32_t ref_count;
343
+ EDVirtualNode* next_free;
344
+
345
+ /* Component info */
346
+ void* component_instance;
347
+ void* component_state;
348
+ void* context_value;
349
+
350
+ /* Performance tracking */
351
+ uint64_t render_start_time;
352
+ uint64_t render_end_time;
353
+ uint64_t commit_start_time;
354
+ uint64_t commit_end_time;
355
+ };
356
+
357
+ /* ---- Fiber Node Structure ---- */
358
+ struct EDFiberNode {
359
+ EDFiberTag tag;
360
+ EDFiberFlags flags;
361
+ EDSchedulerPriority priority;
362
+
363
+ /* Tree structure */
364
+ EDFiberNode* parent;
365
+ EDFiberNode* child;
366
+ EDFiberNode* sibling;
367
+ EDFiberNode* alternate;
368
+
369
+ /* Work */
370
+ EDVirtualNode* pending_props;
371
+ EDVirtualNode* memoized_props;
372
+ EDVirtualNode* memoized_state;
373
+ EDHookNode* memoized_hooks;
374
+
375
+ /* DOM reference */
376
+ void* state_node;
377
+ void* ref_value;
378
+
379
+ /* Key for reconciliation */
380
+ char key[ED_MAX_KEY_LEN];
381
+ uint32_t key_hash;
382
+
383
+ /* Effect lists */
384
+ EDFiberNode* first_effect;
385
+ EDFiberNode* last_effect;
386
+ EDFiberNode* next_effect;
387
+
388
+ /* Dependency tracking */
389
+ EDFiberNode* dependencies;
390
+ uint32_t lanes;
391
+ uint32_t child_lanes;
392
+
393
+ /* Update queue */
394
+ void* update_queue;
395
+ uint32_t update_count;
396
+
397
+ /* Return node */
398
+ EDFiberNode* return_node;
399
+
400
+ /* Index for sibling tracking */
401
+ int32_t index;
402
+
403
+ /* Scheduling info */
404
+ uint64_t expiration_time;
405
+ uint64_t start_time;
406
+ uint64_t finish_time;
407
+
408
+ /* Error boundary */
409
+ EDFiberNode* error_boundary;
410
+ void* error_boundary_info;
411
+
412
+ /* Offscreen tracking */
413
+ bool is_hidden;
414
+ bool is_offscreen;
415
+
416
+ /* Pool management */
417
+ bool is_active;
418
+ EDFiberNode* next_free;
419
+ };
420
+
421
+ /* ---- Fiber Pool ---- */
422
+ struct EDFiberPool {
423
+ EDFiberNode* nodes;
424
+ EDFiberNode* free_list;
425
+ uint32_t capacity;
426
+ uint32_t used_count;
427
+ uint32_t peak_usage;
428
+ uint32_t alloc_count;
429
+ uint32_t free_count;
430
+ uint32_t reuse_count;
431
+ };
432
+
433
+ /* ---- Scheduler Task ---- */
434
+ struct EDSchedulerTask {
435
+ uint32_t id;
436
+ EDSchedulerPriority priority;
437
+ void (*callback)(void* data);
438
+ void* data;
439
+ uint64_t expiration_time;
440
+ uint64_t start_time;
441
+ bool is_running;
442
+ bool is_cancelled;
443
+ bool is_recurring;
444
+ uint32_t interval_ms;
445
+ EDSchedulerTask* next;
446
+ };
447
+
448
+ /* ---- Scheduler ---- */
449
+ struct EDScheduler {
450
+ EDSchedulerTask* queues[6];
451
+ uint32_t queue_sizes[6];
452
+ uint32_t total_tasks;
453
+ uint32_t completed_tasks;
454
+ uint32_t cancelled_tasks;
455
+ uint64_t frame_start;
456
+ uint64_t frame_deadline;
457
+ bool is_working;
458
+ bool should_yield;
459
+ uint32_t current_priority;
460
+ EDSchedulerTask* current_task;
461
+ uint32_t next_task_id;
462
+ };
463
+
464
+ /* ---- Diff Operation ---- */
465
+ struct EDDiffOperation {
466
+ EDDiffOpType type;
467
+ uint32_t index;
468
+ uint32_t new_index;
469
+ EDVirtualNode* node;
470
+ EDVirtualNode* new_node;
471
+ EDVirtualProp* prop_changes;
472
+ uint32_t prop_change_count;
473
+ EDDiffOperation* next;
474
+ };
475
+
476
+ /* ---- Diff Result ---- */
477
+ struct EDDiffResult {
478
+ EDDiffOperation* operations;
479
+ uint32_t operation_count;
480
+ uint32_t insert_count;
481
+ uint32_t delete_count;
482
+ uint32_t update_count;
483
+ uint32_t move_count;
484
+ uint32_t reorder_count;
485
+ bool has_changes;
486
+ };
487
+
488
+ /* ---- Patch Operation ---- */
489
+ struct EDPatchOperation {
490
+ EDPatchOpType type;
491
+ void* target_node;
492
+ char key[ED_MAX_PROP_KEY_LEN];
493
+ char value[ED_MAX_PROP_VALUE_LEN];
494
+ uint32_t index;
495
+ void* data;
496
+ EDPatchOperation* next;
497
+ };
498
+
499
+ /* ---- Patch Queue ---- */
500
+ struct EDPatchQueue {
501
+ EDPatchOperation* head;
502
+ EDPatchOperation* tail;
503
+ uint32_t count;
504
+ uint32_t capacity;
505
+ };
506
+
507
+ /* ---- Event ---- */
508
+ struct EDEvent {
509
+ char type[64];
510
+ EDEventPhase phase;
511
+ void* target;
512
+ void* current_target;
513
+ bool bubbles;
514
+ bool cancelable;
515
+ bool default_prevented;
516
+ bool propagation_stopped;
517
+ bool immediate_propagation_stopped;
518
+ uint64_t timestamp;
519
+ void* native_event;
520
+ EDEvent* synthetic_parent;
521
+ int32_t event_phase;
522
+ };
523
+
524
+ /* ---- Event Listener ---- */
525
+ struct EDEventListener {
526
+ char event_type[64];
527
+ void (*handler)(EDEvent* event, void* user_data);
528
+ void* user_data;
529
+ bool capture;
530
+ bool passive;
531
+ bool once;
532
+ uint32_t priority;
533
+ EDEventListener* next;
534
+ };
535
+
536
+ /* ---- Event System ---- */
537
+ struct EDEventSystem {
538
+ EDEventListener* listeners[ED_EVENT_MAX_LISTENERS];
539
+ uint32_t listener_counts[ED_EVENT_MAX_LISTENERS];
540
+ void* delegation_root;
541
+ bool is_dispatching;
542
+ uint32_t active_event_count;
543
+ uint64_t total_events_processed;
544
+ EDEvent* current_event;
545
+ };
546
+
547
+ /* ---- Hook Node ---- */
548
+ struct EDHookNode {
549
+ EDHookType type;
550
+ uint32_t index;
551
+ void* memoized_state;
552
+ void* queue;
553
+ void* base_queue;
554
+ EDHookNode* next;
555
+ bool has_effect;
556
+ bool is_layout;
557
+ bool is_passive;
558
+ bool is_insertion;
559
+ void* cleanup;
560
+ void* effect_callback;
561
+ void* deps;
562
+ uint32_t deps_count;
563
+ EDFiberNode* fiber;
564
+ };
565
+
566
+ /* ---- Hook Queue ---- */
567
+ struct EDHookQueue {
568
+ EDHookNode* head;
569
+ EDHookNode* tail;
570
+ uint32_t count;
571
+ };
572
+
573
+ /* ---- State Node ---- */
574
+ struct EDStateNode {
575
+ void* value;
576
+ void* updater;
577
+ uint32_t version;
578
+ uint64_t last_update_time;
579
+ bool is_pending;
580
+ EDStateNode* next;
581
+ };
582
+
583
+ /* ---- State Manager ---- */
584
+ struct EDStateManager {
585
+ EDStateNode* states[ED_HOOKS_STATE_SLOTS];
586
+ uint32_t state_counts[ED_HOOKS_STATE_SLOTS];
587
+ uint32_t total_states;
588
+ uint32_t active_states;
589
+ uint64_t total_updates;
590
+ uint64_t batched_updates;
591
+ bool is_batching;
592
+ void* batch_callback;
593
+ };
594
+
595
+ /* ---- Render Batch ---- */
596
+ struct EDRenderBatch {
597
+ EDPatchOperation* operations;
598
+ uint32_t count;
599
+ uint64_t start_time;
600
+ uint64_t end_time;
601
+ uint32_t dom_writes;
602
+ uint32_t dom_reads;
603
+ EDRenderBatch* next;
604
+ };
605
+
606
+ /* ---- String Interning ---- */
607
+ struct EDStringEntry {
608
+ char* str;
609
+ uint32_t len;
610
+ uint32_t hash;
611
+ uint32_t ref_count;
612
+ EDStringEntry* next;
613
+ };
614
+
615
+ /* ---- Memory Pool Block ---- */
616
+ struct EDPoolBlock {
617
+ uint8_t* data;
618
+ uint32_t size;
619
+ uint32_t used;
620
+ EDPoolBlock* next;
621
+ };
622
+
623
+ /* ---- Memory Pool ---- */
624
+ struct EDMemoryPool {
625
+ EDPoolBlock* blocks;
626
+ uint32_t total_size;
627
+ uint32_t used_size;
628
+ uint32_t peak_usage;
629
+ uint32_t block_count;
630
+ uint32_t alloc_count;
631
+ uint32_t free_count;
632
+ bool is_initialized;
633
+ };
634
+
635
+ /* ---- Weak Reference ---- */
636
+ struct EDWeakRef {
637
+ void* target;
638
+ uint32_t id;
639
+ bool is_alive;
640
+ EDWeakRef* next;
641
+ };
642
+
643
+ /* ---- Symbol Table ---- */
644
+ struct EDSymbolEntry {
645
+ char name[128];
646
+ uint32_t id;
647
+ void* value;
648
+ EDSymbolEntry* next;
649
+ };
650
+
651
+ /* ---- Function Pointer Types ---- */
652
+ typedef void (*EDRenderCallback)(EDVirtualNode* tree, void* context);
653
+ typedef void (*EDCommitCallback)(EDFiberNode* fiber, void* state_node);
654
+ typedef void (*EDReconcileCallback)(EDFiberNode* current, EDFiberNode* work_in_progress);
655
+ typedef void (*EDEffectCallback)(void* effect, void* cleanup);
656
+ typedef void* (*EDStateUpdater)(void* prev_state, void* action);
657
+ typedef bool (*EDShouldUpdateFunc)(EDVirtualNode* prev, EDVirtualNode* next);
658
+ typedef void (*EDErrorHandler)(int error_code, const char* message, void* context);
659
+ typedef void (*EDSchedulerCallback)(void* data);
660
+ typedef void (*EDEventCallback)(EDEvent* event, void* user_data);
661
+ typedef void (*EDHookCallback)(EDHookNode* hook, EDFiberNode* fiber);
662
+ typedef uint64_t (*EDTimestampFunc)(void);
663
+
664
+ /* ---- Global Configuration ---- */
665
+ typedef struct {
666
+ bool concurrent_mode;
667
+ bool strict_mode;
668
+ bool profiler_enabled;
669
+ bool suspense_enabled;
670
+ bool error_boundaries_enabled;
671
+ bool dev_tools_enabled;
672
+ bool trace_updates;
673
+ bool validate_props;
674
+ uint32_t max_render_time_ms;
675
+ uint32_t max_commit_time_ms;
676
+ uint32_t scheduler_frame_budget_ms;
677
+ bool auto_batch_updates;
678
+ bool legacy_context_api;
679
+ EDErrorHandler on_error;
680
+ void* error_context;
681
+ EDTimestampFunc get_timestamp;
682
+ } EDConfiguration;
683
+
684
+ /* ---- API Functions - Virtual DOM ---- */
685
+ EDVirtualNode* ed_vnode_create(EDNodeType type, const char* tag, const char* key);
686
+ void ed_vnode_destroy(EDVirtualNode* node);
687
+ void ed_vnode_add_child(EDVirtualNode* parent, EDVirtualNode* child);
688
+ void ed_vnode_remove_child(EDVirtualNode* parent, EDVirtualNode* child);
689
+ void ed_vnode_insert_child(EDVirtualNode* parent, EDVirtualNode* child, uint32_t index);
690
+ void ed_vnode_replace_child(EDVirtualNode* parent, EDVirtualNode* new_child, EDVirtualNode* old_child);
691
+ void ed_vnode_set_prop(EDVirtualNode* node, const char* key, const char* value, uint8_t type);
692
+ void ed_vnode_remove_prop(EDVirtualNode* node, const char* key);
693
+ EDVirtualProp* ed_vnode_get_prop(EDVirtualNode* node, const char* key);
694
+ void ed_vnode_set_text(EDVirtualNode* node, const char* text);
695
+ void ed_vnode_set_key(EDVirtualNode* node, const char* key);
696
+ uint32_t ed_vnode_hash(EDVirtualNode* node);
697
+ bool ed_vnode_equals(EDVirtualNode* a, EDVirtualNode* b);
698
+ EDVirtualNode* ed_vnode_clone(EDVirtualNode* node);
699
+ void ed_vnode_mark_dirty(EDVirtualNode* node);
700
+ void ed_vnode_clear_dirty(EDVirtualNode* node);
701
+ uint32_t ed_vnode_depth(EDVirtualNode* node);
702
+ uint32_t ed_vnode_count(EDVirtualNode* node);
703
+ void ed_vnode_traverse(EDVirtualNode* node, void (*visitor)(EDVirtualNode*, void*), void* data);
704
+ void ed_vnode_traverse_bfs(EDVirtualNode* node, void (*visitor)(EDVirtualNode*, void*), void* data);
705
+
706
+ /* ---- API Functions - Fiber ---- */
707
+ EDFiberNode* ed_fiber_create(EDFiberTag tag, EDFiberFlags flags);
708
+ void ed_fiber_destroy(EDFiberNode* fiber);
709
+ EDFiberPool* ed_fiber_pool_create(uint32_t capacity);
710
+ void ed_fiber_pool_destroy(EDFiberPool* pool);
711
+ EDFiberNode* ed_fiber_pool_alloc(EDFiberPool* pool);
712
+ void ed_fiber_pool_free(EDFiberPool* pool, EDFiberNode* fiber);
713
+ EDFiberNode* ed_fiber_clone(EDFiberNode* fiber);
714
+ void ed_fiber_add_child(EDFiberNode* parent, EDFiberNode* child);
715
+ void ed_fiber_add_sibling(EDFiberNode* a, EDFiberNode* b);
716
+ void ed_fiber_set_props(EDFiberNode* fiber, EDVirtualNode* props);
717
+ void ed_fiber_set_state(EDFiberNode* fiber, EDVirtualNode* state);
718
+ void ed_fiber_add_effect(EDFiberNode* fiber, EDFiberNode* effect);
719
+ void ed_fiber_add_dependency(EDFiberNode* fiber, EDFiberNode* dep);
720
+ void ed_fiber_set_priority(EDFiberNode* fiber, EDSchedulerPriority priority);
721
+ uint32_t ed_fiber_count_descendants(EDFiberNode* fiber);
722
+ uint32_t ed_fiber_count_effects(EDFiberNode* fiber);
723
+ bool ed_fiber_has_effect(EDFiberNode* fiber, EDFiberFlags flag);
724
+ void ed_fiber_set_flag(EDFiberNode* fiber, EDFiberFlags flag);
725
+ void ed_fiber_clear_flag(EDFiberNode* fiber, EDFiberFlags flag);
726
+
727
+ /* ---- API Functions - Scheduler ---- */
728
+ EDScheduler* ed_scheduler_create(void);
729
+ void ed_scheduler_destroy(EDScheduler* scheduler);
730
+ uint32_t ed_scheduler_schedule(EDScheduler* scheduler, EDSchedulerPriority priority, EDSchedulerCallback callback, void* data);
731
+ bool ed_scheduler_cancel(EDScheduler* scheduler, uint32_t task_id);
732
+ void ed_scheduler_work(EDScheduler* scheduler);
733
+ bool ed_scheduler_should_yield(EDScheduler* scheduler);
734
+ void ed_scheduler_flush_all(EDScheduler* scheduler);
735
+ void ed_scheduler_advance(EDScheduler* scheduler);
736
+ EDSchedulerPriority ed_scheduler_get_current_priority(EDScheduler* scheduler);
737
+ void ed_scheduler_start_profiling(EDScheduler* scheduler);
738
+ void ed_scheduler_stop_profiling(EDScheduler* scheduler);
739
+ uint64_t ed_scheduler_get_frame_deadline(EDScheduler* scheduler);
740
+ uint32_t ed_scheduler_get_pending_count(EDScheduler* scheduler);
741
+
742
+ /* ---- API Functions - Diff ---- */
743
+ EDDiffResult* ed_diff_compute(EDVirtualNode* old_tree, EDVirtualNode* new_tree);
744
+ void ed_diff_result_destroy(EDDiffResult* result);
745
+ EDDiffOperation* ed_diff_operation_create(EDDiffOpType type, uint32_t index);
746
+ void ed_diff_operation_destroy(EDDiffOperation* op);
747
+ uint32_t ed_diff_count_operations(EDDiffResult* result);
748
+ bool ed_diff_has_changes(EDDiffResult* result);
749
+
750
+ /* ---- API Functions - Patch ---- */
751
+ EDPatchQueue* ed_patch_queue_create(uint32_t capacity);
752
+ void ed_patch_queue_destroy(EDPatchQueue* queue);
753
+ void ed_patch_queue_push(EDPatchQueue* queue, EDPatchOperation* op);
754
+ EDPatchOperation* ed_patch_queue_pop(EDPatchQueue* queue);
755
+ void ed_patch_queue_flush(EDPatchQueue* queue);
756
+ uint32_t ed_patch_queue_count(EDPatchQueue* queue);
757
+ bool ed_patch_queue_is_empty(EDPatchQueue* queue);
758
+ void ed_patch_apply(EDPatchOperation* op);
759
+ void ed_patch_apply_all(EDPatchQueue* queue);
760
+
761
+ /* ---- API Functions - Reconciliation ---- */
762
+ EDFiberNode* ed_reconcile_children(EDFiberNode* current, EDFiberNode* work_in_progress);
763
+ void ed_reconcile_child_fibers(EDFiberNode* current, EDFiberNode* work_in_progress, EDVirtualNode* next_children);
764
+ EDFiberNode* ed_reconcile_single_element(EDFiberNode* current, EDFiberNode* work_in_progress, EDVirtualNode* element);
765
+ EDFiberNode* ed_reconcile_single_text(EDFiberNode* current, EDFiberNode* work_in_progress, EDVirtualNode* text);
766
+ EDFiberNode* ed_reconcile_children_array(EDFiberNode* current, EDFiberNode* work_in_progress, EDVirtualNode** next_children, uint32_t count);
767
+ void ed_place_child(EDFiberNode* new_fiber, EDFiberFlags flags, uint32_t index);
768
+ EDFiberNode* ed_update_slot(EDFiberNode* current, uint32_t index, EDVirtualNode* element);
769
+ EDFiberNode* ed_create_child(EDVirtualNode* element, uint32_t index);
770
+ EDFiberNode* ed_use_fiber(EDFiberNode* current, EDVirtualNode* pending_props);
771
+ uint32_t ed_delete_remaining_children(EDFiberNode* current);
772
+
773
+ /* ---- API Functions - Hooks ---- */
774
+ EDHookNode* ed_hook_create(EDHookType type, uint32_t index);
775
+ void ed_hook_destroy(EDHookNode* hook);
776
+ void ed_hook_queue_push(EDHookQueue* queue, EDHookNode* hook);
777
+ EDHookNode* ed_hook_queue_pop(EDHookQueue* queue);
778
+ void ed_hook_set_state(EDHookNode* hook, void* state);
779
+ void* ed_hook_get_state(EDHookNode* hook);
780
+ void ed_hook_set_effect(EDHookNode* hook, void* callback, void* deps, uint32_t deps_count);
781
+ void ed_hook_run_effect(EDHookNode* hook);
782
+ void ed_hook_run_cleanup(EDHookNode* hook);
783
+ bool ed_hook_deps_changed(void* prev_deps, void* next_deps, uint32_t count);
784
+
785
+ /* ---- API Functions - State ---- */
786
+ EDStateManager* ed_state_manager_create(void);
787
+ void ed_state_manager_destroy(EDStateManager* manager);
788
+ EDStateNode* ed_state_create(void* initial_value);
789
+ void ed_state_destroy(EDStateNode* state);
790
+ void ed_state_update(EDStateNode* state, void* new_value);
791
+ void ed_state_batch_update(EDStateManager* manager, EDStateNode** states, void** values, uint32_t count);
792
+ void ed_state_flush_updates(EDStateManager* manager);
793
+ uint32_t ed_state_version(EDStateNode* state);
794
+
795
+ /* ---- API Functions - Event System ---- */
796
+ EDEventSystem* ed_event_system_create(void);
797
+ void ed_event_system_destroy(EDEventSystem* system);
798
+ uint32_t ed_event_add_listener(EDEventSystem* system, const char* event_type, EDEventCallback handler, void* user_data, bool capture);
799
+ bool ed_event_remove_listener(EDEventSystem* system, uint32_t listener_id);
800
+ void ed_event_dispatch(EDEventSystem* system, EDEvent* event);
801
+ EDEvent* ed_event_create(const char* type, bool bubbles, bool cancelable);
802
+ void ed_event_destroy(EDEvent* event);
803
+ void ed_event_stop_propagation(EDEvent* event);
804
+ void ed_event_prevent_default(EDEvent* event);
805
+
806
+ /* ---- API Functions - Renderer ---- */
807
+ int ed_renderer_init(EDConfiguration* config);
808
+ void ed_renderer_shutdown(void);
809
+ EDRenderBatch* ed_renderer_create_batch(void);
810
+ void ed_renderer_destroy_batch(EDRenderBatch* batch);
811
+ void ed_renderer_commit_batch(EDRenderBatch* batch);
812
+ uint32_t ed_renderer_schedule_update(EDFiberNode* fiber, EDSchedulerPriority priority);
813
+ void ed_renderer_process_updates(void);
814
+ void ed_renderer_request_paint(void);
815
+ void ed_renderer_flush_passive_effects(void);
816
+ void ed_renderer_flush_layout_effects(void);
817
+ void ed_renderer_flush_sync(void);
818
+
819
+ /* ---- API Functions - Memory Pool ---- */
820
+ EDMemoryPool* ed_pool_create(uint32_t initial_size);
821
+ void ed_pool_destroy(EDMemoryPool* pool);
822
+ void* ed_pool_alloc(EDMemoryPool* pool, uint32_t size);
823
+ void ed_pool_free(EDMemoryPool* pool, void* ptr);
824
+ void ed_pool_reset(EDMemoryPool* pool);
825
+ uint32_t ed_pool_available(EDMemoryPool* pool);
826
+ void ed_pool_gc(EDMemoryPool* pool);
827
+ uint32_t ed_pool_defragment(EDMemoryPool* pool);
828
+
829
+ /* ---- API Functions - String Interning ---- */
830
+ const char* ed_string_intern(const char* str);
831
+ void ed_string_release(const char* str);
832
+ uint32_t ed_string_hash(const char* str);
833
+ bool ed_string_equals_interned(const char* a, const char* b);
834
+
835
+ /* ---- Utility Functions ---- */
836
+ uint64_t ed_get_timestamp_ms(void);
837
+ uint32_t ed_hash_djb2(const char* str);
838
+ uint32_t ed_hash_fnv1a(const char* str);
839
+ bool ed_str_equals(const char* a, const char* b);
840
+ char* ed_str_duplicate(const char* str);
841
+ uint32_t ed_next_power_of_2(uint32_t n);
842
+ void ed_log_info(const char* format, ...);
843
+ void ed_log_warn(const char* format, ...);
844
+ void ed_log_error(const char* format, ...);
845
+ void ed_log_debug(const char* format, ...);
846
+ const char* ed_version(void);
847
+ const char* ed_node_type_name(EDNodeType type);
848
+ const char* ed_fiber_tag_name(EDFiberTag tag);
849
+ const char* ed_error_message(int error_code);
850
+
851
+ #ifdef __cplusplus
852
+ }
853
+ #endif
854
+
855
+ #endif /* ELEMENTDRAWING_BRIDGE_H */