From 3476bd610a5781fd2692faa2bca0b1789d9e5816 Mon Sep 17 00:00:00 2001 From: Rolf Heij Date: Tue, 5 Dec 2023 16:50:13 +0100 Subject: [PATCH 01/10] Added @papi/core --- extensions/.eslintrc.cjs | 13 +- .../src/c-sharp-provider-test/index.d.ts | 3 +- extensions/src/evil/evil.js | 2 +- .../src/hello-someone/hello-someone.d.ts | 3 +- extensions/src/hello-someone/hello-someone.ts | 18 +- .../hello-someone/hello-someone.web-view.html | 4 +- extensions/src/hello-world/hello-world.d.ts | 3 +- extensions/src/hello-world/hello-world.ts | 10 +- .../web-views/components/clock.component.tsx | 2 +- .../web-views/hello-world-2.web-view.tsx | 4 +- .../web-views/hello-world.web-view.html | 6 +- .../web-views/hello-world.web-view.tsx | 7 +- .../project-notes-data-provider/index.d.ts | 8 +- extensions/src/quick-verse/quick-verse.d.ts | 3 +- extensions/src/quick-verse/quick-verse.ts | 12 +- .../src/resource-viewer/resource-viewer.ts | 10 +- .../resource-viewer.web-view.tsx | 6 +- extensions/src/usfm-data-provider/index.d.ts | 8 +- extensions/webpack/webpack.config.base.ts | 8 +- lib/papi-dts/.eslintrc.cjs | 2 +- lib/papi-dts/edit-papi-d-ts.ts | 12 +- lib/papi-dts/papi.d.ts | 1888 +++++++++-------- lib/papi-dts/tsconfig.json | 7 +- src/declarations/README.md | 2 +- src/declarations/papi-shared-types.ts | 2 +- .../services/extension.service.ts | 2 +- src/renderer/global-this.model.ts | 10 +- src/shared/services/papi-core.service.ts | 35 + 28 files changed, 1086 insertions(+), 1004 deletions(-) create mode 100644 src/shared/services/papi-core.service.ts diff --git a/extensions/.eslintrc.cjs b/extensions/.eslintrc.cjs index 7772be355c..ecdaf1c667 100644 --- a/extensions/.eslintrc.cjs +++ b/extensions/.eslintrc.cjs @@ -1,7 +1,18 @@ module.exports = { extends: '../.eslintrc.js', rules: { - 'import/no-unresolved': ['error', { ignore: ['papi'] }], + 'import/no-unresolved': ['error', { ignore: ['@papi'] }], + 'no-restricted-imports': [ + 'error', + { + patterns: [ + { + group: ['shared/*', 'renderer/*', 'extension-host/*', 'node/*', 'client/*', 'main/*'], + message: `Importing from this path is not allowed. Try importing from @papi/core. Imports from paths like 'shared', 'renderer', 'node', 'client' and 'main' are not allowed to prevent unnecessary import break.`, + }, + ], + }, + ], }, overrides: [ { diff --git a/extensions/src/c-sharp-provider-test/index.d.ts b/extensions/src/c-sharp-provider-test/index.d.ts index a5b4b79670..a98f1025e4 100644 --- a/extensions/src/c-sharp-provider-test/index.d.ts +++ b/extensions/src/c-sharp-provider-test/index.d.ts @@ -1,6 +1,5 @@ declare module 'c-sharp-provider-test' { - import type { DataProviderDataType } from 'shared/models/data-provider.model'; - import type IDataProvider from 'shared/models/data-provider.interface'; + import { IDataProvider, DataProviderDataType } from '@papi/core'; type TimeDataTypes = { Time: DataProviderDataType; diff --git a/extensions/src/evil/evil.js b/extensions/src/evil/evil.js index a68965e9a4..4772e23c8d 100644 --- a/extensions/src/evil/evil.js +++ b/extensions/src/evil/evil.js @@ -2,7 +2,7 @@ 'use strict'; -const papi = require('papi-backend'); +const papi = require('@papi/backend'); const { logger } = papi; diff --git a/extensions/src/hello-someone/hello-someone.d.ts b/extensions/src/hello-someone/hello-someone.d.ts index 20efec054d..124b07e91e 100644 --- a/extensions/src/hello-someone/hello-someone.d.ts +++ b/extensions/src/hello-someone/hello-someone.d.ts @@ -1,6 +1,5 @@ declare module 'hello-someone' { - import type IDataProvider from 'shared/models/data-provider.interface'; - import type { DataProviderDataType } from 'shared/models/data-provider.model'; + import { IDataProvider, DataProviderDataType } from '@papi/core'; export type Person = { greeting?: string; diff --git a/extensions/src/hello-someone/hello-someone.ts b/extensions/src/hello-someone/hello-someone.ts index 6ccac4b165..2d65ca9d72 100644 --- a/extensions/src/hello-someone/hello-someone.ts +++ b/extensions/src/hello-someone/hello-someone.ts @@ -1,15 +1,15 @@ -import papi, { logger } from 'papi-backend'; -import type { ExecutionActivationContext } from 'extension-host/extension-types/extension-activation-context.model'; -import type { +import papi, { logger } from '@papi/backend'; +import { + DataProviderUpdateInstructions, + ExecutionActivationContext, + IWebViewProvider, + SavedWebViewDefinition, WebViewContentType, WebViewDefinition, - SavedWebViewDefinition, -} from 'shared/models/web-view.model'; + WithNotifyUpdate, + IDataProviderEngine, +} from '@papi/core'; import type { PeopleData, PeopleDataMethods, PeopleDataTypes, Person } from 'hello-someone'; -import type { DataProviderUpdateInstructions } from 'shared/models/data-provider.model'; -import type IDataProviderEngine from 'shared/models/data-provider-engine.model'; -import type { WithNotifyUpdate } from 'shared/models/data-provider-engine.model'; -import type { IWebViewProvider } from 'shared/models/web-view-provider.model'; import helloSomeoneHtmlWebView from './hello-someone.web-view.html?inline'; logger.info('Hello Someone is importing!'); diff --git a/extensions/src/hello-someone/hello-someone.web-view.html b/extensions/src/hello-someone/hello-someone.web-view.html index ba8f605a80..68614b13f9 100644 --- a/extensions/src/hello-someone/hello-someone.web-view.html +++ b/extensions/src/hello-someone/hello-someone.web-view.html @@ -32,8 +32,8 @@