You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@netlify/dev-utils

Package Overview
Dependencies
Maintainers
16
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netlify/dev-utils - npm Package Compare versions

Comparing version

to
4.1.0

37

dist/main.d.ts

@@ -21,4 +21,26 @@ import { Context } from '@netlify/types';

declare class LocalState {
private path;
constructor(cwd: string);
get all(): any;
set all(val: any);
get size(): number;
get(key: any): string | undefined;
set(...args: any[]): void;
has(key: any): boolean;
delete(key: any): void;
clear(): void;
}
type Geolocation = Context['geo'];
declare const mockLocation: Geolocation;
/**
* Returns geolocation data from a remote API, the local cache, or a mock location, depending on the
* specified options.
*/
declare const getGeoLocation: ({ enabled, cache, state, }: {
enabled?: boolean;
cache?: boolean;
state: LocalState;
}) => Promise<Geolocation>;

@@ -59,15 +81,2 @@ type logFunction = (message?: string) => void;

declare class LocalState {
private path;
constructor(cwd: string);
get all(): any;
set all(val: any);
get size(): number;
get(key: any): string | undefined;
set(...args: any[]): void;
has(key: any): boolean;
delete(key: any): void;
clear(): void;
}
interface CacheEntry<T> {

@@ -200,2 +209,2 @@ enqueued?: boolean;

export { type DevEvent, type DevEventHandler, EventInspector, Fixture, type Geolocation, GlobalConfigStore, HTTPServer, type Handler, LocalState, type Logger, type MemoizeCache, MockFetch, type ProcessRef, createImageServerHandler, createMockLogger, ensureNetlifyIgnore, fromWebResponse, generateImage, getAPIToken, getGlobalConfigStore, getImageResponseSize, headers, killProcess, memoize, mockLocation, netlifyBanner, netlifyCommand, netlifyCyan, renderFunctionErrorPage, resetConfigCache, shouldBase64Encode, toMultiValueHeaders, toWebRequest, watchDebounced };
export { type DevEvent, type DevEventHandler, EventInspector, Fixture, type Geolocation, GlobalConfigStore, HTTPServer, type Handler, LocalState, type Logger, type MemoizeCache, MockFetch, type ProcessRef, createImageServerHandler, createMockLogger, ensureNetlifyIgnore, fromWebResponse, generateImage, getAPIToken, getGeoLocation, getGlobalConfigStore, getImageResponseSize, headers, killProcess, memoize, mockLocation, netlifyBanner, netlifyCommand, netlifyCyan, renderFunctionErrorPage, resetConfigCache, shouldBase64Encode, toMultiValueHeaders, toWebRequest, watchDebounced };

@@ -152,2 +152,41 @@ // src/lib/global-config.ts

};
var API_URL = "https://netlifind.netlify.app";
var STATE_GEO_PROPERTY = "geolocation";
var CACHE_TTL = 864e5;
var REQUEST_TIMEOUT = 1e4;
var getGeoLocation = async ({
enabled = true,
cache = true,
state
}) => {
if (!enabled) {
return mockLocation;
}
const cacheObject = state.get(STATE_GEO_PROPERTY);
if (cacheObject !== void 0 && cache) {
const age = Date.now() - cacheObject.timestamp;
if (age < CACHE_TTL) {
return cacheObject.data;
}
}
try {
const data = await getGeoLocationFromAPI();
const newCacheObject = {
data,
timestamp: Date.now()
};
state.set(STATE_GEO_PROPERTY, newCacheObject);
return data;
} catch {
return mockLocation;
}
};
var getGeoLocationFromAPI = async () => {
const res = await fetch(API_URL, {
method: "GET",
signal: AbortSignal.timeout(REQUEST_TIMEOUT)
});
const { geo } = await res.json();
return geo;
};

@@ -783,2 +822,3 @@ // src/lib/gitignore.ts

getAPIToken,
getGeoLocation,
getGlobalConfigStore,

@@ -785,0 +825,0 @@ getImageResponseSize,

{
"name": "@netlify/dev-utils",
"version": "4.0.0",
"version": "4.1.0",
"description": "TypeScript utilities for the local emulation of the Netlify environment",

@@ -5,0 +5,0 @@ "type": "module",