Skip to content

Commit

Permalink
Replace webext-detect-page with webext-detect (#8731)
Browse files Browse the repository at this point in the history
* Replce `webext-detect-page` with `webext-detect`

* Rename

---------

Co-authored-by: Graham Langford <[email protected]>
  • Loading branch information
fregante and grahamlangford authored Jul 1, 2024
1 parent 159d5a0 commit 8318d74
Show file tree
Hide file tree
Showing 28 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"use-sync-external-store": "^1.2.2",
"uuid": "^10.0.0",
"webext-content-scripts": "^2.7.0",
"webext-detect-page": "^5.0.0",
"webext-detect": "^5.0.2",
"webext-events": "^3.0.0",
"webext-inject-on-install": "^2.2.0",
"webext-messenger": "^0.28.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { type ContextName } from "webext-detect-page";
import { type ContextName } from "webext-detect";

let _context: ContextName = "extension";

Expand All @@ -26,8 +26,8 @@ export function TEST_setContext(context: ContextName) {
// Files in __mocks__ cannot be imported directly
// https://github.com/jest-community/eslint-plugin-jest/blob/v27.9.0/docs/rules/no-mocks-import.md
// ... so this exposes the type for the test-only export:
// Example: import { TEST_setContext } from "webext-detect-page";
declare module "webext-detect-page" {
// Example: import { TEST_setContext } from "webext-detect";
declare module "webext-detect" {
export function TEST_setContext(context: ContextName): boolean;
}

Expand Down
2 changes: 1 addition & 1 deletion src/auth/authStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
type UserData,
type UserDataUpdate,
} from "./authTypes";
import { isExtensionContext } from "webext-detect-page";
import { isExtensionContext } from "webext-detect";
import { expectContext } from "@/utils/expectContext";
import { omit } from "lodash";
import { syncRemotePackages } from "@/registry/memoryRegistry";
Expand Down
2 changes: 1 addition & 1 deletion src/background/backgroundDomWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { isBackgroundPage } from "webext-detect-page";
import { isBackgroundPage } from "webext-detect";

/** @file DO NOT alter this file to add an "init" function because it must be executed as early as possible */
if (isBackgroundPage()) {
Expand Down
2 changes: 1 addition & 1 deletion src/background/contentScript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
isTargetReady,
} from "@/contentScript/ready";
import { SimpleEventTarget } from "@/utils/SimpleEventTarget";
import { TEST_setContext } from "webext-detect-page";
import { TEST_setContext } from "webext-detect";
import { type Runtime, type Tabs } from "webextension-polyfill";

TEST_setContext("background");
Expand Down
2 changes: 1 addition & 1 deletion src/background/contextMenus/initContextMenus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import * as backgroundApi from "@/background/messenger/api";
import { type StarterBrickDefinitionLike } from "@/starterBricks/types";
import { type ModComponentBase } from "@/types/modComponentTypes";
import chromeP from "webext-polyfill-kinda";
import { TEST_setContext } from "webext-detect-page";
import { TEST_setContext } from "webext-detect";
import { modComponentFactory } from "@/testUtils/factories/modComponentFactories";
import { starterBrickDefinitionFactory } from "@/testUtils/factories/modDefinitionFactories";
import { getPlatform } from "@/platform/platformContext";
Expand Down
2 changes: 1 addition & 1 deletion src/background/deploymentUpdater.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { INTERNAL_reset as resetManagedStorage } from "@/store/enterprise/manage
import { type ActivatedModComponent } from "@/types/modComponentTypes";
import { checkDeploymentPermissions } from "@/permissions/deploymentPermissionsHelpers";
import { emptyPermissionsFactory } from "@/permissions/permissionsUtils";
import { TEST_setContext } from "webext-detect-page";
import { TEST_setContext } from "webext-detect";
import {
modComponentFactory,
modMetadataFactory,
Expand Down
2 changes: 1 addition & 1 deletion src/background/externalProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { uuidv4 } from "@/types/helpers";
import { type Runtime } from "webextension-polyfill";
import { patternToRegex } from "webext-patterns";
import chromeP from "webext-polyfill-kinda";
import { isBackground, isExtensionContext } from "webext-detect-page";
import { isBackground, isExtensionContext } from "webext-detect";
import { deserializeError } from "serialize-error";

import {
Expand Down
2 changes: 1 addition & 1 deletion src/background/performConfiguredRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
type IntegrationConfig,
type SecretsConfig,
} from "@/integrations/integrationTypes";
import { TEST_setContext } from "webext-detect-page";
import { TEST_setContext } from "webext-detect";
import { sanitizedIntegrationConfigFactory } from "@/testUtils/factories/integrationFactories";
import { getToken } from "@/background/auth/getToken";
import { PIXIEBRIX_INTEGRATION_ID } from "@/integrations/constants";
Expand Down
2 changes: 1 addition & 1 deletion src/bricks/transformers/brickFactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { reducePipeline } from "@/runtime/reducePipeline";
import Run from "@/bricks/transformers/controlFlow/Run";
import { cloneDeep, partial } from "lodash";
import { extraEmptyModStateContext } from "@/runtime/extendModVariableContext";
import { TEST_setContext } from "webext-detect-page";
import { TEST_setContext } from "webext-detect";
import { uuidv4, validateRegistryId } from "@/types/helpers";
import registerBuiltinBricks from "@/bricks/registerBuiltinBricks";

Expand Down
2 changes: 1 addition & 1 deletion src/bricks/transformers/brickFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {
isPipelineExpression,
type PipelineClosureExpression,
} from "@/utils/expressionUtils";
import { isContentScript } from "webext-detect-page";
import { isContentScript } from "webext-detect";
import { getConnectedTarget } from "@/sidebar/connectedTarget";
import { uuidv4 } from "@/types/helpers";
import { isSpecificError } from "@/errors/errorHelpers";
Expand Down
2 changes: 1 addition & 1 deletion src/contrib/google/sheets/core/useCurrentOrigin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import useCurrentOrigin from "@/contrib/google/sheets/core/useCurrentOrigin";
import { renderHook } from "@/sidebar/testHelpers";
import Tab = chrome.tabs.Tab;
import { waitForEffect } from "@/testUtils/testHelpers";
import { TEST_setContext } from "webext-detect-page";
import { TEST_setContext } from "webext-detect";

const originalRuntime = browser.runtime;
browser.runtime = {
Expand Down
2 changes: 1 addition & 1 deletion src/contrib/google/sheets/core/useCurrentOrigin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { isOptionsPage } from "webext-detect-page";
import { isOptionsPage } from "webext-detect";
import { useEffect } from "react";
import notify from "@/utils/notify";
import useAsyncState from "@/hooks/useAsyncState";
Expand Down
2 changes: 1 addition & 1 deletion src/contrib/uipath/LocalProcessOptions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import * as auth from "@/hooks/auth";
import { type SanitizedIntegrationConfig } from "@/integrations/integrationTypes";
import { type ModComponentFormState } from "@/pageEditor/starterBricks/formStateTypes";
import { valueToAsyncState } from "@/utils/asyncStateUtils";
import { TEST_setContext } from "webext-detect-page";
import { TEST_setContext } from "webext-detect";
import { menuItemFormStateFactory } from "@/testUtils/factories/pageEditorFactories";
import { integrationDependencyFactory } from "@/testUtils/factories/integrationFactories";
import { validateOutputKey } from "@/runtime/runtimeTypes";
Expand Down
2 changes: 1 addition & 1 deletion src/contrib/uipath/ProcessOptions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import registerDefaultWidgets from "@/components/fields/schemaFields/widgets/reg
import { type SanitizedIntegrationConfig } from "@/integrations/integrationTypes";
import { useAuthOptions } from "@/hooks/auth";
import { valueToAsyncState } from "@/utils/asyncStateUtils";
import { TEST_setContext } from "webext-detect-page";
import { TEST_setContext } from "webext-detect";
import { menuItemFormStateFactory } from "@/testUtils/factories/pageEditorFactories";
import { integrationDependencyFactory } from "@/testUtils/factories/integrationFactories";
import { validateOutputKey } from "@/runtime/runtimeTypes";
Expand Down
2 changes: 1 addition & 1 deletion src/data/service/baseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { isExtensionContext } from "webext-detect-page";
import { isExtensionContext } from "webext-detect";
import useUpdatableAsyncState from "@/hooks/useUpdatableAsyncState";
import { readManagedStorageByKey } from "@/store/enterprise/managedStorage";
import { StorageItem } from "webext-storage";
Expand Down
2 changes: 1 addition & 1 deletion src/layout/EnvironmentBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import React from "react";
import { getExtensionAuth } from "@/auth/authStorage";
import { isExtensionContext } from "webext-detect-page";
import { isExtensionContext } from "webext-detect";
import { connectPage } from "@/background/messenger/external/api";
import Banner, { type BannerVariant } from "@/components/banner/Banner";
import useAsyncState from "@/hooks/useAsyncState";
Expand Down
2 changes: 1 addition & 1 deletion src/layout/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import React, { useMemo } from "react";
import { isExtensionContext } from "webext-detect-page";
import { isExtensionContext } from "webext-detect";

const Footer: React.FunctionComponent = () => {
const extensionVersion = useMemo(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/pipelineTests/component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {

import { fromJS } from "@/bricks/transformers/brickFactory";
import { normalizeSemVerString } from "@/types/helpers";
import { TEST_setContext } from "webext-detect-page";
import { TEST_setContext } from "webext-detect";
import { toExpression } from "@/utils/expressionUtils";
import { DefinitionKinds } from "@/types/registryTypes";

Expand Down
2 changes: 1 addition & 1 deletion src/telemetry/initErrorReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { isContentScript } from "webext-detect-page";
import { isContentScript } from "webext-detect";
import { addAuthListener } from "@/auth/authStorage";
import type { UserData } from "@/auth/authTypes";
import pMemoize from "p-memoize";
Expand Down
2 changes: 1 addition & 1 deletion src/telemetry/reportError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { backgroundTarget as bg, getNotifier } from "webext-messenger";
import { serializeError } from "serialize-error";
import { selectError, shouldErrorBeIgnored } from "@/errors/errorHelpers";
import { expectContext } from "@/utils/expectContext";
import { getContextName } from "webext-detect-page";
import { getContextName } from "webext-detect";

expectContext(
"extension",
Expand Down
2 changes: 1 addition & 1 deletion src/tsconfig.strictNullChecks.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"./__mocks__/@/utils/injectScriptTag.ts",
"./__mocks__/@/utils/injectStylesheet.ts",
"./__mocks__/@uipath/robot.ts",
"./__mocks__/webext-detect-page.ts",
"./__mocks__/webext-detect.ts",
"./activation/ActivationLink.tsx",
"./activation/WizardValuesModIntegrationsContextAdapter.tsx",
"./activation/activateLinkClickHandler.test.tsx",
Expand Down
2 changes: 1 addition & 1 deletion src/types/loggerTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import { type UUID } from "@/types/stringTypes";
import { type RegistryId, type SemVerString } from "@/types/registryTypes";
import { type ContextName } from "webext-detect-page";
import { type ContextName } from "webext-detect";

/**
* Log event metadata for the extensions internal logging infrastructure.
Expand Down
2 changes: 1 addition & 1 deletion src/utils/browserUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const brands: Array<{ brand: string }> =
/**
* Return true if the browser is Google Chrome.
*
* Unlike webext-detect-page, attempts to exclude other Chromium-based browsers like Microsoft Edge, Brave, and Opera.
* Unlike webext-detect, attempts to exclude other Chromium-based browsers like Microsoft Edge, Brave, and Opera.
*/
export function isGoogleChrome(): boolean {
return brands.some((x) => x.brand === "Google Chrome");
Expand Down
2 changes: 1 addition & 1 deletion src/utils/expectContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
isContentScript,
isExtensionContext,
isWebPage,
} from "webext-detect-page";
} from "webext-detect";

/**
* Whether the current context is the top frame of the browser sidebar.
Expand Down
2 changes: 1 addition & 1 deletion src/utils/preventNativeFormSubmission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* https://github.com/pixiebrix/pixiebrix-extension/issues/3879
* https://github.com/pixiebrix/pixiebrix-extension/issues/4122
*/
import { isBackgroundWorker, isWebPage } from "webext-detect-page";
import { isBackgroundWorker, isWebPage } from "webext-detect";

function preventDefault(event: Event): void {
event.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/sidePanelUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { getErrorMessage } from "@/errors/errorHelpers";
import { forbidContext, isBrowserSidebarTopFrame } from "@/utils/expectContext";
import { type PageTarget, messenger, getThisFrame } from "webext-messenger";
import { isContentScript } from "webext-detect-page";
import { isContentScript } from "webext-detect";

/**
* Returns true if an error showing sidebar is due to a missing user gesture.
Expand Down

0 comments on commit 8318d74

Please sign in to comment.