onejs-core 1.0.13 → 1.0.14
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/definitions/Assemblies/OneJS.Runtime.d.ts +11 -15
- package/definitions/augments.d.ts +8 -5
- package/definitions/globals.d.ts +6 -6
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/subscribe.d.ts +4 -0
- package/dist/utils/subscribe.js +10 -0
- package/package.json +1 -1
- package/utils/index.ts +1 -0
- package/utils/subscribe.ts +17 -0
|
@@ -65,17 +65,21 @@ declare namespace CS {
|
|
|
65
65
|
public includeGlobalObjects : boolean
|
|
66
66
|
public constructor ()
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
interface IEngineHost {
|
|
69
|
+
add_onReload ($value: System.Action) : void
|
|
70
|
+
remove_onReload ($value: System.Action) : void
|
|
71
|
+
add_onDispose ($value: System.Action) : void
|
|
72
|
+
remove_onDispose ($value: System.Action) : void
|
|
73
|
+
}
|
|
74
|
+
class EngineHost extends System.Object implements System.IDisposable, IEngineHost
|
|
69
75
|
{
|
|
70
76
|
protected [__keep_incompatibility]: never;
|
|
71
|
-
public add_onReload ($value:
|
|
72
|
-
public remove_onReload ($value:
|
|
73
|
-
public
|
|
74
|
-
public
|
|
77
|
+
public add_onReload ($value: System.Action) : void
|
|
78
|
+
public remove_onReload ($value: System.Action) : void
|
|
79
|
+
public add_onDispose ($value: System.Action) : void
|
|
80
|
+
public remove_onDispose ($value: System.Action) : void
|
|
75
81
|
public subscribe ($eventSource: any, $eventName: string, $handler: Function) : System.Action
|
|
76
82
|
public subscribe ($eventName: string, $handler: Function) : System.Action
|
|
77
|
-
public InvokeOnReload () : void
|
|
78
|
-
public InvokeOnDestroy () : void
|
|
79
83
|
public Dispose () : void
|
|
80
84
|
public constructor ($engine: OneJS.ScriptEngine)
|
|
81
85
|
}
|
|
@@ -446,14 +450,6 @@ declare namespace CS {
|
|
|
446
450
|
public constructor ()
|
|
447
451
|
}
|
|
448
452
|
}
|
|
449
|
-
namespace OneJS.EngineHost {
|
|
450
|
-
interface ActionCallback
|
|
451
|
-
{
|
|
452
|
-
() : void;
|
|
453
|
-
Invoke?: () => void;
|
|
454
|
-
}
|
|
455
|
-
var ActionCallback: { new (func: () => void): ActionCallback; }
|
|
456
|
-
}
|
|
457
453
|
namespace Puerts {
|
|
458
454
|
class GenericDelegate extends System.Object
|
|
459
455
|
{
|
|
@@ -34,11 +34,14 @@ declare global {
|
|
|
34
34
|
const cancelAnimationFrame: (id: number) => void
|
|
35
35
|
|
|
36
36
|
const console: {
|
|
37
|
-
log: (...args: any[]) => void
|
|
38
|
-
|
|
39
|
-
warn: (...args: any[]) => void
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
log: (...args: any[]) => void;
|
|
38
|
+
info: (...args: any[]) => void;
|
|
39
|
+
warn: (...args: any[]) => void;
|
|
40
|
+
error: (...args: any[]) => void;
|
|
41
|
+
trace: (...args: any[]) => void;
|
|
42
|
+
assert: (condition: boolean, ...args: any[]) => void;
|
|
43
|
+
time: (label: string) => void;
|
|
44
|
+
timeEnd: (label: string) => void;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
interface Event {
|
package/definitions/globals.d.ts
CHANGED
|
@@ -12,13 +12,13 @@ declare namespace OneJS {
|
|
|
12
12
|
declare const onejs: {
|
|
13
13
|
add_onReload(handler: () => void): void
|
|
14
14
|
remove_onReload(handler: () => void): void
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
add_onDispose(handler: () => void): void
|
|
16
|
+
remove_onDispose(handler: () => void): void
|
|
17
17
|
|
|
18
|
-
interop: { // TODO
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
18
|
+
// interop: { // TODO
|
|
19
|
+
// classes: Record<string, any>
|
|
20
|
+
// objects: Record<string, any>
|
|
21
|
+
// }
|
|
22
22
|
|
|
23
23
|
subscribe<T, K extends OneJS.EventKeys<T>>(
|
|
24
24
|
eventSource: T,
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -10,3 +10,4 @@ export { parseColor, parseCSSColor, colorStrToF4, namedColor, namedColors } from
|
|
|
10
10
|
export { palettes } from "./color-palettes";
|
|
11
11
|
// @ts-ignore - prevent `allowImportingTsExtensions` error
|
|
12
12
|
export { parseFloat2, parseFloat3, parseFloat4 } from "./float-parser";
|
|
13
|
+
export { subscribe } from "./subscribe";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Action, Delegate } from "System";
|
|
2
|
+
export function subscribe(target, eventName, callback) {
|
|
3
|
+
var action = new Action(callback);
|
|
4
|
+
target[eventName] = Delegate.Combine(target[eventName], action);
|
|
5
|
+
const unsubscribe = () => {
|
|
6
|
+
target[eventName] = Delegate.Remove(target[eventName], action);
|
|
7
|
+
};
|
|
8
|
+
onejs.add_onReload(unsubscribe);
|
|
9
|
+
return unsubscribe;
|
|
10
|
+
}
|
package/package.json
CHANGED
package/utils/index.ts
CHANGED
|
@@ -11,3 +11,4 @@ export { parseColor, parseCSSColor, colorStrToF4, namedColor, namedColors } from
|
|
|
11
11
|
export { palettes } from "./color-palettes"
|
|
12
12
|
// @ts-ignore - prevent `allowImportingTsExtensions` error
|
|
13
13
|
export { parseFloat2, parseFloat3, parseFloat4 } from "./float-parser"
|
|
14
|
+
export { subscribe } from "./subscribe"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Action, Delegate } from "System"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export function subscribe<T, K extends keyof T>(target: T, eventName: K, callback: () => void): () => void
|
|
5
|
+
export function subscribe<T, K extends keyof T>(target: { new(): T }, eventName: K, callback: () => void): () => void
|
|
6
|
+
export function subscribe(target: any, eventName: any, callback: () => void): () => void {
|
|
7
|
+
var action = new Action(callback)
|
|
8
|
+
target[eventName] = Delegate.Combine(target[eventName] as any, action) as any
|
|
9
|
+
|
|
10
|
+
const unsubscribe = () => {
|
|
11
|
+
target[eventName] = Delegate.Remove(target[eventName] as any, action) as any
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
onejs.add_onReload(unsubscribe)
|
|
15
|
+
|
|
16
|
+
return unsubscribe
|
|
17
|
+
}
|