Skip to content

Commit 7d4f36e

Browse files
committed
[core] add dpsc types to config
1 parent a06492b commit 7d4f36e

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

rewriter/wasm/src/jsr.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extern "C" {
2828

2929
#[wasm_bindgen(typescript_custom_section)]
3030
const REWRITER_OUTPUT: &'static str = r#"
31-
export type JsRewriterOutput = {
31+
export type JsRewriterOutput = {
3232
js: Uint8Array,
3333
map: Uint8Array,
3434
scramtag: string,
@@ -49,8 +49,11 @@ fn get_config(scramjet: &Object) -> Result<Config> {
4949
Ok(Config {
5050
prefix: get_str(config, "prefix")?,
5151

52+
wrapgetbase: get_str(globals, "wrapgetbase")?,
53+
wrapsetbase: get_str(globals, "wrapsetbase")?,
54+
wrapcomputedgetfn: get_str(globals, "wrapcomputedgetfn")?,
55+
wrapcomputedsetfn: get_str(globals, "wrapcomputedsetfn")?,
5256
wrapfn: get_str(globals, "wrapfn")?,
53-
wrapthisfn: get_str(globals, "wrapthisfn")?,
5457
importfn: get_str(globals, "importfn")?,
5558
rewritefn: get_str(globals, "rewritefn")?,
5659
metafn: get_str(globals, "metafn")?,

src/client/shared/wrap.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,15 @@ export default function (client: ScramjetClient, self: typeof globalThis) {
5555
writable: false,
5656
configurable: false,
5757
});
58-
Object.defineProperty(self, config.globals.wrapthisfn, {
59-
value: function (i) {
60-
if (i === self) return client.globalProxy;
58+
Object.defineProperty(self, config.globals.wrapcomputedgetfn, {
59+
value: function (val, prop) {
60+
if (val === self) {
61+
console.log(prop);
6162

62-
return i;
63+
return null;
64+
}
65+
66+
return Reflect.get(val, prop);
6367
},
6468
writable: false,
6569
configurable: false,

src/controller/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ export class ScramjetController {
1717
prefix: "/scramjet/",
1818
globals: {
1919
wrapfn: "$scramjet$wrap",
20-
wrapthisfn: "$scramjet$wrapthis",
20+
wrapgetbase: "$scramjet$get_",
21+
wrapsetbase: "$scramjet$get_",
22+
wrapcomputedgetfn: "$scramjet$get",
23+
wrapcomputedsetfn: "$scramjet$get",
2124
trysetfn: "$scramjet$tryset",
2225
importfn: "$scramjet$import",
2326
rewritefn: "$scramjet$rewrite",

src/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ export interface ScramjetConfig {
1919
prefix: string;
2020
globals: {
2121
wrapfn: string;
22-
wrapthisfn: string;
22+
wrapsetbase: string;
23+
wrapgetbase: string;
24+
wrapcomputedgetfn: string;
25+
wrapcomputedsetfn: string;
2326
trysetfn: string;
2427
importfn: string;
2528
rewritefn: string;

0 commit comments

Comments
 (0)