feat(core): Load core plugins (plugin bundle) by default
This commit is contained in:
parent
4528e1bc88
commit
b263979ca0
8 changed files with 34 additions and 30 deletions
|
@ -54,6 +54,7 @@ charlie:
|
|||
'@freesewing/snapseries': *freesewing
|
||||
core:
|
||||
_:
|
||||
'@freesewing/plugin-bundle': *freesewing
|
||||
'bezier-js': '6.1.4'
|
||||
'bin-pack-with-constraints': '1.0.1'
|
||||
'hooks': '0.3.2'
|
||||
|
|
|
@ -17,9 +17,9 @@ const options = {
|
|||
entryPoints: ['src/index.mjs'],
|
||||
format: 'esm',
|
||||
outfile: 'dist/index.mjs',
|
||||
external: ['@freesewing'],
|
||||
//external: ['@freesewing'],
|
||||
metafile: process.env.VERBOSE ? true : false,
|
||||
minify: process.env.NO_MINIFY ? false : true,
|
||||
//minify: process.env.NO_MINIFY ? false : true,
|
||||
sourcemap: true,
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
},
|
||||
"peerDependencies": {},
|
||||
"dependencies": {
|
||||
"@freesewing/plugin-bundle": "3.0.0-alpha.10",
|
||||
"bezier-js": "6.1.4",
|
||||
"bin-pack-with-constraints": "1.0.1",
|
||||
"hooks": "0.3.2",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { Hooks } from '../hooks.mjs'
|
||||
import { pluginBundle as corePlugins } from '@freesewing/plugin-bundle'
|
||||
|
||||
/**
|
||||
* Get the name of the given plugin config
|
||||
|
@ -22,6 +23,8 @@ export function PatternPlugins(pattern) {
|
|||
this.hooks = new Hooks()
|
||||
this.macros = {}
|
||||
this.__storeMethods = new Set()
|
||||
// Load core plugins unless the design explicitly asked not to
|
||||
if (!pattern.designConfig.noCorePlugins) this.use(corePlugins)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,24 +6,22 @@ const expect = chai.expect
|
|||
describe('Hooks', () => {
|
||||
it('Should contain all hooks', () => {
|
||||
const pattern = new Pattern()
|
||||
const h = pattern.plugins.hooks
|
||||
const test = {
|
||||
preInit: [],
|
||||
postInit: [],
|
||||
preDraft: [],
|
||||
preSetDraft: [],
|
||||
prePartDraft: [],
|
||||
postPartDraft: [],
|
||||
postSetDraft: [],
|
||||
postDraft: [],
|
||||
preSample: [],
|
||||
postSample: [],
|
||||
preRender: [],
|
||||
preLayout: [],
|
||||
postLayout: [],
|
||||
postRender: [],
|
||||
insertText: [],
|
||||
}
|
||||
expect(h).to.eql(test)
|
||||
expect(Object.keys(pattern.plugins.hooks)).to.eql([
|
||||
'preInit',
|
||||
'postInit',
|
||||
'preDraft',
|
||||
'preSetDraft',
|
||||
'prePartDraft',
|
||||
'postPartDraft',
|
||||
'postSetDraft',
|
||||
'postDraft',
|
||||
'preSample',
|
||||
'postSample',
|
||||
'preRender',
|
||||
'preLayout',
|
||||
'postLayout',
|
||||
'postRender',
|
||||
'insertText',
|
||||
])
|
||||
})
|
||||
})
|
||||
|
|
|
@ -568,7 +568,7 @@ describe('Pattern', () => {
|
|||
plugins: plugin,
|
||||
draft: (part) => part,
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const design = new Design({ parts: [part], noCorePlugins: true })
|
||||
const pattern = new design()
|
||||
pattern.draft()
|
||||
expect(pattern.plugins.hooks.preRender).to.have.lengthOf(1)
|
||||
|
@ -598,7 +598,7 @@ describe('Pattern', () => {
|
|||
plugins: [plugin1, plugin2],
|
||||
draft: (part) => part,
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const design = new Design({ parts: [part], noCorePlugins: true })
|
||||
const pattern = new design()
|
||||
pattern.__init()
|
||||
expect(pattern.plugins.hooks.preRender).to.have.lengthOf(2)
|
||||
|
@ -620,7 +620,7 @@ describe('Pattern', () => {
|
|||
plugins: [{ plugin, condition }],
|
||||
draft: (part) => part,
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const design = new Design({ parts: [part], noCorePlugins: true })
|
||||
const pattern = new design()
|
||||
pattern.__init()
|
||||
expect(pattern.plugins.hooks.preRender).to.have.lengthOf(1)
|
||||
|
@ -642,7 +642,7 @@ describe('Pattern', () => {
|
|||
plugins: [{ plugin, condition }],
|
||||
draft: (part) => part,
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const design = new Design({ parts: [part], noCorePlugins: true })
|
||||
const pattern = new design()
|
||||
expect(pattern.plugins.hooks.preRender).to.have.lengthOf(0)
|
||||
})
|
||||
|
@ -676,7 +676,7 @@ describe('Pattern', () => {
|
|||
],
|
||||
draft: (part) => part,
|
||||
}
|
||||
const design = new Design({ parts: [part] })
|
||||
const design = new Design({ parts: [part], noCorePlugins: true })
|
||||
const pattern = new design()
|
||||
pattern.draft()
|
||||
expect(pattern.plugins.hooks.preRender).to.have.lengthOf(1)
|
||||
|
@ -705,7 +705,7 @@ describe('Pattern', () => {
|
|||
plugins: [{ plugin: plugin1, condition: condition2 }],
|
||||
draft: (part) => part,
|
||||
}
|
||||
const design = new Design({ parts: [part, part2] })
|
||||
const design = new Design({ parts: [part, part2], noCorePlugins: true })
|
||||
const pattern = new design()
|
||||
pattern.__init()
|
||||
expect(pattern.config.plugins).to.be.an('object').that.has.all.keys('example1', 'example1_')
|
||||
|
@ -747,6 +747,7 @@ describe('Pattern', () => {
|
|||
}
|
||||
const design = new Design({
|
||||
parts: [part1, part2],
|
||||
noCorePlugins: true,
|
||||
})
|
||||
const pattern = new design()
|
||||
pattern.__init()
|
||||
|
|
|
@ -82,8 +82,8 @@ describe('Pattern', () => {
|
|||
draft: ({ part }) => part,
|
||||
}
|
||||
const plugin = { name: 'test' }
|
||||
const design = new Design({ parts: [test] })
|
||||
const pattern = new design({ only: ['you'] })
|
||||
const design = new Design({ parts: [test], noCorePlugins: true })
|
||||
const pattern = new design({ only: ['you'], noCorePlugins: true })
|
||||
pattern.use(plugin)
|
||||
pattern.use(plugin)
|
||||
pattern.use({ plugin })
|
||||
|
|
|
@ -25,7 +25,7 @@ const getPattern = (settings = {}, draft = false) => {
|
|||
return part
|
||||
},
|
||||
}
|
||||
const Pattern = new Design({ parts: [part] })
|
||||
const Pattern = new Design({ parts: [part], noCorePlugins: true })
|
||||
|
||||
return new Pattern(settings)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue