@paper-design/shaders-react 0.0.0-canary.2d03406 → 0.0.0-canary.3ce21729

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.
@@ -1,21 +1,18 @@
1
- /** Props of the element that holds the children. It's what gets drawn, so it takes their layout and the visuals */
2
- export type ShaderLayoutProps = React.ComponentProps<'div'> & {
3
- [key: `data-${string}`]: unknown;
4
- };
5
- /** Axes on which the shader takes the size of its content instead of its own size styles */
6
- export type ShaderSizeToContent = 'width' | 'height' | 'both';
7
- export declare function willDrawHtmlChildren(children: React.ReactNode): boolean;
1
+ import { type ShaderSizeToContent } from '@paper-design/shaders';
8
2
  /**
9
3
  * Draws the children into u_image where the browser supports it, otherwise they're shown on top of the shader.
10
4
  * Either way they're held by the same content element, so they lay out the same.
11
5
  *
6
+ * The content element takes the shader's layout: its display, flex and grid styles through CSS inheritance, and its
7
+ * padding copied over, since the canvas covers the padding. So the children lay out as if the shader held them.
8
+ *
12
9
  * The content element fills the shader, except on the axes sized to content: there it takes the size of the children,
13
- * and the shader follows it. The canvas can't be sized by what's inside it, so the content size is measured and
14
- * set on the shader element. Resize observer callbacks run before paint, so this settles within the same frame.
10
+ * and the shader follows it (see `observeHtmlContent`).
15
11
  */
16
- export declare function useHtmlChildren(acceptsHtmlChildren: boolean, children: React.ReactNode, layoutProps: ShaderLayoutProps | undefined, sizeToContent: ShaderSizeToContent | undefined, shaderRef: React.RefObject<HTMLElement | null>): {
12
+ export declare function useHtmlChildren(acceptsHtmlChildren: boolean, children: React.ReactNode, sizeToContent: ShaderSizeToContent | undefined, shaderRef: React.RefObject<HTMLElement | null>): {
17
13
  hasHtmlChildren: boolean;
18
14
  addHtmlUniform: <T extends object>(uniforms: T) => T;
19
15
  renderedChildren: React.ReactNode;
16
+ shaderAttributes: Record<`data-${string}`, string | undefined> | undefined;
20
17
  sizeStyle: React.CSSProperties | undefined;
21
18
  };
@@ -5,69 +5,42 @@
5
5
 
6
6
  "use client";
7
7
  import { Children, useLayoutEffect, useRef, useSyncExternalStore } from "react";
8
- import { isHtmlInCanvasSupported } from "@paper-design/shaders";
9
- import { useMergeRefs } from "./use-merge-refs.js";
8
+ import {
9
+ isHtmlInCanvasSupported,
10
+ observeHtmlContent
11
+ } from "@paper-design/shaders";
10
12
  import { jsx } from "react/jsx-runtime";
11
13
  const subscribeToNothing = () => () => {
12
14
  };
13
15
  const isSupportedOnServer = () => true;
14
- function hasChildren(children) {
15
- return Children.toArray(children).length > 0;
16
- }
17
- function willDrawHtmlChildren(children) {
18
- return hasChildren(children) && isHtmlInCanvasSupported();
19
- }
20
- function useHtmlChildren(acceptsHtmlChildren, children, layoutProps, sizeToContent, shaderRef) {
16
+ function useHtmlChildren(acceptsHtmlChildren, children, sizeToContent, shaderRef) {
21
17
  const contentRef = useRef(null);
22
- const mergedContentRef = useMergeRefs([contentRef, layoutProps?.ref]);
23
18
  const isSupported = useSyncExternalStore(subscribeToNothing, isHtmlInCanvasSupported, isSupportedOnServer);
24
- const isWrapped = acceptsHtmlChildren && hasChildren(children);
25
- const hasHtmlChildren = isWrapped && isSupported;
26
- const fitsWidth = isWrapped && (sizeToContent === "width" || sizeToContent === "both");
27
- const fitsHeight = isWrapped && (sizeToContent === "height" || sizeToContent === "both");
19
+ const hasChildren = acceptsHtmlChildren && Children.toArray(children).length > 0;
20
+ const hasHtmlChildren = hasChildren && isSupported;
21
+ const observerRef = useRef(null);
28
22
  useLayoutEffect(() => {
29
- const content2 = contentRef.current;
30
23
  const shader = shaderRef.current;
31
- if (!content2 || !shader || !fitsWidth && !fitsHeight) {
24
+ const content2 = contentRef.current;
25
+ if (!shader || !content2) {
32
26
  return;
33
27
  }
34
- let contentWidth = 0;
35
- let contentHeight = 0;
36
- const observer = new ResizeObserver((entries) => {
37
- for (const entry of entries) {
38
- const size = entry.borderBoxSize[0];
39
- if (entry.target === content2 && size) {
40
- contentWidth = size.inlineSize;
41
- contentHeight = size.blockSize;
42
- }
43
- }
44
- const style = getComputedStyle(shader);
45
- let borderX = 0;
46
- let borderY = 0;
47
- if (style.boxSizing === "border-box") {
48
- borderX = parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth);
49
- borderY = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
50
- }
51
- shader.style.setProperty("--paper-shader-content-width", `${contentWidth + borderX}px`);
52
- shader.style.setProperty("--paper-shader-content-height", `${contentHeight + borderY}px`);
53
- });
54
- observer.observe(content2);
55
- observer.observe(shader);
28
+ const observer = observeHtmlContent(shader, content2, sizeToContent);
29
+ observerRef.current = observer;
56
30
  return () => {
57
31
  observer.disconnect();
32
+ observerRef.current = null;
58
33
  };
59
- }, [fitsWidth, fitsHeight, hasHtmlChildren, shaderRef]);
34
+ }, [hasChildren, hasHtmlChildren, sizeToContent, shaderRef]);
35
+ useLayoutEffect(() => {
36
+ observerRef.current?.update();
37
+ });
60
38
  const addHtmlUniform = (uniforms) => hasHtmlChildren && contentRef.current ? { ...uniforms, u_image: contentRef.current } : uniforms;
61
- if (!isWrapped) {
62
- return { hasHtmlChildren, addHtmlUniform, renderedChildren: children, sizeStyle: void 0 };
63
- }
64
- const contentStyle = { ...layoutProps?.style };
65
- if (fitsWidth) {
66
- contentStyle.width = "max-content";
67
- }
68
- if (fitsHeight) {
69
- contentStyle.height = "auto";
39
+ if (!hasChildren) {
40
+ return { hasHtmlChildren, addHtmlUniform, renderedChildren: children, shaderAttributes: void 0, sizeStyle: void 0 };
70
41
  }
42
+ const fitsWidth = sizeToContent === "width" || sizeToContent === "both";
43
+ const fitsHeight = sizeToContent === "height" || sizeToContent === "both";
71
44
  let sizeStyle;
72
45
  if (fitsWidth || fitsHeight) {
73
46
  sizeStyle = {};
@@ -78,16 +51,16 @@ function useHtmlChildren(acceptsHtmlChildren, children, layoutProps, sizeToConte
78
51
  sizeStyle.height = "var(--paper-shader-content-height)";
79
52
  }
80
53
  }
81
- const content = /* @__PURE__ */ jsx("div", { ...layoutProps, ref: mergedContentRef, style: contentStyle, ...{ drawable: "" }, children });
54
+ const content = /* @__PURE__ */ jsx("div", { ref: contentRef, ...{ drawable: "" }, children });
82
55
  return {
83
56
  hasHtmlChildren,
84
57
  addHtmlUniform,
85
- renderedChildren: hasHtmlChildren ? /* @__PURE__ */ jsx("canvas", { ...{ content: "drawable", layoutsubtree: "" }, children: content }) : content,
58
+ renderedChildren: hasHtmlChildren ? /* @__PURE__ */ jsx("canvas", { ...{ content: "drawable", layoutsubtree: "" }, style: { display: "inherit" }, children: content }) : content,
59
+ shaderAttributes: { "data-paper-shader": "html", "data-size-to-content": sizeToContent },
86
60
  sizeStyle
87
61
  };
88
62
  }
89
63
  export {
90
- useHtmlChildren,
91
- willDrawHtmlChildren
64
+ useHtmlChildren
92
65
  };
93
66
  //# sourceMappingURL=html-in-canvas.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/html-in-canvas.tsx"],
4
- "sourcesContent": ["'use client';\n\nimport { Children, useLayoutEffect, useRef, useSyncExternalStore } from 'react';\nimport { isHtmlInCanvasSupported } from '@paper-design/shaders';\nimport { useMergeRefs } from './use-merge-refs.js';\n\nconst subscribeToNothing = () => () => {};\n// Assumed on the server, so that supporting browsers don't re-render the canvas after hydration\nconst isSupportedOnServer = () => true;\n\n/** Props of the element that holds the children. It's what gets drawn, so it takes their layout and the visuals */\nexport type ShaderLayoutProps = React.ComponentProps<'div'> & { [key: `data-${string}`]: unknown };\n\n/** Axes on which the shader takes the size of its content instead of its own size styles */\nexport type ShaderSizeToContent = 'width' | 'height' | 'both';\n\nfunction hasChildren(children: React.ReactNode): boolean {\n return Children.toArray(children).length > 0;\n}\n\nexport function willDrawHtmlChildren(children: React.ReactNode): boolean {\n return hasChildren(children) && isHtmlInCanvasSupported();\n}\n\n/**\n * Draws the children into u_image where the browser supports it, otherwise they're shown on top of the shader.\n * Either way they're held by the same content element, so they lay out the same.\n *\n * The content element fills the shader, except on the axes sized to content: there it takes the size of the children,\n * and the shader follows it. The canvas can't be sized by what's inside it, so the content size is measured and\n * set on the shader element. Resize observer callbacks run before paint, so this settles within the same frame.\n */\nexport function useHtmlChildren(\n acceptsHtmlChildren: boolean,\n children: React.ReactNode,\n layoutProps: ShaderLayoutProps | undefined,\n sizeToContent: ShaderSizeToContent | undefined,\n shaderRef: React.RefObject<HTMLElement | null>\n): {\n hasHtmlChildren: boolean;\n addHtmlUniform: <T extends object>(uniforms: T) => T;\n renderedChildren: React.ReactNode;\n sizeStyle: React.CSSProperties | undefined;\n} {\n const contentRef = useRef<HTMLDivElement>(null);\n const mergedContentRef = useMergeRefs([contentRef, layoutProps?.ref]);\n const isSupported = useSyncExternalStore(subscribeToNothing, isHtmlInCanvasSupported, isSupportedOnServer);\n const isWrapped = acceptsHtmlChildren && hasChildren(children);\n const hasHtmlChildren = isWrapped && isSupported;\n\n const fitsWidth = isWrapped && (sizeToContent === 'width' || sizeToContent === 'both');\n const fitsHeight = isWrapped && (sizeToContent === 'height' || sizeToContent === 'both');\n\n useLayoutEffect(() => {\n const content = contentRef.current;\n const shader = shaderRef.current;\n if (!content || !shader || (!fitsWidth && !fitsHeight)) {\n return;\n }\n\n let contentWidth = 0;\n let contentHeight = 0;\n\n // The shader is observed too, so that its border changes are picked up\n const observer = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const size = entry.borderBoxSize[0];\n if (entry.target === content && size) {\n contentWidth = size.inlineSize;\n contentHeight = size.blockSize;\n }\n }\n\n // The shader's own border sits around the content\n const style = getComputedStyle(shader);\n let borderX = 0;\n let borderY = 0;\n if (style.boxSizing === 'border-box') {\n borderX = parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth);\n borderY = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);\n }\n\n shader.style.setProperty('--paper-shader-content-width', `${contentWidth + borderX}px`);\n shader.style.setProperty('--paper-shader-content-height', `${contentHeight + borderY}px`);\n });\n observer.observe(content);\n observer.observe(shader);\n\n return () => {\n observer.disconnect();\n };\n }, [fitsWidth, fitsHeight, hasHtmlChildren, shaderRef]);\n\n const addHtmlUniform = <T extends object>(uniforms: T): T =>\n hasHtmlChildren && contentRef.current ? { ...uniforms, u_image: contentRef.current } : uniforms;\n\n if (!isWrapped) {\n return { hasHtmlChildren, addHtmlUniform, renderedChildren: children, sizeStyle: undefined };\n }\n\n // Sized to content: the content element takes the size of the children, which can overflow the canvas\n const contentStyle: React.CSSProperties = { ...layoutProps?.style };\n if (fitsWidth) {\n contentStyle.width = 'max-content';\n }\n if (fitsHeight) {\n contentStyle.height = 'auto';\n }\n\n // The shader takes the measured content size\n let sizeStyle: React.CSSProperties | undefined;\n if (fitsWidth || fitsHeight) {\n sizeStyle = {};\n if (fitsWidth) {\n sizeStyle.width = 'var(--paper-shader-content-width)';\n }\n if (fitsHeight) {\n sizeStyle.height = 'var(--paper-shader-content-height)';\n }\n }\n\n const content = (\n <div {...layoutProps} ref={mergedContentRef} style={contentStyle} {...{ drawable: '' }}>\n {children}\n </div>\n );\n\n return {\n hasHtmlChildren,\n addHtmlUniform,\n renderedChildren: hasHtmlChildren ? (\n <canvas {...{ content: 'drawable', layoutsubtree: '' }}>{content}</canvas>\n ) : (\n content\n ),\n sizeStyle,\n };\n}\n"],
5
- "mappings": ";;;;;;AAEA,SAAS,UAAU,iBAAiB,QAAQ,4BAA4B;AACxE,SAAS,+BAA+B;AACxC,SAAS,oBAAoB;AAsHzB;AApHJ,MAAM,qBAAqB,MAAM,MAAM;AAAC;AAExC,MAAM,sBAAsB,MAAM;AAQlC,SAAS,YAAY,UAAoC;AACvD,SAAO,SAAS,QAAQ,QAAQ,EAAE,SAAS;AAC7C;AAEO,SAAS,qBAAqB,UAAoC;AACvE,SAAO,YAAY,QAAQ,KAAK,wBAAwB;AAC1D;AAUO,SAAS,gBACd,qBACA,UACA,aACA,eACA,WAMA;AACA,QAAM,aAAa,OAAuB,IAAI;AAC9C,QAAM,mBAAmB,aAAa,CAAC,YAAY,aAAa,GAAG,CAAC;AACp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AAC,WAAW;AACd,WAAO,EAAE,iBAAiB,gBAAgB,kBAAkB,UAAU,WAAW,OAAU;AAAA,EAC7F;AAGA,QAAM,eAAoC,EAAE,GAAG,aAAa,MAAM;AAClE,MAAI,WAAW;AACb,iBAAa,QAAQ;AAAA,EACvB;AACA,MAAI,YAAY;AACd,iBAAa,SAAS;AAAA,EACxB;AAGA,MAAI;AACJ,MAAI,aAAa,YAAY;AAC3B,gBAAY,CAAC;AACb,QAAI,WAAW;AACb,gBAAU,QAAQ;AAAA,IACpB;AACA,QAAI,YAAY;AACd,gBAAU,SAAS;AAAA,IACrB;AAAA,EACF;AAEA,QAAM,UACJ,oBAAC,SAAK,GAAG,aAAa,KAAK,kBAAkB,OAAO,cAAe,GAAG,EAAE,UAAU,GAAG,GAClF,UACH;AAGF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,kBAAkB,kBAChB,oBAAC,YAAQ,GAAG,EAAE,SAAS,YAAY,eAAe,GAAG,GAAI,mBAAQ,IAEjE;AAAA,IAEF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["'use client';\n\nimport { Children, useLayoutEffect, useRef, useSyncExternalStore } from 'react';\nimport {\n isHtmlInCanvasSupported,\n observeHtmlContent,\n type HtmlContentObserver,\n type ShaderSizeToContent,\n} from '@paper-design/shaders';\n\nconst subscribeToNothing = () => () => {};\n// Assumed on the server, so that supporting browsers don't re-render the canvas after hydration\nconst isSupportedOnServer = () => true;\n\n/**\n * Draws the children into u_image where the browser supports it, otherwise they're shown on top of the shader.\n * Either way they're held by the same content element, so they lay out the same.\n *\n * The content element takes the shader's layout: its display, flex and grid styles through CSS inheritance, and its\n * padding copied over, since the canvas covers the padding. So the children lay out as if the shader held them.\n *\n * The content element fills the shader, except on the axes sized to content: there it takes the size of the children,\n * and the shader follows it (see `observeHtmlContent`).\n */\nexport function useHtmlChildren(\n acceptsHtmlChildren: boolean,\n children: React.ReactNode,\n sizeToContent: ShaderSizeToContent | undefined,\n shaderRef: React.RefObject<HTMLElement | null>\n): {\n hasHtmlChildren: boolean;\n addHtmlUniform: <T extends object>(uniforms: T) => T;\n renderedChildren: React.ReactNode;\n shaderAttributes: Record<`data-${string}`, string | undefined> | undefined;\n sizeStyle: React.CSSProperties | undefined;\n} {\n const contentRef = useRef<HTMLDivElement>(null);\n const isSupported = useSyncExternalStore(subscribeToNothing, isHtmlInCanvasSupported, isSupportedOnServer);\n const hasChildren = acceptsHtmlChildren && Children.toArray(children).length > 0;\n const hasHtmlChildren = hasChildren && isSupported;\n\n const observerRef = useRef<HtmlContentObserver | null>(null);\n\n useLayoutEffect(() => {\n const shader = shaderRef.current;\n const content = contentRef.current;\n if (!shader || !content) {\n return;\n }\n const observer = observeHtmlContent(shader, content, sizeToContent);\n observerRef.current = observer;\n return () => {\n observer.disconnect();\n observerRef.current = null;\n };\n }, [hasChildren, hasHtmlChildren, sizeToContent, shaderRef]);\n\n // After every render, since a style or class change can change the padding without resizing anything\n useLayoutEffect(() => {\n observerRef.current?.update();\n });\n\n const addHtmlUniform = <T extends object>(uniforms: T): T =>\n hasHtmlChildren && contentRef.current ? { ...uniforms, u_image: contentRef.current } : uniforms;\n\n if (!hasChildren) {\n return { hasHtmlChildren, addHtmlUniform, renderedChildren: children, shaderAttributes: undefined, sizeStyle: undefined };\n }\n\n const fitsWidth = sizeToContent === 'width' || sizeToContent === 'both';\n const fitsHeight = sizeToContent === 'height' || sizeToContent === 'both';\n\n // The shader takes the measured content size\n let sizeStyle: React.CSSProperties | undefined;\n if (fitsWidth || fitsHeight) {\n sizeStyle = {};\n if (fitsWidth) {\n sizeStyle.width = 'var(--paper-shader-content-width)';\n }\n if (fitsHeight) {\n sizeStyle.height = 'var(--paper-shader-content-height)';\n }\n }\n\n const content = (\n <div ref={contentRef} {...{ drawable: '' }}>\n {children}\n </div>\n );\n\n return {\n hasHtmlChildren,\n addHtmlUniform,\n renderedChildren: hasHtmlChildren ? (\n <canvas {...{ content: 'drawable', layoutsubtree: '' }} style={{ display: 'inherit' }}>\n {content}\n </canvas>\n ) : (\n content\n ),\n shaderAttributes: { 'data-paper-shader': 'html', 'data-size-to-content': sizeToContent },\n sizeStyle,\n };\n}\n"],
5
+ "mappings": ";;;;;;AAEA,SAAS,UAAU,iBAAiB,QAAQ,4BAA4B;AACxE;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AA6EH;AA3EJ,MAAM,qBAAqB,MAAM,MAAM;AAAC;AAExC,MAAM,sBAAsB,MAAM;AAY3B,SAAS,gBACd,qBACA,UACA,eACA,WAOA;AACA,QAAM,aAAa,OAAuB,IAAI;AAC9C,QAAM,cAAc,qBAAqB,oBAAoB,yBAAyB,mBAAmB;AACzG,QAAM,cAAc,uBAAuB,SAAS,QAAQ,QAAQ,EAAE,SAAS;AAC/E,QAAM,kBAAkB,eAAe;AAEvC,QAAM,cAAc,OAAmC,IAAI;AAE3D,kBAAgB,MAAM;AACpB,UAAM,SAAS,UAAU;AACzB,UAAMA,WAAU,WAAW;AAC3B,QAAI,CAAC,UAAU,CAACA,UAAS;AACvB;AAAA,IACF;AACA,UAAM,WAAW,mBAAmB,QAAQA,UAAS,aAAa;AAClE,gBAAY,UAAU;AACtB,WAAO,MAAM;AACX,eAAS,WAAW;AACpB,kBAAY,UAAU;AAAA,IACxB;AAAA,EACF,GAAG,CAAC,aAAa,iBAAiB,eAAe,SAAS,CAAC;AAG3D,kBAAgB,MAAM;AACpB,gBAAY,SAAS,OAAO;AAAA,EAC9B,CAAC;AAED,QAAM,iBAAiB,CAAmB,aACxC,mBAAmB,WAAW,UAAU,EAAE,GAAG,UAAU,SAAS,WAAW,QAAQ,IAAI;AAEzF,MAAI,CAAC,aAAa;AAChB,WAAO,EAAE,iBAAiB,gBAAgB,kBAAkB,UAAU,kBAAkB,QAAW,WAAW,OAAU;AAAA,EAC1H;AAEA,QAAM,YAAY,kBAAkB,WAAW,kBAAkB;AACjE,QAAM,aAAa,kBAAkB,YAAY,kBAAkB;AAGnE,MAAI;AACJ,MAAI,aAAa,YAAY;AAC3B,gBAAY,CAAC;AACb,QAAI,WAAW;AACb,gBAAU,QAAQ;AAAA,IACpB;AACA,QAAI,YAAY;AACd,gBAAU,SAAS;AAAA,IACrB;AAAA,EACF;AAEA,QAAM,UACJ,oBAAC,SAAI,KAAK,YAAa,GAAG,EAAE,UAAU,GAAG,GACtC,UACH;AAGF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,kBAAkB,kBAChB,oBAAC,YAAQ,GAAG,EAAE,SAAS,YAAY,eAAe,GAAG,GAAG,OAAO,EAAE,SAAS,UAAU,GACjF,mBACH,IAEA;AAAA,IAEF,kBAAkB,EAAE,qBAAqB,QAAQ,wBAAwB,cAAc;AAAA,IACvF;AAAA,EACF;AACF;",
6
6
  "names": ["content"]
7
7
  }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { ShaderMount } from './shader-mount.js';
2
2
  export type { ShaderMountProps, ShaderComponentProps } from './shader-mount.js';
3
- export type { ShaderLayoutProps, ShaderSizeToContent } from './html-in-canvas.js';
3
+ export type { ShaderSizeToContent } from '@paper-design/shaders';
4
4
  export { MeshGradient, meshGradientPresets } from './shaders/mesh-gradient.js';
5
5
  export type { MeshGradientProps } from './shaders/mesh-gradient.js';
6
6
  export type { MeshGradientUniforms, MeshGradientParams } from '@paper-design/shaders';
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["'use client';\n\nexport { ShaderMount } from './shader-mount.js';\nexport type { ShaderMountProps, ShaderComponentProps } from './shader-mount.js';\nexport type { ShaderLayoutProps, ShaderSizeToContent } from './html-in-canvas.js';\n\nexport { MeshGradient, meshGradientPresets } from './shaders/mesh-gradient.js';\nexport type { MeshGradientProps } from './shaders/mesh-gradient.js';\nexport type { MeshGradientUniforms, MeshGradientParams } from '@paper-design/shaders';\n\nexport { SmokeRing, smokeRingPresets } from './shaders/smoke-ring.js';\nexport type { SmokeRingProps } from './shaders/smoke-ring.js';\nexport type { SmokeRingUniforms, SmokeRingParams } from '@paper-design/shaders';\n\nexport { NeuroNoise, neuroNoisePresets } from './shaders/neuro-noise.js';\nexport type { NeuroNoiseProps } from './shaders/neuro-noise.js';\nexport type { NeuroNoiseUniforms, NeuroNoiseParams } from '@paper-design/shaders';\n\nexport { DotOrbit, dotOrbitPresets } from './shaders/dot-orbit.js';\nexport type { DotOrbitProps } from './shaders/dot-orbit.js';\nexport type { DotOrbitUniforms, DotOrbitParams } from '@paper-design/shaders';\n\nexport { DotGrid, dotGridPresets } from './shaders/dot-grid.js';\nexport type { DotGridProps } from './shaders/dot-grid.js';\nexport type { DotGridUniforms, DotGridParams } from '@paper-design/shaders';\n\nexport { SimplexNoise, simplexNoisePresets } from './shaders/simplex-noise.js';\nexport type { SimplexNoiseProps } from './shaders/simplex-noise.js';\nexport type { SimplexNoiseUniforms, SimplexNoiseParams } from '@paper-design/shaders';\n\nexport { Metaballs, metaballsPresets } from './shaders/metaballs.js';\nexport type { MetaballsProps } from './shaders/metaballs.js';\nexport type { MetaballsUniforms, MetaballsParams } from '@paper-design/shaders';\n\nexport { Waves, wavesPresets } from './shaders/waves.js';\nexport type { WavesProps } from './shaders/waves.js';\nexport type { WavesUniforms, WavesParams } from '@paper-design/shaders';\n\nexport { PerlinNoise, perlinNoisePresets } from './shaders/perlin-noise.js';\nexport type { PerlinNoiseProps } from './shaders/perlin-noise.js';\nexport type { PerlinNoiseUniforms, PerlinNoiseParams } from '@paper-design/shaders';\n\nexport { Voronoi, voronoiPresets } from './shaders/voronoi.js';\nexport type { VoronoiProps } from './shaders/voronoi.js';\nexport type { VoronoiUniforms, VoronoiParams } from '@paper-design/shaders';\n\nexport { Warp, warpPresets } from './shaders/warp.js';\nexport type { WarpProps } from './shaders/warp.js';\nexport type { WarpUniforms, WarpParams, WarpPattern } from '@paper-design/shaders';\n\nexport { GodRays, godRaysPresets } from './shaders/god-rays.js';\nexport type { GodRaysProps } from './shaders/god-rays.js';\nexport type { GodRaysUniforms, GodRaysParams } from '@paper-design/shaders';\n\nexport { Spiral, spiralPresets } from './shaders/spiral.js';\nexport type { SpiralProps } from './shaders/spiral.js';\nexport type { SpiralUniforms, SpiralParams } from '@paper-design/shaders';\n\nexport { Swirl, swirlPresets } from './shaders/swirl.js';\nexport type { SwirlProps } from './shaders/swirl.js';\nexport type { SwirlUniforms, SwirlParams } from '@paper-design/shaders';\n\nexport { Dithering, ditheringPresets } from './shaders/dithering.js';\nexport type { DitheringProps } from './shaders/dithering.js';\nexport type { DitheringUniforms, DitheringParams } from '@paper-design/shaders';\n\nexport { GrainGradient, grainGradientPresets } from './shaders/grain-gradient.js';\nexport type { GrainGradientProps } from './shaders/grain-gradient.js';\nexport type { GrainGradientUniforms, GrainGradientParams } from '@paper-design/shaders';\n\nexport { PulsingBorder, pulsingBorderPresets } from './shaders/pulsing-border.js';\nexport type { PulsingBorderProps } from './shaders/pulsing-border.js';\nexport type { PulsingBorderUniforms, PulsingBorderParams } from '@paper-design/shaders';\n\nexport { ColorPanels, colorPanelsPresets } from './shaders/color-panels.js';\nexport type { ColorPanelsProps } from './shaders/color-panels.js';\nexport type { ColorPanelsUniforms, ColorPanelsParams } from '@paper-design/shaders';\n\nexport { StaticMeshGradient, staticMeshGradientPresets } from './shaders/static-mesh-gradient.js';\nexport type { StaticMeshGradientProps } from './shaders/static-mesh-gradient.js';\nexport type { StaticMeshGradientUniforms, StaticMeshGradientParams } from '@paper-design/shaders';\n\nexport { StaticRadialGradient, staticRadialGradientPresets } from './shaders/static-radial-gradient.js';\nexport type { StaticRadialGradientProps } from './shaders/static-radial-gradient.js';\nexport type { StaticRadialGradientUniforms, StaticRadialGradientParams } from '@paper-design/shaders';\n\nexport { PaperTexture, paperTexturePresets } from './shaders/paper-texture.js';\nexport type { PaperTextureProps } from './shaders/paper-texture.js';\nexport type { PaperTextureUniforms, PaperTextureParams } from '@paper-design/shaders';\n\nexport { FlutedGlass, flutedGlassPresets } from './shaders/fluted-glass.js';\nexport { type FlutedGlassProps } from './shaders/fluted-glass.js';\nexport { type FlutedGlassUniforms, type FlutedGlassParams } from '@paper-design/shaders';\n\nexport { Water, waterPresets } from './shaders/water.js';\nexport type { WaterProps } from './shaders/water.js';\nexport type { WaterUniforms, WaterParams } from '@paper-design/shaders';\n\nexport { ImageDithering, imageDitheringPresets } from './shaders/image-dithering.js';\nexport type { ImageDitheringProps } from './shaders/image-dithering.js';\nexport type { ImageDitheringUniforms, ImageDitheringParams } from '@paper-design/shaders';\n\nexport { LensDistortion, lensDistortionPresets } from './shaders/lens-distortion.js';\nexport type { LensDistortionProps } from './shaders/lens-distortion.js';\nexport type { LensDistortionUniforms, LensDistortionParams } from '@paper-design/shaders';\n\nexport { Heatmap, heatmapPresets } from './shaders/heatmap.js';\nexport type { HeatmapProps } from './shaders/heatmap.js';\nexport type { HeatmapUniforms, HeatmapParams } from '@paper-design/shaders';\n\nexport { LiquidMetal, liquidMetalPresets } from './shaders/liquid-metal.js';\nexport type { LiquidMetalProps } from './shaders/liquid-metal.js';\nexport type { LiquidMetalUniforms, LiquidMetalParams } from '@paper-design/shaders';\n\nexport { HalftoneDots, halftoneDotsPresets } from './shaders/halftone-dots.js';\nexport type { HalftoneDotsProps } from './shaders/halftone-dots.js';\nexport type { HalftoneDotsUniforms, HalftoneDotsParams } from '@paper-design/shaders';\n\nexport { HalftoneCmyk, halftoneCmykPresets } from './shaders/halftone-cmyk.js';\nexport type { HalftoneCmykProps } from './shaders/halftone-cmyk.js';\nexport type { HalftoneCmykUniforms, HalftoneCmykParams } from '@paper-design/shaders';\n\nexport { GemSmoke, gemSmokePresets } from './shaders/gem-smoke.js';\nexport type { GemSmokeProps } from './shaders/gem-smoke.js';\nexport type { GemSmokeUniforms, GemSmokeParams } from '@paper-design/shaders';\n\nexport { isPaperShaderElement, getShaderColorFromString } from '@paper-design/shaders';\nexport type { PaperShaderElement, ShaderFit, ShaderSizingParams, ShaderSizingUniforms } from '@paper-design/shaders';\n\nexport {\n colorPanelsMeta,\n dotOrbitMeta,\n godRaysMeta,\n grainGradientMeta,\n meshGradientMeta,\n metaballsMeta,\n paperTextureMeta,\n pulsingBorderMeta,\n simplexNoiseMeta,\n smokeRingMeta,\n swirlMeta,\n voronoiMeta,\n warpMeta,\n heatmapMeta,\n lensDistortionMeta,\n staticMeshGradientMeta,\n staticRadialGradientMeta,\n} from '@paper-design/shaders';\n"],
4
+ "sourcesContent": ["'use client';\n\nexport { ShaderMount } from './shader-mount.js';\nexport type { ShaderMountProps, ShaderComponentProps } from './shader-mount.js';\nexport type { ShaderSizeToContent } from '@paper-design/shaders';\n\nexport { MeshGradient, meshGradientPresets } from './shaders/mesh-gradient.js';\nexport type { MeshGradientProps } from './shaders/mesh-gradient.js';\nexport type { MeshGradientUniforms, MeshGradientParams } from '@paper-design/shaders';\n\nexport { SmokeRing, smokeRingPresets } from './shaders/smoke-ring.js';\nexport type { SmokeRingProps } from './shaders/smoke-ring.js';\nexport type { SmokeRingUniforms, SmokeRingParams } from '@paper-design/shaders';\n\nexport { NeuroNoise, neuroNoisePresets } from './shaders/neuro-noise.js';\nexport type { NeuroNoiseProps } from './shaders/neuro-noise.js';\nexport type { NeuroNoiseUniforms, NeuroNoiseParams } from '@paper-design/shaders';\n\nexport { DotOrbit, dotOrbitPresets } from './shaders/dot-orbit.js';\nexport type { DotOrbitProps } from './shaders/dot-orbit.js';\nexport type { DotOrbitUniforms, DotOrbitParams } from '@paper-design/shaders';\n\nexport { DotGrid, dotGridPresets } from './shaders/dot-grid.js';\nexport type { DotGridProps } from './shaders/dot-grid.js';\nexport type { DotGridUniforms, DotGridParams } from '@paper-design/shaders';\n\nexport { SimplexNoise, simplexNoisePresets } from './shaders/simplex-noise.js';\nexport type { SimplexNoiseProps } from './shaders/simplex-noise.js';\nexport type { SimplexNoiseUniforms, SimplexNoiseParams } from '@paper-design/shaders';\n\nexport { Metaballs, metaballsPresets } from './shaders/metaballs.js';\nexport type { MetaballsProps } from './shaders/metaballs.js';\nexport type { MetaballsUniforms, MetaballsParams } from '@paper-design/shaders';\n\nexport { Waves, wavesPresets } from './shaders/waves.js';\nexport type { WavesProps } from './shaders/waves.js';\nexport type { WavesUniforms, WavesParams } from '@paper-design/shaders';\n\nexport { PerlinNoise, perlinNoisePresets } from './shaders/perlin-noise.js';\nexport type { PerlinNoiseProps } from './shaders/perlin-noise.js';\nexport type { PerlinNoiseUniforms, PerlinNoiseParams } from '@paper-design/shaders';\n\nexport { Voronoi, voronoiPresets } from './shaders/voronoi.js';\nexport type { VoronoiProps } from './shaders/voronoi.js';\nexport type { VoronoiUniforms, VoronoiParams } from '@paper-design/shaders';\n\nexport { Warp, warpPresets } from './shaders/warp.js';\nexport type { WarpProps } from './shaders/warp.js';\nexport type { WarpUniforms, WarpParams, WarpPattern } from '@paper-design/shaders';\n\nexport { GodRays, godRaysPresets } from './shaders/god-rays.js';\nexport type { GodRaysProps } from './shaders/god-rays.js';\nexport type { GodRaysUniforms, GodRaysParams } from '@paper-design/shaders';\n\nexport { Spiral, spiralPresets } from './shaders/spiral.js';\nexport type { SpiralProps } from './shaders/spiral.js';\nexport type { SpiralUniforms, SpiralParams } from '@paper-design/shaders';\n\nexport { Swirl, swirlPresets } from './shaders/swirl.js';\nexport type { SwirlProps } from './shaders/swirl.js';\nexport type { SwirlUniforms, SwirlParams } from '@paper-design/shaders';\n\nexport { Dithering, ditheringPresets } from './shaders/dithering.js';\nexport type { DitheringProps } from './shaders/dithering.js';\nexport type { DitheringUniforms, DitheringParams } from '@paper-design/shaders';\n\nexport { GrainGradient, grainGradientPresets } from './shaders/grain-gradient.js';\nexport type { GrainGradientProps } from './shaders/grain-gradient.js';\nexport type { GrainGradientUniforms, GrainGradientParams } from '@paper-design/shaders';\n\nexport { PulsingBorder, pulsingBorderPresets } from './shaders/pulsing-border.js';\nexport type { PulsingBorderProps } from './shaders/pulsing-border.js';\nexport type { PulsingBorderUniforms, PulsingBorderParams } from '@paper-design/shaders';\n\nexport { ColorPanels, colorPanelsPresets } from './shaders/color-panels.js';\nexport type { ColorPanelsProps } from './shaders/color-panels.js';\nexport type { ColorPanelsUniforms, ColorPanelsParams } from '@paper-design/shaders';\n\nexport { StaticMeshGradient, staticMeshGradientPresets } from './shaders/static-mesh-gradient.js';\nexport type { StaticMeshGradientProps } from './shaders/static-mesh-gradient.js';\nexport type { StaticMeshGradientUniforms, StaticMeshGradientParams } from '@paper-design/shaders';\n\nexport { StaticRadialGradient, staticRadialGradientPresets } from './shaders/static-radial-gradient.js';\nexport type { StaticRadialGradientProps } from './shaders/static-radial-gradient.js';\nexport type { StaticRadialGradientUniforms, StaticRadialGradientParams } from '@paper-design/shaders';\n\nexport { PaperTexture, paperTexturePresets } from './shaders/paper-texture.js';\nexport type { PaperTextureProps } from './shaders/paper-texture.js';\nexport type { PaperTextureUniforms, PaperTextureParams } from '@paper-design/shaders';\n\nexport { FlutedGlass, flutedGlassPresets } from './shaders/fluted-glass.js';\nexport { type FlutedGlassProps } from './shaders/fluted-glass.js';\nexport { type FlutedGlassUniforms, type FlutedGlassParams } from '@paper-design/shaders';\n\nexport { Water, waterPresets } from './shaders/water.js';\nexport type { WaterProps } from './shaders/water.js';\nexport type { WaterUniforms, WaterParams } from '@paper-design/shaders';\n\nexport { ImageDithering, imageDitheringPresets } from './shaders/image-dithering.js';\nexport type { ImageDitheringProps } from './shaders/image-dithering.js';\nexport type { ImageDitheringUniforms, ImageDitheringParams } from '@paper-design/shaders';\n\nexport { LensDistortion, lensDistortionPresets } from './shaders/lens-distortion.js';\nexport type { LensDistortionProps } from './shaders/lens-distortion.js';\nexport type { LensDistortionUniforms, LensDistortionParams } from '@paper-design/shaders';\n\nexport { Heatmap, heatmapPresets } from './shaders/heatmap.js';\nexport type { HeatmapProps } from './shaders/heatmap.js';\nexport type { HeatmapUniforms, HeatmapParams } from '@paper-design/shaders';\n\nexport { LiquidMetal, liquidMetalPresets } from './shaders/liquid-metal.js';\nexport type { LiquidMetalProps } from './shaders/liquid-metal.js';\nexport type { LiquidMetalUniforms, LiquidMetalParams } from '@paper-design/shaders';\n\nexport { HalftoneDots, halftoneDotsPresets } from './shaders/halftone-dots.js';\nexport type { HalftoneDotsProps } from './shaders/halftone-dots.js';\nexport type { HalftoneDotsUniforms, HalftoneDotsParams } from '@paper-design/shaders';\n\nexport { HalftoneCmyk, halftoneCmykPresets } from './shaders/halftone-cmyk.js';\nexport type { HalftoneCmykProps } from './shaders/halftone-cmyk.js';\nexport type { HalftoneCmykUniforms, HalftoneCmykParams } from '@paper-design/shaders';\n\nexport { GemSmoke, gemSmokePresets } from './shaders/gem-smoke.js';\nexport type { GemSmokeProps } from './shaders/gem-smoke.js';\nexport type { GemSmokeUniforms, GemSmokeParams } from '@paper-design/shaders';\n\nexport { isPaperShaderElement, getShaderColorFromString } from '@paper-design/shaders';\nexport type { PaperShaderElement, ShaderFit, ShaderSizingParams, ShaderSizingUniforms } from '@paper-design/shaders';\n\nexport {\n colorPanelsMeta,\n dotOrbitMeta,\n godRaysMeta,\n grainGradientMeta,\n meshGradientMeta,\n metaballsMeta,\n paperTextureMeta,\n pulsingBorderMeta,\n simplexNoiseMeta,\n smokeRingMeta,\n swirlMeta,\n voronoiMeta,\n warpMeta,\n heatmapMeta,\n lensDistortionMeta,\n staticMeshGradientMeta,\n staticRadialGradientMeta,\n} from '@paper-design/shaders';\n"],
5
5
  "mappings": ";;;;;;AAEA,SAAS,mBAAmB;AAI5B,SAAS,cAAc,2BAA2B;AAIlD,SAAS,WAAW,wBAAwB;AAI5C,SAAS,YAAY,yBAAyB;AAI9C,SAAS,UAAU,uBAAuB;AAI1C,SAAS,SAAS,sBAAsB;AAIxC,SAAS,cAAc,2BAA2B;AAIlD,SAAS,WAAW,wBAAwB;AAI5C,SAAS,OAAO,oBAAoB;AAIpC,SAAS,aAAa,0BAA0B;AAIhD,SAAS,SAAS,sBAAsB;AAIxC,SAAS,MAAM,mBAAmB;AAIlC,SAAS,SAAS,sBAAsB;AAIxC,SAAS,QAAQ,qBAAqB;AAItC,SAAS,OAAO,oBAAoB;AAIpC,SAAS,WAAW,wBAAwB;AAI5C,SAAS,eAAe,4BAA4B;AAIpD,SAAS,eAAe,4BAA4B;AAIpD,SAAS,aAAa,0BAA0B;AAIhD,SAAS,oBAAoB,iCAAiC;AAI9D,SAAS,sBAAsB,mCAAmC;AAIlE,SAAS,cAAc,2BAA2B;AAIlD,SAAS,aAAa,0BAA0B;AAChD,eAAsC;AACtC,eAAiE;AAEjE,SAAS,OAAO,oBAAoB;AAIpC,SAAS,gBAAgB,6BAA6B;AAItD,SAAS,gBAAgB,6BAA6B;AAItD,SAAS,SAAS,sBAAsB;AAIxC,SAAS,aAAa,0BAA0B;AAIhD,SAAS,cAAc,2BAA2B;AAIlD,SAAS,cAAc,2BAA2B;AAIlD,SAAS,UAAU,uBAAuB;AAI1C,SAAS,sBAAsB,gCAAgC;AAG/D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,4 @@
1
- import { type PaperShaderElement, type ShaderMotionParams } from '@paper-design/shaders';
2
- import { type ShaderLayoutProps, type ShaderSizeToContent } from './html-in-canvas.js';
1
+ import { type PaperShaderElement, type ShaderMotionParams, type ShaderSizeToContent } from '@paper-design/shaders';
3
2
  /**
4
3
  * React Shader Mount can also accept strings as uniform values, which will assumed to be URLs and loaded as images
5
4
  *
@@ -16,12 +15,9 @@ export interface ShaderMountProps extends Omit<React.ComponentProps<'div'>, 'col
16
15
  mipmaps?: string[];
17
16
  minPixelRatio?: number;
18
17
  maxPixelCount?: number;
18
+ resolutionScale?: number;
19
19
  webGlContextAttributes?: WebGLContextAttributes;
20
- /** Set by shaders that can draw their children into u_image (experimental) */
21
20
  acceptsHtmlChildren?: boolean;
22
- /** Props of the element that holds the children and is drawn with them: layout, padding, background, border */
23
- layoutProps?: ShaderLayoutProps;
24
- /** Size the shader to its children on these axes instead of its own width and height styles */
25
21
  sizeToContent?: ShaderSizeToContent;
26
22
  /** Inline CSS width style */
27
23
  width?: string | number;
@@ -32,10 +28,8 @@ export interface ShaderComponentProps extends Omit<React.ComponentProps<'div'>,
32
28
  ref?: React.Ref<PaperShaderElement>;
33
29
  minPixelRatio?: number;
34
30
  maxPixelCount?: number;
31
+ resolutionScale?: number;
35
32
  webGlContextAttributes?: WebGLContextAttributes;
36
- /** Props of the element that holds the children and is drawn with them, for shaders that accept HTML children */
37
- layoutProps?: ShaderLayoutProps;
38
- /** Size the shader to its children on these axes, for shaders that accept HTML children */
39
33
  sizeToContent?: ShaderSizeToContent;
40
34
  /** Inline CSS width style */
41
35
  width?: string | number;
@@ -71,6 +71,22 @@ async function processUniforms(uniformsProp) {
71
71
  await Promise.all(imageLoadPromises);
72
72
  return processedUniforms;
73
73
  }
74
+ function getChangedUniforms(uniforms, appliedUniforms) {
75
+ const changedUniforms = {};
76
+ for (const [key, value] of Object.entries(uniforms)) {
77
+ if (!areUniformValuesEqual(value, appliedUniforms[key])) {
78
+ changedUniforms[key] = value;
79
+ }
80
+ }
81
+ return changedUniforms;
82
+ }
83
+ function areUniformValuesEqual(a, b) {
84
+ if (a === b) return true;
85
+ if (Array.isArray(a) && Array.isArray(b) && a.length === b.length) {
86
+ return a.every((value, i) => areUniformValuesEqual(value, b[i]));
87
+ }
88
+ return false;
89
+ }
74
90
  const ShaderMount = forwardRef(
75
91
  function ShaderMountImpl({
76
92
  fragmentShader,
@@ -82,9 +98,9 @@ const ShaderMount = forwardRef(
82
98
  height,
83
99
  minPixelRatio,
84
100
  maxPixelCount,
101
+ resolutionScale,
85
102
  mipmaps,
86
103
  acceptsHtmlChildren = false,
87
- layoutProps,
88
104
  sizeToContent,
89
105
  children,
90
106
  style,
@@ -94,10 +110,10 @@ const ShaderMount = forwardRef(
94
110
  const divRef = useRef(null);
95
111
  const shaderMountRef = useRef(null);
96
112
  const webGlContextAttributesRef = useRef(webGlContextAttributes);
97
- const { hasHtmlChildren, addHtmlUniform, renderedChildren, sizeStyle } = useHtmlChildren(
113
+ const appliedUniformsRef = useRef({});
114
+ const { hasHtmlChildren, addHtmlUniform, renderedChildren, shaderAttributes, sizeStyle } = useHtmlChildren(
98
115
  acceptsHtmlChildren,
99
116
  children,
100
- layoutProps,
101
117
  sizeToContent,
102
118
  divRef
103
119
  );
@@ -105,7 +121,8 @@ const ShaderMount = forwardRef(
105
121
  useEffect(() => {
106
122
  let isStale = false;
107
123
  const initShader = async () => {
108
- const uniforms = await processUniforms(getUniforms());
124
+ const initialUniforms = getUniforms();
125
+ const uniforms = await processUniforms(initialUniforms);
109
126
  if (!isStale && divRef.current && !shaderMountRef.current) {
110
127
  shaderMountRef.current = new ShaderMountVanilla(
111
128
  divRef.current,
@@ -116,12 +133,19 @@ const ShaderMount = forwardRef(
116
133
  frame,
117
134
  minPixelRatio,
118
135
  maxPixelCount,
119
- mipmaps
136
+ mipmaps,
137
+ resolutionScale
120
138
  );
139
+ appliedUniformsRef.current = initialUniforms;
121
140
  setIsInitialized(true);
122
141
  }
142
+ await shaderMountRef.current?.ready;
143
+ return shaderMountRef.current;
123
144
  };
124
- initShader();
145
+ const ready = initShader();
146
+ if (divRef.current) {
147
+ divRef.current.paperShaderMountReady = ready;
148
+ }
125
149
  return () => {
126
150
  isStale = true;
127
151
  shaderMountRef.current?.dispose();
@@ -129,12 +153,15 @@ const ShaderMount = forwardRef(
129
153
  };
130
154
  }, [fragmentShader, hasHtmlChildren]);
131
155
  useEffect(() => {
156
+ if (!shaderMountRef.current) return;
157
+ const changedUniforms = getChangedUniforms(getUniforms(), appliedUniformsRef.current);
158
+ if (Object.keys(changedUniforms).length === 0) return;
132
159
  let isStale = false;
133
160
  const updateUniforms = async () => {
134
- const uniforms = await processUniforms(getUniforms());
135
- if (!isStale) {
136
- shaderMountRef.current?.setUniforms(uniforms);
137
- }
161
+ const uniforms = await processUniforms(changedUniforms);
162
+ if (isStale || !shaderMountRef.current) return;
163
+ shaderMountRef.current.setUniforms(uniforms);
164
+ appliedUniformsRef.current = { ...appliedUniformsRef.current, ...changedUniforms };
138
165
  };
139
166
  updateUniforms();
140
167
  return () => {
@@ -150,16 +177,28 @@ const ShaderMount = forwardRef(
150
177
  useEffect(() => {
151
178
  shaderMountRef.current?.setMinPixelRatio(minPixelRatio);
152
179
  }, [minPixelRatio, isInitialized]);
180
+ useEffect(() => {
181
+ shaderMountRef.current?.setResolutionScale(resolutionScale);
182
+ }, [resolutionScale, isInitialized]);
153
183
  useEffect(() => {
154
184
  shaderMountRef.current?.setFrame(frame);
155
185
  }, [frame, isInitialized]);
156
186
  const mergedRef = useMergeRefs([divRef, forwardedRef]);
157
- const shaderStyle = width !== void 0 || height !== void 0 ? {
158
- width: typeof width === "string" && isNaN(+width) === false ? +width : width,
159
- height: typeof height === "string" && isNaN(+height) === false ? +height : height,
160
- ...style
161
- } : style;
162
- return /* @__PURE__ */ jsx("div", { ref: mergedRef, style: sizeStyle ? { ...shaderStyle, ...sizeStyle } : shaderStyle, ...divProps, children: renderedChildren });
187
+ return /* @__PURE__ */ jsx(
188
+ "div",
189
+ {
190
+ ref: mergedRef,
191
+ style: width !== void 0 || height !== void 0 ? {
192
+ width: typeof width === "string" && isNaN(+width) === false ? +width : width,
193
+ height: typeof height === "string" && isNaN(+height) === false ? +height : height,
194
+ ...style,
195
+ ...sizeStyle
196
+ } : { ...style, ...sizeStyle },
197
+ ...shaderAttributes,
198
+ ...divProps,
199
+ children: renderedChildren
200
+ }
201
+ );
163
202
  }
164
203
  );
165
204
  ShaderMount.displayName = "ShaderMount";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/shader-mount.tsx"],
4
- "sourcesContent": ["'use client';\n\nimport { useEffect, useRef, forwardRef, useState } from 'react';\nimport {\n ShaderMount as ShaderMountVanilla,\n emptyPixel,\n type PaperShaderElement,\n type ShaderMotionParams,\n type ShaderMountUniforms,\n} from '@paper-design/shaders';\nimport { useMergeRefs } from './use-merge-refs.js';\nimport { setMinImageSize } from './set-min-image-size.js';\nimport { useHtmlChildren, type ShaderLayoutProps, type ShaderSizeToContent } from './html-in-canvas.js';\n\n/**\n * React Shader Mount can also accept strings as uniform values, which will assumed to be URLs and loaded as images\n *\n * We accept undefined as a convenience for server rendering, when some things may be undefined\n * We just skip setting the uniform if it's undefined. This allows the shader mount to still take up space during server rendering\n */\ninterface ShaderMountUniformsReact {\n [key: string]: string | boolean | number | number[] | number[][] | HTMLImageElement | HTMLElement | undefined;\n}\n\nexport interface ShaderMountProps extends Omit<React.ComponentProps<'div'>, 'color' | 'ref'>, ShaderMotionParams {\n ref?: React.Ref<PaperShaderElement>;\n fragmentShader: string;\n uniforms: ShaderMountUniformsReact;\n mipmaps?: string[];\n minPixelRatio?: number;\n maxPixelCount?: number;\n webGlContextAttributes?: WebGLContextAttributes;\n /** Set by shaders that can draw their children into u_image (experimental) */\n acceptsHtmlChildren?: boolean;\n /** Props of the element that holds the children and is drawn with them: layout, padding, background, border */\n layoutProps?: ShaderLayoutProps;\n /** Size the shader to its children on these axes instead of its own width and height styles */\n sizeToContent?: ShaderSizeToContent;\n\n /** Inline CSS width style */\n width?: string | number;\n /** Inline CSS height style */\n height?: string | number;\n}\n\nexport interface ShaderComponentProps extends Omit<React.ComponentProps<'div'>, 'color' | 'ref'> {\n ref?: React.Ref<PaperShaderElement>;\n minPixelRatio?: number;\n maxPixelCount?: number;\n webGlContextAttributes?: WebGLContextAttributes;\n /** Props of the element that holds the children and is drawn with them, for shaders that accept HTML children */\n layoutProps?: ShaderLayoutProps;\n /** Size the shader to its children on these axes, for shaders that accept HTML children */\n sizeToContent?: ShaderSizeToContent;\n\n /** Inline CSS width style */\n width?: string | number;\n /** Inline CSS height style */\n height?: string | number;\n}\n\n/** Parse the provided uniforms, turning URL strings into loaded images */\nasync function processUniforms(uniformsProp: ShaderMountUniformsReact): Promise<ShaderMountUniforms> {\n const processedUniforms = {} as ShaderMountUniforms;\n const imageLoadPromises: Promise<void>[] = [];\n\n const isValidUrl = (url: string): boolean => {\n try {\n // Handle absolute paths\n if (url.startsWith('/')) return true;\n // Check if it's a valid URL\n new URL(url);\n return true;\n } catch {\n return false;\n }\n };\n\n const isExternalUrl = (url: string): boolean => {\n try {\n if (url.startsWith('/')) return false;\n const urlObject = new URL(url, window.location.origin);\n return urlObject.origin !== window.location.origin;\n } catch {\n return false;\n }\n };\n\n Object.entries(uniformsProp).forEach(([key, value]) => {\n if (typeof value === 'string') {\n // Use a transparent pixel for empty strings\n const url = value || emptyPixel;\n\n // Make sure the provided string is a valid URL or just skip trying to set this uniform entirely\n if (!isValidUrl(url)) {\n console.warn(`Uniform \"${key}\" has invalid URL \"${url}\". Skipping image loading.`);\n return;\n }\n\n const imagePromise = new Promise<void>((resolve, reject) => {\n const img = new Image();\n if (isExternalUrl(url)) {\n img.crossOrigin = 'anonymous';\n }\n img.onload = () => {\n setMinImageSize(img);\n processedUniforms[key] = img;\n resolve();\n };\n img.onerror = () => {\n console.error(`Could not set uniforms. Failed to load image at ${url}`);\n reject();\n };\n img.src = url;\n });\n\n imageLoadPromises.push(imagePromise);\n } else if (value instanceof HTMLImageElement) {\n const imagePromise = value.decode().then(() => {\n setMinImageSize(value);\n processedUniforms[key] = value;\n });\n imageLoadPromises.push(imagePromise);\n } else {\n processedUniforms[key] = value;\n }\n });\n\n await Promise.all(imageLoadPromises);\n return processedUniforms;\n}\n\n/**\n * A React component that mounts a shader and updates its uniforms as the component's props change\n * If you pass a string as a uniform value, it will be assumed to be a URL and attempted to be loaded as an image\n */\nexport const ShaderMount: React.FC<ShaderMountProps> = forwardRef<PaperShaderElement, ShaderMountProps>(\n function ShaderMountImpl(\n {\n fragmentShader,\n uniforms: uniformsProp,\n webGlContextAttributes,\n speed = 0,\n frame = 0,\n width,\n height,\n minPixelRatio,\n maxPixelCount,\n mipmaps,\n acceptsHtmlChildren = false,\n layoutProps,\n sizeToContent,\n children,\n style,\n ...divProps\n },\n forwardedRef\n ) {\n const [isInitialized, setIsInitialized] = useState(false);\n const divRef = useRef<PaperShaderElement>(null);\n const shaderMountRef: React.RefObject<ShaderMountVanilla | null> = useRef<ShaderMountVanilla>(null);\n const webGlContextAttributesRef = useRef(webGlContextAttributes);\n const { hasHtmlChildren, addHtmlUniform, renderedChildren, sizeStyle } = useHtmlChildren(\n acceptsHtmlChildren,\n children,\n layoutProps,\n sizeToContent,\n divRef\n );\n\n const getUniforms = (): ShaderMountUniformsReact => addHtmlUniform(uniformsProp);\n\n // Initialize the ShaderMountVanilla\n useEffect(() => {\n let isStale = false;\n\n const initShader = async () => {\n const uniforms = await processUniforms(getUniforms());\n\n if (!isStale && divRef.current && !shaderMountRef.current) {\n shaderMountRef.current = new ShaderMountVanilla(\n divRef.current,\n fragmentShader,\n uniforms,\n webGlContextAttributesRef.current,\n speed,\n frame,\n minPixelRatio,\n maxPixelCount,\n mipmaps\n );\n\n setIsInitialized(true);\n }\n };\n\n initShader();\n\n return () => {\n isStale = true;\n shaderMountRef.current?.dispose();\n shaderMountRef.current = null;\n };\n }, [fragmentShader, hasHtmlChildren]);\n\n // Uniforms\n useEffect(() => {\n let isStale = false;\n\n const updateUniforms = async () => {\n const uniforms = await processUniforms(getUniforms());\n\n if (!isStale) {\n // We only use the freshest uniforms otherwise we can get into race conditions\n // if some uniforms (images!) take longer to load in subsequent effect runs.\n shaderMountRef.current?.setUniforms(uniforms);\n }\n };\n\n updateUniforms();\n\n return () => {\n isStale = true;\n };\n }, [uniformsProp, isInitialized]);\n\n // Speed\n useEffect(() => {\n shaderMountRef.current?.setSpeed(speed);\n }, [speed, isInitialized]);\n\n // Max Pixel Count\n useEffect(() => {\n shaderMountRef.current?.setMaxPixelCount(maxPixelCount);\n }, [maxPixelCount, isInitialized]);\n\n // Min Pixel Ratio\n useEffect(() => {\n shaderMountRef.current?.setMinPixelRatio(minPixelRatio);\n }, [minPixelRatio, isInitialized]);\n\n // Frame\n useEffect(() => {\n shaderMountRef.current?.setFrame(frame);\n }, [frame, isInitialized]);\n\n const mergedRef = useMergeRefs([divRef, forwardedRef]) as unknown as React.RefObject<HTMLDivElement>;\n const shaderStyle =\n width !== undefined || height !== undefined\n ? {\n width: typeof width === 'string' && isNaN(+width) === false ? +width : width,\n height: typeof height === 'string' && isNaN(+height) === false ? +height : height,\n ...style,\n }\n : style;\n return (\n <div ref={mergedRef} style={sizeStyle ? { ...shaderStyle, ...sizeStyle } : shaderStyle} {...divProps}>\n {renderedChildren}\n </div>\n );\n }\n);\n\nShaderMount.displayName = 'ShaderMount';\n"],
5
- "mappings": ";;;;;;AAEA,SAAS,WAAW,QAAQ,YAAY,gBAAgB;AACxD;AAAA,EACE,eAAe;AAAA,EACf;AAAA,OAIK;AACP,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,uBAAyE;AAoP5E;AAlMN,eAAe,gBAAgB,cAAsE;AACnG,QAAM,oBAAoB,CAAC;AAC3B,QAAM,oBAAqC,CAAC;AAE5C,QAAM,aAAa,CAAC,QAAyB;AAC3C,QAAI;AAEF,UAAI,IAAI,WAAW,GAAG,EAAG,QAAO;AAEhC,UAAI,IAAI,GAAG;AACX,aAAO;AAAA,IACT,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,gBAAgB,CAAC,QAAyB;AAC9C,QAAI;AACF,UAAI,IAAI,WAAW,GAAG,EAAG,QAAO;AAChC,YAAM,YAAY,IAAI,IAAI,KAAK,OAAO,SAAS,MAAM;AACrD,aAAO,UAAU,WAAW,OAAO,SAAS;AAAA,IAC9C,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO,QAAQ,YAAY,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACrD,QAAI,OAAO,UAAU,UAAU;AAE7B,YAAM,MAAM,SAAS;AAGrB,UAA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AAS,SAAS,KAAK;AAAA,IACxC,GAAG,CAAC,OAAO,aAAa,CAAC;AAEzB,UAAM,YAAY,aAAa,CAAC,QAAQ,YAAY,CAAC;AACrD,UAAM,cACJ,UAAU,UAAa,WAAW,SAC9B;AAAA,MACE,OAAO,OAAO,UAAU,YAAY,MAAM,CAAC,KAAK,MAAM,QAAQ,CAAC,QAAQ;AAAA,MACvE,QAAQ,OAAO,WAAW,YAAY,MAAM,CAAC,MAAM,MAAM,QAAQ,CAAC,SAAS;AAAA,MAC3E,GAAG;AAAA,IACL,IACA;AACN,WACE,oBAAC,SAAI,KAAK,WAAW,OAAO,YAAY,EAAE,GAAG,aAAa,GAAG,UAAU,IAAI,aAAc,GAAG,UACzF,4BACH;AAAA,EAEJ;AACF;AAEA,YAAY,cAAc;",
4
+ "sourcesContent": ["'use client';\n\nimport { useEffect, useRef, forwardRef, useState } from 'react';\nimport {\n ShaderMount as ShaderMountVanilla,\n emptyPixel,\n type PaperShaderElement,\n type ShaderMotionParams,\n type ShaderMountUniforms,\n type ShaderSizeToContent,\n} from '@paper-design/shaders';\nimport { useMergeRefs } from './use-merge-refs.js';\nimport { setMinImageSize } from './set-min-image-size.js';\nimport { useHtmlChildren } from './html-in-canvas.js';\n\n/**\n * React Shader Mount can also accept strings as uniform values, which will assumed to be URLs and loaded as images\n *\n * We accept undefined as a convenience for server rendering, when some things may be undefined\n * We just skip setting the uniform if it's undefined. This allows the shader mount to still take up space during server rendering\n */\ninterface ShaderMountUniformsReact {\n [key: string]: string | boolean | number | number[] | number[][] | HTMLImageElement | HTMLElement | undefined;\n}\n\nexport interface ShaderMountProps extends Omit<React.ComponentProps<'div'>, 'color' | 'ref'>, ShaderMotionParams {\n ref?: React.Ref<PaperShaderElement>;\n fragmentShader: string;\n uniforms: ShaderMountUniformsReact;\n mipmaps?: string[];\n minPixelRatio?: number;\n maxPixelCount?: number;\n resolutionScale?: number;\n webGlContextAttributes?: WebGLContextAttributes;\n acceptsHtmlChildren?: boolean;\n sizeToContent?: ShaderSizeToContent;\n\n /** Inline CSS width style */\n width?: string | number;\n /** Inline CSS height style */\n height?: string | number;\n}\n\nexport interface ShaderComponentProps extends Omit<React.ComponentProps<'div'>, 'color' | 'ref'> {\n ref?: React.Ref<PaperShaderElement>;\n minPixelRatio?: number;\n maxPixelCount?: number;\n resolutionScale?: number;\n webGlContextAttributes?: WebGLContextAttributes;\n sizeToContent?: ShaderSizeToContent;\n\n /** Inline CSS width style */\n width?: string | number;\n /** Inline CSS height style */\n height?: string | number;\n}\n\n/** Parse the provided uniforms, turning URL strings into loaded images */\nasync function processUniforms(uniformsProp: ShaderMountUniformsReact): Promise<ShaderMountUniforms> {\n const processedUniforms = {} as ShaderMountUniforms;\n const imageLoadPromises: Promise<void>[] = [];\n\n const isValidUrl = (url: string): boolean => {\n try {\n // Handle absolute paths\n if (url.startsWith('/')) return true;\n // Check if it's a valid URL\n new URL(url);\n return true;\n } catch {\n return false;\n }\n };\n\n const isExternalUrl = (url: string): boolean => {\n try {\n if (url.startsWith('/')) return false;\n const urlObject = new URL(url, window.location.origin);\n return urlObject.origin !== window.location.origin;\n } catch {\n return false;\n }\n };\n\n Object.entries(uniformsProp).forEach(([key, value]) => {\n if (typeof value === 'string') {\n // Use a transparent pixel for empty strings\n const url = value || emptyPixel;\n\n // Make sure the provided string is a valid URL or just skip trying to set this uniform entirely\n if (!isValidUrl(url)) {\n console.warn(`Uniform \"${key}\" has invalid URL \"${url}\". Skipping image loading.`);\n return;\n }\n\n const imagePromise = new Promise<void>((resolve, reject) => {\n const img = new Image();\n if (isExternalUrl(url)) {\n img.crossOrigin = 'anonymous';\n }\n img.onload = () => {\n setMinImageSize(img);\n processedUniforms[key] = img;\n resolve();\n };\n img.onerror = () => {\n console.error(`Could not set uniforms. Failed to load image at ${url}`);\n reject();\n };\n img.src = url;\n });\n\n imageLoadPromises.push(imagePromise);\n } else if (value instanceof HTMLImageElement) {\n const imagePromise = value.decode().then(() => {\n setMinImageSize(value);\n processedUniforms[key] = value;\n });\n imageLoadPromises.push(imagePromise);\n } else {\n processedUniforms[key] = value;\n }\n });\n\n await Promise.all(imageLoadPromises);\n return processedUniforms;\n}\n\n/** The uniforms that differ from the applied ones */\nfunction getChangedUniforms(\n uniforms: ShaderMountUniformsReact,\n appliedUniforms: ShaderMountUniformsReact\n): ShaderMountUniformsReact {\n const changedUniforms: ShaderMountUniformsReact = {};\n for (const [key, value] of Object.entries(uniforms)) {\n if (!areUniformValuesEqual(value, appliedUniforms[key])) {\n changedUniforms[key] = value;\n }\n }\n return changedUniforms;\n}\n\nfunction areUniformValuesEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true;\n if (Array.isArray(a) && Array.isArray(b) && a.length === b.length) {\n return a.every((value, i) => areUniformValuesEqual(value, b[i]));\n }\n return false;\n}\n\n/**\n * A React component that mounts a shader and updates its uniforms as the component's props change\n * If you pass a string as a uniform value, it will be assumed to be a URL and attempted to be loaded as an image\n */\nexport const ShaderMount: React.FC<ShaderMountProps> = forwardRef<PaperShaderElement, ShaderMountProps>(\n function ShaderMountImpl(\n {\n fragmentShader,\n uniforms: uniformsProp,\n webGlContextAttributes,\n speed = 0,\n frame = 0,\n width,\n height,\n minPixelRatio,\n maxPixelCount,\n resolutionScale,\n mipmaps,\n acceptsHtmlChildren = false,\n sizeToContent,\n children,\n style,\n ...divProps\n },\n forwardedRef\n ) {\n const [isInitialized, setIsInitialized] = useState(false);\n const divRef = useRef<PaperShaderElement>(null);\n const shaderMountRef: React.RefObject<ShaderMountVanilla | null> = useRef<ShaderMountVanilla>(null);\n const webGlContextAttributesRef = useRef(webGlContextAttributes);\n /** The uniform props the mount has, as passed before processing */\n const appliedUniformsRef = useRef<ShaderMountUniformsReact>({});\n const { hasHtmlChildren, addHtmlUniform, renderedChildren, shaderAttributes, sizeStyle } = useHtmlChildren(\n acceptsHtmlChildren,\n children,\n sizeToContent,\n divRef\n );\n\n const getUniforms = (): ShaderMountUniformsReact => addHtmlUniform(uniformsProp);\n\n // Initialize the ShaderMountVanilla\n useEffect(() => {\n let isStale = false;\n\n const initShader = async () => {\n const initialUniforms = getUniforms();\n const uniforms = await processUniforms(initialUniforms);\n\n if (!isStale && divRef.current && !shaderMountRef.current) {\n shaderMountRef.current = new ShaderMountVanilla(\n divRef.current,\n fragmentShader,\n uniforms,\n webGlContextAttributesRef.current,\n speed,\n frame,\n minPixelRatio,\n maxPixelCount,\n mipmaps,\n resolutionScale\n );\n appliedUniformsRef.current = initialUniforms;\n\n setIsInitialized(true);\n }\n\n await shaderMountRef.current?.ready;\n return shaderMountRef.current;\n };\n\n const ready = initShader();\n if (divRef.current) {\n divRef.current.paperShaderMountReady = ready;\n }\n\n return () => {\n isStale = true;\n shaderMountRef.current?.dispose();\n shaderMountRef.current = null;\n };\n }, [fragmentShader, hasHtmlChildren]);\n\n // Uniforms\n useEffect(() => {\n // The mount is created with the uniforms of that moment\n if (!shaderMountRef.current) return;\n\n // Uniforms are a new object on every render, unchanged images aren't loaded again\n const changedUniforms = getChangedUniforms(getUniforms(), appliedUniformsRef.current);\n if (Object.keys(changedUniforms).length === 0) return;\n\n let isStale = false;\n\n const updateUniforms = async () => {\n const uniforms = await processUniforms(changedUniforms);\n\n // We only use the freshest uniforms otherwise we can get into race conditions\n // if some uniforms (images!) take longer to load in subsequent effect runs.\n // A stale run isn't marked applied, so the next run includes its changes\n if (isStale || !shaderMountRef.current) return;\n\n shaderMountRef.current.setUniforms(uniforms);\n appliedUniformsRef.current = { ...appliedUniformsRef.current, ...changedUniforms };\n };\n\n updateUniforms();\n\n return () => {\n isStale = true;\n };\n }, [uniformsProp, isInitialized]);\n\n // Speed\n useEffect(() => {\n shaderMountRef.current?.setSpeed(speed);\n }, [speed, isInitialized]);\n\n // Max Pixel Count\n useEffect(() => {\n shaderMountRef.current?.setMaxPixelCount(maxPixelCount);\n }, [maxPixelCount, isInitialized]);\n\n // Min Pixel Ratio\n useEffect(() => {\n shaderMountRef.current?.setMinPixelRatio(minPixelRatio);\n }, [minPixelRatio, isInitialized]);\n\n // Resolution Scale\n useEffect(() => {\n shaderMountRef.current?.setResolutionScale(resolutionScale);\n }, [resolutionScale, isInitialized]);\n\n // Frame\n useEffect(() => {\n shaderMountRef.current?.setFrame(frame);\n }, [frame, isInitialized]);\n\n const mergedRef = useMergeRefs([divRef, forwardedRef]) as unknown as React.RefObject<HTMLDivElement>;\n return (\n <div\n ref={mergedRef}\n style={\n width !== undefined || height !== undefined\n ? {\n width: typeof width === 'string' && isNaN(+width) === false ? +width : width,\n height: typeof height === 'string' && isNaN(+height) === false ? +height : height,\n ...style,\n ...sizeStyle,\n }\n : { ...style, ...sizeStyle }\n }\n {...shaderAttributes}\n {...divProps}\n >\n {renderedChildren}\n </div>\n );\n }\n);\n\nShaderMount.displayName = 'ShaderMount';\n"],
5
+ "mappings": ";;;;;;AAEA,SAAS,WAAW,QAAQ,YAAY,gBAAgB;AACxD;AAAA,EACE,eAAe;AAAA,EACf;AAAA,OAKK;AACP,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAqR1B;AAxON,eAAe,gBAAgB,cAAsE;AACnG,QAAM,oBAAoB,CAAC;AAC3B,QAAM,oBAAqC,CAAC;AAE5C,QAAM,aAAa,CAAC,QAAyB;AAC3C,QAAI;AAEF,UAAI,IAAI,WAAW,GAAG,EAAG,QAAO;AAEhC,UAAI,IAAI,GAAG;AACX,aAAO;AAAA,IACT,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,gBAAgB,CAAC,QAAyB;AAC9C,QAAI;AACF,UAAI,IAAI,WAAW,GAAG,EAAG,QAAO;AAChC,YAAM,YAAY,IAAI,IAAI,KAAK,OAAO,SAAS,MAAM;AACrD,aAAO,UAAU,WAAW,OAAO,SAAS;AAAA,IAC9C,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO,QAAQ,YAAY,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACrD,QAAI,O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UAAU,UAAa,WAAW,SAC9B;AAAA,UACE,OAAO,OAAO,UAAU,YAAY,MAAM,CAAC,KAAK,MAAM,QAAQ,CAAC,QAAQ;AAAA,UACvE,QAAQ,OAAO,WAAW,YAAY,MAAM,CAAC,MAAM,MAAM,QAAQ,CAAC,SAAS;AAAA,UAC3E,GAAG;AAAA,UACH,GAAG;AAAA,QACL,IACA,EAAE,GAAG,OAAO,GAAG,UAAU;AAAA,QAE9B,GAAG;AAAA,QACH,GAAG;AAAA,QAEH;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,YAAY,cAAc;",
6
6
  "names": []
7
7
  }
@@ -6,7 +6,6 @@
6
6
  import { memo } from "react";
7
7
  import { ShaderMount } from "../shader-mount.js";
8
8
  import { colorPropsAreEqual } from "../color-props-are-equal.js";
9
- import { willDrawHtmlChildren } from "../html-in-canvas.js";
10
9
  import {
11
10
  defaultObjectSizing,
12
11
  getShaderColorFromString,
@@ -199,7 +198,7 @@ const PaperTexture = memo(function PaperTextureImpl({
199
198
  const uniforms = {
200
199
  // Own uniforms
201
200
  u_image: image,
202
- u_isImage: willDrawHtmlChildren(props.children) || Boolean(image),
201
+ u_isImage: Boolean(image),
203
202
  u_colorBack: getShaderColorFromString(colorBack),
204
203
  u_colorPaper: getShaderColorFromString(colorPaper),
205
204
  u_colorShadow: getShaderColorFromString(colorShadow),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/shaders/paper-texture.tsx"],
4
- "sourcesContent": ["import { memo } from 'react';\nimport { ShaderMount, type ShaderComponentProps } from '../shader-mount.js';\nimport { colorPropsAreEqual } from '../color-props-are-equal.js';\nimport { willDrawHtmlChildren } from '../html-in-canvas.js';\nimport {\n defaultObjectSizing,\n getShaderColorFromString,\n getShaderNoiseTexture,\n paperTextureFragmentShader,\n ShaderFitOptions,\n type ImageShaderPreset,\n type PaperTextureParams,\n type PaperTextureUniforms,\n} from '@paper-design/shaders';\n\nexport interface PaperTextureProps extends ShaderComponentProps, PaperTextureParams {\n /** @deprecated use `fiberSize` instead */\n fiberScale?: number;\n /** @deprecated use `crumpleCount` instead */\n foldsNumber?: number;\n}\n\ntype PaperTexturePreset = ImageShaderPreset<PaperTextureParams>;\n\nexport const defaultPreset: PaperTexturePreset = {\n name: 'Default',\n params: {\n ...defaultObjectSizing,\n fit: 'contain',\n scale: 0.9,\n speed: 0,\n frame: 0,\n colorBack: '#d3d2ab',\n colorPaper: '#ffffff',\n colorShadow: '#cccccc',\n blending: 1,\n distortion: 0.75,\n clip: false,\n angle: 300,\n seed: 4,\n roughness: 0.4,\n roughnessSize: 0.5,\n roughnessRows: 0,\n fiber: 0.4,\n fiberSize: 0.5,\n folds: 0.5,\n foldSizeX: 1,\n foldSizeY: 1,\n foldOffsetX: 0,\n foldOffsetY: 0,\n wrinkles: 1,\n wrinkleSize: 0.65,\n crumples: 0,\n crumpleCount: 6,\n drops: 0.4,\n },\n};\n\nexport const creasedPreset: PaperTexturePreset = {\n name: 'Creased',\n params: {\n ...defaultObjectSizing,\n fit: 'contain',\n scale: 0.9,\n speed: 0,\n frame: 0,\n colorBack: '#d3d2ab',\n colorPaper: '#ffffff',\n colorShadow: '#b3b3b3',\n blending: 1,\n distortion: -0.5,\n clip: false,\n angle: 60,\n seed: 49,\n roughness: 0.4,\n roughnessSize: 0.25,\n roughnessRows: 0,\n fiber: 0.4,\n fiberSize: 0.5,\n folds: 0,\n foldSizeX: 0.6,\n foldSizeY: 0.89,\n foldOffsetX: 0.59,\n foldOffsetY: 1,\n wrinkles: 0,\n wrinkleSize: 0.65,\n crumples: 1,\n crumpleCount: 4,\n drops: 0,\n },\n};\n\nexport const spreadPreset: PaperTexturePreset = {\n name: 'Spread',\n params: {\n ...defaultObjectSizing,\n fit: 'contain',\n scale: 0.9,\n speed: 0,\n frame: 0,\n colorBack: '#ffffff00',\n colorPaper: '#ffffffb5',\n colorShadow: '#b3b3b3',\n blending: 1,\n distortion: -0.3,\n clip: true,\n angle: 236,\n seed: 613,\n roughness: 0.15,\n roughnessSize: 0.25,\n roughnessRows: 0,\n fiber: 0.5,\n fiberSize: 0.5,\n folds: 1,\n foldSizeX: 0.4,\n foldSizeY: 0.89,\n foldOffsetX: 0,\n foldOffsetY: 0,\n wrinkles: 0,\n wrinkleSize: 0.65,\n crumples: 0,\n crumpleCount: 9,\n drops: 0,\n },\n};\n\nexport const flatPreset: PaperTexturePreset = {\n name: 'Flat',\n params: {\n ...defaultObjectSizing,\n fit: 'contain',\n scale: 0.9,\n speed: 0,\n frame: 0,\n colorBack: '#d4cdab',\n colorPaper: '#ffffffa8',\n colorShadow: '#b3b3b3',\n blending: 1,\n distortion: 0,\n clip: false,\n angle: 0,\n seed: 455,\n roughness: 1,\n roughnessSize: 0.5,\n roughnessRows: 0.6,\n fiber: 0.7,\n fiberSize: 1,\n folds: 0,\n foldSizeX: 0,\n foldSizeY: 0.44,\n foldOffsetX: 0,\n foldOffsetY: 0,\n wrinkles: 0,\n wrinkleSize: 0,\n crumples: 0,\n crumpleCount: 6,\n drops: 0.2,\n },\n};\n\nexport const paperTexturePresets: PaperTexturePreset[] = [\n defaultPreset,\n spreadPreset,\n creasedPreset,\n flatPreset,\n] as const;\n\nexport const PaperTexture: React.FC<PaperTextureProps> = memo(function PaperTextureImpl({\n // Own props\n speed = defaultPreset.params.speed,\n frame = defaultPreset.params.frame,\n image = '',\n colorBack = defaultPreset.params.colorBack,\n colorPaper = defaultPreset.params.colorPaper,\n colorShadow = defaultPreset.params.colorShadow,\n blending = defaultPreset.params.blending,\n distortion = defaultPreset.params.distortion,\n clip = defaultPreset.params.clip,\n angle = defaultPreset.params.angle,\n seed = defaultPreset.params.seed,\n roughness = defaultPreset.params.roughness,\n roughnessSize = defaultPreset.params.roughnessSize,\n roughnessRows = defaultPreset.params.roughnessRows,\n fiber = defaultPreset.params.fiber,\n fiberScale,\n fiberSize = fiberScale === undefined ? defaultPreset.params.fiberSize : 0.2 / fiberScale,\n folds = defaultPreset.params.folds,\n foldSizeX = defaultPreset.params.foldSizeX,\n foldSizeY = defaultPreset.params.foldSizeY,\n foldOffsetX = defaultPreset.params.foldOffsetX,\n foldOffsetY = defaultPreset.params.foldOffsetY,\n wrinkles = defaultPreset.params.wrinkles,\n wrinkleSize = defaultPreset.params.wrinkleSize,\n crumples = defaultPreset.params.crumples,\n foldsNumber,\n crumpleCount = foldsNumber === undefined ? defaultPreset.params.crumpleCount : foldsNumber,\n drops = defaultPreset.params.drops,\n\n // Sizing props\n fit = defaultPreset.params.fit,\n scale = defaultPreset.params.scale,\n rotation = defaultPreset.params.rotation,\n originX = defaultPreset.params.originX,\n originY = defaultPreset.params.originY,\n offsetX = defaultPreset.params.offsetX,\n offsetY = defaultPreset.params.offsetY,\n worldWidth = defaultPreset.params.worldWidth,\n worldHeight = defaultPreset.params.worldHeight,\n ...props\n}: PaperTextureProps) {\n const noiseTexture = typeof window !== 'undefined' && { u_noiseTexture: getShaderNoiseTexture() };\n\n const uniforms = {\n // Own uniforms\n u_image: image,\n u_isImage: willDrawHtmlChildren(props.children) || Boolean(image),\n u_colorBack: getShaderColorFromString(colorBack),\n u_colorPaper: getShaderColorFromString(colorPaper),\n u_colorShadow: getShaderColorFromString(colorShadow),\n u_blending: blending,\n u_distortion: distortion,\n u_clip: clip,\n u_angle: angle,\n u_seed: seed,\n u_roughness: roughness,\n u_roughnessSize: roughnessSize,\n u_roughnessRows: roughnessRows,\n u_fiber: fiber,\n u_fiberSize: fiberSize,\n u_folds: folds,\n u_foldSizeX: foldSizeX,\n u_foldSizeY: foldSizeY,\n u_foldOffsetX: foldOffsetX,\n u_foldOffsetY: foldOffsetY,\n u_wrinkles: wrinkles,\n u_wrinkleSize: wrinkleSize,\n u_crumples: crumples,\n u_crumpleCount: crumpleCount,\n u_drops: drops,\n ...noiseTexture,\n\n // Sizing uniforms\n u_fit: ShaderFitOptions[fit],\n u_scale: scale,\n u_rotation: rotation,\n u_offsetX: offsetX,\n u_offsetY: offsetY,\n u_originX: originX,\n u_originY: originY,\n u_worldWidth: worldWidth,\n u_worldHeight: worldHeight,\n } satisfies PaperTextureUniforms;\n\n return (\n <ShaderMount\n {...props}\n speed={speed}\n frame={frame}\n fragmentShader={paperTextureFragmentShader}\n acceptsHtmlChildren\n mipmaps={['u_image']}\n uniforms={uniforms}\n />\n );\n}, colorPropsAreEqual);\n"],
5
- "mappings": ";;;;;AAAA,SAAS,YAAY;AACrB,SAAS,mBAA8C;AACvD,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAiPH;AAtOG,MAAM,gBAAoC;AAAA,EAC/C,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,GAAG;AAAA,IACH,KAAK;AAAA,IACL,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,MAAM;AAAA,IACN,OAAO;AAAA,IACP,MAAM;AAAA,IACN,WAAW;AAAA,IACX,eAAe;AAAA,IACf,eAAe;AAAA,IACf,OAAO;AAAA,IACP,WAAW;AAAA,IACX,OAAO;AAAA,IACP,WAAW;AAAA,IACX,WAAW;AAAA,IACX,aAAa;AAAA,IACb,aAAa;AAAA,IACb,UAAU;AAAA,IACV,aAAa;AAAA,IACb,UAAU;AAAA,IACV,cAAc;AAAA,IACd,OAAO;AAAA,EACT;AACF;AAEO,MAAM,gBAAoC;AAAA,EAC/C,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,GAAG;AAAA,IACH,KAAK;AAAA,IACL,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,MAAM;AAAA,IACN,OAAO;AAAA,IACP,MAAM;AAAA,IACN,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aderMount, type ShaderComponentProps } from '../shader-mount.js';\nimport { colorPropsAreEqual } from '../color-props-are-equal.js';\nimport {\n defaultObjectSizing,\n getShaderColorFromString,\n getShaderNoiseTexture,\n paperTextureFragmentShader,\n ShaderFitOptions,\n type ImageShaderPreset,\n type PaperTextureParams,\n type PaperTextureUniforms,\n} from '@paper-design/shaders';\n\nexport interface PaperTextureProps extends ShaderComponentProps, PaperTextureParams {\n /** @deprecated use `fiberSize` instead */\n fiberScale?: number;\n /** @deprecated use `crumpleCount` instead */\n foldsNumber?: number;\n}\n\ntype PaperTexturePreset = ImageShaderPreset<PaperTextureParams>;\n\nexport const defaultPreset: PaperTexturePreset = {\n name: 'Default',\n params: {\n ...defaultObjectSizing,\n fit: 'contain',\n scale: 0.9,\n speed: 0,\n frame: 0,\n colorBack: '#d3d2ab',\n colorPaper: '#ffffff',\n colorShadow: '#cccccc',\n blending: 1,\n distortion: 0.75,\n clip: false,\n angle: 300,\n seed: 4,\n roughness: 0.4,\n roughnessSize: 0.5,\n roughnessRows: 0,\n fiber: 0.4,\n fiberSize: 0.5,\n folds: 0.5,\n foldSizeX: 1,\n foldSizeY: 1,\n foldOffsetX: 0,\n foldOffsetY: 0,\n wrinkles: 1,\n wrinkleSize: 0.65,\n crumples: 0,\n crumpleCount: 6,\n drops: 0.4,\n },\n};\n\nexport const creasedPreset: PaperTexturePreset = {\n name: 'Creased',\n params: {\n ...defaultObjectSizing,\n fit: 'contain',\n scale: 0.9,\n speed: 0,\n frame: 0,\n colorBack: '#d3d2ab',\n colorPaper: '#ffffff',\n colorShadow: '#b3b3b3',\n blending: 1,\n distortion: -0.5,\n clip: false,\n angle: 60,\n seed: 49,\n roughness: 0.4,\n roughnessSize: 0.25,\n roughnessRows: 0,\n fiber: 0.4,\n fiberSize: 0.5,\n folds: 0,\n foldSizeX: 0.6,\n foldSizeY: 0.89,\n foldOffsetX: 0.59,\n foldOffsetY: 1,\n wrinkles: 0,\n wrinkleSize: 0.65,\n crumples: 1,\n crumpleCount: 4,\n drops: 0,\n },\n};\n\nexport const spreadPreset: PaperTexturePreset = {\n name: 'Spread',\n params: {\n ...defaultObjectSizing,\n fit: 'contain',\n scale: 0.9,\n speed: 0,\n frame: 0,\n colorBack: '#ffffff00',\n colorPaper: '#ffffffb5',\n colorShadow: '#b3b3b3',\n blending: 1,\n distortion: -0.3,\n clip: true,\n angle: 236,\n seed: 613,\n roughness: 0.15,\n roughnessSize: 0.25,\n roughnessRows: 0,\n fiber: 0.5,\n fiberSize: 0.5,\n folds: 1,\n foldSizeX: 0.4,\n foldSizeY: 0.89,\n foldOffsetX: 0,\n foldOffsetY: 0,\n wrinkles: 0,\n wrinkleSize: 0.65,\n crumples: 0,\n crumpleCount: 9,\n drops: 0,\n },\n};\n\nexport const flatPreset: PaperTexturePreset = {\n name: 'Flat',\n params: {\n ...defaultObjectSizing,\n fit: 'contain',\n scale: 0.9,\n speed: 0,\n frame: 0,\n colorBack: '#d4cdab',\n colorPaper: '#ffffffa8',\n colorShadow: '#b3b3b3',\n blending: 1,\n distortion: 0,\n clip: false,\n angle: 0,\n seed: 455,\n roughness: 1,\n roughnessSize: 0.5,\n roughnessRows: 0.6,\n fiber: 0.7,\n fiberSize: 1,\n folds: 0,\n foldSizeX: 0,\n foldSizeY: 0.44,\n foldOffsetX: 0,\n foldOffsetY: 0,\n wrinkles: 0,\n wrinkleSize: 0,\n crumples: 0,\n crumpleCount: 6,\n drops: 0.2,\n },\n};\n\nexport const paperTexturePresets: PaperTexturePreset[] = [\n defaultPreset,\n spreadPreset,\n creasedPreset,\n flatPreset,\n] as const;\n\nexport const PaperTexture: React.FC<PaperTextureProps> = memo(function PaperTextureImpl({\n // Own props\n speed = defaultPreset.params.speed,\n frame = defaultPreset.params.frame,\n image = '',\n colorBack = defaultPreset.params.colorBack,\n colorPaper = defaultPreset.params.colorPaper,\n colorShadow = defaultPreset.params.colorShadow,\n blending = defaultPreset.params.blending,\n distortion = defaultPreset.params.distortion,\n clip = defaultPreset.params.clip,\n angle = defaultPreset.params.angle,\n seed = defaultPreset.params.seed,\n roughness = defaultPreset.params.roughness,\n roughnessSize = defaultPreset.params.roughnessSize,\n roughnessRows = defaultPreset.params.roughnessRows,\n fiber = defaultPreset.params.fiber,\n fiberScale,\n fiberSize = fiberScale === undefined ? defaultPreset.params.fiberSize : 0.2 / fiberScale,\n folds = defaultPreset.params.folds,\n foldSizeX = defaultPreset.params.foldSizeX,\n foldSizeY = defaultPreset.params.foldSizeY,\n foldOffsetX = defaultPreset.params.foldOffsetX,\n foldOffsetY = defaultPreset.params.foldOffsetY,\n wrinkles = defaultPreset.params.wrinkles,\n wrinkleSize = defaultPreset.params.wrinkleSize,\n crumples = defaultPreset.params.crumples,\n foldsNumber,\n crumpleCount = foldsNumber === undefined ? defaultPreset.params.crumpleCount : foldsNumber,\n drops = defaultPreset.params.drops,\n\n // Sizing props\n fit = defaultPreset.params.fit,\n scale = defaultPreset.params.scale,\n rotation = defaultPreset.params.rotation,\n originX = defaultPreset.params.originX,\n originY = defaultPreset.params.originY,\n offsetX = defaultPreset.params.offsetX,\n offsetY = defaultPreset.params.offsetY,\n worldWidth = defaultPreset.params.worldWidth,\n worldHeight = defaultPreset.params.worldHeight,\n ...props\n}: PaperTextureProps) {\n const noiseTexture = typeof window !== 'undefined' && { u_noiseTexture: getShaderNoiseTexture() };\n\n const uniforms = {\n // Own uniforms\n u_image: image,\n u_isImage: Boolean(image),\n u_colorBack: getShaderColorFromString(colorBack),\n u_colorPaper: getShaderColorFromString(colorPaper),\n u_colorShadow: getShaderColorFromString(colorShadow),\n u_blending: blending,\n u_distortion: distortion,\n u_clip: clip,\n u_angle: angle,\n u_seed: seed,\n u_roughness: roughness,\n u_roughnessSize: roughnessSize,\n u_roughnessRows: roughnessRows,\n u_fiber: fiber,\n u_fiberSize: fiberSize,\n u_folds: folds,\n u_foldSizeX: foldSizeX,\n u_foldSizeY: foldSizeY,\n u_foldOffsetX: foldOffsetX,\n u_foldOffsetY: foldOffsetY,\n u_wrinkles: wrinkles,\n u_wrinkleSize: wrinkleSize,\n u_crumples: crumples,\n u_crumpleCount: crumpleCount,\n u_drops: drops,\n ...noiseTexture,\n\n // Sizing uniforms\n u_fit: ShaderFitOptions[fit],\n u_scale: scale,\n u_rotation: rotation,\n u_offsetX: offsetX,\n u_offsetY: offsetY,\n u_originX: originX,\n u_originY: originY,\n u_worldWidth: worldWidth,\n u_worldHeight: worldHeight,\n } satisfies PaperTextureUniforms;\n\n return (\n <ShaderMount\n {...props}\n speed={speed}\n frame={frame}\n fragmentShader={paperTextureFragmentShader}\n acceptsHtmlChildren\n mipmaps={['u_image']}\n uniforms={uniforms}\n />\n );\n}, colorPropsAreEqual);\n"],
5
+ "mappings": ";;;;;AAAA,SAAS,YAAY;AACrB,SAAS,mBAA8C;AACvD,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAiPH;AAtOG,MAAM,gBAAoC;AAAA,EAC/C,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,GAAG;AAAA,IACH,KAAK;AAAA,IACL,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO;AAAA,IACP,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,MAAM;AAAA,IACN,OAAO;AAAA,IACP,MAAM;AAAA,IACN,WAAW;AAAA,IACX,eAAe;AAAA,IACf,eAAe;AAAA,IACf,OAAO;AAAA,IACP,WAAW;AAAA,IACX,OAAO;AAAA,IACP,WAAW;AAAA,IACX,WAAW;AAAA,IACX,aAAa;AAAA,IACb,aAAa;AAAA,IACb,UAAU;AAAA,IACV,aAAa;AAAA,IACb,UAAU;AAAA,IACV,cAAc;AAAA,IACd,OAAO;AAAA,EACT;AACF;AAEO,MAAM,gBAAoC;AAAA,EAC/C,MAAM;AAAA,EACN,QAAQ;AAAA,IACN,GAAG;AAAA,IACH,KAAK;AAA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A,MACA;AAAA,MACA,gBAAgB;AAAA,MAChB,qBAAmB;AAAA,MACnB,SAAS,CAAC,SAAS;AAAA,MACnB;AAAA;AAAA,EACF;AAEJ,GAAG,kBAAkB;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paper-design/shaders-react",
3
- "version": "0.0.0-canary.2d03406",
3
+ "version": "0.0.0-canary.3ce21729",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -26,7 +26,7 @@
26
26
  "type-check": "tsc --project tsconfig.json"
27
27
  },
28
28
  "dependencies": {
29
- "@paper-design/shaders": "0.0.0-canary.2d03406"
29
+ "@paper-design/shaders": "0.0.0-canary.3ce21729"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/react": "19.1.0"