File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
packages/plugin/webview/src/lib Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,11 @@ function toKebabCase(text: string) {
1717 return text . replace ( / ( [ a - z 0 - 9 ] | (? = [ A - Z ] ) ) ( [ A - Z ] ) / g, '$1-$2' ) . toLowerCase ( ) ;
1818} ;
1919
20+ declare global {
21+ function acquireTheiaApi ( ) : any ;
22+ }
23+
24+
2025/**
2126 * This Webview connector
2227 */
@@ -26,9 +31,16 @@ export class WebviewConnector implements ClientConnector {
2631 isVscode : boolean
2732
2833 constructor ( private options : PluginOptions < any > ) {
29- this . isVscode = ( 'acquireVsCodeApi' in window )
34+ // @todo (#295) check if we can merge this statement in `this.isVscode = acquireVsCodeApi !== undefined`
35+ this . isVscode = ( 'acquireVsCodeApi' in window ) || acquireTheiaApi !== undefined
3036 // Check the parent source here
31- this . source = this . isVscode ? window [ 'acquireVsCodeApi' ] ( ) : window . parent
37+ if ( 'acquireVsCodeApi' in window ) {
38+ this . source = window [ 'acquireVsCodeApi' ] ( )
39+ } else if ( acquireTheiaApi !== undefined ) {
40+ this . source = acquireTheiaApi ( )
41+ } else {
42+ this . source = window . parent
43+ }
3244 }
3345
3446
You can’t perform that action at this time.
0 commit comments