shaders 2.5.121 → 2.5.122

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.
@@ -148,7 +148,7 @@ async function createShader(canvas, preset, options) {
148
148
  return;
149
149
  }
150
150
  if (renderer.getPerformanceStats().fps > 0) {
151
- state.telemetryCollector = startTelemetry(renderer, "2.5.121", options?.disableTelemetry || false, false);
151
+ state.telemetryCollector = startTelemetry(renderer, "2.5.122", options?.disableTelemetry || false, false);
152
152
  if (state.telemetryCollector) state.telemetryCollector.start();
153
153
  state.telemetryStartTimeout = null;
154
154
  } else state.telemetryStartTimeout = setTimeout(checkRendering, 500);
@@ -10,10 +10,19 @@ export interface PartnerPresetDefinition {
10
10
  colorSpace?: string;
11
11
  devicePreview?: string;
12
12
  }
13
+ /**
14
+ * Top-level groupings the dotcom catalogues shaders under. Pass to
15
+ * `listPresets({ categories })` to narrow the response. Omit to receive every
16
+ * category.
17
+ */
18
+ export type CollectionCategory = 'background' | 'logo' | 'image-effects';
13
19
  export interface PartnerCollection {
14
20
  id: string;
15
21
  name: string;
16
22
  slug: string;
23
+ /** Top-level grouping. Useful when partners want to render section
24
+ * headings or filter the list further client-side. */
25
+ category: CollectionCategory;
17
26
  }
18
27
  export type PartnerPresetLabel = 'gradient' | 'geometric' | 'organic' | 'glowing' | 'textured' | 'retro' | '3d' | 'minimal' | 'vibrant' | 'dark' | 'calm' | 'dramatic';
19
28
  export interface PartnerKeyPropTarget {
@@ -56,6 +65,13 @@ export interface PartnerClientOptions {
56
65
  export interface ListPresetsOptions {
57
66
  page?: number;
58
67
  limit?: number;
68
+ /**
69
+ * Restrict the response to one or more categories. Omit to receive every
70
+ * category (the default — what you want for a general-purpose integration).
71
+ * Supply a subset (e.g. `['logo']`) when the integration only renders one
72
+ * kind of shader, so you don't pull rows you'll never show.
73
+ */
74
+ categories?: CollectionCategory[];
59
75
  }
60
76
  export declare class PartnerClient {
61
77
  private readonly apiKey;
@@ -65,5 +81,29 @@ export declare class PartnerClient {
65
81
  private getCached;
66
82
  private setCached;
67
83
  listPresets(options?: ListPresetsOptions): Promise<PartnerListPresetsResponse>;
84
+ /**
85
+ * Generate an SDF (signed distance field) `.bin` file from raw SVG content.
86
+ * Resolves to the file's bytes as a `Uint8Array` — the caller can write it
87
+ * to disk, upload it to their own CDN, or feed it straight into a shader
88
+ * component that consumes SDF buffers.
89
+ *
90
+ * Backed by the public `/api/plugin/sdf/generate` endpoint, which is shared
91
+ * with the Framer plugin. The endpoint is anonymous (no API key required);
92
+ * Vercel-side rate limits apply. Maximum input size: 5 MB of SVG text.
93
+ *
94
+ * Not cached — the same SVG fed in twice will round-trip twice. Memoize
95
+ * upstream if you need to.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * const fs = await import('node:fs/promises')
100
+ * const svg = await fs.readFile('./logo.svg', 'utf8')
101
+ * const sdf = await client.generateSdf(svg)
102
+ * await fs.writeFile('./logo.sdf.bin', sdf)
103
+ * ```
104
+ */
105
+ generateSdf(svg: string, options?: {
106
+ timeoutMs?: number;
107
+ }): Promise<Uint8Array>;
68
108
  }
69
109
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,QAAQ,CAAC,EAAE,sBAAsB,EAAE,CAAA;CACpC;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,sBAAsB,EAAE,CAAA;IACpC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MA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IACnC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;OAKG;IACH,UAAU,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAClC;AAUD,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAyC;gBAEnD,OAAO,EAAE,oBAAoB;IAMzC,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,SAAS;IAIX,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAuCxF;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,WAAW,CACf,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GACnC,OAAO,CAAC,UAAU,CAAC;CA2CvB"}
@@ -22,12 +22,16 @@ class PartnerClient {
22
22
  async listPresets(options = {}) {
23
23
  const page = Math.max(1, options.page ?? 1);
24
24
  const limit = Math.min(100, Math.max(1, options.limit ?? 20));
25
- const cacheKey = `presets:p${page}:l${limit}`;
25
+ const categories = options.categories && options.categories.length > 0 ? [...new Set(options.categories)].sort() : null;
26
+ const cacheKey = `presets:p${page}:l${limit}:c${(categories == null ? void 0 : categories.join(",")) ?? "*"}`;
26
27
  const cached = this.getCached(cacheKey);
27
28
  if (cached) return cached;
28
29
  const url = new URL(`${this.baseUrl}/api/partner/v1/presets`);
29
30
  url.searchParams.set("page", String(page));
30
31
  url.searchParams.set("limit", String(limit));
32
+ if (categories) {
33
+ url.searchParams.set("categories", categories.join(","));
34
+ }
31
35
  const response = await fetch(url.toString(), {
32
36
  headers: { Authorization: `Bearer ${this.apiKey}` }
33
37
  });
@@ -44,6 +48,62 @@ class PartnerClient {
44
48
  this.setCached(cacheKey, data);
45
49
  return data;
46
50
  }
51
+ /**
52
+ * Generate an SDF (signed distance field) `.bin` file from raw SVG content.
53
+ * Resolves to the file's bytes as a `Uint8Array` — the caller can write it
54
+ * to disk, upload it to their own CDN, or feed it straight into a shader
55
+ * component that consumes SDF buffers.
56
+ *
57
+ * Backed by the public `/api/plugin/sdf/generate` endpoint, which is shared
58
+ * with the Framer plugin. The endpoint is anonymous (no API key required);
59
+ * Vercel-side rate limits apply. Maximum input size: 5 MB of SVG text.
60
+ *
61
+ * Not cached — the same SVG fed in twice will round-trip twice. Memoize
62
+ * upstream if you need to.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const fs = await import('node:fs/promises')
67
+ * const svg = await fs.readFile('./logo.svg', 'utf8')
68
+ * const sdf = await client.generateSdf(svg)
69
+ * await fs.writeFile('./logo.sdf.bin', sdf)
70
+ * ```
71
+ */
72
+ async generateSdf(svg, options = {}) {
73
+ if (typeof svg !== "string" || svg.length === 0) {
74
+ throw new Error("generateSdf requires a non-empty SVG string");
75
+ }
76
+ const timeoutMs = options.timeoutMs ?? 3e4;
77
+ const controller = new AbortController();
78
+ const timeoutHandle = setTimeout(() => controller.abort(), timeoutMs);
79
+ try {
80
+ const response = await fetch(`${this.baseUrl}/api/plugin/sdf/generate`, {
81
+ method: "POST",
82
+ headers: { "Content-Type": "application/json" },
83
+ body: JSON.stringify({ svg }),
84
+ signal: controller.signal
85
+ });
86
+ if (!response.ok) {
87
+ let message = response.statusText;
88
+ try {
89
+ const body = await response.json();
90
+ if (body.message) message = body.message;
91
+ else if (body.error) message = body.error;
92
+ } catch {
93
+ }
94
+ throw new Error(`SDF generation failed ${response.status}: ${message}`);
95
+ }
96
+ const buffer = await response.arrayBuffer();
97
+ return new Uint8Array(buffer);
98
+ } catch (err) {
99
+ if (err instanceof Error && err.name === "AbortError") {
100
+ throw new Error(`SDF generation timed out after ${timeoutMs}ms`);
101
+ }
102
+ throw err;
103
+ } finally {
104
+ clearTimeout(timeoutHandle);
105
+ }
106
+ }
47
107
  }
48
108
  export {
49
109
  PartnerClient
@@ -89,7 +89,7 @@ const Shader = ({ children, disableTelemetry = false, colorSpace = "p3-linear",
89
89
  return;
90
90
  }
91
91
  if (rendererRef.current.getPerformanceStats().fps > 0) {
92
- telemetryCollectorRef.current = startTelemetry(rendererRef.current, "2.5.121", disableTelemetry, isPreview);
92
+ telemetryCollectorRef.current = startTelemetry(rendererRef.current, "2.5.122", disableTelemetry, isPreview);
93
93
  if (telemetryCollectorRef.current) telemetryCollectorRef.current.start();
94
94
  telemetryStartTimeoutRef.current = null;
95
95
  } else telemetryStartTimeoutRef.current = window.setTimeout(checkRendering, 500);