@flowgram.ai/variable-core 0.1.12 → 0.1.13
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/dist/esm/index.js +31 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -343,6 +343,17 @@ interface UnionJSON {
|
|
|
343
343
|
types?: ASTNodeJSONOrKind[];
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
+
interface CustomTypeJSON {
|
|
347
|
+
typeName: string;
|
|
348
|
+
}
|
|
349
|
+
declare class CustomType extends BaseType<CustomTypeJSON> {
|
|
350
|
+
static kind: string;
|
|
351
|
+
protected _typeName: string;
|
|
352
|
+
get typeName(): string;
|
|
353
|
+
fromJSON(json: CustomTypeJSON): void;
|
|
354
|
+
isTypeEqual(targetTypeJSONOrKind?: ASTNodeJSONOrKind): boolean;
|
|
355
|
+
}
|
|
356
|
+
|
|
346
357
|
type ExpressionRefs = (BaseVariableField | undefined)[];
|
|
347
358
|
declare abstract class BaseExpression<JSON extends ASTNodeJSON = any, InjectOpts = any> extends ASTNode<JSON, InjectOpts> {
|
|
348
359
|
flags: ASTNodeFlags;
|
|
@@ -676,6 +687,7 @@ declare enum ASTKind {
|
|
|
676
687
|
Map = "Map",
|
|
677
688
|
Union = "Union",
|
|
678
689
|
Any = "Any",
|
|
690
|
+
CustomType = "CustomType",
|
|
679
691
|
/**
|
|
680
692
|
* 声明
|
|
681
693
|
*/
|
|
@@ -835,6 +847,10 @@ declare namespace ASTFactory {
|
|
|
835
847
|
types?: ASTNodeJSONOrKind[] | undefined;
|
|
836
848
|
kind: ASTKind;
|
|
837
849
|
};
|
|
850
|
+
const createCustomType: (json: CustomTypeJSON) => {
|
|
851
|
+
typeName: string;
|
|
852
|
+
kind: ASTKind;
|
|
853
|
+
};
|
|
838
854
|
/**
|
|
839
855
|
* 声明相关
|
|
840
856
|
*/
|
|
@@ -869,6 +885,15 @@ declare namespace ASTFactory {
|
|
|
869
885
|
keyPath: string[];
|
|
870
886
|
kind: ASTKind;
|
|
871
887
|
};
|
|
888
|
+
/**
|
|
889
|
+
* 通过 AST Class 创建
|
|
890
|
+
*/
|
|
891
|
+
const create: <JSON_1 extends ASTNodeJSON>(targetType: {
|
|
892
|
+
new (...args: any[]): ASTNode<JSON_1, any>;
|
|
893
|
+
kind: string;
|
|
894
|
+
}, json: JSON_1) => {
|
|
895
|
+
kind: string;
|
|
896
|
+
} & JSON_1;
|
|
872
897
|
}
|
|
873
898
|
|
|
874
899
|
declare const injectToAST: (serviceIdentifier: interfaces.ServiceIdentifier) => (target: any, propertyKey: string) => any;
|
|
@@ -998,4 +1023,4 @@ declare class VariableFieldKeyRenameService {
|
|
|
998
1023
|
dispose(): void;
|
|
999
1024
|
}
|
|
1000
1025
|
|
|
1001
|
-
export { ASTFactory, ASTKind, ASTNode, ASTNodeFlags, type ASTNodeJSON, type ASTNodeRegistry, ASTRegisters, ArrayType, BaseExpression, BaseType, BaseVariableField, BooleanType, type CreateASTParams, DataNode, EnumerateExpression, type EnumerateExpressionJSON, ExpressionList, type ExpressionListJSON, type GetKindJSON, type GetKindJSONOrKind, type GlobalEventActionType, IntegerType, KeyPathExpression, type KeyPathExpressionJSON$1 as KeyPathExpressionJSON, KeyPathExpressionV2, ListNode, type ListNodeJSON, MapNode, type MapNodeJSON, MapType, NumberType, type ObjectJSON, type ObjectPropertiesChangeAction, ObjectType, Property, type PropertyJSON, Scope, ScopeChain, ScopeOutputData, ScopeProvider, StringType, type UnionJSON, VariableContainerModule, VariableDeclaration, type VariableDeclarationJSON, VariableDeclarationList, type VariableDeclarationListChangeAction, type VariableDeclarationListJSON, VariableEngine, VariableEngineProvider, VariableFieldKeyRenameService, VariableTable, injectToAST, isMatchAST, postConstructAST, useAvailableVariables, useCurrentScope, useScopeAvailable, useScopeContext };
|
|
1026
|
+
export { ASTFactory, ASTKind, ASTNode, ASTNodeFlags, type ASTNodeJSON, type ASTNodeRegistry, ASTRegisters, ArrayType, BaseExpression, BaseType, BaseVariableField, BooleanType, type CreateASTParams, CustomType, type CustomTypeJSON, DataNode, EnumerateExpression, type EnumerateExpressionJSON, ExpressionList, type ExpressionListJSON, type GetKindJSON, type GetKindJSONOrKind, type GlobalEventActionType, IntegerType, KeyPathExpression, type KeyPathExpressionJSON$1 as KeyPathExpressionJSON, KeyPathExpressionV2, ListNode, type ListNodeJSON, MapNode, type MapNodeJSON, MapType, NumberType, type ObjectJSON, type ObjectPropertiesChangeAction, ObjectType, Property, type PropertyJSON, Scope, ScopeChain, ScopeOutputData, ScopeProvider, StringType, type UnionJSON, VariableContainerModule, VariableDeclaration, type VariableDeclarationJSON, VariableDeclarationList, type VariableDeclarationListChangeAction, type VariableDeclarationListJSON, VariableEngine, VariableEngineProvider, VariableFieldKeyRenameService, VariableTable, injectToAST, isMatchAST, postConstructAST, useAvailableVariables, useCurrentScope, useScopeAvailable, useScopeContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -343,6 +343,17 @@ interface UnionJSON {
|
|
|
343
343
|
types?: ASTNodeJSONOrKind[];
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
+
interface CustomTypeJSON {
|
|
347
|
+
typeName: string;
|
|
348
|
+
}
|
|
349
|
+
declare class CustomType extends BaseType<CustomTypeJSON> {
|
|
350
|
+
static kind: string;
|
|
351
|
+
protected _typeName: string;
|
|
352
|
+
get typeName(): string;
|
|
353
|
+
fromJSON(json: CustomTypeJSON): void;
|
|
354
|
+
isTypeEqual(targetTypeJSONOrKind?: ASTNodeJSONOrKind): boolean;
|
|
355
|
+
}
|
|
356
|
+
|
|
346
357
|
type ExpressionRefs = (BaseVariableField | undefined)[];
|
|
347
358
|
declare abstract class BaseExpression<JSON extends ASTNodeJSON = any, InjectOpts = any> extends ASTNode<JSON, InjectOpts> {
|
|
348
359
|
flags: ASTNodeFlags;
|
|
@@ -676,6 +687,7 @@ declare enum ASTKind {
|
|
|
676
687
|
Map = "Map",
|
|
677
688
|
Union = "Union",
|
|
678
689
|
Any = "Any",
|
|
690
|
+
CustomType = "CustomType",
|
|
679
691
|
/**
|
|
680
692
|
* 声明
|
|
681
693
|
*/
|
|
@@ -835,6 +847,10 @@ declare namespace ASTFactory {
|
|
|
835
847
|
types?: ASTNodeJSONOrKind[] | undefined;
|
|
836
848
|
kind: ASTKind;
|
|
837
849
|
};
|
|
850
|
+
const createCustomType: (json: CustomTypeJSON) => {
|
|
851
|
+
typeName: string;
|
|
852
|
+
kind: ASTKind;
|
|
853
|
+
};
|
|
838
854
|
/**
|
|
839
855
|
* 声明相关
|
|
840
856
|
*/
|
|
@@ -869,6 +885,15 @@ declare namespace ASTFactory {
|
|
|
869
885
|
keyPath: string[];
|
|
870
886
|
kind: ASTKind;
|
|
871
887
|
};
|
|
888
|
+
/**
|
|
889
|
+
* 通过 AST Class 创建
|
|
890
|
+
*/
|
|
891
|
+
const create: <JSON_1 extends ASTNodeJSON>(targetType: {
|
|
892
|
+
new (...args: any[]): ASTNode<JSON_1, any>;
|
|
893
|
+
kind: string;
|
|
894
|
+
}, json: JSON_1) => {
|
|
895
|
+
kind: string;
|
|
896
|
+
} & JSON_1;
|
|
872
897
|
}
|
|
873
898
|
|
|
874
899
|
declare const injectToAST: (serviceIdentifier: interfaces.ServiceIdentifier) => (target: any, propertyKey: string) => any;
|
|
@@ -998,4 +1023,4 @@ declare class VariableFieldKeyRenameService {
|
|
|
998
1023
|
dispose(): void;
|
|
999
1024
|
}
|
|
1000
1025
|
|
|
1001
|
-
export { ASTFactory, ASTKind, ASTNode, ASTNodeFlags, type ASTNodeJSON, type ASTNodeRegistry, ASTRegisters, ArrayType, BaseExpression, BaseType, BaseVariableField, BooleanType, type CreateASTParams, DataNode, EnumerateExpression, type EnumerateExpressionJSON, ExpressionList, type ExpressionListJSON, type GetKindJSON, type GetKindJSONOrKind, type GlobalEventActionType, IntegerType, KeyPathExpression, type KeyPathExpressionJSON$1 as KeyPathExpressionJSON, KeyPathExpressionV2, ListNode, type ListNodeJSON, MapNode, type MapNodeJSON, MapType, NumberType, type ObjectJSON, type ObjectPropertiesChangeAction, ObjectType, Property, type PropertyJSON, Scope, ScopeChain, ScopeOutputData, ScopeProvider, StringType, type UnionJSON, VariableContainerModule, VariableDeclaration, type VariableDeclarationJSON, VariableDeclarationList, type VariableDeclarationListChangeAction, type VariableDeclarationListJSON, VariableEngine, VariableEngineProvider, VariableFieldKeyRenameService, VariableTable, injectToAST, isMatchAST, postConstructAST, useAvailableVariables, useCurrentScope, useScopeAvailable, useScopeContext };
|
|
1026
|
+
export { ASTFactory, ASTKind, ASTNode, ASTNodeFlags, type ASTNodeJSON, type ASTNodeRegistry, ASTRegisters, ArrayType, BaseExpression, BaseType, BaseVariableField, BooleanType, type CreateASTParams, CustomType, type CustomTypeJSON, DataNode, EnumerateExpression, type EnumerateExpressionJSON, ExpressionList, type ExpressionListJSON, type GetKindJSON, type GetKindJSONOrKind, type GlobalEventActionType, IntegerType, KeyPathExpression, type KeyPathExpressionJSON$1 as KeyPathExpressionJSON, KeyPathExpressionV2, ListNode, type ListNodeJSON, MapNode, type MapNodeJSON, MapType, NumberType, type ObjectJSON, type ObjectPropertiesChangeAction, ObjectType, Property, type PropertyJSON, Scope, ScopeChain, ScopeOutputData, ScopeProvider, StringType, type UnionJSON, VariableContainerModule, VariableDeclaration, type VariableDeclarationJSON, VariableDeclarationList, type VariableDeclarationListChangeAction, type VariableDeclarationListJSON, VariableEngine, VariableEngineProvider, VariableFieldKeyRenameService, VariableTable, injectToAST, isMatchAST, postConstructAST, useAvailableVariables, useCurrentScope, useScopeAvailable, useScopeContext };
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,7 @@ __export(src_exports, {
|
|
|
39
39
|
BaseType: () => BaseType,
|
|
40
40
|
BaseVariableField: () => BaseVariableField,
|
|
41
41
|
BooleanType: () => BooleanType,
|
|
42
|
+
CustomType: () => CustomType,
|
|
42
43
|
DataNode: () => DataNode,
|
|
43
44
|
EnumerateExpression: () => EnumerateExpression,
|
|
44
45
|
ExpressionList: () => ExpressionList,
|
|
@@ -166,6 +167,7 @@ var ASTKind = /* @__PURE__ */ ((ASTKind2) => {
|
|
|
166
167
|
ASTKind2["Map"] = "Map";
|
|
167
168
|
ASTKind2["Union"] = "Union";
|
|
168
169
|
ASTKind2["Any"] = "Any";
|
|
170
|
+
ASTKind2["CustomType"] = "CustomType";
|
|
169
171
|
ASTKind2["Property"] = "Property";
|
|
170
172
|
ASTKind2["VariableDeclaration"] = "VariableDeclaration";
|
|
171
173
|
ASTKind2["VariableDeclarationList"] = "VariableDeclarationList";
|
|
@@ -731,6 +733,29 @@ var ObjectType = class extends BaseType {
|
|
|
731
733
|
};
|
|
732
734
|
ObjectType.kind = "Object" /* Object */;
|
|
733
735
|
|
|
736
|
+
// src/ast/type/custom-type.ts
|
|
737
|
+
var CustomType = class extends BaseType {
|
|
738
|
+
get typeName() {
|
|
739
|
+
return this._typeName;
|
|
740
|
+
}
|
|
741
|
+
fromJSON(json) {
|
|
742
|
+
if (this._typeName !== json.typeName) {
|
|
743
|
+
this._typeName = json.typeName;
|
|
744
|
+
this.fireChange();
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
isTypeEqual(targetTypeJSONOrKind) {
|
|
748
|
+
const targetTypeJSON = parseTypeJsonOrKind(targetTypeJSONOrKind);
|
|
749
|
+
if (targetTypeJSON?.kind === "Union" /* Union */) {
|
|
750
|
+
return (targetTypeJSON?.types || [])?.some(
|
|
751
|
+
(_subType) => this.isTypeEqual(_subType)
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
return targetTypeJSON?.kind === this.kind && targetTypeJSON?.typeName === this.typeName;
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
CustomType.kind = "CustomType" /* CustomType */;
|
|
758
|
+
|
|
734
759
|
// src/ast/expression/base-expression.ts
|
|
735
760
|
var import_rxjs2 = require("rxjs");
|
|
736
761
|
var import_fast_equals2 = require("fast-equals");
|
|
@@ -1318,6 +1343,7 @@ var ASTRegisters = class {
|
|
|
1318
1343
|
this.registerAST(ObjectType);
|
|
1319
1344
|
this.registerAST(ArrayType);
|
|
1320
1345
|
this.registerAST(MapType);
|
|
1346
|
+
this.registerAST(CustomType);
|
|
1321
1347
|
this.registerAST(Property);
|
|
1322
1348
|
this.registerAST(VariableDeclaration);
|
|
1323
1349
|
this.registerAST(VariableDeclarationList);
|
|
@@ -1402,6 +1428,10 @@ var ASTFactory;
|
|
|
1402
1428
|
kind: "Union" /* Union */,
|
|
1403
1429
|
...json
|
|
1404
1430
|
});
|
|
1431
|
+
ASTFactory2.createCustomType = (json) => ({
|
|
1432
|
+
kind: "CustomType" /* CustomType */,
|
|
1433
|
+
...json
|
|
1434
|
+
});
|
|
1405
1435
|
ASTFactory2.createVariableDeclaration = (json) => ({
|
|
1406
1436
|
kind: "VariableDeclaration" /* VariableDeclaration */,
|
|
1407
1437
|
...json
|
|
@@ -1422,6 +1452,7 @@ var ASTFactory;
|
|
|
1422
1452
|
kind: "KeyPathExpression" /* KeyPathExpression */,
|
|
1423
1453
|
...json
|
|
1424
1454
|
});
|
|
1455
|
+
ASTFactory2.create = (targetType, json) => ({ kind: targetType.kind, ...json });
|
|
1425
1456
|
})(ASTFactory || (ASTFactory = {}));
|
|
1426
1457
|
|
|
1427
1458
|
// src/scope/variable-table.ts
|
|
@@ -2037,6 +2068,7 @@ function useAvailableVariables() {
|
|
|
2037
2068
|
BaseType,
|
|
2038
2069
|
BaseVariableField,
|
|
2039
2070
|
BooleanType,
|
|
2071
|
+
CustomType,
|
|
2040
2072
|
DataNode,
|
|
2041
2073
|
EnumerateExpression,
|
|
2042
2074
|
ExpressionList,
|