@fontmin-rs/wasm 0.1.0-beta.4 → 0.1.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
package/dist/index.mjs CHANGED
@@ -255,10 +255,20 @@ async function optimizeBrowser(config) {
255
255
  let assets = config.assets.map(formatAsset);
256
256
  for (const plugin of config.plugins ?? []) {
257
257
  if (plugin.name === "glyph") {
258
- assets = await Promise.all(assets.map(async (asset) => asset.format === "ttf" ? {
259
- ...asset,
260
- contents: await subsetTtf(asset.contents, optionsOf(plugin))
261
- } : asset));
258
+ const options = optionsOf(plugin);
259
+ const subsetAssets = [];
260
+ for (const asset of assets) {
261
+ if (asset.format !== "ttf") {
262
+ subsetAssets.push(asset);
263
+ continue;
264
+ }
265
+ const subsetAsset = {
266
+ ...asset,
267
+ contents: await subsetTtf(asset.contents, options)
268
+ };
269
+ subsetAssets.push(...options.clone === true ? [asset, subsetAsset] : [subsetAsset]);
270
+ }
271
+ assets = subsetAssets;
262
272
  continue;
263
273
  }
264
274
  if (plugin.name === "unicodeSlices") {
@@ -316,11 +326,12 @@ async function optimizeBrowser(config) {
316
326
  if (icons.length > 0) {
317
327
  const options = optionsOf(plugin);
318
328
  const fontName = options.fontName ?? "iconfont";
319
- assets.push({
329
+ const ttfAsset = {
320
330
  contents: await svgsToTtf(icons, options),
321
331
  fileName: `${toKebabCase(fontName)}.ttf`,
322
332
  format: "ttf"
323
- });
333
+ };
334
+ assets = options.clone === true ? [...assets, ttfAsset] : [...assets.filter((asset) => asset.format !== "svg"), ttfAsset];
324
335
  }
325
336
  continue;
326
337
  }
@@ -348,16 +359,18 @@ async function optimizeBrowser(config) {
348
359
  assets = [...transformed, ...emitted];
349
360
  continue;
350
361
  }
351
- if (plugin.name === "otf2ttf" && optionsOf(plugin).clone === false) {
352
- assets = await Promise.all(assets.map(async (asset) => await convert(asset, plugin) ?? asset));
353
- continue;
354
- }
362
+ const clone = optionsOf(plugin).clone !== false;
363
+ const convertedAssets = [];
355
364
  const additions = [];
356
365
  for (const asset of assets) {
357
- const converted = await convert(asset, plugin);
358
- if (converted !== void 0) additions.push(converted);
366
+ const convertedAsset = await convert(asset, plugin);
367
+ if (convertedAsset === void 0) convertedAssets.push(asset);
368
+ else if (clone) {
369
+ convertedAssets.push(asset);
370
+ additions.push(convertedAsset);
371
+ } else convertedAssets.push(convertedAsset);
359
372
  }
360
- assets = [...assets, ...additions];
373
+ assets = [...convertedAssets, ...additions];
361
374
  }
362
375
  return assets;
363
376
  }
@@ -383,7 +396,7 @@ function converted(asset, format, contents) {
383
396
  function formatAsset(asset) {
384
397
  return {
385
398
  ...asset,
386
- format: formatOf(asset.fileName)
399
+ format: asset.format ?? formatOf(asset.fileName)
387
400
  };
388
401
  }
389
402
  function formatOf(fileName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fontmin-rs/wasm",
3
- "version": "0.1.0-beta.4",
3
+ "version": "0.1.0-rc.2",
4
4
  "description": "Browser WASM runtime for fontmin-rs.",
5
5
  "license": "MIT",
6
6
  "repository": {