| 1 |
import { JSONObject } from '@lumino/coreutils'; |
| 2 |
import { IClassicComm, ICallbacks } from './services-shim'; |
| 3 |
import { DOMWidgetModel, DOMWidgetView, WidgetModel, WidgetView } from './widget'; |
| 4 |
/** |
| 5 |
* The options for a model. |
| 6 |
* |
| 7 |
* #### Notes |
| 8 |
* Either a comm or a model_id must be provided. |
| 9 |
*/ |
| 10 |
export interface IModelOptions { |
| 11 |
/** |
| 12 |
* Target name of the widget model to create. |
| 13 |
*/ |
| 14 |
model_name: string; |
| 15 |
/** |
| 16 |
* Module name of the widget model to create. |
| 17 |
*/ |
| 18 |
model_module: string; |
| 19 |
/** |
| 20 |
* Semver version requirement for the model module. |
| 21 |
*/ |
| 22 |
model_module_version: string; |
| 23 |
/** |
| 24 |
* Target name of the widget view to create. |
| 25 |
*/ |
| 26 |
view_name?: string | null; |
| 27 |
/** |
| 28 |
* Module name of the widget view to create. |
| 29 |
*/ |
| 30 |
view_module?: string | null; |
| 31 |
/** |
| 32 |
* Semver version requirement for the view module. |
| 33 |
*/ |
| 34 |
view_module_version?: string; |
| 35 |
/** |
| 36 |
* Comm object associated with the widget. |
| 37 |
*/ |
| 38 |
comm?: any; |
| 39 |
/** |
| 40 |
* The model id to use. If not provided, the comm id of the comm is used. |
| 41 |
*/ |
| 42 |
model_id?: string; |
| 43 |
} |
| 44 |
/** |
| 45 |
* The options for a connected model. |
| 46 |
* |
| 47 |
* This gives all of the information needed to instantiate a comm to a new |
| 48 |
* widget on the kernel side (so view information is mandatory). |
| 49 |
* |
| 50 |
* #### Notes |
| 51 |
* Either a comm or a model_id must be provided. |
| 52 |
*/ |
| 53 |
export interface IWidgetOptions extends IModelOptions { |
| 54 |
/** |
| 55 |
* Target name of the widget model to create. |
| 56 |
*/ |
| 57 |
model_name: string; |
| 58 |
/** |
| 59 |
* Module name of the widget model to create. |
| 60 |
*/ |
| 61 |
model_module: string; |
| 62 |
/** |
| 63 |
* Semver version requirement for the model module. |
| 64 |
*/ |
| 65 |
model_module_version: string; |
| 66 |
/** |
| 67 |
* Target name of the widget view to create. |
| 68 |
*/ |
| 69 |
view_name: string | null; |
| 70 |
/** |
| 71 |
* Module name of the widget view to create. |
| 72 |
*/ |
| 73 |
view_module: string | null; |
| 74 |
/** |
| 75 |
* Semver version requirement for the view module. |
| 76 |
*/ |
| 77 |
view_module_version: string; |
| 78 |
/** |
| 79 |
* Comm object associated with the widget. |
| 80 |
*/ |
| 81 |
comm?: IClassicComm; |
| 82 |
/** |
| 83 |
* The model id to use. If not provided, the comm id of the comm is used. |
| 84 |
*/ |
| 85 |
model_id?: string; |
| 86 |
} |
| 87 |
/** |
| 88 |
* The widget manager interface exposed on the Widget instances |
| 89 |
*/ |
| 90 |
export interface IWidgetManager { |
| 91 |
/** |
| 92 |
* Get a promise for a model by model id. |
| 93 |
* |
| 94 |
* #### Notes |
| 95 |
* If a model is not found, undefined is returned (NOT a promise). However, |
| 96 |
* the calling code should also deal with the case where a rejected promise |
| 97 |
* is returned, and should treat that also as a model not found. |
| 98 |
*/ |
| 99 |
get_model(model_id: string): Promise<WidgetModel>; |
| 100 |
/** |
| 101 |
* Returns true if the given model is registered, otherwise false. |
| 102 |
* |
| 103 |
* #### Notes |
| 104 |
* This is a synchronous way to check if a model is registered. |
| 105 |
*/ |
| 106 |
has_model(model_id: string): boolean; |
| 107 |
/** |
| 108 |
* Register a model instance promise with the manager. |
| 109 |
* |
| 110 |
* By registering the model, it can later be retrieved with `get_model`. |
| 111 |
*/ |
| 112 |
register_model(model_id: string, modelPromise: Promise<WidgetModel>): void; |
| 113 |
/** |
| 114 |
* Create a comm and new widget model. |
| 115 |
* @param options - same options as new_model but comm is not |
| 116 |
* required and additional options are available. |
| 117 |
* @param serialized_state - serialized model attributes. |
| 118 |
*/ |
| 119 |
new_widget(options: IWidgetOptions, serialized_state?: JSONObject): Promise<WidgetModel>; |
| 120 |
/** |
| 121 |
* Create and return a promise for a new widget model |
| 122 |
* |
| 123 |
* @param options - the options for creating the model. |
| 124 |
* @param serialized_state - attribute values for the model. |
| 125 |
* |
| 126 |
* @example |
| 127 |
* widget_manager.new_model({ |
| 128 |
* model_name: 'IntSlider', |
| 129 |
* model_module: '@jupyter-widgets/controls', |
| 130 |
* model_module_version: '1.0.0', |
| 131 |
* model_id: 'u-u-i-d' |
| 132 |
* }).then((model) => { console.log('Create success!', model); }, |
| 133 |
* (err) => {console.error(err)}); |
| 134 |
* |
| 135 |
*/ |
| 136 |
new_model(options: IModelOptions, serialized_state?: JSONObject): Promise<WidgetModel>; |
| 137 |
/** |
| 138 |
* Creates a promise for a view of a given model |
| 139 |
* |
| 140 |
* Make sure the view creation is not out of order with |
| 141 |
* any state updates. |
| 142 |
*/ |
| 143 |
create_view<VT extends DOMWidgetView = DOMWidgetView>(model: DOMWidgetModel, options?: unknown): Promise<VT>; |
| 144 |
create_view<VT extends WidgetView = WidgetView>(model: WidgetModel, options?: unknown): Promise<VT>; |
| 145 |
/** |
| 146 |
* callback handlers specific to a view |
| 147 |
*/ |
| 148 |
callbacks(view?: WidgetView): ICallbacks; |
| 149 |
/** |
| 150 |
* Resolve a URL relative to the current notebook location. |
| 151 |
* |
| 152 |
* The default implementation just returns the original url. |
| 153 |
*/ |
| 154 |
resolveUrl(url: string): Promise<string>; |
| 155 |
inline_sanitize(s: string): string; |
| 156 |
} |
| 157 |
//# sourceMappingURL=manager.d.ts.map |