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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@web-widget/vue-adapter

v0.0.5

Published

a web-widget plugin for vue.js applications

Downloads

3

Readme

vue-adapter

Generic lifecycle hooks for Vue.js applications that are registered as applications of web-widget.

Installation

The vue-adapter will get everything set up.

npm install --save @web-widget/vue-adapter

Alternatively, you can use @web-widget/vue-adapter by adding <script src="https://unpkg.com/@web-widget/vue-adapter"></script> to your HTML file and accessing the WebWidgetVueAdapter global variable.

Usage

import { createAdapter } from '@web-widget/vue-adapter';

export default createAdapter({...});

Vue 2

For Vue 2, change your application's entry file to be the following:

import Vue from 'vue';
import App from './App.vue';
import router from './router';
import { createAdapter } from '@web-widget/vue-adapter';

export default createAdapter({
  Vue,
  vueOptions: {
    render(h) {
      return h(App);
    },
    router,
  },
});

Vue 3

For Vue 3, change your application's entry file to be the following:

import { h, createApp } from 'vue';
import App from './App.vue';
import router from './router';
import { createAdapter } from '@web-widget/vue-adapter';

export default createAdapter({
  createApp,
  vueOptions: {
    render() {
      return h(App, {
        // name: this.name
      });
    },
  },
  handleInstance: (app) => {
    app.use(router);
  }
});

Options

All options are passed to vue-adapter via the opts parameter when calling createAdapter(opts). The following options are available:

  • Vue: (required) The main Vue object, which is generally either exposed onto the window or is available via require('vue') import Vue from 'vue'.
  • vueOptions: (required) An object or async function which will be used to instantiate your Vue.js application. vueOptions will pass directly through to new Vue(vueOptions). Note that if you do not provide an el to vueOptions, that a div will be created and appended to the DOM as a default container for your Vue application. When vueOptions is an async function, it receives the Web Widget application props as an argument.
  • loadRootComponent: (optional and replaces vueOptions.render) A promise that resolves with your root component. This is useful for lazy loading.
  • handleInstance: (optional) A method can be used to handle Vue instance. Vue 3 brings new instance API, and you can access the app instance from this, like handleInstance: (app, props) => app.use(router). For Vue 2 users, a Vue instance can be accessed. The handleInstance(app, props) function receives the instance as its first argument, and Web Widget application props as its second argument. If handleInstance returns a promise, vue-adapter will wait to resolve the app / parcel's mount lifecycle until the handleInstance promise resolves.

To configure which dom element the Web Widget application is mounted to, use vueOptions.el:

const vueLifecycles = createAdapter({
  Vue,
  vueOptions: {
    render: h => h(App),
    el: '#a-special-container',
  },
});

To configure options asynchronously return a promise from vueOptions function:

const vueLifecycles = createAdapter({
  Vue,
  async vueOptions() {
    return {
      router: await routerFactory(),
      render: h => h(App)
    }
  },
});

Thanks

https://github.com/single-spa/single-spa-vue