@vercel/functions 1.0.1 → 1.1.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.
@@ -0,0 +1 @@
1
+ export * from './wait-until';
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./wait-until"), module.exports);
19
+ // Annotate the CommonJS export names for ESM import in node:
20
+ 0 && (module.exports = {
21
+ ...require("./wait-until")
22
+ });
@@ -1,3 +1,4 @@
1
+ export declare const SYMBOL_FOR_REQ_CONTEXT: unique symbol;
1
2
  /**
2
3
  * Extends the lifetime of the request handler for the lifetime of the given {@link Promise}
3
4
  * @see https://developer.mozilla.org/en-US/docs/Web/API/ExtendableEvent/waitUntil
@@ -14,4 +15,4 @@
14
15
  * }
15
16
  * ```
16
17
  */
17
- export const waitUntil: (promise: Promise<unknown>) => void;
18
+ export declare const waitUntil: (promise: Promise<unknown>) => void | undefined;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var wait_until_exports = {};
20
+ __export(wait_until_exports, {
21
+ SYMBOL_FOR_REQ_CONTEXT: () => SYMBOL_FOR_REQ_CONTEXT,
22
+ waitUntil: () => waitUntil
23
+ });
24
+ module.exports = __toCommonJS(wait_until_exports);
25
+ const SYMBOL_FOR_REQ_CONTEXT = Symbol.for("@vercel/request-context");
26
+ const waitUntil = (promise) => {
27
+ if (promise === null || typeof promise !== "object" || typeof promise.then !== "function") {
28
+ throw new TypeError(
29
+ `waitUntil can only be called with a Promise, got ${typeof promise}`
30
+ );
31
+ }
32
+ return getContext().waitUntil?.(promise);
33
+ };
34
+ function getContext() {
35
+ const fromSymbol = globalThis;
36
+ return fromSymbol[SYMBOL_FOR_REQ_CONTEXT]?.get?.() ?? {};
37
+ }
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ SYMBOL_FOR_REQ_CONTEXT,
41
+ waitUntil
42
+ });
package/package.json CHANGED
@@ -2,9 +2,14 @@
2
2
  "name": "@vercel/functions",
3
3
  "description": "Runtime functions to be used with your Vercel Functions",
4
4
  "homepage": "https://vercel.com",
5
- "version": "1.0.1",
6
- "types": "index.d.ts",
7
- "main": "index.js",
5
+ "exports": {
6
+ ".": "./dist/index.js"
7
+ },
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "types": "./dist/index.d.ts",
12
+ "version": "1.1.0",
8
13
  "repository": {
9
14
  "directory": "packages/functions",
10
15
  "type": "git",
@@ -14,20 +19,19 @@
14
19
  "url": "https://github.com/vercel/vercel/issues"
15
20
  },
16
21
  "devDependencies": {
22
+ "typescript": "4.9.5",
23
+ "tinyspawn": "1.3.1",
17
24
  "vitest": "1.3.1"
18
25
  },
19
26
  "engines": {
20
27
  "node": ">= 16"
21
28
  },
22
- "files": [
23
- "index.d.ts",
24
- "index.js"
25
- ],
26
29
  "license": "Apache-2.0",
27
30
  "publishConfig": {
28
31
  "access": "public"
29
32
  },
30
33
  "scripts": {
31
- "test": "vitest"
34
+ "test": "vitest",
35
+ "build": "node ../../utils/build.mjs"
32
36
  }
33
37
  }
package/index.js DELETED
@@ -1,16 +0,0 @@
1
- /* global globalThis */
2
-
3
- export const waitUntil = promise => {
4
- if (
5
- promise === null ||
6
- typeof promise !== 'object' ||
7
- typeof promise.then !== 'function'
8
- ) {
9
- throw new TypeError(
10
- `waitUntil can only be called with a Promise, got ${typeof promise}`
11
- );
12
- }
13
-
14
- const ctx = globalThis[Symbol.for('@vercel/request-context')]?.get?.() ?? {};
15
- ctx.waitUntil?.(promise);
16
- };