netlify-cli 17.3.2 → 17.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.
Files changed (210) hide show
  1. package/README.md +2 -138
  2. package/npm-shrinkwrap.json +76 -76
  3. package/package.json +16 -15
  4. package/src/commands/addons/addons-auth.mjs +27 -30
  5. package/src/commands/addons/addons-config.mjs +145 -154
  6. package/src/commands/addons/addons-create.mjs +94 -108
  7. package/src/commands/addons/addons-delete.mjs +36 -41
  8. package/src/commands/addons/addons-list.mjs +38 -42
  9. package/src/commands/addons/addons.mjs +26 -28
  10. package/src/commands/addons/index.mjs +1 -1
  11. package/src/commands/api/api.mjs +45 -53
  12. package/src/commands/api/index.mjs +1 -1
  13. package/src/commands/base-command.mjs +597 -684
  14. package/src/commands/blobs/blobs-delete.mjs +35 -0
  15. package/src/commands/blobs/blobs-get.mjs +44 -0
  16. package/src/commands/blobs/blobs-list.mjs +48 -0
  17. package/src/commands/blobs/blobs-set.mjs +54 -0
  18. package/src/commands/blobs/blobs.mjs +32 -0
  19. package/src/commands/blobs/index.mjs +1 -0
  20. package/src/commands/build/build.mjs +55 -67
  21. package/src/commands/build/index.mjs +1 -1
  22. package/src/commands/completion/completion.mjs +41 -46
  23. package/src/commands/completion/index.mjs +1 -1
  24. package/src/commands/deploy/deploy.mjs +675 -710
  25. package/src/commands/deploy/index.mjs +1 -1
  26. package/src/commands/dev/dev-exec.mjs +20 -32
  27. package/src/commands/dev/dev.mjs +217 -302
  28. package/src/commands/dev/index.mjs +1 -1
  29. package/src/commands/dev/types.d.ts +30 -0
  30. package/src/commands/env/env-clone.mjs +157 -184
  31. package/src/commands/env/env-get.mjs +49 -68
  32. package/src/commands/env/env-import.mjs +100 -119
  33. package/src/commands/env/env-list.mjs +104 -129
  34. package/src/commands/env/env-set.mjs +160 -185
  35. package/src/commands/env/env-unset.mjs +104 -122
  36. package/src/commands/env/env.mjs +28 -30
  37. package/src/commands/env/index.mjs +1 -1
  38. package/src/commands/functions/functions-build.mjs +29 -41
  39. package/src/commands/functions/functions-create.mjs +533 -601
  40. package/src/commands/functions/functions-invoke.mjs +193 -216
  41. package/src/commands/functions/functions-list.mjs +45 -55
  42. package/src/commands/functions/functions-serve.mjs +51 -61
  43. package/src/commands/functions/functions.mjs +26 -32
  44. package/src/commands/functions/index.mjs +1 -1
  45. package/src/commands/index.mjs +2 -2
  46. package/src/commands/init/index.mjs +1 -1
  47. package/src/commands/init/init.mjs +138 -167
  48. package/src/commands/integration/deploy.mjs +337 -399
  49. package/src/commands/integration/index.mjs +12 -13
  50. package/src/commands/link/index.mjs +1 -1
  51. package/src/commands/link/link.mjs +298 -317
  52. package/src/commands/lm/index.mjs +1 -1
  53. package/src/commands/lm/lm-info.mjs +23 -31
  54. package/src/commands/lm/lm-install.mjs +13 -17
  55. package/src/commands/lm/lm-setup.mjs +80 -84
  56. package/src/commands/lm/lm-uninstall.mjs +7 -12
  57. package/src/commands/lm/lm.mjs +18 -22
  58. package/src/commands/login/index.mjs +1 -1
  59. package/src/commands/login/login.mjs +35 -41
  60. package/src/commands/logout/index.mjs +1 -1
  61. package/src/commands/logout/logout.mjs +25 -31
  62. package/src/commands/main.mjs +166 -201
  63. package/src/commands/open/index.mjs +1 -1
  64. package/src/commands/open/open-admin.mjs +15 -18
  65. package/src/commands/open/open-site.mjs +16 -19
  66. package/src/commands/open/open.mjs +24 -27
  67. package/src/commands/recipes/common.mjs +23 -34
  68. package/src/commands/recipes/index.mjs +1 -1
  69. package/src/commands/recipes/recipes-list.mjs +13 -20
  70. package/src/commands/recipes/recipes.mjs +59 -72
  71. package/src/commands/serve/index.mjs +1 -1
  72. package/src/commands/serve/serve.mjs +142 -189
  73. package/src/commands/sites/index.mjs +2 -2
  74. package/src/commands/sites/sites-create-template.mjs +214 -236
  75. package/src/commands/sites/sites-create.mjs +145 -157
  76. package/src/commands/sites/sites-delete.mjs +75 -81
  77. package/src/commands/sites/sites-list.mjs +63 -66
  78. package/src/commands/sites/sites.mjs +18 -20
  79. package/src/commands/status/index.mjs +1 -1
  80. package/src/commands/status/status-hooks.mjs +32 -34
  81. package/src/commands/status/status.mjs +99 -106
  82. package/src/commands/switch/index.mjs +1 -1
  83. package/src/commands/switch/switch.mjs +32 -37
  84. package/src/commands/types.d.ts +31 -0
  85. package/src/commands/unlink/index.mjs +1 -1
  86. package/src/commands/unlink/unlink.mjs +23 -29
  87. package/src/commands/watch/index.mjs +1 -1
  88. package/src/commands/watch/watch.mjs +91 -105
  89. package/src/functions-templates/javascript/hello/{{name}}.js +2 -3
  90. package/src/lib/account.mjs +4 -5
  91. package/src/lib/api.mjs +22 -20
  92. package/src/lib/blobs/blobs.mjs +36 -45
  93. package/src/lib/build.mjs +82 -85
  94. package/src/lib/completion/constants.mjs +2 -4
  95. package/src/lib/completion/generate-autocompletion.mjs +33 -36
  96. package/src/lib/completion/get-autocompletion.mjs +31 -35
  97. package/src/lib/completion/index.mjs +1 -1
  98. package/src/lib/completion/script.mjs +12 -19
  99. package/src/lib/edge-functions/bootstrap.mjs +3 -5
  100. package/src/lib/edge-functions/consts.mjs +9 -10
  101. package/src/lib/edge-functions/deploy.mjs +28 -34
  102. package/src/lib/edge-functions/editor-helper.mjs +29 -42
  103. package/src/lib/edge-functions/headers.mjs +24 -26
  104. package/src/lib/edge-functions/internal.mjs +38 -44
  105. package/src/lib/edge-functions/proxy.mjs +229 -228
  106. package/src/lib/edge-functions/registry.mjs +473 -574
  107. package/src/lib/exec-fetcher.mjs +115 -122
  108. package/src/lib/fs.mjs +28 -27
  109. package/src/lib/functions/background.mjs +16 -20
  110. package/src/lib/functions/config.mjs +12 -9
  111. package/src/lib/functions/form-submissions-handler.mjs +143 -149
  112. package/src/lib/functions/local-proxy.mjs +40 -44
  113. package/src/lib/functions/memoized-build.mjs +19 -21
  114. package/src/lib/functions/netlify-function.mjs +269 -249
  115. package/src/lib/functions/registry.mjs +509 -568
  116. package/src/lib/functions/runtimes/go/index.mjs +62 -71
  117. package/src/lib/functions/runtimes/index.mjs +8 -15
  118. package/src/lib/functions/runtimes/js/builders/netlify-lambda.mjs +55 -64
  119. package/src/lib/functions/runtimes/js/builders/zisi.mjs +135 -154
  120. package/src/lib/functions/runtimes/js/constants.mjs +1 -1
  121. package/src/lib/functions/runtimes/js/index.mjs +92 -109
  122. package/src/lib/functions/runtimes/js/worker.mjs +43 -45
  123. package/src/lib/functions/runtimes/rust/index.mjs +64 -73
  124. package/src/lib/functions/scheduled.mjs +70 -88
  125. package/src/lib/functions/server.mjs +269 -327
  126. package/src/lib/functions/synchronous.mjs +118 -147
  127. package/src/lib/functions/utils.mjs +38 -46
  128. package/src/lib/geo-location.mjs +69 -81
  129. package/src/lib/http-agent.mjs +87 -90
  130. package/src/lib/images/proxy.mjs +97 -99
  131. package/src/lib/log.mjs +6 -9
  132. package/src/lib/path.mjs +2 -1
  133. package/src/lib/render-error-template.mjs +19 -20
  134. package/src/lib/settings.mjs +17 -19
  135. package/src/lib/spinner.mjs +21 -23
  136. package/src/lib/string.mjs +4 -2
  137. package/src/recipes/vscode/index.mjs +69 -85
  138. package/src/recipes/vscode/settings.mjs +53 -58
  139. package/src/utils/addons/compare.mjs +31 -32
  140. package/src/utils/addons/diffs/index.mjs +16 -17
  141. package/src/utils/addons/diffs/options.mjs +99 -101
  142. package/src/utils/addons/prepare.mjs +100 -97
  143. package/src/utils/addons/prompts.mjs +73 -76
  144. package/src/utils/addons/render.mjs +33 -36
  145. package/src/utils/addons/validation.mjs +19 -15
  146. package/src/utils/banner.mjs +11 -16
  147. package/src/utils/build-info.mjs +65 -66
  148. package/src/utils/command-helpers.mjs +185 -199
  149. package/src/utils/create-deferred.mjs +9 -12
  150. package/src/utils/create-stream-promise.mjs +54 -47
  151. package/src/utils/deploy/constants.mjs +9 -11
  152. package/src/utils/deploy/deploy-site.mjs +162 -182
  153. package/src/utils/deploy/hash-config.mjs +21 -21
  154. package/src/utils/deploy/hash-files.mjs +34 -38
  155. package/src/utils/deploy/hash-fns.mjs +149 -154
  156. package/src/utils/deploy/hasher-segments.mjs +58 -52
  157. package/src/utils/deploy/upload-files.mjs +99 -113
  158. package/src/utils/deploy/util.mjs +85 -91
  159. package/src/utils/detect-server-settings.mjs +236 -268
  160. package/src/utils/dev.mjs +163 -178
  161. package/src/utils/dot-env.mjs +37 -42
  162. package/src/utils/env/index.mjs +148 -148
  163. package/src/utils/execa.mjs +9 -13
  164. package/src/utils/feature-flags.mjs +6 -5
  165. package/src/utils/framework-server.mjs +43 -52
  166. package/src/utils/functions/constants.mjs +1 -1
  167. package/src/utils/functions/functions.mjs +30 -40
  168. package/src/utils/functions/get-functions.mjs +28 -29
  169. package/src/utils/functions/index.mjs +3 -3
  170. package/src/utils/get-global-config.mjs +33 -36
  171. package/src/utils/get-package-json.mjs +14 -15
  172. package/src/utils/get-repo-data.mjs +54 -64
  173. package/src/utils/get-site.mjs +14 -14
  174. package/src/utils/gh-auth.mjs +79 -100
  175. package/src/utils/gitignore.mjs +37 -40
  176. package/src/utils/headers.mjs +33 -35
  177. package/src/utils/hooks/requires-site-info.mjs +26 -22
  178. package/src/utils/init/config-github.mjs +207 -219
  179. package/src/utils/init/config-manual.mjs +83 -100
  180. package/src/utils/init/config.mjs +25 -26
  181. package/src/utils/init/node-version.mjs +23 -30
  182. package/src/utils/init/plugins.mjs +12 -8
  183. package/src/utils/init/utils.mjs +152 -172
  184. package/src/utils/live-tunnel.mjs +118 -141
  185. package/src/utils/lm/install.mjs +220 -259
  186. package/src/utils/lm/requirements.mjs +54 -63
  187. package/src/utils/lm/steps.mjs +31 -31
  188. package/src/utils/lm/ui.mjs +13 -20
  189. package/src/utils/open-browser.mjs +31 -32
  190. package/src/utils/parse-raw-flags.mjs +39 -35
  191. package/src/utils/proxy-server.mjs +84 -71
  192. package/src/utils/proxy.mjs +696 -750
  193. package/src/utils/read-repo-url.mjs +48 -47
  194. package/src/utils/redirects.mjs +49 -49
  195. package/src/utils/request-id.mjs +2 -4
  196. package/src/utils/rules-proxy.mjs +96 -100
  197. package/src/utils/run-build.mjs +109 -132
  198. package/src/utils/shell.mjs +99 -106
  199. package/src/utils/sign-redirect.mjs +14 -14
  200. package/src/utils/sites/utils.mjs +48 -55
  201. package/src/utils/state-config.mjs +101 -101
  202. package/src/utils/static-server.mjs +28 -34
  203. package/src/utils/telemetry/index.mjs +2 -2
  204. package/src/utils/telemetry/report-error.mjs +45 -49
  205. package/src/utils/telemetry/request.mjs +36 -43
  206. package/src/utils/telemetry/telemetry.mjs +90 -105
  207. package/src/utils/telemetry/utils.mjs +5 -6
  208. package/src/utils/telemetry/validation.mjs +55 -53
  209. package/src/utils/types.d.ts +46 -0
  210. package/src/utils/validation.mjs +10 -13
@@ -1,16 +1,17 @@
1
- // @ts-check
2
- import { fileURLToPath } from 'url'
3
-
4
- import {
5
- NETLIFYDEVERR,
6
- NETLIFYDEVLOG,
7
- NETLIFYDEVWARN,
8
- chalk,
9
- log,
10
- warn,
11
- watchDebounced,
12
- } from '../../utils/command-helpers.mjs'
13
-
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _EdgeFunctionsRegistry_instances, _a, _EdgeFunctionsRegistry_bundler, _EdgeFunctionsRegistry_configPath, _EdgeFunctionsRegistry_debug, _EdgeFunctionsRegistry_directories, _EdgeFunctionsRegistry_internalDirectories, _EdgeFunctionsRegistry_getUpdatedConfig, _EdgeFunctionsRegistry_runIsolate, _EdgeFunctionsRegistry_buildError, _EdgeFunctionsRegistry_declarationsFromDeployConfig, _EdgeFunctionsRegistry_declarationsFromTOML, _EdgeFunctionsRegistry_env, _EdgeFunctionsRegistry_directoryWatchers, _EdgeFunctionsRegistry_dependencyPaths, _EdgeFunctionsRegistry_functionPaths, _EdgeFunctionsRegistry_manifest, _EdgeFunctionsRegistry_userFunctions, _EdgeFunctionsRegistry_internalFunctions, _EdgeFunctionsRegistry_initialScan, _EdgeFunctionsRegistry_routes, _EdgeFunctionsRegistry_servePath, _EdgeFunctionsRegistry_doInitialScan, _EdgeFunctionsRegistry_functions_get, _EdgeFunctionsRegistry_build, _EdgeFunctionsRegistry_buildRoutes, _EdgeFunctionsRegistry_checkForAddedOrDeletedFunctions, _EdgeFunctionsRegistry_getDeclarationsFromTOML, _EdgeFunctionsRegistry_getEnvironmentVariables, _EdgeFunctionsRegistry_handleFileChange, _EdgeFunctionsRegistry_logEvent, _EdgeFunctionsRegistry_processGraph, _EdgeFunctionsRegistry_runBuild, _EdgeFunctionsRegistry_scanForFunctions, _EdgeFunctionsRegistry_setupWatchers, _EdgeFunctionsRegistry_setupWatcherForDirectory, _EdgeFunctionsRegistry_getDisplayName;
13
+ import { fileURLToPath } from 'url';
14
+ import { NETLIFYDEVERR, NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, log, warn, watchDebounced, } from '../../utils/command-helpers.mjs';
14
15
  /** @typedef {import('@netlify/edge-bundler').Declaration} Declaration */
15
16
  /** @typedef {import('@netlify/edge-bundler').EdgeFunction} EdgeFunction */
16
17
  /**
@@ -21,619 +22,517 @@ import {
21
22
  /** @typedef {import('@netlify/edge-bundler').ModuleGraph} ModuleGraph */
22
23
  /** @typedef {Awaited<ReturnType<typeof import('@netlify/edge-bundler').serve>>} RunIsolate */
23
24
  /** @typedef {Omit<Manifest["routes"][0], "pattern"> & { pattern: RegExp }} Route */
24
-
25
- const featureFlags = { edge_functions_correct_order: true }
26
-
25
+ const featureFlags = { edge_functions_correct_order: true };
27
26
  export class EdgeFunctionsRegistry {
28
- /** @type {import('@netlify/edge-bundler')} */
29
- #bundler
30
-
31
- /** @type {string} */
32
- #configPath
33
-
34
- /** @type {boolean} */
35
- #debug
36
-
37
- /** @type {string[]} */
38
- #directories
39
-
40
- /** @type {string[]} */
41
- #internalDirectories
42
-
43
- /** @type {() => Promise<object>} */
44
- #getUpdatedConfig
45
-
46
- /** @type {RunIsolate} */
47
- #runIsolate
48
-
49
- /** @type {Error | null} */
50
- #buildError = null
51
-
52
- /** @type {Declaration[]} */
53
- #declarationsFromDeployConfig
54
-
55
- /** @type {Declaration[]} */
56
- #declarationsFromTOML
57
-
58
- /** @type {Record<string, string>} */
59
- #env
60
-
61
- /** @type {Map<string, import('chokidar').FSWatcher>} */
62
- #directoryWatchers = new Map()
63
-
64
- /** @type {Map<string, string[]>} */
65
- #dependencyPaths = new Map()
66
-
67
- /** @type {Map<string, string>} */
68
- #functionPaths = new Map()
69
-
70
- /** @type {Manifest | null} */
71
- #manifest = null
72
-
73
- /** @type {EdgeFunction[]} */
74
- #userFunctions = []
75
-
76
- /** @type {EdgeFunction[]} */
77
- #internalFunctions = []
78
-
79
- /** @type {Promise<void>} */
80
- #initialScan
81
-
82
- /** @type {Route[]} */
83
- #routes = []
84
-
85
- /** @type {string} */
86
- #servePath
87
-
88
- /**
89
- * @param {Object} opts
90
- * @param {import('@netlify/edge-bundler')} opts.bundler
91
- * @param {object} opts.config
92
- * @param {string} opts.configPath
93
- * @param {boolean} opts.debug
94
- * @param {string[]} opts.directories
95
- * @param {Record<string, { sources: string[], value: string}>} opts.env
96
- * @param {() => Promise<object>} opts.getUpdatedConfig
97
- * @param {string[]} opts.internalDirectories
98
- * @param {Declaration[]} opts.internalFunctions
99
- * @param {string} opts.projectDir
100
- * @param {RunIsolate} opts.runIsolate
101
- * @param {string} opts.servePath
102
- */
103
- constructor({
104
- bundler,
105
- config,
106
- configPath,
107
- debug,
108
- directories,
109
- env,
110
- getUpdatedConfig,
111
- internalDirectories,
112
- internalFunctions,
113
- projectDir,
114
- runIsolate,
115
- servePath,
116
- }) {
117
- this.#bundler = bundler
118
- this.#configPath = configPath
119
- this.#debug = debug
120
- this.#directories = directories
121
- this.#internalDirectories = internalDirectories
122
- this.#getUpdatedConfig = getUpdatedConfig
123
- this.#runIsolate = runIsolate
124
- this.#servePath = servePath
125
-
126
- this.#declarationsFromDeployConfig = internalFunctions
127
- this.#declarationsFromTOML = EdgeFunctionsRegistry.#getDeclarationsFromTOML(config)
128
- this.#env = EdgeFunctionsRegistry.#getEnvironmentVariables(env)
129
-
130
- this.#buildError = null
131
- this.#directoryWatchers = new Map()
132
- this.#dependencyPaths = new Map()
133
- this.#functionPaths = new Map()
134
- this.#userFunctions = []
135
- this.#internalFunctions = []
136
-
137
- this.#initialScan = this.#doInitialScan()
138
-
139
- this.#setupWatchers(projectDir)
140
- }
141
-
142
- /**
143
- * @returns {Promise<void>}
144
- */
145
- async #doInitialScan() {
146
- await this.#scanForFunctions()
147
-
27
+ /**
28
+ * @param {Object} opts
29
+ * @param {import('@netlify/edge-bundler')} opts.bundler
30
+ * @param {object} opts.config
31
+ * @param {string} opts.configPath
32
+ * @param {boolean} opts.debug
33
+ * @param {string[]} opts.directories
34
+ * @param {Record<string, { sources: string[], value: string}>} opts.env
35
+ * @param {() => Promise<object>} opts.getUpdatedConfig
36
+ * @param {string[]} opts.internalDirectories
37
+ * @param {Declaration[]} opts.internalFunctions
38
+ * @param {string} opts.projectDir
39
+ * @param {RunIsolate} opts.runIsolate
40
+ * @param {string} opts.servePath
41
+ */
42
+ constructor({
43
+ // @ts-expect-error TS(7031) FIXME: Binding element 'bundler' implicitly has an 'any' ... Remove this comment to see the full error message
44
+ bundler,
45
+ // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message
46
+ config,
47
+ // @ts-expect-error TS(7031) FIXME: Binding element 'configPath' implicitly has an 'an... Remove this comment to see the full error message
48
+ configPath,
49
+ // @ts-expect-error TS(7031) FIXME: Binding element 'debug' implicitly has an 'any' ty... Remove this comment to see the full error message
50
+ debug,
51
+ // @ts-expect-error TS(7031) FIXME: Binding element 'directories' implicitly has an 'a... Remove this comment to see the full error message
52
+ directories,
53
+ // @ts-expect-error TS(7031) FIXME: Binding element 'env' implicitly has an 'any' type... Remove this comment to see the full error message
54
+ env,
55
+ // @ts-expect-error TS(7031) FIXME: Binding element 'getUpdatedConfig' implicitly has ... Remove this comment to see the full error message
56
+ getUpdatedConfig,
57
+ // @ts-expect-error TS(7031) FIXME: Binding element 'internalDirectories' implicitly h... Remove this comment to see the full error message
58
+ internalDirectories,
59
+ // @ts-expect-error TS(7031) FIXME: Binding element 'internalFunctions' implicitly has... Remove this comment to see the full error message
60
+ internalFunctions,
61
+ // @ts-expect-error TS(7031) FIXME: Binding element 'projectDir' implicitly has an 'an... Remove this comment to see the full error message
62
+ projectDir,
63
+ // @ts-expect-error TS(7031) FIXME: Binding element 'runIsolate' implicitly has an 'an... Remove this comment to see the full error message
64
+ runIsolate,
65
+ // @ts-expect-error TS(7031) FIXME: Binding element 'servePath' implicitly has an 'any... Remove this comment to see the full error message
66
+ servePath, }) {
67
+ _EdgeFunctionsRegistry_instances.add(this);
68
+ /** @type {import('@netlify/edge-bundler')} */
69
+ _EdgeFunctionsRegistry_bundler.set(this, void 0);
70
+ /** @type {string} */
71
+ _EdgeFunctionsRegistry_configPath.set(this, void 0);
72
+ /** @type {boolean} */
73
+ _EdgeFunctionsRegistry_debug.set(this, void 0);
74
+ /** @type {string[]} */
75
+ _EdgeFunctionsRegistry_directories.set(this, void 0);
76
+ /** @type {string[]} */
77
+ _EdgeFunctionsRegistry_internalDirectories.set(this, void 0);
78
+ /** @type {() => Promise<object>} */
79
+ _EdgeFunctionsRegistry_getUpdatedConfig.set(this, void 0);
80
+ /** @type {RunIsolate} */
81
+ _EdgeFunctionsRegistry_runIsolate.set(this, void 0);
82
+ /** @type {Error | null} */
83
+ _EdgeFunctionsRegistry_buildError.set(this, null
84
+ /** @type {Declaration[]} */
85
+ );
86
+ /** @type {Declaration[]} */
87
+ _EdgeFunctionsRegistry_declarationsFromDeployConfig.set(this, void 0);
88
+ /** @type {Declaration[]} */
89
+ _EdgeFunctionsRegistry_declarationsFromTOML.set(this, void 0);
90
+ /** @type {Record<string, string>} */
91
+ _EdgeFunctionsRegistry_env.set(this, void 0);
92
+ /** @type {Map<string, import('chokidar').FSWatcher>} */
93
+ _EdgeFunctionsRegistry_directoryWatchers.set(this, new Map()
94
+ /** @type {Map<string, string[]>} */
95
+ );
96
+ /** @type {Map<string, string[]>} */
97
+ _EdgeFunctionsRegistry_dependencyPaths.set(this, new Map()
98
+ /** @type {Map<string, string>} */
99
+ );
100
+ /** @type {Map<string, string>} */
101
+ _EdgeFunctionsRegistry_functionPaths.set(this, new Map()
102
+ /** @type {Manifest | null} */
103
+ );
104
+ /** @type {Manifest | null} */
105
+ _EdgeFunctionsRegistry_manifest.set(this, null
106
+ /** @type {EdgeFunction[]} */
107
+ );
108
+ /** @type {EdgeFunction[]} */
109
+ _EdgeFunctionsRegistry_userFunctions.set(this, []
110
+ /** @type {EdgeFunction[]} */
111
+ );
112
+ /** @type {EdgeFunction[]} */
113
+ _EdgeFunctionsRegistry_internalFunctions.set(this, []
114
+ /** @type {Promise<void>} */
115
+ );
116
+ /** @type {Promise<void>} */
117
+ _EdgeFunctionsRegistry_initialScan.set(this, void 0);
118
+ /** @type {Route[]} */
119
+ _EdgeFunctionsRegistry_routes.set(this, []
120
+ /** @type {string} */
121
+ );
122
+ /** @type {string} */
123
+ _EdgeFunctionsRegistry_servePath.set(this, void 0);
124
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_bundler, bundler, "f");
125
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_configPath, configPath, "f");
126
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_debug, debug, "f");
127
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_directories, directories, "f");
128
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_internalDirectories, internalDirectories, "f");
129
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_getUpdatedConfig, getUpdatedConfig, "f");
130
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_runIsolate, runIsolate, "f");
131
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_servePath, servePath, "f");
132
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_declarationsFromDeployConfig, internalFunctions, "f");
133
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_declarationsFromTOML, __classPrivateFieldGet(EdgeFunctionsRegistry, _a, "m", _EdgeFunctionsRegistry_getDeclarationsFromTOML).call(EdgeFunctionsRegistry, config), "f");
134
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_env, __classPrivateFieldGet(EdgeFunctionsRegistry, _a, "m", _EdgeFunctionsRegistry_getEnvironmentVariables).call(EdgeFunctionsRegistry, env), "f");
135
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_buildError, null, "f");
136
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_directoryWatchers, new Map(), "f");
137
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_dependencyPaths, new Map(), "f");
138
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_functionPaths, new Map(), "f");
139
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_userFunctions, [], "f");
140
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_internalFunctions, [], "f");
141
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_initialScan, __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_doInitialScan).call(this), "f");
142
+ __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_setupWatchers).call(this, projectDir);
143
+ }
144
+ /**
145
+ * @return {Promise<void>}
146
+ */
147
+ async initialize() {
148
+ return await __classPrivateFieldGet(this, _EdgeFunctionsRegistry_initialScan, "f");
149
+ }
150
+ /**
151
+ * Returns the functions in the registry that should run for a given URL path
152
+ * and HTTP method, based on the routes registered for each function.
153
+ *
154
+ * @param {string} urlPath
155
+ * @param {string} method
156
+ */
157
+ // @ts-expect-error TS(7006) FIXME: Parameter 'urlPath' implicitly has an 'any' type.
158
+ matchURLPath(urlPath, method) {
159
+ /** @type string[] */
160
+ // @ts-expect-error TS(7034) FIXME: Variable 'functionNames' implicitly has type 'any[... Remove this comment to see the full error message
161
+ const functionNames = [];
162
+ /** @type number[] */
163
+ // @ts-expect-error TS(7034) FIXME: Variable 'routeIndexes' implicitly has type 'any[]... Remove this comment to see the full error message
164
+ const routeIndexes = [];
165
+ __classPrivateFieldGet(this, _EdgeFunctionsRegistry_routes, "f").forEach((route, index) => {
166
+ // @ts-expect-error TS(2339) FIXME: Property 'methods' does not exist on type 'never'.
167
+ if (route.methods && route.methods.length !== 0 && !route.methods.includes(method)) {
168
+ return;
169
+ }
170
+ // @ts-expect-error TS(2339) FIXME: Property 'pattern' does not exist on type 'never'.
171
+ if (!route.pattern.test(urlPath)) {
172
+ return;
173
+ }
174
+ // @ts-expect-error TS(2339) FIXME: Property 'function_config' does not exist on type ... Remove this comment to see the full error message
175
+ const isExcluded = __classPrivateFieldGet(this, _EdgeFunctionsRegistry_manifest, "f")?.function_config[route.function]?.excluded_patterns?.some((pattern) => new RegExp(pattern).test(urlPath));
176
+ if (isExcluded) {
177
+ return;
178
+ }
179
+ // @ts-expect-error TS(2339) FIXME: Property 'function' does not exist on type 'never'... Remove this comment to see the full error message
180
+ functionNames.push(route.function);
181
+ routeIndexes.push(index);
182
+ });
183
+ const invocationMetadata = {
184
+ // @ts-expect-error TS(2339) FIXME: Property 'function_config' does not exist on type ... Remove this comment to see the full error message
185
+ function_config: __classPrivateFieldGet(this, _EdgeFunctionsRegistry_manifest, "f")?.function_config,
186
+ // @ts-expect-error TS(7005) FIXME: Variable 'routeIndexes' implicitly has an 'any[]' ... Remove this comment to see the full error message
187
+ req_routes: routeIndexes,
188
+ // @ts-expect-error TS(2339) FIXME: Property 'routes' does not exist on type 'never'.
189
+ routes: __classPrivateFieldGet(this, _EdgeFunctionsRegistry_manifest, "f")?.routes.map((route) => ({
190
+ function: route.function,
191
+ path: route.path,
192
+ pattern: route.pattern,
193
+ })),
194
+ };
195
+ // @ts-expect-error TS(7005) FIXME: Variable 'functionNames' implicitly has an 'any[]'... Remove this comment to see the full error message
196
+ return { functionNames, invocationMetadata };
197
+ }
198
+ }
199
+ _a = EdgeFunctionsRegistry, _EdgeFunctionsRegistry_bundler = new WeakMap(), _EdgeFunctionsRegistry_configPath = new WeakMap(), _EdgeFunctionsRegistry_debug = new WeakMap(), _EdgeFunctionsRegistry_directories = new WeakMap(), _EdgeFunctionsRegistry_internalDirectories = new WeakMap(), _EdgeFunctionsRegistry_getUpdatedConfig = new WeakMap(), _EdgeFunctionsRegistry_runIsolate = new WeakMap(), _EdgeFunctionsRegistry_buildError = new WeakMap(), _EdgeFunctionsRegistry_declarationsFromDeployConfig = new WeakMap(), _EdgeFunctionsRegistry_declarationsFromTOML = new WeakMap(), _EdgeFunctionsRegistry_env = new WeakMap(), _EdgeFunctionsRegistry_directoryWatchers = new WeakMap(), _EdgeFunctionsRegistry_dependencyPaths = new WeakMap(), _EdgeFunctionsRegistry_functionPaths = new WeakMap(), _EdgeFunctionsRegistry_manifest = new WeakMap(), _EdgeFunctionsRegistry_userFunctions = new WeakMap(), _EdgeFunctionsRegistry_internalFunctions = new WeakMap(), _EdgeFunctionsRegistry_initialScan = new WeakMap(), _EdgeFunctionsRegistry_routes = new WeakMap(), _EdgeFunctionsRegistry_servePath = new WeakMap(), _EdgeFunctionsRegistry_instances = new WeakSet(), _EdgeFunctionsRegistry_doInitialScan =
200
+ /**
201
+ * @returns {Promise<void>}
202
+ */
203
+ async function _EdgeFunctionsRegistry_doInitialScan() {
204
+ await __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_scanForFunctions).call(this);
148
205
  try {
149
- const { warnings } = await this.#build()
150
-
151
- this.#functions.forEach((func) => {
152
- this.#logEvent('loaded', { functionName: func.name, warnings: warnings[func.name] })
153
- })
154
- } catch {
155
- // no-op
206
+ const { warnings } = await __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_build).call(this);
207
+ __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "a", _EdgeFunctionsRegistry_functions_get).forEach((func) => {
208
+ // @ts-expect-error TS(2345) FIXME: Argument of type '{ functionName: any; warnings: a... Remove this comment to see the full error message
209
+ __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_logEvent).call(this, 'loaded', { functionName: func.name, warnings: warnings[func.name] });
210
+ });
211
+ }
212
+ catch {
213
+ // no-op
156
214
  }
157
- }
158
-
159
- /**
160
- * @return {EdgeFunction[]}
161
- */
162
- get #functions() {
163
- return [...this.#internalFunctions, ...this.#userFunctions]
164
- }
165
-
166
- /**
167
- * @return {Promise<{warnings: Record<string, string[]>}>}
168
- */
169
- async #build() {
215
+ }, _EdgeFunctionsRegistry_functions_get = function _EdgeFunctionsRegistry_functions_get() {
216
+ return [...__classPrivateFieldGet(this, _EdgeFunctionsRegistry_internalFunctions, "f"), ...__classPrivateFieldGet(this, _EdgeFunctionsRegistry_userFunctions, "f")];
217
+ }, _EdgeFunctionsRegistry_build =
218
+ /**
219
+ * @return {Promise<{warnings: Record<string, string[]>}>}
220
+ */
221
+ async function _EdgeFunctionsRegistry_build() {
170
222
  /**
171
223
  * @type Record<string, string[]>
172
224
  */
173
- const warnings = {}
174
-
225
+ const warnings = {};
175
226
  try {
176
- const { functionsConfig, graph, npmSpecifiersWithExtraneousFiles, success } = await this.#runBuild()
177
-
178
- if (!success) {
179
- throw new Error('Build error')
180
- }
181
-
182
- this.#buildError = null
183
-
184
- // We use one index to loop over both internal and user function, because we know that this.#functions has internalFunctions first.
185
- // functionsConfig therefore contains first all internal functionConfigs and then user functionConfigs
186
- let index = 0
187
-
188
- /** @type {Record<string, FunctionConfig>} */
189
- const internalFunctionConfigs = this.#internalFunctions.reduce(
227
+ const { functionsConfig, graph, npmSpecifiersWithExtraneousFiles, success } = await __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_runBuild).call(this);
228
+ if (!success) {
229
+ throw new Error('Build error');
230
+ }
231
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_buildError, null, "f");
232
+ // We use one index to loop over both internal and user function, because we know that this.#functions has internalFunctions first.
233
+ // functionsConfig therefore contains first all internal functionConfigs and then user functionConfigs
234
+ let index = 0;
235
+ /** @type {Record<string, FunctionConfig>} */
236
+ const internalFunctionConfigs = __classPrivateFieldGet(this, _EdgeFunctionsRegistry_internalFunctions, "f").reduce(
237
+ // @ts-expect-error TS(2339) FIXME: Property 'name' does not exist on type 'never'.
190
238
  // eslint-disable-next-line no-plusplus
191
- (acc, func) => ({ ...acc, [func.name]: functionsConfig[index++] }),
192
- {},
193
- )
194
-
195
- /** @type {Record<string, FunctionConfig>} */
196
- const userFunctionConfigs = this.#userFunctions.reduce(
239
+ (acc, func) => ({ ...acc, [func.name]: functionsConfig[index++] }), {});
240
+ /** @type {Record<string, FunctionConfig>} */
241
+ const userFunctionConfigs = __classPrivateFieldGet(this, _EdgeFunctionsRegistry_userFunctions, "f").reduce(
242
+ // @ts-expect-error TS(2339) FIXME: Property 'name' does not exist on type 'never'.
197
243
  // eslint-disable-next-line no-plusplus
198
- (acc, func) => ({ ...acc, [func.name]: functionsConfig[index++] }),
199
- {},
200
- )
201
-
202
- const { manifest, routes, unroutedFunctions } = this.#buildRoutes(internalFunctionConfigs, userFunctionConfigs)
203
-
204
- this.#manifest = manifest
205
- this.#routes = routes
206
-
207
- unroutedFunctions.forEach((name) => {
208
- warnings[name] = warnings[name] || []
209
- warnings[name].push(
210
- `Edge function is not accessible because it does not have a path configured. Learn more at https://ntl.fyi/edge-create.`,
211
- )
212
- })
213
-
214
- for (const functionName in userFunctionConfigs) {
215
- if ('paths' in userFunctionConfigs[functionName]) {
216
- warnings[functionName] = warnings[functionName] || []
217
- warnings[functionName].push(`Unknown 'paths' configuration property. Did you mean 'path'?`)
244
+ (acc, func) => ({ ...acc, [func.name]: functionsConfig[index++] }), {});
245
+ const { manifest, routes, unroutedFunctions } = __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_buildRoutes).call(this, internalFunctionConfigs, userFunctionConfigs);
246
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_manifest, manifest, "f");
247
+ // @ts-expect-error TS(2322) FIXME: Type 'any[]' is not assignable to type 'never[]'.
248
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_routes, routes, "f");
249
+ // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type.
250
+ unroutedFunctions.forEach((name) => {
251
+ // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
252
+ warnings[name] = warnings[name] || [];
253
+ // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
254
+ warnings[name].push(`Edge function is not accessible because it does not have a path configured. Learn more at https://ntl.fyi/edge-create.`);
255
+ });
256
+ for (const functionName in userFunctionConfigs) {
257
+ // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
258
+ if ('paths' in userFunctionConfigs[functionName]) {
259
+ // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
260
+ warnings[functionName] = warnings[functionName] || [];
261
+ // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
262
+ warnings[functionName].push(`Unknown 'paths' configuration property. Did you mean 'path'?`);
263
+ }
264
+ }
265
+ __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_processGraph).call(this, graph);
266
+ if (npmSpecifiersWithExtraneousFiles.length !== 0) {
267
+ // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type.
268
+ const modules = npmSpecifiersWithExtraneousFiles.map((name) => chalk.yellow(name)).join(', ');
269
+ log(`${NETLIFYDEVWARN} The following npm modules, which are directly or indirectly imported by an edge function, may not be supported: ${modules}. For more information, visit https://ntl.fyi/edge-functions-npm.`);
218
270
  }
219
- }
220
-
221
- this.#processGraph(graph)
222
-
223
- if (npmSpecifiersWithExtraneousFiles.length !== 0) {
224
- const modules = npmSpecifiersWithExtraneousFiles.map((name) => chalk.yellow(name)).join(', ')
225
-
226
- log(
227
- `${NETLIFYDEVWARN} The following npm modules, which are directly or indirectly imported by an edge function, may not be supported: ${modules}. For more information, visit https://ntl.fyi/edge-functions-npm.`,
228
- )
229
- }
230
-
231
- return { warnings }
232
- } catch (error) {
233
- this.#buildError = error
234
-
235
- throw error
271
+ return { warnings };
272
+ }
273
+ catch (error) {
274
+ // @ts-expect-error TS(2322) FIXME: Type 'unknown' is not assignable to type 'null'.
275
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_buildError, error, "f");
276
+ throw error;
236
277
  }
237
- }
238
-
239
- /**
240
- * Builds a manifest and corresponding routes for the functions in the
241
- * registry, taking into account the declarations from the TOML, from
242
- * the deploy configuration API, and from the in-source configuration
243
- * found in both internal and user functions.
244
- *
245
- * @param {Record<string, FunctionConfig>} internalFunctionConfigs
246
- * @param {Record<string, FunctionConfig>} userFunctionConfigs
247
- */
248
- #buildRoutes(internalFunctionConfigs, userFunctionConfigs) {
249
- const declarations = this.#bundler.mergeDeclarations(
250
- this.#declarationsFromTOML,
251
- userFunctionConfigs,
252
- internalFunctionConfigs,
253
- this.#declarationsFromDeployConfig,
254
- featureFlags,
255
- )
256
- const { declarationsWithoutFunction, manifest, unroutedFunctions } = this.#bundler.generateManifest({
257
- declarations,
258
- userFunctionConfig: userFunctionConfigs,
259
- internalFunctionConfig: internalFunctionConfigs,
260
- functions: this.#functions,
261
- featureFlags,
262
- })
278
+ }, _EdgeFunctionsRegistry_buildRoutes = function _EdgeFunctionsRegistry_buildRoutes(internalFunctionConfigs, userFunctionConfigs) {
279
+ const declarations = __classPrivateFieldGet(this, _EdgeFunctionsRegistry_bundler, "f").mergeDeclarations(__classPrivateFieldGet(this, _EdgeFunctionsRegistry_declarationsFromTOML, "f"), userFunctionConfigs, internalFunctionConfigs, __classPrivateFieldGet(this, _EdgeFunctionsRegistry_declarationsFromDeployConfig, "f"), featureFlags);
280
+ const { declarationsWithoutFunction, manifest, unroutedFunctions } = __classPrivateFieldGet(this, _EdgeFunctionsRegistry_bundler, "f").generateManifest({
281
+ declarations,
282
+ userFunctionConfig: userFunctionConfigs,
283
+ internalFunctionConfig: internalFunctionConfigs,
284
+ functions: __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "a", _EdgeFunctionsRegistry_functions_get),
285
+ featureFlags,
286
+ });
263
287
  const routes = [...manifest.routes, ...manifest.post_cache_routes].map((route) => ({
264
- ...route,
265
- pattern: new RegExp(route.pattern),
266
- }))
267
-
268
- return { declarationsWithoutFunction, manifest, routes, unroutedFunctions }
269
- }
270
-
271
- /**
272
- * @returns {Promise<void>}
273
- */
274
- async #checkForAddedOrDeletedFunctions() {
275
- const { deleted: deletedFunctions, new: newFunctions } = await this.#scanForFunctions()
276
-
288
+ ...route,
289
+ pattern: new RegExp(route.pattern),
290
+ }));
291
+ return { declarationsWithoutFunction, manifest, routes, unroutedFunctions };
292
+ }, _EdgeFunctionsRegistry_checkForAddedOrDeletedFunctions =
293
+ /**
294
+ * @returns {Promise<void>}
295
+ */
296
+ async function _EdgeFunctionsRegistry_checkForAddedOrDeletedFunctions() {
297
+ const { deleted: deletedFunctions, new: newFunctions } = await __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_scanForFunctions).call(this);
277
298
  if (newFunctions.length === 0 && deletedFunctions.length === 0) {
278
- return
299
+ return;
279
300
  }
280
-
281
301
  try {
282
- const { warnings } = await this.#build()
283
-
284
- deletedFunctions.forEach((func) => {
285
- this.#logEvent('removed', { functionName: func.name, warnings: warnings[func.name] })
286
- })
287
-
288
- newFunctions.forEach((func) => {
289
- this.#logEvent('loaded', { functionName: func.name, warnings: warnings[func.name] })
290
- })
291
- } catch {
292
- // no-op
302
+ const { warnings } = await __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_build).call(this);
303
+ deletedFunctions.forEach((func) => {
304
+ // @ts-expect-error TS(2345) FIXME: Argument of type '{ functionName: any; warnings: a... Remove this comment to see the full error message
305
+ __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_logEvent).call(this, 'removed', { functionName: func.name, warnings: warnings[func.name] });
306
+ });
307
+ newFunctions.forEach((func) => {
308
+ // @ts-expect-error TS(2345) FIXME: Argument of type '{ functionName: any; warnings: a... Remove this comment to see the full error message
309
+ __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_logEvent).call(this, 'loaded', { functionName: func.name, warnings: warnings[func.name] });
310
+ });
293
311
  }
294
- }
295
-
296
- /**
297
- * @param {any} config
298
- * @returns {Declaration[]}
299
- */
300
- static #getDeclarationsFromTOML(config) {
301
- const { edge_functions: edgeFunctions = [] } = config
302
-
303
- return edgeFunctions
304
- }
305
-
306
- /**
307
- * @param {Record<string, { sources:string[], value:string }>} envConfig
308
- * @returns {Record<string, string>}
309
- */
310
- static #getEnvironmentVariables(envConfig) {
311
- const env = Object.create(null)
312
+ catch {
313
+ // no-op
314
+ }
315
+ }, _EdgeFunctionsRegistry_getDeclarationsFromTOML = function _EdgeFunctionsRegistry_getDeclarationsFromTOML(config) {
316
+ const { edge_functions: edgeFunctions = [] } = config;
317
+ return edgeFunctions;
318
+ }, _EdgeFunctionsRegistry_getEnvironmentVariables = function _EdgeFunctionsRegistry_getEnvironmentVariables(envConfig) {
319
+ const env = Object.create(null);
312
320
  Object.entries(envConfig).forEach(([key, variable]) => {
313
- if (
321
+ if (
322
+ // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
314
323
  variable.sources.includes('ui') ||
315
- variable.sources.includes('account') ||
316
- variable.sources.includes('addons') ||
317
- variable.sources.includes('internal') ||
318
- variable.sources.some((source) => source.startsWith('.env'))
319
- ) {
320
- env[key] = variable.value
321
- }
322
- })
323
-
324
- env.DENO_REGION = 'local'
325
-
326
- return env
327
- }
328
-
329
- /**
330
- * @param {string[]} paths
331
- * @returns {Promise<void>}
332
- */
333
- async #handleFileChange(paths) {
334
- const matchingFunctions = new Set(
335
- [
336
- ...paths.map((path) => this.#functionPaths.get(path)),
337
- ...paths.flatMap((path) => this.#dependencyPaths.get(path)),
338
- ].filter(Boolean),
339
- )
340
-
324
+ // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
325
+ variable.sources.includes('account') ||
326
+ // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
327
+ variable.sources.includes('addons') ||
328
+ // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
329
+ variable.sources.includes('internal') ||
330
+ // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
331
+ variable.sources.some((source) => source.startsWith('.env'))) {
332
+ // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
333
+ env[key] = variable.value;
334
+ }
335
+ });
336
+ env.DENO_REGION = 'local';
337
+ return env;
338
+ }, _EdgeFunctionsRegistry_handleFileChange =
339
+ /**
340
+ * @param {string[]} paths
341
+ * @returns {Promise<void>}
342
+ */
343
+ // @ts-expect-error TS(7006) FIXME: Parameter 'paths' implicitly has an 'any' type.
344
+ async function _EdgeFunctionsRegistry_handleFileChange(paths) {
345
+ const matchingFunctions = new Set([
346
+ // @ts-expect-error TS(7006) FIXME: Parameter 'path' implicitly has an 'any' type.
347
+ ...paths.map((path) => __classPrivateFieldGet(this, _EdgeFunctionsRegistry_functionPaths, "f").get(path)),
348
+ // @ts-expect-error TS(7006) FIXME: Parameter 'path' implicitly has an 'any' type.
349
+ ...paths.flatMap((path) => __classPrivateFieldGet(this, _EdgeFunctionsRegistry_dependencyPaths, "f").get(path)),
350
+ ].filter(Boolean));
341
351
  // If the file is not associated with any function, there's no point in
342
352
  // building. However, it might be that the path is in fact associated with
343
353
  // a function but we just haven't registered it due to a build error. So if
344
354
  // there was a build error, let's always build.
345
- if (matchingFunctions.size === 0 && this.#buildError === null) {
346
- return
355
+ if (matchingFunctions.size === 0 && __classPrivateFieldGet(this, _EdgeFunctionsRegistry_buildError, "f") === null) {
356
+ return;
347
357
  }
348
-
349
- this.#logEvent('reloading', {})
350
-
358
+ // @ts-expect-error TS(2345) FIXME: Argument of type '{}' is not assignable to paramet... Remove this comment to see the full error message
359
+ __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_logEvent).call(this, 'reloading', {});
351
360
  try {
352
- const { warnings } = await this.#build()
353
- const functionNames = [...matchingFunctions]
354
-
355
- if (functionNames.length === 0) {
356
- this.#logEvent('reloaded', {})
357
- } else {
358
- functionNames.forEach((functionName) => {
359
- this.#logEvent('reloaded', { functionName, warnings: warnings[functionName] })
360
- })
361
- }
362
- } catch (error) {
363
- this.#logEvent('buildError', { buildError: error?.message })
361
+ const { warnings } = await __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_build).call(this);
362
+ const functionNames = [...matchingFunctions];
363
+ if (functionNames.length === 0) {
364
+ // @ts-expect-error TS(2345) FIXME: Argument of type '{}' is not assignable to paramet... Remove this comment to see the full error message
365
+ __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_logEvent).call(this, 'reloaded', {});
366
+ }
367
+ else {
368
+ functionNames.forEach((functionName) => {
369
+ // @ts-expect-error TS(2345) FIXME: Argument of type '{ functionName: any; warnings: a... Remove this comment to see the full error message
370
+ __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_logEvent).call(this, 'reloaded', { functionName, warnings: warnings[functionName] });
371
+ });
372
+ }
373
+ }
374
+ catch (error) {
375
+ // @ts-expect-error TS(2345) FIXME: Argument of type '{ buildError: any; }' is not ass... Remove this comment to see the full error message
376
+ __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_logEvent).call(this, 'buildError', { buildError: error?.message });
364
377
  }
365
- }
366
-
367
- /**
368
- * @return {Promise<void>}
369
- */
370
- async initialize() {
371
- return await this.#initialScan
372
- }
373
-
374
- /**
375
- * Logs an event associated with functions.
376
- *
377
- * @param {EdgeFunctionEvent} event
378
- * @param {object} data
379
- * @param {Error} [data.buildError]
380
- * @param {string} [data.functionName]
381
- * @param {string[]} [data.warnings]
382
- * @returns
383
- */
384
- #logEvent(event, { buildError, functionName, warnings = [] }) {
378
+ }, _EdgeFunctionsRegistry_logEvent = function _EdgeFunctionsRegistry_logEvent(event, { buildError, functionName, warnings = [] }) {
385
379
  const subject = functionName
386
- ? `edge function ${chalk.yellow(this.#getDisplayName(functionName))}`
387
- : 'edge functions'
388
- const warningsText =
389
- warnings.length === 0 ? '' : ` with warnings:\n${warnings.map((warning) => ` - ${warning}`).join('\n')}`
390
-
380
+ ? `edge function ${chalk.yellow(__classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_getDisplayName).call(this, functionName))}`
381
+ : 'edge functions';
382
+ const warningsText = warnings.length === 0 ? '' : ` with warnings:\n${warnings.map((warning) => ` - ${warning}`).join('\n')}`;
391
383
  if (event === 'buildError') {
392
- log(`${NETLIFYDEVERR} ${chalk.red('Failed to load')} ${subject}: ${buildError}`)
393
-
394
- return
384
+ log(`${NETLIFYDEVERR} ${chalk.red('Failed to load')} ${subject}: ${buildError}`);
385
+ return;
395
386
  }
396
-
397
387
  if (event === 'loaded') {
398
- const icon = warningsText ? NETLIFYDEVWARN : NETLIFYDEVLOG
399
- const color = warningsText ? chalk.yellow : chalk.green
400
-
401
- log(`${icon} ${color('Loaded')} ${subject}${warningsText}`)
402
-
403
- return
388
+ const icon = warningsText ? NETLIFYDEVWARN : NETLIFYDEVLOG;
389
+ const color = warningsText ? chalk.yellow : chalk.green;
390
+ log(`${icon} ${color('Loaded')} ${subject}${warningsText}`);
391
+ return;
404
392
  }
405
-
406
393
  if (event === 'reloaded') {
407
- const icon = warningsText ? NETLIFYDEVWARN : NETLIFYDEVLOG
408
- const color = warningsText ? chalk.yellow : chalk.green
409
-
410
- log(`${icon} ${color('Reloaded')} ${subject}${warningsText}`)
411
-
412
- return
394
+ const icon = warningsText ? NETLIFYDEVWARN : NETLIFYDEVLOG;
395
+ const color = warningsText ? chalk.yellow : chalk.green;
396
+ log(`${icon} ${color('Reloaded')} ${subject}${warningsText}`);
397
+ return;
413
398
  }
414
-
415
399
  if (event === 'reloading') {
416
- log(`${NETLIFYDEVLOG} ${chalk.magenta('Reloading')} ${subject}...`)
417
-
418
- return
400
+ log(`${NETLIFYDEVLOG} ${chalk.magenta('Reloading')} ${subject}...`);
401
+ return;
419
402
  }
420
-
421
403
  if (event === 'removed') {
422
- log(`${NETLIFYDEVLOG} ${chalk.magenta('Removed')} ${subject}`)
404
+ log(`${NETLIFYDEVLOG} ${chalk.magenta('Removed')} ${subject}`);
423
405
  }
424
- }
425
-
426
- /**
427
- * Returns the functions in the registry that should run for a given URL path
428
- * and HTTP method, based on the routes registered for each function.
429
- *
430
- * @param {string} urlPath
431
- * @param {string} method
432
- */
433
- matchURLPath(urlPath, method) {
434
- /** @type string[] */
435
- const functionNames = []
436
-
437
- /** @type number[] */
438
- const routeIndexes = []
439
-
440
- this.#routes.forEach((route, index) => {
441
- if (route.methods && route.methods.length !== 0 && !route.methods.includes(method)) {
442
- return
443
- }
444
-
445
- if (!route.pattern.test(urlPath)) {
446
- return
447
- }
448
-
449
- const isExcluded = this.#manifest?.function_config[route.function]?.excluded_patterns?.some((pattern) =>
450
- new RegExp(pattern).test(urlPath),
451
- )
452
-
453
- if (isExcluded) {
454
- return
455
- }
456
-
457
- functionNames.push(route.function)
458
- routeIndexes.push(index)
459
- })
460
- const invocationMetadata = {
461
- function_config: this.#manifest?.function_config,
462
- req_routes: routeIndexes,
463
- routes: this.#manifest?.routes.map((route) => ({
464
- function: route.function,
465
- path: route.path,
466
- pattern: route.pattern,
467
- })),
468
- }
469
-
470
- return { functionNames, invocationMetadata }
471
- }
472
-
473
- /**
474
- * Takes the module graph returned from the server and tracks dependencies of
475
- * each function.
476
- *
477
- * @param {ModuleGraph} graph
478
- */
479
- #processGraph(graph) {
406
+ }, _EdgeFunctionsRegistry_processGraph = function _EdgeFunctionsRegistry_processGraph(graph) {
480
407
  if (!graph) {
481
- warn('Could not process edge functions dependency graph. Live reload will not be available.')
482
-
483
- return
408
+ warn('Could not process edge functions dependency graph. Live reload will not be available.');
409
+ return;
484
410
  }
485
-
486
411
  // Creating a Map from `this.#functions` that map function paths to function
487
412
  // names. This allows us to match modules against functions in O(1) time as
488
413
  // opposed to O(n).
414
+ // @ts-expect-error TS(2339) FIXME: Property 'path' does not exist on type 'never'.
489
415
  // eslint-disable-next-line unicorn/prefer-spread
490
- const functionPaths = new Map(Array.from(this.#functions, (func) => [func.path, func.name]))
491
-
416
+ const functionPaths = new Map(Array.from(__classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "a", _EdgeFunctionsRegistry_functions_get), (func) => [func.path, func.name]));
492
417
  // Mapping file URLs to names of functions that use them as dependencies.
493
- const dependencyPaths = new Map()
494
-
418
+ const dependencyPaths = new Map();
419
+ // @ts-expect-error TS(7031) FIXME: Binding element 'specifier' implicitly has an 'any... Remove this comment to see the full error message
495
420
  graph.modules.forEach(({ dependencies = [], specifier }) => {
496
- if (!specifier.startsWith('file://')) {
497
- return
498
- }
499
-
500
- const path = fileURLToPath(specifier)
501
- const functionMatch = functionPaths.get(path)
502
-
503
- if (!functionMatch) {
504
- return
505
- }
506
-
507
- dependencies.forEach((dependency) => {
508
- // We're interested in tracking local dependencies, so we only look at
509
- // specifiers with the `file:` protocol.
510
- if (
511
- dependency.code === undefined ||
512
- typeof dependency.code.specifier !== 'string' ||
513
- !dependency.code.specifier.startsWith('file://')
514
- ) {
515
- return
421
+ if (!specifier.startsWith('file://')) {
422
+ return;
516
423
  }
517
-
518
- const { specifier: dependencyURL } = dependency.code
519
- const dependencyPath = fileURLToPath(dependencyURL)
520
- const functions = dependencyPaths.get(dependencyPath) || []
521
-
522
- dependencyPaths.set(dependencyPath, [...functions, functionMatch])
523
- })
524
- })
525
-
526
- this.#dependencyPaths = dependencyPaths
527
- this.#functionPaths = functionPaths
528
- }
529
-
530
- /**
531
- * Thin wrapper for `#runIsolate` that skips running a build and returns an
532
- * empty response if there are no functions in the registry.
533
- */
534
- async #runBuild() {
535
- if (this.#functions.length === 0) {
536
- return {
537
- functionsConfig: [],
538
- graph: {
539
- modules: [],
540
- },
541
- npmSpecifiersWithExtraneousFiles: [],
542
- success: true,
543
- }
424
+ const path = fileURLToPath(specifier);
425
+ const functionMatch = functionPaths.get(path);
426
+ if (!functionMatch) {
427
+ return;
428
+ }
429
+ dependencies.forEach((dependency) => {
430
+ // We're interested in tracking local dependencies, so we only look at
431
+ // specifiers with the `file:` protocol.
432
+ if (
433
+ // @ts-expect-error TS(2339) FIXME: Property 'code' does not exist on type 'never'.
434
+ dependency.code === undefined ||
435
+ // @ts-expect-error TS(2339) FIXME: Property 'code' does not exist on type 'never'.
436
+ typeof dependency.code.specifier !== 'string' ||
437
+ // @ts-expect-error TS(2339) FIXME: Property 'code' does not exist on type 'never'.
438
+ !dependency.code.specifier.startsWith('file://')) {
439
+ return;
440
+ }
441
+ // @ts-expect-error TS(2339) FIXME: Property 'code' does not exist on type 'never'.
442
+ const { specifier: dependencyURL } = dependency.code;
443
+ const dependencyPath = fileURLToPath(dependencyURL);
444
+ const functions = dependencyPaths.get(dependencyPath) || [];
445
+ dependencyPaths.set(dependencyPath, [...functions, functionMatch]);
446
+ });
447
+ });
448
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_dependencyPaths, dependencyPaths, "f");
449
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_functionPaths, functionPaths, "f");
450
+ }, _EdgeFunctionsRegistry_runBuild =
451
+ /**
452
+ * Thin wrapper for `#runIsolate` that skips running a build and returns an
453
+ * empty response if there are no functions in the registry.
454
+ */
455
+ async function _EdgeFunctionsRegistry_runBuild() {
456
+ if (__classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "a", _EdgeFunctionsRegistry_functions_get).length === 0) {
457
+ return {
458
+ functionsConfig: [],
459
+ graph: {
460
+ modules: [],
461
+ },
462
+ npmSpecifiersWithExtraneousFiles: [],
463
+ success: true,
464
+ };
544
465
  }
545
-
546
- const { functionsConfig, graph, npmSpecifiersWithExtraneousFiles, success } = await this.#runIsolate(
547
- this.#functions,
548
- this.#env,
549
- {
466
+ const { functionsConfig, graph, npmSpecifiersWithExtraneousFiles, success } = await __classPrivateFieldGet(this, _EdgeFunctionsRegistry_runIsolate, "f").call(this, __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "a", _EdgeFunctionsRegistry_functions_get), __classPrivateFieldGet(this, _EdgeFunctionsRegistry_env, "f"), {
550
467
  getFunctionsConfig: true,
551
- },
552
- )
553
-
554
- return { functionsConfig, graph, npmSpecifiersWithExtraneousFiles, success }
555
- }
556
-
557
- /**
558
- * @returns {Promise<{all: EdgeFunction[], new: EdgeFunction[], deleted: EdgeFunction[]}>}
559
- */
560
- async #scanForFunctions() {
468
+ });
469
+ return { functionsConfig, graph, npmSpecifiersWithExtraneousFiles, success };
470
+ }, _EdgeFunctionsRegistry_scanForFunctions =
471
+ /**
472
+ * @returns {Promise<{all: EdgeFunction[], new: EdgeFunction[], deleted: EdgeFunction[]}>}
473
+ */
474
+ async function _EdgeFunctionsRegistry_scanForFunctions() {
561
475
  const [internalFunctions, userFunctions] = await Promise.all([
562
- this.#bundler.find(this.#internalDirectories),
563
- this.#bundler.find(this.#directories),
564
- ])
565
-
566
- const functions = [...internalFunctions, ...userFunctions]
567
-
476
+ __classPrivateFieldGet(this, _EdgeFunctionsRegistry_bundler, "f").find(__classPrivateFieldGet(this, _EdgeFunctionsRegistry_internalDirectories, "f")),
477
+ __classPrivateFieldGet(this, _EdgeFunctionsRegistry_bundler, "f").find(__classPrivateFieldGet(this, _EdgeFunctionsRegistry_directories, "f")),
478
+ ]);
479
+ const functions = [...internalFunctions, ...userFunctions];
568
480
  const newFunctions = functions.filter((func) => {
569
- const functionExists = this.#functions.some(
570
- (existingFunc) => func.name === existingFunc.name && func.path === existingFunc.path,
571
- )
572
-
573
- return !functionExists
574
- })
575
- const deletedFunctions = this.#functions.filter((existingFunc) => {
576
- const functionExists = functions.some(
577
- (func) => func.name === existingFunc.name && func.path === existingFunc.path,
578
- )
579
-
580
- return !functionExists
581
- })
582
-
583
- this.#internalFunctions = internalFunctions
584
- this.#userFunctions = userFunctions
585
-
586
- return { all: functions, new: newFunctions, deleted: deletedFunctions }
587
- }
588
-
589
- /**
590
- * @param {string} projectDir
591
- */
592
- async #setupWatchers(projectDir) {
593
- if (this.#configPath) {
594
- // Creating a watcher for the config file. When it changes, we update the
595
- // declarations and see if we need to register or unregister any functions.
596
- await watchDebounced(this.#configPath, {
597
- onChange: async () => {
598
- const newConfig = await this.#getUpdatedConfig()
599
-
600
- this.#declarationsFromTOML = EdgeFunctionsRegistry.#getDeclarationsFromTOML(newConfig)
601
-
602
- await this.#checkForAddedOrDeletedFunctions()
603
- },
604
- })
481
+ const functionExists = __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "a", _EdgeFunctionsRegistry_functions_get).some(
482
+ // @ts-expect-error TS(2339) FIXME: Property 'name' does not exist on type 'never'.
483
+ (existingFunc) => func.name === existingFunc.name && func.path === existingFunc.path);
484
+ return !functionExists;
485
+ });
486
+ const deletedFunctions = __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "a", _EdgeFunctionsRegistry_functions_get).filter((existingFunc) => {
487
+ const functionExists = functions.some(
488
+ // @ts-expect-error TS(2339) FIXME: Property 'name' does not exist on type 'never'.
489
+ (func) => func.name === existingFunc.name && func.path === existingFunc.path);
490
+ return !functionExists;
491
+ });
492
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_internalFunctions, internalFunctions, "f");
493
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_userFunctions, userFunctions, "f");
494
+ return { all: functions, new: newFunctions, deleted: deletedFunctions };
495
+ }, _EdgeFunctionsRegistry_setupWatchers =
496
+ /**
497
+ * @param {string} projectDir
498
+ */
499
+ // @ts-expect-error TS(7006) FIXME: Parameter 'projectDir' implicitly has an 'any' typ... Remove this comment to see the full error message
500
+ async function _EdgeFunctionsRegistry_setupWatchers(projectDir) {
501
+ if (__classPrivateFieldGet(this, _EdgeFunctionsRegistry_configPath, "f")) {
502
+ // Creating a watcher for the config file. When it changes, we update the
503
+ // declarations and see if we need to register or unregister any functions.
504
+ // @ts-expect-error TS(2345) FIXME: Argument of type '{ onChange: () => Promise<void>;... Remove this comment to see the full error message
505
+ await watchDebounced(__classPrivateFieldGet(this, _EdgeFunctionsRegistry_configPath, "f"), {
506
+ onChange: async () => {
507
+ const newConfig = await __classPrivateFieldGet(this, _EdgeFunctionsRegistry_getUpdatedConfig, "f").call(this);
508
+ __classPrivateFieldSet(this, _EdgeFunctionsRegistry_declarationsFromTOML, __classPrivateFieldGet(EdgeFunctionsRegistry, _a, "m", _EdgeFunctionsRegistry_getDeclarationsFromTOML).call(EdgeFunctionsRegistry, newConfig), "f");
509
+ await __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_checkForAddedOrDeletedFunctions).call(this);
510
+ },
511
+ });
605
512
  }
606
-
607
513
  // While functions are guaranteed to be inside one of the configured
608
514
  // directories, they might be importing files that are located in
609
515
  // parent directories. So we watch the entire project directory for
610
516
  // changes.
611
- await this.#setupWatcherForDirectory(projectDir)
612
- }
613
-
614
- /**
615
- * @param {string} directory
616
- * @returns {Promise<void>}
617
- */
618
- async #setupWatcherForDirectory(directory) {
619
- const ignored = [`${this.#servePath}/**`]
517
+ await __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_setupWatcherForDirectory).call(this, projectDir);
518
+ }, _EdgeFunctionsRegistry_setupWatcherForDirectory =
519
+ /**
520
+ * @param {string} directory
521
+ * @returns {Promise<void>}
522
+ */
523
+ // @ts-expect-error TS(7006) FIXME: Parameter 'directory' implicitly has an 'any' type... Remove this comment to see the full error message
524
+ async function _EdgeFunctionsRegistry_setupWatcherForDirectory(directory) {
525
+ const ignored = [`${__classPrivateFieldGet(this, _EdgeFunctionsRegistry_servePath, "f")}/**`];
620
526
  const watcher = await watchDebounced(directory, {
621
- ignored,
622
- onAdd: () => this.#checkForAddedOrDeletedFunctions(),
623
- onChange: (paths) => this.#handleFileChange(paths),
624
- onUnlink: () => this.#checkForAddedOrDeletedFunctions(),
625
- })
626
-
627
- this.#directoryWatchers.set(directory, watcher)
628
- }
629
-
630
- /**
631
- * @param {string} func
632
- * @returns {string | undefined}
633
- */
634
- #getDisplayName(func) {
635
- const declarations = [...this.#declarationsFromTOML, ...this.#declarationsFromDeployConfig]
636
-
637
- return declarations.find((declaration) => declaration.function === func)?.name ?? func
638
- }
639
- }
527
+ // @ts-expect-error TS(2322) FIXME: Type 'string[]' is not assignable to type 'never[]... Remove this comment to see the full error message
528
+ ignored,
529
+ onAdd: () => __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_checkForAddedOrDeletedFunctions).call(this),
530
+ // @ts-expect-error TS(2322) FIXME: Type '(paths: any) => Promise<void>' is not assign... Remove this comment to see the full error message
531
+ onChange: (paths) => __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_handleFileChange).call(this, paths),
532
+ onUnlink: () => __classPrivateFieldGet(this, _EdgeFunctionsRegistry_instances, "m", _EdgeFunctionsRegistry_checkForAddedOrDeletedFunctions).call(this),
533
+ });
534
+ __classPrivateFieldGet(this, _EdgeFunctionsRegistry_directoryWatchers, "f").set(directory, watcher);
535
+ }, _EdgeFunctionsRegistry_getDisplayName = function _EdgeFunctionsRegistry_getDisplayName(func) {
536
+ const declarations = [...__classPrivateFieldGet(this, _EdgeFunctionsRegistry_declarationsFromTOML, "f"), ...__classPrivateFieldGet(this, _EdgeFunctionsRegistry_declarationsFromDeployConfig, "f")];
537
+ return declarations.find((declaration) => declaration.function === func)?.name ?? func;
538
+ };