@devvit/ui-renderer 0.10.17 → 0.10.18-next-2024-03-04-883f53706.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-ui-looper.d.ts","sourceRoot":"","sources":["../../library/src/client/app-ui-looper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app-ui-looper.d.ts","sourceRoot":"","sources":["../../library/src/client/app-ui-looper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,MAAM,EAGN,YAAY,EACZ,QAAQ,EACR,iBAAiB,EACjB,kBAAkB,EAClB,MAAM,EACN,OAAO,EACR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAsB,MAAM,gBAAgB,CAAC;AAC1E,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EAEX,MAAM,kDAAkD,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAElF,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAG7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAQzC,KAAK,QAAQ,GAAG;IACd,UAAU,CAAC,EAAE;QACX,OAAO,EAAE,GAAG,GAAG,SAAS,CAAC;QACzB,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;KACtC,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AACF,KAAK,SAAS,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE5C;;;;;;;;;;;;;GAaG;AACH,qBAAa,WAAW;;IACtB,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,OAAO,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IACpC,YAAY,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IAC1C,YAAY,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,iBAAiB,EAAE,GAAG,EAAE,kBAAkB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACvF,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;IAC1C,MAAM,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAC1B,sCAAsC;IACtC,MAAM,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IAe3B;;;OAGG;IACH,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAWhC,6DAA6D;IAC7D,IAAI,QAAQ,IAAI,QAAQ,CAGvB;IAED;;;OAGG;IACG,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxE,UAAU,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI;IAW7B,eAAe,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;IAK1F,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED;;;OAGG;IACH,aAAa,IAAI,IAAI;IAKrB,mCAAmC;IACnC,WAAW,CAAC,GAAG,EAAE,IAAI,GAAG,SAAS,GAAG,IAAI;IAUxC,mDAAmD;IACnD,MAAM,IAAI,IAAI;CA6Gf"}
|
package/client/app-ui-looper.js
CHANGED
|
@@ -9,7 +9,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
9
9
|
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");
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
|
-
var _AppUILooper_instances, _AppUILooper_appState, _AppUILooper_q, _AppUILooper_rendered, _AppUILooper_rerenderTimeout, _AppUILooper_onEffects, _AppUILooper_onPluginCall, _AppUILooper_processEvent, _AppUILooper_renderPost;
|
|
12
|
+
var _AppUILooper_instances, _AppUILooper_app, _AppUILooper_appState, _AppUILooper_q, _AppUILooper_rendered, _AppUILooper_rerenderTimeout, _AppUILooper_onEffects, _AppUILooper_onError, _AppUILooper_onPluginCall, _AppUILooper_processEvent, _AppUILooper_renderPost;
|
|
13
13
|
import { BlockRenderEventType, RealtimeDefinition } from '@devvit/protos';
|
|
14
14
|
import { BrowserLiteClient } from '@devvit/runtime-lite/client/BrowserLiteClient.js';
|
|
15
15
|
import { isCircuitBreaker } from '@devvit/runtime-lite/types/CircuitBreaker.js';
|
|
@@ -35,6 +35,11 @@ initDevvitGlobal();
|
|
|
35
35
|
export class AppUILooper {
|
|
36
36
|
constructor() {
|
|
37
37
|
_AppUILooper_instances.add(this);
|
|
38
|
+
/**
|
|
39
|
+
* Bundle currently loaded. Used to test whether failed requests are for the
|
|
40
|
+
* currently loaded bundle or a previous one.
|
|
41
|
+
*/
|
|
42
|
+
_AppUILooper_app.set(this, void 0);
|
|
38
43
|
/**
|
|
39
44
|
* App state is never reset in production. Prior remote executions may have
|
|
40
45
|
* occurred. The next loop will replace the state. Do not lose the current
|
|
@@ -70,25 +75,28 @@ export class AppUILooper {
|
|
|
70
75
|
*/
|
|
71
76
|
async load(app, sandbox) {
|
|
72
77
|
this.unload();
|
|
78
|
+
__classPrivateFieldSet(this, _AppUILooper_app, app, "f");
|
|
73
79
|
try {
|
|
74
80
|
await this._local?.loadBundle(app, sandbox);
|
|
75
81
|
}
|
|
76
82
|
catch (err) {
|
|
77
|
-
this.
|
|
83
|
+
__classPrivateFieldGet(this, _AppUILooper_instances, "m", _AppUILooper_onError).call(this, app, 'Error', err);
|
|
78
84
|
}
|
|
79
85
|
}
|
|
80
86
|
queueEvent(ev) {
|
|
87
|
+
const app = __classPrivateFieldGet(this, _AppUILooper_app, "f");
|
|
81
88
|
if (ev.queue) {
|
|
82
89
|
// TODO: Add QoS for different types of events on alternate queues. For
|
|
83
90
|
// now, treat alternate queues as having infinite concurrency.
|
|
84
|
-
void __classPrivateFieldGet(this, _AppUILooper_instances, "m", _AppUILooper_processEvent).call(this, ev);
|
|
91
|
+
void __classPrivateFieldGet(this, _AppUILooper_instances, "m", _AppUILooper_processEvent).call(this, app, ev);
|
|
85
92
|
}
|
|
86
93
|
else {
|
|
87
|
-
void __classPrivateFieldGet(this, _AppUILooper_q, "f").add(() => __classPrivateFieldGet(this, _AppUILooper_instances, "m", _AppUILooper_processEvent).call(this, ev));
|
|
94
|
+
void __classPrivateFieldGet(this, _AppUILooper_q, "f").add(() => __classPrivateFieldGet(this, _AppUILooper_instances, "m", _AppUILooper_processEvent).call(this, app, ev));
|
|
88
95
|
}
|
|
89
96
|
}
|
|
90
97
|
queueRenderPost(type, id, data) {
|
|
91
|
-
|
|
98
|
+
const app = __classPrivateFieldGet(this, _AppUILooper_app, "f");
|
|
99
|
+
void __classPrivateFieldGet(this, _AppUILooper_q, "f").add(() => __classPrivateFieldGet(this, _AppUILooper_instances, "m", _AppUILooper_renderPost).call(this, app, type, id, data));
|
|
92
100
|
}
|
|
93
101
|
get rendered() {
|
|
94
102
|
return __classPrivateFieldGet(this, _AppUILooper_rendered, "f");
|
|
@@ -113,17 +121,14 @@ export class AppUILooper {
|
|
|
113
121
|
}
|
|
114
122
|
/** Unload the app and reject any open requests. */
|
|
115
123
|
unload() {
|
|
124
|
+
__classPrivateFieldSet(this, _AppUILooper_app, undefined, "f");
|
|
116
125
|
if (__classPrivateFieldGet(this, _AppUILooper_rerenderTimeout, "f") != null)
|
|
117
126
|
clearTimeout(__classPrivateFieldGet(this, _AppUILooper_rerenderTimeout, "f"));
|
|
118
|
-
|
|
119
|
-
// re-enable errors. Leave app state as-is.
|
|
120
|
-
const onError = this.onError;
|
|
121
|
-
this.onError = undefined;
|
|
127
|
+
__classPrivateFieldGet(this, _AppUILooper_q, "f").clear();
|
|
122
128
|
this._local?.quit();
|
|
123
|
-
this.onError = onError;
|
|
124
129
|
}
|
|
125
130
|
}
|
|
126
|
-
_AppUILooper_appState = new WeakMap(), _AppUILooper_q = new WeakMap(), _AppUILooper_rendered = new WeakMap(), _AppUILooper_rerenderTimeout = new WeakMap(), _AppUILooper_onPluginCall = new WeakMap(), _AppUILooper_instances = new WeakSet(), _AppUILooper_onEffects = function _AppUILooper_onEffects(renderType, effects) {
|
|
131
|
+
_AppUILooper_app = new WeakMap(), _AppUILooper_appState = new WeakMap(), _AppUILooper_q = new WeakMap(), _AppUILooper_rendered = new WeakMap(), _AppUILooper_rerenderTimeout = new WeakMap(), _AppUILooper_onPluginCall = new WeakMap(), _AppUILooper_instances = new WeakSet(), _AppUILooper_onEffects = function _AppUILooper_onEffects(renderType, effects) {
|
|
127
132
|
for (const effect of effects) {
|
|
128
133
|
if (effect.rerenderUi) {
|
|
129
134
|
if (__classPrivateFieldGet(this, _AppUILooper_rerenderTimeout, "f") != null)
|
|
@@ -140,7 +145,16 @@ _AppUILooper_appState = new WeakMap(), _AppUILooper_q = new WeakMap(), _AppUILoo
|
|
|
140
145
|
this.onUserAction?.(effect);
|
|
141
146
|
}
|
|
142
147
|
}
|
|
143
|
-
},
|
|
148
|
+
}, _AppUILooper_onError = function _AppUILooper_onError(app, type, err) {
|
|
149
|
+
// Test if error was for a previously loaded bundle. If so, it's a hanging
|
|
150
|
+
// request waiting for the BrowserLiteClient.quit() rejection. We can clear
|
|
151
|
+
// enqueued requests on quit() but not in-flight requests. If app is
|
|
152
|
+
// undefined, no assumptions can be made about the request since it was for
|
|
153
|
+
// remote execution
|
|
154
|
+
if (app && __classPrivateFieldGet(this, _AppUILooper_app, "f") !== app)
|
|
155
|
+
return;
|
|
156
|
+
this.onError?.(type, err);
|
|
157
|
+
}, _AppUILooper_processEvent = async function _AppUILooper_processEvent(app, ev) {
|
|
144
158
|
let rsp;
|
|
145
159
|
const req = { event: ev, state: this.appState };
|
|
146
160
|
if (this._local?.ready) {
|
|
@@ -149,7 +163,7 @@ _AppUILooper_appState = new WeakMap(), _AppUILooper_q = new WeakMap(), _AppUILoo
|
|
|
149
163
|
}
|
|
150
164
|
catch (err) {
|
|
151
165
|
if (!isCircuitBreaker(err) || !this.remote)
|
|
152
|
-
this.
|
|
166
|
+
__classPrivateFieldGet(this, _AppUILooper_instances, "m", _AppUILooper_onError).call(this, app, 'Error', err);
|
|
153
167
|
if (devvit?.logLocalErrors)
|
|
154
168
|
console.info('remote call', err);
|
|
155
169
|
}
|
|
@@ -159,7 +173,7 @@ _AppUILooper_appState = new WeakMap(), _AppUILooper_q = new WeakMap(), _AppUILoo
|
|
|
159
173
|
rsp = await this.remote?.HandleUIEvent(req, this.meta);
|
|
160
174
|
}
|
|
161
175
|
catch (err) {
|
|
162
|
-
this.
|
|
176
|
+
__classPrivateFieldGet(this, _AppUILooper_instances, "m", _AppUILooper_onError).call(this, app, 'Error', err);
|
|
163
177
|
}
|
|
164
178
|
}
|
|
165
179
|
if (rsp) {
|
|
@@ -172,7 +186,7 @@ _AppUILooper_appState = new WeakMap(), _AppUILooper_q = new WeakMap(), _AppUILoo
|
|
|
172
186
|
: BlockRenderEventType.RENDER_USER_ACTION;
|
|
173
187
|
__classPrivateFieldGet(this, _AppUILooper_instances, "m", _AppUILooper_onEffects).call(this, renderType, rsp.effects);
|
|
174
188
|
}
|
|
175
|
-
}, _AppUILooper_renderPost = async function _AppUILooper_renderPost(type, id, data) {
|
|
189
|
+
}, _AppUILooper_renderPost = async function _AppUILooper_renderPost(app, type, id, data) {
|
|
176
190
|
const req = { blocks: { type, id, data }, state: this.appState };
|
|
177
191
|
let rsp;
|
|
178
192
|
if (this._local?.ready) {
|
|
@@ -183,7 +197,7 @@ _AppUILooper_appState = new WeakMap(), _AppUILooper_q = new WeakMap(), _AppUILoo
|
|
|
183
197
|
if (isCircuitBreaker(err) && err.response)
|
|
184
198
|
rsp = err.response;
|
|
185
199
|
if (!isCircuitBreaker(err) || !this.remote)
|
|
186
|
-
this.
|
|
200
|
+
__classPrivateFieldGet(this, _AppUILooper_instances, "m", _AppUILooper_onError).call(this, app, 'Error', err);
|
|
187
201
|
if (devvit?.logLocalErrors)
|
|
188
202
|
console.info('remote call', err);
|
|
189
203
|
}
|
|
@@ -193,7 +207,7 @@ _AppUILooper_appState = new WeakMap(), _AppUILooper_q = new WeakMap(), _AppUILoo
|
|
|
193
207
|
rsp = await this.remote?.RenderPost(req, this.meta);
|
|
194
208
|
}
|
|
195
209
|
catch (err) {
|
|
196
|
-
this.
|
|
210
|
+
__classPrivateFieldGet(this, _AppUILooper_instances, "m", _AppUILooper_onError).call(this, app, 'Error', err);
|
|
197
211
|
}
|
|
198
212
|
}
|
|
199
213
|
if (rsp) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
2
|
-
import type { BlockAction, Effect, LinkedBundle, Metadata, RenderPostResponse, Struct, UIEvent
|
|
2
|
+
import type { BlockAction, Effect, LinkedBundle, Metadata, RealtimeEvent, RenderPostResponse, Struct, UIEvent } from '@devvit/protos';
|
|
3
3
|
import type { WorkerErrorType } from '@devvit/runtime-lite/client/BrowserLiteClient.js';
|
|
4
4
|
import type { ActorRef } from '@devvit/runtimes/common/runtime/ActorRef.js';
|
|
5
5
|
import type { FaceplateEvent } from '@reddit/faceplate/event-types.js';
|
|
@@ -58,6 +58,7 @@ export type DevvitUserActionEvent = FaceplateEvent<'devvit-user-action'> & {
|
|
|
58
58
|
*/
|
|
59
59
|
export declare class DevvitCustomPost extends LitElement {
|
|
60
60
|
#private;
|
|
61
|
+
static get styles(): import("lit").CSSResult[];
|
|
61
62
|
/** Probably a wrapper around the remote runtime (compute-go). */
|
|
62
63
|
actorRef?: ActorRef | UIApp | undefined;
|
|
63
64
|
bundle?: LinkedBundle | undefined;
|
|
@@ -73,11 +74,10 @@ export declare class DevvitCustomPost extends LitElement {
|
|
|
73
74
|
private _isSuspended;
|
|
74
75
|
private _rootBlock?;
|
|
75
76
|
constructor();
|
|
77
|
+
get blocksConfig(): string;
|
|
76
78
|
connectedCallback(): Promise<void>;
|
|
77
79
|
disconnectedCallback(): void;
|
|
78
|
-
get blocksConfig(): string;
|
|
79
80
|
rerender(): void;
|
|
80
|
-
static get styles(): import("lit").CSSResult[];
|
|
81
81
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
82
82
|
protected willUpdate(props: PropertyValues<this>): Promise<void>;
|
|
83
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devvit-custom-post.d.ts","sourceRoot":"","sources":["../../library/src/client/devvit-custom-post.ts"],"names":[],"mappings":"AAAA,OAAO,kEAAkE,CAAC;AAE1E,OAAO,KAAK,EACV,WAAW,EAEX,MAAM,EACN,YAAY,EACZ,QAAQ,
|
|
1
|
+
{"version":3,"file":"devvit-custom-post.d.ts","sourceRoot":"","sources":["../../library/src/client/devvit-custom-post.ts"],"names":[],"mappings":"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"}
|
|
@@ -20,12 +20,11 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
20
20
|
};
|
|
21
21
|
var _DevvitCustomPost_instances, _DevvitCustomPost_lastRequest, _DevvitCustomPost_looper, _DevvitCustomPost_rootHeight, _DevvitCustomPost_bubble, _DevvitCustomPost_newRenderContext, _DevvitCustomPost_onError, _DevvitCustomPost_onPluginCall, _DevvitCustomPost_onRenderPost, _DevvitCustomPost_onUserActionEffect, _DevvitCustomPost_onUserActionEvent;
|
|
22
22
|
import '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
23
|
-
import { Block } from '@devvit/protos';
|
|
24
|
-
import { BlockConfig_Root, BlockRenderEventType, BlockStackDirection, RealtimeDefinition, } from '@devvit/protos';
|
|
25
|
-
import * as b64 from 'base64-js';
|
|
23
|
+
import { Block, BlockConfig_Root, BlockRenderEventType, BlockStackDirection, RealtimeDefinition, } from '@devvit/protos';
|
|
26
24
|
import { isCircuitBreaker } from '@devvit/runtime-lite/types/CircuitBreaker.js';
|
|
27
25
|
import { asT3ID } from '@devvit/shared-types/tid.js';
|
|
28
26
|
import { customEvent } from '@reddit/faceplate/lib/custom-event.js';
|
|
27
|
+
import * as b64 from 'base64-js';
|
|
29
28
|
import { LitElement, html, nothing } from 'lit';
|
|
30
29
|
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
31
30
|
import { DevvitBlocksRenderer } from '../blocks/components/devvit-blocks-renderer.js';
|
|
@@ -48,6 +47,9 @@ import './devvit-animation-player.js';
|
|
|
48
47
|
* @slot - Loading / unloaded state.
|
|
49
48
|
*/
|
|
50
49
|
let DevvitCustomPost = class DevvitCustomPost extends LitElement {
|
|
50
|
+
static get styles() {
|
|
51
|
+
return [styles];
|
|
52
|
+
}
|
|
51
53
|
constructor() {
|
|
52
54
|
super();
|
|
53
55
|
_DevvitCustomPost_instances.add(this);
|
|
@@ -108,6 +110,11 @@ let DevvitCustomPost = class DevvitCustomPost extends LitElement {
|
|
|
108
110
|
__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").onRenderPost = __classPrivateFieldGet(this, _DevvitCustomPost_onRenderPost, "f");
|
|
109
111
|
__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").onUserAction = __classPrivateFieldGet(this, _DevvitCustomPost_onUserActionEffect, "f");
|
|
110
112
|
}
|
|
113
|
+
get blocksConfig() {
|
|
114
|
+
if (!this._rootBlock)
|
|
115
|
+
return '';
|
|
116
|
+
return b64.fromByteArray(Block.encode(this._rootBlock).finish());
|
|
117
|
+
}
|
|
111
118
|
async connectedCallback() {
|
|
112
119
|
super.connectedCallback();
|
|
113
120
|
this._isSuspended = false;
|
|
@@ -117,18 +124,10 @@ let DevvitCustomPost = class DevvitCustomPost extends LitElement {
|
|
|
117
124
|
__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").unload();
|
|
118
125
|
super.disconnectedCallback();
|
|
119
126
|
}
|
|
120
|
-
get blocksConfig() {
|
|
121
|
-
if (!this._rootBlock)
|
|
122
|
-
return '';
|
|
123
|
-
return b64.fromByteArray(Block.encode(this._rootBlock).finish());
|
|
124
|
-
}
|
|
125
127
|
// to-do [studio]: remove.
|
|
126
128
|
rerender() {
|
|
127
129
|
this._blocksRenderer?.requestUpdate();
|
|
128
130
|
}
|
|
129
|
-
static get styles() {
|
|
130
|
-
return [styles];
|
|
131
|
-
}
|
|
132
131
|
render() {
|
|
133
132
|
if (!this.renderResponse) {
|
|
134
133
|
// The slot content is considered the loading state.
|
|
@@ -165,9 +164,11 @@ let DevvitCustomPost = class DevvitCustomPost extends LitElement {
|
|
|
165
164
|
__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").setLocalSrc(this.localRuntimeCode);
|
|
166
165
|
if (props.has('bundle') && this.bundle) {
|
|
167
166
|
await __classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").load(this.bundle, this.useSandbox);
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
if (props.get('bundle')) {
|
|
168
|
+
// Bundle was _replaced_ (likely devvit-preview). Require a new render.
|
|
169
|
+
this.renderResponse = undefined;
|
|
170
170
|
__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").resetAppState();
|
|
171
|
+
}
|
|
171
172
|
}
|
|
172
173
|
if (!__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").rendered)
|
|
173
174
|
__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").queueRenderPost(BlockRenderEventType.RENDER_INITIAL, undefined, {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/ui-renderer",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.18-next-2024-03-04-883f53706.0",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
},
|
|
56
56
|
"types": "./index.d.ts",
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@devvit/protos": "0.10.
|
|
59
|
-
"@devvit/runtime-lite": "0.10.
|
|
60
|
-
"@devvit/runtimes": "0.10.
|
|
61
|
-
"@devvit/shared-types": "0.10.
|
|
58
|
+
"@devvit/protos": "0.10.18-next-2024-03-04-883f53706.0",
|
|
59
|
+
"@devvit/runtime-lite": "0.10.18-next-2024-03-04-883f53706.0",
|
|
60
|
+
"@devvit/runtimes": "0.10.18-next-2024-03-04-883f53706.0",
|
|
61
|
+
"@devvit/shared-types": "0.10.18-next-2024-03-04-883f53706.0",
|
|
62
62
|
"@dotlottie/player-component": "2.7.2",
|
|
63
63
|
"p-queue": "7.3.4",
|
|
64
64
|
"rxjs": "7.8.1"
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@devvit/eslint-config": "0.10.17",
|
|
87
87
|
"@devvit/repo-tools": "0.10.17",
|
|
88
|
-
"@devvit/tsconfig": "0.10.
|
|
88
|
+
"@devvit/tsconfig": "0.10.18-next-2024-03-04-883f53706.0",
|
|
89
89
|
"@lit-labs/ssr": "^2.2.3",
|
|
90
90
|
"@lit/localize": "0.11.4",
|
|
91
91
|
"@open-wc/testing-helpers": "2.3.0",
|
|
@@ -118,5 +118,5 @@
|
|
|
118
118
|
"directory": "dist"
|
|
119
119
|
},
|
|
120
120
|
"source": "./src/index.ts",
|
|
121
|
-
"gitHead": "
|
|
121
|
+
"gitHead": "d80d340bcbc4ed4be43e7ae0780cf3649d74eb9b"
|
|
122
122
|
}
|