@impro.social/impro-plugin 0.0.11 → 0.0.13
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/main.js +81 -7
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -147,6 +147,17 @@ class PluginData {
|
|
|
147
147
|
getProfile(did) {
|
|
148
148
|
return hostCall("getProfile", { did });
|
|
149
149
|
}
|
|
150
|
+
// Like getProfile, but includes viewer relationship details not present
|
|
151
|
+
// on the basic profile view: viewer.following, viewer.followedBy, and
|
|
152
|
+
// viewer.knownFollowers (a summary of mutual followers).
|
|
153
|
+
getDetailedProfile(did) {
|
|
154
|
+
return hostCall("getDetailedProfile", { did });
|
|
155
|
+
}
|
|
156
|
+
// The full known-followers list for did (the summary on
|
|
157
|
+
// getDetailedProfile's viewer.knownFollowers is capped to a handful).
|
|
158
|
+
getKnownFollowers(did) {
|
|
159
|
+
return hostCall("getKnownFollowers", { did });
|
|
160
|
+
}
|
|
150
161
|
getRecord(repo, collection, rkey) {
|
|
151
162
|
return hostCall("getRecord", { repo, collection, rkey });
|
|
152
163
|
}
|
|
@@ -164,6 +175,32 @@ class App {
|
|
|
164
175
|
refreshFeedFilters(feedURI = null) {
|
|
165
176
|
return hostCall("refreshFeedFilters", feedURI);
|
|
166
177
|
}
|
|
178
|
+
|
|
179
|
+
// Actions on behalf of the signed-in user. Each method requires the
|
|
180
|
+
// corresponding scope ("mute", "block", "feedFeedback") to be declared in
|
|
181
|
+
// the plugin manifest's `permissions.actions` array, which the user must
|
|
182
|
+
// grant at install time.
|
|
183
|
+
muteActor(did) {
|
|
184
|
+
return hostCall("muteActor", { did, mute: true });
|
|
185
|
+
}
|
|
186
|
+
unmuteActor(did) {
|
|
187
|
+
return hostCall("muteActor", { did, mute: false });
|
|
188
|
+
}
|
|
189
|
+
blockActor(did) {
|
|
190
|
+
return hostCall("blockActor", { did, block: true });
|
|
191
|
+
}
|
|
192
|
+
unblockActor(did) {
|
|
193
|
+
return hostCall("blockActor", { did, block: false });
|
|
194
|
+
}
|
|
195
|
+
// Acts like the user clicking "Show less like this": sends the requestLess
|
|
196
|
+
// feedback signal to the feed that served the post and collapses the post
|
|
197
|
+
// behind a feedback message in feeds.
|
|
198
|
+
showLessLikeThis(postUri, feedUri) {
|
|
199
|
+
return hostCall("showLessLikeThis", { postUri, feedUri });
|
|
200
|
+
}
|
|
201
|
+
showMoreLikeThis(postUri, feedUri) {
|
|
202
|
+
return hostCall("showMoreLikeThis", { postUri, feedUri });
|
|
203
|
+
}
|
|
167
204
|
}
|
|
168
205
|
|
|
169
206
|
export async function fetch(url, init = {}) {
|
|
@@ -702,15 +739,30 @@ class PostsFeedComponent {
|
|
|
702
739
|
}
|
|
703
740
|
}
|
|
704
741
|
|
|
742
|
+
export class VirtualText {
|
|
743
|
+
constructor(value) {
|
|
744
|
+
this.value = value == null ? "" : String(value);
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
_serialize() {
|
|
748
|
+
return { type: "text", value: this.value };
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
705
752
|
export class VirtualEl {
|
|
706
753
|
constructor(tag) {
|
|
707
754
|
this.tag = tag;
|
|
708
755
|
this.attrs = {};
|
|
709
|
-
this.
|
|
756
|
+
this.styles = {};
|
|
710
757
|
this.children = [];
|
|
711
758
|
this.events = {};
|
|
712
759
|
}
|
|
713
760
|
|
|
761
|
+
setStyle(name, value) {
|
|
762
|
+
this.styles[String(name)] = value == null ? "" : String(value);
|
|
763
|
+
return this;
|
|
764
|
+
}
|
|
765
|
+
|
|
714
766
|
onClick(fn) {
|
|
715
767
|
const handlerId = uuid.create();
|
|
716
768
|
callHandlers.set(handlerId, fn);
|
|
@@ -733,17 +785,37 @@ export class VirtualEl {
|
|
|
733
785
|
}
|
|
734
786
|
|
|
735
787
|
setText(text) {
|
|
736
|
-
this.text = text;
|
|
737
788
|
this.children = [];
|
|
789
|
+
if (text != null && text !== "") this.children.push(new VirtualText(text));
|
|
738
790
|
return this;
|
|
739
791
|
}
|
|
740
792
|
|
|
741
793
|
empty() {
|
|
742
|
-
this.text = null;
|
|
743
794
|
this.children = [];
|
|
744
795
|
return this;
|
|
745
796
|
}
|
|
746
797
|
|
|
798
|
+
appendChild(child) {
|
|
799
|
+
if (!(child instanceof VirtualEl) && !(child instanceof VirtualText)) {
|
|
800
|
+
throw new TypeError(
|
|
801
|
+
"appendChild expects a VirtualEl or VirtualText instance",
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
this.children.push(child);
|
|
805
|
+
return this;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
appendText(value) {
|
|
809
|
+
this.children.push(new VirtualText(value));
|
|
810
|
+
return this;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
createText(value) {
|
|
814
|
+
const node = new VirtualText(value);
|
|
815
|
+
this.children.push(node);
|
|
816
|
+
return node;
|
|
817
|
+
}
|
|
818
|
+
|
|
747
819
|
addClass(cls) {
|
|
748
820
|
this.attrs.class = this.attrs.class ? `${this.attrs.class} ${cls}` : cls;
|
|
749
821
|
return this;
|
|
@@ -756,7 +828,7 @@ export class VirtualEl {
|
|
|
756
828
|
|
|
757
829
|
createEl(tag, options = {}, callback) {
|
|
758
830
|
const child = new VirtualEl(tag);
|
|
759
|
-
if (options.text != null) child.
|
|
831
|
+
if (options.text != null) child.setText(options.text);
|
|
760
832
|
if (options.cls) {
|
|
761
833
|
child.attrs.class = Array.isArray(options.cls)
|
|
762
834
|
? options.cls.join(" ")
|
|
@@ -795,13 +867,15 @@ export class VirtualEl {
|
|
|
795
867
|
}
|
|
796
868
|
|
|
797
869
|
_serialize() {
|
|
798
|
-
|
|
870
|
+
const serialized = {
|
|
871
|
+
type: "element",
|
|
799
872
|
tag: this.tag,
|
|
800
873
|
attrs: this.attrs,
|
|
801
|
-
text: this.text,
|
|
802
|
-
children: this.children.map((child) => child._serialize()),
|
|
803
874
|
events: this.events,
|
|
875
|
+
children: this.children.map((child) => child._serialize()),
|
|
804
876
|
};
|
|
877
|
+
if (Object.keys(this.styles).length > 0) serialized.styles = this.styles;
|
|
878
|
+
return serialized;
|
|
805
879
|
}
|
|
806
880
|
}
|
|
807
881
|
|