fix: CJS 产物改 .cjs 扩展名并提升 default 导出 — 修复 require() 兼容性

- 包声明 type:module 时 .js 产物被 Node 按 ESM 解析:Node 16/18 下 require 报 ERR_REQUIRE_ESM,Node 20+ 拿到 namespace 对象(success/version 等属性 undefined)
- dist/metona-toast.cjs.js → .cjs,dist/react.cjs.js → .cjs
- 主包 CJS footer 将 default 提升为 module.exports:require() 直接返回 MeToast(兼容 .default / .MeToast / .Met / .Toast / .VERSION 所有用法)
- 版本 0.5.1(0.5.0 已发布带问题产物)
- 真实消费者验证:CJS/ESM/React 子包四路加载全部正常
This commit is contained in:
tianhao
2026-08-08 15:25:47 +08:00
parent dd061025e0
commit 95f5652e9c
36 changed files with 116 additions and 113 deletions
+15 -14
View File
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
/**
* MetonaToast Utils 工具函数
* @module utils
* @version 0.5.0
* @version 0.5.1
*/
/**
* 生成唯一ID
@@ -42,7 +42,7 @@ const prefersDark = () => {
/**
* MetonaToast Icons 图标SVG定义
* @module icons
* @version 0.5.0
* @version 0.5.1
* @description 107 个内置 SVG 图标
*/
const ICONS = {
@@ -539,7 +539,7 @@ const ICONS = {
/**
* MetonaToast Locales 国际化翻译数据
* @module locales
* @version 0.5.0
* @version 0.5.1
* @description 内置 zh-CN / en-US 完整翻译
*/
const LOCALES = {
@@ -1026,12 +1026,12 @@ const LOCALES = {
/**
* MetonaToast Constants 常量定义
* @module constants
* @version 0.5.0
* @version 0.5.1
*/
/**
* 版本号 唯一来源发布时只需修改此处
*/
const VERSION = '0.5.0';
const VERSION = '0.5.1';
/**
* 默认配置
*/
@@ -1298,7 +1298,7 @@ const ANIMATION_TYPES = ['slide', 'fade', 'scale', 'bounce', 'flip', 'rotate', '
/**
* MetonaToast Styles 样式管理
* @module styles
* @version 0.5.0
* @version 0.5.1
*/
// 样式缓存
let styleElement = null;
@@ -1787,7 +1787,7 @@ const injectStyles = () => {
/**
* MetonaToast Themes 主题管理
* @module themes
* @version 0.5.0
* @version 0.5.1
*/
// 当前主题状态
let currentTheme = 'auto';
@@ -2131,7 +2131,7 @@ const themeUtils = {
/**
* MetonaToast i18n 国际化管理
* @module i18n
* @version 0.5.0
* @version 0.5.1
*/
// 当前语言状态
let currentLocale = 'zh-CN';
@@ -2806,7 +2806,7 @@ const animationUtils = {
/**
* MetonaToast Toast Toast
* @module toast
* @version 0.5.0
* @version 0.5.1
*/
/**
* Toast 核心通知组件
@@ -3445,7 +3445,7 @@ const _containerCache = new Map();
/**
* MetonaToast Templates HTML 模板辅助函数
* @module templates
* @version 0.5.0
* @version 0.5.1
* @description confirm / prompt / progress / action DOM 模板
*/
/**
@@ -3517,7 +3517,7 @@ const actionHTML = (actions) => {
/**
* MetonaToast Plugins 插件系统
* @module plugins
* @version 0.5.0
* @version 0.5.1
*/
/**
* 插件管理器
@@ -3777,7 +3777,7 @@ const defaultPluginManager = new PluginManager();
/**
* MetonaToast API meToast 核心 API 对象
* @module api
* @version 0.5.0
* @version 0.5.1
*/
/**
* 参数标准化工具
@@ -4463,7 +4463,7 @@ Toast.setCallbacks({
/**
* MetonaToast 轻量级Toast通知库
* @module metona-toast
* @version 0.5.0
* @version 0.5.1
* @author thzxx
* @license MIT
*/
@@ -4532,4 +4532,5 @@ exports.Toast = Toast;
exports.VERSION = VERSION;
exports.default = enhancedMeToast;
exports.meToast = enhancedMeToast;
//# sourceMappingURL=metona-toast.cjs.js.map
module.exports = Object.assign(exports.default, exports);
//# sourceMappingURL=metona-toast.cjs.map
-1
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+4 -4
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast — 核心类型定义
* @module types
* @version 0.5.0
* @version 0.5.1
*/
/** Toast 通知类型(107种内置图标类型) */
type ToastType = 'default' | 'success' | 'error' | 'warning' | 'info' | 'loading' | 'check' | 'x' | 'alert' | 'question' | 'star' | 'heart' | 'bell' | 'mail' | 'settings' | 'user' | 'home' | 'search' | 'plus' | 'minus' | 'edit' | 'trash' | 'download' | 'upload' | 'share' | 'link' | 'external' | 'clock' | 'calendar' | 'map' | 'compass' | 'globe' | 'wifi' | 'cloud' | 'sun' | 'moon' | 'zap' | 'activity' | 'cpu' | 'database' | 'server' | 'terminal' | 'code' | 'git' | 'package' | 'layers' | 'grid' | 'list' | 'filter' | 'sort' | 'refresh' | 'sync' | 'power' | 'battery' | 'bluetooth' | 'volume' | 'mic' | 'camera' | 'image' | 'video' | 'music' | 'file' | 'folder' | 'clipboard' | 'save' | 'print' | 'eye' | 'eyeOff' | 'lock' | 'unlock' | 'shield' | 'key' | 'flag' | 'bookmark' | 'tag' | 'gift' | 'award' | 'target' | 'crosshair' | 'move' | 'maximize' | 'minimize' | 'copy' | 'cut' | 'paste' | 'rotateCw' | 'rotateCcw' | 'zoomIn' | 'zoomOut' | 'crop' | 'sliders' | 'toggleLeft' | 'toggleRight' | 'checkCircle' | 'xCircle' | 'alertCircle' | 'infoCircle' | 'helpCircle' | 'alertTriangle' | 'checkSquare' | 'square' | 'circle' | 'triangle' | 'hexagon' | 'octagon' | 'pentagon' | 'diamond';
@@ -418,7 +418,7 @@ declare global {
/**
* MetonaToast Toast — Toast 类
* @module toast
* @version 0.5.0
* @version 0.5.1
*/
/**
@@ -492,13 +492,13 @@ declare class Toast implements ToastInstance {
/**
* MetonaToast Constants — 常量定义
* @module constants
* @version 0.5.0
* @version 0.5.1
*/
/**
* 版本号 — 唯一来源,发布时只需修改此处
*/
declare const VERSION = "0.5.0";
declare const VERSION = "0.5.1";
/**
* 增强的 MeToast 对象 — 在 meToast 基础上注入子模块
+13 -13
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast Utils — 工具函数
* @module utils
* @version 0.5.0
* @version 0.5.1
*/
/**
* 生成唯一ID
@@ -38,7 +38,7 @@ const prefersDark = () => {
/**
* MetonaToast Icons — 图标SVG定义
* @module icons
* @version 0.5.0
* @version 0.5.1
* @description 107 个内置 SVG 图标
*/
const ICONS = {
@@ -535,7 +535,7 @@ const ICONS = {
/**
* MetonaToast Locales — 国际化翻译数据
* @module locales
* @version 0.5.0
* @version 0.5.1
* @description 内置 zh-CN / en-US 完整翻译
*/
const LOCALES = {
@@ -1022,12 +1022,12 @@ const LOCALES = {
/**
* MetonaToast Constants — 常量定义
* @module constants
* @version 0.5.0
* @version 0.5.1
*/
/**
* 版本号 — 唯一来源,发布时只需修改此处
*/
const VERSION = '0.5.0';
const VERSION = '0.5.1';
/**
* 默认配置
*/
@@ -1294,7 +1294,7 @@ const ANIMATION_TYPES = ['slide', 'fade', 'scale', 'bounce', 'flip', 'rotate', '
/**
* MetonaToast Styles — 样式管理
* @module styles
* @version 0.5.0
* @version 0.5.1
*/
// 样式缓存
let styleElement = null;
@@ -1783,7 +1783,7 @@ const injectStyles = () => {
/**
* MetonaToast Themes — 主题管理
* @module themes
* @version 0.5.0
* @version 0.5.1
*/
// 当前主题状态
let currentTheme = 'auto';
@@ -2127,7 +2127,7 @@ const themeUtils = {
/**
* MetonaToast i18n — 国际化管理
* @module i18n
* @version 0.5.0
* @version 0.5.1
*/
// 当前语言状态
let currentLocale = 'zh-CN';
@@ -2802,7 +2802,7 @@ const animationUtils = {
/**
* MetonaToast Toast — Toast 类
* @module toast
* @version 0.5.0
* @version 0.5.1
*/
/**
* Toast 类 — 核心通知组件
@@ -3441,7 +3441,7 @@ const _containerCache = new Map();
/**
* MetonaToast Templates — HTML 模板辅助函数
* @module templates
* @version 0.5.0
* @version 0.5.1
* @description confirm / prompt / progress / action 的 DOM 模板
*/
/**
@@ -3513,7 +3513,7 @@ const actionHTML = (actions) => {
/**
* MetonaToast Plugins — 插件系统
* @module plugins
* @version 0.5.0
* @version 0.5.1
*/
/**
* 插件管理器
@@ -3773,7 +3773,7 @@ const defaultPluginManager = new PluginManager();
/**
* MetonaToast API — meToast 核心 API 对象
* @module api
* @version 0.5.0
* @version 0.5.1
*/
/**
* 参数标准化工具
@@ -4459,7 +4459,7 @@ Toast.setCallbacks({
/**
* MetonaToast — 轻量级Toast通知库
* @module metona-toast
* @version 0.5.0
* @version 0.5.1
* @author thzxx
* @license MIT
*/
+13 -13
View File
@@ -7,7 +7,7 @@
/**
* MetonaToast Utils — 工具函数
* @module utils
* @version 0.5.0
* @version 0.5.1
*/
/**
* 生成唯一ID
@@ -44,7 +44,7 @@
/**
* MetonaToast Icons — 图标SVG定义
* @module icons
* @version 0.5.0
* @version 0.5.1
* @description 107 个内置 SVG 图标
*/
const ICONS = {
@@ -541,7 +541,7 @@
/**
* MetonaToast Locales — 国际化翻译数据
* @module locales
* @version 0.5.0
* @version 0.5.1
* @description 内置 zh-CN / en-US 完整翻译
*/
const LOCALES = {
@@ -1028,12 +1028,12 @@
/**
* MetonaToast Constants — 常量定义
* @module constants
* @version 0.5.0
* @version 0.5.1
*/
/**
* 版本号 — 唯一来源,发布时只需修改此处
*/
const VERSION = '0.5.0';
const VERSION = '0.5.1';
/**
* 默认配置
*/
@@ -1300,7 +1300,7 @@
/**
* MetonaToast Styles — 样式管理
* @module styles
* @version 0.5.0
* @version 0.5.1
*/
// 样式缓存
let styleElement = null;
@@ -1789,7 +1789,7 @@
/**
* MetonaToast Themes — 主题管理
* @module themes
* @version 0.5.0
* @version 0.5.1
*/
// 当前主题状态
let currentTheme = 'auto';
@@ -2133,7 +2133,7 @@
/**
* MetonaToast i18n — 国际化管理
* @module i18n
* @version 0.5.0
* @version 0.5.1
*/
// 当前语言状态
let currentLocale = 'zh-CN';
@@ -2808,7 +2808,7 @@
/**
* MetonaToast Toast — Toast 类
* @module toast
* @version 0.5.0
* @version 0.5.1
*/
/**
* Toast 类 — 核心通知组件
@@ -3447,7 +3447,7 @@
/**
* MetonaToast Templates — HTML 模板辅助函数
* @module templates
* @version 0.5.0
* @version 0.5.1
* @description confirm / prompt / progress / action 的 DOM 模板
*/
/**
@@ -3519,7 +3519,7 @@
/**
* MetonaToast Plugins — 插件系统
* @module plugins
* @version 0.5.0
* @version 0.5.1
*/
/**
* 插件管理器
@@ -3779,7 +3779,7 @@
/**
* MetonaToast API — meToast 核心 API 对象
* @module api
* @version 0.5.0
* @version 0.5.1
*/
/**
* 参数标准化工具
@@ -4465,7 +4465,7 @@
/**
* MetonaToast — 轻量级Toast通知库
* @module metona-toast
* @version 0.5.0
* @version 0.5.1
* @author thzxx
* @license MIT
*/
+1 -1
View File
File diff suppressed because one or more lines are too long
+15 -15
View File
@@ -5,7 +5,7 @@ var react = require('react');
/**
* MetonaToast Utils 工具函数
* @module utils
* @version 0.5.0
* @version 0.5.1
*/
/**
* 生成唯一ID
@@ -42,7 +42,7 @@ const prefersDark = () => {
/**
* MetonaToast Icons 图标SVG定义
* @module icons
* @version 0.5.0
* @version 0.5.1
* @description 107 个内置 SVG 图标
*/
const ICONS = {
@@ -539,7 +539,7 @@ const ICONS = {
/**
* MetonaToast Locales 国际化翻译数据
* @module locales
* @version 0.5.0
* @version 0.5.1
* @description 内置 zh-CN / en-US 完整翻译
*/
const LOCALES = {
@@ -1026,12 +1026,12 @@ const LOCALES = {
/**
* MetonaToast Constants 常量定义
* @module constants
* @version 0.5.0
* @version 0.5.1
*/
/**
* 版本号 唯一来源发布时只需修改此处
*/
const VERSION = '0.5.0';
const VERSION = '0.5.1';
/**
* 默认配置
*/
@@ -1298,7 +1298,7 @@ const ANIMATION_TYPES = ['slide', 'fade', 'scale', 'bounce', 'flip', 'rotate', '
/**
* MetonaToast Styles 样式管理
* @module styles
* @version 0.5.0
* @version 0.5.1
*/
// 样式缓存
let styleElement = null;
@@ -1787,7 +1787,7 @@ const injectStyles = () => {
/**
* MetonaToast Themes 主题管理
* @module themes
* @version 0.5.0
* @version 0.5.1
*/
// 当前主题状态
let currentTheme = 'auto';
@@ -2131,7 +2131,7 @@ const themeUtils = {
/**
* MetonaToast i18n 国际化管理
* @module i18n
* @version 0.5.0
* @version 0.5.1
*/
// 当前语言状态
let currentLocale = 'zh-CN';
@@ -2806,7 +2806,7 @@ const animationUtils = {
/**
* MetonaToast Toast Toast
* @module toast
* @version 0.5.0
* @version 0.5.1
*/
/**
* Toast 核心通知组件
@@ -3445,7 +3445,7 @@ const _containerCache = new Map();
/**
* MetonaToast Templates HTML 模板辅助函数
* @module templates
* @version 0.5.0
* @version 0.5.1
* @description confirm / prompt / progress / action DOM 模板
*/
/**
@@ -3517,7 +3517,7 @@ const actionHTML = (actions) => {
/**
* MetonaToast Plugins 插件系统
* @module plugins
* @version 0.5.0
* @version 0.5.1
*/
/**
* 插件管理器
@@ -3777,7 +3777,7 @@ const defaultPluginManager = new PluginManager();
/**
* MetonaToast API meToast 核心 API 对象
* @module api
* @version 0.5.0
* @version 0.5.1
*/
/**
* 参数标准化工具
@@ -4463,7 +4463,7 @@ Toast$1.setCallbacks({
/**
* MetonaToast 轻量级Toast通知库
* @module metona-toast
* @version 0.5.0
* @version 0.5.1
* @author thzxx
* @license MIT
*/
@@ -4529,7 +4529,7 @@ if (typeof window !== 'undefined') {
/**
* MetonaToast React React 适配器
* @module react
* @version 0.5.0
* @version 0.5.1
* @description useToast hook + 声明式 <Toast /> 组件主包保持零依赖React optional peerDependency
*/
const SHOW_METHODS = ['success', 'error', 'warning', 'info', 'show'];
@@ -4614,4 +4614,4 @@ exports.MeToast = enhancedMeToast;
exports.Toast = Toast;
exports.createBoundApi = createBoundApi;
exports.useToast = useToast;
//# sourceMappingURL=react.cjs.js.map
//# sourceMappingURL=react.cjs.map
-1
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast — 核心类型定义
* @module types
* @version 0.5.0
* @version 0.5.1
*/
/** Toast 通知类型(107种内置图标类型) */
type ToastType = 'default' | 'success' | 'error' | 'warning' | 'info' | 'loading' | 'check' | 'x' | 'alert' | 'question' | 'star' | 'heart' | 'bell' | 'mail' | 'settings' | 'user' | 'home' | 'search' | 'plus' | 'minus' | 'edit' | 'trash' | 'download' | 'upload' | 'share' | 'link' | 'external' | 'clock' | 'calendar' | 'map' | 'compass' | 'globe' | 'wifi' | 'cloud' | 'sun' | 'moon' | 'zap' | 'activity' | 'cpu' | 'database' | 'server' | 'terminal' | 'code' | 'git' | 'package' | 'layers' | 'grid' | 'list' | 'filter' | 'sort' | 'refresh' | 'sync' | 'power' | 'battery' | 'bluetooth' | 'volume' | 'mic' | 'camera' | 'image' | 'video' | 'music' | 'file' | 'folder' | 'clipboard' | 'save' | 'print' | 'eye' | 'eyeOff' | 'lock' | 'unlock' | 'shield' | 'key' | 'flag' | 'bookmark' | 'tag' | 'gift' | 'award' | 'target' | 'crosshair' | 'move' | 'maximize' | 'minimize' | 'copy' | 'cut' | 'paste' | 'rotateCw' | 'rotateCcw' | 'zoomIn' | 'zoomOut' | 'crop' | 'sliders' | 'toggleLeft' | 'toggleRight' | 'checkCircle' | 'xCircle' | 'alertCircle' | 'infoCircle' | 'helpCircle' | 'alertTriangle' | 'checkSquare' | 'square' | 'circle' | 'triangle' | 'hexagon' | 'octagon' | 'pentagon' | 'diamond';
@@ -478,7 +478,7 @@ declare const enhancedMeToast: {
/**
* MetonaToast React — React 适配器
* @module react
* @version 0.5.0
* @version 0.5.1
* @description useToast hook + 声明式 <Toast /> 组件。主包保持零依赖,React 为 optional peerDependency
*/
+14 -14
View File
@@ -3,7 +3,7 @@ import { useRef, useEffect, useMemo } from 'react';
/**
* MetonaToast Utils 工具函数
* @module utils
* @version 0.5.0
* @version 0.5.1
*/
/**
* 生成唯一ID
@@ -40,7 +40,7 @@ const prefersDark = () => {
/**
* MetonaToast Icons 图标SVG定义
* @module icons
* @version 0.5.0
* @version 0.5.1
* @description 107 个内置 SVG 图标
*/
const ICONS = {
@@ -537,7 +537,7 @@ const ICONS = {
/**
* MetonaToast Locales 国际化翻译数据
* @module locales
* @version 0.5.0
* @version 0.5.1
* @description 内置 zh-CN / en-US 完整翻译
*/
const LOCALES = {
@@ -1024,12 +1024,12 @@ const LOCALES = {
/**
* MetonaToast Constants 常量定义
* @module constants
* @version 0.5.0
* @version 0.5.1
*/
/**
* 版本号 唯一来源发布时只需修改此处
*/
const VERSION = '0.5.0';
const VERSION = '0.5.1';
/**
* 默认配置
*/
@@ -1296,7 +1296,7 @@ const ANIMATION_TYPES = ['slide', 'fade', 'scale', 'bounce', 'flip', 'rotate', '
/**
* MetonaToast Styles 样式管理
* @module styles
* @version 0.5.0
* @version 0.5.1
*/
// 样式缓存
let styleElement = null;
@@ -1785,7 +1785,7 @@ const injectStyles = () => {
/**
* MetonaToast Themes 主题管理
* @module themes
* @version 0.5.0
* @version 0.5.1
*/
// 当前主题状态
let currentTheme = 'auto';
@@ -2129,7 +2129,7 @@ const themeUtils = {
/**
* MetonaToast i18n 国际化管理
* @module i18n
* @version 0.5.0
* @version 0.5.1
*/
// 当前语言状态
let currentLocale = 'zh-CN';
@@ -2804,7 +2804,7 @@ const animationUtils = {
/**
* MetonaToast Toast Toast
* @module toast
* @version 0.5.0
* @version 0.5.1
*/
/**
* Toast 核心通知组件
@@ -3443,7 +3443,7 @@ const _containerCache = new Map();
/**
* MetonaToast Templates HTML 模板辅助函数
* @module templates
* @version 0.5.0
* @version 0.5.1
* @description confirm / prompt / progress / action DOM 模板
*/
/**
@@ -3515,7 +3515,7 @@ const actionHTML = (actions) => {
/**
* MetonaToast Plugins 插件系统
* @module plugins
* @version 0.5.0
* @version 0.5.1
*/
/**
* 插件管理器
@@ -3775,7 +3775,7 @@ const defaultPluginManager = new PluginManager();
/**
* MetonaToast API meToast 核心 API 对象
* @module api
* @version 0.5.0
* @version 0.5.1
*/
/**
* 参数标准化工具
@@ -4461,7 +4461,7 @@ Toast$1.setCallbacks({
/**
* MetonaToast 轻量级Toast通知库
* @module metona-toast
* @version 0.5.0
* @version 0.5.1
* @author thzxx
* @license MIT
*/
@@ -4527,7 +4527,7 @@ if (typeof window !== 'undefined') {
/**
* MetonaToast React React 适配器
* @module react
* @version 0.5.0
* @version 0.5.1
* @description useToast hook + 声明式 <Toast /> 组件主包保持零依赖React optional peerDependency
*/
const SHOW_METHODS = ['success', 'error', 'warning', 'info', 'show'];
+4 -4
View File
@@ -1,9 +1,9 @@
{
"name": "@metona-team/metona-toast",
"version": "0.5.0",
"version": "0.5.1",
"description": "轻量、零依赖、精致美观的Toast通知库。TypeScript源码,开箱即用。",
"type": "module",
"main": "dist/metona-toast.cjs.js",
"main": "dist/metona-toast.cjs",
"module": "dist/metona-toast.esm.js",
"unpkg": "dist/metona-toast.min.js",
"jsdelivr": "dist/metona-toast.min.js",
@@ -11,12 +11,12 @@
"exports": {
".": {
"import": "./dist/metona-toast.esm.js",
"require": "./dist/metona-toast.cjs.js",
"require": "./dist/metona-toast.cjs",
"types": "./dist/metona-toast.d.ts"
},
"./react": {
"import": "./dist/react.js",
"require": "./dist/react.cjs.js",
"require": "./dist/react.cjs",
"types": "./dist/react.d.ts"
}
},
+5 -3
View File
@@ -59,14 +59,16 @@ export default [
},
plugins: basePlugins,
},
// CommonJS
// CommonJS.cjs 扩展名:包声明 type:module.js 会被 Node 按 ESM 解析)
// footer 将 default 提升为 module.exports,保证 require() 直接返回 MeToast
{
input: 'src/index.ts',
output: {
file: 'dist/metona-toast.cjs.js',
file: 'dist/metona-toast.cjs',
format: 'cjs',
exports: 'named',
sourcemap: true,
footer: 'module.exports = Object.assign(exports.default, exports);',
},
plugins: basePlugins,
},
@@ -115,7 +117,7 @@ export default [
sourcemap: true,
},
{
file: 'dist/react.cjs.js',
file: 'dist/react.cjs',
format: 'cjs',
exports: 'named',
sourcemap: true,
+1 -1
View File
@@ -336,7 +336,7 @@
</main>
<footer>
MetonaToast v0.5.0 · MIT ·
MetonaToast v0.5.1 · MIT ·
<a href="index.html">首页</a> ·
<a href="docs.html">文档</a> ·
<a href="https://git.metona.cn/MetonaTeam/MetonaToast">Gitea</a>
+1 -1
View File
@@ -146,7 +146,7 @@
<main class="main">
<h1>API 文档</h1>
<p class="h1-desc">MetonaToast v0.5.0 完整 API 参考。所有基础通知方法支持字符串与对象两种调用形式,均可传入任何<a href="#config">配置项</a>作为可选参数。</p>
<p class="h1-desc">MetonaToast v0.5.1 完整 API 参考。所有基础通知方法支持字符串与对象两种调用形式,均可传入任何<a href="#config">配置项</a>作为可选参数。</p>
<!-- ===== 基础通知 ===== -->
<h2 id="show">show(message, opts?)</h2>
+2 -2
View File
@@ -251,7 +251,7 @@
<div class="orb orb-1"></div>
<div class="orb orb-2"></div>
<div class="orb orb-3"></div>
<div class="hero-badge"><span class="dot"></span> v0.5.0 · 385 测试 · 覆盖率 96%</div>
<div class="hero-badge"><span class="dot"></span> v0.5.1 · 385 测试 · 覆盖率 96%</div>
<h1><span class="grad-text">MetonaToast</span></h1>
<p class="hero-sub">轻量 · 零依赖 · 精致美观的 Toast 通知库。TypeScript 严格模式,gzip 不到 10KB,一切开箱即用。</p>
<div class="hero-badges">
@@ -441,7 +441,7 @@ MeToast.<span class="fn">action</span>(<span class="s">'文件已删除'</span>,
</section>
<footer>
MetonaToast v0.5.0 · MIT License ·
MetonaToast v0.5.1 · MIT License ·
<a href="https://git.metona.cn/MetonaTeam/MetonaToast" target="_blank">Gitea</a> ·
<a href="docs.html">文档</a> ·
<a href="demo.html">演示</a>
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast API meToast API
* @module api
* @version 0.5.0
* @version 0.5.1
*/
import { Toast, _containerCache } from './toast.js';
+2 -2
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast Constants
* @module constants
* @version 0.5.0
* @version 0.5.1
*/
import { ICONS } from './icons.js';
@@ -12,7 +12,7 @@ export { ICONS, LOCALES };
/**
*
*/
export const VERSION = '0.5.0';
export const VERSION = '0.5.1';
/**
*
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast i18n
* @module i18n
* @version 0.5.0
* @version 0.5.1
*/
import { LOCALES } from './constants.js';
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast Icons SVG定义
* @module icons
* @version 0.5.0
* @version 0.5.1
* @description 107 SVG
*/
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast Toast通知库
* @module metona-toast
* @version 0.5.0
* @version 0.5.1
* @author thzxx
* @license MIT
*/
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast Locales
* @module locales
* @version 0.5.0
* @version 0.5.1
* @description zh-CN / en-US
*/
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast Plugins
* @module plugins
* @version 0.5.0
* @version 0.5.1
*/
import { t } from './i18n.js';
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast React React
* @module react
* @version 0.5.0
* @version 0.5.1
* @description useToast hook + <Toast /> React optional peerDependency
*/
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast Styles
* @module styles
* @version 0.5.0
* @version 0.5.1
*/
import type { ThemeConfig } from './types.js';
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast Templates HTML
* @module templates
* @version 0.5.0
* @version 0.5.1
* @description confirm / prompt / progress / action DOM
*/
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast Themes
* @module themes
* @version 0.5.0
* @version 0.5.1
*/
import { THEMES } from './constants.js';
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast Toast Toast
* @module toast
* @version 0.5.0
* @version 0.5.1
*/
import { generateId, escapeHTML } from './utils.js';
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast
* @module types
* @version 0.5.0
* @version 0.5.1
*/
// ========== 基础类型 ==========
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast Utils
* @module utils
* @version 0.5.0
* @version 0.5.1
*/
/**
+2 -2
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast 95%+
* @module tests
* @version 0.5.0
* @version 0.5.1
*/
import MeToast, { Toast, VERSION } from '../src/index';
@@ -809,7 +809,7 @@ describe('api.ts 覆盖率', () => {
test('getStatus 返回完整状态', () => {
const status = MeToast.getStatus();
expect(status.version).toBe('0.5.0');
expect(status.version).toBe('0.5.1');
expect(status.toasts).toBeGreaterThanOrEqual(0);
expect(status.theme).toBeDefined();
expect(status.locale).toBeDefined();
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast DOM jsdom DOM
* @module tests
* @version 0.5.0
* @version 0.5.1
*/
import MeToast, { Toast } from '../src/index';
+4 -4
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast
* @module tests
* @version 0.5.0
* @version 0.5.1
*/
import MeToast, { Toast, VERSION } from '../src/index';
@@ -105,8 +105,8 @@ const mockWindow = {
describe('版本信息', () => {
test('应该有正确的版本号', () => {
expect(VERSION).toBe('0.5.0');
expect(MeToast.version).toBe('0.5.0');
expect(VERSION).toBe('0.5.1');
expect(MeToast.version).toBe('0.5.1');
});
});
@@ -526,7 +526,7 @@ const mockWindow = {
test('应该能够获取状态信息', () => {
MeToast.success('消息');
const status = MeToast.getStatus();
expect(status.version).toBe('0.5.0');
expect(status.version).toBe('0.5.1');
expect(status.toasts).toBeGreaterThanOrEqual(0);
expect(status.theme).toBeDefined();
expect(status.locale).toBeDefined();
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* MetonaToast React
* @module tests
* @version 0.5.0
* @version 0.5.1
*/
import React from 'react';
+1 -1
View File
@@ -4,7 +4,7 @@
* require import
* jsdom getter document/window defineProperty
* @module tests
* @version 0.5.0
* @version 0.5.1
*/
/** 临时移除全局对象,返回恢复函数 */