( component: Component.Any, rootProps: unknown, container: unknown, state: (path: string) => PaintState | undefined, hostOf: (ctx: Context.Context<any>) => HostInput, path?: string | undefined )
| 1134 | } |
| 1135 | |
| 1136 | const paintCore = ( |
| 1137 | component: Component.Any, |
| 1138 | rootProps: unknown, |
| 1139 | container: unknown, |
| 1140 | state: (path: string) => PaintState | undefined, |
| 1141 | hostOf: (ctx: Context.Context<any>) => HostInput, |
| 1142 | path?: string | undefined |
| 1143 | ): Effect.Effect< |
| 1144 | Painted, |
| 1145 | never, |
| 1146 | Scope.Scope |
| 1147 | > => |
| 1148 | Effect.contextWith((caller: Context.Context<Scope.Scope>) => { |
| 1149 | const ctx = onScheduler(caller) |
| 1150 | const executor = Context.get(ctx, Executor.CurrentExecutor) |
| 1151 | const fellBack: Array<string> = [] |
| 1152 | const skipped = new Set<string>() |
| 1153 | let broke: { readonly error: unknown } | undefined |
| 1154 | const { base, dom } = hostOf(ctx).make( |
| 1155 | container, |
| 1156 | false, |
| 1157 | messageLog.silent.step |
| 1158 | ) |
| 1159 | const close = () => { |
| 1160 | painted.close() |
| 1161 | dom?.dispose() |
| 1162 | } |
| 1163 | const painted = Kernel.mount( |
| 1164 | component as unknown as Kernel.Runnable, |
| 1165 | rootProps, |
| 1166 | container, |
| 1167 | { |
| 1168 | ...base, |
| 1169 | setEvents: () => {}, |
| 1170 | transitions: () => unmoved, |
| 1171 | inert: true, |
| 1172 | skipped: (path) => skipped.add(path) |
| 1173 | }, |
| 1174 | { |
| 1175 | path, |
| 1176 | context: ctx, |
| 1177 | init: (inst) => { |
| 1178 | let recorded: PaintState | undefined |
| 1179 | try { |
| 1180 | recorded = state(inst.path) |
| 1181 | } catch (error) { |
| 1182 | broke = { error } |
| 1183 | throw error |
| 1184 | } |
| 1185 | if (recorded === undefined) { |
| 1186 | fellBack.push(inst.path) |
| 1187 | recorded = inst.component.init(inst.props) |
| 1188 | } else { |
| 1189 | if (Object.hasOwn(recorded, "props")) inst.props = recorded.props |
| 1190 | inst.results = recorded.queries |
| 1191 | } |
| 1192 | return { |
| 1193 | model: recorded!.model, |
no test coverage detected