cppmodel 0.9.0 → 0.9.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/README.md CHANGED
@@ -82,9 +82,10 @@ Inputs and outputs are numbers. Parameters keep their JSON type. All three have
82
82
  - **`run()` is synchronous.** It blocks the event loop until the simulation has finished, which is
83
83
  fine for scripts and tests. In a server, run simulations in a
84
84
  [worker thread](https://nodejs.org/api/worker_threads.html).
85
- - **Workspace access:** set `CPPMODEL_USERNAME` and `CPPMODEL_PASSWORD` for scripts and CI. Pass
86
- `{ offline: true }` to run without the workspace. Without credentials, the first run prints a
87
- sign-in link and waits until you've signed in.
85
+ - **Workspace access:** every run reads its inputs from and records its execution in your
86
+ workspace. Set `CPPMODEL_USERNAME` and `CPPMODEL_PASSWORD` for scripts and CI. Without
87
+ credentials, the first run prints a sign-in link and waits 60 seconds for you to sign in
88
+ (`CPPMODEL_LOGIN_TIMEOUT` changes that, in seconds); without a sign-in, `run()` throws.
88
89
  - **Fingerprint:** each execution records a `CppModel.BinaryFingerprint` of the simulation's code,
89
90
  so the workspace can tell runs of the same code from runs of changed code. It is the fingerprint
90
91
  of the file that creates the simulation. Set `sim.fingerprintFile` to use another file.
package/index.d.ts CHANGED
@@ -69,8 +69,6 @@ export declare class Parameters {
69
69
  }
70
70
 
71
71
  export interface SimulationOptions<S extends Simulation = Simulation> {
72
- /** When true, run() doesn't reach the workspace: nothing is fetched or submitted. */
73
- offline?: boolean;
74
72
  init?: (simulation: S) => void;
75
73
  step?: (simulation: S, timeMs: number) => void;
76
74
  finalize?: (simulation: S) => void;
@@ -106,7 +104,6 @@ export declare class Simulation {
106
104
  name: string;
107
105
  totalTimeMs: number;
108
106
  stepMs: number;
109
- offline: boolean;
110
107
  /**
111
108
  * The file whose fingerprint is recorded as CppModel.BinaryFingerprint. Defaults to the file that
112
109
  * created the simulation; null means the Node.js executable's fingerprint.
package/index.js CHANGED
@@ -50,7 +50,6 @@ function load() {
50
50
  getName: f('int cm_simulation_get_name(void *simulation, _Out_ const char **out)'),
51
51
  setTiming: f('int cm_simulation_set_timing(void *simulation, uint64_t total_time_ms, uint64_t step_ms)'),
52
52
  getTiming: f('int cm_simulation_get_timing(void *simulation, _Out_ uint64_t *total_time_ms, _Out_ uint64_t *step_ms)'),
53
- setRunOffline: f('int cm_simulation_set_run_offline(void *simulation, int offline)'),
54
53
  setFingerprintFile: f('int cm_simulation_set_fingerprint_file(void *simulation, const char *path)'),
55
54
  setInitCallback: f('int cm_simulation_set_init_callback(void *simulation, cm_callback *callback, void *user_data)'),
56
55
  setStepCallback: f('int cm_simulation_set_step_callback(void *simulation, cm_callback *callback, void *user_data)'),
@@ -273,15 +272,13 @@ const finalizer = new FinalizationRegistry((handle) => c.destroy(handle));
273
272
  */
274
273
  class Simulation {
275
274
  #handle;
276
- #offline = false;
277
275
  #fingerprintFile = null;
278
276
  #functions;
279
277
 
280
- constructor(name, totalTimeMs, stepMs, { offline = false, init, step, finalize } = {}) {
278
+ constructor(name, totalTimeMs, stepMs, { init, step, finalize } = {}) {
281
279
  this.#handle = read(c.create, name, totalTimeMs, stepMs);
282
280
  finalizer.register(this, this.#handle, this);
283
281
  this.#functions = { init, step, finalize };
284
- this.offline = offline;
285
282
  const caller = callerFile();
286
283
  const file = caller ? path.resolve(caller) : null;
287
284
  if (file && c.setFingerprintFile(this.#handle, file) === Status.OK) this.#fingerprintFile = file;
@@ -393,16 +390,6 @@ class Simulation {
393
390
  check(c.setTiming(this._live(), this.totalTimeMs, value));
394
391
  }
395
392
 
396
- /** When true, run() doesn't reach the workspace: nothing is fetched or submitted. */
397
- get offline() {
398
- return this.#offline;
399
- }
400
-
401
- set offline(value) {
402
- check(c.setRunOffline(this._live(), value ? 1 : 0));
403
- this.#offline = Boolean(value);
404
- }
405
-
406
393
  /**
407
394
  * The file whose fingerprint is recorded as CppModel.BinaryFingerprint, so that runs of the same
408
395
  * code can be told apart from runs of changed code. Defaults to the file that created the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cppmodel",
3
- "version": "0.9.0",
3
+ "version": "0.9.4",
4
4
  "description": "Write CppModel simulations in Node.js",
5
5
  "keywords": ["cppmodel", "simulation", "plant model", "testing", "embedded"],
6
6
  "homepage": "https://cppmodel.com",
Binary file
Binary file
Binary file