actview 3.0.0 → 3.1.0

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.
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  ## 核心功能
8
8
 
9
9
  - **vue 运行时 re-export**:响应式(`ref` / `reactive` / `computed` / `watch` / `effectScope`)、组件(`defineComponent` / `createApp` / `h`)、生命周期、内置组件(`KeepAlive` / `Teleport` / `Suspense` / `Transition` / `TransitionGroup`)
10
- - **defineComponent 桥接**(React 语义):`ctx.slots` → `props.children`(读时求值),props 读不到时从 attrs 兜底,`inheritAttrs: false`
10
+ - **defineComponent 桥接**(React 语义):`ctx.slots` → `props.children`(读时求值),props 读不到时从 attrs 兜底;**有 props 声明时自动落根**(`inheritAttrs` 开启,未消费 attrs 透传到根元素 + scoped data-v 生效),无声明时保持不透传(React 语义,避免 props 污染 DOM)
11
11
  - **createContext**:React 语义(`.Provider` / `.use()`),基于 vue `provide/inject`
12
12
  - **JSX 类型层**:全局 `IntrinsicElements` 完整标签表(React 语义属性)+ vue 组件兼容;组件 props 严格检查(未声明 prop 报错)
13
13
 
package/dist/index.d.ts CHANGED
@@ -23,7 +23,16 @@ type ActViewComponent<Props extends Record<string, any> = Record<string, any>> =
23
23
  __isVue?: true;
24
24
  __vccOpts?: any;
25
25
  };
26
- declare function defineComponent<Props extends Record<string, any> = Record<string, any>>(setup: (props: Props, ctx: SetupContext) => unknown, name?: string): ActViewComponent<Props>;
26
+ interface ActViewDefineComponentOptions {
27
+ name?: string;
28
+ /**
29
+ * 运行时 props 声明(@actview/plugin-jsx 编译期从类型注解提取注入,
30
+ * 也可手写)。存在时开启自动落根:未消费的 attrs(class / data-v-* /
31
+ * 事件 / 透传属性)自动 apply 到根元素。
32
+ */
33
+ props?: Record<string, any>;
34
+ }
35
+ declare function defineComponent<Props extends Record<string, any> = Record<string, any>>(setup: (props: Props, ctx: SetupContext) => unknown, options?: ActViewDefineComponentOptions | string): ActViewComponent<Props>;
27
36
  interface Context<T> {
28
37
  /** 内部唯一键(Symbol):对象身份即键 */
29
38
  readonly _key: symbol;
@@ -43,4 +52,4 @@ interface Context<T> {
43
52
  declare function createContext<T extends object>(defaultValue: Reactive<T>): Context<T>;
44
53
  declare function createContext<T>(defaultValue: T): Context<T>;
45
54
 
46
- export { type ActViewComponent, type Context, createContext, defineComponent };
55
+ export { type ActViewComponent, type ActViewDefineComponentOptions, type Context, createContext, defineComponent };
package/dist/index.js CHANGED
@@ -79,11 +79,15 @@ import {
79
79
  inject as inject2,
80
80
  provide as provide2
81
81
  } from "vue";
82
- function defineComponent(setup, name) {
82
+ function defineComponent(setup, options) {
83
+ const opts = typeof options === "string" ? { name: options } : options ?? {};
83
84
  return vueDefineComponent({
84
- name,
85
- // 未消费 props 不自动落根 DOM(React 语义;Vue 默认 inheritAttrs 会落)
86
- inheritAttrs: false,
85
+ name: opts.name,
86
+ // 编译期提取的 props 声明(无则 undefined——组件保持「任意 props 兜底」)
87
+ props: opts.props,
88
+ // 有 props 声明 → 开启自动落根(透传 + scoped data-v 生效);
89
+ // 无声明 → false(React 语义:避免未消费 props 以 DOM 属性形式污染根元素)
90
+ inheritAttrs: !!opts.props,
87
91
  setup(props, ctx) {
88
92
  const attrs = ctx.attrs;
89
93
  const bridge = new Proxy(props, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "actview",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "type": "module",
5
5
  "description": "ActView v2:Vue 引擎 + React 语义 JSX(运行时基于 vue 官方包,JSX 由 @actview/plugin-jsx 编译)",
6
6
  "exports": {