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

@swissup/pwa-core

v13.0.0

Published

Magento PWA Studio Integration Module

Downloads

5

Readme

@swissup/pwa-core

Module add some targetable endpoints into @magento/pwa-studio and add more extensibility

Magento PWA Studio Setup

Magento PWA Studio setup

Install module

 yarn add @swissup/pwa-core
With github access
 yarn add ssh://[email protected]:swissup/pwa-core.git
For maintainers
 mkdir -p pwa-studio-custom-packages/swissup
 cd pwa-studio-custom-packages/swissup

 git clone [email protected]:swissup/pwa-core.git
 cd pwa-core
 pwd

 # goto pwa project root dir
 cd  ../../../pwa-studio-fundamentals

 yarn add file:[some path]/pwa-studio-custom-packages/swissup/pwa-core
 yarn watch
# or
 yarn build
 yarn start

Add @swissup to trusted vendors

  1. In your pwa-studio project root open package.json
  2. Find "pwa-studio" section
  3. Add "trusted-vendors" section if not exist
  4. Add "@swissup" vendor to "trusted-vendors"
{
    ...
    "pwa-studio": {
        "targets": {
          "intercept": "./local-intercept.js"
        },
        "trusted-vendors": [
          "@swissup"
        ]
    }
}
Show trusted vendor list
cat package.json | jq '."pwa-studio"."trusted-vendors"'
Oneline add vendor command (experimental jq)
mv package.json package.json.old && cat package.json.old | jq '."pwa-studio"."trusted-vendors" [."pwa-studio"."trusted-vendors" | length] |= . + "@swissup"' > package.json && rm package.json.old

Usage

Add custom content types

add peerDependencies

   "@swissup/pwa-core": "*"

into your module package.json

and

    "pwa-studio": {
        "targets": {
            "intercept": "./lib/intercept.js"
        }
    },

intercept.js

 module.exports = targets => {
  ...
  targets
    .of("@swissup/pwa-core")
    .contentTypes.tap(contentTypes => {
        contentTypes.add({
            componentName: '[componentx]',
            importPath: require.resolve("../lib/components/componentx/index.js")
        });
      });
  ...
}

componentx/index.js

export { default } from './componentX';
export { default as Component } from './componentX';
export { default as canRender } from './detectComponentX';

detectComponentX.js

export default function detectComponentX(content) {
    return /data-content-type=\"ComponentTypeX/.test(content);
}

componentx.js


import React from 'react';
import { setContentTypeConfig } from '@magento/pagebuilder/lib/config';

import ComponentXContentTypeConfig from './ContentTypes/ComponentTypeX';

// add custom page builder content type
//https://github.com/magento/pwa-studio/pull/2131
setContentTypeConfig('ComponentTypeX', ComponentXContentTypeConfig);

const ComponentX = (props) => {
    return null;
};

export default ComponentX;

ContentTypes/ComponentTypeX/index.js

import SomeComponent from './someComponent';
import configAggregator from './configAggregator';

export default {
    configAggregator,
    component: SomeComponent
}

ContentTypes/ComponentX/configAggregator.js

export default (node, props) => {
  const id = node.getAttribute('id');

  return {
        id
    }
}

ContentTypes/someComponent.js

import React from 'react';

const SomeComponent = props => {
  const { id } = props;

  return (<span>{id}</span>);
}

export default SomeComponent;

Docs