-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #473 from OpenWebGAL/dev
4.4.12
- Loading branch information
Showing
83 changed files
with
1,519 additions
and
1,009 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"printWidth": 80, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"semi": true, | ||
"singleQuote": true, | ||
"quoteProps": "as-needed", | ||
"jsxSingleQuote": false, | ||
"trailingComma": "all", | ||
"bracketSpacing": true, | ||
"bracketSameLine": false, | ||
"arrowParens": "always", | ||
"requirePragma": false, | ||
"insertPragma": false, | ||
"proseWrap": "preserve", | ||
"htmlWhitespaceSensitivity": "css", | ||
"endOfLine": "lf", | ||
"embeddedLanguageFormatting": "auto" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,72 @@ | ||
import {commandType, IAsset} from "./interface/sceneInterface"; | ||
import {fileType} from "./interface/assets"; | ||
import {sceneParser} from "./sceneParser"; | ||
import {ADD_NEXT_ARG_LIST, SCRIPT_CONFIG} from "./config/scriptConfig"; | ||
import {configParser, WebgalConfig} from "./configParser/configParser"; | ||
import { | ||
ADD_NEXT_ARG_LIST, | ||
SCRIPT_CONFIG, | ||
ConfigMap, | ||
ConfigItem, | ||
} from './config/scriptConfig'; | ||
import { configParser, WebgalConfig } from './configParser/configParser'; | ||
import { fileType } from './interface/assets'; | ||
import { IAsset } from './interface/sceneInterface'; | ||
import { sceneParser } from './sceneParser'; | ||
|
||
export default class SceneParser { | ||
|
||
private readonly assetsPrefetcher; | ||
private readonly assetSetter; | ||
private readonly ADD_NEXT_ARG_LIST; | ||
private readonly SCRIPT_CONFIG; | ||
|
||
constructor(assetsPrefetcher: ((assetList: Array<IAsset>) => void), | ||
assetSetter: (fileName: string, assetType: fileType) => string, | ||
ADD_NEXT_ARG_LIST: Array<number>, SCRIPT_CONFIG: Array<any>) { | ||
this.assetsPrefetcher = assetsPrefetcher; | ||
this.assetSetter = assetSetter; | ||
this.ADD_NEXT_ARG_LIST = ADD_NEXT_ARG_LIST; | ||
this.SCRIPT_CONFIG = SCRIPT_CONFIG; | ||
} | ||
|
||
parse(rawScene: string, sceneName: string, sceneUrl: string | ||
private readonly SCRIPT_CONFIG_MAP: ConfigMap; | ||
constructor( | ||
private readonly assetsPrefetcher: (assetList: IAsset[]) => void, | ||
private readonly assetSetter: ( | ||
fileName: string, | ||
assetType: fileType, | ||
) => string, | ||
private readonly ADD_NEXT_ARG_LIST: number[], | ||
SCRIPT_CONFIG_INPUT: ConfigItem[] | ConfigMap, | ||
) { | ||
return sceneParser(rawScene, sceneName, sceneUrl, this.assetsPrefetcher, this.assetSetter, this.ADD_NEXT_ARG_LIST, this.SCRIPT_CONFIG); | ||
if (Array.isArray(SCRIPT_CONFIG_INPUT)) { | ||
this.SCRIPT_CONFIG_MAP = new Map(); | ||
SCRIPT_CONFIG_INPUT.forEach((config) => { | ||
this.SCRIPT_CONFIG_MAP.set(config.scriptString, config); | ||
}); | ||
} else { | ||
this.SCRIPT_CONFIG_MAP = SCRIPT_CONFIG_INPUT; | ||
} | ||
} | ||
/** | ||
* 解析场景 | ||
* @param rawScene 原始场景 | ||
* @param sceneName 场景名称 | ||
* @param sceneUrl 场景url | ||
* @return 解析后的场景 | ||
*/ | ||
parse(rawScene: string, sceneName: string, sceneUrl: string) { | ||
return sceneParser( | ||
rawScene, | ||
sceneName, | ||
sceneUrl, | ||
this.assetsPrefetcher, | ||
this.assetSetter, | ||
this.ADD_NEXT_ARG_LIST, | ||
this.SCRIPT_CONFIG_MAP, | ||
); | ||
} | ||
|
||
parseConfig(configText: string) { | ||
return configParser(configText) | ||
return configParser(configText); | ||
} | ||
|
||
stringifyConfig(config: WebgalConfig) { | ||
return config | ||
.reduce( | ||
(previousValue, curr) => | ||
(previousValue + `${curr.command}:${curr.args.join('|')}${curr.options.length <= 0 ? '' : curr.options.reduce((p, c) => (p + ' -' + c.key + '=' + c.value), '')};\n`), | ||
'' | ||
) | ||
return config.reduce( | ||
(previousValue, curr) => | ||
previousValue + | ||
`${curr.command}:${curr.args.join('|')}${ | ||
curr.options.length <= 0 | ||
? '' | ||
: curr.options.reduce( | ||
(p, c) => p + ' -' + c.key + '=' + c.value, | ||
'', | ||
) | ||
};\n`, | ||
'', | ||
); | ||
} | ||
} | ||
|
||
export {ADD_NEXT_ARG_LIST, SCRIPT_CONFIG}; | ||
export { ADD_NEXT_ARG_LIST, SCRIPT_CONFIG }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.