@devvit/ui-renderer 0.8.11 → 0.9.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 (77) hide show
  1. package/blocks/attributes.d.ts +30 -0
  2. package/blocks/attributes.d.ts.map +1 -0
  3. package/blocks/attributes.js +275 -0
  4. package/blocks/index.d.ts +3 -0
  5. package/blocks/index.d.ts.map +1 -0
  6. package/blocks/index.js +2 -0
  7. package/blocks/templates/index.d.ts +13 -0
  8. package/blocks/templates/index.d.ts.map +1 -0
  9. package/blocks/templates/index.js +37 -0
  10. package/blocks/templates/renderAnimationBlock.d.ts +5 -0
  11. package/blocks/templates/renderAnimationBlock.d.ts.map +1 -0
  12. package/blocks/templates/renderAnimationBlock.js +26 -0
  13. package/blocks/templates/renderAvatarBlock.d.ts +5 -0
  14. package/blocks/templates/renderAvatarBlock.d.ts.map +1 -0
  15. package/blocks/templates/renderAvatarBlock.js +26 -0
  16. package/blocks/templates/renderBlock.d.ts +5 -0
  17. package/blocks/templates/renderBlock.d.ts.map +1 -0
  18. package/blocks/templates/renderBlock.js +39 -0
  19. package/blocks/templates/renderButtonBlock.d.ts +5 -0
  20. package/blocks/templates/renderButtonBlock.d.ts.map +1 -0
  21. package/blocks/templates/renderButtonBlock.js +26 -0
  22. package/blocks/templates/renderFullSnooBlock.d.ts +5 -0
  23. package/blocks/templates/renderFullSnooBlock.d.ts.map +1 -0
  24. package/blocks/templates/renderFullSnooBlock.js +26 -0
  25. package/blocks/templates/renderIconBlock.d.ts +5 -0
  26. package/blocks/templates/renderIconBlock.d.ts.map +1 -0
  27. package/blocks/templates/renderIconBlock.js +17 -0
  28. package/blocks/templates/renderImageBlock.d.ts +5 -0
  29. package/blocks/templates/renderImageBlock.d.ts.map +1 -0
  30. package/blocks/templates/renderImageBlock.js +31 -0
  31. package/blocks/templates/renderSpacerBlock.d.ts +5 -0
  32. package/blocks/templates/renderSpacerBlock.d.ts.map +1 -0
  33. package/blocks/templates/renderSpacerBlock.js +14 -0
  34. package/blocks/templates/renderStackBlock.d.ts +5 -0
  35. package/blocks/templates/renderStackBlock.d.ts.map +1 -0
  36. package/blocks/templates/renderStackBlock.js +38 -0
  37. package/blocks/templates/renderTextBlock.d.ts +5 -0
  38. package/blocks/templates/renderTextBlock.d.ts.map +1 -0
  39. package/blocks/templates/renderTextBlock.js +59 -0
  40. package/blocks/templates/renderWebViewBlock.d.ts +5 -0
  41. package/blocks/templates/renderWebViewBlock.d.ts.map +1 -0
  42. package/blocks/templates/renderWebViewBlock.js +36 -0
  43. package/client/assets/snooBlocks.d.ts +2 -0
  44. package/client/assets/snooBlocks.d.ts.map +1 -0
  45. package/client/assets/snooBlocks.js +2 -0
  46. package/client/{renderer.d.ts → blocks.d.ts} +2 -2
  47. package/client/blocks.d.ts.map +1 -0
  48. package/client/{renderer.js → blocks.js} +1 -1
  49. package/client/devvit-animation-player.d.ts +2 -2
  50. package/client/devvit-animation-player.d.ts.map +1 -1
  51. package/client/devvit-animation-player.js +3 -4
  52. package/client/devvit-custom-post.d.ts +25 -0
  53. package/client/devvit-custom-post.d.ts.map +1 -0
  54. package/client/devvit-custom-post.js +147 -0
  55. package/client/effects/devvit-effect-handler.d.ts +18 -0
  56. package/client/effects/devvit-effect-handler.d.ts.map +1 -0
  57. package/client/effects/devvit-effect-handler.js +58 -0
  58. package/client/effects/form-effect-handler.d.ts +9 -0
  59. package/client/effects/form-effect-handler.d.ts.map +1 -0
  60. package/client/effects/form-effect-handler.js +15 -0
  61. package/client/effects/toast-effect-handler.d.ts +6 -0
  62. package/client/effects/toast-effect-handler.d.ts.map +1 -0
  63. package/client/effects/toast-effect-handler.js +12 -0
  64. package/package.json +11 -10
  65. package/server/{renderer.d.ts → blocks.d.ts} +2 -2
  66. package/server/blocks.d.ts.map +1 -0
  67. package/server/{renderer.js → blocks.js} +1 -1
  68. package/styles.css +42 -1
  69. package/tailwind.devvit.cjs +15 -0
  70. package/client/devvit-ui-interactive.d.ts +0 -34
  71. package/client/devvit-ui-interactive.d.ts.map +0 -1
  72. package/client/devvit-ui-interactive.js +0 -229
  73. package/client/renderer.d.ts.map +0 -1
  74. package/render-core.d.ts +0 -20
  75. package/render-core.d.ts.map +0 -1
  76. package/render-core.js +0 -347
  77. package/server/renderer.d.ts.map +0 -1
@@ -0,0 +1,147 @@
1
+ var _DevvitCustomPost_instances, _DevvitCustomPost_postData, _DevvitCustomPost_appState, _DevvitCustomPost_customPostActor, _DevvitCustomPost_uiEventHandlerActor, _DevvitCustomPost_rpcQueue, _DevvitCustomPost_rerenderTimeout, _DevvitCustomPost_state_get, _DevvitCustomPost_handleUIEvent, _DevvitCustomPost_renderRequest, _DevvitCustomPost_initialRender, _DevvitCustomPost_userActionRender, _DevvitCustomPost_effectEventRender, _DevvitCustomPost_renderPost, _DevvitCustomPost_handleEffects;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet, __decorate, __metadata } from "tslib";
3
+ import { html, LitElement } from 'lit';
4
+ import { customElement, property, state } from 'lit/decorators.js';
5
+ import PQueue from 'p-queue';
6
+ import '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
7
+ import { emptyState } from '@reddit/faceplate-ui/templates/empty-state.js';
8
+ import { customEvent } from '@reddit/faceplate/lib/custom-event.js';
9
+ import tailwind from '@reddit/shreddit.styles';
10
+ import { Block, BlockRenderEventType, BlockStackDirection, BlockType, CustomPostDefinition, EffectType, RenderPostResponse, UIEventHandlerDefinition, } from '@devvit/protos';
11
+ import { renderBlocks } from '../blocks/index.js';
12
+ import { snooBlocks } from './assets/snooBlocks.js';
13
+ import './devvit-animation-player.js';
14
+ let DevvitCustomPost = class DevvitCustomPost extends LitElement {
15
+ constructor() {
16
+ super(...arguments);
17
+ _DevvitCustomPost_instances.add(this);
18
+ _DevvitCustomPost_postData.set(this, void 0);
19
+ _DevvitCustomPost_appState.set(this, {});
20
+ _DevvitCustomPost_customPostActor.set(this, void 0);
21
+ _DevvitCustomPost_uiEventHandlerActor.set(this, void 0);
22
+ _DevvitCustomPost_rpcQueue.set(this, new PQueue({ concurrency: 1 }));
23
+ _DevvitCustomPost_rerenderTimeout.set(this, void 0);
24
+ _DevvitCustomPost_handleUIEvent.set(this, (event) => {
25
+ void __classPrivateFieldGet(this, _DevvitCustomPost_rpcQueue, "f").add(async () => {
26
+ const req = {
27
+ event,
28
+ state: __classPrivateFieldGet(this, _DevvitCustomPost_instances, "a", _DevvitCustomPost_state_get),
29
+ };
30
+ const call = __classPrivateFieldGet(this, _DevvitCustomPost_uiEventHandlerActor, "f")?.HandleUIEvent(req, this.metadata);
31
+ if (call) {
32
+ const res = await call;
33
+ __classPrivateFieldSet(this, _DevvitCustomPost_appState, res.state ?? {}, "f");
34
+ await __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_handleEffects).call(this, res.effects);
35
+ }
36
+ });
37
+ });
38
+ _DevvitCustomPost_renderRequest.set(this, (type, id, data = {}) => ({
39
+ blocks: { type, id, data },
40
+ state: __classPrivateFieldGet(this, _DevvitCustomPost_instances, "a", _DevvitCustomPost_state_get),
41
+ }));
42
+ }
43
+ static get styles() {
44
+ return [tailwind];
45
+ }
46
+ disconnectedCallback() {
47
+ super.disconnectedCallback();
48
+ if (__classPrivateFieldGet(this, _DevvitCustomPost_rerenderTimeout, "f") !== undefined) {
49
+ window.clearTimeout(__classPrivateFieldGet(this, _DevvitCustomPost_rerenderTimeout, "f"));
50
+ }
51
+ }
52
+ willUpdate(changedProperties) {
53
+ if (changedProperties.has('actorRef')) {
54
+ __classPrivateFieldSet(this, _DevvitCustomPost_customPostActor, this.actorRef?.As(CustomPostDefinition), "f");
55
+ __classPrivateFieldSet(this, _DevvitCustomPost_uiEventHandlerActor, this.actorRef?.As(UIEventHandlerDefinition), "f");
56
+ __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_initialRender).call(this);
57
+ }
58
+ if (changedProperties.has('postId')) {
59
+ __classPrivateFieldSet(this, _DevvitCustomPost_postData, this.postId !== undefined ? { __postData: { thingId: this.postId } } : undefined, "f");
60
+ }
61
+ }
62
+ render() {
63
+ if (!this.renderResponse) {
64
+ return html `<slot></slot>`;
65
+ }
66
+ if (this.rootBlock && this.rootBlock.type === BlockType.BLOCK_ROOT) {
67
+ return renderBlocks(this.rootBlock, {
68
+ blockRender: this.renderResponse.blocks,
69
+ state: __classPrivateFieldGet(this, _DevvitCustomPost_instances, "a", _DevvitCustomPost_state_get),
70
+ stackDirection: BlockStackDirection.UNRECOGNIZED,
71
+ onAction: (action) => {
72
+ __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_userActionRender).call(this, action.id, action.data);
73
+ },
74
+ });
75
+ }
76
+ return html `${emptyState({
77
+ creative: html `<div class="w-lg h-lg">${snooBlocks}</div>`,
78
+ title: 'Whoops!',
79
+ description: 'Something went wrong while attempting to display this content.',
80
+ })}`;
81
+ }
82
+ };
83
+ _DevvitCustomPost_postData = new WeakMap(), _DevvitCustomPost_appState = new WeakMap(), _DevvitCustomPost_customPostActor = new WeakMap(), _DevvitCustomPost_uiEventHandlerActor = new WeakMap(), _DevvitCustomPost_rpcQueue = new WeakMap(), _DevvitCustomPost_rerenderTimeout = new WeakMap(), _DevvitCustomPost_handleUIEvent = new WeakMap(), _DevvitCustomPost_renderRequest = new WeakMap(), _DevvitCustomPost_instances = new WeakSet(), _DevvitCustomPost_state_get = function _DevvitCustomPost_state_get() {
84
+ return Object.assign({}, __classPrivateFieldGet(this, _DevvitCustomPost_postData, "f"), __classPrivateFieldGet(this, _DevvitCustomPost_appState, "f"));
85
+ }, _DevvitCustomPost_initialRender = function _DevvitCustomPost_initialRender() {
86
+ __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_renderPost).call(this, __classPrivateFieldGet(this, _DevvitCustomPost_renderRequest, "f").call(this, BlockRenderEventType.RENDER_INITIAL));
87
+ }, _DevvitCustomPost_userActionRender = function _DevvitCustomPost_userActionRender(actionId, data = {}) {
88
+ __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_renderPost).call(this, __classPrivateFieldGet(this, _DevvitCustomPost_renderRequest, "f").call(this, BlockRenderEventType.RENDER_USER_ACTION, actionId, data));
89
+ }, _DevvitCustomPost_effectEventRender = function _DevvitCustomPost_effectEventRender(effectType, effectData) {
90
+ __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_renderPost).call(this, __classPrivateFieldGet(this, _DevvitCustomPost_renderRequest, "f").call(this, BlockRenderEventType.RENDER_EFFECT_EVENT, effectType, effectData));
91
+ }, _DevvitCustomPost_renderPost = function _DevvitCustomPost_renderPost(req) {
92
+ void __classPrivateFieldGet(this, _DevvitCustomPost_rpcQueue, "f").add(async () => {
93
+ const call = await __classPrivateFieldGet(this, _DevvitCustomPost_customPostActor, "f")?.RenderPost(req, this.metadata);
94
+ if (call) {
95
+ this.renderResponse = await call;
96
+ if (this.renderResponse.state) {
97
+ __classPrivateFieldSet(this, _DevvitCustomPost_appState, this.renderResponse.state, "f");
98
+ }
99
+ if (this.renderResponse?.blocks?.ui) {
100
+ this.rootBlock = this.renderResponse.blocks.ui;
101
+ }
102
+ await __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_handleEffects).call(this, this.renderResponse.effects);
103
+ }
104
+ });
105
+ }, _DevvitCustomPost_handleEffects = async function _DevvitCustomPost_handleEffects(effects) {
106
+ effects.forEach((effect) => {
107
+ if (effect.type === EffectType.EFFECT_RERENDER_UI) {
108
+ if (__classPrivateFieldGet(this, _DevvitCustomPost_rerenderTimeout, "f") !== undefined) {
109
+ window.clearTimeout(__classPrivateFieldGet(this, _DevvitCustomPost_rerenderTimeout, "f"));
110
+ }
111
+ __classPrivateFieldSet(this, _DevvitCustomPost_rerenderTimeout, window.setTimeout(() => {
112
+ __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_effectEventRender).call(this, 'rerender-effect', {});
113
+ }, (effect.rerenderUi?.delaySeconds ?? 0) * 1000), "f");
114
+ }
115
+ else {
116
+ this.dispatchEvent(customEvent('devvit-ui-effect', { effect, onEvent: __classPrivateFieldGet(this, _DevvitCustomPost_handleUIEvent, "f") }));
117
+ }
118
+ });
119
+ };
120
+ __decorate([
121
+ property({ attribute: false }),
122
+ __metadata("design:type", Object)
123
+ ], DevvitCustomPost.prototype, "actorRef", void 0);
124
+ __decorate([
125
+ property({ attribute: false }),
126
+ __metadata("design:type", Object)
127
+ ], DevvitCustomPost.prototype, "metadata", void 0);
128
+ __decorate([
129
+ property({ attribute: false }),
130
+ __metadata("design:type", String)
131
+ ], DevvitCustomPost.prototype, "postId", void 0);
132
+ __decorate([
133
+ state(),
134
+ __metadata("design:type", Object)
135
+ ], DevvitCustomPost.prototype, "renderResponse", void 0);
136
+ __decorate([
137
+ state(),
138
+ __metadata("design:type", Object)
139
+ ], DevvitCustomPost.prototype, "rootBlock", void 0);
140
+ __decorate([
141
+ state(),
142
+ __metadata("design:type", Object)
143
+ ], DevvitCustomPost.prototype, "alphaRootBlock", void 0);
144
+ DevvitCustomPost = __decorate([
145
+ customElement('devvit-custom-post')
146
+ ], DevvitCustomPost);
147
+ export { DevvitCustomPost };
@@ -0,0 +1,18 @@
1
+ import { ReactiveController, ReactiveElement } from 'lit';
2
+ import { Effect, Form, RealtimeSubscriptionsEffect, ReloadPartEffect, Toast, UIEvent } from '@devvit/protos';
3
+ export declare abstract class DevvitEffectHandler implements ReactiveController {
4
+ #private;
5
+ protected host: ReactiveElement;
6
+ constructor(host: ReactiveElement);
7
+ protected onShowToast(_toast: Toast, _onEvent: (event: UIEvent) => void): void;
8
+ protected onShowForm(_form: Form, _onEvent: (event: UIEvent) => void): void;
9
+ protected onReloadPart(_parts: ReloadPartEffect, _onEvent: (event: UIEvent) => void): void;
10
+ protected onViewThing(_thingId: string, _onEvent: (event: UIEvent) => void): void;
11
+ protected onRealtimeSubscriptions(_subscriptions: RealtimeSubscriptionsEffect, _onEvent: (event: UIEvent) => void): void;
12
+ hostConnected(): void;
13
+ hostDisconnected(): void;
14
+ hostUpdate(): void;
15
+ hostUpdated(): void;
16
+ handle: (effect: Effect, onEvent: (event: UIEvent) => void) => void;
17
+ }
18
+ //# sourceMappingURL=devvit-effect-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devvit-effect-handler.d.ts","sourceRoot":"","sources":["../../../src/client/effects/devvit-effect-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAC1D,OAAO,EACL,MAAM,EAEN,IAAI,EACJ,2BAA2B,EAC3B,gBAAgB,EAChB,KAAK,EACL,OAAO,EACR,MAAM,gBAAgB,CAAC;AAExB,8BAAsB,mBAAoB,YAAW,kBAAkB;;IACrE,SAAS,CAAC,IAAI,EAAE,eAAe,CAAC;gBAEpB,IAAI,EAAE,eAAe;IAKjC,SAAS,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;IAEvE,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;IAEpE,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;IAEnF,SAAS,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;IAE1E,SAAS,CAAC,uBAAuB,CAC/B,cAAc,EAAE,2BAA2B,EAC3C,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;IAGpC,aAAa;IAIb,gBAAgB;IAIhB,UAAU;IAEV,WAAW;IAOX,MAAM,WAAY,MAAM,mBAAmB,OAAO,KAAK,IAAI,UA8BzD;CACH"}
@@ -0,0 +1,58 @@
1
+ var _DevvitEffectHandler_handleEvent;
2
+ import { __classPrivateFieldGet } from "tslib";
3
+ import { EffectType, } from '@devvit/protos';
4
+ export class DevvitEffectHandler {
5
+ constructor(host) {
6
+ _DevvitEffectHandler_handleEvent.set(this, (event) => {
7
+ const { effect, onEvent } = event.detail;
8
+ this.handle(effect, onEvent);
9
+ });
10
+ this.handle = (effect, onEvent) => {
11
+ switch (effect.type) {
12
+ case EffectType.EFFECT_SHOW_TOAST:
13
+ if (effect.showToast?.toast) {
14
+ this.onShowToast(effect.showToast.toast, onEvent);
15
+ }
16
+ break;
17
+ case EffectType.EFFECT_SHOW_FORM:
18
+ if (effect.showForm?.form) {
19
+ this.onShowForm(effect.showForm.form, onEvent);
20
+ }
21
+ break;
22
+ case EffectType.EFFECT_REALTIME_SUB:
23
+ if (effect.realtimeSubscriptions) {
24
+ this.onRealtimeSubscriptions(effect.realtimeSubscriptions, onEvent);
25
+ }
26
+ break;
27
+ case EffectType.EFFECT_RELOAD_PART:
28
+ if (effect.reloadPart) {
29
+ this.onReloadPart(effect.reloadPart, onEvent);
30
+ }
31
+ break;
32
+ case EffectType.EFFECT_VIEW_THING:
33
+ if (effect.viewThing?.thingId) {
34
+ this.onViewThing(effect.viewThing.thingId, onEvent);
35
+ }
36
+ break;
37
+ default:
38
+ return;
39
+ }
40
+ };
41
+ this.host = host;
42
+ this.host.addController(this);
43
+ }
44
+ onShowToast(_toast, _onEvent) { }
45
+ onShowForm(_form, _onEvent) { }
46
+ onReloadPart(_parts, _onEvent) { }
47
+ onViewThing(_thingId, _onEvent) { }
48
+ onRealtimeSubscriptions(_subscriptions, _onEvent) { }
49
+ hostConnected() {
50
+ this.host.addEventListener('devvit-ui-effect', __classPrivateFieldGet(this, _DevvitEffectHandler_handleEvent, "f"));
51
+ }
52
+ hostDisconnected() {
53
+ this.host.removeEventListener('devvit-ui-effect', __classPrivateFieldGet(this, _DevvitEffectHandler_handleEvent, "f"));
54
+ }
55
+ hostUpdate() { }
56
+ hostUpdated() { }
57
+ }
58
+ _DevvitEffectHandler_handleEvent = new WeakMap();
@@ -0,0 +1,9 @@
1
+ import { DevvitEffectHandler } from './devvit-effect-handler.js';
2
+ import { Form, UIEvent } from '@devvit/protos';
3
+ import { ReactiveElement } from 'lit';
4
+ export declare class FormEffectHandler extends DevvitEffectHandler {
5
+ #private;
6
+ constructor(host: ReactiveElement, queryString: string);
7
+ protected onShowForm(form: Form, onEvent: (event: UIEvent) => void): void;
8
+ }
9
+ //# sourceMappingURL=form-effect-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-effect-handler.d.ts","sourceRoot":"","sources":["../../../src/client/effects/form-effect-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAGtC,qBAAa,iBAAkB,SAAQ,mBAAmB;;gBAG5C,IAAI,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM;cAKnC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;CAG5E"}
@@ -0,0 +1,15 @@
1
+ var _FormEffectHandler_queryString;
2
+ import { __classPrivateFieldSet } from "tslib";
3
+ import { DevvitEffectHandler } from './devvit-effect-handler.js';
4
+ import { customEvent } from '@reddit/faceplate/lib/custom-event.js';
5
+ export class FormEffectHandler extends DevvitEffectHandler {
6
+ constructor(host, queryString) {
7
+ super(host);
8
+ _FormEffectHandler_queryString.set(this, void 0);
9
+ __classPrivateFieldSet(this, _FormEffectHandler_queryString, queryString, "f");
10
+ }
11
+ onShowForm(form, onEvent) {
12
+ this.host.dispatchEvent(customEvent('devvit-show-form', { form, onEvent }));
13
+ }
14
+ }
15
+ _FormEffectHandler_queryString = new WeakMap();
@@ -0,0 +1,6 @@
1
+ import { Toast } from '@devvit/protos';
2
+ import { DevvitEffectHandler } from './devvit-effect-handler.js';
3
+ export declare class ToastEffectHandler extends DevvitEffectHandler {
4
+ onShowToast(toast: Toast): void;
5
+ }
6
+ //# sourceMappingURL=toast-effect-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toast-effect-handler.d.ts","sourceRoot":"","sources":["../../../src/client/effects/toast-effect-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAmB,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAIjE,qBAAa,kBAAmB,SAAQ,mBAAmB;IAChD,WAAW,CAAC,KAAK,EAAE,KAAK;CAQlC"}
@@ -0,0 +1,12 @@
1
+ import { ToastAppearance } from '@devvit/protos';
2
+ import { DevvitEffectHandler } from './devvit-effect-handler.js';
3
+ import { customEvent } from '@reddit/faceplate/lib/custom-event.js';
4
+ import { Severity } from '@reddit/faceplate/types.js';
5
+ export class ToastEffectHandler extends DevvitEffectHandler {
6
+ onShowToast(toast) {
7
+ this.host.dispatchEvent(customEvent('faceplate-alert', {
8
+ message: toast.text,
9
+ level: toast.appearance === ToastAppearance.SUCCESS ? Severity.success : Severity.info,
10
+ }));
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devvit/ui-renderer",
3
- "version": "0.8.11",
3
+ "version": "0.9.0",
4
4
  "license": "BSD-3-Clause",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  "lint:fix": "yarn lint --fix",
18
18
  "prepublishOnly": "publish-package-json",
19
19
  "styles:clean": "rm -f dist/styles.css",
20
- "styles:copy": "yarn styles:clean && cp styles.css dist/styles.css",
20
+ "styles:copy": "yarn styles:clean && cp styles.css dist/styles.css && cp tailwind.devvit.cjs dist/tailwind.devvit.cjs",
21
21
  "styles:dev": "echo 'todo make a filewatcher for styles.css or build it in less and use the preprocessor watch mode'",
22
22
  "test": "yarn test:unit && yarn test:types && yarn lint",
23
23
  "test:types": "tsc --noEmit",
@@ -26,9 +26,10 @@
26
26
  },
27
27
  "types": "./index.d.ts",
28
28
  "dependencies": {
29
- "@devvit/protos": "0.8.11",
30
- "@devvit/runtimes": "0.8.11",
29
+ "@devvit/protos": "0.9.0",
30
+ "@devvit/runtimes": "0.9.0",
31
31
  "@lottiefiles/lottie-player": "1.7.1",
32
+ "p-queue": "7.3.4",
32
33
  "rxjs": "7.5.7"
33
34
  },
34
35
  "peerDependencies": {
@@ -55,14 +56,14 @@
55
56
  "lit": "^2.0.0"
56
57
  },
57
58
  "devDependencies": {
58
- "@devvit/eslint-config": "0.8.11",
59
- "@devvit/public-api": "0.8.11",
60
- "@devvit/repo-tools": "0.8.11",
61
- "@devvit/tsconfig": "0.8.11",
59
+ "@devvit/eslint-config": "0.9.0",
60
+ "@devvit/public-api": "0.9.0",
61
+ "@devvit/repo-tools": "0.9.0",
62
+ "@devvit/tsconfig": "0.9.0",
62
63
  "@reddit/baseplate": "0.14.0",
63
64
  "@reddit/eslint-plugin-i18n-shreddit": "0.1.0",
64
65
  "@reddit/faceplate": "2.0.0",
65
- "@reddit/faceplate-ui": "1.0.5-6",
66
+ "@reddit/faceplate-ui": "2.0.0",
66
67
  "eslint": "8.9.0",
67
68
  "lit": "^2.0.0",
68
69
  "typescript": "4.9.3",
@@ -72,5 +73,5 @@
72
73
  "directory": "dist"
73
74
  },
74
75
  "source": "./src/index.ts",
75
- "gitHead": "baae809e7a137d2b8b9c4977e32eda91008d7660"
76
+ "gitHead": "199c828f2632d9c09e6dc4182988cd7693704848"
76
77
  }
@@ -1,3 +1,3 @@
1
1
  import '@reddit/faceplate-ui/templateRenderingStrategy/serverStrategy.js';
2
- export * from '../render-core.js';
3
- //# sourceMappingURL=renderer.d.ts.map
2
+ export * from '../blocks/index.js';
3
+ //# sourceMappingURL=blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/server/blocks.ts"],"names":[],"mappings":"AAAA,OAAO,kEAAkE,CAAC;AAC1E,cAAc,oBAAoB,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import '@reddit/faceplate-ui/templateRenderingStrategy/serverStrategy.js';
2
- export * from '../render-core.js';
2
+ export * from '../blocks/index.js';
3
3
  // TODO (schwers): In the future WebViews (and others) will probably need
4
4
  // a different server-side render method to avoid hydration issues
package/styles.css CHANGED
@@ -15,7 +15,48 @@
15
15
  grid-template-columns: 1fr;
16
16
  }
17
17
 
18
- .devvit-depth > div {
18
+ .devvit-depth > * {
19
19
  grid-row-start: 1;
20
20
  grid-column-start: 1;
21
21
  }
22
+
23
+ .grid.grid-cols-1 > * {
24
+ grid-column-start: 1;
25
+ grid-row-start: 1;
26
+ }
27
+
28
+ @supports (-webkit-text-stroke: 1px black) {
29
+ .text-outline-thin-bright {
30
+ -webkit-text-stroke: 1px black;
31
+ }
32
+
33
+ .text-outline-thick-bright {
34
+ -webkit-text-stroke: 2px black;
35
+ }
36
+
37
+ .text-outline-thin-dark {
38
+ -webkit-text-stroke: 1px white;
39
+ }
40
+
41
+ .text-outline-thick-dark {
42
+ -webkit-text-stroke: 2px white;
43
+ }
44
+ }
45
+
46
+ @supports not (-webkit-text-stroke: 1px black) {
47
+ .text-outline-thin-bright {
48
+ text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
49
+ }
50
+
51
+ .text-outline-thick-bright {
52
+ text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000;
53
+ }
54
+
55
+ .text-outline-thin-dark {
56
+ text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff;
57
+ }
58
+
59
+ .text-outline-thick-dark {
60
+ text-shadow: -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff, 2px 2px 0 #fff;
61
+ }
62
+ }
@@ -0,0 +1,15 @@
1
+ module.exports = {
2
+ theme: {
3
+ extend: {
4
+ borderWidth: {
5
+ 'dx-thin': '1px',
6
+ 'dx-thick': '2px',
7
+ },
8
+ borderRadius: {
9
+ 'dx-sm': '0.5rem',
10
+ 'dx-md': '1rem',
11
+ 'dx-lg': '1.5rem',
12
+ },
13
+ },
14
+ },
15
+ };
@@ -1,34 +0,0 @@
1
- /**
2
- * Component that renders wraps a rendering of devvit ui and makes it interactive.
3
- *
4
- * Needs to handle
5
- * 1 - not getting slotted content and IT triggers the first render
6
- * 2 - getting slotted content from SSR and then replacing it when interactivity happens
7
- */
8
- /// <reference lib="dom" />
9
- import { LitElement, PropertyValues } from 'lit';
10
- import type { Metadata, Realtime } from '@devvit/protos';
11
- import { RenderPostResponse } from '@devvit/protos';
12
- import type { ActorRef } from '@devvit/runtimes/common/runtime/ActorRef.js';
13
- import './devvit-animation-player.js';
14
- type RenderStateChange = (state: RenderPostResponse) => void;
15
- declare global {
16
- interface HTMLElementTagNameMap {
17
- 'devvit-ui-interactive': DevvitInteractiveUI;
18
- }
19
- }
20
- export declare class DevvitInteractiveUI extends LitElement {
21
- #private;
22
- actorRef?: ActorRef;
23
- realtime?: Realtime;
24
- metadata?: Metadata;
25
- onRender?: RenderStateChange;
26
- renderResponse?: RenderPostResponse;
27
- static get styles(): import("lit").CSSResult[];
28
- connectedCallback(): void;
29
- disconnectedCallback(): void;
30
- protected willUpdate(changedProperties: PropertyValues): void;
31
- render(): import("lit-html").TemplateResult<1>;
32
- }
33
- export {};
34
- //# sourceMappingURL=devvit-ui-interactive.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"devvit-ui-interactive.d.ts","sourceRoot":"","sources":["../../src/client/devvit-ui-interactive.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;AAGH,OAAO,EAAa,UAAU,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAK5D,OAAO,KAAK,EAGV,QAAQ,EACR,QAAQ,EAMT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAKL,kBAAkB,EAGnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAC;AAO5E,OAAO,8BAA8B,CAAC;AAItC,KAAK,iBAAiB,GAAG,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;AAK7D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,uBAAuB,EAAE,mBAAmB,CAAC;KAC9C;CACF;AAED,qBACa,mBAAoB,SAAQ,UAAU;;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAG7D,cAAc,CAAC,EAAE,kBAAkB,CAAC;IAQpC,WAAoB,MAAM,8BAMzB;IAEQ,iBAAiB;IAOjB,oBAAoB;cAOV,UAAU,CAAC,iBAAiB,EAAE,cAAc;IAwKtD,MAAM;CAiBhB"}