Meta tags:
description= The public WebContainer API allows you to build custom applications on top of an in-browser Node.js runtime.;
Headings (most frequently used words):
signature, string, void, on, example, properties, boolean, listener, event, options, returns, number, auth, spawnoptions, methods, error, webcontainer, dirent, filesystemapi, webcontainerprocess, bufferencoding, spawn, preview, overloads, reloadpreview, configureapikey, filesystemtree, filenode, symlinknode, directorynode, exportoptions, previewscriptoptions, port, server, ready, message, portlistener, errorlistener, serverreadylistener, previewmessagelistener, command, promise, logged, out, failed, reason, description, encoding, recursive, file, output, api, reference, guides, community, projects, boot, mount, export, setpreviewscript, teardown, functions, init, startauthflow, loggedin, logout, isdirectory, isfile, mkdir, readdir, readfile, rename, rm, writefile, watch, kill, resize, fs, path, workdir, return, bootoptions, coep, require, corp, credentialless, none, workdirname, forwardpreviewerrors, exceptions, only, previewmessage, args, htmliframeelement, hardrefreshtimeout, 200, key, authinitoptions, authfailederror, name, withfiletypes, force, null, watcher, close, contents, uint8array, symlink, directory, cwd, env, record, terminal, cols, rows, format, json, binary, zip, includes, excludes, type, module, importmap, defer, async, exit, input, writablestream, readablestream,
Text of the page (most frequently used words):
the (146), #string (98), void (41), interface (41), #options (38), file (35), for (33), boolean (33), this (29), webcontainer (29), webcontainerinstance (28), await (28), signature (26), promise (26), directory (26), error (24), event (23), will (22), const (20), listener (20), type (19), number (19), when (18), message (18), src (17), path (17), process (16), can (16), and (16), encoding (16), returns (15), api (15), that (14), script (14), recursive (14), page (13), instance (13), from (13), filesystemtree (13), uint8array (13), console (13), main (13), bufferencoding (12), spawn (12), set (12), true (12), export (12), your (12), auth (12), you (11), see (11), example (11), events (11), preview (11), emitted (10), default (10), json (10), with (10), contents (10), function (10), port (10), output (9), all (9), properties (9), only (9), user (9), are (9), description (9), stackblitz (9), value (8), format (8), used (8), any (8), log (8), watch (8), x83 (8), xe3 (8), listens (8), binary (7), terminal (7), data (7), zip (7), spawnoptions (7), directorynode (7), symlinknode (7), filenode (7), filename (7), rename (7), logged (7), called (7), install (7), boot (7), oauth (7), args (7), attribute (6), tree (6), which (6), symlink (6), name (6), watcher (6), null (6), writefile (6), hello (6), readfile (6), dirent (6), popup (6), failed (6), added (6), stack (6), previewmessagetype (6), webcontainerprocess (5), more (5), async (5), defer (5), previewscriptoptions (5), previews (5), exportoptions (5), working (5), also (5), given (5), close (5), not (5), new (5), exceptions (5), after (5), scope (5), now (5), application (5), https (5), they (5), ready (5), previewmessage (5), tutorial (4), was (4), latin1 (4), utf (4), cols (4), rows (4), methods (4), false (4), its (4), information (4), use (4), module (4), control (4), files (4), folders (4), never (4), environment (4), current (4), represents (4), node (4), foo (4), action (4), whether (4), should (4), xe5 (4), x82 (4), webcontainers (4), exist (4), package (4), content (4), without (4), throw (4), filesystemapi (4), system (4), entry (4), time (4), npm (4), loggedin (4), resolves (4), authfailederror (4), rfc (4), origin (4), authinitoptions (4), init (4), authentication (4), version (4), iframe (4), world (4), setpreviewscript (4), spawns (4), command (4), url (4), server (4), consoleerrormessage (4), undefined (4), unhandledrejectionmessage (4), uncaughtexceptionmessage (4), basepreviewmessage (4), none (4), coep (4), bootoptions (4), reference (4), utf8 (3), attached (3), via (3), stream (3), including (3), spawned (3), code (3), running (3), then (3), check (3), mdn (3), importmap (3), excludes (3), include (3), includes (3), calling (3), mount (3), env (3), record (3), workdir (3), change (3), cwd (3), watching (3), buffer (3), specified (3), does (3), directories (3), force (3), option (3), newpath (3), return (3), withfiletypes (3), might (3), reason (3), credentials (3), authenticate (3), out (3), overloads (3), once (3), every (3), gets (3), logout (3), private (3), packages (3), organisation (3), until (3), flow (3), editor (3), status (3), under (3), clientid (3), client (3), soon (3), method (3), top (3), users (3), configureapikey (3), configure (3), reload (3), reloadpreview (3), provided (3), teardown (3), processes (3), html (3), arguments (3), serverreadylistener (3), unhandledrejection (3), search (3), previewmessagelistener (3), errorlistener (3), portlistener (3), errors (3), forwardpreviewerrors (3), workdirname (3), require (3), corp (3), credentialless (3), runtime (3), browser (3), changelog (2), hex (2), base64url (2), base64 (2), ucs (2), ucs2 (2), utf16le (2), ascii (2), resize (2), kill (2), readablestream (2), input (2), exit (2), tag (2), injected (2), into (2), globbing (2), patterns (2), within (2), exported (2), size (2), back (2), booting (2), another (2), emptyfolder (2), staging (2), envrc (2), bar (2), myproject (2), like (2), folder (2), changes (2), passed (2), x8d (2), xe8 (2), x91 (2), x89 (2), xb8 (2), x96 (2), xab (2), xbc (2), xb9 (2), create (2), one (2), exists (2), deleting (2), nested (2), delete (2), second (2), argument (2), inside (2), index (2), oldpath (2), parent (2), must (2), bytes (2), reads (2), array (2), those (2), readdir (2), mkdir (2), isfile (2), isdirectory (2), authorization (2), possible (2), values (2), declines (2), unsubscribe (2), unsubscribed (2), longer (2), ignorerevokeerror (2), locally (2), saved (2), fetch (2), our (2), wait (2), authorized (2), startauthflow (2), detailed (2), short (2), www (2), org (2), rfc6749 (2), section (2), found (2), teams (2), settings (2), editororigin (2), com (2), exception (2), before (2), closed (2), completed (2), been (2), have (2), access (2), website (2), allows (2), key (2), commercial (2), usage (2), unusable (2), always (2), print (2), serve (2), existing (2), reloaded (2), blob (2), dist (2), filesystem (2), additional (2), yarn (2), started (2), receive (2), consoleerror (2), uncaughtexception (2), hash (2), pathname (2), previewid (2), internal (2), triggered (2), open (2), mountpoint (2), snapshot (2), generated (2), received (2), forwarded (2), window (2), booted (2), headers (2), playground (2), projects (2), support (2), guides (2), navigation (2), discord (2), twitter (2), github (2), next, previous, last, updated, edit, yes, helpful, dimensions, resizes, kills, disabled, setting, receives, stdout, stderr, descendants, pseudoterminal, device, writablestream, attributes, exclude, excluded, exporting, sent, produce, chunks, variables, relative, spawning, pointing, location, structure, describe, mounted, stop, indicates, subdirectories, watched, applies, specifies, character, writes, overwrite, recursively, remove, ignored, deletes, needed, everything, renaming, objects, accepted, missing, creates, already, interact, directly, modeled, promises, representation, addded, future, behind, having, typed, instead, union, invalid, unknown, malformed, invalid_scope, denied, request, access_denied, property, corresponds, constant, match, against, while, human, readable, useful, development, tab, revoked, meaning, needs, revocation, discarded, nonetheless, clear, were, authorizes, guaranteed, rejected, starts, redirecting, unless, case, done, need, mode, likely, want, side, routing, happening, query, parameters, populated, related, removes, them, consumed, intialize, part, loading, phase, loaded, loads, important, multiple, reasons, functions, able, authorize, belong, generate, namespace, visiting, order, authenticated, enterprise, has, htmliframeelement, hardrefreshtimeout, 200, sending, falling, resetting, didn, respond, entities, derived, etc, become, destroys, turning, releases, resources, obtained, scriptsrc, particular, break, features, ones, later, advanced, feature, since, servers, preferable, add, serving, itself, warning, notably, won, either, extra, responses, otherwise, exports, line, traffic, opened, some, arraybuffer, mounts, object, register, handler, uncaught, calls, occurring, embedded, iframes, captured, originate, mostly, cosmetic, sets, auto, fixed, first, cannot, changed, successive, reboots, choosing, result, cross, isolation, being, work, chromium, based, browsers, long, trial, supported, header, load, static, boots, single, concurrently, expensive, operation, full, variable, through, gives, underlying, library, public, build, custom, applications, point, class, table, contact, clack, pkg, vslite, builder, stylelint, otto, engineer, security, academy, sveltekit, web, publisher, codeflow, schachnovelle, angular, tune, community, configuration, versioning, test, cases, agents, troubleshooting, configuring, quickstart, introduction, sidebar, menu, appearance, pricing, skip,
Text of the page (random words):
handledrejectionmessage type previewmessagetype unhandledrejection message string stack string undefined interface consoleerrormessage type previewmessagetype consoleerror args any stack string on event server ready listener serverreadylistener void listens for server ready events emitted when a server was started and ready to receive traffic serverreadylistener function ts port number url string void port number url string void spawn spawns a process when no args are provided spawns a process without command line arguments signature spawn command string args string options spawnoptions promise webcontainerprocess example with args js const install await webcontainerinstance spawn npm i const install await webcontainerinstance spawn npm i without args js const install await webcontainerinstance spawn yarn const install await webcontainerinstance spawn yarn returns returns a webcontainerprocess overloads spawn command string args string options spawnoptions void spawns a process with additional arguments spawn command string options spawnoptions void spawns a process without additional arguments export added in version 1 4 0 exports the filesystem signature export path string options exportoptions promise uint8array filesystemtree example js const data await webcontainerinstance export dist format zip const zip new blob data const data await webcontainerinstance export dist format zip const zip new blob data returns returns a filesystemtree when the format is json otherwise a uint8array setpreviewscript added in version 1 5 0 configure a script to be injected inside all previews after this function resolves every preview iframe that is either added or reloaded will now include this extra script on all html responses notably existing previews won t include the script until they have been reloaded to reload a preview you can use reloadpreview warning this api is an advanced feature that should only be used if it is your only option since you can control servers running in webcontainer it s preferable to add this code when serving the content itself in particular this might break existing webcontainer features or ones that will be added later signature setpreviewscript scriptsrc string options previewscriptoptions promise void example js const script console log hello world await webcontainerinstance setpreviewscript script now all previews will always print hello world to the console if they serve html const script console log hello world await webcontainerinstance setpreviewscript script now all previews will always print hello world to the console if they serve html teardown destroys the webcontainer instance turning it unusable and releases its resources after this a new webcontainer instance can be obtained by calling boot all entities derived from this instance e g processes the file system etc also become unusable after calling this method signature teardown void reloadpreview added in version 1 2 2 reload the provided iframe by sending a message to the iframe and falling back to resetting the src if the iframe didn t respond in time signature reloadpreview preview htmliframeelement hardrefreshtimeout number 200 promise void returns returns a promise that resolves when the reload has completed configureapikey added in version 1 3 0 configure an api key to be used for commercial usage of the webcontainer api see https webcontainers io enterprise for more information signature configureapikey key string void this function will throw an exception if webcontainer boot was called before configureapikey auth the authentication api is exported under the auth namespace it allows you to authenticate users visiting your website via stackblitz in order for users to be authenticated via this method they must be logged in on stackblitz belong to the organisation you used to generate your clientid for use with the webcontainer api authorize your website once logged in you ll be able to install private packages that those users have access to within webcontainer auth functions init intialize the authentication for use in webcontainer this method should be called as soon as possible as part of the loading phase of your page for example at the top of a module that gets loaded as soon as the page loads this is important for multiple reasons if you do client side routing and the oauth flow is happening then query parameters might be populated with values related to the oauth flow the init function removes them after they ve been consumed if you do the authentication in popup mode you likely want the popup to be closed as soon as the authentication completed signature init options authinitoptions status need auth authorized authfailederror this function will throw an exception if webcontainer boot was called before auth init authinitoptions ts interface authinitoptions stackblitz origin default https stackblitz com editororigin string the client id for this oauth application clientid string oauth scope the value can be found under your teams settings api see https www rfc editor org rfc rfc6749 section 3 3 scope string interface authinitoptions stackblitz origin default https stackblitz com editororigin string the client id for this oauth application clientid string oauth scope the value can be found under your teams settings api see https www rfc editor org rfc rfc6749 section 3 3 scope string authfailederror ts interface authfailederror status auth failed a short description of the error error string a detailed description of the error description string interface authfailederror status auth failed a short description of the error error string a detailed description of the error description string startauthflow this starts the oauth flow redirecting the current page to the stackblitz editor to authenticate the user unless popup is set to true in which case it s done in a popup startauthflow options popup boolean void loggedin returns a promise that resolves when the user authorized your application this promise is guaranteed to never be rejected if the user never authorizes or declines your application this promise never resolves signature loggedin promise void example ts const instance await webcontainer boot wait until the user is logged in await auth loggedin we can now fetch private packages from our organisation await instance spawn npm install const instance await webcontainer boot wait until the user is logged in await auth loggedin we can now fetch private packages from our organisation await instance spawn npm install logout logout the user and clear any credentials that were saved locally if ignorerevokeerror is set and the revocation failed the locally saved credentials are discarded nonetheless signature logout options ignorerevokeerror boolean promise void on listens for an event the listener is called every time the event gets emitted signature on event logged out auth failed listener void reason error string description string void void returns returns a function to unsubscribe from the events once unsubscribed the listener will no longer be called overloads on event logged out listener void void listens for logged out events which are emitted when the credentials are revoked meaning the user needs to re authenticate on event auth failed listener reason error string description string void void listens for auth failed events which are emitted when the user declines authorization in another tab popup the property error corresponds to a constant that your code can match against while description is a human readable error that can be useful for development the possible values of error are access_denied the user denied the authorization request invalid_scope the scope is invalid unknown or malformed more might be addded in the future which is reason behind having error typed as a string instead of an union dirent a representation of a directory entry see the node js api dirent properties name the name of the file or directory signature name string uint8array dirent methods isdirectory whether the entry is a directory signature isdirectory boolean isfile whether the entry is a file signature isfile boolean filesystemapi interface to interact directly with the webcontainer file system modeled after fs promises in node filesystemapi methods mkdir creates a new directory if the directory already exists it will throw an error signature mkdir path string options options promise void options when recursive is set to true it will create any missing folders in the path ts interface options recursive boolean interface options recursive boolean readdir reads a given directory and returns an array of its files and directories signature readdir path string options options promise uint8array promise string promise dirent uint8array promise dirent string options ts interface options encoding bufferencoding withfiletypes boolean interface options encoding bufferencoding withfiletypes boolean encoding bufferencoding the encoding see bufferencoding can be any one of those accepted by buffer withfiletypes boolean when set to true the return value is an array of dirent objects readfile reads the file at the given path if the file does not exist it will throw an error signature readfile path string encoding bufferencoding null promise uint8array promise string by default it returns a uint8array a second argument can be passed as the encoding example without encoding ts const bytes await webcontainerinstance fs readfile package json const bytes await webcontainerinstance fs readfile package json with a specified encoding ts const content await webcontainerinstance fs readfile package json utf 8 const content await webcontainerinstance fs readfile package json utf 8 returns promise uint8array or promise string rename rename the file from oldpath to newpath the parent folders in newpath must all exist signature rename oldpath string newpath string promise void example renaming a file js await webcontainerinstance fs rename src index js src main js await webcontainerinstance fs rename src index js src main js rm deletes a file or a directory if the path is a file it will delete the file if the path is a directory a second argument is needed with option recursive set to true to delete the directory and everything inside it including nested folders signature rm path string options options promise void options ts interface options force boolean recursive boolean interface options force boolean recursive boolean force boolean when true exceptions will be ignored if the path does not exist recursive boolean if true it will recursively remove directories including nested directories example deleting a file js await webcontainerinstance fs rm src main js await webcontainerinstance fs rm src main js deleting a directory js await webcontainerinstance fs rm src recursive true await webcontainerinstance fs rm src recursive true writefile writes a file to the given path if the file does not exist it will create a new one if the file exists it will overwrite the file signature writefile path string data string uint8array options string encoding null bufferencoding null promise void example default js await webcontainerinstance fs writefile src main js console log hello from webcontainers await webcontainerinstance fs writefile src main js console log hello from webcontainers with encoding js await webcontainerinstance fs writefile src main js xe5 x8d x83 xe8 x91 x89 xe5 xb8 x82 xe3 x83 x96 xe3 x83 xab xe3 x83 xbc xe3 x82 xb9 encoding latin1 await webcontainerinstance fs writefile src main js xe5 x8d x83 xe8 x91 x89 xe5 xb8 x82 xe3 x83 x96 xe3 x83 xab xe3 x83 xbc xe3 x82 xb9 encoding latin1 watch watch for changes to a given file or directory signature watch path string options options listener listener watcher watch path string listener listener watcher options ts interface options encoding bufferencoding null recursive boolean interface options encoding bufferencoding null recursive boolean encoding bufferencoding null specifies the character encoding to be used for the filename passed to the listener default utf8 recursive boolean indicates whether all subdirectories should be watched or only the current directory this applies when a directory is specified default false listener ts type listener event rename change filename string buffer void type listener event rename change filename string buffer void watcher ts interface watcher close void interface watcher close void close void stop watching for changes on the given watcher example watching a file js webcontainerinstance fs watch src main js event console log action event webcontainerinstance fs watch src main js event console log action event watching a directory js webcontainerinstance fs watch src recursive true event filename console log file filename action event webcontainerinstance fs watch src recursive true event filename console log file filename action event filesystemtree a tree like structure to describe the contents of a folder to be mounted ts interface filesystemtree name string filenode symlinknode directorynode interface filesystemtree name string filenode symlinknode directorynode also see filenode symlinknode and directorynode example js const tree myproject directory foo js file contents const x 1 bar js file symlink foo js envrc file contents environment staging emptyfolder directory const tree myproject directory foo js file contents const x 1 bar js file symlink foo js envrc file contents environment staging emptyfolder directory filenode ts interface filenode file contents string uint8array interface filenode file contents string uint8array filenode properties file contents string uint8array represents a file with contents also see filesystemtree symlinknode ts interface symlinknode file symlink string interface symlinknode file symlink string symlinknode properties file symlink string represents a symlink pointing to another location also see filesystemtree directorynode ts interface directorynode directory filesystemtree interface directorynode directory filesystemtree directorynode properties directory filesystemtree represents a directory node also see filesystemtree spawnoptions options that control spawning a process ts export interface spawnoptions cwd string env record string string number boolean output boolean terminal cols number rows number export interface spawnoptions cwd string env record string string number boolean output boolean terminal cols number rows number spawnoptions properties cwd string current working directory for the process relative to workdir this instance which you can change when booting webcontainer by default the working directory of the spawned process is workdir env record string string number boolean environment variables to set for the process output boolean when set to false no terminal output is sent back to the process and the output stream will never produce any chunks terminal cols number rows number the size of the attached te...
|