mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 16:33:15 +01:00
get rid of CoreContext in favor of granular bundle contexts
This commit is contained in:
parent
49ec6090aa
commit
4bb2abadab
22 changed files with 51 additions and 55 deletions
|
|
@ -50,7 +50,5 @@ export interface ApplicationContext extends
|
|||
WorkbenchBundleContext
|
||||
{}
|
||||
|
||||
export type CoreContext = ApplicationContext;
|
||||
|
||||
export default {} as ApplicationContext;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import materializeParams from './schema/materializeParams';
|
|||
import CadError from '../../utils/errors';
|
||||
import {MObject, MObjectIdGenerator} from '../model/mobject';
|
||||
import {intercept} from "lstream/intercept";
|
||||
import {CoreContext} from "cad/context";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {OperationParams} from "cad/craft/schema/schema";
|
||||
import {clearImplicitModels} from "cad/craft/e0/occCommandInterface";
|
||||
|
||||
export function activate(ctx: CoreContext) {
|
||||
export function activate(ctx: ApplicationContext) {
|
||||
|
||||
|
||||
const modifications$ = state({
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {SketchGeom} from "cad/sketch/sketchReader";
|
||||
import {CoreContext} from "cad/context";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import CSys from "math/csys";
|
||||
import {OperationResult} from "cad/craft/craftBundle";
|
||||
import {BooleanDefinition, BooleanKind} from "cad/craft/schema/common/BooleanDefinition";
|
||||
|
|
@ -27,7 +27,7 @@ export interface FaceRef extends WireRef {
|
|||
topoShape: Shell,
|
||||
}
|
||||
|
||||
export function createOCCUtils(ctx: CoreContext): OCCUtils {
|
||||
export function createOCCUtils(ctx: ApplicationContext): OCCUtils {
|
||||
|
||||
function sketchToFaces(sketch: SketchGeom, csys: CSys): FaceRef[] {
|
||||
const occ = ctx.occService;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import {MObject} from "cad/model/mobject";
|
|||
import {Interrogate} from "cad/craft/e0/interact";
|
||||
import {readShellEntityFromJson} from "cad/scene/wrappers/entityIO";
|
||||
import {createOCCSketchLoader, OCCSketchLoader} from "cad/craft/e0/occSketchLoader";
|
||||
import {CoreContext} from "cad/context";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {ProductionAnalyzer} from "cad/craft/production/productionAnalyzer";
|
||||
import {readBrep} from "brep/io/brepIO";
|
||||
import {Shell} from "brep/topo/shell";
|
||||
|
|
@ -22,7 +22,7 @@ export interface OCCIO {
|
|||
sketchLoader: OCCSketchLoader
|
||||
}
|
||||
|
||||
export function createOCCIO(ctx: CoreContext): OCCIO {
|
||||
export function createOCCIO(ctx: ApplicationContext): OCCIO {
|
||||
|
||||
function getShell(shapeName: string, productionAnalyzer?: ProductionAnalyzer): MShell {
|
||||
const shapeJson = Interrogate(shapeName);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {CoreContext} from "cad/context";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {OCCCommandInterface, OCI} from "cad/craft/e0/occCommandInterface";
|
||||
import {createOCCIO, OCCIO} from "cad/craft/e0/occIO";
|
||||
import {createOCCUtils, OCCUtils} from "cad/craft/e0/OCCUtils";
|
||||
|
|
@ -15,7 +15,7 @@ export interface OCCService {
|
|||
engineInterface: any
|
||||
}
|
||||
|
||||
export function createOCCService(ctx: CoreContext): OCCService {
|
||||
export function createOCCService(ctx: ApplicationContext): OCCService {
|
||||
|
||||
const oci = OCI;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
|||
import {state} from 'lstream';
|
||||
import {IconType} from "react-icons";
|
||||
import {ActionAppearance} from "../actions/actionSystemBundle";
|
||||
import {ApplicationContext, CoreContext} from "cad/context";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {OperationResult} from "./craftBundle";
|
||||
import {OperationSchema, SchemaField, schemaIterator, unwrapMetadata} from "cad/craft/schema/schema";
|
||||
import {FormDefinition} from "cad/mdf/ui/uiDefinition";
|
||||
|
|
@ -137,7 +137,7 @@ export interface OperationDescriptor<R> {
|
|||
info: string;
|
||||
icon: OpIcon;
|
||||
actionParams?: any;
|
||||
run: (params: {}, ctx: CoreContext, rawParams: R) => OperationResult | Promise<OperationResult>;
|
||||
run: (params: {}, ctx: ApplicationContext, rawParams: R) => OperationResult | Promise<OperationResult>;
|
||||
paramsInfo: (params: R) => string,
|
||||
previewGeomProvider?: (params: R) => OperationGeometryProvider,
|
||||
previewer?: any,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import {Types} from "cad/craft/schema/types";
|
||||
import {isValueNotProvided, OperationSchema, SchemaField} from "cad/craft/schema/schema";
|
||||
import {CoreContext} from "cad/context";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
|
||||
export default function initializeBySchema(schema: OperationSchema, context: CoreContext) {
|
||||
export default function initializeBySchema(schema: OperationSchema, context: ApplicationContext) {
|
||||
let fields = Object.keys(schema);
|
||||
let obj = {};
|
||||
for (let field of fields) {
|
||||
|
|
@ -43,7 +43,7 @@ export default function initializeBySchema(schema: OperationSchema, context: Cor
|
|||
}
|
||||
|
||||
|
||||
export function fillUpMissingFields(params: any, schema: OperationSchema, context: CoreContext) {
|
||||
export function fillUpMissingFields(params: any, schema: OperationSchema, context: ApplicationContext) {
|
||||
let fields = Object.keys(schema);
|
||||
for (let field of fields) {
|
||||
const md = schema[field] as SchemaField;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {TypeRegistry} from "cad/craft/schema/types";
|
||||
import {CoreContext} from "cad/context";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {
|
||||
isValueNotProvided,
|
||||
OperationParams,
|
||||
|
|
@ -19,7 +19,7 @@ function createErrorReporter(path: string[], errors: OperationParamsError[]): Op
|
|||
return report;
|
||||
}
|
||||
|
||||
export default function materializeParams(ctx: CoreContext,
|
||||
export default function materializeParams(ctx: ApplicationContext,
|
||||
params: OperationParams,
|
||||
schema: OperationSchema,
|
||||
result: any,
|
||||
|
|
@ -28,7 +28,7 @@ export default function materializeParams(ctx: CoreContext,
|
|||
|
||||
}
|
||||
|
||||
function materializeParamsImpl(ctx: CoreContext,
|
||||
function materializeParamsImpl(ctx: ApplicationContext,
|
||||
params: OperationParams,
|
||||
schema: OperationSchema,
|
||||
result: any,
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import {ArrayTypeSchema} from "cad/craft/schema/types/arrayType";
|
|||
import {ObjectTypeSchema} from "cad/craft/schema/types/objectType";
|
||||
import {StringTypeSchema} from "cad/craft/schema/types/stringType";
|
||||
import {BooleanTypeSchema} from "cad/craft/schema/types/booleanType";
|
||||
import {Materializer, Types} from "cad/craft/schema/types";
|
||||
import {CoreContext} from "cad/context";
|
||||
import {Types} from "cad/craft/schema/types";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {ParamsPath} from "cad/craft/wizard/wizardTypes";
|
||||
|
||||
export type Coercable = any;
|
||||
|
|
@ -55,7 +55,7 @@ export type OperationParamsErrorReporter = ((msg: string) => void) & {
|
|||
dot: (pathPart: string|number) => OperationParamsErrorReporter
|
||||
};
|
||||
|
||||
export type ValueResolver<IN, OUT> = (ctx: CoreContext,
|
||||
export type ValueResolver<IN, OUT> = (ctx: ApplicationContext,
|
||||
value: IN,
|
||||
md: SchemaField,
|
||||
reportError: OperationParamsErrorReporter) => OUT;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {Materializer, Type, TypeRegistry, Types} from "cad/craft/schema/types/index";
|
||||
import {CoreContext} from "cad/context";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {BaseSchemaField, OperationParamsErrorReporter, SchemaField} from "cad/craft/schema/schema";
|
||||
|
||||
export interface ArrayTypeSchema extends BaseSchemaField {
|
||||
|
|
@ -19,7 +19,7 @@ export interface ArrayTypeSchema extends BaseSchemaField {
|
|||
|
||||
export const ArrayType: Type<any[], any[], ArrayTypeSchema> = {
|
||||
|
||||
resolve(ctx: CoreContext,
|
||||
resolve(ctx: ApplicationContext,
|
||||
value: any[],
|
||||
md: ArrayTypeSchema,
|
||||
reportError: OperationParamsErrorReporter,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {Materializer, Type, Types} from "cad/craft/schema/types/index";
|
||||
import {CoreContext} from "cad/context";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {BaseSchemaField, OperationParamsErrorReporter} from "cad/craft/schema/schema";
|
||||
|
||||
export interface BooleanTypeSchema extends BaseSchemaField {
|
||||
|
|
@ -10,7 +10,7 @@ export interface BooleanTypeSchema extends BaseSchemaField {
|
|||
|
||||
export const BooleanType: Type<any, boolean, BooleanTypeSchema> = {
|
||||
|
||||
resolve(ctx: CoreContext,
|
||||
resolve(ctx: ApplicationContext,
|
||||
value: any,
|
||||
md: BooleanTypeSchema,
|
||||
reportError: OperationParamsErrorReporter,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {Type, TypeRegistry, Types} from "cad/craft/schema/types/index";
|
||||
import {CoreContext} from "cad/context";
|
||||
import {Type, Types} from "cad/craft/schema/types/index";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {BaseSchemaField, OperationParamsErrorReporter} from "cad/craft/schema/schema";
|
||||
import {EntityKind} from "cad/model/entities";
|
||||
import {MObject} from "cad/model/mobject";
|
||||
|
|
@ -20,7 +20,7 @@ export type EntityCapture = (entity: MObject) => boolean;
|
|||
|
||||
export const EntityType: Type<string, MObject, EntityTypeSchema> = {
|
||||
|
||||
resolve(ctx: CoreContext,
|
||||
resolve(ctx: ApplicationContext,
|
||||
value: string,
|
||||
md: EntityTypeSchema,
|
||||
reportError: OperationParamsErrorReporter): MObject {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {CoreContext} from "cad/context";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {OperationParams, OperationParamsErrorReporter, OperationSchema, SchemaField} from "cad/craft/schema/schema";
|
||||
import {ArrayType} from "cad/craft/schema/types/arrayType";
|
||||
import {EntityType} from "cad/craft/schema/types/entityType";
|
||||
|
|
@ -7,7 +7,7 @@ import {ObjectType} from "cad/craft/schema/types/objectType";
|
|||
import {StringType} from "cad/craft/schema/types/stringType";
|
||||
import {BooleanType} from "cad/craft/schema/types/booleanType";
|
||||
|
||||
export type Materializer = (ctx: CoreContext,
|
||||
export type Materializer = (ctx: ApplicationContext,
|
||||
params: OperationParams,
|
||||
schema: OperationSchema,
|
||||
result: any,
|
||||
|
|
@ -15,7 +15,7 @@ export type Materializer = (ctx: CoreContext,
|
|||
|
||||
export interface Type<IN, OUT, METADATA extends SchemaField> {
|
||||
|
||||
resolve(ctx: CoreContext, value: IN, md: METADATA,
|
||||
resolve(ctx: ApplicationContext, value: IN, md: METADATA,
|
||||
reportError: OperationParamsErrorReporter,
|
||||
materializer: Materializer): OUT;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {Materializer, Type, TypeRegistry, Types} from "cad/craft/schema/types/index";
|
||||
import {CoreContext} from "cad/context";
|
||||
import {BaseSchemaField, OperationParamsErrorReporter, SchemaField} from "cad/craft/schema/schema";
|
||||
import {EntityType} from "cad/craft/schema/types/entityType";
|
||||
import {Materializer, Type, Types} from "cad/craft/schema/types/index";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {BaseSchemaField, OperationParamsErrorReporter} from "cad/craft/schema/schema";
|
||||
|
||||
export interface NumberTypeSchema extends BaseSchemaField {
|
||||
|
||||
|
|
@ -15,7 +14,7 @@ export interface NumberTypeSchema extends BaseSchemaField {
|
|||
|
||||
export const NumberType: Type<any, number, NumberTypeSchema> = {
|
||||
|
||||
resolve(ctx: CoreContext,
|
||||
resolve(ctx: ApplicationContext,
|
||||
value: any,
|
||||
md: NumberTypeSchema,
|
||||
reportError: OperationParamsErrorReporter,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {Materializer, Type, TypeRegistry, Types} from "cad/craft/schema/types/index";
|
||||
import {CoreContext} from "cad/context";
|
||||
import {Materializer, Type, Types} from "cad/craft/schema/types/index";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {BaseSchemaField, OperationParamsErrorReporter, OperationSchema} from "cad/craft/schema/schema";
|
||||
|
||||
export interface ObjectTypeSchema extends BaseSchemaField {
|
||||
|
|
@ -14,7 +14,7 @@ export interface ObjectTypeSchema extends BaseSchemaField {
|
|||
|
||||
export const ObjectType: Type<any, any, ObjectTypeSchema> = {
|
||||
|
||||
resolve(ctx: CoreContext,
|
||||
resolve(ctx: ApplicationContext,
|
||||
value: any,
|
||||
md: ObjectTypeSchema,
|
||||
reportError: OperationParamsErrorReporter,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {Materializer, Type, TypeRegistry, Types} from "cad/craft/schema/types/index";
|
||||
import {CoreContext} from "cad/context";
|
||||
import {Materializer, Type, Types} from "cad/craft/schema/types/index";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {BaseSchemaField, OperationParamsErrorReporter} from "cad/craft/schema/schema";
|
||||
|
||||
export interface StringTypeSchema extends BaseSchemaField {
|
||||
|
|
@ -12,7 +12,7 @@ export interface StringTypeSchema extends BaseSchemaField {
|
|||
|
||||
export const StringType: Type<any, string, StringTypeSchema> = {
|
||||
|
||||
resolve(ctx: CoreContext,
|
||||
resolve(ctx: ApplicationContext,
|
||||
value: any,
|
||||
md: StringTypeSchema,
|
||||
reportError: OperationParamsErrorReporter,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import {merge, state, StateStream, Stream} from 'lstream';
|
||||
import {indexArray} from 'gems/iterables';
|
||||
import {CoreContext} from "cad/context";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
|
||||
export const BundleName = "@Expressions";
|
||||
|
||||
export function activate(ctx: CoreContext) {
|
||||
export function activate(ctx: ApplicationContext) {
|
||||
let _evaluateExpression: (string) => any = () => {};
|
||||
|
||||
const script$ = state('');
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {EntityKind} from "cad/model/entities";
|
|||
import {SectionWidgetProps} from "cad/mdf/ui/SectionWidget";
|
||||
import {MObject} from "cad/model/mobject";
|
||||
import Axis from "math/axis";
|
||||
import {CoreContext} from "cad/context";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {ObjectTypeSchema} from "cad/craft/schema/types/objectType";
|
||||
|
||||
export interface AxisInput {
|
||||
|
|
@ -13,7 +13,7 @@ export interface AxisInput {
|
|||
flip: boolean
|
||||
}
|
||||
|
||||
export const AxisResolver: ValueResolver<AxisInput, Axis> = (ctx: CoreContext,
|
||||
export const AxisResolver: ValueResolver<AxisInput, Axis> = (ctx: ApplicationContext,
|
||||
value: AxisInput,
|
||||
md: ObjectTypeSchema,
|
||||
reportError: OperationParamsErrorReporter): Axis => {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import React from "react";
|
||||
import {OperationParamsErrorReporter, ValueResolver} from "cad/craft/schema/schema";
|
||||
import {CoreContext} from "cad/context";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {ObjectTypeSchema} from "cad/craft/schema/types/objectType";
|
||||
import {AxisBasedWidgetDefinition, AxisBasedWidgetProps, AxisInput, AxisResolver} from "cad/mdf/ui/AxisWidget";
|
||||
import {UnitVector} from "math/vector";
|
||||
|
||||
export const DirectionResolver: ValueResolver<AxisInput, UnitVector> = (ctx: CoreContext,
|
||||
export const DirectionResolver: ValueResolver<AxisInput, UnitVector> = (ctx: ApplicationContext,
|
||||
value: AxisInput,
|
||||
md: ObjectTypeSchema,
|
||||
reportError: OperationParamsErrorReporter): UnitVector => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import {CoreContext} from "cad/context";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {ReadSketch} from "./sketchReader";
|
||||
|
||||
export function activate(ctx: CoreContext) {
|
||||
export function activate(ctx: ApplicationContext) {
|
||||
|
||||
function getAllSketches() {
|
||||
let nm = ctx.projectService.sketchStorageNamespace;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {stream} from 'lstream';
|
||||
import {CoreContext} from "cad/context";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
|
||||
const updates$ = stream();
|
||||
|
||||
|
|
@ -9,7 +9,7 @@ export function defineStreams(ctx) {
|
|||
}
|
||||
}
|
||||
|
||||
export function activate(ctx: CoreContext) {
|
||||
export function activate(ctx: ApplicationContext) {
|
||||
|
||||
const {services, streams} = ctx;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,17 +2,16 @@ import {OperationDescriptor} from "cad/craft/operationBundle";
|
|||
import {ActionDefinition} from "cad/actions/actionSystemBundle";
|
||||
import {state} from "lstream";
|
||||
import {Index} from "gems/indexType";
|
||||
import {ApplicationContext, CoreContext} from "cad/context";
|
||||
import {ApplicationContext} from "cad/context";
|
||||
import {ActionRef} from "cad/dom/uiBundle";
|
||||
import {IconDeclaration} from "cad/icons/IconDeclaration";
|
||||
import {CurrentWorkbenchIcon} from "cad/workbench/CurrentWorkbenchIcon";
|
||||
|
||||
export class WorkbenchService {
|
||||
|
||||
workbenches$ = state<Index<WorkbenchConfig>>({});
|
||||
|
||||
currentWorkbench$ = state<WorkbenchConfig>(null);
|
||||
ctx: CoreContext;
|
||||
ctx: ApplicationContext;
|
||||
|
||||
constructor(ctx: ApplicationContext) {
|
||||
this.ctx = ctx;
|
||||
|
|
|
|||
Loading…
Reference in a new issue