@sdeverywhere/build 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +188 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +183 -22
- package/dist/index.d.ts +183 -22
- package/dist/index.js +192 -74
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -8,10 +8,14 @@ type LogLevel = 'error' | 'info' | 'verbose';
|
|
|
8
8
|
*/
|
|
9
9
|
type BuildMode = 'development' | 'production';
|
|
10
10
|
|
|
11
|
+
/** A variable name as used in the modeling tool. */
|
|
12
|
+
type VarName = string;
|
|
11
13
|
/**
|
|
12
14
|
* Describes a model input variable.
|
|
13
15
|
*/
|
|
14
16
|
interface InputSpec {
|
|
17
|
+
/** The variable name (as used in the modeling tool). */
|
|
18
|
+
varName: VarName;
|
|
15
19
|
/**
|
|
16
20
|
* The stable input identifier. It is recommended to set this to a value (for example, a
|
|
17
21
|
* numeric string like what `plugin-config` uses) that is separate from `varName` and is
|
|
@@ -21,33 +25,164 @@ interface InputSpec {
|
|
|
21
25
|
* note that this approach will be less resilient to renames.
|
|
22
26
|
*/
|
|
23
27
|
inputId?: string;
|
|
24
|
-
/** The variable name (as used in the modeling tool). */
|
|
25
|
-
varName: string;
|
|
26
28
|
/** The default value for the input. */
|
|
27
|
-
defaultValue
|
|
29
|
+
defaultValue?: number;
|
|
28
30
|
/** The minimum value for the input. */
|
|
29
|
-
minValue
|
|
31
|
+
minValue?: number;
|
|
30
32
|
/** The maximum value for the input. */
|
|
31
|
-
maxValue
|
|
33
|
+
maxValue?: number;
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
34
36
|
* Describes a model output variable.
|
|
35
37
|
*/
|
|
36
38
|
interface OutputSpec {
|
|
37
39
|
/** The variable name (as used in the modeling tool). */
|
|
38
|
-
varName:
|
|
40
|
+
varName: VarName;
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
41
43
|
* Describes a model (e.g., a Vensim mdl file) and the input/output variables
|
|
42
|
-
* that should be included in the model generated by
|
|
44
|
+
* that should be included in the model generated by SDEverywhere.
|
|
43
45
|
*/
|
|
44
46
|
interface ModelSpec {
|
|
45
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* The input variables for the model. This can either be a simple array of
|
|
49
|
+
* input variable names, or an array of `InputSpec` instances.
|
|
50
|
+
*
|
|
51
|
+
* The builder requires only variable names for the purposes of generating
|
|
52
|
+
* a model, but some plugins may require full `InputSpec` instances.
|
|
53
|
+
*/
|
|
54
|
+
inputs: VarName[] | InputSpec[];
|
|
55
|
+
/**
|
|
56
|
+
* The output variables for the model. This can either be a simple array of
|
|
57
|
+
* output variable names, or an array of `OutputSpec` instances.
|
|
58
|
+
*/
|
|
59
|
+
outputs: VarName[] | OutputSpec[];
|
|
60
|
+
/**
|
|
61
|
+
* The dat files that provide the data for exogenous data variables in the
|
|
62
|
+
* model.
|
|
63
|
+
*/
|
|
64
|
+
datFiles?: string[];
|
|
65
|
+
/**
|
|
66
|
+
* Whether to bundle a model listing with the generated model.
|
|
67
|
+
*
|
|
68
|
+
* If undefined, defaults to false.
|
|
69
|
+
*
|
|
70
|
+
* When this is true, a model listing will be bundled with the generated
|
|
71
|
+
* model to allow the `runtime` package to resolve variables that are
|
|
72
|
+
* referenced by name or identifier. This listing will increase the size
|
|
73
|
+
* of the generated model, so it is recommended to set this to true only
|
|
74
|
+
* if it is needed.
|
|
75
|
+
*/
|
|
76
|
+
bundleListing?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Whether to allow lookups to be overridden at runtime using `setLookup`.
|
|
79
|
+
*
|
|
80
|
+
* If undefined or false, the generated model will implement `setLookup`
|
|
81
|
+
* as a no-op, meaning that lookups cannot be overridden at runtime.
|
|
82
|
+
*
|
|
83
|
+
* If true, all lookups in the generated model will be available to be
|
|
84
|
+
* overridden.
|
|
85
|
+
*
|
|
86
|
+
* If an array is provided, only those variable names in the array will
|
|
87
|
+
* be available to be overridden.
|
|
88
|
+
*/
|
|
89
|
+
customLookups?: boolean | VarName[];
|
|
90
|
+
/**
|
|
91
|
+
* Whether to allow for capturing the data for arbitrary variables at
|
|
92
|
+
* runtime (including variables that are not configured in the `outputs`
|
|
93
|
+
* array).
|
|
94
|
+
*
|
|
95
|
+
* If undefined or false, the generated model will implement `storeOutput`
|
|
96
|
+
* as a no-op, meaning that the data for arbitrary variables cannot be
|
|
97
|
+
* captured at runtime.
|
|
98
|
+
*
|
|
99
|
+
* If true, all variables in the generated model will be available to be
|
|
100
|
+
* captured at runtime.
|
|
101
|
+
*
|
|
102
|
+
* If an array is provided, only those variable names in the array will
|
|
103
|
+
* be available to be captured at runtime.
|
|
104
|
+
*/
|
|
105
|
+
customOutputs?: boolean | VarName[];
|
|
106
|
+
/** Additional options included with the SDE `spec.json` file. */
|
|
107
|
+
options?: {
|
|
108
|
+
[key: string]: any;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Describes a model (e.g., a Vensim mdl file) and the input/output variables
|
|
113
|
+
* that should be included in the model generated by SDEverywhere. This is
|
|
114
|
+
* largely the same as the `ModelSpec` interface, except this one has been
|
|
115
|
+
* fully resolved (paths have been validated, input and output variables have
|
|
116
|
+
* been checked, etc). This is the spec object that will be passed to plugin
|
|
117
|
+
* functions.
|
|
118
|
+
*/
|
|
119
|
+
interface ResolvedModelSpec {
|
|
120
|
+
/**
|
|
121
|
+
* The input variable names for the model. This will be defined regardless
|
|
122
|
+
* of whether `ModelSpec.inputs` was defined as an array of variable names
|
|
123
|
+
* or an array of `InputSpec` instances. (The input variable names are
|
|
124
|
+
* derived from the `InputSpec` instances as needed.)
|
|
125
|
+
*/
|
|
126
|
+
inputVarNames: VarName[];
|
|
127
|
+
/**
|
|
128
|
+
* The input variable specs for the model.
|
|
129
|
+
*/
|
|
46
130
|
inputs: InputSpec[];
|
|
47
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* The output variable names for the model. This will be defined regardless
|
|
133
|
+
* of whether `ModelSpec.outputs` was defined as an array of variable names
|
|
134
|
+
* or an array of `OutputSpec` instances. (The output variable names are
|
|
135
|
+
* derived from the `OutputSpec` instances as needed.)
|
|
136
|
+
*/
|
|
137
|
+
outputVarNames: VarName[];
|
|
138
|
+
/**
|
|
139
|
+
* The output variable specs for the model.
|
|
140
|
+
*/
|
|
48
141
|
outputs: OutputSpec[];
|
|
49
|
-
/**
|
|
142
|
+
/**
|
|
143
|
+
* The dat files that provide the data for exogenous data variables in the
|
|
144
|
+
* model.
|
|
145
|
+
*/
|
|
50
146
|
datFiles: string[];
|
|
147
|
+
/**
|
|
148
|
+
* Whether to bundle a model listing with the generated model.
|
|
149
|
+
*
|
|
150
|
+
* When this is true, a model listing will be bundled with the generated
|
|
151
|
+
* model to allow the `runtime` package to resolve variables that are
|
|
152
|
+
* referenced by name or identifier. This listing will increase the size
|
|
153
|
+
* of the generated model, so it is recommended to set this to true only
|
|
154
|
+
* if it is needed.
|
|
155
|
+
*/
|
|
156
|
+
bundleListing: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Whether to allow lookups to be overridden at runtime using `setLookup`.
|
|
159
|
+
*
|
|
160
|
+
* If false, the generated model will contain a `setLookup` function that
|
|
161
|
+
* throws an error, meaning that lookups cannot be overridden at runtime.
|
|
162
|
+
*
|
|
163
|
+
* If true, all lookups in the generated model will be available to be
|
|
164
|
+
* overridden.
|
|
165
|
+
*
|
|
166
|
+
* If an array is provided, only those variable names in the array will
|
|
167
|
+
* be available to be overridden.
|
|
168
|
+
*/
|
|
169
|
+
customLookups: boolean | VarName[];
|
|
170
|
+
/**
|
|
171
|
+
* Whether to allow for capturing the data for arbitrary variables at
|
|
172
|
+
* runtime (including variables that are not configured in the `outputs`
|
|
173
|
+
* array).
|
|
174
|
+
*
|
|
175
|
+
* If false, the generated model will contain a `storeOutput` function
|
|
176
|
+
* that throws an error, meaning that the data for arbitrary variables
|
|
177
|
+
* cannot be captured at runtime.
|
|
178
|
+
*
|
|
179
|
+
* If true, all variables in the generated model will be available to be
|
|
180
|
+
* captured at runtime.
|
|
181
|
+
*
|
|
182
|
+
* If an array is provided, only those variable names in the array will
|
|
183
|
+
* be available to be captured at runtime.
|
|
184
|
+
*/
|
|
185
|
+
customOutputs: boolean | VarName[];
|
|
51
186
|
/** Additional options included with the SDE `spec.json` file. */
|
|
52
187
|
options?: {
|
|
53
188
|
[key: string]: any;
|
|
@@ -88,6 +223,17 @@ interface ResolvedConfig {
|
|
|
88
223
|
* can be paths to files or glob patterns (relative to the project directory).
|
|
89
224
|
*/
|
|
90
225
|
watchPaths: string[];
|
|
226
|
+
/**
|
|
227
|
+
* The code format to generate. If 'js', the model will be compiled to a JavaScript
|
|
228
|
+
* file. If 'c', the model will be compiled to a C file (in which case an additional
|
|
229
|
+
* plugin will be needed to convert the C code to a WebAssembly module).
|
|
230
|
+
*/
|
|
231
|
+
genFormat: 'js' | 'c';
|
|
232
|
+
/**
|
|
233
|
+
* The absolute path to the JSON file that will be written by the build process that
|
|
234
|
+
* lists all dimensions and variables in the model.
|
|
235
|
+
*/
|
|
236
|
+
outListingFile?: string;
|
|
91
237
|
/**
|
|
92
238
|
* The path to the `@sdeverywhere/cli` package. This is currently only used to get
|
|
93
239
|
* access to the files in the `src/c` directory.
|
|
@@ -272,8 +418,8 @@ declare class BuildContext {
|
|
|
272
418
|
* - preGenerate
|
|
273
419
|
* - preProcessMdl
|
|
274
420
|
* - postProcessMdl
|
|
275
|
-
* -
|
|
276
|
-
* -
|
|
421
|
+
* - preGenerateCode
|
|
422
|
+
* - postGenerateCode
|
|
277
423
|
* - postGenerate
|
|
278
424
|
* - postBuild
|
|
279
425
|
* - watch (only called once after initial build steps when mode==development)
|
|
@@ -292,7 +438,7 @@ interface Plugin {
|
|
|
292
438
|
* @param context The build context (for logging, etc).
|
|
293
439
|
* @param modelSpec The spec that controls how the model is generated.
|
|
294
440
|
*/
|
|
295
|
-
preGenerate?(context: BuildContext, modelSpec:
|
|
441
|
+
preGenerate?(context: BuildContext, modelSpec: ResolvedModelSpec): Promise<void>;
|
|
296
442
|
/**
|
|
297
443
|
* Called before SDE preprocesses the mdl file (in the case of one mdl file),
|
|
298
444
|
* or before SDE flattens the mdl files (in the case of multiple mdl files).
|
|
@@ -310,19 +456,21 @@ interface Plugin {
|
|
|
310
456
|
*/
|
|
311
457
|
postProcessMdl?(context: BuildContext, mdlContent: string): Promise<string>;
|
|
312
458
|
/**
|
|
313
|
-
* Called before SDE generates a C file from the mdl file.
|
|
459
|
+
* Called before SDE generates a JS or C file from the mdl file.
|
|
314
460
|
*
|
|
315
461
|
* @param context The build context (for logging, etc).
|
|
462
|
+
* @param format The generated code format, either 'js' or 'c'.
|
|
316
463
|
*/
|
|
317
|
-
|
|
464
|
+
preGenerateCode?(context: BuildContext, format: 'js' | 'c'): Promise<void>;
|
|
318
465
|
/**
|
|
319
|
-
* Called after SDE generates a C file from the mdl file.
|
|
466
|
+
* Called after SDE generates a JS or C file from the mdl file.
|
|
320
467
|
*
|
|
321
468
|
* @param context The build context (for logging, etc).
|
|
322
|
-
* @param
|
|
323
|
-
* @
|
|
469
|
+
* @param format The generated code format, either 'js' or 'c'.
|
|
470
|
+
* @param content The resulting JS or C file content.
|
|
471
|
+
* @return The modified JS or C file content (if postprocessing was needed).
|
|
324
472
|
*/
|
|
325
|
-
|
|
473
|
+
postGenerateCode?(context: BuildContext, format: 'js' | 'c', content: string): Promise<string>;
|
|
326
474
|
/**
|
|
327
475
|
* Called after the "generate model" process has completed (but before the staged
|
|
328
476
|
* files are copied to their destination).
|
|
@@ -332,7 +480,7 @@ interface Plugin {
|
|
|
332
480
|
* @return Whether the plugin succeeded (for example, a plugin that runs tests can
|
|
333
481
|
* return false to indicate that one or more tests failed).
|
|
334
482
|
*/
|
|
335
|
-
postGenerate?(context: BuildContext, modelSpec:
|
|
483
|
+
postGenerate?(context: BuildContext, modelSpec: ResolvedModelSpec): Promise<boolean>;
|
|
336
484
|
/**
|
|
337
485
|
* Called after the model has been generated and after the staged files
|
|
338
486
|
* have been copied to their destination.
|
|
@@ -342,7 +490,7 @@ interface Plugin {
|
|
|
342
490
|
* @return Whether the plugin succeeded (for example, a plugin that runs tests can
|
|
343
491
|
* return false to indicate that one or more tests failed).
|
|
344
492
|
*/
|
|
345
|
-
postBuild?(context: BuildContext, modelSpec:
|
|
493
|
+
postBuild?(context: BuildContext, modelSpec: ResolvedModelSpec): Promise<boolean>;
|
|
346
494
|
/**
|
|
347
495
|
* Called in development/watch mode after the initial build has completed
|
|
348
496
|
* (i.e., after the model has been generated and after the staged files
|
|
@@ -384,6 +532,19 @@ interface UserConfig {
|
|
|
384
532
|
* If left undefined, this will resolve to the `modelFiles` array.
|
|
385
533
|
*/
|
|
386
534
|
watchPaths?: string[];
|
|
535
|
+
/**
|
|
536
|
+
* The code format to generate. If 'js', the model will be compiled to a JavaScript
|
|
537
|
+
* file. If 'c', the model will be compiled to a C file (in which case an additional
|
|
538
|
+
* plugin will be needed to convert the C code to a WebAssembly module). If undefined,
|
|
539
|
+
* defaults to 'js'.
|
|
540
|
+
*/
|
|
541
|
+
genFormat?: 'js' | 'c';
|
|
542
|
+
/**
|
|
543
|
+
* If defined, the build process will write a JSON file to the provided path that lists
|
|
544
|
+
* all dimensions and variables in the model. This can be an absolute path, or if it
|
|
545
|
+
* is a relative path it will be resolved relative to the `rootDir` for the project.
|
|
546
|
+
*/
|
|
547
|
+
outListingFile?: string;
|
|
387
548
|
/**
|
|
388
549
|
* The array of plugins that are used to customize the build process. These will be
|
|
389
550
|
* executed in the order defined here.
|
|
@@ -437,4 +598,4 @@ interface BuildResult {
|
|
|
437
598
|
*/
|
|
438
599
|
declare function build(mode: BuildMode, options: BuildOptions): Promise<Result<BuildResult, Error>>;
|
|
439
600
|
|
|
440
|
-
export { BuildContext, BuildMode, BuildOptions, BuildResult, InputSpec, LogLevel, ModelSpec, OutputSpec, Plugin, ResolvedConfig, UserConfig, build };
|
|
601
|
+
export { BuildContext, BuildMode, BuildOptions, BuildResult, InputSpec, LogLevel, ModelSpec, OutputSpec, Plugin, ResolvedConfig, ResolvedModelSpec, UserConfig, VarName, build };
|
package/dist/index.d.ts
CHANGED
|
@@ -8,10 +8,14 @@ type LogLevel = 'error' | 'info' | 'verbose';
|
|
|
8
8
|
*/
|
|
9
9
|
type BuildMode = 'development' | 'production';
|
|
10
10
|
|
|
11
|
+
/** A variable name as used in the modeling tool. */
|
|
12
|
+
type VarName = string;
|
|
11
13
|
/**
|
|
12
14
|
* Describes a model input variable.
|
|
13
15
|
*/
|
|
14
16
|
interface InputSpec {
|
|
17
|
+
/** The variable name (as used in the modeling tool). */
|
|
18
|
+
varName: VarName;
|
|
15
19
|
/**
|
|
16
20
|
* The stable input identifier. It is recommended to set this to a value (for example, a
|
|
17
21
|
* numeric string like what `plugin-config` uses) that is separate from `varName` and is
|
|
@@ -21,33 +25,164 @@ interface InputSpec {
|
|
|
21
25
|
* note that this approach will be less resilient to renames.
|
|
22
26
|
*/
|
|
23
27
|
inputId?: string;
|
|
24
|
-
/** The variable name (as used in the modeling tool). */
|
|
25
|
-
varName: string;
|
|
26
28
|
/** The default value for the input. */
|
|
27
|
-
defaultValue
|
|
29
|
+
defaultValue?: number;
|
|
28
30
|
/** The minimum value for the input. */
|
|
29
|
-
minValue
|
|
31
|
+
minValue?: number;
|
|
30
32
|
/** The maximum value for the input. */
|
|
31
|
-
maxValue
|
|
33
|
+
maxValue?: number;
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
34
36
|
* Describes a model output variable.
|
|
35
37
|
*/
|
|
36
38
|
interface OutputSpec {
|
|
37
39
|
/** The variable name (as used in the modeling tool). */
|
|
38
|
-
varName:
|
|
40
|
+
varName: VarName;
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
41
43
|
* Describes a model (e.g., a Vensim mdl file) and the input/output variables
|
|
42
|
-
* that should be included in the model generated by
|
|
44
|
+
* that should be included in the model generated by SDEverywhere.
|
|
43
45
|
*/
|
|
44
46
|
interface ModelSpec {
|
|
45
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* The input variables for the model. This can either be a simple array of
|
|
49
|
+
* input variable names, or an array of `InputSpec` instances.
|
|
50
|
+
*
|
|
51
|
+
* The builder requires only variable names for the purposes of generating
|
|
52
|
+
* a model, but some plugins may require full `InputSpec` instances.
|
|
53
|
+
*/
|
|
54
|
+
inputs: VarName[] | InputSpec[];
|
|
55
|
+
/**
|
|
56
|
+
* The output variables for the model. This can either be a simple array of
|
|
57
|
+
* output variable names, or an array of `OutputSpec` instances.
|
|
58
|
+
*/
|
|
59
|
+
outputs: VarName[] | OutputSpec[];
|
|
60
|
+
/**
|
|
61
|
+
* The dat files that provide the data for exogenous data variables in the
|
|
62
|
+
* model.
|
|
63
|
+
*/
|
|
64
|
+
datFiles?: string[];
|
|
65
|
+
/**
|
|
66
|
+
* Whether to bundle a model listing with the generated model.
|
|
67
|
+
*
|
|
68
|
+
* If undefined, defaults to false.
|
|
69
|
+
*
|
|
70
|
+
* When this is true, a model listing will be bundled with the generated
|
|
71
|
+
* model to allow the `runtime` package to resolve variables that are
|
|
72
|
+
* referenced by name or identifier. This listing will increase the size
|
|
73
|
+
* of the generated model, so it is recommended to set this to true only
|
|
74
|
+
* if it is needed.
|
|
75
|
+
*/
|
|
76
|
+
bundleListing?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Whether to allow lookups to be overridden at runtime using `setLookup`.
|
|
79
|
+
*
|
|
80
|
+
* If undefined or false, the generated model will implement `setLookup`
|
|
81
|
+
* as a no-op, meaning that lookups cannot be overridden at runtime.
|
|
82
|
+
*
|
|
83
|
+
* If true, all lookups in the generated model will be available to be
|
|
84
|
+
* overridden.
|
|
85
|
+
*
|
|
86
|
+
* If an array is provided, only those variable names in the array will
|
|
87
|
+
* be available to be overridden.
|
|
88
|
+
*/
|
|
89
|
+
customLookups?: boolean | VarName[];
|
|
90
|
+
/**
|
|
91
|
+
* Whether to allow for capturing the data for arbitrary variables at
|
|
92
|
+
* runtime (including variables that are not configured in the `outputs`
|
|
93
|
+
* array).
|
|
94
|
+
*
|
|
95
|
+
* If undefined or false, the generated model will implement `storeOutput`
|
|
96
|
+
* as a no-op, meaning that the data for arbitrary variables cannot be
|
|
97
|
+
* captured at runtime.
|
|
98
|
+
*
|
|
99
|
+
* If true, all variables in the generated model will be available to be
|
|
100
|
+
* captured at runtime.
|
|
101
|
+
*
|
|
102
|
+
* If an array is provided, only those variable names in the array will
|
|
103
|
+
* be available to be captured at runtime.
|
|
104
|
+
*/
|
|
105
|
+
customOutputs?: boolean | VarName[];
|
|
106
|
+
/** Additional options included with the SDE `spec.json` file. */
|
|
107
|
+
options?: {
|
|
108
|
+
[key: string]: any;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Describes a model (e.g., a Vensim mdl file) and the input/output variables
|
|
113
|
+
* that should be included in the model generated by SDEverywhere. This is
|
|
114
|
+
* largely the same as the `ModelSpec` interface, except this one has been
|
|
115
|
+
* fully resolved (paths have been validated, input and output variables have
|
|
116
|
+
* been checked, etc). This is the spec object that will be passed to plugin
|
|
117
|
+
* functions.
|
|
118
|
+
*/
|
|
119
|
+
interface ResolvedModelSpec {
|
|
120
|
+
/**
|
|
121
|
+
* The input variable names for the model. This will be defined regardless
|
|
122
|
+
* of whether `ModelSpec.inputs` was defined as an array of variable names
|
|
123
|
+
* or an array of `InputSpec` instances. (The input variable names are
|
|
124
|
+
* derived from the `InputSpec` instances as needed.)
|
|
125
|
+
*/
|
|
126
|
+
inputVarNames: VarName[];
|
|
127
|
+
/**
|
|
128
|
+
* The input variable specs for the model.
|
|
129
|
+
*/
|
|
46
130
|
inputs: InputSpec[];
|
|
47
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* The output variable names for the model. This will be defined regardless
|
|
133
|
+
* of whether `ModelSpec.outputs` was defined as an array of variable names
|
|
134
|
+
* or an array of `OutputSpec` instances. (The output variable names are
|
|
135
|
+
* derived from the `OutputSpec` instances as needed.)
|
|
136
|
+
*/
|
|
137
|
+
outputVarNames: VarName[];
|
|
138
|
+
/**
|
|
139
|
+
* The output variable specs for the model.
|
|
140
|
+
*/
|
|
48
141
|
outputs: OutputSpec[];
|
|
49
|
-
/**
|
|
142
|
+
/**
|
|
143
|
+
* The dat files that provide the data for exogenous data variables in the
|
|
144
|
+
* model.
|
|
145
|
+
*/
|
|
50
146
|
datFiles: string[];
|
|
147
|
+
/**
|
|
148
|
+
* Whether to bundle a model listing with the generated model.
|
|
149
|
+
*
|
|
150
|
+
* When this is true, a model listing will be bundled with the generated
|
|
151
|
+
* model to allow the `runtime` package to resolve variables that are
|
|
152
|
+
* referenced by name or identifier. This listing will increase the size
|
|
153
|
+
* of the generated model, so it is recommended to set this to true only
|
|
154
|
+
* if it is needed.
|
|
155
|
+
*/
|
|
156
|
+
bundleListing: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Whether to allow lookups to be overridden at runtime using `setLookup`.
|
|
159
|
+
*
|
|
160
|
+
* If false, the generated model will contain a `setLookup` function that
|
|
161
|
+
* throws an error, meaning that lookups cannot be overridden at runtime.
|
|
162
|
+
*
|
|
163
|
+
* If true, all lookups in the generated model will be available to be
|
|
164
|
+
* overridden.
|
|
165
|
+
*
|
|
166
|
+
* If an array is provided, only those variable names in the array will
|
|
167
|
+
* be available to be overridden.
|
|
168
|
+
*/
|
|
169
|
+
customLookups: boolean | VarName[];
|
|
170
|
+
/**
|
|
171
|
+
* Whether to allow for capturing the data for arbitrary variables at
|
|
172
|
+
* runtime (including variables that are not configured in the `outputs`
|
|
173
|
+
* array).
|
|
174
|
+
*
|
|
175
|
+
* If false, the generated model will contain a `storeOutput` function
|
|
176
|
+
* that throws an error, meaning that the data for arbitrary variables
|
|
177
|
+
* cannot be captured at runtime.
|
|
178
|
+
*
|
|
179
|
+
* If true, all variables in the generated model will be available to be
|
|
180
|
+
* captured at runtime.
|
|
181
|
+
*
|
|
182
|
+
* If an array is provided, only those variable names in the array will
|
|
183
|
+
* be available to be captured at runtime.
|
|
184
|
+
*/
|
|
185
|
+
customOutputs: boolean | VarName[];
|
|
51
186
|
/** Additional options included with the SDE `spec.json` file. */
|
|
52
187
|
options?: {
|
|
53
188
|
[key: string]: any;
|
|
@@ -88,6 +223,17 @@ interface ResolvedConfig {
|
|
|
88
223
|
* can be paths to files or glob patterns (relative to the project directory).
|
|
89
224
|
*/
|
|
90
225
|
watchPaths: string[];
|
|
226
|
+
/**
|
|
227
|
+
* The code format to generate. If 'js', the model will be compiled to a JavaScript
|
|
228
|
+
* file. If 'c', the model will be compiled to a C file (in which case an additional
|
|
229
|
+
* plugin will be needed to convert the C code to a WebAssembly module).
|
|
230
|
+
*/
|
|
231
|
+
genFormat: 'js' | 'c';
|
|
232
|
+
/**
|
|
233
|
+
* The absolute path to the JSON file that will be written by the build process that
|
|
234
|
+
* lists all dimensions and variables in the model.
|
|
235
|
+
*/
|
|
236
|
+
outListingFile?: string;
|
|
91
237
|
/**
|
|
92
238
|
* The path to the `@sdeverywhere/cli` package. This is currently only used to get
|
|
93
239
|
* access to the files in the `src/c` directory.
|
|
@@ -272,8 +418,8 @@ declare class BuildContext {
|
|
|
272
418
|
* - preGenerate
|
|
273
419
|
* - preProcessMdl
|
|
274
420
|
* - postProcessMdl
|
|
275
|
-
* -
|
|
276
|
-
* -
|
|
421
|
+
* - preGenerateCode
|
|
422
|
+
* - postGenerateCode
|
|
277
423
|
* - postGenerate
|
|
278
424
|
* - postBuild
|
|
279
425
|
* - watch (only called once after initial build steps when mode==development)
|
|
@@ -292,7 +438,7 @@ interface Plugin {
|
|
|
292
438
|
* @param context The build context (for logging, etc).
|
|
293
439
|
* @param modelSpec The spec that controls how the model is generated.
|
|
294
440
|
*/
|
|
295
|
-
preGenerate?(context: BuildContext, modelSpec:
|
|
441
|
+
preGenerate?(context: BuildContext, modelSpec: ResolvedModelSpec): Promise<void>;
|
|
296
442
|
/**
|
|
297
443
|
* Called before SDE preprocesses the mdl file (in the case of one mdl file),
|
|
298
444
|
* or before SDE flattens the mdl files (in the case of multiple mdl files).
|
|
@@ -310,19 +456,21 @@ interface Plugin {
|
|
|
310
456
|
*/
|
|
311
457
|
postProcessMdl?(context: BuildContext, mdlContent: string): Promise<string>;
|
|
312
458
|
/**
|
|
313
|
-
* Called before SDE generates a C file from the mdl file.
|
|
459
|
+
* Called before SDE generates a JS or C file from the mdl file.
|
|
314
460
|
*
|
|
315
461
|
* @param context The build context (for logging, etc).
|
|
462
|
+
* @param format The generated code format, either 'js' or 'c'.
|
|
316
463
|
*/
|
|
317
|
-
|
|
464
|
+
preGenerateCode?(context: BuildContext, format: 'js' | 'c'): Promise<void>;
|
|
318
465
|
/**
|
|
319
|
-
* Called after SDE generates a C file from the mdl file.
|
|
466
|
+
* Called after SDE generates a JS or C file from the mdl file.
|
|
320
467
|
*
|
|
321
468
|
* @param context The build context (for logging, etc).
|
|
322
|
-
* @param
|
|
323
|
-
* @
|
|
469
|
+
* @param format The generated code format, either 'js' or 'c'.
|
|
470
|
+
* @param content The resulting JS or C file content.
|
|
471
|
+
* @return The modified JS or C file content (if postprocessing was needed).
|
|
324
472
|
*/
|
|
325
|
-
|
|
473
|
+
postGenerateCode?(context: BuildContext, format: 'js' | 'c', content: string): Promise<string>;
|
|
326
474
|
/**
|
|
327
475
|
* Called after the "generate model" process has completed (but before the staged
|
|
328
476
|
* files are copied to their destination).
|
|
@@ -332,7 +480,7 @@ interface Plugin {
|
|
|
332
480
|
* @return Whether the plugin succeeded (for example, a plugin that runs tests can
|
|
333
481
|
* return false to indicate that one or more tests failed).
|
|
334
482
|
*/
|
|
335
|
-
postGenerate?(context: BuildContext, modelSpec:
|
|
483
|
+
postGenerate?(context: BuildContext, modelSpec: ResolvedModelSpec): Promise<boolean>;
|
|
336
484
|
/**
|
|
337
485
|
* Called after the model has been generated and after the staged files
|
|
338
486
|
* have been copied to their destination.
|
|
@@ -342,7 +490,7 @@ interface Plugin {
|
|
|
342
490
|
* @return Whether the plugin succeeded (for example, a plugin that runs tests can
|
|
343
491
|
* return false to indicate that one or more tests failed).
|
|
344
492
|
*/
|
|
345
|
-
postBuild?(context: BuildContext, modelSpec:
|
|
493
|
+
postBuild?(context: BuildContext, modelSpec: ResolvedModelSpec): Promise<boolean>;
|
|
346
494
|
/**
|
|
347
495
|
* Called in development/watch mode after the initial build has completed
|
|
348
496
|
* (i.e., after the model has been generated and after the staged files
|
|
@@ -384,6 +532,19 @@ interface UserConfig {
|
|
|
384
532
|
* If left undefined, this will resolve to the `modelFiles` array.
|
|
385
533
|
*/
|
|
386
534
|
watchPaths?: string[];
|
|
535
|
+
/**
|
|
536
|
+
* The code format to generate. If 'js', the model will be compiled to a JavaScript
|
|
537
|
+
* file. If 'c', the model will be compiled to a C file (in which case an additional
|
|
538
|
+
* plugin will be needed to convert the C code to a WebAssembly module). If undefined,
|
|
539
|
+
* defaults to 'js'.
|
|
540
|
+
*/
|
|
541
|
+
genFormat?: 'js' | 'c';
|
|
542
|
+
/**
|
|
543
|
+
* If defined, the build process will write a JSON file to the provided path that lists
|
|
544
|
+
* all dimensions and variables in the model. This can be an absolute path, or if it
|
|
545
|
+
* is a relative path it will be resolved relative to the `rootDir` for the project.
|
|
546
|
+
*/
|
|
547
|
+
outListingFile?: string;
|
|
387
548
|
/**
|
|
388
549
|
* The array of plugins that are used to customize the build process. These will be
|
|
389
550
|
* executed in the order defined here.
|
|
@@ -437,4 +598,4 @@ interface BuildResult {
|
|
|
437
598
|
*/
|
|
438
599
|
declare function build(mode: BuildMode, options: BuildOptions): Promise<Result<BuildResult, Error>>;
|
|
439
600
|
|
|
440
|
-
export { BuildContext, BuildMode, BuildOptions, BuildResult, InputSpec, LogLevel, ModelSpec, OutputSpec, Plugin, ResolvedConfig, UserConfig, build };
|
|
601
|
+
export { BuildContext, BuildMode, BuildOptions, BuildResult, InputSpec, LogLevel, ModelSpec, OutputSpec, Plugin, ResolvedConfig, ResolvedModelSpec, UserConfig, VarName, build };
|