Socket
Socket
Sign inDemoInstall

druxt-router

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

druxt-router - npm Package Compare versions

Comparing version 0.18.0 to 0.18.1

14

dist/druxt-router.esm.js

@@ -14,3 +14,3 @@ import { resolve } from 'path';

/**
* The NuxtJS module function.
* The Nuxt.js module function.
*

@@ -160,12 +160,18 @@ * - Extends the Vue router, adding the Druxt wildcard route.

head: function head () {
return {
var head = {
title: this.title,
link: [
{
hid: 'canonical',
rel: 'canonical',
href: this.canonical || this.route.canonical
}
],
meta: this.metatags || false
]
};
if (this.metatags) {
head.meta = this.metatags;
}
return head
},

@@ -172,0 +178,0 @@

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

var DruxtRouter=function(t,e,r,o,n){"use strict";n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;function i(t,e,r,o,n,i,s,u,a,d){"boolean"!=typeof s&&(a=u,u=s,s=!1);var c,p="function"==typeof r?r.options:r;if(t&&t.render&&(p.render=t.render,p.staticRenderFns=t.staticRenderFns,p._compiled=!0,n&&(p.functional=!0)),o&&(p._scopeId=o),i?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),e&&e.call(this,a(t)),t&&t._registeredComponents&&t._registeredComponents.add(i)},p._ssrRegister=c):e&&(c=s?function(t){e.call(this,d(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,u(t))}),c)if(p.functional){var l=p.render;p.render=function(t,e){return c.call(e),l(t,e)}}else{var h=p.beforeCreate;p.beforeCreate=h?[].concat(h,c):[c]}return r}var s=i({render:function(){var t=this,e=t.$createElement,r=t._self._c||e;return t.$fetchState.pending?t._e():r(t.wrapper.component,t._b({tag:"component",class:t.wrapper.class,style:t.wrapper.style},"component",t.wrapper.propsData,!1),[r(t.component.is,t._b({tag:"component"},"component",t.component.propsData,!1),[t._v("\n "+t._s(t.route)+"\n ")])],1)},staticRenderFns:[]},undefined,{name:"DruxtRouter",mixins:[r.DruxtComponentMixin],middleware:async function(t){var e=t.store,r=t.redirect,o=t.route,n=await e.dispatch("druxtRouter/get",o.fullPath);n.redirect&&r(n.redirect)},computed:Object.assign({},{module:function(){return!(!(this.route||{}).component||!this.route.component.startsWith("druxt-"))&&this.route.component.substring(6)},title:function(){return this.route.label||!1},props:function(){return this.route.props||!1}},o.mapState({redirect:function(t){return t.druxtRouter.redirect},route:function(t){return t.druxtRouter.route}})),head:function(){return{title:this.title,link:[{rel:"canonical",href:this.canonical||this.route.canonical}],meta:this.metatags||!1}},druxt:function(t){var e=t.vm;return{componentOptions:[[e.module?e.module:"error",e.route.isHomePath?"front":"not-front"],["default"]],propsData:{route:e.route}}}},undefined,false,undefined,!1,void 0,void 0,void 0),u=function(t,e){void 0===e&&(e={}),this.options=Object.assign({},{types:[{type:"entity",canonical:function(t){return t.entity.canonical},component:"druxt-entity",property:"entity",props:function(t){return{type:t.jsonapi.resourceName,uuid:t.entity.uuid}}},{type:"views",canonical:function(t){return t.resolved},component:"druxt-view",property:"view",props:function(t){return{displayId:t.view.display_id,type:t.jsonapi.resourceName,uuid:t.view.uuid,viewId:t.view.view_id}}}]},e),this.druxt=new r.DruxtClient(t,this.options),this.axios=this.druxt.axios};u.prototype.addHeaders=function(t){if(console.warn("[druxt-router] `addHeaders` is deprecated. See http://druxtjs.org/api/client."),void 0===t)return!1;this.druxt.addHeaders(t)},u.prototype.buildQueryUrl=function(t,e){return console.warn("[druxt-router] `buildQueryUrl` is deprecated. See http://druxtjs.org/api/client."),this.druxt.buildQueryUrl(t,e)},u.prototype.checkPermissions=function(t){return console.warn("[druxt-router] `checkPermissions` is deprecated. See http://druxtjs.org/api/client."),this.druxt.checkPermissions(t)},u.prototype.get=async function(t){var e=await this.getRoute(t);return e.error?{route:e}:{redirect:this.getRedirect(t,e),route:e}},u.prototype.getIndex=async function(t){return console.warn("[druxt-router] `getIndex` is deprecated. See http://druxtjs.org/api/client."),this.index=await this.druxt.getIndex(t),this.index},u.prototype.getRedirect=function(t,e){if(void 0===e&&(e={}),((e.redirect||[])[0]||{}).to)return e.redirect[0].to;var r=n(t);if(e.isHomePath)return"/"!==r.pathname&&"/";if("string"==typeof e.canonical){var o=new n(e.canonical);if(r.pathname!==o.pathname)return o.pathname}return!1},u.prototype.getResource=async function(t){return void 0===t&&(t={}),console.warn("[druxt-router] `getResource` is deprecated. See http://druxtjs.org/api/client."),(await this.druxt.getResource(t.type,t.id)).data||!1},u.prototype.getResources=async function(t,e,r){void 0===r&&(r={}),console.warn("[druxt-router] `getResources` is deprecated. See http://druxtjs.org/api/client.");var o={data:[]};r.all?(await this.druxt.getCollectionAll(t,e)).map((function(t){(t.data||[]).map((function(t){o.data.push(t)}))})):o=await this.druxt.getCollection(t,e);return o.data||!1},u.prototype.getResourceByRoute=async function(t){return(await this.druxt.getResource(t.jsonapi.resourceName,t.entity.uuid)).data||!1},u.prototype.getRoute=async function(t){var e="/router/translate-path?path="+t,r=await this.druxt.axios.get(e,{validateStatus:function(t){return t<500}}),o=Object.assign({},{isHomePath:!1,jsonapi:{},label:!1,redirect:!1},r.data),i={error:!1,type:!1,canonical:!1,component:!1,isHomePath:o.isHomePath,jsonapi:o.jsonapi,label:o.label,props:!1,redirect:o.redirect,resolvedPath:n(o.resolved).pathname};for(var s in this.options.types){var u=Object.assign({},this.options.types[s]);if("string"==typeof u.property&&void 0!==o[u.property]){delete u.property,"function"==typeof u.canonical&&(u.canonical=u.canonical(o)),"function"==typeof u.props&&(u.props=u.props(o)),i=Object.assign({},i,u);break}}return r.status>=200&&r.status<300||(i.error={statusCode:r.status,message:r.statusText},i.component="error"),i};var a={props:{mode:{type:String,default:"default"},type:{type:String,required:!0},uuid:{type:String,required:!0}},fetch:async function(){if(void 0===this.entities[this.uuid]){if(!this.entity&&this.uuid&&this.type){var t=await this.getResource({id:this.uuid,type:this.type});this.entity=t.data,this.loading=!1}}else this.entity=this.entities[this.uuid]},data:function(){return{entity:!1,loading:!0}},computed:Object.assign({},o.mapState({entities:function(t){return t.druxt.resources}})),methods:Object.assign({},o.mapActions({getEntity:"druxtRouter/getEntity",getResource:"druxt/getResource"}))},d={props:{route:{type:Object,required:!0}}};return t.DruxtRouter=u,t.DruxtRouterComponent=s,t.DruxtRouterEntityMixin=a,t.DruxtRouterMixin=d,t.DruxtRouterStore=function(t){var e=t.store;if(void 0===e)throw new TypeError("Vuex store not found.");var r="druxtRouter",o={namespaced:!0,state:function(){return{entities:{},redirect:!1,route:{},routes:{}}},mutations:{addEntity:function(t,e){console.warn("[druxt-router] `druxtRouter/addEntity` is deprecated. See http://druxtjs.org/api/stores/druxt."),e&&void 0!==e.id&&(t.entities[e.id]=e)},setRedirect:function(t,e){t.redirect=e},addRoute:function(t,e){var r=e.path,o=e.route;"string"==typeof r&&void 0!==o&&(t.routes[r]=o)},setRoute:function(t,e){"string"==typeof e&&void 0!==t.routes[e]&&(t.route=t.routes[e])}},actions:{get:async function(t,e){var r=t.commit,o=t.dispatch,n=(t.state,await o("getRoute",e));if(n.error&&void 0!==n.error.statusCode&&((this.app||{}).context||{}).error)return this.app.context.error(n.error);r("setRoute",e);var i=this.$druxtRouter().getRedirect(e,n);return r("setRedirect",i),{redirect:i,route:n}},getEntity:async function(t,e){var r=t.commit,o=t.state;if(console.warn("[druxt-router] `druxtRouter/getEntity` is deprecated. See http://druxtjs.org/api/stores/druxt."),void 0!==o.entities[e.id])return o.entities[e.id];var n=await this.app.store.dispatch("druxt/getResource",e);return r("addEntity",n.data),n.data},getResources:async function(t,e){var r=e.resource,o=e.query;e.options;return console.warn("[druxt-router] `druxtRouter/getResources` is deprecated. See http://druxtjs.org/api/stores/druxt."),(await this.app.store.dispatch("druxt/getCollection",{type:r,query:o})).data||!1},getRoute:async function(t,e){var r=t.commit,o=t.state;if(void 0!==o.routes[e])return o.routes[e];var n=await this.$druxtRouter().getRoute(e);return r("addRoute",{path:e,route:n}),n}}};e.registerModule(r,o,{preserveState:Boolean(e.state[r])})},t.default=function(t){var r=this;if(void 0===this.options||!this.options.druxt)throw new TypeError("Druxt settings missing.");var o=this.options.druxt;o.router=o.router||{},this.extendRoutes((function(t,e){o.router.component||(o.router.component=e(r.options.buildDir,"components/druxt-router.js"),r.addTemplate({src:e(__dirname,"../nuxt/component.js"),fileName:"components/druxt-router.js",options:o})),t.push({name:"druxt-router",path:"*",component:o.router.component,chunkName:"druxt-router"})})),this.addPlugin({src:e.resolve(__dirname,"../nuxt/plugin.js"),fileName:"druxt-router.js",options:o}),this.addPlugin({src:e.resolve(__dirname,"../nuxt/store.js"),fileName:"store/druxt-router.js",options:o})},t}({},path,druxt,vuex,Url);
var DruxtRouter=function(t,e,r,o,n){"use strict";n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;function i(t,e,r,o,n,i,s,u,a,d){"boolean"!=typeof s&&(a=u,u=s,s=!1);var c,p="function"==typeof r?r.options:r;if(t&&t.render&&(p.render=t.render,p.staticRenderFns=t.staticRenderFns,p._compiled=!0,n&&(p.functional=!0)),o&&(p._scopeId=o),i?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),e&&e.call(this,a(t)),t&&t._registeredComponents&&t._registeredComponents.add(i)},p._ssrRegister=c):e&&(c=s?function(t){e.call(this,d(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,u(t))}),c)if(p.functional){var l=p.render;p.render=function(t,e){return c.call(e),l(t,e)}}else{var h=p.beforeCreate;p.beforeCreate=h?[].concat(h,c):[c]}return r}var s=i({render:function(){var t=this,e=t.$createElement,r=t._self._c||e;return t.$fetchState.pending?t._e():r(t.wrapper.component,t._b({tag:"component",class:t.wrapper.class,style:t.wrapper.style},"component",t.wrapper.propsData,!1),[r(t.component.is,t._b({tag:"component"},"component",t.component.propsData,!1),[t._v("\n "+t._s(t.route)+"\n ")])],1)},staticRenderFns:[]},undefined,{name:"DruxtRouter",mixins:[r.DruxtComponentMixin],middleware:async function(t){var e=t.store,r=t.redirect,o=t.route,n=await e.dispatch("druxtRouter/get",o.fullPath);n.redirect&&r(n.redirect)},computed:Object.assign({},{module:function(){return!(!(this.route||{}).component||!this.route.component.startsWith("druxt-"))&&this.route.component.substring(6)},title:function(){return this.route.label||!1},props:function(){return this.route.props||!1}},o.mapState({redirect:function(t){return t.druxtRouter.redirect},route:function(t){return t.druxtRouter.route}})),head:function(){var t={title:this.title,link:[{hid:"canonical",rel:"canonical",href:this.canonical||this.route.canonical}]};return this.metatags&&(t.meta=this.metatags),t},druxt:function(t){var e=t.vm;return{componentOptions:[[e.module?e.module:"error",e.route.isHomePath?"front":"not-front"],["default"]],propsData:{route:e.route}}}},undefined,false,undefined,!1,void 0,void 0,void 0),u=function(t,e){void 0===e&&(e={}),this.options=Object.assign({},{types:[{type:"entity",canonical:function(t){return t.entity.canonical},component:"druxt-entity",property:"entity",props:function(t){return{type:t.jsonapi.resourceName,uuid:t.entity.uuid}}},{type:"views",canonical:function(t){return t.resolved},component:"druxt-view",property:"view",props:function(t){return{displayId:t.view.display_id,type:t.jsonapi.resourceName,uuid:t.view.uuid,viewId:t.view.view_id}}}]},e),this.druxt=new r.DruxtClient(t,this.options),this.axios=this.druxt.axios};u.prototype.addHeaders=function(t){if(console.warn("[druxt-router] `addHeaders` is deprecated. See http://druxtjs.org/api/client."),void 0===t)return!1;this.druxt.addHeaders(t)},u.prototype.buildQueryUrl=function(t,e){return console.warn("[druxt-router] `buildQueryUrl` is deprecated. See http://druxtjs.org/api/client."),this.druxt.buildQueryUrl(t,e)},u.prototype.checkPermissions=function(t){return console.warn("[druxt-router] `checkPermissions` is deprecated. See http://druxtjs.org/api/client."),this.druxt.checkPermissions(t)},u.prototype.get=async function(t){var e=await this.getRoute(t);return e.error?{route:e}:{redirect:this.getRedirect(t,e),route:e}},u.prototype.getIndex=async function(t){return console.warn("[druxt-router] `getIndex` is deprecated. See http://druxtjs.org/api/client."),this.index=await this.druxt.getIndex(t),this.index},u.prototype.getRedirect=function(t,e){if(void 0===e&&(e={}),((e.redirect||[])[0]||{}).to)return e.redirect[0].to;var r=n(t);if(e.isHomePath)return"/"!==r.pathname&&"/";if("string"==typeof e.canonical){var o=new n(e.canonical);if(r.pathname!==o.pathname)return o.pathname}return!1},u.prototype.getResource=async function(t){return void 0===t&&(t={}),console.warn("[druxt-router] `getResource` is deprecated. See http://druxtjs.org/api/client."),(await this.druxt.getResource(t.type,t.id)).data||!1},u.prototype.getResources=async function(t,e,r){void 0===r&&(r={}),console.warn("[druxt-router] `getResources` is deprecated. See http://druxtjs.org/api/client.");var o={data:[]};r.all?(await this.druxt.getCollectionAll(t,e)).map((function(t){(t.data||[]).map((function(t){o.data.push(t)}))})):o=await this.druxt.getCollection(t,e);return o.data||!1},u.prototype.getResourceByRoute=async function(t){return(await this.druxt.getResource(t.jsonapi.resourceName,t.entity.uuid)).data||!1},u.prototype.getRoute=async function(t){var e="/router/translate-path?path="+t,r=await this.druxt.axios.get(e,{validateStatus:function(t){return t<500}}),o=Object.assign({},{isHomePath:!1,jsonapi:{},label:!1,redirect:!1},r.data),i={error:!1,type:!1,canonical:!1,component:!1,isHomePath:o.isHomePath,jsonapi:o.jsonapi,label:o.label,props:!1,redirect:o.redirect,resolvedPath:n(o.resolved).pathname};for(var s in this.options.types){var u=Object.assign({},this.options.types[s]);if("string"==typeof u.property&&void 0!==o[u.property]){delete u.property,"function"==typeof u.canonical&&(u.canonical=u.canonical(o)),"function"==typeof u.props&&(u.props=u.props(o)),i=Object.assign({},i,u);break}}return r.status>=200&&r.status<300||(i.error={statusCode:r.status,message:r.statusText},i.component="error"),i};var a={props:{mode:{type:String,default:"default"},type:{type:String,required:!0},uuid:{type:String,required:!0}},fetch:async function(){if(void 0===this.entities[this.uuid]){if(!this.entity&&this.uuid&&this.type){var t=await this.getResource({id:this.uuid,type:this.type});this.entity=t.data,this.loading=!1}}else this.entity=this.entities[this.uuid]},data:function(){return{entity:!1,loading:!0}},computed:Object.assign({},o.mapState({entities:function(t){return t.druxt.resources}})),methods:Object.assign({},o.mapActions({getEntity:"druxtRouter/getEntity",getResource:"druxt/getResource"}))},d={props:{route:{type:Object,required:!0}}};return t.DruxtRouter=u,t.DruxtRouterComponent=s,t.DruxtRouterEntityMixin=a,t.DruxtRouterMixin=d,t.DruxtRouterStore=function(t){var e=t.store;if(void 0===e)throw new TypeError("Vuex store not found.");var r="druxtRouter",o={namespaced:!0,state:function(){return{entities:{},redirect:!1,route:{},routes:{}}},mutations:{addEntity:function(t,e){console.warn("[druxt-router] `druxtRouter/addEntity` is deprecated. See http://druxtjs.org/api/stores/druxt."),e&&void 0!==e.id&&(t.entities[e.id]=e)},setRedirect:function(t,e){t.redirect=e},addRoute:function(t,e){var r=e.path,o=e.route;"string"==typeof r&&void 0!==o&&(t.routes[r]=o)},setRoute:function(t,e){"string"==typeof e&&void 0!==t.routes[e]&&(t.route=t.routes[e])}},actions:{get:async function(t,e){var r=t.commit,o=t.dispatch,n=(t.state,await o("getRoute",e));if(n.error&&void 0!==n.error.statusCode&&((this.app||{}).context||{}).error)return this.app.context.error(n.error);r("setRoute",e);var i=this.$druxtRouter().getRedirect(e,n);return r("setRedirect",i),{redirect:i,route:n}},getEntity:async function(t,e){var r=t.commit,o=t.state;if(console.warn("[druxt-router] `druxtRouter/getEntity` is deprecated. See http://druxtjs.org/api/stores/druxt."),void 0!==o.entities[e.id])return o.entities[e.id];var n=await this.app.store.dispatch("druxt/getResource",e);return r("addEntity",n.data),n.data},getResources:async function(t,e){var r=e.resource,o=e.query;e.options;return console.warn("[druxt-router] `druxtRouter/getResources` is deprecated. See http://druxtjs.org/api/stores/druxt."),(await this.app.store.dispatch("druxt/getCollection",{type:r,query:o})).data||!1},getRoute:async function(t,e){var r=t.commit,o=t.state;if(void 0!==o.routes[e])return o.routes[e];var n=await this.$druxtRouter().getRoute(e);return r("addRoute",{path:e,route:n}),n}}};e.registerModule(r,o,{preserveState:Boolean(e.state[r])})},t.default=function(t){var r=this;if(void 0===this.options||!this.options.druxt)throw new TypeError("Druxt settings missing.");var o=this.options.druxt;o.router=o.router||{},this.extendRoutes((function(t,e){o.router.component||(o.router.component=e(r.options.buildDir,"components/druxt-router.js"),r.addTemplate({src:e(__dirname,"../nuxt/component.js"),fileName:"components/druxt-router.js",options:o})),t.push({name:"druxt-router",path:"*",component:o.router.component,chunkName:"druxt-router"})})),this.addPlugin({src:e.resolve(__dirname,"../nuxt/plugin.js"),fileName:"druxt-router.js",options:o}),this.addPlugin({src:e.resolve(__dirname,"../nuxt/store.js"),fileName:"store/druxt-router.js",options:o})},t}({},path,druxt,vuex,Url);

@@ -9,3 +9,3 @@ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});function _interopDefault(e){return(e&&(typeof e==='object')&&'default'in e)?e['default']:e}var path=require('path'),druxt=require('druxt'),vuex=require('vuex'),Url=_interopDefault(require('url-parse'));/**

/**
* The NuxtJS module function.
* The Nuxt.js module function.
*

@@ -153,12 +153,18 @@ * - Extends the Vue router, adding the Druxt wildcard route.

head: function head () {
return {
var head = {
title: this.title,
link: [
{
hid: 'canonical',
rel: 'canonical',
href: this.canonical || this.route.canonical
}
],
meta: this.metatags || false
]
};
if (this.metatags) {
head.meta = this.metatags;
}
return head
},

@@ -265,3 +271,3 @@

/* module identifier */
var __vue_module_identifier__ = "data-v-517b6e3b";
var __vue_module_identifier__ = "data-v-130f3e88";
/* functional template */

@@ -268,0 +274,0 @@ var __vue_is_functional_template__ = false;

{
"name": "druxt-router",
"version": "0.18.0",
"version": "0.18.1",
"description": "Simple decoupled Drupal routing for Nuxt.",

@@ -5,0 +5,0 @@ "files": [

@@ -7,3 +7,3 @@ # DruxtJS Router

> Simple decoupled [Drupal](https://drupal.org) routing for your [NuxtJS](https://nuxtjs.org) application.
> Simple decoupled [Drupal](https://drupal.org) routing for your [Nuxt.js](https://nuxtjs.org) application.

@@ -18,3 +18,3 @@ ## Links

- NuxtJS module with out of the box page routing: `druxt-router`
- Nuxt.js module with out of the box page routing: `druxt-router`
- Vuex store: `druxtRouter`

@@ -21,0 +21,0 @@ - Vue component: `<DruxtRouter />`

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