Documentation / @imvu/chkn / Product
Class: Product
Defined in: packages/chkn/src/Product.ts:67
An IMVU product with its whole inheritance chain loaded: its CFL archive, its _contents.json manifest, its own template, its parent product, and the expanded ProductDefinition.
const source = new CdnProductSource({ revisions: { 53938393: 1, 512: 11 } });
const product = await Product.load(53938393, source);
product.definition.meshes; // Map { 0 => { asset: 'Room.MESH.xmf', … } }
const { skeleton, parts } = await product.loadModel();Constructors
Constructor
new Product(
id,
url,
archive,
manifest,
template,
parent,
definition,
source
): Product;Defined in: packages/chkn/src/Product.ts:71
Internal
Use Product.load.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | number | - |
url | string | The CFL's URL. |
archive | CflArchive | - |
manifest | ReadonlyMap<string, ManifestEntry> | _contents.json entries by file name. |
template | TemplateDict | This product's own template, before inheritance (deletion markers included). |
parent | Product | null | The product it derives from (its first __DATAIMPORT), if any. |
definition | ProductDefinition | The expanded template. |
source | ProductSource | - |
Returns
Product
Properties
archive
readonly archive: CflArchive;Defined in: packages/chkn/src/Product.ts:75
definition
readonly definition: ProductDefinition;Defined in: packages/chkn/src/Product.ts:83
The expanded template.
id
readonly id: number;Defined in: packages/chkn/src/Product.ts:72
manifest
readonly manifest: ReadonlyMap<string, ManifestEntry>;Defined in: packages/chkn/src/Product.ts:77
_contents.json entries by file name.
parent
readonly parent: Product | null;Defined in: packages/chkn/src/Product.ts:81
The product it derives from (its first __DATAIMPORT), if any.
template
readonly template: TemplateDict;Defined in: packages/chkn/src/Product.ts:79
This product's own template, before inheritance (deletion markers included).
url
readonly url: string;Defined in: packages/chkn/src/Product.ts:74
The CFL's URL.
Accessors
ancestors
Get Signature
get ancestors(): Product[];Defined in: packages/chkn/src/Product.ts:99
Parents, nearest first.
Returns
Product[]
assetNames
Get Signature
get assetNames(): Set<string>;Defined in: packages/chkn/src/Product.ts:111
Names of every file reachable through the chain.
Returns
Set<string>
ownAssetNames
Get Signature
get ownAssetNames(): Set<string>;Defined in: packages/chkn/src/Product.ts:106
Names of the files this product itself carries: CFL entries and _contents.json names.
Returns
Set<string>
Methods
fetchAsset()
fetchAsset(name): Promise<Uint8Array<ArrayBufferLike>>;Defined in: packages/chkn/src/Product.ts:147
A file's contents. Textures come from the CDN: the copies inside CFLs are tiny placeholders (16×16 PNGs), and the manifest tags the full-size file original. Everything else comes from the CFL, falling back to the CDN.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
Promise<Uint8Array<ArrayBufferLike>>
flattenedFiles()
flattenedFiles(): Promise<Map<string, Uint8Array<ArrayBufferLike>>>;Defined in: packages/chkn/src/Product.ts:220
The whole ancestor chain rolled up into one standalone product:
index.xmlis the expanded template (every inherited setting written out, no__DATAIMPORT);- every file reachable through the chain, the nearest product's copy winning when names collide (the same lookup the client does), textures at full size;
- no
_contents.json: its entries point at each product's own CDN folder, which means nothing once the files sit side by side.
Returns
Promise<Map<string, Uint8Array<ArrayBufferLike>>>
getAssetUrl()
getAssetUrl(name): string | undefined;Defined in: packages/chkn/src/Product.ts:135
The CDN URL of a file listed in the chain's manifests.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
string | undefined
getFile()
getFile(name): Uint8Array<ArrayBufferLike> | undefined;Defined in: packages/chkn/src/Product.ts:126
A file from the CFL archives of the chain, nearest first (no network).
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
Uint8Array<ArrayBufferLike> | undefined
loadModel()
loadModel(): ProductModel;Defined in: packages/chkn/src/Product.ts:173
Parse the product's Cal3D data: its skeleton and, per body part, the mesh and the materials its submeshes refer to. Textures are not downloaded — each material's maps name them; fetch them with fetchAsset.
Returns
loadSkeleton()
loadSkeleton(): Skeleton | null;Defined in: packages/chkn/src/Product.ts:162
Parse the product's skeleton, if it has one.
Returns
Skeleton | null
ownerOf()
ownerOf(name): Product | undefined;Defined in: packages/chkn/src/Product.ts:118
The nearest product in the chain that carries name (what the client calls its data source).
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
Product | undefined
toChkn()
toChkn(__namedParameters?): Promise<Uint8Array<ArrayBufferLike>>;Defined in: packages/chkn/src/Product.ts:200
Package the product as a .chkn (a ZIP that IMVU's create mode opens), with textures replaced by their full-size CDN originals.
By default it holds the product's own CFL entries, so its index.xml still imports the parent. With flatten: true it is self-contained: see flattenedFiles.
Parameters
| Parameter | Type |
|---|---|
__namedParameters? | ChknOptions |
Returns
Promise<Uint8Array<ArrayBufferLike>>
load()
static load(
productId,
source,
options?
): Promise<Product>;Defined in: packages/chkn/src/Product.ts:90
Load a product and, recursively, every product it imports.
Parameters
| Parameter | Type |
|---|---|
productId | number |
source | ProductSource |
options? | LoadProductOptions |
Returns
Promise<Product>