Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gentle-ravens-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@kitql/helper': patch
---

Remove colors from browser in production
10 changes: 8 additions & 2 deletions packages/helper/src/lib/colors/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BROWSER } from 'esm-env'
import { BROWSER, DEV } from 'esm-env'
import * as stylesBrowser from './stylesBrowser.js'
import * as stylesNode from './stylesNode.js'
import type { Style } from './types.js'
Expand All @@ -25,6 +25,9 @@ const START1 = `$$KitQL_`
const START2 = `_KitQL$$`
const END = `$$KitQLEND$$`
const colorBrowser = (style: Style, str: string) => {
if (BROWSER && !DEV) {
return str
}
return `${START1}${style}${START2}${str}${END}`
}

Expand Down Expand Up @@ -53,10 +56,13 @@ const getAllIndexOf = (str: string, subStr: string) => {
return indexes
}

export const colorProcess = (str: string) => {
export const colorProcess = (str: string): string[] => {
if (!BROWSER) {
return [str]
}
if (BROWSER && !DEV) {
return [str]
}
const originalStr = str
const posToReplace: { index: number; browser: string }[] = []

Expand Down