-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #695 from smapiot/develop
Release 1.5.6
- Loading branch information
Showing
12 changed files
with
122 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import info from '@angular/compiler/package.json'; | ||
|
||
if (typeof window.ngVersions === 'undefined') { | ||
window.ngVersions = {}; | ||
} | ||
|
||
const defaultVersion = 'default'; | ||
const existing = Object.getOwnPropertyDescriptor(window, 'ng'); | ||
|
||
function setUrl(url, version) { | ||
if (version) { | ||
window.ngVersions[url] = version; | ||
return version; | ||
} | ||
|
||
return defaultVersion; | ||
} | ||
|
||
setUrl(new URL('.', __system_context__.meta.url).href, info.version); | ||
|
||
if (existing?.get === undefined) { | ||
const ngs = { | ||
[defaultVersion]: existing?.value, | ||
}; | ||
|
||
function getUrl() { | ||
const { stack } = new Error(); | ||
const lines = stack?.split('\n') || []; | ||
|
||
if (lines[0] === 'Error') { | ||
// V8 | ||
const line = lines[3] || ''; | ||
return /\((.*):\d+:\d+\)$/.exec(line)?.[1] || ''; | ||
} else { | ||
// SpiderMonkey and JavaScriptCore | ||
const line = lines[2] || ''; | ||
return /@(.*):\d+:\d+$/.exec(line)?.[1] || ''; | ||
} | ||
} | ||
|
||
function getNgVersion(url) { | ||
const version = window.ngVersions[url]; | ||
|
||
if (!version) { | ||
try { | ||
const baseUrl = new URL('.', url); | ||
const baseVersion = window.ngVersions[baseUrl.href]; | ||
return setUrl(url, baseVersion); | ||
} catch { | ||
return defaultVersion; | ||
} | ||
} | ||
|
||
return version; | ||
} | ||
|
||
Object.defineProperty(window, 'ng', { | ||
configurable: true, | ||
get() { | ||
const url = getUrl(); | ||
const version = getNgVersion(url); | ||
return ngs[version]; | ||
}, | ||
set(value) { | ||
const url = getUrl(); | ||
const version = getNgVersion(url); | ||
ngs[version] = value; | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters