Skip to content

Commit 32d8bdd

Browse files
feat(bindgen): add drop for external stream class
1 parent 5591ba9 commit 32d8bdd

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

crates/js-component-bindgen/src/intrinsics/lift.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,7 @@ impl LiftIntrinsic {
10501050
isWritable: streamEnd.isWritable(),
10511051
writeFn: (v) => {{ return streamEnd.write(v); }},
10521052
readFn: () => {{ return streamEnd.read(); }},
1053+
dropFn: () => {{ return streamEnd.drop(); }},
10531054
}});
10541055
10551056
return [ stream, ctx ];

crates/js-component-bindgen/src/intrinsics/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,8 +1015,9 @@ pub struct RenderIntrinsicsArgs<'a> {
10151015
}
10161016

10171017
/// Intrinsics that should be rendered as early as possible
1018-
const EARLY_INTRINSICS: [Intrinsic; 31] = [
1018+
const EARLY_INTRINSICS: [Intrinsic; 32] = [
10191019
Intrinsic::PromiseWithResolversPonyfill,
1020+
Intrinsic::SymbolDispose,
10201021
Intrinsic::DebugLog,
10211022
Intrinsic::GlobalAsyncDeterminism,
10221023
Intrinsic::GlobalComponentMemoryMap,

crates/js-component-bindgen/src/intrinsics/p3/async_stream.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,8 @@ impl AsyncStreamIntrinsic {
12121212
Self::ExternalStreamClass => {
12131213
let debug_log_fn = Intrinsic::DebugLog.name();
12141214
let external_stream_class_name = self.name();
1215+
let symbol_dispose = Intrinsic::SymbolDispose.name();
1216+
12151217
output.push_str(&format!(
12161218
r#"
12171219
class {external_stream_class_name} {{
@@ -1220,6 +1222,7 @@ impl AsyncStreamIntrinsic {
12201222
#isWritable;
12211223
#writeFn;
12221224
#readFn;
1225+
#dropFn;
12231226
12241227
constructor(args) {{
12251228
{debug_log_fn}('[{external_stream_class_name}#constructor()] args', args);
@@ -1237,6 +1240,8 @@ impl AsyncStreamIntrinsic {
12371240
12381241
if (this.#isReadable && args.readFn === undefined) {{ throw new TypeError("missing read fn"); }}
12391242
this.#readFn = args.readFn;
1243+
1244+
this.#dropFn = args.dropFn;
12401245
}}
12411246
12421247
globalRep() {{ return this.#globalRep; }}
@@ -1259,6 +1264,11 @@ impl AsyncStreamIntrinsic {
12591264
12601265
this.#writeFn(obj);
12611266
}}
1267+
1268+
[{symbol_dispose}]() {{
1269+
this.#dropFn();
1270+
}}
1271+
12621272
}}
12631273
"#
12641274
));

0 commit comments

Comments
 (0)