@mittwald/ext-bridge 0.2.0-alpha.999 → 1.0.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/js/config/extractHostConfig.mjs +7 -5
- package/dist/js/config/extractHostConfig.mjs.map +1 -1
- package/dist/js/config/getConfig.mjs +7 -7
- package/dist/js/config/getConfig.mjs.map +1 -1
- package/dist/js/config/parse.mjs +10 -12
- package/dist/js/config/parse.mjs.map +1 -1
- package/dist/js/config/schemas.mjs +62 -15
- package/dist/js/config/schemas.mjs.map +1 -1
- package/dist/js/environment.mjs +7 -5
- package/dist/js/environment.mjs.map +1 -1
- package/dist/js/error.mjs +10 -8
- package/dist/js/error.mjs.map +1 -1
- package/dist/js/getExtBridge.mjs +9 -8
- package/dist/js/getExtBridge.mjs.map +1 -1
- package/dist/js/global-browser.mjs +8 -14
- package/dist/js/global-browser.mjs.map +1 -1
- package/dist/js/i18next.mjs +2 -2
- package/dist/js/index-browser.mjs +7 -6
- package/dist/js/index-browser.mjs.map +1 -1
- package/dist/js/index-node.mjs +4 -6
- package/dist/js/index.mjs +0 -2
- package/dist/js/integrations/i18next/modules/remoteLanguageDetectorModule.mjs +14 -16
- package/dist/js/integrations/i18next/modules/remoteLanguageDetectorModule.mjs.map +1 -1
- package/dist/js/lib/assertBrowserEnv.mjs +8 -11
- package/dist/js/lib/assertBrowserEnv.mjs.map +1 -1
- package/dist/js/lib/controllablePromise.mjs +20 -16
- package/dist/js/lib/controllablePromise.mjs.map +1 -1
- package/dist/js/react/hooks/index.mjs +3 -0
- package/dist/js/react/hooks/useConfig.mjs +7 -6
- package/dist/js/react/hooks/useConfig.mjs.map +1 -1
- package/dist/js/react/hooks/useExtBridge.mjs +8 -7
- package/dist/js/react/hooks/useExtBridge.mjs.map +1 -1
- package/dist/js/react/hooks/useLanguage.mjs +6 -5
- package/dist/js/react/hooks/useLanguage.mjs.map +1 -1
- package/dist/js/react.mjs +4 -3
- package/dist/js/readiness.mjs +32 -33
- package/dist/js/readiness.mjs.map +1 -1
- package/dist/js/sessionToken/decode.mjs +15 -27
- package/dist/js/sessionToken/decode.mjs.map +1 -1
- package/dist/js/sessionToken/getAccessToken.mjs +16 -13
- package/dist/js/sessionToken/getAccessToken.mjs.map +1 -1
- package/dist/js/sessionToken/getSessionToken.mjs +7 -7
- package/dist/js/sessionToken/getSessionToken.mjs.map +1 -1
- package/dist/js/sessionToken/index.mjs +3 -0
- package/dist/js/sessionToken/publicKeys/fetchPublicKey.mjs +15 -15
- package/dist/js/sessionToken/publicKeys/fetchPublicKey.mjs.map +1 -1
- package/dist/js/sessionToken/publicKeys/index.mjs +2 -0
- package/dist/js/sessionToken/publicKeys/publicKeys.mjs +14 -15
- package/dist/js/sessionToken/publicKeys/publicKeys.mjs.map +1 -1
- package/dist/js/sessionToken/schemas.mjs +18 -17
- package/dist/js/sessionToken/schemas.mjs.map +1 -1
- package/dist/js/sessionToken/verify.mjs +13 -11
- package/dist/js/sessionToken/verify.mjs.map +1 -1
- package/dist/types/config/extractHostConfig.d.ts +1 -2
- package/dist/types/config/extractHostConfig.d.ts.map +1 -1
- package/dist/types/config/parse.d.ts +28 -5
- package/dist/types/config/parse.d.ts.map +1 -1
- package/dist/types/config/schemas.d.ts +33 -5
- package/dist/types/config/schemas.d.ts.map +1 -1
- package/dist/types/config/types.d.ts +39 -2
- package/dist/types/config/types.d.ts.map +1 -1
- package/dist/types/types.d.ts +1 -1
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +10 -13
- package/dist/js/i18next.mjs.map +0 -1
- package/dist/js/index-node.mjs.map +0 -1
- package/dist/js/index.mjs.map +0 -1
- package/dist/js/react.mjs.map +0 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/config/extractHostConfig.ts
|
|
2
|
+
var extractHostConfig = (config) => ({
|
|
3
|
+
language: config.language,
|
|
4
|
+
theme: config.theme
|
|
4
5
|
});
|
|
5
|
-
|
|
6
|
+
//#endregion
|
|
6
7
|
export { extractHostConfig };
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=extractHostConfig.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractHostConfig.mjs","sources":["../../../src/config/extractHostConfig.ts"],"sourcesContent":["import type { HostConfig } from \"
|
|
1
|
+
{"version":3,"file":"extractHostConfig.mjs","names":[],"sources":["../../../src/config/extractHostConfig.ts"],"sourcesContent":["import type { ExtBridgeConfigInput, HostConfig } from \"./types\";\n\nexport const extractHostConfig = (\n config: ExtBridgeConfigInput,\n): HostConfig => ({\n language: config.language,\n theme: config.theme,\n});\n"],"mappings":";AAEA,IAAa,qBACX,YACgB;CAChB,UAAU,OAAO;CACjB,OAAO,OAAO;AAChB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getExtBridge } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return extBridge.config;
|
|
1
|
+
import { getExtBridge } from "../getExtBridge.mjs";
|
|
2
|
+
//#region src/config/getConfig.ts
|
|
3
|
+
var getConfig = async () => {
|
|
4
|
+
return (await getExtBridge()).config;
|
|
6
5
|
};
|
|
7
|
-
|
|
6
|
+
//#endregion
|
|
8
7
|
export { getConfig };
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=getConfig.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConfig.mjs","sources":["../../../src/config/getConfig.ts"],"sourcesContent":["import { getExtBridge } from \"@/getExtBridge\";\n\nexport const getConfig = async () => {\n const extBridge = await getExtBridge();\n return extBridge.config;\n};\n"],"
|
|
1
|
+
{"version":3,"file":"getConfig.mjs","names":[],"sources":["../../../src/config/getConfig.ts"],"sourcesContent":["import { getExtBridge } from \"@/getExtBridge\";\n\nexport const getConfig = async () => {\n const extBridge = await getExtBridge();\n return extBridge.config;\n};\n"],"mappings":";;AAEA,IAAa,YAAY,YAAY;CAEnC,QAAO,MADiB,aAAa,EAAA,CACpB;AACnB"}
|
package/dist/js/config/parse.mjs
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
throw new ExtBridgeError("Invalid config: " + parsed.error.message);
|
|
9
|
-
}
|
|
10
|
-
return parsed.data;
|
|
1
|
+
import { ExtBridgeError } from "../error.mjs";
|
|
2
|
+
import { config } from "./schemas.mjs";
|
|
3
|
+
//#region src/config/parse.ts
|
|
4
|
+
var parseConfig = (something) => {
|
|
5
|
+
const parsed = config.safeParse(something);
|
|
6
|
+
if (parsed.error) throw new ExtBridgeError("Invalid config: " + parsed.error.message);
|
|
7
|
+
return parsed.data;
|
|
11
8
|
};
|
|
12
|
-
|
|
9
|
+
//#endregion
|
|
13
10
|
export { parseConfig };
|
|
14
|
-
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=parse.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.mjs","sources":["../../../src/config/parse.ts"],"sourcesContent":["import { config } from \"@/config/schemas\";\nimport { ExtBridgeError } from \"@/error\";\
|
|
1
|
+
{"version":3,"file":"parse.mjs","names":[],"sources":["../../../src/config/parse.ts"],"sourcesContent":["import { config } from \"@/config/schemas\";\nimport { ExtBridgeError } from \"@/error\";\n\nexport const parseConfig = (something: unknown) => {\n const parsed = config.safeParse(something);\n if (parsed.error) {\n throw new ExtBridgeError(\"Invalid config: \" + parsed.error.message);\n }\n return parsed.data;\n};\n"],"mappings":";;;AAGA,IAAa,eAAe,cAAuB;CACjD,MAAM,SAAS,OAAO,UAAU,SAAS;CACzC,IAAI,OAAO,OACT,MAAM,IAAI,eAAe,qBAAqB,OAAO,MAAM,OAAO;CAEpE,OAAO,OAAO;AAChB"}
|
|
@@ -1,18 +1,65 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/config/schemas.ts
|
|
3
|
+
/**
|
|
4
|
+
* Schema of an optional config value: `string | undefined` to a consumer.
|
|
5
|
+
*
|
|
6
|
+
* A host that sends `null` degrades to "value absent" instead of failing the
|
|
7
|
+
* config parse — a failed parse throws and the extension never starts.
|
|
8
|
+
*/
|
|
9
|
+
var optionalString = z.string().nullable().optional().transform((value) => value ?? void 0);
|
|
10
|
+
/**
|
|
11
|
+
* Breaking Change warning: Do not remove/rename/modify existing properties in
|
|
12
|
+
* the config schema, as they might be used by existing extensions.
|
|
13
|
+
*/
|
|
14
|
+
var baseConfig = z.object({
|
|
15
|
+
sessionId: z.string(),
|
|
16
|
+
userId: z.string(),
|
|
17
|
+
extensionId: z.string(),
|
|
18
|
+
extensionInstanceId: z.string(),
|
|
19
|
+
variantKey: optionalString
|
|
9
20
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The context parameters the mStudio host can supply, in addition to
|
|
23
|
+
* `sessionId`.
|
|
24
|
+
*
|
|
25
|
+
* Breaking Change warning: Do not remove/rename/modify existing properties in
|
|
26
|
+
* the config schema, as they might be used by existing extensions.
|
|
27
|
+
*/
|
|
28
|
+
var contextParameters = z.object({
|
|
29
|
+
aiApiKeyId: optionalString,
|
|
30
|
+
appInstallationId: optionalString,
|
|
31
|
+
backupId: optionalString,
|
|
32
|
+
certificateId: optionalString,
|
|
33
|
+
containerId: optionalString,
|
|
34
|
+
contractId: optionalString,
|
|
35
|
+
conversationId: optionalString,
|
|
36
|
+
cronjobId: optionalString,
|
|
37
|
+
customerId: optionalString,
|
|
38
|
+
databaseId: optionalString,
|
|
39
|
+
deliveryBoxId: optionalString,
|
|
40
|
+
domainId: optionalString,
|
|
41
|
+
emailAddressId: optionalString,
|
|
42
|
+
ingressId: optionalString,
|
|
43
|
+
leadId: optionalString,
|
|
44
|
+
licenseId: optionalString,
|
|
45
|
+
mailAddressId: optionalString,
|
|
46
|
+
projectId: optionalString,
|
|
47
|
+
registryId: optionalString,
|
|
48
|
+
scheduleId: optionalString,
|
|
49
|
+
serverId: optionalString,
|
|
50
|
+
sftpUserId: optionalString,
|
|
51
|
+
sshUserId: optionalString,
|
|
52
|
+
stackId: optionalString,
|
|
53
|
+
templateId: optionalString,
|
|
54
|
+
zoneId: optionalString
|
|
14
55
|
});
|
|
15
|
-
|
|
16
|
-
|
|
56
|
+
/**
|
|
57
|
+
* The catchall keeps a context parameter mStudio starts sending before this
|
|
58
|
+
* schema declares it. It is part of the exported schema on purpose: the type
|
|
59
|
+
* and the runtime parse must agree about unknown keys.
|
|
60
|
+
*/
|
|
61
|
+
var config = baseConfig.extend(contextParameters.shape).catchall(optionalString);
|
|
62
|
+
//#endregion
|
|
17
63
|
export { config };
|
|
18
|
-
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=schemas.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.mjs","sources":["../../../src/config/schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/**\n * Breaking Change warning: Do not remove/rename/modify existing properties in\n * the config schema, as they might be used by existing extensions.\n */\nconst baseConfig = z.object({\n sessionId: z.string(),\n userId: z.string(),\n extensionId: z.string(),\n extensionInstanceId: z.string(),\n variantKey:
|
|
1
|
+
{"version":3,"file":"schemas.mjs","names":[],"sources":["../../../src/config/schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/**\n * Schema of an optional config value: `string | undefined` to a consumer.\n *\n * A host that sends `null` degrades to \"value absent\" instead of failing the\n * config parse — a failed parse throws and the extension never starts.\n */\nconst optionalString = z\n .string()\n .nullable()\n .optional()\n .transform((value) => value ?? undefined);\n\n/**\n * Breaking Change warning: Do not remove/rename/modify existing properties in\n * the config schema, as they might be used by existing extensions.\n */\nconst baseConfig = z.object({\n sessionId: z.string(),\n userId: z.string(),\n extensionId: z.string(),\n extensionInstanceId: z.string(),\n variantKey: optionalString,\n});\n\n/**\n * The context parameters the mStudio host can supply, in addition to\n * `sessionId`.\n *\n * Breaking Change warning: Do not remove/rename/modify existing properties in\n * the config schema, as they might be used by existing extensions.\n */\nconst contextParameters = z.object({\n aiApiKeyId: optionalString,\n appInstallationId: optionalString,\n backupId: optionalString,\n certificateId: optionalString,\n containerId: optionalString,\n contractId: optionalString,\n conversationId: optionalString,\n cronjobId: optionalString,\n customerId: optionalString,\n databaseId: optionalString,\n deliveryBoxId: optionalString,\n domainId: optionalString,\n // `emailAddressId` and `ingressId` are deprecated. Their `@deprecated` tags\n // live on `DeprecatedContextParameters` in ./types.ts — JSDoc on a zod shape\n // does not survive the declaration emit.\n emailAddressId: optionalString,\n ingressId: optionalString,\n leadId: optionalString,\n licenseId: optionalString,\n mailAddressId: optionalString,\n projectId: optionalString,\n registryId: optionalString,\n scheduleId: optionalString,\n serverId: optionalString,\n sftpUserId: optionalString,\n sshUserId: optionalString,\n stackId: optionalString,\n templateId: optionalString,\n zoneId: optionalString,\n});\n\n/**\n * The catchall keeps a context parameter mStudio starts sending before this\n * schema declares it. It is part of the exported schema on purpose: the type\n * and the runtime parse must agree about unknown keys.\n */\nexport const config = baseConfig\n .extend(contextParameters.shape)\n .catchall(optionalString);\n"],"mappings":";;;;;;;;AAQA,IAAM,iBAAiB,EACpB,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,CAAC,CACV,WAAW,UAAU,SAAS,KAAA,CAAS;;;;;AAM1C,IAAM,aAAa,EAAE,OAAO;CAC1B,WAAW,EAAE,OAAO;CACpB,QAAQ,EAAE,OAAO;CACjB,aAAa,EAAE,OAAO;CACtB,qBAAqB,EAAE,OAAO;CAC9B,YAAY;AACd,CAAC;;;;;;;;AASD,IAAM,oBAAoB,EAAE,OAAO;CACjC,YAAY;CACZ,mBAAmB;CACnB,UAAU;CACV,eAAe;CACf,aAAa;CACb,YAAY;CACZ,gBAAgB;CAChB,WAAW;CACX,YAAY;CACZ,YAAY;CACZ,eAAe;CACf,UAAU;CAIV,gBAAgB;CAChB,WAAW;CACX,QAAQ;CACR,WAAW;CACX,eAAe;CACf,WAAW;CACX,YAAY;CACZ,YAAY;CACZ,UAAU;CACV,YAAY;CACZ,WAAW;CACX,SAAS;CACT,YAAY;CACZ,QAAQ;AACV,CAAC;;;;;;AAOD,IAAa,SAAS,WACnB,OAAO,kBAAkB,KAAK,CAAC,CAC/B,SAAS,cAAc"}
|
package/dist/js/environment.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { env } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { env } from "std-env";
|
|
2
|
+
//#region src/environment.ts
|
|
3
|
+
/** @internal */
|
|
4
|
+
var MW_EXT_API_URL = env["MW_EXT_API_URL"] ?? "https://api.mittwald.de";
|
|
5
|
+
//#endregion
|
|
5
6
|
export { MW_EXT_API_URL };
|
|
6
|
-
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=environment.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.mjs","sources":["../../src/environment.ts"],"sourcesContent":["import { env } from \"std-env\";\n\n/** @internal */\nexport const MW_EXT_API_URL =\n env[\"MW_EXT_API_URL\"] ?? \"https://api.mittwald.de\";\n"],"
|
|
1
|
+
{"version":3,"file":"environment.mjs","names":[],"sources":["../../src/environment.ts"],"sourcesContent":["import { env } from \"std-env\";\n\n/** @internal */\nexport const MW_EXT_API_URL =\n env[\"MW_EXT_API_URL\"] ?? \"https://api.mittwald.de\";\n"],"mappings":";;;AAGA,IAAa,iBACX,IAAI,qBAAqB"}
|
package/dist/js/error.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
1
|
+
//#region src/error.ts
|
|
2
|
+
var ExtBridgeError = class extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.message = message;
|
|
6
|
+
}
|
|
7
|
+
};
|
|
7
8
|
ExtBridgeError.prototype.name = "ExtBridgeError";
|
|
8
|
-
|
|
9
|
+
//#endregion
|
|
9
10
|
export { ExtBridgeError };
|
|
10
|
-
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=error.mjs.map
|
package/dist/js/error.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.mjs","sources":["../../src/error.ts"],"sourcesContent":["export class ExtBridgeError extends Error {\n constructor(message: string) {\n super(message);\n this.message = message;\n }\n}\n\nExtBridgeError.prototype.name = \"ExtBridgeError\";\n"],"
|
|
1
|
+
{"version":3,"file":"error.mjs","names":[],"sources":["../../src/error.ts"],"sourcesContent":["export class ExtBridgeError extends Error {\n constructor(message: string) {\n super(message);\n this.message = message;\n }\n}\n\nExtBridgeError.prototype.name = \"ExtBridgeError\";\n"],"mappings":";AAAA,IAAa,iBAAb,cAAoC,MAAM;CACxC,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,UAAU;CACjB;AACF;AAEA,eAAe,UAAU,OAAO"}
|
package/dist/js/getExtBridge.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { initExtBridge } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { initExtBridge } from "./global-browser.mjs";
|
|
2
|
+
//#region src/getExtBridge.ts
|
|
3
|
+
var getExtBridge = async () => {
|
|
4
|
+
initExtBridge();
|
|
5
|
+
await globalThis.mwExtBridge.readiness.isReady();
|
|
6
|
+
return globalThis.mwExtBridge;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
//#endregion
|
|
9
9
|
export { getExtBridge };
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=getExtBridge.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getExtBridge.mjs","sources":["../../src/getExtBridge.ts"],"sourcesContent":["import { initExtBridge } from \"@/global-browser\";\n\nexport const getExtBridge = async () => {\n initExtBridge();\n await globalThis.mwExtBridge.readiness.isReady();\n return globalThis.mwExtBridge;\n};\n"],"
|
|
1
|
+
{"version":3,"file":"getExtBridge.mjs","names":[],"sources":["../../src/getExtBridge.ts"],"sourcesContent":["import { initExtBridge } from \"@/global-browser\";\n\nexport const getExtBridge = async () => {\n initExtBridge();\n await globalThis.mwExtBridge.readiness.isReady();\n return globalThis.mwExtBridge;\n};\n"],"mappings":";;AAEA,IAAa,eAAe,YAAY;CACtC,cAAc;CACd,MAAM,WAAW,YAAY,UAAU,QAAQ;CAC/C,OAAO,WAAW;AACpB"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import { readinessApi } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
console.warn(
|
|
6
|
-
"mwExtBridge is already defined. The @mittwald/ext-bridge package is probably installed multiple times."
|
|
7
|
-
);
|
|
8
|
-
}
|
|
9
|
-
const mwExtBridge = {
|
|
10
|
-
readiness: readinessApi
|
|
11
|
-
};
|
|
1
|
+
import { readinessApi } from "./readiness.mjs";
|
|
2
|
+
//#region src/global-browser.ts
|
|
3
|
+
if (typeof globalThis.mwExtBridge !== "undefined") console.warn("mwExtBridge is already defined. The @mittwald/ext-bridge package is probably installed multiple times.");
|
|
4
|
+
var mwExtBridge = { readiness: readinessApi };
|
|
12
5
|
function initExtBridge() {
|
|
13
|
-
|
|
6
|
+
globalThis.mwExtBridge = mwExtBridge;
|
|
14
7
|
}
|
|
15
|
-
|
|
8
|
+
//#endregion
|
|
16
9
|
export { initExtBridge, mwExtBridge };
|
|
17
|
-
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=global-browser.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-browser.mjs","sources":["../../src/global-browser.ts"],"sourcesContent":["import { readinessApi } from \"@/readiness\";\nimport type { ExtBridge } from \"@/types\";\n\nconst isAlreadyDefined = typeof globalThis.mwExtBridge !== \"undefined\";\n\nif (isAlreadyDefined) {\n console.warn(\n \"mwExtBridge is already defined. The @mittwald/ext-bridge package is probably installed multiple times.\",\n );\n}\n\nexport const mwExtBridge = {\n readiness: readinessApi,\n} as ExtBridge;\n\nexport function initExtBridge(): void {\n globalThis.mwExtBridge = mwExtBridge;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"global-browser.mjs","names":[],"sources":["../../src/global-browser.ts"],"sourcesContent":["import { readinessApi } from \"@/readiness\";\nimport type { ExtBridge } from \"@/types\";\n\nconst isAlreadyDefined = typeof globalThis.mwExtBridge !== \"undefined\";\n\nif (isAlreadyDefined) {\n console.warn(\n \"mwExtBridge is already defined. The @mittwald/ext-bridge package is probably installed multiple times.\",\n );\n}\n\nexport const mwExtBridge = {\n readiness: readinessApi,\n} as ExtBridge;\n\nexport function initExtBridge(): void {\n globalThis.mwExtBridge = mwExtBridge;\n}\n"],"mappings":";;AAKA,IAFyB,OAAO,WAAW,gBAAgB,aAGzD,QAAQ,KACN,wGACF;AAGF,IAAa,cAAc,EACzB,WAAW,aACb;AAEA,SAAgB,gBAAsB;CACpC,WAAW,cAAc;AAC3B"}
|
package/dist/js/i18next.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { remoteLanguageDetectorModule } from "./integrations/i18next/modules/remoteLanguageDetectorModule.mjs";
|
|
2
|
+
export { remoteLanguageDetectorModule };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { initExtBridge } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { initExtBridge } from "./global-browser.mjs";
|
|
2
|
+
import { getConfig } from "./config/getConfig.mjs";
|
|
3
|
+
import { getSessionToken } from "./sessionToken/getSessionToken.mjs";
|
|
4
|
+
//#region src/index-browser.ts
|
|
5
5
|
initExtBridge();
|
|
6
|
+
//#endregion
|
|
7
|
+
export { getConfig, getSessionToken, initExtBridge };
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
//# sourceMappingURL=index-browser.mjs.map
|
|
9
|
+
//# sourceMappingURL=index-browser.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-browser.mjs","sources":["../../src/index-browser.ts"],"sourcesContent":["import { initExtBridge } from \"@/global-browser\";\n\ninitExtBridge();\n\nexport { initExtBridge };\n\nexport { getConfig } from \"@/config/getConfig\";\nexport { getSessionToken } from \"@/sessionToken/getSessionToken\";\n"],"
|
|
1
|
+
{"version":3,"file":"index-browser.mjs","names":[],"sources":["../../src/index-browser.ts"],"sourcesContent":["import { initExtBridge } from \"@/global-browser\";\n\ninitExtBridge();\n\nexport { initExtBridge };\n\nexport { getConfig } from \"@/config/getConfig\";\nexport { getSessionToken } from \"@/sessionToken/getSessionToken\";\n"],"mappings":";;;;AAEA,cAAc"}
|
package/dist/js/index-node.mjs
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
export { verify }
|
|
5
|
-
export { getAccessToken } from './sessionToken/getAccessToken.mjs';
|
|
6
|
-
//# sourceMappingURL=index-node.mjs.map
|
|
1
|
+
import { verify } from "./sessionToken/verify.mjs";
|
|
2
|
+
import "./sessionToken/index.mjs";
|
|
3
|
+
import { getAccessToken } from "./sessionToken/getAccessToken.mjs";
|
|
4
|
+
export { getAccessToken, verify };
|
package/dist/js/index.mjs
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return config.language;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
1
|
+
import { isBrowser } from "../../../lib/assertBrowserEnv.mjs";
|
|
2
|
+
import { getConfig } from "../../../config/getConfig.mjs";
|
|
3
|
+
import "../../../index-browser.mjs";
|
|
4
|
+
import "i18next";
|
|
5
|
+
//#region src/integrations/i18next/modules/remoteLanguageDetectorModule.ts
|
|
6
|
+
var remoteLanguageDetectorModule = () => ({
|
|
7
|
+
type: "languageDetector",
|
|
8
|
+
async: true,
|
|
9
|
+
detect: async () => {
|
|
10
|
+
if (isBrowser) return (await getConfig()).language;
|
|
11
|
+
}
|
|
15
12
|
});
|
|
16
|
-
|
|
13
|
+
//#endregion
|
|
17
14
|
export { remoteLanguageDetectorModule };
|
|
18
|
-
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=remoteLanguageDetectorModule.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteLanguageDetectorModule.mjs","sources":["../../../../../src/integrations/i18next/modules/remoteLanguageDetectorModule.ts"],"sourcesContent":["import { getConfig } from \"@/index-browser\";\nimport { isBrowser } from \"@/lib/assertBrowserEnv\";\nimport { type LanguageDetectorAsyncModule } from \"i18next\";\n\nexport const remoteLanguageDetectorModule =\n (): LanguageDetectorAsyncModule => ({\n type: \"languageDetector\",\n async: true,\n detect: async () => {\n if (isBrowser) {\n const config = await getConfig();\n return config.language;\n }\n },\n });\n"],"
|
|
1
|
+
{"version":3,"file":"remoteLanguageDetectorModule.mjs","names":[],"sources":["../../../../../src/integrations/i18next/modules/remoteLanguageDetectorModule.ts"],"sourcesContent":["import { getConfig } from \"@/index-browser\";\nimport { isBrowser } from \"@/lib/assertBrowserEnv\";\nimport { type LanguageDetectorAsyncModule } from \"i18next\";\n\nexport const remoteLanguageDetectorModule =\n (): LanguageDetectorAsyncModule => ({\n type: \"languageDetector\",\n async: true,\n detect: async () => {\n if (isBrowser) {\n const config = await getConfig();\n return config.language;\n }\n },\n });\n"],"mappings":";;;;;AAIA,IAAa,sCACyB;CAClC,MAAM;CACN,OAAO;CACP,QAAQ,YAAY;EAClB,IAAI,WAEF,QAAO,MADc,UAAU,EAAA,CACjB;CAElB;AACF"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { ExtBridgeError } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
throw new ExtBridgeError(
|
|
7
|
-
"Ext Bridge can only be used in a browser environment. To opt-out from SSR you can use <BrowserOnly> from '@mittwald/flow-remote-react-components'."
|
|
8
|
-
);
|
|
9
|
-
}
|
|
1
|
+
import { ExtBridgeError } from "../error.mjs";
|
|
2
|
+
//#region src/lib/assertBrowserEnv.ts
|
|
3
|
+
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
4
|
+
var assertBrowserEnv = () => {
|
|
5
|
+
if (!isBrowser) throw new ExtBridgeError("Ext Bridge can only be used in a browser environment. To opt-out from SSR you can use <BrowserOnly> from '@mittwald/flow-remote-react-components'.");
|
|
10
6
|
};
|
|
11
|
-
|
|
7
|
+
//#endregion
|
|
12
8
|
export { assertBrowserEnv, isBrowser };
|
|
13
|
-
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=assertBrowserEnv.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertBrowserEnv.mjs","sources":["../../../src/lib/assertBrowserEnv.ts"],"sourcesContent":["import { ExtBridgeError } from \"@/error\";\n\nexport const isBrowser: boolean =\n typeof window !== \"undefined\" && typeof window.document !== \"undefined\";\n\nexport const assertBrowserEnv = () => {\n if (!isBrowser) {\n throw new ExtBridgeError(\n \"Ext Bridge can only be used in a browser environment. To opt-out from SSR you can use <BrowserOnly> from '@mittwald/flow-remote-react-components'.\",\n );\n }\n};\n"],"
|
|
1
|
+
{"version":3,"file":"assertBrowserEnv.mjs","names":[],"sources":["../../../src/lib/assertBrowserEnv.ts"],"sourcesContent":["import { ExtBridgeError } from \"@/error\";\n\nexport const isBrowser: boolean =\n typeof window !== \"undefined\" && typeof window.document !== \"undefined\";\n\nexport const assertBrowserEnv = () => {\n if (!isBrowser) {\n throw new ExtBridgeError(\n \"Ext Bridge can only be used in a browser environment. To opt-out from SSR you can use <BrowserOnly> from '@mittwald/flow-remote-react-components'.\",\n );\n }\n};\n"],"mappings":";;AAEA,IAAa,YACX,OAAO,WAAW,eAAe,OAAO,OAAO,aAAa;AAE9D,IAAa,yBAAyB;CACpC,IAAI,CAAC,WACH,MAAM,IAAI,eACR,oJACF;AAEJ"}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import { ExtBridgeError } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { ExtBridgeError } from "../error.mjs";
|
|
2
|
+
//#region src/lib/controllablePromise.ts
|
|
3
|
+
var controllablePromise = () => {
|
|
4
|
+
let resolve = () => {
|
|
5
|
+
throw new ExtBridgeError("Unexpected call of resolve()");
|
|
6
|
+
};
|
|
7
|
+
let reject = () => {
|
|
8
|
+
throw new ExtBridgeError("Unexpected call of reject()");
|
|
9
|
+
};
|
|
10
|
+
return [
|
|
11
|
+
new Promise((res, rej) => {
|
|
12
|
+
resolve = res;
|
|
13
|
+
reject = rej;
|
|
14
|
+
}),
|
|
15
|
+
resolve,
|
|
16
|
+
reject
|
|
17
|
+
];
|
|
15
18
|
};
|
|
16
|
-
|
|
19
|
+
//#endregion
|
|
17
20
|
export { controllablePromise };
|
|
18
|
-
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=controllablePromise.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controllablePromise.mjs","sources":["../../../src/lib/controllablePromise.ts"],"sourcesContent":["import { ExtBridgeError } from \"@/error\";\n\nexport const controllablePromise = () => {\n let resolve = (): void => {\n throw new ExtBridgeError(\"Unexpected call of resolve()\");\n };\n\n let reject: (error: unknown) => void = () => {\n throw new ExtBridgeError(\"Unexpected call of reject()\");\n };\n\n const promise = new Promise<void>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n\n return [promise, resolve, reject] as const;\n};\n"],"
|
|
1
|
+
{"version":3,"file":"controllablePromise.mjs","names":[],"sources":["../../../src/lib/controllablePromise.ts"],"sourcesContent":["import { ExtBridgeError } from \"@/error\";\n\nexport const controllablePromise = () => {\n let resolve = (): void => {\n throw new ExtBridgeError(\"Unexpected call of resolve()\");\n };\n\n let reject: (error: unknown) => void = () => {\n throw new ExtBridgeError(\"Unexpected call of reject()\");\n };\n\n const promise = new Promise<void>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n\n return [promise, resolve, reject] as const;\n};\n"],"mappings":";;AAEA,IAAa,4BAA4B;CACvC,IAAI,gBAAsB;EACxB,MAAM,IAAI,eAAe,8BAA8B;CACzD;CAEA,IAAI,eAAyC;EAC3C,MAAM,IAAI,eAAe,6BAA6B;CACxD;CAOA,OAAO;EAAC,IALY,SAAe,KAAK,QAAQ;GAC9C,UAAU;GACV,SAAS;EACX,CAEQ;EAAS;EAAS;CAAM;AAClC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { useExtBridge } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { useExtBridge } from "./useExtBridge.mjs";
|
|
2
|
+
//#region src/react/hooks/useConfig.ts
|
|
3
|
+
var useConfig = () => {
|
|
4
|
+
return useExtBridge().config;
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
//#endregion
|
|
7
7
|
export { useConfig };
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=useConfig.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConfig.mjs","sources":["../../../../src/react/hooks/useConfig.ts"],"sourcesContent":["import { useExtBridge } from \"@/react/hooks/useExtBridge\";\n\nexport const useConfig = () => {\n return useExtBridge().config;\n};\n"],"
|
|
1
|
+
{"version":3,"file":"useConfig.mjs","names":[],"sources":["../../../../src/react/hooks/useConfig.ts"],"sourcesContent":["import { useExtBridge } from \"@/react/hooks/useExtBridge\";\n\nexport const useConfig = () => {\n return useExtBridge().config;\n};\n"],"mappings":";;AAEA,IAAa,kBAAkB;CAC7B,OAAO,aAAa,CAAC,CAAC;AACxB"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { getExtBridge } from
|
|
2
|
-
import { usePromise } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { getExtBridge } from "../../getExtBridge.mjs";
|
|
2
|
+
import { usePromise } from "@mittwald/react-use-promise";
|
|
3
|
+
//#region src/react/hooks/useExtBridge.ts
|
|
4
|
+
var useExtBridge = () => {
|
|
5
|
+
return usePromise(getExtBridge, []);
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
//#endregion
|
|
8
8
|
export { useExtBridge };
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=useExtBridge.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExtBridge.mjs","sources":["../../../../src/react/hooks/useExtBridge.ts"],"sourcesContent":["import { getExtBridge } from \"@/getExtBridge\";\nimport { usePromise } from \"@mittwald/react-use-promise\";\n\nexport const useExtBridge = () => {\n return usePromise(getExtBridge, []);\n};\n"],"
|
|
1
|
+
{"version":3,"file":"useExtBridge.mjs","names":[],"sources":["../../../../src/react/hooks/useExtBridge.ts"],"sourcesContent":["import { getExtBridge } from \"@/getExtBridge\";\nimport { usePromise } from \"@mittwald/react-use-promise\";\n\nexport const useExtBridge = () => {\n return usePromise(getExtBridge, []);\n};\n"],"mappings":";;;AAGA,IAAa,qBAAqB;CAChC,OAAO,WAAW,cAAc,CAAC,CAAC;AACpC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { useConfig } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { useConfig } from "./useConfig.mjs";
|
|
2
|
+
//#region src/react/hooks/useLanguage.ts
|
|
3
|
+
var useLanguage = () => useConfig().language;
|
|
4
|
+
//#endregion
|
|
5
5
|
export { useLanguage };
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=useLanguage.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLanguage.mjs","sources":["../../../../src/react/hooks/useLanguage.ts"],"sourcesContent":["import { useConfig } from \"./useConfig\";\n\nexport const useLanguage = () => useConfig().language;\n"],"
|
|
1
|
+
{"version":3,"file":"useLanguage.mjs","names":[],"sources":["../../../../src/react/hooks/useLanguage.ts"],"sourcesContent":["import { useConfig } from \"./useConfig\";\n\nexport const useLanguage = () => useConfig().language;\n"],"mappings":";;AAEA,IAAa,oBAAoB,UAAU,CAAC,CAAC"}
|
package/dist/js/react.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { useConfig } from "./react/hooks/useConfig.mjs";
|
|
2
|
+
import { useLanguage } from "./react/hooks/useLanguage.mjs";
|
|
3
|
+
import "./react/hooks/index.mjs";
|
|
4
|
+
export { useConfig, useLanguage };
|
package/dist/js/readiness.mjs
CHANGED
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { assertBrowserEnv } from
|
|
4
|
-
import { controllablePromise } from
|
|
5
|
-
import { extractHostConfig } from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}, timeoutMs);
|
|
16
|
-
return timoutPromise;
|
|
1
|
+
import { ExtBridgeError } from "./error.mjs";
|
|
2
|
+
import { parseConfig } from "./config/parse.mjs";
|
|
3
|
+
import { assertBrowserEnv } from "./lib/assertBrowserEnv.mjs";
|
|
4
|
+
import { controllablePromise } from "./lib/controllablePromise.mjs";
|
|
5
|
+
import { extractHostConfig } from "./config/extractHostConfig.mjs";
|
|
6
|
+
//#region src/readiness.ts
|
|
7
|
+
var timeoutMs = 7500;
|
|
8
|
+
var [readiness, resolveReadiness] = controllablePromise();
|
|
9
|
+
var [timoutPromise, , rejectOnTimeout] = controllablePromise();
|
|
10
|
+
var startTimeout = () => {
|
|
11
|
+
setTimeout(() => {
|
|
12
|
+
rejectOnTimeout(new ExtBridgeError(`Ext Bridge not ready after ${timeoutMs}ms`));
|
|
13
|
+
}, timeoutMs);
|
|
14
|
+
return timoutPromise;
|
|
17
15
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
16
|
+
var readinessApi = {
|
|
17
|
+
isReady: async () => {
|
|
18
|
+
assertBrowserEnv();
|
|
19
|
+
await Promise.race([readiness, startTimeout()]);
|
|
20
|
+
},
|
|
21
|
+
setIsReady: async () => {
|
|
22
|
+
const config = await mwExtBridge.connection.getConfig();
|
|
23
|
+
const parsedConfig = parseConfig(config);
|
|
24
|
+
const hostConfig = extractHostConfig(config);
|
|
25
|
+
mwExtBridge.config = {
|
|
26
|
+
...parsedConfig,
|
|
27
|
+
...hostConfig
|
|
28
|
+
};
|
|
29
|
+
resolveReadiness();
|
|
30
|
+
}
|
|
33
31
|
};
|
|
34
|
-
|
|
32
|
+
//#endregion
|
|
35
33
|
export { readinessApi };
|
|
36
|
-
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=readiness.mjs.map
|