Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into sara/update-stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusc93 committed Dec 10, 2024
2 parents 1d037c3 + 2433d6a commit 62aeaa6
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 66 deletions.
50 changes: 25 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "warp-ipfs"
name = "warp-wasm"
version = "0.1.0"
edition = "2021"

Expand Down
4 changes: 2 additions & 2 deletions examples/from-js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ fn main() {
let cmd = get_cmd("cargo install wasm-pack");
spawn_and_wait(cmd);

println!("\nBuilding warp-ipfs wasm files ...");
println!("\nBuilding warp wasm files ...");
let cmd =
get_cmd("wasm-pack build --target web --out-dir examples/from-js/built-wasm/warp-ipfs");
get_cmd("wasm-pack build --target web --out-dir examples/from-js/built-wasm/warp-wasm");
spawn_and_wait(cmd);

println!("\nStarting file server ...");
Expand Down
2 changes: 1 addition & 1 deletion examples/from-js/ipfs-constellation.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Warp Wasm Test</title>
</head>
<script type="module">
import init, * as wasm from './built-wasm/warp-ipfs/warp_ipfs.js';
import init, * as wasm from './built-wasm/warp-wasm/warp_wasm.js';
init().then(async (_exports) => {
console.log(wasm)
let ipfs = await new wasm.WarpIpfs(wasm.Config.minimal_testing(), null)
Expand Down
2 changes: 1 addition & 1 deletion examples/from-js/ipfs-friends.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Warp Wasm Test</title>
</head>
<script type="module">
import init, * as wasm from './built-wasm/warp-ipfs/warp_ipfs.js';
import init, * as wasm from './built-wasm/warp-wasm/warp_wasm.js';
init().then(async (_exports) => {
console.log(wasm)

Expand Down
2 changes: 1 addition & 1 deletion examples/from-js/ipfs-identity-metadata.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Warp Wasm Test</title>
</head>
<script type="module">
import init, * as wasm from './built-wasm/warp-ipfs/warp_ipfs.js';
import init, * as wasm from './built-wasm/warp-wasm/warp_wasm.js';
init().then(async (_exports) => {
let ipfs = await new wasm.WarpIpfs(wasm.Config.minimal_testing(), null)
let multipass = ipfs.multipass
Expand Down
2 changes: 1 addition & 1 deletion examples/from-js/ipfs-identity.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Warp Wasm Test</title>
</head>
<script type="module">
import init, * as wasm from './built-wasm/warp-ipfs/warp_ipfs.js';
import init, * as wasm from './built-wasm/warp-wasm/warp_wasm.js';
init().then(async (_exports) => {
console.log(wasm)

Expand Down
2 changes: 1 addition & 1 deletion examples/from-js/ipfs-persistent-chat-user-a.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Warp Wasm Test</title>
</head>
<script type="module">
import init, * as wasm from './built-wasm/warp-ipfs/warp_ipfs.js';
import init, * as wasm from './built-wasm/warp-wasm/warp_wasm.js';
init().then(async (_exports) => {
console.log(wasm)

Expand Down
2 changes: 1 addition & 1 deletion examples/from-js/ipfs-persistent-chat-user-b.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Warp Wasm Test</title>
</head>
<script type="module">
import init, * as wasm from './built-wasm/warp-ipfs/warp_ipfs.js';
import init, * as wasm from './built-wasm/warp-wasm/warp_wasm.js';
init().then(async (_exports) => {
console.log(wasm)

Expand Down
2 changes: 1 addition & 1 deletion examples/from-js/ipfs-raygun.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Warp Wasm Test</title>
</head>
<script type="module">
import init, * as wasm from './built-wasm/warp-ipfs/warp_ipfs.js';
import init, * as wasm from './built-wasm/warp-wasm/warp_wasm.js';
init().then(async (_exports) => {
console.log(wasm)

Expand Down
2 changes: 1 addition & 1 deletion examples/from-js/tesseract.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Warp Wasm Test</title>
</head>
<script type="module">
import init, * as wasm from './built-wasm/warp-ipfs/warp_ipfs.js';
import init, * as wasm from './built-wasm/warp-wasm/warp_wasm.js';
init().then((_exports) => {
console.log(wasm)

Expand Down
10 changes: 5 additions & 5 deletions pkg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"version": "1.6.2",
"description": "Web Assembly TypeScript library for interfacing with Warp.",
"files": [
"warp_ipfs_bg.wasm",
"warp_ipfs.js",
"warp_ipfs.d.ts"
"warp_wasm_bg.wasm",
"warp_wasm.js",
"warp_wasm.d.ts"
],
"module": "warp_ipfs.js",
"types": "warp_ipfs.d.ts",
"module": "warp_wasm.js",
"types": "warp_wasm.d.ts",
"sideEffects": [
"./snippets/*"
],
Expand Down
6 changes: 3 additions & 3 deletions src/warp/constellation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,9 @@ impl From<constellation::file::FileType> for FileType {
}
}

impl Into<constellation::file::FileType> for FileType {
fn into(self) -> constellation::file::FileType {
match self {
impl From<FileType> for constellation::file::FileType {
fn from(value: FileType) -> Self {
match value {
FileType::Generic => constellation::file::FileType::Generic,
FileType::Mime(media_type_buf) => {
constellation::file::FileType::Mime(media_type_buf.parse().unwrap())
Expand Down
25 changes: 16 additions & 9 deletions src/warp/multipass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,15 @@ impl MultiPassBox {

/// Manually export identity to a specific location
/// If exporting to memory will return the memory buffer for it
pub async fn export_identity(&mut self, memory: Option<bool>) -> Result<Option<Vec<u8>>, JsError> {
let mut buffer: Option<Vec<u8>> = if memory.unwrap_or_default() { Some(vec![]) } else { None };
pub async fn export_identity(
&mut self,
memory: Option<bool>,
) -> Result<Option<Vec<u8>>, JsError> {
let mut buffer: Option<Vec<u8>> = if memory.unwrap_or_default() {
Some(vec![])
} else {
None
};
let loc: multipass::ImportLocation = match buffer.as_mut() {
Some(buffer) => multipass::ImportLocation::Memory { buffer },
None => multipass::ImportLocation::Remote,
Expand Down Expand Up @@ -348,9 +355,9 @@ pub enum IdentityUpdate {
ClearStatusMessage,
}

impl Into<identity::IdentityUpdate> for IdentityUpdate {
fn into(self) -> identity::IdentityUpdate {
match self {
impl From<IdentityUpdate> for identity::IdentityUpdate {
fn from(value: IdentityUpdate) -> Self {
match value {
IdentityUpdate::Username(name) => identity::IdentityUpdate::Username(name),
IdentityUpdate::Picture(data) => identity::IdentityUpdate::Picture(data),
IdentityUpdate::PicturePath(path) => identity::IdentityUpdate::PicturePath(path),
Expand Down Expand Up @@ -384,9 +391,9 @@ pub enum Identifier {
Username(String),
}

impl Into<identity::Identifier> for Identifier {
fn into(self) -> identity::Identifier {
match self {
impl From<Identifier> for identity::Identifier {
fn from(value: Identifier) -> Self {
match value {
Identifier::DID(did) => identity::Identifier::DID(DID::from_str(&did).unwrap()),
Identifier::DIDList(vec) => identity::Identifier::DIDList(
vec.into_iter()
Expand Down Expand Up @@ -570,7 +577,7 @@ impl Identity {
self.0.username().to_string()
}
pub fn status_message(&self) -> Option<String> {
self.0.status_message().map(|s|s.to_string())
self.0.status_message().map(|s| s.to_string())
}
pub fn short_id(&self) -> String {
format!("{}", self.0.short_id())
Expand Down
31 changes: 18 additions & 13 deletions src/warp/raygun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ impl Conversation {
self.inner.id().to_string()
}
pub fn name(&self) -> Option<String> {
self.inner.name().map(|s|s.to_string())
self.inner.name().map(|s| s.to_string())
}
pub fn creator(&self) -> Option<String> {
self.inner.creator().map(|did| did.to_string())
Expand All @@ -621,7 +621,7 @@ impl Conversation {
pub fn conversation_type(&self) -> ConversationType {
self.inner.conversation_type().into()
}
/// Get the permissions for this group.
/// Get the permissions for this group.
/// Modifications on this struct are NOT reflected on the conversation. You need to set them again
pub fn permissions(&self) -> GroupPermissions {
GroupPermissions(self.inner.permissions().clone())
Expand Down Expand Up @@ -957,11 +957,11 @@ impl AttachmentStream {
Self { size, stream }
}
}
impl Into<raygun::Location> for AttachmentFile {
fn into(self) -> raygun::Location {
if let Some(attachment) = self.stream {
impl From<AttachmentFile> for raygun::Location {
fn from(value: AttachmentFile) -> Self {
if let Some(attachment) = value.stream {
Location::Stream {
name: self.file,
name: value.file,
size: attachment.size,
stream: {
let stream = InnerStream::from(wasm_streams::ReadableStream::from_raw(
Expand All @@ -971,7 +971,7 @@ impl Into<raygun::Location> for AttachmentFile {
},
}
} else {
Location::Constellation { path: self.file }
Location::Constellation { path: value.file }
}
}
}
Expand Down Expand Up @@ -1120,13 +1120,16 @@ pub enum GroupPermission {
AddParticipants,
RemoveParticipants,
EditGroupInfo,
EditGroupImages,}
EditGroupImages,
}

impl From<GroupPermission> for warp::raygun::GroupPermission {
fn from(value: GroupPermission) -> Self {
match value {
GroupPermission::AddParticipants => warp::raygun::GroupPermission::AddParticipants,
GroupPermission::RemoveParticipants => warp::raygun::GroupPermission::RemoveParticipants,
GroupPermission::RemoveParticipants => {
warp::raygun::GroupPermission::RemoveParticipants
}
GroupPermission::EditGroupInfo => warp::raygun::GroupPermission::EditGroupInfo,
GroupPermission::EditGroupImages => warp::raygun::GroupPermission::EditGroupImages,
}
Expand All @@ -1137,7 +1140,9 @@ impl From<warp::raygun::GroupPermission> for GroupPermission {
fn from(value: warp::raygun::GroupPermission) -> Self {
match value {
warp::raygun::GroupPermission::AddParticipants => GroupPermission::AddParticipants,
warp::raygun::GroupPermission::RemoveParticipants => GroupPermission::RemoveParticipants,
warp::raygun::GroupPermission::RemoveParticipants => {
GroupPermission::RemoveParticipants
}
warp::raygun::GroupPermission::EditGroupInfo => GroupPermission::EditGroupInfo,
warp::raygun::GroupPermission::EditGroupImages => GroupPermission::EditGroupImages,
}
Expand Down Expand Up @@ -1235,9 +1240,9 @@ pub enum MessagesType {
},
}

impl Into<raygun::MessagesType> for MessagesType {
fn into(self) -> raygun::MessagesType {
match self {
impl From<MessagesType> for raygun::MessagesType {
fn from(value: MessagesType) -> Self {
match value {
MessagesType::Stream => raygun::MessagesType::Stream,
MessagesType::List => raygun::MessagesType::List,
MessagesType::Pages {
Expand Down

0 comments on commit 62aeaa6

Please sign in to comment.