workers-start 0.2.1 → 0.4.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/CHANGELOG.md +13 -0
- package/README.md +18 -14
- package/dist/accept.d.ts.map +1 -1
- package/dist/accept.js +6 -2
- package/dist/accept.js.map +1 -1
- package/dist/check-bundle-cli.d.ts +1 -1
- package/dist/check-bundle-cli.js +23 -6
- package/dist/check-bundle-cli.js.map +1 -1
- package/dist/check-bundle.d.ts +7 -4
- package/dist/check-bundle.d.ts.map +1 -1
- package/dist/check-bundle.js +32 -11
- package/dist/check-bundle.js.map +1 -1
- package/dist/entry.d.ts +8 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +33 -12
- package/dist/entry.js.map +1 -1
- package/dist/head.d.ts +57 -6
- package/dist/head.d.ts.map +1 -1
- package/dist/head.js +80 -10
- package/dist/head.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/scripts.d.ts.map +1 -1
- package/dist/scripts.js +6 -2
- package/dist/scripts.js.map +1 -1
- package/dist/workers.d.ts.map +1 -1
- package/dist/workers.js +2 -1
- package/dist/workers.js.map +1 -1
- package/package.json +1 -3
- package/src/accept.ts +10 -2
- package/src/check-bundle-cli.ts +38 -9
- package/src/check-bundle.ts +59 -16
- package/src/entry.ts +79 -27
- package/src/head.ts +162 -27
- package/src/index.ts +24 -4
- package/src/scripts.ts +6 -2
- package/src/workers.ts +18 -4
- package/biome.preset.json +0 -47
package/src/workers.ts
CHANGED
|
@@ -21,7 +21,10 @@ let modulePromise: Promise<WorkersModule | null> | null = null;
|
|
|
21
21
|
let override: WorkersModule | null | undefined;
|
|
22
22
|
|
|
23
23
|
function processEnv(): Record<string, string | undefined> {
|
|
24
|
-
return (
|
|
24
|
+
return (
|
|
25
|
+
(globalThis as { process?: { env?: Record<string, string | undefined> } })
|
|
26
|
+
.process?.env ?? {}
|
|
27
|
+
);
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
/** The `cloudflare:workers` module, or null outside workerd. */
|
|
@@ -47,7 +50,10 @@ export function setWorkersModule(mod: WorkersModule | null | undefined): void {
|
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
/** A binding by name, or null when it is missing or fails the guard. */
|
|
50
|
-
export async function getBinding<T>(
|
|
53
|
+
export async function getBinding<T>(
|
|
54
|
+
name: string,
|
|
55
|
+
guard?: (value: unknown) => value is T,
|
|
56
|
+
): Promise<T | null> {
|
|
51
57
|
const mod = await loadWorkers();
|
|
52
58
|
const value = mod?.env[name];
|
|
53
59
|
if (value === undefined || value === null) {
|
|
@@ -91,12 +97,20 @@ export async function afterResponse(work: Promise<unknown>): Promise<void> {
|
|
|
91
97
|
/** True for a KV namespace (it has `getWithMetadata`, which R2 buckets do not). Use as a `getBinding` guard. */
|
|
92
98
|
export function isKvNamespace(value: unknown): value is {
|
|
93
99
|
get(key: string): Promise<string | null>;
|
|
94
|
-
put(
|
|
100
|
+
put(
|
|
101
|
+
key: string,
|
|
102
|
+
value: string,
|
|
103
|
+
options?: { expirationTtl?: number },
|
|
104
|
+
): Promise<void>;
|
|
95
105
|
} {
|
|
96
106
|
if (typeof value !== "object" || value === null) {
|
|
97
107
|
return false;
|
|
98
108
|
}
|
|
99
|
-
const candidate = value as {
|
|
109
|
+
const candidate = value as {
|
|
110
|
+
get?: unknown;
|
|
111
|
+
put?: unknown;
|
|
112
|
+
getWithMetadata?: unknown;
|
|
113
|
+
};
|
|
100
114
|
return (
|
|
101
115
|
typeof candidate.get === "function" &&
|
|
102
116
|
typeof candidate.put === "function" &&
|
package/biome.preset.json
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/2.6.8/schema.json",
|
|
3
|
-
"formatter": {
|
|
4
|
-
"indentStyle": "space",
|
|
5
|
-
"indentWidth": 2,
|
|
6
|
-
"lineEnding": "lf",
|
|
7
|
-
"lineWidth": 80
|
|
8
|
-
},
|
|
9
|
-
"javascript": {
|
|
10
|
-
"formatter": {
|
|
11
|
-
"arrowParentheses": "always",
|
|
12
|
-
"jsxQuoteStyle": "double",
|
|
13
|
-
"quoteProperties": "asNeeded",
|
|
14
|
-
"semicolons": "always",
|
|
15
|
-
"trailingCommas": "es5"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"json": {
|
|
19
|
-
"formatter": {
|
|
20
|
-
"trailingCommas": "none"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"css": {
|
|
24
|
-
"parser": {
|
|
25
|
-
"tailwindDirectives": true
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"assist": {
|
|
29
|
-
"actions": {
|
|
30
|
-
"source": {
|
|
31
|
-
"organizeImports": "on",
|
|
32
|
-
"useSortedAttributes": "on"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"linter": {
|
|
37
|
-
"rules": {
|
|
38
|
-
"preset": "recommended",
|
|
39
|
-
"security": {
|
|
40
|
-
"noDangerouslySetInnerHtml": "off"
|
|
41
|
-
},
|
|
42
|
-
"performance": {
|
|
43
|
-
"useTopLevelRegex": "error"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|