@mpgd/adapter-devvit 0.4.0 → 0.6.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/dist/web.js ADDED
@@ -0,0 +1,41 @@
1
+ import * as devvitWebClient from '@devvit/web/client';
2
+ import { startDevvitSurface, } from './surface.js';
3
+ // The Devvit package publishes browser implementations behind an export
4
+ // condition while its default declaration is a server-side panic module.
5
+ // Keep the narrow browser contract explicit until its default types expose it.
6
+ const browserClient = devvitWebClient;
7
+ export function startDevvitWebSurface(options) {
8
+ return startDevvitSurface({
9
+ ...options,
10
+ client: { getWebViewMode: browserClient.getWebViewMode },
11
+ });
12
+ }
13
+ export async function requestDevvitExpandedMode(event, entry) {
14
+ await browserClient.requestExpandedMode(event, entry);
15
+ }
16
+ /**
17
+ * Presents Devvit's native share surface without claiming that the user
18
+ * completed sharing. Devvit does not report a completion callback.
19
+ */
20
+ export async function presentDevvitShareSheet(options) {
21
+ try {
22
+ await browserClient.showShareSheet(options);
23
+ return {
24
+ status: 'shared',
25
+ completion: 'presented',
26
+ };
27
+ }
28
+ catch (error) {
29
+ if (isAbortError(error)) {
30
+ return { status: 'cancelled' };
31
+ }
32
+ return { status: 'unavailable' };
33
+ }
34
+ }
35
+ function isAbortError(error) {
36
+ return typeof DOMException !== 'undefined' && error instanceof DOMException
37
+ ? error.name === 'AbortError'
38
+ : typeof error === 'object'
39
+ && error !== null
40
+ && error.name === 'AbortError';
41
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpgd/adapter-devvit",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Reddit Devvit Web platform adapter for mpgd games.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,18 +28,32 @@
28
28
  ".": {
29
29
  "types": "./dist/index.d.ts",
30
30
  "default": "./dist/index.js"
31
+ },
32
+ "./server": {
33
+ "types": "./dist/server/index.d.ts",
34
+ "default": "./dist/server/index.js"
35
+ },
36
+ "./surface": {
37
+ "types": "./dist/surface.d.ts",
38
+ "default": "./dist/surface.js"
39
+ },
40
+ "./web": {
41
+ "types": "./dist/web.d.ts",
42
+ "default": "./dist/web.js"
31
43
  }
32
44
  },
33
45
  "files": [
34
46
  "dist"
35
47
  ],
36
48
  "dependencies": {
37
- "@mpgd/bridge": "0.5.0",
38
- "@mpgd/platform": "0.4.0"
49
+ "@devvit/web": "0.13.7",
50
+ "@mpgd/bridge": "0.6.0",
51
+ "@mpgd/platform": "0.5.1",
52
+ "@mpgd/game-services": "0.6.0"
39
53
  },
40
54
  "devDependencies": {
41
- "ttsc": "0.16.9",
42
- "typescript": "7.0.1-rc",
55
+ "ttsc": "0.18.4",
56
+ "typescript": "7.0.2",
43
57
  "vitest": "^4.0.0"
44
58
  },
45
59
  "main": "./dist/index.js",
@@ -52,6 +66,6 @@
52
66
  "lint": "ttsc --noEmit",
53
67
  "format": "ttsc format",
54
68
  "fix": "ttsc fix",
55
- "test": "vitest run"
69
+ "test": "vitest run && node test/server-dist-import.mjs && node --conditions=browser test/web-dist-import.mjs"
56
70
  }
57
71
  }