@rsconcept/domain 1.0.0 → 1.1.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/README.md +3 -3
- package/dist/analyzer-DlSq3Y3r.d.ts +39 -0
- package/dist/arguments-extractor-1acwjQNc.d.ts +38 -0
- package/dist/ast-C8sIpKdL.d.ts +51 -0
- package/dist/ast-annotations-BiMjkKvz.d.ts +16 -0
- package/dist/branded-ZlzIcxzu.d.ts +9 -0
- package/dist/calculator-C9W2jkSx.d.ts +39 -0
- package/dist/cctext/index.d.ts +2 -1
- package/dist/cctext/index.js +2 -42
- package/dist/cctext/language-api.d.ts +10 -12
- package/dist/cctext/language-api.js +157 -227
- package/dist/cctext/language-api.js.map +1 -1
- package/dist/cctext/language.d.ts +24 -22
- package/dist/cctext/language.js +43 -39
- package/dist/cctext/language.js.map +1 -1
- package/dist/error-E1LVq_3w.d.ts +87 -0
- package/dist/graph/graph.d.ts +2 -62
- package/dist/graph/graph.js +339 -382
- package/dist/graph/graph.js.map +1 -1
- package/dist/graph/index.d.ts +2 -1
- package/dist/graph/index.js +2 -384
- package/dist/graph-DR8rL2o3.d.ts +64 -0
- package/dist/hash-Y8I4c6Al.d.ts +8 -0
- package/dist/index-BKZ67WMa.d.ts +1 -0
- package/dist/index-BVVgDSdq.d.ts +1 -0
- package/dist/index-DmtQKWjk.d.ts +1 -0
- package/dist/index-_6s0AX1B.d.ts +1 -0
- package/dist/index.d.ts +27 -28
- package/dist/index.js +23 -5851
- package/dist/lezer-tree-iS7LpLBJ.d.ts +14 -0
- package/dist/library/folder-tree.d.ts +22 -20
- package/dist/library/folder-tree.js +108 -130
- package/dist/library/folder-tree.js.map +1 -1
- package/dist/library/index.d.ts +8 -17
- package/dist/library/index.js +7 -2800
- package/dist/library/library-api.d.ts +3 -1
- package/dist/library/library-api.js +9 -8
- package/dist/library/library-api.js.map +1 -1
- package/dist/library/library.d.ts +2 -56
- package/dist/library/library.js +23 -19
- package/dist/library/library.js.map +1 -1
- package/dist/library/oss-api.d.ts +26 -37
- package/dist/library/oss-api.js +257 -1096
- package/dist/library/oss-api.js.map +1 -1
- package/dist/library/oss-layout-api.d.ts +28 -28
- package/dist/library/oss-layout-api.js +239 -316
- package/dist/library/oss-layout-api.js.map +1 -1
- package/dist/library/oss-layout.d.ts +2 -25
- package/dist/library/oss-layout.js +1 -1
- package/dist/library/oss.d.ts +87 -89
- package/dist/library/oss.js +27 -26
- package/dist/library/oss.js.map +1 -1
- package/dist/library/rsengine.d.ts +100 -106
- package/dist/library/rsengine.js +439 -2599
- package/dist/library/rsengine.js.map +1 -1
- package/dist/library/rsform-api.d.ts +11 -16
- package/dist/library/rsform-api.js +313 -825
- package/dist/library/rsform-api.js.map +1 -1
- package/dist/library/rsform.d.ts +159 -167
- package/dist/library/rsform.js +29 -28
- package/dist/library/rsform.js.map +1 -1
- package/dist/library/rsmodel-api.d.ts +8 -15
- package/dist/library/rsmodel-api.js +172 -813
- package/dist/library/rsmodel-api.js.map +1 -1
- package/dist/library/rsmodel.d.ts +27 -33
- package/dist/library/rsmodel.js +16 -23
- package/dist/library/rsmodel.js.map +1 -1
- package/dist/library/structure-planner.d.ts +20 -26
- package/dist/library/structure-planner.js +106 -474
- package/dist/library/structure-planner.js.map +1 -1
- package/dist/library-CYun28Xz.d.ts +58 -0
- package/dist/oss-layout-3glgAqfn.d.ts +27 -0
- package/dist/parser-Bwd8LxJ1.d.ts +7 -0
- package/dist/parsing/ast.d.ts +2 -49
- package/dist/parsing/ast.js +68 -76
- package/dist/parsing/ast.js.map +1 -1
- package/dist/parsing/index.d.ts +3 -3
- package/dist/parsing/index.js +3 -141
- package/dist/parsing/lezer-tree.d.ts +2 -13
- package/dist/parsing/lezer-tree.js +50 -43
- package/dist/parsing/lezer-tree.js.map +1 -1
- package/dist/rslang/api.d.ts +9 -14
- package/dist/rslang/api.js +114 -827
- package/dist/rslang/api.js.map +1 -1
- package/dist/rslang/ast-annotations.d.ts +2 -18
- package/dist/rslang/ast-annotations.js +34 -45
- package/dist/rslang/ast-annotations.js.map +1 -1
- package/dist/rslang/error.d.ts +2 -85
- package/dist/rslang/error.js +88 -150
- package/dist/rslang/error.js.map +1 -1
- package/dist/rslang/eval/calculator.d.ts +2 -43
- package/dist/rslang/eval/calculator.js +81 -1636
- package/dist/rslang/eval/calculator.js.map +1 -1
- package/dist/rslang/eval/evaluation-cache.d.ts +22 -26
- package/dist/rslang/eval/evaluation-cache.js +168 -287
- package/dist/rslang/eval/evaluation-cache.js.map +1 -1
- package/dist/rslang/eval/evaluator.d.ts +59 -63
- package/dist/rslang/eval/evaluator.js +602 -1509
- package/dist/rslang/eval/evaluator.js.map +1 -1
- package/dist/rslang/eval/value-api.d.ts +2 -48
- package/dist/rslang/eval/value-api.js +2 -490
- package/dist/rslang/eval/value.d.ts +2 -36
- package/dist/rslang/eval/value.js +2 -118
- package/dist/rslang/index.d.ts +14 -17
- package/dist/rslang/index.js +12 -4314
- package/dist/rslang/labels.d.ts +6 -6
- package/dist/rslang/labels.js +139 -305
- package/dist/rslang/labels.js.map +1 -1
- package/dist/rslang/parser/expression-generator.d.ts +5 -5
- package/dist/rslang/parser/expression-generator.js +248 -446
- package/dist/rslang/parser/expression-generator.js.map +1 -1
- package/dist/rslang/parser/normalize.d.ts +4 -8
- package/dist/rslang/parser/normalize.js +286 -481
- package/dist/rslang/parser/normalize.js.map +1 -1
- package/dist/rslang/parser/parser.d.ts +2 -5
- package/dist/rslang/parser/parser.js +30 -21
- package/dist/rslang/parser/parser.js.map +1 -1
- package/dist/rslang/parser/parser.terms.d.ts +43 -41
- package/dist/rslang/parser/parser.terms.js +44 -83
- package/dist/rslang/parser/parser.terms.js.map +1 -1
- package/dist/rslang/parser/syntax-errors.d.ts +5 -8
- package/dist/rslang/parser/syntax-errors.js +113 -382
- package/dist/rslang/parser/syntax-errors.js.map +1 -1
- package/dist/rslang/parser/token.d.ts +2 -79
- package/dist/rslang/parser/token.js +81 -93
- package/dist/rslang/parser/token.js.map +1 -1
- package/dist/rslang/semantic/analyzer.d.ts +2 -39
- package/dist/rslang/semantic/analyzer.js +186 -2600
- package/dist/rslang/semantic/analyzer.js.map +1 -1
- package/dist/rslang/semantic/arguments-extractor.d.ts +2 -42
- package/dist/rslang/semantic/arguments-extractor.js +202 -361
- package/dist/rslang/semantic/arguments-extractor.js.map +1 -1
- package/dist/rslang/semantic/type-auditor.d.ts +64 -68
- package/dist/rslang/semantic/type-auditor.js +594 -1564
- package/dist/rslang/semantic/type-auditor.js.map +1 -1
- package/dist/rslang/semantic/typification-api.d.ts +4 -7
- package/dist/rslang/semantic/typification-api.js +162 -303
- package/dist/rslang/semantic/typification-api.js.map +1 -1
- package/dist/rslang/semantic/typification-parser.d.ts +2 -12
- package/dist/rslang/semantic/typification-parser.js +165 -219
- package/dist/rslang/semantic/typification-parser.js.map +1 -1
- package/dist/rslang/semantic/typification.d.ts +2 -119
- package/dist/rslang/semantic/typification.js +66 -52
- package/dist/rslang/semantic/typification.js.map +1 -1
- package/dist/rslang/semantic/value-auditor.d.ts +32 -38
- package/dist/rslang/semantic/value-auditor.js +206 -518
- package/dist/rslang/semantic/value-auditor.js.map +1 -1
- package/dist/rslang/semantic/value-class.d.ts +2 -10
- package/dist/rslang/semantic/value-class.js +8 -7
- package/dist/rslang/semantic/value-class.js.map +1 -1
- package/dist/rslang/typification-graph.d.ts +2 -33
- package/dist/rslang/typification-graph.js +94 -306
- package/dist/rslang/typification-graph.js.map +1 -1
- package/dist/shared/branded.d.ts +2 -7
- package/dist/shared/branded.js +1 -1
- package/dist/shared/hash.d.ts +2 -6
- package/dist/shared/hash.js +13 -13
- package/dist/shared/hash.js.map +1 -1
- package/dist/shared/index.d.ts +3 -2
- package/dist/shared/index.js +2 -18
- package/dist/token-DeXAmzwr.d.ts +81 -0
- package/dist/typification-Dk-fisgO.d.ts +120 -0
- package/dist/typification-graph-6HcZ-rKH.d.ts +30 -0
- package/dist/typification-parser-BBVx1RxP.d.ts +13 -0
- package/dist/value-B8UtCqaK.js +366 -0
- package/dist/value-B8UtCqaK.js.map +1 -0
- package/dist/value-CTjX6825.d.ts +33 -0
- package/dist/value-api-Bw-SgaYY.d.ts +49 -0
- package/dist/value-class-CNI-lqXJ.d.ts +12 -0
- package/package.json +8 -8
- package/src/library/rsform-api.test.ts +24 -0
- package/src/library/rsform-api.ts +12 -4
- package/dist/cctext/index.js.map +0 -1
- package/dist/graph/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/library/index.js.map +0 -1
- package/dist/library/oss-layout.js.map +0 -1
- package/dist/parsing/index.js.map +0 -1
- package/dist/rslang/eval/value-api.js.map +0 -1
- package/dist/rslang/eval/value.js.map +0 -1
- package/dist/rslang/index.js.map +0 -1
- package/dist/shared/branded.js.map +0 -1
- package/dist/shared/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/library/oss.ts","../../src/library/oss-layout-api.ts"],"sourcesContent":["/**\n * Module: Schema of Synthesis Operations.\n */\n\nimport { type Graph } from '../graph';\n\nimport { type LibraryItem } from './library';\nimport { type NodePosition, type OssLayout } from './oss-layout';\n\n/** Represents OSS node type. */\nexport const NodeType = {\n OPERATION: 1,\n BLOCK: 2\n} as const;\nexport type NodeType = (typeof NodeType)[keyof typeof NodeType];\n\n/** Represents OSS graph node. */\ninterface OssNode extends NodePosition {\n nodeType: NodeType;\n parent: number | null;\n}\n\n/** Represents {@link Operation} type. */\nexport const OperationType = {\n INPUT: 'input',\n SYNTHESIS: 'synthesis',\n REPLICA: 'replica'\n} as const;\nexport type OperationType = (typeof OperationType)[keyof typeof OperationType];\n\n/** Represents {@link Substitution} extended data. */\nexport interface CstSubstituteInfo {\n original: number;\n substitution: number;\n operation: number;\n original_schema: number;\n original_alias: string;\n original_term: string;\n substitution_schema: number;\n substitution_alias: string;\n substitution_term: string;\n}\n\n/** Represents Operation common attributes. */\ninterface OperationBase extends OssNode {\n id: number;\n alias: string;\n title: string;\n description: string;\n operation_type: OperationType;\n result: number | null;\n nodeType: typeof NodeType.OPERATION;\n has_additions: boolean;\n}\n\n/** Represents Input Operation. */\nexport interface OperationInput extends OperationBase {\n operation_type: typeof OperationType.INPUT;\n is_import: boolean;\n}\n\n/** Represents Replica Operation. */\ninterface OperationReplica extends OperationBase {\n operation_type: typeof OperationType.REPLICA;\n target: number;\n}\n\n/** Represents Synthesis Operation. */\nexport interface OperationSynthesis extends OperationBase {\n operation_type: typeof OperationType.SYNTHESIS;\n is_consolidation: boolean; // aka 'diamond synthesis'\n substitutions: CstSubstituteInfo[];\n arguments: number[];\n}\n\n/** Represents Operation. */\nexport type Operation = OperationInput | OperationReplica | OperationSynthesis;\n\n/** Represents Block. */\nexport interface Block extends OssNode {\n id: number;\n oss: number;\n title: string;\n description: string;\n parent: number | null;\n nodeType: typeof NodeType.BLOCK;\n}\n\n/** Represents item of OperationSchema. */\nexport type OssItem = Operation | Block;\n\n/** Represents {@link OperationSchema} statistics. */\nexport interface OperationSchemaStats {\n count_all: number;\n count_inputs: number;\n count_synthesis: number;\n count_schemas: number;\n count_owned: number;\n count_block: number;\n count_references: number;\n}\n\n/** Represents OperationSchema. */\nexport interface OperationSchema extends LibraryItem {\n editors: number[];\n operations: Operation[];\n blocks: Block[];\n replicas: {\n original: number;\n replica: number;\n }[];\n layout: OssLayout;\n arguments: {\n operation: number;\n argument: number;\n }[];\n substitutions: CstSubstituteInfo[];\n\n graph: Graph;\n extendedGraph: Graph;\n hierarchy: Graph<string>;\n schemas: number[];\n stats: OperationSchemaStats;\n operationByID: Map<number, Operation>;\n blockByID: Map<number, Block>;\n itemByNodeID: Map<string, OssItem>;\n}\n\n/** Represents substitution error description. */\nexport interface SubstitutionErrorDescription {\n errorType: SubstitutionErrorType;\n params: string[];\n}\n\n/** Represents Substitution table error types. */\nexport const SubstitutionErrorType = {\n invalidIDs: 0,\n incorrectCst: 1,\n invalidClasses: 2,\n invalidBasic: 3,\n invalidConstant: 4,\n typificationCycle: 5,\n baseSubstitutionNotSet: 6,\n unequalTypification: 7,\n unequalExpressions: 8,\n unequalArgsCount: 9,\n unequalArgs: 10,\n invalidNominal: 11\n} as const;\nexport type SubstitutionErrorType = (typeof SubstitutionErrorType)[keyof typeof SubstitutionErrorType];\n","import { NodeType, type OperationSchema, OperationType } from './oss';\nimport { type NodePosition, type OssLayout, type Position2D, type Rectangle2D } from './oss-layout';\n\nexport const GRID_SIZE = 10; // pixels - size of OSS grid\nconst MIN_DISTANCE = 2 * GRID_SIZE; // pixels - minimum distance between nodes\n\nexport const OPERATION_NODE_WIDTH = 150;\nexport const OPERATION_NODE_HEIGHT = 40;\n\n/** Layout manipulations for {@link OperationSchema}. */\nexport class LayoutManager {\n public oss: OperationSchema;\n public layout: OssLayout;\n\n constructor(oss: OperationSchema, layout?: OssLayout) {\n this.oss = oss;\n if (layout) {\n this.layout = layout;\n } else {\n this.layout = this.oss.layout;\n }\n }\n\n /** Calculate insert position for a new {@link Operation} */\n newOperationPosition(position: Rectangle2D, parent: number | null, args: number[] = []): Rectangle2D {\n const result = { ...position };\n const parentNode = this.layout.find(pos => pos.nodeID === `b${parent}`) ?? null;\n const operations = this.layout.filter(pos => pos.nodeID.startsWith('o'));\n const hasArguments = args.length !== 0;\n if (hasArguments) {\n const pos = calculatePositionFromArgs(operations.filter(node => args.includes(Number(node.nodeID.slice(1)))));\n result.x = pos.x;\n result.y = pos.y;\n } else if (parentNode) {\n result.x = parentNode.x + MIN_DISTANCE;\n result.y = parentNode.y + MIN_DISTANCE;\n } else {\n const pos = this.calculatePositionForFreeOperation(result);\n result.x = pos.x;\n result.y = pos.y;\n }\n\n const siblingBlocks = this.oss.blocks.filter(block => block.parent === parent).map(block => block.nodeID);\n preventOverlap(\n result,\n this.layout.filter(node => siblingBlocks.includes(node.nodeID)),\n {\n moveX: !hasArguments,\n moveY: hasArguments\n }\n );\n\n preventOverlap(result, operations);\n this.extendParentBounds(parentNode, result);\n\n return result;\n }\n\n /** Calculate insert position for a new {@link Block} */\n newBlockPosition(position: Rectangle2D, parent: number | null, blocks: number[], operations: number[]): Rectangle2D {\n const blockNodes = blocks.map(id => this.layout.find(block => block.nodeID === `b${id}`)).filter(node => !!node);\n const operationNodes = operations\n .map(id => this.layout.find(operation => operation.nodeID === `o${id}`))\n .filter(node => !!node);\n const parentNode = this.layout.find(pos => pos.nodeID === `b${parent}`) ?? null;\n const parentID = parentNode ? parent : null;\n\n let result: Rectangle2D = { ...position };\n\n if (blockNodes.length !== 0 || operationNodes.length !== 0) {\n result = calculatePositionFromChildren(position, operationNodes, blockNodes);\n } else if (parentNode) {\n result = {\n x: parentNode.x + MIN_DISTANCE,\n y: parentNode.y + MIN_DISTANCE,\n width: position.width,\n height: position.height\n };\n } else {\n result = this.calculatePositionForFreeBlock(result);\n }\n\n if (blockNodes.length === 0 && operationNodes.length === 0) {\n const siblings = this.oss.blocks.filter(block => block.parent === parentID).map(block => block.nodeID);\n preventOverlap(\n result,\n this.layout.filter(node => siblings.includes(node.nodeID))\n );\n }\n\n this.extendParentBounds(parentNode, result);\n return result;\n }\n\n /** Calculate insert position for a new clone of {@link Operation} */\n newClonePosition(targetID: string): Rectangle2D | null {\n const targetNode = this.layout.find(pos => pos.nodeID === targetID);\n if (!targetNode) {\n return null;\n } else {\n return {\n x: targetNode.x + targetNode.width / 2 + GRID_SIZE,\n y: targetNode.y + targetNode.height / 2 + GRID_SIZE,\n width: OPERATION_NODE_WIDTH,\n height: OPERATION_NODE_HEIGHT\n };\n }\n }\n\n /** Update layout when parent changes */\n onChangeParent(targetID: string, newParent: string | null) {\n const targetNode = this.layout.find(pos => pos.nodeID === targetID);\n if (!targetNode) {\n return;\n }\n\n const parentNode = this.layout.find(pos => pos.nodeID === newParent) ?? null;\n const offset = this.calculateOffsetForParentChange(targetNode, parentNode);\n if (offset.x === 0 && offset.y === 0) {\n return;\n }\n\n targetNode.x += offset.x;\n targetNode.y += offset.y;\n\n const children = this.oss.hierarchy.expandAllOutputs([targetID]);\n const childrenPositions = this.layout.filter(pos => children.includes(pos.nodeID));\n for (const child of childrenPositions) {\n child.x += offset.x;\n child.y += offset.y;\n }\n\n this.extendParentBounds(parentNode, targetNode);\n }\n\n /** Calculate closest node to the left */\n selectLeft(targetID: string): string | null {\n const targetNode = this.layout.find(pos => pos.nodeID === targetID);\n if (!targetNode) {\n return null;\n }\n const operationNodes = this.layout.filter(pos => pos.nodeID !== targetID && pos.nodeID.startsWith('o'));\n const leftNodes = operationNodes.filter(pos => pos.x <= targetNode.x);\n if (leftNodes.length === 0) {\n return null;\n }\n const similarYNodes = leftNodes.filter(pos => Math.abs(pos.y - targetNode.y) <= MIN_DISTANCE);\n let closestNode: typeof targetNode | null = null;\n if (similarYNodes.length > 0) {\n closestNode = similarYNodes.reduce((prev, curr) => (curr.x > prev.x ? curr : prev));\n } else {\n closestNode = findClosestNodeByDistance(leftNodes, targetNode);\n }\n return closestNode?.nodeID ?? null;\n }\n\n /** Calculate closest node to the right */\n selectRight(targetID: string): string | null {\n const targetNode = this.layout.find(pos => pos.nodeID === targetID);\n if (!targetNode) {\n return null;\n }\n const operationNodes = this.layout.filter(pos => pos.nodeID !== targetID && pos.nodeID.startsWith('o'));\n const rightNodes = operationNodes.filter(pos => pos.x >= targetNode.x);\n if (rightNodes.length === 0) {\n return null;\n }\n const similarYNodes = rightNodes.filter(pos => Math.abs(pos.y - targetNode.y) <= MIN_DISTANCE);\n let closestNode: typeof targetNode | null = null;\n if (similarYNodes.length > 0) {\n closestNode = similarYNodes.reduce((prev, curr) => (curr.x < prev.x ? curr : prev));\n } else {\n closestNode = findClosestNodeByDistance(rightNodes, targetNode);\n }\n return closestNode?.nodeID ?? null;\n }\n\n /** Calculate closest node upwards */\n selectUp(targetID: string): string | null {\n const targetNode = this.layout.find(pos => pos.nodeID === targetID);\n if (!targetNode) {\n return null;\n }\n\n const operationNodes = this.layout.filter(pos => pos.nodeID !== targetID && pos.nodeID.startsWith('o'));\n const upperNodes = operationNodes.filter(pos => pos.y <= targetNode.y - MIN_DISTANCE);\n const targetOperation = this.oss.itemByNodeID.get(targetID);\n if (upperNodes.length === 0 || !targetOperation || targetOperation.nodeType === NodeType.BLOCK) {\n return null;\n }\n\n const predecessors = this.oss.graph.expandAllInputs([targetOperation.id]);\n const predecessorNodes = upperNodes.filter(pos => predecessors.includes(Number(pos.nodeID.slice(1))));\n\n let closestNode: typeof targetNode | null = null;\n if (predecessorNodes.length > 0) {\n closestNode = findClosestNodeByDistance(predecessorNodes, targetNode);\n } else {\n closestNode = findClosestNodeByDistance(upperNodes, targetNode);\n }\n return closestNode?.nodeID ?? null;\n }\n\n /** Calculate closest node downwards */\n selectDown(targetID: string): string | null {\n const targetNode = this.layout.find(pos => pos.nodeID === targetID);\n if (!targetNode) {\n return null;\n }\n\n const operationNodes = this.layout.filter(pos => pos.nodeID !== targetID && pos.nodeID.startsWith('o'));\n const lowerNodes = operationNodes.filter(pos => pos.y >= targetNode.y - MIN_DISTANCE);\n const targetOperation = this.oss.itemByNodeID.get(targetID);\n if (lowerNodes.length === 0 || !targetOperation || targetOperation.nodeType === NodeType.BLOCK) {\n return null;\n }\n\n const descendants = this.oss.graph.expandAllOutputs([targetOperation.id]);\n const descendantsNodes = lowerNodes.filter(pos => descendants.includes(Number(pos.nodeID.slice(1))));\n\n let closestNode: typeof targetNode | null = null;\n if (descendantsNodes.length > 0) {\n closestNode = findClosestNodeByDistance(descendantsNodes, targetNode);\n } else {\n closestNode = findClosestNodeByDistance(lowerNodes, targetNode);\n }\n return closestNode?.nodeID ?? null;\n }\n\n private extendParentBounds(parent: NodePosition | null, child: Rectangle2D) {\n if (!parent) {\n return;\n }\n const borderX = child.x + child.width + MIN_DISTANCE;\n const borderY = child.y + child.height + MIN_DISTANCE;\n parent.width = Math.max(parent.width, borderX - parent.x);\n parent.height = Math.max(parent.height, borderY - parent.y);\n }\n\n private calculatePositionForFreeOperation(initial: Position2D): Position2D {\n if (this.oss.operations.length === 0) {\n return initial;\n }\n\n const freeInputs = this.oss.operations\n .filter(\n operation =>\n operation.parent === null &&\n (operation.operation_type !== OperationType.SYNTHESIS || operation.arguments.length === 0)\n )\n .map(operation => operation.nodeID);\n let inputsPositions = this.layout.filter(pos => freeInputs.includes(pos.nodeID));\n if (inputsPositions.length === 0) {\n inputsPositions = this.layout.filter(pos => pos.nodeID.startsWith('o'));\n }\n const maxX = Math.max(...inputsPositions.map(node => node.x));\n const minY = Math.min(...inputsPositions.map(node => node.y));\n return {\n x: maxX + OPERATION_NODE_WIDTH + MIN_DISTANCE + GRID_SIZE,\n y: minY\n };\n }\n\n private calculatePositionForFreeBlock(initial: Rectangle2D): Rectangle2D {\n const rootBlocks = this.oss.blocks.filter(block => block.parent === null).map(block => block.nodeID);\n const blocksPositions = this.layout.filter(pos => rootBlocks.includes(pos.nodeID));\n if (blocksPositions.length === 0) {\n return initial;\n }\n const maxX = Math.max(...blocksPositions.map(node => node.x + node.width));\n const minY = Math.min(...blocksPositions.map(node => node.y));\n return { ...initial, x: maxX + MIN_DISTANCE, y: minY };\n }\n\n private calculateOffsetForParentChange(target: NodePosition, parent: NodePosition | null): Position2D {\n const newPosition = { ...target };\n if (parent === null) {\n const rootElements = this.oss.hierarchy.rootNodes();\n const positions = this.layout.filter(pos => rootElements.includes(pos.nodeID));\n preventOverlap(newPosition, positions);\n } else if (!rectanglesStrictOverlap(target, parent)) {\n newPosition.x = parent.x + MIN_DISTANCE;\n newPosition.y = parent.y + MIN_DISTANCE;\n\n const siblings = this.oss.hierarchy.at(parent.nodeID)?.outputs ?? [];\n const siblingsPositions = this.layout.filter(pos => siblings.includes(pos.nodeID));\n preventOverlap(newPosition, siblingsPositions);\n }\n return { x: newPosition.x - target.x, y: newPosition.y - target.y };\n }\n}\n\n// ======= Internals =======\nfunction rectanglesOverlap(a: Rectangle2D, b: Rectangle2D): boolean {\n return !(\n a.x + a.width + MIN_DISTANCE <= b.x ||\n b.x + b.width + MIN_DISTANCE <= a.x ||\n a.y + a.height + MIN_DISTANCE <= b.y ||\n b.y + b.height + MIN_DISTANCE <= a.y\n );\n}\n\nfunction rectanglesStrictOverlap(a: Rectangle2D, b: Rectangle2D): boolean {\n return !(a.x + a.width <= b.x || b.x + b.width <= a.x || a.y + a.height <= b.y || b.y + b.height <= a.y);\n}\n\nfunction preventOverlap(\n target: Rectangle2D,\n fixedRectangles: Rectangle2D[],\n options: { moveX?: boolean; moveY?: boolean } = { moveX: true, moveY: true }\n) {\n if ((!options.moveX && !options.moveY) || fixedRectangles.length === 0) {\n return;\n }\n let hasOverlap: boolean;\n do {\n hasOverlap = false;\n for (const fixed of fixedRectangles) {\n if (rectanglesOverlap(target, fixed)) {\n hasOverlap = true;\n if (options.moveX) {\n target.x += MIN_DISTANCE;\n }\n if (options.moveY) {\n target.y += MIN_DISTANCE;\n }\n break;\n }\n }\n } while (hasOverlap);\n}\n\nfunction calculatePositionFromArgs(args: NodePosition[]): Position2D {\n const maxY = Math.max(...args.map(node => node.y));\n const minX = Math.min(...args.map(node => node.x));\n const maxX = Math.max(...args.map(node => node.x));\n return {\n x: Math.ceil((maxX + minX) / 2 / GRID_SIZE) * GRID_SIZE,\n y: maxY + 2 * OPERATION_NODE_HEIGHT + MIN_DISTANCE\n };\n}\n\nfunction calculatePositionFromChildren(\n initial: Rectangle2D,\n operations: NodePosition[],\n blocks: NodePosition[]\n): Rectangle2D {\n const allNodes = [...blocks, ...operations];\n if (allNodes.length === 0) {\n return initial;\n }\n\n const left = Math.min(...allNodes.map(n => n.x)) - MIN_DISTANCE;\n const top = Math.min(...allNodes.map(n => n.y)) - MIN_DISTANCE;\n const right = Math.max(...allNodes.map(n => n.x + n.width)) + MIN_DISTANCE;\n const bottom = Math.max(...allNodes.map(n => n.y + n.height)) + MIN_DISTANCE;\n\n return {\n x: left,\n y: top,\n width: right - left,\n height: bottom - top\n };\n}\n\nfunction findClosestNodeByDistance(nodes: NodePosition[], target: NodePosition): NodePosition | null {\n let minDist = Infinity;\n let minNode = null;\n for (const curr of nodes) {\n const currDist = Math.hypot(curr.x - target.x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YACA,QACa;AACb,QAAM,WAAW,CAAC,GAAG,QAAQ,GAAG,UAAU;AAC1C,MAAI,SAAS,WAAW,GAAG;AACzB,WAAO;AAAA,EACT;AAEA,QAAM,OAAO,KAAK,IAAI,GAAG,SAAS,IAAI,OAAK,EAAE,CAAC,CAAC,IAAI;AACnD,QAAM,MAAM,KAAK,IAAI,GAAG,SAAS,IAAI,OAAK,EAAE,CAAC,CAAC,IAAI;AAClD,QAAM,QAAQ,KAAK,IAAI,GAAG,SAAS,IAAI,OAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI;AAC9D,QAAM,SAAS,KAAK,IAAI,GAAG,SAAS,IAAI,OAAK,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI;AAEhE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,IACH,OAAO,QAAQ;AAAA,IACf,QAAQ,SAAS;AAAA,EACnB;AACF;AAEA,SAAS,0BAA0B,OAAuB,QAA2C;AACnG,MAAI,UAAU;AACd,MAAI,UAAU;AACd,aAAW,QAAQ,OAAO;AACxB,UAAM,WAAW,KAAK,MAAM,KAAK,IAAI,OAAO,GAAG,KAAK,IAAI,OAAO,CAAC;AAChE,QAAI,WAAW,SAAS;AACtB,gBAAU;AACV,gBAAU;AAAA,IACZ;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"file":"oss-layout-api.js","names":[],"sources":["../../src/library/oss-layout-api.ts"],"sourcesContent":["import { NodeType, type OperationSchema, OperationType } from './oss';\nimport { type NodePosition, type OssLayout, type Position2D, type Rectangle2D } from './oss-layout';\n\nexport const GRID_SIZE = 10; // pixels - size of OSS grid\nconst MIN_DISTANCE = 2 * GRID_SIZE; // pixels - minimum distance between nodes\n\nexport const OPERATION_NODE_WIDTH = 150;\nexport const OPERATION_NODE_HEIGHT = 40;\n\n/** Layout manipulations for {@link OperationSchema}. */\nexport class LayoutManager {\n public oss: OperationSchema;\n public layout: OssLayout;\n\n constructor(oss: OperationSchema, layout?: OssLayout) {\n this.oss = oss;\n if (layout) {\n this.layout = layout;\n } else {\n this.layout = this.oss.layout;\n }\n }\n\n /** Calculate insert position for a new {@link Operation} */\n newOperationPosition(position: Rectangle2D, parent: number | null, args: number[] = []): Rectangle2D {\n const result = { ...position };\n const parentNode = this.layout.find(pos => pos.nodeID === `b${parent}`) ?? null;\n const operations = this.layout.filter(pos => pos.nodeID.startsWith('o'));\n const hasArguments = args.length !== 0;\n if (hasArguments) {\n const pos = calculatePositionFromArgs(operations.filter(node => args.includes(Number(node.nodeID.slice(1)))));\n result.x = pos.x;\n result.y = pos.y;\n } else if (parentNode) {\n result.x = parentNode.x + MIN_DISTANCE;\n result.y = parentNode.y + MIN_DISTANCE;\n } else {\n const pos = this.calculatePositionForFreeOperation(result);\n result.x = pos.x;\n result.y = pos.y;\n }\n\n const siblingBlocks = this.oss.blocks.filter(block => block.parent === parent).map(block => block.nodeID);\n preventOverlap(\n result,\n this.layout.filter(node => siblingBlocks.includes(node.nodeID)),\n {\n moveX: !hasArguments,\n moveY: hasArguments\n }\n );\n\n preventOverlap(result, operations);\n this.extendParentBounds(parentNode, result);\n\n return result;\n }\n\n /** Calculate insert position for a new {@link Block} */\n newBlockPosition(position: Rectangle2D, parent: number | null, blocks: number[], operations: number[]): Rectangle2D {\n const blockNodes = blocks.map(id => this.layout.find(block => block.nodeID === `b${id}`)).filter(node => !!node);\n const operationNodes = operations\n .map(id => this.layout.find(operation => operation.nodeID === `o${id}`))\n .filter(node => !!node);\n const parentNode = this.layout.find(pos => pos.nodeID === `b${parent}`) ?? null;\n const parentID = parentNode ? parent : null;\n\n let result: Rectangle2D = { ...position };\n\n if (blockNodes.length !== 0 || operationNodes.length !== 0) {\n result = calculatePositionFromChildren(position, operationNodes, blockNodes);\n } else if (parentNode) {\n result = {\n x: parentNode.x + MIN_DISTANCE,\n y: parentNode.y + MIN_DISTANCE,\n width: position.width,\n height: position.height\n };\n } else {\n result = this.calculatePositionForFreeBlock(result);\n }\n\n if (blockNodes.length === 0 && operationNodes.length === 0) {\n const siblings = this.oss.blocks.filter(block => block.parent === parentID).map(block => block.nodeID);\n preventOverlap(\n result,\n this.layout.filter(node => siblings.includes(node.nodeID))\n );\n }\n\n this.extendParentBounds(parentNode, result);\n return result;\n }\n\n /** Calculate insert position for a new clone of {@link Operation} */\n newClonePosition(targetID: string): Rectangle2D | null {\n const targetNode = this.layout.find(pos => pos.nodeID === targetID);\n if (!targetNode) {\n return null;\n } else {\n return {\n x: targetNode.x + targetNode.width / 2 + GRID_SIZE,\n y: targetNode.y + targetNode.height / 2 + GRID_SIZE,\n width: OPERATION_NODE_WIDTH,\n height: OPERATION_NODE_HEIGHT\n };\n }\n }\n\n /** Update layout when parent changes */\n onChangeParent(targetID: string, newParent: string | null) {\n const targetNode = this.layout.find(pos => pos.nodeID === targetID);\n if (!targetNode) {\n return;\n }\n\n const parentNode = this.layout.find(pos => pos.nodeID === newParent) ?? null;\n const offset = this.calculateOffsetForParentChange(targetNode, parentNode);\n if (offset.x === 0 && offset.y === 0) {\n return;\n }\n\n targetNode.x += offset.x;\n targetNode.y += offset.y;\n\n const children = this.oss.hierarchy.expandAllOutputs([targetID]);\n const childrenPositions = this.layout.filter(pos => children.includes(pos.nodeID));\n for (const child of childrenPositions) {\n child.x += offset.x;\n child.y += offset.y;\n }\n\n this.extendParentBounds(parentNode, targetNode);\n }\n\n /** Calculate closest node to the left */\n selectLeft(targetID: string): string | null {\n const targetNode = this.layout.find(pos => pos.nodeID === targetID);\n if (!targetNode) {\n return null;\n }\n const operationNodes = this.layout.filter(pos => pos.nodeID !== targetID && pos.nodeID.startsWith('o'));\n const leftNodes = operationNodes.filter(pos => pos.x <= targetNode.x);\n if (leftNodes.length === 0) {\n return null;\n }\n const similarYNodes = leftNodes.filter(pos => Math.abs(pos.y - targetNode.y) <= MIN_DISTANCE);\n let closestNode: typeof targetNode | null = null;\n if (similarYNodes.length > 0) {\n closestNode = similarYNodes.reduce((prev, curr) => (curr.x > prev.x ? curr : prev));\n } else {\n closestNode = findClosestNodeByDistance(leftNodes, targetNode);\n }\n return closestNode?.nodeID ?? null;\n }\n\n /** Calculate closest node to the right */\n selectRight(targetID: string): string | null {\n const targetNode = this.layout.find(pos => pos.nodeID === targetID);\n if (!targetNode) {\n return null;\n }\n const operationNodes = this.layout.filter(pos => pos.nodeID !== targetID && pos.nodeID.startsWith('o'));\n const rightNodes = operationNodes.filter(pos => pos.x >= targetNode.x);\n if (rightNodes.length === 0) {\n return null;\n }\n const similarYNodes = rightNodes.filter(pos => Math.abs(pos.y - targetNode.y) <= MIN_DISTANCE);\n let closestNode: typeof targetNode | null = null;\n if (similarYNodes.length > 0) {\n closestNode = similarYNodes.reduce((prev, curr) => (curr.x < prev.x ? curr : prev));\n } else {\n closestNode = findClosestNodeByDistance(rightNodes, targetNode);\n }\n return closestNode?.nodeID ?? null;\n }\n\n /** Calculate closest node upwards */\n selectUp(targetID: string): string | null {\n const targetNode = this.layout.find(pos => pos.nodeID === targetID);\n if (!targetNode) {\n return null;\n }\n\n const operationNodes = this.layout.filter(pos => pos.nodeID !== targetID && pos.nodeID.startsWith('o'));\n const upperNodes = operationNodes.filter(pos => pos.y <= targetNode.y - MIN_DISTANCE);\n const targetOperation = this.oss.itemByNodeID.get(targetID);\n if (upperNodes.length === 0 || !targetOperation || targetOperation.nodeType === NodeType.BLOCK) {\n return null;\n }\n\n const predecessors = this.oss.graph.expandAllInputs([targetOperation.id]);\n const predecessorNodes = upperNodes.filter(pos => predecessors.includes(Number(pos.nodeID.slice(1))));\n\n let closestNode: typeof targetNode | null = null;\n if (predecessorNodes.length > 0) {\n closestNode = findClosestNodeByDistance(predecessorNodes, targetNode);\n } else {\n closestNode = findClosestNodeByDistance(upperNodes, targetNode);\n }\n return closestNode?.nodeID ?? null;\n }\n\n /** Calculate closest node downwards */\n selectDown(targetID: string): string | null {\n const targetNode = this.layout.find(pos => pos.nodeID === targetID);\n if (!targetNode) {\n return null;\n }\n\n const operationNodes = this.layout.filter(pos => pos.nodeID !== targetID && pos.nodeID.startsWith('o'));\n const lowerNodes = operationNodes.filter(pos => pos.y >= targetNode.y - MIN_DISTANCE);\n const targetOperation = this.oss.itemByNodeID.get(targetID);\n if (lowerNodes.length === 0 || !targetOperation || targetOperation.nodeType === NodeType.BLOCK) {\n return null;\n }\n\n const descendants = this.oss.graph.expandAllOutputs([targetOperation.id]);\n const descendantsNodes = lowerNodes.filter(pos => descendants.includes(Number(pos.nodeID.slice(1))));\n\n let closestNode: typeof targetNode | null = null;\n if (descendantsNodes.length > 0) {\n closestNode = findClosestNodeByDistance(descendantsNodes, targetNode);\n } else {\n closestNode = findClosestNodeByDistance(lowerNodes, targetNode);\n }\n return closestNode?.nodeID ?? null;\n }\n\n private extendParentBounds(parent: NodePosition | null, child: Rectangle2D) {\n if (!parent) {\n return;\n }\n const borderX = child.x + child.width + MIN_DISTANCE;\n const borderY = child.y + child.height + MIN_DISTANCE;\n parent.width = Math.max(parent.width, borderX - parent.x);\n parent.height = Math.max(parent.height, borderY - parent.y);\n }\n\n private calculatePositionForFreeOperation(initial: Position2D): Position2D {\n if (this.oss.operations.length === 0) {\n return initial;\n }\n\n const freeInputs = this.oss.operations\n .filter(\n operation =>\n operation.parent === null &&\n (operation.operation_type !== OperationType.SYNTHESIS || operation.arguments.length === 0)\n )\n .map(operation => operation.nodeID);\n let inputsPositions = this.layout.filter(pos => freeInputs.includes(pos.nodeID));\n if (inputsPositions.length === 0) {\n inputsPositions = this.layout.filter(pos => pos.nodeID.startsWith('o'));\n }\n const maxX = Math.max(...inputsPositions.map(node => node.x));\n const minY = Math.min(...inputsPositions.map(node => node.y));\n return {\n x: maxX + OPERATION_NODE_WIDTH + MIN_DISTANCE + GRID_SIZE,\n y: minY\n };\n }\n\n private calculatePositionForFreeBlock(initial: Rectangle2D): Rectangle2D {\n const rootBlocks = this.oss.blocks.filter(block => block.parent === null).map(block => block.nodeID);\n const blocksPositions = this.layout.filter(pos => rootBlocks.includes(pos.nodeID));\n if (blocksPositions.length === 0) {\n return initial;\n }\n const maxX = Math.max(...blocksPositions.map(node => node.x + node.width));\n const minY = Math.min(...blocksPositions.map(node => node.y));\n return { ...initial, x: maxX + MIN_DISTANCE, y: minY };\n }\n\n private calculateOffsetForParentChange(target: NodePosition, parent: NodePosition | null): Position2D {\n const newPosition = { ...target };\n if (parent === null) {\n const rootElements = this.oss.hierarchy.rootNodes();\n const positions = this.layout.filter(pos => rootElements.includes(pos.nodeID));\n preventOverlap(newPosition, positions);\n } else if (!rectanglesStrictOverlap(target, parent)) {\n newPosition.x = parent.x + MIN_DISTANCE;\n newPosition.y = parent.y + MIN_DISTANCE;\n\n const siblings = this.oss.hierarchy.at(parent.nodeID)?.outputs ?? [];\n const siblingsPositions = this.layout.filter(pos => siblings.includes(pos.nodeID));\n preventOverlap(newPosition, siblingsPositions);\n }\n return { x: newPosition.x - target.x, y: newPosition.y - target.y };\n }\n}\n\n// ======= Internals =======\nfunction rectanglesOverlap(a: Rectangle2D, b: Rectangle2D): boolean {\n return !(\n a.x + a.width + MIN_DISTANCE <= b.x ||\n b.x + b.width + MIN_DISTANCE <= a.x ||\n a.y + a.height + MIN_DISTANCE <= b.y ||\n b.y + b.height + MIN_DISTANCE <= a.y\n );\n}\n\nfunction rectanglesStrictOverlap(a: Rectangle2D, b: Rectangle2D): boolean {\n return !(a.x + a.width <= b.x || b.x + b.width <= a.x || a.y + a.height <= b.y || b.y + b.height <= a.y);\n}\n\nfunction preventOverlap(\n target: Rectangle2D,\n fixedRectangles: Rectangle2D[],\n options: { moveX?: boolean; moveY?: boolean } = { moveX: true, moveY: true }\n) {\n if ((!options.moveX && !options.moveY) || fixedRectangles.length === 0) {\n return;\n }\n let hasOverlap: boolean;\n do {\n hasOverlap = false;\n for (const fixed of fixedRectangles) {\n if (rectanglesOverlap(target, fixed)) {\n hasOverlap = true;\n if (options.moveX) {\n target.x += MIN_DISTANCE;\n }\n if (options.moveY) {\n target.y += MIN_DISTANCE;\n }\n break;\n }\n }\n } while (hasOverlap);\n}\n\nfunction calculatePositionFromArgs(args: NodePosition[]): Position2D {\n const maxY = Math.max(...args.map(node => node.y));\n const minX = Math.min(...args.map(node => node.x));\n const maxX = Math.max(...args.map(node => node.x));\n return {\n x: Math.ceil((maxX + minX) / 2 / GRID_SIZE) * GRID_SIZE,\n y: maxY + 2 * OPERATION_NODE_HEIGHT + MIN_DISTANCE\n };\n}\n\nfunction calculatePositionFromChildren(\n initial: Rectangle2D,\n operations: NodePosition[],\n blocks: NodePosition[]\n): Rectangle2D {\n const allNodes = [...blocks, ...operations];\n if (allNodes.length === 0) {\n return initial;\n }\n\n const left = Math.min(...allNodes.map(n => n.x)) - MIN_DISTANCE;\n const top = Math.min(...allNodes.map(n => n.y)) - MIN_DISTANCE;\n const right = Math.max(...allNodes.map(n => n.x + n.width)) + MIN_DISTANCE;\n const bottom = Math.max(...allNodes.map(n => n.y + n.height)) + MIN_DISTANCE;\n\n return {\n x: left,\n y: top,\n width: right - left,\n height: bottom - top\n };\n}\n\nfunction findClosestNodeByDistance(nodes: NodePosition[], target: NodePosition): NodePosition | null {\n let minDist = Infinity;\n let minNode = null;\n for (const curr of nodes) {\n const currDist = Math.hypot(curr.x - target.x, curr.y - target.y);\n if (currDist < minDist) {\n minDist = currDist;\n minNode = curr;\n }\n }\n return minNode;\n}\n"],"mappings":";;AAGA,MAAa,YAAY;AACzB,MAAM,eAAe;AAErB,MAAa,uBAAuB;AACpC,MAAa,wBAAwB;;AAGrC,IAAa,gBAAb,MAA2B;CACzB;CACA;CAEA,YAAY,KAAsB,QAAoB;EACpD,KAAK,MAAM;EACX,IAAI,QACF,KAAK,SAAS;OAEd,KAAK,SAAS,KAAK,IAAI;CAE3B;;CAGA,qBAAqB,UAAuB,QAAuB,OAAiB,CAAC,GAAgB;EACnG,MAAM,SAAS,EAAE,GAAG,SAAS;EAC7B,MAAM,aAAa,KAAK,OAAO,MAAK,QAAO,IAAI,WAAW,IAAI,QAAQ,KAAK;EAC3E,MAA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;EACH,OAAO,QAAQ;EACf,QAAQ,SAAS;CACnB;AACF;AAEA,SAAS,0BAA0B,OAAuB,QAA2C;CACnG,IAAI,UAAU;CACd,IAAI,UAAU;CACd,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,KAAK,MAAM,KAAK,IAAI,OAAO,GAAG,KAAK,IAAI,OAAO,CAAC;EAChE,IAAI,WAAW,SAAS;GACtB,UAAU;GACV,UAAU;EACZ;CACF;CACA,OAAO;AACT"}
|
|
@@ -1,25 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
/** Represents XY Position. */
|
|
5
|
-
interface Position2D {
|
|
6
|
-
x: number;
|
|
7
|
-
y: number;
|
|
8
|
-
}
|
|
9
|
-
/** Represents XY Position and dimensions. */
|
|
10
|
-
interface Rectangle2D extends Position2D {
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
}
|
|
14
|
-
/** Represents a node in {@link OssLayout}. */
|
|
15
|
-
interface NodePosition {
|
|
16
|
-
nodeID: string;
|
|
17
|
-
x: number;
|
|
18
|
-
y: number;
|
|
19
|
-
width: number;
|
|
20
|
-
height: number;
|
|
21
|
-
}
|
|
22
|
-
/** Represents {@link OperationSchema} layout. */
|
|
23
|
-
type OssLayout = NodePosition[];
|
|
24
|
-
|
|
25
|
-
export type { NodePosition, OssLayout, Position2D, Rectangle2D };
|
|
1
|
+
import { i as Rectangle2D, n as OssLayout, r as Position2D, t as NodePosition } from "../oss-layout-3glgAqfn.js";
|
|
2
|
+
export { NodePosition, OssLayout, Position2D, Rectangle2D };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
package/dist/library/oss.d.ts
CHANGED
|
@@ -1,136 +1,134 @@
|
|
|
1
|
-
import { Graph } from
|
|
2
|
-
import { LibraryItem } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Module: Schema of Synthesis Operations.
|
|
7
|
-
*/
|
|
1
|
+
import { t as Graph } from "../graph-DR8rL2o3.js";
|
|
2
|
+
import { r as LibraryItem } from "../library-CYun28Xz.js";
|
|
3
|
+
import { n as OssLayout, t as NodePosition } from "../oss-layout-3glgAqfn.js";
|
|
8
4
|
|
|
5
|
+
//#region src/library/oss.d.ts
|
|
9
6
|
/** Represents OSS node type. */
|
|
10
7
|
declare const NodeType: {
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
readonly OPERATION: 1;
|
|
9
|
+
readonly BLOCK: 2;
|
|
13
10
|
};
|
|
14
11
|
type NodeType = (typeof NodeType)[keyof typeof NodeType];
|
|
15
12
|
/** Represents OSS graph node. */
|
|
16
13
|
interface OssNode extends NodePosition {
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
nodeType: NodeType;
|
|
15
|
+
parent: number | null;
|
|
19
16
|
}
|
|
20
17
|
/** Represents {@link Operation} type. */
|
|
21
18
|
declare const OperationType: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
readonly INPUT: "input";
|
|
20
|
+
readonly SYNTHESIS: "synthesis";
|
|
21
|
+
readonly REPLICA: "replica";
|
|
25
22
|
};
|
|
26
23
|
type OperationType = (typeof OperationType)[keyof typeof OperationType];
|
|
27
24
|
/** Represents {@link Substitution} extended data. */
|
|
28
25
|
interface CstSubstituteInfo {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
original: number;
|
|
27
|
+
substitution: number;
|
|
28
|
+
operation: number;
|
|
29
|
+
original_schema: number;
|
|
30
|
+
original_alias: string;
|
|
31
|
+
original_term: string;
|
|
32
|
+
substitution_schema: number;
|
|
33
|
+
substitution_alias: string;
|
|
34
|
+
substitution_term: string;
|
|
38
35
|
}
|
|
39
36
|
/** Represents Operation common attributes. */
|
|
40
37
|
interface OperationBase extends OssNode {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
id: number;
|
|
39
|
+
alias: string;
|
|
40
|
+
title: string;
|
|
41
|
+
description: string;
|
|
42
|
+
operation_type: OperationType;
|
|
43
|
+
result: number | null;
|
|
44
|
+
nodeType: typeof NodeType.OPERATION;
|
|
45
|
+
has_additions: boolean;
|
|
49
46
|
}
|
|
50
47
|
/** Represents Input Operation. */
|
|
51
48
|
interface OperationInput extends OperationBase {
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
operation_type: typeof OperationType.INPUT;
|
|
50
|
+
is_import: boolean;
|
|
54
51
|
}
|
|
55
52
|
/** Represents Replica Operation. */
|
|
56
53
|
interface OperationReplica extends OperationBase {
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
operation_type: typeof OperationType.REPLICA;
|
|
55
|
+
target: number;
|
|
59
56
|
}
|
|
60
57
|
/** Represents Synthesis Operation. */
|
|
61
58
|
interface OperationSynthesis extends OperationBase {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
operation_type: typeof OperationType.SYNTHESIS;
|
|
60
|
+
is_consolidation: boolean;
|
|
61
|
+
substitutions: CstSubstituteInfo[];
|
|
62
|
+
arguments: number[];
|
|
66
63
|
}
|
|
67
64
|
/** Represents Operation. */
|
|
68
65
|
type Operation = OperationInput | OperationReplica | OperationSynthesis;
|
|
69
66
|
/** Represents Block. */
|
|
70
67
|
interface Block extends OssNode {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
id: number;
|
|
69
|
+
oss: number;
|
|
70
|
+
title: string;
|
|
71
|
+
description: string;
|
|
72
|
+
parent: number | null;
|
|
73
|
+
nodeType: typeof NodeType.BLOCK;
|
|
77
74
|
}
|
|
78
75
|
/** Represents item of OperationSchema. */
|
|
79
76
|
type OssItem = Operation | Block;
|
|
80
77
|
/** Represents {@link OperationSchema} statistics. */
|
|
81
78
|
interface OperationSchemaStats {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
count_all: number;
|
|
80
|
+
count_inputs: number;
|
|
81
|
+
count_synthesis: number;
|
|
82
|
+
count_schemas: number;
|
|
83
|
+
count_owned: number;
|
|
84
|
+
count_block: number;
|
|
85
|
+
count_references: number;
|
|
89
86
|
}
|
|
90
87
|
/** Represents OperationSchema. */
|
|
91
88
|
interface OperationSchema extends LibraryItem {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
89
|
+
editors: number[];
|
|
90
|
+
operations: Operation[];
|
|
91
|
+
blocks: Block[];
|
|
92
|
+
replicas: {
|
|
93
|
+
original: number;
|
|
94
|
+
replica: number;
|
|
95
|
+
}[];
|
|
96
|
+
layout: OssLayout;
|
|
97
|
+
arguments: {
|
|
98
|
+
operation: number;
|
|
99
|
+
argument: number;
|
|
100
|
+
}[];
|
|
101
|
+
substitutions: CstSubstituteInfo[];
|
|
102
|
+
graph: Graph;
|
|
103
|
+
extendedGraph: Graph;
|
|
104
|
+
hierarchy: Graph<string>;
|
|
105
|
+
schemas: number[];
|
|
106
|
+
stats: OperationSchemaStats;
|
|
107
|
+
operationByID: Map<number, Operation>;
|
|
108
|
+
blockByID: Map<number, Block>;
|
|
109
|
+
itemByNodeID: Map<string, OssItem>;
|
|
113
110
|
}
|
|
114
111
|
/** Represents substitution error description. */
|
|
115
112
|
interface SubstitutionErrorDescription {
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
errorType: SubstitutionErrorType;
|
|
114
|
+
params: string[];
|
|
118
115
|
}
|
|
119
116
|
/** Represents Substitution table error types. */
|
|
120
117
|
declare const SubstitutionErrorType: {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
118
|
+
readonly invalidIDs: 0;
|
|
119
|
+
readonly incorrectCst: 1;
|
|
120
|
+
readonly invalidClasses: 2;
|
|
121
|
+
readonly invalidBasic: 3;
|
|
122
|
+
readonly invalidConstant: 4;
|
|
123
|
+
readonly typificationCycle: 5;
|
|
124
|
+
readonly baseSubstitutionNotSet: 6;
|
|
125
|
+
readonly unequalTypification: 7;
|
|
126
|
+
readonly unequalExpressions: 8;
|
|
127
|
+
readonly unequalArgsCount: 9;
|
|
128
|
+
readonly unequalArgs: 10;
|
|
129
|
+
readonly invalidNominal: 11;
|
|
133
130
|
};
|
|
134
131
|
type SubstitutionErrorType = (typeof SubstitutionErrorType)[keyof typeof SubstitutionErrorType];
|
|
135
|
-
|
|
136
|
-
export {
|
|
132
|
+
//#endregion
|
|
133
|
+
export { Block, CstSubstituteInfo, NodeType, Operation, OperationInput, OperationSchema, OperationSchemaStats, OperationSynthesis, OperationType, OssItem, SubstitutionErrorDescription, SubstitutionErrorType };
|
|
134
|
+
//# sourceMappingURL=oss.d.ts.map
|
package/dist/library/oss.js
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//#region src/library/oss.ts
|
|
2
|
+
/** Represents OSS node type. */
|
|
3
|
+
const NodeType = {
|
|
4
|
+
OPERATION: 1,
|
|
5
|
+
BLOCK: 2
|
|
5
6
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/** Represents {@link Operation} type. */
|
|
8
|
+
const OperationType = {
|
|
9
|
+
INPUT: "input",
|
|
10
|
+
SYNTHESIS: "synthesis",
|
|
11
|
+
REPLICA: "replica"
|
|
10
12
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export {
|
|
26
|
-
NodeType,
|
|
27
|
-
OperationType,
|
|
28
|
-
SubstitutionErrorType
|
|
13
|
+
/** Represents Substitution table error types. */
|
|
14
|
+
const SubstitutionErrorType = {
|
|
15
|
+
invalidIDs: 0,
|
|
16
|
+
incorrectCst: 1,
|
|
17
|
+
invalidClasses: 2,
|
|
18
|
+
invalidBasic: 3,
|
|
19
|
+
invalidConstant: 4,
|
|
20
|
+
typificationCycle: 5,
|
|
21
|
+
baseSubstitutionNotSet: 6,
|
|
22
|
+
unequalTypification: 7,
|
|
23
|
+
unequalExpressions: 8,
|
|
24
|
+
unequalArgsCount: 9,
|
|
25
|
+
unequalArgs: 10,
|
|
26
|
+
invalidNominal: 11
|
|
29
27
|
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { NodeType, OperationType, SubstitutionErrorType };
|
|
30
|
+
|
|
30
31
|
//# sourceMappingURL=oss.js.map
|
package/dist/library/oss.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/library/oss.ts"],"sourcesContent":["/**\n * Module: Schema of Synthesis Operations.\n */\n\nimport { type Graph } from '../graph';\n\nimport { type LibraryItem } from './library';\nimport { type NodePosition, type OssLayout } from './oss-layout';\n\n/** Represents OSS node type. */\nexport const NodeType = {\n OPERATION: 1,\n BLOCK: 2\n} as const;\nexport type NodeType = (typeof NodeType)[keyof typeof NodeType];\n\n/** Represents OSS graph node. */\ninterface OssNode extends NodePosition {\n nodeType: NodeType;\n parent: number | null;\n}\n\n/** Represents {@link Operation} type. */\nexport const OperationType = {\n INPUT: 'input',\n SYNTHESIS: 'synthesis',\n REPLICA: 'replica'\n} as const;\nexport type OperationType = (typeof OperationType)[keyof typeof OperationType];\n\n/** Represents {@link Substitution} extended data. */\nexport interface CstSubstituteInfo {\n original: number;\n substitution: number;\n operation: number;\n original_schema: number;\n original_alias: string;\n original_term: string;\n substitution_schema: number;\n substitution_alias: string;\n substitution_term: string;\n}\n\n/** Represents Operation common attributes. */\ninterface OperationBase extends OssNode {\n id: number;\n alias: string;\n title: string;\n description: string;\n operation_type: OperationType;\n result: number | null;\n nodeType: typeof NodeType.OPERATION;\n has_additions: boolean;\n}\n\n/** Represents Input Operation. */\nexport interface OperationInput extends OperationBase {\n operation_type: typeof OperationType.INPUT;\n is_import: boolean;\n}\n\n/** Represents Replica Operation. */\ninterface OperationReplica extends OperationBase {\n operation_type: typeof OperationType.REPLICA;\n target: number;\n}\n\n/** Represents Synthesis Operation. */\nexport interface OperationSynthesis extends OperationBase {\n operation_type: typeof OperationType.SYNTHESIS;\n is_consolidation: boolean; // aka 'diamond synthesis'\n substitutions: CstSubstituteInfo[];\n arguments: number[];\n}\n\n/** Represents Operation. */\nexport type Operation = OperationInput | OperationReplica | OperationSynthesis;\n\n/** Represents Block. */\nexport interface Block extends OssNode {\n id: number;\n oss: number;\n title: string;\n description: string;\n parent: number | null;\n nodeType: typeof NodeType.BLOCK;\n}\n\n/** Represents item of OperationSchema. */\nexport type OssItem = Operation | Block;\n\n/** Represents {@link OperationSchema} statistics. */\nexport interface OperationSchemaStats {\n count_all: number;\n count_inputs: number;\n count_synthesis: number;\n count_schemas: number;\n count_owned: number;\n count_block: number;\n count_references: number;\n}\n\n/** Represents OperationSchema. */\nexport interface OperationSchema extends LibraryItem {\n editors: number[];\n operations: Operation[];\n blocks: Block[];\n replicas: {\n original: number;\n replica: number;\n }[];\n layout: OssLayout;\n arguments: {\n operation: number;\n argument: number;\n }[];\n substitutions: CstSubstituteInfo[];\n\n graph: Graph;\n extendedGraph: Graph;\n hierarchy: Graph<string>;\n schemas: number[];\n stats: OperationSchemaStats;\n operationByID: Map<number, Operation>;\n blockByID: Map<number, Block>;\n itemByNodeID: Map<string, OssItem>;\n}\n\n/** Represents substitution error description. */\nexport interface SubstitutionErrorDescription {\n errorType: SubstitutionErrorType;\n params: string[];\n}\n\n/** Represents Substitution table error types. */\nexport const SubstitutionErrorType = {\n invalidIDs: 0,\n incorrectCst: 1,\n invalidClasses: 2,\n invalidBasic: 3,\n invalidConstant: 4,\n typificationCycle: 5,\n baseSubstitutionNotSet: 6,\n unequalTypification: 7,\n unequalExpressions: 8,\n unequalArgsCount: 9,\n unequalArgs: 10,\n invalidNominal: 11\n} as const;\nexport type SubstitutionErrorType = (typeof SubstitutionErrorType)[keyof typeof SubstitutionErrorType];\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"oss.js","names":[],"sources":["../../src/library/oss.ts"],"sourcesContent":["/**\n * Module: Schema of Synthesis Operations.\n */\n\nimport { type Graph } from '../graph';\n\nimport { type LibraryItem } from './library';\nimport { type NodePosition, type OssLayout } from './oss-layout';\n\n/** Represents OSS node type. */\nexport const NodeType = {\n OPERATION: 1,\n BLOCK: 2\n} as const;\nexport type NodeType = (typeof NodeType)[keyof typeof NodeType];\n\n/** Represents OSS graph node. */\ninterface OssNode extends NodePosition {\n nodeType: NodeType;\n parent: number | null;\n}\n\n/** Represents {@link Operation} type. */\nexport const OperationType = {\n INPUT: 'input',\n SYNTHESIS: 'synthesis',\n REPLICA: 'replica'\n} as const;\nexport type OperationType = (typeof OperationType)[keyof typeof OperationType];\n\n/** Represents {@link Substitution} extended data. */\nexport interface CstSubstituteInfo {\n original: number;\n substitution: number;\n operation: number;\n original_schema: number;\n original_alias: string;\n original_term: string;\n substitution_schema: number;\n substitution_alias: string;\n substitution_term: string;\n}\n\n/** Represents Operation common attributes. */\ninterface OperationBase extends OssNode {\n id: number;\n alias: string;\n title: string;\n description: string;\n operation_type: OperationType;\n result: number | null;\n nodeType: typeof NodeType.OPERATION;\n has_additions: boolean;\n}\n\n/** Represents Input Operation. */\nexport interface OperationInput extends OperationBase {\n operation_type: typeof OperationType.INPUT;\n is_import: boolean;\n}\n\n/** Represents Replica Operation. */\ninterface OperationReplica extends OperationBase {\n operation_type: typeof OperationType.REPLICA;\n target: number;\n}\n\n/** Represents Synthesis Operation. */\nexport interface OperationSynthesis extends OperationBase {\n operation_type: typeof OperationType.SYNTHESIS;\n is_consolidation: boolean; // aka 'diamond synthesis'\n substitutions: CstSubstituteInfo[];\n arguments: number[];\n}\n\n/** Represents Operation. */\nexport type Operation = OperationInput | OperationReplica | OperationSynthesis;\n\n/** Represents Block. */\nexport interface Block extends OssNode {\n id: number;\n oss: number;\n title: string;\n description: string;\n parent: number | null;\n nodeType: typeof NodeType.BLOCK;\n}\n\n/** Represents item of OperationSchema. */\nexport type OssItem = Operation | Block;\n\n/** Represents {@link OperationSchema} statistics. */\nexport interface OperationSchemaStats {\n count_all: number;\n count_inputs: number;\n count_synthesis: number;\n count_schemas: number;\n count_owned: number;\n count_block: number;\n count_references: number;\n}\n\n/** Represents OperationSchema. */\nexport interface OperationSchema extends LibraryItem {\n editors: number[];\n operations: Operation[];\n blocks: Block[];\n replicas: {\n original: number;\n replica: number;\n }[];\n layout: OssLayout;\n arguments: {\n operation: number;\n argument: number;\n }[];\n substitutions: CstSubstituteInfo[];\n\n graph: Graph;\n extendedGraph: Graph;\n hierarchy: Graph<string>;\n schemas: number[];\n stats: OperationSchemaStats;\n operationByID: Map<number, Operation>;\n blockByID: Map<number, Block>;\n itemByNodeID: Map<string, OssItem>;\n}\n\n/** Represents substitution error description. */\nexport interface SubstitutionErrorDescription {\n errorType: SubstitutionErrorType;\n params: string[];\n}\n\n/** Represents Substitution table error types. */\nexport const SubstitutionErrorType = {\n invalidIDs: 0,\n incorrectCst: 1,\n invalidClasses: 2,\n invalidBasic: 3,\n invalidConstant: 4,\n typificationCycle: 5,\n baseSubstitutionNotSet: 6,\n unequalTypification: 7,\n unequalExpressions: 8,\n unequalArgsCount: 9,\n unequalArgs: 10,\n invalidNominal: 11\n} as const;\nexport type SubstitutionErrorType = (typeof SubstitutionErrorType)[keyof typeof SubstitutionErrorType];\n"],"mappings":";;AAUA,MAAa,WAAW;CACtB,WAAW;CACX,OAAO;AACT;;AAUA,MAAa,gBAAgB;CAC3B,OAAO;CACP,WAAW;CACX,SAAS;AACX;;AA4GA,MAAa,wBAAwB;CACnC,YAAY;CACZ,cAAc;CACd,gBAAgB;CAChB,cAAc;CACd,iBAAiB;CACjB,mBAAmB;CACnB,wBAAwB;CACxB,qBAAqB;CACrB,oBAAoB;CACpB,kBAAkB;CAClB,aAAa;CACb,gBAAgB;AAClB"}
|