uikit/scripts/build-watermark-distribution.mjs
Mohamadzadeh 1099691b9a
All checks were successful
Build and Deploy Next.js + Nginx Docker Image / build-and-deploy (push) Successful in 50s
Build and Deploy Next.js + Nginx Docker Image / deploy (push) Successful in 7s
uikit-v1.4.0-watermark-complete
2026-11-01 12:52:28 +03:30

18 lines
1.0 KiB
JavaScript

// Fallback distributor for the isolated watermark module. The normal Vite
// build also emits this public entry; no host-application imports are bundled.
import { readFile, writeFile } from 'node:fs/promises';
const parts = await Promise.all([
'src/watermark/codec.js',
'src/watermark/render.js',
'src/watermark/ForensicWatermark.jsx',
'src/watermark/resolve-token.js',
'src/watermark/index.jsx',
].map(path => readFile(path, 'utf8')));
function localize(s) {
return s.replace(/^import[\s\S]*?from\s+["'][^"']+["'];\s*/gm, '')
.replace(/^export\s+(?=(?:const|function|class)\b)/gm, '')
.replace(/^export\s*\{[^\n]*\}\s*from\s*[\"'][^\"']+[\"'];?\s*/gm, '');
}
const output = `"use client";\nimport React, { useCallback, useRef, useState, useEffect } from "react";\nimport { d as defineFeature } from "./chunks/_shared-DHh79jO9.js";\nimport { u as useKeycloakOptional } from "./chunks/_runtime-B6XIrDzf.js";\n` + parts.map(localize).join('\n') + '\nexport { Watermark, ForensicWatermark };\n';
await writeFile('dist/watermark.js', output);