Commit b588b4b0 authored by 邱旭's avatar 邱旭

修复鸿蒙3.0问题,只是临时修复,不确定是否会有其他的影响

parent d05ce625
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
{ {
"name": "fyge", "name": "fyge",
"version": "2.0.70", "version": "2.0.71",
"description": "canvas渲染引擎", "description": "canvas渲染引擎",
"main": "./build/fyge.min.js", "main": "./build/fyge.min.js",
"module": "./build/fyge.esm.js", "module": "./build/fyge.esm.js",
...@@ -10,16 +10,12 @@ ...@@ -10,16 +10,12 @@
"rollup-plugin-serve": "^1.1.0" "rollup-plugin-serve": "^1.1.0"
}, },
"scripts": { "scripts": {
"declare": "node scripts/declare.js src/index.ts", "declareFYGE": "node scripts/declare.js src/index.ts build/FYGE.d.ts",
"declare2D": "node scripts/declare.js src/2d.ts build/FYGE2D.d.ts",
"declare": "npm run declareFYGE && npm run declare2D",
"declare1": "node scripts/declare1.js src/index.ts", "declare1": "node scripts/declare1.js src/index.ts",
"declare2": "tsc -d --declarationDir types --emitDeclarationOnly", "build": "rollup -c --environment BUILD:production",
"build": "webpack", "dev": "rollup -c -m -w"
"buildR": "rollup -c --environment BUILD:production",
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack -w",
"devR": "rollup -c -m -w",
"watch": "webpack --watch",
"typedoc": "typedoc src/index.ts"
}, },
"author": "MrKwon", "author": "MrKwon",
"license": "ISC", "license": "ISC",
...@@ -33,12 +29,9 @@ ...@@ -33,12 +29,9 @@
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript": "^1.0.1", "rollup-plugin-typescript": "^1.0.1",
"rollup-plugin-typescript2": "^0.25.2", "rollup-plugin-typescript2": "^0.25.2",
"ts-loader": "^4.0.0",
"tslib": "^2.1.0", "tslib": "^2.1.0",
"typedoc": "^0.20.20", "typedoc": "^0.20.20",
"typescript": "^3.5.1", "typescript": "^3.5.1"
"webpack": "^4.1.0",
"webpack-cli": "^3.3.2"
}, },
"keywords": [ "keywords": [
"h5,淘宝小程序,canvas,webgl,3d,gltf,spine,lottie,svga" "h5,淘宝小程序,canvas,webgl,3d,gltf,spine,lottie,svga"
......
const resolve = require('rollup-plugin-node-resolve'); const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs'); const commonjs = require('rollup-plugin-commonjs');
const progress = require('rollup-plugin-progress'); const progress = require('rollup-plugin-progress');
...@@ -15,42 +14,61 @@ const serve = require('rollup-plugin-serve'); ...@@ -15,42 +14,61 @@ const serve = require('rollup-plugin-serve');
const isProd = process.env.BUILD === 'production'; const isProd = process.env.BUILD === 'production';
export default { import pkg from "./package.json";
input: 'src/index.ts',
output: [ const version = pkg.version;
{ const outputPath = isProd ? "build" : "debug";
file: "build/fyge.min.js",
format: 'umd', const plugins = [
name: 'FYGE', progress(),
globals: { resolve(),
//tslib: 'tslib' typescript(),
}, commonjs(),
//banner: tslibCode + '\n' + tslibWrapper, isProd && terser(),
sourcemap: true//!isProd, !isProd && livereload(),
}, ];
{
file: `build/fyge.esm.js`, export default [
format: 'esm', {
globals: { input: 'src/index.ts',
//tslib: 'tslib' output: [
}, {
//banner: tslibCode + '\n' + tslibWrapper, file: `${outputPath}/fyge_${version}.min.js`,
sourcemap: true//!isProd, format: 'umd',
}, name: 'FYGE',
], sourcemap: true//!isProd,
plugins: [ },
progress(), {
resolve({}), file: `${outputPath}/fyge_${version}.esm.js`,
typescript(), format: 'esm',
commonjs(), sourcemap: true//!isProd,
isProd && terser(), }
!isProd &&serve({ ],
port:8099, plugins: [
headers: { ...plugins,
'Access-Control-Allow-Origin': '*', !isProd && serve({
}, port: 8099,
}), headers: {
!isProd && livereload(), 'Access-Control-Allow-Origin': '*',
], },
//external: ['tslib'], }),
}; ],
},
{
input: 'src/2d.ts',
output: [
{
file: `${outputPath}/fyge2d_${version}.min.js`,
format: 'umd',
name: 'FYGE',
sourcemap: true//!isProd,
},
{
file: `${outputPath}/fyge2d_${version}.esm.js`,
format: 'esm',
sourcemap: true//!isProd,
}
],
plugins: plugins,
}
];
const fs = require('fs'); const fs = require('fs');
const ts = require("typescript"); const ts = require("typescript");
const regLine = /(export|declare)((?!from).)*/g; const regLine = /(export|declare)((?!from).)*/g;
function compile(fileNames, options) { function compile(fileNames, outputName, options) {
const host = ts.createCompilerHost(options); const host = ts.createCompilerHost(options);
const exports = []; const exports = [];
host.writeFile = (fileName, fileContent) => { host.writeFile = (fileName, fileContent) => {
const result = fileContent.match(regLine); const result = fileContent.match(regLine);
for (let line of result) { for (let line of result) {
if (line.match(/export (default)? \w+;/)) { if (line.match(/export (default)? \w+;/)) {
continue; continue;
} }
if (line.endsWith(';')) { if (line.endsWith(';')) {
if (!line.startsWith('_') && !line.startsWith('export default function')) { if (!line.startsWith('_') && !line.startsWith('export default function')) {
exports.push(line); exports.push(line);
} }
} else { } else {
if (line.endsWith('{')) { if (line.endsWith('{')) {
let start = fileContent.indexOf(line); let start = fileContent.indexOf(line);
const block = fileContent.substring(start, fileContent.indexOf('\n}', start) + 2); const block = fileContent.substring(start, fileContent.indexOf('\n}', start) + 2);
if (!block.startsWith('_')) { if (!block.startsWith('_')) {
exports.push(block); exports.push(block);
} }
} }
} }
} }
}; };
const program = ts.createProgram(fileNames, options, host); const program = ts.createProgram([fileNames], options, host);
program.emit(); program.emit();
let allExports = exports.join('\n\n') let allExports = exports.join('\n\n')
.replace(/export default _default;/g, '') .replace(/export default _default;/g, '')
.replace(/export declare/g, 'export ') .replace(/export declare/g, 'export ')
.replace(/export default/g, 'export ') .replace(/export default/g, 'export ')
.replace(/declare /g, 'export ') .replace(/declare /g, 'export ')
; ;
// const content = `declare module FYGE{${allExports}}`; // const content = `declare module FYGE{${allExports}}`;
// const content = `declare namespace FYGE{${allExports}}\ndeclare module "fyge" {export = FYGE;}`; // const content = `declare namespace FYGE{${allExports}}\ndeclare module "fyge" {export = FYGE;}`;
const content = `declare namespace FYGE{${allExports}}`;//不作为npm使用时还是去掉吧 const content = `declare namespace FYGE{${allExports}}`;//不作为npm使用时还是去掉吧
fs.writeFileSync('build/FYGE.d.ts', content); fs.writeFileSync(outputName, content);
} }
compile(process.argv.slice(2), { const [src, out] = process.argv.slice(2);
allowJs: true,
declaration: true, compile(src, out, {
emitDeclarationOnly: true, allowJs: true,
declaration: true,
emitDeclarationOnly: true,
maxNodeModuleJsDepth: 0,
}); });
...@@ -29,7 +29,7 @@ function compile(fileNames, options) { ...@@ -29,7 +29,7 @@ function compile(fileNames, options) {
} }
}; };
const program = ts.createProgram(fileNames, options, host); const program = ts.createProgram([fileNames], options, host);
program.emit(); program.emit();
let allExports = exports.join('\n\n') let allExports = exports.join('\n\n')
......
export * from './2d/const';
export * from "./2d/display";
export * from "./2d/events";
export * from "./2d/filter";
export * from "./2d/graphics";
export * from "./2d/loader";
export * from "./2d/math";
export * from "./2d/mesh";
export * from "./2d/renderers/CanvasRenderer";
export * from "./2d/renderers/WebglRenderer";
export * from "./2d/renderers/toDisplayDataURL";//单独导出
export * from "./2d/text";
export * from "./2d/texture";
export * from "./2d/ui";
export * from "./2d/utils";
export * from "./tween";
// glCore
export * from "./glCore";
//spine
export * from "./spine";
//fps面板,后续可以加入每次drawCall,总绘制对象等等
export * from "./2d/FpsPanel";
\ No newline at end of file
export * from "./2d";
export * from './2d/const';
export * from "./2d/display";
export * from "./2d/events";
export * from "./2d/filter";
export * from "./2d/graphics";
export * from "./2d/loader";
export * from "./2d/math";
export * from "./2d/mesh";
export * from "./2d/renderers/CanvasRenderer";
export * from "./2d/renderers/WebglRenderer";
export * from "./2d/renderers/toDisplayDataURL";//单独导出
export * from "./2d/text";
export * from "./2d/texture";
export * from "./2d/ui";
export * from "./2d/utils";
export * from "./tween";
//3D //3D
export * from "./3d"; export * from "./3d";
// glCore
export * from "./glCore";
//spine
export * from "./spine";
//fps面板,后续可以加入每次drawCall,总绘制对象等等
export * from "./2d/FpsPanel";
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment