Skip to content

Align various implementation details between hed-javascript and hed-typescript - #947

Merged
VisLab merged 4 commits into
hed-standard:mainfrom
VisLab:fix_required
Oct 29, 2026
Merged

VisLab merged 4 commits into
hed-standard:mainfrom
VisLab:fix_required

Conversation

@VisLab

@VisLab VisLab commented Oct 29, 2026

Copy link
Copy Markdown
Member

No description provided.

VisLab and others added 3 commits October 29, 2026 09:22
- Split schema loading into AbstractHedSchemaLoader with Node.js and browser
  subclasses; the browser build gets HedSchemaBrowserLoader through the
  package.json browser field.
- Load bundled schemas on demand: one ESM chunk per schema, CommonJS inline.
- Move BidsDirectoryAccessor to its own module with a browser stand-in, replace
  node:path with string helpers, and drop the node-modules polyfill plugin.
- Reject a library listed twice in one merge group when the version string is
  parsed (multipleVersionsOfSameLibrarySchema).
- parseHedStrings returns null for the whole list if any string fails.
- Spec tests read hed-tests schemas through a mock loader.
- Align BIDS class shapes and helpers with hed-typescript; remove the unused
  getDir helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every path that reaches the Event constructor assigns defName first, so the
initial null was never read (ESLint no-useless-assignment).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The duplicate-library check rejects valid merges of distinct local schema files because it compares empty library values before loading their XML identities.

1 open issue
What changed in this PR

This PR aligns hed-javascript’s schema loading, BIDS handling, and utility behavior with hed-typescript, while separating browser and Node.js file access.

Changes:

  • Introduces environment-specific schema loaders and on-demand schema chunks for the browser build, removing Node.js polyfills.
  • Refactors BIDS accessors, parsing helpers, and validation internals.
  • Updates duplicate-schema validation, parser return types, tests, and documentation.
File Description
types/​index.d.ts Updates accessor constructor and nullable parser results.
tests/​testHelpers/​testUtilities.js Corrects the named issue import.
tests/​otherTests/​webAccessor.spec.js Checks browser schema-loader selection.
tests/​otherTests/​schemaParser.spec.js Updates the XML collection import.
tests/​otherTests/​schemaLoader.spec.js Adds loader behavior and error tests.
tests/​otherTests/​paths.spec.js Tests browser-compatible path helpers.
tests/​otherTests/​parser.spec.js Tests whole-list failure results.
tests/​otherTests/​datasetParser.spec.js Updates accessor imports and category assertions.
tests/​otherTests/​dataset.spec.js Tests browser directory-access rejection.
tests/​otherTests/​build.spec.js Checks browser bundle isolation and schema chunks.
tests/​jsonTestData/​schemaBuildTests.data.js Updates duplicate-schema error cases.
src/​utils/​types.js Adds JSON-object and string-record guards.
src/​utils/​string.js Adds object-only JSON parsing.
src/​utils/​paths.js Refactors path organization and removes Node.js dependency.
src/​utils/​files.js Keeps local file reading; relocates HTTPS reading.
src/​utils/​files.browser.js Removes obsolete browser file utilities.
src/​schema/​xmlType.js Houses the XML collection and compatibility alias.
src/​schema/​xmlCollection.js Removes the relocated collection module.
src/​schema/​specs.js Rejects duplicate schema names during specification construction.
src/​schema/​loader.js Implements the Node.js schema-loader subclass.
src/​schema/​init.js Delegates schema construction to the loader.
src/​schema/​config.js Loads bundled schemas through dynamic imports.
src/​schema/​browserLoader.js Adds schema loading without local file access.
src/​schema/​abstractLoader.js Centralizes schema loading and merge construction.
src/​schema/​__mocks__/​loader.js Adds test-schema lookup with bundled fallback.
src/​parser/​parser.js Returns a null list when any string fails.
src/​parser/​eventManager.js Leaves absent definition names undefined.
src/​issues/​data.js Replaces the duplicate-schema diagnostic.
src/​bids/​webAccessor.js Injects a browser-specific schema builder.
src/​bids/​validator/​validator.js Clarifies validator documentation.
src/​bids/​validator/​tsvValidator.js Consolidates issue collection and privatizes helpers.
src/​bids/​validator/​sidecarValidator.js Documents internal validation helpers.
src/​bids/​types/​tsv.js Extracts TSV parsing and HED-column initialization.
src/​bids/​types/​json.js Uses the shared JSON-object guard.
src/​bids/​types/​file.js Privatizes validator storage and adds toString().
src/​bids/​types/​dataset.js Uses JSON-file objects and portable path parsing.
src/​bids/​tsvParser.js Adds TSV typedefs and renames an internal helper.
src/​bids/​schema.js Accepts an injectable schema loader.
src/​bids/​index.js Updates accessor imports and removes the default export.
src/​bids/​directoryAccessor.js Separates Node.js directory access.
src/​bids/​directoryAccessor.browser.js Explicitly rejects browser directory access.
src/​bids/​datasetParser.js Injects schema builders and isolates the base accessor.
spec_tests/​hedTests.spec.js Uses the shared mock schema loader.
package.json Updates browser mappings and removes the polyfill dependency.
package-lock.json Removes polyfill-related dependency entries.
esbuild.mjs Enables browser schema chunks without Node.js polyfills.
CHANGELOG.md Records alignment and behavior changes.
.github/​copilot-instructions.md Updates the documented module layout.

Review effort: Balanced

Comment thread src/schema/specs.js Resolved
A specification with only a local path has an empty library name until its
file is read, so the parse-time duplicate check rejected a standard schema
file merged with a library file. The parse-time check now skips local-path
specifications, and buildSchemaObjects checks the names of the loaded schemas.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@VisLab
VisLab merged commit ebf7fae into hed-standard:main Oct 29, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

alignment Alignment between hed-javascript and hed-typescript. required-update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants