Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ The study configurations are defined in JSON files with schemas. These configs s
Imported Libraries
We provide several libraries to facilitate the development of user studies, such as vlat, mini-vlat, nasa-tlx, color-blindness, and more. These libraries are components and sequences that are defined in public/libraries/. Each library has its own folder containing the necessary code and assets. Use only libraries that exist under public/libraries/ (no ad-hoc local component imports in study configs). You can import these libraries into your study configs to enhance the functionality and user experience of your studies by adding the libraries to the top level `importedLibraries` field in the study config, and then referencing the components in the `baseComponent` field or in sequences and the sequences in the `sequences` field. When referencing the components and sequences use the following syntax `"$libraryName.components.componentName"` and `"$libraryName.sequences.sequenceName"` respectively.

Large Media Assets
Large bundled-library media should not be committed directly to this repository. Put heavyweight shared library assets in the public `revisit-studies/library-assets` repository, tag the asset release, and reference files from study/library configs with tag-pinned raw GitHub URLs such as `https://raw.githubusercontent.com/revisit-studies/library-assets/v1/...`.

Storage Engines
ReVISit supports multiple storage backends for storing study data, including Firebase and Supabase. This allows researchers to choose the backend that best fits their needs in terms of scalability, ease of use, and integration with other tools. The storage engines are abstracted in the codebase, allowing for easy addition of new storage solutions in the future. The storage engine implementations can be found in src/storage/ directory.

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
120 changes: 60 additions & 60 deletions public/libraries/calvi/config.json

Large diffs are not rendered by default.

Binary file removed public/libraries/vlat/assets/VLAT1.png
Diff not rendered.
Binary file removed public/libraries/vlat/assets/VLAT10.png
Diff not rendered.
Binary file removed public/libraries/vlat/assets/VLAT11.png
Diff not rendered.
Binary file removed public/libraries/vlat/assets/VLAT12.png
Diff not rendered.
Binary file removed public/libraries/vlat/assets/VLAT2.png
Diff not rendered.
Binary file removed public/libraries/vlat/assets/VLAT3.png
Diff not rendered.
Binary file removed public/libraries/vlat/assets/VLAT4.png
Diff not rendered.
Binary file removed public/libraries/vlat/assets/VLAT5.png
Diff not rendered.
Binary file removed public/libraries/vlat/assets/VLAT6.png
Diff not rendered.
Binary file removed public/libraries/vlat/assets/VLAT7.png
Diff not rendered.
Binary file removed public/libraries/vlat/assets/VLAT8.png
Diff not rendered.
Binary file removed public/libraries/vlat/assets/VLAT9.png
Diff not rendered.
26 changes: 13 additions & 13 deletions public/libraries/vlat/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"baseComponents": {
"line": {
"type": "image",
"path": "libraries/vlat/assets/VLAT1.png",
"path": "https://raw.githubusercontent.com/revisit-studies/library-assets/v1/vlat/VLAT1.png",
"style": {
"width": "800px"
},
Expand All @@ -16,7 +16,7 @@
},
"bar": {
"type": "image",
"path": "libraries/vlat/assets/VLAT2.png",
"path": "https://raw.githubusercontent.com/revisit-studies/library-assets/v1/vlat/VLAT2.png",
"style": {
"width": "800px"
},
Expand All @@ -26,7 +26,7 @@
},
"stackbar": {
"type": "image",
"path": "libraries/vlat/assets/VLAT3.png",
"path": "https://raw.githubusercontent.com/revisit-studies/library-assets/v1/vlat/VLAT3.png",
"style": {
"width": "800px"
},
Expand All @@ -36,7 +36,7 @@
},
"stackbar100": {
"type": "image",
"path": "libraries/vlat/assets/VLAT4.png",
"path": "https://raw.githubusercontent.com/revisit-studies/library-assets/v1/vlat/VLAT4.png",
"style": {
"width": "800px"
},
Expand All @@ -46,7 +46,7 @@
},
"pie": {
"type": "image",
"path": "libraries/vlat/assets/VLAT5.png",
"path": "https://raw.githubusercontent.com/revisit-studies/library-assets/v1/vlat/VLAT5.png",
"style": {
"width": "800px"
},
Expand All @@ -56,7 +56,7 @@
},
"histogram": {
"type": "image",
"path": "libraries/vlat/assets/VLAT6.png",
"path": "https://raw.githubusercontent.com/revisit-studies/library-assets/v1/vlat/VLAT6.png",
"style": {
"width": "800px"
},
Expand All @@ -66,7 +66,7 @@
},
"scatterplot": {
"type": "image",
"path": "libraries/vlat/assets/VLAT7.png",
"path": "https://raw.githubusercontent.com/revisit-studies/library-assets/v1/vlat/VLAT7.png",
"style": {
"width": "800px"
},
Expand All @@ -76,7 +76,7 @@
},
"area": {
"type": "image",
"path": "libraries/vlat/assets/VLAT8.png",
"path": "https://raw.githubusercontent.com/revisit-studies/library-assets/v1/vlat/VLAT8.png",
"style": {
"width": "800px"
},
Expand All @@ -86,7 +86,7 @@
},
"stackarea": {
"type": "image",
"path": "libraries/vlat/assets/VLAT9.png",
"path": "https://raw.githubusercontent.com/revisit-studies/library-assets/v1/vlat/VLAT9.png",
"style": {
"width": "800px"
},
Expand All @@ -96,7 +96,7 @@
},
"bubble": {
"type": "image",
"path": "libraries/vlat/assets/VLAT10.png",
"path": "https://raw.githubusercontent.com/revisit-studies/library-assets/v1/vlat/VLAT10.png",
"style": {
"width": "800px"
},
Expand All @@ -106,7 +106,7 @@
},
"map": {
"type": "image",
"path": "libraries/vlat/assets/VLAT11.png",
"path": "https://raw.githubusercontent.com/revisit-studies/library-assets/v1/vlat/VLAT11.png",
"style": {
"width": "800px"
},
Expand All @@ -116,7 +116,7 @@
},
"treemap": {
"type": "image",
"path": "libraries/vlat/assets/VLAT12.png",
"path": "https://raw.githubusercontent.com/revisit-studies/library-assets/v1/vlat/VLAT12.png",
"style": {
"width": "800px"
},
Expand Down Expand Up @@ -1358,7 +1358,7 @@
"instruction": "What is the total length of the metro system in Beijing?",
"instructionLocation": "sidebar",
"type": "image",
"path": "libraries/vlat/assets/VLAT10.png",
"path": "https://raw.githubusercontent.com/revisit-studies/library-assets/v1/vlat/VLAT10.png",
"style": {
"width": "800px"
},
Expand Down
10 changes: 10 additions & 0 deletions src/controllers/tests/ComponentController.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,16 @@ describe('ImageController', () => {
const { container } = render(<ImageController currentConfig={{ type: 'image', path: '/found.png', response: [] }} />);
await waitFor(() => expect(container.querySelector('img')).toBeTruthy());
});

test('checks absolute image URLs without prefixing them', async () => {
const remotePath = 'https://raw.githubusercontent.com/revisit-studies/library-assets/v1/vlat/VLAT1.png';
vi.mocked(getStaticAssetByPath).mockResolvedValueOnce('image-data');

const { container } = render(<ImageController currentConfig={{ type: 'image', path: remotePath, response: [] }} />);

await waitFor(() => expect(getStaticAssetByPath).toHaveBeenCalledWith(remotePath));
expect(container.querySelector('img')?.getAttribute('src')).toBe(remotePath);
});
});

// ── MarkdownController ────────────────────────────────────────────────────────
Expand Down
36 changes: 36 additions & 0 deletions src/parser/tests/libraryParser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
ComponentBlock, DynamicBlock, LibraryConfig, StudyConfig, InheritedComponent, IndividualComponent, ParserErrorWarning,
} from '../types';
import { isDynamicBlock } from '../utils';
import calviConfig from '../../../public/libraries/calvi/config.json';
import vlatConfig from '../../../public/libraries/vlat/config.json';

function isComponentBlock(value: string | ComponentBlock | DynamicBlock): value is ComponentBlock {
return typeof value === 'object' && value !== null && 'components' in value && !isDynamicBlock(value);
Expand Down Expand Up @@ -1368,6 +1370,40 @@ describe('verifyLibraryUsage', () => {
});

describe('loadLibrariesParseNamespace', () => {
test('loads CALVI and VLAT configs with tag-pinned external image assets', async () => {
const libraryConfigs: Record<string, LibraryConfig> = {
calvi: calviConfig as LibraryConfig,
vlat: vlatConfig as LibraryConfig,
};

global.fetch = vi.fn().mockImplementation((path: URL | RequestInfo) => {
const pathString = path.toString();
const libraryName = pathString.includes('/calvi/')
? 'calvi'
: 'vlat';

return Promise.resolve({
text: async () => JSON.stringify(libraryConfigs[libraryName]),
});
});

const errors: ParserErrorWarning[] = [];
const warnings: ParserErrorWarning[] = [];

const result = await loadLibrariesParseNamespace(['calvi', 'vlat'], errors, warnings);
const assetBaseUrl = 'https://raw.githubusercontent.com/revisit-studies/library-assets/v1';
const calviN1 = result.calvi.components['$calvi.components.N1'] as { path: string };
const vlatLine = result.vlat.components['$vlat.components.line-value'] as { path: string };

expect(errors).toHaveLength(0);
expect(result.calvi.sequences?.full).toBeDefined();
expect(result.calvi.sequences?.specificBank).toBeDefined();
expect(result.calvi.sequences?.fullBank).toBeDefined();
expect(result.vlat.sequences?.full).toBeDefined();
expect(calviN1.path).toBe(`${assetBaseUrl}/calvi/questions/normal/N1.jpg`);
expect(vlatLine.path).toBe(`${assetBaseUrl}/vlat/VLAT1.png`);
});

test('loads libraries and namespaces components correctly', async () => {
const mockLibraryConfig = {
$schema: '',
Expand Down
Loading