diff --git a/packages/docs/variable/SERVICE_WORK_VERSION.ts b/packages/docs/variable/SERVICE_WORK_VERSION.ts index aa8751358f..2ac7f60ffc 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/babel.config.cjs b/packages/ranui-react/babel.config.cjs index e6ffbd417e..08249c74c7 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/components/message/index.ts b/packages/ranui-react/components/message/index.ts index be1b7a3530..63f734ff99 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-react/package.json b/packages/ranui-react/package.json index 91aba1d0cc..e519ed8612 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.5", "description": "UI Component library based on `Web Component`", "main": "dist/umd/index.umd.cjs", "module": "dist/index.js", diff --git a/packages/ranui/README.zh-CN.md b/packages/ranui/README.zh-CN.md index 8ac694b93a..15fd87e676 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/babel.config.cjs b/packages/ranui/babel.config.cjs index e6ffbd417e..842a84692b 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 26312222f3..c08c6622d2 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.18", "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/readme.md b/packages/ranui/readme.md index e962a99086..99795e30ff 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 diff --git a/packages/ranui/typings.d.ts b/packages/ranui/typings.d.ts index e1a6b2bca2..22b0287d35 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,69 +47,71 @@ 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 { - 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; + } } -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 9ed647e84a..ddb38ca7e3 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: {