1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | /**
|
4 | * Finds the host app under which an addon is running.
|
5 | *
|
6 | * This allows us to easily look up the host app from a nested addon (an addon
|
7 | * running under another addon).
|
8 | */
|
9 | // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
10 | function findHost(addon) {
|
11 | // If the addon has the _findHost() method (in ember-cli >= 2.7.0), we'll just
|
12 | // use that.
|
13 | if (typeof addon._findHost === 'function') {
|
14 | return addon._findHost();
|
15 | }
|
16 | // Otherwise, we'll use this implementation borrowed from the _findHost()
|
17 | // method in ember-cli.
|
18 | let current = addon;
|
19 | let app;
|
20 | // Keep iterating upward until we don't have a grandparent.
|
21 | // Has to do this grandparent check because at some point we hit the project.
|
22 | do {
|
23 | app = current.app || app;
|
24 | } while (current.parent.parent && (current = current.parent));
|
25 | return app;
|
26 | }
|
27 | exports.default = findHost;
|
28 | //# sourceMappingURL=findHost.js.map |
\ | No newline at end of file |