From a74682c664ef6e83fd993e88979559ebcb5a82b6 Mon Sep 17 00:00:00 2001 From: Sam Svindland Date: Wed, 16 Oct 2024 09:14:41 -0400 Subject: [PATCH 1/8] add pnpm lock --- pnpm-lock.yaml | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 pnpm-lock.yaml diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..f281975 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,49 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + devDependencies: + '@types/node': + specifier: ^20.6.2 + version: 20.16.11 + typescript: + specifier: ^4.9.5 + version: 4.9.5 + uglify-js: + specifier: ^3.17.4 + version: 3.19.3 + +packages: + + '@types/node@20.16.11': + resolution: {integrity: sha512-y+cTCACu92FyA5fgQSAI8A1H429g7aSK2HsO7K4XYUWc4dY5IUz55JSDIYT6/VsOLfGy8vmvQYC2hfb0iF16Uw==} + + typescript@4.9.5: + resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} + engines: {node: '>=4.2.0'} + hasBin: true + + uglify-js@3.19.3: + resolution: {integrity: sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==} + engines: {node: '>=0.8.0'} + hasBin: true + + undici-types@6.19.8: + resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==} + +snapshots: + + '@types/node@20.16.11': + dependencies: + undici-types: 6.19.8 + + typescript@4.9.5: {} + + uglify-js@3.19.3: {} + + undici-types@6.19.8: {} From 3466f354079295e12c83bd92d6e42bfb00c70b93 Mon Sep 17 00:00:00 2001 From: Sam Svindland Date: Wed, 16 Oct 2024 09:19:11 -0400 Subject: [PATCH 2/8] switch to using vite for build step instead of uglify --- .gitignore | 3 - .npmignore | 26 - {types => dist}/index.d.ts | 0 dist/index.es.js | 107 ++++ dist/index.es.js.map | 1 + dist/index.umd.js | 3 + dist/index.umd.js.map | 1 + package.json | 9 +- pnpm-lock.yaml | 1172 +++++++++++++++++++++++++++++++++++- vite.config.js | 27 + 10 files changed, 1303 insertions(+), 46 deletions(-) delete mode 100644 .npmignore rename {types => dist}/index.d.ts (100%) create mode 100644 dist/index.es.js create mode 100644 dist/index.es.js.map create mode 100644 dist/index.umd.js create mode 100644 dist/index.umd.js.map create mode 100644 vite.config.js diff --git a/.gitignore b/.gitignore index 3fd2583..09c6bfa 100644 --- a/.gitignore +++ b/.gitignore @@ -4,9 +4,6 @@ npm-debug.log yarn-error.log yarn.lock -# Build output -/dist - # IDE and editor files .vscode/ .idea/ diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 0875c5c..0000000 --- a/.npmignore +++ /dev/null @@ -1,26 +0,0 @@ -# Node.js files -node_modules/ -npm-debug.log -yarn-error.log -yarn.lock - -tsconfig.json - -# Source and example files -/src/ -/examples/ - -# Source control files -.git/ -.gitignore - -# IDE and editor files -.vscode/ -.idea/ -*.iml -*.ipr -*.iws - -# Miscellaneous -.DS_Store -Thumbs.db \ No newline at end of file diff --git a/types/index.d.ts b/dist/index.d.ts similarity index 100% rename from types/index.d.ts rename to dist/index.d.ts diff --git a/dist/index.es.js b/dist/index.es.js new file mode 100644 index 0000000..b3b7e1a --- /dev/null +++ b/dist/index.es.js @@ -0,0 +1,107 @@ +var d = /* @__PURE__ */ ((t) => (t.ADDRESS = "address", t.LATLNG = "latlng", t.PLACE_ID = "place_id", t))(d || {}), p = /* @__PURE__ */ ((t) => (t.XML = "xml", t.JSON = "json", t))(p || {}); +const g = "https://maps.googleapis.com/maps/api/geocode"; +let s = { + outputFormat: "json" + /* JSON */ +}; +async function l(t) { + const { outputFormat: n, ...e } = t, r = new URLSearchParams( + e + ).toString(), o = `${g}/${n}?${r}`; + try { + const i = await (await fetch(o)).json(), { status: c, error_message: f } = i; + if (c === "OK") + return i; + throw new Error( + `Geocoding failed: ${f}. Server returned status code ${c}.` + ); + } catch (a) { + throw a instanceof Error ? new Error(`Geocoding request failed: ${a.message}`) : new Error(`Geocoding request failed with unknown error: ${a}`); + } +} +function m(t) { + s = { + ...s, + ...t + }; +} +function w(t) { + s.key = t; +} +function y(t) { + s.language = t; +} +function $(t) { + s.region = t; +} +function h(t) { + s.components = t; +} +function E(t) { + s.bounds = t; +} +function L(t) { + s.result_type = t; +} +function _(t) { + s.location_type = t; +} +function j(t) { + s.outputFormat = t; +} +function G(t) { + s.enable_address_descriptor = t; +} +function u(t, n, e) { + if (typeof t != "string" || typeof n != "string") + throw new Error( + `Both requestType and value are required and must be of type string. + requestType: ${typeof t}, value: ${typeof n}` + ); + const r = { + ...s, + ...e, + [t]: n + }; + return l(r); +} +function O(t, n, e, r) { + const o = { + outputFormat: "json" + /* JSON */ + }; + return n && (o.key = n), e && (o.language = e), r && (o.region = r), u("address", t, o); +} +function S(t, n, e, r) { + const o = { + outputFormat: "json" + /* JSON */ + }; + return n && (o.key = n), e && (o.language = e), r && (o.region = r), u("place_id", t, o); +} +function A(t, n, e, r, o, a) { + const i = { + outputFormat: "json" + /* JSON */ + }; + return e && (i.key = e), r && (i.language = r), o && (i.region = o), a && (i.location_type = a), u("latlng", `${t},${n}`, i); +} +export { + p as OutputFormat, + d as RequestType, + G as enableAddressDescriptor, + O as fromAddress, + A as fromLatLng, + S as fromPlaceId, + u as geocode, + E as setBounds, + h as setComponents, + m as setDefaults, + w as setKey, + y as setLanguage, + _ as setLocationType, + j as setOutputFormat, + $ as setRegion, + L as setResultType +}; +//# sourceMappingURL=index.es.js.map diff --git a/dist/index.es.js.map b/dist/index.es.js.map new file mode 100644 index 0000000..63f1321 --- /dev/null +++ b/dist/index.es.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.es.js","sources":["../src/index.ts"],"sourcesContent":["/**\r\n * Enum defining possible request types for geocoding.\r\n */\r\nexport enum RequestType {\r\n ADDRESS = \"address\", // Geocoding by address\r\n LATLNG = \"latlng\", // Geocoding by latitude and longitude\r\n PLACE_ID = \"place_id\", // Geocoding by place ID\r\n}\r\n\r\n/**\r\n * Enum defining possible output formats for geocoding.\r\n */\r\nexport enum OutputFormat {\r\n XML = \"xml\", // Output format XML\r\n JSON = \"json\", // Output format JSON\r\n}\r\n\r\n/**\r\n * The URL of the Google Geocoding API.\r\n */\r\nconst GOOGLE_GEOCODE_API = \"https://maps.googleapis.com/maps/api/geocode\";\r\n\r\n/**\r\n * Options that can be passed to the geocoding requests.\r\n */\r\nexport interface GeocodeOptions {\r\n key?: string; // API key for the Google Maps Geocoding API.\r\n language?: string; // Language code for the response.\r\n region?: string; // Region code for the response.\r\n components?: string; // Component filtering for the response.\r\n bounds?: string; // Bounding box for the response.\r\n result_type?: string; // Result type filtering for the response.\r\n location_type?: string; // Location type filtering for the response.\r\n outputFormat: OutputFormat; // Desired output format (either XML or JSON)\r\n enable_address_descriptor?: boolean; // Whether to include an address descriptor in the reverse geocoding response.\r\n}\r\n\r\n/**\r\n * Response object from the geocoding API.\r\n */\r\ninterface GeocodeResponse {\r\n status: string;\r\n results: GeocodeResult[];\r\n address_descriptor?: AddressDescriptor;\r\n plus_code?: PlusCode;\r\n error_message?: string;\r\n}\r\n\r\n/**\r\n * The query parameters for geocoding requests.\r\n */\r\ninterface GeocodeQueryParams extends GeocodeOptions {\r\n place_id?: string; // The plce id to geocode\r\n address?: string; // The address to geocode\r\n latlng?: string; // The latitude/longitude of the location to geocode\r\n}\r\n\r\n/**\r\n * Default options for the geocoding requests.\r\n */\r\nlet defaultOptions: GeocodeOptions = {\r\n outputFormat: OutputFormat.JSON,\r\n};\r\n\r\n/**\r\n * Performs a geocoding request to the Google Geocoding API.\r\n * @function geocodeRequest\r\n * @async\r\n * @param {GeocodeQueryParams} queryParams - The query parameters for the geocoding request.\r\n * @returns {Promise} - A promise that resolves with the geocoding response object.\r\n * @throws {Error} - Throws an error if the geocoding request fails.\r\n */\r\nasync function geocodeRequest(\r\n queryParams: GeocodeQueryParams\r\n): Promise {\r\n const { outputFormat, ...restParams } = queryParams;\r\n const queryString = new URLSearchParams(\r\n restParams as Record\r\n ).toString();\r\n const url = `${GOOGLE_GEOCODE_API}/${outputFormat}?${queryString}`;\r\n try {\r\n const response = await fetch(url);\r\n const json = await response.json();\r\n const { status, error_message } = json;\r\n\r\n if (status === \"OK\") {\r\n return json;\r\n }\r\n\r\n throw new Error(\r\n `Geocoding failed: ${error_message}. Server returned status code ${status}.`\r\n );\r\n } catch (error: unknown) {\r\n if (error instanceof Error) {\r\n throw new Error(`Geocoding request failed: ${error.message}`);\r\n }\r\n throw new Error(`Geocoding request failed with unknown error: ${error}`);\r\n }\r\n}\r\n\r\n/**\r\n * Sets default options for geocoding requests.\r\n *\r\n * @param options - The default options to set.\r\n */\r\nexport function setDefaults(options: GeocodeOptions): void {\r\n defaultOptions = {\r\n ...defaultOptions,\r\n ...options,\r\n };\r\n}\r\n\r\n/**\r\n * Sets the API key to use for geocoding requests.\r\n *\r\n * @param key - The API key to set.\r\n */\r\nexport function setKey(key: string): void {\r\n defaultOptions.key = key;\r\n}\r\n\r\n/**\r\n * Sets the language to use for geocoding requests.\r\n *\r\n * @param language - The language to set.\r\n */\r\nexport function setLanguage(language: string): void {\r\n defaultOptions.language = language;\r\n}\r\n\r\n/**\r\n * Sets the region code to use for geocoding requests.\r\n *\r\n * @param region - The region code to set.\r\n */\r\nexport function setRegion(region: string): void {\r\n defaultOptions.region = region;\r\n}\r\n\r\n/**\r\n * Sets the component filter to use for geocoding requests.\r\n *\r\n * @param components - The component filter to set.\r\n */\r\nexport function setComponents(components: string): void {\r\n defaultOptions.components = components;\r\n}\r\n\r\n/**\r\n * Sets the bounding box to use for geocoding requests.\r\n *\r\n * @param bounds - The bounding box to set.\r\n */\r\nexport function setBounds(bounds: string): void {\r\n defaultOptions.bounds = bounds;\r\n}\r\n\r\n/**\r\n * Sets the result type filter to use for geocoding requests.\r\n * One or more address types to return, separated by a pipe (|).\r\n * Possible values are \"street_address\", \"route\", \"intersection\", \"political\", \"country\",\r\n * \"administrative_area_level_1\", \"administrative_area_level_2\", \"administrative_area_level_3\",\r\n * \"administrative_area_level_4\", \"administrative_area_level_5\", \"colloquial_area\", \"locality\",\r\n * \"ward\", \"sublocality\", \"neighborhood\", \"premise\", \"subpremise\", \"postal_code\", \"natural_feature\",\r\n * \"airport\", \"park\", \"point_of_interest\", and \"postal_code_prefix\".\r\n *\r\n * @param resultType - The result type to set.\r\n */\r\nexport function setResultType(resultType: string): void {\r\n defaultOptions.result_type = resultType;\r\n}\r\n\r\n/**\r\n * Sets the location type filter to use for geocoding requests.\r\n * One or more location types to return. Possible values are \"ROOFTOP\",\r\n * \"RANGE_INTERPOLATED\", \"GEOMETRIC_CENTER\", \"APPROXIMATE\".\r\n *\r\n * @param locationType - The location type to set.\r\n */\r\nexport function setLocationType(locationType: string): void {\r\n defaultOptions.location_type = locationType;\r\n}\r\n\r\n/**\r\n * Sets the desired output format for geocoding requests. The format can be either XML or JSON.\r\n *\r\n * @param outputFormat - The desired output format (either OutputFormat.XML or OutputFormat.JSON).\r\n */\r\nexport function setOutputFormat(outputFormat: OutputFormat): void {\r\n defaultOptions.outputFormat = outputFormat;\r\n}\r\n\r\n/**\r\n * Sets whether to include an address descriptor in the reverse geocoding response.\r\n *\r\n * @param enableAddressDescriptor - A boolean parameter indicating whether to include the address descriptor.\r\n */\r\nexport function enableAddressDescriptor(\r\n enableAddressDescriptor: boolean\r\n): void {\r\n defaultOptions.enable_address_descriptor = enableAddressDescriptor;\r\n}\r\n\r\n/**\r\n * Sends a geocoding request to the Google Maps Geocoding API for a given address and returns the response.\r\n * @function geocode\r\n * @async\r\n * @param {RequestType} requestType - Identifier to specify the type of request (place_id, address, or latlng).\r\n * @param {string} value - The value to be used for geocoding (address, place_id, or latlng).\r\n * @param {GeocodeOptions} [options={}] - Additional options for the geocoding request.\r\n * @returns {Promise} - A promise that resolves with the geocoding response object.\r\n * @throws {Error} - Throws an error if the address is invalid or the geocoding request fails.\r\n */\r\nexport function geocode(\r\n requestType: RequestType | string,\r\n value: string,\r\n options?: GeocodeOptions\r\n): Promise {\r\n if (typeof requestType !== \"string\" || typeof value !== \"string\") {\r\n throw new Error(\r\n `Both requestType and value are required and must be of type string. \r\n requestType: ${typeof requestType}, value: ${typeof value}`\r\n );\r\n }\r\n\r\n const queryParams: GeocodeQueryParams = {\r\n ...defaultOptions,\r\n ...options,\r\n [requestType]: value,\r\n };\r\n return geocodeRequest(queryParams);\r\n}\r\n\r\n/**\r\n * @deprecated Use `geocode` instead.\r\n * Usage: geocode(\"address\", \"Washington\", *options)\r\n */\r\nexport function fromAddress(\r\n address: string,\r\n key?: string,\r\n language?: string,\r\n region?: string\r\n) {\r\n const options: GeocodeOptions = {\r\n outputFormat: OutputFormat.JSON,\r\n };\r\n if (key) {\r\n options.key = key;\r\n }\r\n if (language) {\r\n options.language = language;\r\n }\r\n if (region) {\r\n options.region = region;\r\n }\r\n return geocode(RequestType.ADDRESS, address, options);\r\n}\r\n\r\n/**\r\n * @deprecated use `geocode` instead\r\n * Usage: geocode(\"place_id\", \"ChIJd8BlQ2BZwokRAFUEcm_qrcA\", *options)\r\n */\r\nexport function fromPlaceId(\r\n placeId: string,\r\n key?: string,\r\n language?: string,\r\n region?: string\r\n) {\r\n const options: GeocodeOptions = {\r\n outputFormat: OutputFormat.JSON,\r\n };\r\n if (key) {\r\n options.key = key;\r\n }\r\n if (language) {\r\n options.language = language;\r\n }\r\n if (region) {\r\n options.region = region;\r\n }\r\n return geocode(RequestType.PLACE_ID, placeId, options);\r\n}\r\n\r\n/**\r\n * @deprecated use `geocode` instead\r\n * Usage: geocode(\"latlng\", \"40.714224,-73.961452\", *options)\r\n */\r\nexport function fromLatLng(\r\n lat: number,\r\n lng: number,\r\n key?: string,\r\n language?: string,\r\n region?: string,\r\n location_type?: string\r\n) {\r\n const options: GeocodeOptions = {\r\n outputFormat: OutputFormat.JSON,\r\n };\r\n if (key) {\r\n options.key = key;\r\n }\r\n if (language) {\r\n options.language = language;\r\n }\r\n if (region) {\r\n options.region = region;\r\n }\r\n if (location_type) {\r\n options.location_type = location_type;\r\n }\r\n return geocode(RequestType.LATLNG, `${lat},${lng}`, options);\r\n}\r\n\r\ninterface GeocodeResult {\r\n address_components: AddressComponent[];\r\n formatted_address: string;\r\n geometry: Geometry;\r\n place_id: string;\r\n plus_code: PlusCode;\r\n types: string[];\r\n}\r\n\r\ninterface AddressComponent {\r\n long_name: string;\r\n short_name: string;\r\n types: string[];\r\n}\r\n\r\ninterface Geometry {\r\n location: {\r\n lat: number;\r\n lng: number;\r\n };\r\n location_type: string;\r\n viewport: {\r\n lat: number;\r\n lng: number;\r\n };\r\n southwest: {\r\n lat: number;\r\n lng: number;\r\n };\r\n}\r\n\r\ninterface AddressDescriptor {\r\n area: AreaDescriptor[];\r\n landmarks: Landmark[];\r\n}\r\n\r\ninterface AreaDescriptor {\r\n containment: string;\r\n display_name: {\r\n language_code: string;\r\n text: string;\r\n };\r\n place_id: string;\r\n}\r\n\r\ninterface Landmark {\r\n display_name: {\r\n language_code: string;\r\n text: string;\r\n };\r\n straight_line_distance_meters: number;\r\n place_id: string;\r\n travel_distance_meters: number;\r\n spatial_relationship: string;\r\n types: string[];\r\n}\r\n\r\ninterface PlusCode {\r\n compound_code: string;\r\n global_code: string;\r\n}\r\n"],"names":["RequestType","OutputFormat","GOOGLE_GEOCODE_API","defaultOptions","geocodeRequest","queryParams","outputFormat","restParams","queryString","url","json","status","error_message","error","setDefaults","options","setKey","key","setLanguage","language","setRegion","region","setComponents","components","setBounds","bounds","setResultType","resultType","setLocationType","locationType","setOutputFormat","enableAddressDescriptor","geocode","requestType","value","fromAddress","address","fromPlaceId","placeId","fromLatLng","lat","lng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MACF3B,EAAQ,gBAAgB2B,IAEnBV,EAAQ,UAAoB,GAAGQ,CAAG,IAAIC,CAAG,IAAI1B,CAAO;AAC7D;"} \ No newline at end of file diff --git a/dist/index.umd.js b/dist/index.umd.js new file mode 100644 index 0000000..b37267f --- /dev/null +++ b/dist/index.umd.js @@ -0,0 +1,3 @@ +(function(t,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(t=typeof globalThis<"u"?globalThis:t||self,f(t["react-geocode"]={}))})(this,function(t){"use strict";var f=(e=>(e.ADDRESS="address",e.LATLNG="latlng",e.PLACE_ID="place_id",e))(f||{}),d=(e=>(e.XML="xml",e.JSON="json",e))(d||{});const l="https://maps.googleapis.com/maps/api/geocode";let s={outputFormat:"json"};async function m(e){const{outputFormat:o,...r}=e,i=new URLSearchParams(r).toString(),n=`${l}/${o}?${i}`;try{const u=await(await fetch(n)).json(),{status:g,error_message:D}=u;if(g==="OK")return u;throw new Error(`Geocoding failed: ${D}. Server returned status code ${g}.`)}catch(a){throw a instanceof Error?new Error(`Geocoding request failed: ${a.message}`):new Error(`Geocoding request failed with unknown error: ${a}`)}}function p(e){s={...s,...e}}function y(e){s.key=e}function L(e){s.language=e}function h(e){s.region=e}function w(e){s.components=e}function $(e){s.bounds=e}function E(e){s.result_type=e}function O(e){s.location_type=e}function _(e){s.outputFormat=e}function j(e){s.enable_address_descriptor=e}function c(e,o,r){if(typeof e!="string"||typeof o!="string")throw new Error(`Both requestType and value are required and must be of type string. + requestType: ${typeof e}, value: ${typeof o}`);const i={...s,...r,[e]:o};return m(i)}function S(e,o,r,i){const n={outputFormat:"json"};return o&&(n.key=o),r&&(n.language=r),i&&(n.region=i),c("address",e,n)}function b(e,o,r,i){const n={outputFormat:"json"};return o&&(n.key=o),r&&(n.language=r),i&&(n.region=i),c("place_id",e,n)}function A(e,o,r,i,n,a){const u={outputFormat:"json"};return r&&(u.key=r),i&&(u.language=i),n&&(u.region=n),a&&(u.location_type=a),c("latlng",`${e},${o}`,u)}t.OutputFormat=d,t.RequestType=f,t.enableAddressDescriptor=j,t.fromAddress=S,t.fromLatLng=A,t.fromPlaceId=b,t.geocode=c,t.setBounds=$,t.setComponents=w,t.setDefaults=p,t.setKey=y,t.setLanguage=L,t.setLocationType=O,t.setOutputFormat=_,t.setRegion=h,t.setResultType=E,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}); +//# sourceMappingURL=index.umd.js.map diff --git a/dist/index.umd.js.map b/dist/index.umd.js.map new file mode 100644 index 0000000..846e9bf --- /dev/null +++ b/dist/index.umd.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["/**\r\n * Enum defining possible request types for geocoding.\r\n */\r\nexport enum RequestType {\r\n ADDRESS = \"address\", // Geocoding by address\r\n LATLNG = \"latlng\", // Geocoding by latitude and longitude\r\n PLACE_ID = \"place_id\", // Geocoding by place ID\r\n}\r\n\r\n/**\r\n * Enum defining possible output formats for geocoding.\r\n */\r\nexport enum OutputFormat {\r\n XML = \"xml\", // Output format XML\r\n JSON = \"json\", // Output format JSON\r\n}\r\n\r\n/**\r\n * The URL of the Google Geocoding API.\r\n */\r\nconst GOOGLE_GEOCODE_API = \"https://maps.googleapis.com/maps/api/geocode\";\r\n\r\n/**\r\n * Options that can be passed to the geocoding requests.\r\n */\r\nexport interface GeocodeOptions {\r\n key?: string; // API key for the Google Maps Geocoding API.\r\n language?: string; // Language code for the response.\r\n region?: string; // Region code for the response.\r\n components?: string; // Component filtering for the response.\r\n bounds?: string; // Bounding box for the response.\r\n result_type?: string; // Result type filtering for the response.\r\n location_type?: string; // Location type filtering for the response.\r\n outputFormat: OutputFormat; // Desired output format (either XML or JSON)\r\n enable_address_descriptor?: boolean; // Whether to include an address descriptor in the reverse geocoding response.\r\n}\r\n\r\n/**\r\n * Response object from the geocoding API.\r\n */\r\ninterface GeocodeResponse {\r\n status: string;\r\n results: GeocodeResult[];\r\n address_descriptor?: AddressDescriptor;\r\n plus_code?: PlusCode;\r\n error_message?: string;\r\n}\r\n\r\n/**\r\n * The query parameters for geocoding requests.\r\n */\r\ninterface GeocodeQueryParams extends GeocodeOptions {\r\n place_id?: string; // The plce id to geocode\r\n address?: string; // The address to geocode\r\n latlng?: string; // The latitude/longitude of the location to geocode\r\n}\r\n\r\n/**\r\n * Default options for the geocoding requests.\r\n */\r\nlet defaultOptions: GeocodeOptions = {\r\n outputFormat: OutputFormat.JSON,\r\n};\r\n\r\n/**\r\n * Performs a geocoding request to the Google Geocoding API.\r\n * @function geocodeRequest\r\n * @async\r\n * @param {GeocodeQueryParams} queryParams - The query parameters for the geocoding request.\r\n * @returns {Promise} - A promise that resolves with the geocoding response object.\r\n * @throws {Error} - Throws an error if the geocoding request fails.\r\n */\r\nasync function geocodeRequest(\r\n queryParams: GeocodeQueryParams\r\n): Promise {\r\n const { outputFormat, ...restParams } = queryParams;\r\n const queryString = new URLSearchParams(\r\n restParams as Record\r\n ).toString();\r\n const url = `${GOOGLE_GEOCODE_API}/${outputFormat}?${queryString}`;\r\n try {\r\n const response = await fetch(url);\r\n const json = await response.json();\r\n const { status, error_message } = json;\r\n\r\n if (status === \"OK\") {\r\n return json;\r\n }\r\n\r\n throw new Error(\r\n `Geocoding failed: ${error_message}. Server returned status code ${status}.`\r\n );\r\n } catch (error: unknown) {\r\n if (error instanceof Error) {\r\n throw new Error(`Geocoding request failed: ${error.message}`);\r\n }\r\n throw new Error(`Geocoding request failed with unknown error: ${error}`);\r\n }\r\n}\r\n\r\n/**\r\n * Sets default options for geocoding requests.\r\n *\r\n * @param options - The default options to set.\r\n */\r\nexport function setDefaults(options: GeocodeOptions): void {\r\n defaultOptions = {\r\n ...defaultOptions,\r\n ...options,\r\n };\r\n}\r\n\r\n/**\r\n * Sets the API key to use for geocoding requests.\r\n *\r\n * @param key - The API key to set.\r\n */\r\nexport function setKey(key: string): void {\r\n defaultOptions.key = key;\r\n}\r\n\r\n/**\r\n * Sets the language to use for geocoding requests.\r\n *\r\n * @param language - The language to set.\r\n */\r\nexport function setLanguage(language: string): void {\r\n defaultOptions.language = language;\r\n}\r\n\r\n/**\r\n * Sets the region code to use for geocoding requests.\r\n *\r\n * @param region - The region code to set.\r\n */\r\nexport function setRegion(region: string): void {\r\n defaultOptions.region = region;\r\n}\r\n\r\n/**\r\n * Sets the component filter to use for geocoding requests.\r\n *\r\n * @param components - The component filter to set.\r\n */\r\nexport function setComponents(components: string): void {\r\n defaultOptions.components = components;\r\n}\r\n\r\n/**\r\n * Sets the bounding box to use for geocoding requests.\r\n *\r\n * @param bounds - The bounding box to set.\r\n */\r\nexport function setBounds(bounds: string): void {\r\n defaultOptions.bounds = bounds;\r\n}\r\n\r\n/**\r\n * Sets the result type filter to use for geocoding requests.\r\n * One or more address types to return, separated by a pipe (|).\r\n * Possible values are \"street_address\", \"route\", \"intersection\", \"political\", \"country\",\r\n * \"administrative_area_level_1\", \"administrative_area_level_2\", \"administrative_area_level_3\",\r\n * \"administrative_area_level_4\", \"administrative_area_level_5\", \"colloquial_area\", \"locality\",\r\n * \"ward\", \"sublocality\", \"neighborhood\", \"premise\", \"subpremise\", \"postal_code\", \"natural_feature\",\r\n * \"airport\", \"park\", \"point_of_interest\", and \"postal_code_prefix\".\r\n *\r\n * @param resultType - The result type to set.\r\n */\r\nexport function setResultType(resultType: string): void {\r\n defaultOptions.result_type = resultType;\r\n}\r\n\r\n/**\r\n * Sets the location type filter to use for geocoding requests.\r\n * One or more location types to return. Possible values are \"ROOFTOP\",\r\n * \"RANGE_INTERPOLATED\", \"GEOMETRIC_CENTER\", \"APPROXIMATE\".\r\n *\r\n * @param locationType - The location type to set.\r\n */\r\nexport function setLocationType(locationType: string): void {\r\n defaultOptions.location_type = locationType;\r\n}\r\n\r\n/**\r\n * Sets the desired output format for geocoding requests. The format can be either XML or JSON.\r\n *\r\n * @param outputFormat - The desired output format (either OutputFormat.XML or OutputFormat.JSON).\r\n */\r\nexport function setOutputFormat(outputFormat: OutputFormat): void {\r\n defaultOptions.outputFormat = outputFormat;\r\n}\r\n\r\n/**\r\n * Sets whether to include an address descriptor in the reverse geocoding response.\r\n *\r\n * @param enableAddressDescriptor - A boolean parameter indicating whether to include the address descriptor.\r\n */\r\nexport function enableAddressDescriptor(\r\n enableAddressDescriptor: boolean\r\n): void {\r\n defaultOptions.enable_address_descriptor = enableAddressDescriptor;\r\n}\r\n\r\n/**\r\n * Sends a geocoding request to the Google Maps Geocoding API for a given address and returns the response.\r\n * @function geocode\r\n * @async\r\n * @param {RequestType} requestType - Identifier to specify the type of request (place_id, address, or latlng).\r\n * @param {string} value - The value to be used for geocoding (address, place_id, or latlng).\r\n * @param {GeocodeOptions} [options={}] - Additional options for the geocoding request.\r\n * @returns {Promise} - A promise that resolves with the geocoding response object.\r\n * @throws {Error} - Throws an error if the address is invalid or the geocoding request fails.\r\n */\r\nexport function geocode(\r\n requestType: RequestType | string,\r\n value: string,\r\n options?: GeocodeOptions\r\n): Promise {\r\n if (typeof requestType !== \"string\" || typeof value !== \"string\") {\r\n throw new Error(\r\n `Both requestType and value are required and must be of type string. \r\n requestType: ${typeof requestType}, value: ${typeof value}`\r\n );\r\n }\r\n\r\n const queryParams: GeocodeQueryParams = {\r\n ...defaultOptions,\r\n ...options,\r\n [requestType]: value,\r\n };\r\n return geocodeRequest(queryParams);\r\n}\r\n\r\n/**\r\n * @deprecated Use `geocode` instead.\r\n * Usage: geocode(\"address\", \"Washington\", *options)\r\n */\r\nexport function fromAddress(\r\n address: string,\r\n key?: string,\r\n language?: string,\r\n region?: string\r\n) {\r\n const options: GeocodeOptions = {\r\n outputFormat: OutputFormat.JSON,\r\n };\r\n if (key) {\r\n options.key = key;\r\n }\r\n if (language) {\r\n options.language = language;\r\n }\r\n if (region) {\r\n options.region = region;\r\n }\r\n return geocode(RequestType.ADDRESS, address, options);\r\n}\r\n\r\n/**\r\n * @deprecated use `geocode` instead\r\n * Usage: geocode(\"place_id\", \"ChIJd8BlQ2BZwokRAFUEcm_qrcA\", *options)\r\n */\r\nexport function fromPlaceId(\r\n placeId: string,\r\n key?: string,\r\n language?: string,\r\n region?: string\r\n) {\r\n const options: GeocodeOptions = {\r\n outputFormat: OutputFormat.JSON,\r\n };\r\n if (key) {\r\n options.key = key;\r\n }\r\n if (language) {\r\n options.language = language;\r\n }\r\n if (region) {\r\n options.region = region;\r\n }\r\n return geocode(RequestType.PLACE_ID, placeId, options);\r\n}\r\n\r\n/**\r\n * @deprecated use `geocode` instead\r\n * Usage: geocode(\"latlng\", \"40.714224,-73.961452\", *options)\r\n */\r\nexport function fromLatLng(\r\n lat: number,\r\n lng: number,\r\n key?: string,\r\n language?: string,\r\n region?: string,\r\n location_type?: string\r\n) {\r\n const options: GeocodeOptions = {\r\n outputFormat: OutputFormat.JSON,\r\n };\r\n if (key) {\r\n options.key = key;\r\n }\r\n if (language) {\r\n options.language = language;\r\n }\r\n if (region) {\r\n options.region = region;\r\n }\r\n if (location_type) {\r\n options.location_type = location_type;\r\n }\r\n return geocode(RequestType.LATLNG, `${lat},${lng}`, options);\r\n}\r\n\r\ninterface GeocodeResult {\r\n address_components: AddressComponent[];\r\n formatted_address: string;\r\n geometry: Geometry;\r\n place_id: string;\r\n plus_code: PlusCode;\r\n types: string[];\r\n}\r\n\r\ninterface AddressComponent {\r\n long_name: string;\r\n short_name: string;\r\n types: string[];\r\n}\r\n\r\ninterface Geometry {\r\n location: {\r\n lat: number;\r\n lng: number;\r\n };\r\n location_type: string;\r\n viewport: {\r\n lat: number;\r\n lng: number;\r\n };\r\n southwest: {\r\n lat: number;\r\n lng: number;\r\n };\r\n}\r\n\r\ninterface AddressDescriptor {\r\n area: AreaDescriptor[];\r\n landmarks: Landmark[];\r\n}\r\n\r\ninterface AreaDescriptor {\r\n containment: string;\r\n display_name: {\r\n language_code: string;\r\n text: string;\r\n };\r\n place_id: string;\r\n}\r\n\r\ninterface Landmark {\r\n display_name: {\r\n language_code: string;\r\n text: string;\r\n };\r\n straight_line_distance_meters: number;\r\n place_id: string;\r\n travel_distance_meters: number;\r\n spatial_relationship: string;\r\n types: string[];\r\n}\r\n\r\ninterface PlusCode {\r\n compound_code: string;\r\n global_code: string;\r\n}\r\n"],"names":["RequestType","OutputFormat","GOOGLE_GEOCODE_API","defaultOptions","geocodeRequest","queryParams","outputFormat","restParams","queryString","url","json","status","error_message","error","setDefaults","options","setKey","key","setLanguage","language","setRegion","region","setComponents","components","setBounds","bounds","setResultType","resultType","setLocationType","locationType","setOutputFormat","enableAddressDescriptor","geocode","requestType","value","fromAddress","address","fromPlaceId","placeId","fromLatLng","lat","lng","location_type"],"mappings":"wOAGY,IAAAA,GAAAA,IACVA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,SAAW,WAHDA,IAAAA,GAAA,CAAA,CAAA,EASAC,GAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,KAAO,OAFGA,IAAAA,GAAA,CAAA,CAAA,EAQZ,MAAMC,EAAqB,+CAwC3B,IAAIC,EAAiC,CACnC,aAAc,MAChB,EAUA,eAAeC,EACbC,EAC0B,CAC1B,KAAM,CAAE,aAAAC,EAAc,GAAGC,CAAA,EAAeF,EAClCG,EAAc,IAAI,gBACtBD,GACA,SAAS,EACLE,EAAM,GAAGP,CAAkB,IAAII,CAAY,IAAIE,CAAW,GAC5D,GAAA,CAEI,MAAAE,EAAO,MADI,MAAM,MAAMD,CAAG,GACJ,OACtB,CAAE,OAAAE,EAAQ,cAAAC,CAAkB,EAAAF,EAElC,GAAIC,IAAW,KACN,OAAAD,EAGT,MAAM,IAAI,MACR,qBAAqBE,CAAa,iCAAiCD,CAAM,GAAA,QAEpEE,EAAgB,CACvB,MAAIA,aAAiB,MACb,IAAI,MAAM,6BAA6BA,EAAM,OAAO,EAAE,EAExD,IAAI,MAAM,gDAAgDA,CAAK,EAAE,CACzE,CACF,CAOO,SAASC,EAAYC,EAA+B,CACxCZ,EAAA,CACf,GAAGA,EACH,GAAGY,CAAA,CAEP,CAOO,SAASC,EAAOC,EAAmB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EACA,CACA,MAAM3B,EAA0B,CAC9B,aAAc,MAAA,EAEhB,OAAIE,IACFF,EAAQ,IAAME,GAEZE,IACFJ,EAAQ,SAAWI,GAEjBE,IACFN,EAAQ,OAASM,GAEfqB,IACF3B,EAAQ,cAAgB2B,GAEnBV,EAAQ,SAAoB,GAAGQ,CAAG,IAAIC,CAAG,GAAI1B,CAAO,CAC7D"} \ No newline at end of file diff --git a/package.json b/package.json index aa77c4c..87dc237 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-geocode", - "version": "1.0.0-alpha.1", + "version": "1.0.0", "description": "A module to transform a description of a location (i.e. street address, town name, etc.) into geographic coordinates (i.e. latitude and longitude) and vice versa.", "main": "dist/index.js", "types": "types/index.d.ts", @@ -22,11 +22,12 @@ }, "homepage": "https://github.com/shukerullah/react-geocode#readme", "scripts": { - "build": "tsc && uglifyjs --compress --mangle --output ./dist/index.js -- ./dist/index.js" + "build": "vite build" }, "devDependencies": { "@types/node": "^20.6.2", - "typescript": "^4.9.5", - "uglify-js": "^3.17.4" + "typescript": "^5.6.3", + "vite": "^5.4.9", + "vite-plugin-dts": "^4.2.4" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f281975..b089b39 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,38 +12,1184 @@ importers: specifier: ^20.6.2 version: 20.16.11 typescript: - specifier: ^4.9.5 - version: 4.9.5 - uglify-js: - specifier: ^3.17.4 - version: 3.19.3 + specifier: ^5.6.3 + version: 5.6.3 + vite: + specifier: ^5.4.9 + version: 5.4.9(@types/node@20.16.11) + vite-plugin-dts: + specifier: ^4.2.4 + version: 4.2.4(@types/node@20.16.11)(rollup@4.24.0)(typescript@5.6.3)(vite@5.4.9(@types/node@20.16.11)) packages: + '@babel/helper-string-parser@7.25.7': + resolution: {integrity: sha512-CbkjYdsJNHFk8uqpEkpCvRs3YRp9tY6FmFY7wLMSYuGYkrdUi7r2lc4/wqsvlHoMznX3WJ9IP8giGPq68T/Y6g==} + engines: {node: '>=6.9.0'} + + '@babel/helper-validator-identifier@7.25.7': + resolution: {integrity: sha512-AM6TzwYqGChO45oiuPqwL2t20/HdMC1rTPAesnBCgPCSF1x3oN9MVUwQV2iyz4xqWrctwK5RNC8LV22kaQCNYg==} + engines: {node: '>=6.9.0'} + + '@babel/parser@7.25.8': + resolution: {integrity: sha512-HcttkxzdPucv3nNFmfOOMfFf64KgdJVqm1KaCm25dPGMLElo9nsLvXeJECQg8UzPuBGLyTSA0ZzqCtDSzKTEoQ==} + engines: {node: '>=6.0.0'} + hasBin: true + + '@babel/types@7.25.8': + resolution: {integrity: sha512-JWtuCu8VQsMladxVz/P4HzHUGCAwpuqacmowgXFs5XjxIgKuNjnLokQzuVjlTvIzODaDmpjT3oxcC48vyk9EWg==} + engines: {node: '>=6.9.0'} + + '@esbuild/aix-ppc64@0.21.5': + resolution: {integrity: sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [aix] + + '@esbuild/android-arm64@0.21.5': + resolution: {integrity: sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + + '@esbuild/android-arm@0.21.5': + resolution: {integrity: sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + + '@esbuild/android-x64@0.21.5': + resolution: {integrity: sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + + '@esbuild/darwin-arm64@0.21.5': + resolution: {integrity: sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + + '@esbuild/darwin-x64@0.21.5': + resolution: {integrity: sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + + '@esbuild/freebsd-arm64@0.21.5': + resolution: {integrity: sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + + '@esbuild/freebsd-x64@0.21.5': + resolution: {integrity: sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + + '@esbuild/linux-arm64@0.21.5': + resolution: {integrity: sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + + '@esbuild/linux-arm@0.21.5': + resolution: {integrity: sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + + '@esbuild/linux-ia32@0.21.5': + resolution: {integrity: sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + + '@esbuild/linux-loong64@0.21.5': + resolution: {integrity: sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + + '@esbuild/linux-mips64el@0.21.5': + resolution: {integrity: sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + + '@esbuild/linux-ppc64@0.21.5': + resolution: {integrity: sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + + '@esbuild/linux-riscv64@0.21.5': + resolution: {integrity: sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + + '@esbuild/linux-s390x@0.21.5': + resolution: {integrity: sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + + '@esbuild/linux-x64@0.21.5': + resolution: {integrity: sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + + '@esbuild/netbsd-x64@0.21.5': + resolution: {integrity: sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + + '@esbuild/openbsd-x64@0.21.5': + resolution: {integrity: sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + + '@esbuild/sunos-x64@0.21.5': + resolution: {integrity: sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + + '@esbuild/win32-arm64@0.21.5': + resolution: {integrity: sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + + '@esbuild/win32-ia32@0.21.5': + resolution: {integrity: sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + + '@esbuild/win32-x64@0.21.5': + resolution: {integrity: sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + + '@jridgewell/sourcemap-codec@1.5.0': + resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} + + '@microsoft/api-extractor-model@7.29.6': + resolution: {integrity: sha512-gC0KGtrZvxzf/Rt9oMYD2dHvtN/1KPEYsrQPyMKhLHnlVuO/f4AFN3E4toqZzD2pt4LhkKoYmL2H9tX3yCOyRw==} + + '@microsoft/api-extractor@7.47.7': + resolution: {integrity: sha512-fNiD3G55ZJGhPOBPMKD/enozj8yxJSYyVJWxRWdcUtw842rvthDHJgUWq9gXQTensFlMHv2wGuCjjivPv53j0A==} + hasBin: true + + '@microsoft/tsdoc-config@0.17.0': + resolution: {integrity: sha512-v/EYRXnCAIHxOHW+Plb6OWuUoMotxTN0GLatnpOb1xq0KuTNw/WI3pamJx/UbsoJP5k9MCw1QxvvhPcF9pH3Zg==} + + '@microsoft/tsdoc@0.15.0': + resolution: {integrity: sha512-HZpPoABogPvjeJOdzCOSJsXeL/SMCBgBZMVC3X3d7YYp2gf31MfxhUoYUNwf1ERPJOnQc0wkFn9trqI6ZEdZuA==} + + '@rollup/pluginutils@5.1.2': + resolution: {integrity: sha512-/FIdS3PyZ39bjZlwqFnWqCOVnW7o963LtKMwQOD0NhQqw22gSr2YY1afu3FxRip4ZCZNsD5jq6Aaz6QV3D/Njw==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 + peerDependenciesMeta: + rollup: + optional: true + + '@rollup/rollup-android-arm-eabi@4.24.0': + resolution: {integrity: sha512-Q6HJd7Y6xdB48x8ZNVDOqsbh2uByBhgK8PiQgPhwkIw/HC/YX5Ghq2mQY5sRMZWHb3VsFkWooUVOZHKr7DmDIA==} + cpu: [arm] + os: [android] + + '@rollup/rollup-android-arm64@4.24.0': + resolution: {integrity: sha512-ijLnS1qFId8xhKjT81uBHuuJp2lU4x2yxa4ctFPtG+MqEE6+C5f/+X/bStmxapgmwLwiL3ih122xv8kVARNAZA==} + cpu: [arm64] + os: [android] + + '@rollup/rollup-darwin-arm64@4.24.0': + resolution: {integrity: sha512-bIv+X9xeSs1XCk6DVvkO+S/z8/2AMt/2lMqdQbMrmVpgFvXlmde9mLcbQpztXm1tajC3raFDqegsH18HQPMYtA==} + cpu: [arm64] + os: [darwin] + + '@rollup/rollup-darwin-x64@4.24.0': + resolution: {integrity: sha512-X6/nOwoFN7RT2svEQWUsW/5C/fYMBe4fnLK9DQk4SX4mgVBiTA9h64kjUYPvGQ0F/9xwJ5U5UfTbl6BEjaQdBQ==} + cpu: [x64] + os: [darwin] + + '@rollup/rollup-linux-arm-gnueabihf@4.24.0': + resolution: {integrity: sha512-0KXvIJQMOImLCVCz9uvvdPgfyWo93aHHp8ui3FrtOP57svqrF/roSSR5pjqL2hcMp0ljeGlU4q9o/rQaAQ3AYA==} + cpu: [arm] + os: [linux] + + '@rollup/rollup-linux-arm-musleabihf@4.24.0': + resolution: {integrity: sha512-it2BW6kKFVh8xk/BnHfakEeoLPv8STIISekpoF+nBgWM4d55CZKc7T4Dx1pEbTnYm/xEKMgy1MNtYuoA8RFIWw==} + cpu: [arm] + os: [linux] + + '@rollup/rollup-linux-arm64-gnu@4.24.0': + resolution: {integrity: sha512-i0xTLXjqap2eRfulFVlSnM5dEbTVque/3Pi4g2y7cxrs7+a9De42z4XxKLYJ7+OhE3IgxvfQM7vQc43bwTgPwA==} + cpu: [arm64] + os: [linux] + + '@rollup/rollup-linux-arm64-musl@4.24.0': + resolution: {integrity: sha512-9E6MKUJhDuDh604Qco5yP/3qn3y7SLXYuiC0Rpr89aMScS2UAmK1wHP2b7KAa1nSjWJc/f/Lc0Wl1L47qjiyQw==} + cpu: [arm64] + os: [linux] + + '@rollup/rollup-linux-powerpc64le-gnu@4.24.0': + resolution: {integrity: sha512-2XFFPJ2XMEiF5Zi2EBf4h73oR1V/lycirxZxHZNc93SqDN/IWhYYSYj8I9381ikUFXZrz2v7r2tOVk2NBwxrWw==} + cpu: [ppc64] + os: [linux] + + '@rollup/rollup-linux-riscv64-gnu@4.24.0': + resolution: {integrity: sha512-M3Dg4hlwuntUCdzU7KjYqbbd+BLq3JMAOhCKdBE3TcMGMZbKkDdJ5ivNdehOssMCIokNHFOsv7DO4rlEOfyKpg==} + cpu: [riscv64] + os: [linux] + + '@rollup/rollup-linux-s390x-gnu@4.24.0': + resolution: {integrity: sha512-mjBaoo4ocxJppTorZVKWFpy1bfFj9FeCMJqzlMQGjpNPY9JwQi7OuS1axzNIk0nMX6jSgy6ZURDZ2w0QW6D56g==} + cpu: [s390x] + os: [linux] + + '@rollup/rollup-linux-x64-gnu@4.24.0': + resolution: {integrity: sha512-ZXFk7M72R0YYFN5q13niV0B7G8/5dcQ9JDp8keJSfr3GoZeXEoMHP/HlvqROA3OMbMdfr19IjCeNAnPUG93b6A==} + cpu: [x64] + os: [linux] + + '@rollup/rollup-linux-x64-musl@4.24.0': + resolution: {integrity: sha512-w1i+L7kAXZNdYl+vFvzSZy8Y1arS7vMgIy8wusXJzRrPyof5LAb02KGr1PD2EkRcl73kHulIID0M501lN+vobQ==} + cpu: [x64] + os: [linux] + + '@rollup/rollup-win32-arm64-msvc@4.24.0': + resolution: {integrity: sha512-VXBrnPWgBpVDCVY6XF3LEW0pOU51KbaHhccHw6AS6vBWIC60eqsH19DAeeObl+g8nKAz04QFdl/Cefta0xQtUQ==} + cpu: [arm64] + os: [win32] + + '@rollup/rollup-win32-ia32-msvc@4.24.0': + resolution: {integrity: sha512-xrNcGDU0OxVcPTH/8n/ShH4UevZxKIO6HJFK0e15XItZP2UcaiLFd5kiX7hJnqCbSztUF8Qot+JWBC/QXRPYWQ==} + cpu: [ia32] + os: [win32] + + '@rollup/rollup-win32-x64-msvc@4.24.0': + resolution: {integrity: sha512-fbMkAF7fufku0N2dE5TBXcNlg0pt0cJue4xBRE2Qc5Vqikxr4VCgKj/ht6SMdFcOacVA9rqF70APJ8RN/4vMJw==} + cpu: [x64] + os: [win32] + + '@rushstack/node-core-library@5.7.0': + resolution: {integrity: sha512-Ff9Cz/YlWu9ce4dmqNBZpA45AEya04XaBFIjV7xTVeEf+y/kTjEasmozqFELXlNG4ROdevss75JrrZ5WgufDkQ==} + peerDependencies: + '@types/node': '*' + peerDependenciesMeta: + '@types/node': + optional: true + + '@rushstack/rig-package@0.5.3': + resolution: {integrity: sha512-olzSSjYrvCNxUFZowevC3uz8gvKr3WTpHQ7BkpjtRpA3wK+T0ybep/SRUMfr195gBzJm5gaXw0ZMgjIyHqJUow==} + + '@rushstack/terminal@0.14.0': + resolution: {integrity: sha512-juTKMAMpTIJKudeFkG5slD8Z/LHwNwGZLtU441l/u82XdTBfsP+LbGKJLCNwP5se+DMCT55GB8x9p6+C4UL7jw==} + peerDependencies: + '@types/node': '*' + peerDependenciesMeta: + '@types/node': + optional: true + + '@rushstack/ts-command-line@4.22.6': + resolution: {integrity: sha512-QSRqHT/IfoC5nk9zn6+fgyqOPXHME0BfchII9EUPR19pocsNp/xSbeBCbD3PIR2Lg+Q5qk7OFqk1VhWPMdKHJg==} + + '@types/argparse@1.0.38': + resolution: {integrity: sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==} + + '@types/estree@1.0.6': + resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==} + '@types/node@20.16.11': resolution: {integrity: sha512-y+cTCACu92FyA5fgQSAI8A1H429g7aSK2HsO7K4XYUWc4dY5IUz55JSDIYT6/VsOLfGy8vmvQYC2hfb0iF16Uw==} - typescript@4.9.5: - resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} - engines: {node: '>=4.2.0'} + '@volar/language-core@2.4.6': + resolution: {integrity: sha512-FxUfxaB8sCqvY46YjyAAV6c3mMIq/NWQMVvJ+uS4yxr1KzOvyg61gAuOnNvgCvO4TZ7HcLExBEsWcDu4+K4E8A==} + + '@volar/source-map@2.4.6': + resolution: {integrity: sha512-Nsh7UW2ruK+uURIPzjJgF0YRGP5CX9nQHypA2OMqdM2FKy7rh+uv3XgPnWPw30JADbKvZ5HuBzG4gSbVDYVtiw==} + + '@volar/typescript@2.4.6': + resolution: {integrity: sha512-NMIrA7y5OOqddL9VtngPWYmdQU03htNKFtAYidbYfWA0TOhyGVd9tfcP4TsLWQ+RBWDZCbBqsr8xzU0ZOxYTCQ==} + + '@vue/compiler-core@3.5.12': + resolution: {integrity: sha512-ISyBTRMmMYagUxhcpyEH0hpXRd/KqDU4ymofPgl2XAkY9ZhQ+h0ovEZJIiPop13UmR/54oA2cgMDjgroRelaEw==} + + '@vue/compiler-dom@3.5.12': + resolution: {integrity: sha512-9G6PbJ03uwxLHKQ3P42cMTi85lDRvGLB2rSGOiQqtXELat6uI4n8cNz9yjfVHRPIu+MsK6TE418Giruvgptckg==} + + '@vue/compiler-vue2@2.7.16': + resolution: {integrity: sha512-qYC3Psj9S/mfu9uVi5WvNZIzq+xnXMhOwbTFKKDD7b1lhpnn71jXSFdTQ+WsIEk0ONCd7VV2IMm7ONl6tbQ86A==} + + '@vue/language-core@2.1.6': + resolution: {integrity: sha512-MW569cSky9R/ooKMh6xa2g1D0AtRKbL56k83dzus/bx//RDJk24RHWkMzbAlXjMdDNyxAaagKPRquBIxkxlCkg==} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + + '@vue/shared@3.5.12': + resolution: {integrity: sha512-L2RPSAwUFbgZH20etwrXyVyCBu9OxRSi8T/38QsvnkJyvq2LufW2lDCOzm7t/U9C1mkhJGWYfCuFBCmIuNivrg==} + + acorn@8.13.0: + resolution: {integrity: sha512-8zSiw54Oxrdym50NlZ9sUusyO1Z1ZchgRLWRaK6c86XJFClyCgFKetdowBg5bKxyp/u+CDBJG4Mpp0m3HLZl9w==} + engines: {node: '>=0.4.0'} hasBin: true - uglify-js@3.19.3: - resolution: {integrity: sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==} - engines: {node: '>=0.8.0'} + ajv-draft-04@1.0.0: + resolution: {integrity: sha512-mv00Te6nmYbRp5DCwclxtt7yV/joXJPGS7nM+97GdxvuttCOfgI3K4U25zboyeX0O+myI8ERluxQe5wljMmVIw==} + peerDependencies: + ajv: ^8.5.0 + peerDependenciesMeta: + ajv: + optional: true + + ajv-formats@3.0.1: + resolution: {integrity: sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==} + peerDependencies: + ajv: ^8.0.0 + peerDependenciesMeta: + ajv: + optional: true + + ajv@8.12.0: + resolution: {integrity: sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==} + + ajv@8.13.0: + resolution: {integrity: sha512-PRA911Blj99jR5RMeTunVbNXMF6Lp4vZXnk5GQjcnUWUTsrXtekg/pnmFFI2u/I36Y/2bITGS30GZCXei6uNkA==} + + argparse@1.0.10: + resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} + + balanced-match@1.0.2: + resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + + brace-expansion@1.1.11: + resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} + + brace-expansion@2.0.1: + resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} + + compare-versions@6.1.1: + resolution: {integrity: sha512-4hm4VPpIecmlg59CHXnRDnqGplJFrbLG4aFEl5vl6cK1u76ws3LLvX7ikFnTDl5vo39sjWD6AaDPYodJp/NNHg==} + + computeds@0.0.1: + resolution: {integrity: sha512-7CEBgcMjVmitjYo5q8JTJVra6X5mQ20uTThdK+0kR7UEaDrAWEQcRiBtWJzga4eRpP6afNwwLsX2SET2JhVB1Q==} + + concat-map@0.0.1: + resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + + confbox@0.1.8: + resolution: {integrity: sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==} + + de-indent@1.0.2: + resolution: {integrity: sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==} + + debug@4.3.7: + resolution: {integrity: sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + + entities@4.5.0: + resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} + engines: {node: '>=0.12'} + + esbuild@0.21.5: + resolution: {integrity: sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==} + engines: {node: '>=12'} + hasBin: true + + estree-walker@2.0.2: + resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} + + fast-deep-equal@3.1.3: + resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + + fs-extra@7.0.1: + resolution: {integrity: sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==} + engines: {node: '>=6 <7 || >=8'} + + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + + function-bind@1.1.2: + resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} + + graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + + has-flag@4.0.0: + resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} + engines: {node: '>=8'} + + hasown@2.0.2: + resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} + engines: {node: '>= 0.4'} + + he@1.2.0: + resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==} + hasBin: true + + import-lazy@4.0.0: + resolution: {integrity: sha512-rKtvo6a868b5Hu3heneU+L4yEQ4jYKLtjpnPeUdK7h0yzXGmyBTypknlkCvHFBqfX9YlorEiMM6Dnq/5atfHkw==} + engines: {node: '>=8'} + + is-core-module@2.15.1: + resolution: {integrity: sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==} + engines: {node: '>= 0.4'} + + jju@1.4.0: + resolution: {integrity: sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==} + + json-schema-traverse@1.0.0: + resolution: {integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==} + + jsonfile@4.0.0: + resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} + + kolorist@1.8.0: + resolution: {integrity: sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==} + + local-pkg@0.5.0: + resolution: {integrity: sha512-ok6z3qlYyCDS4ZEU27HaU6x/xZa9Whf8jD4ptH5UZTQYZVYeb9bnZ3ojVhiJNLiXK1Hfc0GNbLXcmZ5plLDDBg==} + engines: {node: '>=14'} + + lodash@4.17.21: + resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} + + lru-cache@6.0.0: + resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} + engines: {node: '>=10'} + + magic-string@0.30.12: + resolution: {integrity: sha512-Ea8I3sQMVXr8JhN4z+H/d8zwo+tYDgHE9+5G4Wnrwhs0gaK9fXTKx0Tw5Xwsd/bCPTTZNRAdpyzvoeORe9LYpw==} + + minimatch@3.0.8: + resolution: {integrity: sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==} + + minimatch@9.0.5: + resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} + engines: {node: '>=16 || 14 >=14.17'} + + mlly@1.7.2: + resolution: {integrity: sha512-tN3dvVHYVz4DhSXinXIk7u9syPYaJvio118uomkovAtWBT+RdbP6Lfh/5Lvo519YMmwBafwlh20IPTXIStscpA==} + + ms@2.1.3: + resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + + muggle-string@0.4.1: + resolution: {integrity: sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==} + + nanoid@3.3.7: + resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true + path-browserify@1.0.1: + resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==} + + path-parse@1.0.7: + resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} + + pathe@1.1.2: + resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} + + picocolors@1.1.0: + resolution: {integrity: sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==} + + picomatch@2.3.1: + resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} + engines: {node: '>=8.6'} + + pkg-types@1.2.1: + resolution: {integrity: sha512-sQoqa8alT3nHjGuTjuKgOnvjo4cljkufdtLMnO2LBP/wRwuDlo1tkaEdMxCRhyGRPacv/ztlZgDPm2b7FAmEvw==} + + postcss@8.4.47: + resolution: {integrity: sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==} + engines: {node: ^10 || ^12 || >=14} + + punycode@2.3.1: + resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} + engines: {node: '>=6'} + + require-from-string@2.0.2: + resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} + engines: {node: '>=0.10.0'} + + resolve@1.22.8: + resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==} + hasBin: true + + rollup@4.24.0: + resolution: {integrity: sha512-DOmrlGSXNk1DM0ljiQA+i+o0rSLhtii1je5wgk60j49d1jHT5YYttBv1iWOnYSTG+fZZESUOSNiAl89SIet+Cg==} + engines: {node: '>=18.0.0', npm: '>=8.0.0'} + hasBin: true + + semver@7.5.4: + resolution: {integrity: sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==} + engines: {node: '>=10'} + hasBin: true + + source-map-js@1.2.1: + resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} + engines: {node: '>=0.10.0'} + + source-map@0.6.1: + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + engines: {node: '>=0.10.0'} + + sprintf-js@1.0.3: + resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} + + string-argv@0.3.2: + resolution: {integrity: sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==} + engines: {node: '>=0.6.19'} + + strip-json-comments@3.1.1: + resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} + engines: {node: '>=8'} + + supports-color@8.1.1: + resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==} + engines: {node: '>=10'} + + supports-preserve-symlinks-flag@1.0.0: + resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} + engines: {node: '>= 0.4'} + + to-fast-properties@2.0.0: + resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==} + engines: {node: '>=4'} + + typescript@5.4.2: + resolution: {integrity: sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==} + engines: {node: '>=14.17'} + hasBin: true + + typescript@5.6.3: + resolution: {integrity: sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==} + engines: {node: '>=14.17'} + hasBin: true + + ufo@1.5.4: + resolution: {integrity: sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==} + undici-types@6.19.8: resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==} + universalify@0.1.2: + resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} + engines: {node: '>= 4.0.0'} + + uri-js@4.4.1: + resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} + + vite-plugin-dts@4.2.4: + resolution: {integrity: sha512-REcYoxO90Pi8c0P1J7XAa/nVwNVGkX2eYkBEIfFSfcKE4g1W8sB0R23a7SU3aLEMfdOdb0SVHq3JlJ+Qb6gjgA==} + engines: {node: ^14.18.0 || >=16.0.0} + peerDependencies: + typescript: '*' + vite: '*' + peerDependenciesMeta: + vite: + optional: true + + vite@5.4.9: + resolution: {integrity: sha512-20OVpJHh0PAM0oSOELa5GaZNWeDjcAvQjGXy2Uyr+Tp+/D2/Hdz6NLgpJLsarPTA2QJ6v8mX2P1ZfbsSKvdMkg==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@types/node': ^18.0.0 || >=20.0.0 + less: '*' + lightningcss: ^1.21.0 + sass: '*' + sass-embedded: '*' + stylus: '*' + sugarss: '*' + terser: ^5.4.0 + peerDependenciesMeta: + '@types/node': + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + sass-embedded: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + + vscode-uri@3.0.8: + resolution: {integrity: sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==} + + yallist@4.0.0: + resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} + snapshots: + '@babel/helper-string-parser@7.25.7': {} + + '@babel/helper-validator-identifier@7.25.7': {} + + '@babel/parser@7.25.8': + dependencies: + '@babel/types': 7.25.8 + + '@babel/types@7.25.8': + dependencies: + '@babel/helper-string-parser': 7.25.7 + '@babel/helper-validator-identifier': 7.25.7 + to-fast-properties: 2.0.0 + + '@esbuild/aix-ppc64@0.21.5': + optional: true + + '@esbuild/android-arm64@0.21.5': + optional: true + + '@esbuild/android-arm@0.21.5': + optional: true + + '@esbuild/android-x64@0.21.5': + optional: true + + '@esbuild/darwin-arm64@0.21.5': + optional: true + + '@esbuild/darwin-x64@0.21.5': + optional: true + + '@esbuild/freebsd-arm64@0.21.5': + optional: true + + '@esbuild/freebsd-x64@0.21.5': + optional: true + + '@esbuild/linux-arm64@0.21.5': + optional: true + + '@esbuild/linux-arm@0.21.5': + optional: true + + '@esbuild/linux-ia32@0.21.5': + optional: true + + '@esbuild/linux-loong64@0.21.5': + optional: true + + '@esbuild/linux-mips64el@0.21.5': + optional: true + + '@esbuild/linux-ppc64@0.21.5': + optional: true + + '@esbuild/linux-riscv64@0.21.5': + optional: true + + '@esbuild/linux-s390x@0.21.5': + optional: true + + '@esbuild/linux-x64@0.21.5': + optional: true + + '@esbuild/netbsd-x64@0.21.5': + optional: true + + '@esbuild/openbsd-x64@0.21.5': + optional: true + + '@esbuild/sunos-x64@0.21.5': + optional: true + + '@esbuild/win32-arm64@0.21.5': + optional: true + + '@esbuild/win32-ia32@0.21.5': + optional: true + + '@esbuild/win32-x64@0.21.5': + optional: true + + '@jridgewell/sourcemap-codec@1.5.0': {} + + '@microsoft/api-extractor-model@7.29.6(@types/node@20.16.11)': + dependencies: + '@microsoft/tsdoc': 0.15.0 + '@microsoft/tsdoc-config': 0.17.0 + '@rushstack/node-core-library': 5.7.0(@types/node@20.16.11) + transitivePeerDependencies: + - '@types/node' + + '@microsoft/api-extractor@7.47.7(@types/node@20.16.11)': + dependencies: + '@microsoft/api-extractor-model': 7.29.6(@types/node@20.16.11) + '@microsoft/tsdoc': 0.15.0 + '@microsoft/tsdoc-config': 0.17.0 + '@rushstack/node-core-library': 5.7.0(@types/node@20.16.11) + '@rushstack/rig-package': 0.5.3 + '@rushstack/terminal': 0.14.0(@types/node@20.16.11) + '@rushstack/ts-command-line': 4.22.6(@types/node@20.16.11) + lodash: 4.17.21 + minimatch: 3.0.8 + resolve: 1.22.8 + semver: 7.5.4 + source-map: 0.6.1 + typescript: 5.4.2 + transitivePeerDependencies: + - '@types/node' + + '@microsoft/tsdoc-config@0.17.0': + dependencies: + '@microsoft/tsdoc': 0.15.0 + ajv: 8.12.0 + jju: 1.4.0 + resolve: 1.22.8 + + '@microsoft/tsdoc@0.15.0': {} + + '@rollup/pluginutils@5.1.2(rollup@4.24.0)': + dependencies: + '@types/estree': 1.0.6 + estree-walker: 2.0.2 + picomatch: 2.3.1 + optionalDependencies: + rollup: 4.24.0 + + '@rollup/rollup-android-arm-eabi@4.24.0': + optional: true + + '@rollup/rollup-android-arm64@4.24.0': + optional: true + + '@rollup/rollup-darwin-arm64@4.24.0': + optional: true + + '@rollup/rollup-darwin-x64@4.24.0': + optional: true + + '@rollup/rollup-linux-arm-gnueabihf@4.24.0': + optional: true + + '@rollup/rollup-linux-arm-musleabihf@4.24.0': + optional: true + + '@rollup/rollup-linux-arm64-gnu@4.24.0': + optional: true + + '@rollup/rollup-linux-arm64-musl@4.24.0': + optional: true + + '@rollup/rollup-linux-powerpc64le-gnu@4.24.0': + optional: true + + '@rollup/rollup-linux-riscv64-gnu@4.24.0': + optional: true + + '@rollup/rollup-linux-s390x-gnu@4.24.0': + optional: true + + '@rollup/rollup-linux-x64-gnu@4.24.0': + optional: true + + '@rollup/rollup-linux-x64-musl@4.24.0': + optional: true + + '@rollup/rollup-win32-arm64-msvc@4.24.0': + optional: true + + '@rollup/rollup-win32-ia32-msvc@4.24.0': + optional: true + + '@rollup/rollup-win32-x64-msvc@4.24.0': + optional: true + + '@rushstack/node-core-library@5.7.0(@types/node@20.16.11)': + dependencies: + ajv: 8.13.0 + ajv-draft-04: 1.0.0(ajv@8.13.0) + ajv-formats: 3.0.1(ajv@8.13.0) + fs-extra: 7.0.1 + import-lazy: 4.0.0 + jju: 1.4.0 + resolve: 1.22.8 + semver: 7.5.4 + optionalDependencies: + '@types/node': 20.16.11 + + '@rushstack/rig-package@0.5.3': + dependencies: + resolve: 1.22.8 + strip-json-comments: 3.1.1 + + '@rushstack/terminal@0.14.0(@types/node@20.16.11)': + dependencies: + '@rushstack/node-core-library': 5.7.0(@types/node@20.16.11) + supports-color: 8.1.1 + optionalDependencies: + '@types/node': 20.16.11 + + '@rushstack/ts-command-line@4.22.6(@types/node@20.16.11)': + dependencies: + '@rushstack/terminal': 0.14.0(@types/node@20.16.11) + '@types/argparse': 1.0.38 + argparse: 1.0.10 + string-argv: 0.3.2 + transitivePeerDependencies: + - '@types/node' + + '@types/argparse@1.0.38': {} + + '@types/estree@1.0.6': {} + '@types/node@20.16.11': dependencies: undici-types: 6.19.8 - typescript@4.9.5: {} + '@volar/language-core@2.4.6': + dependencies: + '@volar/source-map': 2.4.6 + + '@volar/source-map@2.4.6': {} + + '@volar/typescript@2.4.6': + dependencies: + '@volar/language-core': 2.4.6 + path-browserify: 1.0.1 + vscode-uri: 3.0.8 + + '@vue/compiler-core@3.5.12': + dependencies: + '@babel/parser': 7.25.8 + '@vue/shared': 3.5.12 + entities: 4.5.0 + estree-walker: 2.0.2 + source-map-js: 1.2.1 + + '@vue/compiler-dom@3.5.12': + dependencies: + '@vue/compiler-core': 3.5.12 + '@vue/shared': 3.5.12 + + '@vue/compiler-vue2@2.7.16': + dependencies: + de-indent: 1.0.2 + he: 1.2.0 + + '@vue/language-core@2.1.6(typescript@5.6.3)': + dependencies: + '@volar/language-core': 2.4.6 + '@vue/compiler-dom': 3.5.12 + '@vue/compiler-vue2': 2.7.16 + '@vue/shared': 3.5.12 + computeds: 0.0.1 + minimatch: 9.0.5 + muggle-string: 0.4.1 + path-browserify: 1.0.1 + optionalDependencies: + typescript: 5.6.3 + + '@vue/shared@3.5.12': {} + + acorn@8.13.0: {} + + ajv-draft-04@1.0.0(ajv@8.13.0): + optionalDependencies: + ajv: 8.13.0 + + ajv-formats@3.0.1(ajv@8.13.0): + optionalDependencies: + ajv: 8.13.0 + + ajv@8.12.0: + dependencies: + fast-deep-equal: 3.1.3 + json-schema-traverse: 1.0.0 + require-from-string: 2.0.2 + uri-js: 4.4.1 + + ajv@8.13.0: + dependencies: + fast-deep-equal: 3.1.3 + json-schema-traverse: 1.0.0 + require-from-string: 2.0.2 + uri-js: 4.4.1 + + argparse@1.0.10: + dependencies: + sprintf-js: 1.0.3 + + balanced-match@1.0.2: {} + + brace-expansion@1.1.11: + dependencies: + balanced-match: 1.0.2 + concat-map: 0.0.1 + + brace-expansion@2.0.1: + dependencies: + balanced-match: 1.0.2 + + compare-versions@6.1.1: {} - uglify-js@3.19.3: {} + computeds@0.0.1: {} + + concat-map@0.0.1: {} + + confbox@0.1.8: {} + + de-indent@1.0.2: {} + + debug@4.3.7: + dependencies: + ms: 2.1.3 + + entities@4.5.0: {} + + esbuild@0.21.5: + optionalDependencies: + '@esbuild/aix-ppc64': 0.21.5 + '@esbuild/android-arm': 0.21.5 + '@esbuild/android-arm64': 0.21.5 + '@esbuild/android-x64': 0.21.5 + '@esbuild/darwin-arm64': 0.21.5 + '@esbuild/darwin-x64': 0.21.5 + '@esbuild/freebsd-arm64': 0.21.5 + '@esbuild/freebsd-x64': 0.21.5 + '@esbuild/linux-arm': 0.21.5 + '@esbuild/linux-arm64': 0.21.5 + '@esbuild/linux-ia32': 0.21.5 + '@esbuild/linux-loong64': 0.21.5 + '@esbuild/linux-mips64el': 0.21.5 + '@esbuild/linux-ppc64': 0.21.5 + '@esbuild/linux-riscv64': 0.21.5 + '@esbuild/linux-s390x': 0.21.5 + '@esbuild/linux-x64': 0.21.5 + '@esbuild/netbsd-x64': 0.21.5 + '@esbuild/openbsd-x64': 0.21.5 + '@esbuild/sunos-x64': 0.21.5 + '@esbuild/win32-arm64': 0.21.5 + '@esbuild/win32-ia32': 0.21.5 + '@esbuild/win32-x64': 0.21.5 + + estree-walker@2.0.2: {} + + fast-deep-equal@3.1.3: {} + + fs-extra@7.0.1: + dependencies: + graceful-fs: 4.2.11 + jsonfile: 4.0.0 + universalify: 0.1.2 + + fsevents@2.3.3: + optional: true + + function-bind@1.1.2: {} + + graceful-fs@4.2.11: {} + + has-flag@4.0.0: {} + + hasown@2.0.2: + dependencies: + function-bind: 1.1.2 + + he@1.2.0: {} + + import-lazy@4.0.0: {} + + is-core-module@2.15.1: + dependencies: + hasown: 2.0.2 + + jju@1.4.0: {} + + json-schema-traverse@1.0.0: {} + + jsonfile@4.0.0: + optionalDependencies: + graceful-fs: 4.2.11 + + kolorist@1.8.0: {} + + local-pkg@0.5.0: + dependencies: + mlly: 1.7.2 + pkg-types: 1.2.1 + + lodash@4.17.21: {} + + lru-cache@6.0.0: + dependencies: + yallist: 4.0.0 + + magic-string@0.30.12: + dependencies: + '@jridgewell/sourcemap-codec': 1.5.0 + + minimatch@3.0.8: + dependencies: + brace-expansion: 1.1.11 + + minimatch@9.0.5: + dependencies: + brace-expansion: 2.0.1 + + mlly@1.7.2: + dependencies: + acorn: 8.13.0 + pathe: 1.1.2 + pkg-types: 1.2.1 + ufo: 1.5.4 + + ms@2.1.3: {} + + muggle-string@0.4.1: {} + + nanoid@3.3.7: {} + + path-browserify@1.0.1: {} + + path-parse@1.0.7: {} + + pathe@1.1.2: {} + + picocolors@1.1.0: {} + + picomatch@2.3.1: {} + + pkg-types@1.2.1: + dependencies: + confbox: 0.1.8 + mlly: 1.7.2 + pathe: 1.1.2 + + postcss@8.4.47: + dependencies: + nanoid: 3.3.7 + picocolors: 1.1.0 + source-map-js: 1.2.1 + + punycode@2.3.1: {} + + require-from-string@2.0.2: {} + + resolve@1.22.8: + dependencies: + is-core-module: 2.15.1 + path-parse: 1.0.7 + supports-preserve-symlinks-flag: 1.0.0 + + rollup@4.24.0: + dependencies: + '@types/estree': 1.0.6 + optionalDependencies: + '@rollup/rollup-android-arm-eabi': 4.24.0 + '@rollup/rollup-android-arm64': 4.24.0 + '@rollup/rollup-darwin-arm64': 4.24.0 + '@rollup/rollup-darwin-x64': 4.24.0 + '@rollup/rollup-linux-arm-gnueabihf': 4.24.0 + '@rollup/rollup-linux-arm-musleabihf': 4.24.0 + '@rollup/rollup-linux-arm64-gnu': 4.24.0 + '@rollup/rollup-linux-arm64-musl': 4.24.0 + '@rollup/rollup-linux-powerpc64le-gnu': 4.24.0 + '@rollup/rollup-linux-riscv64-gnu': 4.24.0 + '@rollup/rollup-linux-s390x-gnu': 4.24.0 + '@rollup/rollup-linux-x64-gnu': 4.24.0 + '@rollup/rollup-linux-x64-musl': 4.24.0 + '@rollup/rollup-win32-arm64-msvc': 4.24.0 + '@rollup/rollup-win32-ia32-msvc': 4.24.0 + '@rollup/rollup-win32-x64-msvc': 4.24.0 + fsevents: 2.3.3 + + semver@7.5.4: + dependencies: + lru-cache: 6.0.0 + + source-map-js@1.2.1: {} + + source-map@0.6.1: {} + + sprintf-js@1.0.3: {} + + string-argv@0.3.2: {} + + strip-json-comments@3.1.1: {} + + supports-color@8.1.1: + dependencies: + has-flag: 4.0.0 + + supports-preserve-symlinks-flag@1.0.0: {} + + to-fast-properties@2.0.0: {} + + typescript@5.4.2: {} + + typescript@5.6.3: {} + + ufo@1.5.4: {} undici-types@6.19.8: {} + + universalify@0.1.2: {} + + uri-js@4.4.1: + dependencies: + punycode: 2.3.1 + + vite-plugin-dts@4.2.4(@types/node@20.16.11)(rollup@4.24.0)(typescript@5.6.3)(vite@5.4.9(@types/node@20.16.11)): + dependencies: + '@microsoft/api-extractor': 7.47.7(@types/node@20.16.11) + '@rollup/pluginutils': 5.1.2(rollup@4.24.0) + '@volar/typescript': 2.4.6 + '@vue/language-core': 2.1.6(typescript@5.6.3) + compare-versions: 6.1.1 + debug: 4.3.7 + kolorist: 1.8.0 + local-pkg: 0.5.0 + magic-string: 0.30.12 + typescript: 5.6.3 + optionalDependencies: + vite: 5.4.9(@types/node@20.16.11) + transitivePeerDependencies: + - '@types/node' + - rollup + - supports-color + + vite@5.4.9(@types/node@20.16.11): + dependencies: + esbuild: 0.21.5 + postcss: 8.4.47 + rollup: 4.24.0 + optionalDependencies: + '@types/node': 20.16.11 + fsevents: 2.3.3 + + vscode-uri@3.0.8: {} + + yallist@4.0.0: {} diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..2a97615 --- /dev/null +++ b/vite.config.js @@ -0,0 +1,27 @@ +import path from "node:path"; +import { defineConfig } from "vite"; +import dts from "vite-plugin-dts"; + +export default defineConfig({ + build: { + //Specifies that the output of the build will be a library. + lib: { + //Defines the entry point for the library build. It resolves + //to src/index.ts,indicating that the library starts from this file. + entry: path.resolve(__dirname, "src/index.ts"), + name: "react-geocode", + //A function that generates the output file + //name for different formats during the build + fileName: (format) => `index.${format}.js`, + }, + //Generates sourcemaps for the built files, + //aiding in debugging. + sourcemap: true, + //Clears the output directory before building. + emptyOutDir: true, + }, + //react() enables React support. + //dts() generates TypeScript declaration files (*.d.ts) + //during the build. + plugins: [dts()], +}); From 76b814e0ffba15d91031d15ac826e96eaed6a705 Mon Sep 17 00:00:00 2001 From: Sam Svindland Date: Wed, 16 Oct 2024 09:19:38 -0400 Subject: [PATCH 3/8] update node types --- package.json | 2 +- pnpm-lock.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 87dc237..7f3537e 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "build": "vite build" }, "devDependencies": { - "@types/node": "^20.6.2", + "@types/node": "^20.16.11", "typescript": "^5.6.3", "vite": "^5.4.9", "vite-plugin-dts": "^4.2.4" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b089b39..a543312 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,7 +9,7 @@ importers: .: devDependencies: '@types/node': - specifier: ^20.6.2 + specifier: ^20.16.11 version: 20.16.11 typescript: specifier: ^5.6.3 From ee43d4d12ea50911558d32bcb2fa671f01970104 Mon Sep 17 00:00:00 2001 From: Sam Svindland Date: Wed, 16 Oct 2024 09:21:11 -0400 Subject: [PATCH 4/8] fix author portfolio link --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7f3537e..1175d88 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "geocoder", "geocoding" ], - "author": "Pir Shukarulalh Shah (http://www.shukarullah.com)", + "author": "Pir Shukarulalh Shah (https://www.shukarullah.com)", "license": "MIT", "bugs": { "url": "https://github.com/shukerullah/react-geocode/issues" From 04fd946ea7b66fdd6c365494339b9c1f93f84243 Mon Sep 17 00:00:00 2001 From: Sam Svindland Date: Wed, 16 Oct 2024 09:23:19 -0400 Subject: [PATCH 5/8] update main, export, and files --- package.json | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 1175d88..75af827 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,21 @@ "name": "react-geocode", "version": "1.0.0", "description": "A module to transform a description of a location (i.e. street address, town name, etc.) into geographic coordinates (i.e. latitude and longitude) and vice versa.", - "main": "dist/index.js", - "types": "types/index.d.ts", - "src": "src/index.ts", + "packageManager": "pnpm@9.12.0", + "main": "dist/index.umd.js", + "module": "dist/index.es.js", + "types": "index.d.ts", + "type": "module", + "export": { + ".": { + "import": "./dist/index.es.js", + "require": "./dist/index.umd.js", + "types": "./index.d.ts" + } + }, + "files": [ + "dist" + ], "repository": { "type": "git", "url": "git+https://github.com/shukerullah/react-geocode.git" From b05adc363336eb4cddecad3830edb32be054e33d Mon Sep 17 00:00:00 2001 From: Sam Svindland Date: Wed, 16 Oct 2024 09:41:41 -0400 Subject: [PATCH 6/8] add prettier --- dist/index.es.js.map | 2 +- dist/index.umd.js.map | 2 +- package.json | 4 +++- pnpm-lock.yaml | 10 ++++++++++ src/index.ts | 18 +++++++++--------- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/dist/index.es.js.map b/dist/index.es.js.map index 63f1321..c85e3c5 100644 --- a/dist/index.es.js.map +++ b/dist/index.es.js.map @@ -1 +1 @@ -{"version":3,"file":"index.es.js","sources":["../src/index.ts"],"sourcesContent":["/**\r\n * Enum defining possible request types for geocoding.\r\n */\r\nexport enum RequestType {\r\n ADDRESS = \"address\", // Geocoding by address\r\n LATLNG = \"latlng\", // Geocoding by latitude and longitude\r\n PLACE_ID = \"place_id\", // Geocoding by place ID\r\n}\r\n\r\n/**\r\n * Enum defining possible output formats for geocoding.\r\n */\r\nexport enum OutputFormat {\r\n XML = \"xml\", // Output format XML\r\n JSON = \"json\", // Output format JSON\r\n}\r\n\r\n/**\r\n * The URL of the Google Geocoding API.\r\n */\r\nconst GOOGLE_GEOCODE_API = \"https://maps.googleapis.com/maps/api/geocode\";\r\n\r\n/**\r\n * Options that can be passed to the geocoding requests.\r\n */\r\nexport interface GeocodeOptions {\r\n key?: string; // API key for the Google Maps Geocoding API.\r\n language?: string; // Language code for the response.\r\n region?: string; // Region code for the response.\r\n components?: string; // Component filtering for the response.\r\n bounds?: string; // Bounding box for the response.\r\n result_type?: string; // Result type filtering for the response.\r\n location_type?: string; // Location type filtering for the response.\r\n outputFormat: OutputFormat; // Desired output format (either XML or JSON)\r\n enable_address_descriptor?: boolean; // Whether to include an address descriptor in the reverse geocoding response.\r\n}\r\n\r\n/**\r\n * Response object from the geocoding API.\r\n */\r\ninterface GeocodeResponse {\r\n status: string;\r\n results: GeocodeResult[];\r\n address_descriptor?: AddressDescriptor;\r\n plus_code?: PlusCode;\r\n error_message?: string;\r\n}\r\n\r\n/**\r\n * The query parameters for geocoding requests.\r\n */\r\ninterface GeocodeQueryParams extends GeocodeOptions {\r\n place_id?: string; // The plce id to geocode\r\n address?: string; // The address to geocode\r\n latlng?: string; // The latitude/longitude of the location to geocode\r\n}\r\n\r\n/**\r\n * Default options for the geocoding requests.\r\n */\r\nlet defaultOptions: GeocodeOptions = {\r\n outputFormat: OutputFormat.JSON,\r\n};\r\n\r\n/**\r\n * Performs a geocoding request to the Google Geocoding API.\r\n * @function geocodeRequest\r\n * @async\r\n * @param {GeocodeQueryParams} queryParams - The query parameters for the geocoding request.\r\n * @returns {Promise} - A promise that resolves with the geocoding response object.\r\n * @throws {Error} - Throws an error if the geocoding request fails.\r\n */\r\nasync function geocodeRequest(\r\n queryParams: GeocodeQueryParams\r\n): Promise {\r\n const { outputFormat, ...restParams } = queryParams;\r\n const queryString = new URLSearchParams(\r\n restParams as Record\r\n ).toString();\r\n const url = `${GOOGLE_GEOCODE_API}/${outputFormat}?${queryString}`;\r\n try {\r\n const response = await fetch(url);\r\n const json = await response.json();\r\n const { status, error_message } = json;\r\n\r\n if (status === \"OK\") {\r\n return json;\r\n }\r\n\r\n throw new Error(\r\n `Geocoding failed: ${error_message}. Server returned status code ${status}.`\r\n );\r\n } catch (error: unknown) {\r\n if (error instanceof Error) {\r\n throw new Error(`Geocoding request failed: ${error.message}`);\r\n }\r\n throw new Error(`Geocoding request failed with unknown error: ${error}`);\r\n }\r\n}\r\n\r\n/**\r\n * Sets default options for geocoding requests.\r\n *\r\n * @param options - The default options to set.\r\n */\r\nexport function setDefaults(options: GeocodeOptions): void {\r\n defaultOptions = {\r\n ...defaultOptions,\r\n ...options,\r\n };\r\n}\r\n\r\n/**\r\n * Sets the API key to use for geocoding requests.\r\n *\r\n * @param key - The API key to set.\r\n */\r\nexport function setKey(key: string): void {\r\n defaultOptions.key = key;\r\n}\r\n\r\n/**\r\n * Sets the language to use for geocoding requests.\r\n *\r\n * @param language - The language to set.\r\n */\r\nexport function setLanguage(language: string): void {\r\n defaultOptions.language = language;\r\n}\r\n\r\n/**\r\n * Sets the region code to use for geocoding requests.\r\n *\r\n * @param region - The region code to set.\r\n */\r\nexport function setRegion(region: string): void {\r\n defaultOptions.region = region;\r\n}\r\n\r\n/**\r\n * Sets the component filter to use for geocoding requests.\r\n *\r\n * @param components - The component filter to set.\r\n */\r\nexport function setComponents(components: string): void {\r\n defaultOptions.components = components;\r\n}\r\n\r\n/**\r\n * Sets the bounding box to use for geocoding requests.\r\n *\r\n * @param bounds - The bounding box to set.\r\n */\r\nexport function setBounds(bounds: string): void {\r\n defaultOptions.bounds = bounds;\r\n}\r\n\r\n/**\r\n * Sets the result type filter to use for geocoding requests.\r\n * One or more address types to return, separated by a pipe (|).\r\n * Possible values are \"street_address\", \"route\", \"intersection\", \"political\", \"country\",\r\n * \"administrative_area_level_1\", \"administrative_area_level_2\", \"administrative_area_level_3\",\r\n * \"administrative_area_level_4\", \"administrative_area_level_5\", \"colloquial_area\", \"locality\",\r\n * \"ward\", \"sublocality\", \"neighborhood\", \"premise\", \"subpremise\", \"postal_code\", \"natural_feature\",\r\n * \"airport\", \"park\", \"point_of_interest\", and \"postal_code_prefix\".\r\n *\r\n * @param resultType - The result type to set.\r\n */\r\nexport function setResultType(resultType: string): void {\r\n defaultOptions.result_type = resultType;\r\n}\r\n\r\n/**\r\n * Sets the location type filter to use for geocoding requests.\r\n * One or more location types to return. Possible values are \"ROOFTOP\",\r\n * \"RANGE_INTERPOLATED\", \"GEOMETRIC_CENTER\", \"APPROXIMATE\".\r\n *\r\n * @param locationType - The location type to set.\r\n */\r\nexport function setLocationType(locationType: string): void {\r\n defaultOptions.location_type = locationType;\r\n}\r\n\r\n/**\r\n * Sets the desired output format for geocoding requests. The format can be either XML or JSON.\r\n *\r\n * @param outputFormat - The desired output format (either OutputFormat.XML or OutputFormat.JSON).\r\n */\r\nexport function setOutputFormat(outputFormat: OutputFormat): void {\r\n defaultOptions.outputFormat = outputFormat;\r\n}\r\n\r\n/**\r\n * Sets whether to include an address descriptor in the reverse geocoding response.\r\n *\r\n * @param enableAddressDescriptor - A boolean parameter indicating whether to include the address descriptor.\r\n */\r\nexport function enableAddressDescriptor(\r\n enableAddressDescriptor: boolean\r\n): void {\r\n defaultOptions.enable_address_descriptor = enableAddressDescriptor;\r\n}\r\n\r\n/**\r\n * Sends a geocoding request to the Google Maps Geocoding API for a given address and returns the response.\r\n * @function geocode\r\n * @async\r\n * @param {RequestType} requestType - Identifier to specify the type of request (place_id, address, or latlng).\r\n * @param {string} value - The value to be used for geocoding (address, place_id, or latlng).\r\n * @param {GeocodeOptions} [options={}] - Additional options for the geocoding request.\r\n * @returns {Promise} - A promise that resolves with the geocoding response object.\r\n * @throws {Error} - Throws an error if the address is invalid or the geocoding request fails.\r\n */\r\nexport function geocode(\r\n requestType: RequestType | string,\r\n value: string,\r\n options?: GeocodeOptions\r\n): Promise {\r\n if (typeof requestType !== \"string\" || typeof value !== \"string\") {\r\n throw new Error(\r\n `Both requestType and value are required and must be of type string. \r\n requestType: ${typeof requestType}, value: ${typeof value}`\r\n );\r\n }\r\n\r\n const queryParams: GeocodeQueryParams = {\r\n ...defaultOptions,\r\n ...options,\r\n [requestType]: value,\r\n };\r\n return geocodeRequest(queryParams);\r\n}\r\n\r\n/**\r\n * @deprecated Use `geocode` instead.\r\n * Usage: geocode(\"address\", \"Washington\", *options)\r\n */\r\nexport function fromAddress(\r\n address: string,\r\n key?: string,\r\n language?: string,\r\n region?: string\r\n) {\r\n const options: GeocodeOptions = {\r\n outputFormat: OutputFormat.JSON,\r\n };\r\n if (key) {\r\n options.key = key;\r\n }\r\n if (language) {\r\n options.language = language;\r\n }\r\n if (region) {\r\n options.region = region;\r\n }\r\n return geocode(RequestType.ADDRESS, address, options);\r\n}\r\n\r\n/**\r\n * @deprecated use `geocode` instead\r\n * Usage: geocode(\"place_id\", \"ChIJd8BlQ2BZwokRAFUEcm_qrcA\", *options)\r\n */\r\nexport function fromPlaceId(\r\n placeId: string,\r\n key?: string,\r\n language?: string,\r\n region?: string\r\n) {\r\n const options: GeocodeOptions = {\r\n outputFormat: OutputFormat.JSON,\r\n };\r\n if (key) {\r\n options.key = key;\r\n }\r\n if (language) {\r\n options.language = language;\r\n }\r\n if (region) {\r\n options.region = region;\r\n }\r\n return geocode(RequestType.PLACE_ID, placeId, options);\r\n}\r\n\r\n/**\r\n * @deprecated use `geocode` instead\r\n * Usage: geocode(\"latlng\", \"40.714224,-73.961452\", *options)\r\n */\r\nexport function fromLatLng(\r\n lat: number,\r\n lng: number,\r\n key?: string,\r\n language?: string,\r\n region?: string,\r\n location_type?: string\r\n) {\r\n const options: GeocodeOptions = {\r\n outputFormat: OutputFormat.JSON,\r\n };\r\n if (key) {\r\n options.key = key;\r\n }\r\n if (language) {\r\n options.language = language;\r\n }\r\n if (region) {\r\n options.region = region;\r\n }\r\n if (location_type) {\r\n options.location_type = location_type;\r\n }\r\n return geocode(RequestType.LATLNG, `${lat},${lng}`, options);\r\n}\r\n\r\ninterface GeocodeResult {\r\n address_components: AddressComponent[];\r\n formatted_address: string;\r\n geometry: Geometry;\r\n place_id: string;\r\n plus_code: PlusCode;\r\n types: string[];\r\n}\r\n\r\ninterface AddressComponent {\r\n long_name: string;\r\n short_name: string;\r\n types: string[];\r\n}\r\n\r\ninterface Geometry {\r\n location: {\r\n lat: number;\r\n lng: number;\r\n };\r\n location_type: string;\r\n viewport: {\r\n lat: number;\r\n lng: number;\r\n };\r\n southwest: {\r\n lat: number;\r\n lng: number;\r\n };\r\n}\r\n\r\ninterface AddressDescriptor {\r\n area: AreaDescriptor[];\r\n landmarks: Landmark[];\r\n}\r\n\r\ninterface AreaDescriptor {\r\n containment: string;\r\n display_name: {\r\n language_code: string;\r\n text: string;\r\n };\r\n place_id: string;\r\n}\r\n\r\ninterface Landmark {\r\n display_name: {\r\n language_code: string;\r\n text: string;\r\n };\r\n straight_line_distance_meters: number;\r\n place_id: string;\r\n travel_distance_meters: number;\r\n spatial_relationship: string;\r\n types: string[];\r\n}\r\n\r\ninterface PlusCode {\r\n compound_code: string;\r\n global_code: string;\r\n}\r\n"],"names":["RequestType","OutputFormat","GOOGLE_GEOCODE_API","defaultOptions","geocodeRequest","queryParams","outputFormat","restParams","queryString","url","json","status","error_message","error","setDefaults","options","setKey","key","setLanguage","language","setRegion","region","setComponents","components","setBounds","bounds","setResultType","resultType","setLocationType","locationType","setOutputFormat","enableAddressDescriptor","geocode","requestType","value","fromAddress","address","fromPlaceId","placeId","fromLatLng","lat","lng","location_type"],"mappings":"AAGY,IAAAA,sBAAAA,OACVA,EAAA,UAAU,WACVA,EAAA,SAAS,UACTA,EAAA,WAAW,YAHDA,IAAAA,KAAA,CAAA,CAAA,GASAC,sBAAAA,OACVA,EAAA,MAAM,OACNA,EAAA,OAAO,QAFGA,IAAAA,KAAA,CAAA,CAAA;AAQZ,MAAMC,IAAqB;AAwC3B,IAAIC,IAAiC;AAAA,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AC,EACdC,GACAC,GACAnB,GACc;AACd,MAAI,OAAOkB,KAAgB,YAAY,OAAOC,KAAU;AACtD,UAAM,IAAI;AAAA,MACR;AAAA,sBACgB,OAAOD,CAAW,YAAY,OAAOC,CAAK;AAAA,IAAA;AAI9D,QAAM7B,IAAkC;AAAA,IACtC,GAAGF;AAAA,IACH,GAAGY;AAAA,IACH,CAACkB,CAAW,GAAGC;AAAA,EAAA;AAEjB,SAAO9B,EAAeC,CAAW;AACnC;AAMO,SAAS8B,EACdC,GACAnB,GACAE,GACAE,GACA;AACA,QAAMN,IAA0B;AAAA,IAC9B,cAAc;AAAA;AAAA,EAAA;AAEhB,SAAIE,MACFF,EAAQ,MAAME,IAEZE,MACFJ,EAAQ,WAAWI,IAEjBE,MACFN,EAAQ,SAASM,IAEZW,EAAQ,WAAqBI,GAASrB,CAAO;AACtD;AAMO,SAASsB,EACdC,GACArB,GACAE,GACAE,GACA;AACA,QAAMN,IAA0B;AAAA,IAC9B,cAAc;AAAA;AAAA,EAAA;AAEhB,SAAIE,MACFF,EAAQ,MAAME,IAEZE,MACFJ,EAAQ,WAAWI,IAEjBE,MACFN,EAAQ,SAASM,IAEZW,EAAQ,YAAsBM,GAASvB,CAAO;AACvD;AAMO,SAASwB,EACdC,GACAC,GACAxB,GACAE,GACAE,GACAqB,GACA;AACA,QAAM3B,IAA0B;AAAA,IAC9B,cAAc;AAAA;AAAA,EAAA;AAEhB,SAAIE,MACFF,EAAQ,MAAME,IAEZE,MACFJ,EAAQ,WAAWI,IAEjBE,MACFN,EAAQ,SAASM,IAEfqB,MACF3B,EAAQ,gBAAgB2B,IAEnBV,EAAQ,UAAoB,GAAGQ,CAAG,IAAIC,CAAG,IAAI1B,CAAO;AAC7D;"} \ No newline at end of file +{"version":3,"file":"index.es.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * Enum defining possible request types for geocoding.\n */\nexport enum RequestType {\n ADDRESS = \"address\", // Geocoding by address\n LATLNG = \"latlng\", // Geocoding by latitude and longitude\n PLACE_ID = \"place_id\", // Geocoding by place ID\n}\n\n/**\n * Enum defining possible output formats for geocoding.\n */\nexport enum OutputFormat {\n XML = \"xml\", // Output format XML\n JSON = \"json\", // Output format JSON\n}\n\n/**\n * The URL of the Google Geocoding API.\n */\nconst GOOGLE_GEOCODE_API = \"https://maps.googleapis.com/maps/api/geocode\";\n\n/**\n * Options that can be passed to the geocoding requests.\n */\nexport interface GeocodeOptions {\n key?: string; // API key for the Google Maps Geocoding API.\n language?: string; // Language code for the response.\n region?: string; // Region code for the response.\n components?: string; // Component filtering for the response.\n bounds?: string; // Bounding box for the response.\n result_type?: string; // Result type filtering for the response.\n location_type?: string; // Location type filtering for the response.\n outputFormat: OutputFormat; // Desired output format (either XML or JSON)\n enable_address_descriptor?: boolean; // Whether to include an address descriptor in the reverse geocoding response.\n}\n\n/**\n * Response object from the geocoding API.\n */\ninterface GeocodeResponse {\n status: string;\n results: GeocodeResult[];\n address_descriptor?: AddressDescriptor;\n plus_code?: PlusCode;\n error_message?: string;\n}\n\n/**\n * The query parameters for geocoding requests.\n */\ninterface GeocodeQueryParams extends GeocodeOptions {\n place_id?: string; // The plce id to geocode\n address?: string; // The address to geocode\n latlng?: string; // The latitude/longitude of the location to geocode\n}\n\n/**\n * Default options for the geocoding requests.\n */\nlet defaultOptions: GeocodeOptions = {\n outputFormat: OutputFormat.JSON,\n};\n\n/**\n * Performs a geocoding request to the Google Geocoding API.\n * @function geocodeRequest\n * @async\n * @param {GeocodeQueryParams} queryParams - The query parameters for the geocoding request.\n * @returns {Promise} - A promise that resolves with the geocoding response object.\n * @throws {Error} - Throws an error if the geocoding request fails.\n */\nasync function geocodeRequest(\n queryParams: GeocodeQueryParams,\n): Promise {\n const { outputFormat, ...restParams } = queryParams;\n const queryString = new URLSearchParams(\n restParams as Record,\n ).toString();\n const url = `${GOOGLE_GEOCODE_API}/${outputFormat}?${queryString}`;\n try {\n const response = await fetch(url);\n const json = await response.json();\n const { status, error_message } = json;\n\n if (status === \"OK\") {\n return json;\n }\n\n throw new Error(\n `Geocoding failed: ${error_message}. Server returned status code ${status}.`,\n );\n } catch (error: unknown) {\n if (error instanceof Error) {\n throw new Error(`Geocoding request failed: ${error.message}`);\n }\n throw new Error(`Geocoding request failed with unknown error: ${error}`);\n }\n}\n\n/**\n * Sets default options for geocoding requests.\n *\n * @param options - The default options to set.\n */\nexport function setDefaults(options: GeocodeOptions): void {\n defaultOptions = {\n ...defaultOptions,\n ...options,\n };\n}\n\n/**\n * Sets the API key to use for geocoding requests.\n *\n * @param key - The API key to set.\n */\nexport function setKey(key: string): void {\n defaultOptions.key = key;\n}\n\n/**\n * Sets the language to use for geocoding requests.\n *\n * @param language - The language to set.\n */\nexport function setLanguage(language: string): void {\n defaultOptions.language = language;\n}\n\n/**\n * Sets the region code to use for geocoding requests.\n *\n * @param region - The region code to set.\n */\nexport function setRegion(region: string): void {\n defaultOptions.region = region;\n}\n\n/**\n * Sets the component filter to use for geocoding requests.\n *\n * @param components - The component filter to set.\n */\nexport function setComponents(components: string): void {\n defaultOptions.components = components;\n}\n\n/**\n * Sets the bounding box to use for geocoding requests.\n *\n * @param bounds - The bounding box to set.\n */\nexport function setBounds(bounds: string): void {\n defaultOptions.bounds = bounds;\n}\n\n/**\n * Sets the result type filter to use for geocoding requests.\n * One or more address types to return, separated by a pipe (|).\n * Possible values are \"street_address\", \"route\", \"intersection\", \"political\", \"country\",\n * \"administrative_area_level_1\", \"administrative_area_level_2\", \"administrative_area_level_3\",\n * \"administrative_area_level_4\", \"administrative_area_level_5\", \"colloquial_area\", \"locality\",\n * \"ward\", \"sublocality\", \"neighborhood\", \"premise\", \"subpremise\", \"postal_code\", \"natural_feature\",\n * \"airport\", \"park\", \"point_of_interest\", and \"postal_code_prefix\".\n *\n * @param resultType - The result type to set.\n */\nexport function setResultType(resultType: string): void {\n defaultOptions.result_type = resultType;\n}\n\n/**\n * Sets the location type filter to use for geocoding requests.\n * One or more location types to return. Possible values are \"ROOFTOP\",\n * \"RANGE_INTERPOLATED\", \"GEOMETRIC_CENTER\", \"APPROXIMATE\".\n *\n * @param locationType - The location type to set.\n */\nexport function setLocationType(locationType: string): void {\n defaultOptions.location_type = locationType;\n}\n\n/**\n * Sets the desired output format for geocoding requests. The format can be either XML or JSON.\n *\n * @param outputFormat - The desired output format (either OutputFormat.XML or OutputFormat.JSON).\n */\nexport function setOutputFormat(outputFormat: OutputFormat): void {\n defaultOptions.outputFormat = outputFormat;\n}\n\n/**\n * Sets whether to include an address descriptor in the reverse geocoding response.\n *\n * @param enableAddressDescriptor - A boolean parameter indicating whether to include the address descriptor.\n */\nexport function enableAddressDescriptor(\n enableAddressDescriptor: boolean,\n): void {\n defaultOptions.enable_address_descriptor = enableAddressDescriptor;\n}\n\n/**\n * Sends a geocoding request to the Google Maps Geocoding API for a given address and returns the response.\n * @function geocode\n * @async\n * @param {RequestType} requestType - Identifier to specify the type of request (place_id, address, or latlng).\n * @param {string} value - The value to be used for geocoding (address, place_id, or latlng).\n * @param {GeocodeOptions} [options={}] - Additional options for the geocoding request.\n * @returns {Promise} - A promise that resolves with the geocoding response object.\n * @throws {Error} - Throws an error if the address is invalid or the geocoding request fails.\n */\nexport function geocode(\n requestType: RequestType | string,\n value: string,\n options?: GeocodeOptions,\n): Promise {\n if (typeof requestType !== \"string\" || typeof value !== \"string\") {\n throw new Error(\n `Both requestType and value are required and must be of type string. \n requestType: ${typeof requestType}, value: ${typeof value}`,\n );\n }\n\n const queryParams: GeocodeQueryParams = {\n ...defaultOptions,\n ...options,\n [requestType]: value,\n };\n return geocodeRequest(queryParams);\n}\n\n/**\n * @deprecated Use `geocode` instead.\n * Usage: geocode(\"address\", \"Washington\", *options)\n */\nexport function fromAddress(\n address: string,\n key?: string,\n language?: string,\n region?: string,\n) {\n const options: GeocodeOptions = {\n outputFormat: OutputFormat.JSON,\n };\n if (key) {\n options.key = key;\n }\n if (language) {\n options.language = language;\n }\n if (region) {\n options.region = region;\n }\n return geocode(RequestType.ADDRESS, address, options);\n}\n\n/**\n * @deprecated use `geocode` instead\n * Usage: geocode(\"place_id\", \"ChIJd8BlQ2BZwokRAFUEcm_qrcA\", *options)\n */\nexport function fromPlaceId(\n placeId: string,\n key?: string,\n language?: string,\n region?: string,\n) {\n const options: GeocodeOptions = {\n outputFormat: OutputFormat.JSON,\n };\n if (key) {\n options.key = key;\n }\n if (language) {\n options.language = language;\n }\n if (region) {\n options.region = region;\n }\n return geocode(RequestType.PLACE_ID, placeId, options);\n}\n\n/**\n * @deprecated use `geocode` instead\n * Usage: geocode(\"latlng\", \"40.714224,-73.961452\", *options)\n */\nexport function fromLatLng(\n lat: number,\n lng: number,\n key?: string,\n language?: string,\n region?: string,\n location_type?: string,\n) {\n const options: GeocodeOptions = {\n outputFormat: OutputFormat.JSON,\n };\n if (key) {\n options.key = key;\n }\n if (language) {\n options.language = language;\n }\n if (region) {\n options.region = region;\n }\n if (location_type) {\n options.location_type = location_type;\n }\n return geocode(RequestType.LATLNG, `${lat},${lng}`, options);\n}\n\ninterface GeocodeResult {\n address_components: AddressComponent[];\n formatted_address: string;\n geometry: Geometry;\n place_id: string;\n plus_code: PlusCode;\n types: string[];\n}\n\ninterface AddressComponent {\n long_name: string;\n short_name: string;\n types: string[];\n}\n\ninterface Geometry {\n location: {\n lat: number;\n lng: number;\n };\n location_type: string;\n viewport: {\n lat: number;\n lng: number;\n };\n southwest: {\n lat: number;\n lng: number;\n };\n}\n\ninterface AddressDescriptor {\n area: AreaDescriptor[];\n landmarks: Landmark[];\n}\n\ninterface AreaDescriptor {\n containment: string;\n display_name: {\n language_code: string;\n text: string;\n };\n place_id: string;\n}\n\ninterface Landmark {\n display_name: {\n language_code: string;\n text: string;\n };\n straight_line_distance_meters: number;\n place_id: string;\n travel_distance_meters: number;\n spatial_relationship: string;\n types: string[];\n}\n\ninterface PlusCode {\n compound_code: string;\n global_code: string;\n}\n"],"names":["RequestType","OutputFormat","GOOGLE_GEOCODE_API","defaultOptions","geocodeRequest","queryParams","outputFormat","restParams","queryString","url","json","status","error_message","error","setDefaults","options","setKey","key","setLanguage","language","setRegion","region","setComponents","components","setBounds","bounds","setResultType","resultType","setLocationType","locationType","setOutputFormat","enableAddressDescriptor","geocode","requestType","value","fromAddress","address","fromPlaceId","placeId","fromLatLng","lat","lng","location_type"],"mappings":"AAGY,IAAAA,sBAAAA,OACVA,EAAA,UAAU,WACVA,EAAA,SAAS,UACTA,EAAA,WAAW,YAHDA,IAAAA,KAAA,CAAA,CAAA,GASAC,sBAAAA,OACVA,EAAA,MAAM,OACNA,EAAA,OAAO,QAFGA,IAAAA,KAAA,CAAA,CAAA;AAQZ,MAAMC,IAAqB;AAwC3B,IAAIC,IAAiC;AAAA,EACnC,cAAc;AAAA;AAChB;AAUA,eAAeC,EACbC,GAC0B;AAC1B,QAAM,EAAE,cAAAC,GAAc,GAAGC,EAAA,IAAeF,GAClCG,IAAc,IAAI;AAAA,IACtBD;AAAA,IACA,SAAS,GACLE,IAAM,GAAGP,CAAkB,IAAII,CAAY,IAAIE,CAAW;AAC5D,MAAA;AAEI,UAAAE,IAAO,OADI,MAAM,MAAMD,CAAG,GACJ,QACtB,EAAE,QAAAE,GAAQ,eAAAC,EAAkB,IAAAF;AAElC,QAAIC,MAAW;AACN,aAAAD;AAGT,UAAM,IAAI;AAAA,MACR,qBAAqBE,CAAa,iCAAiCD,CAAM;AAAA,IAAA;AAAA,WAEpEE,GAAgB;AACvB,UAAIA,aAAiB,QACb,IAAI,MAAM,6BAA6BA,EAAM,OAAO,EAAE,IAExD,IAAI,MAAM,gDAAgDA,CAAK,EAAE;AAAA,EACzE;AACF;AAOO,SAASC,EAAYC,GAA+B;AACxC,EAAAZ,IAAA;AAAA,IACf,GAAGA;AAAA,IACH,GAAGY;AAAA,EAAA;AAEP;AAOO,SAASC,EAAOC,GAAmB;AACxC,EAAAd,EAAe,MAAMc;AACvB;AAOO,SAASC,EAAYC,GAAwB;AAClD,EAAAhB,EAAe,WAAWgB;AAC5B;AAOO,SAASC,EAAUC,G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E,GACAqB,GACA;AACA,QAAM3B,IAA0B;AAAA,IAC9B,cAAc;AAAA;AAAA,EAAA;AAEhB,SAAIE,MACFF,EAAQ,MAAME,IAEZE,MACFJ,EAAQ,WAAWI,IAEjBE,MACFN,EAAQ,SAASM,IAEfqB,MACF3B,EAAQ,gBAAgB2B,IAEnBV,EAAQ,UAAoB,GAAGQ,CAAG,IAAIC,CAAG,IAAI1B,CAAO;AAC7D;"} \ No newline at end of file diff --git a/dist/index.umd.js.map b/dist/index.umd.js.map index 846e9bf..6def974 100644 --- a/dist/index.umd.js.map +++ b/dist/index.umd.js.map @@ -1 +1 @@ -{"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["/**\r\n * Enum defining possible request types for geocoding.\r\n */\r\nexport enum RequestType {\r\n ADDRESS = \"address\", // Geocoding by address\r\n LATLNG = \"latlng\", // Geocoding by latitude and longitude\r\n PLACE_ID = \"place_id\", // Geocoding by place ID\r\n}\r\n\r\n/**\r\n * Enum defining possible output formats for geocoding.\r\n */\r\nexport enum OutputFormat {\r\n XML = \"xml\", // Output format XML\r\n JSON = \"json\", // Output format JSON\r\n}\r\n\r\n/**\r\n * The URL of the Google Geocoding API.\r\n */\r\nconst GOOGLE_GEOCODE_API = \"https://maps.googleapis.com/maps/api/geocode\";\r\n\r\n/**\r\n * Options that can be passed to the geocoding requests.\r\n */\r\nexport interface GeocodeOptions {\r\n key?: string; // API key for the Google Maps Geocoding API.\r\n language?: string; // Language code for the response.\r\n region?: string; // Region code for the response.\r\n components?: string; // Component filtering for the response.\r\n bounds?: string; // Bounding box for the response.\r\n result_type?: string; // Result type filtering for the response.\r\n location_type?: string; // Location type filtering for the response.\r\n outputFormat: OutputFormat; // Desired output format (either XML or JSON)\r\n enable_address_descriptor?: boolean; // Whether to include an address descriptor in the reverse geocoding response.\r\n}\r\n\r\n/**\r\n * Response object from the geocoding API.\r\n */\r\ninterface GeocodeResponse {\r\n status: string;\r\n results: GeocodeResult[];\r\n address_descriptor?: AddressDescriptor;\r\n plus_code?: PlusCode;\r\n error_message?: string;\r\n}\r\n\r\n/**\r\n * The query parameters for geocoding requests.\r\n */\r\ninterface GeocodeQueryParams extends GeocodeOptions {\r\n place_id?: string; // The plce id to geocode\r\n address?: string; // The address to geocode\r\n latlng?: string; // The latitude/longitude of the location to geocode\r\n}\r\n\r\n/**\r\n * Default options for the geocoding requests.\r\n */\r\nlet defaultOptions: GeocodeOptions = {\r\n outputFormat: OutputFormat.JSON,\r\n};\r\n\r\n/**\r\n * Performs a geocoding request to the Google Geocoding API.\r\n * @function geocodeRequest\r\n * @async\r\n * @param {GeocodeQueryParams} queryParams - The query parameters for the geocoding request.\r\n * @returns {Promise} - A promise that resolves with the geocoding response object.\r\n * @throws {Error} - Throws an error if the geocoding request fails.\r\n */\r\nasync function geocodeRequest(\r\n queryParams: GeocodeQueryParams\r\n): Promise {\r\n const { outputFormat, ...restParams } = queryParams;\r\n const queryString = new URLSearchParams(\r\n restParams as Record\r\n ).toString();\r\n const url = `${GOOGLE_GEOCODE_API}/${outputFormat}?${queryString}`;\r\n try {\r\n const response = await fetch(url);\r\n const json = await response.json();\r\n const { status, error_message } = json;\r\n\r\n if (status === \"OK\") {\r\n return json;\r\n }\r\n\r\n throw new Error(\r\n `Geocoding failed: ${error_message}. Server returned status code ${status}.`\r\n );\r\n } catch (error: unknown) {\r\n if (error instanceof Error) {\r\n throw new Error(`Geocoding request failed: ${error.message}`);\r\n }\r\n throw new Error(`Geocoding request failed with unknown error: ${error}`);\r\n }\r\n}\r\n\r\n/**\r\n * Sets default options for geocoding requests.\r\n *\r\n * @param options - The default options to set.\r\n */\r\nexport function setDefaults(options: GeocodeOptions): void {\r\n defaultOptions = {\r\n ...defaultOptions,\r\n ...options,\r\n };\r\n}\r\n\r\n/**\r\n * Sets the API key to use for geocoding requests.\r\n *\r\n * @param key - The API key to set.\r\n */\r\nexport function setKey(key: string): void {\r\n defaultOptions.key = key;\r\n}\r\n\r\n/**\r\n * Sets the language to use for geocoding requests.\r\n *\r\n * @param language - The language to set.\r\n */\r\nexport function setLanguage(language: string): void {\r\n defaultOptions.language = language;\r\n}\r\n\r\n/**\r\n * Sets the region code to use for geocoding requests.\r\n *\r\n * @param region - The region code to set.\r\n */\r\nexport function setRegion(region: string): void {\r\n defaultOptions.region = region;\r\n}\r\n\r\n/**\r\n * Sets the component filter to use for geocoding requests.\r\n *\r\n * @param components - The component filter to set.\r\n */\r\nexport function setComponents(components: string): void {\r\n defaultOptions.components = components;\r\n}\r\n\r\n/**\r\n * Sets the bounding box to use for geocoding requests.\r\n *\r\n * @param bounds - The bounding box to set.\r\n */\r\nexport function setBounds(bounds: string): void {\r\n defaultOptions.bounds = bounds;\r\n}\r\n\r\n/**\r\n * Sets the result type filter to use for geocoding requests.\r\n * One or more address types to return, separated by a pipe (|).\r\n * Possible values are \"street_address\", \"route\", \"intersection\", \"political\", \"country\",\r\n * \"administrative_area_level_1\", \"administrative_area_level_2\", \"administrative_area_level_3\",\r\n * \"administrative_area_level_4\", \"administrative_area_level_5\", \"colloquial_area\", \"locality\",\r\n * \"ward\", \"sublocality\", \"neighborhood\", \"premise\", \"subpremise\", \"postal_code\", \"natural_feature\",\r\n * \"airport\", \"park\", \"point_of_interest\", and \"postal_code_prefix\".\r\n *\r\n * @param resultType - The result type to set.\r\n */\r\nexport function setResultType(resultType: string): void {\r\n defaultOptions.result_type = resultType;\r\n}\r\n\r\n/**\r\n * Sets the location type filter to use for geocoding requests.\r\n * One or more location types to return. Possible values are \"ROOFTOP\",\r\n * \"RANGE_INTERPOLATED\", \"GEOMETRIC_CENTER\", \"APPROXIMATE\".\r\n *\r\n * @param locationType - The location type to set.\r\n */\r\nexport function setLocationType(locationType: string): void {\r\n defaultOptions.location_type = locationType;\r\n}\r\n\r\n/**\r\n * Sets the desired output format for geocoding requests. The format can be either XML or JSON.\r\n *\r\n * @param outputFormat - The desired output format (either OutputFormat.XML or OutputFormat.JSON).\r\n */\r\nexport function setOutputFormat(outputFormat: OutputFormat): void {\r\n defaultOptions.outputFormat = outputFormat;\r\n}\r\n\r\n/**\r\n * Sets whether to include an address descriptor in the reverse geocoding response.\r\n *\r\n * @param enableAddressDescriptor - A boolean parameter indicating whether to include the address descriptor.\r\n */\r\nexport function enableAddressDescriptor(\r\n enableAddressDescriptor: boolean\r\n): void {\r\n defaultOptions.enable_address_descriptor = enableAddressDescriptor;\r\n}\r\n\r\n/**\r\n * Sends a geocoding request to the Google Maps Geocoding API for a given address and returns the response.\r\n * @function geocode\r\n * @async\r\n * @param {RequestType} requestType - Identifier to specify the type of request (place_id, address, or latlng).\r\n * @param {string} value - The value to be used for geocoding (address, place_id, or latlng).\r\n * @param {GeocodeOptions} [options={}] - Additional options for the geocoding request.\r\n * @returns {Promise} - A promise that resolves with the geocoding response object.\r\n * @throws {Error} - Throws an error if the address is invalid or the geocoding request fails.\r\n */\r\nexport function geocode(\r\n requestType: RequestType | string,\r\n value: string,\r\n options?: GeocodeOptions\r\n): Promise {\r\n if (typeof requestType !== \"string\" || typeof value !== \"string\") {\r\n throw new Error(\r\n `Both requestType and value are required and must be of type string. \r\n requestType: ${typeof requestType}, value: ${typeof value}`\r\n );\r\n }\r\n\r\n const queryParams: GeocodeQueryParams = {\r\n ...defaultOptions,\r\n ...options,\r\n [requestType]: value,\r\n };\r\n return geocodeRequest(queryParams);\r\n}\r\n\r\n/**\r\n * @deprecated Use `geocode` instead.\r\n * Usage: geocode(\"address\", \"Washington\", *options)\r\n */\r\nexport function fromAddress(\r\n address: string,\r\n key?: string,\r\n language?: string,\r\n region?: string\r\n) {\r\n const options: GeocodeOptions = {\r\n outputFormat: OutputFormat.JSON,\r\n };\r\n if (key) {\r\n options.key = key;\r\n }\r\n if (language) {\r\n options.language = language;\r\n }\r\n if (region) {\r\n options.region = region;\r\n }\r\n return geocode(RequestType.ADDRESS, address, options);\r\n}\r\n\r\n/**\r\n * @deprecated use `geocode` instead\r\n * Usage: geocode(\"place_id\", \"ChIJd8BlQ2BZwokRAFUEcm_qrcA\", *options)\r\n */\r\nexport function fromPlaceId(\r\n placeId: string,\r\n key?: string,\r\n language?: string,\r\n region?: string\r\n) {\r\n const options: GeocodeOptions = {\r\n outputFormat: OutputFormat.JSON,\r\n };\r\n if (key) {\r\n options.key = key;\r\n }\r\n if (language) {\r\n options.language = language;\r\n }\r\n if (region) {\r\n options.region = region;\r\n }\r\n return geocode(RequestType.PLACE_ID, placeId, options);\r\n}\r\n\r\n/**\r\n * @deprecated use `geocode` instead\r\n * Usage: geocode(\"latlng\", \"40.714224,-73.961452\", *options)\r\n */\r\nexport function fromLatLng(\r\n lat: number,\r\n lng: number,\r\n key?: string,\r\n language?: string,\r\n region?: string,\r\n location_type?: string\r\n) {\r\n const options: GeocodeOptions = {\r\n outputFormat: OutputFormat.JSON,\r\n };\r\n if (key) {\r\n options.key = key;\r\n }\r\n if (language) {\r\n options.language = language;\r\n }\r\n if (region) {\r\n options.region = region;\r\n }\r\n if (location_type) {\r\n options.location_type = location_type;\r\n }\r\n return geocode(RequestType.LATLNG, `${lat},${lng}`, options);\r\n}\r\n\r\ninterface GeocodeResult {\r\n address_components: AddressComponent[];\r\n formatted_address: string;\r\n geometry: Geometry;\r\n place_id: string;\r\n plus_code: PlusCode;\r\n types: string[];\r\n}\r\n\r\ninterface AddressComponent {\r\n long_name: string;\r\n short_name: string;\r\n types: string[];\r\n}\r\n\r\ninterface Geometry {\r\n location: {\r\n lat: number;\r\n lng: number;\r\n };\r\n location_type: string;\r\n viewport: {\r\n lat: number;\r\n lng: number;\r\n };\r\n southwest: {\r\n lat: number;\r\n lng: number;\r\n };\r\n}\r\n\r\ninterface AddressDescriptor {\r\n area: AreaDescriptor[];\r\n landmarks: Landmark[];\r\n}\r\n\r\ninterface AreaDescriptor {\r\n containment: string;\r\n display_name: {\r\n language_code: string;\r\n text: string;\r\n };\r\n place_id: string;\r\n}\r\n\r\ninterface Landmark {\r\n display_name: {\r\n language_code: string;\r\n text: string;\r\n };\r\n straight_line_distance_meters: number;\r\n place_id: string;\r\n travel_distance_meters: number;\r\n spatial_relationship: string;\r\n types: string[];\r\n}\r\n\r\ninterface PlusCode {\r\n compound_code: string;\r\n global_code: string;\r\n}\r\n"],"names":["RequestType","OutputFormat","GOOGLE_GEOCODE_API","defaultOptions","geocodeRequest","queryParams","outputFormat","restParams","queryString","url","json","status","error_message","error","setDefaults","options","setKey","key","setLanguage","language","setRegion","region","setComponents","components","setBounds","bounds","setResultType","resultType","setLocationType","locationType","setOutputFormat","enableAddressDescriptor","geocode","requestType","value","fromAddress","address","fromPlaceId","placeId","fromLatLng","lat","lng","location_type"],"mappings":"wOAGY,IAAAA,GAAAA,IACVA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,SAAW,WAHDA,IAAAA,GAAA,CAAA,CAAA,EASAC,GAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,KAAO,OAFGA,IAAAA,GAAA,CAAA,CAAA,EAQZ,MAAMC,EAAqB,+CAwC3B,IAAIC,EAAiC,CACnC,aAAc,MAChB,EAUA,eAAeC,EACbC,EAC0B,CAC1B,KAAM,CAAE,aAAAC,EAAc,GAAGC,CAAA,EAAeF,EAClCG,EAAc,IAAI,gBACtBD,GACA,SAAS,EACLE,EAAM,GAAGP,CAAkB,IAAII,CAAY,IAAIE,CAAW,GAC5D,GAAA,CAEI,MAAAE,EAAO,MADI,MAAM,MAAMD,CAAG,GACJ,OACtB,CAAE,OAAAE,EAAQ,cAAAC,CAAkB,EAAAF,EAElC,GAAIC,IAAW,KACN,OAAAD,EAGT,MAAM,IAAI,MACR,qBAAqBE,CAAa,iCAAiCD,CAAM,GAAA,QAEpEE,EAAgB,CACvB,MAAIA,aAAiB,MACb,IAAI,MAAM,6BAA6BA,EAAM,OAAO,EAAE,EAExD,IAAI,MAAM,gDAAgDA,CAAK,EAAE,CACzE,CACF,CAOO,SAASC,EAAYC,EAA+B,CACxCZ,EAAA,CACf,GAAGA,EACH,GAAGY,CAAA,CAEP,CAOO,SAASC,EAAOC,EA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qB,EACA,CACA,MAAM3B,EAA0B,CAC9B,aAAc,MAAA,EAEhB,OAAIE,IACFF,EAAQ,IAAME,GAEZE,IACFJ,EAAQ,SAAWI,GAEjBE,IACFN,EAAQ,OAASM,GAEfqB,IACF3B,EAAQ,cAAgB2B,GAEnBV,EAAQ,SAAoB,GAAGQ,CAAG,IAAIC,CAAG,GAAI1B,CAAO,CAC7D"} \ No newline at end of file +{"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * Enum defining possible request types for geocoding.\n */\nexport enum RequestType {\n ADDRESS = \"address\", // Geocoding by address\n LATLNG = \"latlng\", // Geocoding by latitude and longitude\n PLACE_ID = \"place_id\", // Geocoding by place ID\n}\n\n/**\n * Enum defining possible output formats for geocoding.\n */\nexport enum OutputFormat {\n XML = \"xml\", // Output format XML\n JSON = \"json\", // Output format JSON\n}\n\n/**\n * The URL of the Google Geocoding API.\n */\nconst GOOGLE_GEOCODE_API = \"https://maps.googleapis.com/maps/api/geocode\";\n\n/**\n * Options that can be passed to the geocoding requests.\n */\nexport interface GeocodeOptions {\n key?: string; // API key for the Google Maps Geocoding API.\n language?: string; // Language code for the response.\n region?: string; // Region code for the response.\n components?: string; // Component filtering for the response.\n bounds?: string; // Bounding box for the response.\n result_type?: string; // Result type filtering for the response.\n location_type?: string; // Location type filtering for the response.\n outputFormat: OutputFormat; // Desired output format (either XML or JSON)\n enable_address_descriptor?: boolean; // Whether to include an address descriptor in the reverse geocoding response.\n}\n\n/**\n * Response object from the geocoding API.\n */\ninterface GeocodeResponse {\n status: string;\n results: GeocodeResult[];\n address_descriptor?: AddressDescriptor;\n plus_code?: PlusCode;\n error_message?: string;\n}\n\n/**\n * The query parameters for geocoding requests.\n */\ninterface GeocodeQueryParams extends GeocodeOptions {\n place_id?: string; // The plce id to geocode\n address?: string; // The address to geocode\n latlng?: string; // The latitude/longitude of the location to geocode\n}\n\n/**\n * Default options for the geocoding requests.\n */\nlet defaultOptions: GeocodeOptions = {\n outputFormat: OutputFormat.JSON,\n};\n\n/**\n * Performs a geocoding request to the Google Geocoding API.\n * @function geocodeRequest\n * @async\n * @param {GeocodeQueryParams} queryParams - The query parameters for the geocoding request.\n * @returns {Promise} - A promise that resolves with the geocoding response object.\n * @throws {Error} - Throws an error if the geocoding request fails.\n */\nasync function geocodeRequest(\n queryParams: GeocodeQueryParams,\n): Promise {\n const { outputFormat, ...restParams } = queryParams;\n const queryString = new URLSearchParams(\n restParams as Record,\n ).toString();\n const url = `${GOOGLE_GEOCODE_API}/${outputFormat}?${queryString}`;\n try {\n const response = await fetch(url);\n const json = await response.json();\n const { status, error_message } = json;\n\n if (status === \"OK\") {\n return json;\n }\n\n throw new Error(\n `Geocoding failed: ${error_message}. Server returned status code ${status}.`,\n );\n } catch (error: unknown) {\n if (error instanceof Error) {\n throw new Error(`Geocoding request failed: ${error.message}`);\n }\n throw new Error(`Geocoding request failed with unknown error: ${error}`);\n }\n}\n\n/**\n * Sets default options for geocoding requests.\n *\n * @param options - The default options to set.\n */\nexport function setDefaults(options: GeocodeOptions): void {\n defaultOptions = {\n ...defaultOptions,\n ...options,\n };\n}\n\n/**\n * Sets the API key to use for geocoding requests.\n *\n * @param key - The API key to set.\n */\nexport function setKey(key: string): void {\n defaultOptions.key = key;\n}\n\n/**\n * Sets the language to use for geocoding requests.\n *\n * @param language - The language to set.\n */\nexport function setLanguage(language: string): void {\n defaultOptions.language = language;\n}\n\n/**\n * Sets the region code to use for geocoding requests.\n *\n * @param region - The region code to set.\n */\nexport function setRegion(region: string): void {\n defaultOptions.region = region;\n}\n\n/**\n * Sets the component filter to use for geocoding requests.\n *\n * @param components - The component filter to set.\n */\nexport function setComponents(components: string): void {\n defaultOptions.components = components;\n}\n\n/**\n * Sets the bounding box to use for geocoding requests.\n *\n * @param bounds - The bounding box to set.\n */\nexport function setBounds(bounds: string): void {\n defaultOptions.bounds = bounds;\n}\n\n/**\n * Sets the result type filter to use for geocoding requests.\n * One or more address types to return, separated by a pipe (|).\n * Possible values are \"street_address\", \"route\", \"intersection\", \"political\", \"country\",\n * \"administrative_area_level_1\", \"administrative_area_level_2\", \"administrative_area_level_3\",\n * \"administrative_area_level_4\", \"administrative_area_level_5\", \"colloquial_area\", \"locality\",\n * \"ward\", \"sublocality\", \"neighborhood\", \"premise\", \"subpremise\", \"postal_code\", \"natural_feature\",\n * \"airport\", \"park\", \"point_of_interest\", and \"postal_code_prefix\".\n *\n * @param resultType - The result type to set.\n */\nexport function setResultType(resultType: string): void {\n defaultOptions.result_type = resultType;\n}\n\n/**\n * Sets the location type filter to use for geocoding requests.\n * One or more location types to return. Possible values are \"ROOFTOP\",\n * \"RANGE_INTERPOLATED\", \"GEOMETRIC_CENTER\", \"APPROXIMATE\".\n *\n * @param locationType - The location type to set.\n */\nexport function setLocationType(locationType: string): void {\n defaultOptions.location_type = locationType;\n}\n\n/**\n * Sets the desired output format for geocoding requests. The format can be either XML or JSON.\n *\n * @param outputFormat - The desired output format (either OutputFormat.XML or OutputFormat.JSON).\n */\nexport function setOutputFormat(outputFormat: OutputFormat): void {\n defaultOptions.outputFormat = outputFormat;\n}\n\n/**\n * Sets whether to include an address descriptor in the reverse geocoding response.\n *\n * @param enableAddressDescriptor - A boolean parameter indicating whether to include the address descriptor.\n */\nexport function enableAddressDescriptor(\n enableAddressDescriptor: boolean,\n): void {\n defaultOptions.enable_address_descriptor = enableAddressDescriptor;\n}\n\n/**\n * Sends a geocoding request to the Google Maps Geocoding API for a given address and returns the response.\n * @function geocode\n * @async\n * @param {RequestType} requestType - Identifier to specify the type of request (place_id, address, or latlng).\n * @param {string} value - The value to be used for geocoding (address, place_id, or latlng).\n * @param {GeocodeOptions} [options={}] - Additional options for the geocoding request.\n * @returns {Promise} - A promise that resolves with the geocoding response object.\n * @throws {Error} - Throws an error if the address is invalid or the geocoding request fails.\n */\nexport function geocode(\n requestType: RequestType | string,\n value: string,\n options?: GeocodeOptions,\n): Promise {\n if (typeof requestType !== \"string\" || typeof value !== \"string\") {\n throw new Error(\n `Both requestType and value are required and must be of type string. \n requestType: ${typeof requestType}, value: ${typeof value}`,\n );\n }\n\n const queryParams: GeocodeQueryParams = {\n ...defaultOptions,\n ...options,\n [requestType]: value,\n };\n return geocodeRequest(queryParams);\n}\n\n/**\n * @deprecated Use `geocode` instead.\n * Usage: geocode(\"address\", \"Washington\", *options)\n */\nexport function fromAddress(\n address: string,\n key?: string,\n language?: string,\n region?: string,\n) {\n const options: GeocodeOptions = {\n outputFormat: OutputFormat.JSON,\n };\n if (key) {\n options.key = key;\n }\n if (language) {\n options.language = language;\n }\n if (region) {\n options.region = region;\n }\n return geocode(RequestType.ADDRESS, address, options);\n}\n\n/**\n * @deprecated use `geocode` instead\n * Usage: geocode(\"place_id\", \"ChIJd8BlQ2BZwokRAFUEcm_qrcA\", *options)\n */\nexport function fromPlaceId(\n placeId: string,\n key?: string,\n language?: string,\n region?: string,\n) {\n const options: GeocodeOptions = {\n outputFormat: OutputFormat.JSON,\n };\n if (key) {\n options.key = key;\n }\n if (language) {\n options.language = language;\n }\n if (region) {\n options.region = region;\n }\n return geocode(RequestType.PLACE_ID, placeId, options);\n}\n\n/**\n * @deprecated use `geocode` instead\n * Usage: geocode(\"latlng\", \"40.714224,-73.961452\", *options)\n */\nexport function fromLatLng(\n lat: number,\n lng: number,\n key?: string,\n language?: string,\n region?: string,\n location_type?: string,\n) {\n const options: GeocodeOptions = {\n outputFormat: OutputFormat.JSON,\n };\n if (key) {\n options.key = key;\n }\n if (language) {\n options.language = language;\n }\n if (region) {\n options.region = region;\n }\n if (location_type) {\n options.location_type = location_type;\n }\n return geocode(RequestType.LATLNG, `${lat},${lng}`, options);\n}\n\ninterface GeocodeResult {\n address_components: AddressComponent[];\n formatted_address: string;\n geometry: Geometry;\n place_id: string;\n plus_code: PlusCode;\n types: string[];\n}\n\ninterface AddressComponent {\n long_name: string;\n short_name: string;\n types: string[];\n}\n\ninterface Geometry {\n location: {\n lat: number;\n lng: number;\n };\n location_type: string;\n viewport: {\n lat: number;\n lng: number;\n };\n southwest: {\n lat: number;\n lng: number;\n };\n}\n\ninterface AddressDescriptor {\n area: AreaDescriptor[];\n landmarks: Landmark[];\n}\n\ninterface AreaDescriptor {\n containment: string;\n display_name: {\n language_code: string;\n text: string;\n };\n place_id: string;\n}\n\ninterface Landmark {\n display_name: {\n language_code: string;\n text: string;\n };\n straight_line_distance_meters: number;\n place_id: string;\n travel_distance_meters: number;\n spatial_relationship: string;\n types: string[];\n}\n\ninterface PlusCode {\n compound_code: string;\n global_code: string;\n}\n"],"names":["RequestType","OutputFormat","GOOGLE_GEOCODE_API","defaultOptions","geocodeRequest","queryParams","outputFormat","restParams","queryString","url","json","status","error_message","error","setDefaults","options","setKey","key","setLanguage","language","setRegion","region","setComponents","components","setBounds","bounds","setResultType","resultType","setLocationType","locationType","setOutputFormat","enableAddressDescriptor","geocode","requestType","value","fromAddress","address","fromPlaceId","placeId","fromLatLng","lat","lng","location_type"],"mappings":"wOAGY,IAAAA,GAAAA,IACVA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,SAAW,WAHDA,IAAAA,GAAA,CAAA,CAAA,EASAC,GAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,KAAO,OAFGA,IAAAA,GAAA,CAAA,CAAA,EAQZ,MAAMC,EAAqB,+CAwC3B,IAAIC,EAAiC,CACnC,aAAc,MAChB,EAUA,eAAeC,EACbC,EAC0B,CAC1B,KAAM,CAAE,aAAAC,EAAc,GAAGC,CAAA,EAAeF,EAClCG,EAAc,IAAI,gBACtBD,GACA,SAAS,EACLE,EAAM,GAAGP,CAAkB,IAAII,CAAY,IAAIE,CAAW,GAC5D,GAAA,CAEI,MAAAE,EAAO,MADI,MAAM,MAAMD,CAAG,GACJ,OACtB,CAAE,OAAAE,EAAQ,cAAAC,CAAkB,EAAAF,EAElC,GAAIC,IAAW,KACN,OAAAD,EAGT,MAAM,IAAI,MACR,qBAAqBE,CAAa,iCAAiCD,CAAM,GAAA,QAEpEE,EAAgB,CACv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MN,EAA0B,CAC9B,aAAc,MAAA,EAEhB,OAAIE,IACFF,EAAQ,IAAME,GAEZE,IACFJ,EAAQ,SAAWI,GAEjBE,IACFN,EAAQ,OAASM,GAEZW,EAAQ,WAAsBM,EAASvB,CAAO,CACvD,CAMO,SAASwB,EACdC,EACAC,EACAxB,EACAE,EACAE,EACAqB,EACA,CACA,MAAM3B,EAA0B,CAC9B,aAAc,MAAA,EAEhB,OAAIE,IACFF,EAAQ,IAAME,GAEZE,IACFJ,EAAQ,SAAWI,GAEjBE,IACFN,EAAQ,OAASM,GAEfqB,IACF3B,EAAQ,cAAgB2B,GAEnBV,EAAQ,SAAoB,GAAGQ,CAAG,IAAIC,CAAG,GAAI1B,CAAO,CAC7D"} \ No newline at end of file diff --git a/package.json b/package.json index 75af827..e5b21c4 100644 --- a/package.json +++ b/package.json @@ -34,10 +34,12 @@ }, "homepage": "https://github.com/shukerullah/react-geocode#readme", "scripts": { - "build": "vite build" + "build": "vite build", + "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx}\"" }, "devDependencies": { "@types/node": "^20.16.11", + "prettier": "^3.3.3", "typescript": "^5.6.3", "vite": "^5.4.9", "vite-plugin-dts": "^4.2.4" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a543312..8c341db 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@types/node': specifier: ^20.16.11 version: 20.16.11 + prettier: + specifier: ^3.3.3 + version: 3.3.3 typescript: specifier: ^5.6.3 version: 5.6.3 @@ -526,6 +529,11 @@ packages: resolution: {integrity: sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==} engines: {node: ^10 || ^12 || >=14} + prettier@3.3.3: + resolution: {integrity: sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==} + engines: {node: '>=14'} + hasBin: true + punycode@2.3.1: resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} @@ -1094,6 +1102,8 @@ snapshots: picocolors: 1.1.0 source-map-js: 1.2.1 + prettier@3.3.3: {} + punycode@2.3.1: {} require-from-string@2.0.2: {} diff --git a/src/index.ts b/src/index.ts index 239ba50..517c3de 100644 --- a/src/index.ts +++ b/src/index.ts @@ -71,11 +71,11 @@ let defaultOptions: GeocodeOptions = { * @throws {Error} - Throws an error if the geocoding request fails. */ async function geocodeRequest( - queryParams: GeocodeQueryParams + queryParams: GeocodeQueryParams, ): Promise { const { outputFormat, ...restParams } = queryParams; const queryString = new URLSearchParams( - restParams as Record + restParams as Record, ).toString(); const url = `${GOOGLE_GEOCODE_API}/${outputFormat}?${queryString}`; try { @@ -88,7 +88,7 @@ async function geocodeRequest( } throw new Error( - `Geocoding failed: ${error_message}. Server returned status code ${status}.` + `Geocoding failed: ${error_message}. Server returned status code ${status}.`, ); } catch (error: unknown) { if (error instanceof Error) { @@ -196,7 +196,7 @@ export function setOutputFormat(outputFormat: OutputFormat): void { * @param enableAddressDescriptor - A boolean parameter indicating whether to include the address descriptor. */ export function enableAddressDescriptor( - enableAddressDescriptor: boolean + enableAddressDescriptor: boolean, ): void { defaultOptions.enable_address_descriptor = enableAddressDescriptor; } @@ -214,12 +214,12 @@ export function enableAddressDescriptor( export function geocode( requestType: RequestType | string, value: string, - options?: GeocodeOptions + options?: GeocodeOptions, ): Promise { if (typeof requestType !== "string" || typeof value !== "string") { throw new Error( `Both requestType and value are required and must be of type string. - requestType: ${typeof requestType}, value: ${typeof value}` + requestType: ${typeof requestType}, value: ${typeof value}`, ); } @@ -239,7 +239,7 @@ export function fromAddress( address: string, key?: string, language?: string, - region?: string + region?: string, ) { const options: GeocodeOptions = { outputFormat: OutputFormat.JSON, @@ -264,7 +264,7 @@ export function fromPlaceId( placeId: string, key?: string, language?: string, - region?: string + region?: string, ) { const options: GeocodeOptions = { outputFormat: OutputFormat.JSON, @@ -291,7 +291,7 @@ export function fromLatLng( key?: string, language?: string, region?: string, - location_type?: string + location_type?: string, ) { const options: GeocodeOptions = { outputFormat: OutputFormat.JSON, From dea51b95437b216088c7bf3592db76464e8baa73 Mon Sep 17 00:00:00 2001 From: Sam Svindland Date: Wed, 16 Oct 2024 09:49:03 -0400 Subject: [PATCH 7/8] fix types --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e5b21c4..3d354a9 100644 --- a/package.json +++ b/package.json @@ -5,13 +5,13 @@ "packageManager": "pnpm@9.12.0", "main": "dist/index.umd.js", "module": "dist/index.es.js", - "types": "index.d.ts", + "types": "dist/index.d.ts", "type": "module", "export": { ".": { "import": "./dist/index.es.js", "require": "./dist/index.umd.js", - "types": "./index.d.ts" + "types": "./dist/index.d.ts" } }, "files": [ From ffda35b6200530bfc19b12a2ca80b7ce411a41d2 Mon Sep 17 00:00:00 2001 From: Sam Svindland Date: Wed, 19 Feb 2025 16:16:10 -0500 Subject: [PATCH 8/8] remove dist and revert change to .gitignore --- .gitignore | 3 ++ dist/index.d.ts | 34 -------------- dist/index.es.js | 107 ------------------------------------------ dist/index.es.js.map | 1 - dist/index.umd.js | 3 -- dist/index.umd.js.map | 1 - 6 files changed, 3 insertions(+), 146 deletions(-) delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.es.js delete mode 100644 dist/index.es.js.map delete mode 100644 dist/index.umd.js delete mode 100644 dist/index.umd.js.map diff --git a/.gitignore b/.gitignore index 09c6bfa..3fd2583 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ npm-debug.log yarn-error.log yarn.lock +# Build output +/dist + # IDE and editor files .vscode/ .idea/ diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 3104c94..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,34 +0,0 @@ -export declare enum RequestType { - ADDRESS = "address", - LATLNG = "latlng", - PLACE_ID = "place_id" -} -export declare enum OutputFormat { - XML = "xml", - JSON = "json" -} -export interface GeocodeOptions { - key?: string; - language?: string; - region?: string; - components?: string; - bounds?: string; - result_type?: string; - location_type?: string; - outputFormat: OutputFormat; - enable_address_descriptor?: boolean; -} -export declare function setDefaults(options: GeocodeOptions): void; -export declare function setKey(key: string): void; -export declare function setLanguage(language: string): void; -export declare function setRegion(region: string): void; -export declare function setComponents(components: string): void; -export declare function setBounds(bounds: string): void; -export declare function setResultType(resultType: string): void; -export declare function setLocationType(locationType: string): void; -export declare function setOutputFormat(outputFormat: OutputFormat): void; -export declare function enableAddressDescriptor(enableAddressDescriptor: boolean): void; -export declare function geocode(requestType: RequestType | string, value: string, options?: GeocodeOptions): Promise; -export declare function fromAddress(address: string, key?: string, language?: string, region?: string): Promise; -export declare function fromPlaceId(placeId: string, key?: string, language?: string, region?: string): Promise; -export declare function fromLatLng(lat: number, lng: number, key?: string, language?: string, region?: string, location_type?: string): Promise; diff --git a/dist/index.es.js b/dist/index.es.js deleted file mode 100644 index b3b7e1a..0000000 --- a/dist/index.es.js +++ /dev/null @@ -1,107 +0,0 @@ -var d = /* @__PURE__ */ ((t) => (t.ADDRESS = "address", t.LATLNG = "latlng", t.PLACE_ID = "place_id", t))(d || {}), p = /* @__PURE__ */ ((t) => (t.XML = "xml", t.JSON = "json", t))(p || {}); -const g = "https://maps.googleapis.com/maps/api/geocode"; -let s = { - outputFormat: "json" - /* JSON */ -}; -async function l(t) { - const { outputFormat: n, ...e } = t, r = new URLSearchParams( - e - ).toString(), o = `${g}/${n}?${r}`; - try { - const i = await (await fetch(o)).json(), { status: c, error_message: f } = i; - if (c === "OK") - return i; - throw new Error( - `Geocoding failed: ${f}. Server returned status code ${c}.` - ); - } catch (a) { - throw a instanceof Error ? new Error(`Geocoding request failed: ${a.message}`) : new Error(`Geocoding request failed with unknown error: ${a}`); - } -} -function m(t) { - s = { - ...s, - ...t - }; -} -function w(t) { - s.key = t; -} -function y(t) { - s.language = t; -} -function $(t) { - s.region = t; -} -function h(t) { - s.components = t; -} -function E(t) { - s.bounds = t; -} -function L(t) { - s.result_type = t; -} -function _(t) { - s.location_type = t; -} -function j(t) { - s.outputFormat = t; -} -function G(t) { - s.enable_address_descriptor = t; -} -function u(t, n, e) { - if (typeof t != "string" || typeof n != "string") - throw new Error( - `Both requestType and value are required and must be of type string. - requestType: ${typeof t}, value: ${typeof n}` - ); - const r = { - ...s, - ...e, - [t]: n - }; - return l(r); -} -function O(t, n, e, r) { - const o = { - outputFormat: "json" - /* JSON */ - }; - return n && (o.key = n), e && (o.language = e), r && (o.region = r), u("address", t, o); -} -function S(t, n, e, r) { - const o = { - outputFormat: "json" - /* JSON */ - }; - return n && (o.key = n), e && (o.language = e), r && (o.region = r), u("place_id", t, o); -} -function A(t, n, e, r, o, a) { - const i = { - outputFormat: "json" - /* JSON */ - }; - return e && (i.key = e), r && (i.language = r), o && (i.region = o), a && (i.location_type = a), u("latlng", `${t},${n}`, i); -} -export { - p as OutputFormat, - d as RequestType, - G as enableAddressDescriptor, - O as fromAddress, - A as fromLatLng, - S as fromPlaceId, - u as geocode, - E as setBounds, - h as setComponents, - m as setDefaults, - w as setKey, - y as setLanguage, - _ as setLocationType, - j as setOutputFormat, - $ as setRegion, - L as setResultType -}; -//# sourceMappingURL=index.es.js.map diff --git a/dist/index.es.js.map b/dist/index.es.js.map deleted file mode 100644 index c85e3c5..0000000 --- a/dist/index.es.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.es.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * Enum defining possible request types for geocoding.\n */\nexport enum RequestType {\n ADDRESS = \"address\", // Geocoding by address\n LATLNG = \"latlng\", // Geocoding by latitude and longitude\n PLACE_ID = \"place_id\", // Geocoding by place ID\n}\n\n/**\n * Enum defining possible output formats for geocoding.\n */\nexport enum OutputFormat {\n XML = \"xml\", // Output format XML\n JSON = \"json\", // Output format JSON\n}\n\n/**\n * The URL of the Google Geocoding API.\n */\nconst GOOGLE_GEOCODE_API = \"https://maps.googleapis.com/maps/api/geocode\";\n\n/**\n * Options that can be passed to the geocoding requests.\n */\nexport interface GeocodeOptions {\n key?: string; // API key for the Google Maps Geocoding API.\n language?: string; // Language code for the response.\n region?: string; // Region code for the response.\n components?: string; // Component filtering for the response.\n bounds?: string; // Bounding box for the response.\n result_type?: string; // Result type filtering for the response.\n location_type?: string; // Location type filtering for the response.\n outputFormat: OutputFormat; // Desired output format (either XML or JSON)\n enable_address_descriptor?: boolean; // Whether to include an address descriptor in the reverse geocoding response.\n}\n\n/**\n * Response object from the geocoding API.\n */\ninterface GeocodeResponse {\n status: string;\n results: GeocodeResult[];\n address_descriptor?: AddressDescriptor;\n plus_code?: PlusCode;\n error_message?: string;\n}\n\n/**\n * The query parameters for geocoding requests.\n */\ninterface GeocodeQueryParams extends GeocodeOptions {\n place_id?: string; // The plce id to geocode\n address?: string; // The address to geocode\n latlng?: string; // The latitude/longitude of the location to geocode\n}\n\n/**\n * Default options for the geocoding requests.\n */\nlet defaultOptions: GeocodeOptions = {\n outputFormat: OutputFormat.JSON,\n};\n\n/**\n * Performs a geocoding request to the Google Geocoding API.\n * @function geocodeRequest\n * @async\n * @param {GeocodeQueryParams} queryParams - The query parameters for the geocoding request.\n * @returns {Promise} - A promise that resolves with the geocoding response object.\n * @throws {Error} - Throws an error if the geocoding request fails.\n */\nasync function geocodeRequest(\n queryParams: GeocodeQueryParams,\n): Promise {\n const { outputFormat, ...restParams } = queryParams;\n const queryString = new URLSearchParams(\n restParams as Record,\n ).toString();\n const url = `${GOOGLE_GEOCODE_API}/${outputFormat}?${queryString}`;\n try {\n const response = await fetch(url);\n const json = await response.json();\n const { status, error_message } = json;\n\n if (status === \"OK\") {\n return json;\n }\n\n throw new Error(\n `Geocoding failed: ${error_message}. Server returned status code ${status}.`,\n );\n } catch (error: unknown) {\n if (error instanceof Error) {\n throw new Error(`Geocoding request failed: ${error.message}`);\n }\n throw new Error(`Geocoding request failed with unknown error: ${error}`);\n }\n}\n\n/**\n * Sets default options for geocoding requests.\n *\n * @param options - The default options to set.\n */\nexport function setDefaults(options: GeocodeOptions): void {\n defaultOptions = {\n ...defaultOptions,\n ...options,\n };\n}\n\n/**\n * Sets the API key to use for geocoding requests.\n *\n * @param key - The API key to set.\n */\nexport function setKey(key: string): void {\n defaultOptions.key = key;\n}\n\n/**\n * Sets the language to use for geocoding requests.\n *\n * @param language - The language to set.\n */\nexport function setLanguage(language: string): void {\n defaultOptions.language = language;\n}\n\n/**\n * Sets the region code to use for geocoding requests.\n *\n * @param region - The region code to set.\n */\nexport function setRegion(region: string): void {\n defaultOptions.region = region;\n}\n\n/**\n * Sets the component filter to use for geocoding requests.\n *\n * @param components - The component filter to set.\n */\nexport function setComponents(components: string): void {\n defaultOptions.components = components;\n}\n\n/**\n * Sets the bounding box to use for geocoding requests.\n *\n * @param bounds - The bounding box to set.\n */\nexport function setBounds(bounds: string): void {\n defaultOptions.bounds = bounds;\n}\n\n/**\n * Sets the result type filter to use for geocoding requests.\n * One or more address types to return, separated by a pipe (|).\n * Possible values are \"street_address\", \"route\", \"intersection\", \"political\", \"country\",\n * \"administrative_area_level_1\", \"administrative_area_level_2\", \"administrative_area_level_3\",\n * \"administrative_area_level_4\", \"administrative_area_level_5\", \"colloquial_area\", \"locality\",\n * \"ward\", \"sublocality\", \"neighborhood\", \"premise\", \"subpremise\", \"postal_code\", \"natural_feature\",\n * \"airport\", \"park\", \"point_of_interest\", and \"postal_code_prefix\".\n *\n * @param resultType - The result type to set.\n */\nexport function setResultType(resultType: string): void {\n defaultOptions.result_type = resultType;\n}\n\n/**\n * Sets the location type filter to use for geocoding requests.\n * One or more location types to return. Possible values are \"ROOFTOP\",\n * \"RANGE_INTERPOLATED\", \"GEOMETRIC_CENTER\", \"APPROXIMATE\".\n *\n * @param locationType - The location type to set.\n */\nexport function setLocationType(locationType: string): void {\n defaultOptions.location_type = locationType;\n}\n\n/**\n * Sets the desired output format for geocoding requests. The format can be either XML or JSON.\n *\n * @param outputFormat - The desired output format (either OutputFormat.XML or OutputFormat.JSON).\n */\nexport function setOutputFormat(outputFormat: OutputFormat): void {\n defaultOptions.outputFormat = outputFormat;\n}\n\n/**\n * Sets whether to include an address descriptor in the reverse geocoding response.\n *\n * @param enableAddressDescriptor - A boolean parameter indicating whether to include the address descriptor.\n */\nexport function enableAddressDescriptor(\n enableAddressDescriptor: boolean,\n): void {\n defaultOptions.enable_address_descriptor = enableAddressDescriptor;\n}\n\n/**\n * Sends a geocoding request to the Google Maps Geocoding API for a given address and returns the response.\n * @function geocode\n * @async\n * @param {RequestType} requestType - Identifier to specify the type of request (place_id, address, or latlng).\n * @param {string} value - The value to be used for geocoding (address, place_id, or latlng).\n * @param {GeocodeOptions} [options={}] - Additional options for the geocoding request.\n * @returns {Promise} - A promise that resolves with the geocoding response object.\n * @throws {Error} - Throws an error if the address is invalid or the geocoding request fails.\n */\nexport function geocode(\n requestType: RequestType | string,\n value: string,\n options?: GeocodeOptions,\n): Promise {\n if (typeof requestType !== \"string\" || typeof value !== \"string\") {\n throw new Error(\n `Both requestType and value are required and must be of type string. \n requestType: ${typeof requestType}, value: ${typeof value}`,\n );\n }\n\n const queryParams: GeocodeQueryParams = {\n ...defaultOptions,\n ...options,\n [requestType]: value,\n };\n return geocodeRequest(queryParams);\n}\n\n/**\n * @deprecated Use `geocode` instead.\n * Usage: geocode(\"address\", \"Washington\", *options)\n */\nexport function fromAddress(\n address: string,\n key?: string,\n language?: string,\n region?: string,\n) {\n const options: GeocodeOptions = {\n outputFormat: OutputFormat.JSON,\n };\n if (key) {\n options.key = key;\n }\n if (language) {\n options.language = language;\n }\n if (region) {\n options.region = region;\n }\n return geocode(RequestType.ADDRESS, address, options);\n}\n\n/**\n * @deprecated use `geocode` instead\n * Usage: geocode(\"place_id\", \"ChIJd8BlQ2BZwokRAFUEcm_qrcA\", *options)\n */\nexport function fromPlaceId(\n placeId: string,\n key?: string,\n language?: string,\n region?: string,\n) {\n const options: GeocodeOptions = {\n outputFormat: OutputFormat.JSON,\n };\n if (key) {\n options.key = key;\n }\n if (language) {\n options.language = language;\n }\n if (region) {\n options.region = region;\n }\n return geocode(RequestType.PLACE_ID, placeId, options);\n}\n\n/**\n * @deprecated use `geocode` instead\n * Usage: geocode(\"latlng\", \"40.714224,-73.961452\", *options)\n */\nexport function fromLatLng(\n lat: number,\n lng: number,\n key?: string,\n language?: string,\n region?: string,\n location_type?: string,\n) {\n const options: GeocodeOptions = {\n outputFormat: OutputFormat.JSON,\n };\n if (key) {\n options.key = key;\n }\n if (language) {\n options.language = language;\n }\n if (region) {\n options.region = region;\n }\n if (location_type) {\n options.location_type = location_type;\n }\n return geocode(RequestType.LATLNG, `${lat},${lng}`, options);\n}\n\ninterface GeocodeResult {\n address_components: AddressComponent[];\n formatted_address: string;\n geometry: Geometry;\n place_id: string;\n plus_code: PlusCode;\n types: string[];\n}\n\ninterface AddressComponent {\n long_name: string;\n short_name: string;\n types: string[];\n}\n\ninterface Geometry {\n location: {\n lat: number;\n lng: number;\n };\n location_type: string;\n viewport: {\n lat: number;\n lng: number;\n };\n southwest: {\n lat: number;\n lng: number;\n };\n}\n\ninterface AddressDescriptor {\n area: AreaDescriptor[];\n landmarks: Landmark[];\n}\n\ninterface AreaDescriptor {\n containment: string;\n display_name: {\n language_code: string;\n text: string;\n };\n place_id: string;\n}\n\ninterface Landmark {\n display_name: {\n language_code: string;\n text: string;\n };\n straight_line_distance_meters: number;\n place_id: string;\n travel_distance_meters: number;\n spatial_relationship: string;\n types: string[];\n}\n\ninterface PlusCode {\n compound_code: string;\n global_code: string;\n}\n"],"names":["RequestType","OutputFormat","GOOGLE_GEOCODE_API","defaultOptions","geocodeRequest","queryParams","outputFormat","restParams","queryString","url","json","status","error_message","error","setDefaults","options","setKey","key","setLanguage","language","setRegion","region","setComponents","components","setBounds","bounds","setResultType","resultType","setLocationType","locationType","setOutputFormat","enableAddressDescriptor","geocode","requestType","value","fromAddress","address","fromPlaceId","placeId","fromLatLng","lat","lng","location_type"],"mappings":"AAGY,IAAAA,sBAAAA,OACVA,EAAA,UAAU,WACVA,EAAA,SAAS,UACTA,EAAA,WAAW,YAHDA,IAAAA,KAAA,CAAA,CAAA,GASAC,sBAAAA,OACVA,EAAA,MAAM,OACNA,EAAA,OAAO,QAFGA,IAAAA,KAAA,CAAA,CAAA;AAQZ,MAAMC,IAAqB;AAwC3B,IAAIC,IAAiC;AAAA,EACnC,cAAc;AAAA;AAChB;AAUA,eAAeC,EACbC,GAC0B;AAC1B,QAAM,EAAE,cAAAC,GAAc,GAAGC,EAAA,IAAeF,GAClCG,IAAc,IAAI;AAAA,IACtBD;AAAA,IACA,SAAS,GACLE,IAAM,GAAGP,CAAkB,IAAII,CAAY,IAAIE,CAAW;AAC5D,MAAA;AAEI,UAAAE,IAAO,OADI,MAAM,MAAMD,CAAG,GACJ,QACtB,EAAE,QAAAE,GAAQ,eAAAC,EAAkB,IAAAF;AAElC,QAAIC,MAAW;AACN,aAAAD;AAGT,UAAM,IAAI;AAAA,MACR,qBAAqBE,CAAa,iCAAiCD,CAAM;AAAA,IAAA;AAAA,WAEpEE,GAAgB;AACvB,UAAIA,aAAiB,QACb,IAAI,MAAM,6BAA6BA,EAAM,OAAO,EAAE,IAExD,IAAI,MAAM,gDAAgDA,CAAK,EAAE;AAAA,EACzE;AACF;AAOO,SAASC,EAAYC,GAA+B;AACxC,EAAAZ,IAAA;AAAA,IACf,GAAGA;AAAA,IACH,GAAGY;AAAA,EAAA;AAEP;AAOO,SAASC,EAAOC,GAAmB;AACxC,EAAAd,EAAe,MAAMc;AACvB;AAOO,SAASC,EAAYC,GAAwB;AAClD,EAAAhB,EAAe,WAAWgB;AAC5B;AAOO,SAASC,EAAUC,GAAsB;AAC9C,EAAAlB,EAAe,SAASkB;AAC1B;AAOO,SAASC,EAAcC,GAA0B;AACtD,EAAApB,EAAe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MACFF,EAAQ,MAAME,IAEZE,MACFJ,EAAQ,WAAWI,IAEjBE,MACFN,EAAQ,SAASM,IAEfqB,MACF3B,EAAQ,gBAAgB2B,IAEnBV,EAAQ,UAAoB,GAAGQ,CAAG,IAAIC,CAAG,IAAI1B,CAAO;AAC7D;"} \ No newline at end of file diff --git a/dist/index.umd.js b/dist/index.umd.js deleted file mode 100644 index b37267f..0000000 --- a/dist/index.umd.js +++ /dev/null @@ -1,3 +0,0 @@ -(function(t,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(t=typeof globalThis<"u"?globalThis:t||self,f(t["react-geocode"]={}))})(this,function(t){"use strict";var f=(e=>(e.ADDRESS="address",e.LATLNG="latlng",e.PLACE_ID="place_id",e))(f||{}),d=(e=>(e.XML="xml",e.JSON="json",e))(d||{});const l="https://maps.googleapis.com/maps/api/geocode";let s={outputFormat:"json"};async function m(e){const{outputFormat:o,...r}=e,i=new URLSearchParams(r).toString(),n=`${l}/${o}?${i}`;try{const u=await(await fetch(n)).json(),{status:g,error_message:D}=u;if(g==="OK")return u;throw new Error(`Geocoding failed: ${D}. Server returned status code ${g}.`)}catch(a){throw a instanceof Error?new Error(`Geocoding request failed: ${a.message}`):new Error(`Geocoding request failed with unknown error: ${a}`)}}function p(e){s={...s,...e}}function y(e){s.key=e}function L(e){s.language=e}function h(e){s.region=e}function w(e){s.components=e}function $(e){s.bounds=e}function E(e){s.result_type=e}function O(e){s.location_type=e}function _(e){s.outputFormat=e}function j(e){s.enable_address_descriptor=e}function c(e,o,r){if(typeof e!="string"||typeof o!="string")throw new Error(`Both requestType and value are required and must be of type string. - requestType: ${typeof e}, value: ${typeof o}`);const i={...s,...r,[e]:o};return m(i)}function S(e,o,r,i){const n={outputFormat:"json"};return o&&(n.key=o),r&&(n.language=r),i&&(n.region=i),c("address",e,n)}function b(e,o,r,i){const n={outputFormat:"json"};return o&&(n.key=o),r&&(n.language=r),i&&(n.region=i),c("place_id",e,n)}function A(e,o,r,i,n,a){const u={outputFormat:"json"};return r&&(u.key=r),i&&(u.language=i),n&&(u.region=n),a&&(u.location_type=a),c("latlng",`${e},${o}`,u)}t.OutputFormat=d,t.RequestType=f,t.enableAddressDescriptor=j,t.fromAddress=S,t.fromLatLng=A,t.fromPlaceId=b,t.geocode=c,t.setBounds=$,t.setComponents=w,t.setDefaults=p,t.setKey=y,t.setLanguage=L,t.setLocationType=O,t.setOutputFormat=_,t.setRegion=h,t.setResultType=E,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}); -//# sourceMappingURL=index.umd.js.map diff --git a/dist/index.umd.js.map b/dist/index.umd.js.map deleted file mode 100644 index 6def974..0000000 --- a/dist/index.umd.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * Enum defining possible request types for geocoding.\n */\nexport enum RequestType {\n ADDRESS = \"address\", // Geocoding by address\n LATLNG = \"latlng\", // Geocoding by latitude and longitude\n PLACE_ID = \"place_id\", // Geocoding by place ID\n}\n\n/**\n * Enum defining possible output formats for geocoding.\n */\nexport enum OutputFormat {\n XML = \"xml\", // Output format XML\n JSON = \"json\", // Output format JSON\n}\n\n/**\n * The URL of the Google Geocoding API.\n */\nconst GOOGLE_GEOCODE_API = \"https://maps.googleapis.com/maps/api/geocode\";\n\n/**\n * Options that can be passed to the geocoding requests.\n */\nexport interface GeocodeOptions {\n key?: string; // API key for the Google Maps Geocoding API.\n language?: string; // Language code for the response.\n region?: string; // Region code for the response.\n components?: string; // Component filtering for the response.\n bounds?: string; // Bounding box for the response.\n result_type?: string; // Result type filtering for the response.\n location_type?: string; // Location type filtering for the response.\n outputFormat: OutputFormat; // Desired output format (either XML or JSON)\n enable_address_descriptor?: boolean; // Whether to include an address descriptor in the reverse geocoding response.\n}\n\n/**\n * Response object from the geocoding API.\n */\ninterface GeocodeResponse {\n status: string;\n results: GeocodeResult[];\n address_descriptor?: AddressDescriptor;\n plus_code?: PlusCode;\n error_message?: string;\n}\n\n/**\n * The query parameters for geocoding requests.\n */\ninterface GeocodeQueryParams extends GeocodeOptions {\n place_id?: string; // The plce id to geocode\n address?: string; // The address to geocode\n latlng?: string; // The latitude/longitude of the location to geocode\n}\n\n/**\n * Default options for the geocoding requests.\n */\nlet defaultOptions: GeocodeOptions = {\n outputFormat: OutputFormat.JSON,\n};\n\n/**\n * Performs a geocoding request to the Google Geocoding API.\n * @function geocodeRequest\n * @async\n * @param {GeocodeQueryParams} queryParams - The query parameters for the geocoding request.\n * @returns {Promise} - A promise that resolves with the geocoding response object.\n * @throws {Error} - Throws an error if the geocoding request fails.\n */\nasync function geocodeRequest(\n queryParams: GeocodeQueryParams,\n): Promise {\n const { outputFormat, ...restParams } = queryParams;\n const queryString = new URLSearchParams(\n restParams as Record,\n ).toString();\n const url = `${GOOGLE_GEOCODE_API}/${outputFormat}?${queryString}`;\n try {\n const response = await fetch(url);\n const json = await response.json();\n const { status, error_message } = json;\n\n if (status === \"OK\") {\n return json;\n }\n\n throw new Error(\n `Geocoding failed: ${error_message}. Server returned status code ${status}.`,\n );\n } catch (error: unknown) {\n if (error instanceof Error) {\n throw new Error(`Geocoding request failed: ${error.message}`);\n }\n throw new Error(`Geocoding request failed with unknown error: ${error}`);\n }\n}\n\n/**\n * Sets default options for geocoding requests.\n *\n * @param options - The default options to set.\n */\nexport function setDefaults(options: GeocodeOptions): void {\n defaultOptions = {\n ...defaultOptions,\n ...options,\n };\n}\n\n/**\n * Sets the API key to use for geocoding requests.\n *\n * @param key - The API key to set.\n */\nexport function setKey(key: string): void {\n defaultOptions.key = key;\n}\n\n/**\n * Sets the language to use for geocoding requests.\n *\n * @param language - The language to set.\n */\nexport function setLanguage(language: string): void {\n defaultOptions.language = language;\n}\n\n/**\n * Sets the region code to use for geocoding requests.\n *\n * @param region - The region code to set.\n */\nexport function setRegion(region: string): void {\n defaultOptions.region = region;\n}\n\n/**\n * Sets the component filter to use for geocoding requests.\n *\n * @param components - The component filter to set.\n */\nexport function setComponents(components: string): void {\n defaultOptions.components = components;\n}\n\n/**\n * Sets the bounding box to use for geocoding requests.\n *\n * @param bounds - The bounding box to set.\n */\nexport function setBounds(bounds: string): void {\n defaultOptions.bounds = bounds;\n}\n\n/**\n * Sets the result type filter to use for geocoding requests.\n * One or more address types to return, separated by a pipe (|).\n * Possible values are \"street_address\", \"route\", \"intersection\", \"political\", \"country\",\n * \"administrative_area_level_1\", \"administrative_area_level_2\", \"administrative_area_level_3\",\n * \"administrative_area_level_4\", \"administrative_area_level_5\", \"colloquial_area\", \"locality\",\n * \"ward\", \"sublocality\", \"neighborhood\", \"premise\", \"subpremise\", \"postal_code\", \"natural_feature\",\n * \"airport\", \"park\", \"point_of_interest\", and \"postal_code_prefix\".\n *\n * @param resultType - The result type to set.\n */\nexport function setResultType(resultType: string): void {\n defaultOptions.result_type = resultType;\n}\n\n/**\n * Sets the location type filter to use for geocoding requests.\n * One or more location types to return. Possible values are \"ROOFTOP\",\n * \"RANGE_INTERPOLATED\", \"GEOMETRIC_CENTER\", \"APPROXIMATE\".\n *\n * @param locationType - The location type to set.\n */\nexport function setLocationType(locationType: string): void {\n defaultOptions.location_type = locationType;\n}\n\n/**\n * Sets the desired output format for geocoding requests. The format can be either XML or JSON.\n *\n * @param outputFormat - The desired output format (either OutputFormat.XML or OutputFormat.JSON).\n */\nexport function setOutputFormat(outputFormat: OutputFormat): void {\n defaultOptions.outputFormat = outputFormat;\n}\n\n/**\n * Sets whether to include an address descriptor in the reverse geocoding response.\n *\n * @param enableAddressDescriptor - A boolean parameter indicating whether to include the address descriptor.\n */\nexport function enableAddressDescriptor(\n enableAddressDescriptor: boolean,\n): void {\n defaultOptions.enable_address_descriptor = enableAddressDescriptor;\n}\n\n/**\n * Sends a geocoding request to the Google Maps Geocoding API for a given address and returns the response.\n * @function geocode\n * @async\n * @param {RequestType} requestType - Identifier to specify the type of request (place_id, address, or latlng).\n * @param {string} value - The value to be used for geocoding (address, place_id, or latlng).\n * @param {GeocodeOptions} [options={}] - Additional options for the geocoding request.\n * @returns {Promise} - A promise that resolves with the geocoding response object.\n * @throws {Error} - Throws an error if the address is invalid or the geocoding request fails.\n */\nexport function geocode(\n requestType: RequestType | string,\n value: string,\n options?: GeocodeOptions,\n): Promise {\n if (typeof requestType !== \"string\" || typeof value !== \"string\") {\n throw new Error(\n `Both requestType and value are required and must be of type string. \n requestType: ${typeof requestType}, value: ${typeof value}`,\n );\n }\n\n const queryParams: GeocodeQueryParams = {\n ...defaultOptions,\n ...options,\n [requestType]: value,\n };\n return geocodeRequest(queryParams);\n}\n\n/**\n * @deprecated Use `geocode` instead.\n * Usage: geocode(\"address\", \"Washington\", *options)\n */\nexport function fromAddress(\n address: string,\n key?: string,\n language?: string,\n region?: string,\n) {\n const options: GeocodeOptions = {\n outputFormat: OutputFormat.JSON,\n };\n if (key) {\n options.key = key;\n }\n if (language) {\n options.language = language;\n }\n if (region) {\n options.region = region;\n }\n return geocode(RequestType.ADDRESS, address, options);\n}\n\n/**\n * @deprecated use `geocode` instead\n * Usage: geocode(\"place_id\", \"ChIJd8BlQ2BZwokRAFUEcm_qrcA\", *options)\n */\nexport function fromPlaceId(\n placeId: string,\n key?: string,\n language?: string,\n region?: string,\n) {\n const options: GeocodeOptions = {\n outputFormat: OutputFormat.JSON,\n };\n if (key) {\n options.key = key;\n }\n if (language) {\n options.language = language;\n }\n if (region) {\n options.region = region;\n }\n return geocode(RequestType.PLACE_ID, placeId, options);\n}\n\n/**\n * @deprecated use `geocode` instead\n * Usage: geocode(\"latlng\", \"40.714224,-73.961452\", *options)\n */\nexport function fromLatLng(\n lat: number,\n lng: number,\n key?: string,\n language?: string,\n region?: string,\n location_type?: string,\n) {\n const options: GeocodeOptions = {\n outputFormat: OutputFormat.JSON,\n };\n if (key) {\n options.key = key;\n }\n if (language) {\n options.language = language;\n }\n if (region) {\n options.region = region;\n }\n if (location_type) {\n options.location_type = location_type;\n }\n return geocode(RequestType.LATLNG, `${lat},${lng}`, options);\n}\n\ninterface GeocodeResult {\n address_components: AddressComponent[];\n formatted_address: string;\n geometry: Geometry;\n place_id: string;\n plus_code: PlusCode;\n types: string[];\n}\n\ninterface AddressComponent {\n long_name: string;\n short_name: string;\n types: string[];\n}\n\ninterface Geometry {\n location: {\n lat: number;\n lng: number;\n };\n location_type: string;\n viewport: {\n lat: number;\n lng: number;\n };\n southwest: {\n lat: number;\n lng: number;\n };\n}\n\ninterface AddressDescriptor {\n area: AreaDescriptor[];\n landmarks: Landmark[];\n}\n\ninterface AreaDescriptor {\n containment: string;\n display_name: {\n language_code: string;\n text: string;\n };\n place_id: string;\n}\n\ninterface Landmark {\n display_name: {\n language_code: string;\n text: string;\n };\n straight_line_distance_meters: number;\n place_id: string;\n travel_distance_meters: number;\n spatial_relationship: string;\n types: string[];\n}\n\ninterface PlusCode {\n compound_code: string;\n global_code: string;\n}\n"],"names":["RequestType","OutputFormat","GOOGLE_GEOCODE_API","defaultOptions","geocodeRequest","queryParams","outputFormat","restParams","queryString","url","json","status","error_message","error","setDefaults","options","setKey","key","setLanguage","language","setRegion","region","setComponents","components","setBounds","bounds","setResultType","resultType","setLocationType","locationType","setOutputFormat","enableAddressDescriptor","geocode","requestType","value","fromAddress","address","fromPlaceId","placeId","fromLatLng","lat","lng","location_type"],"mappings":"wOAGY,IAAAA,GAAAA,IACVA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,SAAW,WAHDA,IAAAA,GAAA,CAAA,CAAA,EASAC,GAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,KAAO,OAFGA,IAAAA,GAAA,CAAA,CAAA,EAQZ,MAAMC,EAAqB,+CAwC3B,IAAIC,EAAiC,CACnC,aAAc,MAChB,EAUA,eAAeC,EACbC,EAC0B,CAC1B,KAAM,CAAE,aAAAC,EAAc,GAAGC,CAAA,EAAeF,EAClCG,EAAc,IAAI,gBACtBD,GACA,SAAS,EACLE,EAAM,GAAGP,CAAkB,IAAII,CAAY,IAAIE,CAAW,GAC5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