0.0.6 • Published 2 years ago

ad4m-connect-common v0.0.6

Weekly downloads
-
License
CAL-1.0
Repository
-
Last release
2 years ago

AD4M Connect Web Component

Usage

Install AD4M Connect from npm,

npm install ad4m-connect-common

HTML

You need to include the bundled file as a script,

<script type="module" src="../dist/ad4m-connect.bundled.js"></script>

Then use the custom element,

<body>
  <ad4m-connect
    app='{"name":"kaichaoapp","description":"test app","url":"my-url"}'
    endpoint="ws://localhost:12000/graphql"
    capabilities='[{"with":{"domain":"*","pointers":["*"]},"can":["*"]}]'
  />
</body>

Listen to the custom jwt-received event for generated JWT,

<script>
  window.addEventListener('jwt-received', (e) => {
    console.log("jwt received");
    console.log(e.detail.jwt);
  });
</script>

Example

Vue

  1. Config vite by following the doc Vue and Web Components, adding one line of code tag === "ad4m-connect",
export default defineConfig({
  plugins: [
    vue({
      template: {
        compilerOptions: {
          isCustomElement: (tag) => {
            return (
              tag === "ad4m-connect"
            );
          },
        },
      },
    }),
    vueJsx(),
  ],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
});
  1. Import ad4m-connect-common in the app root main.ts or app.ts,
import "ad4m-connect-common";
  1. Use the custom tag ad4m-connect wherever you want,
<ad4m-connect
  .app='{"name":"testapp","description":"test app","url":"my-url"}'
  endpoint="ws://localhost:12000/graphql"
  .capabilities='[{"with":{"domain":"*","pointers":["*"]},"can":["*"]}]'
/>
0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago