workbuddy-layered-psd-bridge 1.1.0 → 1.1.1
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/README.md +3 -3
- package/package.json +1 -1
- package/ps_backend/build_template.jsx +20 -4
- package/ps_backend/tests/font_selection.test.mjs +80 -0
- package/src/server.mjs +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# WorkBuddy Layered PSD Bridge 1.1.
|
|
1
|
+
# WorkBuddy Layered PSD Bridge 1.1.1
|
|
2
2
|
|
|
3
3
|
Create a real layered Photoshop PSD from a **structured poster plan** in WorkBuddy. Ardot is optional. The primary path needs only WorkBuddy and Windows desktop Photoshop on the same PC; WorkBuddy prepares Node for the Connector.
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ A single ImageGen poster or a WorkBuddy image-edit result is a bitmap, not a rec
|
|
|
10
10
|
|
|
11
11
|
## Requirements
|
|
12
12
|
|
|
13
|
-
- Windows WorkBuddy 5.0+ and Adobe Photoshop 2020 (v21) or newer. Photoshop **26.8.1**
|
|
13
|
+
- Windows WorkBuddy 5.0+ and Adobe Photoshop 2020 (v21) or newer. Photoshop **26.8.1** was used for the original RGB and CMYK builds and for a 1.1.1 font-selection regression. On another PC, Photoshop **25.0.0** exported a layered PSD with the 1.1.1 local candidate tarball: the export reported no warnings, and the user visually confirmed separate editable bold and regular text layers plus an independent rectangle layer. This is local candidate validation; public npm installation remains to be tested after publication.
|
|
14
14
|
- Node 20+ when running outside WorkBuddy. WorkBuddy's Connector `runtime.type: "node"` can provide it automatically.
|
|
15
15
|
- Enough RAM and disk for the chosen canvas. The backend checks dimensions, layer/asset counts, decoded image sizes, memory and disk estimates, and asset hashes before building. There is no single hardware minimum for every poster.
|
|
16
16
|
- Fonts used by editable text should be installed on the target PC. Substitution is reported; text overflow fails rather than silently shifting the design.
|
|
@@ -35,7 +35,7 @@ HTTPS image imports are restricted to trusted hosts; local paths and MCP image b
|
|
|
35
35
|
|
|
36
36
|
## Distribution
|
|
37
37
|
|
|
38
|
-
Publish `workbuddy-layered-psd-bridge@1.1.
|
|
38
|
+
Publish `workbuddy-layered-psd-bridge@1.1.1` to npm **after validating the candidate** and before uploading the matching WorkBuddy Connector ZIP. The market ZIP contains metadata, `mcp.json`, icon, and a Skill; it does not itself contain this executable package. WorkBuddy's managed Node runtime allows other users to connect without installing Node manually. The published 1.1.0 package is immutable and must not be republished.
|
|
39
39
|
|
|
40
40
|
The public WorkBuddy docs describe the built-in “设计创意” Ardot canvas but do not document a way for a third-party Connector to read its internal node tree directly. The direct WorkBuddy route therefore builds its **own explicit layer plan**. The Ardot route requires real MCP node data and has not been validated against a live account in this release.
|
|
41
41
|
|
package/package.json
CHANGED
|
@@ -84,9 +84,25 @@ function zjShape(parent, node) {
|
|
|
84
84
|
layer.name = node.name;
|
|
85
85
|
return layer;
|
|
86
86
|
}
|
|
87
|
+
// FONT_SELECTION_START
|
|
87
88
|
function zjNormalizeFont(value) {
|
|
88
89
|
return String(value || "").toLowerCase().replace(/[\s_\-]/g, "");
|
|
89
90
|
}
|
|
91
|
+
function zjPostScriptFamily(value) {
|
|
92
|
+
var raw = String(value || "");
|
|
93
|
+
var dash = raw.lastIndexOf("-");
|
|
94
|
+
if (dash > 0) {
|
|
95
|
+
var suffix = zjNormalizeFont(raw.substring(dash + 1));
|
|
96
|
+
if (/(bold|heavy|black|demi|regular|roman|italic|oblique|light|thin|medium)/.test(suffix))
|
|
97
|
+
return zjNormalizeFont(raw.substring(0, dash));
|
|
98
|
+
}
|
|
99
|
+
return zjNormalizeFont(raw);
|
|
100
|
+
}
|
|
101
|
+
function zjFontIsBold(font) {
|
|
102
|
+
var style = zjNormalizeFont(font.style);
|
|
103
|
+
var postScript = zjNormalizeFont(font.postScriptName);
|
|
104
|
+
return /(bold|heavy|black|demi)/.test(style) || /(bold|heavy|black|demi)(italic|oblique|mt)?$/.test(postScript);
|
|
105
|
+
}
|
|
90
106
|
function zjSetFont(textItem, textSpec, layerName) {
|
|
91
107
|
var requested = String(textSpec.fontFamily || "");
|
|
92
108
|
var wantBold = Number(textSpec.fontWeight || 400) >= 600;
|
|
@@ -97,15 +113,14 @@ function zjSetFont(textItem, textSpec, layerName) {
|
|
|
97
113
|
var font = app.fonts[i];
|
|
98
114
|
var family = zjNormalizeFont(font.family);
|
|
99
115
|
var postScript = zjNormalizeFont(font.postScriptName);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
var isBold =
|
|
116
|
+
var postScriptFamily = zjPostScriptFamily(font.postScriptName);
|
|
117
|
+
if (family != normalized && postScript != normalized && postScriptFamily != normalized) continue;
|
|
118
|
+
var isBold = zjFontIsBold(font);
|
|
103
119
|
if (isBold == wantBold) { best = font; weightMatched = true; break; }
|
|
104
120
|
if (best == null) best = font;
|
|
105
121
|
}
|
|
106
122
|
if (best != null) {
|
|
107
123
|
textItem.font = best.postScriptName;
|
|
108
|
-
if (zjNormalizeFont(best.family) != normalized) ZJ_WARNINGS.push("Font substituted for " + layerName);
|
|
109
124
|
if (!weightMatched) ZJ_WARNINGS.push("Requested font weight unavailable for " + layerName + "; used " + best.postScriptName);
|
|
110
125
|
return;
|
|
111
126
|
}
|
|
@@ -120,6 +135,7 @@ function zjSetFont(textItem, textSpec, layerName) {
|
|
|
120
135
|
}
|
|
121
136
|
throw new Error("No usable font for text layer: " + layerName);
|
|
122
137
|
}
|
|
138
|
+
// FONT_SELECTION_END
|
|
123
139
|
function zjText(parent, node) {
|
|
124
140
|
var layer = parent.artLayers.add();
|
|
125
141
|
layer.kind = LayerKind.TEXT;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import test from 'node:test';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import vm from 'node:vm';
|
|
6
|
+
|
|
7
|
+
const source = readFileSync(fileURLToPath(new URL('../build_template.jsx', import.meta.url)), 'utf8');
|
|
8
|
+
const startMarker = '// FONT_SELECTION_START';
|
|
9
|
+
const endMarker = '// FONT_SELECTION_END';
|
|
10
|
+
const start = source.indexOf(startMarker);
|
|
11
|
+
const end = source.indexOf(endMarker);
|
|
12
|
+
assert.ok(start >= 0 && end > start, 'font selection block must be present in the Photoshop script');
|
|
13
|
+
const fontSelectionSource = source.slice(start + startMarker.length, end);
|
|
14
|
+
|
|
15
|
+
function selectFont(fonts, fontFamily, fontWeight) {
|
|
16
|
+
const installed = new Set(fonts.map((font) => font.postScriptName));
|
|
17
|
+
let selected = null;
|
|
18
|
+
const textItem = {};
|
|
19
|
+
Object.defineProperty(textItem, 'font', {
|
|
20
|
+
get() { return selected; },
|
|
21
|
+
set(value) {
|
|
22
|
+
if (!installed.has(value)) throw new Error(`Font unavailable: ${value}`);
|
|
23
|
+
selected = value;
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const context = { app: { fonts }, ZJ_WARNINGS: [] };
|
|
27
|
+
vm.runInNewContext(fontSelectionSource, context, { timeout: 1000 });
|
|
28
|
+
context.zjSetFont(textItem, { fontFamily, fontWeight }, '标题');
|
|
29
|
+
return { selected, warnings: Array.from(context.ZJ_WARNINGS) };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
test('localized Photoshop family with matching PostScript name is not substituted', () => {
|
|
33
|
+
const result = selectFont([
|
|
34
|
+
{ family: '微软雅黑', postScriptName: 'MicrosoftYaHei', style: '常规' },
|
|
35
|
+
], 'Microsoft YaHei', 400);
|
|
36
|
+
assert.equal(result.selected, 'MicrosoftYaHei');
|
|
37
|
+
assert.deepEqual(result.warnings, []);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('localized bold variant is selected by PostScript family and weight', () => {
|
|
41
|
+
const result = selectFont([
|
|
42
|
+
{ family: '微软雅黑', postScriptName: 'MicrosoftYaHei', style: '常规' },
|
|
43
|
+
{ family: '微软雅黑', postScriptName: 'MicrosoftYaHei-Bold', style: '粗体' },
|
|
44
|
+
], 'Microsoft YaHei', 700);
|
|
45
|
+
assert.equal(result.selected, 'MicrosoftYaHei-Bold');
|
|
46
|
+
assert.deepEqual(result.warnings, []);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('a truly unavailable weight still produces a weight warning', () => {
|
|
50
|
+
const result = selectFont([
|
|
51
|
+
{ family: '微软雅黑', postScriptName: 'MicrosoftYaHei', style: '常规' },
|
|
52
|
+
], 'Microsoft YaHei', 700);
|
|
53
|
+
assert.equal(result.selected, 'MicrosoftYaHei');
|
|
54
|
+
assert.deepEqual(result.warnings, ['Requested font weight unavailable for 标题; used MicrosoftYaHei']);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('a missing family uses an installed fallback and reports it', () => {
|
|
58
|
+
const result = selectFont([
|
|
59
|
+
{ family: 'Arial', postScriptName: 'ArialMT', style: 'Regular' },
|
|
60
|
+
], 'Nonexistent Poster Font', 400);
|
|
61
|
+
assert.equal(result.selected, 'ArialMT');
|
|
62
|
+
assert.deepEqual(result.warnings, ["Missing font 'Nonexistent Poster Font' on 标题; used ArialMT"]);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('a family prefix is not mistaken for the requested family', () => {
|
|
66
|
+
const result = selectFont([
|
|
67
|
+
{ family: 'Arial Narrow', postScriptName: 'ArialNarrow-Bold', style: 'Bold' },
|
|
68
|
+
{ family: 'Arial', postScriptName: 'Arial-BoldMT', style: 'Bold' },
|
|
69
|
+
], 'Arial', 700);
|
|
70
|
+
assert.equal(result.selected, 'Arial-BoldMT');
|
|
71
|
+
assert.deepEqual(result.warnings, []);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('the word bold inside a family name does not mark its regular face bold', () => {
|
|
75
|
+
const result = selectFont([
|
|
76
|
+
{ family: 'Boldface Sans', postScriptName: 'BoldfaceSans-Regular', style: 'Regular' },
|
|
77
|
+
], 'Boldface Sans', 400);
|
|
78
|
+
assert.equal(result.selected, 'BoldfaceSans-Regular');
|
|
79
|
+
assert.deepEqual(result.warnings, []);
|
|
80
|
+
});
|
package/src/server.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import { getPosterDraft } from './direct.mjs';
|
|
|
16
16
|
|
|
17
17
|
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
18
18
|
const backendCli = path.join(packageRoot, 'ps_backend', 'cli.mjs');
|
|
19
|
-
const VERSION = '1.1.
|
|
19
|
+
const VERSION = '1.1.1';
|
|
20
20
|
|
|
21
21
|
function toolResult(value, isError = false) {
|
|
22
22
|
return { content: [{ type: 'text', text: JSON.stringify(value) }], structuredContent: value, isError };
|