use presets for common hide configurations
This commit is contained in:
parent
0c501f642d
commit
7551f09b8d
33 changed files with 228 additions and 170 deletions
|
@ -1,5 +1,6 @@
|
|||
import { pluginBust } from '@freesewing/plugin-bust'
|
||||
import { front as carltonFront } from '@freesewing/carlton'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function draftCarlitaFront({
|
||||
paperless,
|
||||
|
@ -501,10 +502,7 @@ function draftCarlitaFront({
|
|||
export const front = {
|
||||
name: 'carlita.front',
|
||||
from: carltonFront,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
measurements: ['highBust', 'bustSpan', 'hpsToBust'],
|
||||
plugins: [pluginBust],
|
||||
options: {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { back as bentBack } from '@freesewing/bent'
|
||||
import { calculateRatios } from './shared.mjs'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function draftCarltonBack({
|
||||
paperless,
|
||||
|
@ -230,10 +231,7 @@ function draftCarltonBack({
|
|||
export const back = {
|
||||
name: 'carlton.back',
|
||||
from: bentBack,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
measurements: ['chest', 'hpsToWaistBack'],
|
||||
options: {
|
||||
backPleat: 0.048,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { front as bentFront } from '@freesewing/bent'
|
||||
import { calculateRatios } from './shared.mjs'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function draftCarltonFront({
|
||||
paperless,
|
||||
|
@ -477,10 +478,7 @@ function draftCarltonFront({
|
|||
export const front = {
|
||||
name: 'carlton.front',
|
||||
from: bentFront,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
measurements: ['waist', 'waistToFloor', 'waistToSeat'],
|
||||
options: {
|
||||
chestEase: { pct: 10, min: 5, max: 20, menu: 'fit' },
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { back as titanBack } from '@freesewing/titan'
|
||||
import { front } from './front.mjs'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function draftCharlieBack({
|
||||
points,
|
||||
|
@ -346,10 +347,7 @@ export const back = {
|
|||
name: 'charlie.back',
|
||||
from: titanBack,
|
||||
after: front,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
options: {
|
||||
backPocketVerticalPlacement: { pct: 24, min: 18, max: 30, menu: 'pockets.backpockets' },
|
||||
backPocketHorizontalPlacement: { pct: 55, min: 48, max: 62, menu: 'pockets.backpockets' },
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { elastics } from '@freesewing/snapseries'
|
||||
import { pctBasedOn } from '@freesewing/core'
|
||||
import { pctBasedOn, hidePresets } from '@freesewing/core'
|
||||
import { front as titanFront } from '@freesewing/titan'
|
||||
|
||||
function draftCharlieFront({
|
||||
|
@ -366,10 +366,7 @@ function draftCharlieFront({
|
|||
export const front = {
|
||||
name: 'charlie.front',
|
||||
from: titanFront,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
measurements: [
|
||||
'crossSeam',
|
||||
'crossSeamFront',
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { front as frontBase } from '@freesewing/brian'
|
||||
import { back as backBase } from '@freesewing/brian'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
export function draftDianaFrontOrBack({
|
||||
measurements,
|
||||
|
@ -165,10 +166,7 @@ export function draftDianaFrontOrBack({
|
|||
export const front = {
|
||||
name: 'diana.front',
|
||||
from: frontBase,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
measurements: [
|
||||
'biceps',
|
||||
'chest',
|
||||
|
@ -244,10 +242,7 @@ export const front = {
|
|||
export const back = {
|
||||
name: 'diana.back',
|
||||
from: backBase,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
measurements: [
|
||||
'biceps',
|
||||
'chest',
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { sleeve as sleeveBase } from '@freesewing/brian'
|
||||
import { front } from './front.mjs'
|
||||
import { back } from './front.mjs'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function draftDianaSleeve({ sa, points, paths, Path, complete, paperless, macro, part }) {
|
||||
paths.seam = new Path()
|
||||
|
@ -67,9 +68,6 @@ export const sleeve = {
|
|||
name: 'diana.sleeve',
|
||||
from: sleeveBase,
|
||||
after: [front, back],
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
draft: draftDianaSleeve,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { sleeve as brianSleeve } from '@freesewing/brian'
|
||||
import { back } from './back.mjs'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function draftHueySleeve({
|
||||
Point,
|
||||
|
@ -94,8 +95,5 @@ export const sleeve = {
|
|||
from: brianSleeve,
|
||||
after: back,
|
||||
draft: draftHueySleeve,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { back as brianBack } from '@freesewing/brian'
|
||||
import { front } from './front.mjs'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function hugoBack({
|
||||
store,
|
||||
|
@ -116,10 +117,7 @@ function hugoBack({
|
|||
export const back = {
|
||||
name: 'hugo.back',
|
||||
from: brianBack,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
measurements: ['hips'],
|
||||
after: front,
|
||||
draft: hugoBack,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { front as brianFront } from '@freesewing/brian'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
import {
|
||||
collarEase,
|
||||
armholeDepthFactor,
|
||||
|
@ -189,10 +190,7 @@ function hugoFront({
|
|||
export const front = {
|
||||
name: 'hugo.front',
|
||||
from: brianFront,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
measurements: ['hips', 'waistToHips'],
|
||||
options: {
|
||||
collarEase,
|
||||
|
|
|
@ -2,6 +2,7 @@ import { sleeve as brianSleeve } from '@freesewing/brian'
|
|||
import { front } from './front.mjs'
|
||||
import { back } from './back.mjs'
|
||||
import { cuffEase, sleeveLengthBonus, ribbingHeight } from './options.mjs'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function hugoSleeve({
|
||||
utils,
|
||||
|
@ -223,10 +224,7 @@ function hugoSleeve({
|
|||
export const sleeve = {
|
||||
name: 'hugo.sleeve',
|
||||
from: brianSleeve,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
after: [front, back],
|
||||
options: { cuffEase, sleeveLengthBonus, ribbingHeight },
|
||||
draft: hugoSleeve,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { calculateRatios, backSideBoundary } from './shared.mjs'
|
||||
import { back as bentBack } from '@freesewing/bent'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
import {
|
||||
centerBackDart,
|
||||
hipsEase,
|
||||
|
@ -91,11 +92,7 @@ export const backBase = {
|
|||
name: 'jaeger.backBase',
|
||||
measurements: ['hips', 'waist'],
|
||||
from: bentBack,
|
||||
hide: {
|
||||
self: true,
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_ALL,
|
||||
options: {
|
||||
centerBackDart,
|
||||
hipsEase,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { backSideBoundary } from './shared.mjs'
|
||||
import { front as bentFront } from '@freesewing/bent'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
import {
|
||||
hipsEase,
|
||||
waistEase,
|
||||
|
@ -192,11 +193,7 @@ export const frontBase = {
|
|||
name: 'jaeger.frontBase',
|
||||
measurements: ['hips', 'waist'],
|
||||
from: bentFront,
|
||||
hide: {
|
||||
self: true,
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_ALL,
|
||||
options: {
|
||||
hipsEase,
|
||||
waistEase,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { topSleeve as bentTopSleeve } from '@freesewing/bent'
|
||||
import { sleeveVentLength, sleeveVentWidth } from './options.mjs'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function jaegerTopSleeve({
|
||||
paperless,
|
||||
|
@ -219,10 +220,7 @@ function jaegerTopSleeve({
|
|||
export const topSleeve = {
|
||||
name: 'jaeger.topSleeve',
|
||||
from: bentTopSleeve,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
options: { sleeveVentLength, sleeveVentWidth },
|
||||
draft: jaegerTopSleeve,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { underSleeve as bentUnderSleeve } from '@freesewing/bent'
|
||||
import { sleeveVentLength, sleeveVentWidth } from './options.mjs'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function jaegerUnderSleeve({
|
||||
paperless,
|
||||
|
@ -204,9 +205,6 @@ export const underSleeve = {
|
|||
name: 'jaeger.underSleeve',
|
||||
from: bentUnderSleeve,
|
||||
options: { sleeveVentLength, sleeveVentWidth },
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
draft: jaegerUnderSleeve,
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { back as bellaBack } from '@freesewing/bella'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
import * as options from './options.mjs'
|
||||
|
||||
function nobleBackPoints({ points, Path, paths, options, snippets, log, part }) {
|
||||
|
@ -83,11 +84,7 @@ function nobleBackPoints({ points, Path, paths, options, snippets, log, part })
|
|||
export const backPoints = {
|
||||
name: 'noble.backPoints',
|
||||
from: bellaBack,
|
||||
hide: {
|
||||
self: true,
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_ALL,
|
||||
options,
|
||||
draft: nobleBackPoints,
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { frontSideDart as bellaFront } from '@freesewing/bella'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
import * as options from './options.mjs'
|
||||
|
||||
function nobleFrontPoints({ log, points, Path, paths, snippets, options, macro, part }) {
|
||||
|
@ -318,11 +319,7 @@ function nobleFrontPoints({ log, points, Path, paths, snippets, options, macro,
|
|||
export const frontPoints = {
|
||||
name: 'noble.frontPoints',
|
||||
from: bellaFront,
|
||||
hide: {
|
||||
self: true,
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_ALL,
|
||||
options,
|
||||
draft: nobleFrontPoints,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { back as titanBack } from '@freesewing/titan'
|
||||
import { pctBasedOn } from '@freesewing/core'
|
||||
import { pctBasedOn, hidePresets } from '@freesewing/core'
|
||||
import { elastics, smallSteps } from '@freesewing/snapseries'
|
||||
|
||||
function pacoBack({
|
||||
|
@ -312,10 +312,7 @@ function pacoBack({
|
|||
export const back = {
|
||||
name: 'paco.back',
|
||||
from: titanBack,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
measurements: ['heel'],
|
||||
options: {
|
||||
// Constants
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { front as titanFront } from '@freesewing/titan'
|
||||
import { back } from './back.mjs'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function pacoFront({
|
||||
utils,
|
||||
|
@ -327,10 +328,7 @@ function pacoFront({
|
|||
export const front = {
|
||||
name: 'paco.front',
|
||||
from: titanFront,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
after: back,
|
||||
draft: pacoFront,
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { calculateReduction } from './shared.mjs'
|
||||
import { flipPlugin } from '@freesewing/plugin-flip'
|
||||
import { back as brianBack } from '@freesewing/brian'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
import {
|
||||
collarFactor,
|
||||
backDarts,
|
||||
|
@ -408,10 +409,7 @@ export const back = {
|
|||
plugins: [flipPlugin],
|
||||
measurements: ['waist', 'hips'],
|
||||
from: brianBack,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
options: {
|
||||
collarFactor,
|
||||
backDarts,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { front } from './front.mjs'
|
||||
import { sleeve as brianSleeve } from '@freesewing/brian'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
import {
|
||||
cuffOverlap,
|
||||
cuffDrape,
|
||||
|
@ -284,10 +285,7 @@ export const sleeve = {
|
|||
name: 'simon.sleeve',
|
||||
from: brianSleeve,
|
||||
after: front,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
options: {
|
||||
cuffOverlap,
|
||||
cuffDrape,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { front as brianFront, back as brianBack } from '@freesewing/brian'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function svenFrontBack({
|
||||
store,
|
||||
|
@ -128,10 +129,7 @@ export const front = {
|
|||
name: 'sven.front',
|
||||
from: brianFront,
|
||||
options,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
measurements,
|
||||
draft: svenFrontBack,
|
||||
}
|
||||
|
@ -140,10 +138,7 @@ export const back = {
|
|||
name: 'sven.back',
|
||||
from: brianBack,
|
||||
options,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
measurements,
|
||||
draft: svenFrontBack,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { sleeve as brianSleeve } from '@freesewing/brian'
|
||||
import { ribbing, front, back } from './frontback.mjs'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function svenSleeve({ store, sa, points, paths, Path, complete, paperless, macro, options, part }) {
|
||||
if (options.ribbing) {
|
||||
|
@ -72,10 +73,7 @@ function svenSleeve({ store, sa, points, paths, Path, complete, paperless, macro
|
|||
export const sleeve = {
|
||||
name: 'sven.sleeve',
|
||||
from: brianSleeve,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
after: [front, back],
|
||||
options: {
|
||||
ribbing,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { base } from '@freesewing/brian'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function teaganFront({
|
||||
utils,
|
||||
|
@ -166,10 +167,7 @@ export const front = {
|
|||
name: 'teagan.front',
|
||||
from: base,
|
||||
measurements: ['hips', 'waist'],
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
options: {
|
||||
bicepsEase: 0.05,
|
||||
shoulderEase: 0,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { sleevecap } from '@freesewing/brian'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function teaganSleeve({
|
||||
sa,
|
||||
|
@ -96,10 +97,7 @@ function teaganSleeve({
|
|||
export const sleeve = {
|
||||
name: 'teagan.sleeve',
|
||||
from: sleevecap,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
options: {
|
||||
sleeveEase: { pct: 15, min: 5, max: 35, menu: 'style' },
|
||||
},
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { constructMainDart, shapeSideSeam, dartPath } from './shared.mjs'
|
||||
import { back as brianBack } from '@freesewing/brian'
|
||||
import { backInset, shoulderInset, neckInset, centerBackDart, backScyeDart } from './options.mjs'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function wahidBack({
|
||||
points,
|
||||
|
@ -227,10 +228,7 @@ function wahidBack({
|
|||
export const back = {
|
||||
name: 'wahid.back',
|
||||
from: brianBack,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
measurements: ['hips', 'waist'],
|
||||
options: {
|
||||
backInset,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { constructMainDart, shapeSideSeam, dartPath } from './shared.mjs'
|
||||
import { front as brianFront } from '@freesewing/brian'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
import {
|
||||
frontOverlap,
|
||||
necklineDrop,
|
||||
|
@ -493,10 +494,7 @@ function wahidFront({
|
|||
export const front = {
|
||||
name: 'wahid.front',
|
||||
from: brianFront,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
measurements: ['hips', 'waist'],
|
||||
options: {
|
||||
frontOverlap,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { back as brianBack } from '@freesewing/brian'
|
||||
import { sharedDimensions } from './shared.mjs'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function yuriBack({
|
||||
store,
|
||||
|
@ -109,10 +110,7 @@ export const back = {
|
|||
sleeveLengthBonus: { pct: 1, min: 0, max: 10 },
|
||||
},
|
||||
},
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
options: {
|
||||
hipsEase: { pct: 0, min: 0, max: 10 },
|
||||
},
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { front as brianFront } from '@freesewing/brian'
|
||||
import { sharedDimensions } from './shared.mjs'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function yuriFront({
|
||||
store,
|
||||
|
@ -118,10 +119,7 @@ export const front = {
|
|||
sleeveLengthBonus: { pct: 1, min: 0, max: 10 },
|
||||
},
|
||||
},
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
options: {
|
||||
hipsEase: { pct: 0, min: 0, max: 10 },
|
||||
},
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { sleeve as brianSleeve } from '@freesewing/brian'
|
||||
import { hidePresets } from '@freesewing/core'
|
||||
|
||||
function yuriSleeve({ Point, Path, points, paths, complete, sa, paperless, macro, part }) {
|
||||
// Clear paths from Brian, but keep sleevecap
|
||||
|
@ -69,9 +70,6 @@ function yuriSleeve({ Point, Path, points, paths, complete, sa, paperless, macro
|
|||
export const sleeve = {
|
||||
name: 'yuri.sleeve',
|
||||
from: brianSleeve,
|
||||
hide: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
draft: yuriSleeve,
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import { Point } from './point.mjs'
|
|||
import { Path } from './path.mjs'
|
||||
import { Snippet } from './snippet.mjs'
|
||||
import { Store } from './store.mjs'
|
||||
import { hidePresets } from './pattern-config.mjs'
|
||||
import {
|
||||
beamIntersectsCircle,
|
||||
beamIntersectsX,
|
||||
|
@ -47,6 +48,8 @@ export {
|
|||
Store,
|
||||
version,
|
||||
Bezier,
|
||||
//consts
|
||||
hidePresets,
|
||||
// Utils
|
||||
beamIntersectsCircle,
|
||||
beamIntersectsX,
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
import { __addNonEnumProp, capitalize } from './utils.mjs'
|
||||
|
||||
export const hidePresets = {
|
||||
HIDE_ALL: {
|
||||
self: true,
|
||||
from: true,
|
||||
after: true,
|
||||
inherited: true,
|
||||
},
|
||||
HIDE_TREE: {
|
||||
from: true,
|
||||
inherited: true,
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the given plugin config
|
||||
*
|
||||
|
@ -328,18 +341,21 @@ PatternConfig.prototype.__addPartPlugins = function (part) {
|
|||
const depTypes = ['from', 'after']
|
||||
const exceptionTypes = ['never', 'always']
|
||||
PatternConfig.prototype.__resolvePartHiding = function (part) {
|
||||
if (part.hide) {
|
||||
let hide = part.hide
|
||||
if (typeof hide === 'string') hide = hidePresets[hide]
|
||||
if (!hide) return
|
||||
|
||||
// get the part's option priority
|
||||
const partDistance = this.__mutated.partDistance?.[part.name]
|
||||
const neverDistance = this.__hiding.never[part.name] || Infinity
|
||||
const alwaysDistance = this.__hiding.always[part.name] || Infinity
|
||||
|
||||
if (part.hide.self && (neverDistance > partDistance || alwaysDistance <= neverDistance))
|
||||
if (hide.self && (neverDistance > partDistance || alwaysDistance <= neverDistance))
|
||||
this.partHide[part.name] = true
|
||||
|
||||
exceptionTypes.forEach((e, i) => {
|
||||
if (part.hide[e]) {
|
||||
part.hide[e].forEach((p) => {
|
||||
if (hide[e]) {
|
||||
hide[e].forEach((p) => {
|
||||
const otherDistance = this.__hiding[exceptionTypes[Math.abs(i - 1)]][p] || Infinity
|
||||
|
||||
if (otherDistance > partDistance) {
|
||||
|
@ -351,11 +367,9 @@ PatternConfig.prototype.__resolvePartHiding = function (part) {
|
|||
}
|
||||
})
|
||||
|
||||
Object.keys(this.__hiding).forEach((k) => {
|
||||
if (!exceptionTypes.includes(k) && this.__hiding[k][part.name] === undefined)
|
||||
this.__hiding[k][part.name] = part.hide[k]
|
||||
depTypes.concat('inherited').forEach((k) => {
|
||||
if (this.__hiding[k][part.name] === undefined) this.__hiding[k][part.name] = hide[k]
|
||||
})
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Recursively register part dependencies
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import chai from 'chai'
|
||||
import { Design } from '../src/index.mjs'
|
||||
import { Design, hidePresets } from '../src/index.mjs'
|
||||
|
||||
const expect = chai.expect
|
||||
function hidePartMatcher(partName) {
|
||||
|
@ -14,7 +14,25 @@ function hidePartMatcher(partName) {
|
|||
`expected part ${partName} to NOT be hidden, but it is hidden`
|
||||
)
|
||||
}
|
||||
|
||||
function hidePartsMatcher(...partNames) {
|
||||
const hiddens = partNames.map((n) => {
|
||||
if (!this._obj.config.parts[n]) {
|
||||
throw new chai.AssertionError(`expected part \`${n}\` to exist in pattern`)
|
||||
this.fail()
|
||||
}
|
||||
return this._obj.__isPartHidden(n)
|
||||
})
|
||||
|
||||
this.assert(
|
||||
hiddens.every((v) => v === true),
|
||||
`expected parts [${partNames}] to be hidden, but hide check returns [${hiddens}]`,
|
||||
`expected parts [${partNames}] to NOT be hidden, but hide check returns [${hiddens}]`
|
||||
)
|
||||
}
|
||||
|
||||
chai.Assertion.addMethod('hidePart', hidePartMatcher)
|
||||
chai.Assertion.addMethod('hideParts', hidePartsMatcher)
|
||||
|
||||
const blankDraft = ({ part }) => part
|
||||
const blankPart = (name, config = {}) => ({
|
||||
|
@ -49,8 +67,7 @@ describe('Hiding parts', () => {
|
|||
})
|
||||
|
||||
it("Should NOT hide the part's dependencies", () => {
|
||||
expect(pattern).not.to.hidePart('fromPart')
|
||||
expect(pattern).not.to.hidePart('afterPart')
|
||||
expect(pattern).not.to.hidePart('fromPart', 'afterPart')
|
||||
})
|
||||
|
||||
describe('Inherited Parts', () => {
|
||||
|
@ -75,8 +92,7 @@ describe('Hiding parts', () => {
|
|||
pattern.__init()
|
||||
|
||||
it('Should NOT hide inherited `from` dependencies', () => {
|
||||
expect(pattern).not.to.hidePart('fromPart')
|
||||
expect(pattern).not.to.hidePart('mainPart')
|
||||
expect(pattern).not.to.hideParts('fromPart', 'mainPart')
|
||||
})
|
||||
|
||||
it('Should NOT hide inherited `after` dependencies', () => {
|
||||
|
@ -247,13 +263,11 @@ describe('Hiding parts', () => {
|
|||
})
|
||||
|
||||
it('Should hide the `after` dependencies of `from` dependencies', () => {
|
||||
expect(pattern).to.hidePart('afterPart')
|
||||
expect(pattern).to.hidePart('parentAfter')
|
||||
expect(pattern).to.hideParts('afterPart', 'parentAfter')
|
||||
})
|
||||
|
||||
it('Should hide the `from` dependencies of `from` dependencies', () => {
|
||||
expect(pattern).to.hidePart('fromPart')
|
||||
expect(pattern).to.hidePart('grandParent')
|
||||
expect(pattern).to.hideParts('fromPart', 'grandParent')
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -342,6 +356,107 @@ describe('Hiding parts', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('HIDE_ALL', () => {
|
||||
const grandParent = blankPart('grandParent')
|
||||
const parent = blankPart('parent', {
|
||||
from: grandParent,
|
||||
})
|
||||
|
||||
it('Should behave like `{self: true, after: true, from: true, inherited: true}`', () => {
|
||||
const main1 = blankPart('main1', {
|
||||
from: parent,
|
||||
after: afterPart,
|
||||
hide: hidePresets.HIDE_ALL,
|
||||
})
|
||||
|
||||
const Test = new Design({
|
||||
name: 'test',
|
||||
parts: [main1],
|
||||
})
|
||||
const pattern = new Test()
|
||||
pattern.__init()
|
||||
|
||||
expect(pattern).to.hideParts('grandParent', 'parent', 'main1', 'afterPart')
|
||||
})
|
||||
it('Should work when passed as a string', () => {
|
||||
const main1 = blankPart('main1', {
|
||||
from: parent,
|
||||
after: afterPart,
|
||||
hide: 'HIDE_ALL',
|
||||
})
|
||||
|
||||
const Test = new Design({
|
||||
name: 'test',
|
||||
parts: [main1],
|
||||
})
|
||||
const pattern = new Test()
|
||||
pattern.__init()
|
||||
|
||||
expect(pattern).to.hideParts('grandParent', 'parent', 'main1', 'afterPart')
|
||||
})
|
||||
})
|
||||
|
||||
describe('HIDE_TREE', () => {
|
||||
const grandParent = blankPart('grandParent', { from: fromPart, after: afterPart })
|
||||
const parentAfter = blankPart('parentAfter')
|
||||
const parent = blankPart('parent', { from: grandParent, after: parentAfter })
|
||||
const mainAfterFrom = blankPart('mainAfterFrom')
|
||||
const mainAfterAfter = blankPart('mainAfterAfter')
|
||||
const mainAfter = blankPart('mainAfter', { after: mainAfterAfter, from: mainAfterFrom })
|
||||
|
||||
it('Should behave like `{from: true, inherited: true}`', () => {
|
||||
const mainPart = {
|
||||
name: 'mainPart',
|
||||
from: parent,
|
||||
after: mainAfter,
|
||||
hide: hidePresets.HIDE_TREE,
|
||||
draft: blankDraft,
|
||||
}
|
||||
const Test = new Design({
|
||||
name: 'test',
|
||||
parts: [mainPart],
|
||||
})
|
||||
|
||||
const pattern = new Test()
|
||||
pattern.__init()
|
||||
|
||||
expect(pattern).to.hideParts(
|
||||
'grandParent',
|
||||
'fromPart',
|
||||
'afterPart',
|
||||
'parentAfter',
|
||||
`mainAfterFrom`,
|
||||
`parent`
|
||||
)
|
||||
expect(pattern).to.not.hideParts('mainPart', 'mainAfter', 'mainAfterAfter')
|
||||
})
|
||||
it('Should work when passed as a string', () => {
|
||||
const mainPart = {
|
||||
name: 'mainPart',
|
||||
from: parent,
|
||||
after: mainAfter,
|
||||
hide: 'HIDE_TREE',
|
||||
draft: blankDraft,
|
||||
}
|
||||
const Test = new Design({
|
||||
name: 'test',
|
||||
parts: [mainPart],
|
||||
})
|
||||
|
||||
const pattern = new Test()
|
||||
pattern.__init()
|
||||
|
||||
expect(pattern).to.hideParts(
|
||||
'grandParent',
|
||||
'fromPart',
|
||||
'afterPart',
|
||||
'parentAfter',
|
||||
`mainAfterFrom`,
|
||||
`parent`
|
||||
)
|
||||
expect(pattern).to.not.hideParts('mainPart', 'mainAfter', 'mainAfterAfter')
|
||||
})
|
||||
})
|
||||
describe('With complex inheritance', () => {
|
||||
it('Should use the strictest hiding configuration given by toplevel parts', () => {
|
||||
const greatGrandParent = blankPart('greatGrandParent')
|
||||
|
@ -363,9 +478,7 @@ describe('Hiding parts', () => {
|
|||
const pattern = new Test()
|
||||
pattern.__init()
|
||||
|
||||
expect(pattern).to.hidePart('parent')
|
||||
expect(pattern).to.hidePart('grandParent')
|
||||
expect(pattern).to.hidePart('greatGrandParent')
|
||||
expect(pattern).to.hideParts('parent', 'grandParent', 'greatGrandParent')
|
||||
})
|
||||
it('Should use inherited configurations that are not overridden', () => {
|
||||
const greatGrandParent = blankPart('greatGrandParent')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue