Commit Graph

154 Commits

Author SHA1 Message Date
diamondburned e08064021e Reproducible empty interface code generation
Prior to this commit, the code generator for package empty doesn't have
a defined order. This commit now sorts the packages before generation,
which gets rid of the main map's undefined order.
2020-10-03 23:24:15 -07:00
diamondburned dd4e230e0f Fixed UnreadContainer's comment
Prior to this commit, UnreadContainer's comments mentioned deprecated
SetUnread and such methods. It now reflects the new API.
2020-10-03 23:17:32 -07:00
diamondburned 99f7224d32 Mentioned now returns bool
Prior to this commit, the Mentioned method in MessageCreate didn't
return anything. This is a regression. It now returns a boolean that
indicates mentioned.
2020-10-03 23:14:54 -07:00
diamondburned 555931f974 Added Avatar() into Author
This commit adds the Avatar method into the Author interface. It returns
the URL if one, or it can return an empty string if either the service
does not support avatars or the user doesn't have avatars.
2020-10-03 23:08:24 -07:00
diamondburned aaa29f35b0 Author now has Name() over Namer
Prior to this commit, interface Author embedded interface Namer. This
doesn't work, as it is discouraged to keep a working state inside the
implementation of Author, but Namer's embedded Iconer requires a state.

The commit changed Author to use a Name method instead, which is only a
getter. It will no longer satisfy interface Name.
2020-10-03 22:52:21 -07:00
diamondburned 1588cfef9c Fixed IconContainer.SetIcon; added ImageContainer
This commit fixes IconContainer's SetIcon, which was SetImage prior to
this commit. Before the code generation commits, this container
originally had SetIcon.

This commit also adds back ImageContainer, which was a regression during
the code generation changes. It has the SetImage method.
2020-10-03 22:06:50 -07:00
diamondburned e2751cc260 Added helper functions in package text
This package adds back the Plain function from the old package text as
well as a new function called SolidColor that returns a new RGBA color
with the alpha bits maxed out.

These functions are there for convenience. They're also outside the
scope of the code generator and repository.
2020-10-03 21:29:15 -07:00
diamondburned 7b9b4864a5 Fixed package empty having wrong package name 2020-10-03 20:00:09 -07:00
diamondburned 2d00544d67 Added missing methods from embedded interfaces
This commit adds missing empty asserter methods from the interfaces
embedded in the parent interface.
2020-10-03 19:56:58 -07:00
diamondburned 59778af1dd Empty impls for package text
This commit adds empty structs that implement no-op asserter methods for
interfaces in package text. Those implementations have "Text" prefixed
to their names.

The added implementations stay in the same place as cchat's.
2020-10-03 19:31:44 -07:00
diamondburned 9a64b50703 Package text to use asserters; colors now RGBA
This commit regenerates package text to use asserters instead of
manually asserting structs. This is to both bring consistency to the
interfaces and prepare it for the incoming IPC additions.

This commit also changed the Colorer interface to require returning a
32-bit RGBA color. Before, backends could return 24-bit RGB OR 32-bit
RGBA, but there wasn't a good way to distinguish between the two. Now,
backends must set the alpha bits to 0xFF if it's 24-bit only.
2020-10-03 15:43:05 -07:00
diamondburned 25980eb794 Added package empty
This package adds the code generation for package empty, which provides
structs that has no-op asserter methods for ease of use.

The package demonstrates one of the many possible use cases of having a
repository ready for code generation.
2020-10-03 14:31:38 -07:00
diamondburned 2d93bf62ea Regenerated with Backlogger and fixes 2020-09-27 20:37:27 -07:00
diamondburned f515470458 Generated code now compiles; added DO NOT EDIT 2020-09-27 19:30:36 -07:00
diamondburned 516532ee01 Repository changes; regenerated code
This commit fixes some trivial errors in the repository package. The
changes are breaking.

This commit also replaced the old cchat and text Go source code files
with ones generated straight from the repository. To regenerate, run

    go generate ./...

The code is generated using the Jennifer library. In the future, all
generated code (including package empty and the RPC library) will use
Jennifer.
2020-09-27 18:41:17 -07:00
diamondburned 8e9321928b Added a repository for API source of truth
This commit adds a new package repository containing every single cchat
types that the package provides. Its goal is to be the source of truth
for the cchat files to be generated from.

A huge advantage of this is having types in an easily representable
format. This means that other languages can easily parse the repository
and generate its own types that are similar to the original ones.

Having a repository also allows easier code generation. For example,
this commit will allow generating the "empty" package in the future,
which would contain empty implementations of cchat databases that would
return nil for asserter methods.
2020-09-26 18:24:56 -07:00
diamondburned 8b8c46a714 Refactored to a completely new API
This commit refactors entirely the ways cchat interfaces extend others.
Prior to this commit, interfaces extend itself simply by implementing
methods. This change is crucial to allow structs to decide whether or
not an interface is extended during runtime.

The current change adds the "As" methods into interfaces. When said, for
example, "Messenger extends Server," we now have the Server interface
implementing the AsMessenger method instead of before where the struct
implementing Server also implemented Messenger's methods.

For future references, these method will be called asserter methods.

The biggest motivation for this change is that these asserter methods
can allow backends to decide whether or not certain features are
implemented during runtime. For example, not all servers may support
sending messages. The asserting method is also simpler than the actual
type assertions done before.

Another motivation is to prepare cchat for an API that can reasonably be
translated to something that can be transferred over the wire. Although
the API itself will likely not be transferred over actual networking,
there are lots of plans for IPC-ing the API. This could mean that
developers would be able to develop the backends and frontends in any
programming language.

A downside to this is that the API is more restricted in terms of
extending beyond interfaces defined in the package. The initial goal of
this was to allow certain frontends to check for additional interfaces
outside of cchat that certain services could implement. However, this
goal is mostly moot, as interfaces like these require prior extensive
knowledge from both the developers of the backend and frontend
libraries.
2020-09-25 19:31:01 -07:00
diamondburned d51668512b Fixed typo in MemberListDynamicSection 2020-09-07 20:36:32 -07:00
diamondburned 62711b89f2 Fixed superfluous Lister in Session 2020-09-07 18:30:12 -07:00
diamondburned 214233cf3d Fixed error: Messager -> Messenger
This commit breaks existing v0.1.0 code to fix a grammatical error.
2020-09-07 17:19:18 -07:00
diamondburned ab2b4d48fa Fixed assert example in package header
This commit fixed an error in the package header from the previous
commit.
2020-09-05 19:46:58 -07:00
diamondburned 40dbe21c82 Shorter interface names; "Is" method in interfaces
This commit introduces many breaking changes that will break all current
code, both in the frontend and backend.

This commit changes the previous interface names to shorter versions.
This is done because, with the addition of the parent interface being
embedded in every extension interfaces, it is pointless to have the
name indicate this relationship. Furthermore, shorter and concise names
are more idiomatic.

This commit also introduces the "Is" method that is in every extension
interfaces. The purpose of this method is to provide an alternative
mechanism to check if an interface is extended.

Prior to the "Is" method, the only way for a backend to indicate
channels that can either be sent a message or not is to use two
separate types. Now, backends could implement a single type and return a
true or false on the Is method.

This method has a major disadvantage: it makes type assertions longer
and more complex. Refer to the "assert extension interfaces" example for
an example.

Despite the above disadvantage, this change is needed by the RPC
implementation in the future. Thus, it is worth the trouble of checks
being more verbose.
2020-09-05 19:39:34 -07:00
diamondburned 4239dc47c4 Added rich.Empty
This commit adds rich.Empty for convenience. It describes an empty text
segment.
2020-09-05 19:39:34 -07:00
diamondburned cd018ef8f9 Added ID type; Added backlog interfaces
This commit adds the ID type, which is a type alias to a string. This
change does not break any APIs and is done purely for documentation
purposes.

This commit also adds backlog interfaces to add support for services
capable of storing and showing chat history.

A subtle behavior change with the above change would be that
MessageContainer implementations are now required to add a mechanism to
invalidate old containers when needed. For example, the MessagePrepender
passed into MessagesBefore must be invalidated by the frontend when the
channel in view is changed. This prevents stray messages from old
channels coming in.

There are many ways to invalidate a container, but the easiest way would
be to attach an optionally atomic boolean into the store and completely
separate the store from the view (aka widget).
2020-08-19 15:58:36 -07:00
diamondburned 1b70301711 Added MemberListDynamicSection
The interface MemberListDynamicSection was added to allow server
implementations to ignore the dynamic section methods if needed.

A new method LoadLess was also introduced into the new interfaces along
with the old LoadMore. This method basically unrolls the member list as
the user scroll back up.
2020-08-15 14:19:44 -07:00
diamondburned 681cc520d9 Added text.Plain helper function
This function was added for convenience.
2020-08-15 14:10:53 -07:00
diamondburned 2f5c86aa60 Breaking changes on member list interfaces
This commit breaks the old member list API in order to change several
things. These changes are done to improve the overall usability and
flexibility of their interfaces.

This commit introduces the method LoadMore into the MemberListSection
interface. The method was added to allow sections to be lazy loaded
conditionally. This allows the server to lazy load the member list over
the network.

In the future, there might be further modifications to allow clients to
invalidate or mark sections as stale, which would allow the server to
free up the list.

This commit also changed the old Name method of MemberListSection to use
the unified Namer interface. It also moved from using section's contents
as identifiers to having a dedicated ID method using the unified
Identifier interface.
2020-08-14 14:11:28 -07:00
diamondburned 3f4d50fa92 Added a Description and Placeholder field for auth entry
This commit adds 2 extra string fields into the authentication entry
struct. The objective is to allow backends to hint additional
information that the user might want to know while authenticating.

Frontends that cannot do placeholders can opt for another way to display
the information, such as adding it into the name, surrounded by
parentheses.
2020-07-29 16:55:28 -07:00
diamondburned 7ae629e1ca Added the ISC license 2020-07-19 10:44:34 -07:00
diamondburned c45d874a80 Added member list support; moved documentation off README and into GoDoc
This commit adds member list support for servers capable of showing
messages. This includes both backend and frontend interfaces.

A UserStatus type was added with the appropriate constants for this purpose,
but it could be used in the future for other purposes.

All cchat documentation has been moved off of the README and into
GoDoc's documentation sections. This is done to free up the README for
other useful information about the project that doesn't have to do with
the code itself.
2020-07-19 10:37:51 -07:00
diamondburned 8827df937d Added MentionerAvatar and MentionedImage; clarified new behavior for Mentioner
This commit adds the MentionerAvatar and MentionedImage interfaces. This
interface gives the mentioned object an avatar or image. An example of
this would be showing a user's avatar. This allows the frontend to do
simple layouting.

The new behavior for Mentioner states that the frontends should be able
to use the highlighted segment as the mentioned object's display name.
For example, if the mentioned segment highlights "@username", then the
frontend should display "@username" as the large text.
2020-07-19 00:55:57 -07:00
diamondburned 9a7fe13cef Removed SetMentioned from UnreadIndicator
This change was done because using a message as an argument for
SetMentioned was too much. The client can manually check which messages
have Mentioned being true and highlight them.

As we no longer need a message forr SetMentioned, it is now merged into
SetUnread. As such, SetUnread now takes both an unread and a mentioned
boolean.
2020-07-16 18:53:54 -07:00
diamondburned 9974fcc636 Changes ServerMessageUnreadIndicator to return a cancel callback
This commit is a breaking change. It changes the UnreadIndicate method
to require returning an additional stop callback similar to that in
Nickname.

The motivation for this change was that frontends need a way to announce
cancellation before it destroys its server containers. This may happen
when the backend wants to replace in the container a completely new
list. As such, old lists will be destroyed, and the frontend will call
UnreadIndicate again. Because of that, the old callbacks must be cleaned
up.
2020-07-16 18:40:18 -07:00
diamondburned 1fe254db60 Added documentation to clarify attachments 2020-07-09 16:13:17 -07:00
diamondburned 106b543f09 Adds message attachments
This commit adds message attachments. More specifically, the
MessageAttachment struct was added to represent a single attachment.
Interfaces are added as well, that is ServerMessageAttachmentSender and
SendableMessageAttachments.

For the most parts, the frontend will use SendableMessageAttachments,
which extends the usual SendableMessage.
2020-07-09 16:03:35 -07:00
diamondburned ecbd4515a2 Added Mentioner and clarifications
This commit adds the Mentioner interface. The objective is to have a
clickable mention string similar to that in Discord, that when pressed
will popup a small box containing the given user info.

In the future, Mentioner may be expanded to add Avatar capabilities, but
for now, it can be added using text segments.

This commit also clarified that segments can implement multiple
interfaces. This is done to allow segments such as Mentioner to also be
colored using Colorer.

Frontend implementations should, instead of a type switch, use multiple
if statements separately. This may introduce a lot more boilerplate code.
2020-07-07 13:26:39 -07:00
diamondburned (Forefront) 0abbf861bc Added Avatarer into package text
This commit adds Avatarer into the list of supported text segments. This
should work very similarly to Imager, except that avatars should be
rounded by the frontend.

This commit should make the text image APIs consistent with the main
cchat package.
2020-07-04 01:15:50 -07:00
diamondburned (Forefront) c8d6c89a08 Added Time into Typer 2020-07-01 13:32:54 -07:00
diamondburned (Forefront) 78767a3f2f Undo latest changes that added RoundIconContainers
This commit undos these latest changes and replaced them with the new
ImageContainer API as well as Image boolean in CompletionEntry.

These changes, unlike the earlier commits, are not breaking changes.
They are only additions.

ImageContainer is added for future usages, which translates to the
previous commits' IconContainer. The current IconContainer translates to
the previous commits' RoundIconContainer.
2020-07-01 10:49:44 -07:00
diamondburned (Forefront) d29ee70d56 Updated README to add RoundIconContainer 2020-06-30 19:46:50 -07:00
diamondburned (Forefront) e7aa6fb885 Added secondary text into completion entry; added RoundIconContainer
This change was done without breaking the existing API. Initially, the
idea was to use a URL fragment to indicate if an icon should be round.
That, however, was a bad idea, as URL fragments are part of the URL
string and would require additional effort to parse them. As such,
RoundIconContainer was added.

Frontends don't need to round icons from RoundIconContainer, and as
such, may call IconContainer in the implementation. The choice of using
round icons is up to the backend implementations.
2020-06-30 19:43:42 -07:00
diamondburned (Forefront) d754f011ba Clarified RunCommand's documentation
This clarification applies on the latest release; however, no releases
will be made for it.
2020-06-29 19:57:11 -07:00
diamondburned (Forefront) a8cfc54f6d Breaking: Added stop callbacks to functions that take in containers
This breaking change was done to provide a clean API for backends to
remove event handlers when they're not needed anymore. It also moves the
cancellation logic from the backend to the frontend, making it easier
for backends.
2020-06-29 13:27:00 -07:00
diamondburned (Forefront) 88879d45f2 Added typing capabilities and indicator interfaces
This commit adds typing capabilities and indicator interfaces into
cchat. The objective is to provide an API for typing event APIs similar
to Discord's and IRCv3's.
2020-06-29 11:39:59 -07:00
diamondburned (Forefront) 88834ab465 Added MessageEditable into ServerMessageEditor
This is a breaking change, as it modifies the ServerMessageEditor
interface.

This breaking change is done with the assumption that not all services
will support editing every single message. For example, Discord only
allows editing your own messages.

With the introduction of a MessageEditable method, services shouldn't
have to return an error to indicate that a message isn't editable
anymore.
2020-06-27 23:31:34 -07:00
diamondburned (Forefront) 5d2cd4a57b MessageActions now takes in a message ID.
This change was done to add support to messages that may have more or
less actions. For example, this lets the backend only display the
"Delete" option when the message can be deleted.

Documentation is also corrected and further done in this commit.
2020-06-20 15:52:04 -07:00
diamondburned (Forefront) 6c7cd5feb2 Added UnreadIndicator and ServerMessageIndicator for unread indicators 2020-06-20 15:02:05 -07:00
diamondburned (Forefront) dfb60ac0eb text.Rich to implement Stringer; extra docs 2020-06-20 00:10:23 -07:00
diamondburned (Forefront) e953dbbcb1 Added extra methods onto Imager.
This is done instead of text substitution, as images might have contexts
and other important attributes. One such example is an emoji, which may
have worked with text substitution, but would also work with a simple
string append.
2020-06-17 20:45:30 -07:00
diamondburned (Forefront) 05b7a6a10c Specified that Images cannot do text substitution
This commit specifies that images cannot substitute a piece of text with
itself. This means that end bounds of those segments are ignored, and
images will be inserted where the start bounds point them to.

Frontends that can't actually display images should represent this
information in another way by itself. One way is to treat this as a
hyperlink that says "Image."
2020-06-17 17:34:38 -07:00