lyb-pixi-js 1.12.2 → 1.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
+ import { LibJsResizeWatcher } from "lyb-js/Base/LibJsResizeWatcher.js";
1
2
  import { Container, Ticker, UPDATE_PRIORITY, } from "pixi.js";
2
- import { LibPixiRectBgColor } from "../Base/LibPixiRectBgColor";
3
+ import { LibPixiRectangle } from "../Base/LibPixiRectangle";
3
4
  import { LibPixiText } from "../Base/LibPixiText";
4
5
  /** @description 监视帧率、Draw Call、Max Draw Call
5
6
  * @link 使用方法:https://www.npmjs.com/package/lyb-pixi-js#LibPixiPerforMon-性能监视器
@@ -27,12 +28,7 @@ export class LibPixiPerforMon extends Container {
27
28
  this._containerHeight = 50;
28
29
  this.pivot.x = this._containerWidth / 2;
29
30
  //创建背景
30
- this._bg = new LibPixiRectBgColor({
31
- width: this._containerWidth,
32
- height: this._containerHeight,
33
- bgColor: "#000",
34
- alpha: 0.75,
35
- });
31
+ this._bg = new LibPixiRectangle(this._containerWidth, this._containerHeight, "#0000007e");
36
32
  this.addChild(this._bg);
37
33
  //创建内容容器
38
34
  const content = new Container();
@@ -53,6 +49,23 @@ export class LibPixiPerforMon extends Container {
53
49
  this._renderer = app.renderer;
54
50
  this._drawElements = this._renderer["gl"].drawElements;
55
51
  this.init();
52
+ if (LibPixiPerforMon.ADAPT_MODE === "h") {
53
+ this.x = 1920 / 2;
54
+ }
55
+ else if (LibPixiPerforMon.ADAPT_MODE === "v") {
56
+ this.x = 1080 / 2;
57
+ }
58
+ else {
59
+ const resize = new LibJsResizeWatcher();
60
+ resize.on((w, h) => {
61
+ if (w > h) {
62
+ this.x = 1920 / 2;
63
+ }
64
+ else {
65
+ this.x = 1080 / 2;
66
+ }
67
+ });
68
+ }
56
69
  }
57
70
  /** @description 初始化显示性能数据 */
58
71
  init() {
package/lyb-pixi.js CHANGED
@@ -1315,7 +1315,7 @@
1315
1315
  var ys = arrObjKeys(obj, inspect2);
1316
1316
  var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
1317
1317
  var protoTag = obj instanceof Object ? "" : "null prototype";
1318
- var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr$1(obj), 8, -1) : protoTag ? "Object" : "";
1318
+ var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
1319
1319
  var constructorTag = isPlainObject || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
1320
1320
  var tag2 = constructorTag + (stringTag || protoTag ? "[" + $join.call($concat$1.call([], stringTag || [], protoTag || []), ": ") + "] " : "");
1321
1321
  if (ys.length === 0) {
@@ -1337,25 +1337,25 @@
1337
1337
  return $replace$1.call(String(s2), /"/g, """);
1338
1338
  }
1339
1339
  function isArray$3(obj) {
1340
- return toStr$1(obj) === "[object Array]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1340
+ return toStr(obj) === "[object Array]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1341
1341
  }
1342
1342
  function isDate(obj) {
1343
- return toStr$1(obj) === "[object Date]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1343
+ return toStr(obj) === "[object Date]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1344
1344
  }
1345
1345
  function isRegExp$1(obj) {
1346
- return toStr$1(obj) === "[object RegExp]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1346
+ return toStr(obj) === "[object RegExp]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1347
1347
  }
1348
1348
  function isError(obj) {
1349
- return toStr$1(obj) === "[object Error]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1349
+ return toStr(obj) === "[object Error]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1350
1350
  }
1351
1351
  function isString(obj) {
1352
- return toStr$1(obj) === "[object String]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1352
+ return toStr(obj) === "[object String]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1353
1353
  }
1354
1354
  function isNumber(obj) {
1355
- return toStr$1(obj) === "[object Number]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1355
+ return toStr(obj) === "[object Number]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1356
1356
  }
1357
1357
  function isBoolean(obj) {
1358
- return toStr$1(obj) === "[object Boolean]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1358
+ return toStr(obj) === "[object Boolean]" && (!toStringTag || !(typeof obj === "object" && toStringTag in obj));
1359
1359
  }
1360
1360
  function isSymbol(obj) {
1361
1361
  if (hasShammedSymbols) {
@@ -1391,7 +1391,7 @@
1391
1391
  function has$3(obj, key) {
1392
1392
  return hasOwn$1.call(obj, key);
1393
1393
  }
1394
- function toStr$1(obj) {
1394
+ function toStr(obj) {
1395
1395
  return objectToString.call(obj);
1396
1396
  }
1397
1397
  function nameOf(f2) {
@@ -1700,7 +1700,7 @@
1700
1700
  var uri = URIError;
1701
1701
  var abs$2 = Math.abs;
1702
1702
  var floor$2 = Math.floor;
1703
- var max$3 = Math.max;
1703
+ var max$2 = Math.max;
1704
1704
  var min$2 = Math.min;
1705
1705
  var pow$2 = Math.pow;
1706
1706
  var round$3 = Math.round;
@@ -1833,78 +1833,102 @@
1833
1833
  Object_getPrototypeOf = $Object2.getPrototypeOf || null;
1834
1834
  return Object_getPrototypeOf;
1835
1835
  }
1836
- var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
1837
- var toStr = Object.prototype.toString;
1838
- var max$2 = Math.max;
1839
- var funcType = "[object Function]";
1840
- var concatty = function concatty2(a2, b2) {
1841
- var arr = [];
1842
- for (var i2 = 0; i2 < a2.length; i2 += 1) {
1843
- arr[i2] = a2[i2];
1844
- }
1845
- for (var j2 = 0; j2 < b2.length; j2 += 1) {
1846
- arr[j2 + a2.length] = b2[j2];
1847
- }
1848
- return arr;
1849
- };
1850
- var slicy = function slicy2(arrLike, offset) {
1851
- var arr = [];
1852
- for (var i2 = offset || 0, j2 = 0; i2 < arrLike.length; i2 += 1, j2 += 1) {
1853
- arr[j2] = arrLike[i2];
1854
- }
1855
- return arr;
1856
- };
1857
- var joiny = function(arr, joiner) {
1858
- var str = "";
1859
- for (var i2 = 0; i2 < arr.length; i2 += 1) {
1860
- str += arr[i2];
1861
- if (i2 + 1 < arr.length) {
1862
- str += joiner;
1836
+ var implementation;
1837
+ var hasRequiredImplementation;
1838
+ function requireImplementation() {
1839
+ if (hasRequiredImplementation)
1840
+ return implementation;
1841
+ hasRequiredImplementation = 1;
1842
+ var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
1843
+ var toStr2 = Object.prototype.toString;
1844
+ var max2 = Math.max;
1845
+ var funcType = "[object Function]";
1846
+ var concatty = function concatty2(a2, b2) {
1847
+ var arr = [];
1848
+ for (var i2 = 0; i2 < a2.length; i2 += 1) {
1849
+ arr[i2] = a2[i2];
1863
1850
  }
1864
- }
1865
- return str;
1866
- };
1867
- var implementation$1 = function bind2(that) {
1868
- var target = this;
1869
- if (typeof target !== "function" || toStr.apply(target) !== funcType) {
1870
- throw new TypeError(ERROR_MESSAGE + target);
1871
- }
1872
- var args = slicy(arguments, 1);
1873
- var bound;
1874
- var binder = function() {
1875
- if (this instanceof bound) {
1876
- var result = target.apply(
1877
- this,
1878
- concatty(args, arguments)
1879
- );
1880
- if (Object(result) === result) {
1881
- return result;
1851
+ for (var j2 = 0; j2 < b2.length; j2 += 1) {
1852
+ arr[j2 + a2.length] = b2[j2];
1853
+ }
1854
+ return arr;
1855
+ };
1856
+ var slicy = function slicy2(arrLike, offset) {
1857
+ var arr = [];
1858
+ for (var i2 = offset || 0, j2 = 0; i2 < arrLike.length; i2 += 1, j2 += 1) {
1859
+ arr[j2] = arrLike[i2];
1860
+ }
1861
+ return arr;
1862
+ };
1863
+ var joiny = function(arr, joiner) {
1864
+ var str = "";
1865
+ for (var i2 = 0; i2 < arr.length; i2 += 1) {
1866
+ str += arr[i2];
1867
+ if (i2 + 1 < arr.length) {
1868
+ str += joiner;
1882
1869
  }
1883
- return this;
1884
1870
  }
1885
- return target.apply(
1886
- that,
1887
- concatty(args, arguments)
1888
- );
1871
+ return str;
1889
1872
  };
1890
- var boundLength = max$2(0, target.length - args.length);
1891
- var boundArgs = [];
1892
- for (var i2 = 0; i2 < boundLength; i2++) {
1893
- boundArgs[i2] = "$" + i2;
1894
- }
1895
- bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
1896
- if (target.prototype) {
1897
- var Empty = function Empty2() {
1873
+ implementation = function bind2(that) {
1874
+ var target = this;
1875
+ if (typeof target !== "function" || toStr2.apply(target) !== funcType) {
1876
+ throw new TypeError(ERROR_MESSAGE + target);
1877
+ }
1878
+ var args = slicy(arguments, 1);
1879
+ var bound;
1880
+ var binder = function() {
1881
+ if (this instanceof bound) {
1882
+ var result = target.apply(
1883
+ this,
1884
+ concatty(args, arguments)
1885
+ );
1886
+ if (Object(result) === result) {
1887
+ return result;
1888
+ }
1889
+ return this;
1890
+ }
1891
+ return target.apply(
1892
+ that,
1893
+ concatty(args, arguments)
1894
+ );
1898
1895
  };
1899
- Empty.prototype = target.prototype;
1900
- bound.prototype = new Empty();
1901
- Empty.prototype = null;
1902
- }
1903
- return bound;
1904
- };
1905
- var implementation = implementation$1;
1906
- var functionBind = Function.prototype.bind || implementation;
1907
- var functionCall = Function.prototype.call;
1896
+ var boundLength = max2(0, target.length - args.length);
1897
+ var boundArgs = [];
1898
+ for (var i2 = 0; i2 < boundLength; i2++) {
1899
+ boundArgs[i2] = "$" + i2;
1900
+ }
1901
+ bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
1902
+ if (target.prototype) {
1903
+ var Empty = function Empty2() {
1904
+ };
1905
+ Empty.prototype = target.prototype;
1906
+ bound.prototype = new Empty();
1907
+ Empty.prototype = null;
1908
+ }
1909
+ return bound;
1910
+ };
1911
+ return implementation;
1912
+ }
1913
+ var functionBind;
1914
+ var hasRequiredFunctionBind;
1915
+ function requireFunctionBind() {
1916
+ if (hasRequiredFunctionBind)
1917
+ return functionBind;
1918
+ hasRequiredFunctionBind = 1;
1919
+ var implementation2 = requireImplementation();
1920
+ functionBind = Function.prototype.bind || implementation2;
1921
+ return functionBind;
1922
+ }
1923
+ var functionCall;
1924
+ var hasRequiredFunctionCall;
1925
+ function requireFunctionCall() {
1926
+ if (hasRequiredFunctionCall)
1927
+ return functionCall;
1928
+ hasRequiredFunctionCall = 1;
1929
+ functionCall = Function.prototype.call;
1930
+ return functionCall;
1931
+ }
1908
1932
  var functionApply;
1909
1933
  var hasRequiredFunctionApply;
1910
1934
  function requireFunctionApply() {
@@ -1915,14 +1939,14 @@
1915
1939
  return functionApply;
1916
1940
  }
1917
1941
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
1918
- var bind$2 = functionBind;
1942
+ var bind$2 = requireFunctionBind();
1919
1943
  var $apply$1 = requireFunctionApply();
1920
- var $call$2 = functionCall;
1944
+ var $call$2 = requireFunctionCall();
1921
1945
  var $reflectApply = reflectApply;
1922
1946
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
1923
- var bind$1 = functionBind;
1947
+ var bind$1 = requireFunctionBind();
1924
1948
  var $TypeError$4 = type;
1925
- var $call$1 = functionCall;
1949
+ var $call$1 = requireFunctionCall();
1926
1950
  var $actualApply = actualApply;
1927
1951
  var callBindApplyHelpers = function callBindBasic2(args) {
1928
1952
  if (args.length < 1 || typeof args[0] !== "function") {
@@ -1991,7 +2015,7 @@
1991
2015
  hasRequiredHasown = 1;
1992
2016
  var call = Function.prototype.call;
1993
2017
  var $hasOwn = Object.prototype.hasOwnProperty;
1994
- var bind2 = functionBind;
2018
+ var bind2 = requireFunctionBind();
1995
2019
  hasown = bind2.call(call, $hasOwn);
1996
2020
  return hasown;
1997
2021
  }
@@ -2006,7 +2030,7 @@
2006
2030
  var $URIError = uri;
2007
2031
  var abs$1 = abs$2;
2008
2032
  var floor$1 = floor$2;
2009
- var max$1 = max$3;
2033
+ var max$1 = max$2;
2010
2034
  var min$1 = min$2;
2011
2035
  var pow$1 = pow$2;
2012
2036
  var round$2 = round$3;
@@ -2040,7 +2064,7 @@
2040
2064
  var $ObjectGPO = requireObject_getPrototypeOf();
2041
2065
  var $ReflectGPO = requireReflect_getPrototypeOf();
2042
2066
  var $apply = requireFunctionApply();
2043
- var $call = functionCall;
2067
+ var $call = requireFunctionCall();
2044
2068
  var needsEval = {};
2045
2069
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
2046
2070
  var INTRINSICS = {
@@ -2210,7 +2234,7 @@
2210
2234
  "%WeakMapPrototype%": ["WeakMap", "prototype"],
2211
2235
  "%WeakSetPrototype%": ["WeakSet", "prototype"]
2212
2236
  };
2213
- var bind = functionBind;
2237
+ var bind = requireFunctionBind();
2214
2238
  var hasOwn = requireHasown();
2215
2239
  var $concat = bind.call($call, Array.prototype.concat);
2216
2240
  var $spliceApply = bind.call($apply, Array.prototype.splice);
@@ -48939,7 +48963,72 @@ void main(void)\r
48939
48963
  });
48940
48964
  }
48941
48965
  }
48942
- class LibPixiPerforMon extends Container {
48966
+ class LibJsResizeWatcher {
48967
+ constructor(mode = "hv") {
48968
+ this._listeners = [];
48969
+ this._handleResize = () => {
48970
+ const w2 = window.innerWidth;
48971
+ const h2 = window.innerHeight;
48972
+ let s2;
48973
+ const orientation = w2 > h2 ? "h" : "v";
48974
+ if (orientation === "h") {
48975
+ s2 = Math.min(w2 / 1920, h2 / 1080);
48976
+ } else {
48977
+ s2 = Math.min(w2 / 1080, h2 / 1920);
48978
+ }
48979
+ this._listeners.forEach(({ cb }) => cb(w2, h2, s2));
48980
+ };
48981
+ this._mode = mode;
48982
+ if (mode === "h" || mode === "v")
48983
+ return;
48984
+ window.addEventListener("resize", this._handleResize);
48985
+ }
48986
+ /**
48987
+ * @description 注册一个窗口尺寸变化的监听器
48988
+ * @param cb 回调函数,参数为当前窗口宽度和高度
48989
+ * @param immediate 是否在注册时立即执行一次回调,默认为 true
48990
+ * @returns 一个函数,用于移除该监听器
48991
+ */
48992
+ on(cb, immediate = true) {
48993
+ const w2 = window.innerWidth;
48994
+ const h2 = window.innerHeight;
48995
+ const orientation = w2 > h2 ? "h" : "v";
48996
+ if (this._mode === "h") {
48997
+ immediate && cb(1920, 1080, Math.min(w2 / 1920, h2 / 1080));
48998
+ return () => {
48999
+ };
49000
+ } else if (this._mode === "v") {
49001
+ immediate && cb(1080, 1920, Math.min(w2 / 1080, h2 / 1920));
49002
+ return () => {
49003
+ };
49004
+ }
49005
+ let s2;
49006
+ if (orientation === "h") {
49007
+ s2 = Math.min(w2 / 1920, h2 / 1080);
49008
+ } else {
49009
+ s2 = Math.min(w2 / 1080, h2 / 1920);
49010
+ }
49011
+ const item = { cb, immediate };
49012
+ this._listeners.push(item);
49013
+ if (immediate)
49014
+ cb(window.innerWidth, window.innerHeight, s2);
49015
+ return () => {
49016
+ this._listeners = this._listeners.filter((l2) => l2 !== item);
49017
+ };
49018
+ }
49019
+ }
49020
+ class LibPixiRectangle extends Graphics {
49021
+ constructor(width, height, color) {
49022
+ super();
49023
+ this.beginFill(color || 0);
49024
+ this.drawRect(0, 0, width, height);
49025
+ this.endFill();
49026
+ if (!color) {
49027
+ this.alpha = 0;
49028
+ }
49029
+ }
49030
+ }
49031
+ const _LibPixiPerforMon = class _LibPixiPerforMon2 extends Container {
48943
49032
  constructor(app) {
48944
49033
  super();
48945
49034
  this.COLLECT_TIME = 5 * 1e3;
@@ -48952,12 +49041,11 @@ void main(void)\r
48952
49041
  this._containerWidth = 590;
48953
49042
  this._containerHeight = 50;
48954
49043
  this.pivot.x = this._containerWidth / 2;
48955
- this._bg = new LibPixiRectBgColor({
48956
- width: this._containerWidth,
48957
- height: this._containerHeight,
48958
- bgColor: "#000",
48959
- alpha: 0.75
48960
- });
49044
+ this._bg = new LibPixiRectangle(
49045
+ this._containerWidth,
49046
+ this._containerHeight,
49047
+ "#0000007e"
49048
+ );
48961
49049
  this.addChild(this._bg);
48962
49050
  const content = new Container();
48963
49051
  this.addChild(content);
@@ -48974,6 +49062,20 @@ void main(void)\r
48974
49062
  this._renderer = app.renderer;
48975
49063
  this._drawElements = this._renderer["gl"].drawElements;
48976
49064
  this.init();
49065
+ if (_LibPixiPerforMon2.ADAPT_MODE === "h") {
49066
+ this.x = 1920 / 2;
49067
+ } else if (_LibPixiPerforMon2.ADAPT_MODE === "v") {
49068
+ this.x = 1080 / 2;
49069
+ } else {
49070
+ const resize = new LibJsResizeWatcher();
49071
+ resize.on((w2, h2) => {
49072
+ if (w2 > h2) {
49073
+ this.x = 1920 / 2;
49074
+ } else {
49075
+ this.x = 1080 / 2;
49076
+ }
49077
+ });
49078
+ }
48977
49079
  }
48978
49080
  /** @description 初始化显示性能数据 */
48979
49081
  init() {
@@ -49039,8 +49141,9 @@ void main(void)\r
49039
49141
  }
49040
49142
  return color;
49041
49143
  }
49042
- }
49043
- LibPixiPerforMon.ADAPT_MODE = "hv";
49144
+ };
49145
+ _LibPixiPerforMon.ADAPT_MODE = "hv";
49146
+ let LibPixiPerforMon = _LibPixiPerforMon;
49044
49147
  class TextBox extends Container {
49045
49148
  constructor(text, fontSize = 26) {
49046
49149
  super();
@@ -49237,17 +49340,6 @@ void main(void)\r
49237
49340
  }
49238
49341
  }
49239
49342
  }
49240
- class LibPixiRectangle extends Graphics {
49241
- constructor(width, height, color) {
49242
- super();
49243
- this.beginFill(color || 0);
49244
- this.drawRect(0, 0, width, height);
49245
- this.endFill();
49246
- if (!color) {
49247
- this.alpha = 0;
49248
- }
49249
- }
49250
- }
49251
49343
  class LibPixiScrollContainerY extends LibPixiContainer {
49252
49344
  constructor(params) {
49253
49345
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lyb-pixi-js",
3
- "version": "1.12.2",
3
+ "version": "1.12.3",
4
4
  "description": "自用Pixi.JS方法库",
5
5
  "license": "ISC",
6
6
  "exports": {