Skip to content

Typedef fixes#16

Open
kookster wants to merge 5 commits intofeat/node_24_and_related_upgradesfrom
feat/typedef_fixes
Open

Typedef fixes#16
kookster wants to merge 5 commits intofeat/node_24_and_related_upgradesfrom
feat/typedef_fixes

Conversation

@kookster
Copy link
Copy Markdown
Member

I saw some other PRs for typedefs that weren't right and the typedefs for cart chunk and related other chunks were pretty vague, so this fixes those issues, and the export style - this obviously builds off PR #14 :

Bug:

  • toSampleRate(samples: number, ...) — parameter should be sampleRate, not samples

Chunk types are all object — these should have proper interfaces:

  • fact — has chunkId, chunkSize, dwSampleLength
  • cue — has chunkId, chunkSize, dwCuePoints, points (array of point objects)
  • smpl — has 12 fields plus loops array (each with 6 fields)
  • bext — has 17 fields (BWF metadata)
  • mext — has 7 fields (MPEG extension)
  • cart — has 22 fields including postTimer array
  • iXML, _PMX — have chunkId, chunkSize, value
  • ds64 — has 9 fields (RF64 size info)
  • junk — has chunkId, chunkSize, chunkData

Missing from fmt type:

  • MPEG fields (headLayer, headBitRate, headMode, headModeExt, headEmphasis, headFlags, ptsLow, ptsHigh) — should be optional

Return types too vague:

  • listTags() returns object — should be Record<string, string>
  • listCuePoints() returns Array — should have a CuePoint interface with all 15 fields

    Missing method:

    • getLISTIndex(listType: string): number | null — public method on WaveFileTagEditor

    Export style:

    • Uses export = wavefile / declare namespace (CJS-style). Now that the package has "type": "module" and ESM exports, this should use export class WaveFile instead.

The parameter was named 'samples' but should be 'sampleRate' to match
the actual implementation in wavefile-converter.js.
Replace generic 'object' types with specific interfaces for:
fact, cue, smpl, bext, mext, cart, iXML, ds64, LIST, junk, _PMX chunks.
Also adds sub-types for cue points, smpl loops, and cart post timers.
Adds MPEG fields (headLayer, headBitRate, etc.) to the fmt chunk type.
…uePoint

- listTags() now returns Record<string, string> instead of object
- listCuePoints() now returns CuePointOutput[] with all 15 fields typed
- setCuePoint() now accepts CuePointInput with required position and
  optional label, end, and region attributes
The package now uses "type": "module" with ESM exports, so the type
definitions should use 'export class' and 'export type' instead of
'export = wavefile' with 'declare namespace'. All types are now
individually exported so consumers can import them directly.
Consumers using default imports (e.g. import wavefile from 'prx-wavefile')
will continue to work alongside named imports (import { WaveFile }).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant