@tarojs/runtime 4.0.0-beta.15 → 4.0.0-beta.17
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/bom/window.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"window.js","sources":["../../src/bom/window.ts"],"sourcesContent":["import { isString } from '@tarojs/shared'\n\nimport { CONTEXT_ACTIONS } from '../constants'\nimport { Events } from '../emitter/emitter'\nimport env from '../env'\nimport { getComputedStyle } from './getComputedStyle'\nimport { History } from './history'\nimport { Location } from './location'\nimport { nav as navigator } from './navigator'\nimport { caf, raf } from './raf'\n\nimport type { TaroHistory } from './history'\nimport type { TaroLocation } from './location'\n\nclass TaroWindow extends Events {\n navigator = navigator\n requestAnimationFrame = raf\n cancelAnimationFrame = caf\n getComputedStyle = getComputedStyle\n Date: DateConstructor\n\n location: TaroLocation\n history: TaroHistory\n XMLHttpRequest?: Partial<XMLHttpRequest>\n\n constructor () {\n super()\n\n const globalProperties = [\n ...Object.getOwnPropertyNames(global || {}),\n ...Object.getOwnPropertySymbols(global || {})\n ]\n\n globalProperties.forEach(property => {\n if (property === 'atob' || property === 'document') return\n if (!Object.prototype.hasOwnProperty.call(this, property)) {\n // 防止小程序环境下,window 上的某些 get 属性在赋值时报错\n try {\n this[property] = global[property]\n } catch (e) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`)\n }\n }\n }\n })\n\n this.Date ||= Date\n\n // 应用启动时,提供给需要读取历史信息的库使用\n this.location = new Location({ window: this }) as any\n // @ts-ignore\n this.history = new History(this.location, { window: this })\n\n this.initEvent()\n }\n\n initEvent () {\n const _location = this.location\n const _history = this.history\n\n this.on(CONTEXT_ACTIONS.INIT, (pageId: string) => {\n // 页面onload,为该页面建立新的上下文信息\n _location.trigger(CONTEXT_ACTIONS.INIT, pageId)\n }, null)\n\n this.on(CONTEXT_ACTIONS.RECOVER, (pageId: string) => {\n // 页面onshow,恢复当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.RECOVER, pageId)\n _history.trigger(CONTEXT_ACTIONS.RECOVER, pageId)\n }, null)\n\n this.on(CONTEXT_ACTIONS.RESTORE, (pageId: string) => {\n // 页面onhide,缓存当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.RESTORE, pageId)\n _history.trigger(CONTEXT_ACTIONS.RESTORE, pageId)\n }, null)\n\n this.on(CONTEXT_ACTIONS.DESTORY, (pageId: string) => {\n // 页面onunload,清除当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.DESTORY, pageId)\n _history.trigger(CONTEXT_ACTIONS.DESTORY, pageId)\n }, null)\n }\n\n get document () {\n return env.document\n }\n\n addEventListener (event: string, callback: (arg: any) => void) {\n if (!isString(event)) return\n this.on(event, callback, null)\n }\n\n removeEventListener (event: string, callback: (arg: any) => void) {\n if (!isString(event)) return\n this.off(event, callback, null)\n }\n\n setTimeout (...args: Parameters<typeof setTimeout>) {\n return setTimeout(...args)\n }\n\n clearTimeout (...args: Parameters<typeof clearTimeout>) {\n return clearTimeout(...args)\n }\n}\n\nexport type { TaroWindow }\nexport const window: TaroWindow = process.env.TARO_PLATFORM === 'web' ? env.window : (env.window = new TaroWindow())\n\nexport const location = window.location\nexport const history = window.history\n
|
|
1
|
+
{"version":3,"file":"window.js","sources":["../../src/bom/window.ts"],"sourcesContent":["import { isString } from '@tarojs/shared'\n\nimport { CONTEXT_ACTIONS } from '../constants'\nimport { Events } from '../emitter/emitter'\nimport env from '../env'\nimport { getComputedStyle } from './getComputedStyle'\nimport { History } from './history'\nimport { Location } from './location'\nimport { nav as navigator } from './navigator'\nimport { caf, raf } from './raf'\n\nimport type { TaroHistory } from './history'\nimport type { TaroLocation } from './location'\n\nclass TaroWindow extends Events {\n navigator = navigator\n requestAnimationFrame = raf\n cancelAnimationFrame = caf\n getComputedStyle = getComputedStyle\n Date: DateConstructor\n\n location: TaroLocation\n history: TaroHistory\n XMLHttpRequest?: Partial<XMLHttpRequest>\n\n constructor () {\n super()\n\n const globalProperties = [\n ...Object.getOwnPropertyNames(global || {}),\n ...Object.getOwnPropertySymbols(global || {})\n ]\n\n globalProperties.forEach(property => {\n if (property === 'atob' || property === 'document') return\n if (!Object.prototype.hasOwnProperty.call(this, property)) {\n // 防止小程序环境下,window 上的某些 get 属性在赋值时报错\n try {\n this[property] = global[property]\n } catch (e) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`)\n }\n }\n }\n })\n\n this.Date ||= Date\n\n // 应用启动时,提供给需要读取历史信息的库使用\n this.location = new Location({ window: this }) as any\n // @ts-ignore\n this.history = new History(this.location, { window: this })\n\n this.initEvent()\n }\n\n initEvent () {\n const _location = this.location\n const _history = this.history\n\n this.on(CONTEXT_ACTIONS.INIT, (pageId: string) => {\n // 页面onload,为该页面建立新的上下文信息\n _location.trigger(CONTEXT_ACTIONS.INIT, pageId)\n }, null)\n\n this.on(CONTEXT_ACTIONS.RECOVER, (pageId: string) => {\n // 页面onshow,恢复当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.RECOVER, pageId)\n _history.trigger(CONTEXT_ACTIONS.RECOVER, pageId)\n }, null)\n\n this.on(CONTEXT_ACTIONS.RESTORE, (pageId: string) => {\n // 页面onhide,缓存当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.RESTORE, pageId)\n _history.trigger(CONTEXT_ACTIONS.RESTORE, pageId)\n }, null)\n\n this.on(CONTEXT_ACTIONS.DESTORY, (pageId: string) => {\n // 页面onunload,清除当前页面的上下文信息\n _location.trigger(CONTEXT_ACTIONS.DESTORY, pageId)\n _history.trigger(CONTEXT_ACTIONS.DESTORY, pageId)\n }, null)\n }\n\n get document () {\n return env.document\n }\n\n addEventListener (event: string, callback: (arg: any) => void) {\n if (!isString(event)) return\n this.on(event, callback, null)\n }\n\n removeEventListener (event: string, callback: (arg: any) => void) {\n if (!isString(event)) return\n this.off(event, callback, null)\n }\n\n setTimeout (...args: Parameters<typeof setTimeout>) {\n return setTimeout(...args)\n }\n\n clearTimeout (...args: Parameters<typeof clearTimeout>) {\n return clearTimeout(...args)\n }\n}\n\nexport type { TaroWindow }\nexport const window: TaroWindow = process.env.TARO_PLATFORM === 'web' ? env.window : (env.window = new TaroWindow())\n\nexport const location = window.location\nexport const history = window.history\n"],"names":["navigator","raf","caf"],"mappings":";;;;;;;;;;AAcA,MAAM,UAAW,SAAQ,MAAM,CAAA;AAW7B,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE,CAAA;QAXT,IAAS,CAAA,SAAA,GAAGA,GAAS,CAAA;QACrB,IAAqB,CAAA,qBAAA,GAAGC,IAAG,CAAA;QAC3B,IAAoB,CAAA,oBAAA,GAAGC,IAAG,CAAA;QAC1B,IAAgB,CAAA,gBAAA,GAAG,gBAAgB,CAAA;AAUjC,QAAA,MAAM,gBAAgB,GAAG;AACvB,YAAA,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,IAAI,EAAE,CAAC;AAC3C,YAAA,GAAG,MAAM,CAAC,qBAAqB,CAAC,MAAM,IAAI,EAAE,CAAC;SAC9C,CAAA;AAED,QAAA,gBAAgB,CAAC,OAAO,CAAC,QAAQ,IAAG;AAClC,YAAA,IAAI,QAAQ,KAAK,MAAM,IAAI,QAAQ,KAAK,UAAU;gBAAE,OAAM;AAC1D,YAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE;;gBAEzD,IAAI;oBACF,IAAI,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;AAClC,iBAAA;AAAC,gBAAA,OAAO,CAAC,EAAE;AACV,oBAAA,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;wBACzC,OAAO,CAAC,IAAI,CAAC,CAAsB,mBAAA,EAAA,MAAM,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