MCPcopy
hub / github.com/NervJS/taro / parsePageOrComp

Function parsePageOrComp

packages/taro-platform-harmony-cpp/src/program/vite/page.ts:109–687  ·  view source on GitHub ↗
(config: TPageMeta)

Source from the content-addressed store, hash-verified

107 }
108
109 const parsePageOrComp = (config: TPageMeta) => {
110 if (!isPureComp(config)) {
111 config.entryOption = {}
112 }
113 config.modifyPageImport = function (this: PageParser, importStr: string[], page: TPageMeta | TPageMeta[]) {
114 function fixPageEntry (meta: TPageMeta) {
115 Object.assign(config.entryOption, {
116 routeName: meta.name,
117 })
118 if (isObject(meta.config?.entryOption)) {
119 Object.assign(config.entryOption, meta.config.entryOption)
120 }
121 }
122
123 if (!isPureComp(page)) {
124 if (page instanceof Array) {
125 page.forEach(fixPageEntry)
126 } else {
127 fixPageEntry(page)
128 }
129 }
130
131 importStr.unshift('import { navigateBack } from "@tarojs/taro"')
132 importStr.unshift('import oh_window from "@ohos.window"')
133 importStr.unshift('import { TaroXComponent } from "@tarojs/components"')
134 importStr.unshift('import { TaroNativeModule, initStyleSheetConfig, systemContext, WINDOW_STATE } from "@tarojs/runtime"')
135 importStr.unshift('import { NodeContent } from "@ohos.arkui.node"')
136 importStr.unshift('import display from "@ohos.display"')
137 importStr.unshift('import { audio } from "@kit.AudioKit"')
138 }
139
140 config.modifyRenderState = function (this: PageParser, state: (string | null)[], page: TPageMeta | TPageMeta[]) {
141 const isPure = isPureComp(page)
142 state.push(
143 this.renderState(
144 {
145 name: '__layoutSize',
146 type: 'TaroAny',
147 foreach: () => 'null',
148 disabled: !this.buildConfig.isBuildNativeComp && isPure,
149 },
150 false
151 ),
152 this.renderState(
153 {
154 name: 'areaChange',
155 type: 'TaroAny',
156 foreach: () => 'null',
157 },
158 false
159 ),
160 this.renderState(
161 {
162 name: '__pageName',
163 type: 'TaroAny',
164 foreach: () => 'null',
165 disabled: !this.buildConfig.isBuildNativeComp && isPure,
166 },

Callers

nothing calls this directly

Calls 15

getProjectIdFunction · 0.90
isPureCompFunction · 0.85
fixPageEntryFunction · 0.85
genUniPageIdFunction · 0.85
unshiftMethod · 0.80
renderStateMethod · 0.80
transArr2StrMethod · 0.80
repeatMethod · 0.80
includesMethod · 0.80
forEachMethod · 0.65
pushMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected