npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@carbonenginejs/core-types

v0.4.6

Published

Shared CarbonEngineJS type normalization, schema metadata, document graph, and runtime model helpers.

Downloads

1,497

Readme

@carbonenginejs/core-types

Shared CarbonEngineJS type, schema, document, hydration, and runtime model helpers.

This package is the common contract for packages that read, write, or generate CarbonEngineJS data. Format packages can stop at plain JSON or a neutral CjsCarbonDocument; runtime packages can opt into registered classes and CjsModel when they want live objects.

Install

npm install @carbonenginejs/core-types

What It Owns

  • document: neutral CjsCarbonDocument, class/struct registries, hydration, and dehydration.
  • hydration: adapter seam for construction, value application, and finalize behavior.
  • schema: decorators, class/field/method metadata, enum registration, Carbon-method provenance, and component metadata helpers.
  • types: Carbon type descriptors, defaults, coercion, cloning, and export helpers.
  • model: CjsModel, CjsEventEmitter, CjsEventEmitterScope, CjsModelDirtyState, traversal helpers, and source-record utilities.

Generated enums and generated class catalogs should live in schema or generated runtime packages, not in this foundational package.

Hydration Contract

core-types does not impose a runtime lifecycle on callers. The hydrator only guarantees ordering:

  1. construct
  2. applyValues
  3. finalize

The default behavior is intentionally minimal: registry/class construction, Object.assign for values, and no finalize step. Callers opt into stricter population rules by supplying an adapter.

Use createLifecycleAdapter() when your runtime classes follow a SetValues-style contract. Initialize is optional; disable it explicitly when a project only wants SetValues.

Usage

Hydrate a neutral document into runtime classes

import {
  CjsCarbonDocument,
  CjsClassRegistry,
  CjsDocumentHydrator,
  CjsModel,
  CjsSchema
} from "@carbonenginejs/core-types";
import { createLifecycleAdapter } from "@carbonenginejs/core-types/hydration";

class DemoNode extends CjsModel
{
  position = [0, 0, 0];
}

CjsSchema.define(DemoNode, { className: "DemoNode" });
CjsSchema.defineField(DemoNode, "position", "type", { kind: "vec3" });
CjsSchema.defineField(DemoNode, "position", "io", {
  read: true,
  write: true,
  persist: true,
  notify: true
});

const document = CjsCarbonDocument.create({
  format: "example",
  roots: [{ ref: { $ref: 1 } }],
  nodes: [{
    id: 1,
    kind: "DemoNode",
    fields: { position: [1, 2, 3] }
  }]
});

const registry = CjsClassRegistry.fromMaps({
  constructors: { DemoNode }
});

const adapter = createLifecycleAdapter({ initialize: false });
const { root } = CjsDocumentHydrator.hydrate(document, { registry, adapter });

Work with schema-backed runtime models directly

const node = DemoNode.from({ position: [1, 2, 3] });

node.OnEvent("modified", (_target, payload) => {
  console.log([...payload.properties]);
});

node.SetValues({ position: [4, 5, 6] });
const plain = node.GetValues();

CjsModel is evented, tracks dirty/update state explicitly, and uses schema metadata as its default field contract. registerSourceShapes() and initializeSourceFields() still exist for source-shaped compatibility, but new schema-backed model classes do not need them.

Subpaths

import { CjsCarbonDocument, CjsDocumentHydrator } from "@carbonenginejs/core-types/document";
import { createLifecycleAdapter } from "@carbonenginejs/core-types/hydration";
import { CjsSchema, type, io, carbon, components } from "@carbonenginejs/core-types/schema";
import { CjsModel, CjsEventEmitter, CjsModelDirtyState } from "@carbonenginejs/core-types/model";
import { CARBON_TYPE, normalizeCarbonValue } from "@carbonenginejs/core-types/types";