@douyinfe/semi-foundation 2.90.1-alpha.0 → 2.90.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ module.exports = ({ isESM }) => {
2
+ return {
3
+ presets: [
4
+ [
5
+ '@babel/preset-env',
6
+ {
7
+ modules: isESM ? false : 'commonjs',
8
+ targets: {
9
+ browsers: [
10
+ "> 0.5%",
11
+ "last 2 versions",
12
+ "Firefox ESR",
13
+ "not dead",
14
+ "not IE 11"
15
+ ]
16
+ }
17
+ },
18
+ ],
19
+ ],
20
+ plugins: [
21
+ 'lodash',
22
+ ]
23
+ };
24
+ };
package/gulpfile.js ADDED
@@ -0,0 +1,107 @@
1
+ const path = require('path');
2
+ const { Buffer } = require('buffer');
3
+ const through2 = require('through2');
4
+ const gulp = require('gulp');
5
+ const merge2 = require('merge2');
6
+ const gulpTS = require('gulp-typescript');
7
+ const gulpBabel = require('gulp-babel');
8
+ const sass = require('gulp-sass')(require('sass'));
9
+ const del = require('del');
10
+ const tsConfig = require('./tsconfig.json');
11
+ const getBabelConfig = require('./getBabelConfig');
12
+
13
+ gulp.task('cleanLib', function cleanLib() {
14
+ return del(['lib/**/*']);
15
+ });
16
+
17
+ function compileTS(isESM) {
18
+ const targetDir = isESM ? 'lib/es' : 'lib/cjs';
19
+ const tsStream = gulp.src(['**/*.ts', '!node_modules/**/*.*'])
20
+ .pipe(gulpTS(tsConfig.compilerOptions));
21
+ const jsStream = tsStream.js
22
+ .pipe(gulpBabel(getBabelConfig({ isESM })))
23
+ .pipe(gulp.dest(targetDir));
24
+ const dtsStream = tsStream.dts.pipe(gulp.dest(targetDir));
25
+ return merge2([jsStream, dtsStream]);
26
+ }
27
+
28
+ gulp.task('compileTSForESM', function compileTSForESM() {
29
+ return compileTS(true);
30
+ });
31
+
32
+ gulp.task('compileTSForCJS', function compileTSForCJS() {
33
+ return compileTS(false);
34
+ });
35
+
36
+ const excludeScss = [
37
+ '!**/button/splitButtonGroup.scss',
38
+ '!**/steps/bacisSteps.scss',
39
+ '!**/steps/fillSteps.scss',
40
+ '!**/steps/navSteps.scss',
41
+ '!**/table/operationPanel.scss',
42
+ '!**/tooltip/arrow.scss',
43
+ '!**/autoComplete/option.scss',
44
+ '!**/select/option.scss',
45
+ ];
46
+ gulp.task('compileScss', function compileScss() {
47
+ return gulp.src(['**/*.scss', '!node_modules/**/*.*', '!**/rtl.scss', '!**/variables.scss', "!**/animation.scss", ...excludeScss])
48
+ .pipe(through2.obj(
49
+ function (chunk, enc, cb) {
50
+ const rootPath = path.join(__dirname, '../../');
51
+ const scssVarStr = `@import "${rootPath}/packages/semi-theme-default/scss/index.scss";\n`;
52
+ let scssRaw = chunk.contents.toString('utf-8');
53
+ if (scssRaw.startsWith("@use")) {
54
+ const scssRawSplit = scssRaw.split("\n");
55
+ const codeStartIndex = scssRawSplit.findIndex(item => !item.startsWith("@use"));
56
+ scssRawSplit.splice(codeStartIndex, 0, scssVarStr);
57
+ scssRaw = scssRawSplit.join("\n");
58
+ } else {
59
+ scssRaw = `${scssVarStr}\n${scssRaw}`;
60
+ }
61
+ chunk.contents = Buffer.from(scssRaw, 'utf-8');
62
+ cb(null, chunk);
63
+ }
64
+ ))
65
+ .pipe(sass({
66
+ charset: false
67
+ }).on('error', sass.logError))
68
+ .pipe(gulp.dest('lib/es'))
69
+ .pipe(gulp.dest('lib/cjs'));
70
+ });
71
+
72
+ gulp.task('moveScss', function moveScss() {
73
+ return gulp.src(['**/*.scss', '!node_modules/**/*.*'])
74
+ .pipe(gulp.dest('lib/es'))
75
+ .pipe(gulp.dest('lib/cjs'));
76
+ });
77
+
78
+ gulp.task('compileLib',
79
+ gulp.series(
80
+ [
81
+ 'cleanLib', 'compileScss',
82
+ 'moveScss',
83
+ gulp.parallel('compileTSForESM', 'compileTSForCJS'),
84
+ ]
85
+ )
86
+ );
87
+
88
+ gulp.task('findDupCSSVariables', function findDupCSSVariables() {
89
+ return gulp.src(['**/variable?.scss', '!node_modules/**/*.*'])
90
+ .pipe(through2.obj((chunk, enc, cb) => {
91
+ const fileStr = chunk.contents.toString(enc);
92
+ const lines = fileStr.split('\n');
93
+ const variables = new Set();
94
+ for (let line of lines) {
95
+ if (/\$[a-z]+(-[a-z0-9_]+)+/.test(line)) {
96
+ const variable = line.split(':')[0];
97
+ if (variables.has(variable)) {
98
+ console.error(`❌ ${variable} dup`);
99
+ } else {
100
+ variables.add(variable);
101
+ }
102
+ }
103
+ }
104
+ cb();
105
+ }));
106
+ });
107
+
@@ -0,0 +1,51 @@
1
+ const esbuild = require('esbuild');
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+
5
+
6
+
7
+
8
+ const compileWorker = async ()=>{
9
+ const workerEntry = path.join(__dirname, "..", "core/src/worker/json.worker.ts");
10
+
11
+ const result = await esbuild.build({
12
+ entryPoints: [workerEntry],
13
+ bundle: true,
14
+ write: false,
15
+ });
16
+ return result.outputFiles[0].text;
17
+ };
18
+
19
+
20
+ const buildMain = async ()=>{
21
+ const mainEntry = path.join(__dirname, "..", "core/src/index.ts");
22
+
23
+ const result = await esbuild.build({
24
+ entryPoints: [mainEntry],
25
+ bundle: true,
26
+ packages: 'external',
27
+ write: false,
28
+ format: 'esm'
29
+ });
30
+ return result.outputFiles[0].text;
31
+
32
+ };
33
+
34
+
35
+
36
+ const compile = async ()=>{
37
+ const workerRaw = await compileWorker();
38
+
39
+ const mainRaw = await buildMain();
40
+
41
+ const finalRaw = mainRaw.replaceAll("%WORKER_RAW%", encodeURIComponent(workerRaw));
42
+
43
+ const saveDir = path.join(__dirname, "..", "core/lib");
44
+
45
+ if (!fs.existsSync(saveDir)) {
46
+ fs.mkdirSync(saveDir);
47
+ }
48
+ fs.writeFileSync(path.join(saveDir, "index.js"), finalRaw, 'utf8');
49
+ };
50
+
51
+ compile();
@@ -253,6 +253,6 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
253
253
  * - When yam open type is 'left' or 'right', weeks minHeight should be set
254
254
  * If the minHeight is not set, the change of the number of weeks will cause the scrollList to be unstable
255
255
  */
256
- getYAMOpenType(): "left" | "right" | "none" | "both";
256
+ getYAMOpenType(): "none" | "left" | "right" | "both";
257
257
  }
258
258
  export {};
@@ -83,6 +83,6 @@ export declare function getValueOrKey(data: any, keyMaps?: KeyMapProps): any;
83
83
  export declare function normalizeValue(value: any, withObject: boolean, keyMaps?: KeyMapProps): any;
84
84
  export declare function updateKeys(keySet: Set<string> | string[], keyEntities: KeyEntities): string[];
85
85
  export declare function calcDisabledKeys(keyEntities: KeyEntities, keyMaps?: KeyMapProps): Set<string>;
86
- export declare function calcDropRelativePosition(event: any, treeNode: any): 1 | -1 | 0;
86
+ export declare function calcDropRelativePosition(event: any, treeNode: any): 1 | 0 | -1;
87
87
  export declare function getDragNodesKeys(key: string, keyEntities: KeyEntities): string[];
88
88
  export declare function calcDropActualPosition(pos: string, relativeDropPos: any): any;
@@ -253,6 +253,6 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
253
253
  * - When yam open type is 'left' or 'right', weeks minHeight should be set
254
254
  * If the minHeight is not set, the change of the number of weeks will cause the scrollList to be unstable
255
255
  */
256
- getYAMOpenType(): "left" | "right" | "none" | "both";
256
+ getYAMOpenType(): "none" | "left" | "right" | "both";
257
257
  }
258
258
  export {};
@@ -83,6 +83,6 @@ export declare function getValueOrKey(data: any, keyMaps?: KeyMapProps): any;
83
83
  export declare function normalizeValue(value: any, withObject: boolean, keyMaps?: KeyMapProps): any;
84
84
  export declare function updateKeys(keySet: Set<string> | string[], keyEntities: KeyEntities): string[];
85
85
  export declare function calcDisabledKeys(keyEntities: KeyEntities, keyMaps?: KeyMapProps): Set<string>;
86
- export declare function calcDropRelativePosition(event: any, treeNode: any): 1 | -1 | 0;
86
+ export declare function calcDropRelativePosition(event: any, treeNode: any): 1 | 0 | -1;
87
87
  export declare function getDragNodesKeys(key: string, keyEntities: KeyEntities): string[];
88
88
  export declare function calcDropActualPosition(pos: string, relativeDropPos: any): any;
package/package.json CHANGED
@@ -1,32 +1,15 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.90.1-alpha.0",
3
+ "version": "2.90.1-alpha.2",
4
4
  "description": "",
5
5
  "scripts": {
6
- "clean": "rimraf lib",
7
6
  "build:lib": "node ./scripts/compileLib.js",
8
- "prepublishOnly": "npm run clean && npm run build:lib"
9
- },
10
- "files": [
11
- "lib/*",
12
- "**/*.ts",
13
- "**/*.scss",
14
- "!**/node_modules/**",
15
- "!**/*.test.ts",
16
- "!**/*.spec.ts"
17
- ],
18
- "typesVersions": {
19
- "*": {
20
- "*": [
21
- "lib/es/*"
22
- ]
23
- }
7
+ "prepublishOnly": "npm run build:lib"
24
8
  },
25
9
  "dependencies": {
26
- "@douyinfe/semi-animation": "2.90.1-alpha.0",
27
- "@douyinfe/semi-json-viewer-core": "2.90.1-alpha.0",
10
+ "@douyinfe/semi-animation": "2.90.1-alpha.2",
11
+ "@douyinfe/semi-json-viewer-core": "2.90.1-alpha.2",
28
12
  "@mdx-js/mdx": "^3.0.1",
29
- "@mlc-ai/web-llm": "^0.2.80",
30
13
  "async-validator": "^3.5.0",
31
14
  "classnames": "^2.2.6",
32
15
  "date-fns": "^2.29.3",
@@ -46,7 +29,7 @@
46
29
  "*.scss",
47
30
  "*.css"
48
31
  ],
49
- "gitHead": "45220ac4d7b6983a9f346f7606b5e76fc5bee8d2",
32
+ "gitHead": "d18a8b7d4bc38ae0cdc1dcbbe372b4d99bbde398",
50
33
  "devDependencies": {
51
34
  "@babel/plugin-transform-runtime": "^7.15.8",
52
35
  "@babel/preset-env": "^7.15.8",
@@ -62,7 +45,6 @@
62
45
  "gulp-sass": "^5.0.0",
63
46
  "gulp-typescript": "^6.0.0-alpha.1",
64
47
  "merge2": "^1.4.1",
65
- "rimraf": "^3.0.2",
66
48
  "through2": "^4.0.2"
67
49
  }
68
50
  }
@@ -0,0 +1,13 @@
1
+ const gulp = require('gulp');
2
+ require('../gulpfile');
3
+
4
+ function compileLib() {
5
+ const taskInstance = gulp.task('compileLib');
6
+ if (taskInstance === undefined) {
7
+ console.error('no task named compileLib registered');
8
+ return;
9
+ }
10
+ taskInstance.apply(gulp);
11
+ }
12
+
13
+ compileLib();
package/tsconfig.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2015",
4
+ "baseUrl": "./",
5
+ "outDir": "lib",
6
+ "sourceMap": true,
7
+ "allowJs": true,
8
+ "module": "es6",
9
+ "lib": ["esnext", "dom"],
10
+ "moduleResolution": "node",
11
+ "noImplicitAny": false,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "allowSyntheticDefaultImports": true,
14
+ "experimentalDecorators": true,
15
+ "noImplicitReturns": true,
16
+ "noImplicitThis": false,
17
+ "strictNullChecks": false,
18
+ "esModuleInterop": true,
19
+ "skipLibCheck": true,
20
+ "declaration": true,
21
+ "strict": true
22
+ },
23
+ "include": ["**/*.ts"],
24
+ "exclude": ["node_modules"]
25
+ }
@@ -1,70 +0,0 @@
1
- @import './variables.scss';
2
-
3
- $module: #{$prefix}-client-ai;
4
-
5
- .#{$module} {
6
- &-wrapper {
7
- padding: $spacing-clientAI-wrapper-padding;
8
- max-width: $width-clientAI-wrapper-max;
9
- margin: 0 auto;
10
- min-height: $height-clientAI-wrapper-min;
11
- height: $height-clientAI-wrapper-min;
12
- display: flex;
13
- flex-direction: column;
14
- }
15
-
16
- &-loading {
17
- padding: $spacing-clientAI-loading-paddingY $spacing-clientAI-loading-paddingX !important;
18
- display: flex !important;
19
- flex-direction: column !important;
20
- justify-content: center !important;
21
- align-items: center !important;
22
- min-height: $height-clientAI-loading-min !important;
23
- gap: $spacing-clientAI-loading-gap;
24
- }
25
-
26
- &-loading-content {
27
- width: 100%;
28
- max-width: $width-clientAI-loading-content-max;
29
- display: flex;
30
- flex-direction: column;
31
- gap: $spacing-clientAI-loading-content-gap;
32
- }
33
-
34
- &-loading-text {
35
- text-align: center;
36
- font-size: $font-clientAI-loading-text-fontSize;
37
- color: var(--semi-color-text-0);
38
- }
39
-
40
- &-error {
41
- padding: $spacing-clientAI-error-padding;
42
- }
43
-
44
- &-content {
45
- flex: 1;
46
- display: flex;
47
- flex-direction: column;
48
- min-height: 0;
49
- overflow: hidden;
50
- }
51
-
52
- &-dialogue-wrapper {
53
- flex: 1;
54
- overflow: auto;
55
- }
56
-
57
- &-input-wrapper {
58
- margin: $spacing-clientAI-input-wrapper-margin;
59
- min-height: $height-clientAI-input-wrapper-min;
60
- max-height: $height-clientAI-input-wrapper-max;
61
- flex-shrink: 0;
62
- }
63
-
64
- &-input-edit {
65
- margin: $spacing-clientAI-input-edit-marginY $spacing-clientAI-input-edit-marginX;
66
- max-height: $height-clientAI-input-edit-max;
67
- flex-shrink: 0;
68
- }
69
- }
70
-
@@ -1,109 +0,0 @@
1
- import { BASE_CLASS_PREFIX } from '../base/constants';
2
- import type { AppConfig, MLCEngineConfig } from './interface';
3
-
4
- const cssClasses = {
5
- PREFIX: `${BASE_CLASS_PREFIX}-client-ai`,
6
- WRAPPER: `${BASE_CLASS_PREFIX}-client-ai-wrapper`,
7
- LOADING: `${BASE_CLASS_PREFIX}-client-ai-loading`,
8
- LOADING_CONTENT: `${BASE_CLASS_PREFIX}-client-ai-loading-content`,
9
- LOADING_TEXT: `${BASE_CLASS_PREFIX}-client-ai-loading-text`,
10
- ERROR: `${BASE_CLASS_PREFIX}-client-ai-error`,
11
- CONTENT: `${BASE_CLASS_PREFIX}-client-ai-content`,
12
- DIALOGUE_WRAPPER: `${BASE_CLASS_PREFIX}-client-ai-dialogue-wrapper`,
13
- INPUT_WRAPPER: `${BASE_CLASS_PREFIX}-client-ai-input-wrapper`,
14
- INPUT_EDIT: `${BASE_CLASS_PREFIX}-client-ai-input-edit`,
15
- } as const;
16
-
17
- const strings = {} as const;
18
-
19
- const numbers = {} as const;
20
-
21
- // ============================================
22
- // 国外配置(使用 Hugging Face + GitHub Raw)
23
- // ============================================
24
-
25
- // Qwen3-1.7B 模型配置 - 国外
26
- export const Qwen3_1_7B_RECORD = {
27
- model: 'https://huggingface.co/mlc-ai/Qwen3-1.7B-q4f32_1-MLC',
28
- model_id: 'Qwen3-1.7B-q4f32_1-MLC',
29
- model_lib: 'https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/web-llm-models/v0_2_80/Qwen3-1.7B-q4f32_1-ctx4k_cs1k-webgpu.wasm',
30
- vram_required_MB: 2635.44,
31
- low_resource_required: true,
32
- overrides: {
33
- context_window_size: 40960,
34
- },
35
- };
36
-
37
- // Qwen3-1.7B 引擎配置 - 国外
38
- export const Qwen3_1_7B_ENGINE_CONFIG: MLCEngineConfig = {
39
- appConfig: {
40
- useIndexedDBCache: true,
41
- model_list: [Qwen3_1_7B_RECORD],
42
- } as AppConfig,
43
- };
44
-
45
- // Qwen3-4B 模型配置 - 国外
46
- export const Qwen3_4B_RECORD = {
47
- model: 'https://huggingface.co/mlc-ai/Qwen3-4B-q4f32_1-MLC',
48
- model_id: 'Qwen3-4B-q4f32_1-MLC',
49
- model_lib: 'https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/web-llm-models/v0_2_80/Qwen3-4B-q4f32_1-ctx4k_cs1k-webgpu.wasm',
50
- vram_required_MB: 6000,
51
- low_resource_required: false,
52
- overrides: {
53
- context_window_size: 40960,
54
- },
55
- };
56
-
57
- // Qwen3-4B 引擎配置 - 国外
58
- export const Qwen3_4B_ENGINE_CONFIG: MLCEngineConfig = {
59
- appConfig: {
60
- useIndexedDBCache: true,
61
- model_list: [Qwen3_4B_RECORD],
62
- } as AppConfig,
63
- };
64
-
65
- // ============================================
66
- // 中国配置(使用 ModelScope + jsDelivr CDN)
67
- // ============================================
68
-
69
- // Qwen3-1.7B 模型配置 - 中国
70
- export const Qwen3_1_7B_RECORD_CN = {
71
- model: 'https://modelscope.cn/models/mlc-ai/Qwen3-1.7B-q4f32_1-MLC',
72
- model_id: 'Qwen3-1.7B-q4f32_1-MLC',
73
- model_lib: 'https://cdn.jsdelivr.net/gh/mlc-ai/binary-mlc-llm-libs@main/web-llm-models/v0_2_80/Qwen3-1.7B-q4f32_1-ctx4k_cs1k-webgpu.wasm',
74
- vram_required_MB: 2635.44,
75
- low_resource_required: true,
76
- overrides: {
77
- context_window_size: 40960,
78
- },
79
- };
80
-
81
- // Qwen3-1.7B 引擎配置 - 中国
82
- export const Qwen3_1_7B_ENGINE_CONFIG_CN: MLCEngineConfig = {
83
- appConfig: {
84
- useIndexedDBCache: true,
85
- model_list: [Qwen3_1_7B_RECORD_CN],
86
- } as AppConfig,
87
- };
88
-
89
- // Qwen3-4B 模型配置 - 中国
90
- export const Qwen3_4B_RECORD_CN = {
91
- model: 'https://modelscope.cn/models/mlc-ai/Qwen3-4B-q4f32_1-MLC',
92
- model_id: 'Qwen3-4B-q4f32_1-MLC',
93
- model_lib: 'https://cdn.jsdelivr.net/gh/mlc-ai/binary-mlc-llm-libs@main/web-llm-models/v0_2_80/Qwen3-4B-q4f32_1-ctx4k_cs1k-webgpu.wasm',
94
- vram_required_MB: 6000,
95
- low_resource_required: false,
96
- overrides: {
97
- context_window_size: 40960,
98
- },
99
- };
100
-
101
- // Qwen3-4B 引擎配置 - 中国
102
- export const Qwen3_4B_ENGINE_CONFIG_CN: MLCEngineConfig = {
103
- appConfig: {
104
- useIndexedDBCache: true,
105
- model_list: [Qwen3_4B_RECORD_CN],
106
- } as AppConfig,
107
- };
108
-
109
- export { cssClasses, strings, numbers };