pptx-glimpse 0.9.0 → 0.10.0

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.
package/dist/index.cjs CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  DEFAULT_FONT_MAPPING: () => DEFAULT_FONT_MAPPING,
24
+ clearFontCache: () => clearFontCache,
24
25
  collectUsedFonts: () => collectUsedFonts,
25
26
  convertPptxToPng: () => convertPptxToPng,
26
27
  convertPptxToSvg: () => convertPptxToSvg,
@@ -1544,7 +1545,23 @@ function collectFontNames(font) {
1544
1545
  }
1545
1546
  return names;
1546
1547
  }
1548
+ function buildCacheKey(additionalFontDirs, fontMapping) {
1549
+ const dirsKey = additionalFontDirs ? [...additionalFontDirs].sort().join("\0") : "";
1550
+ const mappingKey = fontMapping ? JSON.stringify(fontMapping, Object.keys(fontMapping).sort()) : "";
1551
+ return `${dirsKey}
1552
+ ${mappingKey}`;
1553
+ }
1554
+ var cachedSetup = null;
1555
+ var cachedSetupKey = null;
1556
+ function clearFontCache() {
1557
+ cachedSetup = null;
1558
+ cachedSetupKey = null;
1559
+ }
1547
1560
  async function createOpentypeSetupFromSystem(additionalFontDirs, fontMapping) {
1561
+ const key = buildCacheKey(additionalFontDirs, fontMapping);
1562
+ if (cachedSetup && cachedSetupKey === key) {
1563
+ return cachedSetup;
1564
+ }
1548
1565
  const opentype = await tryLoadOpentype();
1549
1566
  if (!opentype) return null;
1550
1567
  const fontFilePaths = collectFontFilePaths(additionalFontDirs);
@@ -1576,7 +1593,10 @@ async function createOpentypeSetupFromSystem(additionalFontDirs, fontMapping) {
1576
1593
  resolverFonts,
1577
1594
  firstResolverFont ?? void 0
1578
1595
  );
1579
- return { measurer, fontResolver };
1596
+ const setup = { measurer, fontResolver };
1597
+ cachedSetup = setup;
1598
+ cachedSetupKey = key;
1599
+ return setup;
1580
1600
  }
1581
1601
 
1582
1602
  // src/font/script-font-context.ts
@@ -9004,6 +9024,7 @@ function collectFontsFromTextBody(textBody, fonts) {
9004
9024
  // Annotate the CommonJS export names for ESM import in node:
9005
9025
  0 && (module.exports = {
9006
9026
  DEFAULT_FONT_MAPPING,
9027
+ clearFontCache,
9007
9028
  collectUsedFonts,
9008
9029
  convertPptxToPng,
9009
9030
  convertPptxToSvg,
package/dist/index.d.cts CHANGED
@@ -177,6 +177,12 @@ interface OpentypeSetup {
177
177
  * 同じ Font オブジェクトを measurer と fontResolver の両方に渡す。
178
178
  */
179
179
  declare function createOpentypeSetupFromBuffers(fontBuffers: FontBuffer[], fontMapping?: FontMapping): Promise<OpentypeSetup | null>;
180
+ /**
181
+ * フォントオブジェクトキャッシュをクリアする。
182
+ * 通常は呼び出す必要はないが、フォントのインストール/アンインストール後に
183
+ * 強制的に再読み込みしたい場合に使用する。
184
+ */
185
+ declare function clearFontCache(): void;
180
186
 
181
187
  /**
182
188
  * resvg-wasm の WASM モジュールを初期化する。
@@ -185,4 +191,4 @@ declare function createOpentypeSetupFromBuffers(fontBuffers: FontBuffer[], fontM
185
191
  */
186
192
  declare function initResvgWasm(): Promise<void>;
187
193
 
188
- export { type ConvertOptions, DEFAULT_FONT_MAPPING, type FontBuffer, type FontMapping, type LogLevel, type OpentypeSetup, type SlideImage, type SlideSvg, type UsedFonts, type WarningEntry, type WarningSummary, collectUsedFonts, convertPptxToPng, convertPptxToSvg, createFontMapping, createOpentypeSetupFromBuffers, createOpentypeTextMeasurerFromBuffers, getMappedFont, getWarningEntries, getWarningSummary, initResvgWasm };
194
+ export { type ConvertOptions, DEFAULT_FONT_MAPPING, type FontBuffer, type FontMapping, type LogLevel, type OpentypeSetup, type SlideImage, type SlideSvg, type UsedFonts, type WarningEntry, type WarningSummary, clearFontCache, collectUsedFonts, convertPptxToPng, convertPptxToSvg, createFontMapping, createOpentypeSetupFromBuffers, createOpentypeTextMeasurerFromBuffers, getMappedFont, getWarningEntries, getWarningSummary, initResvgWasm };
package/dist/index.d.ts CHANGED
@@ -177,6 +177,12 @@ interface OpentypeSetup {
177
177
  * 同じ Font オブジェクトを measurer と fontResolver の両方に渡す。
178
178
  */
179
179
  declare function createOpentypeSetupFromBuffers(fontBuffers: FontBuffer[], fontMapping?: FontMapping): Promise<OpentypeSetup | null>;
180
+ /**
181
+ * フォントオブジェクトキャッシュをクリアする。
182
+ * 通常は呼び出す必要はないが、フォントのインストール/アンインストール後に
183
+ * 強制的に再読み込みしたい場合に使用する。
184
+ */
185
+ declare function clearFontCache(): void;
180
186
 
181
187
  /**
182
188
  * resvg-wasm の WASM モジュールを初期化する。
@@ -185,4 +191,4 @@ declare function createOpentypeSetupFromBuffers(fontBuffers: FontBuffer[], fontM
185
191
  */
186
192
  declare function initResvgWasm(): Promise<void>;
187
193
 
188
- export { type ConvertOptions, DEFAULT_FONT_MAPPING, type FontBuffer, type FontMapping, type LogLevel, type OpentypeSetup, type SlideImage, type SlideSvg, type UsedFonts, type WarningEntry, type WarningSummary, collectUsedFonts, convertPptxToPng, convertPptxToSvg, createFontMapping, createOpentypeSetupFromBuffers, createOpentypeTextMeasurerFromBuffers, getMappedFont, getWarningEntries, getWarningSummary, initResvgWasm };
194
+ export { type ConvertOptions, DEFAULT_FONT_MAPPING, type FontBuffer, type FontMapping, type LogLevel, type OpentypeSetup, type SlideImage, type SlideSvg, type UsedFonts, type WarningEntry, type WarningSummary, clearFontCache, collectUsedFonts, convertPptxToPng, convertPptxToSvg, createFontMapping, createOpentypeSetupFromBuffers, createOpentypeTextMeasurerFromBuffers, getMappedFont, getWarningEntries, getWarningSummary, initResvgWasm };
package/dist/index.js CHANGED
@@ -1508,7 +1508,23 @@ function collectFontNames(font) {
1508
1508
  }
1509
1509
  return names;
1510
1510
  }
1511
+ function buildCacheKey(additionalFontDirs, fontMapping) {
1512
+ const dirsKey = additionalFontDirs ? [...additionalFontDirs].sort().join("\0") : "";
1513
+ const mappingKey = fontMapping ? JSON.stringify(fontMapping, Object.keys(fontMapping).sort()) : "";
1514
+ return `${dirsKey}
1515
+ ${mappingKey}`;
1516
+ }
1517
+ var cachedSetup = null;
1518
+ var cachedSetupKey = null;
1519
+ function clearFontCache() {
1520
+ cachedSetup = null;
1521
+ cachedSetupKey = null;
1522
+ }
1511
1523
  async function createOpentypeSetupFromSystem(additionalFontDirs, fontMapping) {
1524
+ const key = buildCacheKey(additionalFontDirs, fontMapping);
1525
+ if (cachedSetup && cachedSetupKey === key) {
1526
+ return cachedSetup;
1527
+ }
1512
1528
  const opentype = await tryLoadOpentype();
1513
1529
  if (!opentype) return null;
1514
1530
  const fontFilePaths = collectFontFilePaths(additionalFontDirs);
@@ -1540,7 +1556,10 @@ async function createOpentypeSetupFromSystem(additionalFontDirs, fontMapping) {
1540
1556
  resolverFonts,
1541
1557
  firstResolverFont ?? void 0
1542
1558
  );
1543
- return { measurer, fontResolver };
1559
+ const setup = { measurer, fontResolver };
1560
+ cachedSetup = setup;
1561
+ cachedSetupKey = key;
1562
+ return setup;
1544
1563
  }
1545
1564
 
1546
1565
  // src/font/script-font-context.ts
@@ -8966,6 +8985,7 @@ function collectFontsFromTextBody(textBody, fonts) {
8966
8985
  }
8967
8986
  export {
8968
8987
  DEFAULT_FONT_MAPPING,
8988
+ clearFontCache,
8969
8989
  collectUsedFonts,
8970
8990
  convertPptxToPng,
8971
8991
  convertPptxToSvg,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pptx-glimpse",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "A lightweight JavaScript library for rendering PowerPoint (.pptx) files as SVG or PNG in Node.js. No LibreOffice required.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",