flow-step-space-logic 0.1.0 → 0.1.2
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 +5 -4
- package/src/core.ts +911 -0
- package/src/filesystem.ts +58 -16
- package/src/index.ts +1 -783
package/src/filesystem.ts
CHANGED
|
@@ -11,6 +11,19 @@ import {
|
|
|
11
11
|
export interface FilesystemDefinitionStepRuntimeOptions {
|
|
12
12
|
/** Host policy lives in the runtime adapter, never in semantic Processor input. */
|
|
13
13
|
readonly rootDir: string;
|
|
14
|
+
readonly extensionCodecs?: DefinitionStepAssemblyRuntime['extensionCodecs'];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface FilesystemDefinitionStepProfileRuntime extends DefinitionStepAssemblyRuntime {
|
|
18
|
+
readonly profileSources: {
|
|
19
|
+
readTopLevelXnlSources(): readonly { readonly ref: string; readonly content: string }[];
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface AssembleDefinitionStepProfileDirectoryInput {}
|
|
24
|
+
|
|
25
|
+
export interface AssembleDefinitionStepProfileDirectoryConfig extends DefinitionStepProfileLoadOptions {
|
|
26
|
+
readonly profileRoot: string;
|
|
14
27
|
}
|
|
15
28
|
|
|
16
29
|
export function createFilesystemDefinitionStepRuntime(
|
|
@@ -46,30 +59,59 @@ export function createFilesystemDefinitionStepRuntime(
|
|
|
46
59
|
return new Uint8Array(fs.readFileSync(realFile));
|
|
47
60
|
},
|
|
48
61
|
}),
|
|
62
|
+
extensionCodecs: options.extensionCodecs ?? Object.freeze({ resolve: () => undefined }),
|
|
49
63
|
});
|
|
50
64
|
}
|
|
51
65
|
|
|
52
|
-
|
|
66
|
+
export function createFilesystemDefinitionStepProfileRuntime(
|
|
67
|
+
options: FilesystemDefinitionStepRuntimeOptions,
|
|
68
|
+
): FilesystemDefinitionStepProfileRuntime {
|
|
69
|
+
const absoluteRoot = path.resolve(options.rootDir);
|
|
70
|
+
const stepRuntime = createFilesystemDefinitionStepRuntime(options);
|
|
71
|
+
return Object.freeze({
|
|
72
|
+
...stepRuntime,
|
|
73
|
+
profileSources: Object.freeze({
|
|
74
|
+
readTopLevelXnlSources() {
|
|
75
|
+
return fs.readdirSync(absoluteRoot, { withFileTypes: true })
|
|
76
|
+
.filter((entry) => entry.isFile() && entry.name.endsWith('.xnl'))
|
|
77
|
+
.sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0)
|
|
78
|
+
.map((entry) => Object.freeze({
|
|
79
|
+
ref: entry.name,
|
|
80
|
+
content: fs.readFileSync(path.join(absoluteRoot, entry.name), 'utf8'),
|
|
81
|
+
}));
|
|
82
|
+
},
|
|
83
|
+
}),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Processor authority; the host root is closed inside the runtime adapter. */
|
|
53
88
|
export function assembleDefinitionStepProfileDirectory(
|
|
89
|
+
runtime: FilesystemDefinitionStepProfileRuntime,
|
|
90
|
+
_input: AssembleDefinitionStepProfileDirectoryInput,
|
|
91
|
+
config: AssembleDefinitionStepProfileDirectoryConfig,
|
|
92
|
+
) {
|
|
93
|
+
if (!runtime?.profileSources || typeof runtime.profileSources.readTopLevelXnlSources !== 'function') {
|
|
94
|
+
throw diagnostic('step-profile-runtime-invalid', 'runtime.profileSources.readTopLevelXnlSources is required');
|
|
95
|
+
}
|
|
96
|
+
const sources = runtime.profileSources.readTopLevelXnlSources();
|
|
97
|
+
return assembleDefinitionStepProfileSourcesWithRuntime(
|
|
98
|
+
{ sources: runtime.sources, extensionCodecs: runtime.extensionCodecs },
|
|
99
|
+
sources,
|
|
100
|
+
config.profileRoot,
|
|
101
|
+
config,
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** @deprecated Compatibility wrapper; new code must inject a filesystem runtime. */
|
|
106
|
+
export function assembleDefinitionStepProfileDirectoryFromRoot(
|
|
54
107
|
rootDir: string,
|
|
55
108
|
profileRoot: string,
|
|
56
109
|
options: DefinitionStepProfileLoadOptions = {},
|
|
57
110
|
) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
.sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0)
|
|
63
|
-
.map((entry) => ({
|
|
64
|
-
name: entry.name,
|
|
65
|
-
content: fs.readFileSync(path.join(absoluteRoot, entry.name), 'utf8'),
|
|
66
|
-
}))
|
|
67
|
-
: [];
|
|
68
|
-
return assembleDefinitionStepProfileSourcesWithRuntime(
|
|
69
|
-
createFilesystemDefinitionStepRuntime({ rootDir: absoluteRoot }),
|
|
70
|
-
sources,
|
|
71
|
-
profileRoot,
|
|
72
|
-
options,
|
|
111
|
+
return assembleDefinitionStepProfileDirectory(
|
|
112
|
+
createFilesystemDefinitionStepProfileRuntime({ rootDir }),
|
|
113
|
+
{},
|
|
114
|
+
{ ...options, profileRoot },
|
|
73
115
|
);
|
|
74
116
|
}
|
|
75
117
|
|