mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +00:00
Merge branch 'main' into add-workers-gen-go-command
This commit is contained in:
commit
9895c004f4
24
examples/assets/shim.mjs
Normal file
24
examples/assets/shim.mjs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import "./polyfill_performance.js";
|
||||||
|
import "./wasm_exec.js";
|
||||||
|
|
||||||
|
const go = new Go();
|
||||||
|
|
||||||
|
let mod;
|
||||||
|
|
||||||
|
export function init(m) {
|
||||||
|
mod = m;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function run() {
|
||||||
|
const readyPromise = new Promise((resolve) => {
|
||||||
|
globalThis.ready = resolve;
|
||||||
|
});
|
||||||
|
const instance = new WebAssembly.Instance(mod, go.importObject);
|
||||||
|
go.run(instance);
|
||||||
|
await readyPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetch(req, env, ctx) {
|
||||||
|
await run();
|
||||||
|
return handleRequest(req, { env, ctx });
|
||||||
|
}
|
@ -1,22 +1,6 @@
|
|||||||
import "../assets/polyfill_performance.js";
|
import * as imports from "../assets/shim.mjs";
|
||||||
import "../assets/wasm_exec.js";
|
|
||||||
import mod from "./dist/app.wasm";
|
import mod from "./dist/app.wasm";
|
||||||
|
|
||||||
const go = new Go();
|
imports.init(mod);
|
||||||
|
|
||||||
const readyPromise = new Promise((resolve) => {
|
export default { fetch: imports.fetch }
|
||||||
globalThis.ready = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const load = WebAssembly.instantiate(mod, go.importObject).then((instance) => {
|
|
||||||
go.run(instance);
|
|
||||||
return instance;
|
|
||||||
});
|
|
||||||
|
|
||||||
export default {
|
|
||||||
async fetch(req, env, ctx) {
|
|
||||||
await load;
|
|
||||||
await readyPromise;
|
|
||||||
return handleRequest(req, { env, ctx });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
22
examples/cache/worker.mjs
vendored
22
examples/cache/worker.mjs
vendored
@ -1,22 +1,6 @@
|
|||||||
import "../assets/polyfill_performance.js";
|
import * as imports from "../assets/shim.mjs";
|
||||||
import "../assets/wasm_exec.js";
|
|
||||||
import mod from "./dist/app.wasm";
|
import mod from "./dist/app.wasm";
|
||||||
|
|
||||||
const go = new Go();
|
imports.init(mod);
|
||||||
|
|
||||||
const readyPromise = new Promise((resolve) => {
|
export default { fetch: imports.fetch }
|
||||||
globalThis.ready = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const load = WebAssembly.instantiate(mod, go.importObject).then((instance) => {
|
|
||||||
go.run(instance);
|
|
||||||
return instance;
|
|
||||||
});
|
|
||||||
|
|
||||||
export default {
|
|
||||||
async fetch(req, env, ctx) {
|
|
||||||
await load;
|
|
||||||
await readyPromise;
|
|
||||||
return handleRequest(req, { env, ctx });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,6 @@
|
|||||||
import "../assets/polyfill_performance.js";
|
import * as imports from "../assets/shim.mjs";
|
||||||
import "../assets/wasm_exec.js";
|
|
||||||
import mod from "./dist/app.wasm";
|
import mod from "./dist/app.wasm";
|
||||||
|
|
||||||
const go = new Go();
|
imports.init(mod);
|
||||||
|
|
||||||
const readyPromise = new Promise((resolve) => {
|
export default { fetch: imports.fetch }
|
||||||
globalThis.ready = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const load = WebAssembly.instantiate(mod, go.importObject).then((instance) => {
|
|
||||||
go.run(instance);
|
|
||||||
return instance;
|
|
||||||
});
|
|
||||||
|
|
||||||
export default {
|
|
||||||
async fetch(req, env, ctx) {
|
|
||||||
await load;
|
|
||||||
await readyPromise;
|
|
||||||
return handleRequest(req, { env, ctx });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,25 +1,9 @@
|
|||||||
import "../assets/polyfill_performance.js";
|
import * as imports from "../assets/shim.mjs";
|
||||||
import "../assets/wasm_exec.js";
|
|
||||||
import mod from "./dist/app.wasm";
|
import mod from "./dist/app.wasm";
|
||||||
|
|
||||||
const go = new Go();
|
imports.init(mod);
|
||||||
|
|
||||||
const readyPromise = new Promise((resolve) => {
|
export default { fetch: imports.fetch }
|
||||||
globalThis.ready = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const load = WebAssembly.instantiate(mod, go.importObject).then((instance) => {
|
|
||||||
go.run(instance);
|
|
||||||
return instance;
|
|
||||||
});
|
|
||||||
|
|
||||||
export default {
|
|
||||||
async fetch(req, env, ctx) {
|
|
||||||
await load;
|
|
||||||
await readyPromise;
|
|
||||||
return handleRequest(req, { env, ctx });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Durable Object
|
// Durable Object
|
||||||
|
|
||||||
|
22
examples/env/worker.mjs
vendored
22
examples/env/worker.mjs
vendored
@ -1,22 +1,6 @@
|
|||||||
import "../assets/polyfill_performance.js";
|
import * as imports from "../assets/shim.mjs";
|
||||||
import "../assets/wasm_exec.js";
|
|
||||||
import mod from "./dist/app.wasm";
|
import mod from "./dist/app.wasm";
|
||||||
|
|
||||||
const go = new Go();
|
imports.init(mod);
|
||||||
|
|
||||||
const readyPromise = new Promise((resolve) => {
|
export default { fetch: imports.fetch }
|
||||||
globalThis.ready = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const load = WebAssembly.instantiate(mod, go.importObject).then((instance) => {
|
|
||||||
go.run(instance);
|
|
||||||
return instance;
|
|
||||||
});
|
|
||||||
|
|
||||||
export default {
|
|
||||||
async fetch(req, env, ctx) {
|
|
||||||
await load;
|
|
||||||
await readyPromise;
|
|
||||||
return handleRequest(req, { env, ctx });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,6 @@
|
|||||||
import "../assets/polyfill_performance.js";
|
import * as imports from "../assets/shim.mjs";
|
||||||
import "../assets/wasm_exec.js";
|
|
||||||
import mod from "./dist/app.wasm";
|
import mod from "./dist/app.wasm";
|
||||||
|
|
||||||
const go = new Go();
|
imports.init(mod);
|
||||||
|
|
||||||
const readyPromise = new Promise((resolve) => {
|
export default { fetch: imports.fetch }
|
||||||
globalThis.ready = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const load = WebAssembly.instantiate(mod, go.importObject).then((instance) => {
|
|
||||||
go.run(instance);
|
|
||||||
return instance;
|
|
||||||
});
|
|
||||||
|
|
||||||
export default {
|
|
||||||
async fetch(req, env, ctx) {
|
|
||||||
await load;
|
|
||||||
await readyPromise;
|
|
||||||
return handleRequest(req, { env, ctx });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,6 @@
|
|||||||
import "../assets/polyfill_performance.js";
|
import * as imports from "../assets/shim.mjs";
|
||||||
import "../assets/wasm_exec.js";
|
|
||||||
import mod from "./dist/app.wasm";
|
import mod from "./dist/app.wasm";
|
||||||
|
|
||||||
const go = new Go();
|
imports.init(mod);
|
||||||
|
|
||||||
const readyPromise = new Promise((resolve) => {
|
export default { fetch: imports.fetch }
|
||||||
globalThis.ready = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const load = WebAssembly.instantiate(mod, go.importObject).then((instance) => {
|
|
||||||
go.run(instance);
|
|
||||||
return instance;
|
|
||||||
});
|
|
||||||
|
|
||||||
export default {
|
|
||||||
async fetch(req, env, ctx) {
|
|
||||||
await load;
|
|
||||||
await readyPromise;
|
|
||||||
return handleRequest(req, { env, ctx });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,6 @@
|
|||||||
import "../assets/polyfill_performance.js";
|
import * as imports from "../assets/shim.mjs";
|
||||||
import "../assets/wasm_exec.js";
|
|
||||||
import mod from "./dist/app.wasm";
|
import mod from "./dist/app.wasm";
|
||||||
|
|
||||||
const go = new Go();
|
imports.init(mod);
|
||||||
|
|
||||||
const readyPromise = new Promise((resolve) => {
|
export default { fetch: imports.fetch }
|
||||||
globalThis.ready = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const load = WebAssembly.instantiate(mod, go.importObject).then((instance) => {
|
|
||||||
go.run(instance);
|
|
||||||
return instance;
|
|
||||||
});
|
|
||||||
|
|
||||||
export default {
|
|
||||||
async fetch(req, env, ctx) {
|
|
||||||
await load;
|
|
||||||
await readyPromise;
|
|
||||||
return handleRequest(req, { env, ctx });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,6 @@
|
|||||||
import "../assets/polyfill_performance.js";
|
import * as imports from "../assets/shim.mjs";
|
||||||
import "../assets/wasm_exec.js";
|
|
||||||
import mod from "./dist/app.wasm";
|
import mod from "./dist/app.wasm";
|
||||||
|
|
||||||
const go = new Go();
|
imports.init(mod);
|
||||||
|
|
||||||
const readyPromise = new Promise((resolve) => {
|
export default { fetch: imports.fetch }
|
||||||
globalThis.ready = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const load = WebAssembly.instantiate(mod, go.importObject).then((instance) => {
|
|
||||||
go.run(instance);
|
|
||||||
return instance;
|
|
||||||
});
|
|
||||||
|
|
||||||
export default {
|
|
||||||
async fetch(req, env, ctx) {
|
|
||||||
await load;
|
|
||||||
await readyPromise;
|
|
||||||
return handleRequest(req, { env, ctx });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,6 @@
|
|||||||
import "../assets/polyfill_performance.js";
|
import * as imports from "../assets/shim.mjs";
|
||||||
import "../assets/wasm_exec.js";
|
|
||||||
import mod from "./dist/app.wasm";
|
import mod from "./dist/app.wasm";
|
||||||
|
|
||||||
const go = new Go();
|
imports.init(mod);
|
||||||
|
|
||||||
const readyPromise = new Promise((resolve) => {
|
export default { fetch: imports.fetch }
|
||||||
globalThis.ready = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const load = WebAssembly.instantiate(mod, go.importObject).then((instance) => {
|
|
||||||
go.run(instance);
|
|
||||||
return instance;
|
|
||||||
});
|
|
||||||
|
|
||||||
export default {
|
|
||||||
async fetch(req, env, ctx) {
|
|
||||||
await load;
|
|
||||||
await readyPromise;
|
|
||||||
return handleRequest(req, { env, ctx });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,6 @@
|
|||||||
import "../assets/polyfill_performance.js";
|
import * as imports from "../assets/shim.mjs";
|
||||||
import "../assets/wasm_exec.js";
|
|
||||||
import mod from "./dist/app.wasm";
|
import mod from "./dist/app.wasm";
|
||||||
|
|
||||||
const go = new Go();
|
imports.init(mod);
|
||||||
|
|
||||||
const readyPromise = new Promise((resolve) => {
|
export default { fetch: imports.fetch }
|
||||||
globalThis.ready = resolve;
|
|
||||||
});
|
|
||||||
|
|
||||||
const load = WebAssembly.instantiate(mod, go.importObject).then((instance) => {
|
|
||||||
go.run(instance);
|
|
||||||
return instance;
|
|
||||||
});
|
|
||||||
|
|
||||||
export default {
|
|
||||||
async fetch(req, env, ctx) {
|
|
||||||
await load;
|
|
||||||
await readyPromise;
|
|
||||||
return handleRequest(req, { env, ctx });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user