|
1372 | 1372 | "duckPlayer",
|
1373 | 1373 | "duckPlayerNative",
|
1374 | 1374 | "duckAiListener",
|
| 1375 | + "duckAiDataClearing", |
1375 | 1376 | "harmfulApis",
|
1376 | 1377 | "webCompat",
|
1377 | 1378 | "windowsPermissionUsage",
|
|
1385 | 1386 | ]
|
1386 | 1387 | );
|
1387 | 1388 | var platformSupport = {
|
1388 |
| - apple: ["webCompat", "duckPlayerNative", ...baseFeatures, "duckAiListener", "pageContext"], |
| 1389 | + apple: ["webCompat", "duckPlayerNative", ...baseFeatures, "duckAiListener", "duckAiDataClearing", "pageContext"], |
1389 | 1390 | "apple-isolated": [
|
1390 | 1391 | "duckPlayer",
|
1391 | 1392 | "duckPlayerNative",
|
1392 | 1393 | "brokerProtection",
|
| 1394 | + "breakageReporting", |
1393 | 1395 | "performanceMetrics",
|
1394 | 1396 | "clickToLoad",
|
1395 | 1397 | "messageBridge",
|
|
1420 | 1422 | "messageBridge",
|
1421 | 1423 | "webCompat",
|
1422 | 1424 | "pageContext",
|
1423 |
| - "duckAiListener" |
| 1425 | + "duckAiListener", |
| 1426 | + "duckAiDataClearing" |
1424 | 1427 | ],
|
1425 | 1428 | firefox: ["cookie", ...baseFeatures, "clickToLoad"],
|
1426 | 1429 | chrome: ["cookie", ...baseFeatures, "clickToLoad"],
|
@@ -10130,6 +10133,87 @@ ${truncatedWarning}
|
10130 | 10133 | __publicField(_DuckAiPromptTelemetry, "ONE_DAY_MS", 24 * 60 * 60 * 1e3);
|
10131 | 10134 | var DuckAiPromptTelemetry = _DuckAiPromptTelemetry;
|
10132 | 10135 |
|
| 10136 | + // src/features/duck-ai-data-clearing.js |
| 10137 | + init_define_import_meta_trackerLookup(); |
| 10138 | + var DuckAiDataClearing = class extends ContentFeature { |
| 10139 | + init() { |
| 10140 | + this.messaging.subscribe("duckAiClearData", (_2) => this.clearData()); |
| 10141 | + } |
| 10142 | + async clearData() { |
| 10143 | + let success = true; |
| 10144 | + const localStorageKeys = this.getFeatureSetting("chatsLocalStorageKeys"); |
| 10145 | + for (const localStorageKey of localStorageKeys) { |
| 10146 | + try { |
| 10147 | + this.clearSavedAIChats(localStorageKey); |
| 10148 | + } catch (error) { |
| 10149 | + success = false; |
| 10150 | + this.log.error("Error clearing saved chats:", error); |
| 10151 | + } |
| 10152 | + } |
| 10153 | + const indexDbNameObjectStoreNamePairs = this.getFeatureSetting("chatImagesIndexDbNameObjectStoreNamePairs"); |
| 10154 | + for (const [indexDbName, objectStoreName] of indexDbNameObjectStoreNamePairs) { |
| 10155 | + try { |
| 10156 | + await this.clearChatImagesStore(indexDbName, objectStoreName); |
| 10157 | + } catch (error) { |
| 10158 | + success = false; |
| 10159 | + this.log.error("Error clearing saved chat images:", error); |
| 10160 | + } |
| 10161 | + } |
| 10162 | + if (success) { |
| 10163 | + this.notify("duckAiClearDataCompleted"); |
| 10164 | + } else { |
| 10165 | + this.notify("duckAiClearDataFailed"); |
| 10166 | + } |
| 10167 | + } |
| 10168 | + clearSavedAIChats(localStorageKey) { |
| 10169 | + this.log.info(`Clearing '${localStorageKey}'`); |
| 10170 | + window.localStorage.removeItem(localStorageKey); |
| 10171 | + } |
| 10172 | + clearChatImagesStore(indexDbName, objectStoreName) { |
| 10173 | + this.log.info(`Clearing '${indexDbName}' object store`); |
| 10174 | + return new Promise((resolve, reject) => { |
| 10175 | + const request = window.indexedDB.open(indexDbName); |
| 10176 | + request.onerror = (event) => { |
| 10177 | + this.log.error("Error opening IndexedDB:", event); |
| 10178 | + reject(event); |
| 10179 | + }; |
| 10180 | + request.onsuccess = (_2) => { |
| 10181 | + const db = request.result; |
| 10182 | + if (!db) { |
| 10183 | + this.log.error("IndexedDB onsuccess but no db result"); |
| 10184 | + reject(new Error("No DB result")); |
| 10185 | + return; |
| 10186 | + } |
| 10187 | + if (!db.objectStoreNames.contains(objectStoreName)) { |
| 10188 | + this.log.info(`'${objectStoreName}' object store does not exist, nothing to clear`); |
| 10189 | + db.close(); |
| 10190 | + resolve(null); |
| 10191 | + return; |
| 10192 | + } |
| 10193 | + try { |
| 10194 | + const transaction = db.transaction([objectStoreName], "readwrite"); |
| 10195 | + const objectStore = transaction.objectStore(objectStoreName); |
| 10196 | + const clearRequest = objectStore.clear(); |
| 10197 | + clearRequest.onsuccess = () => { |
| 10198 | + db.close(); |
| 10199 | + resolve(null); |
| 10200 | + }; |
| 10201 | + clearRequest.onerror = (err) => { |
| 10202 | + this.log.error("Error clearing object store:", err); |
| 10203 | + db.close(); |
| 10204 | + reject(err); |
| 10205 | + }; |
| 10206 | + } catch (err) { |
| 10207 | + this.log.error("Exception during IndexedDB clearing:", err); |
| 10208 | + db.close(); |
| 10209 | + reject(err); |
| 10210 | + } |
| 10211 | + }; |
| 10212 | + }); |
| 10213 | + } |
| 10214 | + }; |
| 10215 | + var duck_ai_data_clearing_default = DuckAiDataClearing; |
| 10216 | + |
10133 | 10217 | // src/features/page-context.js
|
10134 | 10218 | init_define_import_meta_trackerLookup();
|
10135 | 10219 |
|
@@ -10513,6 +10597,7 @@ ${children}
|
10513 | 10597 | ddg_feature_exceptionHandler: ExceptionHandler,
|
10514 | 10598 | ddg_feature_apiManipulation: ApiManipulation,
|
10515 | 10599 | ddg_feature_duckAiListener: DuckAiListener,
|
| 10600 | + ddg_feature_duckAiDataClearing: duck_ai_data_clearing_default, |
10516 | 10601 | ddg_feature_pageContext: PageContext
|
10517 | 10602 | };
|
10518 | 10603 |
|
|
0 commit comments