Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@teamnovu/statamic-live-preview-nuxt

Package Overview
Dependencies
Maintainers
6
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@teamnovu/statamic-live-preview-nuxt - npm Package Compare versions

Comparing version 1.3.1 to 2.0.0

.idea/modules.xml

2

CHANGELOG.md

@@ -5,2 +5,4 @@ # Changelog

## [2.0.0](https://github.com/teamnovu/statamic-live-preview-nuxt/compare/v1.3.1...v2.0.0) (2023-04-28)
## [1.3.0](https://github.com/teamnovu/statamic-live-preview-nuxt/compare/v1.2.0...v1.3.0) (2022-05-23)

@@ -7,0 +9,0 @@

75

lib/plugin.js
/**
* The identifier that will be used to
* The identifier that will be used to
* set the element's data attribute via the Vue directive

@@ -19,6 +19,6 @@ */

function scrollTo(element) {
element.scrollIntoView({
behavior: "smooth",
block: "center",
inline: "nearest"
element.scrollIntoView({
behavior: "smooth",
block: "center",
inline: "nearest"
});

@@ -57,3 +57,3 @@ }

const matchingTarget = targets.find((target) => elementIdentifier === target.identifier)
if (matchingTarget) {

@@ -81,3 +81,3 @@ return matchingTarget

const ancestorIdentifier = getParentIdentifierRecursively(target.parentElement)
// the target might be nested within another target

@@ -105,34 +105,8 @@ // when that is the case, we need to concatenate the ancestor identifier with the element identifier

export default ({ app, query, $axios, $graphql, enablePreview }) => {
// Add token to new route query when changing route
if (query.token) {
app.router.beforeEach((to, from, next) => {
if (!from?.query?.token) {
// No token in from-query
return next()
}
let token = query.token
if (to.query?.token) {
// Already a token in to-query
return next()
}
return next({
...to,
query: {
...(to.query || {}),
...{
token: from.query.token,
// live-preview is used to prevent caching: https://github.com/statamic/cms/blob/33a9cd1b4f71c435cfd703f17f497f8eef582d8e/src/Http/Controllers/CP/PreviewController.php#L48
'live-preview': from.query['live-preview'],
},
},
})
})
}
// Add Axios interceptor
if ($axios) {
$axios.onRequest((config) => {
if (!query.token) {
if (!token) {
return config

@@ -144,3 +118,3 @@ }

...{
token: query.token,
token,
},

@@ -153,14 +127,8 @@ }

if ($graphql) {
app.router.afterEach((to, from) => {
if (!to.query.token) {
return
}
Object.keys($graphql).forEach((key) => {
$graphql[key].url = `${$graphql[key].url}?token=${to.query.token}`
})
Object.keys($graphql).forEach((key) => {
$graphql[key].url = `${$graphql[key].url}?token=${token}`
})
}
if (process.client && query.token) {
if (process.client && token) {
log('Enabling preview mode...')

@@ -173,5 +141,14 @@

window.onmessage = ({ data }) => {
if (!data) return
if (!(typeof data === 'object')) return
if (typeof data === 'object' && data.focusedElement) {
if (data.name === 'statamic.preview.updated') {
if (data.token && data.token !== token) {
log('Using new token:', data.token)
token = data.token
}
log('Refreshing page...')
window.$nuxt?.refresh()
} else if (data.focusedElement) {
const element = getElement(data.focusedElement)

@@ -182,6 +159,2 @@

scrollTo(element)
} else if (data === 'live-preview-update') {
log('Refreshing page...')
window.$nuxt?.refresh()
}

@@ -188,0 +161,0 @@ }

{
"name": "@teamnovu/statamic-live-preview-nuxt",
"version": "1.3.1",
"version": "2.0.0",
"description": "A Nuxt.js Plugin for the Statamic Live Preview",

@@ -10,3 +10,3 @@ "private": false,

"release-minor": "standard-version --release-as minor && git push --follow-tags && npm publish",
"release-major": "standard-version --release-as major && gi t push --follow-tags && npm publish",
"release-major": "standard-version --release-as major && git push --follow-tags && npm publish",
"test": "echo \"Error: no test specified\" && exit 1"

@@ -13,0 +13,0 @@ },

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