@devvit/server 0.11.18-next-2025-06-23-18-44-30-c58ed8056.0 → 0.11.18-next-2025-06-23-21-36-15-f01593d3a.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.
- package/define-config.d.ts +2 -1
- package/define-config.d.ts.map +1 -1
- package/define-config.js +47 -1
- package/package.json +7 -7
package/define-config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Devvit } from '@devvit/public-api';
|
|
2
|
-
import type { AppConfig, AppPermissionConfig, AppPostCreateConfig } from '@devvit/shared-types/schemas/config-file.v1.js';
|
|
2
|
+
import type { AppConfig, AppMenuActionConfig, AppPermissionConfig, AppPostCreateConfig } from '@devvit/shared-types/schemas/config-file.v1.js';
|
|
3
3
|
/**
|
|
4
4
|
* A subset of AppConfig (see config-file.v1.json) available in V8-flavored
|
|
5
5
|
* LinkedBundles except for the deprecated Blocks callbacks. This config is used
|
|
@@ -12,6 +12,7 @@ import type { AppConfig, AppPermissionConfig, AppPostCreateConfig } from '@devvi
|
|
|
12
12
|
export type DynamicAppConfig = {
|
|
13
13
|
permissions: AppPermissionConfig;
|
|
14
14
|
post?: DynamicAppPostConfig | undefined;
|
|
15
|
+
menuActions?: AppMenuActionConfig[];
|
|
15
16
|
};
|
|
16
17
|
/** @experimental */
|
|
17
18
|
export type DynamicAppPostConfig = {
|
package/define-config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../src/define-config.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../src/define-config.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAKP,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,gDAAgD,CAAC;AAIxD;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,mBAAmB,CAAC;IACjC,IAAI,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;IACxC,WAAW,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACrC,CAAC;AAEF,oBAAoB;AACpB,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE;QACN,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,kBAAkB;QAClB,MAAM,CAAC,EAAE;YACP,iDAAiD;YACjD,MAAM,CAAC,EACH,QAAQ,GACR;gBACE,IAAI,EAAE,OAAO,CAAC;gBACd;;;mBAGG;gBACH,KAAK,CAAC,EAAE,CAAC,MAAM,MAAM,CAAC,GAAG,SAAS,CAAC;aACpC,GACD,MAAM,CAAC,mBAAmB,GAC1B,SAAS,CAAC;SACf,CAAC;KACH,CAAC;IACF,MAAM,EAAE,0BAA0B,CAAC;CACpC,CAAC;AAEF,oBAAoB;AACpB,MAAM,MAAM,0BAA0B,GAAG,mBAAmB,GAAG;IAC7D,kBAAkB;IAClB,MAAM,CAAC,EACH;QACE;;;;WAIG;QACH,MAAM,CAAC,IAAI,GAAG,CAAC,OAAO,GAAG,SAAS,CAAC;QACnC;;;WAGG;QACH,KAAK,CAAC,IAAI,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;KAChD,GACD,SAAS,CAAC;CACf,CAAC;AAEF,oBAAoB;AACpB,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,GAAG,SAAS,CAAC,GAAG,OAAO,MAAM,CAK1F"}
|
package/define-config.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { Devvit, useWebView } from '@devvit/public-api';
|
|
1
|
+
import { Devvit, useWebView, } from '@devvit/public-api';
|
|
2
|
+
import { getServerPort } from './get-server-port.js';
|
|
2
3
|
/** @experimental */
|
|
3
4
|
export function defineConfig(config) {
|
|
4
5
|
configurePermissions(config.permissions);
|
|
5
6
|
if (config.post)
|
|
6
7
|
configurePost(config.post);
|
|
8
|
+
if (config.menuActions)
|
|
9
|
+
configureMenuActions(config.menuActions);
|
|
7
10
|
return Devvit;
|
|
8
11
|
}
|
|
9
12
|
function configurePermissions(permissions) {
|
|
@@ -61,6 +64,49 @@ function configurePost(post) {
|
|
|
61
64
|
},
|
|
62
65
|
});
|
|
63
66
|
}
|
|
67
|
+
function configureMenuActions(menuActions) {
|
|
68
|
+
for (const action of menuActions) {
|
|
69
|
+
const menuItem = {
|
|
70
|
+
label: action.label,
|
|
71
|
+
location: action.location,
|
|
72
|
+
onPress: async (ev, ctx) => {
|
|
73
|
+
const url = new URL(action.endpoint, `http://webbit.local:${getServerPort()}/`);
|
|
74
|
+
const headers = {};
|
|
75
|
+
Object.entries(ctx.debug.metadata).forEach(([key, metadata]) => {
|
|
76
|
+
headers[key] = metadata.values[0];
|
|
77
|
+
});
|
|
78
|
+
headers['Content-Type'] = 'application/json';
|
|
79
|
+
const response = await fetch(url, {
|
|
80
|
+
method: 'POST',
|
|
81
|
+
// TODO: add a request message type that devs can use with this info.
|
|
82
|
+
// i.e. (req: Request<MenuItemOnPressEvent>)
|
|
83
|
+
body: JSON.stringify({
|
|
84
|
+
location: ev.location,
|
|
85
|
+
targetId: ev.targetId,
|
|
86
|
+
}),
|
|
87
|
+
headers,
|
|
88
|
+
});
|
|
89
|
+
if (!response.ok) {
|
|
90
|
+
const body = await response.text();
|
|
91
|
+
throw new Error(`Failed to fetch from ${action.endpoint}: ${response.statusText}, body: ${body}`);
|
|
92
|
+
}
|
|
93
|
+
// TODO: implement UI effect handling.
|
|
94
|
+
ctx.ui.showToast('it was clicked! ' + JSON.stringify(await response.json()));
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
// "user" type is blank in Devvit classic. So if it's present in
|
|
98
|
+
// devvit.json, we add an extra menu item without forUserType set.
|
|
99
|
+
// "moderator" maps across as expected.
|
|
100
|
+
// "loggedOut" type (Devvit classic) we no longer support
|
|
101
|
+
if (action.forUserType === 'moderator')
|
|
102
|
+
menuItem.forUserType = 'moderator';
|
|
103
|
+
if (action.postFilter === 'currentApp')
|
|
104
|
+
menuItem.postFilter = action.postFilter;
|
|
105
|
+
if (action.description)
|
|
106
|
+
menuItem.description = action.description;
|
|
107
|
+
Devvit.addMenuItem(menuItem);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
64
110
|
async function createPost(ctx, create) {
|
|
65
111
|
if (!ctx.subredditName)
|
|
66
112
|
throw Error('no sub name');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/server",
|
|
3
|
-
"version": "0.11.18-next-2025-06-23-
|
|
3
|
+
"version": "0.11.18-next-2025-06-23-21-36-15-f01593d3a.0",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
},
|
|
24
24
|
"types": "./index.d.ts",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@devvit/protos": "0.11.18-next-2025-06-23-
|
|
27
|
-
"@devvit/public-api": "0.11.18-next-2025-06-23-
|
|
28
|
-
"@devvit/shared-types": "0.11.18-next-2025-06-23-
|
|
26
|
+
"@devvit/protos": "0.11.18-next-2025-06-23-21-36-15-f01593d3a.0",
|
|
27
|
+
"@devvit/public-api": "0.11.18-next-2025-06-23-21-36-15-f01593d3a.0",
|
|
28
|
+
"@devvit/shared-types": "0.11.18-next-2025-06-23-21-36-15-f01593d3a.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@devvit/repo-tools": "0.11.18-next-2025-06-23-
|
|
32
|
-
"@devvit/tsconfig": "0.11.18-next-2025-06-23-
|
|
31
|
+
"@devvit/repo-tools": "0.11.18-next-2025-06-23-21-36-15-f01593d3a.0",
|
|
32
|
+
"@devvit/tsconfig": "0.11.18-next-2025-06-23-21-36-15-f01593d3a.0",
|
|
33
33
|
"eslint": "9.11.1",
|
|
34
34
|
"typescript": "5.8.3",
|
|
35
35
|
"vitest": "1.6.1"
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"directory": "dist"
|
|
39
39
|
},
|
|
40
40
|
"source": "./src/index.ts",
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "337751fa3f20923c7361a72ee2798426f3bdeb02"
|
|
42
42
|
}
|