{"name":"@webcontainer/env","version":"1.1.0","keywords":["stackblitz","webcontainer","nodejs"],"author":{"name":"StackBlitz Inc."},"license":"MIT","_id":"@webcontainer/env@1.1.0","maintainers":[{"name":"stackblitz-devops","email":"devops@stackblitz.com"},{"name":"_rvidal","email":"roberto.vidal@ikumene.com"},{"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":"807cb96a46cabe84d2ca8b43beaecbedbc22271f","tarball":"http://registry-npm.ywwl.com/@webcontainer/env/download/@webcontainer/env-1.1.0.tgz","fileCount":7,"integrity":"sha512-DreJFHUui8vq1N3nQGU3HwK5UI4hVNW7VQfhAOmeQbBVnpKtGhoNobjDNF8LzlN7ssmFI9Uhkc9Au4mtKvPK6Q==","signatures":[{"sig":"MEYCIQDU2fMuEb3Q3YxJHxH7L7PDPzUXdJb/7LrmkjgEQ2D51gIhAPUXCyc2Lo9W6RYsYRidiHIAVqH+HhN1zvdmDpcWwe+k","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9919,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkHWGdACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpd/w/8CN32lEKBEg2HAm3lp4tv4aH/r8qdgFH6rWaHHXriIzAyACyc\r\nl0mJEprkH0jKhhSN9aa7QmV13VytJqYv5KqKIN5zM8UM0YiarkxEJy003TMy\r\nTEELObCkFCN77lZqSN34TcIwtuFBBHx3I3aB0lLeo/8x9gKki3vH7hfPCTf8\r\ncqvR+I51+sPfzB6J4IwOY8siUF4SaCFsR8v9T9gMWb5JfpTpv/AiDk2m91JY\r\nIufgcHhWOe9nM3XxylxRu1xYftRmxYfn0FS49QfBXzGUuLLo0PJD/UHgWQY6\r\n/2ylkNsO8dUaeyCZdtqt+au4+5xngwJ76qn7/I9QXiegxLyTR74l2WJgJDZP\r\nXJHrwRGNKqOdvfmnA0ZaFGZahf5L7ndPcknG8x3MDgVNX2h1KLRi3oNVQ2ZF\r\noJsJPOseHOHhvGfSB1SLIMlL1UeOoKicdu1UwQdCTvrCZqs2iKrSWwAkH3Q7\r\n844EaegRycX2y6KcHJgSxNSEOf/R5i5e3aY9swiGfKa/IDa3K93/BP9pqDws\r\nNs3JkNjEe1SxavK2gQziVTPeUU2y7+LiQEoXoElZ6qL73nKx1wsExSWhbq4B\r\nENkay9GIqTlwVMgPlSKCLWDq2xowD4i9XDidNyVQP7BErBHip4ctVbTuc5wv\r\ndJv4NW/4RJbtHdQHczymkkrP1NEEVyuUu64=\r\n=hJoU\r\n-----END PGP SIGNATURE-----\r\n","size":4081,"noattachment":false,"key":"/@webcontainer/env/-/@webcontainer/env-1.1.0.tgz"},"main":"dist/index.js","types":"dist/index.d.ts","exports":{"import":"./dist/index.js","require":"./dist/index.js"},"gitHead":"8f264d9ee3217b269379ef30cd3177ea09036952","scripts":{"test":"jest","build":"esbuild src/index.ts --bundle --minify --keep-names --platform=node --external:@blitz/internal/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.1.0_1679647132993_0.3483045032523062","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":1679647133147,"_cnpm_publish_time":1679647133147,"dist-tags":{"latest":"1.1.1"}}