1 line
36 KiB
Plaintext
1 line
36 KiB
Plaintext
{"version":3,"sources":["./node_modules/@ionic/core/dist/esm/ion-nav_2.entry.js"],"names":[],"mappings":";;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA6G;AACnC;AACtB;AACuH;AACjG;AACF;;AAExE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,yEAAe;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,8DAAM;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA,sBAAsB,OAAO,QAAQ,MAAM,SAAS,kBAAkB,0BAA0B,gBAAgB,UAAU;;AAE1H;AACA;AACA,IAAI,4DAAgB;AACpB,0BAA0B,4DAAW;AACrC,4BAA4B,4DAAW;AACvC,2BAA2B,4DAAW;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,mEAAU;AAC7B,0BAA0B,2DAAM;AAChC;AACA;AACA;AACA;AACA;AACA,0BAA0B,2NAAkC;AAC5D;AACA;AACA;AACA;AACA,MAAM,4DAAS,eAAe,oDAAqB;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,4BAA4B;AACjD;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,4BAA4B;AACjD;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,4BAA4B;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0EAA0E,gBAAgB,iDAAiD;AAC3I;AACA;AACA,qEAAqE,gBAAgB,8BAA8B;AACnH;AACA;AACA,wEAAwE,gBAAgB,iEAAiE;AACzJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,8DAAM;AACZ,MAAM,8DAAM;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,8DAAM;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,QAAQ;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,8DAAM;AACV,IAAI,8DAAM;AACV,IAAI,8DAAM;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,8DAAM;AACZ,MAAM,8DAAM;AACZ;AACA,qBAAqB,iBAAiB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,8DAAM;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,4DAAS,eAAe,oDAAoB;AACpD,QAAQ,4DAAS,eAAe,oDAAmB;AACnD,QAAQ,4DAAS,eAAe,oDAAqB;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,mEAAU;AAC3B;AACA;AACA,yCAAyC,mIAAmI,2DAAM,mEAAmE,2DAAM;AAC3P,iBAAiB;AACjB,WAAW,eAAe,SAAS,4DAAU;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,8DAAM;AACZ;AACA;AACA;AACA,MAAM,8DAAM;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,8DAAM;AACV;AACA;AACA,IAAI,8DAAM;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,QAAQ;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,4DAAS,UAAU,oDAAqB;AAClD;AACA;AACA;AACA;AACA;AACA,UAAU,4DAAa;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,GAAG,wBAAwB;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,mEAAuB;AAC/C;AACA;AACA,wBAAwB,mEAAuB;AAC/C;AACA;AACA;AACA;AACA;AACA,YAAY,4DAAC;AACb;AACA,YAAY,QAAQ,4DAAU,OAAO;AACrC,yBAAyB;AACzB;AACA;AACA,IAAI;AACJ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,oDAAoD,sDAAsD;AAC1G;AACA;AACA;AACA;AACA,uDAAuD,sDAAsD;AAC7G;AACA;AACA;AACA,sBAAsB,sDAAsD;AAC5E;AACA;AACA;AACA;;AAEA;AACA;AACA,IAAI,4DAAgB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,4DAAC,CAAC,oDAAI,GAAG,wBAAwB;AAC7C;AACA,YAAY,QAAQ,4DAAU,OAAO;AACrC;;AAEmD","file":"21-es2015.js","sourcesContent":["import { r as registerInstance, e as createEvent, h, i as getElement, H as Host } from './index-e806d1f6.js';\nimport { b as getIonMode, c as config } from './ionic-global-9d5c8ee3.js';\nimport { k as assert } from './helpers-90f46169.js';\nimport { l as lifecycle, t as transition, s as setPageHidden, d as LIFECYCLE_WILL_UNLOAD, b as LIFECYCLE_WILL_LEAVE, c as LIFECYCLE_DID_LEAVE } from './index-1eeeab2e.js';\nimport { g as getTimeGivenProgression } from './cubic-bezier-eea9a7a9.js';\nimport { a as attachComponent } from './framework-delegate-4584ab5a.js';\n\nconst VIEW_STATE_NEW = 1;\nconst VIEW_STATE_ATTACHED = 2;\nconst VIEW_STATE_DESTROYED = 3;\nclass ViewController {\n constructor(component, params) {\n this.component = component;\n this.params = params;\n this.state = VIEW_STATE_NEW;\n }\n async init(container) {\n this.state = VIEW_STATE_ATTACHED;\n if (!this.element) {\n const component = this.component;\n this.element = await attachComponent(this.delegate, container, component, ['ion-page', 'ion-page-invisible'], this.params);\n }\n }\n /**\n * DOM WRITE\n */\n _destroy() {\n assert(this.state !== VIEW_STATE_DESTROYED, 'view state must be ATTACHED');\n const element = this.element;\n if (element) {\n if (this.delegate) {\n this.delegate.removeViewFromDom(element.parentElement, element);\n }\n else {\n element.remove();\n }\n }\n this.nav = undefined;\n this.state = VIEW_STATE_DESTROYED;\n }\n}\nconst matches = (view, id, params) => {\n if (!view) {\n return false;\n }\n if (view.component !== id) {\n return false;\n }\n const currentParams = view.params;\n if (currentParams === params) {\n return true;\n }\n if (!currentParams && !params) {\n return true;\n }\n if (!currentParams || !params) {\n return false;\n }\n const keysA = Object.keys(currentParams);\n const keysB = Object.keys(params);\n if (keysA.length !== keysB.length) {\n return false;\n }\n // Test for A's keys different from B.\n for (const key of keysA) {\n if (currentParams[key] !== params[key]) {\n return false;\n }\n }\n return true;\n};\nconst convertToView = (page, params) => {\n if (!page) {\n return null;\n }\n if (page instanceof ViewController) {\n return page;\n }\n return new ViewController(page, params);\n};\nconst convertToViews = (pages) => {\n return pages.map(page => {\n if (page instanceof ViewController) {\n return page;\n }\n if ('component' in page) {\n /**\n * TODO Ionic 6:\n * Consider switching to just using `undefined` here\n * as well as on the public interfaces and on\n * `NavComponentWithProps`. Previously `pages` was\n * of type `any[]` so TypeScript did not catch this.\n */\n return convertToView(page.component, (page.componentProps === null) ? undefined : page.componentProps);\n }\n return convertToView(page, undefined);\n }).filter(v => v !== null);\n};\n\nconst navCss = \":host{left:0;right:0;top:0;bottom:0;position:absolute;contain:layout size style;overflow:hidden;z-index:0}\";\n\nconst Nav = class {\n constructor(hostRef) {\n registerInstance(this, hostRef);\n this.ionNavWillLoad = createEvent(this, \"ionNavWillLoad\", 7);\n this.ionNavWillChange = createEvent(this, \"ionNavWillChange\", 3);\n this.ionNavDidChange = createEvent(this, \"ionNavDidChange\", 3);\n this.transInstr = [];\n this.animationEnabled = true;\n this.useRouter = false;\n this.isTransitioning = false;\n this.destroyed = false;\n this.views = [];\n /**\n * If `true`, the nav should animate the transition of components.\n */\n this.animated = true;\n }\n swipeGestureChanged() {\n if (this.gesture) {\n this.gesture.enable(this.swipeGesture === true);\n }\n }\n rootChanged() {\n if (this.root !== undefined) {\n if (!this.useRouter) {\n this.setRoot(this.root, this.rootParams);\n }\n }\n }\n componentWillLoad() {\n this.useRouter =\n !!document.querySelector('ion-router') &&\n !this.el.closest('[no-router]');\n if (this.swipeGesture === undefined) {\n const mode = getIonMode(this);\n this.swipeGesture = config.getBoolean('swipeBackEnabled', mode === 'ios');\n }\n this.ionNavWillLoad.emit();\n }\n async componentDidLoad() {\n this.rootChanged();\n this.gesture = (await import('./swipe-back-2154c9a7.js')).createSwipeBackGesture(this.el, this.canStart.bind(this), this.onStart.bind(this), this.onMove.bind(this), this.onEnd.bind(this));\n this.swipeGestureChanged();\n }\n disconnectedCallback() {\n for (const view of this.views) {\n lifecycle(view.element, LIFECYCLE_WILL_UNLOAD);\n view._destroy();\n }\n if (this.gesture) {\n this.gesture.destroy();\n this.gesture = undefined;\n }\n // release swipe back gesture and transition\n this.transInstr.length = this.views.length = 0;\n this.destroyed = true;\n }\n /**\n * Push a new component onto the current navigation stack. Pass any additional\n * information along as an object. This additional information is accessible\n * through NavParams.\n *\n * @param component The component to push onto the navigation stack.\n * @param componentProps Any properties of the component.\n * @param opts The navigation options.\n * @param done The transition complete function.\n */\n push(component, componentProps, opts, done) {\n return this.queueTrns({\n insertStart: -1,\n insertViews: [{ component, componentProps }],\n opts\n }, done);\n }\n /**\n * Inserts a component into the navigation stack at the specified index.\n * This is useful to add a component at any point in the navigation stack.\n *\n * @param insertIndex The index to insert the component at in the stack.\n * @param component The component to insert into the navigation stack.\n * @param componentProps Any properties of the component.\n * @param opts The navigation options.\n * @param done The transition complete function.\n */\n insert(insertIndex, component, componentProps, opts, done) {\n return this.queueTrns({\n insertStart: insertIndex,\n insertViews: [{ component, componentProps }],\n opts\n }, done);\n }\n /**\n * Inserts an array of components into the navigation stack at the specified index.\n * The last component in the array will become instantiated as a view, and animate\n * in to become the active view.\n *\n * @param insertIndex The index to insert the components at in the stack.\n * @param insertComponents The components to insert into the navigation stack.\n * @param opts The navigation options.\n * @param done The transition complete function.\n */\n insertPages(insertIndex, insertComponents, opts, done) {\n return this.queueTrns({\n insertStart: insertIndex,\n insertViews: insertComponents,\n opts\n }, done);\n }\n /**\n * Pop a component off of the navigation stack. Navigates back from the current\n * component.\n *\n * @param opts The navigation options.\n * @param done The transition complete function.\n */\n pop(opts, done) {\n return this.queueTrns({\n removeStart: -1,\n removeCount: 1,\n opts\n }, done);\n }\n /**\n * Pop to a specific index in the navigation stack.\n *\n * @param indexOrViewCtrl The index or view controller to pop to.\n * @param opts The navigation options.\n * @param done The transition complete function.\n */\n popTo(indexOrViewCtrl, opts, done) {\n const tiConfig = {\n removeStart: -1,\n removeCount: -1,\n opts\n };\n if (typeof indexOrViewCtrl === 'object' && indexOrViewCtrl.component) {\n tiConfig.removeView = indexOrViewCtrl;\n tiConfig.removeStart = 1;\n }\n else if (typeof indexOrViewCtrl === 'number') {\n tiConfig.removeStart = indexOrViewCtrl + 1;\n }\n return this.queueTrns(tiConfig, done);\n }\n /**\n * Navigate back to the root of the stack, no matter how far back that is.\n *\n * @param opts The navigation options.\n * @param done The transition complete function.\n */\n popToRoot(opts, done) {\n return this.queueTrns({\n removeStart: 1,\n removeCount: -1,\n opts\n }, done);\n }\n /**\n * Removes a component from the navigation stack at the specified index.\n *\n * @param startIndex The number to begin removal at.\n * @param removeCount The number of components to remove.\n * @param opts The navigation options.\n * @param done The transition complete function.\n */\n removeIndex(startIndex, removeCount = 1, opts, done) {\n return this.queueTrns({\n removeStart: startIndex,\n removeCount,\n opts\n }, done);\n }\n /**\n * Set the root for the current navigation stack to a component.\n *\n * @param component The component to set as the root of the navigation stack.\n * @param componentProps Any properties of the component.\n * @param opts The navigation options.\n * @param done The transition complete function.\n */\n setRoot(component, componentProps, opts, done) {\n return this.setPages([{ component, componentProps }], opts, done);\n }\n /**\n * Set the views of the current navigation stack and navigate to the last view.\n * By default animations are disabled, but they can be enabled by passing options\n * to the navigation controller. Navigation parameters can also be passed to the\n * individual pages in the array.\n *\n * @param views The list of views to set as the navigation stack.\n * @param opts The navigation options.\n * @param done The transition complete function.\n */\n setPages(views, opts, done) {\n if (opts == null) {\n opts = {};\n }\n // if animation wasn't set to true then default it to NOT animate\n if (opts.animated !== true) {\n opts.animated = false;\n }\n return this.queueTrns({\n insertStart: 0,\n insertViews: views,\n removeStart: 0,\n removeCount: -1,\n opts\n }, done);\n }\n /** @internal */\n setRouteId(id, params, direction, animation) {\n const active = this.getActiveSync();\n if (matches(active, id, params)) {\n return Promise.resolve({\n changed: false,\n element: active.element\n });\n }\n let resolve;\n const promise = new Promise(r => (resolve = r));\n let finish;\n const commonOpts = {\n updateURL: false,\n viewIsReady: enteringEl => {\n let mark;\n const p = new Promise(r => (mark = r));\n resolve({\n changed: true,\n element: enteringEl,\n markVisible: async () => {\n mark();\n await finish;\n }\n });\n return p;\n }\n };\n if (direction === 'root') {\n finish = this.setRoot(id, params, commonOpts);\n }\n else {\n const viewController = this.views.find(v => matches(v, id, params));\n if (viewController) {\n finish = this.popTo(viewController, Object.assign(Object.assign({}, commonOpts), { direction: 'back', animationBuilder: animation }));\n }\n else if (direction === 'forward') {\n finish = this.push(id, params, Object.assign(Object.assign({}, commonOpts), { animationBuilder: animation }));\n }\n else if (direction === 'back') {\n finish = this.setRoot(id, params, Object.assign(Object.assign({}, commonOpts), { direction: 'back', animated: true, animationBuilder: animation }));\n }\n }\n return promise;\n }\n /** @internal */\n async getRouteId() {\n const active = this.getActiveSync();\n return active\n ? {\n id: active.element.tagName,\n params: active.params,\n element: active.element\n }\n : undefined;\n }\n /**\n * Get the active view.\n */\n getActive() {\n return Promise.resolve(this.getActiveSync());\n }\n /**\n * Get the view at the specified index.\n *\n * @param index The index of the view.\n */\n getByIndex(index) {\n return Promise.resolve(this.views[index]);\n }\n /**\n * Returns `true` if the current view can go back.\n *\n * @param view The view to check.\n */\n canGoBack(view) {\n return Promise.resolve(this.canGoBackSync(view));\n }\n /**\n * Get the previous view.\n *\n * @param view The view to get.\n */\n getPrevious(view) {\n return Promise.resolve(this.getPreviousSync(view));\n }\n getLength() {\n return this.views.length;\n }\n getActiveSync() {\n return this.views[this.views.length - 1];\n }\n canGoBackSync(view = this.getActiveSync()) {\n return !!(view && this.getPreviousSync(view));\n }\n getPreviousSync(view = this.getActiveSync()) {\n if (!view) {\n return undefined;\n }\n const views = this.views;\n const index = views.indexOf(view);\n return index > 0 ? views[index - 1] : undefined;\n }\n // _queueTrns() adds a navigation stack change to the queue and schedules it to run:\n // 1. _nextTrns(): consumes the next transition in the queue\n // 2. _viewInit(): initializes enteringView if required\n // 3. _viewTest(): ensures canLeave/canEnter Returns `true`, so the operation can continue\n // 4. _postViewInit(): add/remove the views from the navigation stack\n // 5. _transitionInit(): initializes the visual transition if required and schedules it to run\n // 6. _viewAttachToDOM(): attaches the enteringView to the DOM\n // 7. _transitionStart(): called once the transition actually starts, it initializes the Animation underneath.\n // 8. _transitionFinish(): called once the transition finishes\n // 9. _cleanup(): syncs the navigation internal state with the DOM. For example it removes the pages from the DOM or hides/show them.\n async queueTrns(ti, done) {\n if (this.isTransitioning && ti.opts != null && ti.opts.skipIfBusy) {\n return Promise.resolve(false);\n }\n const promise = new Promise((resolve, reject) => {\n ti.resolve = resolve;\n ti.reject = reject;\n });\n ti.done = done;\n /**\n * If using router, check to see if navigation hooks\n * will allow us to perform this transition. This\n * is required in order for hooks to work with\n * the ion-back-button or swipe to go back.\n */\n if (ti.opts && ti.opts.updateURL !== false && this.useRouter) {\n const router = document.querySelector('ion-router');\n if (router) {\n const canTransition = await router.canTransition();\n if (canTransition === false) {\n return Promise.resolve(false);\n }\n else if (typeof canTransition === 'string') {\n router.push(canTransition, ti.opts.direction || 'back');\n return Promise.resolve(false);\n }\n }\n }\n // Normalize empty\n if (ti.insertViews && ti.insertViews.length === 0) {\n ti.insertViews = undefined;\n }\n // Enqueue transition instruction\n this.transInstr.push(ti);\n // if there isn't a transition already happening\n // then this will kick off this transition\n this.nextTrns();\n return promise;\n }\n success(result, ti) {\n if (this.destroyed) {\n this.fireError('nav controller was destroyed', ti);\n return;\n }\n if (ti.done) {\n ti.done(result.hasCompleted, result.requiresTransition, result.enteringView, result.leavingView, result.direction);\n }\n ti.resolve(result.hasCompleted);\n if (ti.opts.updateURL !== false && this.useRouter) {\n const router = document.querySelector('ion-router');\n if (router) {\n const direction = result.direction === 'back' ? 'back' : 'forward';\n router.navChanged(direction);\n }\n }\n }\n failed(rejectReason, ti) {\n if (this.destroyed) {\n this.fireError('nav controller was destroyed', ti);\n return;\n }\n this.transInstr.length = 0;\n this.fireError(rejectReason, ti);\n }\n fireError(rejectReason, ti) {\n if (ti.done) {\n ti.done(false, false, rejectReason);\n }\n if (ti.reject && !this.destroyed) {\n ti.reject(rejectReason);\n }\n else {\n ti.resolve(false);\n }\n }\n nextTrns() {\n // this is the framework's bread 'n butta function\n // only one transition is allowed at any given time\n if (this.isTransitioning) {\n return false;\n }\n // there is no transition happening right now\n // get the next instruction\n const ti = this.transInstr.shift();\n if (!ti) {\n return false;\n }\n this.runTransition(ti);\n return true;\n }\n async runTransition(ti) {\n try {\n // set that this nav is actively transitioning\n this.ionNavWillChange.emit();\n this.isTransitioning = true;\n this.prepareTI(ti);\n const leavingView = this.getActiveSync();\n const enteringView = this.getEnteringView(ti, leavingView);\n if (!leavingView && !enteringView) {\n throw new Error('no views in the stack to be removed');\n }\n if (enteringView && enteringView.state === VIEW_STATE_NEW) {\n await enteringView.init(this.el);\n }\n this.postViewInit(enteringView, leavingView, ti);\n // Needs transition?\n const requiresTransition = (ti.enteringRequiresTransition || ti.leavingRequiresTransition) &&\n enteringView !== leavingView;\n if (requiresTransition && ti.opts && leavingView) {\n const isBackDirection = ti.opts.direction === 'back';\n /**\n * If heading back, use the entering page's animation\n * unless otherwise specified by the developer.\n */\n if (isBackDirection) {\n ti.opts.animationBuilder = ti.opts.animationBuilder || (enteringView && enteringView.animationBuilder);\n }\n leavingView.animationBuilder = ti.opts.animationBuilder;\n }\n const result = requiresTransition\n ? await this.transition(enteringView, leavingView, ti)\n : {\n // transition is not required, so we are already done!\n // they're inserting/removing the views somewhere in the middle or\n // beginning, so visually nothing needs to animate/transition\n // resolve immediately because there's no animation that's happening\n hasCompleted: true,\n requiresTransition: false\n };\n this.success(result, ti);\n this.ionNavDidChange.emit();\n }\n catch (rejectReason) {\n this.failed(rejectReason, ti);\n }\n this.isTransitioning = false;\n this.nextTrns();\n }\n prepareTI(ti) {\n const viewsLength = this.views.length;\n ti.opts = ti.opts || {};\n if (ti.opts.delegate === undefined) {\n ti.opts.delegate = this.delegate;\n }\n if (ti.removeView !== undefined) {\n assert(ti.removeStart !== undefined, 'removeView needs removeStart');\n assert(ti.removeCount !== undefined, 'removeView needs removeCount');\n const index = this.views.indexOf(ti.removeView);\n if (index < 0) {\n throw new Error('removeView was not found');\n }\n ti.removeStart += index;\n }\n if (ti.removeStart !== undefined) {\n if (ti.removeStart < 0) {\n ti.removeStart = viewsLength - 1;\n }\n if (ti.removeCount < 0) {\n ti.removeCount = viewsLength - ti.removeStart;\n }\n ti.leavingRequiresTransition =\n ti.removeCount > 0 && ti.removeStart + ti.removeCount === viewsLength;\n }\n if (ti.insertViews) {\n // allow -1 to be passed in to auto push it on the end\n // and clean up the index if it's larger then the size of the stack\n if (ti.insertStart < 0 || ti.insertStart > viewsLength) {\n ti.insertStart = viewsLength;\n }\n ti.enteringRequiresTransition = ti.insertStart === viewsLength;\n }\n const insertViews = ti.insertViews;\n if (!insertViews) {\n return;\n }\n assert(insertViews.length > 0, 'length can not be zero');\n const viewControllers = convertToViews(insertViews);\n if (viewControllers.length === 0) {\n throw new Error('invalid views to insert');\n }\n // Check all the inserted view are correct\n for (const view of viewControllers) {\n view.delegate = ti.opts.delegate;\n const nav = view.nav;\n if (nav && nav !== this) {\n throw new Error('inserted view was already inserted');\n }\n if (view.state === VIEW_STATE_DESTROYED) {\n throw new Error('inserted view was already destroyed');\n }\n }\n ti.insertViews = viewControllers;\n }\n getEnteringView(ti, leavingView) {\n const insertViews = ti.insertViews;\n if (insertViews !== undefined) {\n // grab the very last view of the views to be inserted\n // and initialize it as the new entering view\n return insertViews[insertViews.length - 1];\n }\n const removeStart = ti.removeStart;\n if (removeStart !== undefined) {\n const views = this.views;\n const removeEnd = removeStart + ti.removeCount;\n for (let i = views.length - 1; i >= 0; i--) {\n const view = views[i];\n if ((i < removeStart || i >= removeEnd) && view !== leavingView) {\n return view;\n }\n }\n }\n return undefined;\n }\n postViewInit(enteringView, leavingView, ti) {\n assert(leavingView || enteringView, 'Both leavingView and enteringView are null');\n assert(ti.resolve, 'resolve must be valid');\n assert(ti.reject, 'reject must be valid');\n const opts = ti.opts;\n const insertViews = ti.insertViews;\n const removeStart = ti.removeStart;\n const removeCount = ti.removeCount;\n let destroyQueue;\n // there are views to remove\n if (removeStart !== undefined && removeCount !== undefined) {\n assert(removeStart >= 0, 'removeStart can not be negative');\n assert(removeCount >= 0, 'removeCount can not be negative');\n destroyQueue = [];\n for (let i = 0; i < removeCount; i++) {\n const view = this.views[i + removeStart];\n if (view && view !== enteringView && view !== leavingView) {\n destroyQueue.push(view);\n }\n }\n // default the direction to \"back\"\n opts.direction = opts.direction || 'back';\n }\n const finalBalance = this.views.length +\n (insertViews !== undefined ? insertViews.length : 0) -\n (removeCount !== undefined ? removeCount : 0);\n assert(finalBalance >= 0, 'final balance can not be negative');\n if (finalBalance === 0) {\n console.warn(`You can't remove all the pages in the navigation stack. nav.pop() is probably called too many times.`, this, this.el);\n throw new Error('navigation stack needs at least one root page');\n }\n // At this point the transition can not be rejected, any throw should be an error\n // there are views to insert\n if (insertViews) {\n // add the views to the\n let insertIndex = ti.insertStart;\n for (const view of insertViews) {\n this.insertViewAt(view, insertIndex);\n insertIndex++;\n }\n if (ti.enteringRequiresTransition) {\n // default to forward if not already set\n opts.direction = opts.direction || 'forward';\n }\n }\n // if the views to be removed are in the beginning or middle\n // and there is not a view that needs to visually transition out\n // then just destroy them and don't transition anything\n // batch all of lifecycles together\n // let's make sure, callbacks are zoned\n if (destroyQueue && destroyQueue.length > 0) {\n for (const view of destroyQueue) {\n lifecycle(view.element, LIFECYCLE_WILL_LEAVE);\n lifecycle(view.element, LIFECYCLE_DID_LEAVE);\n lifecycle(view.element, LIFECYCLE_WILL_UNLOAD);\n }\n // once all lifecycle events has been delivered, we can safely detroy the views\n for (const view of destroyQueue) {\n this.destroyView(view);\n }\n }\n }\n async transition(enteringView, leavingView, ti) {\n // we should animate (duration > 0) if the pushed page is not the first one (startup)\n // or if it is a portal (modal, actionsheet, etc.)\n const opts = ti.opts;\n const progressCallback = opts.progressAnimation\n ? (ani) => this.sbAni = ani\n : undefined;\n const mode = getIonMode(this);\n const enteringEl = enteringView.element;\n const leavingEl = leavingView && leavingView.element;\n const animationOpts = Object.assign({ mode, showGoBack: this.canGoBackSync(enteringView), baseEl: this.el, animationBuilder: this.animation || opts.animationBuilder || config.get('navAnimation'), progressCallback, animated: this.animated && config.getBoolean('animated', true), enteringEl,\n leavingEl }, opts);\n const { hasCompleted } = await transition(animationOpts);\n return this.transitionFinish(hasCompleted, enteringView, leavingView, opts);\n }\n transitionFinish(hasCompleted, enteringView, leavingView, opts) {\n const cleanupView = hasCompleted ? enteringView : leavingView;\n if (cleanupView) {\n this.cleanup(cleanupView);\n }\n return {\n hasCompleted,\n requiresTransition: true,\n enteringView,\n leavingView,\n direction: opts.direction\n };\n }\n insertViewAt(view, index) {\n const views = this.views;\n const existingIndex = views.indexOf(view);\n if (existingIndex > -1) {\n // this view is already in the stack!!\n // move it to its new location\n assert(view.nav === this, 'view is not part of the nav');\n views.splice(index, 0, views.splice(existingIndex, 1)[0]);\n }\n else {\n assert(!view.nav, 'nav is used');\n // this is a new view to add to the stack\n // create the new entering view\n view.nav = this;\n // insert the entering view into the correct index in the stack\n views.splice(index, 0, view);\n }\n }\n removeView(view) {\n assert(view.state === VIEW_STATE_ATTACHED || view.state === VIEW_STATE_DESTROYED, 'view state should be loaded or destroyed');\n const views = this.views;\n const index = views.indexOf(view);\n assert(index > -1, 'view must be part of the stack');\n if (index >= 0) {\n views.splice(index, 1);\n }\n }\n destroyView(view) {\n view._destroy();\n this.removeView(view);\n }\n /**\n * DOM WRITE\n */\n cleanup(activeView) {\n // ok, cleanup time!! Destroy all of the views that are\n // INACTIVE and come after the active view\n // only do this if the views exist, though\n if (this.destroyed) {\n return;\n }\n const views = this.views;\n const activeViewIndex = views.indexOf(activeView);\n for (let i = views.length - 1; i >= 0; i--) {\n const view = views[i];\n /**\n * When inserting multiple views via insertPages\n * the last page will be transitioned to, but the\n * others will not be. As a result, a DOM element\n * will only be created for the last page inserted.\n * As a result, it is possible to have views in the\n * stack that do not have `view.element` yet.\n */\n const element = view.element;\n if (element) {\n if (i > activeViewIndex) {\n // this view comes after the active view\n // let's unload it\n lifecycle(element, LIFECYCLE_WILL_UNLOAD);\n this.destroyView(view);\n }\n else if (i < activeViewIndex) {\n // this view comes before the active view\n // and it is not a portal then ensure it is hidden\n setPageHidden(element, true);\n }\n }\n }\n }\n canStart() {\n return (!!this.swipeGesture &&\n !this.isTransitioning &&\n this.transInstr.length === 0 &&\n this.animationEnabled &&\n this.canGoBackSync());\n }\n onStart() {\n this.queueTrns({\n removeStart: -1,\n removeCount: 1,\n opts: {\n direction: 'back',\n progressAnimation: true\n }\n }, undefined);\n }\n onMove(stepValue) {\n if (this.sbAni) {\n this.sbAni.progressStep(stepValue);\n }\n }\n onEnd(shouldComplete, stepValue, dur) {\n if (this.sbAni) {\n this.animationEnabled = false;\n this.sbAni.onFinish(() => {\n this.animationEnabled = true;\n }, { oneTimeCallback: true });\n // Account for rounding errors in JS\n let newStepValue = (shouldComplete) ? -0.001 : 0.001;\n /**\n * Animation will be reversed here, so need to\n * reverse the easing curve as well\n *\n * Additionally, we need to account for the time relative\n * to the new easing curve, as `stepValue` is going to be given\n * in terms of a linear curve.\n */\n if (!shouldComplete) {\n this.sbAni.easing('cubic-bezier(1, 0, 0.68, 0.28)');\n newStepValue += getTimeGivenProgression([0, 0], [1, 0], [0.68, 0.28], [1, 1], stepValue)[0];\n }\n else {\n newStepValue += getTimeGivenProgression([0, 0], [0.32, 0.72], [0, 1], [1, 1], stepValue)[0];\n }\n this.sbAni.progressEnd(shouldComplete ? 1 : 0, newStepValue, dur);\n }\n }\n render() {\n return (h(\"slot\", null));\n }\n get el() { return getElement(this); }\n static get watchers() { return {\n \"swipeGesture\": [\"swipeGestureChanged\"],\n \"root\": [\"rootChanged\"]\n }; }\n};\nNav.style = navCss;\n\nconst navLink = (el, routerDirection, component, componentProps, routerAnimation) => {\n const nav = el.closest('ion-nav');\n if (nav) {\n if (routerDirection === 'forward') {\n if (component !== undefined) {\n return nav.push(component, componentProps, { skipIfBusy: true, animationBuilder: routerAnimation });\n }\n }\n else if (routerDirection === 'root') {\n if (component !== undefined) {\n return nav.setRoot(component, componentProps, { skipIfBusy: true, animationBuilder: routerAnimation });\n }\n }\n else if (routerDirection === 'back') {\n return nav.pop({ skipIfBusy: true, animationBuilder: routerAnimation });\n }\n }\n return Promise.resolve(false);\n};\n\nconst NavLink = class {\n constructor(hostRef) {\n registerInstance(this, hostRef);\n /**\n * The transition direction when navigating to another page.\n */\n this.routerDirection = 'forward';\n this.onClick = () => {\n return navLink(this.el, this.routerDirection, this.component, this.componentProps, this.routerAnimation);\n };\n }\n render() {\n return (h(Host, { onClick: this.onClick }));\n }\n get el() { return getElement(this); }\n};\n\nexport { Nav as ion_nav, NavLink as ion_nav_link };\n"],"sourceRoot":"webpack:///"} |