Skip to content

Commit

Permalink
chore: release
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed Apr 24, 2024
1 parent edc33d0 commit ed8f0e4
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 29 deletions.
6 changes: 6 additions & 0 deletions packages/istanbul-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# istanbul-widget

## 1.3.2

### Patch Changes

- iife: mount the istanbul instance on Window

## 1.3.1

### Patch Changes
Expand Down
17 changes: 14 additions & 3 deletions packages/istanbul-widget/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
如果你使用vite作为开发框架,推荐使用 `vite-plugin-istanbul-widget`

## 安装
## 上手

### 方法一:使用 npm

```bash
npm install istanbul-widget
```

## 使用

```ts
import { IstanbulWidget } from 'istanbul-widget'

Expand All @@ -26,6 +26,17 @@ const istanbulWidget = new IstanbulWidget({
})
```

### 方法二:使用CDN直接插入到HTML

```html
<script src="https://unpkg.com/istanbul-widget@latest/dist/istanbul-widget.min.js"></script>
<script>
// 默认会挂载到 `window.IstanbulWidget` 上
var istanbulWidget = new window.IstanbulWidget();
</script>
```


## 配置项

```ts
Expand Down
18 changes: 18 additions & 0 deletions packages/istanbul-widget/iife.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>iife</title>
</head>

<body>
<script src="./dist/istanbul-widget.min.js"></script>
<script>
var istanbulWidget = new window.IstanbulWidget()
console.log(istanbulWidget)
</script>
</body>

</html>
2 changes: 1 addition & 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.3.1",
"version": "1.3.2",
"type": "module",
"files": [
"**"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isFunction } from '@minko-fe/lodash-pro'
import React from 'react'
import ReactDOM from 'react-dom/client'
import { $ } from '@/utils/query'
Expand Down Expand Up @@ -38,7 +39,7 @@ export class IstanbulWidgetReactPlugin<T extends {} = {}> extends IstanbulWidget
public registerEvents() {
const properties = Object.getOwnPropertyNames(IstanbulWidgetReactPlugin.prototype)

const onMethods = properties.filter((name) => name.startsWith('on') && typeof this[name] === 'function')
const onMethods = properties.filter((name) => name.startsWith('on') && isFunction(this[name]))

onMethods.forEach((methodName) => {
this[methodName].call(this)
Expand Down
5 changes: 5 additions & 0 deletions packages/istanbul-widget/src/istanbul-widget.iife.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-nocheck

import { IstanbulWidget } from './core/core'

window.IstanbulWidget = IstanbulWidget
9 changes: 5 additions & 4 deletions packages/istanbul-widget/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const common = (option: Options): Options => ({
})

const esmBundle: Options = {
format: ['esm'],
format: 'esm',
entry: {
'istanbul-widget.esm': 'src/istanbul-widget.ts',
},
Expand All @@ -120,9 +120,9 @@ const esmBundle: Options = {

const iife: Options = {
injectStyle: true,
format: ['iife'],
format: 'iife',
entry: {
'istanbul-widget.min': 'src/istanbul-widget.ts',
'istanbul-widget.min': 'src/istanbul-widget.iife.ts',
},
esbuildOptions(options) {
if (!options.logOverride) {
Expand All @@ -131,14 +131,15 @@ const iife: Options = {
options.logOverride!['empty-import-meta'] = 'silent'
},
dts: false,
minify: true,
}

const esmBundleless: Options = {
entry: ['src/**/*.{ts,tsx,css}'],
dts: {
entry: getEntry('src/**/*.{ts,tsx}'),
},
format: ['esm'],
format: 'esm',
outDir: 'dist/es',
outExtension: () => ({ js: '.js' }),
esbuildPlugins: [fileSuffixPlugin('esm')],
Expand Down
8 changes: 8 additions & 0 deletions packages/vite-plugin-istanbul-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# vite-plugin-istanbul-widget

## 1.3.2

### Patch Changes

- docs update
- Updated dependencies
- istanbul-widget@1.3.2

## 1.3.1

### Patch Changes
Expand Down
42 changes: 24 additions & 18 deletions packages/vite-plugin-istanbul-widget/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,29 @@ export default defineConfig((env) => ({

```ts
type VitePluginIstanbulWidgetOptions = {
/**
* 入口文件,默认读取 src/main.{ts,tsx}
* @default 'src/main.{ts,tsx}'
*/
entry?: string;
/**
* 是否开启插件
*/
enabled?: boolean;
/**
* vite-plugin-istanbul 配置
*/
istanbulPluginConfig?: IstanbulPluginOptions;
/**
* istanbul-widget 配置
* @description false 时则关闭 istanbulWidget 控件
*/
istanbulWidgetConfig: IstanbulWidgetOptions | false;
/**
* 入口文件
* @default 'src/main.{ts,tsx}'
*/
entry?: string
/**
* 是否开启插件
* @default false
*/
enabled?: boolean
/**
* 全量上报
* @default true
*/
fullReport?: boolean
/**
* vite-plugin-istanbul 配置
*/
istanbulPluginConfig?: IstanbulPluginOptions
/**
* istanbul-widget 配置
* @description false 则关闭 istanbul-widget 控件
*/
istanbulWidgetConfig: IstanbulWidgetOptions | false
}
```
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.3.1",
"version": "1.3.2",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin-istanbul-widget/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import glob from 'tiny-glob'
import istanbul, { type IstanbulPluginOptions } from 'vite-plugin-istanbul'
import serialize from '../serialize'

type VitePluginIstanbulWidgetOptions = {
export type VitePluginIstanbulWidgetOptions = {
/**
* 入口文件
* @default 'src/main.{ts,tsx}'
Expand Down

0 comments on commit ed8f0e4

Please sign in to comment.