@handofclient/embed-js 0.0.0-stage → 0.1.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/channel.d.ts +34 -0
- package/dist/channel.js +82 -0
- package/dist/embed.global.js +3 -0
- package/dist/host/defaultUi.d.ts +8 -0
- package/dist/host/defaultUi.js +109 -0
- package/dist/host/global.d.ts +15 -0
- package/dist/host/global.js +7 -0
- package/dist/host/index.d.ts +48 -0
- package/dist/host/index.js +133 -0
- package/dist/host/packageIdEncoding.d.ts +7 -0
- package/dist/host/packageIdEncoding.js +13 -0
- package/dist/host/watchdog.d.ts +12 -0
- package/dist/host/watchdog.js +19 -0
- package/dist/plugin/index.d.ts +87 -0
- package/dist/plugin/index.js +131 -0
- package/dist/plugin/resize.d.ts +7 -0
- package/dist/plugin/resize.js +26 -0
- package/dist/plugin/tokenProvider.d.ts +23 -0
- package/dist/plugin/tokenProvider.js +62 -0
- package/dist/protocol.d.ts +128 -0
- package/dist/protocol.js +36 -0
- package/package.json +37 -4
- package/README.md +0 -3
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types for the postMessage embed protocol - see docs/postmessage-protocol.md (task C1) for the
|
|
3
|
+
* normative spec. Shared verbatim between the host-side and plugin-side halves of this package so both
|
|
4
|
+
* sides can never drift on envelope/message shape.
|
|
5
|
+
*/
|
|
6
|
+
export const PROTOCOL_VERSION = 1;
|
|
7
|
+
export const MessageType = {
|
|
8
|
+
Hello: "hoc:hello",
|
|
9
|
+
Init: "hoc:init",
|
|
10
|
+
Ready: "hoc:ready",
|
|
11
|
+
Error: "hoc:error",
|
|
12
|
+
Resize: "hoc:resize",
|
|
13
|
+
Navigate: "hoc:navigate",
|
|
14
|
+
TokenRefresh: "hoc:token-refresh",
|
|
15
|
+
ContextChanged: "hoc:context-changed",
|
|
16
|
+
Telemetry: "hoc:telemetry",
|
|
17
|
+
Ui: "hoc:ui",
|
|
18
|
+
};
|
|
19
|
+
export function isEnvelope(data) {
|
|
20
|
+
if (typeof data !== "object" || data === null)
|
|
21
|
+
return false;
|
|
22
|
+
const candidate = data;
|
|
23
|
+
return (candidate.v === PROTOCOL_VERSION &&
|
|
24
|
+
typeof candidate.type === "string" &&
|
|
25
|
+
typeof candidate.msgId === "string" &&
|
|
26
|
+
typeof candidate.payload === "object" &&
|
|
27
|
+
candidate.payload !== null);
|
|
28
|
+
}
|
|
29
|
+
export function makeMsgId() {
|
|
30
|
+
return crypto.randomUUID();
|
|
31
|
+
}
|
|
32
|
+
export function makeEnvelope(type, payload, replyTo) {
|
|
33
|
+
return replyTo === undefined
|
|
34
|
+
? { v: PROTOCOL_VERSION, type, msgId: makeMsgId(), payload }
|
|
35
|
+
: { v: PROTOCOL_VERSION, type, msgId: makeMsgId(), replyTo, payload };
|
|
36
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@handofclient/embed-js",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/PanglossTechnologies/HandOfClientSDK.git",
|
|
7
|
+
"directory": "sdk/embed-js"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"description": "HandOfClient postMessage embed protocol SDK (task C1 spec at docs/postmessage-protocol.md): host-side embed.js (drop-in <script> or npm import) plus the plugin-side SDK a plugin author imports inside their own bundle.",
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
"./host": {
|
|
17
|
+
"types": "./dist/host/index.d.ts",
|
|
18
|
+
"import": "./dist/host/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./plugin": {
|
|
21
|
+
"types": "./dist/plugin/index.d.ts",
|
|
22
|
+
"import": "./dist/plugin/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc -p tsconfig.json && node build.mjs",
|
|
30
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@handofclient/api": "^0.1.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"esbuild": "^0.28.2",
|
|
37
|
+
"typescript": "^5.9.3"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/README.md
DELETED