emulate 0.4.0 → 0.5.0

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.
Files changed (50) hide show
  1. package/README.md +59 -10
  2. package/dist/api.d.ts +2 -1
  3. package/dist/api.js +232 -96
  4. package/dist/api.js.map +1 -1
  5. package/dist/{chunk-TEPNEZ63.js → chunk-AQ2CLRU3.js} +26 -23
  6. package/dist/chunk-AQ2CLRU3.js.map +1 -0
  7. package/dist/chunk-WVQMFHQM.js +83 -0
  8. package/dist/chunk-WVQMFHQM.js.map +1 -0
  9. package/dist/{dist-RDFBZ5O6.js → dist-4X2KPMAJ.js} +212 -47
  10. package/dist/dist-4X2KPMAJ.js.map +1 -0
  11. package/dist/{dist-OTJZRQ3Q.js → dist-5JVGPOL3.js} +217 -75
  12. package/dist/dist-5JVGPOL3.js.map +1 -0
  13. package/dist/{dist-G7WQPZ3Y.js → dist-CE6BUCWQ.js} +211 -60
  14. package/dist/dist-CE6BUCWQ.js.map +1 -0
  15. package/dist/{dist-6JFNJPUU.js → dist-CFST4X4K.js} +172 -22
  16. package/dist/dist-CFST4X4K.js.map +1 -0
  17. package/dist/{dist-YOVM5HEY.js → dist-ENKE2S7V.js} +521 -60
  18. package/dist/dist-ENKE2S7V.js.map +1 -0
  19. package/dist/{dist-RMK3BS5M.js → dist-ETHHYBGF.js} +197 -33
  20. package/dist/dist-ETHHYBGF.js.map +1 -0
  21. package/dist/{dist-QMOJM6DV.js → dist-IBXD3O6A.js} +239 -54
  22. package/dist/dist-IBXD3O6A.js.map +1 -0
  23. package/dist/dist-J6LHUR52.js +1899 -0
  24. package/dist/dist-J6LHUR52.js.map +1 -0
  25. package/dist/{dist-6EW7SSOZ.js → dist-KKTYBE5S.js} +391 -222
  26. package/dist/dist-KKTYBE5S.js.map +1 -0
  27. package/dist/{dist-VVXVP5EZ.js → dist-LDUHEJAN.js} +553 -91
  28. package/dist/dist-LDUHEJAN.js.map +1 -0
  29. package/dist/{dist-B674PYKV.js → dist-PWGOAQC6.js} +22 -43
  30. package/dist/dist-PWGOAQC6.js.map +1 -0
  31. package/dist/{dist-H6JYGQM4.js → dist-REDHDZ3V.js} +272 -157
  32. package/dist/dist-REDHDZ3V.js.map +1 -0
  33. package/dist/fonts/favicon.ico +0 -0
  34. package/dist/helpers-LXLP3DFE-LBOTATT5.js +17 -0
  35. package/dist/helpers-LXLP3DFE-LBOTATT5.js.map +1 -0
  36. package/dist/index.js +365 -108
  37. package/dist/index.js.map +1 -1
  38. package/package.json +17 -14
  39. package/dist/chunk-TEPNEZ63.js.map +0 -1
  40. package/dist/dist-6EW7SSOZ.js.map +0 -1
  41. package/dist/dist-6JFNJPUU.js.map +0 -1
  42. package/dist/dist-B674PYKV.js.map +0 -1
  43. package/dist/dist-G7WQPZ3Y.js.map +0 -1
  44. package/dist/dist-H6JYGQM4.js.map +0 -1
  45. package/dist/dist-OTJZRQ3Q.js.map +0 -1
  46. package/dist/dist-QMOJM6DV.js.map +0 -1
  47. package/dist/dist-RDFBZ5O6.js.map +0 -1
  48. package/dist/dist-RMK3BS5M.js.map +0 -1
  49. package/dist/dist-VVXVP5EZ.js.map +0 -1
  50. package/dist/dist-YOVM5HEY.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import "./chunk-TEPNEZ63.js";
1
+ import "./chunk-AQ2CLRU3.js";
2
2
 
3
3
  // ../@emulators/slack/dist/index.js
4
4
  import { randomBytes } from "crypto";
@@ -108,17 +108,22 @@ function chatRoutes(ctx) {
108
108
  });
109
109
  }
110
110
  }
111
- await webhooks.dispatch("message", {
112
- type: "event_callback",
113
- event: {
114
- type: "message",
115
- channel: ch.channel_id,
116
- user: authUser.login,
117
- text,
118
- ts,
119
- thread_ts
120
- }
121
- });
111
+ await webhooks.dispatch(
112
+ "message",
113
+ void 0,
114
+ {
115
+ type: "event_callback",
116
+ event: {
117
+ type: "message",
118
+ channel: ch.channel_id,
119
+ user: authUser.login,
120
+ text,
121
+ ts,
122
+ thread_ts
123
+ }
124
+ },
125
+ "slack"
126
+ );
122
127
  return slackOk(c, {
123
128
  channel: ch.channel_id,
124
129
  ts,
@@ -429,15 +434,20 @@ function reactionsRoutes(ctx) {
429
434
  reactions.push({ name, users: [authUser.login], count: 1 });
430
435
  }
431
436
  ss().messages.update(msg.id, { reactions });
432
- await webhooks.dispatch("reaction_added", {
433
- type: "event_callback",
434
- event: {
435
- type: "reaction_added",
436
- user: authUser.login,
437
- reaction: name,
438
- item: { type: "message", channel, ts: timestamp }
439
- }
440
- });
437
+ await webhooks.dispatch(
438
+ "reaction_added",
439
+ void 0,
440
+ {
441
+ type: "event_callback",
442
+ event: {
443
+ type: "reaction_added",
444
+ user: authUser.login,
445
+ reaction: name,
446
+ item: { type: "message", channel, ts: timestamp }
447
+ }
448
+ },
449
+ "slack"
450
+ );
441
451
  return slackOk(c, {});
442
452
  });
443
453
  app.post("/api/reactions.remove", async (c) => {
@@ -459,15 +469,20 @@ function reactionsRoutes(ctx) {
459
469
  existing.count--;
460
470
  const filtered = reactions.filter((r) => r.count > 0);
461
471
  ss().messages.update(msg.id, { reactions: filtered });
462
- await webhooks.dispatch("reaction_removed", {
463
- type: "event_callback",
464
- event: {
465
- type: "reaction_removed",
466
- user: authUser.login,
467
- reaction: name,
468
- item: { type: "message", channel, ts: timestamp }
469
- }
470
- });
472
+ await webhooks.dispatch(
473
+ "reaction_removed",
474
+ void 0,
475
+ {
476
+ type: "event_callback",
477
+ event: {
478
+ type: "reaction_removed",
479
+ user: authUser.login,
480
+ reaction: name,
481
+ item: { type: "message", channel, ts: timestamp }
482
+ }
483
+ },
484
+ "slack"
485
+ );
471
486
  return slackOk(c, {});
472
487
  });
473
488
  app.post("/api/reactions.get", async (c) => {
@@ -542,6 +557,7 @@ var FONTS = {
542
557
  "geist-sans.woff2": readFileSync(join(__dirname, "fonts", "geist-sans.woff2")),
543
558
  "GeistPixel-Square.woff2": readFileSync(join(__dirname, "fonts", "GeistPixel-Square.woff2"))
544
559
  };
560
+ var FAVICON = readFileSync(join(__dirname, "fonts", "favicon.ico"));
545
561
  function escapeHtml(s) {
546
562
  return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
547
563
  }
@@ -693,6 +709,132 @@ body{
693
709
  .app-link-name{font-weight:600;font-size:.875rem;color:#33ff00;}
694
710
  .app-link-scopes{font-size:.6875rem;color:#1a8c00;margin-top:1px;}
695
711
  .empty{color:#1a8c00;text-align:center;padding:28px 0;font-size:.875rem;}
712
+
713
+ .inspector-layout{max-width:960px;margin:0 auto;padding:28px 20px;}
714
+ .inspector-tabs{display:flex;gap:4px;margin-bottom:20px;}
715
+ .inspector-tabs a{
716
+ padding:7px 16px;border-radius:6px;text-decoration:none;
717
+ font-size:.8125rem;color:#1a8c00;border:1px solid transparent;
718
+ transition:color .15s,border-color .15s;
719
+ }
720
+ .inspector-tabs a:hover{color:#33ff00;}
721
+ .inspector-tabs a.active{color:#33ff00;font-weight:600;border-color:#0a3300;background:#0a3300;}
722
+ .inspector-section{margin-bottom:24px;}
723
+ .inspector-section h2{
724
+ font-family:'Geist Pixel',monospace;
725
+ font-size:1rem;font-weight:600;color:#33ff00;margin-bottom:10px;
726
+ }
727
+ .inspector-section h3{
728
+ font-family:'Geist Pixel',monospace;
729
+ font-size:.875rem;font-weight:600;color:#1a8c00;margin:16px 0 8px;
730
+ }
731
+ .inspector-table{width:100%;border-collapse:collapse;margin-bottom:12px;}
732
+ .inspector-table th,.inspector-table td{
733
+ text-align:left;padding:8px 12px;border-bottom:1px solid #0a3300;
734
+ font-size:.8125rem;
735
+ }
736
+ .inspector-table th{color:#1a8c00;font-weight:600;font-size:.75rem;text-transform:uppercase;letter-spacing:.04em;}
737
+ .inspector-table td{color:#33ff00;}
738
+ .inspector-table tbody tr{transition:background .1s;}
739
+ .inspector-table tbody tr:hover{background:#0a3300;}
740
+ .inspector-empty{color:#1a8c00;text-align:center;padding:20px 0;font-size:.8125rem;}
741
+
742
+ .checkout-layout{
743
+ display:flex;min-height:calc(100vh - 42px);
744
+ }
745
+ .checkout-summary{
746
+ flex:1;background:#020;padding:48px 40px 48px 10%;
747
+ display:flex;flex-direction:column;justify-content:center;
748
+ border-right:1px solid #0a3300;
749
+ }
750
+ .checkout-form-side{
751
+ flex:1;background:#000;padding:48px 10% 48px 40px;
752
+ display:flex;flex-direction:column;justify-content:center;
753
+ }
754
+ .checkout-merchant{
755
+ display:flex;align-items:center;gap:10px;margin-bottom:6px;
756
+ }
757
+ .checkout-merchant-name{
758
+ font-family:'Geist Pixel',monospace;
759
+ font-size:.9375rem;font-weight:600;color:#33ff00;
760
+ }
761
+ .checkout-test-badge{
762
+ font-size:.625rem;font-weight:700;letter-spacing:.04em;text-transform:uppercase;
763
+ background:#0a3300;color:#1a8c00;padding:2px 8px;border-radius:4px;
764
+ }
765
+ .checkout-total{
766
+ font-family:'Geist Pixel',monospace;
767
+ font-size:2rem;font-weight:700;color:#33ff00;margin:8px 0 28px;
768
+ }
769
+ .checkout-line-item{
770
+ display:flex;align-items:center;gap:14px;padding:14px 0;
771
+ border-bottom:1px solid #0a3300;
772
+ }
773
+ .checkout-line-item:first-child{border-top:1px solid #0a3300;}
774
+ .checkout-item-icon{
775
+ width:42px;height:42px;border-radius:6px;background:#0a3300;
776
+ display:flex;align-items:center;justify-content:center;flex-shrink:0;
777
+ font-family:'Geist Pixel',monospace;font-size:.875rem;font-weight:700;color:#116600;
778
+ }
779
+ .checkout-item-details{flex:1;min-width:0;}
780
+ .checkout-item-name{font-size:.875rem;font-weight:600;color:#33ff00;}
781
+ .checkout-item-qty{font-size:.75rem;color:#1a8c00;margin-top:2px;}
782
+ .checkout-item-price{
783
+ font-size:.875rem;font-weight:600;color:#33ff00;text-align:right;white-space:nowrap;
784
+ }
785
+ .checkout-item-unit{font-size:.6875rem;color:#1a8c00;text-align:right;margin-top:2px;}
786
+ .checkout-totals{margin-top:20px;}
787
+ .checkout-totals-row{
788
+ display:flex;justify-content:space-between;padding:6px 0;
789
+ font-size:.8125rem;color:#1a8c00;
790
+ }
791
+ .checkout-totals-row.total{
792
+ border-top:1px solid #0a3300;margin-top:8px;padding-top:14px;
793
+ font-size:.9375rem;font-weight:600;color:#33ff00;
794
+ }
795
+ .checkout-form-section{margin-bottom:24px;}
796
+ .checkout-form-label{
797
+ font-size:.8125rem;font-weight:600;color:#33ff00;margin-bottom:8px;display:block;
798
+ }
799
+ .checkout-input{
800
+ width:100%;padding:10px 12px;border:1px solid #0a3300;border-radius:6px;
801
+ background:#020;color:#33ff00;font:inherit;font-size:.875rem;
802
+ transition:border-color .15s;outline:none;
803
+ }
804
+ .checkout-input:focus{border-color:#33ff00;}
805
+ .checkout-input::placeholder{color:#116600;}
806
+ .checkout-card-box{
807
+ border:1px solid #0a3300;border-radius:6px;padding:14px;
808
+ background:#020;
809
+ }
810
+ .checkout-card-row{
811
+ display:flex;gap:12px;margin-top:10px;
812
+ }
813
+ .checkout-card-row .checkout-input{flex:1;}
814
+ .checkout-sim-note{
815
+ font-size:.6875rem;color:#1a8c00;margin-top:10px;text-align:center;
816
+ font-style:italic;
817
+ }
818
+ .checkout-pay-btn{
819
+ width:100%;padding:14px;border:none;border-radius:8px;
820
+ background:#33ff00;color:#000;font:inherit;font-size:.9375rem;font-weight:700;
821
+ cursor:pointer;transition:background .15s;
822
+ font-family:'Geist Pixel',monospace;
823
+ }
824
+ .checkout-pay-btn:hover{background:#44ff22;}
825
+ .checkout-cancel{
826
+ text-align:center;margin-top:14px;
827
+ }
828
+ .checkout-cancel a{
829
+ color:#1a8c00;text-decoration:none;font-size:.8125rem;
830
+ transition:color .15s;
831
+ }
832
+ .checkout-cancel a:hover{color:#33ff00;}
833
+ @media(max-width:768px){
834
+ .checkout-layout{flex-direction:column;}
835
+ .checkout-summary{padding:32px 20px;border-right:none;border-bottom:1px solid #0a3300;}
836
+ .checkout-form-side{padding:32px 20px;}
837
+ }
696
838
  `;
697
839
  var POWERED_BY = `<div class="powered-by">Powered by <a href="https://emulate.dev" target="_blank" rel="noopener">emulate</a></div>`;
698
840
  function emuBar(service) {
@@ -712,6 +854,7 @@ function head(title) {
712
854
  <head>
713
855
  <meta charset="utf-8"/>
714
856
  <meta name="viewport" content="width=device-width,initial-scale=1"/>
857
+ <link rel="icon" href="/_emulate/favicon.ico"/>
715
858
  <title>${escapeHtml(title)} | emulate</title>
716
859
  <style>${CSS}</style>
717
860
  </head>`;
@@ -824,7 +967,11 @@ function oauthRoutes({ app, store, baseUrl, tokenMap }) {
824
967
  }
825
968
  if (redirect_uri && !matchesRedirectUri(redirect_uri, oauthApp.redirect_uris)) {
826
969
  return c.html(
827
- renderErrorPage("Redirect URI mismatch", "The redirect_uri is not registered for this application.", SERVICE_LABEL),
970
+ renderErrorPage(
971
+ "Redirect URI mismatch",
972
+ "The redirect_uri is not registered for this application.",
973
+ SERVICE_LABEL
974
+ ),
828
975
  400
829
976
  );
830
977
  }
@@ -968,9 +1115,7 @@ function webhookRoutes(ctx) {
968
1115
  if (!text && !body.blocks && !body.attachments) {
969
1116
  return c.text("no_text", 400);
970
1117
  }
971
- const webhook = ss().incomingWebhooks.all().find(
972
- (w) => w.token === c.req.param("token")
973
- );
1118
+ const webhook = ss().incomingWebhooks.all().find((w) => w.token === c.req.param("token"));
974
1119
  let targetChannel = channelName ? ss().channels.findOneBy("name", channelName) ?? ss().channels.findOneBy("channel_id", channelName) : null;
975
1120
  if (!targetChannel && webhook) {
976
1121
  targetChannel = ss().channels.findOneBy("name", webhook.default_channel) ?? ss().channels.findOneBy("channel_id", webhook.default_channel);
@@ -995,18 +1140,23 @@ function webhookRoutes(ctx) {
995
1140
  reply_users: [],
996
1141
  reactions: []
997
1142
  });
998
- await webhooks.dispatch("message", {
999
- type: "event_callback",
1000
- event: {
1001
- type: "message",
1002
- subtype: "bot_message",
1003
- channel: targetChannel.channel_id,
1004
- bot_id: botId,
1005
- text: text || "(rich message)",
1006
- ts,
1007
- thread_ts: threadTs
1008
- }
1009
- });
1143
+ await webhooks.dispatch(
1144
+ "message",
1145
+ void 0,
1146
+ {
1147
+ type: "event_callback",
1148
+ event: {
1149
+ type: "message",
1150
+ subtype: "bot_message",
1151
+ channel: targetChannel.channel_id,
1152
+ bot_id: botId,
1153
+ text: text || "(rich message)",
1154
+ ts,
1155
+ thread_ts: threadTs
1156
+ }
1157
+ },
1158
+ "slack"
1159
+ );
1010
1160
  return c.text("ok");
1011
1161
  });
1012
1162
  }
@@ -1051,12 +1201,14 @@ function inspectorRoutes(ctx) {
1051
1201
  const channels = ss().channels.all().filter((ch) => !ch.is_archived);
1052
1202
  const team = ss().teams.all()[0];
1053
1203
  if (channels.length === 0) {
1054
- return c.html(renderSettingsPage(
1055
- "Slack Inspector",
1056
- "<p class='empty'>No channels</p>",
1057
- "<p class='empty'>No channels in the emulator store.</p>",
1058
- SERVICE_LABEL2
1059
- ));
1204
+ return c.html(
1205
+ renderSettingsPage(
1206
+ "Slack Inspector",
1207
+ "<p class='empty'>No channels</p>",
1208
+ "<p class='empty'>No channels in the emulator store.</p>",
1209
+ SERVICE_LABEL2
1210
+ )
1211
+ );
1060
1212
  }
1061
1213
  const requestedChannel = c.req.query("channel") ?? "";
1062
1214
  const activeChannel = channels.find((ch) => ch.channel_id === requestedChannel) ?? channels[0];
@@ -1087,12 +1239,7 @@ function inspectorRoutes(ctx) {
1087
1239
  </div>
1088
1240
  ${messageHtml}
1089
1241
  </div>`;
1090
- return c.html(renderSettingsPage(
1091
- `${team?.name ?? "Slack"} - Message Inspector`,
1092
- sidebar,
1093
- bodyHtml,
1094
- SERVICE_LABEL2
1095
- ));
1242
+ return c.html(renderSettingsPage(`${team?.name ?? "Slack"} - Message Inspector`, sidebar, bodyHtml, SERVICE_LABEL2));
1096
1243
  });
1097
1244
  }
1098
1245
  function seedDefaults(store, _baseUrl) {
@@ -1142,7 +1289,11 @@ function seedDefaults(store, _baseUrl) {
1142
1289
  is_private: false,
1143
1290
  is_archived: false,
1144
1291
  topic: { value: "Random stuff", creator: userId, last_set: Math.floor(Date.now() / 1e3) },
1145
- purpose: { value: "A place for non-work-related chatter", creator: userId, last_set: Math.floor(Date.now() / 1e3) },
1292
+ purpose: {
1293
+ value: "A place for non-work-related chatter",
1294
+ creator: userId,
1295
+ last_set: Math.floor(Date.now() / 1e3)
1296
+ },
1146
1297
  members: [userId],
1147
1298
  creator: userId,
1148
1299
  num_members: 1
@@ -1284,4 +1435,4 @@ export {
1284
1435
  seedFromConfig,
1285
1436
  slackPlugin
1286
1437
  };
1287
- //# sourceMappingURL=dist-G7WQPZ3Y.js.map
1438
+ //# sourceMappingURL=dist-CE6BUCWQ.js.map