From 84bd0e6f430a8602f4b335204ce649a94ba0aeeb Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Thu, 16 Nov 2023 09:15:05 +0000 Subject: [PATCH] correct import --- build/app/public/js/base.js | 469 ++++++++++++------------- shared/js/browser/ios-communication.js | 3 +- 2 files changed, 235 insertions(+), 237 deletions(-) diff --git a/build/app/public/js/base.js b/build/app/public/js/base.js index b2c0a66b..f520bb18 100644 --- a/build/app/public/js/base.js +++ b/build/app/public/js/base.js @@ -12465,200 +12465,18 @@ } }); - // shared/js/browser/windows-communication.js - var windows_communication_exports = {}; - __export(windows_communication_exports, { - OpenInNewTab: () => OpenInNewTab, - OpenSettings: () => OpenSettings, - SetSize: () => SetSize, - SubmitBrokenSiteReport: () => SubmitBrokenSiteReport, - backgroundMessage: () => backgroundMessage3, - fetch: () => fetch3, - firstRenderComplete: () => firstRenderComplete2, - getBackgroundTabData: () => getBackgroundTabData3, - handleIncomingMessage: () => handleIncomingMessage, - setup: () => setup3 - }); - function handleViewModelUpdate(viewModel) { - upgradedHttps2 = viewModel.upgradedHttps; - parentEntity2 = viewModel.parentEntity || {}; - permissionsData2 = viewModel.permissions || []; - certificateData2 = viewModel.certificates || []; - protections2 = viewModel.protections; - trackerBlockingData2 = createTabData(viewModel.tabUrl, upgradedHttps2, viewModel.protections, viewModel.rawRequestData); - trackerBlockingData2.cookiePromptManagementStatus = viewModel.cookiePromptManagementStatus; - if (trackerBlockingData2) - trackerBlockingData2.upgradedHttps = upgradedHttps2; - resolveInitialRender2(); - } - function windowsPostMessage(name, data) { - assert(typeof window.chrome.webview?.postMessage === "function"); - window.chrome.webview.postMessage({ - Feature: "PrivacyDashboard", - Name: name, - Data: data - }); - } - async function fetch3(message) { - if (message instanceof SubmitBrokenSiteReportMessage) { - SubmitBrokenSiteReport({ - category: message.category, - description: message.description - }); - return; - } - if (message instanceof OpenSettingsMessages) { - OpenSettings({ - target: message.target - }); - return; - } - if (message instanceof SetListsMessage) { - for (const listItem of message.lists) { - const { list, value } = listItem; - if (list !== "allowlisted") { - if (!window.__playwright) - console.warn("only `allowlisted` is currently supported on windows"); - continue; - } - const isProtected = value === false; - const eventOrigin = message.eventOrigin; - if (isProtected) { - windowsPostMessage("RemoveFromAllowListCommand", { eventOrigin }); - } else { - windowsPostMessage("AddToAllowListCommand", { eventOrigin }); - } - } - } - if (message instanceof UpdatePermissionMessage) { - windowsPostMessage("SetPermissionCommand", { - permission: message.id, - value: message.value - }); - } - } - function SubmitBrokenSiteReport(report2) { - windowsPostMessage("SubmitBrokenSiteReport", { - category: report2.category, - description: report2.description - }); - } - function OpenInNewTab(args) { - windowsPostMessage("OpenInNewTab", { - url: args.url - }); - } - function SetSize(payload) { - windowsPostMessage("SetSize", payload); - } - function OpenSettings(args) { - windowsPostMessage("OpenSettings", args); - } - function handleIncomingMessage(message) { - const parsed = eventShape.safeParse(message); - if (!parsed.success) { - console.error("cannot handle incoming message from event data", message); - console.error(parsed.error); - return; - } - switch (parsed.data.Name) { - case "VisibilityChanged": { - if (parsed.data.Data.isVisible === false) { - document.body.innerHTML = ""; - } - break; - } - case "ViewModelUpdated": { - handleViewModelUpdate(parsed.data.Data); - } - } - } - function setup3() { - if (!window.chrome.webview) { - console.error("window.chrome.webview not available"); - return; - } - setupColorScheme(); - assert(typeof window.chrome.webview?.addEventListener === "function", "window.chrome.webview.addEventListener is required"); - window.chrome.webview.addEventListener("message", (event) => { - handleIncomingMessage(event.data); - }); - setupMutationObserver((height) => { - SetSize({ height }); - }); - setupGlobalOpenerListener((href) => { - OpenInNewTab({ - url: href - }); - }); - } - function firstRenderComplete2() { - const height = getContentHeight(); - if (typeof height === "number") { - SetSize({ height }); - } - } - var channel3, backgroundMessage3, getBackgroundTabDataPromises2, trackerBlockingData2, permissionsData2, certificateData2, upgradedHttps2, protections2, isPendingUpdates2, parentEntity2, combineSources2, resolveInitialRender2, getBackgroundTabData3, eventShape; - var init_windows_communication = __esm({ - "shared/js/browser/windows-communication.js"() { - "use strict"; - init_lib(); - init_schema_parsers(); - init_utils(); - init_common(); - init_request_details(); - channel3 = null; - backgroundMessage3 = (backgroundModel) => { - channel3 = backgroundModel; - }; - getBackgroundTabDataPromises2 = []; - combineSources2 = () => ({ - tab: Object.assign( - {}, - trackerBlockingData2 || {}, - { - isPendingUpdates: isPendingUpdates2, - parentEntity: parentEntity2 - }, - permissionsData2 ? { permissions: permissionsData2 } : {}, - certificateData2 ? { certificate: certificateData2 } : {} - ) - }); - resolveInitialRender2 = function() { - const isUpgradedHttpsSet = typeof upgradedHttps2 === "boolean"; - const isIsProtectedSet = typeof protections2 !== "undefined"; - const isTrackerBlockingDataSet = typeof trackerBlockingData2 === "object"; - if (!isUpgradedHttpsSet || !isIsProtectedSet || !isTrackerBlockingDataSet) { - return; - } - getBackgroundTabDataPromises2.forEach((resolve) => resolve(combineSources2())); - channel3?.send("updateTabData"); - }; - getBackgroundTabData3 = () => { - return new Promise((resolve) => { - if (trackerBlockingData2) { - resolve(combineSources2()); - return; - } - getBackgroundTabDataPromises2.push(resolve); - }); - }; - eventShape = mod.discriminatedUnion("Name", [windowsIncomingViewModelSchema, windowsIncomingVisibilitySchema]); - } - }); - // shared/js/browser/ios-communication.js var ios_communication_exports = {}; __export(ios_communication_exports, { backgroundMessage: () => backgroundMessage2, - fetch: () => fetch4, - firstRenderComplete: () => firstRenderComplete2, + fetch: () => fetch3, + firstRenderComplete: () => firstRenderComplete, getBackgroundTabData: () => getBackgroundTabData2, privacyDashboardClose: () => privacyDashboardClose, privacyDashboardShowReportBrokenSite: () => privacyDashboardShowReportBrokenSite, - setup: () => setup4 + setup: () => setup3 }); - function setup4() { + function setup3() { const setColorScheme = setupColorScheme(); window.onChangeTheme = function(themeName) { setColorScheme(themeName); @@ -12674,7 +12492,7 @@ invariant(window.webkit?.messageHandlers, "webkit.messageHandlers required"); window.webkit.messageHandlers.privacyDashboardShowReportBrokenSite.postMessage(args); } - async function fetch4(message) { + async function fetch3(message) { if (message instanceof CloseMessage) { privacyDashboardClose({}); return; @@ -12691,7 +12509,6 @@ init_tiny_invariant(); init_common(); init_macos_communication(); - init_windows_communication(); } }); @@ -12699,19 +12516,19 @@ var android_communication_exports = {}; __export(android_communication_exports, { PrivacyDashboardJavascriptInterface: () => PrivacyDashboardJavascriptInterface, - backgroundMessage: () => backgroundMessage4, - fetch: () => fetch5, - getBackgroundTabData: () => getBackgroundTabData4, + backgroundMessage: () => backgroundMessage3, + fetch: () => fetch4, + getBackgroundTabData: () => getBackgroundTabData3, onChangeConsentManaged: () => onChangeConsentManaged2, onChangeFeatureSettings: () => onChangeFeatureSettings, onChangeLocale: () => onChangeLocale2, onChangeProtectionStatus: () => onChangeProtectionStatus2, onChangeRequestData: () => onChangeRequestData2, - setup: () => setup5 + setup: () => setup4 }); function onChangeRequestData2(tabUrl, rawRequestData) { const requestData = requestDataSchema.safeParse(rawRequestData); - if (!protections3) { + if (!protections2) { console.error("protections status not set"); return; } @@ -12720,8 +12537,8 @@ console.log(requestData.error); return; } - trackerBlockingData3 = createTabData(tabUrl, upgradedHttps3, protections3, requestData.data); - resolveInitialRender3(); + trackerBlockingData2 = createTabData(tabUrl, upgradedHttps2, protections2, requestData.data); + resolveInitialRender2(); } function onChangeProtectionStatus2(protectionsStatus) { const parsed = protectionsStatusSchema.safeParse(protectionsStatus); @@ -12730,8 +12547,8 @@ console.error(parsed.error); return; } - protections3 = parsed.data; - resolveInitialRender3(); + protections2 = parsed.data; + resolveInitialRender2(); } function onChangeLocale2(payload) { const parsed = localeSettingsSchema.safeParse(payload); @@ -12741,7 +12558,7 @@ return; } locale2 = parsed.data.locale; - channel4?.send("updateTabData", { via: "onChangeLocale" }); + channel3?.send("updateTabData", { via: "onChangeLocale" }); } function onChangeFeatureSettings(payload) { const parsed = remoteFeatureSettingsSchema.safeParse(payload); @@ -12751,7 +12568,7 @@ return; } featureSettings = parsed.data; - channel4?.send("updateTabData", { via: "onChangeFeatureSettings" }); + channel3?.send("updateTabData", { via: "onChangeFeatureSettings" }); } function onChangeConsentManaged2(payload) { const parsed = cookiePromptManagementStatusSchema.safeParse(payload); @@ -12761,7 +12578,7 @@ return; } Object.assign(cookiePromptManagementStatus2, parsed.data); - channel4?.send("updateTabData"); + channel3?.send("updateTabData"); } async function fetchAndroid(message) { if (message instanceof SetListsMessage) { @@ -12789,7 +12606,7 @@ }); } } - function setup5() { + function setup4() { const setColorScheme = setupColorScheme(); window.onChangeTheme = function(themeName) { setColorScheme(themeName); @@ -12800,26 +12617,26 @@ window.onChangeConsentManaged = onChangeConsentManaged2; window.onChangeFeatureSettings = onChangeFeatureSettings; window.onChangeAllowedPermissions = function(data) { - permissionsData3 = data; - channel4?.send("updateTabData", { via: "onChangeAllowedPermissions" }); + permissionsData2 = data; + channel3?.send("updateTabData", { via: "onChangeAllowedPermissions" }); }; window.onChangeUpgradedHttps = function(data) { - upgradedHttps3 = data; - if (trackerBlockingData3) - trackerBlockingData3.upgradedHttps = upgradedHttps3; - resolveInitialRender3(); + upgradedHttps2 = data; + if (trackerBlockingData2) + trackerBlockingData2.upgradedHttps = upgradedHttps2; + resolveInitialRender2(); }; window.onChangeCertificateData = function(data) { - certificateData3 = data.secCertificateViewModels; - channel4?.send("updateTabData", { via: "onChangeCertificateData" }); + certificateData2 = data.secCertificateViewModels; + channel3?.send("updateTabData", { via: "onChangeCertificateData" }); }; window.onIsPendingUpdates = function(data) { - isPendingUpdates3 = data; - channel4?.send("updateTabData", { via: "onIsPendingUpdates" }); + isPendingUpdates2 = data; + channel3?.send("updateTabData", { via: "onIsPendingUpdates" }); }; window.onChangeParentEntity = function(data) { - parentEntity3 = data; - channel4?.send("updateTabData", { via: "onChangeParentEntity" }); + parentEntity2 = data; + channel3?.send("updateTabData", { via: "onChangeParentEntity" }); }; privacyDashboardApi = new PrivacyDashboardJavascriptInterface(); setupBlurOnLongPress(); @@ -12829,7 +12646,7 @@ }); }); } - var channel4, backgroundMessage4, getBackgroundTabDataPromises3, trackerBlockingData3, permissionsData3, certificateData3, upgradedHttps3, protections3, isPendingUpdates3, parentEntity3, cookiePromptManagementStatus2, locale2, featureSettings, combineSources3, resolveInitialRender3, PrivacyDashboardJavascriptInterface, privacyDashboardApi, getBackgroundTabDataAndroid, getBackgroundTabData4, fetch5; + var channel3, backgroundMessage3, getBackgroundTabDataPromises2, trackerBlockingData2, permissionsData2, certificateData2, upgradedHttps2, protections2, isPendingUpdates2, parentEntity2, cookiePromptManagementStatus2, locale2, featureSettings, combineSources2, resolveInitialRender2, PrivacyDashboardJavascriptInterface, privacyDashboardApi, getBackgroundTabDataAndroid, getBackgroundTabData3, fetch4; var init_android_communication = __esm({ "shared/js/browser/android-communication.js"() { "use strict"; @@ -12837,37 +12654,37 @@ init_utils(); init_common(); init_request_details(); - channel4 = null; - backgroundMessage4 = (backgroundModel) => { - channel4 = backgroundModel; + channel3 = null; + backgroundMessage3 = (backgroundModel) => { + channel3 = backgroundModel; }; - getBackgroundTabDataPromises3 = []; + getBackgroundTabDataPromises2 = []; cookiePromptManagementStatus2 = {}; - combineSources3 = () => ({ + combineSources2 = () => ({ tab: Object.assign( {}, - trackerBlockingData3 || {}, + trackerBlockingData2 || {}, { - isPendingUpdates: isPendingUpdates3, - parentEntity: parentEntity3, + isPendingUpdates: isPendingUpdates2, + parentEntity: parentEntity2, cookiePromptManagementStatus: cookiePromptManagementStatus2, locale: locale2 }, - permissionsData3 ? { permissions: permissionsData3 } : {}, - certificateData3 ? { certificate: certificateData3 } : {} + permissionsData2 ? { permissions: permissionsData2 } : {}, + certificateData2 ? { certificate: certificateData2 } : {} ), featureSettings }); - resolveInitialRender3 = function() { - const isUpgradedHttpsSet = typeof upgradedHttps3 === "boolean"; - const isIsProtectedSet = typeof protections3 !== "undefined"; - const isTrackerBlockingDataSet = typeof trackerBlockingData3 === "object"; + resolveInitialRender2 = function() { + const isUpgradedHttpsSet = typeof upgradedHttps2 === "boolean"; + const isIsProtectedSet = typeof protections2 !== "undefined"; + const isTrackerBlockingDataSet = typeof trackerBlockingData2 === "object"; const isLocaleSet = typeof locale2 === "string"; if (!isLocaleSet || !isUpgradedHttpsSet || !isIsProtectedSet || !isTrackerBlockingDataSet) { return; } - getBackgroundTabDataPromises3.forEach((resolve) => resolve(combineSources3())); - channel4?.send("updateTabData", { via: "resolveInitialRender" }); + getBackgroundTabDataPromises2.forEach((resolve) => resolve(combineSources2())); + channel3?.send("updateTabData", { via: "resolveInitialRender" }); }; PrivacyDashboardJavascriptInterface = class { /** @@ -12939,19 +12756,19 @@ }; getBackgroundTabDataAndroid = () => { return new Promise((resolve) => { - if (trackerBlockingData3) { - resolve(combineSources3()); + if (trackerBlockingData2) { + resolve(combineSources2()); return; } - getBackgroundTabDataPromises3.push(resolve); + getBackgroundTabDataPromises2.push(resolve); }); }; - getBackgroundTabData4 = new Proxy(getBackgroundTabDataAndroid, { + getBackgroundTabData3 = new Proxy(getBackgroundTabDataAndroid, { apply(target, thisArg, argArray) { return Reflect.apply(target, thisArg, argArray); } }); - fetch5 = new Proxy(fetchAndroid, { + fetch4 = new Proxy(fetchAndroid, { apply(target, thisArg, argArray) { return Reflect.apply(target, thisArg, argArray); } @@ -12959,6 +12776,188 @@ } }); + // shared/js/browser/windows-communication.js + var windows_communication_exports = {}; + __export(windows_communication_exports, { + OpenInNewTab: () => OpenInNewTab, + OpenSettings: () => OpenSettings, + SetSize: () => SetSize, + SubmitBrokenSiteReport: () => SubmitBrokenSiteReport, + backgroundMessage: () => backgroundMessage4, + fetch: () => fetch5, + firstRenderComplete: () => firstRenderComplete2, + getBackgroundTabData: () => getBackgroundTabData4, + handleIncomingMessage: () => handleIncomingMessage, + setup: () => setup5 + }); + function handleViewModelUpdate(viewModel) { + upgradedHttps3 = viewModel.upgradedHttps; + parentEntity3 = viewModel.parentEntity || {}; + permissionsData3 = viewModel.permissions || []; + certificateData3 = viewModel.certificates || []; + protections3 = viewModel.protections; + trackerBlockingData3 = createTabData(viewModel.tabUrl, upgradedHttps3, viewModel.protections, viewModel.rawRequestData); + trackerBlockingData3.cookiePromptManagementStatus = viewModel.cookiePromptManagementStatus; + if (trackerBlockingData3) + trackerBlockingData3.upgradedHttps = upgradedHttps3; + resolveInitialRender3(); + } + function windowsPostMessage(name, data) { + assert(typeof window.chrome.webview?.postMessage === "function"); + window.chrome.webview.postMessage({ + Feature: "PrivacyDashboard", + Name: name, + Data: data + }); + } + async function fetch5(message) { + if (message instanceof SubmitBrokenSiteReportMessage) { + SubmitBrokenSiteReport({ + category: message.category, + description: message.description + }); + return; + } + if (message instanceof OpenSettingsMessages) { + OpenSettings({ + target: message.target + }); + return; + } + if (message instanceof SetListsMessage) { + for (const listItem of message.lists) { + const { list, value } = listItem; + if (list !== "allowlisted") { + if (!window.__playwright) + console.warn("only `allowlisted` is currently supported on windows"); + continue; + } + const isProtected = value === false; + const eventOrigin = message.eventOrigin; + if (isProtected) { + windowsPostMessage("RemoveFromAllowListCommand", { eventOrigin }); + } else { + windowsPostMessage("AddToAllowListCommand", { eventOrigin }); + } + } + } + if (message instanceof UpdatePermissionMessage) { + windowsPostMessage("SetPermissionCommand", { + permission: message.id, + value: message.value + }); + } + } + function SubmitBrokenSiteReport(report2) { + windowsPostMessage("SubmitBrokenSiteReport", { + category: report2.category, + description: report2.description + }); + } + function OpenInNewTab(args) { + windowsPostMessage("OpenInNewTab", { + url: args.url + }); + } + function SetSize(payload) { + windowsPostMessage("SetSize", payload); + } + function OpenSettings(args) { + windowsPostMessage("OpenSettings", args); + } + function handleIncomingMessage(message) { + const parsed = eventShape.safeParse(message); + if (!parsed.success) { + console.error("cannot handle incoming message from event data", message); + console.error(parsed.error); + return; + } + switch (parsed.data.Name) { + case "VisibilityChanged": { + if (parsed.data.Data.isVisible === false) { + document.body.innerHTML = ""; + } + break; + } + case "ViewModelUpdated": { + handleViewModelUpdate(parsed.data.Data); + } + } + } + function setup5() { + if (!window.chrome.webview) { + console.error("window.chrome.webview not available"); + return; + } + setupColorScheme(); + assert(typeof window.chrome.webview?.addEventListener === "function", "window.chrome.webview.addEventListener is required"); + window.chrome.webview.addEventListener("message", (event) => { + handleIncomingMessage(event.data); + }); + setupMutationObserver((height) => { + SetSize({ height }); + }); + setupGlobalOpenerListener((href) => { + OpenInNewTab({ + url: href + }); + }); + } + function firstRenderComplete2() { + const height = getContentHeight(); + if (typeof height === "number") { + SetSize({ height }); + } + } + var channel4, backgroundMessage4, getBackgroundTabDataPromises3, trackerBlockingData3, permissionsData3, certificateData3, upgradedHttps3, protections3, isPendingUpdates3, parentEntity3, combineSources3, resolveInitialRender3, getBackgroundTabData4, eventShape; + var init_windows_communication = __esm({ + "shared/js/browser/windows-communication.js"() { + "use strict"; + init_lib(); + init_schema_parsers(); + init_utils(); + init_common(); + init_request_details(); + channel4 = null; + backgroundMessage4 = (backgroundModel) => { + channel4 = backgroundModel; + }; + getBackgroundTabDataPromises3 = []; + combineSources3 = () => ({ + tab: Object.assign( + {}, + trackerBlockingData3 || {}, + { + isPendingUpdates: isPendingUpdates3, + parentEntity: parentEntity3 + }, + permissionsData3 ? { permissions: permissionsData3 } : {}, + certificateData3 ? { certificate: certificateData3 } : {} + ) + }); + resolveInitialRender3 = function() { + const isUpgradedHttpsSet = typeof upgradedHttps3 === "boolean"; + const isIsProtectedSet = typeof protections3 !== "undefined"; + const isTrackerBlockingDataSet = typeof trackerBlockingData3 === "object"; + if (!isUpgradedHttpsSet || !isIsProtectedSet || !isTrackerBlockingDataSet) { + return; + } + getBackgroundTabDataPromises3.forEach((resolve) => resolve(combineSources3())); + channel4?.send("updateTabData"); + }; + getBackgroundTabData4 = () => { + return new Promise((resolve) => { + if (trackerBlockingData3) { + resolve(combineSources3()); + return; + } + getBackgroundTabDataPromises3.push(resolve); + }); + }; + eventShape = mod.discriminatedUnion("Name", [windowsIncomingViewModelSchema, windowsIncomingVisibilitySchema]); + } + }); + // shared/js/browser/utils/communication-mocks.mjs var init_communication_mocks = __esm({ "shared/js/browser/utils/communication-mocks.mjs"() { diff --git a/shared/js/browser/ios-communication.js b/shared/js/browser/ios-communication.js index 442fa6fe..672d40c6 100644 --- a/shared/js/browser/ios-communication.js +++ b/shared/js/browser/ios-communication.js @@ -23,8 +23,7 @@ */ import invariant from 'tiny-invariant' import { CheckBrokenSiteReportHandledMessage, CloseMessage, setupColorScheme } from './common.js' -import { backgroundMessage, getBackgroundTabData, fetch as macosFetch, setupShared } from './macos-communication.js' -import { firstRenderComplete } from './windows-communication.js' +import { backgroundMessage, getBackgroundTabData, fetch as macosFetch, setupShared, firstRenderComplete } from './macos-communication.js' /** * iOS specific setup