@spcsn/taro-runtime 0.1.1 → 1.0.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/README.md +16 -39
- package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/assertClassBrand.js +7 -0
- package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/checkPrivateRedeclaration.js +6 -0
- package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldGet2.js +7 -0
- package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldInitSpec.js +7 -0
- package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldSet2.js +7 -0
- package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateMethodInitSpec.js +7 -0
- package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/defineProperty.js +12 -0
- package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/objectSpread2.js +25 -0
- package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/toPrimitive.js +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/toPropertyKey.js +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/typeof.js +11 -0
- package/dist/bom/{URL.js → URL2.js} +39 -30
- package/dist/bom/URL2.js.map +1 -0
- package/dist/bom/document.d.ts +0 -1
- package/dist/bom/document.js +1 -54
- package/dist/bom/document.js.map +1 -1
- package/dist/bom/get-computed-style.js +8 -0
- package/dist/bom/get-computed-style.js.map +1 -0
- package/dist/bom/history.d.ts +1 -5
- package/dist/bom/history.js +53 -40
- package/dist/bom/history.js.map +1 -1
- package/dist/bom/location.d.ts +1 -11
- package/dist/bom/location.js +103 -93
- package/dist/bom/location.js.map +1 -1
- package/dist/bom/navigator.js +1 -2
- package/dist/bom/navigator.js.map +1 -1
- package/dist/bom/raf.d.ts +2 -2
- package/dist/bom/raf.js +2 -2
- package/dist/bom/raf.js.map +1 -1
- package/dist/bom/url-search-params.d.ts +14 -0
- package/dist/bom/{URLSearchParams.js → url-search-params.js} +26 -25
- package/dist/bom/url-search-params.js.map +1 -0
- package/dist/bom/{URL.d.ts → url.d.ts} +2 -6
- package/dist/bom/url.js +196 -0
- package/dist/bom/url.js.map +1 -0
- package/dist/bom/window.d.ts +3 -3
- package/dist/bom/window.js +3 -3
- package/dist/bom/window.js.map +1 -1
- package/dist/current.d.ts +3 -0
- package/dist/current.js +10 -1
- package/dist/current.js.map +1 -1
- package/dist/dom/anchor-element.js +17 -9
- package/dist/dom/anchor-element.js.map +1 -1
- package/dist/dom/class-list.js +2 -1
- package/dist/dom/class-list.js.map +1 -1
- package/dist/dom/document.js.map +1 -1
- package/dist/dom/element.js +9 -8
- package/dist/dom/element.js.map +1 -1
- package/dist/dom/event-target.js +2 -4
- package/dist/dom/event-target.js.map +1 -1
- package/dist/dom/event.d.ts +1 -1
- package/dist/dom/event.js +19 -28
- package/dist/dom/event.js.map +1 -1
- package/dist/dom/form.js +3 -2
- package/dist/dom/form.js.map +1 -1
- package/dist/dom/node.d.ts +4 -3
- package/dist/dom/node.js +23 -13
- package/dist/dom/node.js.map +1 -1
- package/dist/dom/root.js +4 -6
- package/dist/dom/root.js.map +1 -1
- package/dist/dom/{style_properties.js → style-properties.js} +2 -2
- package/dist/dom/{style_properties.js.map → style-properties.js.map} +1 -1
- package/dist/dom/style.js +1 -1
- package/dist/dom/style.js.map +1 -1
- package/dist/dom/text.d.ts +1 -1
- package/dist/dom/text.js.map +1 -1
- package/dist/dom/transfer.js.map +1 -1
- package/dist/dom/tree.js +1 -1
- package/dist/dom/tree.js.map +1 -1
- package/dist/dom-external/mutation-observer/implements.js +1 -1
- package/dist/dom-external/mutation-observer/implements.js.map +1 -1
- package/dist/dsl/common.js +45 -63
- package/dist/dsl/common.js.map +1 -1
- package/dist/env.js +2 -2
- package/dist/env.js.map +1 -1
- package/dist/hydrate.js +11 -8
- package/dist/hydrate.js.map +1 -1
- package/dist/index.cjs.d.ts +4 -4
- package/dist/index.cjs.js +670 -911
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -6
- package/dist/next-tick.js +1 -4
- package/dist/next-tick.js.map +1 -1
- package/dist/perf.d.ts +1 -1
- package/dist/perf.js +10 -6
- package/dist/perf.js.map +1 -1
- package/dist/polyfill/index.js +1 -6
- package/dist/polyfill/index.js.map +1 -1
- package/dist/runtime.esm.d.ts +4 -4
- package/dist/runtime.esm.js +669 -911
- package/dist/runtime.esm.js.map +1 -1
- package/dist/utils/cache.js.map +1 -1
- package/dist/utils/index.js +9 -6
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/router.js +2 -1
- package/dist/utils/router.js.map +1 -1
- package/package.json +26 -20
- package/LICENSE +0 -174
- package/dist/bom/URL.js.map +0 -1
- package/dist/bom/URLSearchParams.d.ts +0 -1
- package/dist/bom/URLSearchParams.js.map +0 -1
- package/dist/bom/getComputedStyle.js +0 -9
- package/dist/bom/getComputedStyle.js.map +0 -1
- package/dist/polyfill/intersection-observer.js +0 -494
- package/dist/polyfill/intersection-observer.js.map +0 -1
- /package/dist/bom/{getComputedStyle.d.ts → get-computed-style.d.ts} +0 -0
- /package/dist/dom/{node_types.d.ts → node-types.d.ts} +0 -0
- /package/dist/dom/{style_properties.d.ts → style-properties.d.ts} +0 -0
package/dist/dom/root.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.js","names":[],"sources":["../../src/dom/root.ts"],"sourcesContent":["import { hooks, isArray, isFunction, isUndefined, Shortcuts } from '@spcsn/taro-shared';\n\nimport { CUSTOM_WRAPPER, PAGE_INIT, ROOT_STR, SET_DATA } from '../constants';\nimport { options } from '../options';\nimport { perf } from '../perf';\nimport { customWrapperCache, isComment } from '../utils';\nimport { TaroElement } from './element';\n\nimport type { HydratedData, MpInstance, TFunc, UpdatePayload, UpdatePayloadValue } from '../interface';\n\nfunction findCustomWrapper(root: TaroRootElement, dataPathArr: string[]) {\n // ['root', 'cn', '[0]'] remove 'root' => ['cn', '[0]']\n const list = dataPathArr.slice(1);\n let currentData: any = root;\n let customWrapper: Record<string, any> | undefined;\n let splitedPath = '';\n\n list.some((item, i) => {\n const key = item\n // '[0]' => '0'\n .replace(/^\\[(.+)\\]$/, '$1')\n // 'cn' => 'childNodes'\n .replace(/\\bcn\\b/g, 'childNodes');\n\n currentData = currentData[key];\n\n if (isArray(currentData)) {\n currentData = currentData.filter((el) => !isComment(el));\n }\n\n if (isUndefined(currentData)) return true;\n\n if (currentData.nodeName === CUSTOM_WRAPPER) {\n const res = customWrapperCache.get(currentData.sid);\n if (res) {\n customWrapper = res;\n splitedPath = dataPathArr.slice(i + 2).join('.');\n }\n }\n });\n\n if (customWrapper) {\n return {\n customWrapper,\n splitedPath,\n };\n }\n}\n\nexport class TaroRootElement extends TaroElement {\n private updatePayloads: UpdatePayload[] = [];\n\n private updateCallbacks: TFunc[] = [];\n\n public pendingUpdate = false;\n\n public ctx: null | MpInstance = null;\n\n public constructor() {\n super();\n this.nodeName = ROOT_STR;\n this.tagName = ROOT_STR.toUpperCase();\n }\n\n public get _path(): string {\n return ROOT_STR;\n }\n\n public get _root(): TaroRootElement {\n return this;\n }\n\n public scheduleTask(fn: TFunc) {\n // 这里若使用微任务可略微提前setData的执行时机,但在部分场景下可能会出现连续setData两次,造成更大的性能问题\n setTimeout(fn);\n }\n\n public enqueueUpdate(payload: UpdatePayload): void {\n this.updatePayloads.push(payload);\n\n if (!this.pendingUpdate && this.ctx) {\n this.performUpdate();\n }\n }\n\n public performUpdate(initRender = false, prerender?: TFunc) {\n this.pendingUpdate = true;\n\n const ctx = hooks.call('proxyToRaw', this.ctx)!;\n\n this.scheduleTask(() => {\n const setDataMark = `${SET_DATA} 开始时间戳 ${Date.now()}`;\n perf.start(setDataMark);\n const data: Record<string, UpdatePayloadValue | ReturnType<HydratedData>> = Object.create(null);\n const resetPaths = new Set<string>(initRender ? ['root.cn.[0]', 'root.cn[0]'] : []);\n\n while (this.updatePayloads.length > 0) {\n const { path, value } = this.updatePayloads.shift()!;\n if (path.endsWith(Shortcuts.Childnodes)) {\n resetPaths.add(path);\n }\n data[path] = value;\n }\n\n for (const path in data) {\n resetPaths.forEach((p) => {\n // 已经重置了数组,就不需要分别再设置了\n if (path.includes(p) && path !== p) {\n delete data[path];\n }\n });\n\n const value = data[path];\n if (isFunction(value)) {\n data[path] = value();\n }\n }\n\n // 预渲染\n if (isFunction(prerender)) return prerender(data);\n\n // 正常渲染\n this.pendingUpdate = false;\n let normalUpdate = {};\n const customWrapperMap: Map<Record<any, any>, Record<string, any>> = new Map();\n\n if (initRender) {\n // 初次渲染,使用页面级别的 setData\n normalUpdate = data;\n } else {\n // 更新渲染,区分 CustomWrapper 与页面级别的 setData\n for (const p in data) {\n const dataPathArr = p.split('.');\n const found = findCustomWrapper(this, dataPathArr);\n if (found) {\n // 此项数据使用 CustomWrapper 去更新\n const { customWrapper, splitedPath } = found;\n // 合并同一个 customWrapper 的相关更新到一次 setData 中\n customWrapperMap.set(customWrapper, {\n ...(customWrapperMap.get(customWrapper) || {}),\n [`i.${splitedPath}`]: data[p],\n });\n } else {\n // 此项数据使用页面去更新\n normalUpdate[p] = data[p];\n }\n }\n }\n\n const customWrapperCount = customWrapperMap.size;\n const isNeedNormalUpdate = Object.keys(normalUpdate).length > 0;\n const updateArrLen = customWrapperCount + (isNeedNormalUpdate ? 1 : 0);\n let executeTime = 0;\n\n const cb = () => {\n if (++executeTime === updateArrLen) {\n perf.stop(setDataMark);\n this.flushUpdateCallback();\n initRender && perf.stop(PAGE_INIT);\n }\n };\n\n // custom-wrapper setData\n if (customWrapperCount) {\n customWrapperMap.forEach((data, ctx) => {\n if (process.env.NODE_ENV !== 'production' && options.debug) {\n
|
|
1
|
+
{"version":3,"file":"root.js","names":[],"sources":["../../src/dom/root.ts"],"sourcesContent":["import { hooks, isArray, isFunction, isUndefined, Shortcuts } from '@spcsn/taro-shared';\n\nimport { CUSTOM_WRAPPER, PAGE_INIT, ROOT_STR, SET_DATA } from '../constants';\nimport { options } from '../options';\nimport { perf } from '../perf';\nimport { customWrapperCache, isComment } from '../utils';\nimport { TaroElement } from './element';\n\nimport type { HydratedData, MpInstance, TFunc, UpdatePayload, UpdatePayloadValue } from '../interface';\n\nfunction findCustomWrapper(root: TaroRootElement, dataPathArr: string[]) {\n // ['root', 'cn', '[0]'] remove 'root' => ['cn', '[0]']\n const list = dataPathArr.slice(1);\n let currentData: any = root;\n let customWrapper: Record<string, any> | undefined;\n let splitedPath = '';\n\n list.some((item, i) => {\n const key = item\n // '[0]' => '0'\n .replace(/^\\[(.+)\\]$/, '$1')\n // 'cn' => 'childNodes'\n .replace(/\\bcn\\b/g, 'childNodes');\n\n currentData = currentData[key];\n\n if (isArray(currentData)) {\n currentData = currentData.filter((el) => !isComment(el));\n }\n\n if (isUndefined(currentData)) return true;\n\n if (currentData.nodeName === CUSTOM_WRAPPER) {\n const res = customWrapperCache.get(currentData.sid);\n if (res) {\n customWrapper = res;\n splitedPath = dataPathArr.slice(i + 2).join('.');\n }\n }\n });\n\n if (customWrapper) {\n return {\n customWrapper,\n splitedPath,\n };\n }\n}\n\nexport class TaroRootElement extends TaroElement {\n private updatePayloads: UpdatePayload[] = [];\n\n private updateCallbacks: TFunc[] = [];\n\n public pendingUpdate = false;\n\n public ctx: null | MpInstance = null;\n\n public constructor() {\n super();\n this.nodeName = ROOT_STR;\n this.tagName = ROOT_STR.toUpperCase();\n }\n\n public get _path(): string {\n return ROOT_STR;\n }\n\n public get _root(): TaroRootElement {\n return this;\n }\n\n public scheduleTask(fn: TFunc) {\n // 这里若使用微任务可略微提前setData的执行时机,但在部分场景下可能会出现连续setData两次,造成更大的性能问题\n setTimeout(fn);\n }\n\n public enqueueUpdate(payload: UpdatePayload): void {\n this.updatePayloads.push(payload);\n\n if (!this.pendingUpdate && this.ctx) {\n this.performUpdate();\n }\n }\n\n public performUpdate(initRender = false, prerender?: TFunc) {\n this.pendingUpdate = true;\n\n const ctx = hooks.call('proxyToRaw', this.ctx)!;\n\n this.scheduleTask(() => {\n const setDataMark = `${SET_DATA} 开始时间戳 ${Date.now()}`;\n perf.start(setDataMark);\n const data: Record<string, UpdatePayloadValue | ReturnType<HydratedData>> = Object.create(null);\n const resetPaths = new Set<string>(initRender ? ['root.cn.[0]', 'root.cn[0]'] : []);\n\n while (this.updatePayloads.length > 0) {\n const { path, value } = this.updatePayloads.shift()!;\n if (path.endsWith(Shortcuts.Childnodes)) {\n resetPaths.add(path);\n }\n data[path] = value;\n }\n\n for (const path in data) {\n resetPaths.forEach((p) => {\n // 已经重置了数组,就不需要分别再设置了\n if (path.includes(p) && path !== p) {\n delete data[path];\n }\n });\n\n const value = data[path];\n if (isFunction(value)) {\n data[path] = value();\n }\n }\n\n // 预渲染\n if (isFunction(prerender)) return prerender(data);\n\n // 正常渲染\n this.pendingUpdate = false;\n let normalUpdate = {};\n const customWrapperMap: Map<Record<any, any>, Record<string, any>> = new Map();\n\n if (initRender) {\n // 初次渲染,使用页面级别的 setData\n normalUpdate = data;\n } else {\n // 更新渲染,区分 CustomWrapper 与页面级别的 setData\n for (const p in data) {\n const dataPathArr = p.split('.');\n const found = findCustomWrapper(this, dataPathArr);\n if (found) {\n // 此项数据使用 CustomWrapper 去更新\n const { customWrapper, splitedPath } = found;\n // 合并同一个 customWrapper 的相关更新到一次 setData 中\n customWrapperMap.set(customWrapper, {\n ...(customWrapperMap.get(customWrapper) || {}),\n [`i.${splitedPath}`]: data[p],\n });\n } else {\n // 此项数据使用页面去更新\n normalUpdate[p] = data[p];\n }\n }\n }\n\n const customWrapperCount = customWrapperMap.size;\n const isNeedNormalUpdate = Object.keys(normalUpdate).length > 0;\n const updateArrLen = customWrapperCount + (isNeedNormalUpdate ? 1 : 0);\n let executeTime = 0;\n\n const cb = () => {\n if (++executeTime === updateArrLen) {\n perf.stop(setDataMark);\n this.flushUpdateCallback();\n initRender && perf.stop(PAGE_INIT);\n }\n };\n\n // custom-wrapper setData\n if (customWrapperCount) {\n customWrapperMap.forEach((data, ctx) => {\n if (process.env.NODE_ENV !== 'production' && options.debug) {\n globalThis.console.log('custom wrapper setData: ', data);\n }\n ctx.setData(data, cb);\n });\n }\n\n // page setData\n if (isNeedNormalUpdate) {\n if (process.env.NODE_ENV !== 'production' && options.debug) {\n globalThis.console.log('page setData:', normalUpdate);\n }\n ctx.setData(normalUpdate, cb);\n }\n });\n }\n\n public enqueueUpdateCallback(cb: TFunc, ctx?: Record<string, any>) {\n this.updateCallbacks.push(() => {\n ctx ? cb.call(ctx) : cb();\n });\n }\n\n public flushUpdateCallback() {\n const updateCallbacks = this.updateCallbacks;\n if (!updateCallbacks.length) return;\n\n const copies = updateCallbacks.slice(0);\n this.updateCallbacks.length = 0;\n for (let i = 0; i < copies.length; i++) {\n copies[i]();\n }\n }\n}\n"],"mappings":";;;;;;;;AAUA,SAAS,kBAAkB,MAAuB,aAAuB;CAEvE,MAAM,OAAO,YAAY,MAAM,CAAC;CAChC,IAAI,cAAmB;CACvB,IAAI;CACJ,IAAI,cAAc;CAElB,KAAK,MAAM,MAAM,MAAM;EACrB,MAAM,MAAM,KAET,QAAQ,cAAc,IAAI,EAE1B,QAAQ,WAAW,YAAY;EAElC,cAAc,YAAY;EAE1B,IAAI,QAAQ,WAAW,GACrB,cAAc,YAAY,QAAQ,OAAO,CAAC,UAAU,EAAE,CAAC;EAGzD,IAAI,YAAY,WAAW,GAAG,OAAO;EAErC,IAAI,YAAY,aAAA,kBAA6B;GAC3C,MAAM,MAAM,mBAAmB,IAAI,YAAY,GAAG;GAClD,IAAI,KAAK;IACP,gBAAgB;IAChB,cAAc,YAAY,MAAM,IAAI,CAAC,EAAE,KAAK,GAAG;GACjD;EACF;CACF,CAAC;CAED,IAAI,eACF,OAAO;EACL;EACA;CACF;AAEJ;AAEA,IAAa,kBAAb,cAAqC,YAAY;CAS/C,cAAqB;EACnB,MAAM;EATR,KAAQ,iBAAkC,CAAC;EAE3C,KAA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
1
|
-
//#region src/dom/
|
|
1
|
+
//#region src/dom/style-properties.ts
|
|
2
2
|
const WEBKIT = "webkit";
|
|
3
3
|
const styleProperties = [
|
|
4
4
|
"all",
|
|
@@ -371,4 +371,4 @@ combine(WEBKIT, [
|
|
|
371
371
|
//#endregion
|
|
372
372
|
export { styleProperties };
|
|
373
373
|
|
|
374
|
-
//# sourceMappingURL=
|
|
374
|
+
//# sourceMappingURL=style-properties.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style_properties.js","names":[],"sources":["../../src/dom/style_properties.ts"],"sourcesContent":["/*\n *\n * https://www.w3.org/Style/CSS/all-properties.en.html\n */\n\nconst WEBKIT = 'webkit';\n\nconst styleProperties = [\n 'all',\n 'appearance',\n 'backdropFilter',\n 'blockOverflow',\n 'blockSize',\n 'bottom',\n 'clear',\n 'contain',\n 'content',\n 'continue',\n 'cursor',\n 'direction',\n 'display',\n 'filter',\n 'float',\n 'gap',\n 'height',\n 'inset',\n 'isolation',\n 'left',\n 'letterSpacing',\n 'lightingColor',\n 'markerSide',\n 'mixBlendMode',\n 'opacity',\n 'order',\n 'position',\n 'quotes',\n 'resize',\n 'right',\n 'rowGap',\n 'tabSize',\n 'tableLayout',\n 'top',\n 'userSelect',\n 'verticalAlign',\n 'visibility',\n 'voiceFamily',\n 'volume',\n 'whiteSpace',\n 'widows',\n 'width',\n 'zIndex',\n 'pointerEvents',\n 'aspectRatio',\n\n /** 非常用 style */\n // 'azimuth',\n // 'backfaceVisibility',\n // 'baselineShift',\n // 'captionSide',\n // 'chains',\n // 'dominantBaseline',\n // 'elevation',\n // 'emptyCells',\n // 'forcedColorAdjust',\n // 'glyphOrientationVertical',\n // 'hangingPunctuation',\n // 'hyphenateCharacter',\n // 'hyphens',\n // 'imageOrientation',\n // 'imageResolution',\n // 'orphans',\n // 'playDuring',\n // 'pointerEvents',\n // 'regionFragment',\n // 'richness',\n // 'running',\n // 'scrollBehavior',\n // 'speechRate',\n // 'stress',\n // 'stringSet',\n // 'unicodeBidi',\n // 'willChange',\n // 'writingMode',\n];\n\n// 减少文件体积\nfunction combine(prefix: string, list: string[], excludeSelf?: boolean) {\n !excludeSelf && styleProperties.push(prefix);\n list.forEach((item) => {\n styleProperties.push(prefix + item);\n if (prefix === WEBKIT) {\n styleProperties.push('Webkit' + item);\n }\n });\n}\n\nconst color = 'Color';\nconst style = 'Style';\nconst width = 'Width';\nconst image = 'Image';\nconst size = 'Size';\nconst color_style_width = [color, style, width];\nconst fitlength_fitwidth_image = ['FitLength', 'FitWidth', image];\nconst fitlength_fitwidth_image_radius = [...fitlength_fitwidth_image, 'Radius'];\nconst color_style_width_fitlength_fitwidth_image = [...color_style_width, ...fitlength_fitwidth_image];\nconst endRadius_startRadius = ['EndRadius', 'StartRadius'];\nconst bottom_left_right_top = ['Bottom', 'Left', 'Right', 'Top'];\nconst end_start = ['End', 'Start'];\nconst content_items_self = ['Content', 'Items', 'Self'];\nconst blockSize_height_inlineSize_width = ['BlockSize', 'Height', 'InlineSize', width];\nconst after_before = ['After', 'Before'];\n\ncombine('borderBlock', color_style_width);\ncombine('borderBlockEnd', color_style_width);\ncombine('borderBlockStart', color_style_width);\ncombine('outline', [...color_style_width, 'Offset']);\ncombine('border', [...color_style_width, 'Boundary', 'Break', 'Collapse', 'Radius', 'Spacing']);\ncombine('borderFit', ['Length', width]);\ncombine('borderInline', color_style_width);\ncombine('borderInlineEnd', color_style_width);\ncombine('borderInlineStart', color_style_width);\ncombine('borderLeft', color_style_width_fitlength_fitwidth_image);\ncombine('borderRight', color_style_width_fitlength_fitwidth_image);\ncombine('borderTop', color_style_width_fitlength_fitwidth_image);\ncombine('borderBottom', color_style_width_fitlength_fitwidth_image);\ncombine('textDecoration', [color, style, 'Line']);\ncombine('textEmphasis', [color, style, 'Position']);\ncombine('scrollMargin', bottom_left_right_top);\ncombine('scrollPadding', bottom_left_right_top);\ncombine('padding', bottom_left_right_top);\ncombine('margin', [...bottom_left_right_top, 'Trim']);\ncombine('scrollMarginBlock', end_start);\ncombine('scrollMarginInline', end_start);\ncombine('scrollPaddingBlock', end_start);\ncombine('scrollPaddingInline', end_start);\ncombine('gridColumn', end_start);\ncombine('gridRow', end_start);\ncombine('insetBlock', end_start);\ncombine('insetInline', end_start);\ncombine('marginBlock', end_start);\ncombine('marginInline', end_start);\ncombine('paddingBlock', end_start);\ncombine('paddingInline', end_start);\ncombine('pause', after_before);\ncombine('cue', after_before);\ncombine('mask', ['Clip', 'Composite', image, 'Mode', 'Origin', 'Position', 'Repeat', size, 'Type']);\ncombine('borderImage', ['Outset', 'Repeat', 'Slice', 'Source', 'Transform', width]);\ncombine('maskBorder', ['Mode', 'Outset', 'Repeat', 'Slice', 'Source', width]);\ncombine('font', [\n 'Family',\n 'FeatureSettings',\n 'Kerning',\n 'LanguageOverride',\n 'MaxSize',\n 'MinSize',\n 'OpticalSizing',\n 'Palette',\n size,\n 'SizeAdjust',\n 'Stretch',\n style,\n 'Weight',\n 'VariationSettings',\n]);\ncombine('transform', ['Box', 'Origin', style]);\ncombine('background', [color, image, 'Attachment', 'BlendMode', 'Clip', 'Origin', 'Position', 'Repeat', size]);\ncombine('listStyle', [image, 'Position', 'Type']);\ncombine('scrollSnap', ['Align', 'Stop', 'Type']);\ncombine('grid', ['Area', 'AutoColumns', 'AutoFlow', 'AutoRows']);\ncombine('gridTemplate', ['Areas', 'Columns', 'Rows']);\ncombine('overflow', ['Block', 'Inline', 'Wrap', 'X', 'Y']);\ncombine('transition', ['Delay', 'Duration', 'Property', 'TimingFunction']);\ncombine('color', ['Adjust', 'InterpolationFilters', 'Scheme']);\ncombine('textAlign', ['All', 'Last']);\ncombine('page', ['BreakAfter', 'BreakBefore', 'BreakInside']);\ncombine('animation', [\n 'Delay',\n 'Direction',\n 'Duration',\n 'FillMode',\n 'IterationCount',\n 'Name',\n 'PlayState',\n 'TimingFunction',\n]);\ncombine('flex', ['Basis', 'Direction', 'Flow', 'Grow', 'Shrink', 'Wrap']);\ncombine('offset', [...after_before, ...end_start, 'Anchor', 'Distance', 'Path', 'Position', 'Rotate']);\ncombine('perspective', ['Origin']);\ncombine('clip', ['Path', 'Rule']);\ncombine('flow', ['From', 'Into']);\n\ncombine('align', ['Content', 'Items', 'Self'], true);\ncombine('alignment', ['Adjust', 'Baseline'], true);\ncombine('borderStart', endRadius_startRadius, true);\ncombine('borderEnd', endRadius_startRadius, true);\ncombine('borderCorner', ['Fit', image, 'ImageTransform'], true);\ncombine('borderTopLeft', fitlength_fitwidth_image_radius, true);\ncombine('borderTopRight', fitlength_fitwidth_image_radius, true);\ncombine('borderBottomLeft', fitlength_fitwidth_image_radius, true);\ncombine('borderBottomRight', fitlength_fitwidth_image_radius, true);\ncombine('column', ['s', 'Count', 'Fill', 'Gap', 'Rule', 'RuleColor', 'RuleStyle', 'RuleWidth', 'Span', width], true);\ncombine('break', [...after_before, 'Inside'], true);\ncombine('wrap', [...after_before, 'Flow', 'Inside', 'Through'], true);\ncombine('justify', content_items_self, true);\ncombine('place', content_items_self, true);\ncombine('max', [...blockSize_height_inlineSize_width, 'Lines'], true);\ncombine('min', blockSize_height_inlineSize_width, true);\ncombine('line', ['Break', 'Clamp', 'Grid', 'Height', 'Padding', 'Snap'], true);\ncombine('inline', ['BoxAlign', size, 'Sizing'], true);\ncombine(\n 'text',\n [\n 'CombineUpright',\n 'GroupAlign',\n 'Height',\n 'Indent',\n 'Justify',\n 'Orientation',\n 'Overflow',\n 'Shadow',\n 'SpaceCollapse',\n 'SpaceTrim',\n 'Spacing',\n 'Transform',\n 'UnderlinePosition',\n 'Wrap',\n ],\n true,\n);\ncombine('shape', ['ImageThreshold', 'Inside', 'Margin', 'Outside'], true);\ncombine('word', ['Break', 'Spacing', 'Wrap'], true);\ncombine('object', ['Fit', 'Position'], true);\ncombine('box', ['DecorationBreak', 'Shadow', 'Sizing', 'Snap'], true);\n\ncombine(WEBKIT, ['LineClamp', 'BoxOrient', 'TextFillColor', 'TextStroke', 'TextStrokeColor', 'TextStrokeWidth'], true);\n\n/** 非常用 style */\n// combine('caret', [color, 'Shape'])\n// combine('counter', ['Increment', 'Reset', 'Set'], true)\n// combine('dropInitial', ['AfterAdjust', 'AfterAlign', 'BeforeAdjust', 'BeforeAlign', size, 'Value'], true)\n// combine('flood', [color, 'Opacity'], true)\n// combine('footnote', ['Display', 'Policy'], true)\n// combine('hyphenateLimit', ['Chars', 'Last', 'Lines', 'Zone'], true)\n// combine('initialLetters', ['Align', 'Wrap'])\n// combine('ruby', ['Align', 'Merge', 'Position'], true)\n// combine('lineStacking', ['Ruby', 'Shift', 'Strategy'])\n// combine('bookmark', ['Label', 'Level', 'State'], true)\n// combine('speak', ['Header', 'Numeral', 'Punctuation'])\n// combine('pitch', ['Range'])\n// combine('nav', ['Down', 'Left', 'Right', 'Up'], true)\n// combine('fontSynthesis', ['SmallCaps', style, 'Weight'])\n// combine('fontVariant', ['Alternates', 'Caps', 'EastAsian', 'Emoji', 'Ligatures', 'Numeric', 'Position'])\n\nexport { styleProperties };\n"],"mappings":";AAKA,MAAM,SAAS;AAEf,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AA+BF;AAGA,SAAS,QAAQ,QAAgB,MAAgB,aAAuB;CACtE,CAAC,eAAe,gBAAgB,KAAK,MAAM;CAC3C,KAAK,SAAS,SAAS;EACrB,gBAAgB,KAAK,SAAS,IAAI;EAClC,IAAI,WAAW,QACb,gBAAgB,KAAK,WAAW,IAAI;CAExC,CAAC;AACH;AAEA,MAAM,QAAQ;AACd,MAAM,QAAQ;AACd,MAAM,QAAQ;AACd,MAAM,QAAQ;AACd,MAAM,OAAO;AACb,MAAM,oBAAoB;CAAC;CAAO;CAAO;AAAK;A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AAI;AACpD,QACE,QACA;CACE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GACA,IACF;AACA,QAAQ,SAAS;CAAC;CAAkB;CAAU;CAAU;AAAS,GAAG,IAAI;AACxE,QAAQ,QAAQ;CAAC;CAAS;CAAW;AAAM,GAAG,IAAI;AAClD,QAAQ,UAAU,CAAC,OAAO,UAAU,GAAG,IAAI;AAC3C,QAAQ,OAAO;CAAC;CAAmB;CAAU;CAAU;AAAM,GAAG,IAAI;AAEpE,QAAQ,QAAQ;CAAC;CAAa;CAAa;CAAiB;CAAc;CAAmB;AAAiB,GAAG,IAAI"}
|
|
1
|
+
{"version":3,"file":"style-properties.js","names":[],"sources":["../../src/dom/style-properties.ts"],"sourcesContent":["/*\n *\n * https://www.w3.org/Style/CSS/all-properties.en.html\n */\n\nconst WEBKIT = 'webkit';\n\nconst styleProperties = [\n 'all',\n 'appearance',\n 'backdropFilter',\n 'blockOverflow',\n 'blockSize',\n 'bottom',\n 'clear',\n 'contain',\n 'content',\n 'continue',\n 'cursor',\n 'direction',\n 'display',\n 'filter',\n 'float',\n 'gap',\n 'height',\n 'inset',\n 'isolation',\n 'left',\n 'letterSpacing',\n 'lightingColor',\n 'markerSide',\n 'mixBlendMode',\n 'opacity',\n 'order',\n 'position',\n 'quotes',\n 'resize',\n 'right',\n 'rowGap',\n 'tabSize',\n 'tableLayout',\n 'top',\n 'userSelect',\n 'verticalAlign',\n 'visibility',\n 'voiceFamily',\n 'volume',\n 'whiteSpace',\n 'widows',\n 'width',\n 'zIndex',\n 'pointerEvents',\n 'aspectRatio',\n\n /** 非常用 style */\n // 'azimuth',\n // 'backfaceVisibility',\n // 'baselineShift',\n // 'captionSide',\n // 'chains',\n // 'dominantBaseline',\n // 'elevation',\n // 'emptyCells',\n // 'forcedColorAdjust',\n // 'glyphOrientationVertical',\n // 'hangingPunctuation',\n // 'hyphenateCharacter',\n // 'hyphens',\n // 'imageOrientation',\n // 'imageResolution',\n // 'orphans',\n // 'playDuring',\n // 'pointerEvents',\n // 'regionFragment',\n // 'richness',\n // 'running',\n // 'scrollBehavior',\n // 'speechRate',\n // 'stress',\n // 'stringSet',\n // 'unicodeBidi',\n // 'willChange',\n // 'writingMode',\n];\n\n// 减少文件体积\nfunction combine(prefix: string, list: string[], excludeSelf?: boolean) {\n !excludeSelf && styleProperties.push(prefix);\n list.forEach((item) => {\n styleProperties.push(prefix + item);\n if (prefix === WEBKIT) {\n styleProperties.push('Webkit' + item);\n }\n });\n}\n\nconst color = 'Color';\nconst style = 'Style';\nconst width = 'Width';\nconst image = 'Image';\nconst size = 'Size';\nconst color_style_width = [color, style, width];\nconst fitlength_fitwidth_image = ['FitLength', 'FitWidth', image];\nconst fitlength_fitwidth_image_radius = [...fitlength_fitwidth_image, 'Radius'];\nconst color_style_width_fitlength_fitwidth_image = [...color_style_width, ...fitlength_fitwidth_image];\nconst endRadius_startRadius = ['EndRadius', 'StartRadius'];\nconst bottom_left_right_top = ['Bottom', 'Left', 'Right', 'Top'];\nconst end_start = ['End', 'Start'];\nconst content_items_self = ['Content', 'Items', 'Self'];\nconst blockSize_height_inlineSize_width = ['BlockSize', 'Height', 'InlineSize', width];\nconst after_before = ['After', 'Before'];\n\ncombine('borderBlock', color_style_width);\ncombine('borderBlockEnd', color_style_width);\ncombine('borderBlockStart', color_style_width);\ncombine('outline', [...color_style_width, 'Offset']);\ncombine('border', [...color_style_width, 'Boundary', 'Break', 'Collapse', 'Radius', 'Spacing']);\ncombine('borderFit', ['Length', width]);\ncombine('borderInline', color_style_width);\ncombine('borderInlineEnd', color_style_width);\ncombine('borderInlineStart', color_style_width);\ncombine('borderLeft', color_style_width_fitlength_fitwidth_image);\ncombine('borderRight', color_style_width_fitlength_fitwidth_image);\ncombine('borderTop', color_style_width_fitlength_fitwidth_image);\ncombine('borderBottom', color_style_width_fitlength_fitwidth_image);\ncombine('textDecoration', [color, style, 'Line']);\ncombine('textEmphasis', [color, style, 'Position']);\ncombine('scrollMargin', bottom_left_right_top);\ncombine('scrollPadding', bottom_left_right_top);\ncombine('padding', bottom_left_right_top);\ncombine('margin', [...bottom_left_right_top, 'Trim']);\ncombine('scrollMarginBlock', end_start);\ncombine('scrollMarginInline', end_start);\ncombine('scrollPaddingBlock', end_start);\ncombine('scrollPaddingInline', end_start);\ncombine('gridColumn', end_start);\ncombine('gridRow', end_start);\ncombine('insetBlock', end_start);\ncombine('insetInline', end_start);\ncombine('marginBlock', end_start);\ncombine('marginInline', end_start);\ncombine('paddingBlock', end_start);\ncombine('paddingInline', end_start);\ncombine('pause', after_before);\ncombine('cue', after_before);\ncombine('mask', ['Clip', 'Composite', image, 'Mode', 'Origin', 'Position', 'Repeat', size, 'Type']);\ncombine('borderImage', ['Outset', 'Repeat', 'Slice', 'Source', 'Transform', width]);\ncombine('maskBorder', ['Mode', 'Outset', 'Repeat', 'Slice', 'Source', width]);\ncombine('font', [\n 'Family',\n 'FeatureSettings',\n 'Kerning',\n 'LanguageOverride',\n 'MaxSize',\n 'MinSize',\n 'OpticalSizing',\n 'Palette',\n size,\n 'SizeAdjust',\n 'Stretch',\n style,\n 'Weight',\n 'VariationSettings',\n]);\ncombine('transform', ['Box', 'Origin', style]);\ncombine('background', [color, image, 'Attachment', 'BlendMode', 'Clip', 'Origin', 'Position', 'Repeat', size]);\ncombine('listStyle', [image, 'Position', 'Type']);\ncombine('scrollSnap', ['Align', 'Stop', 'Type']);\ncombine('grid', ['Area', 'AutoColumns', 'AutoFlow', 'AutoRows']);\ncombine('gridTemplate', ['Areas', 'Columns', 'Rows']);\ncombine('overflow', ['Block', 'Inline', 'Wrap', 'X', 'Y']);\ncombine('transition', ['Delay', 'Duration', 'Property', 'TimingFunction']);\ncombine('color', ['Adjust', 'InterpolationFilters', 'Scheme']);\ncombine('textAlign', ['All', 'Last']);\ncombine('page', ['BreakAfter', 'BreakBefore', 'BreakInside']);\ncombine('animation', [\n 'Delay',\n 'Direction',\n 'Duration',\n 'FillMode',\n 'IterationCount',\n 'Name',\n 'PlayState',\n 'TimingFunction',\n]);\ncombine('flex', ['Basis', 'Direction', 'Flow', 'Grow', 'Shrink', 'Wrap']);\ncombine('offset', [...after_before, ...end_start, 'Anchor', 'Distance', 'Path', 'Position', 'Rotate']);\ncombine('perspective', ['Origin']);\ncombine('clip', ['Path', 'Rule']);\ncombine('flow', ['From', 'Into']);\n\ncombine('align', ['Content', 'Items', 'Self'], true);\ncombine('alignment', ['Adjust', 'Baseline'], true);\ncombine('borderStart', endRadius_startRadius, true);\ncombine('borderEnd', endRadius_startRadius, true);\ncombine('borderCorner', ['Fit', image, 'ImageTransform'], true);\ncombine('borderTopLeft', fitlength_fitwidth_image_radius, true);\ncombine('borderTopRight', fitlength_fitwidth_image_radius, true);\ncombine('borderBottomLeft', fitlength_fitwidth_image_radius, true);\ncombine('borderBottomRight', fitlength_fitwidth_image_radius, true);\ncombine('column', ['s', 'Count', 'Fill', 'Gap', 'Rule', 'RuleColor', 'RuleStyle', 'RuleWidth', 'Span', width], true);\ncombine('break', [...after_before, 'Inside'], true);\ncombine('wrap', [...after_before, 'Flow', 'Inside', 'Through'], true);\ncombine('justify', content_items_self, true);\ncombine('place', content_items_self, true);\ncombine('max', [...blockSize_height_inlineSize_width, 'Lines'], true);\ncombine('min', blockSize_height_inlineSize_width, true);\ncombine('line', ['Break', 'Clamp', 'Grid', 'Height', 'Padding', 'Snap'], true);\ncombine('inline', ['BoxAlign', size, 'Sizing'], true);\ncombine(\n 'text',\n [\n 'CombineUpright',\n 'GroupAlign',\n 'Height',\n 'Indent',\n 'Justify',\n 'Orientation',\n 'Overflow',\n 'Shadow',\n 'SpaceCollapse',\n 'SpaceTrim',\n 'Spacing',\n 'Transform',\n 'UnderlinePosition',\n 'Wrap',\n ],\n true,\n);\ncombine('shape', ['ImageThreshold', 'Inside', 'Margin', 'Outside'], true);\ncombine('word', ['Break', 'Spacing', 'Wrap'], true);\ncombine('object', ['Fit', 'Position'], true);\ncombine('box', ['DecorationBreak', 'Shadow', 'Sizing', 'Snap'], true);\n\ncombine(WEBKIT, ['LineClamp', 'BoxOrient', 'TextFillColor', 'TextStroke', 'TextStrokeColor', 'TextStrokeWidth'], true);\n\n/** 非常用 style */\n// combine('caret', [color, 'Shape'])\n// combine('counter', ['Increment', 'Reset', 'Set'], true)\n// combine('dropInitial', ['AfterAdjust', 'AfterAlign', 'BeforeAdjust', 'BeforeAlign', size, 'Value'], true)\n// combine('flood', [color, 'Opacity'], true)\n// combine('footnote', ['Display', 'Policy'], true)\n// combine('hyphenateLimit', ['Chars', 'Last', 'Lines', 'Zone'], true)\n// combine('initialLetters', ['Align', 'Wrap'])\n// combine('ruby', ['Align', 'Merge', 'Position'], true)\n// combine('lineStacking', ['Ruby', 'Shift', 'Strategy'])\n// combine('bookmark', ['Label', 'Level', 'State'], true)\n// combine('speak', ['Header', 'Numeral', 'Punctuation'])\n// combine('pitch', ['Range'])\n// combine('nav', ['Down', 'Left', 'Right', 'Up'], true)\n// combine('fontSynthesis', ['SmallCaps', style, 'Weight'])\n// combine('fontVariant', ['Alternates', 'Caps', 'EastAsian', 'Emoji', 'Ligatures', 'Numeric', 'Position'])\n\nexport { styleProperties };\n"],"mappings":";AAKA,MAAM,SAAS;AAEf,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AA+BF;AAGA,SAAS,QAAQ,QAAgB,MAAgB,aAAuB;CACtE,CAAC,eAAe,gBAAgB,KAAK,MAAM;CAC3C,KAAK,SAAS,SAAS;EACrB,gBAAgB,KAAK,SAAS,IAAI;EAClC,IAAI,WAAW,QACb,gBAAgB,KAAK,WAAW,IAAI;CAExC,CAAC;AACH;AAEA,MAAM,QAAQ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,QAAQ;CAAC;CAAS;CAAS;CAAQ;CAAU;CAAW;AAAM,GAAG,IAAI;AAC7E,QAAQ,UAAU;CAAC;CAAY;CAAM;AAAQ,GAAG,IAAI;AACpD,QACE,QACA;CACE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GACA,IACF;AACA,QAAQ,SAAS;CAAC;CAAkB;CAAU;CAAU;AAAS,GAAG,IAAI;AACxE,QAAQ,QAAQ;CAAC;CAAS;CAAW;AAAM,GAAG,IAAI;AAClD,QAAQ,UAAU,CAAC,OAAO,UAAU,GAAG,IAAI;AAC3C,QAAQ,OAAO;CAAC;CAAmB;CAAU;CAAU;AAAM,GAAG,IAAI;AAEpE,QAAQ,QAAQ;CAAC;CAAa;CAAa;CAAiB;CAAc;CAAmB;AAAiB,GAAG,IAAI"}
|
package/dist/dom/style.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../constants/index.js";
|
|
2
2
|
import { MutationObserver } from "../dom-external/mutation-observer/index.js";
|
|
3
|
-
import { styleProperties } from "./
|
|
3
|
+
import { styleProperties } from "./style-properties.js";
|
|
4
4
|
import { Shortcuts, hooks, isArray, isNull, isString, isUndefined, toCamelCase, toDashed, warn } from "@spcsn/taro-shared";
|
|
5
5
|
//#region src/dom/style.ts
|
|
6
6
|
function recordCss(obj) {
|
package/dist/dom/style.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","names":[],"sources":["../../src/dom/style.ts"],"sourcesContent":["import {\n hooks,\n isArray,\n isNull,\n isString,\n isUndefined,\n Shortcuts,\n toCamelCase,\n toDashed,\n warn,\n} from '@spcsn/taro-shared';\n\nimport { PROPERTY_THRESHOLD } from '../constants';\nimport { MutationObserver, MutationRecordType } from '../dom-external/mutation-observer';\nimport { TaroElement } from './element';\nimport { styleProperties } from './
|
|
1
|
+
{"version":3,"file":"style.js","names":[],"sources":["../../src/dom/style.ts"],"sourcesContent":["import {\n hooks,\n isArray,\n isNull,\n isString,\n isUndefined,\n Shortcuts,\n toCamelCase,\n toDashed,\n warn,\n} from '@spcsn/taro-shared';\n\nimport { PROPERTY_THRESHOLD } from '../constants';\nimport { MutationObserver, MutationRecordType } from '../dom-external/mutation-observer';\nimport { TaroElement } from './element';\nimport { styleProperties } from './style-properties';\n\nfunction recordCss(obj: Style) {\n MutationObserver.record({\n type: MutationRecordType.ATTRIBUTES,\n target: obj._element,\n attributeName: 'style',\n oldValue: obj.cssText,\n });\n}\n\nfunction enqueueUpdate(obj: Style) {\n const element = obj._element;\n if (element._root) {\n element.enqueueUpdate({\n path: `${element._path}.${Shortcuts.Style}`,\n value: obj.cssText,\n });\n }\n}\n\nfunction setStyle(this: Style, newVal: string, styleKey: string) {\n process.env.NODE_ENV !== 'production' &&\n warn(\n isString(newVal) && newVal.length > PROPERTY_THRESHOLD,\n `Style 属性 ${styleKey} 的值数据量过大,可能会影响渲染性能,考虑使用 CSS 类或其它方案替代。`,\n );\n\n const old = this[styleKey];\n\n if (old === newVal) return;\n\n !this._pending && recordCss(this);\n\n if (isNull(newVal) || isUndefined(newVal) || newVal === '') {\n this._usedStyleProp.delete(styleKey);\n delete this._value[styleKey];\n } else {\n this._usedStyleProp.add(styleKey);\n this._value[styleKey] = newVal;\n }\n\n !this._pending && enqueueUpdate(this);\n}\n\nfunction initStyle(ctor: typeof Style, styleProperties: string[]) {\n const properties = {};\n\n for (let i = 0; i < styleProperties.length; i++) {\n const styleKey = styleProperties[i];\n\n if (ctor[styleKey]) return;\n\n properties[styleKey] = {\n get(this: Style) {\n const val = this._value[styleKey];\n return isNull(val) || isUndefined(val) ? '' : val;\n },\n set(this: Style, newVal: string) {\n setStyle.call(this, newVal, styleKey);\n },\n };\n }\n\n Object.defineProperties(ctor.prototype, properties);\n}\n\nfunction isCssVariable(propertyName) {\n return /^--/.test(propertyName);\n}\n\nexport class Style {\n public _pending: boolean;\n\n public _usedStyleProp: Set<string>;\n\n public _value: Partial<CSSStyleDeclaration>;\n\n public _element: TaroElement;\n\n public constructor(element: TaroElement) {\n this._element = element;\n this._usedStyleProp = new Set();\n this._value = {};\n }\n\n private setCssVariables(styleKey: string) {\n this.hasOwnProperty(styleKey) ||\n Object.defineProperty(this, styleKey, {\n enumerable: true,\n configurable: true,\n get: () => {\n return this._value[styleKey] || '';\n },\n set: (newVal: string) => {\n setStyle.call(this, newVal, styleKey);\n },\n });\n }\n\n public get cssText() {\n if (!this._usedStyleProp.size) return '';\n\n const texts: string[] = [];\n this._usedStyleProp.forEach((key) => {\n const val = this[key];\n if (isNull(val) || isUndefined(val)) return;\n let styleName = isCssVariable(key) ? key : toDashed(key);\n if (styleName.indexOf('webkit') === 0 || styleName.indexOf('Webkit') === 0) {\n styleName = `-${styleName}`;\n }\n texts.push(`${styleName}: ${val};`);\n });\n return texts.join(' ');\n }\n\n public set cssText(str: string) {\n this._pending = true;\n recordCss(this);\n\n this._usedStyleProp.forEach((prop) => {\n this.removeProperty(prop);\n });\n\n if (str === '' || isUndefined(str) || isNull(str)) {\n this._pending = false;\n enqueueUpdate(this);\n return;\n }\n\n const rules = str.split(';');\n\n for (let i = 0; i < rules.length; i++) {\n const rule = rules[i].trim();\n if (rule === '') {\n continue;\n }\n\n // 可能存在 'background: url(http:x/y/z)' 的情况\n const [propName, ...valList] = rule.split(':');\n const val = valList.join(':');\n\n if (isUndefined(val)) {\n continue;\n }\n this.setProperty(propName.trim(), val.trim());\n }\n\n this._pending = false;\n enqueueUpdate(this);\n }\n\n public setProperty(propertyName: string, value?: string | null) {\n if (propertyName[0] === '-') {\n // 支持 webkit 属性或 css 变量\n this.setCssVariables(propertyName);\n } else {\n propertyName = toCamelCase(propertyName);\n }\n\n if (isNull(value) || isUndefined(value)) {\n this.removeProperty(propertyName);\n } else {\n this[propertyName] = value;\n }\n }\n\n public removeProperty(propertyName: string): string {\n propertyName = toCamelCase(propertyName);\n if (!this._usedStyleProp.has(propertyName)) {\n return '';\n }\n\n const value = this[propertyName];\n this[propertyName] = undefined;\n return value;\n }\n\n public getPropertyValue(propertyName: string) {\n propertyName = toCamelCase(propertyName);\n const value = this[propertyName];\n if (!value) {\n return '';\n }\n\n return value;\n }\n}\n\ninitStyle(Style, styleProperties);\n\nhooks.tap('injectNewStyleProperties', (newStyleProperties: string[]) => {\n if (isArray(newStyleProperties)) {\n initStyle(Style, newStyleProperties);\n } else {\n if (typeof newStyleProperties !== 'string') return;\n\n initStyle(Style, [newStyleProperties]);\n }\n});\n"],"mappings":";;;;;AAiBA,SAAS,UAAU,KAAY;CAC7B,iBAAiB,OAAO;EACtB,MAAA;EACA,QAAQ,IAAI;EACZ,eAAe;EACf,UAAU,IAAI;CAChB,CAAC;AACH;AAEA,SAAS,cAAc,KAAY;CACjC,MAAM,UAAU,IAAI;CACpB,IAAI,QAAQ,OACV,QAAQ,cAAc;EACpB,MAAM,GAAG,QAAQ,MAAM,GAAG,UAAU;EACpC,OAAO,IAAI;CACb,CAAC;AAEL;AAEA,SAAS,SAAsB,QAAgB,UAAkB;CAC/D,KAEI,SAAS,MAAM,KAAK,OAAO,SAAA,MAC3B,YAAY,SAAS,sCACvB;CAIF,IAFY,KAAK,cAEL,QAAQ;CAEpB,CAAC,KAAK,YAAY,UAAU,IAAI;CAEhC,IAAI,OAAO,MAAM,KAAK,YAAY,MAAM,KAAK,WAAW,IAAI;EAC1D,KAAK,eAAe,OAAO,QAAQ;EACnC,OAAO,KAAK,OAAO;CACrB,OAAO;EACL,KAAK,eAAe,IAAI,QAAQ;EAChC,KAAK,OAAO,YAAY;CAC1B;CAEA,CAAC,KAAK,YAAY,cAAc,IAAI;AACtC;AAEA,SAAS,UAAU,MAAoB,iBAA2B;CAChE,MAAM,aAAa,CAAC;CAEpB,KAAK,IAAI,IAAI,GAAG,IAAI,gBAAgB,QAAQ,KAAK;EAC/C,MAAM,WAAW,gBAAgB;EAEjC,IAAI,KAAK,WAAW;EAEpB,WAAW,YAAY;GACrB,MAAiB;IACf,MAAM,MAAM,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ources":["../../src/dom/text.ts"],"sourcesContent":["import { Shortcuts } from '@spcsn/taro-shared';\n\nimport { MutationObserver, MutationRecordType } from '../dom-external/mutation-observer';\nimport { TaroNode } from './node';\nimport { NodeType } from './
|
|
1
|
+
{"version":3,"file":"text.js","names":[],"sources":["../../src/dom/text.ts"],"sourcesContent":["import { Shortcuts } from '@spcsn/taro-shared';\n\nimport { MutationObserver, MutationRecordType } from '../dom-external/mutation-observer';\nimport { TaroNode } from './node';\nimport { NodeType } from './node-types';\n\nexport class TaroText extends TaroNode {\n public _value: string;\n public nodeType = NodeType.TEXT_NODE;\n public nodeName = '#text';\n\n constructor(value) {\n super();\n this._value = value;\n }\n\n public set textContent(text: string) {\n MutationObserver.record({\n target: this,\n type: MutationRecordType.CHARACTER_DATA,\n oldValue: this._value,\n });\n this._value = text;\n this.enqueueUpdate({\n path: `${this._path}.${Shortcuts.Text}`,\n value: text,\n });\n }\n\n public get textContent(): string {\n return this._value;\n }\n\n public set nodeValue(text: string) {\n this.textContent = text;\n }\n\n public get nodeValue(): string {\n return this._value;\n }\n\n public set data(text: string) {\n this.textContent = text;\n }\n\n public get data(): string {\n return this._value;\n }\n}\n"],"mappings":";;;;AAMA,IAAa,WAAb,cAA8B,SAAS;CAKrC,YAAY,OAAO;EACjB,MAAM;EAJR,KAAO,WAAA;EACP,KAAO,WAAW;EAIhB,KAAK,SAAS;CAChB;CAEA,IAAW,YAAY,MAAc;EACnC,iBAAiB,OAAO;GACtB,QAAQ;GACR,MAAA;GACA,UAAU,KAAK;EACjB,CAAC;EACD,KAAK,SAAS;EACd,KAAK,cAAc;GACjB,MAAM,GAAG,KAAK,MAAM,GAAG,UAAU;GACjC,OAAO;EACT,CAAC;CACH;CAEA,IAAW,cAAsB;EAC/B,OAAO,KAAK;CACd;CAEA,IAAW,UAAU,MAAc;EACjC,KAAK,cAAc;CACrB;CAEA,IAAW,YAAoB;EAC7B,OAAO,KAAK;CACd;CAEA,IAAW,KAAK,MAAc;EAC5B,KAAK,cAAc;CACrB;CAEA,IAAW,OAAe;EACxB,OAAO,KAAK;CACd;AACF"}
|
package/dist/dom/transfer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer.js","names":[],"sources":["../../src/dom/transfer.ts"],"sourcesContent":["import { TaroElement } from './element';\n\nexport class TransferElement extends TaroElement {\n public isTransferElement = true;\n\n constructor(public dataName: string) {\n super();\n }\n\n public get _path() {\n return this.dataName;\n }\n}\n"],"mappings":";;AAEA,IAAa,kBAAb,cAAqC,YAAY;CAG/C,YAAY,UAAyB;EACnC,MAAM;EADW,KAAA,WAAA;
|
|
1
|
+
{"version":3,"file":"transfer.js","names":[],"sources":["../../src/dom/transfer.ts"],"sourcesContent":["import { TaroElement } from './element';\n\nexport class TransferElement extends TaroElement {\n public isTransferElement = true;\n\n constructor(public dataName: string) {\n super();\n }\n\n public get _path() {\n return this.dataName;\n }\n}\n"],"mappings":";;AAEA,IAAa,kBAAb,cAAqC,YAAY;CAG/C,YAAY,UAAyB;EACnC,MAAM;EADW,KAAA,WAAA;EAFnB,KAAO,oBAAoB;CAI3B;CAEA,IAAW,QAAQ;EACjB,OAAO,KAAK;CACd;AACF"}
|
package/dist/dom/tree.js
CHANGED
|
@@ -4,7 +4,7 @@ function returnTrue() {
|
|
|
4
4
|
}
|
|
5
5
|
function treeToArray(root, predict) {
|
|
6
6
|
const array = [];
|
|
7
|
-
const filter = predict
|
|
7
|
+
const filter = predict !== null && predict !== void 0 ? predict : returnTrue;
|
|
8
8
|
let object = root;
|
|
9
9
|
while (object) {
|
|
10
10
|
if (object.nodeType === 1 && filter(object)) array.push(object);
|
package/dist/dom/tree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.js","names":[],"sources":["../../src/dom/tree.ts"],"sourcesContent":["import { NodeType } from './
|
|
1
|
+
{"version":3,"file":"tree.js","names":[],"sources":["../../src/dom/tree.ts"],"sourcesContent":["import { NodeType } from './node-types';\n\nimport type { TaroElement } from './element';\n\ntype Filter = (element: TaroElement) => boolean;\n\nfunction returnTrue() {\n return true;\n}\n\nexport function treeToArray(root: TaroElement, predict?: Filter): TaroElement[] {\n const array: TaroElement[] = [];\n const filter = predict ?? returnTrue;\n\n let object: TaroElement | null = root;\n\n while (object) {\n if (object.nodeType === NodeType.ELEMENT_NODE && filter(object)) {\n array.push(object);\n }\n\n object = following(object, root);\n }\n\n return array;\n}\n\nfunction following(el: TaroElement, root: TaroElement): TaroElement | null {\n const firstChild = el.firstChild;\n const isElmentTypeValid = el.nodeType === NodeType.ELEMENT_NODE || el.nodeType === NodeType.DOCUMENT_NODE;\n\n // 如果当前 el 不是 element 或 document 元素,则可以直接不递归他的子元素了\n if (firstChild && isElmentTypeValid) {\n return firstChild as TaroElement;\n }\n\n let current: TaroElement | null = el;\n\n do {\n if (current === root) {\n return null;\n }\n\n const nextSibling = current.nextSibling;\n\n if (nextSibling) {\n return nextSibling as TaroElement;\n }\n current = current.parentElement;\n } while (current);\n\n return null;\n}\n"],"mappings":";AAMA,SAAS,aAAa;CACpB,OAAO;AACT;AAEA,SAAgB,YAAY,MAAmB,SAAiC;CAC9E,MAAM,QAAuB,CAAC;CAC9B,MAAM,SAAS,YAAA,QAAA,YAAA,KAAA,IAAA,UAAW;CAE1B,IAAI,SAA6B;CAEjC,OAAO,QAAQ;EACb,IAAI,OAAO,aAAA,KAAsC,OAAO,MAAM,GAC5D,MAAM,KAAK,MAAM;EAGnB,SAAS,UAAU,QAAQ,IAAI;CACjC;CAEA,OAAO;AACT;AAEA,SAAS,UAAU,IAAiB,MAAuC;CACzE,MAAM,aAAa,GAAG;CACtB,MAAM,oBAAoB,GAAG,aAAA,KAAsC,GAAG,aAAA;CAGtE,IAAI,cAAc,mBAChB,OAAO;CAGT,IAAI,UAA8B;CAElC,GAAG;EACD,IAAI,YAAY,MACd,OAAO;EAGT,MAAM,cAAc,QAAQ;EAE5B,IAAI,aACF,OAAO;EAET,UAAU,QAAQ;CACpB,SAAS;CAET,OAAO;AACT"}
|
|
@@ -48,7 +48,7 @@ var MutationObserverImpl = class {
|
|
|
48
48
|
};
|
|
49
49
|
/** Match two TaroNodes by sid. */
|
|
50
50
|
const sidMatches = (observerTarget, target) => {
|
|
51
|
-
return !!observerTarget && observerTarget.sid === target
|
|
51
|
+
return !!observerTarget && observerTarget.sid === (target === null || target === void 0 ? void 0 : target.sid);
|
|
52
52
|
};
|
|
53
53
|
const isConcerned = (record, options) => {
|
|
54
54
|
const { characterData, characterDataOldValue, attributes, attributeOldValue, childList } = options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implements.js","names":[],"sources":["../../../src/dom-external/mutation-observer/implements.ts"],"sourcesContent":["import { MutationRecordType } from './record';\n\nimport type { TaroNode } from '../../dom/node';\nimport type { MutationRecord } from './record';\n\nexport type MutationCallback = (mutations: MutationRecord[]) => any;\n\n/**\n * @see https://dom.spec.whatwg.org/#dictdef-mutationobserverinit\n */\nexport interface MutationObserverInit {\n attributeFilter?: string[];\n attributeOldValue?: boolean;\n attributes?: boolean;\n characterData?: boolean;\n characterDataOldValue?: boolean;\n childList?: boolean;\n subtree?: boolean;\n}\n\nconst observers: MutationObserverImpl[] = [];\n\n/**\n * The MutationObserver provides the ability\n * to watch for changes being made to the DOM tree.\n * It will invoke a specified callback function\n * when DOM changes occur.\n * @see https://dom.spec.whatwg.org/#mutationobserver\n * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver\n */\nexport class MutationObserverImpl {\n public callback: MutationCallback;\n public target: TaroNode | null;\n public options: MutationObserverInit;\n public records: MutationRecord[] = [];\n\n constructor(callback: MutationCallback) {\n this.callback = callback;\n }\n\n /**\n * Configures the MutationObserver\n * to begin receiving notifications\n * through its callback function\n * when DOM changes matching the given options occur.\n *\n * Options matching is to be implemented.\n */\n observe(target: TaroNode, options?: MutationObserverInit): void {\n this.disconnect();\n this.target = target;\n this.options = options || {};\n\n observers.push(this);\n }\n\n /**\n * Stop the MutationObserver instance\n * from receiving further notifications\n * until and unless observe() is called again.\n */\n disconnect(): void {\n this.target = null;\n\n const index = observers.indexOf(this);\n if (index >= 0) {\n observers.splice(index, 1);\n }\n }\n\n /**\n * Removes all pending notifications\n * from the MutationObserver's notification queue\n * and returns them in a new Array of MutationRecord objects.\n */\n takeRecords(): MutationRecord[] {\n return this.records.splice(0, this.records.length);\n }\n}\n\n/** Match two TaroNodes by sid. */\nconst sidMatches = (observerTarget: TaroNode | null, target: TaroNode | null): boolean => {\n return !!observerTarget && observerTarget.sid === target?.sid;\n};\n\nconst isConcerned = (record: MutationRecord, options: MutationObserverInit) => {\n const { characterData, characterDataOldValue, attributes, attributeOldValue, childList } = options;\n switch (record.type) {\n case MutationRecordType.CHARACTER_DATA:\n if (characterData) {\n if (!characterDataOldValue) record.oldValue = null;\n return true;\n }\n return false;\n case MutationRecordType.ATTRIBUTES:\n if (attributes) {\n if (!attributeOldValue) record.oldValue = null;\n return true;\n }\n return false;\n case MutationRecordType.CHILD_LIST:\n if (childList) {\n return true;\n }\n return false;\n }\n};\n\nlet pendingMuatations = false;\n\nfunction logMutation(observer: MutationObserverImpl, record: MutationRecord) {\n observer.records.push(record);\n if (!pendingMuatations) {\n pendingMuatations = true;\n Promise.resolve().then(() => {\n pendingMuatations = false;\n observers.forEach((observer) => {\n return observer.callback(observer.takeRecords());\n });\n });\n }\n}\n\nexport function recordMutation(record: MutationRecord) {\n observers.forEach((observer) => {\n const { options } = observer;\n for (let t: TaroNode | null = record.target; t; t = t.parentNode) {\n if (sidMatches(observer.target, t) && isConcerned(record, options)) {\n logMutation(observer, record);\n break;\n }\n if (!options.subtree) break;\n }\n });\n}\n"],"mappings":";AAoBA,MAAM,YAAoC,CAAC;;;;;;;;;AAU3C,IAAa,uBAAb,MAAkC;CAMhC,YAAY,UAA4B;
|
|
1
|
+
{"version":3,"file":"implements.js","names":[],"sources":["../../../src/dom-external/mutation-observer/implements.ts"],"sourcesContent":["import { MutationRecordType } from './record';\n\nimport type { TaroNode } from '../../dom/node';\nimport type { MutationRecord } from './record';\n\nexport type MutationCallback = (mutations: MutationRecord[]) => any;\n\n/**\n * @see https://dom.spec.whatwg.org/#dictdef-mutationobserverinit\n */\nexport interface MutationObserverInit {\n attributeFilter?: string[];\n attributeOldValue?: boolean;\n attributes?: boolean;\n characterData?: boolean;\n characterDataOldValue?: boolean;\n childList?: boolean;\n subtree?: boolean;\n}\n\nconst observers: MutationObserverImpl[] = [];\n\n/**\n * The MutationObserver provides the ability\n * to watch for changes being made to the DOM tree.\n * It will invoke a specified callback function\n * when DOM changes occur.\n * @see https://dom.spec.whatwg.org/#mutationobserver\n * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver\n */\nexport class MutationObserverImpl {\n public callback: MutationCallback;\n public target: TaroNode | null;\n public options: MutationObserverInit;\n public records: MutationRecord[] = [];\n\n constructor(callback: MutationCallback) {\n this.callback = callback;\n }\n\n /**\n * Configures the MutationObserver\n * to begin receiving notifications\n * through its callback function\n * when DOM changes matching the given options occur.\n *\n * Options matching is to be implemented.\n */\n observe(target: TaroNode, options?: MutationObserverInit): void {\n this.disconnect();\n this.target = target;\n this.options = options || {};\n\n observers.push(this);\n }\n\n /**\n * Stop the MutationObserver instance\n * from receiving further notifications\n * until and unless observe() is called again.\n */\n disconnect(): void {\n this.target = null;\n\n const index = observers.indexOf(this);\n if (index >= 0) {\n observers.splice(index, 1);\n }\n }\n\n /**\n * Removes all pending notifications\n * from the MutationObserver's notification queue\n * and returns them in a new Array of MutationRecord objects.\n */\n takeRecords(): MutationRecord[] {\n return this.records.splice(0, this.records.length);\n }\n}\n\n/** Match two TaroNodes by sid. */\nconst sidMatches = (observerTarget: TaroNode | null, target: TaroNode | null): boolean => {\n return !!observerTarget && observerTarget.sid === target?.sid;\n};\n\nconst isConcerned = (record: MutationRecord, options: MutationObserverInit) => {\n const { characterData, characterDataOldValue, attributes, attributeOldValue, childList } = options;\n switch (record.type) {\n case MutationRecordType.CHARACTER_DATA:\n if (characterData) {\n if (!characterDataOldValue) record.oldValue = null;\n return true;\n }\n return false;\n case MutationRecordType.ATTRIBUTES:\n if (attributes) {\n if (!attributeOldValue) record.oldValue = null;\n return true;\n }\n return false;\n case MutationRecordType.CHILD_LIST:\n if (childList) {\n return true;\n }\n return false;\n }\n};\n\nlet pendingMuatations = false;\n\nfunction logMutation(observer: MutationObserverImpl, record: MutationRecord) {\n observer.records.push(record);\n if (!pendingMuatations) {\n pendingMuatations = true;\n Promise.resolve().then(() => {\n pendingMuatations = false;\n observers.forEach((observer) => {\n return observer.callback(observer.takeRecords());\n });\n });\n }\n}\n\nexport function recordMutation(record: MutationRecord) {\n observers.forEach((observer) => {\n const { options } = observer;\n for (let t: TaroNode | null = record.target; t; t = t.parentNode) {\n if (sidMatches(observer.target, t) && isConcerned(record, options)) {\n logMutation(observer, record);\n break;\n }\n if (!options.subtree) break;\n }\n });\n}\n"],"mappings":";AAoBA,MAAM,YAAoC,CAAC;;;;;;;;;AAU3C,IAAa,uBAAb,MAAkC;CAMhC,YAAY,UAA4B;EAFxC,KAAO,UAA4B,CAAC;EAGlC,KAAK,WAAW;CAClB;;;;;;;;;CAUA,QAAQ,QAAkB,SAAsC;EAC9D,KAAK,WAAW;EAChB,KAAK,SAAS;EACd,KAAK,UAAU,WAAW,CAAC;EAE3B,UAAU,KAAK,IAAI;CACrB;;;;;;CAOA,aAAmB;EACjB,KAAK,SAAS;EAEd,MAAM,QAAQ,UAAU,QAAQ,IAAI;EACpC,IAAI,SAAS,GACX,UAAU,OAAO,OAAO,CAAC;CAE7B;;;;;;CAOA,cAAgC;EAC9B,OAAO,KAAK,QAAQ,OAAO,GAAG,KAAK,QAAQ,MAAM;CACnD;AACF;;AAGA,MAAM,cAAc,gBAAiC,WAAqC;CACxF,OAAO,CAAC,CAAC,kBAAkB,eAAe,SAAA,WAAA,QAAA,WAAA,KAAA,IAAA,KAAA,IAAQ,OAAQ;AAC5D;AAEA,MAAM,eAAe,QAAwB,YAAkC;CAC7E,MAAM,EAAE,eAAe,uBAAuB,YAAY,mBAAmB,cAAc;CAC3F,QAAQ,OAAO,MAAf;EACE,KAAA;GACE,IAAI,eAAe;IACjB,IAAI,CAAC,uBAAuB,OAAO,WAAW;IAC9C,OAAO;GACT;GACA,OAAO;EACT,KAAA;GACE,IAAI,YAAY;IACd,IAAI,CAAC,mBAAmB,OAAO,WAAW;IAC1C,OAAO;GACT;GACA,OAAO;EACT,KAAA;GACE,IAAI,WACF,OAAO;GAET,OAAO;CACX;AACF;AAEA,IAAI,oBAAoB;AAExB,SAAS,YAAY,UAAgC,QAAwB;CAC3E,SAAS,QAAQ,KAAK,MAAM;CAC5B,IAAI,CAAC,mBAAmB;EACtB,oBAAoB;EACpB,QAAQ,QAAQ,EAAE,WAAW;GAC3B,oBAAoB;GACpB,UAAU,SAAS,aAAa;IAC9B,OAAO,SAAS,SAAS,SAAS,YAAY,CAAC;GACjD,CAAC;EACH,CAAC;CACH;AACF;AAEA,SAAgB,eAAe,QAAwB;CACrD,UAAU,SAAS,aAAa;EAC9B,MAAM,EAAE,YAAY;EACpB,KAAK,IAAI,IAAqB,OAAO,QAAQ,GAAG,IAAI,EAAE,YAAY;GAChE,IAAI,WAAW,SAAS,QAAQ,CAAC,KAAK,YAAY,QAAQ,OAAO,GAAG;IAClE,YAAY,UAAU,MAAM;IAC5B;GACF;GACA,IAAI,CAAC,QAAQ,SAAS;EACxB;CACF,CAAC;AACH"}
|
package/dist/dsl/common.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { BEHAVIORS, CUSTOM_WRAPPER, EXTERNAL_CLASSES, ON_HIDE, ON_LOAD, ON_READY, ON_SHOW, OPTIONS, PAGE_INIT, VIEW } from "../constants/index.js";
|
|
2
|
+
import { _objectSpread2 } from "../_virtual/_@oxc-project_runtime@0.130.0/helpers/objectSpread2.js";
|
|
2
3
|
import { eventCenter } from "../emitter/emitter.js";
|
|
3
4
|
import env from "../env.js";
|
|
4
|
-
import { Current } from "../current.js";
|
|
5
|
+
import { Current, whenAppReady } from "../current.js";
|
|
5
6
|
import { _raf } from "../bom/raf.js";
|
|
6
7
|
import { taroWindowProvider } from "../bom/window.js";
|
|
7
8
|
import { addLeadingSlash } from "../utils/router.js";
|
|
8
9
|
import { customWrapperCache, incrementId } from "../utils/index.js";
|
|
9
10
|
import { eventHandler } from "../dom/event.js";
|
|
10
11
|
import { perf } from "../perf.js";
|
|
11
|
-
import { EMPTY_OBJ,
|
|
12
|
+
import { EMPTY_OBJ, Shortcuts, ensure, getComponentsAlias, hooks, internalComponents, isArray, isFunction, isString, isUndefined } from "@spcsn/taro-shared";
|
|
12
13
|
//#region src/dsl/common.ts
|
|
13
14
|
const instances = /* @__PURE__ */ new Map();
|
|
14
15
|
const pageId = incrementId();
|
|
@@ -39,8 +40,7 @@ function stringify(obj) {
|
|
|
39
40
|
}
|
|
40
41
|
function getPath(id, options) {
|
|
41
42
|
const idx = id.indexOf("?");
|
|
42
|
-
|
|
43
|
-
else return `${idx > -1 ? id.substring(0, idx) : id}${stringify(options)}`;
|
|
43
|
+
return `${idx > -1 ? id.substring(0, idx) : id}${stringify(options)}`;
|
|
44
44
|
}
|
|
45
45
|
function getOnReadyEventKey(path) {
|
|
46
46
|
return path + "." + ON_READY;
|
|
@@ -52,13 +52,13 @@ function getOnHideEventKey(path) {
|
|
|
52
52
|
return path + "." + ON_HIDE;
|
|
53
53
|
}
|
|
54
54
|
function createPageConfig(component, pageName, data, pageConfig) {
|
|
55
|
-
const id = pageName
|
|
55
|
+
const id = pageName !== null && pageName !== void 0 ? pageName : `taro_page_${pageId()}`;
|
|
56
56
|
const [ONLOAD, ONUNLOAD, ONREADY, ONSHOW, ONHIDE, LIFECYCLES, SIDE_EFFECT_LIFECYCLES] = hooks.call("getMiniLifecycleImpl").page;
|
|
57
57
|
let pageElement = null;
|
|
58
58
|
let unmounting = false;
|
|
59
59
|
let prepareMountList = [];
|
|
60
60
|
function setCurrentRouter(page) {
|
|
61
|
-
const router =
|
|
61
|
+
const router = page.route || page.__route__ || page.$taroPath;
|
|
62
62
|
Current.router = {
|
|
63
63
|
params: page.$taroParams,
|
|
64
64
|
path: addLeadingSlash(router),
|
|
@@ -81,33 +81,28 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
81
81
|
this.config = pageConfig || {};
|
|
82
82
|
const uniqueOptions = Object.assign({}, options, { $taroTimestamp: Date.now() });
|
|
83
83
|
const $taroPath = this.$taroPath = getPath(id, uniqueOptions);
|
|
84
|
-
if (process.env.TARO_PLATFORM === "web") config.path = $taroPath;
|
|
85
84
|
if (this.$taroParams == null) this.$taroParams = uniqueOptions;
|
|
86
85
|
setCurrentRouter(this);
|
|
87
|
-
|
|
86
|
+
taroWindowProvider.trigger("0", $taroPath);
|
|
88
87
|
const mount = () => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
else pageElement = env.document.getElementById($taroPath);
|
|
88
|
+
whenAppReady((app) => app.mount(component, $taroPath, () => {
|
|
89
|
+
pageElement = env.document.getElementById($taroPath);
|
|
92
90
|
ensure(pageElement !== null, "没有找到页面实例。");
|
|
93
91
|
safeExecute($taroPath, ON_LOAD, this.$taroParams);
|
|
94
92
|
loadResolver();
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
else pageElement.performUpdate(true, cb);
|
|
99
|
-
} else isFunction(cb) && cb();
|
|
100
|
-
});
|
|
93
|
+
pageElement.ctx = this;
|
|
94
|
+
pageElement.performUpdate(true, cb);
|
|
95
|
+
}));
|
|
101
96
|
};
|
|
102
97
|
if (unmounting) prepareMountList.push(mount);
|
|
103
98
|
else mount();
|
|
104
99
|
},
|
|
105
100
|
[ONUNLOAD]() {
|
|
106
101
|
const $taroPath = this.$taroPath;
|
|
107
|
-
|
|
102
|
+
taroWindowProvider.trigger("3", $taroPath);
|
|
108
103
|
safeExecute($taroPath, ONUNLOAD);
|
|
109
104
|
unmounting = true;
|
|
110
|
-
|
|
105
|
+
whenAppReady((app) => app.unmount($taroPath, () => {
|
|
111
106
|
unmounting = false;
|
|
112
107
|
instances.delete($taroPath);
|
|
113
108
|
if (pageElement) {
|
|
@@ -118,26 +113,26 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
118
113
|
prepareMountList.forEach((fn) => fn());
|
|
119
114
|
prepareMountList = [];
|
|
120
115
|
}
|
|
121
|
-
});
|
|
116
|
+
}));
|
|
122
117
|
},
|
|
123
118
|
[ONREADY]() {
|
|
124
119
|
hasLoaded.then(() => {
|
|
125
120
|
safeExecute(this.$taroPath, ON_READY);
|
|
126
121
|
_raf(() => eventCenter.trigger(getOnReadyEventKey(id)));
|
|
127
|
-
this.
|
|
122
|
+
this[ONREADY].called = true;
|
|
128
123
|
});
|
|
129
124
|
},
|
|
130
125
|
[ONSHOW](options = {}) {
|
|
131
126
|
hasLoaded.then(() => {
|
|
132
127
|
Current.page = this;
|
|
133
128
|
setCurrentRouter(this);
|
|
134
|
-
|
|
129
|
+
taroWindowProvider.trigger("2", this.$taroPath);
|
|
135
130
|
safeExecute(this.$taroPath, ON_SHOW, options);
|
|
136
131
|
_raf(() => eventCenter.trigger(getOnShowEventKey(id)));
|
|
137
132
|
});
|
|
138
133
|
},
|
|
139
134
|
[ONHIDE]() {
|
|
140
|
-
|
|
135
|
+
taroWindowProvider.trigger("1", this.$taroPath);
|
|
141
136
|
if (Current.page === this) {
|
|
142
137
|
Current.page = null;
|
|
143
138
|
Current.router = null;
|
|
@@ -146,10 +141,6 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
146
141
|
eventCenter.trigger(getOnHideEventKey(id));
|
|
147
142
|
}
|
|
148
143
|
};
|
|
149
|
-
if (process.env.TARO_PLATFORM === "web") config.getOpenerEventChannel = () => {
|
|
150
|
-
return EventChannel.pageChannel;
|
|
151
|
-
};
|
|
152
|
-
const isSWAN = process.env.TARO_ENV === "swan";
|
|
153
144
|
LIFECYCLES.forEach((lifecycle) => {
|
|
154
145
|
let isDefer = false;
|
|
155
146
|
let isEvent = false;
|
|
@@ -161,22 +152,19 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
161
152
|
isEvent = true;
|
|
162
153
|
return "";
|
|
163
154
|
});
|
|
164
|
-
if (isEvent
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return safeExecute(this.$taroPath, lifecycle, ...arguments);
|
|
168
|
-
};
|
|
169
|
-
} else config[lifecycle] = function() {
|
|
170
|
-
const exec = () => safeExecute(this.$taroPath, lifecycle, ...arguments);
|
|
171
|
-
if (isSWAN) return exec();
|
|
155
|
+
if (isEvent) return;
|
|
156
|
+
config[lifecycle] = function(...args) {
|
|
157
|
+
const exec = () => safeExecute(this.$taroPath, lifecycle, ...args);
|
|
172
158
|
if (isDefer) hasLoaded.then(exec);
|
|
173
159
|
else return exec();
|
|
174
160
|
};
|
|
175
161
|
});
|
|
176
162
|
SIDE_EFFECT_LIFECYCLES.forEach((lifecycle) => {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
163
|
+
var _component$prototype;
|
|
164
|
+
if (component[lifecycle] || ((_component$prototype = component.prototype) === null || _component$prototype === void 0 ? void 0 : _component$prototype[lifecycle]) || component[lifecycle.replace(/^on/, "enable")] || (pageConfig === null || pageConfig === void 0 ? void 0 : pageConfig[lifecycle.replace(/^on/, "enable")])) config[lifecycle] = function(...args) {
|
|
165
|
+
var _args$;
|
|
166
|
+
const target = (_args$ = args[0]) === null || _args$ === void 0 ? void 0 : _args$.target;
|
|
167
|
+
if (target === null || target === void 0 ? void 0 : target.id) {
|
|
180
168
|
const id = target.id;
|
|
181
169
|
const element = env.document.getElementById(id);
|
|
182
170
|
if (element) target.dataset = element.dataset;
|
|
@@ -190,31 +178,30 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
190
178
|
return config;
|
|
191
179
|
}
|
|
192
180
|
function createComponentConfig(component, componentName, data) {
|
|
193
|
-
const id = componentName
|
|
181
|
+
const id = componentName !== null && componentName !== void 0 ? componentName : `taro_component_${pageId()}`;
|
|
194
182
|
let componentElement = null;
|
|
195
183
|
const [ATTACHED, DETACHED] = hooks.call("getMiniLifecycleImpl").component;
|
|
196
184
|
const config = {
|
|
197
185
|
[ATTACHED]() {
|
|
186
|
+
var _this$getPageId;
|
|
198
187
|
perf.start(PAGE_INIT);
|
|
199
|
-
this.pageIdCache = this.getPageId
|
|
188
|
+
this.pageIdCache = ((_this$getPageId = this.getPageId) === null || _this$getPageId === void 0 ? void 0 : _this$getPageId.call(this)) || pageId();
|
|
200
189
|
const path = getPath(id, { id: this.pageIdCache });
|
|
201
|
-
|
|
190
|
+
whenAppReady((app) => app.mount(component, path, () => {
|
|
202
191
|
componentElement = env.document.getElementById(path);
|
|
203
192
|
ensure(componentElement !== null, "没有找到组件实例。");
|
|
204
193
|
this.$taroInstances = instances.get(path);
|
|
205
194
|
safeExecute(path, ON_LOAD);
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
});
|
|
195
|
+
componentElement.ctx = this;
|
|
196
|
+
componentElement.performUpdate(true);
|
|
197
|
+
}));
|
|
211
198
|
},
|
|
212
199
|
[DETACHED]() {
|
|
213
200
|
const path = getPath(id, { id: this.pageIdCache });
|
|
214
|
-
|
|
201
|
+
whenAppReady((app) => app.unmount(path, () => {
|
|
215
202
|
instances.delete(path);
|
|
216
203
|
if (componentElement) componentElement.ctx = null;
|
|
217
|
-
});
|
|
204
|
+
}));
|
|
218
205
|
},
|
|
219
206
|
methods: { eh: eventHandler }
|
|
220
207
|
};
|
|
@@ -224,7 +211,8 @@ function createComponentConfig(component, componentName, data) {
|
|
|
224
211
|
EXTERNAL_CLASSES,
|
|
225
212
|
BEHAVIORS
|
|
226
213
|
].forEach((key) => {
|
|
227
|
-
|
|
214
|
+
var _component$key;
|
|
215
|
+
config[key] = (_component$key = component[key]) !== null && _component$key !== void 0 ? _component$key : EMPTY_OBJ;
|
|
228
216
|
});
|
|
229
217
|
return config;
|
|
230
218
|
}
|
|
@@ -233,8 +221,8 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
233
221
|
const [ATTACHED, DETACHED] = hooks.call("getMiniLifecycleImpl").component;
|
|
234
222
|
const lifeCycles = isCustomWrapper ? {
|
|
235
223
|
[ATTACHED]() {
|
|
236
|
-
|
|
237
|
-
const componentId = this.data.i
|
|
224
|
+
var _this$data$i, _this$props$i;
|
|
225
|
+
const componentId = ((_this$data$i = this.data.i) === null || _this$data$i === void 0 ? void 0 : _this$data$i.sid) || ((_this$props$i = this.props.i) === null || _this$props$i === void 0 ? void 0 : _this$props$i.sid);
|
|
238
226
|
if (isString(componentId)) {
|
|
239
227
|
customWrapperCache.set(componentId, this);
|
|
240
228
|
const el = env.document.getElementById(componentId);
|
|
@@ -242,8 +230,8 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
242
230
|
}
|
|
243
231
|
},
|
|
244
232
|
[DETACHED]() {
|
|
245
|
-
|
|
246
|
-
const componentId = this.data.i
|
|
233
|
+
var _this$data$i2, _this$props$i2;
|
|
234
|
+
const componentId = ((_this$data$i2 = this.data.i) === null || _this$data$i2 === void 0 ? void 0 : _this$data$i2.sid) || ((_this$props$i2 = this.props.i) === null || _this$props$i2 === void 0 ? void 0 : _this$props$i2.sid);
|
|
247
235
|
if (isString(componentId)) {
|
|
248
236
|
customWrapperCache.delete(componentId);
|
|
249
237
|
const el = env.document.getElementById(componentId);
|
|
@@ -251,9 +239,7 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
251
239
|
}
|
|
252
240
|
}
|
|
253
241
|
} : EMPTY_OBJ;
|
|
254
|
-
|
|
255
|
-
if (process.env.TARO_ENV === "jd") extraOptions.addGlobalClass = true;
|
|
256
|
-
return hooks.call("modifyRecursiveComponentConfig", {
|
|
242
|
+
return hooks.call("modifyRecursiveComponentConfig", _objectSpread2({
|
|
257
243
|
properties: {
|
|
258
244
|
i: {
|
|
259
245
|
type: Object,
|
|
@@ -264,13 +250,9 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
264
250
|
value: ""
|
|
265
251
|
}
|
|
266
252
|
},
|
|
267
|
-
options: {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
},
|
|
271
|
-
methods: { eh: eventHandler },
|
|
272
|
-
...lifeCycles
|
|
273
|
-
}, { isCustomWrapper });
|
|
253
|
+
options: { virtualHost: !isCustomWrapper },
|
|
254
|
+
methods: { eh: eventHandler }
|
|
255
|
+
}, lifeCycles), { isCustomWrapper });
|
|
274
256
|
}
|
|
275
257
|
//#endregion
|
|
276
258
|
export { createComponentConfig, createPageConfig, createRecursiveComponentConfig, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify };
|