@devvit/ui-renderer 0.10.18-next-2024-03-14-45dbecf91.0 → 0.10.18-next-2024-03-15-a57872b7a.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,4 +1,4 @@
|
|
|
1
|
-
import type { Effect, LinkedBundle, Metadata, RenderPostRequest, RenderPostResponse, Struct, UIEvent } from '@devvit/protos';
|
|
1
|
+
import type { Dimensions, Effect, LinkedBundle, Metadata, RenderPostRequest, RenderPostResponse, Struct, UIEvent } from '@devvit/protos';
|
|
2
2
|
import { BlockRenderEventType } from '@devvit/protos';
|
|
3
3
|
import type { ErrorCallback, LiteClient } from '@devvit/runtime-lite/client/BrowserLiteClient.js';
|
|
4
4
|
import type { PluginCallback } from '@devvit/runtime-lite/runtime/RuntimeLite.js';
|
|
@@ -39,6 +39,8 @@ export declare class AppUILooper {
|
|
|
39
39
|
postID?: T3ID | undefined;
|
|
40
40
|
/** A client to the remote runtime. */
|
|
41
41
|
remote?: UIApp | undefined;
|
|
42
|
+
/** Dimensions that describe layout information for the custom post entry point */
|
|
43
|
+
dimensions: Dimensions;
|
|
42
44
|
/**
|
|
43
45
|
* A client to the local runtime.
|
|
44
46
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
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,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AAS,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;IAC3B,kFAAkF;IAClF,UAAU,EAAE,UAAU,CAAsB;IAe5C;;;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;CAiHf"}
|
package/client/app-ui-looper.js
CHANGED
|
@@ -15,6 +15,7 @@ import { BrowserLiteClient } from '@devvit/runtime-lite/client/BrowserLiteClient
|
|
|
15
15
|
import { isCircuitBreaker } from '@devvit/runtime-lite/types/CircuitBreaker.js';
|
|
16
16
|
import PQueue from 'p-queue';
|
|
17
17
|
import { initDevvitGlobal } from '../types/devvit-global.js';
|
|
18
|
+
import { DEFAULT_DIMENSIONS } from '@devvit/shared-types/dimensions.js';
|
|
18
19
|
// Effects that can only be fired as the result of a user action
|
|
19
20
|
const userActionEffects = ['showToast', 'showForm', 'navigateToUrl'];
|
|
20
21
|
initDevvitGlobal();
|
|
@@ -35,6 +36,8 @@ initDevvitGlobal();
|
|
|
35
36
|
export class AppUILooper {
|
|
36
37
|
constructor() {
|
|
37
38
|
_AppUILooper_instances.add(this);
|
|
39
|
+
/** Dimensions that describe layout information for the custom post entry point */
|
|
40
|
+
this.dimensions = DEFAULT_DIMENSIONS;
|
|
38
41
|
/**
|
|
39
42
|
* Bundle currently loaded. Used to test whether failed requests are for the
|
|
40
43
|
* currently loaded bundle or a previous one.
|
|
@@ -187,7 +190,11 @@ _AppUILooper_app = new WeakMap(), _AppUILooper_appState = new WeakMap(), _AppUIL
|
|
|
187
190
|
__classPrivateFieldGet(this, _AppUILooper_instances, "m", _AppUILooper_onEffects).call(this, renderType, rsp.effects);
|
|
188
191
|
}
|
|
189
192
|
}, _AppUILooper_renderPost = async function _AppUILooper_renderPost(app, type, id, data) {
|
|
190
|
-
const req = {
|
|
193
|
+
const req = {
|
|
194
|
+
blocks: { type, id, data },
|
|
195
|
+
state: this.appState,
|
|
196
|
+
dimensions: this.dimensions,
|
|
197
|
+
};
|
|
191
198
|
let rsp;
|
|
192
199
|
if (this._local?.ready) {
|
|
193
200
|
try {
|
|
@@ -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,EACR,aAAa,EAEb,kBAAkB,EAClB,MAAM,EACN,OAAO,EACR,MAAM,gBAAgB,CAAC;AAQxB,OAAO,KAAK,EAEV,eAAe,EAChB,MAAM,kDAAkD,CAAC;AAG1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAC;AAE5E,OAAO,KAAK,EAAE,cAAc,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CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAExB,OAAO,CAAC,eAAe,CAAwB;IACvE,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,UAAU,CAAC,CAAoB;;IAehD,iBAAiB,IAAI,IAAI;IAwBzB,IAAI,YAAY,IAAI,MAAM,CAGzB;IACc,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAKxC,oBAAoB,IAAI,IAAI;IAOrC,QAAQ,IAAI,IAAI;cAIG,MAAM;cAoBA,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CA2FhF"}
|
|
@@ -32,6 +32,7 @@ import { DEFAULT_ROOT_HEIGHT } from '../blocks/templates/renderBlock.js';
|
|
|
32
32
|
import { styles } from '../styles.js';
|
|
33
33
|
import { AppUILooper } from './app-ui-looper.js';
|
|
34
34
|
import { RemoteApp } from './ui-app.js';
|
|
35
|
+
import { throttle } from '@devvit/shared-types/throttle.js';
|
|
35
36
|
import '../blocks/components/devvit-blocks-renderer.js';
|
|
36
37
|
import '../blocks/components/devvit-blocks-webview.js';
|
|
37
38
|
import './devvit-animation-player.js';
|
|
@@ -109,6 +110,24 @@ let DevvitCustomPost = class DevvitCustomPost extends LitElement {
|
|
|
109
110
|
__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").onPluginCall = __classPrivateFieldGet(this, _DevvitCustomPost_onPluginCall, "f");
|
|
110
111
|
__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").onRenderPost = __classPrivateFieldGet(this, _DevvitCustomPost_onRenderPost, "f");
|
|
111
112
|
__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").onUserAction = __classPrivateFieldGet(this, _DevvitCustomPost_onUserActionEffect, "f");
|
|
113
|
+
this.observeDimensions();
|
|
114
|
+
}
|
|
115
|
+
observeDimensions() {
|
|
116
|
+
const resizeObserver = new ResizeObserver(throttle((entries) => {
|
|
117
|
+
if (entries.length === 0)
|
|
118
|
+
return;
|
|
119
|
+
const entry = entries[0];
|
|
120
|
+
const { contentRect: { width, height }, } = entry;
|
|
121
|
+
const scale = window.devicePixelRatio;
|
|
122
|
+
// Set dimensions on the looper directly so that all effects will contain the most
|
|
123
|
+
// update to date dimensions.
|
|
124
|
+
__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").dimensions = { width, height, scale };
|
|
125
|
+
// Ensure the initial update is handled inside of willUpdate
|
|
126
|
+
if (__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").rendered) {
|
|
127
|
+
__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").queueRenderPost(BlockRenderEventType.RENDER_USER_ACTION, undefined, {});
|
|
128
|
+
}
|
|
129
|
+
}, 600));
|
|
130
|
+
resizeObserver.observe(this);
|
|
112
131
|
}
|
|
113
132
|
get blocksConfig() {
|
|
114
133
|
if (!this._rootBlock)
|
|
@@ -170,8 +189,9 @@ let DevvitCustomPost = class DevvitCustomPost extends LitElement {
|
|
|
170
189
|
__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").resetAppState();
|
|
171
190
|
}
|
|
172
191
|
}
|
|
173
|
-
if (!__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").rendered)
|
|
174
|
-
__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").queueRenderPost(BlockRenderEventType.
|
|
192
|
+
if (!__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").rendered) {
|
|
193
|
+
__classPrivateFieldGet(this, _DevvitCustomPost_looper, "f").queueRenderPost(BlockRenderEventType.RENDER_USER_ACTION, undefined, {});
|
|
194
|
+
}
|
|
175
195
|
}
|
|
176
196
|
};
|
|
177
197
|
_DevvitCustomPost_lastRequest = new WeakMap();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/ui-renderer",
|
|
3
|
-
"version": "0.10.18-next-2024-03-
|
|
3
|
+
"version": "0.10.18-next-2024-03-15-a57872b7a.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.18-next-2024-03-
|
|
59
|
-
"@devvit/runtime-lite": "0.10.18-next-2024-03-
|
|
60
|
-
"@devvit/runtimes": "0.10.18-next-2024-03-
|
|
61
|
-
"@devvit/shared-types": "0.10.18-next-2024-03-
|
|
58
|
+
"@devvit/protos": "0.10.18-next-2024-03-15-a57872b7a.0",
|
|
59
|
+
"@devvit/runtime-lite": "0.10.18-next-2024-03-15-a57872b7a.0",
|
|
60
|
+
"@devvit/runtimes": "0.10.18-next-2024-03-15-a57872b7a.0",
|
|
61
|
+
"@devvit/shared-types": "0.10.18-next-2024-03-15-a57872b7a.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.18-next-2024-03-
|
|
88
|
+
"@devvit/tsconfig": "0.10.18-next-2024-03-15-a57872b7a.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": "3910d5aba1bc7e22ddffb0587e1511675eb4e35c"
|
|
122
122
|
}
|