metano-runtime 0.7.0 → 0.8.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.
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridges a C# `[This]`-decorated delegate (whose first parameter
|
|
3
|
+
* is the JavaScript receiver) onto a TypeScript-idiomatic
|
|
4
|
+
* `(this: T, ...args) => R` shape without forcing the generated
|
|
5
|
+
* lambda to use the `function` keyword.
|
|
6
|
+
*
|
|
7
|
+
* The transpiler emits the user's `(self, arg) => ...` lambda as a
|
|
8
|
+
* plain arrow — keeping `this` from the enclosing C# class lexically
|
|
9
|
+
* captured — and wraps it in {@link bindReceiver}. The wrapper is a
|
|
10
|
+
* classic `function` so the dispatching runtime (DOM event loop,
|
|
11
|
+
* native API, etc.) can rebind `this` on invocation; it then
|
|
12
|
+
* forwards that runtime `this` as the first positional argument to
|
|
13
|
+
* the wrapped arrow. The net effect:
|
|
14
|
+
*
|
|
15
|
+
* - arrow's first parameter (the receiver) carries the runtime
|
|
16
|
+
* `this` per call,
|
|
17
|
+
* - any reference to the keyword `this` inside the arrow body
|
|
18
|
+
* keeps pointing at the outer C# instance via the arrow's
|
|
19
|
+
* lexical scope — no body rewrite or `const self = this`
|
|
20
|
+
* shuffle needed.
|
|
21
|
+
*
|
|
22
|
+
* Compatible with delegates whose target-facing type reads
|
|
23
|
+
* `(this: Receiver, ...args: Rest) => R` — the TS compiler infers
|
|
24
|
+
* `Receiver`, `Rest`, and `R` from the wrapped arrow's signature.
|
|
25
|
+
*/
|
|
26
|
+
export declare function bindReceiver<Receiver, Rest extends readonly unknown[], R>(fn: (receiver: Receiver, ...rest: Rest) => R): (this: Receiver, ...args: Rest) => R;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridges a C# `[This]`-decorated delegate (whose first parameter
|
|
3
|
+
* is the JavaScript receiver) onto a TypeScript-idiomatic
|
|
4
|
+
* `(this: T, ...args) => R` shape without forcing the generated
|
|
5
|
+
* lambda to use the `function` keyword.
|
|
6
|
+
*
|
|
7
|
+
* The transpiler emits the user's `(self, arg) => ...` lambda as a
|
|
8
|
+
* plain arrow — keeping `this` from the enclosing C# class lexically
|
|
9
|
+
* captured — and wraps it in {@link bindReceiver}. The wrapper is a
|
|
10
|
+
* classic `function` so the dispatching runtime (DOM event loop,
|
|
11
|
+
* native API, etc.) can rebind `this` on invocation; it then
|
|
12
|
+
* forwards that runtime `this` as the first positional argument to
|
|
13
|
+
* the wrapped arrow. The net effect:
|
|
14
|
+
*
|
|
15
|
+
* - arrow's first parameter (the receiver) carries the runtime
|
|
16
|
+
* `this` per call,
|
|
17
|
+
* - any reference to the keyword `this` inside the arrow body
|
|
18
|
+
* keeps pointing at the outer C# instance via the arrow's
|
|
19
|
+
* lexical scope — no body rewrite or `const self = this`
|
|
20
|
+
* shuffle needed.
|
|
21
|
+
*
|
|
22
|
+
* Compatible with delegates whose target-facing type reads
|
|
23
|
+
* `(this: Receiver, ...args: Rest) => R` — the TS compiler infers
|
|
24
|
+
* `Receiver`, `Rest`, and `R` from the wrapped arrow's signature.
|
|
25
|
+
*/
|
|
26
|
+
export function bindReceiver(fn) {
|
|
27
|
+
return function (...args) {
|
|
28
|
+
return fn(this, ...args);
|
|
29
|
+
};
|
|
30
|
+
}
|
package/dist/system/index.d.ts
CHANGED
package/dist/system/index.js
CHANGED