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",
"version": "2.0.70",
"version": "2.0.71",
"description": "canvas渲染引擎",
"main": "./build/fyge.min.js",
"module": "./build/fyge.esm.js",
......@@ -10,16 +10,12 @@
"rollup-plugin-serve": "^1.1.0"
},
"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",
"declare2": "tsc -d --declarationDir types --emitDeclarationOnly",
"build": "webpack",
"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"
"build": "rollup -c --environment BUILD:production",
"dev": "rollup -c -m -w"
},
"author": "MrKwon",
"license": "ISC",
......@@ -33,12 +29,9 @@
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript": "^1.0.1",
"rollup-plugin-typescript2": "^0.25.2",
"ts-loader": "^4.0.0",
"tslib": "^2.1.0",
"typedoc": "^0.20.20",
"typescript": "^3.5.1",
"webpack": "^4.1.0",
"webpack-cli": "^3.3.2"
"typescript": "^3.5.1"
},
"keywords": [
"h5,淘宝小程序,canvas,webgl,3d,gltf,spine,lottie,svga"
......
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const progress = require('rollup-plugin-progress');
......@@ -15,42 +14,61 @@ const serve = require('rollup-plugin-serve');
const isProd = process.env.BUILD === 'production';
export default {
input: 'src/index.ts',
output: [
{
file: "build/fyge.min.js",
format: 'umd',
name: 'FYGE',
globals: {
//tslib: 'tslib'
},
//banner: tslibCode + '\n' + tslibWrapper,
sourcemap: true//!isProd,
},
{
file: `build/fyge.esm.js`,
format: 'esm',
globals: {
//tslib: 'tslib'
},
//banner: tslibCode + '\n' + tslibWrapper,
sourcemap: true//!isProd,
},
],
plugins: [
progress(),
resolve({}),
typescript(),
commonjs(),
isProd && terser(),
!isProd &&serve({
port:8099,
headers: {
'Access-Control-Allow-Origin': '*',
},
}),
!isProd && livereload(),
],
//external: ['tslib'],
};
import pkg from "./package.json";
const version = pkg.version;
const outputPath = isProd ? "build" : "debug";
const plugins = [
progress(),
resolve(),
typescript(),
commonjs(),
isProd && terser(),
!isProd && livereload(),
];
export default [
{
input: 'src/index.ts',
output: [
{
file: `${outputPath}/fyge_${version}.min.js`,
format: 'umd',
name: 'FYGE',
sourcemap: true//!isProd,
},
{
file: `${outputPath}/fyge_${version}.esm.js`,
format: 'esm',
sourcemap: true//!isProd,
}
],
plugins: [
...plugins,
!isProd && serve({
port: 8099,
headers: {
'Access-Control-Allow-Origin': '*',
},
}),
],
},
{
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 ts = require("typescript");
const regLine = /(export|declare)((?!from).)*/g;
function compile(fileNames, options) {
const host = ts.createCompilerHost(options);
const exports = [];
host.writeFile = (fileName, fileContent) => {
const result = fileContent.match(regLine);
for (let line of result) {
if (line.match(/export (default)? \w+;/)) {
continue;
}
if (line.endsWith(';')) {
if (!line.startsWith('_') && !line.startsWith('export default function')) {
exports.push(line);
}
} else {
if (line.endsWith('{')) {
let start = fileContent.indexOf(line);
const block = fileContent.substring(start, fileContent.indexOf('\n}', start) + 2);
if (!block.startsWith('_')) {
exports.push(block);
}
}
}
}
};
const program = ts.createProgram(fileNames, options, host);
program.emit();
let allExports = exports.join('\n\n')
.replace(/export default _default;/g, '')
.replace(/export declare/g, 'export ')
.replace(/export default/g, 'export ')
.replace(/declare /g, 'export ')
;
// const content = `declare module FYGE{${allExports}}`;
// const content = `declare namespace FYGE{${allExports}}\ndeclare module "fyge" {export = FYGE;}`;
const content = `declare namespace FYGE{${allExports}}`;//不作为npm使用时还是去掉吧
fs.writeFileSync('build/FYGE.d.ts', content);
function compile(fileNames, outputName, options) {
const host = ts.createCompilerHost(options);
const exports = [];
host.writeFile = (fileName, fileContent) => {
const result = fileContent.match(regLine);
for (let line of result) {
if (line.match(/export (default)? \w+;/)) {
continue;
}
if (line.endsWith(';')) {
if (!line.startsWith('_') && !line.startsWith('export default function')) {
exports.push(line);
}
} else {
if (line.endsWith('{')) {
let start = fileContent.indexOf(line);
const block = fileContent.substring(start, fileContent.indexOf('\n}', start) + 2);
if (!block.startsWith('_')) {
exports.push(block);
}
}
}
}
};
const program = ts.createProgram([fileNames], options, host);
program.emit();
let allExports = exports.join('\n\n')
.replace(/export default _default;/g, '')
.replace(/export declare/g, 'export ')
.replace(/export default/g, 'export ')
.replace(/declare /g, 'export ')
;
// const content = `declare module FYGE{${allExports}}`;
// const content = `declare namespace FYGE{${allExports}}\ndeclare module "fyge" {export = FYGE;}`;
const content = `declare namespace FYGE{${allExports}}`;//不作为npm使用时还是去掉吧
fs.writeFileSync(outputName, content);
}
compile(process.argv.slice(2), {
allowJs: true,
declaration: true,
emitDeclarationOnly: true,
const [src, out] = process.argv.slice(2);
compile(src, out, {
allowJs: true,
declaration: true,
emitDeclarationOnly: true,
maxNodeModuleJsDepth: 0,
});
......@@ -29,7 +29,7 @@ function compile(fileNames, options) {
}
};
const program = ts.createProgram(fileNames, options, host);
const program = ts.createProgram([fileNames], options, host);
program.emit();
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/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";
export * from "./2d";
//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