// import {helloHelper} from 'helper.js' // helloHelper2 = require('./helper.js') // for organizational proposes const helper = require('./helper') const sdapi = require('./sdapi') const exportHelper = require('./export_png') const outpaint = require('./outpaint') const psapi = require('./psapi') const app = window.require('photoshop').app const { batchPlay } = require('photoshop').action const { executeAsModal } = require('photoshop').core const dialog_box = require('./dialog_box') // const {entrypoints} = require('uxp') const html_manip = require('./html_manip') const export_png = require('./export_png') const viewer = require('./viewer') const selection = require('./selection') const util_layer = require('./utility/layer') const eventHandler = async (event, descriptor) => { // console.log("event got triggered!") try{ const isSelectionActive = await psapi.checkIfSelectionAreaIsActive() if (isSelectionActive){ const [final_width,final_height] = await selection.selectionToFinalWidthHeight() console.log("(final_width,final_height):",final_width,final_height) console.log(event, descriptor) html_manip.autoFillInWidth(final_width) html_manip.autoFillInHeight(final_height) // if selection has changed : change the color and text generate btn "Generate" color "red" const new_selection = await psapi.getSelectionInfoExe() if(await hasSelectionChanged(new_selection,g_selection)){ sessionStartHtml(false)//generate ,red color }else{ sessionStartHtml(true)//generate more, green color } // } }catch(e){ console.warn(e) } } require("photoshop").action.addNotificationListener(['set','move'], eventHandler); // require("photoshop").action.addNotificationListener(['historyStateChanged'], eventHandler); // const onSelect = (event, descriptor) => { // // console.log(`descriptor._target?.[0]._ref === "layer" : `,descriptor._target?.[0]._ref === "layer" ) // // console.log(`descriptor._target?.[0]._name === "Mask -- Paint White to Mask -- temporary" : `,descriptor._target?.[0]._name === "Mask -- Paint White to Mask -- temporary" ) // console.log(event,descriptor) // // if(descriptor._target?.[0]._ref === "layer" && descriptor._target?.[0]._name === "Mask -- Paint White to Mask -- temporary") { // // // -> The layer with name "Test Layer 1" was selected // // console.log(" onSelect event got triggered!") // // console.log("descriptor: ",descriptor) // // // console.log() // // } // } // require("photoshop").action.addNotificationListener(['all'], onSelect); async function getUniqueDocumentId () { try { uniqueDocumentId = await psapi.readUniqueDocumentIdExe() console.log( 'getUniqueDocumentId(): uniqueDocumentId: ', uniqueDocumentId ) // Regular expression to check if string is a valid UUID const regexExp = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi // String with valid UUID separated by dash // const str = 'a24a6ea4-ce75-4665-a070-57453082c256' const isValidId = regexExp.test(uniqueDocumentId) // true console.log('isValidId: ', isValidId) if (isValidId == false) { let uuid = self.crypto.randomUUID() console.log(uuid) // for example "36b8f84d-df4e-4d49-b662-bcde71a8764f" await psapi.saveUniqueDocumentIdExe(uuid) uniqueDocumentId = uuid } } catch (e) { console.warn('warning Document Id may not be valid', e) } return uniqueDocumentId } // document // .getElementById('btnLinkCurrentDocument') // .addEventListener('click', async () => { // await getUniqueDocumentId() // }) // attach event listeners for tabs Array.from(document.querySelectorAll(".sp-tab")).forEach(theTab => { theTab.onclick = () => { // localStorage.setItem("currentTab", theTab.getAttribute("id")); Array.from(document.querySelectorAll(".sp-tab")).forEach(aTab => { if (aTab.getAttribute("id") === theTab.getAttribute("id")) { aTab.classList.add("selected"); } else { aTab.classList.remove("selected"); } }); Array.from(document.querySelectorAll(".sp-tab-page")).forEach(tabPage => { if (tabPage.getAttribute("id").startsWith(theTab.getAttribute("id"))) { tabPage.classList.add("visible"); } else { tabPage.classList.remove("visible"); } }); } }); document.getElementById("sp-viewer-tab").addEventListener('click',()=>{ moveElementToAnotherTab("batchNumberUi","batchNumberViewerTabContainer") }) document.getElementById("sp-stable-diffusion-ui-tab").addEventListener('click', ()=>{ moveElementToAnotherTab("batchNumberUi","batchNumberSdUiTabContainer") }) // entrypoints.setup({ // panels:{ // vanilla: ()=>{ // console.log("you are in the vanilla panel") // }, // experimental_1: ()=>{ // console.log("you are in the experimental_1 panel") // } // } // } // ) // just a number that shouldn't unique enough that we will use when save files. // each session will get a number from 1 to 1000000 const random_session_id = Math.floor((Math.random() * 1000000) + 1); function getSelectedText() // JavaScript { // // Obtain the object reference for the