diff --git a/package.json b/package.json index ec5184e96..06c697c02 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,17 @@ "keywords": [], "author": "", "license": "ISC", + "engines": { + "node": ">=16.0.0", + "yarn": "please-use-pnpm", + "pnpm": ">=7.0.0" + }, "scripts": { "dev": "npm-run-all --parallel dev:*", "dev:demo": "pnpm --dir packages/demo dev", "dev:fineui": "pnpm --dir packages/fineui dev", - "build": "pnpm --dir packages/fineui build" + "build": "pnpm --dir packages/fineui build", + "build:demo": "pnpm --dir packages/demo build" }, "devDependencies": { "@babel/cli": "^7.21.0", diff --git a/packages/demo/package.json b/packages/demo/package.json index deaabb82e..01fe03056 100644 --- a/packages/demo/package.json +++ b/packages/demo/package.json @@ -4,7 +4,8 @@ "description": "", "main": "index.js", "scripts": { - "dev": "webpack-dev-server --open --config=webpack.dev.js" + "dev": "webpack-dev-server --open --config=webpack.dev.js --progress", + "build": "webpack --config=webpack.prod.js --progress" }, "keywords": [], "author": "", diff --git a/packages/demo/webpack.prod.js b/packages/demo/webpack.prod.js new file mode 100644 index 000000000..20bc06a53 --- /dev/null +++ b/packages/demo/webpack.prod.js @@ -0,0 +1,58 @@ +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const path = require('path'); +const TerserPlugin = require("terser-webpack-plugin"); +const webpack = require("webpack"); +const childProcess = require("child_process"); + +function git(command) { + return childProcess.execSync(`git ${command}`).toString().trim(); +} + +module.exports = { + mode: 'production', + entry: { + "demo.min": './src/index.js' + }, + module: { + rules: [ + { + test: /\.js$/, + exclude: /node_modules/, + use: { + loader: 'babel-loader', + }, + }, + { + test: /\.less$/i, + use: ['style-loader', 'css-loader', 'less-loader'], + }, + ], + }, + devtool: 'source-map', + resolve: { + extensions: ['.js', '.ts'], + alias: { + '@': path.resolve(__dirname, './src'), + }, + }, + optimization: { + usedExports: false, + minimize: true, + minimizer: [ + new TerserPlugin({ + include: /\.min/, + parallel: true, + terserOptions: { + output: { + comments: false, + }, + }, + }), + new webpack.BannerPlugin({ + banner: `time: ${new Date().toLocaleString("en-US")}; branch: ${git( + "name-rev --name-only HEAD" + )} commit: ${git("rev-parse HEAD")}`, + }) + ], + }, +}; diff --git a/packages/fineui/bin/cli/cli.js b/packages/fineui/bin/cli/cli.js new file mode 100644 index 000000000..513024023 --- /dev/null +++ b/packages/fineui/bin/cli/cli.js @@ -0,0 +1,21 @@ +#!/usr/bin/env node +const yargs = require('yargs/yargs'); +const { hideBin } = require('yargs/helpers'); + +const workerCmd = require('./worker/cli.worker'); + +const argv = yargs(hideBin(process.argv)).argv; + +const cmd = argv._[0]; + +const cmds = new Map([ + ['worker', workerCmd], +]); + +if (!cmd) throw new Error('Command is undefined!'); + +if (cmds.has(cmd)) { + cmds.get(cmd)?.exec(argv); +} else { + throw new Error(`Command ${cmd} not supported`); +} diff --git a/packages/fineui/bin/cli/worker/cli.worker.js b/packages/fineui/bin/cli/worker/cli.worker.js new file mode 100644 index 000000000..b67513fbb --- /dev/null +++ b/packages/fineui/bin/cli/worker/cli.worker.js @@ -0,0 +1,76 @@ +const fs = require('fs'); +const path = require('path'); + +function first2UpperCase(str) { + return str.toLowerCase().replace(/( |^)[a-z]/g, L => L.toUpperCase()); +} + +function scanAndCreate(structure, workerName, root) { + Object.keys(structure) + .forEach(name => { + if (typeof structure[name] === 'object') { + fs.mkdirSync(path.resolve(root, name)); + + scanAndCreate(structure[name], workerName, path.resolve(root, `./${name}`)); + } else if (structure[name] === '') { + fs.appendFileSync(path.resolve(root, name), ''); + } else if (typeof structure[name] === 'string') { + let content = fs.readFileSync(structure[name]).toString(); + + content = content + .replace(/\${WorkerName}/g, first2UpperCase(workerName)) + .replace(/\${workerName}/g, workerName); + + fs.appendFileSync(path.resolve(root, name), content); + } + }); +} + +module.exports = { + exec: async args => { + if (!args.init) { + throw new Error(`Command init not found in args`); + } + + if (!args.name) { + throw new Error('Command --name=... not found in args'); + } + + const name = args.name; + + const structure = { + [`${name}_worker`]: { + 'main_thread': { + action: { + 'action.worker_ability_test.ts': path.resolve(__dirname, './template/main_thread/action/action.worker_ability_test.t'), + }, + [`${name}_main_thread.ts`]: path.resolve(__dirname, './template/main_thread/main_thread.t'), + }, + utils: { + 'action_type.ts': path.resolve(__dirname, './template/utils/action_type.t'), + 'payload_type.ts': path.resolve(__dirname, './template/utils/payload_type.t'), + }, + 'worker_thread': { + action: { + 'action.worker_ability_test.ts': path.resolve(__dirname, './template/worker_thread/action/action.worker_ability_test.t'), + }, + [`${name}_worker_thread.ts`]: path.resolve(__dirname, './template/worker_thread/worker_thread.t'), + }, + [`${name}_main_thread.helper.ts`]: path.resolve(__dirname, './template/main_thread.helper.t'), + }, + }; + + scanAndCreate(structure, name, args.where ? path.resolve(args.where) : process.cwd()); + }, +}; + +// 结构 +// -xxx_worker +// -|--main_thread +// -|--|--action +// -|--|--xxx_main_thread.ts +// -|--utils +// -|--|--action_type.ts +// -|--worker_thread +// -|--|--action +// -|--|--worker_main_thread.ts diff --git a/packages/fineui/bin/cli/worker/template/main_thread.helper.t b/packages/fineui/bin/cli/worker/template/main_thread.helper.t new file mode 100644 index 000000000..2ee06acb7 --- /dev/null +++ b/packages/fineui/bin/cli/worker/template/main_thread.helper.t @@ -0,0 +1,48 @@ +import { ${WorkerName}MainThreadWorker } from './main_thread/${workerName}_main_thread'; +// 不需要一起打包的话则不需要引入这行 +// FuiWorkerPlugin中的属性会同步到fui-worker中,同时支持loader行内传入属性 +// 根据实际需求传入inline,返回格式 true -> blob url,false -> servicePath +import workerUrl from 'fui-worker!./worker_thread/${workerName}_worker_thread'; + +export class ${WorkerName}WorkerHelper { + private worker: ${WorkerName}MainThreadWorker; + + /** + * 拿到helper中的worker + */ + public getWorker() { + if (this.worker) { + return this.worker; + } + + this.worker = BI.Workers.createWorker(${WorkerName}MainThreadWorker, { + workerUrl: this.urlFormatter(workerUrl), + workerName: BI.UUID(), + }); + + return this.worker; + } + + /** + * 格式化worker url,比如补充一些环境信息到参数里 + * 可通过 #hash 将参数传入blob url + * @param url worker url + */ + private urlFormatter(url: string) { + return url; + } + + /** + * 终止worker + */ + public terminate() { + this.worker?.terminate(); + } +} + +// 使用示例 +// const workerHelper = new ${WorkerName}WorkerHelper(); + +// workerHelper.getWorker() +// .testCommunication() +// .then(res => console.log(res)); diff --git a/packages/fineui/bin/cli/worker/template/main_thread/action/action.worker_ability_test.t b/packages/fineui/bin/cli/worker/template/main_thread/action/action.worker_ability_test.t new file mode 100644 index 000000000..42425b859 --- /dev/null +++ b/packages/fineui/bin/cli/worker/template/main_thread/action/action.worker_ability_test.t @@ -0,0 +1,13 @@ +import { WorkerAbilityTestActionType } from '../../utils/action_type'; +import { WorkerAbilityTestPayload, WorkerAbilityTestReponse } from '../../utils/payload_type'; + +export class WorkerAbilityTestMainThreadAction extends BI.Workers.WorkerBaseAction { + /** + * 通信能力检测 + */ + public communicationTest(): Promise { + const mainThreadPostTime: WorkerAbilityTestPayload['CommunicationTest'] = Date.now(); + + return this.controller.requestPromise(WorkerAbilityTestActionType.CommunicationTest, mainThreadPostTime); + } +} diff --git a/packages/fineui/bin/cli/worker/template/main_thread/main_thread.t b/packages/fineui/bin/cli/worker/template/main_thread/main_thread.t new file mode 100644 index 000000000..00fb09177 --- /dev/null +++ b/packages/fineui/bin/cli/worker/template/main_thread/main_thread.t @@ -0,0 +1,13 @@ +import { WorkerAbilityTestMainThreadAction } from './action/action.worker_ability_test'; + +export class ${WorkerName}MainThreadWorker extends BI.Workers.MainThreadWorker { + private communicationTest: WorkerAbilityTestMainThreadAction; + + public initActions(): void { + this.communicationTest = this.createAction(WorkerAbilityTestMainThreadAction); + } + + public testCommunication() { + return this.communicationTest.communicationTest(); + } +} diff --git a/packages/fineui/bin/cli/worker/template/utils/action_type.t b/packages/fineui/bin/cli/worker/template/utils/action_type.t new file mode 100644 index 000000000..c92de897a --- /dev/null +++ b/packages/fineui/bin/cli/worker/template/utils/action_type.t @@ -0,0 +1,8 @@ +/* + * Worker 事务标识 + * 每类事务有命名空间, 包含多个具体事务 + */ + +export const enum WorkerAbilityTestActionType { + CommunicationTest = 'CommunicationTest', +} diff --git a/packages/fineui/bin/cli/worker/template/utils/payload_type.t b/packages/fineui/bin/cli/worker/template/utils/payload_type.t new file mode 100644 index 000000000..6b9a71509 --- /dev/null +++ b/packages/fineui/bin/cli/worker/template/utils/payload_type.t @@ -0,0 +1,13 @@ +/** + * 跨线程通信各事务的发送数据类型声明 + */ +export interface WorkerAbilityTestPayload { + CommunicationTest: number; +} + +/** + * 跨线程通信各事务的响应数据类型声明 + */ +export interface WorkerAbilityTestReponse { + CommunicationTest: number; +} diff --git a/packages/fineui/bin/cli/worker/template/worker_thread/action/action.worker_ability_test.t b/packages/fineui/bin/cli/worker/template/worker_thread/action/action.worker_ability_test.t new file mode 100644 index 000000000..f7d1248f4 --- /dev/null +++ b/packages/fineui/bin/cli/worker/template/worker_thread/action/action.worker_ability_test.t @@ -0,0 +1,24 @@ +import { WorkerAbilityTestActionType } from '../../utils/action_type'; +import { WorkerAbilityTestPayload, WorkerAbilityTestReponse } from '../../utils/payload_type'; + +export class WorkerAbilityTestWorkerThreadAction extends BI.Workers.WorkerBaseAction { + protected addActionHandler(): void { + this.controller.addActionHandler( + WorkerAbilityTestActionType.CommunicationTest, + this.communicationTest.bind(this) + ); + } + + /** + * 通信能力检测的处理器 + */ + private communicationTest( + payload: WorkerAbilityTestPayload['CommunicationTest'] + ): WorkerAbilityTestReponse['CommunicationTest'] { + const mainThreadPostTime = payload; + // 收到主线程信息的耗时 + const workerGetMessageDuration = Date.now() - mainThreadPostTime; + + return workerGetMessageDuration; + } +} diff --git a/packages/fineui/bin/cli/worker/template/worker_thread/worker_thread.t b/packages/fineui/bin/cli/worker/template/worker_thread/worker_thread.t new file mode 100644 index 000000000..f437bbc23 --- /dev/null +++ b/packages/fineui/bin/cli/worker/template/worker_thread/worker_thread.t @@ -0,0 +1,12 @@ +// TODO: 这边需要先import fineui资源 +import { WorkerAbilityTestWorkerThreadAction } from './action/action.worker_ability_test'; + +class ${WorkerName}WorkerTreadWorker extends BI.Workers.WorkerThreadWorker { + public communicationTest: WorkerAbilityTestWorkerThreadAction; + + public initActions(): void { + this.communicationTest = this.createAction(WorkerAbilityTestWorkerThreadAction); + } +} + +export const ${workerName}WorkerTreadWorker = BI.Workers.createWorker(${WorkerName}WorkerTreadWorker); diff --git a/packages/fineui/package.json b/packages/fineui/package.json index 707b58a46..7551b66e4 100644 --- a/packages/fineui/package.json +++ b/packages/fineui/package.json @@ -2,29 +2,35 @@ "name": "@fui/core", "version": "2.0.20230208163847", "description": "fineui", - "main": "dist/fineui_without_conflict.min.js", + "main": "dist/fineui.min.js", "module": "dist/es/index.js", - "types": "dist/type/index.d.ts", + "types": "dist/lib/index.d.ts", "bin": { "fui-cli": "./bin/cli/cli.js" }, "sideEffects": [ "**/*.less", "src/**/*.js", - "dist/es/core/*.js", - "dist/es/core/element/**/*.js", - "dist/es/core/platform/**/*.js", + "dist/es/index.js", + "dist/es/core/system.js", + "dist/es/core/platform/web/config.js", + "dist/es/core/platform/web/jquery/*.js", "dist/es/polyfill/**/*.js", "dist/es/case/ztree/jquery.ztree.core-3.5.js", "dist/es/case/ztree/jquery.ztree.excheck-3.5.js" ], "scripts": { - "dev": "babel src -d dist/es --config-file ./esm.babel.js -w", - "build": "webpack --config=webpack/webpack.prod.js", + "dev": "tsc && babel src -d dist/es --config-file ./esm.babel.js -w", + "build": "tsc && run-p build:*", + "build:es": "babel src -d dist/es --config-file ./esm.babel.js", + "build:fineui": "webpack --progress --config=webpack/webpack.prod.js", "webpack:css": "webpack --config=webpack/webpack.css.js --mode production", - "biCss": "cross-env LESS_CONFIG_PATH=lessconfig/bi.lessconfig.json LESS_FILE_NAME=bi npm run webpack:css", - "jsyCss": "cross-env LESS_CONFIG_PATH=lessconfig/jsy.lessconfig.json LESS_FILE_NAME=jsy npm run webpack:css" + "build:biCss": "cross-env LESS_CONFIG_PATH=lessconfig/bi.lessconfig.json LESS_FILE_NAME=bi npm run webpack:css", + "build:jsyCss": "cross-env LESS_CONFIG_PATH=lessconfig/jsy.lessconfig.json LESS_FILE_NAME=jsy npm run webpack:css" }, + "files": [ + "dist" + ], "repository": { "type": "git", "url": "https://git.coding.net/fanruan/fineui.git" @@ -35,7 +41,8 @@ "finebi" ], "publishConfig": { - "registry": "https://registry.npmjs.org" + "registry": "https://registry.npmjs.org", + "access": "public" }, "author": "fanruan", "license": "MIT", diff --git a/packages/fineui/src/core/index.js b/packages/fineui/src/core/index.js index b754913f6..6dbdf43c9 100644 --- a/packages/fineui/src/core/index.js +++ b/packages/fineui/src/core/index.js @@ -1,5 +1,5 @@ export * from './system'; -export { Plugin } from './6.plugin'; + export { StyleLoaderManager } from './loader/loader.style'; export { ShowListener } from './listener/listener.show'; export { useInWorker } from './worker'; @@ -15,16 +15,14 @@ export { PopoverController } from './controller/controller.popover'; export { ResizeController } from './controller/controller.resizer'; export { TooltipsController } from './controller/controller.tooltips'; -export * from './4.widget'; +export * as _ from './1.lodash'; export * from './2.base'; export * from './3.ob'; - +export * from './4.widget'; export * from './5.inject'; export * from './6.plugin'; export * from './action'; -// export * from "./behavior"; -// export * from "./controller"; export * from './func'; export * from './structure'; export * from './h'; @@ -36,6 +34,5 @@ export * from './utils'; export { shortcut, provider, store, model, mixin, mixins } from './decorator'; -import _ from './1.lodash'; -export { _ }; + diff --git a/packages/fineui/src/core/platform/web/jquery/_jquery.js b/packages/fineui/src/core/platform/web/jquery/_jquery.js deleted file mode 100644 index 52f4c1ef3..000000000 --- a/packages/fineui/src/core/platform/web/jquery/_jquery.js +++ /dev/null @@ -1,7 +0,0 @@ -// import jQuery from "jquery"; -// import { _global } from "@/core/0.foundation"; - -// // todo:先垫着,不然开发会崩 -// _global.BI = _global.BI || {}; - -// _global.BI.jQuery = _global.BI.$ = jQuery; diff --git a/packages/fineui/src/core/platform/web/jquery/fn.js b/packages/fineui/src/core/platform/web/jquery/fn.js index 2403d95b6..2edb1545d 100644 --- a/packages/fineui/src/core/platform/web/jquery/fn.js +++ b/packages/fineui/src/core/platform/web/jquery/fn.js @@ -252,3 +252,9 @@ $.fn.extend({ }, }); + +$.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "), (function(e, t) { + $.fn[t] = function(e, i) { + return arguments.length > 0 ? this.on(t, null, e, i) : this.trigger(t) + } +})) \ No newline at end of file diff --git a/packages/fineui/src/core/platform/web/jquery/index.js b/packages/fineui/src/core/platform/web/jquery/index.js index 4c523e052..adc0e96a7 100644 --- a/packages/fineui/src/core/platform/web/jquery/index.js +++ b/packages/fineui/src/core/platform/web/jquery/index.js @@ -1,4 +1,3 @@ -import "./_jquery"; import "./event"; import "./fn"; import "./jquery.mousewheel"; diff --git a/packages/fineui/src/core/platform/web/jquery/jquery.polyfill.js b/packages/fineui/src/core/platform/web/jquery/jquery.polyfill.js new file mode 100644 index 000000000..7564b7855 --- /dev/null +++ b/packages/fineui/src/core/platform/web/jquery/jquery.polyfill.js @@ -0,0 +1,81 @@ +/** + * 用于 jquery 在 worker 环境或者 V8 引擎的 polyfill + */ +import { _global } from "@/core/0.foundation"; +if (!_global.window) { + _global.window = _global; + const document = (_global.document = {}); + const fakeElement = Object.create(document); + + Object.assign(document, { + parentNode: null, + nodeType: 9, + head: fakeElement, + body: fakeElement, + ownerDocument: document, + documentElement: document, + toString() { + return "FakeDocument"; + }, + appendChild(child) { + return child; + }, + implementation: { + createHTMLDocument() { + return { + body: { + childNodes: [], + }, + }; + }, + createDocumentFragment() { + return this; + }, + }, + getElementById() { + return fakeElement; + }, + createElement() { + return fakeElement; + }, + createDocumentFragment() { + return this; + }, + cloneNode() { + return this; + }, + getElementsByTagName() { + return [fakeElement]; + }, + getElementsByClassName() { + return [fakeElement]; + }, + setAttribute() { + return null; + }, + getAttribute() { + return null; + }, + removeChild() { + return null; + }, + addEventListener() { + return null; + }, + removeEventListener() { + return null; + }, + }); + + Object.assign(fakeElement, { + nodeType: 1, + style: {}, + ownerDocument: document, + parentNod: fakeElement, + firstChild: fakeElement, + lastChild: fakeElement, + toString() { + return "FakeElement"; + }, + }); +} diff --git a/packages/fineui/src/index.js b/packages/fineui/src/index.js index 718910771..e0600bc9e 100644 --- a/packages/fineui/src/index.js +++ b/packages/fineui/src/index.js @@ -1,13 +1,9 @@ // sideEffects -import "./polyfill"; import "./core/system"; -import "./core/element"; -import "./core/platform"; import "./core/platform/web/jquery" -// 必须要等上面的准备好, 才初始化 config import "./core/platform/web/config"; -import _jquery from "jquery"; +import jquery from "jquery"; export * from "./core"; export * from "./base"; @@ -17,5 +13,5 @@ export * from "./component"; export * from "./fix"; export * from "./router"; export * as Popper from "@popperjs/core"; -export const jQuery = _jquery; -export const $ = _jquery; +export const jQuery = jquery; +export const $ = jquery; diff --git a/packages/fineui/src/polyfill/event.js b/packages/fineui/src/polyfill/event.js index 346ec16c8..decca0f7f 100644 --- a/packages/fineui/src/polyfill/event.js +++ b/packages/fineui/src/polyfill/event.js @@ -1,9 +1,9 @@ -(function () { - if (typeof window.CustomEvent === "function") return false; // If not IE +const isIE = () => typeof window.CustomEvent !== "function"; - function CustomEvent (event, params) { +if (isIE()) { + function CustomEvent(event, params) { params = params || { bubbles: false, cancelable: false, detail: undefined }; - var evt = document.createEvent("CustomEvent"); + const evt = document.createEvent("CustomEvent"); evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); return evt; @@ -12,4 +12,4 @@ CustomEvent.prototype = window.Event.prototype; window.CustomEvent = CustomEvent; -}()); +} diff --git a/packages/fineui/tsconfig.json b/packages/fineui/tsconfig.json index c4d27c622..5a888d48a 100644 --- a/packages/fineui/tsconfig.json +++ b/packages/fineui/tsconfig.json @@ -4,10 +4,13 @@ "target": "es2017", "module": "es2015", "moduleResolution": "node", - "lib": ["es2017", "dom"], + "lib": [ + "es2017", + "dom" + ], "declaration": true, "experimentalDecorators": true, - "outDir": "./type/lib", + "outDir": "./dist/lib", "baseUrl": ".", // "strict": true, "strictNullChecks": true, diff --git a/packages/fineui/webpack/attachments.js b/packages/fineui/webpack/attachments.js index c46279897..58ea3107c 100644 --- a/packages/fineui/webpack/attachments.js +++ b/packages/fineui/webpack/attachments.js @@ -1,19 +1,16 @@ const { sync, uniq } = require("./utils"); const fixJs = "./dist/fix/fix.js"; -const fixProxyJs = './dist/fix/fix.proxy.js'; +const fixProxyJs = "./dist/fix/fix.proxy.js"; const fixCompact = "./dist/fix/fix.compact.js"; -const workerCompact = './dist/fix/worker.compact.js'; +const workerCompact = "./dist/fix/worker.compact.js"; const lodashJs = "src/core/1.lodash.js"; -const jqueryJs = "src/core/platform/web/jquery/_jquery.js"; +const jqueryPolyfill = "./src/core/platform/web/jquery/jquery.polyfill.js"; -const runtimePolyfill = ["core-js/stable"]; +const runtimePolyfill = []; const basicAttachmentMap = { - polyfill: sync([ - "src/core/0.foundation.js", - "src/polyfill/**/*.js", - ]).concat(runtimePolyfill), + polyfill: sync(["src/core/0.foundation.js", "src/polyfill/**/*.js"]).concat(runtimePolyfill), core: sync([ "src/less/core/**/*.less", "src/less/theme/**/*.less", @@ -39,38 +36,23 @@ const basicAttachmentMap = { // "src/widget/**/*.js", // "src/component/**/*.js", ]), - router: sync([ - "src/router/**/*.js", - ]), - core_without_platform: sync([ - "src/core/0.foundation.js", - lodashJs, - "src/core/**/*.js", - "src/data/**/*.js", - ], [ - "src/core/platform/**/*.js", - "src/core/controller/**/*.js", - ]), + router: sync(["src/router/**/*.js"]), + core_without_platform: sync( + ["src/core/0.foundation.js", lodashJs, "src/core/**/*.js", "src/data/**/*.js"], + ["src/core/platform/**/*.js", "src/core/controller/**/*.js"] + ), core_without_normalize: sync( - ["src/less/core/**/*.less", "src/less/theme/**/*.less"], ["src/less/core/normalize.less", "src/less/core/normalize2.less"] + ["src/less/core/**/*.less", "src/less/theme/**/*.less"], + ["src/less/core/normalize.less", "src/less/core/normalize2.less"] + ), + core_without_conflict: sync( + ["src/less/core/**/*.less", "src/less/theme/**/*.less", lodashJs, "src/core/**/*.js", "src/data/**/*.js"], + ["src/core/conflict.js"] ), - core_without_conflict: sync([ - "src/less/core/**/*.less", - "src/less/theme/**/*.less", - lodashJs, - "src/core/**/*.js", - "src/data/**/*.js", - ], [ - "src/core/conflict.js", - ]), resource: sync(["src/less/resource/**/*.less"]), font: sync(["public/less/font.less"]), - ts: ['./typescript/bundle.ts'], - ui: sync([ - 'ui/less/app.less', - 'ui/less/**/*.less', - 'ui/js/**/*.js', - ]), + ts: ["./typescript/bundle.ts"], + ui: sync(["ui/less/app.less", "ui/less/**/*.less", "ui/js/**/*.js"]), config: sync(["demo/version.js", "i18n/i18n.cn.js"]), utils: sync([ "src/core/0.foundation.js", @@ -95,7 +77,7 @@ const basicAttachmentMap = { "src/less/widget/**/*.less", "src/less/component/**/*.less", ]), - js_bundle: sync(["src/bundle.js"]) + js_bundle: sync(["src/bundle.js"]), }; const bundle = [].concat( @@ -109,13 +91,10 @@ const bundle = [].concat( [fixCompact, workerCompact], basicAttachmentMap.router, sync(["public/js/**/*.js", "public/js/index.js", "i18n/i18n.cn.js"]), - basicAttachmentMap.ts, + basicAttachmentMap.ts ); -const bundleCss = [].concat( - basicAttachmentMap.less, - sync(["public/less/app.less", "public/less/**/*.less"]), -); +const bundleCss = [].concat(basicAttachmentMap.less, sync(["public/less/app.less", "public/less/**/*.less"])); // const bundleModern = [].concat( // sync(["src/less/modern.less"]), @@ -129,9 +108,9 @@ const coreJs = [].concat( basicAttachmentMap.base, basicAttachmentMap.case, basicAttachmentMap.widget, - ['./dist/fix/fix.compact.js'], + ["./dist/fix/fix.compact.js"], basicAttachmentMap.router, - basicAttachmentMap.ts, + basicAttachmentMap.ts ); const resource = sync(["private/less/app.less", "private/less/**/*.less"]); @@ -140,16 +119,17 @@ const config = sync(["public/js/**/*.js", "public/js/index.js", "i18n/i18n.cn.js const bundleWithoutNormalize = [].concat( basicAttachmentMap.core_without_normalize, - sync([ - "src/less/base/**/*.less", - "src/less/case/**/*.less", - "src/less/widget/**/*.less", - "src/less/component/**/*.less", - "public/less/**/*.less", - // ts的less - ], [ - "public/less/app.less", - ]), + sync( + [ + "src/less/base/**/*.less", + "src/less/case/**/*.less", + "src/less/widget/**/*.less", + "src/less/component/**/*.less", + "public/less/**/*.less", + // ts的less + ], + ["public/less/app.less"] + ) ); const fineuiWithoutNormalize = [].concat( @@ -159,20 +139,27 @@ const fineuiWithoutNormalize = [].concat( "src/less/case/**/*.less", "src/less/widget/**/*.less", "src/less/component/**/*.less", - 'ui/less/app.less', - 'ui/less/**/*.less', - ]), + "ui/less/app.less", + "ui/less/**/*.less", + ]) ); const fineui = [].concat( bundleCss, + basicAttachmentMap.polyfill, basicAttachmentMap.js_bundle, basicAttachmentMap.ui, - // basicAttachmentMap.ts, + basicAttachmentMap.ts +); + +const fineuiForWorker = [].concat( + jqueryPolyfill, + basicAttachmentMap.js_bundle, + basicAttachmentMap.ui, + basicAttachmentMap.ts ); const fineuiWithoutConflict = [].concat( - basicAttachmentMap.polyfill, basicAttachmentMap.core_without_conflict, basicAttachmentMap.fix, basicAttachmentMap.base, @@ -182,6 +169,7 @@ const fineuiWithoutConflict = [].concat( [fixCompact, workerCompact], basicAttachmentMap.ui, basicAttachmentMap.ts, + basicAttachmentMap.polyfill ); // const fineuiModern = [].concat( @@ -202,30 +190,7 @@ const fineuiProxy = [].concat( basicAttachmentMap.router, [fixCompact, workerCompact], basicAttachmentMap.ui, - basicAttachmentMap.ts, -); - -const fineuiWithoutJqueryAndPolyfillJs = [].concat( - runtimePolyfill, - sync([ - "src/core/0.foundation.js", - lodashJs, - "src/core/**/*.js", - "src/data/**/*.js", - ], [ - "src/core/platform/web/**/*.js", - ]), - basicAttachmentMap.fix, - sync([ - "src/base/**/*.js", - "src/case/**/*.js", - ], [ - "src/base/single/input/file.js", - "src/case/ztree/**/*.js", - ]), - basicAttachmentMap.widget, - sync([fixCompact, workerCompact, "ui/js/**/*.js"]), - basicAttachmentMap.ts, + basicAttachmentMap.ts ); const demo = [].concat( @@ -240,7 +205,7 @@ const demo = [].concat( sync(["public/less/app.less", "public/less/**/*.less"]), [fixCompact, workerCompact], basicAttachmentMap.ts, - sync(["demo/less/*.less", "demo/less/**/*.less", "demo/app.js", "demo/js/**/*.js", "demo/config.js"]), + sync(["demo/less/*.less", "demo/less/**/*.less", "demo/app.js", "demo/js/**/*.js", "demo/config.js"]) ); module.exports = { @@ -254,12 +219,12 @@ module.exports = { bundleWithoutNormalize: uniq(bundleWithoutNormalize), fineui: uniq(fineui), fineuiProxy: uniq(fineuiProxy), - fineuiWithoutJqueryAndPolyfillJs: uniq(fineuiWithoutJqueryAndPolyfillJs), + fineuiForWorker: uniq(fineuiForWorker), utils: uniq(basicAttachmentMap.utils), demo: uniq(demo), coreWithoutPlatform: uniq(basicAttachmentMap.core_without_platform), coreJs: uniq(coreJs), - resource: uniq((resource)), + resource: uniq(resource), config: uniq(config), bundleCss: uniq(bundleCss), }; diff --git a/packages/fineui/webpack/webpack.prod.js b/packages/fineui/webpack/webpack.prod.js index d5eab3742..991d535f2 100644 --- a/packages/fineui/webpack/webpack.prod.js +++ b/packages/fineui/webpack/webpack.prod.js @@ -17,7 +17,8 @@ module.exports = merge(common, { mode: "production", entry: { - "fineui.min": attachments.fineui + "fineui.min": attachments.fineui, + "fineui.worker.min": attachments.fineuiForWorker, }, output: { @@ -49,7 +50,6 @@ module.exports = merge(common, { ], }, - plugins: [ new MiniCssExtractPlugin({ filename: "[name].css", diff --git a/script/chinese.js b/scripts/chinese.js similarity index 100% rename from script/chinese.js rename to scripts/chinese.js diff --git a/script/code.static.js b/scripts/code.static.js similarity index 100% rename from script/code.static.js rename to scripts/code.static.js diff --git a/script/lib/fui.component.json b/scripts/lib/fui.component.json similarity index 100% rename from script/lib/fui.component.json rename to scripts/lib/fui.component.json diff --git a/script/lib/fui.export.txt b/scripts/lib/fui.export.txt similarity index 100% rename from script/lib/fui.export.txt rename to scripts/lib/fui.export.txt diff --git a/script/lib/utils.js b/scripts/lib/utils.js similarity index 100% rename from script/lib/utils.js rename to scripts/lib/utils.js diff --git a/script/rename.js b/scripts/rename.js similarity index 100% rename from script/rename.js rename to scripts/rename.js