@o3r/third-party 11.6.0-prerelease.21 → 11.6.0-prerelease.23
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/third-party",
|
|
3
|
-
"version": "11.6.0-prerelease.
|
|
3
|
+
"version": "11.6.0-prerelease.23",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"@angular-devkit/schematics": "~18.2.0",
|
|
20
|
-
"@o3r/core": "^11.6.0-prerelease.
|
|
21
|
-
"@o3r/schematics": "^11.6.0-prerelease.
|
|
20
|
+
"@o3r/core": "^11.6.0-prerelease.23",
|
|
21
|
+
"@o3r/schematics": "^11.6.0-prerelease.23",
|
|
22
22
|
"@schematics/angular": "~18.2.0",
|
|
23
23
|
"rxjs": "^7.8.1",
|
|
24
24
|
"typescript": "~5.5.4"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/iframe-to-component/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,IAAI,EAGL,MAAM,4BAA4B,CAAC;AAmBpC,OAAO,KAAK,EACV,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AA0BlB;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,2BAA2B,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/iframe-to-component/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,IAAI,EAGL,MAAM,4BAA4B,CAAC;AAmBpC,OAAO,KAAK,EACV,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AA0BlB;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,2BAA2B,GAAG,IAAI,CAwKxE;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,gDAAuD,CAAC"}
|
|
@@ -34,22 +34,23 @@ function ngAddIframeFn(options) {
|
|
|
34
34
|
from: '@angular/core',
|
|
35
35
|
importNames: [
|
|
36
36
|
'AfterViewInit',
|
|
37
|
+
'DestroyRef',
|
|
37
38
|
'ElementRef',
|
|
38
|
-
'
|
|
39
|
+
'inject',
|
|
39
40
|
'viewChild'
|
|
40
41
|
]
|
|
41
42
|
},
|
|
42
43
|
{
|
|
43
|
-
from: '@
|
|
44
|
+
from: '@angular/core/rxjs-interop',
|
|
44
45
|
importNames: [
|
|
45
|
-
'
|
|
46
|
-
'IframeBridge'
|
|
46
|
+
'takeUntilDestroyed'
|
|
47
47
|
]
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
|
-
from: '
|
|
50
|
+
from: '@o3r/third-party',
|
|
51
51
|
importNames: [
|
|
52
|
-
'
|
|
52
|
+
'generateIFrameContent',
|
|
53
|
+
'IframeBridge'
|
|
53
54
|
]
|
|
54
55
|
}
|
|
55
56
|
]),
|
|
@@ -61,7 +62,7 @@ function ngAddIframeFn(options) {
|
|
|
61
62
|
const visit = (node) => {
|
|
62
63
|
if (ts.isClassDeclaration(node)) {
|
|
63
64
|
const implementsClauses = node.heritageClauses?.find((heritageClause) => heritageClause.token === ts.SyntaxKind.ImplementsKeyword);
|
|
64
|
-
const interfaceToImplements = (0, schematics_2.generateImplementsExpressionWithTypeArguments)('
|
|
65
|
+
const interfaceToImplements = (0, schematics_2.generateImplementsExpressionWithTypeArguments)('AfterViewInit');
|
|
65
66
|
const deduplicateHeritageClauses = (clauses) => clauses.filter((h, i) => !clauses.slice(i + 1).some((h2) => h2.kind === h.kind && h2.expression.escapedText === h.expression.escapedText));
|
|
66
67
|
const newImplementsClauses = implementsClauses
|
|
67
68
|
? factory.updateHeritageClause(implementsClauses, deduplicateHeritageClauses([...implementsClauses.types, ...interfaceToImplements]))
|
|
@@ -72,49 +73,39 @@ function ngAddIframeFn(options) {
|
|
|
72
73
|
const newModifiers = []
|
|
73
74
|
.concat(ts.getDecorators(node) || [])
|
|
74
75
|
.concat(ts.getModifiers(node) || []);
|
|
75
|
-
const hasSubscriptions = node.members.find((classElement) => ts.isPropertyDeclaration(classElement)
|
|
76
|
-
&& ts.isIdentifier(classElement.name)
|
|
77
|
-
&& classElement.name.escapedText.toString() === 'subscriptions');
|
|
78
76
|
const propertiesToAdd = (0, schematics_2.generateClassElementsFromString)(`
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
private frame = viewChild.required<ElementRef<HTMLIFrameElement>>('frame');
|
|
78
|
+
private bridge?: IframeBridge;
|
|
79
|
+
private readonly destroyRef = inject(DestroyRef);
|
|
82
80
|
`);
|
|
83
81
|
const newNgAfterViewInit = (0, schematics_2.getSimpleUpdatedMethod)(node, factory, 'ngAfterViewInit', (0, schematics_2.generateBlockStatementsFromString)(`
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
);
|
|
105
|
-
}
|
|
82
|
+
const nativeElem = this.frame().nativeElement;
|
|
83
|
+
if (nativeElem.contentDocument) {
|
|
84
|
+
nativeElem.contentDocument.write(
|
|
85
|
+
generateIFrameContent(
|
|
86
|
+
'', // third-party-script-url
|
|
87
|
+
'' // third-party-html-headers-to-add
|
|
88
|
+
)
|
|
89
|
+
);
|
|
90
|
+
nativeElem.contentDocument.close();
|
|
91
|
+
}
|
|
92
|
+
if (nativeElem.contentWindow) {
|
|
93
|
+
this.bridge = new IframeBridge(window, nativeElem);
|
|
94
|
+
this.bridge.messages$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((message) => {
|
|
95
|
+
switch (message.action) {
|
|
96
|
+
// custom logic based on received message
|
|
97
|
+
default:
|
|
98
|
+
console.warn('Received unsupported action: ', message.action);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
106
102
|
`));
|
|
107
|
-
const newNgOnDestroy = (0, schematics_2.getSimpleUpdatedMethod)(node, factory, 'ngOnDestroy', (0, schematics_2.generateBlockStatementsFromString)(`
|
|
108
|
-
this.subscriptions.forEach((subscription) => subscription.unsubscribe());
|
|
109
|
-
`));
|
|
110
103
|
const newMembers = node.members
|
|
111
|
-
.filter((classElement) => !(
|
|
112
|
-
|
|
113
|
-
.concat(propertiesToAdd, newNgAfterViewInit, ...(hasSubscriptions ? [] : [newNgOnDestroy]))
|
|
104
|
+
.filter((classElement) => !(0, schematics_2.findMethodByName)('ngAfterViewInit')(classElement))
|
|
105
|
+
.concat(propertiesToAdd, newNgAfterViewInit)
|
|
114
106
|
.sort(schematics_2.sortClassElement);
|
|
115
107
|
(0, schematics_2.addCommentsOnClassProperties)(newMembers, {
|
|
116
|
-
bridge: 'Iframe object template reference'
|
|
117
|
-
subscriptions: 'List of subscriptions to unsubscribe on destroy'
|
|
108
|
+
bridge: 'Iframe object template reference'
|
|
118
109
|
});
|
|
119
110
|
return factory.updateClassDeclaration(node, newModifiers, node.name, node.typeParameters, heritageClauses, newMembers);
|
|
120
111
|
}
|