Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/tough-cases-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@lynx-js/testing-environment": patch
"@lynx-js/react-webpack-plugin": patch
"@lynx-js/react": patch
---

Remove element api calls alog by default, and only enable it when `__ALOG_ELEMENT_API__` is defined to `true` or environment variable `REACT_ALOG_ELEMENT_API` is set to `true`.
2 changes: 0 additions & 2 deletions packages/react/runtime/src/alog/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Copyright 2025 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
import { initElementPAPICallAlog } from './elementPAPICall.js';
import { initRenderAlog } from './render.js';

export function initAlog(): void {
initRenderAlog();
initElementPAPICallAlog();
}
4 changes: 4 additions & 0 deletions packages/react/runtime/src/lynx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { options } from 'preact';
// to make sure preact's hooks to register earlier than ours
import './hooks/react.js';

import { initElementPAPICallAlog } from './alog/elementPAPICall.js';
import { initAlog } from './alog/index.js';
import { setupComponentStack } from './debug/component-stack.js';
import { initProfileHook } from './debug/profile.js';
Expand Down Expand Up @@ -52,6 +53,9 @@ if (typeof __ALOG__ !== 'undefined' && __ALOG__) {
// We are logging both main-thread and background.
initAlog();
}
if (typeof __ALOG_ELEMENT_API__ !== 'undefined' && __ALOG_ELEMENT_API__) {
initElementPAPICallAlog();
}

if (typeof __BACKGROUND__ !== 'undefined' && __BACKGROUND__) {
// Trick Preact and TypeScript to accept our custom document adapter.
Expand Down
1 change: 1 addition & 0 deletions packages/react/runtime/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ declare global {
declare const __MAIN_THREAD__: boolean;
declare const __PROFILE__: boolean;
declare const __ALOG__: boolean | undefined;
declare const __ALOG_ELEMENT_API__: boolean | undefined;
declare const __ENABLE_SSR__: boolean;

declare function __CreatePage(componentId: string, cssId: number): FiberElement;
Expand Down
4 changes: 3 additions & 1 deletion packages/react/testing-library/src/vitest-global-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ globalThis.onInjectMainThreadGlobals = (target) => {

target.globalPipelineOptions = undefined;

initElementPAPICallAlog(target);
if (typeof __ALOG_ELEMENT_API__ !== 'undefined' && __ALOG_ELEMENT_API__) {
initElementPAPICallAlog(target);
}
};
globalThis.onInjectBackgroundThreadGlobals = (target) => {
if (onInjectBackgroundThreadGlobals) {
Expand Down
2 changes: 2 additions & 0 deletions packages/testing-library/testing-environment/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ function injectMainThreadGlobals(target?: any, polyfills?: any) {
target.__DEV__ = true;
target.__PROFILE__ = true;
target.__ALOG__ = true;
target.__ALOG_ELEMENT_API__ = true;
target.__JS__ = false;
target.__LEPUS__ = true;
target.__BACKGROUND__ = false;
Expand Down Expand Up @@ -378,6 +379,7 @@ function injectBackgroundThreadGlobals(target?: any, polyfills?: any) {
target.__DEV__ = true;
target.__PROFILE__ = true;
target.__ALOG__ = true;
target.__ALOG_ELEMENT_API__ = true;
target.__JS__ = true;
target.__LEPUS__ = false;
target.__BACKGROUND__ = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ class ReactWebpackPlugin {
),
// User can enable ALog by environment variable `REACT_ALOG=true`
__ALOG__: JSON.stringify(Boolean(process.env['REACT_ALOG'])),
// User can enable ALog of element API calls by environment variable `REACT_ALOG_ELEMENT_API=true`
__ALOG_ELEMENT_API__: JSON.stringify(
Boolean(process.env['REACT_ALOG_ELEMENT_API']),
),
__EXTRACT_STR__: JSON.stringify(Boolean(options.extractStr)),
__FIRST_SCREEN_SYNC_TIMING__: JSON.stringify(
options.firstScreenSyncTiming,
Expand Down
Loading