npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

antv-x6-vue2-shape

v2.1.3

Published

X6 shape for rendering vue2 components with teleport polyfill.

Readme

antv-x6-vue2-shape

x6 shape for rendering vue 2 components with teleport polyfill

this package is based on @antv/x6-vue-shape (keep updated with @antv/x6-vue-shape at v2.1.2)

but with the following key improvements for Vue2-only scenarios:

  • Removed vue-demi dependency: Fully optimized for Vue2, eliminating cross-version compatibility code to reduce package size and improve runtime efficiency.
  • Added Teleport polyfill support: For the first time, brings Vue3's native teleport capability to Vue2 environments, solving the rendering context isolation issue when embedding Vue components in X6 nodes.
  • Optional Teleport mode: The Teleport feature is optional. If you don't call useTeleport(), it behaves exactly like the original @antv/x6-vue-shape (Vue2 version). When enabled via useTeleport({ target: HTMLElement | string }), you can specify a custom DOM container for component mounting.

antv-x6-vue2-shape是专门针对 Vue2 的场景,去除了 vue-demi 本版兼容工具,提供了 Teleport polyfill 的支持,以解决 Vue2 下 X6 动态节点导致的渲染上下文丢失、事件冒泡异常等问题。

  • 未启用 Teleport:组件直接渲染在 X6 节点的默认容器中,与原始 @antv/x6-vue-shape (Vue2) 完全一致。
  • 启用 Teleport:组件将通过 Polyfill 渲染到指定的 target 容器中,缓解 Vue2 下因 X6 动态节点导致的 DOM 上下文丢失和事件冒泡异常问题,使渲染行为在 DOM 层面更接近 Vue3 的原生 Teleport(但不完全支持跨层级的 provide/inject 等上下文传递)。

Installation

# npm
$ npm install @antv/x6 antv-x6-vue2-shape --save

# yarn
$ yarn add @antv/x6 antv-x6-vue2-shape

# pnpm
pnpm add @antv/x6 antv-x6-vue2-shape

Usage

<template>
  <div>
    <h1>Vue2 + X6 + antv-x6-vue2-shape 自定义节点示例</h1>
    <div
      id="container"
      style="
        width: 100%;
        height: 600px;
        border: 2px solid #e0e0e0;
        margin-top: 20px;
      "
    ></div>
    <div id="teleport-target"></div>
  </div>
</template>

<script>
import { Graph } from '@antv/x6'
import { useTeleport, register } '@antv-x6-vue2-shape'

const HelloWorld = {
  data() {
    return {
      name: 'x6-vue2-shape',
    }
  },
  render(h) {
    return h('div', [`Hello ${this.name}`])
  }
}

export default {
  mounted() {
    this.init()
  },
  methods: {
    init() {
      // 启用 Teleport 功能,指定 Teleport 挂载点(可选)
      useTeleport({
        target: '#teleport-target' // 支持 CSS 选择器或 HTMLElement
      })

      const graph = new Graph({
        container: document.getElementById("container"),
        grid: { size: 10, visible: true }, // 显示更细的网格
        background: { color: "#f8f9fa" }, // 设置背景色
      });

      // 注册自定义节点
      register({
        name: 'vue-shape',
        component: HelloWorld,
      })

      // 添加节点
      graph.addNode({shape: 'vue-shape', x: 32, y: 48, width: 180, height: 40})
    }
  }
}
</script>