Skip to content

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.

ts
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 ​

ts
new Product(
   id, 
   url, 
   archive, 
   manifest, 
   template, 
   parent, 
   definition, 
   source
): Product;

Defined in: packages/chkn/src/Product.ts:71

Internal

Use Product.load.

Parameters ​

ParameterTypeDescription
idnumber-
urlstringThe CFL's URL.
archiveCflArchive-
manifestReadonlyMap<string, ManifestEntry>_contents.json entries by file name.
templateTemplateDictThis product's own template, before inheritance (deletion markers included).
parentProduct | nullThe product it derives from (its first __DATAIMPORT), if any.
definitionProductDefinitionThe expanded template.
sourceProductSource-

Returns ​

Product

Properties ​

archive ​

ts
readonly archive: CflArchive;

Defined in: packages/chkn/src/Product.ts:75


definition ​

ts
readonly definition: ProductDefinition;

Defined in: packages/chkn/src/Product.ts:83

The expanded template.


id ​

ts
readonly id: number;

Defined in: packages/chkn/src/Product.ts:72


manifest ​

ts
readonly manifest: ReadonlyMap<string, ManifestEntry>;

Defined in: packages/chkn/src/Product.ts:77

_contents.json entries by file name.


parent ​

ts
readonly parent: Product | null;

Defined in: packages/chkn/src/Product.ts:81

The product it derives from (its first __DATAIMPORT), if any.


template ​

ts
readonly template: TemplateDict;

Defined in: packages/chkn/src/Product.ts:79

This product's own template, before inheritance (deletion markers included).


url ​

ts
readonly url: string;

Defined in: packages/chkn/src/Product.ts:74

The CFL's URL.

Accessors ​

ancestors ​

Get Signature ​

ts
get ancestors(): Product[];

Defined in: packages/chkn/src/Product.ts:99

Parents, nearest first.

Returns ​

Product[]


assetNames ​

Get Signature ​

ts
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 ​

ts
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() ​

ts
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 ​

ParameterType
namestring

Returns ​

Promise<Uint8Array<ArrayBufferLike>>


flattenedFiles() ​

ts
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.xml is 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() ​

ts
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 ​

ParameterType
namestring

Returns ​

string | undefined


getFile() ​

ts
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 ​

ParameterType
namestring

Returns ​

Uint8Array<ArrayBufferLike> | undefined


loadModel() ​

ts
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 ​

ProductModel


loadSkeleton() ​

ts
loadSkeleton(): Skeleton | null;

Defined in: packages/chkn/src/Product.ts:162

Parse the product's skeleton, if it has one.

Returns ​

Skeleton | null


ownerOf() ​

ts
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 ​

ParameterType
namestring

Returns ​

Product | undefined


toChkn() ​

ts
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 ​

ParameterType
__namedParameters?ChknOptions

Returns ​

Promise<Uint8Array<ArrayBufferLike>>


load() ​

ts
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 ​

ParameterType
productIdnumber
sourceProductSource
options?LoadProductOptions

Returns ​

Promise<Product>

Released under the MIT License.