@difizen/libro-jupyter 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/es/add-between-cell/add-between-cell.js +1 -1
  2. package/es/cell/jupyter-code-cell-view.d.ts +3 -1
  3. package/es/cell/jupyter-code-cell-view.d.ts.map +1 -1
  4. package/es/cell/jupyter-code-cell-view.js +12 -5
  5. package/es/command/command-contribution.d.ts.map +1 -1
  6. package/es/command/command-contribution.js +5 -5
  7. package/es/components/icons.js +1 -1
  8. package/es/contents/content-contribution.js +1 -1
  9. package/es/contents/save-content-contribution.d.ts +10 -0
  10. package/es/contents/save-content-contribution.d.ts.map +1 -0
  11. package/es/contents/save-content-contribution.js +110 -0
  12. package/es/file/file-create-modal.d.ts.map +1 -1
  13. package/es/file/file-create-modal.js +16 -5
  14. package/es/file/file-service.js +1 -1
  15. package/es/file/index.d.ts +1 -0
  16. package/es/file/index.d.ts.map +1 -1
  17. package/es/file/index.js +2 -1
  18. package/es/index.d.ts +1 -0
  19. package/es/index.d.ts.map +1 -1
  20. package/es/index.js +2 -1
  21. package/es/keybind-instructions/index.less +9 -9
  22. package/es/keybind-instructions/keybind-instructions-view.d.ts +2 -2
  23. package/es/keybind-instructions/keybind-instructions-view.d.ts.map +1 -1
  24. package/es/keybind-instructions/keybind-instructions-view.js +69 -63
  25. package/es/libro-jupyter-model.d.ts +2 -4
  26. package/es/libro-jupyter-model.d.ts.map +1 -1
  27. package/es/libro-jupyter-model.js +35 -120
  28. package/es/libro-jupyter-workspace.d.ts +18 -0
  29. package/es/libro-jupyter-workspace.d.ts.map +1 -0
  30. package/es/libro-jupyter-workspace.js +108 -0
  31. package/es/module.d.ts.map +1 -1
  32. package/es/module.js +5 -2
  33. package/es/output/libro-jupyter-outputarea.d.ts.map +1 -1
  34. package/es/output/libro-jupyter-outputarea.js +60 -56
  35. package/es/toolbar/save-file-error.d.ts.map +1 -1
  36. package/es/toolbar/save-file-error.js +20 -13
  37. package/es/widget/box/contribution.d.ts +10 -0
  38. package/es/widget/box/contribution.d.ts.map +1 -0
  39. package/es/widget/box/contribution.js +48 -0
  40. package/es/widget/box/index.d.ts +3 -0
  41. package/es/widget/box/index.d.ts.map +1 -0
  42. package/es/widget/box/index.js +2 -0
  43. package/es/widget/box/index.less +3 -0
  44. package/es/widget/box/view.d.ts +19 -0
  45. package/es/widget/box/view.d.ts.map +1 -0
  46. package/es/widget/box/view.js +114 -0
  47. package/es/widget/comm.d.ts +65 -0
  48. package/es/widget/comm.d.ts.map +1 -0
  49. package/es/widget/comm.js +153 -0
  50. package/es/widget/index.d.ts +10 -0
  51. package/es/widget/index.d.ts.map +1 -0
  52. package/es/widget/index.js +9 -0
  53. package/es/widget/index.less +7 -0
  54. package/es/widget/instance-progress/contribution.d.ts +10 -0
  55. package/es/widget/instance-progress/contribution.d.ts.map +1 -0
  56. package/es/widget/instance-progress/contribution.js +39 -0
  57. package/es/widget/instance-progress/index.d.ts +3 -0
  58. package/es/widget/instance-progress/index.d.ts.map +1 -0
  59. package/es/widget/instance-progress/index.js +2 -0
  60. package/es/widget/instance-progress/view.d.ts +30 -0
  61. package/es/widget/instance-progress/view.d.ts.map +1 -0
  62. package/es/widget/instance-progress/view.js +180 -0
  63. package/es/widget/libro-widgets.d.ts +84 -0
  64. package/es/widget/libro-widgets.d.ts.map +1 -0
  65. package/es/widget/libro-widgets.js +307 -0
  66. package/es/widget/module.d.ts +4 -0
  67. package/es/widget/module.d.ts.map +1 -0
  68. package/es/widget/module.js +38 -0
  69. package/es/widget/progress/contribution.d.ts +10 -0
  70. package/es/widget/progress/contribution.d.ts.map +1 -0
  71. package/es/widget/progress/contribution.js +39 -0
  72. package/es/widget/progress/index.d.ts +3 -0
  73. package/es/widget/progress/index.d.ts.map +1 -0
  74. package/es/widget/progress/index.js +2 -0
  75. package/es/widget/progress/progressBar.d.ts +15 -0
  76. package/es/widget/progress/progressBar.d.ts.map +1 -0
  77. package/es/widget/progress/progressBar.js +20 -0
  78. package/es/widget/progress/view.d.ts +19 -0
  79. package/es/widget/progress/view.d.ts.map +1 -0
  80. package/es/widget/progress/view.js +74 -0
  81. package/es/widget/protocol.d.ts +193 -0
  82. package/es/widget/protocol.d.ts.map +1 -0
  83. package/es/widget/protocol.js +33 -0
  84. package/es/widget/utils.d.ts +27 -0
  85. package/es/widget/utils.d.ts.map +1 -0
  86. package/es/widget/utils.js +59 -0
  87. package/es/widget/version.d.ts +3 -0
  88. package/es/widget/version.d.ts.map +1 -0
  89. package/es/widget/version.js +2 -0
  90. package/es/widget/widget-manager.d.ts +19 -0
  91. package/es/widget/widget-manager.d.ts.map +1 -0
  92. package/es/widget/widget-manager.js +77 -0
  93. package/es/widget/widget-render.d.ts +7 -0
  94. package/es/widget/widget-render.d.ts.map +1 -0
  95. package/es/widget/widget-render.js +46 -0
  96. package/es/widget/widget-rendermime-contribution.d.ts +16 -0
  97. package/es/widget/widget-rendermime-contribution.d.ts.map +1 -0
  98. package/es/widget/widget-rendermime-contribution.js +50 -0
  99. package/es/widget/widget-view-contribution.d.ts +10 -0
  100. package/es/widget/widget-view-contribution.d.ts.map +1 -0
  101. package/es/widget/widget-view-contribution.js +36 -0
  102. package/es/widget/widget-view.d.ts +71 -0
  103. package/es/widget/widget-view.d.ts.map +1 -0
  104. package/es/widget/widget-view.js +273 -0
  105. package/package.json +18 -18
  106. package/src/add-between-cell/add-between-cell.tsx +1 -1
  107. package/src/cell/jupyter-code-cell-view.tsx +14 -6
  108. package/src/command/command-contribution.ts +11 -10
  109. package/src/components/icons.tsx +1 -1
  110. package/src/contents/content-contribution.ts +1 -1
  111. package/src/contents/save-content-contribution.ts +67 -0
  112. package/src/file/file-create-modal.tsx +10 -1
  113. package/src/file/file-service.ts +1 -1
  114. package/src/file/index.ts +1 -0
  115. package/src/index.ts +1 -0
  116. package/src/keybind-instructions/index.less +9 -9
  117. package/src/keybind-instructions/keybind-instructions-view.tsx +72 -62
  118. package/src/libro-jupyter-model.ts +1 -69
  119. package/src/libro-jupyter-workspace.ts +49 -0
  120. package/src/module.ts +6 -0
  121. package/src/output/libro-jupyter-outputarea.tsx +56 -49
  122. package/src/toolbar/save-file-error.tsx +25 -15
  123. package/src/widget/box/contribution.ts +29 -0
  124. package/src/widget/box/index.less +3 -0
  125. package/src/widget/box/index.ts +2 -0
  126. package/src/widget/box/view.tsx +112 -0
  127. package/src/widget/comm.ts +152 -0
  128. package/src/widget/index.less +7 -0
  129. package/src/widget/index.ts +9 -0
  130. package/src/widget/instance-progress/contribution.ts +20 -0
  131. package/src/widget/instance-progress/index.ts +2 -0
  132. package/src/widget/instance-progress/view.tsx +155 -0
  133. package/src/widget/libro-widgets.ts +223 -0
  134. package/src/widget/module.ts +73 -0
  135. package/src/widget/progress/contribution.ts +24 -0
  136. package/src/widget/progress/index.ts +2 -0
  137. package/src/widget/progress/progressBar.tsx +29 -0
  138. package/src/widget/progress/view.tsx +70 -0
  139. package/src/widget/protocol.ts +255 -0
  140. package/src/widget/utils.ts +67 -0
  141. package/src/widget/version.ts +2 -0
  142. package/src/widget/widget-manager.ts +45 -0
  143. package/src/widget/widget-render.tsx +52 -0
  144. package/src/widget/widget-rendermime-contribution.ts +36 -0
  145. package/src/widget/widget-view-contribution.ts +14 -0
  146. package/src/widget/widget-view.tsx +259 -0
@@ -0,0 +1,193 @@
1
+ import type { JSONObject, JSONValue } from '@difizen/libro-common';
2
+ import type { IComm, IKernelConnection, KernelMessage } from '@difizen/libro-kernel';
3
+ import { Syringe } from '@difizen/mana-app';
4
+ import type { WidgetView } from './widget-view.js';
5
+ export interface IWidgetViewOptions {
6
+ model_id: string;
7
+ comm: IClassicComm;
8
+ }
9
+ export interface IWidgetViewProps {
10
+ attributes: any;
11
+ options: IWidgetViewOptions;
12
+ widgetsId: string;
13
+ }
14
+ /**
15
+ * A simple dictionary type.
16
+ */
17
+ export type Dict<T> = Record<string, T>;
18
+ export type BufferJSON = {
19
+ [property: string]: BufferJSON;
20
+ } | BufferJSON[] | string | number | boolean | null | ArrayBuffer | DataView;
21
+ export interface ISerializedState {
22
+ state: JSONObject;
23
+ buffers: ArrayBuffer[];
24
+ buffer_paths: (string | number)[][];
25
+ }
26
+ /**
27
+ * The widget manager interface exposed on the Widget instances
28
+ */
29
+ export interface IWidgets {
30
+ getModel: (model_id: string) => WidgetView;
31
+ /**
32
+ * Returns true if the given model is registered, otherwise false.
33
+ *
34
+ * #### Notes
35
+ * This is a synchronous way to check if a model is registered.
36
+ */
37
+ hasModel: (model_id: string) => boolean;
38
+ /**
39
+ * Register a model instance promise with the manager.
40
+ *
41
+ * By registering the model, it can later be retrieved with `getModel`.
42
+ */
43
+ registerWidgetView: (model_id: string, model: Promise<WidgetView>) => void;
44
+ newWidgetView: (attributes: any, options: IWidgetViewOptions) => Promise<WidgetView>;
45
+ }
46
+ export declare const LibroWidgetsFactory: unique symbol;
47
+ export type LibroWidgetsFactory = (options: WidgetsOption) => IWidgets;
48
+ export declare const WidgetsOption: unique symbol;
49
+ export interface WidgetsOption {
50
+ kc: IKernelConnection;
51
+ id: string;
52
+ }
53
+ export interface IWidgetView {
54
+ toJSON: () => string;
55
+ setState: (state: Dict<unknown>) => void;
56
+ handleCommMsg: (msg: KernelMessage.ICommMsgMsg) => Promise<void>;
57
+ model_id: string;
58
+ name: string;
59
+ module: string;
60
+ model_module: string;
61
+ model_name: string;
62
+ model_module_version: string;
63
+ view_module: string;
64
+ view_name: string | null;
65
+ view_module_version: string;
66
+ view_count: number | null;
67
+ }
68
+ export declare const IWidgetView: unique symbol;
69
+ export declare const WidgetViewContribution: Syringe.DefinedToken;
70
+ export interface WidgetViewContribution {
71
+ canHandle: (attributes: any) => number;
72
+ factory: (props: IWidgetViewProps) => Promise<WidgetView>;
73
+ }
74
+ export interface InstanceRecord {
75
+ startDate: number;
76
+ endDate: number;
77
+ }
78
+ interface Stage {
79
+ name: string;
80
+ backup_workers: number;
81
+ terminated_workers: number;
82
+ running_workers: number;
83
+ total_workers: number;
84
+ input_records: number;
85
+ output_records: number;
86
+ finished_percentage: number;
87
+ }
88
+ export interface Task {
89
+ name: string;
90
+ status: 'WAITING' | 'RUNNING' | 'SUCCESS' | 'FAILED' | 'SUSPENDED' | 'CANCELLED';
91
+ stages: Stage[];
92
+ }
93
+ export interface ProgressInstance {
94
+ id: string;
95
+ status: 'Running' | 'Suspended' | 'Terminated';
96
+ logview: string;
97
+ tasks: Task[];
98
+ }
99
+ export interface ProgressItem {
100
+ name: string;
101
+ key: string;
102
+ gen_time: string;
103
+ logView: string;
104
+ instances?: ProgressInstance[];
105
+ }
106
+ export type InstancesRecords = Record<string, InstanceRecord>;
107
+ /**
108
+ * Callbacks for services shim comms.
109
+ */
110
+ export interface ICallbacks {
111
+ shell?: Record<string, (msg: KernelMessage.IShellMessage) => void>;
112
+ iopub?: Record<string, (msg: KernelMessage.IIOPubMessage) => void>;
113
+ input?: (msg: KernelMessage.IStdinMessage) => void;
114
+ }
115
+ export declare const LibroWidgetCommFactory: unique symbol;
116
+ export type LibroWidgetCommFactory = (options: WidgetCommOption) => IClassicComm;
117
+ export declare const WidgetCommOption: unique symbol;
118
+ export interface WidgetCommOption {
119
+ comm: IComm;
120
+ }
121
+ export interface IClassicComm {
122
+ /**
123
+ * Comm id
124
+ * @return {string}
125
+ */
126
+ comm_id: string;
127
+ /**
128
+ * Target name
129
+ * @return {string}
130
+ */
131
+ target_name: string;
132
+ /**
133
+ * Opens a sibling comm in the backend
134
+ * @param data
135
+ * @param callbacks
136
+ * @param metadata
137
+ * @param buffers
138
+ * @return msg id
139
+ */
140
+ open(data: JSONValue, callbacks?: ICallbacks, metadata?: JSONObject, buffers?: ArrayBuffer[] | ArrayBufferView[]): string;
141
+ /**
142
+ * Sends a message to the sibling comm in the backend
143
+ * @param data
144
+ * @param callbacks
145
+ * @param metadata
146
+ * @param buffers
147
+ * @return message id
148
+ */
149
+ send(data: JSONValue, callbacks?: ICallbacks, metadata?: JSONObject, buffers?: ArrayBuffer[] | ArrayBufferView[]): string;
150
+ /**
151
+ * Closes the sibling comm in the backend
152
+ * @param data
153
+ * @param callbacks
154
+ * @param metadata
155
+ * @param buffers
156
+ * @return msg id
157
+ */
158
+ close(data?: JSONValue, callbacks?: ICallbacks, metadata?: JSONObject, buffers?: ArrayBuffer[] | ArrayBufferView[]): string;
159
+ /**
160
+ * Register a message handler
161
+ * @param callback, which is given a message
162
+ */
163
+ onMsg(callback: (x: any) => void): void;
164
+ /**
165
+ * Register a handler for when the comm is closed by the backend
166
+ * @param callback, which is given a message
167
+ */
168
+ onClose(callback: (x: any) => void): void;
169
+ }
170
+ export interface WidgetState {
171
+ msg_id?: string;
172
+ behavior?: string;
173
+ continuous_update: boolean;
174
+ description: string;
175
+ description_allow_html: boolean;
176
+ disabled: boolean;
177
+ layout?: string;
178
+ readout: boolean;
179
+ readout_format: string;
180
+ style?: string;
181
+ [key: string]: any;
182
+ }
183
+ export declare const defaultWidgetState: WidgetState;
184
+ export interface FormattableState {
185
+ readout: boolean;
186
+ readout_format: string;
187
+ }
188
+ export declare const defaultFormattableState: FormattableState;
189
+ export interface OrientableState {
190
+ orientation: 'horizontal' | 'vertical';
191
+ }
192
+ export {};
193
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/widget/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,MAAM,WAAW,gBAAg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BAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,uBAAuB,EAAE,gBAGrC,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,YAAY,GAAG,UAAU,CAAC;CACxC"}
@@ -0,0 +1,33 @@
1
+ import { Syringe } from '@difizen/mana-app';
2
+
3
+ /**
4
+ * A simple dictionary type.
5
+ */
6
+
7
+ /**
8
+ * The widget manager interface exposed on the Widget instances
9
+ */
10
+
11
+ export var LibroWidgetsFactory = Symbol('LibroWidgetsFactory');
12
+ export var WidgetsOption = Symbol('WidgetsOption');
13
+ export var IWidgetView = Symbol('IWidgetView');
14
+ export var WidgetViewContribution = Syringe.defineToken('WidgetViewContribution');
15
+
16
+ /**
17
+ * Callbacks for services shim comms.
18
+ */
19
+
20
+ export var LibroWidgetCommFactory = Symbol('LibroWidgetCommFactory');
21
+ export var WidgetCommOption = Symbol('WidgetCommOption');
22
+ export var defaultWidgetState = {
23
+ continuous_update: false,
24
+ description_allow_html: false,
25
+ description: '',
26
+ disabled: false,
27
+ readout: true,
28
+ readout_format: 'd'
29
+ };
30
+ export var defaultFormattableState = {
31
+ readout: true,
32
+ readout_format: 'd'
33
+ };
@@ -0,0 +1,27 @@
1
+ import type { BufferJSON, Dict } from './protocol.js';
2
+ /**
3
+ * Takes an object 'state' and fills in buffer[i] at 'path' buffer_paths[i]
4
+ * where buffer_paths[i] is a list indicating where in the object buffer[i] should
5
+ * be placed
6
+ * Example: state = {a: 1, b: {}, c: [0, null]}
7
+ * buffers = [array1, array2]
8
+ * buffer_paths = [['b', 'data'], ['c', 1]]
9
+ * Will lead to {a: 1, b: {data: array1}, c: [0, array2]}
10
+ */
11
+ export declare function put_buffers(state: Dict<BufferJSON>, buffer_paths: (string | number)[][], buffers: (DataView | ArrayBuffer | ArrayBufferView | {
12
+ buffer: ArrayBuffer;
13
+ })[]): void;
14
+ /**
15
+ * Creates a wrappable Promise rejection function.
16
+ *
17
+ * Creates a function that logs an error message before rethrowing
18
+ * the original error that caused the promise to reject.
19
+ */
20
+ export declare function reject(message: string, log: boolean): (error: Error) => never;
21
+ /**
22
+ * A polyfill for Object.assign
23
+ *
24
+ * This is from code that Typescript 2.4 generates for a polyfill.
25
+ */
26
+ export declare const assign: any;
27
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/widget/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAEtD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,EACvB,YAAY,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,EACnC,OAAO,EAAE,CAAC,QAAQ,GAAG,WAAW,GAAG,eAAe,GAAG;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,CAAC,EAAE,GAC9E,IAAI,CAiBN;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,WACV,KAAK,KAAG,KAAK,CAMtD;AAED;;;;GAIG;AACH,eAAO,MAAM,MAAM,KAYhB,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Takes an object 'state' and fills in buffer[i] at 'path' buffer_paths[i]
3
+ * where buffer_paths[i] is a list indicating where in the object buffer[i] should
4
+ * be placed
5
+ * Example: state = {a: 1, b: {}, c: [0, null]}
6
+ * buffers = [array1, array2]
7
+ * buffer_paths = [['b', 'data'], ['c', 1]]
8
+ * Will lead to {a: 1, b: {data: array1}, c: [0, array2]}
9
+ */
10
+ export function put_buffers(state, buffer_paths, buffers) {
11
+ for (var i = 0; i < buffer_paths.length; i++) {
12
+ var buffer_path = buffer_paths[i];
13
+ // make sure the buffers are DataViews
14
+ var buffer = buffers[i];
15
+ if (!(buffer instanceof DataView)) {
16
+ buffer = new DataView(buffer instanceof ArrayBuffer ? buffer : buffer.buffer);
17
+ }
18
+ // say we want to set state[x][y][z] = buffer
19
+ var obj = state;
20
+ // we first get obj = state[x][y]
21
+ for (var j = 0; j < buffer_path.length - 1; j++) {
22
+ obj = obj[buffer_path[j]];
23
+ }
24
+ // and then set: obj[z] = buffer
25
+ obj[buffer_path[buffer_path.length - 1]] = buffer;
26
+ }
27
+ }
28
+
29
+ /**
30
+ * Creates a wrappable Promise rejection function.
31
+ *
32
+ * Creates a function that logs an error message before rethrowing
33
+ * the original error that caused the promise to reject.
34
+ */
35
+ export function reject(message, log) {
36
+ return function promiseRejection(error) {
37
+ if (log) {
38
+ console.error(new Error(message));
39
+ }
40
+ throw error;
41
+ };
42
+ }
43
+
44
+ /**
45
+ * A polyfill for Object.assign
46
+ *
47
+ * This is from code that Typescript 2.4 generates for a polyfill.
48
+ */
49
+ export var assign = Object.assign || function (t) {
50
+ for (var i = 1; i < (arguments.length <= 1 ? 0 : arguments.length - 1); i++) {
51
+ var s = i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1];
52
+ for (var p in s) {
53
+ if (Object.prototype.hasOwnProperty.call(s, p)) {
54
+ t[p] = s[p];
55
+ }
56
+ }
57
+ }
58
+ return t;
59
+ };
@@ -0,0 +1,3 @@
1
+ export declare const LIBRO_WIDGETS_VERSION = "2.0.0";
2
+ export declare const PROTOCOL_VERSION = "2.1.0";
3
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/widget/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,UAAU,CAAC;AAC7C,eAAO,MAAM,gBAAgB,UAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ export var LIBRO_WIDGETS_VERSION = '2.0.0';
2
+ export var PROTOCOL_VERSION = '2.1.0';
@@ -0,0 +1,19 @@
1
+ import { LibroService } from '@difizen/libro-core';
2
+ import type { IKernelConnection } from '@difizen/libro-kernel';
3
+ import { LibroKernelManager } from '@difizen/libro-kernel';
4
+ import { ApplicationContribution } from '@difizen/mana-app';
5
+ import type { LibroWidgets } from './libro-widgets.js';
6
+ import type { WidgetsOption } from './protocol.js';
7
+ export declare class LibroWidgetManager implements ApplicationContribution {
8
+ widgetsFactory: (options: WidgetsOption) => LibroWidgets;
9
+ kernelManager: LibroKernelManager;
10
+ libroService: LibroService;
11
+ initialize: () => void;
12
+ getOrCreateWidgets: (kc: IKernelConnection) => LibroWidgets;
13
+ getWidgets(id: string): LibroWidgets | undefined;
14
+ /**
15
+ * Dictionary of model ids and model instance promises
16
+ */
17
+ protected widgets: Map<string, LibroWidgets>;
18
+ }
19
+ //# sourceMappingURL=widget-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-manager.d.ts","sourceRoot":"","sources":["../../src/widget/widget-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAoB,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAA2B,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAErF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,qBACa,kBAAmB,YAAW,uBAAuB;IACnC,cAAc,EAAG,CAC5C,OAAO,EAAE,aAAa,KACnB,YAAY,CAAC;IACU,aAAa,EAAE,kBAAkB,CAAC;IACxC,YAAY,EAAE,YAAY,CAAC;IAEjD,UAAU,aAMR;IAEF,kBAAkB,OAAQ,iBAAiB,kBAQzC;IAEF,UAAU,CAAC,EAAE,EAAE,MAAM;IAIrB;;OAEG;IAEH,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAa;CAC1D"}
@@ -0,0 +1,77 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
3
+ function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
4
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
6
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
8
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
10
+ function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
11
+ import { LibroService } from '@difizen/libro-core';
12
+ import { KernelConnection, LibroKernelManager } from '@difizen/libro-kernel';
13
+ import { inject, prop, singleton, ApplicationContribution } from '@difizen/mana-app';
14
+ import { LibroWidgetsFactory } from "./protocol.js";
15
+ export var LibroWidgetManager = (_dec = singleton({
16
+ contrib: ApplicationContribution
17
+ }), _dec2 = inject(LibroWidgetsFactory), _dec3 = inject(LibroKernelManager), _dec4 = inject(LibroService), _dec5 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function () {
18
+ function LibroWidgetManager() {
19
+ var _this = this;
20
+ _classCallCheck(this, LibroWidgetManager);
21
+ _initializerDefineProperty(this, "widgetsFactory", _descriptor, this);
22
+ _initializerDefineProperty(this, "kernelManager", _descriptor2, this);
23
+ _initializerDefineProperty(this, "libroService", _descriptor3, this);
24
+ this.initialize = function () {
25
+ _this.kernelManager.onConnectToKernel(function (kc) {
26
+ if (kc instanceof KernelConnection) {
27
+ _this.getOrCreateWidgets(kc);
28
+ }
29
+ });
30
+ };
31
+ this.getOrCreateWidgets = function (kc) {
32
+ var widgets = _this.widgets.get(kc.id);
33
+ if (widgets) {
34
+ return widgets;
35
+ }
36
+ var newWidgets = _this.widgetsFactory({
37
+ kc: kc,
38
+ id: kc.id
39
+ });
40
+ _this.widgets.set(kc.id, newWidgets);
41
+ return newWidgets;
42
+ };
43
+ /**
44
+ * Dictionary of model ids and model instance promises
45
+ */
46
+ _initializerDefineProperty(this, "widgets", _descriptor4, this);
47
+ }
48
+ _createClass(LibroWidgetManager, [{
49
+ key: "getWidgets",
50
+ value: function getWidgets(id) {
51
+ return this.widgets.get(id);
52
+ }
53
+ }]);
54
+ return LibroWidgetManager;
55
+ }(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "widgetsFactory", [_dec2], {
56
+ configurable: true,
57
+ enumerable: true,
58
+ writable: true,
59
+ initializer: null
60
+ }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "kernelManager", [_dec3], {
61
+ configurable: true,
62
+ enumerable: true,
63
+ writable: true,
64
+ initializer: null
65
+ }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "libroService", [_dec4], {
66
+ configurable: true,
67
+ enumerable: true,
68
+ writable: true,
69
+ initializer: null
70
+ }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "widgets", [_dec5], {
71
+ configurable: true,
72
+ enumerable: true,
73
+ writable: true,
74
+ initializer: function initializer() {
75
+ return new Map();
76
+ }
77
+ })), _class2)) || _class);
@@ -0,0 +1,7 @@
1
+ import type { BaseOutputView } from '@difizen/libro-core';
2
+ import React from 'react';
3
+ import './index.less';
4
+ export declare const WidgetRender: React.FC<{
5
+ model: BaseOutputView;
6
+ }>;
7
+ //# sourceMappingURL=widget-render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-render.d.ts","sourceRoot":"","sources":["../../src/widget/widget-render.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,qBAAqB,CAAC;AAI3E,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,cAAc,CAAC;AAKtB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,cAAc,CAAA;CAAE,CAwC5D,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { RenderMimeRegistry } from '@difizen/libro-rendermime';
2
+ import { getOrigin, useInject, ViewInstance, ViewRender } from '@difizen/mana-app';
3
+ import React from 'react';
4
+ import "./index.less";
5
+ import { LibroJupyterModel } from "../libro-jupyter-model.js";
6
+ import { LibroWidgetManager } from "./widget-manager.js";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ export var WidgetRender = function WidgetRender(props) {
9
+ var model = props.model;
10
+
11
+ // The widget will be rendered in the output through the MIME mechanism, obtaining the output context.
12
+ var output = useInject(ViewInstance);
13
+ var widgetManager = useInject(LibroWidgetManager);
14
+ var defaultRenderMime = useInject(RenderMimeRegistry);
15
+ var libro = model.cell.parent;
16
+ if (!(libro.model instanceof LibroJupyterModel) || !libro.model.kernelConnection) {
17
+ return null;
18
+ }
19
+ var widgets = widgetManager.getOrCreateWidgets(getOrigin(libro.model.kernelConnection));
20
+ var mimeType = defaultRenderMime.preferredMimeType(model);
21
+ if (mimeType) {
22
+ var model_id = JSON.parse(JSON.stringify(model.data[mimeType])).model_id;
23
+ if (model_id) {
24
+ var widgetView = widgets.getModel(model_id);
25
+ widgetView.setCell(getOrigin(output.cell));
26
+ if (widgetView.isCommClosed) {
27
+ return null;
28
+ }
29
+ return /*#__PURE__*/_jsx("div", {
30
+ className: "libro-widget-render-container",
31
+ children: /*#__PURE__*/_jsx("div", {
32
+ className: "libro-widget-render",
33
+ children: /*#__PURE__*/_jsx(ViewRender, {
34
+ view: widgetView
35
+ })
36
+ })
37
+ });
38
+ }
39
+ }
40
+ return /*#__PURE__*/_jsx("div", {
41
+ className: "libro-widget-render-container",
42
+ children: /*#__PURE__*/_jsx("div", {
43
+ className: "libro-widget-render empty"
44
+ })
45
+ });
46
+ };
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" resolution-mode="require"/>
2
+ import type { BaseOutputView } from '@difizen/libro-core';
3
+ import { RenderMimeContribution } from '@difizen/libro-rendermime';
4
+ import { LibroWidgetManager } from './widget-manager.js';
5
+ export declare class LibroWidgetMimeContribution implements RenderMimeContribution {
6
+ libroWidgetManager: LibroWidgetManager;
7
+ canHandle: (model: BaseOutputView) => number;
8
+ renderType: string;
9
+ safe: boolean;
10
+ mimeTypes: string[];
11
+ allowClear: boolean;
12
+ render: import("react").FC<{
13
+ model: BaseOutputView;
14
+ }>;
15
+ }
16
+ //# sourceMappingURL=widget-rendermime-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-rendermime-contribution.d.ts","sourceRoot":"","sources":["../../src/widget/widget-rendermime-contribution.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAKnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGzD,qBACa,2BAA4B,YAAW,sBAAsB;IAC5C,kBAAkB,EAAE,kBAAkB,CAAC;IACnE,SAAS,UAAW,cAAc,YAiBhC;IACF,UAAU,SAAoB;IAC9B,IAAI,UAAQ;IACZ,SAAS,WAAgD;IACzD,UAAU,UAAS;IACnB,MAAM;;OAAgB;CACvB"}
@@ -0,0 +1,50 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _dec, _dec2, _class, _class2, _descriptor;
3
+ function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
4
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
5
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
+ function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
10
+ function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
11
+ import { RenderMimeContribution } from '@difizen/libro-rendermime';
12
+ import { inject, singleton } from '@difizen/mana-app';
13
+ import { LibroJupyterModel } from "../libro-jupyter-model.js";
14
+ import { LibroWidgetManager } from "./widget-manager.js";
15
+ import { WidgetRender } from "./widget-render.js";
16
+ export var LibroWidgetMimeContribution = (_dec = singleton({
17
+ contrib: RenderMimeContribution
18
+ }), _dec2 = inject(LibroWidgetManager), _dec(_class = (_class2 = /*#__PURE__*/_createClass(function LibroWidgetMimeContribution() {
19
+ var _this = this;
20
+ _classCallCheck(this, LibroWidgetMimeContribution);
21
+ _initializerDefineProperty(this, "libroWidgetManager", _descriptor, this);
22
+ this.canHandle = function (model) {
23
+ var libroModel = model.cell.parent.model;
24
+ var rank = 0;
25
+ if (libroModel instanceof LibroJupyterModel && libroModel.kernelConnection) {
26
+ var kc = libroModel.kernelConnection;
27
+ var widget = _this.libroWidgetManager.getOrCreateWidgets(kc);
28
+ _this.mimeTypes.forEach(function (mimeType) {
29
+ var mimeData = model.data[mimeType];
30
+ if (mimeData && mimeData !== null) {
31
+ var data = JSON.parse(JSON.stringify(mimeData)).model_id;
32
+ if (Object.keys(model.data).includes(mimeType) && widget.hasModel(data)) {
33
+ rank = 100;
34
+ }
35
+ }
36
+ });
37
+ }
38
+ return rank;
39
+ };
40
+ this.renderType = 'widgetRenderer';
41
+ this.safe = true;
42
+ this.mimeTypes = ['application/vnd.jupyter.widget-view+json'];
43
+ this.allowClear = false;
44
+ this.render = WidgetRender;
45
+ }), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "libroWidgetManager", [_dec2], {
46
+ configurable: true,
47
+ enumerable: true,
48
+ writable: true,
49
+ initializer: null
50
+ })), _class2)) || _class);
@@ -0,0 +1,10 @@
1
+ import { ViewManager } from '@difizen/mana-app';
2
+ import type { IWidgetViewProps } from './protocol.js';
3
+ import { WidgetViewContribution } from './protocol.js';
4
+ import { WidgetView } from './widget-view.js';
5
+ export declare class DefaultWidgetViewContribution implements WidgetViewContribution {
6
+ viewManager: ViewManager;
7
+ canHandle: () => number;
8
+ factory(props: IWidgetViewProps): Promise<WidgetView>;
9
+ }
10
+ //# sourceMappingURL=widget-view-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-view-contribution.d.ts","sourceRoot":"","sources":["../../src/widget/widget-view-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AAEnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBACa,6BAA8B,YAAW,sBAAsB;IACrD,WAAW,EAAE,WAAW,CAAC;IAC9C,SAAS,eAAW;IACpB,OAAO,CAAC,KAAK,EAAE,gBAAgB;CAGhC"}
@@ -0,0 +1,36 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _dec, _dec2, _class, _class2, _descriptor;
3
+ function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
4
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
6
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
8
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
10
+ function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
11
+ import { ViewManager, inject, singleton } from '@difizen/mana-app';
12
+ import { WidgetViewContribution } from "./protocol.js";
13
+ import { WidgetView } from "./widget-view.js";
14
+ export var DefaultWidgetViewContribution = (_dec = singleton({
15
+ contrib: WidgetViewContribution
16
+ }), _dec2 = inject(ViewManager), _dec(_class = (_class2 = /*#__PURE__*/function () {
17
+ function DefaultWidgetViewContribution() {
18
+ _classCallCheck(this, DefaultWidgetViewContribution);
19
+ _initializerDefineProperty(this, "viewManager", _descriptor, this);
20
+ this.canHandle = function () {
21
+ return 1;
22
+ };
23
+ }
24
+ _createClass(DefaultWidgetViewContribution, [{
25
+ key: "factory",
26
+ value: function factory(props) {
27
+ return this.viewManager.getOrCreateView(WidgetView, props);
28
+ }
29
+ }]);
30
+ return DefaultWidgetViewContribution;
31
+ }(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "viewManager", [_dec2], {
32
+ configurable: true,
33
+ enumerable: true,
34
+ writable: true,
35
+ initializer: null
36
+ })), _class2)) || _class);