From e695d430b6414d5ab17100a706f9ccd7babbb76c Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Sun, 26 Jul 2020 15:49:58 -0700 Subject: [PATCH 1/9] chore: update core to 7.0.0-beta.1 --- package.json | 2 +- src/directives/viewDirective.ts | 51 ++++++++++++++++++--------------- yarn.lock | 8 +++--- 3 files changed, 33 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index f41b69a4b..792969a81 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "module": "lib-esm/index.js", "typings": "lib/index.d.ts", "dependencies": { - "@uirouter/core": "6.0.7" + "@uirouter/core": "v7beta" }, "peerDependencies": { "angular": ">=1.2.0" diff --git a/src/directives/viewDirective.ts b/src/directives/viewDirective.ts index c8cd41662..2ac3458a5 100644 --- a/src/directives/viewDirective.ts +++ b/src/directives/viewDirective.ts @@ -21,6 +21,7 @@ import { Transition, TransitionService, TypedMap, + UIViewPortalRenderCommand, unnestR, ViewService, } from '@uirouter/core'; @@ -213,7 +214,6 @@ uiView = [ }; const directive = { - count: 0, restrict: 'ECA', terminal: true, priority: 400, @@ -228,44 +228,49 @@ uiView = [ let previousEl: JQuery, currentEl: JQuery, currentScope: IScope, viewConfig: Ng1ViewConfig; + const uiViewId = $view.registerView('ng1', inherited.$uiView.id, name, renderContentIntoUIViewPortal); + + scope.$on('$destroy', function () { + trace.traceUIViewEvent('Destroying/Unregistering', activeUIView); + $view.deregisterView(uiViewId); + }); + const activeUIView: ActiveUIView = { $type: 'ng1', - id: directive.count++, // Global sequential ID for ui-view tags added to DOM + id: uiViewId, // filled in later name: name, // ui-view name (
fqn: inherited.$uiView.fqn ? inherited.$uiView.fqn + '.' + name : name, // fully qualified name, describes location in DOM config: null, // The ViewConfig loaded (from a state.views definition) - configUpdated: configUpdatedCallback, // Called when the matching ViewConfig changes - get creationContext() { - // The context in which this ui-view "tag" was created - const fromParentTagConfig = parse('$cfg.viewDecl.$context')(inherited); - // Allow - // See https://github.com/angular-ui/ui-router/issues/3355 - const fromParentTag = parse('$uiView.creationContext')(inherited); - return fromParentTagConfig || fromParentTag; - }, + configUpdated: undefined, // unused in core + creationContext: undefined, // unused in core + // configUpdated: configUpdatedCallback, // Called when the matching ViewConfig changes + // get creationContext() { + // The context in which this ui-view "tag" was created + // const fromParentTagConfig = parse('$cfg.viewDecl.$context')(inherited); + // Allow + // See https://github.com/angular-ui/ui-router/issues/3355 + // const fromParentTag = parse('$uiView.creationContext')(inherited); + // return fromParentTagConfig || fromParentTag; + // }, }; trace.traceUIViewEvent('Linking', activeUIView); - function configUpdatedCallback(config?: Ng1ViewConfig) { - if (config && !(config instanceof Ng1ViewConfig)) return; - if (configsEqual(viewConfig, config)) return; - trace.traceUIViewConfigUpdated(activeUIView, config && config.viewDecl && config.viewDecl.$context); + function renderContentIntoUIViewPortal(renderCommand: UIViewPortalRenderCommand) { + if (renderCommand.command === 'RENDER_DEFAULT_CONTENT') { + viewConfig = undefined; + } else if (renderCommand.command === 'RENDER_ROUTED_VIEW') { + viewConfig = renderCommand.routedViewConfig as Ng1ViewConfig; + } else if (renderCommand.command === 'RENDER_INTEROP_DIV') { + } - viewConfig = config; - updateView(config); + updateView(viewConfig); } $element.data('$uiView', { $uiView: activeUIView }); updateView(); - const unregister = $view.registerUIView(activeUIView); - scope.$on('$destroy', function () { - trace.traceUIViewEvent('Destroying/Unregistering', activeUIView); - unregister(); - }); - function cleanupLastView() { if (previousEl) { trace.traceUIViewEvent('Removing (previous) el', previousEl.data('$uiView')); diff --git a/yarn.lock b/yarn.lock index 5fd398a23..2565d4b55 100644 --- a/yarn.lock +++ b/yarn.lock @@ -735,10 +735,10 @@ dependencies: eslint-visitor-keys "^1.1.0" -"@uirouter/core@6.0.7": - version "6.0.7" - resolved "https://registry.yarnpkg.com/@uirouter/core/-/core-6.0.7.tgz#a66743dceb13a56d8908474ff891d63e5d5a2b01" - integrity sha512-KUTJxL+6q0PiBnFx4/Z+Hsyg0pSGiaW5yZQeJmUxknecjpTbnXkLU8H2EqRn9N2B+qDRa7Jg8RcgeNDPY72O1w== +"@uirouter/core@v7beta": + version "7.0.0-beta.1" + resolved "https://registry.yarnpkg.com/@uirouter/core/-/core-7.0.0-beta.1.tgz#294c9a9f82f203ca396763b470093daeef3a8d52" + integrity sha512-jdRQscId7iHWnuSw9xvWNnTDM8QORqP1J5ovtDPtKEW3m0+SfCcKJqQWV6AyXXBFhUIzF+0JmQ8YOoVxDFSBPw== "@uirouter/publish-scripts@2.5.5": version "2.5.5" From 03d66cb0d6a26ea073ca37ae06b11a303a12dfb4 Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Sat, 8 Aug 2020 10:32:47 -0700 Subject: [PATCH 2/9] feat: update to uirouter/core 7.0.0-beta.2 --- src/directives/viewDirective.ts | 46 ++++++++++++++++----------------- yarn.lock | 6 ++--- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/directives/viewDirective.ts b/src/directives/viewDirective.ts index 2ac3458a5..18ab81b2b 100644 --- a/src/directives/viewDirective.ts +++ b/src/directives/viewDirective.ts @@ -226,18 +226,11 @@ uiView = [ inherited = $element.inheritedData('$uiView') || rootData, name = $interpolate(attrs['uiView'] || attrs['name'] || '')(scope) || '$default'; - let previousEl: JQuery, currentEl: JQuery, currentScope: IScope, viewConfig: Ng1ViewConfig; - - const uiViewId = $view.registerView('ng1', inherited.$uiView.id, name, renderContentIntoUIViewPortal); - - scope.$on('$destroy', function () { - trace.traceUIViewEvent('Destroying/Unregistering', activeUIView); - $view.deregisterView(uiViewId); - }); + let previousEl: JQuery, currentEl: JQuery, currentScope: IScope; const activeUIView: ActiveUIView = { $type: 'ng1', - id: uiViewId, // filled in later + id: null, // filled in later name: name, // ui-view name (
fqn: inherited.$uiView.fqn ? inherited.$uiView.fqn + '.' + name : name, // fully qualified name, describes location in DOM config: null, // The ViewConfig loaded (from a state.views definition) @@ -255,22 +248,15 @@ uiView = [ }; trace.traceUIViewEvent('Linking', activeUIView); + const uiViewId = $view.registerView('ng1', inherited.$uiView.id, name, renderContentIntoUIViewPortal); - function renderContentIntoUIViewPortal(renderCommand: UIViewPortalRenderCommand) { - if (renderCommand.command === 'RENDER_DEFAULT_CONTENT') { - viewConfig = undefined; - } else if (renderCommand.command === 'RENDER_ROUTED_VIEW') { - viewConfig = renderCommand.routedViewConfig as Ng1ViewConfig; - } else if (renderCommand.command === 'RENDER_INTEROP_DIV') { - } - - updateView(viewConfig); - } + scope.$on('$destroy', function () { + trace.traceUIViewEvent('Destroying/Unregistering', activeUIView); + $view.deregisterView(uiViewId); + }); $element.data('$uiView', { $uiView: activeUIView }); - updateView(); - function cleanupLastView() { if (previousEl) { trace.traceUIViewEvent('Removing (previous) el', previousEl.data('$uiView')); @@ -297,13 +283,25 @@ uiView = [ } } - function updateView(config?: Ng1ViewConfig) { + function renderContentIntoUIViewPortal(renderCommand: UIViewPortalRenderCommand) { + if (isString(activeUIView) && activeUIView.id !== renderCommand.id) { + throw new Error( + `Received a render command for wrong UIView. Render command id: ${renderCommand.id}, but this UIView id: ${activeUIView.id}` + ); + } + + activeUIView.id = renderCommand.id; + const viewConfig = + renderCommand.command === 'RENDER_ROUTED_VIEW' + ? (renderCommand.routedViewConfig as Ng1ViewConfig) + : undefined; + const newScope = scope.$new(); const animEnter = $q.defer(), animLeave = $q.defer(); const $uiViewData: UIViewData = { - $cfg: config, + $cfg: viewConfig, $uiView: activeUIView, }; @@ -354,7 +352,7 @@ uiView = [ * * @param {Object} event Event object. */ - currentScope.$emit('$viewContentLoaded', config || viewConfig); + currentScope.$emit('$viewContentLoaded', viewConfig); currentScope.$eval(onloadExp); } }; diff --git a/yarn.lock b/yarn.lock index 2565d4b55..3ba5c5fa9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -736,9 +736,9 @@ eslint-visitor-keys "^1.1.0" "@uirouter/core@v7beta": - version "7.0.0-beta.1" - resolved "https://registry.yarnpkg.com/@uirouter/core/-/core-7.0.0-beta.1.tgz#294c9a9f82f203ca396763b470093daeef3a8d52" - integrity sha512-jdRQscId7iHWnuSw9xvWNnTDM8QORqP1J5ovtDPtKEW3m0+SfCcKJqQWV6AyXXBFhUIzF+0JmQ8YOoVxDFSBPw== + version "7.0.0-beta.2" + resolved "https://registry.yarnpkg.com/@uirouter/core/-/core-7.0.0-beta.2.tgz#99669b70ef2b27066cc46f167caa1de1a505dcb9" + integrity sha512-ScY+H1n6lyEP5f78CTZlvc8eT5U5NRac0CAZQhy77ExLE4+zg0djyczsHR+omgNfAUndnSx4tqo+DbgjXZfUlw== "@uirouter/publish-scripts@2.5.5": version "2.5.5" From 6bc945b41659c43678059fbfdb31ebcbc6ac1dbc Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Sat, 8 Aug 2020 12:45:23 -0700 Subject: [PATCH 3/9] fix docgen for v7 beta --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 792969a81..7aa561a1d 100644 --- a/package.json +++ b/package.json @@ -144,7 +144,7 @@ { "pkg": "@uirouter/core", "repo": "https://github.com/ui-router/core", - "branch": "master" + "branch": "v7" } ] } From b0fa5b6b9032688dbdcfc47ef8c294781be0f7ac Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Sat, 8 Aug 2020 13:00:21 -0700 Subject: [PATCH 4/9] wip: add interop div support --- src/directives/viewDirective.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/directives/viewDirective.ts b/src/directives/viewDirective.ts index 18ab81b2b..422103564 100644 --- a/src/directives/viewDirective.ts +++ b/src/directives/viewDirective.ts @@ -34,8 +34,9 @@ import { ng1_directive } from './stateDirectives'; /** @hidden */ export type UIViewData = { - $cfg: Ng1ViewConfig; - $uiView: ActiveUIView; + $renderCommand: UIViewPortalRenderCommand; + $cfg: Ng1ViewConfig; // for backwards compat + $uiView: ActiveUIView; // for backwards compat }; /** @hidden */ @@ -301,6 +302,7 @@ uiView = [ animLeave = $q.defer(); const $uiViewData: UIViewData = { + $renderCommand: renderCommand, $cfg: viewConfig, $uiView: activeUIView, }; @@ -384,17 +386,22 @@ function $ViewDirectiveFill( tElement.empty(); return function (scope: IScope, $element: JQuery) { - const data: UIViewData = $element.data('$uiView'); - if (!data) { + const data: UIViewData = $element.data('$uiView') || {}; + const { $renderCommand, $uiView } = data; + if (!$renderCommand || $renderCommand.command === 'RENDER_DEFAULT_CONTENT') { $element.html(initial); $compile($element.contents() as any)(scope); return; + } else if ($renderCommand.command === 'RENDER_INTEROP_DIV') { + $element.html('
'); + $renderCommand.giveDiv($element.find('div')[0]); + return; } - const cfg: Ng1ViewConfig = data.$cfg || { viewDecl: {}, getTemplate: noop }; + const cfg: Ng1ViewConfig = $renderCommand.routedViewConfig || ({ viewDecl: {}, getTemplate: noop } as any); const resolveCtx: ResolveContext = cfg.path && new ResolveContext(cfg.path); $element.html(cfg.getTemplate($element, resolveCtx) || initial); - trace.traceUIViewFill(data.$uiView, $element.html()); + trace.traceUIViewFill($uiView, $element.html()); const link = $compile($element.contents() as any); const controller = cfg.controller as angular.IControllerService; From 56097a9729e60ce230ceb5373bd4346b19fa1bbc Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Sat, 8 Aug 2020 13:58:14 -0700 Subject: [PATCH 5/9] docs: rename sref symbols and export them for docs --- package.json | 10 +++++----- src/directives/stateDirectives.ts | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 7aa561a1d..369ef8174 100644 --- a/package.json +++ b/package.json @@ -129,11 +129,11 @@ "Interfaces": [ "Ng1StateDeclaration" ], - "Components": [ - "uiView", - "UISref", - "UISrefActive", - "uiStateDirective" + "Directives": [ + { "name": "uiView", "kindString": "Variable" }, + { "name": "uiSref", "kindString": "Variable" }, + { "name": "uiSrefActive", "kindString": "Variable" }, + { "name": "uiState", "kindString": "Variable" } ], "Other": [ "Transition", diff --git a/src/directives/stateDirectives.ts b/src/directives/stateDirectives.ts index 07540e813..48f9aa58a 100644 --- a/src/directives/stateDirectives.ts +++ b/src/directives/stateDirectives.ts @@ -281,8 +281,8 @@ function bindEvents(element: IAugmentedJQuery, scope: IScope, hookFn: EventListe * - Unlike the parameter values expression, the state name is not `$watch`ed (for performance reasons). * If you need to dynamically update the state being linked to, use the fully dynamic [[uiState]] directive. */ -let uiSrefDirective: ng1_directive; -uiSrefDirective = [ +export let uiSref: ng1_directive; +uiSref = [ '$uiRouter', '$timeout', function $StateRefDirective($uiRouter: UIRouter, $timeout: ITimeoutService) { @@ -419,8 +419,8 @@ uiSrefDirective = [ * - A middle-click, right-click, or ctrl-click is handled (natively) by the browser to open the href in a new window, for example. * ``` */ -let uiStateDirective: ng1_directive; -uiStateDirective = [ +export let uiState: ng1_directive; +uiState = [ '$uiRouter', '$timeout', function $StateRefDynamicDirective($uiRouter: UIRouter, $timeout: ITimeoutService) { @@ -569,8 +569,8 @@ uiStateDirective = [ * * - Multiple classes may be specified in a space-separated format: `ui-sref-active='class1 class2 class3'` */ -let uiSrefActiveDirective: ng1_directive; -uiSrefActiveDirective = [ +export let uiSrefActive: ng1_directive; +uiSrefActive = [ '$state', '$stateParams', '$interpolate', @@ -726,7 +726,7 @@ interface StateData { angular .module('ui.router.state') - .directive('uiSref', uiSrefDirective) - .directive('uiSrefActive', uiSrefActiveDirective) - .directive('uiSrefActiveEq', uiSrefActiveDirective) - .directive('uiState', uiStateDirective); + .directive('uiSref', uiSref) + .directive('uiSrefActive', uiSrefActive) + .directive('uiSrefActiveEq', uiSrefActive) + .directive('uiState', uiState); From 5381c83be73d4e15107162322c36443f69fb573e Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Mon, 21 Dec 2020 10:29:59 -0800 Subject: [PATCH 6/9] wip --- src/directives/viewDirective.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/directives/viewDirective.ts b/src/directives/viewDirective.ts index 422103564..dd69e3384 100644 --- a/src/directives/viewDirective.ts +++ b/src/directives/viewDirective.ts @@ -205,10 +205,6 @@ uiView = [ }; } - function configsEqual(config1: Ng1ViewConfig, config2: Ng1ViewConfig) { - return config1 === config2; - } - const rootData = { $cfg: { viewDecl: { $context: $view._pluginapi._rootViewContext() } }, $uiView: {}, From 2f52c941afdea7d0bc81c45be06f63ab1d7e7dc8 Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Thu, 24 Dec 2020 16:46:12 -0800 Subject: [PATCH 7/9] update to 7.0 beta-3 --- src/directives/viewDirective.ts | 63 +++++++++++++++++++++++++-------- test/stateSpec.ts | 1 + yarn.lock | 6 ++-- 3 files changed, 52 insertions(+), 18 deletions(-) diff --git a/src/directives/viewDirective.ts b/src/directives/viewDirective.ts index dd69e3384..1147a21df 100644 --- a/src/directives/viewDirective.ts +++ b/src/directives/viewDirective.ts @@ -1,7 +1,6 @@ /** @publicapi @module directives */ /** */ import { $QLike, - ActiveUIView, extend, filter, HookRegOptions, @@ -23,8 +22,11 @@ import { TypedMap, UIViewPortalRenderCommand, unnestR, + ViewConfig, + ViewContext, ViewService, } from '@uirouter/core'; +import { UIViewPortalRegistration } from '@uirouter/core/lib/view/interface'; import { IAugmentedJQuery, IInterpolateService, IScope, ITranscludeFunction } from 'angular'; import { ng as angular } from '../angular'; import { Ng1Controller, Ng1StateDeclaration } from '../interface'; @@ -172,6 +174,26 @@ export type UIViewAnimData = { * ``` */ export let uiView: ng1_directive; + +// No longer exported from @uirouter/core +// for backwards compat only +export interface ActiveUIView { + /** type of framework, e.g., "ng1" or "ng2" */ + $type: string; + /** An auto-incremented id */ + id: number | string; + /** The ui-view short name */ + name: string; + /** The ui-view's fully qualified name */ + fqn: string; + /** The ViewConfig that is currently loaded into the ui-view */ + config: ViewConfig; + /** The state context in which the ui-view tag was created. */ + creationContext: ViewContext; + /** A callback that should apply a ViewConfig (or clear the ui-view, if config is undefined) */ + configUpdated: (config: ViewConfig) => void; +} + // eslint-disable-next-line prefer-const uiView = [ '$view', @@ -244,14 +266,22 @@ uiView = [ // }, }; - trace.traceUIViewEvent('Linking', activeUIView); - const uiViewId = $view.registerView('ng1', inherited.$uiView.id, name, renderContentIntoUIViewPortal); + const uiViewId = $view._pluginapi._registerView( + 'ng1', + inherited.$uiView.id, + name, + renderContentIntoUIViewPortal + ); + // as any: trace requires the internal interface, hmmm... this isn't good + const registration = $view._pluginapi._registeredUIView(uiViewId) as any; + trace.traceUIViewEvent('Linking', registration); scope.$on('$destroy', function () { - trace.traceUIViewEvent('Destroying/Unregistering', activeUIView); - $view.deregisterView(uiViewId); + trace.traceUIViewEvent('Destroying/Unregistering', registration); + $view._pluginapi._deregisterView(uiViewId); }); + // backwards compat $element.data('$uiView', { $uiView: activeUIView }); function cleanupLastView() { @@ -262,7 +292,7 @@ uiView = [ } if (currentScope) { - trace.traceUIViewEvent('Destroying scope', activeUIView); + trace.traceUIViewEvent('Destroying scope', registration); currentScope.$destroy(); currentScope = null; } @@ -281,16 +311,17 @@ uiView = [ } function renderContentIntoUIViewPortal(renderCommand: UIViewPortalRenderCommand) { - if (isString(activeUIView) && activeUIView.id !== renderCommand.id) { + const renderCmdViewId = renderCommand.uiViewPortalRegistration.id; + if (isString(activeUIView.id) && activeUIView.id !== renderCmdViewId) { throw new Error( - `Received a render command for wrong UIView. Render command id: ${renderCommand.id}, but this UIView id: ${activeUIView.id}` + `Received a render command for wrong UIView. Render command id: ${renderCmdViewId}, but this UIView id: ${activeUIView.id}` ); } - activeUIView.id = renderCommand.id; + activeUIView.id = renderCmdViewId; const viewConfig = - renderCommand.command === 'RENDER_ROUTED_VIEW' - ? (renderCommand.routedViewConfig as Ng1ViewConfig) + renderCommand.portalContentType === 'RENDER_ROUTED_VIEW' + ? (renderCommand.uiViewPortalRegistration.viewConfig as Ng1ViewConfig) : undefined; const newScope = scope.$new(); @@ -384,20 +415,22 @@ function $ViewDirectiveFill( return function (scope: IScope, $element: JQuery) { const data: UIViewData = $element.data('$uiView') || {}; const { $renderCommand, $uiView } = data; - if (!$renderCommand || $renderCommand.command === 'RENDER_DEFAULT_CONTENT') { + if (!$renderCommand || $renderCommand.portalContentType === 'RENDER_DEFAULT_CONTENT') { $element.html(initial); $compile($element.contents() as any)(scope); return; - } else if ($renderCommand.command === 'RENDER_INTEROP_DIV') { + } else if ($renderCommand.portalContentType === 'RENDER_INTEROP_DIV') { $element.html('
'); $renderCommand.giveDiv($element.find('div')[0]); return; } - const cfg: Ng1ViewConfig = $renderCommand.routedViewConfig || ({ viewDecl: {}, getTemplate: noop } as any); + const { uiViewPortalRegistration } = $renderCommand; + const { viewConfig } = uiViewPortalRegistration; + const cfg: Ng1ViewConfig = viewConfig || ({ viewDecl: {}, getTemplate: noop } as any); const resolveCtx: ResolveContext = cfg.path && new ResolveContext(cfg.path); $element.html(cfg.getTemplate($element, resolveCtx) || initial); - trace.traceUIViewFill($uiView, $element.html()); + trace.traceUIViewFill(uiViewPortalRegistration as any, $element.html()); const link = $compile($element.contents() as any); const controller = cfg.controller as angular.IControllerService; diff --git a/test/stateSpec.ts b/test/stateSpec.ts index 6c9629a7d..ffc4fedf5 100644 --- a/test/stateSpec.ts +++ b/test/stateSpec.ts @@ -928,6 +928,7 @@ describe('state', function () { $rootScope, $compile ) { + debugger; $compile('
')($rootScope); $state.transitionTo('logA.logB.logC'); $q.flush(); diff --git a/yarn.lock b/yarn.lock index 3ba5c5fa9..7a5851e53 100644 --- a/yarn.lock +++ b/yarn.lock @@ -736,9 +736,9 @@ eslint-visitor-keys "^1.1.0" "@uirouter/core@v7beta": - version "7.0.0-beta.2" - resolved "https://registry.yarnpkg.com/@uirouter/core/-/core-7.0.0-beta.2.tgz#99669b70ef2b27066cc46f167caa1de1a505dcb9" - integrity sha512-ScY+H1n6lyEP5f78CTZlvc8eT5U5NRac0CAZQhy77ExLE4+zg0djyczsHR+omgNfAUndnSx4tqo+DbgjXZfUlw== + version "7.0.0-beta.3" + resolved "https://registry.yarnpkg.com/@uirouter/core/-/core-7.0.0-beta.3.tgz#a4df98267d5aa4f512b545cc1535f20192270f8e" + integrity sha512-T4UT0V2MgadE+Z/ZaB8bc/QhZdvw0foQWWb/BrVCxoKDZJMghxAk7/7PI3KGRTBvJkk+Py0n2INafwGlPH4M+w== "@uirouter/publish-scripts@2.5.5": version "2.5.5" From 7b31e84269020c87b80c3e4c46ac62339804163e Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Sun, 28 Mar 2021 09:42:16 -1000 Subject: [PATCH 8/9] feat(trace): remove internal approximateDigests code --- src/services.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/services.ts b/src/services.ts index 6d8decb35..c31df5e75 100644 --- a/src/services.ts +++ b/src/services.ts @@ -146,13 +146,6 @@ const getUrlRouterProvider = (uiRouter: UIRouter) => (uiRouter.urlRouterProvider // $urlRouter service and $urlRouterProvider const getStateProvider = () => extend(router.stateProvider, { $get: () => router.stateService }); -watchDigests.$inject = ['$rootScope']; -export function watchDigests($rootScope: IRootScopeService) { - $rootScope.$watch(function () { - trace.approximateDigests++; - }); -} - mod_init.provider('$uiRouter', $uiRouterProvider); mod_rtr.provider('$urlRouter', ['$uiRouterProvider', getUrlRouterProvider]); mod_util.provider('$urlService', getProviderFor('urlService')); @@ -167,7 +160,6 @@ mod_state.factory('$stateParams', ['$uiRouter', ($uiRouter: UIRouter) => $uiRout mod_main.factory('$view', () => router.viewService); mod_main.service('$trace', () => trace); -mod_main.run(watchDigests); mod_util.run(['$urlMatcherFactory', function ($urlMatcherFactory: UrlMatcherFactory) {}]); mod_state.run(['$state', function ($state: StateService) {}]); mod_rtr.run(['$urlRouter', function ($urlRouter: UrlRouter) {}]); From 1b0e1c489f57cf624d0ccf68df34d4d90a01bbb9 Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Sun, 28 Mar 2021 09:43:33 -1000 Subject: [PATCH 9/9] fix(trace): Switch to newer uirouter/core trace api --- src/directives/viewDirective.ts | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/directives/viewDirective.ts b/src/directives/viewDirective.ts index 1147a21df..452420792 100644 --- a/src/directives/viewDirective.ts +++ b/src/directives/viewDirective.ts @@ -1,6 +1,7 @@ /** @publicapi @module directives */ /** */ import { $QLike, + Category, extend, filter, HookRegOptions, @@ -8,6 +9,7 @@ import { isFunction, isString, kebobString, + maxLength, noop, Obj, Param, @@ -272,12 +274,14 @@ uiView = [ name, renderContentIntoUIViewPortal ); - // as any: trace requires the internal interface, hmmm... this isn't good - const registration = $view._pluginapi._registeredUIView(uiViewId) as any; - trace.traceUIViewEvent('Linking', registration); + + const traceUiViewEvent = (message: string, extra?: string) => + $view._pluginapi._traceUIViewEvent(uiViewId, message, extra); + + traceUiViewEvent('Linking'); scope.$on('$destroy', function () { - trace.traceUIViewEvent('Destroying/Unregistering', registration); + traceUiViewEvent('Destroying/Unregistering'); $view._pluginapi._deregisterView(uiViewId); }); @@ -286,20 +290,20 @@ uiView = [ function cleanupLastView() { if (previousEl) { - trace.traceUIViewEvent('Removing (previous) el', previousEl.data('$uiView')); + traceUiViewEvent('Removing (previous) el', previousEl.data('$uiView')); previousEl.remove(); previousEl = null; } if (currentScope) { - trace.traceUIViewEvent('Destroying scope', registration); + traceUiViewEvent('Destroying scope'); currentScope.$destroy(); currentScope = null; } if (currentEl) { const _viewData = currentEl.data('$uiViewAnim'); - trace.traceUIViewEvent('Animate out', _viewData); + traceUiViewEvent('Animate out', _viewData); renderer.leave(currentEl, function () { _viewData.$$animLeave.resolve(); previousEl = null; @@ -430,7 +434,10 @@ function $ViewDirectiveFill( const cfg: Ng1ViewConfig = viewConfig || ({ viewDecl: {}, getTemplate: noop } as any); const resolveCtx: ResolveContext = cfg.path && new ResolveContext(cfg.path); $element.html(cfg.getTemplate($element, resolveCtx) || initial); - trace.traceUIViewFill(uiViewPortalRegistration as any, $element.html()); + + if (trace.enabled(Category.UIVIEW)) { + $view._pluginapi._traceUIViewEvent($uiView.id as string, 'Fill', ` with: ${maxLength(200, $element.html())}`); + } const link = $compile($element.contents() as any); const controller = cfg.controller as angular.IControllerService;