@adriansteffan/reactive 0.2.6 → 0.5.0

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.
Files changed (156) hide show
  1. package/README.md +796 -229
  2. package/bin/add.js +56 -0
  3. package/bin/deploy.js +48 -0
  4. package/bin/download.js +28 -0
  5. package/bin/ghsetup.js +21 -0
  6. package/bin/native.js +81 -0
  7. package/bin/setup.js +11 -17
  8. package/bin/study-deploy.js +60 -0
  9. package/bin/undeploy.js +15 -0
  10. package/extras/transcription/compose.yaml +32 -0
  11. package/{template → extras}/transcription/transcribe.py +4 -9
  12. package/package.json +62 -64
  13. package/src/bun-env.d.ts +1 -0
  14. package/src/bun-plugin.ts +22 -0
  15. package/src/components/canvasblock.tsx +209 -537
  16. package/src/components/checkdevice.tsx +64 -84
  17. package/src/components/fullscreenblock.tsx +130 -0
  18. package/src/components/icons.tsx +50 -0
  19. package/src/components/index.ts +9 -11
  20. package/src/components/microphonecheck.tsx +76 -38
  21. package/src/components/plaininput.tsx +48 -41
  22. package/src/components/prolificending.tsx +64 -28
  23. package/src/components/quest.tsx +89 -87
  24. package/src/components/{randomdotkinetogram.tsx → randomdotkinematogram.tsx} +205 -267
  25. package/src/components/{voicerecorder.tsx → recorder.tsx} +81 -106
  26. package/src/components/requestfilepermission.tsx +63 -0
  27. package/src/components/stimulus.tsx +373 -0
  28. package/src/components/storeui.tsx +94 -148
  29. package/src/components/text.tsx +61 -59
  30. package/src/components/tutorial.tsx +45 -47
  31. package/src/components/upload.tsx +133 -309
  32. package/src/components/voicerecording.tsx +90 -94
  33. package/src/core/backend.ts +20 -0
  34. package/src/core/bytecode.ts +178 -0
  35. package/src/core/columns.ts +50 -0
  36. package/src/core/component.ts +238 -0
  37. package/src/core/development.ts +32 -0
  38. package/src/core/experiment.ts +263 -0
  39. package/src/core/files.ts +291 -0
  40. package/src/core/params.ts +166 -0
  41. package/src/core/platform.ts +29 -0
  42. package/src/core/rows.ts +106 -0
  43. package/src/core/simulation.ts +158 -0
  44. package/src/core/slides.ts +178 -0
  45. package/src/core/store.ts +22 -0
  46. package/src/core/timeline.ts +399 -0
  47. package/src/fonts/AtkinsonHyperlegible-Bold.woff2 +0 -0
  48. package/src/fonts/AtkinsonHyperlegible-BoldItalic.woff2 +0 -0
  49. package/src/fonts/AtkinsonHyperlegible-Italic.woff2 +0 -0
  50. package/src/fonts/AtkinsonHyperlegible-Regular.woff2 +0 -0
  51. package/src/index.css +5 -7
  52. package/src/mod.tsx +31 -17
  53. package/src/native.ts +127 -0
  54. package/src/quest.ts +2 -0
  55. package/src/runner/contexts.ts +35 -0
  56. package/src/runner/devpanel.tsx +68 -0
  57. package/src/runner/experimentrunner.tsx +210 -0
  58. package/src/runner/fullscreenguard.tsx +93 -0
  59. package/src/runner/paraminput.tsx +86 -0
  60. package/src/runner/progressbar.tsx +20 -0
  61. package/src/runner/settingsscreen.tsx +517 -0
  62. package/src/{utils → runner}/theme.ts +9 -8
  63. package/src/server.ts +93 -0
  64. package/src/tutorial.ts +3 -0
  65. package/src/utils/array.ts +30 -62
  66. package/src/utils/canvas.ts +66 -0
  67. package/src/utils/ddm.ts +47 -70
  68. package/src/utils/distributions.ts +352 -61
  69. package/src/utils/fullscreen.ts +38 -0
  70. package/src/utils/ids.ts +11 -0
  71. package/src/utils/keys.ts +46 -0
  72. package/src/utils/llm.ts +15 -15
  73. package/src/utils/time.ts +12 -0
  74. package/src/utils/tts.ts +24 -24
  75. package/template/.dockerignore +3 -1
  76. package/template/.env.example +5 -0
  77. package/template/.github/workflows/deploy.yml +25 -0
  78. package/template/.gitignore +14 -0
  79. package/template/Dockerfile +9 -14
  80. package/template/README.md +74 -214
  81. package/template/biome.json +34 -0
  82. package/template/build.ts +20 -0
  83. package/template/bunfig.toml +3 -0
  84. package/template/docker-compose.yaml +4 -33
  85. package/template/index.html +2 -2
  86. package/template/package.json +16 -89
  87. package/template/public/.gitkeep +0 -0
  88. package/template/server.ts +32 -0
  89. package/template/simulate.ts +4 -44
  90. package/template/src/Experiment.tsx +76 -128
  91. package/template/src/bun-env.d.ts +1 -0
  92. package/template/src/index.css +1 -9
  93. package/template/src/main.tsx +25 -10
  94. package/template/tsconfig.json +4 -6
  95. package/.claude/settings.local.json +0 -61
  96. package/.eslintrc.cjs +0 -18
  97. package/.playwright-mcp/console-2026-04-07T14-22-59-060Z.log +0 -1
  98. package/.prettierrc +0 -5
  99. package/Dockerfile +0 -20
  100. package/dist/mod-HDegGPrf.js +0 -87434
  101. package/dist/mod.d.ts +0 -946
  102. package/dist/reactive.es.js +0 -87
  103. package/dist/reactive.umd.js +0 -10255
  104. package/dist/style.css +0 -5
  105. package/dist/web-7BbR1Ad7.js +0 -435
  106. package/dist/web-CATfZO1Q.js +0 -12
  107. package/planned.md +0 -103
  108. package/postcss.config.js +0 -6
  109. package/raw-loader-hooks.mjs +0 -25
  110. package/raw-loader.mjs +0 -5
  111. package/rdk_doc.md +0 -341
  112. package/src/components/enterfullscreen.tsx +0 -230
  113. package/src/components/exitfullscreen.tsx +0 -113
  114. package/src/components/experimentprovider.tsx +0 -69
  115. package/src/components/experimentrunner.tsx +0 -497
  116. package/src/components/mobilefilepermission.tsx +0 -68
  117. package/src/components/settingsscreen.tsx +0 -770
  118. package/src/types/array.d.ts +0 -6
  119. package/src/utils/audiodevice.ts +0 -4
  120. package/src/utils/bytecode.ts +0 -261
  121. package/src/utils/common.ts +0 -291
  122. package/src/utils/ddm.test.ts +0 -233
  123. package/src/utils/distributions.test.ts +0 -209
  124. package/src/utils/nodecompat.ts +0 -11
  125. package/src/utils/overlays.ts +0 -19
  126. package/src/utils/request.ts +0 -25
  127. package/src/utils/simulation.ts +0 -299
  128. package/src/utils/upload.ts +0 -275
  129. package/src/vite-env.d.ts +0 -1
  130. package/template/.env.template +0 -2
  131. package/template/.eslintrc.cjs +0 -18
  132. package/template/.prettierrc +0 -5
  133. package/template/backend/package-lock.json +0 -2544
  134. package/template/backend/package.json +0 -31
  135. package/template/backend/src/backend.ts +0 -131
  136. package/template/backend/tsconfig.json +0 -110
  137. package/template/capacitor.config.ts +0 -15
  138. package/template/electron/main.js +0 -131
  139. package/template/electron/preload.js +0 -9
  140. package/template/electron.vite.config.js +0 -45
  141. package/template/package-lock.json +0 -12467
  142. package/template/postcss.config.js +0 -5
  143. package/template/public/Atkinson_Hyperlegible/AtkinsonHyperlegible-Bold.ttf +0 -0
  144. package/template/public/Atkinson_Hyperlegible/AtkinsonHyperlegible-BoldItalic.ttf +0 -0
  145. package/template/public/Atkinson_Hyperlegible/AtkinsonHyperlegible-Italic.ttf +0 -0
  146. package/template/public/Atkinson_Hyperlegible/AtkinsonHyperlegible-Regular.ttf +0 -0
  147. package/template/shared.vite.config.js +0 -39
  148. package/template/src/vite-env.d.ts +0 -2
  149. package/template/tsconfig.node.json +0 -12
  150. package/template/vite.config.js +0 -11
  151. package/tsconfig.json +0 -30
  152. package/tsconfig.node.json +0 -12
  153. package/vite.config.ts +0 -39
  154. /package/{template → extras}/transcription/Dockerfile.cpu +0 -0
  155. /package/{template → extras}/transcription/Dockerfile.gpu +0 -0
  156. /package/{template/public/Atkinson_Hyperlegible → src/fonts}/OFL.txt +0 -0
@@ -1,435 +0,0 @@
1
- import { W as P, b as x, E } from "./mod-HDegGPrf.js";
2
- function m(w) {
3
- const e = w.split("/").filter((t) => t !== "."), r = [];
4
- return e.forEach((t) => {
5
- t === ".." && r.length > 0 && r[r.length - 1] !== ".." ? r.pop() : r.push(t);
6
- }), r.join("/");
7
- }
8
- function R(w, e) {
9
- w = m(w), e = m(e);
10
- const r = w.split("/"), t = e.split("/");
11
- return w !== e && r.every((i, n) => i === t[n]);
12
- }
13
- class g extends P {
14
- constructor() {
15
- super(...arguments), this.DB_VERSION = 1, this.DB_NAME = "Disc", this._writeCmds = ["add", "put", "delete"], this.downloadFile = async (e) => {
16
- var r, t;
17
- const i = x(e, e.webFetchExtra), n = await fetch(e.url, i);
18
- let s;
19
- if (!e.progress)
20
- s = await n.blob();
21
- else if (!(n != null && n.body))
22
- s = new Blob();
23
- else {
24
- const c = n.body.getReader();
25
- let o = 0;
26
- const d = [], h = n.headers.get("content-type"), y = parseInt(n.headers.get("content-length") || "0", 10);
27
- for (; ; ) {
28
- const { done: f, value: p } = await c.read();
29
- if (f)
30
- break;
31
- d.push(p), o += (p == null ? void 0 : p.length) || 0;
32
- const b = {
33
- url: e.url,
34
- bytes: o,
35
- contentLength: y
36
- };
37
- this.notifyListeners("progress", b);
38
- }
39
- const u = new Uint8Array(o);
40
- let l = 0;
41
- for (const f of d)
42
- typeof f > "u" || (u.set(f, l), l += f.length);
43
- s = new Blob([u.buffer], { type: h || void 0 });
44
- }
45
- return { path: (await this.writeFile({
46
- path: e.path,
47
- directory: (r = e.directory) !== null && r !== void 0 ? r : void 0,
48
- recursive: (t = e.recursive) !== null && t !== void 0 ? t : !1,
49
- data: s
50
- })).uri, blob: s };
51
- };
52
- }
53
- async initDb() {
54
- if (this._db !== void 0)
55
- return this._db;
56
- if (!("indexedDB" in window))
57
- throw this.unavailable("This browser doesn't support IndexedDB");
58
- return new Promise((e, r) => {
59
- const t = indexedDB.open(this.DB_NAME, this.DB_VERSION);
60
- t.onupgradeneeded = g.doUpgrade, t.onsuccess = () => {
61
- this._db = t.result, e(t.result);
62
- }, t.onerror = () => r(t.error), t.onblocked = () => {
63
- console.warn("db blocked");
64
- };
65
- });
66
- }
67
- static doUpgrade(e) {
68
- const t = e.target.result;
69
- switch (e.oldVersion) {
70
- case 0:
71
- case 1:
72
- default:
73
- t.objectStoreNames.contains("FileStorage") && t.deleteObjectStore("FileStorage"), t.createObjectStore("FileStorage", { keyPath: "path" }).createIndex("by_folder", "folder");
74
- }
75
- }
76
- async dbRequest(e, r) {
77
- const t = this._writeCmds.indexOf(e) !== -1 ? "readwrite" : "readonly";
78
- return this.initDb().then((i) => new Promise((n, s) => {
79
- const o = i.transaction(["FileStorage"], t).objectStore("FileStorage")[e](...r);
80
- o.onsuccess = () => n(o.result), o.onerror = () => s(o.error);
81
- }));
82
- }
83
- async dbIndexRequest(e, r, t) {
84
- const i = this._writeCmds.indexOf(r) !== -1 ? "readwrite" : "readonly";
85
- return this.initDb().then((n) => new Promise((s, a) => {
86
- const h = n.transaction(["FileStorage"], i).objectStore("FileStorage").index(e)[r](...t);
87
- h.onsuccess = () => s(h.result), h.onerror = () => a(h.error);
88
- }));
89
- }
90
- getPath(e, r) {
91
- const t = r !== void 0 ? r.replace(/^[/]+|[/]+$/g, "") : "";
92
- let i = "";
93
- return e !== void 0 && (i += "/" + e), r !== "" && (i += "/" + t), i;
94
- }
95
- async clear() {
96
- (await this.initDb()).transaction(["FileStorage"], "readwrite").objectStore("FileStorage").clear();
97
- }
98
- /**
99
- * Read a file from disk
100
- * @param options options for the file read
101
- * @return a promise that resolves with the read file data result
102
- */
103
- async readFile(e) {
104
- const r = this.getPath(e.directory, e.path), t = await this.dbRequest("get", [r]);
105
- if (t === void 0)
106
- throw Error("File does not exist.");
107
- return { data: t.content ? t.content : "" };
108
- }
109
- /**
110
- * Write a file to disk in the specified location on device
111
- * @param options options for the file write
112
- * @return a promise that resolves with the file write result
113
- */
114
- async writeFile(e) {
115
- const r = this.getPath(e.directory, e.path);
116
- let t = e.data;
117
- const i = e.encoding, n = e.recursive, s = await this.dbRequest("get", [r]);
118
- if (s && s.type === "directory")
119
- throw Error("The supplied path is a directory.");
120
- const a = r.substr(0, r.lastIndexOf("/"));
121
- if (await this.dbRequest("get", [a]) === void 0) {
122
- const h = a.indexOf("/", 1);
123
- if (h !== -1) {
124
- const y = a.substr(h);
125
- await this.mkdir({
126
- path: y,
127
- directory: e.directory,
128
- recursive: n
129
- });
130
- }
131
- }
132
- if (!i && !(t instanceof Blob) && (t = t.indexOf(",") >= 0 ? t.split(",")[1] : t, !this.isBase64String(t)))
133
- throw Error("The supplied data is not valid base64 content.");
134
- const o = Date.now(), d = {
135
- path: r,
136
- folder: a,
137
- type: "file",
138
- size: t instanceof Blob ? t.size : t.length,
139
- ctime: o,
140
- mtime: o,
141
- content: t
142
- };
143
- return await this.dbRequest("put", [d]), {
144
- uri: d.path
145
- };
146
- }
147
- /**
148
- * Append to a file on disk in the specified location on device
149
- * @param options options for the file append
150
- * @return a promise that resolves with the file write result
151
- */
152
- async appendFile(e) {
153
- const r = this.getPath(e.directory, e.path);
154
- let t = e.data;
155
- const i = e.encoding, n = r.substr(0, r.lastIndexOf("/")), s = Date.now();
156
- let a = s;
157
- const c = await this.dbRequest("get", [r]);
158
- if (c && c.type === "directory")
159
- throw Error("The supplied path is a directory.");
160
- if (await this.dbRequest("get", [n]) === void 0) {
161
- const h = n.indexOf("/", 1);
162
- if (h !== -1) {
163
- const y = n.substr(h);
164
- await this.mkdir({
165
- path: y,
166
- directory: e.directory,
167
- recursive: !0
168
- });
169
- }
170
- }
171
- if (!i && !this.isBase64String(t))
172
- throw Error("The supplied data is not valid base64 content.");
173
- if (c !== void 0) {
174
- if (c.content instanceof Blob)
175
- throw Error("The occupied entry contains a Blob object which cannot be appended to.");
176
- c.content !== void 0 && !i ? t = btoa(atob(c.content) + atob(t)) : t = c.content + t, a = c.ctime;
177
- }
178
- const d = {
179
- path: r,
180
- folder: n,
181
- type: "file",
182
- size: t.length,
183
- ctime: a,
184
- mtime: s,
185
- content: t
186
- };
187
- await this.dbRequest("put", [d]);
188
- }
189
- /**
190
- * Delete a file from disk
191
- * @param options options for the file delete
192
- * @return a promise that resolves with the deleted file data result
193
- */
194
- async deleteFile(e) {
195
- const r = this.getPath(e.directory, e.path);
196
- if (await this.dbRequest("get", [r]) === void 0)
197
- throw Error("File does not exist.");
198
- if ((await this.dbIndexRequest("by_folder", "getAllKeys", [
199
- IDBKeyRange.only(r)
200
- ])).length !== 0)
201
- throw Error("Folder is not empty.");
202
- await this.dbRequest("delete", [r]);
203
- }
204
- /**
205
- * Create a directory.
206
- * @param options options for the mkdir
207
- * @return a promise that resolves with the mkdir result
208
- */
209
- async mkdir(e) {
210
- const r = this.getPath(e.directory, e.path), t = e.recursive, i = r.substr(0, r.lastIndexOf("/")), n = (r.match(/\//g) || []).length, s = await this.dbRequest("get", [i]), a = await this.dbRequest("get", [r]);
211
- if (n === 1)
212
- throw Error("Cannot create Root directory");
213
- if (a !== void 0)
214
- throw Error("Current directory does already exist.");
215
- if (!t && n !== 2 && s === void 0)
216
- throw Error("Parent directory must exist");
217
- if (t && n !== 2 && s === void 0) {
218
- const d = i.substr(i.indexOf("/", 1));
219
- await this.mkdir({
220
- path: d,
221
- directory: e.directory,
222
- recursive: t
223
- });
224
- }
225
- const c = Date.now(), o = {
226
- path: r,
227
- folder: i,
228
- type: "directory",
229
- size: 0,
230
- ctime: c,
231
- mtime: c
232
- };
233
- await this.dbRequest("put", [o]);
234
- }
235
- /**
236
- * Remove a directory
237
- * @param options the options for the directory remove
238
- */
239
- async rmdir(e) {
240
- const { path: r, directory: t, recursive: i } = e, n = this.getPath(t, r), s = await this.dbRequest("get", [n]);
241
- if (s === void 0)
242
- throw Error("Folder does not exist.");
243
- if (s.type !== "directory")
244
- throw Error("Requested path is not a directory");
245
- const a = await this.readdir({ path: r, directory: t });
246
- if (a.files.length !== 0 && !i)
247
- throw Error("Folder is not empty");
248
- for (const c of a.files) {
249
- const o = `${r}/${c.name}`;
250
- (await this.stat({ path: o, directory: t })).type === "file" ? await this.deleteFile({ path: o, directory: t }) : await this.rmdir({ path: o, directory: t, recursive: i });
251
- }
252
- await this.dbRequest("delete", [n]);
253
- }
254
- /**
255
- * Return a list of files from the directory (not recursive)
256
- * @param options the options for the readdir operation
257
- * @return a promise that resolves with the readdir directory listing result
258
- */
259
- async readdir(e) {
260
- const r = this.getPath(e.directory, e.path), t = await this.dbRequest("get", [r]);
261
- if (e.path !== "" && t === void 0)
262
- throw Error("Folder does not exist.");
263
- const i = await this.dbIndexRequest("by_folder", "getAllKeys", [IDBKeyRange.only(r)]);
264
- return { files: await Promise.all(i.map(async (s) => {
265
- let a = await this.dbRequest("get", [s]);
266
- return a === void 0 && (a = await this.dbRequest("get", [s + "/"])), {
267
- name: s.substring(r.length + 1),
268
- type: a.type,
269
- size: a.size,
270
- ctime: a.ctime,
271
- mtime: a.mtime,
272
- uri: a.path
273
- };
274
- })) };
275
- }
276
- /**
277
- * Return full File URI for a path and directory
278
- * @param options the options for the stat operation
279
- * @return a promise that resolves with the file stat result
280
- */
281
- async getUri(e) {
282
- const r = this.getPath(e.directory, e.path);
283
- let t = await this.dbRequest("get", [r]);
284
- return t === void 0 && (t = await this.dbRequest("get", [r + "/"])), {
285
- uri: (t == null ? void 0 : t.path) || r
286
- };
287
- }
288
- /**
289
- * Return data about a file
290
- * @param options the options for the stat operation
291
- * @return a promise that resolves with the file stat result
292
- */
293
- async stat(e) {
294
- const r = this.getPath(e.directory, e.path);
295
- let t = await this.dbRequest("get", [r]);
296
- if (t === void 0 && (t = await this.dbRequest("get", [r + "/"])), t === void 0)
297
- throw Error("Entry does not exist.");
298
- return {
299
- type: t.type,
300
- size: t.size,
301
- ctime: t.ctime,
302
- mtime: t.mtime,
303
- uri: t.path
304
- };
305
- }
306
- /**
307
- * Rename a file or directory
308
- * @param options the options for the rename operation
309
- * @return a promise that resolves with the rename result
310
- */
311
- async rename(e) {
312
- await this._copy(e, !0);
313
- }
314
- /**
315
- * Copy a file or directory
316
- * @param options the options for the copy operation
317
- * @return a promise that resolves with the copy result
318
- */
319
- async copy(e) {
320
- return this._copy(e, !1);
321
- }
322
- async requestPermissions() {
323
- return { publicStorage: "granted" };
324
- }
325
- async checkPermissions() {
326
- return { publicStorage: "granted" };
327
- }
328
- /**
329
- * Function that can perform a copy or a rename
330
- * @param options the options for the rename operation
331
- * @param doRename whether to perform a rename or copy operation
332
- * @return a promise that resolves with the result
333
- */
334
- async _copy(e, r = !1) {
335
- let { toDirectory: t } = e;
336
- const { to: i, from: n, directory: s } = e;
337
- if (!i || !n)
338
- throw Error("Both to and from must be provided");
339
- t || (t = s);
340
- const a = this.getPath(s, n), c = this.getPath(t, i);
341
- if (a === c)
342
- return {
343
- uri: c
344
- };
345
- if (R(a, c))
346
- throw Error("To path cannot contain the from path");
347
- let o;
348
- try {
349
- o = await this.stat({
350
- path: i,
351
- directory: t
352
- });
353
- } catch {
354
- const l = i.split("/");
355
- l.pop();
356
- const f = l.join("/");
357
- if (l.length > 0 && (await this.stat({
358
- path: f,
359
- directory: t
360
- })).type !== "directory")
361
- throw new Error("Parent directory of the to path is a file");
362
- }
363
- if (o && o.type === "directory")
364
- throw new Error("Cannot overwrite a directory with a file");
365
- const d = await this.stat({
366
- path: n,
367
- directory: s
368
- }), h = async (u, l, f) => {
369
- const p = this.getPath(t, u), b = await this.dbRequest("get", [p]);
370
- b.ctime = l, b.mtime = f, await this.dbRequest("put", [b]);
371
- }, y = d.ctime ? d.ctime : Date.now();
372
- switch (d.type) {
373
- case "file": {
374
- const u = await this.readFile({
375
- path: n,
376
- directory: s
377
- });
378
- r && await this.deleteFile({
379
- path: n,
380
- directory: s
381
- });
382
- let l;
383
- !(u.data instanceof Blob) && !this.isBase64String(u.data) && (l = E.UTF8);
384
- const f = await this.writeFile({
385
- path: i,
386
- directory: t,
387
- data: u.data,
388
- encoding: l
389
- });
390
- return r && await h(i, y, d.mtime), f;
391
- }
392
- case "directory": {
393
- if (o)
394
- throw Error("Cannot move a directory over an existing object");
395
- try {
396
- await this.mkdir({
397
- path: i,
398
- directory: t,
399
- recursive: !1
400
- }), r && await h(i, y, d.mtime);
401
- } catch {
402
- }
403
- const u = (await this.readdir({
404
- path: n,
405
- directory: s
406
- })).files;
407
- for (const l of u)
408
- await this._copy({
409
- from: `${n}/${l.name}`,
410
- to: `${i}/${l.name}`,
411
- directory: s,
412
- toDirectory: t
413
- }, r);
414
- r && await this.rmdir({
415
- path: n,
416
- directory: s
417
- });
418
- }
419
- }
420
- return {
421
- uri: c
422
- };
423
- }
424
- isBase64String(e) {
425
- try {
426
- return btoa(atob(e)) == e;
427
- } catch {
428
- return !1;
429
- }
430
- }
431
- }
432
- g._debug = !0;
433
- export {
434
- g as FilesystemWeb
435
- };
@@ -1,12 +0,0 @@
1
- import { W as e } from "./mod-HDegGPrf.js";
2
- class s extends e {
3
- async enable() {
4
- console.log("Immersive mode is only available on Android");
5
- }
6
- async disable() {
7
- console.log("Immersive mode is only available on Android");
8
- }
9
- }
10
- export {
11
- s as ImmersiveModeWeb
12
- };
package/planned.md DELETED
@@ -1,103 +0,0 @@
1
- # Planned: Browser-based simulation mode
2
-
3
- ## Motivation
4
-
5
- The current simulation framework is headless — it bypasses rendering entirely and computes responseData directly in Node. This is fast (hundreds of participants in seconds) but doesn't test that the UI actually works. A browser-based mode would render components in a real browser and drive them with programmatic interactions, catching rendering bugs, event handler issues, and timing problems.
6
-
7
- ## Key design insight
8
-
9
- The existing **simulators stay unchanged**. They already encode *what* the participant decides (pick choice B, wait 2800ms, type "hello"). Only the execution layer changes — instead of directly building responseData from simulator output, a DOM driver translates decisions into browser interactions and lets components call `next()` naturally.
10
-
11
- ```
12
- Simulator (shared): "participant picks choice B after 2800ms"
13
- Headless driver (current): constructs responseData directly → fast, no DOM
14
- DOM driver (new): waits 2800ms, clicks the radio button → component calls next() with real data
15
- ```
16
-
17
- ## Architecture
18
-
19
- ### Two simulation modes
20
-
21
- - `headless` (existing) — Node subprocesses, no browser, fast bulk data generation
22
- - `browser` (new) — Playwright browser contexts, real rendering, slow but thorough
23
-
24
- The consumer chooses the mode in their simulate.ts config. Participant definitions, simulators, and timeline are identical between modes.
25
-
26
- ### Component DOM drivers
27
-
28
- Each component type gets a DOM driver function that maps simulator output to browser actions:
29
-
30
- ```ts
31
- type DOMDriver = (
32
- page: Page, // Playwright page
33
- simulatorOutput: { value: any; duration: number },
34
- trialProps: Record<string, any>,
35
- ) => Promise<void>;
36
- ```
37
-
38
- The generic driver loop per trial:
39
- 1. Wait for the component to mount (detect a known selector or mutation)
40
- 2. Call the simulator to get the participant's decision
41
- 3. Wait `duration` ms
42
- 4. Call the component-specific DOM driver
43
- 5. Wait for the experiment runner to advance (next component mounts)
44
-
45
- ### Per-component complexity
46
-
47
- | Component | DOM driver complexity | Notes |
48
- |---|---|---|
49
- | Text | Trivial (~10 lines) | Wait, click button |
50
- | PlainInput | Trivial (~10 lines) | Type into input, click button |
51
- | Tutorial | Simple (~15 lines) | Click next arrow per slide |
52
- | Upload | Trivial (~10 lines) | Click submit button |
53
- | EnterFullscreen | Trivial (~5 lines) | Click button (fullscreen API may need mocking) |
54
- | ExitFullscreen | Zero | Auto-advances |
55
- | CheckDevice | Zero | Auto-advances |
56
- | CanvasBlock | Medium (~30-50 lines) | Simulate mouse/keyboard events on canvas |
57
- | RDK | Medium (~20-30 lines) | Keyboard response on canvas |
58
- | **Quest (SurveyJS)** | **Hard (~80-100 lines)** | Per-question-type selectors against SurveyJS DOM |
59
-
60
- **Quest is the riskiest part** — SurveyJS's internal DOM structure is an implementation detail that can change between versions. Each question type (rating, radiogroup, checkbox, text, boolean, matrix, dropdown) needs its own selector logic.
61
-
62
- ### Orchestration
63
-
64
- Replace `child_process.spawn` workers with Playwright browser contexts:
65
-
66
- 1. Start Vite dev server (or serve the built app)
67
- 2. For each participant: open a new browser context, navigate to the app URL with appropriate params
68
- 3. Run the driver loop until the experiment completes
69
- 4. Collect results from the backend (same upload path as headless)
70
- 5. Tear down contexts and server
71
-
72
- Concurrency is limited by browser resources rather than CPU cores. 4-8 parallel contexts is realistic.
73
-
74
- ### Synchronization
75
-
76
- The main technical challenge beyond SurveyJS DOM selectors. Need to reliably detect:
77
- - Component has mounted and is interactive (not mid-animation)
78
- - `next()` has been called and the next component is rendering
79
- - The experiment has completed
80
-
81
- Options: MutationObserver polling, custom data attributes on the experiment runner, or Playwright's `waitForSelector` / `waitForFunction`.
82
-
83
- ## Estimated scope
84
-
85
- ~400-500 lines of new code:
86
- - Browser orchestrator: ~100-150 lines
87
- - Generic driver loop: ~50 lines
88
- - All component DOM drivers: ~200-250 lines
89
-
90
- Existing code changes: minimal. Possibly add data attributes to ExperimentRunner for synchronization (e.g., `data-reactive-component-type` on the active component wrapper).
91
-
92
- ## Constraints
93
-
94
- - **Speed**: ~100x slower than headless. This is for smoke testing (1-5 participants), not bulk generation.
95
- - **Dependency**: Playwright becomes a (dev) dependency for consumers using this mode.
96
- - **Fragility**: SurveyJS DOM selectors will need maintenance when upgrading survey-core.
97
- - **Fullscreen**: Browser automation and fullscreen API don't mix well. EnterFullscreen/ExitFullscreen may need to be mocked or skipped in browser mode.
98
-
99
- ## Not in scope
100
-
101
- - Replacing the headless simulation mode (it remains the default)
102
- - Visual regression testing (screenshot comparison)
103
- - Recording/replaying real participant sessions
package/postcss.config.js DELETED
@@ -1,6 +0,0 @@
1
- export default {
2
- plugins: {
3
- '@tailwindcss/postcss': {},
4
- autoprefixer: {},
5
- },
6
- }
@@ -1,25 +0,0 @@
1
- // Loader hooks for handling Vite's ?raw import suffix in Node.
2
- // Strips ?raw from specifiers and returns file contents as string exports.
3
- import { readFileSync } from 'fs';
4
- import { fileURLToPath } from 'url';
5
-
6
- const RAW_PATTERN = /\?raw$/;
7
- const RAW_EXTENSIONS = ['.csv', '.txt', '.svg', '.glsl', '.md'];
8
-
9
- export function resolve(specifier, context, nextResolve) {
10
- if (RAW_PATTERN.test(specifier)) {
11
- return nextResolve(specifier.replace(RAW_PATTERN, ''), context);
12
- }
13
- return nextResolve(specifier, context);
14
- }
15
-
16
- export function load(url, context, nextLoad) {
17
- try {
18
- const path = fileURLToPath(url);
19
- if (RAW_EXTENSIONS.some(ext => path.endsWith(ext))) {
20
- const content = readFileSync(path, 'utf8');
21
- return { format: 'module', source: `export default ${JSON.stringify(content)};`, shortCircuit: true };
22
- }
23
- } catch { /* not a file URL, pass through */ }
24
- return nextLoad(url, context);
25
- }
package/raw-loader.mjs DELETED
@@ -1,5 +0,0 @@
1
- // Node loader that handles Vite's ?raw import suffix and raw file imports.
2
- // Registers itself as a module loader hook via module.register().
3
- import { register } from 'module';
4
-
5
- register(new URL('./raw-loader-hooks.mjs', import.meta.url));