Built-ins
The host defines these globals before your app runs. This page lists where a global differs from the Web standards and how to load their types. Console has its own page.
Types
Add the types of these globals to your tsconfig.json:
{
"compilerOptions": {
"types": ["incajs/globals"]
}
}Don't load the DOM and Node.js types. They declare names the host does not define, such as the window object and the fetch function. With @types/node loaded as well, keep skipLibCheck on. A file that uses Node APIs, such as an inca.config.ts that reads process.env, belongs in a second tsconfig with "types": ["node"].
TextEncoder and TextDecoder
Both follow the Encoding Standard.
TextEncoderStreamandTextDecoderStreamare missing.- The host refuses two cases of a detached buffer:
encodeInto()with a view over a detached resizable buffer throws aTypeError.decode()returns an empty string when astreamgetter of the options detaches the buffer of the view.
URL and URLSearchParams
Both follow the URL Standard.
URL.createObjectURL()andURL.revokeObjectURL()are missing, because the host has noBlob.new URLSearchParams(record)reads aProxyrecord in this order: everygetOwnPropertyDescriptortrap, then everygettrap.- A URL of 4 GiB or more aborts the host.
- The
originof afile:URL isfile://.
These results of parsing and setting differ from the ones of browsers:
- The characters
^and|stay raw in a path. - Setting
pathnameto//xonfoo:/pgivesfoo://x. - A space in a host and the label
xn--aare refused. - Setting
protocoltohttponmailto:x?q#fchanges nothing. - The
originoffilesystem:http://a/t/xis"null". - On
data:a ?x,searchParams.delete("x")andsearch = ""givedata:a. Ondata:a #x,hash = ""givesdata:a.
These results for file: URLs differ from the ones of browsers:
file:///C|/xkeeps the|.file://C:/xparses.- The host
localhostis dropped, also by thehostnamesetter. file:///c:/../xand/xagainstfile:///C:/a/bkeep the drive letter.
structuredClone()
structuredClone() follows the HTML Standard. It differs in two places:
- A view that tracks the length of a resizable
ArrayBufferbecomes a view of a fixed length when it is cloned. - A
SharedArrayBufferand a view over one throw aDataCloneError.
performance
now()counts milliseconds from the start of the app, and a reload of the development window starts it again.timeOriginand the entries ofmark()andmeasure()start again with it.- The timeline starts empty. It holds the entries of
mark()andmeasure(), and no other entry type. toJSON()returnstimeOriginonly, and entries have nonavigationId.performanceis not anEventTarget, so it has noaddEventListener().measure()with a navigation timing name, such asfetchStart, asstartorendthrowsInvalidAccessError.navigationStartis 0.- These do not exist:
PerformanceObservertimingnavigationmemoryeventCountsinteractionCountclearResourceTimings()setResourceTimingBufferSize()onresourcetimingbufferfull
crypto
This follows the Web Cryptography API.
CryptoKeyis missing, and so are allSubtleCryptomethods exceptdigest():generateKey()importKey()exportKey()sign()verify()encrypt()decrypt()deriveKey()deriveBits()wrapKey()unwrapKey()
AbortController and AbortSignal
AbortSignal.timeout()waits at most 4294967295 milliseconds.- A signal that one of its own listeners refers to stays in memory until it aborts.
- One start of the host can create 2^32 - 1 signals, and a reload of the development window starts the count again. After that,
new AbortController(),AbortSignal.abort(),AbortSignal.timeout()andAbortSignal.any()throw aRangeError.
setTimeout() and setInterval()
These follow the HTML Standard.
- A handler must be a function. A string or any other value throws a
TypeError. - An interval keeps its schedule. After a late run, the next run is the next point of the original schedule, and the runs it missed are skipped.
requestAnimationFrame()
This follows the HTML Standard.
- A callback must be a function. A string or any other value throws a
TypeError. - On macOS, callbacks wait while another window fully covers the app's window, and run when it is uncovered.
Limits
- One run of the app can register 2^31 - 1 timers, frame callbacks and event listeners in total. A cleared or removed one still counts. After that, these throw a
RangeError:setTimeout()AbortSignal.timeout()setInterval()requestAnimationFrame()addEventListener()
- A reload of the development window starts the count again.