Commit 9b8ae891 authored by haiyoucuv's avatar haiyoucuv

1

parent a3eb0863
File added
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="TsLint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
<option name="languageLevel" value="FLOW" />
</component>
</project>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
<changelist name="Uncommitted_changes_before_Checkout_at_2020_5_15,_2_12_下午_[Default_Changelist]" date="1589523138013" recycled="false" toDelete="true">
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Checkout_at_2020_5_15,_2_12_下午_[Default_Changelist]/shelved.patch" />
<option name="DESCRIPTION" value="Uncommitted changes before Checkout at 2020/5/15, 2:12 下午 [Default Changelist]" />
</changelist>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
<changelist name="Uncommitted_changes_before_Update_at_2020_5_14,_2_47_下午_[Default_Changelist]" date="1589438835098" recycled="false" toDelete="true">
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_2020_5_14,_2_47_下午_[Default_Changelist]/shelved.patch" />
<option name="DESCRIPTION" value="Uncommitted changes before Update at 2020/5/14, 2:47 下午 [Default Changelist]" />
</changelist>
\ No newline at end of file
<changelist name="Uncommitted_changes_before_Update_at_2020_5_14,_2_47_下午_[Default_Changelist]1" date="1589438857749" recycled="true" deleted="true">
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_2020_5_14,_2_47_下午_[Default_Changelist]1/shelved.patch" />
<option name="DESCRIPTION" value="Uncommitted changes before Update at 2020/5/14, 2:47 下午 [Default Changelist]" />
</changelist>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="af35c04f-08f6-48ed-85db-2f94c60e87fd" name="Default Changelist" comment="" />
<list default="true" id="af35c04f-08f6-48ed-85db-2f94c60e87fd" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/debug/engine.js" beforeDir="false" afterPath="$PROJECT_DIR$/debug/engine.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/debug/engine.js.map" beforeDir="false" afterPath="$PROJECT_DIR$/debug/engine.js.map" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/rollup.config.js" beforeDir="false" afterPath="$PROJECT_DIR$/rollup.config.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/2d/display/Container.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/2d/display/Container.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/2d/display/Sprite.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/2d/display/Sprite.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/2d/display/Stage.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/2d/display/Stage.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/2d/events/Event.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/2d/events/Event.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/zeroing/decorators/auto-adjust.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/zeroing/decorators/auto-adjust.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/zeroing/game-warpper/GameStage.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/zeroing/game-warpper/GameStage.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/zeroing/launcher.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/zeroing/launcher.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/zeroing/utils/utils.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/zeroing/utils/utils.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/yarn.lock" beforeDir="false" afterPath="$PROJECT_DIR$/yarn.lock" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
......@@ -10,9 +26,9 @@
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="JavaScript File" />
<option value="MarkDown" />
<option value="TypeScript File" />
<option value="JavaScript File" />
</list>
</option>
</component>
......@@ -25,28 +41,31 @@
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="UPDATE_TYPE" value="MERGE" />
</component>
<component name="IgnoredFileRootStore">
<option name="generatedRoots">
<set>
<option value="$PROJECT_DIR$/.idea" />
</set>
</option>
<component name="JsFlowSettings">
<service-enabled>true</service-enabled>
<exe-path />
<other-services-enabled>true</other-services-enabled>
<auto-save>true</auto-save>
</component>
<component name="ProjectId" id="1ZYzLmPKm3UfhIZLkr8RtiZwhUf" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/src/zeroing/game-warpper/mvvm" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.path.for.package.eslint" value="project" />
<property name="node.js.path.for.package.tslint" value="project" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="node.js.selected.package.tslint" value="(autodetect)" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="nodejs_package_manager_path" value="yarn" />
<property name="run.code.analysis.last.selected.profile" value="pProject Default" />
<property name="settings.editor.selected.configurable" value="settings.typescriptcompiler" />
<property name="settings.editor.selected.configurable" value="yiiguxing.plugin.translate" />
<property name="ts.external.directory.path" value="$PROJECT_DIR$/node_modules/typescript/lib" />
</component>
<component name="RecentsManager">
......@@ -108,8 +127,8 @@
</configuration>
<recent_temporary>
<list>
<item itemvalue="npm.preprocess" />
<item itemvalue="npm.dev" />
<item itemvalue="npm.preprocess" />
<item itemvalue="npm.declare" />
<item itemvalue="npm.debug" />
<item itemvalue="npm.build:prod" />
......@@ -157,15 +176,22 @@
<workItem from="1587606438033" duration="14026000" />
<workItem from="1587696728690" duration="5561000" />
<workItem from="1587713741312" duration="310000" />
<workItem from="1589536818547" duration="8764000" />
<workItem from="1589709011120" duration="341000" />
<workItem from="1589766926355" duration="379000" />
<workItem from="1589767318703" duration="29000" />
<workItem from="1589767471060" duration="25732000" />
<workItem from="1589853014410" duration="21858000" />
<workItem from="1589888428282" duration="5840000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
<option name="version" value="2" />
<option name="exactExcludedFiles">
<list>
<option value="$PROJECT_DIR$/examples/scripts/Wave.js" />
<option value="$PROJECT_DIR$/examples/scripts/TouchZoom.js" />
<option value="$PROJECT_DIR$/examples/scripts/Wave.js" />
</list>
</option>
</component>
......@@ -190,37 +216,37 @@
<screen x="1680" y="-229" width="1920" height="1177" />
</state>
<state width="969" height="466" key="DebuggerActiveHint/35.23.1645.1027/1680.-229.1920.1177@1680.-229.1920.1177" timestamp="1585535223173" />
<state width="584" height="1056" key="GridCell.Tab.0.bottom" timestamp="1587713730150">
<screen x="1680" y="-252" width="1920" height="1200" />
<state width="493" height="821" key="GridCell.Tab.0.bottom" timestamp="1589897780335">
<screen x="1680" y="-229" width="1920" height="1177" />
</state>
<state width="276" height="1101" key="GridCell.Tab.0.bottom/0.0.1680.1050/1680.-252.1920.1200@1680.-252.1920.1200" timestamp="1587712516387" />
<state width="584" height="1056" key="GridCell.Tab.0.bottom/0.23.1680.1027/1680.-252.1920.1200@1680.-252.1920.1200" timestamp="1587713730150" />
<state width="584" height="1056" key="GridCell.Tab.0.bottom/35.23.1645.1027/1680.-229.1920.1177@1680.-229.1920.1177" timestamp="1587710590931" />
<state width="336" height="906" key="GridCell.Tab.0.bottom/35.23.1645.1027/1680.-229.1920.1177@35.23.1645.1027" timestamp="1585720951511" />
<state width="493" height="821" key="GridCell.Tab.0.bottom/35.23.1645.1027/1680.-229.1920.1177@1680.-229.1920.1177" timestamp="1589897780335" />
<state width="687" height="907" key="GridCell.Tab.0.bottom/35.23.1645.1027/1680.-229.1920.1177@35.23.1645.1027" timestamp="1589767347615" />
<state width="427" height="906" key="GridCell.Tab.0.bottom/35.23.1645.1027@35.23.1645.1027" timestamp="1586963282147" />
<state width="584" height="1056" key="GridCell.Tab.0.center" timestamp="1587713730146">
<screen x="1680" y="-252" width="1920" height="1200" />
<state width="493" height="821" key="GridCell.Tab.0.center" timestamp="1589897780335">
<screen x="1680" y="-229" width="1920" height="1177" />
</state>
<state width="276" height="1101" key="GridCell.Tab.0.center/0.0.1680.1050/1680.-252.1920.1200@1680.-252.1920.1200" timestamp="1587712516380" />
<state width="584" height="1056" key="GridCell.Tab.0.center/0.23.1680.1027/1680.-252.1920.1200@1680.-252.1920.1200" timestamp="1587713730146" />
<state width="584" height="1056" key="GridCell.Tab.0.center/35.23.1645.1027/1680.-229.1920.1177@1680.-229.1920.1177" timestamp="1587710590929" />
<state width="336" height="906" key="GridCell.Tab.0.center/35.23.1645.1027/1680.-229.1920.1177@35.23.1645.1027" timestamp="1585720951508" />
<state width="493" height="821" key="GridCell.Tab.0.center/35.23.1645.1027/1680.-229.1920.1177@1680.-229.1920.1177" timestamp="1589897780335" />
<state width="687" height="907" key="GridCell.Tab.0.center/35.23.1645.1027/1680.-229.1920.1177@35.23.1645.1027" timestamp="1589767347614" />
<state width="427" height="906" key="GridCell.Tab.0.center/35.23.1645.1027@35.23.1645.1027" timestamp="1586963282146" />
<state width="584" height="1056" key="GridCell.Tab.0.left" timestamp="1587713730145">
<screen x="1680" y="-252" width="1920" height="1200" />
<state width="493" height="821" key="GridCell.Tab.0.left" timestamp="1589897780334">
<screen x="1680" y="-229" width="1920" height="1177" />
</state>
<state width="276" height="1101" key="GridCell.Tab.0.left/0.0.1680.1050/1680.-252.1920.1200@1680.-252.1920.1200" timestamp="1587712516377" />
<state width="584" height="1056" key="GridCell.Tab.0.left/0.23.1680.1027/1680.-252.1920.1200@1680.-252.1920.1200" timestamp="1587713730145" />
<state width="584" height="1056" key="GridCell.Tab.0.left/35.23.1645.1027/1680.-229.1920.1177@1680.-229.1920.1177" timestamp="1587710590928" />
<state width="336" height="906" key="GridCell.Tab.0.left/35.23.1645.1027/1680.-229.1920.1177@35.23.1645.1027" timestamp="1585720951505" />
<state width="493" height="821" key="GridCell.Tab.0.left/35.23.1645.1027/1680.-229.1920.1177@1680.-229.1920.1177" timestamp="1589897780334" />
<state width="687" height="907" key="GridCell.Tab.0.left/35.23.1645.1027/1680.-229.1920.1177@35.23.1645.1027" timestamp="1589767347614" />
<state width="427" height="906" key="GridCell.Tab.0.left/35.23.1645.1027@35.23.1645.1027" timestamp="1586963282146" />
<state width="584" height="1056" key="GridCell.Tab.0.right" timestamp="1587713730146">
<screen x="1680" y="-252" width="1920" height="1200" />
<state width="493" height="821" key="GridCell.Tab.0.right" timestamp="1589897780335">
<screen x="1680" y="-229" width="1920" height="1177" />
</state>
<state width="276" height="1101" key="GridCell.Tab.0.right/0.0.1680.1050/1680.-252.1920.1200@1680.-252.1920.1200" timestamp="1587712516385" />
<state width="584" height="1056" key="GridCell.Tab.0.right/0.23.1680.1027/1680.-252.1920.1200@1680.-252.1920.1200" timestamp="1587713730146" />
<state width="584" height="1056" key="GridCell.Tab.0.right/35.23.1645.1027/1680.-229.1920.1177@1680.-229.1920.1177" timestamp="1587710590930" />
<state width="336" height="906" key="GridCell.Tab.0.right/35.23.1645.1027/1680.-229.1920.1177@35.23.1645.1027" timestamp="1585720951509" />
<state width="493" height="821" key="GridCell.Tab.0.right/35.23.1645.1027/1680.-229.1920.1177@1680.-229.1920.1177" timestamp="1589897780335" />
<state width="687" height="907" key="GridCell.Tab.0.right/35.23.1645.1027/1680.-229.1920.1177@35.23.1645.1027" timestamp="1589767347615" />
<state width="427" height="906" key="GridCell.Tab.0.right/35.23.1645.1027@35.23.1645.1027" timestamp="1586963282147" />
<state x="445" y="278" key="IDE.errors.dialog" timestamp="1585719736587">
<screen x="35" y="23" width="1645" height="1027" />
......@@ -230,10 +256,14 @@
<screen x="1680" y="-229" width="1920" height="1177" />
</state>
<state x="2356" y="82" key="MultipleFileMergeDialog/35.23.1645.1027/1680.-229.1920.1177@1680.-229.1920.1177" timestamp="1586919094159" />
<state x="2149" y="-2" key="SettingsEditor" timestamp="1585555176349">
<state x="631" y="245" key="RollbackChangesDialog" timestamp="1589766990893">
<screen x="35" y="23" width="1645" height="1027" />
</state>
<state x="631" y="245" key="RollbackChangesDialog/35.23.1645.1027/1680.-229.1920.1177@35.23.1645.1027" timestamp="1589766990893" />
<state x="2149" y="-2" key="SettingsEditor" timestamp="1589888551577">
<screen x="1680" y="-229" width="1920" height="1177" />
</state>
<state x="2149" y="-2" key="SettingsEditor/35.23.1645.1027/1680.-229.1920.1177@1680.-229.1920.1177" timestamp="1585555176349" />
<state x="2149" y="-2" key="SettingsEditor/35.23.1645.1027/1680.-229.1920.1177@1680.-229.1920.1177" timestamp="1589888551577" />
<state x="2441" y="283" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2" timestamp="1587713822207">
<screen x="1680" y="-229" width="1920" height="1177" />
</state>
......@@ -248,11 +278,12 @@
<screen x="1680" y="-229" width="1920" height="1177" />
</state>
<state x="2327" y="157" key="git4idea.merge.GitPullDialog/35.23.1645.1027/1680.-229.1920.1177@1680.-229.1920.1177" timestamp="1587714144888" />
<state x="2305" y="18" width="670" height="690" key="search.everywhere.popup" timestamp="1587713287518">
<screen x="1680" y="-252" width="1920" height="1200" />
<state x="2305" y="36" width="670" height="676" key="search.everywhere.popup" timestamp="1589893517546">
<screen x="1680" y="-229" width="1920" height="1177" />
</state>
<state x="2305" y="18" width="670" height="690" key="search.everywhere.popup/0.0.1680.1050/1680.-252.1920.1200@1680.-252.1920.1200" timestamp="1587713287518" />
<state x="2305" y="36" width="670" height="676" key="search.everywhere.popup/35.23.1645.1027/1680.-229.1920.1177@1680.-229.1920.1177" timestamp="1587712362381" />
<state x="2305" y="36" width="670" height="676" key="search.everywhere.popup/35.23.1645.1027/1680.-229.1920.1177@1680.-229.1920.1177" timestamp="1589893517546" />
<state x="570" y="254" width="670" height="590" key="search.everywhere.popup/35.23.1645.1027/1680.-229.1920.1177@35.23.1645.1027" timestamp="1587004990635" />
<state x="570" y="254" width="670" height="590" key="search.everywhere.popup/35.23.1645.1027@35.23.1645.1027" timestamp="1589767535433" />
</component>
</project>
\ No newline at end of file
......@@ -2,10 +2,10 @@ var __extends;var __assign;var __rest;var __decorate;var __param;var __metadata;
}};__exportStar=function(m,exports){for(var p in m){if(!exports.hasOwnProperty(p)){exports[p]=m[p]}}};__values=function(o){var m=typeof Symbol==="function"&&o[Symbol.iterator],i=0;if(m){return m.call(o)}return{next:function(){if(o&&i>=o.length){o=void 0}return{value:o&&o[i++],done:!o}}}};__read=function(o,n){var m=typeof Symbol==="function"&&o[Symbol.iterator];if(!m){return o}var i=m.call(o),r,ar=[],e;try{while((n===void 0||n-->0)&&!(r=i.next()).done){ar.push(r.value)}}catch(error){e={error:error}}finally{try{if(r&&!r.done&&(m=i["return"])){m.call(i)}}finally{if(e){throw e.error}}}return ar};__spread=function(){for(var ar=[],i=0;i<arguments.length;i++){ar=ar.concat(__read(arguments[i]))}return ar};__spreadArrays=function(){for(var s=0,i=0,il=arguments.length;i<il;i++){s+=arguments[i].length}for(var r=Array(s),k=0,i=0;i<il;i++){for(var a=arguments[i],j=0,jl=a.length;j<jl;j++,k++){r[k]=a[j]}}return r};__await=function(v){return this instanceof __await?(this.v=v,this):new __await(v)};__asyncGenerator=function(thisArg,_arguments,generator){if(!Symbol.asyncIterator){throw new TypeError("Symbol.asyncIterator is not defined.")}var g=generator.apply(thisArg,_arguments||[]),i,q=[];return i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i;function verb(n){if(g[n]){i[n]=function(v){return new Promise(function(a,b){q.push([n,v,a,b])>1||resume(n,v)})}}}function resume(n,v){try{step(g[n](v))}catch(e){settle(q[0][3],e)}}function step(r){r.value instanceof __await?Promise.resolve(r.value.v).then(fulfill,reject):settle(q[0][2],r)}function fulfill(value){resume("next",value)}function reject(value){resume("throw",value)}function settle(f,v){if(f(v),q.shift(),q.length){resume(q[0][0],q[0][1])}}};__asyncDelegator=function(o){var i,p;return i={},verb("next"),verb("throw",function(e){throw e}),verb("return"),i[Symbol.iterator]=function(){return this},i;function verb(n,f){i[n]=o[n]?function(v){return(p=!p)?{value:__await(o[n](v)),done:n==="return"}:f?f(v):v}:f}};__asyncValues=function(o){if(!Symbol.asyncIterator){throw new TypeError("Symbol.asyncIterator is not defined.")}var m=o[Symbol.asyncIterator],i;return m?m.call(o):(o=typeof __values==="function"?__values(o):o[Symbol.iterator](),i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i);function verb(n){i[n]=o[n]&&function(v){return new Promise(function(resolve,reject){v=o[n](v),settle(resolve,reject,v.done,v.value)})}}function settle(resolve,reject,d,v){Promise.resolve(v).then(function(v){resolve({value:v,done:d})},reject)}};__makeTemplateObject=function(cooked,raw){if(Object.defineProperty){Object.defineProperty(cooked,"raw",{value:raw})}else{cooked.raw=raw}return cooked};__importStar=function(mod){if(mod&&mod.__esModule){return mod}var result={};if(mod!=null){for(var k in mod){if(Object.hasOwnProperty.call(mod,k)){result[k]=mod[k]}}}result["default"]=mod;return result};__importDefault=function(mod){return(mod&&mod.__esModule)?mod:{"default":mod}};exporter("__extends",__extends);exporter("__assign",__assign);exporter("__rest",__rest);exporter("__decorate",__decorate);exporter("__param",__param);exporter("__metadata",__metadata);exporter("__awaiter",__awaiter);exporter("__generator",__generator);exporter("__exportStar",__exportStar);exporter("__values",__values);exporter("__read",__read);exporter("__spread",__spread);exporter("__spreadArrays",__spreadArrays);exporter("__await",__await);exporter("__asyncGenerator",__asyncGenerator);exporter("__asyncDelegator",__asyncDelegator);exporter("__asyncValues",__asyncValues);exporter("__makeTemplateObject",__makeTemplateObject);exporter("__importStar",__importStar);exporter("__importDefault",__importDefault)});
var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate: __decorate,__param: __param,__metadata: __metadata,__awaiter: __awaiter,__generator: __generator,__exportStar: __exportStar,__values: __values,__read: __read,__spread: __spread,__spreadArrays: __spreadArrays,__await: __await,__asyncGenerator: __asyncGenerator,__asyncDelegator: __asyncDelegator,__asyncValues: __asyncValues,__makeTemplateObject: __makeTemplateObject,__importStar: __importStar,__importDefault: __importDefault};
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('tslib')) :
typeof define === 'function' && define.amd ? define(['exports', 'tslib'], factory) :
(global = global || self, factory(global.engine = {}, global.tslib));
}(this, function (exports, tslib_1) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('tslib'), require('props-compute')) :
typeof define === 'function' && define.amd ? define(['exports', 'tslib', 'props-compute'], factory) :
(global = global || self, factory(global.engine = {}, global.tslib, global.propsCompute));
}(this, (function (exports, tslib_1, propsCompute) { 'use strict';
var HashObject = (function () {
function HashObject() {
......@@ -63,6 +63,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
s.type = type;
delete s.data;
};
Event.MAYBE_ALIGN = "maybeAlign";
Event.RESIZE = "onResize";
Event.ON_SCROLL_TO_HEAD = "onScrollToHead";
Event.ON_SCROLL_STOP = "onScrollStop";
......@@ -1634,135 +1635,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return MouseEvent;
}(Event));
function applyAutoAdjust(ctor) {
ctor.prototype.applyAutoAdjust = function () {
var adjustProxy = this.adjustProxy = new AdjustProxy(this);
this.addEventListener(Event.ADDED_TO_STAGE, adjustProxy.onAddedToStage, adjustProxy);
this.addEventListener(Event.REMOVED_FROM_STAGE, adjustProxy.onRemovedFromStage, adjustProxy);
};
var temp = new AdjustProxy(null);
var _loop_1 = function (key) {
Object.defineProperty(ctor.prototype, key, {
get: function () {
return this.adjustProxy.data[key];
},
set: function (v) {
var adjustProxy = this.adjustProxy;
if (adjustProxy.data[key] !== v) {
adjustProxy.data[key] = v;
adjustProxy.makeDirty();
}
},
enumerable: true,
configurable: true
});
};
for (var key in temp.data) {
_loop_1(key);
}
}
var AdjustProxy = (function () {
function AdjustProxy(host) {
this.data = {
percentWidth: NaN,
percentHeight: NaN,
left: NaN,
top: NaN,
right: NaN,
bottom: NaN,
horizonCenter: NaN,
verticalCenter: NaN,
};
this._host = host;
this.makeDirty();
}
AdjustProxy.prototype.makeDirty = function () {
this._sizeDirty = true;
};
AdjustProxy.prototype.onAddedToStage = function (e) {
this._host.parent.addEventListener(Event.RESIZE, this.onResize, this);
this._host.addEventListener(Event.RESIZE, this.onResize, this);
this._host.addEventListener(Event.ENTER_FRAME, this.onEnterFrame, this);
};
AdjustProxy.prototype.onRemovedFromStage = function (e) {
this._host.removeEventListener(Event.RESIZE, this.onResize, this);
this._host.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
};
AdjustProxy.prototype.setFrom = function (adjustProxy) {
for (var k in adjustProxy.data) {
this.data[k] = adjustProxy.data[k];
}
};
AdjustProxy.prototype.onResize = function (e) {
this._sizeDirty = true;
};
AdjustProxy.prototype.onEnterFrame = function (e) {
if (this._sizeDirty) {
this._sizeDirty = false;
this.adjustLayout();
}
};
AdjustProxy.prototype.adjustLayout = function () {
var that = this._host;
var _a = that.parent, pWidth = _a.width, pHeight = _a.height;
var width = that.width, height = that.height;
var _b = this.data, percentWidth = _b.percentWidth, percentHeight = _b.percentHeight, left = _b.left, top = _b.top, right = _b.right, bottom = _b.bottom, horizonCenter = _b.horizonCenter, verticalCenter = _b.verticalCenter;
var applyPercentWidth = function () {
if (t(percentWidth)) {
that.width = pWidth * percentWidth / 100;
}
};
var applyPercentHeight = function () {
if (t(percentHeight)) {
that.height = pHeight * percentHeight / 100;
}
};
var pw = true, ph = true;
if (t(horizonCenter)) {
applyPercentWidth();
that.x = (pWidth - that.width) / 2 + horizonCenter;
}
else {
if (t(left)) {
that.x = left;
if (t(right)) {
that.width = pWidth - left - right;
pw = false;
}
}
else if (t(right)) {
that.x = pWidth - width - right;
}
if (pw) {
applyPercentWidth();
}
}
if (t(verticalCenter)) {
applyPercentHeight();
that.y = (pHeight - that.height) / 2 + verticalCenter;
}
else {
if (t(top)) {
that.y = top;
if (t(bottom)) {
that.height = pHeight - top - bottom;
ph = false;
}
}
else if (t(bottom)) {
that.y = pHeight - height - bottom;
}
if (ph) {
applyPercentHeight();
}
}
};
return AdjustProxy;
}());
function t(v) {
return !isNaN(v) && v !== null && v !== undefined;
}
var ESCAPE_REG_EXP = /\$\{[\u4e00-\u9fa5_a-zA-Z0-9\|]+\}/g;
var linkedFlag = '$_linked_$';
var nodeScheme = 'node://';
......@@ -2016,6 +1888,198 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
}
}
function toBoolean(v) {
return !isNaN(v) && v !== null && v !== undefined;
}
var AlignManager = (function () {
function AlignManager() {
this.alignList = [];
}
AlignManager.prototype.flush = function () {
var _this = this;
this.alignList.forEach(function (v) {
_this.autoSize(v);
_this.align(v);
});
this.alignList.forEach(function (v) {
if (v.alignMode === ALIGN_MODE.ONCE) {
v.alignEnabled = false;
}
});
this.alignList.length = 0;
};
AlignManager.prototype.align = function (that) {
var _this = this;
if (!that.alignEnabled)
return;
var percentWidth = that.percentWidth, percentHeight = that.percentHeight, left = that.left, top = that.top, right = that.right, bottom = that.bottom, horizonCenter = that.horizonCenter, verticalCenter = that.verticalCenter;
var _a = that._width, tW_Z = _a === void 0 ? 0 : _a, _b = that._height, tH_Z = _b === void 0 ? 0 : _b;
var _c = (that.parent || {}), _d = _c._width, pW_Z = _d === void 0 ? 0 : _d, _e = _c._height, pH_Z = _e === void 0 ? 0 : _e;
if (toBoolean(left) && toBoolean(right)) {
that.x = left;
that.width = pW_Z - left - right;
}
else {
toBoolean(percentWidth) && (tW_Z = that.width = pW_Z * percentWidth / 100);
if (toBoolean(horizonCenter)) {
that.x = pW_Z / 2 - tW_Z / 2 + horizonCenter;
}
else if (toBoolean(left)) {
that.x = left;
}
else if (toBoolean(right)) {
that.x = pW_Z - right - tW_Z;
}
}
if (toBoolean(top) && toBoolean(bottom)) {
that.y = top;
that.height = pH_Z - top - bottom;
}
else {
toBoolean(percentHeight) && (tH_Z = that.height = pH_Z * percentHeight / 100);
if (toBoolean(verticalCenter)) {
that.y = pH_Z / 2 - tH_Z / 2 + verticalCenter;
}
else if (toBoolean(top)) {
that.y = top;
}
else if (toBoolean(bottom)) {
that.y = pH_Z - bottom - tH_Z;
}
}
that.children.forEach(function (v) { return _this.align(v); });
};
AlignManager.prototype.autoSize = function (that) {
var len = that.children.length;
if (len > 0) {
if (that.autoWidth && !toBoolean(that.right) && !toBoolean(that.percentWidth)) {
var max = 0;
for (var i = 0; i < len; i++) {
if (toBoolean(that.children[i].right))
continue;
var _x = that.children[i].x || 0;
var _w = that.children[i].__width || 0;
if (_x + _w > max) {
max = _x + _w;
}
}
that.width = max;
}
if (that.autoHeight && !toBoolean(that.bottom) && !toBoolean(that.percentHeight)) {
var max = 0;
for (var i = 0; i < len; i++) {
if (toBoolean(that.children[i].bottom))
continue;
var _y = that.children[i].y || 0;
var _h = that.children[i].__height || 0;
if (_y + _h > max) {
max = _y + _h;
}
}
that.height = max;
}
}
};
AlignManager.prototype.addAlign = function (obj) {
if (this.alignList.indexOf(obj) < 0) {
this.alignList.push(obj);
}
};
return AlignManager;
}());
var alignMgr = new AlignManager();
function applyAutoAdjust(ctor) {
ctor.prototype.applyAutoAdjust = function () {
var adjustProxy = this.adjustProxy = new AdjustProxy(this);
this.addEventListener(Event.ADDED_TO_STAGE, adjustProxy.onAddedToStage, adjustProxy);
this.addEventListener(Event.REMOVED_FROM_STAGE, adjustProxy.onRemovedFromStage, adjustProxy);
};
var temp = new AdjustProxy(null);
var _loop_1 = function (key) {
if (key == 'alignMode')
return "continue";
Object.defineProperty(ctor.prototype, key, {
get: function () {
return this.adjustProxy.data[key];
},
set: function (v) {
var adjustProxy = this.adjustProxy;
if (adjustProxy.data[key] !== v && !(isNaN(adjustProxy.data[key]) && isNaN(v))) {
adjustProxy.data[key] = v;
adjustProxy.makeDirty();
}
},
enumerable: true,
configurable: true
});
};
for (var key in temp.data) {
_loop_1(key);
}
Object.defineProperty(ctor.prototype, 'alignMode', {
get: function () {
return this.adjustProxy.data['alignMode'];
},
set: function (v) {
var adjustProxy = this.adjustProxy;
if (adjustProxy.data['alignMode'] !== v) {
adjustProxy.data['alignMode'] = v;
adjustProxy.makeDirty();
if (v == ALIGN_MODE.ALWAYS)
this.alignEnabled = true;
}
},
enumerable: true,
configurable: true
});
}
var ALIGN_MODE;
(function (ALIGN_MODE) {
ALIGN_MODE["ONCE"] = "once";
ALIGN_MODE["ALWAYS"] = "always";
})(ALIGN_MODE || (ALIGN_MODE = {}));
var AdjustProxy = (function () {
function AdjustProxy(host) {
this.data = {
percentWidth: NaN,
percentHeight: NaN,
left: NaN,
top: NaN,
right: NaN,
bottom: NaN,
horizonCenter: NaN,
verticalCenter: NaN,
alignEnabled: true,
alignMode: ALIGN_MODE.ALWAYS,
};
this._host = host;
this.makeDirty();
}
AdjustProxy.prototype.makeDirty = function () {
this._sizeDirty = true;
this._host && alignMgr.addAlign(this._host);
this._host && this._host.parent && this._host.parent.adjustProxy.makeDirty();
};
AdjustProxy.prototype.onAddedToStage = function (e) {
this._host.addEventListener(Event.MAYBE_ALIGN, this.readyAlign, this);
};
AdjustProxy.prototype.onRemovedFromStage = function (e) {
this._host.removeEventListener(Event.MAYBE_ALIGN, this.readyAlign);
};
AdjustProxy.prototype.setFrom = function (adjustProxy) {
for (var k in adjustProxy.data) {
this.data[k] = adjustProxy.data[k];
}
};
AdjustProxy.prototype.readyAlign = function (e) {
this._sizeDirty = true;
this._host && alignMgr.addAlign(this._host);
this._host && this._host.parent && this._host.parent.adjustProxy.makeDirty();
};
return AdjustProxy;
}());
function transPoint(str, sep) {
if (sep === void 0) { sep = ','; }
......@@ -3093,6 +3157,10 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
function Container() {
var _this = _super.call(this) || this;
_this._mouseChildren = true;
_this.__width = 0;
_this.__height = 0;
_this._autoWidth = false;
_this._autoHeight = false;
_this._instanceType = "Container";
_this.children = [];
_this._transform = _this.transform;
......@@ -3113,14 +3181,10 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
Container.prototype.afterConstructor = function () {
};
Container.prototype.onChildrenChange = function (index) {
this.dispatchEvent(Event.MAYBE_ALIGN);
};
Container.prototype.attachVisibility = function () {
return;
this.dispatchEvent(this.worldVisible ? Event.VISIBLE : Event.HIDDEN);
for (var i = 0, li = this.children.length; i < li; i++) {
var child = this.children[i];
child.attachVisibility();
}
};
Container.prototype.addChild = function (child) {
this.addChildAt(child, this.children.length);
......@@ -3516,6 +3580,14 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
this._width = value;
this._localBoundsSelf.width = value;
this.dispatchEvent(Event.RESIZE);
this.dispatchEvent(Event.MAYBE_ALIGN);
}
if (toBoolean(this.percentWidth)
|| (toBoolean(this.left) && toBoolean(this.right))) {
this.__width = 0;
}
else {
this.__width = value;
}
},
enumerable: true,
......@@ -3530,11 +3602,71 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
this._height = value;
this._localBoundsSelf.height = value;
this.dispatchEvent(Event.RESIZE);
this.dispatchEvent(Event.MAYBE_ALIGN);
}
if (toBoolean(this.percentHeight)
|| (toBoolean(this.top) && toBoolean(this.bottom))) {
this.__height = 0;
}
else {
this.__height = value;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(Container.prototype, "autoWidth", {
get: function () {
return this._autoWidth;
},
set: function (autoWidth) {
this._autoWidth = autoWidth;
this.right = NaN;
this.percentWidth = NaN;
this.adjustProxy.makeDirty();
},
enumerable: true,
configurable: true
});
Object.defineProperty(Container.prototype, "autoHeight", {
get: function () {
return this._autoHeight;
},
set: function (autoHeight) {
this._autoHeight = autoHeight;
this.bottom = NaN;
this.percentHeight = NaN;
this.adjustProxy.makeDirty();
},
enumerable: true,
configurable: true
});
Object.defineProperty(Container.prototype, "x", {
get: function () {
return this.position.x;
},
set: function (value) {
if (value == this.transform.position.x)
return;
this.transform.position.x = value;
this.dispatchEvent(Event.MAYBE_ALIGN);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Container.prototype, "y", {
get: function () {
return this.position.y;
},
set: function (value) {
if (value == this.transform.position.y)
return;
this.transform.position.y = value;
this.dispatchEvent(Event.MAYBE_ALIGN);
},
enumerable: true,
configurable: true
});
Container.prototype.clone = function (withEvents, withScripts) {
if (withEvents === void 0) { withEvents = false; }
if (withScripts === void 0) { withScripts = false; }
......@@ -4675,7 +4807,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
function determineCrossOrigin(url, loc) {
if (loc === void 0) { loc = window.location; }
if (url.indexOf('data:') === 0) {
return '';
}
......@@ -5405,7 +5536,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return color;
}
function inputFeildIosEnable() {
var u = navigator.userAgent, app = navigator.appVersion;
var u = navigator.userAgent;
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
if (isIOS) {
setTimeout(function () {
......@@ -5745,9 +5876,17 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return Math.abs(this.scale.x) * this._texture.orig.width;
},
set: function (value) {
value = Math.abs(value);
var s = sign(this.scale.x) || 1;
this.scale.x = s * value / this._texture.orig.width;
this._width = value;
this.dispatchEvent(Event.MAYBE_ALIGN);
if (isNaN(this.percentWidth) || this.percentWidth === null) {
this.__width = value;
}
else {
this.__width = 0;
}
},
enumerable: true,
configurable: true
......@@ -5757,9 +5896,17 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return Math.abs(this.scale.y) * this._texture.orig.height;
},
set: function (value) {
value = Math.abs(value);
var s = sign(this.scale.y) || 1;
this.scale.y = s * value / this._texture.orig.height;
this._height = value;
this.dispatchEvent(Event.MAYBE_ALIGN);
if (isNaN(this.percentHeight) || this.percentHeight === null) {
this.__height = value;
}
else {
this.__height = 0;
}
},
enumerable: true,
configurable: true
......@@ -8331,6 +8478,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
Stage.flushAll = function () {
if (!GlobalPro.startTime)
GlobalPro.startTime = Date.now();
alignMgr.flush();
if (!Stage._pause) {
var len = Stage.allUpdateObjList.length;
for (var i = 0; i < len; i++) {
......@@ -11354,24 +11502,31 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var failedList = [];
return Promise.all(config.map(function (assetConfig) {
assetsConfig.push(assetConfig);
var url = assetConfig.url, ext = assetConfig.ext, uuid = assetConfig.uuid;
var loadFunc = loaderMapping[ext];
if (loadFunc) {
if (url.indexOf(linkScheme) === 0) {
loaded++;
onProgress && onProgress(loaded, total);
return Promise.resolve();
if (assetConfig.url.indexOf(linkScheme) === 0) {
var linkUUID = assetConfig.url.replace(linkScheme, '');
assetConfig = getAssetByUUID(linkUUID);
}
if (assetConfig) {
var url_1 = assetConfig.url, ext = assetConfig.ext, uuid = assetConfig.uuid;
var loadFunc = loaderMapping[ext];
if (loadFunc) {
var method = globalLoader['load' + loadFunc];
return method.call(globalLoader, url_1, uuid).then(function (data) {
parse(assetConfig, data);
loaded++;
onProgress && onProgress(loaded, total);
}, function (error) {
failedList.push(url_1);
});
}
else {
return p();
}
var method = globalLoader['load' + loadFunc];
return method.call(globalLoader, url, uuid).then(function (data) {
parse(assetConfig, data);
loaded++;
onProgress && onProgress(loaded, total);
}, function (error) {
failedList.push(url);
});
}
else {
return p();
}
function p() {
loaded++;
onProgress && onProgress(loaded, total);
return Promise.resolve();
......@@ -17150,10 +17305,14 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
if (playEffect === void 0) { playEffect = true; }
return new Promise(function (resolve) {
var action = 'popAll';
var lastView = _this.getChildAt(0);
var len = _this.childNum;
while (_this.children.length > 1) {
_this.removeChildAt(1);
if (len == 0) {
resolve();
return;
}
var lastView = _this.getChildAt(len);
while (_this.children.length > 2) {
_this.removeChildAt(0);
}
if (_this._mutex) {
_this._stack.splice(0);
......@@ -17162,7 +17321,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
view.visible = false;
_this.addChild(view);
}
var data = { action: action, view: view, lastView: lastView, options: options, hasView: len > 1 };
var data = { action: action, view: view, lastView: lastView, options: options, hasView: false };
_this.dispatchEvent(Event.START, data);
playViewEffect(playEffect ? options ? options.effect : null : null, options ? options.effectParams : {}, _this._mutex, lastView, view, _this, function () {
_this.dispatchEvent(Event.COMPLETE, data);
......@@ -17173,155 +17332,155 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return StackContainer;
}(Node$1));
var colorName = {
"aliceblue": [240, 248, 255],
"antiquewhite": [250, 235, 215],
"aqua": [0, 255, 255],
"aquamarine": [127, 255, 212],
"azure": [240, 255, 255],
"beige": [245, 245, 220],
"bisque": [255, 228, 196],
"black": [0, 0, 0],
"blanchedalmond": [255, 235, 205],
"blue": [0, 0, 255],
"blueviolet": [138, 43, 226],
"brown": [165, 42, 42],
"burlywood": [222, 184, 135],
"cadetblue": [95, 158, 160],
"chartreuse": [127, 255, 0],
"chocolate": [210, 105, 30],
"coral": [255, 127, 80],
"cornflowerblue": [100, 149, 237],
"cornsilk": [255, 248, 220],
"crimson": [220, 20, 60],
"cyan": [0, 255, 255],
"darkblue": [0, 0, 139],
"darkcyan": [0, 139, 139],
"darkgoldenrod": [184, 134, 11],
"darkgray": [169, 169, 169],
"darkgreen": [0, 100, 0],
"darkgrey": [169, 169, 169],
"darkkhaki": [189, 183, 107],
"darkmagenta": [139, 0, 139],
"darkolivegreen": [85, 107, 47],
"darkorange": [255, 140, 0],
"darkorchid": [153, 50, 204],
"darkred": [139, 0, 0],
"darksalmon": [233, 150, 122],
"darkseagreen": [143, 188, 143],
"darkslateblue": [72, 61, 139],
"darkslategray": [47, 79, 79],
"darkslategrey": [47, 79, 79],
"darkturquoise": [0, 206, 209],
"darkviolet": [148, 0, 211],
"deeppink": [255, 20, 147],
"deepskyblue": [0, 191, 255],
"dimgray": [105, 105, 105],
"dimgrey": [105, 105, 105],
"dodgerblue": [30, 144, 255],
"firebrick": [178, 34, 34],
"floralwhite": [255, 250, 240],
"forestgreen": [34, 139, 34],
"fuchsia": [255, 0, 255],
"gainsboro": [220, 220, 220],
"ghostwhite": [248, 248, 255],
"gold": [255, 215, 0],
"goldenrod": [218, 165, 32],
"gray": [128, 128, 128],
"green": [0, 128, 0],
"greenyellow": [173, 255, 47],
"grey": [128, 128, 128],
"honeydew": [240, 255, 240],
"hotpink": [255, 105, 180],
"indianred": [205, 92, 92],
"indigo": [75, 0, 130],
"ivory": [255, 255, 240],
"khaki": [240, 230, 140],
"lavender": [230, 230, 250],
"lavenderblush": [255, 240, 245],
"lawngreen": [124, 252, 0],
"lemonchiffon": [255, 250, 205],
"lightblue": [173, 216, 230],
"lightcoral": [240, 128, 128],
"lightcyan": [224, 255, 255],
"lightgoldenrodyellow": [250, 250, 210],
"lightgray": [211, 211, 211],
"lightgreen": [144, 238, 144],
"lightgrey": [211, 211, 211],
"lightpink": [255, 182, 193],
"lightsalmon": [255, 160, 122],
"lightseagreen": [32, 178, 170],
"lightskyblue": [135, 206, 250],
"lightslategray": [119, 136, 153],
"lightslategrey": [119, 136, 153],
"lightsteelblue": [176, 196, 222],
"lightyellow": [255, 255, 224],
"lime": [0, 255, 0],
"limegreen": [50, 205, 50],
"linen": [250, 240, 230],
"magenta": [255, 0, 255],
"maroon": [128, 0, 0],
"mediumaquamarine": [102, 205, 170],
"mediumblue": [0, 0, 205],
"mediumorchid": [186, 85, 211],
"mediumpurple": [147, 112, 219],
"mediumseagreen": [60, 179, 113],
"mediumslateblue": [123, 104, 238],
"mediumspringgreen": [0, 250, 154],
"mediumturquoise": [72, 209, 204],
"mediumvioletred": [199, 21, 133],
"midnightblue": [25, 25, 112],
"mintcream": [245, 255, 250],
"mistyrose": [255, 228, 225],
"moccasin": [255, 228, 181],
"navajowhite": [255, 222, 173],
"navy": [0, 0, 128],
"oldlace": [253, 245, 230],
"olive": [128, 128, 0],
"olivedrab": [107, 142, 35],
"orange": [255, 165, 0],
"orangered": [255, 69, 0],
"orchid": [218, 112, 214],
"palegoldenrod": [238, 232, 170],
"palegreen": [152, 251, 152],
"paleturquoise": [175, 238, 238],
"palevioletred": [219, 112, 147],
"papayawhip": [255, 239, 213],
"peachpuff": [255, 218, 185],
"peru": [205, 133, 63],
"pink": [255, 192, 203],
"plum": [221, 160, 221],
"powderblue": [176, 224, 230],
"purple": [128, 0, 128],
"rebeccapurple": [102, 51, 153],
"red": [255, 0, 0],
"rosybrown": [188, 143, 143],
"royalblue": [65, 105, 225],
"saddlebrown": [139, 69, 19],
"salmon": [250, 128, 114],
"sandybrown": [244, 164, 96],
"seagreen": [46, 139, 87],
"seashell": [255, 245, 238],
"sienna": [160, 82, 45],
"silver": [192, 192, 192],
"skyblue": [135, 206, 235],
"slateblue": [106, 90, 205],
"slategray": [112, 128, 144],
"slategrey": [112, 128, 144],
"snow": [255, 250, 250],
"springgreen": [0, 255, 127],
"steelblue": [70, 130, 180],
"tan": [210, 180, 140],
"teal": [0, 128, 128],
"thistle": [216, 191, 216],
"tomato": [255, 99, 71],
"turquoise": [64, 224, 208],
"violet": [238, 130, 238],
"wheat": [245, 222, 179],
"white": [255, 255, 255],
"whitesmoke": [245, 245, 245],
"yellow": [255, 255, 0],
"yellowgreen": [154, 205, 50]
var colorName = {
"aliceblue": [240, 248, 255],
"antiquewhite": [250, 235, 215],
"aqua": [0, 255, 255],
"aquamarine": [127, 255, 212],
"azure": [240, 255, 255],
"beige": [245, 245, 220],
"bisque": [255, 228, 196],
"black": [0, 0, 0],
"blanchedalmond": [255, 235, 205],
"blue": [0, 0, 255],
"blueviolet": [138, 43, 226],
"brown": [165, 42, 42],
"burlywood": [222, 184, 135],
"cadetblue": [95, 158, 160],
"chartreuse": [127, 255, 0],
"chocolate": [210, 105, 30],
"coral": [255, 127, 80],
"cornflowerblue": [100, 149, 237],
"cornsilk": [255, 248, 220],
"crimson": [220, 20, 60],
"cyan": [0, 255, 255],
"darkblue": [0, 0, 139],
"darkcyan": [0, 139, 139],
"darkgoldenrod": [184, 134, 11],
"darkgray": [169, 169, 169],
"darkgreen": [0, 100, 0],
"darkgrey": [169, 169, 169],
"darkkhaki": [189, 183, 107],
"darkmagenta": [139, 0, 139],
"darkolivegreen": [85, 107, 47],
"darkorange": [255, 140, 0],
"darkorchid": [153, 50, 204],
"darkred": [139, 0, 0],
"darksalmon": [233, 150, 122],
"darkseagreen": [143, 188, 143],
"darkslateblue": [72, 61, 139],
"darkslategray": [47, 79, 79],
"darkslategrey": [47, 79, 79],
"darkturquoise": [0, 206, 209],
"darkviolet": [148, 0, 211],
"deeppink": [255, 20, 147],
"deepskyblue": [0, 191, 255],
"dimgray": [105, 105, 105],
"dimgrey": [105, 105, 105],
"dodgerblue": [30, 144, 255],
"firebrick": [178, 34, 34],
"floralwhite": [255, 250, 240],
"forestgreen": [34, 139, 34],
"fuchsia": [255, 0, 255],
"gainsboro": [220, 220, 220],
"ghostwhite": [248, 248, 255],
"gold": [255, 215, 0],
"goldenrod": [218, 165, 32],
"gray": [128, 128, 128],
"green": [0, 128, 0],
"greenyellow": [173, 255, 47],
"grey": [128, 128, 128],
"honeydew": [240, 255, 240],
"hotpink": [255, 105, 180],
"indianred": [205, 92, 92],
"indigo": [75, 0, 130],
"ivory": [255, 255, 240],
"khaki": [240, 230, 140],
"lavender": [230, 230, 250],
"lavenderblush": [255, 240, 245],
"lawngreen": [124, 252, 0],
"lemonchiffon": [255, 250, 205],
"lightblue": [173, 216, 230],
"lightcoral": [240, 128, 128],
"lightcyan": [224, 255, 255],
"lightgoldenrodyellow": [250, 250, 210],
"lightgray": [211, 211, 211],
"lightgreen": [144, 238, 144],
"lightgrey": [211, 211, 211],
"lightpink": [255, 182, 193],
"lightsalmon": [255, 160, 122],
"lightseagreen": [32, 178, 170],
"lightskyblue": [135, 206, 250],
"lightslategray": [119, 136, 153],
"lightslategrey": [119, 136, 153],
"lightsteelblue": [176, 196, 222],
"lightyellow": [255, 255, 224],
"lime": [0, 255, 0],
"limegreen": [50, 205, 50],
"linen": [250, 240, 230],
"magenta": [255, 0, 255],
"maroon": [128, 0, 0],
"mediumaquamarine": [102, 205, 170],
"mediumblue": [0, 0, 205],
"mediumorchid": [186, 85, 211],
"mediumpurple": [147, 112, 219],
"mediumseagreen": [60, 179, 113],
"mediumslateblue": [123, 104, 238],
"mediumspringgreen": [0, 250, 154],
"mediumturquoise": [72, 209, 204],
"mediumvioletred": [199, 21, 133],
"midnightblue": [25, 25, 112],
"mintcream": [245, 255, 250],
"mistyrose": [255, 228, 225],
"moccasin": [255, 228, 181],
"navajowhite": [255, 222, 173],
"navy": [0, 0, 128],
"oldlace": [253, 245, 230],
"olive": [128, 128, 0],
"olivedrab": [107, 142, 35],
"orange": [255, 165, 0],
"orangered": [255, 69, 0],
"orchid": [218, 112, 214],
"palegoldenrod": [238, 232, 170],
"palegreen": [152, 251, 152],
"paleturquoise": [175, 238, 238],
"palevioletred": [219, 112, 147],
"papayawhip": [255, 239, 213],
"peachpuff": [255, 218, 185],
"peru": [205, 133, 63],
"pink": [255, 192, 203],
"plum": [221, 160, 221],
"powderblue": [176, 224, 230],
"purple": [128, 0, 128],
"rebeccapurple": [102, 51, 153],
"red": [255, 0, 0],
"rosybrown": [188, 143, 143],
"royalblue": [65, 105, 225],
"saddlebrown": [139, 69, 19],
"salmon": [250, 128, 114],
"sandybrown": [244, 164, 96],
"seagreen": [46, 139, 87],
"seashell": [255, 245, 238],
"sienna": [160, 82, 45],
"silver": [192, 192, 192],
"skyblue": [135, 206, 235],
"slateblue": [106, 90, 205],
"slategray": [112, 128, 144],
"slategrey": [112, 128, 144],
"snow": [255, 250, 250],
"springgreen": [0, 255, 127],
"steelblue": [70, 130, 180],
"tan": [210, 180, 140],
"teal": [0, 128, 128],
"thistle": [216, 191, 216],
"tomato": [255, 99, 71],
"turquoise": [64, 224, 208],
"violet": [238, 130, 238],
"wheat": [245, 222, 179],
"white": [255, 255, 255],
"whitesmoke": [245, 245, 245],
"yellow": [255, 255, 0],
"yellowgreen": [154, 205, 50]
};
var isArrayish = function isArrayish(obj) {
......@@ -17604,155 +17763,155 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var colorString_1 = colorString.to;
var colorString_2 = colorString.get;
var colorName$1 = {
"aliceblue": [240, 248, 255],
"antiquewhite": [250, 235, 215],
"aqua": [0, 255, 255],
"aquamarine": [127, 255, 212],
"azure": [240, 255, 255],
"beige": [245, 245, 220],
"bisque": [255, 228, 196],
"black": [0, 0, 0],
"blanchedalmond": [255, 235, 205],
"blue": [0, 0, 255],
"blueviolet": [138, 43, 226],
"brown": [165, 42, 42],
"burlywood": [222, 184, 135],
"cadetblue": [95, 158, 160],
"chartreuse": [127, 255, 0],
"chocolate": [210, 105, 30],
"coral": [255, 127, 80],
"cornflowerblue": [100, 149, 237],
"cornsilk": [255, 248, 220],
"crimson": [220, 20, 60],
"cyan": [0, 255, 255],
"darkblue": [0, 0, 139],
"darkcyan": [0, 139, 139],
"darkgoldenrod": [184, 134, 11],
"darkgray": [169, 169, 169],
"darkgreen": [0, 100, 0],
"darkgrey": [169, 169, 169],
"darkkhaki": [189, 183, 107],
"darkmagenta": [139, 0, 139],
"darkolivegreen": [85, 107, 47],
"darkorange": [255, 140, 0],
"darkorchid": [153, 50, 204],
"darkred": [139, 0, 0],
"darksalmon": [233, 150, 122],
"darkseagreen": [143, 188, 143],
"darkslateblue": [72, 61, 139],
"darkslategray": [47, 79, 79],
"darkslategrey": [47, 79, 79],
"darkturquoise": [0, 206, 209],
"darkviolet": [148, 0, 211],
"deeppink": [255, 20, 147],
"deepskyblue": [0, 191, 255],
"dimgray": [105, 105, 105],
"dimgrey": [105, 105, 105],
"dodgerblue": [30, 144, 255],
"firebrick": [178, 34, 34],
"floralwhite": [255, 250, 240],
"forestgreen": [34, 139, 34],
"fuchsia": [255, 0, 255],
"gainsboro": [220, 220, 220],
"ghostwhite": [248, 248, 255],
"gold": [255, 215, 0],
"goldenrod": [218, 165, 32],
"gray": [128, 128, 128],
"green": [0, 128, 0],
"greenyellow": [173, 255, 47],
"grey": [128, 128, 128],
"honeydew": [240, 255, 240],
"hotpink": [255, 105, 180],
"indianred": [205, 92, 92],
"indigo": [75, 0, 130],
"ivory": [255, 255, 240],
"khaki": [240, 230, 140],
"lavender": [230, 230, 250],
"lavenderblush": [255, 240, 245],
"lawngreen": [124, 252, 0],
"lemonchiffon": [255, 250, 205],
"lightblue": [173, 216, 230],
"lightcoral": [240, 128, 128],
"lightcyan": [224, 255, 255],
"lightgoldenrodyellow": [250, 250, 210],
"lightgray": [211, 211, 211],
"lightgreen": [144, 238, 144],
"lightgrey": [211, 211, 211],
"lightpink": [255, 182, 193],
"lightsalmon": [255, 160, 122],
"lightseagreen": [32, 178, 170],
"lightskyblue": [135, 206, 250],
"lightslategray": [119, 136, 153],
"lightslategrey": [119, 136, 153],
"lightsteelblue": [176, 196, 222],
"lightyellow": [255, 255, 224],
"lime": [0, 255, 0],
"limegreen": [50, 205, 50],
"linen": [250, 240, 230],
"magenta": [255, 0, 255],
"maroon": [128, 0, 0],
"mediumaquamarine": [102, 205, 170],
"mediumblue": [0, 0, 205],
"mediumorchid": [186, 85, 211],
"mediumpurple": [147, 112, 219],
"mediumseagreen": [60, 179, 113],
"mediumslateblue": [123, 104, 238],
"mediumspringgreen": [0, 250, 154],
"mediumturquoise": [72, 209, 204],
"mediumvioletred": [199, 21, 133],
"midnightblue": [25, 25, 112],
"mintcream": [245, 255, 250],
"mistyrose": [255, 228, 225],
"moccasin": [255, 228, 181],
"navajowhite": [255, 222, 173],
"navy": [0, 0, 128],
"oldlace": [253, 245, 230],
"olive": [128, 128, 0],
"olivedrab": [107, 142, 35],
"orange": [255, 165, 0],
"orangered": [255, 69, 0],
"orchid": [218, 112, 214],
"palegoldenrod": [238, 232, 170],
"palegreen": [152, 251, 152],
"paleturquoise": [175, 238, 238],
"palevioletred": [219, 112, 147],
"papayawhip": [255, 239, 213],
"peachpuff": [255, 218, 185],
"peru": [205, 133, 63],
"pink": [255, 192, 203],
"plum": [221, 160, 221],
"powderblue": [176, 224, 230],
"purple": [128, 0, 128],
"rebeccapurple": [102, 51, 153],
"red": [255, 0, 0],
"rosybrown": [188, 143, 143],
"royalblue": [65, 105, 225],
"saddlebrown": [139, 69, 19],
"salmon": [250, 128, 114],
"sandybrown": [244, 164, 96],
"seagreen": [46, 139, 87],
"seashell": [255, 245, 238],
"sienna": [160, 82, 45],
"silver": [192, 192, 192],
"skyblue": [135, 206, 235],
"slateblue": [106, 90, 205],
"slategray": [112, 128, 144],
"slategrey": [112, 128, 144],
"snow": [255, 250, 250],
"springgreen": [0, 255, 127],
"steelblue": [70, 130, 180],
"tan": [210, 180, 140],
"teal": [0, 128, 128],
"thistle": [216, 191, 216],
"tomato": [255, 99, 71],
"turquoise": [64, 224, 208],
"violet": [238, 130, 238],
"wheat": [245, 222, 179],
"white": [255, 255, 255],
"whitesmoke": [245, 245, 245],
"yellow": [255, 255, 0],
"yellowgreen": [154, 205, 50]
var colorName$1 = {
"aliceblue": [240, 248, 255],
"antiquewhite": [250, 235, 215],
"aqua": [0, 255, 255],
"aquamarine": [127, 255, 212],
"azure": [240, 255, 255],
"beige": [245, 245, 220],
"bisque": [255, 228, 196],
"black": [0, 0, 0],
"blanchedalmond": [255, 235, 205],
"blue": [0, 0, 255],
"blueviolet": [138, 43, 226],
"brown": [165, 42, 42],
"burlywood": [222, 184, 135],
"cadetblue": [95, 158, 160],
"chartreuse": [127, 255, 0],
"chocolate": [210, 105, 30],
"coral": [255, 127, 80],
"cornflowerblue": [100, 149, 237],
"cornsilk": [255, 248, 220],
"crimson": [220, 20, 60],
"cyan": [0, 255, 255],
"darkblue": [0, 0, 139],
"darkcyan": [0, 139, 139],
"darkgoldenrod": [184, 134, 11],
"darkgray": [169, 169, 169],
"darkgreen": [0, 100, 0],
"darkgrey": [169, 169, 169],
"darkkhaki": [189, 183, 107],
"darkmagenta": [139, 0, 139],
"darkolivegreen": [85, 107, 47],
"darkorange": [255, 140, 0],
"darkorchid": [153, 50, 204],
"darkred": [139, 0, 0],
"darksalmon": [233, 150, 122],
"darkseagreen": [143, 188, 143],
"darkslateblue": [72, 61, 139],
"darkslategray": [47, 79, 79],
"darkslategrey": [47, 79, 79],
"darkturquoise": [0, 206, 209],
"darkviolet": [148, 0, 211],
"deeppink": [255, 20, 147],
"deepskyblue": [0, 191, 255],
"dimgray": [105, 105, 105],
"dimgrey": [105, 105, 105],
"dodgerblue": [30, 144, 255],
"firebrick": [178, 34, 34],
"floralwhite": [255, 250, 240],
"forestgreen": [34, 139, 34],
"fuchsia": [255, 0, 255],
"gainsboro": [220, 220, 220],
"ghostwhite": [248, 248, 255],
"gold": [255, 215, 0],
"goldenrod": [218, 165, 32],
"gray": [128, 128, 128],
"green": [0, 128, 0],
"greenyellow": [173, 255, 47],
"grey": [128, 128, 128],
"honeydew": [240, 255, 240],
"hotpink": [255, 105, 180],
"indianred": [205, 92, 92],
"indigo": [75, 0, 130],
"ivory": [255, 255, 240],
"khaki": [240, 230, 140],
"lavender": [230, 230, 250],
"lavenderblush": [255, 240, 245],
"lawngreen": [124, 252, 0],
"lemonchiffon": [255, 250, 205],
"lightblue": [173, 216, 230],
"lightcoral": [240, 128, 128],
"lightcyan": [224, 255, 255],
"lightgoldenrodyellow": [250, 250, 210],
"lightgray": [211, 211, 211],
"lightgreen": [144, 238, 144],
"lightgrey": [211, 211, 211],
"lightpink": [255, 182, 193],
"lightsalmon": [255, 160, 122],
"lightseagreen": [32, 178, 170],
"lightskyblue": [135, 206, 250],
"lightslategray": [119, 136, 153],
"lightslategrey": [119, 136, 153],
"lightsteelblue": [176, 196, 222],
"lightyellow": [255, 255, 224],
"lime": [0, 255, 0],
"limegreen": [50, 205, 50],
"linen": [250, 240, 230],
"magenta": [255, 0, 255],
"maroon": [128, 0, 0],
"mediumaquamarine": [102, 205, 170],
"mediumblue": [0, 0, 205],
"mediumorchid": [186, 85, 211],
"mediumpurple": [147, 112, 219],
"mediumseagreen": [60, 179, 113],
"mediumslateblue": [123, 104, 238],
"mediumspringgreen": [0, 250, 154],
"mediumturquoise": [72, 209, 204],
"mediumvioletred": [199, 21, 133],
"midnightblue": [25, 25, 112],
"mintcream": [245, 255, 250],
"mistyrose": [255, 228, 225],
"moccasin": [255, 228, 181],
"navajowhite": [255, 222, 173],
"navy": [0, 0, 128],
"oldlace": [253, 245, 230],
"olive": [128, 128, 0],
"olivedrab": [107, 142, 35],
"orange": [255, 165, 0],
"orangered": [255, 69, 0],
"orchid": [218, 112, 214],
"palegoldenrod": [238, 232, 170],
"palegreen": [152, 251, 152],
"paleturquoise": [175, 238, 238],
"palevioletred": [219, 112, 147],
"papayawhip": [255, 239, 213],
"peachpuff": [255, 218, 185],
"peru": [205, 133, 63],
"pink": [255, 192, 203],
"plum": [221, 160, 221],
"powderblue": [176, 224, 230],
"purple": [128, 0, 128],
"rebeccapurple": [102, 51, 153],
"red": [255, 0, 0],
"rosybrown": [188, 143, 143],
"royalblue": [65, 105, 225],
"saddlebrown": [139, 69, 19],
"salmon": [250, 128, 114],
"sandybrown": [244, 164, 96],
"seagreen": [46, 139, 87],
"seashell": [255, 245, 238],
"sienna": [160, 82, 45],
"silver": [192, 192, 192],
"skyblue": [135, 206, 235],
"slateblue": [106, 90, 205],
"slategray": [112, 128, 144],
"slategrey": [112, 128, 144],
"snow": [255, 250, 250],
"springgreen": [0, 255, 127],
"steelblue": [70, 130, 180],
"tan": [210, 180, 140],
"teal": [0, 128, 128],
"thistle": [216, 191, 216],
"tomato": [255, 99, 71],
"turquoise": [64, 224, 208],
"violet": [238, 130, 238],
"wheat": [245, 222, 179],
"white": [255, 255, 255],
"whitesmoke": [245, 245, 245],
"yellow": [255, 255, 0],
"yellowgreen": [154, 205, 50]
};
var conversions = createCommonjsModule(function (module) {
......@@ -20885,9 +21044,9 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return sendData();
};
}
function accessLog(pagebizid, params) {
function accessLog(pageBizId, params) {
var p = {
pagebizid: pagebizid,
pageBizId: pageBizId,
};
injectProp(p, params);
return httpRequest('buriedPoint', 'get', p);
......@@ -20999,30 +21158,22 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
});
GameStage.prototype.launch = function (config, onPreloadAssetsProgress, onPreloadAssetsComplete, onStart) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
function p() {
loaded++;
onPreloadAssetsProgress && onPreloadAssetsProgress(loaded, total);
if (loaded >= total) {
onPreloadAssetsComplete && onPreloadAssetsComplete();
}
}
var assets, customs, loaded, assetsToLoad, total;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
var _a, env, dataMapping, processes, builtinProcesses, customs;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
this._config = config;
assets = config.assets, customs = config.customs;
loaded = 0;
assetsToLoad = assets;
if (!Array.isArray(assets)) {
assetsToLoad = assets['common'];
_a = this._config, env = _a.options.env, dataMapping = _a.dataMapping, processes = _a.processes, builtinProcesses = _a.builtinProcesses, customs = _a.customs;
Stage.addUpdateObj(Tween);
injectEnv(env);
registerCustomModules(customs);
if (dataMapping) {
this.dataCenter.registerDataMapping(dataMapping);
}
total = assetsToLoad.length;
return [4, loadAssets(assetsToLoad, p).catch(function (e) {
console.log(e);
})];
setProcessMetaLibs(processes, builtinProcesses);
return [4, this.loadPreloadAssets(onPreloadAssetsProgress, onPreloadAssetsComplete)];
case 1:
_a.sent();
_b.sent();
this.start();
dealPxEnv();
dealPageRemainTime();
......@@ -21035,14 +21186,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
};
GameStage.prototype.start = function () {
var _this = this;
var _a = this._config, _b = _a.options, entrySceneView = _b.entrySceneView, env = _b.env, dataMapping = _a.dataMapping, processes = _a.processes, builtinProcesses = _a.builtinProcesses, scripts = _a.scripts, customs = _a.customs;
Stage.addUpdateObj(Tween);
injectEnv(env);
registerCustomModules(customs);
if (dataMapping) {
this.dataCenter.registerDataMapping(dataMapping);
}
setProcessMetaLibs(processes, builtinProcesses);
var entrySceneView = this._config.options.entrySceneView;
setTimeout(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var sceneEntry;
return tslib_1.__generator(this, function (_a) {
......@@ -21119,6 +21263,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
groups[viewConfig.uuid] = depAssets;
}
}
if (!(Object.keys(groups).length > 0)) return [3, 2];
return [4, loadAssetsGroups(groups, function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
......@@ -21206,6 +21351,58 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
};
GameStage.prototype.onPopupContainerComplete = function (e) {
};
GameStage.prototype.loadPreloadAssets = function (onPreloadAssetsProgress, onPreloadAssetsComplete) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
function p() {
loaded++;
onPreloadAssetsProgress && onPreloadAssetsProgress(loaded, total);
if (loaded >= total) {
onPreloadAssetsComplete && onPreloadAssetsComplete();
}
}
var assets, loaded, assetsToLoad, total;
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
assets = this._config.assets;
loaded = 0;
assetsToLoad = assets;
if (!!Array.isArray(assets)) return [3, 4];
assetsToLoad = assets['common'];
if (!(assetsToLoad.length > 0)) return [3, 3];
return [4, this.showInnerLoadingView()];
case 1:
_a.sent();
return [4, loadAssetsGroups({
preload: assetsToLoad,
}, function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
return [2];
});
}); }, function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
this.hideInnerLoadingView();
return [2];
});
}); })];
case 2:
_a.sent();
_a.label = 3;
case 3: return [3, 6];
case 4:
total = assetsToLoad.length;
return [4, loadAssets(assetsToLoad, p).catch(function (e) {
console.log(e);
})];
case 5:
_a.sent();
_a.label = 6;
case 6: return [2];
}
});
});
};
return GameStage;
}(Node$1));
......@@ -21293,6 +21490,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
}
var alignManager = alignMgr;
function launch(url, loadingDelegate, onStart) {
if (queryParams.__proxy_mode__) {
return Promise.resolve('cancel launch');
......@@ -21358,101 +21556,14 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
};
/**
* Created by rockyl on 2020-01-27.
*/
var genericRegexp = /(\w+)(<(\w+)>)?/;
function compute(props, options) {
var result = props || {};
var _loop_1 = function (key) {
var sourceValue = getValue(result, options, key);
var value = sourceValue;
if (options) {
var option = options[key];
if (option && option.type) {
var _a = parseType(option.type), type = _a.type, generic_1 = _a.generic;
switch (type) {
case 'vector2':
value = parseVector2(sourceValue);
break;
case 'array':
var seps = sourceValue.split(',');
seps = seps.map(function (sep) {
var item;
if (generic_1) {
switch (generic_1) {
case 'number':
item = parseFloat(sep);
break;
case 'boolean':
item = sep === 'true';
break;
default:
item = sep;
break;
}
}
else {
item = sep;
}
return item;
});
value = seps;
break;
}
}
}
result[key] = value;
};
for (var key in options) {
_loop_1(key);
}
return result;
}
function parseType(typeStr) {
var type = typeStr, generic;
var regResult = typeStr.match(genericRegexp);
if (regResult) {
type = regResult[1];
generic = regResult[3];
}
return {
type: type, generic: generic,
};
}
function parseVector2(sourceValue) {
var value = sourceValue;
if (!sourceValue) {
value = { x: undefined, y: undefined };
}
if (typeof sourceValue === 'string') {
var arr = sourceValue.split(',');
value = {
x: arr[0] === '' ? undefined : parseFloat(arr[0]),
y: arr[1] === '' ? undefined : parseFloat(arr[1]),
};
}
else if (Array.isArray(sourceValue)) {
value = {
x: sourceValue[0] === '' ? undefined : parseFloat(sourceValue[0]),
y: sourceValue[1] === '' ? undefined : parseFloat(sourceValue[1]),
};
}
return value;
}
function getValue(props, options, key) {
var value;
if (props.hasOwnProperty(key)) {
value = props[key];
}
else if (options && options[key].hasOwnProperty('default')) {
value = options[key].default;
}
return value;
}
var emojiRegexp = emojiRegex();
Object.defineProperty(exports, 'computeProps', {
enumerable: true,
get: function () {
return propsCompute.compute;
}
});
exports.BaseTexture = BaseTexture;
exports.BaseTextureCache = BaseTextureCache;
exports.BitmapText = BitmapText;
......@@ -21517,6 +21628,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
exports.abs = abs;
exports.accessLog = accessLog;
exports.addCustomModule = addCustomModule;
exports.alignManager = alignManager;
exports.appendScript = appendScript;
exports.applyEvents = applyEvents;
exports.applyScript = applyScript;
......@@ -21527,7 +21639,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
exports.clearTextureCache = clearTextureCache;
exports.cmdOldPrefix = cmdOldPrefix;
exports.cmdPrefix = cmdPrefix;
exports.computeProps = compute;
exports.copyProp = copyProp;
exports.cos = cos;
exports.countTrailingZeros = countTrailingZeros;
......@@ -21633,6 +21744,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
exports.strLen = strLen;
exports.strShort = strShort;
exports.string2hex = string2hex;
exports.toBoolean = toBoolean;
exports.toDisplayDataURL = toDisplayDataURL;
exports.transPoint = transPoint;
exports.traverseViewNode = traverseViewNode;
......@@ -21642,5 +21754,5 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
Object.defineProperty(exports, '__esModule', { value: true });
}));
})));
//# sourceMappingURL=engine.js.map
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -26,10 +26,10 @@ export default {
},
],
plugins: [
progress(),
// progress(),
resolve({}),
typescript({
//useTsconfigDeclarationDir: true,
// useTsconfigDeclarationDir: true,
}),
commonjs(),
process.env.BUILD === 'production' && uglify({})
......
import {DisplayObject} from './DisplayObject';
import {Rectangle} from "../math/Rectangle";
import {Point} from '../math/index';
import { DisplayObject } from './DisplayObject';
import { Rectangle } from "../math/Rectangle";
import { Point } from '../math/index';
import CanvasRenderer from '../renderers/CanvasRenderer';
import {Event} from "../events/Event"
import {WebglRenderer} from '../renderers/WebglRenderer';
import {applyAutoAdjust} from "../../zeroing/decorators/auto-adjust";
import {applyScript} from "../../zeroing/decorators/scripts";
import {applyEvents} from "../../zeroing/decorators/events";
import {afterConstructor} from "../../zeroing/decorators/after-constructor";
import {injectProperties, instantiateScript} from "../../zeroing/utils/index";
import {isUI} from "../../zeroing/game-warpper/nodes/IUIComponent";
import { Event } from "../events/Event"
import { WebglRenderer } from '../renderers/WebglRenderer';
import { applyAutoAdjust } from "../../zeroing/decorators/auto-adjust";
import { applyScript } from "../../zeroing/decorators/scripts";
import { applyEvents } from "../../zeroing/decorators/events";
import { afterConstructor } from "../../zeroing/decorators/after-constructor";
import { injectProperties, instantiateScript, toBoolean } from "../../zeroing/utils/index";
import { isUI } from "../../zeroing/game-warpper/nodes/IUIComponent";
import Transform from "../math/Transform";
/**
......@@ -23,811 +23,885 @@ import Transform from "../math/Transform";
@applyScript
@applyEvents
export default class Container extends DisplayObject {
percentWidth: number;
percentHeight: number;
left: number;
top: number;
right: number;
bottom: number;
horizonCenter: number;
verticalCenter: number;
private _transform: Transform;
private _lastLocalID;
/**
* 为false鼠标事件不再向下传递
*/
_mouseChildren: boolean = true;
/**
* 孩子们
* @member {DisplayObject[]}
* @readonly
*/
children: any[];
/**
* 特殊用处
* 缓存的Container的updateTransform
*/
containerUpdateTransform;
constructor() {
super();
this._instanceType = "Container";
this.children = [];
this._transform = this.transform;
this.afterConstructor();
}
get mouseChildren() {
return this._mouseChildren;
}
set mouseChildren(v) {
this._mouseChildren = v;
}
afterConstructor() {
}
/**
* children改变时
* @private
*/
onChildrenChange(index) {
/* empty */
//子类需要时重写
}
attachVisibility() {
return;
this.dispatchEvent(this.worldVisible ? Event.VISIBLE : Event.HIDDEN);
for (let i = 0, li = this.children.length; i < li; i++) {
const child = <Container>this.children[i];
child.attachVisibility();
}
}
/**
* 添加child
* @param {DisplayObject} child
* @return {DisplayObject}
*/
addChild(child: DisplayObject): DisplayObject {
//默认添加在最顶层
this.addChildAt(child, this.children.length);
return child;
}
/**
* 在相应index处添加child
* @param {DisplayObject} child - The child to add
* @param {number} index - The index to place the child in
* @return {DisplayObject} The child that was added.
*/
addChildAt(child: DisplayObject, index: number): DisplayObject {
if (!child) return;
let s = this;
let sameParent = (s == child.parent);
let len: number;
if (child.parent) {
if (!sameParent) {
child.parent.removeChild(child);
} else {
len = s.children.length;
for (let i = 0; i < len; i++) {
if (s.children[i] == child) {
s.children.splice(i, 1);
break;
}
}
}
}
child.parent = s;
//保证child的transform会被更新
child.transform._parentID = -1;
//确保包围盒重新计算
this._boundsID++;
len = s.children.length;
if (index >= len) {
s.children[s.children.length] = child;
index = len;
} else if (index == 0 || index < 0) {
s.children.unshift(child);
index = 0;
} else {
s.children.splice(index, 0, child);
}
if (s.stage && !sameParent) {
// child["_cp"] = true;
child._onDispatchBubbledEvent(Event.ADDED_TO_STAGE);
}
this.onChildrenChange(index);
return child;
}
/**
* 只用于交换索引
* @param {DisplayObject} child - First display object to swap
* @param {DisplayObject} child2 - Second display object to swap
*/
swapChildren(child1: DisplayObject, child2: DisplayObject) {
if (child1 === child2) {
return;
}
let s = this;
let id1 = -1;
let id2 = -1;
let childCount = s.children.length;
if (typeof (child1) == "number") {
id1 = child1;
} else {
id1 = s.getChildIndex(child1);
}
if (typeof (child2) == "number") {
id2 = child2;
} else {
id2 = s.getChildIndex(child2);
}
if (id1 == id2 || id1 < 0 || id1 >= childCount || id2 < 0 || id2 >= childCount) {
return false;
} else {
let temp: any = s.children[id1];
s.children[id1] = s.children[id2];
s.children[id2] = temp;
this.onChildrenChange(id1 < id2 ? id1 : id2);
return true;
}
}
/**
* 获取child的层级索引index
* @param {DisplayObject} child - The DisplayObject instance to identify
* @return {number} The index position of the child display object to identify
*/
getChildIndex(child: DisplayObject): number {
const index = this.children.indexOf(child);
if (index === -1) {
return null
}
return index;
}
/**
* 是否含有child
* @param child
*/
contains(child: DisplayObject): boolean {
return !!this.getChildIndex(child);
}
/**
* 设置child的层级
* @param {DisplayObject} child
* @param {number} index
*/
setChildIndex(child: DisplayObject, index: number) {
this.addChildAt(child, index);
}
/**
* Returns the child at the specified index
* @param {number} index - The index to get the child at
* @return {DisplayObject} The child at the given index, if any.
*/
getChildAt(index: number): DisplayObject {
if (index < 0 || index >= this.children.length) {
return null
}
return this.children[index];
}
/**
* 根据路径获取子节点
* @param path
* @param method
*/
getChildByPath(path: any, method: string): DisplayObject {
if (!path) {
return null;
}
let p = this;
while (path.length > 0) {
let segment = path.shift();
p = p[method](segment);
if (!p) {
break;
}
}
return p;
}
/**
* 根据名称路径获取子节点
* @param path
*/
getChildByNamePath(path: string): DisplayObject {
const pathArr = path.split('/');
return this.getChildByPath(pathArr, 'getChildByName');
}
/**
* 根据索引路径获取子节点
* @param path
*/
getChildByIndexPath(path: string): DisplayObject {
const pathArr = path.split('/').map(seg => parseInt(seg));
return this.getChildByPath(pathArr, 'getChildAt');
}
/**
* 根据uuid搜索子节点
* @param uuid
*/
findChildByUUID(uuid: string) {
if (this['uuid'] === uuid) {
return this;
}
if (this.children && this.children.length > 0) {
for (let child of this.children) {
if (child.findChildByUUID) {
let target = child.findChildByUUID(uuid);
if (target) {
return target;
}
}
}
}
}
/**
* 通过名字获取子级
* @param name
* @param isOnlyOne
* @param isRecursive
*/
public getChildByName(name: string | RegExp, isOnlyOne: boolean = true, isRecursive: boolean = false): any {
if (!name) return null;
let s = this;
let rex: any;
if (typeof (name) == "string") {
rex = new RegExp("^" + name + "$");
} else {
rex = name;
}
let elements: Array<DisplayObject> = [];
Container._getElementsByName(rex, s, isOnlyOne, isRecursive, elements);
let len = elements.length;
if (len == 0) {
return null;
} else if (len == 1) {
return elements[0];
} else {
return elements;
}
}
/**
* 移除child
* @param {DisplayObject} child
* @return {DisplayObject}
*/
removeChild(child: DisplayObject): DisplayObject {
const index = this.children.indexOf(child);
if (index === -1) return null;
this.removeChildAt(index);
return child;
}
/**
* 在index处移除child
* @param {number} index - The index to get the child from
* @return {DisplayObject} The child that was removed.
*/
removeChildAt(index: number): DisplayObject {
let s = this;
let child: any;
let len = s.children.length - 1;
if (len < 0) return;
if (index == len) {
child = s.children.pop();
} else if (index == 0) {
child = s.children.shift();
} else {
child = s.children.splice(index, 1)[0];
}
child._onDispatchBubbledEvent(Event.REMOVED_FROM_STAGE);
//保证子级会被更新
child.parent = null;
child.transform._parentID = -1;
//保证包围盒重新计算
this._boundsID++;
this.onChildrenChange(index);
return child;
}
/**
* 通过索引批量移除child
* @param {number} [beginIndex=0]
* @param {number} [endIndex=this.children.length]
* @returns {DisplayObject[]} List of removed children
*/
removeChildren(beginIndex: number = 0, endIndex: number = this.children.length): DisplayObject[] {
const begin = beginIndex;
const end = typeof endIndex === 'number' ? endIndex : this.children.length;
const range = end - begin;
let removed;
if (range > 0 && range <= end) {
removed = this.children.splice(begin, range);
for (let i = 0; i < removed.length; ++i) {
removed[i].parent = null;
if (removed[i].transform) {
removed[i].transform._parentID = -1;
}
}
this._boundsID++;
this.onChildrenChange(beginIndex);
for (let i = 0; i < removed.length; ++i) {
removed[i]._onDispatchBubbledEvent(Event.REMOVED_FROM_STAGE);
}
return removed;
} else if (range === 0 && this.children.length === 0) {
return [];
}
throw new RangeError('removeChildren: numeric values are outside the acceptable range.');
}
/**
* 更新矩阵
*/
updateTransform() {
//自己先算
super.updateTransform();
//考虑是否要加,
this._boundsID++;
//children遍历计算
for (let i = 0, j = this.children.length; i < j; ++i) {
const child = this.children[i];
if (child.visible) {
child.updateTransform();
}
}
/*if(this._transform === this.transform && isUI(this) && this._lastLocalID !== this.transform.localID){
this._lastLocalID = this.transform.localID;
//console.log(this.name, this.instanceId , 'dirty!');
this.stage.layoutInvalid = true;
}*/
}
/**
* 父类重写
* 都是全局的
*/
calculateBounds() {
if (this._lastBoundsID == this._boundsID) return
this._lastBoundsID = this._boundsID
this._bounds.clear();
//算自己的
this._calculateBounds();
for (let i = 0; i < this.children.length; i++) {
const child = this.children[i];
if (!child.visible || !child.renderable) {
continue;
}
child.calculateBounds();
if (child.$mask) {
child.$mask.calculateBounds();
//取交集矩形
if (child._bounds.x < child.$mask._bounds.x) {
child._bounds.x = child.$mask._bounds.x;
}
if (child._bounds.y < child.$mask._bounds.y) {
child._bounds.y = child.$mask._bounds.y;
}
if (child._bounds.width > child.$mask._bounds.width) {
child._bounds.width = child.$mask._bounds.width;
}
if (child._bounds.height > child.$mask._bounds.height) {
child._bounds.height = child.$mask._bounds.height;
}
Rectangle.createFromRects(this._bounds, child._bounds);
} else {
Rectangle.createFromRects(this._bounds, child._bounds);
}
}
}
/**
* 加"_"的方法基本是为了自己特殊处理
*/
protected _calculateBounds() {
//子类自己重写
//let wp = this.worldMatrix.transformPoint(this.x, this.y);
let widthSetted = !!this._width && this._width !== 0;
let heightSetted = !!this._height && this._height !== 0;
/*if (widthSetted) {
this._bounds.x = this.x;
this._bounds.width = this._width;
}
if (heightSetted) {
this._bounds.y = this.y;
this._bounds.height = this._height;
}*/
if(widthSetted || heightSetted){
const rect = this._localBoundsSelf;
var matrix = this.transform.worldMatrix;
matrix.transformPoint(rect.x, rect.y, DisplayObject._p1);
matrix.transformPoint(rect.x + rect.width, rect.y, DisplayObject._p2);
matrix.transformPoint(rect.x + rect.width, rect.y + rect.height, DisplayObject._p3);
matrix.transformPoint(rect.x, rect.y + rect.height, DisplayObject._p4);
Rectangle.createFromPoints(this._bounds, DisplayObject._p1, DisplayObject._p2, DisplayObject._p3, DisplayObject._p4);
}
}
/**
* 检测点是否在任何child上
* 重写父类方法
*/
hitTestPoint(globalPoint: Point, isMouseEvent: boolean = false) {
//如果不可见
if (!this.visible) return null
//如果禁止子级的鼠标事件
if (isMouseEvent && !this.mouseChildren){
return this.hitTestSelf(globalPoint);
}
var children = this.children;
var length = children.length;
let child, hitDisplayObject;
//后序遍历,后添加的在上层
for (var i = length - 1; i >= 0; i--) {
child = children[i];
//当作遮罩的不作为检测,跳过
if (child.isUsedToMask) continue;
//有遮罩,但是不在遮罩内,跳过
if (child.mask && !child.mask.hitTestPoint(globalPoint, isMouseEvent)) continue;
//检测
hitDisplayObject = child.hitTestPoint(globalPoint, isMouseEvent);
//存在直接返回
if (hitDisplayObject) return hitDisplayObject;
}
return this.displayObjectHitTestPoint(globalPoint, isMouseEvent);
}
hitTestSelf(globalPoint) {
if (this.mouseEnabled) {
return this.hitTestSelfBounds(globalPoint);
}
return null;
}
hitTestSelfBounds(globalPoint) {
if (this._width && this._height) {
//let {x: tx, y: ty} = this.getBounds();
let {tx, ty} = this.worldMatrix;
const {x, y} = globalPoint;
if (x > tx &&
x < tx + this.width &&
y > ty &&
y < ty + this.height
) return this;
}
return null
}
/**
* webgl渲染
* @param {WebglRenderer} renderer - The renderer
*/
renderWebGL(renderer: WebglRenderer) {
//不可见,全局透明度为0,或者 不渲染,直接return
if (!this.visible || this.worldAlpha <= 0 || !this.renderable) {
return;
}
//是否有遮罩。到时如果有滤镜,
if (this.mask) {
this.renderAdvancedWebGL(renderer);
} else {
//自身先渲染
this._renderWebGL(renderer);
//遍历children
for (let i = 0, j = this.children.length; i < j; ++i) {
this.children[i].renderWebGL(renderer);
}
}
}
/**
* 高级渲染方法
*
* @private
* @param {WebGLRenderer} renderer - The renderer
*/
private renderAdvancedWebGL(renderer: WebglRenderer) {
//之前的批处理刷掉先
renderer.batchManager.flush();
//有滤镜再说
const mask = this.mask;
if (mask) {
//先画遮罩
renderer.maskManager.pushMask(this, this.mask);
}
//渲染自身
this._renderWebGL(renderer);
//遍历children
for (let i = 0, j = this.children.length; i < j; i++) {
this.children[i].renderWebGL(renderer);
}
//刷掉批处理
renderer.batchManager.flush();
if (mask) {
//移除遮罩,支持多重遮罩
renderer.maskManager.popMask(this, this.mask);
}
}
/**
* 自身渲染方式
* @private
* @param {WebglRenderer} renderer - The renderer
*/
protected _renderWebGL(renderer: WebglRenderer) {
//自身绘制方法
}
/**
* canvas渲染方式
* @param {CanvasRenderer} renderer - The renderer
*/
renderCanvas(renderer: CanvasRenderer) {
if (!this.visible || this.worldAlpha <= 0 || !this.renderable) {
return;
}
if (this.mask) {
renderer.maskManager.pushMask(this.mask);
}
this._renderCanvas(renderer);
for (let i = 0, j = this.children.length; i < j; ++i) {
this.children[i].renderCanvas(renderer);
}
if (this.mask) {
renderer.maskManager.popMask(renderer);
}
}
/**
* 自身渲染方法
*
* @private
* @param {CanvasRenderer} renderer - The renderer
*/
protected _renderCanvas(renderer: CanvasRenderer) {
//自身绘制方法
}
/**
* 更新方法
*/
update(deltaTime: number) {
/*if (!this.visible) return;*/
//更新自己的
super.update(deltaTime)
//更新儿子们的
let len = this.children.length;
for (let i = len - 1; i >= 0; i--) {
const child = this.children[i];
/*if (child.visible)*/
child.update(deltaTime);
}
}
/**
* 调用此方法对自己及其child触发一次指定事件
* @method _onDispatchBubbledEvent
* @public
* @param {string} type
* @since 1.0.0
*/
public _onDispatchBubbledEvent(type: string): void {
let s = this;
let len = s.children.length;
if (type == Event.REMOVED_FROM_STAGE && !s.stage) return;
super._onDispatchBubbledEvent(type);
for (let i = 0; i < len; i++) {
s.children[i]._onDispatchBubbledEvent(type);
}
}
/**
*
*/
destroy() {
let s = this;
//让子级也destroy
for (let i = s.children.length - 1; i >= 0; i--) {
s.children[i].destroy();
}
super.destroy();
this.mouseChildren = false;
}
/**
* 一般用于获取宽高并设置
* 包括子级的,容器的尽量少用,子类可重写
* @member {number}
*/
get width(): number {
return this._width || this.scale.x * this.getLocalBounds().width;
}
set width(value: number) {
// const width = this.getLocalBounds().width;
// if (width !== 0) {
// this.scale.x = value / width;
// } else {
// this.scale.x = 1;
// }
if (this._width !== value) {
//子类有用,有_width,才需设置scaleX
this._width = value;
this._localBoundsSelf.width = value;
//if (this.stage) this.stage.layoutInvalid = true;
this.dispatchEvent(Event.RESIZE);
}
}
/**
* 高度同width
* @member {number}
*/
get height(): number {
return this._height || this.scale.y * this.getLocalBounds().height;
}
set height(value: number) {
// const height = this.getLocalBounds().height;
// if (height !== 0) {
// this.scale.y = value / height;
// } else {
// this.scale.y = 1;
// }
if (this._height !== value) {
this._height = value;
this._localBoundsSelf.height = value;
//if (this.stage) this.stage.layoutInvalid = true;
this.dispatchEvent(Event.RESIZE);
}
}
clone(withEvents = false, withScripts = false) {
let target = this.constructor.apply(Object.create(this.constructor.prototype));
const originConfig = this['__originConfig'];
const {name, properties, events, scripts} = originConfig;
target.name = name;
target['__originConfig'] = originConfig;
injectProperties(target, properties);
if (withScripts) {
if (scripts && scripts.length > 0) {
for (let scriptConfig of scripts) {
instantiateScript(target, scriptConfig);
}
}
}
if (withEvents) {
if (events) {
target.eventsProxy.start(events);
}
}
for (let child of this.children) {
let childCopy = child.clone(withEvents, withScripts);
target.addChild(childCopy);
}
return target;
}
get $store() {
let p = this;
do {
if (p['$isViewRoot']) {
break;
}
p = p.parent;
}
while (p.parent);
if (p) {
return p['$_store'];
}
}
//全局遍历
/**
* @method _getElementsByName
* @param {RegExp} rex
* @param {Container} root
* @param {boolean} isOnlyOne
* @param {boolean} isRecursive
* @param {Array<DisplayObject>} resultList
* @private
* @static
*/
private static _getElementsByName(rex: RegExp, root: Container, isOnlyOne: boolean, isRecursive: boolean, resultList: Array<DisplayObject>): void {
let len = root.children.length;
if (len > 0) {
let name: string;
let child: any;
for (let i = 0; i < len; i++) {
child = root.children[i];
name = child.name;
if (name && name != "") {
if (rex.test(name)) {
resultList[resultList.length] = child;
if (isOnlyOne) {
return;
}
}
}
if (isRecursive) {
if (child["children"] != null) {
Container._getElementsByName(rex, child, isOnlyOne, isRecursive, resultList);
}
}
}
}
}
percentWidth: number;
percentHeight: number;
left: number;
top: number;
right: number;
bottom: number;
horizonCenter: number;
verticalCenter: number;
private _transform: Transform;
private _lastLocalID;
/**
* 为false鼠标事件不再向下传递
*/
_mouseChildren: boolean = true;
/**
* 孩子们
* @member {DisplayObject[]}
* @readonly
*/
children: any[];
/**
* 特殊用处
* 缓存的Container的updateTransform
*/
containerUpdateTransform;
constructor() {
super();
this._instanceType = "Container";
this.children = [];
this._transform = this.transform;
this.afterConstructor();
}
get mouseChildren() {
return this._mouseChildren;
}
set mouseChildren(v) {
this._mouseChildren = v;
}
afterConstructor() {
}
/**
* children改变时
* @private
*/
onChildrenChange(index) {
/* empty */
//子类需要时重写
this.dispatchEvent(Event.MAYBE_ALIGN);
}
attachVisibility() {
return;
this.dispatchEvent(this.worldVisible ? Event.VISIBLE : Event.HIDDEN);
for(let i = 0, li = this.children.length; i < li; i++) {
const child = <Container>this.children[i];
child.attachVisibility();
}
}
/**
* 添加child
* @param {DisplayObject} child
* @return {DisplayObject}
*/
addChild(child: DisplayObject): DisplayObject {
//默认添加在最顶层
this.addChildAt(child, this.children.length);
return child;
}
/**
* 在相应index处添加child
* @param {DisplayObject} child - The child to add
* @param {number} index - The index to place the child in
* @return {DisplayObject} The child that was added.
*/
addChildAt(child: DisplayObject, index: number): DisplayObject {
if(!child) return;
let s = this;
let sameParent = (s == child.parent);
let len: number;
if(child.parent) {
if(!sameParent) {
child.parent.removeChild(child);
} else {
len = s.children.length;
for(let i = 0; i < len; i++) {
if(s.children[i] == child) {
s.children.splice(i, 1);
break;
}
}
}
}
child.parent = s;
//保证child的transform会被更新
child.transform._parentID = -1;
//确保包围盒重新计算
this._boundsID++;
len = s.children.length;
if(index >= len) {
s.children[s.children.length] = child;
index = len;
} else if(index == 0 || index < 0) {
s.children.unshift(child);
index = 0;
} else {
s.children.splice(index, 0, child);
}
if(s.stage && !sameParent) {
// child["_cp"] = true;
child._onDispatchBubbledEvent(Event.ADDED_TO_STAGE);
}
this.onChildrenChange(index);
return child;
}
/**
* 只用于交换索引
* @param {DisplayObject} child - First display object to swap
* @param {DisplayObject} child2 - Second display object to swap
*/
swapChildren(child1: DisplayObject, child2: DisplayObject) {
if(child1 === child2) {
return;
}
let s = this;
let id1 = -1;
let id2 = -1;
let childCount = s.children.length;
if(typeof (child1) == "number") {
id1 = child1;
} else {
id1 = s.getChildIndex(child1);
}
if(typeof (child2) == "number") {
id2 = child2;
} else {
id2 = s.getChildIndex(child2);
}
if(id1 == id2 || id1 < 0 || id1 >= childCount || id2 < 0 || id2 >= childCount) {
return false;
} else {
let temp: any = s.children[id1];
s.children[id1] = s.children[id2];
s.children[id2] = temp;
this.onChildrenChange(id1 < id2 ? id1 : id2);
return true;
}
}
/**
* 获取child的层级索引index
* @param {DisplayObject} child - The DisplayObject instance to identify
* @return {number} The index position of the child display object to identify
*/
getChildIndex(child: DisplayObject): number {
const index = this.children.indexOf(child);
if(index === -1) {
return null
}
return index;
}
/**
* 是否含有child
* @param child
*/
contains(child: DisplayObject): boolean {
return !!this.getChildIndex(child);
}
/**
* 设置child的层级
* @param {DisplayObject} child
* @param {number} index
*/
setChildIndex(child: DisplayObject, index: number) {
this.addChildAt(child, index);
}
/**
* Returns the child at the specified index
* @param {number} index - The index to get the child at
* @return {DisplayObject} The child at the given index, if any.
*/
getChildAt(index: number): DisplayObject {
if(index < 0 || index >= this.children.length) {
return null
}
return this.children[index];
}
/**
* 根据路径获取子节点
* @param path
* @param method
*/
getChildByPath(path: any, method: string): DisplayObject {
if(!path) {
return null;
}
let p = this;
while(path.length > 0) {
let segment = path.shift();
p = p[method](segment);
if(!p) {
break;
}
}
return p;
}
/**
* 根据名称路径获取子节点
* @param path
*/
getChildByNamePath(path: string): DisplayObject {
const pathArr = path.split('/');
return this.getChildByPath(pathArr, 'getChildByName');
}
/**
* 根据索引路径获取子节点
* @param path
*/
getChildByIndexPath(path: string): DisplayObject {
const pathArr = path.split('/').map(seg => parseInt(seg));
return this.getChildByPath(pathArr, 'getChildAt');
}
/**
* 根据uuid搜索子节点
* @param uuid
*/
findChildByUUID(uuid: string) {
if(this['uuid'] === uuid) {
return this;
}
if(this.children && this.children.length > 0) {
for(let child of this.children) {
if(child.findChildByUUID) {
let target = child.findChildByUUID(uuid);
if(target) {
return target;
}
}
}
}
}
/**
* 通过名字获取子级
* @param name
* @param isOnlyOne
* @param isRecursive
*/
public getChildByName(name: string | RegExp, isOnlyOne: boolean = true, isRecursive: boolean = false): any {
if(!name) return null;
let s = this;
let rex: any;
if(typeof (name) == "string") {
rex = new RegExp("^" + name + "$");
} else {
rex = name;
}
let elements: Array<DisplayObject> = [];
Container._getElementsByName(rex, s, isOnlyOne, isRecursive, elements);
let len = elements.length;
if(len == 0) {
return null;
} else if(len == 1) {
return elements[0];
} else {
return elements;
}
}
/**
* 移除child
* @param {DisplayObject} child
* @return {DisplayObject}
*/
removeChild(child: DisplayObject): DisplayObject {
const index = this.children.indexOf(child);
if(index === -1) return null;
this.removeChildAt(index);
return child;
}
/**
* 在index处移除child
* @param {number} index - The index to get the child from
* @return {DisplayObject} The child that was removed.
*/
removeChildAt(index: number): DisplayObject {
let s = this;
let child: any;
let len = s.children.length - 1;
if(len < 0) return;
if(index == len) {
child = s.children.pop();
} else if(index == 0) {
child = s.children.shift();
} else {
child = s.children.splice(index, 1)[0];
}
child._onDispatchBubbledEvent(Event.REMOVED_FROM_STAGE);
//保证子级会被更新
child.parent = null;
child.transform._parentID = -1;
//保证包围盒重新计算
this._boundsID++;
this.onChildrenChange(index);
return child;
}
/**
* 通过索引批量移除child
* @param {number} [beginIndex=0]
* @param {number} [endIndex=this.children.length]
* @returns {DisplayObject[]} List of removed children
*/
removeChildren(beginIndex: number = 0, endIndex: number = this.children.length): DisplayObject[] {
const begin = beginIndex;
const end = typeof endIndex === 'number' ? endIndex : this.children.length;
const range = end - begin;
let removed;
if(range > 0 && range <= end) {
removed = this.children.splice(begin, range);
for(let i = 0; i < removed.length; ++i) {
removed[i].parent = null;
if(removed[i].transform) {
removed[i].transform._parentID = -1;
}
}
this._boundsID++;
this.onChildrenChange(beginIndex);
for(let i = 0; i < removed.length; ++i) {
removed[i]._onDispatchBubbledEvent(Event.REMOVED_FROM_STAGE);
}
return removed;
} else if(range === 0 && this.children.length === 0) {
return [];
}
throw new RangeError('removeChildren: numeric values are outside the acceptable range.');
}
/**
* 更新矩阵
*/
updateTransform() {
//自己先算
super.updateTransform();
//考虑是否要加,
this._boundsID++;
//children遍历计算
for(let i = 0, j = this.children.length; i < j; ++i) {
const child = this.children[i];
if(child.visible) {
child.updateTransform();
}
}
/*if(this._transform === this.transform && isUI(this) && this._lastLocalID !== this.transform.localID){
this._lastLocalID = this.transform.localID;
//console.log(this.name, this.instanceId , 'dirty!');
this.stage.layoutInvalid = true;
}*/
}
/**
* 父类重写
* 都是全局的
*/
calculateBounds() {
if(this._lastBoundsID == this._boundsID) return
this._lastBoundsID = this._boundsID
this._bounds.clear();
//算自己的
this._calculateBounds();
for(let i = 0; i < this.children.length; i++) {
const child = this.children[i];
if(!child.visible || !child.renderable) {
continue;
}
child.calculateBounds();
if(child.$mask) {
child.$mask.calculateBounds();
//取交集矩形
if(child._bounds.x < child.$mask._bounds.x) {
child._bounds.x = child.$mask._bounds.x;
}
if(child._bounds.y < child.$mask._bounds.y) {
child._bounds.y = child.$mask._bounds.y;
}
if(child._bounds.width > child.$mask._bounds.width) {
child._bounds.width = child.$mask._bounds.width;
}
if(child._bounds.height > child.$mask._bounds.height) {
child._bounds.height = child.$mask._bounds.height;
}
Rectangle.createFromRects(this._bounds, child._bounds);
} else {
Rectangle.createFromRects(this._bounds, child._bounds);
}
}
}
/**
* 加"_"的方法基本是为了自己特殊处理
*/
protected _calculateBounds() {
//子类自己重写
//let wp = this.worldMatrix.transformPoint(this.x, this.y);
let widthSetted = !!this._width && this._width !== 0;
let heightSetted = !!this._height && this._height !== 0;
/*if (widthSetted) {
this._bounds.x = this.x;
this._bounds.width = this._width;
}
if (heightSetted) {
this._bounds.y = this.y;
this._bounds.height = this._height;
}*/
if(widthSetted || heightSetted) {
const rect = this._localBoundsSelf;
var matrix = this.transform.worldMatrix;
matrix.transformPoint(rect.x, rect.y, DisplayObject._p1);
matrix.transformPoint(rect.x + rect.width, rect.y, DisplayObject._p2);
matrix.transformPoint(rect.x + rect.width, rect.y + rect.height, DisplayObject._p3);
matrix.transformPoint(rect.x, rect.y + rect.height, DisplayObject._p4);
Rectangle.createFromPoints(this._bounds, DisplayObject._p1, DisplayObject._p2, DisplayObject._p3, DisplayObject._p4);
}
}
/**
* 检测点是否在任何child上
* 重写父类方法
*/
hitTestPoint(globalPoint: Point, isMouseEvent: boolean = false) {
//如果不可见
if(!this.visible) return null
//如果禁止子级的鼠标事件
if(isMouseEvent && !this.mouseChildren) {
return this.hitTestSelf(globalPoint);
}
var children = this.children;
var length = children.length;
let child, hitDisplayObject;
//后序遍历,后添加的在上层
for(var i = length - 1; i >= 0; i--) {
child = children[i];
//当作遮罩的不作为检测,跳过
if(child.isUsedToMask) continue;
//有遮罩,但是不在遮罩内,跳过
if(child.mask && !child.mask.hitTestPoint(globalPoint, isMouseEvent)) continue;
//检测
hitDisplayObject = child.hitTestPoint(globalPoint, isMouseEvent);
//存在直接返回
if(hitDisplayObject) return hitDisplayObject;
}
return this.displayObjectHitTestPoint(globalPoint, isMouseEvent);
}
hitTestSelf(globalPoint) {
if(this.mouseEnabled) {
return this.hitTestSelfBounds(globalPoint);
}
return null;
}
hitTestSelfBounds(globalPoint) {
if(this._width && this._height) {
//let {x: tx, y: ty} = this.getBounds();
let {tx, ty} = this.worldMatrix;
const {x, y} = globalPoint;
if(x > tx &&
x < tx + this.width &&
y > ty &&
y < ty + this.height
) return this;
}
return null
}
/**
* webgl渲染
* @param {WebglRenderer} renderer - The renderer
*/
renderWebGL(renderer: WebglRenderer) {
//不可见,全局透明度为0,或者 不渲染,直接return
if(!this.visible || this.worldAlpha <= 0 || !this.renderable) {
return;
}
//是否有遮罩。到时如果有滤镜,
if(this.mask) {
this.renderAdvancedWebGL(renderer);
} else {
//自身先渲染
this._renderWebGL(renderer);
//遍历children
for(let i = 0, j = this.children.length; i < j; ++i) {
this.children[i].renderWebGL(renderer);
}
}
}
/**
* 高级渲染方法
*
* @private
* @param {WebGLRenderer} renderer - The renderer
*/
private renderAdvancedWebGL(renderer: WebglRenderer) {
//之前的批处理刷掉先
renderer.batchManager.flush();
//有滤镜再说
const mask = this.mask;
if(mask) {
//先画遮罩
renderer.maskManager.pushMask(this, this.mask);
}
//渲染自身
this._renderWebGL(renderer);
//遍历children
for(let i = 0, j = this.children.length; i < j; i++) {
this.children[i].renderWebGL(renderer);
}
//刷掉批处理
renderer.batchManager.flush();
if(mask) {
//移除遮罩,支持多重遮罩
renderer.maskManager.popMask(this, this.mask);
}
}
/**
* 自身渲染方式
* @private
* @param {WebglRenderer} renderer - The renderer
*/
protected _renderWebGL(renderer: WebglRenderer) {
//自身绘制方法
}
/**
* canvas渲染方式
* @param {CanvasRenderer} renderer - The renderer
*/
renderCanvas(renderer: CanvasRenderer) {
if(!this.visible || this.worldAlpha <= 0 || !this.renderable) {
return;
}
if(this.mask) {
renderer.maskManager.pushMask(this.mask);
}
this._renderCanvas(renderer);
for(let i = 0, j = this.children.length; i < j; ++i) {
this.children[i].renderCanvas(renderer);
}
if(this.mask) {
renderer.maskManager.popMask(renderer);
}
}
/**
* 自身渲染方法
*
* @private
* @param {CanvasRenderer} renderer - The renderer
*/
protected _renderCanvas(renderer: CanvasRenderer) {
//自身绘制方法
}
/**
* 更新方法
*/
update(deltaTime: number) {
/*if (!this.visible) return;*/
//更新自己的
super.update(deltaTime)
//更新儿子们的
let len = this.children.length;
for(let i = len - 1; i >= 0; i--) {
const child = this.children[i];
/*if (child.visible)*/
child.update(deltaTime);
}
}
/**
* 调用此方法对自己及其child触发一次指定事件
* @method _onDispatchBubbledEvent
* @public
* @param {string} type
* @since 1.0.0
*/
public _onDispatchBubbledEvent(type: string): void {
let s = this;
let len = s.children.length;
if(type == Event.REMOVED_FROM_STAGE && !s.stage) return;
super._onDispatchBubbledEvent(type);
for(let i = 0; i < len; i++) {
s.children[i]._onDispatchBubbledEvent(type);
}
}
/**
*
*/
destroy() {
let s = this;
//让子级也destroy
for(let i = s.children.length - 1; i >= 0; i--) {
s.children[i].destroy();
}
super.destroy();
this.mouseChildren = false;
}
/**
* 一般用于获取宽高并设置
* 包括子级的,容器的尽量少用,子类可重写
* @member {number}
*/
get width(): number {
return this._width || this.scale.x * this.getLocalBounds().width;
}
set width(value: number) {
// const width = this.getLocalBounds().width;
// if (width !== 0) {
// this.scale.x = value / width;
// } else {
// this.scale.x = 1;
// }
if(this._width !== value) {
//子类有用,有_width,才需设置scaleX
this._width = value;
this._localBoundsSelf.width = value;
//if (this.stage) this.stage.layoutInvalid = true;
this.dispatchEvent(Event.RESIZE);
this.dispatchEvent(Event.MAYBE_ALIGN);
}
// 如果它设置了 percentWidth 或同时设置了 left 和 right 则表示他的宽度是相对的,则对于父级来说它的宽度永远是 0
if(toBoolean(this.percentWidth)
|| (toBoolean(this.left) && toBoolean(this.right))
) {
this.__width = 0;
} else {
this.__width = value;
}
}
/**
* 高度同width
* @member {number}
*/
get height(): number {
return this._height || this.scale.y * this.getLocalBounds().height;
}
set height(value: number) {
// const height = this.getLocalBounds().height;
// if (height !== 0) {
// this.scale.y = value / height;
// } else {
// this.scale.y = 1;
// }
if(this._height !== value) {
this._height = value;
this._localBoundsSelf.height = value;
//if (this.stage) this.stage.layoutInvalid = true;
this.dispatchEvent(Event.RESIZE);
this.dispatchEvent(Event.MAYBE_ALIGN);
}
// 如果它设置了 percentHeight 或同时设置了 top 和 bottom 则表示他的高度是相对的,则对于父级来说它的高度永远是 0
if(toBoolean(this.percentHeight)
|| (toBoolean(this.top) && toBoolean(this.bottom))
) {
this.__height = 0;
} else {
this.__height = value;
}
}
protected __width = 0; // 忽略 相对宽度 的 宽度,在父级计算自动宽度的时候用到
protected __height = 0; // 忽略 相对高度 的 高度,在父级计算自动高度的时候用到
protected _autoWidth = false; // 自动宽度?
protected _autoHeight = false; // 自动高度?
public get autoWidth() {
return this._autoWidth;
}
public get autoHeight() {
return this._autoHeight;
}
public set autoWidth(autoWidth) {
this._autoWidth = autoWidth;
this.right = NaN; /// TODO 不知道需不需要
this.percentWidth = NaN; /// TODO 不知道需不需要
this.adjustProxy.makeDirty();
}
public set autoHeight(autoHeight) {
this._autoHeight = autoHeight;
this.bottom = NaN; /// TODO 不知道需不需要
this.percentHeight = NaN; /// TODO 不知道需不需要
this.adjustProxy.makeDirty();
}
// public judgeAutoSize() {
// this.autoWidth = !(toBoolean(this.right) || toBoolean(this.percentWidth) || toBoolean(this._width));
// this.autoHeight = !(toBoolean(this.bottom) || toBoolean(this.percentHeight) || toBoolean(this._height));
// }
get x(): number {
return this.position.x;
}
set x(value: number) {
if(value == this.transform.position.x) return;
this.transform.position.x = value;
this.dispatchEvent(Event.MAYBE_ALIGN);
}
get y(): number {
return this.position.y;
}
set y(value: number) {
if(value == this.transform.position.y) return;
this.transform.position.y = value;
this.dispatchEvent(Event.MAYBE_ALIGN);
}
clone(withEvents = false, withScripts = false) {
let target = this.constructor.apply(Object.create(this.constructor.prototype));
const originConfig = this['__originConfig'];
const {name, properties, events, scripts} = originConfig;
target.name = name;
target['__originConfig'] = originConfig;
injectProperties(target, properties);
if(withScripts) {
if(scripts && scripts.length > 0) {
for(let scriptConfig of scripts) {
instantiateScript(target, scriptConfig);
}
}
}
if(withEvents) {
if(events) {
target.eventsProxy.start(events);
}
}
for(let child of this.children) {
let childCopy = child.clone(withEvents, withScripts);
target.addChild(childCopy);
}
return target;
}
get $store() {
let p = this;
do {
if(p['$isViewRoot']) {
break;
}
p = p.parent;
}
while(p.parent);
if(p) {
return p['$_store'];
}
}
//全局遍历
/**
* @method _getElementsByName
* @param {RegExp} rex
* @param {Container} root
* @param {boolean} isOnlyOne
* @param {boolean} isRecursive
* @param {Array<DisplayObject>} resultList
* @private
* @static
*/
private static _getElementsByName(rex: RegExp, root: Container, isOnlyOne: boolean, isRecursive: boolean, resultList: Array<DisplayObject>): void {
let len = root.children.length;
if(len > 0) {
let name: string;
let child: any;
for(let i = 0; i < len; i++) {
child = root.children[i];
name = child.name;
if(name && name != "") {
if(rex.test(name)) {
resultList[resultList.length] = child;
if(isOnlyOne) {
return;
}
}
}
if(isRecursive) {
if(child["children"] != null) {
Container._getElementsByName(rex, child, isOnlyOne, isRecursive, resultList);
}
}
}
}
}
}
Container.prototype.containerUpdateTransform = Container.prototype.updateTransform;
......@@ -395,10 +395,19 @@ export default class Sprite extends Container {
}
set width(value) {
value = Math.abs(value);
const s = sign(this.scale.x) || 1;
this.scale.x = s * value / this._texture.orig.width;
this._width = value;
this.dispatchEvent(Event.MAYBE_ALIGN);
if(isNaN(this.percentWidth) || this.percentWidth === null) {
this.__width = value;
} else {
this.__width = 0;
}
}
/**
......@@ -410,9 +419,17 @@ export default class Sprite extends Container {
}
set height(value) {
value = Math.abs(value);
const s = sign(this.scale.y) || 1;
this.scale.y = s * value / this._texture.orig.height;
this._height = value;
this.dispatchEvent(Event.MAYBE_ALIGN);
if(isNaN(this.percentHeight) || this.percentHeight === null) {
this.__height = value;
} else {
this.__height= 0;
}
}
/**
......
......@@ -12,6 +12,7 @@ import {WebglRenderer} from "../renderers/WebglRenderer";
import {GDispatcher} from "../events/GDispatcher";
import CanvasRenderer from "../renderers/CanvasRenderer";
import {GlobalPro, isWebGLSupported} from "../utils/index";
import { alignMgr } from "../../zeroing/decorators/AlignManager";
//如果以后还出现帧率问题,使用ticker;
//兼容requestAnimationFrame
......@@ -972,12 +973,13 @@ export class Stage extends Container {
if (!GlobalPro.startTime) GlobalPro.startTime = Date.now();
//console.log('flushAll', Date.now());
alignMgr.flush();
if (!Stage._pause) {
let len = Stage.allUpdateObjList.length;
for (let i = 0; i < len; i++) {
Stage.allUpdateObjList[i] && Stage.allUpdateObjList[i].flush();
}
}
requestAnimationFrame(Stage.flushAll);
}
......@@ -1035,4 +1037,4 @@ export class Stage extends Container {
s._ml = null;
super.destroy();
}
}
\ No newline at end of file
}
......@@ -9,9 +9,10 @@ import {HashObject} from "../HashObject";
*/
export class Event extends HashObject {
// public static IMAGE_LOADED: string = "onImageLoaded"
public static MAYBE_ALIGN: string = "maybeAlign";
/**
// public static IMAGE_LOADED: string = "onImageLoaded"
/**
* 舞台尺寸发生变化时触发
* @Event
* @property RESIZE
......
import { ALIGN_MODE } from "./auto-adjust";
import { toBoolean } from "../utils/utils";
/**
* 自适应管理器
* @constructor
*/
class AlignManager {
// 这个列表里的对象会在渲染前被自动调整
private alignList = [];
constructor() {
}
/**
* flash (渲染前)
*/
public flush() {
this.alignList.forEach((v) => {
this.autoSize(v); // 去调整大小
this.align(v); // 去自动对齐
});
// 要在这里单独检查,因为对齐一次后可能遇到其父节点需要对齐导致其再对齐一次
this.alignList.forEach((v) => {
if(v.alignMode === ALIGN_MODE.ONCE) { // 如果是单次对齐则一次运算之后就关闭它
v.alignEnabled = false;
}
});
// 干掉列表
this.alignList.length = 0;
}
/**
* align
* @param that
*/
private align(that) {
// if(that)
if(!that.alignEnabled) return; // 如果的自动对齐关闭里则啥也不干
// if(that.alignMode === ALIGN_MODE.ONCE) { // 如果是单次对齐则一次运算之后就关闭它
// that.alignEnabled = false;
// }
const {percentWidth, percentHeight, left, top, right, bottom, horizonCenter, verticalCenter} = that;
let {_width: tW_Z = 0, _height: tH_Z = 0} = that;
const {_width: pW_Z = 0, _height: pH_Z = 0} = (that.parent || {});
/**
* 计算 width 和 x 值
*/
if(toBoolean(left) && toBoolean(right)) { // left right 都有则直接拉伸或缩小
that.x = left;
that.width = pW_Z - left - right;
} else {
// 先设置下自己的 width
toBoolean(percentWidth) && (tW_Z = that.width = pW_Z * percentWidth / 100);
// 先考虑 horizonCenter 属性
if(toBoolean(horizonCenter)) {
// x 值 = 父节点的中间值 - 自己宽度的一半 - 居中差值
that.x = pW_Z / 2 - tW_Z / 2 + horizonCenter;
} else if(toBoolean(left)) { // 假如有左边距
that.x = left;
} else if(toBoolean(right)) { // 假如有右边距
that.x = pW_Z - right - tW_Z;
}
}
/**
* 计算 height 和 y 值
*/
if(toBoolean(top) && toBoolean(bottom)) { // top bottom 都有则直接拉伸或缩小
that.y = top;
that.height = pH_Z - top - bottom;
} else {
// 先设置下自己的 height
toBoolean(percentHeight) && (tH_Z = that.height = pH_Z * percentHeight / 100);
// 先考虑 horizonCenter 属性
if(toBoolean(verticalCenter)) {
// x 值 = 父节点的中间值 - 自己高度的一半 - 居中差值
that.y = pH_Z / 2 - tH_Z / 2 + verticalCenter;
} else if(toBoolean(top)) { // 假如有 top
that.y = top;
} else if(toBoolean(bottom)) { // 假如有 bottom
that.y = pH_Z - bottom - tH_Z;
}
}
// console.log(that.name, that.width, that.height);
that.children.forEach(v => this.align(v));
}
/**
* 自动大小
* @param that
*/
private autoSize(that) {
let len = that.children.length
if(len > 0) {
// 检测本身的是否是可以自动宽
if(that.autoWidth && !toBoolean(that.right) && !toBoolean(that.percentWidth)) {
// 找出子节点最小x
// let minX = 0;
// for(let i = 0; i < len; i++) {
// if(that.children[i].x < minX) {
// minX = that.children[i].x;
// }
// }
// if(minX < 0) {
// that.children.forEach(v => v.x -= minX);
// that.x += minX;
// that.width -= minX;
// }
// 找出最右值
let max = 0;
for(let i = 0; i < len; i++) {
if(toBoolean(that.children[i].right)) continue;
let _x = that.children[i].x || 0;
let _w = that.children[i].__width || 0;
if(_x + _w > max) {
max = _x + _w;
}
}
that.width = max;
}
// 检测本身的是否是可以自动高
if(that.autoHeight && !toBoolean(that.bottom) && !toBoolean(that.percentHeight)) {
// 找出子节点最小y
// let minY = 0;
// for(let i = 1; i < len; i++) {
// if(that.children[i].y < minY) {
// minY = that.children[i].y;
// }
// }
// if(minY < 0) {
// that.children.forEach(v => v.y -= minY);
// that.y += minY;
// that.height -= minY;
// }
// 找出最下值
let max = 0;
for(let i = 0; i < len; i++) {
if(toBoolean(that.children[i].bottom)) continue;
let _y = that.children[i].y || 0;
let _h = that.children[i].__height || 0;
if(_y + _h > max) {
max = _y + _h;
}
}
that.height = max;
}
}
}
/**
* 添加一个变脏的对象
* @param obj
*/
public addAlign(obj) {
if(this.alignList.indexOf(obj) < 0) {
this.alignList.push(obj);
}
}
}
export let alignMgr = new AlignManager();
......@@ -4,151 +4,320 @@
* 自适应功能
*/
import {Event} from "../../2d/events/index";
import { Event } from "../../2d/events/index";
import { alignMgr } from "./AlignManager";
/**
* 应用自适应
* @param ctor
*/
export function applyAutoAdjust(ctor: Function) {
ctor.prototype.applyAutoAdjust = function () {
let adjustProxy = this.adjustProxy = new AdjustProxy(this);
this.addEventListener(Event.ADDED_TO_STAGE, adjustProxy.onAddedToStage, adjustProxy);
this.addEventListener(Event.REMOVED_FROM_STAGE, adjustProxy.onRemovedFromStage, adjustProxy);
};
let temp = new AdjustProxy(null);
for (let key in temp.data)
Object.defineProperty(ctor.prototype, key, {
get: function () {
return this.adjustProxy.data[key];
},
set: function (v) {
const adjustProxy: AdjustProxy = this.adjustProxy;
if (adjustProxy.data[key] !== v) {
adjustProxy.data[key] = v;
adjustProxy.makeDirty();
}
},
enumerable: true,
configurable: true
});
ctor.prototype.applyAutoAdjust = function() {
let adjustProxy = this.adjustProxy = new AdjustProxy(this);
this.addEventListener(Event.ADDED_TO_STAGE, adjustProxy.onAddedToStage, adjustProxy);
this.addEventListener(Event.REMOVED_FROM_STAGE, adjustProxy.onRemovedFromStage, adjustProxy);
};
let temp = new AdjustProxy(null);
for(let key in temp.data) {
if(key == 'alignMode'
// || key == 'percentWidth' || key == 'percentHeight'
) continue;
Object.defineProperty(ctor.prototype, key, {
get: function() {
return this.adjustProxy.data[key];
},
set: function(v) {
const adjustProxy: AdjustProxy = this.adjustProxy;
if(adjustProxy.data[key] !== v && !(isNaN(adjustProxy.data[key]) && isNaN(v))) {
adjustProxy.data[key] = v;
adjustProxy.makeDirty();
}
},
enumerable: true,
configurable: true
});
}
// Object.defineProperty(ctor.prototype, 'percentWidth', {
// get: function() {
// return this.adjustProxy.data['percentWidth'];
// },
// set: function(v) {
// const adjustProxy: AdjustProxy = this.adjustProxy;
// if(adjustProxy.data['percentWidth'] !== v) {
// adjustProxy.data['percentWidth'] = v;
// adjustProxy.makeDirty();
//
// this._autoWidth = false;
// }
// },
// enumerable: true,
// configurable: true
// });
//
// Object.defineProperty(ctor.prototype, 'percentHeight', {
// get: function() {
// return this.adjustProxy.data['percentHeight'];
// },
// set: function(v) {
// const adjustProxy: AdjustProxy = this.adjustProxy;
// if(adjustProxy.data['percentHeight'] !== v) {
// adjustProxy.data['percentHeight'] = v;
// adjustProxy.makeDirty();
//
// this._autoHeight = isNaN(this._height) || this._height === null || this._height === undefined;
// }
// },
// enumerable: true,
// configurable: true
// });
Object.defineProperty(ctor.prototype, 'alignMode', {
get: function() {
return this.adjustProxy.data['alignMode'];
},
set: function(v) {
const adjustProxy: AdjustProxy = this.adjustProxy;
if(adjustProxy.data['alignMode'] !== v) {
adjustProxy.data['alignMode'] = v;
adjustProxy.makeDirty();
if(v == ALIGN_MODE.ALWAYS) this.alignEnabled = true; // 如果设置为 always 则自动开启
}
},
enumerable: true,
configurable: true
});
}
export enum ALIGN_MODE {
ONCE = 'once',
ALWAYS = 'always',
}
/**
* 自适应数据
*/
class AdjustProxy {
data = {
percentWidth: NaN,
percentHeight: NaN,
left: NaN,
top: NaN,
right: NaN,
bottom: NaN,
horizonCenter: NaN,
verticalCenter: NaN,
};
private _host;
private _sizeDirty;
constructor(host) {
this._host = host;
this.makeDirty();
}
makeDirty() {
this._sizeDirty = true;
}
onAddedToStage(e) {
this._host.parent.addEventListener(Event.RESIZE, this.onResize, this);
this._host.addEventListener(Event.RESIZE, this.onResize, this);
this._host.addEventListener(Event.ENTER_FRAME, this.onEnterFrame, this);
}
onRemovedFromStage(e) {
//this._host.parent.removeEventListener(Event.RESIZE, this.onResize);
this._host.removeEventListener(Event.RESIZE, this.onResize, this);
this._host.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
}
setFrom(adjustProxy: AdjustProxy) {
for (let k in adjustProxy.data) {
this.data[k] = adjustProxy.data[k];
}
}
private onResize(e) {
this._sizeDirty = true;
}
private onEnterFrame(e) {
if (this._sizeDirty) {
this._sizeDirty = false;
this.adjustLayout();
}
}
adjustLayout() {
const that = this._host;
const {width: pWidth, height: pHeight} = that.parent;
const {width, height} = that;
const {percentWidth, percentHeight, left, top, right, bottom, horizonCenter, verticalCenter} = this.data;
const applyPercentWidth = function () {
if (t(percentWidth)) {
that.width = pWidth * percentWidth / 100;
}
};
const applyPercentHeight = function () {
if (t(percentHeight)) {
that.height = pHeight * percentHeight / 100;
}
};
let pw = true, ph = true;
if (t(horizonCenter)) {
applyPercentWidth();
that.x = (pWidth - that.width) / 2 + horizonCenter;
} else {
if (t(left)) {
that.x = left;
if (t(right)) {
that.width = pWidth - left - right;
pw = false;
}
} else if (t(right)) {
that.x = pWidth - width - right;
}
if (pw) {
applyPercentWidth();
}
}
if (t(verticalCenter)) {
applyPercentHeight();
that.y = (pHeight - that.height) / 2 + verticalCenter;
} else {
if (t(top)) {
that.y = top;
if (t(bottom)) {
that.height = pHeight - top - bottom;
ph = false;
}
} else if (t(bottom)) {
that.y = pHeight - height - bottom;
}
if (ph) {
applyPercentHeight();
}
}
}
data = {
percentWidth: NaN,
percentHeight: NaN,
left: NaN,
top: NaN,
right: NaN,
bottom: NaN,
horizonCenter: NaN,
verticalCenter: NaN,
}
alignEnabled: true,
alignMode: ALIGN_MODE.ALWAYS,
};
private _host;
private _sizeDirty;
constructor(host) {
this._host = host;
this.makeDirty();
}
makeDirty() {
this._sizeDirty = true;
this._host && alignMgr.addAlign(this._host);
this._host && this._host.parent && this._host.parent.adjustProxy.makeDirty();
}
onAddedToStage(e) {
this._host.addEventListener(Event.MAYBE_ALIGN, this.readyAlign, this);
// this._host.parent.addEventListener(Event.MAYBE_ALIGN, this.align, this);
// this._host.parent.addEventListener(Event.RESIZE, this.align, this);
// this._host.addEventListener(Event.RESIZE, this.align, this);
// this._host.addEventListener(Event.ENTER_FRAME, this.onEnterFrame, this);
}
onRemovedFromStage(e) {
this._host.removeEventListener(Event.MAYBE_ALIGN, this.readyAlign);
// this._host.parent.removeEventListener(Event.MAYBE_ALIGN, this.align);
// this._host.parent.removeEventListener(Event.RESIZE, this.align);
// this._host.removeEventListener(Event.RESIZE, this.align, this);
// this._host.removeEventListener(Event.ENTER_FRAME, this.onEnterFrame);
}
setFrom(adjustProxy: AdjustProxy) {
for(let k in adjustProxy.data) {
this.data[k] = adjustProxy.data[k];
}
}
/**
* align 方式 T + 1
* @param e
*/
private readyAlign(e) {
this._sizeDirty = true;
this._host && alignMgr.addAlign(this._host);
this._host && this._host.parent && this._host.parent.adjustProxy.makeDirty(); // 它爸爸也要设置一次。可能有autoSize
}
// autoSize() {
// let that = this._host.parent;
// if(that.name !== 'rect1' && that.name !== 'rect_main' && that.name !== 'rect2' && that.name !== 'rect3') return;
//
// if(that.name == "scene-container"
// || that.name == "game-stage"
// || that.name == "main")
// return;
//
// // 检测本身的是否是自动宽高
// let len = that.children.length
// if(len > 0) {
// // if(that._autoWidth) {
// // 找出子节点最小x
// // let minX = that.children[0].x;
// // for(let i = 1; i < len; i++) {
// // if(that.children[i].x < minX) {
// // minX = that.children[i].x;
// // }
// // }
// // that.children.forEach(v => v._x -= minX);
// // that._x += minX;
//
// // 找出右值
// let max = 0;
// for(let i = 0; i < len; i++) {
// if(t(that.children[i].right)) continue;
// let _x = that.children[i].x || 0;
// let _w = that.children[i].__width || 0;
// if(_x + _w > max) {
// max = _x + _w;
// }
// }
// that.width = max;
// // let dw = that.width - max;
// // that._width -= dw;
// // }
//
// // if(that._autoHeight) {
// // 找出子节点最小y
// // let minY = that.children[0].y;
// // for(let i = 1; i < len; i++) {
// // if(that.children[i].x < minY) {
// // minY = that.children[i].y;
// // }
// // }
// // that.children.forEach(v => v._y -= minY);
// // that._y += minY;
//
// // 找出右值
// max = 0;
// for(let i = 0; i < len; i++) {
// if(t(that.children[i].bottom)) continue;
// let _y = that.children[i].y || 0;
// let _h = that.children[i].__height || 0;
// if(_y + _h > max) {
// max = _y + _h;
// }
// }
// that.height = max;
// // let dh = that.height - max;
// // that._height -= dh;
// // }
// }
//
// }
// private onEnterFrame(e) {
// if(this._sizeDirty) {
// this._sizeDirty = false;
//
// // this.adjustLayout();
// }
// }
function t(v) {
return !isNaN(v) && v !== null && v !== undefined;
// /**
// * 手动调用可在当前帧 align
// */
// adjustLayout() {
// // return;
//
// const that = this._host;
//
// if(!that.alignEnabled) return;
//
// if(that.alignMode === ALIGN_MODE.ONCE) { // 如果是单次对齐则一次运算之后就关闭它
// that.alignEnabled = false;
// }
//
// const {percentWidth, percentHeight, left, top, right, bottom, horizonCenter, verticalCenter} = this.data;
//
// let {_width: tW_Z = 0, _height: tH_Z = 0} = that;
// const {_width: pW_Z = 0, _height: pH_Z = 0} = that.parent;
//
// let {_width: tW, _height: tH} = that;
// const {_width: pW, _height: pH} = that.parent;
// this.autoSize();
//
// /**
// * 计算 width 和 x 值
// */
// if(t(left) && t(right)) { // left right 都有则直接拉伸或缩小
//
// that.x = left;
//
// that.width = pW_Z - left - right;
//
// } else {
// // 先设置下自己的 width
// t(percentWidth) && (tW_Z = that.width = pW_Z * percentWidth / 100);
//
// // 先考虑 horizonCenter 属性
// if(t(horizonCenter)) {
// // x 值 = 父节点的中间值 - 自己宽度的一半 - 居中差值
// that.x = pW_Z / 2 - tW_Z / 2 + horizonCenter;
//
// } else if(t(left)) { // 假如有左边距
//
// that.x = left;
//
// } else if(t(right)) { // 假如有右边距
//
// that.x = pW_Z - right - tW_Z;
//
// }
// }
//
// /**
// * 计算 height 和 y 值
// */
// if(t(top) && t(bottom)) { // top bottom 都有则直接拉伸或缩小
//
// that.y = top;
//
// that.height = pH_Z - top - bottom;
//
// } else {
// // 先设置下自己的 height
// t(percentHeight) && (tH_Z = that.height = pH_Z * percentHeight / 100);
//
// // 先考虑 horizonCenter 属性
// if(t(verticalCenter)) {
// // x 值 = 父节点的中间值 - 自己高度的一半 - 居中差值
// that.y = pH_Z / 2 - tH_Z / 2 + verticalCenter;
//
// } else if(t(top)) { // 假如有 top
//
// that.y = top;
//
// } else if(t(bottom)) { // 假如有 bottom
//
// that.y = pH_Z - bottom - tH_Z;
//
// }
// }
//
// // console.log(that.name, that.width, that.height);
// that.children.forEach(v => v.adjustProxy.adjustLayout());
// }
}
......@@ -2,354 +2,354 @@
* Created by rockyl on 2019-11-05.
*/
import {Stage} from "../../2d/display/index";
import {StackContainer} from "./StackContainer";
import {checkAssetGroupLoaded, loadAssetsGroup, loadAssets, loadAssetsGroups} from "./assets-manager";
import {instantiate} from "./view-interpreter";
import {dataCenter, DataCenter} from "./data-center";
import {setProcessMetaLibs} from "../behavior-runtime/index";
import {Tween} from "../../2d/tween/index";
import {Rect} from "./nodes/index";
import {injectEnv} from "./enviroment";
import {Toast} from "./Toast";
import {arrayFind} from "../utils/index";
import {Node} from "./nodes/Node";
import {bind, createStore} from "./mvvm/index";
import {registerCustomModules} from "./custom-module";
import {dealPageRemainTime, dealPxEnv} from "../px-logics";
import { Stage } from "../../2d/display/index";
import { StackContainer } from "./StackContainer";
import { checkAssetGroupLoaded, loadAssetsGroup, loadAssets, loadAssetsGroups } from "./assets-manager";
import { instantiate } from "./view-interpreter";
import { dataCenter, DataCenter } from "./data-center";
import { setProcessMetaLibs } from "../behavior-runtime/index";
import { Tween } from "../../2d/tween/index";
import { Rect } from "./nodes/index";
import { injectEnv } from "./enviroment";
import { Toast } from "./Toast";
import { arrayFind } from "../utils/index";
import { Node } from "./nodes/Node";
import { bind, createStore } from "./mvvm/index";
import { registerCustomModules } from "./custom-module";
import { dealPageRemainTime, dealPxEnv } from "../px-logics";
import Container from "../../2d/display/Container";
import {Event} from "../../2d/events/Event";
import { Event } from "../../2d/events/Event";
/**
* 游戏舞台
*/
export class GameStage extends Node {
private _sceneContainer: StackContainer; //场景容器
private _popupContainer: StackContainer; //弹层容器
private _loadingView: Container;
private _toast: Toast;
private _blackLayer: Rect;
private _stage;
private _dataCenter: DataCenter;
private _config: any;
private _viewCache: any = {};
constructor(stage: Stage) {
super();
this.name = 'game-stage';
stage.width = stage.viewRect.width;
stage.height = stage.viewRect.height;
this._stage = stage;
this._dataCenter = dataCenter;
this.percentWidth = 100;
this.percentHeight = 100;
this.mouseEnabled = false;
let loadingView = this._loadingView = new Container();
this.addChild(this._sceneContainer = new StackContainer());
this.addChild(this._popupContainer = new StackContainer(false, 1));
this.addChild(this._toast = new Toast(this));
this.addChild(loadingView);
let blackLayer = this._blackLayer = new Rect();
blackLayer.name = 'blackLayer';
blackLayer.width = stage.width;
blackLayer.height = stage.height;
blackLayer.fillColor = 0;
blackLayer.alpha = 0.7;
loadingView.percentWidth = 100;
loadingView.percentHeight = 100;
loadingView.visible = false;
this._sceneContainer.name = 'scene-container';
this._popupContainer.name = 'popup-container';
this._popupContainer.addEventListener(Event.START, this.onPopupContainerStart, this);
this._popupContainer.addEventListener(Event.COMPLETE, this.onPopupContainerComplete, this);
}
/**
* 场景容器
*/
get sceneContainer(): StackContainer {
return this._sceneContainer;
}
/**
* 弹层容器
*/
get popupContainer(): StackContainer {
return this._popupContainer;
}
/**
* Toast提示
*/
get toast(): Toast {
return this._toast;
}
/**
* 数据中心
*/
get dataCenter(): DataCenter {
return this._dataCenter;
}
/**
* 启动游戏
* @param config
* @param onPreloadAssetsProgress 预加载素材进度
* @param onPreloadAssetsComplete 预加载素材完成
* @param onStart
*/
async launch(config, onPreloadAssetsProgress?, onPreloadAssetsComplete?, onStart?) {
this._config = config;
const {options: {env}, dataMapping, processes, builtinProcesses, customs} = this._config;
Stage.addUpdateObj(Tween);
injectEnv(env);
//registerScripts(scripts);
//registerCustomModuleFromConfig(customs);
registerCustomModules(customs);
if (dataMapping) {
this.dataCenter.registerDataMapping(dataMapping);
}
setProcessMetaLibs(processes, builtinProcesses);
await this.loadPreloadAssets(onPreloadAssetsProgress, onPreloadAssetsComplete);
this.start();
dealPxEnv();
dealPageRemainTime();
onStart && onStart();
setTimeout(this.lazyLoadAllAssets,
this._config.options.lazyLoadWait || 1000);
}
/**
* 开始游戏
*/
start() {
const {options: {entrySceneView, }, } = this._config;
setTimeout(async () => {
let sceneEntry = await this.instantiateView(entrySceneView);
if (sceneEntry) {
this._sceneContainer.push(sceneEntry);
}
})
}
/**
* 显示加载视图
*/
async showInnerLoadingView() {
let loadingViewName = this._config.options.loadingView;
let loadingView = this._loadingView.getChildAt(0);
if (this._loadingView.children.length == 0 && loadingViewName) {
loadingView = await this.instantiateView(loadingViewName, true, false);
this._loadingView.addChild(loadingView);
}
this._loadingView.visible = true;
}
/**
* 隐藏加载视图
*/
hideInnerLoadingView() {
if (this._loadingView.visible) {
this._loadingView.visible = false;
}
}
/**
* 实例化视图
* @param name
* @param cache 如果开启缓存,就会以单例形式存在
* @param showLoadingView
*/
async instantiateView(name, cache = true, showLoadingView = true) {
let view;
if (cache) {
view = this._viewCache[name];
}
if (!view) {
let viewConfig = this.getViewConfigByName(name);
if (viewConfig) {
const {assets, customs} = this._config;
if (!Array.isArray(assets)) {
let groups = {};
let {depCustoms} = viewConfig;
if (depCustoms && depCustoms.length > 0) {
for (let custom of customs) {
if (depCustoms.indexOf(custom.id) >= 0 && custom.assets) {
if (!checkAssetGroupLoaded(custom.id)) {
groups[custom.id] = custom.assets;
}
}
}
}
if (!checkAssetGroupLoaded(viewConfig.uuid)) {
let depAssets = assets[viewConfig.uuid];
if (depAssets && depAssets.length > 0) {
groups[viewConfig.uuid] = depAssets;
}
}
if(Object.keys(groups).length > 0){
await loadAssetsGroups(groups, async () => {
if (showLoadingView) {
await this.showInnerLoadingView();
}
}, async () => {
if (showLoadingView) {
this.hideInnerLoadingView();
}
});
}
}
view = instantiate(viewConfig);
let store = {};
if (viewConfig.store) {
const {exp, computed} = viewConfig.store;
store = createStore(exp, computed);
}
view['$isViewRoot'] = true;
view['$_store'] = store;
console.time('bind');
bind(store, view);
console.timeEnd('bind');
if (cache) {
this._viewCache[name] = view;
}
} else {
console.error('view config not exists:', name);
}
}
return view;
}
/**
* 根据name获取视图配置
* @param name
*/
getViewConfigByName(name) {
return arrayFind(this._config.views, view => view.name === name);
}
onPopupContainerStart(e) {
const {action, view, lastView, options, hasView} = e.data;
const target = <StackContainer>e.target;
switch (action) {
case 'push':
case 'replace':
case 'popAll':
if (options && options.center) {
view.x = (target.width - view.width) / 2;
view.y = (target.height - view.height) / 2;
}
break;
}
let blackLayer = this._blackLayer;
let pParent = blackLayer.parent;
if (hasView) {
target.addChildAt(blackLayer, target.childNum - 1 - (view ? 0 : 1));
let modalAlpha = 0.7;
if(options && options.hasOwnProperty('modalAlpha')){
modalAlpha = options.modalAlpha;
}
if (!pParent || blackLayer['tween_count'] > 0) {
blackLayer.alpha = 0;
Tween.get(blackLayer, null, null, true)
.to({alpha: modalAlpha}, 300);
}
} else if (pParent) {
Tween.get(blackLayer, null, null, true)
.to({alpha: 0}, 300)
.call(() => {
pParent.removeChild(blackLayer);
});
}
}
onPopupContainerComplete(e) {
}
lazyLoadAllAssets = async () => {
let {assets, customs} = this._config;
if (!Array.isArray(assets)) {
for (let uuid in assets) {
let group = assets[uuid];
if (group && group.length > 0) {
await loadAssetsGroup(group, uuid);
}
}
}
for (let custom of customs) {
let group = custom.assets;
if (group && group.length > 0) {
await loadAssetsGroup(group, custom.id);
}
}
};
async loadPreloadAssets(onPreloadAssetsProgress, onPreloadAssetsComplete){
const {assets, } = this._config;
let loaded = 0;
let assetsToLoad = assets;
let total;
if (!Array.isArray(assets)) { //如果是分组后的配置就加载共用分组,否则加载全部
assetsToLoad = assets['common'];
if(assetsToLoad.length > 0){
await this.showInnerLoadingView();
await loadAssetsGroups({
preload: assetsToLoad,
}, async () => {
}, async () => {
this.hideInnerLoadingView();
});
}
}else{
total = assetsToLoad.length;
await loadAssets(assetsToLoad, p).catch(e => {
console.log(e);
});
}
function p() {
loaded++;
onPreloadAssetsProgress && onPreloadAssetsProgress(loaded, total);
if (loaded >= total) {
onPreloadAssetsComplete && onPreloadAssetsComplete();
}
}
}
private _sceneContainer: StackContainer; //场景容器
private _popupContainer: StackContainer; //弹层容器
private _loadingView: Container;
private _toast: Toast;
private _blackLayer: Rect;
private _stage;
private _dataCenter: DataCenter;
private _config: any;
private _viewCache: any = {};
constructor(stage: Stage) {
super();
this.name = 'game-stage';
stage.width = stage.viewRect.width;
stage.height = stage.viewRect.height;
this._stage = stage;
this._dataCenter = dataCenter;
this.percentWidth = 100;
this.percentHeight = 100;
this.mouseEnabled = false;
let loadingView = this._loadingView = new Container();
this.addChild(this._sceneContainer = new StackContainer());
this.addChild(this._popupContainer = new StackContainer(false, 1));
this.addChild(this._toast = new Toast(this));
this.addChild(loadingView);
let blackLayer = this._blackLayer = new Rect();
blackLayer.name = 'blackLayer';
blackLayer.width = stage.width;
blackLayer.height = stage.height;
blackLayer.fillColor = 0;
blackLayer.alpha = 0.7;
loadingView.percentWidth = 100;
loadingView.percentHeight = 100;
loadingView.visible = false;
this._sceneContainer.name = 'scene-container';
this._popupContainer.name = 'popup-container';
this._popupContainer.addEventListener(Event.START, this.onPopupContainerStart, this);
this._popupContainer.addEventListener(Event.COMPLETE, this.onPopupContainerComplete, this);
}
/**
* 场景容器
*/
get sceneContainer(): StackContainer {
return this._sceneContainer;
}
/**
* 弹层容器
*/
get popupContainer(): StackContainer {
return this._popupContainer;
}
/**
* Toast提示
*/
get toast(): Toast {
return this._toast;
}
/**
* 数据中心
*/
get dataCenter(): DataCenter {
return this._dataCenter;
}
/**
* 启动游戏
* @param config
* @param onPreloadAssetsProgress 预加载素材进度
* @param onPreloadAssetsComplete 预加载素材完成
* @param onStart
*/
async launch(config, onPreloadAssetsProgress?, onPreloadAssetsComplete?, onStart?) {
this._config = config;
const {options: {env}, dataMapping, processes, builtinProcesses, customs} = this._config;
Stage.addUpdateObj(Tween);
injectEnv(env);
//registerScripts(scripts);
//registerCustomModuleFromConfig(customs);
registerCustomModules(customs);
if(dataMapping) {
this.dataCenter.registerDataMapping(dataMapping);
}
setProcessMetaLibs(processes, builtinProcesses);
await this.loadPreloadAssets(onPreloadAssetsProgress, onPreloadAssetsComplete);
this.start();
dealPxEnv();
dealPageRemainTime();
onStart && onStart();
setTimeout(this.lazyLoadAllAssets,
this._config.options.lazyLoadWait || 1000);
}
/**
* 开始游戏
*/
start() {
const {options: {entrySceneView,},} = this._config;
setTimeout(async () => {
let sceneEntry = await this.instantiateView(entrySceneView);
if(sceneEntry) {
this._sceneContainer.push(sceneEntry);
}
})
}
/**
* 显示加载视图
*/
async showInnerLoadingView() {
let loadingViewName = this._config.options.loadingView;
let loadingView = this._loadingView.getChildAt(0);
if(this._loadingView.children.length == 0 && loadingViewName) {
loadingView = await this.instantiateView(loadingViewName, true, false);
this._loadingView.addChild(loadingView);
}
this._loadingView.visible = true;
}
/**
* 隐藏加载视图
*/
hideInnerLoadingView() {
if(this._loadingView.visible) {
this._loadingView.visible = false;
}
}
/**
* 实例化视图
* @param name
* @param cache 如果开启缓存,就会以单例形式存在
* @param showLoadingView
*/
async instantiateView(name, cache = true, showLoadingView = true) {
let view;
if(cache) {
view = this._viewCache[name];
}
if(!view) {
let viewConfig = this.getViewConfigByName(name);
if(viewConfig) {
const {assets, customs} = this._config;
if(!Array.isArray(assets)) {
let groups = {};
let {depCustoms} = viewConfig;
if(depCustoms && depCustoms.length > 0) {
for(let custom of customs) {
if(depCustoms.indexOf(custom.id) >= 0 && custom.assets) {
if(!checkAssetGroupLoaded(custom.id)) {
groups[custom.id] = custom.assets;
}
}
}
}
if(!checkAssetGroupLoaded(viewConfig.uuid)) {
let depAssets = assets[viewConfig.uuid];
if(depAssets && depAssets.length > 0) {
groups[viewConfig.uuid] = depAssets;
}
}
if(Object.keys(groups).length > 0) {
await loadAssetsGroups(groups, async () => {
if(showLoadingView) {
await this.showInnerLoadingView();
}
}, async () => {
if(showLoadingView) {
this.hideInnerLoadingView();
}
});
}
}
view = instantiate(viewConfig);
let store = {};
if(viewConfig.store) {
const {exp, computed} = viewConfig.store;
store = createStore(exp, computed);
}
view['$isViewRoot'] = true;
view['$_store'] = store;
console.time('bind');
bind(store, view);
console.timeEnd('bind');
if(cache) {
this._viewCache[name] = view;
}
} else {
console.error('view config not exists:', name);
}
}
return view;
}
/**
* 根据name获取视图配置
* @param name
*/
getViewConfigByName(name) {
return arrayFind(this._config.views, view => view.name === name);
}
onPopupContainerStart(e) {
const {action, view, lastView, options, hasView} = e.data;
const target = <StackContainer>e.target;
switch(action) {
case 'push':
case 'replace':
case 'popAll':
if(options && options.center) {
view.x = (target.width - view.width) / 2;
view.y = (target.height - view.height) / 2;
}
break;
}
let blackLayer = this._blackLayer;
let pParent = blackLayer.parent;
if(hasView) {
target.addChildAt(blackLayer, target.childNum - 1 - (view ? 0 : 1));
let modalAlpha = 0.7;
if(options && options.hasOwnProperty('modalAlpha')) {
modalAlpha = options.modalAlpha;
}
if(!pParent || blackLayer['tween_count'] > 0) {
blackLayer.alpha = 0;
Tween.get(blackLayer, null, null, true)
.to({alpha: modalAlpha}, 300);
}
} else if(pParent) {
Tween.get(blackLayer, null, null, true)
.to({alpha: 0}, 300)
.call(() => {
pParent.removeChild(blackLayer);
});
}
}
onPopupContainerComplete(e) {
}
lazyLoadAllAssets = async () => {
let {assets, customs} = this._config;
if(!Array.isArray(assets)) {
for(let uuid in assets) {
let group = assets[uuid];
if(group && group.length > 0) {
await loadAssetsGroup(group, uuid);
}
}
}
for(let custom of customs) {
let group = custom.assets;
if(group && group.length > 0) {
await loadAssetsGroup(group, custom.id);
}
}
};
async loadPreloadAssets(onPreloadAssetsProgress, onPreloadAssetsComplete) {
const {assets,} = this._config;
let loaded = 0;
let assetsToLoad = assets;
let total;
if(!Array.isArray(assets)) { //如果是分组后的配置就加载共用分组,否则加载全部
assetsToLoad = assets['common'];
if(assetsToLoad.length > 0) {
await this.showInnerLoadingView();
await loadAssetsGroups({
preload: assetsToLoad,
}, async () => {
}, async () => {
this.hideInnerLoadingView();
});
}
} else {
total = assetsToLoad.length;
await loadAssets(assetsToLoad, p).catch(e => {
console.log(e);
});
}
function p() {
loaded++;
onPreloadAssetsProgress && onPreloadAssetsProgress(loaded, total);
if(loaded >= total) {
onPreloadAssetsComplete && onPreloadAssetsComplete();
}
}
}
}
......@@ -2,87 +2,92 @@
* Created by rockyl on 2019-11-08.
*/
import {Stage} from "../2d/display/index";
import {GameStage, registerCustomModuleFromConfig} from "./game-warpper/index";
import {setGlobalContext, setProcessMetaLibs} from "./behavior-runtime/index";
import {globalLoader} from "../2d/loader/Loader";
import {Event} from "../2d/events/Event";
import { Stage } from "../2d/display/index";
import { GameStage, registerCustomModuleFromConfig } from "./game-warpper/index";
import { setGlobalContext, setProcessMetaLibs } from "./behavior-runtime/index";
import { globalLoader } from "../2d/loader/Loader";
import { Event } from "../2d/events/Event";
import builtinLoadingView from "./game-warpper/LoadingView";
import {queryParams} from "./web";
import {initAutoLayout} from "./game-warpper/auto-layout";
import {registerScripts} from "./decorators/scripts";
import {RENDERER_TYPE, StageScaleMode} from "../2d/const";
import { queryParams } from "./web";
import { initAutoLayout } from "./game-warpper/auto-layout";
import { registerScripts } from "./decorators/scripts";
import { RENDERER_TYPE, StageScaleMode } from "../2d/const";
import { alignMgr } from "./decorators/AlignManager";
export let gameStage: GameStage;
export let alignManager = alignMgr;
export function launch(url, loadingDelegate?, onStart?) {
if (queryParams.__proxy_mode__) {
return Promise.resolve('cancel launch');
}
return globalLoader.loadJson(url)
.then(config => {
return launchWithConfig(config, loadingDelegate, onStart);
});
if(queryParams.__proxy_mode__) {
return Promise.resolve('cancel launch');
}
return globalLoader.loadJson(url)
.then(config => {
return launchWithConfig(config, loadingDelegate, onStart);
});
}
export function launchWithLocalStorage(id, loadingDelegate?, onStart?) {
const storeKey = 'preview-project-' + id;
let storeData = localStorage.getItem(storeKey);
let {data, processes, scripts, customs,} = JSON.parse(storeData);
const storeKey = 'preview-project-' + id;
let storeData = localStorage.getItem(storeKey);
let {data, processes, scripts, customs,} = JSON.parse(storeData);
setProcessMetaLibs(processes);
registerScripts(scripts);
registerCustomModuleFromConfig(customs);
setProcessMetaLibs(processes);
registerScripts(scripts);
registerCustomModuleFromConfig(customs);
return launchWithConfig(data, loadingDelegate, onStart);
return launchWithConfig(data, loadingDelegate, onStart);
}
export function launchWithWindowVariable(name, loadingDelegate?, onStart?) {
let {data, processes, scripts, customs,} = window[name];
let {data, processes, scripts, customs,} = window[name];
setProcessMetaLibs(processes);
registerScripts(scripts);
registerCustomModuleFromConfig(customs);
setProcessMetaLibs(processes);
registerScripts(scripts);
registerCustomModuleFromConfig(customs);
return launchWithConfig(data, loadingDelegate, onStart);
return launchWithConfig(data, loadingDelegate, onStart);
}
export async function launchWithConfig(config, loadingDelegate?, onStart?) {
await new Promise(resolve => {
setTimeout(resolve, 300);
});
return await new Promise(resolve => {
const {containerId, designWidth, designHeight, frameRate, scaleMode, rendererType, bgColor, autoResize,} = config.options;
let stage = window['stage'] = new Stage(
containerId || "game-container",
designWidth || 750,
designHeight || 1334,
frameRate || 60,
scaleMode || StageScaleMode.FIXED_WIDTH,
rendererType || RENDERER_TYPE.WEBGL,
true,
bgColor,
autoResize,
);
initAutoLayout(stage);
Stage.flushAll();
stage.addEventListener(Event.ON_INIT_STAGE, () => {
gameStage = new GameStage(stage);
setGlobalContext({
gameStage
});
stage.addChild(gameStage);
let delegate = loadingDelegate || builtinLoadingView;
gameStage.launch(config, function (done, total) {
delegate.onProgress && delegate.onProgress(done, total)
}, function () {
delegate.onComplete && delegate.onComplete();
}, onStart);
});
resolve(gameStage);
})
await new Promise(resolve => {
setTimeout(resolve, 300);
});
return await new Promise(resolve => {
const {containerId, designWidth, designHeight, frameRate, scaleMode, rendererType, bgColor, autoResize,} = config.options;
let stage = window['stage'] = new Stage(
containerId || "game-container",
designWidth || 750,
designHeight || 1334,
frameRate || 60,
scaleMode || StageScaleMode.FIXED_WIDTH,
rendererType || RENDERER_TYPE.WEBGL,
true,
bgColor,
autoResize,
);
initAutoLayout(stage);
Stage.flushAll();
// Stage.addUpdateObj(alignMgr);
stage.addEventListener(Event.ON_INIT_STAGE, () => {
gameStage = new GameStage(stage);
setGlobalContext({
gameStage
});
stage.addChild(gameStage);
let delegate = loadingDelegate || builtinLoadingView;
gameStage.launch(config, function(done, total) {
delegate.onProgress && delegate.onProgress(done, total)
}, function() {
delegate.onComplete && delegate.onComplete();
}, onStart);
});
resolve(gameStage);
})
}
......@@ -14,16 +14,16 @@ export const linkScheme = 'link://';
* @param predicate
*/
export function arrayFind(arr, predicate) {
if (!arr) {
return;
}
for (let i = 0, li = arr.length; i < li; i++) {
const item = arr[i];
if (predicate(item, i, arr)) {
return item;
}
}
if(!arr) {
return;
}
for(let i = 0, li = arr.length; i < li; i++) {
const item = arr[i];
if(predicate(item, i, arr)) {
return item;
}
}
}
/**
......@@ -31,23 +31,23 @@ export function arrayFind(arr, predicate) {
* @param obj
*/
export function objClone(obj) {
return obj ? JSON.parse(JSON.stringify(obj)) : obj;
return obj ? JSON.parse(JSON.stringify(obj)) : obj;
}
const percentKeys = ['width', 'height'];
export function propertyParse(key, node, properties) {
let value = properties[key];
let targetKey = key;
if (percentKeys.indexOf(key) >= 0) {
if (typeof value === 'string') {
if (value[value.length - 1] === '%') {
targetKey = 'percent' + key[0].toUpperCase() + key.substr(1);
}
value = parseInt(value);
}
}
node[targetKey] = value;
let value = properties[key];
let targetKey = key;
if(percentKeys.indexOf(key) >= 0) {
if(typeof value === 'string') {
if(value[value.length - 1] === '%') {
targetKey = 'percent' + key[0].toUpperCase() + key.substr(1);
}
value = parseInt(value);
}
}
node[targetKey] = value;
}
/**
......@@ -57,15 +57,15 @@ export function propertyParse(key, node, properties) {
* @param throwException
*/
export function getDataByPath(scope, path, throwException?) {
let func = new Function('scope', `return scope` + (path ? ('.' + path) : ''));
try {
return func(scope);
} catch (e) {
//console.warn(e);
if (throwException) {
throw e;
}
}
let func = new Function('scope', `return scope` + (path ? ('.' + path) : ''));
try {
return func(scope);
} catch(e) {
//console.warn(e);
if(throwException) {
throw e;
}
}
}
/**
......@@ -74,14 +74,14 @@ export function getDataByPath(scope, path, throwException?) {
* @param throwException
*/
export function safeEval(code, throwException = false) {
let func = new Function(code);
try {
return func();
} catch (e) {
if (throwException) {
throw e;
}
}
let func = new Function(code);
try {
return func();
} catch(e) {
if(throwException) {
throw e;
}
}
}
/**
......@@ -95,28 +95,28 @@ export function safeEval(code, throwException = false) {
* @return 是否有字段注入
*/
export function injectProp(target: any, data?: any, callback?: Function, ignoreMethod: boolean = true, ignoreNull: boolean = true): boolean {
if (!target || !data) {
return false;
}
let result = false;
for (let key in data) {
let value: any = data[key];
if ((!ignoreMethod || typeof value != 'function') && (!ignoreNull || value != null)) {
if (callback) {
callback(target, key, value);
} else {
try {
target[key] = value;
} catch (e) {
}
}
result = true;
}
}
return result;
if(!target || !data) {
return false;
}
let result = false;
for(let key in data) {
let value: any = data[key];
if((!ignoreMethod || typeof value != 'function') && (!ignoreNull || value != null)) {
if(callback) {
callback(target, key, value);
} else {
try {
target[key] = value;
} catch(e) {
}
}
result = true;
}
}
return result;
}
/**
......@@ -126,22 +126,22 @@ export function injectProp(target: any, data?: any, callback?: Function, ignoreM
* @param config
*/
export function copyProp(target, data, config?) {
if (data) {
for (let key in config) {
let valueConfig = config[key];
if (Array.isArray(valueConfig)) {
target[key] = {};
for (let field of valueConfig) {
target[key][field] = data[key][field];
}
} else if (typeof valueConfig === 'string') {
target[valueConfig] = data[valueConfig];
} else if (typeof valueConfig === 'object') {
target[key] = {};
copyProp(target[key], data[key], valueConfig)
}
}
}
if(data) {
for(let key in config) {
let valueConfig = config[key];
if(Array.isArray(valueConfig)) {
target[key] = {};
for(let field of valueConfig) {
target[key][field] = data[key][field];
}
} else if(typeof valueConfig === 'string') {
target[valueConfig] = data[valueConfig];
} else if(typeof valueConfig === 'object') {
target[key] = {};
copyProp(target[key], data[key], valueConfig)
}
}
}
}
/**
......@@ -149,18 +149,18 @@ export function copyProp(target, data, config?) {
* @param obj
*/
export function obj2query(obj: any): string {
if (!obj) {
return '';
}
let arr: string[] = [];
for (let key in obj) {
arr.push(key + (key ? '=' : '') + obj[key]);
}
return arr.join('&');
if(!obj) {
return '';
}
let arr: string[] = [];
for(let key in obj) {
arr.push(key + (key ? '=' : '') + obj[key]);
}
return arr.join('&');
}
function requireForCJS(id) {
return window[id];
return window[id];
}
/**
......@@ -169,19 +169,19 @@ function requireForCJS(id) {
* @param node
*/
export function importCJSCode(code, node?) {
if (node) {
let create = new Function('module', 'require', code);
let module = {
exports: {},
};
create(module, requireForCJS);
return module.exports;
} else {
let create = new Function('exports', code);
let exports: any = {};
create(exports);
return exports.default;
}
if(node) {
let create = new Function('module', 'require', code);
let module = {
exports: {},
};
create(module, requireForCJS);
return module.exports;
} else {
let create = new Function('exports', code);
let exports: any = {};
create(exports);
return exports.default;
}
}
/**
......@@ -189,10 +189,10 @@ export function importCJSCode(code, node?) {
* @param code
*/
export function importUMDCode(code) {
let create = new Function('exports', code);
let exports: any = {};
create.call(exports);
return exports;
let create = new Function('exports', code);
let exports: any = {};
create.call(exports);
return exports;
}
/**
......@@ -201,24 +201,24 @@ export function importUMDCode(code) {
* @param char
*/
export function trimChar(str: string, char: string) {
if (!str || !char) {
return;
}
while (true) {
let len = str.length, from = 0, end = len;
if (str[0] === char) {
from = 1;
}
if (str[len - 1] === char) {
end = len - 1;
}
str = str.substring(from, end);
if (str.length == len) {
break;
}
}
return str;
if(!str || !char) {
return;
}
while(true) {
let len = str.length, from = 0, end = len;
if(str[0] === char) {
from = 1;
}
if(str[len - 1] === char) {
end = len - 1;
}
str = str.substring(from, end);
if(str.length == len) {
break;
}
}
return str;
}
/**
......@@ -226,11 +226,11 @@ export function trimChar(str: string, char: string) {
* @param segments
*/
export function joinPath(...segments: string[]) {
let result = [];
for (let segment of segments) {
result.push(trimChar(segment, '/'));
}
return result.join('/');
let result = [];
for(let segment of segments) {
result.push(trimChar(segment, '/'));
}
return result.join('/');
}
/**
......@@ -239,16 +239,16 @@ export function joinPath(...segments: string[]) {
* @param contexts
*/
export function findVariable(name: string, ...contexts) {
let result;
for (let context of contexts) {
if (context) {
result = context[name];
if (result !== undefined) {
break;
}
}
}
return result;
let result;
for(let context of contexts) {
if(context) {
result = context[name];
if(result !== undefined) {
break;
}
}
}
return result;
}
let el;
......@@ -258,15 +258,15 @@ let el;
* @param htmlText
*/
export function htmlToPureText(htmlText) {
if (!el) {
el = document.createElement('div');
}
el.innerHTML = htmlText;
document.body.appendChild(el);
let pureText = el.innerText;
document.body.removeChild(el);
return pureText;
if(!el) {
el = document.createElement('div');
}
el.innerHTML = htmlText;
document.body.appendChild(el);
let pureText = el.innerText;
document.body.removeChild(el);
return pureText;
}
const zhReg = /[\u4e00-\u9fa5]/;
......@@ -276,11 +276,11 @@ const zhReg = /[\u4e00-\u9fa5]/;
* @param str
*/
export function strLen(str) {
let len = 0;
for (let char of str) {
len += char.match(zhReg) ? 2 : 1;
}
return len;
let len = 0;
for(let char of str) {
len += char.match(zhReg) ? 2 : 1;
}
return len;
}
/**
......@@ -290,23 +290,23 @@ export function strLen(str) {
* @param replace
*/
export function strShort(str, limit, replace = '…') {
let result = '';
if (strLen(str) > limit) {
let len = 0;
for (let i = 0, li = str.length; i < li; i++) {
const char = str[i];
len += char.match(zhReg) ? 2 : 1;
if (len > limit) {
result += replace;
break;
} else {
result += char;
}
}
} else {
result = str;
}
return result;
let result = '';
if(strLen(str) > limit) {
let len = 0;
for(let i = 0, li = str.length; i < li; i++) {
const char = str[i];
len += char.match(zhReg) ? 2 : 1;
if(len > limit) {
result += replace;
break;
} else {
result += char;
}
}
} else {
result = str;
}
return result;
}
/**
......@@ -315,8 +315,8 @@ export function strShort(str, limit, replace = '…') {
* @param ScriptConfig
*/
export function instantiateScript(node, ScriptConfig) {
const {script: scriptName, props, disabled} = ScriptConfig;
const script = node.scripts.add(scriptName, props, disabled);
const {script: scriptName, props, disabled} = ScriptConfig;
const script = node.scripts.add(scriptName, props, disabled);
}
export const cmdPrefix = 'z-';
......@@ -328,13 +328,13 @@ export const cmdOldPrefix = '//z-';
* @param source
*/
export function injectProperties(target, source) {
for (let key in source) {
if (key.indexOf('//') !== 0 && !source.hasOwnProperty(cmdPrefix + key)) {
propertyParse(key, target, source);
}
}
for(let key in source) {
if(key.indexOf('//') !== 0 && !source.hasOwnProperty(cmdPrefix + key)) {
propertyParse(key, target, source);
}
}
return target;
return target;
}
/**
......@@ -344,14 +344,25 @@ export function injectProperties(target, source) {
* @param includeSelf
*/
export function traverseViewNode(node: Container, callback: Function, includeSelf = false) {
if (includeSelf) {
callback(node);
}
for (let child of node.children) {
callback(child, node);
if (child.children && child.children.length > 0) {
traverseViewNode(child, callback);
}
}
if(includeSelf) {
callback(node);
}
for(let child of node.children) {
callback(child, node);
if(child.children && child.children.length > 0) {
traverseViewNode(child, callback);
}
}
}
/**
* 数字转化为boolean值
* NaN -> false 'aaa' -> false null -> false undefined -> false
* 666 -> true '007' -> true Infinity -> true
* @param v
* @returns {boolean}
*/
export function toBoolean(v): boolean {
return !isNaN(v) && v !== null && v !== undefined;
}
......@@ -438,10 +438,10 @@ rollup-plugin-node-resolve@^5.2.0:
resolve "^1.11.1"
rollup-pluginutils "^2.8.1"
rollup-plugin-progress@^1.1.1:
version "1.1.1"
resolved "https://registry.npm.taobao.org/rollup-plugin-progress/download/rollup-plugin-progress-1.1.1.tgz#fcce2f915d545014ac89ea0927ee97cb48052f60"
integrity sha1-/M4vkV1UUBSsieoJJ+6Xy0gFL2A=
rollup-plugin-progress@^1.1.2:
version "1.1.2"
resolved "https://registry.npm.taobao.org/rollup-plugin-progress/download/rollup-plugin-progress-1.1.2.tgz#5c1dfe7c50f654906bc34d167d5512ee1a4b72d5"
integrity sha1-XB3+fFD2VJBrw00WfVUS7hpLctU=
dependencies:
chalk "^2.4.2"
......
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