@meonode/canvas 2.0.2 → 2.0.4

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.
Files changed (119) hide show
  1. package/dist/cjs/{src/canvas → canvas}/canvas.helper.d.ts +1 -20
  2. package/dist/cjs/canvas/canvas.helper.d.ts.map +1 -0
  3. package/dist/cjs/canvas/canvas.helper.js +0 -230
  4. package/dist/cjs/canvas/canvas.helper.js.map +1 -1
  5. package/dist/{esm/src → cjs}/canvas/canvas.type.d.ts +1 -12
  6. package/dist/cjs/canvas/canvas.type.d.ts.map +1 -0
  7. package/dist/cjs/{src/canvas → canvas}/chart.canvas.d.ts +1 -1
  8. package/dist/cjs/canvas/chart.canvas.d.ts.map +1 -0
  9. package/dist/cjs/canvas/chart.canvas.js +70 -144
  10. package/dist/cjs/canvas/chart.canvas.js.map +1 -1
  11. package/dist/cjs/canvas/grid.canvas.d.ts.map +1 -0
  12. package/dist/cjs/canvas/grid.canvas.js.map +1 -1
  13. package/dist/{esm/src → cjs}/canvas/image.canvas.d.ts +1 -1
  14. package/dist/cjs/canvas/image.canvas.d.ts.map +1 -0
  15. package/dist/cjs/canvas/image.canvas.js +2 -2
  16. package/dist/cjs/canvas/image.canvas.js.map +1 -1
  17. package/dist/{esm/src → cjs}/canvas/layout.canvas.d.ts +2 -2
  18. package/dist/cjs/canvas/layout.canvas.d.ts.map +1 -0
  19. package/dist/cjs/canvas/layout.canvas.js +6 -6
  20. package/dist/cjs/canvas/layout.canvas.js.map +1 -1
  21. package/dist/{esm/src → cjs}/canvas/root.canvas.d.ts +3 -2
  22. package/dist/cjs/canvas/root.canvas.d.ts.map +1 -0
  23. package/dist/cjs/canvas/root.canvas.js +23 -117
  24. package/dist/cjs/canvas/root.canvas.js.map +1 -1
  25. package/dist/cjs/{src/canvas → canvas}/text.canvas.d.ts +1 -1
  26. package/dist/cjs/canvas/text.canvas.d.ts.map +1 -0
  27. package/dist/cjs/canvas/text.canvas.js +2 -2
  28. package/dist/cjs/canvas/text.canvas.js.map +1 -1
  29. package/dist/cjs/constant/common.const.d.ts.map +1 -0
  30. package/dist/cjs/constant/common.const.js.map +1 -1
  31. package/dist/cjs/index.d.ts.map +1 -0
  32. package/dist/cjs/util/disk.cache.d.ts.map +1 -0
  33. package/dist/cjs/util/disk.cache.js.map +1 -1
  34. package/dist/cjs/worker/comlink.pool.d.ts +30 -0
  35. package/dist/cjs/worker/comlink.pool.d.ts.map +1 -0
  36. package/dist/cjs/worker/comlink.pool.js +164 -0
  37. package/dist/cjs/worker/comlink.pool.js.map +1 -0
  38. package/dist/cjs/worker/comlink.setup.d.ts +4 -0
  39. package/dist/cjs/worker/comlink.setup.d.ts.map +1 -0
  40. package/dist/cjs/worker/comlink.setup.js +53 -0
  41. package/dist/cjs/worker/comlink.setup.js.map +1 -0
  42. package/dist/cjs/worker/render.worker.d.ts.map +1 -0
  43. package/dist/cjs/worker/render.worker.js +58 -61
  44. package/dist/cjs/worker/render.worker.js.map +1 -1
  45. package/dist/cjs/worker/worker.types.d.ts +13 -0
  46. package/dist/cjs/worker/worker.types.d.ts.map +1 -0
  47. package/dist/esm/{src/canvas → canvas}/canvas.helper.d.ts +1 -20
  48. package/dist/esm/canvas/canvas.helper.d.ts.map +1 -0
  49. package/dist/esm/canvas/canvas.helper.js +1 -230
  50. package/dist/{cjs/src → esm}/canvas/canvas.type.d.ts +1 -12
  51. package/dist/esm/canvas/canvas.type.d.ts.map +1 -0
  52. package/dist/esm/{src/canvas → canvas}/chart.canvas.d.ts +1 -1
  53. package/dist/esm/canvas/chart.canvas.d.ts.map +1 -0
  54. package/dist/esm/canvas/chart.canvas.js +71 -145
  55. package/dist/esm/canvas/grid.canvas.d.ts.map +1 -0
  56. package/dist/{cjs/src → esm}/canvas/image.canvas.d.ts +1 -1
  57. package/dist/esm/canvas/image.canvas.d.ts.map +1 -0
  58. package/dist/esm/canvas/image.canvas.js +2 -2
  59. package/dist/{cjs/src → esm}/canvas/layout.canvas.d.ts +2 -2
  60. package/dist/esm/canvas/layout.canvas.d.ts.map +1 -0
  61. package/dist/esm/canvas/layout.canvas.js +6 -6
  62. package/dist/{cjs/src → esm}/canvas/root.canvas.d.ts +3 -2
  63. package/dist/esm/canvas/root.canvas.d.ts.map +1 -0
  64. package/dist/esm/canvas/root.canvas.js +23 -116
  65. package/dist/esm/{src/canvas → canvas}/text.canvas.d.ts +1 -1
  66. package/dist/esm/canvas/text.canvas.d.ts.map +1 -0
  67. package/dist/esm/canvas/text.canvas.js +2 -2
  68. package/dist/esm/constant/common.const.d.ts.map +1 -0
  69. package/dist/esm/index.d.ts.map +1 -0
  70. package/dist/esm/util/disk.cache.d.ts.map +1 -0
  71. package/dist/esm/worker/comlink.pool.d.ts +30 -0
  72. package/dist/esm/worker/comlink.pool.d.ts.map +1 -0
  73. package/dist/esm/worker/comlink.pool.js +139 -0
  74. package/dist/esm/worker/comlink.setup.d.ts +4 -0
  75. package/dist/esm/worker/comlink.setup.d.ts.map +1 -0
  76. package/dist/esm/worker/comlink.setup.js +30 -0
  77. package/dist/esm/worker/render.worker.d.ts.map +1 -0
  78. package/dist/esm/worker/render.worker.js +38 -60
  79. package/dist/esm/worker/worker.types.d.ts +13 -0
  80. package/dist/esm/worker/worker.types.d.ts.map +1 -0
  81. package/package.json +2 -1
  82. package/dist/cjs/src/canvas/canvas.helper.d.ts.map +0 -1
  83. package/dist/cjs/src/canvas/canvas.type.d.ts.map +0 -1
  84. package/dist/cjs/src/canvas/chart.canvas.d.ts.map +0 -1
  85. package/dist/cjs/src/canvas/grid.canvas.d.ts.map +0 -1
  86. package/dist/cjs/src/canvas/image.canvas.d.ts.map +0 -1
  87. package/dist/cjs/src/canvas/layout.canvas.d.ts.map +0 -1
  88. package/dist/cjs/src/canvas/root.canvas.d.ts.map +0 -1
  89. package/dist/cjs/src/canvas/text.canvas.d.ts.map +0 -1
  90. package/dist/cjs/src/constant/common.const.d.ts.map +0 -1
  91. package/dist/cjs/src/index.d.ts.map +0 -1
  92. package/dist/cjs/src/util/disk.cache.d.ts.map +0 -1
  93. package/dist/cjs/src/worker/render.worker.d.ts.map +0 -1
  94. package/dist/cjs/src/worker/worker.types.d.ts +0 -76
  95. package/dist/cjs/src/worker/worker.types.d.ts.map +0 -1
  96. package/dist/esm/src/canvas/canvas.helper.d.ts.map +0 -1
  97. package/dist/esm/src/canvas/canvas.type.d.ts.map +0 -1
  98. package/dist/esm/src/canvas/chart.canvas.d.ts.map +0 -1
  99. package/dist/esm/src/canvas/grid.canvas.d.ts.map +0 -1
  100. package/dist/esm/src/canvas/image.canvas.d.ts.map +0 -1
  101. package/dist/esm/src/canvas/layout.canvas.d.ts.map +0 -1
  102. package/dist/esm/src/canvas/root.canvas.d.ts.map +0 -1
  103. package/dist/esm/src/canvas/text.canvas.d.ts.map +0 -1
  104. package/dist/esm/src/constant/common.const.d.ts.map +0 -1
  105. package/dist/esm/src/index.d.ts.map +0 -1
  106. package/dist/esm/src/util/disk.cache.d.ts.map +0 -1
  107. package/dist/esm/src/worker/render.worker.d.ts.map +0 -1
  108. package/dist/esm/src/worker/worker.types.d.ts +0 -76
  109. package/dist/esm/src/worker/worker.types.d.ts.map +0 -1
  110. /package/dist/cjs/{src/canvas → canvas}/grid.canvas.d.ts +0 -0
  111. /package/dist/cjs/{src/constant → constant}/common.const.d.ts +0 -0
  112. /package/dist/cjs/{src/index.d.ts → index.d.ts} +0 -0
  113. /package/dist/cjs/{src/util → util}/disk.cache.d.ts +0 -0
  114. /package/dist/cjs/{src/worker → worker}/render.worker.d.ts +0 -0
  115. /package/dist/esm/{src/canvas → canvas}/grid.canvas.d.ts +0 -0
  116. /package/dist/esm/{src/constant → constant}/common.const.d.ts +0 -0
  117. /package/dist/esm/{src/index.d.ts → index.d.ts} +0 -0
  118. /package/dist/esm/{src/util → util}/disk.cache.d.ts +0 -0
  119. /package/dist/esm/{src/worker → worker}/render.worker.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"image.canvas.js","sources":["../../../../../src/canvas/image.canvas.ts"],"sourcesContent":["import type { BaseProps, ImageProps, CanvasElement } from '@/canvas/canvas.type.js'\nimport { type CanvasRenderingContext2D, Image as CanvasImage, loadImage } from 'skia-canvas'\nimport { BoxNode } from '@/canvas/layout.canvas.js'\nimport { drawRoundedRectPath, parseBorderRadius } from '@/canvas/canvas.helper.js'\nimport { promises as fs } from 'fs'\nimport { Style } from '@/constant/common.const.js'\nimport { hashBuffer, readDiskCache, writeDiskCache } from '@/util/disk.cache.js'\n\n/**\n * Calculates pixel offset for image positioning based on percentage or pixel values.\n * This handles centering, edge alignment, and percentage-based positioning.\n */\nfunction calculateOffsetFromValue(positionValue: number | `${number}%` | undefined, availableSpace: number): number {\n const value = positionValue ?? '50%'\n if (typeof value === 'number') {\n return value\n }\n if (typeof value === 'string' && value.endsWith('%')) {\n const percentage = parseFloat(value) / 100\n return availableSpace * percentage\n }\n console.warn(`[ImageNode] Invalid objectPosition value format: ${value}. Defaulting to 50%.`)\n return availableSpace * 0.5\n}\n\n/**\n * Per-render image cache — keyed by `src|color` for string sources.\n * Scoped to a single RootNode.render() call; discarded after rendering.\n * Deduplicates concurrent fetches when multiple ImageNodes share the same src.\n */\nexport type RenderImageCache = Map<string, Promise<CanvasImage>>\n\n/**\n * Renders images with configurable sizing, positioning, and effects.\n * Supports object-fit modes, positioning, border radius, and saturation filters.\n */\nexport class ImageNode extends BoxNode {\n declare props: ImageProps & BaseProps\n private loadedImage: CanvasImage | null = null\n private naturalWidth = 0\n private naturalHeight = 0\n private loadingPromise: Promise<void> | null = null\n\n constructor(props: ImageProps) {\n super({ name: 'Image', ...props, children: undefined })\n\n this.props = {\n objectFit: 'fill',\n overflow: Style.Overflow.Hidden,\n saturate: 1,\n objectPosition: { Left: '50%', Top: '50%' },\n ...props,\n }\n }\n\n public load(cache?: RenderImageCache, diskCacheKeys?: Set<string>): Promise<void> {\n if (!this.loadingPromise) {\n this.loadingPromise = this._loadImage(cache, diskCacheKeys)\n }\n return this.loadingPromise\n }\n\n /**\n * Fetches and processes the image source into a CanvasImage.\n * Does not touch node state — pure fetch logic.\n *\n * If `diskCacheKey` and `diskCacheKeys` are provided, the resolved image buffer\n * is written to disk and the key is recorded so the caller can clean it up later.\n */\n private async _fetchCanvasImage(diskCacheKey?: string, diskCacheKeys?: Set<string>): Promise<CanvasImage> {\n const { fileTypeFromBuffer, fileTypeFromFile } = await import('file-type')\n let finalSource: string | Buffer = this.props.src\n let isSvg = false\n let contentBuffer: Buffer | null = null\n let detectedMime: string | undefined\n\n if (typeof this.props.src === 'string') {\n if (this.props.src.startsWith('http')) {\n const response = await fetch(this.props.src)\n if (!response.ok) {\n throw new Error(`HTTP error ${response.status} fetching image: ${this.props.src}`)\n }\n const imageArrayBuffer = await response.arrayBuffer()\n contentBuffer = Buffer.from(imageArrayBuffer)\n finalSource = contentBuffer\n\n const fileTypeResult = await fileTypeFromBuffer(contentBuffer)\n detectedMime = fileTypeResult?.mime\n isSvg = detectedMime === 'image/svg+xml'\n\n if ((!detectedMime || detectedMime === 'application/xml') && contentBuffer.toString('utf-8').includes('<svg')) {\n isSvg = true\n }\n } else {\n finalSource = this.props.src\n const filePath = this.props.src\n\n try {\n const fileTypeResult = await fileTypeFromFile(filePath)\n detectedMime = fileTypeResult?.mime\n isSvg = detectedMime === 'image/svg+xml'\n\n if ((!detectedMime || detectedMime === 'application/xml') && filePath.toLowerCase().endsWith('.svg')) {\n isSvg = true\n }\n } catch {\n isSvg = filePath.toLowerCase().endsWith('.svg')\n }\n\n if (isSvg && this.props.color) {\n try {\n contentBuffer = await fs.readFile(filePath)\n } catch {\n isSvg = false\n contentBuffer = null\n }\n }\n }\n } else {\n contentBuffer = this.props.src\n finalSource = contentBuffer\n\n const fileTypeResult = await fileTypeFromBuffer(contentBuffer)\n detectedMime = fileTypeResult?.mime\n isSvg = detectedMime === 'image/svg+xml'\n }\n\n if (isSvg && this.props.color && contentBuffer) {\n const svgString = contentBuffer.toString('utf-8')\n const modifiedSvgString = svgString.replace(/fill=\"[^\"]*\"/g, `fill=\"${this.props.color}\"`)\n finalSource = modifiedSvgString !== svgString ? Buffer.from(modifiedSvgString) : contentBuffer\n }\n\n // Write to disk and track the key so the render owner can clean it up\n if (diskCacheKey && diskCacheKeys) {\n const cacheBuffer = Buffer.isBuffer(finalSource) ? finalSource : contentBuffer\n if (cacheBuffer) {\n await writeDiskCache(diskCacheKey, cacheBuffer)\n diskCacheKeys.add(diskCacheKey)\n }\n }\n\n return loadImage(finalSource as never)\n }\n\n /**\n * Loads and processes an image.\n *\n * Resolution order:\n * 1. Disk cache at `.cache/files/<hash>` — survives process restarts.\n * 2. Per-render dedup cache — avoids duplicate in-flight fetches when\n * multiple ImageNodes share the same src within one render pass.\n * 3. Fresh fetch via `_fetchCanvasImage()` — writes buffer to disk cache.\n *\n * Buffer sources use a SHA-256 hash as their cache key (same as string sources).\n * All resolved images are released when the render completes (no cross-render retention).\n */\n private _loadImage(cache?: RenderImageCache, diskCacheKeys?: Set<string>): Promise<void> {\n if (!this.props.src) {\n const aspectRatioFromProps = typeof this.props.aspectRatio === 'number' && this.props.aspectRatio > 0 ? this.props.aspectRatio : undefined\n this.node.setAspectRatio(aspectRatioFromProps)\n this.naturalWidth = 0\n this.naturalHeight = 0\n return Promise.resolve()\n }\n\n return new Promise(resolve => {\n const load = async () => {\n try {\n const srcHash = typeof this.props.src === 'string' ? hashBuffer(Buffer.from(this.props.src)) : hashBuffer(this.props.src)\n const cacheKey = this.props.color ? `${srcHash}|${this.props.color}` : srcHash\n\n // 1. Disk cache read — only when disk caching is enabled for this render\n if (diskCacheKeys) {\n const diskBuffer = await readDiskCache(cacheKey)\n if (diskBuffer) {\n const img = await loadImage(diskBuffer as never)\n this.loadedImage = img\n this.naturalWidth = img.width\n this.naturalHeight = img.height\n const calculatedAspectRatio = img.width > 0 && img.height > 0 ? img.width / img.height : undefined\n const finalAspectRatio = typeof this.props.aspectRatio === 'number' && this.props.aspectRatio > 0 ? this.props.aspectRatio : calculatedAspectRatio\n this.node.setAspectRatio(finalAspectRatio)\n this.props.onLoad?.()\n resolve()\n return\n }\n }\n\n // 2. Per-render memory dedup cache or fresh fetch\n let imagePromise: Promise<CanvasImage>\n if (cache) {\n if (!cache.has(cacheKey)) {\n cache.set(cacheKey, this._fetchCanvasImage(diskCacheKeys ? cacheKey : undefined, diskCacheKeys))\n }\n imagePromise = cache.get(cacheKey)!\n } else {\n imagePromise = this._fetchCanvasImage(diskCacheKeys ? cacheKey : undefined, diskCacheKeys)\n }\n\n const img = await imagePromise\n\n this.loadedImage = img\n this.naturalWidth = img.width\n this.naturalHeight = img.height\n\n const calculatedAspectRatio = this.naturalWidth > 0 && this.naturalHeight > 0 ? this.naturalWidth / this.naturalHeight : undefined\n const finalAspectRatio = typeof this.props.aspectRatio === 'number' && this.props.aspectRatio > 0 ? this.props.aspectRatio : calculatedAspectRatio\n\n this.node.setAspectRatio(finalAspectRatio)\n this.props.onLoad?.()\n resolve()\n } catch (error: any) {\n this.naturalWidth = 0\n this.naturalHeight = 0\n const finalAspectRatioOnError = typeof this.props.aspectRatio === 'number' && this.props.aspectRatio > 0 ? this.props.aspectRatio : undefined\n this.node.setAspectRatio(finalAspectRatioOnError)\n this.props.onError?.(error)\n resolve()\n }\n }\n load()\n })\n }\n\n public getLoadingPromise(): Promise<void> {\n return this.loadingPromise ?? this.load()\n }\n\n /**\n * Renders the image with correct sizing, clipping, and positioning.\n * Handles object-fit, object-position, and visual effects like saturation.\n */\n protected override _renderContent(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number) {\n super._renderContent(ctx, x, y, width, height)\n\n if (!this.loadedImage || width <= 0 || height <= 0) return\n const img = this.loadedImage\n const imgW = this.naturalWidth\n const imgH = this.naturalHeight\n if (imgW <= 0 || imgH <= 0) return\n\n // Calculate content box accounting for padding and borders\n const paddingLeft = this.node.getComputedPadding(Style.Edge.Left)\n const paddingTop = this.node.getComputedPadding(Style.Edge.Top)\n const paddingRight = this.node.getComputedPadding(Style.Edge.Right)\n const paddingBottom = this.node.getComputedPadding(Style.Edge.Bottom)\n const borderLeft = this.node.getComputedBorder(Style.Edge.Left)\n const borderTop = this.node.getComputedBorder(Style.Edge.Top)\n const borderRight = this.node.getComputedBorder(Style.Edge.Right)\n const borderBottom = this.node.getComputedBorder(Style.Edge.Bottom)\n const contentX = x + borderLeft + paddingLeft\n const contentY = y + borderTop + paddingTop\n const contentWidth = Math.max(0, width - borderLeft - paddingLeft - borderRight - paddingRight)\n const contentHeight = Math.max(0, height - borderTop - paddingTop - borderBottom - paddingBottom)\n\n if (contentWidth <= 0 || contentHeight <= 0) return\n\n // Apply clipping for border radius\n ctx.save()\n const outerRadii = parseBorderRadius(this.props.borderRadius)\n const innerBorderRadii = {\n TopLeft: Math.max(0, outerRadii.TopLeft - borderTop),\n TopRight: Math.max(0, outerRadii.TopRight - borderTop),\n BottomRight: Math.max(0, outerRadii.BottomRight - borderBottom),\n BottomLeft: Math.max(0, outerRadii.BottomLeft - borderBottom),\n }\n const contentRadii = {\n TopLeft: Math.max(0, innerBorderRadii.TopLeft - Math.max(paddingLeft, paddingTop)),\n TopRight: Math.max(0, innerBorderRadii.TopRight - Math.max(paddingRight, paddingTop)),\n BottomRight: Math.max(0, innerBorderRadii.BottomRight - Math.max(paddingRight, paddingBottom)),\n BottomLeft: Math.max(0, innerBorderRadii.BottomLeft - Math.max(paddingLeft, paddingBottom)),\n }\n drawRoundedRectPath(ctx, contentX, contentY, contentWidth, contentHeight, contentRadii)\n ctx.clip()\n\n // Calculate image dimensions based on object-fit\n const nodeRatio = contentWidth / contentHeight\n const imgRatio = imgW / imgH\n const objectFit = this.props.objectFit\n let dw = contentWidth\n let dh = contentHeight\n\n if (objectFit === 'contain') {\n if (imgRatio > nodeRatio) {\n dw = contentWidth\n dh = contentWidth / imgRatio\n } else {\n dh = contentHeight\n dw = contentHeight * imgRatio\n }\n } else if (objectFit === 'cover') {\n if (imgRatio > nodeRatio) {\n dh = contentHeight\n dw = contentHeight * imgRatio\n } else {\n dw = contentWidth\n dh = contentWidth / imgRatio\n }\n } else if (objectFit === 'none') {\n dw = imgW\n dh = imgH\n } else if (objectFit === 'scale-down') {\n if (imgW <= contentWidth && imgH <= contentHeight) {\n dw = imgW\n dh = imgH\n } else {\n if (imgRatio > nodeRatio) {\n dw = contentWidth\n dh = contentWidth / imgRatio\n } else {\n dh = contentHeight\n dw = contentHeight * imgRatio\n }\n }\n }\n\n // Calculate image position based on object-position\n const sx = 0\n const sy = 0\n const sw = imgW\n const sh = imgH\n\n const availableWidth = contentWidth - dw\n const availableHeight = contentHeight - dh\n const posProps = this.props.objectPosition || {}\n const horizontalValue = posProps.Left !== undefined ? posProps.Left : posProps.Right !== undefined ? posProps.Right : '50%'\n const verticalValue = posProps.Top !== undefined ? posProps.Top : posProps.Bottom !== undefined ? posProps.Bottom : '50%'\n\n let offsetX = calculateOffsetFromValue(horizontalValue, availableWidth)\n let offsetY = calculateOffsetFromValue(verticalValue, availableHeight)\n\n if (posProps.Left === undefined && posProps.Right !== undefined) {\n offsetX = availableWidth - offsetX\n }\n if (posProps.Top === undefined && posProps.Bottom !== undefined) {\n offsetY = availableHeight - offsetY\n }\n\n const dx = contentX + offsetX\n const dy = contentY + offsetY\n\n // Draw image with filters\n ctx.save()\n try {\n if (this.props.dropShadow) {\n const shadow = this.props.dropShadow\n const shadowBlur = Math.max(shadow.offsetX ?? 0, shadow.offsetY ?? 0)\n ctx.shadowOffsetX = shadow.offsetX ?? 0\n ctx.shadowOffsetY = shadow.offsetY ?? 0\n ctx.shadowBlur = Math.max(0, shadow.blur ?? shadowBlur)\n ctx.shadowColor = shadow.color ?? 'black'\n }\n\n const saturateValue = this.props.saturate ?? 1\n let filterString = ''\n if (saturateValue !== 1) {\n filterString += `saturate(${saturateValue * 100}%) `\n }\n\n if (filterString) {\n const currentFilter = ctx.filter && ctx.filter !== 'none' ? ctx.filter + ' ' : ''\n ctx.filter = currentFilter + filterString.trim()\n }\n\n const finalDX = Math.floor(dx)\n const finalDY = Math.floor(dy)\n const finalDW = Math.ceil(dw + (dx - finalDX))\n const finalDH = Math.ceil(dh + (dy - finalDY))\n\n if (finalDW > 0 && finalDH > 0) {\n ctx.drawImage(img, sx, sy, sw, sh, finalDX, finalDY, finalDW, finalDH)\n }\n } catch (drawError) {\n console.error('[ImageNode] Error drawing image:', drawError)\n } finally {\n ctx.restore()\n }\n\n ctx.restore()\n }\n}\n\n/**\n * Factory function to create ImageNode instances\n */\nexport const Image = (props: ImageProps): CanvasElement => ({\n __type: 'Image',\n props: props as Omit<ImageProps, 'onLoad' | 'onError'>,\n})\n"],"names":["BoxNode","Style","fs","writeDiskCache","loadImage","hashBuffer","readDiskCache","parseBorderRadius","drawRoundedRectPath"],"mappings":";;;;;;;;;AAQA;;;AAGG;AACH,SAAS,wBAAwB,CAAC,aAAgD,EAAE,cAAsB,EAAA;AACxG,IAAA,MAAM,KAAK,GAAG,aAAa,IAAI,KAAK;AACpC,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,OAAO,KAAK;IACd;AACA,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACpD,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,GAAG;QAC1C,OAAO,cAAc,GAAG,UAAU;IACpC;AACA,IAAA,OAAO,CAAC,IAAI,CAAC,oDAAoD,KAAK,CAAA,oBAAA,CAAsB,CAAC;IAC7F,OAAO,cAAc,GAAG,GAAG;AAC7B;AASA;;;AAGG;AACG,MAAO,SAAU,SAAQA,qBAAO,CAAA;IAE5B,WAAW,GAAuB,IAAI;IACtC,YAAY,GAAG,CAAC;IAChB,aAAa,GAAG,CAAC;IACjB,cAAc,GAAyB,IAAI;AAEnD,IAAA,WAAA,CAAY,KAAiB,EAAA;AAC3B,QAAA,KAAK,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,S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AO,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,CAAC;AAC9C,YAAA,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,CAAC;YAE9C,IAAI,OAAO,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE;gBAC9B,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC;YACxE;QACF;QAAE,OAAO,SAAS,EAAE;AAClB,YAAA,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,SAAS,CAAC;QAC9D;gBAAU;YACR,GAAG,CAAC,OAAO,EAAE;QACf;QAEA,GAAG,CAAC,OAAO,EAAE;IACf;AACD;AAED;;AAEG;MACU,KAAK,GAAG,CAAC,KAAiB,MAAqB;AAC1D,IAAA,MAAM,EAAE,OAAO;AACf,IAAA,KAAK,EAAE,KAA+C;AACvD,CAAA;;;;;"}
1
+ {"version":3,"file":"image.canvas.js","sources":["../../../../src/canvas/image.canvas.ts"],"sourcesContent":["import type { BaseProps, ImageProps, CanvasElement } from '@/canvas/canvas.type.js'\nimport { type CanvasRenderingContext2D, Image as CanvasImage, loadImage } from 'skia-canvas'\nimport { BoxNode } from '@/canvas/layout.canvas.js'\nimport { drawRoundedRectPath, parseBorderRadius } from '@/canvas/canvas.helper.js'\nimport { promises as fs } from 'fs'\nimport { Style } from '@/constant/common.const.js'\nimport { hashBuffer, readDiskCache, writeDiskCache } from '@/util/disk.cache.js'\n\n/**\n * Calculates pixel offset for image positioning based on percentage or pixel values.\n * This handles centering, edge alignment, and percentage-based positioning.\n */\nfunction calculateOffsetFromValue(positionValue: number | `${number}%` | undefined, availableSpace: number): number {\n const value = positionValue ?? '50%'\n if (typeof value === 'number') {\n return value\n }\n if (typeof value === 'string' && value.endsWith('%')) {\n const percentage = parseFloat(value) / 100\n return availableSpace * percentage\n }\n console.warn(`[ImageNode] Invalid objectPosition value format: ${value}. Defaulting to 50%.`)\n return availableSpace * 0.5\n}\n\n/**\n * Per-render image cache — keyed by `src|color` for string sources.\n * Scoped to a single RootNode.render() call; discarded after rendering.\n * Deduplicates concurrent fetches when multiple ImageNodes share the same src.\n */\nexport type RenderImageCache = Map<string, Promise<CanvasImage>>\n\n/**\n * Renders images with configurable sizing, positioning, and effects.\n * Supports object-fit modes, positioning, border radius, and saturation filters.\n */\nexport class ImageNode extends BoxNode {\n declare props: ImageProps & BaseProps\n private loadedImage: CanvasImage | null = null\n private naturalWidth = 0\n private naturalHeight = 0\n private loadingPromise: Promise<void> | null = null\n\n constructor(props: ImageProps) {\n super({ name: 'Image', ...props, children: undefined })\n\n this.props = {\n objectFit: 'fill',\n overflow: Style.Overflow.Hidden,\n saturate: 1,\n objectPosition: { Left: '50%', Top: '50%' },\n ...props,\n }\n }\n\n public load(cache?: RenderImageCache, diskCacheKeys?: Set<string>): Promise<void> {\n if (!this.loadingPromise) {\n this.loadingPromise = this._loadImage(cache, diskCacheKeys)\n }\n return this.loadingPromise\n }\n\n /**\n * Fetches and processes the image source into a CanvasImage.\n * Does not touch node state — pure fetch logic.\n *\n * If `diskCacheKey` and `diskCacheKeys` are provided, the resolved image buffer\n * is written to disk and the key is recorded so the caller can clean it up later.\n */\n private async _fetchCanvasImage(diskCacheKey?: string, diskCacheKeys?: Set<string>): Promise<CanvasImage> {\n const { fileTypeFromBuffer, fileTypeFromFile } = await import('file-type')\n let finalSource: string | Buffer = this.props.src\n let isSvg = false\n let contentBuffer: Buffer | null = null\n let detectedMime: string | undefined\n\n if (typeof this.props.src === 'string') {\n if (this.props.src.startsWith('http')) {\n const response = await fetch(this.props.src)\n if (!response.ok) {\n throw new Error(`HTTP error ${response.status} fetching image: ${this.props.src}`)\n }\n const imageArrayBuffer = await response.arrayBuffer()\n contentBuffer = Buffer.from(imageArrayBuffer)\n finalSource = contentBuffer\n\n const fileTypeResult = await fileTypeFromBuffer(contentBuffer)\n detectedMime = fileTypeResult?.mime\n isSvg = detectedMime === 'image/svg+xml'\n\n if ((!detectedMime || detectedMime === 'application/xml') && contentBuffer.toString('utf-8').includes('<svg')) {\n isSvg = true\n }\n } else {\n finalSource = this.props.src\n const filePath = this.props.src\n\n try {\n const fileTypeResult = await fileTypeFromFile(filePath)\n detectedMime = fileTypeResult?.mime\n isSvg = detectedMime === 'image/svg+xml'\n\n if ((!detectedMime || detectedMime === 'application/xml') && filePath.toLowerCase().endsWith('.svg')) {\n isSvg = true\n }\n } catch {\n isSvg = filePath.toLowerCase().endsWith('.svg')\n }\n\n if (isSvg && this.props.color) {\n try {\n contentBuffer = await fs.readFile(filePath)\n } catch {\n isSvg = false\n contentBuffer = null\n }\n }\n }\n } else {\n contentBuffer = this.props.src\n finalSource = contentBuffer\n\n const fileTypeResult = await fileTypeFromBuffer(contentBuffer)\n detectedMime = fileTypeResult?.mime\n isSvg = detectedMime === 'image/svg+xml'\n }\n\n if (isSvg && this.props.color && contentBuffer) {\n const svgString = contentBuffer.toString('utf-8')\n const modifiedSvgString = svgString.replace(/fill=\"[^\"]*\"/g, `fill=\"${this.props.color}\"`)\n finalSource = modifiedSvgString !== svgString ? Buffer.from(modifiedSvgString) : contentBuffer\n }\n\n // Write to disk and track the key so the render owner can clean it up\n if (diskCacheKey && diskCacheKeys) {\n const cacheBuffer = Buffer.isBuffer(finalSource) ? finalSource : contentBuffer\n if (cacheBuffer) {\n await writeDiskCache(diskCacheKey, cacheBuffer)\n diskCacheKeys.add(diskCacheKey)\n }\n }\n\n return loadImage(finalSource as never)\n }\n\n /**\n * Loads and processes an image.\n *\n * Resolution order:\n * 1. Disk cache at `.cache/files/<hash>` — survives process restarts.\n * 2. Per-render dedup cache — avoids duplicate in-flight fetches when\n * multiple ImageNodes share the same src within one render pass.\n * 3. Fresh fetch via `_fetchCanvasImage()` — writes buffer to disk cache.\n *\n * Buffer sources use a SHA-256 hash as their cache key (same as string sources).\n * All resolved images are released when the render completes (no cross-render retention).\n */\n private _loadImage(cache?: RenderImageCache, diskCacheKeys?: Set<string>): Promise<void> {\n if (!this.props.src) {\n const aspectRatioFromProps = typeof this.props.aspectRatio === 'number' && this.props.aspectRatio > 0 ? this.props.aspectRatio : undefined\n this.node.setAspectRatio(aspectRatioFromProps)\n this.naturalWidth = 0\n this.naturalHeight = 0\n return Promise.resolve()\n }\n\n return new Promise(resolve => {\n const load = async () => {\n try {\n const srcHash = typeof this.props.src === 'string' ? hashBuffer(Buffer.from(this.props.src)) : hashBuffer(this.props.src)\n const cacheKey = this.props.color ? `${srcHash}|${this.props.color}` : srcHash\n\n // 1. Disk cache read — only when disk caching is enabled for this render\n if (diskCacheKeys) {\n const diskBuffer = await readDiskCache(cacheKey)\n if (diskBuffer) {\n const img = await loadImage(diskBuffer as never)\n this.loadedImage = img\n this.naturalWidth = img.width\n this.naturalHeight = img.height\n const calculatedAspectRatio = img.width > 0 && img.height > 0 ? img.width / img.height : undefined\n const finalAspectRatio = typeof this.props.aspectRatio === 'number' && this.props.aspectRatio > 0 ? this.props.aspectRatio : calculatedAspectRatio\n this.node.setAspectRatio(finalAspectRatio)\n this.props.onLoad?.()\n resolve()\n return\n }\n }\n\n // 2. Per-render memory dedup cache or fresh fetch\n let imagePromise: Promise<CanvasImage>\n if (cache) {\n if (!cache.has(cacheKey)) {\n cache.set(cacheKey, this._fetchCanvasImage(diskCacheKeys ? cacheKey : undefined, diskCacheKeys))\n }\n imagePromise = cache.get(cacheKey)!\n } else {\n imagePromise = this._fetchCanvasImage(diskCacheKeys ? cacheKey : undefined, diskCacheKeys)\n }\n\n const img = await imagePromise\n\n this.loadedImage = img\n this.naturalWidth = img.width\n this.naturalHeight = img.height\n\n const calculatedAspectRatio = this.naturalWidth > 0 && this.naturalHeight > 0 ? this.naturalWidth / this.naturalHeight : undefined\n const finalAspectRatio = typeof this.props.aspectRatio === 'number' && this.props.aspectRatio > 0 ? this.props.aspectRatio : calculatedAspectRatio\n\n this.node.setAspectRatio(finalAspectRatio)\n this.props.onLoad?.()\n resolve()\n } catch (error: any) {\n this.naturalWidth = 0\n this.naturalHeight = 0\n const finalAspectRatioOnError = typeof this.props.aspectRatio === 'number' && this.props.aspectRatio > 0 ? this.props.aspectRatio : undefined\n this.node.setAspectRatio(finalAspectRatioOnError)\n this.props.onError?.(error)\n resolve()\n }\n }\n load()\n })\n }\n\n public getLoadingPromise(): Promise<void> {\n return this.loadingPromise ?? this.load()\n }\n\n /**\n * Renders the image with correct sizing, clipping, and positioning.\n * Handles object-fit, object-position, and visual effects like saturation.\n */\n protected override async _renderContent(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number) {\n await super._renderContent(ctx, x, y, width, height)\n\n if (!this.loadedImage || width <= 0 || height <= 0) return\n const img = this.loadedImage\n const imgW = this.naturalWidth\n const imgH = this.naturalHeight\n if (imgW <= 0 || imgH <= 0) return\n\n // Calculate content box accounting for padding and borders\n const paddingLeft = this.node.getComputedPadding(Style.Edge.Left)\n const paddingTop = this.node.getComputedPadding(Style.Edge.Top)\n const paddingRight = this.node.getComputedPadding(Style.Edge.Right)\n const paddingBottom = this.node.getComputedPadding(Style.Edge.Bottom)\n const borderLeft = this.node.getComputedBorder(Style.Edge.Left)\n const borderTop = this.node.getComputedBorder(Style.Edge.Top)\n const borderRight = this.node.getComputedBorder(Style.Edge.Right)\n const borderBottom = this.node.getComputedBorder(Style.Edge.Bottom)\n const contentX = x + borderLeft + paddingLeft\n const contentY = y + borderTop + paddingTop\n const contentWidth = Math.max(0, width - borderLeft - paddingLeft - borderRight - paddingRight)\n const contentHeight = Math.max(0, height - borderTop - paddingTop - borderBottom - paddingBottom)\n\n if (contentWidth <= 0 || contentHeight <= 0) return\n\n // Apply clipping for border radius\n ctx.save()\n const outerRadii = parseBorderRadius(this.props.borderRadius)\n const innerBorderRadii = {\n TopLeft: Math.max(0, outerRadii.TopLeft - borderTop),\n TopRight: Math.max(0, outerRadii.TopRight - borderTop),\n BottomRight: Math.max(0, outerRadii.BottomRight - borderBottom),\n BottomLeft: Math.max(0, outerRadii.BottomLeft - borderBottom),\n }\n const contentRadii = {\n TopLeft: Math.max(0, innerBorderRadii.TopLeft - Math.max(paddingLeft, paddingTop)),\n TopRight: Math.max(0, innerBorderRadii.TopRight - Math.max(paddingRight, paddingTop)),\n BottomRight: Math.max(0, innerBorderRadii.BottomRight - Math.max(paddingRight, paddingBottom)),\n BottomLeft: Math.max(0, innerBorderRadii.BottomLeft - Math.max(paddingLeft, paddingBottom)),\n }\n drawRoundedRectPath(ctx, contentX, contentY, contentWidth, contentHeight, contentRadii)\n ctx.clip()\n\n // Calculate image dimensions based on object-fit\n const nodeRatio = contentWidth / contentHeight\n const imgRatio = imgW / imgH\n const objectFit = this.props.objectFit\n let dw = contentWidth\n let dh = contentHeight\n\n if (objectFit === 'contain') {\n if (imgRatio > nodeRatio) {\n dw = contentWidth\n dh = contentWidth / imgRatio\n } else {\n dh = contentHeight\n dw = contentHeight * imgRatio\n }\n } else if (objectFit === 'cover') {\n if (imgRatio > nodeRatio) {\n dh = contentHeight\n dw = contentHeight * imgRatio\n } else {\n dw = contentWidth\n dh = contentWidth / imgRatio\n }\n } else if (objectFit === 'none') {\n dw = imgW\n dh = imgH\n } else if (objectFit === 'scale-down') {\n if (imgW <= contentWidth && imgH <= contentHeight) {\n dw = imgW\n dh = imgH\n } else {\n if (imgRatio > nodeRatio) {\n dw = contentWidth\n dh = contentWidth / imgRatio\n } else {\n dh = contentHeight\n dw = contentHeight * imgRatio\n }\n }\n }\n\n // Calculate image position based on object-position\n const sx = 0\n const sy = 0\n const sw = imgW\n const sh = imgH\n\n const availableWidth = contentWidth - dw\n const availableHeight = contentHeight - dh\n const posProps = this.props.objectPosition || {}\n const horizontalValue = posProps.Left !== undefined ? posProps.Left : posProps.Right !== undefined ? posProps.Right : '50%'\n const verticalValue = posProps.Top !== undefined ? posProps.Top : posProps.Bottom !== undefined ? posProps.Bottom : '50%'\n\n let offsetX = calculateOffsetFromValue(horizontalValue, availableWidth)\n let offsetY = calculateOffsetFromValue(verticalValue, availableHeight)\n\n if (posProps.Left === undefined && posProps.Right !== undefined) {\n offsetX = availableWidth - offsetX\n }\n if (posProps.Top === undefined && posProps.Bottom !== undefined) {\n offsetY = availableHeight - offsetY\n }\n\n const dx = contentX + offsetX\n const dy = contentY + offsetY\n\n // Draw image with filters\n ctx.save()\n try {\n if (this.props.dropShadow) {\n const shadow = this.props.dropShadow\n const shadowBlur = Math.max(shadow.offsetX ?? 0, shadow.offsetY ?? 0)\n ctx.shadowOffsetX = shadow.offsetX ?? 0\n ctx.shadowOffsetY = shadow.offsetY ?? 0\n ctx.shadowBlur = Math.max(0, shadow.blur ?? shadowBlur)\n ctx.shadowColor = shadow.color ?? 'black'\n }\n\n const saturateValue = this.props.saturate ?? 1\n let filterString = ''\n if (saturateValue !== 1) {\n filterString += `saturate(${saturateValue * 100}%) `\n }\n\n if (filterString) {\n const currentFilter = ctx.filter && ctx.filter !== 'none' ? ctx.filter + ' ' : ''\n ctx.filter = currentFilter + filterString.trim()\n }\n\n const finalDX = Math.floor(dx)\n const finalDY = Math.floor(dy)\n const finalDW = Math.ceil(dw + (dx - finalDX))\n const finalDH = Math.ceil(dh + (dy - finalDY))\n\n if (finalDW > 0 && finalDH > 0) {\n ctx.drawImage(img, sx, sy, sw, sh, finalDX, finalDY, finalDW, finalDH)\n }\n } catch (drawError) {\n console.error('[ImageNode] Error drawing image:', drawError)\n } finally {\n ctx.restore()\n }\n\n ctx.restore()\n }\n}\n\n/**\n * Factory function to create ImageNode instances\n */\nexport const Image = (props: ImageProps): CanvasElement => ({\n __type: 'Image',\n props: props as Omit<ImageProps, 'onLoad' | 'onError'>,\n})\n"],"names":["BoxNode","Style","fs","writeDiskCache","loadImage","hashBuffer","readDiskCache","parseBorderRadius","drawRoundedRectPath"],"mappings":";;;;;;;;;AAQA;;;AAGG;AACH,SAAS,wBAAwB,CAAC,aAAg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,GAAG,CAAC,OAAO,EAAE;QACf;QAEA,GAAG,CAAC,OAAO,EAAE;IACf;AACD;AAED;;AAEG;MACU,KAAK,GAAG,CAAC,KAAiB,MAAqB;AAC1D,IAAA,MAAM,EAAE,OAAO;AACf,IAAA,KAAK,EAAE,KAA+C;AACvD,CAAA;;;;;"}
@@ -75,7 +75,7 @@ export declare class BoxNode {
75
75
  * @param {number} offsetX X offset for rendering.
76
76
  * @param {number} offsetY Y offset for rendering.
77
77
  */
78
- render(ctx: CanvasRenderingContext2D, offsetX?: number, offsetY?: number): void;
78
+ render(ctx: CanvasRenderingContext2D, offsetX?: number, offsetY?: number): Promise<void>;
79
79
  /**
80
80
  * Renders the node's visual content including background fills, shadows, and borders.
81
81
  * This is an internal method used by the render() pipeline.
@@ -85,7 +85,7 @@ export declare class BoxNode {
85
85
  * @param width The width of the content area to render
86
86
  * @param height The height of the content area to render
87
87
  */
88
- protected _renderContent(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number): void;
88
+ protected _renderContent(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number): Promise<void>;
89
89
  }
90
90
  /**
91
91
  * Creates a new BoxNode instance.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.canvas.d.ts","sourceRoot":"","sources":["../../../src/canvas/layout.canvas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAEnE,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAkB,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAGjG,OAAa,EAAS,IAAI,EAAE,MAAM,4BAA4B,CAAA;AAE9D;;;;GAIG;AACH,qBAAa,OAAO;IAClB;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IAE/B;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IAEV;;OAEG;IACH,QAAQ,EAAE,OAAO,EAAE,CAAA;IAEnB;;OAEG;IACH,KAAK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AAI,uBAAuB,QAAQ,KAAG,aAIpD,CAAA"}
@@ -308,7 +308,7 @@ class BoxNode {
308
308
  * @param {number} offsetX X offset for rendering.
309
309
  * @param {number} offsetY Y offset for rendering.
310
310
  */
311
- render(ctx, offsetX = 0, offsetY = 0) {
311
+ async render(ctx, offsetX = 0, offsetY = 0) {
312
312
  const layout = this.node.getComputedLayout();
313
313
  const x = layout.left + offsetX;
314
314
  const y = layout.top + offsetY;
@@ -363,7 +363,7 @@ class BoxNode {
363
363
  // --- End Transformation Setup ---
364
364
  // --- Step 1: Render Parent Background/Borders/Content ---
365
365
  // This renders the current node's own visual appearance first.
366
- this._renderContent(ctx, x, y, width, height);
366
+ await this._renderContent(ctx, x, y, width, height);
367
367
  // --- Step 2: Prepare Children for Stacking ---
368
368
  const positionedChildren = [];
369
369
  const inFlowChildren = [];
@@ -420,19 +420,19 @@ class BoxNode {
420
420
  for (const item of positionedChildren) {
421
421
  if (item.zIndex < 0) {
422
422
  // Pass parent's layout origin (x, y) as offset
423
- item.node.render(ctx, x, y);
423
+ await item.node.render(ctx, x, y);
424
424
  }
425
425
  }
426
426
  // 4b: Render in-flow children (recursively)
427
427
  for (const child of inFlowChildren) {
428
428
  // Pass parent's layout origin (x, y) as offset
429
- child.render(ctx, x, y);
429
+ await child.render(ctx, x, y);
430
430
  }
431
431
  // 4c: Render positioned children with zero or positive zIndex
432
432
  for (const item of positionedChildren) {
433
433
  if (item.zIndex >= 0) {
434
434
  // Pass parent's layout origin (x, y) as offset
435
- item.node.render(ctx, x, y);
435
+ await item.node.render(ctx, x, y);
436
436
  }
437
437
  }
438
438
  // --- End Child Rendering ---
@@ -464,7 +464,7 @@ class BoxNode {
464
464
  * @param width The width of the content area to render
465
465
  * @param height The height of the content area to render
466
466
  */
467
- _renderContent(ctx, x, y, width, height) {
467
+ async _renderContent(ctx, x, y, width, height) {
468
468
  // Calculate border radius values for all corners
469
469
  const radii = { TopLeft: 0, TopRight: 0, BottomRight: 0, BottomLeft: 0 };
470
470
  if (this.props.borderRadius) {
@@ -1 +1 @@
1
- {"version":3,"file":"layout.canvas.js","sources":["../../../../../src/canvas/layout.canvas.ts"],"sourcesContent":["import { Canvas, type CanvasRenderingContext2D } from 'skia-canvas'\nimport { drawBorders, drawRoundedRectPath, parseBorderRadius, parsePercentage } from '@/canvas/canvas.helper.js'\nimport type { BaseProps, BoxProps, BoxShadowProps, CanvasElement } from '@/canvas/canvas.type.js'\nimport { omit } from 'lodash-es'\nimport tinycolor from 'tinycolor2'\nimport Yoga, { Style, Node } from '@/constant/common.const.js'\n\n/**\n * @class BoxNode\n * @classdesc Base node class for rendering rectangular boxes with layout, styling, and children.\n * It uses the Yoga layout engine for positioning and sizing.\n */\nexport class BoxNode {\n /**\n * @property {Partial<BoxProps>} initialProps - Original props passed to the constructor before any modifications.\n */\n initialProps: Partial<BoxProps>\n\n /**\n * @property {Node} node - The Yoga layout engine node.\n */\n node: Node\n\n /**\n * @property {BoxNode[]} children - Child nodes.\n */\n children: BoxNode[]\n\n /**\n * @property {BoxProps & BaseProps} props - Current props including defaults and inherited values.\n */\n props: BoxProps & BaseProps\n\n /**\n * @property {string} name - Node type name.\n */\n readonly name?: string\n\n /**\n * @property {string} key - Unique node identifier.\n */\n key?: string\n\n /**\n * Creates a new BoxNode instance\n * @param props Initial box properties and styling\n */\n constructor(props: BoxProps & BaseProps = {}) {\n const children = (Array.isArray(props?.children) ? props.children : [props.children]).filter(child => child)\n this.initialProps = { ...props, children }\n this.node = Yoga.Node.create()\n this.children = []\n\n this.props = {\n key: this.key,\n borderColor: 'black',\n borderStyle: Style.Border.Solid,\n boxSizing: Style.BoxSizing.BorderBox,\n opacity: 1,\n flexShrink: 1,\n ...this.initialProps,\n }\n this.name = this.props.name || 'Box'\n this.key = this.props.key || `${this.name}-0`\n\n this.setLayout(this.props)\n }\n\n /**\n * Processes and appends any children passed in the initial props.\n */\n public processInitialChildren() {\n if (this.props.children) {\n const childrenToAdd = Array.isArray(this.props.children) ? this.props.children : [this.props.children]\n childrenToAdd.forEach((child, index) => {\n if (child) {\n this.appendChild(child as BoxNode, index)\n }\n })\n }\n }\n\n /**\n * Inherits styles from the parent node.\n * @param {BoxProps & BaseProps} parentProps Parent node properties to inherit from.\n */\n protected resolveInheritedStyles(parentProps: BoxProps & BaseProps) {\n if (parentProps.key) {\n this.key = `${parentProps.key}-${this.key}`\n this.props.key = this.key\n }\n\n const inheritableKeys = [\n 'fontSize',\n 'fontFamily',\n 'fontWeight',\n 'fontStyle',\n 'color',\n 'textAlign',\n 'verticalAlign',\n 'lineHeight',\n 'lineGap',\n 'letterSpacing',\n 'wordSpacing',\n 'textDecoration',\n 'maxLines',\n 'fontVariant',\n ] as const\n\n const initialPropsRec = this.initialProps as Record<string, unknown>\n const parentPropsRec = parentProps as Record<string, unknown>\n const propsRec = this.props as Record<string, unknown>\n for (const key of inheritableKeys) {\n if (initialPropsRec[key] === undefined && parentPropsRec[key] !== undefined) {\n propsRec[key] = parentPropsRec[key]\n }\n }\n\n if (!this.node.isDirty()) {\n this.node.markDirty()\n }\n }\n\n /**\n * Applies node type-specific default values after inheritance.\n */\n protected applyDefaults(): void {\n // Base implementation does nothing; subclasses can override.\n }\n\n /**\n * Appends a child node at the specified index.\n * @param {BoxNode} child Child node to append.\n * @param index Index to insert child at\n */\n protected appendChild(child: BoxNode, index: number) {\n if (!child || !child.node) {\n console.warn('Attempted to append an invalid child node.', child)\n return\n }\n\n child.resolveInheritedStyles(omit(this.props, 'children'))\n child.applyDefaults()\n this.children.push(child)\n this.node.insertChild(child.node, index)\n child.processInitialChildren()\n }\n\n /**\n * Performs final layout adjustments recursively after the main layout calculation.\n * @returns {boolean} Whether any node was marked as dirty during finalization.\n */\n public finalizeLayout(): boolean {\n let wasDirty = false\n this.updateLayoutBasedOnComputedSize()\n if (this.node.isDirty()) {\n wasDirty = true\n }\n\n for (const child of this.children) {\n child.finalizeLayout()\n if (child.node.isDirty()) {\n wasDirty = true\n }\n }\n\n return wasDirty\n }\n\n /**\n * Hook for subclasses to update layout based on computed size.\n */\n protected updateLayoutBasedOnComputedSize() {\n // Base implementation does nothing; subclasses can override.\n }\n\n /**\n * Applies layout properties to the Yoga node.\n * @param props Box properties containing layout values\n */\n protected setLayout(props: BoxProps) {\n // --- Yoga layout property application ---\n // (This entire block remains unchanged as it interacts with Yoga, not the canvas library)\n const {\n width,\n height,\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n flexDirection,\n justifyContent,\n alignItems,\n alignSelf,\n alignContent,\n flexGrow,\n flexShrink,\n flexBasis,\n positionType,\n position,\n gap,\n margin,\n padding,\n border,\n aspectRatio,\n overflow,\n display,\n boxSizing = Style.BoxSizing.BorderBox,\n direction = Style.Direction.LTR,\n flexWrap,\n } = props\n\n if (width !== undefined) this.node.setWidth(width)\n if (height !== undefined) this.node.setHeight(height)\n if (minWidth !== undefined) this.node.setMinWidth(minWidth)\n if (minHeight !== undefined) this.node.setMinHeight(minHeight)\n if (maxWidth !== undefined) this.node.setMaxWidth(maxWidth)\n if (maxHeight !== undefined) this.node.setMaxHeight(maxHeight)\n if (flexDirection !== undefined) this.node.setFlexDirection(flexDirection)\n if (justifyContent !== undefined) this.node.setJustifyContent(justifyContent)\n if (alignItems !== undefined) this.node.setAlignItems(alignItems)\n if (alignSelf !== undefined) this.node.setAlignSelf(alignSelf)\n if (alignContent !== undefined) this.node.setAlignContent(alignContent)\n if (flexGrow !== undefined) this.node.setFlexGrow(flexGrow)\n if (flexShrink !== undefined) this.node.setFlexShrink(flexShrink)\n if (positionType !== undefined) this.node.setPositionType(positionType)\n if (flexBasis !== undefined) this.node.setFlexBasis(flexBasis)\n if (position) {\n if (typeof position === 'number') {\n this.node.setPosition(Style.Edge.All, position)\n } else if (typeof position === 'string' && position.endsWith('%')) {\n this.node.setPositionPercent(Style.Edge.All, parseFloat(position))\n } else {\n for (const [edge, value] of Object.entries(position)) {\n if (edge in Style.Edge) {\n const edgeKey = edge as keyof typeof Style.Edge\n if (typeof value === 'string' && value.endsWith('%')) {\n this.node.setPositionPercent(Style.Edge[edgeKey], parseFloat(value))\n } else {\n this.node.setPosition(Style.Edge[edgeKey], value as number)\n }\n }\n }\n }\n }\n if (gap) {\n if (typeof gap === 'number') {\n this.node.setGap(Style.Gutter.All, gap)\n } else if (typeof gap === 'string' && gap.endsWith('%')) {\n this.node.setGapPercent(Style.Gutter.All, parseFloat(gap))\n } else {\n for (const [gutter, value] of Object.entries(gap)) {\n if (gutter in Style.Gutter) {\n const gutterKey = gutter as keyof typeof Style.Gutter\n if (typeof value === 'string' && value.endsWith('%')) {\n this.node.setGapPercent(Style.Gutter[gutterKey], parseFloat(value))\n } else {\n this.node.setGap(Style.Gutter[gutterKey], value as number)\n }\n }\n }\n }\n }\n if (margin) {\n if (typeof margin === 'number' || margin === 'auto') {\n this.node.setMargin(Style.Edge.All, margin)\n } else if (typeof margin === 'string' && margin.endsWith('%')) {\n this.node.setMarginPercent(Style.Edge.All, parseFloat(margin))\n } else {\n for (const [edge, value] of Object.entries(margin)) {\n if (edge in Style.Edge) {\n const edgeKey = edge as keyof typeof Style.Edge\n if (typeof value === 'string' && value.endsWith('%')) {\n this.node.setMarginPercent(Style.Edge[edgeKey], parseFloat(value))\n } else {\n this.node.setMargin(Style.Edge[edgeKey], value as number)\n }\n }\n }\n }\n }\n if (padding) {\n if (typeof padding === 'number') {\n this.node.setPadding(Style.Edge.All, padding)\n } else if (typeof padding === 'string' && padding.endsWith('%')) {\n this.node.setPaddingPercent(Style.Edge.All, parseFloat(padding))\n } else {\n for (const [edge, value] of Object.entries(padding)) {\n if (edge in Style.Edge) {\n const edgeKey = edge as keyof typeof Style.Edge\n if (typeof value === 'string' && value.endsWith('%')) {\n this.node.setPaddingPercent(Style.Edge[edgeKey], parseFloat(value))\n } else {\n this.node.setPadding(Style.Edge[edgeKey], value as number)\n }\n }\n }\n }\n }\n if (border) {\n if (typeof border === 'number') {\n this.node.setBorder(Style.Edge.All, border)\n } else {\n for (const [edge, value] of Object.entries(border)) {\n if (edge in Style.Edge) this.node.setBorder(Style.Edge[edge as keyof typeof Style.Edge], value)\n }\n }\n }\n if (aspectRatio !== undefined) this.node.setAspectRatio(aspectRatio)\n if (overflow !== undefined) this.node.setOverflow(overflow)\n if (display !== undefined) this.node.setDisplay(display)\n if (boxSizing !== undefined) this.node.setBoxSizing(boxSizing)\n if (direction !== undefined) this.node.setDirection(direction)\n if (flexWrap !== undefined) this.node.setFlexWrap(flexWrap)\n // --- End Yoga layout property application ---\n }\n\n /**\n * Renders the node and its children to the canvas.\n * @param {CanvasRenderingContext2D} ctx Canvas rendering context (from skia-canvas).\n * @param {number} offsetX X offset for rendering.\n * @param {number} offsetY Y offset for rendering.\n */\n render(ctx: CanvasRenderingContext2D, offsetX: number = 0, offsetY: number = 0) {\n const layout = this.node.getComputedLayout()\n const x = layout.left + offsetX\n const y = layout.top + offsetY\n const width = layout.width\n const height = layout.height\n\n // Exit early if the node is invisible or has no dimensions.\n if (width <= 0 || height <= 0 || this.props.display === Style.Display.None) {\n return\n }\n\n // --- Opacity Setup ---\n const desiredOpacity = Math.max(0, Math.min(1, this.props.opacity ?? 1))\n let originalAlpha: number | undefined = undefined\n let appliedOpacity = false\n if (desiredOpacity < 1) {\n originalAlpha = ctx.globalAlpha\n ctx.globalAlpha = originalAlpha * desiredOpacity\n appliedOpacity = true\n }\n // --- End Opacity Setup ---\n\n try {\n // --- Transformation Setup ---\n const transform = this.props.transform\n const needsTransform =\n transform && (transform.translateX || transform.translateY || transform.rotate || transform.scale || transform.scaleX || transform.scaleY)\n\n let savedContextForTransform = false\n if (needsTransform) {\n ctx.save()\n savedContextForTransform = true\n const originXRaw = transform.originX ?? '50%'\n const originYRaw = transform.originY ?? '50%'\n const originOffsetX = parsePercentage(originXRaw, width)\n const originOffsetY = parsePercentage(originYRaw, height)\n const originAbsX = x + originOffsetX\n const originAbsY = y + originOffsetY\n ctx.translate(originAbsX, originAbsY)\n if (transform.translateX || transform.translateY) {\n const tx = parsePercentage(transform.translateX, width)\n const ty = parsePercentage(transform.translateY, height)\n if (tx !== 0 || ty !== 0) ctx.translate(tx, ty)\n }\n if (transform.rotate) {\n ctx.rotate((transform.rotate * Math.PI) / 180)\n }\n if (transform.scale || transform.scaleX || transform.scaleY) {\n const scaleX = transform.scaleX ?? transform.scale ?? 1\n const scaleY = transform.scaleY ?? transform.scale ?? 1\n if (scaleX !== 1 || scaleY !== 1) ctx.scale(scaleX, scaleY)\n }\n ctx.translate(-originAbsX, -originAbsY)\n }\n // --- End Transformation Setup ---\n\n // --- Step 1: Render Parent Background/Borders/Content ---\n // This renders the current node's own visual appearance first.\n this._renderContent(ctx, x, y, width, height)\n\n // --- Step 2: Prepare Children for Stacking ---\n const positionedChildren: { node: BoxNode; zIndex: number; originalIndex: number }[] = []\n const inFlowChildren: BoxNode[] = []\n\n this.children.forEach((child, index) => {\n // Check if child participates in zIndex stacking\n if (child.props.positionType === Style.PositionType.Absolute && child.props.zIndex !== undefined) {\n positionedChildren.push({\n node: child,\n zIndex: child.props.zIndex,\n originalIndex: index, // Keep original order for tie-breaking\n })\n } else {\n inFlowChildren.push(child)\n }\n })\n\n // Sort positioned children by zIndex, then by original order\n positionedChildren.sort((a, b) => {\n return a.zIndex - b.zIndex || a.originalIndex - b.originalIndex\n })\n\n // --- Step 3: Handle Clipping (Applies before drawing children) ---\n let savedContextForClip = false\n if (this.props.overflow === Style.Overflow.Hidden && (width > 0 || height > 0)) {\n ctx.save()\n savedContextForClip = true\n const borderLeft = this.node.getComputedBorder(Style.Edge.Left)\n const borderTop = this.node.getComputedBorder(Style.Edge.Top)\n const borderRight = this.node.getComputedBorder(Style.Edge.Right)\n const borderBottom = this.node.getComputedBorder(Style.Edge.Bottom)\n const innerX = x + borderLeft\n const innerY = y + borderTop\n const innerWidth = Math.max(0, width - borderLeft - borderRight)\n const innerHeight = Math.max(0, height - borderTop - borderBottom)\n const outerRadii = parseBorderRadius(this.props.borderRadius)\n const innerRadii = {\n TopLeft: Math.max(0, outerRadii.TopLeft - Math.max(borderLeft, borderTop)),\n TopRight: Math.max(0, outerRadii.TopRight - Math.max(borderRight, borderTop)),\n BottomRight: Math.max(0, outerRadii.BottomRight - Math.max(borderRight, borderBottom)),\n BottomLeft: Math.max(0, outerRadii.BottomLeft - Math.max(borderLeft, borderBottom)),\n }\n if (innerWidth > 0 && innerHeight > 0) {\n drawRoundedRectPath(ctx, innerX, innerY, innerWidth, innerHeight, innerRadii)\n ctx.clip()\n } else {\n ctx.beginPath()\n ctx.rect(innerX, innerY, 0, 0)\n ctx.clip()\n }\n }\n // --- End Clipping Setup ---\n\n // --- Step 4: Render Children in Stacking Order ---\n\n // 4a: Render positioned children with negative zIndex\n for (const item of positionedChildren) {\n if (item.zIndex < 0) {\n // Pass parent's layout origin (x, y) as offset\n item.node.render(ctx, x, y)\n }\n }\n\n // 4b: Render in-flow children (recursively)\n for (const child of inFlowChildren) {\n // Pass parent's layout origin (x, y) as offset\n child.render(ctx, x, y)\n }\n\n // 4c: Render positioned children with zero or positive zIndex\n for (const item of positionedChildren) {\n if (item.zIndex >= 0) {\n // Pass parent's layout origin (x, y) as offset\n item.node.render(ctx, x, y)\n }\n }\n // --- End Child Rendering ---\n\n // --- Step 5: Restore Clipping Context ---\n if (savedContextForClip) {\n ctx.restore()\n }\n // --- End Clipping Restoration ---\n\n // --- Step 6: Restore Transformation Context ---\n if (savedContextForTransform) {\n ctx.restore()\n }\n // --- End Transformation Restoration ---\n } finally {\n // --- Opacity Restoration ---\n if (appliedOpacity && originalAlpha !== undefined) {\n ctx.globalAlpha = originalAlpha\n }\n // --- End Opacity Restoration ---\n }\n }\n\n /**\n * Renders the node's visual content including background fills, shadows, and borders.\n * This is an internal method used by the render() pipeline.\n * @param ctx The skia-canvas 2D rendering context to draw into\n * @param x The absolute x-coordinate where drawing should begin\n * @param y The absolute y-coordinate where drawing should begin\n * @param width The width of the content area to render\n * @param height The height of the content area to render\n */\n protected _renderContent(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number) {\n // Calculate border radius values for all corners\n const radii = { TopLeft: 0, TopRight: 0, BottomRight: 0, BottomLeft: 0 }\n if (this.props.borderRadius) {\n // Handle both number and object border radius specifications\n if (typeof this.props.borderRadius === 'number') {\n radii.TopLeft = radii.TopRight = radii.BottomRight = radii.BottomLeft = this.props.borderRadius\n } else {\n // Extract individual corner radii, defaulting to 0 if not specified\n radii.TopLeft = this.props.borderRadius.TopLeft ?? 0\n radii.TopRight = this.props.borderRadius.TopRight ?? 0\n radii.BottomRight = this.props.borderRadius.BottomRight ?? 0\n radii.BottomLeft = this.props.borderRadius.BottomLeft ?? 0\n }\n // Ensure all radii are non-negative\n radii.TopLeft = Math.max(0, radii.TopLeft)\n radii.TopRight = Math.max(0, radii.TopRight)\n radii.BottomRight = Math.max(0, radii.BottomRight)\n radii.BottomLeft = Math.max(0, radii.BottomLeft)\n }\n\n // Process shadow configurations\n let shadows: BoxShadowProps[] = []\n if (this.props.boxShadow) {\n shadows = Array.isArray(this.props.boxShadow) ? this.props.boxShadow : [this.props.boxShadow]\n }\n // Split shadows into outset (normal) and inset types\n const outsetShadows = shadows.filter(s => !s.inset)\n const insetShadows = shadows.filter(s => s.inset)\n\n // Determine if background is fully opaque for shadow optimization\n const backgroundColor = this.props.backgroundColor\n let isOpaque = false\n if (backgroundColor && !this.props.gradient) {\n const rgba = tinycolor(backgroundColor).toRgb()\n isOpaque = rgba && rgba.a === 1\n }\n\n // Render outset shadows if present\n if (outsetShadows.length > 0) {\n const subtractOffset = 0.75\n if (isOpaque) {\n // Optimized rendering path for opaque backgrounds\n ctx.save()\n ctx.fillStyle = 'black' // Shadow source color\n for (const shadow of outsetShadows) {\n ctx.shadowColor = shadow.color ?? 'black'\n ctx.shadowOffsetX = shadow.offsetX ?? 0\n ctx.shadowOffsetY = shadow.offsetY ?? 0\n ctx.shadowBlur = shadow.blur ?? Math.max(shadow.offsetX ?? 0, shadow.offsetY ?? 0)\n drawRoundedRectPath(ctx, x + subtractOffset / 2, y + subtractOffset / 2, width - subtractOffset, height - subtractOffset, radii)\n ctx.fill()\n }\n ctx.restore()\n } else {\n // Complex shadow rendering for transparent/gradient backgrounds\n let maxBlur = 0\n let maxOffsetX = 0\n let maxOffsetY = 0\n\n // Calculate maximum shadow extents\n for (const shadow of outsetShadows) {\n const currentOffsetX = shadow.offsetX ?? 0\n const currentOffsetY = shadow.offsetY ?? 0\n const currentBlur = shadow.blur ?? Math.max(currentOffsetX, currentOffsetY)\n maxBlur = Math.max(maxBlur, currentBlur)\n maxOffsetX = Math.max(maxOffsetX, Math.abs(currentOffsetX))\n maxOffsetY = Math.max(maxOffsetY, Math.abs(currentOffsetY))\n }\n\n // Calculate offscreen canvas size with padding for shadows\n const blurPaddingMultiplier = 2\n const shadowPadding = Math.ceil(maxBlur * blurPaddingMultiplier + Math.max(maxOffsetX, maxOffsetY))\n const offscreenWidth = Math.ceil(width + shadowPadding * 2)\n const offscreenHeight = Math.ceil(height + shadowPadding * 2)\n\n if (offscreenWidth > 0 && offscreenHeight > 0) {\n // Create temporary canvas for shadow composition\n const offscreenCanvas = new Canvas(offscreenWidth, offscreenHeight)\n const offCtx = offscreenCanvas.getContext('2d')\n offCtx.imageSmoothingEnabled = true\n offCtx.imageSmoothingQuality = 'high'\n const shapeOffsetX = shadowPadding\n const shapeOffsetY = shadowPadding\n\n // Render each shadow individually onto offscreen canvas\n for (const shadow of outsetShadows) {\n offCtx.save()\n const shadowOffsetX = shadow.offsetX ?? 0\n const shadowOffsetY = shadow.offsetY ?? 0\n const blur = shadow.blur ?? Math.max(shadowOffsetX, shadowOffsetY)\n offCtx.shadowColor = shadow.color ?? 'black'\n offCtx.shadowOffsetX = shadowOffsetX\n offCtx.shadowOffsetY = shadowOffsetY\n offCtx.shadowBlur = Math.max(0, blur)\n drawRoundedRectPath(\n offCtx,\n shapeOffsetX + subtractOffset / 2,\n shapeOffsetY + subtractOffset / 2,\n width - subtractOffset,\n height - subtractOffset,\n radii,\n )\n offCtx.fillStyle = 'rgba(0,0,0,1)'\n offCtx.fill()\n offCtx.restore()\n }\n\n // Cut out the shape from accumulated shadows\n offCtx.save()\n offCtx.globalCompositeOperation = 'destination-out'\n drawRoundedRectPath(offCtx, shapeOffsetX, shapeOffsetY, width, height, radii)\n offCtx.fillStyle = 'rgba(0,0,0,1)'\n offCtx.fill()\n offCtx.restore()\n\n // Composite shadow result onto main canvas\n ctx.drawImage(offscreenCanvas, x - shadowPadding, y - shadowPadding)\n }\n }\n }\n\n // Render background fill (solid color or gradient)\n // This logic uses standard context methods and remains unchanged.\n const hasFill = this.props.gradient || this.props.backgroundColor\n if (hasFill) {\n let fillStyle: string | CanvasGradient = this.props.backgroundColor || 'transparent'\n if (this.props.gradient) {\n const { type = 'linear', colors, direction = 'to-bottom' } = this.props.gradient\n let grad: CanvasGradient | null = null\n if (colors && colors.length > 0 && width > 0 && height > 0) {\n if (type === 'linear') {\n let x0 = 0,\n y0 = 0,\n x1 = 0,\n y1 = 0\n let directionIsValid = false\n if (Array.isArray(direction) && direction.length === 4) {\n ;[x0, y0, x1, y1] = direction\n directionIsValid = true\n } else if (typeof direction === 'string') {\n switch (direction.toLowerCase()) {\n case 'to-right':\n x0 = 0\n y0 = 0\n x1 = width\n y1 = 0\n directionIsValid = true\n break\n case 'to-left':\n x0 = width\n y0 = 0\n x1 = 0\n y1 = 0\n directionIsValid = true\n break\n case 'to-bottom':\n x0 = 0\n y0 = 0\n x1 = 0\n y1 = height\n directionIsValid = true\n break\n case 'to-top':\n x0 = 0\n y0 = height\n x1 = 0\n y1 = 0\n directionIsValid = true\n break\n case 'to-top-right':\n x0 = 0\n y0 = height\n x1 = width\n y1 = 0\n directionIsValid = true\n break\n case 'to-top-left':\n x0 = width\n y0 = height\n x1 = 0\n y1 = 0\n directionIsValid = true\n break\n case 'to-bottom-right':\n x0 = 0\n y0 = 0\n x1 = width\n y1 = height\n directionIsValid = true\n break\n case 'to-bottom-left':\n x0 = width\n y0 = 0\n x1 = 0\n y1 = height\n directionIsValid = true\n break\n }\n }\n if (directionIsValid) {\n grad = ctx.createLinearGradient(x + x0, y + y0, x + x1, y + y1)\n } else {\n console.warn(`[BoxNode ${this.key}] Invalid linear gradient direction:`, direction)\n }\n } else if (type === 'radial') {\n const centerX = x + width / 2\n const centerY = y + height / 2\n const r0 = 0\n const r1 = 0.5 * Math.sqrt(width * width + height * height)\n if (r1 > 0) {\n grad = ctx.createRadialGradient(centerX, centerY, r0, centerX, centerY, r1)\n }\n }\n if (grad) {\n colors.forEach((color, i) => {\n const stop = colors.length > 1 ? Math.max(0, Math.min(1, i / (colors.length - 1))) : 0.5\n grad!.addColorStop(stop, color)\n })\n fillStyle = grad\n } else {\n console.warn(`[BoxNode ${this.key}] Could not create ${type} gradient. Falling back to backgroundColor.`)\n }\n } else {\n if (!colors?.length) {\n console.warn(`[BoxNode ${this.key}] Gradient specified but no colors provided. Falling back to backgroundColor.`)\n } else {\n console.warn(`[BoxNode ${this.key}] Cannot draw gradient with zero width/height.`)\n }\n }\n }\n if (fillStyle && fillStyle !== 'transparent') {\n ctx.fillStyle = fillStyle\n drawRoundedRectPath(ctx, x, y, width, height, radii)\n ctx.fill()\n }\n }\n\n // Render inset shadows\n // This logic uses standard context methods and remains unchanged.\n if (insetShadows.length > 0) {\n for (const shadow of insetShadows) {\n ctx.save()\n const color = shadow.color ?? 'black'\n const shadowOffsetX = shadow.offsetX ?? 0\n const shadowOffsetY = shadow.offsetY ?? 0\n const blur = shadow.blur ?? Math.max(shadowOffsetX, shadowOffsetY)\n drawRoundedRectPath(ctx, x, y, width, height, radii)\n ctx.clip()\n ctx.shadowColor = color\n ctx.shadowOffsetX = shadowOffsetX\n ctx.shadowOffsetY = shadowOffsetY\n ctx.shadowBlur = blur\n ctx.lineWidth = 1 // Minimal line width for the stroke.\n ctx.strokeStyle = 'transparent' // Stroke color doesn't matter; only the shadow does.\n // Draw a slightly offset path *inside* the clip to generate the inset shadow.\n drawRoundedRectPath(ctx, x - shadowOffsetX, y - shadowOffsetY, width, height, radii)\n ctx.stroke() // The stroke generates the shadow inside the clipped area.\n ctx.restore()\n }\n }\n\n // Render border strokes\n // (This logic uses standard context methods via drawBorders helper and remains unchanged)\n drawBorders({\n ctx,\n node: this.node,\n x,\n y,\n width,\n height,\n radii,\n borderColor: this.props.borderColor,\n borderStyle: this.props.borderStyle,\n })\n }\n}\n\n/**\n * Normalizes children into a flat CanvasElement array, filtering falsy values.\n */\nfunction normalizeDescriptorChildren(children: BoxProps['children']): CanvasElement[] | undefined {\n if (children === undefined || children === null || children === false) return undefined\n const arr = (Array.isArray(children) ? children : [children]).filter(Boolean) as CanvasElement[]\n return arr.length > 0 ? arr : undefined\n}\n\n/**\n * Creates a new BoxNode instance.\n * @param {BoxProps} props Box properties and configuration.\n * @returns {BoxNode} New BoxNode instance.\n */\nexport const Box = ({ children, ...rest }: BoxProps): CanvasElement => ({\n __type: 'Box',\n props: rest,\n children: normalizeDescriptorChildren(children),\n})\n\n/**\n * @class ColumnNode\n * Node class for vertical column layout\n */\nexport class ColumnNode extends BoxNode {\n constructor(props: BoxProps & BaseProps = {}) {\n super({\n display: Style.Display.Flex,\n flexDirection: Style.FlexDirection.Column,\n flexShrink: 1,\n flexBasis: props.flexGrow === 1 ? 0 : undefined,\n ...props,\n })\n }\n}\n\n/**\n * Creates a new ColumnNode instance.\n * @param {BoxProps} props Column properties and configuration.\n * @returns {ColumnNode} New ColumnNode instance.\n */\nexport const Column = ({ children, ...rest }: BoxProps): CanvasElement => ({\n __type: 'Column',\n props: rest,\n children: normalizeDescriptorChildren(children),\n})\n\n/**\n * @class RowNode\n * @classdesc Node class for horizontal row layout.\n */\nexport class RowNode extends BoxNode {\n constructor(props: BoxProps & BaseProps = {}) {\n super({\n name: 'Row',\n display: Style.Display.Flex,\n flexDirection: Style.FlexDirection.Row,\n flexShrink: 1, // Default shrink for rows\n ...props,\n })\n }\n}\n\n/**\n * Creates a new RowNode instance.\n * @param {BoxProps} props Row properties and configuration.\n * @returns {RowNode} New RowNode instance.\n */\nexport const Row = ({ children, ...rest }: BoxProps): CanvasElement => ({\n __type: 'Row',\n props: rest,\n children: normalizeDescriptorChildren(children),\n})\n"],"names":["Yoga","Style","omit","parsePercentage","parseBorderRadius","drawRoundedRectPath","Canvas","drawBorders"],"mappings":";;;;;;;;;AAOA;;;;AAIG;MACU,OAAO,CAAA;AAClB;;AAEG;AACH,IAAA,YAAY;AAEZ;;AAEG;AACH,IAAA,IAAI;AAEJ;;AAEG;AACH,IAAA,QAAQ;AAER;;AAEG;AACH,IAAA,KAAK;AAEL;;AAEG;AACM,IAAA,IAAI;AAEb;;AAEG;AACH,IAAA,GAAG;AAEH;;;AAGG;AACH,IAAA,WAAA,CAAY,QAA8B,EAAE,EAAA;AAC1C,QAAA,MAAM,QAAQ,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC;QAC5G,IAAI,CAAC,YAAY,GAAG,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE;QAC1C,IAAI,CAAC,IAAI,GAAGA,SAAI,CAAC,IAAI,CAAC,MAAM,EAAE;AAC9B,QAAA,IAAI,CAAC,QAAQ,GAAG,EAAE;QAElB,IAAI,CAAC,KAAK,GAAG;YACX,GAAG,EAAE,IAAI,CAAC,GAAG;AACb,YAAA,WAAW,EAAE,OAAO;AACpB,YAAA,WAAW,EAAEC,kBAAK,CAAC,MAAM,CAAC,KAAK;AAC/B,YAAA,SAAS,EAAEA,kBAAK,CAAC,SAAS,CAAC,SAAS;AACpC,YAAA,OAAO,EAAE,CAAC;AACV,YAAA,UAAU,EAAE,CAAC;YACb,GAAG,IAAI,CAAC,YAAY;SACrB;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK;AACpC,QAAA,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,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1C,QAAA,KAAK,CAAC;AACJ,YAAA,OAAO,EAAEN,kBAAK,CAAC,OAAO,CAAC,IAAI;AAC3B,YAAA,aAAa,EAAEA,kBAAK,CAAC,aAAa,CAAC,MAAM;AACzC,YAAA,UAAU,EAAE,CAAC;AACb,YAAA,SAAS,EAAE,KAAK,CAAC,QAAQ,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS;AAC/C,YAAA,GAAG,KAAK;AACT,SAAA,CAAC;IACJ;AACD;AAED;;;;AAIG;AACI,MAAM,MAAM,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAY,MAAqB;AACzE,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,QAAQ,EAAE,2BAA2B,CAAC,QAAQ,CAAC;AAChD,CAAA;AAED;;;AAGG;AACG,MAAO,OAAQ,SAAQ,OAAO,CAAA;AAClC,IAAA,WAAA,CAAY,QAA8B,EAAE,EAAA;AAC1C,QAAA,KAAK,CAAC;AACJ,YAAA,IAAI,EAAE,KAAK;AACX,YAAA,OAAO,EAAEA,kBAAK,CAAC,OAAO,CAAC,IAAI;AAC3B,YAAA,aAAa,EAAEA,kBAAK,CAAC,aAAa,CAAC,GAAG;YACtC,UAAU,EAAE,CAAC;AACb,YAAA,GAAG,KAAK;AACT,SAAA,CAAC;IACJ;AACD;AAED;;;;AAIG;AACI,MAAM,GAAG,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAY,MAAqB;AACtE,IAAA,MAAM,EAAE,KAAK;AACb,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,QAAQ,EAAE,2BAA2B,CAAC,QAAQ,CAAC;AAChD,CAAA;;;;;;;;;"}
1
+ {"version":3,"file":"layout.canvas.js","sources":["../../../../src/canvas/layout.canvas.ts"],"sourcesContent":["import { Canvas, type CanvasRenderingContext2D } from 'skia-canvas'\nimport { drawBorders, drawRoundedRectPath, parseBorderRadius, parsePercentage } from '@/canvas/canvas.helper.js'\nimport type { BaseProps, BoxProps, BoxShadowProps, CanvasElement } from '@/canvas/canvas.type.js'\nimport { omit } from 'lodash-es'\nimport tinycolor from 'tinycolor2'\nimport Yoga, { Style, Node } from '@/constant/common.const.js'\n\n/**\n * @class BoxNode\n * @classdesc Base node class for rendering rectangular boxes with layout, styling, and children.\n * It uses the Yoga layout engine for positioning and sizing.\n */\nexport class BoxNode {\n /**\n * @property {Partial<BoxProps>} initialProps - Original props passed to the constructor before any modifications.\n */\n initialProps: Partial<BoxProps>\n\n /**\n * @property {Node} node - The Yoga layout engine node.\n */\n node: Node\n\n /**\n * @property {BoxNode[]} children - Child nodes.\n */\n children: BoxNode[]\n\n /**\n * @property {BoxProps & BaseProps} props - Current props including defaults and inherited values.\n */\n props: BoxProps & BaseProps\n\n /**\n * @property {string} name - Node type name.\n */\n readonly name?: string\n\n /**\n * @property {string} key - Unique node identifier.\n */\n key?: string\n\n /**\n * Creates a new BoxNode instance\n * @param props Initial box properties and styling\n */\n constructor(props: BoxProps & BaseProps = {}) {\n const children = (Array.isArray(props?.children) ? props.children : [props.children]).filter(child => child)\n this.initialProps = { ...props, children }\n this.node = Yoga.Node.create()\n this.children = []\n\n this.props = {\n key: this.key,\n borderColor: 'black',\n borderStyle: Style.Border.Solid,\n boxSizing: Style.BoxSizing.BorderBox,\n opacity: 1,\n flexShrink: 1,\n ...this.initialProps,\n }\n this.name = this.props.name || 'Box'\n this.key = this.props.key || `${this.name}-0`\n\n this.setLayout(this.props)\n }\n\n /**\n * Processes and appends any children passed in the initial props.\n */\n public processInitialChildren() {\n if (this.props.children) {\n const childrenToAdd = Array.isArray(this.props.children) ? this.props.children : [this.props.children]\n childrenToAdd.forEach((child, index) => {\n if (child) {\n this.appendChild(child as BoxNode, index)\n }\n })\n }\n }\n\n /**\n * Inherits styles from the parent node.\n * @param {BoxProps & BaseProps} parentProps Parent node properties to inherit from.\n */\n protected resolveInheritedStyles(parentProps: BoxProps & BaseProps) {\n if (parentProps.key) {\n this.key = `${parentProps.key}-${this.key}`\n this.props.key = this.key\n }\n\n const inheritableKeys = [\n 'fontSize',\n 'fontFamily',\n 'fontWeight',\n 'fontStyle',\n 'color',\n 'textAlign',\n 'verticalAlign',\n 'lineHeight',\n 'lineGap',\n 'letterSpacing',\n 'wordSpacing',\n 'textDecoration',\n 'maxLines',\n 'fontVariant',\n ] as const\n\n const initialPropsRec = this.initialProps as Record<string, unknown>\n const parentPropsRec = parentProps as Record<string, unknown>\n const propsRec = this.props as Record<string, unknown>\n for (const key of inheritableKeys) {\n if (initialPropsRec[key] === undefined && parentPropsRec[key] !== undefined) {\n propsRec[key] = parentPropsRec[key]\n }\n }\n\n if (!this.node.isDirty()) {\n this.node.markDirty()\n }\n }\n\n /**\n * Applies node type-specific default values after inheritance.\n */\n protected applyDefaults(): void {\n // Base implementation does nothing; subclasses can override.\n }\n\n /**\n * Appends a child node at the specified index.\n * @param {BoxNode} child Child node to append.\n * @param index Index to insert child at\n */\n protected appendChild(child: BoxNode, index: number) {\n if (!child || !child.node) {\n console.warn('Attempted to append an invalid child node.', child)\n return\n }\n\n child.resolveInheritedStyles(omit(this.props, 'children'))\n child.applyDefaults()\n this.children.push(child)\n this.node.insertChild(child.node, index)\n child.processInitialChildren()\n }\n\n /**\n * Performs final layout adjustments recursively after the main layout calculation.\n * @returns {boolean} Whether any node was marked as dirty during finalization.\n */\n public finalizeLayout(): boolean {\n let wasDirty = false\n this.updateLayoutBasedOnComputedSize()\n if (this.node.isDirty()) {\n wasDirty = true\n }\n\n for (const child of this.children) {\n child.finalizeLayout()\n if (child.node.isDirty()) {\n wasDirty = true\n }\n }\n\n return wasDirty\n }\n\n /**\n * Hook for subclasses to update layout based on computed size.\n */\n protected updateLayoutBasedOnComputedSize() {\n // Base implementation does nothing; subclasses can override.\n }\n\n /**\n * Applies layout properties to the Yoga node.\n * @param props Box properties containing layout values\n */\n protected setLayout(props: BoxProps) {\n // --- Yoga layout property application ---\n // (This entire block remains unchanged as it interacts with Yoga, not the canvas library)\n const {\n width,\n height,\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n flexDirection,\n justifyContent,\n alignItems,\n alignSelf,\n alignContent,\n flexGrow,\n flexShrink,\n flexBasis,\n positionType,\n position,\n gap,\n margin,\n padding,\n border,\n aspectRatio,\n overflow,\n display,\n boxSizing = Style.BoxSizing.BorderBox,\n direction = Style.Direction.LTR,\n flexWrap,\n } = props\n\n if (width !== undefined) this.node.setWidth(width)\n if (height !== undefined) this.node.setHeight(height)\n if (minWidth !== undefined) this.node.setMinWidth(minWidth)\n if (minHeight !== undefined) this.node.setMinHeight(minHeight)\n if (maxWidth !== undefined) this.node.setMaxWidth(maxWidth)\n if (maxHeight !== undefined) this.node.setMaxHeight(maxHeight)\n if (flexDirection !== undefined) this.node.setFlexDirection(flexDirection)\n if (justifyContent !== undefined) this.node.setJustifyContent(justifyContent)\n if (alignItems !== undefined) this.node.setAlignItems(alignItems)\n if (alignSelf !== undefined) this.node.setAlignSelf(alignSelf)\n if (alignContent !== undefined) this.node.setAlignContent(alignContent)\n if (flexGrow !== undefined) this.node.setFlexGrow(flexGrow)\n if (flexShrink !== undefined) this.node.setFlexShrink(flexShrink)\n if (positionType !== undefined) this.node.setPositionType(positionType)\n if (flexBasis !== undefined) this.node.setFlexBasis(flexBasis)\n if (position) {\n if (typeof position === 'number') {\n this.node.setPosition(Style.Edge.All, position)\n } else if (typeof position === 'string' && position.endsWith('%')) {\n this.node.setPositionPercent(Style.Edge.All, parseFloat(position))\n } else {\n for (const [edge, value] of Object.entries(position)) {\n if (edge in Style.Edge) {\n const edgeKey = edge as keyof typeof Style.Edge\n if (typeof value === 'string' && value.endsWith('%')) {\n this.node.setPositionPercent(Style.Edge[edgeKey], parseFloat(value))\n } else {\n this.node.setPosition(Style.Edge[edgeKey], value as number)\n }\n }\n }\n }\n }\n if (gap) {\n if (typeof gap === 'number') {\n this.node.setGap(Style.Gutter.All, gap)\n } else if (typeof gap === 'string' && gap.endsWith('%')) {\n this.node.setGapPercent(Style.Gutter.All, parseFloat(gap))\n } else {\n for (const [gutter, value] of Object.entries(gap)) {\n if (gutter in Style.Gutter) {\n const gutterKey = gutter as keyof typeof Style.Gutter\n if (typeof value === 'string' && value.endsWith('%')) {\n this.node.setGapPercent(Style.Gutter[gutterKey], parseFloat(value))\n } else {\n this.node.setGap(Style.Gutter[gutterKey], value as number)\n }\n }\n }\n }\n }\n if (margin) {\n if (typeof margin === 'number' || margin === 'auto') {\n this.node.setMargin(Style.Edge.All, margin)\n } else if (typeof margin === 'string' && margin.endsWith('%')) {\n this.node.setMarginPercent(Style.Edge.All, parseFloat(margin))\n } else {\n for (const [edge, value] of Object.entries(margin)) {\n if (edge in Style.Edge) {\n const edgeKey = edge as keyof typeof Style.Edge\n if (typeof value === 'string' && value.endsWith('%')) {\n this.node.setMarginPercent(Style.Edge[edgeKey], parseFloat(value))\n } else {\n this.node.setMargin(Style.Edge[edgeKey], value as number)\n }\n }\n }\n }\n }\n if (padding) {\n if (typeof padding === 'number') {\n this.node.setPadding(Style.Edge.All, padding)\n } else if (typeof padding === 'string' && padding.endsWith('%')) {\n this.node.setPaddingPercent(Style.Edge.All, parseFloat(padding))\n } else {\n for (const [edge, value] of Object.entries(padding)) {\n if (edge in Style.Edge) {\n const edgeKey = edge as keyof typeof Style.Edge\n if (typeof value === 'string' && value.endsWith('%')) {\n this.node.setPaddingPercent(Style.Edge[edgeKey], parseFloat(value))\n } else {\n this.node.setPadding(Style.Edge[edgeKey], value as number)\n }\n }\n }\n }\n }\n if (border) {\n if (typeof border === 'number') {\n this.node.setBorder(Style.Edge.All, border)\n } else {\n for (const [edge, value] of Object.entries(border)) {\n if (edge in Style.Edge) this.node.setBorder(Style.Edge[edge as keyof typeof Style.Edge], value)\n }\n }\n }\n if (aspectRatio !== undefined) this.node.setAspectRatio(aspectRatio)\n if (overflow !== undefined) this.node.setOverflow(overflow)\n if (display !== undefined) this.node.setDisplay(display)\n if (boxSizing !== undefined) this.node.setBoxSizing(boxSizing)\n if (direction !== undefined) this.node.setDirection(direction)\n if (flexWrap !== undefined) this.node.setFlexWrap(flexWrap)\n // --- End Yoga layout property application ---\n }\n\n /**\n * Renders the node and its children to the canvas.\n * @param {CanvasRenderingContext2D} ctx Canvas rendering context (from skia-canvas).\n * @param {number} offsetX X offset for rendering.\n * @param {number} offsetY Y offset for rendering.\n */\n async render(ctx: CanvasRenderingContext2D, offsetX: number = 0, offsetY: number = 0) {\n const layout = this.node.getComputedLayout()\n const x = layout.left + offsetX\n const y = layout.top + offsetY\n const width = layout.width\n const height = layout.height\n\n // Exit early if the node is invisible or has no dimensions.\n if (width <= 0 || height <= 0 || this.props.display === Style.Display.None) {\n return\n }\n\n // --- Opacity Setup ---\n const desiredOpacity = Math.max(0, Math.min(1, this.props.opacity ?? 1))\n let originalAlpha: number | undefined = undefined\n let appliedOpacity = false\n if (desiredOpacity < 1) {\n originalAlpha = ctx.globalAlpha\n ctx.globalAlpha = originalAlpha * desiredOpacity\n appliedOpacity = true\n }\n // --- End Opacity Setup ---\n\n try {\n // --- Transformation Setup ---\n const transform = this.props.transform\n const needsTransform =\n transform && (transform.translateX || transform.translateY || transform.rotate || transform.scale || transform.scaleX || transform.scaleY)\n\n let savedContextForTransform = false\n if (needsTransform) {\n ctx.save()\n savedContextForTransform = true\n const originXRaw = transform.originX ?? '50%'\n const originYRaw = transform.originY ?? '50%'\n const originOffsetX = parsePercentage(originXRaw, width)\n const originOffsetY = parsePercentage(originYRaw, height)\n const originAbsX = x + originOffsetX\n const originAbsY = y + originOffsetY\n ctx.translate(originAbsX, originAbsY)\n if (transform.translateX || transform.translateY) {\n const tx = parsePercentage(transform.translateX, width)\n const ty = parsePercentage(transform.translateY, height)\n if (tx !== 0 || ty !== 0) ctx.translate(tx, ty)\n }\n if (transform.rotate) {\n ctx.rotate((transform.rotate * Math.PI) / 180)\n }\n if (transform.scale || transform.scaleX || transform.scaleY) {\n const scaleX = transform.scaleX ?? transform.scale ?? 1\n const scaleY = transform.scaleY ?? transform.scale ?? 1\n if (scaleX !== 1 || scaleY !== 1) ctx.scale(scaleX, scaleY)\n }\n ctx.translate(-originAbsX, -originAbsY)\n }\n // --- End Transformation Setup ---\n\n // --- Step 1: Render Parent Background/Borders/Content ---\n // This renders the current node's own visual appearance first.\n await this._renderContent(ctx, x, y, width, height)\n\n // --- Step 2: Prepare Children for Stacking ---\n const positionedChildren: { node: BoxNode; zIndex: number; originalIndex: number }[] = []\n const inFlowChildren: BoxNode[] = []\n\n this.children.forEach((child, index) => {\n // Check if child participates in zIndex stacking\n if (child.props.positionType === Style.PositionType.Absolute && child.props.zIndex !== undefined) {\n positionedChildren.push({\n node: child,\n zIndex: child.props.zIndex,\n originalIndex: index, // Keep original order for tie-breaking\n })\n } else {\n inFlowChildren.push(child)\n }\n })\n\n // Sort positioned children by zIndex, then by original order\n positionedChildren.sort((a, b) => {\n return a.zIndex - b.zIndex || a.originalIndex - b.originalIndex\n })\n\n // --- Step 3: Handle Clipping (Applies before drawing children) ---\n let savedContextForClip = false\n if (this.props.overflow === Style.Overflow.Hidden && (width > 0 || height > 0)) {\n ctx.save()\n savedContextForClip = true\n const borderLeft = this.node.getComputedBorder(Style.Edge.Left)\n const borderTop = this.node.getComputedBorder(Style.Edge.Top)\n const borderRight = this.node.getComputedBorder(Style.Edge.Right)\n const borderBottom = this.node.getComputedBorder(Style.Edge.Bottom)\n const innerX = x + borderLeft\n const innerY = y + borderTop\n const innerWidth = Math.max(0, width - borderLeft - borderRight)\n const innerHeight = Math.max(0, height - borderTop - borderBottom)\n const outerRadii = parseBorderRadius(this.props.borderRadius)\n const innerRadii = {\n TopLeft: Math.max(0, outerRadii.TopLeft - Math.max(borderLeft, borderTop)),\n TopRight: Math.max(0, outerRadii.TopRight - Math.max(borderRight, borderTop)),\n BottomRight: Math.max(0, outerRadii.BottomRight - Math.max(borderRight, borderBottom)),\n BottomLeft: Math.max(0, outerRadii.BottomLeft - Math.max(borderLeft, borderBottom)),\n }\n if (innerWidth > 0 && innerHeight > 0) {\n drawRoundedRectPath(ctx, innerX, innerY, innerWidth, innerHeight, innerRadii)\n ctx.clip()\n } else {\n ctx.beginPath()\n ctx.rect(innerX, innerY, 0, 0)\n ctx.clip()\n }\n }\n // --- End Clipping Setup ---\n\n // --- Step 4: Render Children in Stacking Order ---\n\n // 4a: Render positioned children with negative zIndex\n for (const item of positionedChildren) {\n if (item.zIndex < 0) {\n // Pass parent's layout origin (x, y) as offset\n await item.node.render(ctx, x, y)\n }\n }\n\n // 4b: Render in-flow children (recursively)\n for (const child of inFlowChildren) {\n // Pass parent's layout origin (x, y) as offset\n await child.render(ctx, x, y)\n }\n\n // 4c: Render positioned children with zero or positive zIndex\n for (const item of positionedChildren) {\n if (item.zIndex >= 0) {\n // Pass parent's layout origin (x, y) as offset\n await item.node.render(ctx, x, y)\n }\n }\n // --- End Child Rendering ---\n\n // --- Step 5: Restore Clipping Context ---\n if (savedContextForClip) {\n ctx.restore()\n }\n // --- End Clipping Restoration ---\n\n // --- Step 6: Restore Transformation Context ---\n if (savedContextForTransform) {\n ctx.restore()\n }\n // --- End Transformation Restoration ---\n } finally {\n // --- Opacity Restoration ---\n if (appliedOpacity && originalAlpha !== undefined) {\n ctx.globalAlpha = originalAlpha\n }\n // --- End Opacity Restoration ---\n }\n }\n\n /**\n * Renders the node's visual content including background fills, shadows, and borders.\n * This is an internal method used by the render() pipeline.\n * @param ctx The skia-canvas 2D rendering context to draw into\n * @param x The absolute x-coordinate where drawing should begin\n * @param y The absolute y-coordinate where drawing should begin\n * @param width The width of the content area to render\n * @param height The height of the content area to render\n */\n protected async _renderContent(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number) {\n // Calculate border radius values for all corners\n const radii = { TopLeft: 0, TopRight: 0, BottomRight: 0, BottomLeft: 0 }\n if (this.props.borderRadius) {\n // Handle both number and object border radius specifications\n if (typeof this.props.borderRadius === 'number') {\n radii.TopLeft = radii.TopRight = radii.BottomRight = radii.BottomLeft = this.props.borderRadius\n } else {\n // Extract individual corner radii, defaulting to 0 if not specified\n radii.TopLeft = this.props.borderRadius.TopLeft ?? 0\n radii.TopRight = this.props.borderRadius.TopRight ?? 0\n radii.BottomRight = this.props.borderRadius.BottomRight ?? 0\n radii.BottomLeft = this.props.borderRadius.BottomLeft ?? 0\n }\n // Ensure all radii are non-negative\n radii.TopLeft = Math.max(0, radii.TopLeft)\n radii.TopRight = Math.max(0, radii.TopRight)\n radii.BottomRight = Math.max(0, radii.BottomRight)\n radii.BottomLeft = Math.max(0, radii.BottomLeft)\n }\n\n // Process shadow configurations\n let shadows: BoxShadowProps[] = []\n if (this.props.boxShadow) {\n shadows = Array.isArray(this.props.boxShadow) ? this.props.boxShadow : [this.props.boxShadow]\n }\n // Split shadows into outset (normal) and inset types\n const outsetShadows = shadows.filter(s => !s.inset)\n const insetShadows = shadows.filter(s => s.inset)\n\n // Determine if background is fully opaque for shadow optimization\n const backgroundColor = this.props.backgroundColor\n let isOpaque = false\n if (backgroundColor && !this.props.gradient) {\n const rgba = tinycolor(backgroundColor).toRgb()\n isOpaque = rgba && rgba.a === 1\n }\n\n // Render outset shadows if present\n if (outsetShadows.length > 0) {\n const subtractOffset = 0.75\n if (isOpaque) {\n // Optimized rendering path for opaque backgrounds\n ctx.save()\n ctx.fillStyle = 'black' // Shadow source color\n for (const shadow of outsetShadows) {\n ctx.shadowColor = shadow.color ?? 'black'\n ctx.shadowOffsetX = shadow.offsetX ?? 0\n ctx.shadowOffsetY = shadow.offsetY ?? 0\n ctx.shadowBlur = shadow.blur ?? Math.max(shadow.offsetX ?? 0, shadow.offsetY ?? 0)\n drawRoundedRectPath(ctx, x + subtractOffset / 2, y + subtractOffset / 2, width - subtractOffset, height - subtractOffset, radii)\n ctx.fill()\n }\n ctx.restore()\n } else {\n // Complex shadow rendering for transparent/gradient backgrounds\n let maxBlur = 0\n let maxOffsetX = 0\n let maxOffsetY = 0\n\n // Calculate maximum shadow extents\n for (const shadow of outsetShadows) {\n const currentOffsetX = shadow.offsetX ?? 0\n const currentOffsetY = shadow.offsetY ?? 0\n const currentBlur = shadow.blur ?? Math.max(currentOffsetX, currentOffsetY)\n maxBlur = Math.max(maxBlur, currentBlur)\n maxOffsetX = Math.max(maxOffsetX, Math.abs(currentOffsetX))\n maxOffsetY = Math.max(maxOffsetY, Math.abs(currentOffsetY))\n }\n\n // Calculate offscreen canvas size with padding for shadows\n const blurPaddingMultiplier = 2\n const shadowPadding = Math.ceil(maxBlur * blurPaddingMultiplier + Math.max(maxOffsetX, maxOffsetY))\n const offscreenWidth = Math.ceil(width + shadowPadding * 2)\n const offscreenHeight = Math.ceil(height + shadowPadding * 2)\n\n if (offscreenWidth > 0 && offscreenHeight > 0) {\n // Create temporary canvas for shadow composition\n const offscreenCanvas = new Canvas(offscreenWidth, offscreenHeight)\n const offCtx = offscreenCanvas.getContext('2d')\n offCtx.imageSmoothingEnabled = true\n offCtx.imageSmoothingQuality = 'high'\n const shapeOffsetX = shadowPadding\n const shapeOffsetY = shadowPadding\n\n // Render each shadow individually onto offscreen canvas\n for (const shadow of outsetShadows) {\n offCtx.save()\n const shadowOffsetX = shadow.offsetX ?? 0\n const shadowOffsetY = shadow.offsetY ?? 0\n const blur = shadow.blur ?? Math.max(shadowOffsetX, shadowOffsetY)\n offCtx.shadowColor = shadow.color ?? 'black'\n offCtx.shadowOffsetX = shadowOffsetX\n offCtx.shadowOffsetY = shadowOffsetY\n offCtx.shadowBlur = Math.max(0, blur)\n drawRoundedRectPath(\n offCtx,\n shapeOffsetX + subtractOffset / 2,\n shapeOffsetY + subtractOffset / 2,\n width - subtractOffset,\n height - subtractOffset,\n radii,\n )\n offCtx.fillStyle = 'rgba(0,0,0,1)'\n offCtx.fill()\n offCtx.restore()\n }\n\n // Cut out the shape from accumulated shadows\n offCtx.save()\n offCtx.globalCompositeOperation = 'destination-out'\n drawRoundedRectPath(offCtx, shapeOffsetX, shapeOffsetY, width, height, radii)\n offCtx.fillStyle = 'rgba(0,0,0,1)'\n offCtx.fill()\n offCtx.restore()\n\n // Composite shadow result onto main canvas\n ctx.drawImage(offscreenCanvas, x - shadowPadding, y - shadowPadding)\n }\n }\n }\n\n // Render background fill (solid color or gradient)\n // This logic uses standard context methods and remains unchanged.\n const hasFill = this.props.gradient || this.props.backgroundColor\n if (hasFill) {\n let fillStyle: string | CanvasGradient = this.props.backgroundColor || 'transparent'\n if (this.props.gradient) {\n const { type = 'linear', colors, direction = 'to-bottom' } = this.props.gradient\n let grad: CanvasGradient | null = null\n if (colors && colors.length > 0 && width > 0 && height > 0) {\n if (type === 'linear') {\n let x0 = 0,\n y0 = 0,\n x1 = 0,\n y1 = 0\n let directionIsValid = false\n if (Array.isArray(direction) && direction.length === 4) {\n ;[x0, y0, x1, y1] = direction\n directionIsValid = true\n } else if (typeof direction === 'string') {\n switch (direction.toLowerCase()) {\n case 'to-right':\n x0 = 0\n y0 = 0\n x1 = width\n y1 = 0\n directionIsValid = true\n break\n case 'to-left':\n x0 = width\n y0 = 0\n x1 = 0\n y1 = 0\n directionIsValid = true\n break\n case 'to-bottom':\n x0 = 0\n y0 = 0\n x1 = 0\n y1 = height\n directionIsValid = true\n break\n case 'to-top':\n x0 = 0\n y0 = height\n x1 = 0\n y1 = 0\n directionIsValid = true\n break\n case 'to-top-right':\n x0 = 0\n y0 = height\n x1 = width\n y1 = 0\n directionIsValid = true\n break\n case 'to-top-left':\n x0 = width\n y0 = height\n x1 = 0\n y1 = 0\n directionIsValid = true\n break\n case 'to-bottom-right':\n x0 = 0\n y0 = 0\n x1 = width\n y1 = height\n directionIsValid = true\n break\n case 'to-bottom-left':\n x0 = width\n y0 = 0\n x1 = 0\n y1 = height\n directionIsValid = true\n break\n }\n }\n if (directionIsValid) {\n grad = ctx.createLinearGradient(x + x0, y + y0, x + x1, y + y1)\n } else {\n console.warn(`[BoxNode ${this.key}] Invalid linear gradient direction:`, direction)\n }\n } else if (type === 'radial') {\n const centerX = x + width / 2\n const centerY = y + height / 2\n const r0 = 0\n const r1 = 0.5 * Math.sqrt(width * width + height * height)\n if (r1 > 0) {\n grad = ctx.createRadialGradient(centerX, centerY, r0, centerX, centerY, r1)\n }\n }\n if (grad) {\n colors.forEach((color, i) => {\n const stop = colors.length > 1 ? Math.max(0, Math.min(1, i / (colors.length - 1))) : 0.5\n grad!.addColorStop(stop, color)\n })\n fillStyle = grad\n } else {\n console.warn(`[BoxNode ${this.key}] Could not create ${type} gradient. Falling back to backgroundColor.`)\n }\n } else {\n if (!colors?.length) {\n console.warn(`[BoxNode ${this.key}] Gradient specified but no colors provided. Falling back to backgroundColor.`)\n } else {\n console.warn(`[BoxNode ${this.key}] Cannot draw gradient with zero width/height.`)\n }\n }\n }\n if (fillStyle && fillStyle !== 'transparent') {\n ctx.fillStyle = fillStyle\n drawRoundedRectPath(ctx, x, y, width, height, radii)\n ctx.fill()\n }\n }\n\n // Render inset shadows\n // This logic uses standard context methods and remains unchanged.\n if (insetShadows.length > 0) {\n for (const shadow of insetShadows) {\n ctx.save()\n const color = shadow.color ?? 'black'\n const shadowOffsetX = shadow.offsetX ?? 0\n const shadowOffsetY = shadow.offsetY ?? 0\n const blur = shadow.blur ?? Math.max(shadowOffsetX, shadowOffsetY)\n drawRoundedRectPath(ctx, x, y, width, height, radii)\n ctx.clip()\n ctx.shadowColor = color\n ctx.shadowOffsetX = shadowOffsetX\n ctx.shadowOffsetY = shadowOffsetY\n ctx.shadowBlur = blur\n ctx.lineWidth = 1 // Minimal line width for the stroke.\n ctx.strokeStyle = 'transparent' // Stroke color doesn't matter; only the shadow does.\n // Draw a slightly offset path *inside* the clip to generate the inset shadow.\n drawRoundedRectPath(ctx, x - shadowOffsetX, y - shadowOffsetY, width, height, radii)\n ctx.stroke() // The stroke generates the shadow inside the clipped area.\n ctx.restore()\n }\n }\n\n // Render border strokes\n // (This logic uses standard context methods via drawBorders helper and remains unchanged)\n drawBorders({\n ctx,\n node: this.node,\n x,\n y,\n width,\n height,\n radii,\n borderColor: this.props.borderColor,\n borderStyle: this.props.borderStyle,\n })\n }\n}\n\n/**\n * Normalizes children into a flat CanvasElement array, filtering falsy values.\n */\nfunction normalizeDescriptorChildren(children: BoxProps['children']): CanvasElement[] | undefined {\n if (children === undefined || children === null || children === false) return undefined\n const arr = (Array.isArray(children) ? children : [children]).filter(Boolean) as CanvasElement[]\n return arr.length > 0 ? arr : undefined\n}\n\n/**\n * Creates a new BoxNode instance.\n * @param {BoxProps} props Box properties and configuration.\n * @returns {BoxNode} New BoxNode instance.\n */\nexport const Box = ({ children, ...rest }: BoxProps): CanvasElement => ({\n __type: 'Box',\n props: rest,\n children: normalizeDescriptorChildren(children),\n})\n\n/**\n * @class ColumnNode\n * Node class for vertical column layout\n */\nexport class ColumnNode extends BoxNode {\n constructor(props: BoxProps & BaseProps = {}) {\n super({\n display: Style.Display.Flex,\n flexDirection: Style.FlexDirection.Column,\n flexShrink: 1,\n flexBasis: props.flexGrow === 1 ? 0 : undefined,\n ...props,\n })\n }\n}\n\n/**\n * Creates a new ColumnNode instance.\n * @param {BoxProps} props Column properties and configuration.\n * @returns {ColumnNode} New ColumnNode instance.\n */\nexport const Column = ({ children, ...rest }: BoxProps): CanvasElement => ({\n __type: 'Column',\n props: rest,\n children: normalizeDescriptorChildren(children),\n})\n\n/**\n * @class RowNode\n * @classdesc Node class for horizontal row layout.\n */\nexport class RowNode extends BoxNode {\n constructor(props: BoxProps & BaseProps = {}) {\n super({\n name: 'Row',\n display: Style.Display.Flex,\n flexDirection: Style.FlexDirection.Row,\n flexShrink: 1, // Default shrink for rows\n ...props,\n })\n }\n}\n\n/**\n * Creates a new RowNode instance.\n * @param {BoxProps} props Row properties and configuration.\n * @returns {RowNode} New RowNode instance.\n */\nexport const Row = ({ children, ...rest }: BoxProps): CanvasElement => ({\n __type: 'Row',\n props: rest,\n children: normalizeDescriptorChildren(children),\n})\n"],"names":["Yoga","Style","omit","parsePercentage","parseBorderRadius","drawRoundedRectPath","Canvas","drawBorders"],"mappings":";;;;;;;;;AAOA;;;;AAIG;MACU,OAAO,C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,YAAA,UAAU,EAAE,CAAC;AACb,YAAA,SAAS,EAAE,KAAK,CAAC,QAAQ,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS;AAC/C,YAAA,GAAG,KAAK;AACT,SAAA,CAAC;IACJ;AACD;AAED;;;;AAIG;AACI,MAAM,MAAM,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAY,MAAqB;AACzE,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,QAAQ,EAAE,2BAA2B,CAAC,QAAQ,CAAC;AAChD,CAAA;AAED;;;AAGG;AACG,MAAO,OAAQ,SAAQ,OAAO,CAAA;AAClC,IAAA,WAAA,CAAY,QAA8B,EAAE,EAAA;AAC1C,QAAA,KAAK,CAAC;AACJ,YAAA,IAAI,EAAE,KAAK;AACX,YAAA,OAAO,EAAEA,kBAAK,CAAC,OAAO,CAAC,IAAI;AAC3B,YAAA,aAAa,EAAEA,kBAAK,CAAC,aAAa,CAAC,GAAG;YACtC,UAAU,EAAE,CAAC;AACb,YAAA,GAAG,KAAK;AACT,SAAA,CAAC;IACJ;AACD;AAED;;;;AAIG;AACI,MAAM,GAAG,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAY,MAAqB;AACtE,IAAA,MAAM,EAAE,KAAK;AACb,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,QAAQ,EAAE,2BAA2B,CAAC,QAAQ,CAAC;AAChD,CAAA;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { Canvas } from 'skia-canvas';
1
+ import { Canvas, type CanvasRenderingContext2D } from 'skia-canvas';
2
2
  import { ColumnNode, BoxNode } from '../canvas/layout.canvas.js';
3
3
  import type { BaseProps, RootProps, CanvasElement, RootPropsWithWorker, RootPropsWithoutWorker } from '../canvas/canvas.type.js';
4
4
  export declare const _clearRegisteredFonts: () => void;
@@ -58,7 +58,8 @@ export declare class RootNode extends ColumnNode {
58
58
  * and final drawing
59
59
  * @returns Promise resolving to the rendered Canvas instance
60
60
  */
61
- render(): Promise<Canvas>;
61
+ render(ctx: CanvasRenderingContext2D, offsetX?: number, offsetY?: number): Promise<void>;
62
+ render(ctx?: CanvasRenderingContext2D, offsetX?: number, offsetY?: number): Promise<Canvas>;
62
63
  }
63
64
  /**
64
65
  * Creates and renders a new root node with the given properties.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root.canvas.d.ts","sourceRoot":"","sources":["../../../src/canvas/root.canvas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,KAAK,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAEhF,OAAO,EAAE,UAAU,EAAE,OAAO,EAAW,MAAM,2BAA2B,CAAA;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAgB/H,eAAO,MAAM,qBAAqB,YAEjC,CAAA;AAmBD,MAAM,WAAW,kBAAkB;IACjC,uFAAuF;IACvF,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,kBAAkB,QAGpD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,SAKxB;AAqFD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,aAAa,GAAG,OAAO,CAmB5D;AAED;;;GAGG;AACH,qBAAa,QAAS,SAAQ,UAAU;IAC9B,KAAK,EAAE,SAAS,GAAG,SAAS,CAAA;IACpC,6CAA6C;IAC7C,OAAO,CAAC,MAAM,CAAoB;IAClC,8CAA8C;IAC9C,OAAO,CAAC,GAAG,CAAwC;IACnD,4CAA4C;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;IACpC,6CAA6C;IAC7C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAoB;I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