@bikky/replication 1.0.1
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/Constants/Errors.d.ts +27 -0
- package/Constants/Errors.js +75 -0
- package/Constants/Logging.d.ts +17 -0
- package/Constants/Logging.js +97 -0
- package/Constants/ReplicableRegistry.d.ts +37 -0
- package/Constants/ReplicableRegistry.js +234 -0
- package/Constants/SerialisationTypes.d.ts +82 -0
- package/Constants/SerialisationTypes.js +160 -0
- package/Constants/SourceMaps.d.ts +10 -0
- package/Constants/SourceMaps.js +12 -0
- package/Constants/TraversalStep.d.ts +5 -0
- package/Constants/TraversalStep.js +2 -0
- package/Constants/Versions.d.ts +15 -0
- package/Constants/Versions.js +63 -0
- package/Expressions/Compiler/BuiltinGrammar.d.ts +234 -0
- package/Expressions/Compiler/BuiltinGrammar.js +446 -0
- package/Expressions/Compiler/ExpressionGrammar.d.ts +89 -0
- package/Expressions/Compiler/ExpressionGrammar.js +70 -0
- package/Expressions/Compiler/Parser.d.ts +56 -0
- package/Expressions/Compiler/Parser.js +314 -0
- package/Expressions/Compiler/Tokenizer.d.ts +52 -0
- package/Expressions/Compiler/Tokenizer.js +222 -0
- package/Expressions/Compiler/__tests__/Replicable.Expressions.Parser.test.d.ts +1 -0
- package/Expressions/Compiler/__tests__/Replicable.Expressions.Parser.test.js +516 -0
- package/Expressions/Compiler/__tests__/Replicable.Expressions.Tokenizer.test.d.ts +1 -0
- package/Expressions/Compiler/__tests__/Replicable.Expressions.Tokenizer.test.js +68 -0
- package/Expressions/CreateEvaluator.d.ts +4 -0
- package/Expressions/CreateEvaluator.js +85 -0
- package/Expressions/EvaluatorChain.d.ts +19 -0
- package/Expressions/EvaluatorChain.js +137 -0
- package/Expressions/EvaluatorSteps.d.ts +19 -0
- package/Expressions/EvaluatorSteps.js +12 -0
- package/Expressions/EvaluatorString.d.ts +21 -0
- package/Expressions/EvaluatorString.js +26 -0
- package/Expressions/Expression.d.ts +36 -0
- package/Expressions/Expression.js +147 -0
- package/Expressions/Traverser.d.ts +28 -0
- package/Expressions/Traverser.js +348 -0
- package/Expressions/TypeRegistry/Accessors.d.ts +26 -0
- package/Expressions/TypeRegistry/Accessors.js +58 -0
- package/Expressions/TypeRegistry/ChainCollections.d.ts +51 -0
- package/Expressions/TypeRegistry/ChainCollections.js +134 -0
- package/Expressions/TypeRegistry/ChainTypes.d.ts +23 -0
- package/Expressions/TypeRegistry/ChainTypes.js +46 -0
- package/Expressions/TypeRegistry/CustomAPI.d.ts +36 -0
- package/Expressions/TypeRegistry/CustomAPI.js +181 -0
- package/Expressions/TypeRegistry/Primitive.d.ts +19 -0
- package/Expressions/TypeRegistry/Primitive.js +47 -0
- package/Expressions/TypeRegistry/Registry.d.ts +27 -0
- package/Expressions/TypeRegistry/Registry.js +270 -0
- package/Expressions/TypeRegistry/ReplAPI.d.ts +41 -0
- package/Expressions/TypeRegistry/ReplAPI.js +220 -0
- package/Expressions/TypeRegistry/Scope.d.ts +24 -0
- package/Expressions/TypeRegistry/Scope.js +44 -0
- package/Expressions/TypeRegistry/Types.d.ts +23 -0
- package/Expressions/TypeRegistry/Types.js +1 -0
- package/Expressions/TypeRegistry/__tests__/Replicable.Expressions.Accessors.test.d.ts +1 -0
- package/Expressions/TypeRegistry/__tests__/Replicable.Expressions.Accessors.test.js +31 -0
- package/Expressions/__tests__/ExpressionExamples.d.ts +28 -0
- package/Expressions/__tests__/ExpressionExamples.js +50 -0
- package/Expressions/__tests__/Replicable.Expressions.Expressions.test.d.ts +1 -0
- package/Expressions/__tests__/Replicable.Expressions.Expressions.test.js +166 -0
- package/IDPool.d.ts +18 -0
- package/IDPool.data.d.ts +17 -0
- package/IDPool.js +139 -0
- package/License.txt +1 -0
- package/Main.d.ts +13 -0
- package/Main.js +13 -0
- package/Networking.d.ts +60 -0
- package/Networking.js +626 -0
- package/Replicatable.d.ts +66 -0
- package/Replicatable.js +123 -0
- package/Tracking/Buffable.d.ts +68 -0
- package/Tracking/Buffable.js +194 -0
- package/Tracking/Class.d.ts +97 -0
- package/Tracking/Class.js +221 -0
- package/Tracking/Functions.d.ts +14 -0
- package/Tracking/Functions.js +27 -0
- package/Tracking/GlobalGroup.d.ts +5 -0
- package/Tracking/GlobalGroup.js +39 -0
- package/Tracking/Property.d.ts +95 -0
- package/Tracking/Property.js +125 -0
- package/Tracking/Types.d.ts +33 -0
- package/Tracking/Types.js +1 -0
- package/Tracking/__tests__/Replicable.Tracking.Decorator.test.d.ts +1 -0
- package/Tracking/__tests__/Replicable.Tracking.Decorator.test.js +151 -0
- package/Tracking/__tests__/Replicable.Tracking.Deserialisation.test.d.ts +1 -0
- package/Tracking/__tests__/Replicable.Tracking.Deserialisation.test.js +253 -0
- package/Tracking/__tests__/Replicable.Tracking.MixinSchemaGeneration.test.d.ts +1 -0
- package/Tracking/__tests__/Replicable.Tracking.MixinSchemaGeneration.test.js +135 -0
- package/Tracking/__tests__/Replicable.Tracking.Struct.test.d.ts +1 -0
- package/Tracking/__tests__/Replicable.Tracking.Struct.test.js +66 -0
- package/Tracking/__tests__/Replicable.Tracking.Type.test.d.ts +1 -0
- package/Tracking/__tests__/Replicable.Tracking.Type.test.js +67 -0
- package/Transformers/Configurer.d.ts +39 -0
- package/Transformers/Configurer.js +415 -0
- package/Transformers/Constructor.d.ts +12 -0
- package/Transformers/Constructor.js +44 -0
- package/Transformers/Definitions.d.ts +102 -0
- package/Transformers/Definitions.js +626 -0
- package/Transformers/Loader.d.ts +45 -0
- package/Transformers/Loader.js +350 -0
- package/Transformers/Progress.d.ts +32 -0
- package/Transformers/Progress.js +429 -0
- package/Transformers/Reference.d.ts +37 -0
- package/Transformers/Reference.js +212 -0
- package/Transformers/SchemaGenerator.d.ts +102 -0
- package/Transformers/SchemaGenerator.js +564 -0
- package/Transformers/Serialiser.d.ts +31 -0
- package/Transformers/Serialiser.js +366 -0
- package/Transformers/Utils.d.ts +33 -0
- package/Transformers/Utils.js +287 -0
- package/Transformers/__tests__/Examples.d.ts +168 -0
- package/Transformers/__tests__/Examples.js +263 -0
- package/Transformers/__tests__/Replicable.Transformers.Definitions.test.d.ts +1 -0
- package/Transformers/__tests__/Replicable.Transformers.Definitions.test.js +457 -0
- package/Transformers/__tests__/Replicable.Transformers.Loader.test.d.ts +1 -0
- package/Transformers/__tests__/Replicable.Transformers.Loader.test.js +339 -0
- package/Transformers/__tests__/Replicable.Transformers.Progress.test.d.ts +1 -0
- package/Transformers/__tests__/Replicable.Transformers.Progress.test.js +256 -0
- package/Transformers/__tests__/Replicable.Transformers.Reference.test.d.ts +1 -0
- package/Transformers/__tests__/Replicable.Transformers.Reference.test.js +167 -0
- package/Transformers/__tests__/Replicable.Transformers.SchemaGenerator.test.d.ts +1 -0
- package/Transformers/__tests__/Replicable.Transformers.SchemaGenerator.test.js +400 -0
- package/Transformers/__tests__/Replicable.Transformers.SchemaGeneratorOutput.test.d.ts +1 -0
- package/Transformers/__tests__/Replicable.Transformers.SchemaGeneratorOutput.test.js +441 -0
- package/Transformers/__tests__/Replicable.Transformers.Serialiser.test.d.ts +1 -0
- package/Transformers/__tests__/Replicable.Transformers.Serialiser.test.js +320 -0
- package/Transformers/__tests__/Replicable.Transformers.Utils.test.d.ts +1 -0
- package/Transformers/__tests__/Replicable.Transformers.Utils.test.js +534 -0
- package/__tests__/Replicable.Expressions.test.d.ts +1 -0
- package/__tests__/Replicable.Expressions.test.js +166 -0
- package/__tests__/Replicable.IDPool.test.d.ts +1 -0
- package/__tests__/Replicable.IDPool.test.js +11 -0
- package/__tests__/Replicable.ReplicableRegistry.test.d.ts +1 -0
- package/__tests__/Replicable.ReplicableRegistry.test.js +154 -0
- package/__tests__/Replicable.Serialisation.test.d.ts +1 -0
- package/__tests__/Replicable.Serialisation.test.js +283 -0
- package/package.json +14 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ExpressionSyntaxError } from "../../Constants/Errors.js";
|
|
2
|
+
export class ChainType {
|
|
3
|
+
constructor(debugName) {
|
|
4
|
+
this.debugName = debugName;
|
|
5
|
+
}
|
|
6
|
+
getOutputTypes() {
|
|
7
|
+
return [this.getOwnOutputTypes(), this.getOwnOutputStyle()];
|
|
8
|
+
}
|
|
9
|
+
checkContextScopes(version, prop, node, contexts) {
|
|
10
|
+
if (contexts && contexts.length > 0) {
|
|
11
|
+
let [parentContext, ...rest] = contexts;
|
|
12
|
+
try {
|
|
13
|
+
return parentContext.getLive(version, prop, node, rest);
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
if (e instanceof ExpressionSyntaxError) {
|
|
17
|
+
e.message = e.message.replace(/\n/, ` Nor on type "${this.debugName}".\n`);
|
|
18
|
+
e.stack = e.stack.replace(/\n/, ` Nor on type "${this.debugName}".\n`);
|
|
19
|
+
}
|
|
20
|
+
throw e;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
let appendix = "";
|
|
24
|
+
//Kinda hacky, but since expressions are PascalCase by default, we can do a hard-coded reminder here.
|
|
25
|
+
//TODO: Actually check to see if the upper-case version exists.
|
|
26
|
+
if (prop[0].toLowerCase() == prop[0]) {
|
|
27
|
+
appendix = ` Did you mean to write "${prop[0].toUpperCase() + prop.slice(1)}"?`;
|
|
28
|
+
}
|
|
29
|
+
throw new ExpressionSyntaxError(`Error: Key "${prop}" doesn't exist on type "${this.debugName}".` + appendix, node);
|
|
30
|
+
}
|
|
31
|
+
checkContextsData(version, prop, node, parents) {
|
|
32
|
+
if (parents && parents.length > 0) {
|
|
33
|
+
let [parent, ...rest] = parents;
|
|
34
|
+
try {
|
|
35
|
+
return parent.getData(version, prop, node, rest);
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
if (e instanceof ExpressionSyntaxError) {
|
|
39
|
+
e.message.replace(/\n/, `\nNor in scope ${this.debugName}.\n`);
|
|
40
|
+
}
|
|
41
|
+
throw e;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
throw new ExpressionSyntaxError(`No variable with the name ${prop} exists in scope ${this.debugName}.`, node);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ChainType } from "./ChainTypes.js";
|
|
2
|
+
import { Versions } from "../../Constants/Versions.js";
|
|
3
|
+
import { ErrorStack } from "../../Constants/Errors.js";
|
|
4
|
+
import { ExpressionGrammar } from "../Compiler/ExpressionGrammar.js";
|
|
5
|
+
import Node = ExpressionGrammar.Node;
|
|
6
|
+
export declare class CustomType extends ChainType {
|
|
7
|
+
typePlaceholder: any;
|
|
8
|
+
properties: any;
|
|
9
|
+
dataProperties: any;
|
|
10
|
+
name: string;
|
|
11
|
+
isLiveOfType?: (obj: any) => boolean;
|
|
12
|
+
isDataOfType?: (data: any) => boolean;
|
|
13
|
+
typeCastableToThis?: (type: any) => boolean;
|
|
14
|
+
constructor(name: string, thing: any);
|
|
15
|
+
getOwnOutputTypes(): any[];
|
|
16
|
+
getOwnOutputStyle(): ReturnType<ChainType["getOwnOutputStyle"]>;
|
|
17
|
+
isAssignableCompile(version: Versions, type: any): boolean;
|
|
18
|
+
isAssignableLive(version: Versions, value: any): any;
|
|
19
|
+
isAssignableData(version: Versions, value: any, stack: ErrorStack): any;
|
|
20
|
+
isCastableCompile(version: Versions, type: any): any;
|
|
21
|
+
isCastableLive(version: Versions, value: any): any;
|
|
22
|
+
isCastableData(version: Versions, value: any, stack: ErrorStack): any;
|
|
23
|
+
getLive(version: Versions, prop: string, node: Node, parents?: ChainType[]): any;
|
|
24
|
+
getData(version: Versions, prop: string, node: Node, parents?: ChainType[]): any;
|
|
25
|
+
}
|
|
26
|
+
export declare class CustomExpressionTypeAPI {
|
|
27
|
+
#private;
|
|
28
|
+
constructor(type: "Custom", name: string, source: any);
|
|
29
|
+
registerIsTypeCheck(isLiveOfType: (obj: any) => boolean): this;
|
|
30
|
+
registerIsDataCheck(isDataOfType: (data: any) => boolean): this;
|
|
31
|
+
registerIsTypeCastableToThis(typeCastableToThis: (type: any) => boolean): this;
|
|
32
|
+
addProperty(version: Versions, name: string, types: any[]): this;
|
|
33
|
+
addMap(version: Versions, name: string, types: any[]): this;
|
|
34
|
+
addDict(version: Versions, name: string, types: any[]): this;
|
|
35
|
+
addFunction(version: Versions, name: string, types: any[], parameters: any[][]): this;
|
|
36
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _CustomExpressionTypeAPI_private;
|
|
13
|
+
import { InstantPromise, VersionMap } from "@bikky/smart-collections";
|
|
14
|
+
import { ChainType } from "./ChainTypes.js";
|
|
15
|
+
import { ChainFunction, ChainProperty } from "./Accessors.js";
|
|
16
|
+
import { GetAllVersionsAfter, Versions } from "../../Constants/Versions.js";
|
|
17
|
+
import { ValidExpressionTypes } from "./Registry.js";
|
|
18
|
+
import { Progress } from "../../Transformers/Progress.js";
|
|
19
|
+
export class CustomType extends ChainType {
|
|
20
|
+
constructor(name, thing) {
|
|
21
|
+
super(name);
|
|
22
|
+
this.properties = new VersionMap(Versions.v1_0_0);
|
|
23
|
+
this.dataProperties = new VersionMap(Versions.v1_0_0);
|
|
24
|
+
this.name = name;
|
|
25
|
+
this.typePlaceholder = thing;
|
|
26
|
+
ValidExpressionTypes.SetTypeChain(thing, this);
|
|
27
|
+
ValidExpressionTypes.AddAliasForType(name, thing);
|
|
28
|
+
}
|
|
29
|
+
getOwnOutputTypes() {
|
|
30
|
+
return [this.typePlaceholder];
|
|
31
|
+
}
|
|
32
|
+
getOwnOutputStyle() {
|
|
33
|
+
return "Single";
|
|
34
|
+
}
|
|
35
|
+
isAssignableCompile(version, type) {
|
|
36
|
+
var _a;
|
|
37
|
+
return ((_a = this.typeCastableToThis) === null || _a === void 0 ? void 0 : _a.call(this, type)) || type == this.typePlaceholder;
|
|
38
|
+
}
|
|
39
|
+
isAssignableLive(version, value) {
|
|
40
|
+
var _a, _b, _c, _d, _e;
|
|
41
|
+
return (_e = (_b = (_a = this.isLiveOfType) === null || _a === void 0 ? void 0 : _a.call(this, value)) !== null && _b !== void 0 ? _b : (_d = (_c = this.typePlaceholder).isLiveOfType) === null || _d === void 0 ? void 0 : _d.call(_c, value)) !== null && _e !== void 0 ? _e : false;
|
|
42
|
+
}
|
|
43
|
+
isAssignableData(version, value, stack) {
|
|
44
|
+
var _a, _b, _c, _d, _e;
|
|
45
|
+
return (_e = (_b = (_a = this.isDataOfType) === null || _a === void 0 ? void 0 : _a.call(this, value)) !== null && _b !== void 0 ? _b : (_d = (_c = this.typePlaceholder).isDataOfType) === null || _d === void 0 ? void 0 : _d.call(_c, value)) !== null && _e !== void 0 ? _e : false;
|
|
46
|
+
}
|
|
47
|
+
isCastableCompile(version, type) {
|
|
48
|
+
var _a, _b, _c, _d, _e;
|
|
49
|
+
return (_e = (_b = (_a = this.typeCastableToThis) === null || _a === void 0 ? void 0 : _a.call(this, type)) !== null && _b !== void 0 ? _b : (_d = (_c = this.typePlaceholder).typeCastableToThis) === null || _d === void 0 ? void 0 : _d.call(_c, type)) !== null && _e !== void 0 ? _e : false;
|
|
50
|
+
}
|
|
51
|
+
isCastableLive(version, value) {
|
|
52
|
+
var _a, _b, _c, _d, _e;
|
|
53
|
+
return (_e = (_b = (_a = this.isLiveOfType) === null || _a === void 0 ? void 0 : _a.call(this, value)) !== null && _b !== void 0 ? _b : (_d = (_c = this.typePlaceholder).isLiveOfType) === null || _d === void 0 ? void 0 : _d.call(_c, value)) !== null && _e !== void 0 ? _e : false;
|
|
54
|
+
}
|
|
55
|
+
isCastableData(version, value, stack) {
|
|
56
|
+
var _a, _b, _c, _d, _e;
|
|
57
|
+
return (_e = (_b = (_a = this.isDataOfType) === null || _a === void 0 ? void 0 : _a.call(this, value)) !== null && _b !== void 0 ? _b : (_d = (_c = this.typePlaceholder).isDataOfType) === null || _d === void 0 ? void 0 : _d.call(_c, value)) !== null && _e !== void 0 ? _e : false;
|
|
58
|
+
}
|
|
59
|
+
getLive(version, prop, node, parents) {
|
|
60
|
+
let value = this.properties.get(version, prop);
|
|
61
|
+
if (value)
|
|
62
|
+
return value;
|
|
63
|
+
return this.checkContextScopes(version, prop, node, parents);
|
|
64
|
+
}
|
|
65
|
+
getData(version, prop, node, parents) {
|
|
66
|
+
let value = this.dataProperties.get(version, prop);
|
|
67
|
+
if (value)
|
|
68
|
+
return value;
|
|
69
|
+
return this.checkContextsData(version, prop, node, parents);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export class CustomExpressionTypeAPI {
|
|
73
|
+
constructor(type, name, source) {
|
|
74
|
+
_CustomExpressionTypeAPI_private.set(this, void 0);
|
|
75
|
+
__classPrivateFieldSet(this, _CustomExpressionTypeAPI_private, new CustomType(name, source), "f");
|
|
76
|
+
}
|
|
77
|
+
registerIsTypeCheck(isLiveOfType) {
|
|
78
|
+
__classPrivateFieldGet(this, _CustomExpressionTypeAPI_private, "f").isLiveOfType = isLiveOfType;
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
registerIsDataCheck(isDataOfType) {
|
|
82
|
+
__classPrivateFieldGet(this, _CustomExpressionTypeAPI_private, "f").isDataOfType = isDataOfType;
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
registerIsTypeCastableToThis(typeCastableToThis) {
|
|
86
|
+
__classPrivateFieldGet(this, _CustomExpressionTypeAPI_private, "f").typeCastableToThis = typeCastableToThis;
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
addProperty(version, name, types) {
|
|
90
|
+
InstantPromise.all(types.flatMap((e) => {
|
|
91
|
+
return Progress.AwaitReplicableFor(e);
|
|
92
|
+
}).flat()).then((result) => {
|
|
93
|
+
let types = result.flat();
|
|
94
|
+
let chains = types.map((e) => {
|
|
95
|
+
let chain = ValidExpressionTypes.GetTypeChain(e);
|
|
96
|
+
if (!chain)
|
|
97
|
+
throw new Error(`Error, attempted to register type as expression parameter`
|
|
98
|
+
+ `, but type hasn't been registered with expressions ${e}`);
|
|
99
|
+
return chain;
|
|
100
|
+
});
|
|
101
|
+
let accessor = new ChainProperty(name, "self", chains);
|
|
102
|
+
for (let after of GetAllVersionsAfter(version)) {
|
|
103
|
+
__classPrivateFieldGet(this, _CustomExpressionTypeAPI_private, "f").properties.set(after, name, accessor);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
addMap(version, name, types) {
|
|
109
|
+
InstantPromise.all(types.flatMap((e) => {
|
|
110
|
+
return Progress.AwaitReplicableFor(e);
|
|
111
|
+
}).flat()).then((result) => {
|
|
112
|
+
let types = result.flat();
|
|
113
|
+
let chains = types.map((e) => {
|
|
114
|
+
let chain = ValidExpressionTypes.GetTypeChain(e);
|
|
115
|
+
if (!chain)
|
|
116
|
+
throw new Error(`Error, attempted to register type as expression parameter`
|
|
117
|
+
+ `, but type hasn't been registered with expressions ${e}`);
|
|
118
|
+
return chain;
|
|
119
|
+
});
|
|
120
|
+
let mapType = ValidExpressionTypes.GetMapType(chains);
|
|
121
|
+
let accessor = new ChainProperty(name, "self", [mapType]);
|
|
122
|
+
for (let after of GetAllVersionsAfter(version)) {
|
|
123
|
+
__classPrivateFieldGet(this, _CustomExpressionTypeAPI_private, "f").properties.set(after, name, accessor);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
addDict(version, name, types) {
|
|
129
|
+
InstantPromise.all(types.flatMap((e) => {
|
|
130
|
+
return Progress.AwaitReplicableFor(e);
|
|
131
|
+
}).flat()).then((result) => {
|
|
132
|
+
let types = result.flat();
|
|
133
|
+
let chains = types.map((e) => {
|
|
134
|
+
let chain = ValidExpressionTypes.GetTypeChain(e);
|
|
135
|
+
if (!chain)
|
|
136
|
+
throw new Error(`Error, attempted to register type as expression parameter`
|
|
137
|
+
+ `, but type hasn't been registered with expressions ${e}`);
|
|
138
|
+
return chain;
|
|
139
|
+
});
|
|
140
|
+
let dictType = ValidExpressionTypes.GetDictType(chains);
|
|
141
|
+
let accessor = new ChainProperty(name, "self", [dictType]);
|
|
142
|
+
for (let after of GetAllVersionsAfter(version)) {
|
|
143
|
+
__classPrivateFieldGet(this, _CustomExpressionTypeAPI_private, "f").dataProperties.set(after, name, accessor);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
return this;
|
|
147
|
+
}
|
|
148
|
+
addFunction(version, name, types, parameters) {
|
|
149
|
+
let loadingTypes = types.flatMap((e) => {
|
|
150
|
+
return Progress.AwaitReplicableFor(e);
|
|
151
|
+
}).flat();
|
|
152
|
+
let loadingParams = parameters.map((e) => {
|
|
153
|
+
return e.map((g) => Progress.AwaitReplicableFor(g)).flat();
|
|
154
|
+
});
|
|
155
|
+
InstantPromise.all([...loadingTypes, ...(loadingParams.flat())]).then(() => {
|
|
156
|
+
types = loadingTypes.map((e) => e.result).flat();
|
|
157
|
+
parameters = loadingParams.map((e) => e.map((g) => g.result).flat());
|
|
158
|
+
types = types.map((e) => {
|
|
159
|
+
let chain = ValidExpressionTypes.GetTypeChain(e);
|
|
160
|
+
if (!chain) {
|
|
161
|
+
throw new Error(`Error, attempted to register type as expression parameter`
|
|
162
|
+
+ `, but type hasn't been registered with expressions ${e}`);
|
|
163
|
+
}
|
|
164
|
+
return chain;
|
|
165
|
+
});
|
|
166
|
+
parameters = parameters.map((slot) => slot.map((e) => {
|
|
167
|
+
let chain = ValidExpressionTypes.GetTypeChain(e);
|
|
168
|
+
if (!chain)
|
|
169
|
+
throw new Error(`Error, attempted to register type as expression parameter`
|
|
170
|
+
+ `, but type hasn't been registered with expressions ${e}`);
|
|
171
|
+
return chain;
|
|
172
|
+
}));
|
|
173
|
+
let accessor = new ChainFunction(name, "self", types, parameters);
|
|
174
|
+
for (let after of GetAllVersionsAfter(version)) {
|
|
175
|
+
__classPrivateFieldGet(this, _CustomExpressionTypeAPI_private, "f").properties.set(after, name, accessor);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
return this;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
_CustomExpressionTypeAPI_private = new WeakMap();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ChainType } from "./ChainTypes.js";
|
|
2
|
+
import { ExpressionGrammar } from "../Compiler/ExpressionGrammar.js";
|
|
3
|
+
import { ChainAccessor } from "./Accessors.js";
|
|
4
|
+
import { ErrorStack } from "../../Constants/Errors.js";
|
|
5
|
+
import { Versions } from "../../Constants/Versions.js";
|
|
6
|
+
export declare class PrimitiveType extends ChainType {
|
|
7
|
+
type: any;
|
|
8
|
+
constructor(name: string, type: any);
|
|
9
|
+
getOwnOutputStyle(): ReturnType<ChainType["getOwnOutputStyle"]>;
|
|
10
|
+
getOwnOutputTypes(): any[];
|
|
11
|
+
isAssignableCompile(version: Versions, type: any, style: ReturnType<ChainType["getOwnOutputStyle"]>): boolean;
|
|
12
|
+
isAssignableData(version: Versions, value: any, stack: ErrorStack): boolean;
|
|
13
|
+
isAssignableLive(version: Versions, value: any): boolean;
|
|
14
|
+
isCastableCompile(version: Versions, type: any): boolean;
|
|
15
|
+
isCastableData(version: Versions, value: any, stack: ErrorStack): boolean;
|
|
16
|
+
isCastableLive(version: Versions, value: any): boolean;
|
|
17
|
+
getData(version: Versions, prop: string, node: ExpressionGrammar.Node, parents?: ChainType[]): ChainAccessor;
|
|
18
|
+
getLive(version: Versions, prop: string, node: ExpressionGrammar.Node, parents?: ChainType[]): ChainAccessor;
|
|
19
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ChainType } from "./ChainTypes.js";
|
|
2
|
+
import { ValidExpressionTypes } from "./Registry.js";
|
|
3
|
+
import { describeObject, ValueIsPrimitiveType } from "../../Constants/SerialisationTypes.js";
|
|
4
|
+
export class PrimitiveType extends ChainType {
|
|
5
|
+
constructor(name, type) {
|
|
6
|
+
super(name);
|
|
7
|
+
this.type = type;
|
|
8
|
+
ValidExpressionTypes.SetTypeChain(type, this);
|
|
9
|
+
ValidExpressionTypes.AddAliasForType(this.debugName, type);
|
|
10
|
+
ValidExpressionTypes.AddAliasForType(describeObject(type), type);
|
|
11
|
+
}
|
|
12
|
+
getOwnOutputStyle() {
|
|
13
|
+
return "Single";
|
|
14
|
+
}
|
|
15
|
+
getOwnOutputTypes() {
|
|
16
|
+
return [this.type];
|
|
17
|
+
}
|
|
18
|
+
isAssignableCompile(version, type, style) {
|
|
19
|
+
return type == this.type && style == "Single";
|
|
20
|
+
}
|
|
21
|
+
isAssignableData(version, value, stack) {
|
|
22
|
+
return ValueIsPrimitiveType(this.type, value);
|
|
23
|
+
}
|
|
24
|
+
isAssignableLive(version, value) {
|
|
25
|
+
return ValueIsPrimitiveType(this.type, value);
|
|
26
|
+
}
|
|
27
|
+
isCastableCompile(version, type) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
isCastableData(version, value, stack) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
isCastableLive(version, value) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
getData(version, prop, node, parents) {
|
|
37
|
+
return this.checkContextsData(version, prop, node, parents);
|
|
38
|
+
}
|
|
39
|
+
getLive(version, prop, node, parents) {
|
|
40
|
+
return this.checkContextScopes(version, prop, node, parents);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
new PrimitiveType("String", String);
|
|
44
|
+
new PrimitiveType("Boolean", Boolean);
|
|
45
|
+
new PrimitiveType("Number", Number);
|
|
46
|
+
new PrimitiveType("null", null);
|
|
47
|
+
new PrimitiveType("undefined", undefined);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ChainType } from "./ChainTypes.js";
|
|
2
|
+
export declare namespace ValidExpressionTypes {
|
|
3
|
+
function GetTypeChain(name: any): ChainType | undefined;
|
|
4
|
+
function SetTypeChain(name: any, rule: ChainType): void;
|
|
5
|
+
function ToRawTypes(type: any[]): any[];
|
|
6
|
+
function AddAliasForType(newAlias: any, existingType: any): void;
|
|
7
|
+
function GetDictType(types: ChainType[]): ChainType;
|
|
8
|
+
function GetMapType(types: ChainType[]): ChainType;
|
|
9
|
+
function GetArrayType(types: ChainType[]): ChainType;
|
|
10
|
+
}
|
|
11
|
+
export declare namespace ExpressionScopes {
|
|
12
|
+
type ScopeValues = {
|
|
13
|
+
[variable: string]: any;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* This function is only for testing!
|
|
17
|
+
*/
|
|
18
|
+
export function ResetScopes(): void;
|
|
19
|
+
export function GetScopeChain(type: any): [ChainType, ChainType | undefined, {
|
|
20
|
+
local: ScopeValues;
|
|
21
|
+
global: ScopeValues;
|
|
22
|
+
}];
|
|
23
|
+
export function addLocalVariable(scope: any, variableName: string, types: any[], behaviour?: "Map" | "Dict" | "Function", params?: any[][]): void;
|
|
24
|
+
export function setLocalScope(scope: any, values: ScopeValues): void;
|
|
25
|
+
export function addGlobalVariable(globalName: string, types: any[], value: any, behaviour?: "Map" | "Dict" | "Function", params?: any[][]): void;
|
|
26
|
+
export {};
|
|
27
|
+
}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { describeObject } from "../../Constants/SerialisationTypes.js";
|
|
2
|
+
import { ChainFunction, ChainProperty } from "./Accessors.js";
|
|
3
|
+
import { ArrayType, DictType, MapType } from "./ChainCollections.js";
|
|
4
|
+
import { ArrayMap } from "@bikky/smart-collections";
|
|
5
|
+
import { ChainType } from "./ChainTypes.js";
|
|
6
|
+
import { ScopeType } from "./Scope.js";
|
|
7
|
+
import { ReplicableRegistry } from "../../Constants/ReplicableRegistry.js";
|
|
8
|
+
const TypeRules = new Map();
|
|
9
|
+
const AliasMap = new ArrayMap();
|
|
10
|
+
const LiveLocalMaps = new Map();
|
|
11
|
+
const DataLocalMaps = new Map();
|
|
12
|
+
const LocalScopeRules = new Map();
|
|
13
|
+
let liveGlobalMap = {};
|
|
14
|
+
let dataGlobalMap = {};
|
|
15
|
+
let globalScopeRules;
|
|
16
|
+
export var ValidExpressionTypes;
|
|
17
|
+
(function (ValidExpressionTypes) {
|
|
18
|
+
function GetTypeChain(name) {
|
|
19
|
+
return TypeRules.get(name);
|
|
20
|
+
}
|
|
21
|
+
ValidExpressionTypes.GetTypeChain = GetTypeChain;
|
|
22
|
+
OnBikDelayCompleted(function MapProgressClasses(old, upd) {
|
|
23
|
+
let val = TypeRules.get(old);
|
|
24
|
+
let val2 = TypeRules.get(upd);
|
|
25
|
+
//If it's registered with the old class, make the new class an alias.
|
|
26
|
+
if (val) {
|
|
27
|
+
TypeRules.set(upd, val);
|
|
28
|
+
AliasMap.push(val, upd);
|
|
29
|
+
}
|
|
30
|
+
//If it's registered with the new class, make the old class an alias.
|
|
31
|
+
else if (val2) {
|
|
32
|
+
TypeRules.set(old, val2);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
function SetTypeChain(name, rule) {
|
|
36
|
+
TypeRules.set(name, rule);
|
|
37
|
+
AliasMap.push(rule, name);
|
|
38
|
+
}
|
|
39
|
+
ValidExpressionTypes.SetTypeChain = SetTypeChain;
|
|
40
|
+
function ToRawTypes(type) {
|
|
41
|
+
return type.flatMap(t => {
|
|
42
|
+
if (t instanceof ChainType) {
|
|
43
|
+
return t.getOwnOutputTypes();
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
let type = ValidExpressionTypes.GetTypeChain(t);
|
|
47
|
+
return type ? type.getOwnOutputTypes() : [t];
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
ValidExpressionTypes.ToRawTypes = ToRawTypes;
|
|
52
|
+
ChainType.ToRawTypes = ToRawTypes;
|
|
53
|
+
function AddAliasForType(newAlias, existingType) {
|
|
54
|
+
let rule = TypeRules.get(existingType);
|
|
55
|
+
if (!rule) {
|
|
56
|
+
throw new Error(`Error, attempted to alias ${existingType} to ${newAlias} but ${existingType} doesn't exist in the parser's lexicon.`);
|
|
57
|
+
}
|
|
58
|
+
TypeRules.set(newAlias, rule);
|
|
59
|
+
AliasMap.push(rule, newAlias);
|
|
60
|
+
if (LiveLocalMaps.has(existingType)) {
|
|
61
|
+
LiveLocalMaps.set(newAlias, LiveLocalMaps.get(existingType));
|
|
62
|
+
}
|
|
63
|
+
if (DataLocalMaps.has(existingType)) {
|
|
64
|
+
DataLocalMaps.set(newAlias, DataLocalMaps.get(existingType));
|
|
65
|
+
}
|
|
66
|
+
if (LocalScopeRules.has(existingType)) {
|
|
67
|
+
LocalScopeRules.set(newAlias, LocalScopeRules.get(existingType));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
ValidExpressionTypes.AddAliasForType = AddAliasForType;
|
|
71
|
+
function GetDictType(types) {
|
|
72
|
+
let name = DictType.generateName(types);
|
|
73
|
+
let dict = ValidExpressionTypes.GetTypeChain(name);
|
|
74
|
+
if (!dict) {
|
|
75
|
+
dict = new DictType(name, types);
|
|
76
|
+
ValidExpressionTypes.SetTypeChain(name, dict);
|
|
77
|
+
}
|
|
78
|
+
return dict;
|
|
79
|
+
}
|
|
80
|
+
ValidExpressionTypes.GetDictType = GetDictType;
|
|
81
|
+
function GetMapType(types) {
|
|
82
|
+
let name = MapType.generateName(types);
|
|
83
|
+
let map = ValidExpressionTypes.GetTypeChain(name);
|
|
84
|
+
if (!map) {
|
|
85
|
+
map = new MapType(name, types);
|
|
86
|
+
ValidExpressionTypes.SetTypeChain(name, map);
|
|
87
|
+
}
|
|
88
|
+
return map;
|
|
89
|
+
}
|
|
90
|
+
ValidExpressionTypes.GetMapType = GetMapType;
|
|
91
|
+
function GetArrayType(types) {
|
|
92
|
+
let name = ArrayType.generateName(types);
|
|
93
|
+
let array = ValidExpressionTypes.GetTypeChain(name);
|
|
94
|
+
if (!array) {
|
|
95
|
+
array = new ArrayType(name, types);
|
|
96
|
+
ValidExpressionTypes.SetTypeChain(name, array);
|
|
97
|
+
}
|
|
98
|
+
return array;
|
|
99
|
+
}
|
|
100
|
+
ValidExpressionTypes.GetArrayType = GetArrayType;
|
|
101
|
+
})(ValidExpressionTypes || (ValidExpressionTypes = {}));
|
|
102
|
+
export var ExpressionScopes;
|
|
103
|
+
(function (ExpressionScopes) {
|
|
104
|
+
var GetTypeChain = ValidExpressionTypes.GetTypeChain;
|
|
105
|
+
const CurrentLocalScopeValues = new Map();
|
|
106
|
+
let globalScopeValues = {};
|
|
107
|
+
/**
|
|
108
|
+
* This function is only for testing!
|
|
109
|
+
*/
|
|
110
|
+
function ResetScopes() {
|
|
111
|
+
if (typeof TestingMode === "boolean" && TestingMode) {
|
|
112
|
+
CurrentLocalScopeValues.clear();
|
|
113
|
+
globalScopeValues = {};
|
|
114
|
+
liveGlobalMap = {};
|
|
115
|
+
dataGlobalMap = {};
|
|
116
|
+
LiveLocalMaps.clear();
|
|
117
|
+
DataLocalMaps.clear();
|
|
118
|
+
LocalScopeRules.clear();
|
|
119
|
+
globalScopeRules = new ScopeType("Global", liveGlobalMap, dataGlobalMap);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
throw new Error("Error, attempted to reset scopes in a non-testing environment.");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
ExpressionScopes.ResetScopes = ResetScopes;
|
|
126
|
+
function GetScopeChain(type) {
|
|
127
|
+
if (!globalScopeRules) {
|
|
128
|
+
globalScopeRules = new ScopeType("Global", liveGlobalMap, dataGlobalMap);
|
|
129
|
+
}
|
|
130
|
+
let scopeObj = {};
|
|
131
|
+
let name = type;
|
|
132
|
+
if (typeof name !== "string") {
|
|
133
|
+
name = ReplicableRegistry.GetDataName(name);
|
|
134
|
+
}
|
|
135
|
+
Object.defineProperties(scopeObj, {
|
|
136
|
+
local: {
|
|
137
|
+
value: Object.assign({}, CurrentLocalScopeValues.get(name)),
|
|
138
|
+
writable: false,
|
|
139
|
+
configurable: true,
|
|
140
|
+
enumerable: true
|
|
141
|
+
},
|
|
142
|
+
global: {
|
|
143
|
+
value: Object.assign({}, globalScopeValues),
|
|
144
|
+
writable: false,
|
|
145
|
+
configurable: false,
|
|
146
|
+
enumerable: true
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return [globalScopeRules, LocalScopeRules.get(name), scopeObj];
|
|
150
|
+
}
|
|
151
|
+
ExpressionScopes.GetScopeChain = GetScopeChain;
|
|
152
|
+
function addLocalVariable(scope, variableName, types, behaviour, params) {
|
|
153
|
+
var _a;
|
|
154
|
+
let liveLocalScope = LiveLocalMaps.get(scope);
|
|
155
|
+
let rule = TypeRules.get(scope);
|
|
156
|
+
let aliases = [scope];
|
|
157
|
+
if (rule) {
|
|
158
|
+
aliases = (_a = AliasMap.get(rule)) !== null && _a !== void 0 ? _a : aliases;
|
|
159
|
+
}
|
|
160
|
+
if (!liveLocalScope) {
|
|
161
|
+
liveLocalScope = {};
|
|
162
|
+
for (let alias of aliases) {
|
|
163
|
+
LiveLocalMaps.set(alias, liveLocalScope);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
let dataLocalScope = DataLocalMaps.get(scope);
|
|
167
|
+
if (!dataLocalScope) {
|
|
168
|
+
dataLocalScope = {};
|
|
169
|
+
for (let alias of aliases) {
|
|
170
|
+
DataLocalMaps.set(alias, dataLocalScope);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
let chain = LocalScopeRules.get(scope);
|
|
174
|
+
if (!chain) {
|
|
175
|
+
chain = aliases.map((e) => LocalScopeRules.get(e)).filter((e) => e)[0];
|
|
176
|
+
if (!chain) {
|
|
177
|
+
chain = new ScopeType(describeObject(scope) + "_scope", liveLocalScope, dataLocalScope);
|
|
178
|
+
}
|
|
179
|
+
aliases.forEach((e) => LocalScopeRules.set(e, chain));
|
|
180
|
+
}
|
|
181
|
+
switch (behaviour) {
|
|
182
|
+
case "Map": {
|
|
183
|
+
types = [
|
|
184
|
+
ValidExpressionTypes.GetMapType(types)
|
|
185
|
+
];
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
case "Dict": {
|
|
189
|
+
types = [
|
|
190
|
+
ValidExpressionTypes.GetDictType(types)
|
|
191
|
+
];
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (behaviour === "Function") {
|
|
196
|
+
params = params !== null && params !== void 0 ? params : [];
|
|
197
|
+
let paramChains = params.map((e) => e.map((p) => {
|
|
198
|
+
let result = GetTypeChain(p);
|
|
199
|
+
if (!result) {
|
|
200
|
+
throw new Error(`Error, ${p} is not a valid type.`);
|
|
201
|
+
}
|
|
202
|
+
return result;
|
|
203
|
+
}));
|
|
204
|
+
liveLocalScope[variableName] = new ChainFunction(variableName, "local", types, paramChains);
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
liveLocalScope[variableName] = new ChainProperty(variableName, "local", types);
|
|
208
|
+
dataLocalScope[variableName] = new ChainProperty(variableName, "local", types);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
ExpressionScopes.addLocalVariable = addLocalVariable;
|
|
212
|
+
function helpSetLocalScope(scope, values) {
|
|
213
|
+
if (LiveLocalMaps.has(scope)) {
|
|
214
|
+
CurrentLocalScopeValues.set(scope, values);
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
let chain = GetTypeChain(scope);
|
|
218
|
+
//This is a bit hacky...
|
|
219
|
+
if (chain && "repl" in chain) {
|
|
220
|
+
let repl = chain.repl;
|
|
221
|
+
for (let parent of repl.parents) {
|
|
222
|
+
if (helpSetLocalScope(parent.classConstructor, values)) {
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (!chain) {
|
|
228
|
+
let proto = Object.getPrototypeOf(scope);
|
|
229
|
+
while (proto && proto !== Function.prototype) {
|
|
230
|
+
scope = proto;
|
|
231
|
+
if (helpSetLocalScope(scope, values)) {
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
proto = Object.getPrototypeOf(scope);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
function setLocalScope(scope, values) {
|
|
240
|
+
if (!helpSetLocalScope(scope, values)) {
|
|
241
|
+
throw new Error(`Error, attempted to set local scope for ${describeObject(scope)} but it doesn't exist.`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
ExpressionScopes.setLocalScope = setLocalScope;
|
|
245
|
+
function addGlobalVariable(globalName, types, value, behaviour, params) {
|
|
246
|
+
switch (behaviour) {
|
|
247
|
+
case "Map": {
|
|
248
|
+
types = [
|
|
249
|
+
ValidExpressionTypes.GetMapType(types)
|
|
250
|
+
];
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
case "Dict": {
|
|
254
|
+
types = [
|
|
255
|
+
ValidExpressionTypes.GetDictType(types)
|
|
256
|
+
];
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (behaviour === "Function") {
|
|
261
|
+
liveGlobalMap[globalName] = new ChainFunction(globalName, "global", types, params !== null && params !== void 0 ? params : []);
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
liveGlobalMap[globalName] = new ChainProperty(globalName, "global", types);
|
|
265
|
+
dataGlobalMap[globalName] = new ChainProperty(globalName, "global", types);
|
|
266
|
+
}
|
|
267
|
+
globalScopeValues[globalName] = value;
|
|
268
|
+
}
|
|
269
|
+
ExpressionScopes.addGlobalVariable = addGlobalVariable;
|
|
270
|
+
})(ExpressionScopes || (ExpressionScopes = {}));
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ChainType } from "./ChainTypes.js";
|
|
2
|
+
import { PropertyDoesntExist, PropertyRemoved, ReplicableClass } from "../../Tracking/Class.js";
|
|
3
|
+
import { Versions } from "../../Constants/Versions.js";
|
|
4
|
+
import { ErrorStack } from "../../Constants/Errors.js";
|
|
5
|
+
import type { ReplicableRegistry } from "../../Constants/ReplicableRegistry.js";
|
|
6
|
+
import { ExpressionGrammar } from "../Compiler/ExpressionGrammar.js";
|
|
7
|
+
import Node = ExpressionGrammar.Node;
|
|
8
|
+
import { ComplexPropertyType, PropertyConfiguration } from "../../Tracking/Property.js";
|
|
9
|
+
import type { Definitions } from "../../Transformers/Definitions.js";
|
|
10
|
+
export declare namespace __ReplTypeHelperFunctions {
|
|
11
|
+
function SetIsLoadableDataForType(func: typeof Definitions.IsLoadableDataForType): void;
|
|
12
|
+
function SetDataNameTypeLookupFunction(lookupFunc: typeof ReplicableRegistry.GetTypeForDataName): void;
|
|
13
|
+
function SetPrimOrClassLookupFunction(lookupFunc: typeof ReplicableRegistry.__GetReplOrPrimFor): void;
|
|
14
|
+
}
|
|
15
|
+
export declare class ReplType extends ChainType {
|
|
16
|
+
repl: ReplicableClass;
|
|
17
|
+
properties: any;
|
|
18
|
+
dataProperties: any;
|
|
19
|
+
constructor(repl: ReplicableClass);
|
|
20
|
+
getOwnOutputStyle(): ReturnType<ChainType["getOwnOutputStyle"]>;
|
|
21
|
+
getOwnOutputTypes(): any[];
|
|
22
|
+
isAssignableCompile(version: Versions, type: any): boolean;
|
|
23
|
+
isAssignableLive(version: Versions, value: any): boolean;
|
|
24
|
+
isAssignableData(version: Versions, value: any, stack: ErrorStack): boolean;
|
|
25
|
+
isCastableCompile(version: Versions, type: any): boolean;
|
|
26
|
+
isCastableLive(version: Versions, value: any): boolean;
|
|
27
|
+
isCastableData(version: Versions, value: any, stack: ErrorStack): boolean;
|
|
28
|
+
getLive(version: Versions, prop: string, node: Node, contexts?: ChainType[]): any;
|
|
29
|
+
getData(version: Versions, prop: string, node: Node, contexts?: ChainType[]): any;
|
|
30
|
+
}
|
|
31
|
+
export declare class ReplAPI {
|
|
32
|
+
#private;
|
|
33
|
+
replicable: ReplicableClass;
|
|
34
|
+
constructor(type: "Repl", opts: ReplicableClass);
|
|
35
|
+
addProperty(version: Versions | string, def: PropertyConfiguration | PropertyRemoved | PropertyDoesntExist): Promise<void>;
|
|
36
|
+
private addPropertyHelper;
|
|
37
|
+
addFunction(version: Versions, opts: {
|
|
38
|
+
name: string;
|
|
39
|
+
exprName: string;
|
|
40
|
+
}, types: ComplexPropertyType[], parameters: ComplexPropertyType[][]): void;
|
|
41
|
+
}
|