Repository: googlemaps/js-api-loader
Pull request #480 (2021-12-14 06:05:45)

build(deps-dev): bump typescript from 4.5.2 to 4.5.4
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.5.2 to 4.5.4.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/Microsoft/TypeScript/releases">typescript's releases</a>.</em></p>
<blockquote>
<h2>TypeScript 4.5.4</h2>
<p>This patch release includes a fix for <a href="https://github-redirect.dependabot.com/microsoft/TypeScript/issues/47090">incorrectly offering up JSX attribute snippet completions at the beginning of a tag name</a>.</p>
<p>For the complete list of fixed issues, check out the</p>
<ul>
<li><a href="https://github.com/microsoft/TypeScript/issues?q=milestone%3A%22TypeScript+4.5.0%22+">fixed issues query for Typescript 4.5.0 (Beta)</a>.</li>
<li><a href="https://github.com/microsoft/TypeScript/issues?q=milestone%3A%22TypeScript+4.5.1%22+">fixed issues query for Typescript 4.5.1 (RC)</a>.</li>
<li><a href="https://github.com/microsoft/TypeScript/issues?q=milestone%3A%22TypeScript+4.5.2%22+">fixed issues query for Typescript 4.5.2 (Stable)</a>.</li>
<li><a href="https://github.com/microsoft/TypeScript/issues?q=milestone%3A%22TypeScript+4.5.3%22+">fixed issues query for Typescript 4.5.3 (Stable)</a>.</li>
<li>
<ul>
<li><a href="https://github.com/microsoft/TypeScript/issues?q=milestone%3A%22TypeScript+4.5.4%22+">fixed issues query for Typescript 4.5.4 (Stable)</a>.</li>
</ul>
</li>
</ul>
<p>Downloads are available on:</p>
<ul>
<li><a href="https://www.npmjs.com/package/typescript">npm</a></li>
<li><a href="https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild">NuGet package</a></li>
</ul>
<h2>TypeScript 4.5.3</h2>
<p>For release notes, check out the <a href="https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/">release announcement</a>.</p>
<p>For the complete list of fixed issues, check out the</p>
<ul>
<li><a href="https://github.com/microsoft/TypeScript/issues?q=milestone%3A%22TypeScript+4.5.0%22+">fixed issues query for Typescript 4.5.0 (Beta)</a>.</li>
<li><a href="https://github.com/microsoft/TypeScript/issues?q=milestone%3A%22TypeScript+4.5.1%22+">fixed issues query for Typescript 4.5.1 (RC)</a>.</li>
<li><a href="https://github.com/microsoft/TypeScript/issues?q=milestone%3A%22TypeScript+4.5.2%22+">fixed issues query for Typescript 4.5.2 (Stable)</a>.</li>
<li><a href="https://github.com/microsoft/TypeScript/issues?q=milestone%3A%22TypeScript+4.5.3%22+">fixed issues query for Typescript 4.5.3 (Stable)</a>.</li>
</ul>
<p>Downloads are available on:</p>
<ul>
<li><a href="https://www.npmjs.com/package/typescript">npm</a></li>
<li><a href="https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild">NuGet package</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/microsoft/TypeScript/commit/1bc124e6359d8e7fa54206c8b58d324bd8b80beb"><code>1bc124e</code></a> Bump version to 4.5.4 and LKG</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/1d4ec40130bae10f4b955bd7672054e34cba8caa"><code>1d4ec40</code></a> Cherry-pick PR <a href="https://github-redirect.dependabot.com/Microsoft/TypeScript/issues/47096">#47096</a> into release-4.5 (<a href="https://github-redirect.dependabot.com/Microsoft/TypeScript/issues/47105">#47105</a>)</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/002c79bf5098886e06a9c02816e2b994c7eb3b8c"><code>002c79b</code></a> Bump version to 4.5.3 and LKG</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/ae448625b0252f20252c7a81015424eeb1c1f5bc"><code>ae44862</code></a> Cherry-pick PR <a href="https://github-redirect.dependabot.com/Microsoft/TypeScript/issues/46599">#46599</a> into release-4.5 (<a href="https://github-redirect.dependabot.com/Microsoft/TypeScript/issues/46974">#46974</a>)</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/c63f0cf7d2b84a56ecb18c7097be6b00b3249163"><code>c63f0cf</code></a> Cherry-pick PR <a href="https://github-redirect.dependabot.com/Microsoft/TypeScript/issues/46973">#46973</a> into release-4.5 (<a href="https://github-redirect.dependabot.com/Microsoft/TypeScript/issues/47005">#47005</a>)</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/d710e39921d547408acbe17daf8239b84a53bc77"><code>d710e39</code></a> 🤖 Pick PR <a href="https://github-redirect.dependabot.com/Microsoft/TypeScript/issues/47007">#47007</a> (Use features for selected module re...) into release-4.5 (#...</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/c1758b555d5384af0e8257d2008c1197b3ce7560"><code>c1758b5</code></a> Cherry-pick PR <a href="https://github-redirect.dependabot.com/Microsoft/TypeScript/issues/46951">#46951</a> into release-4.5 (<a href="https://github-redirect.dependabot.com/Microsoft/TypeScript/issues/47058">#47058</a>)</li>
<li><a href="https://github.com/microsoft/TypeScript/commit/49b1acc1266a153e2bfe2dc4a72ab1465049c7a7"><code>49b1acc</code></a> Pin chalk to ^4.1 (<a href="https://github-redirect.dependabot.com/Microsoft/TypeScript/issues/46985">#46985</a>) (<a href="https://github-redirect.dependabot.com/Microsoft/TypeScript/issues/47014">#47014</a>)</li>
<li>See full diff in <a href="https://github.com/Microsoft/TypeScript/compare/v4.5.2...v4.5.4">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=typescript&package-manager=npm_and_yarn&previous-version=4.5.2&new-version=4.5.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

codecov[bot]: # [Codecov](https://codecov.io/gh/googlemaps/js-api-loader/pull/480?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=googlemaps) Report
> Merging [#480](https://codecov.io/gh/googlemaps/js-api-loader/pull/480?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=googlemaps) (b053e58) into [main](https://codecov.io/gh/googlemaps/js-api-loader/commit/64bb4728ea8dcdce8a3029e54d14608270d7badf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=googlemaps) (64bb472) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/googlemaps/js-api-loader/pull/480/graphs/tree.svg?width=650&height=150&src=pr&token=aAmgcWFXMs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=googlemaps)](https://codecov.io/gh/googlemaps/js-api-loader/pull/480?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=googlemaps)

```diff
@@            Coverage Diff            @@
##              main      #480   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          123       123           
  Branches        25        25           
=========================================
  Hits           123       123           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/googlemaps/js-api-loader/pull/480?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=googlemaps).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=googlemaps)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/googlemaps/js-api-loader/pull/480?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=googlemaps). Last update [64bb472...b053e58](https://codecov.io/gh/googlemaps/js-api-loader/pull/480?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=googlemaps). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=googlemaps).


Patch:
diff --git a/package-lock.json b/package-lock.json
index 0375789..a9a2a14 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
 {
   "name": "@googlemaps/js-api-loader",
-  "version": "1.12.11",
+  "version": "1.13.1",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
@@ -4053,9 +4053,9 @@
       "dev": true
     },
     "@types/google.maps": {
-      "version": "3.46.0",
-      "resolved": "https://registry.npmjs.org/@types/google.maps/-/google.maps-3.46.0.tgz",
-      "integrity": "sha512-TvrN/+XkDSblCrkx9bJXSrYOrDeUgiPl1ec215vv4mYBuvU3YOAq0XVB32dV6r7ySctqJO1M7aEgVJsJZOgrmQ==",
+      "version": "3.47.2",
+      "resolved": "https://registry.npmjs.org/@types/google.maps/-/google.maps-3.47.2.tgz",
+      "integrity": "sha512-mFmt428CY4UN49U8KH5J4RfcdkeRu6SZyPIXxU1MA0pnHb4pqn/c/whawTodB3pkKWe8F9fXfUlpBFsk9HucXw==",
       "dev": true
     },
     "@types/graceful-fs": {
@@ -4098,9 +4098,9 @@
       }
     },
     "@types/jest": {
-      "version": "27.0.2",
-      "resolved": "https://registry.npmjs.org/@types/jest/-/jest-27.0.2.tgz",
-      "integrity": "sha512-4dRxkS/AFX0c5XW6IPMNOydLn2tEhNhJV7DnYK+0bjoJZ+QTmfucBlihX7aoEsh/ocYtkLC73UbnBXBXIxsULA==",
+      "version": "27.4.0",
+      "resolved": "https://registry.npmjs.org/@types/jest/-/jest-27.4.0.tgz",
+      "integrity": "sha512-gHl8XuC1RZ8H2j5sHv/JqsaxXkDDM9iDOgu0Wp8sjs4u/snb2PVehyWXJPr+ORA0RPpgw231mnutWI1+0hgjIQ==",
       "dev": true,
       "requires": {
         "jest-diff": "^27.0.0",
@@ -4108,9 +4108,9 @@
       },
       "dependencies": {
         "@jest/types": {
-          "version": "27.1.1",
-          "resolved": "https://registry.npmjs.org/@jest/types/-/types-27.1.1.tgz",
-          "integrity": "sha512-yqJPDDseb0mXgKqmNqypCsb85C22K1aY5+LUxh7syIM9n/b0AsaltxNy+o6tt29VcfGDpYEve175bm3uOhcehA==",
+          "version": "27.4.2",
+          "resolved": "https://registry.npmjs.org/@jest/types/-/types-27.4.2.tgz",
+          "integrity": "sha512-j35yw0PMTPpZsUoOBiuHzr1zTYoad1cVIE0ajEjcrJONxxrko/IRGKkXx3os0Nsi4Hu3+5VmDbVfq5WhG/pWAg==",
           "dev": true,
           "requires": {
             "@types/istanbul-lib-coverage": "^2.0.0",
@@ -4136,31 +4136,31 @@
           "dev": true
         },
         "jest-diff": {
-          "version": "27.2.0",
-          "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-27.2.0.tgz",
-          "integrity": "sha512-QSO9WC6btFYWtRJ3Hac0sRrkspf7B01mGrrQEiCW6TobtViJ9RWL0EmOs/WnBsZDsI/Y2IoSHZA2x6offu0sYw==",
+          "version": "27.4.2",
+          "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-27.4.2.tgz",
+          "integrity": "sha512-ujc9ToyUZDh9KcqvQDkk/gkbf6zSaeEg9AiBxtttXW59H/AcqEYp1ciXAtJp+jXWva5nAf/ePtSsgWwE5mqp4Q==",
           "dev": true,
           "requires": {
             "chalk": "^4.0.0",
-            "diff-sequences": "^27.0.6",
-            "jest-get-type": "^27.0.6",
-            "pretty-format": "^27.2.0"
+            "diff-sequences": "^27.4.0",
+            "jest-get-type": "^27.4.0",
+            "pretty-format": "^27.4.2"
           }
         },
         "jest-get-type": {
-          "version": "27.0.6",
-          "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-27.0.6.tgz",
-          "integrity": "sha512-XTkK5exIeUbbveehcSR8w0bhH+c0yloW/Wpl+9vZrjzztCPWrxhHwkIFpZzCt71oRBsgxmuUfxEqOYoZI2macg==",
+          "version": "27.4.0",
+          "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-27.4.0.tgz",
+          "integrity": "sha512-tk9o+ld5TWq41DkK14L4wox4s2D9MtTpKaAVzXfr5CUKm5ZK2ExcaFE0qls2W71zE/6R2TxxrK9w2r6svAFDBQ==",
           "dev": true
         },
         "pretty-format": {
-          "version": "27.2.0",
-          "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.2.0.tgz",
-          "integrity": "sha512-KyJdmgBkMscLqo8A7K77omgLx5PWPiXJswtTtFV7XgVZv2+qPk6UivpXXO+5k6ZEbWIbLoKdx1pZ6ldINzbwTA==",
+          "version": "27.4.2",
+          "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.4.2.tgz",
+          "integrity": "sha512-p0wNtJ9oLuvgOQDEIZ9zQjZffK7KtyR6Si0jnXULIDwrlNF8Cuir3AZP0hHv0jmKuNN/edOnbMjnzd4uTcmWiw==",
           "dev": true,
           "requires": {
-            "@jest/types": "^27.1.1",
-            "ansi-regex": "^5.0.0",
+            "@jest/types": "^27.4.2",
+            "ansi-regex": "^5.0.1",
             "ansi-styles": "^5.0.0",
             "react-is": "^17.0.1"
           }
@@ -5472,9 +5472,9 @@
       "dev": true
     },
     "diff-sequences": {
-      "version": "27.0.6",
-      "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.0.6.tgz",
-      "integrity": "sha512-ag6wfpBFyNXZ0p8pcuIDS//D8H062ZQJ3fzYxjpmeKjnz8W4pekL3AI8VohmyZmsWW2PWaHgjsmqR6L13101VQ==",
+      "version": "27.4.0",
+      "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.4.0.tgz",
+      "integrity": "sha512-YqiQzkrsmHMH5uuh8OdQFU9/ZpADnwzml8z0O5HvRNda+5UZsaX/xN+AAxfR2hWq1Y7HZnAzO9J5lJXOuDz2Ww==",
       "dev": true
     },
     "dir-glob": {
@@ -9005,13 +9005,12 @@
       }
     },
     "selenium-webdriver": {
-      "version": "4.0.0",
-      "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.0.0.tgz",
-      "integrity": "sha512-tOlu6FnTjPq2FKpd153pl8o2cB7H40Rvl/ogiD2sapMv4IDjQqpIxbd+swDJe9UDLdszeh5CDis6lgy4e9UG1w==",
+      "version": "4.1.0",
+      "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.1.0.tgz",
+      "integrity": "sha512-kUDH4N8WruYprTzvug4Pl73Th+WKb5YiLz8z/anOpHyUNUdM3UzrdTOxmSNaf9AczzBeY+qXihzku8D1lMaKOg==",
       "dev": true,
       "requires": {
         "jszip": "^3.6.0",
-        "rimraf": "^3.0.2",
         "tmp": "^0.2.1",
         "ws": ">=7.4.6"
       }
@@ -9927,9 +9926,9 @@
       }
     },
     "typescript": {
-      "version": "4.5.2",
-      "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz",
-      "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==",
+      "version": "4.5.4",
+      "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.4.tgz",
+      "integrity": "sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==",
       "dev": true
     },
     "unicode-canonical-property-names-ecmascript": {
diff --git a/package.json b/package.json
index 747197c..0f936ee 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@googlemaps/js-api-loader",
-  "version": "1.12.11",
+  "version": "1.13.1",
   "description": "Wrapper for the loading of Google Maps JavaScript API script in the browser",
   "keywords": [
     "google",
@@ -21,7 +21,8 @@
   "module": "dist/index.esm.js",
   "types": "dist/index.d.ts",
   "files": [
-    "dist/*"
+    "dist/",
+    "src/"
   ],
   "scripts": {
     "docs": "typedoc src/index.ts && cp -r dist docs/dist && cp -r examples docs/examples",
diff --git a/rollup.config.js b/rollup.config.js
index 8b60966..a785023 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -34,7 +34,7 @@ export default [
   {
     input: "src/index.ts",
     plugins: [
-      typescript({ tsconfig: "./tsconfig.json" }),
+      typescript({ tsconfig: "./tsconfig.json", declarationDir: "./" }),
 
       nodeResolve(resolveOptions),
       commonjs(),
diff --git a/src/index.ts b/src/index.ts
index e8fc2f3..f476a84 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -27,7 +27,7 @@ declare global {
 
 export const DEFAULT_ID = "__googleMapsScriptId";
 
-type Libraries = (
+export type Libraries = (
   | "drawing"
   | "geometry"
   | "localContext"
@@ -165,6 +165,16 @@ export interface LoaderOptions {
   retries?: number;
 }
 
+/**
+ * The status of the [[Loader]].
+ */
+export enum LoaderStatus {
+  INITIALIZED,
+  LOADING,
+  SUCCESS,
+  FAILURE,
+}
+
 /**
  * [[Loader]] makes it easier to add Google Maps JavaScript API to your application
  * dynamically using
@@ -314,6 +324,19 @@ export class Loader {
     };
   }
 
+  public get status(): LoaderStatus {
+    if (this.errors.length) {
+      return LoaderStatus.FAILURE;
+    }
+    if (this.done) {
+      return LoaderStatus.SUCCESS;
+    }
+    if (this.loading) {
+      return LoaderStatus.LOADING;
+    }
+    return LoaderStatus.INITIALIZED;
+  }
+
   private get failed(): boolean {
     return this.done && !this.loading && this.errors.length >= this.retries + 1;
   }


Test patch:
diff --git a/src/index.test.ts b/src/index.test.ts
index 43fe595..06242cd 100644
--- a/src/index.test.ts
+++ b/src/index.test.ts
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 /* eslint @typescript-eslint/no-explicit-any: 0 */
-import { DEFAULT_ID, Loader, LoaderOptions } from ".";
+import { DEFAULT_ID, Loader, LoaderOptions, LoaderStatus } from ".";
 
 jest.useFakeTimers();
 
@@ -54,6 +54,7 @@ test.each([
 ])("createUrl is correct", (options: LoaderOptions, expected: string) => {
   const loader = new Loader(options);
   expect(loader.createUrl()).toEqual(expected);
+  expect(loader.status).toBe(LoaderStatus.INITIALIZED);
 });
 
 test("uses default id if empty string", () => {
@@ -128,6 +129,7 @@ test("script onerror should reject promise", async () => {
   expect(loader["done"]).toBeTruthy();
   expect(loader["loading"]).toBeFalsy();
   expect(loader["errors"].length).toBe(1);
+  expect(loader.status).toBe(LoaderStatus.FAILURE);
 });
 
 test("script onerror should reject promise with multiple loaders", async () => {
@@ -301,6 +303,7 @@ test("singleton should be used", () => {
 
   loader["done"] = true;
   expect(extraLoader["done"]).toBe(loader["done"]);
+  expect(loader.status).toBe(LoaderStatus.SUCCESS);
 });
 
 test("singleton should throw with different options", () => {
@@ -333,7 +336,7 @@ test("loader should resolve immediately when failed loading", async () => {
 test("loader should wait if already loading", () => {
   const loader = new Loader({ apiKey: "foo", retries: 0 });
   loader["loading"] = true;
-
+  expect(loader.status).toBe(LoaderStatus.LOADING);
   loader.load();
 });