unreal-toolkit 0.1.11 → 0.1.12
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 +11 -0
- package/dist/index.d.ts +19 -20
- package/dist/unreal.toolkit.d.ts +19 -20
- package/dist/unreal.toolkit.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -16,3 +16,14 @@ npm install unreal-toolkit
|
|
16
16
|
```javascript
|
17
17
|
import UnrealToolkit from 'unreal-toolkit';
|
18
18
|
```
|
19
|
+
|
20
|
+
* Unreal Toolkit Message Bus Usage
|
21
|
+
```typescript
|
22
|
+
// Post window message
|
23
|
+
UnrealToolkit.EventBus.PostWindowMessage("myevent", ["Hello World!"]);
|
24
|
+
|
25
|
+
// Handle window message
|
26
|
+
UnrealToolkit.EventBus.OnWindowMessage("myevent", (args:string[]) => {
|
27
|
+
console.log("My Event Args: ", args);
|
28
|
+
});
|
29
|
+
```
|
package/dist/index.d.ts
CHANGED
@@ -8,13 +8,13 @@ export declare class UnrealToolkit {
|
|
8
8
|
/** Unreal Toolkit event message bus
|
9
9
|
* @example
|
10
10
|
* ```typescript
|
11
|
-
* //
|
12
|
-
* UnrealToolkit.EventBus.
|
13
|
-
* console.log("My Event Data: " + data);
|
14
|
-
* });
|
11
|
+
* // Post myevent window message
|
12
|
+
* UnrealToolkit.EventBus.PostWindowMessage("myevent", ["Hello World!"]);
|
15
13
|
*
|
16
|
-
* //
|
17
|
-
* UnrealToolkit.EventBus.
|
14
|
+
* // Handle myevent window message
|
15
|
+
* UnrealToolkit.EventBus.OnWindowMessage("myevent", (args:string[]) => {
|
16
|
+
* console.log("My Event Args: ", args);
|
17
|
+
* });
|
18
18
|
* ```
|
19
19
|
*/
|
20
20
|
static get EventBus(): UnrealMessageBus;
|
@@ -24,28 +24,27 @@ export declare class UnrealToolkit {
|
|
24
24
|
* @class UnrealMessageBus - All rights reserved (c) 2024 Mackey Kinard
|
25
25
|
*/
|
26
26
|
export declare class UnrealMessageBus {
|
27
|
-
|
27
|
+
static AllowedOrigin: string;
|
28
|
+
static TargetOrigin: string;
|
28
29
|
constructor();
|
29
|
-
/**
|
30
|
-
* @param
|
31
|
-
* @param
|
30
|
+
/** Post event bus message
|
31
|
+
* @param name The message to post
|
32
|
+
* @param args The args to post
|
32
33
|
* @returns void
|
33
34
|
*/
|
34
|
-
|
35
|
-
/**
|
36
|
-
* @param
|
37
|
-
* @param
|
38
|
-
* @param target The target to post
|
39
|
-
* @param transfer The transfer to post
|
35
|
+
PostWindowMessage(name: string, args?: string[]): void;
|
36
|
+
/** Handle event bus message
|
37
|
+
* @param name The name to handle
|
38
|
+
* @param args The args to handle
|
40
39
|
* @returns void
|
41
40
|
*/
|
42
|
-
|
41
|
+
OnWindowMessage(name: string, handler: (args: string[]) => void): void;
|
43
42
|
/** Remove event bus message handler
|
44
43
|
* @param message The message to remove
|
45
44
|
* @param handler The handler to remove
|
46
45
|
* @returns void
|
47
46
|
*/
|
48
|
-
RemoveHandler(message: string, handler: (
|
47
|
+
RemoveHandler(message: string, handler: (args: string[]) => void): void;
|
49
48
|
/** Clear and reset all event bus message handlers
|
50
49
|
* @returns void
|
51
50
|
*/
|
@@ -60,8 +59,8 @@ export declare class UnrealMessageBus {
|
|
60
59
|
*/
|
61
60
|
private HandleWindowMessage;
|
62
61
|
/** Dispatch internal event bus message
|
63
|
-
* @param
|
64
|
-
* @param
|
62
|
+
* @param name The name to dispatch
|
63
|
+
* @param args The args to dispatch
|
65
64
|
* @returns void
|
66
65
|
*/
|
67
66
|
private OnDispatchMessage;
|
package/dist/unreal.toolkit.d.ts
CHANGED
@@ -8,13 +8,13 @@ export declare class UnrealToolkit {
|
|
8
8
|
/** Unreal Toolkit event message bus
|
9
9
|
* @example
|
10
10
|
* ```typescript
|
11
|
-
* //
|
12
|
-
* UnrealToolkit.EventBus.
|
13
|
-
* console.log("My Event Data: " + data);
|
14
|
-
* });
|
11
|
+
* // Post myevent window message
|
12
|
+
* UnrealToolkit.EventBus.PostWindowMessage("myevent", ["Hello World!"]);
|
15
13
|
*
|
16
|
-
* //
|
17
|
-
* UnrealToolkit.EventBus.
|
14
|
+
* // Handle myevent window message
|
15
|
+
* UnrealToolkit.EventBus.OnWindowMessage("myevent", (args:string[]) => {
|
16
|
+
* console.log("My Event Args: ", args);
|
17
|
+
* });
|
18
18
|
* ```
|
19
19
|
*/
|
20
20
|
static get EventBus(): UnrealMessageBus;
|
@@ -24,28 +24,27 @@ export declare class UnrealToolkit {
|
|
24
24
|
* @class UnrealMessageBus - All rights reserved (c) 2024 Mackey Kinard
|
25
25
|
*/
|
26
26
|
export declare class UnrealMessageBus {
|
27
|
-
|
27
|
+
static AllowedOrigin: string;
|
28
|
+
static TargetOrigin: string;
|
28
29
|
constructor();
|
29
|
-
/**
|
30
|
-
* @param
|
31
|
-
* @param
|
30
|
+
/** Post event bus message
|
31
|
+
* @param name The message to post
|
32
|
+
* @param args The args to post
|
32
33
|
* @returns void
|
33
34
|
*/
|
34
|
-
|
35
|
-
/**
|
36
|
-
* @param
|
37
|
-
* @param
|
38
|
-
* @param target The target to post
|
39
|
-
* @param transfer The transfer to post
|
35
|
+
PostWindowMessage(name: string, args?: string[]): void;
|
36
|
+
/** Handle event bus message
|
37
|
+
* @param name The name to handle
|
38
|
+
* @param args The args to handle
|
40
39
|
* @returns void
|
41
40
|
*/
|
42
|
-
|
41
|
+
OnWindowMessage(name: string, handler: (args: string[]) => void): void;
|
43
42
|
/** Remove event bus message handler
|
44
43
|
* @param message The message to remove
|
45
44
|
* @param handler The handler to remove
|
46
45
|
* @returns void
|
47
46
|
*/
|
48
|
-
RemoveHandler(message: string, handler: (
|
47
|
+
RemoveHandler(message: string, handler: (args: string[]) => void): void;
|
49
48
|
/** Clear and reset all event bus message handlers
|
50
49
|
* @returns void
|
51
50
|
*/
|
@@ -60,8 +59,8 @@ export declare class UnrealMessageBus {
|
|
60
59
|
*/
|
61
60
|
private HandleWindowMessage;
|
62
61
|
/** Dispatch internal event bus message
|
63
|
-
* @param
|
64
|
-
* @param
|
62
|
+
* @param name The name to dispatch
|
63
|
+
* @param args The args to dispatch
|
65
64
|
* @returns void
|
66
65
|
*/
|
67
66
|
private OnDispatchMessage;
|
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 i in t)e.o(t,i)&&!e.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)},n={};e.d(n,{default:()=>o});var t=function(){function e(){}return Object.defineProperty(e,"EventBus",{get:function(){return null==e._EventBus&&(e._EventBus=new i),e._EventBus},enumerable:!1,configurable:!0}),e._EventBus=null,e}(),i=function(){function e(){this.
|
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 i in t)e.o(t,i)&&!e.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:t[i]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n)},n={};e.d(n,{default:()=>o});var t=function(){function e(){}return Object.defineProperty(e,"EventBus",{get:function(){return null==e._EventBus&&(e._EventBus=new i),e._EventBus},enumerable:!1,configurable:!0}),e._EventBus=null,e}(),i=function(){function e(){this.ListenerDictionary={},this.HandleWindowMessage=this.HandleWindowMessage.bind(this),window.top.addEventListener("message",this.HandleWindowMessage)}return e.prototype.PostWindowMessage=function(n,t){try{window.top.postMessage({source:"unrealtoolkit",message:n,args:t},e.TargetOrigin)}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.RemoveHandler=function(e,n){var t=this.ListenerDictionary[e];if(null!=t){var i=t.findIndex((function(e){return n==e}));i>=0&&t.splice(i,1)}},e.prototype.ResetHandlers=function(){this.ListenerDictionary={}},e.prototype.Dispose=function(){this.ResetHandlers(),window.top.removeEventListener("message",this.HandleWindowMessage)},e.prototype.HandleWindowMessage=function(n){if(null!=n&&null!=n.origin&&null!=n.data&&null!=n.data.source&&null!=n.data.message)try{if(null!=e.AllowedOrigin&&""!==e.AllowedOrigin&&"*"!==e.AllowedOrigin&&n.origin!==e.AllowedOrigin)return void console.warn("UnrealMessageBus: Invalid Origin: "+n.origin);this.OnDispatchMessage(n.data.message,null!=n.data.args?n.data.args:null)}catch(e){console.warn(e)}},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.AllowedOrigin="*",e.TargetOrigin="*",e}();console.log("Unreal Toolkit Runtime - Version 0.1.8");const o=t;return n.default})()));
|