@assistant-ui/react
Version:
Typescript/React library for AI Chat
87 lines (86 loc) • 2.81 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/api/AttachmentRuntime.ts
var AttachmentRuntime_exports = {};
__export(AttachmentRuntime_exports, {
AttachmentRuntimeImpl: () => AttachmentRuntimeImpl,
EditComposerAttachmentRuntimeImpl: () => EditComposerAttachmentRuntimeImpl,
MessageAttachmentRuntimeImpl: () => MessageAttachmentRuntimeImpl,
ThreadComposerAttachmentRuntimeImpl: () => ThreadComposerAttachmentRuntimeImpl
});
module.exports = __toCommonJS(AttachmentRuntime_exports);
var AttachmentRuntimeImpl = class {
constructor(_core) {
this._core = _core;
}
get path() {
return this._core.path;
}
__internal_bindMethods() {
this.getState = this.getState.bind(this);
this.remove = this.remove.bind(this);
this.subscribe = this.subscribe.bind(this);
}
getState() {
return this._core.getState();
}
subscribe(callback) {
return this._core.subscribe(callback);
}
};
var ComposerAttachmentRuntime = class extends AttachmentRuntimeImpl {
constructor(core, _composerApi) {
super(core);
this._composerApi = _composerApi;
}
remove() {
const core = this._composerApi.getState();
if (!core) throw new Error("Composer is not available");
return core.removeAttachment(this.getState().id);
}
};
var ThreadComposerAttachmentRuntimeImpl = class extends ComposerAttachmentRuntime {
get source() {
return "thread-composer";
}
};
var EditComposerAttachmentRuntimeImpl = class extends ComposerAttachmentRuntime {
get source() {
return "edit-composer";
}
};
var MessageAttachmentRuntimeImpl = class extends AttachmentRuntimeImpl {
get source() {
return "message";
}
constructor(core) {
super(core);
}
remove() {
throw new Error("Message attachments cannot be removed");
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
AttachmentRuntimeImpl,
EditComposerAttachmentRuntimeImpl,
MessageAttachmentRuntimeImpl,
ThreadComposerAttachmentRuntimeImpl
});
//# sourceMappingURL=AttachmentRuntime.js.map
;