Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/version #277

Merged
merged 4 commits into from
Aug 6, 2024
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
2 changes: 1 addition & 1 deletion packages/docs/variable/SERVICE_WORK_VERSION.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const SERVICE_WORK_VERSION = '1721560332';
export const SERVICE_WORK_VERSION = "1722909342"
3 changes: 3 additions & 0 deletions packages/ranui-react/babel.config.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module.exports = {
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'],
"plugins": [
"@babel/plugin-transform-nullish-coalescing-operator" // 处理 ?? 运算符
]
};
3 changes: 0 additions & 3 deletions packages/ranui-react/components/message/index.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion packages/ranui-react/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
14 changes: 8 additions & 6 deletions packages/ranui/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions packages/ranui/babel.config.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module.exports = {
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'],
"plugins": [
"@babel/plugin-transform-nullish-coalescing-operator"
]
};
4 changes: 3 additions & 1 deletion packages/ranui/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions packages/ranui/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
60 changes: 31 additions & 29 deletions packages/ranui/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,11 +26,11 @@ export declare namespace Ran {
}
}

export interface Ranui {
interface Ranui {
message: Partial<Ran.Message>;
}

export interface HlsPlayer {
interface HlsPlayer {
off: (s: string, f: Function) => void;
on: (s: string, f: Function) => void;
loadSource: (s: string) => void;
Expand All @@ -39,77 +39,79 @@ export interface HlsPlayer {
startLoad(): () => void;
}

export interface Hls {
interface Hls {
Events: {
MANIFEST_LOADED: 'hlsManifestLoaded';
ERROR: 'error';
};
isSupported: () => boolean;
}

export type HLS = Hls & (new () => HlsPlayer);
type HLS = Hls & (new () => HlsPlayer);

export interface Viewport {
interface Viewport {
width: number;
height: number;
viewBox: Array<number>;
}
export interface RenderContext {
interface RenderContext {
canvasContext: CanvasRenderingContext2D | null;
transform: Array<number>;
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<PDFPageProxy>;
}

export interface HTMLElement {
interface HTMLElement {
mozRequestFullScreen: (options?: FullscreenOptions) => Promise<void>;
msRequestFullscreen: (options?: FullscreenOptions) => Promise<void>;
oRequestFullscreen: (options?: FullscreenOptions) => Promise<void>;
webkitRequestFullscreen: (options?: FullscreenOptions) => Promise<void>;
webkitEnterFullscreen: (options?: FullscreenOptions) => Promise<void>;
}
export declare interface Document {
declare interface Document {
msExitFullscreen: () => Promise<void>;
mozCancelFullScreen: () => Promise<void>;
oCancelFullScreen: () => Promise<void>;
webkitExitFullscreen: () => Promise<void>;
}

export interface MathJax {
interface MathJax {
texReset: () => void;
getMetricsFor: (x: HTMLElement) => object;
tex2chtmlPromise: (x: string, y: object) => Promise<Element>;
}

export declare interface Window {
ranui: Partial<Ranui>;
message: Partial<Ran.Message>;
MathJax: MathJax;
katex: {
render: (x: string, y: HTMLElement, z: object) => void;
};
pdfjsLib: {
GlobalWorkerOptions: {
workerSrc: string;
};
getDocument: (x: string | ArrayBuffer) => {
promise: Promise<PDFDocumentProxy>;
};
};
Hls: HLS;
declare global {
interface Window {
ranui: Partial<Ranui>;
message: Partial<Ran.Message>;
MathJax: MathJax;
katex: {
render: (x: string, y: HTMLElement, z: object) => void;
};
pdfjsLib: {
GlobalWorkerOptions: {
workerSrc: string;
};
getDocument: (x: string | ArrayBuffer) => {
promise: Promise<PDFDocumentProxy>;
};
};
Hls: HLS;
}
}

export namespace JSX {
namespace JSX {
interface IntrinsicElements {
'r-loading': any & {
name: NAME_AMP;
Expand Down
2 changes: 2 additions & 0 deletions packages/ranui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -115,6 +116,7 @@ export const viteConfig: UserConfig = {
svg: imageminSvgo(),
},
}),
babel()
],
resolve: {
alias: {
Expand Down
Loading