Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion dist/js/constants.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
export declare enum Units {
bohr = "bohr",
angstrom = "angstrom",
degree = "degree",
radian = "radian",
alat = "alat"
}
/**
* @summary Coordinates units for a material's basis.
*/
export declare enum AtomicCoordinateUnits {
crystal = "crystal",
cartesian = "cartesian"
}
export declare enum Tolerance {
length = 0.01,
lengthAngstrom = 0.001,
pointsDistance = 0.001
}
export declare enum Coefficients {
EV_TO_RY = 0.0734986176,
BOHR_TO_ANGSTROM = 0.52917721092,
ANGSTROM_TO_BOHR = 1.8897261245650618,
EV_A_TO_RY_BOHR = 0.03889379346800142
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to have these in ESSE. AtomicCoordinateUnits is already there

}
export declare const HASH_TOLERANCE: 3;
export declare const coefficients: {
EV_TO_RY: number;
BOHR_TO_ANGSTROM: number;
Expand All @@ -23,7 +49,6 @@ export declare const ATOMIC_COORD_UNITS: {
crystal: string;
cartesian: string;
};
export declare const HASH_TOLERANCE = 3;
declare const _default: {
coefficients: {
EV_TO_RY: number;
Expand Down
37 changes: 34 additions & 3 deletions dist/js/constants.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HASH_TOLERANCE = exports.ATOMIC_COORD_UNITS = exports.units = exports.tolerance = exports.coefficients = void 0;
exports.ATOMIC_COORD_UNITS = exports.units = exports.tolerance = exports.coefficients = exports.HASH_TOLERANCE = exports.Coefficients = exports.Tolerance = exports.AtomicCoordinateUnits = exports.Units = void 0;
var Units;
(function (Units) {
Units["bohr"] = "bohr";
Units["angstrom"] = "angstrom";
Units["degree"] = "degree";
Units["radian"] = "radian";
Units["alat"] = "alat";
})(Units || (exports.Units = Units = {}));
/**
* @summary Coordinates units for a material's basis.
*/
var AtomicCoordinateUnits;
(function (AtomicCoordinateUnits) {
AtomicCoordinateUnits["crystal"] = "crystal";
AtomicCoordinateUnits["cartesian"] = "cartesian";
})(AtomicCoordinateUnits || (exports.AtomicCoordinateUnits = AtomicCoordinateUnits = {}));
// in crystal coordinates
var Tolerance;
(function (Tolerance) {
Tolerance[Tolerance["length"] = 0.01] = "length";
Tolerance[Tolerance["lengthAngstrom"] = 0.001] = "lengthAngstrom";
Tolerance[Tolerance["pointsDistance"] = 0.001] = "pointsDistance";
})(Tolerance || (exports.Tolerance = Tolerance = {}));
var Coefficients;
(function (Coefficients) {
Coefficients[Coefficients["EV_TO_RY"] = 0.0734986176] = "EV_TO_RY";
Coefficients[Coefficients["BOHR_TO_ANGSTROM"] = 0.52917721092] = "BOHR_TO_ANGSTROM";
Coefficients[Coefficients["ANGSTROM_TO_BOHR"] = 1.8897261245650618] = "ANGSTROM_TO_BOHR";
Coefficients[Coefficients["EV_A_TO_RY_BOHR"] = 0.03889379346800142] = "EV_A_TO_RY_BOHR";
})(Coefficients || (exports.Coefficients = Coefficients = {}));
// Only 3 digits will be considered for lattice and basis params on hashing
exports.HASH_TOLERANCE = 3;
// TODO: remove everything below this line
exports.coefficients = {
EV_TO_RY: 0.0734986176,
BOHR_TO_ANGSTROM: 0.52917721092,
Expand All @@ -27,8 +60,6 @@ exports.ATOMIC_COORD_UNITS = {
crystal: "crystal",
cartesian: "cartesian",
};
// Only 3 digits will be considered for lattice and basis params on hashing
exports.HASH_TOLERANCE = 3;
exports.default = {
coefficients: exports.coefficients,
tolerance: exports.tolerance,
Expand Down
8 changes: 2 additions & 6 deletions dist/js/entity/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { InMemoryEntity } from "./in_memory";
import { ContextAndRenderFieldsMixin } from "./mixins/context";
import { RuntimeContextFieldMixin } from "./mixins/context_runtime";
import { FlowchartEntityMixin, FlowchartItemMixin } from "./mixins/flowchart";
import { HasScopeTrackMixin } from "./mixins/props";
import { RuntimeItemsMixin } from "./mixins/runtime_items";
import { DefaultableInMemoryEntity, HasConsistencyChecksHasMetadataNamedDefaultableInMemoryEntity, HasMetadataNamedDefaultableInMemoryEntity, NamedDefaultableInMemoryEntity, NamedDefaultableRepetitionContextAndRenderInMemoryEntity, NamedDefaultableRepetitionImportantSettingsInMemoryEntity, NamedDefaultableRepetitionRuntimeItemsImportantSettingsContextAndRenderHashedInMemoryEntity, NamedInMemoryEntity } from "./other";
import { DefaultableInMemoryEntity, HasConsistencyChecksHasMetadataNamedDefaultableInMemoryEntity, HasMetadataNamedDefaultableInMemoryEntity, NamedDefaultableInMemoryEntity, NamedInMemoryEntity } from "./other";
import { InMemoryEntitySet } from "./set";
import { ENTITY_SET_TYPES } from "./set/enums";
import { constructEntitySetFactoryByConfig } from "./set/factory";
import { InMemoryEntityInSetMixin, InMemoryEntitySetMixin } from "./set/mixins";
import { OrderedInMemoryEntityInSetMixin, OrderedInMemoryEntitySetMixin } from "./set/ordered/mixins";
import * as selectorsForEntitySet from "./set/selectors";
export { InMemoryEntity, NamedInMemoryEntity, DefaultableInMemoryEntity, NamedDefaultableInMemoryEntity, HasMetadataNamedDefaultableInMemoryEntity, NamedDefaultableRepetitionContextAndRenderInMemoryEntity, NamedDefaultableRepetitionImportantSettingsInMemoryEntity, NamedDefaultableRepetitionRuntimeItemsImportantSettingsContextAndRenderHashedInMemoryEntity, HasConsistencyChecksHasMetadataNamedDefaultableInMemoryEntity, HasScopeTrackMixin, RuntimeItemsMixin, RuntimeContextFieldMixin, InMemoryEntitySet, ENTITY_SET_TYPES, constructEntitySetFactoryByConfig, selectorsForEntitySet, InMemoryEntitySetMixin, InMemoryEntityInSetMixin, OrderedInMemoryEntitySetMixin, OrderedInMemoryEntityInSetMixin, ContextAndRenderFieldsMixin, FlowchartEntityMixin, FlowchartItemMixin, };
export { InMemoryEntity, NamedInMemoryEntity, DefaultableInMemoryEntity, NamedDefaultableInMemoryEntity, HasMetadataNamedDefaultableInMemoryEntity, HasConsistencyChecksHasMetadataNamedDefaultableInMemoryEntity, RuntimeContextFieldMixin, InMemoryEntitySet, ENTITY_SET_TYPES, constructEntitySetFactoryByConfig, selectorsForEntitySet, InMemoryEntitySetMixin, InMemoryEntityInSetMixin, OrderedInMemoryEntitySetMixin, OrderedInMemoryEntityInSetMixin, };
15 changes: 2 additions & 13 deletions dist/js/entity/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,17 @@ var __importStar = (this && this.__importStar) || (function () {
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.FlowchartItemMixin = exports.FlowchartEntityMixin = exports.ContextAndRenderFieldsMixin = exports.OrderedInMemoryEntityInSetMixin = exports.OrderedInMemoryEntitySetMixin = exports.InMemoryEntityInSetMixin = exports.InMemoryEntitySetMixin = exports.selectorsForEntitySet = exports.constructEntitySetFactoryByConfig = exports.ENTITY_SET_TYPES = exports.InMemoryEntitySet = exports.RuntimeContextFieldMixin = exports.RuntimeItemsMixin = exports.HasScopeTrackMixin = exports.HasConsistencyChecksHasMetadataNamedDefaultableInMemoryEntity = exports.NamedDefaultableRepetitionRuntimeItemsImportantSettingsContextAndRenderHashedInMemoryEntity = exports.NamedDefaultableRepetitionImportantSettingsInMemoryEntity = exports.NamedDefaultableRepetitionContextAndRenderInMemoryEntity = exports.HasMetadataNamedDefaultableInMemoryEntity = exports.NamedDefaultableInMemoryEntity = exports.DefaultableInMemoryEntity = exports.NamedInMemoryEntity = exports.InMemoryEntity = void 0;
exports.OrderedInMemoryEntityInSetMixin = exports.OrderedInMemoryEntitySetMixin = exports.InMemoryEntityInSetMixin = exports.InMemoryEntitySetMixin = exports.selectorsForEntitySet = exports.constructEntitySetFactoryByConfig = exports.ENTITY_SET_TYPES = exports.InMemoryEntitySet = exports.RuntimeContextFieldMixin = exports.HasConsistencyChecksHasMetadataNamedDefaultableInMemoryEntity = exports.HasMetadataNamedDefaultableInMemoryEntity = exports.NamedDefaultableInMemoryEntity = exports.DefaultableInMemoryEntity = exports.NamedInMemoryEntity = exports.InMemoryEntity = void 0;
const in_memory_1 = require("./in_memory");
Object.defineProperty(exports, "InMemoryEntity", { enumerable: true, get: function () { return in_memory_1.InMemoryEntity; } });
const context_1 = require("./mixins/context");
Object.defineProperty(exports, "ContextAndRenderFieldsMixin", { enumerable: true, get: function () { return context_1.ContextAndRenderFieldsMixin; } });
const context_runtime_1 = require("./mixins/context_runtime");
Object.defineProperty(exports, "RuntimeContextFieldMixin", { enumerable: true, get: function () { return context_runtime_1.RuntimeContextFieldMixin; } });
const flowchart_1 = require("./mixins/flowchart");
Object.defineProperty(exports, "FlowchartEntityMixin", { enumerable: true, get: function () { return flowchart_1.FlowchartEntityMixin; } });
Object.defineProperty(exports, "FlowchartItemMixin", { enumerable: true, get: function () { return flowchart_1.FlowchartItemMixin; } });
const props_1 = require("./mixins/props");
Object.defineProperty(exports, "HasScopeTrackMixin", { enumerable: true, get: function () { return props_1.HasScopeTrackMixin; } });
const runtime_items_1 = require("./mixins/runtime_items");
Object.defineProperty(exports, "RuntimeItemsMixin", { enumerable: true, get: function () { return runtime_items_1.RuntimeItemsMixin; } });
// import { RuntimeItemsMixin } from "./mixins/runtime_items";
const other_1 = require("./other");
Object.defineProperty(exports, "DefaultableInMemoryEntity", { enumerable: true, get: function () { return other_1.DefaultableInMemoryEntity; } });
Object.defineProperty(exports, "HasConsistencyChecksHasMetadataNamedDefaultableInMemoryEntity", { enumerable: true, get: function () { return other_1.HasConsistencyChecksHasMetadataNamedDefaultableInMemoryEntity; } });
Object.defineProperty(exports, "HasMetadataNamedDefaultableInMemoryEntity", { enumerable: true, get: function () { return other_1.HasMetadataNamedDefaultableInMemoryEntity; } });
Object.defineProperty(exports, "NamedDefaultableInMemoryEntity", { enumerable: true, get: function () { return other_1.NamedDefaultableInMemoryEntity; } });
Object.defineProperty(exports, "NamedDefaultableRepetitionContextAndRenderInMemoryEntity", { enumerable: true, get: function () { return other_1.NamedDefaultableRepetitionContextAndRenderInMemoryEntity; } });
Object.defineProperty(exports, "NamedDefaultableRepetitionImportantSettingsInMemoryEntity", { enumerable: true, get: function () { return other_1.NamedDefaultableRepetitionImportantSettingsInMemoryEntity; } });
Object.defineProperty(exports, "NamedDefaultableRepetitionRuntimeItemsImportantSettingsContextAndRenderHashedInMemoryEntity", { enumerable: true, get: function () { return other_1.NamedDefaultableRepetitionRuntimeItemsImportantSettingsContextAndRenderHashedInMemoryEntity; } });
Object.defineProperty(exports, "NamedInMemoryEntity", { enumerable: true, get: function () { return other_1.NamedInMemoryEntity; } });
const set_1 = require("./set");
Object.defineProperty(exports, "InMemoryEntitySet", { enumerable: true, get: function () { return set_1.InMemoryEntitySet; } });
Expand Down
15 changes: 15 additions & 0 deletions dist/js/entity/mixins/ContextAndRenderFieldsMixin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
import type { InMemoryEntity } from "../in_memory";
export type Context = AnyObject;
export type ContextAndRenderFields = {
context?: Context;
updateContext(ctx: Context): void;
getPersistentContext(): Context | undefined;
updatePersistentContext(ctx: Context): void;
getCombinedContext(): Context;
};
type AbstractBase = {
render(ctx: Context): void;
};
export declare function contextAndRenderFieldsMixin<T extends InMemoryEntity & AbstractBase>(item: T): asserts item is T & ContextAndRenderFields;
export {};
21 changes: 21 additions & 0 deletions dist/js/entity/mixins/ContextAndRenderFieldsMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.contextAndRenderFieldsMixin = contextAndRenderFieldsMixin;
function contextAndRenderFieldsMixin(item) {
// @ts-expect-error
const properties = {
updateContext(ctx) {
this.context = { ...this.context, ...ctx };
},
getPersistentContext() {
return this.prop("context");
},
updatePersistentContext(ctx) {
this.setProp("context", { ...ctx });
},
getCombinedContext() {
return { ...this.getPersistentContext(), ...this.context };
},
};
Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
}
16 changes: 6 additions & 10 deletions dist/js/entity/mixins/DefaultableMixin.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import type { Constructor } from "../../utils/types";
import { type DefaultableSchemaMixin } from "../../generated/DefaultableSchemaMixin";
import type { AbstractConstructor, Constructor } from "../../utils/types";
import { InMemoryEntity } from "../in_memory";
export declare function defaultableEntityMixin<T extends InMemoryEntity>(item: T): InMemoryEntity & DefaultableInMemoryEntity;
export declare function defaultableEntityStaticMixin(Item: Constructor<InMemoryEntity>): DefaultableInMemoryStaticEntity & Constructor<InMemoryEntity> & Constructor<DefaultableInMemoryEntity> & {
defaultConfig?: object | null;
};
export type DefaultableInMemoryEntity = {
isDefault: boolean;
};
export type Defaultable = DefaultableSchemaMixin;
export type DefaultableInMemoryStaticEntity = {
createDefault: () => InMemoryEntity & DefaultableInMemoryEntity;
createDefault: () => InMemoryEntity & Defaultable;
};
export type DefaultableInMemoryEntityConstructor = Constructor<DefaultableInMemoryEntity> & DefaultableInMemoryStaticEntity;
export type DefaultableInMemoryEntityConstructor = Constructor<Defaultable> & DefaultableInMemoryStaticEntity;
export declare function defaultableEntityMixin(Item: AbstractConstructor<InMemoryEntity>): void;
19 changes: 5 additions & 14 deletions dist/js/entity/mixins/DefaultableMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultableEntityMixin = defaultableEntityMixin;
exports.defaultableEntityStaticMixin = defaultableEntityStaticMixin;
function defaultableEntityMixin(item) {
// @ts-expect-error
const properties = {
get isDefault() {
return this.prop("isDefault", false);
},
set isDefault(isDefault) {
this.setProp("isDefault", isDefault);
},
};
Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
return properties;
}
const DefaultableSchemaMixin_1 = require("../../generated/DefaultableSchemaMixin");
function defaultableEntityStaticMixin(Item) {
// @ts-expect-error
const staticProperties = {
Expand All @@ -26,3 +13,7 @@ function defaultableEntityStaticMixin(Item) {
Object.defineProperties(Item, Object.getOwnPropertyDescriptors(staticProperties));
return staticProperties;
}
function defaultableEntityMixin(Item) {
(0, DefaultableSchemaMixin_1.defaultableSchemaMixin)(Item.prototype);
defaultableEntityStaticMixin(Item);
}
10 changes: 6 additions & 4 deletions dist/js/entity/mixins/HasConsistencyChecksMixin.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { ConsistencyCheck } from "@mat3ra/esse/dist/js/types";
import { type HasConsistencyChecksSchemaMixin } from "../../generated/HasConsistencyChecksSchemaMixin";
import type { Constructor } from "../../utils/types";
import { InMemoryEntity } from "../in_memory";
export declare function hasConsistencyChecksMixin<T extends InMemoryEntity>(item: T): InMemoryEntity & HasConsistencyChecksInMemoryEntity;
export type HasConsistencyChecksInMemoryEntity = {
consistencyChecks: ConsistencyCheck[];
type HasConsistencyChecksProperties = {
addConsistencyChecks: (array: ConsistencyCheck[]) => void;
};
export type HasConsistencyChecksInMemoryEntityConstructor = Constructor<HasConsistencyChecksInMemoryEntity>;
export type HasConsistencyChecks = HasConsistencyChecksSchemaMixin & HasConsistencyChecksProperties;
export type HasConsistencyChecksInMemoryEntityConstructor = Constructor<HasConsistencyChecks>;
export declare function hasConsistencyChecksMixin<T extends InMemoryEntity>(item: T): asserts item is T & HasConsistencyChecks;
export {};
9 changes: 2 additions & 7 deletions dist/js/entity/mixins/HasConsistencyChecksMixin.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasConsistencyChecksMixin = hasConsistencyChecksMixin;
const HasConsistencyChecksSchemaMixin_1 = require("../../generated/HasConsistencyChecksSchemaMixin");
function hasConsistencyChecksMixin(item) {
(0, HasConsistencyChecksSchemaMixin_1.hasConsistencyChecksSchemaMixin)(item);
// @ts-expect-error
const properties = {
get consistencyChecks() {
return this.prop("consistencyChecks", []);
},
set consistencyChecks(array) {
this.setProp("consistencyChecks", array);
},
addConsistencyChecks(array) {
this.consistencyChecks = [...(this.consistencyChecks || []), ...array];
},
};
Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
return properties;
}
12 changes: 3 additions & 9 deletions dist/js/entity/mixins/HasDescriptionMixin.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import type { DescriptionSchema } from "@mat3ra/esse/dist/js/types";
import type { Constructor } from "../../utils/types";
import { InMemoryEntity } from "../in_memory";
export declare function hasDescriptionMixin<T extends InMemoryEntity>(item: T): InMemoryEntity & HasDescriptionInMemoryEntity;
export type HasDescriptionInMemoryEntity = {
description: string;
descriptionObject: DescriptionSchema["descriptionObject"];
};
export type HasDescriptionInMemoryEntityConstructor = Constructor<HasDescriptionInMemoryEntity>;
import { type HasDescriptionSchemaMixin, hasDescriptionSchemaMixin } from "../../generated/HasDescriptionSchemaMixin";
export type HasDescription = HasDescriptionSchemaMixin;
export declare const hasDescriptionPropertiesMixin: typeof hasDescriptionSchemaMixin;
23 changes: 3 additions & 20 deletions dist/js/entity/mixins/HasDescriptionMixin.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasDescriptionMixin = hasDescriptionMixin;
function hasDescriptionMixin(item) {
// @ts-expect-error
const properties = {
get description() {
return this.prop("description", "");
},
set description(string) {
this.setProp("description", string);
},
get descriptionObject() {
return this.prop("descriptionObject");
},
set descriptionObject(obj) {
this.setProp("descriptionObject", obj);
},
};
Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
return properties;
}
exports.hasDescriptionPropertiesMixin = void 0;
const HasDescriptionSchemaMixin_1 = require("../../generated/HasDescriptionSchemaMixin");
exports.hasDescriptionPropertiesMixin = HasDescriptionSchemaMixin_1.hasDescriptionSchemaMixin;
13 changes: 8 additions & 5 deletions dist/js/entity/mixins/HasMetadataMixin.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import type { MetadataSchema } from "@mat3ra/esse/dist/js/types";
import type { Constructor } from "../../utils/types";
import { InMemoryEntity } from "../in_memory";
export declare function hasMetadataMixin<T extends InMemoryEntity>(item: T): InMemoryEntity & HasMetadataInMemoryEntity;
export type HasMetadataInMemoryEntity = {
metadata: object;
updateMetadata: (object: object) => void;
type Metadata = MetadataSchema["metadata"];
export type HasMetadata<T extends Metadata = Metadata> = {
metadata?: T;
updateMetadata: (object: Partial<T>) => void;
};
export type HasMetadataInMemoryEntityConstructor = Constructor<HasMetadataInMemoryEntity>;
export type HasMetadataInMemoryEntityConstructor<T extends Metadata = Metadata> = Constructor<HasMetadata<T>>;
export declare function hasMetadataMixin<T extends InMemoryEntity>(item: T): asserts item is T & HasMetadata;
export {};
14 changes: 8 additions & 6 deletions dist/js/entity/mixins/HasMetadataMixin.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasMetadataMixin = hasMetadataMixin;
function hasMetadataMixin(item) {
function hasMetadataPropertiesMixin(item) {
// @ts-expect-error
const properties = {
get metadata() {
return this.prop("metadata", {});
return this.prop("metadata");
},
set metadata(object) {
this.setProp("metadata", object);
set metadata(value) {
this.setProp("metadata", value);
},
updateMetadata(object) {
this.metadata = { ...this.metadata, ...object };
this.setProp("metadata", { ...this.metadata, ...object });
},
};
Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
return properties;
}
function hasMetadataMixin(item) {
hasMetadataPropertiesMixin(item);
}
Loading
Loading