11import { equals , removeFrom } from "../../shared/common.ts" ;
2+ import { $injectTokens as $t } from "../../injection-tokens.ts" ;
23import { trace } from "../common/trace.ts" ;
34import { getViewConfigFactory , type ViewConfig } from "../state/views.ts" ;
45import type { PathNode } from "../path/path-node.ts" ;
56import type { ViewDeclaration } from "../state/interface.ts" ;
67import type { StateObject } from "../state/state-object.ts" ;
8+ import type { TemplateFactoryProvider } from "../template-factory.ts" ;
79
810/** The context ref can be anything that has a `name` and a `parent` reference to another IContextRef */
911export interface ViewContext {
@@ -26,7 +28,7 @@ export interface ActiveUIView {
2628 configUpdated : ( config : ViewConfig | undefined ) => void ;
2729}
2830
29- // A uiView and its matching viewConfig
31+ // An ngView and its matching viewConfig
3032export interface ViewTuple {
3133 ngView : ActiveUIView | undefined ;
3234 viewConfig : ViewConfig | undefined ;
@@ -42,7 +44,7 @@ type ViewConfigFactory = (
4244) => ViewConfig ;
4345
4446/**
45- * Tracks active `ui -view` instances and matches them with registered
47+ * Tracks active `ng -view` instances and matches them with registered
4648 * view configs produced during state transitions.
4749 */
4850export class ViewService {
@@ -58,20 +60,27 @@ export class ViewService {
5860 _rootContext : StateObject | null | undefined ;
5961
6062 /**
61- * Creates an empty view registry ready to track active `ui -view` instances.
63+ * Creates an empty view registry ready to track active `ng -view` instances.
6264 */
6365 constructor ( ) {
6466 this . _ngViews = [ ] ;
6567 this . _viewConfigs = [ ] ;
6668 this . _listeners = [ ] ;
67- this . _viewConfigFactory = getViewConfigFactory ( ) ;
69+ this . _viewConfigFactory = undefined ;
6870 this . _rootContext = undefined ;
6971 }
7072
7173 /**
7274 * Returns the singleton view service instance.
7375 */
74- $get = ( ) : ViewService => this ;
76+ $get = [
77+ $t . _templateFactory ,
78+ ( $templateFactory : TemplateFactoryProvider ) : ViewService => {
79+ this . _viewConfigFactory = getViewConfigFactory ( $templateFactory ) ;
80+
81+ return this ;
82+ } ,
83+ ] ;
7584
7685 onSync ( listener : ( tuples : ViewTuple [ ] ) => void ) : ( ) => void {
7786 this . _listeners . push ( listener ) ;
@@ -80,7 +89,7 @@ export class ViewService {
8089 }
8190
8291 /**
83- * Gets or sets the root view context used for relative `ui -view` targeting.
92+ * Gets or sets the root view context used for relative `ng -view` targeting.
8493 */
8594 rootViewContext (
8695 context ?: StateObject | null ,
@@ -119,7 +128,7 @@ export class ViewService {
119128 }
120129
121130 /**
122- * Re-matches active `ui -view` instances against currently registered view configs
131+ * Re-matches active `ng -view` instances against currently registered view configs
123132 * and notifies both the views and registered listeners of the new assignments.
124133 */
125134 sync ( ) : void {
@@ -240,7 +249,7 @@ export class ViewService {
240249 }
241250
242251 /**
243- * Registers one active `ui -view` and returns a deregistration function.
252+ * Registers one active `ng -view` and returns a deregistration function.
244253 */
245254 registerUIView ( ngView : ActiveUIView ) : ( ) => void {
246255 trace . traceViewServiceUIViewEvent ( "-> Registering" , ngView ) ;
@@ -300,7 +309,7 @@ export class ViewService {
300309
301310 /**
302311 * Builds a predicate that determines whether a view config matches
303- * a specific active `ui -view`.
312+ * a specific active `ng -view`.
304313 */
305314 static matches (
306315 ngViewsByFqn : Record < string , ActiveUIView > ,
0 commit comments