@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,31 @@
1
+ import { nothing } from '@reddit/baseplate/html.js';
2
+ import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
3
+ import { onClickAction, resizeModeClass, sizingClass, sizingStyle } from '../attributes.js';
4
+ import { classMap } from './index.js';
5
+ export function renderImageBlock(block, ctx) {
6
+ const { html, styleMap, ifDefined } = getTemplateRenderingStrategy();
7
+ if (!block.config?.imageConfig) {
8
+ console.error('Invalid block: Image missing ImageConfig');
9
+ return nothing;
10
+ }
11
+ const { width, height, url, description, resizeMode } = block.config.imageConfig;
12
+ const classes = {
13
+ ...sizingClass(block.size),
14
+ ...resizeModeClass(resizeMode),
15
+ };
16
+ const styles = {
17
+ ...sizingStyle(block.size),
18
+ };
19
+ const onClick = onClickAction(block, ctx);
20
+ return html `
21
+ <img
22
+ src="${url}"
23
+ width="${width}"
24
+ height="${height}"
25
+ alt="${description}"
26
+ class="${classMap(classes)}"
27
+ style="${styleMap(styles)}"
28
+ @click="${ifDefined(onClick)}"
29
+ />
30
+ `;
31
+ }
@@ -0,0 +1,5 @@
1
+ import { TemplateLike } from '@reddit/baseplate/html.js';
2
+ import { Block } from '@devvit/protos';
3
+ import { RenderContext } from './index.js';
4
+ export declare function renderSpacerBlock(block: Block, ctx: RenderContext): TemplateLike;
5
+ //# sourceMappingURL=renderSpacerBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderSpacerBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderSpacerBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CAahF"}
@@ -0,0 +1,14 @@
1
+ import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
2
+ import { sizingClass, sizingStyle, spacerSizeClass } from '../attributes.js';
3
+ import { classMap } from './index.js';
4
+ export function renderSpacerBlock(block, ctx) {
5
+ const { html, styleMap } = getTemplateRenderingStrategy();
6
+ const classes = {
7
+ ...sizingClass(block.size),
8
+ ...spacerSizeClass(block.config?.spacerConfig?.size, ctx.stackDirection),
9
+ };
10
+ const styles = {
11
+ ...sizingStyle(block.size),
12
+ };
13
+ return html `<div class="${classMap(classes)}" style="${styleMap(styles)}"></div>`;
14
+ }
@@ -0,0 +1,5 @@
1
+ import { TemplateLike } from '@reddit/baseplate/html.js';
2
+ import { Block } from '@devvit/protos';
3
+ import { RenderContext } from './index.js';
4
+ export declare function renderStackBlock(block: Block, ctx?: RenderContext): TemplateLike;
5
+ //# sourceMappingURL=renderStackBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderStackBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderStackBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAuB,MAAM,gBAAgB,CAAC;AAgB5D,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,KAAK,EACZ,GAAG,GAAE,aAAoE,GACxE,YAAY,CAgDd"}
@@ -0,0 +1,38 @@
1
+ import { nothing } from '@reddit/baseplate/html.js';
2
+ import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
3
+ import { BlockStackDirection } from '@devvit/protos';
4
+ import { alignmentClass, backgroundStyle, borderClass, borderStyle, gapClass, onClickAction, paddingClass, radiusClass, sizingClass, sizingStyle, stackDirectionClass, } from '../attributes.js';
5
+ import { renderBlock } from './renderBlock.js';
6
+ import { classMap } from './index.js';
7
+ export function renderStackBlock(block, ctx = { stackDirection: BlockStackDirection.UNRECOGNIZED }) {
8
+ const { html, repeat, styleMap, ifDefined } = getTemplateRenderingStrategy();
9
+ if (block.config?.stackConfig === undefined) {
10
+ console.error('Invalid block: Stack missing StackConfig');
11
+ return nothing;
12
+ }
13
+ const { children, direction, padding, gap, alignment, reverse, backgroundColor, border, cornerRadius, } = block.config.stackConfig;
14
+ const classes = {
15
+ ...stackDirectionClass(direction, reverse),
16
+ ...sizingClass(block.size),
17
+ ...paddingClass(padding),
18
+ ...gapClass(gap),
19
+ ...alignmentClass(direction, alignment),
20
+ ...borderClass(border),
21
+ ...radiusClass(cornerRadius),
22
+ };
23
+ const styles = {
24
+ ...sizingStyle(block.size),
25
+ ...backgroundStyle(backgroundColor),
26
+ ...borderStyle(border),
27
+ };
28
+ const newCtx = {
29
+ ...ctx,
30
+ stackDirection: direction,
31
+ };
32
+ const onClick = onClickAction(block, ctx);
33
+ return html `
34
+ <div class="${classMap(classes)}" style="${styleMap(styles)}" @click="${ifDefined(onClick)}">
35
+ ${repeat(children, (block) => renderBlock(block, newCtx))}
36
+ </div>
37
+ `;
38
+ }
@@ -0,0 +1,5 @@
1
+ import { TemplateLike } from '@reddit/baseplate/html.js';
2
+ import { Block } from '@devvit/protos';
3
+ import { RenderContext } from './index.js';
4
+ export declare function renderTextBlock(block: Block, ctx: RenderContext): TemplateLike;
5
+ //# sourceMappingURL=renderTextBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderTextBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderTextBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAkD,MAAM,gBAAgB,CAAC;AAWvF,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CA4D9E"}
@@ -0,0 +1,59 @@
1
+ import { nothing } from '@reddit/baseplate/html.js';
2
+ import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
3
+ import { BlockTextSize, BlockTextStyle, BlockTextWeight } from '@devvit/protos';
4
+ import { colorStyle, onClickAction, sizingClass, textAlignClass, textOutlineClass, textSizeClass, textWeightClass, } from '../attributes.js';
5
+ import { classMap } from './index.js';
6
+ export function renderTextBlock(block, ctx) {
7
+ const { html, styleMap, ifDefined } = getTemplateRenderingStrategy();
8
+ if (!block.config?.textConfig) {
9
+ console.error('Invalid block: Text missing TextConfig');
10
+ return nothing;
11
+ }
12
+ const { text, color, size, alignment, weight, style, outline } = block.config.textConfig;
13
+ let textColor = 'neutral-content';
14
+ let baseStyle = {};
15
+ switch (style) {
16
+ case BlockTextStyle.TEXT_STYLE_METADATA:
17
+ textColor = 'neutral-content-weak';
18
+ baseStyle = {
19
+ ...textSizeClass(BlockTextSize.TEXT_SIZE_SMALL),
20
+ ...textWeightClass(BlockTextWeight.TEXT_WEIGHT_REGULAR),
21
+ };
22
+ break;
23
+ case BlockTextStyle.TEXT_STYLE_BODY:
24
+ textColor = 'neutral-content';
25
+ baseStyle = {
26
+ ...textSizeClass(BlockTextSize.TEXT_SIZE_MEDIUM),
27
+ ...textWeightClass(BlockTextWeight.TEXT_WEIGHT_REGULAR),
28
+ };
29
+ break;
30
+ case BlockTextStyle.TEXT_STYLE_HEADING:
31
+ textColor = 'neutral-content-strong';
32
+ baseStyle = {
33
+ ...textSizeClass(BlockTextSize.TEXT_SIZE_LARGE),
34
+ ...textWeightClass(BlockTextWeight.TEXT_WEIGHT_BOLD),
35
+ };
36
+ break;
37
+ }
38
+ textColor = color ?? textColor;
39
+ const styles = {
40
+ ...colorStyle(textColor),
41
+ };
42
+ const classes = {
43
+ ...baseStyle,
44
+ ...sizingClass(block.size),
45
+ ...textSizeClass(size),
46
+ ...textAlignClass(alignment),
47
+ ...textWeightClass(weight),
48
+ };
49
+ if (outline !== undefined) {
50
+ Object.assign(classes, textOutlineClass(outline, textColor));
51
+ }
52
+ const onClick = onClickAction(block, ctx);
53
+ return html `<span
54
+ class="${classMap(classes)}"
55
+ style="${styleMap(styles)}"
56
+ @click="${ifDefined(onClick)}"
57
+ >${text}</span
58
+ >`;
59
+ }
@@ -0,0 +1,5 @@
1
+ import { TemplateLike } from '@reddit/baseplate/html.js';
2
+ import { Block } from '@devvit/protos';
3
+ import { RenderContext } from './index.js';
4
+ export declare function renderWebViewBlock(block: Block, ctx: RenderContext): TemplateLike;
5
+ //# sourceMappingURL=renderWebViewBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderWebViewBlock.d.ts","sourceRoot":"","sources":["../../../src/blocks/templates/renderWebViewBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AASrD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,GAAG,YAAY,CAgCjF"}
@@ -0,0 +1,36 @@
1
+ import { nothing } from '@reddit/baseplate/html.js';
2
+ import { getTemplateRenderingStrategy } from '@reddit/faceplate-ui/faceplateUIConfig.js';
3
+ import { sizingClass, sizingStyle } from '../attributes.js';
4
+ import { classMap } from './index.js';
5
+ const iframeRefs = {};
6
+ const postMessage = (src, ctx) => {
7
+ const iframe = iframeRefs[src];
8
+ iframe?.contentWindow?.postMessage(ctx, '*');
9
+ };
10
+ export function renderWebViewBlock(block, ctx) {
11
+ const { html, styleMap } = getTemplateRenderingStrategy();
12
+ if (!block.config?.webviewConfig) {
13
+ console.error('Invalid block: WebView missing WebViewConfig');
14
+ return nothing;
15
+ }
16
+ const { url } = block.config.webviewConfig;
17
+ const classes = {
18
+ ...sizingClass(block.size),
19
+ };
20
+ const styles = {
21
+ ...sizingStyle(block.size),
22
+ };
23
+ const onLoad = (evt) => {
24
+ iframeRefs[url] = evt.target;
25
+ postMessage(url, ctx);
26
+ };
27
+ const saveRef = (el) => (iframeRefs[url] = el);
28
+ return html `<iframe
29
+ src="${url}"
30
+ sandbox="allow-scripts"
31
+ class="${classMap(classes)}"
32
+ style="${styleMap(styles)}"
33
+ @load="${onLoad}"
34
+ ref="${saveRef}"
35
+ ></iframe>`;
36
+ }
@@ -0,0 +1,2 @@
1
+ export declare const snooBlocks: import("lit-html").TemplateResult<2>;
2
+ //# sourceMappingURL=snooBlocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snooBlocks.d.ts","sourceRoot":"","sources":["../../../src/client/assets/snooBlocks.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,sCAAy37K,CAAC"}