mwg API
    Preparing search index...

    Function compilePackages

    • Compiles a content set: each character expands into a unit_type named packageId:id, and the result is an ordinary compiled game, with the packages' _() strings in messages and the packages' media paths in assets. A set with no package compiles to an empty game.

      Parameters

      Returns MwlCompiledGame

      import { compilePackages, encodePackage, loadPackage, mergePackage } from '@datamoc/mwg/mwl';

      const source = "[{ tag: 'package', id: 'marta', version: '1.0.0' }, { tag: 'character', id: 'marta', hitpoints: 28 }]";
      const bytes = await encodePackage([{ path: 'content.mwl', data: new TextEncoder().encode(source) }]);
      console.log(compilePackages(mergePackage(await loadPackage(bytes))).roots[0]?.attributes.id); // 'marta:marta'