fix circular imports and change weakref.get->deref

This commit is contained in:
DjDeveloperr
2023-12-19 15:32:50 -05:00
parent 02da807b9f
commit 7dd41e5c21
31 changed files with 108 additions and 107 deletions

View File

@ -121,9 +121,9 @@ export function buildUIWithWeakRefAndInteract<T extends View>(createFunc: () =>
clearPage(); clearPage();
const page = getCurrentPage(); const page = getCurrentPage();
const weakRef = new WeakRef(createFunc()); const weakRef = new WeakRef(createFunc());
page.content = weakRef.get(); page.content = weakRef.deref();
if (interactWithViewFunc) { if (interactWithViewFunc) {
interactWithViewFunc(weakRef.get()); interactWithViewFunc(weakRef.deref());
} }
page.content = null; page.content = null;
// Give a change for native cleanup (e.g. keyboard close, etc.). // Give a change for native cleanup (e.g. keyboard close, etc.).
@ -141,7 +141,7 @@ export function buildUIWithWeakRefAndInteract<T extends View>(createFunc: () =>
} }
Utils.GC(); Utils.GC();
try { try {
TKUnit.assert(!weakRef.get(), weakRef.get() + ' leaked!'); TKUnit.assert(!weakRef.deref(), weakRef.deref() + ' leaked!');
done(null); done(null);
} catch (ex) { } catch (ex) {
done(ex); done(ex);

View File

@ -216,18 +216,18 @@ export function test_bindingContext_Change_IsReflected_Properly() {
// const weakRef = createButton(model); // const weakRef = createButton(model);
// try { // try {
// stack.addChild(weakRef.get()); // stack.addChild(weakRef.deref());
// TKUnit.waitUntilReady(() => weakRef.get().isLoaded); // TKUnit.waitUntilReady(() => weakRef.deref().isLoaded);
// TKUnit.assertEqual(weakRef.get().text, expectedValue, 'Binding is not working properly!'); // TKUnit.assertEqual(weakRef.deref().text, expectedValue, 'Binding is not working properly!');
// stack.removeChild(weakRef.get()); // stack.removeChild(weakRef.deref());
// TKUnit.waitUntilReady(() => !weakRef.get().isLoaded); // TKUnit.waitUntilReady(() => !weakRef.deref().isLoaded);
// utils.GC(); // utils.GC();
// // Give time for the GC to kick in // // Give time for the GC to kick in
// setTimeout(() => { // setTimeout(() => {
// utils.GC(); // utils.GC();
// TKUnit.assert(!weakRef.get(), 'UIElement is still alive!'); // TKUnit.assert(!weakRef.deref(), 'UIElement is still alive!');
// testFinished = true; // testFinished = true;
// }, 100); // }, 100);
// } catch (e) { // } catch (e) {

View File

@ -104,12 +104,12 @@ function getTargetAsWeakRef(): WeakRef<Target> {
// // with the v8 6.5 the GC does not release WeakRefs so fast if you pass them to a method // // with the v8 6.5 the GC does not release WeakRefs so fast if you pass them to a method
// // that's why we are making the call to the addWeakEventListener in a closure so that the WeakRef will be easier released // // that's why we are making the call to the addWeakEventListener in a closure so that the WeakRef will be easier released
// (function () { // (function () {
// addWeakEventListener(sourceRef.get(), Observable.propertyChangeEvent, emptyHandler, targetRef.get()); // addWeakEventListener(sourceRef.deref(), Observable.propertyChangeEvent, emptyHandler, targetRef.deref());
// })(); // })();
// forceGC(); // forceGC();
// try { // try {
// TKUnit.assert(!targetRef.get(), 'Target should be released after GC'); // TKUnit.assert(!targetRef.deref(), 'Target should be released after GC');
// done(null); // done(null);
// } catch (e) { // } catch (e) {
// done(e); // done(e);
@ -123,12 +123,12 @@ function getTargetAsWeakRef(): WeakRef<Target> {
// // with the v8 6.5 the GC does not release WeakRefs so fast if you pass them to a method // // with the v8 6.5 the GC does not release WeakRefs so fast if you pass them to a method
// // that's why we are making the call to the addWeakEventListener in a closure so that the WeakRef will be easier released // // that's why we are making the call to the addWeakEventListener in a closure so that the WeakRef will be easier released
// (function () { // (function () {
// addWeakEventListener(sourceRef.get(), Observable.propertyChangeEvent, targetRef.get().onEvent, targetRef.get()); // addWeakEventListener(sourceRef.deref(), Observable.propertyChangeEvent, targetRef.deref().onEvent, targetRef.deref());
// })(); // })();
// forceGC(); // forceGC();
// try { // try {
// TKUnit.assert(!sourceRef.get(), 'Source should be released after GC'); // TKUnit.assert(!sourceRef.deref(), 'Source should be released after GC');
// done(null); // done(null);
// } catch (e) { // } catch (e) {
// done(e); // done(e);

View File

@ -626,9 +626,9 @@ export class ListViewTest extends UITest<ListView> {
public test_no_memory_leak_when_items_is_regular_array() { public test_no_memory_leak_when_items_is_regular_array() {
let weakRef = new WeakRef<ListView>(this.testView); let weakRef = new WeakRef<ListView>(this.testView);
weakRef.get().items = FEW_ITEMS; weakRef.deref().items = FEW_ITEMS;
this.waitUntilTestElementIsLoaded(); this.waitUntilTestElementIsLoaded();
TKUnit.assertTrue(weakRef.get().isLoaded, 'ListView should be loaded here'); TKUnit.assertTrue(weakRef.deref().isLoaded, 'ListView should be loaded here');
this.assertNoMemoryLeak(weakRef); this.assertNoMemoryLeak(weakRef);
} }
@ -637,9 +637,9 @@ export class ListViewTest extends UITest<ListView> {
var colors = new ObservableArray(['red', 'green', 'blue']); var colors = new ObservableArray(['red', 'green', 'blue']);
let weakRef = new WeakRef<ListView>(this.testView); let weakRef = new WeakRef<ListView>(this.testView);
weakRef.get().items = colors; weakRef.deref().items = colors;
this.waitUntilTestElementIsLoaded(); this.waitUntilTestElementIsLoaded();
TKUnit.assertTrue(weakRef.get().isLoaded, 'ListView should be loaded here'); TKUnit.assertTrue(weakRef.deref().isLoaded, 'ListView should be loaded here');
this.assertNoMemoryLeak(weakRef); this.assertNoMemoryLeak(weakRef);
} }
@ -729,7 +729,7 @@ export class ListViewTest extends UITest<ListView> {
} }
Utils.GC(); Utils.GC();
TKUnit.assert(weakRef.get(), weakRef.get() + ' died prematurely!'); TKUnit.assert(weakRef.deref(), weakRef.deref() + ' died prematurely!');
} }
public test_check_if_item_at_index_is_visible() { public test_check_if_item_at_index_is_visible() {
@ -772,10 +772,10 @@ export class ListViewTest extends UITest<ListView> {
// } // }
// Utils.GC(); // Utils.GC();
// //
// return !weakRef.get(); // return !weakRef.deref();
// }); // });
// TKUnit.assert(!weakRef.get(), weakRef.get() + ' leaked!'); // TKUnit.assert(!weakRef.deref(), weakRef.deref() + ' leaked!');
} }
private loadViewWithItemNumber(args: ItemEventData) { private loadViewWithItemNumber(args: ItemEventData) {

View File

@ -14,7 +14,7 @@ export class CommonA11YServiceEnabledObservable extends SharedA11YObservable {
let lastValue: boolean; let lastValue: boolean;
function callback() { function callback() {
const self = ref?.get(); const self = ref?.deref();
if (!self) { if (!self) {
sharedA11YObservable.off(Observable.propertyChangeEvent, callback); sharedA11YObservable.off(Observable.propertyChangeEvent, callback);

View File

@ -71,7 +71,7 @@ function accessibilityEventHelper(view: View, eventType: number) {
return; return;
} }
case android.view.accessibility.AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: { case android.view.accessibility.AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: {
const lastView = lastFocusedView?.get(); const lastView = lastFocusedView?.deref();
if (lastView && view !== lastView) { if (lastView && view !== lastView) {
const lastAndroidView = lastView.nativeViewProtected as android.view.View; const lastAndroidView = lastView.nativeViewProtected as android.view.View;
if (lastAndroidView) { if (lastAndroidView) {
@ -89,7 +89,7 @@ function accessibilityEventHelper(view: View, eventType: number) {
return; return;
} }
case android.view.accessibility.AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED: { case android.view.accessibility.AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED: {
const lastView = lastFocusedView?.get(); const lastView = lastFocusedView?.deref();
if (lastView && view === lastView) { if (lastView && view === lastView) {
lastFocusedView = null; lastFocusedView = null;
androidView.clearFocus(); androidView.clearFocus();
@ -145,7 +145,7 @@ function ensureNativeClasses() {
} }
private getTnsView(androidView: android.view.View) { private getTnsView(androidView: android.view.View) {
const view = androidViewToTNSView.get(androidView)?.get(); const view = androidViewToTNSView.get(androidView)?.deref();
if (!view) { if (!view) {
androidViewToTNSView.delete(androidView); androidViewToTNSView.delete(androidView);

View File

@ -6,7 +6,7 @@ export class Color extends ColorBase {
get ios(): UIColor { get ios(): UIColor {
if (!this._ios) { if (!this._ios) {
// iOS Color is using floating-point values in the [0, 1] range, so divide the components by 255 // iOS Color is using floating-point values in the [0, 1] range, so divide the components by 255
this._ios = UIColor.alloc().initWithRedGreenBlueAlpha(this.r / 255, this.g / 255, this.b / 255, this.a / 255); this._ios = UIColor.colorWithRedGreenBlueAlpha(this.r / 255, this.g / 255, this.b / 255, this.a / 255);
} }
return this._ios; return this._ios;

View File

@ -21,7 +21,7 @@ function getViewById(nodeId: number): ViewBase {
const node = getNodeById(nodeId); const node = getNodeById(nodeId);
let view; let view;
if (node) { if (node) {
view = node.viewRef.get(); view = node.viewRef.deref();
} }
return view; return view;

View File

@ -91,13 +91,13 @@ export class DOMNode {
public loadAttributes() { public loadAttributes() {
this.attributes = []; this.attributes = [];
getSetPropertiesLazy()(this.viewRef.get()) getSetPropertiesLazy()(this.viewRef.deref())
.filter(propertyFilter) .filter(propertyFilter)
.forEach((pair) => this.attributes.push(pair[0], pair[1] + '')); .forEach((pair) => this.attributes.push(pair[0], pair[1] + ''));
} }
get children(): DOMNode[] { get children(): DOMNode[] {
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (!view) { if (!view) {
return []; return [];
} }
@ -116,7 +116,7 @@ export class DOMNode {
onChildAdded(childView: ViewBase): void { onChildAdded(childView: ViewBase): void {
notifyInspector((ins) => { notifyInspector((ins) => {
const view = this.viewRef.get(); const view = this.viewRef.deref();
let previousChild: ViewBase; let previousChild: ViewBase;
view.eachChild((child) => { view.eachChild((child) => {
@ -156,7 +156,7 @@ export class DOMNode {
} }
getComputedProperties(): CSSComputedStyleProperty[] { getComputedProperties(): CSSComputedStyleProperty[] {
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (!view) { if (!view) {
return []; return [];
} }

View File

@ -434,7 +434,7 @@ export const androidContentInsetLeftProperty = new CssProperty<Style, CoreTypes.
defaultValue: 'auto', defaultValue: 'auto',
equalityComparer: Length.equals, equalityComparer: Length.equals,
valueChanged: (target, oldValue, newValue) => { valueChanged: (target, oldValue, newValue) => {
const view = <ActionBarBase>target.viewRef.get(); const view = <ActionBarBase>target.viewRef.deref();
if (view) { if (view) {
view.effectiveContentInsetLeft = Length.toDevicePixels(newValue); view.effectiveContentInsetLeft = Length.toDevicePixels(newValue);
} else { } else {
@ -451,7 +451,7 @@ export const androidContentInsetRightProperty = new CssProperty<Style, CoreTypes
defaultValue: 'auto', defaultValue: 'auto',
equalityComparer: Length.equals, equalityComparer: Length.equals,
valueChanged: (target, oldValue, newValue) => { valueChanged: (target, oldValue, newValue) => {
const view = <ActionBarBase>target.viewRef.get(); const view = <ActionBarBase>target.viewRef.deref();
if (view) { if (view) {
view.effectiveContentInsetRight = Length.toDevicePixels(newValue); view.effectiveContentInsetRight = Length.toDevicePixels(newValue);
} else { } else {

View File

@ -293,7 +293,7 @@ export class ActionBar extends ActionBarBase {
this.nativeViewProtected.setNavigationOnClickListener( this.nativeViewProtected.setNavigationOnClickListener(
new android.view.View.OnClickListener({ new android.view.View.OnClickListener({
onClick: function (v) { onClick: function (v) {
const owner = navBtn?.get(); const owner = navBtn?.deref();
if (owner) { if (owner) {
owner._raiseTap(); owner._raiseTap();
} }
@ -382,7 +382,7 @@ export class ActionBar extends ActionBarBase {
item.actionView.android.setOnClickListener( item.actionView.android.setOnClickListener(
new android.view.View.OnClickListener({ new android.view.View.OnClickListener({
onClick: function (v: android.view.View) { onClick: function (v: android.view.View) {
const owner = weakRef?.get(); const owner = weakRef?.deref();
if (owner) { if (owner) {
owner._raiseTap(); owner._raiseTap();
} }

View File

@ -143,7 +143,7 @@ export class Animation extends AnimationBase {
if (Trace.isEnabled()) { if (Trace.isEnabled()) {
Trace.write('MainAnimatorListener.onAnimationEnd(' + animator + ')', Trace.categories.Animation); Trace.write('MainAnimatorListener.onAnimationEnd(' + animator + ')', Trace.categories.Animation);
} }
const thisRef = that?.get(); const thisRef = that?.deref();
if (thisRef) { if (thisRef) {
thisRef._onAndroidAnimationEnd(); thisRef._onAndroidAnimationEnd();
} }
@ -152,7 +152,7 @@ export class Animation extends AnimationBase {
if (Trace.isEnabled()) { if (Trace.isEnabled()) {
Trace.write('MainAnimatorListener.onAnimationCancel(' + animator + ')', Trace.categories.Animation); Trace.write('MainAnimatorListener.onAnimationCancel(' + animator + ')', Trace.categories.Animation);
} }
const thisRef = that?.get(); const thisRef = that?.deref();
if (thisRef) { if (thisRef) {
thisRef._onAndroidAnimationCancel(); thisRef._onAndroidAnimationCancel();
} }

View File

@ -136,7 +136,7 @@ export class Binding {
} }
if (options.twoWay) { if (options.twoWay) {
const target = this.targetOptions.instance.get(); const target = this.targetOptions.instance.deref();
if (target instanceof Observable) { if (target instanceof Observable) {
target.on(`${this.targetOptions.property}Change`, this.onTargetPropertyChanged, this); target.on(`${this.targetOptions.property}Change`, this.onTargetPropertyChanged, this);
} }
@ -189,7 +189,7 @@ export class Binding {
} }
private bindingContextChanged(data: PropertyChangeData): void { private bindingContextChanged(data: PropertyChangeData): void {
const target = this.targetOptions.instance.get(); const target = this.targetOptions.instance.deref();
if (!target) { if (!target) {
this.unbind(); this.unbind();
@ -209,7 +209,7 @@ export class Binding {
} }
public bind(source: any): void { public bind(source: any): void {
const target = this.targetOptions.instance.get(); const target = this.targetOptions.instance.deref();
if (this.sourceIsBindingContext && target instanceof Observable && this.targetOptions.property !== 'bindingContext') { if (this.sourceIsBindingContext && target instanceof Observable && this.targetOptions.property !== 'bindingContext') {
target.on('bindingContextChange', this.bindingContextChanged, this); target.on('bindingContextChange', this.bindingContextChanged, this);
} }
@ -238,7 +238,7 @@ export class Binding {
} }
public unbind() { public unbind() {
const target = this.targetOptions.instance.get(); const target = this.targetOptions.instance.deref();
if (target instanceof Observable) { if (target instanceof Observable) {
if (this.options.twoWay) { if (this.options.twoWay) {
target.off(`${this.targetOptions.property}Change`, this.onTargetPropertyChanged, this); target.off(`${this.targetOptions.property}Change`, this.onTargetPropertyChanged, this);
@ -273,11 +273,11 @@ export class Binding {
} }
if (property === bc.parentValueKey || property.indexOf(bc.parentsValueKey) === 0) { if (property === bc.parentValueKey || property.indexOf(bc.parentsValueKey) === 0) {
const parentView = this.getParentView(this.target.get(), property).view; const parentView = this.getParentView(this.target.deref(), property).view;
if (parentView) { if (parentView) {
currentObject = parentView.bindingContext; currentObject = parentView.bindingContext;
} else { } else {
const targetInstance = this.target.get(); const targetInstance = this.target.deref();
targetInstance.off('loaded', this.loadedHandlerVisualTreeBinding, this); targetInstance.off('loaded', this.loadedHandlerVisualTreeBinding, this);
targetInstance.on('loaded', this.loadedHandlerVisualTreeBinding, this); targetInstance.on('loaded', this.loadedHandlerVisualTreeBinding, this);
} }
@ -303,7 +303,7 @@ export class Binding {
} }
private addPropertyChangeListeners(source: WeakRef<Object>, sourceProperty: Array<string>, parentProperies?: string) { private addPropertyChangeListeners(source: WeakRef<Object>, sourceProperty: Array<string>, parentProperies?: string) {
const objectsAndProperties = this.resolveObjectsAndProperties(source.get(), sourceProperty); const objectsAndProperties = this.resolveObjectsAndProperties(source.deref(), sourceProperty);
let prop = parentProperies || ''; let prop = parentProperies || '';
for (let i = 0, length = objectsAndProperties.length; i < length; i++) { for (let i = 0, length = objectsAndProperties.length; i < length; i++) {
@ -345,7 +345,7 @@ export class Binding {
if (__UI_USE_EXTERNAL_RENDERER__) { if (__UI_USE_EXTERNAL_RENDERER__) {
} else if (this.options.expression) { } else if (this.options.expression) {
const changedModel = {}; const changedModel = {};
const targetInstance = this.target.get(); const targetInstance = this.target.deref();
let sourcePropertyName = ''; let sourcePropertyName = '';
if (this.sourceOptions) { if (this.sourceOptions) {
sourcePropertyName = this.sourceOptions.property; sourcePropertyName = this.sourceOptions.property;
@ -382,7 +382,7 @@ export class Binding {
if (!__UI_USE_EXTERNAL_RENDERER__) { if (!__UI_USE_EXTERNAL_RENDERER__) {
let context; let context;
const targetInstance = this.target.get(); const targetInstance = this.target.deref();
const addedProps = []; const addedProps = [];
try { try {
let exp; let exp;
@ -393,7 +393,7 @@ export class Binding {
} }
if (exp) { if (exp) {
context = (this.source && this.source.get && this.source.get()) || global; context = (this.source && this.source.deref && this.source.deref()) || global;
const resources = bindableResources.get(); const resources = bindableResources.get();
for (const prop in resources) { for (const prop in resources) {
if (resources.hasOwnProperty(prop) && !context.hasOwnProperty(prop)) { if (resources.hasOwnProperty(prop) && !context.hasOwnProperty(prop)) {
@ -526,7 +526,7 @@ export class Binding {
if (__UI_USE_EXTERNAL_RENDERER__) { if (__UI_USE_EXTERNAL_RENDERER__) {
} else if (this.options.expression) { } else if (this.options.expression) {
const changedModel = {}; const changedModel = {};
changedModel[bc.bindingValueKey] = this.source ? this.source.get() : undefined; changedModel[bc.bindingValueKey] = this.source ? this.source.deref() : undefined;
const expressionValue = this._getExpressionValue(this.options.expression, false, changedModel); const expressionValue = this._getExpressionValue(this.options.expression, false, changedModel);
if (expressionValue instanceof Error) { if (expressionValue instanceof Error) {
Trace.write((<Error>expressionValue).message, Trace.categories.Binding, Trace.messageType.error); Trace.write((<Error>expressionValue).message, Trace.categories.Binding, Trace.messageType.error);
@ -536,7 +536,7 @@ export class Binding {
} }
if (this.sourceOptions) { if (this.sourceOptions) {
const sourceOptionsInstance = this.sourceOptions.instance.get(); const sourceOptionsInstance = this.sourceOptions.instance.deref();
if (this.sourceOptions.property === bc.bindingValueKey) { if (this.sourceOptions.property === bc.bindingValueKey) {
return sourceOptionsInstance; return sourceOptionsInstance;
} else if (sourceOptionsInstance instanceof Observable && this.sourceOptions.property && this.sourceOptions.property !== '') { } else if (sourceOptionsInstance instanceof Observable && this.sourceOptions.property && this.sourceOptions.property !== '') {
@ -565,7 +565,7 @@ export class Binding {
} }
private updateSource(value: any) { private updateSource(value: any) {
if (this.updating || !this.source || !this.source.get()) { if (this.updating || !this.source || !this.source.deref()) {
return; return;
} }
@ -624,7 +624,7 @@ export class Binding {
private updateOptions(options: { instance: WeakRef<any>; property: string }, value: any) { private updateOptions(options: { instance: WeakRef<any>; property: string }, value: any) {
let optionsInstance; let optionsInstance;
if (options && options.instance) { if (options && options.instance) {
optionsInstance = options.instance.get(); optionsInstance = options.instance.deref();
} }
if (!optionsInstance) { if (!optionsInstance) {

View File

@ -645,7 +645,7 @@ export class CssProperty<T extends Style, U> implements CssProperty<T, U> {
const property = this; const property = this;
function setLocalValue(this: T, newValue: U | string): void { function setLocalValue(this: T, newValue: U | string): void {
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (!view) { if (!view) {
Trace.write(`${newValue} not set to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); Trace.write(`${newValue} not set to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
@ -723,7 +723,7 @@ export class CssProperty<T extends Style, U> implements CssProperty<T, U> {
} }
function setCssValue(this: T, newValue: U | string): void { function setCssValue(this: T, newValue: U | string): void {
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (!view) { if (!view) {
Trace.write(`${newValue} not set to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); Trace.write(`${newValue} not set to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
@ -925,7 +925,7 @@ export class CssAnimationProperty<T extends Style, U> implements CssAnimationPro
return this[symbol]; return this[symbol];
}, },
set(this: T, boxedValue: U | string) { set(this: T, boxedValue: U | string) {
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (!view) { if (!view) {
Trace.write(`${boxedValue} not set to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn); Trace.write(`${boxedValue} not set to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
@ -1034,7 +1034,7 @@ export class CssAnimationProperty<T extends Style, U> implements CssAnimationPro
} }
public _initDefaultNativeValue(target: T): void { public _initDefaultNativeValue(target: T): void {
const view = target.viewRef.get(); const view = target.viewRef.deref();
if (!view) { if (!view) {
Trace.write(`_initDefaultNativeValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn); Trace.write(`_initDefaultNativeValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
@ -1102,7 +1102,7 @@ export class InheritedCssProperty<T extends Style, U> extends CssProperty<T, U>
const setFunc = (valueSource: ValueSource) => const setFunc = (valueSource: ValueSource) =>
function (this: T, boxedValue: any): void { function (this: T, boxedValue: any): void {
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (!view) { if (!view) {
Trace.write(`${boxedValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); Trace.write(`${boxedValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
@ -1249,7 +1249,7 @@ export class ShorthandProperty<T extends Style, P> implements ShorthandProperty<
const converter = options.converter; const converter = options.converter;
function setLocalValue(this: T, value: string | P): void { function setLocalValue(this: T, value: string | P): void {
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (!view) { if (!view) {
Trace.write(`setLocalValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn); Trace.write(`setLocalValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
@ -1264,7 +1264,7 @@ export class ShorthandProperty<T extends Style, P> implements ShorthandProperty<
} }
function setCssValue(this: T, value: string): void { function setCssValue(this: T, value: string): void {
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (!view) { if (!view) {
Trace.write(`setCssValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn); Trace.write(`setCssValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);

View File

@ -270,7 +270,7 @@ let viewIdCounter = 1;
// let nativeView; // let nativeView;
// while (array.length > 0) { // while (array.length > 0) {
// const weakRef = array.pop(); // const weakRef = array.pop();
// nativeView = weakRef.get(); // nativeView = weakRef.deref();
// if (nativeView) { // if (nativeView) {
// return nativeView; // return nativeView;
// } // }

View File

@ -97,7 +97,7 @@ function initializeTouchListener(): void {
} }
onTouch(view: android.view.View, event: android.view.MotionEvent): boolean { onTouch(view: android.view.View, event: android.view.MotionEvent): boolean {
const owner = this.owner.get(); const owner = this.owner.deref();
if (!owner) { if (!owner) {
return; return;
} }
@ -259,7 +259,7 @@ function initializeDialogFragment() {
public onDismiss(dialog: android.content.DialogInterface): void { public onDismiss(dialog: android.content.DialogInterface): void {
super.onDismiss(dialog); super.onDismiss(dialog);
const manager = this.getFragmentManager(); const manager = this.getFragmentManager();
const activity = this.activity?.get(); const activity = this.activity?.deref();
if (manager && !activity?.isChangingConfigurations()) { if (manager && !activity?.isChangingConfigurations()) {
removeModal(this.owner._domId); removeModal(this.owner._domId);
this._dismissCallback(); this._dismissCallback();
@ -274,7 +274,7 @@ function initializeDialogFragment() {
public onDestroy(): void { public onDestroy(): void {
super.onDestroy(); super.onDestroy();
const owner = this.owner; const owner = this.owner;
const activity = this.activity?.get(); const activity = this.activity?.deref();
if (!activity?.isChangingConfigurations()) { if (!activity?.isChangingConfigurations()) {
this.activity = null; this.activity = null;
} }

View File

@ -15,7 +15,7 @@ import { ViewHelper } from './view-helper';
import { PercentLength } from '../../styling/style-properties'; import { PercentLength } from '../../styling/style-properties';
import { observe as gestureObserve, GesturesObserver, GestureTypes, GestureEventData, fromString as gestureFromString, TouchManager, TouchAnimationOptions } from '../../gestures'; import { observe as gestureObserve, GesturesObserver, GestureTypes, GestureEventData, fromString as gestureFromString, type TouchAnimationOptions } from '../../gestures';
import { CSSUtils } from '../../../css/system-classes'; import { CSSUtils } from '../../../css/system-classes';
import { Builder } from '../../builder'; import { Builder } from '../../builder';
@ -170,6 +170,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
onLoaded() { onLoaded() {
if (!this.isLoaded) { if (!this.isLoaded) {
const { TouchManager } = require('../../gestures/touch-manager');
const enableTapAnimations = TouchManager.enableGlobalTapAnimations && (this.hasListeners('tap') || this.hasListeners('tapChange') || this.getGestureObservers(GestureTypes.tap)); const enableTapAnimations = TouchManager.enableGlobalTapAnimations && (this.hasListeners('tap') || this.hasListeners('tapChange') || this.getGestureObservers(GestureTypes.tap));
if (!this.ignoreTouchAnimation && (this.touchAnimation || enableTapAnimations)) { if (!this.ignoreTouchAnimation && (this.touchAnimation || enableTapAnimations)) {
// console.log('view:', Object.keys((<any>this)._observers)); // console.log('view:', Object.keys((<any>this)._observers));

View File

@ -36,7 +36,7 @@ function getHandlerForEventName(eventName: string): (eventData: EventData) => vo
let target; let target;
for (let i = 0; i < targetHandlerPairList.length; i++) { for (let i = 0; i < targetHandlerPairList.length; i++) {
pair = targetHandlerPairList[i]; pair = targetHandlerPairList[i];
target = pair.tagetRef.get(); target = pair.tagetRef.deref();
if (target) { if (target) {
pair.handler.call(target, eventData); pair.handler.call(target, eventData);
} else { } else {
@ -130,7 +130,7 @@ export function removeWeakEventListener(source: Observable, eventName: string, h
for (let i = 0; i < targetHandlerPairList.length; i++) { for (let i = 0; i < targetHandlerPairList.length; i++) {
pair = targetHandlerPairList[i]; pair = targetHandlerPairList[i];
registeredTarget = pair.tagetRef.get(); registeredTarget = pair.tagetRef.deref();
if (!registeredTarget || (registeredTarget === target && handler === pair.handler)) { if (!registeredTarget || (registeredTarget === target && handler === pair.handler)) {
targetHandlerPairsToRemove.push(i); targetHandlerPairsToRemove.push(i);
} }

View File

@ -60,23 +60,23 @@ function initializeEditTextListeners(): void {
} }
public beforeTextChanged(text: string, start: number, count: number, after: number): void { public beforeTextChanged(text: string, start: number, count: number, after: number): void {
this.owner?.get()?.beforeTextChanged(text, start, count, after); this.owner?.deref()?.beforeTextChanged(text, start, count, after);
} }
public onTextChanged(text: string, start: number, before: number, count: number): void { public onTextChanged(text: string, start: number, before: number, count: number): void {
this.owner?.get()?.onTextChanged(text, start, before, count); this.owner?.deref()?.onTextChanged(text, start, before, count);
} }
public afterTextChanged(editable: android.text.Editable): void { public afterTextChanged(editable: android.text.Editable): void {
this.owner?.get()?.afterTextChanged(editable); this.owner?.deref()?.afterTextChanged(editable);
} }
public onFocusChange(view: android.view.View, hasFocus: boolean): void { public onFocusChange(view: android.view.View, hasFocus: boolean): void {
this.owner?.get()?.onFocusChange(view, hasFocus); this.owner?.deref()?.onFocusChange(view, hasFocus);
} }
public onEditorAction(textView: android.widget.TextView, actionId: number, event: android.view.KeyEvent): boolean { public onEditorAction(textView: android.widget.TextView, actionId: number, event: android.view.KeyEvent): boolean {
return this.owner?.get()?.onEditorAction(textView, actionId, event) || false; return this.owner?.deref()?.onEditorAction(textView, actionId, event) || false;
} }
} }

View File

@ -807,7 +807,7 @@ function startActivity(activity: androidx.appcompat.app.AppCompatActivity, frame
function getFrameByNumberId(frameId: number): Frame { function getFrameByNumberId(frameId: number): Frame {
// Find the frame for this activity. // Find the frame for this activity.
for (let i = 0; i < framesCache.length; i++) { for (let i = 0; i < framesCache.length; i++) {
const aliveFrame = framesCache[i].get(); const aliveFrame = framesCache[i].deref();
if (aliveFrame && aliveFrame.frameId === frameId) { if (aliveFrame && aliveFrame.frameId === frameId) {
return aliveFrame.owner; return aliveFrame.owner;
} }
@ -1050,7 +1050,7 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
// also, to be compatible with fragments 1.2.x we need this setTimeout as animations haven't run on onResume yet // also, to be compatible with fragments 1.2.x we need this setTimeout as animations haven't run on onResume yet
const weakRef = new WeakRef(this); const weakRef = new WeakRef(this);
setTimeout(() => { setTimeout(() => {
const owner = weakRef.get(); const owner = weakRef.deref();
if (!owner) { if (!owner) {
return; return;
} }
@ -1133,7 +1133,7 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks {
if (savedInstanceState) { if (savedInstanceState) {
const rootViewId = savedInstanceState.getInt(ROOT_VIEW_ID_EXTRA, -1); const rootViewId = savedInstanceState.getInt(ROOT_VIEW_ID_EXTRA, -1);
if (rootViewId !== -1 && activityRootViewsMap.has(rootViewId)) { if (rootViewId !== -1 && activityRootViewsMap.has(rootViewId)) {
this._rootView = activityRootViewsMap.get(rootViewId)?.get(); this._rootView = activityRootViewsMap.get(rootViewId)?.deref();
} }
} }

View File

@ -2,8 +2,6 @@
import type { View } from '../core/view'; import type { View } from '../core/view';
import type { EventData } from '../../data/observable'; import type { EventData } from '../../data/observable';
export * from './touch-manager';
/** /**
* Events emitted during gesture lifecycle * Events emitted during gesture lifecycle
*/ */

View File

@ -42,7 +42,7 @@ export class Cache extends common.Cache {
const that = new WeakRef(this); const that = new WeakRef(this);
this._callback = new org.nativescript.widgets.Async.CompleteCallback({ this._callback = new org.nativescript.widgets.Async.CompleteCallback({
onComplete: function (result: any, context: any) { onComplete: function (result: any, context: any) {
const instance = that?.get(); const instance = that?.deref();
if (instance) { if (instance) {
if (result) { if (result) {
instance._onDownloadCompleted(context, result); instance._onDownloadCompleted(context, result);
@ -52,7 +52,7 @@ export class Cache extends common.Cache {
} }
}, },
onError: function (err: string, context: any) { onError: function (err: string, context: any) {
const instance = that?.get(); const instance = that?.deref();
if (instance) { if (instance) {
instance._onDownloadError(context, new Error(err)); instance._onDownloadError(context, new Error(err));
} }

View File

@ -27,7 +27,8 @@ export * from './editable-text-base';
export { Frame, setActivityCallbacks } from './frame'; export { Frame, setActivityCallbacks } from './frame';
export type { NavigationEntry, NavigationContext, NavigationTransition, BackstackEntry, ViewEntry, AndroidActivityCallbacks } from './frame'; export type { NavigationEntry, NavigationContext, NavigationTransition, BackstackEntry, ViewEntry, AndroidActivityCallbacks } from './frame';
export { GesturesObserver, TouchAction, GestureTypes, GestureStateTypes, SwipeDirection, GestureEvents, TouchManager } from './gestures'; export { GesturesObserver, TouchAction, GestureTypes, GestureStateTypes, SwipeDirection, GestureEvents } from './gestures';
export { TouchManager } from './gestures/touch-manager';
export type { GestureEventData, GestureEventDataWithState, TapGestureEventData, PanGestureEventData, PinchGestureEventData, RotationGestureEventData, SwipeGestureEventData, TouchGestureEventData, TouchAnimationOptions } from './gestures'; export type { GestureEventData, GestureEventDataWithState, TapGestureEventData, PanGestureEventData, PinchGestureEventData, RotationGestureEventData, SwipeGestureEventData, TouchGestureEventData, TouchAnimationOptions } from './gestures';
export { HtmlView } from './html-view'; export { HtmlView } from './html-view';

View File

@ -371,7 +371,7 @@ class UIViewControllerImpl extends UIViewController {
// TODO: a11y // TODO: a11y
// public accessibilityPerformEscape() { // public accessibilityPerformEscape() {
// const owner = this._owner.get(); // const owner = this._owner.deref();
// if (!owner) { // if (!owner) {
// return false; // return false;
// } // }

View File

@ -133,7 +133,7 @@ export class ScrollView extends ScrollViewBase {
const viewRef = new WeakRef(this); const viewRef = new WeakRef(this);
this.handler = new android.view.ViewTreeObserver.OnScrollChangedListener({ this.handler = new android.view.ViewTreeObserver.OnScrollChangedListener({
onScrollChanged: function () { onScrollChanged: function () {
const owner: ScrollView = viewRef.get(); const owner: ScrollView = viewRef.deref();
if (owner) { if (owner) {
owner._onScrollChanged(); owner._onScrollChanged();
} }

View File

@ -191,7 +191,7 @@ export const minWidthProperty = new CssProperty<Style, CoreTypes.LengthType>({
affectsLayout: global.isIOS, affectsLayout: global.isIOS,
equalityComparer: Length.equals, equalityComparer: Length.equals,
valueChanged: (target, oldValue, newValue) => { valueChanged: (target, oldValue, newValue) => {
const view = target.viewRef.get(); const view = target.viewRef.deref();
if (view) { if (view) {
view.effectiveMinWidth = Length.toDevicePixels(newValue, 0); view.effectiveMinWidth = Length.toDevicePixels(newValue, 0);
} else { } else {
@ -209,7 +209,7 @@ export const minHeightProperty = new CssProperty<Style, CoreTypes.LengthType>({
affectsLayout: global.isIOS, affectsLayout: global.isIOS,
equalityComparer: Length.equals, equalityComparer: Length.equals,
valueChanged: (target, oldValue, newValue) => { valueChanged: (target, oldValue, newValue) => {
const view = target.viewRef.get(); const view = target.viewRef.deref();
if (view) { if (view) {
view.effectiveMinHeight = Length.toDevicePixels(newValue, 0); view.effectiveMinHeight = Length.toDevicePixels(newValue, 0);
} else { } else {
@ -229,7 +229,7 @@ export const widthProperty = new CssAnimationProperty<Style, CoreTypes.PercentLe
// on the animation property, so fake it here. x_x // on the animation property, so fake it here. x_x
valueChanged: (target, oldValue, newValue) => { valueChanged: (target, oldValue, newValue) => {
if (global.isIOS) { if (global.isIOS) {
const view = target.viewRef.get(); const view = target.viewRef.deref();
if (view) { if (view) {
view.requestLayout(); view.requestLayout();
} }
@ -248,7 +248,7 @@ export const heightProperty = new CssAnimationProperty<Style, CoreTypes.PercentL
// on the animation property, so fake it here. -_- // on the animation property, so fake it here. -_-
valueChanged: (target, oldValue, newValue) => { valueChanged: (target, oldValue, newValue) => {
if (global.isIOS) { if (global.isIOS) {
const view = target.viewRef.get(); const view = target.viewRef.deref();
if (view) { if (view) {
view.requestLayout(); view.requestLayout();
} }
@ -333,7 +333,7 @@ export const paddingLeftProperty = new CssProperty<Style, CoreTypes.LengthType>(
affectsLayout: global.isIOS, affectsLayout: global.isIOS,
equalityComparer: Length.equals, equalityComparer: Length.equals,
valueChanged: (target, oldValue, newValue) => { valueChanged: (target, oldValue, newValue) => {
const view = target.viewRef.get(); const view = target.viewRef.deref();
if (view) { if (view) {
view.effectivePaddingLeft = Length.toDevicePixels(newValue, 0); view.effectivePaddingLeft = Length.toDevicePixels(newValue, 0);
} else { } else {
@ -351,7 +351,7 @@ export const paddingRightProperty = new CssProperty<Style, CoreTypes.LengthType>
affectsLayout: global.isIOS, affectsLayout: global.isIOS,
equalityComparer: Length.equals, equalityComparer: Length.equals,
valueChanged: (target, oldValue, newValue) => { valueChanged: (target, oldValue, newValue) => {
const view = target.viewRef.get(); const view = target.viewRef.deref();
if (view) { if (view) {
view.effectivePaddingRight = Length.toDevicePixels(newValue, 0); view.effectivePaddingRight = Length.toDevicePixels(newValue, 0);
} else { } else {
@ -369,7 +369,7 @@ export const paddingTopProperty = new CssProperty<Style, CoreTypes.LengthType>({
affectsLayout: global.isIOS, affectsLayout: global.isIOS,
equalityComparer: Length.equals, equalityComparer: Length.equals,
valueChanged: (target, oldValue, newValue) => { valueChanged: (target, oldValue, newValue) => {
const view = target.viewRef.get(); const view = target.viewRef.deref();
if (view) { if (view) {
view.effectivePaddingTop = Length.toDevicePixels(newValue, 0); view.effectivePaddingTop = Length.toDevicePixels(newValue, 0);
} else { } else {
@ -387,7 +387,7 @@ export const paddingBottomProperty = new CssProperty<Style, CoreTypes.LengthType
affectsLayout: global.isIOS, affectsLayout: global.isIOS,
equalityComparer: Length.equals, equalityComparer: Length.equals,
valueChanged: (target, oldValue, newValue) => { valueChanged: (target, oldValue, newValue) => {
const view = target.viewRef.get(); const view = target.viewRef.deref();
if (view) { if (view) {
view.effectivePaddingBottom = Length.toDevicePixels(newValue, 0); view.effectivePaddingBottom = Length.toDevicePixels(newValue, 0);
} else { } else {
@ -1041,7 +1041,7 @@ export const borderTopWidthProperty = new CssProperty<Style, CoreTypes.LengthTyp
throw new Error(`border-top-width should be Non-Negative Finite number. Value: ${value}`); throw new Error(`border-top-width should be Non-Negative Finite number. Value: ${value}`);
} }
const view = target.viewRef.get(); const view = target.viewRef.deref();
if (view) { if (view) {
view.effectiveBorderTopWidth = value; view.effectiveBorderTopWidth = value;
} else { } else {
@ -1065,7 +1065,7 @@ export const borderRightWidthProperty = new CssProperty<Style, CoreTypes.LengthT
throw new Error(`border-right-width should be Non-Negative Finite number. Value: ${value}`); throw new Error(`border-right-width should be Non-Negative Finite number. Value: ${value}`);
} }
const view = target.viewRef.get(); const view = target.viewRef.deref();
if (view) { if (view) {
view.effectiveBorderRightWidth = value; view.effectiveBorderRightWidth = value;
} else { } else {
@ -1089,7 +1089,7 @@ export const borderBottomWidthProperty = new CssProperty<Style, CoreTypes.Length
throw new Error(`border-bottom-width should be Non-Negative Finite number. Value: ${value}`); throw new Error(`border-bottom-width should be Non-Negative Finite number. Value: ${value}`);
} }
const view = target.viewRef.get(); const view = target.viewRef.deref();
if (view) { if (view) {
view.effectiveBorderBottomWidth = value; view.effectiveBorderBottomWidth = value;
} else { } else {
@ -1113,7 +1113,7 @@ export const borderLeftWidthProperty = new CssProperty<Style, CoreTypes.LengthTy
throw new Error(`border-left-width should be Non-Negative Finite number. Value: ${value}`); throw new Error(`border-left-width should be Non-Negative Finite number. Value: ${value}`);
} }
const view = target.viewRef.get(); const view = target.viewRef.deref();
if (view) { if (view) {
view.effectiveBorderLeftWidth = value; view.effectiveBorderLeftWidth = value;
} else { } else {
@ -1448,7 +1448,7 @@ export const visibilityProperty = new CssProperty<Style, CoreTypes.VisibilityTyp
affectsLayout: global.isIOS, affectsLayout: global.isIOS,
valueConverter: CoreTypes.Visibility.parse, valueConverter: CoreTypes.Visibility.parse,
valueChanged: (target, oldValue, newValue) => { valueChanged: (target, oldValue, newValue) => {
const view = target.viewRef.get(); const view = target.viewRef.deref();
if (view) { if (view) {
view.isCollapsed = newValue === CoreTypes.Visibility.collapse; view.isCollapsed = newValue === CoreTypes.Visibility.collapse;
} else { } else {

View File

@ -427,7 +427,7 @@ export class CssState {
* As a result, at some point in time, the selectors matched have to be requerried from the style scope and applied to the view. * As a result, at some point in time, the selectors matched have to be requerried from the style scope and applied to the view.
*/ */
public onChange(): void { public onChange(): void {
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (view && view.isLoaded) { if (view && view.isLoaded) {
this.unsubscribeFromDynamicUpdates(); this.unsubscribeFromDynamicUpdates();
this.updateMatch(); this.updateMatch();
@ -439,14 +439,14 @@ export class CssState {
} }
public isSelectorsLatestVersionApplied(): boolean { public isSelectorsLatestVersionApplied(): boolean {
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (!view) { if (!view) {
Trace.write(`isSelectorsLatestVersionApplied returns default value "false" because "this.viewRef" cleared.`, Trace.categories.Style, Trace.messageType.warn); Trace.write(`isSelectorsLatestVersionApplied returns default value "false" because "this.viewRef" cleared.`, Trace.categories.Style, Trace.messageType.warn);
return false; return false;
} }
return this.viewRef.get()._styleScope.getSelectorsVersion() === this._appliedSelectorsVersion; return this.viewRef.deref()._styleScope.getSelectorsVersion() === this._appliedSelectorsVersion;
} }
public onLoaded(): void { public onLoaded(): void {
@ -464,7 +464,7 @@ export class CssState {
@profile @profile
private updateMatch() { private updateMatch() {
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (view && view._styleScope) { if (view && view._styleScope) {
this._match = view._styleScope.matchSelectors(view); this._match = view._styleScope.matchSelectors(view);
this._appliedSelectorsVersion = view._styleScope.getSelectorsVersion(); this._appliedSelectorsVersion = view._styleScope.getSelectorsVersion();
@ -477,7 +477,7 @@ export class CssState {
@profile @profile
private updateDynamicState(): void { private updateDynamicState(): void {
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (!view) { if (!view) {
Trace.write(`updateDynamicState not executed to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); Trace.write(`updateDynamicState not executed to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
@ -515,7 +515,7 @@ export class CssState {
}); });
if ((this._playsKeyframeAnimations = animations.length > 0)) { if ((this._playsKeyframeAnimations = animations.length > 0)) {
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (!view) { if (!view) {
Trace.write(`KeyframeAnimations cannot play because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn); Trace.write(`KeyframeAnimations cannot play because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
@ -536,7 +536,7 @@ export class CssState {
this._appliedAnimations.filter((animation) => animation.isPlaying).forEach((animation) => animation.cancel()); this._appliedAnimations.filter((animation) => animation.isPlaying).forEach((animation) => animation.cancel());
this._appliedAnimations = CssState.emptyAnimationArray; this._appliedAnimations = CssState.emptyAnimationArray;
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (view) { if (view) {
view.style['keyframe:rotate'] = unsetValue; view.style['keyframe:rotate'] = unsetValue;
view.style['keyframe:rotateX'] = unsetValue; view.style['keyframe:rotateX'] = unsetValue;
@ -561,7 +561,7 @@ export class CssState {
* @param matchingSelectors * @param matchingSelectors
*/ */
private setPropertyValues(matchingSelectors: SelectorCore[]): void { private setPropertyValues(matchingSelectors: SelectorCore[]): void {
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (!view) { if (!view) {
Trace.write(`${matchingSelectors} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); Trace.write(`${matchingSelectors} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
return; return;
@ -688,7 +688,7 @@ export class CssState {
} }
toString(): string { toString(): string {
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (!view) { if (!view) {
Trace.write(`toString() of CssState cannot execute correctly because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn); Trace.write(`toString() of CssState cannot execute correctly because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);

View File

@ -95,7 +95,7 @@ export class Style extends Observable implements StyleDefinition {
} }
toString() { toString() {
const view = this.viewRef.get(); const view = this.viewRef.deref();
if (!view) { if (!view) {
Trace.write(`toString() of Style cannot execute correctly because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn); Trace.write(`toString() of Style cannot execute correctly because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
@ -249,7 +249,7 @@ export class Style extends Observable implements StyleDefinition {
public get view(): ViewBase { public get view(): ViewBase {
if (this.viewRef) { if (this.viewRef) {
return this.viewRef.get(); return this.viewRef.deref();
} }
return undefined; return undefined;

View File

@ -33,12 +33,12 @@ function makeFragmentName(viewId: number, id: number): string {
function getTabById(id: number): TabView { function getTabById(id: number): TabView {
const ref = tabs.find((ref) => { const ref = tabs.find((ref) => {
const tab = ref.get(); const tab = ref.deref();
return tab && tab._domId === id; return tab && tab._domId === id;
}); });
return ref && ref.get(); return ref && ref.deref();
} }
function initializeNativeClasses() { function initializeNativeClasses() {

View File

@ -83,7 +83,7 @@ function initializeClickableSpan(): void {
return global.__native(this); return global.__native(this);
} }
onClick(view: android.view.View): void { onClick(view: android.view.View): void {
const owner = this.owner?.get(); const owner = this.owner?.deref();
if (owner) { if (owner) {
owner._emit(Span.linkTapEvent); owner._emit(Span.linkTapEvent);
} }

View File

@ -116,8 +116,9 @@ class WKUIDelegateImpl extends NSObject implements WKUIDelegate {
} }
@NativeClass @NativeClass
@ObjCClass(UIScrollViewDelegate)
class UIScrollViewDelegateImpl extends NSObject implements UIScrollViewDelegate { class UIScrollViewDelegateImpl extends NSObject implements UIScrollViewDelegate {
public static ObjCProtocols = [UIScrollViewDelegate];
public static initWithOwner(owner: WeakRef<WebView>): UIScrollViewDelegateImpl { public static initWithOwner(owner: WeakRef<WebView>): UIScrollViewDelegateImpl {
const handler = <UIScrollViewDelegateImpl>UIScrollViewDelegateImpl.new(); const handler = <UIScrollViewDelegateImpl>UIScrollViewDelegateImpl.new();
handler._owner = owner; handler._owner = owner;