onejs-react 0.1.7 → 0.1.8
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/package.json +1 -1
- package/src/host-config.ts +5 -33
package/package.json
CHANGED
package/src/host-config.ts
CHANGED
|
@@ -12,12 +12,6 @@ declare function clearTimeout(id: number): void;
|
|
|
12
12
|
|
|
13
13
|
declare const console: { log: (...args: unknown[]) => void; error: (...args: unknown[]) => void };
|
|
14
14
|
|
|
15
|
-
// Native delegate callback helpers (from QuickJSBootstrap __csHelpers)
|
|
16
|
-
declare const __csHelpers: {
|
|
17
|
-
createDelegateCallback(fn: Function): number;
|
|
18
|
-
freeDelegateCallback(handle: number): void;
|
|
19
|
-
[key: string]: unknown;
|
|
20
|
-
};
|
|
21
15
|
|
|
22
16
|
// Priority constants from react-reconciler/constants
|
|
23
17
|
// These match React's internal lane priorities
|
|
@@ -156,8 +150,6 @@ export interface Instance {
|
|
|
156
150
|
hasMixedContent?: boolean;
|
|
157
151
|
// For vector drawing: track the current generateVisualContent callback
|
|
158
152
|
visualContentCallback?: GenerateVisualContentCallback;
|
|
159
|
-
// Native callback handle for the above (used to free slot on replacement)
|
|
160
|
-
visualContentCallbackHandle?: number;
|
|
161
153
|
}
|
|
162
154
|
|
|
163
155
|
export type TextInstance = Instance; // For Label elements with text content
|
|
@@ -444,14 +436,6 @@ function untrackParent(child: CSObject) {
|
|
|
444
436
|
}
|
|
445
437
|
}
|
|
446
438
|
|
|
447
|
-
// Free native callback handles tracked on an instance (prevents callback table leak)
|
|
448
|
-
function cleanupCallbackHandles(instance: Instance) {
|
|
449
|
-
if (instance.visualContentCallbackHandle !== undefined) {
|
|
450
|
-
__csHelpers.freeDelegateCallback(instance.visualContentCallbackHandle);
|
|
451
|
-
instance.visualContentCallbackHandle = undefined;
|
|
452
|
-
instance.visualContentCallback = undefined;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
439
|
|
|
456
440
|
// Apply event handlers
|
|
457
441
|
function applyEvents(instance: Instance, props: BaseProps) {
|
|
@@ -486,27 +470,17 @@ function applyVisualContentCallback(instance: Instance, props: BaseProps) {
|
|
|
486
470
|
if (callback !== existingCallback) {
|
|
487
471
|
const element = instance.element as unknown as { generateVisualContent: GenerateVisualContentCallback | null };
|
|
488
472
|
|
|
489
|
-
//
|
|
473
|
+
// Remove old callback if exists
|
|
490
474
|
if (existingCallback) {
|
|
475
|
+
// Clear the delegate via C# interop
|
|
491
476
|
element.generateVisualContent = null;
|
|
492
|
-
if (instance.visualContentCallbackHandle !== undefined) {
|
|
493
|
-
__csHelpers.freeDelegateCallback(instance.visualContentCallbackHandle);
|
|
494
|
-
}
|
|
495
|
-
instance.visualContentCallbackHandle = undefined;
|
|
496
477
|
}
|
|
497
478
|
|
|
498
479
|
// Add new callback if provided
|
|
499
480
|
if (callback) {
|
|
500
|
-
//
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
instance.visualContentCallbackHandle = handle;
|
|
504
|
-
// Pass pre-resolved handle directly — bypasses __resolveValue's auto-registration
|
|
505
|
-
element.generateVisualContent = { __csCallbackHandle: handle } as any;
|
|
506
|
-
} else {
|
|
507
|
-
// WebGL path: no native callback table
|
|
508
|
-
element.generateVisualContent = callback;
|
|
509
|
-
}
|
|
481
|
+
// Assign callback to generateVisualContent property
|
|
482
|
+
// The C# interop layer handles the delegate conversion
|
|
483
|
+
element.generateVisualContent = callback;
|
|
510
484
|
instance.visualContentCallback = callback;
|
|
511
485
|
} else {
|
|
512
486
|
instance.visualContentCallback = undefined;
|
|
@@ -975,7 +949,6 @@ export const hostConfig = {
|
|
|
975
949
|
removeMergedTextChild(parentInstance, child);
|
|
976
950
|
} else {
|
|
977
951
|
__eventAPI.removeAllEventListeners(child.element);
|
|
978
|
-
cleanupCallbackHandles(child);
|
|
979
952
|
parentInstance.element.Remove(child.element);
|
|
980
953
|
}
|
|
981
954
|
untrackParent(child.element);
|
|
@@ -983,7 +956,6 @@ export const hostConfig = {
|
|
|
983
956
|
|
|
984
957
|
removeChildFromContainer(container: Container, child: Instance) {
|
|
985
958
|
__eventAPI.removeAllEventListeners(child.element);
|
|
986
|
-
cleanupCallbackHandles(child);
|
|
987
959
|
container.Remove(child.element);
|
|
988
960
|
untrackParent(child.element);
|
|
989
961
|
},
|