dazscript-framework 1.0.9 → 1.0.10

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 CHANGED
@@ -302,8 +302,9 @@ Custom action icons are selected from `action(...)` metadata and sibling image f
302
302
  Setup dialog header assets are optional and are discovered beside `src/Setup.dsa.ts`:
303
303
 
304
304
  1. `src/Setup.header.png`
305
- 2. `src/Setup.png`
306
- 3. `src/Setup.dsa.png` legacy fallback
305
+ 2. `src/Setup.tip.png`
306
+ 3. `src/Setup.png`
307
+ 4. `src/Setup.dsa.png` legacy fallback
307
308
 
308
309
  Header text can be placed in `src/Setup.header.html`, `src/Setup.header.md`, or `src/Setup.header.txt`, with `src/Setup.html`, `src/Setup.md`, and `src/Setup.txt` as script-named fallbacks. The installer generator embeds that text into `Setup.dsa.ts`, so Daz Studio does not need to read the text file at setup time. The setup dialog renders the header body with `DzTextBrowser` rich text support; no Markdown conversion is performed. The image remains a deployed PNG asset and is resolved relative to the generated setup script at runtime.
309
310
 
@@ -279,6 +279,7 @@ function toPosix(filePath) {
279
279
  function resolveSetupHeaderImage(workdir) {
280
280
  const candidates = [
281
281
  path.join(workdir, 'src', 'Setup.header.png'),
282
+ path.join(workdir, 'src', 'Setup.tip.png'),
282
283
  path.join(workdir, 'src', 'Setup.png'),
283
284
  path.join(workdir, 'src', 'Setup.dsa.png'),
284
285
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dazscript-framework",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "author": "Freddy Diaz",
5
5
  "license": "MPL-2.0",
6
6
  "description": "",
@@ -1,6 +1,7 @@
1
1
  import LayoutBuilder from './layout-builder'
2
2
  import { createWidget } from './widget-builder'
3
3
  import { WidgetBuilderContext } from './widgets-builder'
4
+ import { getScriptPath } from '@dsf/helpers/script-helper'
4
5
 
5
6
  export type DialogHeaderOptions = {
6
7
  image?: Pixmap
@@ -20,13 +21,21 @@ const escapeHtml = (value: string): string =>
20
21
  .replace(/'/g, ''')
21
22
  .replace(/\r?\n/g, '<br>')
22
23
 
24
+ const resolveImagePath = (filePath: string): string => {
25
+ const value = String(filePath ?? '').replace(/\\/g, '/')
26
+ if (!value) return ''
27
+ if (value.indexOf(':') >= 0 || value.charAt(0) === '/') return value
28
+
29
+ return `${getScriptPath()}/${value.replace(/^\.\//, '')}`
30
+ }
31
+
23
32
  export class DialogHeaderBuilder {
24
33
  constructor(
25
34
  private readonly context: WidgetBuilderContext,
26
35
  private readonly options: DialogHeaderOptions
27
36
  ) { }
28
37
 
29
- build(): DzHBoxLayout {
38
+ build(): DzWidget {
30
39
  const height = this.options.height ?? 96
31
40
  const imageWidth = this.options.imageWidth ?? height
32
41
  const html = this.options.html ?? (
@@ -35,18 +44,23 @@ export class DialogHeaderBuilder {
35
44
  : ''
36
45
  )
37
46
 
38
- return LayoutBuilder
39
- .create(this.context)
40
- .direction('horizontal')
41
- .build(() => {
42
- this.buildImage(height, imageWidth)
43
- this.buildText(html, height)
44
- }) as DzHBoxLayout
47
+ return createWidget(this.context).build(DzWidget, (container) => {
48
+ container.setFixedHeight(height)
49
+
50
+ LayoutBuilder
51
+ .create(this.context)
52
+ .parent(container)
53
+ .direction('horizontal')
54
+ .build(() => {
55
+ this.buildImage(height, imageWidth)
56
+ this.buildText(html, height)
57
+ })
58
+ })
45
59
  }
46
60
 
47
61
  private buildImage(height: number, imageWidth: number): void {
48
62
  const pixmap = this.options.image ?? (
49
- this.options.imagePath ? new Pixmap(this.options.imagePath) : null
63
+ this.options.imagePath ? new Pixmap(resolveImagePath(this.options.imagePath)) : null
50
64
  )
51
65
  if (!pixmap) return
52
66
 
@@ -113,11 +113,25 @@ describe('install generator setup header', () => {
113
113
  const projectDir = makeProject()
114
114
  writeScript(projectDir, 'render-tools')
115
115
  writePng(projectDir, 'Setup.header.png')
116
+ writePng(projectDir, 'Setup.tip.png')
116
117
  writePng(projectDir, 'Setup.png')
117
118
 
118
119
  const setup = generateSetup(projectDir)
119
120
 
120
121
  expect(setup).toContain('"headerImagePath":"./Setup.header.png"')
122
+ expect(setup).not.toContain('"headerImagePath":"./Setup.tip.png"')
123
+ expect(setup).not.toContain('"headerImagePath":"./Setup.png"')
124
+ })
125
+
126
+ it('uses the setup tip image before the generic setup image', () => {
127
+ const projectDir = makeProject()
128
+ writeScript(projectDir, 'render-tools')
129
+ writePng(projectDir, 'Setup.tip.png')
130
+ writePng(projectDir, 'Setup.png')
131
+
132
+ const setup = generateSetup(projectDir)
133
+
134
+ expect(setup).toContain('"headerImagePath":"./Setup.tip.png"')
121
135
  expect(setup).not.toContain('"headerImagePath":"./Setup.png"')
122
136
  })
123
137