Skip to content

Commit

Permalink
chore: release
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed Feb 19, 2025
1 parent 4667cf2 commit 5b65d4c
Show file tree
Hide file tree
Showing 18 changed files with 364 additions and 834 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@changesets/cli": "^2.27.12",
"@commitlint/cli": "^19.7.1",
"@minko-fe/commitlint-config": "^2.1.2",
"@minko-fe/eslint-config": "^4.1.1",
"@minko-fe/eslint-config": "^4.1.3",
"@minko-fe/prettier-config": "^2.2.3",
"@minko-fe/tsconfig": "latest",
"eslint": "^9.20.1",
Expand Down
5 changes: 5 additions & 0 deletions packages/istanbul-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# istanbul-widget

## 1.10.0
### Minor Changes

- expose context

## 1.9.2
### Patch Changes

Expand Down
5 changes: 4 additions & 1 deletion packages/istanbul-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "istanbul-widget",
"version": "1.9.2",
"version": "1.10.0",
"description": "收集 istanbul 代码覆盖率的web小组件",
"type": "module",
"keywords": [
Expand Down Expand Up @@ -40,6 +40,9 @@
"default": "./dist/istanbul-widget.lib.cjs"
},
"./package.json": "./package.json",
"./types": {
"types": "./types.d.ts"
},
"./*": "./*"
},
"sideEffects": [
Expand Down
1 change: 1 addition & 0 deletions packages/istanbul-widget/src/components/ui/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const DialogContent = React.forwardRef<
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<DialogPortal container={document.querySelector(`#${ISTANBUL_WIDGET_ID}`) as HTMLElement}>
<DialogDescription />
<DialogOverlay />
<DialogPrimitive.Content
ref={ref}
Expand Down
2 changes: 2 additions & 0 deletions packages/istanbul-widget/src/components/ui/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ const PopoverContent = React.forwardRef<
"iw-z-50 iw-w-fit iw-rounded-md iw-border iw-bg-popover iw-text-popover-foreground iw-shadow-md iw-outline-none data-[state=open]:iw-animate-in data-[state=closed]:iw-animate-out data-[state=closed]:iw-fade-out-0 data-[state=open]:iw-fade-in-0 data-[state=closed]:iw-zoom-out-95 data-[state=open]:iw-zoom-in-95 data-[side=bottom]:iw-slide-in-from-top-2 data-[side=left]:iw-slide-in-from-right-2 data-[side=right]:iw-slide-in-from-left-2 data-[side=top]:iw-slide-in-from-bottom-2 data-[state=closed]:iw-hidden",
className
)}
aria-describedby="popover-description"
{...props}

/>
</PopoverPrimitive.Portal>
))
Expand Down
2 changes: 1 addition & 1 deletion packages/istanbul-widget/src/core/components/draggable.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { memo, type PropsWithChildren, useEffect, useRef } from 'react'
import { useDraggable } from '@neodrag/react'
import { memo, type PropsWithChildren, useEffect, useRef } from 'react'
import { useLocalStorageState, useMemoizedFn } from 'ahooks'
import { max } from 'lodash-es'
import { cn } from '@/components/utils'
Expand Down
9 changes: 8 additions & 1 deletion packages/istanbul-widget/src/core/context.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { useDebounceFn, useLatest, useSetState } from 'ahooks'
import { createContainer } from 'context-state'
import { useToast } from '@/components/ui'
import { IstanbulWidget } from './core'
import { IstanbulWidget, type widgetReactContext } from './core'
import { type IstanbulWidgetOptions, type PluginName, type PluginType, type ReportParams } from './options.interface'

export type InitialWidgetProps = IstanbulWidgetOptions & {
/**
* 插件
*/
pluginList: { [id: string]: PluginType }
/**
* 上传上下文
*/
context: widgetReactContext
}

function useContext(initialValues: InitialWidgetProps) {
Expand All @@ -29,6 +33,7 @@ function useContext(initialValues: InitialWidgetProps) {

const { toast } = useToast()

const { context } = initialValues
const { beforeReport, onReport, afterReport } = initialValues.plugin?.report || {}

/**
Expand Down Expand Up @@ -74,6 +79,8 @@ function useContext(initialValues: InitialWidgetProps) {
},
)

context.report = reportFn.run

return {
...initialValues,
reportActions,
Expand Down
30 changes: 20 additions & 10 deletions packages/istanbul-widget/src/core/core.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
import { IstanbulWidgetReactPlugin } from './plugin/istanbul-widget-react-plugin'
import { type ConsolaInstance, createConsola, LogLevels } from 'consola/browser'
import { isArray, isFunction, isObject, merge, set } from 'lodash-es'
import { ButtonGroupPlugin } from '@/plugins/button-group/button-group-plugin'
import { ReportPlugin } from '@/plugins/report/report-plugin'
import { SettingPlugin } from '@/plugins/setting/setting-plugin'
import { ISTANBUL_WIDGET_ID } from '@/utils/const'
import { $ } from '@/utils/query'
import Context from './context'
import { type IstanbulWidgetOptions, type PluginName, type PluginType } from './options.interface'
import { IstanbulWidgetPlugin } from './plugin/istanbul-widget-plugin'
import { IstanbulWidgetReactPlugin } from './plugin/istanbul-widget-react-plugin'
import { type CompInstance, render } from './render'
import '@/styles/global.css'

export type widgetReactContext = {
report: (showToast?: boolean) => Promise<void> | undefined
}

declare global {
var __VERSION__: string

interface Window {
__istanbulWidgetAutoReportInterval: number | undefined
__coverage__: any | undefined
}
}

export class IstanbulWidget {
public version: string = __VERSION__
public isInited: boolean = false
Expand All @@ -27,11 +39,12 @@ export class IstanbulWidget {
},
defaultPlugins: ['buttonGroup', 'setting'],
} as IstanbulWidgetOptions
public context: widgetReactContext = {} as widgetReactContext

protected compInstance: CompInstance = {
private compInstance: CompInstance = {
pluginList: {},
} as CompInstance
protected pluginList: { [id: string]: IstanbulWidgetPlugin } = {} // plugin instance
private pluginList: { [id: string]: IstanbulWidgetPlugin } = {} // plugin instance

// Export static classes
public static IstanbulWidgetPlugin: typeof IstanbulWidgetPlugin
Expand All @@ -40,8 +53,6 @@ export class IstanbulWidget {
public static SettingPlugin: typeof SettingPlugin
public static ButtonGroupPlugin: typeof ButtonGroupPlugin

public static Context: typeof Context

public static logger: ConsolaInstance

constructor(opts: IstanbulWidgetOptions = {}) {
Expand Down Expand Up @@ -111,6 +122,7 @@ export class IstanbulWidget {
...this.compInstance,
...render({
target,
context: this.context,
pluginList: {},
theme: this.option.theme,
defaultPosition: {
Expand Down Expand Up @@ -284,7 +296,7 @@ export class IstanbulWidget {
}

public static get instance() {
return window.__ISTANBUL_WIDGET_INSTANCE
return window.__istanbul_widget__
}

public static set instance(value: IstanbulWidget | undefined) {
Expand All @@ -294,7 +306,7 @@ export class IstanbulWidget {
)
return
}
window.__ISTANBUL_WIDGET_INSTANCE = value
window.__istanbul_widget__ = value
}
}

Expand All @@ -303,5 +315,3 @@ IstanbulWidget.IstanbulWidgetReactPlugin = IstanbulWidgetReactPlugin
IstanbulWidget.ReportPlugin = ReportPlugin
IstanbulWidget.SettingPlugin = SettingPlugin
IstanbulWidget.ButtonGroupPlugin = ButtonGroupPlugin

IstanbulWidget.Context = Context
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { reactdomRender, reactdomUnmount } from '../dom/react-render'
import React from 'react'
import { $ } from '@/utils/query'
import { IstanbulWidget } from '../core'
import { reactdomRender, reactdomUnmount } from '../dom/react-render'
import { type PluginType } from '../options.interface'
import { IstanbulWidgetPlugin } from './istanbul-widget-plugin'

Expand Down
4 changes: 3 additions & 1 deletion packages/istanbul-widget/src/core/render.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { reactdomRender, reactdomUnmount } from './dom/react-render'
import { ISTANBUL_WIDGET_ID } from '@/utils/const'
import Context, { type InitialWidgetProps } from './context'
import { reactdomRender, reactdomUnmount } from './dom/react-render'
import { type widgetReactContext } from './core'
import IstanbulWidgetComponent from './istanbul-widget'
import { type PluginType } from './options.interface'

Expand All @@ -15,6 +16,7 @@ export function render({
...coreOptions
}: {
target: HTMLElement
context: widgetReactContext
} & InitialWidgetProps): Pick<CompInstance, 'destroy' | 'update'> {
const container = document.createElement('div')
container.id = ISTANBUL_WIDGET_ID
Expand Down
11 changes: 0 additions & 11 deletions packages/istanbul-widget/src/types.d.ts

This file was deleted.

9 changes: 9 additions & 0 deletions packages/istanbul-widget/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { type IstanbulWidget } from './src/istanbul-widget'

declare global {
interface Window {
__istanbul_widget__: IstanbulWidget | undefined
}
}

export {}
10 changes: 10 additions & 0 deletions packages/vite-plugin-istanbul-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# vite-plugin-istanbul-widget

## 1.10.0
### Minor Changes

- expose context

### Patch Changes

- Updated dependencies
- istanbul-widget@1.10.0

## 1.9.6
### Patch Changes

Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin-istanbul-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-istanbul-widget",
"version": "1.9.6",
"version": "1.10.0",
"description": "集成了 istanbul-widget 和 vite-plugin-istanbul 的vite插件",
"type": "module",
"keywords": [
Expand Down
5 changes: 0 additions & 5 deletions packages/vite-plugin-istanbul-widget/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import { checkPluginEnabled, ensureArray, getCommitId, resolveOptions, resolveWi
import { debug } from './utils/debug'
import { resolvedVirtualModuleId, runtimeId, vmods } from './virtual'

declare global {
// eslint-disable-next-line vars-on-top, no-var
var __GIT_COMMIT_ID__: string
}

export function istanbulWidget(opts: VitePluginIstanbulWidgetOptions): any {
const {
enabled,
Expand Down
6 changes: 6 additions & 0 deletions packages/vite-plugin-istanbul-widget/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="istanbul-widget/types" />

import { type IstanbulWidgetOptions } from 'istanbul-widget'
import { type IstanbulPluginOptions } from 'vite-plugin-istanbul'

Expand Down Expand Up @@ -36,3 +38,7 @@ export type VitePluginIstanbulWidgetOptions = {
*/
istanbulWidgetConfig?: IstanbulWidgetOptions | false
}

declare global {
var __GIT_COMMIT_ID__: string
}
1 change: 1 addition & 0 deletions playground/react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"preview": "vite preview"
},
"dependencies": {
"istanbul-widget": "workspace:*",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
Expand Down
Loading

0 comments on commit 5b65d4c

Please sign in to comment.