From e960d31d96c6c71d74103b150adbe4be9c9fb513 Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Wed, 28 Sep 2022 19:22:22 +0200 Subject: [PATCH] chore: Lab debug and types. See #2838 --- package.json | 1 + packages/core/src/pattern.mjs | 6 +++--- sites/lab/package.json | 2 ++ sites/shared/components/workbench/draft/error.js | 4 ++-- sites/shared/components/wrappers/workbench.js | 4 ++-- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 4f30048d92c..1c3efb038f0 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "?": "node scripts/help.mjs", "tips": "node scripts/help.mjs", "lab": "cd sites/lab && yarn start", + "lab-debug": "cd sites/lab && yarn start-debug", "kickstart": "npx lerna bootstrap && yarn buildall && yarn prepare && yarn tips", "cleanall": "lerna run clean", "test": "lerna run test", diff --git a/packages/core/src/pattern.mjs b/packages/core/src/pattern.mjs index ddfd9344078..efae09215cd 100644 --- a/packages/core/src/pattern.mjs +++ b/packages/core/src/pattern.mjs @@ -467,7 +467,7 @@ Pattern.prototype.__addPartOptions = function (part) { this.__mutated.optionDistance[optionName] = this.__mutated.partDistance?.[part.name] || 0 // Keep design parts immutable in the pattern or risk subtle bugs this.config.options[optionName] = Object.freeze(part.options[optionName]) - this.store.log.debug(`🔵 __${optionName}__ option loaded from \`${part.name}\``) + this.store.log.debug(`🔵 __${optionName}__ option loaded from part \`${part.name}\``) } else if ( this.__mutated.optionDistance[optionName] > this.__mutated.partDistance[part.name] ) { @@ -850,7 +850,7 @@ Pattern.prototype.__loadOptionDefaults = function () { * Loads a plugin * * @private - * @param {object} plugin - The plugin object + * @param {object} plugin - The plugin object, or an object with `plugin` and `condition` keys * @param {object} data - Any plugin data to load * @return {Pattern} this - The Pattern instance */ @@ -1393,7 +1393,7 @@ Pattern.prototype.__snappedPercentageOption = function (optionName, set) { * Loads a conditional plugin * * @private - * @param {object} plugin - The plugin object + * @param {object} plugin - An object with `plugin` and `condition` keys * @return {Pattern} this - The Pattern instance */ Pattern.prototype.__useIf = function (plugin) { diff --git a/sites/lab/package.json b/sites/lab/package.json index 763045c4457..dc4feb15d70 100644 --- a/sites/lab/package.json +++ b/sites/lab/package.json @@ -5,7 +5,9 @@ "scripts": { "dev": "node --experimental-json-modules ../../node_modules/.bin/next dev -p 8000", "develop": "node --experimental-json-modules ../../node_modules/.bin/next dev -p 8000", + "dev-debug": "node --inspect --experimental-json-modules ../../node_modules/.bin/next dev -p 8000", "start": "yarn prebuild && yarn dev", + "start-debug": "yarn prebuild && yarn dev-debug", "prebuild": "node --experimental-json-modules ../shared/prebuild/index.mjs", "cibuild": "yarn prebuild && node --experimental-json-modules ../../node_modules/.bin/next build", "build": "node --experimental-json-modules ../../node_modules/.bin/next build", diff --git a/sites/shared/components/workbench/draft/error.js b/sites/shared/components/workbench/draft/error.js index 0cb6bf54f64..36745261941 100644 --- a/sites/shared/components/workbench/draft/error.js +++ b/sites/shared/components/workbench/draft/error.js @@ -1,6 +1,6 @@ import DefaultErrorView from 'shared/components/error/view' -const Error = ({ logs=[], updateGist }) => { +const Error = ({ logs = [], updateGist }) => { let errors = 0 let warnings = 0 for (const log of logs) { @@ -13,7 +13,7 @@ const Error = ({ logs=[], updateGist }) => {
  • Check the{' '}
  • Check the partially rendered pattern below to see which areas are problematic
  • diff --git a/sites/shared/components/wrappers/workbench.js b/sites/shared/components/wrappers/workbench.js index deac795442b..076381492d8 100644 --- a/sites/shared/components/wrappers/workbench.js +++ b/sites/shared/components/wrappers/workbench.js @@ -115,9 +115,9 @@ const WorkbenchWrapper = ({ app, design, preload = false, from = false, layout = if (['draft', 'logs', 'test', 'printingLayout'].indexOf(gist._state?.view) !== -1) { gist.embed = true // get the appropriate layout for the view - const layout = gist.layouts?.[gist._state.view] || gist.layout || true + gist.layout = gist.layouts?.[gist._state.view] || gist.layout || true // hand it separately to the design - draft = new design({ ...gist, layout }) + draft = new design(gist) draft.__init() // add theme to svg renderer