@rsconcept/domain 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +258 -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/oss-api.test.ts +76 -0
- package/src/library/oss-api.ts +4 -1
- 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
package/dist/graph/graph.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/graph/graph.ts"],"sourcesContent":["/**\n * Module: Custom graph data structure.\n */\n\n/** Represents single node of a {@link Graph}, as implemented by storing outgoing and incoming connections. */\nexport class GraphNode<NodeID> {\n /** Unique identifier of the node. */\n id: NodeID;\n /** List of outgoing nodes. */\n outputs: NodeID[];\n /** List of incoming nodes. */\n inputs: NodeID[];\n\n constructor(id: NodeID) {\n this.id = id;\n this.outputs = [];\n this.inputs = [];\n }\n\n clone(): GraphNode<NodeID> {\n const result = new GraphNode(this.id);\n result.outputs = [...this.outputs];\n result.inputs = [...this.inputs];\n return result;\n }\n\n addOutput(node: NodeID): void {\n this.outputs.push(node);\n }\n\n addInput(node: NodeID): void {\n this.inputs.push(node);\n }\n\n removeInput(target: NodeID): NodeID | null {\n const index = this.inputs.findIndex(node => node === target);\n return index > -1 ? this.inputs.splice(index, 1)[0] : null;\n }\n\n removeOutput(target: NodeID): NodeID | null {\n const index = this.outputs.findIndex(node => node === target);\n return index > -1 ? this.outputs.splice(index, 1)[0] : null;\n }\n}\n\n/**\n * Represents a Graph.\n *\n * This class is optimized for TermGraph use case and not supposed to be used as generic graph implementation.\n */\nexport class Graph<NodeID = number> {\n /** Map of nodes. */\n nodes = new Map<NodeID, GraphNode<NodeID>>();\n\n constructor(arr?: NodeID[][]) {\n if (!arr) {\n return;\n }\n arr.forEach(edge => {\n if (edge.length === 1) {\n this.addNode(edge[0]);\n } else {\n this.addEdge(edge[0], edge[1]);\n }\n });\n }\n\n clone(): Graph<NodeID> {\n const result = new Graph<NodeID>();\n this.nodes.forEach(node => result.nodes.set(node.id, node.clone()));\n return result;\n }\n\n at(target: NodeID): GraphNode<NodeID> | undefined {\n return this.nodes.get(target);\n }\n\n addNode(target: NodeID): GraphNode<NodeID> {\n let node = this.nodes.get(target);\n if (!node) {\n node = new GraphNode(target);\n this.nodes.set(target, node);\n }\n return node;\n }\n\n hasNode(target: NodeID): boolean {\n return !!this.nodes.get(target);\n }\n\n removeNode(target: NodeID): void {\n this.nodes.forEach(node => {\n node.removeInput(target);\n node.removeOutput(target);\n });\n this.nodes.delete(target);\n }\n\n foldNode(target: NodeID): void {\n const nodeToRemove = this.nodes.get(target);\n if (!nodeToRemove) {\n return;\n }\n nodeToRemove.inputs.forEach(input => {\n nodeToRemove.outputs.forEach(output => {\n this.addEdge(input, output);\n });\n });\n this.removeNode(target);\n }\n\n removeIsolated(): GraphNode<NodeID>[] {\n const result: GraphNode<NodeID>[] = [];\n this.nodes.forEach(node => {\n if (node.outputs.length === 0 && node.inputs.length === 0) {\n result.push(node);\n this.nodes.delete(node.id);\n }\n });\n return result;\n }\n\n addEdge(source: NodeID, destination: NodeID): void {\n if (this.hasEdge(source, destination)) {\n return;\n }\n const sourceNode = this.addNode(source);\n const destinationNode = this.addNode(destination);\n sourceNode.addOutput(destinationNode.id);\n destinationNode.addInput(sourceNode.id);\n }\n\n removeEdge(source: NodeID, destination: NodeID): void {\n const sourceNode = this.nodes.get(source);\n const destinationNode = this.nodes.get(destination);\n if (sourceNode && destinationNode) {\n sourceNode.removeOutput(destination);\n destinationNode.removeInput(source);\n }\n }\n\n hasEdge(source: NodeID, destination: NodeID): boolean {\n const sourceNode = this.nodes.get(source);\n if (!sourceNode) {\n return false;\n }\n return !!sourceNode.outputs.find(id => id === destination);\n }\n\n isReachable(source: NodeID, destination: NodeID): boolean {\n return this.expandAllOutputs([source]).includes(destination);\n }\n\n rootNodes(): NodeID[] {\n return [...this.nodes.keys()].filter(id => !this.nodes.get(id)?.inputs.length);\n }\n\n expandOutputs(origin: NodeID[]): NodeID[] {\n const result: NodeID[] = [];\n origin.forEach(id => {\n const node = this.nodes.get(id);\n if (node) {\n node.outputs.forEach(child => {\n if (!origin.includes(child) && !result.includes(child)) {\n result.push(child);\n }\n });\n }\n });\n return result;\n }\n\n expandInputs(origin: NodeID[]): NodeID[] {\n const result: NodeID[] = [];\n origin.forEach(id => {\n const node = this.nodes.get(id);\n if (node) {\n node.inputs.forEach(child => {\n if (!origin.includes(child) && !result.includes(child)) {\n result.push(child);\n }\n });\n }\n });\n return result;\n }\n\n expandAllOutputs(origin: NodeID[]): NodeID[] {\n const result: NodeID[] = this.expandOutputs(origin);\n if (result.length === 0) {\n return [];\n }\n\n const marked = new Map<NodeID, boolean>();\n origin.forEach(id => marked.set(id, true));\n let position = 0;\n while (position < result.length) {\n const node = this.nodes.get(result[position]);\n if (node && !marked.get(node.id)) {\n marked.set(node.id, true);\n node.outputs.forEach(child => {\n if (!marked.get(child) && !result.find(id => id === child)) {\n result.push(child);\n }\n });\n }\n position += 1;\n }\n return result;\n }\n\n expandAllInputs(origin: NodeID[]): NodeID[] {\n const result: NodeID[] = this.expandInputs(origin);\n if (result.length === 0) {\n return [];\n }\n\n const marked = new Map<NodeID, boolean>();\n origin.forEach(id => marked.set(id, true));\n let position = 0;\n while (position < result.length) {\n const node = this.nodes.get(result[position]);\n if (node && !marked.get(node.id)) {\n marked.set(node.id, true);\n node.inputs.forEach(child => {\n if (!marked.get(child) && !result.find(id => id === child)) {\n result.push(child);\n }\n });\n }\n position += 1;\n }\n return result;\n }\n\n maximizePart(origin: NodeID[]): NodeID[] {\n const outputs: NodeID[] = this.expandAllOutputs(origin);\n const result = [...origin];\n this.topologicalOrder()\n .filter(id => outputs.includes(id))\n .forEach(id => {\n const node = this.nodes.get(id);\n if (node?.inputs.every(parent => result.includes(parent))) {\n result.push(id);\n }\n });\n return result;\n }\n\n topologicalOrder(): NodeID[] {\n const result: NodeID[] = [];\n const marked = new Set<NodeID>();\n const nodeStack: NodeID[] = [];\n this.nodes.forEach(node => {\n if (marked.has(node.id)) {\n return;\n }\n nodeStack.push(node.id);\n while (nodeStack.length > 0) {\n const item = nodeStack[nodeStack.length - 1];\n if (marked.has(item)) {\n if (!result.find(id => id === item)) {\n result.push(item);\n }\n nodeStack.pop();\n } else {\n marked.add(item);\n const itemNode = this.nodes.get(item);\n if (itemNode && itemNode.outputs.length > 0) {\n itemNode.outputs.forEach(child => {\n if (!marked.has(child)) {\n nodeStack.push(child);\n }\n });\n }\n }\n }\n });\n return result.reverse();\n }\n\n /**\n * Stably reorders the given node ids so that, for this DAG, no node appears before a transitive\n * successor (edges: source → dependent; {@link GraphNode.outputs} lists dependents).\n */\n sortStable(target: NodeID[]): NodeID[] {\n if (target.length <= 1) {\n return [...target];\n }\n\n const reachable = this.buildTransitiveClosureForSort();\n const testSet = new Set<NodeID>();\n const result: NodeID[] = [];\n\n for (const nodeId of [...target].reverse()) {\n const nodeReachable = reachable.get(nodeId) ?? new Set<NodeID>();\n const needMove = testSet.has(nodeId);\n for (const childId of nodeReachable) {\n testSet.add(childId);\n }\n\n if (!needMove) {\n result.push(nodeId);\n continue;\n }\n\n let inserted = false;\n for (let index = 0; index < result.length; index++) {\n const parent = result[index];\n const parentReachable = reachable.get(parent) ?? new Set<NodeID>();\n if (nodeReachable.has(parent)) {\n if (parentReachable.has(nodeId)) {\n result.push(nodeId);\n } else {\n result.splice(index, 0, nodeId);\n }\n inserted = true;\n break;\n }\n }\n if (!inserted) {\n result.push(nodeId);\n }\n }\n\n result.reverse();\n return result;\n }\n\n private buildTransitiveClosureForSort(): Map<NodeID, Set<NodeID>> {\n const closure = new Map<NodeID, Set<NodeID>>();\n for (const node of this.nodes.values()) {\n closure.set(node.id, new Set(node.outputs));\n }\n\n const order = this.topologicalOrder();\n for (const nodeId of [...order].reverse()) {\n const node = this.at(nodeId);\n if (!node) {\n continue;\n }\n const nodeClosure = closure.get(nodeId) ?? new Set<NodeID>();\n for (const parentId of node.inputs) {\n const parentClosure = closure.get(parentId) ?? new Set<NodeID>();\n for (const childId of nodeClosure) {\n parentClosure.add(childId);\n }\n closure.set(parentId, parentClosure);\n }\n }\n\n return closure;\n }\n\n transitiveReduction() {\n const order = this.topologicalOrder();\n const marked = new Map<NodeID, boolean>();\n order.forEach(nodeID => {\n if (marked.get(nodeID)) {\n return;\n }\n const stack: { id: NodeID; parents: NodeID[] }[] = [];\n stack.push({ id: nodeID, parents: [] });\n while (stack.length > 0) {\n const item = stack.splice(0, 1)[0];\n const node = this.nodes.get(item.id);\n if (node) {\n node.outputs.forEach(child => {\n item.parents.forEach(parent => this.removeEdge(parent, child));\n stack.push({ id: child, parents: [item.id, ...item.parents] });\n });\n }\n marked.set(item.id, true);\n }\n });\n }\n\n /**\n * Finds a cycle in the graph.\n *\n * @returns {NodeID[] | null} The cycle if found, otherwise `null`.\n * Uses non-recursive DFS.\n */\n findCycle(): NodeID[] | null {\n const visited = new Set<NodeID>();\n const nodeStack = new Set<NodeID>();\n const parents = new Map<NodeID, NodeID>();\n\n for (const nodeId of this.nodes.keys()) {\n if (visited.has(nodeId)) {\n continue;\n }\n\n const callStack: { nodeId: NodeID; parentId: NodeID | null }[] = [];\n callStack.push({ nodeId: nodeId, parentId: null });\n while (callStack.length > 0) {\n const { nodeId, parentId } = callStack[callStack.length - 1];\n if (visited.has(nodeId)) {\n nodeStack.delete(nodeId);\n callStack.pop();\n continue;\n }\n visited.add(nodeId);\n nodeStack.add(nodeId);\n if (parentId !== null) {\n parents.set(nodeId, parentId);\n }\n\n const currentNode = this.nodes.get(nodeId)!;\n for (const child of currentNode.outputs) {\n if (!visited.has(child)) {\n callStack.push({ nodeId: child, parentId: nodeId });\n continue;\n }\n if (!nodeStack.has(child)) {\n continue;\n }\n const cycle: NodeID[] = [];\n let current = nodeId;\n cycle.push(child);\n while (current !== child) {\n cycle.push(current);\n current = parents.get(current)!;\n }\n cycle.push(child);\n cycle.reverse();\n return cycle;\n }\n }\n }\n return null;\n }\n}\n"],"mappings":";AAKO,IAAM,YAAN,MAAM,WAAkB;AAAA;AAAA,EAE7B;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAEA,YAAY,IAAY;AACtB,SAAK,KAAK;AACV,SAAK,UAAU,CAAC;AAChB,SAAK,SAAS,CAAC;AAAA,EACjB;AAAA,EAEA,QAA2B;AACzB,UAAM,SAAS,IAAI,WAAU,KAAK,EAAE;AACpC,WAAO,UAAU,CAAC,GAAG,KAAK,OAAO;AACjC,WAAO,SAAS,CAAC,GAAG,KAAK,MAAM;AAC/B,WAAO;AAAA,EACT;AAAA,EAEA,UAAU,MAAoB;AAC5B,SAAK,QAAQ,KAAK,IAAI;AAAA,EACxB;AAAA,EAEA,SAAS,MAAoB;AAC3B,SAAK,OAAO,KAAK,IAAI;AAAA,EACvB;AAAA,EAEA,YAAY,QAA+B;AACzC,UAAM,QAAQ,KAAK,OAAO,UAAU,UAAQ,SAAS,MAAM;AAC3D,WAAO,QAAQ,KAAK,KAAK,OAAO,OAAO,OAAO,CAAC,EAAE,CAAC,IAAI;AAAA,EACxD;AAAA,EAEA,aAAa,QAA+B;AAC1C,UAAM,QAAQ,KAAK,QAAQ,UAAU,UAAQ,SAAS,MAAM;AAC5D,WAAO,QAAQ,KAAK,KAAK,QAAQ,OAAO,OAAO,CAAC,EAAE,CAAC,IAAI;AAAA,EACzD;AACF;AAOO,IAAM,QAAN,MAAM,OAAuB;AAAA;AAAA,EAElC,QAAQ,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KAAK,EAAE,QAAQ,OAAO,UAAUA,QAAO,CAAC;AAClD;AAAA,UACF;AACA,cAAI,CAAC,UAAU,IAAI,KAAK,GAAG;AACzB;AAAA,UACF;AACA,gBAAM,QAAkB,CAAC;AACzB,cAAI,UAAUA;AACd,gBAAM,KAAK,KAAK;AAChB,iBAAO,YAAY,OAAO;AACxB,kBAAM,KAAK,OAAO;AAClB,sBAAU,QAAQ,IAAI,OAAO;AAAA,UAC/B;AACA,gBAAM,KAAK,KAAK;AAChB,gBAAM,QAAQ;AACd,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;","names":["nodeId"]}
|
|
1
|
+
{"version":3,"file":"graph.js","names":[],"sources":["../../src/graph/graph.ts"],"sourcesContent":["/**\n * Module: Custom graph data structure.\n */\n\n/** Represents single node of a {@link Graph}, as implemented by storing outgoing and incoming connections. */\nexport class GraphNode<NodeID> {\n /** Unique identifier of the node. */\n id: NodeID;\n /** List of outgoing nodes. */\n outputs: NodeID[];\n /** List of incoming nodes. */\n inputs: NodeID[];\n\n constructor(id: NodeID) {\n this.id = id;\n this.outputs = [];\n this.inputs = [];\n }\n\n clone(): GraphNode<NodeID> {\n const result = new GraphNode(this.id);\n result.outputs = [...this.outputs];\n result.inputs = [...this.inputs];\n return result;\n }\n\n addOutput(node: NodeID): void {\n this.outputs.push(node);\n }\n\n addInput(node: NodeID): void {\n this.inputs.push(node);\n }\n\n removeInput(target: NodeID): NodeID | null {\n const index = this.inputs.findIndex(node => node === target);\n return index > -1 ? this.inputs.splice(index, 1)[0] : null;\n }\n\n removeOutput(target: NodeID): NodeID | null {\n const index = this.outputs.findIndex(node => node === target);\n return index > -1 ? this.outputs.splice(index, 1)[0] : null;\n }\n}\n\n/**\n * Represents a Graph.\n *\n * This class is optimized for TermGraph use case and not supposed to be used as generic graph implementation.\n */\nexport class Graph<NodeID = number> {\n /** Map of nodes. */\n nodes = new Map<NodeID, GraphNode<NodeID>>();\n\n constructor(arr?: NodeID[][]) {\n if (!arr) {\n return;\n }\n arr.forEach(edge => {\n if (edge.length === 1) {\n this.addNode(edge[0]);\n } else {\n this.addEdge(edge[0], edge[1]);\n }\n });\n }\n\n clone(): Graph<NodeID> {\n const result = new Graph<NodeID>();\n this.nodes.forEach(node => result.nodes.set(node.id, node.clone()));\n return result;\n }\n\n at(target: NodeID): GraphNode<NodeID> | undefined {\n return this.nodes.get(target);\n }\n\n addNode(target: NodeID): GraphNode<NodeID> {\n let node = this.nodes.get(target);\n if (!node) {\n node = new GraphNode(target);\n this.nodes.set(target, node);\n }\n return node;\n }\n\n hasNode(target: NodeID): boolean {\n return !!this.nodes.get(target);\n }\n\n removeNode(target: NodeID): void {\n this.nodes.forEach(node => {\n node.removeInput(target);\n node.removeOutput(target);\n });\n this.nodes.delete(target);\n }\n\n foldNode(target: NodeID): void {\n const nodeToRemove = this.nodes.get(target);\n if (!nodeToRemove) {\n return;\n }\n nodeToRemove.inputs.forEach(input => {\n nodeToRemove.outputs.forEach(output => {\n this.addEdge(input, output);\n });\n });\n this.removeNode(target);\n }\n\n removeIsolated(): GraphNode<NodeID>[] {\n const result: GraphNode<NodeID>[] = [];\n this.nodes.forEach(node => {\n if (node.outputs.length === 0 && node.inputs.length === 0) {\n result.push(node);\n this.nodes.delete(node.id);\n }\n });\n return result;\n }\n\n addEdge(source: NodeID, destination: NodeID): void {\n if (this.hasEdge(source, destination)) {\n return;\n }\n const sourceNode = this.addNode(source);\n const destinationNode = this.addNode(destination);\n sourceNode.addOutput(destinationNode.id);\n destinationNode.addInput(sourceNode.id);\n }\n\n removeEdge(source: NodeID, destination: NodeID): void {\n const sourceNode = this.nodes.get(source);\n const destinationNode = this.nodes.get(destination);\n if (sourceNode && destinationNode) {\n sourceNode.removeOutput(destination);\n destinationNode.removeInput(source);\n }\n }\n\n hasEdge(source: NodeID, destination: NodeID): boolean {\n const sourceNode = this.nodes.get(source);\n if (!sourceNode) {\n return false;\n }\n return !!sourceNode.outputs.find(id => id === destination);\n }\n\n isReachable(source: NodeID, destination: NodeID): boolean {\n return this.expandAllOutputs([source]).includes(destination);\n }\n\n rootNodes(): NodeID[] {\n return [...this.nodes.keys()].filter(id => !this.nodes.get(id)?.inputs.length);\n }\n\n expandOutputs(origin: NodeID[]): NodeID[] {\n const result: NodeID[] = [];\n origin.forEach(id => {\n const node = this.nodes.get(id);\n if (node) {\n node.outputs.forEach(child => {\n if (!origin.includes(child) && !result.includes(child)) {\n result.push(child);\n }\n });\n }\n });\n return result;\n }\n\n expandInputs(origin: NodeID[]): NodeID[] {\n const result: NodeID[] = [];\n origin.forEach(id => {\n const node = this.nodes.get(id);\n if (node) {\n node.inputs.forEach(child => {\n if (!origin.includes(child) && !result.includes(child)) {\n result.push(child);\n }\n });\n }\n });\n return result;\n }\n\n expandAllOutputs(origin: NodeID[]): NodeID[] {\n const result: NodeID[] = this.expandOutputs(origin);\n if (result.length === 0) {\n return [];\n }\n\n const marked = new Map<NodeID, boolean>();\n origin.forEach(id => marked.set(id, true));\n let position = 0;\n while (position < result.length) {\n const node = this.nodes.get(result[position]);\n if (node && !marked.get(node.id)) {\n marked.set(node.id, true);\n node.outputs.forEach(child => {\n if (!marked.get(child) && !result.find(id => id === child)) {\n result.push(child);\n }\n });\n }\n position += 1;\n }\n return result;\n }\n\n expandAllInputs(origin: NodeID[]): NodeID[] {\n const result: NodeID[] = this.expandInputs(origin);\n if (result.length === 0) {\n return [];\n }\n\n const marked = new Map<NodeID, boolean>();\n origin.forEach(id => marked.set(id, true));\n let position = 0;\n while (position < result.length) {\n const node = this.nodes.get(result[position]);\n if (node && !marked.get(node.id)) {\n marked.set(node.id, true);\n node.inputs.forEach(child => {\n if (!marked.get(child) && !result.find(id => id === child)) {\n result.push(child);\n }\n });\n }\n position += 1;\n }\n return result;\n }\n\n maximizePart(origin: NodeID[]): NodeID[] {\n const outputs: NodeID[] = this.expandAllOutputs(origin);\n const result = [...origin];\n this.topologicalOrder()\n .filter(id => outputs.includes(id))\n .forEach(id => {\n const node = this.nodes.get(id);\n if (node?.inputs.every(parent => result.includes(parent))) {\n result.push(id);\n }\n });\n return result;\n }\n\n topologicalOrder(): NodeID[] {\n const result: NodeID[] = [];\n const marked = new Set<NodeID>();\n const nodeStack: NodeID[] = [];\n this.nodes.forEach(node => {\n if (marked.has(node.id)) {\n return;\n }\n nodeStack.push(node.id);\n while (nodeStack.length > 0) {\n const item = nodeStack[nodeStack.length - 1];\n if (marked.has(item)) {\n if (!result.find(id => id === item)) {\n result.push(item);\n }\n nodeStack.pop();\n } else {\n marked.add(item);\n const itemNode = this.nodes.get(item);\n if (itemNode && itemNode.outputs.length > 0) {\n itemNode.outputs.forEach(child => {\n if (!marked.has(child)) {\n nodeStack.push(child);\n }\n });\n }\n }\n }\n });\n return result.reverse();\n }\n\n /**\n * Stably reorders the given node ids so that, for this DAG, no node appears before a transitive\n * successor (edges: source → dependent; {@link GraphNode.outputs} lists dependents).\n */\n sortStable(target: NodeID[]): NodeID[] {\n if (target.length <= 1) {\n return [...target];\n }\n\n const reachable = this.buildTransitiveClosureForSort();\n const testSet = new Set<NodeID>();\n const result: NodeID[] = [];\n\n for (const nodeId of [...target].reverse()) {\n const nodeReachable = reachable.get(nodeId) ?? new Set<NodeID>();\n const needMove = testSet.has(nodeId);\n for (const childId of nodeReachable) {\n testSet.add(childId);\n }\n\n if (!needMove) {\n result.push(nodeId);\n continue;\n }\n\n let inserted = false;\n for (let index = 0; index < result.length; index++) {\n const parent = result[index];\n const parentReachable = reachable.get(parent) ?? new Set<NodeID>();\n if (nodeReachable.has(parent)) {\n if (parentReachable.has(nodeId)) {\n result.push(nodeId);\n } else {\n result.splice(index, 0, nodeId);\n }\n inserted = true;\n break;\n }\n }\n if (!inserted) {\n result.push(nodeId);\n }\n }\n\n result.reverse();\n return result;\n }\n\n private buildTransitiveClosureForSort(): Map<NodeID, Set<NodeID>> {\n const closure = new Map<NodeID, Set<NodeID>>();\n for (const node of this.nodes.values()) {\n closure.set(node.id, new Set(node.outputs));\n }\n\n const order = this.topologicalOrder();\n for (const nodeId of [...order].reverse()) {\n const node = this.at(nodeId);\n if (!node) {\n continue;\n }\n const nodeClosure = closure.get(nodeId) ?? new Set<NodeID>();\n for (const parentId of node.inputs) {\n const parentClosure = closure.get(parentId) ?? new Set<NodeID>();\n for (const childId of nodeClosure) {\n parentClosure.add(childId);\n }\n closure.set(parentId, parentClosure);\n }\n }\n\n return closure;\n }\n\n transitiveReduction() {\n const order = this.topologicalOrder();\n const marked = new Map<NodeID, boolean>();\n order.forEach(nodeID => {\n if (marked.get(nodeID)) {\n return;\n }\n const stack: { id: NodeID; parents: NodeID[] }[] = [];\n stack.push({ id: nodeID, parents: [] });\n while (stack.length > 0) {\n const item = stack.splice(0, 1)[0];\n const node = this.nodes.get(item.id);\n if (node) {\n node.outputs.forEach(child => {\n item.parents.forEach(parent => this.removeEdge(parent, child));\n stack.push({ id: child, parents: [item.id, ...item.parents] });\n });\n }\n marked.set(item.id, true);\n }\n });\n }\n\n /**\n * Finds a cycle in the graph.\n *\n * @returns {NodeID[] | null} The cycle if found, otherwise `null`.\n * Uses non-recursive DFS.\n */\n findCycle(): NodeID[] | null {\n const visited = new Set<NodeID>();\n const nodeStack = new Set<NodeID>();\n const parents = new Map<NodeID, NodeID>();\n\n for (const nodeId of this.nodes.keys()) {\n if (visited.has(nodeId)) {\n continue;\n }\n\n const callStack: { nodeId: NodeID; parentId: NodeID | null }[] = [];\n callStack.push({ nodeId: nodeId, parentId: null });\n while (callStack.length > 0) {\n const { nodeId, parentId } = callStack[callStack.length - 1];\n if (visited.has(nodeId)) {\n nodeStack.delete(nodeId);\n callStack.pop();\n continue;\n }\n visited.add(nodeId);\n nodeStack.add(nodeId);\n if (parentId !== null) {\n parents.set(nodeId, parentId);\n }\n\n const currentNode = this.nodes.get(nodeId)!;\n for (const child of currentNode.outputs) {\n if (!visited.has(child)) {\n callStack.push({ nodeId: child, parentId: nodeId });\n continue;\n }\n if (!nodeStack.has(child)) {\n continue;\n }\n const cycle: NodeID[] = [];\n let current = nodeId;\n cycle.push(child);\n while (current !== child) {\n cycle.push(current);\n current = parents.get(current)!;\n }\n cycle.push(child);\n cycle.reverse();\n return cycle;\n }\n }\n }\n return null;\n }\n}\n"],"mappings":";;;;;AAKA,IAAa,YAAb,MAAa,UAAkB;;CAE7B;;CAEA;;CAEA;CAEA,YAAY,IAAY;EACtB,KAAK,KAAK;EACV,KAAK,UAAU,CAAC;EAChB,KAAK,SAAS,CAAC;CACjB;CAEA,QAA2B;EACzB,MAAM,SAAS,IAAI,UAAU,KAAK,EAAE;EACpC,OAAO,UAAU,CAAC,GAAG,KAAK,OAAO;EACjC,OAAO,SAAS,CAAC,GAAG,KAAK,MAAM;EAC/B,OAAO;CACT;CAEA,UAAU,MAAoB;EAC5B,KAAK,QAAQ,KAAK,IAAI;CACxB;CAEA,SAAS,MAAoB;EAC3B,KAAK,OAAO,KAAK,IAAI;CACvB;CAEA,YAAY,QAA+B;EACzC,MAAM,QAAQ,KAAK,OAAO,WAAU,SAAQ,SAAS,MAAM;EAC3D,OAAO,QAAQ,KAAK,KAAK,OAAO,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK;CACxD;CAEA,aAAa,QAA+B;EAC1C,MAAM,QAAQ,KAAK,QAAQ,WAAU,SAAQ,SAAS,MAAM;EAC5D,OAAO,QAAQ,KAAK,KAAK,QAAQ,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK;CACzD;AACF;;;;;;AAOA,IAAa,QAAb,MAAa,MAAuB;;CAElC,wBAAQ,IAAI,IAA+B;CAE3C,YAAY,KAAkB;EAC5B,IAAI,CAAC,KACH;EAEF,IAAI,SAAQ,SAAQ;GAClB,IAAI,KAAK,WAAW,GAClB,KAAK,QAAQ,KAAK,EAAE;QAEpB,KAAK,QAAQ,KAAK,IAAI,KAAK,EAAE;EAEjC,CAAC;CACH;CAEA,QAAuB;EACrB,MAAM,SAAS,IAAI,MAAc;EACjC,KAAK,MAAM,SAAQ,SAAQ,OA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ACzB,IAAI,UAAU;KACd,MAAM,KAAK,KAAK;KAChB,OAAO,YAAY,OAAO;MACxB,MAAM,KAAK,OAAO;MAClB,UAAU,QAAQ,IAAI,OAAO;KAC/B;KACA,MAAM,KAAK,KAAK;KAChB,MAAM,QAAQ;KACd,OAAO;IACT;GACF;EACF;EACA,OAAO;CACT;AACF"}
|
package/dist/graph/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { t as Graph } from "../graph-DR8rL2o3.js";
|
|
2
|
+
export { Graph };
|
package/dist/graph/index.js
CHANGED
|
@@ -1,384 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/** Unique identifier of the node. */
|
|
4
|
-
id;
|
|
5
|
-
/** List of outgoing nodes. */
|
|
6
|
-
outputs;
|
|
7
|
-
/** List of incoming nodes. */
|
|
8
|
-
inputs;
|
|
9
|
-
constructor(id) {
|
|
10
|
-
this.id = id;
|
|
11
|
-
this.outputs = [];
|
|
12
|
-
this.inputs = [];
|
|
13
|
-
}
|
|
14
|
-
clone() {
|
|
15
|
-
const result = new _GraphNode(this.id);
|
|
16
|
-
result.outputs = [...this.outputs];
|
|
17
|
-
result.inputs = [...this.inputs];
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
addOutput(node) {
|
|
21
|
-
this.outputs.push(node);
|
|
22
|
-
}
|
|
23
|
-
addInput(node) {
|
|
24
|
-
this.inputs.push(node);
|
|
25
|
-
}
|
|
26
|
-
removeInput(target) {
|
|
27
|
-
const index = this.inputs.findIndex((node) => node === target);
|
|
28
|
-
return index > -1 ? this.inputs.splice(index, 1)[0] : null;
|
|
29
|
-
}
|
|
30
|
-
removeOutput(target) {
|
|
31
|
-
const index = this.outputs.findIndex((node) => node === target);
|
|
32
|
-
return index > -1 ? this.outputs.splice(index, 1)[0] : null;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
var Graph = class _Graph {
|
|
36
|
-
/** Map of nodes. */
|
|
37
|
-
nodes = /* @__PURE__ */ new Map();
|
|
38
|
-
constructor(arr) {
|
|
39
|
-
if (!arr) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
arr.forEach((edge) => {
|
|
43
|
-
if (edge.length === 1) {
|
|
44
|
-
this.addNode(edge[0]);
|
|
45
|
-
} else {
|
|
46
|
-
this.addEdge(edge[0], edge[1]);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
clone() {
|
|
51
|
-
const result = new _Graph();
|
|
52
|
-
this.nodes.forEach((node) => result.nodes.set(node.id, node.clone()));
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
at(target) {
|
|
56
|
-
return this.nodes.get(target);
|
|
57
|
-
}
|
|
58
|
-
addNode(target) {
|
|
59
|
-
let node = this.nodes.get(target);
|
|
60
|
-
if (!node) {
|
|
61
|
-
node = new GraphNode(target);
|
|
62
|
-
this.nodes.set(target, node);
|
|
63
|
-
}
|
|
64
|
-
return node;
|
|
65
|
-
}
|
|
66
|
-
hasNode(target) {
|
|
67
|
-
return !!this.nodes.get(target);
|
|
68
|
-
}
|
|
69
|
-
removeNode(target) {
|
|
70
|
-
this.nodes.forEach((node) => {
|
|
71
|
-
node.removeInput(target);
|
|
72
|
-
node.removeOutput(target);
|
|
73
|
-
});
|
|
74
|
-
this.nodes.delete(target);
|
|
75
|
-
}
|
|
76
|
-
foldNode(target) {
|
|
77
|
-
const nodeToRemove = this.nodes.get(target);
|
|
78
|
-
if (!nodeToRemove) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
nodeToRemove.inputs.forEach((input) => {
|
|
82
|
-
nodeToRemove.outputs.forEach((output) => {
|
|
83
|
-
this.addEdge(input, output);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
this.removeNode(target);
|
|
87
|
-
}
|
|
88
|
-
removeIsolated() {
|
|
89
|
-
const result = [];
|
|
90
|
-
this.nodes.forEach((node) => {
|
|
91
|
-
if (node.outputs.length === 0 && node.inputs.length === 0) {
|
|
92
|
-
result.push(node);
|
|
93
|
-
this.nodes.delete(node.id);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
return result;
|
|
97
|
-
}
|
|
98
|
-
addEdge(source, destination) {
|
|
99
|
-
if (this.hasEdge(source, destination)) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const sourceNode = this.addNode(source);
|
|
103
|
-
const destinationNode = this.addNode(destination);
|
|
104
|
-
sourceNode.addOutput(destinationNode.id);
|
|
105
|
-
destinationNode.addInput(sourceNode.id);
|
|
106
|
-
}
|
|
107
|
-
removeEdge(source, destination) {
|
|
108
|
-
const sourceNode = this.nodes.get(source);
|
|
109
|
-
const destinationNode = this.nodes.get(destination);
|
|
110
|
-
if (sourceNode && destinationNode) {
|
|
111
|
-
sourceNode.removeOutput(destination);
|
|
112
|
-
destinationNode.removeInput(source);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
hasEdge(source, destination) {
|
|
116
|
-
const sourceNode = this.nodes.get(source);
|
|
117
|
-
if (!sourceNode) {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
return !!sourceNode.outputs.find((id) => id === destination);
|
|
121
|
-
}
|
|
122
|
-
isReachable(source, destination) {
|
|
123
|
-
return this.expandAllOutputs([source]).includes(destination);
|
|
124
|
-
}
|
|
125
|
-
rootNodes() {
|
|
126
|
-
return [...this.nodes.keys()].filter((id) => !this.nodes.get(id)?.inputs.length);
|
|
127
|
-
}
|
|
128
|
-
expandOutputs(origin) {
|
|
129
|
-
const result = [];
|
|
130
|
-
origin.forEach((id) => {
|
|
131
|
-
const node = this.nodes.get(id);
|
|
132
|
-
if (node) {
|
|
133
|
-
node.outputs.forEach((child) => {
|
|
134
|
-
if (!origin.includes(child) && !result.includes(child)) {
|
|
135
|
-
result.push(child);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
return result;
|
|
141
|
-
}
|
|
142
|
-
expandInputs(origin) {
|
|
143
|
-
const result = [];
|
|
144
|
-
origin.forEach((id) => {
|
|
145
|
-
const node = this.nodes.get(id);
|
|
146
|
-
if (node) {
|
|
147
|
-
node.inputs.forEach((child) => {
|
|
148
|
-
if (!origin.includes(child) && !result.includes(child)) {
|
|
149
|
-
result.push(child);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
return result;
|
|
155
|
-
}
|
|
156
|
-
expandAllOutputs(origin) {
|
|
157
|
-
const result = this.expandOutputs(origin);
|
|
158
|
-
if (result.length === 0) {
|
|
159
|
-
return [];
|
|
160
|
-
}
|
|
161
|
-
const marked = /* @__PURE__ */ new Map();
|
|
162
|
-
origin.forEach((id) => marked.set(id, true));
|
|
163
|
-
let position = 0;
|
|
164
|
-
while (position < result.length) {
|
|
165
|
-
const node = this.nodes.get(result[position]);
|
|
166
|
-
if (node && !marked.get(node.id)) {
|
|
167
|
-
marked.set(node.id, true);
|
|
168
|
-
node.outputs.forEach((child) => {
|
|
169
|
-
if (!marked.get(child) && !result.find((id) => id === child)) {
|
|
170
|
-
result.push(child);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
position += 1;
|
|
175
|
-
}
|
|
176
|
-
return result;
|
|
177
|
-
}
|
|
178
|
-
expandAllInputs(origin) {
|
|
179
|
-
const result = this.expandInputs(origin);
|
|
180
|
-
if (result.length === 0) {
|
|
181
|
-
return [];
|
|
182
|
-
}
|
|
183
|
-
const marked = /* @__PURE__ */ new Map();
|
|
184
|
-
origin.forEach((id) => marked.set(id, true));
|
|
185
|
-
let position = 0;
|
|
186
|
-
while (position < result.length) {
|
|
187
|
-
const node = this.nodes.get(result[position]);
|
|
188
|
-
if (node && !marked.get(node.id)) {
|
|
189
|
-
marked.set(node.id, true);
|
|
190
|
-
node.inputs.forEach((child) => {
|
|
191
|
-
if (!marked.get(child) && !result.find((id) => id === child)) {
|
|
192
|
-
result.push(child);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
position += 1;
|
|
197
|
-
}
|
|
198
|
-
return result;
|
|
199
|
-
}
|
|
200
|
-
maximizePart(origin) {
|
|
201
|
-
const outputs = this.expandAllOutputs(origin);
|
|
202
|
-
const result = [...origin];
|
|
203
|
-
this.topologicalOrder().filter((id) => outputs.includes(id)).forEach((id) => {
|
|
204
|
-
const node = this.nodes.get(id);
|
|
205
|
-
if (node?.inputs.every((parent) => result.includes(parent))) {
|
|
206
|
-
result.push(id);
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
return result;
|
|
210
|
-
}
|
|
211
|
-
topologicalOrder() {
|
|
212
|
-
const result = [];
|
|
213
|
-
const marked = /* @__PURE__ */ new Set();
|
|
214
|
-
const nodeStack = [];
|
|
215
|
-
this.nodes.forEach((node) => {
|
|
216
|
-
if (marked.has(node.id)) {
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
nodeStack.push(node.id);
|
|
220
|
-
while (nodeStack.length > 0) {
|
|
221
|
-
const item = nodeStack[nodeStack.length - 1];
|
|
222
|
-
if (marked.has(item)) {
|
|
223
|
-
if (!result.find((id) => id === item)) {
|
|
224
|
-
result.push(item);
|
|
225
|
-
}
|
|
226
|
-
nodeStack.pop();
|
|
227
|
-
} else {
|
|
228
|
-
marked.add(item);
|
|
229
|
-
const itemNode = this.nodes.get(item);
|
|
230
|
-
if (itemNode && itemNode.outputs.length > 0) {
|
|
231
|
-
itemNode.outputs.forEach((child) => {
|
|
232
|
-
if (!marked.has(child)) {
|
|
233
|
-
nodeStack.push(child);
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
return result.reverse();
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Stably reorders the given node ids so that, for this DAG, no node appears before a transitive
|
|
244
|
-
* successor (edges: source → dependent; {@link GraphNode.outputs} lists dependents).
|
|
245
|
-
*/
|
|
246
|
-
sortStable(target) {
|
|
247
|
-
if (target.length <= 1) {
|
|
248
|
-
return [...target];
|
|
249
|
-
}
|
|
250
|
-
const reachable = this.buildTransitiveClosureForSort();
|
|
251
|
-
const testSet = /* @__PURE__ */ new Set();
|
|
252
|
-
const result = [];
|
|
253
|
-
for (const nodeId of [...target].reverse()) {
|
|
254
|
-
const nodeReachable = reachable.get(nodeId) ?? /* @__PURE__ */ new Set();
|
|
255
|
-
const needMove = testSet.has(nodeId);
|
|
256
|
-
for (const childId of nodeReachable) {
|
|
257
|
-
testSet.add(childId);
|
|
258
|
-
}
|
|
259
|
-
if (!needMove) {
|
|
260
|
-
result.push(nodeId);
|
|
261
|
-
continue;
|
|
262
|
-
}
|
|
263
|
-
let inserted = false;
|
|
264
|
-
for (let index = 0; index < result.length; index++) {
|
|
265
|
-
const parent = result[index];
|
|
266
|
-
const parentReachable = reachable.get(parent) ?? /* @__PURE__ */ new Set();
|
|
267
|
-
if (nodeReachable.has(parent)) {
|
|
268
|
-
if (parentReachable.has(nodeId)) {
|
|
269
|
-
result.push(nodeId);
|
|
270
|
-
} else {
|
|
271
|
-
result.splice(index, 0, nodeId);
|
|
272
|
-
}
|
|
273
|
-
inserted = true;
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
if (!inserted) {
|
|
278
|
-
result.push(nodeId);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
result.reverse();
|
|
282
|
-
return result;
|
|
283
|
-
}
|
|
284
|
-
buildTransitiveClosureForSort() {
|
|
285
|
-
const closure = /* @__PURE__ */ new Map();
|
|
286
|
-
for (const node of this.nodes.values()) {
|
|
287
|
-
closure.set(node.id, new Set(node.outputs));
|
|
288
|
-
}
|
|
289
|
-
const order = this.topologicalOrder();
|
|
290
|
-
for (const nodeId of [...order].reverse()) {
|
|
291
|
-
const node = this.at(nodeId);
|
|
292
|
-
if (!node) {
|
|
293
|
-
continue;
|
|
294
|
-
}
|
|
295
|
-
const nodeClosure = closure.get(nodeId) ?? /* @__PURE__ */ new Set();
|
|
296
|
-
for (const parentId of node.inputs) {
|
|
297
|
-
const parentClosure = closure.get(parentId) ?? /* @__PURE__ */ new Set();
|
|
298
|
-
for (const childId of nodeClosure) {
|
|
299
|
-
parentClosure.add(childId);
|
|
300
|
-
}
|
|
301
|
-
closure.set(parentId, parentClosure);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return closure;
|
|
305
|
-
}
|
|
306
|
-
transitiveReduction() {
|
|
307
|
-
const order = this.topologicalOrder();
|
|
308
|
-
const marked = /* @__PURE__ */ new Map();
|
|
309
|
-
order.forEach((nodeID) => {
|
|
310
|
-
if (marked.get(nodeID)) {
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
const stack = [];
|
|
314
|
-
stack.push({ id: nodeID, parents: [] });
|
|
315
|
-
while (stack.length > 0) {
|
|
316
|
-
const item = stack.splice(0, 1)[0];
|
|
317
|
-
const node = this.nodes.get(item.id);
|
|
318
|
-
if (node) {
|
|
319
|
-
node.outputs.forEach((child) => {
|
|
320
|
-
item.parents.forEach((parent) => this.removeEdge(parent, child));
|
|
321
|
-
stack.push({ id: child, parents: [item.id, ...item.parents] });
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
marked.set(item.id, true);
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* Finds a cycle in the graph.
|
|
330
|
-
*
|
|
331
|
-
* @returns {NodeID[] | null} The cycle if found, otherwise `null`.
|
|
332
|
-
* Uses non-recursive DFS.
|
|
333
|
-
*/
|
|
334
|
-
findCycle() {
|
|
335
|
-
const visited = /* @__PURE__ */ new Set();
|
|
336
|
-
const nodeStack = /* @__PURE__ */ new Set();
|
|
337
|
-
const parents = /* @__PURE__ */ new Map();
|
|
338
|
-
for (const nodeId of this.nodes.keys()) {
|
|
339
|
-
if (visited.has(nodeId)) {
|
|
340
|
-
continue;
|
|
341
|
-
}
|
|
342
|
-
const callStack = [];
|
|
343
|
-
callStack.push({ nodeId, parentId: null });
|
|
344
|
-
while (callStack.length > 0) {
|
|
345
|
-
const { nodeId: nodeId2, parentId } = callStack[callStack.length - 1];
|
|
346
|
-
if (visited.has(nodeId2)) {
|
|
347
|
-
nodeStack.delete(nodeId2);
|
|
348
|
-
callStack.pop();
|
|
349
|
-
continue;
|
|
350
|
-
}
|
|
351
|
-
visited.add(nodeId2);
|
|
352
|
-
nodeStack.add(nodeId2);
|
|
353
|
-
if (parentId !== null) {
|
|
354
|
-
parents.set(nodeId2, parentId);
|
|
355
|
-
}
|
|
356
|
-
const currentNode = this.nodes.get(nodeId2);
|
|
357
|
-
for (const child of currentNode.outputs) {
|
|
358
|
-
if (!visited.has(child)) {
|
|
359
|
-
callStack.push({ nodeId: child, parentId: nodeId2 });
|
|
360
|
-
continue;
|
|
361
|
-
}
|
|
362
|
-
if (!nodeStack.has(child)) {
|
|
363
|
-
continue;
|
|
364
|
-
}
|
|
365
|
-
const cycle = [];
|
|
366
|
-
let current = nodeId2;
|
|
367
|
-
cycle.push(child);
|
|
368
|
-
while (current !== child) {
|
|
369
|
-
cycle.push(current);
|
|
370
|
-
current = parents.get(current);
|
|
371
|
-
}
|
|
372
|
-
cycle.push(child);
|
|
373
|
-
cycle.reverse();
|
|
374
|
-
return cycle;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
return null;
|
|
379
|
-
}
|
|
380
|
-
};
|
|
381
|
-
export {
|
|
382
|
-
Graph
|
|
383
|
-
};
|
|
384
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { Graph } from "./graph.js";
|
|
2
|
+
export { Graph };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//#region src/graph/graph.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Module: Custom graph data structure.
|
|
4
|
+
*/
|
|
5
|
+
/** Represents single node of a {@link Graph}, as implemented by storing outgoing and incoming connections. */
|
|
6
|
+
declare class GraphNode<NodeID> {
|
|
7
|
+
/** Unique identifier of the node. */
|
|
8
|
+
id: NodeID;
|
|
9
|
+
/** List of outgoing nodes. */
|
|
10
|
+
outputs: NodeID[];
|
|
11
|
+
/** List of incoming nodes. */
|
|
12
|
+
inputs: NodeID[];
|
|
13
|
+
constructor(id: NodeID);
|
|
14
|
+
clone(): GraphNode<NodeID>;
|
|
15
|
+
addOutput(node: NodeID): void;
|
|
16
|
+
addInput(node: NodeID): void;
|
|
17
|
+
removeInput(target: NodeID): NodeID | null;
|
|
18
|
+
removeOutput(target: NodeID): NodeID | null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Represents a Graph.
|
|
22
|
+
*
|
|
23
|
+
* This class is optimized for TermGraph use case and not supposed to be used as generic graph implementation.
|
|
24
|
+
*/
|
|
25
|
+
declare class Graph<NodeID = number> {
|
|
26
|
+
/** Map of nodes. */
|
|
27
|
+
nodes: Map<NodeID, GraphNode<NodeID>>;
|
|
28
|
+
constructor(arr?: NodeID[][]);
|
|
29
|
+
clone(): Graph<NodeID>;
|
|
30
|
+
at(target: NodeID): GraphNode<NodeID> | undefined;
|
|
31
|
+
addNode(target: NodeID): GraphNode<NodeID>;
|
|
32
|
+
hasNode(target: NodeID): boolean;
|
|
33
|
+
removeNode(target: NodeID): void;
|
|
34
|
+
foldNode(target: NodeID): void;
|
|
35
|
+
removeIsolated(): GraphNode<NodeID>[];
|
|
36
|
+
addEdge(source: NodeID, destination: NodeID): void;
|
|
37
|
+
removeEdge(source: NodeID, destination: NodeID): void;
|
|
38
|
+
hasEdge(source: NodeID, destination: NodeID): boolean;
|
|
39
|
+
isReachable(source: NodeID, destination: NodeID): boolean;
|
|
40
|
+
rootNodes(): NodeID[];
|
|
41
|
+
expandOutputs(origin: NodeID[]): NodeID[];
|
|
42
|
+
expandInputs(origin: NodeID[]): NodeID[];
|
|
43
|
+
expandAllOutputs(origin: NodeID[]): NodeID[];
|
|
44
|
+
expandAllInputs(origin: NodeID[]): NodeID[];
|
|
45
|
+
maximizePart(origin: NodeID[]): NodeID[];
|
|
46
|
+
topologicalOrder(): NodeID[];
|
|
47
|
+
/**
|
|
48
|
+
* Stably reorders the given node ids so that, for this DAG, no node appears before a transitive
|
|
49
|
+
* successor (edges: source → dependent; {@link GraphNode.outputs} lists dependents).
|
|
50
|
+
*/
|
|
51
|
+
sortStable(target: NodeID[]): NodeID[];
|
|
52
|
+
private buildTransitiveClosureForSort;
|
|
53
|
+
transitiveReduction(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Finds a cycle in the graph.
|
|
56
|
+
*
|
|
57
|
+
* @returns {NodeID[] | null} The cycle if found, otherwise `null`.
|
|
58
|
+
* Uses non-recursive DFS.
|
|
59
|
+
*/
|
|
60
|
+
findCycle(): NodeID[] | null;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { GraphNode as n, Graph as t };
|
|
64
|
+
//# sourceMappingURL=graph-DR8rL2o3.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/shared/hash.d.ts
|
|
2
|
+
/** 32-bit FNV-1a hash */
|
|
3
|
+
declare function applyHash_fnv1a(str: string): number;
|
|
4
|
+
/** Generates stub ID for text. */
|
|
5
|
+
declare function generateStub(text: string): string;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { generateStub as n, applyHash_fnv1a as t };
|
|
8
|
+
//# sourceMappingURL=hash-Y8I4c6Al.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
import '@lezer/lr';
|
|
1
|
+
import { EntityReference, Grammeme, ReferenceType, SyntacticReference, TermContext, WordForm, supportedGrammemes } from "./cctext/language.js";
|
|
2
|
+
import { t as Graph } from "./graph-DR8rL2o3.js";
|
|
3
|
+
import { FolderNode, FolderTree } from "./library/folder-tree.js";
|
|
4
|
+
import { a as LibraryItemType, i as LibraryItemReference, n as CurrentVersion, o as LocationHead, r as LibraryItem, s as VersionInfo, t as AccessPolicy } from "./library-CYun28Xz.js";
|
|
5
|
+
import { n as OssLayout, r as Position2D } from "./oss-layout-3glgAqfn.js";
|
|
6
|
+
import { Block, CstSubstituteInfo, NodeType, Operation, OperationInput, OperationSchema, OperationSchemaStats, OperationSynthesis, OperationType, OssItem, SubstitutionErrorDescription, SubstitutionErrorType } from "./library/oss.js";
|
|
7
|
+
import { r as printTree, t as CMSyntaxNode } from "./lezer-tree-iS7LpLBJ.js";
|
|
8
|
+
import { a as TOKEN_ERROR, c as flattenAst, d as printAst, f as visitAstDFS, i as FlatAstNode, l as getNodeIndices, n as AstNodeBase, o as buildTree, r as FlatAST, s as findByUid, t as AstNode, u as getNodeText } from "./ast-C8sIpKdL.js";
|
|
9
|
+
import { t as Branded } from "./branded-ZlzIcxzu.js";
|
|
10
|
+
import { n as generateStub, t as applyHash_fnv1a } from "./hash-Y8I4c6Al.js";
|
|
11
|
+
import { O as makeTypePath, b as Typification, d as EmptySetT, f as ExpressionType, g as TypeClass, m as LogicT, t as AnyTypificationT, v as TypeID, y as TypePath } from "./typification-Dk-fisgO.js";
|
|
12
|
+
import { i as RSErrorDescription, r as RSErrorCode } from "./error-E1LVq_3w.js";
|
|
13
|
+
import { i as readTypeAnnotation, r as readErrorAnnotation } from "./ast-annotations-BiMjkKvz.js";
|
|
14
|
+
import { c as Value, f as makeValuePath, u as ValuePath } from "./value-CTjX6825.js";
|
|
15
|
+
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "./calculator-C9W2jkSx.js";
|
|
16
|
+
import { d as printValue } from "./value-api-Bw-SgaYY.js";
|
|
17
|
+
import { t as parser } from "./parser-Bwd8LxJ1.js";
|
|
18
|
+
import { t as TokenID } from "./token-DeXAmzwr.js";
|
|
19
|
+
import { t as ValueClass } from "./value-class-CNI-lqXJ.js";
|
|
20
|
+
import { a as RSLangAnalyzer, n as AnalysisFast, r as AnalysisFull, t as AnalysisBase } from "./analyzer-DlSq3Y3r.js";
|
|
21
|
+
import { n as ArgumentsType } from "./arguments-extractor-1acwjQNc.js";
|
|
22
|
+
import { n as applyAsciiTypeSubstitutions, r as parseTypeText } from "./typification-parser-BBVx1RxP.js";
|
|
23
|
+
import { n as TypificationNodeData, t as TypificationGraph } from "./typification-graph-6HcZ-rKH.js";
|
|
24
|
+
import { ArgumentValue, Attribution, Constituenta, CstClass, CstStatus, CstType, RSForm, RSFormStats, Substitution, TypeInfo } from "./library/rsform.js";
|
|
25
|
+
import { BasicBinding, BasicsContext, DEFAULT_VALUE_TEXT, EvalStatus, RSModel, RSModelStats } from "./library/rsmodel.js";
|
|
26
|
+
import { RSEngine } from "./library/rsengine.js";
|
|
27
|
+
export { AccessPolicy, type AnalysisBase, type AnalysisFast, type AnalysisFull, AnyTypificationT, type ArgumentValue, type ArgumentsType, type AstNode, type AstNodeBase, type Attribution, type BasicBinding, type BasicsContext, type Block, type Branded, type CMSyntaxNode, type CalculatorEvaluateOptions, type CalculatorResult, type Constituenta, CstClass, CstStatus, type CstSubstituteInfo, CstType, type CurrentVersion, DEFAULT_VALUE_TEXT, EmptySetT, type EntityReference, EvalStatus, type ExpressionType, type FlatAST, type FlatAstNode, FolderNode, FolderTree, Grammeme, Graph, type LibraryItem, type LibraryItemReference, LibraryItemType, LocationHead, LogicT, NodeType, type Operation, type OperationInput, type OperationSchema, type OperationSchemaStats, type OperationSynthesis, OperationType, type OssItem, type OssLayout, type Position2D, RSCalculator, RSEngine, RSErrorCode, type RSErrorDescription, type RSForm, type RSFormStats, RSLangAnalyzer, type RSModel, type RSModelStats, ReferenceType, type Substitution, type SubstitutionErrorDescription, SubstitutionErrorType, type SyntacticReference, TOKEN_ERROR, type TermContext, TokenID, TypeClass, TypeID, type TypeInfo, type TypePath, type Typification, TypificationGraph, type TypificationNodeData, type Value, ValueClass, type ValuePath, type VersionInfo, type WordForm, applyAsciiTypeSubstitutions, applyHash_fnv1a, buildTree, findByUid, flattenAst, generateStub, getNodeIndices, getNodeText, makeTypePath, makeValuePath, parseTypeText, printAst, printTree, printValue, readErrorAnnotation, readTypeAnnotation, parser as rslangParser, supportedGrammemes, visitAstDFS };
|