@micro-zoe/micro-app 1.0.0-rc.27 → 1.0.0-rc.29

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/lib/index.d.ts CHANGED
@@ -113,7 +113,7 @@ declare module '@micro-zoe/micro-app/libs/utils' {
113
113
  import { Func, LocationQueryObject, MicroLocation, AttrsType, fiberTasks, MicroAppElementTagNameMap, MicroAppElementInterface } from '@micro-app/types';
114
114
  export const version = "__MICRO_APP_VERSION__";
115
115
  export const isBrowser: boolean;
116
- export const globalThis: any;
116
+ export const globalObj: any;
117
117
  export const noop: () => void;
118
118
  export const noopFalse: () => boolean;
119
119
  export const isArray: (arg: any) => arg is any[];
package/lib/index.esm.js CHANGED
@@ -1,12 +1,16 @@
1
- const version = '1.0.0-rc.27';
1
+ const version = '1.0.0-rc.29';
2
2
  // do not use isUndefined
3
3
  const isBrowser = typeof window !== 'undefined';
4
4
  // do not use isUndefined
5
- const globalThis = (typeof global !== 'undefined')
6
- ? global
7
- : ((typeof window !== 'undefined')
8
- ? window
9
- : ((typeof self !== 'undefined') ? self : Function('return this')()));
5
+ const globalObj = typeof globalThis !== 'undefined'
6
+ ? globalThis
7
+ : typeof global !== 'undefined'
8
+ ? global
9
+ : typeof window !== 'undefined'
10
+ ? window
11
+ : typeof self !== 'undefined'
12
+ ? self
13
+ : Function('return this')();
10
14
  const noopFalse = () => false;
11
15
  // Array.isArray
12
16
  const isArray = Array.isArray;
@@ -233,7 +237,7 @@ const createURL = (function () {
233
237
  * @param url address
234
238
  */
235
239
  function addProtocol(url) {
236
- return url.startsWith('//') ? `${globalThis.location.protocol}${url}` : url;
240
+ return url.startsWith('//') ? `${globalObj.location.protocol}${url}` : url;
237
241
  }
238
242
  /**
239
243
  * format URL address
@@ -355,7 +359,7 @@ function unique(array) {
355
359
  }, Object.create(null));
356
360
  }
357
361
  // requestIdleCallback polyfill
358
- const requestIdleCallback = globalThis.requestIdleCallback ||
362
+ const requestIdleCallback = globalObj.requestIdleCallback ||
359
363
  function (fn) {
360
364
  const lastTime = Date.now();
361
365
  return setTimeout(function () {
@@ -6006,13 +6010,29 @@ function patchDocumentPrototype(appName, microAppWindow) {
6006
6010
  const rawMicroGetElementsByName = microRootDocument.prototype.getElementsByName;
6007
6011
  const rawMicroElementFromPoint = microRootDocument.prototype.elementFromPoint;
6008
6012
  const rawMicroCaretRangeFromPoint = microRootDocument.prototype.caretRangeFromPoint;
6009
- microRootDocument.prototype.caretRangeFromPoint = function caretRangeFromPoint(x, y) {
6010
- // 这里this指向document才可以获取到子应用的document实例,range才可以被成功生成
6011
- const element = rawMicroElementFromPoint.call(rawDocument, x, y);
6012
- const range = rawMicroCaretRangeFromPoint.call(rawDocument, x, y);
6013
- updateElementInfo(element, appName);
6014
- return range;
6015
- };
6013
+ const rawMicroCaretPositionFromPoint = microRootDocument.prototype.caretPositionFromPoint;
6014
+ /**
6015
+ * Firefox does not support caretRangeFromPoint
6016
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Document/caretRangeFromPoint
6017
+ */
6018
+ if (isFunction(rawMicroCaretRangeFromPoint)) {
6019
+ microRootDocument.prototype.caretRangeFromPoint = function caretRangeFromPoint(x, y) {
6020
+ // 这里this指向document才可以获取到子应用的document实例,range才可以被成功生成
6021
+ const element = rawMicroElementFromPoint.call(rawDocument, x, y);
6022
+ const range = rawMicroCaretRangeFromPoint.call(rawDocument, x, y);
6023
+ updateElementInfo(element, appName);
6024
+ return range;
6025
+ };
6026
+ }
6027
+ if (isFunction(rawMicroCaretPositionFromPoint)) {
6028
+ microRootDocument.prototype.caretPositionFromPoint = function caretPositionFromPoint(x, y) {
6029
+ // 这里this指向document才可以获取到子应用的document实例,range才可以被成功生成
6030
+ const element = rawMicroElementFromPoint.call(rawDocument, x, y);
6031
+ const range = rawMicroCaretPositionFromPoint.call(rawDocument, x, y);
6032
+ updateElementInfo(element, appName);
6033
+ return range;
6034
+ };
6035
+ }
6016
6036
  microRootDocument.prototype.createElement = function createElement(tagName, options) {
6017
6037
  let element = rawMicroCreateElement.call(getElementDocument(this, rawDocument), tagName, options);
6018
6038
  if (isWebComponentElement(element)) {