{"name":"@webcontainer/env","version":"1.0.0","keywords":["stackblitz","webcontainer","nodejs"],"author":{"name":"StackBlitz Inc."},"license":"MIT","_id":"@webcontainer/env@1.0.0","maintainers":[{"name":"d3lm","email":"elmdominic@gmx.net"},{"name":"apai4","email":"iamalbertpai@gmail.com"},{"name":"ericmsimons","email":"eric@esft.com"}],"homepage":"https://github.com/stackblitz/webcontainer-core","bugs":{"url":"https://github.com/stackblitz/webcontainer-core/issues"},"dist":{"shasum":"26cbf67f4824d875b66b73345b603694ae795248","tarball":"http://registry-npm.ywwl.com/@webcontainer/env/download/@webcontainer/env-1.0.0.tgz","fileCount":7,"integrity":"sha512-DF9G5spcuFF4qApkNpeiLabAK5skJtC2E80NJuJsyYtdG/aKrcM46eiR+lRGRHybtQDigfXOWXZdrbwJzP7xlQ==","signatures":[{"sig":"MEQCIFj5ryuS6Cp24YhXwqLwJo8KzpcYlmK5ANYyIEX6d5vwAiAyUymWAbCz44STkbd+fGBqFJJxJCgJquzOY9gPlAz9NQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9662,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiemntACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrfBQ/+P5cTNzNSqBVbH8qksU1JL+i+zbQjUvL0QXJ+JA/eOyR9ZsFW\r\ne8dgm0Qb5CQTwIyYjSh+cRLwpJyKgUVoVGMyS8MpIe9fGuVsfLrRRiQhdt9Z\r\nyfHbpv7jukVJz7mGeuukDhBSjiCReOLfnMuT/05mJN4DromBGAMAT5AeEVgt\r\nCvq9USkemB3NOg+9uXAnZY9DfweRvAc1s2P0wCP0F3bw9VkVVJtqejsqJPC9\r\nktJygT5dFCAIdhtsFlRSpEIW9iPvQqM7iey1LX26K+F8exsBjo/HqgjimV4R\r\nshgJAwSOX6MLO13Jvm1BxR3cAbf9+ddvBfNau4g6D7E+nJyjSY7Pl/acdxzq\r\nQsIzgW7wSuKq8s0LC2Qm5J+q9WPzSNwM13pBNZgrFDa19mOxl6b4hQwQlsOx\r\nLmleETG7KzvNX7ByuQVqrlZBpGVgEkk3Pu2xwxnEwD0/3x+0M6X1G3d97BUE\r\nHhT137Soxa4zpqzz66x6ZARvX2spwxMEEcXeFetuEy9YSwhUgYPUpUc/lqYw\r\nQ4czdXuknmYCXdfqlnHNJbxWOGB/UlfvMxhyjWh/Dip6tD6Ekhj7g4ckT2g2\r\ny748MzIgQ18TD9ZqDGxoMtx4/3e516vCj+6KGtF+drEanaW/Le+7ghvsmHHl\r\nCAWw06CboCyIKtwN3hcMhUq7mB6zEGWC16U=\r\n=B/3E\r\n-----END PGP SIGNATURE-----\r\n","size":4049,"noattachment":false,"key":"/@webcontainer/env/-/@webcontainer/env-1.0.0.tgz"},"main":"dist/index.js","types":"dist/index.d.ts","exports":{"import":"./dist/index.js","require":"./dist/index.js"},"gitHead":"baa4b6fb08d1d5ac53b3eeaf3266d6d7f5c6caf9","scripts":{"test":"jest","build":"esbuild src/index.ts --bundle --minify --keep-names --platform=node --external:@blitz/env --outfile=dist/index.js && tsc --project tsconfig.build.json --emitDeclarationOnly","prepack":"npm run test && npm run build"},"_npmUser":{"name":"d3lm","email":"elmdominic@gmx.net"},"repository":{"url":"git+https://github.com/stackblitz/webcontainer-core.git","type":"git"},"_npmVersion":"8.5.0","description":"Set of environment utilities for WebContainers","directories":{},"_nodeVersion":"16.14.2","_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.14.38"},"_npmOperationalInternal":{"tmp":"tmp/env_1.0.0_1652189677199_0.001292945205255469","host":"s3://npm-registry-packages"},"readme":"# @webcontainer/env\n\n> ⚠️ Important ⚠️\n>\n> We strongly recommend that you update to version `1.1.0` or greater as we\n> recently introduced a breaking change in WebContainer, making older versions of\n> `@webcontainer/api` generate invalid `HostURL.href` and `HostURL.hostname`\n> when those methods are called inside a WebContainer.\n\nSet of environment utilities for [WebContainers](https://blog.stackblitz.com/posts/introducing-webcontainers/).\n\n## Install\n\n```shell\n$ npm install @webcontainer/env\n```\n\n## API\n\n### `isWebContainer(): boolean` (method)\n\nReturns a `boolean` indicating whether the program runs in a WebContainer.\n\n### `HostURL` (class)\n\nThe `HostURL` class represents a host specific URL. It can be used to parse a regular URL, such as\n`http://localhost:1234`, into a `HostURL`. Only if the program is executed in a WebContainer,\nthe `hostname` is resolved to a WebContainer hostname, e.g. `http://blitz--1234.local.webcontainer.io`.\nThis can be useful to create platform-dependent OAuth callback URLs.\n\n#### [`HostURL.port(): string`](https://developer.mozilla.org/en-US/docs/Web/API/URL/port) (getter)\n\n#### [`HostURL.hash(): string`](https://developer.mozilla.org/en-US/docs/Web/API/URL/hash) (getter)\n\n#### [`HostURL.host(): string`](https://developer.mozilla.org/en-US/docs/Web/API/URL/host) (getter)\n\n#### [`HostURL.hostname(): string`](https://developer.mozilla.org/en-US/docs/Web/API/URL/hostname) (getter)\n\n#### [`HostURL.href(): string`](https://developer.mozilla.org/en-US/docs/Web/API/URL/href) (getter)\n\n#### [`HostURL.origin(): string`](https://developer.mozilla.org/en-US/docs/Web/API/URL/origin) (getter)\n\n#### [`HostURL.username(): string`](https://developer.mozilla.org/en-US/docs/Web/API/URL/username) (getter)\n\n#### [`HostURL.password(): string`](https://developer.mozilla.org/en-US/docs/Web/API/URL/password) (getter)\n\n#### [`HostURL.pathname(): string`](https://developer.mozilla.org/en-US/docs/Web/API/URL/pathname) (getter)\n\n#### [`HostURL.protocol(): string`](https://developer.mozilla.org/en-US/docs/Web/API/URL/protocol) (getter)\n\n#### [`HostURL.search(): string`](https://developer.mozilla.org/en-US/docs/Web/API/URL/search) (getter)\n\n#### [`HostURL.searchParams(): URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams) (getter)\n\n#### `HostURL.parse(url: string | URL): HostURL` (static method)\n\nParses a `url` into a `HostURL`. On local this is a no-op but when running in a WebContainer it resolves `localhost`\nto a WebContainer hostname.\n\n**Example**\n\n```js\nimport { HostURL, isWebContainer } from '@webcontainer/env';\n\nconst hostURL = HostURL.parse('http://localhost:1234');\n\n/**\n * Note that this branching would not be necessary as the host URL gets parsed\n * and resolved automatically through `HostURL.parse()` (see above). So `href`\n * will return a different value depending on the environment. This is illustrated\n * with the following `if` statement.\n */\nif (isWebContainer()) {\n  console.log(hostURL.href); // http://blitz--1234.local.webcontainer.io\n} else {\n  console.log(hostURL.href); // http://localhost:1234\n}\n```\n\n#### `HostURL.update(change: Partial<UpdateableURLProperties>): HostURL` (method)\n\nUpdates the `HostURL`.\n\n##### **change**\n\nObject containing the URL changes. Note that some properties are immutable (read-only), e.g. `origin` or `searchParams`. When updating the `port` it automatically updates the `host`.\n\nType: `Partial<UpdateableURLProperties>`\n\n```js\ninterface UpdateableURLProperties {\n  hash: string;\n  host: string;\n  hostname: string;\n  href: string;\n  password: string;\n  pathname: string;\n  port: string;\n  protocol: string;\n  search: string;\n  username: string;\n}\n```\n\n#### `HostURL.toString(): string` (method)\n\nStringifies the HostURL. It is effectively a read-only version of `HostURL.href`.\n\n#### `HostURL.toJSON(): string` (method)\n\nReturns a string containing a serialized version of the `HostURL`.\n","publish_time":1652189677325,"_cnpm_publish_time":1652189677325,"dist-tags":{"latest":"1.1.1"}}