feat(core): remove internal annotation from dark mode toggle and config (#5212)

This commit is contained in:
白熱
2025-05-16 13:03:10 +08:00
committed by GitHub
parent 7441d00fef
commit 5896972af2
11 changed files with 413 additions and 580 deletions
+8 -8
View File
@@ -17,23 +17,23 @@
},
"dependencies": {
"@chromatic-com/storybook": "^3.2.6",
"@storybook/addon-essentials": "^8.6.12",
"@storybook/addon-interactions": "^8.6.12",
"@storybook/addon-links": "^8.6.12",
"@storybook/addon-essentials": "8.6.13",
"@storybook/addon-interactions": "8.6.13",
"@storybook/addon-links": "8.6.13",
"@storybook/addon-styling-webpack": "^1.0.1",
"@storybook/addon-webpack5-compiler-swc": "^3.0.0",
"@storybook/blocks": "^8.6.12",
"@storybook/blocks": "8.6.13",
"@storybook/icons": "^1.4.0",
"@storybook/react": "^8.6.12",
"@storybook/react-webpack5": "^8.6.12",
"@storybook/types": "^8.6.12",
"@storybook/react": "8.6.13",
"@storybook/react-webpack5": "8.6.13",
"@storybook/types": "8.6.13",
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
"@univerjs/themes": "workspace:*",
"@univerjs/ui": "workspace:*",
"css-loader": "^7.1.2",
"postcss-loader": "^8.1.1",
"storybook": "^8.6.12",
"storybook": "8.6.13",
"storybook-addon-swc": "^1.2.0",
"style-loader": "^4.0.0",
"tsconfig-paths-webpack-plugin": "^4.2.0",
-100
View File
@@ -26,15 +26,12 @@ import cleanPlugin from 'esbuild-plugin-clean';
import copyPlugin from 'esbuild-plugin-copy';
import vue from 'esbuild-plugin-vue3';
import stylePlugin from 'esbuild-style-plugin';
import glob from 'fast-glob';
import fs from 'fs-extra';
import minimist from 'minimist';
import React from 'react';
import tailwindcss from 'tailwindcss';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const LINK_TO_LIB = process.env.LINK_TO_LIB === 'true';
const nodeModules = path.resolve(process.cwd(), './node_modules');
const args = minimist(process.argv.slice(2));
@@ -50,101 +47,6 @@ const monacoEditorEntryPoints = [
'vs/editor/editor.worker.js',
];
/**
* fix `import '@univerjs/xxx/lib/index.css'` not work on source code dev mode
*
* The `stylePlugin` must be loaded after the `skipLibCssEsbuildPlugin`.
*/
const skipLibCssEsbuildPlugin = {
name: 'skip-lib-css-esbuild-plugin',
setup(build) {
console.log('[skip-lib-css-esbuild-plugin] enabled, resolve will skip `import \'@univerjs/xxx/lib/**/*.css\'`');
build.onResolve({ filter: /\/lib\/.*\.css$/ }, async (args) => {
if (args.path.includes('@univerjs/')) {
return {
path: args.path,
namespace: 'univer-lib-css',
};
}
});
build.onLoad({ filter: /.*/, namespace: 'univer-lib-css' }, async () => {
// return virtual css content
return {
contents: '',
loader: 'css',
};
});
},
};
/**
* Add this function to generate aliases
*/
function generateAliases() {
const aliases = {};
const packagesRoots = ['packages', 'packages-experimental'].map((dir) =>
path.resolve(__dirname, '..', dir)
);
for (const packagesRoot of packagesRoots) {
if (!fs.existsSync(packagesRoot)) continue;
// Find all package.json files in subdirectories
const packageJsonPaths = glob.sync('*/package.json', { cwd: packagesRoot });
for (const packageJsonPath of packageJsonPaths) {
const pkgDir = path.join(packagesRoot, path.dirname(packageJsonPath));
const pkgJson = fs.readJSONSync(path.join(packagesRoot, packageJsonPath));
const exportsConfig = pkgJson.publishConfig?.exports;
if (!exportsConfig) continue;
// Add main package alias
if (exportsConfig['.']) {
aliases[pkgJson.name] = path.resolve(pkgDir, exportsConfig['.'].import);
}
const getValue = (val: { import: string } | string) => {
if (typeof val === 'string') {
return val;
}
return val.import;
};
// Add subpath aliases
Object.entries(exportsConfig as Record<string, { import: string } | string>).forEach(([key, value]) => {
try {
if (key === '.') {
aliases[pkgJson.name] = path.resolve(pkgDir, exportsConfig['.'].import);
} else if (key === './lib/*') {
const cssFile = path.resolve(pkgDir, getValue(value).replace('*', 'index.css'));
if (fs.existsSync(cssFile)) {
aliases[`${pkgJson.name}/lib/index.css`] = cssFile;
}
} else if (key === './*') {
// do nothing
} else if (key === './locale/*') {
const locales = ['en-US', 'fr-FR', 'ru-RU', 'zh-CN', 'zh-TW', 'vi-VN', 'fa-IR'];
locales.forEach((lang) => {
aliases[`${pkgJson.name}/locale/${lang}`] = path.resolve(pkgDir, getValue(value).replace('*', lang));
});
} else {
const aliasKey = `${pkgJson.name}/${key.replace('./', '')}`;
const aliasPath = path.resolve(pkgDir, getValue(value));
aliases[aliasKey] = aliasPath;
}
} catch (e) {
console.error(`Error generating aliases for ${pkgJson.name}: ${e.message}`);
process.exit(1);
}
});
}
}
return aliases;
}
function nodeBuildTask() {
return esbuild.build({
bundle: true,
@@ -272,7 +174,6 @@ const config: SameShape<BuildOptions, BuildOptions> = {
to: ['./'],
},
}),
...(LINK_TO_LIB ? [] : [skipLibCssEsbuildPlugin]),
stylePlugin({
postcss: {
plugins: [tailwindcss as any],
@@ -288,7 +189,6 @@ const config: SameShape<BuildOptions, BuildOptions> = {
entryPoints,
outdir: './local',
define,
alias: LINK_TO_LIB ? generateAliases() : {},
};
if (isReact16) {
-2
View File
@@ -11,7 +11,6 @@
"prepare": "tsx ./scripts/generate-locales.ts && tsx ./scripts/generate-html.ts",
"build:demo": "tsx ./esbuild.config.ts",
"dev:demo": "tsx ./esbuild.config.ts --watch",
"dev:demo-libs": "cross-env LINK_TO_LIB=true tsx ./esbuild.config.ts --watch",
"dev:e2e": "tsx ./esbuild.config.ts --watch --e2e",
"build:e2e": "tsx ./esbuild.config.ts --e2e",
"lint:types": "tsc --noEmit"
@@ -99,7 +98,6 @@
"esbuild-plugin-copy": "^2.1.1",
"esbuild-plugin-vue3": "^0.4.2",
"esbuild-style-plugin": "^1.6.3",
"fast-glob": "^3.3.3",
"fs-extra": "^11.3.0",
"minimist": "^1.2.8",
"postcss": "^8.5.3",
-2
View File
@@ -56,9 +56,7 @@ import '@univerjs/sheets-drawing-ui/facade';
import '@univerjs/sheets-zen-editor/facade';
import '@univerjs/sheets-crosshair-highlight/facade';
import '@univerjs/sheets-sort/facade';
import '../global.css';
import './styles';
const LOAD_LAZY_PLUGINS_TIMEOUT = 100;
const LOAD_VERY_LAZY_PLUGINS_TIMEOUT = 1_000;
-32
View File
@@ -1,32 +0,0 @@
/**
* Copyright 2023-present DreamNum Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import '@univerjs/sheets-ui/lib/index.css';
import '@univerjs/ui/lib/index.css';
import '@univerjs/design/lib/index.css';
import '@univerjs/docs-ui/lib/index.css';
import '@univerjs/sheets-formula-ui/lib/index.css';
import '@univerjs/sheets-numfmt-ui/lib/index.css';
import '@univerjs/drawing-ui/lib/index.css';
import '@univerjs/docs-drawing-ui/lib/index.css';
import '@univerjs/sheets-data-validation-ui/lib/index.css';
import '@univerjs/sheets-filter-ui/lib/index.css';
import '@univerjs/find-replace/lib/index.css';
import '@univerjs/sheets-hyper-link-ui/lib/index.css';
import '@univerjs/sheets-sort-ui/lib/index.css';
import '@univerjs/thread-comment-ui/lib/index.css';
import '@univerjs/sheets-zen-editor/lib/index.css';
import '@univerjs/uniscript/lib/index.css';
-1
View File
@@ -65,7 +65,6 @@ import '@univerjs/sheets-sort/facade';
import '@univerjs/network/facade';
import '@univerjs/sheets-note/facade';
import '../global.css';
import './styles';
/* eslint-disable-next-line node/prefer-global/process */
const IS_E2E: boolean = !!process.env.IS_E2E;
-32
View File
@@ -1,32 +0,0 @@
/**
* Copyright 2023-present DreamNum Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import '@univerjs/sheets-ui/lib/index.css';
import '@univerjs/ui/lib/index.css';
import '@univerjs/design/lib/index.css';
import '@univerjs/docs-ui/lib/index.css';
import '@univerjs/sheets-formula-ui/lib/index.css';
import '@univerjs/sheets-numfmt-ui/lib/index.css';
import '@univerjs/drawing-ui/lib/index.css';
import '@univerjs/docs-drawing-ui/lib/index.css';
import '@univerjs/sheets-data-validation-ui/lib/index.css';
import '@univerjs/sheets-filter-ui/lib/index.css';
import '@univerjs/find-replace/lib/index.css';
import '@univerjs/sheets-hyper-link-ui/lib/index.css';
import '@univerjs/sheets-sort-ui/lib/index.css';
import '@univerjs/thread-comment-ui/lib/index.css';
import '@univerjs/sheets-zen-editor/lib/index.css';
import '@univerjs/uniscript/lib/index.css';
+2 -2
View File
@@ -52,9 +52,9 @@
"@playwright/test": "^1.52.0",
"@release-it-plugins/workspaces": "^4.2.0",
"@release-it/conventional-changelog": "^9.0.4",
"@storybook/react": "8.6.12",
"@storybook/react": "8.6.13",
"@types/fs-extra": "^11.0.4",
"@types/node": "^22.15.17",
"@types/node": "^22.15.18",
"@types/react": "^19.1.4",
"@types/react-dom": "^19.1.5",
"@univerjs-infra/shared": "workspace:*",
-1
View File
@@ -321,7 +321,6 @@ export class FUniver extends Disposable {
/**
* Toggle dark mode on or off.
* @param {boolean} isDarkMode - Whether the dark mode is enabled.
* @internal
* @example
* ```ts
* univerAPI.toggleDarkMode(true);
-1
View File
@@ -63,7 +63,6 @@ export interface IUniverConfig {
/**
* Whether to use dark mode.
* @internal
* @default false
*/
darkMode?: boolean;
+403 -399
View File
File diff suppressed because it is too large Load Diff