@devvit/cli 0.11.2-next-2024-10-31-30436bfff.0 → 0.11.2
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/package.json +8 -8
- package/dist/templates/webviews/package.json +0 -13
- package/dist/templates/webviews/src/createPost.tsx +0 -26
- package/dist/templates/webviews/src/main.tsx +0 -43
- package/dist/templates/webviews/template-config.json +0 -3
- package/dist/templates/webviews/tsconfig.json +0 -3
- package/dist/templates/webviews/webroot/page.html +0 -14
- package/dist/templates/webviews/webroot/script.js +0 -24
- package/dist/templates/webviews/webroot/style.css +0 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/cli",
|
|
3
|
-
"version": "0.11.2
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "Reddit's Dev Platform CLI Tool",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"author": "@reddit/dev-platform",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
},
|
|
43
43
|
"types": "dist/index.d.ts",
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@devvit/build-pack": "0.11.2
|
|
45
|
+
"@devvit/build-pack": "0.11.2",
|
|
46
46
|
"@devvit/play": "0.0.43",
|
|
47
|
-
"@devvit/protos": "0.11.2
|
|
48
|
-
"@devvit/public-api": "0.11.2
|
|
49
|
-
"@devvit/shared-types": "0.11.2
|
|
47
|
+
"@devvit/protos": "0.11.2",
|
|
48
|
+
"@devvit/public-api": "0.11.2",
|
|
49
|
+
"@devvit/shared-types": "0.11.2",
|
|
50
50
|
"@improbable-eng/grpc-web": "0.15.0",
|
|
51
51
|
"@improbable-eng/grpc-web-node-http-transport": "0.15.0",
|
|
52
52
|
"@oclif/core": "2.9.4",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"ws": "8.18.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@devvit/repo-tools": "0.11.2
|
|
82
|
-
"@devvit/tsconfig": "0.11.2
|
|
81
|
+
"@devvit/repo-tools": "0.11.2",
|
|
82
|
+
"@devvit/tsconfig": "0.11.2",
|
|
83
83
|
"@types/file-type": "10.9.1",
|
|
84
84
|
"@types/inquirer": "9.0.3",
|
|
85
85
|
"@types/js-yaml": "4.0.5",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
]
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
|
-
"gitHead": "
|
|
123
|
+
"gitHead": "9dbed838554fc960b6ce0211b33fcfca12d4df6f"
|
|
124
124
|
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Devvit } from '@devvit/public-api';
|
|
2
|
-
|
|
3
|
-
Devvit.configure({
|
|
4
|
-
redditAPI: true,
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
Devvit.addMenuItem({
|
|
8
|
-
label: 'Create Webview Example Post',
|
|
9
|
-
location: 'subreddit',
|
|
10
|
-
onPress: async (_event, context) => {
|
|
11
|
-
const { reddit, ui } = context;
|
|
12
|
-
const subreddit = await reddit.getCurrentSubreddit();
|
|
13
|
-
const post = await reddit.submitPost({
|
|
14
|
-
title: 'Webview Example',
|
|
15
|
-
subredditName: subreddit.name,
|
|
16
|
-
// The preview appears while the post loads
|
|
17
|
-
preview: (
|
|
18
|
-
<vstack height="100%" width="100%" alignment="middle center">
|
|
19
|
-
<text size="large">Loading ...</text>
|
|
20
|
-
</vstack>
|
|
21
|
-
),
|
|
22
|
-
});
|
|
23
|
-
ui.showToast({ text: 'Created post!' });
|
|
24
|
-
ui.navigateTo(post);
|
|
25
|
-
},
|
|
26
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import './createPost.js';
|
|
2
|
-
|
|
3
|
-
import { Devvit, type JSONObject, useState } from '@devvit/public-api';
|
|
4
|
-
|
|
5
|
-
Devvit.addCustomPostType({
|
|
6
|
-
name: 'Webview Example',
|
|
7
|
-
height: 'tall',
|
|
8
|
-
render: () => {
|
|
9
|
-
const [webviewState, setWebviewState] = useState({
|
|
10
|
-
lastUpdate: 0,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
const onMessage = (msg: JSONObject): void => {
|
|
14
|
-
if (msg.type === 'ping') {
|
|
15
|
-
const newState = { ...webviewState, lastUpdate: Date.now() };
|
|
16
|
-
setWebviewState(newState);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<vstack grow padding="small">
|
|
22
|
-
<text>WebView Content:</text>
|
|
23
|
-
<vstack border="thick" borderColor="black" grow>
|
|
24
|
-
<webview url="page.html" state={webviewState} onMessage={onMessage} grow />
|
|
25
|
-
</vstack>
|
|
26
|
-
<vstack grow padding="small">
|
|
27
|
-
<text size="small" alignment="middle center">
|
|
28
|
-
Your webview app is working.{' '}
|
|
29
|
-
</text>
|
|
30
|
-
<text size="small" alignment="middle center">
|
|
31
|
-
If you can't see the content of page.html, you likely need to get your app allow-listed
|
|
32
|
-
for the webview feature.
|
|
33
|
-
</text>
|
|
34
|
-
<text size="small" alignment="middle center">
|
|
35
|
-
Get in touch with Reddit admins via Discord to allow-list your app.{' '}
|
|
36
|
-
</text>
|
|
37
|
-
</vstack>
|
|
38
|
-
</vstack>
|
|
39
|
-
);
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
export default Devvit;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
5
|
-
<meta charset="UTF-8" />
|
|
6
|
-
<title>Webview Example</title>
|
|
7
|
-
<link rel="stylesheet" href="style.css" />
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<button>Ping</button>
|
|
11
|
-
<pre id="stateOutput"></pre>
|
|
12
|
-
<script type="application/javascript" src="script.js"></script>
|
|
13
|
-
</body>
|
|
14
|
-
</html>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
-
//@ts-nocheck
|
|
3
|
-
|
|
4
|
-
class App {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.state = {};
|
|
7
|
-
|
|
8
|
-
const output = document.querySelector('#stateOutput');
|
|
9
|
-
window.addEventListener('message', (ev) => {
|
|
10
|
-
const { type, data } = ev.data;
|
|
11
|
-
|
|
12
|
-
if (type === 'stateUpdate') {
|
|
13
|
-
output.replaceChildren(JSON.stringify(data, undefined, 2));
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
const pingButton = document.querySelector('button');
|
|
18
|
-
pingButton.addEventListener('click', () => {
|
|
19
|
-
window.parent?.postMessage({ type: 'ping' }, '*');
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
new App();
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
body {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
gap: 8px;
|
|
5
|
-
padding: 8px;
|
|
6
|
-
max-width: 100%;
|
|
7
|
-
max-height: 100%;
|
|
8
|
-
margin: 0;
|
|
9
|
-
box-sizing: border-box;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
#stateOutput {
|
|
13
|
-
border: 1px solid black;
|
|
14
|
-
overflow-y: auto;
|
|
15
|
-
flex-grow: 1;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
pre {
|
|
19
|
-
padding: 4px;
|
|
20
|
-
}
|