import { encodePackage, loadPackage, mergePackage, packageContent } from '@datamoc/mwg/mwl';
const source = "[{ tag: 'package', id: 'marta', version: '1.0.0' }, { tag: 'sound_effect', id: 'ouch', chip: 'sn76489' }]";
const bytes = await encodePackage([{ path: 'content.mwl', data: new TextEncoder().encode(source) }]);
const set = mergePackage(await loadPackage(bytes));
console.log(Object.keys(packageContent(set).soundEffects)); // ['marta:ouch']
Adds a package to a content set (a new set; the old one is untouched). Dependencies named by
importmust already be in the set. Two versions of one package may coexist: the newest owns the plainpackageId:idnames, every version answers topackageId@version:id.