asciify-engine 1.0.8 → 1.0.9

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.d.cts CHANGED
@@ -160,15 +160,19 @@ declare function asciifyGif(source: string | ArrayBuffer, canvas: HTMLCanvasElem
160
160
  */
161
161
  declare function asciifyVideo(source: HTMLVideoElement | string, canvas: HTMLCanvasElement, { fontSize, style, options }?: AsciifySimpleOptions): Promise<() => void>;
162
162
  /**
163
- * Generate a clean 2-line embed snippet.
163
+ * Generate a clean embed snippet.
164
164
  *
165
- * All data lives in data attributes on the <canvas>.
166
- * The <script> tag is always the same CDN line identical across all embeds,
167
- * so browsers/CDNs cache it once and reuse it everywhere.
165
+ * Structure:
166
+ * <canvas id> the render target, short and clean
167
+ * <script type=json id> — frame data lives here, clearly separated
168
+ * <script src=cdn> — always the same line, cached by browsers
168
169
  *
169
- * Output:
170
- * <canvas data-asciify-id="ar-xxx" data-asciify-src="…" data-asciify-opts="{…}" width="…" height="…"></canvas>
171
- * <script src="https://cdn.jsdelivr.net/npm/asciify-engine@x.x.x/dist/embed.js" async></script>
170
+ * Output (static):
171
+ * <!-- Asciify Embed -->
172
+ * <canvas id="ar-xxx" data-asciify-opts="{…}" width="…" height="…"></canvas>
173
+ * <script type="application/json" id="ar-xxx-d">"BASE64"</script>
174
+ * <script src="cdn/embed.js" async></script>
175
+ * <!-- /Asciify Embed -->
172
176
  */
173
177
  declare function generateEmbedCode(frame: AsciiFrame, options: AsciiOptions, width: number, height: number): string;
174
178
  /**
package/dist/index.d.ts CHANGED
@@ -160,15 +160,19 @@ declare function asciifyGif(source: string | ArrayBuffer, canvas: HTMLCanvasElem
160
160
  */
161
161
  declare function asciifyVideo(source: HTMLVideoElement | string, canvas: HTMLCanvasElement, { fontSize, style, options }?: AsciifySimpleOptions): Promise<() => void>;
162
162
  /**
163
- * Generate a clean 2-line embed snippet.
163
+ * Generate a clean embed snippet.
164
164
  *
165
- * All data lives in data attributes on the <canvas>.
166
- * The <script> tag is always the same CDN line identical across all embeds,
167
- * so browsers/CDNs cache it once and reuse it everywhere.
165
+ * Structure:
166
+ * <canvas id> the render target, short and clean
167
+ * <script type=json id> — frame data lives here, clearly separated
168
+ * <script src=cdn> — always the same line, cached by browsers
168
169
  *
169
- * Output:
170
- * <canvas data-asciify-id="ar-xxx" data-asciify-src="…" data-asciify-opts="{…}" width="…" height="…"></canvas>
171
- * <script src="https://cdn.jsdelivr.net/npm/asciify-engine@x.x.x/dist/embed.js" async></script>
170
+ * Output (static):
171
+ * <!-- Asciify Embed -->
172
+ * <canvas id="ar-xxx" data-asciify-opts="{…}" width="…" height="…"></canvas>
173
+ * <script type="application/json" id="ar-xxx-d">"BASE64"</script>
174
+ * <script src="cdn/embed.js" async></script>
175
+ * <!-- /Asciify Embed -->
172
176
  */
173
177
  declare function generateEmbedCode(frame: AsciiFrame, options: AsciiOptions, width: number, height: number): string;
174
178
  /**
package/dist/index.js CHANGED
@@ -832,7 +832,7 @@ async function asciifyVideo(source, canvas, { fontSize = 10, style = "classic",
832
832
  cancelAnimationFrame(animId);
833
833
  };
834
834
  }
835
- var EMBED_CDN_VERSION = "1.0.8";
835
+ var EMBED_CDN_VERSION = "1.0.9";
836
836
  function buildEmbedOpts(options, rows, cols, width, height, fps, animated) {
837
837
  const o = {
838
838
  r: rows,
@@ -866,7 +866,8 @@ function generateEmbedCode(frame, options, width, height) {
866
866
  const id = `ar-${Math.random().toString(36).slice(2, 9)}`;
867
867
  const opts = buildEmbedOpts(options, rows, cols, width, height);
868
868
  return `<!-- Asciify Embed -->
869
- <canvas data-asciify-id="${id}" data-asciify-src='"${data}"' data-asciify-opts='${opts}' width="${width}" height="${height}"></canvas>
869
+ <canvas id="${id}" data-asciify-opts='${opts}' width="${width}" height="${height}"></canvas>
870
+ <script type="application/json" id="${id}-d">"${data}"</script>
870
871
  ${CDN_SCRIPT}
871
872
  <!-- /Asciify Embed -->`;
872
873
  }
@@ -879,7 +880,8 @@ function generateAnimatedEmbedCode(frames, options, fps, width, height) {
879
880
  const id = `ar-${Math.random().toString(36).slice(2, 9)}`;
880
881
  const opts = buildEmbedOpts(options, rows, cols, width, height, fps, true);
881
882
  return `<!-- Asciify Animated Embed -->
882
- <canvas data-asciify-id="${id}" data-asciify-src='${JSON.stringify(allData)}' data-asciify-opts='${opts}' width="${width}" height="${height}"></canvas>
883
+ <canvas id="${id}" data-asciify-opts='${opts}' width="${width}" height="${height}"></canvas>
884
+ <script type="application/json" id="${id}-d">${JSON.stringify(allData)}</script>
883
885
  ${CDN_SCRIPT}
884
886
  <!-- /Asciify Animated Embed -->`;
885
887
  }