unreal-toolkit 0.1.20 → 0.1.22
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +26 -11
- package/dist/index.d.ts +32 -20
- package/dist/unreal.toolkit.d.ts +32 -20
- package/dist/unreal.toolkit.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -5,6 +5,8 @@ with your hosted Unreal Engine streaming web application.
|
|
5
5
|
<a href="https://www.npmjs.com/package/unreal-toolkit-next">Next Edition (ES6)</a>
|
6
6
|
<br/>
|
7
7
|
<a href="https://github.com/codewrxai/UnrealToolkit/tree/master/cdn">Browser Edition (CDN)</a>
|
8
|
+
<br/>
|
9
|
+
<a href="https://github.com/codewrxai/UnrealToolkit/tree/master">Unreal Toolkit Plugin (UE5)</a>
|
8
10
|
|
9
11
|
|
10
12
|
## Default Installation (UMD)
|
@@ -12,22 +14,25 @@ with your hosted Unreal Engine streaming web application.
|
|
12
14
|
npm install unreal-toolkit
|
13
15
|
```
|
14
16
|
|
15
|
-
*
|
16
|
-
```
|
17
|
+
* Unreal Toolkit Runtime Library
|
18
|
+
```typescript
|
17
19
|
import UnrealToolkit from 'unreal-toolkit';
|
18
|
-
```
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
UnrealToolkit.EventBus.PostWindowMessage("WM_HELLO", ["Hello World!"]);
|
21
|
+
// Create IFRAME window for Unreal Engine content
|
22
|
+
const iframe = UnrealToolkit.Bridge.CreateWindow("game");
|
23
|
+
iframe.src = "your.unrealtoolkitproject.com";
|
24
24
|
|
25
|
-
// Handle
|
26
|
-
UnrealToolkit.
|
25
|
+
// Handle WM_EVENT message from Unreal Engine content
|
26
|
+
UnrealToolkit.Bridge.OnWindowMessage("WM_EVENT", (args:string[]) => {
|
27
27
|
console.log("My Event Args: ", args);
|
28
28
|
});
|
29
|
+
|
30
|
+
// Post WM_HELLO message safely to Unreal Engine content
|
31
|
+
UnrealToolkit.Bridge.PostWindowMessage("WM_HELLO", ["Hello World!"]);
|
29
32
|
```
|
30
33
|
|
34
|
+
## Additional Reference Information
|
35
|
+
|
31
36
|
* Unreal Toolkit Content Frame Style
|
32
37
|
```css
|
33
38
|
iframe {
|
@@ -41,12 +46,22 @@ iframe {
|
|
41
46
|
}
|
42
47
|
```
|
43
48
|
|
44
|
-
* Unreal Toolkit Content Frame
|
49
|
+
* Unreal Toolkit Content Frame Settings
|
45
50
|
```html
|
46
51
|
<iframe
|
47
|
-
src="your.unrealtoolkitproject.com"
|
48
52
|
crossorigin="anonymous"
|
49
53
|
allow="cross-origin-isolated"
|
50
54
|
sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-pointer-lock">
|
51
55
|
</iframe>
|
52
56
|
```
|
57
|
+
|
58
|
+
* Unreal Toolkit Required Response Headers
|
59
|
+
```json
|
60
|
+
headers: {
|
61
|
+
'Access-Control-Allow-Origin': '*',
|
62
|
+
'Cross-Origin-Opener-Policy': 'same-origin',
|
63
|
+
'Cross-Origin-Embedder-Policy': 'require-corp',
|
64
|
+
'Cross-Origin-Resource-Policy': 'cross-origin',
|
65
|
+
'Permissions-Policy': 'cross-origin-isolated=*'
|
66
|
+
}
|
67
|
+
```
|
package/dist/index.d.ts
CHANGED
@@ -1,29 +1,36 @@
|
|
1
1
|
/** UMD Type References */
|
2
2
|
/**
|
3
|
-
* Unreal Toolkit
|
3
|
+
* Unreal Toolkit Runtime Library
|
4
4
|
* @class UnrealToolkit - All rights reserved (c) 2024 Mackey Kinard
|
5
5
|
*/
|
6
6
|
export declare class UnrealToolkit {
|
7
|
-
private static
|
8
|
-
/** Unreal Toolkit
|
7
|
+
private static _Bridge;
|
8
|
+
/** Unreal Toolkit Communication Bridge (Event Bus)
|
9
9
|
* @example
|
10
|
-
*
|
11
|
-
*
|
12
|
-
* UnrealToolkit.EventBus.PostWindowMessage("WM_HELLO", ["Hello World!"]);
|
10
|
+
* ```typescript
|
11
|
+
* import UnrealToolkit from 'unreal-toolkit';
|
13
12
|
*
|
14
|
-
*
|
15
|
-
* UnrealToolkit.
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
|
20
|
-
|
13
|
+
* // Create IFRAME window for Unreal Engine content
|
14
|
+
* const iframe = UnrealToolkit.Bridge.CreateWindow("game");
|
15
|
+
* iframe.src = "your.unrealtoolkitproject.com";
|
16
|
+
*
|
17
|
+
* // Handle WM_EVENT message from Unreal Engine content
|
18
|
+
* UnrealToolkit.Bridge.OnWindowMessage("WM_EVENT", (args:string[]) => {
|
19
|
+
* console.log("My Event Args: ", args);
|
20
|
+
* });
|
21
|
+
*
|
22
|
+
* // Post WM_HELLO message safely to Unreal Engine content
|
23
|
+
* UnrealToolkit.Bridge.PostWindowMessage("WM_HELLO", ["Hello World!"]);
|
24
|
+
* ```
|
25
|
+
*/
|
26
|
+
static get Bridge(): EventMessageBus;
|
21
27
|
}
|
22
28
|
/**
|
23
|
-
* Unreal Toolkit Message Bus (Asynchronous
|
24
|
-
* @class
|
29
|
+
* Unreal Toolkit Event Message Bus (Asynchronous Message Communication)
|
30
|
+
* @class EventMessageBus - All rights reserved (c) 2024 Mackey Kinard
|
25
31
|
*/
|
26
|
-
export declare class
|
32
|
+
export declare class EventMessageBus {
|
33
|
+
static PostWindowID: string;
|
27
34
|
static AllowedOrigin: string;
|
28
35
|
static TargetOrigin: string;
|
29
36
|
static ContentFrames: NodeListOf<HTMLIFrameElement>;
|
@@ -40,6 +47,11 @@ export declare class UnrealMessageBus {
|
|
40
47
|
* @returns void
|
41
48
|
*/
|
42
49
|
OnWindowMessage(name: string, handler: (args: string[]) => void): void;
|
50
|
+
/** Creates or attaches a game window iframe
|
51
|
+
* @param id The iframe id to create
|
52
|
+
* @returns HTMLIFrameElement
|
53
|
+
*/
|
54
|
+
CreateWindow(id: string, display?: string): HTMLIFrameElement;
|
43
55
|
/** Remove event bus message handler
|
44
56
|
* @param message The message to remove
|
45
57
|
* @param handler The handler to remove
|
@@ -50,14 +62,14 @@ export declare class UnrealMessageBus {
|
|
50
62
|
* @returns void
|
51
63
|
*/
|
52
64
|
ResetHandlers(): void;
|
53
|
-
/** Dispose the unreal message bus
|
54
|
-
* @returns void
|
55
|
-
*/
|
56
|
-
Dispose(): void;
|
57
65
|
/** Resets the content frame list
|
58
66
|
* @returns void
|
59
67
|
*/
|
60
68
|
ResetContentFrames(): void;
|
69
|
+
/** Dispose the unreal message bus
|
70
|
+
* @returns void
|
71
|
+
*/
|
72
|
+
Dispose(): void;
|
61
73
|
/** Handle window message event
|
62
74
|
* @param event The message event to handle
|
63
75
|
* @returns void
|
package/dist/unreal.toolkit.d.ts
CHANGED
@@ -1,29 +1,36 @@
|
|
1
1
|
/** UMD Type References */
|
2
2
|
/**
|
3
|
-
* Unreal Toolkit
|
3
|
+
* Unreal Toolkit Runtime Library
|
4
4
|
* @class UnrealToolkit - All rights reserved (c) 2024 Mackey Kinard
|
5
5
|
*/
|
6
6
|
export declare class UnrealToolkit {
|
7
|
-
private static
|
8
|
-
/** Unreal Toolkit
|
7
|
+
private static _Bridge;
|
8
|
+
/** Unreal Toolkit Communication Bridge (Event Bus)
|
9
9
|
* @example
|
10
|
-
*
|
11
|
-
*
|
12
|
-
* UnrealToolkit.EventBus.PostWindowMessage("WM_HELLO", ["Hello World!"]);
|
10
|
+
* ```typescript
|
11
|
+
* import UnrealToolkit from 'unreal-toolkit';
|
13
12
|
*
|
14
|
-
*
|
15
|
-
* UnrealToolkit.
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
|
20
|
-
|
13
|
+
* // Create IFRAME window for Unreal Engine content
|
14
|
+
* const iframe = UnrealToolkit.Bridge.CreateWindow("game");
|
15
|
+
* iframe.src = "your.unrealtoolkitproject.com";
|
16
|
+
*
|
17
|
+
* // Handle WM_EVENT message from Unreal Engine content
|
18
|
+
* UnrealToolkit.Bridge.OnWindowMessage("WM_EVENT", (args:string[]) => {
|
19
|
+
* console.log("My Event Args: ", args);
|
20
|
+
* });
|
21
|
+
*
|
22
|
+
* // Post WM_HELLO message safely to Unreal Engine content
|
23
|
+
* UnrealToolkit.Bridge.PostWindowMessage("WM_HELLO", ["Hello World!"]);
|
24
|
+
* ```
|
25
|
+
*/
|
26
|
+
static get Bridge(): EventMessageBus;
|
21
27
|
}
|
22
28
|
/**
|
23
|
-
* Unreal Toolkit Message Bus (Asynchronous
|
24
|
-
* @class
|
29
|
+
* Unreal Toolkit Event Message Bus (Asynchronous Message Communication)
|
30
|
+
* @class EventMessageBus - All rights reserved (c) 2024 Mackey Kinard
|
25
31
|
*/
|
26
|
-
export declare class
|
32
|
+
export declare class EventMessageBus {
|
33
|
+
static PostWindowID: string;
|
27
34
|
static AllowedOrigin: string;
|
28
35
|
static TargetOrigin: string;
|
29
36
|
static ContentFrames: NodeListOf<HTMLIFrameElement>;
|
@@ -40,6 +47,11 @@ export declare class UnrealMessageBus {
|
|
40
47
|
* @returns void
|
41
48
|
*/
|
42
49
|
OnWindowMessage(name: string, handler: (args: string[]) => void): void;
|
50
|
+
/** Creates or attaches a game window iframe
|
51
|
+
* @param id The iframe id to create
|
52
|
+
* @returns HTMLIFrameElement
|
53
|
+
*/
|
54
|
+
CreateWindow(id: string, display?: string): HTMLIFrameElement;
|
43
55
|
/** Remove event bus message handler
|
44
56
|
* @param message The message to remove
|
45
57
|
* @param handler The handler to remove
|
@@ -50,14 +62,14 @@ export declare class UnrealMessageBus {
|
|
50
62
|
* @returns void
|
51
63
|
*/
|
52
64
|
ResetHandlers(): void;
|
53
|
-
/** Dispose the unreal message bus
|
54
|
-
* @returns void
|
55
|
-
*/
|
56
|
-
Dispose(): void;
|
57
65
|
/** Resets the content frame list
|
58
66
|
* @returns void
|
59
67
|
*/
|
60
68
|
ResetContentFrames(): void;
|
69
|
+
/** Dispose the unreal message bus
|
70
|
+
* @returns void
|
71
|
+
*/
|
72
|
+
Dispose(): void;
|
61
73
|
/** Handle window message event
|
62
74
|
* @param event The message event to handle
|
63
75
|
* @returns void
|
package/dist/unreal.toolkit.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.UnrealToolkit=n():e.UnrealToolkit=n()}(this,(()=>(()=>{"use strict";var e={d:(n,t)=>{for(var o in t)e.o(t,o)&&!e.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:t[o]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)},n={};e.d(n,{default:()=>i});var t=function(){function e(){}return Object.defineProperty(e,"
|
1
|
+
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.UnrealToolkit=n():e.UnrealToolkit=n()}(this,(()=>(()=>{"use strict";var e={d:(n,t)=>{for(var o in t)e.o(t,o)&&!e.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:t[o]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)},n={};e.d(n,{default:()=>i});var t=function(){function e(){}return Object.defineProperty(e,"Bridge",{get:function(){return null==e._Bridge&&(e._Bridge=new o),e._Bridge},enumerable:!1,configurable:!0}),e._Bridge=null,e}(),o=function(){function e(){this.ListenerDictionary={},this.HandleWindowMessage=this.HandleWindowMessage.bind(this),window.addEventListener("message",this.HandleWindowMessage)}return e.prototype.PostWindowMessage=function(n,t){try{null==e.ContentFrames&&(e.ContentFrames=document.querySelectorAll("iframe")),null!=e.ContentFrames?e.ContentFrames.forEach((function(o){var i;try{null!=e.PostWindowID&&""!==e.PostWindowID&&o.id!==e.PostWindowID||null===(i=o.contentWindow)||void 0===i||i.postMessage({source:"unrealtoolkit",message:n,args:t},e.TargetOrigin)}catch(e){console.warn(e)}})):console.warn("EventMessageBus: No Content Frames Found!")}catch(e){console.warn(e)}},e.prototype.OnWindowMessage=function(e,n){var t;null==this.ListenerDictionary[e]?(t=[],this.ListenerDictionary[e]=t):t=this.ListenerDictionary[e],t.findIndex((function(e){return n==e}))<0&&t.push(n)},e.prototype.CreateWindow=function(e,n){void 0===n&&(n="block");var t=document.getElementById(e);if(null!=t)return t;var o=document.createElement("iframe");return o.id=e||"game",o.allow="cross-origin-isolated",o.crossOrigin="anonymous",o.sandbox.add("allow-same-origin","allow-scripts","allow-popups","allow-forms","allow-pointer-lock"),o.style.position="absolute",o.style.width="100%",o.style.height="100%",o.style.minHeight="100vh",o.style.border="none",o.style.outline="none",o.style.zIndex="0",o.style.display=n||"block",document.body.insertBefore(o,document.body.firstChild),o},e.prototype.RemoveHandler=function(e,n){var t=this.ListenerDictionary[e];if(null!=t){var o=t.findIndex((function(e){return n==e}));o>=0&&t.splice(o,1)}},e.prototype.ResetHandlers=function(){this.ListenerDictionary={}},e.prototype.ResetContentFrames=function(){e.ContentFrames=null},e.prototype.Dispose=function(){this.ResetHandlers(),this.ResetContentFrames(),window.removeEventListener("message",this.HandleWindowMessage)},e.prototype.HandleWindowMessage=function(n){if(null!=n&&null!=n.origin&&null!=n.data)if(null==e.AllowedOrigin||""===e.AllowedOrigin||"*"===e.AllowedOrigin||n.origin===e.AllowedOrigin){var t=null,o=null;null!=n.data.type?"progress"===n.data.type?(t="WM_PROGRESS",o=null!=n.data.value?[n.data.value.toString()]:null):"loaded"===n.data.type?(t="WM_LOADED",o=null):"focus"===n.data.type?(t="WM_FOCUS",o=null):"blur"===n.data.type?(t="WM_BLUR",o=null):"pointer-lock-active"===n.data.type?(t="WM_POINTER_LOCK_ACTIVE",o=null):"pointer-lock-inactive"===n.data.type&&(t="WM_POINTER_LOCK_INACTIVE",o=null):null!=n.data.source&&"unrealtoolkit"===n.data.source&&null!=n.data.message&&(t=n.data.message,o=null!=n.data.args?n.data.args:null);try{null!=t&&this.OnDispatchMessage(t,o)}catch(e){console.warn(e)}}else console.warn("EventMessageBus: Invalid Origin: "+n.origin)},e.prototype.OnDispatchMessage=function(e,n){void 0===n&&(n=null);var t=this.ListenerDictionary[e];null!=t&&t.forEach((function(e){try{e&&e(n)}catch(e){console.warn(e)}}))},e.PostWindowID=null,e.AllowedOrigin="*",e.TargetOrigin="*",e.ContentFrames=null,e}();console.log("Unreal Toolkit Runtime - Version 0.1.8");const i=t;return n.default})()));
|