@tarojs/runtime 3.6.22-nightly.6 → 3.6.22-nightly.8

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/index.d.ts CHANGED
@@ -31,3 +31,4 @@ export { incrementId, isHasExtractProp } from "./utils/index.js";
31
31
  export * from "./utils/router.js";
32
32
  export * from "./instance-0f017c6e.js";
33
33
  export * from "./index-26658829.js";
34
+ export * from "./polyfill/index.js";
package/dist/index.js CHANGED
@@ -29,4 +29,5 @@ export { nextTick } from './next-tick.js';
29
29
  export { options } from './options.js';
30
30
  export { incrementId, isHasExtractProp } from './utils/index.js';
31
31
  export { addLeadingSlash, getCurrentPage, getHomePage, hasBasename, stripBasename, stripSuffix, stripTrailing } from './utils/router.js';
32
+ export { handlePolyfill } from './polyfill/index.js';
32
33
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,3 @@
1
+ declare function handleArrayFindPolyfill(): void;
2
+ declare function handleArrayIncludesPolyfill(): void;
3
+ export { handleArrayFindPolyfill, handleArrayIncludesPolyfill };
@@ -0,0 +1,56 @@
1
+ import { isFunction } from '@tarojs/shared';
2
+
3
+ function handleArrayFindPolyfill() {
4
+ if (!isFunction(Array.prototype.find)) {
5
+ Object.defineProperty(Array.prototype, 'find', {
6
+ value(predicate) {
7
+ if (this == null) {
8
+ throw new TypeError('"this" is null or not defined');
9
+ }
10
+ const o = Object(this);
11
+ const len = o.length >>> 0;
12
+ if (!isFunction(predicate)) {
13
+ throw new TypeError('predicate must be a function');
14
+ }
15
+ const thisArg = arguments[1];
16
+ let k = 0;
17
+ while (k < len) {
18
+ const kValue = o[k];
19
+ if (predicate.call(thisArg, kValue, k, o)) {
20
+ return kValue;
21
+ }
22
+ k++;
23
+ }
24
+ return undefined;
25
+ }
26
+ });
27
+ }
28
+ }
29
+ function handleArrayIncludesPolyfill() {
30
+ if (!isFunction(Array.prototype.includes)) {
31
+ Object.defineProperty(Array.prototype, 'includes', {
32
+ value(searchElement, fromIndex) {
33
+ if (this == null) {
34
+ throw new TypeError('"this" is null or not defined');
35
+ }
36
+ const o = Object(this);
37
+ const len = o.length >>> 0;
38
+ if (len === 0) {
39
+ return false;
40
+ }
41
+ const n = fromIndex | 0;
42
+ let k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
43
+ while (k < len) {
44
+ if (o[k] === searchElement) {
45
+ return true;
46
+ }
47
+ k++;
48
+ }
49
+ return false;
50
+ }
51
+ });
52
+ }
53
+ }
54
+
55
+ export { handleArrayFindPolyfill, handleArrayIncludesPolyfill };
56
+ //# sourceMappingURL=array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.js","sources":["../../src/polyfill/array.ts"],"sourcesContent":["import { isFunction } from '@tarojs/shared'\n\nexport function handleArrayFindPolyfill () {\n if (!isFunction(Array.prototype.find)) {\n Object.defineProperty(Array.prototype, 'find', {\n value (predicate) {\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined')\n }\n const o = Object(this)\n const len = o.length >>> 0\n if (!isFunction(predicate)) {\n throw new TypeError('predicate must be a function')\n }\n const thisArg = arguments[1]\n let k = 0\n while (k < len) {\n const kValue = o[k]\n if (predicate.call(thisArg, kValue, k, o)) {\n return kValue\n }\n k++\n }\n return undefined\n }\n })\n }\n}\n\nexport function handleArrayIncludesPolyfill () {\n if (!isFunction(Array.prototype.includes)) {\n Object.defineProperty(Array.prototype, 'includes', {\n value (searchElement, fromIndex) {\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined')\n }\n const o = Object(this)\n const len = o.length >>> 0\n if (len === 0) {\n return false\n }\n const n = fromIndex | 0\n let k = Math.max(n >= 0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CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,UAAU,EAAE;YACjD,KAAK,CAAE,aAAa,EAAE,SAAS,EAAA;gBAC7B,IAAI,IAAI,IAAI,IAAI,EAAE;AAChB,oBAAA,MAAM,IAAI,SAAS,CAAC,+BAA+B,CAAC,CAAA;AACrD,iBAAA;AACD,gBAAA,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;AACtB,gBAAA,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAAA;gBAC1B,IAAI,GAAG,KAAK,CAAC,EAAE;AACb,oBAAA,OAAO,KAAK,CAAA;AACb,iBAAA;AACD,gBAAA,MAAM,CAAC,GAAG,SAAS,GAAG,CAAC,CAAA;gBACvB,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;gBACnD,OAAO,CAAC,GAAG,GAAG,EAAE;AACd,oBAAA,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,aAAa,EAAE;AAC1B,wBAAA,OAAO,IAAI,CAAA;AACZ,qBAAA;AACD,oBAAA,CAAC,EAAE,CAAA;AACJ,iBAAA;AACD,gBAAA,OAAO,KAAK,CAAA;aACb;AACF,SAAA,CAAC,CAAA;AACH,KAAA;AACH;;;;"}
@@ -0,0 +1,2 @@
1
+ declare function handlePolyfill(): void;
2
+ export { handlePolyfill };
@@ -0,0 +1,34 @@
1
+ import { isObject } from '@tarojs/shared';
2
+ import { handleArrayFindPolyfill, handleArrayIncludesPolyfill } from './array.js';
3
+ import { handleIntersectionObserverPolyfill } from './intersection-observer.js';
4
+ import { handleObjectAssignPolyfill, handleObjectEntriesPolyfill, handleObjectDefinePropertyPolyfill } from './object.js';
5
+
6
+ function handlePolyfill() {
7
+ if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.assign') {
8
+ handleObjectAssignPolyfill();
9
+ }
10
+ if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.entries') {
11
+ handleObjectEntriesPolyfill();
12
+ }
13
+ if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.defineProperty') {
14
+ handleObjectDefinePropertyPolyfill();
15
+ }
16
+ if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Array' || process.env.SUPPORT_TARO_POLYFILL === 'Array.find') {
17
+ handleArrayFindPolyfill();
18
+ }
19
+ if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Array' || process.env.SUPPORT_TARO_POLYFILL === 'Array.includes') {
20
+ handleArrayIncludesPolyfill();
21
+ }
22
+ // Exit early if we're not running in a browser.
23
+ if (process.env.TARO_PLATFORM === 'web' && isObject(window)) {
24
+ if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'IntersectionObserver') {
25
+ handleIntersectionObserverPolyfill();
26
+ }
27
+ }
28
+ }
29
+ if (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFORM !== 'web') {
30
+ handlePolyfill();
31
+ }
32
+
33
+ export { handlePolyfill };
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/polyfill/index.ts"],"sourcesContent":["import { isObject } from '@tarojs/shared'\n\nimport { handleArrayFindPolyfill, handleArrayIncludesPolyfill } from './array'\nimport { handleIntersectionObserverPolyfill } from './intersection-observer'\nimport { handleObjectAssignPolyfill, handleObjectDefinePropertyPolyfill, handleObjectEntriesPolyfill } from './object'\n\nfunction handlePolyfill () {\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.assign') {\n handleObjectAssignPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.entries') {\n handleObjectEntriesPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.defineProperty') {\n handleObjectDefinePropertyPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Array' || process.env.SUPPORT_TARO_POLYFILL === 'Array.find') {\n handleArrayFindPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Array' || process.env.SUPPORT_TARO_POLYFILL === 'Array.includes') {\n handleArrayIncludesPolyfill()\n }\n // Exit early if we're not running in a browser.\n if (process.env.TARO_PLATFORM === 'web' && isObject(window)) {\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'IntersectionObserver') {\n handleIntersectionObserverPolyfill()\n }\n }\n}\n\nif (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFORM !== 'web') {\n handlePolyfill()\n}\n\nexport { handlePolyfill }\n\n"],"names":[],"mappings":";;;;;AAMA,SAAS,cAAc,GAAA;IACrB,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,eAAe,EAAE;AAC9J,QAAA,0BA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