@chat-de-hp/site 0.2.6 → 0.2.7
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/astro.js +2 -2
- package/dist/emdash-annotation.d.ts.map +1 -1
- package/dist/emdash-annotation.js +1 -5
- package/dist/internal/annotation-integration.d.ts +1 -1
- package/dist/internal/annotation-integration.d.ts.map +1 -1
- package/dist/internal/annotation-integration.js +3 -7
- package/dist/runtime/annotation-capture.d.ts +1 -1
- package/dist/runtime/annotation-capture.d.ts.map +1 -1
- package/dist/runtime/annotation-capture.js +72 -99
- package/dist/runtime/capture-contract.d.ts +10 -10
- package/dist/runtime/capture-contract.d.ts.map +1 -1
- package/dist/runtime/capture-contract.js +22 -12
- package/dist/runtime/contracts.d.ts +0 -2
- package/dist/runtime/contracts.d.ts.map +1 -1
- package/dist/runtime/contracts.js +1 -2
- package/dist/runtime/index.d.ts +0 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +0 -1
- package/package.json +1 -5
package/dist/astro.js
CHANGED
|
@@ -3,7 +3,7 @@ import react from "@astrojs/react";
|
|
|
3
3
|
import { d1, r2 } from "@emdash-cms/cloudflare";
|
|
4
4
|
import { defineConfig } from "astro/config";
|
|
5
5
|
import emdash from "emdash/astro";
|
|
6
|
-
import {
|
|
6
|
+
import { createPublicAnnotationsIntegration } from "./internal/annotation-integration.js";
|
|
7
7
|
import { createApprovedAstroPlugins } from "./internal/astro-plugins.js";
|
|
8
8
|
import { resolveSiteDefinition } from "./internal/registry.js";
|
|
9
9
|
const SITE_ASTRO_OPTION_KEYS = [
|
|
@@ -53,7 +53,7 @@ export function createChatDeHpAstroConfig(site, options = {}) {
|
|
|
53
53
|
plugins: plugins,
|
|
54
54
|
storage: r2({ binding: "MEDIA" }),
|
|
55
55
|
}),
|
|
56
|
-
|
|
56
|
+
createPublicAnnotationsIntegration(),
|
|
57
57
|
],
|
|
58
58
|
output: "server",
|
|
59
59
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emdash-annotation.d.ts","sourceRoot":"","sources":["../src/emdash-annotation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAEhB,WAAW,EACX,mBAAmB,EACpB,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"emdash-annotation.d.ts","sourceRoot":"","sources":["../src/emdash-annotation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAEhB,WAAW,EACX,mBAAmB,EACpB,MAAM,QAAQ,CAAC;AAGhB,cAAc,QAAQ,CAAC;AAEvB,wBAAsB,mBAAmB,CACvC,CAAC,SAAS,MAAM,EAChB,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,EAC1B,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAMlE;AAED,wBAAsB,cAAc,CAClC,CAAC,SAAS,MAAM,EAChB,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,EAC1B,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAU7E"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { createEditable, getEmDashCollection as getPublishedEmDashCollection, getEmDashEntry as getPublishedEmDashEntry, } from "emdash";
|
|
2
|
-
import { isAnnotationMode } from "./internal/annotation-context.js";
|
|
3
2
|
// oxlint-disable-next-line no-barrel-file -- this compatibility module preserves the existing EmDash API while overriding only its two content queries
|
|
4
3
|
export * from "emdash";
|
|
5
4
|
export async function getEmDashCollection(type, filter) {
|
|
6
5
|
const result = await getPublishedEmDashCollection(type, filter);
|
|
7
|
-
if (!isAnnotationMode()) {
|
|
8
|
-
return result;
|
|
9
|
-
}
|
|
10
6
|
return {
|
|
11
7
|
...result,
|
|
12
8
|
entries: result.entries.map((entry) => annotateEntry(type, entry)),
|
|
@@ -14,7 +10,7 @@ export async function getEmDashCollection(type, filter) {
|
|
|
14
10
|
}
|
|
15
11
|
export async function getEmDashEntry(type, id, options) {
|
|
16
12
|
const result = await getPublishedEmDashEntry(type, id, options);
|
|
17
|
-
if (!
|
|
13
|
+
if (!result.entry) {
|
|
18
14
|
return result;
|
|
19
15
|
}
|
|
20
16
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotation-integration.d.ts","sourceRoot":"","sources":["../../src/internal/annotation-integration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAK9C,wBAAgB
|
|
1
|
+
{"version":3,"file":"annotation-integration.d.ts","sourceRoot":"","sources":["../../src/internal/annotation-integration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAK9C,wBAAgB,kCAAkC,IAAI,gBAAgB,CAiBrE"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
const ANNOTATION_INTEGRATION_NAME = "@chat-de-hp/site/
|
|
2
|
-
export function
|
|
1
|
+
const ANNOTATION_INTEGRATION_NAME = "@chat-de-hp/site/public-annotations";
|
|
2
|
+
export function createPublicAnnotationsIntegration() {
|
|
3
3
|
return {
|
|
4
4
|
hooks: {
|
|
5
|
-
"astro:config:setup": ({
|
|
6
|
-
addMiddleware({
|
|
7
|
-
entrypoint: "@chat-de-hp/site/annotation-middleware",
|
|
8
|
-
order: "pre",
|
|
9
|
-
});
|
|
5
|
+
"astro:config:setup": ({ injectScript, updateConfig }) => {
|
|
10
6
|
injectScript("page", 'import "@chat-de-hp/site/runtime/annotation-capture";');
|
|
11
7
|
updateConfig({
|
|
12
8
|
vite: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function startAnnotationCapture(): () => void;
|
|
2
2
|
//# sourceMappingURL=annotation-capture.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotation-capture.d.ts","sourceRoot":"","sources":["../../src/runtime/annotation-capture.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"annotation-capture.d.ts","sourceRoot":"","sources":["../../src/runtime/annotation-capture.ts"],"names":[],"mappings":"AAkBA,wBAAgB,sBAAsB,eA2DrC"}
|
|
@@ -1,69 +1,61 @@
|
|
|
1
|
-
import { isExpectedSiteCaptureParentMessage,
|
|
1
|
+
import { isExpectedSiteCaptureParentMessage, SITE_CAPTURE_BOOT_PAGE_HASH_PARAM, SITE_CAPTURE_BOOT_PARENT_ORIGIN_PARAM, SITE_CAPTURE_MESSAGE_TYPE, SITE_CAPTURE_SESSION_STORAGE_KEY, } from "./capture-contract.js";
|
|
2
2
|
import { freezeCaptureViewport } from "./capture-viewport.js";
|
|
3
|
-
import { SITE_ANNOTATION_END_PARAM } from "./contracts.js";
|
|
4
3
|
import { extractElements } from "./element-extractor.js";
|
|
5
4
|
let captureFrozen = false;
|
|
6
|
-
let endSessionPromise = null;
|
|
7
5
|
let resumeViewport = null;
|
|
8
|
-
function startAnnotationCapture() {
|
|
6
|
+
export function startAnnotationCapture() {
|
|
9
7
|
if (window.parent === window) {
|
|
10
|
-
return;
|
|
8
|
+
return () => { };
|
|
11
9
|
}
|
|
12
10
|
const session = readCaptureSession();
|
|
13
11
|
if (!session) {
|
|
14
|
-
return;
|
|
12
|
+
return () => { };
|
|
15
13
|
}
|
|
16
|
-
|
|
14
|
+
const onMessage = (event) => {
|
|
17
15
|
if (!isExpectedSiteCaptureParentMessage(event, {
|
|
18
|
-
nonce: session.nonce,
|
|
19
16
|
origin: session.parentOrigin,
|
|
20
17
|
source: window.parent,
|
|
21
18
|
})) {
|
|
22
19
|
return;
|
|
23
20
|
}
|
|
21
|
+
if (event.data.type === SITE_CAPTURE_MESSAGE_TYPE.reload) {
|
|
22
|
+
window.location.reload();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
24
25
|
if (event.data.type === SITE_CAPTURE_MESSAGE_TYPE.end) {
|
|
25
|
-
|
|
26
|
+
cleanup();
|
|
27
|
+
endAnnotationSession(session, true);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (event.data.type === SITE_CAPTURE_MESSAGE_TYPE.probe) {
|
|
31
|
+
postReady(session);
|
|
26
32
|
return;
|
|
27
33
|
}
|
|
28
34
|
if (event.data.type === SITE_CAPTURE_MESSAGE_TYPE.resume) {
|
|
29
35
|
resumeViewport?.();
|
|
30
36
|
resumeViewport = null;
|
|
31
37
|
captureFrozen = false;
|
|
32
|
-
|
|
33
|
-
nonce: session.nonce,
|
|
34
|
-
pagePath: currentPagePath(),
|
|
35
|
-
type: SITE_CAPTURE_MESSAGE_TYPE.ready,
|
|
36
|
-
});
|
|
38
|
+
postReady(session);
|
|
37
39
|
return;
|
|
38
40
|
}
|
|
39
41
|
if (captureFrozen) {
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
nonce: session.nonce,
|
|
58
|
-
type: SITE_CAPTURE_MESSAGE_TYPE.error,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
postToParent(session, {
|
|
63
|
-
nonce: session.nonce,
|
|
64
|
-
pagePath: currentPagePath(),
|
|
65
|
-
type: SITE_CAPTURE_MESSAGE_TYPE.ready,
|
|
66
|
-
});
|
|
44
|
+
captureCurrentViewport(session);
|
|
45
|
+
};
|
|
46
|
+
const onBeforeUnload = () => {
|
|
47
|
+
postToParent(session, {
|
|
48
|
+
type: SITE_CAPTURE_MESSAGE_TYPE.loading,
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
window.addEventListener("message", onMessage);
|
|
52
|
+
window.addEventListener("beforeunload", onBeforeUnload);
|
|
53
|
+
const cleanup = () => {
|
|
54
|
+
window.removeEventListener("message", onMessage);
|
|
55
|
+
window.removeEventListener("beforeunload", onBeforeUnload);
|
|
56
|
+
};
|
|
57
|
+
postReady(session);
|
|
58
|
+
return cleanup;
|
|
67
59
|
}
|
|
68
60
|
function readCaptureSession() {
|
|
69
61
|
const bootstrap = readCaptureBootstrap();
|
|
@@ -85,18 +77,14 @@ function readCaptureSession() {
|
|
|
85
77
|
}
|
|
86
78
|
function readCaptureBootstrap() {
|
|
87
79
|
const hash = new URLSearchParams(window.location.hash.slice(1));
|
|
88
|
-
const nonce = hash.get(SITE_CAPTURE_BOOT_NONCE_PARAM);
|
|
89
80
|
const parentOrigin = normalizeOrigin(hash.get(SITE_CAPTURE_BOOT_PARENT_ORIGIN_PARAM));
|
|
90
|
-
if (!
|
|
91
|
-
nonce.length <= 256 &&
|
|
92
|
-
parentOrigin &&
|
|
93
|
-
parentOrigin === readAllowedParentOrigin())) {
|
|
81
|
+
if (!parentOrigin) {
|
|
94
82
|
return null;
|
|
95
83
|
}
|
|
96
84
|
const pageHash = hash.get(SITE_CAPTURE_BOOT_PAGE_HASH_PARAM);
|
|
97
85
|
const nextUrl = `${window.location.pathname}${window.location.search}${pageHash ? `#${pageHash}` : ""}`;
|
|
98
86
|
window.history.replaceState(window.history.state, "", nextUrl);
|
|
99
|
-
return {
|
|
87
|
+
return { parentOrigin };
|
|
100
88
|
}
|
|
101
89
|
function parseStoredSession(value) {
|
|
102
90
|
if (!value) {
|
|
@@ -107,15 +95,8 @@ function parseStoredSession(value) {
|
|
|
107
95
|
if (!parsed || typeof parsed !== "object") {
|
|
108
96
|
return null;
|
|
109
97
|
}
|
|
110
|
-
const nonce = Reflect.get(parsed, "nonce");
|
|
111
98
|
const parentOrigin = normalizeOrigin(Reflect.get(parsed, "parentOrigin"));
|
|
112
|
-
return
|
|
113
|
-
nonce.trim() &&
|
|
114
|
-
nonce.length <= 256 &&
|
|
115
|
-
parentOrigin &&
|
|
116
|
-
parentOrigin === readAllowedParentOrigin()
|
|
117
|
-
? { nonce, parentOrigin }
|
|
118
|
-
: null;
|
|
99
|
+
return parentOrigin ? { parentOrigin } : null;
|
|
119
100
|
}
|
|
120
101
|
catch {
|
|
121
102
|
return null;
|
|
@@ -137,61 +118,53 @@ function normalizeOrigin(value) {
|
|
|
137
118
|
return null;
|
|
138
119
|
}
|
|
139
120
|
}
|
|
140
|
-
function readAllowedParentOrigin() {
|
|
141
|
-
for (const item of document.cookie.split(";")) {
|
|
142
|
-
const separator = item.indexOf("=");
|
|
143
|
-
if (separator < 1) {
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
if (item.slice(0, separator).trim() === SITE_CAPTURE_PARENT_ORIGIN_COOKIE) {
|
|
147
|
-
try {
|
|
148
|
-
return normalizeOrigin(decodeURIComponent(item.slice(separator + 1).trim()));
|
|
149
|
-
}
|
|
150
|
-
catch {
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
121
|
function currentPagePath() {
|
|
158
122
|
return `${window.location.pathname}${window.location.search}${window.location.hash}`;
|
|
159
123
|
}
|
|
124
|
+
function captureCurrentViewport(session) {
|
|
125
|
+
try {
|
|
126
|
+
const root = document.body ?? document.documentElement;
|
|
127
|
+
const elements = extractElements(root);
|
|
128
|
+
resumeViewport = freezeCaptureViewport();
|
|
129
|
+
captureFrozen = true;
|
|
130
|
+
postToParent(session, {
|
|
131
|
+
elements,
|
|
132
|
+
pagePath: currentPagePath(),
|
|
133
|
+
type: SITE_CAPTURE_MESSAGE_TYPE.captured,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
postToParent(session, {
|
|
138
|
+
message: "画面を読み取れませんでした。",
|
|
139
|
+
type: SITE_CAPTURE_MESSAGE_TYPE.error,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
160
143
|
function endAnnotationSession(session, notifyParent) {
|
|
161
|
-
|
|
162
|
-
|
|
144
|
+
resumeViewport?.();
|
|
145
|
+
resumeViewport = null;
|
|
146
|
+
captureFrozen = false;
|
|
147
|
+
try {
|
|
148
|
+
window.sessionStorage.removeItem(SITE_CAPTURE_SESSION_STORAGE_KEY);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
// The capture bridge is inactive after its message listeners are removed.
|
|
152
|
+
}
|
|
153
|
+
if (notifyParent) {
|
|
154
|
+
postToParent(session, {
|
|
155
|
+
type: SITE_CAPTURE_MESSAGE_TYPE.ended,
|
|
156
|
+
});
|
|
163
157
|
}
|
|
164
|
-
endSessionPromise = (async () => {
|
|
165
|
-
try {
|
|
166
|
-
window.sessionStorage.removeItem(SITE_CAPTURE_SESSION_STORAGE_KEY);
|
|
167
|
-
}
|
|
168
|
-
catch {
|
|
169
|
-
// The server-side cookie expiration remains authoritative.
|
|
170
|
-
}
|
|
171
|
-
const endUrl = new URL(window.location.href);
|
|
172
|
-
endUrl.hash = "";
|
|
173
|
-
endUrl.search = "";
|
|
174
|
-
endUrl.searchParams.set(SITE_ANNOTATION_END_PARAM, "1");
|
|
175
|
-
try {
|
|
176
|
-
await window.fetch(endUrl, {
|
|
177
|
-
cache: "no-store",
|
|
178
|
-
credentials: "same-origin",
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
finally {
|
|
182
|
-
if (notifyParent) {
|
|
183
|
-
postToParent(session, {
|
|
184
|
-
nonce: session.nonce,
|
|
185
|
-
type: SITE_CAPTURE_MESSAGE_TYPE.ended,
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
})();
|
|
190
|
-
return endSessionPromise;
|
|
191
158
|
}
|
|
192
159
|
function postToParent(session, message) {
|
|
193
160
|
window.parent.postMessage(message, session.parentOrigin);
|
|
194
161
|
}
|
|
162
|
+
function postReady(session) {
|
|
163
|
+
postToParent(session, {
|
|
164
|
+
pagePath: currentPagePath(),
|
|
165
|
+
type: SITE_CAPTURE_MESSAGE_TYPE.ready,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
195
168
|
if (document.readyState === "loading") {
|
|
196
169
|
document.addEventListener("DOMContentLoaded", startAnnotationCapture, {
|
|
197
170
|
once: true,
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { ExtractedElement } from "./element-extractor.js";
|
|
2
|
-
export declare const SITE_CAPTURE_BOOT_NONCE_PARAM = "__chat_de_hp_capture";
|
|
3
2
|
export declare const SITE_CAPTURE_BOOT_PARENT_ORIGIN_PARAM = "__chat_de_hp_capture_parent";
|
|
4
3
|
export declare const SITE_CAPTURE_BOOT_PAGE_HASH_PARAM = "__chat_de_hp_capture_page_hash";
|
|
5
|
-
export declare const SITE_CAPTURE_PARENT_ORIGIN_COOKIE = "__Host-chat-de-hp-annotation-parent";
|
|
6
4
|
export declare const SITE_CAPTURE_SESSION_STORAGE_KEY = "chat-de-hp:capture-session";
|
|
7
5
|
export declare const SITE_CAPTURE_MESSAGE_TYPE: {
|
|
8
6
|
readonly capture: "chat-de-hp:capture";
|
|
@@ -10,34 +8,36 @@ export declare const SITE_CAPTURE_MESSAGE_TYPE: {
|
|
|
10
8
|
readonly end: "chat-de-hp:end-capture";
|
|
11
9
|
readonly ended: "chat-de-hp:capture-ended";
|
|
12
10
|
readonly error: "chat-de-hp:capture-error";
|
|
11
|
+
readonly loading: "chat-de-hp:capture-loading";
|
|
12
|
+
readonly probe: "chat-de-hp:capture-probe";
|
|
13
13
|
readonly ready: "chat-de-hp:capture-ready";
|
|
14
|
+
readonly reload: "chat-de-hp:reload";
|
|
14
15
|
readonly resume: "chat-de-hp:resume-capture";
|
|
15
16
|
};
|
|
16
17
|
export type SiteCaptureParentMessage = {
|
|
17
|
-
nonce: string;
|
|
18
18
|
type: typeof SITE_CAPTURE_MESSAGE_TYPE.capture;
|
|
19
19
|
} | {
|
|
20
|
-
nonce: string;
|
|
21
20
|
type: typeof SITE_CAPTURE_MESSAGE_TYPE.end;
|
|
22
21
|
} | {
|
|
23
|
-
|
|
22
|
+
type: typeof SITE_CAPTURE_MESSAGE_TYPE.probe;
|
|
23
|
+
} | {
|
|
24
|
+
type: typeof SITE_CAPTURE_MESSAGE_TYPE.reload;
|
|
25
|
+
} | {
|
|
24
26
|
type: typeof SITE_CAPTURE_MESSAGE_TYPE.resume;
|
|
25
27
|
};
|
|
26
28
|
export type SiteCaptureFrameMessage = {
|
|
27
|
-
nonce: string;
|
|
28
29
|
pagePath: string;
|
|
29
30
|
type: typeof SITE_CAPTURE_MESSAGE_TYPE.ready;
|
|
30
31
|
} | {
|
|
31
32
|
elements: ExtractedElement[];
|
|
32
|
-
nonce: string;
|
|
33
33
|
pagePath: string;
|
|
34
34
|
type: typeof SITE_CAPTURE_MESSAGE_TYPE.captured;
|
|
35
35
|
} | {
|
|
36
36
|
message: string;
|
|
37
|
-
nonce: string;
|
|
38
37
|
type: typeof SITE_CAPTURE_MESSAGE_TYPE.error;
|
|
39
38
|
} | {
|
|
40
|
-
|
|
39
|
+
type: typeof SITE_CAPTURE_MESSAGE_TYPE.loading;
|
|
40
|
+
} | {
|
|
41
41
|
type: typeof SITE_CAPTURE_MESSAGE_TYPE.ended;
|
|
42
42
|
};
|
|
43
43
|
type CaptureMessageEvent = {
|
|
@@ -46,7 +46,6 @@ type CaptureMessageEvent = {
|
|
|
46
46
|
source: unknown;
|
|
47
47
|
};
|
|
48
48
|
type CaptureMessageExpectation = {
|
|
49
|
-
nonce: string;
|
|
50
49
|
origin: string;
|
|
51
50
|
source: unknown;
|
|
52
51
|
};
|
|
@@ -56,6 +55,7 @@ export declare function isExpectedSiteCaptureParentMessage(event: CaptureMessage
|
|
|
56
55
|
export declare function isExpectedSiteCaptureFrameMessage(event: CaptureMessageEvent, expected: CaptureMessageExpectation): event is CaptureMessageEvent & {
|
|
57
56
|
data: SiteCaptureFrameMessage;
|
|
58
57
|
};
|
|
58
|
+
export declare function isSiteCaptureFrameProtocolMessage(value: unknown): boolean;
|
|
59
59
|
export declare function isSiteCaptureParentMessage(value: unknown): value is SiteCaptureParentMessage;
|
|
60
60
|
export declare function isSiteCaptureFrameMessage(value: unknown): value is SiteCaptureFrameMessage;
|
|
61
61
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture-contract.d.ts","sourceRoot":"","sources":["../../src/runtime/capture-contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"capture-contract.d.ts","sourceRoot":"","sources":["../../src/runtime/capture-contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,eAAO,MAAM,qCAAqC,gCACnB,CAAC;AAChC,eAAO,MAAM,iCAAiC,mCACZ,CAAC;AACnC,eAAO,MAAM,gCAAgC,+BAA+B,CAAC;AAE7E,eAAO,MAAM,yBAAyB;;;;;;;;;;;CAW5B,CAAC;AAEX,MAAM,MAAM,wBAAwB,GAChC;IACE,IAAI,EAAE,OAAO,yBAAyB,CAAC,OAAO,CAAC;CAChD,GACD;IACE,IAAI,EAAE,OAAO,yBAAyB,CAAC,GAAG,CAAC;CAC5C,GACD;IACE,IAAI,EAAE,OAAO,yBAAyB,CAAC,KAAK,CAAC;CAC9C,GACD;IACE,IAAI,EAAE,OAAO,yBAAyB,CAAC,MAAM,CAAC;CAC/C,GACD;IACE,IAAI,EAAE,OAAO,yBAAyB,CAAC,MAAM,CAAC;CAC/C,CAAC;AAEN,MAAM,MAAM,uBAAuB,GAC/B;IACE,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,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
1
|
export const SITE_CAPTURE_BOOT_PARENT_ORIGIN_PARAM = "__chat_de_hp_capture_parent";
|
|
3
2
|
export const SITE_CAPTURE_BOOT_PAGE_HASH_PARAM = "__chat_de_hp_capture_page_hash";
|
|
4
|
-
export const SITE_CAPTURE_PARENT_ORIGIN_COOKIE = "__Host-chat-de-hp-annotation-parent";
|
|
5
3
|
export const SITE_CAPTURE_SESSION_STORAGE_KEY = "chat-de-hp:capture-session";
|
|
6
4
|
export const SITE_CAPTURE_MESSAGE_TYPE = {
|
|
7
5
|
capture: "chat-de-hp:capture",
|
|
@@ -9,31 +7,45 @@ export const SITE_CAPTURE_MESSAGE_TYPE = {
|
|
|
9
7
|
end: "chat-de-hp:end-capture",
|
|
10
8
|
ended: "chat-de-hp:capture-ended",
|
|
11
9
|
error: "chat-de-hp:capture-error",
|
|
10
|
+
loading: "chat-de-hp:capture-loading",
|
|
11
|
+
probe: "chat-de-hp:capture-probe",
|
|
12
12
|
ready: "chat-de-hp:capture-ready",
|
|
13
|
+
reload: "chat-de-hp:reload",
|
|
13
14
|
resume: "chat-de-hp:resume-capture",
|
|
14
15
|
};
|
|
15
16
|
export function isExpectedSiteCaptureParentMessage(event, expected) {
|
|
16
17
|
return (event.origin === expected.origin &&
|
|
17
18
|
event.source === expected.source &&
|
|
18
|
-
isSiteCaptureParentMessage(event.data)
|
|
19
|
-
event.data.nonce === expected.nonce);
|
|
19
|
+
isSiteCaptureParentMessage(event.data));
|
|
20
20
|
}
|
|
21
21
|
export function isExpectedSiteCaptureFrameMessage(event, expected) {
|
|
22
22
|
return (event.origin === expected.origin &&
|
|
23
23
|
event.source === expected.source &&
|
|
24
|
-
isSiteCaptureFrameMessage(event.data)
|
|
25
|
-
|
|
24
|
+
isSiteCaptureFrameMessage(event.data));
|
|
25
|
+
}
|
|
26
|
+
export function isSiteCaptureFrameProtocolMessage(value) {
|
|
27
|
+
if (!isRecord(value)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const { type } = value;
|
|
31
|
+
return (type === SITE_CAPTURE_MESSAGE_TYPE.captured ||
|
|
32
|
+
type === SITE_CAPTURE_MESSAGE_TYPE.ended ||
|
|
33
|
+
type === SITE_CAPTURE_MESSAGE_TYPE.error ||
|
|
34
|
+
type === SITE_CAPTURE_MESSAGE_TYPE.loading ||
|
|
35
|
+
type === SITE_CAPTURE_MESSAGE_TYPE.ready);
|
|
26
36
|
}
|
|
27
37
|
export function isSiteCaptureParentMessage(value) {
|
|
28
|
-
if (!isRecord(value)
|
|
38
|
+
if (!isRecord(value)) {
|
|
29
39
|
return false;
|
|
30
40
|
}
|
|
31
41
|
return (value.type === SITE_CAPTURE_MESSAGE_TYPE.capture ||
|
|
32
42
|
value.type === SITE_CAPTURE_MESSAGE_TYPE.end ||
|
|
43
|
+
value.type === SITE_CAPTURE_MESSAGE_TYPE.probe ||
|
|
44
|
+
value.type === SITE_CAPTURE_MESSAGE_TYPE.reload ||
|
|
33
45
|
value.type === SITE_CAPTURE_MESSAGE_TYPE.resume);
|
|
34
46
|
}
|
|
35
47
|
export function isSiteCaptureFrameMessage(value) {
|
|
36
|
-
if (!isRecord(value)
|
|
48
|
+
if (!isRecord(value)) {
|
|
37
49
|
return false;
|
|
38
50
|
}
|
|
39
51
|
if (value.type === SITE_CAPTURE_MESSAGE_TYPE.ready) {
|
|
@@ -47,7 +59,8 @@ export function isSiteCaptureFrameMessage(value) {
|
|
|
47
59
|
if (value.type === SITE_CAPTURE_MESSAGE_TYPE.error) {
|
|
48
60
|
return isNonEmptyString(value.message);
|
|
49
61
|
}
|
|
50
|
-
return value.type === SITE_CAPTURE_MESSAGE_TYPE.ended
|
|
62
|
+
return (value.type === SITE_CAPTURE_MESSAGE_TYPE.ended ||
|
|
63
|
+
value.type === SITE_CAPTURE_MESSAGE_TYPE.loading);
|
|
51
64
|
}
|
|
52
65
|
function isExtractedElement(value) {
|
|
53
66
|
if (!isRecord(value) ||
|
|
@@ -96,9 +109,6 @@ function isPagePath(value) {
|
|
|
96
109
|
!value.startsWith("//") &&
|
|
97
110
|
!value.includes("\\"));
|
|
98
111
|
}
|
|
99
|
-
function isNonce(value) {
|
|
100
|
-
return isNonEmptyString(value) && value.length <= 256;
|
|
101
|
-
}
|
|
102
112
|
function isNonEmptyString(value) {
|
|
103
113
|
return typeof value === "string" && value.trim().length > 0;
|
|
104
114
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export declare const CHAT_DE_HP_ANNOTATION_MODE_HEADER = "x-chat-de-hp-annotation-mode";
|
|
2
|
-
export declare const SITE_ANNOTATION_END_PARAM = "__chat_de_hp_annotation_end";
|
|
3
1
|
export type ChatDeHpExecutionContext = {
|
|
4
2
|
passThroughOnException?(): void;
|
|
5
3
|
waitUntil(promise: Promise<unknown>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/runtime/contracts.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/runtime/contracts.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAAG;IACrC,sBAAsB,CAAC,IAAI,IAAI,CAAC;IAChC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;KAAE,CAAC;IACxD,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CA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;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,CACJ,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,SAAS,2BAA2B,EAAE,CAAC;CACpD,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,CACH,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,QAAQ,CAAC,CAAC;CACtB,CAAC"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export const SITE_ANNOTATION_END_PARAM = "__chat_de_hp_annotation_end";
|
|
1
|
+
export {};
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { PluginBridge } from "@emdash-cms/cloudflare/sandbox";
|
|
2
2
|
export type { ChatDeHpExecutionContext, ChatDeHpRuntimeContribution, ChatDeHpRuntimeRoute, ChatDeHpSiteEnv, GeneratedSiteRuntime, } from "./contracts.js";
|
|
3
|
-
export { CHAT_DE_HP_ANNOTATION_MODE_HEADER } from "./contracts.js";
|
|
4
3
|
export { createChatDeHpSiteWorker } from "./worker.js";
|
|
5
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,YAAY,EACV,wBAAwB,EACxB,2BAA2B,EAC3B,oBAAoB,EACpB,eAAe,EACf,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,YAAY,EACV,wBAAwB,EACxB,2BAA2B,EAC3B,oBAAoB,EACpB,eAAe,EACf,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/runtime/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chat-de-hp/site",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Managed Astro site runtime and primitive composition for Chat de HP",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,10 +22,6 @@
|
|
|
22
22
|
"types": "./dist/astro.d.ts",
|
|
23
23
|
"default": "./dist/astro.js"
|
|
24
24
|
},
|
|
25
|
-
"./annotation-middleware": {
|
|
26
|
-
"types": "./dist/annotation-middleware.d.ts",
|
|
27
|
-
"default": "./dist/annotation-middleware.js"
|
|
28
|
-
},
|
|
29
25
|
"./emdash": {
|
|
30
26
|
"types": "./dist/emdash-annotation.d.ts",
|
|
31
27
|
"default": "./dist/emdash-annotation.js"
|