Skip to content

mkeblx/model-type

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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-type

Usage

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:

  • HTMLModelElement
  • HTMLElementTagNameMap["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.

About

TypeScript types for the HTML `<model>` element

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors