instant-ctrl-flow-logic 0.1.3 → 0.1.4
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/package.json +4 -4
- package/src/filesystem.ts +10 -2
- package/src/loader.ts +14 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instant-ctrl-flow-logic",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "InstantCtrlFlow 引擎:xnl bundle 加载 → 行为树编译 → 无状态单次执行",
|
|
6
6
|
"type": "module",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"depa-behavior-tree": "0.1.0",
|
|
15
|
-
"flow-step-space-contract": "0.1.
|
|
16
|
-
"flow-step-space-logic": "0.1.
|
|
17
|
-
"instant-ctrl-flow-contract": "0.1.
|
|
15
|
+
"flow-step-space-contract": "0.1.1",
|
|
16
|
+
"flow-step-space-logic": "0.1.1",
|
|
17
|
+
"instant-ctrl-flow-contract": "0.1.2",
|
|
18
18
|
"xnl-core": "^0.1.8"
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
package/src/filesystem.ts
CHANGED
|
@@ -3,13 +3,17 @@ import path from 'node:path';
|
|
|
3
3
|
import { pathToFileURL } from 'node:url';
|
|
4
4
|
import type { FlowCodeFunction, FlowCodeResolver, LoadFlowSourcesOptions } from 'instant-ctrl-flow-contract';
|
|
5
5
|
import { loadFlowBundleFromSources, type LoadResult } from './loader.js';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
assembleDefinitionStepProfileDirectory,
|
|
8
|
+
createFilesystemDefinitionStepProfileRuntime,
|
|
9
|
+
} from 'flow-step-space-logic/filesystem';
|
|
7
10
|
import { FlowLoadError, runInstantCtrlFlowSpec } from './engine.js';
|
|
8
11
|
import type { InstantCtrlFlowRunOptions } from 'instant-ctrl-flow-contract';
|
|
9
12
|
|
|
10
13
|
/** Filesystem convenience only; parsing and validation belong to the named-source loader. */
|
|
11
14
|
export function loadFlowBundle(dir: string, options: LoadFlowSourcesOptions = {}): LoadResult {
|
|
12
15
|
const absoluteDir = path.resolve(dir);
|
|
16
|
+
const stepRuntime = createFilesystemDefinitionStepProfileRuntime({ rootDir: absoluteDir });
|
|
13
17
|
const sources = fs.existsSync(absoluteDir)
|
|
14
18
|
? fs.readdirSync(absoluteDir, { withFileTypes: true })
|
|
15
19
|
.filter((entry) => entry.isFile() && entry.name.endsWith('.xnl'))
|
|
@@ -20,7 +24,11 @@ export function loadFlowBundle(dir: string, options: LoadFlowSourcesOptions = {}
|
|
|
20
24
|
}))
|
|
21
25
|
: [];
|
|
22
26
|
for (const profileRoot of ['InstantCtrlFlow', 'WorkCtrlFlow', 'BPCtrlFlow']) {
|
|
23
|
-
const assembled = assembleDefinitionStepProfileDirectory(
|
|
27
|
+
const assembled = assembleDefinitionStepProfileDirectory(
|
|
28
|
+
stepRuntime,
|
|
29
|
+
{},
|
|
30
|
+
{ ...(options.stepSpace ?? {}), profileRoot },
|
|
31
|
+
);
|
|
24
32
|
if (assembled.diagnostics.length > 0) {
|
|
25
33
|
return { diagnostics: assembled.diagnostics.map(({ code, message }) => ({ code, message })) };
|
|
26
34
|
}
|
package/src/loader.ts
CHANGED
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
* 完整 lint 由 tools/flow-dsl-check 承担;此处只做引擎必需的结构化与硬校验。
|
|
5
5
|
*/
|
|
6
6
|
import { parseXnl } from 'xnl-core';
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import {
|
|
8
|
+
assembleDefinitionStepProfile,
|
|
9
|
+
createDefinitionStepSourceRuntime,
|
|
10
|
+
} from 'flow-step-space-logic';
|
|
11
|
+
import type { DefinitionStepForest, DefinitionStepSourceCollection } from 'flow-step-space-contract';
|
|
9
12
|
import type {
|
|
10
13
|
FlowBundleSpec,
|
|
11
14
|
CtrlFlowContract,
|
|
@@ -171,8 +174,16 @@ function loadCtrlFlowSources(
|
|
|
171
174
|
|
|
172
175
|
let definitionStepForest: DefinitionStepForest | undefined;
|
|
173
176
|
let effectiveSources = sources;
|
|
177
|
+
const definitionSources: DefinitionStepSourceCollection = Array.isArray(sources)
|
|
178
|
+
? sources.map((source) => ({ ref: source.name, content: source.content }))
|
|
179
|
+
: Object.entries(sources).map(([ref, content]) => ({ ref, content }));
|
|
180
|
+
const stepRuntime = createDefinitionStepSourceRuntime(definitionSources);
|
|
174
181
|
for (const candidateRoot of profile ? [profile.rootTag] : FORMS) {
|
|
175
|
-
const assembled =
|
|
182
|
+
const assembled = assembleDefinitionStepProfile(
|
|
183
|
+
stepRuntime,
|
|
184
|
+
{ sources: definitionSources },
|
|
185
|
+
{ ...(options.stepSpace ?? {}), profileRoot: candidateRoot },
|
|
186
|
+
);
|
|
176
187
|
if (assembled.diagnostics.length > 0) {
|
|
177
188
|
return { diagnostics: assembled.diagnostics.map(({ code, message }) => ({ code, message })) };
|
|
178
189
|
}
|