py-test-component 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,37 @@
1
+ /*!
2
+ * Vue.js v2.7.16
3
+ * (c) 2014-2023 Evan You
4
+ * Released under the MIT License.
5
+ */
6
+
7
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
8
+
9
+ /**
10
+ * vue-custom-element v3.3.0
11
+ * (c) 2021 Karol Fabjańczuk
12
+ * @license MIT
13
+ */
14
+
15
+ /**
16
+ * @license
17
+ * Lodash <https://lodash.com/>
18
+ * Copyright JS Foundation and other contributors <https://js.foundation/>
19
+ * Released under MIT license <https://lodash.com/license>
20
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
21
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
22
+ */
23
+
24
+ /**
25
+ * Checks if an event is supported in the current execution environment.
26
+ *
27
+ * NOTE: This will not work correctly for non-generic events such as `change`,
28
+ * `reset`, `load`, `error`, and `select`.
29
+ *
30
+ * Borrows from Modernizr.
31
+ *
32
+ * @param {string} eventNameSuffix Event name, e.g. "click".
33
+ * @param {?boolean} capture Check if the capture phase is supported.
34
+ * @return {boolean} True if the event is supported.
35
+ * @internal
36
+ * @license Modernizr 3.0.0pre (Custom Build) | MIT
37
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "py-test-component",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Vue2 + ElementUI 组件库,支持 React 使用",
5
5
  "main": "dist/py-component.js",
6
6
  "module": "dist/py-component.esm.js",
@@ -22,13 +22,14 @@ let isLoaded = false;
22
22
 
23
23
  /**
24
24
  * 加载组件库核心逻辑
25
- * 使用 ESM 动态导入,由构建工具处理路径解析
25
+ * 动态加载 UMD 构建产物,避免循环依赖
26
26
  */
27
27
  async function doLoad() {
28
28
  if (typeof window === 'undefined') return null;
29
29
  if (window.PyComponent) return window.PyComponent;
30
30
 
31
- const module = await import('py-test-component');
31
+ // 使用相对路径加载构建产物,支持 Webpack/Vite 等构建工具解析
32
+ const module = await import('../../dist/py-component.esm.js');
32
33
  const PyComponent = module.default || module;
33
34
 
34
35
  if (PyComponent && typeof window !== 'undefined') {
@@ -94,7 +95,7 @@ export const PyTable = forwardRef(function PyTable({ data, loading: propsLoading
94
95
 
95
96
  useEffect(() => {
96
97
  if (elRef.current && data && loaded) {
97
- // 直接设置 property,比 setAttribute 更可靠
98
+ // 直接设置 property,避免 JSON 序列化/反序列化开销
98
99
  elRef.current.tableData = data;
99
100
  }
100
101
  }, [data, loaded]);
package/index.d.ts DELETED
@@ -1,80 +0,0 @@
1
- // ============================================
2
- // py-test-component - TypeScript 类型定义
3
- // ============================================
4
-
5
- declare module 'py-test-component' {
6
- export interface PyComponentStore {
7
- set(config: Record<string, any>): void;
8
- get(key?: string): any;
9
- }
10
-
11
- export const store: PyComponentStore;
12
- export function init(config?: Record<string, any>): void;
13
-
14
- const _default: {
15
- init: typeof init;
16
- store: PyComponentStore;
17
- };
18
- export default _default;
19
- }
20
-
21
- declare module 'py-test-component/vue' {
22
- import { Component } from 'vue';
23
-
24
- /** 表格组件 - Vue 版本 */
25
- export const PyTable: Component;
26
- /** 天气组件 - Vue 版本 */
27
- export const PyWeather: Component;
28
-
29
- const _default: {
30
- PyTable: typeof PyTable;
31
- PyWeather: typeof PyWeather;
32
- };
33
- export default _default;
34
- }
35
-
36
- declare module 'py-test-component/react' {
37
- import { ReactNode, Ref, ForwardRefExoticComponent, RefAttributes } from 'react';
38
-
39
- export interface PyTableProps {
40
- /** 表格数据 */
41
- data?: Record<string, any>[];
42
- /** 加载中的占位内容 */
43
- loading?: ReactNode;
44
- /** 其他 HTML 属性 */
45
- [key: string]: any;
46
- }
47
-
48
- export interface PyWeatherProps {
49
- /** 城市名称 */
50
- city?: string;
51
- /** 加载中的占位内容 */
52
- loading?: ReactNode;
53
- /** 其他 HTML 属性 */
54
- [key: string]: any;
55
- }
56
-
57
- export interface PyComponentRef {
58
- /** 获取 DOM 元素 */
59
- getElement: () => HTMLElement | null;
60
- /** 是否已加载完成 */
61
- loaded: boolean;
62
- /** 加载错误信息 */
63
- error: Error | null;
64
- }
65
-
66
- /** 表格组件 - React 版本 */
67
- export const PyTable: ForwardRefExoticComponent<PyTableProps & RefAttributes<PyComponentRef>>;
68
-
69
- /** 天气组件 - React 版本 */
70
- export const PyWeather: ForwardRefExoticComponent<PyWeatherProps & RefAttributes<PyComponentRef>>;
71
-
72
- /** 初始化组件库 */
73
- export function initPyComponent(config?: Record<string, any>): Promise<any>;
74
-
75
- /** 获取全局 store */
76
- export function getStore(): Record<string, any> | null;
77
-
78
- /** 预加载组件库(可提前调用以加速渲染) */
79
- export function preloadPyComponent(): Promise<any>;
80
- }