@gjsify/iframe 0.1.13 → 0.2.0
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/README.md +3 -3
- package/lib/esm/html-iframe-element.js +3 -3
- package/lib/esm/{iframe-widget.js → iframe-bridge.js} +4 -4
- package/lib/esm/index.js +2 -2
- package/lib/esm/message-bridge.js +1 -1
- package/lib/types/html-iframe-element.d.ts +4 -4
- package/lib/types/{iframe-widget.d.ts → iframe-bridge.d.ts} +140 -141
- package/lib/types/index.d.ts +2 -2
- package/lib/types/message-bridge.d.ts +1 -1
- package/lib/types/types/index.d.ts +3 -3
- package/package.json +11 -11
- package/src/html-iframe-element.ts +5 -5
- package/src/{iframe-widget.ts → iframe-bridge.ts} +10 -11
- package/src/index.spec.ts +1 -1
- package/src/index.ts +2 -2
- package/src/message-bridge.ts +1 -1
- package/src/property-symbol.ts +1 -1
- package/src/types/index.ts +3 -3
- package/tmp/.tsbuildinfo +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @gjsify/iframe
|
|
2
2
|
|
|
3
|
-
GJS implementation of HTMLIFrameElement using WebKit 6.0. Provides
|
|
3
|
+
GJS implementation of HTMLIFrameElement using WebKit 6.0. Provides IFrameBridge extending WebKit.WebView with postMessage bridge.
|
|
4
4
|
|
|
5
5
|
Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
|
|
6
6
|
|
|
@@ -15,9 +15,9 @@ yarn add @gjsify/iframe
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
|
-
import {
|
|
18
|
+
import { IFrameBridge } from '@gjsify/iframe';
|
|
19
19
|
|
|
20
|
-
const widget = new
|
|
20
|
+
const widget = new IFrameBridge();
|
|
21
21
|
|
|
22
22
|
widget.onReady((iframe) => {
|
|
23
23
|
iframe.contentWindow?.addEventListener('message', (event) => {
|
|
@@ -6,7 +6,7 @@ const { tagName, localName, namespaceURI } = PropertySymbol;
|
|
|
6
6
|
class HTMLIFrameElement extends HTMLElement {
|
|
7
7
|
constructor() {
|
|
8
8
|
super();
|
|
9
|
-
/** @internal The backing
|
|
9
|
+
/** @internal The backing IFrameBridge (set by IFrameBridge when it creates this element) */
|
|
10
10
|
this[_c] = null;
|
|
11
11
|
/** @internal The contentWindow proxy */
|
|
12
12
|
this[_b] = null;
|
|
@@ -85,7 +85,7 @@ class HTMLIFrameElement extends HTMLElement {
|
|
|
85
85
|
// -- Content access --
|
|
86
86
|
/**
|
|
87
87
|
* Returns the window proxy for the iframe's content.
|
|
88
|
-
* Available after the
|
|
88
|
+
* Available after the IFrameBridge has loaded content.
|
|
89
89
|
*/
|
|
90
90
|
get contentWindow() {
|
|
91
91
|
return this[PS.windowProxy];
|
|
@@ -115,7 +115,7 @@ class HTMLIFrameElement extends HTMLElement {
|
|
|
115
115
|
get [(_c = PS.iframeWidget, _b = PS.windowProxy, _a = PS.loaded, Symbol.toStringTag)]() {
|
|
116
116
|
return "HTMLIFrameElement";
|
|
117
117
|
}
|
|
118
|
-
// -- Internal: called by
|
|
118
|
+
// -- Internal: called by IFrameBridge --
|
|
119
119
|
/** @internal Fire load event */
|
|
120
120
|
_onLoad() {
|
|
121
121
|
this[PS.loaded] = true;
|
|
@@ -4,9 +4,9 @@ import { HTMLIFrameElement } from "./html-iframe-element.js";
|
|
|
4
4
|
import { IFrameWindowProxy } from "./iframe-window-proxy.js";
|
|
5
5
|
import { MessageBridge } from "./message-bridge.js";
|
|
6
6
|
import * as PS from "./property-symbol.js";
|
|
7
|
-
const
|
|
8
|
-
{ GTypeName: "
|
|
9
|
-
class
|
|
7
|
+
const IFrameBridge = GObject.registerClass(
|
|
8
|
+
{ GTypeName: "GjsifyIFrameBridge" },
|
|
9
|
+
class IFrameBridge2 extends WebKit.WebView {
|
|
10
10
|
constructor(options) {
|
|
11
11
|
const { enableDeveloperExtras, enableJavascript, ...webViewProps } = options ?? {};
|
|
12
12
|
const userContentManager = new WebKit.UserContentManager();
|
|
@@ -103,5 +103,5 @@ const IFrameWidget = GObject.registerClass(
|
|
|
103
103
|
}
|
|
104
104
|
);
|
|
105
105
|
export {
|
|
106
|
-
|
|
106
|
+
IFrameBridge
|
|
107
107
|
};
|
package/lib/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HTMLIFrameElement } from "./html-iframe-element.js";
|
|
2
|
-
import {
|
|
2
|
+
import { IFrameBridge } from "./iframe-bridge.js";
|
|
3
3
|
import { IFrameWindowProxy } from "./iframe-window-proxy.js";
|
|
4
4
|
import { MessageBridge } from "./message-bridge.js";
|
|
5
5
|
import { Document } from "@gjsify/dom-elements";
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(globalThis, "HTMLIFrameElement", {
|
|
|
12
12
|
});
|
|
13
13
|
export {
|
|
14
14
|
HTMLIFrameElement,
|
|
15
|
-
|
|
15
|
+
IFrameBridge,
|
|
16
16
|
IFrameWindowProxy,
|
|
17
17
|
MessageBridge
|
|
18
18
|
};
|
|
@@ -38,7 +38,7 @@ class MessageBridge {
|
|
|
38
38
|
setWindowProxy(proxy) {
|
|
39
39
|
this._windowProxy = proxy;
|
|
40
40
|
}
|
|
41
|
-
/** Update current URI (called by
|
|
41
|
+
/** Update current URI (called by IFrameBridge on load-changed) */
|
|
42
42
|
updateUri(uri) {
|
|
43
43
|
this._currentUri = uri;
|
|
44
44
|
}
|
|
@@ -4,14 +4,14 @@ import type { IFrameWindowProxy } from './iframe-window-proxy.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* HTML IFrame Element.
|
|
6
6
|
*
|
|
7
|
-
* Backed by WebKit.WebView when connected to an
|
|
7
|
+
* Backed by WebKit.WebView when connected to an IFrameBridge.
|
|
8
8
|
* Without a backing widget, behaves as a pure DOM element with attribute storage.
|
|
9
9
|
*
|
|
10
10
|
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement
|
|
11
11
|
*/
|
|
12
12
|
export declare class HTMLIFrameElement extends HTMLElement {
|
|
13
|
-
/** @internal The backing
|
|
14
|
-
[PS.iframeWidget]: import('./iframe-
|
|
13
|
+
/** @internal The backing IFrameBridge (set by IFrameBridge when it creates this element) */
|
|
14
|
+
[PS.iframeWidget]: import('./iframe-bridge.js').IFrameBridge | null;
|
|
15
15
|
/** @internal The contentWindow proxy */
|
|
16
16
|
[PS.windowProxy]: IFrameWindowProxy | null;
|
|
17
17
|
/** @internal Whether content has been loaded */
|
|
@@ -37,7 +37,7 @@ export declare class HTMLIFrameElement extends HTMLElement {
|
|
|
37
37
|
set height(value: string);
|
|
38
38
|
/**
|
|
39
39
|
* Returns the window proxy for the iframe's content.
|
|
40
|
-
* Available after the
|
|
40
|
+
* Available after the IFrameBridge has loaded content.
|
|
41
41
|
*/
|
|
42
42
|
get contentWindow(): IFrameWindowProxy | null;
|
|
43
43
|
/**
|