@netlify/dev 4.4.6 → 4.5.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/main.cjs CHANGED
@@ -312,6 +312,7 @@ var NetlifyDev = class {
312
312
  #cleanupJobs;
313
313
  #edgeFunctionsHandler;
314
314
  #functionsHandler;
315
+ #geolocationConfig;
315
316
  #functionsServePath;
316
317
  #config;
317
318
  #features;
@@ -334,11 +335,13 @@ var NetlifyDev = class {
334
335
  const projectRoot = options.projectRoot ?? import_node_process2.default.cwd();
335
336
  this.#apiToken = options.apiToken;
336
337
  this.#cleanupJobs = [];
338
+ this.#geolocationConfig = options.geolocation;
337
339
  this.#features = {
338
340
  blobs: options.blobs?.enabled !== false,
339
341
  edgeFunctions: options.edgeFunctions?.enabled !== false,
340
342
  environmentVariables: options.environmentVariables?.enabled !== false,
341
343
  functions: options.functions?.enabled !== false,
344
+ geolocation: options.geolocation?.enabled !== false,
342
345
  headers: options.headers?.enabled !== false,
343
346
  images: options.images?.enabled !== false,
344
347
  redirects: options.redirects?.enabled !== false,
@@ -545,6 +548,7 @@ var NetlifyDev = class {
545
548
  siteID
546
549
  });
547
550
  }
551
+ let geolocation;
548
552
  if (this.#features.edgeFunctions) {
549
553
  const edgeFunctionsEnv = {
550
554
  // User-defined env vars + documented runtime env vars
@@ -567,11 +571,16 @@ var NetlifyDev = class {
567
571
  {}
568
572
  )
569
573
  };
574
+ geolocation ??= await (0, import_dev_utils.getGeoLocation)({
575
+ enabled: this.#features.geolocation,
576
+ cache: this.#geolocationConfig?.cache ?? true,
577
+ state
578
+ });
570
579
  const edgeFunctionsHandler = new import_dev.EdgeFunctionsHandler({
571
580
  configDeclarations: this.#config?.config.edge_functions ?? [],
572
581
  directories: [this.#config?.config.build.edge_functions].filter(Boolean),
573
582
  env: edgeFunctionsEnv,
574
- geolocation: import_dev_utils.mockLocation,
583
+ geolocation,
575
584
  logger: this.#logger,
576
585
  siteID,
577
586
  siteName: config?.siteInfo.name
@@ -582,10 +591,15 @@ var NetlifyDev = class {
582
591
  if (this.#features.functions) {
583
592
  const userFunctionsPath = this.#config?.config.functionsDirectory ?? import_node_path2.default.join(this.#projectRoot, "netlify/functions");
584
593
  const userFunctionsPathExists = await isDirectory(userFunctionsPath);
594
+ geolocation ??= await (0, import_dev_utils.getGeoLocation)({
595
+ enabled: this.#features.geolocation,
596
+ cache: this.#geolocationConfig?.cache ?? true,
597
+ state
598
+ });
585
599
  this.#functionsHandler = new import_dev2.FunctionsHandler({
586
600
  config: this.#config,
587
601
  destPath: this.#functionsServePath,
588
- geolocation: import_dev_utils.mockLocation,
602
+ geolocation,
589
603
  projectRoot: this.#projectRoot,
590
604
  settings: {},
591
605
  siteId: this.#siteID,
package/dist/main.d.cts CHANGED
@@ -35,6 +35,21 @@ interface Features {
35
35
  functions?: {
36
36
  enabled?: boolean;
37
37
  };
38
+ /**
39
+ * Configuration options for geolocation data used by Functions and Edge Functions.
40
+ *
41
+ * {@link} https://docs.netlify.com/build/edge-functions/api/#geo
42
+ */
43
+ geolocation?: {
44
+ enabled?: boolean;
45
+ /**
46
+ * Cache the result of the API call. When disabled, the location is retrieved
47
+ * each time.
48
+ *
49
+ * {@default} true
50
+ */
51
+ cache?: boolean;
52
+ };
38
53
  /**
39
54
  * Configuration options for Netlify response headers.
40
55
  *
package/dist/main.d.ts CHANGED
@@ -35,6 +35,21 @@ interface Features {
35
35
  functions?: {
36
36
  enabled?: boolean;
37
37
  };
38
+ /**
39
+ * Configuration options for geolocation data used by Functions and Edge Functions.
40
+ *
41
+ * {@link} https://docs.netlify.com/build/edge-functions/api/#geo
42
+ */
43
+ geolocation?: {
44
+ enabled?: boolean;
45
+ /**
46
+ * Cache the result of the API call. When disabled, the location is retrieved
47
+ * each time.
48
+ *
49
+ * {@default} true
50
+ */
51
+ cache?: boolean;
52
+ };
38
53
  /**
39
54
  * Configuration options for Netlify response headers.
40
55
  *
package/dist/main.js CHANGED
@@ -3,7 +3,13 @@ import { promises as fs2 } from "fs";
3
3
  import path2 from "path";
4
4
  import process2 from "process";
5
5
  import { resolveConfig } from "@netlify/config";
6
- import { ensureNetlifyIgnore, getAPIToken, mockLocation, LocalState, HTTPServer } from "@netlify/dev-utils";
6
+ import {
7
+ ensureNetlifyIgnore,
8
+ getAPIToken,
9
+ getGeoLocation,
10
+ LocalState,
11
+ HTTPServer
12
+ } from "@netlify/dev-utils";
7
13
  import { EdgeFunctionsHandler } from "@netlify/edge-functions/dev";
8
14
  import { FunctionsHandler } from "@netlify/functions/dev";
9
15
  import { HeadersHandler } from "@netlify/headers";
@@ -278,6 +284,7 @@ var NetlifyDev = class {
278
284
  #cleanupJobs;
279
285
  #edgeFunctionsHandler;
280
286
  #functionsHandler;
287
+ #geolocationConfig;
281
288
  #functionsServePath;
282
289
  #config;
283
290
  #features;
@@ -300,11 +307,13 @@ var NetlifyDev = class {
300
307
  const projectRoot = options.projectRoot ?? process2.cwd();
301
308
  this.#apiToken = options.apiToken;
302
309
  this.#cleanupJobs = [];
310
+ this.#geolocationConfig = options.geolocation;
303
311
  this.#features = {
304
312
  blobs: options.blobs?.enabled !== false,
305
313
  edgeFunctions: options.edgeFunctions?.enabled !== false,
306
314
  environmentVariables: options.environmentVariables?.enabled !== false,
307
315
  functions: options.functions?.enabled !== false,
316
+ geolocation: options.geolocation?.enabled !== false,
308
317
  headers: options.headers?.enabled !== false,
309
318
  images: options.images?.enabled !== false,
310
319
  redirects: options.redirects?.enabled !== false,
@@ -511,6 +520,7 @@ var NetlifyDev = class {
511
520
  siteID
512
521
  });
513
522
  }
523
+ let geolocation;
514
524
  if (this.#features.edgeFunctions) {
515
525
  const edgeFunctionsEnv = {
516
526
  // User-defined env vars + documented runtime env vars
@@ -533,11 +543,16 @@ var NetlifyDev = class {
533
543
  {}
534
544
  )
535
545
  };
546
+ geolocation ??= await getGeoLocation({
547
+ enabled: this.#features.geolocation,
548
+ cache: this.#geolocationConfig?.cache ?? true,
549
+ state
550
+ });
536
551
  const edgeFunctionsHandler = new EdgeFunctionsHandler({
537
552
  configDeclarations: this.#config?.config.edge_functions ?? [],
538
553
  directories: [this.#config?.config.build.edge_functions].filter(Boolean),
539
554
  env: edgeFunctionsEnv,
540
- geolocation: mockLocation,
555
+ geolocation,
541
556
  logger: this.#logger,
542
557
  siteID,
543
558
  siteName: config?.siteInfo.name
@@ -548,10 +563,15 @@ var NetlifyDev = class {
548
563
  if (this.#features.functions) {
549
564
  const userFunctionsPath = this.#config?.config.functionsDirectory ?? path2.join(this.#projectRoot, "netlify/functions");
550
565
  const userFunctionsPathExists = await isDirectory(userFunctionsPath);
566
+ geolocation ??= await getGeoLocation({
567
+ enabled: this.#features.geolocation,
568
+ cache: this.#geolocationConfig?.cache ?? true,
569
+ state
570
+ });
551
571
  this.#functionsHandler = new FunctionsHandler({
552
572
  config: this.#config,
553
573
  destPath: this.#functionsServePath,
554
- geolocation: mockLocation,
574
+ geolocation,
555
575
  projectRoot: this.#projectRoot,
556
576
  settings: {},
557
577
  siteId: this.#siteID,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/dev",
3
- "version": "4.4.6",
3
+ "version": "4.5.1",
4
4
  "description": "Emulation of the Netlify environment for local development",
5
5
  "type": "module",
6
6
  "engines": {
@@ -52,16 +52,16 @@
52
52
  "vitest": "^3.0.0"
53
53
  },
54
54
  "dependencies": {
55
- "@netlify/blobs": "10.0.6",
55
+ "@netlify/blobs": "10.0.7",
56
56
  "@netlify/config": "^23.2.0",
57
- "@netlify/dev-utils": "4.0.0",
58
- "@netlify/edge-functions": "2.16.1",
59
- "@netlify/functions": "4.1.14",
60
- "@netlify/headers": "2.0.6",
61
- "@netlify/images": "1.2.2",
62
- "@netlify/redirects": "3.0.6",
63
- "@netlify/runtime": "4.0.10",
64
- "@netlify/static": "3.0.6",
57
+ "@netlify/dev-utils": "4.1.0",
58
+ "@netlify/edge-functions": "2.16.2",
59
+ "@netlify/functions": "4.1.15",
60
+ "@netlify/headers": "2.0.7",
61
+ "@netlify/images": "1.2.4",
62
+ "@netlify/redirects": "3.0.7",
63
+ "@netlify/runtime": "4.0.11",
64
+ "@netlify/static": "3.0.7",
65
65
  "ulid": "^3.0.0"
66
66
  }
67
67
  }