bluedither 1.0.18 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fine-tuner/dev-middleware.js +6 -3
- package/fine-tuner/inject.js +7 -1
- package/fine-tuner/tuner.js +12 -7
- package/package.json +1 -1
- package/theme/generators/react.md +17 -3
|
@@ -18,17 +18,20 @@ import { resolve, dirname } from 'path';
|
|
|
18
18
|
const ENDPOINT = '/__bluedither/commit';
|
|
19
19
|
|
|
20
20
|
function findTokensPath() {
|
|
21
|
-
// Search from cwd
|
|
21
|
+
// Search from cwd — prioritize public/ (Vite serves static from there)
|
|
22
22
|
const cwd = process.cwd();
|
|
23
23
|
const paths = [
|
|
24
|
-
resolve(cwd, 'bluedither', 'tokens.json'),
|
|
25
24
|
resolve(cwd, 'public', 'bluedither', 'tokens.json'),
|
|
25
|
+
resolve(cwd, 'bluedither', 'tokens.json'),
|
|
26
26
|
resolve(cwd, 'theme', 'tokens.json'),
|
|
27
27
|
];
|
|
28
28
|
for (const p of paths) {
|
|
29
29
|
if (existsSync(p)) return p;
|
|
30
30
|
}
|
|
31
|
-
// Default to bluedither/
|
|
31
|
+
// Default to public/bluedither if public/ dir exists (Vite project), else bluedither/
|
|
32
|
+
if (existsSync(resolve(cwd, 'public'))) {
|
|
33
|
+
return resolve(cwd, 'public', 'bluedither', 'tokens.json');
|
|
34
|
+
}
|
|
32
35
|
return resolve(cwd, 'bluedither', 'tokens.json');
|
|
33
36
|
}
|
|
34
37
|
|
package/fine-tuner/inject.js
CHANGED
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
(async function () {
|
|
13
|
+
// Prevent double-init (React StrictMode re-fires effects in dev)
|
|
14
|
+
if (window.__BD_INJECT_LOADED__) return;
|
|
15
|
+
window.__BD_INJECT_LOADED__ = true;
|
|
16
|
+
|
|
13
17
|
// Find the base path to bluedither/ directory
|
|
14
18
|
const scriptEl = document.currentScript;
|
|
15
19
|
const scriptSrc = scriptEl?.src || '';
|
|
@@ -111,7 +115,9 @@
|
|
|
111
115
|
if (t.shader?.scale != null) params.scale = t.shader.scale;
|
|
112
116
|
if (t.shader?.size != null) params.size = t.shader.size;
|
|
113
117
|
if (t.shader?.rotation != null) params.rotation = t.shader.rotation;
|
|
114
|
-
shader.updateParams
|
|
118
|
+
if (typeof shader.updateParams === 'function') {
|
|
119
|
+
shader.updateParams(params);
|
|
120
|
+
}
|
|
115
121
|
return true;
|
|
116
122
|
};
|
|
117
123
|
|
package/fine-tuner/tuner.js
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* - Real-time shader parameter updates
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
// Prevent double-init (React StrictMode re-fires effects in dev)
|
|
13
|
+
if (!window.__BD_TUNER_LOADED__) {
|
|
14
|
+
window.__BD_TUNER_LOADED__ = true;
|
|
15
|
+
|
|
12
16
|
const tokens = structuredClone(
|
|
13
17
|
window.__BD_TOKENS__ ||
|
|
14
18
|
JSON.parse(document.querySelector('script[type="application/json"][data-bluedither-tokens]')?.textContent || '{}')
|
|
@@ -341,17 +345,17 @@ function addSegmented(section, label, tokenPath, options, extraCb) {
|
|
|
341
345
|
|
|
342
346
|
// ── Colors ──
|
|
343
347
|
const colorsSection = addSection('Colors');
|
|
344
|
-
addColor(colorsSection, 'Background', 'colors.background', '--bd-
|
|
348
|
+
addColor(colorsSection, 'Background', 'colors.background', '--bd-bg');
|
|
345
349
|
// Shader Front is declared first (but appended later) so Primary can reference it
|
|
346
350
|
let shaderFrontHandle;
|
|
347
|
-
addColor(colorsSection, 'Primary', 'colors.primary', '--bd-
|
|
351
|
+
addColor(colorsSection, 'Primary', 'colors.primary', '--bd-primary', (v) => {
|
|
348
352
|
// Sync shader front color: update token, UI, and live shader
|
|
349
353
|
shaderFrontHandle.setValue(v);
|
|
350
354
|
updateShader('colorFront', v);
|
|
351
355
|
});
|
|
352
|
-
addColor(colorsSection, 'Text', 'colors.text', '--bd-
|
|
353
|
-
addColor(colorsSection, 'CTA Background', 'colors.ctaBackground', '--bd-
|
|
354
|
-
addColor(colorsSection, 'CTA Text', 'colors.ctaText', '--bd-
|
|
356
|
+
addColor(colorsSection, 'Text', 'colors.text', '--bd-text');
|
|
357
|
+
addColor(colorsSection, 'CTA Background', 'colors.ctaBackground', '--bd-cta-bg');
|
|
358
|
+
addColor(colorsSection, 'CTA Text', 'colors.ctaText', '--bd-cta-text');
|
|
355
359
|
shaderFrontHandle = addColor(colorsSection, 'Shader Front', 'colors.shaderFront', null, (v) => updateShader('colorFront', v));
|
|
356
360
|
|
|
357
361
|
// ── Typography ──
|
|
@@ -360,8 +364,8 @@ addFontDropdown(typoSection, 'Primary Font', 'typography.primaryFont', '--bd-fon
|
|
|
360
364
|
addFontDropdown(typoSection, 'Secondary Font', 'typography.secondaryFont', '--bd-font-secondary');
|
|
361
365
|
addPxField(typoSection, 'Headline Size', 'typography.headline.referencePx', 32, 300, 1, '--bd-headline-size');
|
|
362
366
|
addPxField(typoSection, 'Headline LH', 'typography.headline.lineHeightPx', 24, 280, 1, '--bd-headline-lh');
|
|
363
|
-
addPxField(typoSection, 'Sub Size', 'typography.subHeadline.referencePx', 10, 48, 1, '--bd-
|
|
364
|
-
addPxField(typoSection, 'Sub LH', 'typography.subHeadline.lineHeightPx', 12, 80, 1, '--bd-
|
|
367
|
+
addPxField(typoSection, 'Sub Size', 'typography.subHeadline.referencePx', 10, 48, 1, '--bd-sub-size');
|
|
368
|
+
addPxField(typoSection, 'Sub LH', 'typography.subHeadline.lineHeightPx', 12, 80, 1, '--bd-sub-lh');
|
|
365
369
|
addPxField(typoSection, 'Logo Size', 'typography.logo.referencePx', 12, 80, 1, '--bd-logo-size');
|
|
366
370
|
addPxField(typoSection, 'Nav Size', 'typography.navItem.referencePx', 10, 48, 1, '--bd-nav-size');
|
|
367
371
|
|
|
@@ -499,3 +503,4 @@ commitBtn.onclick = async () => {
|
|
|
499
503
|
}
|
|
500
504
|
};
|
|
501
505
|
panel.appendChild(commitBtn);
|
|
506
|
+
} // end guard
|
package/package.json
CHANGED
|
@@ -80,9 +80,23 @@ function App() {
|
|
|
80
80
|
u_fit: 0, u_offsetX: 0, u_offsetY: 0,
|
|
81
81
|
}, { alpha: true, premultipliedAlpha: false }, SHADER_PARAMS.speed, 0, 2);
|
|
82
82
|
|
|
83
|
-
// CRITICAL: expose for tuner
|
|
84
|
-
window.__BD_SHADER__ =
|
|
85
|
-
|
|
83
|
+
// CRITICAL: expose wrapper with updateParams for the tuner
|
|
84
|
+
window.__BD_SHADER__ = {
|
|
85
|
+
updateParams(params) {
|
|
86
|
+
const uniforms = {};
|
|
87
|
+
if (params.colorFront !== undefined) uniforms.u_colorFront = getShaderColorFromString(params.colorFront);
|
|
88
|
+
if (params.colorBack !== undefined) uniforms.u_colorBack = getShaderColorFromString(params.colorBack);
|
|
89
|
+
if (params.shape !== undefined) uniforms.u_shape = DitheringShapes[params.shape] ?? DitheringShapes.warp;
|
|
90
|
+
if (params.type !== undefined) uniforms.u_type = DitheringTypes[params.type] ?? DitheringTypes['2x2'];
|
|
91
|
+
if (params.size !== undefined) uniforms.u_pxSize = params.size;
|
|
92
|
+
if (params.scale !== undefined) uniforms.u_scale = params.scale;
|
|
93
|
+
if (params.rotation !== undefined) uniforms.u_rotation = parseFloat(params.rotation) || 180;
|
|
94
|
+
if (Object.keys(uniforms).length > 0) mount.setUniforms(uniforms);
|
|
95
|
+
if (params.speed !== undefined) mount.setSpeed(params.speed);
|
|
96
|
+
},
|
|
97
|
+
dispose() { mount.dispose(); },
|
|
98
|
+
};
|
|
99
|
+
return () => { window.__BD_SHADER__.dispose(); window.__BD_SHADER__ = null; };
|
|
86
100
|
}, []);
|
|
87
101
|
|
|
88
102
|
// Load tuner in dev mode only
|