diff --git a/src/main/resources/index.d.ts b/src/main/resources/index.d.ts index bf2ab0b6..7fccdc65 100644 --- a/src/main/resources/index.d.ts +++ b/src/main/resources/index.d.ts @@ -1,12 +1,8 @@ export { Cache, - Component, ComponentType, + EntryName, OneOrMore, - PageContributions, - React4xp, - Request, - Response, Stats, } from './types/index.d'; diff --git a/src/main/resources/lib/enonic/react4xp/React4xp.ts b/src/main/resources/lib/enonic/react4xp/React4xp.ts index 90018d26..a2bccfe6 100644 --- a/src/main/resources/lib/enonic/react4xp/React4xp.ts +++ b/src/main/resources/lib/enonic/react4xp/React4xp.ts @@ -1,5 +1,6 @@ import type { Component, + PageContributions, Request, Response, } from '@enonic-types/core'; @@ -7,7 +8,6 @@ import type { Entry, Id, Instance, - PageContributions, // React4xp as React4xpNamespace, UrlType } from '@enonic-types/lib-react4xp'; diff --git a/src/main/resources/lib/enonic/react4xp/React4xp/methods/renderBody.ts b/src/main/resources/lib/enonic/react4xp/React4xp/methods/renderBody.ts index 5ab37cda..1cab1018 100644 --- a/src/main/resources/lib/enonic/react4xp/React4xp/methods/renderBody.ts +++ b/src/main/resources/lib/enonic/react4xp/React4xp/methods/renderBody.ts @@ -1,4 +1,4 @@ -import type { Request } from '../../../../..'; +import type { Request } from '@enonic-types/core'; import type { React4xp } from '../../React4xp'; import isEditMode from '/lib/enonic/react4xp/React4xp/utils/isEditMode'; import getSsrConfig from '/lib/enonic/react4xp/React4xp/utils/getSsrConfig'; diff --git a/src/main/resources/lib/enonic/react4xp/React4xp/methods/renderPageContributions.ts b/src/main/resources/lib/enonic/react4xp/React4xp/methods/renderPageContributions.ts index 29a9679f..d47034d3 100644 --- a/src/main/resources/lib/enonic/react4xp/React4xp/methods/renderPageContributions.ts +++ b/src/main/resources/lib/enonic/react4xp/React4xp/methods/renderPageContributions.ts @@ -1,11 +1,11 @@ +import type { + PageContributions, + Request, +} from '@enonic-types/core'; import type { AppConfig, UrlType } from '@enonic-types/lib-react4xp'; -import type { - PageContributions, - Request -} from '../../../../..'; import type { React4xp } from '../../React4xp'; import { isSet } from '@enonic/js-utils/value/isSet'; //import {toStr} from '@enonic/js-utils/value/toStr'; diff --git a/src/main/resources/lib/enonic/react4xp/React4xp/methods/renderSSRIntoContainer.ts b/src/main/resources/lib/enonic/react4xp/React4xp/methods/renderSSRIntoContainer.ts index ff8b3bef..754a5e3d 100644 --- a/src/main/resources/lib/enonic/react4xp/React4xp/methods/renderSSRIntoContainer.ts +++ b/src/main/resources/lib/enonic/react4xp/React4xp/methods/renderSSRIntoContainer.ts @@ -1,4 +1,4 @@ -import type {Request} from '../../../../..'; +import type {Request} from '@enonic-types/core'; import type {React4xp} from '../../React4xp'; diff --git a/src/main/resources/lib/enonic/react4xp/React4xp/methods/renderWarningPlaceholder.ts b/src/main/resources/lib/enonic/react4xp/React4xp/methods/renderWarningPlaceholder.ts index 4f5fd53a..e29482cc 100644 --- a/src/main/resources/lib/enonic/react4xp/React4xp/methods/renderWarningPlaceholder.ts +++ b/src/main/resources/lib/enonic/react4xp/React4xp/methods/renderWarningPlaceholder.ts @@ -1,4 +1,4 @@ -import type { React4xp } from '@enonic-types/lib-react4xp'; +import type { React4xp } from '..'; export function renderWarningPlaceholder(this: React4xp) { diff --git a/src/main/resources/lib/enonic/react4xp/asset/cache.ts b/src/main/resources/lib/enonic/react4xp/asset/cache.ts index d0ad0e1d..4e6ae402 100644 --- a/src/main/resources/lib/enonic/react4xp/asset/cache.ts +++ b/src/main/resources/lib/enonic/react4xp/asset/cache.ts @@ -1,7 +1,7 @@ import type { Request, Response -} from '../../../..'; +} from '@enonic-types/core'; import {includes} from '@enonic/js-utils/array/includes'; diff --git a/src/main/resources/lib/enonic/react4xp/asset/handleAssetRequest.ts b/src/main/resources/lib/enonic/react4xp/asset/handleAssetRequest.ts index b888b268..53dc4a98 100644 --- a/src/main/resources/lib/enonic/react4xp/asset/handleAssetRequest.ts +++ b/src/main/resources/lib/enonic/react4xp/asset/handleAssetRequest.ts @@ -1,7 +1,7 @@ import type { Request, Response -} from '../../../..'; +} from '@enonic-types/core'; import {startsWith} from '@enonic/js-utils/string/startsWith'; // import {toStr} from '@enonic/js-utils/value/toStr'; import {eTagGetter} from '/lib/enonic/react4xp/asset/eTagGetter'; diff --git a/src/main/resources/lib/enonic/react4xp/clientCacheResources.ts b/src/main/resources/lib/enonic/react4xp/clientCacheResources.ts index 126a9b5b..4744e04e 100644 --- a/src/main/resources/lib/enonic/react4xp/clientCacheResources.ts +++ b/src/main/resources/lib/enonic/react4xp/clientCacheResources.ts @@ -1,6 +1,4 @@ -import type { - Response, -} from '../../..'; +import type { Response } from '@enonic-types/core'; import {forceArray} from '@enonic/js-utils/array/forceArray'; diff --git a/src/main/resources/lib/enonic/react4xp/dependencies/forceTrimmedArray.ts b/src/main/resources/lib/enonic/react4xp/dependencies/forceTrimmedArray.ts index 62257fae..4c2e87a0 100644 --- a/src/main/resources/lib/enonic/react4xp/dependencies/forceTrimmedArray.ts +++ b/src/main/resources/lib/enonic/react4xp/dependencies/forceTrimmedArray.ts @@ -1,13 +1,13 @@ import type { + EntryName, OneOrMore, - React4xp as React4xpNamespace } from '../../../../index.d'; import {isString} from '@enonic/js-utils/value/isString'; -export function forceTrimmedArray(entryNames :OneOrMore = []) :Array { +export function forceTrimmedArray(entryNames: OneOrMore = []): EntryName[] { if (isString(entryNames)) { const trimmed = entryNames.trim(); return (trimmed === "") diff --git a/src/main/resources/lib/enonic/react4xp/dependencies/getComponentChunkNames.ts b/src/main/resources/lib/enonic/react4xp/dependencies/getComponentChunkNames.ts index 3b6bfeb7..f18f3548 100644 --- a/src/main/resources/lib/enonic/react4xp/dependencies/getComponentChunkNames.ts +++ b/src/main/resources/lib/enonic/react4xp/dependencies/getComponentChunkNames.ts @@ -1,6 +1,6 @@ import type { + EntryName, OneOrMore, - React4xp as React4xpNamespace } from '../../../../index.d'; @@ -11,7 +11,7 @@ import {readComponentChunkNamesCached} from '/lib/enonic/react4xp/dependencies/r import {IS_PROD_MODE} from '/lib/enonic/react4xp/xp/appHelper'; -export function getComponentChunkNames(entryNames :OneOrMore) { +export function getComponentChunkNames(entryNames: OneOrMore) { const componentChunkNames = IS_PROD_MODE ? readComponentChunkNamesCached(entryNames) : readComponentChunkNames(forceTrimmedArray(entryNames)); diff --git a/src/main/resources/lib/enonic/react4xp/dependencies/getComponentChunkUrls.ts b/src/main/resources/lib/enonic/react4xp/dependencies/getComponentChunkUrls.ts index c89b8e35..f3d93fa8 100644 --- a/src/main/resources/lib/enonic/react4xp/dependencies/getComponentChunkUrls.ts +++ b/src/main/resources/lib/enonic/react4xp/dependencies/getComponentChunkUrls.ts @@ -1,7 +1,7 @@ import type { UrlType } from '@enonic-types/lib-react4xp'; import type { + EntryName, OneOrMore, - React4xp as React4xpNamespace } from '../../../../index.d'; @@ -11,7 +11,7 @@ import { getComponentChunkNames } from '/lib/enonic/react4xp/dependencies/getCom // NOTE: This function is exported in ..React4xp.ts, so a major release is needed to change it's signature. // TODO: Change to single param with two properties. -export function getComponentChunkUrls(entries: OneOrMore, { +export function getComponentChunkUrls(entries: OneOrMore, { urlType // default is app.config['react4xp.urlType'] || 'server' }: { urlType?: UrlType diff --git a/src/main/resources/lib/enonic/react4xp/dependencies/normalizeEntryNames.ts b/src/main/resources/lib/enonic/react4xp/dependencies/normalizeEntryNames.ts index 83b86e3a..ef5d6aea 100644 --- a/src/main/resources/lib/enonic/react4xp/dependencies/normalizeEntryNames.ts +++ b/src/main/resources/lib/enonic/react4xp/dependencies/normalizeEntryNames.ts @@ -1,13 +1,13 @@ import type { + EntryName, OneOrMore, - React4xp as React4xpNamespace } from '../../../../index.d'; import {forceTrimmedArray} from '/lib/enonic/react4xp/dependencies/forceTrimmedArray'; -export function normalizeEntryNames(entryNames :OneOrMore = []) :Array { +export function normalizeEntryNames(entryNames: OneOrMore = []): EntryName[] { const arr = forceTrimmedArray(entryNames); arr.sort() return arr; diff --git a/src/main/resources/lib/enonic/react4xp/dependencies/readComponentChunkNames.ts b/src/main/resources/lib/enonic/react4xp/dependencies/readComponentChunkNames.ts index 2a7a5b29..3e2c7296 100644 --- a/src/main/resources/lib/enonic/react4xp/dependencies/readComponentChunkNames.ts +++ b/src/main/resources/lib/enonic/react4xp/dependencies/readComponentChunkNames.ts @@ -1,6 +1,6 @@ import type { + EntryName, OneOrMore, - React4xp as React4xpNamespace } from '../../../../index.d'; @@ -24,7 +24,7 @@ let buildStatsEntrypoints :Object|undefined; * ASSUMES that stats.json.entrypoints is an object where the keys are entry names without file extensions, mapping to values that are objects, * which in turn have an "assets" key, under which are the full file names of the entry's dependencies. * If the input array is empty or null, returns ALL dependency chunk names. */ -export function readComponentChunkNames(entryNames :OneOrMore) { +export function readComponentChunkNames(entryNames: OneOrMore) { //log.debug('readComponentChunkNames(%s)', toStr(entryNames)); // Just verify that it exists and has a content: @@ -39,7 +39,7 @@ export function readComponentChunkNames(entryNames :OneOrMore).forEach(entry => { + (entryNames as Array).forEach(entry => { try { let data = buildStatsEntrypoints[entry]; if (!data) { diff --git a/src/main/resources/lib/enonic/react4xp/dependencies/readComponentChunkNamesCached.ts b/src/main/resources/lib/enonic/react4xp/dependencies/readComponentChunkNamesCached.ts index 4514713d..7f58dc7f 100644 --- a/src/main/resources/lib/enonic/react4xp/dependencies/readComponentChunkNamesCached.ts +++ b/src/main/resources/lib/enonic/react4xp/dependencies/readComponentChunkNamesCached.ts @@ -1,6 +1,6 @@ import type { + EntryName, OneOrMore, - React4xp as React4xpNamespace } from '../../../../index.d'; @@ -14,7 +14,7 @@ import {readComponentChunkNames} from '/lib/enonic/react4xp/dependencies/readCom // WARNING: Do not cache anything that contains assetRoot, it changes per context! // But since this doesn't contain assetRoot, it's ok to cache :) // Cached version of readComponentChunkNames - used in prod mode -export function readComponentChunkNamesCached(entryNames :OneOrMore) :Array { +export function readComponentChunkNamesCached(entryNames: OneOrMore): string[] { entryNames = normalizeEntryNames(entryNames); const cacheKey = getSiteLocalCacheKey(entryNames.join("*")); diff --git a/src/main/resources/lib/enonic/react4xp/htmlHandling.ts b/src/main/resources/lib/enonic/react4xp/htmlHandling.ts index c92df167..b69efe28 100644 --- a/src/main/resources/lib/enonic/react4xp/htmlHandling.ts +++ b/src/main/resources/lib/enonic/react4xp/htmlHandling.ts @@ -1,16 +1,15 @@ import type { Request } from '@enonic-types/core'; import type { Id, - React4xp, + Instance, } from '@enonic-types/lib-react4xp'; -//import type {React4xp} from './React4xp'; export function buildErrorContainer( heading: string, message: string, request: Request, - react4xpObj: React4xp.Instance | { + react4xpObj: Instance | { jsxPath: string|object react4xpId: Id }, diff --git a/src/main/resources/lib/enonic/react4xp/pageContributions/buildPageContributions.ts b/src/main/resources/lib/enonic/react4xp/pageContributions/buildPageContributions.ts index 1a348930..79916c53 100644 --- a/src/main/resources/lib/enonic/react4xp/pageContributions/buildPageContributions.ts +++ b/src/main/resources/lib/enonic/react4xp/pageContributions/buildPageContributions.ts @@ -1,8 +1,8 @@ +import type { PageContributions } from '@enonic-types/core'; import type { UrlType } from '@enonic-types/lib-react4xp'; import type { + EntryName, OneOrMore, - PageContributions, - React4xp as React4xpNamespace } from '../../../../index.d'; @@ -24,7 +24,7 @@ export function buildPageContributions({ suppressJS, urlType // default is app.config['react4xp.urlType'] || 'server' }: { - entries: OneOrMore + entries: OneOrMore suppressJS: boolean urlType?: UrlType }) { diff --git a/src/main/resources/lib/enonic/react4xp/pageContributions/getAndMerge.ts b/src/main/resources/lib/enonic/react4xp/pageContributions/getAndMerge.ts index 9d1319a4..0e5608d9 100644 --- a/src/main/resources/lib/enonic/react4xp/pageContributions/getAndMerge.ts +++ b/src/main/resources/lib/enonic/react4xp/pageContributions/getAndMerge.ts @@ -1,8 +1,8 @@ +import type { PageContributions } from '@enonic-types/core'; import type { UrlType } from '@enonic-types/lib-react4xp'; import type { - OneOrMore, - PageContributions, - React4xp as React4xpNamespace + EntryName, + OneOrMore } from '../../../../index.d'; @@ -30,7 +30,7 @@ export function getAndMerge({ suppressJS, urlType // default is app.config['react4xp.urlType'] || 'server' }: { - entryNames: OneOrMore + entryNames: OneOrMore incomingPgContrib: PageContributions newPgContrib: PageContributions suppressJS: boolean diff --git a/src/main/resources/types/Component.d.ts b/src/main/resources/types/Component.d.ts index 40275088..9ad57b4f 100644 --- a/src/main/resources/types/Component.d.ts +++ b/src/main/resources/types/Component.d.ts @@ -1,37 +1 @@ -// import type { Region } from "@enonic-types/lib-portal"; -export type { Component, PageComponent, PartComponent, TextComponent } from "@enonic-types/lib-portal"; - export type ComponentType = 'fragment'|'layout'|'page'|'part'|'text'; // image? region? - - -// export interface PageComponent { -// config: PageConfig -// descriptor: string -// path: string -// regions: Record -// template: string // TODO: Missing from lib-portal -// type: 'page' -// } - - -// export interface PartComponent { -// config: PartConfig -// descriptor: string -// path: string -// type: ComponentType -// } - - -// export interface TextComponent { -// path: string -// text: string -// type: 'text' -// } - -// export type Component = PageComponent | PartComponent// | TextComponent; - -// This is stricter than lib-portal -// interface Region { -// components: Array -// name: Name -// } diff --git a/src/main/resources/types/DoubleUnderscore.d.ts b/src/main/resources/types/DoubleUnderscore.d.ts deleted file mode 100644 index f35486ca..00000000 --- a/src/main/resources/types/DoubleUnderscore.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface DoubleUnderscore { - disposer :(fn :() => void) => void - newBean :(string :string) => unknown - nullOrValue :(value :unknown) => null|unknown - registerMock :(name :string, value:unknown) => void - toNativeObject :(value :unknown) => unknown - toScriptValue :(value :unknown) => unknown -} diff --git a/src/main/resources/types/Log.d.ts b/src/main/resources/types/Log.d.ts deleted file mode 100644 index 582d8611..00000000 --- a/src/main/resources/types/Log.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface Log { - debug(message :string, ...args :unknown[]): void - error(message :string, ...args :unknown[]): void - info(message :string, ...args :unknown[]): void - warning(message :string, ...args :unknown[]): void -} diff --git a/src/main/resources/types/PageContributions.d.ts b/src/main/resources/types/PageContributions.d.ts deleted file mode 100644 index 7bb74133..00000000 --- a/src/main/resources/types/PageContributions.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface PageContributions { - headBegin?: string[] - headEnd?: string[] - bodyBegin?: string[] - bodyEnd?: string[] -} diff --git a/src/main/resources/types/index.d.ts b/src/main/resources/types/index.d.ts index 3007e573..1c0fadb7 100644 --- a/src/main/resources/types/index.d.ts +++ b/src/main/resources/types/index.d.ts @@ -1,19 +1,12 @@ export {AppConfig} from './Application.d'; export {Cache} from './Cache.d'; -export { - Component, - ComponentType -} from './Component.d'; +export {ComponentType} from './Component.d'; export type { PageTemplateContent } from './ContentTypes'; -export {DoubleUnderscore} from './DoubleUnderscore.d'; -export {Log} from './Log.d'; -export {PageContributions} from './PageContributions.d'; export { Entry, + EntryName, Id, Instance, - Props, - React4xp, UrlType } from './React4xp.d'; export {Stats} from './Stats.d';