New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@beyondwords/ghost-helper

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@beyondwords/ghost-helper - npm Package Compare versions

Comparing version 0.0.1-rc.4 to 0.0.1-rc.5

2

dist/umd.js

@@ -1,2 +0,2 @@

(function(o,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(o=typeof globalThis<"u"?globalThis:o||self,o.GhostHelper=n())})(this,function(){"use strict";const o=class{constructor(t){this.props=t,this.playerLoader=this.init().then(e=>{this.player=e}).catch(e=>{throw console.error("BeyondWords.GhostHelper",e),e})}async init(){var s;await this.domContentLoaded();const t=this.resolveTargetElement(),e=this.attachPlayerTargetElement(t);if(await this.loadPlayerScript(t),!((s=window.BeyondWords)!=null&&s.Player))throw new Error("BeyondWords Player SDK failed to initialize");return new window.BeyondWords.Player({sourceUrl:window.location.href,...this.props,target:e})}async domContentLoaded(){if(!(document.readyState==="complete"||document.readyState==="interactive"))return new Promise(t=>{document.addEventListener("DOMContentLoaded",()=>t())})}resolveTargetElement(){if(this.props.target instanceof Element)return this.props.target;if(typeof this.props.target=="string"){const a=document.querySelector(this.props.target);if(!a)throw new Error(`Target element "${this.props.target}" not found.`);return a}const t=document.querySelector(".beyondwords-target");if(t)return t;const e=document.body.classList.contains("post-template"),s=document.body.classList.contains("page-template");if(!e&&!s)throw new Error("Player is only available on Ghost Posts and Pages.");const r=document.querySelector(".post-full-content");if(r)return r;const i=document.querySelector("article");if(i){const a=i.querySelector("header");return a||i}const d=document.querySelector(".content");if(d)return d;throw new Error("Target not found. See https://ghost.org/integrations/beyondwords/#advanced for further information.")}async loadPlayerScript(t){return typeof o.playerScriptLoader>"u"&&(o.playerScriptLoader=new Promise((e,s)=>{const r=document.createElement("script");r.onload=()=>{r.onload=null,r.onerror=null,e()},r.onerror=i=>{r.onload=null,r.onerror=null,s(i)},r.src="https://proxy.beyondwords.io/npm/@beyondwords/player@latest/dist/umd.js",t.insertBefore(r,t.firstChild)})),o.playerScriptLoader}attachPlayerTargetElement(t){const e=document.createElement("div");return e.setAttribute("id","beyondwords-player"),e.style.width="100%",e.style.marginBottom="1em",t.insertBefore(e,t.firstChild),e}};let n=o;return n.playerScriptLoader=void 0,window.BeyondWords||(window.BeyondWords={Player:void 0}),window.BeyondWords.GhostHelper=n,n});
(function(o,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(o=typeof globalThis<"u"?globalThis:o||self,o.GhostHelper=n())})(this,function(){"use strict";const o=class{constructor(e){this.props=e,this.playerLoader=this.init().then(t=>{this.player=t}).catch(t=>{throw console.error("BeyondWords.GhostHelper",t),t})}async init(){var s;await this.domContentLoaded();const e=this.resolveTargetElement(),t=this.attachPlayerTargetElement(e);if(await this.loadPlayerScript(e),!((s=window.BeyondWords)!=null&&s.Player))throw new Error("BeyondWords Player SDK failed to initialize");return new window.BeyondWords.Player({sourceUrl:window.location.href,...this.props,target:t})}async domContentLoaded(){if(!(document.readyState==="complete"||document.readyState==="interactive"))return new Promise(e=>{document.addEventListener("DOMContentLoaded",()=>e())})}resolveTargetElement(){if(this.props.target instanceof Element)return this.props.target;if(typeof this.props.target=="string"){const a=document.querySelector(this.props.target);if(!a)throw new Error(`Target element "${this.props.target}" not found.`);return a}const e=document.querySelector(".beyondwords-target");if(e)return e;const t=document.body.classList.contains("post-template"),s=document.body.classList.contains("page-template");if(!t&&!s)throw new Error("Player is only available on Ghost Posts and Pages.");const r=document.querySelector(".post-full-content");if(r)return r;const i=document.querySelector("article");if(i){const a=i.querySelector("header");return a||i}const d=document.querySelector(".content");if(d)return d;throw new Error("Target not found. See https://ghost.org/integrations/beyondwords/#advanced for further information.")}async loadPlayerScript(e){return typeof o.playerScriptLoader>"u"&&(o.playerScriptLoader=new Promise((t,s)=>{const r=document.createElement("script");r.onload=()=>{r.onload=null,r.onerror=null,t()},r.onerror=i=>{r.onload=null,r.onerror=null,s(i)},r.src="https://proxy.beyondwords.io/npm/@beyondwords/player@latest/dist/umd.js",e.insertBefore(r,e.firstChild)})),o.playerScriptLoader}attachPlayerTargetElement(e){const t=document.createElement("div");return t.setAttribute("id","beyondwords-player"),t.style.width="100%",e.insertBefore(t,e.firstChild),t}};let n=o;return n.playerScriptLoader=void 0,window.BeyondWords||(window.BeyondWords={Player:void 0}),window.BeyondWords.GhostHelper=n,n});
//# sourceMappingURL=umd.js.map
{
"name": "@beyondwords/ghost-helper",
"version": "0.0.1-rc.4",
"version": "0.0.1-rc.5",
"author": "BeyondWords Developers",

@@ -5,0 +5,0 @@ "description": "BeyondWords Player integration for Ghost",

@@ -1,2 +0,2 @@

# BeyondWords Player Ghost helper
# BeyondWords Ghost Helper

@@ -6,3 +6,3 @@ [![Build](https://github.com/beyondwords-io/ghost-helper/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/beyondwords-io/ghost-helper/actions/workflows/build.yml)

Helper script for easier integration of the [BeyondWords Player](https://github.com/BeyondWords-io/player) with [Ghosts](https://ghost.org)
The Ghost Helper aims to make the integration with [Ghosts](https://ghost.org) easier by placing the [BeyondWords Player](https://github.com/beyondwords-io/player) in the right place for your theme and by selecting the correct content based on the page URL.

@@ -14,4 +14,58 @@ # Documentation

# Examples
## Basic
```html
<script async defer src="https://proxy.beyondwords.io/npm/@beyondwords/ghost-helper@latest/dist/umd.js"
onload="new BeyondWords.GhostHelper({
projectId: <ID>
})">
</script>
```
## Custom position
```html
<script async defer src="https://proxy.beyondwords.io/npm/@beyondwords/ghost-helper@latest/dist/umd.js"
onload="new BeyondWords.GhostHelper({
projectId: <ID>,
target: '.custom-target',
})">
</script>
```
## Custom styles
```html
<style>
#beyondwords-player {
margin: 16px 0;
}
</style>
<script async defer src="https://proxy.beyondwords.io/npm/@beyondwords/ghost-helper@latest/dist/umd.js"
onload="new BeyondWords.GhostHelper({
projectId: <ID>
})">
</script>
```
## Player reference
```js
const helper = new BeyondWords.GhostHelper({
projectId: <ID>
});
await helper.playerLoader;
helper.player.addEventListener("<any>", console.log);
```
## Other
For further customization you can refer to the [BeyondWords Player](https://github.com/beyondwords-io/player) documentation as the arguments of the GhostHelper constructor matches the BeyondWords Player constructor.
# Development
## Prerequisites
To work on the project you must have installed:

@@ -23,3 +77,3 @@

- Install NPM dependencies:
- npm dependencies:

@@ -32,3 +86,3 @@ ```

The `build` script will produce artifacts in the `/dist` directory, using [Vite](https://vitejs.dev/)
The `build` script will produce artifacts in the `/dist` directory, using [Vite](https://vitejs.dev/).

@@ -43,3 +97,3 @@ The build artifact is a single js file using the umd format.

The `lint` script does a full static analysis of the source code, using [ESLint](https://eslint.org/)
The `lint` script does a full static analysis of the source code, using [ESLint](https://eslint.org/).

@@ -52,6 +106,6 @@ ```

A new version of the Ghost helper will be published automatically to [NPM](https://www.npmjs.com/package/@beyondwords/ghost-helper) using the [release Github Actions workflow](.github/workflows/release.yml) on each new published Github release.
A new version of the Ghost Helper will be published automatically to [NPM](https://www.npmjs.com/package/@beyondwords/ghost-helper) using the [release Github Actions workflow](.github/workflows/release.yml) on each new published Github release.
## License
BeyondWords Player Ghost helper is [MIT licensed](LICENSE).
BeyondWords Ghost Helper is [MIT licensed](LICENSE).

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc