@devvit/ui-renderer 0.8.11 → 0.9.1

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 (79) hide show
  1. package/blocks/attributes.d.ts +32 -0
  2. package/blocks/attributes.d.ts.map +1 -0
  3. package/blocks/attributes.js +287 -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 +38 -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 +29 -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 +29 -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 +60 -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 +35 -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 +29 -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 +21 -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 +34 -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 +20 -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 +57 -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 +62 -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 +39 -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 +28 -22
  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 +785 -17
  69. package/styles.d.ts +2 -0
  70. package/styles.d.ts.map +1 -0
  71. package/styles.js +3 -0
  72. package/client/devvit-ui-interactive.d.ts +0 -34
  73. package/client/devvit-ui-interactive.d.ts.map +0 -1
  74. package/client/devvit-ui-interactive.js +0 -229
  75. package/client/renderer.d.ts.map +0 -1
  76. package/render-core.d.ts +0 -20
  77. package/render-core.d.ts.map +0 -1
  78. package/render-core.js +0 -347
  79. 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 { styles } from '../styles.js';
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 [styles];
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.1",
4
4
  "license": "BSD-3-Clause",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,33 +9,36 @@
9
9
  "type": "module",
10
10
  "main": "./index.js",
11
11
  "scripts": {
12
- "build": "tsc && yarn styles:copy",
12
+ "build": "yarn build:typescript && yarn build:styles",
13
+ "build:styles": "postcss -c postcss.config.cjs styles.css -o dist/styles.css && yarn build:styles-dist",
14
+ "build:styles-dist": "node scripts/make-styles.js",
15
+ "build:typescript": "tsc",
13
16
  "clean": "rm -rf .turbo coverage dist",
14
17
  "clobber": "yarn clean && rm -rf node_modules",
15
- "dev": "yarn styles:copy && tsc -w",
18
+ "dev": "concurrently -n 'styles,styles-dist,typescript' 'yarn watch:styles' 'yarn watch:styles-dist' 'yarn watch:typescript'",
16
19
  "lint": "redlint .",
17
20
  "lint:fix": "yarn lint --fix",
18
21
  "prepublishOnly": "publish-package-json",
19
- "styles:clean": "rm -f dist/styles.css",
20
- "styles:copy": "yarn styles:clean && cp styles.css dist/styles.css",
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",
24
24
  "test:unit": "vitest run",
25
- "test:unit-with-coverage": "vitest run --coverage"
25
+ "test:unit-with-coverage": "vitest run --coverage",
26
+ "watch:styles": "postcss -w -c postcss.config.cjs styles.css -o dist/styles.css",
27
+ "watch:styles-dist": "node scripts/make-styles.js --watch",
28
+ "watch:typescript": "tsc -w"
26
29
  },
27
30
  "types": "./index.d.ts",
28
31
  "dependencies": {
29
- "@devvit/protos": "0.8.11",
30
- "@devvit/runtimes": "0.8.11",
32
+ "@devvit/protos": "0.9.1",
33
+ "@devvit/runtimes": "0.9.1",
31
34
  "@lottiefiles/lottie-player": "1.7.1",
35
+ "p-queue": "7.3.4",
32
36
  "rxjs": "7.5.7"
33
37
  },
34
38
  "peerDependencies": {
35
39
  "@reddit/baseplate": "0.14.0",
36
- "@reddit/faceplate": "2.0.0",
37
- "@reddit/faceplate-ui": "1.0.5-6",
38
- "@reddit/shreddit.styles": "^1.0.8"
40
+ "@reddit/faceplate": "2.x",
41
+ "@reddit/faceplate-ui": "2.x"
39
42
  },
40
43
  "peerDependenciesMeta": {
41
44
  "@reddit/baseplate": {
@@ -46,25 +49,28 @@
46
49
  },
47
50
  "@reddit/faceplate-ui": {
48
51
  "optional": true
49
- },
50
- "@reddit/shreddit.styles": {
51
- "optional": true
52
52
  }
53
53
  },
54
54
  "optionalDependencies": {
55
55
  "lit": "^2.0.0"
56
56
  },
57
57
  "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",
58
+ "@devvit/eslint-config": "0.9.1",
59
+ "@devvit/public-api": "0.9.1",
60
+ "@devvit/repo-tools": "0.9.1",
61
+ "@devvit/tsconfig": "0.9.1",
62
62
  "@reddit/baseplate": "0.14.0",
63
63
  "@reddit/eslint-plugin-i18n-shreddit": "0.1.0",
64
- "@reddit/faceplate": "2.0.0",
65
- "@reddit/faceplate-ui": "1.0.5-6",
64
+ "autoprefixer": "10.4.14",
65
+ "chokidar": "3.5.3",
66
+ "concurrently": "7.5.0",
67
+ "debounce": "1.2.1",
66
68
  "eslint": "8.9.0",
67
69
  "lit": "^2.0.0",
70
+ "postcss": "8.4.22",
71
+ "postcss-cli": "10.1.0",
72
+ "postcss-import": "15.1.0",
73
+ "tailwindcss": "3.3.1",
68
74
  "typescript": "4.9.3",
69
75
  "vitest": "0.8.2"
70
76
  },
@@ -72,5 +78,5 @@
72
78
  "directory": "dist"
73
79
  },
74
80
  "source": "./src/index.ts",
75
- "gitHead": "baae809e7a137d2b8b9c4977e32eda91008d7660"
81
+ "gitHead": "9c3a31746cb435b9ec47f392e719b4335c8f3765"
76
82
  }
@@ -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