From e4219ce5bb1789ef2f67cd8ff5836379ee96b140 Mon Sep 17 00:00:00 2001 From: Varixo Date: Thu, 12 Dec 2024 17:41:19 +0100 Subject: [PATCH] refactor: remove processJsx method --- packages/docs/src/routes/api/qwik/api.json | 2 +- packages/qwik/src/core/api.md | 8 ++------ .../qwik/src/core/client/dom-container.ts | 10 ---------- packages/qwik/src/core/shared/scheduler.ts | 19 +++++++++++++++---- .../qwik/src/core/shared/scheduler.unit.tsx | 1 - .../qwik/src/core/shared/shared-container.ts | 3 --- packages/qwik/src/core/shared/types.ts | 4 ---- packages/qwik/src/server/ssr-container.ts | 8 -------- 8 files changed, 18 insertions(+), 37 deletions(-) diff --git a/packages/docs/src/routes/api/qwik/api.json b/packages/docs/src/routes/api/qwik/api.json index fe1f23a2be3..3595bd3ec82 100644 --- a/packages/docs/src/routes/api/qwik/api.json +++ b/packages/docs/src/routes/api/qwik/api.json @@ -2214,4 +2214,4 @@ "mdFile": "core.withlocale.md" } ] -} +} \ No newline at end of file diff --git a/packages/qwik/src/core/api.md b/packages/qwik/src/core/api.md index c6876244be9..057073592c0 100644 --- a/packages/qwik/src/core/api.md +++ b/packages/qwik/src/core/api.md @@ -184,14 +184,12 @@ class DomContainer extends _SharedContainer implements ClientContainer { getParentHost(host: HostElement): HostElement | null; // (undocumented) getSyncFn(id: number): (...args: unknown[]) => unknown; + // Warning: (ae-forgotten-export) The symbol "HostElement" needs to be exported by the entry point index.d.ts + // // (undocumented) handleError(err: any, host: HostElement): void; // (undocumented) parseQRL(qrl: string): QRL; - // Warning: (ae-forgotten-export) The symbol "HostElement" needs to be exported by the entry point index.d.ts - // - // (undocumented) - processJsx(host: HostElement, jsx: JSXOutput): ValueOrPromise; // (undocumented) qBase: string; // (undocumented) @@ -837,8 +835,6 @@ export abstract class _SharedContainer implements Container { // (undocumented) abstract handleError(err: any, $host$: HostElement): void; // (undocumented) - abstract processJsx(host: HostElement, jsx: JSXOutput): ValueOrPromise; - // (undocumented) abstract resolveContext(host: HostElement, contextId: ContextId): T | undefined; // Warning: (ae-forgotten-export) The symbol "SymbolToChunkResolver" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "SerializationContext" needs to be exported by the entry point index.d.ts diff --git a/packages/qwik/src/core/client/dom-container.ts b/packages/qwik/src/core/client/dom-container.ts index 1d7d88339f0..75c8c44cf2d 100644 --- a/packages/qwik/src/core/client/dom-container.ts +++ b/packages/qwik/src/core/client/dom-container.ts @@ -4,7 +4,6 @@ import { assertTrue } from '../shared/error/assert'; import { getPlatform } from '../shared/platform/platform'; import type { QRL } from '../shared/qrl/qrl.public'; import { ERROR_CONTEXT, isRecoverable } from '../shared/error/error-handling'; -import type { JSXOutput } from '../shared/jsx/types/jsx-node'; import type { ContextId } from '../use/use-context'; import { EMPTY_ARRAY } from '../shared/utils/flyweight'; import { throwErrorAndStop } from '../shared/utils/log'; @@ -30,10 +29,8 @@ import { import { isPromise } from '../shared/utils/promises'; import { isSlotProp } from '../shared/utils/prop'; import { qDev } from '../shared/utils/qdev'; -import type { ValueOrPromise } from '../shared/utils/types'; import { ChoreType } from '../shared/scheduler'; import { - addComponentStylePrefix, convertScopedStyleIdsToArray, convertStyleIdsToString, } from '../shared/utils/scoped-styles'; @@ -69,7 +66,6 @@ import { vnode_setProp, type VNodeJournal, } from './vnode'; -import { vnode_diff } from './vnode-diff'; /** @public */ export function getDomContainer(element: Element | VNode): IClientContainer { @@ -193,12 +189,6 @@ export class DomContainer extends _SharedContainer implements IClientContainer { return inflateQRL(this, parseQRL(qrl)) as QRL; } - processJsx(host: HostElement, jsx: JSXOutput): ValueOrPromise { - // console.log('>>>> processJsx', String(host)); - const styleScopedId = this.getHostProp(host, QScopedStyle); - return vnode_diff(this, jsx, host as VirtualVNode, addComponentStylePrefix(styleScopedId)); - } - handleError(err: any, host: HostElement): void { if (qDev) { // Clean vdom diff --git a/packages/qwik/src/core/shared/scheduler.ts b/packages/qwik/src/core/shared/scheduler.ts index 3bfa1df6464..07637582f1b 100644 --- a/packages/qwik/src/core/shared/scheduler.ts +++ b/packages/qwik/src/core/shared/scheduler.ts @@ -86,13 +86,14 @@ import type { JSXOutput } from './jsx/types/jsx-node'; import { Task, TaskFlags, cleanupTask, runTask, type TaskFn } from '../use/use-task'; import { runResource, type ResourceDescriptor } from '../use/use-resource'; import { logWarn, throwErrorAndStop } from './utils/log'; -import { isPromise, maybeThen, maybeThenPassError, safeCall } from './utils/promises'; +import { isPromise, maybeThenPassError, safeCall } from './utils/promises'; import type { ValueOrPromise } from './utils/types'; import { isDomContainer } from '../client/dom-container'; import { ElementVNodeProps, VNodeFlags, VNodeProps, + type ClientContainer, type ElementVNode, type VirtualVNode, } from '../client/types'; @@ -110,6 +111,8 @@ import { type DomContainer } from '../client/dom-container'; import { serializeAttribute } from './utils/styles'; import type { OnRenderFn } from './component.public'; import type { Props } from './jsx/jsx-runtime'; +import { QScopedStyle } from './utils/markers'; +import { addComponentStylePrefix } from './utils/scoped-styles'; // Turn this on to get debug output of what the scheduler is doing. const DEBUG: boolean = false; @@ -334,9 +337,17 @@ export const createScheduler = ( chore.$payload$ as Props | null ), (jsx) => { - return chore.$type$ === ChoreType.COMPONENT - ? maybeThen(container.processJsx(host, jsx), () => jsx) - : jsx; + if (chore.$type$ === ChoreType.COMPONENT) { + const styleScopedId = container.getHostProp(host, QScopedStyle); + return vnode_diff( + container as ClientContainer, + jsx, + host as VirtualVNode, + addComponentStylePrefix(styleScopedId) + ); + } else { + return jsx; + } }, (err: any) => container.handleError(err, host) ); diff --git a/packages/qwik/src/core/shared/scheduler.unit.tsx b/packages/qwik/src/core/shared/scheduler.unit.tsx index 55e08f87ff3..fec2e5a0bbc 100644 --- a/packages/qwik/src/core/shared/scheduler.unit.tsx +++ b/packages/qwik/src/core/shared/scheduler.unit.tsx @@ -36,7 +36,6 @@ describe('scheduler', () => { document = createDocument(); document.body.setAttribute(QContainerAttr, 'paused'); const container = getDomContainer(document.body); - container.processJsx = () => null!; scheduler = createScheduler( container, () => null, diff --git a/packages/qwik/src/core/shared/shared-container.ts b/packages/qwik/src/core/shared/shared-container.ts index 94bcefee2c0..a835656fead 100644 --- a/packages/qwik/src/core/shared/shared-container.ts +++ b/packages/qwik/src/core/shared/shared-container.ts @@ -1,7 +1,5 @@ -import type { JSXOutput } from './jsx/types/jsx-node'; import type { ContextId } from '../use/use-context'; import { trackSignal } from '../use/use-core'; -import type { ValueOrPromise } from './utils/types'; import { version } from '../version'; import type { Effect, EffectData } from '../signal/signal'; import type { Signal } from '../signal/signal.public'; @@ -69,7 +67,6 @@ export abstract class _SharedContainer implements Container { } abstract ensureProjectionResolved(host: HostElement): void; - abstract processJsx(host: HostElement, jsx: JSXOutput): ValueOrPromise; abstract handleError(err: any, $host$: HostElement): void; abstract getParentHost(host: HostElement): HostElement | null; abstract setContext(host: HostElement, context: ContextId, value: T): void; diff --git a/packages/qwik/src/core/shared/types.ts b/packages/qwik/src/core/shared/types.ts index 74279d62cf4..fa27a699be0 100644 --- a/packages/qwik/src/core/shared/types.ts +++ b/packages/qwik/src/core/shared/types.ts @@ -1,6 +1,4 @@ -import type { JSXOutput } from './jsx/types/jsx-node'; import type { ContextId } from '../use/use-context'; -import type { ValueOrPromise } from './utils/types'; import type { VNode } from '../client/types'; import type { ISsrNode, StreamWriter, SymbolToChunkResolver } from '../ssr/ssr-types'; import type { Scheduler } from './scheduler'; @@ -25,8 +23,6 @@ export interface Container { readonly $serverData$: Record; $currentUniqueId$: number; - // TODO(misko): I think `processJsx` can be deleted. - processJsx(host: HostElement, jsx: JSXOutput): ValueOrPromise; handleError(err: any, $host$: HostElement): void; getParentHost(host: HostElement): HostElement | null; setContext(host: HostElement, context: ContextId, value: T): void; diff --git a/packages/qwik/src/server/ssr-container.ts b/packages/qwik/src/server/ssr-container.ts index 8a01156f10a..4dc68080e7a 100644 --- a/packages/qwik/src/server/ssr-container.ts +++ b/packages/qwik/src/server/ssr-container.ts @@ -243,14 +243,6 @@ class SSRContainer extends _SharedContainer implements ISSRContainer { ensureProjectionResolved(host: HostElement): void {} - processJsx(host: HostElement, jsx: JSXOutput): void { - /** - * During SSR the output needs to be streamed. So we should never get here, because we can't - * process JSX out of order. - */ - throw new Error('Should not get here.'); - } - handleError(err: any, $host$: HostElement): void { throw err; }