@devvit/ui-renderer 0.10.15-next-2024-02-09-09f4c00d6.0 → 0.10.15-next-2024-02-12-96a7f2dbb.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.
@@ -1,5 +1,5 @@
1
- import { LitElement, PropertyValues } from 'lit';
2
1
  import { BlockAnimationDirection, BlockAnimationLoopMode, BlockAnimationType } from '@devvit/protos';
2
+ import { LitElement, PropertyValues } from 'lit';
3
3
  import '@dotlottie/player-component';
4
4
  /**
5
5
  * @description a simple wrapper for lottie-player
@@ -17,7 +17,7 @@ export declare class DevvitAnimationPlayer extends LitElement {
17
17
  $lottieAnimation?: HTMLDivElement;
18
18
  loopModeStr: string;
19
19
  directionNum?: number | undefined;
20
- updated(changedProperties: PropertyValues): void;
20
+ updated(changedProperties: PropertyValues<this>): void;
21
21
  render(): import("lit-html").TemplateResult<1>;
22
22
  }
23
23
  //# sourceMappingURL=devvit-animation-player.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"devvit-animation-player.d.ts","sourceRoot":"","sources":["../../library/src/client/devvit-animation-player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAGvD,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,6BAA6B,CAAC;AAGrC;;GAEG;AACH,qBACa,qBAAsB,SAAQ,UAAU;IACvB,GAAG,EAAE,MAAM,CAAM;IACjB,UAAU,EAAE,MAAM,CAAM;IACxB,WAAW,EAAE,MAAM,CAAM;IACxB,QAAQ,EAAE,OAAO,CAAQ;IACzB,IAAI,EAAE,OAAO,CAAQ;IACtB,QAAQ,EAAE,sBAAsB,CAClB;IACd,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,SAAS,CAAC,EAAE,uBAAuB,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IAElB,gBAAgB,CAAC,EAAE,cAAc,CAAC;IAElD,WAAW,EAAE,MAAM,CAAY;IAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAElC,OAAO,CAAC,iBAAiB,EAAE,cAAc,GAAG,IAAI;IAyBhD,MAAM;CAyBhB"}
1
+ {"version":3,"file":"devvit-animation-player.d.ts","sourceRoot":"","sources":["../../library/src/client/devvit-animation-player.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAQ,UAAU,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAIvD,OAAO,6BAA6B,CAAC;AAGrC;;GAEG;AACH,qBACa,qBAAsB,SAAQ,UAAU;IACvB,GAAG,EAAE,MAAM,CAAM;IACjB,UAAU,EAAE,MAAM,CAAM;IACxB,WAAW,EAAE,MAAM,CAAM;IACxB,QAAQ,EAAE,OAAO,CAAQ;IACzB,IAAI,EAAE,OAAO,CAAQ;IACtB,QAAQ,EAAE,sBAAsB,CAClB;IACd,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,SAAS,CAAC,EAAE,uBAAuB,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IAElB,gBAAgB,CAAC,EAAE,cAAc,CAAC;IAElD,WAAW,EAAE,MAAM,CAAY;IAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAElC,OAAO,CAAC,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAyBtD,MAAM;CAyBhB"}
@@ -7,10 +7,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
+ import { BlockAnimationDirection, BlockAnimationLoopMode, BlockAnimationType, } from '@devvit/protos';
10
11
  import { html, LitElement } from 'lit';
11
12
  import { customElement, property, query, state } from 'lit/decorators.js';
12
13
  import { styleMap } from 'lit/directives/style-map.js';
13
- import { BlockAnimationDirection, BlockAnimationLoopMode, BlockAnimationType, } from '@devvit/protos';
14
14
  import '@dotlottie/player-component';
15
15
  import { ifDefined } from 'lit/directives/if-defined.js';
16
16
  /**
@@ -1,11 +1,10 @@
1
- import { LitElement, PropertyValues } from 'lit';
2
1
  import '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
3
- import type { Block, BlockAction, Effect, LinkedBundle, Metadata, RenderPostResponse, Struct, UIEvent } from '@devvit/protos';
2
+ import type { BlockAction, Effect, LinkedBundle, Metadata, RenderPostResponse, Struct, UIEvent } from '@devvit/protos';
4
3
  import { RealtimeEvent } from '@devvit/protos';
5
- import { BrowserLiteClient } from '@devvit/runtime-lite/client/BrowserLiteClient.js';
4
+ import { WorkerErrorType } from '@devvit/runtime-lite/client/BrowserLiteClient.js';
6
5
  import type { ActorRef } from '@devvit/runtimes/common/runtime/ActorRef.js';
7
6
  import { FaceplateEvent } from '@reddit/faceplate/event-types.js';
8
- import { DevvitBlocksRenderer } from '../blocks/components/devvit-blocks-renderer.js';
7
+ import { LitElement, PropertyValues } from 'lit';
9
8
  import '../blocks/components/devvit-blocks-renderer.js';
10
9
  import '../blocks/components/devvit-blocks-webview.js';
11
10
  import './devvit-animation-player.js';
@@ -14,50 +13,66 @@ declare global {
14
13
  'devvit-custom-post': DevvitCustomPost;
15
14
  }
16
15
  interface HTMLElementEventMap {
16
+ 'devvit-realtime-send': DevvitRealtimeSendEvent;
17
17
  'devvit-ui-effect': DevvitUIEffectEvent;
18
- 'devvit-user-action': DevvitUserAction;
19
- 'devvit-realtime-send': DevvitRealtimeSend;
18
+ 'devvit-ui-error': FaceplateEvent<'devvit-ui-error'> & {
19
+ detail: DevvitUIError;
20
+ };
21
+ 'devvit-user-action': DevvitUserActionEvent;
20
22
  }
21
23
  }
22
- export type DevvitRealtimeSend = FaceplateEvent<'devvit-realtime-send'> & {
23
- detail: Readonly<{
24
- event: RealtimeEvent;
25
- }>;
24
+ export type DevvitRealtimeSend = {
25
+ event: RealtimeEvent;
26
+ };
27
+ export type DevvitRealtimeSendEvent = FaceplateEvent<'devvit-realtime-send'> & {
28
+ detail: DevvitRealtimeSend;
26
29
  };
27
- export type DevvitUserAction = FaceplateEvent<'devvit-user-action'> & {
28
- detail: Readonly<{
29
- action: BlockAction;
30
- }>;
30
+ export type DevvitUIEffect = {
31
+ effect: Effect;
32
+ onEvent(event: UIEvent): void;
31
33
  };
32
34
  export type DevvitUIEffectEvent = FaceplateEvent<'devvit-ui-effect'> & {
33
- detail: Readonly<{
34
- effect: Effect;
35
- onEvent(event: UIEvent): void;
36
- }>;
35
+ detail: DevvitUIEffect;
36
+ };
37
+ export type DevvitUIError = {
38
+ type: WorkerErrorType;
39
+ err: unknown;
40
+ };
41
+ export type DevvitUserAction = {
42
+ action: BlockAction;
43
+ };
44
+ export type DevvitUserActionEvent = FaceplateEvent<'devvit-user-action'> & {
45
+ detail: DevvitUserAction;
37
46
  };
47
+ /**
48
+ * Blocks program renderer.
49
+ *
50
+ * Assumes the loaded program is a CustomPost & UIEventHandler.
51
+ *
52
+ * @slot - Loading / unloaded state.
53
+ */
38
54
  export declare class DevvitCustomPost extends LitElement {
39
55
  #private;
40
56
  /** Probably a wrapper around the remote runtime (compute-go). */
41
- actorRef?: ActorRef;
42
- metadata: Metadata | undefined;
43
- postId?: string;
44
- postConfig?: Struct['fields'];
45
- localRuntimeCode?: Blob;
46
- bundle?: LinkedBundle;
47
- useSandbox: boolean;
57
+ actorRef?: ActorRef | undefined;
58
+ bundle?: LinkedBundle | undefined;
59
+ localRuntimeCode?: Blob | undefined;
60
+ metadata?: Metadata | undefined;
61
+ postConfig?: Struct['fields'] | undefined;
62
+ postId?: string | undefined;
63
+ scheme?: 'dark' | 'light' | undefined;
48
64
  useExperimentalBlocks: boolean;
49
- forceColorScheme: string | undefined;
50
- blocksRenderer?: DevvitBlocksRenderer;
51
- renderResponse?: RenderPostResponse;
52
- rootBlock?: Block;
53
- isSuspended: boolean;
54
- localClient?: BrowserLiteClient;
55
- static get styles(): import("lit").CSSResult[];
65
+ useSandbox: boolean;
66
+ renderResponse?: RenderPostResponse | undefined;
67
+ private _blocksRenderer;
68
+ private _isSuspended;
69
+ private _rootBlock?;
70
+ constructor();
71
+ disconnectedCallback(): void;
56
72
  rerender(): void;
57
- connectedCallback(): void;
73
+ static get styles(): import("lit").CSSResult[];
58
74
  suspendPost(): void;
59
- disconnectedCallback(): void;
60
- protected willUpdate(changedProperties: PropertyValues): Promise<void>;
61
- render(): import("lit-html").TemplateResult<1>;
75
+ protected render(): import("lit-html").TemplateResult<1>;
76
+ protected willUpdate(props: PropertyValues<this>): Promise<void>;
62
77
  }
63
78
  //# sourceMappingURL=devvit-custom-post.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"devvit-custom-post.d.ts","sourceRoot":"","sources":["../../library/src/client/devvit-custom-post.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAIvD,OAAO,kEAAkE,CAAC;AAG1E,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EAGX,MAAM,EAGN,YAAY,EACZ,QAAQ,EAER,kBAAkB,EAClB,MAAM,EACN,OAAO,EAER,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAOL,aAAa,EAEd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAC;AAGrF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAMtF,OAAO,gDAAgD,CAAC;AACxD,OAAO,+CAA+C,CAAC;AACvD,OAAO,8BAA8B,CAAC;AAEtC,OA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EAAE,OAAO,CAAQ;IACzE,cAAc,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAGxB,OAAO,CAAC,eAAe,CAAwB;IAGvE,OAAO,CAAC,YAAY,CAAkB;IAItC,OAAO,CAAC,UAAU,CAAC,CAAQ;;IAY3B,oBAAoB,IAAI,IAAI;IAKrC,QAAQ,IAAI,IAAI;IAIhB,WAAoB,MAAM,8BAEzB;IAED,WAAW,IAAI,IAAI;cAQA,MAAM;cAoBA,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CA2NhF"}
@@ -18,15 +18,15 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
18
18
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
19
19
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
20
20
  };
21
- var _DevvitCustomPost_instances, _DevvitCustomPost_appState, _DevvitCustomPost_lastRequest, _DevvitCustomPost_rootHeight, _DevvitCustomPost_hasInitialRender, _DevvitCustomPost_hostname, _DevvitCustomPost_customPostActor, _DevvitCustomPost_uiEventHandlerActor, _DevvitCustomPost_rpcQueue, _DevvitCustomPost_rerenderTimeout, _DevvitCustomPost_state_get, _DevvitCustomPost_makeRenderContext, _DevvitCustomPost_handleUIEvent, _DevvitCustomPost_handleUserAction, _DevvitCustomPost_renderRequest, _DevvitCustomPost_initialRender, _DevvitCustomPost_userActionRender, _DevvitCustomPost_effectEventRender, _DevvitCustomPost_renderPost, _DevvitCustomPost_handleEffects, _DevvitCustomPost_onPluginCall;
22
- import { html, LitElement } from 'lit';
23
- import { customElement, property, query, state } from 'lit/decorators.js';
24
- import PQueue from 'p-queue';
21
+ var _DevvitCustomPost_instances, _DevvitCustomPost_appState, _DevvitCustomPost_customPostActor, _DevvitCustomPost_hasInitialRender, _DevvitCustomPost_lastRequest, _DevvitCustomPost_localClient, _DevvitCustomPost_rerenderTimeout, _DevvitCustomPost_rootHeight, _DevvitCustomPost_rpcQueue, _DevvitCustomPost_uiEventHandlerActor, _DevvitCustomPost_bubble, _DevvitCustomPost_effectEventRender, _DevvitCustomPost_handleEffects, _DevvitCustomPost_handleUserAction, _DevvitCustomPost_initialRender, _DevvitCustomPost_makeRenderContext, _DevvitCustomPost_newRenderRequest, _DevvitCustomPost_onPluginCall, _DevvitCustomPost_processEvent, _DevvitCustomPost_queueEvent, _DevvitCustomPost_queueRenderPost, _DevvitCustomPost_renderPost, _DevvitCustomPost_state_get, _DevvitCustomPost_userActionRender;
25
22
  import '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
26
- import { customEvent } from '@reddit/faceplate/lib/custom-event.js';
27
23
  import { BlockConfig_Root, BlockRenderEventType, BlockStackDirection, CustomPostDefinition, EffectType, RealtimeDefinition, UIEventHandlerDefinition, } from '@devvit/protos';
28
- import { BrowserLiteClient } from '@devvit/runtime-lite/client/BrowserLiteClient.js';
24
+ import { BrowserLiteClient, } from '@devvit/runtime-lite/client/BrowserLiteClient.js';
29
25
  import { isCircuitBreaker } from '@devvit/runtime-lite/types/CircuitBreaker.js';
26
+ import { customEvent } from '@reddit/faceplate/lib/custom-event.js';
27
+ import { LitElement, html } from 'lit';
28
+ import { customElement, property, query, state } from 'lit/decorators.js';
29
+ import PQueue from 'p-queue';
30
30
  import { DevvitBlocksRenderer } from '../blocks/components/devvit-blocks-renderer.js';
31
31
  import { DEFAULT_ROOT_HEIGHT } from '../blocks/templates/renderBlock.js';
32
32
  import { styles } from '../styles.js';
@@ -41,262 +41,265 @@ const USER_ACTION_EFFECTS = [
41
41
  EffectType.EFFECT_SHOW_FORM,
42
42
  EffectType.EFFECT_NAVIGATE_TO_URL,
43
43
  ];
44
+ /**
45
+ * Blocks program renderer.
46
+ *
47
+ * Assumes the loaded program is a CustomPost & UIEventHandler.
48
+ *
49
+ * @slot - Loading / unloaded state.
50
+ */
44
51
  let DevvitCustomPost = class DevvitCustomPost extends LitElement {
45
52
  constructor() {
46
- super(...arguments);
53
+ super();
47
54
  _DevvitCustomPost_instances.add(this);
48
- this.useSandbox = true;
49
55
  this.useExperimentalBlocks = false;
50
- this.isSuspended = false;
56
+ this.useSandbox = true;
51
57
  _DevvitCustomPost_appState.set(this, {});
58
+ _DevvitCustomPost_customPostActor.set(this, void 0);
59
+ _DevvitCustomPost_hasInitialRender.set(this, false);
60
+ this._isSuspended = false; // eslint-disable-line @typescript-eslint/naming-convention
52
61
  _DevvitCustomPost_lastRequest.set(this, void 0);
62
+ _DevvitCustomPost_localClient.set(this, void 0);
63
+ _DevvitCustomPost_rerenderTimeout.set(this, void 0);
53
64
  _DevvitCustomPost_rootHeight.set(this, void 0);
54
- _DevvitCustomPost_hasInitialRender.set(this, false);
55
- _DevvitCustomPost_hostname.set(this, void 0);
56
- _DevvitCustomPost_customPostActor.set(this, void 0);
57
- _DevvitCustomPost_uiEventHandlerActor.set(this, void 0);
65
+ // No concurrency is used to enforce order.
58
66
  _DevvitCustomPost_rpcQueue.set(this, new PQueue({ concurrency: 1 }));
59
- _DevvitCustomPost_rerenderTimeout.set(this, void 0);
67
+ _DevvitCustomPost_uiEventHandlerActor.set(this, void 0);
68
+ _DevvitCustomPost_handleUserAction.set(this, async (event) => {
69
+ await __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_userActionRender).call(this, event.detail.action.id, event.detail.action.data);
70
+ });
60
71
  _DevvitCustomPost_makeRenderContext.set(this, () => ({
61
72
  request: __classPrivateFieldGet(this, _DevvitCustomPost_lastRequest, "f"),
62
73
  state: __classPrivateFieldGet(this, _DevvitCustomPost_instances, "a", _DevvitCustomPost_state_get),
63
74
  stackDirection: BlockStackDirection.UNRECOGNIZED,
64
- onAction: (action) => {
65
- __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_userActionRender).call(this, action.id, action.data);
66
- },
75
+ onAction: (action) => void __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_userActionRender).call(this, action.id, action.data),
67
76
  experimental: this.useExperimentalBlocks,
68
77
  }));
69
- _DevvitCustomPost_handleUIEvent.set(this, (event) => {
70
- void __classPrivateFieldGet(this, _DevvitCustomPost_rpcQueue, "f").add(async () => {
71
- const req = {
72
- event,
73
- state: __classPrivateFieldGet(this, _DevvitCustomPost_instances, "a", _DevvitCustomPost_state_get),
74
- };
75
- let call;
76
- try {
77
- call = (await this.localClient?.call('HandleUIEvent', req, this.metadata));
78
- }
79
- catch (e) {
80
- if (!isCircuitBreaker(e) && this.localClient?.ready) {
81
- console.error(e);
82
- }
83
- else {
84
- if (devvit?.logCircuitBreaks)
85
- console.warn('remote call triggered at', e);
86
- }
87
- // Call remote runtime.
88
- call = await __classPrivateFieldGet(this, _DevvitCustomPost_uiEventHandlerActor, "f")?.HandleUIEvent(req, this.metadata);
89
- }
90
- if (call) {
91
- const res = await call;
92
- __classPrivateFieldSet(this, _DevvitCustomPost_appState, res.state ?? {}, "f");
93
- const renderType = event.realtimeEvent
94
- ? BlockRenderEventType.RENDER_EFFECT_EVENT
95
- : BlockRenderEventType.RENDER_USER_ACTION;
96
- await __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_handleEffects).call(this, renderType, res.effects);
97
- }
98
- });
99
- });
100
- _DevvitCustomPost_handleUserAction.set(this, (event) => {
101
- __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_userActionRender).call(this, event.detail.action.id, event.detail.action.data);
102
- });
103
- _DevvitCustomPost_renderRequest.set(this, (type, id, data = {}) => ({
78
+ _DevvitCustomPost_newRenderRequest.set(this, (type, id, data = {}) => ({
104
79
  blocks: { type, id, data },
105
80
  }));
106
81
  _DevvitCustomPost_onPluginCall.set(this, (id, serviceName, method, args) => {
107
82
  if (serviceName === RealtimeDefinition.fullName &&
108
83
  method === RealtimeDefinition.methods.send.name) {
109
- this.dispatchEvent(customEvent('devvit-realtime-send', { event: args }));
110
- this.localClient?.onPluginResponse(id, { error: undefined, success: true, value: {} });
84
+ __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_bubble).call(this, 'devvit-realtime-send', { event: args });
85
+ __classPrivateFieldGet(this, _DevvitCustomPost_localClient, "f")?.onPluginResponse(id, { error: undefined, success: true, value: {} });
111
86
  }
112
87
  });
88
+ _DevvitCustomPost_queueEvent.set(this, async (ev) => {
89
+ await __classPrivateFieldGet(this, _DevvitCustomPost_rpcQueue, "f").add(() => __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_processEvent).call(this, ev));
90
+ });
91
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
92
+ this.addEventListener('devvit-user-action', __classPrivateFieldGet(this, _DevvitCustomPost_handleUserAction, "f"));
113
93
  }
114
- static get styles() {
115
- return [styles];
94
+ disconnectedCallback() {
95
+ this.suspendPost();
96
+ super.disconnectedCallback();
116
97
  }
117
98
  rerender() {
118
- this.blocksRenderer?.requestUpdate();
99
+ this._blocksRenderer?.requestUpdate();
119
100
  }
120
- connectedCallback() {
121
- super.connectedCallback();
122
- this.addEventListener('devvit-user-action', __classPrivateFieldGet(this, _DevvitCustomPost_handleUserAction, "f"));
101
+ static get styles() {
102
+ return [styles];
123
103
  }
124
104
  suspendPost() {
125
- this.isSuspended = true;
105
+ this._isSuspended = true;
126
106
  if (__classPrivateFieldGet(this, _DevvitCustomPost_rerenderTimeout, "f") !== undefined) {
127
107
  window.clearTimeout(__classPrivateFieldGet(this, _DevvitCustomPost_rerenderTimeout, "f"));
128
108
  }
129
- this.localClient?.quit();
109
+ __classPrivateFieldGet(this, _DevvitCustomPost_localClient, "f")?.quit();
130
110
  }
131
- disconnectedCallback() {
132
- super.disconnectedCallback();
133
- this.suspendPost();
134
- this.removeEventListener('devvit-user-action', __classPrivateFieldGet(this, _DevvitCustomPost_handleUserAction, "f"));
111
+ render() {
112
+ if (!this.renderResponse) {
113
+ // The slot content is considered the loading state.
114
+ return html `<slot></slot>`;
115
+ }
116
+ return html `<div class="relative">
117
+ <devvit-blocks-renderer
118
+ class="${this.scheme ?? ''}"
119
+ .block="${this._rootBlock}"
120
+ .renderContext="${__classPrivateFieldGet(this, _DevvitCustomPost_makeRenderContext, "f")}"
121
+ >
122
+ <slot slot="empty-state-image" name="empty-state-image"></slot>
123
+ </devvit-blocks-renderer>
124
+ ${this._isSuspended
125
+ ? html `<div class="absolute top-0 left-0 w-full h-full bg-transparent border-none"></div>`
126
+ : html ``}
127
+ </div>`;
135
128
  }
136
- async willUpdate(changedProperties) {
137
- if (changedProperties.has('localRuntimeCode') && this.localRuntimeCode) {
138
- this.localClient?.quit();
139
- this.localClient = new BrowserLiteClient(this.localRuntimeCode, undefined, {
129
+ async willUpdate(props) {
130
+ if (props.has('localRuntimeCode') && this.localRuntimeCode) {
131
+ __classPrivateFieldGet(this, _DevvitCustomPost_localClient, "f")?.quit();
132
+ __classPrivateFieldSet(this, _DevvitCustomPost_localClient, new BrowserLiteClient(this.localRuntimeCode, undefined, {
140
133
  callback: __classPrivateFieldGet(this, _DevvitCustomPost_onPluginCall, "f"),
141
134
  plugins: [RealtimeDefinition.fullName],
142
- });
135
+ }), "f");
143
136
  }
144
- const actorRefChanged = changedProperties.has('actorRef');
137
+ const actorRefChanged = props.has('actorRef');
145
138
  if (actorRefChanged) {
146
139
  __classPrivateFieldSet(this, _DevvitCustomPost_customPostActor, this.actorRef?.As(CustomPostDefinition), "f");
147
140
  __classPrivateFieldSet(this, _DevvitCustomPost_uiEventHandlerActor, this.actorRef?.As(UIEventHandlerDefinition), "f");
148
141
  }
149
- const bundleChanged = changedProperties.has('bundle');
150
- let appChanged = false;
151
- if (bundleChanged) {
152
- this.localClient?.quit();
153
- if (this.bundle?.hostname !== __classPrivateFieldGet(this, _DevvitCustomPost_hostname, "f")) {
154
- appChanged = true;
155
- }
156
- }
157
- const experimentalChanged = changedProperties.has('useExperimentalBlocks');
158
- const sandboxChanged = changedProperties.has('useSandbox');
159
- if (sandboxChanged) {
160
- this.localClient?.quit();
161
- }
162
- if ((this.actorRef && (actorRefChanged || bundleChanged)) || sandboxChanged) {
142
+ if (props.has('bundle') || props.has('useSandbox'))
143
+ __classPrivateFieldGet(this, _DevvitCustomPost_localClient, "f")?.quit();
144
+ if ((this.actorRef && (actorRefChanged || props.has('bundle'))) || props.has('useSandbox')) {
163
145
  if (this.bundle) {
164
146
  // offline/online, defer initialRender for offline client
165
- await this.localClient?.loadBundle(this.bundle, this.useSandbox);
147
+ await __classPrivateFieldGet(this, _DevvitCustomPost_localClient, "f")?.loadBundle(this.bundle, this.useSandbox);
166
148
  }
167
- else if (appChanged || !__classPrivateFieldGet(this, _DevvitCustomPost_hasInitialRender, "f")) {
149
+ else if ((this.bundle && props.has('bundle')) || !__classPrivateFieldGet(this, _DevvitCustomPost_hasInitialRender, "f")) {
168
150
  // online only
169
151
  __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_initialRender).call(this);
170
152
  }
171
153
  }
172
- else if (experimentalChanged) {
154
+ else if (props.has('useExperimentalBlocks')) {
173
155
  __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_initialRender).call(this);
174
156
  }
175
157
  }
176
- render() {
177
- if (!this.renderResponse) {
178
- return html `<slot></slot>`;
179
- }
180
- return html `<div class="relative">
181
- <devvit-blocks-renderer
182
- class="${this.forceColorScheme ?? ''}"
183
- .block="${this.rootBlock}"
184
- .renderContext="${__classPrivateFieldGet(this, _DevvitCustomPost_makeRenderContext, "f")}"
185
- >
186
- <slot slot="empty-state-image" name="empty-state-image"></slot>
187
- </devvit-blocks-renderer>
188
- ${this.isSuspended
189
- ? html `<div class="absolute top-0 left-0 w-full h-full bg-transparent border-none"></div>`
190
- : html ``}
191
- </div>`;
192
- }
193
158
  };
194
159
  _DevvitCustomPost_appState = new WeakMap();
160
+ _DevvitCustomPost_customPostActor = new WeakMap();
161
+ _DevvitCustomPost_hasInitialRender = new WeakMap();
195
162
  _DevvitCustomPost_lastRequest = new WeakMap();
163
+ _DevvitCustomPost_localClient = new WeakMap();
164
+ _DevvitCustomPost_rerenderTimeout = new WeakMap();
196
165
  _DevvitCustomPost_rootHeight = new WeakMap();
197
- _DevvitCustomPost_hasInitialRender = new WeakMap();
198
- _DevvitCustomPost_hostname = new WeakMap();
199
- _DevvitCustomPost_customPostActor = new WeakMap();
200
- _DevvitCustomPost_uiEventHandlerActor = new WeakMap();
201
166
  _DevvitCustomPost_rpcQueue = new WeakMap();
202
- _DevvitCustomPost_rerenderTimeout = new WeakMap();
203
- _DevvitCustomPost_makeRenderContext = new WeakMap();
204
- _DevvitCustomPost_handleUIEvent = new WeakMap();
167
+ _DevvitCustomPost_uiEventHandlerActor = new WeakMap();
205
168
  _DevvitCustomPost_handleUserAction = new WeakMap();
206
- _DevvitCustomPost_renderRequest = new WeakMap();
169
+ _DevvitCustomPost_makeRenderContext = new WeakMap();
170
+ _DevvitCustomPost_newRenderRequest = new WeakMap();
207
171
  _DevvitCustomPost_onPluginCall = new WeakMap();
172
+ _DevvitCustomPost_queueEvent = new WeakMap();
208
173
  _DevvitCustomPost_instances = new WeakSet();
209
- _DevvitCustomPost_state_get = function _DevvitCustomPost_state_get() {
210
- const data = { __postData: { thingId: this.postId, config: this.postConfig } };
211
- return Object.assign({}, __classPrivateFieldGet(this, _DevvitCustomPost_appState, "f"), data);
174
+ _DevvitCustomPost_bubble = function _DevvitCustomPost_bubble(type, detail) {
175
+ this.dispatchEvent(customEvent(type, detail));
176
+ };
177
+ _DevvitCustomPost_effectEventRender = async function _DevvitCustomPost_effectEventRender(effectType, effectData) {
178
+ await __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_queueRenderPost).call(this, __classPrivateFieldGet(this, _DevvitCustomPost_newRenderRequest, "f").call(this, BlockRenderEventType.RENDER_EFFECT_EVENT, effectType, effectData), 'CircuitClose' // eslint-disable-line @reddit/i18n-shreddit/no-unwrapped-strings
179
+ );
180
+ };
181
+ _DevvitCustomPost_handleEffects = async function _DevvitCustomPost_handleEffects(renderType, effects) {
182
+ effects.forEach((effect) => {
183
+ if (effect.type === EffectType.EFFECT_RERENDER_UI) {
184
+ if (__classPrivateFieldGet(this, _DevvitCustomPost_rerenderTimeout, "f") != null)
185
+ clearTimeout(__classPrivateFieldGet(this, _DevvitCustomPost_rerenderTimeout, "f"));
186
+ __classPrivateFieldSet(this, _DevvitCustomPost_rerenderTimeout, setTimeout(() => {
187
+ void __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_effectEventRender).call(this, 'rerender-effect', {});
188
+ }, (effect.rerenderUi?.delaySeconds ?? 0) * 1000), "f");
189
+ }
190
+ else {
191
+ if (renderType !== BlockRenderEventType.RENDER_USER_ACTION ||
192
+ USER_ACTION_EFFECTS.includes(effect.type)) {
193
+ __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_bubble).call(this, 'devvit-ui-effect', {
194
+ effect,
195
+ onEvent: (ev) => void __classPrivateFieldGet(this, _DevvitCustomPost_queueEvent, "f").call(this, ev),
196
+ });
197
+ }
198
+ }
199
+ });
212
200
  };
213
201
  _DevvitCustomPost_initialRender = function _DevvitCustomPost_initialRender() {
214
- if (this.isSuspended) {
215
- this.isSuspended = false;
202
+ if (this._isSuspended) {
203
+ this._isSuspended = false;
216
204
  }
217
205
  __classPrivateFieldSet(this, _DevvitCustomPost_rootHeight, undefined, "f");
218
206
  __classPrivateFieldSet(this, _DevvitCustomPost_hasInitialRender, true, "f");
219
- __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_renderPost).call(this, __classPrivateFieldGet(this, _DevvitCustomPost_renderRequest, "f").call(this, BlockRenderEventType.RENDER_INITIAL));
207
+ __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_queueRenderPost).call(this, __classPrivateFieldGet(this, _DevvitCustomPost_newRenderRequest, "f").call(this, BlockRenderEventType.RENDER_INITIAL), 'CircuitClose' // eslint-disable-line @reddit/i18n-shreddit/no-unwrapped-strings
208
+ );
220
209
  };
221
- _DevvitCustomPost_userActionRender = function _DevvitCustomPost_userActionRender(actionId, data = {}) {
222
- __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_renderPost).call(this, __classPrivateFieldGet(this, _DevvitCustomPost_renderRequest, "f").call(this, BlockRenderEventType.RENDER_USER_ACTION, actionId, data));
210
+ _DevvitCustomPost_processEvent = async function _DevvitCustomPost_processEvent(ev) {
211
+ const req = {
212
+ event: ev,
213
+ state: __classPrivateFieldGet(this, _DevvitCustomPost_instances, "a", _DevvitCustomPost_state_get),
214
+ };
215
+ let call;
216
+ try {
217
+ call = (await __classPrivateFieldGet(this, _DevvitCustomPost_localClient, "f")?.call('HandleUIEvent', req, this.metadata));
218
+ }
219
+ catch (e) {
220
+ if (!isCircuitBreaker(e) && __classPrivateFieldGet(this, _DevvitCustomPost_localClient, "f")?.ready) {
221
+ console.error(e);
222
+ }
223
+ else {
224
+ if (devvit?.logCircuitBreaks)
225
+ console.warn('remote call triggered at', e);
226
+ }
227
+ // Call remote runtime.
228
+ call = await __classPrivateFieldGet(this, _DevvitCustomPost_uiEventHandlerActor, "f")?.HandleUIEvent(req, this.metadata);
229
+ }
230
+ if (call) {
231
+ const res = await call;
232
+ __classPrivateFieldSet(this, _DevvitCustomPost_appState, res.state ?? {}, "f");
233
+ const renderType = ev.realtimeEvent
234
+ ? BlockRenderEventType.RENDER_EFFECT_EVENT
235
+ : BlockRenderEventType.RENDER_USER_ACTION;
236
+ await __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_handleEffects).call(this, renderType, res.effects);
237
+ }
223
238
  };
224
- _DevvitCustomPost_effectEventRender = function _DevvitCustomPost_effectEventRender(effectType, effectData) {
225
- __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_renderPost).call(this, __classPrivateFieldGet(this, _DevvitCustomPost_renderRequest, "f").call(this, BlockRenderEventType.RENDER_EFFECT_EVENT, effectType, effectData));
239
+ _DevvitCustomPost_queueRenderPost = function _DevvitCustomPost_queueRenderPost(req, circuit) {
240
+ void __classPrivateFieldGet(this, _DevvitCustomPost_rpcQueue, "f").add(() => __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_renderPost).call(this, req, circuit),
241
+ // Cut in line to re-render from server response immediately
242
+ { priority: circuit === 'CircuitBreak' ? 100 : 0 });
226
243
  };
227
- _DevvitCustomPost_renderPost = function _DevvitCustomPost_renderPost(req, circuitBreak = false) {
228
- void __classPrivateFieldGet(this, _DevvitCustomPost_rpcQueue, "f").add(async () => {
229
- var _a, _b;
230
- let call;
231
- req.state = __classPrivateFieldGet(this, _DevvitCustomPost_instances, "a", _DevvitCustomPost_state_get);
232
- try {
233
- if (circuitBreak) {
234
- throw new Error();
244
+ _DevvitCustomPost_renderPost = async function _DevvitCustomPost_renderPost(req, circuit) {
245
+ var _a, _b;
246
+ let call;
247
+ req.state = __classPrivateFieldGet(this, _DevvitCustomPost_instances, "a", _DevvitCustomPost_state_get);
248
+ try {
249
+ if (circuit === 'CircuitBreak') {
250
+ throw new Error();
251
+ }
252
+ call = (await __classPrivateFieldGet(this, _DevvitCustomPost_localClient, "f")?.call('RenderPost', req, this.metadata));
253
+ }
254
+ catch (e) {
255
+ if (isCircuitBreaker(e)) {
256
+ if (e.response) {
257
+ call = e.response;
235
258
  }
236
- call = (await this.localClient?.call('RenderPost', req, this.metadata));
259
+ __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_queueRenderPost).call(this, req, 'CircuitBreak' // eslint-disable-line @reddit/i18n-shreddit/no-unwrapped-strings
260
+ );
237
261
  }
238
- catch (e) {
239
- if (isCircuitBreaker(e)) {
240
- if (e.response) {
241
- call = e.response;
242
- }
243
- // queue up follow-up call
244
- __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_renderPost).call(this, req, true);
262
+ else {
263
+ if (circuit === 'CircuitClose' && __classPrivateFieldGet(this, _DevvitCustomPost_localClient, "f")?.ready) {
264
+ console.error(e);
245
265
  }
246
266
  else {
247
- if (!circuitBreak && this.localClient?.ready) {
248
- console.error(e);
249
- }
250
- else {
251
- if (devvit?.logCircuitBreaks)
252
- console.warn('remote call triggered at', e);
253
- }
254
- // Call remote runtime.
255
- call = await __classPrivateFieldGet(this, _DevvitCustomPost_customPostActor, "f")?.RenderPost(req, this.metadata);
267
+ if (devvit?.logCircuitBreaks)
268
+ console.warn('remote call triggered at', e);
256
269
  }
270
+ // Call remote runtime.
271
+ call = await __classPrivateFieldGet(this, _DevvitCustomPost_customPostActor, "f")?.RenderPost(req, this.metadata);
257
272
  }
258
- if (call) {
259
- this.renderResponse = call;
260
- if (this.renderResponse.state) {
261
- __classPrivateFieldSet(this, _DevvitCustomPost_appState, this.renderResponse.state, "f");
262
- }
263
- if (this.renderResponse?.blocks?.ui) {
264
- __classPrivateFieldSet(this, _DevvitCustomPost_lastRequest, req.blocks, "f");
265
- this.rootBlock = this.renderResponse.blocks.ui;
266
- if (!__classPrivateFieldGet(this, _DevvitCustomPost_rootHeight, "f")) {
267
- // Lock in the initial height
268
- __classPrivateFieldSet(this, _DevvitCustomPost_rootHeight, this.rootBlock.config?.rootConfig?.height || DEFAULT_ROOT_HEIGHT, "f");
269
- }
270
- else {
271
- (_a = this.rootBlock).config ?? (_a.config = {});
272
- (_b = this.rootBlock.config).rootConfig ?? (_b.rootConfig = BlockConfig_Root.fromPartial({}));
273
- this.rootBlock.config.rootConfig.height = __classPrivateFieldGet(this, _DevvitCustomPost_rootHeight, "f");
274
- }
275
- await this.updateComplete;
276
- }
277
- await __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_handleEffects).call(this, req.blocks.type, this.renderResponse.effects);
273
+ }
274
+ if (call) {
275
+ this.renderResponse = call;
276
+ if (this.renderResponse.state) {
277
+ __classPrivateFieldSet(this, _DevvitCustomPost_appState, this.renderResponse.state, "f");
278
278
  }
279
- },
280
- // Cut in line to re-render from server response immediately
281
- circuitBreak ? { priority: 100 } : {});
282
- };
283
- _DevvitCustomPost_handleEffects = async function _DevvitCustomPost_handleEffects(renderType, effects) {
284
- effects.forEach((effect) => {
285
- if (effect.type === EffectType.EFFECT_RERENDER_UI) {
286
- if (__classPrivateFieldGet(this, _DevvitCustomPost_rerenderTimeout, "f") !== undefined) {
287
- window.clearTimeout(__classPrivateFieldGet(this, _DevvitCustomPost_rerenderTimeout, "f"));
279
+ if (this.renderResponse?.blocks?.ui) {
280
+ __classPrivateFieldSet(this, _DevvitCustomPost_lastRequest, req.blocks, "f");
281
+ this._rootBlock = this.renderResponse.blocks.ui;
282
+ if (!__classPrivateFieldGet(this, _DevvitCustomPost_rootHeight, "f")) {
283
+ // Lock in the initial height
284
+ __classPrivateFieldSet(this, _DevvitCustomPost_rootHeight, this._rootBlock.config?.rootConfig?.height || DEFAULT_ROOT_HEIGHT, "f");
288
285
  }
289
- __classPrivateFieldSet(this, _DevvitCustomPost_rerenderTimeout, window.setTimeout(() => {
290
- __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_effectEventRender).call(this, 'rerender-effect', {});
291
- }, (effect.rerenderUi?.delaySeconds ?? 0) * 1000), "f");
292
- }
293
- else {
294
- if (renderType !== BlockRenderEventType.RENDER_USER_ACTION ||
295
- USER_ACTION_EFFECTS.includes(effect.type)) {
296
- this.dispatchEvent(customEvent('devvit-ui-effect', { effect, onEvent: __classPrivateFieldGet(this, _DevvitCustomPost_handleUIEvent, "f") }));
286
+ else {
287
+ (_a = this._rootBlock).config ?? (_a.config = {});
288
+ (_b = this._rootBlock.config).rootConfig ?? (_b.rootConfig = BlockConfig_Root.fromPartial({}));
289
+ this._rootBlock.config.rootConfig.height = __classPrivateFieldGet(this, _DevvitCustomPost_rootHeight, "f");
297
290
  }
291
+ await this.updateComplete;
298
292
  }
299
- });
293
+ await __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_handleEffects).call(this, req.blocks.type, this.renderResponse.effects);
294
+ }
295
+ };
296
+ _DevvitCustomPost_state_get = function _DevvitCustomPost_state_get() {
297
+ const data = { __postData: { thingId: this.postId, config: this.postConfig } };
298
+ return Object.assign({}, __classPrivateFieldGet(this, _DevvitCustomPost_appState, "f"), data);
299
+ };
300
+ _DevvitCustomPost_userActionRender = async function _DevvitCustomPost_userActionRender(actionId, data = {}) {
301
+ await __classPrivateFieldGet(this, _DevvitCustomPost_instances, "m", _DevvitCustomPost_queueRenderPost).call(this, __classPrivateFieldGet(this, _DevvitCustomPost_newRenderRequest, "f").call(this, BlockRenderEventType.RENDER_USER_ACTION, actionId, data), 'CircuitClose' // eslint-disable-line @reddit/i18n-shreddit/no-unwrapped-strings
302
+ );
300
303
  };
301
304
  __decorate([
302
305
  property({ attribute: false }),
@@ -305,52 +308,53 @@ __decorate([
305
308
  __decorate([
306
309
  property({ attribute: false }),
307
310
  __metadata("design:type", Object)
308
- ], DevvitCustomPost.prototype, "metadata", void 0);
311
+ ], DevvitCustomPost.prototype, "bundle", void 0);
309
312
  __decorate([
310
313
  property({ attribute: false }),
311
- __metadata("design:type", String)
312
- ], DevvitCustomPost.prototype, "postId", void 0);
314
+ __metadata("design:type", Object)
315
+ ], DevvitCustomPost.prototype, "localRuntimeCode", void 0);
313
316
  __decorate([
314
317
  property({ attribute: false }),
315
318
  __metadata("design:type", Object)
316
- ], DevvitCustomPost.prototype, "postConfig", void 0);
319
+ ], DevvitCustomPost.prototype, "metadata", void 0);
317
320
  __decorate([
318
321
  property({ attribute: false }),
319
- __metadata("design:type", Blob)
320
- ], DevvitCustomPost.prototype, "localRuntimeCode", void 0);
322
+ __metadata("design:type", Object)
323
+ ], DevvitCustomPost.prototype, "postConfig", void 0);
321
324
  __decorate([
322
- property({ attribute: false }),
325
+ property({ attribute: 'post-id' }),
323
326
  __metadata("design:type", Object)
324
- ], DevvitCustomPost.prototype, "bundle", void 0);
327
+ ], DevvitCustomPost.prototype, "postId", void 0);
325
328
  __decorate([
326
- property({ attribute: false }),
327
- __metadata("design:type", Boolean)
328
- ], DevvitCustomPost.prototype, "useSandbox", void 0);
329
+ property({ attribute: 'scheme' }),
330
+ __metadata("design:type", Object)
331
+ ], DevvitCustomPost.prototype, "scheme", void 0);
329
332
  __decorate([
330
- property({ attribute: false }),
333
+ property({ attribute: 'use-experimental-blocks', type: Boolean }),
331
334
  __metadata("design:type", Boolean)
332
335
  ], DevvitCustomPost.prototype, "useExperimentalBlocks", void 0);
333
336
  __decorate([
334
- property({ attribute: false }),
337
+ property({ attribute: 'use-sandbox', type: Boolean }),
338
+ __metadata("design:type", Boolean)
339
+ ], DevvitCustomPost.prototype, "useSandbox", void 0);
340
+ __decorate([
341
+ state(),
335
342
  __metadata("design:type", Object)
336
- ], DevvitCustomPost.prototype, "forceColorScheme", void 0);
343
+ ], DevvitCustomPost.prototype, "renderResponse", void 0);
337
344
  __decorate([
338
345
  query('devvit-blocks-renderer'),
339
346
  __metadata("design:type", DevvitBlocksRenderer)
340
- ], DevvitCustomPost.prototype, "blocksRenderer", void 0);
347
+ ], DevvitCustomPost.prototype, "_blocksRenderer", void 0);
341
348
  __decorate([
342
349
  state(),
343
- __metadata("design:type", Object)
344
- ], DevvitCustomPost.prototype, "renderResponse", void 0);
350
+ __metadata("design:type", Boolean)
351
+ ], DevvitCustomPost.prototype, "_isSuspended", void 0);
345
352
  __decorate([
346
353
  state(),
347
354
  __metadata("design:type", Object)
348
- ], DevvitCustomPost.prototype, "rootBlock", void 0);
349
- __decorate([
350
- state(),
351
- __metadata("design:type", Boolean)
352
- ], DevvitCustomPost.prototype, "isSuspended", void 0);
355
+ ], DevvitCustomPost.prototype, "_rootBlock", void 0);
353
356
  DevvitCustomPost = __decorate([
354
- customElement('devvit-custom-post')
357
+ customElement('devvit-custom-post'),
358
+ __metadata("design:paramtypes", [])
355
359
  ], DevvitCustomPost);
356
360
  export { DevvitCustomPost };
@@ -11,7 +11,7 @@ export declare class DevvitFormSelectionDropdown extends InputElement {
11
11
  currentLabel: string;
12
12
  static get styles(): import("lit").CSSResultGroup[];
13
13
  get value(): string;
14
- willUpdate(changedProperties: PropertyValues): void;
14
+ willUpdate(changedProperties: PropertyValues<this>): void;
15
15
  render(): TemplateResult<1>;
16
16
  }
17
17
  //# sourceMappingURL=devvit-form-selection-dropdown.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"devvit-form-selection-dropdown.d.ts","sourceRoot":"","sources":["../../../../library/src/client/formbuilder/components/devvit-form-selection-dropdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAS1D,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAE/E,OAAO,EAGL,SAAS,EAEV,MAAM,gBAAgB,CAAC;AAIxB,OAAO,4DAA4D,CAAC;AACpE,OAAO,mDAAmD,CAAC;AAC3D,OAAO,2DAA2D,CAAC;AAGnE,qBAAa,2BAA4B,SAAQ,YAAY;;IAE3D,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IAG7B,YAAY,UAAS;IAGrB,YAAY,SAAM;IAKlB,WAAoB,MAAM,mCAWzB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,UAAU,CAAC,iBAAiB,EAAE,cAAc,GAAG,IAAI;IAwD1C,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC;CAoDrC"}
1
+ {"version":3,"file":"devvit-form-selection-dropdown.d.ts","sourceRoot":"","sources":["../../../../library/src/client/formbuilder/components/devvit-form-selection-dropdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAQ1D,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAG/E,OAAO,EAGL,SAAS,EAEV,MAAM,gBAAgB,CAAC;AAIxB,OAAO,4DAA4D,CAAC;AACpE,OAAO,mDAAmD,CAAC;AAC3D,OAAO,2DAA2D,CAAC;AAGnE,qBAAa,2BAA4B,SAAQ,YAAY;;IAE3D,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IAG7B,YAAY,UAAS;IAGrB,YAAY,SAAM;IAKlB,WAAoB,MAAM,mCAWzB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,UAAU,CAAC,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAwDhD,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC;CAoDrC"}
@@ -23,10 +23,10 @@ import { css } from 'lit';
23
23
  import { property, state } from 'lit/decorators.js';
24
24
  import { classMap } from 'lit/directives/class-map.js';
25
25
  import { html, ifDefined } from '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
26
- import { listItem } from '@reddit/faceplate-ui/templates/list-item.js';
27
26
  import { dropdownButton } from '@reddit/faceplate-ui/templates/dropdownButton.js';
28
- import { msg } from '@reddit/faceplate/lib/i18n/localize.js';
27
+ import { listItem } from '@reddit/faceplate-ui/templates/list-item.js';
29
28
  import { InputElement } from '@reddit/faceplate/base-classes/input-element.js';
29
+ import { msg } from '@reddit/faceplate/lib/i18n/localize.js';
30
30
  import { FieldConfig_Selection, FormFieldValue_SelectionValue, } from '@devvit/protos';
31
31
  import { styles } from '../../../styles.js';
32
32
  import '@reddit/faceplate-ui/components/faceplate-dropdown-menu.js';
@@ -1,14 +1,14 @@
1
1
  import { PropertyValues, TemplateResult } from 'lit';
2
2
  import { InputElement } from '@reddit/faceplate/base-classes/input-element.js';
3
3
  import { FormField } from '@devvit/protos';
4
- import '@reddit/faceplate-ui/components/faceplate-radio-input.js';
5
4
  import '@reddit/faceplate-ui/components/faceplate-checkbox-input.js';
5
+ import '@reddit/faceplate-ui/components/faceplate-radio-input.js';
6
6
  export declare class DevvitFormSelectionList extends InputElement {
7
7
  #private;
8
8
  field: FormField | undefined;
9
9
  static get styles(): import("lit").CSSResultGroup[];
10
10
  get value(): string;
11
- willUpdate(changedProperties: PropertyValues): void;
11
+ willUpdate(changedProperties: PropertyValues<this>): void;
12
12
  render(): TemplateResult<1>;
13
13
  }
14
14
  //# sourceMappingURL=devvit-form-selection-list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"devvit-form-selection-list.d.ts","sourceRoot":"","sources":["../../../../library/src/client/formbuilder/components/devvit-form-selection-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAKrD,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAE/E,OAAO,EAGL,SAAS,EAEV,MAAM,gBAAgB,CAAC;AAMxB,OAAO,0DAA0D,CAAC;AAClE,OAAO,6DAA6D,CAAC;AAErE,qBAAa,uBAAwB,SAAQ,YAAY;;IAEvD,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IAK7B,WAAoB,MAAM,mCAEzB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,UAAU,CAAC,iBAAiB,EAAE,cAAc,GAAG,IAAI;IAsB1C,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC;CAgDrC"}
1
+ {"version":3,"file":"devvit-form-selection-list.d.ts","sourceRoot":"","sources":["../../../../library/src/client/formbuilder/components/devvit-form-selection-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAKrD,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAE/E,OAAO,EAGL,SAAS,EAEV,MAAM,gBAAgB,CAAC;AAMxB,OAAO,6DAA6D,CAAC;AACrE,OAAO,0DAA0D,CAAC;AAElE,qBAAa,uBAAwB,SAAQ,YAAY;;IAEvD,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IAK7B,WAAoB,MAAM,mCAEzB;IAED,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,UAAU,CAAC,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAsBhD,MAAM,IAAI,cAAc,CAAC,CAAC,CAAC;CAgDrC"}
@@ -25,8 +25,8 @@ import { InputElement } from '@reddit/faceplate/base-classes/input-element.js';
25
25
  import { FieldConfig_Selection, FormFieldValue_SelectionValue, } from '@devvit/protos';
26
26
  import { renderFieldLabel } from '../fields/renderFieldLabel.js';
27
27
  import { styles } from '../../../styles.js';
28
- import '@reddit/faceplate-ui/components/faceplate-radio-input.js';
29
28
  import '@reddit/faceplate-ui/components/faceplate-checkbox-input.js';
29
+ import '@reddit/faceplate-ui/components/faceplate-radio-input.js';
30
30
  export class DevvitFormSelectionList extends InputElement {
31
31
  constructor() {
32
32
  super(...arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devvit/ui-renderer",
3
- "version": "0.10.15-next-2024-02-09-09f4c00d6.0",
3
+ "version": "0.10.15-next-2024-02-12-96a7f2dbb.0",
4
4
  "license": "BSD-3-Clause",
5
5
  "repository": {
6
6
  "type": "git",
@@ -54,10 +54,10 @@
54
54
  },
55
55
  "types": "./index.d.ts",
56
56
  "dependencies": {
57
- "@devvit/protos": "0.10.15-next-2024-02-09-09f4c00d6.0",
58
- "@devvit/runtime-lite": "0.10.15-next-2024-02-09-09f4c00d6.0",
59
- "@devvit/runtimes": "0.10.15-next-2024-02-09-09f4c00d6.0",
60
- "@devvit/shared-types": "0.10.15-next-2024-02-09-09f4c00d6.0",
57
+ "@devvit/protos": "0.10.15-next-2024-02-12-96a7f2dbb.0",
58
+ "@devvit/runtime-lite": "0.10.15-next-2024-02-12-96a7f2dbb.0",
59
+ "@devvit/runtimes": "0.10.15-next-2024-02-12-96a7f2dbb.0",
60
+ "@devvit/shared-types": "0.10.15-next-2024-02-12-96a7f2dbb.0",
61
61
  "@dotlottie/player-component": "2.7.2",
62
62
  "p-queue": "7.3.4",
63
63
  "rxjs": "7.5.7"
@@ -84,7 +84,7 @@
84
84
  "devDependencies": {
85
85
  "@devvit/eslint-config": "0.10.14",
86
86
  "@devvit/repo-tools": "0.10.14",
87
- "@devvit/tsconfig": "0.10.15-next-2024-02-09-09f4c00d6.0",
87
+ "@devvit/tsconfig": "0.10.15-next-2024-02-12-96a7f2dbb.0",
88
88
  "@lit-labs/ssr": "^2.2.3",
89
89
  "@lit/localize": "0.11.4",
90
90
  "@open-wc/testing-helpers": "2.3.0",
@@ -116,5 +116,5 @@
116
116
  "directory": "dist"
117
117
  },
118
118
  "source": "./src/index.ts",
119
- "gitHead": "31bd7244adba75d19602fc0d813f84d848a12649"
119
+ "gitHead": "66fa3740beaa38fa6244ca9ea2d612a4e12db80e"
120
120
  }