Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/js-component-bindgen/src/intrinsics/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl ComponentIntrinsic {
"
class {class_name} {{
#callingAsyncImport = false;
#syncImportWait = Promise.withResolvers();
#syncImportWait = promiseWithResolvers();
#lock = null;

mayLeave = true;
Expand All @@ -156,7 +156,7 @@ impl ComponentIntrinsic {

#notifySyncImportEnd() {{
const existing = this.#syncImportWait;
this.#syncImportWait = Promise.withResolvers();
this.#syncImportWait = promiseWithResolvers();
existing.resolve();
}}

Expand Down Expand Up @@ -218,7 +218,7 @@ impl ComponentIntrinsic {
if (finishedTicket === ticket - 1n) {{ break; }}
}}

const {{ promise, resolve }} = Promise.withResolvers();
const {{ promise, resolve }} = promiseWithResolvers();
this.#lock = {{
ticket,
promise,
Expand Down
16 changes: 9 additions & 7 deletions crates/js-component-bindgen/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub enum Intrinsic {
Host(HostIntrinsic),

// Polyfills
PromiseWithResolversPolyfill,
PromiseWithResolversPonyfill,

/// Enable debug logging
DebugLog,
Expand Down Expand Up @@ -198,7 +198,7 @@ pub fn render_intrinsics(args: RenderIntrinsicsArgs) -> Source {
AsyncTaskIntrinsic::UnpackCallbackResult,
));
args.intrinsics
.insert(Intrinsic::PromiseWithResolversPolyfill);
.insert(Intrinsic::PromiseWithResolversPonyfill);
args.intrinsics
.insert(Intrinsic::Host(HostIntrinsic::PrepareCall));
args.intrinsics
Expand Down Expand Up @@ -674,19 +674,21 @@ pub fn render_intrinsics(args: RenderIntrinsicsArgs) -> Source {
));
}

Intrinsic::PromiseWithResolversPolyfill => {
Intrinsic::PromiseWithResolversPonyfill => {
output.push_str(
r#"
if (!Promise.withResolvers) {
Promise.withResolvers = () => {
function promiseWithResolvers() {
if (Promise.withResolvers) {
return Promise.withResolvers();
} else {
let resolve;
let reject;
const promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
return { promise, resolve, reject };
};
}
}
"#,
);
Expand Down Expand Up @@ -959,7 +961,7 @@ impl Intrinsic {

// Debugging
Intrinsic::DebugLog => "_debugLog",
Intrinsic::PromiseWithResolversPolyfill => unreachable!("always global"),
Intrinsic::PromiseWithResolversPonyfill => unreachable!("always global"),

// Types
Intrinsic::ConstantI32Min => "I32_MIN",
Expand Down
6 changes: 3 additions & 3 deletions crates/js-component-bindgen/src/intrinsics/p3/async_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ impl AsyncTaskIntrinsic {
promise: completionPromise,
resolve: resolveCompletionPromise,
reject: rejectCompletionPromise,
}} = Promise.withResolvers();
}} = promiseWithResolvers();
this.#completionPromise = completionPromise;

this.#onResolve = (results) => {{
Expand Down Expand Up @@ -785,7 +785,7 @@ impl AsyncTaskIntrinsic {
}}

// Build a promise that this task can await on which resolves when it is awoken
const {{ promise, resolve, reject }} = Promise.withResolvers();
const {{ promise, resolve, reject }} = promiseWithResolvers();
this.awaitableResume = () => {{
{debug_log_fn}('[{task_class}] resuming after onBlock', {{ taskID: this.#id }});
resolve();
Expand Down Expand Up @@ -988,7 +988,7 @@ impl AsyncTaskIntrinsic {
if (args.waitable) {{
this.#waitable = args.waitable;
}} else {{
const {{ promise, resolve, reject }} = Promise.withResolvers();
const {{ promise, resolve, reject }} = promiseWithResolvers();
this.#waitableResolve = resolve;
this.#waitableReject = reject;

Expand Down
Loading