@leafer-game/miniapp 1.4.1 → 1.5.0

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.
package/dist/miniapp.cjs CHANGED
@@ -6,66 +6,43 @@ var state = require('@leafer-in/state');
6
6
  var animate = require('@leafer-in/animate');
7
7
  var motionPath = require('@leafer-in/motion-path');
8
8
  var find = require('@leafer-in/find');
9
- var core = require('@leafer/core');
10
9
 
11
- const systemInfo = wx.getSystemInfoSync();
12
- const platform = systemInfo.platform;
13
- if (platform === 'ios') {
14
- core.LeaferImage.prototype.getPattern = function (canvas, repeat, transform, paint) {
15
- const pattern = core.Platform.canvas.createPattern(this.view, repeat);
16
- const { width, height } = canvas;
17
- if (this.width !== width || this.height !== height) {
18
- if (!transform)
19
- transform = core.MatrixHelper.get();
20
- core.MatrixHelper.scale(transform, width / this.width, height / this.height);
21
- }
22
- try {
23
- if (transform && pattern.setTransform) {
24
- pattern.setTransform(transform);
25
- transform = null;
26
- }
27
- }
28
- catch (_a) { }
29
- if (paint)
30
- paint.transform = transform;
31
- return pattern;
32
- };
33
- }
10
+
34
11
 
35
12
  Object.keys(miniapp).forEach(function (k) {
36
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
37
- enumerable: true,
38
- get: function () { return miniapp[k]; }
39
- });
13
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
14
+ enumerable: true,
15
+ get: function () { return miniapp[k]; }
16
+ });
40
17
  });
41
18
  Object.keys(robot).forEach(function (k) {
42
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
43
- enumerable: true,
44
- get: function () { return robot[k]; }
45
- });
19
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
20
+ enumerable: true,
21
+ get: function () { return robot[k]; }
22
+ });
46
23
  });
47
24
  Object.keys(state).forEach(function (k) {
48
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
49
- enumerable: true,
50
- get: function () { return state[k]; }
51
- });
25
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
26
+ enumerable: true,
27
+ get: function () { return state[k]; }
28
+ });
52
29
  });
53
30
  Object.keys(animate).forEach(function (k) {
54
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
55
- enumerable: true,
56
- get: function () { return animate[k]; }
57
- });
31
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
32
+ enumerable: true,
33
+ get: function () { return animate[k]; }
34
+ });
58
35
  });
59
36
  Object.keys(motionPath).forEach(function (k) {
60
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
61
- enumerable: true,
62
- get: function () { return motionPath[k]; }
63
- });
37
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
38
+ enumerable: true,
39
+ get: function () { return motionPath[k]; }
40
+ });
64
41
  });
65
42
  Object.keys(find).forEach(function (k) {
66
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
67
- enumerable: true,
68
- get: function () { return find[k]; }
69
- });
43
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
44
+ enumerable: true,
45
+ get: function () { return find[k]; }
46
+ });
70
47
  });
71
48
  //# sourceMappingURL=miniapp.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"miniapp.cjs","sources":["../../../../../../../src/miniapp/src/patch.ts"],"sourcesContent":["\nimport { IMatrixData, ILeaferImagePatternPaint, ICanvasPattern } from '@leafer/interface'\nimport { MatrixHelper, Platform, LeaferImage } from '@leafer/core'\n\n/**\n * android、ios下不支持离屏画布对画\n */\n\n// LeaferCanvas.prototype.__createContext = function () {\n// if (this.viewSelect) {\n// const offscreenView = Platform.origin.createCanvas(1, 1)\n// const context = this.view.getContext('2d')\n\n// this.testView = this.view\n// this.testContext = context\n// this.view = offscreenView\n// }\n\n// this.context = this.view.getContext('2d')\n// this.__bindContext()\n// }\n\n// LeaferCanvas.prototype.updateRender = function (bounds: IBoundsData) {\n// if (this.testView) {\n\n// // 把离屏画布同步到视图画布中: imageData 复制模式 android / ios均有效\n// const { x, y, width, height } = this.bounds.getIntersect(bounds).scale(this.pixelRatio).ceil()\n// let data = this.context.getImageData(x, y, width, height)\n// this.testContext.clearRect(x, y, width, height)\n// this.testContext.putImageData(data, x, y)\n// data = null\n\n// // pattern 下只有 android 有效\n// // let pattern = this.context.createPattern(this.view, Platform.origin.noRepeat)\n// // this.testContext.clearRect(0, 0, this.view.width, this.view.height)\n// // this.testContext.fillStyle = pattern\n// // this.testContext.fillRect(0, 0, this.view.width, this.view.height)\n// // this.testContext.fillStyle = pattern = null\n// }\n// }\n\n// LeaferCanvas.prototype.updateViewSize = function () {\n// const { width, height, pixelRatio, view, testView } = this\n// view.width = width * pixelRatio\n// view.height = height * pixelRatio\n\n// if (testView) {\n// testView.width = view.width\n// testView.height = view.height\n// }\n// }\n\n\n/**\n * ios 下图案填充不能使用离屏画布,改用原图\n */\n\nconst systemInfo = wx.getSystemInfoSync()\nconst platform = systemInfo.platform\n\nif (platform === 'ios') {\n\n LeaferImage.prototype.getPattern = function (canvas: any, repeat: string | null, transform?: IMatrixData, paint?: ILeaferImagePatternPaint): ICanvasPattern {\n //const pattern = Platform.canvas.createPattern(canvas, repeat)\n const pattern = Platform.canvas.createPattern(this.view, repeat)\n\n // 增加使用原图的矩阵\n const { width, height } = canvas\n if (this.width !== width || this.height !== height) {\n if (!transform) transform = MatrixHelper.get()\n MatrixHelper.scale(transform, width / this.width, height / this.height)\n }\n\n try {\n if (transform && pattern.setTransform) {\n pattern.setTransform(transform) // maybe error \n transform = null\n }\n } catch { }\n\n if (paint) paint.transform = transform\n return pattern\n }\n\n}"],"names":["LeaferImage","Platform","MatrixHelper"],"mappings":";;;;;;;;;;AAyDA,MAAM,UAAU,GAAG,EAAE,CAAC,iBAAiB,EAAE;AACzC,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ;AAEpC,IAAI,QAAQ,KAAK,KAAK,EAAE;AAEpB,IAAAA,gBAAW,CAAC,SAAS,CAAC,UAAU,GAAG,UAAU,MAAW,EAAE,MAAqB,EAAE,SAAuB,EAAE,KAAgC,EAAA;AAEtI,QAAA,MAAM,OAAO,GAAGC,aAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;AAGhE,QAAA,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;AAChC,QAAA,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE;AAChD,YAAA,IAAI,CAAC,SAAS;AAAE,gBAAA,SAAS,GAAGC,iBAAY,CAAC,GAAG,EAAE;AAC9C,YAAAA,iBAAY,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;;AAG3E,QAAA,IAAI;AACA,YAAA,IAAI,SAAS,IAAI,OAAO,CAAC,YAAY,EAAE;AACnC,gBAAA,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC;gBAC/B,SAAS,GAAG,IAAI;;;QAEtB,OAAM,EAAA,EAAA;AAER,QAAA,IAAI,KAAK;AAAE,YAAA,KAAK,CAAC,SAAS,GAAG,SAAS;AACtC,QAAA,OAAO,OAAO;AAClB,KAAC;AAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"miniapp.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -4,29 +4,4 @@ export * from '@leafer-in/state';
4
4
  export * from '@leafer-in/animate';
5
5
  export * from '@leafer-in/motion-path';
6
6
  export * from '@leafer-in/find';
7
- import { LeaferImage, Platform, MatrixHelper } from '@leafer/core';
8
-
9
- const systemInfo = wx.getSystemInfoSync();
10
- const platform = systemInfo.platform;
11
- if (platform === 'ios') {
12
- LeaferImage.prototype.getPattern = function (canvas, repeat, transform, paint) {
13
- const pattern = Platform.canvas.createPattern(this.view, repeat);
14
- const { width, height } = canvas;
15
- if (this.width !== width || this.height !== height) {
16
- if (!transform)
17
- transform = MatrixHelper.get();
18
- MatrixHelper.scale(transform, width / this.width, height / this.height);
19
- }
20
- try {
21
- if (transform && pattern.setTransform) {
22
- pattern.setTransform(transform);
23
- transform = null;
24
- }
25
- }
26
- catch (_a) { }
27
- if (paint)
28
- paint.transform = transform;
29
- return pattern;
30
- };
31
- }
32
7
  //# sourceMappingURL=miniapp.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"miniapp.esm.js","sources":["../../../../../../../src/miniapp/src/patch.ts"],"sourcesContent":["\nimport { IMatrixData, ILeaferImagePatternPaint, ICanvasPattern } from '@leafer/interface'\nimport { MatrixHelper, Platform, LeaferImage } from '@leafer/core'\n\n/**\n * android、ios下不支持离屏画布对画\n */\n\n// LeaferCanvas.prototype.__createContext = function () {\n// if (this.viewSelect) {\n// const offscreenView = Platform.origin.createCanvas(1, 1)\n// const context = this.view.getContext('2d')\n\n// this.testView = this.view\n// this.testContext = context\n// this.view = offscreenView\n// }\n\n// this.context = this.view.getContext('2d')\n// this.__bindContext()\n// }\n\n// LeaferCanvas.prototype.updateRender = function (bounds: IBoundsData) {\n// if (this.testView) {\n\n// // 把离屏画布同步到视图画布中: imageData 复制模式 android / ios均有效\n// const { x, y, width, height } = this.bounds.getIntersect(bounds).scale(this.pixelRatio).ceil()\n// let data = this.context.getImageData(x, y, width, height)\n// this.testContext.clearRect(x, y, width, height)\n// this.testContext.putImageData(data, x, y)\n// data = null\n\n// // pattern 下只有 android 有效\n// // let pattern = this.context.createPattern(this.view, Platform.origin.noRepeat)\n// // this.testContext.clearRect(0, 0, this.view.width, this.view.height)\n// // this.testContext.fillStyle = pattern\n// // this.testContext.fillRect(0, 0, this.view.width, this.view.height)\n// // this.testContext.fillStyle = pattern = null\n// }\n// }\n\n// LeaferCanvas.prototype.updateViewSize = function () {\n// const { width, height, pixelRatio, view, testView } = this\n// view.width = width * pixelRatio\n// view.height = height * pixelRatio\n\n// if (testView) {\n// testView.width = view.width\n// testView.height = view.height\n// }\n// }\n\n\n/**\n * ios 下图案填充不能使用离屏画布,改用原图\n */\n\nconst systemInfo = wx.getSystemInfoSync()\nconst platform = systemInfo.platform\n\nif (platform === 'ios') {\n\n LeaferImage.prototype.getPattern = function (canvas: any, repeat: string | null, transform?: IMatrixData, paint?: ILeaferImagePatternPaint): ICanvasPattern {\n //const pattern = Platform.canvas.createPattern(canvas, repeat)\n const pattern = Platform.canvas.createPattern(this.view, repeat)\n\n // 增加使用原图的矩阵\n const { width, height } = canvas\n if (this.width !== width || this.height !== height) {\n if (!transform) transform = MatrixHelper.get()\n MatrixHelper.scale(transform, width / this.width, height / this.height)\n }\n\n try {\n if (transform && pattern.setTransform) {\n pattern.setTransform(transform) // maybe error \n transform = null\n }\n } catch { }\n\n if (paint) paint.transform = transform\n return pattern\n }\n\n}"],"names":[],"mappings":";;;;;;;;AAyDA,MAAM,UAAU,GAAG,EAAE,CAAC,iBAAiB,EAAE;AACzC,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ;AAEpC,IAAI,QAAQ,KAAK,KAAK,EAAE;AAEpB,IAAA,WAAW,CAAC,SAAS,CAAC,UAAU,GAAG,UAAU,MAAW,EAAE,MAAqB,EAAE,SAAuB,EAAE,KAAgC,EAAA;AAEtI,QAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;AAGhE,QAAA,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;AAChC,QAAA,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE;AAChD,YAAA,IAAI,CAAC,SAAS;AAAE,gBAAA,SAAS,GAAG,YAAY,CAAC,GAAG,EAAE;AAC9C,YAAA,YAAY,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;;AAG3E,QAAA,IAAI;AACA,YAAA,IAAI,SAAS,IAAI,OAAO,CAAC,YAAY,EAAE;AACnC,gBAAA,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC;gBAC/B,SAAS,GAAG,IAAI;;;QAEtB,OAAM,EAAA,EAAA;AAER,QAAA,IAAI,KAAK;AAAE,YAAA,KAAK,CAAC,SAAS,GAAG,SAAS;AACtC,QAAA,OAAO,OAAO;AAClB,KAAC;AAEL"}
1
+ {"version":3,"file":"miniapp.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -1,2 +1,2 @@
1
- export*from"@leafer-ui/miniapp";export*from"@leafer-in/robot";export*from"@leafer-in/state";export*from"@leafer-in/animate";export*from"@leafer-in/motion-path";export*from"@leafer-in/find";import{LeaferImage as t,Platform as e,MatrixHelper as r}from"@leafer/core";"ios"===wx.getSystemInfoSync().platform&&(t.prototype.getPattern=function(t,o,i,a){const n=e.canvas.createPattern(this.view,o),{width:f,height:h}=t;this.width===f&&this.height===h||(i||(i=r.get()),r.scale(i,f/this.width,h/this.height));try{i&&n.setTransform&&(n.setTransform(i),i=null)}catch(t){}return a&&(a.transform=i),n});
1
+ export*from"@leafer-ui/miniapp";export*from"@leafer-in/robot";export*from"@leafer-in/state";export*from"@leafer-in/animate";export*from"@leafer-in/motion-path";export*from"@leafer-in/find";
2
2
  //# sourceMappingURL=miniapp.esm.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"miniapp.esm.min.js","sources":["../../../../../../../src/miniapp/src/patch.ts"],"sourcesContent":["\nimport { IMatrixData, ILeaferImagePatternPaint, ICanvasPattern } from '@leafer/interface'\nimport { MatrixHelper, Platform, LeaferImage } from '@leafer/core'\n\n/**\n * android、ios下不支持离屏画布对画\n */\n\n// LeaferCanvas.prototype.__createContext = function () {\n// if (this.viewSelect) {\n// const offscreenView = Platform.origin.createCanvas(1, 1)\n// const context = this.view.getContext('2d')\n\n// this.testView = this.view\n// this.testContext = context\n// this.view = offscreenView\n// }\n\n// this.context = this.view.getContext('2d')\n// this.__bindContext()\n// }\n\n// LeaferCanvas.prototype.updateRender = function (bounds: IBoundsData) {\n// if (this.testView) {\n\n// // 把离屏画布同步到视图画布中: imageData 复制模式 android / ios均有效\n// const { x, y, width, height } = this.bounds.getIntersect(bounds).scale(this.pixelRatio).ceil()\n// let data = this.context.getImageData(x, y, width, height)\n// this.testContext.clearRect(x, y, width, height)\n// this.testContext.putImageData(data, x, y)\n// data = null\n\n// // pattern 下只有 android 有效\n// // let pattern = this.context.createPattern(this.view, Platform.origin.noRepeat)\n// // this.testContext.clearRect(0, 0, this.view.width, this.view.height)\n// // this.testContext.fillStyle = pattern\n// // this.testContext.fillRect(0, 0, this.view.width, this.view.height)\n// // this.testContext.fillStyle = pattern = null\n// }\n// }\n\n// LeaferCanvas.prototype.updateViewSize = function () {\n// const { width, height, pixelRatio, view, testView } = this\n// view.width = width * pixelRatio\n// view.height = height * pixelRatio\n\n// if (testView) {\n// testView.width = view.width\n// testView.height = view.height\n// }\n// }\n\n\n/**\n * ios 下图案填充不能使用离屏画布,改用原图\n */\n\nconst systemInfo = wx.getSystemInfoSync()\nconst platform = systemInfo.platform\n\nif (platform === 'ios') {\n\n LeaferImage.prototype.getPattern = function (canvas: any, repeat: string | null, transform?: IMatrixData, paint?: ILeaferImagePatternPaint): ICanvasPattern {\n //const pattern = Platform.canvas.createPattern(canvas, repeat)\n const pattern = Platform.canvas.createPattern(this.view, repeat)\n\n // 增加使用原图的矩阵\n const { width, height } = canvas\n if (this.width !== width || this.height !== height) {\n if (!transform) transform = MatrixHelper.get()\n MatrixHelper.scale(transform, width / this.width, height / this.height)\n }\n\n try {\n if (transform && pattern.setTransform) {\n pattern.setTransform(transform) // maybe error \n transform = null\n }\n } catch { }\n\n if (paint) paint.transform = transform\n return pattern\n }\n\n}"],"names":["wx","getSystemInfoSync","platform","LeaferImage","prototype","getPattern","canvas","repeat","transform","paint","pattern","Platform","createPattern","this","view","width","height","MatrixHelper","get","scale","setTransform","_a"],"mappings":"wQA4DiB,QAHEA,GAAGC,oBACMC,WAIxBC,EAAYC,UAAUC,WAAa,SAAUC,EAAaC,EAAuBC,EAAyBC,GAEtG,MAAMC,EAAUC,EAASL,OAAOM,cAAcC,KAAKC,KAAMP,IAGnDQ,MAAEA,EAAKC,OAAEA,GAAWV,EACtBO,KAAKE,QAAUA,GAASF,KAAKG,SAAWA,IACnCR,IAAWA,EAAYS,EAAaC,OACzCD,EAAaE,MAAMX,EAAWO,EAAQF,KAAKE,MAAOC,EAASH,KAAKG,SAGpE,IACQR,GAAaE,EAAQU,eACrBV,EAAQU,aAAaZ,GACrBA,EAAY,MAElB,MAAMa,GAAA,CAGR,OADIZ,IAAOA,EAAMD,UAAYA,GACtBE,CACV"}
1
+ {"version":3,"file":"miniapp.esm.min.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("@leafer-ui/miniapp"),t=require("@leafer-in/robot"),r=require("@leafer-in/state"),n=require("@leafer-in/animate"),o=require("@leafer-in/motion-path"),a=require("@leafer-in/find"),i=require("@leafer/core");"ios"===wx.getSystemInfoSync().platform&&(i.LeaferImage.prototype.getPattern=function(e,t,r,n){const o=i.Platform.canvas.createPattern(this.view,t),{width:a,height:c}=e;this.width===a&&this.height===c||(r||(r=i.MatrixHelper.get()),i.MatrixHelper.scale(r,a/this.width,c/this.height));try{r&&o.setTransform&&(o.setTransform(r),r=null)}catch(e){}return n&&(n.transform=r),o}),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})),Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(r).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return r[e]}})})),Object.keys(n).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return n[e]}})})),Object.keys(o).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return o[e]}})})),Object.keys(a).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return a[e]}})}));
1
+ "use strict";var e=require("@leafer-ui/miniapp"),t=require("@leafer-in/robot"),r=require("@leafer-in/state"),o=require("@leafer-in/animate"),n=require("@leafer-in/motion-path"),c=require("@leafer-in/find");Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})),Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(r).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return r[e]}})})),Object.keys(o).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return o[e]}})})),Object.keys(n).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return n[e]}})})),Object.keys(c).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return c[e]}})}));
2
2
  //# sourceMappingURL=miniapp.min.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"miniapp.min.cjs","sources":["../../../../../../../src/miniapp/src/patch.ts"],"sourcesContent":["\nimport { IMatrixData, ILeaferImagePatternPaint, ICanvasPattern } from '@leafer/interface'\nimport { MatrixHelper, Platform, LeaferImage } from '@leafer/core'\n\n/**\n * android、ios下不支持离屏画布对画\n */\n\n// LeaferCanvas.prototype.__createContext = function () {\n// if (this.viewSelect) {\n// const offscreenView = Platform.origin.createCanvas(1, 1)\n// const context = this.view.getContext('2d')\n\n// this.testView = this.view\n// this.testContext = context\n// this.view = offscreenView\n// }\n\n// this.context = this.view.getContext('2d')\n// this.__bindContext()\n// }\n\n// LeaferCanvas.prototype.updateRender = function (bounds: IBoundsData) {\n// if (this.testView) {\n\n// // 把离屏画布同步到视图画布中: imageData 复制模式 android / ios均有效\n// const { x, y, width, height } = this.bounds.getIntersect(bounds).scale(this.pixelRatio).ceil()\n// let data = this.context.getImageData(x, y, width, height)\n// this.testContext.clearRect(x, y, width, height)\n// this.testContext.putImageData(data, x, y)\n// data = null\n\n// // pattern 下只有 android 有效\n// // let pattern = this.context.createPattern(this.view, Platform.origin.noRepeat)\n// // this.testContext.clearRect(0, 0, this.view.width, this.view.height)\n// // this.testContext.fillStyle = pattern\n// // this.testContext.fillRect(0, 0, this.view.width, this.view.height)\n// // this.testContext.fillStyle = pattern = null\n// }\n// }\n\n// LeaferCanvas.prototype.updateViewSize = function () {\n// const { width, height, pixelRatio, view, testView } = this\n// view.width = width * pixelRatio\n// view.height = height * pixelRatio\n\n// if (testView) {\n// testView.width = view.width\n// testView.height = view.height\n// }\n// }\n\n\n/**\n * ios 下图案填充不能使用离屏画布,改用原图\n */\n\nconst systemInfo = wx.getSystemInfoSync()\nconst platform = systemInfo.platform\n\nif (platform === 'ios') {\n\n LeaferImage.prototype.getPattern = function (canvas: any, repeat: string | null, transform?: IMatrixData, paint?: ILeaferImagePatternPaint): ICanvasPattern {\n //const pattern = Platform.canvas.createPattern(canvas, repeat)\n const pattern = Platform.canvas.createPattern(this.view, repeat)\n\n // 增加使用原图的矩阵\n const { width, height } = canvas\n if (this.width !== width || this.height !== height) {\n if (!transform) transform = MatrixHelper.get()\n MatrixHelper.scale(transform, width / this.width, height / this.height)\n }\n\n try {\n if (transform && pattern.setTransform) {\n pattern.setTransform(transform) // maybe error \n transform = null\n }\n } catch { }\n\n if (paint) paint.transform = transform\n return pattern\n }\n\n}"],"names":["wx","getSystemInfoSync","platform","LeaferImage","prototype","getPattern","canvas","repeat","transform","paint","pattern","Platform","createPattern","this","view","width","height","MatrixHelper","get","scale","setTransform","_a"],"mappings":"wOA4DiB,QAHEA,GAAGC,oBACMC,WAIxBC,EAAWA,YAACC,UAAUC,WAAa,SAAUC,EAAaC,EAAuBC,EAAyBC,GAEtG,MAAMC,EAAUC,EAAAA,SAASL,OAAOM,cAAcC,KAAKC,KAAMP,IAGnDQ,MAAEA,EAAKC,OAAEA,GAAWV,EACtBO,KAAKE,QAAUA,GAASF,KAAKG,SAAWA,IACnCR,IAAWA,EAAYS,EAAYA,aAACC,OACzCD,eAAaE,MAAMX,EAAWO,EAAQF,KAAKE,MAAOC,EAASH,KAAKG,SAGpE,IACQR,GAAaE,EAAQU,eACrBV,EAAQU,aAAaZ,GACrBA,EAAY,MAElB,MAAMa,GAAA,CAGR,OADIZ,IAAOA,EAAMD,UAAYA,GACtBE,CACV"}
1
+ {"version":3,"file":"miniapp.min.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -3635,7 +3635,12 @@ const Resource = {
3635
3635
  return R.map[key];
3636
3636
  },
3637
3637
  remove(key) {
3638
- delete R.map[key];
3638
+ const r = R.map[key];
3639
+ if (r) {
3640
+ if (r.destroy)
3641
+ r.destroy();
3642
+ delete R.map[key];
3643
+ }
3639
3644
  },
3640
3645
  loadImage(key, format) {
3641
3646
  return new Promise((resolve, reject) => {
@@ -3661,6 +3666,7 @@ const Resource = {
3661
3666
  const R = Resource;
3662
3667
 
3663
3668
  const ImageManager = {
3669
+ maxRecycled: 100,
3664
3670
  recycledList: [],
3665
3671
  patternTasker: new TaskProcessor(),
3666
3672
  get(config) {
@@ -3677,13 +3683,8 @@ const ImageManager = {
3677
3683
  },
3678
3684
  clearRecycled() {
3679
3685
  const list = I$1.recycledList;
3680
- if (list.length > 100) {
3681
- list.forEach(image => {
3682
- if (!image.use && image.url) {
3683
- Resource.remove(image.url);
3684
- image.destroy();
3685
- }
3686
- });
3686
+ if (list.length > I$1.maxRecycled) {
3687
+ list.forEach(image => (!image.use && image.url) && Resource.remove(image.url));
3687
3688
  list.length = 0;
3688
3689
  }
3689
3690
  },
@@ -4069,12 +4070,11 @@ function defineDataProcessor(target, key, defaultValue) {
4069
4070
  if (defaultValue === undefined) {
4070
4071
  property.get = function () { return this[computedKey]; };
4071
4072
  }
4072
- else if (typeof defaultValue === 'object') {
4073
- const { clone } = DataHelper;
4073
+ else if (typeof defaultValue === 'function') {
4074
4074
  property.get = function () {
4075
4075
  let v = this[computedKey];
4076
4076
  if (v === undefined)
4077
- this[computedKey] = v = clone(defaultValue);
4077
+ this[computedKey] = v = defaultValue(this.__leaf);
4078
4078
  return v;
4079
4079
  };
4080
4080
  }
@@ -5721,10 +5721,10 @@ let Leaf = class Leaf {
5721
5721
  static changeAttr(attrName, defaultValue, fn) {
5722
5722
  fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
5723
5723
  }
5724
- static addAttr(attrName, defaultValue, fn) {
5724
+ static addAttr(attrName, defaultValue, fn, helpValue) {
5725
5725
  if (!fn)
5726
5726
  fn = boundsType;
5727
- fn(defaultValue)(this.prototype, attrName);
5727
+ fn(defaultValue, helpValue)(this.prototype, attrName);
5728
5728
  }
5729
5729
  __emitLifeEvent(type) {
5730
5730
  if (this.hasEvent(type))
@@ -6051,7 +6051,7 @@ class LeafLevelList {
6051
6051
  }
6052
6052
  }
6053
6053
 
6054
- const version = "1.4.1";
6054
+ const version = "1.5.0";
6055
6055
 
6056
6056
  class LeaferCanvas extends LeaferCanvasBase {
6057
6057
  get allowBackgroundColor() { return false; }
@@ -7077,7 +7077,11 @@ const State = {
7077
7077
  setStyleName() { return Plugin.need('state'); },
7078
7078
  set() { return Plugin.need('state'); }
7079
7079
  };
7080
- const Transition = {};
7080
+ const Transition = {
7081
+ list: {},
7082
+ register(attrName, fn) { Transition.list[attrName] = fn; },
7083
+ get(attrName) { return Transition.list[attrName]; }
7084
+ };
7081
7085
 
7082
7086
  const { parse, objectToCanvasData } = PathConvert;
7083
7087
  const emptyPaint = {};
@@ -7501,9 +7505,6 @@ let UI = UI_1 = class UI extends Leaf {
7501
7505
  this.__drawPathByBox(pen);
7502
7506
  return pen;
7503
7507
  }
7504
- get editConfig() { return undefined; }
7505
- get editOuter() { return ''; }
7506
- get editInner() { return ''; }
7507
7508
  constructor(data) {
7508
7509
  super(data);
7509
7510
  }
@@ -7585,8 +7586,11 @@ let UI = UI_1 = class UI extends Leaf {
7585
7586
  export(_filename, _options) {
7586
7587
  return Plugin.need('export');
7587
7588
  }
7589
+ syncExport(_filename, _options) {
7590
+ return Plugin.need('export');
7591
+ }
7588
7592
  clone(data) {
7589
- const json = this.toJSON();
7593
+ const json = DataHelper.clone(this.toJSON());
7590
7594
  if (data)
7591
7595
  Object.assign(json, data);
7592
7596
  return UI_1.one(json);
@@ -7885,7 +7889,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7885
7889
  get layoutLocked() { return !this.layouter.running; }
7886
7890
  get FPS() { return this.renderer ? this.renderer.FPS : 60; }
7887
7891
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
7888
- get clientBounds() { return this.canvas && this.canvas.getClientBounds(); }
7892
+ get clientBounds() { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData(); }
7889
7893
  constructor(userConfig, data) {
7890
7894
  super(data);
7891
7895
  this.config = {
@@ -8187,6 +8191,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8187
8191
  getPagePointByClient(clientPoint, updateClient) {
8188
8192
  return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
8189
8193
  }
8194
+ getClientPointByWorld(worldPoint) {
8195
+ const { x, y } = this.clientBounds;
8196
+ return { x: x + worldPoint.x, y: y + worldPoint.y };
8197
+ }
8190
8198
  updateClientBounds() {
8191
8199
  this.canvas && this.canvas.updateClientBounds();
8192
8200
  }
@@ -10155,8 +10163,6 @@ ui$5.__updateHitCanvas = function () {
10155
10163
  h.setStrokeOptions(data);
10156
10164
  };
10157
10165
  ui$5.__hit = function (inner) {
10158
- if (Platform.name === 'miniapp')
10159
- this.__drawHitPath(this.__hitCanvas);
10160
10166
  const data = this.__;
10161
10167
  if (data.__isHitPixel && this.__hitPixel(inner))
10162
10168
  return true;
@@ -11616,13 +11622,14 @@ function toChar(data, charX, rowData, isOverflow) {
11616
11622
  }
11617
11623
 
11618
11624
  function layoutText(drawData, style) {
11619
- const { rows, bounds } = drawData;
11625
+ const { rows, bounds } = drawData, countRows = rows.length;
11620
11626
  const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
11621
- let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11627
+ let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11622
11628
  let starY = __baseLine;
11623
11629
  if (__clipText && realHeight > height) {
11624
11630
  realHeight = Math.max(height, __lineHeight);
11625
- drawData.overflow = rows.length;
11631
+ if (countRows > 1)
11632
+ drawData.overflow = countRows;
11626
11633
  }
11627
11634
  else if (height || autoSizeAlign) {
11628
11635
  switch (verticalAlign) {
@@ -11634,7 +11641,7 @@ function layoutText(drawData, style) {
11634
11641
  }
11635
11642
  starY += y;
11636
11643
  let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
11637
- for (let i = 0, len = rows.length; i < len; i++) {
11644
+ for (let i = 0, len = countRows; i < len; i++) {
11638
11645
  row = rows[i];
11639
11646
  row.x = x;
11640
11647
  if (row.width < width || (row.width > width && !__clipText)) {
@@ -11703,7 +11710,7 @@ function clipText(drawData, style, x, width) {
11703
11710
  if (i === end && charRight < right) {
11704
11711
  break;
11705
11712
  }
11706
- else if (charRight < right && char.char !== ' ') {
11713
+ else if ((charRight < right && char.char !== ' ') || !i) {
11707
11714
  row.data.splice(i + 1);
11708
11715
  row.width -= char.width;
11709
11716
  break;
@@ -12300,17 +12307,17 @@ State.getStyle = getStyle;
12300
12307
  State.updateStyle = updateStyle;
12301
12308
  State.updateEventStyle = updateEventStyle;
12302
12309
  const ui$3 = UI.prototype;
12303
- stateType(false, 'selectedStyle')(ui$3, 'selected');
12304
- stateType(false, 'disabledStyle')(ui$3, 'disabled');
12305
- stateStyleType({})(ui$3, 'states');
12306
- stateType('')(ui$3, 'state');
12307
- dataType()(ui$3, 'normalStyle');
12308
- stateStyleType()(ui$3, 'hoverStyle');
12309
- stateStyleType()(ui$3, 'pressStyle');
12310
- stateStyleType()(ui$3, 'focusStyle');
12311
- stateStyleType()(ui$3, 'selectedStyle');
12312
- stateStyleType()(ui$3, 'disabledStyle');
12313
- dataType(false)(ui$3, 'button');
12310
+ UI.addAttr('selected', false, stateType, 'selectedStyle');
12311
+ UI.addAttr('disabled', false, stateType, 'disabledStyle');
12312
+ UI.addAttr('states', {}, stateStyleType);
12313
+ UI.addAttr('state', '', stateType);
12314
+ UI.addAttr('normalStyle', undefined, dataType);
12315
+ UI.addAttr('hoverStyle', undefined, stateStyleType);
12316
+ UI.addAttr('pressStyle', undefined, stateStyleType);
12317
+ UI.addAttr('focusStyle', undefined, stateStyleType);
12318
+ UI.addAttr('selectedStyle', undefined, stateStyleType);
12319
+ UI.addAttr('disabledStyle', undefined, stateStyleType);
12320
+ UI.addAttr('button', false, dataType);
12314
12321
  ui$3.focus = function (value = true) {
12315
12322
  this.waitLeafer(() => {
12316
12323
  let { focusData } = this.app.interaction;
@@ -13275,7 +13282,6 @@ const TransitionList = {
13275
13282
  innerShadow: shadow
13276
13283
  };
13277
13284
  const TransitionModule = {
13278
- list: TransitionList,
13279
13285
  value,
13280
13286
  number,
13281
13287
  color
@@ -13320,13 +13326,13 @@ function shadow(from, to, t) {
13320
13326
 
13321
13327
  Plugin.add('animate', 'color');
13322
13328
  State.canAnimate = true;
13323
- Object.assign(Transition, Object.assign(Object.assign({}, TransitionModule), { register(attrName, fn) { Transition.list[attrName] = fn; },
13324
- get(attrName) { return Transition.list[attrName]; } }));
13329
+ Object.assign(Transition.list, TransitionList);
13330
+ Object.assign(Transition, TransitionModule);
13325
13331
  const ui$2 = UI.prototype;
13326
- animationType()(ui$2, 'animation');
13327
- dataType()(ui$2, 'animationOut');
13328
- dataType(true)(ui$2, 'transition');
13329
- dataType()(ui$2, 'transitionOut');
13332
+ UI.addAttr('animation', undefined, animationType);
13333
+ UI.addAttr('animationOut', undefined, dataType);
13334
+ UI.addAttr('transition', true, dataType);
13335
+ UI.addAttr('transitionOut', undefined, dataType);
13330
13336
  ui$2.animate = function (keyframe, options, kill, isTemp) {
13331
13337
  if (keyframe === undefined)
13332
13338
  return this.__animate;
@@ -13500,7 +13506,7 @@ const HighCurveHelper = {
13500
13506
  toX = data[i + 1];
13501
13507
  toY = data[i + 2];
13502
13508
  distance = segments[index];
13503
- if (total + distance > motionDistance || !distanceData.total) {
13509
+ if (total + distance >= motionDistance || !distanceData.total) {
13504
13510
  if (!i)
13505
13511
  x = toX, y = toY;
13506
13512
  tempFrom.x = x;
@@ -13519,7 +13525,7 @@ const HighCurveHelper = {
13519
13525
  toX = data[i + 5];
13520
13526
  toY = data[i + 6];
13521
13527
  distance = segments[index];
13522
- if (total + distance > motionDistance) {
13528
+ if (total + distance >= motionDistance) {
13523
13529
  x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
13524
13530
  t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
13525
13531
  BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to);
@@ -13555,7 +13561,7 @@ const HighCurveHelper = {
13555
13561
  toX = data[i + 1];
13556
13562
  toY = data[i + 2];
13557
13563
  distance = segments[index];
13558
- if (total + distance > motionDistance || !distanceData.total) {
13564
+ if (total + distance >= motionDistance || !distanceData.total) {
13559
13565
  if (!i)
13560
13566
  x = toX, y = toY;
13561
13567
  tempFrom.x = x;
@@ -13576,7 +13582,7 @@ const HighCurveHelper = {
13576
13582
  toX = data[i + 5];
13577
13583
  toY = data[i + 6];
13578
13584
  distance = segments[index];
13579
- if (total + distance > motionDistance) {
13585
+ if (total + distance >= motionDistance) {
13580
13586
  t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
13581
13587
  HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY);
13582
13588
  return path;
@@ -13627,10 +13633,10 @@ Transition.register('motionRotation', function (from, to, t) {
13627
13633
  const ui$1 = UI.prototype;
13628
13634
  const { updateMatrix, updateAllMatrix } = LeafHelper;
13629
13635
  const { updateBounds } = BranchHelper;
13630
- motionPathType()(ui$1, 'motionPath');
13631
- motionPathType(1)(ui$1, 'motionPrecision');
13632
- motionPathType()(ui$1, 'motion');
13633
- motionPathType(true)(ui$1, 'motionRotation');
13636
+ UI.addAttr('motionPath', undefined, motionPathType);
13637
+ UI.addAttr('motionPrecision', 1, motionPathType);
13638
+ UI.addAttr('motion', undefined, motionPathType);
13639
+ UI.addAttr('motionRotation', true, motionPathType);
13634
13640
  ui$1.getMotionPathData = function () {
13635
13641
  return getMotionPathData(getMotionPath(this));
13636
13642
  };
@@ -13857,29 +13863,5 @@ Creator.finder = function (target) {
13857
13863
  return new Finder(target);
13858
13864
  };
13859
13865
 
13860
- const systemInfo = wx.getSystemInfoSync();
13861
- const platform = systemInfo.platform;
13862
- if (platform === 'ios') {
13863
- LeaferImage.prototype.getPattern = function (canvas, repeat, transform, paint) {
13864
- const pattern = Platform.canvas.createPattern(this.view, repeat);
13865
- const { width, height } = canvas;
13866
- if (this.width !== width || this.height !== height) {
13867
- if (!transform)
13868
- transform = MatrixHelper.get();
13869
- MatrixHelper.scale(transform, width / this.width, height / this.height);
13870
- }
13871
- try {
13872
- if (transform && pattern.setTransform) {
13873
- pattern.setTransform(transform);
13874
- transform = null;
13875
- }
13876
- }
13877
- catch (_a) { }
13878
- if (paint)
13879
- paint.transform = transform;
13880
- return pattern;
13881
- };
13882
- }
13883
-
13884
13866
  export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Frame, FrameData, Group, GroupData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isNull, layoutProcessor, maskType, motionPathType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$4 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
13885
13867
  //# sourceMappingURL=miniapp.module.js.map