@ox-content/vite-plugin 0.3.0-alpha.14 → 0.3.0-alpha.18

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
@@ -8102,6 +8102,63 @@ async function writeCache(cacheDir, key, png) {
8102
8102
  await fs_promises.writeFile(filePath, png);
8103
8103
  }
8104
8104
 
8105
+ //#endregion
8106
+ //#region \0@oxc-project+runtime@0.110.0/helpers/usingCtx.js
8107
+ function _usingCtx() {
8108
+ var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
8109
+ var n = Error();
8110
+ return n.name = "SuppressedError", n.error = r, n.suppressed = e, n;
8111
+ }, e = {}, n = [];
8112
+ function using(r, e) {
8113
+ if (null != e) {
8114
+ if (Object(e) !== e) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
8115
+ if (r) var o = e[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
8116
+ if (void 0 === o && (o = e[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r)) var t = o;
8117
+ if ("function" != typeof o) throw new TypeError("Object is not disposable.");
8118
+ t && (o = function o() {
8119
+ try {
8120
+ t.call(e);
8121
+ } catch (r) {
8122
+ return Promise.reject(r);
8123
+ }
8124
+ }), n.push({
8125
+ v: e,
8126
+ d: o,
8127
+ a: r
8128
+ });
8129
+ } else r && n.push({
8130
+ d: e,
8131
+ a: r
8132
+ });
8133
+ return e;
8134
+ }
8135
+ return {
8136
+ e,
8137
+ u: using.bind(null, !1),
8138
+ a: using.bind(null, !0),
8139
+ d: function d() {
8140
+ var o, t = this.e, s = 0;
8141
+ function next() {
8142
+ for (; o = n.pop();) try {
8143
+ if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next);
8144
+ if (o.d) {
8145
+ var r = o.d.call(o.v);
8146
+ if (o.a) return s |= 2, Promise.resolve(r).then(next, err);
8147
+ } else s |= 1;
8148
+ } catch (r) {
8149
+ return err(r);
8150
+ }
8151
+ if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve();
8152
+ if (t !== e) throw t;
8153
+ }
8154
+ function err(n) {
8155
+ return t = t !== e ? new r(n, t) : n, next();
8156
+ }
8157
+ return next();
8158
+ }
8159
+ };
8160
+ }
8161
+
8105
8162
  //#endregion
8106
8163
  //#region src/og-image/index.ts
8107
8164
  /**
@@ -8384,28 +8441,35 @@ async function computeTemplateSource(options, root) {
8384
8441
  * All errors are non-fatal: failures are reported in results but never throw.
8385
8442
  */
8386
8443
  async function generateOgImages(pages, options, root) {
8387
- if (pages.length === 0) return [];
8388
- const templateFn = await resolveTemplate(options, root);
8389
- const templateSource = await computeTemplateSource(options, root);
8390
- const cacheDir = path$1.join(root, ".cache", "og-images");
8391
- if (options.cache) {
8392
- const allCached = await tryServeAllFromCache(pages, templateSource, options, cacheDir);
8393
- if (allCached) return allCached;
8394
- }
8395
- await using session = await openBrowser();
8396
- if (!session) return pages.map((p) => ({
8397
- outputPath: p.outputPath,
8398
- cached: false,
8399
- error: "Chromium not available"
8400
- }));
8401
- const results = [];
8402
- const concurrency = Math.max(1, options.concurrency);
8403
- for (let i = 0; i < pages.length; i += concurrency) {
8404
- const batch = pages.slice(i, i + concurrency);
8405
- const batchResults = await Promise.all(batch.map((entry) => renderSinglePage(entry, templateFn, templateSource, options, cacheDir, session)));
8406
- results.push(...batchResults);
8444
+ try {
8445
+ var _usingCtx$1 = _usingCtx();
8446
+ if (pages.length === 0) return [];
8447
+ const templateFn = await resolveTemplate(options, root);
8448
+ const templateSource = await computeTemplateSource(options, root);
8449
+ const cacheDir = path$1.join(root, ".cache", "og-images");
8450
+ if (options.cache) {
8451
+ const allCached = await tryServeAllFromCache(pages, templateSource, options, cacheDir);
8452
+ if (allCached) return allCached;
8453
+ }
8454
+ const session = _usingCtx$1.a(await openBrowser());
8455
+ if (!session) return pages.map((p) => ({
8456
+ outputPath: p.outputPath,
8457
+ cached: false,
8458
+ error: "Chromium not available"
8459
+ }));
8460
+ const results = [];
8461
+ const concurrency = Math.max(1, options.concurrency);
8462
+ for (let i = 0; i < pages.length; i += concurrency) {
8463
+ const batch = pages.slice(i, i + concurrency);
8464
+ const batchResults = await Promise.all(batch.map((entry) => renderSinglePage(entry, templateFn, templateSource, options, cacheDir, session)));
8465
+ results.push(...batchResults);
8466
+ }
8467
+ return results;
8468
+ } catch (_) {
8469
+ _usingCtx$1.e = _;
8470
+ } finally {
8471
+ await _usingCtx$1.d();
8407
8472
  }
8408
- return results;
8409
8473
  }
8410
8474
  /**
8411
8475
  * Tries to serve all pages from cache.