@devvit/shared-types 0.12.0-next-2025-04-30-5d2b49b36.0 → 0.12.0-next-2025-08-12-20-06-14-50f19bb3e.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/AdsMetadata.d.ts +6 -0
- package/AdsMetadata.d.ts.map +1 -0
- package/AdsMetadata.js +5 -0
- package/Assets.d.ts +0 -2
- package/Assets.d.ts.map +1 -1
- package/Assets.js +0 -2
- package/CircuitBreaker.d.ts.map +1 -1
- package/Config.d.ts +3 -3
- package/Config.d.ts.map +1 -1
- package/ConfigImpl.d.ts +8 -8
- package/ConfigImpl.d.ts.map +1 -1
- package/ConfigImpl.js +22 -31
- package/Header.d.ts +1 -0
- package/Header.d.ts.map +1 -1
- package/Header.js +1 -0
- package/PostData.d.ts +8 -0
- package/PostData.d.ts.map +1 -0
- package/ProjectTemplateInfo.d.ts +21 -0
- package/ProjectTemplateInfo.d.ts.map +1 -0
- package/ProjectTemplateInfo.js +10 -0
- package/client/emit-effect.d.ts +24 -0
- package/client/emit-effect.d.ts.map +1 -0
- package/client/emit-effect.js +56 -0
- package/client/emit-effect.test.d.ts.map +1 -0
- package/client/share.d.ts +3 -0
- package/client/share.d.ts.map +1 -0
- package/client/share.js +2 -0
- package/constants.d.ts +9 -0
- package/constants.d.ts.map +1 -1
- package/constants.js +9 -0
- package/fetch-domains.d.ts +14 -0
- package/fetch-domains.d.ts.map +1 -0
- package/fetch-domains.js +42 -0
- package/fetch-domains.test.d.ts.map +1 -0
- package/isDevvitDependency.js +1 -1
- package/json.d.ts +12 -12
- package/package.json +18 -13
- package/richtext/index.d.ts +6 -0
- package/richtext/index.d.ts.map +1 -0
- package/richtext/index.js +1 -0
- package/schemas/config-file.v1.d.ts +272 -0
- package/schemas/config-file.v1.d.ts.map +1 -0
- package/schemas/config-file.v1.js +254 -0
- package/schemas/config-file.v1.json +683 -0
- package/schemas/config-file.v1.test.d.ts.map +1 -0
- package/schemas/constants.d.ts +4 -0
- package/schemas/constants.d.ts.map +1 -0
- package/schemas/constants.js +3 -0
- package/{payments/products.schema.json → schemas/products.json} +1 -1
- package/{payments/productSchemaJSONValidator.d.ts → schemas/productsSchemaJSONValidator.d.ts} +2 -2
- package/schemas/productsSchemaJSONValidator.d.ts.map +1 -0
- package/{payments/productSchemaJSONValidator.js → schemas/productsSchemaJSONValidator.js} +1 -1
- package/schemas/productsSchemaJSONValidator.test.d.ts.map +1 -0
- package/server/get-devvit-config.d.ts +7 -0
- package/server/get-devvit-config.d.ts.map +1 -0
- package/server/get-devvit-config.js +10 -0
- package/shared/devvit-worker-global.d.ts +47 -0
- package/shared/devvit-worker-global.d.ts.map +1 -0
- package/shared/devvit-worker-global.js +7 -0
- package/{forms/types.d.ts → shared/form.d.ts} +16 -72
- package/shared/form.d.ts.map +1 -0
- package/tid.d.ts +26 -32
- package/tid.d.ts.map +1 -1
- package/tid.js +43 -62
- package/web-view-scripts-constants.d.ts +14 -0
- package/web-view-scripts-constants.d.ts.map +1 -0
- package/web-view-scripts-constants.js +13 -0
- package/forms/assertValidFormFields.d.ts +0 -11
- package/forms/assertValidFormFields.d.ts.map +0 -1
- package/forms/assertValidFormFields.js +0 -29
- package/forms/assertValidFormFields.test.d.ts.map +0 -1
- package/forms/getFormValues.d.ts +0 -6
- package/forms/getFormValues.d.ts.map +0 -1
- package/forms/getFormValues.js +0 -31
- package/forms/getFormValues.test.d.ts.map +0 -1
- package/forms/transformForm.d.ts +0 -4
- package/forms/transformForm.d.ts.map +0 -1
- package/forms/transformForm.js +0 -141
- package/forms/transformForm.test.d.ts.map +0 -1
- package/forms/types.d.ts.map +0 -1
- package/index.d.ts +0 -2
- package/index.d.ts.map +0 -1
- package/payments/index.d.ts +0 -4
- package/payments/index.d.ts.map +0 -1
- package/payments/index.js +0 -3
- package/payments/productSchemaJSONValidator.d.ts.map +0 -1
- package/payments/productSchemaJSONValidator.test.d.ts.map +0 -1
- /package/{index.js → PostData.js} +0 -0
- /package/{forms/types.js → shared/form.js} +0 -0
package/AdsMetadata.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdsMetadata.d.ts","sourceRoot":"","sources":["../src/AdsMetadata.ts"],"names":[],"mappings":"AAAA;;;KAGK;AAEL,MAAM,MAAM,WAAW,GAAG,EAEzB,CAAC"}
|
package/AdsMetadata.js
ADDED
package/Assets.d.ts
CHANGED
|
@@ -12,8 +12,6 @@
|
|
|
12
12
|
export type AssetMap = {
|
|
13
13
|
[path: string]: string;
|
|
14
14
|
};
|
|
15
|
-
export declare const ASSET_DIRNAME = "assets";
|
|
16
|
-
export declare const WEB_VIEW_ASSET_DIRNAME = "webroot";
|
|
17
15
|
export declare const ALLOWED_ASSET_EXTENSIONS: string[];
|
|
18
16
|
export declare const KILOBYTE = 1024;
|
|
19
17
|
export declare const MEGABYTE: number;
|
package/Assets.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Assets.d.ts","sourceRoot":"","sources":["../src/Assets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,QAAQ,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"Assets.d.ts","sourceRoot":"","sources":["../src/Assets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,QAAQ,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAKlD,eAAO,MAAM,wBAAwB,UAA6C,CAAC;AAEnF,eAAO,MAAM,QAAQ,OAAO,CAAC;AAC7B,eAAO,MAAM,QAAQ,QAAsB,CAAC;AAC5C,eAAO,MAAM,QAAQ,QAAsB,CAAC;AAC5C,eAAO,MAAM,2BAA2B,QAAW,CAAC;AACpD,eAAO,MAAM,kBAAkB,QAAgB,CAAC;AAChD,eAAO,MAAM,sBAAsB,QAAgB,CAAC;AAEpD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAYrD"}
|
package/Assets.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export const ASSET_DIRNAME = 'assets';
|
|
2
|
-
export const WEB_VIEW_ASSET_DIRNAME = 'webroot';
|
|
3
1
|
// List of allowed asset extensions. Note that this should not be used as definitive proof that
|
|
4
2
|
// an asset is valid, as it is possible to spoof the extension of a file. This is just a quick
|
|
5
3
|
// check to make sure the file is probably an image.
|
package/CircuitBreaker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CircuitBreaker.d.ts","sourceRoot":"","sources":["../src/CircuitBreaker.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,MAAM,MAAM,iBAAiB,GAAG;IAC9B,+DAA+D;IAC/D,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,CAAC;AAGF,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"CircuitBreaker.d.ts","sourceRoot":"","sources":["../src/CircuitBreaker.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,MAAM,MAAM,iBAAiB,GAAG;IAC9B,+DAA+D;IAC/D,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,CAAC;AAGF,eAAO,MAAM,mBAAmB,EAAU,oBAAoB,CAAC;AAG/D,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,CAO9D;AAED,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,SAAkB,KAAK,EAAE,iBAAiB,CAAC;gBAE/B,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,iBAAiB;CAMxD;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,KAAK,GAAG,sBAAsB,GAAG,OAAO,GAC5C,GAAG,IAAI,sBAAsB,CAE/B"}
|
package/Config.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Definition } from '@devvit/protos/lib/Types.js';
|
|
2
|
-
import type { DependencySpec,
|
|
2
|
+
import type { DependencySpec, Permissions } from '@devvit/protos/types/devvit/runtime/bundle.js';
|
|
3
3
|
import type { AssetMap } from './Assets.js';
|
|
4
|
-
import type { DeepPartial } from './BuiltinTypes.js';
|
|
5
4
|
import type { Namespace } from './Namespace.js';
|
|
6
5
|
/**
|
|
7
6
|
* Bundle configuration for code about to be built (eg, dependencies). All
|
|
@@ -17,12 +16,13 @@ export type Config = {
|
|
|
17
16
|
readonly webviewAssets?: Readonly<AssetMap> | undefined;
|
|
18
17
|
export(namespace: Readonly<Namespace>): DependencySpec;
|
|
19
18
|
provides(definition: Readonly<Definition>): void;
|
|
20
|
-
use<T>(definition: Readonly<Definition
|
|
19
|
+
use<T>(definition: Readonly<Definition>): T;
|
|
21
20
|
/**
|
|
22
21
|
* Check if a previous call to `use` was made. This is useful for allowing polyfills
|
|
23
22
|
* to ensure that they can provide functionality in terms of a plugin, or fallback to
|
|
24
23
|
* default functionality if not
|
|
25
24
|
*/
|
|
26
25
|
uses(definition: Readonly<Definition>): boolean;
|
|
26
|
+
addPermissions?(permissions: Readonly<Permissions>): void;
|
|
27
27
|
};
|
|
28
28
|
//# sourceMappingURL=Config.d.ts.map
|
package/Config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../src/Config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../src/Config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAEjG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAEpC,QAAQ,CAAC,mBAAmB,EAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;IACrD,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;IAExD,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,cAAc,CAAC;IAEvD,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAEjD,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAE5C;;;;OAIG;IACH,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC;IAEhD,cAAc,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;CAC3D,CAAC"}
|
package/ConfigImpl.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { Definition } from '@devvit/protos/lib/Types.js';
|
|
2
|
-
import { ActorSpec, DependencySpec,
|
|
2
|
+
import { ActorSpec, DependencySpec, Permissions } from '@devvit/protos/types/devvit/runtime/bundle.js';
|
|
3
3
|
import type { AssetMap } from './Assets.js';
|
|
4
|
-
import type { DeepPartial } from './BuiltinTypes.js';
|
|
5
4
|
import type { Config } from './Config.js';
|
|
6
5
|
import type { Namespace } from './Namespace.js';
|
|
7
6
|
export type ClientFactory = {
|
|
8
|
-
Build<T>(desc: Definition
|
|
7
|
+
Build<T>(desc: Definition): T;
|
|
9
8
|
};
|
|
10
9
|
export declare class ConfigImpl implements Config {
|
|
11
10
|
#private;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
constructor(factory: ClientFactory, actorSpec: ActorSpec, assets: AssetMap, webviewAssets: AssetMap);
|
|
11
|
+
readonly assets: Readonly<AssetMap>;
|
|
12
|
+
readonly webviewAssets: Readonly<AssetMap>;
|
|
13
|
+
constructor(factory: ClientFactory, actorSpec: ActorSpec, assets: AssetMap, webViewAssets: AssetMap);
|
|
16
14
|
export(namespace: Readonly<Namespace>): DependencySpec;
|
|
15
|
+
get providedDefinitions(): Readonly<Definition>[];
|
|
17
16
|
provides(definition: Readonly<Definition>): void;
|
|
18
|
-
|
|
17
|
+
addPermissions(permissions: Readonly<Permissions>): void;
|
|
18
|
+
use<T>(definition: Readonly<Definition>): T;
|
|
19
19
|
uses(definition: Readonly<Definition>): boolean;
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=ConfigImpl.d.ts.map
|
package/ConfigImpl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigImpl.d.ts","sourceRoot":"","sources":["../src/ConfigImpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EACL,SAAS,EACT,cAAc,
|
|
1
|
+
{"version":3,"file":"ConfigImpl.d.ts","sourceRoot":"","sources":["../src/ConfigImpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EACL,SAAS,EACT,cAAc,EAEd,WAAW,EACZ,MAAM,+CAA+C,CAAC;AAEvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,GAAG,CAAC,CAAC;CAC/B,CAAC;AAEF,qBAAa,UAAW,YAAW,MAAM;;IACvC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBAUzC,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,QAAQ,EAChB,aAAa,EAAE,QAAQ;IAUzB,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,cAAc;IAgBtD,IAAI,mBAAmB,IAAI,QAAQ,CAAC,UAAU,CAAC,EAAE,CAEhD;IAED,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,IAAI;IAIhD,cAAc,CAAC,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI;IAIxD,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;IAM3C,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,OAAO;CAWhD"}
|
package/ConfigImpl.js
CHANGED
|
@@ -1,30 +1,21 @@
|
|
|
1
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
1
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
2
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
3
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
4
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
5
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
6
|
};
|
|
12
|
-
var
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _ConfigImpl_instances, _ConfigImpl_factory, _ConfigImpl_name, _ConfigImpl_owner, _ConfigImpl_provides, _ConfigImpl_useQueries, _ConfigImpl_version, _ConfigImpl_permissions, _ConfigImpl_newActorSpec;
|
|
13
13
|
import { Definition } from '@devvit/protos/lib/Types.js';
|
|
14
|
-
import { ActorSpec, DependencySpec, PackageQuery, } from '@devvit/protos/types/devvit/runtime/bundle.js';
|
|
14
|
+
import { ActorSpec, DependencySpec, PackageQuery, Permissions, } from '@devvit/protos/types/devvit/runtime/bundle.js';
|
|
15
15
|
import { PLUGIN_NAME, resolveActorHostname } from './HostnameUtil.js';
|
|
16
16
|
import { NonNull } from './NonNull.js';
|
|
17
17
|
export class ConfigImpl {
|
|
18
|
-
|
|
19
|
-
return __classPrivateFieldGet(this, _ConfigImpl_assets, "f");
|
|
20
|
-
}
|
|
21
|
-
get webviewAssets() {
|
|
22
|
-
return __classPrivateFieldGet(this, _ConfigImpl_webviewAssets, "f");
|
|
23
|
-
}
|
|
24
|
-
get providedDefinitions() {
|
|
25
|
-
return __classPrivateFieldGet(this, _ConfigImpl_provides, "f");
|
|
26
|
-
}
|
|
27
|
-
constructor(factory, actorSpec, assets, webviewAssets) {
|
|
18
|
+
constructor(factory, actorSpec, assets, webViewAssets) {
|
|
28
19
|
_ConfigImpl_instances.add(this);
|
|
29
20
|
_ConfigImpl_factory.set(this, void 0);
|
|
30
21
|
_ConfigImpl_name.set(this, void 0);
|
|
@@ -32,14 +23,13 @@ export class ConfigImpl {
|
|
|
32
23
|
_ConfigImpl_provides.set(this, []);
|
|
33
24
|
_ConfigImpl_useQueries.set(this, []);
|
|
34
25
|
_ConfigImpl_version.set(this, void 0);
|
|
35
|
-
|
|
36
|
-
_ConfigImpl_webviewAssets.set(this, void 0);
|
|
26
|
+
_ConfigImpl_permissions.set(this, []);
|
|
37
27
|
__classPrivateFieldSet(this, _ConfigImpl_factory, factory, "f");
|
|
38
28
|
__classPrivateFieldSet(this, _ConfigImpl_name, actorSpec.name, "f");
|
|
39
29
|
__classPrivateFieldSet(this, _ConfigImpl_owner, actorSpec.owner, "f");
|
|
40
30
|
__classPrivateFieldSet(this, _ConfigImpl_version, actorSpec.version, "f");
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
this.assets = Object.freeze(assets);
|
|
32
|
+
this.webviewAssets = Object.freeze(webViewAssets);
|
|
43
33
|
}
|
|
44
34
|
export(namespace) {
|
|
45
35
|
return {
|
|
@@ -53,27 +43,28 @@ export class ConfigImpl {
|
|
|
53
43
|
};
|
|
54
44
|
}),
|
|
55
45
|
uses: __classPrivateFieldGet(this, _ConfigImpl_useQueries, "f"),
|
|
46
|
+
permissions: __classPrivateFieldGet(this, _ConfigImpl_permissions, "f"),
|
|
56
47
|
};
|
|
57
48
|
}
|
|
49
|
+
get providedDefinitions() {
|
|
50
|
+
return __classPrivateFieldGet(this, _ConfigImpl_provides, "f");
|
|
51
|
+
}
|
|
58
52
|
provides(definition) {
|
|
59
53
|
__classPrivateFieldGet(this, _ConfigImpl_provides, "f").push(definition);
|
|
60
54
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
versions: options.versions,
|
|
67
|
-
typeName: definition.fullName,
|
|
68
|
-
};
|
|
55
|
+
addPermissions(permissions) {
|
|
56
|
+
__classPrivateFieldGet(this, _ConfigImpl_permissions, "f").push(permissions);
|
|
57
|
+
}
|
|
58
|
+
use(definition) {
|
|
59
|
+
const query = { name: PLUGIN_NAME, typeName: definition.fullName };
|
|
69
60
|
__classPrivateFieldGet(this, _ConfigImpl_useQueries, "f").push(query);
|
|
70
|
-
return __classPrivateFieldGet(this, _ConfigImpl_factory, "f").Build(definition
|
|
61
|
+
return __classPrivateFieldGet(this, _ConfigImpl_factory, "f").Build(definition);
|
|
71
62
|
}
|
|
72
63
|
uses(definition) {
|
|
73
64
|
return __classPrivateFieldGet(this, _ConfigImpl_useQueries, "f").some((query) => query.typeName === definition.fullName);
|
|
74
65
|
}
|
|
75
66
|
}
|
|
76
|
-
_ConfigImpl_factory = new WeakMap(), _ConfigImpl_name = new WeakMap(), _ConfigImpl_owner = new WeakMap(), _ConfigImpl_provides = new WeakMap(), _ConfigImpl_useQueries = new WeakMap(), _ConfigImpl_version = new WeakMap(),
|
|
67
|
+
_ConfigImpl_factory = new WeakMap(), _ConfigImpl_name = new WeakMap(), _ConfigImpl_owner = new WeakMap(), _ConfigImpl_provides = new WeakMap(), _ConfigImpl_useQueries = new WeakMap(), _ConfigImpl_version = new WeakMap(), _ConfigImpl_permissions = new WeakMap(), _ConfigImpl_instances = new WeakSet(), _ConfigImpl_newActorSpec = function _ConfigImpl_newActorSpec() {
|
|
77
68
|
return {
|
|
78
69
|
name: __classPrivateFieldGet(this, _ConfigImpl_name, "f") ?? '',
|
|
79
70
|
owner: __classPrivateFieldGet(this, _ConfigImpl_owner, "f") ?? '',
|
package/Header.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare const Header: Readonly<{
|
|
|
17
17
|
ModPermissions: "devvit-mod-permissions";
|
|
18
18
|
Post: "devvit-post";
|
|
19
19
|
PostAuthor: "devvit-post-author";
|
|
20
|
+
PostData: "devvit-post-data";
|
|
20
21
|
R2Auth: "devvit-sec-authorization";
|
|
21
22
|
R2Host: "devvit-r2-host";
|
|
22
23
|
RemoteHostname: "devvit-remote-hostname";
|
package/Header.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../src/Header.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../src/Header.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCjB,CAAC;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC;AAE1D,kDAAkD;AAClD,eAAO,MAAM,YAAY,EAAE,MAAkB,CAAC;AAE9C,6CAA6C;AAC7C,0BAAkB,QAAQ;IACxB,uCAAuC;IACvC,MAAM,WAAW;IACjB;;;;OAIG;IACH,aAAa,kBAAkB;IAC/B,6BAA6B;IAC7B,SAAS,cAAc;IACvB,+DAA+D;IAC/D,QAAQ,aAAa;IACrB,6CAA6C;IAC7C,OAAO,YAAY;IACnB,8DAA8D;IAC9D,OAAO,YAAY;IACnB,2DAA2D;IAC3D,QAAQ,aAAa;IACrB,6CAA6C;IAC7C,QAAQ,aAAa;IACrB,+BAA+B;IAC/B,SAAS,cAAc;IACvB,yBAAyB;IACzB,OAAO,YAAY;CACpB"}
|
package/Header.js
CHANGED
|
@@ -17,6 +17,7 @@ export const Header = Object.freeze({
|
|
|
17
17
|
ModPermissions: 'devvit-mod-permissions',
|
|
18
18
|
Post: 'devvit-post',
|
|
19
19
|
PostAuthor: 'devvit-post-author',
|
|
20
|
+
PostData: 'devvit-post-data',
|
|
20
21
|
R2Auth: 'devvit-sec-authorization',
|
|
21
22
|
R2Host: 'devvit-r2-host',
|
|
22
23
|
RemoteHostname: 'devvit-remote-hostname',
|
package/PostData.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { JsonObject } from './json.js';
|
|
2
|
+
/**
|
|
3
|
+
* Post data included in the current post.
|
|
4
|
+
* This data is set at custom Post creation via `submitPost({ postData: {...} })` and can be updated via `Post.setPostData({...})`.
|
|
5
|
+
* If there is no post data specified, the value is undefined.
|
|
6
|
+
*/
|
|
7
|
+
export type PostData = JsonObject;
|
|
8
|
+
//# sourceMappingURL=PostData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostData.d.ts","sourceRoot":"","sources":["../src/PostData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type ProjectTemplateInfo = {
|
|
2
|
+
name: string;
|
|
3
|
+
shortName: string;
|
|
4
|
+
description: string;
|
|
5
|
+
url: string;
|
|
6
|
+
/** Optional field to hide the template from all listings */
|
|
7
|
+
hidden?: boolean;
|
|
8
|
+
overrides?: {
|
|
9
|
+
[key in ProjectTemplateOverrides]?: Partial<Omit<ProjectTemplateInfo, 'overrides'>>;
|
|
10
|
+
};
|
|
11
|
+
category?: ProjectTemplateCategory;
|
|
12
|
+
};
|
|
13
|
+
export declare enum ProjectTemplateOverrides {
|
|
14
|
+
CLI = "cli",
|
|
15
|
+
New = "new"
|
|
16
|
+
}
|
|
17
|
+
export declare enum ProjectTemplateCategory {
|
|
18
|
+
Web = "web",
|
|
19
|
+
Other = "other"
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=ProjectTemplateInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectTemplateInfo.d.ts","sourceRoot":"","sources":["../src/ProjectTemplateInfo.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,4DAA4D;IAC5D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE;SACT,GAAG,IAAI,wBAAwB,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;KACpF,CAAC;IACF,QAAQ,CAAC,EAAE,uBAAuB,CAAC;CACpC,CAAC;AAEF,oBAAY,wBAAwB;IAClC,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAED,oBAAY,uBAAuB;IACjC,GAAG,QAAQ;IACX,KAAK,UAAU;CAChB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var ProjectTemplateOverrides;
|
|
2
|
+
(function (ProjectTemplateOverrides) {
|
|
3
|
+
ProjectTemplateOverrides["CLI"] = "cli";
|
|
4
|
+
ProjectTemplateOverrides["New"] = "new";
|
|
5
|
+
})(ProjectTemplateOverrides || (ProjectTemplateOverrides = {}));
|
|
6
|
+
export var ProjectTemplateCategory;
|
|
7
|
+
(function (ProjectTemplateCategory) {
|
|
8
|
+
ProjectTemplateCategory["Web"] = "web";
|
|
9
|
+
ProjectTemplateCategory["Other"] = "other";
|
|
10
|
+
})(ProjectTemplateCategory || (ProjectTemplateCategory = {}));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Effect as SharedEffects } from '@devvit/protos';
|
|
2
|
+
import { WebViewImmersiveModeEffect } from '@devvit/protos/types/devvit/ui/effects/web_view/v1alpha/immersive_mode.js';
|
|
3
|
+
import type { WebViewShareEffect } from '@devvit/protos/types/devvit/ui/effects/web_view/v1alpha/share.js';
|
|
4
|
+
import { WebViewInternalEventMessage } from '@devvit/protos/types/devvit/ui/events/v1alpha/web_view.js';
|
|
5
|
+
type Effect = Omit<SharedEffects, 'interval'> & {
|
|
6
|
+
immersiveMode?: WebViewImmersiveModeEffect | undefined;
|
|
7
|
+
share?: WebViewShareEffect;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Emits an effect to the parent window and handles the response if required.
|
|
11
|
+
*
|
|
12
|
+
* @param effect - The effect to be emitted to the parent window
|
|
13
|
+
* @returns A promise that resolves with the response message for effects that require
|
|
14
|
+
* a response, or resolves immediately with undefined for effects that don't
|
|
15
|
+
*
|
|
16
|
+
* @description
|
|
17
|
+
* This function handles two types of effects:
|
|
18
|
+
* 1. Effects that require a response: Creates a unique ID, sets up a message listener,
|
|
19
|
+
* and resolves the promise when a matching response is received
|
|
20
|
+
* 2. Effects that don't require a response: Posts the message and resolves immediately
|
|
21
|
+
*/
|
|
22
|
+
export declare const emitEffect: (effect: Effect) => Promise<WebViewInternalEventMessage | undefined>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=emit-effect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit-effect.d.ts","sourceRoot":"","sources":["../../src/client/emit-effect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAc,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,2EAA2E,CAAC;AAKvH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kEAAkE,CAAC;AAC3G,OAAO,EAAE,2BAA2B,EAAE,MAAM,2DAA2D,CAAC;AAExG,KAAK,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,GAAG;IAC9C,aAAa,CAAC,EAAE,0BAA0B,GAAG,SAAS,CAAC;IACvD,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC5B,CAAC;AAIF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,KAAG,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAsC1F,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { WebViewImmersiveModeEffect } from '@devvit/protos/types/devvit/ui/effects/web_view/v1alpha/immersive_mode.js';
|
|
2
|
+
import { WebViewInternalEventMessage } from '@devvit/protos/types/devvit/ui/events/v1alpha/web_view.js';
|
|
3
|
+
const EFFECTS_WITH_RESPONSE = [3];
|
|
4
|
+
/**
|
|
5
|
+
* Emits an effect to the parent window and handles the response if required.
|
|
6
|
+
*
|
|
7
|
+
* @param effect - The effect to be emitted to the parent window
|
|
8
|
+
* @returns A promise that resolves with the response message for effects that require
|
|
9
|
+
* a response, or resolves immediately with undefined for effects that don't
|
|
10
|
+
*
|
|
11
|
+
* @description
|
|
12
|
+
* This function handles two types of effects:
|
|
13
|
+
* 1. Effects that require a response: Creates a unique ID, sets up a message listener,
|
|
14
|
+
* and resolves the promise when a matching response is received
|
|
15
|
+
* 2. Effects that don't require a response: Posts the message and resolves immediately
|
|
16
|
+
*/
|
|
17
|
+
export const emitEffect = (effect) => {
|
|
18
|
+
return new Promise((resolve) => {
|
|
19
|
+
const message = {
|
|
20
|
+
scope: 0,
|
|
21
|
+
type: 'devvit-internal',
|
|
22
|
+
};
|
|
23
|
+
if (effect.realtimeSubscriptions) {
|
|
24
|
+
message.realtimeEffect = effect.realtimeSubscriptions;
|
|
25
|
+
}
|
|
26
|
+
else if (effect.immersiveMode) {
|
|
27
|
+
message.immersiveMode = effect.immersiveMode;
|
|
28
|
+
}
|
|
29
|
+
else if (effect.share) {
|
|
30
|
+
message.share = effect.share;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
message.effect = effect;
|
|
34
|
+
}
|
|
35
|
+
// Only set message id and add a listener for effects which require a response
|
|
36
|
+
if (EFFECTS_WITH_RESPONSE.includes(effect.type)) {
|
|
37
|
+
const id = self.crypto.randomUUID();
|
|
38
|
+
message.id = id;
|
|
39
|
+
const handleEffect = (event) => {
|
|
40
|
+
if (event.data?.type === 'devvit-message' && event.data?.data?.id === id) {
|
|
41
|
+
const serializedMessage = WebViewInternalEventMessage.fromJSON(event.data.data);
|
|
42
|
+
resolve(serializedMessage);
|
|
43
|
+
window.removeEventListener('message', handleEffect);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
window.addEventListener('message', handleEffect);
|
|
47
|
+
// Post message to the parent window, handled by client web view component
|
|
48
|
+
window.parent.postMessage(message, '*');
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
window.parent.postMessage(message, '*');
|
|
52
|
+
// Resolve immediately for effects that don't expect a response.
|
|
53
|
+
resolve(undefined);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit-effect.test.d.ts","sourceRoot":"","sources":["../../src/client/emit-effect.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share.d.ts","sourceRoot":"","sources":["../../src/client/share.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,eAAO,MAAM,0BAA0B,OAAO,CAAC"}
|
package/client/share.js
ADDED
package/constants.d.ts
CHANGED
|
@@ -19,4 +19,13 @@ export declare const MAX_ALLOWED_SUBSCRIBER_COUNT = 200;
|
|
|
19
19
|
* @type {number}
|
|
20
20
|
*/
|
|
21
21
|
export declare const ASSET_UPLOAD_BATCH_SIZE = 10;
|
|
22
|
+
export declare const REDDIT_OAUTH_COPY_PASTE_CLIENT_ID = "TWTsqXa53CexlrYGBWaesQ";
|
|
23
|
+
/** All server endpoints must start with this prefix. */
|
|
24
|
+
export declare const apiPathPrefix = "/api/";
|
|
25
|
+
/** All unexposed APIs must start with this prefix. */
|
|
26
|
+
export declare const internalPathPrefix = "/internal/";
|
|
27
|
+
/** When an app's icon is present in the media assets list, it'll be with this special name. */
|
|
28
|
+
export declare const ICON_FILE_PATH = "$devvit_icon.png";
|
|
29
|
+
export declare const REDDIT_DISCORD_INVITE_URL = "https://discord.gg/Cd43ExtEFS";
|
|
30
|
+
export declare const REDDIT_SUBREDDIT_URL = "https://www.reddit.com/r/devvit";
|
|
22
31
|
//# sourceMappingURL=constants.d.ts.map
|
package/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,QAAQ,CAAC;AACnC,eAAO,MAAM,sBAAsB,SAAS,CAAC;AAE7C,sBAAsB;AACtB,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAE3C;;;;;MAKM;AACN,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,QAAQ,CAAC;AACnC,eAAO,MAAM,sBAAsB,SAAS,CAAC;AAE7C,sBAAsB;AACtB,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAE3C;;;;;MAKM;AACN,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,eAAO,MAAM,iCAAiC,2BAA2B,CAAC;AAE1E,wDAAwD;AACxD,eAAO,MAAM,aAAa,UAAU,CAAC;AAErC,sDAAsD;AACtD,eAAO,MAAM,kBAAkB,eAAe,CAAC;AAE/C,+FAA+F;AAC/F,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD,eAAO,MAAM,yBAAyB,kCAAkC,CAAC;AACzE,eAAO,MAAM,oBAAoB,oCAAoC,CAAC"}
|
package/constants.js
CHANGED
|
@@ -22,3 +22,12 @@ export const MAX_ALLOWED_SUBSCRIBER_COUNT = 200;
|
|
|
22
22
|
* @type {number}
|
|
23
23
|
*/
|
|
24
24
|
export const ASSET_UPLOAD_BATCH_SIZE = 10;
|
|
25
|
+
export const REDDIT_OAUTH_COPY_PASTE_CLIENT_ID = 'TWTsqXa53CexlrYGBWaesQ';
|
|
26
|
+
/** All server endpoints must start with this prefix. */
|
|
27
|
+
export const apiPathPrefix = '/api/';
|
|
28
|
+
/** All unexposed APIs must start with this prefix. */
|
|
29
|
+
export const internalPathPrefix = '/internal/';
|
|
30
|
+
/** When an app's icon is present in the media assets list, it'll be with this special name. */
|
|
31
|
+
export const ICON_FILE_PATH = '$devvit_icon.png'; // Uses special characters intentionally to avoid conflicts with real asset paths
|
|
32
|
+
export const REDDIT_DISCORD_INVITE_URL = 'https://discord.gg/Cd43ExtEFS';
|
|
33
|
+
export const REDDIT_SUBREDDIT_URL = 'https://www.reddit.com/r/devvit';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asserts that the number of requested fetch domains is within the allowed limit.
|
|
3
|
+
* @param requestedFetchDomains - The array of requested fetch domains.
|
|
4
|
+
* @throws Error if the number of domains exceeds the limit.
|
|
5
|
+
*/
|
|
6
|
+
export declare function assertRequestedFetchDomainsLimit(requestedFetchDomains: string[]): void;
|
|
7
|
+
/**
|
|
8
|
+
* Normalizes the requested fetch domains by removing the protocol and 'www' prefix if present.
|
|
9
|
+
* @param requestedFetchDomains - The array of requested fetch domains.
|
|
10
|
+
* @returns An array of normalized domains.
|
|
11
|
+
* @throws Error if any domain format is invalid.
|
|
12
|
+
*/
|
|
13
|
+
export declare function normalizeDomains(requestedFetchDomains: string[]): string[];
|
|
14
|
+
//# sourceMappingURL=fetch-domains.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-domains.d.ts","sourceRoot":"","sources":["../src/fetch-domains.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,qBAAqB,EAAE,MAAM,EAAE,GAAG,IAAI,CAItF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,qBAAqB,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CA4B1E"}
|
package/fetch-domains.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Regular expression to check if a domain contains a top-level domain, eg '.com' or '.org'
|
|
2
|
+
const TOP_LEVEL_DOMAIN_REGEX = /\.[a-zA-Z]{2,}$/;
|
|
3
|
+
const MAX_DOMAINS = 25;
|
|
4
|
+
/**
|
|
5
|
+
* Asserts that the number of requested fetch domains is within the allowed limit.
|
|
6
|
+
* @param requestedFetchDomains - The array of requested fetch domains.
|
|
7
|
+
* @throws Error if the number of domains exceeds the limit.
|
|
8
|
+
*/
|
|
9
|
+
export function assertRequestedFetchDomainsLimit(requestedFetchDomains) {
|
|
10
|
+
if (requestedFetchDomains.length > MAX_DOMAINS) {
|
|
11
|
+
throw new Error(`The size of requestedFetchDomains is limited to ${MAX_DOMAINS} domains.`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Normalizes the requested fetch domains by removing the protocol and 'www' prefix if present.
|
|
16
|
+
* @param requestedFetchDomains - The array of requested fetch domains.
|
|
17
|
+
* @returns An array of normalized domains.
|
|
18
|
+
* @throws Error if any domain format is invalid.
|
|
19
|
+
*/
|
|
20
|
+
export function normalizeDomains(requestedFetchDomains) {
|
|
21
|
+
const normalizedSet = new Set();
|
|
22
|
+
for (let rawDomain of requestedFetchDomains) {
|
|
23
|
+
try {
|
|
24
|
+
// Check for valid TLD (like '.com', '.net', etc.)
|
|
25
|
+
if (!TOP_LEVEL_DOMAIN_REGEX.test(rawDomain)) {
|
|
26
|
+
throw new Error(`The domain does not have a valid top-level domain.`);
|
|
27
|
+
}
|
|
28
|
+
// Prepend 'http://' if no protocol is present
|
|
29
|
+
if (!rawDomain.includes('://')) {
|
|
30
|
+
rawDomain = 'http://' + rawDomain;
|
|
31
|
+
}
|
|
32
|
+
// Create URL object and extract hostname
|
|
33
|
+
const url = new URL(rawDomain);
|
|
34
|
+
const normalizedDomain = url.hostname.replace(/^www\./, ''); // Remove 'www.' prefix
|
|
35
|
+
normalizedSet.add(normalizedDomain);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
throw new Error(`Failed to determine hostname from requested domain: '${rawDomain}'. ${error}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return Array.from(normalizedSet);
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-domains.test.d.ts","sourceRoot":"","sources":["../src/fetch-domains.test.ts"],"names":[],"mappings":""}
|
package/isDevvitDependency.js
CHANGED
|
@@ -7,7 +7,7 @@ export function isDevvitDependency(dependencyName) {
|
|
|
7
7
|
if (dependencyName === '@devvit/kit') {
|
|
8
8
|
return false;
|
|
9
9
|
}
|
|
10
|
-
return dependencyName.startsWith('@devvit/');
|
|
10
|
+
return dependencyName === 'devvit' || dependencyName.startsWith('@devvit/');
|
|
11
11
|
}
|
|
12
12
|
export function isDependencyManagedByDevvit(dependencyName) {
|
|
13
13
|
// Note: The moment we want to add a second dependency that isn't a @devvit/
|
package/json.d.ts
CHANGED
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
* @see https://github.com/microsoft/TypeScript/issues/1897
|
|
10
10
|
* @see https://www.json.org
|
|
11
11
|
*/
|
|
12
|
-
export type
|
|
13
|
-
export type
|
|
14
|
-
[key: string]:
|
|
12
|
+
export type JsonValue = JsonPrimitive | JsonArray | JsonObject;
|
|
13
|
+
export type JsonObject = {
|
|
14
|
+
[key: string]: JsonValue;
|
|
15
15
|
};
|
|
16
|
-
export type
|
|
17
|
-
export type
|
|
16
|
+
export type JsonArray = JsonValue[];
|
|
17
|
+
export type JsonPrimitive = boolean | null | number | string;
|
|
18
18
|
/**
|
|
19
|
-
* Like
|
|
19
|
+
* Like JsonValue but deeply allow lossy undefined values that are easier to
|
|
20
20
|
* type but may de/serialize differently or incorrectly. For example:
|
|
21
21
|
*
|
|
22
22
|
* - `JSON.stringify({a: 1, b: 2, c: undefined, d: 3})`: `'{"a":1,"b":2,"d":3}'`.
|
|
@@ -24,7 +24,7 @@ export type JSONPrimitive = boolean | null | number | string;
|
|
|
24
24
|
* - `JSON.stringify(undefined)`: `undefined`.
|
|
25
25
|
*
|
|
26
26
|
* JSON.stringify() accepts an `any` input so there are no typing guards. Prefer
|
|
27
|
-
* plain
|
|
27
|
+
* plain JsonValue when possible.
|
|
28
28
|
*
|
|
29
29
|
* One mostly only cares about stringify since creating a JSON string with
|
|
30
30
|
* undefineds in it would require deliberate effort. These all throw errors:
|
|
@@ -34,10 +34,10 @@ export type JSONPrimitive = boolean | null | number | string;
|
|
|
34
34
|
* - `JSON.parse('undefined')`.
|
|
35
35
|
* - `JSON.parse(undefined)` (also a typing error).
|
|
36
36
|
*/
|
|
37
|
-
export type
|
|
38
|
-
export type
|
|
39
|
-
[key: string]:
|
|
37
|
+
export type PartialJsonValue = PartialJsonPrimitive | PartialJsonArray | PartialJsonObject;
|
|
38
|
+
export type PartialJsonObject = Partial<{
|
|
39
|
+
[key: string]: PartialJsonValue;
|
|
40
40
|
}>;
|
|
41
|
-
export type
|
|
42
|
-
export type
|
|
41
|
+
export type PartialJsonArray = PartialJsonValue[];
|
|
42
|
+
export type PartialJsonPrimitive = boolean | null | number | string | undefined;
|
|
43
43
|
//# sourceMappingURL=json.d.ts.map
|