dazscript-framework 1.0.2 → 1.0.3

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
@@ -254,7 +254,7 @@ Applying the dialog:
254
254
  - Affected toolbars are rebuilt; empty framework-created toolbars are removed
255
255
  - Selected keyboard shortcut rows are applied after actions are installed
256
256
 
257
- This replaces the older `Install.dsa.ts` / `Uninstall.dsa.ts` pattern. The installer generator removes those legacy files if they exist, except when shortcut restoration is needed.
257
+ This replaces the older `Install.dsa.ts` / `Uninstall.dsa.ts` pattern. The installer generator removes those legacy files if they exist.
258
258
 
259
259
  ### Setup Keyboard Shortcuts
260
260
 
@@ -288,7 +288,7 @@ Before changing a non-custom Daz Studio action shortcut, setup writes the origin
288
288
  App.getAppDataPath()/<appDataPath>/Installer/keyboard-shortcuts-backup.json
289
289
  ```
290
290
 
291
- When shortcut JSON exists, the generator also writes `src/Uninstall.dsa.ts`. Running that uninstall script restores backed-up non-custom shortcuts. Custom action shortcuts are not backed up because uninstalling the custom action removes the shortcut with the action.
291
+ Shortcut setup is part of the generated setup dialog. The generator does not create a separate shortcut-only uninstall script.
292
292
 
293
293
  ---
294
294
 
@@ -29,14 +29,6 @@ setup(${data}, ${JSON.stringify(options)});
29
29
  `;
30
30
  }
31
31
 
32
- function generateUninstallTemplate(options) {
33
- return `
34
- import { restoreSetupKeyboardShortcuts as restoreShortcuts } from '@dsf/helpers/custom-action-installer-helper';
35
-
36
- restoreShortcuts(${JSON.stringify(options)});
37
- `;
38
- }
39
-
40
32
  function literalValue(node) {
41
33
  if (!node) {
42
34
  return undefined;
@@ -329,9 +321,7 @@ function generateInstallerFiles(workdir, options) {
329
321
  const uninstallPath = path.join(workdir, 'src', 'Uninstall.dsa.ts');
330
322
  if (fs.existsSync(installPath)) fs.unlinkSync(installPath);
331
323
 
332
- if (shortcutData.shortcuts && shortcutData.shortcuts.length > 0) {
333
- fs.writeFileSync(path.join(workdir, 'src', 'Uninstall.dsa.ts'), generateUninstallTemplate(setupOptions));
334
- } else if (fs.existsSync(uninstallPath)) {
324
+ if (fs.existsSync(uninstallPath)) {
335
325
  fs.unlinkSync(uninstallPath);
336
326
  }
337
327
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dazscript-framework",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "author": "Freddy Diaz",
5
5
  "license": "MPL-2.0",
6
6
  "description": "",
@@ -78,6 +78,10 @@ export type CustomActionTargets = {
78
78
  toolbar: boolean
79
79
  }
80
80
 
81
+ type ApplyCustomActionOptions = {
82
+ deferToolbar?: boolean
83
+ }
84
+
81
85
  type CustomActionCandidate = {
82
86
  name: string
83
87
  text: string
@@ -377,13 +381,18 @@ export const getInstalledCustomActionState = (action: CustomAction, scriptsPath:
377
381
  }
378
382
  }
379
383
 
380
- export const applyCustomActionTargets = (action: CustomAction, targets: CustomActionTargets, scriptsPath: string = getScriptPath()) => {
384
+ export const applyCustomActionTargets = (
385
+ action: CustomAction,
386
+ targets: CustomActionTargets,
387
+ scriptsPath: string = getScriptPath(),
388
+ options: ApplyCustomActionOptions = {}
389
+ ): CustomAction | null => {
381
390
  const resolvedAction = resolveActionPaths(action, scriptsPath)
382
391
  const shouldInstall = targets.menu || targets.toolbar
383
392
 
384
393
  if (!shouldInstall) {
385
394
  removeCustomActionTargets(action, { menu: true, toolbar: true }, scriptsPath)
386
- return
395
+ return null
387
396
  }
388
397
 
389
398
  const customAction = createOrUpdateCustomAction(action, resolvedAction)
@@ -392,9 +401,11 @@ export const applyCustomActionTargets = (action: CustomAction, targets: CustomAc
392
401
  addToMenu(customAction)
393
402
  }
394
403
 
395
- if (targets.toolbar && action.toolbar) {
404
+ if (targets.toolbar && action.toolbar && !options.deferToolbar) {
396
405
  addToToolbar(customAction)
397
406
  }
407
+
408
+ return customAction
398
409
  }
399
410
 
400
411
  export const removeCustomActionTargets = (action: CustomAction, targets: CustomActionTargets, scriptsPath: string = getScriptPath()) => {
@@ -561,24 +561,31 @@ export const showSetupCustomActionsDialog = (actions: CustomAction[], options: s
561
561
 
562
562
  debug(`[Setup] applying ${selections.actions.filter(selection => selection.selected).length}/${selections.actions.length} selected actions`)
563
563
 
564
- const removedToolbarNames = new CustomSet<string>()
564
+ const touchedToolbarNames = new CustomSet<string>()
565
+ const selectedToolbarActions: CustomAction[] = []
565
566
 
566
567
  progress('Setting Up Scripts', selections.actions, (selection) => {
567
568
  debug(`[Setup] ${selection.selected ? 'install' : 'remove'} "${selection.action.text}"`)
568
569
 
570
+ if (selection.supportsToolbar && selection.action.toolbar) {
571
+ touchedToolbarNames.add(selection.action.toolbar)
572
+ }
573
+
569
574
  if (selection.selected) {
570
- applyCustomActionTargets({
575
+ const customAction = applyCustomActionTargets({
571
576
  ...selection.action,
572
577
  shortcut: selection.effectiveShortcut
573
578
  }, {
574
579
  menu: selection.supportsMenu,
575
580
  toolbar: selection.supportsToolbar
581
+ }, undefined, {
582
+ deferToolbar: true
576
583
  })
577
- return
578
- }
579
584
 
580
- if (selection.supportsToolbar && selection.action.toolbar) {
581
- removedToolbarNames.add(selection.action.toolbar)
585
+ if (customAction && selection.supportsToolbar && selection.action.toolbar) {
586
+ selectedToolbarActions.push(customAction)
587
+ }
588
+ return
582
589
  }
583
590
 
584
591
  removeCustomActionTargets(selection.action, {
@@ -587,14 +594,11 @@ export const showSetupCustomActionsDialog = (actions: CustomAction[], options: s
587
594
  })
588
595
  })
589
596
 
590
- removedToolbarNames.forEach((toolbarName) => {
597
+ touchedToolbarNames.forEach((toolbarName) => {
591
598
  clearToolbar(toolbarName)
592
599
 
593
- const stillSelected = selections.actions.filter(s => s.selected && s.supportsToolbar && s.action.toolbar === toolbarName)
594
- stillSelected.forEach((s) => addToToolbar({
595
- ...s.action,
596
- shortcut: s.effectiveShortcut
597
- }))
600
+ const stillSelected = selectedToolbarActions.filter(action => action.toolbar === toolbarName)
601
+ stillSelected.forEach((action) => addToToolbar(action))
598
602
  debug(`[Setup] Toolbar ${toolbarName} rebuilt with ${stillSelected.length} remaining actions`)
599
603
 
600
604
  if (stillSelected.length === 0) {