Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/core/application/application.ios.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { profile } from '../profiling';
import { ContentView } from '../ui/content-view';
import type { ContentView } from '../ui/content-view';
import type { View } from '../ui/core/view';
import { isEmbedded } from '../ui/embedding';
import { IOSHelper } from '../ui/core/view/view-helper';
Expand All @@ -19,7 +19,7 @@ import type { WindowRole } from '../native-window/window-base';
import { NativeWindowEvents } from '../native-window/native-window-interfaces';
import type { NativeWindowEventData, WindowContentRequest, WindowOpenOptions } from '../native-window/native-window-interfaces';
import { CoreTypes } from '../core-types';
import { getiOSWindow, setApplicationPropertiesCallback, setAppMainEntry, setiOSWindow, setRootView, setToggleApplicationEventListenersCallback } from './helpers-common';
import { createContentView, getiOSWindow, setApplicationPropertiesCallback, setAppMainEntry, setiOSWindow, setRootView, setToggleApplicationEventListenersCallback } from './helpers-common';

@NativeClass
class NotificationObserver extends NSObject {
Expand Down Expand Up @@ -1223,7 +1223,7 @@ export class iOSApplication extends ApplicationCommon implements IiOSApplication
* window's actual root view (see `_contentHosts`).
*/
private setHostedWindowContent(window: NativeWindow, userView: View): void {
const host = new ContentView();
const host = createContentView() as ContentView;
this._contentHosts.add(host);

// Sets the host up as a root view (CSS classes, native controller) and, for the primary
Expand Down Expand Up @@ -1277,7 +1277,7 @@ export class iOSApplication extends ApplicationCommon implements IiOSApplication
this._rootView._onRootViewReset();
}

const rootView = new ContentView();
const rootView = createContentView() as ContentView;
this._contentHosts.add(rootView);
const controller = this.getViewController(rootView);

Expand Down
12 changes: 12 additions & 0 deletions packages/core/application/helpers-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,18 @@ export function setApplicationPropertiesCallback(callback: () => ApplicationProp
_applicationPropertiesCallback = callback;
}

// Lets the application create its root host without importing the UI stack, which workers must not load
let _contentViewFactory: () => any /* ContentView */;
export function setContentViewFactory(factory: () => any /* ContentView */) {
_contentViewFactory = factory;
}
export function createContentView(): any /* ContentView */ {
if (!_contentViewFactory) {
throw new Error('ContentView is not registered: import "@nativescript/core/ui/content-view" before creating the root view.');
}
return _contentViewFactory();
}

let _a11yUpdatePropertiesCallback: (view: any /* View */) => void;
export function setA11yUpdatePropertiesCallback(callback: (view: any /* View */) => void) {
_a11yUpdatePropertiesCallback = callback;
Expand Down
2 changes: 2 additions & 0 deletions packages/core/ui/content-view/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { View, CustomLayoutView, AddChildFromBuilder } from '../core/view';
import { layout } from '../../utils';
import { setContentViewFactory } from '../../application/helpers-common';

/**
* Represents a View that has a single child - content.
Expand Down Expand Up @@ -104,3 +105,4 @@ export class ContentView extends CustomLayoutView implements AddChildFromBuilder
}

ContentView.prototype.recycleNativeView = 'auto';
setContentViewFactory(() => new ContentView());
Loading