diff --git a/cocos/core/geometry/curve.ts b/cocos/core/geometry/curve.ts index 5833c38386..5dbbddbe6b 100644 --- a/cocos/core/geometry/curve.ts +++ b/cocos/core/geometry/curve.ts @@ -189,6 +189,8 @@ export class AnimationCurve { case WrapMode.PingPong: wrappedTime = pingPong(time - startTime, endTime - startTime) + startTime; break; + case WrapMode.Default: + case WrapMode.Normal: case WrapMode.Clamp: wrappedTime = clamp(time, startTime, endTime); break; @@ -246,6 +248,8 @@ export class AnimationCurve { case WrapMode.PingPong: wrappedTime = pingPong(time - startTime, endTime - startTime) + startTime; break; + case WrapMode.Default: + case WrapMode.Normal: case WrapMode.Clamp: wrappedTime = clamp(time, startTime, endTime); break; @@ -254,10 +258,7 @@ export class AnimationCurve { return this.cachedKey.evaluate(wrappedTime); } else { const leftIndex = this.findIndex(this.cachedKey, wrappedTime); - let rightIndex = leftIndex + 1; - if (rightIndex === this.keyFrames!.length) { - rightIndex -= 1; - } + const rightIndex = Math.min(leftIndex + 1, this.keyFrames!.length - 1); this.calcOptimizedKey(this.cachedKey, leftIndex, rightIndex); return this.cachedKey.evaluate(wrappedTime); } diff --git a/editor/assets/default-video.mp4 b/editor/assets/default-video.mp4 new file mode 100644 index 0000000000..8159a03a5c Binary files /dev/null and b/editor/assets/default-video.mp4 differ diff --git a/editor/assets/default-video.mp4.meta b/editor/assets/default-video.mp4.meta new file mode 100644 index 0000000000..10994ae413 --- /dev/null +++ b/editor/assets/default-video.mp4.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.0.1", + "importer": "video-clip", + "imported": true, + "uuid": "2be36297-9abb-4fee-8049-9ed5e271da8a", + "files": [ + ".mp4", + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/editor/assets/default_prefab/ui/RichText.prefab b/editor/assets/default_prefab/ui/RichText.prefab new file mode 100644 index 0000000000..c461da0061 --- /dev/null +++ b/editor/assets/default_prefab/ui/RichText.prefab @@ -0,0 +1,410 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "RichText", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + }, + { + "__id__": 8 + } + ], + "_active": true, + "_components": [ + { + "__id__": 14 + }, + { + "__id__": 16 + } + ], + "_prefab": { + "__id__": 18 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.PrivateNode", + "_name": "RICHTEXT_CHILD", + "_objFlags": 1024, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 3 + }, + { + "__id__": 5 + } + ], + "_prefab": { + "__id__": 7 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -76.69, + "y": -25.2, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "6csmVlB7RJMbzgr0ruy/Rz" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "__prefab": { + "__id__": 4 + }, + "_priority": 0, + "_contentSize": { + "__type__": "cc.Size", + "width": 80.02, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_id": "6e4/YFEbFHzZBehWqOktUl" + }, + { + "__type__": "cc.CompPrefabInfo ", + "fileId": "2e5gEZK7JEv6t/lN+cudVF" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "__prefab": { + "__id__": 6 + }, + "_visFlags": 0, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 255, + "b": 0, + "a": 255 + }, + "_useOriginalSize": true, + "_string": "Rich", + "_horizontalAlign": 0, + "_verticalAlign": 0, + "_actualFontSize": 40, + "_fontSize": 40, + "_fontFamily": "Arial", + "_lineHeight": 40, + "_overflow": 0, + "_enableWrapText": true, + "_font": null, + "_isSystemFontUsed": true, + "_isItalic": false, + "_isBold": false, + "_isUnderline": false, + "_underlineHeight": 2, + "_cacheMode": 0, + "_id": "7aViHQO/JMT5W88a+35F5h" + }, + { + "__type__": "cc.CompPrefabInfo ", + "fileId": "b58BtkmEREfLcahhaxkiSf" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "65qTwtkgJOrInNSCqrNs+f", + "sync": false, + "_synced": { + "default": false, + "serializable": false + } + }, + { + "__type__": "cc.PrivateNode", + "_name": "RICHTEXT_CHILD", + "_objFlags": 1024, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 9 + }, + { + "__id__": 11 + } + ], + "_prefab": { + "__id__": 13 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 3.3299999999999983, + "y": -25.2, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "dbCqT+089FV6hPqc4qyqkx" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "__prefab": { + "__id__": 10 + }, + "_priority": 0, + "_contentSize": { + "__type__": "cc.Size", + "width": 73.36, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_id": "63Udn/+qJJGZgy9VR1u6JL" + }, + { + "__type__": "cc.CompPrefabInfo ", + "fileId": "8fB1K+zqFDm6KLLi/2Tbxt" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "__prefab": { + "__id__": 12 + }, + "_visFlags": 0, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 15, + "g": 255, + "b": 255, + "a": 255 + }, + "_useOriginalSize": true, + "_string": "Text", + "_horizontalAlign": 0, + "_verticalAlign": 0, + "_actualFontSize": 40, + "_fontSize": 40, + "_fontFamily": "Arial", + "_lineHeight": 40, + "_overflow": 0, + "_enableWrapText": true, + "_font": null, + "_isSystemFontUsed": true, + "_isItalic": false, + "_isBold": false, + "_isUnderline": false, + "_underlineHeight": 2, + "_cacheMode": 0, + "_id": "bdTdPOjbRBFK1zYN9pkSl1" + }, + { + "__type__": "cc.CompPrefabInfo ", + "fileId": "08TnEzpqFCOK/MDNdWrYro" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "3eOynnfhFIULJmtJFVqoI6", + "sync": false, + "_synced": { + "default": false, + "serializable": false + } + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 15 + }, + "_priority": 0, + "_contentSize": { + "__type__": "cc.Size", + "width": 153.38, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo ", + "fileId": "78TiFTq9pPVbHywzr3HwuF" + }, + { + "__type__": "cc.RichText", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 17 + }, + "_lineHeight": 40, + "_string": "RichText", + "_horizontalAlign": 0, + "_fontSize": 40, + "_maxWidth": 0, + "_fontFamily": "Arial", + "_font": null, + "_isSystemFontUsed": true, + "_userDefinedFont": null, + "_cacheMode": 0, + "_imageAtlas": null, + "_handleTouchEvent": true, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo ", + "fileId": "95NxRt8ExMwbEuH92a6KWX" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "ddu3l1uz1AJ7G5NFjjOoPp", + "sync": false, + "_synced": { + "default": false, + "serializable": false + } + } +] \ No newline at end of file diff --git a/editor/assets/default_prefab/ui/RichText.prefab.meta b/editor/assets/default_prefab/ui/RichText.prefab.meta new file mode 100644 index 0000000000..91d0b568ce --- /dev/null +++ b/editor/assets/default_prefab/ui/RichText.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.23", + "importer": "prefab", + "imported": true, + "uuid": "fc6bfcfa-8086-4326-809b-0ba1226bac7d", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "RichText" + } +} diff --git a/editor/assets/default_prefab/ui/SpriteSplash.prefab b/editor/assets/default_prefab/ui/SpriteSplash.prefab new file mode 100644 index 0000000000..58360084c0 --- /dev/null +++ b/editor/assets/default_prefab/ui/SpriteSplash.prefab @@ -0,0 +1,146 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "SpriteSplash", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + }, + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 6 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 3 + }, + "_priority": 0, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo ", + "fileId": "94Ki8oOf5BApUAVjddk12n" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 5 + }, + "_visFlags": 0, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_spriteFrame": { + "__uuid__": "7d8f9b89-4fd1-4c9f-a3ab-38ec7cded7ca@f9941" + }, + "_type": 0, + "_fillType": 0, + "_sizeMode": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_useGrayscale": false, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo ", + "fileId": "62gb5XootOJqH7yKP7GfB0" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "2auWFC5gdLdawQHv2TQRjx", + "sync": false, + "_synced": { + "default": false, + "serializable": false + } + } +] \ No newline at end of file diff --git a/editor/assets/default_prefab/ui/SpriteSplash.prefab.meta b/editor/assets/default_prefab/ui/SpriteSplash.prefab.meta new file mode 100644 index 0000000000..468fb1a495 --- /dev/null +++ b/editor/assets/default_prefab/ui/SpriteSplash.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.23", + "importer": "prefab", + "imported": true, + "uuid": "e5f21aad-3a69-4011-ac62-b74352ac025e", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "SpriteSplash" + } +} diff --git a/editor/assets/default_prefab/ui/TiledMap.prefab b/editor/assets/default_prefab/ui/TiledMap.prefab new file mode 100644 index 0000000000..0447c2621a --- /dev/null +++ b/editor/assets/default_prefab/ui/TiledMap.prefab @@ -0,0 +1,122 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "TiledMap", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + }, + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 6 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -480, + "y": -320, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 3 + }, + "_priority": 0, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo ", + "fileId": "a7PFP2zJtI6ITn7h8/nh2Z" + }, + { + "__type__": "cc.TiledMap", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 5 + }, + "_tmxFile": null, + "_enableCulling": true, + "cleanupImageCache": true, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo ", + "fileId": "bcLty6YUdDK7yX23lAP8eP" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "2105AkR79NcIYqFsVLNWzz", + "sync": false, + "_synced": { + "default": false, + "serializable": false + } + } +] \ No newline at end of file diff --git a/editor/assets/default_prefab/ui/TiledMap.prefab.meta b/editor/assets/default_prefab/ui/TiledMap.prefab.meta new file mode 100644 index 0000000000..4be5f9f73b --- /dev/null +++ b/editor/assets/default_prefab/ui/TiledMap.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.23", + "importer": "prefab", + "imported": true, + "uuid": "3139fa4f-8c42-4ce6-98be-15e848d9734c", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "TiledMap" + } +} diff --git a/editor/assets/default_prefab/ui/VideoPlayer.prefab b/editor/assets/default_prefab/ui/VideoPlayer.prefab new file mode 100644 index 0000000000..17b3ec2f66 --- /dev/null +++ b/editor/assets/default_prefab/ui/VideoPlayer.prefab @@ -0,0 +1,133 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "VideoPlayer", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + }, + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 6 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 3 + }, + "_priority": 0, + "_contentSize": { + "__type__": "cc.Size", + "width": 960, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo ", + "fileId": "84IWCQmzxOwqmg8nEmFTNt" + }, + { + "__type__": "cc.VideoPlayer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 5 + }, + "_resourceType": 1, + "_remoteURL": "", + "_clip": { + "__uuid__": "2be36297-9abb-4fee-8049-9ed5e271da8a" + }, + "_playOnAwake": true, + "_volume": 1, + "_mute": false, + "_playbackRate": 1, + "_loop": false, + "_fullScreenOnAwake": false, + "_stayOnBottom": false, + "_keepAspectRatio": true, + "videoPlayerEvent": [], + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo ", + "fileId": "4ef/bMt1pLt5NzRNACjJwQ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "88MH35CSlBl5HUFQvHLFlY", + "sync": false, + "_synced": { + "default": false, + "serializable": false + } + } +] \ No newline at end of file diff --git a/editor/assets/default_prefab/ui/VideoPlayer.prefab.meta b/editor/assets/default_prefab/ui/VideoPlayer.prefab.meta new file mode 100644 index 0000000000..5d9461bd18 --- /dev/null +++ b/editor/assets/default_prefab/ui/VideoPlayer.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.23", + "importer": "prefab", + "imported": true, + "uuid": "7e089eaf-fa97-40d7-8a20-741a152585df", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "VideoPlayer" + } +} diff --git a/editor/assets/default_prefab/ui/WebView.prefab b/editor/assets/default_prefab/ui/WebView.prefab new file mode 100644 index 0000000000..c019916d6a --- /dev/null +++ b/editor/assets/default_prefab/ui/WebView.prefab @@ -0,0 +1,121 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "WebView", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 2 + }, + { + "__id__": 4 + } + ], + "_prefab": { + "__id__": 6 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 3 + }, + "_priority": 0, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo ", + "fileId": "f8vvYOuJJPMpDZ0V7jUnx7" + }, + { + "__type__": "cc.WebView", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 5 + }, + "_url": "https://cocos.com", + "webviewEvents": [], + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo ", + "fileId": "56z0QooUVAnqSSs975NkzA" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "02LVpQNydBDY4ip8CPqdof", + "sync": false, + "_synced": { + "default": false, + "serializable": false + } + } +] \ No newline at end of file diff --git a/editor/assets/default_prefab/ui/WebView.prefab.meta b/editor/assets/default_prefab/ui/WebView.prefab.meta new file mode 100644 index 0000000000..d2aa18da76 --- /dev/null +++ b/editor/assets/default_prefab/ui/WebView.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.23", + "importer": "prefab", + "imported": true, + "uuid": "9c541fa2-1dc8-4d8b-813a-aec89133f5b1", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "WebView" + } +} diff --git a/package-lock.json b/package-lock.json index cd4abb5a6f..0e665c2a9c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1252,7 +1252,7 @@ }, "@babel/preset-env": { "version": "7.8.7", - "resolved": "https://registry.npm.taobao.org/@babel/preset-env/download/@babel/preset-env-7.8.7.tgz", + "resolved": "https://registry.npm.taobao.org/@babel/preset-env/download/@babel/preset-env-7.8.7.tgz?cache=0&sync_timestamp=1593522855920&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fpreset-env%2Fdownload%2F%40babel%2Fpreset-env-7.8.7.tgz", "integrity": "sha1-H8fYnH910tcMK2do3mwuBJs8uds=", "dev": true, "requires": { @@ -1412,7 +1412,7 @@ }, "@cocos/babel-plugin-dynamic-import-vars": { "version": "1.0.2", - "resolved": "https://registry.npm.taobao.org/@cocos/babel-plugin-dynamic-import-vars/download/@cocos/babel-plugin-dynamic-import-vars-1.0.2.tgz?cache=0&sync_timestamp=1604048375532&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40cocos%2Fbabel-plugin-dynamic-import-vars%2Fdownload%2F%40cocos%2Fbabel-plugin-dynamic-import-vars-1.0.2.tgz", + "resolved": "https://registry.npm.taobao.org/@cocos/babel-plugin-dynamic-import-vars/download/@cocos/babel-plugin-dynamic-import-vars-1.0.2.tgz", "integrity": "sha1-chaboK/r3jjHTS02cU95rWZBT5g=", "dev": true, "requires": { @@ -1444,9 +1444,9 @@ } }, "@cocos/build-engine": { - "version": "4.0.0-jsb.alpha.14", - "resolved": "https://registry.npm.taobao.org/@cocos/build-engine/download/@cocos/build-engine-4.0.0-jsb.alpha.14.tgz", - "integrity": "sha1-ha2Fn+yLYk9Vwzt/Qy/1dHQ3vec=", + "version": "4.0.0-beta.0", + "resolved": "https://registry.npm.taobao.org/@cocos/build-engine/download/@cocos/build-engine-4.0.0-beta.0.tgz?cache=0&sync_timestamp=1605068242322&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40cocos%2Fbuild-engine%2Fdownload%2F%40cocos%2Fbuild-engine-4.0.0-beta.0.tgz", + "integrity": "sha1-hP/YaEfpeVV4+h2OP+/XWC2G7DY=", "dev": true, "requires": { "@babel/core": "^7.9.0", @@ -1466,6 +1466,7 @@ "rollup": "2.26.6", "rollup-plugin-progress": "^1.1.1", "rollup-plugin-terser": "^5.2.0", + "rollup-plugin-visualizer": "^4.2.0", "semver": "^7.3.2", "yargs": "^15.1.0" }, @@ -1487,7 +1488,7 @@ }, "cliui": { "version": "6.0.0", - "resolved": "https://registry.npm.taobao.org/cliui/download/cliui-6.0.0.tgz?cache=0&sync_timestamp=1602861367442&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcliui%2Fdownload%2Fcliui-6.0.0.tgz", + "resolved": "https://registry.npm.taobao.org/cliui/download/cliui-6.0.0.tgz", "integrity": "sha1-UR1wLAxOQcoVbX0OlgIfI+EyJbE=", "dev": true, "requires": { @@ -1534,6 +1535,15 @@ "integrity": "sha1-T5RBKoLbMvNuOwuXQfipf+sDH34=", "dev": true }, + "is-core-module": { + "version": "2.1.0", + "resolved": "https://registry.npm.taobao.org/is-core-module/download/is-core-module-2.1.0.tgz?cache=0&sync_timestamp=1604519290792&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fis-core-module%2Fdownload%2Fis-core-module-2.1.0.tgz", + "integrity": "sha1-pMwDHZsaymPuy9GKZQ4Ty07quUY=", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npm.taobao.org/is-fullwidth-code-point/download/is-fullwidth-code-point-3.0.0.tgz", @@ -1556,12 +1566,12 @@ "dev": true }, "resolve": { - "version": "1.18.1", - "resolved": "https://registry.npm.taobao.org/resolve/download/resolve-1.18.1.tgz?cache=0&sync_timestamp=1603313597183&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fresolve%2Fdownload%2Fresolve-1.18.1.tgz", - "integrity": "sha1-AY/LLFsgfSpkJK7jYcWiZtqPQTA=", + "version": "1.19.0", + "resolved": "https://registry.npm.taobao.org/resolve/download/resolve-1.19.0.tgz?cache=0&sync_timestamp=1605052050544&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fresolve%2Fdownload%2Fresolve-1.19.0.tgz", + "integrity": "sha1-GvW/YwQJc0oGfK4pMYqsf6KaJnw=", "dev": true, "requires": { - "is-core-module": "^2.0.0", + "is-core-module": "^2.1.0", "path-parse": "^1.0.6" } }, @@ -1677,7 +1687,7 @@ }, "source-map": { "version": "0.6.1", - "resolved": "https://registry.npm.taobao.org/source-map/download/source-map-0.6.1.tgz", + "resolved": "https://registry.npm.taobao.org/source-map/download/source-map-0.6.1.tgz?cache=0&sync_timestamp=1571657176668&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsource-map%2Fdownload%2Fsource-map-0.6.1.tgz", "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", "dev": true }, @@ -1702,7 +1712,7 @@ "dependencies": { "fs-extra": { "version": "8.1.0", - "resolved": "https://registry.npm.taobao.org/fs-extra/download/fs-extra-8.1.0.tgz", + "resolved": "https://registry.npm.taobao.org/fs-extra/download/fs-extra-8.1.0.tgz?cache=0&sync_timestamp=1591229972229&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffs-extra%2Fdownload%2Ffs-extra-8.1.0.tgz", "integrity": "sha1-SdQ8RaiM2Wd2aMt74bRu/bjS4cA=", "dev": true, "requires": { @@ -1715,7 +1725,7 @@ }, "typescript": { "version": "3.7.5", - "resolved": "https://registry.npm.taobao.org/typescript/download/typescript-3.7.5.tgz?cache=0&sync_timestamp=1591858152806&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftypescript%2Fdownload%2Ftypescript-3.7.5.tgz", + "resolved": "https://registry.npm.taobao.org/typescript/download/typescript-3.7.5.tgz?cache=0&sync_timestamp=1594620477415&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftypescript%2Fdownload%2Ftypescript-3.7.5.tgz", "integrity": "sha1-BpLiH2X9QQi5MwI4qsEd0uF3oa4=", "dev": true } @@ -2048,12 +2058,12 @@ }, "dependencies": { "@babel/helper-module-imports": { - "version": "7.12.1", - "resolved": "https://registry.npm.taobao.org/@babel/helper-module-imports/download/@babel/helper-module-imports-7.12.1.tgz?cache=0&sync_timestamp=1602802634702&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fhelper-module-imports%2Fdownload%2F%40babel%2Fhelper-module-imports-7.12.1.tgz", - "integrity": "sha1-FkTAFZGhWi8ITdbQktlDDrHRIWw=", + "version": "7.12.5", + "resolved": "https://registry.npm.taobao.org/@babel/helper-module-imports/download/@babel/helper-module-imports-7.12.5.tgz?cache=0&sync_timestamp=1604441076449&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fhelper-module-imports%2Fdownload%2F%40babel%2Fhelper-module-imports-7.12.5.tgz", + "integrity": "sha1-G/wCKfeUmI927QpNTpCGCFC1Tfs=", "dev": true, "requires": { - "@babel/types": "^7.12.1" + "@babel/types": "^7.12.5" } }, "@babel/helper-validator-identifier": { @@ -2063,9 +2073,9 @@ "dev": true }, "@babel/types": { - "version": "7.12.1", - "resolved": "https://registry.npm.taobao.org/@babel/types/download/@babel/types-7.12.1.tgz", - "integrity": "sha1-4QnZq5mo3nNb4ofuPWqZR6GQxK4=", + "version": "7.12.6", + "resolved": "https://registry.npm.taobao.org/@babel/types/download/@babel/types-7.12.6.tgz?cache=0&sync_timestamp=1604486339981&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Ftypes%2Fdownload%2F%40babel%2Ftypes-7.12.6.tgz", + "integrity": "sha1-rg5V7xzOH7yIHNJvgjTrPmV+3JY=", "dev": true, "requires": { "@babel/helper-validator-identifier": "^7.10.4", @@ -2257,7 +2267,7 @@ }, "@types/resolve": { "version": "0.0.8", - "resolved": "https://registry.npm.taobao.org/@types/resolve/download/@types/resolve-0.0.8.tgz?cache=0&sync_timestamp=1596840738717&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fresolve%2Fdownload%2F%40types%2Fresolve-0.0.8.tgz", + "resolved": "https://registry.npm.taobao.org/@types/resolve/download/@types/resolve-0.0.8.tgz", "integrity": "sha1-8mB00jjgJlnjI84aE9BB7uKA4ZQ=", "dev": true, "requires": { @@ -3532,7 +3542,7 @@ }, "commondir": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "resolved": "https://registry.npm.taobao.org/commondir/download/commondir-1.0.1.tgz", "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", "dev": true }, @@ -4010,6 +4020,13 @@ "es6-symbol": "^3.1.1" } }, + "escalade": { + "version": "3.1.1", + "resolved": "https://registry.npm.taobao.org/escalade/download/escalade-3.1.1.tgz?cache=0&sync_timestamp=1602567343144&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fescalade%2Fdownload%2Fescalade-3.1.1.tgz", + "integrity": "sha1-2M/ccACWXFoBdLSoLqpcBVJ0LkA=", + "dev": true, + "optional": true + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npm.taobao.org/escape-string-regexp/download/escape-string-regexp-1.0.5.tgz", @@ -6662,6 +6679,13 @@ } } }, + "is-docker": { + "version": "2.1.1", + "resolved": "https://registry.npm.taobao.org/is-docker/download/is-docker-2.1.1.tgz", + "integrity": "sha1-QSWojkTkUNOE4JBH7eca3C0UQVY=", + "dev": true, + "optional": true + }, "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npm.taobao.org/is-extendable/download/is-extendable-0.1.1.tgz", @@ -8454,6 +8478,13 @@ "dev": true, "optional": true }, + "nanoid": { + "version": "3.1.16", + "resolved": "https://registry.npm.taobao.org/nanoid/download/nanoid-3.1.16.tgz?cache=0&sync_timestamp=1603674706627&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnanoid%2Fdownload%2Fnanoid-3.1.16.tgz", + "integrity": "sha1-sh8KfQMRlvr3UxTXxl02NSvu72Q=", + "dev": true, + "optional": true + }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npm.taobao.org/nanomatch/download/nanomatch-1.2.13.tgz", @@ -8871,6 +8902,29 @@ "mimic-fn": "^2.1.0" } }, + "open": { + "version": "7.3.0", + "resolved": "https://registry.npm.taobao.org/open/download/open-7.3.0.tgz?cache=0&sync_timestamp=1601376181109&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fopen%2Fdownload%2Fopen-7.3.0.tgz", + "integrity": "sha1-RUYf3uRkRPNkW24U6zypS4Lhvmk=", + "dev": true, + "optional": true, + "requires": { + "is-docker": "^2.0.0", + "is-wsl": "^2.1.1" + }, + "dependencies": { + "is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npm.taobao.org/is-wsl/download/is-wsl-2.2.0.tgz", + "integrity": "sha1-dKTHbnfKn9P5MvKQwX6jJs0VcnE=", + "dev": true, + "optional": true, + "requires": { + "is-docker": "^2.0.0" + } + } + } + }, "opener": { "version": "1.4.3", "resolved": "https://registry.npm.taobao.org/opener/download/opener-1.4.3.tgz", @@ -8935,7 +8989,7 @@ }, "os-tmpdir": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "resolved": "https://registry.npm.taobao.org/os-tmpdir/download/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, @@ -9840,7 +9894,7 @@ }, "rollup": { "version": "2.26.6", - "resolved": "https://registry.npm.taobao.org/rollup/download/rollup-2.26.6.tgz", + "resolved": "https://registry.npm.taobao.org/rollup/download/rollup-2.26.6.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Frollup%2Fdownload%2Frollup-2.26.6.tgz", "integrity": "sha1-C0YMHaIkxq8SoelIooxROqEfK5M=", "dev": true, "requires": { @@ -9849,7 +9903,7 @@ "dependencies": { "fsevents": { "version": "2.1.3", - "resolved": "https://registry.npm.taobao.org/fsevents/download/fsevents-2.1.3.tgz?cache=0&sync_timestamp=1588787369955&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffsevents%2Fdownload%2Ffsevents-2.1.3.tgz", + "resolved": "https://registry.npm.taobao.org/fsevents/download/fsevents-2.1.3.tgz?cache=0&sync_timestamp=1604593283990&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffsevents%2Fdownload%2Ffsevents-2.1.3.tgz", "integrity": "sha1-+3OHA66NL5/pAMM4Nt3r7ouX8j4=", "dev": true, "optional": true @@ -9878,6 +9932,159 @@ "terser": "^4.6.2" } }, + "rollup-plugin-visualizer": { + "version": "4.2.0", + "resolved": "https://registry.npm.taobao.org/rollup-plugin-visualizer/download/rollup-plugin-visualizer-4.2.0.tgz", + "integrity": "sha1-L73Z0R0ivyMXgra1ahC10wqUoBw=", + "dev": true, + "optional": true, + "requires": { + "nanoid": "^3.0.1", + "open": "^7.0.3", + "source-map": "^0.7.3", + "yargs": "^16.0.3" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npm.taobao.org/ansi-regex/download/ansi-regex-5.0.0.tgz?cache=0&sync_timestamp=1570188663907&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fansi-regex%2Fdownload%2Fansi-regex-5.0.0.tgz", + "integrity": "sha1-OIU59VF5vzkznIGvMKZU1p+Hy3U=", + "dev": true, + "optional": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npm.taobao.org/ansi-styles/download/ansi-styles-4.3.0.tgz?cache=0&sync_timestamp=1601839226460&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fansi-styles%2Fdownload%2Fansi-styles-4.3.0.tgz", + "integrity": "sha1-7dgDYornHATIWuegkG7a00tkiTc=", + "dev": true, + "optional": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "cliui": { + "version": "7.0.4", + "resolved": "https://registry.npm.taobao.org/cliui/download/cliui-7.0.4.tgz", + "integrity": "sha1-oCZe5lVHb8gHrqnfPfjfd4OAi08=", + "dev": true, + "optional": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npm.taobao.org/color-convert/download/color-convert-2.0.1.tgz", + "integrity": "sha1-ctOmjVmMm9s68q0ehPIdiWq9TeM=", + "dev": true, + "optional": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npm.taobao.org/color-name/download/color-name-1.1.4.tgz", + "integrity": "sha1-wqCah6y95pVD3m9j+jmVyCbFNqI=", + "dev": true, + "optional": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npm.taobao.org/emoji-regex/download/emoji-regex-8.0.0.tgz?cache=0&sync_timestamp=1603212180491&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Femoji-regex%2Fdownload%2Femoji-regex-8.0.0.tgz", + "integrity": "sha1-6Bj9ac5cz8tARZT4QpY79TFkzDc=", + "dev": true, + "optional": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npm.taobao.org/get-caller-file/download/get-caller-file-2.0.5.tgz", + "integrity": "sha1-T5RBKoLbMvNuOwuXQfipf+sDH34=", + "dev": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npm.taobao.org/is-fullwidth-code-point/download/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha1-8Rb4Bk/pCz94RKOJl8C3UFEmnx0=", + "dev": true, + "optional": true + }, + "source-map": { + "version": "0.7.3", + "resolved": "https://registry.npm.taobao.org/source-map/download/source-map-0.7.3.tgz?cache=0&sync_timestamp=1571657176668&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsource-map%2Fdownload%2Fsource-map-0.7.3.tgz", + "integrity": "sha1-UwL4FpAxc1ImVECS5kmB91F1A4M=", + "dev": true, + "optional": true + }, + "string-width": { + "version": "4.2.0", + "resolved": "https://registry.npm.taobao.org/string-width/download/string-width-4.2.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fstring-width%2Fdownload%2Fstring-width-4.2.0.tgz", + "integrity": "sha1-lSGCxGzHssMT0VluYjmSvRY7crU=", + "dev": true, + "optional": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npm.taobao.org/strip-ansi/download/strip-ansi-6.0.0.tgz?cache=0&sync_timestamp=1573280518303&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fstrip-ansi%2Fdownload%2Fstrip-ansi-6.0.0.tgz", + "integrity": "sha1-CxVx3XZpzNTz4G4U7x7tJiJa5TI=", + "dev": true, + "optional": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npm.taobao.org/wrap-ansi/download/wrap-ansi-7.0.0.tgz", + "integrity": "sha1-Z+FFz/UQpqaYS98RUpEdadLrnkM=", + "dev": true, + "optional": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "y18n": { + "version": "5.0.5", + "resolved": "https://registry.npm.taobao.org/y18n/download/y18n-5.0.5.tgz?cache=0&sync_timestamp=1603639294538&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fy18n%2Fdownload%2Fy18n-5.0.5.tgz", + "integrity": "sha1-h2nsCNA7HqLfJQCs71YXQ7u5qxg=", + "dev": true, + "optional": true + }, + "yargs": { + "version": "16.1.0", + "resolved": "https://registry.npm.taobao.org/yargs/download/yargs-16.1.0.tgz?cache=0&sync_timestamp=1602805577427&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fyargs%2Fdownload%2Fyargs-16.1.0.tgz", + "integrity": "sha1-/DM/5HkWYOrOWolLOdQvhRzUjyo=", + "dev": true, + "optional": true, + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.2", + "yargs-parser": "^20.2.2" + } + }, + "yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npm.taobao.org/yargs-parser/download/yargs-parser-20.2.4.tgz?cache=0&sync_timestamp=1604886709178&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fyargs-parser%2Fdownload%2Fyargs-parser-20.2.4.tgz", + "integrity": "sha1-tCiQ8UVmeW+Fro46JSkNIF8VSlQ=", + "dev": true, + "optional": true + } + } + }, "rollup-pluginutils": { "version": "2.8.2", "resolved": "https://registry.npm.taobao.org/rollup-pluginutils/download/rollup-pluginutils-2.8.2.tgz", @@ -10036,7 +10243,7 @@ }, "shelljs": { "version": "0.8.4", - "resolved": "https://registry.npm.taobao.org/shelljs/download/shelljs-0.8.4.tgz", + "resolved": "https://registry.npm.taobao.org/shelljs/download/shelljs-0.8.4.tgz?cache=0&sync_timestamp=1587787210621&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fshelljs%2Fdownload%2Fshelljs-0.8.4.tgz", "integrity": "sha1-3naE/ut2f4cWsyYHiooAh1iQ48I=", "dev": true, "requires": { @@ -10306,7 +10513,7 @@ }, "sprintf-js": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "resolved": "https://registry.npm.taobao.org/sprintf-js/download/sprintf-js-1.0.3.tgz", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, @@ -10839,7 +11046,7 @@ }, "text-table": { "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "resolved": "https://registry.npm.taobao.org/text-table/download/text-table-0.2.0.tgz", "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, @@ -10998,7 +11205,7 @@ }, "through": { "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "https://registry.npm.taobao.org/through/download/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, @@ -11510,7 +11717,7 @@ "dependencies": { "fs-extra": { "version": "8.1.0", - "resolved": "https://registry.npm.taobao.org/fs-extra/download/fs-extra-8.1.0.tgz", + "resolved": "https://registry.npm.taobao.org/fs-extra/download/fs-extra-8.1.0.tgz?cache=0&sync_timestamp=1591229972229&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffs-extra%2Fdownload%2Ffs-extra-8.1.0.tgz", "integrity": "sha1-SdQ8RaiM2Wd2aMt74bRu/bjS4cA=", "dev": true, "requires": { @@ -11552,7 +11759,7 @@ }, "source-map": { "version": "0.6.1", - "resolved": "https://registry.npm.taobao.org/source-map/download/source-map-0.6.1.tgz", + "resolved": "https://registry.npm.taobao.org/source-map/download/source-map-0.6.1.tgz?cache=0&sync_timestamp=1571657176668&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsource-map%2Fdownload%2Fsource-map-0.6.1.tgz", "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", "dev": true }, @@ -11591,7 +11798,7 @@ "dependencies": { "semver": { "version": "7.3.2", - "resolved": "https://registry.npm.taobao.org/semver/download/semver-7.3.2.tgz?cache=0&sync_timestamp=1586886267748&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsemver%2Fdownload%2Fsemver-7.3.2.tgz", + "resolved": "https://registry.npm.taobao.org/semver/download/semver-7.3.2.tgz", "integrity": "sha1-YElisFK4HtB4aq6EOJ/7pw/9OTg=", "dev": true } @@ -11631,7 +11838,7 @@ }, "underscore": { "version": "1.10.2", - "resolved": "https://registry.npm.taobao.org/underscore/download/underscore-1.10.2.tgz", + "resolved": "https://registry.npm.taobao.org/underscore/download/underscore-1.10.2.tgz?cache=0&sync_timestamp=1585603748606&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Funderscore%2Fdownload%2Funderscore-1.10.2.tgz", "integrity": "sha1-c9aqNmjzGI5K2w8ZQ70Sz9fvqq8=", "dev": true }, diff --git a/package.json b/package.json index 4c8c74e958..5c081c4c34 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "@babel/core": "^7.9.0", "@babel/preset-env": "7.8.7", "@cocos/babel-preset-cc": "2.2.0", - "@cocos/build-engine": "4.0.0-jsb.alpha.14", + "@cocos/build-engine": "4.0.0-beta.0", "@cocos/typedoc-plugin-internal-external": "^1.0.1", "@cocos/typedoc-plugin-localization": "^1.0.0", "@types/fs-extra": "^5.0.4", diff --git a/scripts/build-engine/.npmignore b/scripts/build-engine/.npmignore deleted file mode 100644 index 33b95305c7..0000000000 --- a/scripts/build-engine/.npmignore +++ /dev/null @@ -1,6 +0,0 @@ - -src/ - -tsconfig.json - -out/ \ No newline at end of file diff --git a/scripts/build-engine/.vscode/launch.json b/scripts/build-engine/.vscode/launch.json index f3a783fd82..d84e4c37a4 100644 --- a/scripts/build-engine/.vscode/launch.json +++ b/scripts/build-engine/.vscode/launch.json @@ -22,8 +22,7 @@ "--platform=NATIVE", "--module=system", "--sourcemap", - "--out=out", - "--split" + "--out=out" ] } ] diff --git a/scripts/build-engine/package-lock.json b/scripts/build-engine/package-lock.json index c90ce2636e..e31df1c161 100644 --- a/scripts/build-engine/package-lock.json +++ b/scripts/build-engine/package-lock.json @@ -1,6 +1,6 @@ { "name": "@cocos/build-engine", - "version": "4.0.0-jsb.alpha.15", + "version": "4.0.0-beta.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1690,11 +1690,11 @@ "resolved": "https://registry.npm.taobao.org/emoji-regex/download/emoji-regex-8.0.0.tgz", "integrity": "sha1-6Bj9ac5cz8tARZT4QpY79TFkzDc=" }, - "escape-goat": { - "version": "2.1.1", - "resolved": "https://registry.npm.taobao.org/escape-goat/download/escape-goat-2.1.1.tgz", - "integrity": "sha1-Gy3HcANnbEV+x2Cy3GjttkgYhnU=", - "dev": true + "escalade": { + "version": "3.1.1", + "resolved": "https://registry.npm.taobao.org/escalade/download/escalade-3.1.1.tgz?cache=0&sync_timestamp=1602567343144&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fescalade%2Fdownload%2Fescalade-3.1.1.tgz", + "integrity": "sha1-2M/ccACWXFoBdLSoLqpcBVJ0LkA=", + "optional": true }, "escape-string-regexp": { "version": "1.0.5", @@ -1835,10 +1835,10 @@ } }, "is-docker": { - "version": "2.0.0", - "resolved": "https://registry.npm.taobao.org/is-docker/download/is-docker-2.0.0.tgz", - "integrity": "sha1-LLDfDnXi0GT+GGTDfN6st7Lc8ls=", - "dev": true + "version": "2.1.1", + "resolved": "https://registry.npm.taobao.org/is-docker/download/is-docker-2.1.1.tgz", + "integrity": "sha1-QSWojkTkUNOE4JBH7eca3C0UQVY=", + "optional": true }, "is-extglob": { "version": "2.1.1", @@ -1884,10 +1884,13 @@ } }, "is-wsl": { - "version": "2.1.1", - "resolved": "https://registry.npm.taobao.org/is-wsl/download/is-wsl-2.1.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fis-wsl%2Fdownload%2Fis-wsl-2.1.1.tgz", - "integrity": "sha1-ShwVLUKd89RBZpSY4khtNZbrrx0=", - "dev": true + "version": "2.2.0", + "resolved": "https://registry.npm.taobao.org/is-wsl/download/is-wsl-2.2.0.tgz", + "integrity": "sha1-dKTHbnfKn9P5MvKQwX6jJs0VcnE=", + "optional": true, + "requires": { + "is-docker": "^2.0.0" + } }, "jest-worker": { "version": "24.9.0", @@ -2006,10 +2009,10 @@ "integrity": "sha1-0J0fNXtEP0kzgqjrPM0YOHKuYAk=" }, "nanoid": { - "version": "3.1.3", - "resolved": "https://registry.npm.taobao.org/nanoid/download/nanoid-3.1.3.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnanoid%2Fdownload%2Fnanoid-3.1.3.tgz", - "integrity": "sha1-srz8/aS01oOLwioMjdPAoXogTCA=", - "dev": true + "version": "3.1.16", + "resolved": "https://registry.npm.taobao.org/nanoid/download/nanoid-3.1.16.tgz?cache=0&sync_timestamp=1603674706627&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fnanoid%2Fdownload%2Fnanoid-3.1.16.tgz", + "integrity": "sha1-sh8KfQMRlvr3UxTXxl02NSvu72Q=", + "optional": true }, "node-releases": { "version": "1.1.53", @@ -2033,10 +2036,10 @@ } }, "open": { - "version": "7.0.3", - "resolved": "https://registry.npm.taobao.org/open/download/open-7.0.3.tgz", - "integrity": "sha1-21UaGvnHq0x69mQTmTCCYThTHEg=", - "dev": true, + "version": "7.3.0", + "resolved": "https://registry.npm.taobao.org/open/download/open-7.3.0.tgz?cache=0&sync_timestamp=1601376181109&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fopen%2Fdownload%2Fopen-7.3.0.tgz", + "integrity": "sha1-RUYf3uRkRPNkW24U6zypS4Lhvmk=", + "optional": true, "requires": { "is-docker": "^2.0.0", "is-wsl": "^2.1.1" @@ -2141,15 +2144,6 @@ "resolved": "https://registry.npm.taobao.org/private/download/private-0.1.8.tgz", "integrity": "sha1-I4Hts2ifelPWUxkAYPz4ItLzaP8=" }, - "pupa": { - "version": "2.0.1", - "resolved": "https://registry.npm.taobao.org/pupa/download/pupa-2.0.1.tgz", - "integrity": "sha1-29yf9I/76komoGm2+fersFEAhyY=", - "dev": true, - "requires": { - "escape-goat": "^2.0.0" - } - }, "regenerate": { "version": "1.4.0", "resolved": "https://registry.npm.taobao.org/regenerate/download/regenerate-1.4.0.tgz", @@ -2242,9 +2236,9 @@ } }, "rollup-plugin-progress": { - "version": "1.1.1", - "resolved": "https://registry.npm.taobao.org/rollup-plugin-progress/download/rollup-plugin-progress-1.1.1.tgz", - "integrity": "sha1-/M4vkV1UUBSsieoJJ+6Xy0gFL2A=", + "version": "1.1.2", + "resolved": "https://registry.npm.taobao.org/rollup-plugin-progress/download/rollup-plugin-progress-1.1.2.tgz", + "integrity": "sha1-XB3+fFD2VJBrw00WfVUS7hpLctU=", "requires": { "chalk": "^2.4.2" } @@ -2279,23 +2273,95 @@ } }, "rollup-plugin-visualizer": { - "version": "4.0.4", - "resolved": "https://registry.npm.taobao.org/rollup-plugin-visualizer/download/rollup-plugin-visualizer-4.0.4.tgz", - "integrity": "sha1-abkUDG+vRjKJl+0tCLl0JSv51oM=", - "dev": true, + "version": "4.2.0", + "resolved": "https://registry.npm.taobao.org/rollup-plugin-visualizer/download/rollup-plugin-visualizer-4.2.0.tgz", + "integrity": "sha1-L73Z0R0ivyMXgra1ahC10wqUoBw=", + "optional": true, "requires": { "nanoid": "^3.0.1", "open": "^7.0.3", - "pupa": "^2.0.0", "source-map": "^0.7.3", - "yargs": "^15.0.0" + "yargs": "^16.0.3" }, "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npm.taobao.org/ansi-styles/download/ansi-styles-4.3.0.tgz?cache=0&sync_timestamp=1601839226460&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fansi-styles%2Fdownload%2Fansi-styles-4.3.0.tgz", + "integrity": "sha1-7dgDYornHATIWuegkG7a00tkiTc=", + "optional": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "cliui": { + "version": "7.0.4", + "resolved": "https://registry.npm.taobao.org/cliui/download/cliui-7.0.4.tgz", + "integrity": "sha1-oCZe5lVHb8gHrqnfPfjfd4OAi08=", + "optional": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npm.taobao.org/color-convert/download/color-convert-2.0.1.tgz", + "integrity": "sha1-ctOmjVmMm9s68q0ehPIdiWq9TeM=", + "optional": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npm.taobao.org/color-name/download/color-name-1.1.4.tgz", + "integrity": "sha1-wqCah6y95pVD3m9j+jmVyCbFNqI=", + "optional": true + }, "source-map": { "version": "0.7.3", "resolved": "https://registry.npm.taobao.org/source-map/download/source-map-0.7.3.tgz?cache=0&sync_timestamp=1571657176668&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsource-map%2Fdownload%2Fsource-map-0.7.3.tgz", "integrity": "sha1-UwL4FpAxc1ImVECS5kmB91F1A4M=", - "dev": true + "optional": true + }, + "wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npm.taobao.org/wrap-ansi/download/wrap-ansi-7.0.0.tgz", + "integrity": "sha1-Z+FFz/UQpqaYS98RUpEdadLrnkM=", + "optional": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "y18n": { + "version": "5.0.5", + "resolved": "https://registry.npm.taobao.org/y18n/download/y18n-5.0.5.tgz?cache=0&sync_timestamp=1603639294538&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fy18n%2Fdownload%2Fy18n-5.0.5.tgz", + "integrity": "sha1-h2nsCNA7HqLfJQCs71YXQ7u5qxg=", + "optional": true + }, + "yargs": { + "version": "16.1.0", + "resolved": "https://registry.npm.taobao.org/yargs/download/yargs-16.1.0.tgz?cache=0&sync_timestamp=1602805577427&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fyargs%2Fdownload%2Fyargs-16.1.0.tgz", + "integrity": "sha1-/DM/5HkWYOrOWolLOdQvhRzUjyo=", + "optional": true, + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.2", + "yargs-parser": "^20.2.2" + } + }, + "yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npm.taobao.org/yargs-parser/download/yargs-parser-20.2.4.tgz?cache=0&sync_timestamp=1604886709178&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fyargs-parser%2Fdownload%2Fyargs-parser-20.2.4.tgz", + "integrity": "sha1-tCiQ8UVmeW+Fro46JSkNIF8VSlQ=", + "optional": true } } }, diff --git a/scripts/build-engine/package.json b/scripts/build-engine/package.json index 56ca0c5d0c..4efcedabc1 100644 --- a/scripts/build-engine/package.json +++ b/scripts/build-engine/package.json @@ -1,8 +1,16 @@ { "name": "@cocos/build-engine", - "version": "4.0.0-jsb.alpha.15", + "version": "4.0.0-beta.0", "description": "", + "repository": { + "type": "git", + "url": "https://github.com/cocos-creator/engine.git", + "directory": "scripts/build-engine" + }, "main": "dist/index.js", + "files": [ + "dist/" + ], "dependencies": { "@babel/core": "^7.9.0", "@babel/plugin-transform-classes": "^7.8.6", @@ -32,16 +40,19 @@ "@types/node": "^13.1.7", "@types/resolve": "^1.17.1", "@types/semver": "^7.3.4", - "@types/yargs": "^15.0.4", - "rollup-plugin-visualizer": "^4.0.4" + "@types/yargs": "^15.0.4" }, "peerDependencies": { "typescript": "^3.7.2" }, "scripts": { - "build": "tsc", - "prepublishOnly": "npm run build" + "build": "npx tsc", + "clear": "node ./scripts/clear.mjs", + "prepublishOnly": "npm run clear & npm run build" }, "author": "", - "license": "MIT" + "license": "MIT", + "optionalDependencies": { + "rollup-plugin-visualizer": "^4.2.0" + } } diff --git a/scripts/build-engine/scripts/clear.mjs b/scripts/build-engine/scripts/clear.mjs new file mode 100644 index 0000000000..f714e796ec --- /dev/null +++ b/scripts/build-engine/scripts/clear.mjs @@ -0,0 +1,5 @@ + +import fs from 'fs-extra'; +import { URL, fileURLToPath } from 'url'; + +await fs.emptyDir(fileURLToPath(new URL('../dist', import.meta.url))); diff --git a/scripts/build-engine/src/index.ts b/scripts/build-engine/src/index.ts index 70b876a442..a62c4aacaa 100644 --- a/scripts/build-engine/src/index.ts +++ b/scripts/build-engine/src/index.ts @@ -1,4 +1,3 @@ - import fs from 'fs-extra'; import ps from 'path'; import rpBabel, { RollupBabelInputPluginOptions } from '@rollup/plugin-babel'; @@ -9,22 +8,22 @@ import { terser as rpTerser } from 'rollup-plugin-terser'; import babelPresetEnv from '@babel/preset-env'; import type { Options as babelPresetEnvOptions } from '@babel/preset-env'; import babelPresetCc from '@cocos/babel-preset-cc'; -// @ts-ignore +// @ts-expect-error: No typing import babelPluginTransformForOf from '@babel/plugin-transform-for-of'; import * as rollup from 'rollup'; -// @ts-ignore +// @ts-expect-error: No typing import rpProgress from 'rollup-plugin-progress'; -// @ts-ignore +// @ts-expect-error: No typing import rpVirtual from '@rollup/plugin-virtual'; +import nodeResolve from 'resolve'; +import JSON5 from 'json5'; +import babelPluginDynamicImportVars from '@cocos/babel-plugin-dynamic-import-vars'; import { ModuleOption, enumerateModuleOptionReps, parseModuleOption } from './module-option'; import { generateCCSource } from './make-cc'; -import nodeResolve from 'resolve'; import { getModuleName } from './module-name'; import tsConfigPaths from './ts-paths'; -import JSON5 from 'json5'; import { getPlatformConstantNames, IBuildTimeConstants } from './build-time-constants'; import removeDeprecatedFeatures from './remove-deprecated-features'; -import babelPluginDynamicImportVars from '@cocos/babel-plugin-dynamic-import-vars'; export { ModuleOption, enumerateModuleOptionReps, parseModuleOption }; @@ -37,7 +36,7 @@ async function build (options: build.Options) { let moduleEntries: string[]; if (!options.moduleEntries || options.moduleEntries.length === 0) { - console.debug(`No module entry specified, default module entries will be used.`); + console.debug('No module entry specified, default module entries will be used.'); moduleEntries = await getDefaultModuleEntries(options.engine); } else { moduleEntries = options.moduleEntries; @@ -107,7 +106,7 @@ namespace build { * - 为 `true` 时使用 WebAssembly 版本的 ammo.js; * - 为 `false` 时使用 asm.js 版本的 ammo.js; * - 为 `'fallback` 时同时在结果中包含两个版本的 ammo.js,并自动根据环境 fallback 选择。 - * + * * 注意,`'fallback'` 只有在 SystemJS 和 Async functions 同时支持时才有效。 * @default false */ @@ -156,7 +155,6 @@ namespace build { */ exports: Record; - dependencyGraph?: Record; } } @@ -207,9 +205,9 @@ async function _doBuild ({ const rollupFormat = moduleOptionsToRollupFormat(moduleOption); let { ammoJsWasm } = options; - if (ammoJsWasm === 'fallback' && - moduleOption !== ModuleOption.system) { - console.warn(`--ammojs-wasm=fallback is only available under SystemJS target.`); + if (ammoJsWasm === 'fallback' + && moduleOption !== ModuleOption.system) { + console.warn('--ammojs-wasm=fallback is only available under SystemJS target.'); ammoJsWasm = false; } @@ -226,14 +224,14 @@ async function _doBuild ({ console.debug(`Module source "internal-constants":\n${vmInternalConstants}`); rpVirtualOptions['internal:constants'] = vmInternalConstants; - const forceStandaloneModules = [ 'cc.wait-for-ammo-instantiation', 'cc.decorator' ]; + const forceStandaloneModules = ['cc.wait-for-ammo-instantiation', 'cc.decorator']; let rollupEntries: NonNullable | undefined; if (split) { - rollupEntries = Object.assign({}, engineEntries); + rollupEntries = { ...engineEntries }; } else { rollupEntries = { - 'cc': 'cc', + cc: 'cc', }; const bundledModules = []; for (const moduleName of Object.keys(engineEntries)) { @@ -245,14 +243,17 @@ async function _doBuild ({ } } - rpVirtualOptions['cc'] = generateCCSource(bundledModules); - rollupEntries['cc'] = 'cc'; + rpVirtualOptions.cc = generateCCSource(bundledModules); + rollupEntries.cc = 'cc'; - console.debug(`Module source "cc":\n${rpVirtualOptions['cc']}`); + console.debug(`Module source "cc":\n${rpVirtualOptions.cc}`); } const presetEnvOptions: babelPresetEnvOptions = { loose: options.loose ?? true, + // We need explicitly specified targets. + // Ignore it to avoid the engine's parent dirs contain unexpected config. + ignoreBrowserslistConfig: true, }; if (options.targets !== undefined) { presetEnvOptions.targets = options.targets; @@ -273,14 +274,27 @@ async function _doBuild ({ }], ); - const babelOptions: RollupBabelInputPluginOptions = { + interface BabelOverrides { + overrides?: Array<{ + test: RegExp | string; + } & babel.TransformOptions>, + } + + const babelOptions: RollupBabelInputPluginOptions & BabelOverrides = { babelHelpers: 'bundled', extensions: ['.js', '.ts'], exclude: [ - /node_modules[\/\\]@cocos[\/\\]ammo/g, - /node_modules[\/\\]@cocos[\/\\]cannon/g, + /node_modules[/\\]@cocos[/\\]ammo/g, + /node_modules[/\\]@cocos[/\\]cannon/g, ], - highlightCode: true, + comments: false, // Do not preserve comments, even in debug build since we have source map + overrides: [{ + // Eliminates the babel compact warning: + // 'The code generator has deoptimised the styling of ...' + // that came from node_modules/@cocos + test: /node_modules[/\\]@cocos[/\\]/g, + compact: true, + }], plugins: babelPlugins, presets: [ [babelPresetEnv, presetEnvOptions], @@ -306,13 +320,14 @@ async function _doBuild ({ const rollupPlugins: rollup.Plugin[] = []; if (options.noDeprecatedFeatures) { rollupPlugins.push(removeDeprecatedFeatures( - typeof options.noDeprecatedFeatures === 'string' ? options.noDeprecatedFeatures : undefined)); + typeof options.noDeprecatedFeatures === 'string' ? options.noDeprecatedFeatures : undefined, + )); } rollupPlugins.push( { name: '@cocos/build-engine|module-overrides', - load: function (this, id: string) { + load (this, id: string) { const key = makePathEqualityKey(id); if (!(key in moduleRedirects)) { return null; @@ -363,7 +378,7 @@ async function _doBuild ({ beautify: !doUglify, }, sourcemap: !!options.sourceMap, - + // https://github.com/rollup/rollup/issues/3315 // We only do this for CommonJS. // Especially, we cannot do this for IIFE. @@ -371,15 +386,16 @@ async function _doBuild ({ })); } - const visualizeOptions = typeof options.visualize === 'object' ? - options.visualize: - (options.visualize ? {} : undefined); + const visualizeOptions = typeof options.visualize === 'object' + ? options.visualize + : (options.visualize ? {} : undefined); if (visualizeOptions) { let rpVisualizer; try { - rpVisualizer = require('rollup-plugin-visualizer'); + // @ts-expect-error: No typing + rpVisualizer = await import('rollup-plugin-visualizer'); } catch { - console.warn(`Visualizing needs 'rollup-plugin-visualizer' to be installed. It's installed as dev-dependency.`); + console.warn('Visualizing needs \'rollup-plugin-visualizer\' to be installed. It\'s installed as dev-dependency.'); } if (rpVisualizer) { const visualizeFile = visualizeOptions.file ?? ps.join(options.out, 'visualize.html'); @@ -426,16 +442,17 @@ export { isWasm }; const { incremental: incrementalFile } = options; if (incrementalFile) { const watchFiles: Record = {}; - for (const watchFile of rollupBuild.watchFiles.concat([ + const files = rollupBuild.watchFiles.concat([ ccConfigFile, - ])) { + ]); + await Promise.all(files.map(async (watchFile) => { try { const stat = await fs.stat(watchFile); watchFiles[watchFile] = stat.mtimeMs; } catch { // the `watchFiles` may contain non-fs modules. } - } + })); await fs.ensureDir(ps.dirname(incrementalFile)); await fs.writeFile(incrementalFile, JSON.stringify(watchFiles, undefined, 2)); } @@ -500,7 +517,8 @@ export { isWasm }; if (ammoJsWasm === 'fallback' || ammoJsWasm === true) { await fs.copy( ps.join(ammoJsWasmModule, '..', 'ammo.wasm.wasm'), - ps.join(options.out, 'ammo.wasm.wasm')); + ps.join(options.out, 'ammo.wasm.wasm'), + ); } return result; @@ -520,14 +538,14 @@ export { isWasm }; if (err) { reject(err); } else { - r(resolved); + r(resolved as string); } }); }); } } -function filePathToModuleRequest(path: string) { +function filePathToModuleRequest (path: string) { return path.replace(/\\/g, '\\\\'); } @@ -535,17 +553,17 @@ function getModuleSourceInternalConstants (buildTimeConstants: IBuildTimeConstan return Object.entries(buildTimeConstants).map(([k, v]) => `export const ${k} = ${v};`).join('\n'); } -function moduleOptionsToRollupFormat(moduleOptions: ModuleOption): rollup.ModuleFormat { +function moduleOptionsToRollupFormat (moduleOptions: ModuleOption): rollup.ModuleFormat { switch (moduleOptions) { - case ModuleOption.cjs: return 'cjs'; - case ModuleOption.esm: return 'esm'; - case ModuleOption.system: return 'system'; - case ModuleOption.iife: return 'iife'; - default: throw new Error(`Unknown module format ${moduleOptions}`); + case ModuleOption.cjs: return 'cjs'; + case ModuleOption.esm: return 'esm'; + case ModuleOption.system: return 'system'; + case ModuleOption.iife: return 'iife'; + default: throw new Error(`Unknown module format ${moduleOptions}`); } } -export async function isSourceChanged(incrementalFile: string) { +export async function isSourceChanged (incrementalFile: string) { let record: Record; try { record = await fs.readJSON(incrementalFile); @@ -556,6 +574,7 @@ export async function isSourceChanged(incrementalFile: string) { for (const file of Object.keys(record)) { const mtime = record[file]; try { + /* eslint-disable-next-line no-await-in-loop */ const mtimeNow = (await fs.stat(file)).mtimeMs; if (mtimeNow !== mtime) { console.debug(`Source ${file} in watch files record ${incrementalFile} has a different time stamp - rebuild is needed.`); @@ -574,9 +593,7 @@ async function getDefaultModuleEntries (engine: string) { type GroupItem = any; // import('../../scripts/module-division/tools/division-config').GroupItem; type Item = any; // import('../../scripts/module-division/tools/division-config').Item; - const isGroupItem = (item: Item): item is GroupItem => { - return 'options' in item; - }; + const isGroupItem = (item: Item): item is GroupItem => 'options' in item; const divisionConfig: ModuleDivision = await fs.readJSON(ps.join(engine, 'scripts', 'module-division', 'division-config.json')); const result: string[] = []; @@ -594,7 +611,7 @@ async function getDefaultModuleEntries (engine: string) { if (isGroupItem(item)) { addEntry(item.options[item.defaultOption || 0].entry); } else { - // @ts-ignore + // @ts-expect-error: By convention addEntry(item.entry); } }