@adriansteffan/reactive 0.0.40 → 0.0.41

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 P, b as x, E } from "./mod-atv0jMSt.js";
1
+ import { W as P, b as x, E } from "./mod-DBgU62Mz.js";
2
2
  function m(w) {
3
3
  const e = w.split("/").filter((t) => t !== "."), r = [];
4
4
  return e.forEach((t) => {
@@ -1,4 +1,4 @@
1
- import { W as e } from "./mod-atv0jMSt.js";
1
+ import { W as e } from "./mod-DBgU62Mz.js";
2
2
  class s extends e {
3
3
  async enable() {
4
4
  console.log("Immersive mode is only available on Android");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adriansteffan/reactive",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -112,15 +112,32 @@ function combineTrialsToCsv(
112
112
  fun?: (obj: any) => any,
113
113
  ): FileUpload | FileUpload[] {
114
114
 
115
- // Collect all flattener results first
115
+ // Collect all flattener results first, filtering out completely empty results
116
116
  const allResults: (any[] | Record<string, any[]>)[] = names.flatMap((name) => {
117
117
  const matchingItems = data.filter((d) => d.name === name);
118
118
 
119
119
  return matchingItems.map((item) => {
120
120
  const flattener = item.type && flatteningFunctions[item.type];
121
- return flattener ? flattener(item) : [transform(item)];
121
+ const result = flattener ? flattener(item) : [transform(item)];
122
+
123
+ // Filter out completely empty results
124
+ if (Array.isArray(result) && result.length === 0) {
125
+ return null; // Signal this trial should be completely skipped
126
+ }
127
+
128
+ if (result && typeof result === 'object' && !Array.isArray(result)) {
129
+ // Check if all arrays in the object are empty
130
+ const hasAnyData = Object.values(result).some(val =>
131
+ Array.isArray(val) && val.length > 0
132
+ );
133
+ if (!hasAnyData) {
134
+ return null; // Signal this trial should be completely skipped
135
+ }
136
+ }
137
+
138
+ return result;
122
139
  });
123
- });
140
+ }).filter(result => result !== null);
124
141
 
125
142
  // Check if any result is a multi-table object (has string keys with array values)
126
143
  const hasMultiTable = allResults.some((result) =>
@@ -131,11 +148,16 @@ function combineTrialsToCsv(
131
148
  );
132
149
 
133
150
  if (!hasMultiTable) {
134
- // Original behavior: all results are arrays, combine them into one CSV
151
+ // all results are arrays, combine them into one CSV
135
152
  const processedData = allResults
136
153
  .flatMap((result) => Array.isArray(result) ? result : [])
137
154
  .map((x) => (fun ? fun(x) : x));
138
155
 
156
+ // Skip creating CSV if all flatteners returned empty arrays
157
+ if (processedData.length === 0) {
158
+ return [];
159
+ }
160
+
139
161
  return {
140
162
  filename,
141
163
  encoding: 'utf8' as const,
@@ -143,7 +165,7 @@ function combineTrialsToCsv(
143
165
  };
144
166
  }
145
167
 
146
- // New behavior: handle multi-table results
168
+ // handle multi-table results
147
169
  // Collect all table keys from all results
148
170
  const allTableKeys = new Set<string>();
149
171
  allResults.forEach((result) => {
@@ -171,6 +193,11 @@ function combineTrialsToCsv(
171
193
  return [];
172
194
  }).map((x) => (fun ? fun(x) : x));
173
195
 
196
+ // Skip creating CSV if all flatteners returned empty arrays for this table
197
+ if (tableData.length === 0) {
198
+ continue;
199
+ }
200
+
174
201
  // Remove file extension from filename and add table key
175
202
  const baseFilename = filename.replace(/\.csv$/, '');
176
203
 
@@ -181,6 +208,11 @@ function combineTrialsToCsv(
181
208
  });
182
209
  }
183
210
 
211
+ // Return empty array if no files were created
212
+ if (files.length === 0) {
213
+ return [];
214
+ }
215
+
184
216
  return files.length === 1 ? files[0] : files;
185
217
  }
186
218
 
@@ -477,7 +509,10 @@ export default function Upload({
477
509
  );
478
510
 
479
511
  if (Array.isArray(result)) {
480
- files.push(...result);
512
+ // Only push files if the array is not empty
513
+ if (result.length > 0) {
514
+ files.push(...result);
515
+ }
481
516
  } else {
482
517
  files.push(result);
483
518
  }