UNPKG

@gmetrixr/rjson

Version:
36 lines (35 loc) 1.26 kB
import * as R from "./R"; import { RT, rtp, createRecord, emptyROM } from "./R"; import { RecordUtils } from "./R/RecordFactory"; import { ElementUtils } from "./recordFactories/ElementFactory"; import { ProjectUtils } from "./recordFactories/ProjectFactory"; import * as RF from "./recordFactories"; import { en, sn, vn, rn, pn, fn } from "./definitions"; /** * Use r.record(json) for all RecordNode type objects, except the below ones * For project, scene, rule and element only there are overridden factories */ const r = { "record": (json) => new R.RecordFactory(json), "project": (json) => new RF.ProjectFactory(json), "scene": (json) => new RF.SceneFactory(json), "element": (json) => new RF.ElementFactory(json), }; const rUtils = { ElementUtils, ProjectUtils, RecordUtils, }; const getFactory = (rJson) => { switch (rJson.type) { case RT.project: return new RF.ProjectFactory(rJson); case RT.scene: return new RF.SceneFactory(rJson); case RT.element: return new RF.ElementFactory(rJson); default: return new R.RecordFactory(rJson); } }; export { R, r, RF, rUtils, RT, rtp, createRecord, emptyROM, getFactory, en, sn, vn, rn, pn, fn };