uicore-ts 1.1.387 → 1.1.388

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -182,6 +182,7 @@ const _UIRoute = class extends Array {
182
182
  targetHistoryPosition2 = targetHistoryPosition2 + 1;
183
183
  }
184
184
  _UIRoute._recordPresentedRouteAtHistoryPosition(targetRoute, targetHistoryPosition2);
185
+ reapplyCurrentRoute();
185
186
  return;
186
187
  }
187
188
  const targetHistoryPosition = _UIRoute._historyPositionFromCurrentEntry();
@@ -191,10 +192,12 @@ const _UIRoute = class extends Array {
191
192
  untaggedHistoryPosition = untaggedHistoryPosition + 1;
192
193
  }
193
194
  _UIRoute._recordPresentedRouteAtHistoryPosition(targetRoute, untaggedHistoryPosition);
195
+ reapplyCurrentRoute();
194
196
  return;
195
197
  }
196
198
  if (targetHistoryPosition === _UIRoute._presentedHistoryPosition) {
197
199
  _UIRoute._recordPresentedRouteAtHistoryPosition(targetRoute, targetHistoryPosition);
200
+ reapplyCurrentRoute();
198
201
  return;
199
202
  }
200
203
  event.stopImmediatePropagation();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../scripts/UIRoute.ts"],
4
- "sourcesContent": ["import { IS_NIL, IS_NOT, NO, ValueOf, YES } from \"./UIObject\"\nimport { UIViewController } from \"./UIViewController\"\n\n\nexport type PropType<TObj, TProp extends keyof TObj> = TObj[TProp];\n\nexport type UIRouteParameters<T = any> = {\n \n [key: string]: string;\n \n} | T;\n\n\nexport interface UIRouteComponent<T = any> {\n \n name: string;\n parameters: UIRouteParameters<T>;\n \n}\n\n\nexport interface UIRouteChangeDescriptor {\n \n currentRoute: UIRoute;\n targetRoute: UIRoute;\n forcefully: boolean;\n replacesCurrentRouteInHistory: boolean;\n \n}\n\n\nexport type UIRouteShouldApplyRouteChangeCallbackFunction = (\n routeChangeDescriptor: UIRouteChangeDescriptor\n) => boolean | Promise<boolean>;\n\n\nconst historyPositionStateKey = \"uiRouteHistoryPosition\"\n\n\nexport class UIRoute extends Array<UIRouteComponent> {\n \n static shouldApplyRouteChange?: UIRouteShouldApplyRouteChangeCallbackFunction\n \n // Native Back/Forward navigation fires `hashchange` directly, bypassing\n // `apply()` and therefore `shouldApplyRouteChange` - the fields and\n // methods below (installed via `_installNativeHistoryNavigationGuard`)\n // close that gap by tagging every history entry with a running position,\n // so a native traversal can be told apart from this class's own hash\n // mutations and, when declined, undone with `history.go(...)`.\n static _presentedRoute: UIRoute = new UIRoute()\n static _presentedHistoryPosition = 0\n static _recordedHistoryLength = 0\n static _selfInitiatedRouteChange?: UIRouteChangeDescriptor\n static _nativeHistoryNavigationGeneration = 0\n \n constructor(hash?: string) {\n \n super()\n \n if (!hash || !hash.startsWith) {\n \n return\n \n }\n \n if (hash.startsWith(\"#\")) {\n hash = hash.slice(1)\n }\n \n hash = decodeURIComponent(hash)\n \n const components = hash.split(\"]\")\n components.forEach(component => {\n \n const componentName = component.split(\"[\")[0]\n const parameters: Record<string, string> = {}\n \n if (!componentName) {\n return\n }\n \n const parametersString = component.split(\"[\")[1] || \"\"\n const parameterPairStrings = parametersString.split(\",\") || []\n \n parameterPairStrings.forEach(pairString => {\n \n const keyAndValueArray = pairString.split(\":\")\n const key = decodeURIComponent(keyAndValueArray[0])\n const value = decodeURIComponent(keyAndValueArray[1])\n \n if (key) {\n parameters[key] = value\n }\n \n })\n \n \n this.push({\n name: componentName,\n parameters: parameters\n })\n \n })\n \n \n }\n \n \n static get currentRoute() {\n\n return new UIRoute(window.location.hash)\n\n }\n\n\n /**\n * @param forcefully When `true`, applies the route even if its string\n * representation is identical to the current URL hash, causing the browser\n * to fire a `hashchange` event and re-run the full `handleRoute` flow.\n * Use this only when you explicitly need re-entrant navigation (e.g. the\n * \"tap the already-active tab to reset to root\" feature in TopBarView).\n * Defaults to `false`.\n */\n apply(forcefully = NO): boolean | Promise<boolean> {\n \n return this._applyRouteAfterRouteChangeApproval(forcefully, NO)\n \n }\n \n \n /**\n * Applies this route without consulting `UIRoute.shouldApplyRouteChange`.\n * Use this only for route changes that are internal bookkeeping or that already\n * passed a higher-level confirmation flow.\n */\n applyWithoutRouteChangeApproval(forcefully = NO): boolean {\n \n return this._applyRouteWithoutRouteChangeApproval(forcefully, NO)\n \n }\n \n \n /**\n * @param forcefully When `true`, replaces the current history entry with\n * this route even when the route is identical to the current URL hash.\n * Defaults to `false`.\n */\n applyByReplacingCurrentRouteInHistory(forcefully = NO): boolean | Promise<boolean> {\n \n return this._applyRouteAfterRouteChangeApproval(forcefully, YES)\n \n }\n \n \n /**\n * Replaces the current history entry without consulting\n * `UIRoute.shouldApplyRouteChange`.\n */\n applyByReplacingCurrentRouteInHistoryWithoutRouteChangeApproval(forcefully = NO): boolean {\n \n return this._applyRouteWithoutRouteChangeApproval(forcefully, YES)\n \n }\n \n \n _applyRouteAfterRouteChangeApproval(\n forcefully: boolean,\n replacesCurrentRouteInHistory: boolean\n ): boolean | Promise<boolean> {\n \n if (!this._needsRouteChange(forcefully)) {\n return NO\n }\n \n const shouldApplyRouteChange = UIRoute.shouldApplyRouteChange\n if (!shouldApplyRouteChange) {\n return this._applyRouteWithoutRouteChangeApproval(forcefully, replacesCurrentRouteInHistory)\n }\n \n const shouldProceed = shouldApplyRouteChange(\n this._routeChangeDescriptor(forcefully, replacesCurrentRouteInHistory)\n )\n \n if (shouldProceed instanceof Promise) {\n return shouldProceed.then(isRouteChangeApproved => {\n return this._applyRouteIfAllowed(\n isRouteChangeApproved,\n forcefully,\n replacesCurrentRouteInHistory\n )\n })\n }\n \n return this._applyRouteIfAllowed(shouldProceed, forcefully, replacesCurrentRouteInHistory)\n \n }\n \n \n _applyRouteIfAllowed(\n isRouteChangeApproved: boolean,\n forcefully: boolean,\n replacesCurrentRouteInHistory: boolean\n ): boolean {\n \n if (!isRouteChangeApproved) {\n return NO\n }\n \n return this._applyRouteWithoutRouteChangeApproval(forcefully, replacesCurrentRouteInHistory)\n \n }\n \n \n _applyRouteWithoutRouteChangeApproval(\n forcefully: boolean,\n replacesCurrentRouteInHistory: boolean\n ): boolean {\n \n if (!this._needsRouteChange(forcefully)) {\n return NO\n }\n\n // Tags the hashchange this is about to cause as this class's own\n // doing, so `_hashDidChange` can tell it apart from a native\n // Back/Forward traversal instead of falling back to guessing from\n // `window.history.length`.\n UIRoute._selfInitiatedRouteChange = this._routeChangeDescriptor(forcefully, replacesCurrentRouteInHistory)\n\n if (replacesCurrentRouteInHistory) {\n window.location.replace(this.linkRepresentation)\n }\n else {\n window.location.hash = this.stringRepresentation\n }\n\n return YES\n\n }\n \n \n _needsRouteChange(forcefully: boolean): boolean {\n \n if (!forcefully && new UIRoute(window.location.hash).stringRepresentation == this.stringRepresentation) {\n return NO\n }\n \n return YES\n \n }\n \n \n _routeChangeDescriptor(forcefully: boolean, replacesCurrentRouteInHistory: boolean): UIRouteChangeDescriptor {\n \n return {\n currentRoute: UIRoute.currentRoute,\n targetRoute: this.copy(),\n forcefully: forcefully,\n replacesCurrentRouteInHistory: replacesCurrentRouteInHistory\n }\n\n }\n\n\n /**\n * Installs handling so that native browser Back/Forward navigation\n * consults `shouldApplyRouteChange` the same way `apply()` does, instead\n * of silently bypassing it. Call exactly once, from `UICore`'s\n * constructor.\n *\n * @param reapplyCurrentRoute Re-runs route handling for `UIRoute.currentRoute`.\n * Called once a native navigation is allowed to proceed (or is self-initiated),\n * so its effect actually appears on screen.\n */\n static _installNativeHistoryNavigationGuard(reapplyCurrentRoute: () => void | Promise<void>) {\n\n UIRoute._recordPresentedRouteAtHistoryPosition(\n UIRoute.currentRoute,\n UIRoute._historyPositionFromCurrentEntry() ?? 0\n )\n\n window.addEventListener(\"hashchange\", event =>\n UIRoute._hashDidChange(event, reapplyCurrentRoute)\n )\n\n }\n\n\n static _historyPositionFromCurrentEntry(): number | undefined {\n\n const historyPosition = (window.history.state as Record<string, unknown> | null)?.[historyPositionStateKey]\n if (typeof historyPosition !== \"number\") {\n return undefined\n }\n return historyPosition\n\n }\n\n\n static _recordPresentedRouteAtHistoryPosition(route: UIRoute, historyPosition: number) {\n\n const historyState = Object.assign({}, window.history.state)\n historyState[historyPositionStateKey] = historyPosition\n window.history.replaceState(historyState, \"\")\n\n UIRoute._presentedRoute = route.copy()\n UIRoute._presentedHistoryPosition = historyPosition\n UIRoute._recordedHistoryLength = window.history.length\n\n }\n\n\n /**\n * The single listener installed for every `hashchange` - self-initiated,\n * native Back/Forward, or an untagged bypass (see the class-level comment\n * above `_presentedRoute`) - and the point where those three cases are\n * told apart.\n *\n * @param event The native event. Only used to call\n * `stopImmediatePropagation()` when a native traversal needs to be held\n * back pending `shouldApplyRouteChange`, so `UICore`'s own route handling\n * doesn't run before that check settles.\n * @param reapplyCurrentRoute Forwarded to `_applyHistoryNavigationToRouteAtPositionIfAllowed`\n * - see its own doc comment.\n */\n static _hashDidChange(event: HashChangeEvent, reapplyCurrentRoute: () => void | Promise<void>) {\n\n const targetRoute = UIRoute.currentRoute\n const selfInitiatedRouteChange = UIRoute._selfInitiatedRouteChange\n UIRoute._selfInitiatedRouteChange = undefined\n\n if (\n selfInitiatedRouteChange &&\n selfInitiatedRouteChange.targetRoute.stringRepresentation === targetRoute.stringRepresentation\n ) {\n\n let targetHistoryPosition = UIRoute._presentedHistoryPosition\n if (!selfInitiatedRouteChange.replacesCurrentRouteInHistory) {\n targetHistoryPosition = targetHistoryPosition + 1\n }\n UIRoute._recordPresentedRouteAtHistoryPosition(targetRoute, targetHistoryPosition)\n return\n\n }\n\n const targetHistoryPosition = UIRoute._historyPositionFromCurrentEntry()\n if (targetHistoryPosition === undefined) {\n\n // A hash mutation that bypassed this class entirely (e.g. a\n // direct `window.location.hash = ...` assignment) produces an\n // untagged entry. A larger native history length means it was\n // pushed; an unchanged length means the current entry was\n // replaced. Preserve both established escape hatches while\n // bringing the entry into this sequence.\n let untaggedHistoryPosition = UIRoute._presentedHistoryPosition\n if (window.history.length > UIRoute._recordedHistoryLength) {\n untaggedHistoryPosition = untaggedHistoryPosition + 1\n }\n UIRoute._recordPresentedRouteAtHistoryPosition(targetRoute, untaggedHistoryPosition)\n return\n\n }\n if (targetHistoryPosition === UIRoute._presentedHistoryPosition) {\n UIRoute._recordPresentedRouteAtHistoryPosition(targetRoute, targetHistoryPosition)\n return\n }\n\n event.stopImmediatePropagation()\n const navigationGeneration = ++UIRoute._nativeHistoryNavigationGeneration\n UIRoute._applyHistoryNavigationToRouteAtPositionIfAllowed(\n targetRoute,\n targetHistoryPosition,\n navigationGeneration,\n reapplyCurrentRoute\n ).catch(error => {\n console.error(\"UIRoute: native history navigation check failed\", error)\n })\n\n }\n\n\n /**\n * Consults `shouldApplyRouteChange` for a native Back/Forward traversal,\n * exactly like `apply()` does for a programmatic one, then either lets it\n * through or reverts it with `history.go(...)`.\n *\n * @param targetRoute The route the native traversal is asking to move to.\n * @param targetHistoryPosition That route's tagged position, used both to\n * revert (`history.go`) and to detect a newer navigation arriving mid-check.\n * @param navigationGeneration A token captured by the caller at dispatch\n * time. If it no longer matches `_nativeHistoryNavigationGeneration` by\n * the time `shouldApplyRouteChange` resolves, a newer navigation has\n * superseded this one and this check's result is discarded.\n * @param reapplyCurrentRoute Called once the navigation is approved, so\n * `UIRoute.currentRoute`'s new value actually takes effect on screen.\n */\n static async _applyHistoryNavigationToRouteAtPositionIfAllowed(\n targetRoute: UIRoute,\n targetHistoryPosition: number,\n navigationGeneration: number,\n reapplyCurrentRoute: () => void | Promise<void>\n ) {\n\n const shouldApplyRouteChange = UIRoute.shouldApplyRouteChange\n const isRouteChangeApproved = shouldApplyRouteChange\n ? await shouldApplyRouteChange({\n currentRoute: UIRoute._presentedRoute.copy(),\n targetRoute: targetRoute.copy(),\n forcefully: NO,\n replacesCurrentRouteInHistory: NO\n })\n : YES\n\n if (navigationGeneration !== UIRoute._nativeHistoryNavigationGeneration) {\n return\n }\n if (\n UIRoute.currentRoute.stringRepresentation !== targetRoute.stringRepresentation ||\n UIRoute._historyPositionFromCurrentEntry() !== targetHistoryPosition\n ) {\n return\n }\n\n if (isRouteChangeApproved) {\n UIRoute._recordPresentedRouteAtHistoryPosition(targetRoute, targetHistoryPosition)\n await reapplyCurrentRoute()\n return\n }\n\n const historyDelta = UIRoute._presentedHistoryPosition - targetHistoryPosition\n if (historyDelta !== 0) {\n window.history.go(historyDelta)\n }\n\n }\n\n\n override copy() {\n const result = new UIRoute(this.stringRepresentation)\n return result\n }\n \n \n routeByRemovingComponentsOtherThanOnesNamed(componentNames: string[]) {\n const result = this.copy()\n const indexesToRemove: number[] = []\n result.forEach(function (component, index, array) {\n if (!componentNames.contains(component.name)) {\n indexesToRemove.push(index)\n }\n })\n indexesToRemove.forEach(function (indexToRemove, index, array) {\n result.removeElementAtIndex(indexToRemove)\n })\n return result\n }\n \n \n routeByRemovingComponentNamed(componentName: string) {\n const result = this.copy()\n const componentIndex = result.findIndex(function (component, index) {\n return (component.name == componentName)\n })\n if (componentIndex != -1) {\n result.splice(componentIndex, 1)\n }\n return result\n }\n \n \n routeByRemovingParameterInComponent(componentName: string, parameterName: string, removeComponentIfEmpty = NO) {\n let result = this.copy()\n let parameters = result.componentWithName(componentName)?.parameters ?? {}\n delete parameters[parameterName]\n result = result.routeWithComponent(componentName, parameters)\n if (removeComponentIfEmpty && Object.keys(parameters).length == 0) {\n result = result.routeByRemovingComponentNamed(componentName)\n }\n return result\n }\n \n routeBySettingParameterInComponent(componentName: string, parameterName: string, valueToSet: string) {\n let result = this.copy()\n if (IS_NIL(valueToSet) || IS_NIL(parameterName)) {\n return result\n }\n let parameters = result.componentWithName(componentName)?.parameters\n if (IS_NOT(parameters)) {\n parameters = {}\n }\n parameters[parameterName] = valueToSet\n result = result.routeWithComponent(componentName, parameters)\n return result\n }\n \n \n routeWithViewControllerComponent<T extends typeof UIViewController>(\n viewController: T,\n parameters: UIRouteParameters<{ [P in keyof T[\"ParameterIdentifierName\"]]: string }>,\n extendParameters: boolean = NO\n ) {\n \n return this.routeWithComponent(viewController.routeComponentName, parameters, extendParameters)\n \n }\n \n routeWithComponent(name: string, parameters: UIRouteParameters, extendParameters: boolean = NO) {\n \n const result = this.copy()\n let component = result.componentWithName(name)\n if (IS_NOT(component)) {\n component = {\n name: name,\n parameters: {}\n }\n result.push(component)\n }\n \n if (IS_NOT(parameters)) {\n \n parameters = {}\n \n }\n \n if (extendParameters) {\n component.parameters = Object.assign(component.parameters, parameters)\n }\n else {\n component.parameters = parameters\n }\n \n return result\n \n }\n \n navigateBySettingComponent(name: string, parameters: UIRouteParameters, extendParameters: boolean = NO) {\n \n return this.routeWithComponent(name, parameters, extendParameters).apply()\n \n }\n \n \n componentWithViewController<T extends typeof UIViewController>(viewController: T): UIRouteComponent<{ [P in ValueOf<T[\"ParameterIdentifierName\"]>]: string }> | undefined {\n \n return this.componentWithName(viewController.routeComponentName)\n \n }\n \n componentWithName(name: string): UIRouteComponent | undefined {\n let result\n this.forEach(function (component, index, self) {\n if (component.name == name) {\n result = component\n }\n })\n return result\n }\n \n \n get linkRepresentation() {\n return \"#\" + this.stringRepresentation\n }\n \n \n get stringRepresentation() {\n \n let result = \"\"\n this.forEach(function (component, index, self) {\n result = result + component.name\n const parameters = component.parameters\n result = result + \"[\"\n Object.keys(parameters).forEach(function (key, index, keys) {\n if (index) {\n result = result + \",\"\n }\n result = result + encodeURIComponent(key) + \":\" + encodeURIComponent(parameters[key])\n })\n result = result + \"]\"\n })\n \n return result\n \n }\n \n \n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAiD;AAoCjD,MAAM,0BAA0B;AAGzB,MAAM,WAAN,cAAsB,MAAwB;AAAA,EAgBjD,YAAY,MAAe;AAEvB,UAAM;AAEN,QAAI,CAAC,QAAQ,CAAC,KAAK,YAAY;AAE3B;AAAA,IAEJ;AAEA,QAAI,KAAK,WAAW,GAAG,GAAG;AACtB,aAAO,KAAK,MAAM,CAAC;AAAA,IACvB;AAEA,WAAO,mBAAmB,IAAI;AAE9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} from \"./UIObject\"\nimport { UIViewController } from \"./UIViewController\"\n\n\nexport type PropType<TObj, TProp extends keyof TObj> = TObj[TProp];\n\nexport type UIRouteParameters<T = any> = {\n \n [key: string]: string;\n \n} | T;\n\n\nexport interface UIRouteComponent<T = any> {\n \n name: string;\n parameters: UIRouteParameters<T>;\n \n}\n\n\nexport interface UIRouteChangeDescriptor {\n \n currentRoute: UIRoute;\n targetRoute: UIRoute;\n forcefully: boolean;\n replacesCurrentRouteInHistory: boolean;\n \n}\n\n\nexport type UIRouteShouldApplyRouteChangeCallbackFunction = (\n routeChangeDescriptor: UIRouteChangeDescriptor\n) => boolean | Promise<boolean>;\n\n\nconst historyPositionStateKey = \"uiRouteHistoryPosition\"\n\n\nexport class UIRoute extends Array<UIRouteComponent> {\n \n static shouldApplyRouteChange?: UIRouteShouldApplyRouteChangeCallbackFunction\n \n // Native Back/Forward navigation fires `hashchange` directly, bypassing\n // `apply()` and therefore `shouldApplyRouteChange` - the fields and\n // methods below (installed via `_installNativeHistoryNavigationGuard`)\n // close that gap by tagging every history entry with a running position,\n // so a native traversal can be told apart from this class's own hash\n // mutations and, when declined, undone with `history.go(...)`.\n static _presentedRoute: UIRoute = new UIRoute()\n static _presentedHistoryPosition = 0\n static _recordedHistoryLength = 0\n static _selfInitiatedRouteChange?: UIRouteChangeDescriptor\n static _nativeHistoryNavigationGeneration = 0\n \n constructor(hash?: string) {\n \n super()\n \n if (!hash || !hash.startsWith) {\n \n return\n \n }\n \n if (hash.startsWith(\"#\")) {\n hash = hash.slice(1)\n }\n \n hash = decodeURIComponent(hash)\n \n const components = hash.split(\"]\")\n components.forEach(component => {\n \n const componentName = component.split(\"[\")[0]\n const parameters: Record<string, string> = {}\n \n if (!componentName) {\n return\n }\n \n const parametersString = component.split(\"[\")[1] || \"\"\n const parameterPairStrings = parametersString.split(\",\") || []\n \n parameterPairStrings.forEach(pairString => {\n \n const keyAndValueArray = pairString.split(\":\")\n const key = decodeURIComponent(keyAndValueArray[0])\n const value = decodeURIComponent(keyAndValueArray[1])\n \n if (key) {\n parameters[key] = value\n }\n \n })\n \n \n this.push({\n name: componentName,\n parameters: parameters\n })\n \n })\n \n \n }\n \n \n static get currentRoute() {\n\n return new UIRoute(window.location.hash)\n\n }\n\n\n /**\n * @param forcefully When `true`, applies the route even if its string\n * representation is identical to the current URL hash, causing the browser\n * to fire a `hashchange` event and re-run the full `handleRoute` flow.\n * Use this only when you explicitly need re-entrant navigation (e.g. the\n * \"tap the already-active tab to reset to root\" feature in TopBarView).\n * Defaults to `false`.\n */\n apply(forcefully = NO): boolean | Promise<boolean> {\n \n return this._applyRouteAfterRouteChangeApproval(forcefully, NO)\n \n }\n \n \n /**\n * Applies this route without consulting `UIRoute.shouldApplyRouteChange`.\n * Use this only for route changes that are internal bookkeeping or that already\n * passed a higher-level confirmation flow.\n */\n applyWithoutRouteChangeApproval(forcefully = NO): boolean {\n \n return this._applyRouteWithoutRouteChangeApproval(forcefully, NO)\n \n }\n \n \n /**\n * @param forcefully When `true`, replaces the current history entry with\n * this route even when the route is identical to the current URL hash.\n * Defaults to `false`.\n */\n applyByReplacingCurrentRouteInHistory(forcefully = NO): boolean | Promise<boolean> {\n \n return this._applyRouteAfterRouteChangeApproval(forcefully, YES)\n \n }\n \n \n /**\n * Replaces the current history entry without consulting\n * `UIRoute.shouldApplyRouteChange`.\n */\n applyByReplacingCurrentRouteInHistoryWithoutRouteChangeApproval(forcefully = NO): boolean {\n \n return this._applyRouteWithoutRouteChangeApproval(forcefully, YES)\n \n }\n \n \n _applyRouteAfterRouteChangeApproval(\n forcefully: boolean,\n replacesCurrentRouteInHistory: boolean\n ): boolean | Promise<boolean> {\n \n if (!this._needsRouteChange(forcefully)) {\n return NO\n }\n \n const shouldApplyRouteChange = UIRoute.shouldApplyRouteChange\n if (!shouldApplyRouteChange) {\n return this._applyRouteWithoutRouteChangeApproval(forcefully, replacesCurrentRouteInHistory)\n }\n \n const shouldProceed = shouldApplyRouteChange(\n this._routeChangeDescriptor(forcefully, replacesCurrentRouteInHistory)\n )\n \n if (shouldProceed instanceof Promise) {\n return shouldProceed.then(isRouteChangeApproved => {\n return this._applyRouteIfAllowed(\n isRouteChangeApproved,\n forcefully,\n replacesCurrentRouteInHistory\n )\n })\n }\n \n return this._applyRouteIfAllowed(shouldProceed, forcefully, replacesCurrentRouteInHistory)\n \n }\n \n \n _applyRouteIfAllowed(\n isRouteChangeApproved: boolean,\n forcefully: boolean,\n replacesCurrentRouteInHistory: boolean\n ): boolean {\n \n if (!isRouteChangeApproved) {\n return NO\n }\n \n return this._applyRouteWithoutRouteChangeApproval(forcefully, replacesCurrentRouteInHistory)\n \n }\n \n \n _applyRouteWithoutRouteChangeApproval(\n forcefully: boolean,\n replacesCurrentRouteInHistory: boolean\n ): boolean {\n \n if (!this._needsRouteChange(forcefully)) {\n return NO\n }\n\n // Tags the hashchange this is about to cause as this class's own\n // doing, so `_hashDidChange` can tell it apart from a native\n // Back/Forward traversal instead of falling back to guessing from\n // `window.history.length`.\n UIRoute._selfInitiatedRouteChange = this._routeChangeDescriptor(forcefully, replacesCurrentRouteInHistory)\n\n if (replacesCurrentRouteInHistory) {\n window.location.replace(this.linkRepresentation)\n }\n else {\n window.location.hash = this.stringRepresentation\n }\n\n return YES\n\n }\n \n \n _needsRouteChange(forcefully: boolean): boolean {\n \n if (!forcefully && new UIRoute(window.location.hash).stringRepresentation == this.stringRepresentation) {\n return NO\n }\n \n return YES\n \n }\n \n \n _routeChangeDescriptor(forcefully: boolean, replacesCurrentRouteInHistory: boolean): UIRouteChangeDescriptor {\n \n return {\n currentRoute: UIRoute.currentRoute,\n targetRoute: this.copy(),\n forcefully: forcefully,\n replacesCurrentRouteInHistory: replacesCurrentRouteInHistory\n }\n\n }\n\n\n /**\n * Installs handling so that native browser Back/Forward navigation\n * consults `shouldApplyRouteChange` the same way `apply()` does, instead\n * of silently bypassing it. Call exactly once, from `UICore`'s\n * constructor.\n *\n * @param reapplyCurrentRoute Re-runs route handling for `UIRoute.currentRoute`.\n * Called once a native navigation is allowed to proceed (or is self-initiated),\n * so its effect actually appears on screen.\n */\n static _installNativeHistoryNavigationGuard(reapplyCurrentRoute: () => void | Promise<void>) {\n\n UIRoute._recordPresentedRouteAtHistoryPosition(\n UIRoute.currentRoute,\n UIRoute._historyPositionFromCurrentEntry() ?? 0\n )\n\n window.addEventListener(\"hashchange\", event =>\n UIRoute._hashDidChange(event, reapplyCurrentRoute)\n )\n\n }\n\n\n static _historyPositionFromCurrentEntry(): number | undefined {\n\n const historyPosition = (window.history.state as Record<string, unknown> | null)?.[historyPositionStateKey]\n if (typeof historyPosition !== \"number\") {\n return undefined\n }\n return historyPosition\n\n }\n\n\n static _recordPresentedRouteAtHistoryPosition(route: UIRoute, historyPosition: number) {\n\n const historyState = Object.assign({}, window.history.state)\n historyState[historyPositionStateKey] = historyPosition\n window.history.replaceState(historyState, \"\")\n\n UIRoute._presentedRoute = route.copy()\n UIRoute._presentedHistoryPosition = historyPosition\n UIRoute._recordedHistoryLength = window.history.length\n\n }\n\n\n /**\n * The single listener installed for every `hashchange` - self-initiated,\n * native Back/Forward, or an untagged bypass (see the class-level comment\n * above `_presentedRoute`) - and the point where those three cases are\n * told apart.\n *\n * @param event The native event. Only used to call\n * `stopImmediatePropagation()` when a native traversal needs to be held\n * back pending `shouldApplyRouteChange`, so `UICore`'s own route handling\n * doesn't run before that check settles.\n * @param reapplyCurrentRoute Forwarded to `_applyHistoryNavigationToRouteAtPositionIfAllowed`\n * - see its own doc comment.\n */\n static _hashDidChange(event: HashChangeEvent, reapplyCurrentRoute: () => void | Promise<void>) {\n\n const targetRoute = UIRoute.currentRoute\n const selfInitiatedRouteChange = UIRoute._selfInitiatedRouteChange\n UIRoute._selfInitiatedRouteChange = undefined\n\n if (\n selfInitiatedRouteChange &&\n selfInitiatedRouteChange.targetRoute.stringRepresentation === targetRoute.stringRepresentation\n ) {\n\n let targetHistoryPosition = UIRoute._presentedHistoryPosition\n if (!selfInitiatedRouteChange.replacesCurrentRouteInHistory) {\n targetHistoryPosition = targetHistoryPosition + 1\n }\n UIRoute._recordPresentedRouteAtHistoryPosition(targetRoute, targetHistoryPosition)\n reapplyCurrentRoute()\n return\n\n }\n\n const targetHistoryPosition = UIRoute._historyPositionFromCurrentEntry()\n if (targetHistoryPosition === undefined) {\n\n // A hash mutation that bypassed this class entirely (e.g. a\n // direct `window.location.hash = ...` assignment) produces an\n // untagged entry. A larger native history length means it was\n // pushed; an unchanged length means the current entry was\n // replaced. Preserve both established escape hatches while\n // bringing the entry into this sequence.\n let untaggedHistoryPosition = UIRoute._presentedHistoryPosition\n if (window.history.length > UIRoute._recordedHistoryLength) {\n untaggedHistoryPosition = untaggedHistoryPosition + 1\n }\n UIRoute._recordPresentedRouteAtHistoryPosition(targetRoute, untaggedHistoryPosition)\n reapplyCurrentRoute()\n return\n\n }\n if (targetHistoryPosition === UIRoute._presentedHistoryPosition) {\n UIRoute._recordPresentedRouteAtHistoryPosition(targetRoute, targetHistoryPosition)\n reapplyCurrentRoute()\n return\n }\n\n event.stopImmediatePropagation()\n const navigationGeneration = ++UIRoute._nativeHistoryNavigationGeneration\n UIRoute._applyHistoryNavigationToRouteAtPositionIfAllowed(\n targetRoute,\n targetHistoryPosition,\n navigationGeneration,\n reapplyCurrentRoute\n ).catch(error => {\n console.error(\"UIRoute: native history navigation check failed\", error)\n })\n\n }\n\n\n /**\n * Consults `shouldApplyRouteChange` for a native Back/Forward traversal,\n * exactly like `apply()` does for a programmatic one, then either lets it\n * through or reverts it with `history.go(...)`.\n *\n * @param targetRoute The route the native traversal is asking to move to.\n * @param targetHistoryPosition That route's tagged position, used both to\n * revert (`history.go`) and to detect a newer navigation arriving mid-check.\n * @param navigationGeneration A token captured by the caller at dispatch\n * time. If it no longer matches `_nativeHistoryNavigationGeneration` by\n * the time `shouldApplyRouteChange` resolves, a newer navigation has\n * superseded this one and this check's result is discarded.\n * @param reapplyCurrentRoute Called once the navigation is approved, so\n * `UIRoute.currentRoute`'s new value actually takes effect on screen.\n */\n static async _applyHistoryNavigationToRouteAtPositionIfAllowed(\n targetRoute: UIRoute,\n targetHistoryPosition: number,\n navigationGeneration: number,\n reapplyCurrentRoute: () => void | Promise<void>\n ) {\n\n const shouldApplyRouteChange = UIRoute.shouldApplyRouteChange\n const isRouteChangeApproved = shouldApplyRouteChange\n ? await shouldApplyRouteChange({\n currentRoute: UIRoute._presentedRoute.copy(),\n targetRoute: targetRoute.copy(),\n forcefully: NO,\n replacesCurrentRouteInHistory: NO\n })\n : YES\n\n if (navigationGeneration !== UIRoute._nativeHistoryNavigationGeneration) {\n return\n }\n if (\n UIRoute.currentRoute.stringRepresentation !== targetRoute.stringRepresentation ||\n UIRoute._historyPositionFromCurrentEntry() !== targetHistoryPosition\n ) {\n return\n }\n\n if (isRouteChangeApproved) {\n UIRoute._recordPresentedRouteAtHistoryPosition(targetRoute, targetHistoryPosition)\n await reapplyCurrentRoute()\n return\n }\n\n const historyDelta = UIRoute._presentedHistoryPosition - targetHistoryPosition\n if (historyDelta !== 0) {\n window.history.go(historyDelta)\n }\n\n }\n\n\n override copy() {\n const result = new UIRoute(this.stringRepresentation)\n return result\n }\n \n \n routeByRemovingComponentsOtherThanOnesNamed(componentNames: string[]) {\n const result = this.copy()\n const indexesToRemove: number[] = []\n result.forEach(function (component, index, array) {\n if (!componentNames.contains(component.name)) {\n indexesToRemove.push(index)\n }\n })\n indexesToRemove.forEach(function (indexToRemove, index, array) {\n result.removeElementAtIndex(indexToRemove)\n })\n return result\n }\n \n \n routeByRemovingComponentNamed(componentName: string) {\n const result = this.copy()\n const componentIndex = result.findIndex(function (component, index) {\n return (component.name == componentName)\n })\n if (componentIndex != -1) {\n result.splice(componentIndex, 1)\n }\n return result\n }\n \n \n routeByRemovingParameterInComponent(componentName: string, parameterName: string, removeComponentIfEmpty = NO) {\n let result = this.copy()\n let parameters = result.componentWithName(componentName)?.parameters ?? {}\n delete parameters[parameterName]\n result = result.routeWithComponent(componentName, parameters)\n if (removeComponentIfEmpty && Object.keys(parameters).length == 0) {\n result = result.routeByRemovingComponentNamed(componentName)\n }\n return result\n }\n \n routeBySettingParameterInComponent(componentName: string, parameterName: string, valueToSet: string) {\n let result = this.copy()\n if (IS_NIL(valueToSet) || IS_NIL(parameterName)) {\n return result\n }\n let parameters = result.componentWithName(componentName)?.parameters\n if (IS_NOT(parameters)) {\n parameters = {}\n }\n parameters[parameterName] = valueToSet\n result = result.routeWithComponent(componentName, parameters)\n return result\n }\n \n \n routeWithViewControllerComponent<T extends typeof UIViewController>(\n viewController: T,\n parameters: UIRouteParameters<{ [P in keyof T[\"ParameterIdentifierName\"]]: string }>,\n extendParameters: boolean = NO\n ) {\n \n return this.routeWithComponent(viewController.routeComponentName, parameters, extendParameters)\n \n }\n \n routeWithComponent(name: string, parameters: UIRouteParameters, extendParameters: boolean = NO) {\n \n const result = this.copy()\n let component = result.componentWithName(name)\n if (IS_NOT(component)) {\n component = {\n name: name,\n parameters: {}\n }\n result.push(component)\n }\n \n if (IS_NOT(parameters)) {\n \n parameters = {}\n \n }\n \n if (extendParameters) {\n component.parameters = Object.assign(component.parameters, parameters)\n }\n else {\n component.parameters = parameters\n }\n \n return result\n \n }\n \n navigateBySettingComponent(name: string, parameters: UIRouteParameters, extendParameters: boolean = NO) {\n \n return this.routeWithComponent(name, parameters, extendParameters).apply()\n \n }\n \n \n componentWithViewController<T extends typeof UIViewController>(viewController: T): UIRouteComponent<{ [P in ValueOf<T[\"ParameterIdentifierName\"]>]: string }> | undefined {\n \n return this.componentWithName(viewController.routeComponentName)\n \n }\n \n componentWithName(name: string): UIRouteComponent | undefined {\n let result\n this.forEach(function (component, index, self) {\n if (component.name == name) {\n result = component\n }\n })\n return result\n }\n \n \n get linkRepresentation() {\n return \"#\" + this.stringRepresentation\n }\n \n \n get stringRepresentation() {\n \n let result = \"\"\n this.forEach(function (component, index, self) {\n result = result + component.name\n const parameters = component.parameters\n result = result + \"[\"\n Object.keys(parameters).forEach(function (key, index, keys) {\n if (index) {\n result = result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,WAAW,OAAO,MAAM;AAC3C,eAAS,SAAS,UAAU;AAC5B,YAAM,aAAa,UAAU;AAC7B,eAAS,SAAS;AAClB,aAAO,KAAK,UAAU,EAAE,QAAQ,SAAU,KAAKC,QAAO,MAAM;AACxD,YAAIA,QAAO;AACP,mBAAS,SAAS;AAAA,QACtB;AACA,iBAAS,SAAS,mBAAmB,GAAG,IAAI,MAAM,mBAAmB,WAAW,IAAI;AAAA,MACxF,CAAC;AACD,eAAS,SAAS;AAAA,IACtB,CAAC;AAED,WAAO;AAAA,EAEX;AAGJ;AApiBO,IAAM,UAAN;AAAM,QAUF,kBAA2B,IAAI,SAAQ;AAVrC,QAWF,4BAA4B;AAX1B,QAYF,yBAAyB;AAZvB,QAcF,qCAAqC;",
6
6
  "names": ["targetHistoryPosition", "index"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uicore-ts",
3
- "version": "1.1.387",
3
+ "version": "1.1.388",
4
4
  "description": "UICore is a library to build native-like user interfaces using pure Typescript. No HTML is needed at all. Components are described as TS classes and all user interactions are handled explicitly. This library is strongly inspired by the UIKit framework that is used in IOS. In addition, UICore has tools to handle URL based routing, array sorting and filtering and adds a number of other utilities for convenience.",
5
5
  "main": "compiledScripts/index.js",
6
6
  "types": "compiledScripts/index.d.ts",
@@ -338,6 +338,7 @@ export class UIRoute extends Array<UIRouteComponent> {
338
338
  targetHistoryPosition = targetHistoryPosition + 1
339
339
  }
340
340
  UIRoute._recordPresentedRouteAtHistoryPosition(targetRoute, targetHistoryPosition)
341
+ reapplyCurrentRoute()
341
342
  return
342
343
 
343
344
  }
@@ -356,11 +357,13 @@ export class UIRoute extends Array<UIRouteComponent> {
356
357
  untaggedHistoryPosition = untaggedHistoryPosition + 1
357
358
  }
358
359
  UIRoute._recordPresentedRouteAtHistoryPosition(targetRoute, untaggedHistoryPosition)
360
+ reapplyCurrentRoute()
359
361
  return
360
362
 
361
363
  }
362
364
  if (targetHistoryPosition === UIRoute._presentedHistoryPosition) {
363
365
  UIRoute._recordPresentedRouteAtHistoryPosition(targetRoute, targetHistoryPosition)
366
+ reapplyCurrentRoute()
364
367
  return
365
368
  }
366
369