mirror of
https://github.com/infinilabs/coco-app.git
synced 2025-12-16 11:37:47 +01:00
chhore: add
This commit is contained in:
10
package.json
10
package.json
@@ -8,9 +8,10 @@
|
||||
"build": "tsc && vite build",
|
||||
"build:web": "cross-env BUILD_TARGET=web tsc && cross-env BUILD_TARGET=web tsup --format esm",
|
||||
"publish:web": "cd out/search-chat && npm publish",
|
||||
"publish:web:beta": "cd dist/search-chat && npm publish --tag beta",
|
||||
"publish:web:alpha": "cd dist/search-chat && npm publish --tag alpha",
|
||||
"publish:web:rc": "cd dist/search-chat && npm publish --tag rc",
|
||||
"publish:web:beta": "cd out/search-chat && npm publish --tag beta",
|
||||
"publish:web:alpha": "cd out/search-chat && npm publish --tag alpha",
|
||||
"publish:web:rc": "cd out/search-chat && npm publish --tag rc",
|
||||
"publish:web:otp": "cd out/search-chat && npm publish --access public --otp $NPM_OTP",
|
||||
"preview": "vite preview",
|
||||
"tauri": "tauri",
|
||||
"release": "release-it",
|
||||
@@ -85,6 +86,7 @@
|
||||
"zustand": "^5.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4.1.17",
|
||||
"@tailwindcss/vite": "^4.0.0",
|
||||
"@tauri-apps/cli": "^2.5.0",
|
||||
"@types/dom-speech-recognition": "^0.0.4",
|
||||
@@ -109,4 +111,4 @@
|
||||
"vite": "^5.4.19"
|
||||
},
|
||||
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
|
||||
}
|
||||
}
|
||||
|
||||
20
pnpm-lock.yaml
generated
20
pnpm-lock.yaml
generated
@@ -204,6 +204,9 @@ importers:
|
||||
specifier: ^5.0.4
|
||||
version: 5.0.8(@types/react@18.3.26)(immer@10.2.0)(react@18.3.1)(use-sync-external-store@1.5.0(react@18.3.1))
|
||||
devDependencies:
|
||||
'@tailwindcss/postcss':
|
||||
specifier: ^4.1.17
|
||||
version: 4.1.17
|
||||
'@tailwindcss/vite':
|
||||
specifier: ^4.0.0
|
||||
version: 4.1.17(vite@5.4.21(@types/node@22.18.12)(lightningcss@1.30.2)(sass@1.93.2)(terser@5.40.0))
|
||||
@@ -273,6 +276,10 @@ importers:
|
||||
|
||||
packages:
|
||||
|
||||
'@alloc/quick-lru@5.2.0':
|
||||
resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
'@antfu/install-pkg@1.1.0':
|
||||
resolution: {integrity: sha512-MGQsmw10ZyI+EJo45CdSER4zEb+p31LpDAFp2Z3gkSd1yqVZGi0Ebx++YTEMonJy4oChEMLsxZ64j8FH6sSqtQ==}
|
||||
|
||||
@@ -1682,6 +1689,9 @@ packages:
|
||||
resolution: {integrity: sha512-F0F7d01fmkQhsTjXezGBLdrl1KresJTcI3DB8EkScCldyKp3Msz4hub4uyYaVnk88BAS1g5DQjjF6F5qczheLA==}
|
||||
engines: {node: '>= 10'}
|
||||
|
||||
'@tailwindcss/postcss@4.1.17':
|
||||
resolution: {integrity: sha512-+nKl9N9mN5uJ+M7dBOOCzINw94MPstNR/GtIhz1fpZysxL/4a+No64jCBD6CPN+bIHWFx3KWuu8XJRrj/572Dw==}
|
||||
|
||||
'@tailwindcss/vite@4.1.17':
|
||||
resolution: {integrity: sha512-4+9w8ZHOiGnpcGI6z1TVVfWaX/koK7fKeSYF3qlYg2xpBtbteP2ddBxiarL+HVgfSJGeK5RIxRQmKm4rTJJAwA==}
|
||||
peerDependencies:
|
||||
@@ -4409,6 +4419,8 @@ packages:
|
||||
|
||||
snapshots:
|
||||
|
||||
'@alloc/quick-lru@5.2.0': {}
|
||||
|
||||
'@antfu/install-pkg@1.1.0':
|
||||
dependencies:
|
||||
package-manager-detector: 1.5.0
|
||||
@@ -5633,6 +5645,14 @@ snapshots:
|
||||
'@tailwindcss/oxide-win32-arm64-msvc': 4.1.17
|
||||
'@tailwindcss/oxide-win32-x64-msvc': 4.1.17
|
||||
|
||||
'@tailwindcss/postcss@4.1.17':
|
||||
dependencies:
|
||||
'@alloc/quick-lru': 5.2.0
|
||||
'@tailwindcss/node': 4.1.17
|
||||
'@tailwindcss/oxide': 4.1.17
|
||||
postcss: 8.5.6
|
||||
tailwindcss: 4.1.17
|
||||
|
||||
'@tailwindcss/vite@4.1.17(vite@5.4.21(@types/node@22.18.12)(lightningcss@1.30.2)(sass@1.93.2)(terser@5.40.0))':
|
||||
dependencies:
|
||||
'@tailwindcss/node': 4.1.17
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
export default {
|
||||
plugins: {},
|
||||
plugins: {
|
||||
// Tailwind v4 PostCSS plugin has moved to @tailwindcss/postcss
|
||||
'@tailwindcss/postcss': {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
|
||||
30
src/main.css
30
src/main.css
@@ -193,26 +193,18 @@
|
||||
--coco-icon-color: rgb(255, 255, 255);
|
||||
}
|
||||
|
||||
/* Base styles */
|
||||
/* Base styles (scoped to coco container to avoid global overrides) */
|
||||
@layer base {
|
||||
* {
|
||||
.coco-container * {
|
||||
@apply box-border outline-none;
|
||||
}
|
||||
html {
|
||||
@apply h-full overscroll-none select-none;
|
||||
.coco-container {
|
||||
@apply antialiased rounded-xl bg-background text-foreground;
|
||||
}
|
||||
html,
|
||||
body,
|
||||
#root {
|
||||
@apply h-full antialiased rounded-xl;
|
||||
}
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
.input-body {
|
||||
.coco-container .input-body {
|
||||
@apply rounded-xl overflow-hidden;
|
||||
}
|
||||
.icon {
|
||||
.coco-container .icon {
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
vertical-align: -0.15em;
|
||||
@@ -238,27 +230,27 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Utility styles */
|
||||
/* Utility styles (scoped to coco container where reasonable) */
|
||||
@layer utilities {
|
||||
/* Fallback for Tailwind v4 class extraction edge-cases: ensure rounded-xl exists */
|
||||
.rounded-xl {
|
||||
border-radius: 0.75rem;
|
||||
}
|
||||
/* Scrollbar styles */
|
||||
.custom-scrollbar {
|
||||
.coco-container .custom-scrollbar {
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: #cbd5e1 transparent;
|
||||
}
|
||||
|
||||
.custom-scrollbar::-webkit-scrollbar {
|
||||
.coco-container .custom-scrollbar::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.custom-scrollbar::-webkit-scrollbar-track {
|
||||
.coco-container .custom-scrollbar::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.custom-scrollbar::-webkit-scrollbar-thumb {
|
||||
.coco-container .custom-scrollbar::-webkit-scrollbar-thumb {
|
||||
background-color: #cbd5e1;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import { Get } from "@/api/axiosRequest";
|
||||
import { useWebConfigStore } from "@/stores/webConfigStore";
|
||||
|
||||
import "@/i18n";
|
||||
import "@/main.css";
|
||||
// Styles are distributed separately in the library build (out/search-chat/index.css)
|
||||
|
||||
interface WebAppProps {
|
||||
headers?: Record<string, unknown>;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// manual modification
|
||||
import { createTauriAdapter } from "./tauriAdapter";
|
||||
let platformAdapter = createTauriAdapter();
|
||||
// import { createTauriAdapter } from "./tauriAdapter";
|
||||
// let platformAdapter = createTauriAdapter();
|
||||
|
||||
// import { createWebAdapter } from "./webAdapter";
|
||||
// let platformAdapter = createWebAdapter();
|
||||
import { createWebAdapter } from "./webAdapter";
|
||||
let platformAdapter = createWebAdapter();
|
||||
|
||||
export default platformAdapter;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { defineConfig } from 'tsup';
|
||||
import { writeFileSync, readFileSync, readdirSync, statSync } from 'fs';
|
||||
import { writeFileSync, readFileSync, readdirSync, statSync, existsSync } from 'fs';
|
||||
import { join, resolve } from 'path';
|
||||
import postcss from 'postcss';
|
||||
import tailwindcssPostcss from '@tailwindcss/postcss';
|
||||
import autoprefixer from 'autoprefixer';
|
||||
|
||||
const projectPackageJson = JSON.parse(
|
||||
readFileSync(join(__dirname, 'package.json'), 'utf-8')
|
||||
@@ -107,12 +110,12 @@ export default defineConfig({
|
||||
|
||||
const packageJson = {
|
||||
name: "@infinilabs/search-chat",
|
||||
version: "1.2.46",
|
||||
version: "1.2.54-beat.3",
|
||||
main: "index.js",
|
||||
module: "index.js",
|
||||
type: "module",
|
||||
types: "index.d.ts",
|
||||
dependencies: projectPackageJson.dependencies,
|
||||
dependencies: projectPackageJson.dependencies as Record<string, string>,
|
||||
peerDependencies: {
|
||||
"react": "^18.0.0",
|
||||
"react-dom": "^18.0.0"
|
||||
@@ -157,5 +160,54 @@ export default defineConfig({
|
||||
} catch (error) {
|
||||
console.error('Failed to copy README.md:', error);
|
||||
}
|
||||
|
||||
// Ensure Tailwind v4 directives (@import, @source, @apply, @theme) are compiled
|
||||
// into a final CSS for the library consumer. Esbuild doesn't process Tailwind,
|
||||
// so we run PostCSS with Tailwind + Autoprefixer here to produce index.css.
|
||||
try {
|
||||
const cssInPath = join(__dirname, 'src/main.css');
|
||||
const cssOutPath = join(__dirname, 'out/search-chat/index.css');
|
||||
const cssIn = readFileSync(cssInPath, 'utf-8');
|
||||
|
||||
const result = await postcss([
|
||||
// Use the Tailwind v4 PostCSS plugin from @tailwindcss/postcss
|
||||
tailwindcssPostcss,
|
||||
autoprefixer,
|
||||
]).process(cssIn, {
|
||||
from: cssInPath,
|
||||
to: cssOutPath,
|
||||
map: false,
|
||||
});
|
||||
|
||||
// Inline absolute asset URLs as Base64 data URIs to avoid shipping extra files
|
||||
// This fixes consumer bundlers failing to resolve "/assets/*.png" from node_modules
|
||||
const assetRegex = /url\((['"])\/assets\/([^'"\)]+)\1\)/g;
|
||||
const rewrittenCss = result.css.replace(assetRegex, (_m, quote, file) => {
|
||||
const srcAssetPath = join(__dirname, 'src/assets', file);
|
||||
if (!existsSync(srcAssetPath)) {
|
||||
console.warn(`[build:web] Asset not found: ${srcAssetPath}`);
|
||||
return `url(${quote}/assets/${file}${quote})`;
|
||||
}
|
||||
try {
|
||||
const buffer = readFileSync(srcAssetPath);
|
||||
const ext = file.split('.').pop()?.toLowerCase() ?? 'png';
|
||||
const mime = ext === 'svg'
|
||||
? 'image/svg+xml'
|
||||
: ext === 'jpg' || ext === 'jpeg'
|
||||
? 'image/jpeg'
|
||||
: 'image/png';
|
||||
const base64 = buffer.toString('base64');
|
||||
const dataUrl = `data:${mime};base64,${base64}`;
|
||||
return `url(${quote}${dataUrl}${quote})`;
|
||||
} catch (err) {
|
||||
console.error(`[build:web] Failed to inline asset ${file}:`, err);
|
||||
return `url(${quote}/assets/${file}${quote})`;
|
||||
}
|
||||
});
|
||||
|
||||
writeFileSync(cssOutPath, rewrittenCss);
|
||||
} catch (error) {
|
||||
console.error('Failed to compile Tailwind CSS with PostCSS:', error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user