From b24dc8fee705e7197a0c047e926fbf2205371a16 Mon Sep 17 00:00:00 2001 From: kudo-sync-bot Date: Thu, 5 Dec 2024 06:56:18 -0800 Subject: [PATCH] =?UTF-8?q?Condensed=20`import()`,=20moved=20def=20+=20dep?= =?UTF-8?q?endencies=20inside=20`dependencies`=20for=20improved=20structur?= =?UTF-8?q?e=20=E2=86=9E=20[auto-sync=20from=20https://github.com/KudoAI/c?= =?UTF-8?q?hatgpt.js-chrome-starter]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- starters/chrome/extension/components/icons.js | 5 ++-- .../chrome/extension/components/modals.js | 26 ++++++++++--------- starters/chrome/extension/content.js | 2 +- starters/chrome/extension/popup/controller.js | 2 +- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/starters/chrome/extension/components/icons.js b/starters/chrome/extension/components/icons.js index 6e47916ac..5e18a8a0f 100644 --- a/starters/chrome/extension/components/icons.js +++ b/starters/chrome/extension/components/icons.js @@ -2,7 +2,8 @@ window.icons = { - import(dependencies) { Object.entries(dependencies).forEach(([name, dependency]) => this[name] = dependency) }, + import(dependencies) { // { app } + for (const name in dependencies) this[name] = dependencies[name] }, create({ name, size = 16, width, height, ...additionalAttrs }) { const iconData = icons[name], @@ -24,6 +25,6 @@ window.icons = { questionMark: { type: 'png', - get src() { return `${icons.app.urls.assetHost}@b5551ac/images/icons/question-mark/icon16.png` } + get src() { return `${icons.dependencies.app.urls.assetHost}@b5551ac/images/icons/question-mark/icon16.png` } } }; diff --git a/starters/chrome/extension/components/modals.js b/starters/chrome/extension/components/modals.js index 9e38edc2c..c75b8c27a 100644 --- a/starters/chrome/extension/components/modals.js +++ b/starters/chrome/extension/components/modals.js @@ -3,8 +3,10 @@ window.modals = { stack: [], // of types of undismissed modals - import(dependencies) { // { app, siteAlert } - Object.entries(dependencies).forEach(([name, dependency]) => this[name] = dependency) }, + dependencies: { + import(dependencies) { // { app, siteAlert } + for (const name in dependencies) this[name] = dependencies[name] } + }, open(modalType) { this.stack.unshift(modalType) // add to stack @@ -71,23 +73,23 @@ window.modals = { // Init buttons const modalBtns = [ - function getSupport(){ modals.safeWinOpen(`${modals.app.urls.gitHub}/issues`) }, - function rateUs() { modals.safeWinOpen(`${modals.app.urls.gitHub}/discussions`) }, - function moreAiExtensions(){ modals.safeWinOpen(modals.app.urls.relatedExtensions) } + function getSupport(){ modals.safeWinOpen(`${modals.dependencies.app.urls.gitHub}/issues`) }, + function rateUs() { modals.safeWinOpen(`${modals.dependencies.app.urls.gitHub}/discussions`) }, + function moreAiExtensions(){ modals.safeWinOpen(modals.dependencies.app.urls.relatedExtensions) } ] // Show modal - const aboutModal = this.siteAlert( - `${this.app.symbol} ${chrome.runtime.getManifest().name}`, // title + const aboutModal = this.dependencies.siteAlert( + `${this.dependencies.app.symbol} ${chrome.runtime.getManifest().name}`, // title `🏷️ Version: ` - + `${this.app.version}\n` + + `${this.dependencies.app.version}\n` + `Powered by: ` + `` - + `` - + 'chatgpt.js\n' + + `chatgpt.js\n' + `📜 Open source code:\n` - + `` - + this.app.urls.gitHub + '', + + `${this.dependencies.app.urls.gitHub}`, modalBtns, '', 451 ) diff --git a/starters/chrome/extension/content.js b/starters/chrome/extension/content.js index 6a681737b..13655cbcf 100644 --- a/starters/chrome/extension/content.js +++ b/starters/chrome/extension/content.js @@ -12,7 +12,7 @@ // Import APP data const { app } = await chrome.storage.sync.get('app') - modals.import({ app, siteAlert }) + modals.dependencies.import({ app, siteAlert }) // Add CHROME MSG listener chrome.runtime.onMessage.addListener(req => { // from service-worker.js + popup/index.html diff --git a/starters/chrome/extension/popup/controller.js b/starters/chrome/extension/popup/controller.js index 7bb1b2130..15763e7e3 100644 --- a/starters/chrome/extension/popup/controller.js +++ b/starters/chrome/extension/popup/controller.js @@ -10,7 +10,7 @@ // Import APP data const { app } = await chrome.storage.sync.get('app') - icons.import({ app }) // for src's using app.urls.assetHost + icons.dependencies.import({ app }) // for src's using app.urls.assetHost // Define FUNCTIONS