diff --git a/package-lock.json b/package-lock.json index 9f4b2201..950b4c0c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12998,9 +12998,9 @@ "dev": true }, "mobx": { - "version": "5.15.4", - "resolved": "https://registry.npmjs.org/mobx/-/mobx-5.15.4.tgz", - "integrity": "sha512-xRFJxSU2Im3nrGCdjSuOTFmxVDGeqOHL+TyADCGbT0k4HHqGmx5u2yaHNryvoORpI4DfbzjJ5jPmuv+d7sioFw==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/mobx/-/mobx-6.0.1.tgz", + "integrity": "sha512-Pk6uJXZ34yqd661yRmS6z/9avm4FOGXpFpVjnEfiYYOsZXnAxv1fpYjxTCEZ9tuwk0Xe1qnUUlgm+rJtGe0YJA==", "dev": true }, "mobx-react": { diff --git a/package.json b/package.json index 7df1754c..a5ec49be 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,7 @@ "jest": "^26.1.0", "license-checker": "^25.0.1", "lodash": "^4.17.19", - "mobx": "^5.15.4", + "mobx": "^6.0.1", "prettier": "^2.0.5", "raf": "^3.4.1", "react": "^16.13.1", @@ -129,7 +129,7 @@ }, "peerDependencies": { "core-js": "^3.1.4", - "mobx": "^4.2.0 || ^5.0.0", + "mobx": "^6.0.1", "react": "^16.8.4", "react-dom": "^16.8.4", "styled-components": "^4.1.1 || ^5.1.1" diff --git a/src/polyfills.ts b/src/polyfills.ts index 5c8a5635..f0dbc02b 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -2,6 +2,8 @@ import 'core-js/es/promise'; import 'core-js/es/array/find'; import 'core-js/es/object/assign'; +import 'core-js/es/object/entries'; +import 'core-js/es/object/is'; import 'core-js/es/string/ends-with'; import 'core-js/es/string/starts-with'; diff --git a/src/services/MenuStore.ts b/src/services/MenuStore.ts index 2a619af6..ac60fee8 100644 --- a/src/services/MenuStore.ts +++ b/src/services/MenuStore.ts @@ -1,4 +1,4 @@ -import { action, observable } from 'mobx'; +import { action, observable, makeObservable } from 'mobx'; import { querySelector } from '../utils/dom'; import { SpecStore } from './models'; @@ -76,6 +76,8 @@ export class MenuStore { * @param scroll scroll service instance used by this menu */ constructor(spec: SpecStore, public scroll: ScrollService, public history: HistoryService) { + makeObservable(this); + this.items = spec.contentItems; this.flatItems = flattenByProp(this.items || [], 'items'); diff --git a/src/services/models/Callback.ts b/src/services/models/Callback.ts index 7adfc27f..956537af 100644 --- a/src/services/models/Callback.ts +++ b/src/services/models/Callback.ts @@ -1,4 +1,4 @@ -import { action, observable } from 'mobx'; +import { action, observable, makeObservable } from 'mobx'; import { OpenAPICallback, Referenced } from '../../types'; import { isOperationName, JsonPointer } from '../../utils'; @@ -19,6 +19,8 @@ export class CallbackModel { pointer: string, options: RedocNormalizedOptions, ) { + makeObservable(this); + this.name = name; const paths = parser.deref(infoOrRef); parser.exitRef(infoOrRef); diff --git a/src/services/models/Field.ts b/src/services/models/Field.ts index b7b0311a..d156b039 100644 --- a/src/services/models/Field.ts +++ b/src/services/models/Field.ts @@ -1,4 +1,4 @@ -import { action, observable } from 'mobx'; +import { action, observable, makeObservable } from 'mobx'; import { OpenAPIParameter, @@ -61,6 +61,8 @@ export class FieldModel { pointer: string, options: RedocNormalizedOptions, ) { + makeObservable(this); + const info = parser.deref(infoOrRef); this.kind = infoOrRef.kind || 'field'; this.name = infoOrRef.name || info.name; diff --git a/src/services/models/Group.model.ts b/src/services/models/Group.model.ts index be3fc479..f1009f4e 100644 --- a/src/services/models/Group.model.ts +++ b/src/services/models/Group.model.ts @@ -1,4 +1,4 @@ -import { action, observable } from 'mobx'; +import { action, observable, makeObservable } from 'mobx'; import { OpenAPIExternalDocumentation, OpenAPITag } from '../../types'; import { safeSlugify } from '../../utils'; @@ -35,6 +35,8 @@ export class GroupModel implements IMenuItem { tagOrGroup: OpenAPITag | MarkdownHeading, parent?: GroupModel, ) { + makeObservable(this); + // markdown headings already have ids calculated as they are needed for heading anchors this.id = (tagOrGroup as MarkdownHeading).id || type + '/' + safeSlugify(tagOrGroup.name); this.type = type; diff --git a/src/services/models/MediaContent.ts b/src/services/models/MediaContent.ts index ff2c4950..e993da91 100644 --- a/src/services/models/MediaContent.ts +++ b/src/services/models/MediaContent.ts @@ -1,4 +1,4 @@ -import { action, computed, observable } from 'mobx'; +import { action, computed, observable, makeObservable } from 'mobx'; import { OpenAPIMediaType } from '../../types'; import { MediaTypeModel } from './MediaType'; @@ -26,6 +26,8 @@ export class MediaContentModel { public isRequestType: boolean, options: RedocNormalizedOptions, ) { + makeObservable(this); + if (options.unstable_ignoreMimeParameters) { info = mergeSimilarMediaTypes(info); } diff --git a/src/services/models/Operation.ts b/src/services/models/Operation.ts index 107865a0..d00461a1 100644 --- a/src/services/models/Operation.ts +++ b/src/services/models/Operation.ts @@ -1,4 +1,4 @@ -import { action, observable } from 'mobx'; +import { action, observable, makeObservable } from 'mobx'; import { IMenuItem } from '../MenuStore'; import { GroupModel } from './Group.model'; @@ -84,6 +84,8 @@ export class OperationModel implements IMenuItem { private options: RedocNormalizedOptions, isCallback: boolean = false, ) { + makeObservable(this); + this.pointer = operationSpec.pointer; this.description = operationSpec.description; diff --git a/src/services/models/Response.ts b/src/services/models/Response.ts index 3fc4d06c..2b4631ca 100644 --- a/src/services/models/Response.ts +++ b/src/services/models/Response.ts @@ -1,4 +1,4 @@ -import { action, observable } from 'mobx'; +import { action, observable, makeObservable } from 'mobx'; import { OpenAPIResponse, Referenced } from '../../types'; @@ -26,6 +26,8 @@ export class ResponseModel { infoOrRef: Referenced, options: RedocNormalizedOptions, ) { + makeObservable(this); + this.expanded = options.expandResponses === 'all' || options.expandResponses[code]; const info = parser.deref(infoOrRef); diff --git a/src/services/models/Schema.ts b/src/services/models/Schema.ts index b5986154..dd4a4d6f 100644 --- a/src/services/models/Schema.ts +++ b/src/services/models/Schema.ts @@ -1,4 +1,4 @@ -import { action, observable } from 'mobx'; +import { action, observable, makeObservable } from 'mobx'; import { OpenAPIExternalDocumentation, OpenAPISchema, Referenced } from '../../types'; @@ -72,6 +72,8 @@ export class SchemaModel { private options: RedocNormalizedOptions, isChild: boolean = false, ) { + makeObservable(this); + this.pointer = schemaOrRef.$ref || pointer || ''; this.rawSchema = parser.deref(schemaOrRef); this.schema = parser.mergeAllOf(this.rawSchema, this.pointer, isChild); diff --git a/src/standalone.tsx b/src/standalone.tsx index fb5a34d6..f0eda0b1 100644 --- a/src/standalone.tsx +++ b/src/standalone.tsx @@ -1,11 +1,16 @@ import * as React from 'react'; import { hydrate as hydrateComponent, render } from 'react-dom'; +import { configure } from "mobx" import { Redoc, RedocStandalone } from './components/'; import { AppStore, StoreState } from './services/AppStore'; import { debugTime, debugTimeEnd } from './utils/debug'; import { querySelector } from './utils/dom'; +configure({ + useProxies: 'ifavailable' +}) + export { Redoc, AppStore } from '.'; export const version = __REDOC_VERSION__;