@omujs/chat 0.10.1 → 0.10.3
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.
- package/dist/models/content.d.ts +13 -11
- package/dist/models/content.js +1 -1
- package/dist/models/content.js.map +3 -3
- package/dist/models/gift.d.ts +1 -0
- package/dist/models/gift.js +1 -1
- package/dist/models/gift.js.map +2 -2
- package/dist/models/message.d.ts +1 -0
- package/dist/models/message.js +1 -1
- package/dist/models/message.js.map +2 -2
- package/dist/models/paid.d.ts +1 -0
- package/dist/models/paid.js +1 -1
- package/dist/models/paid.js.map +2 -2
- package/dist/models/room.d.ts +1 -0
- package/dist/models/room.js.map +2 -2
- package/package.json +2 -2
package/dist/models/content.d.ts
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { JsonType } from '@omujs/omu/serialize';
|
|
2
2
|
export interface ComponentType<T extends string, D extends JsonType = JsonType> {
|
|
3
|
-
type: T;
|
|
4
|
-
data: D;
|
|
3
|
+
readonly type: T;
|
|
4
|
+
readonly data: D;
|
|
5
5
|
}
|
|
6
|
-
export type Root = ComponentType<'root', Component[]>;
|
|
6
|
+
export type Root = ComponentType<'root', readonly Component[]>;
|
|
7
7
|
export type Text = ComponentType<'text', string>;
|
|
8
8
|
export type Image = ComponentType<'image', {
|
|
9
|
-
url: string;
|
|
10
|
-
id: string;
|
|
11
|
-
name?: string;
|
|
9
|
+
readonly url: string;
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly name?: string;
|
|
12
12
|
}>;
|
|
13
13
|
export type Asset = ComponentType<'asset', {
|
|
14
|
-
id: string;
|
|
14
|
+
readonly id: string;
|
|
15
15
|
}>;
|
|
16
16
|
export type Link = ComponentType<'link', {
|
|
17
|
-
url: string;
|
|
18
|
-
children: Component[];
|
|
17
|
+
readonly url: string;
|
|
18
|
+
readonly children: readonly Component[];
|
|
19
19
|
}>;
|
|
20
|
-
export type System = ComponentType<'system', Component[]>;
|
|
20
|
+
export type System = ComponentType<'system', readonly Component[]>;
|
|
21
21
|
export type Component = Root | Text | Image | Asset | Link | System;
|
|
22
|
-
export declare function children(component: Component): Component[];
|
|
22
|
+
export declare function children(component: Component): readonly Component[];
|
|
23
|
+
export declare function setChildren(component: Component, children: readonly Component[]): Component;
|
|
23
24
|
export declare function walk(component: Component): Iterable<Component>;
|
|
24
25
|
export declare function format(component: Component): string;
|
|
26
|
+
export declare function transform(component: Component, fn: (component: Component) => Component): Component;
|
package/dist/models/content.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function o(e){switch(e.type){case"root":return e.data;case"system":return e.data;case"link":return e.data.children;case"text":return[];case"image":return[];case"asset":return[]}}function*
|
|
1
|
+
function o(e){switch(e.type){case"root":return e.data;case"system":return e.data;case"link":return e.data.children;case"text":return[];case"image":return[];case"asset":return[]}}function a(e,t){switch(e.type){case"root":return{...e,data:t};case"system":return{...e,data:t};case"link":return{...e,data:{...e.data,children:t}};default:return e}}function*s(e){const t=[e];for(;t.length>0;){const n=t.pop();if(!n)return;yield n,t.push(...o(n).slice().reverse())}}function d(e){return[...s(e)].filter(t=>t.type==="text").map(t=>t.data).join("")}function y(e,t){const n=o(e).map(p=>y(p,t)),r=a(e,n);return t(r)}export{o as children,d as format,a as setChildren,y as transform,s as walk};
|
|
2
2
|
//# sourceMappingURL=content.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/models/content.ts"],
|
|
4
|
-
"sourcesContent": ["import { JsonType } from '@omujs/omu/serialize';\n\nexport interface ComponentType<T extends string, D extends JsonType = JsonType> {\n type: T;\n data: D;\n};\n\nexport type Root = ComponentType<'root', Component[]>;\n\nexport type Text = ComponentType<'text', string>;\n\nexport type Image = ComponentType<'image', {\n url: string;\n id: string;\n name?: string;\n}>;\n\nexport type Asset = ComponentType<'asset', {\n id: string;\n}>;\n\nexport type Link = ComponentType<'link', {\n url: string;\n children: Component[];\n}>;\n\nexport type System = ComponentType<'system', Component[]>;\n\nexport type Component =\n | Root\n | Text\n | Image\n | Asset\n | Link\n | System;\n\nexport function children(component: Component): Component[] {\n switch (component.type) {\n case 'root': return component.data;\n case 'system': return component.data;\n case 'link': return component.data.children;\n case 'text': return [];\n case 'image': return [];\n case 'asset': return [];\n }\n}\n\nexport function *walk(component: Component): Iterable<Component> {\n const queue = [component];\n while (queue.length > 0) {\n const component = queue.pop();\n if (!component) return;\n yield component;\n queue.push(...children(component).slice().reverse());\n }\n}\n\nexport function format(component: Component): string {\n return [...walk(component)]\n .filter(it => it.type === 'text')\n .map(it => it.data).join('');\n}\n"],
|
|
5
|
-
"mappings": "AAoCO,SAASA,EAASC,
|
|
6
|
-
"names": ["children", "component", "walk", "queue", "format", "it"]
|
|
4
|
+
"sourcesContent": ["import { JsonType } from '@omujs/omu/serialize';\n\nexport interface ComponentType<T extends string, D extends JsonType = JsonType> {\n readonly type: T;\n readonly data: D;\n};\n\nexport type Root = ComponentType<'root', readonly Component[]>;\n\nexport type Text = ComponentType<'text', string>;\n\nexport type Image = ComponentType<'image', {\n readonly url: string;\n readonly id: string;\n readonly name?: string;\n}>;\n\nexport type Asset = ComponentType<'asset', {\n readonly id: string;\n}>;\n\nexport type Link = ComponentType<'link', {\n readonly url: string;\n readonly children: readonly Component[];\n}>;\n\nexport type System = ComponentType<'system', readonly Component[]>;\n\nexport type Component =\n | Root\n | Text\n | Image\n | Asset\n | Link\n | System;\n\nexport function children(component: Component): readonly Component[] {\n switch (component.type) {\n case 'root': return component.data;\n case 'system': return component.data;\n case 'link': return component.data.children;\n case 'text': return [];\n case 'image': return [];\n case 'asset': return [];\n }\n}\n\nexport function setChildren(component: Component, children: readonly Component[]): Component {\n switch (component.type) {\n case 'root': return { ...component, data: children };\n case 'system': return { ...component, data: children };\n case 'link': return { ...component, data: { ...component.data, children } };\n default: return component;\n }\n}\n\nexport function *walk(component: Component): Iterable<Component> {\n const queue = [component];\n while (queue.length > 0) {\n const component = queue.pop();\n if (!component) return;\n yield component;\n queue.push(...children(component).slice().reverse());\n }\n}\n\nexport function format(component: Component): string {\n return [...walk(component)]\n .filter(it => it.type === 'text')\n .map(it => it.data).join('');\n}\n\nexport function transform(component: Component, fn: (component: Component) => Component): Component {\n const newChildren = children(component).map(child => transform(child, fn));\n const newComponent = setChildren(component, newChildren);\n return fn(newComponent);\n}\n"],
|
|
5
|
+
"mappings": "AAoCO,SAASA,EAASC,EAA4C,CACjE,OAAQA,EAAU,KAAM,CACpB,IAAK,OAAQ,OAAOA,EAAU,KAC9B,IAAK,SAAU,OAAOA,EAAU,KAChC,IAAK,OAAQ,OAAOA,EAAU,KAAK,SACnC,IAAK,OAAQ,MAAO,CAAC,EACrB,IAAK,QAAS,MAAO,CAAC,EACtB,IAAK,QAAS,MAAO,CAAC,CAC1B,CACJ,CAEO,SAASC,EAAYD,EAAsBD,EAA2C,CACzF,OAAQC,EAAU,KAAM,CACpB,IAAK,OAAQ,MAAO,CAAE,GAAGA,EAAW,KAAMD,CAAS,EACnD,IAAK,SAAU,MAAO,CAAE,GAAGC,EAAW,KAAMD,CAAS,EACrD,IAAK,OAAQ,MAAO,CAAE,GAAGC,EAAW,KAAM,CAAE,GAAGA,EAAU,KAAM,SAAAD,CAAS,CAAE,EAC1E,QAAS,OAAOC,CACpB,CACJ,CAEO,SAAUE,EAAKF,EAA2C,CAC7D,MAAMG,EAAQ,CAACH,CAAS,EACxB,KAAOG,EAAM,OAAS,GAAG,CACrB,MAAMH,EAAYG,EAAM,IAAI,EAC5B,GAAI,CAACH,EAAW,OAChB,MAAMA,EACNG,EAAM,KAAK,GAAGJ,EAASC,CAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,CACvD,CACJ,CAEO,SAASI,EAAOJ,EAA8B,CACjD,MAAO,CAAC,GAAGE,EAAKF,CAAS,CAAC,EACrB,OAAOK,GAAMA,EAAG,OAAS,MAAM,EAC/B,IAAIA,GAAMA,EAAG,IAAI,EAAE,KAAK,EAAE,CACnC,CAEO,SAASC,EAAUN,EAAsBO,EAAoD,CAChG,MAAMC,EAAcT,EAASC,CAAS,EAAE,IAAIS,GAASH,EAAUG,EAAOF,CAAE,CAAC,EACnEG,EAAeT,EAAYD,EAAWQ,CAAW,EACvD,OAAOD,EAAGG,CAAY,CAC1B",
|
|
6
|
+
"names": ["children", "component", "setChildren", "walk", "queue", "format", "it", "transform", "fn", "newChildren", "child", "newComponent"]
|
|
7
7
|
}
|
package/dist/models/gift.d.ts
CHANGED
package/dist/models/gift.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
class a{id;name;amount;isPaid;imageUrl;constructor(i){this.id=i.id,this.name=i.name,this.amount=i.amount,this.isPaid=i.isPaid,this.imageUrl=i.imageUrl}static fromJson(i){return new a({id:i.id,name:i.name,amount:i.amount,isPaid:i.is_paid,imageUrl:i.image_url})}toJson(){return{id:this.id,name:this.name,amount:this.amount,is_paid:this.isPaid,image_url:this.imageUrl}}}export{a as Gift};
|
|
1
|
+
class a{id;name;amount;isPaid;imageUrl;constructor(i){this.id=i.id,this.name=i.name,this.amount=i.amount,this.isPaid=i.isPaid,this.imageUrl=i.imageUrl}static fromJson(i){return new a({id:i.id,name:i.name,amount:i.amount,isPaid:i.is_paid,imageUrl:i.image_url})}toJson(){return{id:this.id,name:this.name,amount:this.amount,is_paid:this.isPaid,image_url:this.imageUrl}}clone(){return new a({id:this.id,name:this.name,amount:this.amount,isPaid:this.isPaid,imageUrl:this.imageUrl})}}export{a as Gift};
|
|
2
2
|
//# sourceMappingURL=gift.js.map
|
package/dist/models/gift.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/models/gift.ts"],
|
|
4
|
-
"sourcesContent": ["export type GiftJson = {\n id: string;\n name?: string;\n amount?: number;\n is_paid?: boolean;\n image_url?: string;\n};\n\nexport class Gift {\n id: string;\n name?: string;\n amount?: number;\n isPaid?: boolean;\n imageUrl?: string;\n\n constructor(options: {\n id: string;\n name?: string;\n amount?: number;\n isPaid?: boolean;\n imageUrl?: string;\n }) {\n this.id = options.id;\n this.name = options.name;\n this.amount = options.amount;\n this.isPaid = options.isPaid;\n this.imageUrl = options.imageUrl;\n }\n\n static fromJson(options: GiftJson): Gift {\n return new Gift({\n id: options.id,\n name: options.name,\n amount: options.amount,\n isPaid: options.is_paid,\n imageUrl: options.image_url,\n });\n }\n\n toJson(): GiftJson {\n return {\n id: this.id,\n name: this.name,\n amount: this.amount,\n is_paid: this.isPaid,\n image_url: this.imageUrl,\n };\n }\n}\n"],
|
|
5
|
-
"mappings": "AAQO,MAAMA,CAAK,CACd,GACA,KACA,OACA,OACA,SAEA,YAAYC,EAMT,CACC,KAAK,GAAKA,EAAQ,GAClB,KAAK,KAAOA,EAAQ,KACpB,KAAK,OAASA,EAAQ,OACtB,KAAK,OAASA,EAAQ,OACtB,KAAK,SAAWA,EAAQ,QAC5B,CAEA,OAAO,SAASA,EAAyB,CACrC,OAAO,IAAID,EAAK,CACZ,GAAIC,EAAQ,GACZ,KAAMA,EAAQ,KACd,OAAQA,EAAQ,OAChB,OAAQA,EAAQ,QAChB,SAAUA,EAAQ,SACtB,CAAC,CACL,CAEA,QAAmB,CACf,MAAO,CACH,GAAI,KAAK,GACT,KAAM,KAAK,KACX,OAAQ,KAAK,OACb,QAAS,KAAK,OACd,UAAW,KAAK,QACpB,CACJ,CACJ",
|
|
4
|
+
"sourcesContent": ["export type GiftJson = {\n id: string;\n name?: string;\n amount?: number;\n is_paid?: boolean;\n image_url?: string;\n};\n\nexport class Gift {\n id: string;\n name?: string;\n amount?: number;\n isPaid?: boolean;\n imageUrl?: string;\n\n constructor(options: {\n id: string;\n name?: string;\n amount?: number;\n isPaid?: boolean;\n imageUrl?: string;\n }) {\n this.id = options.id;\n this.name = options.name;\n this.amount = options.amount;\n this.isPaid = options.isPaid;\n this.imageUrl = options.imageUrl;\n }\n\n static fromJson(options: GiftJson): Gift {\n return new Gift({\n id: options.id,\n name: options.name,\n amount: options.amount,\n isPaid: options.is_paid,\n imageUrl: options.image_url,\n });\n }\n\n toJson(): GiftJson {\n return {\n id: this.id,\n name: this.name,\n amount: this.amount,\n is_paid: this.isPaid,\n image_url: this.imageUrl,\n };\n }\n\n public clone(): Gift {\n return new Gift({\n id: this.id,\n name: this.name,\n amount: this.amount,\n isPaid: this.isPaid,\n imageUrl: this.imageUrl,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAQO,MAAMA,CAAK,CACd,GACA,KACA,OACA,OACA,SAEA,YAAYC,EAMT,CACC,KAAK,GAAKA,EAAQ,GAClB,KAAK,KAAOA,EAAQ,KACpB,KAAK,OAASA,EAAQ,OACtB,KAAK,OAASA,EAAQ,OACtB,KAAK,SAAWA,EAAQ,QAC5B,CAEA,OAAO,SAASA,EAAyB,CACrC,OAAO,IAAID,EAAK,CACZ,GAAIC,EAAQ,GACZ,KAAMA,EAAQ,KACd,OAAQA,EAAQ,OAChB,OAAQA,EAAQ,QAChB,SAAUA,EAAQ,SACtB,CAAC,CACL,CAEA,QAAmB,CACf,MAAO,CACH,GAAI,KAAK,GACT,KAAM,KAAK,KACX,OAAQ,KAAK,OACb,QAAS,KAAK,OACd,UAAW,KAAK,QACpB,CACJ,CAEO,OAAc,CACjB,OAAO,IAAID,EAAK,CACZ,GAAI,KAAK,GACT,KAAM,KAAK,KACX,OAAQ,KAAK,OACb,OAAQ,KAAK,OACb,SAAU,KAAK,QACnB,CAAC,CACL,CACJ",
|
|
6
6
|
"names": ["Gift", "options"]
|
|
7
7
|
}
|
package/dist/models/message.d.ts
CHANGED
package/dist/models/message.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Identifier as i}from"@omujs/omu";import*as
|
|
1
|
+
import{Identifier as i}from"@omujs/omu";import*as r from"./content.js";import{Gift as o}from"./gift.js";import{Paid as n}from"./paid.js";class d{roomId;id;authorId;content;paid;gifts;createdAt;deleted;constructor(t){if(!(t.createdAt instanceof Date))throw new Error("created_at must be a Date");this.roomId=t.roomId,this.id=t.id,this.authorId=t.authorId,this.content=t.content,this.paid=t.paid,this.gifts=t.gifts,this.createdAt=t.createdAt,this.deleted=t.deleted}static serialize(t){return{room_id:t.roomId.key(),id:t.id.key(),author_id:t.authorId?.key(),created_at:t.createdAt.toISOString(),content:t.content,paid:t.paid?.toJson(),gifts:t.gifts?.map(e=>e.toJson()),deleted:t.deleted}}static deserialize(t){return new d({roomId:i.fromKey(t.room_id),id:i.fromKey(t.id),authorId:t.author_id?i.fromKey(t.author_id):void 0,content:t.content,paid:t.paid&&n.fromJson(t.paid),gifts:t.gifts?.map(e=>o.fromJson(e)),createdAt:new Date(t.created_at),deleted:t.deleted})}get text(){return this.content?r.format(this.content):""}key(){return this.id.key()}clone(){return new d({roomId:this.roomId,id:this.id,authorId:this.authorId,content:this.content,paid:this.paid?.clone(),gifts:this.gifts?this.gifts.map(t=>t.clone()):void 0,createdAt:new Date(this.createdAt.getTime()),deleted:this.deleted})}}export{d as Message};
|
|
2
2
|
//# sourceMappingURL=message.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/models/message.ts"],
|
|
4
|
-
"sourcesContent": ["import { Identifier } from '@omujs/omu';\nimport * as content from './content.js';\nimport type { GiftJson } from './gift.js';\nimport { Gift } from './gift.js';\nimport type { PaidJson } from './paid.js';\nimport { Paid } from './paid.js';\n\nexport type MessageJson = {\n room_id: string;\n id: string;\n created_at: string; // ISO 8601 date string\n author_id?: string;\n content?: content.Component;\n paid?: PaidJson;\n gifts?: GiftJson[];\n deleted?: boolean;\n};\n\nexport class Message {\n public roomId: Identifier;\n public id: Identifier;\n public authorId?: Identifier;\n public content?: content.Component;\n public paid?: Paid;\n public gifts?: Gift[];\n public createdAt: Date;\n public deleted?: boolean;\n\n constructor(options: {\n roomId: Identifier;\n id: Identifier;\n authorId?: Identifier;\n createdAt: Date;\n content?: content.Component;\n paid?: Paid;\n gifts?: Gift[];\n deleted?: boolean;\n }) {\n if (!(options.createdAt instanceof Date)) {\n throw new Error('created_at must be a Date');\n }\n this.roomId = options.roomId;\n this.id = options.id;\n this.authorId = options.authorId;\n this.content = options.content;\n this.paid = options.paid;\n this.gifts = options.gifts;\n this.createdAt = options.createdAt;\n this.deleted = options.deleted;\n }\n\n public static serialize(data: Message): MessageJson {\n return {\n room_id: data.roomId.key(),\n id: data.id.key(),\n author_id: data.authorId?.key(),\n created_at: data.createdAt.toISOString(),\n content: data.content,\n paid: data.paid?.toJson(),\n gifts: data.gifts?.map((gift) => gift.toJson()),\n deleted: data.deleted,\n };\n }\n\n public static deserialize(info: MessageJson): Message {\n return new Message({\n roomId: Identifier.fromKey(info.room_id),\n id: Identifier.fromKey(info.id),\n authorId: info.author_id ? Identifier.fromKey(info.author_id) : undefined,\n content: info.content,\n paid: info.paid && Paid.fromJson(info.paid),\n gifts: info.gifts?.map((gift) => Gift.fromJson(gift)),\n createdAt: new Date(info.created_at),\n deleted: info.deleted,\n });\n }\n\n get text(): string {\n if (!this.content) {\n return '';\n }\n return content.format(this.content);\n }\n\n key(): string {\n return this.id.key();\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,cAAAA,MAAkB,aAC3B,UAAYC,MAAa,eAEzB,OAAS,QAAAC,MAAY,YAErB,OAAS,QAAAC,MAAY,YAad,MAAMC,CAAQ,CACV,OACA,GACA,SACA,QACA,KACA,MACA,UACA,QAEP,YAAYC,EAST,CACC,GAAI,EAAEA,EAAQ,qBAAqB,MAC/B,MAAM,IAAI,MAAM,2BAA2B,EAE/C,KAAK,OAASA,EAAQ,OACtB,KAAK,GAAKA,EAAQ,GAClB,KAAK,SAAWA,EAAQ,SACxB,KAAK,QAAUA,EAAQ,QACvB,KAAK,KAAOA,EAAQ,KACpB,KAAK,MAAQA,EAAQ,MACrB,KAAK,UAAYA,EAAQ,UACzB,KAAK,QAAUA,EAAQ,OAC3B,CAEA,OAAc,UAAUC,EAA4B,CAChD,MAAO,CACH,QAASA,EAAK,OAAO,IAAI,EACzB,GAAIA,EAAK,GAAG,IAAI,EAChB,UAAWA,EAAK,UAAU,IAAI,EAC9B,WAAYA,EAAK,UAAU,YAAY,EACvC,QAASA,EAAK,QACd,KAAMA,EAAK,MAAM,OAAO,EACxB,MAAOA,EAAK,OAAO,IAAKC,GAASA,EAAK,OAAO,CAAC,EAC9C,QAASD,EAAK,OAClB,CACJ,CAEA,OAAc,YAAYE,EAA4B,CAClD,OAAO,IAAIJ,EAAQ,CACf,OAAQJ,EAAW,QAAQQ,EAAK,OAAO,EACvC,GAAIR,EAAW,QAAQQ,EAAK,EAAE,EAC9B,SAAUA,EAAK,UAAYR,EAAW,QAAQQ,EAAK,SAAS,EAAI,OAChE,QAASA,EAAK,QACd,KAAMA,EAAK,MAAQL,EAAK,SAASK,EAAK,IAAI,EAC1C,MAAOA,EAAK,OAAO,IAAKD,GAASL,EAAK,SAASK,CAAI,CAAC,EACpD,UAAW,IAAI,KAAKC,EAAK,UAAU,EACnC,QAASA,EAAK,OAClB,CAAC,CACL,CAEA,IAAI,MAAe,CACf,OAAK,KAAK,QAGHP,EAAQ,OAAO,KAAK,OAAO,EAFvB,EAGf,CAEA,KAAc,CACV,OAAO,KAAK,GAAG,IAAI,CACvB,CACJ",
|
|
4
|
+
"sourcesContent": ["import { Identifier } from '@omujs/omu';\nimport * as content from './content.js';\nimport type { GiftJson } from './gift.js';\nimport { Gift } from './gift.js';\nimport type { PaidJson } from './paid.js';\nimport { Paid } from './paid.js';\n\nexport type MessageJson = {\n room_id: string;\n id: string;\n created_at: string; // ISO 8601 date string\n author_id?: string;\n content?: content.Component;\n paid?: PaidJson;\n gifts?: GiftJson[];\n deleted?: boolean;\n};\n\nexport class Message {\n public roomId: Identifier;\n public id: Identifier;\n public authorId?: Identifier;\n public content?: content.Component;\n public paid?: Paid;\n public gifts?: Gift[];\n public createdAt: Date;\n public deleted?: boolean;\n\n constructor(options: {\n roomId: Identifier;\n id: Identifier;\n authorId?: Identifier;\n createdAt: Date;\n content?: content.Component;\n paid?: Paid;\n gifts?: Gift[];\n deleted?: boolean;\n }) {\n if (!(options.createdAt instanceof Date)) {\n throw new Error('created_at must be a Date');\n }\n this.roomId = options.roomId;\n this.id = options.id;\n this.authorId = options.authorId;\n this.content = options.content;\n this.paid = options.paid;\n this.gifts = options.gifts;\n this.createdAt = options.createdAt;\n this.deleted = options.deleted;\n }\n\n public static serialize(data: Message): MessageJson {\n return {\n room_id: data.roomId.key(),\n id: data.id.key(),\n author_id: data.authorId?.key(),\n created_at: data.createdAt.toISOString(),\n content: data.content,\n paid: data.paid?.toJson(),\n gifts: data.gifts?.map((gift) => gift.toJson()),\n deleted: data.deleted,\n };\n }\n\n public static deserialize(info: MessageJson): Message {\n return new Message({\n roomId: Identifier.fromKey(info.room_id),\n id: Identifier.fromKey(info.id),\n authorId: info.author_id ? Identifier.fromKey(info.author_id) : undefined,\n content: info.content,\n paid: info.paid && Paid.fromJson(info.paid),\n gifts: info.gifts?.map((gift) => Gift.fromJson(gift)),\n createdAt: new Date(info.created_at),\n deleted: info.deleted,\n });\n }\n\n get text(): string {\n if (!this.content) {\n return '';\n }\n return content.format(this.content);\n }\n\n key(): string {\n return this.id.key();\n }\n\n public clone(): Message {\n return new Message({\n roomId: this.roomId,\n id: this.id,\n authorId: this.authorId,\n content: this.content,\n paid: this.paid?.clone(),\n gifts: this.gifts ? this.gifts.map((gift) => gift.clone()) : undefined,\n createdAt: new Date(this.createdAt.getTime()),\n deleted: this.deleted,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,cAAAA,MAAkB,aAC3B,UAAYC,MAAa,eAEzB,OAAS,QAAAC,MAAY,YAErB,OAAS,QAAAC,MAAY,YAad,MAAMC,CAAQ,CACV,OACA,GACA,SACA,QACA,KACA,MACA,UACA,QAEP,YAAYC,EAST,CACC,GAAI,EAAEA,EAAQ,qBAAqB,MAC/B,MAAM,IAAI,MAAM,2BAA2B,EAE/C,KAAK,OAASA,EAAQ,OACtB,KAAK,GAAKA,EAAQ,GAClB,KAAK,SAAWA,EAAQ,SACxB,KAAK,QAAUA,EAAQ,QACvB,KAAK,KAAOA,EAAQ,KACpB,KAAK,MAAQA,EAAQ,MACrB,KAAK,UAAYA,EAAQ,UACzB,KAAK,QAAUA,EAAQ,OAC3B,CAEA,OAAc,UAAUC,EAA4B,CAChD,MAAO,CACH,QAASA,EAAK,OAAO,IAAI,EACzB,GAAIA,EAAK,GAAG,IAAI,EAChB,UAAWA,EAAK,UAAU,IAAI,EAC9B,WAAYA,EAAK,UAAU,YAAY,EACvC,QAASA,EAAK,QACd,KAAMA,EAAK,MAAM,OAAO,EACxB,MAAOA,EAAK,OAAO,IAAKC,GAASA,EAAK,OAAO,CAAC,EAC9C,QAASD,EAAK,OAClB,CACJ,CAEA,OAAc,YAAYE,EAA4B,CAClD,OAAO,IAAIJ,EAAQ,CACf,OAAQJ,EAAW,QAAQQ,EAAK,OAAO,EACvC,GAAIR,EAAW,QAAQQ,EAAK,EAAE,EAC9B,SAAUA,EAAK,UAAYR,EAAW,QAAQQ,EAAK,SAAS,EAAI,OAChE,QAASA,EAAK,QACd,KAAMA,EAAK,MAAQL,EAAK,SAASK,EAAK,IAAI,EAC1C,MAAOA,EAAK,OAAO,IAAKD,GAASL,EAAK,SAASK,CAAI,CAAC,EACpD,UAAW,IAAI,KAAKC,EAAK,UAAU,EACnC,QAASA,EAAK,OAClB,CAAC,CACL,CAEA,IAAI,MAAe,CACf,OAAK,KAAK,QAGHP,EAAQ,OAAO,KAAK,OAAO,EAFvB,EAGf,CAEA,KAAc,CACV,OAAO,KAAK,GAAG,IAAI,CACvB,CAEO,OAAiB,CACpB,OAAO,IAAIG,EAAQ,CACf,OAAQ,KAAK,OACb,GAAI,KAAK,GACT,SAAU,KAAK,SACf,QAAS,KAAK,QACd,KAAM,KAAK,MAAM,MAAM,EACvB,MAAO,KAAK,MAAQ,KAAK,MAAM,IAAKG,GAASA,EAAK,MAAM,CAAC,EAAI,OAC7D,UAAW,IAAI,KAAK,KAAK,UAAU,QAAQ,CAAC,EAC5C,QAAS,KAAK,OAClB,CAAC,CACL,CACJ",
|
|
6
6
|
"names": ["Identifier", "content", "Gift", "Paid", "Message", "options", "data", "gift", "info"]
|
|
7
7
|
}
|
package/dist/models/paid.d.ts
CHANGED
package/dist/models/paid.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
class
|
|
1
|
+
class r{constructor(n,t){this.amount=n;this.currency=t}static fromJson(n){return new r(n.amount,n.currency)}toJson(){return{amount:this.amount,currency:this.currency}}clone(){return new r(this.amount,this.currency)}}export{r as Paid};
|
|
2
2
|
//# sourceMappingURL=paid.js.map
|
package/dist/models/paid.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/models/paid.ts"],
|
|
4
|
-
"sourcesContent": ["export type PaidJson = {\n amount: number;\n currency: string;\n};\n\nexport class Paid {\n constructor(\n public amount: number,\n public currency: string,\n ) { }\n\n static fromJson(options: PaidJson): Paid {\n return new Paid(options.amount, options.currency);\n }\n\n toJson(): PaidJson {\n return {\n amount: this.amount,\n currency: this.currency,\n };\n }\n}\n"],
|
|
5
|
-
"mappings": "AAKO,MAAMA,CAAK,CACd,YACWC,EACAC,EACT,CAFS,YAAAD,EACA,cAAAC,CACP,CAEJ,OAAO,SAASC,EAAyB,CACrC,OAAO,IAAIH,EAAKG,EAAQ,OAAQA,EAAQ,QAAQ,CACpD,CAEA,QAAmB,CACf,MAAO,CACH,OAAQ,KAAK,OACb,SAAU,KAAK,QACnB,CACJ,CACJ",
|
|
4
|
+
"sourcesContent": ["export type PaidJson = {\n amount: number;\n currency: string;\n};\n\nexport class Paid {\n constructor(\n public amount: number,\n public currency: string,\n ) { }\n\n static fromJson(options: PaidJson): Paid {\n return new Paid(options.amount, options.currency);\n }\n\n toJson(): PaidJson {\n return {\n amount: this.amount,\n currency: this.currency,\n };\n }\n\n public clone(): Paid {\n return new Paid(this.amount, this.currency);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAKO,MAAMA,CAAK,CACd,YACWC,EACAC,EACT,CAFS,YAAAD,EACA,cAAAC,CACP,CAEJ,OAAO,SAASC,EAAyB,CACrC,OAAO,IAAIH,EAAKG,EAAQ,OAAQA,EAAQ,QAAQ,CACpD,CAEA,QAAmB,CACf,MAAO,CACH,OAAQ,KAAK,OACb,SAAU,KAAK,QACnB,CACJ,CAEO,OAAc,CACjB,OAAO,IAAIH,EAAK,KAAK,OAAQ,KAAK,QAAQ,CAC9C,CACJ",
|
|
6
6
|
"names": ["Paid", "amount", "currency", "options"]
|
|
7
7
|
}
|
package/dist/models/room.d.ts
CHANGED
package/dist/models/room.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/models/room.ts"],
|
|
4
|
-
"sourcesContent": ["import { Identifier } from '@omujs/omu';\n\nexport type MetadataJson = {\n title?: string;\n description?: string;\n url?: string;\n thumbnail?: string;\n viewers?: number;\n created_at?: string;\n started_at?: string;\n ended_at?: string;\n first_message_id?: string;\n last_message_id?: string;\n};\n\nexport type Status = 'online' | 'reserved' | 'offline';\n\nexport type RoomJson = {\n id: string;\n provider_id: string;\n connected: boolean;\n status: Status;\n metadata: MetadataJson;\n channel_id?: string;\n created_at: string; // ISO 8601 date string\n};\n\nexport class Room {\n public id: Identifier;\n public providerId: Identifier;\n public connected: boolean;\n public status: Status;\n public metadata: MetadataJson;\n public channelId?: string;\n public createdAt: Date;\n\n constructor(options: {\n id: Identifier;\n providerId: Identifier;\n connected: boolean;\n status: Status;\n metadata: MetadataJson;\n channelId?: string;\n createdAt: Date;\n }) {\n this.id = options.id;\n this.providerId = options.providerId;\n this.connected = options.connected;\n this.status = options.status;\n this.metadata = options.metadata;\n this.channelId = options.channelId;\n this.createdAt = options.createdAt;\n }\n\n public static deserialize(options: RoomJson): Room {\n return new Room({\n id: Identifier.fromKey(options.id),\n providerId: Identifier.fromKey(options.provider_id),\n connected: options.connected,\n status: options.status,\n metadata: options.metadata,\n channelId: options.channel_id,\n createdAt: new Date(options.created_at),\n });\n }\n\n public static serialize(item: Room): RoomJson {\n return {\n id: item.id.key(),\n provider_id: item.providerId.key(),\n connected: item.connected,\n status: item.status,\n metadata: item.metadata,\n channel_id: item.channelId,\n created_at: item.createdAt.toISOString(),\n };\n }\n\n key(): string {\n return this.id.key();\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,cAAAA,MAAkB,
|
|
4
|
+
"sourcesContent": ["import { Identifier } from '@omujs/omu';\n\nexport type MetadataJson = {\n title?: string;\n description?: string;\n url?: string;\n thumbnail?: string;\n viewers?: number;\n created_at?: string;\n started_at?: string;\n ended_at?: string;\n first_message_id?: string;\n last_message_id?: string;\n likes?: number;\n};\n\nexport type Status = 'online' | 'reserved' | 'offline';\n\nexport type RoomJson = {\n id: string;\n provider_id: string;\n connected: boolean;\n status: Status;\n metadata: MetadataJson;\n channel_id?: string;\n created_at: string; // ISO 8601 date string\n};\n\nexport class Room {\n public id: Identifier;\n public providerId: Identifier;\n public connected: boolean;\n public status: Status;\n public metadata: MetadataJson;\n public channelId?: string;\n public createdAt: Date;\n\n constructor(options: {\n id: Identifier;\n providerId: Identifier;\n connected: boolean;\n status: Status;\n metadata: MetadataJson;\n channelId?: string;\n createdAt: Date;\n }) {\n this.id = options.id;\n this.providerId = options.providerId;\n this.connected = options.connected;\n this.status = options.status;\n this.metadata = options.metadata;\n this.channelId = options.channelId;\n this.createdAt = options.createdAt;\n }\n\n public static deserialize(options: RoomJson): Room {\n return new Room({\n id: Identifier.fromKey(options.id),\n providerId: Identifier.fromKey(options.provider_id),\n connected: options.connected,\n status: options.status,\n metadata: options.metadata,\n channelId: options.channel_id,\n createdAt: new Date(options.created_at),\n });\n }\n\n public static serialize(item: Room): RoomJson {\n return {\n id: item.id.key(),\n provider_id: item.providerId.key(),\n connected: item.connected,\n status: item.status,\n metadata: item.metadata,\n channel_id: item.channelId,\n created_at: item.createdAt.toISOString(),\n };\n }\n\n key(): string {\n return this.id.key();\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,cAAAA,MAAkB,aA4BpB,MAAMC,CAAK,CACP,GACA,WACA,UACA,OACA,SACA,UACA,UAEP,YAAYC,EAQT,CACC,KAAK,GAAKA,EAAQ,GAClB,KAAK,WAAaA,EAAQ,WAC1B,KAAK,UAAYA,EAAQ,UACzB,KAAK,OAASA,EAAQ,OACtB,KAAK,SAAWA,EAAQ,SACxB,KAAK,UAAYA,EAAQ,UACzB,KAAK,UAAYA,EAAQ,SAC7B,CAEA,OAAc,YAAYA,EAAyB,CAC/C,OAAO,IAAID,EAAK,CACZ,GAAID,EAAW,QAAQE,EAAQ,EAAE,EACjC,WAAYF,EAAW,QAAQE,EAAQ,WAAW,EAClD,UAAWA,EAAQ,UACnB,OAAQA,EAAQ,OAChB,SAAUA,EAAQ,SAClB,UAAWA,EAAQ,WACnB,UAAW,IAAI,KAAKA,EAAQ,UAAU,CAC1C,CAAC,CACL,CAEA,OAAc,UAAUC,EAAsB,CAC1C,MAAO,CACH,GAAIA,EAAK,GAAG,IAAI,EAChB,YAAaA,EAAK,WAAW,IAAI,EACjC,UAAWA,EAAK,UAChB,OAAQA,EAAK,OACb,SAAUA,EAAK,SACf,WAAYA,EAAK,UACjB,WAAYA,EAAK,UAAU,YAAY,CAC3C,CACJ,CAEA,KAAc,CACV,OAAO,KAAK,GAAG,IAAI,CACvB,CACJ",
|
|
6
6
|
"names": ["Identifier", "Room", "options", "item"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@omujs/chat",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.3",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"import": "./dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"url": "https://github.com/OMUAPPS/omuapps"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@omujs/omu": "0.10.
|
|
28
|
+
"@omujs/omu": "0.10.3"
|
|
29
29
|
},
|
|
30
30
|
"gitHead": "04559d5aec52117d707e0d554ee429b858da522a"
|
|
31
31
|
}
|