@zeltjs/adapter-cloudflare-workers 0.8.2-canary.0 → 0.8.2-canary.2
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.
- package/dist/index.cjs +43 -0
- package/dist/index.d.cts +26 -0
- package/dist/index.d.cts.map +1 -0
- package/package.json +11 -4
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let cloudflare_workers = require("cloudflare:workers");
|
|
3
|
+
let _zeltjs_core = require("@zeltjs/core");
|
|
4
|
+
//#region src/cloudflare-workers-env.adaptor.ts
|
|
5
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
6
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
9
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10
|
+
}
|
|
11
|
+
var CloudflareWorkersEnvAdaptor = class extends _zeltjs_core.EnvAdaptor {
|
|
12
|
+
get(key) {
|
|
13
|
+
const value = Reflect.get(cloudflare_workers.env, key);
|
|
14
|
+
return typeof value === "string" ? value : void 0;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
CloudflareWorkersEnvAdaptor = _ts_decorate([_zeltjs_core.Config], CloudflareWorkersEnvAdaptor);
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/on-cloudflare-workers.ts
|
|
20
|
+
const onCloudflareWorkers = async (app, options = {}) => {
|
|
21
|
+
const readyApp = await app.createRuntime({
|
|
22
|
+
fallbackConfigs: [CloudflareWorkersEnvAdaptor],
|
|
23
|
+
warmup: options.warmup ?? false
|
|
24
|
+
});
|
|
25
|
+
const fetch = async (request, _env, ctx) => {
|
|
26
|
+
const response = readyApp.http.fetch(request);
|
|
27
|
+
ctx.waitUntil(response.then(() => {}));
|
|
28
|
+
return response;
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
get: readyApp.get,
|
|
32
|
+
fetch,
|
|
33
|
+
shutdown: readyApp.shutdown
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
37
|
+
Object.defineProperty(exports, "CloudflareWorkersEnvAdaptor", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function() {
|
|
40
|
+
return CloudflareWorkersEnvAdaptor;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
exports.onCloudflareWorkers = onCloudflareWorkers;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ConfiguredFeature, CreateRuntimeOptions, EnvAdaptor, HttpCapabilities, RuntimeApp } from "@zeltjs/core";
|
|
2
|
+
|
|
3
|
+
//#region src/cloudflare-workers-env.adaptor.d.ts
|
|
4
|
+
declare class CloudflareWorkersEnvAdaptor extends EnvAdaptor {
|
|
5
|
+
get(key: string): string | undefined;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/on-cloudflare-workers.d.ts
|
|
9
|
+
type CloudflareWorkersOptions = {
|
|
10
|
+
readonly warmup?: boolean;
|
|
11
|
+
};
|
|
12
|
+
type HttpRuntimeApp = RuntimeApp<readonly ConfiguredFeature[]> & {
|
|
13
|
+
readonly http: HttpCapabilities;
|
|
14
|
+
};
|
|
15
|
+
type HttpApp = {
|
|
16
|
+
readonly createRuntime: (options?: CreateRuntimeOptions) => Promise<HttpRuntimeApp>;
|
|
17
|
+
};
|
|
18
|
+
type CloudflareWorkersApp = {
|
|
19
|
+
readonly get: HttpRuntimeApp['get'];
|
|
20
|
+
readonly fetch: (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
21
|
+
readonly shutdown: () => Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
declare const onCloudflareWorkers: (app: HttpApp, options?: CloudflareWorkersOptions) => Promise<CloudflareWorkersApp>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { type CloudflareWorkersApp, CloudflareWorkersEnvAdaptor, type CloudflareWorkersOptions, onCloudflareWorkers };
|
|
26
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/cloudflare-workers-env.adaptor.ts","../src/on-cloudflare-workers.ts"],"mappings":";;;cAIa,2BAAA,SAAoC,UAAA;EACtC,GAAA,CAAI,GAAA;AAAA;;;KCIH,wBAAA;EAAA,SACD,MAAA;AAAA;AAAA,KAGN,cAAA,GAAiB,UAAA,UAAoB,iBAAA;EAAA,SAC/B,IAAA,EAAM,gBAAA;AAAA;AAAA,KAGZ,OAAA;EAAA,SACM,aAAA,GAAgB,OAAA,GAAU,oBAAA,KAAyB,OAAA,CAAQ,cAAA;AAAA;AAAA,KAG1D,oBAAA;EAAA,SACD,GAAA,EAAK,cAAA;EAAA,SACL,KAAA,GAAQ,OAAA,EAAS,OAAA,EAAS,GAAA,WAAc,GAAA,EAAK,gBAAA,KAAqB,OAAA,CAAQ,QAAA;EAAA,SAC1E,QAAA,QAAgB,OAAA;AAAA;AAAA,cAGd,mBAAA,GACX,GAAA,EAAK,OAAA,EACL,OAAA,GAAS,wBAAA,KACR,OAAA,CAAQ,oBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeltjs/adapter-cloudflare-workers",
|
|
3
|
-
"version": "0.8.2-canary.
|
|
3
|
+
"version": "0.8.2-canary.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -13,15 +13,21 @@
|
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
|
-
"
|
|
17
|
-
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"require": {
|
|
21
|
+
"types": "./dist/index.d.cts",
|
|
22
|
+
"default": "./dist/index.cjs"
|
|
23
|
+
}
|
|
18
24
|
}
|
|
19
25
|
},
|
|
20
26
|
"files": [
|
|
21
27
|
"dist"
|
|
22
28
|
],
|
|
23
29
|
"dependencies": {
|
|
24
|
-
"@zeltjs/core": "0.8.2-canary.
|
|
30
|
+
"@zeltjs/core": "0.8.2-canary.2"
|
|
25
31
|
},
|
|
26
32
|
"devDependencies": {
|
|
27
33
|
"@cloudflare/workers-types": "4.20250523.0"
|
|
@@ -29,6 +35,7 @@
|
|
|
29
35
|
"volta": {
|
|
30
36
|
"extends": "../../package.json"
|
|
31
37
|
},
|
|
38
|
+
"main": "./dist/index.cjs",
|
|
32
39
|
"scripts": {
|
|
33
40
|
"build": "tsdown",
|
|
34
41
|
"test": "vitest run",
|