Expand description
Shared UriComponents emitter. Every handler that returns a URI to the
renderer must route through this module so the $mid: 1 marshalling
marker is never forgotten (without it VS Code’s IPC reviver skips the
field and uri.with is not a function cascades through the sidebar).
§UriComponents - VS Code marshalling helpers
Centralised builders for VS Code UriComponents payloads. The
renderer’s reviver (_transformIncomingURIs in uriIpc.ts) walks
every response object and only calls URI.revive() on nested
objects tagged with $mid === MarshalledId.Uri (= 1). An untagged
UriComponents reaches callers as a plain bag - uri.with is not a function, uri.fsPath undefined - and the sidebar / icon loader /
joinPath chain silently breaks.
Layout (one export per file, file name = identity):
MID_URI::VALUE- the magic marshalling constant.StampMidUri::Fn- tag aValue::Objectwith$mid: 1.FromFilePath::Fn-file://-scheme builder from an absolute path.FromUrl::Fn- generic-scheme builder from a URL string.Normalize::Fn- accept string / object / missing and return a tagged URI bag.
Modules§
- From
File Path - Build a
file://UriComponentsfrom an absolute filesystem path. Path is emitted verbatim - no percent-encoding, no normalisation - mirroring what VS Code’sURI.file(…)readers expect. - FromUrl
- Build a
UriComponentsfrom a fully-formed URL string. Handlesfile://(authority-optional) and any other scheme generically (scheme:path+ optional//authority). Fragment / query are split off verbatim so downstreamURI.revive()reconstructs the same URL. Strings that don’t parse as URLs fall back to{ scheme:"file", path:<input> }- a defensive shape the workbench tolerates for unknown-location placeholders. - MID_URI
MarshalledId.Uriconstant from VS Code’ssrc/vs/base/common/marshallingIds.ts. The renderer’s URI reviver (_transformIncomingURIsinuriIpc.ts) keys off this exact value to decide whether to callURI.revive(). If VS Code ever renumbers the enum, this constant must move in lockstep.- Normalize
- Normalise an
extensionLocation(or any similar) field that arrives as either a URL string, a pre-builtUriComponentsobject (possibly already tagged), or is missing / null. The output is always a tagged object with the five URI fields. - Stamp
MidUri - Insert
$mid: 1into aUriComponentsobject if it isn’t already tagged. Non-object values pass through unchanged so call sites can pipe anyserde_json::Valuethrough without branching first.