@zeltjs/adapter-cloudflare-workers 0.8.1 → 0.8.2-canary.0
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.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EnvAdaptor,
|
|
1
|
+
import { ConfiguredFeature, CreateRuntimeOptions, EnvAdaptor, HttpCapabilities, RuntimeApp } from "@zeltjs/core";
|
|
2
2
|
|
|
3
3
|
//#region src/cloudflare-workers-env.adaptor.d.ts
|
|
4
4
|
declare class CloudflareWorkersEnvAdaptor extends EnvAdaptor {
|
|
@@ -9,7 +9,14 @@ declare class CloudflareWorkersEnvAdaptor extends EnvAdaptor {
|
|
|
9
9
|
type CloudflareWorkersOptions = {
|
|
10
10
|
readonly warmup?: boolean;
|
|
11
11
|
};
|
|
12
|
-
type
|
|
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'];
|
|
13
20
|
readonly fetch: (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
14
21
|
readonly shutdown: () => Promise<void>;
|
|
15
22
|
};
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/cloudflare-workers-env.adaptor.ts","../src/on-cloudflare-workers.ts"],"mappings":";;;cAIa,2BAAA,SAAoC,UAAA;EACtC,GAAA,CAAI,GAAA;AAAA;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","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/dist/index.js
CHANGED
|
@@ -17,18 +17,19 @@ CloudflareWorkersEnvAdaptor = _ts_decorate([Config], CloudflareWorkersEnvAdaptor
|
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/on-cloudflare-workers.ts
|
|
19
19
|
const onCloudflareWorkers = async (app, options = {}) => {
|
|
20
|
-
app.
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const readyApp = await app.createRuntime({
|
|
21
|
+
fallbackConfigs: [CloudflareWorkersEnvAdaptor],
|
|
22
|
+
warmup: options.warmup ?? false
|
|
23
|
+
});
|
|
23
24
|
const fetch = async (request, _env, ctx) => {
|
|
24
|
-
const response =
|
|
25
|
+
const response = readyApp.http.fetch(request);
|
|
25
26
|
ctx.waitUntil(response.then(() => {}));
|
|
26
27
|
return response;
|
|
27
28
|
};
|
|
28
29
|
return {
|
|
29
|
-
|
|
30
|
+
get: readyApp.get,
|
|
30
31
|
fetch,
|
|
31
|
-
shutdown:
|
|
32
|
+
shutdown: readyApp.shutdown
|
|
32
33
|
};
|
|
33
34
|
};
|
|
34
35
|
//#endregion
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["env","Config","EnvAdaptor","CloudflareWorkersEnvAdaptor","get","key","value","Reflect","undefined","CloudflareWorkersEnvAdaptor","onCloudflareWorkers","app","options","
|
|
1
|
+
{"version":3,"file":"index.js","names":["env","Config","EnvAdaptor","CloudflareWorkersEnvAdaptor","get","key","value","Reflect","undefined","CloudflareWorkersEnvAdaptor","onCloudflareWorkers","app","options","readyApp","createRuntime","fallbackConfigs","warmup","fetch","request","_env","ctx","response","http","waitUntil","then","get","shutdown"],"sources":["../src/cloudflare-workers-env.adaptor.ts","../src/on-cloudflare-workers.ts"],"sourcesContent":["import { env } from 'cloudflare:workers';\nimport { Config, EnvAdaptor } from '@zeltjs/core';\n\n@Config\nexport class CloudflareWorkersEnvAdaptor extends EnvAdaptor {\n override get(key: string): string | undefined {\n const value: unknown = Reflect.get(env, key);\n return typeof value === 'string' ? value : undefined;\n }\n}\n","import type {\n ConfiguredFeature,\n CreateRuntimeOptions,\n HttpCapabilities,\n RuntimeApp,\n} from '@zeltjs/core';\n\nimport { CloudflareWorkersEnvAdaptor } from './cloudflare-workers-env.adaptor';\n\nexport type CloudflareWorkersOptions = {\n readonly warmup?: boolean;\n};\n\ntype HttpRuntimeApp = RuntimeApp<readonly ConfiguredFeature[]> & {\n readonly http: HttpCapabilities;\n};\n\ntype HttpApp = {\n readonly createRuntime: (options?: CreateRuntimeOptions) => Promise<HttpRuntimeApp>;\n};\n\nexport type CloudflareWorkersApp = {\n readonly get: HttpRuntimeApp['get'];\n readonly fetch: (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;\n readonly shutdown: () => Promise<void>;\n};\n\nexport const onCloudflareWorkers = async (\n app: HttpApp,\n options: CloudflareWorkersOptions = {},\n): Promise<CloudflareWorkersApp> => {\n const readyApp = await app.createRuntime({\n fallbackConfigs: [CloudflareWorkersEnvAdaptor],\n warmup: options.warmup ?? false,\n });\n\n const fetch = async (\n request: Request,\n _env: unknown,\n ctx: ExecutionContext,\n ): Promise<Response> => {\n const response = readyApp.http.fetch(request);\n ctx.waitUntil(response.then(() => {}));\n return response;\n };\n\n return { get: readyApp.get, fetch, shutdown: readyApp.shutdown };\n};\n"],"mappings":";;;;;;;;;AAIA,IAAaG,8BAAb,cAAiDD,WAAAA;CACtCE,IAAIC,KAAiC;EAC5C,MAAMC,QAAiBC,QAAQH,IAAIJ,KAAKK,IAAAA;AACxC,SAAO,OAAOC,UAAU,WAAWA,QAAQE,KAAAA;;;;;;ACoB/C,MAAaE,sBAAsB,OACjCC,KACAC,UAAoC,EAAE,KAAA;CAEtC,MAAMC,WAAW,MAAMF,IAAIG,cAAc;EACvCC,iBAAiB,CAACN,4BAA4B;EAC9CO,QAAQJ,QAAQI,UAAU;EAC5B,CAAA;CAEA,MAAMC,QAAQ,OACZC,SACAC,MACAC,QAAAA;EAEA,MAAMC,WAAWR,SAASS,KAAKL,MAAMC,QAAAA;AACrCE,MAAIG,UAAUF,SAASG,WAAK,GAAO,CAAA;AACnC,SAAOH;;AAGT,QAAO;EAAEI,KAAKZ,SAASY;EAAKR;EAAOS,UAAUb,SAASa;EAAS"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeltjs/adapter-cloudflare-workers",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2-canary.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@zeltjs/core": "0.8.
|
|
24
|
+
"@zeltjs/core": "0.8.2-canary.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@cloudflare/workers-types": "4.20250523.0"
|