@devvit/cli 0.11.18 → 0.11.19-next-2025-07-01-15-23-37-e346f8ae5.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.
Files changed (52) hide show
  1. package/dist/util/package-managers/package-util.d.ts +3 -0
  2. package/dist/util/package-managers/package-util.d.ts.map +1 -1
  3. package/dist/util/project.d.ts.map +1 -1
  4. package/dist/util/project.js +21 -13
  5. package/dist/util/project.test.js +8 -7
  6. package/package.json +9 -10
  7. package/dist/templates/blocks-post/assets/logo.png +0 -0
  8. package/dist/templates/blocks-post/devvit.yaml +0 -1
  9. package/dist/templates/blocks-post/package.json +0 -13
  10. package/dist/templates/blocks-post/src/main.tsx +0 -58
  11. package/dist/templates/blocks-post/template-config.json +0 -4
  12. package/dist/templates/blocks-post/tsconfig.json +0 -3
  13. package/dist/templates/empty/devvit.yaml +0 -1
  14. package/dist/templates/empty/package.json +0 -13
  15. package/dist/templates/empty/src/main.tsx +0 -14
  16. package/dist/templates/empty/template-config.json +0 -4
  17. package/dist/templates/empty/tsconfig.json +0 -3
  18. package/dist/templates/payments/devvit.yaml +0 -1
  19. package/dist/templates/payments/package.json +0 -14
  20. package/dist/templates/payments/src/main.tsx +0 -134
  21. package/dist/templates/payments/src/products.json +0 -26
  22. package/dist/templates/payments/template-config.json +0 -4
  23. package/dist/templates/payments/tsconfig.json +0 -4
  24. package/dist/templates/payments-web-view/devvit.yaml +0 -1
  25. package/dist/templates/payments-web-view/package.json +0 -14
  26. package/dist/templates/payments-web-view/src/createPost.tsx +0 -23
  27. package/dist/templates/payments-web-view/src/main.tsx +0 -75
  28. package/dist/templates/payments-web-view/src/message.ts +0 -22
  29. package/dist/templates/payments-web-view/src/products.json +0 -13
  30. package/dist/templates/payments-web-view/template-config.json +0 -4
  31. package/dist/templates/payments-web-view/tsconfig.json +0 -7
  32. package/dist/templates/payments-web-view/webroot/page.html +0 -18
  33. package/dist/templates/payments-web-view/webroot/script.js +0 -62
  34. package/dist/templates/payments-web-view/webroot/style.css +0 -104
  35. package/dist/templates/pen/devvit.yaml +0 -1
  36. package/dist/templates/pen/package.json +0 -13
  37. package/dist/templates/pen/src/main.tsx +0 -46
  38. package/dist/templates/pen/template-config.json +0 -4
  39. package/dist/templates/pen/tsconfig.json +0 -3
  40. package/dist/templates/web-view-post/devvit.yaml +0 -1
  41. package/dist/templates/web-view-post/package.json +0 -13
  42. package/dist/templates/web-view-post/src/createPost.tsx +0 -23
  43. package/dist/templates/web-view-post/src/main.tsx +0 -99
  44. package/dist/templates/web-view-post/src/message.ts +0 -19
  45. package/dist/templates/web-view-post/template-config.json +0 -4
  46. package/dist/templates/web-view-post/tsconfig.json +0 -7
  47. package/dist/templates/web-view-post/webroot/page.html +0 -24
  48. package/dist/templates/web-view-post/webroot/script.js +0 -81
  49. package/dist/templates/web-view-post/webroot/style.css +0 -114
  50. package/dist/util/Bundler.test.d.ts +0 -2
  51. package/dist/util/Bundler.test.d.ts.map +0 -1
  52. package/dist/util/Bundler.test.js +0 -32
@@ -8,6 +8,9 @@ export type PackageJSON = {
8
8
  version?: string;
9
9
  dependencies?: DependencyMap;
10
10
  devDependencies?: DependencyMap;
11
+ scripts?: {
12
+ [name: string]: string;
13
+ };
11
14
  devvit?: DevvitPackageConfig;
12
15
  };
13
16
  /** Configuration provided in the `devvit` property of a project's package.json */
@@ -1 +1 @@
1
- {"version":3,"file":"package-util.d.ts","sourceRoot":"","sources":["../../../src/util/package-managers/package-util.ts"],"names":[],"mappings":"AAGA,KAAK,aAAa,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEhD,6BAA6B;AAC7B,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B,CAAC;AAGF,kFAAkF;AAClF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE;QACT,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH,CAAC;AAEF,iEAAiE;AACjE,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAGvE"}
1
+ {"version":3,"file":"package-util.d.ts","sourceRoot":"","sources":["../../../src/util/package-managers/package-util.ts"],"names":[],"mappings":"AAGA,KAAK,aAAa,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEhD,6BAA6B;AAC7B,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,OAAO,CAAC,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACrC,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B,CAAC;AAGF,kFAAkF;AAClF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE;QACT,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH,CAAC;AAEF,iEAAiE;AACjE,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAGvE"}
@@ -1 +1 @@
1
- {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/util/project.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,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new(root, filename, mode) {
37
37
  const config = await readConfig(root, filename);
38
- if (isAppConfig(config)) {
39
- const errs = validateConfig(config, existsSync, mode);
40
- if (errs.length)
41
- throw Error(errs.join('; '));
42
- }
43
38
  let packageJSON;
44
39
  try {
45
40
  packageJSON = await readPackageJSON(root);
@@ -47,6 +42,19 @@ export class Project {
47
42
  catch {
48
43
  // Failure is fine, it just means we don't have a config file (yet)
49
44
  }
45
+ if (isAppConfig(config)) {
46
+ const missingFiles = validateConfig(config, existsSync, mode);
47
+ // check if package.json has a build command
48
+ if (missingFiles.length) {
49
+ const containsBuildScript = Object.keys(packageJSON?.scripts ?? {}).some((script) => script.includes('build'));
50
+ let error = "Your devvit.json references files that don't exist: ";
51
+ error += missingFiles.join(', ');
52
+ if (containsBuildScript) {
53
+ error += `. You may need to run your build script to fix this.`;
54
+ }
55
+ throw Error(error);
56
+ }
57
+ }
50
58
  return new Project(root, filename, config, packageJSON?.devvit);
51
59
  }
52
60
  constructor(root, filename, config, packageConfig) {
@@ -170,29 +178,29 @@ async function readConfig(root, filename) {
170
178
  }
171
179
  /** @internal; */
172
180
  export function validateConfig(config, fileExists, mode) {
173
- const errs = [];
181
+ const missingFiles = [];
174
182
  if (config.blocks && !fileExists(config.blocks.entry))
175
- errs.push(`\`config.blocks.entry\` (${config.blocks.entry}) does not exist`);
183
+ missingFiles.push(`\`config.blocks.entry\` (${config.blocks.entry})`);
176
184
  if (config.media && !fileExists(config.media.dir))
177
- errs.push(`\`config.media.dir\` (${config.media.dir}) does not exist`);
185
+ missingFiles.push(`\`config.media.dir\` (${config.media.dir})`);
178
186
  if (config.post) {
179
187
  if (!fileExists(config.post.client.dir) && mode === 'Static')
180
- errs.push(`\`config.post.client.dir\` (${config.post.client.dir}) does not exist`);
188
+ missingFiles.push(`\`config.post.client.dir\` (${config.post.client.dir})`);
181
189
  if (config.post.client.entry.startsWith(apiPathPrefix) || mode === 'Dynamic') {
182
190
  // URL path or user is rebuilding regularly during playtest.
183
191
  }
184
192
  else if (!fileExists(config.post.client.entry))
185
- errs.push(`\`config.post.client.entry\` (${config.post.client.entry}) does not exist`);
193
+ missingFiles.push(`\`config.post.client.entry\` (${config.post.client.entry})`);
186
194
  else {
187
195
  const dir = path.resolve(config.post.client.dir);
188
196
  const entry = path.resolve(config.post.client.entry);
189
197
  if (!entry.startsWith(dir))
190
- errs.push(`\`config.post.client.entry\` (${config.post.client.entry}) must exist within \`config.post.client.dir\` (${config.post.client.dir})`);
198
+ missingFiles.push(`\`config.post.client.entry\` (${config.post.client.entry}) must exist within \`config.post.client.dir\` (${config.post.client.dir})`);
191
199
  }
192
200
  }
193
201
  if (config.server && !fileExists(config.server.entry) && mode === 'Static')
194
- errs.push(`\`config.server.entry\` (${config.server.entry}) does not exist`);
195
- return errs;
202
+ missingFiles.push(`\`config.server.entry\` (${config.server.entry})`);
203
+ return missingFiles;
196
204
  }
197
205
  function writeConfig(projectPath, configFile, config) {
198
206
  writeFileSync(path.join(projectPath, configFile), isAppConfig(config) ? JSON.stringify(config.json, undefined, 2) : dumpJsonToYaml(config));
@@ -4,10 +4,13 @@ import { isAppConfig, parseClassicConfig, Project, validateConfig, } from './pro
4
4
  const noPermissions = {
5
5
  http: { enable: false, allowedDomains: [] },
6
6
  media: false,
7
+ menu: false,
7
8
  payments: false,
8
9
  realtime: false,
9
10
  redis: false,
10
11
  reddit: { enable: false, scope: 'user', asUser: [] },
12
+ settings: false,
13
+ triggers: false,
11
14
  };
12
15
  describe('Project', () => {
13
16
  beforeEach(() => {
@@ -67,13 +70,13 @@ describe('validateConfig()', () => {
67
70
  for (const exists of [false, true])
68
71
  for (const mode of ['Static', 'Dynamic']) {
69
72
  const config = {
70
- blocks: { entry: 'entry', menu: { enable: true } },
73
+ blocks: { entry: 'entry' },
71
74
  schema: 'v1',
72
75
  name: 'name',
73
76
  permissions: noPermissions,
74
77
  json: { name: 'name' },
75
78
  };
76
- expect(validateConfig(config, () => exists, mode)).toStrictEqual(exists ? [] : ['`config.blocks.entry` (entry) does not exist']);
79
+ expect(validateConfig(config, () => exists, mode)).toStrictEqual(exists ? [] : ['`config.blocks.entry` (entry)']);
77
80
  }
78
81
  });
79
82
  test('post.client.dir', () => {
@@ -94,7 +97,7 @@ describe('validateConfig()', () => {
94
97
  },
95
98
  json: { name: 'name' },
96
99
  };
97
- expect(validateConfig(config, (filename) => (filename === 'dir' ? exists : true), mode)).toStrictEqual(exists || mode === 'Dynamic' ? [] : ['`config.post.client.dir` (dir) does not exist']);
100
+ expect(validateConfig(config, (filename) => (filename === 'dir' ? exists : true), mode)).toStrictEqual(exists || mode === 'Dynamic' ? [] : ['`config.post.client.dir` (dir)']);
98
101
  }
99
102
  });
100
103
  test('post.client.entry file', () => {
@@ -115,9 +118,7 @@ describe('validateConfig()', () => {
115
118
  },
116
119
  json: { name: 'name' },
117
120
  };
118
- expect(validateConfig(config, (filename) => (filename === 'dir/entry' ? exists : true), mode)).toStrictEqual(exists || mode === 'Dynamic'
119
- ? []
120
- : ['`config.post.client.entry` (dir/entry) does not exist']);
121
+ expect(validateConfig(config, (filename) => (filename === 'dir/entry' ? exists : true), mode)).toStrictEqual(exists || mode === 'Dynamic' ? [] : ['`config.post.client.entry` (dir/entry)']);
121
122
  }
122
123
  });
123
124
  test('post.client.entry API', () => {
@@ -148,7 +149,7 @@ describe('validateConfig()', () => {
148
149
  server: { entry: 'entry' },
149
150
  json: { name: 'name' },
150
151
  };
151
- expect(validateConfig(config, () => exists, mode)).toStrictEqual(exists || mode === 'Dynamic' ? [] : ['`config.server.entry` (entry) does not exist']);
152
+ expect(validateConfig(config, () => exists, mode)).toStrictEqual(exists || mode === 'Dynamic' ? [] : ['`config.server.entry` (entry)']);
152
153
  }
153
154
  });
154
155
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devvit/cli",
3
- "version": "0.11.18",
3
+ "version": "0.11.19-next-2025-07-01-15-23-37-e346f8ae5.0",
4
4
  "description": "Reddit's Dev Platform CLI Tool",
5
5
  "license": "BSD-3-Clause",
6
6
  "author": "@reddit/dev-platform",
@@ -23,8 +23,7 @@
23
23
  "dist"
24
24
  ],
25
25
  "scripts": {
26
- "build": "rm -rf dist && tsc && yarn build:copy",
27
- "build:copy": "rm -rf ./dist/templates; cp -a ./src/templates ./dist/templates",
26
+ "build": "rm -rf dist && tsc",
28
27
  "clean": "rm -rf .turbo coverage dist docs.json oclif.manifest.json",
29
28
  "clobber": "yarn clean && rm -rf node_modules",
30
29
  "dev": "tsc --watch",
@@ -42,11 +41,11 @@
42
41
  },
43
42
  "types": "dist/index.d.ts",
44
43
  "dependencies": {
45
- "@devvit/build-pack": "0.11.18",
44
+ "@devvit/build-pack": "0.11.19-next-2025-07-01-15-23-37-e346f8ae5.0",
46
45
  "@devvit/play": "0.0.45",
47
- "@devvit/protos": "0.11.18",
48
- "@devvit/public-api": "0.11.18",
49
- "@devvit/shared-types": "0.11.18",
46
+ "@devvit/protos": "0.11.19-next-2025-07-01-15-23-37-e346f8ae5.0",
47
+ "@devvit/public-api": "0.11.19-next-2025-07-01-15-23-37-e346f8ae5.0",
48
+ "@devvit/shared-types": "0.11.19-next-2025-07-01-15-23-37-e346f8ae5.0",
50
49
  "@improbable-eng/grpc-web": "0.15.0",
51
50
  "@improbable-eng/grpc-web-node-http-transport": "0.15.0",
52
51
  "@oclif/core": "2.9.4",
@@ -76,8 +75,8 @@
76
75
  "ws": "8.18.0"
77
76
  },
78
77
  "devDependencies": {
79
- "@devvit/repo-tools": "0.11.18",
80
- "@devvit/tsconfig": "0.11.18",
78
+ "@devvit/repo-tools": "0.11.19-next-2025-07-01-15-23-37-e346f8ae5.0",
79
+ "@devvit/tsconfig": "0.11.19-next-2025-07-01-15-23-37-e346f8ae5.0",
81
80
  "@types/file-type": "10.9.1",
82
81
  "@types/inquirer": "9.0.3",
83
82
  "@types/js-yaml": "4.0.5",
@@ -114,5 +113,5 @@
114
113
  ]
115
114
  }
116
115
  },
117
- "gitHead": "528a395e1d56da073194f98bd6eec9f073b4ae3a"
116
+ "gitHead": "0c1c5eabf8f3220f9b9227178cd631ec16a648de"
118
117
  }
@@ -1 +0,0 @@
1
- name: {{name}}
@@ -1,13 +0,0 @@
1
- {
2
- "private": true,
3
- "name": "experience-template",
4
- "version": "0.11.18-dev",
5
- "license": "BSD-3-Clause",
6
- "type": "module",
7
- "dependencies": {
8
- "@devvit/public-api": "0.11.18-dev"
9
- },
10
- "devDependencies": {
11
- "typescript": "5.8.3"
12
- }
13
- }
@@ -1,58 +0,0 @@
1
- // Learn more at developers.reddit.com/docs
2
- import { Devvit, useState } from '@devvit/public-api';
3
-
4
- Devvit.configure({
5
- redditAPI: true,
6
- });
7
-
8
- // Add a menu item to the subreddit menu for instantiating the new experience post
9
- Devvit.addMenuItem({
10
- label: 'Add my post',
11
- location: 'subreddit',
12
- forUserType: 'moderator',
13
- onPress: async (_event, context) => {
14
- const { reddit, ui } = context;
15
- ui.showToast("Submitting your post - upon completion you'll navigate there.");
16
-
17
- const subreddit = await reddit.getCurrentSubreddit();
18
- const post = await reddit.submitPost({
19
- title: 'My devvit post',
20
- subredditName: subreddit.name,
21
- // The preview appears while the post loads
22
- preview: (
23
- <vstack height="100%" width="100%" alignment="middle center">
24
- <text size="large">Loading ...</text>
25
- </vstack>
26
- ),
27
- });
28
- ui.navigateTo(post);
29
- },
30
- });
31
-
32
- // Add a post type definition
33
- Devvit.addCustomPostType({
34
- name: 'Experience Post',
35
- height: 'regular',
36
- render: (_context) => {
37
- const [counter, setCounter] = useState(0);
38
-
39
- return (
40
- <vstack height="100%" width="100%" gap="medium" alignment="center middle">
41
- <image
42
- url="logo.png"
43
- description="logo"
44
- imageHeight={256}
45
- imageWidth={256}
46
- height="48px"
47
- width="48px"
48
- />
49
- <text size="large">{`Click counter: ${counter}`}</text>
50
- <button appearance="primary" onPress={() => setCounter((counter) => counter + 1)}>
51
- Click me!
52
- </button>
53
- </vstack>
54
- );
55
- },
56
- });
57
-
58
- export default Devvit;
@@ -1,4 +0,0 @@
1
- {
2
- "description": "Create an experience using blocks.",
3
- "hidden": false
4
- }
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@devvit/public-api/devvit.tsconfig.json"
3
- }
@@ -1 +0,0 @@
1
- name: {{name}}
@@ -1,13 +0,0 @@
1
- {
2
- "private": true,
3
- "name": "empty-template",
4
- "version": "0.11.18-dev",
5
- "license": "BSD-3-Clause",
6
- "type": "module",
7
- "dependencies": {
8
- "@devvit/public-api": "0.11.18-dev"
9
- },
10
- "devDependencies": {
11
- "typescript": "5.8.3"
12
- }
13
- }
@@ -1,14 +0,0 @@
1
- // Visit developers.reddit.com/docs to learn Devvit!
2
-
3
- import { Devvit } from '@devvit/public-api';
4
-
5
- Devvit.addMenuItem({
6
- location: 'post',
7
- label: 'Hello World',
8
- onPress: (event, context) => {
9
- console.log(`Pressed ${event.targetId}`);
10
- context.ui.showToast('Hello world!');
11
- },
12
- });
13
-
14
- export default Devvit;
@@ -1,4 +0,0 @@
1
- {
2
- "description": "Start with a blank canvas to build your own app.",
3
- "hidden": false
4
- }
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "@devvit/public-api/devvit.tsconfig.json"
3
- }
@@ -1 +0,0 @@
1
- name: {{name}}
@@ -1,14 +0,0 @@
1
- {
2
- "private": true,
3
- "name": "payment-template",
4
- "version": "0.11.18-dev",
5
- "license": "BSD-3-Clause",
6
- "type": "module",
7
- "dependencies": {
8
- "@devvit/payments": "0.11.18-dev",
9
- "@devvit/public-api": "0.11.18-dev"
10
- },
11
- "devDependencies": {
12
- "typescript": "5.8.3"
13
- }
14
- }
@@ -1,134 +0,0 @@
1
- import {
2
- addPaymentHandler,
3
- getOrders,
4
- type OnPurchaseResult,
5
- OrderResultStatus,
6
- usePayments,
7
- useProducts,
8
- } from '@devvit/payments';
9
- import { ProductButton } from '@devvit/payments/helpers/ProductButton';
10
- import { Devvit, useState } from '@devvit/public-api';
11
-
12
- Devvit.configure({
13
- redis: true,
14
- redditAPI: true,
15
- });
16
-
17
- const GOD_MODE_SKU = 'god_mode';
18
-
19
- addPaymentHandler({
20
- fulfillOrder: async (order, ctx) => {
21
- if (!order.products.some(({ sku }) => sku === GOD_MODE_SKU)) {
22
- throw new Error('Unable to fulfill order: sku not found');
23
- }
24
- if (order.status !== 'PAID') {
25
- throw new Error('Becoming a god has a cost (in Reddit Gold)');
26
- }
27
- const redisKey = godModeRedisKey(ctx.postId, ctx.userId);
28
- await ctx.redis.set(redisKey, 'true');
29
- },
30
- refundOrder: async (order, ctx) => {
31
- if (order.products.some(({ sku }) => sku === GOD_MODE_SKU)) {
32
- await ctx.redis.set(godModeRedisKey(ctx.postId, ctx.userId), 'false');
33
- }
34
- },
35
- });
36
-
37
- const App: Devvit.CustomPostComponent = (context) => {
38
- // Updates current state in redis.
39
- const [godModeEnabled, setGodMode] = useState(async () => {
40
- const state = await context.redis.get(godModeRedisKey(context.postId, context.userId));
41
- return JSON.parse(state || 'false');
42
- });
43
-
44
- const [orderCount, setOrderCount] = useState(async () => {
45
- const orders = await getOrders();
46
- return orders.orders.length;
47
- });
48
-
49
- // Only grab products with the category "powerup".
50
- const { products } = useProducts(context, {
51
- metadata: {
52
- category: 'powerup',
53
- },
54
- });
55
-
56
- // Client side code invoked after a purchase is made. This should be used to update
57
- // app state based on orders.
58
- const payments = usePayments((result: OnPurchaseResult) => {
59
- if (result.status === OrderResultStatus.Success) {
60
- setGodMode(true);
61
- setOrderCount((count: number) => count + 1);
62
- }
63
- });
64
-
65
- const clearGodModeFn = async () => {
66
- await context.redis.set(godModeRedisKey(context.userId), false.toString());
67
- setGodMode(false);
68
- };
69
-
70
- return (
71
- <vstack alignment="center middle" height={100} gap="medium" padding="large">
72
- <text size="large">Has god mode been enabled: {godModeEnabled}</text>
73
- {godModeEnabled && (
74
- <button width={75} onPress={() => clearGodModeFn()}>
75
- I tire of being a god - return me to the mortal coil.
76
- </button>
77
- )}
78
-
79
- <text size="large">
80
- There have been {orderCount} orders placed across all users of this app in this subreddit.
81
- </text>
82
- <vstack>
83
- Products:
84
- {products.map((product) => (
85
- <ProductButton
86
- product={product}
87
- appearance="detailed"
88
- onPress={(p) => {
89
- payments.purchase(p.sku);
90
- }}
91
- />
92
- ))}
93
- </vstack>
94
- </vstack>
95
- );
96
- };
97
-
98
- Devvit.addCustomPostType({
99
- name: 'Example of offering items for sale.',
100
- render: App,
101
- });
102
-
103
- Devvit.addMenuItem({
104
- location: 'subreddit',
105
- label: 'Create a post to show off how purchasing works.',
106
- onPress: async (_, context) => {
107
- const { reddit, ui } = context;
108
- ui.showToast("Submitting your post - upon completion you'll navigate there.");
109
-
110
- const currentSubreddit = context.subredditName;
111
- if (currentSubreddit !== undefined) {
112
- const newPost = await reddit.submitPost({
113
- title: 'Example Purchase Post',
114
- subredditName: currentSubreddit,
115
- preview: (
116
- <vstack padding="medium" cornerRadius="medium">
117
- <text style="heading" size="medium">
118
- Loading a hand-crafted custom app…
119
- </text>
120
- </vstack>
121
- ),
122
- });
123
- ui.navigateTo(newPost);
124
- } else {
125
- ui.showToast('Failed to create post - subreddit not defined.');
126
- }
127
- },
128
- });
129
-
130
- function godModeRedisKey(postId: string | undefined, userId?: string | undefined): string {
131
- return `god_mode:${postId}:${userId}`;
132
- }
133
-
134
- export default Devvit;
@@ -1,26 +0,0 @@
1
- {
2
- "$schema": "https://developers.reddit.com/schema/products.json",
3
- "products": [
4
- {
5
- "sku": "god_mode",
6
- "displayName": "God mode",
7
- "description": "God mode gives you superpowers (in theory)",
8
- "price": 25,
9
- "metadata": {
10
- "category": "powerup"
11
- },
12
- "accountingType": "CONSUMABLE"
13
- },
14
- {
15
- "sku": "other_sku",
16
- "displayName": "Secret product",
17
- "description": "A secret product.",
18
- "price": 2500,
19
- "metadata": {
20
- "category": "secret"
21
- },
22
- "accountingType": "CONSUMABLE"
23
- }
24
- ]
25
- }
26
-
@@ -1,4 +0,0 @@
1
- {
2
- "description": "Add payments to enhance your app.",
3
- "hidden": false
4
- }
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "@devvit/public-api/devvit.tsconfig.json"
3
- }
4
-
@@ -1 +0,0 @@
1
- name: {{name}}
@@ -1,14 +0,0 @@
1
- {
2
- "private": true,
3
- "name": "payments-web-view-template",
4
- "version": "0.11.18-dev",
5
- "license": "BSD-3-Clause",
6
- "type": "module",
7
- "dependencies": {
8
- "@devvit/payments": "0.11.18-dev",
9
- "@devvit/public-api": "0.11.18-dev"
10
- },
11
- "devDependencies": {
12
- "typescript": "5.8.3"
13
- }
14
- }
@@ -1,23 +0,0 @@
1
- import { Devvit } from '@devvit/public-api';
2
-
3
- // Adds a new menu item to the subreddit allowing to create a new post
4
- Devvit.addMenuItem({
5
- label: 'Create New Devvit Post (with Payments and Web View)',
6
- location: 'subreddit',
7
- onPress: async (_event, context) => {
8
- const { reddit, ui } = context;
9
- const subreddit = await reddit.getCurrentSubreddit();
10
- const post = await reddit.submitPost({
11
- title: 'Payments + Web View Example',
12
- subredditName: subreddit.name,
13
- // The preview appears while the post loads
14
- preview: (
15
- <vstack height="100%" width="100%" alignment="middle center">
16
- <text size="large">Loading ...</text>
17
- </vstack>
18
- ),
19
- });
20
- ui.showToast({ text: 'Created post!' });
21
- ui.navigateTo(post);
22
- },
23
- });
@@ -1,75 +0,0 @@
1
- import './createPost.js';
2
-
3
- import {
4
- addPaymentHandler,
5
- type OnPurchaseResult,
6
- OrderResultStatus,
7
- usePayments,
8
- } from '@devvit/payments';
9
- import { Devvit, useWebView } from '@devvit/public-api';
10
-
11
- import type { DevvitMessage, WebViewMessage } from './message.js';
12
-
13
- Devvit.configure({
14
- redditAPI: true,
15
- redis: true,
16
- });
17
-
18
- // Generally, use this to accept/reject purchases and/or update persistent
19
- // state to take into account the purchase.
20
- // In this example it is fine for it to be empty.
21
- // When a user performs a purchase, fulfillOrder will be called.
22
- // After which, the lambda given to usePayments will be called,
23
- // which actually results in the UI changing.
24
- addPaymentHandler({
25
- fulfillOrder() {},
26
- });
27
-
28
- // Add a custom post type to Devvit
29
- Devvit.addCustomPostType({
30
- name: 'Payments + Web View Example',
31
- height: 'tall',
32
- render: () => {
33
- // Create UsePayments hook.
34
- const payments = usePayments((result: OnPurchaseResult) => {
35
- // When a successful purchase is made, send a message to the webview
36
- // for it to update its UI.
37
- if (result.status === OrderResultStatus.Success) {
38
- webView.postMessage({
39
- type: 'purchaseMade',
40
- data: {},
41
- });
42
- }
43
- });
44
- // Create webview
45
- const webView = useWebView<WebViewMessage, DevvitMessage>({
46
- url: 'page.html',
47
- async onMessage(message) {
48
- if (message.type === 'purchase') {
49
- // When a message is sent from the webview with the type 'purchase'
50
- // trigger a purchase. This will result in a modal being presented
51
- // to the user to confirm they want to purchase the item with the
52
- // specified SKU. Their action on that modal will result in
53
- // "fulfill order" being triggered.
54
- payments.purchase(message.data.sku);
55
- } else {
56
- throw new Error(`Unknown message type: ${message.type}`);
57
- }
58
- },
59
- });
60
-
61
- // Render the custom post type
62
- return (
63
- <vstack grow padding="small">
64
- <vstack grow alignment="middle center">
65
- <text size="xlarge" weight="bold">
66
- Payments on WebView Example App
67
- </text>
68
- <button onPress={() => webView.mount()}>Launch App</button>
69
- </vstack>
70
- </vstack>
71
- );
72
- },
73
- });
74
-
75
- export default Devvit;