From 49c3b06989a723d3792fac19776241b4dd603478 Mon Sep 17 00:00:00 2001 From: Federico Brigante Date: Tue, 15 Feb 2022 20:05:27 +0800 Subject: [PATCH] Avoid most explicit cross-boundary imports (#2721) --- .eslintrc.js | 33 +++++++++ src/actionPanel/ActionPanelApp.tsx | 8 ++- src/actionPanel/ActionPanelTabs.tsx | 2 +- src/actionPanel/FormBody.tsx | 2 +- src/actionPanel/PanelBody.tsx | 2 +- src/actionPanel/actionPanelSlice.ts | 6 +- src/actionPanel/actionPanelUtils.ts | 2 +- src/actionPanel/protocol.tsx | 2 +- .../{actionPanelTypes.ts => types.ts} | 0 src/background/executor.ts | 3 +- src/background/messenger/api.ts | 2 + src/background/messenger/registration.ts | 5 ++ src/blocks/effects/forms.ts | 2 +- src/blocks/effects/sidebar.ts | 2 +- .../ephemeralForm/formTransformer.ts | 2 +- .../actionPanel.tsx} | 6 +- src/contentScript/devTools.ts | 3 +- src/contentScript/lifecycle.ts | 4 +- src/contentScript/messenger/api.ts | 1 + src/contentScript/messenger/registration.ts | 18 +++-- .../nativeEditor/dynamic.ts | 19 +----- .../nativeEditor/frameworks.ts | 13 +--- .../nativeEditor/infer.test.tsx | 2 +- src/{ => contentScript}/nativeEditor/infer.ts | 0 .../nativeEditor/insertButton.tsx | 21 +----- .../nativeEditor/insertPanel.tsx | 15 +--- .../nativeEditor/selector.ts | 12 ++-- src/contentScript/nativeEditor/types.ts | 68 +++++++++++++++++++ .../editor/extensionPoints/actionPanel.tsx | 2 +- .../editor/extensionPoints/contextMenu.tsx | 2 +- .../editor/extensionPoints/elementConfig.ts | 2 +- .../editor/extensionPoints/menuItem.ts | 10 +-- src/devTools/editor/extensionPoints/panel.ts | 8 ++- .../editor/extensionPoints/quickBar.tsx | 2 +- .../editor/extensionPoints/trigger.tsx | 2 +- .../editor/fields/SelectorSelectorWidget.tsx | 3 +- src/devTools/editor/tabs/RunLogCard.tsx | 3 +- src/extensionPoints/actionPanelExtension.ts | 2 +- src/extensionPoints/contextMenu.ts | 2 +- .../activateExtension/useEnsurePermissions.ts | 6 +- src/options/pages/brickEditor/BrickLogs.tsx | 3 +- .../pages/installed/ActiveBricksCard.tsx | 2 +- .../pages/marketplace/useEnsurePermissions.ts | 5 +- .../pages/settings/LoggingSettings.tsx | 2 +- src/pageScript/protocol.ts | 2 +- src/script.ts | 4 +- src/tests/factories.ts | 2 +- .../deployment.ts} | 0 .../requireSingleElement.ts} | 0 src/utils/selectionController.ts | 2 +- src/{nativeEditor => vendors}/Overlay.tsx | 0 51 files changed, 195 insertions(+), 126 deletions(-) rename src/actionPanel/{actionPanelTypes.ts => types.ts} (100%) rename src/{actionPanel/native.tsx => contentScript/actionPanel.tsx} (98%) rename src/{ => contentScript}/nativeEditor/dynamic.ts (92%) rename src/{ => contentScript}/nativeEditor/frameworks.ts (90%) rename src/{ => contentScript}/nativeEditor/infer.test.tsx (99%) rename src/{ => contentScript}/nativeEditor/infer.ts (100%) rename src/{ => contentScript}/nativeEditor/insertButton.tsx (82%) rename src/{ => contentScript}/nativeEditor/insertPanel.tsx (82%) rename src/{ => contentScript}/nativeEditor/selector.ts (96%) create mode 100644 src/contentScript/nativeEditor/types.ts rename src/{options/deploymentUtils.ts => utils/deployment.ts} (100%) rename src/{nativeEditor/utils.ts => utils/requireSingleElement.ts} (100%) rename src/{nativeEditor => vendors}/Overlay.tsx (100%) diff --git a/.eslintrc.js b/.eslintrc.js index 2506ac68d2..f53c9b5b07 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,3 +1,29 @@ +const contexts = [ + "background", + "contentScript", + "devTools", + "options", + "actionPanel", + // "pageScript", // TODO: After Messenger migration +]; + +const restrictedZones = []; +for (const exporter of contexts) { + for (const importer of contexts) { + if (exporter !== importer) { + restrictedZones.push({ + target: `./src/${importer}/**/*`, + from: `./src/${exporter}`, + except: [ + `../${exporter}/messenger/api.ts`, + `../${exporter}/types.ts`, + `../${exporter}/nativeEditor/types.ts`, + ], + }); + } + } +} + module.exports = { root: true, extends: [ @@ -5,6 +31,13 @@ module.exports = { "pixiebrix", ], rules: { + "import/no-restricted-paths": [ + "error", + { + zones: restrictedZones, + }, + ], + // Only enable this on tsx files "filenames/match-exported": "off", diff --git a/src/actionPanel/ActionPanelApp.tsx b/src/actionPanel/ActionPanelApp.tsx index 2f81838ddf..9909af0413 100644 --- a/src/actionPanel/ActionPanelApp.tsx +++ b/src/actionPanel/ActionPanelApp.tsx @@ -22,7 +22,8 @@ import { Button } from "react-bootstrap"; import logo from "@img/logo.svg"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleDoubleRight, faCog } from "@fortawesome/free-solid-svg-icons"; -import { getStore } from "@/actionPanel/native"; +// eslint-disable-next-line import/no-restricted-paths -- TODO: This should be called in the content script, but it currently has to be sync +import { getActionPanelStore } from "@/contentScript/actionPanel"; import { addListener, removeListener, @@ -30,11 +31,12 @@ import { } from "@/actionPanel/protocol"; import DefaultActionPanel from "@/actionPanel/DefaultActionPanel"; import { ToastProvider } from "react-toast-notifications"; +// eslint-disable-next-line import/no-restricted-paths -- TODO: move out of @/options or use Messenger import store, { persistor } from "@/options/store"; import { Provider } from "react-redux"; import Loader from "@/components/Loader"; import { PersistGate } from "redux-persist/integration/react"; -import { PanelEntry, FormEntry } from "@/actionPanel/actionPanelTypes"; +import { PanelEntry, FormEntry } from "@/actionPanel/types"; import ActionPanelTabs from "@/actionPanel/ActionPanelTabs"; import slice, { blankActionPanelState } from "./actionPanelSlice"; import { AnyAction } from "redux"; @@ -58,7 +60,7 @@ function getConnectedListener(dispatch: Dispatch): StoreListener { const ActionPanelApp: React.FunctionComponent = () => { const [state, dispatch] = useReducer(slice.reducer, { ...blankActionPanelState, - ...getStore(), + ...getActionPanelStore(), }); const listener: StoreListener = useMemo( diff --git a/src/actionPanel/ActionPanelTabs.tsx b/src/actionPanel/ActionPanelTabs.tsx index e727173833..9bcfc36679 100644 --- a/src/actionPanel/ActionPanelTabs.tsx +++ b/src/actionPanel/ActionPanelTabs.tsx @@ -16,7 +16,7 @@ */ import React, { useCallback, useEffect } from "react"; -import { ActionPanelStore, PanelEntry } from "@/actionPanel/actionPanelTypes"; +import { ActionPanelStore, PanelEntry } from "@/actionPanel/types"; import { mapTabEventKey } from "@/actionPanel/actionPanelUtils"; import useExtensionMeta from "@/hooks/useExtensionMeta"; import { UUID } from "@/core"; diff --git a/src/actionPanel/FormBody.tsx b/src/actionPanel/FormBody.tsx index c0dfd3d166..1d8949418f 100644 --- a/src/actionPanel/FormBody.tsx +++ b/src/actionPanel/FormBody.tsx @@ -16,7 +16,7 @@ */ import React from "react"; -import { FormEntry } from "@/actionPanel/actionPanelTypes"; +import { FormEntry } from "@/actionPanel/types"; import { useAsyncState } from "@/hooks/common"; import Loader from "@/components/Loader"; import { getErrorMessage } from "@/errors"; diff --git a/src/actionPanel/PanelBody.tsx b/src/actionPanel/PanelBody.tsx index 12bb22689f..e8e5b4d5b4 100644 --- a/src/actionPanel/PanelBody.tsx +++ b/src/actionPanel/PanelBody.tsx @@ -23,7 +23,7 @@ import ConsoleLogger from "@/tests/ConsoleLogger"; import ReactShadowRoot from "react-shadow-root"; import { getErrorMessage } from "@/errors"; import { BlockArg, RendererOutput } from "@/core"; -import { PanelPayload } from "@/actionPanel/actionPanelTypes"; +import { PanelPayload } from "@/actionPanel/types"; import RendererComponent from "@/actionPanel/RendererComponent"; const PanelBody: React.FunctionComponent<{ payload: PanelPayload }> = ({ diff --git a/src/actionPanel/actionPanelSlice.ts b/src/actionPanel/actionPanelSlice.ts index 0ab85ad68f..8854f778d6 100644 --- a/src/actionPanel/actionPanelSlice.ts +++ b/src/actionPanel/actionPanelSlice.ts @@ -15,11 +15,7 @@ * along with this program. If not, see . */ -import { - ActionPanelStore, - FormEntry, - PanelEntry, -} from "@/actionPanel/actionPanelTypes"; +import { ActionPanelStore, FormEntry, PanelEntry } from "@/actionPanel/types"; import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { defaultEventKey, diff --git a/src/actionPanel/actionPanelUtils.ts b/src/actionPanel/actionPanelUtils.ts index 7bcfb5713d..07b4fe2766 100644 --- a/src/actionPanel/actionPanelUtils.ts +++ b/src/actionPanel/actionPanelUtils.ts @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -import { ActionPanelStore, EntryType } from "@/actionPanel/actionPanelTypes"; +import { ActionPanelStore, EntryType } from "@/actionPanel/types"; import { UUID } from "@/core"; export function mapTabEventKey( diff --git a/src/actionPanel/protocol.tsx b/src/actionPanel/protocol.tsx index ea1ca616ec..e3c7167acf 100644 --- a/src/actionPanel/protocol.tsx +++ b/src/actionPanel/protocol.tsx @@ -16,7 +16,7 @@ */ import reportError from "@/telemetry/reportError"; -import { FormEntry, PanelEntry } from "@/actionPanel/actionPanelTypes"; +import { FormEntry, PanelEntry } from "@/actionPanel/types"; import { FormDefinition } from "@/blocks/transformers/ephemeralForm/formTypes"; import { UUID } from "@/core"; diff --git a/src/actionPanel/actionPanelTypes.ts b/src/actionPanel/types.ts similarity index 100% rename from src/actionPanel/actionPanelTypes.ts rename to src/actionPanel/types.ts diff --git a/src/background/executor.ts b/src/background/executor.ts index ef43ee311c..816ce1c17b 100644 --- a/src/background/executor.ts +++ b/src/background/executor.ts @@ -15,7 +15,8 @@ * along with this program. If not, see . */ -import { RunBlock } from "@/contentScript/executor"; +// eslint-disable-next-line import/no-restricted-paths -- Type only +import type { RunBlock } from "@/contentScript/executor"; import browser, { Runtime, Tabs } from "webextension-polyfill"; import { BusinessError } from "@/errors"; import { expectContext } from "@/utils/expectContext"; diff --git a/src/background/messenger/api.ts b/src/background/messenger/api.ts index 6ceedd77a6..974fc42713 100644 --- a/src/background/messenger/api.ts +++ b/src/background/messenger/api.ts @@ -95,6 +95,7 @@ export const contextMenus = { export const services = { locate: getMethod("LOCATE_SERVICE", bg), refresh: getMethod("REFRESH_SERVICES", bg), + refreshLocal: getMethod("LOCATOR_REFRESH_LOCAL", bg), }; export const httpRequest = getMethod("HTTP_REQUEST", bg); @@ -110,6 +111,7 @@ export const recordError = getNotifier("RECORD_ERROR", bg); export const recordEvent = getNotifier("RECORD_EVENT", bg); export const getLoggingConfig = getMethod("GET_LOGGING_CONFIG", bg); export const setLoggingConfig = getMethod("SET_LOGGING_CONFIG", bg); +export const clearLogs = getMethod("CLEAR_LOGS", bg); export const traces = { addEntry: getNotifier("ADD_TRACE_ENTRY", bg), diff --git a/src/background/messenger/registration.ts b/src/background/messenger/registration.ts index 2f02a50c9e..2a6f74f9dd 100644 --- a/src/background/messenger/registration.ts +++ b/src/background/messenger/registration.ts @@ -48,6 +48,7 @@ import { getAvailableVersion } from "@/background/installer"; import { locator, refreshServices } from "@/background/locator"; import { reactivateEveryTab } from "@/background/navigation"; import { + clearLogs, getLoggingConfig, recordError, recordLog, @@ -98,6 +99,7 @@ declare global { REGISTRY_FIND: typeof registry.find; LOCATE_SERVICE: typeof locator.locate; REFRESH_SERVICES: typeof refreshServices; + LOCATOR_REFRESH_LOCAL: typeof locator.refreshLocal; REQUEST_RUN_ON_SERVER: typeof requestRunOnServer; REQUEST_RUN_IN_OPENER: typeof requestRunInOpener; @@ -118,6 +120,7 @@ declare global { RECORD_EVENT: typeof recordEvent; GET_LOGGING_CONFIG: typeof getLoggingConfig; SET_LOGGING_CONFIG: typeof setLoggingConfig; + CLEAR_LOGS: typeof clearLogs; ADD_TRACE_ENTRY: typeof addTraceEntry; ADD_TRACE_EXIT: typeof addTraceExit; @@ -161,6 +164,7 @@ export default function registerMessenger(): void { REGISTRY_SYNC: registry.syncRemote, REGISTRY_FIND: registry.find, LOCATE_SERVICE: locator.locate.bind(locator), + LOCATOR_REFRESH_LOCAL: locator.refreshLocal.bind(locator), REFRESH_SERVICES: refreshServices, REQUEST_RUN_ON_SERVER: requestRunOnServer, @@ -182,6 +186,7 @@ export default function registerMessenger(): void { RECORD_EVENT: recordEvent, GET_LOGGING_CONFIG: getLoggingConfig, SET_LOGGING_CONFIG: setLoggingConfig, + CLEAR_LOGS: clearLogs, ADD_TRACE_ENTRY: addTraceEntry, ADD_TRACE_EXIT: addTraceExit, diff --git a/src/blocks/effects/forms.ts b/src/blocks/effects/forms.ts index bc14de449a..a9de1a9717 100644 --- a/src/blocks/effects/forms.ts +++ b/src/blocks/effects/forms.ts @@ -19,7 +19,7 @@ import { Effect } from "@/types"; import { BlockArg, BlockOptions, Logger, Schema } from "@/core"; import { BusinessError } from "@/errors"; import { boolean } from "@/utils"; -import { requireSingleElement } from "@/nativeEditor/utils"; +import { requireSingleElement } from "@/utils/requireSingleElement"; import { RequireExactlyOne } from "type-fest"; type SetValueData = RequireExactlyOne< diff --git a/src/blocks/effects/sidebar.ts b/src/blocks/effects/sidebar.ts index 047b7dbd92..9be5b85248 100644 --- a/src/blocks/effects/sidebar.ts +++ b/src/blocks/effects/sidebar.ts @@ -17,7 +17,7 @@ import { Effect } from "@/types"; import { Schema } from "@/core"; -import { hideActionPanel, showActionPanel } from "@/actionPanel/native"; +import { hideActionPanel, showActionPanel } from "@/contentScript/actionPanel"; const NO_PARAMS: Schema = { $schema: "https://json-schema.org/draft/2019-09/schema#", diff --git a/src/blocks/transformers/ephemeralForm/formTransformer.ts b/src/blocks/transformers/ephemeralForm/formTransformer.ts index fe1026d71b..e25128398b 100644 --- a/src/blocks/transformers/ephemeralForm/formTransformer.ts +++ b/src/blocks/transformers/ephemeralForm/formTransformer.ts @@ -30,7 +30,7 @@ import { hideActionPanelForm, PANEL_HIDING_EVENT, showActionPanelForm, -} from "@/actionPanel/native"; +} from "@/contentScript/actionPanel"; import { showModal } from "@/blocks/transformers/ephemeralForm/modalUtils"; // The modes for createFrameSrc are different than the location argument for FormTransformer. The mode for the frame diff --git a/src/actionPanel/native.tsx b/src/contentScript/actionPanel.tsx similarity index 98% rename from src/actionPanel/native.tsx rename to src/contentScript/actionPanel.tsx index 90b57303a6..d603113a59 100644 --- a/src/actionPanel/native.tsx +++ b/src/contentScript/actionPanel.tsx @@ -22,12 +22,12 @@ import { IS_BROWSER } from "@/helpers"; import { reportEvent } from "@/telemetry/events"; import { expectContext } from "@/utils/expectContext"; import { ExtensionRef, UUID } from "@/core"; -import { +import type { ActionPanelStore, FormEntry, PanelEntry, RendererError, -} from "@/actionPanel/actionPanelTypes"; +} from "@/actionPanel/types"; import { RendererPayload } from "@/runtime/runtimeTypes"; import { hideForm, renderPanels, showForm } from "@/actionPanel/messenger/api"; import { MAX_Z_INDEX, PANEL_FRAME_ID } from "@/common"; @@ -188,7 +188,7 @@ export function isActionPanelVisible(): boolean { return Boolean(document.querySelector(PANEL_CONTAINER_SELECTOR)); } -export function getStore(): ActionPanelStore { +export function getActionPanelStore(): ActionPanelStore { // `forms` state is managed by the action panel react component return { panels, forms: [] }; } diff --git a/src/contentScript/devTools.ts b/src/contentScript/devTools.ts index 4822909ea9..559d1b5f3b 100644 --- a/src/contentScript/devTools.ts +++ b/src/contentScript/devTools.ts @@ -27,6 +27,7 @@ import { ReduceOptions, } from "@/runtime/reducePipeline"; import { ApiVersion, BlockArgContext, IReader, RegistryId } from "@/core"; +// eslint-disable-next-line import/no-restricted-paths -- Custom devTools mechanism to transfer data import { selectedElement } from "@/devTools/getSelectedElement"; import { isNullOrBlank, resolveObj } from "@/utils"; import { BlockConfig } from "@/blocks/types"; @@ -36,7 +37,7 @@ import { SerializableResponse } from "@/messaging/protocol"; import apiVersionOptions from "@/runtime/apiVersionOptions"; import { BusinessError } from "@/errors"; import { $safeFind } from "@/helpers"; -import { clearDynamicElements } from "@/nativeEditor/dynamic"; +import { clearDynamicElements } from "@/contentScript/nativeEditor/dynamic"; import { reactivateTab } from "./lifecycle"; import selection from "@/utils/selectionController"; diff --git a/src/contentScript/lifecycle.ts b/src/contentScript/lifecycle.ts index 35738137f2..9e4c6bfe68 100644 --- a/src/contentScript/lifecycle.ts +++ b/src/contentScript/lifecycle.ts @@ -19,7 +19,7 @@ import { loadOptions } from "@/store/extensionsStorage"; import extensionPointRegistry from "@/extensionPoints/registry"; import { ResolvedExtension, IExtensionPoint, RegistryId, UUID } from "@/core"; import * as context from "@/contentScript/context"; -import * as actionPanel from "@/actionPanel/native"; +import * as actionPanel from "@/contentScript/actionPanel"; import { PromiseCancelled, sleep } from "@/utils"; import { NAVIGATION_RULES } from "@/contrib/navigationRules"; import { testMatchPatterns } from "@/blocks/available"; @@ -28,7 +28,7 @@ import browser from "webextension-polyfill"; import { groupBy } from "lodash"; import { resolveDefinitions } from "@/registry/internal"; import { traces } from "@/background/messenger/api"; -import { isDeploymentActive } from "@/options/deploymentUtils"; +import { isDeploymentActive } from "@/utils/deployment"; import { $safeFind } from "@/helpers"; let _scriptPromise: Promise | undefined; diff --git a/src/contentScript/messenger/api.ts b/src/contentScript/messenger/api.ts index 74366853ed..b6fe304e13 100644 --- a/src/contentScript/messenger/api.ts +++ b/src/contentScript/messenger/api.ts @@ -32,6 +32,7 @@ export const toggleActionPanel = getMethod("TOGGLE_ACTION_PANEL"); export const showActionPanel = getMethod("SHOW_ACTION_PANEL"); export const hideActionPanel = getMethod("HIDE_ACTION_PANEL"); export const removeActionPanel = getMethod("REMOVE_ACTION_PANEL"); +export const getActionPanelStore = getMethod("GET_ACTION_PANEL_STORE"); export const insertPanel = getMethod("INSERT_PANEL"); export const insertButton = getMethod("INSERT_BUTTON"); diff --git a/src/contentScript/messenger/registration.ts b/src/contentScript/messenger/registration.ts index a10c10f5a2..ddd521f08d 100644 --- a/src/contentScript/messenger/registration.ts +++ b/src/contentScript/messenger/registration.ts @@ -36,16 +36,17 @@ import { showActionPanel, toggleActionPanel, removeExtension as removeActionPanel, -} from "@/actionPanel/native"; -import { insertPanel } from "@/nativeEditor/insertPanel"; -import { insertButton } from "@/nativeEditor/insertButton"; + getActionPanelStore, +} from "@/contentScript/actionPanel"; +import { insertPanel } from "@/contentScript/nativeEditor/insertPanel"; +import { insertButton } from "@/contentScript/nativeEditor/insertButton"; import { clearDynamicElements, disableOverlay, enableOverlay, runExtensionPointReader, updateDynamicElement, -} from "@/nativeEditor/dynamic"; +} from "@/contentScript/nativeEditor/dynamic"; import { getProcesses, initRobot } from "@/contentScript/uipath"; import { withDetectFrameworkVersions, withSearchWindow } from "@/common"; import { @@ -58,7 +59,10 @@ import { import { checkAvailable } from "@/blocks/available"; import { showNotification } from "@/contentScript/notify"; import { runBrick } from "@/contentScript/executor"; -import { cancelSelect, selectElement } from "@/nativeEditor/selector"; +import { + cancelSelect, + selectElement, +} from "@/contentScript/nativeEditor/selector"; import { runEffectPipeline, runMapArgs, @@ -85,6 +89,8 @@ declare global { SHOW_ACTION_PANEL: typeof showActionPanel; HIDE_ACTION_PANEL: typeof hideActionPanel; REMOVE_ACTION_PANEL: typeof removeActionPanel; + GET_ACTION_PANEL_STORE: typeof getActionPanelStore; + INSERT_PANEL: typeof insertPanel; INSERT_BUTTON: typeof insertButton; @@ -134,6 +140,8 @@ export default function registerMessenger(): void { SHOW_ACTION_PANEL: showActionPanel, HIDE_ACTION_PANEL: hideActionPanel, REMOVE_ACTION_PANEL: removeActionPanel, + GET_ACTION_PANEL_STORE: getActionPanelStore, + INSERT_PANEL: insertPanel, INSERT_BUTTON: insertButton, diff --git a/src/nativeEditor/dynamic.ts b/src/contentScript/nativeEditor/dynamic.ts similarity index 92% rename from src/nativeEditor/dynamic.ts rename to src/contentScript/nativeEditor/dynamic.ts index f495ba9a5c..be3966aef1 100644 --- a/src/nativeEditor/dynamic.ts +++ b/src/contentScript/nativeEditor/dynamic.ts @@ -16,8 +16,6 @@ */ import { - EmptyConfig, - IExtension, IExtensionPoint, IReader, ReaderOutput, @@ -26,12 +24,7 @@ import { } from "@/core"; import { clearDynamic, runDynamic } from "@/contentScript/lifecycle"; import { fromJS as extensionPointFactory } from "@/extensionPoints/factory"; -import Overlay from "@/nativeEditor/Overlay"; -import { - ExtensionPointConfig, - ExtensionPointDefinition, - ExtensionPointType, -} from "@/extensionPoints/types"; +import Overlay from "@/vendors/Overlay"; import { resolveDefinitions } from "@/registry/internal"; import { expectContext } from "@/utils/expectContext"; import { ContextMenuExtensionPoint } from "@/extensionPoints/contextMenu"; @@ -40,15 +33,7 @@ import { $safeFind } from "@/helpers"; import { TriggerDefinition } from "@/extensionPoints/triggerExtension"; import selection from "@/utils/selectionController"; import { ContextMenuReader } from "@/extensionPoints/contextMenuReader"; - -export interface DynamicDefinition< - TExtensionPoint extends ExtensionPointDefinition = ExtensionPointDefinition, - TExtension extends EmptyConfig = EmptyConfig -> { - type: ExtensionPointType; - extensionPoint: ExtensionPointConfig; - extension: IExtension; -} +import type { DynamicDefinition } from "@/contentScript/nativeEditor/types"; let _overlay: Overlay | null = null; const _temporaryExtensions: Map = new Map(); diff --git a/src/nativeEditor/frameworks.ts b/src/contentScript/nativeEditor/frameworks.ts similarity index 90% rename from src/nativeEditor/frameworks.ts rename to src/contentScript/nativeEditor/frameworks.ts index b6f8d5c860..e7b1d11e7e 100644 --- a/src/nativeEditor/frameworks.ts +++ b/src/contentScript/nativeEditor/frameworks.ts @@ -17,16 +17,9 @@ import { Framework } from "@/messaging/constants"; import adapters from "@/frameworks/adapters"; -import { uniq, isEmpty } from "lodash"; -import { inferSelectors } from "@/nativeEditor/infer"; - -export interface ElementInfo { - selectors: string[]; - framework: Framework; - tagName: string; - hasData: boolean; - parent?: ElementInfo; -} +import { isEmpty, uniq } from "lodash"; +import { inferSelectors } from "@/contentScript/nativeEditor/infer"; +import { ElementInfo } from "@/contentScript/nativeEditor/types"; export async function elementInfo( element: HTMLElement, diff --git a/src/nativeEditor/infer.test.tsx b/src/contentScript/nativeEditor/infer.test.tsx similarity index 99% rename from src/nativeEditor/infer.test.tsx rename to src/contentScript/nativeEditor/infer.test.tsx index 6cd626ac41..4b0445ebcc 100644 --- a/src/nativeEditor/infer.test.tsx +++ b/src/contentScript/nativeEditor/infer.test.tsx @@ -21,7 +21,7 @@ import { inferPanelHTML, inferSelectors, safeCssSelector, -} from "@/nativeEditor/infer"; +} from "@/contentScript/nativeEditor/infer"; import { PIXIEBRIX_DATA_ATTR, EXTENSION_POINT_DATA_ATTR } from "@/common"; test("infer basic button", () => { diff --git a/src/nativeEditor/infer.ts b/src/contentScript/nativeEditor/infer.ts similarity index 100% rename from src/nativeEditor/infer.ts rename to src/contentScript/nativeEditor/infer.ts diff --git a/src/nativeEditor/insertButton.tsx b/src/contentScript/nativeEditor/insertButton.tsx similarity index 82% rename from src/nativeEditor/insertButton.tsx rename to src/contentScript/nativeEditor/insertButton.tsx index dd3ff7ee1c..0d88b95acf 100644 --- a/src/nativeEditor/insertButton.tsx +++ b/src/contentScript/nativeEditor/insertButton.tsx @@ -18,34 +18,15 @@ // https://github.com/facebook/react/blob/7559722a865e89992f75ff38c1015a865660c3cd/packages/react-devtools-shared/src/backend/views/Highlighter/index.js import { uuidv4 } from "@/types/helpers"; -import { ElementInfo } from "./frameworks"; import { userSelectElement } from "./selector"; import * as pageScript from "@/pageScript/protocol"; import { findContainer, inferButtonHTML } from "./infer"; -import { - MenuDefinition, - MenuItemExtensionConfig, -} from "@/extensionPoints/menuItemExtension"; import { html as beautifyHTML } from "js-beautify"; -import type { DynamicDefinition } from "./dynamic"; -import { Except } from "type-fest"; -import { UUID } from "@/core"; import { PRIVATE_ATTRIBUTES_SELECTOR } from "@/common"; +import { ButtonSelectionResult } from "@/contentScript/nativeEditor/types"; export const DEFAULT_ACTION_CAPTION = "Action"; -export type ButtonDefinition = DynamicDefinition< - MenuDefinition, - MenuItemExtensionConfig ->; - -export type ButtonSelectionResult = { - uuid: UUID; - menu: Except; - item: Pick; - containerInfo: ElementInfo; -}; - export async function insertButton( useNewFilter = false ): Promise { diff --git a/src/nativeEditor/insertPanel.tsx b/src/contentScript/nativeEditor/insertPanel.tsx similarity index 82% rename from src/nativeEditor/insertPanel.tsx rename to src/contentScript/nativeEditor/insertPanel.tsx index ee97cc06f2..3a4df7d83e 100644 --- a/src/nativeEditor/insertPanel.tsx +++ b/src/contentScript/nativeEditor/insertPanel.tsx @@ -18,27 +18,14 @@ // https://github.com/facebook/react/blob/7559722a865e89992f75ff38c1015a865660c3cd/packages/react-devtools-shared/src/backend/views/Highlighter/index.js import { uuidv4 } from "@/types/helpers"; -import { ElementInfo } from "./frameworks"; import { userSelectElement } from "./selector"; import * as pageScript from "@/pageScript/protocol"; import { findContainer, inferPanelHTML } from "./infer"; import { html as beautifyHTML } from "js-beautify"; -import { PanelConfig, PanelDefinition } from "@/extensionPoints/panelExtension"; -import { Except } from "type-fest"; -import { UUID } from "@/core"; +import { PanelSelectionResult } from "@/contentScript/nativeEditor/types"; const DEFAULT_PANEL_HEADING = "PixieBrix Panel"; -export type PanelSelectionResult = { - uuid: UUID; - foundation: Except< - PanelDefinition, - "defaultOptions" | "isAvailable" | "reader" - >; - panel: Except; - containerInfo: ElementInfo; -}; - export async function insertPanel(): Promise { const selected = await userSelectElement(); diff --git a/src/nativeEditor/selector.ts b/src/contentScript/nativeEditor/selector.ts similarity index 96% rename from src/nativeEditor/selector.ts rename to src/contentScript/nativeEditor/selector.ts index 80d6e6322c..ca21f7e7f4 100644 --- a/src/nativeEditor/selector.ts +++ b/src/contentScript/nativeEditor/selector.ts @@ -14,12 +14,16 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import Overlay from "@/nativeEditor/Overlay"; -import { findContainer, safeCssSelector } from "@/nativeEditor/infer"; +import Overlay from "@/vendors/Overlay"; +import { + findContainer, + safeCssSelector, +} from "@/contentScript/nativeEditor/infer"; import { Framework } from "@/messaging/constants"; import { uniq } from "lodash"; import * as pageScript from "@/pageScript/protocol"; -import { requireSingleElement } from "@/nativeEditor/utils"; +import { requireSingleElement } from "@/utils/requireSingleElement"; +import { SelectMode } from "@/contentScript/nativeEditor/types"; let overlay: Overlay | null = null; let styleElement: HTMLStyleElement = null; @@ -235,8 +239,6 @@ export async function userSelectElement({ }); } -export type SelectMode = "element" | "container"; - export async function cancelSelect() { if (_cancelSelect) { _cancelSelect(); diff --git a/src/contentScript/nativeEditor/types.ts b/src/contentScript/nativeEditor/types.ts new file mode 100644 index 0000000000..fda5c88ee7 --- /dev/null +++ b/src/contentScript/nativeEditor/types.ts @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2022 PixieBrix, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { Framework } from "@/messaging/constants"; +import { + ExtensionPointConfig, + ExtensionPointDefinition, + ExtensionPointType, +} from "@/extensionPoints/types"; +import { EmptyConfig, IExtension, UUID } from "@/core"; +import { Except } from "type-fest"; +import { PanelConfig, PanelDefinition } from "@/extensionPoints/panelExtension"; +import { + MenuDefinition, + MenuItemExtensionConfig, +} from "@/extensionPoints/menuItemExtension"; + +export interface ElementInfo { + selectors: string[]; + framework: Framework; + tagName: string; + hasData: boolean; + parent?: ElementInfo; +} + +export interface DynamicDefinition< + TExtensionPoint extends ExtensionPointDefinition = ExtensionPointDefinition, + TExtension extends EmptyConfig = EmptyConfig +> { + type: ExtensionPointType; + extensionPoint: ExtensionPointConfig; + extension: IExtension; +} + +export type SelectMode = "element" | "container"; +export type PanelSelectionResult = { + uuid: UUID; + foundation: Except< + PanelDefinition, + "defaultOptions" | "isAvailable" | "reader" + >; + panel: Except; + containerInfo: ElementInfo; +}; +export type ButtonDefinition = DynamicDefinition< + MenuDefinition, + MenuItemExtensionConfig +>; +export type ButtonSelectionResult = { + uuid: UUID; + menu: Except; + item: Pick; + containerInfo: ElementInfo; +}; diff --git a/src/devTools/editor/extensionPoints/actionPanel.tsx b/src/devTools/editor/extensionPoints/actionPanel.tsx index bee17e1804..d8bebe5fd5 100644 --- a/src/devTools/editor/extensionPoints/actionPanel.tsx +++ b/src/devTools/editor/extensionPoints/actionPanel.tsx @@ -38,7 +38,6 @@ import { ActionPanelExtensionPoint, PanelDefinition, } from "@/extensionPoints/actionPanelExtension"; -import { DynamicDefinition } from "@/nativeEditor/dynamic"; import { uuidv4 } from "@/types/helpers"; import { getDomain } from "@/permissions/patterns"; import { faColumns } from "@fortawesome/free-solid-svg-icons"; @@ -50,6 +49,7 @@ import { } from "@/devTools/editor/extensionPoints/elementConfig"; import React from "react"; import { Except } from "type-fest"; +import type { DynamicDefinition } from "@/contentScript/nativeEditor/types"; type Extension = BaseExtensionState & Except; diff --git a/src/devTools/editor/extensionPoints/contextMenu.tsx b/src/devTools/editor/extensionPoints/contextMenu.tsx index 922cf64e85..4007073cdb 100644 --- a/src/devTools/editor/extensionPoints/contextMenu.tsx +++ b/src/devTools/editor/extensionPoints/contextMenu.tsx @@ -33,7 +33,6 @@ import { selectIsAvailable, } from "@/devTools/editor/extensionPoints/base"; import { uuidv4 } from "@/types/helpers"; -import { DynamicDefinition } from "@/nativeEditor/dynamic"; import { ExtensionPointConfig } from "@/extensionPoints/types"; import { ContextMenuConfig, @@ -55,6 +54,7 @@ import { NormalizedAvailability } from "@/blocks/types"; import React from "react"; import ContextMenuConfiguration from "@/devTools/editor/tabs/contextMenu/ContextMenuConfiguration"; import { Except } from "type-fest"; +import type { DynamicDefinition } from "@/contentScript/nativeEditor/types"; type Extension = BaseExtensionState & Except; diff --git a/src/devTools/editor/extensionPoints/elementConfig.ts b/src/devTools/editor/extensionPoints/elementConfig.ts index 2aef041e42..40efe8e1e5 100644 --- a/src/devTools/editor/extensionPoints/elementConfig.ts +++ b/src/devTools/editor/extensionPoints/elementConfig.ts @@ -31,10 +31,10 @@ import { ExtensionPointConfig, ExtensionPointType, } from "@/extensionPoints/types"; -import { DynamicDefinition } from "@/nativeEditor/dynamic"; import { BlockPipeline, NormalizedAvailability } from "@/blocks/types"; import { Target } from "@/types"; import { OptionsDefinition } from "@/types/definitions"; +import type { DynamicDefinition } from "@/contentScript/nativeEditor/types"; /** * A simplified type for ReaderConfig to prevent TypeScript reporting problems with infinite type instantiation diff --git a/src/devTools/editor/extensionPoints/menuItem.ts b/src/devTools/editor/extensionPoints/menuItem.ts index d8b6220db2..244edb7839 100644 --- a/src/devTools/editor/extensionPoints/menuItem.ts +++ b/src/devTools/editor/extensionPoints/menuItem.ts @@ -16,10 +16,6 @@ */ import { IExtension, Metadata } from "@/core"; -import { - ButtonDefinition, - ButtonSelectionResult, -} from "@/nativeEditor/insertButton"; import { baseFromExtension, baseSelectExtension, @@ -52,11 +48,15 @@ import { ElementConfig, SingleLayerReaderConfig, } from "@/devTools/editor/extensionPoints/elementConfig"; -import { ElementInfo } from "@/nativeEditor/frameworks"; import { NormalizedAvailability } from "@/blocks/types"; import MenuItemConfiguration from "@/devTools/editor/tabs/menuItem/MenuItemConfiguration"; import { insertButton } from "@/contentScript/messenger/api"; import { Except } from "type-fest"; +import { + ButtonDefinition, + ButtonSelectionResult, + ElementInfo, +} from "@/contentScript/nativeEditor/types"; type Extension = BaseExtensionState & Except; diff --git a/src/devTools/editor/extensionPoints/panel.ts b/src/devTools/editor/extensionPoints/panel.ts index 5a3846b238..98521a376e 100644 --- a/src/devTools/editor/extensionPoints/panel.ts +++ b/src/devTools/editor/extensionPoints/panel.ts @@ -37,8 +37,6 @@ import { PanelDefinition, PanelExtensionPoint, } from "@/extensionPoints/panelExtension"; -import { DynamicDefinition } from "@/nativeEditor/dynamic"; -import { PanelSelectionResult } from "@/nativeEditor/insertPanel"; import { uuidv4 } from "@/types/helpers"; import { boolean } from "@/utils"; import { getDomain } from "@/permissions/patterns"; @@ -49,12 +47,16 @@ import { ElementConfig, SingleLayerReaderConfig, } from "@/devTools/editor/extensionPoints/elementConfig"; -import { ElementInfo } from "@/nativeEditor/frameworks"; import { MenuPosition } from "@/extensionPoints/menuItemExtension"; import { NormalizedAvailability } from "@/blocks/types"; import PanelConfiguration from "@/devTools/editor/tabs/panel/PanelConfiguration"; import { insertPanel } from "@/contentScript/messenger/api"; import { Except } from "type-fest"; +import { + DynamicDefinition, + ElementInfo, + PanelSelectionResult, +} from "@/contentScript/nativeEditor/types"; export type PanelTraits = { style: { diff --git a/src/devTools/editor/extensionPoints/quickBar.tsx b/src/devTools/editor/extensionPoints/quickBar.tsx index e4ac2098d8..b238fc9c52 100644 --- a/src/devTools/editor/extensionPoints/quickBar.tsx +++ b/src/devTools/editor/extensionPoints/quickBar.tsx @@ -33,7 +33,6 @@ import { selectIsAvailable, } from "@/devTools/editor/extensionPoints/base"; import { uuidv4 } from "@/types/helpers"; -import { DynamicDefinition } from "@/nativeEditor/dynamic"; import { ExtensionPointConfig } from "@/extensionPoints/types"; import { getDomain } from "@/permissions/patterns"; import { faThLarge } from "@fortawesome/free-solid-svg-icons"; @@ -57,6 +56,7 @@ import { import QuickBarConfiguration from "@/devTools/editor/tabs/quickBar/QuickBarConfiguration"; import { isMac } from "@/utils"; import { isEmpty } from "lodash"; +import type { DynamicDefinition } from "@/contentScript/nativeEditor/types"; type Extension = BaseExtensionState & Except; diff --git a/src/devTools/editor/extensionPoints/trigger.tsx b/src/devTools/editor/extensionPoints/trigger.tsx index bd082a92d2..5df7846936 100644 --- a/src/devTools/editor/extensionPoints/trigger.tsx +++ b/src/devTools/editor/extensionPoints/trigger.tsx @@ -41,7 +41,6 @@ import { TriggerDefinition, TriggerExtensionPoint, } from "@/extensionPoints/triggerExtension"; -import { DynamicDefinition } from "@/nativeEditor/dynamic"; import { ExtensionPointConfig } from "@/extensionPoints/types"; import { identity, pickBy } from "lodash"; import { getDomain } from "@/permissions/patterns"; @@ -54,6 +53,7 @@ import { import { NormalizedAvailability } from "@/blocks/types"; import React from "react"; import TriggerConfiguration from "@/devTools/editor/tabs/trigger/TriggerConfiguration"; +import type { DynamicDefinition } from "@/contentScript/nativeEditor/types"; export interface TriggerFormState extends BaseFormState { type: "trigger"; diff --git a/src/devTools/editor/fields/SelectorSelectorWidget.tsx b/src/devTools/editor/fields/SelectorSelectorWidget.tsx index bd27841805..f144924251 100644 --- a/src/devTools/editor/fields/SelectorSelectorWidget.tsx +++ b/src/devTools/editor/fields/SelectorSelectorWidget.tsx @@ -27,10 +27,8 @@ import { faMousePointer } from "@fortawesome/free-solid-svg-icons"; import CreatableAutosuggest, { SuggestionTypeBase, } from "@/devTools/editor/fields/creatableAutosuggest/CreatableAutosuggest"; -import { ElementInfo } from "@/nativeEditor/frameworks"; import SelectorListItem from "@/devTools/editor/fields/selectorListItem/SelectorListItem"; import { Framework } from "@/messaging/constants"; -import { SelectMode } from "@/nativeEditor/selector"; import { useField } from "formik"; import { disableOverlay, @@ -39,6 +37,7 @@ import { cancelSelect, } from "@/contentScript/messenger/api"; import { thisTab } from "@/devTools/utils"; +import { ElementInfo, SelectMode } from "@/contentScript/nativeEditor/types"; interface ElementSuggestion extends SuggestionTypeBase { value: string; diff --git a/src/devTools/editor/tabs/RunLogCard.tsx b/src/devTools/editor/tabs/RunLogCard.tsx index 0ce4954b58..bff90c53d7 100644 --- a/src/devTools/editor/tabs/RunLogCard.tsx +++ b/src/devTools/editor/tabs/RunLogCard.tsx @@ -16,7 +16,8 @@ */ import React, { useMemo, useState } from "react"; -import { MessageLevel } from "@/background/logging"; +// eslint-disable-next-line import/no-restricted-paths -- Types only +import type { MessageLevel } from "@/background/logging"; import Loader from "@/components/Loader"; import { Card } from "react-bootstrap"; import LogTable from "@/components/logViewer/LogTable"; diff --git a/src/extensionPoints/actionPanelExtension.ts b/src/extensionPoints/actionPanelExtension.ts index 6c8bff5a09..35a6b2b7a5 100644 --- a/src/extensionPoints/actionPanelExtension.ts +++ b/src/extensionPoints/actionPanelExtension.ts @@ -44,7 +44,7 @@ import { ShowCallback, updateHeading, upsertPanel, -} from "@/actionPanel/native"; +} from "@/contentScript/actionPanel"; import Mustache from "mustache"; import { uuidv4 } from "@/types/helpers"; import { BusinessError, getErrorMessage } from "@/errors"; diff --git a/src/extensionPoints/contextMenu.ts b/src/extensionPoints/contextMenu.ts index 39306c5640..e2398058a6 100644 --- a/src/extensionPoints/contextMenu.ts +++ b/src/extensionPoints/contextMenu.ts @@ -45,7 +45,7 @@ import { reportEvent } from "@/telemetry/events"; import { selectEventData } from "@/telemetry/deployments"; import { selectExtensionContext } from "@/extensionPoints/helpers"; import { BlockConfig, BlockPipeline } from "@/blocks/types"; -import { isDeploymentActive } from "@/options/deploymentUtils"; +import { isDeploymentActive } from "@/utils/deployment"; import apiVersionOptions from "@/runtime/apiVersionOptions"; import { blockList } from "@/blocks/util"; import { mergeReaders } from "@/blocks/readers/readerUtils"; diff --git a/src/options/pages/activateExtension/useEnsurePermissions.ts b/src/options/pages/activateExtension/useEnsurePermissions.ts index 6339ea3319..2b0b10969d 100644 --- a/src/options/pages/activateExtension/useEnsurePermissions.ts +++ b/src/options/pages/activateExtension/useEnsurePermissions.ts @@ -20,10 +20,12 @@ import { ServiceDependency } from "@/core"; import useNotifications from "@/hooks/useNotifications"; import { useFormikContext } from "formik"; import { useAsyncState } from "@/hooks/common"; -import { locator } from "@/background/locator"; import { collectPermissions, ensureAllPermissions } from "@/permissions"; import { resolveDefinitions } from "@/registry/internal"; -import { containsPermissions } from "@/background/messenger/api"; +import { + containsPermissions, + services as locator, +} from "@/background/messenger/api"; import { useCallback } from "react"; import { getErrorMessage } from "@/errors"; import { reportEvent } from "@/telemetry/events"; diff --git a/src/options/pages/brickEditor/BrickLogs.tsx b/src/options/pages/brickEditor/BrickLogs.tsx index 1b8a9af306..c41093c177 100644 --- a/src/options/pages/brickEditor/BrickLogs.tsx +++ b/src/options/pages/brickEditor/BrickLogs.tsx @@ -16,7 +16,8 @@ */ import React, { useState } from "react"; -import { MessageLevel } from "@/background/logging"; +// eslint-disable-next-line import/no-restricted-paths -- Types only +import type { MessageLevel } from "@/background/logging"; import Loader from "@/components/Loader"; import { Card } from "react-bootstrap"; import { MessageContext } from "@/core"; diff --git a/src/options/pages/installed/ActiveBricksCard.tsx b/src/options/pages/installed/ActiveBricksCard.tsx index 74c444f45e..434c0c2025 100644 --- a/src/options/pages/installed/ActiveBricksCard.tsx +++ b/src/options/pages/installed/ActiveBricksCard.tsx @@ -31,7 +31,7 @@ import ExtensionGroup from "./ExtensionGroup"; import ExtensionGroupHeader from "./ExtensionGroupHeader"; import { groupBy } from "lodash"; import ExtensionRows from "./ExtensionRows"; -import { isDeploymentActive } from "@/options/deploymentUtils"; +import { isDeploymentActive } from "@/utils/deployment"; import { useGetOrganizationsQuery, useGetRecipesQuery, diff --git a/src/options/pages/marketplace/useEnsurePermissions.ts b/src/options/pages/marketplace/useEnsurePermissions.ts index f74688ec51..af87e3aabc 100644 --- a/src/options/pages/marketplace/useEnsurePermissions.ts +++ b/src/options/pages/marketplace/useEnsurePermissions.ts @@ -20,10 +20,9 @@ import { ServiceAuthPair } from "@/core"; import useNotifications from "@/hooks/useNotifications"; import { useFormikContext } from "formik"; import { useAsyncState } from "@/hooks/common"; -import { locator } from "@/background/locator"; import { collectPermissions, ensureAllPermissions } from "@/permissions"; import { resolveRecipe } from "@/registry/internal"; -import { containsPermissions } from "@/background/messenger/api"; +import { containsPermissions, services } from "@/background/messenger/api"; import { useCallback } from "react"; import { getErrorMessage } from "@/errors"; import { reportEvent } from "@/telemetry/events"; @@ -37,7 +36,7 @@ function useEnsurePermissions( const { submitForm } = useFormikContext(); const [permissionState, isPending, error] = useAsyncState(async () => { - await locator.refreshLocal(); + await services.refreshLocal(); const permissions = await collectPermissions( await resolveRecipe(blueprint, selected), serviceAuths diff --git a/src/options/pages/settings/LoggingSettings.tsx b/src/options/pages/settings/LoggingSettings.tsx index 7392fd21f5..b91f4eeb10 100644 --- a/src/options/pages/settings/LoggingSettings.tsx +++ b/src/options/pages/settings/LoggingSettings.tsx @@ -22,7 +22,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faInfoCircle, faTrash } from "@fortawesome/free-solid-svg-icons"; import BootstrapSwitchButton from "bootstrap-switch-button-react"; import Loader from "@/components/Loader"; -import { clearLogs } from "@/background/logging"; +import { clearLogs } from "@/background/messenger/api"; import AsyncButton from "@/components/AsyncButton"; import useUserAction from "@/hooks/useUserAction"; diff --git a/src/pageScript/protocol.ts b/src/pageScript/protocol.ts index 43f592d58e..e6a63929b0 100644 --- a/src/pageScript/protocol.ts +++ b/src/pageScript/protocol.ts @@ -23,8 +23,8 @@ import { SET_COMPONENT_DATA, } from "@/messaging/constants"; import { ReaderOutput } from "@/core"; -import { ElementInfo } from "@/nativeEditor/frameworks"; import { cleanValue } from "@/utils"; +import { ElementInfo } from "@/contentScript/nativeEditor/types"; export type PathSpec = | string diff --git a/src/script.ts b/src/script.ts index 60be7dd2bf..cd2036abea 100644 --- a/src/script.ts +++ b/src/script.ts @@ -70,8 +70,8 @@ import { traverse, WriteableComponentAdapter, } from "@/frameworks/component"; -import { elementInfo } from "@/nativeEditor/frameworks"; -import { requireSingleElement } from "@/nativeEditor/utils"; +import { elementInfo } from "@/contentScript/nativeEditor/frameworks"; +import { requireSingleElement } from "@/utils/requireSingleElement"; import { getPropByPath, noopProxy, ReadProxy } from "@/runtime/pathHelpers"; import { UnknownObject } from "@/types"; diff --git a/src/tests/factories.ts b/src/tests/factories.ts index 297da4c436..e3e69169d4 100644 --- a/src/tests/factories.ts +++ b/src/tests/factories.ts @@ -42,7 +42,6 @@ import trigger, { import menuItem, { ActionFormState, } from "@/devTools/editor/extensionPoints/menuItem"; -import { ButtonSelectionResult } from "@/nativeEditor/insertButton"; import { FormState } from "@/devTools/editor/slices/editorSlice"; import { RecipeDefinition, @@ -59,6 +58,7 @@ import { } from "@/devTools/context"; import { TypedBlock, TypedBlockMap } from "@/blocks/registry"; import { Deployment } from "@/types/contract"; +import { ButtonSelectionResult } from "@/contentScript/nativeEditor/types"; export const recipeMetadataFactory = define({ id: (n: number) => validateRegistryId(`test/recipe-${n}`), diff --git a/src/options/deploymentUtils.ts b/src/utils/deployment.ts similarity index 100% rename from src/options/deploymentUtils.ts rename to src/utils/deployment.ts diff --git a/src/nativeEditor/utils.ts b/src/utils/requireSingleElement.ts similarity index 100% rename from src/nativeEditor/utils.ts rename to src/utils/requireSingleElement.ts diff --git a/src/utils/selectionController.ts b/src/utils/selectionController.ts index 7e29a819b7..0263f490dd 100644 --- a/src/utils/selectionController.ts +++ b/src/utils/selectionController.ts @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -import { getCommonAncestor } from "@/nativeEditor/infer"; +import { getCommonAncestor } from "@/contentScript/nativeEditor/infer"; /** * Get the HTMLElement corresponding to the current selection. diff --git a/src/nativeEditor/Overlay.tsx b/src/vendors/Overlay.tsx similarity index 100% rename from src/nativeEditor/Overlay.tsx rename to src/vendors/Overlay.tsx