piral-ng 1.5.6-beta.7104 → 1.5.6-beta.7113

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.
@@ -0,0 +1,57 @@
1
+ import info from '@angular/compiler/package.json';
2
+
3
+ const url = new URL('.', __system_context__.meta.url);
4
+
5
+ if (typeof window.ngVersions === 'undefined') {
6
+ window.ngVersions = {};
7
+ }
8
+
9
+ window.ngVersions[url.href] = info.version;
10
+
11
+ const existing = Object.getOwnPropertyDescriptor(window, 'ng');
12
+
13
+ if (existing?.get === undefined) {
14
+ const defaultVersion = 'default';
15
+ const ngs = {
16
+ [defaultVersion]: existing?.value,
17
+ };
18
+
19
+ function getUrl() {
20
+ const { stack } = new Error();
21
+ const lines = stack?.split('\n') || [];
22
+
23
+ if (lines[0] === 'Error') {
24
+ // V8
25
+ const line = lines[3] || '';
26
+ return /\((.*):\d+:\d+\)$/.exec(line)?.[1] || '';
27
+ } else {
28
+ // SpiderMonkey and JavaScriptCore
29
+ const line = lines[2] || '';
30
+ return /@(.*):\d+:\d+$/.exec(line)?.[1] || '';
31
+ }
32
+ }
33
+
34
+ function getNgVersion(url) {
35
+ try {
36
+ const baseUrl = new URL('.', url);
37
+ const version = window.ngVersions[baseUrl];
38
+ return version || defaultVersion;
39
+ } catch {
40
+ return defaultVersion;
41
+ }
42
+ }
43
+
44
+ Object.defineProperty(window, 'ng', {
45
+ configurable: true,
46
+ get() {
47
+ const url = getUrl();
48
+ const version = getNgVersion(url);
49
+ return ngs[version];
50
+ },
51
+ set(value) {
52
+ const url = getUrl();
53
+ const version = getNgVersion(url);
54
+ ngs[version] = value;
55
+ },
56
+ });
57
+ }
package/extend-webpack.js CHANGED
@@ -101,18 +101,30 @@ module.exports =
101
101
  );
102
102
 
103
103
  if (jitMode) {
104
- // The job of this plugin is to make angular-core depend on angular-compiler - this way
105
- // angular-compiler does not need to be loaded separately and angular-compiler is present
106
- // *before* angular-core
107
- // this is only required in jit mode - as otherwise everything should be pre-compiled
104
+ // The job of this plugin is
105
+ // (1)
106
+ // to make @angular/core depend on @angular/compiler - this way @angular/compiler
107
+ // does not need to be loaded separately and @angular/compiler is present *before*
108
+ // @angular/core; this is only required in jit mode - as otherwise everything should
109
+ // be pre-compiled.
110
+ // (2)
111
+ // to introduce a dynamic version of the window.ng global, which supports running
112
+ // with multiple versions of Angular.
108
113
  config.plugins.push({
109
114
  apply(compiler) {
110
115
  const { entry } = compiler.options;
111
- const core = entry['angular-core'];
116
+ const coreEntry = entry['angular-core'];
112
117
 
113
- if (typeof core !== 'undefined') {
118
+ if (typeof coreEntry !== 'undefined') {
114
119
  const compilerDependency = resolve(__dirname, 'core-dynamic.js');
115
- core.import = [compilerDependency, ...core.import];
120
+ coreEntry.import = [compilerDependency, ...coreEntry.import];
121
+ }
122
+
123
+ const compilerEntry = entry['angular-compiler'];
124
+
125
+ if (typeof compilerEntry !== 'undefined') {
126
+ const compilerDependency = resolve(__dirname, 'compiler-dynamic.js');
127
+ compilerEntry.import = [compilerDependency, ...compilerEntry.import];
116
128
  }
117
129
  },
118
130
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-ng",
3
- "version": "1.5.6-beta.7104",
3
+ "version": "1.5.6-beta.7113",
4
4
  "description": "Plugin for integrating Angular components in Piral.",
5
5
  "keywords": [
6
6
  "piral",
@@ -27,6 +27,9 @@
27
27
  "./common": {
28
28
  "import": "./common.js"
29
29
  },
30
+ "./compiler-dynamic": {
31
+ "import": "./compiler-dynamic.js"
32
+ },
30
33
  "./convert": {
31
34
  "import": "./convert.js"
32
35
  },
@@ -58,6 +61,7 @@
58
61
  "src",
59
62
  "common.d.ts",
60
63
  "common.js",
64
+ "compiler-dynamic.js",
61
65
  "convert.d.ts",
62
66
  "convert.js",
63
67
  "core-dynamic.js",
@@ -90,9 +94,9 @@
90
94
  "@angular/platform-browser": "^16.0.0",
91
95
  "@angular/platform-browser-dynamic": "^16.0.0",
92
96
  "@angular/router": "^16.0.0",
93
- "piral-core": "1.5.6-beta.7104",
97
+ "piral-core": "1.5.6-beta.7113",
94
98
  "piral-ng-common": "^16.0.0",
95
99
  "rxjs": "^7.3.0"
96
100
  },
97
- "gitHead": "a139eb2c192b2c672419e393dbae2ad49c47402d"
101
+ "gitHead": "a39f961d4616ea8acf9610436dd7c94d89cc46ca"
98
102
  }