vue3-math-editor 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +14 -0
- package/README.md +4 -0
- package/dist/style.css +2 -0
- package/dist/types/components/EquationWorkbench.vue.d.ts +49 -0
- package/dist/types/components/MathField.vue.d.ts +39 -0
- package/dist/types/editor/caretGeometry.d.ts +38 -0
- package/dist/types/editor/clipboard.d.ts +9 -0
- package/dist/types/editor/commands.d.ts +37 -0
- package/dist/types/editor/constants.d.ts +13 -0
- package/dist/types/editor/cursor.d.ts +16 -0
- package/dist/types/editor/exports.d.ts +13 -0
- package/dist/types/editor/history.d.ts +34 -0
- package/dist/types/editor/identifiers.d.ts +33 -0
- package/dist/types/editor/keymap.d.ts +7 -0
- package/dist/types/editor/layout.d.ts +82 -0
- package/dist/types/editor/marks.d.ts +8 -0
- package/dist/types/editor/mathmlImport.d.ts +8 -0
- package/dist/types/editor/names.d.ts +15 -0
- package/dist/types/editor/numberUnits.d.ts +15 -0
- package/dist/types/editor/numbers.d.ts +11 -0
- package/dist/types/editor/operators.d.ts +28 -0
- package/dist/types/editor/parse.d.ts +12 -0
- package/dist/types/editor/selection.d.ts +22 -0
- package/dist/types/editor/toolbar.d.ts +18 -0
- package/dist/types/editor/units.d.ts +27 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/registry/nodes.d.ts +21 -0
- package/dist/types/renderers/layoutLatex.d.ts +17 -0
- package/dist/types/renderers/mathjson.d.ts +6 -0
- package/dist/types/renderers/mathml.d.ts +6 -0
- package/dist/types/types/ast.d.ts +97 -0
- package/dist/types/units/UnitsDefinitionForm.vue.d.ts +16 -0
- package/dist/types/units/UnitsPanel.vue.d.ts +56 -0
- package/dist/types/units/check.d.ts +16 -0
- package/dist/types/units/definitions.d.ts +16 -0
- package/dist/types/units/libcellml.d.ts +81 -0
- package/dist/types/units/library.d.ts +29 -0
- package/dist/types/units/messages.d.ts +13 -0
- package/dist/types/units/panel.d.ts +11 -0
- package/dist/types/units/useUnitsChecker.d.ts +36 -0
- package/dist/vue3-math-editor.js +5641 -0
- package/package.json +4 -3
- package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/assets/__vite-browser-external-DRLrqNA5.js +0 -1
- package/dist/assets/index--yUMU8pB.js +0 -1685
- package/dist/assets/index-C7cJKUIb.css +0 -1
- package/dist/assets/libcellml-D9ZPw9_t.wasm +0 -0
- package/dist/assets/primeicons-C6QP2o4f.woff2 +0 -0
- package/dist/assets/primeicons-DMOk5skT.eot +0 -0
- package/dist/assets/primeicons-Dr5RGzOO.svg +0 -345
- package/dist/assets/primeicons-MpK4pl85.ttf +0 -0
- package/dist/assets/primeicons-WjwUDZjB.woff +0 -0
- package/dist/assets/vue3-libcellml-4ponBlEP.js +0 -8
- package/dist/favicon.ico +0 -0
- package/dist/index.html +0 -14
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Row, RowPath } from '../editor/layout';
|
|
2
|
+
export interface LayoutLatexOptions {
|
|
3
|
+
activeRow?: RowPath | null;
|
|
4
|
+
shownUnits?: ReadonlySet<string>;
|
|
5
|
+
greekNames?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function encodeRowPath(path: RowPath): string;
|
|
8
|
+
export declare function decodeRowPath(encoded: string | null | undefined): RowPath | null;
|
|
9
|
+
export declare function rowToLatex(row: Row, options?: LayoutLatexOptions): string;
|
|
10
|
+
export declare const KATEX_EDITOR_OPTIONS: {
|
|
11
|
+
displayMode: boolean;
|
|
12
|
+
throwOnError: boolean;
|
|
13
|
+
strict: "ignore";
|
|
14
|
+
trust: (context: {
|
|
15
|
+
command: string;
|
|
16
|
+
}) => boolean;
|
|
17
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AstNode } from '../types/ast';
|
|
2
|
+
export type MathJsonValue = number | string | null | MathJsonValue[] | {
|
|
3
|
+
[key: string]: MathJsonValue;
|
|
4
|
+
};
|
|
5
|
+
export declare function astToMathJson(node: AstNode): MathJsonValue;
|
|
6
|
+
export declare function renderMathJson(node: AstNode): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AstNode } from '../types/ast';
|
|
2
|
+
export interface ContentMathMLOptions {
|
|
3
|
+
cellml?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const DEFAULT_NUMBER_UNITS = "dimensionless";
|
|
6
|
+
export declare function astToContentMathML(node: AstNode, options?: ContentMathMLOptions): string;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export type AstNode = NumberNode | IdentifierNode | ConstantNode | AddNode | MultiplyNode | SubtractNode | NegateNode | AbsNode | RootNode | FunctionCallNode | EqualNode | ComparisonNode | LogicNode | NotNode | PiecewiseNode | DivideNode | PowerNode | DerivativeNode | GroupNode | PlaceholderNode;
|
|
2
|
+
export interface NumberNode {
|
|
3
|
+
type: 'Number';
|
|
4
|
+
value: number;
|
|
5
|
+
scientific?: {
|
|
6
|
+
mantissa: string;
|
|
7
|
+
exponent: number;
|
|
8
|
+
};
|
|
9
|
+
units?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PlaceholderNode {
|
|
12
|
+
type: 'Placeholder';
|
|
13
|
+
}
|
|
14
|
+
export interface ConstantNode {
|
|
15
|
+
type: 'Constant';
|
|
16
|
+
name: string;
|
|
17
|
+
}
|
|
18
|
+
export interface IdentifierNode {
|
|
19
|
+
type: 'Identifier';
|
|
20
|
+
name: string;
|
|
21
|
+
}
|
|
22
|
+
export interface AddNode {
|
|
23
|
+
type: 'Add';
|
|
24
|
+
children: AstNode[];
|
|
25
|
+
}
|
|
26
|
+
export interface MultiplyNode {
|
|
27
|
+
type: 'Multiply';
|
|
28
|
+
children: AstNode[];
|
|
29
|
+
}
|
|
30
|
+
export interface SubtractNode {
|
|
31
|
+
type: 'Subtract';
|
|
32
|
+
minuend: AstNode;
|
|
33
|
+
subtrahend: AstNode;
|
|
34
|
+
}
|
|
35
|
+
export interface NegateNode {
|
|
36
|
+
type: 'Negate';
|
|
37
|
+
value: AstNode;
|
|
38
|
+
}
|
|
39
|
+
export interface AbsNode {
|
|
40
|
+
type: 'Abs';
|
|
41
|
+
value: AstNode;
|
|
42
|
+
}
|
|
43
|
+
export interface RootNode {
|
|
44
|
+
type: 'Root';
|
|
45
|
+
radicand: AstNode;
|
|
46
|
+
degree: AstNode | null;
|
|
47
|
+
}
|
|
48
|
+
export interface FunctionCallNode {
|
|
49
|
+
type: 'FunctionCall';
|
|
50
|
+
name: string;
|
|
51
|
+
args: AstNode[];
|
|
52
|
+
}
|
|
53
|
+
export interface EqualNode {
|
|
54
|
+
type: 'Equal';
|
|
55
|
+
left: AstNode;
|
|
56
|
+
right: AstNode;
|
|
57
|
+
}
|
|
58
|
+
export interface ComparisonNode {
|
|
59
|
+
type: 'Less' | 'Greater' | 'LessEqual' | 'GreaterEqual' | 'NotEqual';
|
|
60
|
+
left: AstNode;
|
|
61
|
+
right: AstNode;
|
|
62
|
+
}
|
|
63
|
+
export interface LogicNode {
|
|
64
|
+
type: 'And' | 'Or' | 'Xor';
|
|
65
|
+
children: AstNode[];
|
|
66
|
+
}
|
|
67
|
+
export interface NotNode {
|
|
68
|
+
type: 'Not';
|
|
69
|
+
value: AstNode;
|
|
70
|
+
}
|
|
71
|
+
export interface PiecewiseNode {
|
|
72
|
+
type: 'Piecewise';
|
|
73
|
+
pieces: Array<{
|
|
74
|
+
value: AstNode;
|
|
75
|
+
condition: AstNode;
|
|
76
|
+
}>;
|
|
77
|
+
otherwise: AstNode | null;
|
|
78
|
+
}
|
|
79
|
+
export interface DivideNode {
|
|
80
|
+
type: 'Divide';
|
|
81
|
+
numerator: AstNode;
|
|
82
|
+
denominator: AstNode;
|
|
83
|
+
}
|
|
84
|
+
export interface PowerNode {
|
|
85
|
+
type: 'Power';
|
|
86
|
+
base: AstNode;
|
|
87
|
+
exponent: AstNode;
|
|
88
|
+
}
|
|
89
|
+
export interface GroupNode {
|
|
90
|
+
type: 'Group';
|
|
91
|
+
value: AstNode;
|
|
92
|
+
}
|
|
93
|
+
export interface DerivativeNode {
|
|
94
|
+
type: 'Derivative';
|
|
95
|
+
expression: AstNode;
|
|
96
|
+
variable: AstNode;
|
|
97
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type UnitsDefinition } from './definitions';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
definition?: UnitsDefinition | null;
|
|
4
|
+
others: readonly UnitsDefinition[];
|
|
5
|
+
known: readonly string[] | null;
|
|
6
|
+
choices: readonly string[];
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
9
|
+
cancel: () => any;
|
|
10
|
+
save: (definition: UnitsDefinition) => any;
|
|
11
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
12
|
+
onCancel?: (() => any) | undefined;
|
|
13
|
+
onSave?: ((definition: UnitsDefinition) => any) | undefined;
|
|
14
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { EquationLine, UnitsIssue, VariableUnits } from '../editor/units';
|
|
2
|
+
import { type UnitsDefinition } from './definitions';
|
|
3
|
+
import type { UnitsLibraryProblem, UnitsSource } from './library';
|
|
4
|
+
import type { UnitsCheckerStatus } from './useUnitsChecker';
|
|
5
|
+
type __VLS_Props = {
|
|
6
|
+
status: UnitsCheckerStatus;
|
|
7
|
+
lines: readonly EquationLine[];
|
|
8
|
+
files?: readonly {
|
|
9
|
+
name: string;
|
|
10
|
+
units: readonly string[];
|
|
11
|
+
}[];
|
|
12
|
+
problems?: readonly UnitsLibraryProblem[];
|
|
13
|
+
unitsNames?: readonly string[];
|
|
14
|
+
issues?: readonly UnitsIssue[];
|
|
15
|
+
checking?: boolean;
|
|
16
|
+
};
|
|
17
|
+
type __VLS_ModelProps = {
|
|
18
|
+
'sources'?: UnitsSource[];
|
|
19
|
+
'variableUnits'?: VariableUnits;
|
|
20
|
+
'newUnits'?: UnitsDefinition[];
|
|
21
|
+
};
|
|
22
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
23
|
+
declare var __VLS_16: {}, __VLS_32: {
|
|
24
|
+
definitions: UnitsDefinition[];
|
|
25
|
+
};
|
|
26
|
+
type __VLS_Slots = {} & {
|
|
27
|
+
actions?: (props: typeof __VLS_16) => any;
|
|
28
|
+
} & {
|
|
29
|
+
'new-units-actions'?: (props: typeof __VLS_32) => any;
|
|
30
|
+
};
|
|
31
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
32
|
+
"update:sources": (value: UnitsSource[]) => any;
|
|
33
|
+
"update:variableUnits": (value: Readonly<Record<string, string>>) => any;
|
|
34
|
+
"update:newUnits": (value: UnitsDefinition[]) => any;
|
|
35
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
36
|
+
"onUpdate:sources"?: ((value: UnitsSource[]) => any) | undefined;
|
|
37
|
+
"onUpdate:variableUnits"?: ((value: Readonly<Record<string, string>>) => any) | undefined;
|
|
38
|
+
"onUpdate:newUnits"?: ((value: UnitsDefinition[]) => any) | undefined;
|
|
39
|
+
}>, {
|
|
40
|
+
checking: boolean;
|
|
41
|
+
issues: readonly UnitsIssue[];
|
|
42
|
+
problems: readonly UnitsLibraryProblem[];
|
|
43
|
+
files: readonly {
|
|
44
|
+
name: string;
|
|
45
|
+
units: readonly string[];
|
|
46
|
+
}[];
|
|
47
|
+
unitsNames: readonly string[];
|
|
48
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
49
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
50
|
+
declare const _default: typeof __VLS_export;
|
|
51
|
+
export default _default;
|
|
52
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
53
|
+
new (): {
|
|
54
|
+
$slots: S;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { EquationLine, UnitsIssue, VariableUnits } from '../editor/units';
|
|
2
|
+
import { type LibCellML } from './libcellml';
|
|
3
|
+
import type { UnitsLibrary } from './library';
|
|
4
|
+
export declare function missingUnits(line: EquationLine, variableUnits: VariableUnits): string[];
|
|
5
|
+
export declare class UnitsChecker {
|
|
6
|
+
private readonly lc;
|
|
7
|
+
private readonly library;
|
|
8
|
+
private readonly cache;
|
|
9
|
+
constructor(lc: LibCellML, library: UnitsLibrary);
|
|
10
|
+
check(lines: readonly EquationLine[], variableUnits: VariableUnits): UnitsIssue[];
|
|
11
|
+
checkLine(line: EquationLine, variableUnits: VariableUnits): UnitsIssue[];
|
|
12
|
+
private prechecked;
|
|
13
|
+
private analysed;
|
|
14
|
+
private analyse;
|
|
15
|
+
dispose(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface UnitsPart {
|
|
2
|
+
units: string;
|
|
3
|
+
prefix?: string;
|
|
4
|
+
exponent?: number;
|
|
5
|
+
multiplier?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface UnitsDefinition {
|
|
8
|
+
name: string;
|
|
9
|
+
parts: UnitsPart[];
|
|
10
|
+
}
|
|
11
|
+
export declare const NEW_UNITS_SOURCE = "new units";
|
|
12
|
+
export declare const PREFIXES: readonly ["yotta", "zetta", "exa", "peta", "tera", "giga", "mega", "kilo", "hecto", "deca", "deci", "centi", "milli", "micro", "nano", "pico", "femto", "atto", "zepto", "yocto"];
|
|
13
|
+
export declare function definitionProblems(definition: UnitsDefinition, others: readonly UnitsDefinition[], known: readonly string[] | null): string[];
|
|
14
|
+
export declare function usedBy(name: string, definitions: readonly UnitsDefinition[]): string[];
|
|
15
|
+
export declare function describeDefinition(definition: UnitsDefinition): string;
|
|
16
|
+
export declare function newUnitsFile(definitions: readonly UnitsDefinition[], modelName?: string): string;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export interface Deletable {
|
|
2
|
+
delete(): void;
|
|
3
|
+
}
|
|
4
|
+
export interface LcEnum {
|
|
5
|
+
value: number;
|
|
6
|
+
}
|
|
7
|
+
export interface LcIssue extends Deletable {
|
|
8
|
+
description(): string;
|
|
9
|
+
level(): LcEnum;
|
|
10
|
+
referenceRule(): LcEnum | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface LcLogger extends Deletable {
|
|
13
|
+
issueCount(): number;
|
|
14
|
+
issue(index: number): LcIssue;
|
|
15
|
+
}
|
|
16
|
+
export interface LcUnits extends Deletable {
|
|
17
|
+
name(): string;
|
|
18
|
+
setName(name: string): void;
|
|
19
|
+
unitCount(): number;
|
|
20
|
+
unitAttributeReference(index: number): string;
|
|
21
|
+
isImport(): boolean;
|
|
22
|
+
clone(): LcUnits;
|
|
23
|
+
}
|
|
24
|
+
export interface LcVariable extends Deletable {
|
|
25
|
+
setName(name: string): void;
|
|
26
|
+
setUnitsByName(name: string): void;
|
|
27
|
+
}
|
|
28
|
+
export interface LcComponent extends Deletable {
|
|
29
|
+
setName(name: string): void;
|
|
30
|
+
setMath(math: string): void;
|
|
31
|
+
addVariable(variable: LcVariable): boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface LcModel extends Deletable {
|
|
34
|
+
setName(name: string): void;
|
|
35
|
+
unitsCount(): number;
|
|
36
|
+
unitsByIndex(index: number): LcUnits;
|
|
37
|
+
unitsByName(name: string): LcUnits | null;
|
|
38
|
+
addUnits(units: LcUnits): boolean;
|
|
39
|
+
addComponent(component: LcComponent): boolean;
|
|
40
|
+
linkUnits(): boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface LcParser extends LcLogger {
|
|
43
|
+
parseModel(text: string): LcModel;
|
|
44
|
+
}
|
|
45
|
+
export interface LcValidator extends LcLogger {
|
|
46
|
+
validateModel(model: LcModel): void;
|
|
47
|
+
}
|
|
48
|
+
export interface LcAnalyser extends LcLogger {
|
|
49
|
+
analyseModel(model: LcModel): void;
|
|
50
|
+
}
|
|
51
|
+
export interface LcPrinter extends Deletable {
|
|
52
|
+
printModel(model: LcModel): string;
|
|
53
|
+
}
|
|
54
|
+
export interface LibCellML {
|
|
55
|
+
Parser: new (strict: boolean) => LcParser;
|
|
56
|
+
Validator: new () => LcValidator;
|
|
57
|
+
Analyser: new () => LcAnalyser;
|
|
58
|
+
Printer: new () => LcPrinter;
|
|
59
|
+
Model: new () => LcModel;
|
|
60
|
+
Component: new () => LcComponent;
|
|
61
|
+
Variable: new () => LcVariable;
|
|
62
|
+
Units: {
|
|
63
|
+
new (): LcUnits;
|
|
64
|
+
equivalent(a: LcUnits, b: LcUnits): boolean;
|
|
65
|
+
StandardUnit: Record<string, unknown>;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export declare const LEVEL_ERROR = 0;
|
|
69
|
+
export declare const LEVEL_WARNING = 1;
|
|
70
|
+
export declare const RULE_ANALYSER_UNITS = 112;
|
|
71
|
+
export declare function loggerIssues(logger: LcLogger): {
|
|
72
|
+
message: string;
|
|
73
|
+
level: number;
|
|
74
|
+
rule: number;
|
|
75
|
+
}[];
|
|
76
|
+
export declare class Handles {
|
|
77
|
+
private readonly held;
|
|
78
|
+
track<T extends Deletable | null>(handle: T): T;
|
|
79
|
+
dispose(): void;
|
|
80
|
+
}
|
|
81
|
+
export declare function standardUnitsNames(lc: LibCellML): string[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Handles, type LcModel, type LibCellML } from './libcellml';
|
|
2
|
+
export interface UnitsSource {
|
|
3
|
+
name: string;
|
|
4
|
+
text: string;
|
|
5
|
+
}
|
|
6
|
+
export interface UnitsLibraryProblem {
|
|
7
|
+
source: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class UnitsLibrary {
|
|
11
|
+
private readonly lc;
|
|
12
|
+
readonly names: readonly string[];
|
|
13
|
+
readonly sources: readonly {
|
|
14
|
+
name: string;
|
|
15
|
+
units: readonly string[];
|
|
16
|
+
}[];
|
|
17
|
+
readonly problems: readonly UnitsLibraryProblem[];
|
|
18
|
+
private readonly standard;
|
|
19
|
+
private readonly defined;
|
|
20
|
+
private readonly handles;
|
|
21
|
+
private constructor();
|
|
22
|
+
static load(lc: LibCellML, sources: readonly UnitsSource[]): UnitsLibrary;
|
|
23
|
+
isStandard(name: string): boolean;
|
|
24
|
+
isKnown(name: string): boolean;
|
|
25
|
+
requiredBy(names: Iterable<string>): string[];
|
|
26
|
+
addTo(model: LcModel, names: Iterable<string>, handles: Handles): void;
|
|
27
|
+
dispose(): void;
|
|
28
|
+
private parse;
|
|
29
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface Operand {
|
|
2
|
+
text: string;
|
|
3
|
+
units: string;
|
|
4
|
+
}
|
|
5
|
+
export interface UnitsMessage {
|
|
6
|
+
kind: 'mismatch' | 'notDimensionless';
|
|
7
|
+
expression: string;
|
|
8
|
+
operands: Operand[];
|
|
9
|
+
}
|
|
10
|
+
export declare function readUnitsMessage(message: string): UnitsMessage | null;
|
|
11
|
+
export declare function describeUnitsMessage(parsed: UnitsMessage): string;
|
|
12
|
+
export declare function operandVariables(text: string, variables: readonly string[]): string[];
|
|
13
|
+
export declare function operandNumbers(text: string): number[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EquationLine, VariableUnits } from '../editor/units';
|
|
2
|
+
import type { UnitsSource } from './library';
|
|
3
|
+
export interface VariableRow {
|
|
4
|
+
name: string;
|
|
5
|
+
units: string;
|
|
6
|
+
used: boolean;
|
|
7
|
+
state: 'ok' | 'missing' | 'unknown';
|
|
8
|
+
}
|
|
9
|
+
export declare function variableRows(lines: readonly EquationLine[], variableUnits: VariableUnits, unitsNames: readonly string[] | null): VariableRow[];
|
|
10
|
+
export declare function withUnits(variableUnits: VariableUnits, name: string, units: string): VariableUnits;
|
|
11
|
+
export declare function withSources(sources: readonly UnitsSource[], added: readonly UnitsSource[]): UnitsSource[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import type { EquationLine, UnitsIssue, VariableUnits } from '../editor/units';
|
|
3
|
+
import { type UnitsDefinition } from './definitions';
|
|
4
|
+
import { type LibCellML } from './libcellml';
|
|
5
|
+
import { type UnitsSource } from './library';
|
|
6
|
+
export declare const LIBCELLML_KEY = "$libcellml";
|
|
7
|
+
export interface ProvidedLibCellML {
|
|
8
|
+
status: string;
|
|
9
|
+
library: LibCellML | null;
|
|
10
|
+
}
|
|
11
|
+
export type UnitsCheckerStatus = 'unavailable' | 'loading' | 'ready';
|
|
12
|
+
export interface UnitsCheckerOptions {
|
|
13
|
+
lines: MaybeRefOrGetter<readonly EquationLine[]>;
|
|
14
|
+
sources: MaybeRefOrGetter<readonly UnitsSource[]>;
|
|
15
|
+
variableUnits: MaybeRefOrGetter<VariableUnits>;
|
|
16
|
+
newUnits?: MaybeRefOrGetter<readonly UnitsDefinition[]>;
|
|
17
|
+
enabled?: MaybeRefOrGetter<boolean>;
|
|
18
|
+
delay?: number;
|
|
19
|
+
libcellml?: LibCellML | ProvidedLibCellML | null;
|
|
20
|
+
}
|
|
21
|
+
export declare function useUnitsChecker(options: UnitsCheckerOptions): {
|
|
22
|
+
available: import("vue").ComputedRef<boolean>;
|
|
23
|
+
ready: import("vue").ComputedRef<boolean>;
|
|
24
|
+
status: import("vue").ComputedRef<UnitsCheckerStatus>;
|
|
25
|
+
checking: import("vue").ComputedRef<boolean>;
|
|
26
|
+
issues: import("vue").ShallowRef<UnitsIssue[], UnitsIssue[]>;
|
|
27
|
+
files: import("vue").ComputedRef<readonly {
|
|
28
|
+
name: string;
|
|
29
|
+
units: readonly string[];
|
|
30
|
+
}[]>;
|
|
31
|
+
problems: import("vue").ComputedRef<readonly import("./library").UnitsLibraryProblem[]>;
|
|
32
|
+
newUnitsFile: import("vue").ComputedRef<string>;
|
|
33
|
+
unitsNames: import("vue").ComputedRef<string[]>;
|
|
34
|
+
missing: import("vue").ComputedRef<string[]>;
|
|
35
|
+
check: () => void;
|
|
36
|
+
};
|