react-qml
Version:
135 lines (124 loc) • 5.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _scheduler = require("scheduler");
var _invariant = _interopRequireDefault(require("invariant"));
var _RQElementContainer = _interopRequireDefault(require("./RQElementContainer"));
var _UIManager = _interopRequireDefault(require("./UIManager"));
var _RQAttributePayload = require("./RQAttributePayload");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var nullElement = {
parent: null,
destroy: function destroy() {}
};
var nullElementContainer = new _RQElementContainer.default(nullElement, {
defaultProp: 'data'
});
var hostConfig = {
now: Date.now,
isPrimaryRenderer: true,
noTimeout: -1,
supportsPersistence: false,
supportsHydration: false,
shouldDeprioritizeSubtree: function shouldDeprioritizeSubtree(type, props) {
return false;
},
scheduleDeferredCallback: function scheduleDeferredCallback(callback, options) {},
cancelDeferredCallback: function cancelDeferredCallback(callbackID) {},
schedulePassiveEffects: _scheduler.unstable_scheduleCallback,
cancelPassiveEffects: _scheduler.unstable_cancelCallback,
setTimeout: function setTimeout(handler, timeout) {
if (global && global.setTimeout) {
return global.setTimeout(handler, timeout);
}
return -1;
},
clearTimeout: function clearTimeout(handle) {
if (typeof handle !== 'number' && global && global.clearTimeout) {
global.clearTimeout(handle);
}
},
// general
getPublicInstance: function getPublicInstance(instance) {
// return qml element
return instance.element;
},
getRootHostContext: function getRootHostContext(rootContainerInstance) {
var rootContext = _UIManager.default.getHostContext(rootContainerInstance);
// UIManager.removeAllChildren(rootContext);
return rootContext;
},
getChildHostContext: function getChildHostContext(parentHostContext, type, rootContainerInstance) {
return parentHostContext;
},
shouldSetTextContent: function shouldSetTextContent(type, props) {
return false;
},
createTextInstance: function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) {
(0, _invariant.default)(false, 'Creating text instance not supported');
return nullElementContainer;
},
createInstance: function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
return _UIManager.default.createElementContainer(type, props, rootContainerInstance, hostContext);
},
appendInitialChild: function appendInitialChild(parent, child) {
parent.appendChild(child);
},
finalizeInitialChildren: function finalizeInitialChildren(parentInstance, type, props, rootContainerInstance, hostContext) {
return false;
},
prepareForCommit: function prepareForCommit(rootContainerInstance) {},
resetAfterCommit: function resetAfterCommit(rootContainerInstance) {},
// -------------------
// Mutation
// -------------------
supportsMutation: true,
appendChild: function appendChild(parent, child) {
parent.appendChild(child);
},
appendChildToContainer: function appendChildToContainer(container, child) {
container.appendChild(child);
},
commitTextUpdate: function commitTextUpdate(textInstance, oldText, newText) {
(0, _invariant.default)(false, 'Text instance not supported');
},
resetTextContent: function resetTextContent(instance) {
(0, _invariant.default)(false, 'Text instance not supported');
},
commitMount: function commitMount(instance, type, newProps, fiberNode) {},
prepareUpdate: function prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, hostContext) {
return {};
},
commitUpdate: function commitUpdate(instance, updatePayloadTODO, type, oldProps, newProps, internalInstanceHandle) {
var updatePayload = (0, _RQAttributePayload.diffProps)(oldProps, newProps);
if (updatePayload != null) {
// update props
(0, _RQAttributePayload.updateProps)(instance, updatePayload);
}
},
removeChild: function removeChild(parent, child) {
parent.removeChild(child);
},
removeChildFromContainer: function removeChildFromContainer(container, child) {
container.removeChild(child);
},
insertBefore: function insertBefore(parentInstance, child, beforeChild) {
_UIManager.default.insertBefore(parentInstance, child, beforeChild);
},
insertInContainerBefore: function insertInContainerBefore(container, child, beforeChild) {
_UIManager.default.insertBefore(container, child, beforeChild);
},
// @ts-ignore
hideInstance: function hideInstance(instance) {
instance.element.visible = false;
},
hideTextInstance: function hideTextInstance(instance) {},
unhideInstance: function unhideInstance(instance) {},
unhideTextInstance: function unhideTextInstance(instance) {
instance.element.visible = true;
}
};
var _default = hostConfig;
exports.default = _default;