piral-base 1.12.2 → 1.12.3-beta.69f5a80
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.
- package/dist/piral-base-full.mjs +18 -12
- package/dist/piral-base-node.js +18 -12
- package/lib/types/service.d.ts +1 -1
- package/package.json +1 -1
- package/src/loaders/mf/index.ts +30 -12
- package/src/types/service.ts +1 -1
package/dist/piral-base-full.mjs
CHANGED
|
@@ -1468,20 +1468,22 @@ function loader6(entry, options) {
|
|
|
1468
1468
|
|
|
1469
1469
|
// src/loaders/mf/index.ts
|
|
1470
1470
|
var appShell = "piral";
|
|
1471
|
+
var systemRegistry = System.registerRegistry;
|
|
1472
|
+
var sharedScope = { current: void 0 };
|
|
1471
1473
|
function populateKnownDependencies(scope) {
|
|
1472
|
-
|
|
1474
|
+
var _a;
|
|
1475
|
+
for (const entry of Object.keys(systemRegistry)) {
|
|
1473
1476
|
const index = entry.lastIndexOf("@");
|
|
1474
1477
|
if (index > 0 && !entry.match(/^https?:\/\//)) {
|
|
1475
1478
|
const entryName = entry.substring(0, index);
|
|
1476
1479
|
const entryVersion = entry.substring(index + 1);
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
}
|
|
1480
|
-
scope[entryName][entryVersion] = {
|
|
1480
|
+
scope[entryName] ?? (scope[entryName] = {});
|
|
1481
|
+
(_a = scope[entryName])[entryVersion] ?? (_a[entryVersion] = {
|
|
1481
1482
|
from: appShell,
|
|
1482
1483
|
eager: false,
|
|
1484
|
+
loaded: 1,
|
|
1483
1485
|
get: () => System.import(entry).then((result) => () => result)
|
|
1484
|
-
};
|
|
1486
|
+
});
|
|
1485
1487
|
}
|
|
1486
1488
|
}
|
|
1487
1489
|
}
|
|
@@ -1490,19 +1492,23 @@ function extractSharedDependencies(scope) {
|
|
|
1490
1492
|
const entries = scope[entryName];
|
|
1491
1493
|
for (const entryVersion of Object.keys(entries)) {
|
|
1492
1494
|
const entry = entries[entryVersion];
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
+
const entryKey = `${entryName}@${entryVersion}`;
|
|
1496
|
+
if (entry.from !== appShell && !(entryKey in systemRegistry)) {
|
|
1497
|
+
registerModule(entryKey, () => entry.get().then((factory) => factory()));
|
|
1495
1498
|
}
|
|
1499
|
+
entry.loaded = 1;
|
|
1496
1500
|
}
|
|
1497
1501
|
}
|
|
1498
1502
|
}
|
|
1499
1503
|
function loadMfFactory(piletName, exposedName) {
|
|
1500
1504
|
const varName = piletName.replace(/^@/, "").replace("/", "-").replace(/\-/g, "_");
|
|
1501
1505
|
const container = window[varName];
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
+
if (!sharedScope.current) {
|
|
1507
|
+
sharedScope.current = {};
|
|
1508
|
+
populateKnownDependencies(sharedScope.current);
|
|
1509
|
+
}
|
|
1510
|
+
container.init(sharedScope.current);
|
|
1511
|
+
extractSharedDependencies(sharedScope.current);
|
|
1506
1512
|
return container.get(exposedName);
|
|
1507
1513
|
}
|
|
1508
1514
|
function loader7(entry, _config) {
|
package/dist/piral-base-node.js
CHANGED
|
@@ -6871,20 +6871,22 @@ function loader6(entry, options) {
|
|
|
6871
6871
|
|
|
6872
6872
|
// src/loaders/mf/index.ts
|
|
6873
6873
|
var appShell = "piral";
|
|
6874
|
+
var systemRegistry = System.registerRegistry;
|
|
6875
|
+
var sharedScope = { current: void 0 };
|
|
6874
6876
|
function populateKnownDependencies(scope) {
|
|
6875
|
-
|
|
6877
|
+
var _a;
|
|
6878
|
+
for (const entry of Object.keys(systemRegistry)) {
|
|
6876
6879
|
const index = entry.lastIndexOf("@");
|
|
6877
6880
|
if (index > 0 && !entry.match(/^https?:\/\//)) {
|
|
6878
6881
|
const entryName = entry.substring(0, index);
|
|
6879
6882
|
const entryVersion = entry.substring(index + 1);
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
}
|
|
6883
|
-
scope[entryName][entryVersion] = {
|
|
6883
|
+
scope[entryName] ?? (scope[entryName] = {});
|
|
6884
|
+
(_a = scope[entryName])[entryVersion] ?? (_a[entryVersion] = {
|
|
6884
6885
|
from: appShell,
|
|
6885
6886
|
eager: false,
|
|
6887
|
+
loaded: 1,
|
|
6886
6888
|
get: () => System.import(entry).then((result) => () => result)
|
|
6887
|
-
};
|
|
6889
|
+
});
|
|
6888
6890
|
}
|
|
6889
6891
|
}
|
|
6890
6892
|
}
|
|
@@ -6893,19 +6895,23 @@ function extractSharedDependencies(scope) {
|
|
|
6893
6895
|
const entries = scope[entryName];
|
|
6894
6896
|
for (const entryVersion of Object.keys(entries)) {
|
|
6895
6897
|
const entry = entries[entryVersion];
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
+
const entryKey = `${entryName}@${entryVersion}`;
|
|
6899
|
+
if (entry.from !== appShell && !(entryKey in systemRegistry)) {
|
|
6900
|
+
registerModule(entryKey, () => entry.get().then((factory) => factory()));
|
|
6898
6901
|
}
|
|
6902
|
+
entry.loaded = 1;
|
|
6899
6903
|
}
|
|
6900
6904
|
}
|
|
6901
6905
|
}
|
|
6902
6906
|
function loadMfFactory(piletName, exposedName) {
|
|
6903
6907
|
const varName = piletName.replace(/^@/, "").replace("/", "-").replace(/\-/g, "_");
|
|
6904
6908
|
const container = window[varName];
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
+
if (!sharedScope.current) {
|
|
6910
|
+
sharedScope.current = {};
|
|
6911
|
+
populateKnownDependencies(sharedScope.current);
|
|
6912
|
+
}
|
|
6913
|
+
container.init(sharedScope.current);
|
|
6914
|
+
extractSharedDependencies(sharedScope.current);
|
|
6909
6915
|
return container.get(exposedName);
|
|
6910
6916
|
}
|
|
6911
6917
|
function loader7(entry, _config) {
|
package/lib/types/service.d.ts
CHANGED
package/package.json
CHANGED
package/src/loaders/mf/index.ts
CHANGED
|
@@ -22,23 +22,23 @@ interface MfContainer {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const appShell = 'piral';
|
|
25
|
+
const systemRegistry = (System as any).registerRegistry as Record<string, unknown>;
|
|
26
|
+
const sharedScope = { current: undefined as MfScope | undefined };
|
|
25
27
|
|
|
26
28
|
function populateKnownDependencies(scope: MfScope) {
|
|
27
29
|
// SystemJS to MF
|
|
28
|
-
for (const
|
|
30
|
+
for (const entry of Object.keys(systemRegistry)) {
|
|
29
31
|
const index = entry.lastIndexOf('@');
|
|
30
32
|
|
|
31
33
|
if (index > 0 && !entry.match(/^https?:\/\//)) {
|
|
32
34
|
const entryName = entry.substring(0, index);
|
|
33
35
|
const entryVersion = entry.substring(index + 1);
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
scope[entryName][entryVersion] = {
|
|
37
|
+
scope[entryName] ??= {};
|
|
38
|
+
scope[entryName][entryVersion] ??= {
|
|
40
39
|
from: appShell,
|
|
41
40
|
eager: false,
|
|
41
|
+
loaded: 1,
|
|
42
42
|
get: () => System.import(entry).then((result) => () => result),
|
|
43
43
|
};
|
|
44
44
|
}
|
|
@@ -52,10 +52,24 @@ function extractSharedDependencies(scope: MfScope) {
|
|
|
52
52
|
|
|
53
53
|
for (const entryVersion of Object.keys(entries)) {
|
|
54
54
|
const entry = entries[entryVersion];
|
|
55
|
+
const entryKey = `${entryName}@${entryVersion}`;
|
|
55
56
|
|
|
56
|
-
if (entry.from !== appShell) {
|
|
57
|
-
registerModule(
|
|
57
|
+
if (entry.from !== appShell && !(entryKey in systemRegistry)) {
|
|
58
|
+
registerModule(entryKey, () => entry.get().then((factory) => factory()));
|
|
58
59
|
}
|
|
60
|
+
|
|
61
|
+
// Flagging the scope entry as loaded ensures that subsequent pilets do not
|
|
62
|
+
// overwrite an entry already registered by an earlier pilet.
|
|
63
|
+
// We want to avoid overwrites to ensure stability.
|
|
64
|
+
//
|
|
65
|
+
// Inside a pilet bundled with the MF format, the corresponding scope
|
|
66
|
+
// registration flow is equivalent to:
|
|
67
|
+
// if (!activeVersion || (!activeVersion.loaded && !hasEagerPrecedence)) {
|
|
68
|
+
// writeDependencyToScope();
|
|
69
|
+
// }
|
|
70
|
+
//
|
|
71
|
+
// -> By setting loaded to 1, we ensure that already registered entries are not overwritten.
|
|
72
|
+
entry.loaded = 1;
|
|
59
73
|
}
|
|
60
74
|
}
|
|
61
75
|
}
|
|
@@ -63,10 +77,14 @@ function extractSharedDependencies(scope: MfScope) {
|
|
|
63
77
|
function loadMfFactory(piletName: string, exposedName: string) {
|
|
64
78
|
const varName = piletName.replace(/^@/, '').replace('/', '-').replace(/\-/g, '_');
|
|
65
79
|
const container: MfContainer = window[varName];
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
80
|
+
|
|
81
|
+
if (!sharedScope.current) {
|
|
82
|
+
sharedScope.current = {};
|
|
83
|
+
populateKnownDependencies(sharedScope.current);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
container.init(sharedScope.current);
|
|
87
|
+
extractSharedDependencies(sharedScope.current);
|
|
70
88
|
return container.get(exposedName);
|
|
71
89
|
}
|
|
72
90
|
|