@adriansteffan/reactive 0.2.0 → 0.2.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.
@@ -1,4 +1,4 @@
1
- import { W as e } from "./mod-C-XUCKhQ.js";
1
+ import { W as e } from "./mod-CZYkml9p.js";
2
2
  class s extends e {
3
3
  async enable() {
4
4
  console.log("Immersive mode is only available on Android");
@@ -1,4 +1,4 @@
1
- import { W as P, b as x, E } from "./mod-C-XUCKhQ.js";
1
+ import { W as P, b as x, E } from "./mod-CZYkml9p.js";
2
2
  function m(w) {
3
3
  const e = w.split("/").filter((t) => t !== "."), r = [];
4
4
  return e.forEach((t) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adriansteffan/reactive",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -197,7 +197,9 @@ export function registerExperimentParams(experiment: any[]) {
197
197
  if (params) {
198
198
  for (const param of params) {
199
199
  if(!item.hideSettings || (item.hideSettings !== true && !item.hideSettings.includes(param.name))){
200
- sharedRegistry.push(param);
200
+ if (!sharedRegistry.some((p) => p.name === param.name)) {
201
+ sharedRegistry.push(param);
202
+ }
201
203
  }
202
204
  }
203
205
  }
@@ -211,11 +213,10 @@ export function registerComponentParams(
211
213
  providedComponentParams[type] = params;
212
214
  }
213
215
 
214
- export function subsetExperimentByParam(experiment: any[]) {
216
+ export function prepareTimeline(experiment: any[], options: { subset?: boolean } = {}): any[] {
215
217
  registerExperimentParams(experiment);
216
218
 
217
219
  timelineRepresentation.length = 0;
218
-
219
220
  experiment.forEach((item) => {
220
221
  timelineRepresentation.push({
221
222
  type: item.type ?? 'NoTypeSpecified',
@@ -223,6 +224,8 @@ export function subsetExperimentByParam(experiment: any[]) {
223
224
  });
224
225
  });
225
226
 
227
+ if (!options.subset) return experiment;
228
+
226
229
  const include = getParam('includeSubset', undefined);
227
230
  const exclude = getParam('excludeSubset', undefined);
228
231
 
@@ -255,6 +258,7 @@ export function subsetExperimentByParam(experiment: any[]) {
255
258
  return experimentFiltered;
256
259
  }
257
260
 
261
+
258
262
  export function canvasCountdown(seconds: number) {
259
263
  if (seconds <= 0) {
260
264
  return [];
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import { useState, useRef } from 'react';
3
- import { ExperimentRunner, BaseComponentProps, ExperimentConfig, registerSimulation, registerFlattener, sampleParticipants } from '@adriansteffan/reactive';
3
+ import { ExperimentRunner, BaseComponentProps, ExperimentConfig, registerSimulation, registerFlattener, sampleParticipants, prepareTimeline } from '@adriansteffan/reactive';
4
4
 
5
5
 
6
6
  const config: ExperimentConfig = { showProgressBar: true };
@@ -66,7 +66,7 @@ const CustomQuestion = () => {
66
66
 
67
67
  // --- Timeline ---
68
68
 
69
- const experiment = [
69
+ const experiment = prepareTimeline([
70
70
  {
71
71
  name: 'introtext',
72
72
  type: 'Text',
@@ -149,7 +149,7 @@ const experiment = [
149
149
  content: <>Thank you for participating in our study, you can now close the browser window.</>,
150
150
  },
151
151
  },
152
- ];
152
+ ]);
153
153
 
154
154
  // --- Simulation config ---
155
155
  const simulationConfig = {