@zeltjs/adapter-cloudflare-workers 0.8.1 → 0.8.2-canary.1
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/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 +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/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.1",
|
|
3
|
+
"version": "0.8.2-canary.1",
|
|
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.1"
|
|
30
|
+
"@zeltjs/core": "0.8.2-canary.1"
|
|
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",
|