From b88a19b6f80c697dd7b416aefdb40b25c356363d Mon Sep 17 00:00:00 2001 From: Alexey Kulakov Date: Thu, 2 Nov 2023 18:15:30 -0700 Subject: [PATCH] fix: add warning message for ember-source below v4.1 --- ember-engines-router-service/package.json | 5 +-- .../src/services/engine-router-service.js | 31 ++++++++++++------- yarn.lock | 2 +- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/ember-engines-router-service/package.json b/ember-engines-router-service/package.json index 866870a..f8d6101 100644 --- a/ember-engines-router-service/package.json +++ b/ember-engines-router-service/package.json @@ -36,7 +36,8 @@ "start": "rollup --config --watch" }, "dependencies": { - "@embroider/addon-shim": "^1.8.4" + "@embroider/addon-shim": "^1.8.4", + "@embroider/macros": "^1.13.2" }, "devDependencies": { "@babel/core": "^7.20.7", @@ -56,7 +57,7 @@ "rollup": "^3.8.1" }, "engines": { - "node": "14.* || 16.* || >= 18" + "node": "16.* || 18.* || >= 20" }, "publishConfig": { "registry": "https://registry.npmjs.org" diff --git a/ember-engines-router-service/src/services/engine-router-service.js b/ember-engines-router-service/src/services/engine-router-service.js index 6034fd7..e0a1b28 100644 --- a/ember-engines-router-service/src/services/engine-router-service.js +++ b/ember-engines-router-service/src/services/engine-router-service.js @@ -5,6 +5,7 @@ import { action, computed } from '@ember/object'; import { reads } from '@ember/object/computed'; import { getOwner } from '@ember/application'; import Evented from '@ember/object/evented'; +import { macroCondition, dependencySatisfies } from '@embroider/macros'; import { namespaceEngineRouteName } from '../utils/namespace-engine-route-name'; import { getRootOwner } from '../utils/root-owner'; import { resemblesURL } from '../utils/resembles-url'; @@ -66,21 +67,29 @@ export default class EngineRouterService extends Service.extend(Evented) { } refresh(routeName = this.currentRouteName, ...args) { - if (resemblesURL(routeName)) { - return this.externalRouter.refresh(routeName); + if (macroCondition(dependencySatisfies('ember-source', '>= 4.1'))) { + if (resemblesURL(routeName)) { + return this.externalRouter.refresh(routeName); + } + + return this.externalRouter.refresh( + namespaceEngineRouteName(this._mountPoint, routeName), + ...args + ); + } else { + assert('Refresh method is not available in ember-source below v4.1'); } - - return this.externalRouter.refresh( - namespaceEngineRouteName(this._mountPoint, routeName), - ...args - ); } refreshExternal(routeName, ...args) { - return this.externalRouter.refresh( - this.getExternalRouteName(routeName), - ...args - ); + if (macroCondition(dependencySatisfies('ember-source', '>= 4.1'))) { + return this.externalRouter.refresh( + this.getExternalRouteName(routeName), + ...args + ); + } else { + assert('Refresh method is not available in ember-source below v4.1'); + } } transitionTo(routeName, ...args) { diff --git a/yarn.lock b/yarn.lock index 823260f..9a7259b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1189,7 +1189,7 @@ typescript-memoize "^1.0.1" walk-sync "^3.0.0" -"@embroider/macros@1.13.2", "@embroider/macros@^1.0.0", "@embroider/macros@^1.10.0", "@embroider/macros@^1.13.0", "@embroider/macros@^1.3.0": +"@embroider/macros@1.13.2", "@embroider/macros@^1.0.0", "@embroider/macros@^1.10.0", "@embroider/macros@^1.13.0", "@embroider/macros@^1.13.2", "@embroider/macros@^1.3.0": version "1.13.2" resolved "https://registry.yarnpkg.com/@embroider/macros/-/macros-1.13.2.tgz#07dda11313a2539f403404881b729e622a80ca17" integrity sha512-AUgJ71xG8kjuTx8XB1AQNBiebJuXRfhcHr318dCwnQz9VRXdYSnEEqf38XRvGYIoCvIyn/3c72LrSwzaJqknOA==