@nteract/epics
Version:
Redux-Observable epics for nteract apps
87 lines • 3.46 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ipywidgetsModel$ = void 0;
const messaging_1 = require("@nteract/messaging");
const actions_1 = require("@nteract/actions");
const selectors = __importStar(require("@nteract/selectors"));
const types_1 = require("@nteract/types");
const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
/**
* Listen for comm_open messages from the kernel that are associated
* with models that will not be rendered on the page.
*
* Note: this is not an ideal solution but we need to do this
* so that we can keep the WidgetManager contextualized to the
* WidgetDisplay as opposed to at the top-level.
*/
exports.ipywidgetsModel$ = (kernel, model, contentRef) => kernel.channels.pipe(messaging_1.ofMessageType("comm_open"), operators_1.filter((msg) => {
if (msg.content.data &&
msg.content.data.state &&
msg.content.data.state._model_name === "LinkModel") {
return true;
}
return false;
}), operators_1.switchMap((msg) => {
return rxjs_1.of(actions_1.commOpenAction(msg),
/**
* If the content we are running under is a notebook,
* then append a mock output for the linkModel to the
* notebook.
*/
model && model.type === "notebook"
? actions_1.appendOutput({
/**
* Append the output to the currently focused cell.
*
* Ideally, we would append the output to the cell
* that the output was generated in. However, we
* don't currently do any associated between the source
* of execution and the follow-on actions.
*/
id: selectors.notebook.cellFocused(model) ||
selectors.notebook
.cellOrder(model)
.first(),
contentRef,
output: {
output_type: "display_data",
data: {
"application/vnd.jupyter.widget-view+json": {
model_id: msg.content.comm_id,
version_major: 2,
version_minor: 0
}
},
metadata: {},
transient: {}
}
})
: null);
}), operators_1.catchError((error) => {
return rxjs_1.of(actions_1.executeFailed({
error: new Error("The WebSocket connection has unexpectedly disconnected."),
code: types_1.errors.EXEC_WEBSOCKET_ERROR,
contentRef
}));
}));
//# sourceMappingURL=ipywidgets.js.map