@mkeblx/model-type
v0.1.0
Published
TypeScript types for the HTML model element.
Readme
model-type
TypeScript types for the HTML <model> element.
This package adds a global HTMLModelElement interface and augments HTMLElementTagNameMap so DOM APIs like document.createElement("model") and querySelector("model") are typed in TypeScript.
Installation
npm install @mkeblx/model-typeUsage
This package is published as a normal npm package with bundled .d.ts files. To activate the global DOM augmentation in TypeScript, use one of these approaches.
Option 1: side-effect import
import "@mkeblx/model-type";
const model = document.createElement("model");
model.src = "/asset.usdz";
await model.play();Option 2: tsconfig.json
{
"compilerOptions": {
"types": ["@mkeblx/model-type"]
}
}This is useful if you want the types available project-wide without importing the package in source files.
Included types
The package defines:
HTMLModelElementHTMLElementTagNameMap["model"]
Example:
import "@mkeblx/model-type";
const model = document.createElement("model");
model.src = "/asset.usdz";
model.environmentMap = "/studio.hdr";
model.currentTime = 0;
await model.ready;
await model.play();API coverage
The type surface is based on the current WebKit HTMLModelElement IDL.
Reference: https://github.com/WebKit/WebKit/blob/main/Source/WebCore/Modules/model-element/HTMLModelElement.idl
Notes
- This package provides types only.
- It does not polyfill or implement the
<model>element. - Browser support for
<model>depends on the platform and engine.
