Skip to content

Commit

Permalink
fix: Circular deps detected by Rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed Jun 18, 2018
1 parent e3cd201 commit 3bd2f9d
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 41 deletions.
3 changes: 1 addition & 2 deletions src/body.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ready } from './utils/dom'
import { setBrand } from './utils/colors'
import { isSSR } from './plugins/platform'
import { $q, queues } from './install'

function getBodyClasses ({ is, has, within }, cfg) {
const cls = [
Expand Down Expand Up @@ -54,7 +53,7 @@ function setColors (brand) {
}

export default {
install ({ cfg }) {
install ($q, queues, cfg) {
if (isSSR) {
queues.server.push((q, ctx) => {
const update = ctx.ssr.setBodyClasses
Expand Down
3 changes: 1 addition & 2 deletions src/history.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { isSSR } from './plugins/platform'
import { $q } from './install'

export default {
__history: [],
add: () => {},
remove: () => {},

install ({ cfg }) {
install ($q, cfg) {
if (isSSR || !$q.platform.is.cordova) {
return
}
Expand Down
3 changes: 1 addition & 2 deletions src/i18n.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import langEn from '../i18n/en-us'
import { isSSR } from './plugins/platform'
import { ready } from './utils/dom'
import { $q, queues } from './install'

export default {
install ({ Vue, lang }) {
install ($q, queues, Vue, lang) {
if (isSSR) {
queues.server.push((q, ctx) => {
const fn = ctx.ssr.setHtmlAttrs
Expand Down
3 changes: 1 addition & 2 deletions src/icons.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { isSSR } from './plugins/platform'
import { $q } from './install'
import materialIcons from '../icons/material-icons'

export default {
__installed: false,
install ({ Vue, iconSet }) {
install ($q, Vue, iconSet) {
this.set = (iconDef = materialIcons) => {
iconDef.set = this.set

Expand Down
12 changes: 6 additions & 6 deletions src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export default function (Vue, opts = {}) {
const cfg = opts.config || {}

// required plugins
Platform.install({ Vue })
Body.install({ cfg })
History.install({ cfg })
I18n.install({ Vue, cfg, lang: opts.i18n })
Icons.install({ Vue, iconSet: opts.iconSet })
Platform.install($q, queues, Vue)
Body.install($q, queues, cfg)
History.install($q, cfg)
I18n.install($q, queues, Vue, opts.i18n)
Icons.install($q, Vue, opts.iconSet)

if (isSSR) {
Vue.mixin({
Expand Down Expand Up @@ -59,7 +59,7 @@ export default function (Vue, opts = {}) {
}

if (opts.plugins) {
const param = { Vue, cfg }
const param = { $q, queues, Vue, cfg }
Object.keys(opts.plugins).forEach(key => {
const p = opts.plugins[key]
if (typeof p.install === 'function' && p !== Platform) {
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/action-sheet.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { QActionSheet } from '../components/action-sheet'
import modalFn from '../utils/modal-fn'
import { $q } from '../install'

export default {
install ({ Vue }) {
install ({ $q, Vue }) {
this.create = $q.actionSheet = modalFn(QActionSheet, Vue)
}
}
3 changes: 1 addition & 2 deletions src/plugins/addressbar-color.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Platform, { isSSR } from './platform'
import { ready } from '../utils/dom'
import { getBrand } from '../utils/colors'
import { $q } from '../install'

let metaValue

Expand Down Expand Up @@ -47,7 +46,7 @@ function setColor (hexColor) {
}

export default {
install ({ Vue }) {
install ({ $q, Vue }) {
this.set = !isSSR && Platform.is.mobile && (
Platform.is.cordova ||
Platform.is.winphone || Platform.is.safari ||
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/app-fullscreen.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { isSSR } from './platform'
import { $q } from '../install'

const prefixes = {}

Expand Down Expand Up @@ -27,7 +26,7 @@ export default {
}
},

install ({ Vue }) {
install ({ $q, Vue }) {
$q.fullscreen = this

if (isSSR) { return }
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/app-visibility.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { isSSR } from './platform'
import { $q } from '../install'

export default {
appVisible: false,

install ({ Vue }) {
install ({ $q, Vue }) {
if (isSSR) {
this.appVisible = $q.appVisible = true
return
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/cookies.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { isSSR } from './platform'
import { $q, queues } from '../install'

function encode (string) {
return encodeURIComponent(string)
Expand Down Expand Up @@ -140,7 +139,7 @@ export function getObject (ctx = {}) {
}

export default {
install () {
install ({ $q, queues }) {
if (isSSR) {
queues.server.push((q, ctx) => {
q.cookies = getObject(ctx)
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/dialog.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { QDialog } from '../components/dialog'
import modalFn from '../utils/modal-fn'
import { $q } from '../install'

export default {
install ({ Vue }) {
install ({ $q, Vue }) {
this.create = $q.dialog = modalFn(QDialog, Vue)
}
}
3 changes: 1 addition & 2 deletions src/plugins/loading.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { QSpinner } from '../components/spinner'
import { isSSR } from './platform'
import { $q } from '../install'

let
vm,
Expand Down Expand Up @@ -94,7 +93,7 @@ export default {
},

__Vue: null,
install ({ Vue, cfg: { loading } }) {
install ({ $q, Vue, cfg: { loading } }) {
loading && this.setDefaults(loading)

$q.loading = this
Expand Down
9 changes: 4 additions & 5 deletions src/plugins/notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import uid from '../utils/uid'
import clone from '../utils/clone'
import { isSSR } from './platform'
import { ready } from '../utils/dom'
import { $q } from '../install'

let defaults

Expand Down Expand Up @@ -195,16 +194,16 @@ export default {

install (args) {
if (isSSR) {
$q.notify = () => {}
$q.notify.setDefaults = () => {}
args.$q.notify = () => {}
args.$q.notify.setDefaults = () => {}
return
}

init.call(this, args)

args.cfg.notify && this.setDefaults(args.cfg.notify)

$q.notify = this.create.bind(this)
$q.notify.setDefaults = this.setDefaults
args.$q.notify = this.create.bind(this)
args.$q.notify.setDefaults = this.setDefaults
}
}
4 changes: 1 addition & 3 deletions src/plugins/platform.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { $q, queues } from '../install'

/* eslint-disable no-useless-escape */
/* eslint-disable no-unused-expressions */
/* eslint-disable no-mixed-operators */
Expand Down Expand Up @@ -201,7 +199,7 @@ export default {
iframe: false
},

install ({ Vue }) {
install ($q, queues, Vue) {
if (isSSR) {
queues.server.push((q, ctx) => {
q.platform = {
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/screen.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { isSSR, fromSSR } from './platform'
import { listenOpts } from '../utils/event'
import { debounce } from '../utils/debounce'
import { $q, queues } from '../install'

export default {
width: 0,
Expand All @@ -24,7 +23,7 @@ export default {
setSizes () {},
setDebounce () {},

install ({ Vue }) {
install ({ $q, queues, Vue }) {
if (isSSR) {
$q.screen = this
return
Expand Down
5 changes: 2 additions & 3 deletions src/plugins/web-storage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { onSSR } from './platform'
import { $q } from '../install'

function encode (value) {
if (Object.prototype.toString.call(value) === '[object Date]') {
Expand Down Expand Up @@ -125,7 +124,7 @@ function getStorage (type) {
}

export const LocalStorage = {
install () {
install ({ $q }) {
if (onSSR) {
$q.localStorage = getEmptyStorage()
return
Expand All @@ -140,7 +139,7 @@ export const LocalStorage = {
}

export const SessionStorage = {
install () {
install ({ $q }) {
if (onSSR) {
$q.sessionStorage = getEmptyStorage()
return
Expand Down

0 comments on commit 3bd2f9d

Please sign in to comment.