From a68a20f58d5a7480173e73a5596e2f2dcc727c4a Mon Sep 17 00:00:00 2001 From: ranzhouhang Date: Tue, 6 Aug 2024 09:59:27 +0800 Subject: [PATCH 1/4] feat: update version --- packages/docs/variable/SERVICE_WORK_VERSION.ts | 2 +- packages/ranui-react/package.json | 2 +- packages/ranui/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/docs/variable/SERVICE_WORK_VERSION.ts b/packages/docs/variable/SERVICE_WORK_VERSION.ts index aa8751358..2ac7f60ff 100644 --- a/packages/docs/variable/SERVICE_WORK_VERSION.ts +++ b/packages/docs/variable/SERVICE_WORK_VERSION.ts @@ -1 +1 @@ -export const SERVICE_WORK_VERSION = '1721560332'; +export const SERVICE_WORK_VERSION = "1722909342" diff --git a/packages/ranui-react/package.json b/packages/ranui-react/package.json index 91aba1d0c..484d35317 100644 --- a/packages/ranui-react/package.json +++ b/packages/ranui-react/package.json @@ -1,6 +1,6 @@ { "name": "@ranui/react", - "version": "0.1.5-alpha.3", + "version": "0.1.5-alpha.4", "description": "UI Component library based on `Web Component`", "main": "dist/umd/index.umd.cjs", "module": "dist/index.js", diff --git a/packages/ranui/package.json b/packages/ranui/package.json index 26312222f..4109a9c3e 100644 --- a/packages/ranui/package.json +++ b/packages/ranui/package.json @@ -1,6 +1,6 @@ { "name": "ranui", - "version": "0.1.10-alpha.12", + "version": "0.1.10-alpha.16", "description": "UI Component library based on `Web Component`", "main": "dist/umd/index.umd.cjs", "module": "dist/index.js", From 7bee6d7458fa6811825770605105357139bb21f0 Mon Sep 17 00:00:00 2001 From: ranzhouhang Date: Tue, 6 Aug 2024 13:18:39 +0800 Subject: [PATCH 2/4] feat: update version --- packages/ranui-react/babel.config.cjs | 3 +++ packages/ranui-react/package.json | 2 +- packages/ranui/babel.config.cjs | 3 +++ packages/ranui/package.json | 4 +++- packages/ranui/typings.d.ts | 28 +++++++++++++-------------- packages/ranui/vite.config.ts | 2 ++ 6 files changed, 26 insertions(+), 16 deletions(-) diff --git a/packages/ranui-react/babel.config.cjs b/packages/ranui-react/babel.config.cjs index e6ffbd417..08249c74c 100644 --- a/packages/ranui-react/babel.config.cjs +++ b/packages/ranui-react/babel.config.cjs @@ -1,3 +1,6 @@ module.exports = { presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'], + "plugins": [ + "@babel/plugin-transform-nullish-coalescing-operator" // 处理 ?? 运算符 + ] }; diff --git a/packages/ranui-react/package.json b/packages/ranui-react/package.json index 484d35317..e519ed861 100644 --- a/packages/ranui-react/package.json +++ b/packages/ranui-react/package.json @@ -1,6 +1,6 @@ { "name": "@ranui/react", - "version": "0.1.5-alpha.4", + "version": "0.1.5-alpha.5", "description": "UI Component library based on `Web Component`", "main": "dist/umd/index.umd.cjs", "module": "dist/index.js", diff --git a/packages/ranui/babel.config.cjs b/packages/ranui/babel.config.cjs index e6ffbd417..842a84692 100644 --- a/packages/ranui/babel.config.cjs +++ b/packages/ranui/babel.config.cjs @@ -1,3 +1,6 @@ module.exports = { presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'], + "plugins": [ + "@babel/plugin-transform-nullish-coalescing-operator" + ] }; diff --git a/packages/ranui/package.json b/packages/ranui/package.json index 4109a9c3e..241a99a54 100644 --- a/packages/ranui/package.json +++ b/packages/ranui/package.json @@ -1,6 +1,6 @@ { "name": "ranui", - "version": "0.1.10-alpha.16", + "version": "0.1.10-alpha.17", "description": "UI Component library based on `Web Component`", "main": "dist/umd/index.umd.cjs", "module": "dist/index.js", @@ -177,9 +177,11 @@ }, "devDependencies": { "@babel/core": "^7.24.5", + "@babel/plugin-transform-nullish-coalescing-operator": "^7.24.7", "@babel/preset-env": "^7.24.5", "@babel/preset-typescript": "^7.24.1", "@playwright/test": "^1.44.0", + "@rollup/plugin-babel": "^6.0.4", "@types/imagemin-svgo": "^10.0.5", "@types/lodash": "^4.17.1", "@types/react": "^18.3.1", diff --git a/packages/ranui/typings.d.ts b/packages/ranui/typings.d.ts index e1a6b2bca..7a1029800 100644 --- a/packages/ranui/typings.d.ts +++ b/packages/ranui/typings.d.ts @@ -9,7 +9,7 @@ declare module '@/public/*'; declare module '@/components/*'; declare module '@/plugins/*'; -export declare namespace Ran { +declare namespace Ran { interface Prompt { content: string; duration?: number; @@ -26,11 +26,11 @@ export declare namespace Ran { } } -export interface Ranui { +interface Ranui { message: Partial; } -export interface HlsPlayer { +interface HlsPlayer { off: (s: string, f: Function) => void; on: (s: string, f: Function) => void; loadSource: (s: string) => void; @@ -39,7 +39,7 @@ export interface HlsPlayer { startLoad(): () => void; } -export interface Hls { +interface Hls { Events: { MANIFEST_LOADED: 'hlsManifestLoaded'; ERROR: 'error'; @@ -47,51 +47,51 @@ export interface Hls { isSupported: () => boolean; } -export type HLS = Hls & (new () => HlsPlayer); +type HLS = Hls & (new () => HlsPlayer); -export interface Viewport { +interface Viewport { width: number; height: number; viewBox: Array; } -export interface RenderContext { +interface RenderContext { canvasContext: CanvasRenderingContext2D | null; transform: Array; viewport: Viewport; } -export interface PDFPageProxy { +interface PDFPageProxy { pageNumber: number; getViewport: () => Viewport; render: (options: RenderContext) => void; } -export interface PDFDocumentProxy { +interface PDFDocumentProxy { numPages: number; getPage: (x: number) => Promise; } -export interface HTMLElement { +interface HTMLElement { mozRequestFullScreen: (options?: FullscreenOptions) => Promise; msRequestFullscreen: (options?: FullscreenOptions) => Promise; oRequestFullscreen: (options?: FullscreenOptions) => Promise; webkitRequestFullscreen: (options?: FullscreenOptions) => Promise; webkitEnterFullscreen: (options?: FullscreenOptions) => Promise; } -export declare interface Document { +declare interface Document { msExitFullscreen: () => Promise; mozCancelFullScreen: () => Promise; oCancelFullScreen: () => Promise; webkitExitFullscreen: () => Promise; } -export interface MathJax { +interface MathJax { texReset: () => void; getMetricsFor: (x: HTMLElement) => object; tex2chtmlPromise: (x: string, y: object) => Promise; } -export declare interface Window { +declare interface Window { ranui: Partial; message: Partial; MathJax: MathJax; @@ -109,7 +109,7 @@ export declare interface Window { Hls: HLS; } -export namespace JSX { +namespace JSX { interface IntrinsicElements { 'r-loading': any & { name: NAME_AMP; diff --git a/packages/ranui/vite.config.ts b/packages/ranui/vite.config.ts index 9ed647e84..ddb38ca7e 100644 --- a/packages/ranui/vite.config.ts +++ b/packages/ranui/vite.config.ts @@ -6,6 +6,7 @@ import { visualizer } from 'rollup-plugin-visualizer'; import viteImagemin from '@vheemstra/vite-plugin-imagemin'; import imageminSvgo from 'imagemin-svgo'; import type { RollupOptions } from 'rollup'; +import { babel } from '@rollup/plugin-babel'; import loadStyle from './plugins/load-style'; import loadSvg from './plugins/load-svg'; import { PORT } from './build/config'; @@ -115,6 +116,7 @@ export const viteConfig: UserConfig = { svg: imageminSvgo(), }, }), + babel() ], resolve: { alias: { From d9f2070097faa7c50cd3e04ffe4d0bc831f7029e Mon Sep 17 00:00:00 2001 From: ranzhouhang Date: Tue, 6 Aug 2024 13:53:01 +0800 Subject: [PATCH 3/4] feat: update version --- .../ranui-react/components/message/index.ts | 3 -- packages/ranui/package.json | 2 +- packages/ranui/typings.d.ts | 34 ++++++++++--------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/packages/ranui-react/components/message/index.ts b/packages/ranui-react/components/message/index.ts index be1b7a353..63f734ff9 100644 --- a/packages/ranui-react/components/message/index.ts +++ b/packages/ranui-react/components/message/index.ts @@ -1,8 +1,5 @@ import 'ranui/message'; import 'ranui/style'; -import type { Window } from 'ranui/dist/index.d.ts'; - -declare const window: Window; const message = window.message; diff --git a/packages/ranui/package.json b/packages/ranui/package.json index 241a99a54..c08c6622d 100644 --- a/packages/ranui/package.json +++ b/packages/ranui/package.json @@ -1,6 +1,6 @@ { "name": "ranui", - "version": "0.1.10-alpha.17", + "version": "0.1.10-alpha.18", "description": "UI Component library based on `Web Component`", "main": "dist/umd/index.umd.cjs", "module": "dist/index.js", diff --git a/packages/ranui/typings.d.ts b/packages/ranui/typings.d.ts index 7a1029800..22b0287d3 100644 --- a/packages/ranui/typings.d.ts +++ b/packages/ranui/typings.d.ts @@ -91,22 +91,24 @@ interface MathJax { tex2chtmlPromise: (x: string, y: object) => Promise; } -declare interface Window { - ranui: Partial; - message: Partial; - MathJax: MathJax; - katex: { - render: (x: string, y: HTMLElement, z: object) => void; - }; - pdfjsLib: { - GlobalWorkerOptions: { - workerSrc: string; - }; - getDocument: (x: string | ArrayBuffer) => { - promise: Promise; - }; - }; - Hls: HLS; +declare global { + interface Window { + ranui: Partial; + message: Partial; + MathJax: MathJax; + katex: { + render: (x: string, y: HTMLElement, z: object) => void; + }; + pdfjsLib: { + GlobalWorkerOptions: { + workerSrc: string; + }; + getDocument: (x: string | ArrayBuffer) => { + promise: Promise; + }; + }; + Hls: HLS; + } } namespace JSX { From bc2c3fd88b7511aca30fb0b1a1f4438bf6f0bc53 Mon Sep 17 00:00:00 2001 From: ranzhouhang Date: Tue, 6 Aug 2024 23:38:45 +0800 Subject: [PATCH 4/4] feat: add type readme --- packages/ranui/README.zh-CN.md | 14 ++++++++------ packages/ranui/readme.md | 8 ++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/ranui/README.zh-CN.md b/packages/ranui/README.zh-CN.md index 8ac694b93..15fd87e67 100644 --- a/packages/ranui/README.zh-CN.md +++ b/packages/ranui/README.zh-CN.md @@ -50,15 +50,17 @@ import 'ranui/style'; 如果遇到类型问题,可以选择手动导入类型文件 ```ts -import 'ranui/types'; -``` - -或者 - -```ts +import 'ranui/typings'; +// 或者 +import 'ranui/dist/index.d.ts'; +// 或者 +import 'ranui/type'; +// 或者 import 'ranui/dist/typings'; ``` +并不是都要,选一个能生效的就行 + 也支持全量导入 ```ts diff --git a/packages/ranui/readme.md b/packages/ranui/readme.md index e962a9908..99795e30f 100644 --- a/packages/ranui/readme.md +++ b/packages/ranui/readme.md @@ -51,9 +51,17 @@ import 'ranui/style'; If there is a `type` problem, you can manually import the type ```ts +import 'ranui/typings'; +// or import 'ranui/dist/index.d.ts'; +// or +import 'ranui/type'; +// or +import 'ranui/dist/typings'; ``` +Not all of them. Just pick one that works + Support global import ```ts